@office-iss/react-native-win32 0.0.0-canary.299 → 0.0.0-canary.300

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 (99) hide show
  1. package/.flowconfig +3 -6
  2. package/CHANGELOG.json +46 -1
  3. package/CHANGELOG.md +19 -6
  4. package/IntegrationTests/IntegrationTestsApp.js +1 -1
  5. package/Libraries/Alert/RCTAlertManager.android.js +2 -0
  6. package/Libraries/Animated/Animated.d.ts +2 -0
  7. package/Libraries/Animated/AnimatedImplementation.js +2 -0
  8. package/Libraries/Animated/Easing.js +2 -0
  9. package/Libraries/Animated/animations/Animation.js +14 -14
  10. package/Libraries/Animated/animations/TimingAnimation.js +2 -0
  11. package/Libraries/Animated/nodes/AnimatedNode.js +7 -7
  12. package/Libraries/Animated/nodes/AnimatedObject.js +7 -7
  13. package/Libraries/Animated/nodes/AnimatedProps.js +30 -30
  14. package/Libraries/Animated/nodes/AnimatedStyle.js +17 -17
  15. package/Libraries/Animated/nodes/AnimatedTransform.js +5 -5
  16. package/Libraries/Animated/nodes/AnimatedValue.js +18 -18
  17. package/Libraries/AppState/AppState.js +3 -3
  18. package/Libraries/BatchedBridge/MessageQueue.js +4 -0
  19. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +1 -1
  20. package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +1 -1
  21. package/Libraries/Components/Pressable/Pressable.js +10 -1
  22. package/Libraries/Components/Pressable/Pressable.win32.js +9 -0
  23. package/Libraries/Components/StatusBar/StatusBar.js +2 -2
  24. package/Libraries/Components/Switch/Switch.js +1 -1
  25. package/Libraries/Components/TextInput/TextInput.js +2 -2
  26. package/Libraries/Components/TextInput/TextInput.win32.js +2 -1
  27. package/Libraries/Components/Touchable/TouchableBounce.js +1 -1
  28. package/Libraries/Components/Touchable/TouchableHighlight.js +1 -1
  29. package/Libraries/Components/Touchable/TouchableNativeFeedback.js +1 -1
  30. package/Libraries/Components/Touchable/TouchableOpacity.js +1 -1
  31. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +2 -2
  32. package/Libraries/Components/View/View.js +86 -168
  33. package/Libraries/Core/ReactNativeVersion.js +37 -10
  34. package/Libraries/Core/Timers/queueMicrotask.js +1 -0
  35. package/Libraries/Core/setUpPerformance.js +2 -1
  36. package/Libraries/Interaction/InteractionManager.js +118 -171
  37. package/Libraries/LayoutAnimation/LayoutAnimation.js +2 -0
  38. package/Libraries/LogBox/Data/LogBoxData.js +4 -1
  39. package/Libraries/Modal/Modal.js +1 -1
  40. package/Libraries/NativeComponent/ViewConfig.js +1 -1
  41. package/Libraries/Network/XMLHttpRequest.js +18 -5
  42. package/Libraries/Pressability/Pressability.js +1 -1
  43. package/Libraries/Pressability/Pressability.win32.js +1 -1
  44. package/Libraries/ReactNative/AppRegistryImpl.js +4 -2
  45. package/Libraries/Renderer/implementations/ReactFabric-dev.js +38 -35
  46. package/Libraries/Renderer/implementations/ReactFabric-prod.js +51 -22
  47. package/Libraries/Renderer/implementations/ReactFabric-profiling.js +54 -24
  48. package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js +36 -33
  49. package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js +5 -5
  50. package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.js +5 -5
  51. package/Libraries/Renderer/shims/ReactFabric.js +3 -1
  52. package/Libraries/Renderer/shims/ReactFeatureFlags.js +3 -1
  53. package/Libraries/Renderer/shims/ReactNative.js +3 -1
  54. package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +3 -1
  55. package/Libraries/Renderer/shims/createReactNativeComponentClass.js +3 -1
  56. package/Libraries/Utilities/useMergeRefs.js +1 -1
  57. package/Libraries/promiseRejectionTrackingOptions.js +17 -31
  58. package/flow/HermesInternalType.js +114 -0
  59. package/flow/Stringish.js +14 -0
  60. package/flow/bom.js.flow +554 -0
  61. package/flow/console.js +49 -0
  62. package/flow/cssom.js.flow +575 -0
  63. package/flow/dom.js.flow +6289 -0
  64. package/flow/global.js +88 -0
  65. package/flow/prettier.js.flow +14 -0
  66. package/flow/streams.js.flow +140 -0
  67. package/index.js +5 -2
  68. package/index.win32.js +6 -2
  69. package/jest/mockComponent.js +1 -1
  70. package/jest/setup.js +11 -0
  71. package/overrides.json +11 -11
  72. package/package.json +19 -19
  73. package/src/private/animated/NativeAnimatedHelper.js +8 -1
  74. package/src/private/animated/NativeAnimatedHelper.win32.js +8 -1
  75. package/src/private/animated/createAnimatedPropsHook.js +2 -49
  76. package/src/private/animated/createAnimatedPropsMemoHook.js +2 -48
  77. package/src/private/components/virtualview/VirtualView.js +22 -6
  78. package/src/private/components/virtualview/VirtualViewExperimentalNativeComponent.js +93 -0
  79. package/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +2 -2
  80. package/src/private/featureflags/ReactNativeFeatureFlags.js +71 -51
  81. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +19 -0
  82. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +15 -5
  83. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +1 -1
  84. package/src/private/webapis/dom/oldstylecollections/HTMLCollection.js +2 -2
  85. package/src/private/webapis/dom/oldstylecollections/NodeList.js +2 -2
  86. package/src/private/webapis/geometry/DOMRectList.js +2 -2
  87. package/src/private/webapis/intersectionobserver/internals/IntersectionObserverManager.js +19 -74
  88. package/src/private/webapis/intersectionobserver/specs/NativeIntersectionObserver.js +0 -4
  89. package/src/private/webapis/performance/EventTiming.js +5 -9
  90. package/src/private/webapis/performance/Performance.js +251 -191
  91. package/src/private/webapis/performance/PerformanceObserver.js +8 -29
  92. package/src/private/webapis/performance/UserTiming.js +24 -23
  93. package/src/private/webapis/performance/UserTimingExtensibility.js.flow +38 -0
  94. package/src/private/webapis/performance/internals/Utilities.js +9 -0
  95. package/src/private/webapis/performance/specs/NativePerformance.js +19 -33
  96. package/src/private/webapis/structuredClone/structuredClone.js +1 -1
  97. package/Libraries/Interaction/InteractionManagerStub.js +0 -184
  98. package/Libraries/Interaction/TaskQueue.js +0 -197
  99. package/Libraries/ReactNative/ReactNativeFeatureFlags.js +0 -31
