@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/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var $goTMa$reactariautils = require("@react-aria/utils");
|
|
2
2
|
var $goTMa$react = require("react");
|
|
3
|
+
var $goTMa$reactariassr = require("@react-aria/ssr");
|
|
3
4
|
|
|
4
5
|
function $parcel$export(e, n, v, s) {
|
|
5
6
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -794,7 +795,9 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
794
795
|
]);
|
|
795
796
|
const onSyntheticFocus = (0, $625cf83917e112ad$export$715c682d09d639cc)(onBlur);
|
|
796
797
|
const onFocus = (0, $goTMa$react.useCallback)((e)=>{
|
|
797
|
-
|
|
798
|
+
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
799
|
+
// focus handler already moved focus somewhere else.
|
|
800
|
+
if (e.target === e.currentTarget && document.activeElement === e.target) {
|
|
798
801
|
if (onFocusProp) onFocusProp(e);
|
|
799
802
|
if (onFocusChange) onFocusChange(true);
|
|
800
803
|
onSyntheticFocus(e);
|
|
@@ -807,7 +810,7 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
807
810
|
return {
|
|
808
811
|
focusProps: {
|
|
809
812
|
onFocus: !isDisabled && (onFocusProp || onFocusChange || onBlurProp) ? onFocus : undefined,
|
|
810
|
-
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur :
|
|
813
|
+
onBlur: !isDisabled && (onBlurProp || onFocusChange) ? onBlur : undefined
|
|
811
814
|
}
|
|
812
815
|
};
|
|
813
816
|
}
|
|
@@ -829,6 +832,7 @@ function $5cb73d0ce355b0dc$export$f8168d8dd8fd66e6(props) {
|
|
|
829
832
|
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
830
833
|
|
|
831
834
|
|
|
835
|
+
|
|
832
836
|
let $e77252a287ef94ab$var$currentModality = null;
|
|
833
837
|
let $e77252a287ef94ab$var$changeHandlers = new Set();
|
|
834
838
|
let $e77252a287ef94ab$var$hasSetupGlobalListeners = false;
|
|
@@ -945,7 +949,7 @@ function $e77252a287ef94ab$export$98e20ec92f614cfe() {
|
|
|
945
949
|
$e77252a287ef94ab$var$changeHandlers.delete(handler);
|
|
946
950
|
};
|
|
947
951
|
}, []);
|
|
948
|
-
return modality;
|
|
952
|
+
return (0, $goTMa$reactariassr.useIsSSR)() ? null : modality;
|
|
949
953
|
}
|
|
950
954
|
/**
|
|
951
955
|
* If this is attached to text input component, return if the event is a focus event (Tab/Escape keys pressed) so that
|
|
@@ -1020,7 +1024,9 @@ function $d16842bbd0359d1b$export$420e68273165f4ec(props) {
|
|
|
1020
1024
|
]);
|
|
1021
1025
|
let onSyntheticFocus = (0, $625cf83917e112ad$export$715c682d09d639cc)(onBlur);
|
|
1022
1026
|
let onFocus = (0, $goTMa$react.useCallback)((e)=>{
|
|
1023
|
-
|
|
1027
|
+
// Double check that document.activeElement actually matches e.target in case a previously chained
|
|
1028
|
+
// focus handler already moved focus somewhere else.
|
|
1029
|
+
if (!state.current.isFocusWithin && document.activeElement === e.target) {
|
|
1024
1030
|
if (onFocusWithin) onFocusWithin(e);
|
|
1025
1031
|
if (onFocusWithinChange) onFocusWithinChange(true);
|
|
1026
1032
|
state.current.isFocusWithin = true;
|
|
@@ -1216,10 +1222,8 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1216
1222
|
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
1217
1223
|
if (typeof PointerEvent !== "undefined") {
|
|
1218
1224
|
let onPointerUp = (e)=>{
|
|
1219
|
-
if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref))
|
|
1220
|
-
|
|
1221
|
-
state.onInteractOutside(e);
|
|
1222
|
-
}
|
|
1225
|
+
if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1226
|
+
state.isPointerDown = false;
|
|
1223
1227
|
};
|
|
1224
1228
|
// changing these to capture phase fixed combobox
|
|
1225
1229
|
document.addEventListener("pointerdown", onPointerDown, true);
|
|
@@ -1231,17 +1235,13 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1231
1235
|
} else {
|
|
1232
1236
|
let onMouseUp = (e)=>{
|
|
1233
1237
|
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
1234
|
-
else if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref))
|
|
1235
|
-
|
|
1236
|
-
state.onInteractOutside(e);
|
|
1237
|
-
}
|
|
1238
|
+
else if (state.isPointerDown && state.onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1239
|
+
state.isPointerDown = false;
|
|
1238
1240
|
};
|
|
1239
1241
|
let onTouchEnd = (e)=>{
|
|
1240
1242
|
state.ignoreEmulatedMouseEvents = true;
|
|
1241
|
-
if (state.onInteractOutside && state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref))
|
|
1242
|
-
|
|
1243
|
-
state.onInteractOutside(e);
|
|
1244
|
-
}
|
|
1243
|
+
if (state.onInteractOutside && state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) state.onInteractOutside(e);
|
|
1244
|
+
state.isPointerDown = false;
|
|
1245
1245
|
};
|
|
1246
1246
|
document.addEventListener("mousedown", onPointerDown, true);
|
|
1247
1247
|
document.addEventListener("mouseup", onMouseUp, true);
|
|
@@ -1262,10 +1262,12 @@ function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
|
1262
1262
|
}
|
|
1263
1263
|
function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
|
|
1264
1264
|
if (event.button > 0) return false;
|
|
1265
|
-
// if the event target is no longer in the document
|
|
1266
1265
|
if (event.target) {
|
|
1266
|
+
// if the event target is no longer in the document, ignore
|
|
1267
1267
|
const ownerDocument = event.target.ownerDocument;
|
|
1268
1268
|
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
1269
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
1270
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
1269
1271
|
}
|
|
1270
1272
|
return ref.current && !ref.current.contains(event.target);
|
|
1271
1273
|
}
|