react-native-windows 0.75.3 → 0.76.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 (310) hide show
  1. package/.flowconfig +6 -4
  2. package/Directory.Build.props +4 -0
  3. package/Directory.Build.targets +5 -0
  4. package/Libraries/Alert/Alert.js +3 -0
  5. package/Libraries/Alert/Alert.windows.js +3 -0
  6. package/Libraries/Animated/AnimatedEvent.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +7 -7
  8. package/Libraries/Animated/NativeAnimatedAllowlist.js +111 -0
  9. package/Libraries/Animated/animations/Animation.js +11 -1
  10. package/Libraries/Animated/animations/DecayAnimation.js +1 -1
  11. package/Libraries/Animated/animations/SpringAnimation.js +1 -1
  12. package/Libraries/Animated/animations/TimingAnimation.js +2 -1
  13. package/Libraries/Animated/components/AnimatedScrollView.js +3 -2
  14. package/Libraries/Animated/createAnimatedComponent.js +10 -9
  15. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  16. package/Libraries/Animated/nodes/AnimatedInterpolation.js +3 -2
  17. package/Libraries/Animated/nodes/AnimatedNode.js +42 -33
  18. package/Libraries/Animated/nodes/AnimatedObject.js +56 -50
  19. package/Libraries/Animated/nodes/AnimatedProps.js +77 -40
  20. package/Libraries/Animated/nodes/AnimatedStyle.js +103 -59
  21. package/Libraries/Animated/nodes/AnimatedTracking.js +1 -1
  22. package/Libraries/Animated/nodes/AnimatedTransform.js +102 -67
  23. package/Libraries/Animated/nodes/AnimatedValue.js +2 -1
  24. package/Libraries/Animated/nodes/AnimatedWithChildren.js +21 -22
  25. package/Libraries/Animated/useAnimatedProps.js +142 -7
  26. package/Libraries/BatchedBridge/NativeModules.js +2 -0
  27. package/Libraries/Blob/FileReader.js +1 -1
  28. package/Libraries/Blob/URL.js +2 -62
  29. package/Libraries/Blob/URLSearchParams.js +71 -0
  30. package/Libraries/Components/Button.windows.js +0 -1
  31. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +1 -1
  32. package/Libraries/Components/Keyboard/KeyboardExt.js.map +1 -1
  33. package/Libraries/Components/RefreshControl/__mocks__/RefreshControlMock.js +1 -1
  34. package/Libraries/Components/ScrollView/ScrollView.js +131 -169
  35. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +1 -1
  36. package/Libraries/Components/StatusBar/StatusBar.js +3 -1
  37. package/Libraries/Components/TextInput/TextInput.d.ts +32 -2
  38. package/Libraries/Components/TextInput/TextInput.js +230 -94
  39. package/Libraries/Components/TextInput/TextInput.windows.js +230 -105
  40. package/Libraries/Components/View/ReactNativeStyleAttributes.js +22 -0
  41. package/Libraries/Components/View/ReactNativeViewAttributes.js +2 -0
  42. package/Libraries/Components/View/ReactNativeViewAttributes.windows.js +2 -0
  43. package/Libraries/Components/View/View.windows.js +32 -30
  44. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  45. package/Libraries/Components/View/ViewNativeComponent.js +0 -1
  46. package/Libraries/Components/View/ViewPropTypes.js +14 -0
  47. package/Libraries/Components/View/ViewPropTypes.windows.js +14 -0
  48. package/Libraries/Core/ExceptionsManager.js +2 -0
  49. package/Libraries/Core/InitializeCore.js +3 -1
  50. package/Libraries/Core/ReactFiberErrorDialog.js +3 -0
  51. package/Libraries/Core/ReactNativeVersion.js +4 -4
  52. package/Libraries/Core/setUpErrorHandling.js +7 -1
  53. package/Libraries/Core/setUpGlobals.js +1 -0
  54. package/Libraries/Core/setUpReactRefresh.js +0 -4
  55. package/Libraries/Image/AssetSourceResolver.js +28 -1
  56. package/Libraries/Image/AssetSourceResolver.windows.js +28 -1
  57. package/Libraries/Image/Image.android.js +9 -14
  58. package/Libraries/Image/Image.ios.js +11 -22
  59. package/Libraries/Image/Image.windows.js +11 -22
  60. package/Libraries/Image/ImageBackground.js +1 -8
  61. package/Libraries/Image/ImageUtils.js +9 -9
  62. package/Libraries/Image/ImageViewNativeComponent.js +1 -0
  63. package/Libraries/Inspector/Inspector.js +3 -2
  64. package/Libraries/Inspector/InspectorPanel.js +16 -10
  65. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  66. package/Libraries/Interaction/TaskQueue.js +1 -0
  67. package/Libraries/Lists/FlatList.js +1 -1
  68. package/Libraries/Lists/SectionList.js +2 -2
  69. package/Libraries/Lists/SectionListModern.js +3 -3
  70. package/Libraries/LogBox/Data/LogBoxData.js +24 -3
  71. package/Libraries/LogBox/LogBoxNotificationContainer.js +3 -2
  72. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +9 -8
  73. package/Libraries/LogBox/UI/LogBoxInspectorHeader.windows.js +9 -8
  74. package/Libraries/Modal/Modal.js +0 -1
  75. package/Libraries/NativeComponent/BaseViewConfig.android.js +8 -0
  76. package/Libraries/NativeComponent/BaseViewConfig.ios.js +7 -0
  77. package/Libraries/NativeComponent/BaseViewConfig.windows.js +7 -0
  78. package/Libraries/NativeComponent/NativeComponentRegistry.js +22 -22
  79. package/Libraries/NativeComponent/StaticViewConfigValidator.js +0 -21
  80. package/Libraries/Network/XMLHttpRequest.js +4 -2
  81. package/Libraries/ReactNative/AppContainer-dev.js +1 -5
  82. package/Libraries/ReactNative/AppContainer-prod.js +1 -5
  83. package/Libraries/ReactNative/AppContainer.js +1 -2
  84. package/Libraries/ReactNative/AppRegistry.d.ts +0 -4
  85. package/Libraries/ReactNative/AppRegistry.js +1 -7
  86. package/Libraries/ReactNative/BridgelessUIManager.js +1 -0
  87. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +1 -1
  88. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +5 -5
  89. package/Libraries/ReactNative/RendererImplementation.js +26 -4
  90. package/Libraries/ReactNative/getNativeComponentAttributes.js +8 -0
  91. package/Libraries/ReactNative/renderApplication.js +1 -3
  92. package/Libraries/Renderer/shims/ReactNativeTypes.js +11 -4
  93. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  94. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +74 -15
  95. package/Libraries/StyleSheet/StyleSheetTypes.js +60 -5
  96. package/Libraries/StyleSheet/processBackgroundImage.js +384 -0
  97. package/Libraries/StyleSheet/processBoxShadow.js +211 -0
  98. package/Libraries/StyleSheet/processFilter.js +231 -42
  99. package/Libraries/Text/Text.js +394 -196
  100. package/Libraries/Text/Text.windows.js +476 -300
  101. package/Libraries/Text/TextNativeComponent.js +2 -1
  102. package/Libraries/TurboModule/TurboModuleRegistry.js +13 -50
  103. package/Libraries/Types/CodegenTypes.js +3 -1
  104. package/Libraries/Utilities/Appearance.js +108 -84
  105. package/Libraries/Utilities/DevLoadingView.js +2 -4
  106. package/Libraries/Utilities/HMRClient.js +2 -1
  107. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  108. package/Libraries/Utilities/createPerformanceLogger.js +0 -9
  109. package/Libraries/Utilities/stringifyViewConfig.js +22 -0
  110. package/Libraries/Utilities/useColorScheme.js +3 -3
  111. package/Libraries/WebSocket/WebSocket.js +1 -1
  112. package/Libraries/promiseRejectionTrackingOptions.js +1 -1
  113. package/Libraries/vendor/emitter/EventEmitter.js +6 -5
  114. package/Microsoft.ReactNative/ComponentView.idl +11 -0
  115. package/Microsoft.ReactNative/Composition.Input.idl +1 -0
  116. package/Microsoft.ReactNative/CompositionSwitcher.idl +3 -0
  117. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +9 -9
  118. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +9 -9
  119. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +7 -9
  120. package/Microsoft.ReactNative/Fabric/ComponentView.h +5 -6
  121. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +4 -0
  122. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +1 -0
  123. package/Microsoft.ReactNative/Fabric/Composition/CompositionContextHelper.cpp +44 -13
  124. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +42 -5
  125. package/Microsoft.ReactNative/Fabric/Composition/CompositionHwndHost.cpp +1 -0
  126. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +81 -63
  127. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -3
  128. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +8 -6
  129. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.h +1 -2
  130. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +20 -6
  131. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +13 -6
  132. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +2 -3
  133. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +1 -2
  134. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +72 -54
  135. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +14 -4
  136. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +26 -8
  137. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +5 -2
  138. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +18 -7
  139. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +1 -2
  140. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +6 -6
  141. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +1 -2
  142. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +97 -140
  143. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +8 -4
  144. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +18 -11
  145. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +5 -4
  146. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +0 -13
  147. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +0 -3
  148. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +29 -4
  149. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +2 -0
  150. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -2
  151. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.h +1 -2
  152. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +28 -12
  153. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +33 -0
  154. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.cpp +26 -9
  155. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/TextLayoutManager.h +10 -4
  156. package/Microsoft.ReactNative/IReactModuleBuilder.cpp +5 -0
  157. package/Microsoft.ReactNative/IReactModuleBuilder.h +1 -0
  158. package/Microsoft.ReactNative/IReactModuleBuilder.idl +9 -0
  159. package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +8 -1
  160. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -0
  161. package/Microsoft.ReactNative/Modules/AlertModule.cpp +3 -1
  162. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +1 -1
  163. package/Microsoft.ReactNative/Modules/AppearanceModule.h +7 -1
  164. package/Microsoft.ReactNative/Modules/DevSettingsModule.cpp +3 -3
  165. package/Microsoft.ReactNative/Modules/DevSettingsModule.h +1 -1
  166. package/Microsoft.ReactNative/Modules/LinkingManagerModule.cpp +2 -2
  167. package/Microsoft.ReactNative/Modules/LinkingManagerModule.h +1 -1
  168. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +9 -0
  169. package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -0
  170. package/Microsoft.ReactNative/Modules/SampleTurboModule.cpp +121 -0
  171. package/Microsoft.ReactNative/Modules/SampleTurboModule.h +90 -0
  172. package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +0 -7
  173. package/Microsoft.ReactNative/ReactHost/MsoReactContext.h +0 -5
  174. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +5 -1
  175. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.cpp +59 -0
  176. package/Microsoft.ReactNative/ReactInstanceSettingsBuilder.h +23 -0
  177. package/Microsoft.ReactNative/ReactNativeAppBuilder.cpp +179 -0
  178. package/Microsoft.ReactNative/ReactNativeAppBuilder.h +35 -0
  179. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +69 -0
  180. package/Microsoft.ReactNative/ReactNativeIsland.idl +2 -0
  181. package/Microsoft.ReactNative/ReactNativeWin32App.cpp +82 -0
  182. package/Microsoft.ReactNative/ReactNativeWin32App.h +38 -0
  183. package/Microsoft.ReactNative/TurboModulesProvider.cpp +45 -0
  184. package/Microsoft.ReactNative/Views/DynamicAutomationPeer.cpp +2 -1
  185. package/Microsoft.ReactNative/Views/FlyoutViewManager.cpp +25 -16
  186. package/Microsoft.ReactNative/packages.fabric.lock.json +159 -0
  187. package/Microsoft.ReactNative/packages.lock.json +11 -12
  188. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +3 -4
  189. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +3 -0
  190. package/Microsoft.ReactNative.Cxx/ModuleRegistration.cpp +2 -2
  191. package/Microsoft.ReactNative.Cxx/ModuleRegistration.h +62 -4
  192. package/Microsoft.ReactNative.Cxx/NativeModules.h +131 -14
  193. package/Microsoft.ReactNative.Managed/packages.lock.json +9 -9
  194. package/Microsoft.ReactNative.Managed.CodeGen/ReactNativeNames.cs +10 -2
  195. package/PropertySheets/Autolink.props +1 -1
  196. package/PropertySheets/Bundle.props +1 -1
  197. package/PropertySheets/Codegen.props +1 -1
  198. package/PropertySheets/Generated/PackageVersion.g.props +4 -4
  199. package/PropertySheets/NuGet.LockFile.props +18 -0
  200. package/README.md +29 -29
  201. package/ReactCommon/ReactCommon.vcxproj +5 -1
  202. package/ReactCommon/ReactCommon.vcxproj.filters +11 -2
  203. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +2 -7
  204. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.cpp +441 -0
  205. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/NetworkIOAgent.h +266 -0
  206. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsinspector-modern/Utf8.h +56 -0
  207. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Base.h +3 -1
  208. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +2 -2
  209. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/CallbackWrapper.h +1 -1
  210. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Convert.h +172 -0
  211. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/EventEmitter.h +4 -5
  212. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Function.h +2 -2
  213. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModule.h +1 -1
  214. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/core/ReactCommon/TurboModuleUtils.h +3 -2
  215. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +9 -0
  216. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/core/LayoutableShadowNode.cpp +363 -0
  217. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/JSRuntimeFactory.h +22 -2
  218. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +118 -51
  219. package/ReactCommon/packages.lock.json +2 -2
  220. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +8 -1
  221. package/Scripts/Tfs/Layout-MSRN-Headers.ps1 +2 -2
  222. package/Shared/Modules/WebSocketModule.cpp +1 -2
  223. package/Shared/Networking/WinRTWebSocketResource.cpp +4 -1
  224. package/Shared/Shared.vcxitems +38 -2
  225. package/Shared/Shared.vcxitems.filters +6 -1
  226. package/Shared/TurboModuleManager.cpp +0 -3
  227. package/codegen/NativeLinkingManagerSpec.g.h +3 -3
  228. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +198 -54
  229. package/codegen/NativeSampleTurboModuleSpec.g.h +35 -0
  230. package/codegen/rnwcoreJSI-generated.cpp +245 -101
  231. package/codegen/rnwcoreJSI.h +847 -548
  232. package/index.js +3 -1
  233. package/index.windows.js +3 -1
  234. package/jest/mockComponent.js +4 -1
  235. package/jest/mockModal.js +1 -3
  236. package/jest/mockScrollView.js +1 -1
  237. package/jest/renderer.js +2 -2
  238. package/jest/setup.js +16 -13
  239. package/package.json +26 -25
  240. package/src/private/animated/NativeAnimatedHelper.js +438 -0
  241. package/src/private/animated/NativeAnimatedValidation.js +64 -0
  242. package/src/private/components/HScrollViewNativeComponents.js +56 -0
  243. package/src/private/components/SafeAreaView_INTERNAL_DO_NOT_USE.js +27 -0
  244. package/src/private/components/VScrollViewNativeComponents.js +48 -0
  245. package/src/private/components/useSyncOnScroll.js +48 -0
  246. package/src/private/featureflags/ReactNativeFeatureFlags.js +166 -16
  247. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +29 -5
  248. package/src/private/fusebox/FuseboxSessionObserver.js +42 -0
  249. package/{Libraries/Core → src/private/renderer/errorhandling}/ErrorHandlers.js +14 -4
  250. package/src/private/setup/setUpDOM.js +28 -0
  251. package/src/private/setup/setUpIntersectionObserver.js +27 -0
  252. package/src/private/setup/setUpMutationObserver.js +26 -0
  253. package/src/private/setup/setUpPerformanceObserver.js +64 -0
  254. package/src/private/specs/modules/NativeAppearance.js +3 -3
  255. package/src/private/specs/modules/NativeLinkingManager.js +1 -1
  256. package/src/private/specs/modules/NativePlatformConstantsWindows.js +7 -0
  257. package/src/private/specs/modules/NativeSampleTurboModule.js +14 -1
  258. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +6 -4
  259. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserver.js +5 -3
  260. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverEntry.js +3 -3
  261. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver}/IntersectionObserverManager.js +14 -17
  262. package/src/private/{specs/modules → webapis/intersectionobserver/specs}/NativeIntersectionObserver.js +2 -2
  263. package/{Libraries/IntersectionObserver → src/private/webapis/intersectionobserver/specs}/__mocks__/NativeIntersectionObserver.js +4 -4
  264. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserver.js +5 -3
  265. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationObserverManager.js +24 -15
  266. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver}/MutationRecord.js +4 -6
  267. package/src/private/{specs/modules → webapis/mutationobserver/specs}/NativeMutationObserver.js +2 -2
  268. package/{Libraries/MutationObserver → src/private/webapis/mutationobserver/specs}/__mocks__/NativeMutationObserver.js +5 -5
  269. package/src/private/webapis/performance/{EventCounts.js → EventTiming.js} +65 -3
  270. package/src/private/webapis/performance/LongTasks.js +39 -0
  271. package/src/private/webapis/performance/Performance.js +22 -9
  272. package/src/private/webapis/performance/PerformanceEntry.js +36 -18
  273. package/src/private/webapis/performance/PerformanceObserver.js +29 -43
  274. package/src/private/webapis/performance/RawPerformanceEntry.js +24 -1
  275. package/src/private/webapis/performance/UserTiming.js +17 -12
  276. package/src/private/webapis/performance/specs/NativePerformanceObserver.js +1 -1
  277. package/template/cpp-app/src/AutolinkedNativeModules.g.cpp +1 -1
  278. package/template/cpp-app/src/AutolinkedNativeModules.g.h +1 -1
  279. package/template/cs-app/src/AutolinkedNativeModules.g.cs +1 -1
  280. package/template/index.windows.bundle +1 -1
  281. package/template/metro.config.js +2 -2
  282. package/template/shared-app/src/AutolinkedNativeModules.g.props +1 -1
  283. package/template/shared-app/src/AutolinkedNativeModules.g.targets +1 -1
  284. package/templates/cpp-app/metro.config.js +2 -2
  285. package/templates/cpp-app/template.config.js +5 -5
  286. package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.cpp +1 -1
  287. package/templates/cpp-app/windows/MyApp/AutolinkedNativeModules.g.h +1 -1
  288. package/templates/cpp-app/windows/MyApp/MyApp.cpp +2 -0
  289. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
  290. package/templates/cpp-lib/example/metro.config.js +2 -2
  291. package/templates/cpp-lib/template.config.js +3 -3
  292. package/templates/cpp-lib/windows/MyLib/MyLib.h +3 -3
  293. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  294. package/types/experimental.d.ts +20 -1
  295. package/Libraries/Animated/NativeAnimatedHelper.js +0 -615
  296. package/Libraries/Core/setUpIntersectionObserver.js +0 -16
  297. package/Libraries/Core/setUpMutationObserver.js +0 -16
  298. package/Libraries/Core/setUpPerformanceObserver.js +0 -18
  299. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +0 -13
  300. package/Libraries/MutationObserver/NativeMutationObserver.js +0 -13
  301. package/Libraries/Utilities/verifyComponentAttributeEquivalence.js +0 -135
  302. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/algorithm/CalculateLayout.cpp +0 -2396
  303. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.cpp +0 -136
  304. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/config/Config.h +0 -92
  305. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.cpp +0 -48
  306. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/LayoutResults.h +0 -122
  307. package/ReactCommon/TEMP_UntilReactCommonUpdate/yoga/yoga/node/Node.cpp +0 -388
  308. package/src/private/core/setUpDOM.js +0 -18
  309. package/src/private/webapis/performance/PerformanceEventTiming.js +0 -55
  310. /package/src/private/{core → styles}/composeStyles.js +0 -0