@@ -47,7 +47,7 @@ function flatAnimatedNodes(
47
47
  export default class AnimatedTransform extends AnimatedWithChildren {
48
48
  // NOTE: For potentially historical reasons, some operations only operate on
49
49
  // the first level of AnimatedNode instances. This optimizes that bevavior.
50
- #nodes: $ReadOnlyArray<AnimatedNode>;
50
+ _nodes: $ReadOnlyArray<AnimatedNode>;
51
51
 
52
52
  _transforms: $ReadOnlyArray<Transform<>>;
53
53
 
@@ -74,12 +74,12 @@ export default class AnimatedTransform extends AnimatedWithChildren {
74
74
  config?: ?AnimatedNodeConfig,
75
75
  ) {
76
76
  super(config);
77
- this.#nodes = nodes;
77
+ this._nodes = nodes;
78
78
  this._transforms = transforms;
79
79
  }
80
80
 
81
81
  __makeNative(platformConfig: ?PlatformConfig) {
82
- const nodes = this.#nodes;
82
+ const nodes = this._nodes;
83
83
  for (let ii = 0, length = nodes.length; ii < length; ii++) {
84
84
  const node = nodes[ii];
85
85
  node.__makeNative(platformConfig);
@@ -112,7 +112,7 @@ export default class AnimatedTransform extends AnimatedWithChildren {
112
112
  }
113
113
 
114
114
  __attach(): void {
115
- const nodes = this.#nodes;
115
+ const nodes = this._nodes;
116
116
  for (let ii = 0, length = nodes.length; ii < length; ii++) {
117
117
  const node = nodes[ii];
118
118
  node.__addChild(this);
@@ -121,7 +121,7 @@ export default class AnimatedTransform extends AnimatedWithChildren {
121
121
  }
122
122
 
123
123
  __detach(): void {
124
- const nodes = this.#nodes;
124
+ const nodes = this._nodes;
125
125
  for (let ii = 0, length = nodes.length; ii < length; ii++) {
126
126
  const node = nodes[ii];
127
127
  node.__removeChild(this);
@@ -85,8 +85,8 @@ function _executeAsAnimatedBatch(id: string, operation: () => void) {
85
85
  * See https://reactnative.dev/docs/animatedvalue
86
86
  */
87
87
  export default class AnimatedValue extends AnimatedWithChildren {
88
- #listenerCount: number;
89
- #updateSubscription: ?EventSubscription;
88
+ _listenerCount: number;
89
+ _updateSubscription: ?EventSubscription;
90
90
 
91
91
  _value: number;
92
92
  _startingValue: number;
@@ -100,8 +100,8 @@ export default class AnimatedValue extends AnimatedWithChildren {
100
100
  throw new Error('AnimatedValue: Attempting to set value to undefined');
101
101
  }
102
102
 
103
- this.#listenerCount = 0;
104
- this.#updateSubscription = null;
103
+ this._listenerCount = 0;
104
+ this._updateSubscription = null;
105
105
 
106
106
  this._startingValue = this._value = value;
107
107
  this._offset = 0;
@@ -127,38 +127,38 @@ export default class AnimatedValue extends AnimatedWithChildren {
127
127
 
128
128
  __makeNative(platformConfig: ?PlatformConfig): void {
129
129
  super.__makeNative(platformConfig);
130
- if (this.#listenerCount > 0) {
131
- this.#ensureUpdateSubscriptionExists();
130
+ if (this._listenerCount > 0) {
131
+ this.__ensureUpdateSubscriptionExists();
132
132
  }
133
133
  }
134
134
 
135
135
  addListener(callback: (value: any) => mixed): string {
136
136
  const id = super.addListener(callback);
137
- this.#listenerCount++;
137
+ this._listenerCount++;
138
138
  if (this.__isNative) {
139
- this.#ensureUpdateSubscriptionExists();
139
+ this.__ensureUpdateSubscriptionExists();
140
140
  }
141
141
  return id;
142
142
  }
143
143
 
144
144
  removeListener(id: string): void {
145
145
  super.removeListener(id);
146
- this.#listenerCount--;
147
- if (this.__isNative && this.#listenerCount === 0) {
148
- this.#updateSubscription?.remove();
146
+ this._listenerCount--;
147
+ if (this.__isNative && this._listenerCount === 0) {
148
+ this._updateSubscription?.remove();
149
149
  }
150
150
  }
151
151
 
152
152
  removeAllListeners(): void {
153
153
  super.removeAllListeners();
154
- this.#listenerCount = 0;
154
+ this._listenerCount = 0;
155
155
  if (this.__isNative) {
156
- this.#updateSubscription?.remove();
156
+ this._updateSubscription?.remove();
157
157
  }
158
158
  }
159
159
 
160
- #ensureUpdateSubscriptionExists(): void {
161
- if (this.#updateSubscription != null) {
160
+ __ensureUpdateSubscriptionExists(): void {
161
+ if (this._updateSubscription != null) {
162
162
  return;
163
163
  }
164
164
  const nativeTag = this.__getNativeTag();
@@ -173,13 +173,13 @@ export default class AnimatedValue extends AnimatedWithChildren {
173
173
  },
174
174
  );
175
175
 
176
- this.#updateSubscription = {
176
+ this._updateSubscription = {
177
177
  remove: () => {
178
178
  // Only this function assigns to `this.#updateSubscription`.
179
- if (this.#updateSubscription == null) {
179
+ if (this._updateSubscription == null) {
180
180
  return;
181
181
  }
182
- this.#updateSubscription = null;
182
+ this._updateSubscription = null;
183
183
  subscription.remove();
184
184
  NativeAnimatedAPI.stopListeningToAnimatedNodeValue(nativeTag);
185
185
  },
@@ -120,18 +120,18 @@ class AppStateImpl {
120
120
  }
121
121
  switch (type) {
122
122
  case 'change':
123
- // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
123
+ // $FlowFixMe[invalid-tuple-arity] Flow cannot refine handler based on the event type
124
124
  const changeHandler: AppStateStatus => void = handler;
125
125
  return emitter.addListener('appStateDidChange', appStateData => {
126
126
  changeHandler(appStateData.app_state);
127
127
  });
128
128
  case 'memoryWarning':
129
- // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
129
+ // $FlowFixMe[invalid-tuple-arity] Flow cannot refine handler based on the event type
130
130
  const memoryWarningHandler: () => void = handler;
131
131
  return emitter.addListener('memoryWarning', memoryWarningHandler);
132
132
  case 'blur':
133
133
  case 'focus':
134
- // $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
134
+ // $FlowFixMe[invalid-tuple-arity] Flow cannot refine handler based on the event type
135
135
  const focusOrBlurHandler: () => void = handler;
136
136
  return emitter.addListener('appStateFocusChange', hasFocus => {
137
137
  if (type === 'blur' && !hasFocus) {
@@ -162,6 +162,8 @@ class MessageQueue {
162
162
 
163
163
  getCallableModule(name: string): {...} | null {
164
164
  const getValue = this._lazyCallableModules[name];
165
+ /* $FlowFixMe[constant-condition] Error discovered during Constant
166
+ * Condition roll out. See https://fburl.com/workplace/1v97vimq. */
165
167
  return getValue ? getValue() : null;
166
168
  }
167
169
 
@@ -466,6 +468,8 @@ class MessageQueue {
466
468
  const profileName = debug
467
469
  ? '<callback for ' + module + '.' + method + '>'
468
470
  : cbID;
471
+ /* $FlowFixMe[constant-condition] Error discovered during Constant
472
+ * Condition roll out. See https://fburl.com/workplace/1v97vimq. */
469
473
  if (callback && this.__spy) {
470
474
  this.__spy({type: TO_JS, module: null, method: profileName, args});
471
475
  }
@@ -396,7 +396,7 @@ const AccessibilityInfo = {
396
396
  */
397
397
  addEventListener<K: $Keys<AccessibilityEventDefinitions>>(
398
398
  eventName: K,
399
- // $FlowIssue[incompatible-type] - Flow bug with unions and generics (T128099423)
399
+ // $FlowFixMe[incompatible-type] - Flow bug with unions and generics (T128099423)
400
400
  handler: (...AccessibilityEventDefinitions[K]) => void,
401
401
  ): EventSubscription {
402
402
  const deviceEventName = EventNames.get(eventName);
@@ -420,7 +420,7 @@ const AccessibilityInfo = {
420
420
  */
421
421
  addEventListener<K: $Keys<AccessibilityEventDefinitions>>(
422
422
  eventName: K,
423
- // $FlowIssue[incompatible-type] - Flow bug with unions and generics (T128099423)
423
+ // $FlowFixMe[incompatible-type] - Flow bug with unions and generics (T128099423)
424
424
  handler: (...AccessibilityEventDefinitions[K]) => void,
425
425
  ): EventSubscription {
426
426
  const deviceEventName = EventNames.get(eventName);
@@ -116,6 +116,12 @@ type PressableBaseProps = $ReadOnly<{
116
116
  */
117
117
  onPressOut?: ?(event: GestureResponderEvent) => mixed,
118
118
 
119
+ /**
120
+ * Whether to prevent any other native components from becoming responder
121
+ * while this pressable is responder.
122
+ */
123
+ blockNativeResponder?: ?boolean,
124
+
119
125
  /**
120
126
  * Either view styles or a function that receives a boolean reflecting whether
121
127
  * the component is currently pressed and returns view styles.
@@ -183,6 +189,7 @@ function Pressable({
183
189
  'aria-expanded': ariaExpanded,
184
190
  'aria-label': ariaLabel,
185
191
  'aria-selected': ariaSelected,
192
+ blockNativeResponder,
186
193
  cancelable,
187
194
  children,
188
195
  delayHoverIn,
@@ -236,7 +243,7 @@ function Pressable({
236
243
  };
237
244
 
238
245
  const accessibilityLiveRegion =
239
- ariaLive === 'off' ? 'none' : ariaLive ?? props.accessibilityLiveRegion;
246
+ ariaLive === 'off' ? 'none' : (ariaLive ?? props.accessibilityLiveRegion);
240
247
 
241
248
  const accessibilityLabel = ariaLabel ?? props.accessibilityLabel;
242
249
  const restPropsWithDefaults: React.ElementConfig<typeof View> = {
@@ -294,10 +301,12 @@ function Pressable({
294
301
  onPressOut(event);
295
302
  }
296
303
  },
304
+ blockNativeResponder,
297
305
  }),
298
306
  [
299
307
  android_disableSound,
300
308
  android_rippleConfig,
309
+ blockNativeResponder,
301
310
  cancelable,
302
311
  delayHoverIn,
303
312
  delayHoverOut,
@@ -122,6 +122,12 @@ type PressableBaseProps = $ReadOnly<{
122
122
  */
123
123
  onPressOut?: ?(event: GestureResponderEvent) => mixed,
124
124
 
125
+ /**
126
+ * Whether to prevent any other native components from becoming responder
127
+ * while this pressable is responder.
128
+ */
129
+ blockNativeResponder?: ?boolean,
130
+
125
131
  /**
126
132
  * Called after the element loses focus.
127
133
  */
@@ -231,6 +237,7 @@ function Pressable({
231
237
  'aria-multiselectable': ariaMultiselectable, // Win32
232
238
  'aria-required': ariaRequired, // Win32
233
239
  'aria-selected': ariaSelected,
240
+ blockNativeResponder,
234
241
  cancelable,
235
242
  children,
236
243
  delayHoverIn,
@@ -348,6 +355,7 @@ function Pressable({
348
355
  onPressOut(event);
349
356
  }
350
357
  },
358
+ blockNativeResponder,
351
359
  // [Windows
352
360
  onKeyDown,
353
361
  onKeyUp,
@@ -356,6 +364,7 @@ function Pressable({
356
364
  [
357
365
  android_disableSound,
358
366
  android_rippleConfig,
367
+ blockNativeResponder,
359
368
  cancelable,
360
369
  delayHoverIn,
361
370
  delayHoverOut,
@@ -235,8 +235,8 @@ class StatusBar extends React.Component<StatusBarProps> {
235
235
  static _defaultProps: any = createStackEntry({
236
236
  backgroundColor:
237
237
  Platform.OS === 'android'
238
- ? NativeStatusBarManagerAndroid.getConstants()
239
- .DEFAULT_BACKGROUND_COLOR ?? 'black'
238
+ ? (NativeStatusBarManagerAndroid.getConstants()
239
+ .DEFAULT_BACKGROUND_COLOR ?? 'black')
240
240
  : 'black',
241
241
  barStyle: 'default',
242
242
  translucent: false,
@@ -215,7 +215,7 @@ const Switch: component(
215
215
  native.value != null && native.value !== jsValue;
216
216
  if (
217
217
  shouldUpdateNativeSwitch &&
218
- // $FlowIssue[method-unbinding]
218
+ // $FlowFixMe[method-unbinding]
219
219
  nativeSwitchRef.current?.setNativeProps != null
220
220
  ) {
221
221
  if (Platform.OS === 'android') {
@@ -915,8 +915,8 @@ const TextInput: component(
915
915
  Platform.OS === 'android'
916
916
  ? // $FlowFixMe[invalid-computed-prop]
917
917
  // $FlowFixMe[prop-missing]
918
- autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ??
919
- autoComplete
918
+ (autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ??
919
+ autoComplete)
920
920
  : undefined
921
921
  }
922
922
  textContentType={
@@ -1051,7 +1051,8 @@ const TextInput: component(
1051
1051
  }
1052
1052
  autoComplete={
1053
1053
  Platform.OS === 'android'
1054
- ? // $FlowFixMe
1054
+ ? // $FlowFixMe[invalid-computed-prop]
1055
+ // $FlowFixMe[prop-missing]
1055
1056
  autoCompleteWebToAutoCompleteAndroidMap[autoComplete] ??
1056
1057
  autoComplete
1057
1058
  : undefined
@@ -138,7 +138,7 @@ class TouchableBounce extends React.Component<
138
138
  const accessibilityLiveRegion =
139
139
  this.props['aria-live'] === 'off'
140
140
  ? 'none'
141
- : this.props['aria-live'] ?? this.props.accessibilityLiveRegion;
141
+ : (this.props['aria-live'] ?? this.props.accessibilityLiveRegion);
142
142
  const _accessibilityState = {
143
143
  busy: this.props['aria-busy'] ?? this.props.accessibilityState?.busy,
144
144
  checked:
@@ -328,7 +328,7 @@ class TouchableHighlightImpl extends React.Component<
328
328
  const accessibilityLiveRegion =
329
329
  this.props['aria-live'] === 'off'
330
330
  ? 'none'
331
- : this.props['aria-live'] ?? this.props.accessibilityLiveRegion;
331
+ : (this.props['aria-live'] ?? this.props.accessibilityLiveRegion);
332
332
 
333
333
  const accessibilityLabel =
334
334
  this.props['aria-label'] ?? this.props.accessibilityLabel;
@@ -332,7 +332,7 @@ class TouchableNativeFeedback extends React.Component<
332
332
  const accessibilityLiveRegion =
333
333
  this.props['aria-live'] === 'off'
334
334
  ? 'none'
335
- : this.props['aria-live'] ?? this.props.accessibilityLiveRegion;
335
+ : (this.props['aria-live'] ?? this.props.accessibilityLiveRegion);
336
336
 
337
337
  const accessibilityLabel =
338
338
  this.props['aria-label'] ?? this.props.accessibilityLabel;
@@ -294,7 +294,7 @@ class TouchableOpacity extends React.Component<
294
294
  const accessibilityLiveRegion =
295
295
  this.props['aria-live'] === 'off'
296
296
  ? 'none'
297
- : this.props['aria-live'] ?? this.props.accessibilityLiveRegion;
297
+ : (this.props['aria-live'] ?? this.props.accessibilityLiveRegion);
298
298
 
299
299
  const accessibilityLabel =
300
300
  this.props['aria-label'] ?? this.props.accessibilityLabel;
@@ -189,7 +189,7 @@ export default function TouchableWithoutFeedback(
189
189
  disabled:
190
190
  disabled !== null
191
191
  ? disabled
192
- : ariaDisabled ?? accessibilityState?.disabled,
192
+ : (ariaDisabled ?? accessibilityState?.disabled),
193
193
  hitSlop: hitSlop,
194
194
  delayLongPress: delayLongPress,
195
195
  delayPressIn: delayPressIn,
@@ -272,7 +272,7 @@ export default function TouchableWithoutFeedback(
272
272
  ? 'no-hide-descendants'
273
273
  : props.importantForAccessibility,
274
274
  accessibilityLiveRegion:
275
- ariaLive === 'off' ? 'none' : ariaLive ?? props.accessibilityLiveRegion,
275
+ ariaLive === 'off' ? 'none' : (ariaLive ?? props.accessibilityLiveRegion),
276
276
  nativeID: props.id ?? props.nativeID,
277
277
  };
278
278
 
@@ -10,7 +10,6 @@
10
10
 
11
11
  import type {ViewProps} from './ViewPropTypes';
12
12
 
13
- import * as ReactNativeFeatureFlags from '../../../src/private/featureflags/ReactNativeFeatureFlags';
14
13
  import TextAncestorContext from '../../Text/TextAncestorContext';
15
14
  import ViewNativeComponent from './ViewNativeComponent';
16
15
  import * as React from 'react';
@@ -23,188 +22,103 @@ import {use} from 'react';
23
22
  *
24
23
  * @see https://reactnative.dev/docs/view
25
24
  */
26
- export default component View(
25
+ component View(
27
26
  ref?: React.RefSetter<React.ElementRef<typeof ViewNativeComponent>>,
28
27
  ...props: ViewProps
29
28
  ) {
30
29
  const hasTextAncestor = use(TextAncestorContext);
31
30
 
32
- let actualView;
33
- if (ReactNativeFeatureFlags.reduceDefaultPropsInView()) {
34
- const {
35
- accessibilityState,
36
- accessibilityValue,
37
- 'aria-busy': ariaBusy,
38
- 'aria-checked': ariaChecked,
39
- 'aria-disabled': ariaDisabled,
40
- 'aria-expanded': ariaExpanded,
41
- 'aria-hidden': ariaHidden,
42
- 'aria-label': ariaLabel,
43
- 'aria-labelledby': ariaLabelledBy,
44
- 'aria-live': ariaLive,
45
- 'aria-selected': ariaSelected,
46
- 'aria-valuemax': ariaValueMax,
47
- 'aria-valuemin': ariaValueMin,
48
- 'aria-valuenow': ariaValueNow,
49
- 'aria-valuetext': ariaValueText,
50
- id,
51
- tabIndex,
52
- ...otherProps
53
- } = props;
54
-
55
- // Since we destructured props, we can now treat it as mutable
56
- const processedProps = otherProps as {...ViewProps};
57
-
58
- const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
59
- if (parsedAriaLabelledBy !== undefined) {
60
- processedProps.accessibilityLabelledBy = parsedAriaLabelledBy;
61
- }
31
+ const {
32
+ accessibilityState,
33
+ accessibilityValue,
34
+ 'aria-busy': ariaBusy,
35
+ 'aria-checked': ariaChecked,
36
+ 'aria-disabled': ariaDisabled,
37
+ 'aria-expanded': ariaExpanded,
38
+ 'aria-hidden': ariaHidden,
39
+ 'aria-label': ariaLabel,
40
+ 'aria-labelledby': ariaLabelledBy,
41
+ 'aria-live': ariaLive,
42
+ 'aria-selected': ariaSelected,
43
+ 'aria-valuemax': ariaValueMax,
44
+ 'aria-valuemin': ariaValueMin,
45
+ 'aria-valuenow': ariaValueNow,
46
+ 'aria-valuetext': ariaValueText,
47
+ id,
48
+ tabIndex,
49
+ ...otherProps
50
+ } = props;
51
+
52
+ // Since we destructured props, we can now treat it as mutable
53
+ const processedProps = otherProps as {...ViewProps};
54
+
55
+ const parsedAriaLabelledBy = ariaLabelledBy?.split(/\s*,\s*/g);
56
+ if (parsedAriaLabelledBy !== undefined) {
57
+ processedProps.accessibilityLabelledBy = parsedAriaLabelledBy;
58
+ }
62
59
 
63
- if (ariaLabel !== undefined) {
64
- processedProps.accessibilityLabel = ariaLabel;
65
- }
60
+ if (ariaLabel !== undefined) {
61
+ processedProps.accessibilityLabel = ariaLabel;
62
+ }
66
63
 
67
- if (ariaLive !== undefined) {
68
- processedProps.accessibilityLiveRegion =
69
- ariaLive === 'off' ? 'none' : ariaLive;
70
- }
64
+ if (ariaLive !== undefined) {
65
+ processedProps.accessibilityLiveRegion =
66
+ ariaLive === 'off' ? 'none' : ariaLive;
67
+ }
71
68
 
72
- if (ariaHidden !== undefined) {
73
- processedProps.accessibilityElementsHidden = ariaHidden;
74
- if (ariaHidden === true) {
75
- processedProps.importantForAccessibility = 'no-hide-descendants';
76
- }
69
+ if (ariaHidden !== undefined) {
70
+ processedProps.accessibilityElementsHidden = ariaHidden;
71
+ if (ariaHidden === true) {
72
+ processedProps.importantForAccessibility = 'no-hide-descendants';
77
73
  }
74
+ }
78
75
 
79
- if (id !== undefined) {
80
- processedProps.nativeID = id;
81
- }
76
+ if (id !== undefined) {
77
+ processedProps.nativeID = id;
78
+ }
82
79
 
83
- if (tabIndex !== undefined) {
84
- processedProps.focusable = !tabIndex;
85
- }
80
+ if (tabIndex !== undefined) {
81
+ processedProps.focusable = !tabIndex;
82
+ }
86
83
 
87
- if (
88
- accessibilityState != null ||
89
- ariaBusy != null ||
90
- ariaChecked != null ||
91
- ariaDisabled != null ||
92
- ariaExpanded != null ||
93
- ariaSelected != null
94
- ) {
95
- processedProps.accessibilityState = {
96
- busy: ariaBusy ?? accessibilityState?.busy,
97
- checked: ariaChecked ?? accessibilityState?.checked,
98
- disabled: ariaDisabled ?? accessibilityState?.disabled,
99
- expanded: ariaExpanded ?? accessibilityState?.expanded,
100
- selected: ariaSelected ?? accessibilityState?.selected,
101
- };
102
- }
84
+ if (
85
+ accessibilityState != null ||
86
+ ariaBusy != null ||
87
+ ariaChecked != null ||
88
+ ariaDisabled != null ||
89
+ ariaExpanded != null ||
90
+ ariaSelected != null
91
+ ) {
92
+ processedProps.accessibilityState = {
93
+ busy: ariaBusy ?? accessibilityState?.busy,
94
+ checked: ariaChecked ?? accessibilityState?.checked,
95
+ disabled: ariaDisabled ?? accessibilityState?.disabled,
96
+ expanded: ariaExpanded ?? accessibilityState?.expanded,
97
+ selected: ariaSelected ?? accessibilityState?.selected,
98
+ };
99
+ }
103
100
 
104
- if (
105
- accessibilityValue != null ||
106
- ariaValueMax != null ||
107
- ariaValueMin != null ||
108
- ariaValueNow != null ||
109
- ariaValueText != null
110
- ) {
111
- processedProps.accessibilityValue = {
112
- max: ariaValueMax ?? accessibilityValue?.max,
113
- min: ariaValueMin ?? accessibilityValue?.min,
114
- now: ariaValueNow ?? accessibilityValue?.now,
115
- text: ariaValueText ?? accessibilityValue?.text,
116
- };
117
- }
101
+ if (
102
+ accessibilityValue != null ||
103
+ ariaValueMax != null ||
104
+ ariaValueMin != null ||
105
+ ariaValueNow != null ||
106
+ ariaValueText != null
107
+ ) {
108
+ processedProps.accessibilityValue = {
109
+ max: ariaValueMax ?? accessibilityValue?.max,
110
+ min: ariaValueMin ?? accessibilityValue?.min,
111
+ now: ariaValueNow ?? accessibilityValue?.now,
112
+ text: ariaValueText ?? accessibilityValue?.text,
113
+ };
114
+ }
118
115
 
119
- actualView =
120
- ref == null ? (
121
- <ViewNativeComponent {...processedProps} />
122
- ) : (
123
- <ViewNativeComponent {...processedProps} ref={ref} />
124
- );
125
- } else {
126
- const {
127
- accessibilityElementsHidden,
128
- accessibilityLabel,
129
- accessibilityLabelledBy,
130
- accessibilityLiveRegion,
131
- accessibilityState,
132
- accessibilityValue,
133
- 'aria-busy': ariaBusy,
134
- 'aria-checked': ariaChecked,
135
- 'aria-disabled': ariaDisabled,
136
- 'aria-expanded': ariaExpanded,
137
- 'aria-hidden': ariaHidden,
138
- 'aria-label': ariaLabel,
139
- 'aria-labelledby': ariaLabelledBy,
140
- 'aria-live': ariaLive,
141
- 'aria-selected': ariaSelected,
142
- 'aria-valuemax': ariaValueMax,
143
- 'aria-valuemin': ariaValueMin,
144
- 'aria-valuenow': ariaValueNow,
145
- 'aria-valuetext': ariaValueText,
146
- focusable,
147
- id,
148
- importantForAccessibility,
149
- nativeID,
150
- tabIndex,
151
- ...otherProps
152
- } = props;
153
- const _accessibilityLabelledBy =
154
- ariaLabelledBy?.split(/\s*,\s*/g) ?? accessibilityLabelledBy;
155
-
156
- const _accessibilityState =
157
- accessibilityState != null ||
158
- ariaBusy != null ||
159
- ariaChecked != null ||
160
- ariaDisabled != null ||
161
- ariaExpanded != null ||
162
- ariaSelected != null
163
- ? {
164
- busy: ariaBusy ?? accessibilityState?.busy,
165
- checked: ariaChecked ?? accessibilityState?.checked,
166
- disabled: ariaDisabled ?? accessibilityState?.disabled,
167
- expanded: ariaExpanded ?? accessibilityState?.expanded,
168
- selected: ariaSelected ?? accessibilityState?.selected,
169
- }
170
- : undefined;
171
-
172
- const _accessibilityValue =
173
- accessibilityValue != null ||
174
- ariaValueMax != null ||
175
- ariaValueMin != null ||
176
- ariaValueNow != null ||
177
- ariaValueText != null
178
- ? {
179
- max: ariaValueMax ?? accessibilityValue?.max,
180
- min: ariaValueMin ?? accessibilityValue?.min,
181
- now: ariaValueNow ?? accessibilityValue?.now,
182
- text: ariaValueText ?? accessibilityValue?.text,
183
- }
184
- : undefined;
185
-
186
- actualView = (
187
- <ViewNativeComponent
188
- {...otherProps}
189
- accessibilityLiveRegion={
190
- ariaLive === 'off' ? 'none' : ariaLive ?? accessibilityLiveRegion
191
- }
192
- accessibilityLabel={ariaLabel ?? accessibilityLabel}
193
- focusable={tabIndex !== undefined ? !tabIndex : focusable}
194
- accessibilityState={_accessibilityState}
195
- accessibilityElementsHidden={ariaHidden ?? accessibilityElementsHidden}
196
- accessibilityLabelledBy={_accessibilityLabelledBy}
197
- accessibilityValue={_accessibilityValue}
198
- importantForAccessibility={
199
- ariaHidden === true
200
- ? 'no-hide-descendants'
201
- : importantForAccessibility
202
- }
203
- nativeID={id ?? nativeID}
204
- ref={ref}
205
- />
116
+ const actualView =
117
+ ref == null ? (
118
+ <ViewNativeComponent {...processedProps} />
119
+ ) : (
120
+ <ViewNativeComponent {...processedProps} ref={ref} />
206
121
  );
207
- }
208
122
 
209
123
  if (hasTextAncestor) {
210
124
  return (
@@ -213,3 +127,7 @@ export default component View(
213
127
  }
214
128
  return actualView;
215
129
  }
130
+
131
+ View.displayName = 'View';
132
+
133
+ export default View;