react-native-windows 0.84.0-preview.9 → 0.85.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (487) hide show
  1. package/.flowconfig +1 -5
  2. package/Common/unicode.cpp +36 -0
  3. package/Common/unicode.h +8 -0
  4. package/Directory.Build.props +1 -16
  5. package/Directory.Build.targets +12 -4
  6. package/Folly/ThreadNameStub.cpp +4 -6
  7. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
  8. package/Libraries/Animated/Animated.d.ts +8 -1
  9. package/Libraries/Animated/AnimatedEvent.js +4 -4
  10. package/Libraries/Animated/AnimatedImplementation.js +2 -2
  11. package/Libraries/Animated/animations/Animation.js +3 -3
  12. package/Libraries/Animated/animations/DecayAnimation.js +4 -4
  13. package/Libraries/Animated/animations/SpringAnimation.js +5 -5
  14. package/Libraries/Animated/animations/TimingAnimation.js +5 -5
  15. package/Libraries/Animated/createAnimatedComponent.js +7 -7
  16. package/Libraries/Animated/nodes/AnimatedColor.js +2 -2
  17. package/Libraries/Animated/nodes/AnimatedInterpolation.js +12 -12
  18. package/Libraries/Animated/nodes/AnimatedNode.js +3 -3
  19. package/Libraries/Animated/nodes/AnimatedObject.js +3 -3
  20. package/Libraries/Animated/nodes/AnimatedProps.js +6 -6
  21. package/Libraries/Animated/nodes/AnimatedStyle.js +7 -7
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +13 -13
  23. package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
  24. package/Libraries/Animated/nodes/AnimatedValueXY.js +1 -1
  25. package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
  26. package/Libraries/Animated/useAnimatedColor.d.ts +15 -0
  27. package/Libraries/Animated/useAnimatedColor.js +25 -0
  28. package/Libraries/Animated/useAnimatedValueXY.d.ts +15 -0
  29. package/Libraries/Animated/useAnimatedValueXY.js +26 -0
  30. package/Libraries/AppState/AppState.js +1 -1
  31. package/Libraries/BatchedBridge/MessageQueue.js +3 -3
  32. package/Libraries/BatchedBridge/NativeModules.js +12 -10
  33. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +30 -26
  34. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.windows.js +34 -30
  35. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +2 -2
  36. package/Libraries/Components/Button.js +2 -2
  37. package/Libraries/Components/Button.windows.js +2 -2
  38. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +2 -2
  39. package/Libraries/Components/Keyboard/Keyboard.js +6 -6
  40. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -1
  41. package/Libraries/Components/LayoutConformance/LayoutConformance.js +1 -1
  42. package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
  43. package/Libraries/Components/Pressable/Pressable.d.ts +5 -0
  44. package/Libraries/Components/Pressable/Pressable.js +3 -3
  45. package/Libraries/Components/Pressable/Pressable.windows.js +3 -3
  46. package/Libraries/Components/Pressable/useAndroidRippleForView.js +4 -4
  47. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +1 -1
  48. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +3 -3
  49. package/Libraries/Components/RefreshControl/RefreshControl.js +5 -5
  50. package/Libraries/Components/RefreshControl/RefreshControl.windows.js +5 -5
  51. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +8 -12
  52. package/Libraries/Components/ScrollView/ScrollView.d.ts +9 -0
  53. package/Libraries/Components/ScrollView/ScrollView.js +19 -9
  54. package/Libraries/Components/ScrollView/ScrollView.windows.js +19 -9
  55. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +8 -18
  56. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +8 -18
  57. package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +4 -3
  58. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  59. package/Libraries/Components/StaticRenderer.js +1 -1
  60. package/Libraries/Components/StatusBar/StatusBar.js +8 -8
  61. package/Libraries/Components/Switch/Switch.js +3 -3
  62. package/Libraries/Components/Switch/Switch.windows.js +3 -3
  63. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +33 -48
  64. package/Libraries/Components/TextInput/InputAccessoryView.js +1 -1
  65. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +6 -11
  66. package/Libraries/Components/TextInput/TextInput.flow.js +21 -20
  67. package/Libraries/Components/TextInput/TextInput.flow.windows.js +23 -22
  68. package/Libraries/Components/TextInput/TextInput.js +8 -4
  69. package/Libraries/Components/TextInput/TextInput.windows.js +3 -4
  70. package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +33 -48
  71. package/Libraries/Components/Touchable/PooledClass.js +1 -1
  72. package/Libraries/Components/Touchable/Touchable.js +2 -2
  73. package/Libraries/Components/Touchable/Touchable.windows.js +2 -2
  74. package/Libraries/Components/Touchable/TouchableBounce.js +4 -4
  75. package/Libraries/Components/Touchable/TouchableBounce.windows.js +4 -4
  76. package/Libraries/Components/Touchable/TouchableHighlight.js +8 -8
  77. package/Libraries/Components/Touchable/TouchableHighlight.windows.js +9 -9
  78. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +7 -7
  79. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +7 -7
  80. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -4
  81. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +4 -4
  82. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -1
  83. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +1 -1
  84. package/Libraries/Components/UnimplementedViews/UnimplementedView.js +1 -1
  85. package/Libraries/Components/View/ReactNativeStyleAttributes.js +68 -31
  86. package/Libraries/Components/View/View.windows.js +1 -1
  87. package/Libraries/Components/View/ViewAccessibility.js +7 -7
  88. package/Libraries/Components/View/ViewAccessibility.windows.js +7 -7
  89. package/Libraries/Components/View/ViewPropTypes.js +14 -14
  90. package/Libraries/Components/View/ViewPropTypes.windows.js +18 -16
  91. package/Libraries/Core/Devtools/parseHermesStack.js +8 -8
  92. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -2
  93. package/Libraries/Core/ExceptionsManager.js +2 -2
  94. package/Libraries/Core/ExtendedError.js +3 -3
  95. package/Libraries/Core/RawEventEmitter.js +1 -1
  96. package/Libraries/Core/ReactNativeVersion.js +2 -2
  97. package/Libraries/Core/Timers/JSTimers.js +3 -2
  98. package/Libraries/Core/setUpDeveloperTools.js +1 -1
  99. package/Libraries/Core/setUpErrorHandling.js +4 -2
  100. package/Libraries/Core/setUpReactDevTools.js +23 -6
  101. package/Libraries/Core/setUpSegmentFetcher.js +1 -1
  102. package/Libraries/Debugging/DebuggingOverlay.js +2 -2
  103. package/Libraries/EventEmitter/NativeEventEmitter.js +7 -9
  104. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +1 -1
  105. package/Libraries/Image/AssetSourceResolver.js +1 -1
  106. package/Libraries/Image/AssetSourceResolver.windows.js +1 -1
  107. package/Libraries/Image/Image.android.js +172 -306
  108. package/Libraries/Image/ImageProps.js +9 -11
  109. package/Libraries/Image/ImageSource.js +2 -2
  110. package/Libraries/Image/ImageSourceUtils.js +8 -4
  111. package/Libraries/Image/ImageTypes.flow.js +2 -2
  112. package/Libraries/Image/ImageViewNativeComponent.js +7 -16
  113. package/Libraries/Image/nativeImageSource.js +1 -1
  114. package/Libraries/Interaction/InteractionManager.js +5 -4
  115. package/Libraries/Interaction/PanResponder.js +1 -1
  116. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
  117. package/Libraries/Linking/Linking.js +1 -1
  118. package/Libraries/Lists/FlatList.js +3 -3
  119. package/Libraries/Lists/SectionList.js +1 -1
  120. package/Libraries/Lists/SectionListModern.js +2 -2
  121. package/Libraries/LogBox/Data/LogBoxData.js +38 -24
  122. package/Libraries/LogBox/Data/LogBoxLog.js +43 -112
  123. package/Libraries/LogBox/Data/parseLogBoxLog.js +21 -117
  124. package/Libraries/LogBox/LogBox.js +42 -19
  125. package/Libraries/LogBox/LogBoxInspectorContainer.js +2 -2
  126. package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
  127. package/Libraries/LogBox/UI/LogBoxButton.js +14 -16
  128. package/Libraries/LogBox/UI/LogBoxInspector.js +2 -2
  129. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -9
  130. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.windows.js +6 -9
  131. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -1
  132. package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +1 -1
  133. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  134. package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +1 -1
  135. package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +1 -1
  136. package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +10 -15
  137. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +25 -18
  138. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.windows.js +15 -16
  139. package/Libraries/LogBox/UI/LogBoxInspectorSection.js +5 -7
  140. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +8 -10
  141. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +8 -6
  142. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.windows.js +3 -5
  143. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +17 -29
  144. package/Libraries/LogBox/UI/LogBoxMessage.js +28 -37
  145. package/Libraries/LogBox/UI/LogBoxNotification.js +1 -1
  146. package/Libraries/Modal/Modal.d.ts +4 -0
  147. package/Libraries/Modal/Modal.js +3 -3
  148. package/Libraries/Modal/Modal.windows.js +7 -3
  149. package/Libraries/NativeComponent/BaseViewConfig.android.js +28 -52
  150. package/Libraries/NativeComponent/BaseViewConfig.ios.js +19 -21
  151. package/Libraries/NativeComponent/BaseViewConfig.windows.js +26 -17
  152. package/Libraries/Network/RCTNetworking.android.js +1 -1
  153. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  154. package/Libraries/Network/RCTNetworking.js.flow +1 -1
  155. package/Libraries/Network/RCTNetworking.windows.js +1 -1
  156. package/Libraries/Network/RCTNetworkingEventDefinitions.flow.js +1 -1
  157. package/Libraries/Network/XMLHttpRequest.js +1 -1
  158. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -3
  159. package/Libraries/Pressability/Pressability.js +5 -5
  160. package/Libraries/Pressability/Pressability.windows.js +5 -5
  161. package/Libraries/Pressability/PressabilityDebug.js +1 -1
  162. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
  163. package/Libraries/Pressability/usePressability.js +3 -14
  164. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  165. package/Libraries/ReactNative/AppContainer-dev.js +18 -1
  166. package/Libraries/ReactNative/AppContainer.js +1 -1
  167. package/Libraries/ReactNative/AppRegistry.flow.js +2 -2
  168. package/Libraries/ReactNative/AppRegistryImpl.js +2 -2
  169. package/Libraries/ReactNative/FabricUIManager.js +1 -1
  170. package/Libraries/ReactNative/RendererImplementation.js +4 -4
  171. package/Libraries/ReactNative/UIManagerProperties.js +1 -1
  172. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +3 -2
  173. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -2
  174. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -2
  175. package/Libraries/Renderer/shims/ReactFabric.js +1 -3
  176. package/Libraries/Renderer/shims/ReactFeatureFlags.js +1 -3
  177. package/Libraries/Renderer/shims/ReactNative.js +3 -2
  178. package/Libraries/Renderer/shims/ReactNativeTypes.js +1 -3
  179. package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +1 -3
  180. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +1 -3
  181. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +1 -3
  182. package/Libraries/StyleSheet/PointPropType.js +1 -1
  183. package/Libraries/StyleSheet/Rect.js +1 -1
  184. package/Libraries/StyleSheet/StyleSheet.d.ts +0 -5
  185. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  186. package/Libraries/StyleSheet/StyleSheet.js.flow +1 -1
  187. package/Libraries/StyleSheet/StyleSheetExports.js +16 -25
  188. package/Libraries/StyleSheet/StyleSheetExports.js.flow +2 -7
  189. package/Libraries/StyleSheet/StyleSheetTypes.js +33 -35
  190. package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +5 -5
  191. package/Libraries/StyleSheet/private/_TransformStyle.js +7 -7
  192. package/Libraries/StyleSheet/processBackgroundImage.js +7 -7
  193. package/Libraries/StyleSheet/processBackgroundPosition.js +4 -4
  194. package/Libraries/StyleSheet/processBackgroundRepeat.js +4 -4
  195. package/Libraries/StyleSheet/processBackgroundSize.js +4 -4
  196. package/Libraries/StyleSheet/processBoxShadow.js +44 -4
  197. package/Libraries/StyleSheet/processColorArray.js +2 -2
  198. package/Libraries/StyleSheet/processFilter.js +2 -2
  199. package/Libraries/Text/Text.js +295 -627
  200. package/Libraries/Text/Text.windows.js +342 -717
  201. package/Libraries/Text/TextNativeComponent.js +14 -7
  202. package/Libraries/Text/TextProps.js +4 -4
  203. package/Libraries/Text/TextProps.windows.js +4 -4
  204. package/Libraries/Types/CodegenTypes.js +1 -1
  205. package/Libraries/Types/CoreEventTypes.js +21 -21
  206. package/Libraries/Types/CoreEventTypes.windows.js +21 -21
  207. package/Libraries/Types/ReactDevToolsTypes.js +2 -2
  208. package/Libraries/Utilities/Appearance.js +6 -1
  209. package/Libraries/Utilities/Dimensions.js +1 -1
  210. package/Libraries/Utilities/HMRClient.js +32 -5
  211. package/Libraries/Utilities/IPerformanceLogger.js +4 -4
  212. package/Libraries/Utilities/codegenNativeCommands.js +4 -4
  213. package/Libraries/Utilities/codegenNativeComponent.d.ts +2 -0
  214. package/Libraries/Utilities/codegenNativeComponent.js +2 -2
  215. package/Libraries/Utilities/logError.js +1 -1
  216. package/Libraries/Utilities/stringifySafe.js +3 -3
  217. package/Libraries/Utilities/useMergeRefs.js +2 -2
  218. package/Libraries/vendor/core/ErrorUtils.js +4 -4
  219. package/Libraries/vendor/emitter/EventEmitter.js +16 -20
  220. package/Microsoft.ReactNative/CallInvoker.cpp +14 -4
  221. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +1 -1
  222. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +2 -2
  223. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +1 -1
  224. package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +73 -97
  225. package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.h +4 -1
  226. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +0 -1
  227. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +5 -0
  228. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +94 -26
  229. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +11 -0
  230. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +135 -18
  231. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +10 -0
  232. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +7 -2
  233. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +2 -0
  234. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +63 -15
  235. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +9 -5
  236. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +28 -6
  237. package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +1 -1
  238. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
  239. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +1 -1
  240. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +80 -0
  241. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.h +17 -0
  242. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +11 -0
  243. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +1 -0
  244. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +3 -0
  245. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +0 -3
  246. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +3 -8
  247. package/Microsoft.ReactNative/IReactPackageBuilder.idl +6 -0
  248. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +4 -63
  249. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +1 -26
  250. package/Microsoft.ReactNative/Modules/AlertModule.cpp +2 -1
  251. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +2 -17
  252. package/Microsoft.ReactNative/Modules/AppStateModule.h +0 -4
  253. package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +0 -2
  254. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +16 -15
  255. package/Microsoft.ReactNative/Modules/AppearanceModule.h +5 -1
  256. package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +2 -7
  257. package/Microsoft.ReactNative/Modules/DeviceInfoModule.h +0 -1
  258. package/Microsoft.ReactNative/Modules/I18nManagerModule.h +4 -4
  259. package/Microsoft.ReactNative/QuirkSettings.cpp +0 -133
  260. package/Microsoft.ReactNative/QuirkSettings.h +0 -43
  261. package/Microsoft.ReactNative/QuirkSettings.idl +0 -41
  262. package/Microsoft.ReactNative/ReactHost/CrashManager.cpp +0 -4
  263. package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -2
  264. package/Microsoft.ReactNative/ReactHost/React.h +0 -5
  265. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +0 -1
  266. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +3 -26
  267. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +0 -5
  268. package/Microsoft.ReactNative/ReactHost/React_Win.h +0 -2
  269. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +3 -0
  270. package/Microsoft.ReactNative/ReactPackageBuilder.cpp +7 -0
  271. package/Microsoft.ReactNative/ReactPackageBuilder.h +1 -0
  272. package/Microsoft.ReactNative/RedBox.cpp +0 -9
  273. package/Microsoft.ReactNative/RedBoxHandler.cpp +0 -4
  274. package/Microsoft.ReactNative/TurboModulesProvider.cpp +5 -10
  275. package/Microsoft.ReactNative/TurboModulesProvider.h +2 -0
  276. package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +33 -25
  277. package/Microsoft.ReactNative/Utils/LocalBundleReader.h +5 -3
  278. package/Microsoft.ReactNative/Utils/ValueUtils.cpp +1 -1
  279. package/Microsoft.ReactNative.Cxx/CppWinRTIncludes.h +0 -7
  280. package/Microsoft.ReactNative.Cxx/DesktopWindowBridge.h +0 -22
  281. package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +8 -2
  282. package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +36 -20
  283. package/Microsoft.ReactNative.Cxx/NamespaceRedirect.h +0 -3
  284. package/Microsoft.ReactNative.Cxx/NativeModules.h +8 -2
  285. package/Microsoft.ReactNative.Cxx/XamlUtils.h +0 -9
  286. package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +3 -3
  287. package/Microsoft.ReactNative.Managed/ReactContext.cs +0 -9
  288. package/Microsoft.ReactNative.Managed.CodeGen/Microsoft.ReactNative.Managed.CodeGen.csproj +10 -10
  289. package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Debug.pubxml +1 -1
  290. package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Release.pubxml +1 -1
  291. package/PropertySheets/Autolink.props +1 -1
  292. package/PropertySheets/Bundle.props +1 -1
  293. package/PropertySheets/Codegen.props +1 -1
  294. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  295. package/PropertySheets/JSEngine.props +1 -1
  296. package/PropertySheets/NuGet.LockFile.props +8 -0
  297. package/PropertySheets/React.Cpp.props +8 -7
  298. package/PropertySheets/ReactNativeArchitecture.props +6 -24
  299. package/PropertySheets/WinUI.props +2 -2
  300. package/ReactCommon/ReactCommon.vcxproj +5 -6
  301. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +1 -1
  302. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +15 -4
  303. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +13 -0
  304. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/defaults/DefaultTurboModules.cpp +69 -0
  305. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/animationbackend/AnimatedPropSerializer.cpp +717 -0
  306. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +10 -10
  307. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +2 -21
  308. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/TouchEventEmitter.cpp +151 -0
  309. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/TouchEventEmitter.h +50 -0
  310. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/mapbuffer/MapBuffer.cpp +178 -0
  311. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManager.cpp +69 -39
  312. package/Scripts/JustMyXaml.ps1 +8 -8
  313. package/Scripts/OfficeReact.Win32.nuspec +0 -1
  314. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -39
  315. package/Scripts/UnitTest.ps1 +3 -1
  316. package/Scripts/creaternwapp.cmd +1 -9
  317. package/Scripts/creaternwlib.cmd +4 -24
  318. package/Scripts/rnw-dependencies.ps1 +15 -16
  319. package/Shared/DevSettings.h +0 -3
  320. package/Shared/DevSupportManager.cpp +55 -48
  321. package/Shared/DevSupportManager.h +0 -1
  322. package/Shared/Modules/IWebSocketModuleContentHandler.h +15 -0
  323. package/Shared/Modules/WebSocketModule.cpp +8 -3
  324. package/Shared/Networking/DefaultBlobResource.cpp +37 -0
  325. package/Shared/Networking/DefaultBlobResource.h +12 -0
  326. package/Shared/Networking/WinRTWebSocketResource.cpp +23 -408
  327. package/Shared/Networking/WinRTWebSocketResource.h +8 -120
  328. package/Shared/Shared.vcxitems +63 -38
  329. package/Shared/Shared.vcxitems.filters +54 -0
  330. package/Shared/Utils.cpp +0 -88
  331. package/Shared/Utils.h +0 -14
  332. package/Shared/WebSocketResourceFactory.cpp +28 -0
  333. package/Shared/tracing/fbsystrace.h +1 -0
  334. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +172 -160
  335. package/codegen/react/components/rnwcore/ModalHostView.g.h +8 -0
  336. package/codegen/react/components/rnwcore/Props.cpp +17 -7
  337. package/codegen/react/components/rnwcore/Props.h +3 -1
  338. package/codegen/react/components/rnwcore/VirtualViewExperimental.g.h +4 -4
  339. package/codegen/rnwcoreJSI.h +93 -77
  340. package/index.js +9 -0
  341. package/index.windows.js +9 -0
  342. package/jest/RefreshControlMock.js +2 -2
  343. package/jest/assetFileTransformer.js +8 -3
  344. package/jest/mockComponent.js +3 -4
  345. package/jest/mockNativeComponent.js +1 -1
  346. package/jest/mocks/ActivityIndicator.js +2 -2
  347. package/jest/mocks/Image.js +2 -2
  348. package/jest/mocks/Modal.js +2 -2
  349. package/jest/mocks/RefreshControl.js +3 -3
  350. package/jest/mocks/RendererProxy.js +2 -2
  351. package/jest/mocks/ScrollView.js +5 -5
  352. package/jest/mocks/Text.js +2 -2
  353. package/jest/mocks/TextInput.js +2 -2
  354. package/jest/mocks/View.js +2 -2
  355. package/jest/mocks/ViewNativeComponent.js +1 -1
  356. package/jest/mocks/requireNativeComponent.js +1 -1
  357. package/jest/mocks/useColorScheme.js +1 -1
  358. package/jest/setup.js +68 -31
  359. package/just-task.js +13 -2
  360. package/package.json +25 -20
  361. package/src/private/animated/NativeAnimatedHelper.js +2 -2
  362. package/src/private/animated/createAnimatedPropsMemoHook.js +19 -19
  363. package/src/private/components/virtualview/VirtualView.js +14 -21
  364. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +11 -10
  365. package/src/private/components/virtualview/VirtualViewNativeComponent.js +4 -4
  366. package/src/private/devsupport/devmenu/elementinspector/BorderBox.js +2 -2
  367. package/src/private/devsupport/devmenu/elementinspector/BoxInspector.js +3 -3
  368. package/src/private/devsupport/devmenu/elementinspector/ElementBox.js +4 -4
  369. package/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +1 -1
  370. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +39 -17
  371. package/src/private/devsupport/devmenu/elementinspector/InspectorOverlay.js +15 -3
  372. package/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +2 -2
  373. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -8
  374. package/src/private/devsupport/devmenu/elementinspector/StyleInspector.js +1 -1
  375. package/src/private/devsupport/devmenu/elementinspector/resolveBoxStyle.js +1 -1
  376. package/src/private/devsupport/devmenu/elementinspector/useExternalInspection.js +102 -0
  377. package/src/private/devsupport/rndevtools/FuseboxSessionObserver.js +12 -25
  378. package/src/private/devsupport/rndevtools/GlobalStateObserver.js +56 -0
  379. package/src/private/devsupport/rndevtools/TracingStateObserver.js +28 -0
  380. package/src/private/featureflags/ReactNativeFeatureFlags.js +71 -79
  381. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +2 -2
  382. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +14 -12
  383. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
  384. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
  385. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +3 -3
  386. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
  387. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
  388. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +2 -2
  389. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +3 -3
  390. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
  391. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
  392. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
  393. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +7 -3
  394. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
  395. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +2 -2
  396. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
  397. package/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +1 -1
  398. package/src/private/styles/composeStyles.js +1 -1
  399. package/src/private/utilities/toError.js +27 -0
  400. package/src/private/utilities/toExtendedError.js +30 -0
  401. package/src/private/webapis/dom/events/Event.js +1 -1
  402. package/src/private/webapis/dom/events/EventHandlerAttributes.js +2 -2
  403. package/src/private/webapis/dom/events/EventTarget.js +3 -3
  404. package/src/private/webapis/dom/events/internals/EventInternals.js +2 -2
  405. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  406. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +2 -2
  407. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +14 -14
  408. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +2 -2
  409. package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
  410. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  411. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +8 -8
  412. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +6 -6
  413. package/src/private/webapis/mutationobserver/MutationObserver.js +2 -2
  414. package/src/private/webapis/mutationobserver/MutationRecord.js +2 -2
  415. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  416. package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +3 -3
  417. package/src/private/webapis/performance/LongTasks.js +3 -3
  418. package/src/private/webapis/performance/Performance.js +4 -4
  419. package/src/private/webapis/performance/PerformanceEntry.js +1 -1
  420. package/src/private/webapis/performance/PerformanceObserver.js +2 -2
  421. package/src/private/webapis/performance/specs/NativePerformance.js +8 -8
  422. package/src/private/webapis/structuredClone/structuredClone.js +2 -2
  423. package/src/types/globals.d.ts +4 -4
  424. package/template/cpp-lib/proj/MyLib.sln +0 -33
  425. package/template/cpp-lib/proj/MyLib.vcxproj +1 -1
  426. package/template/cs-lib/proj/MyLib.sln +0 -33
  427. package/template/metro.config.js +12 -2
  428. package/templates/cpp-app/metro.config.js +12 -2
  429. package/templates/cpp-app/windows/MyApp/MyApp.cpp +9 -6
  430. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +2 -2
  431. package/templates/cpp-app/windows/MyApp.sln +0 -33
  432. package/templates/cpp-lib/example/metro.config.js +12 -2
  433. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +2 -2
  434. package/templates/cpp-lib/windows/MyLib.sln +0 -33
  435. package/types/index.d.ts +2 -0
  436. package/Folly/.clang-format +0 -2
  437. package/Folly/Folly.natvis +0 -25
  438. package/Folly/Folly.vcxproj +0 -378
  439. package/Folly/Folly.vcxproj.filters +0 -558
  440. package/Folly/TEMP_UntilFollyUpdate/ConstexprMath.h +0 -978
  441. package/Folly/TEMP_UntilFollyUpdate/Conv.cpp +0 -1205
  442. package/Folly/TEMP_UntilFollyUpdate/chrono/Hardware.h +0 -155
  443. package/Folly/TEMP_UntilFollyUpdate/concurrency/CacheLocality.cpp +0 -633
  444. package/Folly/TEMP_UntilFollyUpdate/json/dynamic-inl.h +0 -1438
  445. package/Folly/TEMP_UntilFollyUpdate/json/json.cpp +0 -1118
  446. package/Folly/TEMP_UntilFollyUpdate/lang/SafeAssert.h +0 -188
  447. package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.cpp +0 -348
  448. package/Folly/TEMP_UntilFollyUpdate/lang/ToAscii.h +0 -182
  449. package/Folly/TEMP_UntilFollyUpdate/portability/Unistd.cpp +0 -33
  450. package/Folly/cgmanifest.json +0 -25
  451. package/Libraries/Components/View/ReactNativeViewAttributes.js +0 -60
  452. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +0 -64
  453. package/Libraries/Image/TextInlineImageNativeComponent.js +0 -49
  454. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper_emptyimpl.cpp +0 -75
  455. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +0 -27
  456. package/Microsoft.ReactNative/Fabric/Composition/Theme_emptyimpl.cpp +0 -81
  457. package/Microsoft.ReactNative/Modules/CreateModules.cpp +0 -24
  458. package/Microsoft.ReactNative/ReactSupport.cpp +0 -221
  459. package/Microsoft.ReactNative/ReactSupport.h +0 -13
  460. package/Microsoft.ReactNative/Utils/UwpPreparedScriptStore.cpp +0 -107
  461. package/Microsoft.ReactNative/Utils/UwpPreparedScriptStore.h +0 -62
  462. package/Microsoft.ReactNative/Utils/UwpScriptStore.cpp +0 -56
  463. package/Microsoft.ReactNative/Utils/UwpScriptStore.h +0 -22
  464. package/Microsoft.ReactNative/XamlUIService.cpp +0 -68
  465. package/Microsoft.ReactNative/XamlUIService.h +0 -37
  466. package/Microsoft.ReactNative/XamlUIService.idl +0 -53
  467. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/CxxNativeModule.cpp +0 -259
  468. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/Instance.cpp +0 -381
  469. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSIndexedRAMBundle.cpp +0 -145
  470. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/MethodCall.cpp +0 -100
  471. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ModuleRegistry.cpp +0 -256
  472. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +0 -363
  473. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/RAMBundleRegistry.cpp +0 -93
  474. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/ReactMarker.cpp +0 -148
  475. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/TraceSection.h +0 -190
  476. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsiexecutor/jsireact/JSINativeModules.cpp +0 -123
  477. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleWithJSIBindings.cpp +0 -27
  478. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/webperformance/NativePerformance.cpp +0 -414
  479. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +0 -91
  480. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventDispatcher.cpp +0 -80
  481. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/EventQueueProcessor.cpp +0 -138
  482. package/fmt/.clang-format +0 -2
  483. package/fmt/cgmanifest.json +0 -15
  484. package/fmt/fmt.vcxproj +0 -153
  485. package/fmt/fmt.vcxproj.filters +0 -59
  486. package/fmt/pch.cpp +0 -4
  487. package/fmt/pch.h +0 -2
