11// base rc-input-number@7.3.4
22import 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' ;
84import StepHandler from './StepHandler' ;
9- import { getNumberPrecision , num2str , trimNumber , validateNumber } from './utils/numberUtil' ;
5+ import { getNumberPrecision , num2str , validateNumber } from './utils/numberUtil' ;
106import useCursor from './hooks/useCursor' ;
117import useFrame from './hooks/useFrame' ;
128import type { HTMLAttributes , PropType } from 'vue' ;
@@ -33,25 +29,9 @@ const getDecimalValue = (stringMode: boolean, decimalValue: DecimalClass) => {
3329
3430 return decimalValue . toNumber ( ) ;
3531} ;
36-
37- const getDecimalIfValidate = ( value : ValueType , precision : number | undefined , isMax ?: boolean ) => {
32+ const getDecimalIfValidate = ( value : ValueType ) => {
3833 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 ;
5535} ;
5636
5737export const inputNumberProps = {
@@ -210,8 +190,8 @@ export default defineComponent({
210190 }
211191
212192 // >>> 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 ) ) ;
215195
216196 const upDisabled = computed ( ( ) => {
217197 if ( ! maxDecimal . value || ! decimalValue . value || decimalValue . value . isInvalidate ( ) ) {
0 commit comments