@office-iss/react-native-win32 0.0.0-canary.295 → 0.0.0-canary.297

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.
Files changed (143) hide show
  1. package/.flowconfig +3 -1
  2. package/CHANGELOG.json +37 -1
  3. package/CHANGELOG.md +25 -8
  4. package/Libraries/Animated/Animated.js +0 -1
  5. package/Libraries/Animated/Animated.js.flow +0 -1
  6. package/Libraries/Animated/AnimatedExports.js +0 -1
  7. package/Libraries/Animated/AnimatedExports.js.flow +1 -2
  8. package/Libraries/Animated/animations/Animation.js +5 -2
  9. package/Libraries/Animated/components/AnimatedScrollView.js +53 -52
  10. package/Libraries/Animated/createAnimatedComponent.js +37 -33
  11. package/Libraries/Animated/nodes/AnimatedObject.js +2 -3
  12. package/Libraries/Animated/nodes/AnimatedProps.js +1 -1
  13. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +6 -1
  14. package/Libraries/AppState/AppState.js +6 -1
  15. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +19 -18
  16. package/Libraries/Components/Button.js +2 -2
  17. package/Libraries/Components/Button.win32.js +2 -2
  18. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +2 -3
  19. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +2 -1
  20. package/Libraries/Components/LayoutConformance/LayoutConformance.js +0 -1
  21. package/Libraries/Components/Pressable/Pressable.js +9 -6
  22. package/Libraries/Components/Pressable/Pressable.win32.js +9 -6
  23. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +14 -13
  24. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +13 -1
  25. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +29 -20
  26. package/Libraries/Components/ScrollView/ScrollView.d.ts +9 -5
  27. package/Libraries/Components/ScrollView/ScrollView.js +18 -12
  28. package/Libraries/Components/ScrollView/ScrollViewContext.js +2 -1
  29. package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +1 -1
  30. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +19 -6
  31. package/Libraries/Components/Switch/Switch.js +8 -2
  32. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +1 -5
  33. package/Libraries/Components/TextInput/TextInput.flow.js +1 -5
  34. package/Libraries/Components/TextInput/TextInput.flow.win32.js +1 -5
  35. package/Libraries/Components/TextInput/TextInput.js +26 -25
  36. package/Libraries/Components/TextInput/TextInput.win32.js +27 -25
  37. package/Libraries/Components/Touchable/TouchableBounce.js +9 -3
  38. package/Libraries/Components/Touchable/TouchableHighlight.js +9 -4
  39. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -1
  40. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +2 -0
  41. package/Libraries/Components/Touchable/TouchableOpacity.js +7 -3
  42. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
  43. package/Libraries/Components/View/View.js +111 -25
  44. package/Libraries/Components/View/ViewAccessibility.d.ts +1 -0
  45. package/Libraries/Core/Devtools/loadBundleFromServer.js +49 -7
  46. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +49 -7
  47. package/Libraries/Core/InitializeCore.js +1 -22
  48. package/Libraries/Core/ReactNativeVersion.js +3 -2
  49. package/Libraries/Debugging/DebuggingOverlay.js +6 -8
  50. package/Libraries/Debugging/DebuggingOverlayRegistry.js +0 -1
  51. package/Libraries/Debugging/useSubscribeToDebuggingOverlayRegistry.js +0 -1
  52. package/Libraries/EventEmitter/NativeEventEmitter.js +1 -1
  53. package/Libraries/Image/AssetRegistry.js +4 -10
  54. package/Libraries/Image/AssetSourceResolver.js +17 -4
  55. package/Libraries/Image/Image.android.js +112 -106
  56. package/Libraries/Image/Image.ios.js +10 -2
  57. package/Libraries/Image/Image.win32.js +11 -3
  58. package/Libraries/Image/ImageAnalyticsTagContext.js +2 -2
  59. package/Libraries/Image/RelativeImageStub.js +1 -0
  60. package/Libraries/Lists/FlatList.d.ts +9 -5
  61. package/Libraries/Lists/FlatList.js +1 -1
  62. package/Libraries/Lists/SectionListModern.js +9 -3
  63. package/Libraries/LogBox/UI/LogBoxButton.js +2 -1
  64. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +2 -1
  65. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +2 -1
  66. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +3 -2
  67. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +3 -2
  68. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +2 -1
  69. package/Libraries/ReactNative/AppContainer-dev.js +4 -4
  70. package/Libraries/ReactNative/AppContainer-prod.js +0 -1
  71. package/Libraries/ReactNative/RootTag.js +2 -2
  72. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -0
  73. package/Libraries/Renderer/shims/ReactNativeTypes.js +21 -25
  74. package/Libraries/Renderer/shims/ReactNativeTypes.win32.js +270 -0
  75. package/Libraries/StyleSheet/StyleSheetExports.js.flow +3 -1
  76. package/Libraries/StyleSheet/StyleSheetTypes.js +4 -3
  77. package/Libraries/StyleSheet/private/_TransformStyle.js +49 -21
  78. package/Libraries/StyleSheet/processBoxShadow.js +0 -1
  79. package/Libraries/StyleSheet/processFilter.js +0 -1
  80. package/Libraries/Text/Text.d.ts +7 -0
  81. package/Libraries/Text/Text.js +255 -244
  82. package/Libraries/Text/Text.win32.js +293 -284
  83. package/Libraries/Text/TextAncestor.js +3 -2
  84. package/Libraries/Text/TextProps.js +2 -34
  85. package/Libraries/Text/TextProps.win32.js +2 -33
  86. package/Libraries/Types/ReactDevToolsTypes.js +0 -1
  87. package/Libraries/Utilities/PerformanceLoggerContext.js +2 -2
  88. package/Libraries/Utilities/PlatformTypes.js +1 -1
  89. package/Libraries/vendor/core/ErrorUtils.js +28 -4
  90. package/index.js +0 -1
  91. package/jest/mockNativeComponent.js +2 -1
  92. package/jest/renderer.js +0 -1
  93. package/jest/resolver.js +31 -0
  94. package/jest/setup.js +1 -1
  95. package/overrides.json +27 -20
  96. package/package.json +13 -13
  97. package/src/private/animated/NativeAnimatedHelper.js +6 -1
  98. package/src/private/animated/NativeAnimatedHelper.win32.js +6 -1
  99. package/src/private/animated/createAnimatedPropsHook.js +11 -4
  100. package/src/private/animated/createAnimatedPropsMemoHook.js +0 -1
  101. package/src/private/components/safeareaview/SafeAreaView_INTERNAL_DO_NOT_USE.js +0 -1
  102. package/src/private/components/scrollview/HScrollViewNativeComponents.js +0 -1
  103. package/src/private/components/scrollview/VScrollViewNativeComponents.js +0 -1
  104. package/src/private/devsupport/rndevtools/FuseboxSessionObserver.js +0 -1
  105. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.android.js +8 -9
  106. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.ios.js +12 -15
  107. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.win32.js +8 -9
  108. package/src/private/devsupport/rndevtools/setUpFuseboxReactDevToolsDispatcher.js +0 -1
  109. package/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js +0 -1
  110. package/src/private/featureflags/ReactNativeFeatureFlags.js +39 -4
  111. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +5 -2
  112. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +44 -0
  113. package/src/private/styles/composeStyles.js +12 -5
  114. package/src/private/webapis/dom/events/Event.js +3 -0
  115. package/src/private/webapis/dom/events/EventTarget.js +3 -0
  116. package/src/private/webapis/dom/nodes/ReactNativeElement.js +6 -23
  117. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +3 -1
  118. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +38 -0
  119. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +3 -0
  120. package/src/private/webapis/dom/oldstylecollections/NodeList.js +3 -0
  121. package/src/private/webapis/errors/DOMException.js +166 -0
  122. package/src/private/webapis/geometry/DOMRect.js +5 -0
  123. package/src/private/webapis/geometry/DOMRectList.js +3 -0
  124. package/src/private/webapis/geometry/DOMRectReadOnly.js +6 -0
  125. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +15 -7
  126. package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +3 -0
  127. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +80 -18
  128. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +12 -0
  129. package/src/private/webapis/mutationobserver/MutationObserver.js +23 -33
  130. package/src/private/webapis/mutationobserver/MutationRecord.js +3 -0
  131. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +56 -24
  132. package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +4 -1
  133. package/src/private/webapis/performance/MemoryInfo.js +4 -1
  134. package/src/private/webapis/performance/Performance.js +19 -8
  135. package/src/private/webapis/performance/PerformanceEntry.js +4 -0
  136. package/src/private/webapis/performance/ReactNativeStartupTiming.js +4 -1
  137. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +2 -0
  138. package/src/private/webapis/structuredClone/structuredClone.js +233 -0
  139. package/src/private/webapis/webidl/PlatformObjects.js +59 -0
  140. package/src/types/globals.d.ts +42 -0
  141. package/src-win/Libraries/Components/View/ViewAccessibility.d.ts +1 -0
  142. package/src-win/Libraries/Text/Text.d.ts +7 -0
  143. package/types/index.d.ts +1 -1
