@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.
@@ -11,7 +11,7 @@ declare type timerType = {
11
11
  * @param ref
12
12
  * @returns
13
13
  */
14
- declare const useTime: (timestamp: any, isStart: any) => {
14
+ declare const useTime: (initialTimestamp: number, isStart: boolean) => {
15
15
  time: timerType;
16
16
  seconds: number;
17
17
  isActive: boolean;
@@ -464,6 +464,13 @@ var _delimiter = function delimiter(num, separator, separateBy) {
464
464
  }
465
465
  return num;
466
466
  };
467
+ var _removeDelimiter = function removeDelimiter(num, separator) {
468
+ if (separator === void 0) {
469
+ separator = ',';
470
+ }
471
+ var cleanedNumber = num.split(separator).join('');
472
+ return parseFloat(cleanedNumber);
473
+ };
467
474
  var _roundUp = function roundUp(val, dec) {
468
475
  var decimal = dec === 0 ? 0 : +("1" + new Array(dec + 1).join('0'));
469
476
  var result = decimal === 0 ? Math.ceil(val) : Math.ceil(+bigDecimal.multiply(val, decimal)) / decimal;
@@ -482,6 +489,12 @@ var numberUtils = {
482
489
  delimiter: function delimiter(num, separator, separateBy) {
483
490
  return _delimiter(num, separator, separateBy);
484
491
  },
492
+ removeDelimiter: function removeDelimiter(num, separator) {
493
+ if (separator === void 0) {
494
+ separator = ',';
495
+ }
496
+ return _removeDelimiter(num, separator);
497
+ },
485
498
  roundDown: function roundDown(val, dec) {
486
499
  return _roundDown(val, dec);
487
500
  },
@@ -541,42 +554,45 @@ var calculateTime = function calculateTime(time) {
541
554
  * @param ref
542
555
  * @returns
543
556
  */
544
- var useTime = function useTime(timestamp, isStart) {
545
- var TIMER;
546
- var _React$useState = React__default.useState(timestamp),
557
+ var useTime = function useTime(initialTimestamp, isStart) {
558
+ var _React$useState = React__default.useState(initialTimestamp),
547
559
  time = _React$useState[0],
548
560
  setTime = _React$useState[1];
549
- var _React$useState2 = React__default.useState(true),
561
+ var _React$useState2 = React__default.useState(false),
550
562
  isActive = _React$useState2[0],
551
563
  setIsActive = _React$useState2[1];
552
564
  React__default.useEffect(function () {
553
- if (time === 0) {
554
- clearInterval(TIMER);
555
- setIsActive(false);
556
- setTime(0);
557
- }
558
- }, [time]);
559
- React__default.useEffect(function () {
565
+ var TIMER;
560
566
  if (isStart && isActive) {
561
567
  TIMER = setInterval(function () {
562
568
  setTime(function (prev) {
569
+ if (prev <= 1000) {
570
+ clearInterval(TIMER);
571
+ setIsActive(false);
572
+ return 0;
573
+ }
563
574
  return prev - 1000;
564
575
  });
565
576
  }, 1000);
566
577
  }
567
578
  return function () {
568
- clearInterval(TIMER);
579
+ if (TIMER) {
580
+ clearInterval(TIMER);
581
+ }
569
582
  };
570
583
  }, [isStart, isActive]);
584
+ React__default.useEffect(function () {
585
+ if (isStart) {
586
+ setIsActive(true);
587
+ }
588
+ }, [isStart]);
571
589
  var reset = function reset() {
572
- clearInterval(TIMER);
573
- TIMER = null;
574
590
  setIsActive(true);
575
- setTime(timestamp);
591
+ setTime(initialTimestamp);
576
592
  };
577
593
  return {
578
594
  time: calculateTime(time),
579
- seconds: time / 1000,
595
+ seconds: Math.floor(time / 1000),
580
596
  isActive: isActive,
581
597
  reset: reset,
582
598
  isComplete: time === 0
@@ -666,7 +682,7 @@ var AlertTimer = function AlertTimer(_ref) {
666
682
  if (isComplete && onComplete) {
667
683
  onComplete();
668
684
  }
669
- }, [isComplete]);
685
+ }, [isComplete, onComplete]);
670
686
  return React__default.createElement(Stack$1, {
671
687
  flexDirection: "row",
672
688
  alignItems: "center",