@@ -19,16 +19,21 @@ import * as PressabilityDebug from '../Pressability/PressabilityDebug';
19
19
  import usePressability from '../Pressability/usePressability';
20
20
  import flattenStyle from '../StyleSheet/flattenStyle';
21
21
  import processColor from '../StyleSheet/processColor';
22
+ import StyleSheet from '../StyleSheet/StyleSheet';
22
23
  import Platform from '../Utilities/Platform';
23
24
  import TextAncestorContext from './TextAncestorContext';
24
- import {NativeText, NativeVirtualText} from './TextNativeComponent';
25
+ import {
26
+ NativeSelectableText,
27
+ NativeText,
28
+ NativeVirtualText,
29
+ } from './TextNativeComponent';
25
30
  import * as React from 'react';
26
31
  import {useContext, useMemo, useState} from 'react';
27
32
 
28
33
  export type {TextProps} from './TextProps';
29
34
 
30
35
  type TextForwardRef = React.ElementRef<
31
- typeof NativeText | typeof NativeVirtualText,
36
+ typeof NativeText | typeof NativeVirtualText | typeof NativeSelectableText,
32
37
  >;
33
38
 
34
39
  /**
@@ -36,638 +41,305 @@ type TextForwardRef = React.ElementRef<
36
41
  *
37
42
  * @see https://reactnative.dev/docs/text
38
43
  */
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
- accessibilityRole,
49
- accessibilityState,
50
- allowFontScaling,
51
- 'aria-busy': ariaBusy,
52
- 'aria-checked': ariaChecked,
53
- 'aria-disabled': ariaDisabled,
54
- 'aria-expanded': ariaExpanded,
55
- 'aria-hidden': ariaHidden,
56
- 'aria-label': ariaLabel,
57
- 'aria-selected': ariaSelected,
58
- children,
59
- ellipsizeMode,
60
- disabled,
61
- id,
62
- nativeID,
63
- numberOfLines,
64
- onLongPress,
65
- onPress,
66
- onPressIn,
67
- onPressOut,
68
- onResponderGrant,
69
- onResponderMove,
70
- onResponderRelease,
71
- onResponderTerminate,
72
- onResponderTerminationRequest,
73
- onStartShouldSetResponder,
74
- pressRetentionOffset,
75
- role,
76
- selectable,
77
- selectionColor,
78
- suppressHighlighting,
79
- style,
80
- ...restProps
81
- }: {
82
- ref?: React.RefSetter<TextForwardRef>,
83
- ...TextProps,
84
- }) => {
85
- const processedProps = restProps as {
86
- ...NativeTextProps,
87
- };
88
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
89
- let _accessibilityState: ?TextProps['accessibilityState'] =
90
- accessibilityState;
91
- if (
92
- ariaBusy != null ||
93
- ariaChecked != null ||
94
- ariaDisabled != null ||
95
- ariaExpanded != null ||
96
- ariaSelected != null
97
- ) {
98
- if (_accessibilityState != null) {
99
- _accessibilityState = {
100
- busy: ariaBusy ?? _accessibilityState.busy,
101
- checked: ariaChecked ?? _accessibilityState.checked,
102
- disabled: ariaDisabled ?? _accessibilityState.disabled,
103
- expanded: ariaExpanded ?? _accessibilityState.expanded,
104
- selected: ariaSelected ?? _accessibilityState.selected,
105
- };
106
- } else {
107
- _accessibilityState = {
108
- busy: ariaBusy,
109
- checked: ariaChecked,
110
- disabled: ariaDisabled,
111
- expanded: ariaExpanded,
112
- selected: ariaSelected,
113
- };
114
- }
115
- }
116
-
117
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
118
- const _disabled = disabled ?? _accessibilityStateDisabled;
119
-
120
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
121
- // falsy states we need to update the accessibilityState object to use the disabled prop.
122
- if (
123
- _accessibilityState != null &&
124
- _disabled !== _accessibilityStateDisabled &&
125
- ((_disabled != null && _disabled !== false) ||
126
- (_accessibilityStateDisabled != null &&
127
- _accessibilityStateDisabled !== false))
128
- ) {
129
- _accessibilityState.disabled = _disabled;
130
- }
131
-
132
- if (ariaHidden !== undefined) {
133
- processedProps.accessibilityElementsHidden = ariaHidden;
134
- if (ariaHidden === true) {
135
- processedProps.importantForAccessibility = 'no-hide-descendants';
136
- }
137
- }
138
-
139
- const _accessible = Platform.select({
140
- ios: accessible !== false,
141
- android:
142
- accessible == null
143
- ? onPress != null || onLongPress != null
144
- : accessible,
145
- default: accessible,
146
- });
147
-
148
- const isPressable =
149
- (onPress != null ||
150
- onLongPress != null ||
151
- onStartShouldSetResponder != null) &&
152
- _disabled !== true;
153
-
154
- const shouldUseLinkRole =
155
- ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
156
- isPressable &&
157
- accessibilityRole == null &&
158
- role == null;
159
-
160
- const _accessibilityRole =
161
- accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
162
-
163
- const _role = shouldUseLinkRole ? undefined : role;
164
-
165
- // TODO: Move this processing to the view configuration.
166
- const _selectionColor =
167
- selectionColor != null ? processColor(selectionColor) : undefined;
168
-
169
- let _style = style;
170
- if (__DEV__) {
171
- if (PressabilityDebug.isEnabled() && onPress != null) {
172
- _style = [style, {color: 'magenta'}];
173
- }
174
- }
175
-
176
- let _numberOfLines = numberOfLines;
177
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
178
- if (__DEV__) {
179
- console.error(
180
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
181
- );
182
- }
183
- _numberOfLines = 0;
184
- }
185
-
186
- let _selectable = selectable;
187
-
188
- let processedStyle = flattenStyle<TextStyleProp>(_style);
189
- if (processedStyle != null) {
190
- let overrides: ?{...TextStyleInternal} = null;
191
- if (typeof processedStyle.fontWeight === 'number') {
192
- overrides = overrides || ({}: {...TextStyleInternal});
193
- overrides.fontWeight =
194
- // $FlowFixMe[incompatible-type]
195
- (String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
196
- }
197
-
198
- if (processedStyle.userSelect != null) {
199
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
200
- overrides = overrides || ({}: {...TextStyleInternal});
201
- overrides.userSelect = undefined;
202
- }
203
-
204
- if (processedStyle.verticalAlign != null) {
205
- overrides = overrides || ({}: {...TextStyleInternal});
206
- overrides.textAlignVertical =
207
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
208
- overrides.verticalAlign = undefined;
209
- }
210
-
211
- if (overrides != null) {
212
- // $FlowFixMe[incompatible-type]
213
- _style = [_style, overrides];
214
- }
215
- }
216
-
217
- const _nativeID = id ?? nativeID;
218
-
219
- if (_accessibilityLabel !== undefined) {
220
- processedProps.accessibilityLabel = _accessibilityLabel;
221
- }
222
- if (_accessibilityRole !== undefined) {
223
- processedProps.accessibilityRole = _accessibilityRole;
224
- }
225
- if (_accessibilityState !== undefined) {
226
- processedProps.accessibilityState = _accessibilityState;
227
- }
228
- if (_nativeID !== undefined) {
229
- processedProps.nativeID = _nativeID;
230
- }
231
- if (_numberOfLines !== undefined) {
232
- processedProps.numberOfLines = _numberOfLines;
233
- }
234
- if (_selectable !== undefined) {
235
- processedProps.selectable = _selectable;
236
- }
237
- if (_style !== undefined) {
238
- processedProps.style = _style;
239
- }
240
- if (_selectionColor !== undefined) {
241
- processedProps.selectionColor = _selectionColor;
242
- }
243
- if (_role !== undefined) {
244
- processedProps.role = _role;
245
- }
246
-
247
- let textPressabilityProps: ?TextPressabilityProps;
248
- if (isPressable) {
249
- textPressabilityProps = {
250
- onLongPress,
251
- onPress,
252
- onPressIn,
253
- onPressOut,
254
- onResponderGrant,
255
- onResponderMove,
256
- onResponderRelease,
257
- onResponderTerminate,
258
- onResponderTerminationRequest,
259
- onStartShouldSetResponder,
260
- pressRetentionOffset,
261
- suppressHighlighting,
44
+ const TextImpl: component(
45
+ ref?: React.RefSetter<TextForwardRef>,
46
+ ...props: TextProps
47
+ ) = ({
48
+ ref: forwardedRef,
49
+ accessible,
50
+ accessibilityLabel,
51
+ accessibilityRole,
52
+ accessibilityState,
53
+ allowFontScaling,
54
+ 'aria-busy': ariaBusy,
55
+ 'aria-checked': ariaChecked,
56
+ 'aria-disabled': ariaDisabled,
57
+ 'aria-expanded': ariaExpanded,
58
+ 'aria-hidden': ariaHidden,
59
+ 'aria-label': ariaLabel,
60
+ 'aria-selected': ariaSelected,
61
+ children,
62
+ ellipsizeMode,
63
+ disabled,
64
+ id,
65
+ nativeID,
66
+ numberOfLines,
67
+ onLongPress,
68
+ onPress,
69
+ onPressIn,
70
+ onPressOut,
71
+ onResponderGrant,
72
+ onResponderMove,
73
+ onResponderRelease,
74
+ onResponderTerminate,
75
+ onResponderTerminationRequest,
76
+ onStartShouldSetResponder,
77
+ pressRetentionOffset,
78
+ role,
79
+ selectable,
80
+ selectionColor,
81
+ suppressHighlighting,
82
+ style,
83
+ ...restProps
84
+ }: {
85
+ ref?: React.RefSetter<TextForwardRef>,
86
+ ...TextProps,
87
+ }) => {
88
+ const processedProps = restProps as {
89
+ ...NativeTextProps,
90
+ };
91
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
92
+ let _accessibilityState: ?TextProps['accessibilityState'] =
93
+ accessibilityState;
94
+ if (
95
+ ariaBusy != null ||
96
+ ariaChecked != null ||
97
+ ariaDisabled != null ||
98
+ ariaExpanded != null ||
99
+ ariaSelected != null
100
+ ) {
101
+ if (_accessibilityState != null) {
102
+ _accessibilityState = {
103
+ busy: ariaBusy ?? _accessibilityState.busy,
104
+ checked: ariaChecked ?? _accessibilityState.checked,
105
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
106
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
107
+ selected: ariaSelected ?? _accessibilityState.selected,
262
108
  };
263
- }
264
-
265
- const hasTextAncestor = useContext(TextAncestorContext);
266
- if (hasTextAncestor) {
267
- processedProps.disabled = disabled;
268
- processedProps.children = children;
269
- if (isPressable) {
270
- return (
271
- <NativePressableVirtualText
272
- ref={forwardedRef}
273
- textProps={processedProps}
274
- textPressabilityProps={textPressabilityProps ?? {}}
275
- />
276
- );
277
- }
278
- return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
279
- }
280
-
281
- let nativeText = null;
282
-
283
- processedProps.accessible = _accessible;
284
- processedProps.allowFontScaling = allowFontScaling !== false;
285
- processedProps.disabled = _disabled;
286
- processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
287
- processedProps.children = children;
288
-
289
- if (isPressable) {
290
- nativeText = (
291
- <NativePressableText
292
- ref={forwardedRef}
293
- textProps={processedProps}
294
- textPressabilityProps={textPressabilityProps ?? {}}
295
- />
296
- );
297
109
  } else {
298
- nativeText = <NativeText {...processedProps} ref={forwardedRef} />;
299
- }
300
-
301
- if (children == null) {
302
- return nativeText;
303
- }
304
-
305
- // If the children do not contain a JSX element it would not be possible to have a
306
- // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
307
- // which has a performance overhead. Since we do this for performance reasons we need
308
- // to keep the check simple to avoid regressing overall perf. For this reason the
309
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
310
- // to capture the majority of `Text` uses but also not make this check too expensive.
311
- if (Array.isArray(children) && children.length <= 3) {
312
- let hasNonTextChild = false;
313
- for (let child of children) {
314
- if (child != null && typeof child === 'object') {
315
- hasNonTextChild = true;
316
- break;
317
- }
318
- }
319
- if (!hasNonTextChild) {
320
- return nativeText;
321
- }
322
- } else if (typeof children !== 'object') {
323
- return nativeText;
110
+ _accessibilityState = {
111
+ busy: ariaBusy,
112
+ checked: ariaChecked,
113
+ disabled: ariaDisabled,
114
+ expanded: ariaExpanded,
115
+ selected: ariaSelected,
116
+ };
324
117
  }
325
-
326
- return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
327
- };
328
- _TextImpl = TextImplNoDefaultProps;
329
- } else {
330
- const TextImplLegacy: component(
331
- ref?: React.RefSetter<TextForwardRef>,
332
- ...props: TextProps
333
- ) = ({
334
- ref: forwardedRef,
335
- accessible,
336
- accessibilityElementsHidden,
337
- importantForAccessibility,
338
- accessibilityLabel,
339
- accessibilityRole,
340
- accessibilityState,
341
- allowFontScaling,
342
- 'aria-busy': ariaBusy,
343
- 'aria-checked': ariaChecked,
344
- 'aria-disabled': ariaDisabled,
345
- 'aria-expanded': ariaExpanded,
346
- 'aria-hidden': ariaHidden,
347
- 'aria-label': ariaLabel,
348
- 'aria-selected': ariaSelected,
349
- children,
350
- ellipsizeMode,
351
- disabled,
352
- id,
353
- nativeID,
354
- numberOfLines,
355
- onLongPress,
356
- onPress,
357
- onPressIn,
358
- onPressOut,
359
- onResponderGrant,
360
- onResponderMove,
361
- onResponderRelease,
362
- onResponderTerminate,
363
- onResponderTerminationRequest,
364
- onStartShouldSetResponder,
365
- pressRetentionOffset,
366
- role,
367
- selectable,
368
- selectionColor,
369
- suppressHighlighting,
370
- style,
371
- ...restProps
372
- }: {
373
- ref?: React.RefSetter<TextForwardRef>,
374
- ...TextProps,
375
- }) => {
376
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
377
-
378
- let _accessibilityState: ?TextProps['accessibilityState'] =
379
- accessibilityState;
380
- if (
381
- ariaBusy != null ||
382
- ariaChecked != null ||
383
- ariaDisabled != null ||
384
- ariaExpanded != null ||
385
- ariaSelected != null
386
- ) {
387
- if (_accessibilityState != null) {
388
- _accessibilityState = {
389
- busy: ariaBusy ?? _accessibilityState.busy,
390
- checked: ariaChecked ?? _accessibilityState.checked,
391
- disabled: ariaDisabled ?? _accessibilityState.disabled,
392
- expanded: ariaExpanded ?? _accessibilityState.expanded,
393
- selected: ariaSelected ?? _accessibilityState.selected,
394
- };
395
- } else {
396
- _accessibilityState = {
397
- busy: ariaBusy,
398
- checked: ariaChecked,
399
- disabled: ariaDisabled,
400
- expanded: ariaExpanded,
401
- selected: ariaSelected,
402
- };
403
- }
118
+ }
119
+
120
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
121
+ const _disabled = disabled ?? _accessibilityStateDisabled;
122
+
123
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
124
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
125
+ if (
126
+ _disabled !== _accessibilityStateDisabled &&
127
+ ((_disabled != null && _disabled !== false) ||
128
+ (_accessibilityStateDisabled != null &&
129
+ _accessibilityStateDisabled !== false))
130
+ ) {
131
+ if (_accessibilityState == null) {
132
+ _accessibilityState = {disabled};
133
+ } else {
134
+ _accessibilityState.disabled = _disabled;
404
135
  }
136
+ }
405
137
 
406
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
407
- const _disabled = disabled ?? _accessibilityStateDisabled;
408
-
409
- let _accessibilityElementsHidden =
410
- ariaHidden ?? accessibilityElementsHidden;
411
- let _importantForAccessibility = importantForAccessibility;
138
+ if (ariaHidden !== undefined) {
139
+ processedProps.accessibilityElementsHidden = ariaHidden;
412
140
  if (ariaHidden === true) {
413
- _importantForAccessibility = 'no-hide-descendants';
141
+ processedProps.importantForAccessibility = 'no-hide-descendants';
414
142
  }
143
+ }
415
144
 
416
- const isPressable =
417
- (onPress != null ||
418
- onLongPress != null ||
419
- onStartShouldSetResponder != null) &&
420
- _disabled !== true;
145
+ const _accessible = Platform.select({
146
+ ios: accessible !== false,
147
+ android:
148
+ accessible == null ? onPress != null || onLongPress != null : accessible,
149
+ default: accessible,
150
+ });
421
151
 
422
- const shouldUseLinkRole =
423
- ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
424
- isPressable &&
425
- accessibilityRole == null &&
426
- role == null;
152
+ const isPressable =
153
+ (onPress != null ||
154
+ onLongPress != null ||
155
+ onStartShouldSetResponder != null) &&
156
+ _disabled !== true;
427
157
 
428
- const _accessibilityRole =
429
- accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
158
+ const shouldUseLinkRole =
159
+ isPressable && accessibilityRole == null && role == null;
430
160
 
431
- const _role = shouldUseLinkRole ? undefined : role;
161
+ const _accessibilityRole =
162
+ accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
432
163
 
433
- // TODO: Move this processing to the view configuration.
434
- const _selectionColor =
435
- selectionColor != null ? processColor(selectionColor) : undefined;
164
+ const _role = shouldUseLinkRole ? undefined : role;
436
165
 
437
- let _style = style;
438
- if (__DEV__) {
439
- if (PressabilityDebug.isEnabled() && onPress != null) {
440
- _style = [style, {color: 'magenta'}];
441
- }
442
- }
166
+ // TODO: Move this processing to the view configuration.
167
+ const _selectionColor =
168
+ selectionColor != null ? processColor(selectionColor) : undefined;
443
169
 
444
- let _numberOfLines = numberOfLines;
445
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
446
- if (__DEV__) {
447
- console.error(
448
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
449
- );
450
- }
451
- _numberOfLines = 0;
170
+ let _style = style;
171
+ if (__DEV__) {
172
+ if (PressabilityDebug.isEnabled() && onPress != null) {
173
+ _style = [style, {color: 'magenta'}];
452
174
  }
175
+ }
453
176
 
454
- let _selectable = selectable;
455
-
456
- let processedStyle = flattenStyle<TextStyleProp>(_style);
457
- if (processedStyle != null) {
458
- let overrides: ?{...TextStyleInternal} = null;
459
- if (typeof processedStyle.fontWeight === 'number') {
460
- overrides = overrides || ({}: {...TextStyleInternal});
461
- overrides.fontWeight =
462
- // $FlowFixMe[incompatible-type]
463
- (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
464
- }
465
-
466
- if (processedStyle.userSelect != null) {
467
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
468
- overrides = overrides || ({}: {...TextStyleInternal});
469
- overrides.userSelect = undefined;
470
- }
177
+ let _numberOfLines = numberOfLines;
178
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
179
+ if (__DEV__) {
180
+ console.error(
181
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
182
+ );
183
+ }
184
+ _numberOfLines = 0;
185
+ }
471
186
 
472
- if (processedStyle.verticalAlign != null) {
473
- overrides = overrides || ({}: {...TextStyleInternal});
474
- overrides.textAlignVertical =
475
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
476
- overrides.verticalAlign = undefined;
477
- }
187
+ let _selectable = selectable;
478
188
 
479
- if (overrides != null) {
189
+ let processedStyle = flattenStyle<TextStyleProp>(_style);
190
+ if (processedStyle != null) {
191
+ let overrides: ?{...TextStyleInternal} = null;
192
+ if (typeof processedStyle.fontWeight === 'number') {
193
+ overrides = overrides || ({}: {...TextStyleInternal});
194
+ overrides.fontWeight =
480
195
  // $FlowFixMe[incompatible-type]
481
- _style = [_style, overrides];
482
- }
196
+ (String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
483
197
  }
484
198
 
485
- const _nativeID = id ?? nativeID;
486
-
487
- const hasTextAncestor = useContext(TextAncestorContext);
488
- if (hasTextAncestor) {
489
- if (isPressable) {
490
- return (
491
- <NativePressableVirtualText
492
- ref={forwardedRef}
493
- textProps={{
494
- ...restProps,
495
- accessibilityElementsHidden: _accessibilityElementsHidden,
496
- accessibilityLabel: _accessibilityLabel,
497
- accessibilityRole: _accessibilityRole,
498
- accessibilityState: _accessibilityState,
499
- importantForAccessibility: _importantForAccessibility,
500
- nativeID: _nativeID,
501
- numberOfLines: _numberOfLines,
502
- selectable: _selectable,
503
- selectionColor: _selectionColor,
504
- style: _style,
505
- disabled: disabled,
506
- role: _role,
507
- children,
508
- }}
509
- textPressabilityProps={{
510
- onLongPress,
511
- onPress,
512
- onPressIn,
513
- onPressOut,
514
- onResponderGrant,
515
- onResponderMove,
516
- onResponderRelease,
517
- onResponderTerminate,
518
- onResponderTerminationRequest,
519
- onStartShouldSetResponder,
520
- pressRetentionOffset,
521
- suppressHighlighting,
522
- }}
523
- />
524
- );
525
- }
526
-
527
- return (
528
- <NativeVirtualText
529
- {...restProps}
530
- accessibilityElementsHidden={_accessibilityElementsHidden}
531
- accessibilityLabel={_accessibilityLabel}
532
- accessibilityRole={_accessibilityRole}
533
- accessibilityState={_accessibilityState}
534
- importantForAccessibility={_importantForAccessibility}
535
- nativeID={_nativeID}
536
- numberOfLines={_numberOfLines}
537
- ref={forwardedRef}
538
- selectable={_selectable}
539
- selectionColor={_selectionColor}
540
- style={_style}
541
- disabled={disabled}
542
- role={_role}>
543
- {children}
544
- </NativeVirtualText>
545
- );
199
+ if (processedStyle.userSelect != null) {
200
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
201
+ overrides = overrides || ({}: {...TextStyleInternal});
202
+ overrides.userSelect = undefined;
546
203
  }
547
204
 
548
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
549
- // falsy states we need to update the accessibilityState object to use the disabled prop.
550
- if (
551
- _disabled !== _accessibilityStateDisabled &&
552
- ((_disabled != null && _disabled !== false) ||
553
- (_accessibilityStateDisabled != null &&
554
- _accessibilityStateDisabled !== false))
555
- ) {
556
- _accessibilityState = {..._accessibilityState, disabled: _disabled};
205
+ if (processedStyle.verticalAlign != null) {
206
+ overrides = overrides || ({}: {...TextStyleInternal});
207
+ overrides.textAlignVertical =
208
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
209
+ overrides.verticalAlign = undefined;
557
210
  }
558
211
 
559
- const _accessible = Platform.select({
560
- ios: accessible !== false,
561
- android:
562
- accessible == null
563
- ? onPress != null || onLongPress != null
564
- : accessible,
565
- default: accessible,
566
- });
212
+ if (overrides != null) {
213
+ // $FlowFixMe[incompatible-type]
214
+ _style = [_style, overrides];
215
+ }
216
+ }
217
+
218
+ if (ReactNativeFeatureFlags.defaultTextToOverflowHidden()) {
219
+ _style = [styles.default, _style];
220
+ }
221
+
222
+ const _nativeID = id ?? nativeID;
223
+
224
+ if (_accessibilityLabel !== undefined) {
225
+ processedProps.accessibilityLabel = _accessibilityLabel;
226
+ }
227
+ if (_accessibilityRole !== undefined) {
228
+ processedProps.accessibilityRole = _accessibilityRole;
229
+ }
230
+ if (_accessibilityState !== undefined) {
231
+ processedProps.accessibilityState = _accessibilityState;
232
+ }
233
+ if (_nativeID !== undefined) {
234
+ processedProps.nativeID = _nativeID;
235
+ }
236
+ if (_numberOfLines !== undefined) {
237
+ processedProps.numberOfLines = _numberOfLines;
238
+ }
239
+ if (_selectable !== undefined) {
240
+ processedProps.selectable = _selectable;
241
+ }
242
+ if (_style !== undefined) {
243
+ processedProps.style = _style;
244
+ }
245
+ if (_selectionColor !== undefined) {
246
+ processedProps.selectionColor = _selectionColor;
247
+ }
248
+ if (_role !== undefined) {
249
+ processedProps.role = _role;
250
+ }
251
+
252
+ let textPressabilityProps: ?TextPressabilityProps;
253
+ if (isPressable) {
254
+ textPressabilityProps = {
255
+ onLongPress,
256
+ onPress,
257
+ onPressIn,
258
+ onPressOut,
259
+ onResponderGrant,
260
+ onResponderMove,
261
+ onResponderRelease,
262
+ onResponderTerminate,
263
+ onResponderTerminationRequest,
264
+ onStartShouldSetResponder,
265
+ pressRetentionOffset,
266
+ suppressHighlighting,
267
+ };
268
+ }
567
269
 
568
- let nativeText = null;
270
+ const hasTextAncestor = useContext(TextAncestorContext);
271
+ if (hasTextAncestor) {
272
+ processedProps.disabled = disabled;
273
+ processedProps.children = children;
569
274
  if (isPressable) {
570
- nativeText = (
571
- <NativePressableText
275
+ return (
276
+ <PressableVirtualText
572
277
  ref={forwardedRef}
573
- textProps={{
574
- ...restProps,
575
- accessibilityElementsHidden: _accessibilityElementsHidden,
576
- accessibilityLabel: _accessibilityLabel,
577
- accessibilityRole: _accessibilityRole,
578
- accessibilityState: _accessibilityState,
579
- accessible: _accessible,
580
- allowFontScaling: allowFontScaling !== false,
581
- disabled: _disabled,
582
- ellipsizeMode: ellipsizeMode ?? 'tail',
583
- importantForAccessibility: _importantForAccessibility,
584
- nativeID: _nativeID,
585
- numberOfLines: _numberOfLines,
586
- selectable: _selectable,
587
- selectionColor: _selectionColor,
588
- style: _style,
589
- role: _role,
590
- children,
591
- }}
592
- textPressabilityProps={{
593
- onLongPress,
594
- onPress,
595
- onPressIn,
596
- onPressOut,
597
- onResponderGrant,
598
- onResponderMove,
599
- onResponderRelease,
600
- onResponderTerminate,
601
- onResponderTerminationRequest,
602
- onStartShouldSetResponder,
603
- pressRetentionOffset,
604
- suppressHighlighting,
605
- }}
278
+ textProps={processedProps}
279
+ textPressabilityProps={textPressabilityProps ?? {}}
606
280
  />
607
281
  );
608
- } else {
609
- nativeText = (
610
- <NativeText
611
- {...restProps}
612
- accessibilityElementsHidden={_accessibilityElementsHidden}
613
- accessibilityLabel={_accessibilityLabel}
614
- accessibilityRole={_accessibilityRole}
615
- accessibilityState={_accessibilityState}
616
- accessible={_accessible}
617
- allowFontScaling={allowFontScaling !== false}
618
- disabled={_disabled}
619
- ellipsizeMode={ellipsizeMode ?? 'tail'}
620
- importantForAccessibility={_importantForAccessibility}
621
- nativeID={_nativeID}
622
- numberOfLines={_numberOfLines}
623
- ref={forwardedRef}
624
- selectable={_selectable}
625
- selectionColor={_selectionColor}
626
- style={_style}
627
- role={_role}>
628
- {children}
629
- </NativeText>
630
- );
631
282
  }
632
-
633
- if (children == null) {
634
- return nativeText;
635
- }
636
-
637
- // If the children do not contain a JSX element it would not be possible to have a
638
- // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
639
- // which has a performance overhead. Since we do this for performance reasons we need
640
- // to keep the check simple to avoid regressing overall perf. For this reason the
641
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
642
- // to capture the majority of `Text` uses but also not make this check too expensive.
643
- if (Array.isArray(children) && children.length <= 3) {
644
- let hasNonTextChild = false;
645
- for (let child of children) {
646
- if (child != null && typeof child === 'object') {
647
- hasNonTextChild = true;
648
- break;
649
- }
650
- }
651
- if (!hasNonTextChild) {
652
- return nativeText;
283
+ return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
284
+ }
285
+
286
+ let nativeText = null;
287
+
288
+ processedProps.accessible = _accessible;
289
+ processedProps.allowFontScaling = allowFontScaling !== false;
290
+ processedProps.disabled = _disabled;
291
+ processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
292
+ processedProps.children = children;
293
+
294
+ if (isPressable) {
295
+ nativeText = (
296
+ <PressableText
297
+ ref={forwardedRef}
298
+ selectable={_selectable}
299
+ textProps={processedProps}
300
+ textPressabilityProps={textPressabilityProps ?? {}}
301
+ />
302
+ );
303
+ } else {
304
+ nativeText =
305
+ _selectable === true ? (
306
+ <NativeSelectableText {...processedProps} ref={forwardedRef} />
307
+ ) : (
308
+ <NativeText {...processedProps} ref={forwardedRef} />
309
+ );
310
+ }
311
+
312
+ if (children == null) {
313
+ return nativeText;
314
+ }
315
+
316
+ // If the children do not contain a JSX element it would not be possible to have a
317
+ // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
318
+ // which has a performance overhead. Since we do this for performance reasons we need
319
+ // to keep the check simple to avoid regressing overall perf. For this reason the
320
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
321
+ // to capture the majority of `Text` uses but also not make this check too expensive.
322
+ if (Array.isArray(children) && children.length <= 3) {
323
+ let hasNonTextChild = false;
324
+ for (let child of children) {
325
+ if (child != null && typeof child === 'object') {
326
+ hasNonTextChild = true;
327
+ break;
653
328
  }
654
- } else if (typeof children !== 'object') {
329
+ }
330
+ if (!hasNonTextChild) {
655
331
  return nativeText;
656
332
  }
333
+ } else if (typeof children !== 'object') {
334
+ return nativeText;
335
+ }
657
336
 
658
- return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
659
- };
660
- _TextImpl = TextImplLegacy;
661
- }
662
-
663
- const TextImpl: component(
664
- ref?: React.RefSetter<TextForwardRef>,
665
- ...props: TextProps
666
- ) = _TextImpl;
337
+ return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
338
+ };
667
339
 
668
340
  TextImpl.displayName = 'Text';
669
341
 
670
- type TextPressabilityProps = $ReadOnly<{
342
+ type TextPressabilityProps = Readonly<{
671
343
  onLongPress?: ?(event: GestureResponderEvent) => unknown,
672
344
  onPress?: ?(event: GestureResponderEvent) => unknown,
673
345
  onPressIn?: ?(event: GestureResponderEvent) => unknown,
@@ -801,28 +473,17 @@ function useTextPressability({
801
473
  );
802
474
  }
803
475
 
804
- type NativePressableTextProps = $ReadOnly<{
805
- textProps: NativeTextProps,
806
- textPressabilityProps: TextPressabilityProps,
807
- }>;
808
-
809
476
  /**
810
477
  * Wrap the NativeVirtualText component and initialize pressability.
811
478
  *
812
479
  * This logic is split out from the main Text component to enable the more
813
480
  * expensive pressability logic to be only initialized when needed.
814
481
  */
815
- const NativePressableVirtualText: component(
816
- ref: React.RefSetter<TextForwardRef>,
817
- ...props: NativePressableTextProps
818
- ) = ({
819
- ref: forwardedRef,
820
- textProps,
821
- textPressabilityProps,
822
- }: {
482
+ component PressableVirtualText(
823
483
  ref?: React.RefSetter<TextForwardRef>,
824
- ...NativePressableTextProps,
825
- }) => {
484
+ textProps: NativeTextProps,
485
+ textPressabilityProps: TextPressabilityProps,
486
+ ) {
826
487
  const [isHighlighted, eventHandlersForText] = useTextPressability(
827
488
  textPressabilityProps,
828
489
  );
@@ -833,42 +494,40 @@ const NativePressableVirtualText: component(
833
494
  {...eventHandlersForText}
834
495
  isHighlighted={isHighlighted}
835
496
  isPressable={true}
836
- ref={forwardedRef}
497
+ ref={ref}
837
498
  />
838
499
  );
839
- };
500
+ }
840
501
 
841
502
  /**
842
- * Wrap the NativeText component and initialize pressability.
503
+ * Wrap a NativeText component and initialize pressability.
843
504
  *
844
505
  * This logic is split out from the main Text component to enable the more
845
506
  * expensive pressability logic to be only initialized when needed.
846
507
  */
847
- const NativePressableText: component(
848
- ref: React.RefSetter<TextForwardRef>,
849
- ...props: NativePressableTextProps
850
- ) = ({
851
- ref: forwardedRef,
852
- textProps,
853
- textPressabilityProps,
854
- }: {
508
+ component PressableText(
855
509
  ref?: React.RefSetter<TextForwardRef>,
856
- ...NativePressableTextProps,
857
- }) => {
510
+ selectable?: ?boolean,
511
+ textProps: NativeTextProps,
512
+ textPressabilityProps: TextPressabilityProps,
513
+ ) {
858
514
  const [isHighlighted, eventHandlersForText] = useTextPressability(
859
515
  textPressabilityProps,
860
516
  );
861
517
 
518
+ const NativeComponent =
519
+ selectable === true ? NativeSelectableText : NativeText;
520
+
862
521
  return (
863
- <NativeText
522
+ <NativeComponent
864
523
  {...textProps}
865
524
  {...eventHandlersForText}
866
525
  isHighlighted={isHighlighted}
867
526
  isPressable={true}
868
- ref={forwardedRef}
527
+ ref={ref}
869
528
  />
870
529
  );
871
- };
530
+ }
872
531
 
873
532
  const userSelectToSelectableMap = {
874
533
  auto: true,
@@ -885,4 +544,13 @@ const verticalAlignToTextAlignVerticalMap = {
885
544
  middle: 'center',
886
545
  } as const;
887
546
 
547
+ const styles = StyleSheet.create({
548
+ // Native components have historically acted like overflow: 'hidden'. We set
549
+ // this, as part of the default style, to let client differentiate with
550
+ // overflow: 'visible'.
551
+ default: {
552
+ overflow: 'hidden',
553
+ },
554
+ });
555
+
888
556
  export default TextImpl;