@office-iss/react-native-win32 0.0.0-canary.270 → 0.0.0-canary.271
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/CHANGELOG.json +16 -1
- package/CHANGELOG.md +12 -4
- package/Libraries/Animated/animations/Animation.js +63 -24
- package/Libraries/Animated/animations/DecayAnimation.js +26 -38
- package/Libraries/Animated/animations/SpringAnimation.js +33 -39
- package/Libraries/Animated/animations/TimingAnimation.js +34 -42
- package/Libraries/Animated/createAnimatedComponent.js +46 -32
- package/Libraries/Animated/nodes/AnimatedProps.js +16 -10
- package/Libraries/Animated/nodes/AnimatedStyle.js +4 -0
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js +61 -3
- package/Libraries/Components/AccessibilityInfo/AccessibilityInfo.win32.js +61 -3
- package/Libraries/Components/Button.js +6 -4
- package/Libraries/Components/Button.win32.js +9 -4
- package/Libraries/Components/ScrollView/ScrollView.js +5 -5
- package/Libraries/Components/Switch/Switch.js +8 -6
- package/Libraries/Components/TextInput/TextInput.d.ts +4 -4
- package/Libraries/Components/TextInput/TextInput.flow.js +7 -10
- package/Libraries/Components/TextInput/TextInput.js +7 -7
- package/Libraries/Components/TextInput/TextInput.win32.js +7 -7
- package/Libraries/Components/TextInput/TextInputState.js +11 -13
- package/Libraries/Components/TextInput/TextInputState.win32.js +13 -16
- package/Libraries/Components/View/ReactNativeStyleAttributes.js +1 -0
- package/Libraries/Components/View/ViewNativeComponent.js +3 -10
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/setUpBatchedBridge.js +1 -10
- package/Libraries/Core/setUpReactDevTools.js +3 -3
- package/Libraries/Core/setUpSegmentFetcher.js +1 -0
- package/Libraries/Core/setUpTimers.js +8 -8
- package/Libraries/Image/ImageBackground.js +2 -5
- package/Libraries/Image/ImageProps.js +1 -1
- package/Libraries/Image/ImageViewNativeComponent.js +2 -2
- package/Libraries/Inspector/ReactDevToolsOverlay.js +0 -1
- package/Libraries/Inspector/getInspectorDataForViewAtPoint.js +3 -5
- package/Libraries/JSInspector/NetworkAgent.js +1 -1
- package/Libraries/Lists/FlatList.d.ts +1 -2
- package/Libraries/Lists/__flowtests__/FlatList-flowtest.js +2 -2
- package/Libraries/Lists/__flowtests__/SectionList-flowtest.js +1 -1
- package/Libraries/LogBox/Data/LogBoxData.js +1 -1
- package/Libraries/LogBox/UI/LogBoxInspectorStackFrames.js +1 -1
- package/Libraries/LogBox/UI/LogBoxMessage.js +2 -2
- package/Libraries/NativeComponent/BaseViewConfig.android.js +1 -0
- package/Libraries/NativeComponent/BaseViewConfig.ios.js +1 -0
- package/Libraries/NativeComponent/BaseViewConfig.win32.js +1 -0
- package/Libraries/Network/XMLHttpRequest.js +26 -1
- package/Libraries/Pressability/HoverState.js +2 -0
- package/Libraries/Pressability/HoverState.win32.js +2 -0
- package/Libraries/Pressability/Pressability.js +2 -3
- package/Libraries/Pressability/Pressability.win32.js +2 -3
- package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricHostComponent.js +2 -3
- package/Libraries/ReactNative/RendererImplementation.js +4 -3
- package/Libraries/Renderer/shims/ReactNativeTypes.js +13 -18
- package/Libraries/StyleSheet/StyleSheetTypes.d.ts +1 -0
- package/Libraries/StyleSheet/StyleSheetTypes.js +13 -0
- package/Libraries/StyleSheet/processTransform.js +3 -34
- package/Libraries/Text/Text.js +251 -249
- package/Libraries/Text/Text.win32.js +285 -295
- package/Libraries/Types/CoreEventTypes.d.ts +3 -10
- package/Libraries/Types/CoreEventTypes.js +4 -6
- package/Libraries/Types/CoreEventTypes.win32.js +4 -6
- package/Libraries/Utilities/Platform.flow.js +2 -2
- package/Libraries/Utilities/Platform.flow.win32.js +2 -2
- package/Libraries/__flowtests__/ReactNativeTypes-flowtest.js +5 -4
- package/index.js +5 -2
- package/index.win32.js +5 -2
- package/jest/setup.js +30 -0
- package/overrides.json +18 -17
- package/package.json +13 -13
- package/src/private/animated/NativeAnimatedHelper.js +2 -4
- package/src/private/animated/NativeAnimatedHelper.win32.js +2 -3
- package/src/private/components/HScrollViewNativeComponents.js +4 -5
- package/src/private/{fusebox → debugging}/setUpFuseboxReactDevToolsDispatcher.js +6 -0
- package/src/private/featureflags/ReactNativeFeatureFlags.js +14 -23
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -5
- package/src/private/specs/modules/NativeAccessibilityInfo.js +3 -0
- package/src/private/specs/modules/NativeAccessibilityInfoWin32.js +3 -0
- package/src/private/specs/modules/NativeAccessibilityManager.js +4 -0
- package/src/private/webapis/dom/nodes/ReactNativeElement.js +2 -3
- package/src/private/webapis/performance/EventTiming.js +13 -8
- package/src/private/webapis/performance/Performance.js +30 -40
- package/src/private/webapis/performance/PerformanceEntry.js +2 -5
- package/src/private/webapis/performance/PerformanceObserver.js +20 -32
- package/src/private/webapis/performance/RawPerformanceEntry.js +1 -1
- package/src/private/webapis/performance/UserTiming.js +6 -2
- package/src/private/webapis/performance/Utilities.js +0 -7
- package/src/private/webapis/performance/specs/NativePerformance.js +53 -0
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceMock.js +247 -0
- package/src-win/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts +19 -3
- package/types/public/ReactNativeTypes.d.ts +4 -4
- package/src/private/webapis/performance/specs/NativePerformanceObserver.js +0 -69
- package/src/private/webapis/performance/specs/__mocks__/NativePerformance.js +0 -69
- package/src/private/webapis/performance/specs/__mocks__/NativePerformanceObserver.js +0 -154
- /package/src/private/{fusebox → debugging}/FuseboxSessionObserver.js +0 -0
- /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.android.js +0 -0
- /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.ios.js +0 -0
- /package/src/private/{reactdevtools → debugging}/ReactDevToolsSettingsManager.win32.js +0 -0
|
@@ -4,12 +4,10 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow strict-local
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
11
|
import type {PlatformConfig} from '../AnimatedPlatformConfig';
|
|
14
12
|
import type {RgbaValue} from '../nodes/AnimatedColor';
|
|
15
13
|
import type AnimatedInterpolation from '../nodes/AnimatedInterpolation';
|
|
@@ -17,7 +15,6 @@ import type AnimatedValue from '../nodes/AnimatedValue';
|
|
|
17
15
|
import type AnimatedValueXY from '../nodes/AnimatedValueXY';
|
|
18
16
|
import type {AnimationConfig, EndCallback} from './Animation';
|
|
19
17
|
|
|
20
|
-
import NativeAnimatedHelper from '../../../src/private/animated/NativeAnimatedHelper';
|
|
21
18
|
import AnimatedColor from '../nodes/AnimatedColor';
|
|
22
19
|
import Animation from './Animation';
|
|
23
20
|
|
|
@@ -26,11 +23,11 @@ export type TimingAnimationConfig = $ReadOnly<{
|
|
|
26
23
|
toValue:
|
|
27
24
|
| number
|
|
28
25
|
| AnimatedValue
|
|
29
|
-
| {
|
|
26
|
+
| $ReadOnly<{
|
|
30
27
|
x: number,
|
|
31
28
|
y: number,
|
|
32
29
|
...
|
|
33
|
-
}
|
|
30
|
+
}>
|
|
34
31
|
| AnimatedValueXY
|
|
35
32
|
| RgbaValue
|
|
36
33
|
| AnimatedColor
|
|
@@ -38,6 +35,7 @@ export type TimingAnimationConfig = $ReadOnly<{
|
|
|
38
35
|
easing?: (value: number) => number,
|
|
39
36
|
duration?: number,
|
|
40
37
|
delay?: number,
|
|
38
|
+
...
|
|
41
39
|
}>;
|
|
42
40
|
|
|
43
41
|
export type TimingAnimationConfigSingle = $ReadOnly<{
|
|
@@ -46,6 +44,7 @@ export type TimingAnimationConfigSingle = $ReadOnly<{
|
|
|
46
44
|
easing?: (value: number) => number,
|
|
47
45
|
duration?: number,
|
|
48
46
|
delay?: number,
|
|
47
|
+
...
|
|
49
48
|
}>;
|
|
50
49
|
|
|
51
50
|
let _easeInOut;
|
|
@@ -65,25 +64,28 @@ export default class TimingAnimation extends Animation {
|
|
|
65
64
|
_delay: number;
|
|
66
65
|
_easing: (value: number) => number;
|
|
67
66
|
_onUpdate: (value: number) => void;
|
|
68
|
-
_animationFrame:
|
|
69
|
-
_timeout:
|
|
70
|
-
_useNativeDriver: boolean;
|
|
67
|
+
_animationFrame: ?AnimationFrameID;
|
|
68
|
+
_timeout: ?TimeoutID;
|
|
71
69
|
_platformConfig: ?PlatformConfig;
|
|
72
70
|
|
|
73
71
|
constructor(config: TimingAnimationConfigSingle) {
|
|
74
|
-
super();
|
|
72
|
+
super(config);
|
|
73
|
+
|
|
75
74
|
this._toValue = config.toValue;
|
|
76
75
|
this._easing = config.easing ?? easeInOut();
|
|
77
76
|
this._duration = config.duration ?? 500;
|
|
78
77
|
this._delay = config.delay ?? 0;
|
|
79
|
-
this.__iterations = config.iterations ?? 1;
|
|
80
|
-
this._useNativeDriver = NativeAnimatedHelper.shouldUseNativeDriver(config);
|
|
81
78
|
this._platformConfig = config.platformConfig;
|
|
82
|
-
this.__isInteraction = config.isInteraction ?? !this._useNativeDriver;
|
|
83
|
-
this.__isLooping = config.isLooping;
|
|
84
79
|
}
|
|
85
80
|
|
|
86
|
-
__getNativeAnimationConfig():
|
|
81
|
+
__getNativeAnimationConfig(): $ReadOnly<{
|
|
82
|
+
type: 'frames',
|
|
83
|
+
frames: $ReadOnlyArray<number>,
|
|
84
|
+
toValue: number,
|
|
85
|
+
iterations: number,
|
|
86
|
+
platformConfig: ?PlatformConfig,
|
|
87
|
+
...
|
|
88
|
+
}> {
|
|
87
89
|
const frameDuration = 1000.0 / 60.0;
|
|
88
90
|
const frames = [];
|
|
89
91
|
const numFrames = Math.round(this._duration / frameDuration);
|
|
@@ -107,35 +109,24 @@ export default class TimingAnimation extends Animation {
|
|
|
107
109
|
previousAnimation: ?Animation,
|
|
108
110
|
animatedValue: AnimatedValue,
|
|
109
111
|
): void {
|
|
110
|
-
|
|
112
|
+
super.start(fromValue, onUpdate, onEnd, previousAnimation, animatedValue);
|
|
113
|
+
|
|
111
114
|
this._fromValue = fromValue;
|
|
112
115
|
this._onUpdate = onUpdate;
|
|
113
|
-
this.__onEnd = onEnd;
|
|
114
116
|
|
|
115
117
|
const start = () => {
|
|
116
|
-
|
|
117
|
-
throw new Error(
|
|
118
|
-
'Attempting to run JS driven animation on animated node ' +
|
|
119
|
-
'that has been moved to "native" earlier by starting an ' +
|
|
120
|
-
'animation with `useNativeDriver: true`',
|
|
121
|
-
);
|
|
122
|
-
}
|
|
118
|
+
this._startTime = Date.now();
|
|
123
119
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
this.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (this._useNativeDriver) {
|
|
133
|
-
this.__startNativeAnimation(animatedValue);
|
|
120
|
+
const useNativeDriver = this.__startAnimationIfNative(animatedValue);
|
|
121
|
+
if (!useNativeDriver) {
|
|
122
|
+
// Animations that sometimes have 0 duration and sometimes do not
|
|
123
|
+
// still need to use the native driver when duration is 0 so as to
|
|
124
|
+
// not cause intermixed JS and native animations.
|
|
125
|
+
if (this._duration === 0) {
|
|
126
|
+
this._onUpdate(this._toValue);
|
|
127
|
+
this.__notifyAnimationEnd({finished: true});
|
|
134
128
|
} else {
|
|
135
|
-
this._animationFrame = requestAnimationFrame(
|
|
136
|
-
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
|
137
|
-
this.onUpdate.bind(this),
|
|
138
|
-
);
|
|
129
|
+
this._animationFrame = requestAnimationFrame(() => this.onUpdate());
|
|
139
130
|
}
|
|
140
131
|
}
|
|
141
132
|
};
|
|
@@ -156,7 +147,7 @@ export default class TimingAnimation extends Animation {
|
|
|
156
147
|
this._fromValue + this._easing(1) * (this._toValue - this._fromValue),
|
|
157
148
|
);
|
|
158
149
|
}
|
|
159
|
-
this.
|
|
150
|
+
this.__notifyAnimationEnd({finished: true});
|
|
160
151
|
return;
|
|
161
152
|
}
|
|
162
153
|
|
|
@@ -173,9 +164,10 @@ export default class TimingAnimation extends Animation {
|
|
|
173
164
|
|
|
174
165
|
stop(): void {
|
|
175
166
|
super.stop();
|
|
176
|
-
this.__active = false;
|
|
177
167
|
clearTimeout(this._timeout);
|
|
178
|
-
|
|
179
|
-
|
|
168
|
+
if (this._animationFrame != null) {
|
|
169
|
+
global.cancelAnimationFrame(this._animationFrame);
|
|
170
|
+
}
|
|
171
|
+
this.__notifyAnimationEnd({finished: false});
|
|
180
172
|
}
|
|
181
173
|
}
|
|
@@ -27,11 +27,24 @@ export type AnimatedProps<Props: {...}> = {
|
|
|
27
27
|
}>)]: any,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
// We could use a mapped type here to introduce acceptable Animated variants
|
|
31
|
+
// of properties, instead of doing so in the core StyleSheetTypes
|
|
32
|
+
// Inexact Props are not supported, they'll be made exact here.
|
|
33
|
+
export type StrictAnimatedProps<Props: {...}> = $ReadOnly<{
|
|
34
|
+
...$Exact<Props>,
|
|
35
|
+
passthroughAnimatedPropExplicitValues?: ?Props,
|
|
36
|
+
}>;
|
|
37
|
+
|
|
30
38
|
export type AnimatedComponentType<
|
|
31
39
|
Props: {...},
|
|
32
40
|
+Instance = mixed,
|
|
33
41
|
> = React.AbstractComponent<AnimatedProps<Props>, Instance>;
|
|
34
42
|
|
|
43
|
+
export type StrictAnimatedComponentType<
|
|
44
|
+
Props: {...},
|
|
45
|
+
+Instance = mixed,
|
|
46
|
+
> = React.AbstractComponent<StrictAnimatedProps<Props>, Instance>;
|
|
47
|
+
|
|
35
48
|
export default function createAnimatedComponent<TProps: {...}, TInstance>(
|
|
36
49
|
Component: React.AbstractComponent<TProps, TInstance>,
|
|
37
50
|
): AnimatedComponentType<TProps, TInstance> {
|
|
@@ -44,40 +57,41 @@ export function unstable_createAnimatedComponentWithAllowlist<
|
|
|
44
57
|
>(
|
|
45
58
|
Component: React.AbstractComponent<TProps, TInstance>,
|
|
46
59
|
allowlist: ?AnimatedPropsAllowlist,
|
|
47
|
-
):
|
|
48
|
-
const AnimatedComponent = React.forwardRef<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
): StrictAnimatedComponentType<TProps, TInstance> {
|
|
61
|
+
const AnimatedComponent = React.forwardRef<
|
|
62
|
+
StrictAnimatedProps<TProps>,
|
|
63
|
+
TInstance,
|
|
64
|
+
>((props, forwardedRef) => {
|
|
65
|
+
const [reducedProps, callbackRef] = useAnimatedProps<TProps, TInstance>(
|
|
66
|
+
// $FlowFixMe[incompatible-call]
|
|
67
|
+
props,
|
|
68
|
+
allowlist,
|
|
69
|
+
);
|
|
70
|
+
const ref = useMergeRefs<TInstance>(callbackRef, forwardedRef);
|
|
56
71
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
// Some components require explicit passthrough values for animation
|
|
73
|
+
// to work properly. For example, if an animated component is
|
|
74
|
+
// transformed and Pressable, onPress will not work after transform
|
|
75
|
+
// without these passthrough values.
|
|
76
|
+
// $FlowFixMe[prop-missing]
|
|
77
|
+
const {passthroughAnimatedPropExplicitValues, style} = reducedProps;
|
|
78
|
+
const passthroughStyle = passthroughAnimatedPropExplicitValues?.style;
|
|
79
|
+
const mergedStyle = useMemo(
|
|
80
|
+
() => composeStyles(style, passthroughStyle),
|
|
81
|
+
[passthroughStyle, style],
|
|
82
|
+
);
|
|
68
83
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
);
|
|
84
|
+
// NOTE: It is important that `passthroughAnimatedPropExplicitValues` is
|
|
85
|
+
// spread after `reducedProps` but before `style`.
|
|
86
|
+
return (
|
|
87
|
+
<Component
|
|
88
|
+
{...reducedProps}
|
|
89
|
+
{...passthroughAnimatedPropExplicitValues}
|
|
90
|
+
style={mergedStyle}
|
|
91
|
+
ref={ref}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
});
|
|
81
95
|
|
|
82
96
|
AnimatedComponent.displayName = `Animated(${
|
|
83
97
|
Component.displayName || 'Anonymous'
|
|
@@ -212,11 +212,14 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
212
212
|
|
|
213
213
|
__connectAnimatedView(): void {
|
|
214
214
|
invariant(this.__isNative, 'Expected node to be marked as "native"');
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
215
|
+
let nativeViewTag: ?number = findNodeHandle(this.#animatedView);
|
|
216
|
+
if (nativeViewTag == null) {
|
|
217
|
+
if (process.env.NODE_ENV === 'test') {
|
|
218
|
+
nativeViewTag = -1;
|
|
219
|
+
} else {
|
|
220
|
+
throw new Error('Unable to locate attached view in the native tree');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
220
223
|
NativeAnimatedHelper.API.connectAnimatedNodeToView(
|
|
221
224
|
this.__getNativeTag(),
|
|
222
225
|
nativeViewTag,
|
|
@@ -225,11 +228,14 @@ export default class AnimatedProps extends AnimatedNode {
|
|
|
225
228
|
|
|
226
229
|
__disconnectAnimatedView(): void {
|
|
227
230
|
invariant(this.__isNative, 'Expected node to be marked as "native"');
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
let nativeViewTag: ?number = findNodeHandle(this.#animatedView);
|
|
232
|
+
if (nativeViewTag == null) {
|
|
233
|
+
if (process.env.NODE_ENV === 'test') {
|
|
234
|
+
nativeViewTag = -1;
|
|
235
|
+
} else {
|
|
236
|
+
throw new Error('Unable to locate attached view in the native tree');
|
|
237
|
+
}
|
|
238
|
+
}
|
|
233
239
|
NativeAnimatedHelper.API.disconnectAnimatedNodeFromView(
|
|
234
240
|
this.__getNativeTag(),
|
|
235
241
|
nativeViewTag,
|
|
@@ -135,6 +135,8 @@ export default class AnimatedStyle extends AnimatedWithChildren {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/* $FlowFixMe[incompatible-type] Error found due to incomplete typing of
|
|
139
|
+
* Platform.flow.js */
|
|
138
140
|
return Platform.OS === 'web' ? [this.#inputStyle, style] : style;
|
|
139
141
|
}
|
|
140
142
|
|
|
@@ -172,6 +174,8 @@ export default class AnimatedStyle extends AnimatedWithChildren {
|
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
176
|
|
|
177
|
+
/* $FlowFixMe[incompatible-type] Error found due to incomplete typing of
|
|
178
|
+
* Platform.flow.js */
|
|
175
179
|
return Platform.OS === 'web' ? [this.#inputStyle, style] : style;
|
|
176
180
|
}
|
|
177
181
|
|
|
@@ -7,8 +7,7 @@
|
|
|
7
7
|
* @format
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
import {HostComponent} from '../../../types/public/ReactNativeTypes';
|
|
10
|
+
import {HostInstance} from '../../../types/public/ReactNativeTypes';
|
|
12
11
|
import {EmitterSubscription} from '../../vendor/emitter/EventEmitter';
|
|
13
12
|
|
|
14
13
|
type AccessibilityChangeEventName =
|
|
@@ -17,6 +16,8 @@ type AccessibilityChangeEventName =
|
|
|
17
16
|
| 'grayscaleChanged' // iOS-only Event
|
|
18
17
|
| 'invertColorsChanged' // iOS-only Event
|
|
19
18
|
| 'reduceMotionChanged'
|
|
19
|
+
| 'highTextContrastChanged' // Android-only Event
|
|
20
|
+
| 'darkerSystemColorsChanged' // iOS-only Event
|
|
20
21
|
| 'screenReaderChanged'
|
|
21
22
|
| 'reduceTransparencyChanged'; // iOS-only Event
|
|
22
23
|
|
|
@@ -69,6 +70,21 @@ export interface AccessibilityInfoStatic {
|
|
|
69
70
|
*/
|
|
70
71
|
isReduceMotionEnabled: () => Promise<boolean>;
|
|
71
72
|
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* Query whether high text contrast is currently enabled.
|
|
76
|
+
*
|
|
77
|
+
* @platform android
|
|
78
|
+
*/
|
|
79
|
+
isHighTextContrastEnabled: () => Promise<boolean>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Query whether darker system colors is currently enabled.
|
|
83
|
+
*
|
|
84
|
+
* @platform ios
|
|
85
|
+
*/
|
|
86
|
+
isDarkerSystemColorsEnabled: () => Promise<boolean>;
|
|
87
|
+
|
|
72
88
|
/**
|
|
73
89
|
* Query whether reduce motion and prefer cross-fade transitions settings are currently enabled.
|
|
74
90
|
*
|
|
@@ -152,7 +168,7 @@ export interface AccessibilityInfoStatic {
|
|
|
152
168
|
*/
|
|
153
169
|
getRecommendedTimeoutMillis: (originalTimeout: number) => Promise<number>;
|
|
154
170
|
sendAccessibilityEvent: (
|
|
155
|
-
handle:
|
|
171
|
+
handle: HostInstance,
|
|
156
172
|
eventType: AccessibilityEventTypes,
|
|
157
173
|
) => void;
|
|
158
174
|
}
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes';
|
|
12
12
|
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
|
|
13
|
-
import type {ElementRef} from 'react';
|
|
14
13
|
|
|
15
14
|
import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter';
|
|
16
15
|
import {sendAccessibilityEvent} from '../../ReactNative/RendererProxy';
|
|
@@ -22,6 +21,7 @@ import NativeAccessibilityManagerIOS from './NativeAccessibilityManager';
|
|
|
22
21
|
// Events that are only supported on Android.
|
|
23
22
|
type AccessibilityEventDefinitionsAndroid = {
|
|
24
23
|
accessibilityServiceChanged: [boolean],
|
|
24
|
+
highTextContrastChanged: [boolean],
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
// Events that are only supported on iOS.
|
|
@@ -31,6 +31,7 @@ type AccessibilityEventDefinitionsIOS = {
|
|
|
31
31
|
grayscaleChanged: [boolean],
|
|
32
32
|
invertColorsChanged: [boolean],
|
|
33
33
|
reduceTransparencyChanged: [boolean],
|
|
34
|
+
darkerSystemColorsChanged: [boolean],
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
type AccessibilityEventDefinitions = {
|
|
@@ -51,6 +52,7 @@ const EventNames: Map<
|
|
|
51
52
|
? new Map([
|
|
52
53
|
['change', 'touchExplorationDidChange'],
|
|
53
54
|
['reduceMotionChanged', 'reduceMotionDidChange'],
|
|
55
|
+
['highTextContrastChanged', 'highTextContrastDidChange'],
|
|
54
56
|
['screenReaderChanged', 'touchExplorationDidChange'],
|
|
55
57
|
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
|
|
56
58
|
])
|
|
@@ -63,6 +65,7 @@ const EventNames: Map<
|
|
|
63
65
|
['reduceMotionChanged', 'reduceMotionChanged'],
|
|
64
66
|
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
|
|
65
67
|
['screenReaderChanged', 'screenReaderChanged'],
|
|
68
|
+
['darkerSystemColorsChanged', 'darkerSystemColorsChanged'],
|
|
66
69
|
]);
|
|
67
70
|
|
|
68
71
|
/**
|
|
@@ -179,6 +182,52 @@ const AccessibilityInfo = {
|
|
|
179
182
|
});
|
|
180
183
|
},
|
|
181
184
|
|
|
185
|
+
/**
|
|
186
|
+
* Query whether high text contrast is currently enabled. Android only.
|
|
187
|
+
*
|
|
188
|
+
* Returns a promise which resolves to a boolean.
|
|
189
|
+
* The result is `true` when high text contrast is enabled and `false` otherwise.
|
|
190
|
+
*/
|
|
191
|
+
isHighTextContrastEnabled(): Promise<boolean> {
|
|
192
|
+
return new Promise((resolve, reject) => {
|
|
193
|
+
if (Platform.OS === 'android') {
|
|
194
|
+
if (NativeAccessibilityInfoAndroid?.isHighTextContrastEnabled != null) {
|
|
195
|
+
NativeAccessibilityInfoAndroid.isHighTextContrastEnabled(resolve);
|
|
196
|
+
} else {
|
|
197
|
+
reject(null);
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
return Promise.resolve(false);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Query whether dark system colors is currently enabled. iOS only.
|
|
207
|
+
*
|
|
208
|
+
* Returns a promise which resolves to a boolean.
|
|
209
|
+
* The result is `true` when dark system colors is enabled and `false` otherwise.
|
|
210
|
+
*/
|
|
211
|
+
isDarkerSystemColorsEnabled(): Promise<boolean> {
|
|
212
|
+
return new Promise((resolve, reject) => {
|
|
213
|
+
if (Platform.OS === 'android') {
|
|
214
|
+
return Promise.resolve(false);
|
|
215
|
+
} else {
|
|
216
|
+
if (
|
|
217
|
+
NativeAccessibilityManagerIOS?.getCurrentDarkerSystemColorsState !=
|
|
218
|
+
null
|
|
219
|
+
) {
|
|
220
|
+
NativeAccessibilityManagerIOS.getCurrentDarkerSystemColorsState(
|
|
221
|
+
resolve,
|
|
222
|
+
reject,
|
|
223
|
+
);
|
|
224
|
+
} else {
|
|
225
|
+
reject(null);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
|
|
182
231
|
/**
|
|
183
232
|
* Query whether reduce motion and prefer cross-fade transitions settings are currently enabled.
|
|
184
233
|
*
|
|
@@ -319,6 +368,15 @@ const AccessibilityInfo = {
|
|
|
319
368
|
* - `announcement`: The string announced by the screen reader.
|
|
320
369
|
* - `success`: A boolean indicating whether the announcement was
|
|
321
370
|
* successfully made.
|
|
371
|
+
* - `darkerSystemColorsChanged`: iOS-only event. Fires when the state of the dark system colors
|
|
372
|
+
* toggle changes. The argument to the event handler is a boolean. The boolean is `true` when
|
|
373
|
+
* dark system colors is enabled and `false` otherwise.
|
|
374
|
+
*
|
|
375
|
+
* These events are only supported on Android:
|
|
376
|
+
*
|
|
377
|
+
* - `highTextContrastChanged`: Android-only event. Fires when the state of the high text contrast
|
|
378
|
+
* toggle changes. The argument to the event handler is a boolean. The boolean is `true` when
|
|
379
|
+
* high text contrast is enabled and `false` otherwise.
|
|
322
380
|
*
|
|
323
381
|
* See https://reactnative.dev/docs/accessibilityinfo#addeventlistener
|
|
324
382
|
*/
|
|
@@ -347,7 +405,7 @@ const AccessibilityInfo = {
|
|
|
347
405
|
* Send a named accessibility event to a HostComponent.
|
|
348
406
|
*/
|
|
349
407
|
sendAccessibilityEvent(
|
|
350
|
-
handle:
|
|
408
|
+
handle: HostInstance,
|
|
351
409
|
eventType: AccessibilityEventTypes,
|
|
352
410
|
) {
|
|
353
411
|
// iOS only supports 'focus' event types
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type {
|
|
11
|
+
import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes';
|
|
12
12
|
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
|
|
13
|
-
import type {ElementRef} from 'react';
|
|
14
13
|
|
|
15
14
|
import RCTDeviceEventEmitter from '../../EventEmitter/RCTDeviceEventEmitter';
|
|
16
15
|
import {sendAccessibilityEvent} from '../../ReactNative/RendererProxy';
|
|
@@ -23,6 +22,7 @@ import NativeAccessibilityManagerIOS from './NativeAccessibilityManager';
|
|
|
23
22
|
// Events that are only supported on Android.
|
|
24
23
|
type AccessibilityEventDefinitionsAndroid = {
|
|
25
24
|
accessibilityServiceChanged: [boolean],
|
|
25
|
+
highTextContrastChanged: [boolean],
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
// Events that are only supported on iOS.
|
|
@@ -32,6 +32,7 @@ type AccessibilityEventDefinitionsIOS = {
|
|
|
32
32
|
grayscaleChanged: [boolean],
|
|
33
33
|
invertColorsChanged: [boolean],
|
|
34
34
|
reduceTransparencyChanged: [boolean],
|
|
35
|
+
darkerSystemColorsChanged: [boolean],
|
|
35
36
|
};
|
|
36
37
|
|
|
37
38
|
type AccessibilityEventDefinitions = {
|
|
@@ -52,6 +53,7 @@ const EventNames: Map<
|
|
|
52
53
|
? new Map([
|
|
53
54
|
['change', 'touchExplorationDidChange'],
|
|
54
55
|
['reduceMotionChanged', 'reduceMotionDidChange'],
|
|
56
|
+
['highTextContrastChanged', 'highTextContrastDidChange'],
|
|
55
57
|
['screenReaderChanged', 'touchExplorationDidChange'],
|
|
56
58
|
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
|
|
57
59
|
])
|
|
@@ -70,6 +72,7 @@ const EventNames: Map<
|
|
|
70
72
|
['reduceMotionChanged', 'reduceMotionChanged'],
|
|
71
73
|
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
|
|
72
74
|
['screenReaderChanged', 'screenReaderChanged'],
|
|
75
|
+
['darkerSystemColorsChanged', 'darkerSystemColorsChanged'],
|
|
73
76
|
]);
|
|
74
77
|
|
|
75
78
|
/**
|
|
@@ -192,6 +195,52 @@ const AccessibilityInfo = {
|
|
|
192
195
|
});
|
|
193
196
|
},
|
|
194
197
|
|
|
198
|
+
/**
|
|
199
|
+
* Query whether high text contrast is currently enabled. Android only.
|
|
200
|
+
*
|
|
201
|
+
* Returns a promise which resolves to a boolean.
|
|
202
|
+
* The result is `true` when high text contrast is enabled and `false` otherwise.
|
|
203
|
+
*/
|
|
204
|
+
isHighTextContrastEnabled(): Promise<boolean> {
|
|
205
|
+
return new Promise((resolve, reject) => {
|
|
206
|
+
if (Platform.OS === 'android') {
|
|
207
|
+
if (NativeAccessibilityInfo?.isHighTextContrastEnabled != null) {
|
|
208
|
+
NativeAccessibilityInfo.isHighTextContrastEnabled(resolve);
|
|
209
|
+
} else {
|
|
210
|
+
reject(null);
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
return Promise.resolve(false);
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
},
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Query whether dark system colors is currently enabled. iOS only.
|
|
220
|
+
*
|
|
221
|
+
* Returns a promise which resolves to a boolean.
|
|
222
|
+
* The result is `true` when dark system colors is enabled and `false` otherwise.
|
|
223
|
+
*/
|
|
224
|
+
isDarkerSystemColorsEnabled(): Promise<boolean> {
|
|
225
|
+
return new Promise((resolve, reject) => {
|
|
226
|
+
if (Platform.OS === 'android') {
|
|
227
|
+
return Promise.resolve(false);
|
|
228
|
+
} else {
|
|
229
|
+
if (
|
|
230
|
+
NativeAccessibilityManagerIOS?.getCurrentDarkerSystemColorsState !=
|
|
231
|
+
null
|
|
232
|
+
) {
|
|
233
|
+
NativeAccessibilityManagerIOS.getCurrentDarkerSystemColorsState(
|
|
234
|
+
resolve,
|
|
235
|
+
reject,
|
|
236
|
+
);
|
|
237
|
+
} else {
|
|
238
|
+
reject(null);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
|
|
195
244
|
/**
|
|
196
245
|
* Query whether reduce motion and prefer cross-fade transitions settings are currently enabled.
|
|
197
246
|
*
|
|
@@ -338,6 +387,15 @@ const AccessibilityInfo = {
|
|
|
338
387
|
* - `announcement`: The string announced by the screen reader.
|
|
339
388
|
* - `success`: A boolean indicating whether the announcement was
|
|
340
389
|
* successfully made.
|
|
390
|
+
* - `darkerSystemColorsChanged`: iOS-only event. Fires when the state of the dark system colors
|
|
391
|
+
* toggle changes. The argument to the event handler is a boolean. The boolean is `true` when
|
|
392
|
+
* dark system colors is enabled and `false` otherwise.
|
|
393
|
+
*
|
|
394
|
+
* These events are only supported on Android:
|
|
395
|
+
*
|
|
396
|
+
* - `highTextContrastChanged`: Android-only event. Fires when the state of the high text contrast
|
|
397
|
+
* toggle changes. The argument to the event handler is a boolean. The boolean is `true` when
|
|
398
|
+
* high text contrast is enabled and `false` otherwise.
|
|
341
399
|
*
|
|
342
400
|
* See https://reactnative.dev/docs/accessibilityinfo#addeventlistener
|
|
343
401
|
*/
|
|
@@ -366,7 +424,7 @@ const AccessibilityInfo = {
|
|
|
366
424
|
* Send a named accessibility event to a HostComponent.
|
|
367
425
|
*/
|
|
368
426
|
sendAccessibilityEvent(
|
|
369
|
-
handle:
|
|
427
|
+
handle: HostInstance,
|
|
370
428
|
eventType: AccessibilityEventTypes,
|
|
371
429
|
) {
|
|
372
430
|
// iOS only supports 'focus' event types
|
|
@@ -283,10 +283,12 @@ type ButtonProps = $ReadOnly<{|
|
|
|
283
283
|
const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
|
|
284
284
|
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
|
|
285
285
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
286
|
+
type ButtonRef = React.ElementRef<typeof Touchable>;
|
|
287
|
+
|
|
288
|
+
const Button: component(
|
|
289
|
+
ref: React.RefSetter<ButtonRef>,
|
|
290
|
+
...props: ButtonProps
|
|
291
|
+
) = React.forwardRef((props: ButtonProps, ref: React.RefSetter<ButtonRef>) => {
|
|
290
292
|
const {
|
|
291
293
|
accessibilityLabel,
|
|
292
294
|
accessibilityState,
|
|
@@ -283,10 +283,15 @@ type ButtonProps = $ReadOnly<{|
|
|
|
283
283
|
```
|
|
284
284
|
*/
|
|
285
285
|
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
286
|
+
const Touchable: typeof TouchableNativeFeedback | typeof TouchableOpacity =
|
|
287
|
+
Platform.OS === 'android' ? TouchableNativeFeedback : TouchableOpacity;
|
|
288
|
+
|
|
289
|
+
type ButtonRef = React.ElementRef<typeof Touchable>;
|
|
290
|
+
|
|
291
|
+
const Button: component(
|
|
292
|
+
ref: React.RefSetter<ButtonRef>,
|
|
293
|
+
...props: ButtonProps
|
|
294
|
+
) = React.forwardRef((props: ButtonProps, ref: React.RefSetter<ButtonRef>) => {
|
|
290
295
|
// Win32
|
|
291
296
|
const {
|
|
292
297
|
accessibilityLabel,
|
|
@@ -12,7 +12,7 @@ import type {
|
|
|
12
12
|
TScrollViewNativeComponentInstance,
|
|
13
13
|
TScrollViewNativeImperativeHandle,
|
|
14
14
|
} from '../../../src/private/components/useSyncOnScroll';
|
|
15
|
-
import type {
|
|
15
|
+
import type {HostInstance} from '../../Renderer/shims/ReactNativeTypes';
|
|
16
16
|
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
|
|
17
17
|
import type {PointProp} from '../../StyleSheet/PointPropType';
|
|
18
18
|
import type {ViewStyleProp} from '../../StyleSheet/StyleSheet';
|
|
@@ -961,12 +961,12 @@ class ScrollView extends React.Component<Props, State> {
|
|
|
961
961
|
* @param {bool} preventNegativeScrolling Whether to allow pulling the content
|
|
962
962
|
* down to make it meet the keyboard's top. Default is false.
|
|
963
963
|
*/
|
|
964
|
-
scrollResponderScrollNativeHandleToKeyboard:
|
|
965
|
-
nodeHandle: number |
|
|
964
|
+
scrollResponderScrollNativeHandleToKeyboard: (
|
|
965
|
+
nodeHandle: number | HostInstance,
|
|
966
966
|
additionalOffset?: number,
|
|
967
967
|
preventNegativeScrollOffset?: boolean,
|
|
968
|
-
) => void =
|
|
969
|
-
nodeHandle: number |
|
|
968
|
+
) => void = (
|
|
969
|
+
nodeHandle: number | HostInstance,
|
|
970
970
|
additionalOffset?: number,
|
|
971
971
|
preventNegativeScrollOffset?: boolean,
|
|
972
972
|
) => {
|