react-native-windows 0.0.0-canary.992 → 0.0.0-canary.993

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 (195) hide show
  1. package/.flowconfig +3 -1
  2. package/Libraries/Animated/Animated.js +0 -1
  3. package/Libraries/Animated/Animated.js.flow +0 -1
  4. package/Libraries/Animated/AnimatedExports.js +0 -1
  5. package/Libraries/Animated/AnimatedExports.js.flow +1 -2
  6. package/Libraries/Animated/animations/Animation.js +5 -2
  7. package/Libraries/Animated/components/AnimatedScrollView.js +53 -52
  8. package/Libraries/Animated/createAnimatedComponent.js +37 -33
  9. package/Libraries/Animated/nodes/AnimatedObject.js +2 -3
  10. package/Libraries/Animated/nodes/AnimatedProps.js +1 -1
  11. package/Libraries/Animated/shouldUseTurboAnimatedModule.js +6 -1
  12. package/Libraries/AppState/AppState.js +6 -1
  13. package/Libraries/Components/ActivityIndicator/ActivityIndicator.js +19 -18
  14. package/Libraries/Components/Button.js +2 -2
  15. package/Libraries/Components/Button.windows.js +2 -3
  16. package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +2 -3
  17. package/Libraries/Components/Keyboard/KeyboardAvoidingView.js +2 -1
  18. package/Libraries/Components/LayoutConformance/LayoutConformance.js +0 -1
  19. package/Libraries/Components/Pressable/Pressable.js +9 -6
  20. package/Libraries/Components/Pressable/Pressable.windows.js +9 -6
  21. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.android.js +14 -13
  22. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroid.js +13 -1
  23. package/Libraries/Components/ProgressBarAndroid/ProgressBarAndroidTypes.js +29 -20
  24. package/Libraries/Components/ScrollView/ScrollView.d.ts +9 -5
  25. package/Libraries/Components/ScrollView/ScrollView.js +18 -12
  26. package/Libraries/Components/ScrollView/ScrollView.windows.js +19 -12
  27. package/Libraries/Components/ScrollView/ScrollViewContext.js +2 -1
  28. package/Libraries/Components/ScrollView/ScrollViewNativeComponentType.js +1 -1
  29. package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +19 -6
  30. package/Libraries/Components/Switch/Switch.js +8 -2
  31. package/Libraries/Components/Switch/Switch.windows.js +8 -2
  32. package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +1 -5
  33. package/Libraries/Components/TextInput/TextInput.flow.js +1 -5
  34. package/Libraries/Components/TextInput/TextInput.flow.windows.js +1 -6
  35. package/Libraries/Components/TextInput/TextInput.js +26 -25
  36. package/Libraries/Components/TextInput/TextInput.windows.js +27 -25
  37. package/Libraries/Components/TextInput/WindowsTextInputNativeComponent.js +1 -5
  38. package/Libraries/Components/Touchable/TouchableBounce.js +9 -3
  39. package/Libraries/Components/Touchable/TouchableBounce.windows.js +9 -3
  40. package/Libraries/Components/Touchable/TouchableHighlight.js +9 -4
  41. package/Libraries/Components/Touchable/TouchableHighlight.windows.js +9 -4
  42. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +2 -1
  43. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +2 -1
  44. package/Libraries/Components/Touchable/TouchableOpacity.js +7 -3
  45. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +7 -3
  46. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
  47. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +2 -2
  48. package/Libraries/Components/View/View.js +111 -25
  49. package/Libraries/Components/View/View.windows.js +427 -227
  50. package/Libraries/Core/Devtools/loadBundleFromServer.js +49 -7
  51. package/Libraries/Core/Devtools/loadBundleFromServer.windows.js +49 -7
  52. package/Libraries/Core/InitializeCore.js +1 -22
  53. package/Libraries/Core/ReactNativeVersion.js +3 -2
  54. package/Libraries/Debugging/DebuggingOverlay.js +6 -8
  55. package/Libraries/Debugging/DebuggingOverlayRegistry.js +0 -1
  56. package/Libraries/Debugging/useSubscribeToDebuggingOverlayRegistry.js +0 -1
  57. package/Libraries/EventEmitter/NativeEventEmitter.js +1 -1
  58. package/Libraries/Image/AssetRegistry.js +4 -10
  59. package/Libraries/Image/AssetSourceResolver.js +17 -4
  60. package/Libraries/Image/AssetSourceResolver.windows.js +17 -4
  61. package/Libraries/Image/Image.android.js +112 -106
  62. package/Libraries/Image/Image.ios.js +10 -2
  63. package/Libraries/Image/Image.windows.js +30 -20
  64. package/Libraries/Image/ImageAnalyticsTagContext.js +2 -2
  65. package/Libraries/Image/RelativeImageStub.js +1 -0
  66. package/Libraries/Lists/FlatList.d.ts +9 -5
  67. package/Libraries/Lists/FlatList.js +1 -1
  68. package/Libraries/Lists/SectionListModern.js +9 -3
  69. package/Libraries/LogBox/UI/LogBoxButton.js +2 -1
  70. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.js +2 -1
  71. package/Libraries/LogBox/UI/LogBoxInspectorReactFrames.windows.js +2 -1
  72. package/Libraries/LogBox/UI/LogBoxInspectorSourceMapStatus.js +3 -2
  73. package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +2 -1
  74. package/Libraries/ReactNative/AppContainer-dev.js +4 -4
  75. package/Libraries/ReactNative/AppContainer-prod.js +0 -1
  76. package/Libraries/ReactNative/RootTag.js +2 -2
  77. package/Libraries/ReactPrivate/ReactNativePrivateInterface.js +1 -0
  78. package/Libraries/Renderer/shims/ReactNativeTypes.js +21 -25
  79. package/Libraries/Renderer/shims/ReactNativeTypes.windows.js +270 -0
  80. package/Libraries/StyleSheet/StyleSheetExports.js.flow +3 -1
  81. package/Libraries/StyleSheet/StyleSheetTypes.js +4 -3
  82. package/Libraries/StyleSheet/private/_TransformStyle.js +49 -21
  83. package/Libraries/StyleSheet/processBoxShadow.js +0 -1
  84. package/Libraries/StyleSheet/processFilter.js +0 -1
  85. package/Libraries/Text/Text.d.ts +1 -2
  86. package/Libraries/Text/Text.js +255 -244
  87. package/Libraries/Text/Text.windows.js +281 -300
  88. package/Libraries/Text/TextAncestor.js +3 -2
  89. package/Libraries/Text/TextProps.js +2 -34
  90. package/Libraries/Text/TextProps.windows.js +2 -34
  91. package/Libraries/Types/ReactDevToolsTypes.js +0 -1
  92. package/Libraries/Utilities/PerformanceLoggerContext.js +2 -2
  93. package/Libraries/Utilities/PlatformTypes.js +1 -1
  94. package/Libraries/vendor/core/ErrorUtils.js +28 -4
  95. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.cpp +1 -1
  96. package/Microsoft.ReactNative/Fabric/AbiComponentDescriptor.h +1 -1
  97. package/Microsoft.ReactNative/Fabric/AbiShadowNode.h +1 -1
  98. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +1 -1
  99. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentDescriptor.h +2 -2
  100. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +10 -9
  101. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.cpp +21 -17
  102. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputShadowNode.h +4 -4
  103. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.cpp +19 -0
  104. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputState.h +76 -0
  105. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +6 -0
  106. package/Microsoft.ReactNative/Modules/PaperUIManagerModule.cpp +19 -2
  107. package/Microsoft.ReactNative/Utils/ThemeUtils.cpp +49 -0
  108. package/Microsoft.ReactNative/Utils/ThemeUtils.h +31 -0
  109. package/Microsoft.ReactNative/Views/ShadowNodeBase.cpp +36 -8
  110. package/Microsoft.ReactNative/Views/ShadowNodeRegistry.cpp +6 -2
  111. package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +9 -1
  112. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Base.h +45 -34
  113. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bool.h +1 -1
  114. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Bridging.h +1 -0
  115. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Class.h +36 -33
  116. package/Microsoft.ReactNative.Cxx/ReactCommon/react/bridging/Number.h +10 -10
  117. package/PropertySheets/External/Microsoft.ReactNative.Cpp.Dependencies.props +10 -0
  118. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  119. package/PropertySheets/React.Cpp.props +1 -1
  120. package/ReactCommon/ReactCommon.vcxproj +10 -19
  121. package/ReactCommon/ReactCommon.vcxproj.filters +36 -13
  122. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/NativeToJsBridge.cpp +1 -1
  123. package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +110 -0
  124. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/bridging/Bridging.h +1 -0
  125. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.cpp +19 -3
  126. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/nativemodule/dom/NativeDOM.h +9 -0
  127. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/ParagraphShadowNode.cpp +459 -0
  128. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/text/platform/android/react/renderer/components/text/ParagraphState.h +92 -0
  129. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +35 -0
  130. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityProps.cpp +28 -1
  131. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/css/CSSTokenizer.h +1 -2
  132. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +2 -1
  133. package/Scripts/creaternwapp.cmd +11 -8
  134. package/Shared/HermesRuntimeHolder.cpp +3 -1
  135. package/Shared/Shared.vcxitems +5 -1
  136. package/Shared/Shared.vcxitems.filters +4 -0
  137. package/codegen/NativeDOMSpec.g.h +6 -0
  138. package/codegen/NativeIntersectionObserverSpec.g.h +19 -5
  139. package/codegen/NativeMutationObserverSpec.g.h +11 -5
  140. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +104 -92
  141. package/codegen/react/components/rnwcore/States.h +8 -8
  142. package/codegen/rnwcoreJSI-generated.cpp +48 -3
  143. package/codegen/rnwcoreJSI.h +73 -10
  144. package/index.js +0 -1
  145. package/jest/mockNativeComponent.js +2 -1
  146. package/jest/renderer.js +0 -1
  147. package/jest/resolver.js +31 -0
  148. package/package.json +13 -13
  149. package/src/private/animated/NativeAnimatedHelper.js +6 -1
  150. package/src/private/animated/createAnimatedPropsHook.js +11 -4
  151. package/src/private/animated/createAnimatedPropsMemoHook.js +0 -1
  152. package/src/private/components/safeareaview/SafeAreaView_INTERNAL_DO_NOT_USE.js +0 -1
  153. package/src/private/components/scrollview/HScrollViewNativeComponents.js +0 -1
  154. package/src/private/components/scrollview/VScrollViewNativeComponents.js +0 -1
  155. package/src/private/devsupport/rndevtools/FuseboxSessionObserver.js +0 -1
  156. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.android.js +8 -9
  157. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.ios.js +12 -15
  158. package/src/private/devsupport/rndevtools/ReactDevToolsSettingsManager.windows.js +8 -9
  159. package/src/private/devsupport/rndevtools/setUpFuseboxReactDevToolsDispatcher.js +0 -1
  160. package/src/private/devsupport/rndevtools/specs/NativeReactDevToolsRuntimeSettingsModule.js +0 -1
  161. package/src/private/featureflags/ReactNativeFeatureFlags.js +39 -4
  162. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +5 -2
  163. package/src/private/setup/setUpDefaultReactNativeEnvironment.js +44 -0
  164. package/src/private/styles/composeStyles.js +12 -5
  165. package/src/private/webapis/dom/events/Event.js +3 -0
  166. package/src/private/webapis/dom/events/EventTarget.js +3 -0
  167. package/src/private/webapis/dom/nodes/ReactNativeElement.js +6 -23
  168. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +3 -1
  169. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +38 -0
  170. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +3 -0
  171. package/src/private/webapis/dom/oldstylecollections/NodeList.js +3 -0
  172. package/src/private/webapis/errors/DOMException.js +166 -0
  173. package/src/private/webapis/geometry/DOMRect.js +5 -0
  174. package/src/private/webapis/geometry/DOMRectList.js +3 -0
  175. package/src/private/webapis/geometry/DOMRectReadOnly.js +6 -0
  176. package/src/private/webapis/intersectionobserver/IntersectionObserver.js +15 -7
  177. package/src/private/webapis/intersectionobserver/IntersectionObserverEntry.js +3 -0
  178. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +80 -18
  179. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +12 -0
  180. package/src/private/webapis/mutationobserver/MutationObserver.js +23 -33
  181. package/src/private/webapis/mutationobserver/MutationRecord.js +3 -0
  182. package/src/private/webapis/mutationobserver/internals/MutationObserverManager.js +56 -24
  183. package/src/private/webapis/mutationobserver/specs/NativeMutationObserver.js +4 -1
  184. package/src/private/webapis/performance/MemoryInfo.js +4 -1
  185. package/src/private/webapis/performance/Performance.js +19 -8
  186. package/src/private/webapis/performance/PerformanceEntry.js +4 -0
  187. package/src/private/webapis/performance/ReactNativeStartupTiming.js +4 -1
  188. package/src/private/webapis/performance/internals/RawPerformanceEntry.js +2 -0
  189. package/src/private/webapis/structuredClone/structuredClone.js +233 -0
  190. package/src/private/webapis/webidl/PlatformObjects.js +59 -0
  191. package/src/types/globals.d.ts +42 -0
  192. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +0 -1
  193. package/types/index.d.ts +1 -1
  194. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.cpp +0 -78
  195. package/ReactCommon/TEMP_UntilReactCommonUpdate/cxxreact/JSExecutor.h +0 -196
