@office-iss/react-native-win32 0.81.2 → 0.82.0-preview.2

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 (209) hide show
  1. package/.flowconfig +3 -11
  2. package/CHANGELOG.json +118 -43
  3. package/CHANGELOG.md +45 -27
  4. package/IntegrationTests/IntegrationTestsApp.js +2 -2
  5. package/IntegrationTests/LayoutEventsTest.js +3 -3
  6. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +7 -3
  7. package/Libraries/Alert/RCTAlertManager.android.js +4 -2
  8. package/Libraries/Animated/Animated.d.ts +2 -0
  9. package/Libraries/Animated/AnimatedEvent.js +1 -1
  10. package/Libraries/Animated/AnimatedExports.js.flow +1 -0
  11. package/Libraries/Animated/AnimatedImplementation.js +4 -2
  12. package/Libraries/Animated/AnimatedMock.js +1 -1
  13. package/Libraries/Animated/Easing.js +2 -0
  14. package/Libraries/Animated/NativeAnimatedAllowlist.js +1 -0
  15. package/Libraries/Animated/animations/Animation.js +19 -20
  16. package/Libraries/Animated/animations/TimingAnimation.js +2 -0
  17. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  18. package/Libraries/Animated/components/AnimatedSectionList.js +1 -1
  19. package/Libraries/Animated/nodes/AnimatedColor.js +9 -9
  20. package/Libraries/Animated/nodes/AnimatedInterpolation.js +4 -4
  21. package/Libraries/Animated/nodes/AnimatedNode.js +14 -7
  22. package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
  23. package/Libraries/Animated/nodes/AnimatedProps.js +32 -32
  24. package/Libraries/Animated/nodes/AnimatedStyle.js +23 -21
  25. package/Libraries/Animated/nodes/AnimatedTransform.js +6 -6
  26. package/Libraries/Animated/nodes/AnimatedValue.js +18 -26
  27. package/Libraries/AppState/AppState.js +8 -4
  28. package/Libraries/BatchedBridge/BatchedBridge.js +1 -0
  29. package/Libraries/BatchedBridge/MessageQueue.js +5 -0
  30. package/Libraries/BatchedBridge/NativeModules.js +1 -1
  31. package/Libraries/Blob/BlobManager.js +1 -1
  32. package/Libraries/Blob/URLSearchParams.js +2 -0
  33. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +2 -2
  34. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +2 -2
  35. package/Libraries/Components/Button.js +1 -1
  36. package/Libraries/Components/Button.win32.js +1 -1
  37. package/Libraries/Components/Pressable/Pressable.js +10 -1
  38. package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
  39. package/Libraries/Components/Pressable/useAndroidRippleForView.js +2 -2
  40. package/Libraries/Components/ScrollView/ScrollView.js +13 -4
  41. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  42. package/Libraries/Components/StatusBar/StatusBar.js +2 -2
  43. package/Libraries/Components/Switch/Switch.js +1 -1
  44. package/Libraries/Components/TextInput/TextInput.flow.js +12 -5
  45. package/Libraries/Components/TextInput/TextInput.flow.win32.js +12 -5
  46. package/Libraries/Components/TextInput/TextInput.js +14 -5
  47. package/Libraries/Components/TextInput/TextInput.win32.js +15 -7
  48. package/Libraries/Components/TextInput/TextInputState.js +1 -1
  49. package/Libraries/Components/TextInput/TextInputState.win32.js +1 -1
  50. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +2 -3
  51. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  52. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  53. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  54. package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
  55. package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
  56. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  57. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +3 -3
  58. package/Libraries/Components/View/View.js +81 -167
  59. package/Libraries/Components/View/View.win32.js +3 -1
  60. package/Libraries/Core/Devtools/loadBundleFromServer.js +1 -1
  61. package/Libraries/Core/Devtools/loadBundleFromServer.win32.js +1 -1
  62. package/Libraries/Core/ExceptionsManager.js +4 -2
  63. package/Libraries/Core/ReactFiberErrorDialog.js +3 -3
  64. package/Libraries/Core/ReactNativeVersion.js +37 -10
  65. package/Libraries/Core/Timers/JSTimers.js +4 -1
  66. package/Libraries/Core/Timers/NativeTiming.js +1 -0
  67. package/Libraries/Core/Timers/immediateShim.js +2 -1
  68. package/Libraries/Core/Timers/queueMicrotask.js +1 -0
  69. package/Libraries/Core/setUpPerformance.js +3 -4
  70. package/Libraries/Debugging/DebuggingOverlayRegistry.js +5 -3
  71. package/Libraries/Image/Image.android.js +327 -111
  72. package/Libraries/Image/Image.ios.js +6 -1
  73. package/Libraries/Image/Image.win32.js +6 -1
  74. package/Libraries/Image/ImageSourceUtils.js +8 -2
  75. package/Libraries/Image/assetPaths.js +1 -1
  76. package/Libraries/Image/resolveAssetSource.js +1 -1
  77. package/Libraries/Image/resolveAssetSource.win32.js +6 -7
  78. package/Libraries/Interaction/InteractionManager.js +118 -167
  79. package/Libraries/Interaction/PanResponder.js +7 -52
  80. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
  81. package/Libraries/Lists/FlatList.js +5 -6
  82. package/Libraries/LogBox/Data/LogBoxData.js +5 -2
  83. package/Libraries/LogBox/Data/parseLogBoxLog.js +1 -1
  84. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +2 -2
  85. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +1 -1
  86. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +1 -1
  87. package/Libraries/Modal/Modal.js +3 -3
  88. package/Libraries/NativeComponent/NativeComponentRegistry.js +1 -1
  89. package/Libraries/NativeComponent/ViewConfig.js +2 -2
  90. package/Libraries/Network/RCTNetworking.android.js +1 -1
  91. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  92. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  93. package/Libraries/Network/XMLHttpRequest.js +20 -5
  94. package/Libraries/Network/convertRequestBody.js +1 -1
  95. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +10 -9
  96. package/Libraries/Pressability/HoverState.js +2 -0
  97. package/Libraries/Pressability/HoverState.win32.js +2 -0
  98. package/Libraries/Pressability/Pressability.js +1 -1
  99. package/Libraries/Pressability/Pressability.win32.js +1 -1
  100. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  101. package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
  102. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -0
  103. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +3 -3
  104. package/Libraries/ReactNative/RendererImplementation.js +116 -116
  105. package/Libraries/ReactNative/UIManager.js +3 -3
  106. package/Libraries/ReactNative/renderApplication.js +1 -0
  107. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -1
  108. package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
  109. package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
  110. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
  111. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
  112. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
  113. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
  114. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  115. package/Libraries/Share/Share.js +4 -0
  116. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +2 -2
  117. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +2 -2
  118. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +4 -0
  119. package/Libraries/StyleSheet/StyleSheet.d.ts +7 -22
  120. package/Libraries/StyleSheet/StyleSheetExports.js +2 -8
  121. package/Libraries/StyleSheet/StyleSheetExports.js.flow +11 -18
  122. package/Libraries/StyleSheet/flattenStyle.js +2 -2
  123. package/Libraries/StyleSheet/processAspectRatio.js +2 -0
  124. package/Libraries/StyleSheet/processFilter.js +5 -5
  125. package/Libraries/StyleSheet/splitLayoutProps.js +2 -2
  126. package/Libraries/Text/Text.js +534 -234
  127. package/Libraries/Text/Text.win32.js +647 -274
  128. package/Libraries/Text/TextNativeComponent.js +2 -2
  129. package/Libraries/Text/TextNativeComponent.win32.js +2 -2
  130. package/Libraries/Utilities/Appearance.d.ts +3 -5
  131. package/Libraries/Utilities/Appearance.js +5 -17
  132. package/Libraries/Utilities/HMRClient.js +2 -1
  133. package/Libraries/Utilities/Platform.android.js +3 -3
  134. package/Libraries/Utilities/Platform.d.ts +1 -0
  135. package/Libraries/Utilities/Platform.ios.js +1 -1
  136. package/Libraries/Utilities/Platform.win32.js +3 -3
  137. package/Libraries/Utilities/PlatformTypes.js +1 -1
  138. package/Libraries/Utilities/ReactNativeTestTools.js +12 -0
  139. package/Libraries/Utilities/SceneTracker.js +1 -1
  140. package/Libraries/Utilities/codegenNativeCommands.js +1 -1
  141. package/Libraries/Utilities/codegenNativeComponent.js +1 -1
  142. package/Libraries/Utilities/createPerformanceLogger.js +32 -0
  143. package/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +2 -0
  144. package/Libraries/Utilities/differ/pointsDiffer.js +1 -1
  145. package/Libraries/Utilities/useMergeRefs.js +1 -1
  146. package/Libraries/WebSocket/WebSocketInterceptor.js +2 -0
  147. package/Libraries/promiseRejectionTrackingOptions.js +17 -31
  148. package/Libraries/vendor/emitter/EventEmitter.js +1 -1
  149. package/flow/bom.js.flow +223 -1
  150. package/flow/prettier.js.flow +14 -0
  151. package/index.js +14 -2
  152. package/index.win32.js +16 -2
  153. package/jest/local-setup.js +2 -2
  154. package/jest/mock.js +1 -1
  155. package/jest/mockComponent.js +9 -9
  156. package/jest/mockNativeComponent.js +3 -2
  157. package/jest/mocks/Modal.js +1 -1
  158. package/jest/mocks/ScrollView.js +1 -1
  159. package/jest/mocks/ViewNativeComponent.js +1 -1
  160. package/jest/setup.js +23 -12
  161. package/overrides.json +23 -23
  162. package/package.json +28 -27
  163. package/saveAssetPlugin.js +2 -2
  164. package/src/private/animated/NativeAnimatedHelper.js +16 -5
  165. package/src/private/animated/NativeAnimatedHelper.win32.js +16 -5
  166. package/src/private/animated/createAnimatedPropsHook.js +11 -60
  167. package/src/private/animated/createAnimatedPropsMemoHook.js +8 -54
  168. package/src/private/components/virtualview/VirtualView.js +43 -12
  169. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
  170. package/src/private/components/virtualview/VirtualViewNativeComponent.js +6 -0
  171. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +2 -2
  172. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
  173. package/src/private/featureflags/ReactNativeFeatureFlags.js +85 -52
  174. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +23 -4
  175. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -6
  176. package/src/private/renderer/errorhandling/ErrorHandlers.js +3 -3
  177. package/src/private/setup/{setUpPerformanceObserver.js → setUpPerformanceModern.js} +43 -18
  178. package/src/private/specs_DEPRECATED/modules/NativeTiming.js +1 -0
  179. package/src/private/types/HostInstance.js +4 -1
  180. package/src/private/webapis/dom/nodes/ReactNativeDocument.js +22 -2
  181. package/src/private/webapis/dom/nodes/ReactNativeElement.js +1 -1
  182. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +5 -3
  183. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +16 -13
  184. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +45 -22
  185. package/src/private/webapis/dom/nodes/internals/ReactNativeDocumentInstanceHandle.js +1 -1
  186. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +26 -192
  187. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +15 -12
  188. package/src/private/webapis/dom/oldstylecollections/NodeList.js +14 -11
  189. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  190. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
  191. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
  192. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  193. package/src/private/webapis/performance/EventTiming.js +40 -25
  194. package/src/private/webapis/performance/LongTasks.js +35 -2
  195. package/src/private/webapis/performance/Performance.js +347 -166
  196. package/src/private/webapis/performance/PerformanceEntry.js +40 -23
  197. package/src/private/webapis/performance/PerformanceObserver.js +37 -29
  198. package/src/private/webapis/performance/ReactNativeStartupTiming.js +3 -24
  199. package/src/private/webapis/performance/ResourceTiming.js +29 -18
  200. package/src/private/webapis/performance/UserTiming.js +92 -34
  201. package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
  202. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +3 -4
  203. package/src/private/webapis/performance/internals/Utilities.js +9 -0
  204. package/src/private/webapis/performance/specs/NativePerformance.js +23 -23
  205. package/src/private/webapis/structuredClone/structuredClone.js +10 -10
  206. package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  207. package/Libraries/Interaction/InteractionManagerStub.js +0 -184
  208. package/Libraries/Interaction/TaskQueue.js +0 -183
  209. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
