@office-iss/react-native-win32 0.64.9 → 0.64.10

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 CHANGED
@@ -12,6 +12,7 @@
12
12
  <PROJECT_ROOT>/Libraries/Alert/Alert.js
13
13
  <PROJECT_ROOT>/Libraries/Components/AccessibilityInfo/NativeAccessibilityInfo.js
14
14
  <PROJECT_ROOT>/Libraries/Components/Picker/Picker.js
15
+ <PROJECT_ROOT>/Libraries/Components/Pressable/Pressable.js
15
16
  <PROJECT_ROOT>/Libraries/Components/SafeAreaView/SafeAreaView.js
16
17
  <PROJECT_ROOT>/Libraries/Components/TextInput/TextInput.js
17
18
  <PROJECT_ROOT>/Libraries/Components/TextInput/TextInputState.js
@@ -19,11 +20,15 @@
19
20
  <PROJECT_ROOT>/Libraries/Components/View/ReactNativeViewAttributes.js
20
21
  <PROJECT_ROOT>/Libraries/Components/View/ReactNativeViewViewConfig.js
21
22
  <PROJECT_ROOT>/Libraries/Components/View/View.js
23
+ <PROJECT_ROOT>/Libraries/Components/View/ViewPropTypes.js
22
24
  <PROJECT_ROOT>/Libraries/Image/Image.js
23
25
  <PROJECT_ROOT>/Libraries/Inspector/Inspector.js
24
26
  <PROJECT_ROOT>/Libraries/Inspector/InspectorOverlay.js
25
27
  <PROJECT_ROOT>/Libraries/Network/RCTNetworking.js
28
+ <PROJECT_ROOT>/Libraries/Pressability/Pressability.js
29
+ <PROJECT_ROOT>/Libraries/Pressability/HoverState.js
26
30
  <PROJECT_ROOT>/Libraries/StyleSheet/StyleSheet.js
31
+ <PROJECT_ROOT>/Libraries/Types/CoreEventTypes.js
27
32
  <PROJECT_ROOT>/Libraries/Utilities/DeviceInfo.js
28
33
  <PROJECT_ROOT>/Libraries/Utilities/Dimensions.js
29
34
 
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@office-iss/react-native-win32",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 15 Nov 2021 16:08:58 GMT",
5
+ "date": "Mon, 17 Jan 2022 16:09:50 GMT",
6
+ "tag": "@office-iss/react-native-win32_v0.64.10",
7
+ "version": "0.64.10",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Port windows pressable with extra desktop support to win32",
12
+ "author": "saadnajmi2@gmail.com",
13
+ "commit": "acfb47a7924f4d4e34e020838423bbbab026d670",
14
+ "package": "@office-iss/react-native-win32"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 15 Nov 2021 16:09:20 GMT",
6
21
  "tag": "@office-iss/react-native-win32_v0.64.9",
7
22
  "version": "0.64.9",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Change Log - @office-iss/react-native-win32
2
2
 
3
- This log was last generated on Mon, 15 Nov 2021 16:08:58 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 17 Jan 2022 16:09:50 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.64.9
7
+ ## 0.64.10
8
8
 
9
- Mon, 15 Nov 2021 16:08:58 GMT
9
+ Mon, 17 Jan 2022 16:09:50 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Add enableFocusRing prop for View and test (ruaraki@microsoft.com)
13
+ - Port windows pressable with extra desktop support to win32 (saadnajmi2@gmail.com)
14
14
 
15
+ ## 0.64.9
16
+
17
+ Mon, 15 Nov 2021 16:09:20 GMT
18
+
19
+ ### Patches
20
+
21
+ - Add enableFocusRing prop for View and test (ruaraki@microsoft.com)
22
+
15
23
  ## 0.64.8
16
24
 
17
25
  Mon, 25 Oct 2021 15:07:12 GMT
