@ornikar/kitt-universal 29.5.1 → 30.0.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,12 +1,4 @@
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);}
10
2
  .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);}
11
3
  .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);}
12
4
  .kitt-u_contentAnimatioExit_cwjstxl{opacity:1;-webkit-transform:rotateZ(0) scale(1);-ms-transform:rotateZ(0) scale(1);transform:rotateZ(0) scale(1);}
@@ -3,9 +3,10 @@ import { View as View$1, ScrollView as ScrollView$1, Pressable as Pressable$1, I
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, ScrollView as ScrollView$2, View as View$2, Linking, Pressable as Pressable$2, StyleSheet, useWindowDimensions } from 'react-native';
6
+ import { Animated, Easing, StyleSheet, Modal, ScrollView as ScrollView$2, View as View$2, Linking, Pressable as Pressable$2, 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 } from 'react-native-reanimated';
9
10
  import { CSSTransition } from 'react-transition-group';
10
11
  import { parse } from '@twemoji/parser';
11
12
  import Downshift, { useSelect } from 'downshift';
@@ -14,7 +15,6 @@ import { launchImageLibraryAsync } from 'expo-image-picker';
14
15
  import { useDebouncedCallback } from 'use-debounce';
15
16
  import { Loader } from '@googlemaps/js-api-loader';
16
17
  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 } 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';
@@ -4144,85 +4144,161 @@ const CardModalRotationContainer = /*#__PURE__*/forwardRef((props, ref) => {
4144
4144
  });
4145
4145
  });
4146
4146
 
