diginet-core-ui 1.4.52-beta.0 → 1.4.52-beta.1

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;
@@ -150,13 +150,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
150
150
  return number;
151
151
  }, [decimalSymbol, max, value, decimalDigit, fixedDecimalDigit]);
152
152
 
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
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
160
160
  */
161
161
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
162
162
  var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
@@ -281,14 +281,19 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
281
281
  onFocus && onFocus(e);
282
282
  };
283
283
  const _onChange = e => {
284
- const target = e.target;
285
- target.value = globalRef.current.valueString;
286
- target.valueString = globalRef.current.returnValue;
287
- onChange({
288
- ...e,
289
- value: globalRef.current.value,
290
- target
291
- });
284
+ if (delayOnChange) {
285
+ if (inputTimer.current) clearTimeout(inputTimer.current);
286
+ inputTimer.current = setTimeout(() => {
287
+ const target = e.target;
288
+ target.value = globalRef.current.valueString;
289
+ target.valueString = globalRef.current.returnValue;
290
+ onChange({
291
+ ...e,
292
+ value: globalRef.current.value,
293
+ target
294
+ });
295
+ }, delayOnChange);
296
+ }
292
297
  };
293
298
  const validateResult = validates && onValidate(Number(convertMoneyToNumber(value) || 0), validates, true);
294
299
  useEffect(() => {
@@ -314,17 +319,12 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
314
319
  // if (typeof valueProps !== 'undefined')
315
320
  // if (disabledNegative && Number(valueProps || 0) < 0) {
316
321
  if (!isNaN(valueProps) || !isNaN(value)) {
322
+ var _valueProps;
317
323
  if (min === 0 && Number(valueProps || 0) < 0) {
318
324
  // nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
319
325
  valueProps = clamp(0, min, max);
320
326
  }
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
- }
327
+ setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
328
328
  // setValue(parseNumberToMoney(valueProps?.toString().replace(regexValidNumber, ''), true));
329
329
  }
330
330
  }, [valueProps, decimalDigit]);
@@ -393,7 +393,7 @@ const NumberInputRootCSS = ({
393
393
  }
394
394
  `;
395
395
  NumberInput.defaultProps = {
396
- delayOnChange: 500
396
+ delayOnChange: 1000
397
397
  // autoFocus: false,
398
398
  // className: '',
399
399
  // decimalDigit: Infinity,
@@ -483,10 +483,10 @@ NumberInput.propTypes = {
483
483
  style: PropTypes.object,
484
484
  /** Thousand separator character. */
485
485
  thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
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
+ /** 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
490
490
  */
491
491
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
492
492
  /** The value of the input element, required for a controlled component. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginet-core-ui",
3
- "version": "1.4.52-beta.0",
3
+ "version": "1.4.52-beta.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",