Skip to content

Commit ddf0440

Browse files
author
xueyuan
committed
feat(input): add select method and clean up redundant code
- Add select() method to Input component for programmatic text selection - Clean up redundant keyboard event handlers in examples and docs - Fix variable naming consistency in documentation - Remove unused handleEnter functions and value15 variables - Update type definitions to include select method
1 parent 47bf2e5 commit ddf0440

5 files changed

Lines changed: 6 additions & 25 deletions

File tree

packages/varlet-ui/src/input/docs/en-US.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const value12 = ref('')
2626
const value13 = ref('')
2727
const value14 = ref('')
2828
const value15 = ref('')
29-
const value16 = ref('')
3029
const inputRef = ref()
3130
3231
const selectAll = () => {
@@ -80,7 +79,7 @@ const selectAll = () => {
8079
<var-input
8180
ref="inputRef"
8281
placeholder="Enter text and click the button to select all"
83-
v-model="value16"
82+
v-model="value15"
8483
/>
8584
<var-button type="primary" @click="selectAll">Select All</var-button>
8685
</var-space>
@@ -120,7 +119,6 @@ const value12 = ref('')
120119
const value13 = ref('')
121120
const value14 = ref('')
122121
const value15 = ref('')
123-
const value16 = ref('')
124122
const inputRef = ref()
125123
126124
const selectAll = () => {
@@ -180,7 +178,7 @@ const selectAll = () => {
180178
<var-input
181179
ref="inputRef"
182180
placeholder="Enter text and click the button to select all"
183-
v-model="value16"
181+
v-model="value15"
184182
/>
185183
<var-button type="primary" @click="selectAll">Select All</var-button>
186184
</var-space>

packages/varlet-ui/src/input/docs/zh-CN.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,8 @@ const value12 = ref('')
2727
const value13 = ref('')
2828
const value14 = ref('')
2929
const value15 = ref('')
30-
const value16 = ref('')
3130
const inputRef = ref()
3231
33-
const handleEnter = (value) => {
34-
Snackbar.info(`回车键被按下,当前值:${value}`)
35-
}
36-
3732
const selectAll = () => {
3833
inputRef.value?.select()
3934
}
@@ -85,7 +80,7 @@ const selectAll = () => {
8580
<var-input
8681
ref="inputRef"
8782
placeholder="输入文本后点击按钮全选"
88-
v-model="value16"
83+
v-model="value15"
8984
/>
9085
<var-button type="primary" @click="selectAll">全选</var-button>
9186
</var-space>

packages/varlet-ui/src/input/example/index.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const standardValue12 = ref('')
1919
const standardValue13 = ref('')
2020
const standardValue14 = ref('')
2121
const standardValue15 = ref('')
22-
const standardValue16 = ref('')
2322
2423
const outlinedValue = ref('')
2524
const outlinedValue2 = ref('')
@@ -38,14 +37,6 @@ const outlinedValue14 = ref('')
3837
3938
const inputRef = ref()
4039
41-
const handleEnter = (value, e) => {
42-
Snackbar.info(`回车键被按下,当前值:${value}`)
43-
}
44-
45-
const handleKeydown = (e) => {
46-
console.log('keydown:', e.key)
47-
}
48-
4940
const selectAll = () => {
5041
inputRef.value?.select()
5142
}
@@ -94,9 +85,8 @@ onThemeChange()
9485
<var-input v-model="standardValue10" :placeholder="t('textarea')" textarea />
9586
<var-input v-model="standardValue11" :placeholder="t('smallSize')" size="small" />
9687
<var-input v-model.trim="standardValue12" :placeholder="t('trim')" />
97-
<var-input v-model="standardValue15" :placeholder="t('enterKey')" @enter="handleEnter" @keydown="handleKeydown" />
9888
<var-space>
99-
<var-input ref="inputRef" v-model="standardValue16" :placeholder="t('selectAll')" />
89+
<var-input ref="inputRef" v-model="standardValue15" :placeholder="t('selectAll')" />
10090
<var-button type="primary" @click="selectAll">{{ t('selectAllButton') }}</var-button>
10191
</var-space>
10292
</var-space>

packages/varlet-ui/src/input/example/locale/en-US.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export default {
1717
placeholder: 'Please enter text',
1818
numberPlaceholder: 'Please enter number',
1919
maxMessage: 'Text length must be greater than 6',
20-
clearableText: 'Clearable Text',
21-
enterKey: 'Try pressing Enter',
20+
clearableText: 'Clearable text',
2221
selectAll: 'Type text and click button to select all',
2322
selectAllButton: 'Select All',
2423
}

packages/varlet-ui/src/input/example/locale/zh-CN.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export default {
1818
numberPlaceholder: '请输入数字',
1919
maxMessage: '文本长度必须大于6',
2020
clearableText: '可清除文本',
21-
enterKey: '按下回车键试试',
22-
selectAll: '输入文本后点击按钮全选',
21+
selectAll: '输入文本后点击按钮 全选',
2322
selectAllButton: '全选',
2423
}

0 commit comments

Comments
 (0)