@office-iss/react-native-win32 0.67.0-preview.2 → 0.67.1
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 +108 -0
- package/CHANGELOG.md +56 -5
- package/Libraries/Components/Keyboard/Keyboard.js +2 -2
- 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/Core/ReactNativeVersion.js +3 -3
- 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/jest/preprocessor.js +7 -75
- package/overrides.json +36 -1
- package/package.json +6 -6
package/.flowconfig
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
; initRNLibraries build step
|
|
11
11
|
<PROJECT_ROOT>/index.js
|
|
12
12
|
<PROJECT_ROOT>/Libraries/Alert/Alert.js
|
|
13
|
+
<PROJECT_ROOT>/Libraries/Components/Pressable/Pressable.js
|
|
13
14
|
<PROJECT_ROOT>/Libraries/Components/SafeAreaView/SafeAreaView.js
|
|
14
15
|
<PROJECT_ROOT>/Libraries/Components/TextInput/TextInput.js
|
|
15
16
|
<PROJECT_ROOT>/Libraries/Components/TextInput/TextInputState.js
|
|
@@ -17,11 +18,15 @@
|
|
|
17
18
|
<PROJECT_ROOT>/Libraries/Components/View/ReactNativeViewAttributes.js
|
|
18
19
|
<PROJECT_ROOT>/Libraries/Components/View/ReactNativeViewViewConfig.js
|
|
19
20
|
<PROJECT_ROOT>/Libraries/Components/View/View.js
|
|
21
|
+
<PROJECT_ROOT>/Libraries/Components/View/ViewPropTypes.js
|
|
20
22
|
<PROJECT_ROOT>/Libraries/Image/Image.js
|
|
21
23
|
<PROJECT_ROOT>/Libraries/Inspector/Inspector.js
|
|
22
24
|
<PROJECT_ROOT>/Libraries/Inspector/InspectorOverlay.js
|
|
23
25
|
<PROJECT_ROOT>/Libraries/Network/RCTNetworking.js
|
|
26
|
+
<PROJECT_ROOT>/Libraries/Pressability/Pressability.js
|
|
27
|
+
<PROJECT_ROOT>/Libraries/Pressability/HoverState.js
|
|
24
28
|
<PROJECT_ROOT>/Libraries/StyleSheet/StyleSheet.js
|
|
29
|
+
<PROJECT_ROOT>/Libraries/Types/CoreEventTypes.js
|
|
25
30
|
<PROJECT_ROOT>/Libraries/Utilities/DeviceInfo.js
|
|
26
31
|
<PROJECT_ROOT>/Libraries/Utilities/Dimensions.js
|
|
27
32
|
|
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,114 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-iss/react-native-win32",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"date": "Mon, 04 Apr 2022 15:12:54 GMT",
|
|
6
|
+
"tag": "@office-iss/react-native-win32_v0.67.1",
|
|
7
|
+
"version": "0.67.1",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "34109996+chiaramooney@users.noreply.github.com",
|
|
12
|
+
"package": "@office-iss/react-native-win32",
|
|
13
|
+
"commit": "f4f970be35618e9942c5c96e6c15c88f8426c91c",
|
|
14
|
+
"comment": "Promote 0.67 to legacy"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "beachball",
|
|
18
|
+
"package": "@office-iss/react-native-win32",
|
|
19
|
+
"comment": "Bump @react-native-windows/virtualized-list to v0.67.1",
|
|
20
|
+
"commit": "e92602643cb768e9ce34430e9800d76769a31a2a"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"date": "Mon, 24 Jan 2022 16:13:22 GMT",
|
|
27
|
+
"tag": "@office-iss/react-native-win32_v0.67.0",
|
|
28
|
+
"version": "0.67.0",
|
|
29
|
+
"comments": {
|
|
30
|
+
"patch": [
|
|
31
|
+
{
|
|
32
|
+
"author": "ngerlem@microsoft.com",
|
|
33
|
+
"package": "@office-iss/react-native-win32",
|
|
34
|
+
"commit": "not available",
|
|
35
|
+
"comment": "Promote 0.67 to latest"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"author": "beachball",
|
|
39
|
+
"package": "@office-iss/react-native-win32",
|
|
40
|
+
"comment": "Bump @react-native-windows/virtualized-list to v0.67.0",
|
|
41
|
+
"commit": "f3ec055a5554558b61b538fcb405719a00249bef"
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"date": "Mon, 24 Jan 2022 16:12:31 GMT",
|
|
48
|
+
"tag": "@office-iss/react-native-win32_v0.67.0",
|
|
49
|
+
"version": "0.67.0",
|
|
50
|
+
"comments": {
|
|
51
|
+
"patch": [
|
|
52
|
+
{
|
|
53
|
+
"author": "ngerlem@microsoft.com",
|
|
54
|
+
"package": "@office-iss/react-native-win32",
|
|
55
|
+
"commit": "56818ebc599aa084aa9ffc949691f1be71da169a",
|
|
56
|
+
"comment": "Promote 0.67 to latest"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"author": "beachball",
|
|
60
|
+
"package": "@office-iss/react-native-win32",
|
|
61
|
+
"comment": "Bump @react-native-windows/virtualized-list to v0.67.0",
|
|
62
|
+
"commit": "56818ebc599aa084aa9ffc949691f1be71da169a"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"date": "Mon, 17 Jan 2022 16:12:54 GMT",
|
|
69
|
+
"tag": "@office-iss/react-native-win32_v0.67.0-preview.3",
|
|
70
|
+
"version": "0.67.0-preview.3",
|
|
71
|
+
"comments": {
|
|
72
|
+
"prerelease": [
|
|
73
|
+
{
|
|
74
|
+
"author": "saadnajmi2@gmail.com",
|
|
75
|
+
"package": "@office-iss/react-native-win32",
|
|
76
|
+
"commit": "not available",
|
|
77
|
+
"comment": "Port windows pressable with extra desktop support to win32"
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"date": "Mon, 17 Jan 2022 16:12:12 GMT",
|
|
84
|
+
"tag": "@office-iss/react-native-win32_v0.67.0-preview.3",
|
|
85
|
+
"version": "0.67.0-preview.3",
|
|
86
|
+
"comments": {
|
|
87
|
+
"prerelease": [
|
|
88
|
+
{
|
|
89
|
+
"author": "saadnajmi2@gmail.com",
|
|
90
|
+
"package": "@office-iss/react-native-win32",
|
|
91
|
+
"commit": "b58a8738eecd8a3d6a2b918fc35d9a7b93b4437a",
|
|
92
|
+
"comment": "Port windows pressable with extra desktop support to win32"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"date": "Mon, 15 Nov 2021 16:10:10 GMT",
|
|
99
|
+
"tag": "@office-iss/react-native-win32_v0.67.0-preview.2",
|
|
100
|
+
"version": "0.67.0-preview.2",
|
|
101
|
+
"comments": {
|
|
102
|
+
"prerelease": [
|
|
103
|
+
{
|
|
104
|
+
"author": "ruaraki@microsoft.com",
|
|
105
|
+
"package": "@office-iss/react-native-win32",
|
|
106
|
+
"commit": "not available",
|
|
107
|
+
"comment": "Add enableFocusRing prop for View and test"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
},
|
|
4
112
|
{
|
|
5
113
|
"date": "Mon, 15 Nov 2021 16:09:34 GMT",
|
|
6
114
|
"tag": "@office-iss/react-native-win32_v0.67.0-preview.2",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,68 @@
|
|
|
1
1
|
# Change Log - @office-iss/react-native-win32
|
|
2
2
|
|
|
3
|
-
This log was last generated on Mon,
|
|
3
|
+
This log was last generated on Mon, 04 Apr 2022 15:12:54 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
## 0.67.
|
|
7
|
+
## 0.67.1
|
|
8
8
|
|
|
9
|
-
Mon,
|
|
9
|
+
Mon, 04 Apr 2022 15:12:54 GMT
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Patches
|
|
12
12
|
|
|
13
|
-
-
|
|
13
|
+
- Promote 0.67 to legacy (34109996+chiaramooney@users.noreply.github.com)
|
|
14
|
+
- Bump @react-native-windows/virtualized-list to v0.67.1
|
|
14
15
|
|
|
16
|
+
## 0.67.0
|
|
17
|
+
|
|
18
|
+
Mon, 24 Jan 2022 16:13:22 GMT
|
|
19
|
+
|
|
20
|
+
### Patches
|
|
21
|
+
|
|
22
|
+
- Promote 0.67 to latest (ngerlem@microsoft.com)
|
|
23
|
+
- Bump @react-native-windows/virtualized-list to v0.67.0
|
|
24
|
+
|
|
25
|
+
## 0.67.0
|
|
26
|
+
|
|
27
|
+
Mon, 24 Jan 2022 16:12:31 GMT
|
|
28
|
+
|
|
29
|
+
### Patches
|
|
30
|
+
|
|
31
|
+
- Promote 0.67 to latest (ngerlem@microsoft.com)
|
|
32
|
+
- Bump @react-native-windows/virtualized-list to v0.67.0
|
|
33
|
+
|
|
34
|
+
## 0.67.0-preview.3
|
|
35
|
+
|
|
36
|
+
Mon, 17 Jan 2022 16:12:54 GMT
|
|
37
|
+
|
|
38
|
+
### Changes
|
|
39
|
+
|
|
40
|
+
- Port windows pressable with extra desktop support to win32 (saadnajmi2@gmail.com)
|
|
41
|
+
|
|
42
|
+
## 0.67.0-preview.3
|
|
43
|
+
|
|
44
|
+
Mon, 17 Jan 2022 16:12:12 GMT
|
|
45
|
+
|
|
46
|
+
### Changes
|
|
47
|
+
|
|
48
|
+
- Port windows pressable with extra desktop support to win32 (saadnajmi2@gmail.com)
|
|
49
|
+
|
|
50
|
+
## 0.67.0-preview.2
|
|
51
|
+
|
|
52
|
+
Mon, 15 Nov 2021 16:10:10 GMT
|
|
53
|
+
|
|
54
|
+
### Changes
|
|
55
|
+
|
|
56
|
+
- Add enableFocusRing prop for View and test (ruaraki@microsoft.com)
|
|
57
|
+
|
|
58
|
+
## 0.67.0-preview.2
|
|
59
|
+
|
|
60
|
+
Mon, 15 Nov 2021 16:09:34 GMT
|
|
61
|
+
|
|
62
|
+
### Changes
|
|
63
|
+
|
|
64
|
+
- Add enableFocusRing prop for View and test (ruaraki@microsoft.com)
|
|
65
|
+
|
|
15
66
|
## 0.67.0-preview.1
|
|
16
67
|
|
|
17
68
|
Mon, 25 Oct 2021 15:07:48 GMT
|
|
@@ -141,9 +141,9 @@ class Keyboard {
|
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
|
-
* @deprecated Use `remove` on the EventSubscription from `
|
|
144
|
+
* @deprecated Use `remove` on the EventSubscription from `addListener`.
|
|
145
145
|
*/
|
|
146
|
-
|
|
146
|
+
removeListener<K: $Keys<KeyboardEventDefinitions>>(
|
|
147
147
|
eventType: K,
|
|
148
148
|
listener: (...$ElementType<KeyboardEventDefinitions, K>) => mixed,
|
|
149
149
|
): void {
|
|
@@ -0,0 +1,384 @@
|
|
|
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-local
|
|
8
|
+
* @format
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import {useMemo, useState, useRef, useImperativeHandle} from 'react';
|
|
13
|
+
import useAndroidRippleForView, {
|
|
14
|
+
type RippleConfig,
|
|
15
|
+
} from './useAndroidRippleForView';
|
|
16
|
+
import type {
|
|
17
|
+
AccessibilityActionEvent,
|
|
18
|
+
AccessibilityActionInfo,
|
|
19
|
+
AccessibilityRole,
|
|
20
|
+
AccessibilityState,
|
|
21
|
+
AccessibilityValue,
|
|
22
|
+
} from '../View/ViewAccessibility';
|
|
23
|
+
import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
|
|
24
|
+
import usePressability from '../../Pressability/usePressability';
|
|
25
|
+
import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
|
|
26
|
+
import type {
|
|
27
|
+
LayoutEvent,
|
|
28
|
+
MouseEvent,
|
|
29
|
+
PressEvent,
|
|
30
|
+
// [Windows
|
|
31
|
+
BlurEvent,
|
|
32
|
+
FocusEvent,
|
|
33
|
+
KeyEvent, // Windows]
|
|
34
|
+
} from '../../Types/CoreEventTypes';
|
|
35
|
+
import type {HandledKeyboardEvent} from '../../Components/View/ViewPropTypes';
|
|
36
|
+
import View from '../View/View';
|
|
37
|
+
import TextInputState from '../TextInput/TextInputState';
|
|
38
|
+
|
|
39
|
+
type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;
|
|
40
|
+
|
|
41
|
+
export type StateCallbackType = $ReadOnly<{|
|
|
42
|
+
pressed: boolean,
|
|
43
|
+
|}>;
|
|
44
|
+
|
|
45
|
+
type Props = $ReadOnly<{|
|
|
46
|
+
/**
|
|
47
|
+
* Accessibility.
|
|
48
|
+
*/
|
|
49
|
+
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
|
|
50
|
+
accessibilityElementsHidden?: ?boolean,
|
|
51
|
+
accessibilityHint?: ?Stringish,
|
|
52
|
+
accessibilityIgnoresInvertColors?: ?boolean,
|
|
53
|
+
accessibilityLabel?: ?Stringish,
|
|
54
|
+
accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'),
|
|
55
|
+
accessibilityRole?: ?AccessibilityRole,
|
|
56
|
+
accessibilityState?: ?AccessibilityState,
|
|
57
|
+
accessibilityValue?: ?AccessibilityValue,
|
|
58
|
+
accessibilityViewIsModal?: ?boolean,
|
|
59
|
+
accessible?: ?boolean,
|
|
60
|
+
focusable?: ?boolean,
|
|
61
|
+
importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'),
|
|
62
|
+
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether a press gesture can be interrupted by a parent gesture such as a
|
|
66
|
+
* scroll event. Defaults to true.
|
|
67
|
+
*/
|
|
68
|
+
cancelable?: ?boolean,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Either children or a render prop that receives a boolean reflecting whether
|
|
72
|
+
* the component is currently pressed.
|
|
73
|
+
*/
|
|
74
|
+
children: React.Node | ((state: StateCallbackType) => React.Node),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Duration to wait after hover in before calling `onHoverIn`.
|
|
78
|
+
*/
|
|
79
|
+
delayHoverIn?: ?number,
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Duration to wait after hover out before calling `onHoverOut`.
|
|
83
|
+
*/
|
|
84
|
+
delayHoverOut?: ?number,
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Duration (in milliseconds) from `onPressIn` before `onLongPress` is called.
|
|
88
|
+
*/
|
|
89
|
+
delayLongPress?: ?number,
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Whether the press behavior is disabled.
|
|
93
|
+
*/
|
|
94
|
+
disabled?: ?boolean,
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Additional distance outside of this view in which a press is detected.
|
|
98
|
+
*/
|
|
99
|
+
hitSlop?: ?RectOrSize,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Additional distance outside of this view in which a touch is considered a
|
|
103
|
+
* press before `onPressOut` is triggered.
|
|
104
|
+
*/
|
|
105
|
+
pressRetentionOffset?: ?RectOrSize,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Called when this view's layout changes.
|
|
109
|
+
*/
|
|
110
|
+
onLayout?: ?(event: LayoutEvent) => mixed,
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Called when the hover is activated to provide visual feedback.
|
|
114
|
+
*/
|
|
115
|
+
onHoverIn?: ?(event: MouseEvent) => mixed,
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Called when the hover is deactivated to undo visual feedback.
|
|
119
|
+
*/
|
|
120
|
+
onHoverOut?: ?(event: MouseEvent) => mixed,
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Called when a long-tap gesture is detected.
|
|
124
|
+
*/
|
|
125
|
+
onLongPress?: ?(event: PressEvent) => mixed,
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Called when a single tap gesture is detected.
|
|
129
|
+
*/
|
|
130
|
+
onPress?: ?(event: PressEvent) => mixed,
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Called when a touch is engaged before `onPress`.
|
|
134
|
+
*/
|
|
135
|
+
onPressIn?: ?(event: PressEvent) => mixed,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Called when a touch is released before `onPress`.
|
|
139
|
+
*/
|
|
140
|
+
onPressOut?: ?(event: PressEvent) => mixed,
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Called after the element loses focus.
|
|
144
|
+
*/
|
|
145
|
+
onBlur?: ?(event: BlurEvent) => mixed,
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Called after the element is focused.
|
|
149
|
+
*/
|
|
150
|
+
onFocus?: ?(event: FocusEvent) => mixed,
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* Called after a key down event is detected.
|
|
154
|
+
*/
|
|
155
|
+
onKeyDown?: ?(event: KeyEvent) => mixed,
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
* Called after a key up event is detected.
|
|
159
|
+
*/
|
|
160
|
+
onKeyUp?: ?(event: KeyEvent) => mixed,
|
|
161
|
+
|
|
162
|
+
/*
|
|
163
|
+
* List of keys handled only by JS.
|
|
164
|
+
*/
|
|
165
|
+
keyDownEvents?: ?$ReadOnlyArray<HandledKeyboardEvent>,
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* List of keys to be handled only by JS.
|
|
169
|
+
*/
|
|
170
|
+
keyUpEvents?: ?$ReadOnlyArray<HandledKeyboardEvent>,
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
* Called in the tunneling phase after a key up event is detected.
|
|
174
|
+
*/
|
|
175
|
+
onKeyDownCapture?: ?(event: KeyEvent) => void,
|
|
176
|
+
|
|
177
|
+
/*
|
|
178
|
+
* Called in the tunneling phase after a key up event is detected.
|
|
179
|
+
*/
|
|
180
|
+
onKeyUpCapture?: ?(event: KeyEvent) => void,
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Either view styles or a function that receives a boolean reflecting whether
|
|
184
|
+
* the component is currently pressed and returns view styles.
|
|
185
|
+
*/
|
|
186
|
+
style?: ViewStyleProp | ((state: StateCallbackType) => ViewStyleProp),
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Identifier used to find this view in tests.
|
|
190
|
+
*/
|
|
191
|
+
testID?: ?string,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* If true, doesn't play system sound on touch.
|
|
195
|
+
*/
|
|
196
|
+
android_disableSound?: ?boolean,
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Enables the Android ripple effect and configures its color.
|
|
200
|
+
*/
|
|
201
|
+
android_ripple?: ?RippleConfig,
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Used only for documentation or testing (e.g. snapshot testing).
|
|
205
|
+
*/
|
|
206
|
+
testOnly_pressed?: ?boolean,
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Duration to wait after press down before calling `onPressIn`.
|
|
210
|
+
*/
|
|
211
|
+
unstable_pressDelay?: ?number,
|
|
212
|
+
|}>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Component used to build display components that should respond to whether the
|
|
216
|
+
* component is currently pressed or not.
|
|
217
|
+
*/
|
|
218
|
+
function Pressable(props: Props, forwardedRef): React.Node {
|
|
219
|
+
const {
|
|
220
|
+
accessible,
|
|
221
|
+
android_disableSound,
|
|
222
|
+
android_ripple,
|
|
223
|
+
cancelable,
|
|
224
|
+
children,
|
|
225
|
+
delayHoverIn,
|
|
226
|
+
delayHoverOut,
|
|
227
|
+
delayLongPress,
|
|
228
|
+
disabled,
|
|
229
|
+
focusable,
|
|
230
|
+
onHoverIn,
|
|
231
|
+
onHoverOut,
|
|
232
|
+
onLongPress,
|
|
233
|
+
onPress,
|
|
234
|
+
onPressIn,
|
|
235
|
+
onPressOut,
|
|
236
|
+
// [Windows
|
|
237
|
+
onBlur,
|
|
238
|
+
onFocus,
|
|
239
|
+
onKeyDown,
|
|
240
|
+
onKeyUp,
|
|
241
|
+
// Windows]
|
|
242
|
+
pressRetentionOffset,
|
|
243
|
+
style,
|
|
244
|
+
testOnly_pressed,
|
|
245
|
+
unstable_pressDelay,
|
|
246
|
+
...restProps
|
|
247
|
+
} = props;
|
|
248
|
+
|
|
249
|
+
const viewRef = useRef<React.ElementRef<typeof View> | null>(null);
|
|
250
|
+
useImperativeHandle(forwardedRef, () => viewRef.current);
|
|
251
|
+
|
|
252
|
+
// [Windows
|
|
253
|
+
const _onBlur = (event: BlurEvent) => {
|
|
254
|
+
TextInputState.blurInput(viewRef.current);
|
|
255
|
+
if (props.onBlur) {
|
|
256
|
+
props.onBlur(event);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const _onFocus = (event: FocusEvent) => {
|
|
261
|
+
TextInputState.focusInput(viewRef.current);
|
|
262
|
+
if (props.onFocus) {
|
|
263
|
+
props.onFocus(event);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
// Windows]
|
|
267
|
+
|
|
268
|
+
const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef);
|
|
269
|
+
|
|
270
|
+
const [pressed, setPressed] = usePressState(testOnly_pressed === true);
|
|
271
|
+
|
|
272
|
+
const hitSlop = normalizeRect(props.hitSlop);
|
|
273
|
+
|
|
274
|
+
const accessibilityState =
|
|
275
|
+
disabled != null
|
|
276
|
+
? {...props.accessibilityState, disabled}
|
|
277
|
+
: props.accessibilityState;
|
|
278
|
+
|
|
279
|
+
const restPropsWithDefaults: React.ElementConfig<typeof View> = {
|
|
280
|
+
...restProps,
|
|
281
|
+
...android_rippleConfig?.viewProps,
|
|
282
|
+
accessible: accessible !== false,
|
|
283
|
+
accessibilityState,
|
|
284
|
+
focusable: focusable !== false,
|
|
285
|
+
hitSlop,
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const config = useMemo(
|
|
289
|
+
() => ({
|
|
290
|
+
cancelable,
|
|
291
|
+
disabled,
|
|
292
|
+
hitSlop,
|
|
293
|
+
pressRectOffset: pressRetentionOffset,
|
|
294
|
+
android_disableSound,
|
|
295
|
+
delayHoverIn,
|
|
296
|
+
delayHoverOut,
|
|
297
|
+
delayLongPress,
|
|
298
|
+
delayPressIn: unstable_pressDelay,
|
|
299
|
+
onHoverIn,
|
|
300
|
+
onHoverOut,
|
|
301
|
+
onLongPress,
|
|
302
|
+
onPress,
|
|
303
|
+
onPressIn(event: PressEvent): void {
|
|
304
|
+
if (android_rippleConfig != null) {
|
|
305
|
+
android_rippleConfig.onPressIn(event);
|
|
306
|
+
}
|
|
307
|
+
setPressed(true);
|
|
308
|
+
if (onPressIn != null) {
|
|
309
|
+
onPressIn(event);
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
onPressMove: android_rippleConfig?.onPressMove,
|
|
313
|
+
onPressOut(event: PressEvent): void {
|
|
314
|
+
if (android_rippleConfig != null) {
|
|
315
|
+
android_rippleConfig.onPressOut(event);
|
|
316
|
+
}
|
|
317
|
+
setPressed(false);
|
|
318
|
+
if (onPressOut != null) {
|
|
319
|
+
onPressOut(event);
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
// [Windows
|
|
323
|
+
onBlur,
|
|
324
|
+
onFocus,
|
|
325
|
+
onKeyDown,
|
|
326
|
+
onKeyUp,
|
|
327
|
+
// Windows]
|
|
328
|
+
}),
|
|
329
|
+
[
|
|
330
|
+
android_disableSound,
|
|
331
|
+
android_rippleConfig,
|
|
332
|
+
cancelable,
|
|
333
|
+
delayHoverIn,
|
|
334
|
+
delayHoverOut,
|
|
335
|
+
delayLongPress,
|
|
336
|
+
disabled,
|
|
337
|
+
hitSlop,
|
|
338
|
+
onHoverIn,
|
|
339
|
+
onHoverOut,
|
|
340
|
+
onLongPress,
|
|
341
|
+
onPress,
|
|
342
|
+
onPressIn,
|
|
343
|
+
onPressOut,
|
|
344
|
+
// [Windows
|
|
345
|
+
onBlur,
|
|
346
|
+
onFocus,
|
|
347
|
+
onKeyDown,
|
|
348
|
+
onKeyUp,
|
|
349
|
+
// Windows]
|
|
350
|
+
pressRetentionOffset,
|
|
351
|
+
setPressed,
|
|
352
|
+
unstable_pressDelay,
|
|
353
|
+
],
|
|
354
|
+
);
|
|
355
|
+
const eventHandlers = usePressability(config);
|
|
356
|
+
|
|
357
|
+
return (
|
|
358
|
+
<View
|
|
359
|
+
{...restPropsWithDefaults}
|
|
360
|
+
{...eventHandlers}
|
|
361
|
+
// [Windows
|
|
362
|
+
onBlur={_onBlur}
|
|
363
|
+
onFocus={_onFocus}
|
|
364
|
+
// Windows]
|
|
365
|
+
ref={viewRef}
|
|
366
|
+
style={typeof style === 'function' ? style({pressed}) : style}>
|
|
367
|
+
{typeof children === 'function' ? children({pressed}) : children}
|
|
368
|
+
{__DEV__ ? <PressabilityDebugView color="red" hitSlop={hitSlop} /> : null}
|
|
369
|
+
</View>
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function usePressState(forcePressed: boolean): [boolean, (boolean) => void] {
|
|
374
|
+
const [pressed, setPressed] = useState(false);
|
|
375
|
+
return [pressed || forcePressed, setPressed];
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
const MemoedPressable = React.memo(React.forwardRef(Pressable));
|
|
379
|
+
MemoedPressable.displayName = 'Pressable';
|
|
380
|
+
|
|
381
|
+
export default (MemoedPressable: React.AbstractComponent<
|
|
382
|
+
Props,
|
|
383
|
+
React.ElementRef<typeof View>,
|
|
384
|
+
>);
|
|
@@ -14,6 +14,9 @@ import ViewNativeComponent from './ViewNativeComponent';
|
|
|
14
14
|
import TextAncestor from '../../Text/TextAncestor';
|
|
15
15
|
import * as React from 'react';
|
|
16
16
|
import invariant from 'invariant'; // [Windows]
|
|
17
|
+
// [Windows
|
|
18
|
+
import type {KeyEvent} from '../../Types/CoreEventTypes';
|
|
19
|
+
// Windows]
|
|
17
20
|
|
|
18
21
|
export type Props = ViewProps;
|
|
19
22
|
|
|
@@ -28,6 +31,50 @@ const View: React.AbstractComponent<
|
|
|
28
31
|
ViewProps,
|
|
29
32
|
React.ElementRef<typeof ViewNativeComponent>,
|
|
30
33
|
> = React.forwardRef((props: ViewProps, forwardedRef) => {
|
|
34
|
+
const _keyDown = (event: KeyEvent) => {
|
|
35
|
+
if (props.keyDownEvents && event.isPropagationStopped() !== true) {
|
|
36
|
+
for (const el of props.keyDownEvents) {
|
|
37
|
+
if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
|
|
38
|
+
event.stopPropagation();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
props.onKeyDown && props.onKeyDown(event);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const _keyUp = (event: KeyEvent) => {
|
|
46
|
+
if (props.keyUpEvents && event.isPropagationStopped() !== true) {
|
|
47
|
+
for (const el of props.keyUpEvents) {
|
|
48
|
+
if (event.nativeEvent.code == el.code && el.handledEventPhase == 3) {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
props.onKeyUp && props.onKeyUp(event);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const _keyDownCapture = (event: KeyEvent) => {
|
|
57
|
+
if (props.keyDownEvents && event.isPropagationStopped() !== true) {
|
|
58
|
+
for (const el of props.keyDownEvents) {
|
|
59
|
+
if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
|
|
60
|
+
event.stopPropagation();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
props.onKeyDownCapture && props.onKeyDownCapture(event);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const _keyUpCapture = (event: KeyEvent) => {
|
|
68
|
+
if (props.keyUpEvents && event.isPropagationStopped() !== true) {
|
|
69
|
+
for (const el of props.keyUpEvents) {
|
|
70
|
+
if (event.nativeEvent.code == el.code && el.handledEventPhase == 1) {
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
props.onKeyUpCapture && props.onKeyUpCapture(event);
|
|
76
|
+
};
|
|
77
|
+
|
|
31
78
|
return (
|
|
32
79
|
// [Windows
|
|
33
80
|
// In core this is a TextAncestor.Provider value={false} See
|
|
@@ -39,10 +86,19 @@ const View: React.AbstractComponent<
|
|
|
39
86
|
!hasTextAncestor,
|
|
40
87
|
'Nesting of <View> within <Text> is not currently supported.',
|
|
41
88
|
);
|
|
42
|
-
|
|
43
|
-
|
|
89
|
+
return (
|
|
90
|
+
<ViewNativeComponent
|
|
91
|
+
{...props}
|
|
92
|
+
ref={forwardedRef}
|
|
93
|
+
onKeyDown={_keyDown}
|
|
94
|
+
onKeyDownCapture={_keyDownCapture}
|
|
95
|
+
onKeyUp={_keyUp}
|
|
96
|
+
onKeyUpCapture={_keyUpCapture}
|
|
97
|
+
/>
|
|
98
|
+
);
|
|
44
99
|
}}
|
|
45
100
|
</TextAncestor.Consumer>
|
|
101
|
+
// Windows]
|
|
46
102
|
);
|
|
47
103
|
});
|
|
48
104
|
|