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