@office-iss/react-native-win32 0.72.8 → 0.73.0-preview.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/.flowconfig +15 -5
  2. package/CHANGELOG.json +530 -101
  3. package/CHANGELOG.md +213 -56
  4. package/IntegrationTests/PromiseTest.js +1 -0
  5. package/IntegrationTests/websocket_integration_test_server.js +1 -1
  6. package/Libraries/Animated/Animated.js +1 -1
  7. package/Libraries/Animated/AnimatedImplementation.js +1 -1
  8. package/Libraries/Animated/NativeAnimatedHelper.js +14 -10
  9. package/Libraries/Animated/NativeAnimatedHelper.win32.js +16 -12
  10. package/Libraries/Animated/NativeAnimatedModule.js +6 -2
  11. package/Libraries/Animated/NativeAnimatedTurboModule.js +7 -4
  12. package/Libraries/Animated/animations/Animation.js +57 -3
  13. package/Libraries/Animated/animations/DecayAnimation.js +9 -0
  14. package/Libraries/Animated/animations/SpringAnimation.js +8 -0
  15. package/Libraries/Animated/animations/TimingAnimation.js +8 -0
  16. package/Libraries/Animated/components/AnimatedFlatList.js +2 -1
  17. package/Libraries/Animated/components/AnimatedScrollView.js +2 -0
  18. package/Libraries/Animated/components/AnimatedSectionList.js +2 -1
  19. package/Libraries/Animated/createAnimatedComponent.js +1 -0
  20. package/Libraries/Animated/nodes/AnimatedColor.js +1 -1
  21. package/Libraries/Animated/nodes/AnimatedObject.js +146 -0
  22. package/Libraries/Animated/nodes/AnimatedProps.js +19 -7
  23. package/Libraries/Animated/nodes/AnimatedStyle.js +29 -55
  24. package/Libraries/Animated/nodes/AnimatedValueXY.js +3 -17
  25. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +17 -0
  26. package/Libraries/Animated/useAnimatedProps.js +9 -10
  27. package/Libraries/AppState/AppState.d.ts +1 -1
  28. package/Libraries/AppState/NativeAppState.js +8 -4
  29. package/Libraries/BatchedBridge/MessageQueue.js +45 -36
  30. package/Libraries/Blob/Blob.js +6 -2
  31. package/Libraries/Blob/BlobManager.js +9 -10
  32. package/Libraries/Blob/BlobRegistry.js +14 -9
  33. package/Libraries/Blob/File.js +1 -1
  34. package/Libraries/Blob/FileReader.js +1 -2
  35. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +1 -5
  36. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +7 -48
  37. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +1 -1
  38. package/Libraries/Components/Button/ButtonWin32.Props.js.map +1 -1
  39. package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
  40. package/Libraries/Components/Button/ButtonWin32.js +1 -4
  41. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  42. package/Libraries/Components/Clipboard/Clipboard.d.ts +4 -4
  43. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +3 -1
  44. package/Libraries/Components/EnterString.win32.d.ts +1 -1
  45. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +26 -6
  46. package/Libraries/Components/Pressable/Pressable.js +3 -2
  47. package/Libraries/Components/Pressable/Pressable.win32.js +4 -3
  48. package/Libraries/Components/Pressable/useAndroidRippleForView.js +1 -1
  49. package/Libraries/Components/SafeAreaView/SafeAreaView.js +7 -7
  50. package/Libraries/Components/SafeAreaView/SafeAreaView.win32.js +7 -8
  51. package/Libraries/Components/ScrollView/ScrollView.js +3 -1
  52. package/Libraries/Components/ScrollView/ScrollView.win32.js +3 -1
  53. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +39 -46
  54. package/Libraries/Components/Switch/Switch.js +1 -0
  55. package/Libraries/Components/Text/TextWin32.d.ts +1 -1
  56. package/Libraries/Components/TextInput/RCTTextInputViewConfig.js +1 -0
  57. package/Libraries/Components/TextInput/TextInput.d.ts +49 -7
  58. package/Libraries/Components/TextInput/TextInput.flow.js +43 -10
  59. package/Libraries/Components/TextInput/TextInput.js +62 -10
  60. package/Libraries/Components/TextInput/TextInput.win32.js +953 -206
  61. package/Libraries/Components/TextInput/Win32TextInputNativeComponent.js +23 -0
  62. package/Libraries/Components/ToastAndroid/{ToastAndroid.ios.js → ToastAndroid.js} +9 -1
  63. package/Libraries/Components/ToastAndroid/ToastAndroid.win32.js +9 -1
  64. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +2 -2
  65. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  66. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  67. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  69. package/Libraries/Components/Touchable/TouchableOpacity.js +4 -1
  70. package/Libraries/Components/Touchable/TouchableWin32.d.ts +1 -1
  71. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  72. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +1 -0
  73. package/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js +16 -6
  74. package/Libraries/Components/View/ReactNativeStyleAttributes.js +9 -0
  75. package/Libraries/Components/View/ReactNativeViewAttributes.js +1 -0
  76. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +1 -0
  77. package/Libraries/Components/View/View.js +46 -32
  78. package/Libraries/Components/View/View.win32.js +37 -6
  79. package/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  80. package/Libraries/Components/View/ViewNativeComponent.js +1 -0
  81. package/Libraries/Components/View/ViewPropTypes.js +18 -3
  82. package/Libraries/Components/View/ViewPropTypes.win32.js +30 -4
  83. package/Libraries/Components/View/ViewWin32.js +3 -2
  84. package/Libraries/Core/Devtools/loadBundleFromServer.js +152 -0
  85. package/Libraries/Core/Devtools/symbolicateStackTrace.js +2 -1
  86. package/Libraries/Core/ExceptionsManager.js +16 -7
  87. package/Libraries/Core/ExtendedError.js +12 -0
  88. package/Libraries/Core/ReactNativeVersion.js +3 -3
  89. package/Libraries/Core/ReactNativeVersionCheck.js +0 -2
  90. package/Libraries/Core/ReactNativeVersionCheck.win32.js +0 -2
  91. package/Libraries/Core/__mocks__/NativeExceptionsManager.js +20 -0
  92. package/Libraries/Core/setUpDeveloperTools.js +5 -1
  93. package/Libraries/Core/setUpIntersectionObserver.js +16 -0
  94. package/Libraries/{Components/ProgressBarAndroid/ProgressBarAndroid.ios.js → Core/setUpMutationObserver.js} +6 -2
  95. package/Libraries/Core/setUpPerformance.js +6 -13
  96. package/Libraries/Core/setUpPerformanceObserver.js +16 -0
  97. package/Libraries/Core/setUpRegeneratorRuntime.js +4 -2
  98. package/Libraries/DOM/Nodes/ReactNativeElement.js +135 -18
  99. package/Libraries/DOM/Nodes/ReadOnlyCharacterData.js +72 -0
  100. package/Libraries/DOM/Nodes/ReadOnlyElement.js +209 -21
  101. package/Libraries/DOM/Nodes/ReadOnlyNode.js +206 -17
  102. package/Libraries/DOM/Nodes/ReadOnlyText.js +30 -0
  103. package/Libraries/DOM/Nodes/Utilities/Traversal.js +54 -0
  104. package/Libraries/EventEmitter/NativeEventEmitter.d.ts +0 -6
  105. package/Libraries/EventEmitter/RCTDeviceEventEmitter.js +15 -4
  106. package/Libraries/Image/Image.android.js +8 -2
  107. package/Libraries/Image/Image.d.ts +1 -1
  108. package/Libraries/Image/Image.ios.js +4 -1
  109. package/Libraries/Image/Image.win32.js +6 -3
  110. package/Libraries/Image/ImageBackground.js +3 -0
  111. package/Libraries/Image/resolveAssetSource.win32.js +1 -1
  112. package/Libraries/Inspector/DevtoolsOverlay.js +6 -3
  113. package/Libraries/Inspector/NetworkOverlay.js +2 -2
  114. package/Libraries/Interaction/JSEventLoopWatchdog.js +1 -5
  115. package/Libraries/Interaction/PanResponder.js +1 -4
  116. package/Libraries/IntersectionObserver/IntersectionObserver.js +252 -0
  117. package/Libraries/IntersectionObserver/IntersectionObserverEntry.js +140 -0
  118. package/Libraries/IntersectionObserver/IntersectionObserverManager.js +221 -0
  119. package/Libraries/IntersectionObserver/NativeIntersectionObserver.js +41 -0
  120. package/Libraries/IntersectionObserver/__mocks__/NativeIntersectionObserver.js +162 -0
  121. package/Libraries/LayoutAnimation/LayoutAnimation.js +1 -1
  122. package/Libraries/Lists/FlatList.d.ts +2 -1
  123. package/Libraries/Lists/FlatList.js +15 -5
  124. package/Libraries/Lists/SectionList.js +4 -0
  125. package/Libraries/LogBox/Data/LogBoxData.js +2 -1
  126. package/Libraries/LogBox/Data/LogBoxLog.js +4 -1
  127. package/Libraries/LogBox/Data/LogBoxSymbolication.js +5 -2
  128. package/Libraries/LogBox/Data/parseLogBoxLog.js +57 -20
  129. package/Libraries/LogBox/UI/AnsiHighlight.js +1 -1
  130. package/Libraries/LogBox/UI/LogBoxInspectorFooter.js +24 -31
  131. package/Libraries/LogBox/UI/LogBoxInspectorHeader.js +1 -1
  132. package/Libraries/LogBox/UI/LogBoxMessage.js +4 -7
  133. package/Libraries/MutationObserver/MutationObserver.js +184 -0
  134. package/Libraries/MutationObserver/MutationObserverManager.js +218 -0
  135. package/Libraries/MutationObserver/MutationRecord.js +82 -0
  136. package/Libraries/MutationObserver/NativeMutationObserver.js +58 -0
  137. package/Libraries/MutationObserver/__mocks__/NativeMutationObserver.js +327 -0
  138. package/Libraries/NativeComponent/BaseViewConfig.android.js +18 -3
  139. package/Libraries/NativeComponent/BaseViewConfig.ios.js +33 -0
  140. package/Libraries/NativeComponent/BaseViewConfig.win32.js +33 -0
  141. package/Libraries/NativeComponent/NativeComponentRegistry.js +13 -9
  142. package/Libraries/NativeModules/specs/NativeSourceCode.js +6 -6
  143. package/Libraries/Network/RCTNetworking.android.js +2 -1
  144. package/Libraries/Network/XMLHttpRequest.js +1 -1
  145. package/Libraries/NewAppScreen/components/DebugInstructions.js +4 -4
  146. package/Libraries/NewAppScreen/components/LearnMoreLinks.js +9 -2
  147. package/Libraries/Performance/QuickPerformanceLogger.js +1 -1
  148. package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +1 -0
  149. package/Libraries/PermissionsAndroid/PermissionsAndroid.d.ts +1 -0
  150. package/Libraries/PermissionsAndroid/PermissionsAndroid.js +3 -1
  151. package/Libraries/Pressability/Pressability.js +28 -3
  152. package/Libraries/Pressability/Pressability.win32.js +30 -5
  153. package/Libraries/ReactNative/AppContainer.js +2 -3
  154. package/Libraries/ReactNative/AppRegistry.d.ts +0 -5
  155. package/Libraries/ReactNative/AppRegistry.js +66 -53
  156. package/Libraries/ReactNative/BridgelessUIManager.js +38 -9
  157. package/Libraries/ReactNative/FabricUIManager.js +143 -34
  158. package/Libraries/ReactNative/I18nManager.js +5 -11
  159. package/Libraries/ReactNative/NativeI18nManager.js +7 -5
  160. package/Libraries/ReactNative/PaperUIManager.win32.js +2 -2
  161. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +151 -0
  162. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +81 -0
  163. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactNativeAttributePayload.js +492 -0
  164. package/Libraries/ReactNative/ReactFabricPublicInstance/warnForStyleProps.js +32 -0
  165. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +19 -3
  166. package/Libraries/ReactNative/UIManager.js +8 -0
  167. package/Libraries/ReactNative/__mocks__/FabricUIManager.js +648 -0
  168. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +38 -2
  169. package/Libraries/Renderer/implementations/ReactFabric-dev.js +27 -27
  170. package/Libraries/Renderer/implementations/ReactFabric-prod.js +3 -3
  171. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +3 -3
  172. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +27 -27
  173. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +3 -3
  174. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +3 -3
  175. package/Libraries/Renderer/shims/ReactFabric.js +5 -6
  176. package/Libraries/Renderer/shims/ReactFeatureFlags.js +2 -3
  177. package/Libraries/Renderer/shims/ReactNative.js +2 -3
  178. package/Libraries/Renderer/shims/ReactNativeTypes.js +35 -17
  179. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -3
  180. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +2 -3
  181. package/Libraries/Settings/{Settings.android.js → Settings.js} +4 -4
  182. package/Libraries/Share/Share.d.ts +3 -9
  183. package/Libraries/StyleSheet/PlatformColorValueTypes.android.js +9 -4
  184. package/Libraries/StyleSheet/PlatformColorValueTypes.ios.js +28 -13
  185. package/Libraries/StyleSheet/PlatformColorValueTypes.win32.js +14 -4
  186. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.ios.js +1 -1
  187. package/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  188. package/Libraries/StyleSheet/StyleSheet.d.ts +10 -1
  189. package/Libraries/StyleSheet/StyleSheet.js +3 -0
  190. package/Libraries/StyleSheet/StyleSheet.win32.js +3 -0
  191. package/Libraries/StyleSheet/StyleSheetTypes.d.ts +31 -17
  192. package/Libraries/StyleSheet/StyleSheetTypes.js +90 -6
  193. package/Libraries/StyleSheet/flattenStyle.js +4 -0
  194. package/Libraries/StyleSheet/private/_TransformStyle.js +16 -2
  195. package/Libraries/StyleSheet/processColor.js +1 -2
  196. package/Libraries/StyleSheet/processTransformOrigin.js +136 -0
  197. package/Libraries/StyleSheet/splitLayoutProps.js +1 -0
  198. package/Libraries/Text/Text.d.ts +5 -5
  199. package/Libraries/Text/Text.js +17 -10
  200. package/Libraries/Text/Text.win32.js +354 -0
  201. package/Libraries/Text/TextProps.win32.js +281 -0
  202. package/Libraries/TurboModule/TurboModuleRegistry.js +47 -7
  203. package/Libraries/TurboModule/samples/NativeSampleTurboModule.js +6 -0
  204. package/Libraries/Types/CoreEventTypes.d.ts +5 -2
  205. package/Libraries/Utilities/GlobalPerformanceLogger.js +2 -12
  206. package/Libraries/Utilities/NativeDeviceInfo.js +8 -9
  207. package/Libraries/Utilities/NativePlatformConstantsAndroid.js +23 -18
  208. package/Libraries/Utilities/NativePlatformConstantsIOS.js +16 -13
  209. package/Libraries/Utilities/NativePlatformConstantsWin.js +13 -10
  210. package/Libraries/Utilities/PerformanceLoggerContext.js +1 -1
  211. package/Libraries/Utilities/Platform.android.js +12 -8
  212. package/Libraries/Utilities/Platform.d.ts +1 -0
  213. package/Libraries/Utilities/Platform.flow.js +84 -0
  214. package/Libraries/Utilities/Platform.flow.win32.js +111 -0
  215. package/Libraries/Utilities/Platform.ios.js +12 -8
  216. package/Libraries/Utilities/Platform.win32.js +12 -8
  217. package/Libraries/Utilities/PolyfillFunctions.js +1 -1
  218. package/Libraries/Utilities/ReactNativeTestTools.js +1 -2
  219. package/Libraries/Utilities/SceneTracker.js +1 -1
  220. package/Libraries/Utilities/createPerformanceLogger.js +63 -32
  221. package/Libraries/Utilities/useColorScheme.js +7 -8
  222. package/Libraries/WebPerformance/MemoryInfo.js +1 -1
  223. package/Libraries/WebPerformance/NativePerformance.js +3 -8
  224. package/Libraries/WebPerformance/NativePerformanceObserver.js +4 -0
  225. package/Libraries/WebPerformance/Performance.js +42 -15
  226. package/Libraries/WebPerformance/PerformanceEntry.js +14 -6
  227. package/Libraries/WebPerformance/PerformanceEventTiming.js +18 -1
  228. package/Libraries/WebPerformance/ReactNativeStartupTiming.js +40 -14
  229. package/Libraries/WebPerformance/__mocks__/NativePerformance.js +4 -2
  230. package/Libraries/WebPerformance/__mocks__/NativePerformanceObserver.js +21 -3
  231. package/Libraries/promiseRejectionTrackingOptions.js +21 -9
  232. package/Libraries/vendor/emitter/EventEmitter.js +17 -17
  233. package/flow/global.js +1 -3
  234. package/flow/jest.js +5 -1
  235. package/{Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.ios.js → jest/ReactNativeInternalFeatureFlagsMock.js} +2 -1
  236. package/jest/__tests__/setup-test.js +18 -0
  237. package/jest/mockModal.js +6 -4
  238. package/jest/setup.js +61 -30
  239. package/jest.config.js +1 -1
  240. package/just-task.js +1 -0
  241. package/overrides.json +54 -60
  242. package/package.json +35 -33
  243. package/src/Libraries/Components/Button/ButtonWin32.Props.ts +1 -1
  244. package/src/Libraries/Components/Button/ButtonWin32.tsx +0 -2
  245. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +2 -2
  246. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +1 -1
  247. package/src/Libraries/Components/View/ViewAccessibility.d.ts +8 -2
  248. package/src/Libraries/StyleSheet/PlatformColorValueTypesWin32.d.ts +1 -1
  249. package/types/experimental.d.ts +44 -0
  250. package/types/index.d.ts +2 -1
  251. package/types/modules/Devtools.d.ts +1 -0
  252. package/types/modules/globals.d.ts +16 -1
  253. package/IntegrationTests/BUCK +0 -32
  254. package/IntegrationTests/PropertiesUpdateTest.js +0 -29
  255. package/IntegrationTests/RCTRootViewIntegrationTestApp.js +0 -86
  256. package/IntegrationTests/ReactContentSizeUpdateTest.js +0 -89
  257. package/IntegrationTests/SizeFlexibilityUpdateTest.js +0 -106
  258. package/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfoWin32.js +0 -37
  259. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +0 -51
  260. package/Libraries/Components/TextInput/TextInput.Types.win32.js +0 -3
  261. package/Libraries/Components/TextInput/TextInput.Types.win32.js.map +0 -1
  262. package/Libraries/Utilities/AcessibilityMapping.js +0 -154
  263. package/Libraries/Utilities/AcessibilityMapping.win32.js +0 -156
  264. package/Libraries/Utilities/NativeDevSplitBundleLoader.js +0 -19
  265. package/Libraries/Utilities/useColorScheme.win32.js +0 -26
  266. package/flow/use-sync-external-store.js +0 -20
  267. package/flow-typed/npm/base64-js_v1.x.x.js +0 -12
  268. package/flow-typed/npm/glob_v7.x.x.js +0 -79
  269. package/flow-typed/npm/pretty-format_v26.x.x.js +0 -49
  270. package/flow-typed/npm/promise_v8.x.x.js +0 -30
  271. package/flow-typed/npm/react-dom_v17.x.x.js +0 -139
  272. package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -79
  273. package/flow-typed/npm/stacktrace-parser_v0.1.x.js +0 -17
  274. package/flow-typed/npm/yargs_v17.x.x.js +0 -341
  275. package/src/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +0 -161
  276. package/src/Libraries/Components/TextInput/TextInput.Types.win32.ts +0 -68
  277. /package/Libraries/{Renderer/public → ReactNative/ReactFabricPublicInstance}/ReactFabricPublicInstanceUtils.js +0 -0
