feat(components): [input] native inputmode prop for el-input & el-input-number (#14997)

* feat(components): add native inputmode for el-input

* feat(components): add native inputmode for el-input-number
 Please enter the commit message for your changes. Lines starting

* chore: rm "props" in template
This commit is contained in:
fratzinger
2025-06-20 14:24:26 +02:00
committed by GitHub
parent 4dbb805181
commit bc7773b673
6 changed files with 21 additions and 3 deletions

View File

@ -119,6 +119,7 @@ input-number/with-prefix-suffix
| value-on-clear ^(2.2.0) | value should be set when input box is cleared | ^[number] / ^[null] / ^[enum]`'min' \| 'max'` | — | | value-on-clear ^(2.2.0) | value should be set when input box is cleared | ^[number] / ^[null] / ^[enum]`'min' \| 'max'` | — |
| validate-event | whether to trigger form validation | ^[boolean] | true | | validate-event | whether to trigger form validation | ^[boolean] | true |
| label ^(a11y) ^(deprecated) | same as `aria-label` in native input | ^[string] | — | | label ^(a11y) ^(deprecated) | same as `aria-label` in native input | ^[string] | — |
| inputmode ^(2.10.3) | same as `inputmode` in native input | ^[string] | — |
### Slots ### Slots

View File

@ -151,6 +151,7 @@ input/length-limiting
| validate-event | whether to trigger form validation | ^[boolean] | true | | validate-event | whether to trigger form validation | ^[boolean] | true |
| input-style | the style of the input element or textarea element | ^[string] / ^[object]`CSSProperties \| CSSProperties[] \| string[]` | {} | | input-style | the style of the input element or textarea element | ^[string] / ^[object]`CSSProperties \| CSSProperties[] \| string[]` | {} |
| label ^(a11y) ^(deprecated) | same as `aria-label` in native input | ^[string] | — | | label ^(a11y) ^(deprecated) | same as `aria-label` in native input | ^[string] | — |
| inputmode ^(2.10.3) | same as `inputmode` in native input | ^[string] | — |
### Events ### Events

View File

@ -1,13 +1,13 @@
import { isNil } from 'lodash-unified' import { isNil } from 'lodash-unified'
import { useAriaProps, useSizeProp } from '@element-plus/hooks' import { useAriaProps, useSizeProp } from '@element-plus/hooks'
import { buildProps, isNumber } from '@element-plus/utils' import { buildProps, definePropType, isNumber } from '@element-plus/utils'
import { import {
CHANGE_EVENT, CHANGE_EVENT,
INPUT_EVENT, INPUT_EVENT,
UPDATE_MODEL_EVENT, UPDATE_MODEL_EVENT,
} from '@element-plus/constants' } from '@element-plus/constants'
import type { ExtractPropTypes } from 'vue' import type { ExtractPropTypes, HTMLAttributes } from 'vue'
import type InputNumber from './input-number.vue' import type InputNumber from './input-number.vue'
export const inputNumberProps = buildProps({ export const inputNumberProps = buildProps({
@ -109,6 +109,13 @@ export const inputNumberProps = buildProps({
default: true, default: true,
}, },
...useAriaProps(['ariaLabel']), ...useAriaProps(['ariaLabel']),
/**
* @description native input mode for virtual keyboards
*/
inputmode: {
type: definePropType<HTMLAttributes['inputmode']>(String),
default: undefined,
},
} as const) } as const)
export type InputNumberProps = ExtractPropTypes<typeof inputNumberProps> export type InputNumberProps = ExtractPropTypes<typeof inputNumberProps>

View File

@ -54,6 +54,7 @@
:name="name" :name="name"
:aria-label="ariaLabel" :aria-label="ariaLabel"
:validate-event="false" :validate-event="false"
:inputmode="inputmode"
@keydown.up.prevent="increase" @keydown.up.prevent="increase"
@keydown.down.prevent="decrease" @keydown.down.prevent="decrease"
@blur="handleBlur" @blur="handleBlur"

View File

@ -8,7 +8,7 @@ import {
import { UPDATE_MODEL_EVENT } from '@element-plus/constants' import { UPDATE_MODEL_EVENT } from '@element-plus/constants'
import { useAriaProps, useSizeProp } from '@element-plus/hooks' import { useAriaProps, useSizeProp } from '@element-plus/hooks'
import type { ExtractPropTypes, StyleValue } from 'vue' import type { ExtractPropTypes, HTMLAttributes, StyleValue } from 'vue'
export type InputAutoSize = { minRows?: number; maxRows?: number } | boolean export type InputAutoSize = { minRows?: number; maxRows?: number } | boolean
@ -168,6 +168,13 @@ export const inputProps = buildProps({
default: 2, default: 2,
}, },
...useAriaProps(['ariaLabel']), ...useAriaProps(['ariaLabel']),
/**
* @description native input mode for virtual keyboards
*/
inputmode: {
type: definePropType<HTMLAttributes['inputmode']>(String),
default: undefined,
},
} as const) } as const)
export type InputProps = ExtractPropTypes<typeof inputProps> export type InputProps = ExtractPropTypes<typeof inputProps>

View File

@ -47,6 +47,7 @@
:form="form" :form="form"
:autofocus="autofocus" :autofocus="autofocus"
:role="containerRole" :role="containerRole"
:inputmode="inputmode"
@compositionstart="handleCompositionStart" @compositionstart="handleCompositionStart"
@compositionupdate="handleCompositionUpdate" @compositionupdate="handleCompositionUpdate"
@compositionend="handleCompositionEnd" @compositionend="handleCompositionEnd"