|
@@ -0,0 +1,409 @@
|
|
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
|
+ * @flow
|
|
9
|
+ */
|
|
10
|
+
|
|
11
|
+'use strict';
|
|
12
|
+
|
|
13
|
+import {
|
|
14
|
+ EdgeInsetsPropType,
|
|
15
|
+ PlatformViewPropTypes,
|
|
16
|
+ // ViewStylePropTypes,
|
|
17
|
+ // StyleSheetPropType
|
|
18
|
+} from 'react-native';
|
|
19
|
+
|
|
20
|
+import PropTypes from 'prop-types';
|
|
21
|
+
|
|
22
|
+import ViewAccessibility from './ViewAccessibility'
|
|
23
|
+
|
|
24
|
+const {
|
|
25
|
+ AccessibilityComponentTypes,
|
|
26
|
+ AccessibilityTraits,
|
|
27
|
+ AccessibilityRoles,
|
|
28
|
+ AccessibilityStates,
|
|
29
|
+} = ViewAccessibility;
|
|
30
|
+
|
|
31
|
+// TODO: Figure out how to properly import StyleSheetPropType, or shim it
|
|
32
|
+const stylePropType = PropTypes.object; // StyleSheetPropType(ViewStylePropTypes);
|
|
33
|
+
|
|
34
|
+module.exports = {
|
|
35
|
+ /**
|
|
36
|
+ * When `true`, indicates that the view is an accessibility element.
|
|
37
|
+ * By default, all the touchable elements are accessible.
|
|
38
|
+ *
|
|
39
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessible
|
|
40
|
+ */
|
|
41
|
+ accessible: PropTypes.bool,
|
|
42
|
+
|
|
43
|
+ /**
|
|
44
|
+ * Overrides the text that's read by the screen reader when the user interacts
|
|
45
|
+ * with the element. By default, the label is constructed by traversing all
|
|
46
|
+ * the children and accumulating all the `Text` nodes separated by space.
|
|
47
|
+ *
|
|
48
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilitylabel
|
|
49
|
+ */
|
|
50
|
+ accessibilityLabel: PropTypes.node,
|
|
51
|
+
|
|
52
|
+ /**
|
|
53
|
+ * An accessibility hint helps users understand what will happen when they perform
|
|
54
|
+ * an action on the accessibility element when that result is not obvious from the
|
|
55
|
+ * accessibility label.
|
|
56
|
+ *
|
|
57
|
+ *
|
|
58
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilityHint
|
|
59
|
+ */
|
|
60
|
+ accessibilityHint: PropTypes.string,
|
|
61
|
+
|
|
62
|
+ /**
|
|
63
|
+ * Provides an array of custom actions available for accessibility.
|
|
64
|
+ *
|
|
65
|
+ * @platform ios
|
|
66
|
+ */
|
|
67
|
+ accessibilityActions: PropTypes.arrayOf(PropTypes.string),
|
|
68
|
+
|
|
69
|
+ /**
|
|
70
|
+ * Prevents view from being inverted if set to true and color inversion is turned on.
|
|
71
|
+ *
|
|
72
|
+ * @platform ios
|
|
73
|
+ */
|
|
74
|
+ accessibilityIgnoresInvertColors: PropTypes.bool,
|
|
75
|
+
|
|
76
|
+ /**
|
|
77
|
+ * Indicates to accessibility services to treat UI component like a
|
|
78
|
+ * native one. Works for Android only.
|
|
79
|
+ *
|
|
80
|
+ * @platform android
|
|
81
|
+ *
|
|
82
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilitycomponenttype
|
|
83
|
+ */
|
|
84
|
+ accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentTypes),
|
|
85
|
+
|
|
86
|
+ /**
|
|
87
|
+ * Indicates to accessibility services to treat UI component like a specific role.
|
|
88
|
+ */
|
|
89
|
+ accessibilityRole: PropTypes.oneOf(AccessibilityRoles),
|
|
90
|
+
|
|
91
|
+ /**
|
|
92
|
+ * Indicates to accessibility services that UI Component is in a specific State.
|
|
93
|
+ */
|
|
94
|
+ accessibilityStates: PropTypes.arrayOf(PropTypes.oneOf(AccessibilityStates)),
|
|
95
|
+ /**
|
|
96
|
+ * Indicates to accessibility services whether the user should be notified
|
|
97
|
+ * when this view changes. Works for Android API >= 19 only.
|
|
98
|
+ *
|
|
99
|
+ * @platform android
|
|
100
|
+ *
|
|
101
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilityliveregion
|
|
102
|
+ */
|
|
103
|
+ accessibilityLiveRegion: PropTypes.oneOf(['none', 'polite', 'assertive']),
|
|
104
|
+
|
|
105
|
+ /**
|
|
106
|
+ * Controls how view is important for accessibility which is if it
|
|
107
|
+ * fires accessibility events and if it is reported to accessibility services
|
|
108
|
+ * that query the screen. Works for Android only.
|
|
109
|
+ *
|
|
110
|
+ * @platform android
|
|
111
|
+ *
|
|
112
|
+ * See http://facebook.github.io/react-native/docs/view.html#importantforaccessibility
|
|
113
|
+ */
|
|
114
|
+ importantForAccessibility: PropTypes.oneOf([
|
|
115
|
+ 'auto',
|
|
116
|
+ 'yes',
|
|
117
|
+ 'no',
|
|
118
|
+ 'no-hide-descendants',
|
|
119
|
+ ]),
|
|
120
|
+
|
|
121
|
+ /**
|
|
122
|
+ * Provides additional traits to screen reader. By default no traits are
|
|
123
|
+ * provided unless specified otherwise in element.
|
|
124
|
+ *
|
|
125
|
+ * You can provide one trait or an array of many traits.
|
|
126
|
+ *
|
|
127
|
+ * @platform ios
|
|
128
|
+ *
|
|
129
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilitytraits
|
|
130
|
+ */
|
|
131
|
+ accessibilityTraits: PropTypes.oneOfType([
|
|
132
|
+ PropTypes.oneOf(AccessibilityTraits),
|
|
133
|
+ PropTypes.arrayOf(PropTypes.oneOf(AccessibilityTraits)),
|
|
134
|
+ ]),
|
|
135
|
+
|
|
136
|
+ /**
|
|
137
|
+ * A value indicating whether VoiceOver should ignore the elements
|
|
138
|
+ * within views that are siblings of the receiver.
|
|
139
|
+ * Default is `false`.
|
|
140
|
+ *
|
|
141
|
+ * @platform ios
|
|
142
|
+ *
|
|
143
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilityviewismodal
|
|
144
|
+ */
|
|
145
|
+ accessibilityViewIsModal: PropTypes.bool,
|
|
146
|
+
|
|
147
|
+ /**
|
|
148
|
+ * A value indicating whether the accessibility elements contained within
|
|
149
|
+ * this accessibility element are hidden.
|
|
150
|
+ *
|
|
151
|
+ * @platform ios
|
|
152
|
+ *
|
|
153
|
+ * See http://facebook.github.io/react-native/docs/view.html#accessibilityElementsHidden
|
|
154
|
+ */
|
|
155
|
+ accessibilityElementsHidden: PropTypes.bool,
|
|
156
|
+
|
|
157
|
+ /**
|
|
158
|
+ * When `accessible` is true, the system will try to invoke this function
|
|
159
|
+ * when the user performs an accessibility custom action.
|
|
160
|
+ *
|
|
161
|
+ * @platform ios
|
|
162
|
+ */
|
|
163
|
+ onAccessibilityAction: PropTypes.func,
|
|
164
|
+
|
|
165
|
+ /**
|
|
166
|
+ * When `accessible` is true, the system will try to invoke this function
|
|
167
|
+ * when the user performs accessibility tap gesture.
|
|
168
|
+ *
|
|
169
|
+ * See http://facebook.github.io/react-native/docs/view.html#onaccessibilitytap
|
|
170
|
+ */
|
|
171
|
+ onAccessibilityTap: PropTypes.func,
|
|
172
|
+
|
|
173
|
+ /**
|
|
174
|
+ * When `accessible` is `true`, the system will invoke this function when the
|
|
175
|
+ * user performs the magic tap gesture.
|
|
176
|
+ *
|
|
177
|
+ * See http://facebook.github.io/react-native/docs/view.html#onmagictap
|
|
178
|
+ */
|
|
179
|
+ onMagicTap: PropTypes.func,
|
|
180
|
+
|
|
181
|
+ /**
|
|
182
|
+ * Used to locate this view in end-to-end tests.
|
|
183
|
+ *
|
|
184
|
+ * > This disables the 'layout-only view removal' optimization for this view!
|
|
185
|
+ *
|
|
186
|
+ * See http://facebook.github.io/react-native/docs/view.html#testid
|
|
187
|
+ */
|
|
188
|
+ testID: PropTypes.string,
|
|
189
|
+
|
|
190
|
+ /**
|
|
191
|
+ * Used to locate this view from native classes.
|
|
192
|
+ *
|
|
193
|
+ * > This disables the 'layout-only view removal' optimization for this view!
|
|
194
|
+ *
|
|
195
|
+ * See http://facebook.github.io/react-native/docs/view.html#nativeid
|
|
196
|
+ */
|
|
197
|
+ nativeID: PropTypes.string,
|
|
198
|
+
|
|
199
|
+ /**
|
|
200
|
+ * For most touch interactions, you'll simply want to wrap your component in
|
|
201
|
+ * `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`,
|
|
202
|
+ * `ScrollResponder.js` and `ResponderEventPlugin.js` for more discussion.
|
|
203
|
+ */
|
|
204
|
+
|
|
205
|
+ /**
|
|
206
|
+ * The View is now responding for touch events. This is the time to highlight
|
|
207
|
+ * and show the user what is happening.
|
|
208
|
+ *
|
|
209
|
+ * `View.props.onResponderGrant: (event) => {}`, where `event` is a synthetic
|
|
210
|
+ * touch event as described above.
|
|
211
|
+ *
|
|
212
|
+ * See http://facebook.github.io/react-native/docs/view.html#onrespondergrant
|
|
213
|
+ */
|
|
214
|
+ onResponderGrant: PropTypes.func,
|
|
215
|
+
|
|
216
|
+ /**
|
|
217
|
+ * The user is moving their finger.
|
|
218
|
+ *
|
|
219
|
+ * `View.props.onResponderMove: (event) => {}`, where `event` is a synthetic
|
|
220
|
+ * touch event as described above.
|
|
221
|
+ *
|
|
222
|
+ * See http://facebook.github.io/react-native/docs/view.html#onrespondermove
|
|
223
|
+ */
|
|
224
|
+ onResponderMove: PropTypes.func,
|
|
225
|
+
|
|
226
|
+ /**
|
|
227
|
+ * Another responder is already active and will not release it to that `View`
|
|
228
|
+ * asking to be the responder.
|
|
229
|
+ *
|
|
230
|
+ * `View.props.onResponderReject: (event) => {}`, where `event` is a
|
|
231
|
+ * synthetic touch event as described above.
|
|
232
|
+ *
|
|
233
|
+ * See http://facebook.github.io/react-native/docs/view.html#onresponderreject
|
|
234
|
+ */
|
|
235
|
+ onResponderReject: PropTypes.func,
|
|
236
|
+
|
|
237
|
+ /**
|
|
238
|
+ * Fired at the end of the touch.
|
|
239
|
+ *
|
|
240
|
+ * `View.props.onResponderRelease: (event) => {}`, where `event` is a
|
|
241
|
+ * synthetic touch event as described above.
|
|
242
|
+ *
|
|
243
|
+ * See http://facebook.github.io/react-native/docs/view.html#onresponderrelease
|
|
244
|
+ */
|
|
245
|
+ onResponderRelease: PropTypes.func,
|
|
246
|
+
|
|
247
|
+ /**
|
|
248
|
+ * The responder has been taken from the `View`. Might be taken by other
|
|
249
|
+ * views after a call to `onResponderTerminationRequest`, or might be taken
|
|
250
|
+ * by the OS without asking (e.g., happens with control center/ notification
|
|
251
|
+ * center on iOS)
|
|
252
|
+ *
|
|
253
|
+ * `View.props.onResponderTerminate: (event) => {}`, where `event` is a
|
|
254
|
+ * synthetic touch event as described above.
|
|
255
|
+ *
|
|
256
|
+ * See http://facebook.github.io/react-native/docs/view.html#onresponderterminate
|
|
257
|
+ */
|
|
258
|
+ onResponderTerminate: PropTypes.func,
|
|
259
|
+
|
|
260
|
+ /**
|
|
261
|
+ * Some other `View` wants to become responder and is asking this `View` to
|
|
262
|
+ * release its responder. Returning `true` allows its release.
|
|
263
|
+ *
|
|
264
|
+ * `View.props.onResponderTerminationRequest: (event) => {}`, where `event`
|
|
265
|
+ * is a synthetic touch event as described above.
|
|
266
|
+ *
|
|
267
|
+ * See http://facebook.github.io/react-native/docs/view.html#onresponderterminationrequest
|
|
268
|
+ */
|
|
269
|
+ onResponderTerminationRequest: PropTypes.func,
|
|
270
|
+
|
|
271
|
+ /**
|
|
272
|
+ * Does this view want to become responder on the start of a touch?
|
|
273
|
+ *
|
|
274
|
+ * `View.props.onStartShouldSetResponder: (event) => [true | false]`, where
|
|
275
|
+ * `event` is a synthetic touch event as described above.
|
|
276
|
+ *
|
|
277
|
+ * See http://facebook.github.io/react-native/docs/view.html#onstartshouldsetresponder
|
|
278
|
+ */
|
|
279
|
+ onStartShouldSetResponder: PropTypes.func,
|
|
280
|
+
|
|
281
|
+ /**
|
|
282
|
+ * If a parent `View` wants to prevent a child `View` from becoming responder
|
|
283
|
+ * on a touch start, it should have this handler which returns `true`.
|
|
284
|
+ *
|
|
285
|
+ * `View.props.onStartShouldSetResponderCapture: (event) => [true | false]`,
|
|
286
|
+ * where `event` is a synthetic touch event as described above.
|
|
287
|
+ *
|
|
288
|
+ * See http://facebook.github.io/react-native/docs/view.html#onstartshouldsetrespondercapture
|
|
289
|
+ */
|
|
290
|
+ onStartShouldSetResponderCapture: PropTypes.func,
|
|
291
|
+
|
|
292
|
+ /**
|
|
293
|
+ * Does this view want to "claim" touch responsiveness? This is called for
|
|
294
|
+ * every touch move on the `View` when it is not the responder.
|
|
295
|
+ *
|
|
296
|
+ * `View.props.onMoveShouldSetResponder: (event) => [true | false]`, where
|
|
297
|
+ * `event` is a synthetic touch event as described above.
|
|
298
|
+ *
|
|
299
|
+ * See http://facebook.github.io/react-native/docs/view.html#onmoveshouldsetresponder
|
|
300
|
+ */
|
|
301
|
+ onMoveShouldSetResponder: PropTypes.func,
|
|
302
|
+
|
|
303
|
+ /**
|
|
304
|
+ * If a parent `View` wants to prevent a child `View` from becoming responder
|
|
305
|
+ * on a move, it should have this handler which returns `true`.
|
|
306
|
+ *
|
|
307
|
+ * `View.props.onMoveShouldSetResponderCapture: (event) => [true | false]`,
|
|
308
|
+ * where `event` is a synthetic touch event as described above.
|
|
309
|
+ *
|
|
310
|
+ * See http://facebook.github.io/react-native/docs/view.html#onMoveShouldsetrespondercapture
|
|
311
|
+ */
|
|
312
|
+ onMoveShouldSetResponderCapture: PropTypes.func,
|
|
313
|
+
|
|
314
|
+ /**
|
|
315
|
+ * This defines how far a touch event can start away from the view.
|
|
316
|
+ * Typical interface guidelines recommend touch targets that are at least
|
|
317
|
+ * 30 - 40 points/density-independent pixels.
|
|
318
|
+ *
|
|
319
|
+ * > The touch area never extends past the parent view bounds and the Z-index
|
|
320
|
+ * > of sibling views always takes precedence if a touch hits two overlapping
|
|
321
|
+ * > views.
|
|
322
|
+ *
|
|
323
|
+ * See http://facebook.github.io/react-native/docs/view.html#hitslop
|
|
324
|
+ */
|
|
325
|
+ hitSlop: EdgeInsetsPropType,
|
|
326
|
+
|
|
327
|
+ /**
|
|
328
|
+ * Invoked on mount and layout changes with:
|
|
329
|
+ *
|
|
330
|
+ * `{nativeEvent: { layout: {x, y, width, height}}}`
|
|
331
|
+ *
|
|
332
|
+ * This event is fired immediately once the layout has been calculated, but
|
|
333
|
+ * the new layout may not yet be reflected on the screen at the time the
|
|
334
|
+ * event is received, especially if a layout animation is in progress.
|
|
335
|
+ *
|
|
336
|
+ * See http://facebook.github.io/react-native/docs/view.html#onlayout
|
|
337
|
+ */
|
|
338
|
+ onLayout: PropTypes.func,
|
|
339
|
+
|
|
340
|
+ /**
|
|
341
|
+ * Controls whether the `View` can be the target of touch events.
|
|
342
|
+ *
|
|
343
|
+ * See http://facebook.github.io/react-native/docs/view.html#pointerevents
|
|
344
|
+ */
|
|
345
|
+ pointerEvents: PropTypes.oneOf(['box-none', 'none', 'box-only', 'auto']),
|
|
346
|
+
|
|
347
|
+ /**
|
|
348
|
+ * See http://facebook.github.io/react-native/docs/style.html
|
|
349
|
+ */
|
|
350
|
+ style: stylePropType,
|
|
351
|
+
|
|
352
|
+ /**
|
|
353
|
+ * This is a special performance property exposed by `RCTView` and is useful
|
|
354
|
+ * for scrolling content when there are many subviews, most of which are
|
|
355
|
+ * offscreen. For this property to be effective, it must be applied to a
|
|
356
|
+ * view that contains many subviews that extend outside its bound. The
|
|
357
|
+ * subviews must also have `overflow: hidden`, as should the containing view
|
|
358
|
+ * (or one of its superviews).
|
|
359
|
+ *
|
|
360
|
+ * See http://facebook.github.io/react-native/docs/view.html#removeclippedsubviews
|
|
361
|
+ */
|
|
362
|
+ removeClippedSubviews: PropTypes.bool,
|
|
363
|
+
|
|
364
|
+ /**
|
|
365
|
+ * Whether this `View` should render itself (and all of its children) into a
|
|
366
|
+ * single hardware texture on the GPU.
|
|
367
|
+ *
|
|
368
|
+ * @platform android
|
|
369
|
+ *
|
|
370
|
+ * See http://facebook.github.io/react-native/docs/view.html#rendertohardwaretextureandroid
|
|
371
|
+ */
|
|
372
|
+ renderToHardwareTextureAndroid: PropTypes.bool,
|
|
373
|
+
|
|
374
|
+ /**
|
|
375
|
+ * Whether this `View` should be rendered as a bitmap before compositing.
|
|
376
|
+ *
|
|
377
|
+ * @platform ios
|
|
378
|
+ *
|
|
379
|
+ * See http://facebook.github.io/react-native/docs/view.html#shouldrasterizeios
|
|
380
|
+ */
|
|
381
|
+ shouldRasterizeIOS: PropTypes.bool,
|
|
382
|
+
|
|
383
|
+ /**
|
|
384
|
+ * Views that are only used to layout their children or otherwise don't draw
|
|
385
|
+ * anything may be automatically removed from the native hierarchy as an
|
|
386
|
+ * optimization. Set this property to `false` to disable this optimization and
|
|
387
|
+ * ensure that this `View` exists in the native view hierarchy.
|
|
388
|
+ *
|
|
389
|
+ * @platform android
|
|
390
|
+ *
|
|
391
|
+ * See http://facebook.github.io/react-native/docs/view.html#collapsable
|
|
392
|
+ */
|
|
393
|
+ collapsable: PropTypes.bool,
|
|
394
|
+
|
|
395
|
+ /**
|
|
396
|
+ * Whether this `View` needs to rendered offscreen and composited with an
|
|
397
|
+ * alpha in order to preserve 100% correct colors and blending behavior.
|
|
398
|
+ *
|
|
399
|
+ * @platform android
|
|
400
|
+ *
|
|
401
|
+ * See http://facebook.github.io/react-native/docs/view.html#needsoffscreenalphacompositing
|
|
402
|
+ */
|
|
403
|
+ needsOffscreenAlphaCompositing: PropTypes.bool,
|
|
404
|
+
|
|
405
|
+ /**
|
|
406
|
+ * Any additional platform-specific view prop types, or prop type overrides.
|
|
407
|
+ */
|
|
408
|
+ ...PlatformViewPropTypes,
|
|
409
|
+};
|