@tarojs/rn-style-transformer 4.0.0-beta.77 → 4.0.0-beta.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +8 -0
- package/LICENSE +8 -1
- package/__tests__/config.spec.js +203 -0
- package/__tests__/index.spec.js +252 -0
- package/__tests__/platform.spec.js +78 -0
- package/__tests__/styles/b.css +3 -0
- package/__tests__/styles/b.less +3 -0
- package/__tests__/styles/b.rn.css +3 -0
- package/__tests__/styles/b.scss +3 -0
- package/__tests__/styles/b.styl +3 -0
- package/__tests__/styles/c.css +3 -0
- package/__tests__/styles/c.less +5 -0
- package/__tests__/styles/c.rn.scss +5 -0
- package/__tests__/styles/c.scss +5 -0
- package/__tests__/styles/d.rn.scss +3 -0
- package/__tests__/styles/d.scss +3 -0
- package/__tests__/styles/mixins.scss +18 -0
- package/__tests__/styles/nest.rn.less +3 -0
- package/__tests__/styles/variable.scss +1 -0
- package/babel.config.js +12 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/transforms/StyleSheet/ColorPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/ImageStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js +1 -1
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.js.map +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js +1 -1
- package/dist/transforms/StyleSheet/StyleSheetValidation.js.map +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/TextStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/TransformPropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js +1 -1
- package/dist/transforms/StyleSheet/ViewStylePropTypes.js.map +1 -1
- package/dist/transforms/StyleSheet/deprecatedPropType.js.map +1 -1
- package/dist/transforms/StyleSheet/normalizeColor.js.map +1 -1
- package/dist/transforms/index.js +5 -5
- package/dist/transforms/index.js.map +1 -1
- package/dist/transforms/less.js.map +1 -1
- package/dist/transforms/postcss.js +1 -5
- package/dist/transforms/postcss.js.map +1 -1
- package/dist/transforms/sass.js.map +1 -1
- package/dist/transforms/stylus.js +1 -1
- package/dist/transforms/stylus.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/reporterSkip.js.map +1 -1
- package/jest.config.js +8 -0
- package/package.json +31 -32
- package/src/config/rn-stylelint.json +5 -0
- package/src/index.ts +52 -0
- package/src/transforms/StyleSheet/ColorPropType.ts +76 -0
- package/src/transforms/StyleSheet/ImageResizeMode.ts +50 -0
- package/src/transforms/StyleSheet/ImageStylePropTypes.ts +62 -0
- package/src/transforms/StyleSheet/LayoutPropTypes.ts +559 -0
- package/src/transforms/StyleSheet/ShadowPropTypesIOS.ts +48 -0
- package/src/transforms/StyleSheet/StyleSheetValidation.ts +81 -0
- package/src/transforms/StyleSheet/TextStylePropTypes.ts +123 -0
- package/src/transforms/StyleSheet/TransformPropTypes.ts +109 -0
- package/src/transforms/StyleSheet/ViewStylePropTypes.ts +61 -0
- package/src/transforms/StyleSheet/deprecatedPropType.ts +31 -0
- package/src/transforms/StyleSheet/index.ts +5 -0
- package/src/transforms/StyleSheet/normalizeColor.ts +369 -0
- package/src/transforms/index.ts +229 -0
- package/src/transforms/less.ts +50 -0
- package/src/transforms/postcss.ts +95 -0
- package/src/transforms/sass.ts +148 -0
- package/src/transforms/stylus.ts +124 -0
- package/src/types/index.ts +242 -0
- package/src/utils/index.ts +229 -0
- package/src/utils/lessImport.ts +50 -0
- package/src/utils/reporterSkip.ts +27 -0
- package/tsconfig.json +12 -0
- package/dist/index.d.ts +0 -8
- package/dist/transforms/StyleSheet/ColorPropType.d.ts +0 -10
- package/dist/transforms/StyleSheet/ImageResizeMode.d.ts +0 -6
- package/dist/transforms/StyleSheet/ImageStylePropTypes.d.ts +0 -128
- package/dist/transforms/StyleSheet/LayoutPropTypes.d.ts +0 -388
- package/dist/transforms/StyleSheet/ShadowPropTypesIOS.d.ts +0 -45
- package/dist/transforms/StyleSheet/StyleSheetValidation.d.ts +0 -15
- package/dist/transforms/StyleSheet/TextStylePropTypes.d.ts +0 -191
- package/dist/transforms/StyleSheet/TransformPropTypes.d.ts +0 -67
- package/dist/transforms/StyleSheet/ViewStylePropTypes.d.ts +0 -136
- package/dist/transforms/StyleSheet/deprecatedPropType.d.ts +0 -13
- package/dist/transforms/StyleSheet/index.d.ts +0 -2
- package/dist/transforms/StyleSheet/normalizeColor.d.ts +0 -10
- package/dist/transforms/index.d.ts +0 -56
- package/dist/transforms/less.d.ts +0 -2
- package/dist/transforms/postcss.d.ts +0 -13
- package/dist/transforms/sass.d.ts +0 -2
- package/dist/transforms/stylus.d.ts +0 -3
- package/dist/types/index.d.ts +0 -206
- package/dist/utils/index.d.ts +0 -21
- package/dist/utils/lessImport.d.ts +0 -5
- package/dist/utils/reporterSkip.d.ts +0 -7
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* strict
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as ReactPropTypes from 'prop-types'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* React Native's layout system is based on Flexbox and is powered both
|
|
15
|
+
* on iOS and Android by an open source project called `Yoga`:
|
|
16
|
+
* https://github.com/facebook/yoga
|
|
17
|
+
*
|
|
18
|
+
* The implementation in Yoga is slightly different from what the
|
|
19
|
+
* Flexbox spec defines - for example, we chose more sensible default
|
|
20
|
+
* values. Since our layout docs are generated from the comments in this
|
|
21
|
+
* file, please keep a brief comment describing each prop type.
|
|
22
|
+
*
|
|
23
|
+
* These properties are a subset of our styles that are consumed by the layout
|
|
24
|
+
* algorithm and affect the positioning and sizing of views.
|
|
25
|
+
*/
|
|
26
|
+
const LayoutPropTypes = {
|
|
27
|
+
/** `display` sets the display type of this component.
|
|
28
|
+
*
|
|
29
|
+
* It works similarly to `display` in CSS, but only support 'flex' and 'none'.
|
|
30
|
+
* 'flex' is the default.
|
|
31
|
+
*/
|
|
32
|
+
display: ReactPropTypes.oneOf(['none', 'flex']),
|
|
33
|
+
|
|
34
|
+
/** `width` sets the width of this component.
|
|
35
|
+
*
|
|
36
|
+
* It works similarly to `width` in CSS, but in React Native you
|
|
37
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
38
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/width for more details.
|
|
39
|
+
*/
|
|
40
|
+
width: ReactPropTypes.oneOfType([
|
|
41
|
+
ReactPropTypes.number,
|
|
42
|
+
ReactPropTypes.string
|
|
43
|
+
]),
|
|
44
|
+
|
|
45
|
+
/** `height` sets the height of this component.
|
|
46
|
+
*
|
|
47
|
+
* It works similarly to `height` in CSS, but in React Native you
|
|
48
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
49
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/height for more details.
|
|
50
|
+
*/
|
|
51
|
+
height: ReactPropTypes.oneOfType([
|
|
52
|
+
ReactPropTypes.number,
|
|
53
|
+
ReactPropTypes.string
|
|
54
|
+
]),
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* When the direction is `ltr`, `start` is equivalent to `left`.
|
|
58
|
+
* When the direction is `rtl`, `start` is equivalent to `right`.
|
|
59
|
+
*
|
|
60
|
+
* This style takes precedence over the `left`, `right`, and `end` styles.
|
|
61
|
+
*/
|
|
62
|
+
start: ReactPropTypes.oneOfType([
|
|
63
|
+
ReactPropTypes.number,
|
|
64
|
+
ReactPropTypes.string
|
|
65
|
+
]),
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* When the direction is `ltr`, `end` is equivalent to `right`.
|
|
69
|
+
* When the direction is `rtl`, `end` is equivalent to `left`.
|
|
70
|
+
*
|
|
71
|
+
* This style takes precedence over the `left` and `right` styles.
|
|
72
|
+
*/
|
|
73
|
+
end: ReactPropTypes.oneOfType([ReactPropTypes.number, ReactPropTypes.string]),
|
|
74
|
+
|
|
75
|
+
/** `top` is the number of logical pixels to offset the top edge of
|
|
76
|
+
* this component.
|
|
77
|
+
*
|
|
78
|
+
* It works similarly to `top` in CSS, but in React Native you
|
|
79
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
80
|
+
*
|
|
81
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/top
|
|
82
|
+
* for more details of how `top` affects layout.
|
|
83
|
+
*/
|
|
84
|
+
top: ReactPropTypes.oneOfType([ReactPropTypes.number, ReactPropTypes.string]),
|
|
85
|
+
|
|
86
|
+
/** `left` is the number of logical pixels to offset the left edge of
|
|
87
|
+
* this component.
|
|
88
|
+
*
|
|
89
|
+
* It works similarly to `left` in CSS, but in React Native you
|
|
90
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
91
|
+
*
|
|
92
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/left
|
|
93
|
+
* for more details of how `left` affects layout.
|
|
94
|
+
*/
|
|
95
|
+
left: ReactPropTypes.oneOfType([
|
|
96
|
+
ReactPropTypes.number,
|
|
97
|
+
ReactPropTypes.string
|
|
98
|
+
]),
|
|
99
|
+
|
|
100
|
+
/** `right` is the number of logical pixels to offset the right edge of
|
|
101
|
+
* this component.
|
|
102
|
+
*
|
|
103
|
+
* It works similarly to `right` in CSS, but in React Native you
|
|
104
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
105
|
+
*
|
|
106
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/right
|
|
107
|
+
* for more details of how `right` affects layout.
|
|
108
|
+
*/
|
|
109
|
+
right: ReactPropTypes.oneOfType([
|
|
110
|
+
ReactPropTypes.number,
|
|
111
|
+
ReactPropTypes.string
|
|
112
|
+
]),
|
|
113
|
+
|
|
114
|
+
/** `bottom` is the number of logical pixels to offset the bottom edge of
|
|
115
|
+
* this component.
|
|
116
|
+
*
|
|
117
|
+
* It works similarly to `bottom` in CSS, but in React Native you
|
|
118
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
119
|
+
*
|
|
120
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/bottom
|
|
121
|
+
* for more details of how `bottom` affects layout.
|
|
122
|
+
*/
|
|
123
|
+
bottom: ReactPropTypes.oneOfType([
|
|
124
|
+
ReactPropTypes.number,
|
|
125
|
+
ReactPropTypes.string
|
|
126
|
+
]),
|
|
127
|
+
|
|
128
|
+
/** `minWidth` is the minimum width for this component, in logical pixels.
|
|
129
|
+
*
|
|
130
|
+
* It works similarly to `min-width` in CSS, but in React Native you
|
|
131
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
132
|
+
*
|
|
133
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/min-width
|
|
134
|
+
* for more details.
|
|
135
|
+
*/
|
|
136
|
+
minWidth: ReactPropTypes.oneOfType([
|
|
137
|
+
ReactPropTypes.number,
|
|
138
|
+
ReactPropTypes.string
|
|
139
|
+
]),
|
|
140
|
+
|
|
141
|
+
/** `maxWidth` is the maximum width for this component, in logical pixels.
|
|
142
|
+
*
|
|
143
|
+
* It works similarly to `max-width` in CSS, but in React Native you
|
|
144
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
145
|
+
*
|
|
146
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/max-width
|
|
147
|
+
* for more details.
|
|
148
|
+
*/
|
|
149
|
+
maxWidth: ReactPropTypes.oneOfType([
|
|
150
|
+
ReactPropTypes.number,
|
|
151
|
+
ReactPropTypes.string
|
|
152
|
+
]),
|
|
153
|
+
|
|
154
|
+
/** `minHeight` is the minimum height for this component, in logical pixels.
|
|
155
|
+
*
|
|
156
|
+
* It works similarly to `min-height` in CSS, but in React Native you
|
|
157
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
158
|
+
*
|
|
159
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/min-height
|
|
160
|
+
* for more details.
|
|
161
|
+
*/
|
|
162
|
+
minHeight: ReactPropTypes.oneOfType([
|
|
163
|
+
ReactPropTypes.number,
|
|
164
|
+
ReactPropTypes.string
|
|
165
|
+
]),
|
|
166
|
+
|
|
167
|
+
/** `maxHeight` is the maximum height for this component, in logical pixels.
|
|
168
|
+
*
|
|
169
|
+
* It works similarly to `max-height` in CSS, but in React Native you
|
|
170
|
+
* must use points or percentages. Ems and other units are not supported.
|
|
171
|
+
*
|
|
172
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/max-height
|
|
173
|
+
* for more details.
|
|
174
|
+
*/
|
|
175
|
+
maxHeight: ReactPropTypes.oneOfType([
|
|
176
|
+
ReactPropTypes.number,
|
|
177
|
+
ReactPropTypes.string
|
|
178
|
+
]),
|
|
179
|
+
|
|
180
|
+
/** Setting `margin` has the same effect as setting each of
|
|
181
|
+
* `marginTop`, `marginLeft`, `marginBottom`, and `marginRight`.
|
|
182
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin
|
|
183
|
+
* for more details.
|
|
184
|
+
*/
|
|
185
|
+
margin: ReactPropTypes.oneOfType([
|
|
186
|
+
ReactPropTypes.number,
|
|
187
|
+
ReactPropTypes.string
|
|
188
|
+
]),
|
|
189
|
+
|
|
190
|
+
/** Setting `marginVertical` has the same effect as setting both
|
|
191
|
+
* `marginTop` and `marginBottom`.
|
|
192
|
+
*/
|
|
193
|
+
marginVertical: ReactPropTypes.oneOfType([
|
|
194
|
+
ReactPropTypes.number,
|
|
195
|
+
ReactPropTypes.string
|
|
196
|
+
]),
|
|
197
|
+
|
|
198
|
+
/** Setting `marginHorizontal` has the same effect as setting
|
|
199
|
+
* both `marginLeft` and `marginRight`.
|
|
200
|
+
*/
|
|
201
|
+
marginHorizontal: ReactPropTypes.oneOfType([
|
|
202
|
+
ReactPropTypes.number,
|
|
203
|
+
ReactPropTypes.string
|
|
204
|
+
]),
|
|
205
|
+
|
|
206
|
+
/** `marginTop` works like `margin-top` in CSS.
|
|
207
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-top
|
|
208
|
+
* for more details.
|
|
209
|
+
*/
|
|
210
|
+
marginTop: ReactPropTypes.oneOfType([
|
|
211
|
+
ReactPropTypes.number,
|
|
212
|
+
ReactPropTypes.string
|
|
213
|
+
]),
|
|
214
|
+
|
|
215
|
+
/** `marginBottom` works like `margin-bottom` in CSS.
|
|
216
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-bottom
|
|
217
|
+
* for more details.
|
|
218
|
+
*/
|
|
219
|
+
marginBottom: ReactPropTypes.oneOfType([
|
|
220
|
+
ReactPropTypes.number,
|
|
221
|
+
ReactPropTypes.string
|
|
222
|
+
]),
|
|
223
|
+
|
|
224
|
+
/** `marginLeft` works like `margin-left` in CSS.
|
|
225
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-left
|
|
226
|
+
* for more details.
|
|
227
|
+
*/
|
|
228
|
+
marginLeft: ReactPropTypes.oneOfType([
|
|
229
|
+
ReactPropTypes.number,
|
|
230
|
+
ReactPropTypes.string
|
|
231
|
+
]),
|
|
232
|
+
|
|
233
|
+
/** `marginRight` works like `margin-right` in CSS.
|
|
234
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/margin-right
|
|
235
|
+
* for more details.
|
|
236
|
+
*/
|
|
237
|
+
marginRight: ReactPropTypes.oneOfType([
|
|
238
|
+
ReactPropTypes.number,
|
|
239
|
+
ReactPropTypes.string
|
|
240
|
+
]),
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* When direction is `ltr`, `marginStart` is equivalent to `marginLeft`.
|
|
244
|
+
* When direction is `rtl`, `marginStart` is equivalent to `marginRight`.
|
|
245
|
+
*/
|
|
246
|
+
marginStart: ReactPropTypes.oneOfType([
|
|
247
|
+
ReactPropTypes.number,
|
|
248
|
+
ReactPropTypes.string
|
|
249
|
+
]),
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* When direction is `ltr`, `marginEnd` is equivalent to `marginRight`.
|
|
253
|
+
* When direction is `rtl`, `marginEnd` is equivalent to `marginLeft`.
|
|
254
|
+
*/
|
|
255
|
+
marginEnd: ReactPropTypes.oneOfType([
|
|
256
|
+
ReactPropTypes.number,
|
|
257
|
+
ReactPropTypes.string
|
|
258
|
+
]),
|
|
259
|
+
|
|
260
|
+
/** Setting `padding` has the same effect as setting each of
|
|
261
|
+
* `paddingTop`, `paddingBottom`, `paddingLeft`, and `paddingRight`.
|
|
262
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding
|
|
263
|
+
* for more details.
|
|
264
|
+
*/
|
|
265
|
+
padding: ReactPropTypes.oneOfType([
|
|
266
|
+
ReactPropTypes.number,
|
|
267
|
+
ReactPropTypes.string
|
|
268
|
+
]),
|
|
269
|
+
|
|
270
|
+
/** Setting `paddingVertical` is like setting both of
|
|
271
|
+
* `paddingTop` and `paddingBottom`.
|
|
272
|
+
*/
|
|
273
|
+
paddingVertical: ReactPropTypes.oneOfType([
|
|
274
|
+
ReactPropTypes.number,
|
|
275
|
+
ReactPropTypes.string
|
|
276
|
+
]),
|
|
277
|
+
|
|
278
|
+
/** Setting `paddingHorizontal` is like setting both of
|
|
279
|
+
* `paddingLeft` and `paddingRight`.
|
|
280
|
+
*/
|
|
281
|
+
paddingHorizontal: ReactPropTypes.oneOfType([
|
|
282
|
+
ReactPropTypes.number,
|
|
283
|
+
ReactPropTypes.string
|
|
284
|
+
]),
|
|
285
|
+
|
|
286
|
+
/** `paddingTop` works like `padding-top` in CSS.
|
|
287
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-top
|
|
288
|
+
* for more details.
|
|
289
|
+
*/
|
|
290
|
+
paddingTop: ReactPropTypes.oneOfType([
|
|
291
|
+
ReactPropTypes.number,
|
|
292
|
+
ReactPropTypes.string
|
|
293
|
+
]),
|
|
294
|
+
|
|
295
|
+
/** `paddingBottom` works like `padding-bottom` in CSS.
|
|
296
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-bottom
|
|
297
|
+
* for more details.
|
|
298
|
+
*/
|
|
299
|
+
paddingBottom: ReactPropTypes.oneOfType([
|
|
300
|
+
ReactPropTypes.number,
|
|
301
|
+
ReactPropTypes.string
|
|
302
|
+
]),
|
|
303
|
+
|
|
304
|
+
/** `paddingLeft` works like `padding-left` in CSS.
|
|
305
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-left
|
|
306
|
+
* for more details.
|
|
307
|
+
*/
|
|
308
|
+
paddingLeft: ReactPropTypes.oneOfType([
|
|
309
|
+
ReactPropTypes.number,
|
|
310
|
+
ReactPropTypes.string
|
|
311
|
+
]),
|
|
312
|
+
|
|
313
|
+
/** `paddingRight` works like `padding-right` in CSS.
|
|
314
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/padding-right
|
|
315
|
+
* for more details.
|
|
316
|
+
*/
|
|
317
|
+
paddingRight: ReactPropTypes.oneOfType([
|
|
318
|
+
ReactPropTypes.number,
|
|
319
|
+
ReactPropTypes.string
|
|
320
|
+
]),
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* When direction is `ltr`, `paddingStart` is equivalent to `paddingLeft`.
|
|
324
|
+
* When direction is `rtl`, `paddingStart` is equivalent to `paddingRight`.
|
|
325
|
+
*/
|
|
326
|
+
paddingStart: ReactPropTypes.oneOfType([
|
|
327
|
+
ReactPropTypes.number,
|
|
328
|
+
ReactPropTypes.string
|
|
329
|
+
]),
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* When direction is `ltr`, `paddingEnd` is equivalent to `paddingRight`.
|
|
333
|
+
* When direction is `rtl`, `paddingEnd` is equivalent to `paddingLeft`.
|
|
334
|
+
*/
|
|
335
|
+
paddingEnd: ReactPropTypes.oneOfType([
|
|
336
|
+
ReactPropTypes.number,
|
|
337
|
+
ReactPropTypes.string
|
|
338
|
+
]),
|
|
339
|
+
|
|
340
|
+
/** `borderWidth` works like `border-width` in CSS.
|
|
341
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-width
|
|
342
|
+
* for more details.
|
|
343
|
+
*/
|
|
344
|
+
borderWidth: ReactPropTypes.number,
|
|
345
|
+
|
|
346
|
+
/** `borderTopWidth` works like `border-top-width` in CSS.
|
|
347
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-top-width
|
|
348
|
+
* for more details.
|
|
349
|
+
*/
|
|
350
|
+
borderTopWidth: ReactPropTypes.number,
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* When direction is `ltr`, `borderStartWidth` is equivalent to `borderLeftWidth`.
|
|
354
|
+
* When direction is `rtl`, `borderStartWidth` is equivalent to `borderRightWidth`.
|
|
355
|
+
*/
|
|
356
|
+
borderStartWidth: ReactPropTypes.number,
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* When direction is `ltr`, `borderEndWidth` is equivalent to `borderRightWidth`.
|
|
360
|
+
* When direction is `rtl`, `borderEndWidth` is equivalent to `borderLeftWidth`.
|
|
361
|
+
*/
|
|
362
|
+
borderEndWidth: ReactPropTypes.number,
|
|
363
|
+
|
|
364
|
+
/** `borderRightWidth` works like `border-right-width` in CSS.
|
|
365
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-right-width
|
|
366
|
+
* for more details.
|
|
367
|
+
*/
|
|
368
|
+
borderRightWidth: ReactPropTypes.number,
|
|
369
|
+
|
|
370
|
+
/** `borderBottomWidth` works like `border-bottom-width` in CSS.
|
|
371
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom-width
|
|
372
|
+
* for more details.
|
|
373
|
+
*/
|
|
374
|
+
borderBottomWidth: ReactPropTypes.number,
|
|
375
|
+
|
|
376
|
+
/** `borderLeftWidth` works like `border-left-width` in CSS.
|
|
377
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-left-width
|
|
378
|
+
* for more details.
|
|
379
|
+
*/
|
|
380
|
+
borderLeftWidth: ReactPropTypes.number,
|
|
381
|
+
|
|
382
|
+
/** `position` in React Native is similar to regular CSS, but
|
|
383
|
+
* everything is set to `relative` by default, so `absolute`
|
|
384
|
+
* positioning is always just relative to the parent.
|
|
385
|
+
*
|
|
386
|
+
* If you want to position a child using specific numbers of logical
|
|
387
|
+
* pixels relative to its parent, set the child to have `absolute`
|
|
388
|
+
* position.
|
|
389
|
+
*
|
|
390
|
+
* If you want to position a child relative to something
|
|
391
|
+
* that is not its parent, just don't use styles for that. Use the
|
|
392
|
+
* component tree.
|
|
393
|
+
*
|
|
394
|
+
* See https://github.com/facebook/yoga
|
|
395
|
+
* for more details on how `position` differs between React Native
|
|
396
|
+
* and CSS.
|
|
397
|
+
*/
|
|
398
|
+
position: ReactPropTypes.oneOf(['absolute', 'relative']),
|
|
399
|
+
|
|
400
|
+
/** `flexDirection` controls which directions children of a container go.
|
|
401
|
+
* `row` goes left to right, `column` goes top to bottom, and you may
|
|
402
|
+
* be able to guess what the other two do. It works like `flex-direction`
|
|
403
|
+
* in CSS, except the default is `column`.
|
|
404
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
|
|
405
|
+
* for more details.
|
|
406
|
+
*/
|
|
407
|
+
flexDirection: ReactPropTypes.oneOf([
|
|
408
|
+
'row',
|
|
409
|
+
'row-reverse',
|
|
410
|
+
'column',
|
|
411
|
+
'column-reverse'
|
|
412
|
+
]),
|
|
413
|
+
|
|
414
|
+
/** `flexWrap` controls whether children can wrap around after they
|
|
415
|
+
* hit the end of a flex container.
|
|
416
|
+
* It works like `flex-wrap` in CSS (default: nowrap).
|
|
417
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap
|
|
418
|
+
* for more details.
|
|
419
|
+
*/
|
|
420
|
+
flexWrap: ReactPropTypes.oneOf(['wrap', 'nowrap', 'wrap-reverse']),
|
|
421
|
+
|
|
422
|
+
/** `justifyContent` aligns children in the main direction.
|
|
423
|
+
* For example, if children are flowing vertically, `justifyContent`
|
|
424
|
+
* controls how they align vertically.
|
|
425
|
+
* It works like `justify-content` in CSS (default: flex-start).
|
|
426
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content
|
|
427
|
+
* for more details.
|
|
428
|
+
*/
|
|
429
|
+
justifyContent: ReactPropTypes.oneOf([
|
|
430
|
+
'flex-start',
|
|
431
|
+
'flex-end',
|
|
432
|
+
'center',
|
|
433
|
+
'space-between',
|
|
434
|
+
'space-around',
|
|
435
|
+
'space-evenly'
|
|
436
|
+
]),
|
|
437
|
+
|
|
438
|
+
/** `alignItems` aligns children in the cross direction.
|
|
439
|
+
* For example, if children are flowing vertically, `alignItems`
|
|
440
|
+
* controls how they align horizontally.
|
|
441
|
+
* It works like `align-items` in CSS (default: stretch).
|
|
442
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/align-items
|
|
443
|
+
* for more details.
|
|
444
|
+
*/
|
|
445
|
+
alignItems: ReactPropTypes.oneOf([
|
|
446
|
+
'flex-start',
|
|
447
|
+
'flex-end',
|
|
448
|
+
'center',
|
|
449
|
+
'stretch',
|
|
450
|
+
'baseline'
|
|
451
|
+
]),
|
|
452
|
+
|
|
453
|
+
/** `alignSelf` controls how a child aligns in the cross direction,
|
|
454
|
+
* overriding the `alignItems` of the parent. It works like `align-self`
|
|
455
|
+
* in CSS (default: auto).
|
|
456
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/align-self
|
|
457
|
+
* for more details.
|
|
458
|
+
*/
|
|
459
|
+
alignSelf: ReactPropTypes.oneOf([
|
|
460
|
+
'auto',
|
|
461
|
+
'flex-start',
|
|
462
|
+
'flex-end',
|
|
463
|
+
'center',
|
|
464
|
+
'stretch',
|
|
465
|
+
'baseline'
|
|
466
|
+
]),
|
|
467
|
+
|
|
468
|
+
/** `alignContent` controls how rows align in the cross direction,
|
|
469
|
+
* overriding the `alignContent` of the parent.
|
|
470
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
|
|
471
|
+
* for more details.
|
|
472
|
+
*/
|
|
473
|
+
alignContent: ReactPropTypes.oneOf([
|
|
474
|
+
'flex-start',
|
|
475
|
+
'flex-end',
|
|
476
|
+
'center',
|
|
477
|
+
'stretch',
|
|
478
|
+
'space-between',
|
|
479
|
+
'space-around'
|
|
480
|
+
]),
|
|
481
|
+
|
|
482
|
+
/** `overflow` controls how children are measured and displayed.
|
|
483
|
+
* `overflow: hidden` causes views to be clipped while `overflow: scroll`
|
|
484
|
+
* causes views to be measured independently of their parents main axis.
|
|
485
|
+
* It works like `overflow` in CSS (default: visible).
|
|
486
|
+
* See https://developer.mozilla.org/en/docs/Web/CSS/overflow
|
|
487
|
+
* for more details.
|
|
488
|
+
* `overflow: visible` only works on iOS. On Android, all views will clip
|
|
489
|
+
* their children.
|
|
490
|
+
*/
|
|
491
|
+
overflow: ReactPropTypes.oneOf(['visible', 'hidden', 'scroll']),
|
|
492
|
+
|
|
493
|
+
/** In React Native `flex` does not work the same way that it does in CSS.
|
|
494
|
+
* `flex` is a number rather than a string, and it works
|
|
495
|
+
* according to the `Yoga` library
|
|
496
|
+
* at https://github.com/facebook/yoga
|
|
497
|
+
*
|
|
498
|
+
* When `flex` is a positive number, it makes the component flexible
|
|
499
|
+
* and it will be sized proportional to its flex value. So a
|
|
500
|
+
* component with `flex` set to 2 will take twice the space as a
|
|
501
|
+
* component with `flex` set to 1.
|
|
502
|
+
*
|
|
503
|
+
* When `flex` is 0, the component is sized according to `width`
|
|
504
|
+
* and `height` and it is inflexible.
|
|
505
|
+
*
|
|
506
|
+
* When `flex` is -1, the component is normally sized according
|
|
507
|
+
* `width` and `height`. However, if there's not enough space,
|
|
508
|
+
* the component will shrink to its `minWidth` and `minHeight`.
|
|
509
|
+
*
|
|
510
|
+
* flexGrow, flexShrink, and flexBasis work the same as in CSS.
|
|
511
|
+
*/
|
|
512
|
+
flex: ReactPropTypes.number,
|
|
513
|
+
flexGrow: ReactPropTypes.number,
|
|
514
|
+
flexShrink: ReactPropTypes.number,
|
|
515
|
+
flexBasis: ReactPropTypes.oneOfType([
|
|
516
|
+
ReactPropTypes.number,
|
|
517
|
+
ReactPropTypes.string
|
|
518
|
+
]),
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Aspect ratio control the size of the undefined dimension of a node. Aspect ratio is a
|
|
522
|
+
* non-standard property only available in react native and not CSS.
|
|
523
|
+
*
|
|
524
|
+
* - On a node with a set width/height aspect ratio control the size of the unset dimension
|
|
525
|
+
* - On a node with a set flex basis aspect ratio controls the size of the node in the cross axis
|
|
526
|
+
* if unset
|
|
527
|
+
* - On a node with a measure function aspect ratio works as though the measure function measures
|
|
528
|
+
* the flex basis
|
|
529
|
+
* - On a node with flex grow/shrink aspect ratio controls the size of the node in the cross axis
|
|
530
|
+
* if unset
|
|
531
|
+
* - Aspect ratio takes min/max dimensions into account
|
|
532
|
+
*/
|
|
533
|
+
aspectRatio: ReactPropTypes.number,
|
|
534
|
+
|
|
535
|
+
/** `zIndex` controls which components display on top of others.
|
|
536
|
+
* Normally, you don't use `zIndex`. Components render according to
|
|
537
|
+
* their order in the document tree, so later components draw over
|
|
538
|
+
* earlier ones. `zIndex` may be useful if you have animations or custom
|
|
539
|
+
* modal interfaces where you don't want this behavior.
|
|
540
|
+
*
|
|
541
|
+
* It works like the CSS `z-index` property - components with a larger
|
|
542
|
+
* `zIndex` will render on top. Think of the z-direction like it's
|
|
543
|
+
* pointing from the phone into your eyeball.
|
|
544
|
+
* See https://developer.mozilla.org/en-US/docs/Web/CSS/z-index for
|
|
545
|
+
* more details.
|
|
546
|
+
*/
|
|
547
|
+
zIndex: ReactPropTypes.number,
|
|
548
|
+
|
|
549
|
+
/** `direction` specifies the directional flow of the user interface.
|
|
550
|
+
* The default is `inherit`, except for root node which will have
|
|
551
|
+
* value based on the current locale.
|
|
552
|
+
* See https://facebook.github.io/yoga/docs/rtl/
|
|
553
|
+
* for more details.
|
|
554
|
+
* @platform ios
|
|
555
|
+
*/
|
|
556
|
+
direction: ReactPropTypes.oneOf(['inherit', 'ltr', 'rtl'])
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
export default LayoutPropTypes
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
import ColorPropType from './ColorPropType'
|
|
11
|
+
import * as ReactPropTypes from 'prop-types'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* These props can be used to dynamically generate shadows on views, images, text, etc.
|
|
15
|
+
*
|
|
16
|
+
* Because they are dynamically generated, they may cause performance regressions. Static
|
|
17
|
+
* shadow image asset may be a better way to go for optimal performance.
|
|
18
|
+
*
|
|
19
|
+
* These properties are iOS only - for similar functionality on Android, use the [`elevation`
|
|
20
|
+
* property](docs/viewstyleproptypes.html#elevation).
|
|
21
|
+
*/
|
|
22
|
+
const ShadowPropTypesIOS = {
|
|
23
|
+
/**
|
|
24
|
+
* Sets the drop shadow color
|
|
25
|
+
* @platform ios
|
|
26
|
+
*/
|
|
27
|
+
shadowColor: ColorPropType,
|
|
28
|
+
/**
|
|
29
|
+
* Sets the drop shadow offset
|
|
30
|
+
* @platform ios
|
|
31
|
+
*/
|
|
32
|
+
shadowOffset: ReactPropTypes.shape({
|
|
33
|
+
width: ReactPropTypes.number,
|
|
34
|
+
height: ReactPropTypes.number
|
|
35
|
+
}),
|
|
36
|
+
/**
|
|
37
|
+
* Sets the drop shadow opacity (multiplied by the color's alpha component)
|
|
38
|
+
* @platform ios
|
|
39
|
+
*/
|
|
40
|
+
shadowOpacity: ReactPropTypes.number,
|
|
41
|
+
/**
|
|
42
|
+
* Sets the drop shadow blur radius
|
|
43
|
+
* @platform ios
|
|
44
|
+
*/
|
|
45
|
+
shadowRadius: ReactPropTypes.number
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default ShadowPropTypesIOS
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2015-present, Facebook, Inc.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import ImageStylePropTypes from './ImageStylePropTypes'
|
|
12
|
+
import TextStylePropTypes from './TextStylePropTypes'
|
|
13
|
+
import ViewStylePropTypes from './ViewStylePropTypes'
|
|
14
|
+
|
|
15
|
+
import invariant from 'fbjs/lib/invariant'
|
|
16
|
+
|
|
17
|
+
// Hardcoded because this is a legit case but we don't want to load it from
|
|
18
|
+
// a private API. We might likely want to unify style sheet creation with how it
|
|
19
|
+
// is done in the DOM so this might move into React. I know what I'm doing so
|
|
20
|
+
// plz don't fire me.
|
|
21
|
+
const ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'
|
|
22
|
+
|
|
23
|
+
class StyleSheetValidation {
|
|
24
|
+
static validateStyleProp (prop, style, caller) {
|
|
25
|
+
if (allStylePropTypes[prop] === undefined) {
|
|
26
|
+
const message1 = '"' + prop + '" 不是一个有效的 React Native 样式属性'
|
|
27
|
+
// const message2 =
|
|
28
|
+
// '\nValid style props: ' +
|
|
29
|
+
// JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' ')
|
|
30
|
+
// styleError(message1, style, caller, message2)
|
|
31
|
+
styleError(message1, style, caller)
|
|
32
|
+
}
|
|
33
|
+
const error = allStylePropTypes[prop](
|
|
34
|
+
style,
|
|
35
|
+
prop,
|
|
36
|
+
caller,
|
|
37
|
+
'prop',
|
|
38
|
+
null,
|
|
39
|
+
ReactPropTypesSecret
|
|
40
|
+
)
|
|
41
|
+
if (error) {
|
|
42
|
+
styleError(error.message, style, caller)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static validateStyle (name, styles) {
|
|
47
|
+
for (const prop in styles[name]) {
|
|
48
|
+
StyleSheetValidation.validateStyleProp(
|
|
49
|
+
prop,
|
|
50
|
+
styles[name],
|
|
51
|
+
'StyleSheet ' + name
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static addValidStylePropTypes (stylePropTypes) {
|
|
57
|
+
for (const key in stylePropTypes) {
|
|
58
|
+
allStylePropTypes[key] = stylePropTypes[key]
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const styleError = function (message1, style, caller, message2?) {
|
|
64
|
+
invariant(
|
|
65
|
+
false,
|
|
66
|
+
message1 +
|
|
67
|
+
'\n' +
|
|
68
|
+
(caller || '<<unknown>>') +
|
|
69
|
+
': ' +
|
|
70
|
+
JSON.stringify(style, null, ' ') +
|
|
71
|
+
(message2 || '')
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const allStylePropTypes = {}
|
|
76
|
+
|
|
77
|
+
StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes)
|
|
78
|
+
StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes)
|
|
79
|
+
StyleSheetValidation.addValidStylePropTypes(ViewStylePropTypes)
|
|
80
|
+
|
|
81
|
+
export default StyleSheetValidation
|