@ornikar/kitt-universal 31.1.0 → 31.2.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.
Files changed (32) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/definitions/Button/Button.d.ts +5 -0
  3. package/dist/definitions/Button/Button.d.ts.map +1 -1
  4. package/dist/definitions/Button/ButtonGauge.d.ts +9 -0
  5. package/dist/definitions/Button/ButtonGauge.d.ts.map +1 -0
  6. package/dist/definitions/CardModal/CardModalAnimation/CardModalAnimation.web.d.ts +4 -0
  7. package/dist/definitions/CardModal/CardModalAnimation/CardModalAnimation.web.d.ts.map +1 -0
  8. package/dist/definitions/CardModal/CardModalAnimation/NativeRotationAnimation.d.ts +1 -0
  9. package/dist/definitions/CardModal/CardModalAnimation/NativeRotationAnimation.d.ts.map +1 -1
  10. package/dist/definitions/NavigationBottomSheet/NavigationBottomSheet.d.ts +3 -0
  11. package/dist/definitions/NavigationBottomSheet/NavigationBottomSheet.d.ts.map +1 -1
  12. package/dist/index-metro.es.android.js +84 -11
  13. package/dist/index-metro.es.android.js.map +1 -1
  14. package/dist/index-metro.es.ios.js +84 -11
  15. package/dist/index-metro.es.ios.js.map +1 -1
  16. package/dist/index-node-22.17.cjs.js +85 -10
  17. package/dist/index-node-22.17.cjs.js.map +1 -1
  18. package/dist/index-node-22.17.cjs.web.css +8 -0
  19. package/dist/index-node-22.17.cjs.web.js +152 -152
  20. package/dist/index-node-22.17.cjs.web.js.map +1 -1
  21. package/dist/index-node-22.17.es.mjs +86 -11
  22. package/dist/index-node-22.17.es.mjs.map +1 -1
  23. package/dist/index-node-22.17.es.web.css +8 -0
  24. package/dist/index-node-22.17.es.web.mjs +153 -153
  25. package/dist/index-node-22.17.es.web.mjs.map +1 -1
  26. package/dist/index.es.js +87 -11
  27. package/dist/index.es.js.map +1 -1
  28. package/dist/index.es.web.js +168 -167
  29. package/dist/index.es.web.js.map +1 -1
  30. package/dist/styles.css +8 -0
  31. package/dist/tsbuildinfo +1 -1
  32. package/package.json +2 -1
@@ -1,4 +1,4 @@
1
- import React, { useContext, createContext, forwardRef, useMemo, cloneElement, useRef, useEffect, useState, Children, useReducer, Fragment as Fragment$1, useCallback } from 'react';
1
+ import React, { useContext, createContext, forwardRef, useMemo, cloneElement, useState, useRef, useCallback, useLayoutEffect, useEffect, Children, useReducer, Fragment as Fragment$1 } from 'react';
2
2
  import { View as View$1, ScrollView as ScrollView$1, Pressable as Pressable$1, Image as Image$1, FlatList as FlatList$1, SectionList as SectionList$1, Stack as Stack$1, VStack as VStack$1, HStack as HStack$1, Center as Center$1, useBreakpointValue as useBreakpointValue$1, useSx, Text, Input, NativeBaseProvider, extendTheme, useMediaQuery } from 'native-base';
3
3
  export { useClipboard, useContrastText, useMediaQuery, useSx, useToken } from 'native-base';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -3633,6 +3633,79 @@ function ButtonContent({
3633
3633
  });
3634
3634
  }
3635
3635
 
