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.
- package/.flowconfig +1 -1
- package/Libraries/Components/Button.js +10 -5
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +1 -0
- package/Libraries/Components/ScrollView/ScrollView.js +49 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.js +2 -0
- package/Libraries/Components/ScrollView/ScrollViewNativeComponent.windows.js +2 -0
- package/Libraries/Components/TextInput/TextInput.windows.js +2 -2
- package/Libraries/Components/Touchable/TouchableOpacity.d.ts +0 -17
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.d.ts +8 -0
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +114 -111
- package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +126 -110
- package/Libraries/Components/View/View.windows.js +3 -0
- package/Libraries/Components/View/ViewPropTypes.d.ts +0 -49
- package/Libraries/Core/ExceptionsManager.js +2 -2
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/ReactNative/AppContainer-dev.js +21 -2
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -2
- package/Libraries/Utilities/NativePlatformConstantsWin.js +2 -2
- package/Libraries/Utilities/ReactNativeTestTools.js +5 -0
- package/Microsoft.ReactNative/CompositionComponentView.idl +17 -7
- package/Microsoft.ReactNative/CompositionRootView.idl +1 -0
- package/Microsoft.ReactNative/CompositionUIService.idl +4 -0
- package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +2 -1
- package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +106 -19
- package/Microsoft.ReactNative/Fabric/AbiViewProps.h +45 -13
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +28 -64
- package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.h +7 -11
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView.h +2 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionRootView_emptyimpl.cpp +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.cpp +12 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService.h +4 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionUIService_emptyimpl.cpp +6 -0
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +27 -16
- package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +13 -4
- package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +49 -95
- package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.h +11 -15
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +16 -31
- package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +5 -8
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +24 -81
- package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +4 -13
- package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +1 -0
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +53 -68
- package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +5 -7
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +38 -84
- package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +6 -10
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +52 -104
- package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +7 -13
- package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -0
- package/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.cpp +2 -2
- package/Microsoft.ReactNative/Modules/PlatformConstantsWinModule.h +3 -3
- package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +2 -3
- package/Microsoft.ReactNative/ViewProps.idl +37 -3
- package/Microsoft.ReactNative/packages.lock.json +68 -40
- package/Microsoft.ReactNative.Cxx/JSValueComposition.h +4 -0
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/scrollview/ScrollViewProps.cpp +36 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/runtime/ReactInstance.cpp +1 -1
- package/Shared/HermesSamplingProfiler.cpp +1 -2
- package/Shared/OInstance.cpp +1 -2
- package/Shared/Shared.vcxitems +3 -0
- package/Shared/Shared.vcxitems.filters +3 -0
- package/codegen/NativeDOMSpec.g.h +43 -25
- package/codegen/NativePlatformConstantsWindowsSpec.g.h +81 -0
- package/codegen/NativeReactNativeFeatureFlagsSpec.g.h +39 -15
- package/codegen/rnwcoreJSI-generated.cpp +67 -22
- package/codegen/rnwcoreJSI.h +327 -2521
- package/package.json +21 -20
- package/src/private/featureflags/ReactNativeFeatureFlags.js +21 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +5 -1
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +3 -7
- package/src/private/webapis/dom/nodes/ReadOnlyElement.js +11 -30
- package/src/private/webapis/dom/nodes/ReadOnlyNode.js +0 -7
- package/src/private/webapis/dom/nodes/specs/NativeDOM.js +114 -27
- package/src/private/webapis/dom/nodes/specs/__mocks__/NativeDOMMock.js +59 -22
- package/src/private/webapis/performance/PerformanceObserver.js +2 -0
- package/src/private/webapis/performance/RawPerformanceEntry.js +0 -5
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +2 -3
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/utils/jsi-utils.cpp +0 -39
- package/ReactCommon/TEMP_UntilReactCommonUpdate/react/utils/jsi-utils.h +0 -31
- package/codegen/NativePlatformConstantsWinSpec.g.h +0 -81
- /package/src/private/specs/modules/{NativePlatformConstantsWin.js → NativePlatformConstantsWindows.js} +0 -0
package/.flowconfig
CHANGED
|
@@ -280,7 +280,13 @@ type ButtonProps = $ReadOnly<{|
|
|
|
280
280
|
```
|
|
281
281
|
*/
|
|
282
282
|
|
|
283
|
-
const
|
|
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
|
|
|
@@ -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
|
-
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
|
|
197
|
-
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
...
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
props.disabled
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
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
|
-
|
|
224
|
+
for (const prop of PASSTHROUGH_PROPS) {
|
|
225
|
+
if (props[prop] !== undefined) {
|
|
226
|
+
elementProps[prop] = props[prop];
|
|
227
|
+
}
|
|
228
|
+
}
|
|
228
229
|
|
|
229
|
-
|
|
230
|
+
// $FlowFixMe[incompatible-call]
|
|
231
|
+
return React.cloneElement(element, elementProps, ...children);
|
|
232
|
+
};
|