4147
- const contentAnimationEnter$1 = "kitt-u_contentAnimationEnter_c11xxy4r";
4148
- const contentAnimatioEnterActive$1 = "kitt-u_contentAnimatioEnterActive_cl52117";
4149
- const contentAnimatioExit$1 = "kitt-u_contentAnimatioExit_cyjczep";
4150
- const contentAnimatioExitActive$1 = "kitt-u_contentAnimatioExitActive_cpsy3dt";
4151
- const contentAnimationClassNames$1 = {
4152
- appear: contentAnimationEnter$1,
4153
- appearActive: contentAnimatioEnterActive$1,
4154
- enter: contentAnimationEnter$1,
4155
- enterActive: contentAnimatioEnterActive$1,
4156
- exit: contentAnimatioExit$1,
4157
- exitActive: contentAnimatioExitActive$1
4158
- };
4159
- const opacityEnter$2 = "kitt-u_opacityEnter_o1ae40dx";
4160
- const opacityEnterActive$2 = "kitt-u_opacityEnterActive_o1t4vl7b";
4161
- const opacityExit$2 = "kitt-u_opacityExit_ogyytm1";
4162
- const opacityExitActive$2 = "kitt-u_opacityExitActive_o18xvk52";
4163
- const opacityClassNames$2 = {
4164
- appear: opacityEnter$2,
4165
- appearActive: opacityEnterActive$2,
4166
- enter: opacityEnter$2,
4167
- enterActive: opacityEnterActive$2,
4168
- exit: opacityExit$2,
4169
- exitActive: opacityExitActive$2
4170
- };
4171
- function CardModalAnimation({
4147
+ function NativeOpacityAnimation({
4148
+ visible,
4172
4149
  children,
4173
- appear = true,
4150
+ onExited
4151
+ }) {
4152
+ const theme = useTheme();
4153
+ const hasRunAnimationRef = useRef(false);
4154
+ function handleAnimationFinished() {
4155
+ if (visible) {
4156
+ hasRunAnimationRef.current = true;
4157
+ }
4158
+ if (!visible && hasRunAnimationRef.current) {
4159
+ onExited();
4160
+ }
4161
+ }
4162
+ const opacityStyle = useAnimatedStyle(() => {
4163
+ const {
4164
+ duration,
4165
+ easing
4166
+ } = theme.kitt.cardModal.animation.overlay;
4167
+ const {
4168
+ x1,
4169
+ y1,
4170
+ x2,
4171
+ y2
4172
+ } = easing;
4173
+ return {
4174
+ opacity: withTiming(visible ? 1 : 0, {
4175
+ duration,
4176
+ easing: Easing$1.bezier(x1, y1, x2, y2)
4177
+ }, isFinished => {
4178
+ if (!isFinished) return;
4179
+ runOnJS(handleAnimationFinished)();
4180
+ })
4181
+ };
4182
+ }, [visible]);
4183
+ return /*#__PURE__*/jsx(Animated$1.View, {
4184
+ style: [StyleSheet.absoluteFillObject, opacityStyle],
4185
+ children: children
4186
+ });
4187
+ }
4188
+
4189
+ function NativeRotationAnimation({
4174
4190
  visible,
4175
- unmountOnExit = true,
4176
- isAnimationEnabled = true,
4191
+ children,
4192
+ onEntered,
4193
+ onExited
4194
+ }) {
4195
+ const theme = useTheme();
4196
+ const hasRunAnimationRef = useRef(false);
4197
+ const rotation = useSharedValue(0.8);
4198
+ function handleAnimationFinished() {
4199
+ if (visible) {
4200
+ if (onEntered) onEntered();
4201
+ hasRunAnimationRef.current = true;
4202
+ }
4203
+ if (!visible && hasRunAnimationRef.current) onExited();
4204
+ }
4205
+ const animatedStyle = useAnimatedStyle(() => {
4206
+ const {
4207
+ duration,
4208
+ easing
4209
+ } = theme.kitt.cardModal.animation.content;
4210
+ const {
4211
+ x1,
4212
+ y1,
4213
+ x2,
4214
+ y2
4215
+ } = easing;
4216
+ rotation.value = withTiming(visible ? 0 : 5, {
4217
+ duration,
4218
+ easing: Easing$1.bezier(x1, y1, x2, y2)
4219
+ }, isFinished => {
4220
+ if (!isFinished) return;
4221
+ runOnJS(handleAnimationFinished)();
4222
+ });
4223
+ return {
4224
+ opacity: withTiming(visible ? 1 : 0, {
4225
+ duration,
4226
+ easing: Easing$1.bezier(x1, y1, x2, y2)
4227
+ }),
4228
+ transform: [{
4229
+ scale: withTiming(visible ? 1 : 0.8, {
4230
+ duration,
4231
+ easing: Easing$1.bezier(x1, y1, x2, y2)
4232
+ })
4233
+ }, {
4234
+ rotateZ: `${rotation.value}deg`
4235
+ }]
4236
+ };
4237
+ }, [rotation, visible]);
4238
+ return /*#__PURE__*/jsx(Animated$1.View, {
4239
+ style: [{
4240
+ flexShrink: 1
4241
+ }, animatedStyle],
4242
+ children: children
4243
+ });
4244
+ }
4245
+
4246
+ function CardModalAnimation({
4247
+ visible,
4248
+ children,
4177
4249
  onEnter,
4178
4250
  onEntered,
4179
4251
  onExit,
4180
4252
  onExited,
4181
- onClose,
4182
- ...props
4253
+ onClose
4183
4254
  }) {
4184
- // React 19 has removed the ReactDOM.findDOMNode method. We need to use refs to access DOM nodes in CSSTransition.
4185
- // See https://github.com/reactjs/react-transition-group/issues/918
4186
- const overlayRef = useRef(null);
4187
- const contentRef = useRef(null);
4188
- const theme = useTheme();
4189
- const {
4190
- animation
4191
- } = theme.kitt.cardModal;
4192
- const sharedProps = {
4193
- in: visible,
4194
- appear,
4195
- unmountOnExit
4255
+ const [isModalVisible, setIsModalVisible] = useState(visible);
4256
+ const [isContentVisible, setIsContentVisible] = useState(false);
4257
+ const handleAnimationExited = () => {
4258
+ setIsModalVisible(false);
4259
+ // Android doesn't handle the onDismiss callback on the modal, we need to call it manually
4196
4260
  };
4197
- return /*#__PURE__*/jsxs(View, {
4198
- ...props,
4199
- height: "100%",
4200
- justifyContent: "center",
4201
- children: [/*#__PURE__*/jsx(CSSTransition, {
4202
- ...sharedProps,
4203
- nodeRef: overlayRef,
4204
- timeout: isAnimationEnabled ? animation.overlay.duration : 0,
4205
- classNames: opacityClassNames$2,
4206
- children: /*#__PURE__*/jsx(Overlay, {
4207
- ref: overlayRef,
4208
- onPress: onClose
4209
- })
4210
- }), /*#__PURE__*/jsx(CSSTransition, {
4211
- ...sharedProps,
4212
- nodeRef: contentRef,
4213
- timeout: isAnimationEnabled ? animation.content.duration : 0,
4214
- classNames: contentAnimationClassNames$1,
4215
- onEnter: onEnter,
4216
- onEntered: onEntered,
4217
- onExit: onExit,
4218
- onExited: onExited,
4219
- children: /*#__PURE__*/jsx(CardModalRotationContainer, {
4220
- ref: contentRef,
4221
- alignItems: "center",
4222
- margin: "auto",
4223
- children: children
4224
- })
4225
- })]
4261
+ useEffect(() => {
4262
+ if (!(!visible && isContentVisible)) return;
4263
+ if (onExit) onExit();
4264
+ setIsContentVisible(false);
4265
+ }, [visible, isContentVisible, onExit]);
4266
+ return /*#__PURE__*/jsx(Modal, {
4267
+ transparent: true,
4268
+ supportedOrientations: ['landscape', 'portrait'],
4269
+ visible: isModalVisible,
4270
+ onShow: () => {
4271
+ if (onEnter) onEnter();
4272
+ setIsContentVisible(true);
4273
+ },
4274
+ onDismiss: () => {
4275
+ if (onExited) onExited();
4276
+ },
4277
+ children: /*#__PURE__*/jsxs(View
4278
+ // This is an ugly workaround to make the Modal calculate its height correctly on Android.
4279
+ // This ugly workaround is used in FullScreenModalAnimation and DialogModalAnimation as well
4280
+ // TODO [expo@>=53]: Check if still needed
4281
+ , {
4282
+ height: undefined,
4283
+ position: "relative",
4284
+ flexGrow: 1,
4285
+ justifyContent: "center",
4286
+ alignItems: "center",
4287
+ children: [/*#__PURE__*/jsx(NativeOpacityAnimation, {
4288
+ visible: isContentVisible,
4289
+ onExited: handleAnimationExited,
4290
+ children: /*#__PURE__*/jsx(Overlay, {
4291
+ onPress: onClose
4292
+ })
4293
+ }), /*#__PURE__*/jsx(CardModalRotationContainer, {
4294
+ children: /*#__PURE__*/jsx(NativeRotationAnimation, {
4295
+ visible: isContentVisible,
4296
+ onExited: handleAnimationExited,
4297
+ onEntered: onEntered,
4298
+ children: children
4299
+ })
4300
+ })]
4301
+ })
4226
4302
  });
4227
4303
  }
4228
4304