@@ -38,228 +38,153 @@ type TextForwardRef = React.ElementRef<
38
38
  const TextImpl: component(
39
39
  ref?: React.RefSetter<TextForwardRef>,
40
40
  ...props: TextProps
41
- ) = React.forwardRef(
42
- (
43
- {
44
- accessible,
45
- accessibilityLabel,
46
- accessibilityState,
47
- allowFontScaling,
48
- 'aria-busy': ariaBusy,
49
- 'aria-checked': ariaChecked,
50
- 'aria-disabled': ariaDisabled,
51
- 'aria-expanded': ariaExpanded,
52
- 'aria-label': ariaLabel,
53
- 'aria-selected': ariaSelected,
54
- children,
55
- ellipsizeMode,
56
- disabled,
57
- id,
58
- nativeID,
59
- numberOfLines,
60
- onLongPress,
61
- onPress,
62
- onPressIn,
63
- onPressOut,
64
- onResponderGrant,
65
- onResponderMove,
66
- onResponderRelease,
67
- onResponderTerminate,
68
- onResponderTerminationRequest,
69
- onStartShouldSetResponder,
70
- pressRetentionOffset,
71
- selectable,
72
- selectionColor,
73
- suppressHighlighting,
74
- style,
75
- ...restProps
76
- }: TextProps,
77
- forwardedRef,
78
- ) => {
79
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
80
-
81
- let _accessibilityState: ?TextProps['accessibilityState'] =
82
- accessibilityState;
83
- if (
84
- ariaBusy != null ||
85
- ariaChecked != null ||
86
- ariaDisabled != null ||
87
- ariaExpanded != null ||
88
- ariaSelected != null
89
- ) {
90
- if (_accessibilityState != null) {
91
- _accessibilityState = {
92
- busy: ariaBusy ?? _accessibilityState.busy,
93
- checked: ariaChecked ?? _accessibilityState.checked,
94
- disabled: ariaDisabled ?? _accessibilityState.disabled,
95
- expanded: ariaExpanded ?? _accessibilityState.expanded,
96
- selected: ariaSelected ?? _accessibilityState.selected,
97
- };
98
- } else {
99
- _accessibilityState = {
100
- busy: ariaBusy,
101
- checked: ariaChecked,
102
- disabled: ariaDisabled,
103
- expanded: ariaExpanded,
104
- selected: ariaSelected,
105
- };
106
- }
41
+ ) = ({
42
+ ref: forwardedRef,
43
+ accessible,
44
+ accessibilityLabel,
45
+ accessibilityState,
46
+ allowFontScaling,
47
+ 'aria-busy': ariaBusy,
48
+ 'aria-checked': ariaChecked,
49
+ 'aria-disabled': ariaDisabled,
50
+ 'aria-expanded': ariaExpanded,
51
+ 'aria-label': ariaLabel,
52
+ 'aria-selected': ariaSelected,
53
+ children,
54
+ ellipsizeMode,
55
+ disabled,
56
+ id,
57
+ nativeID,
58
+ numberOfLines,
59
+ onLongPress,
60
+ onPress,
61
+ onPressIn,
62
+ onPressOut,
63
+ onResponderGrant,
64
+ onResponderMove,
65
+ onResponderRelease,
66
+ onResponderTerminate,
67
+ onResponderTerminationRequest,
68
+ onStartShouldSetResponder,
69
+ pressRetentionOffset,
70
+ selectable,
71
+ selectionColor,
72
+ suppressHighlighting,
73
+ style,
74
+ ...restProps
75
+ }: {
76
+ ref?: React.RefSetter<TextForwardRef>,
77
+ ...TextProps,
78
+ }) => {
79
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
80
+
81
+ let _accessibilityState: ?TextProps['accessibilityState'] =
82
+ accessibilityState;
83
+ if (
84
+ ariaBusy != null ||
85
+ ariaChecked != null ||
86
+ ariaDisabled != null ||
87
+ ariaExpanded != null ||
88
+ ariaSelected != null
89
+ ) {
90
+ if (_accessibilityState != null) {
91
+ _accessibilityState = {
92
+ busy: ariaBusy ?? _accessibilityState.busy,
93
+ checked: ariaChecked ?? _accessibilityState.checked,
94
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
95
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
96
+ selected: ariaSelected ?? _accessibilityState.selected,
97
+ };
98
+ } else {
99
+ _accessibilityState = {
100
+ busy: ariaBusy,
101
+ checked: ariaChecked,
102
+ disabled: ariaDisabled,
103
+ expanded: ariaExpanded,
104
+ selected: ariaSelected,
105
+ };
107
106
  }
107
+ }
108
108
 
109
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
110
- const _disabled = disabled ?? _accessibilityStateDisabled;
109
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
110
+ const _disabled = disabled ?? _accessibilityStateDisabled;
111
111
 
112
- const isPressable =
113
- (onPress != null ||
114
- onLongPress != null ||
115
- onStartShouldSetResponder != null) &&
116
- _disabled !== true;
112
+ const isPressable =
113
+ (onPress != null ||
114
+ onLongPress != null ||
115
+ onStartShouldSetResponder != null) &&
116
+ _disabled !== true;
117
117
 
118
- // TODO: Move this processing to the view configuration.
119
- const _selectionColor =
120
- selectionColor != null ? processColor(selectionColor) : undefined;
118
+ // TODO: Move this processing to the view configuration.
119
+ const _selectionColor =
120
+ selectionColor != null ? processColor(selectionColor) : undefined;
121
121
 
122
- let _style = style;
123
- if (__DEV__) {
124
- if (PressabilityDebug.isEnabled() && onPress != null) {
125
- _style = [style, {color: 'magenta'}];
126
- }
122
+ let _style = style;
123
+ if (__DEV__) {
124
+ if (PressabilityDebug.isEnabled() && onPress != null) {
125
+ _style = [style, {color: 'magenta'}];
127
126
  }
127
+ }
128
128
 
129
- let _numberOfLines = numberOfLines;
130
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
131
- if (__DEV__) {
132
- console.error(
133
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
134
- );
135
- }
136
- _numberOfLines = 0;
129
+ let _numberOfLines = numberOfLines;
130
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
131
+ if (__DEV__) {
132
+ console.error(
133
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
134
+ );
137
135
  }
138
-
139
- let _selectable = selectable;
140
-
141
- let processedStyle = flattenStyle<TextStyleProp>(_style);
142
- if (processedStyle != null) {
143
- let overrides: ?{...TextStyleInternal} = null;
144
- if (typeof processedStyle.fontWeight === 'number') {
145
- overrides = overrides || ({}: {...TextStyleInternal});
146
- overrides.fontWeight =
147
- // $FlowFixMe[incompatible-cast]
148
- (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
149
- }
150
-
151
- if (processedStyle.userSelect != null) {
152
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
153
- overrides = overrides || ({}: {...TextStyleInternal});
154
- overrides.userSelect = undefined;
155
- }
156
-
157
- if (processedStyle.verticalAlign != null) {
158
- overrides = overrides || ({}: {...TextStyleInternal});
159
- overrides.textAlignVertical =
160
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
161
- overrides.verticalAlign = undefined;
162
- }
163
-
164
- if (overrides != null) {
165
- // $FlowFixMe[incompatible-type]
166
- _style = [_style, overrides];
167
- }
136
+ _numberOfLines = 0;
137
+ }
138
+
139
+ let _selectable = selectable;
140
+
141
+ let processedStyle = flattenStyle<TextStyleProp>(_style);
142
+ if (processedStyle != null) {
143
+ let overrides: ?{...TextStyleInternal} = null;
144
+ if (typeof processedStyle.fontWeight === 'number') {
145
+ overrides = overrides || ({}: {...TextStyleInternal});
146
+ overrides.fontWeight =
147
+ // $FlowFixMe[incompatible-cast]
148
+ (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
168
149
  }
169
150
 
170
- const _nativeID = id ?? nativeID;
171
-
172
- const hasTextAncestor = useContext(TextAncestor);
173
- if (hasTextAncestor) {
174
- if (isPressable) {
175
- return (
176
- <NativePressableVirtualText
177
- ref={forwardedRef}
178
- textProps={{
179
- ...restProps,
180
- accessibilityLabel: _accessibilityLabel,
181
- accessibilityState: _accessibilityState,
182
- nativeID: _nativeID,
183
- numberOfLines: _numberOfLines,
184
- selectable: _selectable,
185
- selectionColor: _selectionColor,
186
- style: _style,
187
- disabled: disabled,
188
- children,
189
- }}
190
- textPressabilityProps={{
191
- onLongPress,
192
- onPress,
193
- onPressIn,
194
- onPressOut,
195
- onResponderGrant,
196
- onResponderMove,
197
- onResponderRelease,
198
- onResponderTerminate,
199
- onResponderTerminationRequest,
200
- onStartShouldSetResponder,
201
- pressRetentionOffset,
202
- suppressHighlighting,
203
- }}
204
- />
205
- );
206
- }
151
+ if (processedStyle.userSelect != null) {
152
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
153
+ overrides = overrides || ({}: {...TextStyleInternal});
154
+ overrides.userSelect = undefined;
155
+ }
207
156
 
208
- return (
209
- <NativeVirtualText
210
- {...restProps}
211
- accessibilityLabel={_accessibilityLabel}
212
- accessibilityState={_accessibilityState}
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
- );
157
+ if (processedStyle.verticalAlign != null) {
158
+ overrides = overrides || ({}: {...TextStyleInternal});
159
+ overrides.textAlignVertical =
160
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
161
+ overrides.verticalAlign = undefined;
223
162
  }
224
163
 
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};
164
+ if (overrides != null) {
165
+ // $FlowFixMe[incompatible-type]
166
+ _style = [_style, overrides];
234
167
  }
168
+ }
235
169
 
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
- });
170
+ const _nativeID = id ?? nativeID;
244
171
 
245
- let nativeText = null;
172
+ const hasTextAncestor = useContext(TextAncestor);
173
+ if (hasTextAncestor) {
246
174
  if (isPressable) {
247
- nativeText = (
248
- <NativePressableText
175
+ return (
176
+ <NativePressableVirtualText
249
177
  ref={forwardedRef}
250
178
  textProps={{
251
179
  ...restProps,
252
180
  accessibilityLabel: _accessibilityLabel,
253
181
  accessibilityState: _accessibilityState,
254
- accessible: _accessible,
255
- allowFontScaling: allowFontScaling !== false,
256
- disabled: _disabled,
257
- ellipsizeMode: ellipsizeMode ?? 'tail',
258
182
  nativeID: _nativeID,
259
183
  numberOfLines: _numberOfLines,
260
184
  selectable: _selectable,
261
185
  selectionColor: _selectionColor,
262
186
  style: _style,
187
+ disabled: disabled,
263
188
  children,
264
189
  }}
265
190
  textPressabilityProps={{
@@ -278,57 +203,129 @@ const TextImpl: component(
278
203
  }}
279
204
  />
280
205
  );
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
- nativeID={_nativeID}
292
- numberOfLines={_numberOfLines}
293
- ref={forwardedRef}
294
- selectable={_selectable}
295
- selectionColor={_selectionColor}
296
- style={_style}>
297
- {children}
298
- </NativeText>
299
- );
300
206
  }
301
207
 
302
- if (children == null) {
303
- return nativeText;
304
- }
305
-
306
- // If the children do not contain a JSX element it would not be possible to have a
307
- // nested `Text` component so we can skip adding the `TextAncestor` context wrapper
308
- // which has a performance overhead. Since we do this for performance reasons we need
309
- // to keep the check simple to avoid regressing overall perf. For this reason the
310
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
311
- // to capture the majority of `Text` uses but also not make this check too expensive.
312
- if (Array.isArray(children) && children.length <= 3) {
313
- let hasNonTextChild = false;
314
- for (let child of children) {
315
- if (child != null && typeof child === 'object') {
316
- hasNonTextChild = true;
317
- break;
318
- }
319
- }
320
- if (!hasNonTextChild) {
321
- return nativeText;
208
+ return (
209
+ <NativeVirtualText
210
+ {...restProps}
211
+ accessibilityLabel={_accessibilityLabel}
212
+ accessibilityState={_accessibilityState}
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
+ }
224
+
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 ? onPress != null || onLongPress != null : accessible,
240
+ default: accessible,
241
+ });
242
+
243
+ let nativeText = null;
244
+ if (isPressable) {
245
+ nativeText = (
246
+ <NativePressableText
247
+ ref={forwardedRef}
248
+ textProps={{
249
+ ...restProps,
250
+ accessibilityLabel: _accessibilityLabel,
251
+ accessibilityState: _accessibilityState,
252
+ accessible: _accessible,
253
+ allowFontScaling: allowFontScaling !== false,
254
+ disabled: _disabled,
255
+ ellipsizeMode: ellipsizeMode ?? 'tail',
256
+ nativeID: _nativeID,
257
+ numberOfLines: _numberOfLines,
258
+ selectable: _selectable,
259
+ selectionColor: _selectionColor,
260
+ style: _style,
261
+ children,
262
+ }}
263
+ textPressabilityProps={{
264
+ onLongPress,
265
+ onPress,
266
+ onPressIn,
267
+ onPressOut,
268
+ onResponderGrant,
269
+ onResponderMove,
270
+ onResponderRelease,
271
+ onResponderTerminate,
272
+ onResponderTerminationRequest,
273
+ onStartShouldSetResponder,
274
+ pressRetentionOffset,
275
+ suppressHighlighting,
276
+ }}
277
+ />
278
+ );
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
+ nativeID={_nativeID}
290
+ numberOfLines={_numberOfLines}
291
+ ref={forwardedRef}
292
+ selectable={_selectable}
293
+ selectionColor={_selectionColor}
294
+ style={_style}>
295
+ {children}
296
+ </NativeText>
297
+ );
298
+ }
299
+
300
+ if (children == null) {
301
+ return nativeText;
302
+ }
303
+
304
+ // If the children do not contain a JSX element it would not be possible to have a
305
+ // nested `Text` component so we can skip adding the `TextAncestor` context wrapper
306
+ // which has a performance overhead. Since we do this for performance reasons we need
307
+ // to keep the check simple to avoid regressing overall perf. For this reason the
308
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
309
+ // to capture the majority of `Text` uses but also not make this check too expensive.
310
+ if (Array.isArray(children) && children.length <= 3) {
311
+ let hasNonTextChild = false;
312
+ for (let child of children) {
313
+ if (child != null && typeof child === 'object') {
314
+ hasNonTextChild = true;
315
+ break;
322
316
  }
323
- } else if (typeof children !== 'object') {
317
+ }
318
+ if (!hasNonTextChild) {
324
319
  return nativeText;
325
320
  }
321
+ } else if (typeof children !== 'object') {
322
+ return nativeText;
323
+ }
326
324
 
327
- return (
328
- <TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
329
- );
330
- },
331
- );
325
+ return (
326
+ <TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
327
+ );
328
+ };
332
329
 
333
330
  TextImpl.displayName = 'Text';
334
331
 
@@ -480,7 +477,14 @@ type NativePressableTextProps = $ReadOnly<{
480
477
  const NativePressableVirtualText: component(
481
478
  ref: React.RefSetter<TextForwardRef>,
482
479
  ...props: NativePressableTextProps
483
- ) = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
480
+ ) = ({
481
+ ref: forwardedRef,
482
+ textProps,
483
+ textPressabilityProps,
484
+ }: {
485
+ ref?: React.RefSetter<TextForwardRef>,
486
+ ...NativePressableTextProps,
487
+ }) => {
484
488
  const [isHighlighted, eventHandlersForText] = useTextPressability(
485
489
  textPressabilityProps,
486
490
  );
@@ -494,7 +498,7 @@ const NativePressableVirtualText: component(
494
498
  ref={forwardedRef}
495
499
  />
496
500
  );
497
- });
501
+ };
498
502
 
499
503
  /**
500
504
  * Wrap the NativeText component and initialize pressability.
@@ -505,7 +509,14 @@ const NativePressableVirtualText: component(
505
509
  const NativePressableText: component(
506
510
  ref: React.RefSetter<TextForwardRef>,
507
511
  ...props: NativePressableTextProps
508
- ) = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
512
+ ) = ({
513
+ ref: forwardedRef,
514
+ textProps,
515
+ textPressabilityProps,
516
+ }: {
517
+ ref?: React.RefSetter<TextForwardRef>,
518
+ ...NativePressableTextProps,
519
+ }) => {
509
520
  const [isHighlighted, eventHandlersForText] = useTextPressability(
510
521
  textPressabilityProps,
511
522
  );
@@ -519,7 +530,7 @@ const NativePressableText: component(
519
530
  ref={forwardedRef}
520
531
  />
521
532
  );
522
- });
533
+ };
523
534
 
524
535
  const userSelectToSelectableMap = {
525
536
  auto: true,