@true-engineering/true-react-common-ui-kit 1.4.1 → 1.5.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.
@@ -7701,6 +7701,10 @@
7701
7701
  handleListOpen();
7702
7702
  };
7703
7703
  var handleBlur = function(event) {
7704
+ if (isListOpen && !isOpen) {
7705
+ handleListClose(event);
7706
+ return;
7707
+ }
7704
7708
  if (!isNotEmpty(event.relatedTarget) || !isNotEmpty(list.current)) {
7705
7709
  return;
7706
7710
  }
@@ -7945,7 +7949,7 @@
7945
7949
  event.preventDefault();
7946
7950
  },
7947
7951
  onClick: onArrowClick,
7948
- className: clsx(classes.arrow, isListOpen && classes.activeArrow),
7952
+ className: clsx(classes.arrow, isOpen && classes.activeArrow),
7949
7953
  children: /* @__PURE__ */ jsx(Icon, {
7950
7954
  type: dropdownIcon
7951
7955
  })
@@ -10235,6 +10239,13 @@
10235
10239
  var val = formatNumber(value);
10236
10240
  return isNotEmpty(val) ? val : formatNumber(defaultValue);
10237
10241
  };
10242
+ var constructRegExp = function(param) {
10243
+ var canBeFloat = param.canBeFloat, canBeNegative = param.canBeNegative, intPartPrecision = param.intPartPrecision, precision = param.precision;
10244
+ var basePart = "\\d{0,".concat(intPartPrecision, "}");
10245
+ var floatPart = "(\\.\\d{0,".concat(precision, "})?");
10246
+ var negativePart = "(\\-)?";
10247
+ return "^".concat(canBeNegative ? negativePart : "").concat(basePart).concat(canBeFloat ? floatPart : "", "$");
10248
+ };
10238
10249
  function _array_like_to_array$e(arr, len) {
10239
10250
  if (len == null || len > arr.length)
10240
10251
  len = arr.length;
@@ -10485,9 +10496,10 @@
10485
10496
  }
10486
10497
  };
10487
10498
  var NumberInput = /* @__PURE__ */ React.forwardRef(function(_param, ref) {
10488
- var value = _param.value, _param_canBeFloat = _param.canBeFloat, canBeFloat = _param_canBeFloat === void 0 ? false : _param_canBeFloat, defaultValue = _param.defaultValue, _param_precision = _param.precision, precision = _param_precision === void 0 ? 3 : _param_precision, _param_intPartPrecision = _param.intPartPrecision, intPartPrecision = _param_intPartPrecision === void 0 ? 7 : _param_intPartPrecision, onChange = _param.onChange, onBlur = _param.onBlur, min2 = _param.min, max2 = _param.max, props = _object_without_properties$3(_param, [
10499
+ var value = _param.value, _param_canBeFloat = _param.canBeFloat, canBeFloat = _param_canBeFloat === void 0 ? false : _param_canBeFloat, _param_canBeNegative = _param.canBeNegative, canBeNegative = _param_canBeNegative === void 0 ? false : _param_canBeNegative, defaultValue = _param.defaultValue, _param_precision = _param.precision, precision = _param_precision === void 0 ? 3 : _param_precision, _param_intPartPrecision = _param.intPartPrecision, intPartPrecision = _param_intPartPrecision === void 0 ? 7 : _param_intPartPrecision, onChange = _param.onChange, onBlur = _param.onBlur, min2 = _param.min, max2 = _param.max, props = _object_without_properties$3(_param, [
10489
10500
  "value",
10490
10501
  "canBeFloat",
10502
+ "canBeNegative",
10491
10503
  "defaultValue",
10492
10504
  "precision",
10493
10505
  "intPartPrecision",
@@ -10508,7 +10520,7 @@
10508
10520
  };
10509
10521
  var handleChange = function() {
10510
10522
  var _ref = _async_to_generator$2(function(inputValue, event) {
10511
- var oldValue, target, _target_selectionStart, defaultCaretPos, numString, intRegexp, floatRegexp, numberRegexp, hasDot, formattedValue, newValue;
10523
+ var oldValue, target, _target_selectionStart, defaultCaretPos, numString, numberRegexp, hasDot, formattedValue, newValue;
10512
10524
  return __generator$2(this, function(_state) {
10513
10525
  switch (_state.label) {
10514
10526
  case 0:
@@ -10523,10 +10535,13 @@
10523
10535
  2
10524
10536
  ];
10525
10537
  }
10526
- intRegexp = new RegExp("^\\d{0,".concat(intPartPrecision, "}$"));
10527
- floatRegexp = new RegExp("^\\d{0,".concat(intPartPrecision, "}(\\.\\d{0,").concat(precision, "})?$"));
10528
- numberRegexp = canBeFloat && precision > 0 ? floatRegexp : intRegexp;
10529
- if (!!numString.match(numberRegexp))
10538
+ numberRegexp = new RegExp(constructRegExp({
10539
+ precision,
10540
+ intPartPrecision,
10541
+ canBeNegative,
10542
+ canBeFloat
10543
+ }));
10544
+ if (!!numberRegexp.test(numString))
10530
10545
  return [
10531
10546
  3,
10532
10547
  2
@@ -10542,7 +10557,7 @@
10542
10557
  2
10543
10558
  ];
10544
10559
  case 2:
10545
- hasDot = canBeFloat && inputValue.match(/^[\d\s]*[.,]$/);
10560
+ hasDot = canBeFloat && /^[-]*[\d\s]*[.,]$/.test(inputValue);
10546
10561
  formattedValue = formatStringNumber(numString);
10547
10562
  newValue = hasDot ? "".concat(formattedValue, ".") : formattedValue;
10548
10563
  return [