@@ -41,242 +41,164 @@ type TextForwardRef = React.ElementRef<
41
41
  const TextImpl: component(
42
42
  ref?: React.RefSetter<TextForwardRef>,
43
43
  ...props: TextProps
44
- ) = React.forwardRef(
45
- (
46
- {
47
- accessible,
48
- accessibilityLabel,
49
- accessibilityLevel, // Windows
50
- accessibilityPosInSet, // Windows
51
- accessibilitySetSize, // Windows
52
- accessibilityState,
53
- allowFontScaling,
54
- 'aria-busy': ariaBusy,
55
- 'aria-checked': ariaChecked,
56
- 'aria-disabled': ariaDisabled,
57
- 'aria-expanded': ariaExpanded,
58
- 'aria-multiselectable': ariaMultiselectable, // Windows
59
- 'aria-required': ariaRequired, // Windows
60
- 'aria-label': ariaLabel,
61
- 'aria-level': ariaLevel, // Windows
62
- 'aria-posinset': ariaPosinset, // Windows
63
- 'aria-setsize': ariaSetsize, // Windows
64
- 'aria-selected': ariaSelected,
65
- 'aria-readonly': ariaReadOnly, //Windows
66
- children,
67
- ellipsizeMode,
68
- disabled,
69
- id,
70
- nativeID,
71
- numberOfLines,
72
- onLongPress,
73
- onPress,
74
- onPressIn,
75
- onPressOut,
76
- onResponderGrant,
77
- onResponderMove,
78
- onResponderRelease,
79
- onResponderTerminate,
80
- onResponderTerminationRequest,
81
- onStartShouldSetResponder,
82
- pressRetentionOffset,
83
- selectable,
84
- selectionColor,
85
- suppressHighlighting,
86
- style,
87
- ...restProps
88
- }: TextProps,
89
- forwardedRef,
90
- ) => {
91
- const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
92
- const _accessibilityLevel = ariaLevel ?? accessibilityLevel; // Windows
93
- const _accessibilityPosInSet = ariaPosinset ?? accessibilityPosInSet; // Windows
94
- const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize; // Windows
95
-
96
- let _accessibilityState: ?TextProps['accessibilityState'] =
97
- accessibilityState;
98
- if (
99
- ariaBusy != null ||
100
- ariaChecked != null ||
101
- ariaDisabled != null ||
102
- ariaExpanded != null ||
103
- ariaSelected != null ||
104
- ariaReadOnly != null || // Windows
105
- ariaMultiselectable != null || // Windows
106
- ariaRequired != null // Windows
107
- ) {
108
- if (_accessibilityState != null) {
109
- _accessibilityState = {
110
- busy: ariaBusy ?? _accessibilityState.busy,
111
- checked: ariaChecked ?? _accessibilityState.checked,
112
- disabled: ariaDisabled ?? _accessibilityState.disabled,
113
- expanded: ariaExpanded ?? _accessibilityState.expanded,
114
- selected: ariaSelected ?? _accessibilityState.selected,
115
- readOnly: ariaReadOnly ?? _accessibilityState.readOnly, // Windows
116
- multiselectable:
117
- ariaMultiselectable ?? _accessibilityState.multiselectable, // Windows
118
- required: ariaRequired ?? _accessibilityState.required, // Windows
119
- };
120
- } else {
121
- _accessibilityState = {
122
- busy: ariaBusy,
123
- checked: ariaChecked,
124
- disabled: ariaDisabled,
125
- expanded: ariaExpanded,
126
- selected: ariaSelected,
127
- readOnly: ariaReadOnly, // Windows
128
- multiselectable: ariaMultiselectable, // Windows
129
- required: ariaRequired, // Windows
130
- };
131
- }
44
+ ) = ({
45
+ ref: forwardedRef,
46
+ accessible,
47
+ accessibilityLabel,
48
+ accessibilityLevel, // Windows
49
+ accessibilityPosInSet, // Windows
50
+ accessibilitySetSize, // Windows
51
+ accessibilityState,
52
+ allowFontScaling,
53
+ 'aria-busy': ariaBusy,
54
+ 'aria-checked': ariaChecked,
55
+ 'aria-disabled': ariaDisabled,
56
+ 'aria-expanded': ariaExpanded,
57
+ 'aria-multiselectable': ariaMultiselectable, // Windows
58
+ 'aria-required': ariaRequired, // Windows
59
+ 'aria-label': ariaLabel,
60
+ 'aria-level': ariaLevel, // Windows
61
+ 'aria-posinset': ariaPosinset, // Windows
62
+ 'aria-setsize': ariaSetsize, // Windows
63
+ 'aria-readonly': ariaReadOnly, //Windows
64
+ 'aria-selected': ariaSelected,
65
+ children,
66
+ ellipsizeMode,
67
+ disabled,
68
+ id,
69
+ nativeID,
70
+ numberOfLines,
71
+ onLongPress,
72
+ onPress,
73
+ onPressIn,
74
+ onPressOut,
75
+ onResponderGrant,
76
+ onResponderMove,
77
+ onResponderRelease,
78
+ onResponderTerminate,
79
+ onResponderTerminationRequest,
80
+ onStartShouldSetResponder,
81
+ pressRetentionOffset,
82
+ selectable,
83
+ selectionColor,
84
+ suppressHighlighting,
85
+ style,
86
+ ...restProps
87
+ }: {
88
+ ref?: React.RefSetter<TextForwardRef>,
89
+ ...TextProps,
90
+ }) => {
91
+ const _accessibilityLabel = ariaLabel ?? accessibilityLabel;
92
+ const _accessibilityLevel = ariaLevel ?? accessibilityLevel; // Windows
93
+ const _accessibilityPosInSet = ariaPosinset ?? accessibilityPosInSet; // Windows
94
+ const _accessibilitySetSize = ariaSetsize ?? accessibilitySetSize; // Windows
95
+
96
+ let _accessibilityState: ?TextProps['accessibilityState'] =
97
+ accessibilityState;
98
+ if (
99
+ ariaBusy != null ||
100
+ ariaChecked != null ||
101
+ ariaDisabled != null ||
102
+ ariaExpanded != null ||
103
+ ariaSelected != null ||
104
+ ariaReadOnly != null || // Windows
105
+ ariaMultiselectable != null || // Windows
106
+ ariaRequired != null // Windows
107
+ ) {
108
+ if (_accessibilityState != null) {
109
+ _accessibilityState = {
110
+ busy: ariaBusy ?? _accessibilityState.busy,
111
+ checked: ariaChecked ?? _accessibilityState.checked,
112
+ disabled: ariaDisabled ?? _accessibilityState.disabled,
113
+ expanded: ariaExpanded ?? _accessibilityState.expanded,
114
+ selected: ariaSelected ?? _accessibilityState.selected,
115
+ readOnly: ariaReadOnly ?? _accessibilityState.readOnly, // Windows
116
+ multiselectable:
117
+ ariaMultiselectable ?? _accessibilityState.multiselectable, // Windows
118
+ required: ariaRequired ?? _accessibilityState.required, // Windows
119
+ };
120
+ } else {
121
+ _accessibilityState = {
122
+ busy: ariaBusy,
123
+ checked: ariaChecked,
124
+ disabled: ariaDisabled,
125
+ expanded: ariaExpanded,
126
+ selected: ariaSelected,
127
+ readOnly: ariaReadOnly, // Windows
128
+ multiselectable: ariaMultiselectable, // Windows
129
+ required: ariaRequired, // Windows
130
+ };
132
131
  }
132
+ }
133
133
 
134
- const _accessibilityStateDisabled = _accessibilityState?.disabled;
135
- const _disabled = disabled ?? _accessibilityStateDisabled;
134
+ const _accessibilityStateDisabled = _accessibilityState?.disabled;
135
+ const _disabled = disabled ?? _accessibilityStateDisabled;
136
136
 
137
- const isPressable =
138
- (onPress != null ||
139
- onLongPress != null ||
140
- onStartShouldSetResponder != null) &&
141
- _disabled !== true;
137
+ const isPressable =
138
+ (onPress != null ||
139
+ onLongPress != null ||
140
+ onStartShouldSetResponder != null) &&
141
+ _disabled !== true;
142
142
 
143
- // TODO: Move this processing to the view configuration.
144
- const _selectionColor =
145
- selectionColor != null ? processColor(selectionColor) : undefined;
143
+ // TODO: Move this processing to the view configuration.
144
+ const _selectionColor =
145
+ selectionColor != null ? processColor(selectionColor) : undefined;
146
146
 
147
- let _style = style;
148
- if (__DEV__) {
149
- if (PressabilityDebug.isEnabled() && onPress != null) {
150
- _style = [style, {color: 'magenta'}];
151
- }
147
+ let _style = style;
148
+ if (__DEV__) {
149
+ if (PressabilityDebug.isEnabled() && onPress != null) {
150
+ _style = [style, {color: 'magenta'}];
152
151
  }
152
+ }
153
153
 
154
- let _numberOfLines = numberOfLines;
155
- if (_numberOfLines != null && !(_numberOfLines >= 0)) {
156
- if (__DEV__) {
157
- console.error(
158
- `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
159
- );
160
- }
161
- _numberOfLines = 0;
154
+ let _numberOfLines = numberOfLines;
155
+ if (_numberOfLines != null && !(_numberOfLines >= 0)) {
156
+ if (__DEV__) {
157
+ console.error(
158
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${_numberOfLines}. The value will be set to 0.`,
159
+ );
162
160
  }
163
-
164
- let _selectable = selectable;
165
-
166
- let processedStyle = flattenStyle<TextStyleProp>(_style);
167
- if (processedStyle != null) {
168
- let overrides: ?{...TextStyleInternal} = null;
169
- if (typeof processedStyle.fontWeight === 'number') {
170
- overrides = overrides || ({}: {...TextStyleInternal});
171
- overrides.fontWeight =
172
- // $FlowFixMe[incompatible-cast]
173
- (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
174
- }
175
-
176
- if (processedStyle.userSelect != null) {
177
- _selectable = userSelectToSelectableMap[processedStyle.userSelect];
178
- overrides = overrides || ({}: {...TextStyleInternal});
179
- overrides.userSelect = undefined;
180
- }
181
-
182
- if (processedStyle.verticalAlign != null) {
183
- overrides = overrides || ({}: {...TextStyleInternal});
184
- overrides.textAlignVertical =
185
- verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
186
- overrides.verticalAlign = undefined;
187
- }
188
-
189
- if (overrides != null) {
190
- // $FlowFixMe[incompatible-type]
191
- _style = [_style, overrides];
192
- }
161
+ _numberOfLines = 0;
162
+ }
163
+
164
+ let _selectable = selectable;
165
+
166
+ let processedStyle = flattenStyle<TextStyleProp>(_style);
167
+ if (processedStyle != null) {
168
+ let overrides: ?{...TextStyleInternal} = null;
169
+ if (typeof processedStyle.fontWeight === 'number') {
170
+ overrides = overrides || ({}: {...TextStyleInternal});
171
+ overrides.fontWeight =
172
+ // $FlowFixMe[incompatible-cast]
173
+ (processedStyle.fontWeight.toString(): TextStyleInternal['fontWeight']);
193
174
  }
194
175
 
195
- const _nativeID = id ?? nativeID;
196
-
197
- const hasTextAncestor = useContext(TextAncestor);
198
- if (hasTextAncestor) {
199
- if (isPressable) {
200
- return (
201
- <NativePressableVirtualText
202
- ref={forwardedRef}
203
- textProps={{
204
- ...restProps,
205
- accessibilityLabel: _accessibilityLabel,
206
- accessibilityState: _accessibilityState,
207
- accessibilityLevel: _accessibilityLevel, // Windows
208
- accessibilityPosInSet: _accessibilityPosInSet, // Windows
209
- accessibilitySetSize: _accessibilitySetSize, // Windows
210
- nativeID: _nativeID,
211
- numberOfLines: _numberOfLines,
212
- selectable: _selectable,
213
- selectionColor: _selectionColor,
214
- style: _style,
215
- disabled: disabled,
216
- children,
217
- }}
218
- textPressabilityProps={{
219
- onLongPress,
220
- onPress,
221
- onPressIn,
222
- onPressOut,
223
- onResponderGrant,
224
- onResponderMove,
225
- onResponderRelease,
226
- onResponderTerminate,
227
- onResponderTerminationRequest,
228
- onStartShouldSetResponder,
229
- pressRetentionOffset,
230
- suppressHighlighting,
231
- }}
232
- />
233
- );
234
- }
176
+ if (processedStyle.userSelect != null) {
177
+ _selectable = userSelectToSelectableMap[processedStyle.userSelect];
178
+ overrides = overrides || ({}: {...TextStyleInternal});
179
+ overrides.userSelect = undefined;
180
+ }
235
181
 
236
- return (
237
- <NativeVirtualText
238
- {...restProps}
239
- accessibilityLabel={_accessibilityLabel}
240
- accessibilityState={_accessibilityState}
241
- accessibilityLevel={_accessibilityLevel} // Windows
242
- accessibilityPosInSet={_accessibilityPosInSet} // Windows
243
- accessibilitySetSize={_accessibilitySetSize} // Windows
244
- nativeID={_nativeID}
245
- numberOfLines={_numberOfLines}
246
- ref={forwardedRef}
247
- selectable={_selectable}
248
- selectionColor={_selectionColor}
249
- style={_style}
250
- disabled={disabled}>
251
- {children}
252
- </NativeVirtualText>
253
- );
182
+ if (processedStyle.verticalAlign != null) {
183
+ overrides = overrides || ({}: {...TextStyleInternal});
184
+ overrides.textAlignVertical =
185
+ verticalAlignToTextAlignVerticalMap[processedStyle.verticalAlign];
186
+ overrides.verticalAlign = undefined;
254
187
  }
255
188
 
256
- // If the disabled prop and accessibilityState.disabled are out of sync but not both in
257
- // falsy states we need to update the accessibilityState object to use the disabled prop.
258
- if (
259
- _disabled !== _accessibilityStateDisabled &&
260
- ((_disabled != null && _disabled !== false) ||
261
- (_accessibilityStateDisabled != null &&
262
- _accessibilityStateDisabled !== false))
263
- ) {
264
- _accessibilityState = {..._accessibilityState, disabled: _disabled};
189
+ if (overrides != null) {
190
+ // $FlowFixMe[incompatible-type]
191
+ _style = [_style, overrides];
265
192
  }
193
+ }
266
194
 
267
- const _accessible = Platform.select({
268
- ios: accessible !== false,
269
- android:
270
- accessible == null
271
- ? onPress != null || onLongPress != null
272
- : accessible,
273
- default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
274
- });
195
+ const _nativeID = id ?? nativeID;
275
196
 
276
- let nativeText = null;
197
+ const hasTextAncestor = useContext(TextAncestor);
198
+ if (hasTextAncestor) {
277
199
  if (isPressable) {
278
- nativeText = (
279
- <NativePressableText
200
+ return (
201
+ <NativePressableVirtualText
280
202
  ref={forwardedRef}
281
203
  textProps={{
282
204
  ...restProps,
@@ -285,15 +207,13 @@ const TextImpl: component(
285
207
  accessibilityLevel: _accessibilityLevel, // Windows
286
208
  accessibilityPosInSet: _accessibilityPosInSet, // Windows
287
209
  accessibilitySetSize: _accessibilitySetSize, // Windows
288
- accessible: _accessible,
289
- allowFontScaling: allowFontScaling !== false,
290
- disabled: _disabled,
291
- ellipsizeMode: ellipsizeMode ?? 'tail',
210
+ ellipsizeMode: ellipsizeMode ?? 'tail', // Windows
292
211
  nativeID: _nativeID,
293
212
  numberOfLines: _numberOfLines,
294
213
  selectable: _selectable,
295
214
  selectionColor: _selectionColor,
296
215
  style: _style,
216
+ disabled: disabled,
297
217
  children,
298
218
  }}
299
219
  textPressabilityProps={{
@@ -312,85 +232,132 @@ const TextImpl: component(
312
232
  }}
313
233
  />
314
234
  );
315
- } else {
316
- nativeText = (
317
- <NativeText
318
- {...restProps}
319
- accessibilityLabel={_accessibilityLabel}
320
- accessibilityState={_accessibilityState}
321
- accessibilityLevel={_accessibilityLevel} // Windows
322
- accessibilityPosInSet={_accessibilityPosInSet} // Windows
323
- accessibilitySetSize={_accessibilitySetSize} // Windows
324
- accessible={_accessible}
325
- allowFontScaling={allowFontScaling !== false}
326
- disabled={_disabled}
327
- ellipsizeMode={ellipsizeMode ?? 'tail'}
328
- nativeID={_nativeID}
329
- numberOfLines={_numberOfLines}
330
- ref={forwardedRef}
331
- selectable={_selectable}
332
- selectionColor={_selectionColor}
333
- style={_style}>
334
- {children}
335
- </NativeText>
336
- );
337
235
  }
338
236
 
339
- // [Windows
340
- // $FlowFixMe[unclear-type]
341
- let styleProps: ViewStyleProp = (style: any); // Flow style type casting
342
- if (
343
- global.RN$Bridgeless !== true && // [Windows] Fabric text handles borders, but on paper we need to wrap it in an extra view
344
- styleProps &&
345
- styleProps.borderColor != null &&
346
- (styleProps.borderWidth != null ||
347
- styleProps.borderBottomWidth != null ||
348
- styleProps.borderEndWidth != null ||
349
- styleProps.borderLeftWidth != null ||
350
- styleProps.borderRightWidth != null ||
351
- styleProps.borderStartWidth != null ||
352
- styleProps.borderTopWidth != null)
353
- ) {
354
- return (
355
- <View style={styleProps}>
356
- <TextAncestor.Provider value={true}>
357
- {nativeText}
358
- </TextAncestor.Provider>
359
- </View>
360
- );
237
+ return (
238
+ <NativeVirtualText
239
+ {...restProps}
240
+ accessibilityLabel={_accessibilityLabel}
241
+ accessibilityState={_accessibilityState}
242
+ nativeID={_nativeID}
243
+ numberOfLines={_numberOfLines}
244
+ ref={forwardedRef}
245
+ selectable={_selectable}
246
+ selectionColor={_selectionColor}
247
+ style={_style}
248
+ disabled={disabled}>
249
+ {children}
250
+ </NativeVirtualText>
251
+ );
252
+ }
253
+
254
+ // If the disabled prop and accessibilityState.disabled are out of sync but not both in
255
+ // falsy states we need to update the accessibilityState object to use the disabled prop.
256
+ if (
257
+ _disabled !== _accessibilityStateDisabled &&
258
+ ((_disabled != null && _disabled !== false) ||
259
+ (_accessibilityStateDisabled != null &&
260
+ _accessibilityStateDisabled !== false))
261
+ ) {
262
+ _accessibilityState = {..._accessibilityState, disabled: _disabled};
263
+ }
264
+
265
+ const _accessible = Platform.select({
266
+ ios: accessible !== false,
267
+ android:
268
+ accessible == null ? onPress != null || onLongPress != null : accessible,
269
+ default: accessible !== false, // [Windows #13996 - default value is accessible !== false]
270
+ });
271
+
272
+ let nativeText = null;
273
+ if (isPressable) {
274
+ nativeText = (
275
+ <NativePressableText
276
+ ref={forwardedRef}
277
+ textProps={{
278
+ ...restProps,
279
+ accessibilityLabel: _accessibilityLabel,
280
+ accessibilityState: _accessibilityState,
281
+ accessible: _accessible,
282
+ allowFontScaling: allowFontScaling !== false,
283
+ disabled: _disabled,
284
+ ellipsizeMode: ellipsizeMode ?? 'tail',
285
+ nativeID: _nativeID,
286
+ numberOfLines: _numberOfLines,
287
+ selectable: _selectable,
288
+ selectionColor: _selectionColor,
289
+ style: _style,
290
+ children,
291
+ }}
292
+ textPressabilityProps={{
293
+ onLongPress,
294
+ onPress,
295
+ onPressIn,
296
+ onPressOut,
297
+ onResponderGrant,
298
+ onResponderMove,
299
+ onResponderRelease,
300
+ onResponderTerminate,
301
+ onResponderTerminationRequest,
302
+ onStartShouldSetResponder,
303
+ pressRetentionOffset,
304
+ suppressHighlighting,
305
+ }}
306
+ />
307
+ );
308
+ } else {
309
+ nativeText = (
310
+ <NativeText
311
+ {...restProps}
312
+ accessibilityLabel={_accessibilityLabel}
313
+ accessibilityState={_accessibilityState}
314
+ accessibilityLevel={_accessibilityLevel} // Windows
315
+ accessibilityPosInSet={_accessibilityPosInSet} // Windows
316
+ accessibilitySetSize={_accessibilitySetSize} // Windows
317
+ accessible={_accessible}
318
+ allowFontScaling={allowFontScaling !== false}
319
+ disabled={_disabled}
320
+ ellipsizeMode={ellipsizeMode ?? 'tail'}
321
+ nativeID={_nativeID}
322
+ numberOfLines={_numberOfLines}
323
+ ref={forwardedRef}
324
+ selectable={_selectable}
325
+ selectionColor={_selectionColor}
326
+ style={_style}>
327
+ {children}
328
+ </NativeText>
329
+ );
330
+ }
331
+
332
+ if (children == null) {
333
+ return nativeText;
334
+ }
335
+
336
+ // If the children do not contain a JSX element it would not be possible to have a
337
+ // nested `Text` component so we can skip adding the `TextAncestor` context wrapper
338
+ // which has a performance overhead. Since we do this for performance reasons we need
339
+ // to keep the check simple to avoid regressing overall perf. For this reason the
340
+ // `children.length` constant is set to `3`, this should be a reasonable tradeoff
341
+ // to capture the majority of `Text` uses but also not make this check too expensive.
342
+ if (Array.isArray(children) && children.length <= 3) {
343
+ let hasNonTextChild = false;
344
+ for (let child of children) {
345
+ if (child != null && typeof child === 'object') {
346
+ hasNonTextChild = true;
347
+ break;
348
+ }
361
349
  }
362
- // Windows]
363
-
364
- if (children == null) {
350
+ if (!hasNonTextChild) {
365
351
  return nativeText;
366
352
  }
353
+ } else if (typeof children !== 'object') {
354
+ return nativeText;
355
+ }
367
356
 
368
- // If the children do not contain a JSX element it would not be possible to have a
369
- // nested `Text` component so we can skip adding the `TextAncestor` context wrapper
370
- // which has a performance overhead. Since we do this for performance reasons we need
371
- // to keep the check simple to avoid regressing overall perf. For this reason the
372
- // `children.length` constant is set to `3`, this should be a reasonable tradeoff
373
- // to capture the majority of `Text` uses but also not make this check too expensive.
374
- if (Array.isArray(children) && children.length <= 3) {
375
- let hasNonTextChild = false;
376
- for (let child of children) {
377
- if (child != null && typeof child === 'object') {
378
- hasNonTextChild = true;
379
- break;
380
- }
381
- }
382
- if (!hasNonTextChild) {
383
- return nativeText;
384
- } else if (typeof children !== 'object') {
385
- return nativeText;
386
- }
387
- }
388
-
389
- return (
390
- <TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
391
- );
392
- },
393
- );
357
+ return (
358
+ <TextAncestor.Provider value={true}>{nativeText}</TextAncestor.Provider>
359
+ );
360
+ };
394
361
 
395
362
  TextImpl.displayName = 'Text';
396
363
 
@@ -542,7 +509,14 @@ type NativePressableTextProps = $ReadOnly<{
542
509
  const NativePressableVirtualText: component(
543
510
  ref: React.RefSetter<TextForwardRef>,
544
511
  ...props: NativePressableTextProps
545
- ) = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
512
+ ) = ({
513
+ ref: forwardedRef,
514
+ textProps,
515
+ textPressabilityProps,
516
+ }: {
517
+ ref?: React.RefSetter<TextForwardRef>,
518
+ ...NativePressableTextProps,
519
+ }) => {
546
520
  const [isHighlighted, eventHandlersForText] = useTextPressability(
547
521
  textPressabilityProps,
548
522
  );
@@ -556,7 +530,7 @@ const NativePressableVirtualText: component(
556
530
  ref={forwardedRef}
557
531
  />
558
532
  );
559
- });
533
+ };
560
534
 
561
535
  /**
562
536
  * Wrap the NativeText component and initialize pressability.
@@ -567,7 +541,14 @@ const NativePressableVirtualText: component(
567
541
  const NativePressableText: component(
568
542
  ref: React.RefSetter<TextForwardRef>,
569
543
  ...props: NativePressableTextProps
570
- ) = React.forwardRef(({textProps, textPressabilityProps}, forwardedRef) => {
544
+ ) = ({
545
+ ref: forwardedRef,
546
+ textProps,
547
+ textPressabilityProps,
548
+ }: {
549
+ ref?: React.RefSetter<TextForwardRef>,
550
+ ...NativePressableTextProps,
551
+ }) => {
571
552
  const [isHighlighted, eventHandlersForText] = useTextPressability(
572
553
  textPressabilityProps,
573
554
  );
@@ -581,7 +562,7 @@ const NativePressableText: component(
581
562
  ref={forwardedRef}
582
563
  />
583
564
  );
584
- });
565
+ };
585
566
 
586
567
  const userSelectToSelectableMap = {
587
568
  auto: true,
@@ -10,12 +10,13 @@
10
10
 
11
11
  'use strict';
12
12
 
13
- const React = require('react');
13
+ import * as React from 'react';
14
+ import {createContext} from 'react';
14
15
 
15
16
  /**
16
17
  * Whether the current element is the descendant of a <Text> element.
17
18
  */
18
- const TextAncestorContext: React.Context<boolean> = React.createContext(false);
19
+ const TextAncestorContext: React.Context<boolean> = createContext(false);
19
20
  if (__DEV__) {
20
21
  TextAncestorContext.displayName = 'TextAncestorContext';
21
22
  }