@react-native-oh/react-native-harmony 0.72.82 → 0.77.18
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/LICENSE +21 -0
- package/LICENSE-Meta +21 -0
- package/Libraries/Alert/delegates/AlertDelegate.harmony.ts +84 -0
- package/Libraries/Alert/{AlertManager.ts → delegates/AlertManager.harmony.ts} +10 -4
- package/Libraries/Animated/shouldUseTurboAnimatedModule.harmony.ts +10 -0
- package/Libraries/Components/AccessibilityInfo/delegates/AccessibilityInfoDelegate.harmony.ts +44 -0
- package/Libraries/Components/AccessibilityInfo/{NativeAccessibilityInfoHarmony.ts → delegates/NativeAccessibilityInfoHarmony.harmony.ts} +9 -2
- package/Libraries/Components/Keyboard/delegates/KeyboardAvoidingViewDelegate.harmony.ts +42 -0
- package/Libraries/Components/RefreshControl/delegates/RefreshControlDelegate.harmony.tsx +29 -0
- package/Libraries/Components/SafeAreaView/SafeAreaView.harmony.tsx +93 -31
- package/Libraries/Components/ScrollView/delegates/ScrollViewDelegate.harmony.tsx +41 -0
- package/Libraries/Components/ScrollView/delegates/ScrollViewNativeComponentDelegate.harmony.ts +89 -0
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.ts +19 -0
- package/Libraries/Components/StatusBar/delegates/NativeStatusBarManagerHarmony.harmony.ts +53 -0
- package/Libraries/Components/StatusBar/delegates/StatusBarDelegate.harmony.ts +83 -0
- package/Libraries/Components/TextInput/delegates/TextInputDelegate.harmony.tsx +98 -0
- package/Libraries/Components/TextInput/delegates/TextInputStateDelegate.harmony.tsx +20 -0
- package/Libraries/Components/Touchable/delegates/TouchableHighlightDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableNativeFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/Touchable/delegates/TouchableWithoutFeedbackDelegate.harmony.ts +14 -0
- package/Libraries/Components/delegates/ButtonDelegate.harmony.ts +41 -0
- package/Libraries/Core/setUpPlatform.harmony.js +30 -0
- package/Libraries/Image/AssetSourceResolver.harmony.ts +75 -29
- package/Libraries/Image/Image.harmony.ts +17 -0
- package/Libraries/NativeComponent/BaseViewConfig.harmony.js +12 -326
- package/Libraries/NativeComponent/delegates/ViewConfigIgnoreDelegate.harmony.ts +13 -0
- package/Libraries/ReactNative/delegates/BridgelessUIManagerDelegate.harmony.ts +14 -0
- package/Libraries/ReactNative/delegates/I18nManagerDelegate.harmony.ts +22 -0
- package/Libraries/Settings/Settings.harmony.ts +20 -0
- package/Libraries/Share/delegates/ShareDelegate.harmony.ts +42 -0
- package/Libraries/StyleSheet/NativePlatformColor.harmony.ts +15 -0
- package/Libraries/StyleSheet/PlatformColorValueTypes.harmony.ts +8 -1
- package/Libraries/Utilities/BackHandler.harmony.ts +10 -0
- package/Libraries/Utilities/NativePlatformConstantsHarmony.harmony.ts +17 -0
- package/Libraries/Utilities/Platform.harmony.ts +38 -13
- package/Libraries/Vibration/delegates/VibrationDelegate.harmony.ts +14 -0
- package/NOTICE.md +846 -0
- package/README.md +2 -2
- package/index.js +53 -63
- package/jest.config.js +0 -7
- package/metro.config.d.ts +17 -0
- package/metro.config.js +398 -115
- package/package.json +58 -37
- package/react-native.config.js +57 -9
- package/react_native_openharmony.har +0 -0
- package/tsconfig.json +10 -4
- package/types/index.harmony.d.ts +99 -0
- package/Libraries/Alert/Alert.harmony.js +0 -77
- package/Libraries/Animated/NativeAnimatedHelper.harmony.js +0 -601
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.harmony.js +0 -441
- package/Libraries/Components/Button/Button.harmony.js +0 -451
- package/Libraries/Components/Image/Image.flow.harmony.js +0 -53
- package/Libraries/Components/Image/Image.harmony.js +0 -317
- package/Libraries/Components/Image/NativeImageLoaderHarmony.js +0 -38
- package/Libraries/Components/Keyboard/KeyboardAvoidingView.harmony.js +0 -256
- package/Libraries/Components/RefreshControl/RefreshControl.harmony.js +0 -210
- package/Libraries/Components/ScrollView/ScrollView.harmony.js +0 -1951
- package/Libraries/Components/ScrollView/processDecelerationRate.harmony.js +0 -24
- package/Libraries/Components/StatusBar/NativeStatusBarManagerHarmony.js +0 -71
- package/Libraries/Components/StatusBar/StatusBar.harmony.js +0 -447
- package/Libraries/Components/TextInput/TextInput.harmony.js +0 -1716
- package/Libraries/Components/TextInput/TextInputState.harmony.js +0 -220
- package/Libraries/Components/Touchable/TouchableHighlight.harmony.js +0 -396
- package/Libraries/Components/Touchable/TouchableNativeFeedback.harmony.js +0 -364
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.harmony.js +0 -227
- package/Libraries/Components/View/View.harmony.js +0 -149
- package/Libraries/Core/setUpReactDevTools.harmony.js +0 -93
- package/Libraries/ReactNative/I18nManager.harmony.js +0 -78
- package/Libraries/ReactNative/UIManager.harmony.js +0 -210
- package/Libraries/Settings/Settings.harmony.js +0 -15
- package/Libraries/Share/Share.harmony.js +0 -174
- package/Libraries/StyleSheet/NativePlatformColor.ts +0 -8
- package/Libraries/Utilities/BackHandler.harmony.js +0 -109
- package/Libraries/Utilities/NativePlatformConstants.harmony.ts +0 -8
- package/Libraries/Utilities/Platform.d.ts +0 -117
- package/Libraries/Utilities/createPerformanceLogger.harmony.js +0 -328
- package/Libraries/Vibration/Vibration.harmony.js +0 -88
- package/harmony/.keep +0 -0
- package/harmony/rnoh-hvigor-plugin-0.2.0.tgz +0 -0
- package/react_native_openharmony_release.har +0 -0
- package/types/index.d.ts +0 -108
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and 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
|
-
// RNOH patch: disable view flattening
|
|
12
|
-
|
|
13
|
-
import type { PressEvent } from "react-native/Libraries/Types/CoreEventTypes";
|
|
14
|
-
import typeof TouchableWithoutFeedback from "./TouchableWithoutFeedback";
|
|
15
|
-
|
|
16
|
-
import View from "react-native/Libraries/Components/View/View";
|
|
17
|
-
import Pressability, {
|
|
18
|
-
type PressabilityConfig,
|
|
19
|
-
} from "react-native/Libraries/Pressability/Pressability";
|
|
20
|
-
import { PressabilityDebugView } from "react-native/Libraries/Pressability/PressabilityDebug";
|
|
21
|
-
import { findHostInstance_DEPRECATED } from "react-native/Libraries/ReactNative/RendererProxy";
|
|
22
|
-
import processColor from "react-native/Libraries/StyleSheet/processColor";
|
|
23
|
-
import Platform from "react-native/Libraries/Utilities/Platform";
|
|
24
|
-
import { Commands } from "react-native/Libraries/Components/View/ViewNativeComponent";
|
|
25
|
-
import invariant from "invariant";
|
|
26
|
-
import * as React from "react";
|
|
27
|
-
|
|
28
|
-
type Props = $ReadOnly<{|
|
|
29
|
-
...React.ElementConfig<TouchableWithoutFeedback>,
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Determines the type of background drawable that's going to be used to
|
|
33
|
-
* display feedback. It takes an object with `type` property and extra data
|
|
34
|
-
* depending on the `type`. It's recommended to use one of the static
|
|
35
|
-
* methods to generate that dictionary.
|
|
36
|
-
*/
|
|
37
|
-
background?: ?(
|
|
38
|
-
| $ReadOnly<{|
|
|
39
|
-
type: "ThemeAttrAndroid",
|
|
40
|
-
attribute:
|
|
41
|
-
| "selectableItemBackground"
|
|
42
|
-
| "selectableItemBackgroundBorderless",
|
|
43
|
-
rippleRadius: ?number,
|
|
44
|
-
|}>
|
|
45
|
-
| $ReadOnly<{|
|
|
46
|
-
type: "RippleAndroid",
|
|
47
|
-
color: ?number,
|
|
48
|
-
borderless: boolean,
|
|
49
|
-
rippleRadius: ?number,
|
|
50
|
-
|}>
|
|
51
|
-
),
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* TV preferred focus (see documentation for the View component).
|
|
55
|
-
*/
|
|
56
|
-
hasTVPreferredFocus?: ?boolean,
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* TV next focus down (see documentation for the View component).
|
|
60
|
-
*/
|
|
61
|
-
nextFocusDown?: ?number,
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* TV next focus forward (see documentation for the View component).
|
|
65
|
-
*/
|
|
66
|
-
nextFocusForward?: ?number,
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* TV next focus left (see documentation for the View component).
|
|
70
|
-
*/
|
|
71
|
-
nextFocusLeft?: ?number,
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* TV next focus right (see documentation for the View component).
|
|
75
|
-
*/
|
|
76
|
-
nextFocusRight?: ?number,
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* TV next focus up (see documentation for the View component).
|
|
80
|
-
*/
|
|
81
|
-
nextFocusUp?: ?number,
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Set to true to add the ripple effect to the foreground of the view, instead
|
|
85
|
-
* of the background. This is useful if one of your child views has a
|
|
86
|
-
* background of its own, or you're e.g. displaying images, and you don't want
|
|
87
|
-
* the ripple to be covered by them.
|
|
88
|
-
*
|
|
89
|
-
* Check TouchableNativeFeedback.canUseNativeForeground() first, as this is
|
|
90
|
-
* only available on Android 6.0 and above. If you try to use this on older
|
|
91
|
-
* versions, this will fallback to background.
|
|
92
|
-
*/
|
|
93
|
-
useForeground?: ?boolean,
|
|
94
|
-
|}>;
|
|
95
|
-
|
|
96
|
-
type State = $ReadOnly<{|
|
|
97
|
-
pressability: Pressability,
|
|
98
|
-
|}>;
|
|
99
|
-
|
|
100
|
-
class TouchableNativeFeedback extends React.Component<Props, State> {
|
|
101
|
-
/**
|
|
102
|
-
* Creates a value for the `background` prop that uses the Android theme's
|
|
103
|
-
* default background for selectable elements.
|
|
104
|
-
*/
|
|
105
|
-
static SelectableBackground: (rippleRadius: ?number) => $ReadOnly<{|
|
|
106
|
-
attribute: "selectableItemBackground",
|
|
107
|
-
type: "ThemeAttrAndroid",
|
|
108
|
-
rippleRadius: ?number,
|
|
109
|
-
|}> = (rippleRadius: ?number) => ({
|
|
110
|
-
type: "ThemeAttrAndroid",
|
|
111
|
-
attribute: "selectableItemBackground",
|
|
112
|
-
rippleRadius,
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Creates a value for the `background` prop that uses the Android theme's
|
|
117
|
-
* default background for borderless selectable elements. Requires API 21+.
|
|
118
|
-
*/
|
|
119
|
-
static SelectableBackgroundBorderless: (rippleRadius: ?number) => $ReadOnly<{|
|
|
120
|
-
attribute: "selectableItemBackgroundBorderless",
|
|
121
|
-
type: "ThemeAttrAndroid",
|
|
122
|
-
rippleRadius: ?number,
|
|
123
|
-
|}> = (rippleRadius: ?number) => ({
|
|
124
|
-
type: "ThemeAttrAndroid",
|
|
125
|
-
attribute: "selectableItemBackgroundBorderless",
|
|
126
|
-
rippleRadius,
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Creates a value for the `background` prop that uses the Android ripple with
|
|
131
|
-
* the supplied color. If `borderless` is true, the ripple will render outside
|
|
132
|
-
* of the view bounds. Requires API 21+.
|
|
133
|
-
*/
|
|
134
|
-
static Ripple: (
|
|
135
|
-
color: string,
|
|
136
|
-
borderless: boolean,
|
|
137
|
-
rippleRadius: ?number
|
|
138
|
-
) => $ReadOnly<{|
|
|
139
|
-
borderless: boolean,
|
|
140
|
-
color: ?number,
|
|
141
|
-
rippleRadius: ?number,
|
|
142
|
-
type: "RippleAndroid",
|
|
143
|
-
|}> = (color: string, borderless: boolean, rippleRadius: ?number) => {
|
|
144
|
-
const processedColor = processColor(color);
|
|
145
|
-
invariant(
|
|
146
|
-
processedColor == null || typeof processedColor === "number",
|
|
147
|
-
"Unexpected color given for Ripple color"
|
|
148
|
-
);
|
|
149
|
-
return {
|
|
150
|
-
type: "RippleAndroid",
|
|
151
|
-
color: processedColor,
|
|
152
|
-
borderless,
|
|
153
|
-
rippleRadius,
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Whether `useForeground` is supported.
|
|
159
|
-
*/
|
|
160
|
-
static canUseNativeForeground: () => boolean = () =>
|
|
161
|
-
Platform.OS === "android" && Platform.Version >= 23;
|
|
162
|
-
|
|
163
|
-
state: State = {
|
|
164
|
-
pressability: new Pressability(this._createPressabilityConfig()),
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
_createPressabilityConfig(): PressabilityConfig {
|
|
168
|
-
const accessibilityStateDisabled =
|
|
169
|
-
this.props["aria-disabled"] ?? this.props.accessibilityState?.disabled;
|
|
170
|
-
return {
|
|
171
|
-
cancelable: !this.props.rejectResponderTermination,
|
|
172
|
-
disabled:
|
|
173
|
-
this.props.disabled != null
|
|
174
|
-
? this.props.disabled
|
|
175
|
-
: accessibilityStateDisabled,
|
|
176
|
-
hitSlop: this.props.hitSlop,
|
|
177
|
-
delayLongPress: this.props.delayLongPress,
|
|
178
|
-
delayPressIn: this.props.delayPressIn,
|
|
179
|
-
delayPressOut: this.props.delayPressOut,
|
|
180
|
-
minPressDuration: 0,
|
|
181
|
-
pressRectOffset: this.props.pressRetentionOffset,
|
|
182
|
-
android_disableSound: this.props.touchSoundDisabled,
|
|
183
|
-
onLongPress: this.props.onLongPress,
|
|
184
|
-
onPress: this.props.onPress,
|
|
185
|
-
onPressIn: (event) => {
|
|
186
|
-
if (Platform.OS === "android") {
|
|
187
|
-
this._dispatchHotspotUpdate(event);
|
|
188
|
-
this._dispatchPressedStateChange(true);
|
|
189
|
-
}
|
|
190
|
-
if (this.props.onPressIn != null) {
|
|
191
|
-
this.props.onPressIn(event);
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
onPressMove: (event) => {
|
|
195
|
-
if (Platform.OS === "android") {
|
|
196
|
-
this._dispatchHotspotUpdate(event);
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
onPressOut: (event) => {
|
|
200
|
-
if (Platform.OS === "android") {
|
|
201
|
-
this._dispatchPressedStateChange(false);
|
|
202
|
-
}
|
|
203
|
-
if (this.props.onPressOut != null) {
|
|
204
|
-
this.props.onPressOut(event);
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
_dispatchPressedStateChange(pressed: boolean): void {
|
|
211
|
-
if (Platform.OS === "android") {
|
|
212
|
-
const hostComponentRef = findHostInstance_DEPRECATED(this);
|
|
213
|
-
if (hostComponentRef == null) {
|
|
214
|
-
console.warn(
|
|
215
|
-
"Touchable: Unable to find HostComponent instance. " +
|
|
216
|
-
"Has your Touchable component been unmounted?"
|
|
217
|
-
);
|
|
218
|
-
} else {
|
|
219
|
-
Commands.setPressed(hostComponentRef, pressed);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
_dispatchHotspotUpdate(event: PressEvent): void {
|
|
225
|
-
if (Platform.OS === "android") {
|
|
226
|
-
const { locationX, locationY } = event.nativeEvent;
|
|
227
|
-
const hostComponentRef = findHostInstance_DEPRECATED(this);
|
|
228
|
-
if (hostComponentRef == null) {
|
|
229
|
-
console.warn(
|
|
230
|
-
"Touchable: Unable to find HostComponent instance. " +
|
|
231
|
-
"Has your Touchable component been unmounted?"
|
|
232
|
-
);
|
|
233
|
-
} else {
|
|
234
|
-
Commands.hotspotUpdate(
|
|
235
|
-
hostComponentRef,
|
|
236
|
-
locationX ?? 0,
|
|
237
|
-
locationY ?? 0
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
render(): React.Node {
|
|
244
|
-
const element = React.Children.only<$FlowFixMe>(this.props.children);
|
|
245
|
-
const children: Array<React.Node> = [element.props.children];
|
|
246
|
-
if (__DEV__) {
|
|
247
|
-
if (element.type === View) {
|
|
248
|
-
children.push(
|
|
249
|
-
<PressabilityDebugView color="brown" hitSlop={this.props.hitSlop} />
|
|
250
|
-
);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
|
255
|
-
// adopting `Pressability`, so preserve that behavior.
|
|
256
|
-
const { onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus } =
|
|
257
|
-
this.state.pressability.getEventHandlers();
|
|
258
|
-
|
|
259
|
-
let _accessibilityState = {
|
|
260
|
-
busy: this.props["aria-busy"] ?? this.props.accessibilityState?.busy,
|
|
261
|
-
checked:
|
|
262
|
-
this.props["aria-checked"] ?? this.props.accessibilityState?.checked,
|
|
263
|
-
disabled:
|
|
264
|
-
this.props["aria-disabled"] ?? this.props.accessibilityState?.disabled,
|
|
265
|
-
expanded:
|
|
266
|
-
this.props["aria-expanded"] ?? this.props.accessibilityState?.expanded,
|
|
267
|
-
selected:
|
|
268
|
-
this.props["aria-selected"] ?? this.props.accessibilityState?.selected,
|
|
269
|
-
};
|
|
270
|
-
|
|
271
|
-
_accessibilityState =
|
|
272
|
-
this.props.disabled != null
|
|
273
|
-
? {
|
|
274
|
-
..._accessibilityState,
|
|
275
|
-
disabled: this.props.disabled,
|
|
276
|
-
}
|
|
277
|
-
: _accessibilityState;
|
|
278
|
-
|
|
279
|
-
const accessibilityValue = {
|
|
280
|
-
max: this.props["aria-valuemax"] ?? this.props.accessibilityValue?.max,
|
|
281
|
-
min: this.props["aria-valuemin"] ?? this.props.accessibilityValue?.min,
|
|
282
|
-
now: this.props["aria-valuenow"] ?? this.props.accessibilityValue?.now,
|
|
283
|
-
text: this.props["aria-valuetext"] ?? this.props.accessibilityValue?.text,
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const accessibilityLiveRegion =
|
|
287
|
-
this.props["aria-live"] === "off"
|
|
288
|
-
? "none"
|
|
289
|
-
: this.props["aria-live"] ?? this.props.accessibilityLiveRegion;
|
|
290
|
-
|
|
291
|
-
const accessibilityLabel =
|
|
292
|
-
this.props["aria-label"] ?? this.props.accessibilityLabel;
|
|
293
|
-
return React.cloneElement(
|
|
294
|
-
element,
|
|
295
|
-
{
|
|
296
|
-
...eventHandlersWithoutBlurAndFocus,
|
|
297
|
-
...getBackgroundProp(
|
|
298
|
-
this.props.background === undefined
|
|
299
|
-
? TouchableNativeFeedback.SelectableBackground()
|
|
300
|
-
: this.props.background,
|
|
301
|
-
this.props.useForeground === true
|
|
302
|
-
),
|
|
303
|
-
accessible: this.props.accessible !== false,
|
|
304
|
-
accessibilityHint: this.props.accessibilityHint,
|
|
305
|
-
accessibilityLanguage: this.props.accessibilityLanguage,
|
|
306
|
-
accessibilityLabel: accessibilityLabel,
|
|
307
|
-
accessibilityRole: this.props.accessibilityRole,
|
|
308
|
-
accessibilityState: _accessibilityState,
|
|
309
|
-
accessibilityActions: this.props.accessibilityActions,
|
|
310
|
-
onAccessibilityAction: this.props.onAccessibilityAction,
|
|
311
|
-
accessibilityValue: accessibilityValue,
|
|
312
|
-
importantForAccessibility:
|
|
313
|
-
this.props["aria-hidden"] === true
|
|
314
|
-
? "no-hide-descendants"
|
|
315
|
-
: this.props.importantForAccessibility,
|
|
316
|
-
accessibilityViewIsModal:
|
|
317
|
-
this.props["aria-modal"] ?? this.props.accessibilityViewIsModal,
|
|
318
|
-
accessibilityLiveRegion: accessibilityLiveRegion,
|
|
319
|
-
accessibilityElementsHidden:
|
|
320
|
-
this.props["aria-hidden"] ?? this.props.accessibilityElementsHidden,
|
|
321
|
-
hasTVPreferredFocus: this.props.hasTVPreferredFocus,
|
|
322
|
-
hitSlop: this.props.hitSlop,
|
|
323
|
-
focusable:
|
|
324
|
-
this.props.focusable !== false &&
|
|
325
|
-
this.props.onPress !== undefined &&
|
|
326
|
-
!this.props.disabled,
|
|
327
|
-
nativeID: this.props.nativeID,
|
|
328
|
-
nextFocusDown: this.props.nextFocusDown,
|
|
329
|
-
nextFocusForward: this.props.nextFocusForward,
|
|
330
|
-
nextFocusLeft: this.props.nextFocusLeft,
|
|
331
|
-
nextFocusRight: this.props.nextFocusRight,
|
|
332
|
-
nextFocusUp: this.props.nextFocusUp,
|
|
333
|
-
onLayout: this.props.onLayout,
|
|
334
|
-
testID: this.props.testID,
|
|
335
|
-
collapsable: false, // RNOH: patch
|
|
336
|
-
},
|
|
337
|
-
...children
|
|
338
|
-
);
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
componentDidUpdate(prevProps: Props, prevState: State) {
|
|
342
|
-
this.state.pressability.configure(this._createPressabilityConfig());
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
componentWillUnmount(): void {
|
|
346
|
-
this.state.pressability.reset();
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const getBackgroundProp =
|
|
351
|
-
Platform.OS === "android"
|
|
352
|
-
? /* $FlowFixMe[missing-local-annot] The type annotation(s) required by
|
|
353
|
-
* Flow's LTI update could not be added via codemod */
|
|
354
|
-
(background, useForeground: boolean) =>
|
|
355
|
-
useForeground && TouchableNativeFeedback.canUseNativeForeground()
|
|
356
|
-
? { nativeForegroundAndroid: background }
|
|
357
|
-
: { nativeBackgroundAndroid: background }
|
|
358
|
-
: /* $FlowFixMe[missing-local-annot] The type annotation(s) required by
|
|
359
|
-
* Flow's LTI update could not be added via codemod */
|
|
360
|
-
(background, useForeground: boolean) => null;
|
|
361
|
-
|
|
362
|
-
TouchableNativeFeedback.displayName = "TouchableNativeFeedback";
|
|
363
|
-
|
|
364
|
-
module.exports = TouchableNativeFeedback;
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Meta Platforms, Inc. and 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
|
-
// RNOH patch: disable view flattening
|
|
12
|
-
|
|
13
|
-
import type {
|
|
14
|
-
AccessibilityActionEvent,
|
|
15
|
-
AccessibilityActionInfo,
|
|
16
|
-
AccessibilityRole,
|
|
17
|
-
AccessibilityState,
|
|
18
|
-
AccessibilityValue,
|
|
19
|
-
} from "react-native/Libraries/Components/View/ViewAccessibility";
|
|
20
|
-
import type { EdgeInsetsOrSizeProp } from "react-native/Libraries/StyleSheet/EdgeInsetsPropType";
|
|
21
|
-
import type {
|
|
22
|
-
BlurEvent,
|
|
23
|
-
FocusEvent,
|
|
24
|
-
LayoutEvent,
|
|
25
|
-
PressEvent,
|
|
26
|
-
} from "react-native/Libraries/Types/CoreEventTypes";
|
|
27
|
-
|
|
28
|
-
import View from "react-native/Libraries/Components/View/View";
|
|
29
|
-
import Pressability, {
|
|
30
|
-
type PressabilityConfig,
|
|
31
|
-
} from "react-native/Libraries/Pressability/Pressability";
|
|
32
|
-
import { PressabilityDebugView } from "react-native/Libraries/Pressability/PressabilityDebug";
|
|
33
|
-
import * as React from "react";
|
|
34
|
-
|
|
35
|
-
type Props = $ReadOnly<{|
|
|
36
|
-
accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
|
|
37
|
-
accessibilityElementsHidden?: ?boolean,
|
|
38
|
-
accessibilityHint?: ?Stringish,
|
|
39
|
-
accessibilityLanguage?: ?Stringish,
|
|
40
|
-
accessibilityIgnoresInvertColors?: ?boolean,
|
|
41
|
-
accessibilityLabel?: ?Stringish,
|
|
42
|
-
accessibilityLiveRegion?: ?("none" | "polite" | "assertive"),
|
|
43
|
-
accessibilityRole?: ?AccessibilityRole,
|
|
44
|
-
accessibilityState?: ?AccessibilityState,
|
|
45
|
-
accessibilityValue?: ?AccessibilityValue,
|
|
46
|
-
"aria-valuemax"?: AccessibilityValue["max"],
|
|
47
|
-
"aria-valuemin"?: AccessibilityValue["min"],
|
|
48
|
-
"aria-valuenow"?: AccessibilityValue["now"],
|
|
49
|
-
"aria-valuetext"?: AccessibilityValue["text"],
|
|
50
|
-
accessibilityViewIsModal?: ?boolean,
|
|
51
|
-
"aria-modal"?: ?boolean,
|
|
52
|
-
accessible?: ?boolean,
|
|
53
|
-
/**
|
|
54
|
-
* alias for accessibilityState
|
|
55
|
-
*
|
|
56
|
-
* see https://reactnative.dev/docs/accessibility#accessibilitystate
|
|
57
|
-
*/
|
|
58
|
-
"aria-busy"?: ?boolean,
|
|
59
|
-
"aria-checked"?: ?boolean | "mixed",
|
|
60
|
-
"aria-disabled"?: ?boolean,
|
|
61
|
-
"aria-expanded"?: ?boolean,
|
|
62
|
-
"aria-selected"?: ?boolean,
|
|
63
|
-
"aria-hidden"?: ?boolean,
|
|
64
|
-
"aria-live"?: ?("polite" | "assertive" | "off"),
|
|
65
|
-
"aria-label"?: ?Stringish,
|
|
66
|
-
children?: ?React.Node,
|
|
67
|
-
delayLongPress?: ?number,
|
|
68
|
-
delayPressIn?: ?number,
|
|
69
|
-
delayPressOut?: ?number,
|
|
70
|
-
disabled?: ?boolean,
|
|
71
|
-
focusable?: ?boolean,
|
|
72
|
-
hitSlop?: ?EdgeInsetsOrSizeProp,
|
|
73
|
-
id?: string,
|
|
74
|
-
importantForAccessibility?: ?("auto" | "yes" | "no" | "no-hide-descendants"),
|
|
75
|
-
nativeID?: ?string,
|
|
76
|
-
onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
|
|
77
|
-
onBlur?: ?(event: BlurEvent) => mixed,
|
|
78
|
-
onFocus?: ?(event: FocusEvent) => mixed,
|
|
79
|
-
onLayout?: ?(event: LayoutEvent) => mixed,
|
|
80
|
-
onLongPress?: ?(event: PressEvent) => mixed,
|
|
81
|
-
onPress?: ?(event: PressEvent) => mixed,
|
|
82
|
-
onPressIn?: ?(event: PressEvent) => mixed,
|
|
83
|
-
onPressOut?: ?(event: PressEvent) => mixed,
|
|
84
|
-
pressRetentionOffset?: ?EdgeInsetsOrSizeProp,
|
|
85
|
-
rejectResponderTermination?: ?boolean,
|
|
86
|
-
testID?: ?string,
|
|
87
|
-
touchSoundDisabled?: ?boolean,
|
|
88
|
-
|}>;
|
|
89
|
-
|
|
90
|
-
type State = $ReadOnly<{|
|
|
91
|
-
pressability: Pressability,
|
|
92
|
-
|}>;
|
|
93
|
-
|
|
94
|
-
const PASSTHROUGH_PROPS = [
|
|
95
|
-
"accessibilityActions",
|
|
96
|
-
"accessibilityElementsHidden",
|
|
97
|
-
"accessibilityHint",
|
|
98
|
-
"accessibilityLanguage",
|
|
99
|
-
"accessibilityIgnoresInvertColors",
|
|
100
|
-
"accessibilityLabel",
|
|
101
|
-
"accessibilityLiveRegion",
|
|
102
|
-
"accessibilityRole",
|
|
103
|
-
"accessibilityValue",
|
|
104
|
-
"aria-valuemax",
|
|
105
|
-
"aria-valuemin",
|
|
106
|
-
"aria-valuenow",
|
|
107
|
-
"aria-valuetext",
|
|
108
|
-
"accessibilityViewIsModal",
|
|
109
|
-
"aria-modal",
|
|
110
|
-
"hitSlop",
|
|
111
|
-
"importantForAccessibility",
|
|
112
|
-
"nativeID",
|
|
113
|
-
"onAccessibilityAction",
|
|
114
|
-
"onBlur",
|
|
115
|
-
"onFocus",
|
|
116
|
-
"onLayout",
|
|
117
|
-
"testID",
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
class TouchableWithoutFeedback extends React.Component<Props, State> {
|
|
121
|
-
state: State = {
|
|
122
|
-
pressability: new Pressability(createPressabilityConfig(this.props)),
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
render(): React.Node {
|
|
126
|
-
const element = React.Children.only<$FlowFixMe>(this.props.children);
|
|
127
|
-
const children: Array<React.Node> = [element.props.children];
|
|
128
|
-
const ariaLive = this.props["aria-live"];
|
|
129
|
-
|
|
130
|
-
if (__DEV__) {
|
|
131
|
-
if (element.type === View) {
|
|
132
|
-
children.push(
|
|
133
|
-
<PressabilityDebugView color="red" hitSlop={this.props.hitSlop} />
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
let _accessibilityState = {
|
|
139
|
-
busy: this.props["aria-busy"] ?? this.props.accessibilityState?.busy,
|
|
140
|
-
checked:
|
|
141
|
-
this.props["aria-checked"] ?? this.props.accessibilityState?.checked,
|
|
142
|
-
disabled:
|
|
143
|
-
this.props["aria-disabled"] ?? this.props.accessibilityState?.disabled,
|
|
144
|
-
expanded:
|
|
145
|
-
this.props["aria-expanded"] ?? this.props.accessibilityState?.expanded,
|
|
146
|
-
selected:
|
|
147
|
-
this.props["aria-selected"] ?? this.props.accessibilityState?.selected,
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
|
151
|
-
// adopting `Pressability`, so preserve that behavior.
|
|
152
|
-
const { onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus } =
|
|
153
|
-
this.state.pressability.getEventHandlers();
|
|
154
|
-
|
|
155
|
-
const elementProps: { [string]: mixed, ... } = {
|
|
156
|
-
...eventHandlersWithoutBlurAndFocus,
|
|
157
|
-
accessible: this.props.accessible !== false,
|
|
158
|
-
accessibilityState:
|
|
159
|
-
this.props.disabled != null
|
|
160
|
-
? {
|
|
161
|
-
..._accessibilityState,
|
|
162
|
-
disabled: this.props.disabled,
|
|
163
|
-
}
|
|
164
|
-
: _accessibilityState,
|
|
165
|
-
focusable:
|
|
166
|
-
this.props.focusable !== false && this.props.onPress !== undefined,
|
|
167
|
-
|
|
168
|
-
accessibilityElementsHidden:
|
|
169
|
-
this.props["aria-hidden"] ?? this.props.accessibilityElementsHidden,
|
|
170
|
-
importantForAccessibility:
|
|
171
|
-
this.props["aria-hidden"] === true
|
|
172
|
-
? "no-hide-descendants"
|
|
173
|
-
: this.props.importantForAccessibility,
|
|
174
|
-
accessibilityLiveRegion:
|
|
175
|
-
ariaLive === "off"
|
|
176
|
-
? "none"
|
|
177
|
-
: ariaLive ?? this.props.accessibilityLiveRegion,
|
|
178
|
-
nativeID: this.props.id ?? this.props.nativeID,
|
|
179
|
-
collapsable: false, // RNOH: patch
|
|
180
|
-
};
|
|
181
|
-
for (const prop of PASSTHROUGH_PROPS) {
|
|
182
|
-
if (this.props[prop] !== undefined) {
|
|
183
|
-
elementProps[prop] = this.props[prop];
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return React.cloneElement(element, elementProps, ...children);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
componentDidUpdate(): void {
|
|
191
|
-
this.state.pressability.configure(createPressabilityConfig(this.props));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
componentWillUnmount(): void {
|
|
195
|
-
this.state.pressability.reset();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function createPressabilityConfig({
|
|
200
|
-
"aria-disabled": ariaDisabled,
|
|
201
|
-
...props
|
|
202
|
-
}: Props): PressabilityConfig {
|
|
203
|
-
const accessibilityStateDisabled =
|
|
204
|
-
ariaDisabled ?? props.accessibilityState?.disabled;
|
|
205
|
-
return {
|
|
206
|
-
cancelable: !props.rejectResponderTermination,
|
|
207
|
-
disabled:
|
|
208
|
-
props.disabled !== null ? props.disabled : accessibilityStateDisabled,
|
|
209
|
-
hitSlop: props.hitSlop,
|
|
210
|
-
delayLongPress: props.delayLongPress,
|
|
211
|
-
delayPressIn: props.delayPressIn,
|
|
212
|
-
delayPressOut: props.delayPressOut,
|
|
213
|
-
minPressDuration: 0,
|
|
214
|
-
pressRectOffset: props.pressRetentionOffset,
|
|
215
|
-
android_disableSound: props.touchSoundDisabled,
|
|
216
|
-
onBlur: props.onBlur,
|
|
217
|
-
onFocus: props.onFocus,
|
|
218
|
-
onLongPress: props.onLongPress,
|
|
219
|
-
onPress: props.onPress,
|
|
220
|
-
onPressIn: props.onPressIn,
|
|
221
|
-
onPressOut: props.onPressOut,
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
TouchableWithoutFeedback.displayName = "TouchableWithoutFeedback";
|
|
226
|
-
|
|
227
|
-
module.exports = TouchableWithoutFeedback;
|