@@ -0,0 +1,333 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its 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
+ * @flow strict-local
8
+ * @format
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ import * as React from 'react';
14
+ import {useMemo, useState, useRef, useImperativeHandle} from 'react';
15
+ import useAndroidRippleForView, {
16
+ type RippleConfig,
17
+ } from './useAndroidRippleForView';
18
+ import type {
19
+ AccessibilityActionEvent,
20
+ AccessibilityActionInfo,
21
+ AccessibilityRole,
22
+ AccessibilityState,
23
+ AccessibilityValue,
24
+ } from '../View/ViewAccessibility';
25
+ import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
26
+ import usePressability from '../../Pressability/usePressability';
27
+ import {normalizeRect, type RectOrSize} from '../../StyleSheet/Rect';
28
+ import type {
29
+ LayoutEvent,
30
+ PressEvent,
31
+ // [Windows
32
+ MouseEvent,
33
+ BlurEvent,
34
+ FocusEvent, // Windows]
35
+ } from '../../Types/CoreEventTypes';
36
+ import View from '../View/View';
37
+ import TextInputState from '../TextInput/TextInputState';
38
+
39
+ type ViewStyleProp = $ElementType<React.ElementConfig<typeof View>, 'style'>;
40
+
41
+ export type StateCallbackType = $ReadOnly<{|
42
+ pressed: boolean,
43
+ |}>;
44
+
45
+ type Props = $ReadOnly<{|
46
+ /**
47
+ * Accessibility.
48
+ */
49
+ accessibilityActions?: ?$ReadOnlyArray<AccessibilityActionInfo>,
50
+ accessibilityElementsHidden?: ?boolean,
51
+ accessibilityHint?: ?Stringish,
52
+ accessibilityIgnoresInvertColors?: ?boolean,
53
+ accessibilityLabel?: ?Stringish,
54
+ accessibilityLiveRegion?: ?('none' | 'polite' | 'assertive'),
55
+ accessibilityRole?: ?AccessibilityRole,
56
+ accessibilityState?: ?AccessibilityState,
57
+ accessibilityValue?: ?AccessibilityValue,
58
+ accessibilityViewIsModal?: ?boolean,
59
+ accessible?: ?boolean,
60
+ focusable?: ?boolean,
61
+ importantForAccessibility?: ?('auto' | 'yes' | 'no' | 'no-hide-descendants'),
62
+ onAccessibilityAction?: ?(event: AccessibilityActionEvent) => mixed,
63
+
64
+ /**
65
+ * Either children or a render prop that receives a boolean reflecting whether
66
+ * the component is currently pressed.
67
+ */
68
+ children: React.Node | ((state: StateCallbackType) => React.Node),
69
+
70
+ /**
71
+ * Duration to wait after hover in before calling `onHoverIn`.
72
+ */
73
+ delayHoverIn?: ?number,
74
+
75
+ /**
76
+ * Duration to wait after hover out before calling `onHoverOut`.
77
+ */
78
+ delayHoverOut?: ?number,
79
+
80
+ /**
81
+ * Duration (in milliseconds) from `onPressIn` before `onLongPress` is called.
82
+ */
83
+ delayLongPress?: ?number,
84
+
85
+ /**
86
+ * Whether the press behavior is disabled.
87
+ */
88
+ disabled?: ?boolean,
89
+
90
+ /**
91
+ * Additional distance outside of this view in which a press is detected.
92
+ */
93
+ hitSlop?: ?RectOrSize,
94
+
95
+ /**
96
+ * Additional distance outside of this view in which a touch is considered a
97
+ * press before `onPressOut` is triggered.
98
+ */
99
+ pressRetentionOffset?: ?RectOrSize,
100
+
101
+ /**
102
+ * Called when this view's layout changes.
103
+ */
104
+ onLayout?: ?(event: LayoutEvent) => void,
105
+
106
+ /**
107
+ * Called when the hover is activated to provide visual feedback.
108
+ */
109
+ onHoverIn?: ?(event: MouseEvent) => mixed,
110
+
111
+ /**
112
+ * Called when the hover is deactivated to undo visual feedback.
113
+ */
114
+ onHoverOut?: ?(event: MouseEvent) => mixed,
115
+
116
+ /**
117
+ * Called when a long-tap gesture is detected.
118
+ */
119
+ onLongPress?: ?(event: PressEvent) => void,
120
+
121
+ /**
122
+ * Called when a single tap gesture is detected.
123
+ */
124
+ onPress?: ?(event: PressEvent) => void,
125
+
126
+ /**
127
+ * Called when a touch is engaged before `onPress`.
128
+ */
129
+ onPressIn?: ?(event: PressEvent) => void,
130
+
131
+ /**
132
+ * Called when a touch is released before `onPress`.
133
+ */
134
+ onPressOut?: ?(event: PressEvent) => void,
135
+
136
+ /**
137
+ * Called after the element loses focus.
138
+ */
139
+ onBlur?: ?(event: BlurEvent) => mixed,
140
+
141
+ /**
142
+ * Called after the element is focused.
143
+ */
144
+ onFocus?: ?(event: FocusEvent) => mixed,
145
+
146
+ /**
147
+ * Either view styles or a function that receives a boolean reflecting whether
148
+ * the component is currently pressed and returns view styles.
149
+ */
150
+ style?: ViewStyleProp | ((state: StateCallbackType) => ViewStyleProp),
151
+
152
+ /**
153
+ * Identifier used to find this view in tests.
154
+ */
155
+ testID?: ?string,
156
+
157
+ /**
158
+ * If true, doesn't play system sound on touch.
159
+ */
160
+ android_disableSound?: ?boolean,
161
+
162
+ /**
163
+ * Enables the Android ripple effect and configures its color.
164
+ */
165
+ android_ripple?: ?RippleConfig,
166
+
167
+ /**
168
+ * Used only for documentation or testing (e.g. snapshot testing).
169
+ */
170
+ testOnly_pressed?: ?boolean,
171
+
172
+ /**
173
+ * Duration to wait after press down before calling `onPressIn`.
174
+ */
175
+ unstable_pressDelay?: ?number,
176
+ |}>;
177
+
178
+ /**
179
+ * Component used to build display components that should respond to whether the
180
+ * component is currently pressed or not.
181
+ */
182
+ function Pressable(props: Props, forwardedRef): React.Node {
183
+ const {
184
+ accessible,
185
+ android_disableSound,
186
+ android_ripple,
187
+ children,
188
+ delayHoverIn,
189
+ delayHoverOut,
190
+ delayLongPress,
191
+ disabled,
192
+ focusable,
193
+ onHoverIn,
194
+ onHoverOut,
195
+ onLongPress,
196
+ onPress,
197
+ onPressIn,
198
+ onPressOut,
199
+ // [Windows
200
+ onBlur,
201
+ onFocus,
202
+ // Windows]
203
+ pressRetentionOffset,
204
+ style,
205
+ testOnly_pressed,
206
+ unstable_pressDelay,
207
+ ...restProps
208
+ } = props;
209
+
210
+ const viewRef = useRef<React.ElementRef<typeof View> | null>(null);
211
+ useImperativeHandle(forwardedRef, () => viewRef.current);
212
+
213
+ // [Windows
214
+ const _onBlur = (event: BlurEvent) => {
215
+ TextInputState.blurInput(viewRef.current);
216
+ if (props.onBlur) {
217
+ props.onBlur(event);
218
+ }
219
+ };
220
+
221
+ const _onFocus = (event: FocusEvent) => {
222
+ TextInputState.focusInput(viewRef.current);
223
+ if (props.onFocus) {
224
+ props.onFocus(event);
225
+ }
226
+ };
227
+ // Windows]
228
+
229
+ const android_rippleConfig = useAndroidRippleForView(android_ripple, viewRef);
230
+
231
+ const [pressed, setPressed] = usePressState(testOnly_pressed === true);
232
+
233
+ const hitSlop = normalizeRect(props.hitSlop);
234
+
235
+ const restPropsWithDefaults: React.ElementConfig<typeof View> = {
236
+ ...restProps,
237
+ ...android_rippleConfig?.viewProps,
238
+ accessible: accessible !== false,
239
+ focusable: focusable !== false,
240
+ hitSlop,
241
+ };
242
+
243
+ const config = useMemo(
244
+ () => ({
245
+ disabled,
246
+ hitSlop,
247
+ pressRectOffset: pressRetentionOffset,
248
+ android_disableSound,
249
+ delayHoverIn,
250
+ delayHoverOut,
251
+ delayLongPress,
252
+ delayPressIn: unstable_pressDelay,
253
+ onHoverIn,
254
+ onHoverOut,
255
+ onLongPress,
256
+ onPress,
257
+ onPressIn(event: PressEvent): void {
258
+ if (android_rippleConfig != null) {
259
+ android_rippleConfig.onPressIn(event);
260
+ }
261
+ setPressed(true);
262
+ if (onPressIn != null) {
263
+ onPressIn(event);
264
+ }
265
+ },
266
+ onPressMove: android_rippleConfig?.onPressMove,
267
+ onPressOut(event: PressEvent): void {
268
+ if (android_rippleConfig != null) {
269
+ android_rippleConfig.onPressOut(event);
270
+ }
271
+ setPressed(false);
272
+ if (onPressOut != null) {
273
+ onPressOut(event);
274
+ }
275
+ },
276
+ // [Windows
277
+ onBlur,
278
+ onFocus,
279
+ // Windows]
280
+ }),
281
+ [
282
+ android_disableSound,
283
+ android_rippleConfig,
284
+ delayHoverIn,
285
+ delayHoverOut,
286
+ delayLongPress,
287
+ disabled,
288
+ hitSlop,
289
+ onHoverIn,
290
+ onHoverOut,
291
+ onLongPress,
292
+ onPress,
293
+ onPressIn,
294
+ onPressOut,
295
+ // [Windows
296
+ onBlur,
297
+ onFocus,
298
+ // Windows]
299
+ pressRetentionOffset,
300
+ setPressed,
301
+ unstable_pressDelay,
302
+ ],
303
+ );
304
+ const eventHandlers = usePressability(config);
305
+
306
+ return (
307
+ <View
308
+ {...restPropsWithDefaults}
309
+ {...eventHandlers}
310
+ // [Windows
311
+ onBlur={_onBlur}
312
+ onFocus={_onFocus}
313
+ // Windows]
314
+ ref={viewRef}
315
+ style={typeof style === 'function' ? style({pressed}) : style}>
316
+ {typeof children === 'function' ? children({pressed}) : children}
317
+ {__DEV__ ? <PressabilityDebugView color="red" hitSlop={hitSlop} /> : null}
318
+ </View>
319
+ );
320
+ }
321
+
322
+ function usePressState(forcePressed: boolean): [boolean, (boolean) => void] {
323
+ const [pressed, setPressed] = useState(false);
324
+ return [pressed || forcePressed, setPressed];
325
+ }
326
+
327
+ const MemoedPressable = React.memo(React.forwardRef(Pressable));
328
+ MemoedPressable.displayName = 'Pressable';
329
+
330
+ export default (MemoedPressable: React.AbstractComponent<
331
+ Props,
332
+ React.ElementRef<typeof View>,
333
+ >);
@@ -15,7 +15,6 @@ import type {ViewProps} from './ViewPropTypes';
15
15
  const React = require('react');
