@office-iss/react-native-win32 0.84.0 → 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 (310) hide show
  1. package/.eslintignore +1 -0
  2. package/.flowconfig +1 -5
  3. package/CHANGELOG.json +67 -22
  4. package/CHANGELOG.md +14 -17
  5. package/IntegrationTests/IntegrationTestHarnessTest.js +1 -1
  6. package/IntegrationTests/LayoutEventsTest.js +1 -1
  7. package/IntegrationTests/TimersTest.js +1 -1
  8. package/Libraries/ActionSheetIOS/ActionSheetIOS.js +3 -3
  9. package/Libraries/Animated/Animated.d.ts +8 -1
  10. package/Libraries/Animated/AnimatedEvent.js +4 -4
  11. package/Libraries/Animated/AnimatedImplementation.js +2 -2
  12. package/Libraries/Animated/animations/Animation.js +3 -3
  13. package/Libraries/Animated/animations/DecayAnimation.js +4 -4
  14. package/Libraries/Animated/animations/SpringAnimation.js +5 -5
  15. package/Libraries/Animated/animations/TimingAnimation.js +5 -5
  16. package/Libraries/Animated/createAnimatedComponent.js +7 -7
  17. package/Libraries/Animated/nodes/AnimatedColor.js +2 -2
  18. package/Libraries/Animated/nodes/AnimatedInterpolation.js +12 -12
  19. package/Libraries/Animated/nodes/AnimatedNode.js +3 -3
  20. package/Libraries/Animated/nodes/AnimatedObject.js +3 -3
  21. package/Libraries/Animated/nodes/AnimatedProps.js +6 -6
  22. package/Libraries/Animated/nodes/AnimatedStyle.js +7 -7
  23. package/Libraries/Animated/nodes/AnimatedTransform.js +13 -13
  24. package/Libraries/Animated/nodes/AnimatedValue.js +1 -1
  25. package/Libraries/Animated/nodes/AnimatedValueXY.js +1 -1
  26. package/Libraries/Animated/nodes/AnimatedWithChildren.js +1 -1
  27. package/Libraries/Animated/useAnimatedColor.d.ts +15 -0
  28. package/Libraries/Animated/useAnimatedColor.js +25 -0
  29. package/Libraries/Animated/useAnimatedValueXY.d.ts +15 -0
  30. package/Libraries/Animated/useAnimatedValueXY.js +26 -0
  31. package/Libraries/AppState/AppState.js +1 -1
  32. package/Libraries/BatchedBridge/MessageQueue.js +3 -3
  33. package/Libraries/BatchedBridge/NativeModules.js +12 -10
  34. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +30 -26
  35. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +34 -30
  36. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +2 -2
  37. package/Libraries/Components/Button.js +2 -2
  38. package/Libraries/Components/Button.win32.js +2 -2
  39. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroidTypes.js +2 -2
  40. package/Libraries/Components/EnterString.win32.js +2 -2
  41. package/Libraries/Components/EnterString.win32.js.map +1 -1
  42. package/Libraries/Components/Keyboard/Keyboard.js +6 -6
  43. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +1 -1
  44. package/Libraries/Components/LayoutConformance/LayoutConformance.js +1 -1
  45. package/Libraries/Components/LayoutConformance/LayoutConformanceNativeComponent.js +1 -1
  46. package/Libraries/Components/Pressable/Pressable.d.ts +5 -0
  47. package/Libraries/Components/Pressable/Pressable.js +3 -3
  48. package/Libraries/Components/Pressable/Pressable.win32.js +3 -3
  49. package/Libraries/Components/Pressable/useAndroidRippleForView.js +4 -4
  50. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +1 -1
  51. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +3 -3
  52. package/Libraries/Components/RefreshControl/RefreshControl.js +5 -5
  53. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +8 -12
  54. package/Libraries/Components/ScrollView/ScrollView.d.ts +9 -0
  55. package/Libraries/Components/ScrollView/ScrollView.js +19 -9
  56. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.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/TextInput/AndroidTextInputNativeComponent.js +33 -48
  63. package/Libraries/Components/TextInput/InputAccessoryView.js +1 -1
  64. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +6 -11
  65. package/Libraries/Components/TextInput/TextInput.flow.js +21 -20
  66. package/Libraries/Components/TextInput/TextInput.flow.win32.js +23 -22
  67. package/Libraries/Components/TextInput/TextInput.js +8 -4
  68. package/Libraries/Components/TextInput/TextInput.win32.js +3 -4
  69. package/Libraries/Components/Touchable/PooledClass.js +1 -1
  70. package/Libraries/Components/Touchable/Touchable.js +2 -2
  71. package/Libraries/Components/Touchable/Touchable.win32.js +2 -2
  72. package/Libraries/Components/Touchable/TouchableBounce.js +4 -4
  73. package/Libraries/Components/Touchable/TouchableHighlight.js +8 -8
  74. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +7 -7
  75. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +7 -7
  76. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -4
  77. package/Libraries/Components/Touchable/TouchableWin32.js +1 -1
  78. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  79. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -1
  80. package/Libraries/Components/UnimplementedViews/UnimplementedView.js +1 -1
  81. package/Libraries/Components/View/ReactNativeStyleAttributes.js +68 -31
  82. package/Libraries/Components/View/ViewAccessibility.js +7 -7
  83. package/Libraries/Components/View/ViewAccessibility.win32.js +7 -7
  84. package/Libraries/Components/View/ViewPropTypes.js +14 -14
  85. package/Libraries/Components/View/ViewPropTypes.win32.js +16 -16
  86. package/Libraries/Core/Devtools/parseHermesStack.js +8 -8
  87. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -2
  88. package/Libraries/Core/ExceptionsManager.js +2 -2
  89. package/Libraries/Core/ExtendedError.js +3 -3
  90. package/Libraries/Core/RawEventEmitter.js +1 -1
  91. package/Libraries/Core/ReactNativeVersion.js +2 -2
  92. package/Libraries/Core/Timers/JSTimers.js +3 -2
  93. package/Libraries/Core/setUpDeveloperTools.js +1 -1
  94. package/Libraries/Core/setUpErrorHandling.js +4 -2
  95. package/Libraries/Core/setUpReactDevTools.js +23 -6
  96. package/Libraries/Core/setUpSegmentFetcher.js +1 -1
  97. package/Libraries/Debugging/DebuggingOverlay.js +2 -2
  98. package/Libraries/EventEmitter/NativeEventEmitter.js +7 -9
  99. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +1 -1
  100. package/Libraries/Image/AssetSourceResolver.js +1 -1
  101. package/Libraries/Image/Image.android.js +172 -306
  102. package/Libraries/Image/ImageProps.js +9 -11
  103. package/Libraries/Image/ImageSource.js +2 -2
  104. package/Libraries/Image/ImageSourceUtils.js +8 -4
  105. package/Libraries/Image/ImageTypes.flow.js +2 -2
  106. package/Libraries/Image/ImageViewNativeComponent.js +7 -16
  107. package/Libraries/Image/nativeImageSource.js +1 -1
  108. package/Libraries/Interaction/InteractionManager.js +5 -4
  109. package/Libraries/Interaction/PanResponder.js +1 -1
  110. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -2
  111. package/Libraries/Linking/Linking.js +1 -1
  112. package/Libraries/Lists/FlatList.js +3 -3
  113. package/Libraries/Lists/SectionList.js +1 -1
  114. package/Libraries/Lists/SectionListModern.js +2 -2
  115. package/Libraries/LogBox/Data/LogBoxData.js +38 -24
  116. package/Libraries/LogBox/Data/LogBoxLog.js +43 -112
  117. package/Libraries/LogBox/Data/parseLogBoxLog.js +21 -117
  118. package/Libraries/LogBox/LogBox.js +42 -19
  119. package/Libraries/LogBox/LogBoxInspectorContainer.js +2 -2
  120. package/Libraries/LogBox/LogBoxNotificationContainer.js +2 -2
  121. package/Libraries/LogBox/UI/LogBoxButton.js +14 -16
  122. package/Libraries/LogBox/UI/LogBoxInspector.js +2 -2
  123. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.js +6 -9
  124. package/Libraries/LogBox/UI/LogBoxInspectorCodeFrame.win32.js +6 -9
  125. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +1 -1
  126. package/Libraries/LogBox/UI/LogBoxInspectorFooterButton.js +1 -1
  127. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  128. package/Libraries/LogBox/UI/LogBoxInspectorHeader.win32.js +1 -1
  129. package/Libraries/LogBox/UI/LogBoxInspectorHeaderButton.js +1 -1
  130. package/Libraries/LogBox/UI/LogBoxInspectorMessageHeader.js +10 -15
  131. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +25 -18
  132. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.win32.js +15 -16
  133. package/Libraries/LogBox/UI/LogBoxInspectorSection.js +5 -7
  134. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +8 -10
  135. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.win32.js +11 -13
  136. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.js +8 -6
  137. package/Libraries/LogBox/UI/LogBoxInspectorStackFrame.win32.js +3 -5
  138. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +17 -29
  139. package/Libraries/LogBox/UI/LogBoxMessage.js +28 -37
  140. package/Libraries/LogBox/UI/LogBoxNotification.js +1 -1
  141. package/Libraries/Modal/Modal.js +3 -3
  142. package/Libraries/NativeComponent/BaseViewConfig.android.js +28 -52
  143. package/Libraries/NativeComponent/BaseViewConfig.ios.js +19 -21
  144. package/Libraries/NativeComponent/BaseViewConfig.win32.js +16 -16
  145. package/Libraries/Network/RCTNetworking.android.js +1 -1
  146. package/Libraries/Network/RCTNetworking.ios.js +1 -1
  147. package/Libraries/Network/RCTNetworking.js.flow +1 -1
  148. package/Libraries/Network/RCTNetworking.win32.js +1 -1
  149. package/Libraries/Network/RCTNetworkingEventDefinitions.flow.js +1 -1
  150. package/Libraries/Network/XMLHttpRequest.js +1 -1
  151. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -3
  152. package/Libraries/Pressability/Pressability.js +5 -5
  153. package/Libraries/Pressability/Pressability.win32.js +5 -5
  154. package/Libraries/Pressability/PressabilityDebug.js +1 -1
  155. package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
  156. package/Libraries/Pressability/usePressability.js +3 -14
  157. package/Libraries/PushNotificationIOS/PushNotificationIOS.js +2 -2
  158. package/Libraries/ReactNative/AppContainer-dev.js +18 -1
  159. package/Libraries/ReactNative/AppContainer.js +1 -1
  160. package/Libraries/ReactNative/AppRegistry.flow.js +2 -2
  161. package/Libraries/ReactNative/AppRegistryImpl.js +2 -2
  162. package/Libraries/ReactNative/FabricUIManager.js +1 -1
  163. package/Libraries/ReactNative/RendererImplementation.js +4 -4
  164. package/Libraries/ReactNative/UIManagerProperties.js +1 -1
  165. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +3 -2
  166. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -2
  167. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -2
  168. package/Libraries/Renderer/shims/ReactFabric.js +1 -3
  169. package/Libraries/Renderer/shims/ReactFeatureFlags.js +1 -3
  170. package/Libraries/Renderer/shims/ReactNative.js +3 -2
  171. package/Libraries/Renderer/shims/ReactNativeTypes.js +1 -3
  172. package/Libraries/Renderer/shims/ReactNativeTypes.win32.js +1 -3
  173. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +1 -3
  174. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +1 -3
  175. package/Libraries/StyleSheet/PointPropType.js +1 -1
  176. package/Libraries/StyleSheet/Rect.js +1 -1
  177. package/Libraries/StyleSheet/StyleSheet.d.ts +0 -5
  178. package/Libraries/StyleSheet/StyleSheet.js +1 -1
  179. package/Libraries/StyleSheet/StyleSheet.js.flow +1 -1
  180. package/Libraries/StyleSheet/StyleSheetExports.js +16 -25
  181. package/Libraries/StyleSheet/StyleSheetExports.js.flow +2 -7
  182. package/Libraries/StyleSheet/StyleSheetTypes.js +33 -35
  183. package/Libraries/StyleSheet/private/_StyleSheetTypesOverrides.js +5 -5
  184. package/Libraries/StyleSheet/private/_TransformStyle.js +7 -7
  185. package/Libraries/StyleSheet/processBackgroundImage.js +7 -7
  186. package/Libraries/StyleSheet/processBackgroundPosition.js +4 -4
  187. package/Libraries/StyleSheet/processBackgroundRepeat.js +4 -4
  188. package/Libraries/StyleSheet/processBackgroundSize.js +4 -4
  189. package/Libraries/StyleSheet/processBoxShadow.js +44 -4
  190. package/Libraries/StyleSheet/processColorArray.js +2 -2
  191. package/Libraries/StyleSheet/processFilter.js +2 -2
  192. package/Libraries/Text/Text.js +295 -627
  193. package/Libraries/Text/Text.win32.js +360 -744
  194. package/Libraries/Text/TextNativeComponent.js +14 -7
  195. package/Libraries/Text/TextNativeComponent.win32.js +14 -7
  196. package/Libraries/Text/TextProps.js +4 -4
  197. package/Libraries/Text/TextProps.win32.js +4 -4
  198. package/Libraries/Types/CodegenTypes.js +1 -1
  199. package/Libraries/Types/CoreEventTypes.js +21 -21
  200. package/Libraries/Types/CoreEventTypes.win32.js +22 -21
  201. package/Libraries/Types/ReactDevToolsTypes.js +2 -2
  202. package/Libraries/Utilities/Appearance.js +6 -1
  203. package/Libraries/Utilities/Dimensions.js +1 -1
  204. package/Libraries/Utilities/Dimensions.win32.js +1 -1
  205. package/Libraries/Utilities/HMRClient.js +32 -5
  206. package/Libraries/Utilities/IPerformanceLogger.js +4 -4
  207. package/Libraries/Utilities/codegenNativeCommands.js +4 -4
  208. package/Libraries/Utilities/codegenNativeComponent.d.ts +2 -0
  209. package/Libraries/Utilities/codegenNativeComponent.js +2 -2
  210. package/Libraries/Utilities/logError.js +1 -1
  211. package/Libraries/Utilities/stringifySafe.js +3 -3
  212. package/Libraries/Utilities/useMergeRefs.js +2 -2
  213. package/Libraries/vendor/core/ErrorUtils.js +4 -4
  214. package/Libraries/vendor/emitter/EventEmitter.js +16 -20
  215. package/flow/bom.js.flow +18 -17
  216. package/flow/dom.js.flow +12 -5
  217. package/flow/global.js +1 -1
  218. package/index.js +9 -0
  219. package/index.win32.js +9 -0
  220. package/index.win32.js.flow +8 -1
  221. package/jest/RefreshControlMock.js +2 -2
  222. package/jest/assetFileTransformer.js +8 -3
  223. package/jest/mockComponent.js +3 -4
  224. package/jest/mockNativeComponent.js +1 -1
  225. package/jest/mocks/ActivityIndicator.js +2 -2
  226. package/jest/mocks/Image.js +2 -2
  227. package/jest/mocks/Modal.js +2 -2
  228. package/jest/mocks/RefreshControl.js +3 -3
  229. package/jest/mocks/RendererProxy.js +2 -2
  230. package/jest/mocks/ScrollView.js +5 -5
  231. package/jest/mocks/Text.js +2 -2
  232. package/jest/mocks/TextInput.js +2 -2
  233. package/jest/mocks/View.js +2 -2
  234. package/jest/mocks/ViewNativeComponent.js +1 -1
  235. package/jest/mocks/requireNativeComponent.js +1 -1
  236. package/jest/mocks/useColorScheme.js +1 -1
  237. package/jest/setup.js +68 -31
  238. package/overrides.json +30 -36
  239. package/package.json +22 -19
  240. package/src/private/animated/NativeAnimatedHelper.js +2 -2
  241. package/src/private/animated/NativeAnimatedHelper.win32.js +2 -2
  242. package/src/private/animated/createAnimatedPropsMemoHook.js +19 -19
  243. package/src/private/components/virtualview/VirtualView.js +14 -21
  244. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +11 -10
  245. package/src/private/components/virtualview/VirtualViewNativeComponent.js +4 -4
  246. package/src/private/devsupport/devmenu/elementinspector/BorderBox.js +2 -2
  247. package/src/private/devsupport/devmenu/elementinspector/BoxInspector.js +3 -3
  248. package/src/private/devsupport/devmenu/elementinspector/ElementBox.js +4 -4
  249. package/src/private/devsupport/devmenu/elementinspector/ElementProperties.js +1 -1
  250. package/src/private/devsupport/devmenu/elementinspector/Inspector.js +39 -17
  251. package/src/private/devsupport/devmenu/elementinspector/InspectorOverlay.js +15 -3
  252. package/src/private/devsupport/devmenu/elementinspector/InspectorPanel.js +2 -2
  253. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -8
  254. package/src/private/devsupport/devmenu/elementinspector/StyleInspector.js +1 -1
  255. package/src/private/devsupport/devmenu/elementinspector/resolveBoxStyle.js +1 -1
  256. package/src/private/devsupport/devmenu/elementinspector/useExternalInspection.js +102 -0
  257. package/src/private/devsupport/rndevtools/FuseboxSessionObserver.js +12 -25
  258. package/src/private/devsupport/rndevtools/GlobalStateObserver.js +56 -0
  259. package/src/private/devsupport/rndevtools/TracingStateObserver.js +28 -0
  260. package/src/private/featureflags/ReactNativeFeatureFlags.js +71 -79
  261. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +2 -2
  262. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +14 -12
  263. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
  264. package/src/private/specs_DEPRECATED/components/ActivityIndicatorViewNativeComponent.js +1 -1
  265. package/src/private/specs_DEPRECATED/components/AndroidDrawerLayoutNativeComponent.js +3 -3
  266. package/src/private/specs_DEPRECATED/components/AndroidHorizontalScrollContentViewNativeComponent.js +1 -1
  267. package/src/private/specs_DEPRECATED/components/AndroidSwipeRefreshLayoutNativeComponent.js +2 -2
  268. package/src/private/specs_DEPRECATED/components/AndroidSwitchNativeComponent.js +2 -2
  269. package/src/private/specs_DEPRECATED/components/DebuggingOverlayNativeComponent.js +3 -3
  270. package/src/private/specs_DEPRECATED/components/ProgressBarAndroidNativeComponent.js +1 -1
  271. package/src/private/specs_DEPRECATED/components/PullToRefreshViewNativeComponent.js +1 -1
  272. package/src/private/specs_DEPRECATED/components/RCTInputAccessoryViewNativeComponent.js +1 -1
  273. package/src/private/specs_DEPRECATED/components/RCTModalHostViewNativeComponent.js +3 -3
  274. package/src/private/specs_DEPRECATED/components/RCTSafeAreaViewNativeComponent.js +1 -1
  275. package/src/private/specs_DEPRECATED/components/SwitchNativeComponent.js +2 -2
  276. package/src/private/specs_DEPRECATED/components/UnimplementedNativeViewNativeComponent.js +1 -1
  277. package/src/private/specs_DEPRECATED/modules/NativeImageLoaderIOS.js +1 -1
  278. package/src/private/styles/composeStyles.js +1 -1
  279. package/src/private/utilities/toError.js +27 -0
  280. package/src/private/utilities/toExtendedError.js +30 -0
  281. package/src/private/webapis/dom/events/Event.js +1 -1
  282. package/src/private/webapis/dom/events/EventHandlerAttributes.js +2 -2
  283. package/src/private/webapis/dom/events/EventTarget.js +3 -3
  284. package/src/private/webapis/dom/events/internals/EventInternals.js +2 -2
  285. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  286. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +2 -2
  287. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +14 -14
  288. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +2 -2
  289. package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
  290. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  291. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +8 -8
  292. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +6 -6
  293. package/src/private/webapis/mutationobserver/MutationObserver.js +2 -2
  294. package/src/private/webapis/mutationobserver/MutationRecord.js +2 -2
  295. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +1 -1
  296. package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +3 -3
  297. package/src/private/webapis/performance/LongTasks.js +3 -3
  298. package/src/private/webapis/performance/Performance.js +4 -4
  299. package/src/private/webapis/performance/PerformanceEntry.js +1 -1
  300. package/src/private/webapis/performance/PerformanceObserver.js +2 -2
  301. package/src/private/webapis/performance/specs/NativePerformance.js +8 -8
  302. package/src/private/webapis/structuredClone/structuredClone.js +2 -2
  303. package/src/types/globals.d.ts +4 -4
  304. package/src-win/Libraries/Components/EnterString.win32.tsx +2 -2
  305. package/src-win/Libraries/Components/Touchable/TouchableWin32.tsx +14 -14
  306. package/src-win/index.win32.js.flow +8 -1
  307. package/types/index.d.ts +2 -0
  308. package/Libraries/Components/View/ReactNativeViewAttributes.js +0 -60
  309. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +0 -94
  310. package/Libraries/Image/TextInlineImageNativeComponent.js +0 -49