@@ -44,12 +44,26 @@ export type ____TransformStyle_Internal = $ReadOnly<{|
44
44
  | [number | AnimatedNode, number | AnimatedNode]
45
45
  | AnimatedNode,
46
46
  |}
47
- | {|+skewX: string|}
48
- | {|+skewY: string|}
47
+ | {|+skewX: string | AnimatedNode|}
48
+ | {|+skewY: string | AnimatedNode|}
49
49
  // TODO: what is the actual type it expects?
50
50
  | {|
51
51
  +matrix: $ReadOnlyArray<number | AnimatedNode> | AnimatedNode,
52
52
  |},
53
53
  >
54
54
  | string,
55
+ /**
56
+ * `transformOrigin` accepts an array with 3 elements - each element either being
57
+ * a number, or a string of a number ending with `%`. The last element cannot be
58
+ * a percentage, so must be a number.
59
+ *
60
+ * E.g. transformOrigin: ['30%', '80%', 15]
61
+ *
62
+ * Alternatively accepts a string of the CSS syntax. You must use `%` or `px`.
63
+ *
64
+ * E.g. transformOrigin: '30% 80% 15px'
65
+ */
66
+ transformOrigin?:
67
+ | [string | number, string | number, string | number]
68
+ | string,
55
69
  |}>;
