@rabex-kit/rabex-ui 0.1.24 → 0.1.26

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.
@@ -459,6 +459,13 @@ var _delimiter = function delimiter(num, separator, separateBy) {
459
459
  }
460
460
  return num;
461
461
  };
462
+ var _removeDelimiter = function removeDelimiter(num, separator) {
463
+ if (separator === void 0) {
464
+ separator = ',';
465
+ }
466
+ var cleanedNumber = num.split(separator).join('');
467
+ return parseFloat(cleanedNumber);
468
+ };
462
469
  var _roundUp = function roundUp(val, dec) {
463
470
  var decimal = dec === 0 ? 0 : +("1" + new Array(dec + 1).join('0'));
464
471
  var result = decimal === 0 ? Math.ceil(val) : Math.ceil(+bigDecimal.multiply(val, decimal)) / decimal;
@@ -477,6 +484,12 @@ var numberUtils = {
477
484
  delimiter: function delimiter(num, separator, separateBy) {
478
485
  return _delimiter(num, separator, separateBy);
479
486
  },
487
+ removeDelimiter: function removeDelimiter(num, separator) {
488
+ if (separator === void 0) {
489
+ separator = ',';
490
+ }
491
+ return _removeDelimiter(num, separator);
492
+ },
480
493
  roundDown: function roundDown(val, dec) {
481
494
  return _roundDown(val, dec);
482
495
  },
@@ -536,42 +549,45 @@ var calculateTime = function calculateTime(time) {
536
549
  * @param ref
537
550
  * @returns
538
551
  */
539
- var useTime = function useTime(timestamp, isStart) {
540
- var TIMER;
541
- var _React$useState = React.useState(timestamp),
552
+ var useTime = function useTime(initialTimestamp, isStart) {
553
+ var _React$useState = React.useState(initialTimestamp),
542
554
  time = _React$useState[0],
543
555
  setTime = _React$useState[1];
544
- var _React$useState2 = React.useState(true),
556
+ var _React$useState2 = React.useState(false),
545
557
  isActive = _React$useState2[0],
546
558
  setIsActive = _React$useState2[1];
547
559
  React.useEffect(function () {
548
- if (time === 0) {
549
- clearInterval(TIMER);
550
- setIsActive(false);
551
- setTime(0);
552
- }
553
- }, [time]);
554
- React.useEffect(function () {
560
+ var TIMER;
555
561
  if (isStart && isActive) {
556
562
  TIMER = setInterval(function () {
557
563
  setTime(function (prev) {
564
+ if (prev <= 1000) {
565
+ clearInterval(TIMER);
566
+ setIsActive(false);
567
+ return 0;
568
+ }
558
569
  return prev - 1000;
559
570
  });
560
571
  }, 1000);
561
572
  }
562
573
  return function () {
563
- clearInterval(TIMER);
574
+ if (TIMER) {
575
+ clearInterval(TIMER);
576
+ }
564
577
  };
565
578
  }, [isStart, isActive]);
579
+ React.useEffect(function () {
580
+ if (isStart) {
581
+ setIsActive(true);
582
+ }
583
+ }, [isStart]);
566
584
  var reset = function reset() {
567
- clearInterval(TIMER);
568
- TIMER = null;
569
585
  setIsActive(true);
570
- setTime(timestamp);
586
+ setTime(initialTimestamp);
571
587
  };
572
588
  return {
573
589
  time: calculateTime(time),
574
- seconds: time / 1000,
590
+ seconds: Math.floor(time / 1000),
575
591
  isActive: isActive,
576
592
  reset: reset,
577
593
  isComplete: time === 0
@@ -661,7 +677,7 @@ var AlertTimer = function AlertTimer(_ref) {
661
677
  if (isComplete && onComplete) {
662
678
  onComplete();
663
679
  }
664
- }, [isComplete]);
680
+ }, [isComplete, onComplete]);
665
681
  return React.createElement(Stack$1, {
666
682
  flexDirection: "row",
667
683
  alignItems: "center",