diginet-core-ui 1.4.52-beta.7 → 1.4.52-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -65,15 +65,14 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
65
65
|
style,
|
|
66
66
|
thousandSeparator,
|
|
67
67
|
validates,
|
|
68
|
-
|
|
68
|
+
value: valueProp,
|
|
69
69
|
viewType
|
|
70
70
|
} = props;
|
|
71
71
|
let max = maxProp;
|
|
72
72
|
let min = minProp;
|
|
73
73
|
let thousandSymbol = thousandSeparator;
|
|
74
74
|
let decimalSymbol = decimalSymbolProp;
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
let valueProps = valueProp;
|
|
77
76
|
if (!min && min !== 0) min = -Infinity;
|
|
78
77
|
if (!max && max !== 0) max = Infinity;
|
|
79
78
|
const pos = useRef(null);
|
|
@@ -286,11 +285,18 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
286
285
|
};
|
|
287
286
|
const _onChange = e => {
|
|
288
287
|
if (delayOnChange) {
|
|
288
|
+
var _e$target;
|
|
289
289
|
if (inputTimer.current) clearTimeout(inputTimer.current);
|
|
290
|
+
const target = e.target;
|
|
291
|
+
target.value = globalRef.current.valueString;
|
|
292
|
+
target.valueString = globalRef.current.returnValue;
|
|
293
|
+
// eslint-disable-next-line no-extra-boolean-cast
|
|
294
|
+
if (!!((_e$target = e.target) !== null && _e$target !== void 0 && _e$target.valueString)) {
|
|
295
|
+
if (e.target.valueString.includes(decimalSymbol) && e.target.valueString.split(decimalSymbol)[1] === '') {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
290
299
|
inputTimer.current = setTimeout(() => {
|
|
291
|
-
const target = e.target;
|
|
292
|
-
target.value = globalRef.current.valueString;
|
|
293
|
-
target.valueString = globalRef.current.returnValue;
|
|
294
300
|
onChange({
|
|
295
301
|
...e,
|
|
296
302
|
value: globalRef.current.value,
|
|
@@ -319,20 +325,19 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
319
325
|
setError(errorProp);
|
|
320
326
|
}
|
|
321
327
|
}, [value]);
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
328
|
+
useEffect(() => {
|
|
329
|
+
// if (typeof valueProps !== 'undefined')
|
|
330
|
+
// if (disabledNegative && Number(valueProps || 0) < 0) {
|
|
331
|
+
if (!isNaN(valueProps) || !isNaN(value)) {
|
|
332
|
+
var _valueProps;
|
|
333
|
+
if (min === 0 && Number(valueProps || 0) < 0) {
|
|
334
|
+
// nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
|
|
335
|
+
valueProps = clamp(0, min, max);
|
|
336
|
+
}
|
|
337
|
+
// setValue(valueProps);
|
|
338
|
+
setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
|
|
339
|
+
}
|
|
340
|
+
}, [valueProps, decimalDigit]);
|
|
336
341
|
useEffect(() => {
|
|
337
342
|
setError(errorProp);
|
|
338
343
|
}, [errorProp]);
|