react-native-windows 0.0.0-canary.813 → 0.0.0-canary.815

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 (83) hide show
  1. package/.flowconfig +1 -1
  2. package/Libraries/Components/Button.js +10 -5
  3. package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +1 -0
  4. package/Libraries/Components/ScrollView/ScrollView.js +49 -0
  5. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -0
  6. package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +2 -0
  7. package/Libraries/Components/TextInput/TextInput.windows.js +2 -2
  8. package/Libraries/Components/Touchable/TouchableOpacity.d.ts +0 -17
  9. package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +8 -0
  10. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +114 -111
  11. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +126 -110
  12. package/Libraries/Components/View/View.windows.js +3 -0
  13. package/Libraries/Components/View/ViewPropTypes.d.ts +0 -49
  14. package/Libraries/Core/ExceptionsManager.js +2 -2
  15. package/Libraries/Core/ReactNativeVersion.js +1 -1
  16. package/Libraries/ReactNative/AppContainer-dev.js +21 -2
  17. package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -2
  18. package/Libraries/Utilities/NativePlatformConstantsWin.js +2 -2
  19. package/Libraries/Utilities/ReactNativeTestTools.js +5 -0
  20. package/Microsoft.ReactNative/CompositionComponentView.idl +17 -7
  21. package/Microsoft.ReactNative/CompositionRootView.idl +1 -0
  22. package/Microsoft.ReactNative/CompositionUIService.idl +4 -0
  23. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +2 -1
  24. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +106 -19
  25. package/Microsoft.ReactNative/Fabric/AbiViewProps.h +45 -13
  26. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +28 -64
  27. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +7 -11
  28. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +4 -0
  29. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +2 -0
  30. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +4 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +12 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.h +4 -0
  33. package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +6 -0
  34. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +27 -16
  35. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +13 -4
  36. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -0
  37. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +49 -95
  38. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +11 -15
  39. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +16 -31
  40. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +5 -8
  41. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +24 -81
  42. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -13
  43. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +1 -0
  44. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +53 -68
  45. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +5 -7
  46. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +38 -84
  47. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +6 -10
  48. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +52 -104
  49. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -13
  50. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -0
  51. package/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp +2 -2
  52. package/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h +3 -3
  53. package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +2 -3
  54. package/Microsoft.ReactNative/ViewProps.idl +37 -3
  55. package/Microsoft.ReactNative/packages.lock.json +68 -40
  56. package/Microsoft.ReactNative.Cxx/JSValueComposition.h +4 -0
  57. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  58. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +36 -1
  59. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +1 -1
  60. package/Shared/HermesSamplingProfiler.cpp +1 -2
  61. package/Shared/OInstance.cpp +1 -2
  62. package/Shared/Shared.vcxitems +3 -0
  63. package/Shared/Shared.vcxitems.filters +3 -0
  64. package/codegen/NativeDOMSpec.g.h +43 -25
  65. package/codegen/NativePlatformConstantsWindowsSpec.g.h +81 -0
  66. package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +39 -15
  67. package/codegen/rnwcoreJSI-generated.cpp +67 -22
  68. package/codegen/rnwcoreJSI.h +327 -2521
  69. package/package.json +21 -20
  70. package/src/private/featureflags/ReactNativeFeatureFlags.js +21 -1
  71. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +5 -1
  72. package/src/private/webapis/dom/nodes/ReactNativeElement.js +3 -7
  73. package/src/private/webapis/dom/nodes/ReadOnlyElement.js +11 -30
  74. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +0 -7
  75. package/src/private/webapis/dom/nodes/specs/NativeDOM.js +114 -27
  76. package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +59 -22
  77. package/src/private/webapis/performance/PerformanceObserver.js +2 -0
  78. package/src/private/webapis/performance/RawPerformanceEntry.js +0 -5
  79. package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +2 -3
  80. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/utils/jsi-utils.cpp +0 -39
  81. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/utils/jsi-utils.h +0 -31
  82. package/codegen/NativePlatformConstantsWinSpec.g.h +0 -81
  83. /package/src/private/specs/modules/{NativePlatformConstantsWin.js → NativePlatformConstantsWindows.js} +0 -0
package/.flowconfig CHANGED
@@ -146,4 +146,4 @@ untyped-import
146
146
  untyped-type-import
