mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-04-06 14:30:46 +08:00
fix(input-number): the problem that the negative sign is replaced when the negative sign is entered (#6281)
Co-authored-by: 07akioni <07akioni2@gmail.com>
This commit is contained in:
parent
5c2b9d6ac9
commit
968f3bbd6c
@ -7,6 +7,7 @@
|
||||
### Fixes
|
||||
|
||||
- Fix `n-time-picker`'s `use-12-hours` type error warning, closes [#4308](https://github.com/tusen-ai/naive-ui/issues/4308)
|
||||
- Fix `input-number` the problem that the negative sign is replaced when the negative sign is entered
|
||||
|
||||
### Features
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
### Fixes
|
||||
|
||||
- `n-time-picker` 的 `use-12-hours` 类型错误警告,关闭 [#4308](https://github.com/tusen-ai/naive-ui/issues/4308)
|
||||
- 修复 `input-number` 存在负号时被替换的问题
|
||||
|
||||
### Features
|
||||
|
||||
|
@ -13,10 +13,12 @@ export function parse(value: string): number | null {
|
||||
|
||||
// can be parsed to number but shouldn't be applied when inputing
|
||||
// when value includes `.`, ending with 0 and`.`, doesn't update, if 0 parse func will remove 0
|
||||
// allow negative sign
|
||||
export function isWipValue(value: string): boolean {
|
||||
return (
|
||||
value.includes('.')
|
||||
&& (/^(-)?\d+.*(\.|0)$/.test(value) || /^\.\d+$/.test(value))
|
||||
value === '-'
|
||||
|| (value.includes('.') && /^-?\d*\.?\d*$/.test(value))
|
||||
|| /^-?\d*$/.test(value)
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user