@ornikar/kitt-universal 31.1.0 → 31.1.2-canary.31eec21cbe0c2b92255fb1fa14d83757a05ea8b0.0

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.
@@ -3657,6 +3657,79 @@ function ButtonContent({
3657
3657
  });
3658
3658
  }
3659
3659
 
3660
+ function ButtonGauge({
3661
+ duration,
3662
+ running,
3663
+ onEnded
3664
+ }) {
3665
+ const [translate, setTranslate] = React.useState(100);
3666
+ const startTimeRef = React.useRef(0);
3667
+ const pauseTimeRef = React.useRef(0);
3668
+ const rafRef = React.useRef(undefined);
3669
+ const distance = 100;
3670
+ const draw = React.useCallback(timestamp => {
3671
+ const timeElapsedSinceStart = timestamp - startTimeRef.current;
3672
+ // Since the time between frame is not reliable and regular, we have to
3673
+ // limit the progress to prevent overflows
3674
+ const safeProgress = Math.min(distance * timeElapsedSinceStart / duration, distance);
3675
+ setTranslate(safeProgress);
3676
+ if (safeProgress < distance) {
3677
+ if (!rafRef) return;
3678
+ rafRef.current = requestAnimationFrame(draw);
3679
+ return;
3680
+ }
3681
+ onEnded();
3682
+ if (rafRef.current) {
3683
+ cancelAnimationFrame(rafRef.current);
3684
+ }
3685
+ },
3686
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3687
+ []);
3688
+ React.useLayoutEffect(() => {
3689
+ if (running) {
3690
+ // Resuming from pause
3691
+ if (pauseTimeRef.current > 0) {
3692
+ startTimeRef.current += global.performance.now() - pauseTimeRef.current;
3693
+ draw(global.performance.now());
3694
+ return;
3695
+ }
3696
+
3697
+ // First launch
3698
+ startTimeRef.current = global.performance.now();
3699
+ draw(startTimeRef.current);
3700
+ }
3701
+
3702
+ // On pause
3703
+ if (!running && rafRef.current) {
3704
+ pauseTimeRef.current = global.performance.now();
3705
+ cancelAnimationFrame(rafRef.current);
3706
+ }
3707
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3708
+ }, [running]);
3709
+ React.useEffect(() => {
3710
+ return () => {
3711
+ if (rafRef.current) {
3712
+ cancelAnimationFrame(rafRef.current);
3713
+ }
3714
+ };
3715
+ }, []);
3716
+ return /*#__PURE__*/jsxRuntime.jsx(View, {
3717
+ position: "absolute",
3718
+ left: 0,
3719
+ right: 0,
3720
+ top: 0,
3721
+ bottom: 0,
3722
+ overflow: "hidden",
3723
+ alignItems: "flex-end",
3724
+ borderRadius: "kitt.button.borderRadius",
3725
+ children: /*#__PURE__*/jsxRuntime.jsx(View, {
3726
+ width: `${translate}%`,
3727
+ height: "100%",
3728
+ backgroundColor: "kitt.palettes.deepPurple['white-alpha.20']"
3729
+ })
3730
+ });
3731
+ }
3732
+
3660
3733
  function ButtonPadding({
3661
3734
  children,
3662
3735
  size,
@@ -3747,6 +3820,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
3747
3820
  hrefAttrs,
3748
3821
  withBadge,
3749
3822
  badgeCount,
3823
+ timerAttrs,
3750
3824
  accessibilityRole = 'button',
3751
3825
  innerSpacing = 'center',
3752
3826
  isHoveredInternal,
@@ -3794,7 +3868,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
3794
3868
  isHovered,
3795
3869
  isPressed,
3796
3870
  isFocused
3797
- }) => /*#__PURE__*/jsxRuntime.jsx(AnimatedContainer$2, {
3871
+ }) => /*#__PURE__*/jsxRuntime.jsxs(AnimatedContainer$2, {
3798
3872
  animatedStyles: animatedStyles,
3799
3873
  type: type,
3800
3874
  isHovered: isHovered || isHoveredInternal,
@@ -3804,7 +3878,9 @@ const Button = /*#__PURE__*/React.forwardRef(({
3804
3878
  size: size,
3805
3879
  isIconOnly: isIconOnly,
3806
3880
  isStretch: stretch,
3807
- children: /*#__PURE__*/jsxRuntime.jsxs(ButtonPadding, {
3881
+ children: [timerAttrs ? /*#__PURE__*/jsxRuntime.jsx(ButtonGauge, {
3882
+ ...timerAttrs
3883
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs(ButtonPadding, {
3808
3884
  size: size,
3809
3885
  isIconOnly: isIconOnly,
3810
3886
  children: [/*#__PURE__*/jsxRuntime.jsx(ButtonContent, {
@@ -3826,7 +3902,7 @@ const Button = /*#__PURE__*/React.forwardRef(({
3826
3902
  isHovered: isHovered,
3827
3903
  isPressed: isPressed
3828
3904
  })]
3829
- })
3905
+ })]
3830
3906
  })
3831
3907
  });
3832
3908
  });
@@ -11710,7 +11786,7 @@ function NavigationBottomSheet({
11710
11786
  snapPoints,
11711
11787
  maxDynamicContentSize,
11712
11788
  isVisible,
11713
- isExpanded,
11789
+ isExpanded = false,
11714
11790
  onClose
11715
11791
  }) {
11716
11792
  const bottomSheetRef = useBottomSheet();
@@ -11722,7 +11798,8 @@ function NavigationBottomSheet({
11722
11798
  }
11723
11799
  }, [bottomSheetRef, isVisible]);
11724
11800
  React.useEffect(() => {
11725
- if (isVisible && isExpanded) {
11801
+ if (!isVisible) return;
11802
+ if (isExpanded) {
11726
11803
  bottomSheetRef.current?.expand();
11727
11804
  } else {
11728
11805
  bottomSheetRef.current?.collapse();