diff --git a/.changeset/fresh-scissors-complain.md b/.changeset/fresh-scissors-complain.md new file mode 100644 index 000000000..426f1292e --- /dev/null +++ b/.changeset/fresh-scissors-complain.md @@ -0,0 +1,7 @@ +--- +"@hi-ui/input": patch +"@hi-ui/hiui": patch +--- + +fix(input): 修复 type="X" 时最后一位无法输入 X 的问题 (#3023) +chore(input): type 类型中增加 number 类型 diff --git a/packages/ui/input/src/types.ts b/packages/ui/input/src/types.ts index 53be8da14..0934f0703 100644 --- a/packages/ui/input/src/types.ts +++ b/packages/ui/input/src/types.ts @@ -2,4 +2,12 @@ import { HiBaseAppearanceEnum } from '@hi-ui/core' export type InputAppearanceEnum = HiBaseAppearanceEnum | 'underline' -export type InputTypeEnum = 'text' | 'id' | 'tel' | 'card' | 'amount' | 'email' | 'password' +export type InputTypeEnum = + | 'text' + | 'id' + | 'tel' + | 'card' + | 'amount' + | 'email' + | 'password' + | 'number' diff --git a/packages/ui/input/src/utils/index.ts b/packages/ui/input/src/utils/index.ts index 2b47084df..5b3995e70 100644 --- a/packages/ui/input/src/utils/index.ts +++ b/packages/ui/input/src/utils/index.ts @@ -21,6 +21,10 @@ export const formatId = (val: string) => { } export const pureId = (val: string) => { + if (/\d{6}\s\d{4}\s\d{4}\s\d{3}X/g.test(val)) { + return val + } + const tmp = val.replace(/[^\d|.]/g, '') return tmp.slice(0, 18) }