fix: inputnumber can not input min value, close #5083
parent
41f4187593
commit
30bbd4c3b4
|
@ -1,12 +1,8 @@
|
||||||
// base rc-input-number@7.3.4
|
// base rc-input-number@7.3.4
|
||||||
import type { DecimalClass, ValueType } from './utils/MiniDecimal';
|
import type { DecimalClass, ValueType } from './utils/MiniDecimal';
|
||||||
import getMiniDecimal, {
|
import getMiniDecimal, { toFixed } from './utils/MiniDecimal';
|
||||||
roundDownUnsignedDecimal,
|
|
||||||
roundUpUnsignedDecimal,
|
|
||||||
toFixed,
|
|
||||||
} from './utils/MiniDecimal';
|
|
||||||
import StepHandler from './StepHandler';
|
import StepHandler from './StepHandler';
|
||||||
import { getNumberPrecision, num2str, trimNumber, validateNumber } from './utils/numberUtil';
|
import { getNumberPrecision, num2str, validateNumber } from './utils/numberUtil';
|
||||||
import useCursor from './hooks/useCursor';
|
import useCursor from './hooks/useCursor';
|
||||||
import useFrame from './hooks/useFrame';
|
import useFrame from './hooks/useFrame';
|
||||||
import type { HTMLAttributes, PropType } from 'vue';
|
import type { HTMLAttributes, PropType } from 'vue';
|
||||||
|
@ -33,25 +29,9 @@ const getDecimalValue = (stringMode: boolean, decimalValue: DecimalClass) => {
|
||||||
|
|
||||||
return decimalValue.toNumber();
|
return decimalValue.toNumber();
|
||||||
};
|
};
|
||||||
|
const getDecimalIfValidate = (value: ValueType) => {
|
||||||
const getDecimalIfValidate = (value: ValueType, precision: number | undefined, isMax?: boolean) => {
|
|
||||||
const decimal = getMiniDecimal(value);
|
const decimal = getMiniDecimal(value);
|
||||||
if (decimal.isInvalidate()) {
|
return decimal.isInvalidate() ? null : decimal;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (precision === undefined) {
|
|
||||||
return decimal;
|
|
||||||
}
|
|
||||||
|
|
||||||
const { negative, integerStr, decimalStr, negativeStr } = trimNumber(decimal.toString());
|
|
||||||
const unSignedNumberStr = integerStr + '.' + decimalStr;
|
|
||||||
|
|
||||||
if ((isMax && !negative) || (!isMax && negative)) {
|
|
||||||
return getMiniDecimal(negativeStr + roundDownUnsignedDecimal(unSignedNumberStr, precision));
|
|
||||||
} else {
|
|
||||||
return getMiniDecimal(negativeStr + roundUpUnsignedDecimal(unSignedNumberStr, precision));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const inputNumberProps = {
|
export const inputNumberProps = {
|
||||||
|
@ -210,8 +190,8 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
|
|
||||||
// >>> Max & Min limit
|
// >>> Max & Min limit
|
||||||
const maxDecimal = computed(() => getDecimalIfValidate(props.max, props.precision, true));
|
const maxDecimal = computed(() => getDecimalIfValidate(props.max));
|
||||||
const minDecimal = computed(() => getDecimalIfValidate(props.min, props.precision, false));
|
const minDecimal = computed(() => getDecimalIfValidate(props.min));
|
||||||
|
|
||||||
const upDisabled = computed(() => {
|
const upDisabled = computed(() => {
|
||||||
if (!maxDecimal.value || !decimalValue.value || decimalValue.value.isInvalidate()) {
|
if (!maxDecimal.value || !decimalValue.value || decimalValue.value.isInvalidate()) {
|
||||||
|
|
Loading…
Reference in New Issue