@@ -4,13 +4,13 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  *
7
- * #7149 should be strict local
8
- * @flow
7
+ * @flow strict-local
9
8
  * @format
10
9
  */
11
10
 
12
11
  import type {PressEvent} from '../Types/CoreEventTypes';
13
- import type {TextProps} from './TextProps';
12
+ import type {NativeTextProps} from './TextNativeComponent';
13
+ import type {PressRetentionOffset, TextProps} from './TextProps';
14
14
 
15
15
  import * as PressabilityDebug from '../Pressability/PressabilityDebug';
16
16
  import usePressability from '../Pressability/usePressability';
@@ -22,105 +22,435 @@ import {NativeText, NativeVirtualText} from './TextNativeComponent';
22
22
  import * as React from 'react';
23
23
  import {useContext, useMemo, useState} from 'react';
24
24
 
25
- const View = require('../Components/View/View');
25
+ const View = require('../Components/View/View'); // [Windows]
26
26
  import {type TextStyleProp, type ViewStyleProp} from '../StyleSheet/StyleSheet'; // [Windows]
27
27
 
28
+ type TextForwardRef = React.ElementRef<
29
+ typeof NativeText | typeof NativeVirtualText,
30
+ >;
31
+
28
32
  /**
29
33
  * Text is the fundamental component for displaying text.
30
34
  *
31
35
  * @see https://reactnative.dev/docs/text
32
36
  */
