diginet-core-ui 1.4.52-beta.6 → 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.
|
@@ -99,13 +99,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
99
99
|
|
|
100
100
|
// if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
101
101
|
|
|
102
|
-
/**
|
|
103
|
-
* Convert number to format money
|
|
104
|
-
* @param vl {number} - value
|
|
105
|
-
* @type {function}
|
|
106
|
-
* @return {string}
|
|
107
|
-
* @example 1200300.123 => 1,200,300.123
|
|
108
|
-
* @example 1200300,123 => 1.200.300,123
|
|
102
|
+
/**
|
|
103
|
+
* Convert number to format money
|
|
104
|
+
* @param vl {number} - value
|
|
105
|
+
* @type {function}
|
|
106
|
+
* @return {string}
|
|
107
|
+
* @example 1200300.123 => 1,200,300.123
|
|
108
|
+
* @example 1200300,123 => 1.200.300,123
|
|
109
109
|
*/
|
|
110
110
|
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
111
111
|
var _number, _number2, _number$, _number3;
|
|
@@ -153,13 +153,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
153
153
|
return number;
|
|
154
154
|
}, [decimalSymbol, max, value, decimalDigit, fixedDecimalDigit]);
|
|
155
155
|
|
|
156
|
-
/**
|
|
157
|
-
* Convert money to format number
|
|
158
|
-
* @param vl {string} - value
|
|
159
|
-
* @type {function}
|
|
160
|
-
* @return {number}
|
|
161
|
-
* @example 1,200,300.123 => 1200300.123
|
|
162
|
-
* @example 1.200.300,123 => 1200300.123
|
|
156
|
+
/**
|
|
157
|
+
* Convert money to format number
|
|
158
|
+
* @param vl {string} - value
|
|
159
|
+
* @type {function}
|
|
160
|
+
* @return {number}
|
|
161
|
+
* @example 1,200,300.123 => 1200300.123
|
|
162
|
+
* @example 1.200.300,123 => 1200300.123
|
|
163
163
|
*/
|
|
164
164
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
165
165
|
var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
|
|
@@ -285,11 +285,18 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
285
285
|
};
|
|
286
286
|
const _onChange = e => {
|
|
287
287
|
if (delayOnChange) {
|
|
288
|
+
var _e$target;
|
|
288
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
|
+
}
|
|
289
299
|
inputTimer.current = setTimeout(() => {
|
|
290
|
-
const target = e.target;
|
|
291
|
-
target.value = globalRef.current.valueString;
|
|
292
|
-
target.valueString = globalRef.current.returnValue;
|
|
293
300
|
onChange({
|
|
294
301
|
...e,
|
|
295
302
|
value: globalRef.current.value,
|
|
@@ -318,20 +325,19 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
318
325
|
setError(errorProp);
|
|
319
326
|
}
|
|
320
327
|
}, [value]);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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]);
|
|
335
341
|
useEffect(() => {
|
|
336
342
|
setError(errorProp);
|
|
337
343
|
}, [errorProp]);
|
|
@@ -487,10 +493,10 @@ NumberInput.propTypes = {
|
|
|
487
493
|
style: PropTypes.object,
|
|
488
494
|
/** Thousand separator character. */
|
|
489
495
|
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
490
|
-
/** Validation value, argument can:<br/>
|
|
491
|
-
* * string: the validation rule. Example required.<br/>
|
|
492
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
493
|
-
* * array: the validation rule list, insist object/string
|
|
496
|
+
/** Validation value, argument can:<br/>
|
|
497
|
+
* * string: the validation rule. Example required.<br/>
|
|
498
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
499
|
+
* * array: the validation rule list, insist object/string
|
|
494
500
|
*/
|
|
495
501
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
496
502
|
/** The value of the input element, required for a controlled component. */
|