@react-aria/interactions 3.13.1 → 3.15.0
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 +1634 -0
- package/dist/main.js +19 -17
- package/dist/main.js.map +1 -1
- package/dist/module.js +19 -17
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/package.json +10 -4
- package/src/useFocus.ts +12 -10
- package/src/useFocusVisible.ts +2 -1
- package/src/useFocusWithin.ts +3 -1
- package/src/useInteractOutside.ts +9 -4
- package/src/utils.ts +7 -7
package/dist/module.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {mergeProps as $bx7SL$mergeProps, useSyncRef as $bx7SL$useSyncRef, useGlobalListeners as $bx7SL$useGlobalListeners, isVirtualClick as $bx7SL$isVirtualClick, focusWithoutScrolling as $bx7SL$focusWithoutScrolling, isVirtualPointerEvent as $bx7SL$isVirtualPointerEvent, isIOS as $bx7SL$isIOS, runAfterTransition as $bx7SL$runAfterTransition, useLayoutEffect as $bx7SL$useLayoutEffect, isMac as $bx7SL$isMac, useEvent as $bx7SL$useEvent, useDescription as $bx7SL$useDescription} from "@react-aria/utils";
|
|
2
2
|
import $bx7SL$react, {useRef as $bx7SL$useRef, useContext as $bx7SL$useContext, useState as $bx7SL$useState, useMemo as $bx7SL$useMemo, useEffect as $bx7SL$useEffect, useCallback as $bx7SL$useCallback} from "react";
|
|
3
|
+
import {useIsSSR as $bx7SL$useIsSSR} from "@react-aria/ssr";
|
|
3
4
|
|
|
4
5
|
/*
|
|
5
6
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -770,7 +771,9 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
770
771
|
]);
|
|
771
772
|
const onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
772
773
|
const onFocus = (0, $bx7SL$useCallback)((e)=>{
|
|
773
|
-
|
|
774
|
+
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
775
|
+
// focus handler already moved focus somewhere else.
|
|
776
|
+
if (e.target === e.currentTarget && document.activeElement === e.target) {
|
|
774
777
|
if (onFocusProp) onFocusProp(e);
|
|
775
778
|
if (onFocusChange) onFocusChange(true);
|
|
776
779
|
onSyntheticFocus(e);
|
|
@@ -783,7 +786,7 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
783
786
|
return {
|
|
784
787
|
focusProps: {
|
|
785
788
|
onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
|
|
786
|
-
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur :
|
|
789
|
+
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
|
|
787
790
|
}
|
|
788
791
|
};
|
|
789
792
|
}
|
|
@@ -805,6 +808,7 @@ function $a1ea59d68270f0dd$export$f8168d8dd8fd66e6(props) {
|
|
|
805
808
|
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
806
809
|
|
|
807
810
|
|
|
811
|
+
|
|
808
812
|
let $507fabe10e71c6fb$var$currentModality = null;
|
|
809
813
|
let $507fabe10e71c6fb$var$changeHandlers = new Set();
|
|
810
814
|
let $507fabe10e71c6fb$var$hasSetupGlobalListeners = false;
|
|
@@ -921,7 +925,7 @@ function $507fabe10e71c6fb$export$98e20ec92f614cfe() {
|
|
|
921
925
|
$507fabe10e71c6fb$var$changeHandlers.delete(handler);
|
|
922
926
|
};
|
|
923
927
|
}, []);
|
|
924
|
-
return modality;
|
|
928
|
+
return (0, $bx7SL$useIsSSR)() ? null : modality;
|
|
925
929
|
}
|
|
926
930
|
/**
|
|
927
931
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
@@ -996,7 +1000,9 @@ function $9ab94262bd0047c7$export$420e68273165f4ec(props) {
|
|
|
996
1000
|
]);
|
|
997
1001
|
let onSyntheticFocus = (0, $8a9cb279dc87e130$export$715c682d09d639cc)(onBlur);
|
|
998
1002
|
let onFocus = (0, $bx7SL$useCallback)((e)=>{
|
|
999
|
-
|
|
1003
|
+
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
1004
|
+
// focus handler already moved focus somewhere else.
|
|
1005
|
+
if (!state.current.isFocusWithin && document.activeElement === e.target) {
|
|
1000
1006
|
if (onFocusWithin) onFocusWithin(e);
|
|
1001
1007
|
if (onFocusWithinChange) onFocusWithinChange(true);
|
|
1002
1008
|
state.current.isFocusWithin = true;
|
|
@@ -1192,10 +1198,8 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1192
1198
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
1193
1199
|
if (typeof PointerEvent !== "undefined") {
|
|
1194
1200
|
let onPointerUp = (e)=>{
|
|
1195
|
-
if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref))
|
|
1196
|
-
|
|
1197
|
-
state.onInteractOutside(e);
|
|
1198
|
-
}
|
|
1201
|
+
if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1202
|
+
state.isPointerDown = false;
|
|
1199
1203
|
};
|
|
1200
1204
|
// changing these to capture phase fixed combobox
|
|
1201
1205
|
document.addEventListener("pointerdown", onPointerDown, true);
|
|
@@ -1207,17 +1211,13 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1207
1211
|
} else {
|
|
1208
1212
|
let onMouseUp = (e)=>{
|
|
1209
1213
|
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
1210
|
-
else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref))
|
|
1211
|
-
|
|
1212
|
-
state.onInteractOutside(e);
|
|
1213
|
-
}
|
|
1214
|
+
else if (state.isPointerDown && state.onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1215
|
+
state.isPointerDown = false;
|
|
1214
1216
|
};
|
|
1215
1217
|
let onTouchEnd = (e)=>{
|
|
1216
1218
|
state.ignoreEmulatedMouseEvents = true;
|
|
1217
|
-
if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref))
|
|
1218
|
-
|
|
1219
|
-
state.onInteractOutside(e);
|
|
1220
|
-
}
|
|
1219
|
+
if (state.onInteractOutside && state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1220
|
+
state.isPointerDown = false;
|
|
1221
1221
|
};
|
|
1222
1222
|
document.addEventListener("mousedown", onPointerDown, true);
|
|
1223
1223
|
document.addEventListener("mouseup", onMouseUp, true);
|
|
@@ -1238,10 +1238,12 @@ function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
|
1238
1238
|
}
|
|
1239
1239
|
function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
|
|
1240
1240
|
if (event.button > 0) return false;
|
|
1241
|
-
// if the event target is no longer in the document
|
|
1242
1241
|
if (event.target) {
|
|
1242
|
+
// if the event target is no longer in the document, ignore
|
|
1243
1243
|
const ownerDocument = event.target.ownerDocument;
|
|
1244
1244
|
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
1245
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
1246
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
1245
1247
|
}
|
|
1246
1248
|
return ref.current && !ref.current.contains(event.target);
|
|
1247
1249
|
}
|