@office-iss/react-native-win32 0.71.0 → 0.71.2

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 (79) hide show
  1. package/.flowconfig +1 -0
  2. package/CHANGELOG.json +12667 -12652
  3. package/CHANGELOG.md +23 -15
  4. package/Libraries/Components/Button/ButtonWin32.Props.d.ts +2 -2
  5. package/Libraries/Components/Button/ButtonWin32.d.ts +1 -1
  6. package/Libraries/Components/Button/ButtonWin32.js +6 -4
  7. package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
  8. package/Libraries/Components/Pressable/Pressable.win32.js +0 -1
  9. package/Libraries/Components/Text/TextWin32.Props.d.ts +3 -9
  10. package/Libraries/Components/Text/TextWin32.Props.js.map +1 -1
  11. package/Libraries/Components/Text/TextWin32.d.ts +1 -1
  12. package/Libraries/Components/Text/TextWin32.js.map +1 -1
  13. package/Libraries/Components/TextInput/TextInput.Types.win32.d.ts +9 -9
  14. package/Libraries/Components/TextInput/TextInput.win32.js +1150 -154
  15. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +4 -4
  16. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  17. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.d.ts +119 -16
  18. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +99 -24
  19. package/Libraries/Components/Touchable/TouchableWin32.Props.d.ts +2 -2
  20. package/Libraries/Components/Touchable/TouchableWin32.Props.js.map +1 -1
  21. package/Libraries/Components/Touchable/TouchableWin32.Types.d.ts +9 -9
  22. package/Libraries/Components/Touchable/TouchableWin32.js +5 -6
  23. package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
  24. package/Libraries/Components/View/ReactNativeViewAttributes.win32.js +29 -10
  25. package/Libraries/Components/View/Tests/ViewWin32Test.js +31 -51
  26. package/Libraries/Components/View/Tests/ViewWin32Test.js.map +1 -1
  27. package/Libraries/Components/View/ViewAccessibility.win32.d.ts +527 -0
  28. package/Libraries/Components/View/ViewAccessibility.win32.js +178 -0
  29. package/Libraries/Components/View/ViewPropTypes.win32.d.ts +372 -0
  30. package/Libraries/Components/View/ViewPropTypes.win32.js +23 -0
  31. package/Libraries/Components/View/ViewWin32.d.ts +30 -12
  32. package/Libraries/Components/View/ViewWin32.js +161 -71
  33. package/Libraries/Image/Image.win32.js +0 -1
  34. package/Libraries/Pressability/Pressability.win32.js +2 -2
  35. package/Libraries/Utilities/AcessibilityMapping.win32.js +156 -0
  36. package/Libraries/__tests__/ButtonWin32-test.js +1 -1
  37. package/Libraries/platform-types.d.ts +7 -13
  38. package/index.win32.js +1 -1
  39. package/jest.config.js +2 -4
  40. package/overrides.json +38 -8
  41. package/package.json +5 -5
  42. package/src/Libraries/Components/Button/ButtonWin32.tsx +8 -8
  43. package/src/Libraries/Components/Text/TextWin32.Props.ts +2 -15
  44. package/src/Libraries/Components/Text/TextWin32.tsx +6 -2
  45. package/src/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +5 -5
  46. package/src/Libraries/Components/Touchable/TouchableNativeFeedback.win32.d.ts +119 -0
  47. package/src/Libraries/Components/Touchable/TouchableWin32.Props.tsx +1 -1
  48. package/src/Libraries/Components/Touchable/TouchableWin32.tsx +6 -7
  49. package/src/Libraries/Components/View/Tests/ViewWin32Test.tsx +28 -52
  50. package/src/Libraries/Components/View/ViewAccessibility.win32.d.ts +527 -0
  51. package/src/Libraries/Components/View/ViewPropTypes.win32.d.ts +372 -0
  52. package/src/Libraries/Components/View/ViewWin32.d.ts +30 -0
  53. package/src/Libraries/platform-types.d.ts +7 -13
  54. package/types/modules/BatchedBridge.d.ts +32 -0
  55. package/types/modules/Codegen.d.ts +74 -0
  56. package/types/modules/Devtools.d.ts +31 -0
  57. package/types/modules/LaunchScreen.d.ts +18 -0
  58. package/types/modules/globals.d.ts +577 -0
  59. package/types/private/TimerMixin.d.ts +19 -0
  60. package/types/private/Utilities.d.ts +10 -0
  61. package/types/public/DeprecatedPropertiesAlias.d.ts +205 -0
  62. package/types/public/Insets.d.ts +15 -0
  63. package/types/public/ReactNativeRenderer.d.ts +149 -0
  64. package/types/public/ReactNativeTypes.d.ts +143 -0
  65. package/Libraries/Components/TextInput/TextInput.win32.d.ts +0 -68
  66. package/Libraries/Components/TextInput/TextInput.win32.js.map +0 -1
  67. package/Libraries/Components/Touchable/TouchableNativeFeedback.Props.d.ts +0 -7
  68. package/Libraries/Components/Touchable/TouchableNativeFeedback.Props.js +0 -3
  69. package/Libraries/Components/Touchable/TouchableNativeFeedback.Props.js.map +0 -1
  70. package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js.map +0 -1
  71. package/Libraries/Components/View/ViewWin32.Props.d.ts +0 -174
  72. package/Libraries/Components/View/ViewWin32.Props.js +0 -11
  73. package/Libraries/Components/View/ViewWin32.Props.js.map +0 -1
  74. package/Libraries/Components/View/ViewWin32.js.map +0 -1
  75. package/src/Libraries/Components/TextInput/TextInput.win32.tsx +0 -217
  76. package/src/Libraries/Components/Touchable/TouchableNativeFeedback.Props.ts +0 -9
  77. package/src/Libraries/Components/Touchable/TouchableNativeFeedback.win32.tsx +0 -27
  78. package/src/Libraries/Components/View/ViewWin32.Props.ts +0 -281
  79. package/src/Libraries/Components/View/ViewWin32.tsx +0 -119
@@ -0,0 +1,372 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ */
9
+
10
+ import type * as React from 'react';
11
+ import {Insets} from 'react-native/types/public/Insets';
12
+ import {GestureResponderHandlers} from 'react-native/types/public/ReactNativeRenderer';
13
+ import {StyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet';
14
+ import {ViewStyle} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
15
+ import {
16
+ LayoutChangeEvent,
17
+ MouseEvent, // Win32
18
+ NativeSyntheticEvent, // Win32
19
+ PointerEvents,
20
+ } from 'react-native/Libraries/Types/CoreEventTypes';
21
+ import {Touchable} from 'react-native/Libraries/Components/Touchable/Touchable';
22
+ import {AccessibilityProps} from './ViewAccessibility';
23
+
24
+ export type TVParallaxProperties = {
25
+ /**
26
+ * If true, parallax effects are enabled. Defaults to true.
27
+ */
28
+ enabled?: boolean | undefined;
29
+
30
+ /**
31
+ * Defaults to 2.0.
32
+ */
33
+ shiftDistanceX?: number | undefined;
34
+
35
+ /**
36
+ * Defaults to 2.0.
37
+ */
38
+ shiftDistanceY?: number | undefined;
39
+
40
+ /**
41
+ * Defaults to 0.05.
42
+ */
43
+ tiltAngle?: number | undefined;
44
+
45
+ /**
46
+ * Defaults to 1.0
47
+ */
48
+ magnification?: number | undefined;
49
+
50
+ /**
51
+ * Defaults to 1.0
52
+ */
53
+ pressMagnification?: number | undefined;
54
+
55
+ /**
56
+ * Defaults to 0.3
57
+ */
58
+ pressDuration?: number | undefined;
59
+
60
+ /**
61
+ * Defaults to 0.3
62
+ */
63
+ pressDelay?: number | undefined;
64
+ };
65
+
66
+ export interface TVViewPropsIOS {
67
+ /**
68
+ * *(Apple TV only)* When set to true, this view will be focusable
69
+ * and navigable using the Apple TV remote.
70
+ *
71
+ * @platform ios
72
+ */
73
+ isTVSelectable?: boolean | undefined;
74
+
75
+ /**
76
+ * *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view.
77
+ *
78
+ * @platform ios
79
+ */
80
+ hasTVPreferredFocus?: boolean | undefined;
81
+
82
+ /**
83
+ * *(Apple TV only)* Object with properties to control Apple TV parallax effects.
84
+ *
85
+ * @platform ios
86
+ */
87
+ tvParallaxProperties?: TVParallaxProperties | undefined;
88
+
89
+ /**
90
+ * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
91
+ *
92
+ * @platform ios
93
+ */
94
+ tvParallaxShiftDistanceX?: number | undefined;
95
+
96
+ /**
97
+ * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0.
98
+ *
99
+ * @platform ios
100
+ */
101
+ tvParallaxShiftDistanceY?: number | undefined;
102
+
103
+ /**
104
+ * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05.
105
+ *
106
+ * @platform ios
107
+ */
108
+ tvParallaxTiltAngle?: number | undefined;
109
+
110
+ /**
111
+ * *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0.
112
+ *
113
+ * @platform ios
114
+ */
115
+ tvParallaxMagnification?: number | undefined;
116
+ }
117
+
118
+ export interface ViewPropsIOS extends TVViewPropsIOS {
119
+ /**
120
+ * Whether this view should be rendered as a bitmap before compositing.
121
+ *
122
+ * On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children;
123
+ * for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view
124
+ * and quickly composite it during each frame.
125
+ *
126
+ * Rasterization incurs an off-screen drawing pass and the bitmap consumes memory.
127
+ * Test and measure when using this property.
128
+ */
129
+ shouldRasterizeIOS?: boolean | undefined;
130
+ }
131
+
132
+ export interface ViewPropsAndroid {
133
+ /**
134
+ * Views that are only used to layout their children or otherwise don't draw anything
135
+ * may be automatically removed from the native hierarchy as an optimization.
136
+ * Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy.
137
+ */
138
+ collapsable?: boolean | undefined;
139
+
140
+ /**
141
+ * Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior.
142
+ * The default (false) falls back to drawing the component and its children
143
+ * with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value.
144
+ * This default may be noticeable and undesired in the case where the View you are setting an opacity on
145
+ * has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background).
146
+ *
147
+ * Rendering offscreen to preserve correct alpha behavior is extremely expensive
148
+ * and hard to debug for non-native developers, which is why it is not turned on by default.
149
+ * If you do need to enable this property for an animation,
150
+ * consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame).
151
+ * If that property is enabled, this View will be rendered off-screen once,
152
+ * saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU.
153
+ */
154
+ needsOffscreenAlphaCompositing?: boolean | undefined;
155
+
156
+ /**
157
+ * Whether this view should render itself (and all of its children) into a single hardware texture on the GPU.
158
+ *
159
+ * On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale:
160
+ * in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be
161
+ * re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation.
162
+ */
163
+ renderToHardwareTextureAndroid?: boolean | undefined;
164
+
165
+ /**
166
+ * Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
167
+ */
168
+ focusable?: boolean | undefined;
169
+ }
170
+
171
+ // [Win32
172
+
173
+ export type Cursor =
174
+ | 'auto'
175
+ | 'default'
176
+ | 'pointer'
177
+ | 'help'
178
+ | 'not-allowed'
179
+ | 'wait'
180
+ | 'move'
181
+ | 'nesw-resize'
182
+ | 'ns-resize'
183
+ | 'nwse-resize'
184
+ | 'we-resize'
185
+ | 'text';
186
+
187
+ export interface INativeKeyboardEvent {
188
+ altKey: boolean;
189
+ ctrlKey: boolean;
190
+ metaKey: boolean;
191
+ shiftKey: boolean;
192
+ key: string;
193
+ }
194
+ export type IKeyboardEvent = NativeSyntheticEvent<INativeKeyboardEvent>;
195
+
196
+ // All of T becomes optional except for Keys
197
+ type PartiallyRequired<T, Keys extends keyof T = keyof T> = Pick<
198
+ Partial<T>,
199
+ Exclude<keyof T, Keys>
200
+ > &
201
+ Pick<T, Keys>;
202
+
203
+ export type IHandledKeyboardEvent = PartiallyRequired<
204
+ INativeKeyboardEvent,
205
+ 'key'
206
+ >;
207
+ // Win32]
208
+
209
+ export interface ViewPropsWin32 {
210
+ onKeyDown?: (args: IKeyboardEvent) => void;
211
+ onKeyDownCapture?: (args: IKeyboardEvent) => void;
212
+ onKeyUp?: (args: IKeyboardEvent) => void;
213
+ onKeyUpCapture?: (args: IKeyboardEvent) => void;
214
+
215
+ keyDownEvents?: IHandledKeyboardEvent[];
216
+ keyUpEvents?: IHandledKeyboardEvent[];
217
+
218
+ onMouseLeave?: ?((event: MouseEvent) => void);
219
+ onMouseEnter?: ?((event: MouseEvent) => void);
220
+
221
+ /**
222
+ * Specifies the Tooltip for the view
223
+ * @platform windows
224
+ */
225
+ tooltip?: ?string;
226
+
227
+ /**
228
+ * Tab Index
229
+ * @platform windows
230
+ */
231
+ tabIndex?: ?number;
232
+
233
+ /**
234
+ * Specifies if the control should show System focus visuals
235
+ */
236
+ enableFocusRing?: ?boolean;
237
+
238
+ /**
239
+ * The onBlur event occurs when an element loses focus. The opposite of onBlur is onFocus. Note that in React
240
+ * Native, unlike in the web, the onBlur event bubbles (similar to onFocusOut in the web).
241
+ *
242
+ * `ev.target === ev.currentTarget` when the focus is being lost from this component.
243
+ * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.
244
+ */
245
+ onBlur?: (ev: NativeSyntheticEvent<{}>) => void;
246
+ /**
247
+ * The onBlur event occurs when an element loses focus. The opposite of onBlur is onFocus. Note that in React
248
+ * Native, unlike in the web, the onBlur event bubbles (similar to onFocusOut in the web).
249
+ *
250
+ * `ev.target === ev.currentTarget` when the focus is being lost from this component.
251
+ * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.
252
+ */
253
+ onBlurCapture?: (ev: NativeSyntheticEvent<{}>) => void;
254
+ /**
255
+ * The onFocus event occurs when an element gets focus. The opposite of onFocus is onBlur. Note that in React
256
+ * Native, unlike in the web, the onFocus event bubbles (similar to onFocusIn in the web).
257
+ *
258
+ * `ev.target === ev.currentTarget` when the focus is being lost from this component.
259
+ * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.
260
+ */
261
+ onFocus?: (ev: NativeSyntheticEvent<{}>) => void;
262
+ /**
263
+ * The onFocus event occurs when an element gets focus. The opposite of onFocus is onBlur. Note that in React
264
+ * Native, unlike in the web, the onFocus event bubbles (similar to onFocusIn in the web).
265
+ *
266
+ * `ev.target === ev.currentTarget` when the focus is being lost from this component.
267
+ * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.
268
+ */
269
+ onFocusCapture?: (ev: NativeSyntheticEvent<{}>) => void;
270
+
271
+ cursor?: Cursor;
272
+
273
+ /**
274
+ * Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard.
275
+ */
276
+ focusable?: boolean | undefined;
277
+
278
+ /**
279
+ * Specified an AirSpace animation class to apply to this view
280
+ */
281
+ animationClass?: string;
282
+ }
283
+
284
+ /**
285
+ * @see https://reactnative.dev/docs/view#props
286
+ */
287
+ export interface ViewProps
288
+ extends ViewPropsAndroid,
289
+ ViewPropsIOS,
290
+ ViewPropsWin32,
291
+ GestureResponderHandlers,
292
+ Touchable,
293
+ PointerEvents,
294
+ AccessibilityProps {
295
+ children?: React.ReactNode;
296
+ /**
297
+ * This defines how far a touch event can start away from the view.
298
+ * Typical interface guidelines recommend touch targets that are at least
299
+ * 30 - 40 points/density-independent pixels. If a Touchable view has
300
+ * a height of 20 the touchable height can be extended to 40 with
301
+ * hitSlop={{top: 10, bottom: 10, left: 0, right: 0}}
302
+ * NOTE The touch area never extends past the parent view bounds and
303
+ * the Z-index of sibling views always takes precedence if a touch
304
+ * hits two overlapping views.
305
+ */
306
+ hitSlop?: Insets | undefined;
307
+
308
+ /**
309
+ * Used to reference react managed views from native code.
310
+ */
311
+ id?: string | undefined;
312
+
313
+ /**
314
+ * Invoked on mount and layout changes with
315
+ *
316
+ * {nativeEvent: { layout: {x, y, width, height}}}.
317
+ */
318
+ onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
319
+
320
+ /**
321
+ *
322
+ * In the absence of auto property, none is much like CSS's none value. box-none is as if you had applied the CSS class:
323
+ *
324
+ * .box-none {
325
+ * pointer-events: none;
326
+ * }
327
+ * .box-none * {
328
+ * pointer-events: all;
329
+ * }
330
+ *
331
+ * box-only is the equivalent of
332
+ *
333
+ * .box-only {
334
+ * pointer-events: all;
335
+ * }
336
+ * .box-only * {
337
+ * pointer-events: none;
338
+ * }
339
+ *
340
+ * But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes,
341
+ * we opt to not include pointerEvents on style. On some platforms, we would need to implement it as a className anyways. Using style or not is an implementation detail of the platform.
342
+ */
343
+ pointerEvents?: 'box-none' | 'none' | 'box-only' | 'auto' | undefined;
344
+
345
+ /**
346
+ *
347
+ * This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews,
348
+ * most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound.
349
+ * The subviews must also have overflow: hidden, as should the containing view (or one of its superviews).
350
+ */
351
+ removeClippedSubviews?: boolean | undefined;
352
+
353
+ style?: StyleProp<ViewStyle> | undefined;
354
+
355
+ /**
356
+ * Used to locate this view in end-to-end tests.
357
+ */
358
+ testID?: string | undefined;
359
+
360
+ /**
361
+ * Used to reference react managed views from native code.
362
+ */
363
+ nativeID?: string | undefined;
364
+ }
365
+
366
+ // For backwards compat.... // Win32
367
+ export interface IViewWin32 {
368
+ focus: () => void;
369
+ }
370
+
371
+ // For backwards compat.... // Win32
372
+ export type IViewWin32Props = ViewProps;
@@ -669,4 +669,27 @@ export type ViewProps = $ReadOnly<{|
669
669
  * See https://reactnative.dev/docs/view#removeclippedsubviews
670
670
  */
671
671
  removeClippedSubviews?: ?boolean,
672
+
673
+ /**
674
+ * Specifies the nativeID of the associated label text. When the assistive technology focuses on the component with this props, the text is read aloud.
675
+ *
676
+ * @platform win32
677
+ */
678
+ accessibilityDescribedBy?: ?string,
679
+
680
+ /**
681
+ * Legacy property replaced by accessibilityLabelledBy - here for backwards compat
682
+ *
683
+ * @platform win32
684
+ * @deprecated
685
+ */
686
+ // $FlowFixMe[unclear-type]
687
+ accessibilityLabeledBy?: any,
688
+
689
+ /**
690
+ * Specifies the nativeID of the control that controls this one.
691
+ *
692
+ * @platform win32
693
+ */
694
+ accessibilityControls?: ?string,
672
695
  |}>;
@@ -1,12 +1,30 @@
1
- /**
2
- * Copyright: Microsoft 2015
3
- *
4
- * RN-specific implementation of the cross-platform View abstraction.
5
- */
6
- import React from 'react';
7
- import { View } from 'react-native';
8
- import { IViewWin32Props } from './ViewWin32.Props';
9
- declare type ViewWin32Type = React.ForwardRefExoticComponent<IViewWin32Props & React.RefAttributes<View>> & View;
10
- export declare const ViewWin32: React.ForwardRefExoticComponent<IViewWin32Props & React.RefAttributes<any>>;
11
- export declare type ViewWin32 = ViewWin32Type;
12
- export {};
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @format
8
+ */
9
+
10
+ import type * as React from 'react';
11
+ import {Constructor} from 'react-native/types/private/Utilities';
12
+ import {ViewProps} from './ViewPropTypes';
13
+ import {NativeMethods} from 'react-native/types/public/ReactNativeTypes';
14
+
15
+ /**
16
+ * The most fundamental component for building UI, View is a container that supports layout with flexbox, style, some touch handling,
17
+ * and accessibility controls, and is designed to be nested inside other views and to have 0 to many children of any type.
18
+ * View maps directly to the native view equivalent on whatever platform React is running on,
19
+ * whether that is a UIView, <div>, android.view, etc.
20
+ */
21
+ declare class ViewWin32Component extends React.Component<ViewProps> {}
22
+ declare const ViewWin32Base: Constructor<NativeMethods> &
23
+ typeof ViewWin32Component;
24
+ export class ViewWin32 extends ViewWin32Base {
25
+ /**
26
+ * Is 3D Touch / Force Touch available (i.e. will touch events include `force`)
27
+ * @platform ios
28
+ */
29
+ static forceTouchAvailable: boolean;
30
+ }
@@ -1,71 +1,161 @@
1
- "use strict";
2
- /**
3
- * Copyright: Microsoft 2015
4
- *
5
- * RN-specific implementation of the cross-platform View abstraction.
6
- */
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
9
- };
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.ViewWin32 = void 0;
12
- const react_1 = __importDefault(require("react"));
13
- const react_native_1 = require("react-native");
14
- const setAndForwardRef = require('../../Utilities/setAndForwardRef');
15
- exports.ViewWin32 = react_1.default.forwardRef((props, ref) => {
16
- /**
17
- * Check for raw text in the DOM.
18
- */
19
- if (__DEV__) {
20
- if (props) {
21
- react_1.default.Children.toArray(props.children).forEach(item => {
22
- if (typeof item === 'string') {
23
- console.error(`Unexpected text node: ${item}. A text node cannot be a child of a <View>.`);
24
- }
25
- });
26
- }
27
- }
28
- /**
29
- * Process accessibility refs into node handles after initial DOM render, before sent across the bridge.
30
- * useLayoutEffect will invalidate the render to assess the ref-based accessibility properties.
31
- */
32
- const [labeledByTarget, setLabeledByTarget] = react_1.default.useState(null);
33
- const [describedByTarget, setDescribedByTarget] = react_1.default.useState(null);
34
- const [controlsTarget, setControlsTarget] = react_1.default.useState(null);
35
- const { accessibilityLabeledBy, accessibilityDescribedBy, accessibilityControls, ...rest } = props;
36
- react_1.default.useLayoutEffect(() => {
37
- if (accessibilityLabeledBy !== undefined && accessibilityLabeledBy.current !== null) {
38
- setLabeledByTarget((0, react_native_1.findNodeHandle)(accessibilityLabeledBy.current));
39
- }
40
- }, [accessibilityLabeledBy]);
41
- react_1.default.useLayoutEffect(() => {
42
- if (accessibilityDescribedBy !== undefined && accessibilityDescribedBy.current !== null) {
43
- setDescribedByTarget((0, react_native_1.findNodeHandle)(accessibilityDescribedBy.current));
44
- }
45
- }, [accessibilityDescribedBy]);
46
- react_1.default.useLayoutEffect(() => {
47
- if (accessibilityControls !== undefined && accessibilityControls.current !== null) {
48
- setControlsTarget((0, react_native_1.findNodeHandle)(accessibilityControls.current));
49
- }
50
- }, [accessibilityControls]);
51
- /**
52
- * Set up the forwarding ref to enable adding the focus method.
53
- */
54
- const focusRef = react_1.default.useRef();
55
- const setNativeRef = setAndForwardRef({
56
- getForwardedRef: () => ref,
57
- setLocalRef: localRef => {
58
- focusRef.current = localRef;
59
- /**
60
- * Add focus() as a callable function to the forwarded reference.
61
- */
62
- if (localRef) {
63
- localRef.focus = () => {
64
- react_native_1.UIManager.dispatchViewManagerCommand((0, react_native_1.findNodeHandle)(localRef), react_native_1.UIManager.getViewManagerConfig('RCTView').Commands.focus, null);
65
- };
66
- }
67
- },
68
- });
69
- return react_1.default.createElement(react_native_1.View, { ref: setNativeRef, ...rest, ...((controlsTarget !== null) ? { accessibilityControls: controlsTarget } : {}), ...((labeledByTarget !== null) ? { accessibilityLabeledBy: labeledByTarget } : {}), ...((describedByTarget !== null) ? { accessibilityDescribedBy: describedByTarget } : {}) });
70
- });
71
- //# sourceMappingURL=ViewWin32.js.map
1
+ /**
2
+ * Copyright: Microsoft 2015
3
+ *
4
+ * RN-specific implementation of the cross-platform View abstraction.
5
+ *
6
+ * @flow strict-local
7
+ * @format
8
+ */
9
+
10
+ import * as React from 'react';
11
+ import {useCallback, useRef, useLayoutEffect} from 'react';
12
+ import type {ViewProps} from './ViewPropTypes';
13
+
14
+ import View from './View';
15
+ import {findNodeHandle} from '../../ReactNative/RendererProxy';
16
+ import UIManager from '../../ReactNative/UIManager';
17
+ import useMergeRefs from '../../Utilities/useMergeRefs';
18
+ import warnOnce from '../../Utilities/warnOnce';
19
+
20
+ /**
21
+ * Basic View component with additional Win32 specific functionality
22
+ */
23
+
24
+ const ViewWin32: React.AbstractComponent<
25
+ ViewProps,
26
+ React.ElementRef<typeof View>,
27
+ > = React.forwardRef(
28
+ (
29
+ {
30
+ accessibilityLabeledBy,
31
+ accessibilityDescribedBy,
32
+ accessibilityControls,
33
+ ...rest
34
+ }: ViewProps,
35
+ forwardedRef,
36
+ ) => {
37
+ /**
38
+ * Process accessibility refs into node handles after initial DOM render, before sent across the bridge.
39
+ * useLayoutEffect will invalidate the render to assess the ref-based accessibility properties.
40
+ *
41
+ * RN core moved these properties to use NativeID instead of Refs, so this is only kept for back compat
42
+ */
43
+
44
+ const [labeledByTarget, setLabeledByTarget] = React.useState<
45
+ number | null | void,
46
+ >(null);
47
+ const [describedByTarget, setDescribedByTarget] = React.useState<
48
+ number | null | void,
49
+ >(null);
50
+ const [controlsTarget, setControlsTarget] = React.useState<
51
+ number | null | void,
52
+ >(null);
53
+
54
+ useLayoutEffect(() => {
55
+ if (
56
+ accessibilityLabeledBy !== undefined &&
57
+ accessibilityLabeledBy.current !== null
58
+ ) {
59
+ warnOnce(
60
+ 'accessibilityLabeledByAsRef',
61
+ 'accessibilityLabeledBy has been deprecated. Instead use accessibilityLabelledBy (double L), and specify it as a string matching the nativeID of the target component. Support of specifying accessibilityLabeledBy will be removed in a future release',
62
+ );
63
+ setLabeledByTarget(findNodeHandle(accessibilityLabeledBy.current));
64
+ }
65
+ }, [accessibilityLabeledBy]);
66
+
67
+ useLayoutEffect(() => {
68
+ if (
69
+ typeof accessibilityDescribedBy !== 'string' &&
70
+ accessibilityDescribedBy !== undefined &&
71
+ // $FlowFixMe[incompatible-use] - Using accessibilityDescribedBy as Ref for backcompat, not typed
72
+ // $FlowFixMe[prop-missing]
73
+ accessibilityDescribedBy.current !== null
74
+ ) {
75
+ warnOnce(
76
+ 'accessibilityDescribedByRef',
77
+ 'accessibilityDescribedBy should be specfied as a string matching the nativeID of the target component. Support of specifying accessibilityDescribedBy using a ref is deprecated and will be removed in a future release',
78
+ );
79
+ // $FlowFixMe[incompatible-use] - Using accessibilityDescribedBy as Ref for backcompat, not typed
80
+ // $FlowFixMe[prop-missing]
81
+ setDescribedByTarget(findNodeHandle(accessibilityDescribedBy.current));
82
+ }
83
+ }, [accessibilityDescribedBy]);
84
+
85
+ useLayoutEffect(() => {
86
+ if (
87
+ typeof accessibilityControls !== 'string' &&
88
+ accessibilityControls !== undefined &&
89
+ // $FlowFixMe[incompatible-use] - Using accessibilityControls as Ref for backcompat, not typed
90
+ // $FlowFixMe[prop-missing]
91
+ accessibilityControls.current !== null
92
+ ) {
93
+ warnOnce(
94
+ 'accessibilityControlsRef',
95
+ 'accessibilityControls should be specfied as a string matching the nativeID of the target component. Support of specifying accessibilityControls using a ref is deprecated and will be removed in a future release',
96
+ );
97
+ // $FlowFixMe[incompatible-use] - Using accessibilityControls as Ref for backcompat, not typed
98
+ // $FlowFixMe[prop-missing]
99
+ setControlsTarget(findNodeHandle(accessibilityControls.current));
100
+ }
101
+ }, [accessibilityControls]);
102
+
103
+ /**
104
+ * Set up the forwarding ref to enable adding the focus method.
105
+ */
106
+ const focusRef = useRef<typeof View | null>(null);
107
+
108
+ const setLocalRef = useCallback(
109
+ (instance: typeof View | null) => {
110
+ focusRef.current = instance;
111
+ /**
112
+ * Add focus() as a callable function to the forwarded reference.
113
+ */
114
+ if (instance) {
115
+ // $FlowFixMe[prop-missing] - TODO - focus on a component should already call into TextInputState.focus.. once we remove the refs required for legacy accessibility*By ref support
116
+ instance.focus = () => {
117
+ UIManager.dispatchViewManagerCommand(
118
+ findNodeHandle(instance),
119
+ UIManager.getViewManagerConfig('RCTView').Commands.focus,
120
+ null,
121
+ );
122
+ };
123
+ }
124
+ },
125
+ [focusRef],
126
+ );
127
+
128
+ // $FlowFixMe
129
+ const setNativeRef = useMergeRefs<typeof View | null>({
130
+ setLocalRef,
131
+ forwardedRef,
132
+ });
133
+
134
+ return (
135
+ <View
136
+ ref={setNativeRef}
137
+ {...rest}
138
+ {...(controlsTarget !== null
139
+ ? {accessibilityControls: controlsTarget}
140
+ : {})}
141
+ {...(labeledByTarget !== null
142
+ ? {accessibilityLabeledBy: labeledByTarget}
143
+ : {})}
144
+ {...(describedByTarget !== null
145
+ ? // $FlowFixMe[exponential-spread]
146
+ {accessibilityDescribedBy: describedByTarget}
147
+ : // $FlowFixMe[exponential-spread]
148
+ typeof accessibilityDescribedBy === 'string'
149
+ ? {accessibilityDescribedBy}
150
+ : {})}
151
+ {...(typeof accessibilityControls === 'string'
152
+ ? {accessibilityControls}
153
+ : {})}
154
+ />
155
+ );
156
+ },
157
+ );
158
+
159
+ ViewWin32.displayName = 'ViewWin32';
160
+
161
+ module.exports = ViewWin32;
@@ -25,7 +25,6 @@ import ImageInjection from './ImageInjection';
25
25
  import {getImageSourcesFromImageProps} from './ImageSourceUtils';
26
26
  import {convertObjectFitToResizeMode} from './ImageUtils';
27
27
  import ImageViewNativeComponent from './ImageViewNativeComponent';
28
- import NativeImageLoaderIOS from './NativeImageLoaderIOS';
29
28
  import resolveAssetSource from './resolveAssetSource';
30
29
  import * as React from 'react';
31
30