Skip to content

Commit c965f9e

Browse files
author
xueyuan
committed
feat(input): 添加全选功能并完善inputmode文档
1 parent 00851d4 commit c965f9e

5 files changed

Lines changed: 78 additions & 17 deletions

File tree

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

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,41 @@ const value14 = ref('')
167167
}
168168
</style>
169169
```
170+
### inputmode Demo
171+
172+
The `inputmode` attribute is used to control the type of virtual keyboard on mobile devices, providing a better user experience.
173+
174+
```html
175+
<script setup>
176+
import { ref } from 'vue'
177+
import { useTranslation } from '@varlet/ui'
178+
179+
const { t } = useTranslation()
180+
const inputmodeDecimal = ref('')
181+
const inputmodeNumeric = ref('')
182+
const inputmodeEmail = ref('')
183+
</script>
184+
185+
<template>
186+
<app-type style="margin-top: 10vmin">{{ t('inputmodeDemo') }}</app-type>
187+
<var-space direction="column" :size="['3vmin', 0]">
188+
<var-input v-model="inputmodeDecimal" inputmode="decimal" :placeholder="t('inputmodeDecimal')" />
189+
<var-input v-model="inputmodeNumeric" inputmode="numeric" :placeholder="t('inputmodeNumeric')" />
190+
<var-input v-model="inputmodeEmail" inputmode="email" :placeholder="t('inputmodeEmail')" />
191+
</var-space>
192+
</template>
193+
```
194+
195+
#### inputmode Options
196+
197+
- `decimal`: Display a numeric keypad with decimal point
198+
- `numeric`: Display a pure numeric keypad
199+
- `email`: Display a keyboard optimized for email input
200+
- `tel`: Display a telephone number keypad
201+
- `url`: Display a keyboard optimized for URL input
202+
- `search`: Display a search-optimized keyboard
203+
- `text`: Display a standard text keyboard (default)
204+
170205

171206
## API
172207

@@ -272,10 +307,4 @@ Here are the CSS variables used by the component. Styles can be customized using
272307
| `--input-input-font-size` | `16px` |
273308
| `--input-textarea-height` | `auto` |
274309

275-
### inputmode Demo
276310

277-
```html
278-
<var-input inputmode="decimal" placeholder="inputmode=decimal" />
279-
<var-input inputmode="numeric" placeholder="inputmode=numeric" />
280-
<var-input inputmode="email" placeholder="inputmode=email" />
281-
```

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

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,41 @@ const value14 = ref('')
167167
}
168168
</style>
169169
```
170+
### inputmode 演示
171+
172+
`inputmode` 属性用于控制移动端虚拟键盘的类型,提供更好的用户体验。
173+
174+
```html
175+
<script setup>
176+
import { ref } from 'vue'
177+
import { useTranslation } from '@varlet/ui'
178+
179+
const { t } = useTranslation()
180+
const inputmodeDecimal = ref('')
181+
const inputmodeNumeric = ref('')
182+
const inputmodeEmail = ref('')
183+
</script>
184+
185+
<template>
186+
<app-type style="margin-top: 10vmin">{{ t('inputmodeDemo') }}</app-type>
187+
<var-space direction="column" :size="['3vmin', 0]">
188+
<var-input v-model="inputmodeDecimal" inputmode="decimal" :placeholder="t('inputmodeDecimal')" />
189+
<var-input v-model="inputmodeNumeric" inputmode="numeric" :placeholder="t('inputmodeNumeric')" />
190+
<var-input v-model="inputmodeEmail" inputmode="email" :placeholder="t('inputmodeEmail')" />
191+
</var-space>
192+
</template>
193+
```
194+
195+
#### inputmode 可选值
196+
197+
- `decimal`: 显示包含小数点的数字键盘
198+
- `numeric`: 显示纯数字键盘
199+
- `email`: 显示适合输入邮箱地址的键盘
200+
- `tel`: 显示电话号码键盘
201+
- `url`: 显示适合输入URL的键盘
202+
- `search`: 显示搜索优化的键盘
203+
- `text`: 显示标准文本键盘(默认值)
204+
170205

171206
## API
172207

@@ -271,10 +306,3 @@ const value14 = ref('')
271306
| `--input-input-font-size` | `16px` |
272307
| `--input-textarea-height` | `auto` |
273308

274-
### inputmode 演示
275-
276-
```html
277-
<var-input inputmode="decimal" placeholder="inputmode=decimal" />
278-
<var-input inputmode="numeric" placeholder="inputmode=numeric" />
279-
<var-input inputmode="email" placeholder="inputmode=email" />
280-
```

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ onThemeChange()
130130
<var-input v-model.trim="outlinedValue12" variant="outlined" :placeholder="t('trim')" />
131131
</var-space>
132132

133-
<app-type style="margin-top: 10vmin">inputmode 演示</app-type>
133+
<app-type style="margin-top: 10vmin">{{ t('inputmodeDemo') }}</app-type>
134134
<var-space direction="column" :size="['3vmin', 0]">
135-
<var-input v-model="inputmodeDecimal" inputmode="decimal" placeholder="inputmode=decimal" />
136-
<var-input v-model="inputmodeNumeric" inputmode="numeric" placeholder="inputmode=numeric" />
137-
<var-input v-model="inputmodeEmail" inputmode="email" placeholder="inputmode=email" />
135+
<var-input v-model="inputmodeDecimal" inputmode="decimal" :placeholder="t('inputmodeDecimal')" />
136+
<var-input v-model="inputmodeNumeric" inputmode="numeric" :placeholder="t('inputmodeNumeric')" />
137+
<var-input v-model="inputmodeEmail" inputmode="email" :placeholder="t('inputmodeEmail')" />
138138
</var-space>
139139

140140
<div style="height: 40px"></div>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export default {
1818
numberPlaceholder: 'Please enter number',
1919
maxMessage: 'Text length must be greater than 6',
2020
clearableText: 'Clearable Text',
21+
selectAll: 'Select All',
22+
selectAllButton: 'Select All',
2123
inputmodeDemo: 'inputmode Demo',
2224
inputmodeDecimal: 'inputmode=decimal (decimal keyboard)',
2325
inputmodeNumeric: 'inputmode=numeric (numeric keyboard)',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ export default {
1818
numberPlaceholder: '请输入数字',
1919
maxMessage: '文本长度必须大于6',
2020
clearableText: '可清除文本',
21+
selectAll: '全选',
22+
selectAllButton: '全选',
2123
inputmodeDemo: 'inputmode 演示',
2224
inputmodeDecimal: 'inputmode=decimal(数字小数键盘)',
2325
inputmodeNumeric: 'inputmode=numeric(纯数字键盘)',

0 commit comments

Comments
 (0)