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
@@ -10,9 +10,11 @@
10
10
 
11
11
  import type {ViewProps} from './ViewPropTypes';
12
12
 
13
+ import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
13
14
  import TextAncestor from '../../Text/TextAncestor';
14
15
  import ViewNativeComponent from './ViewNativeComponent';
15
16
  import * as React from 'react';
17
+ import {use} from 'react';
16
18
  import invariant from 'invariant'; // [Windows]
17
19
  // [Windows
18
20
  import type {KeyEvent} from '../../Types/CoreEventTypes';
@@ -20,6 +22,11 @@ import type {KeyEvent} from '../../Types/CoreEventTypes';
20
22
 
21
23
  export type Props = ViewProps;
22
24
 
25
+ type PropsWithRef = $ReadOnly<{
26
+ ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
27
+ ...ViewProps,
28
+ }>;
29
+
23
30
  // [Windows
24
31
  // $FlowFixMe - children typing
25
32
  const childrenWithImportantForAccessibility = children => {
@@ -57,57 +64,270 @@ const childrenWithImportantForAccessibility = children => {
57
64
  *
58
65
  * @see https://reactnative.dev/docs/view
59
66
  */
60
- const View: component(
61
- ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
62
- ...props: ViewProps
63
- ) = React.forwardRef(
64
- (
65
- {
66
- accessibilityElementsHidden,
67
- accessibilityLabel,
68
- accessibilityLabelledBy,
69
- accessibilityLevel, // Windows
70
- accessibilityDescription, //Windows
71
- accessibilityLiveRegion,
72
- accessibilityPosInSet, // Windows
73
- accessibilitySetSize, // Windows
74
- accessibilityState,
75
- accessibilityValue,
76
- 'aria-busy': ariaBusy,
77
- 'aria-checked': ariaChecked,
78
- 'aria-disabled': ariaDisabled,
79
- 'aria-expanded': ariaExpanded,
80
- 'aria-multiselectable': ariaMultiselectable, // Windows
81
- 'aria-required': ariaRequired, // Windows
82
- 'aria-description': ariaDescription, //Windows
83
- 'aria-hidden': ariaHidden,
84
- 'aria-label': ariaLabel,
85
- 'aria-labelledby': ariaLabelledBy,
86
- 'aria-level': ariaLevel,
87
- 'aria-live': ariaLive,
88
- 'aria-posinset': ariaPosinset, // Windows
89
- 'aria-readonly': ariaReadOnly, // Windows
90
- 'aria-selected': ariaSelected,
91
- 'aria-setsize': ariaSetsize, // Windows
92
- 'aria-valuemax': ariaValueMax,
93
- 'aria-valuemin': ariaValueMin,
94
- 'aria-valuenow': ariaValueNow,
95
- 'aria-valuetext': ariaValueText,
96
- focusable,
97
- disabled,
98
- id,
99
- importantForAccessibility,
100
- nativeID,
101
- tabIndex,
102
- ...otherProps
103
- }: ViewProps,
104
- forwardedRef,
105
- ) => {
106
- const hasTextAncestor = React.useContext(TextAncestor);
107
- const _accessibilityLabelledBy =
108
- ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
109
-
110
- const _accessibilityState =
67
+ function View(props: PropsWithRef): React.Node {
68
+ const hasTextAncestor = use(TextAncestor);
69
+
70
+ // Extract common props needed by all paths
71
+ const {
72
+ accessibilityElementsHidden,
73
+ accessibilityLabel,
74
+ accessibilityLabelledBy,
75
+ accessibilityLevel, // Windows
76
+ accessibilityDescription, //Windows
77
+ accessibilityLiveRegion,
78
+ accessibilityPosInSet, // Windows
79
+ accessibilitySetSize, // Windows
80
+ accessibilityState,
81
+ accessibilityValue,
82
+ 'aria-busy': ariaBusy,
83
+ 'aria-checked': ariaChecked,
84
+ 'aria-disabled': ariaDisabled,
85
+ 'aria-expanded': ariaExpanded,
86
+ 'aria-multiselectable': ariaMultiselectable, // Windows
87
+ 'aria-required': ariaRequired, // Windows
88
+ 'aria-description': ariaDescription, //Windows
89
+ 'aria-hidden': ariaHidden,
90
+ 'aria-label': ariaLabel,
91
+ 'aria-labelledby': ariaLabelledBy,
92
+ 'aria-level': ariaLevel,
93
+ 'aria-live': ariaLive,
94
+ 'aria-posinset': ariaPosinset, // Windows
95
+ 'aria-readonly': ariaReadOnly, // Windows
96
+ 'aria-selected': ariaSelected,
97
+ 'aria-setsize': ariaSetsize, // Windows
98
+ 'aria-valuemax': ariaValueMax,
99
+ 'aria-valuemin': ariaValueMin,
100
+ 'aria-valuenow': ariaValueNow,
101
+ 'aria-valuetext': ariaValueText,
102
+ focusable,
103
+ disabled,
104
+ id,
105
+ importantForAccessibility,
106
+ nativeID,
107
+ tabIndex,
108
+ ref,
109
+ ...otherProps
110
+ } = props;
111
+
112
+ // Pre-compute common values needed by both optimized and Paper paths
113
+ const _accessibilityLabelledBy =
114
+ ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
115
+
116
+ const _accessibilityState =
117
+ accessibilityState != null ||
118
+ ariaBusy != null ||
119
+ ariaChecked != null ||
120
+ ariaDisabled != null ||
121
+ ariaExpanded != null ||
122
+ ariaSelected != null ||
123
+ ariaReadOnly != null || // Windows
124
+ ariaMultiselectable != null || // Windows
125
+ ariaRequired != null // Windows
126
+ ? {
127
+ busy: ariaBusy ?? accessibilityState?.busy,
128
+ checked: ariaChecked ?? accessibilityState?.checked,
129
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
130
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
131
+ selected: ariaSelected ?? accessibilityState?.selected,
132
+ readOnly: ariaReadOnly ?? accessibilityState?.readOnly, // Windows
133
+ multiselectable:
134
+ ariaMultiselectable ?? accessibilityState?.multiselectable, // Windows
135
+ required: ariaRequired ?? accessibilityState?.required, // Windows
136
+ }
137
+ : undefined;
138
+
139
+ const _accessibilityValue =
140
+ accessibilityValue != null ||
141
+ ariaValueMax != null ||
142
+ ariaValueMin != null ||
143
+ ariaValueNow != null ||
144
+ ariaValueText != null
145
+ ? {
146
+ max: ariaValueMax ?? accessibilityValue?.max,
147
+ min: ariaValueMin ?? accessibilityValue?.min,
148
+ now: ariaValueNow ?? accessibilityValue?.now,
149
+ text: ariaValueText ?? accessibilityValue?.text,
150
+ }
151
+ : undefined;
152
+
153
+ const _keyDown =
154
+ otherProps.keyDownEvents || otherProps.onKeyDown
155
+ ? (event: KeyEvent) => {
156
+ if (
157
+ otherProps.keyDownEvents &&
158
+ event.isPropagationStopped() !== true
159
+ ) {
160
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
161
+ for (const el of otherProps.keyDownEvents) {
162
+ if (
163
+ event.nativeEvent.code === el.code &&
164
+ el.handledEventPhase === 3
165
+ ) {
166
+ event.stopPropagation();
167
+ }
168
+ }
169
+ }
170
+ otherProps.onKeyDown && otherProps.onKeyDown(event);
171
+ }
172
+ : undefined;
173
+
174
+ const _keyUp =
175
+ otherProps.keyUpEvents || otherProps.onKeyUp
176
+ ? (event: KeyEvent) => {
177
+ if (otherProps.keyUpEvents && event.isPropagationStopped() !== true) {
178
+ // $FlowFixMe - keyUpEvents was already checked to not be undefined
179
+ for (const el of otherProps.keyUpEvents) {
180
+ if (
181
+ event.nativeEvent.code === el.code &&
182
+ el.handledEventPhase === 3
183
+ ) {
184
+ event.stopPropagation();
185
+ }
186
+ }
187
+ }
188
+ otherProps.onKeyUp && otherProps.onKeyUp(event);
189
+ }
190
+ : undefined;
191
+
192
+ const _keyDownCapture =
193
+ otherProps.keyDownEvents || otherProps.onKeyDownCapture
194
+ ? (event: KeyEvent) => {
195
+ if (
196
+ otherProps.keyDownEvents &&
197
+ event.isPropagationStopped() !== true
198
+ ) {
199
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
200
+ for (const el of otherProps.keyDownEvents) {
201
+ if (
202
+ event.nativeEvent.code === el.code &&
203
+ el.handledEventPhase === 1
204
+ ) {
205
+ event.stopPropagation();
206
+ }
207
+ }
208
+ }
209
+ otherProps.onKeyDownCapture && otherProps.onKeyDownCapture(event);
210
+ }
211
+ : undefined;
212
+
213
+ const _keyUpCapture =
214
+ otherProps.keyUpEvents || otherProps.onKeyUpCapture
215
+ ? (event: KeyEvent) => {
216
+ if (otherProps.keyUpEvents && event.isPropagationStopped() !== true) {
217
+ // $FlowFixMe - keyUpEvents was already checked to not be undefined
218
+ for (const el of otherProps.keyUpEvents) {
219
+ if (
220
+ event.nativeEvent.code === el.code &&
221
+ el.handledEventPhase === 1
222
+ ) {
223
+ event.stopPropagation();
224
+ }
225
+ }
226
+ }
227
+ otherProps.onKeyUpCapture && otherProps.onKeyUpCapture(event);
228
+ }
229
+ : undefined;
230
+
231
+ // Windows computed values
232
+ const _focusable = tabIndex !== undefined ? !tabIndex : focusable;
233
+ const _accessible =
234
+ importantForAccessibility === 'no-hide-descendants'
235
+ ? false
236
+ : otherProps.accessible;
237
+
238
+ if (_focusable === true && _accessible === false) {
239
+ console.warn(
240
+ 'All focusable views should report proper accessibility information. Views marked as focusable should always be accessible.',
241
+ );
242
+ }
243
+
244
+ const computedImportantForAccessibility =
245
+ ariaHidden === true ||
246
+ importantForAccessibility === 'no-hide-descendants' ||
247
+ accessibilityElementsHidden === true
248
+ ? 'no-hide-descendants'
249
+ : importantForAccessibility;
250
+
251
+ let actualView;
252
+ if (ReactNativeFeatureFlags.reduceDefaultPropsInView()) {
253
+ //Destructured props at function scope, just create processedProps
254
+ const processedProps = otherProps as {...PropsWithRef};
255
+
256
+ const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
257
+ if (parsedAriaLabelledBy !== undefined) {
258
+ processedProps.accessibilityLabelledBy = parsedAriaLabelledBy;
259
+ }
260
+
261
+ if (ariaLabel !== undefined) {
262
+ processedProps.accessibilityLabel = ariaLabel;
263
+ }
264
+
265
+ if (ariaLive !== undefined) {
266
+ processedProps.accessibilityLiveRegion =
267
+ ariaLive === 'off' ? 'none' : ariaLive;
268
+ }
269
+
270
+ if (ariaHidden !== undefined) {
271
+ processedProps.accessibilityElementsHidden = ariaHidden;
272
+ if (ariaHidden === true) {
273
+ processedProps.importantForAccessibility = 'no-hide-descendants';
274
+ }
275
+ }
276
+
277
+ // Windows accessibility properties
278
+ if (ariaLevel !== undefined) {
279
+ processedProps.accessibilityLevel = ariaLevel;
280
+ } else if (accessibilityLevel !== undefined) {
281
+ processedProps.accessibilityLevel = accessibilityLevel;
282
+ }
283
+
284
+ if (ariaDescription !== undefined) {
285
+ processedProps.accessibilityDescription = ariaDescription;
286
+ } else if (accessibilityDescription !== undefined) {
287
+ processedProps.accessibilityDescription = accessibilityDescription;
288
+ }
289
+
290
+ if (ariaPosinset !== undefined) {
291
+ processedProps.accessibilityPosInSet = ariaPosinset;
292
+ } else if (accessibilityPosInSet !== undefined) {
293
+ processedProps.accessibilityPosInSet = accessibilityPosInSet;
294
+ }
295
+
296
+ if (ariaSetsize !== undefined) {
297
+ processedProps.accessibilitySetSize = ariaSetsize;
298
+ } else if (accessibilitySetSize !== undefined) {
299
+ processedProps.accessibilitySetSize = accessibilitySetSize;
300
+ }
301
+
302
+ // Windows base properties
303
+ if (focusable !== undefined) {
304
+ processedProps.focusable = tabIndex !== undefined ? !tabIndex : focusable;
305
+ } else if (tabIndex !== undefined) {
306
+ processedProps.focusable = !tabIndex;
307
+ }
308
+
309
+ if (disabled !== undefined) {
310
+ processedProps.disabled = disabled;
311
+ }
312
+
313
+ if (importantForAccessibility !== undefined) {
314
+ processedProps.importantForAccessibility = importantForAccessibility;
315
+ }
316
+
317
+ if (nativeID !== undefined) {
318
+ processedProps.nativeID = nativeID;
319
+ }
320
+ // Windows]
321
+
322
+ if (id !== undefined) {
323
+ processedProps.nativeID = id;
324
+ }
325
+
326
+ if (tabIndex !== undefined) {
327
+ processedProps.focusable = !tabIndex;
328
+ }
329
+
330
+ if (
111
331
  accessibilityState != null ||
112
332
  ariaBusy != null ||
113
333
  ariaChecked != null ||
@@ -117,138 +337,123 @@ const View: component(
117
337
  ariaReadOnly != null || // Windows
118
338
  ariaMultiselectable != null || // Windows
119
339
  ariaRequired != null // Windows
120
- ? {
121
- busy: ariaBusy ?? accessibilityState?.busy,
122
- checked: ariaChecked ?? accessibilityState?.checked,
123
- disabled: ariaDisabled ?? accessibilityState?.disabled,
124
- expanded: ariaExpanded ?? accessibilityState?.expanded,
125
- selected: ariaSelected ?? accessibilityState?.selected,
126
- readOnly: ariaReadOnly ?? accessibilityState?.readOnly, // Windows
127
- multiselectable:
128
- ariaMultiselectable ?? accessibilityState?.multiselectable, // Windows
129
- required: ariaRequired ?? accessibilityState?.required, // Windows
130
- }
131
- : undefined;
340
+ ) {
341
+ processedProps.accessibilityState = {
342
+ busy: ariaBusy ?? accessibilityState?.busy,
343
+ checked: ariaChecked ?? accessibilityState?.checked,
344
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
345
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
346
+ selected: ariaSelected ?? accessibilityState?.selected,
347
+ readOnly: ariaReadOnly ?? accessibilityState?.readOnly, // Windows
348
+ multiselectable:
349
+ ariaMultiselectable ?? accessibilityState?.multiselectable, // Windows
350
+ required: ariaRequired ?? accessibilityState?.required, // Windows
351
+ };
352
+ }
132
353
 
133
- const _accessibilityValue =
354
+ if (
134
355
  accessibilityValue != null ||
135
356
  ariaValueMax != null ||
136
357
  ariaValueMin != null ||
137
358
  ariaValueNow != null ||
138
359
  ariaValueText != null
139
- ? {
140
- max: ariaValueMax ?? accessibilityValue?.max,
141
- min: ariaValueMin ?? accessibilityValue?.min,
142
- now: ariaValueNow ?? accessibilityValue?.now,
143
- text: ariaValueText ?? accessibilityValue?.text,
144
- }
145
- : undefined;
360
+ ) {
361
+ processedProps.accessibilityValue = {
362
+ max: ariaValueMax ?? accessibilityValue?.max,
363
+ min: ariaValueMin ?? accessibilityValue?.min,
364
+ now: ariaValueNow ?? accessibilityValue?.now,
365
+ text: ariaValueText ?? accessibilityValue?.text,
366
+ };
367
+ }
146
368
 
147
- const _keyDown =
148
- otherProps.keyDownEvents || otherProps.onKeyDown
149
- ? (event: KeyEvent) => {
369
+ // [Windows key event processing and accessible property
370
+ if (otherProps.keyDownEvents || otherProps.onKeyDown) {
371
+ processedProps.onKeyDown = event => {
372
+ if (otherProps.keyDownEvents && event.isPropagationStopped() !== true) {
373
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
374
+ for (const el of otherProps.keyDownEvents) {
150
375
  if (
151
- otherProps.keyDownEvents &&
152
- event.isPropagationStopped() !== true
376
+ event.nativeEvent.code === el.code &&
377
+ el.handledEventPhase === 3
153
378
  ) {
154
- // $FlowFixMe - keyDownEvents was already checked to not be undefined
155
- for (const el of otherProps.keyDownEvents) {
156
- if (
157
- event.nativeEvent.code === el.code &&
158
- el.handledEventPhase === 3
159
- ) {
160
- event.stopPropagation();
161
- }
162
- }
379
+ event.stopPropagation();
163
380
  }
164
- otherProps.onKeyDown && otherProps.onKeyDown(event);
165
381
  }
166
- : undefined;
382
+ }
383
+ otherProps.onKeyDown && otherProps.onKeyDown(event);
384
+ };
385
+ }
167
386
 
168
- const _keyUp =
169
- otherProps.keyUpEvents || otherProps.onKeyUp
170
- ? (event: KeyEvent) => {
387
+ if (otherProps.keyUpEvents || otherProps.onKeyUp) {
388
+ processedProps.onKeyUp = event => {
389
+ if (otherProps.keyUpEvents && event.isPropagationStopped() !== true) {
390
+ // $FlowFixMe - keyUpEvents was already checked to not be undefined
391
+ for (const el of otherProps.keyUpEvents) {
171
392
  if (
172
- otherProps.keyUpEvents &&
173
- event.isPropagationStopped() !== true
393
+ event.nativeEvent.code === el.code &&
394
+ el.handledEventPhase === 3
174
395
  ) {
175
- // $FlowFixMe - keyUpEvents was already checked to not be undefined
176
- for (const el of otherProps.keyUpEvents) {
177
- if (
178
- event.nativeEvent.code === el.code &&
179
- el.handledEventPhase === 3
180
- ) {
181
- event.stopPropagation();
182
- }
183
- }
396
+ event.stopPropagation();
184
397
  }
185
- otherProps.onKeyUp && otherProps.onKeyUp(event);
186
398
  }
187
- : undefined;
399
+ }
400
+ otherProps.onKeyUp && otherProps.onKeyUp(event);
401
+ };
402
+ }
188
403
 
189
- const _keyDownCapture =
190
- otherProps.keyDownEvents || otherProps.onKeyDownCapture
191
- ? (event: KeyEvent) => {
404
+ if (otherProps.keyDownEvents || otherProps.onKeyDownCapture) {
405
+ processedProps.onKeyDownCapture = event => {
406
+ if (otherProps.keyDownEvents && event.isPropagationStopped() !== true) {
407
+ // $FlowFixMe - keyDownEvents was already checked to not be undefined
408
+ for (const el of otherProps.keyDownEvents) {
192
409
  if (
193
- otherProps.keyDownEvents &&
194
- event.isPropagationStopped() !== true
410
+ event.nativeEvent.code === el.code &&
411
+ el.handledEventPhase === 1
195
412
  ) {
196
- // $FlowFixMe - keyDownEvents was already checked to not be undefined
197
- for (const el of otherProps.keyDownEvents) {
198
- if (
199
- event.nativeEvent.code === el.code &&
200
- el.handledEventPhase === 1
201
- ) {
202
- event.stopPropagation();
203
- }
204
- }
413
+ event.stopPropagation();
205
414
  }
206
- otherProps.onKeyDownCapture && otherProps.onKeyDownCapture(event);
207
415
  }
208
- : undefined;
416
+ }
417
+ otherProps.onKeyDownCapture && otherProps.onKeyDownCapture(event);
418
+ };
419
+ }
209
420
 
210
- const _keyUpCapture =
211
- otherProps.keyUpEvents || otherProps.onKeyUpCapture
212
- ? (event: KeyEvent) => {
421
+ if (otherProps.keyUpEvents || otherProps.onKeyUpCapture) {
422
+ processedProps.onKeyUpCapture = event => {
423
+ if (otherProps.keyUpEvents && event.isPropagationStopped() !== true) {
424
+ // $FlowFixMe - keyUpEvents was already checked to not be undefined
425
+ for (const el of otherProps.keyUpEvents) {
213
426
  if (
214
- otherProps.keyUpEvents &&
215
- event.isPropagationStopped() !== true
427
+ event.nativeEvent.code === el.code &&
428
+ el.handledEventPhase === 1
216
429
  ) {
217
- // $FlowFixMe - keyUpEvents was already checked to not be undefined
218
- for (const el of otherProps.keyUpEvents) {
219
- if (
220
- event.nativeEvent.code === el.code &&
221
- el.handledEventPhase === 1
222
- ) {
223
- event.stopPropagation();
224
- }
225
- }
430
+ event.stopPropagation();
226
431
  }
227
- otherProps.onKeyUpCapture && otherProps.onKeyUpCapture(event);
228
432
  }
229
- : undefined;
433
+ }
434
+ otherProps.onKeyUpCapture && otherProps.onKeyUpCapture(event);
435
+ };
436
+ }
230
437
 
231
- // [Windows
232
- const _focusable = tabIndex !== undefined ? !tabIndex : focusable;
233
- const _accessible =
234
- importantForAccessibility === 'no-hide-descendants'
438
+ // Windows accessible property
439
+ const computedAccessible =
440
+ processedProps.importantForAccessibility === 'no-hide-descendants'
235
441
  ? false
236
442
  : otherProps.accessible;
443
+ if (computedAccessible !== undefined) {
444
+ processedProps.accessible = computedAccessible;
445
+ }
237
446
 
238
- if (_focusable === true && _accessible === false) {
239
- console.warn(
240
- 'All focusable views should report proper accessibility information. Views marked as focusable should always be accessible.',
241
- );
447
+ //Windows add ref to processedProps
448
+ if (ref !== undefined) {
449
+ processedProps.ref = ref;
242
450
  }
243
451
 
244
- const computedImportantForAccessibility =
245
- ariaHidden === true ||
246
- importantForAccessibility === 'no-hide-descendants' ||
247
- accessibilityElementsHidden === true
248
- ? 'no-hide-descendants'
249
- : importantForAccessibility;
452
+ actualView = <ViewNativeComponent {...processedProps} />;
453
+ } else {
454
+ // Destructured props at function scope
250
455
 
251
- const actualView = (
456
+ actualView = (
252
457
  <ViewNativeComponent
253
458
  {...otherProps}
254
459
  accessibilityLiveRegion={
@@ -267,90 +472,85 @@ const View: component(
267
472
  accessibilityValue={_accessibilityValue}
268
473
  importantForAccessibility={computedImportantForAccessibility}
269
474
  nativeID={id ?? nativeID}
270
- ref={forwardedRef}
271
- onKeyDown={_keyDown}
272
- onKeyDownCapture={_keyDownCapture}
273
- onKeyUp={_keyUp}
274
- onKeyUpCapture={_keyUpCapture}
275
475
  // [Windows
276
476
  accessible={_accessible}
277
477
  children={otherProps.children}
278
478
  // Windows]
279
479
  />
280
480
  );
481
+ }
281
482
 
282
- // [Windows - Paper doesn't support Views in Text while Fabric does
283
- if (global.RN$Bridgeless !== true) {
284
- return (
285
- // [Windows
286
- // In core this is a TextAncestor.Provider value={false} See
287
- // https://github.com/facebook/react-native/commit/66601e755fcad10698e61d20878d52194ad0e90c
288
- // But since Views are not currently supported in Text, we do not need the extra provider
289
- <TextAncestor.Consumer>
290
- {consumerHasTextAncestor => {
291
- invariant(
292
- !consumerHasTextAncestor,
293
- 'Nesting of <View> within <Text> is not currently supported.',
294
- );
295
- return (
296
- <ViewNativeComponent
297
- {...otherProps}
298
- accessibilityLiveRegion={
299
- ariaLive === 'off'
300
- ? 'none'
301
- : ariaLive ?? accessibilityLiveRegion
302
- }
303
- accessibilityLabel={ariaLabel ?? accessibilityLabel}
304
- accessibilityLevel={ariaLevel ?? accessibilityLevel}
305
- accessibilityDescription={
306
- ariaDescription ?? accessibilityDescription
307
- }
308
- accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet}
309
- accessibilitySetSize={ariaSetsize ?? accessibilitySetSize}
310
- focusable={_focusable}
311
- disabled={disabled}
312
- accessibilityState={_accessibilityState}
313
- accessibilityElementsHidden={
314
- ariaHidden ?? accessibilityElementsHidden
315
- }
316
- accessibilityLabelledBy={_accessibilityLabelledBy}
317
- accessibilityValue={_accessibilityValue}
318
- importantForAccessibility={computedImportantForAccessibility}
319
- nativeID={id ?? nativeID}
320
- ref={forwardedRef}
321
- onKeyDown={_keyDown}
322
- onKeyDownCapture={_keyDownCapture}
323
- onKeyUp={_keyUp}
324
- onKeyUpCapture={_keyUpCapture}
325
- // [Windows
326
- accessible={_accessible}
327
- children={
328
- computedImportantForAccessibility === 'no-hide-descendants'
329
- ? childrenWithImportantForAccessibility(otherProps.children)
330
- : otherProps.children
331
- }
332
- // Windows]
333
- />
334
- );
335
- }}
336
- </TextAncestor.Consumer>
337
- // Windows]
338
- );
339
- } else {
340
- if (hasTextAncestor) {
341
- return (
342
- <TextAncestor.Provider value={false}>
343
- {actualView}
344
- </TextAncestor.Provider>
345
- );
346
- }
347
- }
348
- // Windows]
483
+ // [Windows - Paper doesn't support Views in Text while Fabric does
484
+ if (global.RN$Bridgeless !== true) {
485
+ return (
486
+ // [Windows
487
+ // In core this is a TextAncestor.Provider value={false} See
488
+ // https://github.com/facebook/react-native/commit/66601e755fcad10698e61d20878d52194ad0e90c
489
+ // But since Views are not currently supported in Text, we do not need the extra provider
490
+ <TextAncestor.Consumer>
491
+ {consumerHasTextAncestor => {
492
+ invariant(
493
+ !hasTextAncestor,
494
+ 'Nesting of <View> within <Text> is not currently supported.',
495
+ );
496
+ return (
497
+ <ViewNativeComponent
498
+ {...otherProps}
499
+ accessibilityLiveRegion={
500
+ ariaLive === 'off'
501
+ ? 'none'
502
+ : ariaLive ?? accessibilityLiveRegion
503
+ }
504
+ accessibilityLabel={ariaLabel ?? accessibilityLabel}
505
+ accessibilityLevel={ariaLevel ?? accessibilityLevel}
506
+ accessibilityDescription={
507
+ ariaDescription ?? accessibilityDescription
508
+ }
509
+ accessibilityPosInSet={ariaPosinset ?? accessibilityPosInSet}
510
+ accessibilitySetSize={ariaSetsize ?? accessibilitySetSize}
511
+ focusable={_focusable}
512
+ disabled={disabled}
513
+ accessibilityState={_accessibilityState}
514
+ accessibilityElementsHidden={
515
+ ariaHidden ?? accessibilityElementsHidden
516
+ }
517
+ accessibilityLabelledBy={_accessibilityLabelledBy}
518
+ accessibilityValue={_accessibilityValue}
519
+ importantForAccessibility={computedImportantForAccessibility}
520
+ nativeID={id ?? nativeID}
521
+ ref={ref}
522
+ onKeyDown={_keyDown}
523
+ onKeyDownCapture={_keyDownCapture}
524
+ onKeyUp={_keyUp}
525
+ onKeyUpCapture={_keyUpCapture}
526
+ // [Windows
527
+ accessible={_accessible}
528
+ children={
529
+ computedImportantForAccessibility === 'no-hide-descendants'
530
+ ? childrenWithImportantForAccessibility(otherProps.children)
531
+ : otherProps.children
532
+ }
533
+ // Windows]
534
+ />
535
+ );
536
+ }}
537
+ </TextAncestor.Consumer>
538
+ // Windows]
539
+ );
540
+ }
541
+ // Windows]
349
542
 
350
- return actualView;
351
- },
352
- );
543
+ // Fabric supports Views in Text, so we can use the TextAncestor context
544
+ // [Windows
545
+ if (hasTextAncestor) {
546
+ return <TextAncestor value={false}>{actualView}</TextAncestor>;
547
+ }
548
+ // Windows]
353
549
 
354
- View.displayName = 'View';
550
+ return actualView;
551
+ }
355
552
 
356
- export default View;
553
+ export default View as component(
554
+ ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
555
+ ...props: ViewProps
556
+ );