@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.
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
- import React, { useContext, createContext, forwardRef, useMemo, cloneElement, useRef, useEffect, useState, Children, useReducer, Fragment as Fragment$1, useCallback } from 'react';
3
+ import React, { useContext, createContext, forwardRef, useMemo, cloneElement, useState, useRef, useCallback, useLayoutEffect, useEffect, Children, useReducer, Fragment as Fragment$1 } from 'react';
4
4
  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';
5
5
  export { useClipboard, useContrastText, useMediaQuery, useSx, useToken } from 'native-base';
6
6
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
@@ -3659,6 +3659,81 @@ function ButtonContent(_ref2) {
3659
3659
  });
3660
3660
  }
3661
3661
 
3662
+ function ButtonGauge(_ref) {
3663
+ var duration = _ref.duration,
3664
+ running = _ref.running,
3665
+ onEnded = _ref.onEnded;
3666
+ var _useState = useState(100),
3667
+ _useState2 = _slicedToArray(_useState, 2),
3668
+ translate = _useState2[0],
3669
+ setTranslate = _useState2[1];
3670
+ var startTimeRef = useRef(0);
3671
+ var pauseTimeRef = useRef(0);
3672
+ var rafRef = useRef(undefined);
3673
+ var distance = 100;
3674
+ var draw = useCallback(function (timestamp) {
3675
+ var timeElapsedSinceStart = timestamp - startTimeRef.current;
3676
+ // Since the time between frame is not reliable and regular, we have to
3677
+ // limit the progress to prevent overflows
3678
+ var safeProgress = Math.min(distance * timeElapsedSinceStart / duration, distance);
3679
+ setTranslate(safeProgress);
3680
+ if (safeProgress < distance) {
3681
+ if (!rafRef) return;
3682
+ rafRef.current = requestAnimationFrame(draw);
3683
+ return;
3684
+ }
3685
+ onEnded();
3686
+ if (rafRef.current) {
3687
+ cancelAnimationFrame(rafRef.current);
3688
+ }
3689
+ },
3690
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3691
+ []);
3692
+ useLayoutEffect(function () {
3693
+ if (running) {
3694
+ // Resuming from pause
3695
+ if (pauseTimeRef.current > 0) {
3696
+ startTimeRef.current += global.performance.now() - pauseTimeRef.current;
3697
+ draw(global.performance.now());
3698
+ return;
3699
+ }
3700
+
3701
+ // First launch
3702
+ startTimeRef.current = global.performance.now();
3703
+ draw(startTimeRef.current);
3704
+ }
3705
+
3706
+ // On pause
3707
+ if (!running && rafRef.current) {
3708
+ pauseTimeRef.current = global.performance.now();
3709
+ cancelAnimationFrame(rafRef.current);
3710
+ }
3711
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3712
+ }, [running]);
3713
+ useEffect(function () {
3714
+ return function () {
3715
+ if (rafRef.current) {
3716
+ cancelAnimationFrame(rafRef.current);
3717
+ }
3718
+ };
3719
+ }, []);
3720
+ return /*#__PURE__*/jsx(View, {
3721
+ position: "absolute",
3722
+ left: 0,
3723
+ right: 0,
3724
+ top: 0,
3725
+ bottom: 0,
3726
+ overflow: "hidden",
3727
+ alignItems: "flex-end",
3728
+ borderRadius: "kitt.button.borderRadius",
3729
+ children: /*#__PURE__*/jsx(View, {
3730
+ width: "".concat(translate, "%"),
3731
+ height: "100%",
3732
+ backgroundColor: "kitt.palettes.deepPurple['white-alpha.20']"
3733
+ })
3734
+ });
3735
+ }
3736
+
3662
3737
  function ButtonPadding(_ref) {
3663
3738
  var children = _ref.children,
3664
3739
  size = _ref.size,
@@ -3747,6 +3822,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3747
3822
  hrefAttrs = _ref.hrefAttrs,
3748
3823
  withBadge = _ref.withBadge,
3749
3824
  badgeCount = _ref.badgeCount,
3825
+ timerAttrs = _ref.timerAttrs,
3750
3826
  _ref$accessibilityRol = _ref.accessibilityRole,
3751
3827
  accessibilityRole = _ref$accessibilityRol === void 0 ? 'button' : _ref$accessibilityRol,
3752
3828
  _ref$innerSpacing = _ref.innerSpacing,
@@ -3794,7 +3870,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3794
3870
  var isHovered = _ref2.isHovered,
3795
3871
  isPressed = _ref2.isPressed,
3796
3872
  isFocused = _ref2.isFocused;
3797
- return /*#__PURE__*/jsx(AnimatedContainer$2, {
3873
+ return /*#__PURE__*/jsxs(AnimatedContainer$2, {
3798
3874
  animatedStyles: animatedStyles,
3799
3875
  type: type,
3800
3876
  isHovered: isHovered || isHoveredInternal,
@@ -3804,7 +3880,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3804
3880
  size: size,
3805
3881
  isIconOnly: isIconOnly,
3806
3882
  isStretch: stretch,
3807
- children: /*#__PURE__*/jsxs(ButtonPadding, {
3883
+ children: [timerAttrs ? /*#__PURE__*/jsx(ButtonGauge, _objectSpread({}, timerAttrs)) : null, /*#__PURE__*/jsxs(ButtonPadding, {
3808
3884
  size: size,
3809
3885
  isIconOnly: isIconOnly,
3810
3886
  children: [/*#__PURE__*/jsx(ButtonContent, {
@@ -3826,7 +3902,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3826
3902
  isHovered: isHovered,
3827
3903
  isPressed: isPressed
3828
3904
  })]
3829
- })
3905
+ })]
3830
3906
  });
3831
3907
  }
3832
3908
  });
@@ -11930,7 +12006,8 @@ function NavigationBottomSheet(_ref) {
11930
12006
  snapPoints = _ref.snapPoints,
11931
12007
  maxDynamicContentSize = _ref.maxDynamicContentSize,
11932
12008
  isVisible = _ref.isVisible,
11933
- isExpanded = _ref.isExpanded,
12009
+ _ref$isExpanded = _ref.isExpanded,
12010
+ isExpanded = _ref$isExpanded === void 0 ? false : _ref$isExpanded,
11934
12011
  onClose = _ref.onClose;
11935
12012
  var bottomSheetRef = useBottomSheet();
11936
12013
  useEffect(function () {
@@ -11943,7 +12020,8 @@ function NavigationBottomSheet(_ref) {
11943
12020
  }
11944
12021
  }, [bottomSheetRef, isVisible]);
11945
12022
  useEffect(function () {
11946
- if (isVisible && isExpanded) {
12023
+ if (!isVisible) return;
12024
+ if (isExpanded) {
11947
12025
  var _bottomSheetRef$curre3;
11948
12026
  (_bottomSheetRef$curre3 = bottomSheetRef.current) === null || _bottomSheetRef$curre3 === void 0 || _bottomSheetRef$curre3.expand();
11949
12027
  } else {