diginet-core-ui 1.4.52-beta.4 → 1.4.52-beta.6

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;
@@ -120,8 +120,10 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
120
120
  const strVal = String(vl);
121
121
  const isDecimalNum = strVal.indexOf('.') > -1 && (((_strVal$split = strVal.split('.')) === null || _strVal$split === void 0 ? void 0 : _strVal$split[1]) || '').length >= decimalDigit;
122
122
  if (isDecimalNum) {
123
- const replacingVal = vl.replace(thousandSymbol, '');
124
- const val = Number(replacingVal).toFixed(decimalDigit);
123
+ const coreToFixed = (num, precision) => {
124
+ return (+(Math.round(+(num + 'e' + precision)) + 'e' + -precision)).toFixed(precision);
125
+ };
126
+ const val = coreToFixed(Number(vl.replace(thousandSymbol, '')), decimalDigit);
125
127
  number = String(val);
126
128
  }
127
129
  }
@@ -151,13 +153,13 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
151
153
  return number;
152
154
  }, [decimalSymbol, max, value, decimalDigit, fixedDecimalDigit]);
153
155
 
154
- /**
155
- * Convert money to format number
156
- * @param vl {string} - value
157
- * @type {function}
158
- * @return {number}
159
- * @example 1,200,300.123 => 1200300.123
160
- * @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
161
163
  */
162
164
  const convertMoneyToNumber = useCallback((vl, isNumber) => {
163
165
  var _number4, _number4$toString, _number4$toString$rep, _number4$toString$rep2, _number4$toString$rep3;
@@ -316,19 +318,20 @@ const NumberInput = /*#__PURE__*/forwardRef((inProps, reference) => {
316
318
  setError(errorProp);
317
319
  }
318
320
  }, [value]);
319
- useEffect(() => {
320
- // if (typeof valueProps !== 'undefined')
321
- // if (disabledNegative && Number(valueProps || 0) < 0) {
322
- if (!isNaN(valueProps) || !isNaN(value)) {
323
- var _valueProps;
324
- if (min === 0 && Number(valueProps || 0) < 0) {
325
- // nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
326
- valueProps = clamp(0, min, max);
327
- }
328
- setValue(parseNumberToMoney((_valueProps = valueProps) === null || _valueProps === void 0 ? void 0 : _valueProps.toString().replace(regexValidNumber, ''), true));
329
- // setValue(parseNumberToMoney(valueProps?.toString().replace(regexValidNumber, ''), true));
330
- }
331
- }, [valueProps, decimalDigit]);
321
+
322
+ // useEffect(() => {
323
+ // // if (typeof valueProps !== 'undefined')
324
+ // // if (disabledNegative && Number(valueProps || 0) < 0) {
325
+ // if (!isNaN(valueProps) || !isNaN(value)) {
326
+ // if (min === 0 && Number(valueProps || 0) < 0) {
327
+ // // nếu không cho nhập số âm mà value đầu vào là âm thì reset value về 0
328
+ // valueProps = clamp(0, min, max);
329
+ // }
330
+ // // setValue(parseNumberToMoney(valueProps?.toString().replace(regexValidNumber, ''), true));
331
+ // // setValue(parseNumberToMoney(valueProps?.toString().replace(regexValidNumber, ''), true));
332
+ // }
333
+ // }, [valueProps, decimalDigit]);
334
+
332
335
  useEffect(() => {
333
336
  setError(errorProp);
334
337
  }, [errorProp]);
@@ -394,7 +397,7 @@ const NumberInputRootCSS = ({
394
397
  }
395
398
  `;
396
399
  NumberInput.defaultProps = {
397
- delayOnChange: 1000
400
+ delayOnChange: 500
398
401
  // autoFocus: false,
399
402
  // className: '',
400
403
  // decimalDigit: Infinity,
@@ -484,10 +487,10 @@ NumberInput.propTypes = {
484
487
  style: PropTypes.object,
485
488
  /** Thousand separator character. */
486
489
  thousandSeparator: PropTypes.oneOfType([PropTypes.bool, PropTypes.oneOf(['.', ','])]),
487
- /** Validation value, argument can:<br/>
488
- * * string: the validation rule. Example required.<br/>
489
- * * object: the validation rule insist name, property, message. Example {name: 'min', compareValue: 9, message: 'Error'} or {max: 99}<br/>
490
- * * array: the validation rule list, insist object/string
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
491
494
  */
492
495
  validates: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array, PropTypes.func]),
493
496
  /** 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.4",
3
+ "version": "1.4.52-beta.6",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "license": "UNLICENSED",