33
- const Text: React.AbstractComponent<
34
- TextProps,
35
- React.ElementRef<typeof NativeText | typeof NativeVirtualText>,
36
- > = React.forwardRef((props: TextProps, forwardedRef) => {
37
- const {
38
- accessible,
39
- accessibilityLabel,
40
- accessibilityLevel, // Windows
41
- accessibilityPosInSet, // Windows
42
- accessibilitySetSize, // Windows
43
- accessibilityState,
44
- allowFontScaling,
45
- 'aria-busy': ariaBusy,
46
- 'aria-checked': ariaChecked,
47
- 'aria-disabled': ariaDisabled,
48
- 'aria-expanded': ariaExpanded,
49
- 'aria-label': ariaLabel,
50
- 'aria-level': ariaLevel, // Windows
51
- 'aria-posinset': ariaPosinset, // Windows
52
- 'aria-setsize': ariaSetsize, // Windows
53
- 'aria-selected': ariaSelected,
54
- ellipsizeMode,
55
- disabled,
56
- id,
57
- nativeID,
58
- numberOfLines,
59
- onLongPress,
60
- onPress,
61
- onPressIn,
62
- onPressOut,
63
- onResponderGrant,
64
- onResponderMove,
65
- onResponderRelease,
66
- onResponderTerminate,
67
- onResponderTerminationRequest,
68
- onStartShouldSetResponder,
69
- pressRetentionOffset,
70
- selectable,
71
- selectionColor,
72
- suppressHighlighting,
73
- style,
74
- ...restProps
75
- } = props;
37
+ const Text: React.AbstractComponent<TextProps, TextForwardRef> =
38
+ React.forwardRef(
39
+ (
40
+ {
41
+ accessible,
42
+ accessibilityLabel,
43
+ accessibilityLevel, // Windows
44
+ accessibilityPosInSet, // Windows
45
+ accessibilitySetSize, // Windows
46
+ accessibilityState,
47
+ allowFontScaling,
48
+ 'aria-busy': ariaBusy,
49
+ 'aria-checked': ariaChecked,
50
+ 'aria-disabled': ariaDisabled,
51
+ 'aria-expanded': ariaExpanded,
52
+ 'aria-label': ariaLabel,
53
+ 'aria-level': ariaLevel, // Windows
54
+ 'aria-posinset': ariaPosinset, // Windows
55
+ 'aria-setsize': ariaSetsize, // Windows
56
+ 'aria-selected': ariaSelected,
57
+ children,
58
+ ellipsizeMode,
59
+ disabled,
60
+ id,
61
+ nativeID,
62
+ numberOfLines,
63
+ onLongPress,
64
+ onPress,
65
+ onPressIn,
66
+ onPressOut,
67
+ onResponderGrant,
68
+ onResponderMove,
69
+ onResponderRelease,
70
+ onResponderTerminate,
71
+ onResponderTerminationRequest,
72
+ onStartShouldSetResponder,
73
+ pressRetentionOffset,
74
+ selectable,
75
+ selectionColor,
76
+ suppressHighlighting,
77
+ style,
78
+ ...restProps
79
+ }: TextProps,
80
+ forwardedRef,
81
+ ) => {
82
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
83
+ const _accessibilityLevel = ariaLevel ?? accessibilityLevel; // Windows
84
+ const _accessibilityPosInSet = ariaPosinset ?? accessibilityPosInSet; // Windows
85
+ const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize; // Windows
76
86
 
77
- const [isHighlighted, setHighlighted] = useState(false);
87
+ let _accessibilityState: ?TextProps['accessibilityState'] =
88
+ accessibilityState;
89
+ if (
90
+ ariaBusy != null ||
91
+ ariaChecked != null ||
92
+ ariaDisabled != null ||
93
+ ariaExpanded != null ||
94
+ ariaSelected != null
95
+ ) {
96
+ if (_accessibilityState != null) {
97
+ _accessibilityState = {
98
+ busy: ariaBusy ?? _accessibilityState.busy,
99
+ checked: ariaChecked ?? _accessibilityState.checked,
100
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
101
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
102
+ selected: ariaSelected ?? _accessibilityState.selected,
103
+ };
104
+ } else {
105
+ _accessibilityState = {
106
+ busy: ariaBusy,
107
+ checked: ariaChecked,
108
+ disabled: ariaDisabled,
109
+ expanded: ariaExpanded,
110
+ selected: ariaSelected,
111
+ };
112
+ }
113
+ }
78
114
 
79
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
80
-
81
- let _accessibilityState: ?TextProps['accessibilityState'] =
82
- accessibilityState;
83
- if (
84
- ariaBusy != null ||
85
- ariaChecked != null ||
86
- ariaDisabled != null ||
87
- ariaExpanded != null ||
88
- ariaSelected != null
89
- ) {
90
- if (_accessibilityState != null) {
91
- _accessibilityState = {
92
- busy: ariaBusy ?? _accessibilityState.busy,
93
- checked: ariaChecked ?? _accessibilityState.checked,
94
- disabled: ariaDisabled ?? _accessibilityState.disabled,
95
- expanded: ariaExpanded ?? _accessibilityState.expanded,
96
- selected: ariaSelected ?? _accessibilityState.selected,
97
- };
98
- } else {
99
- _accessibilityState = {
100
- busy: ariaBusy,
101
- checked: ariaChecked,
102
- disabled: ariaDisabled,
103
- expanded: ariaExpanded,
104
- selected: ariaSelected,
115
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
116
+ const _disabled = disabled ?? _accessibilityStateDisabled;
117
+
118
+ const isPressable =
119
+ (onPress != null ||
120
+ onLongPress != null ||
121
+ onStartShouldSetResponder != null) &&
122
+ _disabled !== true;
123
+
124
+ // TODO: Move this processing to the view configuration.
125
+ const _selectionColor =
126
+ selectionColor == null ? null : processColor(selectionColor);
127
+
128
+ let _style = style;
129
+ if (__DEV__) {
130
+ if (PressabilityDebug.isEnabled() && onPress != null) {
131
+ _style = [style, {color: 'magenta'}];
132
+ }
133
+ }
134
+
135
+ let _numberOfLines = numberOfLines;
136
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
137
+ if (__DEV__) {
138
+ console.error(
139
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
140
+ );
141
+ }
142
+ _numberOfLines = 0;
143
+ }
144
+
145
+ let _selectable = selectable;
146
+
147
+ const processedStyle = flattenStyle(_style);
148
+ if (processedStyle != null) {
149
+ if (typeof processedStyle.fontWeight === 'number') {
150
+ // $FlowFixMe[cannot-write]
151
+ processedStyle.fontWeight = processedStyle.fontWeight.toString();
152
+ }
153
+
154
+ if (processedStyle.userSelect != null) {
155
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
156
+ // $FlowFixMe[cannot-write]
157
+ delete processedStyle.userSelect;
158
+ }
159
+
160
+ if (processedStyle.verticalAlign != null) {
161
+ // $FlowFixMe[cannot-write]
162
+ processedStyle.textAlignVertical =
163
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
164
+ // $FlowFixMe[cannot-write]
165
+ delete processedStyle.verticalAlign;
166
+ }
167
+ }
168
+
169
+ const _nativeID = id ?? nativeID;
170
+
171
+ const hasTextAncestor = useContext(TextAncestor);
172
+ if (hasTextAncestor) {
173
+ if (isPressable) {
174
+ return (
175
+ <NativePressableVirtualText
176
+ ref={forwardedRef}
177
+ textProps={{
178
+ ...restProps,
179
+ accessibilityLabel: _accessibilityLabel,
180
+ accessibilityState: _accessibilityState,
181
+ accessibilityLevel: _accessibilityLevel, // Windows
182
+ accessibilityPosInSet: _accessibilityPosInSet, // Windows
183
+ accessibilitySetSize: _accessibilitySetSize, // Windows
184
+ nativeID: _nativeID,
185
+ numberOfLines: _numberOfLines,
186
+ selectable: _selectable,
187
+ selectionColor: _selectionColor,
188
+ style: processedStyle,
189
+ disabled: disabled,
190
+ children,
191
+ }}
192
+ textPressabilityProps={{
193
+ onLongPress,
194
+ onPress,
195
+ onPressIn,
196
+ onPressOut,
197
+ onResponderGrant,
198
+ onResponderMove,
199
+ onResponderRelease,
200
+ onResponderTerminate,
201
+ onResponderTerminationRequest,
202
+ onStartShouldSetResponder,
203
+ pressRetentionOffset,
204
+ suppressHighlighting,
205
+ }}
206
+ />
207
+ );
208
+ }
209
+
210
+ return (
211
+ <NativeVirtualText
212
+ {...restProps}
213
+ accessibilityLabel={_accessibilityLabel}
214
+ accessibilityState={_accessibilityState}
215
+ accessibilityLevel={_accessibilityLevel} // Windows
216
+ accessibilityPosInSet={_accessibilityPosInSet} // Windows
217
+ accessibilitySetSize={_accessibilitySetSize} // Windows
218
+ isHighlighted={false}
219
+ isPressable={false}
220
+ nativeID={_nativeID}
221
+ numberOfLines={_numberOfLines}
222
+ ref={forwardedRef}
223
+ selectable={_selectable}
224
+ selectionColor={_selectionColor}
225
+ style={processedStyle}
226
+ disabled={disabled}>
227
+ {children}
228
+ </NativeVirtualText>
229
+ );
230
+ }
231
+
232
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
233
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
234
+ if (
235
+ _disabled !== _accessibilityStateDisabled &&
236
+ ((_disabled != null && _disabled !== false) ||
237
+ (_accessibilityStateDisabled != null &&
238
+ _accessibilityStateDisabled !== false))
239
+ ) {
240
+ _accessibilityState = {..._accessibilityState, disabled: _disabled};
241
+ }
242
+
243
+ const _accessible = Platform.select({
244
+ ios: accessible !== false,
245
+ android:
246
+ accessible == null
247
+ ? onPress != null || onLongPress != null
248
+ : accessible,
249
+ default: accessible !== false, // [Windows]
250
+ });
251
+
252
+ let nativeText = null;
253
+ if (isPressable) {
254
+ nativeText = (
255
+ <NativePressableText
256
+ ref={forwardedRef}
257
+ textProps={{
258
+ ...restProps,
259
+ accessibilityLabel: _accessibilityLabel,
260
+ accessibilityState: _accessibilityState,
261
+ accessibilityLevel: _accessibilityLevel, // Windows
262
+ accessibilityPosInSet: _accessibilityPosInSet, // Windows
263
+ accessibilitySetSize: _accessibilitySetSize, // Windows
264
+ accessible: _accessible,
265
+ allowFontScaling: allowFontScaling !== false,
266
+ disabled: _disabled,
267
+ ellipsizeMode: ellipsizeMode ?? 'tail',
268
+ nativeID: _nativeID,
269
+ numberOfLines: _numberOfLines,
270
+ selectable: _selectable,
271
+ selectionColor: _selectionColor,
272
+ style: processedStyle,
273
+ children,
274
+ }}
275
+ textPressabilityProps={{
276
+ onLongPress,
277
+ onPress,
278
+ onPressIn,
279
+ onPressOut,
280
+ onResponderGrant,
281
+ onResponderMove,
282
+ onResponderRelease,
283
+ onResponderTerminate,
284
+ onResponderTerminationRequest,
285
+ onStartShouldSetResponder,
286
+ pressRetentionOffset,
287
+ suppressHighlighting,
288
+ }}
289
+ />
290
+ );
291
+ } else {
292
+ nativeText = (
293
+ <NativeText
294
+ {...restProps}
295
+ accessibilityLabel={_accessibilityLabel}
296
+ accessibilityState={_accessibilityState}
297
+ accessibilityLevel={_accessibilityLevel} // Windows
298
+ accessibilityPosInSet={_accessibilityPosInSet} // Windows
299
+ accessibilitySetSize={_accessibilitySetSize} // Windows
300
+ accessible={_accessible}
301
+ allowFontScaling={allowFontScaling !== false}
302
+ disabled={_disabled}
303
+ ellipsizeMode={ellipsizeMode ?? 'tail'}
304
+ isHighlighted={false}
305
+ nativeID={_nativeID}
306
+ numberOfLines={_numberOfLines}
307
+ ref={forwardedRef}
308
+ selectable={_selectable}
309
+ selectionColor={_selectionColor}
310
+ style={processedStyle}>
311
+ {children}
312
+ </NativeText>
313
+ );
314
+ }
315
+
316
+ // [Windows
317
+ // $FlowFixMe[unclear-type]
318
+ let styleProps: ViewStyleProp = (style: any); // Flow style type casting
319
+ if (
320
+ global.RN$Bridgeless !== true && // [Windows] Fabric text handles borders, but on paper we need to wrap it in an extra view
321
+ styleProps &&
322
+ styleProps.borderColor != null &&
323
+ (styleProps.borderWidth != null ||
324
+ styleProps.borderBottomWidth != null ||
325
+ styleProps.borderEndWidth != null ||
326
+ styleProps.borderLeftWidth != null ||
327
+ styleProps.borderRightWidth != null ||
328
+ styleProps.borderStartWidth != null ||
329
+ styleProps.borderTopWidth != null)
330
+ ) {
331
+ let textStyleProps = Array.isArray(styleProps)
332
+ ? // $FlowFixMe[underconstrained-implicit-instantiation]
333
+ flattenStyle(styleProps)
334
+ : styleProps;
335
+ let {
336
+ // $FlowFixMe[prop-missing]
337
+ margin,
338
+ // $FlowFixMe[prop-missing]
339
+ marginBottom,
340
+ // $FlowFixMe[prop-missing]
341
+ marginEnd,
342
+ // $FlowFixMe[prop-missing]
343
+ marginHorizontal,
344
+ // $FlowFixMe[prop-missing]
345
+ marginLeft,
346
+ // $FlowFixMe[prop-missing]
347
+ marginRight,
348
+ // $FlowFixMe[prop-missing]
349
+ marginStart,
350
+ // $FlowFixMe[prop-missing]
351
+ marginTop,
352
+ // $FlowFixMe[prop-missing]
353
+ marginVertical,
354
+ // $FlowFixMe[prop-missing]
355
+ padding,
356
+ // $FlowFixMe[prop-missing]
357
+ paddingBottom,
358
+ // $FlowFixMe[prop-missing]
359
+ paddingEnd,
360
+ // $FlowFixMe[prop-missing]
361
+ paddingHorizontal,
362
+ // $FlowFixMe[prop-missing]
363
+ paddingLeft,
364
+ // $FlowFixMe[prop-missing]
365
+ paddingRight,
366
+ // $FlowFixMe[prop-missing]
367
+ paddingStart,
368
+ // $FlowFixMe[prop-missing]
369
+ paddingTop,
370
+ // $FlowFixMe[prop-missing]
371
+ paddingVertical,
372
+ // $FlowFixMe[not-an-object]
373
+ ...rest
374
+ } = textStyleProps != null ? textStyleProps : {}
375
+ return (
376
+ <View style={styleProps}><TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider></View>
377
+ );
105
378
  };
106
- }
107
- }
379
+ // Windows]
108
380
 
109
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
110
- const _disabled = disabled ?? _accessibilityStateDisabled;
381
+ if (children == null) {
382
+ return nativeText;
383
+ }
111
384
 
112
- const isPressable =
113
- (onPress != null ||
114
- onLongPress != null ||
115
- onStartShouldSetResponder != null) &&
116
- _disabled !== true;
385
+ // If the children do not contain a JSX element it would not be possible to have a
386
+ // nested `Text` component so we can skip adding the `TextAncestor` context wrapper
387
+ // which has a performance overhead. Since we do this for performance reasons we need
388
+ // to keep the check simple to avoid regressing overall perf. For this reason the
389
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
390
+ // to capture the majority of `Text` uses but also not make this check too expensive.
391
+ /*
392
+ if (Array.isArray(children) && children.length <= 3) {
393
+ let hasNonTextChild = false;
394
+ for (let child of children) {
395
+ if (child != null && typeof child === 'object') {
396
+ hasNonTextChild = true;
397
+ break;
398
+ }
399
+ }
400
+ if (!hasNonTextChild) {
401
+ return nativeText;
402
+ }
403
+ } else if (typeof children !== 'object') {
404
+ return nativeText;
405
+ }
406
+ */
117
407
 
118
- const initialized = useLazyInitialization(isPressable);
119
- const config = useMemo(() => {
120
- if (!initialized) {
121
- return null;
122
- }
408
+ return (
409
+ <TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
410
+ );
411
+ },
412
+ );
413
+
414
+ Text.displayName = 'Text';
123
415
 
416
+ type TextPressabilityProps = $ReadOnly<{
417
+ onLongPress?: ?(event: PressEvent) => mixed,
418
+ onPress?: ?(event: PressEvent) => mixed,
419
+ onPressIn?: ?(event: PressEvent) => mixed,
420
+ onPressOut?: ?(event: PressEvent) => mixed,
421
+ onResponderGrant?: ?(event: PressEvent) => void,
422
+ onResponderMove?: ?(event: PressEvent) => void,
423
+ onResponderRelease?: ?(event: PressEvent) => void,
424
+ onResponderTerminate?: ?(event: PressEvent) => void,
425
+ onResponderTerminationRequest?: ?() => boolean,
426
+ onStartShouldSetResponder?: ?() => boolean,
427
+ pressRetentionOffset?: ?PressRetentionOffset,
428
+ suppressHighlighting?: ?boolean,
429
+ }>;
430
+
431
+ /**
432
+ * Hook that handles setting up Pressability of Text components.
433
+ *
434
+ * NOTE: This hook is relatively expensive so it should only be used absolutely necessary.
435
+ */
436
+ function useTextPressability({
437
+ onLongPress,
438
+ onPress,
439
+ onPressIn,
440
+ onPressOut,
441
+ onResponderGrant,
442
+ onResponderMove,
443
+ onResponderRelease,
444
+ onResponderTerminate,
445
+ onResponderTerminationRequest,
446
+ onStartShouldSetResponder,
447
+ pressRetentionOffset,
448
+ suppressHighlighting,
449
+ }: TextPressabilityProps) {
450
+ const [isHighlighted, setHighlighted] = useState(false);
451
+
452
+ // Setup pressability config and wrap callbacks needs to track the highlight state.
453
+ const config = useMemo(() => {
124
454
  let _onPressIn = onPressIn;
125
455
  let _onPressOut = onPressOut;
126
456
 
@@ -140,7 +470,7 @@ const Text: React.AbstractComponent<
140
470
  }
141
471
 
142
472
  return {
143
- disabled: !isPressable,
473
+ disabled: false,
144
474
  pressRectOffset: pressRetentionOffset,
145
475
  onLongPress,
146
476
  onPress,
@@ -148,8 +478,6 @@ const Text: React.AbstractComponent<
148
478
  onPressOut: _onPressOut,
149
479
  };
150
480
  }, [
151
- initialized,
152
- isPressable,
153
481
  pressRetentionOffset,
154
482
  onLongPress,
155
483
  onPress,
@@ -158,7 +486,10 @@ const Text: React.AbstractComponent<
158
486
  suppressHighlighting,
159
487
  ]);
160
488
 
489
+ // Init the pressability class
161
490
  const eventHandlers = usePressability(config);
491
+
492
+ // Create NativeText event handlers which proxy events to pressability
162
493
  const eventHandlersForText = useMemo(
163
494
  () =>
164
495
  eventHandlers == null
@@ -209,222 +540,67 @@ const Text: React.AbstractComponent<
209
540
  ],
210
541
  );
211
542
 
212
- // TODO: Move this processing to the view configuration.
213
- const _selectionColor =
214
- selectionColor == null ? null : processColor(selectionColor);
215
-
216
- let _style = style;
217
- if (__DEV__) {
218
- if (PressabilityDebug.isEnabled() && onPress != null) {
219
- _style = [style, {color: 'magenta'}];
220
- }
221
- }
543
+ // Return the highlight state and NativeText event handlers
544
+ return useMemo(
545
+ () => [isHighlighted, eventHandlersForText],
546
+ [isHighlighted, eventHandlersForText],
547
+ );
548
+ }
222
549
 
223
- let _numberOfLines = numberOfLines;
224
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
225
- if (__DEV__) {
226
- console.error(
227
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
228
- );
229
- }
230
- _numberOfLines = 0;
231
- }
232
-
233
- let _selectable = selectable;
234
- const processedStyle = flattenStyle(_style);
235
- if (processedStyle != null) {
236
- if (typeof processedStyle.fontWeight === 'number') {
237
- // $FlowFixMe[cannot-write]
238
- processedStyle.fontWeight = processedStyle.fontWeight.toString();
239
- }
550
+ type NativePressableTextProps = $ReadOnly<{
551
+ textProps: NativeTextProps,
552
+ textPressabilityProps: TextPressabilityProps,
553
+ }>;
240
554
 
241
- if (processedStyle.userSelect != null) {
242
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
243
- // $FlowFixMe[cannot-write]
244
- delete processedStyle.userSelect;
245
- }
555
+ /**
556
+ * Wrap the NativeVirtualText component and initialize pressability.
557
+ *
558
+ * This logic is split out from the main Text component to enable the more
559
+ * expensive pressability logic to be only initialized when needed.
560
+ */
561
+ const NativePressableVirtualText: React.AbstractComponent<
562
+ NativePressableTextProps,
563
+ TextForwardRef,
564
+ > = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
565
+ const [isHighlighted, eventHandlersForText] = useTextPressability(
566
+ textPressabilityProps,
567
+ );
246
568
 
247
- if (processedStyle.verticalAlign != null) {
248
- // $FlowFixMe[cannot-write]
249
- processedStyle.textAlignVertical =
250
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
251
- // $FlowFixMe[cannot-write]
252
- delete processedStyle.verticalAlign;
253
- }
254
- }
255
-
256
- const _nativeID = id ?? nativeID;
257
-
258
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
259
- // falsy states we need to update the accessibilityState object to use the disabled prop.
260
- if (
261
- _disabled !== _accessibilityStateDisabled &&
262
- ((_disabled != null && _disabled !== false) ||
263
- (_accessibilityStateDisabled != null &&
264
- _accessibilityStateDisabled !== false))
265
- ) {
266
- _accessibilityState = {..._accessibilityState, disabled: _disabled};
267
- }
268
-
269
- const _accessible = Platform.select({
270
- ios: accessible !== false,
271
- android:
272
- accessible == null ? onPress != null || onLongPress != null : accessible,
273
- default: accessible !== false,
274
- });
275
-
276
- const hasTextAncestor = useContext(TextAncestor);
277
- if (hasTextAncestor) {
278
- return (
279
- <NativeVirtualText
280
- {...restProps}
281
- {...eventHandlersForText}
282
- accessibilityLabel={_accessibilityLabel}
283
- accessibilityState={_accessibilityState}
284
- accessibilityLevel={ariaLevel ?? accessibilityLevel} // Windows
285
- accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet} // Windows
286
- accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Windows
287
- isHighlighted={isHighlighted}
288
- isPressable={isPressable}
289
- nativeID={_nativeID}
290
- numberOfLines={_numberOfLines}
291
- ref={forwardedRef}
292
- selectable={_selectable}
293
- selectionColor={_selectionColor}
294
- style={processedStyle}
295
- />
296
- );
297
- // [Windows] Following else statement forked due to PR #5740
298
- } else {
299
- let styleProps: ViewStyleProp = (style: any);
300
- if (
301
- global.RN$Bridgeless !== true && // [Windows] Fabric text handles borders, but on paper we need to wrap it in an extra view
302
- styleProps &&
303
- styleProps.borderColor &&
304
- (styleProps.borderWidth ||
305
- styleProps.borderBottomWidth ||
306
- styleProps.borderEndWidth ||
307
- styleProps.borderLeftWidth ||
308
- styleProps.borderRightWidth ||
309
- styleProps.borderStartWidth ||
310
- styleProps.borderTopWidth)
311
- ) {
312
- let textStyleProps = Array.isArray(styleProps)
313
- ? // $FlowFixMe[underconstrained-implicit-instantiation]
314
- flattenStyle(styleProps)
315
- : styleProps;
316
- let {
317
- // $FlowFixMe[prop-missing]
318
- margin,
319
- // $FlowFixMe[prop-missing]
320
- marginBottom,
321
- // $FlowFixMe[prop-missing]
322
- marginEnd,
323
- // $FlowFixMe[prop-missing]
324
- marginHorizontal,
325
- // $FlowFixMe[prop-missing]
326
- marginLeft,
327
- // $FlowFixMe[prop-missing]
328
- marginRight,
329
- // $FlowFixMe[prop-missing]
330
- marginStart,
331
- // $FlowFixMe[prop-missing]
332
- marginTop,
333
- // $FlowFixMe[prop-missing]
334
- marginVertical,
335
- // $FlowFixMe[prop-missing]
336
- padding,
337
- // $FlowFixMe[prop-missing]
338
- paddingBottom,
339
- // $FlowFixMe[prop-missing]
340
- paddingEnd,
341
- // $FlowFixMe[prop-missing]
342
- paddingHorizontal,
343
- // $FlowFixMe[prop-missing]
344
- paddingLeft,
345
- // $FlowFixMe[prop-missing]
346
- paddingRight,
347
- // $FlowFixMe[prop-missing]
348
- paddingStart,
349
- // $FlowFixMe[prop-missing]
350
- paddingTop,
351
- // $FlowFixMe[prop-missing]
352
- paddingVertical,
353
- // $FlowFixMe[not-an-object]
354
- ...rest
355
- } = textStyleProps != null ? textStyleProps : {};
356
-
357
- let {style, ...textPropsLessStyle} = props;
358
- return (
359
- <View style={styleProps}>
360
- <TextAncestor.Provider value={true}>
361
- <NativeText
362
- {...textPropsLessStyle}
363
- {...eventHandlersForText}
364
- accessibilityLabel={_accessibilityLabel}
365
- accessibilityLevel={ariaLevel ?? accessibilityLevel} // Windows
366
- accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet} // Windows
367
- accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Windows
368
- accessibilityState={_accessibilityState}
369
- accessible={_accessible}
370
- allowFontScaling={allowFontScaling !== false}
371
- disabled={_disabled}
372
- ellipsizeMode={ellipsizeMode ?? 'tail'}
373
- isHighlighted={isHighlighted}
374
- nativeID={_nativeID}
375
- numberOfLines={_numberOfLines}
376
- ref={forwardedRef}
377
- selectable={_selectable}
378
- selectionColor={_selectionColor}
379
- style={processedStyle}
380
- />
381
- </TextAncestor.Provider>
382
- </View>
383
- );
384
- } else {
385
- return (
386
- <TextAncestor.Provider value={true}>
387
- <NativeText
388
- {...restProps}
389
- {...eventHandlersForText}
390
- accessibilityLabel={_accessibilityLabel}
391
- accessibilityLevel={ariaLevel ?? accessibilityLevel} // Windows
392
- accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet} // Windows
393
- accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Windows
394
- accessibilityState={_accessibilityState}
395
- accessible={_accessible}
396
- allowFontScaling={allowFontScaling !== false}
397
- disabled={_disabled}
398
- ellipsizeMode={ellipsizeMode ?? 'tail'}
399
- isHighlighted={isHighlighted}
400
- nativeID={_nativeID}
401
- numberOfLines={_numberOfLines}
402
- ref={forwardedRef}
403
- selectable={_selectable}
404
- selectionColor={_selectionColor}
405
- style={processedStyle}
406
- />
407
- </TextAncestor.Provider>
408
- );
409
- }
410
- }
411
- // [Windows #5740]
569
+ return (
570
+ <NativeVirtualText
571
+ {...textProps}
572
+ {...eventHandlersForText}
573
+ isHighlighted={isHighlighted}
574
+ isPressable={true}
575
+ ref={forwardedRef}
576
+ />
577
+ );
412
578
  });