@@ -14,12 +14,13 @@ import type {GestureResponderEvent} from '../Types/CoreEventTypes';
14
14
  import type {NativeTextProps} from './TextNativeComponent';
15
15
  import type {PressRetentionOffset, TextProps} from './TextProps';
16
16
 
17
+ import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags';
17
18
  import * as PressabilityDebug from '../Pressability/PressabilityDebug';
18
19
  import usePressability from '../Pressability/usePressability';
19
20
  import flattenStyle from '../StyleSheet/flattenStyle';
20
21
  import processColor from '../StyleSheet/processColor';
21
22
  import Platform from '../Utilities/Platform';
22
- import TextAncestor from './TextAncestor';
23
+ import TextAncestorContext from './TextAncestorContext';
23
24
  import {NativeText, NativeVirtualText} from './TextNativeComponent';
24
25
  import * as React from 'react';
25
26
  import {useContext, useMemo, useState} from 'react';
@@ -35,188 +36,632 @@ type TextForwardRef = React.ElementRef<
35
36
  *
36
37
  * @see https://reactnative.dev/docs/text
37
38
  */
38
- const TextImpl: component(
39
- ref?: React.RefSetter<TextForwardRef>,
40
- ...props: TextProps
41
- ) = ({
42
- ref: forwardedRef,
43
- accessible,
44
- accessibilityControls, // Win32
45
- accessibilityDescribedBy, // Win32
46
- accessibilityDescription, // Win32
47
- accessibilityLabel,
48
- accessibilityLevel, // Win32
49
- accessibilityPositionInSet, // Win32
50
- accessibilitySetSize, // Win32
51
- accessibilityState,
52
- allowFontScaling,
53
- 'aria-busy': ariaBusy,
54
- 'aria-checked': ariaChecked,
55
- 'aria-controls': ariaControls, // Win32
56
- 'aria-describedby': ariaDescribedBy, // Win32
57
- 'aria-description': ariaDescription, // Win32
58
- 'aria-disabled': ariaDisabled,
59
- 'aria-expanded': ariaExpanded,
60
- 'aria-label': ariaLabel,
61
- 'aria-level': ariaLevel, // Win32
62
- 'aria-multiselectable': ariaMultiselectable, // Win32
63
- 'aria-posinset': ariaPosinset, // Win32
64
- 'aria-required': ariaRequired, // Win32
65
- 'aria-selected': ariaSelected,
66
- 'aria-setsize': ariaSetsize, // Win32
67
- children,
68
- ellipsizeMode,
69
- disabled,
70
- id,
71
- nativeID,
72
- numberOfLines,
73
- onLongPress,
74
- onPress,
75
- onPressIn,
76
- onPressOut,
77
- onResponderGrant,
78
- onResponderMove,
79
- onResponderRelease,
80
- onResponderTerminate,
81
- onResponderTerminationRequest,
82
- onStartShouldSetResponder,
83
- pressRetentionOffset,
84
- selectable,
85
- selectionColor,
86
- suppressHighlighting,
87
- style,
88
- ...restProps
89
- }: {
90
- ref?: React.RefSetter<TextForwardRef>,
91
- ...TextProps,
92
- }) => {
93
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
94
- const _accessibilityControls = ariaControls ?? accessibilityControls; // Win32
95
- const _accessibilityDescribedBy = ariaDescribedBy ?? accessibilityDescribedBy; // Win32
96
- const _accessibilityDescription = ariaDescription ?? accessibilityDescription; // Win32
97
- const _accessibilityLevel = ariaLevel ?? accessibilityLevel; // Win32
98
- const _accessibilityPositionInSet =
99
- ariaPosinset ?? accessibilityPositionInSet; // Win32
100
- const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize; // Win32
101
-
102
- let _accessibilityState: ?TextProps['accessibilityState'] =
103
- accessibilityState;
104
- if (
105
- ariaBusy != null ||
106
- ariaChecked != null ||
107
- ariaDisabled != null ||
108
- ariaExpanded != null ||
109
- ariaSelected != null
110
- ) {
111
- if (_accessibilityState != null) {
112
- _accessibilityState = {
113
- busy: ariaBusy ?? _accessibilityState.busy,
114
- checked: ariaChecked ?? _accessibilityState.checked,
115
- disabled: ariaDisabled ?? _accessibilityState.disabled,
116
- expanded: ariaExpanded ?? _accessibilityState.expanded,
117
- multiselectable:
118
- ariaMultiselectable ?? accessibilityState?.multiselectable, // Win32
119
- required: ariaRequired ?? accessibilityState?.required, // Win32
120
- selected: ariaSelected ?? _accessibilityState.selected,
39
+ let _TextImpl;
40
+ if (ReactNativeFeatureFlags.reduceDefaultPropsInText()) {
41
+ const TextImplNoDefaultProps: component(
42
+ ref?: React.RefSetter<TextForwardRef>,
43
+ ...props: TextProps
44
+ ) = ({
45
+ ref: forwardedRef,
46
+ accessible,
47
+ accessibilityLabel,
48
+ accessibilityState,
49
+ allowFontScaling,
50
+ 'aria-busy': ariaBusy,
51
+ 'aria-checked': ariaChecked,
52
+ 'aria-disabled': ariaDisabled,
53
+ 'aria-expanded': ariaExpanded,
54
+ 'aria-hidden': ariaHidden,
55
+ 'aria-label': ariaLabel,
56
+ 'aria-selected': ariaSelected,
57
+ // #[ Win32
58
+ 'aria-level': ariaLevel,
59
+ 'aria-multiselectable': ariaMultiselectable,
60
+ 'aria-posinset': ariaPosinset,
61
+ 'aria-required': ariaRequired,
62
+ 'aria-setsize': ariaSetsize,
63
+ 'aria-controls': ariaControls,
64
+ 'aria-describedby': ariaDescribedBy,
65
+ 'aria-description': ariaDescription,
66
+ accessibilityLevel,
67
+ accessibilityPositionInSet,
68
+ accessibilitySetSize,
69
+ accessibilityControls,
70
+ accessibilityDescribedBy,
71
+ accessibilityDescription,
72
+ // #] Win32
73
+ children,
74
+ ellipsizeMode,
75
+ disabled,
76
+ id,
77
+ nativeID,
78
+ numberOfLines,
79
+ onLongPress,
80
+ onPress,
81
+ onPressIn,
82
+ onPressOut,
83
+ onResponderGrant,
84
+ onResponderMove,
85
+ onResponderRelease,
86
+ onResponderTerminate,
87
+ onResponderTerminationRequest,
88
+ onStartShouldSetResponder,
89
+ pressRetentionOffset,
90
+ selectable,
91
+ selectionColor,
92
+ suppressHighlighting,
93
+ style,
94
+ ...restProps
95
+ }: {
96
+ ref?: React.RefSetter<TextForwardRef>,
97
+ ...TextProps,
98
+ }) => {
99
+ const processedProps = restProps as {
100
+ ...NativeTextProps,
101
+ };
102
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
103
+ // #Win32 [
104
+ const _accessibilityControls = ariaControls ?? accessibilityControls;
105
+ const _accessibilityDescribedBy =
106
+ ariaDescribedBy ?? accessibilityDescribedBy;
107
+ const _accessibilityDescription =
108
+ ariaDescription ?? accessibilityDescription;
109
+ const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
110
+ const _accessibilityPositionInSet =
111
+ ariaPosinset ?? accessibilityPositionInSet;
112
+ const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
113
+ // ] #Win32
114
+
115
+ let _accessibilityState: ?TextProps['accessibilityState'] =
116
+ accessibilityState;
117
+ if (
118
+ ariaBusy != null ||
119
+ ariaChecked != null ||
120
+ ariaDisabled != null ||
121
+ ariaExpanded != null ||
122
+ ariaSelected != null
123
+ ) {
124
+ if (_accessibilityState != null) {
125
+ _accessibilityState = {
126
+ busy: ariaBusy ?? _accessibilityState.busy,
127
+ checked: ariaChecked ?? _accessibilityState.checked,
128
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
129
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
130
+ // #Win32 [
131
+ multiselectable:
132
+ ariaMultiselectable ?? accessibilityState?.multiselectable,
133
+ required: ariaRequired ?? accessibilityState?.required,
134
+ // ] #Win32
135
+ selected: ariaSelected ?? _accessibilityState.selected,
136
+ };
137
+ } else {
138
+ _accessibilityState = {
139
+ busy: ariaBusy,
140
+ checked: ariaChecked,
141
+ disabled: ariaDisabled,
142
+ expanded: ariaExpanded,
143
+ // #Win32 [
144
+ multiselectable: ariaMultiselectable,
145
+ required: ariaRequired,
146
+ // ] #Win32
147
+ selected: ariaSelected,
148
+ };
149
+ }
150
+ }
151
+
152
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
153
+ const _disabled = disabled ?? _accessibilityStateDisabled;
154
+
155
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
156
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
157
+ if (
158
+ _accessibilityState != null &&
159
+ _disabled !== _accessibilityStateDisabled &&
160
+ ((_disabled != null && _disabled !== false) ||
161
+ (_accessibilityStateDisabled != null &&
162
+ _accessibilityStateDisabled !== false))
163
+ ) {
164
+ _accessibilityState.disabled = _disabled;
165
+ }
166
+
167
+ if (ariaHidden !== undefined) {
168
+ processedProps.accessibilityElementsHidden = ariaHidden;
169
+ if (ariaHidden === true) {
170
+ processedProps.importantForAccessibility = 'no-hide-descendants';
171
+ }
172
+ }
173
+
174
+ const _accessible = Platform.select({
175
+ ios: accessible !== false,
176
+ android:
177
+ accessible == null
178
+ ? onPress != null || onLongPress != null
179
+ : accessible,
180
+ default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
181
+ });
182
+
183
+ const isPressable =
184
+ (onPress != null ||
185
+ onLongPress != null ||
186
+ onStartShouldSetResponder != null) &&
187
+ _disabled !== true;
188
+
189
+ // TODO: Move this processing to the view configuration.
190
+ const _selectionColor =
191
+ selectionColor != null ? processColor(selectionColor) : undefined;
192
+
193
+ let _style = style;
194
+ if (__DEV__) {
195
+ if (PressabilityDebug.isEnabled() && onPress != null) {
196
+ _style = [style, {color: 'magenta'}];
197
+ }
198
+ }
199
+
200
+ let _numberOfLines = numberOfLines;
201
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
202
+ if (__DEV__) {
203
+ console.error(
204
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
205
+ );
206
+ }
207
+ _numberOfLines = 0;
208
+ }
209
+
210
+ let _selectable = selectable;
211
+
212
+ let processedStyle = flattenStyle<TextStyleProp>(_style);
213
+ if (processedStyle != null) {
214
+ let overrides: ?{...TextStyleInternal} = null;
215
+ if (typeof processedStyle.fontWeight === 'number') {
216
+ overrides = overrides || ({}: {...TextStyleInternal});
217
+ overrides.fontWeight =
218
+ // $FlowFixMe[incompatible-type]
219
+ (String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
220
+ }
221
+
222
+ if (processedStyle.userSelect != null) {
223
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
224
+ overrides = overrides || ({}: {...TextStyleInternal});
225
+ overrides.userSelect = undefined;
226
+ }
227
+
228
+ if (processedStyle.verticalAlign != null) {
229
+ overrides = overrides || ({}: {...TextStyleInternal});
230
+ overrides.textAlignVertical =
231
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
232
+ overrides.verticalAlign = undefined;
233
+ }
234
+
235
+ if (overrides != null) {
236
+ // $FlowFixMe[incompatible-type]
237
+ _style = [_style, overrides];
238
+ }
239
+ }
240
+
241
+ const _nativeID = id ?? nativeID;
242
+
243
+ if (_accessibilityLabel !== undefined) {
244
+ processedProps.accessibilityLabel = _accessibilityLabel;
245
+ }
246
+ if (_accessibilityState !== undefined) {
247
+ processedProps.accessibilityState = _accessibilityState;
248
+ }
249
+ if (_nativeID !== undefined) {
250
+ processedProps.nativeID = _nativeID;
251
+ }
252
+ if (_numberOfLines !== undefined) {
253
+ processedProps.numberOfLines = _numberOfLines;
254
+ }
255
+ if (_selectable !== undefined) {
256
+ processedProps.selectable = _selectable;
257
+ }
258
+ if (_style !== undefined) {
259
+ processedProps.style = _style;
260
+ }
261
+ if (_selectionColor !== undefined) {
262
+ processedProps.selectionColor = _selectionColor;
263
+ }
264
+
265
+ // [Windows accessibility properties
266
+ if (_accessibilityControls !== undefined) {
267
+ processedProps.accessibilityControls = _accessibilityControls;
268
+ }
269
+
270
+ if (_accessibilityDescribedBy !== undefined) {
271
+ processedProps.accessibilityDescribedBy = _accessibilityDescribedBy;
272
+ }
273
+
274
+ if (_accessibilityDescription !== undefined) {
275
+ processedProps.accessibilityDescription = _accessibilityDescription;
276
+ }
277
+
278
+ if (_accessibilityLevel !== undefined) {
279
+ processedProps.accessibilityLevel = _accessibilityLevel;
280
+ }
281
+ if (_accessibilityPositionInSet !== undefined) {
282
+ processedProps.accessibilityPositionInSet = _accessibilityPositionInSet;
283
+ }
284
+ if (_accessibilitySetSize !== undefined) {
285
+ processedProps.accessibilitySetSize = _accessibilitySetSize;
286
+ }
287
+ // ]
288
+
289
+ let textPressabilityProps: ?TextPressabilityProps;
290
+ if (isPressable) {
291
+ textPressabilityProps = {
292
+ onLongPress,
293
+ onPress,
294
+ onPressIn,
295
+ onPressOut,
296
+ onResponderGrant,
297
+ onResponderMove,
298
+ onResponderRelease,
299
+ onResponderTerminate,
300
+ onResponderTerminationRequest,
301
+ onStartShouldSetResponder,
302
+ pressRetentionOffset,
303
+ suppressHighlighting,
121
304
  };
305
+ }
306
+
307
+ const hasTextAncestor = useContext(TextAncestorContext);
308
+ if (hasTextAncestor) {
309
+ processedProps.disabled = disabled;
310
+ processedProps.children = children;
311
+ if (isPressable) {
312
+ return (
313
+ <NativePressableVirtualText
314
+ ref={forwardedRef}
315
+ textProps={processedProps}
316
+ textPressabilityProps={textPressabilityProps ?? {}}
317
+ />
318
+ );
319
+ }
320
+ return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
321
+ }
322
+
323
+ let nativeText = null;
324
+
325
+ processedProps.accessible = _accessible;
326
+ processedProps.allowFontScaling = allowFontScaling !== false;
327
+ processedProps.disabled = _disabled;
328
+ processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
329
+ processedProps.children = children;
330
+
331
+ if (isPressable) {
332
+ nativeText = (
333
+ <NativePressableText
334
+ ref={forwardedRef}
335
+ textProps={processedProps}
336
+ textPressabilityProps={textPressabilityProps ?? {}}
337
+ />
338
+ );
122
339
  } else {
123
- _accessibilityState = {
124
- busy: ariaBusy,
125
- checked: ariaChecked,
126
- disabled: ariaDisabled,
127
- expanded: ariaExpanded,
128
- multiselectable: ariaMultiselectable, // Win32,
129
- required: ariaRequired, // Win32
130
- selected: ariaSelected,
131
- };
340
+ nativeText = <NativeText {...processedProps} ref={forwardedRef} />;
341
+ }
342
+
343
+ if (children == null) {
344
+ return nativeText;
132
345
  }
133
- }
134
346
 
135
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
136
- const _disabled = disabled ?? _accessibilityStateDisabled;
347
+ // If the children do not contain a JSX element it would not be possible to have a
348
+ // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
349
+ // which has a performance overhead. Since we do this for performance reasons we need
350
+ // to keep the check simple to avoid regressing overall perf. For this reason the
351
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
352
+ // to capture the majority of `Text` uses but also not make this check too expensive.
353
+ if (Array.isArray(children) && children.length <= 3) {
354
+ let hasNonTextChild = false;
355
+ for (let child of children) {
356
+ if (child != null && typeof child === 'object') {
357
+ hasNonTextChild = true;
358
+ break;
359
+ }
360
+ }
361
+ if (!hasNonTextChild) {
362
+ return nativeText;
363
+ }
364
+ } else if (typeof children !== 'object') {
365
+ return nativeText;
366
+ }
137
367
 
138
- const isPressable =
139
- (onPress != null ||
140
- onLongPress != null ||
141
- onStartShouldSetResponder != null) &&
142
- _disabled !== true;
368
+ return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
369
+ };
370
+ _TextImpl = TextImplNoDefaultProps;
371
+ } else {
372
+ const TextImplLegacy: component(
373
+ ref?: React.RefSetter<TextForwardRef>,
374
+ ...props: TextProps
375
+ ) = ({
376
+ ref: forwardedRef,
377
+ accessible,
378
+ accessibilityElementsHidden,
379
+ importantForAccessibility,
380
+ accessibilityLabel,
381
+ accessibilityState,
382
+ allowFontScaling,
383
+ 'aria-busy': ariaBusy,
384
+ 'aria-checked': ariaChecked,
385
+ 'aria-disabled': ariaDisabled,
386
+ 'aria-expanded': ariaExpanded,
387
+ 'aria-hidden': ariaHidden,
388
+ 'aria-label': ariaLabel,
389
+ 'aria-selected': ariaSelected,
390
+ //#[ Win32
391
+ 'aria-controls': ariaControls,
392
+ 'aria-describedby': ariaDescribedBy,
393
+ 'aria-description': ariaDescription,
394
+ 'aria-level': ariaLevel,
395
+ 'aria-multiselectable': ariaMultiselectable,
396
+ 'aria-posinset': ariaPosinset,
397
+ 'aria-required': ariaRequired,
398
+ 'aria-setsize': ariaSetsize,
399
+ accessibilityLevel,
400
+ accessibilityPositionInSet,
401
+ accessibilitySetSize,
402
+ accessibilityControls,
403
+ accessibilityDescribedBy,
404
+ accessibilityDescription,
405
+ // #] Win32
406
+ children,
407
+ ellipsizeMode,
408
+ disabled,
409
+ id,
410
+ nativeID,
411
+ numberOfLines,
412
+ onLongPress,
413
+ onPress,
414
+ onPressIn,
415
+ onPressOut,
416
+ onResponderGrant,
417
+ onResponderMove,
418
+ onResponderRelease,
419
+ onResponderTerminate,
420
+ onResponderTerminationRequest,
421
+ onStartShouldSetResponder,
422
+ pressRetentionOffset,
423
+ selectable,
424
+ selectionColor,
425
+ suppressHighlighting,
426
+ style,
427
+ ...restProps
428
+ }: {
429
+ ref?: React.RefSetter<TextForwardRef>,
430
+ ...TextProps,
431
+ }) => {
432
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
433
+ //#[ Win32
434
+ const _accessibilityControls = ariaControls ?? accessibilityControls;
435
+ const _accessibilityDescribedBy =
436
+ ariaDescribedBy ?? accessibilityDescribedBy;
437
+ const _accessibilityDescription =
438
+ ariaDescription ?? accessibilityDescription;
439
+ const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
440
+ const _accessibilityPositionInSet =
441
+ ariaPosinset ?? accessibilityPositionInSet;
442
+ const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
443
+ //#] Win32
444
+
445
+ let _accessibilityState: ?TextProps['accessibilityState'] =
446
+ accessibilityState;
447
+ if (
448
+ ariaBusy != null ||
449
+ ariaChecked != null ||
450
+ ariaDisabled != null ||
451
+ ariaExpanded != null ||
452
+ ariaSelected != null
453
+ ) {
454
+ if (_accessibilityState != null) {
455
+ _accessibilityState = {
456
+ busy: ariaBusy ?? _accessibilityState.busy,
457
+ checked: ariaChecked ?? _accessibilityState.checked,
458
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
459
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
460
+ //#[Win32
461
+ multiselectable:
462
+ ariaMultiselectable ?? accessibilityState?.multiselectable,
463
+ required: ariaRequired ?? accessibilityState?.required,
464
+ // #] Win32
465
+ selected: ariaSelected ?? _accessibilityState.selected,
466
+ };
467
+ } else {
468
+ _accessibilityState = {
469
+ busy: ariaBusy,
470
+ checked: ariaChecked,
471
+ disabled: ariaDisabled,
472
+ expanded: ariaExpanded,
473
+ // #[ Win32
474
+ multiselectable: ariaMultiselectable,
475
+ required: ariaRequired,
476
+ // #]win32
477
+ selected: ariaSelected,
478
+ };
479
+ }
480
+ }
143
481
 
144
- // TODO: Move this processing to the view configuration.
145
- const _selectionColor =
146
- selectionColor != null ? processColor(selectionColor) : undefined;
482
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
483
+ const _disabled = disabled ?? _accessibilityStateDisabled;
147
484
 
148
- let _style = style;
149
- if (__DEV__) {
150
- if (PressabilityDebug.isEnabled() && onPress != null) {
151
- _style = [style, {color: 'magenta'}];
485
+ let _accessibilityElementsHidden =
486
+ ariaHidden ?? accessibilityElementsHidden;
487
+ let _importantForAccessibility = importantForAccessibility;
488
+ if (ariaHidden === true) {
489
+ _importantForAccessibility = 'no-hide-descendants';
152
490
  }
153
- }
154
491
 
155
- let _numberOfLines = numberOfLines;
156
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
492
+ const isPressable =
493
+ (onPress != null ||
494
+ onLongPress != null ||
495
+ onStartShouldSetResponder != null) &&
496
+ _disabled !== true;
497
+
498
+ // TODO: Move this processing to the view configuration.
499
+ const _selectionColor =
500
+ selectionColor != null ? processColor(selectionColor) : undefined;
501
+
502
+ let _style = style;
157
503
  if (__DEV__) {
158
- console.error(
159
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
160
- );
504
+ if (PressabilityDebug.isEnabled() && onPress != null) {
505
+ _style = [style, {color: 'magenta'}];
506
+ }
161
507
  }
162
- _numberOfLines = 0;
163
- }
164
-
165
- let _selectable = selectable;
166
508
 
167
- let processedStyle = flattenStyle<TextStyleProp>(_style);
168
- if (processedStyle != null) {
169
- let overrides: ?{...TextStyleInternal} = null;
170
- if (typeof processedStyle.fontWeight === 'number') {
171
- overrides = overrides || ({}: {...TextStyleInternal});
172
- overrides.fontWeight =
173
- // $FlowFixMe[incompatible-cast]
174
- (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
509
+ let _numberOfLines = numberOfLines;
510
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
511
+ if (__DEV__) {
512
+ console.error(
513
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
514
+ );
515
+ }
516
+ _numberOfLines = 0;
175
517
  }
176
518
 
177
- if (processedStyle.userSelect != null) {
178
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
179
- overrides = overrides || ({}: {...TextStyleInternal});
180
- overrides.userSelect = undefined;
519
+ let _selectable = selectable;
520
+
521
+ let processedStyle = flattenStyle<TextStyleProp>(_style);
522
+ if (processedStyle != null) {
523
+ let overrides: ?{...TextStyleInternal} = null;
524
+ if (typeof processedStyle.fontWeight === 'number') {
525
+ overrides = overrides || ({}: {...TextStyleInternal});
526
+ overrides.fontWeight =
527
+ // $FlowFixMe[incompatible-type]
528
+ (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
529
+ }
530
+
531
+ if (processedStyle.userSelect != null) {
532
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
533
+ overrides = overrides || ({}: {...TextStyleInternal});
534
+ overrides.userSelect = undefined;
535
+ }
536
+
537
+ if (processedStyle.verticalAlign != null) {
538
+ overrides = overrides || ({}: {...TextStyleInternal});
539
+ overrides.textAlignVertical =
540
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
541
+ overrides.verticalAlign = undefined;
542
+ }
543
+
544
+ if (overrides != null) {
545
+ // $FlowFixMe[incompatible-type]
546
+ _style = [_style, overrides];
547
+ }
181
548
  }
182
549
 
183
- if (processedStyle.verticalAlign != null) {
184
- overrides = overrides || ({}: {...TextStyleInternal});
185
- overrides.textAlignVertical =
186
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
187
- overrides.verticalAlign = undefined;
550
+ const _nativeID = id ?? nativeID;
551
+
552
+ const hasTextAncestor = useContext(TextAncestorContext);
553
+ if (hasTextAncestor) {
554
+ if (isPressable) {
555
+ return (
556
+ <NativePressableVirtualText
557
+ ref={forwardedRef}
558
+ textProps={{
559
+ ...restProps,
560
+ accessibilityElementsHidden: _accessibilityElementsHidden,
561
+ accessibilityLabel: _accessibilityLabel,
562
+ accessibilityState: _accessibilityState,
563
+ importantForAccessibility: _importantForAccessibility,
564
+ // #[ Win32
565
+ accessibilityControls: _accessibilityControls,
566
+ accessibilityDescribedBy: _accessibilityDescribedBy,
567
+ accessibilityDescription: _accessibilityDescription,
568
+ accessibilityLevel: _accessibilityLevel,
569
+ accessibilityPositionInSet: _accessibilityPositionInSet,
570
+ accessibilitySetSize: _accessibilitySetSize,
571
+ // #] Win32
572
+ nativeID: _nativeID,
573
+ numberOfLines: _numberOfLines,
574
+ selectable: _selectable,
575
+ selectionColor: _selectionColor,
576
+ style: _style,
577
+ disabled: disabled,
578
+ children,
579
+ }}
580
+ textPressabilityProps={{
581
+ onLongPress,
582
+ onPress,
583
+ onPressIn,
584
+ onPressOut,
585
+ onResponderGrant,
586
+ onResponderMove,
587
+ onResponderRelease,
588
+ onResponderTerminate,
589
+ onResponderTerminationRequest,
590
+ onStartShouldSetResponder,
591
+ pressRetentionOffset,
592
+ suppressHighlighting,
593
+ }}
594
+ />
595
+ );
596
+ }
597
+
598
+ return (
599
+ <NativeVirtualText
600
+ {...restProps}
601
+ accessibilityElementsHidden={_accessibilityElementsHidden}
602
+ accessibilityLabel={_accessibilityLabel}
603
+ accessibilityState={_accessibilityState}
604
+ importantForAccessibility={_importantForAccessibility}
605
+ // #[ Win32
606
+ accessibilityControls={_accessibilityControls}
607
+ accessibilityDescribedBy={_accessibilityDescribedBy}
608
+ accessibilityDescription={_accessibilityDescription}
609
+ accessibilityLevel={_accessibilityLevel}
610
+ accessibilityPositionInSet={_accessibilityPositionInSet}
611
+ accessibilitySetSize={_accessibilitySetSize}
612
+ // #] Win32
613
+ nativeID={_nativeID}
614
+ numberOfLines={_numberOfLines}
615
+ ref={forwardedRef}
616
+ selectable={_selectable}
617
+ selectionColor={_selectionColor}
618
+ style={_style}
619
+ disabled={disabled}>
620
+ {children}
621
+ </NativeVirtualText>
622
+ );
188
623
  }
189
624
 
190
- if (overrides != null) {
191
- // $FlowFixMe[incompatible-type]
192
- _style = [_style, overrides];
625
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
626
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
627
+ if (
628
+ _disabled !== _accessibilityStateDisabled &&
629
+ ((_disabled != null && _disabled !== false) ||
630
+ (_accessibilityStateDisabled != null &&
631
+ _accessibilityStateDisabled !== false))
632
+ ) {
633
+ _accessibilityState = {..._accessibilityState, disabled: _disabled};
193
634
  }
194
- }
195
635
 
196
- const _nativeID = id ?? nativeID;
636
+ const _accessible = Platform.select({
637
+ ios: accessible !== false,
638
+ android:
639
+ accessible == null
640
+ ? onPress != null || onLongPress != null
641
+ : accessible,
642
+ default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
643
+ });
197
644
 
198
- const hasTextAncestor = useContext(TextAncestor);
199
- if (hasTextAncestor) {
645
+ let nativeText = null;
200
646
  if (isPressable) {
201
- return (
202
- <NativePressableVirtualText
647
+ nativeText = (
648
+ <NativePressableText
203
649
  ref={forwardedRef}
204
650
  textProps={{
205
651
  ...restProps,
652
+ accessibilityElementsHidden: _accessibilityElementsHidden,
206
653
  accessibilityLabel: _accessibilityLabel,
207
654
  accessibilityState: _accessibilityState,
208
- accessibilityControls: _accessibilityControls, // Win32
209
- accessibilityDescribedBy: _accessibilityDescribedBy, // Win32
210
- accessibilityDescription: _accessibilityDescription, // Win32
211
- accessibilityLevel: _accessibilityLevel, // Win32
212
- accessibilityPositionInSet: _accessibilityPositionInSet, // Win32
213
- accessibilitySetSize: _accessibilitySetSize, // Win32
655
+ accessible: _accessible,
656
+ allowFontScaling: allowFontScaling !== false,
657
+ disabled: _disabled,
658
+ ellipsizeMode: ellipsizeMode ?? 'tail',
659
+ importantForAccessibility: _importantForAccessibility,
214
660
  nativeID: _nativeID,
215
661
  numberOfLines: _numberOfLines,
216
662
  selectable: _selectable,
217
663
  selectionColor: _selectionColor,
218
664
  style: _style,
219
- disabled: disabled,
220
665
  children,
221
666
  }}
222
667
  textPressabilityProps={{
@@ -235,135 +680,63 @@ const TextImpl: component(
235
680
  }}
236
681
  />
237
682
  );
683
+ } else {
684
+ nativeText = (
685
+ <NativeText
686
+ {...restProps}
687
+ accessibilityElementsHidden={_accessibilityElementsHidden}
688
+ accessibilityLabel={_accessibilityLabel}
689
+ accessibilityState={_accessibilityState}
690
+ accessible={_accessible}
691
+ allowFontScaling={allowFontScaling !== false}
692
+ disabled={_disabled}
693
+ ellipsizeMode={ellipsizeMode ?? 'tail'}
694
+ importantForAccessibility={_importantForAccessibility}
695
+ nativeID={_nativeID}
696
+ numberOfLines={_numberOfLines}
697
+ ref={forwardedRef}
698
+ selectable={_selectable}
699
+ selectionColor={_selectionColor}
700
+ style={_style}>
701
+ {children}
702
+ </NativeText>
703
+ );
238
704
  }
239
705
 
240
- return (
241
- <NativeVirtualText
242
- {...restProps}
243
- accessibilityLabel={_accessibilityLabel}
244
- accessibilityState={_accessibilityState}
245
- accessibilityControls={_accessibilityControls} // Win32
246
- accessibilityDescribedBy={_accessibilityDescribedBy} // Win32
247
- accessibilityDescription={_accessibilityDescription} // Win32
248
- accessibilityLevel={_accessibilityLevel} // Win32
249
- accessibilityPositionInSet={_accessibilityPositionInSet} // Win32
250
- accessibilitySetSize={_accessibilitySetSize} // Win32
251
- nativeID={_nativeID}
252
- numberOfLines={_numberOfLines}
253
- ref={forwardedRef}
254
- selectable={_selectable}
255
- selectionColor={_selectionColor}
256
- style={_style}
257
- disabled={disabled}>
258
- {children}
259
- </NativeVirtualText>
260
- );
261
- }
262
-
263
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
264
- // falsy states we need to update the accessibilityState object to use the disabled prop.
265
- if (
266
- _disabled !== _accessibilityStateDisabled &&
267
- ((_disabled != null && _disabled !== false) ||
268
- (_accessibilityStateDisabled != null &&
269
- _accessibilityStateDisabled !== false))
270
- ) {
271
- _accessibilityState = {..._accessibilityState, disabled: _disabled};
272
- }
273
-
274
- const _accessible = Platform.select({
275
- ios: accessible !== false,
276
- android:
277
- accessible == null ? onPress != null || onLongPress != null : accessible,
278
- default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
279
- });
280
-
281
- let nativeText = null;
282
- if (isPressable) {
283
- nativeText = (
284
- <NativePressableText
285
- ref={forwardedRef}
286
- textProps={{
287
- ...restProps,
288
- accessibilityLabel: _accessibilityLabel,
289
- accessibilityState: _accessibilityState,
290
- accessible: _accessible,
291
- allowFontScaling: allowFontScaling !== false,
292
- disabled: _disabled,
293
- ellipsizeMode: ellipsizeMode ?? 'tail',
294
- nativeID: _nativeID,
295
- numberOfLines: _numberOfLines,
296
- selectable: _selectable,
297
- selectionColor: _selectionColor,
298
- style: _style,
299
- children,
300
- }}
301
- textPressabilityProps={{
302
- onLongPress,
303
- onPress,
304
- onPressIn,
305
- onPressOut,
306
- onResponderGrant,
307
- onResponderMove,
308
- onResponderRelease,
309
- onResponderTerminate,
310
- onResponderTerminationRequest,
311
- onStartShouldSetResponder,
312
- pressRetentionOffset,
313
- suppressHighlighting,
314
- }}
315
- />
316
- );
317
- } else {
318
- nativeText = (
319
- <NativeText
320
- {...restProps}
321
- accessibilityLabel={_accessibilityLabel}
322
- accessibilityState={_accessibilityState}
323
- accessible={_accessible}
324
- allowFontScaling={allowFontScaling !== false}
325
- disabled={_disabled}
326
- ellipsizeMode={ellipsizeMode ?? 'tail'}
327
- nativeID={_nativeID}
328
- numberOfLines={_numberOfLines}
329
- ref={forwardedRef}
330
- selectable={_selectable}
331
- selectionColor={_selectionColor}
332
- style={_style}>
333
- {children}
334
- </NativeText>
335
- );
336
- }
337
-
338
- if (children == null) {
339
- return nativeText;
340
- }
341
-
342
- // If the children do not contain a JSX element it would not be possible to have a
343
- // nested `Text` component so we can skip adding the `TextAncestor` context wrapper
344
- // which has a performance overhead. Since we do this for performance reasons we need
345
- // to keep the check simple to avoid regressing overall perf. For this reason the
346
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
347
- // to capture the majority of `Text` uses but also not make this check too expensive.
348
- if (Array.isArray(children) && children.length <= 3) {
349
- let hasNonTextChild = false;
350
- for (let child of children) {
351
- if (child != null && typeof child === 'object') {
352
- hasNonTextChild = true;
353
- break;
354
- }
706
+ if (children == null) {
707
+ return nativeText;
355
708
  }
356
- if (!hasNonTextChild) {
709
+
710
+ // If the children do not contain a JSX element it would not be possible to have a
711
+ // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
712
+ // which has a performance overhead. Since we do this for performance reasons we need
713
+ // to keep the check simple to avoid regressing overall perf. For this reason the
714
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
715
+ // to capture the majority of `Text` uses but also not make this check too expensive.
716
+ if (Array.isArray(children) && children.length <= 3) {
717
+ let hasNonTextChild = false;
718
+ for (let child of children) {
719
+ if (child != null && typeof child === 'object') {
720
+ hasNonTextChild = true;
721
+ break;
722
+ }
723
+ }
724
+ if (!hasNonTextChild) {
725
+ return nativeText;
726
+ }
727
+ } else if (typeof children !== 'object') {
357
728
  return nativeText;
358
729
  }
359
- } else if (typeof children !== 'object') {
360
- return nativeText;
361
- }
362
730
 
363
- return (
364
- <TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
365
- );
366
- };
731
+ return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
732
+ };
733
+ _TextImpl = TextImplLegacy;
734
+ }
735
+
736
+ const TextImpl: component(
737
+ ref?: React.RefSetter<TextForwardRef>,
738
+ ...props: TextProps
739
+ ) = _TextImpl;
367
740
 
368
741
  TextImpl.displayName = 'Text';
369
742