@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
@@ -1,4 +1,12 @@
1
1
  .kitt-u_overflowHidden_otm3u3{overflow:hidden;}
2
+ .kitt-u_contentAnimationEnter_c11xxy4r{opacity:0;-webkit-transform:rotateZ(5deg) scale(0.8);-ms-transform:rotateZ(5deg) scale(0.8);transform:rotateZ(5deg) scale(0.8);}
3
+ .kitt-u_contentAnimatioEnterActive_cl52117{opacity:1;-webkit-transform:rotateZ(0) scale(1);-ms-transform:rotateZ(0) scale(1);transform:rotateZ(0) scale(1);-webkit-transition:all 400ms cubic-bezier(0.77,0,0.175,1);transition:all 400ms cubic-bezier(0.77,0,0.175,1);}
4
+ .kitt-u_contentAnimatioExit_cyjczep{opacity:1;-webkit-transform:rotateZ(0) scale(1);-ms-transform:rotateZ(0) scale(1);transform:rotateZ(0) scale(1);}
5
+ .kitt-u_contentAnimatioExitActive_cpsy3dt{opacity:0;-webkit-transform:rotateZ(5deg) scale(0.8);-ms-transform:rotateZ(5deg) scale(0.8);transform:rotateZ(5deg) scale(0.8);-webkit-transition:all 400ms cubic-bezier(0.77,0,0.175,1);transition:all 400ms cubic-bezier(0.77,0,0.175,1);}
6
+ .kitt-u_opacityEnter_o1ae40dx{opacity:0;}
7
+ .kitt-u_opacityEnterActive_o1t4vl7b{opacity:1;-webkit-transition:opacity 250ms cubic-bezier(0.42,0,1,1);transition:opacity 250ms cubic-bezier(0.42,0,1,1);}
8
+ .kitt-u_opacityExit_ogyytm1{opacity:1;}
9
+ .kitt-u_opacityExitActive_o18xvk52{opacity:0;-webkit-transition:opacity 250ms cubic-bezier(0.42,0,1,1);transition:opacity 250ms cubic-bezier(0.42,0,1,1);}
2
10
  .kitt-u_contentAnimationEnter_c1i0gle8{opacity:0;-webkit-transform:rotateZ(5deg) scale(0.8);-ms-transform:rotateZ(5deg) scale(0.8);transform:rotateZ(5deg) scale(0.8);}
3
11
  .kitt-u_contentAnimatioEnterActive_c1jmfkjw{opacity:1;-webkit-transform:rotateZ(0) scale(1);-ms-transform:rotateZ(0) scale(1);transform:rotateZ(0) scale(1);-webkit-transition:all 400ms cubic-bezier(0.77,0,0.175,1);transition:all 400ms cubic-bezier(0.77,0,0.175,1);}
4
12
  .kitt-u_contentAnimatioExit_cwjstxl{opacity:1;-webkit-transform:rotateZ(0) scale(1);-ms-transform:rotateZ(0) scale(1);transform:rotateZ(0) scale(1);}
@@ -8,7 +8,6 @@ const jsxRuntime = require('react/jsx-runtime');
8
8
  const phosphor = require('@ornikar/kitt-icons/phosphor');
9
9
  const reactNative = require('react-native');
10
10
  const reactDom = require('react-dom');
11
- const Animated = require('react-native-reanimated');
12
11
  const reactTransitionGroup = require('react-transition-group');
13
12
  const parser = require('@twemoji/parser');
14
13
  const Downshift = require('downshift');
@@ -17,6 +16,7 @@ const expoImagePicker = require('expo-image-picker');
17
16
  const useDebounce = require('use-debounce');
18
17
  const jsApiLoader = require('@googlemaps/js-api-loader');
19
18
  const libphonenumberJs = require('libphonenumber-js');
19
+ const Animated = require('react-native-reanimated');
20
20
  const reactNativeSafeAreaContext = require('react-native-safe-area-context');