16
16
  import ViewNativeComponent from './ViewNativeComponent';
17
17
  const TextAncestor = require('../../Text/TextAncestor');
18
- import warnOnce from '../../Utilities/warnOnce'; // [Windows]
19
18
  import invariant from 'invariant'; // [Windows]
20
19
 
21
20
  export type Props = ViewProps;
@@ -31,16 +30,14 @@ const View: React.AbstractComponent<
31
30
  ViewProps,
32
31
  React.ElementRef<typeof ViewNativeComponent>,
33
32
  > = React.forwardRef((props: ViewProps, forwardedRef) => {
34
- // [Win32 Intercept props to warn about them going away
33
+ // [Windows
34
+ invariant(
35
+ // $FlowFixMe Wanting to catch untyped usages
36
+ !props || props.acceptsKeyboardFocus === undefined,
37
+ 'Support for the "acceptsKeyboardFocus" property has been removed in favor of "focusable"',
38
+ );
39
+ // Windows]
35
40
 
36
- // $FlowFixMe react-native-win32 doesn't have forked types in Flow yet
37
- if (props.acceptsKeyboardFocus !== undefined) {
38
- warnOnce(
39
- 'deprecated-acceptsKeyboardFocus',
40
- '"acceptsKeyboardFocus" has been deprecated in favor of "focusable" and will be removed soon',
41
- );
42
- }
43
- // Win32]
44
41
  return (
45
42
  // [Windows
46
43
  // In core this is a TextAncestor.Provider value={false} See
@@ -52,10 +49,10 @@ const View: React.AbstractComponent<
52
49
  !hasTextAncestor,
53
50
  'Nesting of <View> within <Text> is not currently supported.',
54
51
  );
55
-
56
52
  return <ViewNativeComponent {...props} ref={forwardedRef} />;
57
53
  }}
58
54
  </TextAncestor.Consumer>
55
+ // Windows]
59
56
  );
60
57
  });
61
58