Skip to content

Commit

Permalink
fix(input): 修复 type="X" 时最后一位无法输入 X 的问题 (#3023) (#3024)
Browse files Browse the repository at this point in the history
* fix(input): 修复 type="X" 时最后一位无法输入 X 的问题 (#3023)

* chore(input): type 类型中增加 number 类型

* chore(input): 增加变更记录文件
  • Loading branch information
zyprepare authored Oct 17, 2024
1 parent 5784cff commit 4baa3bd
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/fresh-scissors-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hi-ui/input": patch
"@hi-ui/hiui": patch
---

fix(input): 修复 type="X" 时最后一位无法输入 X 的问题 (#3023)
chore(input): type 类型中增加 number 类型
10 changes: 9 additions & 1 deletion packages/ui/input/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
4 changes: 4 additions & 0 deletions packages/ui/input/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 4baa3bd

Please sign in to comment.