1
1
2
2
import type { DecimalClass , ValueType } from './utils/MiniDecimal' ;
3
- import getMiniDecimal , {
4
- roundDownUnsignedDecimal ,
5
- roundUpUnsignedDecimal ,
6
- toFixed ,
7
- } from './utils/MiniDecimal' ;
3
+ import getMiniDecimal , { toFixed } from './utils/MiniDecimal' ;
8
4
import StepHandler from './StepHandler' ;
9
- import { getNumberPrecision , num2str , trimNumber , validateNumber } from './utils/numberUtil' ;
5
+ import { getNumberPrecision , num2str , validateNumber } from './utils/numberUtil' ;
10
6
import useCursor from './hooks/useCursor' ;
11
7
import useFrame from './hooks/useFrame' ;
12
8
import type { HTMLAttributes , PropType } from 'vue' ;
@@ -33,25 +29,9 @@ const getDecimalValue = (stringMode: boolean, decimalValue: DecimalClass) => {
33
29
34
30
return decimalValue . toNumber ( ) ;
35
31
} ;
36
-
37
- const getDecimalIfValidate = ( value : ValueType , precision : number | undefined , isMax ?: boolean ) => {
32
+ const getDecimalIfValidate = ( value : ValueType ) => {
38
33
const decimal = getMiniDecimal ( value ) ;
39
- if ( decimal . isInvalidate ( ) ) {
40
- return null ;
41
- }
42
-
43
- if ( precision === undefined ) {
44
- return decimal ;
45
- }
46
-
47
- const { negative, integerStr, decimalStr, negativeStr } = trimNumber ( decimal . toString ( ) ) ;
48
- const unSignedNumberStr = integerStr + '.' + decimalStr ;
49
-
50
- if ( ( isMax && ! negative ) || ( ! isMax && negative ) ) {
51
- return getMiniDecimal ( negativeStr + roundDownUnsignedDecimal ( unSignedNumberStr , precision ) ) ;
52
- } else {
53
- return getMiniDecimal ( negativeStr + roundUpUnsignedDecimal ( unSignedNumberStr , precision ) ) ;
54
- }
34
+ return decimal . isInvalidate ( ) ? null : decimal ;
55
35
} ;
56
36
57
37
export const inputNumberProps = {
@@ -210,8 +190,8 @@ export default defineComponent({
210
190
}
211
191
212
192
// >>> Max & Min limit
213
- const maxDecimal = computed ( ( ) => getDecimalIfValidate ( props . max , props . precision , true ) ) ;
214
- const minDecimal = computed ( ( ) => getDecimalIfValidate ( props . min , props . precision , false ) ) ;
193
+ const maxDecimal = computed ( ( ) => getDecimalIfValidate ( props . max ) ) ;
194
+ const minDecimal = computed ( ( ) => getDecimalIfValidate ( props . min ) ) ;
215
195
216
196
const upDisabled = computed ( ( ) => {
217
197
if ( ! maxDecimal . value || ! decimalValue . value || decimalValue . value . isInvalidate ( ) ) {
0 commit comments