21
21
  const Svg = require('react-native-svg');
22
22
  const reactDom$1 = require('@floating-ui/react-dom');
@@ -26,8 +26,8 @@ const isChromatic = require('chromatic/isChromatic');
26
26
 
27
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
28
28
 
29
- const Animated__default = /*#__PURE__*/_interopDefaultLegacy(Animated);
30
29
  const Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
30
+ const Animated__default = /*#__PURE__*/_interopDefaultLegacy(Animated);
31
31
  const Svg__default = /*#__PURE__*/_interopDefaultLegacy(Svg);
32
32
  const isChromatic__default = /*#__PURE__*/_interopDefaultLegacy(isChromatic);
33
33
 
@@ -3651,6 +3651,79 @@ function ButtonContent({
3651
3651
  });
3652
3652
  }
3653
3653
 
3654
+ function ButtonGauge({
3655
+ duration,
3656
+ running,
3657
+ onEnded
3658
+ }) {
3659
+ const [translate, setTranslate] = react.useState(100);
3660
+ const startTimeRef = react.useRef(0);
3661
+ const pauseTimeRef = react.useRef(0);
3662
+ const rafRef = react.useRef(undefined);
3663
+ const distance = 100;
3664
+ const draw = react.useCallback(timestamp => {
3665
+ const timeElapsedSinceStart = timestamp - startTimeRef.current;
3666
+ // Since the time between frame is not reliable and regular, we have to
3667
+ // limit the progress to prevent overflows
3668
+ const safeProgress = Math.min(distance * timeElapsedSinceStart / duration, distance);
3669
+ setTranslate(safeProgress);
3670
+ if (safeProgress < distance) {
3671
+ if (!rafRef) return;
3672
+ rafRef.current = requestAnimationFrame(draw);
3673
+ return;
3674
+ }
3675
+ onEnded();
3676
+ if (rafRef.current) {
3677
+ cancelAnimationFrame(rafRef.current);
3678
+ }
3679
+ },
3680
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3681
+ []);
3682
+ react.useLayoutEffect(() => {
3683
+ if (running) {
3684
+ // Resuming from pause
3685
+ if (pauseTimeRef.current > 0) {
3686
+ startTimeRef.current += global.performance.now() - pauseTimeRef.current;
3687
+ draw(global.performance.now());
3688
+ return;
3689
+ }
3690
+
3691
+ // First launch
3692
+ startTimeRef.current = global.performance.now();
3693
+ draw(startTimeRef.current);
3694
+ }
3695
+
3696
+ // On pause
3697
+ if (!running && rafRef.current) {
3698
+ pauseTimeRef.current = global.performance.now();
3699
+ cancelAnimationFrame(rafRef.current);
3700
+ }
3701
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3702
+ }, [running]);
3703
+ react.useEffect(() => {
3704
+ return () => {
3705
+ if (rafRef.current) {
3706
+ cancelAnimationFrame(rafRef.current);
3707
+ }
3708
+ };
3709
+ }, []);
3710
+ return /*#__PURE__*/jsxRuntime.jsx(View, {
3711
+ position: "absolute",
3712
+ left: 0,
3713
+ right: 0,
3714
+ top: 0,
3715
+ bottom: 0,
3716
+ overflow: "hidden",
3717
+ alignItems: "flex-end",
3718
+ borderRadius: "kitt.button.borderRadius",
3719
+ children: /*#__PURE__*/jsxRuntime.jsx(View, {
3720
+ width: `${translate}%`,
3721
+ height: "100%",
3722
+ backgroundColor: "kitt.palettes.deepPurple['white-alpha.20']"
3723
+ })
3724
+ });
3725
+ }
3726
+
3654
3727
  function ButtonPadding({
3655
3728
  children,
3656
3729
  size,
@@ -3723,6 +3796,7 @@ const Button = /*#__PURE__*/react.forwardRef(({
3723
3796
  hrefAttrs,
3724
3797
  withBadge,
3725
3798
  badgeCount,
3799
+ timerAttrs,
3726
3800
  accessibilityRole = 'button',
3727
3801
  innerSpacing = 'center',
3728
3802
  isHoveredInternal,
@@ -3767,7 +3841,7 @@ const Button = /*#__PURE__*/react.forwardRef(({
3767
3841
  isHovered,
3768
3842
  isPressed,
3769
3843
  isFocused
3770
- }) => /*#__PURE__*/jsxRuntime.jsx(AnimatedContainer$2, {
3844
+ }) => /*#__PURE__*/jsxRuntime.jsxs(AnimatedContainer$2, {
3771
3845
  animatedStyles: animatedStyles,
3772
3846
  type: type,
3773
3847
  isHovered: isHovered || isHoveredInternal,
@@ -3777,7 +3851,9 @@ const Button = /*#__PURE__*/react.forwardRef(({
3777
3851
  size: size,
3778
3852
  isIconOnly: isIconOnly,
3779
3853
  isStretch: stretch,
3780
- children: /*#__PURE__*/jsxRuntime.jsxs(ButtonPadding, {
3854
+ children: [timerAttrs ? /*#__PURE__*/jsxRuntime.jsx(ButtonGauge, {
3855
+ ...timerAttrs
3856
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs(ButtonPadding, {
3781
3857
  size: size,
3782
3858
  isIconOnly: isIconOnly,
3783
3859
  children: [/*#__PURE__*/jsxRuntime.jsx(ButtonContent, {
@@ -3799,7 +3875,7 @@ const Button = /*#__PURE__*/react.forwardRef(({
3799
3875
  isHovered: isHovered,
3800
3876
  isPressed: isPressed
3801
3877
  })]
3802
- })
3878
+ })]
3803
3879
  })
3804
3880
  });
3805
3881
  });
@@ -4257,161 +4333,85 @@ const CardModalRotationContainer = /*#__PURE__*/react.forwardRef((props, ref) =>
4257
4333
  });
4258
4334
  });
4259
4335
 
4260
- function NativeOpacityAnimation({
4261
- visible,
4262
- children,
4263
- onExited
4264
- }) {
4265
- const theme = useTheme();
4266
- const hasRunAnimationRef = react.useRef(false);
4267
- function handleAnimationFinished() {
4268
- if (visible) {
4269
- hasRunAnimationRef.current = true;
4270
- }
4271
- if (!visible && hasRunAnimationRef.current) {
4272
- onExited();
4273
- }
4274
- }
4275
- const opacityStyle = Animated.useAnimatedStyle(() => {
4276
- const {
4277
- duration,
4278
- easing
4279
- } = theme.kitt.cardModal.animation.overlay;
4280
- const {
4281
- x1,
4282
- y1,
4283
- x2,
4284
- y2
4285
- } = easing;
4286
- return {
4287
- opacity: Animated.withTiming(visible ? 1 : 0, {
4288
- duration,
4289
- easing: Animated.Easing.bezier(x1, y1, x2, y2)
4290
- }, isFinished => {
4291
- if (!isFinished) return;
4292
- Animated.runOnJS(handleAnimationFinished)();
4293
- })
4294
- };
4295
- }, [visible]);
4296
- return /*#__PURE__*/jsxRuntime.jsx(Animated__default.View, {
4297
- style: [reactNative.StyleSheet.absoluteFillObject, opacityStyle],
4298
- children: children
4299
- });
4300
- }
4301
-
4302
- function NativeRotationAnimation({
4303
- visible,
4304
- children,
4305
- onEntered,
4306
- onExited
4307
- }) {
4308
- const theme = useTheme();
4309
- const hasRunAnimationRef = react.useRef(false);
4310
- const rotation = Animated.useSharedValue(0.8);
4311
- function handleAnimationFinished() {
4312
- if (visible) {
4313
- if (onEntered) onEntered();
4314
- hasRunAnimationRef.current = true;
4315
- }
4316
- if (!visible && hasRunAnimationRef.current) onExited();
4317
- }
4318
- const animatedStyle = Animated.useAnimatedStyle(() => {
4319
- const {
4320
- duration,
4321
- easing
4322
- } = theme.kitt.cardModal.animation.content;
4323
- const {
4324
- x1,
4325
- y1,
4326
- x2,
4327
- y2
4328
- } = easing;
4329
- rotation.value = Animated.withTiming(visible ? 0 : 5, {
4330
- duration,
4331
- easing: Animated.Easing.bezier(x1, y1, x2, y2)
4332
- }, isFinished => {
4333
- if (!isFinished) return;
4334
- Animated.runOnJS(handleAnimationFinished)();
4335
- });
4336
- return {
4337
- opacity: Animated.withTiming(visible ? 1 : 0, {
4338
- duration,
4339
- easing: Animated.Easing.bezier(x1, y1, x2, y2)
4340
- }),
4341
- transform: [{
4342
- scale: Animated.withTiming(visible ? 1 : 0.8, {
4343
- duration,
4344
- easing: Animated.Easing.bezier(x1, y1, x2, y2)
4345
- })
4346
- }, {
4347
- rotateZ: `${rotation.value}deg`
4348
- }]
4349
- };
4350
- }, [rotation, visible]);
4351
- return /*#__PURE__*/jsxRuntime.jsx(Animated__default.View, {
4352
- style: [{
4353
- flexShrink: 1
4354
- }, animatedStyle],
4355
- children: children
4356
- });
4357
- }
4358
-
4336
+ const contentAnimationEnter$1 = "kitt-u_contentAnimationEnter_c11xxy4r";
4337
+ const contentAnimatioEnterActive$1 = "kitt-u_contentAnimatioEnterActive_cl52117";
4338
+ const contentAnimatioExit$1 = "kitt-u_contentAnimatioExit_cyjczep";
4339
+ const contentAnimatioExitActive$1 = "kitt-u_contentAnimatioExitActive_cpsy3dt";
4340
+ const contentAnimationClassNames$1 = {
4341
+ appear: contentAnimationEnter$1,
4342
+ appearActive: contentAnimatioEnterActive$1,
4343
+ enter: contentAnimationEnter$1,
4344
+ enterActive: contentAnimatioEnterActive$1,
4345
+ exit: contentAnimatioExit$1,
4346
+ exitActive: contentAnimatioExitActive$1
4347
+ };
4348
+ const opacityEnter$2 = "kitt-u_opacityEnter_o1ae40dx";
4349
+ const opacityEnterActive$2 = "kitt-u_opacityEnterActive_o1t4vl7b";
4350
+ const opacityExit$2 = "kitt-u_opacityExit_ogyytm1";
4351
+ const opacityExitActive$2 = "kitt-u_opacityExitActive_o18xvk52";
4352
+ const opacityClassNames$2 = {
4353
+ appear: opacityEnter$2,
4354
+ appearActive: opacityEnterActive$2,
4355
+ enter: opacityEnter$2,
4356
+ enterActive: opacityEnterActive$2,
4357
+ exit: opacityExit$2,
4358
+ exitActive: opacityExitActive$2
4359
+ };
4359
4360
  function CardModalAnimation({
4360
- visible,
4361
4361
  children,
4362
+ appear = true,
4363
+ visible,
4364
+ unmountOnExit = true,
4365
+ isAnimationEnabled = true,
4362
4366
  onEnter,
4363
4367
  onEntered,
4364
4368
  onExit,
4365
4369
  onExited,
4366
- onClose
4370
+ onClose,
4371
+ ...props
4367
4372
  }) {
4368
- const [isModalVisible, setIsModalVisible] = react.useState(visible);
4369
- const [isContentVisible, setIsContentVisible] = react.useState(false);
4370
- const handleAnimationExited = () => {
4371
- setIsModalVisible(false);
4372
- // Android doesn't handle the onDismiss callback on the modal, we need to call it manually
4373
+ // React 19 has removed the ReactDOM.findDOMNode method. We need to use refs to access DOM nodes in CSSTransition.
4374
+ // See https://github.com/reactjs/react-transition-group/issues/918
4375
+ const overlayRef = react.useRef(null);
4376
+ const contentRef = react.useRef(null);
4377
+ const theme = useTheme();
4378
+ const {
4379
+ animation
4380
+ } = theme.kitt.cardModal;
4381
+ const sharedProps = {
4382
+ in: visible,
4383
+ appear,
4384
+ unmountOnExit
4373
4385
  };
4374
- react.useEffect(() => {
4375
- if (!(!visible && isContentVisible)) return;
4376
- if (onExit) onExit();
4377
- setIsContentVisible(false);
4378
- }, [visible, isContentVisible, onExit]);
4379
- return /*#__PURE__*/jsxRuntime.jsx(reactNative.Modal, {
4380
- transparent: true,
4381
- supportedOrientations: ['landscape', 'portrait'],
4382
- visible: isModalVisible,
4383
- onShow: () => {
4384
- if (onEnter) onEnter();
4385
- setIsContentVisible(true);
4386
- },
4387
- onDismiss: () => {
4388
- if (onExited) onExited();
4389
- },
4390
- children: /*#__PURE__*/jsxRuntime.jsxs(View
4391
- // This is an ugly workaround to make the Modal calculate its height correctly on Android.
4392
- // This ugly workaround is used in FullScreenModalAnimation and DialogModalAnimation as well
4393
- // TODO [expo@>=53]: Check if still needed
4394
- , {
4395
- height: undefined,
4396
- position: "relative",
4397
- flexGrow: 1,
4398
- justifyContent: "center",
4399
- alignItems: "center",
4400
- children: [/*#__PURE__*/jsxRuntime.jsx(NativeOpacityAnimation, {
4401
- visible: isContentVisible,
4402
- onExited: handleAnimationExited,
4403
- children: /*#__PURE__*/jsxRuntime.jsx(Overlay, {
4404
- onPress: onClose
4405
- })
4406
- }), /*#__PURE__*/jsxRuntime.jsx(CardModalRotationContainer, {
4407
- children: /*#__PURE__*/jsxRuntime.jsx(NativeRotationAnimation, {
4408
- visible: isContentVisible,
4409
- onExited: handleAnimationExited,
4410
- onEntered: onEntered,
4411
- children: children
4412
- })
4413
- })]
4414
- })
4386
+ return /*#__PURE__*/jsxRuntime.jsxs(View, {
4387
+ ...props,
4388
+ height: "100%",
4389
+ justifyContent: "center",
4390
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
4391
+ ...sharedProps,
4392
+ nodeRef: overlayRef,
4393
+ timeout: isAnimationEnabled ? animation.overlay.duration : 0,
4394
+ classNames: opacityClassNames$2,
4395
+ children: /*#__PURE__*/jsxRuntime.jsx(Overlay, {
4396
+ ref: overlayRef,
4397
+ onPress: onClose
4398
+ })
4399
+ }), /*#__PURE__*/jsxRuntime.jsx(reactTransitionGroup.CSSTransition, {
4400
+ ...sharedProps,
4401
+ nodeRef: contentRef,
4402
+ timeout: isAnimationEnabled ? animation.content.duration : 0,
4403
+ classNames: contentAnimationClassNames$1,
4404
+ onEnter: onEnter,
4405
+ onEntered: onEntered,
4406
+ onExit: onExit,
4407
+ onExited: onExited,
4408
+ children: /*#__PURE__*/jsxRuntime.jsx(CardModalRotationContainer, {
4409
+ ref: contentRef,
4410
+ alignItems: "center",
4411
+ margin: "auto",
4412
+ children: children
4413
+ })
4414
+ })]
4415
4415
  });
4416
4416
  }
4417
4417