@react-aria/interactions 3.0.0-nightly.2693 → 3.0.0-nightly.2697

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/dist/import.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {useObjectRef as $bx7SL$useObjectRef, mergeProps as $bx7SL$mergeProps, useSyncRef as $bx7SL$useSyncRef, useGlobalListeners as $bx7SL$useGlobalListeners, useEffectEvent as $bx7SL$useEffectEvent, getOwnerDocument as $bx7SL$getOwnerDocument, isMac as $bx7SL$isMac, openLink as $bx7SL$openLink, isVirtualClick as $bx7SL$isVirtualClick, focusWithoutScrolling as $bx7SL$focusWithoutScrolling, isVirtualPointerEvent as $bx7SL$isVirtualPointerEvent, getOwnerWindow as $bx7SL$getOwnerWindow, isIOS as $bx7SL$isIOS, runAfterTransition as $bx7SL$runAfterTransition, useLayoutEffect as $bx7SL$useLayoutEffect, useEvent as $bx7SL$useEvent, useDescription as $bx7SL$useDescription} from "@react-aria/utils";
1
+ import {useObjectRef as $bx7SL$useObjectRef, mergeProps as $bx7SL$mergeProps, useSyncRef as $bx7SL$useSyncRef, useGlobalListeners as $bx7SL$useGlobalListeners, useEffectEvent as $bx7SL$useEffectEvent, getOwnerDocument as $bx7SL$getOwnerDocument, chain as $bx7SL$chain, isMac as $bx7SL$isMac, openLink as $bx7SL$openLink, isVirtualClick as $bx7SL$isVirtualClick, focusWithoutScrolling as $bx7SL$focusWithoutScrolling, isVirtualPointerEvent as $bx7SL$isVirtualPointerEvent, getOwnerWindow as $bx7SL$getOwnerWindow, isIOS as $bx7SL$isIOS, runAfterTransition as $bx7SL$runAfterTransition, useLayoutEffect as $bx7SL$useLayoutEffect, useEvent as $bx7SL$useEvent, useDescription as $bx7SL$useDescription} from "@react-aria/utils";
2
2
  import $bx7SL$react, {useContext as $bx7SL$useContext, useState as $bx7SL$useState, useRef as $bx7SL$useRef, useMemo as $bx7SL$useMemo, useEffect as $bx7SL$useEffect, useCallback as $bx7SL$useCallback} from "react";
3
3
  import {_ as $bx7SL$_} from "@swc/helpers/_/_class_private_field_get";
4
4
  import {_ as $bx7SL$_1} from "@swc/helpers/_/_class_private_field_init";
@@ -43,6 +43,7 @@ import {useIsSSR as $bx7SL$useIsSSR} from "@react-aria/ssr";
43
43
 
44
44
 
45
45
 