@@ -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,751 +41,366 @@ 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
- // #[ Win32
59
- 'aria-level': ariaLevel,
60
- 'aria-multiselectable': ariaMultiselectable,
61
- 'aria-posinset': ariaPosinset,
62
- 'aria-required': ariaRequired,
63
- 'aria-setsize': ariaSetsize,
64
- 'aria-controls': ariaControls,
65
- 'aria-describedby': ariaDescribedBy,
66
- 'aria-description': ariaDescription,
67
- accessibilityLevel,
68
- accessibilityPositionInSet,
69
- accessibilitySetSize,
70
- accessibilityControls,
71
- accessibilityDescribedBy,
72
- accessibilityDescription,
73
- // #] Win32
74
- children,
75
- ellipsizeMode,
76
- disabled,
77
- id,
78
- nativeID,
79
- numberOfLines,
80
- onLongPress,
81
- onPress,
82
- onPressIn,
83
- onPressOut,
84
- onResponderGrant,
85
- onResponderMove,
86
- onResponderRelease,
87
- onResponderTerminate,
88
- onResponderTerminationRequest,
89
- onStartShouldSetResponder,
90
- pressRetentionOffset,
91
- role,
92
- selectable,
93
- selectionColor,
94
- suppressHighlighting,
95
- style,
96
- ...restProps
97
- }: {
98
- ref?: React.RefSetter<TextForwardRef>,
99
- ...TextProps,
100
- }) => {
101
- const processedProps = restProps as {
102
- ...NativeTextProps,
103
- };
104
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
105
- // #Win32 [
106
- const _accessibilityControls = ariaControls ?? accessibilityControls;
107
- const _accessibilityDescribedBy =
108
- ariaDescribedBy ?? accessibilityDescribedBy;
109
- const _accessibilityDescription =
110
- ariaDescription ?? accessibilityDescription;
111
- const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
112
- const _accessibilityPositionInSet =
113
- ariaPosinset ?? accessibilityPositionInSet;
114
- const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
115
- // ] #Win32
116
-
117
- let _accessibilityState: ?TextProps['accessibilityState'] =
118
- accessibilityState;
119
- if (
120
- ariaBusy != null ||
121
- ariaChecked != null ||
122
- ariaDisabled != null ||
123
- ariaExpanded != null ||
124
- ariaSelected != null
125
- ) {
126
- if (_accessibilityState != null) {
127
- _accessibilityState = {
128
- busy: ariaBusy ?? _accessibilityState.busy,
129
- checked: ariaChecked ?? _accessibilityState.checked,
130
- disabled: ariaDisabled ?? _accessibilityState.disabled,
131
- expanded: ariaExpanded ?? _accessibilityState.expanded,
132
- // #Win32 [
133
- multiselectable:
134
- ariaMultiselectable ?? accessibilityState?.multiselectable,
135
- required: ariaRequired ?? accessibilityState?.required,
136
- // ] #Win32
137
- selected: ariaSelected ?? _accessibilityState.selected,
138
- };
139
- } else {
140
- _accessibilityState = {
141
- busy: ariaBusy,
142
- checked: ariaChecked,
143
- disabled: ariaDisabled,
144
- expanded: ariaExpanded,
145
- // #Win32 [
146
- multiselectable: ariaMultiselectable,
147
- required: ariaRequired,
148
- // ] #Win32
149
- selected: ariaSelected,
150
- };
151
- }
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
+ // #[ Win32
62
+ 'aria-level': ariaLevel,
63
+ 'aria-multiselectable': ariaMultiselectable,
64
+ 'aria-posinset': ariaPosinset,
65
+ 'aria-required': ariaRequired,
66
+ 'aria-setsize': ariaSetsize,
67
+ 'aria-controls': ariaControls,
68
+ 'aria-describedby': ariaDescribedBy,
69
+ 'aria-description': ariaDescription,
70
+ accessibilityLevel,
71
+ accessibilityPositionInSet,
72
+ accessibilitySetSize,
73
+ accessibilityControls,
74
+ accessibilityDescribedBy,
75
+ accessibilityDescription,
76
+ // #] Win32
77
+ children,
78
+ ellipsizeMode,
79
+ disabled,
80
+ id,
81
+ nativeID,
82
+ numberOfLines,
83
+ onLongPress,
84
+ onPress,
85
+ onPressIn,
86
+ onPressOut,
87
+ onResponderGrant,
88
+ onResponderMove,
89
+ onResponderRelease,
90
+ onResponderTerminate,
91
+ onResponderTerminationRequest,
92
+ onStartShouldSetResponder,
93
+ pressRetentionOffset,
94
+ role,
95
+ selectable,
96
+ selectionColor,
97
+ suppressHighlighting,
98
+ style,
99
+ ...restProps
100
+ }: {
101
+ ref?: React.RefSetter<TextForwardRef>,
102
+ ...TextProps,
103
+ }) => {
104
+ const processedProps = restProps as {
105
+ ...NativeTextProps,
106
+ };
107
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
108
+ // #Win32 [
109
+ const _accessibilityControls = ariaControls ?? accessibilityControls;
110
+ const _accessibilityDescribedBy =
111
+ ariaDescribedBy ?? accessibilityDescribedBy;
112
+ const _accessibilityDescription =
113
+ ariaDescription ?? accessibilityDescription;
114
+ const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
115
+ const _accessibilityPositionInSet =
116
+ ariaPosinset ?? accessibilityPositionInSet;
117
+ const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
118
+ // ] #Win32
119
+
120
+ let _accessibilityState: ?TextProps['accessibilityState'] =
121
+ accessibilityState;
122
+ if (
123
+ ariaBusy != null ||
124
+ ariaChecked != null ||
125
+ ariaDisabled != null ||
126
+ ariaExpanded != null ||
127
+ ariaSelected != null
128
+ ) {
129
+ if (_accessibilityState != null) {
130
+ _accessibilityState = {
131
+ busy: ariaBusy ?? _accessibilityState.busy,
132
+ checked: ariaChecked ?? _accessibilityState.checked,
133
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
134
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
135
+ // #Win32 [
136
+ multiselectable:
137
+ ariaMultiselectable ?? accessibilityState?.multiselectable,
138
+ required: ariaRequired ?? accessibilityState?.required,
139
+ // ] #Win32
140
+ selected: ariaSelected ?? _accessibilityState.selected,
141
+ };
142
+ } else {
143
+ _accessibilityState = {
144
+ busy: ariaBusy,
145
+ checked: ariaChecked,
146
+ disabled: ariaDisabled,
147
+ expanded: ariaExpanded,
148
+ // #[ Win32
149
+ multiselectable: ariaMultiselectable,
150
+ required: ariaRequired,
151
+ // #] Win32
152
+ selected: ariaSelected,
153
+ };
152
154
  }
153
-
154
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
155
- const _disabled = disabled ?? _accessibilityStateDisabled;
156
-
157
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
158
- // falsy states we need to update the accessibilityState object to use the disabled prop.
159
- if (
160
- _accessibilityState != null &&
161
- _disabled !== _accessibilityStateDisabled &&
162
- ((_disabled != null && _disabled !== false) ||
163
- (_accessibilityStateDisabled != null &&
164
- _accessibilityStateDisabled !== false))
165
- ) {
155
+ }
156
+
157
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
158
+ const _disabled = disabled ?? _accessibilityStateDisabled;
159
+
160
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
161
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
162
+ if (
163
+ _disabled !== _accessibilityStateDisabled &&
164
+ ((_disabled != null && _disabled !== false) ||
165
+ (_accessibilityStateDisabled != null &&
166
+ _accessibilityStateDisabled !== false))
167
+ ) {
168
+ if (_accessibilityState == null) {
169
+ _accessibilityState = {disabled};
170
+ } else {
166
171
  _accessibilityState.disabled = _disabled;
167
172
  }
173
+ }
168
174
 
169
- if (ariaHidden !== undefined) {
170
- processedProps.accessibilityElementsHidden = ariaHidden;
171
- if (ariaHidden === true) {
172
- processedProps.importantForAccessibility = 'no-hide-descendants';
173
- }
174
- }
175
-
176
- const _accessible = Platform.select({
177
- ios: accessible !== false,
178
- android:
179
- accessible == null
180
- ? onPress != null || onLongPress != null
181
- : accessible,
182
- default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
183
- });
184
-
185
- const isPressable =
186
- (onPress != null ||
187
- onLongPress != null ||
188
- onStartShouldSetResponder != null) &&
189
- _disabled !== true;
190
-
191
- const shouldUseLinkRole =
192
- ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
193
- isPressable &&
194
- accessibilityRole == null &&
195
- role == null;
196
-
197
- const _accessibilityRole =
198
- accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
199
-
200
- const _role = shouldUseLinkRole ? undefined : role;
201
-
202
- // TODO: Move this processing to the view configuration.
203
- const _selectionColor =
204
- selectionColor != null ? processColor(selectionColor) : undefined;
205
-
206
- let _style = style;
207
- if (__DEV__) {
208
- if (PressabilityDebug.isEnabled() && onPress != null) {
209
- _style = [style, {color: 'magenta'}];
210
- }
211
- }
212
-
213
- let _numberOfLines = numberOfLines;
214
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
215
- if (__DEV__) {
216
- console.error(
217
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
218
- );
219
- }
220
- _numberOfLines = 0;
175
+ if (ariaHidden !== undefined) {
176
+ processedProps.accessibilityElementsHidden = ariaHidden;
177
+ if (ariaHidden === true) {
178
+ processedProps.importantForAccessibility = 'no-hide-descendants';
221
179
  }
180
+ }
222
181
 
223
- let _selectable = selectable;
224
-
225
- let processedStyle = flattenStyle<TextStyleProp>(_style);
226
- if (processedStyle != null) {
227
- let overrides: ?{...TextStyleInternal} = null;
228
- if (typeof processedStyle.fontWeight === 'number') {
229
- overrides = overrides || ({}: {...TextStyleInternal});
230
- overrides.fontWeight =
231
- // $FlowFixMe[incompatible-type]
232
- (String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
233
- }
234
-
235
- if (processedStyle.userSelect != null) {
236
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
237
- overrides = overrides || ({}: {...TextStyleInternal});
238
- overrides.userSelect = undefined;
239
- }
182
+ const _accessible = Platform.select({
183
+ ios: accessible !== false,
184
+ android:
185
+ accessible == null ? onPress != null || onLongPress != null : accessible,
186
+ default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
187
+ });
240
188
 
241
- if (processedStyle.verticalAlign != null) {
242
- overrides = overrides || ({}: {...TextStyleInternal});
243
- overrides.textAlignVertical =
244
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
245
- overrides.verticalAlign = undefined;
246
- }
189
+ const isPressable =
190
+ (onPress != null ||
191
+ onLongPress != null ||
192
+ onStartShouldSetResponder != null) &&
193
+ _disabled !== true;
247
194
 
248
- if (overrides != null) {
249
- // $FlowFixMe[incompatible-type]
250
- _style = [_style, overrides];
251
- }
252
- }
195
+ const shouldUseLinkRole =
196
+ isPressable && accessibilityRole == null && role == null;
253
197
 
254
- const _nativeID = id ?? nativeID;
198
+ const _accessibilityRole =
199
+ accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
255
200
 
256
- if (_accessibilityLabel !== undefined) {
257
- processedProps.accessibilityLabel = _accessibilityLabel;
258
- }
259
- if (_accessibilityRole !== undefined) {
260
- processedProps.accessibilityRole = _accessibilityRole;
261
- }
262
- if (_accessibilityState !== undefined) {
263
- processedProps.accessibilityState = _accessibilityState;
264
- }
265
- if (_nativeID !== undefined) {
266
- processedProps.nativeID = _nativeID;
267
- }
268
- if (_numberOfLines !== undefined) {
269
- processedProps.numberOfLines = _numberOfLines;
270
- }
271
- if (_selectable !== undefined) {
272
- processedProps.selectable = _selectable;
273
- }
274
- if (_style !== undefined) {
275
- processedProps.style = _style;
276
- }
277
- if (_selectionColor !== undefined) {
278
- processedProps.selectionColor = _selectionColor;
279
- }
280
- if (_role !== undefined) {
281
- processedProps.role = _role;
282
- }
283
-
284
- // [Windows accessibility properties
285
- if (_accessibilityControls !== undefined) {
286
- processedProps.accessibilityControls = _accessibilityControls;
287
- }
201
+ const _role = shouldUseLinkRole ? undefined : role;
288
202
 
289
- if (_accessibilityDescribedBy !== undefined) {
290
- processedProps.accessibilityDescribedBy = _accessibilityDescribedBy;
291
- }
203
+ // TODO: Move this processing to the view configuration.
204
+ const _selectionColor =
205
+ selectionColor != null ? processColor(selectionColor) : undefined;
292
206
 
293
- if (_accessibilityDescription !== undefined) {
294
- processedProps.accessibilityDescription = _accessibilityDescription;
207
+ let _style = style;
208
+ if (__DEV__) {
209
+ if (PressabilityDebug.isEnabled() && onPress != null) {
210
+ _style = [style, {color: 'magenta'}];
295
211
  }
212
+ }
296
213
 
297
- if (_accessibilityLevel !== undefined) {
298
- processedProps.accessibilityLevel = _accessibilityLevel;
299
- }
300
- if (_accessibilityPositionInSet !== undefined) {
301
- processedProps.accessibilityPositionInSet = _accessibilityPositionInSet;
302
- }
303
- if (_accessibilitySetSize !== undefined) {
304
- processedProps.accessibilitySetSize = _accessibilitySetSize;
305
- }
306
- // ]
307
-
308
- let textPressabilityProps: ?TextPressabilityProps;
309
- if (isPressable) {
310
- textPressabilityProps = {
311
- onLongPress,
312
- onPress,
313
- onPressIn,
314
- onPressOut,
315
- onResponderGrant,
316
- onResponderMove,
317
- onResponderRelease,
318
- onResponderTerminate,
319
- onResponderTerminationRequest,
320
- onStartShouldSetResponder,
321
- pressRetentionOffset,
322
- suppressHighlighting,
323
- };
214
+ let _numberOfLines = numberOfLines;
215
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
216
+ if (__DEV__) {
217
+ console.error(
218
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
219
+ );
324
220
  }
221
+ _numberOfLines = 0;
222
+ }
325
223
 
326
- const hasTextAncestor = useContext(TextAncestorContext);
327
- if (hasTextAncestor) {
328
- processedProps.disabled = disabled;
329
- processedProps.children = children;
330
- if (isPressable) {
331
- return (
332
- <NativePressableVirtualText
333
- ref={forwardedRef}
334
- textProps={processedProps}
335
- textPressabilityProps={textPressabilityProps ?? {}}
336
- />
337
- );
338
- }
339
- return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
340
- }
224
+ let _selectable = selectable;
341
225
 
342
- let nativeText = null;
226
+ let processedStyle = flattenStyle<TextStyleProp>(_style);
227
+ if (processedStyle != null) {
228
+ let overrides: ?{...TextStyleInternal} = null;
229
+ if (typeof processedStyle.fontWeight === 'number') {
230
+ overrides = overrides || ({}: {...TextStyleInternal});
231
+ overrides.fontWeight =
232
+ // $FlowFixMe[incompatible-type]
233
+ (String(processedStyle.fontWeight): TextStyleInternal['fontWeight']);
234
+ }
235
+
236
+ if (processedStyle.userSelect != null) {
237
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
238
+ overrides = overrides || ({}: {...TextStyleInternal});
239
+ overrides.userSelect = undefined;
240
+ }
241
+
242
+ if (processedStyle.verticalAlign != null) {
243
+ overrides = overrides || ({}: {...TextStyleInternal});
244
+ overrides.textAlignVertical =
245
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
246
+ overrides.verticalAlign = undefined;
247
+ }
248
+
249
+ if (overrides != null) {
250
+ // $FlowFixMe[incompatible-type]
251
+ _style = [_style, overrides];
252
+ }
253
+ }
254
+
255
+ if (ReactNativeFeatureFlags.defaultTextToOverflowHidden()) {
256
+ _style = [styles.default, _style];
257
+ }
258
+
259
+ const _nativeID = id ?? nativeID;
260
+
261
+ if (_accessibilityLabel !== undefined) {
262
+ processedProps.accessibilityLabel = _accessibilityLabel;
263
+ }
264
+ if (_accessibilityRole !== undefined) {
265
+ processedProps.accessibilityRole = _accessibilityRole;
266
+ }
267
+ if (_accessibilityState !== undefined) {
268
+ processedProps.accessibilityState = _accessibilityState;
269
+ }
270
+ if (_nativeID !== undefined) {
271
+ processedProps.nativeID = _nativeID;
272
+ }
273
+ if (_numberOfLines !== undefined) {
274
+ processedProps.numberOfLines = _numberOfLines;
275
+ }
276
+ if (_selectable !== undefined) {
277
+ processedProps.selectable = _selectable;
278
+ }
279
+ if (_style !== undefined) {
280
+ processedProps.style = _style;
281
+ }
282
+ if (_selectionColor !== undefined) {
283
+ processedProps.selectionColor = _selectionColor;
284
+ }
285
+ if (_role !== undefined) {
286
+ processedProps.role = _role;
287
+ }
288
+
289
+ // [Windows accessibility properties
290
+ if (_accessibilityControls !== undefined) {
291
+ processedProps.accessibilityControls = _accessibilityControls;
292
+ }
293
+
294
+ if (_accessibilityDescribedBy !== undefined) {
295
+ processedProps.accessibilityDescribedBy = _accessibilityDescribedBy;
296
+ }
297
+
298
+ if (_accessibilityDescription !== undefined) {
299
+ processedProps.accessibilityDescription = _accessibilityDescription;
300
+ }
301
+
302
+ if (_accessibilityLevel !== undefined) {
303
+ processedProps.accessibilityLevel = _accessibilityLevel;
304
+ }
305
+ if (_accessibilityPositionInSet !== undefined) {
306
+ processedProps.accessibilityPositionInSet = _accessibilityPositionInSet;
307
+ }
308
+ if (_accessibilitySetSize !== undefined) {
309
+ processedProps.accessibilitySetSize = _accessibilitySetSize;
310
+ }
311
+ // ]
312
+
313
+ let textPressabilityProps: ?TextPressabilityProps;
314
+ if (isPressable) {
315
+ textPressabilityProps = {
316
+ onLongPress,
317
+ onPress,
318
+ onPressIn,
319
+ onPressOut,
320
+ onResponderGrant,
321
+ onResponderMove,
322
+ onResponderRelease,
323
+ onResponderTerminate,
324
+ onResponderTerminationRequest,
325
+ onStartShouldSetResponder,
326
+ pressRetentionOffset,
327
+ suppressHighlighting,
328
+ };
329
+ }
343
330
 
344
- processedProps.accessible = _accessible;
345
- processedProps.allowFontScaling = allowFontScaling !== false;
346
- processedProps.disabled = _disabled;
347
- processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
331
+ const hasTextAncestor = useContext(TextAncestorContext);
332
+ if (hasTextAncestor) {
333
+ processedProps.disabled = disabled;
348
334
  processedProps.children = children;
349
-
350
335
  if (isPressable) {
351
- nativeText = (
352
- <NativePressableText
336
+ return (
337
+ <PressableVirtualText
353
338
  ref={forwardedRef}
354
339
  textProps={processedProps}
355
340
  textPressabilityProps={textPressabilityProps ?? {}}
356
341
  />
357
342
  );
358
- } else {
359
- nativeText = <NativeText {...processedProps} ref={forwardedRef} />;
360
- }
361
-
362
- if (children == null) {
363
- return nativeText;
364
- }
365
-
366
- // If the children do not contain a JSX element it would not be possible to have a
367
- // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
368
- // which has a performance overhead. Since we do this for performance reasons we need
369
- // to keep the check simple to avoid regressing overall perf. For this reason the
370
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
371
- // to capture the majority of `Text` uses but also not make this check too expensive.
372
- if (Array.isArray(children) && children.length <= 3) {
373
- let hasNonTextChild = false;
374
- for (let child of children) {
375
- if (child != null && typeof child === 'object') {
376
- hasNonTextChild = true;
377
- break;
378
- }
379
- }
380
- if (!hasNonTextChild) {
381
- return nativeText;
382
- }
383
- } else if (typeof children !== 'object') {
384
- return nativeText;
385
- }
386
-
387
- return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
388
- };
389
- _TextImpl = TextImplNoDefaultProps;
390
- } else {
391
- const TextImplLegacy: component(
392
- ref?: React.RefSetter<TextForwardRef>,
393
- ...props: TextProps
394
- ) = ({
395
- ref: forwardedRef,
396
- accessible,
397
- accessibilityElementsHidden,
398
- importantForAccessibility,
399
- accessibilityLabel,
400
- accessibilityRole,
401
- accessibilityState,
402
- allowFontScaling,
403
- 'aria-busy': ariaBusy,
404
- 'aria-checked': ariaChecked,
405
- 'aria-disabled': ariaDisabled,
406
- 'aria-expanded': ariaExpanded,
407
- 'aria-hidden': ariaHidden,
408
- 'aria-label': ariaLabel,
409
- 'aria-selected': ariaSelected,
410
- //#[ Win32
411
- 'aria-controls': ariaControls,
412
- 'aria-describedby': ariaDescribedBy,
413
- 'aria-description': ariaDescription,
414
- 'aria-level': ariaLevel,
415
- 'aria-multiselectable': ariaMultiselectable,
416
- 'aria-posinset': ariaPosinset,
417
- 'aria-required': ariaRequired,
418
- 'aria-setsize': ariaSetsize,
419
- accessibilityLevel,
420
- accessibilityPositionInSet,
421
- accessibilitySetSize,
422
- accessibilityControls,
423
- accessibilityDescribedBy,
424
- accessibilityDescription,
425
- // #] Win32
426
- children,
427
- ellipsizeMode,
428
- disabled,
429
- id,
430
- nativeID,
431
- numberOfLines,
432
- onLongPress,
433
- onPress,
434
- onPressIn,
435
- onPressOut,
436
- onResponderGrant,
437
- onResponderMove,
438
- onResponderRelease,
439
- onResponderTerminate,
440
- onResponderTerminationRequest,
441
- onStartShouldSetResponder,
442
- pressRetentionOffset,
443
- role,
444
- selectable,
445
- selectionColor,
446
- suppressHighlighting,
447
- style,
448
- ...restProps
449
- }: {
450
- ref?: React.RefSetter<TextForwardRef>,
451
- ...TextProps,
452
- }) => {
453
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
454
- //#[ Win32
455
- const _accessibilityControls = ariaControls ?? accessibilityControls;
456
- const _accessibilityDescribedBy =
457
- ariaDescribedBy ?? accessibilityDescribedBy;
458
- const _accessibilityDescription =
459
- ariaDescription ?? accessibilityDescription;
460
- const _accessibilityLevel = ariaLevel ?? accessibilityLevel;
461
- const _accessibilityPositionInSet =
462
- ariaPosinset ?? accessibilityPositionInSet;
463
- const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize;
464
- //#] Win32
465
-
466
- let _accessibilityState: ?TextProps['accessibilityState'] =
467
- accessibilityState;
468
- if (
469
- ariaBusy != null ||
470
- ariaChecked != null ||
471
- ariaDisabled != null ||
472
- ariaExpanded != null ||
473
- ariaSelected != null
474
- ) {
475
- if (_accessibilityState != null) {
476
- _accessibilityState = {
477
- busy: ariaBusy ?? _accessibilityState.busy,
478
- checked: ariaChecked ?? _accessibilityState.checked,
479
- disabled: ariaDisabled ?? _accessibilityState.disabled,
480
- expanded: ariaExpanded ?? _accessibilityState.expanded,
481
- //#[Win32
482
- multiselectable:
483
- ariaMultiselectable ?? accessibilityState?.multiselectable,
484
- required: ariaRequired ?? accessibilityState?.required,
485
- // #] Win32
486
- selected: ariaSelected ?? _accessibilityState.selected,
487
- };
488
- } else {
489
- _accessibilityState = {
490
- busy: ariaBusy,
491
- checked: ariaChecked,
492
- disabled: ariaDisabled,
493
- expanded: ariaExpanded,
494
- // #[ Win32
495
- multiselectable: ariaMultiselectable,
496
- required: ariaRequired,
497
- // #]win32
498
- selected: ariaSelected,
499
- };
500
- }
501
- }
502
-
503
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
504
- const _disabled = disabled ?? _accessibilityStateDisabled;
505
-
506
- let _accessibilityElementsHidden =
507
- ariaHidden ?? accessibilityElementsHidden;
508
- let _importantForAccessibility = importantForAccessibility;
509
- if (ariaHidden === true) {
510
- _importantForAccessibility = 'no-hide-descendants';
511
- }
512
-
513
- const isPressable =
514
- (onPress != null ||
515
- onLongPress != null ||
516
- onStartShouldSetResponder != null) &&
517
- _disabled !== true;
518
-
519
- const shouldUseLinkRole =
520
- ReactNativeFeatureFlags.shouldUseLinkRoleForPressableText() &&
521
- isPressable &&
522
- accessibilityRole == null &&
523
- role == null;
524
-
525
- const _accessibilityRole =
526
- accessibilityRole ?? (shouldUseLinkRole ? 'link' : undefined);
527
-
528
- const _role = shouldUseLinkRole ? undefined : role;
529
-
530
- // TODO: Move this processing to the view configuration.
531
- const _selectionColor =
532
- selectionColor != null ? processColor(selectionColor) : undefined;
533
-
534
- let _style = style;
535
- if (__DEV__) {
536
- if (PressabilityDebug.isEnabled() && onPress != null) {
537
- _style = [style, {color: 'magenta'}];
538
- }
539
- }
540
-
541
- let _numberOfLines = numberOfLines;
542
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
543
- if (__DEV__) {
544
- console.error(
545
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
546
- );
547
- }
548
- _numberOfLines = 0;
549
- }
550
-
551
- let _selectable = selectable;
552
-
553
- let processedStyle = flattenStyle<TextStyleProp>(_style);
554
- if (processedStyle != null) {
555
- let overrides: ?{...TextStyleInternal} = null;
556
- if (typeof processedStyle.fontWeight === 'number') {
557
- overrides = overrides || ({}: {...TextStyleInternal});
558
- overrides.fontWeight =
559
- // $FlowFixMe[incompatible-type]
560
- (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
561
- }
562
-
563
- if (processedStyle.userSelect != null) {
564
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
565
- overrides = overrides || ({}: {...TextStyleInternal});
566
- overrides.userSelect = undefined;
567
- }
568
-
569
- if (processedStyle.verticalAlign != null) {
570
- overrides = overrides || ({}: {...TextStyleInternal});
571
- overrides.textAlignVertical =
572
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
573
- overrides.verticalAlign = undefined;
574
- }
575
-
576
- if (overrides != null) {
577
- // $FlowFixMe[incompatible-type]
578
- _style = [_style, overrides];
579
- }
580
- }
581
-
582
- const _nativeID = id ?? nativeID;
583
-
584
- const hasTextAncestor = useContext(TextAncestorContext);
585
- if (hasTextAncestor) {
586
- if (isPressable) {
587
- return (
588
- <NativePressableVirtualText
589
- ref={forwardedRef}
590
- textProps={{
591
- ...restProps,
592
- accessibilityElementsHidden: _accessibilityElementsHidden,
593
- accessibilityLabel: _accessibilityLabel,
594
- accessibilityRole: _accessibilityRole,
595
- accessibilityState: _accessibilityState,
596
- importantForAccessibility: _importantForAccessibility,
597
- // #[ Win32
598
- accessibilityControls: _accessibilityControls,
599
- accessibilityDescribedBy: _accessibilityDescribedBy,
600
- accessibilityDescription: _accessibilityDescription,
601
- accessibilityLevel: _accessibilityLevel,
602
- accessibilityPositionInSet: _accessibilityPositionInSet,
603
- accessibilitySetSize: _accessibilitySetSize,
604
- // #] Win32
605
- nativeID: _nativeID,
606
- numberOfLines: _numberOfLines,
607
- selectable: _selectable,
608
- selectionColor: _selectionColor,
609
- style: _style,
610
- disabled: disabled,
611
- role: _role,
612
- children,
613
- }}
614
- textPressabilityProps={{
615
- onLongPress,
616
- onPress,
617
- onPressIn,
618
- onPressOut,
619
- onResponderGrant,
620
- onResponderMove,
621
- onResponderRelease,
622
- onResponderTerminate,
623
- onResponderTerminationRequest,
624
- onStartShouldSetResponder,
625
- pressRetentionOffset,
626
- suppressHighlighting,
627
- }}
628
- />
629
- );
630
- }
631
-
632
- return (
633
- <NativeVirtualText
634
- {...restProps}
635
- accessibilityElementsHidden={_accessibilityElementsHidden}
636
- accessibilityLabel={_accessibilityLabel}
637
- accessibilityRole={_accessibilityRole}
638
- accessibilityState={_accessibilityState}
639
- importantForAccessibility={_importantForAccessibility}
640
- // #[ Win32
641
- accessibilityControls={_accessibilityControls}
642
- accessibilityDescribedBy={_accessibilityDescribedBy}
643
- accessibilityDescription={_accessibilityDescription}
644
- accessibilityLevel={_accessibilityLevel}
645
- accessibilityPositionInSet={_accessibilityPositionInSet}
646
- accessibilitySetSize={_accessibilitySetSize}
647
- // #] Win32
648
- nativeID={_nativeID}
649
- numberOfLines={_numberOfLines}
650
- ref={forwardedRef}
651
- selectable={_selectable}
652
- selectionColor={_selectionColor}
653
- style={_style}
654
- disabled={disabled}
655
- role={_role}>
656
- {children}
657
- </NativeVirtualText>
658
- );
659
343
  }
660
-
661
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
662
- // falsy states we need to update the accessibilityState object to use the disabled prop.
663
- if (
664
- _disabled !== _accessibilityStateDisabled &&
665
- ((_disabled != null && _disabled !== false) ||
666
- (_accessibilityStateDisabled != null &&
667
- _accessibilityStateDisabled !== false))
668
- ) {
669
- _accessibilityState = {..._accessibilityState, disabled: _disabled};
670
- }
671
-
672
- const _accessible = Platform.select({
673
- ios: accessible !== false,
674
- android:
675
- accessible == null
676
- ? onPress != null || onLongPress != null
677
- : accessible,
678
- default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
679
- });
680
-
681
- let nativeText = null;
682
- if (isPressable) {
683
- nativeText = (
684
- <NativePressableText
685
- ref={forwardedRef}
686
- textProps={{
687
- ...restProps,
688
- accessibilityElementsHidden: _accessibilityElementsHidden,
689
- accessibilityLabel: _accessibilityLabel,
690
- accessibilityRole: _accessibilityRole,
691
- accessibilityState: _accessibilityState,
692
- accessible: _accessible,
693
- allowFontScaling: allowFontScaling !== false,
694
- disabled: _disabled,
695
- ellipsizeMode: ellipsizeMode ?? 'tail',
696
- importantForAccessibility: _importantForAccessibility,
697
- nativeID: _nativeID,
698
- numberOfLines: _numberOfLines,
699
- selectable: _selectable,
700
- selectionColor: _selectionColor,
701
- style: _style,
702
- role: _role,
703
- children,
704
- }}
705
- textPressabilityProps={{
706
- onLongPress,
707
- onPress,
708
- onPressIn,
709
- onPressOut,
710
- onResponderGrant,
711
- onResponderMove,
712
- onResponderRelease,
713
- onResponderTerminate,
714
- onResponderTerminationRequest,
715
- onStartShouldSetResponder,
716
- pressRetentionOffset,
717
- suppressHighlighting,
718
- }}
719
- />
720
- );
721
- } else {
722
- nativeText = (
723
- <NativeText
724
- {...restProps}
725
- accessibilityElementsHidden={_accessibilityElementsHidden}
726
- accessibilityLabel={_accessibilityLabel}
727
- accessibilityRole={_accessibilityRole}
728
- accessibilityState={_accessibilityState}
729
- accessible={_accessible}
730
- allowFontScaling={allowFontScaling !== false}
731
- disabled={_disabled}
732
- ellipsizeMode={ellipsizeMode ?? 'tail'}
733
- importantForAccessibility={_importantForAccessibility}
734
- nativeID={_nativeID}
735
- numberOfLines={_numberOfLines}
736
- ref={forwardedRef}
737
- selectable={_selectable}
738
- selectionColor={_selectionColor}
739
- style={_style}
740
- role={_role}>
741
- {children}
742
- </NativeText>
344
+ return <NativeVirtualText {...processedProps} ref={forwardedRef} />;
345
+ }
346
+
347
+ let nativeText = null;
348
+
349
+ processedProps.accessible = _accessible;
350
+ processedProps.allowFontScaling = allowFontScaling !== false;
351
+ processedProps.disabled = _disabled;
352
+ processedProps.ellipsizeMode = ellipsizeMode ?? 'tail';
353
+ processedProps.children = children;
354
+
355
+ if (isPressable) {
356
+ nativeText = (
357
+ <PressableText
358
+ ref={forwardedRef}
359
+ selectable={_selectable}
360
+ textProps={processedProps}
361
+ textPressabilityProps={textPressabilityProps ?? {}}
362
+ />
363
+ );
364
+ } else {
365
+ nativeText =
366
+ _selectable === true ? (
367
+ <NativeSelectableText {...processedProps} ref={forwardedRef} />
368
+ ) : (
369
+ <NativeText {...processedProps} ref={forwardedRef} />
743
370
  );
744
- }
745
-
746
- if (children == null) {
747
- return nativeText;
748
- }
749
-
750
- // If the children do not contain a JSX element it would not be possible to have a
751
- // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
752
- // which has a performance overhead. Since we do this for performance reasons we need
753
- // to keep the check simple to avoid regressing overall perf. For this reason the
754
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
755
- // to capture the majority of `Text` uses but also not make this check too expensive.
756
- if (Array.isArray(children) && children.length <= 3) {
757
- let hasNonTextChild = false;
758
- for (let child of children) {
759
- if (child != null && typeof child === 'object') {
760
- hasNonTextChild = true;
761
- break;
762
- }
371
+ }
372
+
373
+ if (children == null) {
374
+ return nativeText;
375
+ }
376
+
377
+ // If the children do not contain a JSX element it would not be possible to have a
378
+ // nested `Text` component so we can skip adding the `TextAncestorContext` context wrapper
379
+ // which has a performance overhead. Since we do this for performance reasons we need
380
+ // to keep the check simple to avoid regressing overall perf. For this reason the
381
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
382
+ // to capture the majority of `Text` uses but also not make this check too expensive.
383
+ if (Array.isArray(children) && children.length <= 3) {
384
+ let hasNonTextChild = false;
385
+ for (let child of children) {
386
+ if (child != null && typeof child === 'object') {
387
+ hasNonTextChild = true;
388
+ break;
763
389
  }
764
- if (!hasNonTextChild) {
765
- return nativeText;
766
- }
767
- } else if (typeof children !== 'object') {
390
+ }
391
+ if (!hasNonTextChild) {
768
392
  return nativeText;
769
393
  }
394
+ } else if (typeof children !== 'object') {
395
+ return nativeText;
396
+ }
770
397
 
771
- return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
772
- };
773
- _TextImpl = TextImplLegacy;
774
- }
775
-
776
- const TextImpl: component(
777
- ref?: React.RefSetter<TextForwardRef>,
778
- ...props: TextProps
779
- ) = _TextImpl;
398
+ return <TextAncestorContext value={true}>{nativeText}</TextAncestorContext>;
399
+ };
780
400
 
781
401
  TextImpl.displayName = 'Text';
782
402
 
783
- type TextPressabilityProps = $ReadOnly<{
403
+ type TextPressabilityProps = Readonly<{
784
404
  onLongPress?: ?(event: GestureResponderEvent) => unknown,
785
405
  onPress?: ?(event: GestureResponderEvent) => unknown,
786
406
  onPressIn?: ?(event: GestureResponderEvent) => unknown,
@@ -914,28 +534,17 @@ function useTextPressability({
914
534
  );
915
535
  }
916
536
 
917
- type NativePressableTextProps = $ReadOnly<{
918
- textProps: NativeTextProps,
919
- textPressabilityProps: TextPressabilityProps,
920
- }>;
921
-
922
537
  /**
923
538
  * Wrap the NativeVirtualText component and initialize pressability.
924
539
  *
925
540
  * This logic is split out from the main Text component to enable the more
926
541
  * expensive pressability logic to be only initialized when needed.
927
542
  */
928
- const NativePressableVirtualText: component(
929
- ref: React.RefSetter<TextForwardRef>,
930
- ...props: NativePressableTextProps
931
- ) = ({
932
- ref: forwardedRef,
933
- textProps,
934
- textPressabilityProps,
935
- }: {
543
+ component PressableVirtualText(
936
544
  ref?: React.RefSetter<TextForwardRef>,
937
- ...NativePressableTextProps,
938
- }) => {
545
+ textProps: NativeTextProps,
546
+ textPressabilityProps: TextPressabilityProps,
547
+ ) {
939
548
  const [isHighlighted, eventHandlersForText] = useTextPressability(
940
549
  textPressabilityProps,
941
550
  );
@@ -946,42 +555,40 @@ const NativePressableVirtualText: component(
946
555
  {...eventHandlersForText}
947
556
  isHighlighted={isHighlighted}
948
557
  isPressable={true}
949
- ref={forwardedRef}
558
+ ref={ref}
950
559
  />
951
560
  );
952
- };
561
+ }
953
562
 
954
563
  /**
955
- * Wrap the NativeText component and initialize pressability.
564
+ * Wrap a NativeText component and initialize pressability.
956
565
  *
957
566
  * This logic is split out from the main Text component to enable the more
958
567
  * expensive pressability logic to be only initialized when needed.
959
568
  */
960
- const NativePressableText: component(
961
- ref: React.RefSetter<TextForwardRef>,
962
- ...props: NativePressableTextProps
963
- ) = ({
964
- ref: forwardedRef,
965
- textProps,
966
- textPressabilityProps,
967
- }: {
569
+ component PressableText(
968
570
  ref?: React.RefSetter<TextForwardRef>,
969
- ...NativePressableTextProps,
970
- }) => {
571
+ selectable?: ?boolean,
572
+ textProps: NativeTextProps,
573
+ textPressabilityProps: TextPressabilityProps,
574
+ ) {
971
575
  const [isHighlighted, eventHandlersForText] = useTextPressability(
972
576
  textPressabilityProps,
973
577
  );
974
578
 
579
+ const NativeComponent =
580
+ selectable === true ? NativeSelectableText : NativeText;
581
+
975
582
  return (
976
- <NativeText
583
+ <NativeComponent
977
584
  {...textProps}
978
585
  {...eventHandlersForText}
979
586
  isHighlighted={isHighlighted}
980
587
  isPressable={true}
981
- ref={forwardedRef}
588
+ ref={ref}
982
589
  />
983
590
  );
984
- };
591
+ }
985
592
 
986
593
  const userSelectToSelectableMap = {
987
594
  auto: true,
@@ -998,4 +605,13 @@ const verticalAlignToTextAlignVerticalMap = {
998
605
  middle: 'center',
999
606
  } as const;
1000
607
 
608
+ const styles = StyleSheet.create({
609
+ // Native components have historically acted like overflow: 'hidden'. We set
610
+ // this, as part of the default style, to let client differentiate with
611
+ // overflow: 'visible'.
612
+ default: {
613
+ overflow: 'hidden',
614
+ },
615
+ });
616
+
1001
617
  export default TextImpl;