3636
+ function ButtonGauge({
3637
+ duration,
3638
+ running,
3639
+ onEnded
3640
+ }) {
3641
+ const [translate, setTranslate] = useState(100);
3642
+ const startTimeRef = useRef(0);
3643
+ const pauseTimeRef = useRef(0);
3644
+ const rafRef = useRef(undefined);
3645
+ const distance = 100;
3646
+ const draw = useCallback(timestamp => {
3647
+ const timeElapsedSinceStart = timestamp - startTimeRef.current;
3648
+ // Since the time between frame is not reliable and regular, we have to
3649
+ // limit the progress to prevent overflows
3650
+ const safeProgress = Math.min(distance * timeElapsedSinceStart / duration, distance);
3651
+ setTranslate(safeProgress);
3652
+ if (safeProgress < distance) {
3653
+ if (!rafRef) return;
3654
+ rafRef.current = requestAnimationFrame(draw);
3655
+ return;
3656
+ }
3657
+ onEnded();
3658
+ if (rafRef.current) {
3659
+ cancelAnimationFrame(rafRef.current);
3660
+ }
3661
+ },
3662
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3663
+ []);
3664
+ useLayoutEffect(() => {
3665
+ if (running) {
3666
+ // Resuming from pause
3667
+ if (pauseTimeRef.current > 0) {
3668
+ startTimeRef.current += global.performance.now() - pauseTimeRef.current;
3669
+ draw(global.performance.now());
3670
+ return;
3671
+ }
3672
+
3673
+ // First launch
3674
+ startTimeRef.current = global.performance.now();
3675
+ draw(startTimeRef.current);
3676
+ }
3677
+
3678
+ // On pause
3679
+ if (!running && rafRef.current) {
3680
+ pauseTimeRef.current = global.performance.now();
3681
+ cancelAnimationFrame(rafRef.current);
3682
+ }
3683
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3684
+ }, [running]);
3685
+ useEffect(() => {
3686
+ return () => {
3687
+ if (rafRef.current) {
3688
+ cancelAnimationFrame(rafRef.current);
3689
+ }
3690
+ };
3691
+ }, []);
3692
+ return /*#__PURE__*/jsx(View, {
3693
+ position: "absolute",
3694
+ left: 0,
3695
+ right: 0,
3696
+ top: 0,
3697
+ bottom: 0,
3698
+ overflow: "hidden",
3699
+ alignItems: "flex-end",
3700
+ borderRadius: "kitt.button.borderRadius",
3701
+ children: /*#__PURE__*/jsx(View, {
3702
+ width: `${translate}%`,
3703
+ height: "100%",
3704
+ backgroundColor: "kitt.palettes.deepPurple['white-alpha.20']"
3705
+ })
3706
+ });
3707
+ }
3708
+
3636
3709
  function ButtonPadding({
3637
3710
  children,
3638
3711
  size,
@@ -3723,6 +3796,7 @@ const Button = /*#__PURE__*/forwardRef(({
3723
3796
  hrefAttrs,
3724
3797
  withBadge,
3725
3798
  badgeCount,
3799
+ timerAttrs,
3726
3800
  accessibilityRole = 'button',
3727
3801
  innerSpacing = 'center',
3728
3802
  isHoveredInternal,
@@ -3770,7 +3844,7 @@ const Button = /*#__PURE__*/forwardRef(({
3770
3844
  isHovered,
3771
3845
  isPressed,
3772
3846
  isFocused
3773
- }) => /*#__PURE__*/jsx(AnimatedContainer$2, {
3847
+ }) => /*#__PURE__*/jsxs(AnimatedContainer$2, {
3774
3848
  animatedStyles: animatedStyles,
3775
3849
  type: type,
3776
3850
  isHovered: isHovered || isHoveredInternal,
@@ -3780,7 +3854,9 @@ const Button = /*#__PURE__*/forwardRef(({
3780
3854
  size: size,
3781
3855
  isIconOnly: isIconOnly,
3782
3856
  isStretch: stretch,
3783
- children: /*#__PURE__*/jsxs(ButtonPadding, {
3857
+ children: [timerAttrs ? /*#__PURE__*/jsx(ButtonGauge, {
3858
+ ...timerAttrs
3859
+ }) : null, /*#__PURE__*/jsxs(ButtonPadding, {
3784
3860
  size: size,
3785
3861
  isIconOnly: isIconOnly,
3786
3862
  children: [/*#__PURE__*/jsx(ButtonContent, {
@@ -3802,7 +3878,7 @@ const Button = /*#__PURE__*/forwardRef(({
3802
3878
  isHovered: isHovered,
3803
3879
  isPressed: isPressed
3804
3880
  })]
3805
- })
3881
+ })]
3806
3882
  })
3807
3883
  });
3808
3884
  });
@@ -4319,7 +4395,7 @@ function NativeOpacityAnimation$2({
4319
4395
  runOnJS(handleAnimationFinished)();
4320
4396
  })
4321
4397
  };
4322
- }, [visible]);
4398
+ });
4323
4399
  return /*#__PURE__*/jsx(Animated.View, {
4324
4400
  style: [StyleSheet.absoluteFillObject, opacityStyle],
4325
4401
  children: children
@@ -4374,11 +4450,9 @@ function NativeRotationAnimation$1({
4374
4450
  rotateZ: `${rotation.value}deg`
4375
4451
  }]
4376
4452
  };
4377
- }, [rotation, visible]);
4453
+ });
4378
4454
  return /*#__PURE__*/jsx(Animated.View, {
4379
- style: [{
4380
- flexShrink: 1
4381
- }, animatedStyle],
4455
+ style: [animatedStyle],
4382
4456
  children: children
4383
4457
  });
4384
4458
  }
@@ -11686,7 +11760,7 @@ function NavigationBottomSheet({
11686
11760
  snapPoints,
11687
11761
  maxDynamicContentSize,
11688
11762
  isVisible,
11689
- isExpanded,
11763
+ isExpanded = false,
11690
11764
  onClose
11691
11765
  }) {
11692
11766
  const bottomSheetRef = useBottomSheet();
@@ -11698,7 +11772,8 @@ function NavigationBottomSheet({
11698
11772
  }
11699
11773
  }, [bottomSheetRef, isVisible]);
11700
11774
  useEffect(() => {
11701
- if (isVisible && isExpanded) {
11775
+ if (!isVisible) return;
11776
+ if (isExpanded) {
11702
11777
  bottomSheetRef.current?.expand();
11703
11778
  } else {
11704
11779
  bottomSheetRef.current?.collapse();