@office-iss/react-native-win32 0.0.0-canary.270 → 0.0.0-canary.271
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/CHANGELOG.json +16 -1
- package/CHANGELOG.md +12 -4
- package/Libraries/Animated/animations/Animation.js +63 -24
- package/Libraries/Animated/animations/DecayAnimation.js +26 -38
- package/Libraries/Animated/animations/SpringAnimation.js +33 -39
- package/Libraries/Animated/animations/TimingAnimation.js +34 -42
- package/Libraries/Animated/createAnimatedComponent.js +46 -32
- package/Libraries/Animated/nodes/AnimatedProps.js +16 -10
- package/Libraries/Animated/nodes/AnimatedStyle.js +4 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +61 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +61 -3
- package/Libraries/Components/Button.js +6 -4
- package/Libraries/Components/Button.win32.js +9 -4
- package/Libraries/Components/ScrollView/ScrollView.js +5 -5
- package/Libraries/Components/Switch/Switch.js +8 -6
- package/Libraries/Components/TextInput/TextInput.d.ts +4 -4
- package/Libraries/Components/TextInput/TextInput.flow.js +7 -10
- package/Libraries/Components/TextInput/TextInput.js +7 -7
- package/Libraries/Components/TextInput/TextInput.win32.js +7 -7
- package/Libraries/Components/TextInput/TextInputState.js +11 -13
- package/Libraries/Components/TextInput/TextInputState.win32.js +13 -16
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
- package/Libraries/Components/View/ViewNativeComponent.js +3 -10
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpBatchedBridge.js +1 -10
- package/Libraries/Core/setUpReactDevTools.js +3 -3
- package/Libraries/Core/setUpSegmentFetcher.js +1 -0
- package/Libraries/Core/setUpTimers.js +8 -8
- package/Libraries/Image/ImageBackground.js +2 -5
- package/Libraries/Image/ImageProps.js +1 -1
- package/Libraries/Image/ImageViewNativeComponent.js +2 -2
- package/Libraries/Inspector/ReactDevToolsOverlay.js +0 -1
- package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +3 -5
- package/Libraries/JSInspector/NetworkAgent.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +1 -2
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +2 -2
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +1 -1
- package/Libraries/LogBox/UI/LogBoxMessage.js +2 -2
- package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +1 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +1 -0
- package/Libraries/Network/XMLHttpRequest.js +26 -1
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/Pressability/Pressability.js +2 -3
- package/Libraries/Pressability/Pressability.win32.js +2 -3
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -3
- package/Libraries/ReactNative/RendererImplementation.js +4 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +13 -18
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +13 -0
- package/Libraries/StyleSheet/processTransform.js +3 -34
- package/Libraries/Text/Text.js +251 -249
- package/Libraries/Text/Text.win32.js +285 -295
- package/Libraries/Types/CoreEventTypes.d.ts +3 -10
- package/Libraries/Types/CoreEventTypes.js +4 -6
- package/Libraries/Types/CoreEventTypes.win32.js +4 -6
- package/Libraries/Utilities/Platform.flow.js +2 -2
- package/Libraries/Utilities/Platform.flow.win32.js +2 -2
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +5 -4
- package/index.js +5 -2
- package/index.win32.js +5 -2
- package/jest/setup.js +30 -0
- package/overrides.json +18 -17
- package/package.json +13 -13
- package/src/private/animated/NativeAnimatedHelper.js +2 -4
- package/src/private/animated/NativeAnimatedHelper.win32.js +2 -3
- package/src/private/components/HScrollViewNativeComponents.js +4 -5
- package/src/private/{fusebox → debugging}/setUpFuseboxReactDevToolsDispatcher.js +6 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +14 -23
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -5
- package/src/private/specs/modules/NativeAccessibilityInfo.js +3 -0
- package/src/private/specs/modules/NativeAccessibilityInfoWin32.js +3 -0
- package/src/private/specs/modules/NativeAccessibilityManager.js +4 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -3
- package/src/private/webapis/performance/EventTiming.js +13 -8
- package/src/private/webapis/performance/Performance.js +30 -40
- package/src/private/webapis/performance/PerformanceEntry.js +2 -5
- package/src/private/webapis/performance/PerformanceObserver.js +20 -32
- package/src/private/webapis/performance/RawPerformanceEntry.js +1 -1
- package/src/private/webapis/performance/UserTiming.js +6 -2
- package/src/private/webapis/performance/Utilities.js +0 -7
- package/src/private/webapis/performance/specs/NativePerformance.js +53 -0
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +247 -0
- package/src-win/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
- package/types/public/ReactNativeTypes.d.ts +4 -4
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +0 -69
- package/src/private/webapis/performance/specs/__mocks__/NativePerformance.js +0 -69
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +0 -154
- /package/src/private/{fusebox → debugging}/FuseboxSessionObserver.js +0 -0
- /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.android.js +0 -0
- /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.ios.js +0 -0
- /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.win32.js +0 -0
package/Libraries/Text/Text.js
CHANGED
|
@@ -33,231 +33,156 @@ type TextForwardRef = React.ElementRef<
|
|
|
33
33
|
*
|
|
34
34
|
* @see https://reactnative.dev/docs/text
|
|
35
35
|
*/
|
|
36
|
-
const Text:
|
|
37
|
-
React.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
36
|
+
const Text: component(
|
|
37
|
+
ref: React.RefSetter<TextForwardRef>,
|
|
38
|
+
...props: TextProps
|
|
39
|
+
) = React.forwardRef(
|
|
40
|
+
(
|
|
41
|
+
{
|
|
42
|
+
accessible,
|
|
43
|
+
accessibilityLabel,
|
|
44
|
+
accessibilityState,
|
|
45
|
+
allowFontScaling,
|
|
46
|
+
'aria-busy': ariaBusy,
|
|
47
|
+
'aria-checked': ariaChecked,
|
|
48
|
+
'aria-disabled': ariaDisabled,
|
|
49
|
+
'aria-expanded': ariaExpanded,
|
|
50
|
+
'aria-label': ariaLabel,
|
|
51
|
+
'aria-selected': ariaSelected,
|
|
52
|
+
children,
|
|
53
|
+
ellipsizeMode,
|
|
54
|
+
disabled,
|
|
55
|
+
id,
|
|
56
|
+
nativeID,
|
|
57
|
+
numberOfLines,
|
|
58
|
+
onLongPress,
|
|
59
|
+
onPress,
|
|
60
|
+
onPressIn,
|
|
61
|
+
onPressOut,
|
|
62
|
+
onResponderGrant,
|
|
63
|
+
onResponderMove,
|
|
64
|
+
onResponderRelease,
|
|
65
|
+
onResponderTerminate,
|
|
66
|
+
onResponderTerminationRequest,
|
|
67
|
+
onStartShouldSetResponder,
|
|
68
|
+
pressRetentionOffset,
|
|
69
|
+
selectable,
|
|
70
|
+
selectionColor,
|
|
71
|
+
suppressHighlighting,
|
|
72
|
+
style,
|
|
73
|
+
...restProps
|
|
74
|
+
}: TextProps,
|
|
75
|
+
forwardedRef,
|
|
76
|
+
) => {
|
|
77
|
+
const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
|
|
78
|
+
|
|
79
|
+
let _accessibilityState: ?TextProps['accessibilityState'] =
|
|
80
|
+
accessibilityState;
|
|
81
|
+
if (
|
|
82
|
+
ariaBusy != null ||
|
|
83
|
+
ariaChecked != null ||
|
|
84
|
+
ariaDisabled != null ||
|
|
85
|
+
ariaExpanded != null ||
|
|
86
|
+
ariaSelected != null
|
|
87
|
+
) {
|
|
88
|
+
if (_accessibilityState != null) {
|
|
89
|
+
_accessibilityState = {
|
|
90
|
+
busy: ariaBusy ?? _accessibilityState.busy,
|
|
91
|
+
checked: ariaChecked ?? _accessibilityState.checked,
|
|
92
|
+
disabled: ariaDisabled ?? _accessibilityState.disabled,
|
|
93
|
+
expanded: ariaExpanded ?? _accessibilityState.expanded,
|
|
94
|
+
selected: ariaSelected ?? _accessibilityState.selected,
|
|
95
|
+
};
|
|
96
|
+
} else {
|
|
97
|
+
_accessibilityState = {
|
|
98
|
+
busy: ariaBusy,
|
|
99
|
+
checked: ariaChecked,
|
|
100
|
+
disabled: ariaDisabled,
|
|
101
|
+
expanded: ariaExpanded,
|
|
102
|
+
selected: ariaSelected,
|
|
103
|
+
};
|
|
103
104
|
}
|
|
105
|
+
}
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
const _accessibilityStateDisabled = _accessibilityState?.disabled;
|
|
108
|
+
const _disabled = disabled ?? _accessibilityStateDisabled;
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const isPressable =
|
|
111
|
+
(onPress != null ||
|
|
112
|
+
onLongPress != null ||
|
|
113
|
+
onStartShouldSetResponder != null) &&
|
|
114
|
+
_disabled !== true;
|
|
113
115
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
116
|
+
// TODO: Move this processing to the view configuration.
|
|
117
|
+
const _selectionColor =
|
|
118
|
+
selectionColor == null ? null : processColor(selectionColor);
|
|
117
119
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
120
|
+
let _style = style;
|
|
121
|
+
if (__DEV__) {
|
|
122
|
+
if (PressabilityDebug.isEnabled() && onPress != null) {
|
|
123
|
+
_style = [style, {color: 'magenta'}];
|
|
123
124
|
}
|
|
125
|
+
}
|
|
124
126
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
_numberOfLines = 0;
|
|
127
|
+
let _numberOfLines = numberOfLines;
|
|
128
|
+
if (_numberOfLines != null && !(_numberOfLines >= 0)) {
|
|
129
|
+
if (__DEV__) {
|
|
130
|
+
console.error(
|
|
131
|
+
`'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
|
|
132
|
+
);
|
|
133
133
|
}
|
|
134
|
+
_numberOfLines = 0;
|
|
135
|
+
}
|
|
134
136
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
138
|
-
if (processedStyle != null) {
|
|
139
|
-
let overrides: ?{...TextStyleInternal} = null;
|
|
140
|
-
if (typeof processedStyle.fontWeight === 'number') {
|
|
141
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
142
|
-
overrides.fontWeight =
|
|
143
|
-
// $FlowFixMe[incompatible-cast]
|
|
144
|
-
(processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (processedStyle.userSelect != null) {
|
|
148
|
-
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
149
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
150
|
-
overrides.userSelect = undefined;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (processedStyle.verticalAlign != null) {
|
|
154
|
-
overrides = overrides || ({}: {...TextStyleInternal});
|
|
155
|
-
overrides.textAlignVertical =
|
|
156
|
-
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
157
|
-
overrides.verticalAlign = undefined;
|
|
158
|
-
}
|
|
137
|
+
let _selectable = selectable;
|
|
159
138
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
139
|
+
let processedStyle = flattenStyle<TextStyleProp>(_style);
|
|
140
|
+
if (processedStyle != null) {
|
|
141
|
+
let overrides: ?{...TextStyleInternal} = null;
|
|
142
|
+
if (typeof processedStyle.fontWeight === 'number') {
|
|
143
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
144
|
+
overrides.fontWeight =
|
|
145
|
+
// $FlowFixMe[incompatible-cast]
|
|
146
|
+
(processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
|
|
164
147
|
}
|
|
165
148
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<NativePressableVirtualText
|
|
173
|
-
ref={forwardedRef}
|
|
174
|
-
textProps={{
|
|
175
|
-
...restProps,
|
|
176
|
-
accessibilityLabel: _accessibilityLabel,
|
|
177
|
-
accessibilityState: _accessibilityState,
|
|
178
|
-
nativeID: _nativeID,
|
|
179
|
-
numberOfLines: _numberOfLines,
|
|
180
|
-
selectable: _selectable,
|
|
181
|
-
selectionColor: _selectionColor,
|
|
182
|
-
style: _style,
|
|
183
|
-
disabled: disabled,
|
|
184
|
-
children,
|
|
185
|
-
}}
|
|
186
|
-
textPressabilityProps={{
|
|
187
|
-
onLongPress,
|
|
188
|
-
onPress,
|
|
189
|
-
onPressIn,
|
|
190
|
-
onPressOut,
|
|
191
|
-
onResponderGrant,
|
|
192
|
-
onResponderMove,
|
|
193
|
-
onResponderRelease,
|
|
194
|
-
onResponderTerminate,
|
|
195
|
-
onResponderTerminationRequest,
|
|
196
|
-
onStartShouldSetResponder,
|
|
197
|
-
pressRetentionOffset,
|
|
198
|
-
suppressHighlighting,
|
|
199
|
-
}}
|
|
200
|
-
/>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
149
|
+
if (processedStyle.userSelect != null) {
|
|
150
|
+
_selectable = userSelectToSelectableMap[processedStyle.userSelect];
|
|
151
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
152
|
+
overrides.userSelect = undefined;
|
|
153
|
+
}
|
|
203
154
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
isHighlighted={false}
|
|
210
|
-
isPressable={false}
|
|
211
|
-
nativeID={_nativeID}
|
|
212
|
-
numberOfLines={_numberOfLines}
|
|
213
|
-
ref={forwardedRef}
|
|
214
|
-
selectable={_selectable}
|
|
215
|
-
selectionColor={_selectionColor}
|
|
216
|
-
style={_style}
|
|
217
|
-
disabled={disabled}>
|
|
218
|
-
{children}
|
|
219
|
-
</NativeVirtualText>
|
|
220
|
-
);
|
|
155
|
+
if (processedStyle.verticalAlign != null) {
|
|
156
|
+
overrides = overrides || ({}: {...TextStyleInternal});
|
|
157
|
+
overrides.textAlignVertical =
|
|
158
|
+
verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
|
|
159
|
+
overrides.verticalAlign = undefined;
|
|
221
160
|
}
|
|
222
161
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
_disabled !== _accessibilityStateDisabled &&
|
|
227
|
-
((_disabled != null && _disabled !== false) ||
|
|
228
|
-
(_accessibilityStateDisabled != null &&
|
|
229
|
-
_accessibilityStateDisabled !== false))
|
|
230
|
-
) {
|
|
231
|
-
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
162
|
+
if (overrides != null) {
|
|
163
|
+
// $FlowFixMe[incompatible-type]
|
|
164
|
+
_style = [_style, overrides];
|
|
232
165
|
}
|
|
166
|
+
}
|
|
233
167
|
|
|
234
|
-
|
|
235
|
-
ios: accessible !== false,
|
|
236
|
-
android:
|
|
237
|
-
accessible == null
|
|
238
|
-
? onPress != null || onLongPress != null
|
|
239
|
-
: accessible,
|
|
240
|
-
default: accessible,
|
|
241
|
-
});
|
|
168
|
+
const _nativeID = id ?? nativeID;
|
|
242
169
|
|
|
243
|
-
|
|
170
|
+
const hasTextAncestor = useContext(TextAncestor);
|
|
171
|
+
if (hasTextAncestor) {
|
|
244
172
|
if (isPressable) {
|
|
245
|
-
|
|
246
|
-
<
|
|
173
|
+
return (
|
|
174
|
+
<NativePressableVirtualText
|
|
247
175
|
ref={forwardedRef}
|
|
248
176
|
textProps={{
|
|
249
177
|
...restProps,
|
|
250
178
|
accessibilityLabel: _accessibilityLabel,
|
|
251
179
|
accessibilityState: _accessibilityState,
|
|
252
|
-
accessible: _accessible,
|
|
253
|
-
allowFontScaling: allowFontScaling !== false,
|
|
254
|
-
disabled: _disabled,
|
|
255
|
-
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
256
180
|
nativeID: _nativeID,
|
|
257
181
|
numberOfLines: _numberOfLines,
|
|
258
182
|
selectable: _selectable,
|
|
259
183
|
selectionColor: _selectionColor,
|
|
260
184
|
style: _style,
|
|
185
|
+
disabled: disabled,
|
|
261
186
|
children,
|
|
262
187
|
}}
|
|
263
188
|
textPressabilityProps={{
|
|
@@ -276,58 +201,135 @@ const Text: React.AbstractComponent<TextProps, TextForwardRef> =
|
|
|
276
201
|
}}
|
|
277
202
|
/>
|
|
278
203
|
);
|
|
279
|
-
} else {
|
|
280
|
-
nativeText = (
|
|
281
|
-
<NativeText
|
|
282
|
-
{...restProps}
|
|
283
|
-
accessibilityLabel={_accessibilityLabel}
|
|
284
|
-
accessibilityState={_accessibilityState}
|
|
285
|
-
accessible={_accessible}
|
|
286
|
-
allowFontScaling={allowFontScaling !== false}
|
|
287
|
-
disabled={_disabled}
|
|
288
|
-
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
289
|
-
isHighlighted={false}
|
|
290
|
-
nativeID={_nativeID}
|
|
291
|
-
numberOfLines={_numberOfLines}
|
|
292
|
-
ref={forwardedRef}
|
|
293
|
-
selectable={_selectable}
|
|
294
|
-
selectionColor={_selectionColor}
|
|
295
|
-
style={_style}>
|
|
296
|
-
{children}
|
|
297
|
-
</NativeText>
|
|
298
|
-
);
|
|
299
204
|
}
|
|
300
205
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
206
|
+
return (
|
|
207
|
+
<NativeVirtualText
|
|
208
|
+
{...restProps}
|
|
209
|
+
accessibilityLabel={_accessibilityLabel}
|
|
210
|
+
accessibilityState={_accessibilityState}
|
|
211
|
+
isHighlighted={false}
|
|
212
|
+
isPressable={false}
|
|
213
|
+
nativeID={_nativeID}
|
|
214
|
+
numberOfLines={_numberOfLines}
|
|
215
|
+
ref={forwardedRef}
|
|
216
|
+
selectable={_selectable}
|
|
217
|
+
selectionColor={_selectionColor}
|
|
218
|
+
style={_style}
|
|
219
|
+
disabled={disabled}>
|
|
220
|
+
{children}
|
|
221
|
+
</NativeVirtualText>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
304
224
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
225
|
+
// If the disabled prop and accessibilityState.disabled are out of sync but not both in
|
|
226
|
+
// falsy states we need to update the accessibilityState object to use the disabled prop.
|
|
227
|
+
if (
|
|
228
|
+
_disabled !== _accessibilityStateDisabled &&
|
|
229
|
+
((_disabled != null && _disabled !== false) ||
|
|
230
|
+
(_accessibilityStateDisabled != null &&
|
|
231
|
+
_accessibilityStateDisabled !== false))
|
|
232
|
+
) {
|
|
233
|
+
_accessibilityState = {..._accessibilityState, disabled: _disabled};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const _accessible = Platform.select({
|
|
237
|
+
ios: accessible !== false,
|
|
238
|
+
android:
|
|
239
|
+
accessible == null
|
|
240
|
+
? onPress != null || onLongPress != null
|
|
241
|
+
: accessible,
|
|
242
|
+
default: accessible,
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
let nativeText = null;
|
|
246
|
+
if (isPressable) {
|
|
247
|
+
nativeText = (
|
|
248
|
+
<NativePressableText
|
|
249
|
+
ref={forwardedRef}
|
|
250
|
+
textProps={{
|
|
251
|
+
...restProps,
|
|
252
|
+
accessibilityLabel: _accessibilityLabel,
|
|
253
|
+
accessibilityState: _accessibilityState,
|
|
254
|
+
accessible: _accessible,
|
|
255
|
+
allowFontScaling: allowFontScaling !== false,
|
|
256
|
+
disabled: _disabled,
|
|
257
|
+
ellipsizeMode: ellipsizeMode ?? 'tail',
|
|
258
|
+
nativeID: _nativeID,
|
|
259
|
+
numberOfLines: _numberOfLines,
|
|
260
|
+
selectable: _selectable,
|
|
261
|
+
selectionColor: _selectionColor,
|
|
262
|
+
style: _style,
|
|
263
|
+
children,
|
|
264
|
+
}}
|
|
265
|
+
textPressabilityProps={{
|
|
266
|
+
onLongPress,
|
|
267
|
+
onPress,
|
|
268
|
+
onPressIn,
|
|
269
|
+
onPressOut,
|
|
270
|
+
onResponderGrant,
|
|
271
|
+
onResponderMove,
|
|
272
|
+
onResponderRelease,
|
|
273
|
+
onResponderTerminate,
|
|
274
|
+
onResponderTerminationRequest,
|
|
275
|
+
onStartShouldSetResponder,
|
|
276
|
+
pressRetentionOffset,
|
|
277
|
+
suppressHighlighting,
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
);
|
|
281
|
+
} else {
|
|
282
|
+
nativeText = (
|
|
283
|
+
<NativeText
|
|
284
|
+
{...restProps}
|
|
285
|
+
accessibilityLabel={_accessibilityLabel}
|
|
286
|
+
accessibilityState={_accessibilityState}
|
|
287
|
+
accessible={_accessible}
|
|
288
|
+
allowFontScaling={allowFontScaling !== false}
|
|
289
|
+
disabled={_disabled}
|
|
290
|
+
ellipsizeMode={ellipsizeMode ?? 'tail'}
|
|
291
|
+
isHighlighted={false}
|
|
292
|
+
nativeID={_nativeID}
|
|
293
|
+
numberOfLines={_numberOfLines}
|
|
294
|
+
ref={forwardedRef}
|
|
295
|
+
selectable={_selectable}
|
|
296
|
+
selectionColor={_selectionColor}
|
|
297
|
+
style={_style}>
|
|
298
|
+
{children}
|
|
299
|
+
</NativeText>
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (children == null) {
|
|
304
|
+
return nativeText;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// If the children do not contain a JSX element it would not be possible to have a
|
|
308
|
+
// nested `Text` component so we can skip adding the `TextAncestor` context wrapper
|
|
309
|
+
// which has a performance overhead. Since we do this for performance reasons we need
|
|
310
|
+
// to keep the check simple to avoid regressing overall perf. For this reason the
|
|
311
|
+
// `children.length` constant is set to `3`, this should be a reasonable tradeoff
|
|
312
|
+
// to capture the majority of `Text` uses but also not make this check too expensive.
|
|
313
|
+
if (Array.isArray(children) && children.length <= 3) {
|
|
314
|
+
let hasNonTextChild = false;
|
|
315
|
+
for (let child of children) {
|
|
316
|
+
if (child != null && typeof child === 'object') {
|
|
317
|
+
hasNonTextChild = true;
|
|
318
|
+
break;
|
|
321
319
|
}
|
|
322
|
-
}
|
|
320
|
+
}
|
|
321
|
+
if (!hasNonTextChild) {
|
|
323
322
|
return nativeText;
|
|
324
323
|
}
|
|
324
|
+
} else if (typeof children !== 'object') {
|
|
325
|
+
return nativeText;
|
|
326
|
+
}
|
|
325
327
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
328
|
+
return (
|
|
329
|
+
<TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
|
|
330
|
+
);
|
|
331
|
+
},
|
|
332
|
+
);
|
|
331
333
|
|
|
332
334
|
Text.displayName = 'Text';
|
|
333
335
|
|
|
@@ -476,10 +478,10 @@ type NativePressableTextProps = $ReadOnly<{
|
|
|
476
478
|
* This logic is split out from the main Text component to enable the more
|
|
477
479
|
* expensive pressability logic to be only initialized when needed.
|
|
478
480
|
*/
|
|
479
|
-
const NativePressableVirtualText:
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
481
|
+
const NativePressableVirtualText: component(
|
|
482
|
+
ref: React.RefSetter<TextForwardRef>,
|
|
483
|
+
...props: NativePressableTextProps
|
|
484
|
+
) = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
|
|
483
485
|
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
484
486
|
textPressabilityProps,
|
|
485
487
|
);
|
|
@@ -501,10 +503,10 @@ const NativePressableVirtualText: React.AbstractComponent<
|
|
|
501
503
|
* This logic is split out from the main Text component to enable the more
|
|
502
504
|
* expensive pressability logic to be only initialized when needed.
|
|
503
505
|
*/
|
|
504
|
-
const NativePressableText:
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
506
|
+
const NativePressableText: component(
|
|
507
|
+
ref: React.RefSetter<TextForwardRef>,
|
|
508
|
+
...props: NativePressableTextProps
|
|
509
|
+
) = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
|
|
508
510
|
const [isHighlighted, eventHandlersForText] = useTextPressability(
|
|
509
511
|
textPressabilityProps,
|
|
510
512
|
);
|