@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);}
@@ -1,12 +1,11 @@
1
- import { useContext, createContext, forwardRef, useMemo, cloneElement, useRef, useEffect, useState, Children, useReducer, useCallback, Fragment as Fragment$1 } from 'react';
1
+ import { 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 } from 'native-base';
3
3
  export { useClipboard, useContrastText, useMediaQuery, useSx, useToken } from 'native-base';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { SpinnerGapRegularIcon, UserRegularIcon, XRegularIcon, ArrowLeftRegularIcon, CaretUpFillIcon, CaretDownFillIcon, MapPinRegularIcon, EyeClosedRegularIcon, EyeRegularIcon, CheckCircleFillIcon, CaretDownRegularIcon, CaretRightRegularIcon, InfoRegularIcon, WarningRegularIcon, CheckRegularIcon, WarningCircleRegularIcon, ArrowCounterClockwiseRegularIcon, InfoFillIcon, WarningCircleFillIcon, WarningFillIcon } from '@ornikar/kitt-icons/phosphor';
6
- import { Animated, Easing, StyleSheet, Modal, ScrollView as ScrollView$2, View as View$2, Linking, Pressable as Pressable$2, useWindowDimensions } from 'react-native';
6
+ import { Animated, Easing, ScrollView as ScrollView$2, View as View$2, Linking, Pressable as Pressable$2, StyleSheet, useWindowDimensions } from 'react-native';
7
7
  export { useWindowDimensions as useWindowSize } from 'react-native';
8
8
  import { createPortal } from 'react-dom';
9
- import Animated$1, { useAnimatedStyle, withTiming, Easing as Easing$1, runOnJS, useSharedValue, withSpring, interpolateColor, useAnimatedProps, withDelay, withRepeat, interpolate, ReducedMotionConfig, ReduceMotion } from 'react-native-reanimated';
10
9
  import { CSSTransition } from 'react-transition-group';
11
10
  import { parse } from '@twemoji/parser';
12
11
  import Downshift, { useSelect } from 'downshift';
@@ -15,6 +14,7 @@ import { launchImageLibraryAsync } from 'expo-image-picker';
15
14
  import { useDebouncedCallback } from 'use-debounce';
16
15
  import { Loader } from '@googlemaps/js-api-loader';
17
16
  import { parseNumber, getCountryCallingCode, isValidNumber } from 'libphonenumber-js';
17
+ import Animated$1, { useAnimatedStyle, withSpring, withTiming, useSharedValue, interpolateColor, Easing as Easing$1, useAnimatedProps, withDelay, withRepeat, interpolate, runOnJS, ReducedMotionConfig, ReduceMotion } from 'react-native-reanimated';
18
18
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
19
19
  import Svg, { Circle as Circle$1 } from 'react-native-svg';
20
20
  import { useFloating, autoUpdate, offset, autoPlacement, shift, arrow } from '@floating-ui/react-dom';
@@ -3642,6 +3642,79 @@ function ButtonContent({
3642
3642
  });
3643
3643
  }
3644
3644
 