147
147
 
148
148
  [version]
149
- ^0.231.0
149
+ ^0.232.0
@@ -280,7 +280,13 @@ type ButtonProps = $ReadOnly<{|
280
280
  ```
281
281
  */
282
282
 
283
- const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
283
+ const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
284
+ Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
285
+
286
+ const Button: React.AbstractComponent<
287
+ ButtonProps,
288
+ React.ElementRef<typeof Touchable>,
289
+ > = React.forwardRef((props: ButtonProps, ref) => {
284
290
  const {
285
291
  accessibilityLabel,
286
292
  accessibilityState,
@@ -345,8 +351,6 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
345
351
  );
346
352
  const formattedTitle =
347
353
  Platform.OS === 'android' ? title.toUpperCase() : title;
348
- const Touchable =
349
- Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
350
354
 
351
355
  // If `no` is specified for `importantForAccessibility`, it will be changed to `no-hide-descendants` because the text inside should not be focused.
352
356
  const _importantForAccessibility =
@@ -374,7 +378,8 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
374
378
  testID={testID}
375
379
  disabled={disabled}
376
380
  onPress={onPress}
377
- touchSoundDisabled={touchSoundDisabled}>
381
+ touchSoundDisabled={touchSoundDisabled}
382
+ ref={ref}>
378
383
  <View style={buttonStyles}>
379
384
  <Text style={textStyles} disabled={disabled}>
380
385
  {formattedTitle}
@@ -382,7 +387,7 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
382
387
  </View>
383
388
  </Touchable>
384
389
  );
385
- };
390
+ });
386
391
 
387
392
  Button.displayName = 'Button';
388
393
 
@@ -29,6 +29,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
29
29
  overScrollMode: true,
30
30
  pagingEnabled: true,
31
31
  persistentScrollbar: true,
32
+ horizontal: true,
32
33
  scrollEnabled: true,
33
34
  scrollPerfTag: true,
34
35
  sendMomentumEvents: true,
@@ -33,6 +33,7 @@ import StyleSheet from '../../StyleSheet/StyleSheet';
33
33
  import Dimensions from '../../Utilities/Dimensions';
34
34
  import dismissKeyboard from '../../Utilities/dismissKeyboard';
35
35
  import Platform from '../../Utilities/Platform';
36
+ import EventEmitter from '../../vendor/emitter/EventEmitter';
36
37
  import Keyboard from '../Keyboard/Keyboard';
37
38
  import TextInputState from '../TextInput/TextInputState';
38
39
  import View from '../View/View';
@@ -676,6 +677,9 @@ export type Props = $ReadOnly<{|
676
677
 
677
678
  type State = {|
678
679
  layoutHeight: ?number,
680
+ onScrollEmitter: ?EventEmitter<{
681
+ scroll: [{x: number, y: number}],
682
+ }>,
679
683
  |};
680
684
 
681
685
  const IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16;
@@ -761,6 +765,7 @@ class ScrollView extends React.Component<Props, State> {
761
765
 
762
766
  state: State = {
763
767
  layoutHeight: null,
768
+ onScrollEmitter: null,
764
769
  };
765
770
 
766
771
  componentDidMount() {
@@ -829,6 +834,8 @@ class ScrollView extends React.Component<Props, State> {
829
834
  if (this._scrollAnimatedValueAttachment) {
830
835
  this._scrollAnimatedValueAttachment.detach();
831
836
  }
837
+
838
+ this.state.onScrollEmitter?.removeAllListeners();
832
839
  }
833
840
 
834
841
  /**
@@ -948,6 +955,40 @@ class ScrollView extends React.Component<Props, State> {
948
955
  Commands.flashScrollIndicators(this._scrollView.nativeInstance);
949
956
  };
950
957
 
958
+ _subscribeToOnScroll: (
959
+ callback: ({x: number, y: number}) => void,
960
+ ) => EventSubscription = callback => {
961
+ // An undefined value means the listener has not been added, yet.
962
+ // A null value means the listener has been removed.
963
+ let subscription: ?EventSubscription;
964
+
965
+ this.setState(
966
+ ({onScrollEmitter}) => ({
967
+ onScrollEmitter: onScrollEmitter ?? new EventEmitter(),
968
+ }),
969
+ () => {
970
+ // If `subscription` is null, that means it was removed before we got
971
+ // here so do nothing.
972
+ if (subscription !== null) {
973
+ subscription = nullthrows(this.state.onScrollEmitter).addListener(
974
+ 'scroll',
975
+ callback,
976
+ );
977
+ }
978
+ },
979
+ );
980
+
981
+ return {
982
+ remove() {
983
+ // If `subscription` was created before this invocation, remove it.
984
+ subscription?.remove();
985
+ // Record this invocation by setting `subscription` to null, in case it
986
+ // ends up being created after this invocation.
987
+ subscription = null;
988
+ },
989
+ };
990
+ };
991
+
951
992
  /**
952
993
  * This method should be used as the callback to onFocus in a TextInputs'
953
994
  * parent view. Note that any module using this mixin needs to return
@@ -1154,6 +1195,11 @@ class ScrollView extends React.Component<Props, State> {
1154
1195
  _handleScroll = (e: ScrollEvent) => {
1155
1196
  this._observedScrollSinceBecomingResponder = true;
1156
1197
  this.props.onScroll && this.props.onScroll(e);
1198
+
1199
+ this.state.onScrollEmitter?.emit('scroll', {
1200
+ x: e.nativeEvent.contentOffset.x,
1201
+ y: e.nativeEvent.contentOffset.y,
1202
+ });
1157
1203
  };
1158
1204
 
1159
1205
  _handleLayout = (e: LayoutEvent) => {
@@ -1202,6 +1248,8 @@ class ScrollView extends React.Component<Props, State> {
1202
1248
  scrollToEnd: this.scrollToEnd,
1203
1249
  flashScrollIndicators: this.flashScrollIndicators,
1204
1250
  scrollResponderZoomTo: this.scrollResponderZoomTo,
1251
+ // TODO: Replace unstable_subscribeToOnScroll once scrollView.addEventListener('scroll', (e: ScrollEvent) => {}, {passive: false});
1252
+ unstable_subscribeToOnScroll: this._subscribeToOnScroll,
1205
1253
  scrollResponderScrollNativeHandleToKeyboard:
1206
1254
  this.scrollResponderScrollNativeHandleToKeyboard,
1207
1255
  },
@@ -1778,6 +1826,7 @@ class ScrollView extends React.Component<Props, State> {
1778
1826
  onScroll: this._handleScroll,
1779
1827
  endDraggingSensitivityMultiplier:
1780
1828
  experimental_endDraggingSensitivityMultiplier,
1829
+ enableSyncOnScroll: this.state.onScrollEmitter ? true : undefined,
1781
1830
  scrollEventThrottle: hasStickyHeaders
1782
1831
  ? 1
1783
1832
  : this.props.scrollEventThrottle,
@@ -72,6 +72,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
72
72
  process: require('../../StyleSheet/processColor').default,
73
73
  },
74
74
  persistentScrollbar: true,
75
+ horizontal: true,
75
76
  endFillColor: {
76
77
  process: require('../../StyleSheet/processColor').default,
77
78
  },
@@ -133,6 +134,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
133
134
  contentInsetAdjustmentBehavior: true,
134
135
  decelerationRate: true,
135
136
  endDraggingSensitivityMultiplier: true,
137
+ enableSyncOnScroll: true, // iOS-Fabric only.
136
138
  directionalLockEnabled: true,
137
139
  disableIntervalMomentum: true,
138
140
  indicatorStyle: true,
@@ -72,6 +72,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
72
72
  process: require('../../StyleSheet/processColor').default,
73
73
  },
74
74
  persistentScrollbar: true,
75
+ horizontal: true,
75
76
  endFillColor: {
76
77
  process: require('../../StyleSheet/processColor').default,
77
78
  },
@@ -133,6 +134,7 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig =
133
134
  contentInsetAdjustmentBehavior: true,
134
135
  decelerationRate: true,
135
136
  endDraggingSensitivityMultiplier: true,
137
+ enableSyncOnScroll: true, // iOS-Fabric only.
136
138
  directionalLockEnabled: true,
137
139
  disableIntervalMomentum: true,
138
140
  indicatorStyle: true,
@@ -1310,9 +1310,9 @@ function InternalTextInput(props: Props): React.Node {
1310
1310
  );
1311
1311
  }
1312
1312
  },
1313
- // TODO: Fix this returning true on null === null, when no input is focused
1314
1313
  isFocused(): boolean {
1315
- return TextInputState.currentlyFocusedInput() === inputRef.current;
1314
+ const currentlyFocusedInput = TextInputState.currentlyFocusedInput();
1315
+ return currentlyFocusedInput !== null && currentlyFocusedInput === inputRef.current;
1316
1316
  },
1317
1317
  getNativeRef(): ?React.ElementRef<HostComponent<mixed>> {
1318
1318
  return inputRef.current;
@@ -11,7 +11,6 @@ import type * as React from 'react';
11
11
  import {Constructor} from '../../../types/private/Utilities';
12
12
  import {TimerMixin} from '../../../types/private/TimerMixin';
13
13
  import {NativeMethods} from '../../../types/public/ReactNativeTypes';
14
- import {TVParallaxProperties} from '../View/ViewPropTypes';
15
14
  import {TouchableMixin} from './Touchable';
16
15
  import {TouchableWithoutFeedbackProps} from './TouchableWithoutFeedback';
17
16
 
@@ -70,22 +69,6 @@ export interface TouchableOpacityProps
70
69
  * Defaults to 0.2
71
70
  */
72
71
  activeOpacity?: number | undefined;
73
-
74
- /**
75
- * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
76
- *
77
- * enabled: If true, parallax effects are enabled. Defaults to true.
78
- * shiftDistanceX: Defaults to 2.0.
79
- * shiftDistanceY: Defaults to 2.0.
80
- * tiltAngle: Defaults to 0.05.
81
- * magnification: Defaults to 1.0.
82
- * pressMagnification: Defaults to 1.0.
83
- * pressDuration: Defaults to 0.3.
84
- * pressDelay: Defaults to 0.0.
85
- *
86
- * @platform android
87
- */
88
- tvParallaxProperties?: TVParallaxProperties | undefined;
89
72
  }
90
73
 
91
74
  /**
@@ -42,6 +42,8 @@ export interface TouchableWithoutFeedbackProps
42
42
  AccessibilityProps {
43
43
  children?: React.ReactNode | undefined;
44
44
 
45
+ rejectResponderTermination?: boolean | undefined;
46
+
45
47
  /**
46
48
  * Delay in ms, from onPressIn, before onLongPress is called.
47
49
  */
@@ -62,6 +64,12 @@ export interface TouchableWithoutFeedbackProps
62
64
  */
63
65
  disabled?: boolean | undefined;
64
66
 
67
+ /**
68
+ * Whether this View should be focusable with a non-touch input device,
69
+ * eg. receive focus with a hardware keyboard / TV remote.
70
+ */
71
+ focusable?: boolean | undefined;
72
+
65
73
  /**
66
74
  * This defines how far your touch can start away from the button.
67
75
  * This is added to pressRetentionOffset when moving off of the button.
@@ -24,11 +24,10 @@ import type {
24
24
  } from '../../Types/CoreEventTypes';
25
25
 
26
26
  import View from '../../Components/View/View';
27
- import Pressability, {
28
- type PressabilityConfig,
29
- } from '../../Pressability/Pressability';
30
27
  import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
28
+ import usePressability from '../../Pressability/usePressability';
31
29
  import * as React from 'react';
30
+ import {useMemo} from 'react';
32
31
 
33
32
  type Props = $ReadOnly<{|
34
33
  accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
@@ -85,10 +84,6 @@ type Props = $ReadOnly<{|
85
84
  touchSoundDisabled?: ?boolean,
86
85
  |}>;
87
86
 
88
- type State = $ReadOnly<{|
89
- pressability: Pressability,
90
- |}>;
91
-
92
87
  const PASSTHROUGH_PROPS = [
93
88
  'accessibilityActions',
94
89
  'accessibilityElementsHidden',
@@ -115,115 +110,123 @@ const PASSTHROUGH_PROPS = [
115
110
  'testID',
116
111
  ];
117
112
 
118
- class TouchableWithoutFeedback extends React.Component<Props, State> {
119
- state: State = {
120
- pressability: new Pressability(createPressabilityConfig(this.props)),
121
- };
122
-
123
- render(): React.Node {
124
- const element = React.Children.only<$FlowFixMe>(this.props.children);
125
- const children: Array<React.Node> = [element.props.children];
126
- const ariaLive = this.props['aria-live'];
127
-
128
- if (__DEV__) {
129
- if (element.type === View) {
130
- children.push(
131
- <PressabilityDebugView color="red" hitSlop={this.props.hitSlop} />,
132
- );
133
- }
134
- }
135
-
136
- let _accessibilityState = {
137
- busy: this.props['aria-busy'] ?? this.props.accessibilityState?.busy,
138
- checked:
139
- this.props['aria-checked'] ?? this.props.accessibilityState?.checked,
113
+ module.exports = function TouchableWithoutFeedback(props: Props): React.Node {
114
+ const {
115
+ disabled,
116
+ rejectResponderTermination,
117
+ 'aria-disabled': ariaDisabled,
118
+ accessibilityState,
119
+ hitSlop,
120
+ delayLongPress,
121
+ delayPressIn,
122
+ delayPressOut,
123
+ pressRetentionOffset,
124
+ touchSoundDisabled,
125
+ onBlur: _onBlur,
126
+ onFocus: _onFocus,
127
+ onLongPress,
128
+ onPress,
129
+ onPressIn,
130
+ onPressOut,
131
+ } = props;
132
+
133
+ const pressabilityConfig = useMemo(
134
+ () => ({
135
+ cancelable: !rejectResponderTermination,
140
136
  disabled:
141
- this.props['aria-disabled'] ?? this.props.accessibilityState?.disabled,
142
- expanded:
143
- this.props['aria-expanded'] ?? this.props.accessibilityState?.expanded,
144
- selected:
145
- this.props['aria-selected'] ?? this.props.accessibilityState?.selected,
146
- };
147
-
148
- // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
149
- // adopting `Pressability`, so preserve that behavior.
150
- const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
151
- this.state.pressability.getEventHandlers();
152
-
153
- const elementProps: {[string]: mixed, ...} = {
154
- ...eventHandlersWithoutBlurAndFocus,
155
- accessible: this.props.accessible !== false,
156
- accessibilityState:
157
- this.props.disabled != null
158
- ? {
159
- ..._accessibilityState,
160
- disabled: this.props.disabled,
161
- }
162
- : _accessibilityState,
163
- focusable:
164
- this.props.focusable !== false && this.props.onPress !== undefined,
165
-
166
- accessibilityElementsHidden:
167
- this.props['aria-hidden'] ?? this.props.accessibilityElementsHidden,
168
- importantForAccessibility:
169
- this.props['aria-hidden'] === true
170
- ? 'no-hide-descendants'
171
- : this.props.importantForAccessibility,
172
- accessibilityLiveRegion:
173
- ariaLive === 'off'
174
- ? 'none'
175
- : ariaLive ?? this.props.accessibilityLiveRegion,
176
- nativeID: this.props.id ?? this.props.nativeID,
177
- };
178
- for (const prop of PASSTHROUGH_PROPS) {
179
- if (this.props[prop] !== undefined) {
180
- elementProps[prop] = this.props[prop];
181
- }
137
+ disabled !== null
138
+ ? disabled
139
+ : ariaDisabled ?? accessibilityState?.disabled,
140
+ hitSlop: hitSlop,
141
+ delayLongPress: delayLongPress,
142
+ delayPressIn: delayPressIn,
143
+ delayPressOut: delayPressOut,
144
+ minPressDuration: 0,
145
+ pressRectOffset: pressRetentionOffset,
146
+ android_disableSound: touchSoundDisabled,
147
+ onBlur: _onBlur,
148
+ onFocus: _onFocus,
149
+ onLongPress: onLongPress,
150
+ onPress: onPress,
151
+ onPressIn: onPressIn,
152
+ onPressOut: onPressOut,
153
+ }),
154
+ [
155
+ rejectResponderTermination,
156
+ disabled,
157
+ ariaDisabled,
158
+ accessibilityState?.disabled,
159
+ hitSlop,
160
+ delayLongPress,
161
+ delayPressIn,
162
+ delayPressOut,
163
+ pressRetentionOffset,
164
+ touchSoundDisabled,
165
+ _onBlur,
166
+ _onFocus,
167
+ onLongPress,
168
+ onPress,
169
+ onPressIn,
170
+ onPressOut,
171
+ ],
172
+ );
173
+
174
+ const eventHandlers = usePressability(pressabilityConfig);
175
+
176
+ const element = React.Children.only<$FlowFixMe>(props.children);
177
+ const children: Array<React.Node> = [element.props.children];
178
+ const ariaLive = props['aria-live'];
179
+
180
+ if (__DEV__) {
181
+ if (element.type === View) {
182
+ children.push(
183
+ <PressabilityDebugView color="red" hitSlop={props.hitSlop} />,
184
+ );
182
185
  }
183
-
184
- // $FlowFixMe[incompatible-call]
185
- return React.cloneElement(element, elementProps, ...children);
186
- }
187
-
188
- componentDidUpdate(): void {
189
- this.state.pressability.configure(createPressabilityConfig(this.props));
190
- }
191
-
192
- componentDidMount(): mixed {
193
- this.state.pressability.configure(createPressabilityConfig(this.props));
194
186
  }
195
187
 
196
- componentWillUnmount(): void {
197
- this.state.pressability.reset();
198
- }
199
- }
188
+ let _accessibilityState = {
189
+ busy: props['aria-busy'] ?? props.accessibilityState?.busy,
190
+ checked: props['aria-checked'] ?? props.accessibilityState?.checked,
191
+ disabled: props['aria-disabled'] ?? props.accessibilityState?.disabled,
192
+ expanded: props['aria-expanded'] ?? props.accessibilityState?.expanded,
193
+ selected: props['aria-selected'] ?? props.accessibilityState?.selected,
194
+ };
200
195
 
201
- function createPressabilityConfig({
202
- 'aria-disabled': ariaDisabled,
203
- ...props
204
- }: Props): PressabilityConfig {
205
- const accessibilityStateDisabled =
206
- ariaDisabled ?? props.accessibilityState?.disabled;
207
- return {
208
- cancelable: !props.rejectResponderTermination,
209
- disabled:
210
- props.disabled !== null ? props.disabled : accessibilityStateDisabled,
211
- hitSlop: props.hitSlop,
212
- delayLongPress: props.delayLongPress,
213
- delayPressIn: props.delayPressIn,
214
- delayPressOut: props.delayPressOut,
215
- minPressDuration: 0,
216
- pressRectOffset: props.pressRetentionOffset,
217
- android_disableSound: props.touchSoundDisabled,
218
- onBlur: props.onBlur,
219
- onFocus: props.onFocus,
220
- onLongPress: props.onLongPress,
221
- onPress: props.onPress,
222
- onPressIn: props.onPressIn,
223
- onPressOut: props.onPressOut,
196
+ // BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
197
+ // adopting `Pressability`, so preserve that behavior.
198
+ const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
199
+ eventHandlers || {};
200
+
201
+ const elementProps: {[string]: mixed, ...} = {
202
+ ...eventHandlersWithoutBlurAndFocus,
203
+ accessible: props.accessible !== false,
204
+ accessibilityState:
205
+ props.disabled != null
206
+ ? {
207
+ ..._accessibilityState,
208
+ disabled: props.disabled,
209
+ }
210
+ : _accessibilityState,
211
+ focusable: props.focusable !== false && props.onPress !== undefined,
212
+
213
+ accessibilityElementsHidden:
214
+ props['aria-hidden'] ?? props.accessibilityElementsHidden,
215
+ importantForAccessibility:
216
+ props['aria-hidden'] === true
217
+ ? 'no-hide-descendants'
218
+ : props.importantForAccessibility,
219
+ accessibilityLiveRegion:
220
+ ariaLive === 'off' ? 'none' : ariaLive ?? props.accessibilityLiveRegion,
221
+ nativeID: props.id ?? props.nativeID,
224
222
  };
225
- }
226
223
 
227
- TouchableWithoutFeedback.displayName = 'TouchableWithoutFeedback';
224
+ for (const prop of PASSTHROUGH_PROPS) {
225
+ if (props[prop] !== undefined) {
226
+ elementProps[prop] = props[prop];
227
+ }
228
+ }
228
229
 
229
- module.exports = TouchableWithoutFeedback;
230
+ // $FlowFixMe[incompatible-call]
231
+ return React.cloneElement(element, elementProps, ...children);
232
+ };