UNPKG

3.7 kBTypeScriptView Raw
1import type { Ref, Component } from 'react';
2import type { ShadowNodeWrapper, SharedValue, StyleProps } from '../commonTypes';
3import type { ViewConfig } from '../ConfigHelper';
4import type { ViewDescriptorsSet } from '../ViewDescriptorsSet';
5import type { BaseAnimationBuilder, EntryExitAnimationFunction, ILayoutAnimationBuilder, SharedTransition } from '../layoutReanimation';
6import type { SkipEnteringContext } from '../component/LayoutAnimationConfig';
7export interface AnimatedProps extends Record<string, unknown> {
8 viewDescriptors?: ViewDescriptorsSet;
9 initial?: SharedValue<StyleProps>;
10}
11export interface ViewInfo {
12 viewTag: number | HTMLElement | null;
13 viewName: string | null;
14 shadowNodeWrapper: ShadowNodeWrapper | null;
15 viewConfig: ViewConfig;
16}
17export interface IInlinePropManager {
18 attachInlineProps(animatedComponent: React.Component<unknown, unknown>, viewInfo: ViewInfo): void;
19 detachInlineProps(): void;
20}
21export interface IPropsFilter {
22 filterNonAnimatedProps: (component: React.Component<unknown, unknown> & IAnimatedComponentInternal) => Record<string, unknown>;
23}
24export interface IJSPropsUpdater {
25 addOnJSPropsChangeListener(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal): void;
26 removeOnJSPropsChangeListener(animatedComponent: React.Component<unknown, unknown> & IAnimatedComponentInternal): void;
27}
28export interface INativeEventsManager {
29 attachEvents(): void;
30 detachEvents(): void;
31 updateEvents(prevProps: AnimatedComponentProps<InitialComponentProps>): void;
32}
33export type LayoutAnimationStaticContext = {
34 presetName: string;
35};
36export type AnimatedComponentProps<P extends Record<string, unknown>> = P & {
37 forwardedRef?: Ref<Component>;
38 style?: NestedArray<StyleProps>;
39 animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
40 animatedStyle?: StyleProps;
41 layout?: (BaseAnimationBuilder | ILayoutAnimationBuilder | typeof BaseAnimationBuilder) & LayoutAnimationStaticContext;
42 entering?: (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe) & LayoutAnimationStaticContext;
43 exiting?: (BaseAnimationBuilder | typeof BaseAnimationBuilder | EntryExitAnimationFunction | Keyframe) & LayoutAnimationStaticContext;
44 sharedTransitionTag?: string;
45 sharedTransitionStyle?: SharedTransition;
46};
47export interface AnimatedComponentRef extends Component {
48 setNativeProps?: (props: Record<string, unknown>) => void;
49 getScrollableNode?: () => AnimatedComponentRef;
50 getAnimatableRef?: () => AnimatedComponentRef;
51}
52export interface IAnimatedComponentInternal {
53 _styles: StyleProps[] | null;
54 _animatedProps?: Partial<AnimatedComponentProps<AnimatedProps>>;
55 /**
56 * Used for Shared Element Transitions, Layout Animations and Animated Styles.
57 * It is not related to event handling.
58 */
59 _componentViewTag: number;
60 _isFirstRender: boolean;
61 jestInlineStyle: NestedArray<StyleProps> | undefined;
62 jestAnimatedStyle: {
63 value: StyleProps;
64 };
65 _component: AnimatedComponentRef | HTMLElement | null;
66 _sharedElementTransition: SharedTransition | null;
67 _jsPropsUpdater: IJSPropsUpdater;
68 _InlinePropManager: IInlinePropManager;
69 _PropsFilter: IPropsFilter;
70 /** Doesn't exist on web. */
71 _NativeEventsManager?: INativeEventsManager;
72 _viewInfo?: ViewInfo;
73 context: React.ContextType<typeof SkipEnteringContext>;
74}
75export type NestedArray<T> = T | NestedArray<T>[];
76export interface InitialComponentProps extends Record<string, unknown> {
77 ref?: Ref<Component>;
78 collapsable?: boolean;
79}
80//# sourceMappingURL=commonTypes.d.ts.map
\No newline at end of file