UNPKG

4.5 kBTypeScriptView Raw
1import type { RegisteredStyle, StyleProp } from 'react-native';
2import type { AnimatedStyle, SharedValue, TransformArrayItem } from './commonTypes';
3import type { BaseAnimationBuilder } from './layoutReanimation/animationBuilder/BaseAnimationBuilder';
4import type { EntryExitAnimationFunction, LayoutAnimationFunction } from './layoutReanimation/animationBuilder/commonTypes';
5import type { ReanimatedKeyframe } from './layoutReanimation/animationBuilder/Keyframe';
6import type { SharedTransition } from './layoutReanimation/sharedTransitions';
7type EntryOrExitLayoutType = BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | ReanimatedKeyframe;
8type PickStyleProps<Props> = Pick<Props, {
9 [Key in keyof Props]-?: Key extends `${string}Style` | 'style' ? Key : never;
10}[keyof Props]>;
11type AnimatedStyleProps<Props extends object> = {
12 [Key in keyof PickStyleProps<Props>]: StyleProp<AnimatedStyle<Props[Key]>>;
13};
14/** Component props that are not specially handled by us. */
15type RestProps<Props extends object> = {
16 [K in keyof Omit<Props, keyof PickStyleProps<Props> | 'style'>]: Props[K] | SharedValue<Props[K]>;
17};
18type LayoutProps = {
19 /**
20 * Lets you animate the layout changes when components are added to or removed
21 * from the view hierarchy.
22 *
23 * You can use the predefined layout transitions (eg. `LinearTransition`,
24 * `FadingTransition`) or create your own ones.
25 *
26 * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/layout-transitions
27 */
28 layout?: BaseAnimationBuilder | LayoutAnimationFunction | typeof BaseAnimationBuilder;
29 /**
30 * Lets you animate an element when it's added to or removed from the view
31 * hierarchy.
32 *
33 * You can use the predefined entering animations (eg. `FadeIn`,
34 * `SlideInLeft`) or create your own ones.
35 *
36 * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/entering-exiting-animations
37 */
38 entering?: EntryOrExitLayoutType;
39 /**
40 * Lets you animate an element when it's added to or removed from the view
41 * hierarchy.
42 *
43 * You can use the predefined entering animations (eg. `FadeOut`,
44 * `SlideOutRight`) or create your own ones.
45 *
46 * @see https://docs.swmansion.com/react-native-reanimated/docs/layout-animations/entering-exiting-animations
47 */
48 exiting?: EntryOrExitLayoutType;
49};
50type SharedTransitionProps = {
51 /**
52 * Lets you animate components between two navigation screens.
53 *
54 * Assign the same `sharedTransitionTag` to [animated
55 * components](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/glossary#animated-component)
56 * on two different navigation screens to create a shared transition.
57 *
58 * @experimental
59 * @see https://docs.swmansion.com/react-native-reanimated/docs/shared-element-transitions/overview
60 */
61 sharedTransitionTag?: string;
62 /**
63 * Lets you create a custom shared transition animation.
64 *
65 * Used alongside `SharedTransition.custom()` method.
66 *
67 * @experimental
68 * @see https://docs.swmansion.com/react-native-reanimated/docs/shared-element-transitions/overview
69 */
70 sharedTransitionStyle?: SharedTransition;
71};
72type AnimatedPropsProp<Props extends object> = RestProps<Props> & AnimatedStyleProps<Props> & LayoutProps & SharedTransitionProps;
73export type AnimatedProps<Props extends object> = RestProps<Props> & AnimatedStyleProps<Props> & LayoutProps & SharedTransitionProps & {
74 /**
75 * Lets you animate component props.
76 *
77 * @see https://docs.swmansion.com/react-native-reanimated/docs/core/useAnimatedProps
78 */
79 animatedProps?: Partial<AnimatedPropsProp<Props>>;
80};
81/** @deprecated This type is no longer relevant. */
82export type Adaptable<T> = T | ReadonlyArray<T | ReadonlyArray<T>> | SharedValue<T>;
83/** @deprecated This type is no longer relevant. */
84export type AdaptTransforms<T> = {
85 [P in keyof T]: Adaptable<T[P]>;
86};
87/** @deprecated Please use {@link TransformArrayItem} type instead. */
88export type TransformStyleTypes = TransformArrayItem;
89/** @deprecated This type is no longer relevant. */
90export type AnimatedStyleProp<T> = AnimatedStyle<T> | RegisteredStyle<AnimatedStyle<T>>;
91/** @deprecated Please use {@link AnimatedProps} type instead. */
92export type AnimateProps<Props extends object> = AnimatedProps<Props>;
93export {};
94//# sourceMappingURL=helperTypes.d.ts.map
\No newline at end of file