Repository navigation
Expand file tree
/
Copy pathcss.d.ts
More file actions
152 lines (141 loc) · 4.01 KB
/
Copy pathcss.d.ts
File metadata and controls
152 lines (141 loc) · 4.01 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import type {CSSProperties} from 'react'
import type {ViewStyle, TextStyle, ImageStyle} from 'react-native'
export type DimensionValue = number | 'auto' | `${number}%`
export type Color = undefined | string
type _StylesDesktopOverride = {
backgroundImage?: string
objectFit?: 'contain' | 'cover' | 'fill' | 'none' | 'scale-down'
overflowX?: 'auto' | 'clip' | 'hidden' | 'scroll' | 'visible'
overflowY?: 'auto' | 'clip' | 'hidden' | 'scroll' | 'visible'
wordBreak?: 'normal' | 'break-all' | 'keep-all' | 'inherit' | 'initial' | 'unset' | 'break-word'
WebkitAppRegion?: 'drag' | 'no-drag'
WebkitBackgroundClip?: 'text'
}
// only use a subset of the full CSSProperties for speed reasons
type StyleKeys =
| 'alignContent'
| 'alignItems'
| 'alignSelf'
| 'backgroundColor'
| 'backgroundPosition'
| 'backgroundRepeat'
| 'backgroundSize'
| 'border'
| 'borderBottom'
| 'borderBottomColor'
| 'borderBottomLeftRadius'
| 'borderBottomRightRadius'
| 'borderBottomWidth'
| 'borderColor'
| 'borderLeft'
| 'borderLeftColor'
| 'borderLeftWidth'
| 'borderRadius'
| 'borderRight'
| 'borderRightColor'
| 'borderRightWidth'
| 'borderStyle'
| 'borderTop'
| 'borderTopColor'
| 'borderTopLeftRadius'
| 'borderTopRightRadius'
| 'borderTopWidth'
| 'borderWidth'
| 'bottom'
| 'boxShadow'
| 'color'
| 'columnGap'
| 'contain'
| 'cursor'
| 'direction'
| 'display'
| 'flex'
| 'flexBasis'
| 'flexDirection'
| 'flexGrow'
| 'flexShrink'
| 'flexWrap'
| 'fontFamily'
| 'fontSize'
| 'fontStyle'
| 'fontVariant'
| 'fontWeight'
| 'height'
| 'justifyContent'
| 'left'
| 'letterSpacing'
| 'lineHeight'
| 'margin'
| 'marginBottom'
| 'marginLeft'
| 'marginRight'
| 'marginTop'
| 'maxHeight'
| 'maxWidth'
| 'minHeight'
| 'minWidth'
| 'opacity'
| 'outline'
| 'overflow'
| 'overflowWrap'
| 'overflowX'
| 'overflowY'
| 'padding'
| 'paddingBottom'
| 'paddingLeft'
| 'paddingRight'
| 'paddingTop'
| 'pointerEvents'
| 'position'
| 'resize'
| 'right'
| 'rowGap'
| 'textAlign'
| 'textDecoration'
| 'textDecorationColor'
| 'textDecorationLine'
| 'textDecorationStyle'
| 'textTransform'
| 'textOverflow'
| 'top'
| 'transform'
| 'transition'
| 'visibility'
| 'whiteSpace'
| 'width'
| 'willChange'
| 'wordBreak'
| 'wordWrap'
| 'zIndex'
export type _StylesDesktop = _StylesDesktopOverride &
Pick<CSSProperties, Exclude<StyleKeys, keyof _StylesDesktopOverride>>
type _StylesDesktopFalsy = _StylesDesktop | undefined | null | false
export type StylesDesktop = _StylesDesktopFalsy | ReadonlyArray<_StylesDesktopFalsy>
type _StylesMobileOverride = {
textAlignVertical?: 'top' | 'bottom' | 'center'
textAlign?: 'left' | 'right' | 'center' | 'justify'
}
export type _StylesMobile = ViewStyle &
Omit<TextStyle, 'textAlignVertical' | 'textAlign'> &
ImageStyle &
_StylesMobileOverride
type _StylesMobileFalsy = _StylesMobile | undefined | null | false
export type StylesMobile = _StylesMobileFalsy | ReadonlyArray<_StylesMobileFalsy>
// override some problematic styles
type _StylesCrossPlatformOverride = {
fontSize: _StylesMobile['fontSize']
fontWeight: _StylesMobile['fontWeight']
textAlign: _StylesMobile['textAlign']
}
export type _StylesCrossPlatform = {
[k in keyof _StylesDesktop]: k extends keyof _StylesCrossPlatformOverride // use override
? _StylesCrossPlatformOverride[k] // or if its shared between desktop and mobile choose one which extends the other
: k extends keyof _StylesMobile
? _StylesMobile[k] & _StylesDesktop[k]
: never
}
type _StylesCrossPlatformFalsy = _StylesCrossPlatform | undefined | null | false
export type StylesCrossPlatform = _StylesCrossPlatformFalsy | Array<_StylesCrossPlatformFalsy>
export type _CustomStyles<K extends string, C> = Omit<_StylesCrossPlatform, K> & C
export type _CustomStylesFalsy<K extends string, C> = _CustomStyles<K, C> | undefined | null | false
export type CustomStyles<K extends string, C> = _CustomStylesFalsy<K, C> | Array<_CustomStylesFalsy<K, C>>