From 4baa3bda267233c45d15717bc8765587901447b3 Mon Sep 17 00:00:00 2001 From: zhouyun Date: Thu, 17 Oct 2024 20:59:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(input):=20=E4=BF=AE=E5=A4=8D=20type=3D"X"?= =?UTF-8?q?=20=E6=97=B6=E6=9C=80=E5=90=8E=E4=B8=80=E4=BD=8D=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=BE=93=E5=85=A5=20X=20=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#3023)=20(#3024)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(input): 修复 type="X" 时最后一位无法输入 X 的问题 (#3023) * chore(input): type 类型中增加 number 类型 * chore(input): 增加变更记录文件 --- .changeset/fresh-scissors-complain.md | 7 +++++++ packages/ui/input/src/types.ts | 10 +++++++++- packages/ui/input/src/utils/index.ts | 4 ++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/fresh-scissors-complain.md 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) }