@office-iss/react-native-win32 0.67.0-preview.2 → 0.67.0-preview.3
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/.flowconfig +5 -0
- package/CHANGELOG.json +30 -0
- package/CHANGELOG.md +20 -4
- package/Libraries/Components/Pressable/Pressable.win32.js +384 -0
- package/Libraries/Components/View/View.win32.js +58 -2
- package/Libraries/Components/View/ViewPropTypes.win32.js +546 -0
- package/Libraries/Pressability/HoverState.win32.js +60 -0
- package/Libraries/Pressability/Pressability.win32.js +962 -0
- package/Libraries/Types/CoreEventTypes.win32.js +191 -0
- package/overrides.json +35 -0
- package/package.json +1 -1
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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 strict-local
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BlurEvent,
|
|
15
|
+
FocusEvent,
|
|
16
|
+
MouseEvent,
|
|
17
|
+
PressEvent,
|
|
18
|
+
Layout,
|
|
19
|
+
LayoutEvent,
|
|
20
|
+
KeyEvent, // [Windows]
|
|
21
|
+
} from '../../Types/CoreEventTypes';
|
|
22
|
+
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
|
|
23
|
+
import type {Node} from 'react';
|
|
24
|
+
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
|
|
25
|
+
import type {
|
|
26
|
+
AccessibilityRole,
|
|
27
|
+
AccessibilityState,
|
|
28
|
+
AccessibilityValue,
|
|
29
|
+
AccessibilityActionEvent,
|
|
30
|
+
AccessibilityActionInfo,
|
|
31
|
+
} from './ViewAccessibility';
|
|
32
|
+
|
|
33
|
+
export type ViewLayout = Layout;
|
|
34
|
+
export type ViewLayoutEvent = LayoutEvent;
|
|
35
|
+
|
|
36
|
+
type BubblingEventProps = $ReadOnly<{|
|
|
37
|
+
onBlur?: ?(event: BlurEvent) => mixed,
|
|
38
|
+
onFocus?: ?(event: FocusEvent) => mixed,
|
|
39
|
+
|}>;
|
|
40
|
+
|
|
41
|
+
type DirectEventProps = $ReadOnly<{|
|
|
42
|
+
/**
|
|
43
|
+
* When `accessible` is true, the system will try to invoke this function
|
|
44
|
+
* when the user performs an accessibility custom action.
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* When `accessible` is true, the system will try to invoke this function
|
|
51
|
+
* when the user performs accessibility tap gesture.
|
|
52
|
+
*
|
|
53
|
+
* See https://reactnative.dev/docs/view.html#onaccessibilitytap
|
|
54
|
+
*/
|
|
55
|
+
onAccessibilityTap?: ?() => mixed,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Invoked on mount and layout changes with:
|
|
59
|
+
*
|
|
60
|
+
* `{nativeEvent: { layout: {x, y, width, height}}}`
|
|
61
|
+
*
|
|
62
|
+
* This event is fired immediately once the layout has been calculated, but
|
|
63
|
+
* the new layout may not yet be reflected on the screen at the time the
|
|
64
|
+
* event is received, especially if a layout animation is in progress.
|
|
65
|
+
*
|
|
66
|
+
* See https://reactnative.dev/docs/view.html#onlayout
|
|
67
|
+
*/
|
|
68
|
+
onLayout?: ?(event: LayoutEvent) => mixed,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* When `accessible` is `true`, the system will invoke this function when the
|
|
72
|
+
* user performs the magic tap gesture.
|
|
73
|
+
*
|
|
74
|
+
* See https://reactnative.dev/docs/view.html#onmagictap
|
|
75
|
+
*/
|
|
76
|
+
onMagicTap?: ?() => mixed,
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* When `accessible` is `true`, the system will invoke this function when the
|
|
80
|
+
* user performs the escape gesture.
|
|
81
|
+
*
|
|
82
|
+
* See https://reactnative.dev/docs/view.html#onaccessibilityescape
|
|
83
|
+
*/
|
|
84
|
+
onAccessibilityEscape?: ?() => mixed,
|
|
85
|
+
|}>;
|
|
86
|
+
|
|
87
|
+
type MouseEventProps = $ReadOnly<{|
|
|
88
|
+
onMouseEnter?: (event: MouseEvent) => void,
|
|
89
|
+
onMouseLeave?: (event: MouseEvent) => void,
|
|
90
|
+
|}>;
|
|
91
|
+
|
|
92
|
+
type TouchEventProps = $ReadOnly<{|
|
|
93
|
+
onTouchCancel?: ?(e: PressEvent) => void,
|
|
94
|
+
onTouchCancelCapture?: ?(e: PressEvent) => void,
|
|
95
|
+
onTouchEnd?: ?(e: PressEvent) => void,
|
|
96
|
+
onTouchEndCapture?: ?(e: PressEvent) => void,
|
|
97
|
+
onTouchMove?: ?(e: PressEvent) => void,
|
|
98
|
+
onTouchMoveCapture?: ?(e: PressEvent) => void,
|
|
99
|
+
onTouchStart?: ?(e: PressEvent) => void,
|
|
100
|
+
onTouchStartCapture?: ?(e: PressEvent) => void,
|
|
101
|
+
|}>;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* For most touch interactions, you'll simply want to wrap your component in
|
|
105
|
+
* `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`,
|
|
106
|
+
* `ScrollResponder.js` and `ResponderEventPlugin.js` for more discussion.
|
|
107
|
+
*/
|
|
108
|
+
type GestureResponderEventProps = $ReadOnly<{|
|
|
109
|
+
/**
|
|
110
|
+
* Does this view want to "claim" touch responsiveness? This is called for
|
|
111
|
+
* every touch move on the `View` when it is not the responder.
|
|
112
|
+
*
|
|
113
|
+
* `View.props.onMoveShouldSetResponder: (event) => [true | false]`, where
|
|
114
|
+
* `event` is a synthetic touch event as described above.
|
|
115
|
+
*
|
|
116
|
+
* See https://reactnative.dev/docs/view.html#onmoveshouldsetresponder
|
|
117
|
+
*/
|
|
118
|
+
onMoveShouldSetResponder?: ?(e: PressEvent) => boolean,
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* If a parent `View` wants to prevent a child `View` from becoming responder
|
|
122
|
+
* on a move, it should have this handler which returns `true`.
|
|
123
|
+
*
|
|
124
|
+
* `View.props.onMoveShouldSetResponderCapture: (event) => [true | false]`,
|
|
125
|
+
* where `event` is a synthetic touch event as described above.
|
|
126
|
+
*
|
|
127
|
+
* See https://reactnative.dev/docs/view.html#onMoveShouldsetrespondercapture
|
|
128
|
+
*/
|
|
129
|
+
onMoveShouldSetResponderCapture?: ?(e: PressEvent) => boolean,
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The View is now responding for touch events. This is the time to highlight
|
|
133
|
+
* and show the user what is happening.
|
|
134
|
+
*
|
|
135
|
+
* `View.props.onResponderGrant: (event) => {}`, where `event` is a synthetic
|
|
136
|
+
* touch event as described above.
|
|
137
|
+
*
|
|
138
|
+
* PanResponder includes a note `// TODO: t7467124 investigate if this can be removed` that
|
|
139
|
+
* should help fixing this return type.
|
|
140
|
+
*
|
|
141
|
+
* See https://reactnative.dev/docs/view.html#onrespondergrant
|
|
142
|
+
*/
|
|
143
|
+
onResponderGrant?: ?(e: PressEvent) => void | boolean,
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The user is moving their finger.
|
|
147
|
+
*
|
|
148
|
+
* `View.props.onResponderMove: (event) => {}`, where `event` is a synthetic
|
|
149
|
+
* touch event as described above.
|
|
150
|
+
*
|
|
151
|
+
* See https://reactnative.dev/docs/view.html#onrespondermove
|
|
152
|
+
*/
|
|
153
|
+
onResponderMove?: ?(e: PressEvent) => void,
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Another responder is already active and will not release it to that `View`
|
|
157
|
+
* asking to be the responder.
|
|
158
|
+
*
|
|
159
|
+
* `View.props.onResponderReject: (event) => {}`, where `event` is a
|
|
160
|
+
* synthetic touch event as described above.
|
|
161
|
+
*
|
|
162
|
+
* See https://reactnative.dev/docs/view.html#onresponderreject
|
|
163
|
+
*/
|
|
164
|
+
onResponderReject?: ?(e: PressEvent) => void,
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Fired at the end of the touch.
|
|
168
|
+
*
|
|
169
|
+
* `View.props.onResponderRelease: (event) => {}`, where `event` is a
|
|
170
|
+
* synthetic touch event as described above.
|
|
171
|
+
*
|
|
172
|
+
* See https://reactnative.dev/docs/view.html#onresponderrelease
|
|
173
|
+
*/
|
|
174
|
+
onResponderRelease?: ?(e: PressEvent) => void,
|
|
175
|
+
|
|
176
|
+
onResponderStart?: ?(e: PressEvent) => void,
|
|
177
|
+
onResponderEnd?: ?(e: PressEvent) => void,
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The responder has been taken from the `View`. Might be taken by other
|
|
181
|
+
* views after a call to `onResponderTerminationRequest`, or might be taken
|
|
182
|
+
* by the OS without asking (e.g., happens with control center/ notification
|
|
183
|
+
* center on iOS)
|
|
184
|
+
*
|
|
185
|
+
* `View.props.onResponderTerminate: (event) => {}`, where `event` is a
|
|
186
|
+
* synthetic touch event as described above.
|
|
187
|
+
*
|
|
188
|
+
* See https://reactnative.dev/docs/view.html#onresponderterminate
|
|
189
|
+
*/
|
|
190
|
+
onResponderTerminate?: ?(e: PressEvent) => void,
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Some other `View` wants to become responder and is asking this `View` to
|
|
194
|
+
* release its responder. Returning `true` allows its release.
|
|
195
|
+
*
|
|
196
|
+
* `View.props.onResponderTerminationRequest: (event) => {}`, where `event`
|
|
197
|
+
* is a synthetic touch event as described above.
|
|
198
|
+
*
|
|
199
|
+
* See https://reactnative.dev/docs/view.html#onresponderterminationrequest
|
|
200
|
+
*/
|
|
201
|
+
onResponderTerminationRequest?: ?(e: PressEvent) => boolean,
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Does this view want to become responder on the start of a touch?
|
|
205
|
+
*
|
|
206
|
+
* `View.props.onStartShouldSetResponder: (event) => [true | false]`, where
|
|
207
|
+
* `event` is a synthetic touch event as described above.
|
|
208
|
+
*
|
|
209
|
+
* See https://reactnative.dev/docs/view.html#onstartshouldsetresponder
|
|
210
|
+
*/
|
|
211
|
+
onStartShouldSetResponder?: ?(e: PressEvent) => boolean,
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* If a parent `View` wants to prevent a child `View` from becoming responder
|
|
215
|
+
* on a touch start, it should have this handler which returns `true`.
|
|
216
|
+
*
|
|
217
|
+
* `View.props.onStartShouldSetResponderCapture: (event) => [true | false]`,
|
|
218
|
+
* where `event` is a synthetic touch event as described above.
|
|
219
|
+
*
|
|
220
|
+
* See https://reactnative.dev/docs/view.html#onstartshouldsetrespondercapture
|
|
221
|
+
*/
|
|
222
|
+
onStartShouldSetResponderCapture?: ?(e: PressEvent) => boolean,
|
|
223
|
+
|}>;
|
|
224
|
+
|
|
225
|
+
type AndroidDrawableThemeAttr = $ReadOnly<{|
|
|
226
|
+
type: 'ThemeAttrAndroid',
|
|
227
|
+
attribute: string,
|
|
228
|
+
|}>;
|
|
229
|
+
|
|
230
|
+
type AndroidDrawableRipple = $ReadOnly<{|
|
|
231
|
+
type: 'RippleAndroid',
|
|
232
|
+
color?: ?number,
|
|
233
|
+
borderless?: ?boolean,
|
|
234
|
+
rippleRadius?: ?number,
|
|
235
|
+
|}>;
|
|
236
|
+
|
|
237
|
+
type AndroidDrawable = AndroidDrawableThemeAttr | AndroidDrawableRipple;
|
|
238
|
+
|
|
239
|
+
type AndroidViewProps = $ReadOnly<{|
|
|
240
|
+
nativeBackgroundAndroid?: ?AndroidDrawable,
|
|
241
|
+
nativeForegroundAndroid?: ?AndroidDrawable,
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Whether this `View` should render itself (and all of its children) into a
|
|
245
|
+
* single hardware texture on the GPU.
|
|
246
|
+
*
|
|
247
|
+
* @platform android
|
|
248
|
+
*
|
|
249
|
+
* See https://reactnative.dev/docs/view.html#rendertohardwaretextureandroid
|
|
250
|
+
*/
|
|
251
|
+
renderToHardwareTextureAndroid?: ?boolean,
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Whether this `View` needs to rendered offscreen and composited with an
|
|
255
|
+
* alpha in order to preserve 100% correct colors and blending behavior.
|
|
256
|
+
*
|
|
257
|
+
* @platform android
|
|
258
|
+
*
|
|
259
|
+
* See https://reactnative.dev/docs/view.html#needsoffscreenalphacompositing
|
|
260
|
+
*/
|
|
261
|
+
needsOffscreenAlphaCompositing?: ?boolean,
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Indicates to accessibility services whether the user should be notified
|
|
265
|
+
* when this view changes. Works for Android API >= 19 only.
|
|
266
|
+
*
|
|
267
|
+
* @platform android
|
|
268
|
+
*
|
|
269
|
+
* See https://reactnative.dev/docs/view.html#accessibilityliveregion
|
|
270
|
+
*/
|
|
271
|
+
accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'),
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Controls how view is important for accessibility which is if it
|
|
275
|
+
* fires accessibility events and if it is reported to accessibility services
|
|
276
|
+
* that query the screen. Works for Android only.
|
|
277
|
+
*
|
|
278
|
+
* @platform android
|
|
279
|
+
*
|
|
280
|
+
* See https://reactnative.dev/docs/view.html#importantforaccessibility
|
|
281
|
+
*/
|
|
282
|
+
importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'),
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Whether to force the Android TV focus engine to move focus to this view.
|
|
286
|
+
*
|
|
287
|
+
* @platform android
|
|
288
|
+
*/
|
|
289
|
+
hasTVPreferredFocus?: ?boolean,
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* TV next focus down (see documentation for the View component).
|
|
293
|
+
*
|
|
294
|
+
* @platform android
|
|
295
|
+
*/
|
|
296
|
+
nextFocusDown?: ?number,
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* TV next focus forward (see documentation for the View component).
|
|
300
|
+
*
|
|
301
|
+
* @platform android
|
|
302
|
+
*/
|
|
303
|
+
nextFocusForward?: ?number,
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* TV next focus left (see documentation for the View component).
|
|
307
|
+
*
|
|
308
|
+
* @platform android
|
|
309
|
+
*/
|
|
310
|
+
nextFocusLeft?: ?number,
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* TV next focus right (see documentation for the View component).
|
|
314
|
+
*
|
|
315
|
+
* @platform android
|
|
316
|
+
*/
|
|
317
|
+
nextFocusRight?: ?number,
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* TV next focus up (see documentation for the View component).
|
|
321
|
+
*
|
|
322
|
+
* @platform android
|
|
323
|
+
*/
|
|
324
|
+
nextFocusUp?: ?number,
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
|
|
328
|
+
*
|
|
329
|
+
* @platform android
|
|
330
|
+
*/
|
|
331
|
+
focusable?: boolean,
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The action to perform when this `View` is clicked on by a non-touch click, eg. enter key on a hardware keyboard.
|
|
335
|
+
*
|
|
336
|
+
* @platform android
|
|
337
|
+
*/
|
|
338
|
+
onClick?: ?(event: PressEvent) => mixed,
|
|
339
|
+
|}>;
|
|
340
|
+
|
|
341
|
+
type IOSViewProps = $ReadOnly<{|
|
|
342
|
+
/**
|
|
343
|
+
* Prevents view from being inverted if set to true and color inversion is turned on.
|
|
344
|
+
*
|
|
345
|
+
* @platform ios
|
|
346
|
+
*/
|
|
347
|
+
accessibilityIgnoresInvertColors?: ?boolean,
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A value indicating whether VoiceOver should ignore the elements
|
|
351
|
+
* within views that are siblings of the receiver.
|
|
352
|
+
* Default is `false`.
|
|
353
|
+
*
|
|
354
|
+
* @platform ios
|
|
355
|
+
*
|
|
356
|
+
* See https://reactnative.dev/docs/view.html#accessibilityviewismodal
|
|
357
|
+
*/
|
|
358
|
+
accessibilityViewIsModal?: ?boolean,
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* A value indicating whether the accessibility elements contained within
|
|
362
|
+
* this accessibility element are hidden.
|
|
363
|
+
*
|
|
364
|
+
* @platform ios
|
|
365
|
+
*
|
|
366
|
+
* See https://reactnative.dev/docs/view.html#accessibilityElementsHidden
|
|
367
|
+
*/
|
|
368
|
+
accessibilityElementsHidden?: ?boolean,
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Whether this `View` should be rendered as a bitmap before compositing.
|
|
372
|
+
*
|
|
373
|
+
* @platform ios
|
|
374
|
+
*
|
|
375
|
+
* See https://reactnative.dev/docs/view.html#shouldrasterizeios
|
|
376
|
+
*/
|
|
377
|
+
shouldRasterizeIOS?: ?boolean,
|
|
378
|
+
|}>;
|
|
379
|
+
|
|
380
|
+
// [Windows
|
|
381
|
+
|
|
382
|
+
export type HandledKeyboardEvent = $ReadOnly<{|
|
|
383
|
+
altKey?: ?boolean,
|
|
384
|
+
ctrlKey?: ?boolean,
|
|
385
|
+
metaKey?: ?boolean,
|
|
386
|
+
shiftKey?: ?boolean,
|
|
387
|
+
code: string,
|
|
388
|
+
handledEventPhase?: number,
|
|
389
|
+
|}>;
|
|
390
|
+
|
|
391
|
+
type WindowsViewProps = $ReadOnly<{|
|
|
392
|
+
/**
|
|
393
|
+
* Key up event
|
|
394
|
+
*
|
|
395
|
+
* @platform windows
|
|
396
|
+
*/
|
|
397
|
+
onKeyUp?: ?(e: KeyEvent) => void,
|
|
398
|
+
onKeyUpCapture?: ?(e: KeyEvent) => void,
|
|
399
|
+
keyUpEvents?: ?$ReadOnlyArray<HandledKeyboardEvent>,
|
|
400
|
+
|
|
401
|
+
onKeyDown?: ?(e: KeyEvent) => void,
|
|
402
|
+
onKeyDownCapture?: ?(e: KeyEvent) => void,
|
|
403
|
+
keyDownEvents?: ?$ReadOnlyArray<HandledKeyboardEvent>,
|
|
404
|
+
/**
|
|
405
|
+
* Specifies the Tooltip for the view
|
|
406
|
+
* @platform windows
|
|
407
|
+
*/
|
|
408
|
+
tooltip?: ?string,
|
|
409
|
+
|
|
410
|
+
tabIndex?: ?number,
|
|
411
|
+
|
|
412
|
+
accessibilityPosInSet?: ?number,
|
|
413
|
+
accessibilitySetSize?: ?number,
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Specifies if the control should show System focus visuals
|
|
417
|
+
*/
|
|
418
|
+
enableFocusRing?: ?boolean,
|
|
419
|
+
|
|
420
|
+
onFocus?: ?(event: FocusEvent) => mixed,
|
|
421
|
+
onBlur?: ?(event: FocusEvent) => mixed,
|
|
422
|
+
onMouseLeave?: ?(event: MouseEvent) => mixed,
|
|
423
|
+
onMouseEnter?: ?(event: MouseEvent) => mixed,
|
|
424
|
+
|}>;
|
|
425
|
+
// Windows]
|
|
426
|
+
|
|
427
|
+
export type ViewProps = $ReadOnly<{|
|
|
428
|
+
...BubblingEventProps,
|
|
429
|
+
...DirectEventProps,
|
|
430
|
+
...GestureResponderEventProps,
|
|
431
|
+
...MouseEventProps,
|
|
432
|
+
...TouchEventProps,
|
|
433
|
+
...AndroidViewProps,
|
|
434
|
+
...IOSViewProps,
|
|
435
|
+
...WindowsViewProps, // [Windows]
|
|
436
|
+
|
|
437
|
+
children?: Node,
|
|
438
|
+
style?: ?ViewStyleProp,
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* When `true`, indicates that the view is an accessibility element.
|
|
442
|
+
* By default, all the touchable elements are accessible.
|
|
443
|
+
*
|
|
444
|
+
* See https://reactnative.dev/docs/view.html#accessible
|
|
445
|
+
*/
|
|
446
|
+
accessible?: ?boolean,
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Overrides the text that's read by the screen reader when the user interacts
|
|
450
|
+
* with the element. By default, the label is constructed by traversing all
|
|
451
|
+
* the children and accumulating all the `Text` nodes separated by space.
|
|
452
|
+
*
|
|
453
|
+
* See https://reactnative.dev/docs/view.html#accessibilitylabel
|
|
454
|
+
*/
|
|
455
|
+
accessibilityLabel?: ?Stringish,
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* An accessibility hint helps users understand what will happen when they perform
|
|
459
|
+
* an action on the accessibility element when that result is not obvious from the
|
|
460
|
+
* accessibility label.
|
|
461
|
+
*
|
|
462
|
+
*
|
|
463
|
+
* See https://reactnative.dev/docs/view.html#accessibilityHint
|
|
464
|
+
*/
|
|
465
|
+
accessibilityHint?: ?Stringish,
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Indicates to accessibility services to treat UI component like a specific role.
|
|
469
|
+
*/
|
|
470
|
+
accessibilityRole?: ?AccessibilityRole,
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Indicates to accessibility services that UI Component is in a specific State.
|
|
474
|
+
*/
|
|
475
|
+
accessibilityState?: ?AccessibilityState,
|
|
476
|
+
accessibilityValue?: ?AccessibilityValue,
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Provides an array of custom actions available for accessibility.
|
|
480
|
+
*
|
|
481
|
+
*/
|
|
482
|
+
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Views that are only used to layout their children or otherwise don't draw
|
|
486
|
+
* anything may be automatically removed from the native hierarchy as an
|
|
487
|
+
* optimization. Set this property to `false` to disable this optimization and
|
|
488
|
+
* ensure that this `View` exists in the native view hierarchy.
|
|
489
|
+
*
|
|
490
|
+
* @platform android
|
|
491
|
+
* In Fabric, this prop is used in ios as well.
|
|
492
|
+
*
|
|
493
|
+
* See https://reactnative.dev/docs/view.html#collapsable
|
|
494
|
+
*/
|
|
495
|
+
collapsable?: ?boolean,
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Used to locate this view in end-to-end tests.
|
|
499
|
+
*
|
|
500
|
+
* > This disables the 'layout-only view removal' optimization for this view!
|
|
501
|
+
*
|
|
502
|
+
* See https://reactnative.dev/docs/view.html#testid
|
|
503
|
+
*/
|
|
504
|
+
testID?: ?string,
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Used to locate this view from native classes.
|
|
508
|
+
*
|
|
509
|
+
* > This disables the 'layout-only view removal' optimization for this view!
|
|
510
|
+
*
|
|
511
|
+
* See https://reactnative.dev/docs/view.html#nativeid
|
|
512
|
+
*/
|
|
513
|
+
nativeID?: ?string,
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* This defines how far a touch event can start away from the view.
|
|
517
|
+
* Typical interface guidelines recommend touch targets that are at least
|
|
518
|
+
* 30 - 40 points/density-independent pixels.
|
|
519
|
+
*
|
|
520
|
+
* > The touch area never extends past the parent view bounds and the Z-index
|
|
521
|
+
* > of sibling views always takes precedence if a touch hits two overlapping
|
|
522
|
+
* > views.
|
|
523
|
+
*
|
|
524
|
+
* See https://reactnative.dev/docs/view.html#hitslop
|
|
525
|
+
*/
|
|
526
|
+
hitSlop?: ?EdgeInsetsProp,
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Controls whether the `View` can be the target of touch events.
|
|
530
|
+
*
|
|
531
|
+
* See https://reactnative.dev/docs/view.html#pointerevents
|
|
532
|
+
*/
|
|
533
|
+
pointerEvents?: ?('auto' | 'box-none' | 'box-only' | 'none'),
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* This is a special performance property exposed by `RCTView` and is useful
|
|
537
|
+
* for scrolling content when there are many subviews, most of which are
|
|
538
|
+
* offscreen. For this property to be effective, it must be applied to a
|
|
539
|
+
* view that contains many subviews that extend outside its bound. The
|
|
540
|
+
* subviews must also have `overflow: hidden`, as should the containing view
|
|
541
|
+
* (or one of its superviews).
|
|
542
|
+
*
|
|
543
|
+
* See https://reactnative.dev/docs/view.html#removeclippedsubviews
|
|
544
|
+
*/
|
|
545
|
+
removeClippedSubviews?: ?boolean,
|
|
546
|
+
|}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
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
|
+
* @flow strict
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import Platform from '../Utilities/Platform';
|
|
12
|
+
|
|
13
|
+
let isEnabled = false;
|
|
14
|
+
|
|
15
|
+
if (Platform.OS === 'web') {
|
|
16
|
+
const canUseDOM = Boolean(
|
|
17
|
+
typeof window !== 'undefined' &&
|
|
18
|
+
window.document &&
|
|
19
|
+
window.document.createElement,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (canUseDOM) {
|
|
23
|
+
/**
|
|
24
|
+
* Web browsers emulate mouse events (and hover states) after touch events.
|
|
25
|
+
* This code infers when the currently-in-use modality supports hover
|
|
26
|
+
* (including for multi-modality devices) and considers "hover" to be enabled
|
|
27
|
+
* if a mouse movement occurs more than 1 second after the last touch event.
|
|
28
|
+
* This threshold is long enough to account for longer delays between the
|
|
29
|
+
* browser firing touch and mouse events on low-powered devices.
|
|
30
|
+
*/
|
|
31
|
+
const HOVER_THRESHOLD_MS = 1000;
|
|
32
|
+
let lastTouchTimestamp = 0;
|
|
33
|
+
|
|
34
|
+
const enableHover = () => {
|
|
35
|
+
if (isEnabled || Date.now() - lastTouchTimestamp < HOVER_THRESHOLD_MS) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
isEnabled = true;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const disableHover = () => {
|
|
42
|
+
lastTouchTimestamp = Date.now();
|
|
43
|
+
if (isEnabled) {
|
|
44
|
+
isEnabled = false;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
document.addEventListener('touchstart', disableHover, true);
|
|
49
|
+
document.addEventListener('touchmove', disableHover, true);
|
|
50
|
+
document.addEventListener('mousemove', enableHover, true);
|
|
51
|
+
}
|
|
52
|
+
// [Windows
|
|
53
|
+
} else if (Platform.OS === 'windows' || Platform.OS === 'win32') {
|
|
54
|
+
isEnabled = true;
|
|
55
|
+
// Windows]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function isHoverEnabled(): boolean {
|
|
59
|
+
return isEnabled;
|
|
60
|
+
}
|