intelicoreact 1.3.12 → 1.3.14

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.
@@ -36,7 +36,7 @@ var InputCurrency = function InputCurrency(_ref) {
36
36
  max = _ref.max,
37
37
  error = _ref.error;
38
38
 
39
- var _useState = (0, _react.useState)(value || currencySymbol || '$'),
39
+ var _useState = (0, _react.useState)(currencySymbol || '$'),
40
40
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
41
41
  inputValue = _useState2[0],
42
42
  setInputValue = _useState2[1];
@@ -68,28 +68,34 @@ var InputCurrency = function InputCurrency(_ref) {
68
68
  }
69
69
  };
70
70
 
71
- var checkMinMax = function checkMinMax(event) {
71
+ var checkMinMax = function checkMinMax(event, value) {
72
72
  var _event$target, _event$target$value;
73
73
 
74
- var clearValue = event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$value = _event$target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.replace(/[^0-9]/g, '');
74
+ var clearValue = value !== null && value !== void 0 ? value : event === null || event === void 0 ? void 0 : (_event$target = event.target) === null || _event$target === void 0 ? void 0 : (_event$target$value = _event$target.value) === null || _event$target$value === void 0 ? void 0 : _event$target$value.replace(/[^0-9]/g, '');
75
75
  if (!clearValue) return false;
76
76
 
77
77
  if (clearValue < min) {
78
78
  setInputValue("".concat(currencySymbol || '$').concat(formatNumberWithCommas(min)));
79
79
  onChange(min);
80
+ return false;
80
81
  }
81
82
 
82
83
  if (max && clearValue > max) {
83
84
  setInputValue("".concat(currencySymbol || '$').concat(formatNumberWithCommas(max)));
84
85
  onChange(max);
86
+ return false;
85
87
  }
88
+
89
+ return true;
86
90
  };
87
91
 
88
92
  (0, _react.useEffect)(function () {
89
- if (value) {
90
- setInputValue("".concat(currencySymbol || '$').concat(value));
93
+ var _inputValue$toString;
94
+
95
+ if (value.toString() !== (inputValue === null || inputValue === void 0 ? void 0 : (_inputValue$toString = inputValue.toString()) === null || _inputValue$toString === void 0 ? void 0 : _inputValue$toString.replace(/[^0-9]/g, ''))) {
96
+ if (checkMinMax(null, value)) setInputValue("".concat(currencySymbol || '$').concat(formatNumberWithCommas(value)));
91
97
  }
92
- }, []);
98
+ }, [value]);
93
99
  return /*#__PURE__*/_react.default.createElement("div", {
94
100
  className: (0, _classnames.default)('input-currency-box', className, {
95
101
  disabled: disabled,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intelicoreact",
3
- "version": "1.3.12",
3
+ "version": "1.3.14",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [