@ornikar/kitt-universal 31.1.1 → 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.
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
- import { useContext, createContext, forwardRef, useMemo, cloneElement, useRef, useEffect, useState, Children, useReducer, useCallback, Fragment as Fragment$1 } from 'react';
3
+ import { 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 } from 'native-base';
5
5
  export { useClipboard, useContrastText, useMediaQuery, useSx, useToken } from 'native-base';
6
6
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
@@ -3665,6 +3665,81 @@ function ButtonContent(_ref2) {
3665
3665
  });
3666
3666
  }
3667
3667
 
3668
+ function ButtonGauge(_ref) {
3669
+ var duration = _ref.duration,
3670
+ running = _ref.running,
3671
+ onEnded = _ref.onEnded;
3672
+ var _useState = useState(100),
3673
+ _useState2 = _slicedToArray(_useState, 2),
3674
+ translate = _useState2[0],
3675
+ setTranslate = _useState2[1];
3676
+ var startTimeRef = useRef(0);
3677
+ var pauseTimeRef = useRef(0);
3678
+ var rafRef = useRef(undefined);
3679
+ var distance = 100;
3680
+ var draw = useCallback(function (timestamp) {
3681
+ var timeElapsedSinceStart = timestamp - startTimeRef.current;
3682
+ // Since the time between frame is not reliable and regular, we have to
3683
+ // limit the progress to prevent overflows
3684
+ var safeProgress = Math.min(distance * timeElapsedSinceStart / duration, distance);
3685
+ setTranslate(safeProgress);
3686
+ if (safeProgress < distance) {
3687
+ if (!rafRef) return;
3688
+ rafRef.current = requestAnimationFrame(draw);
3689
+ return;
3690
+ }
3691
+ onEnded();
3692
+ if (rafRef.current) {
3693
+ cancelAnimationFrame(rafRef.current);
3694
+ }
3695
+ },
3696
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3697
+ []);
3698
+ useLayoutEffect(function () {
3699
+ if (running) {
3700
+ // Resuming from pause
3701
+ if (pauseTimeRef.current > 0) {
3702
+ startTimeRef.current += global.performance.now() - pauseTimeRef.current;
3703
+ draw(global.performance.now());
3704
+ return;
3705
+ }
3706
+
3707
+ // First launch
3708
+ startTimeRef.current = global.performance.now();
3709
+ draw(startTimeRef.current);
3710
+ }
3711
+
3712
+ // On pause
3713
+ if (!running && rafRef.current) {
3714
+ pauseTimeRef.current = global.performance.now();
3715
+ cancelAnimationFrame(rafRef.current);
3716
+ }
3717
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3718
+ }, [running]);
3719
+ useEffect(function () {
3720
+ return function () {
3721
+ if (rafRef.current) {
3722
+ cancelAnimationFrame(rafRef.current);
3723
+ }
3724
+ };
3725
+ }, []);
3726
+ return /*#__PURE__*/jsx(View, {
3727
+ position: "absolute",
3728
+ left: 0,
3729
+ right: 0,
3730
+ top: 0,
3731
+ bottom: 0,
3732
+ overflow: "hidden",
3733
+ alignItems: "flex-end",
3734
+ borderRadius: "kitt.button.borderRadius",
3735
+ children: /*#__PURE__*/jsx(View, {
3736
+ width: "".concat(translate, "%"),
3737
+ height: "100%",
3738
+ backgroundColor: "kitt.palettes.deepPurple['white-alpha.20']"
3739
+ })
3740
+ });
3741
+ }
3742
+
3668
3743
  function ButtonPadding(_ref) {
3669
3744
  var children = _ref.children,
3670
3745
  size = _ref.size,
@@ -3736,6 +3811,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3736
3811
  hrefAttrs = _ref.hrefAttrs,
3737
3812
  withBadge = _ref.withBadge,
3738
3813
  badgeCount = _ref.badgeCount,
3814
+ timerAttrs = _ref.timerAttrs,
3739
3815
  _ref$accessibilityRol = _ref.accessibilityRole,
3740
3816
  accessibilityRole = _ref$accessibilityRol === void 0 ? 'button' : _ref$accessibilityRol,
3741
3817
  _ref$innerSpacing = _ref.innerSpacing,
@@ -3780,7 +3856,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3780
3856
  var isHovered = _ref2.isHovered,
3781
3857
  isPressed = _ref2.isPressed,
3782
3858
  isFocused = _ref2.isFocused;
3783
- return /*#__PURE__*/jsx(AnimatedContainer$2, {
3859
+ return /*#__PURE__*/jsxs(AnimatedContainer$2, {
3784
3860
  animatedStyles: animatedStyles,
3785
3861
  type: type,
3786
3862
  isHovered: isHovered || isHoveredInternal,
@@ -3790,7 +3866,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3790
3866
  size: size,
3791
3867
  isIconOnly: isIconOnly,
3792
3868
  isStretch: stretch,
3793
- children: /*#__PURE__*/jsxs(ButtonPadding, {
3869
+ children: [timerAttrs ? /*#__PURE__*/jsx(ButtonGauge, _objectSpread({}, timerAttrs)) : null, /*#__PURE__*/jsxs(ButtonPadding, {
3794
3870
  size: size,
3795
3871
  isIconOnly: isIconOnly,
3796
3872
  children: [/*#__PURE__*/jsx(ButtonContent, {
@@ -3812,7 +3888,7 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
3812
3888
  isHovered: isHovered,
3813
3889
  isPressed: isPressed
3814
3890
  })]
3815
- })
3891
+ })]
3816
3892
  });
3817
3893
  }
3818
3894
  });
@@ -13409,14 +13485,14 @@ function TypographyEmoji(_ref3) {
13409
13485
  });
13410
13486
  }
13411
13487
 
13412
- // overrides :global(a) in Link styles.module.css
13413
- var displayUnderline = "kitt-u_displayUnderline_dch42t";
13414
- var displayUnderlineWhenHovered = "kitt-u_displayUnderlineWhenHovered_d80w0t7";
13488
+ var styles = {"displayUnderline":"TypographyLinkWebWrapper-module_displayUnderline__KxwMp","kitt-hover":"TypographyLinkWebWrapper-module_kitt-hover__CyENw","displayUnderlineWhenHovered":"TypographyLinkWebWrapper-module_displayUnderlineWhenHovered__5V5Cl"};
13489
+
13415
13490
  function TypographyLinkWebWrapper(_ref) {
13416
13491
  var children = _ref.children,
13417
13492
  hasNoUnderline = _ref.hasNoUnderline;
13493
+ var className = hasNoUnderline ? "".concat(styles.displayUnderline, " ").concat(styles.displayUnderlineWhenHovered) : styles.displayUnderline;
13418
13494
  return /*#__PURE__*/jsx("span", {
13419
- className: (displayUnderline ) + " " + ((hasNoUnderline ? displayUnderlineWhenHovered : undefined) || ""),
13495
+ className: className,
13420
13496
  children: children
13421
13497
  });
13422
13498
  }