diginet-core-ui 1.4.51-beta.4 → 1.4.52-beta.0
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.
- package/components/form-control/number-input/index2.js +48 -44
- package/package.json +1 -1
- package/readme.md +11 -0
|
@@ -79,6 +79,7 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
79
79
|
const ref = useRef(null);
|
|
80
80
|
const globalRef = useRef({});
|
|
81
81
|
const inputRef = useRef(null);
|
|
82
|
+
const inputTimer = useRef(null);
|
|
82
83
|
const [value, setValue] = useState(defaultValue);
|
|
83
84
|
const [error, setError] = useState(errorProp);
|
|
84
85
|
const _NumberInputRootCSS = NumberInputRootCSS(theme);
|
|
@@ -98,13 +99,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
98
99
|
|
|
99
100
|
// if (valueProps || valueProps === 0) valueProps = clamp(valueProps, min, max);
|
|
100
101
|
|
|
101
|
-
/**
|
|
102
|
-
* Convert number to format money
|
|
103
|
-
* @param vl {number} - value
|
|
104
|
-
* @type {function}
|
|
105
|
-
* @return {string}
|
|
106
|
-
* @example 1200300.123 => 1,200,300.123
|
|
107
|
-
* @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
|
|
108
109
|
*/
|
|
109
110
|
const parseNumberToMoney = useCallback((vl, isNumber) => {
|
|
110
111
|
var _number, _number2, _number$, _number3;
|
|
@@ -149,13 +150,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
149
150
|
return number;
|
|
150
151
|
}, [decimalSymbol, max, value, decimalDigit, fixedDecimalDigit]);
|
|
151
152
|
|
|
152
|
-
/**
|
|
153
|
-
* Convert money to format number
|
|
154
|
-
* @param vl {string} - value
|
|
155
|
-
* @type {function}
|
|
156
|
-
* @return {number}
|
|
157
|
-
* @example 1,200,300.123 => 1200300.123
|
|
158
|
-
* @example 1.200.300,123 => 1200300.123
|
|
153
|
+
/**
|
|
154
|
+
* Convert money to format number
|
|
155
|
+
* @param vl {string} - value
|
|
156
|
+
* @type {function}
|
|
157
|
+
* @return {number}
|
|
158
|
+
* @example 1,200,300.123 => 1200300.123
|
|
159
|
+
* @example 1.200.300,123 => 1200300.123
|
|
159
160
|
*/
|
|
160
161
|
const convertMoneyToNumber = useCallback((vl, isNumber) => {
|
|
161
162
|
var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
|
|
@@ -313,14 +314,18 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
|
|
|
313
314
|
// if (typeof valueProps !== 'undefined')
|
|
314
315
|
// if (disabledNegative && Number(valueProps || 0) < 0) {
|
|
315
316
|
if (!isNaN(valueProps) || !isNaN(value)) {
|
|
316
|
-
var _valueProps;
|
|
317
317
|
if (min === 0 && Number(valueProps || 0) < 0) {
|
|
318
318
|
// nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
|
|
319
319
|
valueProps = clamp(0, min, max);
|
|
320
320
|
}
|
|
321
|
-
|
|
321
|
+
if (delayOnChange) {
|
|
322
|
+
if (inputTimer.current) clearTimeout(inputTimer.current);
|
|
323
|
+
inputTimer.current = setTimeout(() => {
|
|
324
|
+
var _valueProps;
|
|
325
|
+
setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
|
|
326
|
+
}, delayOnChange);
|
|
327
|
+
}
|
|
322
328
|
// setValue(parseNumberToMoney(valueProps?.toString().replace(regexValidNumber, ''), true));
|
|
323
|
-
setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
|
|
324
329
|
}
|
|
325
330
|
}, [valueProps, decimalDigit]);
|
|
326
331
|
useEffect(() => {
|
|
@@ -387,29 +392,28 @@ const NumberInputRootCSS = ({
|
|
|
387
392
|
${cursorNotAllowed};
|
|
388
393
|
}
|
|
389
394
|
`;
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
//
|
|
393
|
-
//
|
|
394
|
-
//
|
|
395
|
-
//
|
|
396
|
-
//
|
|
397
|
-
//
|
|
398
|
-
//
|
|
399
|
-
//
|
|
400
|
-
//
|
|
401
|
-
//
|
|
402
|
-
//
|
|
403
|
-
//
|
|
404
|
-
//
|
|
405
|
-
//
|
|
406
|
-
//
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
//
|
|
410
|
-
//
|
|
411
|
-
|
|
412
|
-
|
|
395
|
+
NumberInput.defaultProps = {
|
|
396
|
+
delayOnChange: 500
|
|
397
|
+
// autoFocus: false,
|
|
398
|
+
// className: '',
|
|
399
|
+
// decimalDigit: Infinity,
|
|
400
|
+
// decimalSymbol: locale.get() === 'vi' ? ',' : '.',
|
|
401
|
+
// disabled: false,
|
|
402
|
+
// disabledNegative: false,
|
|
403
|
+
// endIcon: '',
|
|
404
|
+
// error: '',
|
|
405
|
+
// fixedDecimalDigit: false,
|
|
406
|
+
// label: '',
|
|
407
|
+
// max: Infinity,
|
|
408
|
+
// min: -Infinity,
|
|
409
|
+
// readOnly: false,
|
|
410
|
+
// required: false,
|
|
411
|
+
// startIcon: '',
|
|
412
|
+
// step: 1,
|
|
413
|
+
// style: {},
|
|
414
|
+
// thousandSeparator: false,
|
|
415
|
+
// viewType: 'underlined',
|
|
416
|
+
};
|
|
413
417
|
NumberInput.propTypes = {
|
|
414
418
|
/** If `true`, the input element is focused during the first mount. */
|
|
415
419
|
autoFocus: PropTypes.bool,
|
|
@@ -479,10 +483,10 @@ NumberInput.propTypes = {
|
|
|
479
483
|
style: PropTypes.object,
|
|
480
484
|
/** Thousand separator character. */
|
|
481
485
|
thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
|
|
482
|
-
/** Validation value, argument can:<br/>
|
|
483
|
-
* * string: the validation rule. Example required.<br/>
|
|
484
|
-
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
485
|
-
* * array: the validation rule list, insist object/string
|
|
486
|
+
/** Validation value, argument can:<br/>
|
|
487
|
+
* * string: the validation rule. Example required.<br/>
|
|
488
|
+
* * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
|
|
489
|
+
* * array: the validation rule list, insist object/string
|
|
486
490
|
*/
|
|
487
491
|
validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
|
|
488
492
|
/** The value of the input element, required for a controlled component. */
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -42,6 +42,17 @@ npm test
|
|
|
42
42
|
|
|
43
43
|
## Changelog
|
|
44
44
|
|
|
45
|
+
## 1.4.52
|
|
46
|
+
- \[Fixed\]: DropDown - Fix bug search data in Dropdown
|
|
47
|
+
- \[Fixed\]: NumberInput – NumberInput Core when changing 'decimalDigit'
|
|
48
|
+
|
|
49
|
+
## 1.4.51
|
|
50
|
+
- \[Changed\]: Treeview - Treeview keeps the search bar visible while scrolling
|
|
51
|
+
- \[Changed\]: DateRangePicker - Quick-selection in DateRangePicker
|
|
52
|
+
- \[Fixed\]: Dropdown – Dropdown data lost in the Filter bar on the Web
|
|
53
|
+
- \[Fixed\]: DateRangePicker – When clearing the value in DateRangePicker CORE, the UI still displays the old value.
|
|
54
|
+
- \[Fixed\]: NumberInput – NumberInput Core when changing 'decimalDigit'
|
|
55
|
+
|
|
45
56
|
## 1.4.50
|
|
46
57
|
- \[Added\]: Icon – Add IconMenu MHRP39N0025, MHRP39N0027, MHRP39N0028
|
|
47
58
|
- \[Added\]: Attachment – Add HEIF support to getFileType in Attachment
|