@ornikar/kitt-universal 31.1.1 → 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 (30) hide show
  1. package/CHANGELOG.md +15 -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/index-metro.es.android.js +81 -9
  11. package/dist/index-metro.es.android.js.map +1 -1
  12. package/dist/index-metro.es.ios.js +81 -9
  13. package/dist/index-metro.es.ios.js.map +1 -1
  14. package/dist/index-node-22.17.cjs.js +82 -8
  15. package/dist/index-node-22.17.cjs.js.map +1 -1
  16. package/dist/index-node-22.17.cjs.web.css +8 -0
  17. package/dist/index-node-22.17.cjs.web.js +152 -152
  18. package/dist/index-node-22.17.cjs.web.js.map +1 -1
  19. package/dist/index-node-22.17.es.mjs +83 -9
  20. package/dist/index-node-22.17.es.mjs.map +1 -1
  21. package/dist/index-node-22.17.es.web.css +8 -0
  22. package/dist/index-node-22.17.es.web.mjs +153 -153
  23. package/dist/index-node-22.17.es.web.mjs.map +1 -1
  24. package/dist/index.es.js +83 -9
  25. package/dist/index.es.js.map +1 -1
  26. package/dist/index.es.web.js +168 -167
  27. package/dist/index.es.web.js.map +1 -1
  28. package/dist/styles.css +8 -0
  29. package/dist/tsbuildinfo +1 -1
  30. package/package.json +2 -1
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
  });
@@ -4362,7 +4438,7 @@ function NativeOpacityAnimation$2(_ref) {
4362
4438
  runOnJS(handleAnimationFinished)();
4363
4439
  })
4364
4440
  };
4365
- }, [visible]);
4441
+ });
4366
4442
  return /*#__PURE__*/jsx(Animated.View, {
4367
4443
  style: [StyleSheet.absoluteFillObject, opacityStyle],
4368
4444
  children: children
@@ -4413,11 +4489,9 @@ function NativeRotationAnimation$1(_ref) {
4413
4489
  rotateZ: "".concat(rotation.value, "deg")
4414
4490
  }]
4415
4491
  };
4416
- }, [rotation, visible]);
4492
+ });
4417
4493
  return /*#__PURE__*/jsx(Animated.View, {
4418
- style: [{
4419
- flexShrink: 1
4420
- }, animatedStyle],
4494
+ style: [animatedStyle],
4421
4495
  children: children
4422
4496
  });
4423
4497
  }