diff --git a/packages/vant/src/field/Field.tsx b/packages/vant/src/field/Field.tsx index 4c51a4be7..6b2dd156c 100644 --- a/packages/vant/src/field/Field.tsx +++ b/packages/vant/src/field/Field.tsx @@ -70,6 +70,7 @@ import type { FieldValidationStatus, FieldValidateTrigger, FieldFormSharedProps, + FieldEnterKeyHint, } from './types'; const [name, bem] = createNamespace('field'); @@ -94,7 +95,7 @@ export const fieldSharedProps = { autocapitalize: String, autocorrect: String, errorMessage: String, - enterkeyhint: String, + enterkeyhint: String as PropType, clearTrigger: makeStringProp('focus'), formatTrigger: makeStringProp('onChange'), spellcheck: { diff --git a/packages/vant/src/field/README.md b/packages/vant/src/field/README.md index 56319c088..6a4bec8ec 100644 --- a/packages/vant/src/field/README.md +++ b/packages/vant/src/field/README.md @@ -352,7 +352,7 @@ Use `label-align` prop to align the input value, can be set to `center`, `right` | rules | Form validation rules | _FieldRule[]_ | - | | autocomplete | HTML native attribute, see [MDN - autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) | _string_ | - | | autocapitalize `v4.6.2` | HTML native attribute, see [MDN - autocapitalize](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize)
| _string_ | - | -| enterkeyhint | HTML native attribute, see [MDN - enterkeyhint](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint)
| _string_ | - | +| enterkeyhint | HTML native attribute, see [MDN - enterkeyhint](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint)
| _FieldEnterKeyHint_ | - | | spellcheck `v4.6.2` | HTML native attribute, see [MDN - spellcheck](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck)
| _boolean_ | - | | autocorrect `v4.6.2` | HTML native attribute, Safari only, see [MDN - autocorrect](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocorrect)
| _string_ | - | | inputmode `v4.9.9` | HTML native attribute, see [MDN - inputmode](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) | _string_ | Set automatically according to the `type` prop | diff --git a/packages/vant/src/field/README.zh-CN.md b/packages/vant/src/field/README.zh-CN.md index c45f690a3..4267524e3 100644 --- a/packages/vant/src/field/README.zh-CN.md +++ b/packages/vant/src/field/README.zh-CN.md @@ -381,7 +381,7 @@ export default { | rules | 表单校验规则,详见 [Form 组件](#/zh-CN/form#rule-shu-ju-jie-gou) | _FieldRule[]_ | - | | autocomplete | HTML 原生属性,用于控制自动完成功能,详见 [MDN - autocomplete](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) | _string_ | - | | autocapitalize `v4.6.2` | HTML 原生属性,用于控制文本输入时是否自动大写,此 API 仅在部分浏览器支持,详见 [MDN - autocapitalize](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autocapitalize) | _string_ | - | -| enterkeyhint | HTML 原生属性,用于控制回车键样式,此 API 仅在部分浏览器支持,详见 [MDN - enterkeyhint](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint)
| _string_ | - | +| enterkeyhint | HTML 原生属性,用于控制回车键样式,此 API 仅在部分浏览器支持,详见 [MDN - enterkeyhint](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/enterkeyhint)
| _FieldEnterKeyHint_ | - | | spellcheck `v4.6.2` | HTML 原生属性,用于检查元素的拼写错误,此 API 仅在部分浏览器支持,详见 [MDN - spellcheck](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/spellcheck)
| _boolean_ | - | | autocorrect `v4.6.2` | HTML 原生属性,仅 Safari 适用,用于自动更正输入的文本,详见 [MDN - autocorrect](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocorrect)
| _string_ | - | | inputmode `v4.9.9` | HTML 原生属性,用于指定输入框的输入模式,详见 [MDN - inputmode](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode) | _string_ | 根据 `type` 属性自动设置 | diff --git a/packages/vant/src/field/index.ts b/packages/vant/src/field/index.ts index 77636e729..6c64d9ac6 100644 --- a/packages/vant/src/field/index.ts +++ b/packages/vant/src/field/index.ts @@ -20,6 +20,7 @@ export type { FieldAutosizeConfig, FieldValidateTrigger, FieldValidationStatus, + FieldEnterKeyHint, } from './types'; declare module 'vue' { diff --git a/packages/vant/src/field/types.ts b/packages/vant/src/field/types.ts index e373370fa..3528baf81 100644 --- a/packages/vant/src/field/types.ts +++ b/packages/vant/src/field/types.ts @@ -36,6 +36,15 @@ export type FieldFormatTrigger = 'onBlur' | 'onChange'; export type FieldValidateTrigger = 'onBlur' | 'onChange' | 'onSubmit'; +export type FieldEnterKeyHint = + | 'search' + | 'done' + | 'enter' + | 'go' + | 'next' + | 'previous' + | 'send'; + export type FieldAutosizeConfig = { maxHeight?: number; minHeight?: number;