Skip to content

Commit 0297d29

Browse files
authored
chore: Move some CSS props to the common dir (#8392)
## Summary This PR moves some types (`PlainStyle`, `AnyRecord`, `AnyComponent`) to the types in the `common` directory. They will be useful after moving style processors to the `common` dir from CSS-specific dirs.
1 parent 72e76c7 commit 0297d29

File tree

32 files changed

+66
-73
lines changed

32 files changed

+66
-73
lines changed

packages/react-native-reanimated/src/common/types.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
'use strict';
2+
3+
import type { ComponentType } from 'react';
4+
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
5+
26
export type Maybe<T> = T | null | undefined;
37

48
/**
@@ -8,6 +12,9 @@ export type Maybe<T> = T | null | undefined;
812
*/
913
export type NonMutable<T> = T extends object ? Readonly<T> : T;
1014

15+
/* eslint-disable @typescript-eslint/no-explicit-any */
16+
export type AnyRecord = Record<string, any>;
17+
1118
export type ValueProcessor<V, R = V> = (
1219
value: NonMutable<V>
1320
) => Maybe<R> | Record<string, R>;
@@ -19,3 +26,18 @@ export type NormalizedTransformOrigin = [
1926
`${number}%` | number,
2027
number,
2128
];
29+
30+
type DeprecatedProps =
31+
| 'transformMatrix'
32+
| 'rotation'
33+
| 'scaleX'
34+
| 'scaleY'
35+
| 'translateX'
36+
| 'translateY';
37+
38+
export type PlainStyle = Omit<
39+
ViewStyle & TextStyle & ImageStyle,
40+
DeprecatedProps
41+
>;
42+
43+
export type AnyComponent = ComponentType<any>;

packages/react-native-reanimated/src/commonTypes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ import type {
1212
} from 'react-native';
1313
import type { SerializableRef, WorkletFunction } from 'react-native-worklets';
1414

15-
import type { Maybe } from './common/types';
15+
import type { AnyRecord, Maybe } from './common';
1616
import type { CSSAnimationProperties, CSSTransitionProperties } from './css';
17-
import type { AnyRecord } from './css/types';
1817
import type { EasingFunctionFactory } from './Easing';
1918

2019
type LayoutAnimationOptions =

packages/react-native-reanimated/src/createAnimatedComponent/createAnimatedComponent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { ComponentRef, ComponentType, ReactNode, Ref } from 'react';
33
import type React from 'react';
44
import type { FlatList, FlatListProps } from 'react-native';
55

6+
import type { AnyRecord } from '../common';
67
import type { InstanceOrElement } from '../commonTypes';
7-
import type { AnyRecord } from '../css/types';
88
import type { AnimatedProps } from '../helperTypes';
99
import type { AnimatedRef } from '../hook';
1010
import type { ExtractElementRef } from '../hook/commonTypes';

packages/react-native-reanimated/src/css/component/AnimatedComponent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Component } from 'react';
44
import type { StyleProp } from 'react-native';
55
import { Platform, StyleSheet } from 'react-native';
66

7+
import type { AnyComponent, AnyRecord, PlainStyle } from '../../common';
78
import { IS_JEST, ReanimatedError, SHOULD_BE_USE_WEB } from '../../common';
89
import type {
910
InternalHostInstance,
@@ -19,7 +20,7 @@ import { getShadowNodeWrapperFromRef } from '../../fabricUtils';
1920
import { findHostInstance } from '../../platform-specific/findHostInstance';
2021
import { markNodeAsRemovable, unmarkNodeAsRemovable } from '../native';
2122
import { CSSManager } from '../platform';
22-
import type { AnyComponent, AnyRecord, CSSStyle, PlainStyle } from '../types';
23+
import type { CSSStyle } from '../types';
2324
import { filterNonCSSStyleProps } from './utils';
2425

2526
export type AnimatedComponentProps = Record<string, unknown> & {

packages/react-native-reanimated/src/css/component/createAnimatedComponent.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import type { ComponentRef, ComponentType, ReactNode, Ref } from 'react';
33
import type React from 'react';
44
import type { FlatList, FlatListProps } from 'react-native';
55

6+
import type { AnyRecord } from '../../common';
67
import type { InitialComponentProps } from '../../createAnimatedComponent/commonTypes';
78
import type { AnimatedProps } from '../../helperTypes';
89
import type { AnimatedRef } from '../../hook';
9-
import type { AnyRecord, CSSProps } from '../types';
10+
import type { CSSProps } from '../types';
1011
import type { AnimatedComponentProps } from './AnimatedComponent';
1112
import AnimatedComponentImpl from './AnimatedComponent';
1213

packages/react-native-reanimated/src/css/component/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
'use strict';
22
import type { StyleProp } from 'react-native';
33

4-
import type { AnyRecord, CSSStyle } from '../types';
4+
import type { AnyRecord } from '../../common';
5+
import type { CSSStyle } from '../types';
56
import { isCSSStyleProp } from '../utils/guards';
67

78
function filterNonCSSStylePropsRecursive(

packages/react-native-reanimated/src/css/models/CSSKeyframesRuleBase.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
'use strict';
2+
import type { PlainStyle } from '../../common';
23
import { ANIMATION_NAME_PREFIX } from '../constants';
3-
import type {
4-
CSSAnimationKeyframes,
5-
CSSKeyframesRule,
6-
PlainStyle,
7-
} from '../types';
4+
import type { CSSAnimationKeyframes, CSSKeyframesRule } from '../types';
85

96
export default abstract class CSSKeyframesRuleBase<S extends PlainStyle>
107
implements CSSKeyframesRule

packages/react-native-reanimated/src/css/native/keyframes/CSSKeyframesRuleImpl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
2+
import type { PlainStyle } from '../../../common';
23
import { CSSKeyframesRuleBase } from '../../models';
3-
import type { CSSAnimationKeyframes, PlainStyle } from '../../types';
4+
import type { CSSAnimationKeyframes } from '../../types';
45
import { normalizeAnimationKeyframes } from '../normalization';
56
import { getStyleBuilder } from '../registry';
67
import type { NormalizedCSSAnimationKeyframesConfig } from '../types';

packages/react-native-reanimated/src/css/native/managers/CSSManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use strict';
2+
import type { AnyRecord } from '../../../common';
23
import { ReanimatedError } from '../../../common';
34
import type { ShadowNodeWrapper } from '../../../commonTypes';
45
import type { ViewInfo } from '../../../createAnimatedComponent/commonTypes';
5-
import type { AnyRecord, CSSStyle } from '../../types';
6+
import type { CSSStyle } from '../../types';
67
import type { ICSSManager } from '../../types/interfaces';
78
import { filterCSSAndStyleProperties } from '../../utils';
89
import { setViewStyle } from '../proxy';

packages/react-native-reanimated/src/css/native/normalization/animation/keyframes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
'use strict';
2+
import type { AnyRecord } from '../../../../common';
23
import { ReanimatedError } from '../../../../common';
34
import type { StyleProps } from '../../../../commonTypes';
45
import { PERCENTAGE_REGEX } from '../../../constants';
56
import type {
6-
AnyRecord,
77
CSSAnimationKeyframes,
88
CSSAnimationKeyframeSelector,
99
CSSAnimationTimingFunction,

0 commit comments

Comments
 (0)