3645
+ function ButtonGauge({
3646
+ duration,
3647
+ running,
3648
+ onEnded
3649
+ }) {
3650
+ const [translate, setTranslate] = useState(100);
3651
+ const startTimeRef = useRef(0);
3652
+ const pauseTimeRef = useRef(0);
3653
+ const rafRef = useRef(undefined);
3654
+ const distance = 100;
3655
+ const draw = useCallback(timestamp => {
3656
+ const timeElapsedSinceStart = timestamp - startTimeRef.current;
3657
+ // Since the time between frame is not reliable and regular, we have to
3658
+ // limit the progress to prevent overflows
3659
+ const safeProgress = Math.min(distance * timeElapsedSinceStart / duration, distance);
3660
+ setTranslate(safeProgress);
3661
+ if (safeProgress < distance) {
3662
+ if (!rafRef) return;
3663
+ rafRef.current = requestAnimationFrame(draw);
3664
+ return;
3665
+ }
3666
+ onEnded();
3667
+ if (rafRef.current) {
3668
+ cancelAnimationFrame(rafRef.current);
3669
+ }
3670
+ },
3671
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3672
+ []);
3673
+ useLayoutEffect(() => {
3674
+ if (running) {
3675
+ // Resuming from pause
3676
+ if (pauseTimeRef.current > 0) {
3677
+ startTimeRef.current += global.performance.now() - pauseTimeRef.current;
3678
+ draw(global.performance.now());
3679
+ return;
3680
+ }
3681
+
3682
+ // First launch
3683
+ startTimeRef.current = global.performance.now();
3684
+ draw(startTimeRef.current);
3685
+ }
3686
+
3687
+ // On pause
3688
+ if (!running && rafRef.current) {
3689
+ pauseTimeRef.current = global.performance.now();
3690
+ cancelAnimationFrame(rafRef.current);
3691
+ }
3692
+ // eslint-disable-next-line react-hooks/exhaustive-deps
3693
+ }, [running]);
3694
+ useEffect(() => {
3695
+ return () => {
3696
+ if (rafRef.current) {
3697
+ cancelAnimationFrame(rafRef.current);
3698
+ }
3699
+ };
3700
+ }, []);
3701
+ return /*#__PURE__*/jsx(View, {
3702
+ position: "absolute",
3703
+ left: 0,
3704
+ right: 0,
3705
+ top: 0,
3706
+ bottom: 0,
3707
+ overflow: "hidden",
3708
+ alignItems: "flex-end",
3709
+ borderRadius: "kitt.button.borderRadius",
3710
+ children: /*#__PURE__*/jsx(View, {
3711
+ width: `${translate}%`,
3712
+ height: "100%",
3713
+ backgroundColor: "kitt.palettes.deepPurple['white-alpha.20']"
3714
+ })
3715
+ });
3716
+ }
3717
+
3645
3718
  function ButtonPadding({
3646
3719
  children,
3647
3720
  size,
@@ -3714,6 +3787,7 @@ const Button = /*#__PURE__*/forwardRef(({
3714
3787
  hrefAttrs,
3715
3788
  withBadge,
3716
3789
  badgeCount,
3790
+ timerAttrs,
3717
3791
  accessibilityRole = 'button',
3718
3792
  innerSpacing = 'center',
3719
3793
  isHoveredInternal,
@@ -3758,7 +3832,7 @@ const Button = /*#__PURE__*/forwardRef(({
3758
3832
  isHovered,
3759
3833
  isPressed,
3760
3834
  isFocused
3761
- }) => /*#__PURE__*/jsx(AnimatedContainer$2, {
3835
+ }) => /*#__PURE__*/jsxs(AnimatedContainer$2, {
3762
3836
  animatedStyles: animatedStyles,
3763
3837
  type: type,
3764
3838
  isHovered: isHovered || isHoveredInternal,
@@ -3768,7 +3842,9 @@ const Button = /*#__PURE__*/forwardRef(({
3768
3842
  size: size,
3769
3843
  isIconOnly: isIconOnly,
3770
3844
  isStretch: stretch,
3771
- children: /*#__PURE__*/jsxs(ButtonPadding, {
3845
+ children: [timerAttrs ? /*#__PURE__*/jsx(ButtonGauge, {
3846
+ ...timerAttrs
3847
+ }) : null, /*#__PURE__*/jsxs(ButtonPadding, {
3772
3848
  size: size,
3773
3849
  isIconOnly: isIconOnly,
3774
3850
  children: [/*#__PURE__*/jsx(ButtonContent, {
@@ -3790,7 +3866,7 @@ const Button = /*#__PURE__*/forwardRef(({
3790
3866
  isHovered: isHovered,
3791
3867
  isPressed: isPressed
3792
3868
  })]
3793
- })
3869
+ })]
3794
3870
  })
3795
3871
  });
3796
3872
  });
@@ -4248,161 +4324,85 @@ const CardModalRotationContainer = /*#__PURE__*/forwardRef((props, ref) => {
4248
4324
  });
4249
4325
  });
4250
4326
 
4251
- function NativeOpacityAnimation({
4252
- visible,
4253
- children,
4254
- onExited
4255
- }) {
4256
- const theme = useTheme();
4257
- const hasRunAnimationRef = useRef(false);
4258
- function handleAnimationFinished() {
4259
- if (visible) {
4260
- hasRunAnimationRef.current = true;
4261
- }
4262
- if (!visible && hasRunAnimationRef.current) {
4263
- onExited();
4264
- }
4265
- }
4266
- const opacityStyle = useAnimatedStyle(() => {
4267
- const {
4268
- duration,
4269
- easing
4270
- } = theme.kitt.cardModal.animation.overlay;
4271
- const {
4272
- x1,
4273
- y1,
4274
- x2,
4275
- y2
4276
- } = easing;
4277
- return {
4278
- opacity: withTiming(visible ? 1 : 0, {
4279
- duration,
4280
- easing: Easing$1.bezier(x1, y1, x2, y2)
4281
- }, isFinished => {
4282
- if (!isFinished) return;
4283
- runOnJS(handleAnimationFinished)();
4284
- })
4285
- };
4286
- }, [visible]);
4287
- return /*#__PURE__*/jsx(Animated$1.View, {
4288
- style: [StyleSheet.absoluteFillObject, opacityStyle],
4289
- children: children
4290
- });
4291
- }
4292
-
4293
- function NativeRotationAnimation({
4294
- visible,
4295
- children,
4296
- onEntered,
4297
- onExited
4298
- }) {
4299
- const theme = useTheme();
4300
- const hasRunAnimationRef = useRef(false);
4301
- const rotation = useSharedValue(0.8);
4302
- function handleAnimationFinished() {
4303
- if (visible) {
4304
- if (onEntered) onEntered();
4305
- hasRunAnimationRef.current = true;
4306
- }
4307
- if (!visible && hasRunAnimationRef.current) onExited();
4308
- }
4309
- const animatedStyle = useAnimatedStyle(() => {
4310
- const {
4311
- duration,
4312
- easing
4313
- } = theme.kitt.cardModal.animation.content;
4314
- const {
4315
- x1,
4316
- y1,
4317
- x2,
4318
- y2
4319
- } = easing;
4320
- rotation.value = withTiming(visible ? 0 : 5, {
4321
- duration,
4322
- easing: Easing$1.bezier(x1, y1, x2, y2)
4323
- }, isFinished => {
4324
- if (!isFinished) return;
4325
- runOnJS(handleAnimationFinished)();
4326
- });
4327
- return {
4328
- opacity: withTiming(visible ? 1 : 0, {
4329
- duration,
4330
- easing: Easing$1.bezier(x1, y1, x2, y2)
4331
- }),
4332
- transform: [{
4333
- scale: withTiming(visible ? 1 : 0.8, {
4334
- duration,
4335
- easing: Easing$1.bezier(x1, y1, x2, y2)
4336
- })
4337
- }, {
4338
- rotateZ: `${rotation.value}deg`
4339
- }]
4340
- };
4341
- }, [rotation, visible]);
4342
- return /*#__PURE__*/jsx(Animated$1.View, {
4343
- style: [{
4344
- flexShrink: 1
4345
- }, animatedStyle],
4346
- children: children
4347
- });
4348
- }
4349
-
4327
+ const contentAnimationEnter$1 = "kitt-u_contentAnimationEnter_c11xxy4r";
4328
+ const contentAnimatioEnterActive$1 = "kitt-u_contentAnimatioEnterActive_cl52117";
4329
+ const contentAnimatioExit$1 = "kitt-u_contentAnimatioExit_cyjczep";
4330
+ const contentAnimatioExitActive$1 = "kitt-u_contentAnimatioExitActive_cpsy3dt";
4331
+ const contentAnimationClassNames$1 = {
4332
+ appear: contentAnimationEnter$1,
4333
+ appearActive: contentAnimatioEnterActive$1,
4334
+ enter: contentAnimationEnter$1,
4335
+ enterActive: contentAnimatioEnterActive$1,
4336
+ exit: contentAnimatioExit$1,
4337
+ exitActive: contentAnimatioExitActive$1
4338
+ };
4339
+ const opacityEnter$2 = "kitt-u_opacityEnter_o1ae40dx";
4340
+ const opacityEnterActive$2 = "kitt-u_opacityEnterActive_o1t4vl7b";
4341
+ const opacityExit$2 = "kitt-u_opacityExit_ogyytm1";
4342
+ const opacityExitActive$2 = "kitt-u_opacityExitActive_o18xvk52";
4343
+ const opacityClassNames$2 = {
4344
+ appear: opacityEnter$2,
4345
+ appearActive: opacityEnterActive$2,
4346
+ enter: opacityEnter$2,
4347
+ enterActive: opacityEnterActive$2,
4348
+ exit: opacityExit$2,
4349
+ exitActive: opacityExitActive$2
4350
+ };
4350
4351
  function CardModalAnimation({
4351
- visible,
4352
4352
  children,
4353
+ appear = true,
4354
+ visible,
4355
+ unmountOnExit = true,
4356
+ isAnimationEnabled = true,
4353
4357
  onEnter,
4354
4358
  onEntered,
4355
4359
  onExit,
4356
4360
  onExited,
4357
- onClose
4361
+ onClose,
4362
+ ...props
4358
4363
  }) {
4359
- const [isModalVisible, setIsModalVisible] = useState(visible);
4360
- const [isContentVisible, setIsContentVisible] = useState(false);
4361
- const handleAnimationExited = () => {
4362
- setIsModalVisible(false);
4363
- // Android doesn't handle the onDismiss callback on the modal, we need to call it manually
4364
+ // React 19 has removed the ReactDOM.findDOMNode method. We need to use refs to access DOM nodes in CSSTransition.
4365
+ // See https://github.com/reactjs/react-transition-group/issues/918
4366
+ const overlayRef = useRef(null);
4367
+ const contentRef = useRef(null);
4368
+ const theme = useTheme();
4369
+ const {
4370
+ animation
4371
+ } = theme.kitt.cardModal;
4372
+ const sharedProps = {
4373
+ in: visible,
4374
+ appear,
4375
+ unmountOnExit
4364
4376
  };
4365
- useEffect(() => {
4366
- if (!(!visible && isContentVisible)) return;
4367
- if (onExit) onExit();
4368
- setIsContentVisible(false);
4369
- }, [visible, isContentVisible, onExit]);
4370
- return /*#__PURE__*/jsx(Modal, {
4371
- transparent: true,
4372
- supportedOrientations: ['landscape', 'portrait'],
4373
- visible: isModalVisible,
4374
- onShow: () => {
4375
- if (onEnter) onEnter();
4376
- setIsContentVisible(true);
4377
- },
4378
- onDismiss: () => {
4379
- if (onExited) onExited();
4380
- },
4381
- children: /*#__PURE__*/jsxs(View
4382
- // This is an ugly workaround to make the Modal calculate its height correctly on Android.
4383
- // This ugly workaround is used in FullScreenModalAnimation and DialogModalAnimation as well
4384
- // TODO [expo@>=53]: Check if still needed
4385
- , {
4386
- height: undefined,
4387
- position: "relative",
4388
- flexGrow: 1,
4389
- justifyContent: "center",
4390
- alignItems: "center",
4391
- children: [/*#__PURE__*/jsx(NativeOpacityAnimation, {
4392
- visible: isContentVisible,
4393
- onExited: handleAnimationExited,
4394
- children: /*#__PURE__*/jsx(Overlay, {
4395
- onPress: onClose
4396
- })
4397
- }), /*#__PURE__*/jsx(CardModalRotationContainer, {
4398
- children: /*#__PURE__*/jsx(NativeRotationAnimation, {
4399
- visible: isContentVisible,
4400
- onExited: handleAnimationExited,
4401
- onEntered: onEntered,
4402
- children: children
4403
- })
4404
- })]
4405
- })
4377
+ return /*#__PURE__*/jsxs(View, {
4378
+ ...props,
4379
+ height: "100%",
4380
+ justifyContent: "center",
4381
+ children: [/*#__PURE__*/jsx(CSSTransition, {
4382
+ ...sharedProps,
4383
+ nodeRef: overlayRef,
4384
+ timeout: isAnimationEnabled ? animation.overlay.duration : 0,
4385
+ classNames: opacityClassNames$2,
4386
+ children: /*#__PURE__*/jsx(Overlay, {
4387
+ ref: overlayRef,
4388
+ onPress: onClose
4389
+ })
4390
+ }), /*#__PURE__*/jsx(CSSTransition, {
4391
+ ...sharedProps,
4392
+ nodeRef: contentRef,
4393
+ timeout: isAnimationEnabled ? animation.content.duration : 0,
4394
+ classNames: contentAnimationClassNames$1,
4395
+ onEnter: onEnter,
4396
+ onEntered: onEntered,
4397
+ onExit: onExit,
4398
+ onExited: onExited,
4399
+ children: /*#__PURE__*/jsx(CardModalRotationContainer, {
4400
+ ref: contentRef,
4401
+ alignItems: "center",
4402
+ margin: "auto",
4403
+ children: children
4404
+ })
4405
+ })]
4406
4406
  });
4407
4407
  }
4408
4408