Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(input): 修复 type="X" 时最后一位无法输入 X 的问题 (#3023) #3024

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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