@@ -10,8 +10,7 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- import type {NativeColorValue} from './PlatformColorValueTypes';
14
- import type {ColorValue} from './StyleSheet';
13
+ import type {ColorValue, NativeColorValue} from './StyleSheet';
15
14
 
16
15
  const Platform = require('../Utilities/Platform');
17
16
  const normalizeColor = require('./normalizeColor');
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ * @flow
9
+ */
10
+
11
+ import invariant from 'invariant';
12
+
13
+ const INDEX_X = 0;
14
+ const INDEX_Y = 1;
15
+ const INDEX_Z = 2;
16
+
17
+ /* eslint-disable no-labels */
18
+ export default function processTransformOrigin(
19
+ transformOrigin: Array<string | number> | string,
20
+ ): Array<string | number> {
21
+ if (typeof transformOrigin === 'string') {
22
+ const transformOriginString = transformOrigin;
23
+ const regex = /(top|bottom|left|right|center|\d+(?:%|px)|0)/gi;
24
+ const transformOriginArray: Array<string | number> = ['50%', '50%', 0];
25
+
26
+ let index = INDEX_X;
27
+ let matches;
28
+ outer: while ((matches = regex.exec(transformOriginString))) {
29
+ let nextIndex = index + 1;
30
+
31
+ const value = matches[0];
32
+ const valueLower = value.toLowerCase();
33
+
34
+ switch (valueLower) {
35
+ case 'left':
36
+ case 'right': {
37
+ invariant(
38
+ index === INDEX_X,
39
+ 'Transform-origin %s can only be used for x-position',
40
+ value,
41
+ );
42
+ transformOriginArray[INDEX_X] = valueLower === 'left' ? 0 : '100%';
43
+ break;
44
+ }
45
+ case 'top':
46
+ case 'bottom': {
47
+ invariant(
48
+ index !== INDEX_Z,
49
+ 'Transform-origin %s can only be used for y-position',
50
+ value,
51
+ );
52
+ transformOriginArray[INDEX_Y] = valueLower === 'top' ? 0 : '100%';
53
+
54
+ // Handle [[ center | left | right ] && [ center | top | bottom ]] <length>?
55
+ if (index === INDEX_X) {
56
+ const horizontal = regex.exec(transformOriginString);
57
+ if (horizontal == null) {
58
+ break outer;
59
+ }
60
+
61
+ switch (horizontal[0].toLowerCase()) {
62
+ case 'left':
63
+ transformOriginArray[INDEX_X] = 0;
64
+ break;
65
+ case 'right':
66
+ transformOriginArray[INDEX_X] = '100%';
67
+ break;
68
+ case 'center':
69
+ transformOriginArray[INDEX_X] = '50%';
70
+ break;
71
+ default:
72
+ invariant(
73
+ false,
74
+ 'Could not parse transform-origin: %s',
75
+ transformOriginString,
76
+ );
77
+ }
78
+ nextIndex = INDEX_Z;
79
+ }
80
+
81
+ break;
82
+ }
83
+ case 'center': {
84
+ invariant(
85
+ index !== INDEX_Z,
86
+ 'Transform-origin value %s cannot be used for z-position',
87
+ value,
88
+ );
89
+ transformOriginArray[index] = '50%';
90
+ break;
91
+ }
92
+ default: {
93
+ if (value.endsWith('%')) {
94
+ transformOriginArray[index] = value;
95
+ } else {
96
+ transformOriginArray[index] = parseFloat(value); // Remove `px`
97
+ }
98
+ break;
99
+ }
100
+ }
101
+
102
+ index = nextIndex;
103
+ }
104
+
105
+ transformOrigin = transformOriginArray;
106
+ }
107
+
108
+ if (__DEV__) {
109
+ _validateTransformOrigin(transformOrigin);
110
+ }
111
+
112
+ return transformOrigin;
113
+ }
114
+
115
+ function _validateTransformOrigin(transformOrigin: Array<string | number>) {
116
+ invariant(
117
+ transformOrigin.length === 3,
118
+ 'Transform origin must have exactly 3 values.',
119
+ );
120
+ const [x, y, z] = transformOrigin;
121
+ invariant(
122
+ typeof x === 'number' || (typeof x === 'string' && x.endsWith('%')),
123
+ 'Transform origin x-position must be a number. Passed value: %s.',
124
+ x,
125
+ );
126
+ invariant(
127
+ typeof y === 'number' || (typeof y === 'string' && y.endsWith('%')),
128
+ 'Transform origin y-position must be a number. Passed value: %s.',
129
+ y,
130
+ );
131
+ invariant(
132
+ typeof z === 'number',
133
+ 'Transform origin z-position must be a number. Passed value: %s.',
134
+ z,
135
+ );
136
+ }
@@ -49,6 +49,7 @@ export default function splitLayoutProps(props: ?____ViewStyle_Internal): {
49
49
  case 'bottom':
50
50
  case 'top':
51
51
  case 'transform':
52
+ case 'transformOrigin':
52
53
  case 'rowGap':
53
54
  case 'columnGap':
54
55
  case 'gap':
@@ -43,11 +43,6 @@ export interface TextPropsIOS {
43
43
  | 'largeTitle'
44
44
  | undefined;
45
45
 
46
- /**
47
- * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
48
- */
49
- minimumFontScale?: number | undefined;
50
-
51
46
  /**
52
47
  * When `true`, no visual change is made when text is pressed down. By
53
48
  * default, a gray oval highlights the text on press down.
@@ -209,6 +204,11 @@ export interface TextProps
209
204
  * - >= 1: sets the maxFontSizeMultiplier of this node to this value
210
205
  */
211
206
  maxFontSizeMultiplier?: number | null | undefined;
207
+
208
+ /**
209
+ * Specifies smallest possible scale a font can reach when adjustsFontSizeToFit is enabled. (values 0.01-1.0).
210
+ */
211
+ minimumFontScale?: number | undefined;
212
212
  }
213
213
 
214
214
  /**
@@ -15,7 +15,6 @@ import * as PressabilityDebug from '../Pressability/PressabilityDebug';
15
15
  import usePressability from '../Pressability/usePressability';
16
16
  import flattenStyle from '../StyleSheet/flattenStyle';
17
17
  import processColor from '../StyleSheet/processColor';
18
- import {getAccessibilityRoleFromRole} from '../Utilities/AcessibilityMapping';
19
18
  import Platform from '../Utilities/Platform';
20
19
  import TextAncestor from './TextAncestor';
21
20
  import {NativeText, NativeVirtualText} from './TextNativeComponent';
@@ -34,7 +33,6 @@ const Text: React.AbstractComponent<
34
33
  const {
35
34
  accessible,
36
35
  accessibilityLabel,
37
- accessibilityRole,
38
36
  accessibilityState,
39
37
  allowFontScaling,
40
38
  'aria-busy': ariaBusy,
@@ -57,7 +55,6 @@ const Text: React.AbstractComponent<
57
55
  onResponderTerminationRequest,
58
56
  onStartShouldSetResponder,
59
57
  pressRetentionOffset,
60
- role,
61
58
  suppressHighlighting,
62
59
  ...restProps
63
60
  } = props;
@@ -108,7 +105,13 @@ const Text: React.AbstractComponent<
108
105
  onLongPress,
109
106
  onPress,
110
107
  onPressIn(event: PressEvent) {
111
- setHighlighted(!suppressHighlighting);
108
+ // Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
109
+ // in the best case, and cause issues with text selection in the worst case. Forcing
110
+ // the isHighlighted prop to false on all platforms except iOS.
111
+ setHighlighted(
112
+ (suppressHighlighting == null || !suppressHighlighting) &&
113
+ Platform.OS === 'ios',
114
+ );
112
115
  onPressIn?.(event);
113
116
  },
114
117
  onPressOut(event: PressEvent) {
@@ -211,18 +214,28 @@ const Text: React.AbstractComponent<
211
214
  style = flattenStyle(style);
212
215
 
213
216
  if (typeof style?.fontWeight === 'number') {
217
+ // $FlowFixMe[prop-missing]
218
+ // $FlowFixMe[cannot-write]
214
219
  style.fontWeight = style?.fontWeight.toString();
215
220
  }
216
221
 
217
222
  let _selectable = restProps.selectable;
218
223
  if (style?.userSelect != null) {
224
+ // $FlowFixMe[invalid-computed-prop]
219
225
  _selectable = userSelectToSelectableMap[style.userSelect];
226
+ // $FlowFixMe[prop-missing]
227
+ // $FlowFixMe[cannot-write]
220
228
  delete style.userSelect;
221
229
  }
222
230
 
223
231
  if (style?.verticalAlign != null) {
232
+ // $FlowFixMe[prop-missing]
233
+ // $FlowFixMe[cannot-write]
224
234
  style.textAlignVertical =
235
+ // $FlowFixMe[invalid-computed-prop]
225
236
  verticalAlignToTextAlignVerticalMap[style.verticalAlign];
237
+ // $FlowFixMe[prop-missing]
238
+ // $FlowFixMe[cannot-write]
226
239
  delete style.verticalAlign;
227
240
  }
228
241
 
@@ -234,9 +247,6 @@ const Text: React.AbstractComponent<
234
247
  {...restProps}
235
248
  {...eventHandlersForText}
236
249
  accessibilityLabel={ariaLabel ?? accessibilityLabel}
237
- accessibilityRole={
238
- role ? getAccessibilityRoleFromRole(role) : accessibilityRole
239
- }
240
250
  accessibilityState={_accessibilityState}
241
251
  isHighlighted={isHighlighted}
242
252
  isPressable={isPressable}
@@ -253,9 +263,6 @@ const Text: React.AbstractComponent<
253
263
  {...restProps}
254
264
  {...eventHandlersForText}
255
265
  accessibilityLabel={ariaLabel ?? accessibilityLabel}
256
- accessibilityRole={
257
- role ? getAccessibilityRoleFromRole(role) : accessibilityRole
258
- }
259
266
  accessibilityState={nativeTextAccessibilityState}
260
267
  accessible={
261
268
  accessible == null && Platform.OS === 'android'
@@ -0,0 +1,354 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ import type {PressEvent} from '../Types/CoreEventTypes';
12
+ import type {TextProps} from './TextProps';
13
+
14
+ import * as PressabilityDebug from '../Pressability/PressabilityDebug';
15
+ import usePressability from '../Pressability/usePressability';
16
+ import flattenStyle from '../StyleSheet/flattenStyle';
17
+ import processColor from '../StyleSheet/processColor';
18
+ import Platform from '../Utilities/Platform';
19
+ import TextAncestor from './TextAncestor';
20
+ import {NativeText, NativeVirtualText} from './TextNativeComponent';
21
+ import * as React from 'react';
22
+ import {useContext, useMemo, useState} from 'react';
23
+
24
+ /**
25
+ * Text is the fundamental component for displaying text.
26
+ *
27
+ * @see https://reactnative.dev/docs/text
28
+ */
29
+ const Text: React.AbstractComponent<
30
+ TextProps,
31
+ React.ElementRef<typeof NativeText | typeof NativeVirtualText>,
32
+ > = React.forwardRef((props: TextProps, forwardedRef) => {
33
+ const {
34
+ accessible,
35
+ accessibilityControls, // Win32
36
+ accessibilityDescribedBy, // Win32
37
+ accessibilityDescription, // Win32
38
+ accessibilityLabel,
39
+ accessibilityLevel, // Win32
40
+ accessibilityPositionInSet, // Win32
41
+ accessibilitySetSize, // Win32
42
+ accessibilityState,
43
+ allowFontScaling,
44
+ 'aria-busy': ariaBusy,
45
+ 'aria-checked': ariaChecked,
46
+ 'aria-controls': ariaControls, // Win32
47
+ 'aria-describedby': ariaDescribedBy, // Win32
48
+ 'aria-description': ariaDescription, // Win32
49
+ 'aria-disabled': ariaDisabled,
50
+ 'aria-expanded': ariaExpanded,
51
+ 'aria-label': ariaLabel,
52
+ 'aria-level': ariaLevel, // Win32
53
+ 'aria-multiselectable': ariaMultiselectable, // Win32
54
+ 'aria-posinset': ariaPosinset, // Win32
55
+ 'aria-required': ariaRequired, // Win32
56
+ 'aria-selected': ariaSelected,
57
+ 'aria-setsize': ariaSetsize, // Win32
58
+ ellipsizeMode,
59
+ id,
60
+ nativeID,
61
+ onLongPress,
62
+ onPress,
63
+ onPressIn,
64
+ onPressOut,
65
+ onResponderGrant,
66
+ onResponderMove,
67
+ onResponderRelease,
68
+ onResponderTerminate,
69
+ onResponderTerminationRequest,
70
+ onStartShouldSetResponder,
71
+ pressRetentionOffset,
72
+ suppressHighlighting,
73
+ ...restProps
74
+ } = props;
75
+
76
+ const [isHighlighted, setHighlighted] = useState(false);
77
+
78
+ let _accessibilityState;
79
+ if (
80
+ accessibilityState != null ||
81
+ ariaBusy != null ||
82
+ ariaChecked != null ||
83
+ ariaDisabled != null ||
84
+ ariaExpanded != null ||
85
+ ariaMultiselectable != null ||
86
+ ariaRequired != null ||
87
+ ariaSelected != null
88
+ ) {
89
+ _accessibilityState = {
90
+ busy: ariaBusy ?? accessibilityState?.busy,
91
+ checked: ariaChecked ?? accessibilityState?.checked,
92
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
93
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
94
+ multiselectable:
95
+ ariaMultiselectable ?? accessibilityState?.multiselectable, // Win32
96
+ required: ariaRequired ?? accessibilityState?.required, // Win32
97
+ selected: ariaSelected ?? accessibilityState?.selected,
98
+ };
99
+ }
100
+
101
+ const _disabled =
102
+ restProps.disabled != null
103
+ ? restProps.disabled
104
+ : _accessibilityState?.disabled;
105
+
106
+ const nativeTextAccessibilityState =
107
+ _disabled !== _accessibilityState?.disabled
108
+ ? {..._accessibilityState, disabled: _disabled}
109
+ : _accessibilityState;
110
+
111
+ const isPressable =
112
+ (onPress != null ||
113
+ onLongPress != null ||
114
+ onStartShouldSetResponder != null) &&
115
+ _disabled !== true;
116
+
117
+ const initialized = useLazyInitialization(isPressable);
118
+ const config = useMemo(
119
+ () =>
120
+ initialized
121
+ ? {
122
+ disabled: !isPressable,
123
+ pressRectOffset: pressRetentionOffset,
124
+ onLongPress,
125
+ onPress,
126
+ onPressIn(event: PressEvent) {
127
+ // Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
128
+ // in the best case, and cause issues with text selection in the worst case. Forcing
129
+ // the isHighlighted prop to false on all platforms except iOS.
130
+ setHighlighted(
131
+ (suppressHighlighting == null || !suppressHighlighting) &&
132
+ Platform.OS === 'ios',
133
+ );
134
+ onPressIn?.(event);
135
+ },
136
+ onPressOut(event: PressEvent) {
137
+ setHighlighted(false);
138
+ onPressOut?.(event);
139
+ },
140
+ onResponderTerminationRequest_DEPRECATED:
141
+ onResponderTerminationRequest,
142
+ onStartShouldSetResponder_DEPRECATED: onStartShouldSetResponder,
143
+ }
144
+ : null,
145
+ [
146
+ initialized,
147
+ isPressable,
148
+ pressRetentionOffset,
149
+ onLongPress,
150
+ onPress,
151
+ onPressIn,
152
+ onPressOut,
153
+ onResponderTerminationRequest,
154
+ onStartShouldSetResponder,
155
+ suppressHighlighting,
156
+ ],
157
+ );
158
+
159
+ const eventHandlers = usePressability(config);
160
+ const eventHandlersForText = useMemo(
161
+ () =>
162
+ eventHandlers == null
163
+ ? null
164
+ : {
165
+ onResponderGrant(event: PressEvent) {
166
+ eventHandlers.onResponderGrant(event);
167
+ if (onResponderGrant != null) {
168
+ onResponderGrant(event);
169
+ }
170
+ },
171
+ onResponderMove(event: PressEvent) {
172
+ eventHandlers.onResponderMove(event);
173
+ if (onResponderMove != null) {
174
+ onResponderMove(event);
175
+ }
176
+ },
177
+ onResponderRelease(event: PressEvent) {
178
+ eventHandlers.onResponderRelease(event);
179
+ if (onResponderRelease != null) {
180
+ onResponderRelease(event);
181
+ }
182
+ },
183
+ onResponderTerminate(event: PressEvent) {
184
+ eventHandlers.onResponderTerminate(event);
185
+ if (onResponderTerminate != null) {
186
+ onResponderTerminate(event);
187
+ }
188
+ },
189
+ onClick: eventHandlers.onClick,
190
+ onResponderTerminationRequest:
191
+ eventHandlers.onResponderTerminationRequest,
192
+ onStartShouldSetResponder: eventHandlers.onStartShouldSetResponder,
193
+ },
194
+ [
195
+ eventHandlers,
196
+ onResponderGrant,
197
+ onResponderMove,
198
+ onResponderRelease,
199
+ onResponderTerminate,
200
+ ],
201
+ );
202
+
203
+ // TODO: Move this processing to the view configuration.
204
+ const selectionColor =
205
+ restProps.selectionColor == null
206
+ ? null
207
+ : processColor(restProps.selectionColor);
208
+
209
+ let style = restProps.style;
210
+
211
+ if (__DEV__) {
212
+ if (PressabilityDebug.isEnabled() && onPress != null) {
213
+ style = [restProps.style, {color: 'magenta'}];
214
+ }
215
+ }
216
+
217
+ let numberOfLines = restProps.numberOfLines;
218
+ if (numberOfLines != null && !(numberOfLines >= 0)) {
219
+ console.error(
220
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${numberOfLines}. The value will be set to 0.`,
221
+ );
222
+ numberOfLines = 0;
223
+ }
224
+
225
+ const hasTextAncestor = useContext(TextAncestor);
226
+
227
+ const _accessible = Platform.select({
228
+ ios: accessible !== false,
229
+ default: accessible,
230
+ });
231
+
232
+ // $FlowFixMe[underconstrained-implicit-instantiation]
233
+ style = flattenStyle(style);
234
+
235
+ if (typeof style?.fontWeight === 'number') {
236
+ // $FlowFixMe[prop-missing]
237
+ // $FlowFixMe[cannot-write]
238
+ style.fontWeight = style?.fontWeight.toString();
239
+ }
240
+
241
+ let _selectable = restProps.selectable;
242
+ if (style?.userSelect != null) {
243
+ // $FlowFixMe[invalid-computed-prop]
244
+ _selectable = userSelectToSelectableMap[style.userSelect];
245
+ // $FlowFixMe[prop-missing]
246
+ // $FlowFixMe[cannot-write]
247
+ delete style.userSelect;
248
+ }
249
+
250
+ if (style?.verticalAlign != null) {
251
+ // $FlowFixMe[prop-missing]
252
+ // $FlowFixMe[cannot-write]
253
+ style.textAlignVertical =
254
+ // $FlowFixMe[invalid-computed-prop]
255
+ verticalAlignToTextAlignVerticalMap[style.verticalAlign];
256
+ // $FlowFixMe[prop-missing]
257
+ // $FlowFixMe[cannot-write]
258
+ delete style.verticalAlign;
259
+ }
260
+
261
+ const _hasOnPressOrOnLongPress =
262
+ props.onPress != null || props.onLongPress != null;
263
+
264
+ return hasTextAncestor ? (
265
+ <NativeVirtualText
266
+ {...restProps}
267
+ {...eventHandlersForText}
268
+ accessibilityControls={ariaControls ?? accessibilityControls} // Win32
269
+ accessibilityDescribedBy={ariaDescribedBy ?? accessibilityDescribedBy} // Win32
270
+ accessibilityDescription={ariaDescription ?? accessibilityDescription} // Win32
271
+ accessibilityLabel={ariaLabel ?? accessibilityLabel}
272
+ accessibilityLevel={ariaLevel ?? accessibilityLevel} // Win32
273
+ accessibilityPositionInSet={ariaPosinset ?? accessibilityPositionInSet} // Win32
274
+ accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Win32
275
+ accessibilityState={_accessibilityState}
276
+ isHighlighted={isHighlighted}
277
+ isPressable={isPressable}
278
+ nativeID={id ?? nativeID}
279
+ numberOfLines={numberOfLines}
280
+ ref={forwardedRef}
281
+ selectable={_selectable}
282
+ selectionColor={selectionColor}
283
+ style={style}
284
+ />
285
+ ) : (
286
+ <TextAncestor.Provider value={true}>
287
+ <NativeText
288
+ {...restProps}
289
+ {...eventHandlersForText}
290
+ accessibilityControls={ariaControls ?? accessibilityControls} // Win32
291
+ accessibilityDescribedBy={ariaDescribedBy ?? accessibilityDescribedBy} // Win32
292
+ accessibilityDescription={ariaDescription ?? accessibilityDescription} // Win32
293
+ accessibilityLabel={ariaLabel ?? accessibilityLabel}
294
+ accessibilityLevel={ariaLevel ?? accessibilityLevel} // Win32
295
+ accessibilityPositionInSet={ariaPosinset ?? accessibilityPositionInSet} // Win32
296
+ accessibilitySetSize={ariaSetsize ?? accessibilitySetSize} // Win32
297
+ accessibilityState={nativeTextAccessibilityState}
298
+ accessible={
299
+ accessible == null && Platform.OS === 'android'
300
+ ? _hasOnPressOrOnLongPress
301
+ : _accessible
302
+ }
303
+ allowFontScaling={allowFontScaling !== false}
304
+ disabled={_disabled}
305
+ ellipsizeMode={ellipsizeMode ?? 'tail'}
306
+ isHighlighted={isHighlighted}
307
+ nativeID={id ?? nativeID}
308
+ numberOfLines={numberOfLines}
309
+ ref={forwardedRef}
310
+ selectable={_selectable}
311
+ selectionColor={selectionColor}
312
+ style={style}
313
+ />
314
+ </TextAncestor.Provider>
315
+ );
316
+ });
317
+
318
+ Text.displayName = 'Text';
319
+
320
+ /**
321
+ * Switch to `deprecated-react-native-prop-types` for compatibility with future
322
+ * releases. This is deprecated and will be removed in the future.
323
+ */
324
+ Text.propTypes = require('deprecated-react-native-prop-types').TextPropTypes;
325
+
326
+ /**
327
+ * Returns false until the first time `newValue` is true, after which this will
328
+ * always return true. This is necessary to lazily initialize `Pressability` so
329
+ * we do not eagerly create one for every pressable `Text` component.
330
+ */
331
+ function useLazyInitialization(newValue: boolean): boolean {
332
+ const [oldValue, setValue] = useState(newValue);
333
+ if (!oldValue && newValue) {
334
+ setValue(newValue);
335
+ }
336
+ return oldValue;
337
+ }
338
+
339
+ const userSelectToSelectableMap = {
340
+ auto: true,
341
+ text: true,
342
+ none: false,
343
+ contain: true,
344
+ all: true,
345
+ };
346
+
347
+ const verticalAlignToTextAlignVerticalMap = {
348
+ auto: 'auto',
349
+ top: 'top',
350
+ bottom: 'bottom',
351
+ middle: 'center',
352
+ };
353
+
354
+ module.exports = Text;