46
+
46
47
  /*
47
48
  * Copyright 2020 Adobe. All rights reserved.
48
49
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -110,7 +111,6 @@ function $14c0b72509d70225$export$b0d6fa1ab32e3295(target) {
110
111
  }
111
112
 
112
113
 
113
-
114
114
  /*
115
115
  * Copyright 2020 Adobe. All rights reserved.
116
116
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -261,8 +261,13 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
261
261
  state.isPressed = true;
262
262
  shouldStopPropagation = triggerPressStart(e, "keyboard");
263
263
  // Focus may move before the key up event, so register the event on the document
264
- // instead of the same element where the key down event occurred.
265
- addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "keyup", onKeyUp, false);
264
+ // instead of the same element where the key down event occurred. Make it capturing so that it will trigger
265
+ // before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.
266
+ let originalTarget = e.currentTarget;
267
+ let pressUp = (e)=>{
268
+ if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && originalTarget.contains(e.target) && state.target) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard");
269
+ };
270
+ addGlobalListener((0, $bx7SL$getOwnerDocument)(e.currentTarget), "keyup", (0, $bx7SL$chain)(pressUp, onKeyUp), true);
266
271
  }
267
272
  if (shouldStopPropagation) e.stopPropagation();
268
273
  // Keep track of the keydown events that occur while the Meta (e.g. Command) key is held.
@@ -275,9 +280,6 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
275
280
  if (e.metaKey && (0, $bx7SL$isMac)()) (_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.set(e.key, e.nativeEvent);
276
281
  } else if (e.key === "Meta") state.metaKeyEvents = new Map();
277
282
  },
278
- onKeyUp (e) {
279
- if ($f6c31cce2adf654f$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target) && state.target) triggerPressUp($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard");
280
- },
281
283
  onClick (e) {
282
284
  if (e && !e.currentTarget.contains(e.target)) return;
283
285
  if (e && e.button === 0 && !state.isTriggeringEvent && !(0, $bx7SL$openLink).isOpening) {
@@ -305,9 +307,8 @@ function $f6c31cce2adf654f$export$45712eceda6fad21(props) {
305
307
  var _state_metaKeyEvents1;
306
308
  if ($f6c31cce2adf654f$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
307
309
  let target = e.target;
308
- let shouldStopPropagation = triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
310
+ triggerPressEnd($f6c31cce2adf654f$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
309
311
  removeAllGlobalListeners();
310
- if (shouldStopPropagation) e.stopPropagation();
311
312
  // If a link was triggered with a key other than Enter, open the URL ourselves.
312
313
  // This means the link has a role override, and the default browser behavior
313
314
  // only applies when using the Enter key.
package/dist/main.js CHANGED
@@ -70,6 +70,7 @@ $parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$export$c2
70
70
 
71
71
 
72
72
 
73
+
73
74
  /*
74
75
  * Copyright 2020 Adobe. All rights reserved.
75
76
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -137,7 +138,6 @@ function $f7e14e656343df57$export$b0d6fa1ab32e3295(target) {
137
138
  }
138
139
 
139
140
 
140
-
141
141
  /*
142
142
  * Copyright 2020 Adobe. All rights reserved.
143
143
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -288,8 +288,13 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
288
288
  state.isPressed = true;
289
289
  shouldStopPropagation = triggerPressStart(e, "keyboard");
290
290
  // Focus may move before the key up event, so register the event on the document
291
- // instead of the same element where the key down event occurred.
292
- addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "keyup", onKeyUp, false);
291
+ // instead of the same element where the key down event occurred. Make it capturing so that it will trigger
292
+ // before stopPropagation from useKeyboard on a child element may happen and thus we can still call triggerPress for the parent element.
293
+ let originalTarget = e.currentTarget;
294
+ let pressUp = (e)=>{
295
+ if ($0294ea432cd92340$var$isValidKeyboardEvent(e, originalTarget) && !e.repeat && originalTarget.contains(e.target) && state.target) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), "keyboard");
296
+ };
297
+ addGlobalListener((0, $goTMa$reactariautils.getOwnerDocument)(e.currentTarget), "keyup", (0, $goTMa$reactariautils.chain)(pressUp, onKeyUp), true);
293
298
  }
294
299
  if (shouldStopPropagation) e.stopPropagation();
295
300
  // Keep track of the keydown events that occur while the Meta (e.g. Command) key is held.
@@ -302,9 +307,6 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
302
307
  if (e.metaKey && (0, $goTMa$reactariautils.isMac)()) (_state_metaKeyEvents = state.metaKeyEvents) === null || _state_metaKeyEvents === void 0 ? void 0 : _state_metaKeyEvents.set(e.key, e.nativeEvent);
303
308
  } else if (e.key === "Meta") state.metaKeyEvents = new Map();
304
309
  },
305
- onKeyUp (e) {
306
- if ($0294ea432cd92340$var$isValidKeyboardEvent(e.nativeEvent, e.currentTarget) && !e.repeat && e.currentTarget.contains(e.target) && state.target) triggerPressUp($0294ea432cd92340$var$createEvent(state.target, e), "keyboard");
307
- },
308
310
  onClick (e) {
309
311
  if (e && !e.currentTarget.contains(e.target)) return;
310
312
  if (e && e.button === 0 && !state.isTriggeringEvent && !(0, $goTMa$reactariautils.openLink).isOpening) {
@@ -332,9 +334,8 @@ function $0294ea432cd92340$export$45712eceda6fad21(props) {
332
334
  var _state_metaKeyEvents1;
333
335
  if ($0294ea432cd92340$var$shouldPreventDefaultKeyboard(e.target, e.key)) e.preventDefault();
334
336
  let target = e.target;
335
- let shouldStopPropagation = triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
337
+ triggerPressEnd($0294ea432cd92340$var$createEvent(state.target, e), "keyboard", state.target.contains(target));
336
338
  removeAllGlobalListeners();
337
- if (shouldStopPropagation) e.stopPropagation();
338
339
  // If a link was triggered with a key other than Enter, open the URL ourselves.
339
340
  // This means the link has a role override, and the default browser behavior
340
341
  // only applies when using the Enter key.