react-native-macos 0.74.3 → 0.74.4

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.
@@ -12,7 +12,12 @@
12
12
 
13
13
  import type {TextStyleProp, ViewStyleProp} from '../StyleSheet/StyleSheet';
14
14
  import type {PressEvent} from '../Types/CoreEventTypes';
15
- import type {BlurEvent, FocusEvent, KeyEvent} from '../Types/CoreEventTypes'; // [macOS]
15
+ import type {
16
+ BlurEvent,
17
+ FocusEvent,
18
+ HandledKeyEvent,
19
+ KeyEvent,
20
+ } from '../Types/CoreEventTypes'; // [macOS]
16
21
  import type {
17
22
  AccessibilityActionEvent,
18
23
  AccessibilityActionInfo,
@@ -177,17 +182,45 @@ type ButtonProps = $ReadOnly<{|
177
182
  onKeyUp?: ?(e: KeyEvent) => void,
178
183
 
179
184
  /*
185
+ * @deprecated use `keyDownEvents` or `keyUpEvents` instead
180
186
  * Array of keys to receive key down events for
181
187
  * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
182
188
  */
183
189
  validKeysDown?: ?Array<string>,
184
190
 
185
191
  /*
192
+ * @deprecated use `keyDownEvents` or `keyUpEvents` instead
186
193
  * Array of keys to receive key up events for
187
194
  * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
188
195
  */
189
196
  validKeysUp?: ?Array<string>,
190
197
 
198
+ /**
199
+ * @deprecated use `keyDownEvents` or `keyUpEvents` instead
200
+ * When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
201
+ * `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
202
+ * are still removed from the event queue, but the others are not.
203
+ *
204
+ * @platform macos
205
+ */
206
+ passthroughAllKeyEvents?: ?boolean,
207
+
208
+ /**
209
+ * Array of keys to receive key down events for. These events have their default native behavior prevented.
210
+ * Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
211
+ *
212
+ * @platform macos
213
+ */
214
+ keyDownEvents?: ?Array<HandledKeyEvent>,
215
+
216
+ /**
217
+ * Array of keys to receive key up events for. These events have their default native behavior prevented.
218
+ * Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
219
+ *
220
+ * @platform macos
221
+ */
222
+ keyUpEvents?: ?Array<HandledKeyEvent>,
223
+
191
224
  /*
192
225
  * Specifies the Tooltip for the view
193
226
  */
@@ -365,8 +398,6 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
365
398
  onBlur,
366
399
  onKeyDown,
367
400
  onKeyUp,
368
- validKeysDown,
369
- validKeysUp,
370
401
  tooltip,
371
402
  // macOS]
372
403
  } = props;
@@ -441,10 +472,6 @@ const Button: React.AbstractComponent<ButtonProps> = (props: ButtonProps) => {
441
472
  // [macOS
442
473
  onFocus={onFocus}
443
474
  onBlur={onBlur}
444
- onKeyDown={onKeyDown}
445
- onKeyUp={onKeyUp}
446
- validKeysDown={validKeysDown}
447
- validKeysUp={validKeysUp}
448
475
  tooltip={tooltip}
449
476
  // macOS]
450
477
  touchSoundDisabled={touchSoundDisabled}>
@@ -12,6 +12,7 @@ import type {
12
12
  BlurEvent,
13
13
  // [macOS
14
14
  FocusEvent,
15
+ HandledKeyEvent,
15
16
  KeyEvent,
16
17
  LayoutEvent,
17
18
  MouseEvent,
@@ -26,7 +27,6 @@ import type {
26
27
  AccessibilityState,
27
28
  AccessibilityValue,
28
29
  } from '../View/ViewAccessibility';
29
- import type {HandledKeyboardEvent} from '../View/ViewPropTypes'; // [macOS]
30
30
 
31
31
  import {PressabilityDebugView} from '../../Pressability/PressabilityDebug';
32
32
  import usePressability from '../../Pressability/usePressability';
@@ -187,9 +187,24 @@ type Props = $ReadOnly<{|
187
187
  onKeyUp?: ?(event: KeyEvent) => void,
188
188
 
189
189
  /**
190
+ * Array of keys to receive key down events for. These events have their default native behavior prevented.
191
+ *
192
+ * @platform macos
193
+ */
194
+ validKeysDown?: ?Array<string | HandledKeyEvent>,
195
+
196
+ /**
197
+ * Array of keys to receive key up events for. These events have their default native behavior prevented.
198
+ *
199
+ * @platform macos
200
+ */
201
+ validKeysUp?: ?Array<string | HandledKeyEvent>,
202
+
203
+ /**
204
+ * @deprecated use `keyDownEvents` or `keyUpEvents` instead
190
205
  * When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
191
206
  * `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
192
- * still have their native default behavior prevented, but the others do not.
207
+ * are still removed from the event queue, but the others are not.
193
208
  *
194
209
  * @platform macos
195
210
  */
@@ -197,17 +212,19 @@ type Props = $ReadOnly<{|
197
212
 
198
213
  /**
199
214
  * Array of keys to receive key down events for. These events have their default native behavior prevented.
215
+ * Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
200
216
  *
201
217
  * @platform macos
202
218
  */
203
- validKeysDown?: ?Array<string | HandledKeyboardEvent>,
219
+ keyDownEvents?: ?Array<HandledKeyEvent>,
204
220
 
205
221
  /**
206
222
  * Array of keys to receive key up events for. These events have their default native behavior prevented.
223
+ * Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
207
224
  *
208
225
  * @platform macos
209
226
  */
210
- validKeysUp?: ?Array<string | HandledKeyboardEvent>,
227
+ keyUpEvents?: ?Array<HandledKeyEvent>,
211
228
 
212
229
  /**
213
230
  * Specifies whether the view should receive the mouse down event when the
@@ -357,6 +374,9 @@ function Pressable(props: Props, forwardedRef): React.Node {
357
374
  onBlur,
358
375
  onKeyDown,
359
376
  onKeyUp,
377
+ passthroughAllKeyEvents,
378
+ keyDownEvents,
379
+ keyUpEvents,
360
380
  acceptsFirstMouse,
361
381
  mouseDownCanMoveWindow,
362
382
  enableFocusRing,
@@ -397,6 +417,7 @@ function Pressable(props: Props, forwardedRef): React.Node {
397
417
  ariaLive === 'off' ? 'none' : ariaLive ?? props.accessibilityLiveRegion;
398
418
 
399
419
  const accessibilityLabel = ariaLabel ?? props.accessibilityLabel;
420
+
400
421
  const restPropsWithDefaults: React.ElementConfig<typeof View> = {
401
422
  ...restProps,
402
423
  ...android_rippleConfig?.viewProps,
@@ -78,18 +78,6 @@ type Props = $ReadOnly<{|
78
78
  */
79
79
  nextFocusUp?: ?number,
80
80
 
81
- /*
82
- * Array of keys to receive key down events for
83
- * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
84
- */
85
- validKeysDown?: ?Array<string>,
86
-
87
- /*
88
- * Array of keys to receive key up events for
89
- * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
90
- */
91
- validKeysUp?: ?Array<string>,
92
-
93
81
  /**
94
82
  * Set to true to add the ripple effect to the foreground of the view, instead
95
83
  * of the background. This is useful if one of your child views has a
@@ -343,8 +331,6 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
343
331
  nextFocusUp: this.props.nextFocusUp,
344
332
  onLayout: this.props.onLayout,
345
333
  testID: this.props.testID,
346
- validKeysDown: this.props.validKeysDown,
347
- validKeysUp: this.props.validKeysUp,
348
334
  },
349
335
  ...children,
350
336
  );
@@ -38,20 +38,6 @@ type Props = $ReadOnly<{|
38
38
  style?: ?ViewStyleProp,
39
39
 
40
40
  hostRef?: ?React.Ref<typeof Animated.View>,
41
-
42
- // [macOS
43
- /*
44
- * Array of keys to receive key down events for
45
- * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
46
- */
47
- validKeysDown?: ?Array<string>,
48
-
49
- /*
50
- * Array of keys to receive key up events for
51
- * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
52
- */
53
- validKeysUp?: ?Array<string>,
54
- // macOS]
55
41
  |}>;
56
42
 
57
43
  type State = $ReadOnly<{|
@@ -178,18 +164,6 @@ class TouchableOpacity extends React.Component<Props, State> {
178
164
  this.props.onFocus(event);
179
165
  }
180
166
  },
181
- onKeyDown: event => {
182
- if (this.props.onKeyDown != null) {
183
- this.props.onKeyDown(event);
184
- }
185
- },
186
- onKeyUp: event => {
187
- if (this.props.onKeyUp != null) {
188
- this.props.onKeyUp(event);
189
- }
190
- },
191
- validKeysDown: this.props.validKeysDown,
192
- validKeysUp: this.props.validKeysUp,
193
167
  onLongPress: this.props.onLongPress,
194
168
  onPress: this.props.onPress,
195
169
  onPressIn: event => {
@@ -95,10 +95,6 @@ type Props = $ReadOnly<{|
95
95
  onDragLeave?: (event: MouseEvent) => void,
96
96
  onDrop?: (event: MouseEvent) => void,
97
97
  draggedTypes?: ?DraggedTypesType,
98
- onKeyDown?: ?(event: KeyEvent) => void,
99
- onKeyUp?: ?(event: KeyEvent) => void,
100
- validKeysDown?: ?Array<string>,
101
- validKeysUp?: ?Array<string>,
102
98
  // macOS]
103
99
  pressRetentionOffset?: ?EdgeInsetsOrSizeProp,
104
100
  rejectResponderTermination?: ?boolean,
@@ -132,8 +128,6 @@ const PASSTHROUGH_PROPS = [
132
128
  'onAccessibilityAction',
133
129
  'onBlur',
134
130
  'onFocus',
135
- 'validKeysDown',
136
- 'validKeysUp',
137
131
  'onLayout',
138
132
  'onMouseEnter', // [macOS
139
133
  'onMouseLeave',
@@ -257,10 +251,6 @@ function createPressabilityConfig({
257
251
  android_disableSound: props.touchSoundDisabled,
258
252
  onBlur: props.onBlur,
259
253
  onFocus: props.onFocus,
260
- onKeyDown: props.onKeyDown,
261
- onKeyUp: props.onKeyUp,
262
- validKeysDown: props.validKeysDown,
263
- validKeysUp: props.validKeysUp,
264
254
  onLongPress: props.onLongPress,
265
255
  onPress: props.onPress,
266
256
  onPressIn: props.onPressIn,
@@ -48,9 +48,11 @@ const UIView = {
48
48
  onDrop: true,
49
49
  onKeyDown: true,
50
50
  onKeyUp: true,
51
- passthroughAllKeyEvents: true,
52
51
  validKeysDown: true,
53
52
  validKeysUp: true,
53
+ passthroughAllKeyEvents: true,
54
+ keyDownEvents: true,
55
+ keyUpEvents: true,
54
56
  draggedTypes: true,
55
57
  // macOS]
56
58
  };
@@ -55,6 +55,13 @@ const View: React.AbstractComponent<
55
55
  nativeID,
56
56
  pointerEvents,
57
57
  tabIndex,
58
+ // [macOS
59
+ passthroughAllKeyEvents,
60
+ validKeysDown,
61
+ validKeysUp,
62
+ keyDownEvents,
63
+ keyUpEvents,
64
+ // macOS]
58
65
  ...otherProps
59
66
  }: ViewProps,
60
67
  forwardedRef,
@@ -102,6 +109,19 @@ const View: React.AbstractComponent<
102
109
  // $FlowFixMe[sketchy-null-mixed]
103
110
  const newPointerEvents = style?.pointerEvents || pointerEvents;
104
111
 
112
+ // [macOS
113
+ let _passthroughAllKeyEvents = passthroughAllKeyEvents;
114
+ let _validKeysDown = validKeysDown;
115
+ let _validKeysUp = validKeysUp;
116
+ if (keyDownEvents || keyUpEvents) {
117
+ _passthroughAllKeyEvents = true;
118
+ // $FlowFixMe[incompatible-type]
119
+ _validKeysDown = keyDownEvents;
120
+ // $FlowFixMe[incompatible-type]
121
+ _validKeysUp = keyUpEvents;
122
+ }
123
+ // macOS]
124
+
105
125
  const actualView = (
106
126
  <ViewNativeComponent
107
127
  {...otherProps}
@@ -123,6 +143,11 @@ const View: React.AbstractComponent<
123
143
  style={style}
124
144
  // $FlowFixMe[incompatible-type]
125
145
  pointerEvents={newPointerEvents}
146
+ // [macOS
147
+ passthroughAllKeyEvents={_passthroughAllKeyEvents}
148
+ validKeysDown={_validKeysDown}
149
+ validKeysUp={_validKeysUp}
150
+ // macOS]
126
151
  ref={forwardedRef}
127
152
  />
128
153
  );
@@ -13,6 +13,7 @@ import {GestureResponderHandlers} from '../../../types/public/ReactNativeRendere
13
13
  import {StyleProp} from '../../StyleSheet/StyleSheet';
14
14
  import {ViewStyle} from '../../StyleSheet/StyleSheetTypes';
15
15
  import {
16
+ HandledKeyEvent,
16
17
  KeyEvent,
17
18
  LayoutChangeEvent,
18
19
  MouseEvent,
@@ -178,8 +179,11 @@ export interface ViewPropsMacOS {
178
179
  onDrop?: ((event: MouseEvent) => void) | undefined;
179
180
  onKeyDown?: ((event: KeyEvent) => void) | undefined;
180
181
  onKeyUp?: ((event: KeyEvent) => void) | undefined;
181
- validKeysDown?: string[] | undefined;
182
- validKeysUp?: string[] | undefined;
182
+ validKeysDown?: Array<HandledKeyEvent | string> | undefined;
183
+ validKeysUp?: Array<HandledKeyEvent | string> | undefined;
184
+ passthroughAllKeyEvents?: boolean | undefined;
185
+ keyDownEvents?: Array<HandledKeyEvent> | undefined;
186
+ keyUpEvents?: Array<HandledKeyEvent> | undefined;
183
187
  draggedTypes?: DraggedTypesType | undefined;
184
188
  }
185
189
 
@@ -16,6 +16,7 @@ import type {
16
16
  BlurEvent,
17
17
  FocusEvent,
18
18
  // [macOS]
19
+ HandledKeyEvent,
19
20
  KeyEvent,
20
21
  Layout,
21
22
  LayoutEvent,
@@ -99,26 +100,6 @@ type DirectEventProps = $ReadOnly<{|
99
100
  onAccessibilityEscape?: ?() => mixed,
100
101
  |}>;
101
102
 
102
- // [macOS
103
- /**
104
- * Represents a key that could be passed to `validKeysDown` and `validKeysUp`.
105
- *
106
- * `key` is the actual key, such as "a", or one of the special values:
107
- * "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
108
- * "Backspace", "Delete", "Home", "End", "PageUp", "PageDown".
109
- *
110
- * The rest are modifiers that when absent mean false.
111
- *
112
- * @platform macos
113
- */
114
- export type HandledKeyboardEvent = $ReadOnly<{|
115
- altKey?: ?boolean,
116
- ctrlKey?: ?boolean,
117
- metaKey?: ?boolean,
118
- shiftKey?: ?boolean,
119
- key: string,
120
- |}>;
121
-
122
103
  export type KeyboardEventProps = $ReadOnly<{|
123
104
  /**
124
105
  * Called after a key down event is detected.
@@ -131,6 +112,21 @@ export type KeyboardEventProps = $ReadOnly<{|
131
112
  onKeyUp?: ?(event: KeyEvent) => void,
132
113
 
133
114
  /**
115
+ * Array of keys to receive key down events for. These events have their default native behavior prevented.
116
+ *
117
+ * @platform macos
118
+ */
119
+ validKeysDown?: ?Array<string | HandledKeyEvent>,
120
+
121
+ /**
122
+ * Array of keys to receive key up events for. These events have their default native behavior prevented.
123
+ *
124
+ * @platform macos
125
+ */
126
+ validKeysUp?: ?Array<string | HandledKeyEvent>,
127
+
128
+ /**
129
+ * @deprecated use `keyDownEvents` or `keyUpEvents` instead
134
130
  * When `true`, allows `onKeyDown` and `onKeyUp` to receive events not specified in
135
131
  * `validKeysDown` and `validKeysUp`, respectively. Events matching `validKeysDown` and `validKeysUp`
136
132
  * are still removed from the event queue, but the others are not.
@@ -141,17 +137,19 @@ export type KeyboardEventProps = $ReadOnly<{|
141
137
 
142
138
  /**
143
139
  * Array of keys to receive key down events for. These events have their default native behavior prevented.
140
+ * Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
144
141
  *
145
142
  * @platform macos
146
143
  */
147
- validKeysDown?: ?Array<string | HandledKeyboardEvent>,
144
+ keyDownEvents?: ?Array<HandledKeyEvent>,
148
145
 
149
146
  /**
150
147
  * Array of keys to receive key up events for. These events have their default native behavior prevented.
148
+ * Overrides the props `validKeysDown`, `validKeysUp` and `passthroughAllKeyEvents`
151
149
  *
152
150
  * @platform macos
153
151
  */
154
- validKeysUp?: ?Array<string | HandledKeyboardEvent>,
152
+ keyUpEvents?: ?Array<HandledKeyEvent>,
155
153
  |}>;
156
154
  // macOS]
157
155
 
@@ -16,7 +16,7 @@ const version: $ReadOnly<{
16
16
  }> = {
17
17
  major: 0,
18
18
  minor: 74,
19
- patch: 3,
19
+ patch: 4,
20
20
  prerelease: null,
21
21
  };
22
22
 
@@ -53,9 +53,11 @@ const validAttributesForNonEventProps = {
53
53
  draggedTypes: true,
54
54
  enableFocusRing: true,
55
55
  tooltip: true,
56
- passthroughAllKeyEvents: true,
57
56
  validKeysDown: true,
58
57
  validKeysUp: true,
58
+ passthroughAllKeyEvents: true,
59
+ keyDownEvents: true,
60
+ keyUpEvents: true,
59
61
  mouseDownCanMoveWindow: true,
60
62
  };
61
63
 
@@ -98,6 +98,7 @@ export type PressabilityConfig = $ReadOnly<{|
98
98
  */
99
99
  onFocus?: ?(event: FocusEvent) => void,
100
100
 
101
+ // [macOS
101
102
  /*
102
103
  * Called after a key down event is detected.
103
104
  */
@@ -107,18 +108,7 @@ export type PressabilityConfig = $ReadOnly<{|
107
108
  * Called after a key up event is detected.
108
109
  */
109
110
  onKeyUp?: ?(event: KeyEvent) => void,
110
-
111
- /*
112
- * Array of keys to receive key down events for
113
- * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
114
- */
115
- validKeysDown?: ?Array<string>,
116
-
117
- /*
118
- * Array of keys to receive key up events for
119
- * For arrow keys, add "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
120
- */
121
- validKeysUp?: ?Array<string>,
111
+ // macOS]
122
112
 
123
113
  /**
124
114
  * Called when the hover is activated to provide visual feedback.
@@ -284,6 +284,25 @@ export interface NativeKeyEvent {
284
284
  key: string;
285
285
  }
286
286
 
287
+ /**
288
+ * Represents a key that could be passed to `validKeysDown` and `validKeysUp`.
289
+ *
290
+ * `key` is the actual key, such as "a", or one of the special values:
291
+ * "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
292
+ * "Backspace", "Delete", "Home", "End", "PageUp", "PageDown".
293
+ *
294
+ * The rest are modifiers that when absent mean false.
295
+ *
296
+ * @platform macos
297
+ */
298
+ export type HandledKeyEvent = {
299
+ altKey?: boolean | undefined;
300
+ ctrlKey?: boolean | undefined;
301
+ metaKey?: boolean | undefined;
302
+ shiftKey?: boolean | undefined;
303
+ key: string;
304
+ };
305
+
287
306
  export interface KeyEvent extends NativeSyntheticEvent<NativeKeyEvent> {}
288
307
 
289
308
  export interface NativeFocusEvent extends TargetedEvent {}
@@ -308,6 +308,26 @@ export type KeyEvent = SyntheticEvent<
308
308
  key: string,
309
309
  |}>,
310
310
  >;
311
+
312
+ /**
313
+ * Represents a key that could be passed to `validKeysDown` and `validKeysUp`.
314
+ *
315
+ * `key` is the actual key, such as "a", or one of the special values:
316
+ * "Tab", "Escape", "Enter", "ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown",
317
+ * "Backspace", "Delete", "Home", "End", "PageUp", "PageDown".
318
+ *
319
+ * The rest are modifiers that when absent mean false.
320
+ *
321
+ * @platform macos
322
+ */
323
+ export type HandledKeyEvent = $ReadOnly<{|
324
+ altKey?: ?boolean,
325
+ ctrlKey?: ?boolean,
326
+ metaKey?: ?boolean,
327
+ shiftKey?: ?boolean,
328
+ key: string,
329
+ |}>;
330
+
311
331
  // macOS]
312
332
 
313
333
  export type MouseEvent = SyntheticEvent<
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(74),
26
- RCTVersionPatch: @(3),
26
+ RCTVersionPatch: @(4),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.74.3
1
+ VERSION_NAME=0.74.4
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 74,
20
- "patch", 3,
20
+ "patch", 4,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 74;
20
- int32_t Patch = 3;
20
+ int32_t Patch = 4;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.74.3",
3
+ "version": "0.74.4",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {