-
Notifications
You must be signed in to change notification settings - Fork 734
/
Copy pathmodifiers.d.ts
110 lines (110 loc) · 5.87 KB
/
modifiers.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import _ from 'lodash';
import { BorderRadiusesLiterals } from '../style/borderRadiuses';
import TypographyPresets from '../style/typographyPresets';
import { colorsPalette } from '../style/colorsPalette';
export declare const FLEX_KEY_PATTERN: RegExp;
export declare const PADDING_KEY_PATTERN: RegExp;
export declare const MARGIN_KEY_PATTERN: RegExp;
export declare const ALIGNMENT_KEY_PATTERN: RegExp;
export declare const POSITION_KEY_PATTERN: RegExp;
export interface AlteredOptions {
flex?: boolean;
alignments?: boolean;
paddings?: boolean;
margins?: boolean;
backgroundColor?: boolean;
position?: boolean;
}
export interface ExtractedStyle {
color?: ReturnType<typeof extractColorValue>;
typography?: ReturnType<typeof extractTypographyValue>;
backgroundColor?: ReturnType<typeof extractBackgroundColorValue>;
borderRadius?: ReturnType<typeof extractBorderRadiusValue>;
paddings?: ReturnType<typeof extractPaddingValues>;
margins?: ReturnType<typeof extractMarginValues>;
alignments?: ReturnType<typeof extractAlignmentsValues>;
flexStyle?: ReturnType<typeof extractFlexStyle>;
positionStyle?: ReturnType<typeof extractPositionStyle>;
}
declare const PADDING_VARIATIONS: {
readonly padding: "padding";
readonly paddingL: "paddingLeft";
readonly paddingT: "paddingTop";
readonly paddingR: "paddingRight";
readonly paddingB: "paddingBottom";
readonly paddingH: "paddingHorizontal";
readonly paddingV: "paddingVertical";
};
declare const MARGIN_VARIATIONS: {
readonly margin: "margin";
readonly marginL: "marginLeft";
readonly marginT: "marginTop";
readonly marginR: "marginRight";
readonly marginB: "marginBottom";
readonly marginH: "marginHorizontal";
readonly marginV: "marginVertical";
};
declare const STYLE_KEY_CONVERTERS: {
readonly flex: "flex";
readonly flexG: "flexGrow";
readonly flexS: "flexShrink";
};
export declare type PaddingLiterals = keyof typeof PADDING_VARIATIONS;
export declare type NativePaddingKeyType = typeof PADDING_VARIATIONS[PaddingLiterals];
export declare type MarginLiterals = keyof typeof MARGIN_VARIATIONS;
export declare type NativeMarginModifierKeyType = typeof MARGIN_VARIATIONS[MarginLiterals];
export declare type FlexLiterals = keyof typeof STYLE_KEY_CONVERTERS;
export declare type NativeFlexModifierKeyType = typeof STYLE_KEY_CONVERTERS[FlexLiterals];
export declare type ColorLiterals = keyof typeof colorsPalette;
export declare type TypographyLiterals = keyof typeof TypographyPresets;
export declare type BorderRadiusLiterals = keyof typeof BorderRadiusesLiterals;
export declare type AlignmentLiterals = 'row' | 'spread' | 'center' | 'centerH' | 'centerV' | 'left' | 'right' | 'top' | 'bottom';
export declare type PositionLiterals = 'absF' | 'absL' | 'absR' | 'absT' | 'absB' | 'absV' | 'absH';
export declare type Modifier<T extends string> = Partial<Record<T, boolean>>;
export declare type CustomModifier = {
[key: string]: boolean;
};
export declare type TypographyModifiers = Modifier<TypographyLiterals> | CustomModifier;
export declare type ColorsModifiers = Modifier<ColorLiterals> | CustomModifier;
export declare type BackgroundColorModifier = Modifier<'bg'>;
export declare type AlignmentModifiers = Modifier<AlignmentLiterals>;
export declare type PositionModifiers = Modifier<PositionLiterals>;
export declare type PaddingModifiers = Modifier<PaddingLiterals>;
export declare type MarginModifiers = Modifier<MarginLiterals>;
export declare type FlexModifiers = Modifier<FlexLiterals>;
export declare type BorderRadiusModifiers = Modifier<BorderRadiusLiterals>;
export declare type ContainerModifiers = AlignmentModifiers & PositionModifiers & PaddingModifiers & MarginModifiers & FlexModifiers & BorderRadiusModifiers & BackgroundColorModifier;
export declare function extractColorValue(props: Dictionary<any>): any;
export declare function extractBackgroundColorValue(props: Dictionary<any>): any;
export declare function extractTypographyValue(props: Dictionary<any>): object | undefined;
export declare function extractPaddingValues(props: Dictionary<any>): Partial<Record<NativePaddingKeyType, number>>;
export declare function extractMarginValues(props: Dictionary<any>): Partial<Record<NativeMarginModifierKeyType, number>>;
export declare function extractAlignmentsValues(props: Dictionary<any>): any;
export declare function extractPositionStyle(props: Dictionary<any>): {
position: "absolute";
} | undefined;
export declare function extractFlexStyle(props: Dictionary<any>): Partial<Record<NativeFlexModifierKeyType, number>> | undefined;
export declare function extractAccessibilityProps(props?: any): Partial<any>;
export declare function extractAnimationProps(props?: any): Pick<any, "direction" | "onAnimationEnd" | "animation" | "duration" | "delay" | "easing" | "iterationCount" | "transition" | "onAnimationBegin" | "useNativeDriver">;
export declare function extractBorderRadiusValue(props: Dictionary<any>): number | undefined;
export declare function extractModifierProps(props: Dictionary<any>): _.Dictionary<any>;
/**
* TODO:
* @deprecated switch to Modifiers#extractComponentProps
*/
export declare function extractOwnProps(props: Dictionary<any>, ignoreProps: string[]): _.Omit<Partial<Dictionary<any>>, string>;
export declare function extractComponentProps(component: any, props: Dictionary<any>, ignoreProps?: string[]): _.Omit<Partial<Dictionary<any>>, string>;
export declare function getThemeProps(props?: any, context?: any): any;
export declare function generateModifiersStyle(options: {
color: boolean;
typography: boolean;
backgroundColor: boolean;
borderRadius: boolean;
paddings: boolean;
margins: boolean;
alignments: boolean;
flex: boolean;
position: boolean;
} | undefined, props: Dictionary<any>): ExtractedStyle;
export declare function getAlteredModifiersOptions(currentProps: any, nextProps: any): AlteredOptions;
export {};