413
579
 
414
- Text.displayName = 'Text';
415
-
416
580
  /**
417
- * Returns false until the first time `newValue` is true, after which this will
418
- * always return true. This is necessary to lazily initialize `Pressability` so
419
- * we do not eagerly create one for every pressable `Text` component.
581
+ * Wrap the NativeText component and initialize pressability.
582
+ *
583
+ * This logic is split out from the main Text component to enable the more
584
+ * expensive pressability logic to be only initialized when needed.
420
585
  */
421
- function useLazyInitialization(newValue: boolean): boolean {
422
- const [oldValue, setValue] = useState(newValue);
423
- if (!oldValue && newValue) {
424
- setValue(newValue);
425
- }
426
- return oldValue;
427
- }
586
+ const NativePressableText: React.AbstractComponent<
587
+ NativePressableTextProps,
588
+ TextForwardRef,
589
+ > = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
590
+ const [isHighlighted, eventHandlersForText] = useTextPressability(
591
+ textPressabilityProps,
592
+ );
593
+
594
+ return (
595
+ <NativeText
596
+ {...textProps}
597
+ {...eventHandlersForText}
598
+ isHighlighted={isHighlighted}
599
+ isPressable={true}
600
+ ref={forwardedRef}
601
+ />
602
+ );
603
+ });
428
604
 
429
605
  const userSelectToSelectableMap = {
430
606
  auto: true,