File tree 1 file changed +7
-1
lines changed
1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export default class NumberFormat {
33
33
input : Input
34
34
number : Input
35
35
isClean : boolean
36
+ isCustomDecimal : boolean
36
37
preSurRegExp : RegExp
37
38
numberRegExp : RegExp
38
39
cleanRegExp : RegExp
@@ -53,6 +54,7 @@ export default class NumberFormat {
53
54
this . numberRegExp = new RegExp ( `[^0-9\\${ decimal } ]+` , 'gi' )
54
55
this . cleanRegExp = new RegExp ( '[^0-9]+' , 'gi' )
55
56
this . negativeRegExp = new RegExp ( '[^0-9\\-]+' , 'gi' )
57
+ this . isCustomDecimal = decimal !== '.'
56
58
}
57
59
58
60
isNull ( ) {
@@ -98,15 +100,19 @@ export default class NumberFormat {
98
100
99
101
numbers ( ) {
100
102
const { reverseFill, decimal } = this . options
103
+ const hasDeciaml = this . input . toString ( ) . indexOf ( decimal ) >= 0
104
+ const input = ! hasDeciaml && this . isCustomDecimal ? this . input + decimal : this . input
105
+
101
106
if ( reverseFill ) {
102
107
this . number = this . toFixed ( ) . replace ( '.' , decimal )
103
108
} else if ( typeof this . input === 'number' ) {
104
109
this . number = this . parts ( this . input . toString ( ) . replace ( '-' , '' ) , '.' ) . join ( decimal )
105
- } else if ( ! isNaN ( this . toNumber ( this . input ) ) ) {
110
+ } else if ( ! isNaN ( this . toNumber ( input ) ) ) {
106
111
this . number = this . parts ( this . input . replace ( '-' , '' ) , '.' ) . join ( decimal )
107
112
} else {
108
113
this . number = this . parts ( this . numberOnly ( ) ) . join ( decimal )
109
114
}
115
+
110
116
return this . number
111
117
}
112
118
You can’t perform that action at this time.
0 commit comments