@react-aria/interactions 3.21.1 → 3.21.2
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/PressResponder.main.js +62 -0
- package/dist/PressResponder.main.js.map +1 -0
- package/dist/PressResponder.mjs +52 -0
- package/dist/PressResponder.module.js +52 -0
- package/dist/PressResponder.module.js.map +1 -0
- package/dist/Pressable.main.js +43 -0
- package/dist/Pressable.main.js.map +1 -0
- package/dist/Pressable.mjs +34 -0
- package/dist/Pressable.module.js +34 -0
- package/dist/Pressable.module.js.map +1 -0
- package/dist/context.main.js +30 -0
- package/dist/context.main.js.map +1 -0
- package/dist/context.mjs +21 -0
- package/dist/context.module.js +21 -0
- package/dist/context.module.js.map +1 -0
- package/dist/createEventHandler.main.js +42 -0
- package/dist/createEventHandler.main.js.map +1 -0
- package/dist/createEventHandler.mjs +37 -0
- package/dist/createEventHandler.module.js +37 -0
- package/dist/createEventHandler.module.js.map +1 -0
- package/dist/import.mjs +12 -1771
- package/dist/main.js +31 -1794
- package/dist/main.js.map +1 -1
- package/dist/module.js +12 -1771
- package/dist/module.js.map +1 -1
- package/dist/textSelection.main.js +77 -0
- package/dist/textSelection.main.js.map +1 -0
- package/dist/textSelection.mjs +71 -0
- package/dist/textSelection.module.js +71 -0
- package/dist/textSelection.module.js.map +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/useFocus.main.js +64 -0
- package/dist/useFocus.main.js.map +1 -0
- package/dist/useFocus.mjs +59 -0
- package/dist/useFocus.module.js +59 -0
- package/dist/useFocus.module.js.map +1 -0
- package/dist/useFocusVisible.main.js +248 -0
- package/dist/useFocusVisible.main.js.map +1 -0
- package/dist/useFocusVisible.mjs +237 -0
- package/dist/useFocusVisible.module.js +237 -0
- package/dist/useFocusVisible.module.js.map +1 -0
- package/dist/useFocusWithin.main.js +76 -0
- package/dist/useFocusWithin.main.js.map +1 -0
- package/dist/useFocusWithin.mjs +71 -0
- package/dist/useFocusWithin.module.js +71 -0
- package/dist/useFocusWithin.module.js.map +1 -0
- package/dist/useHover.main.js +142 -0
- package/dist/useHover.main.js.map +1 -0
- package/dist/useHover.mjs +137 -0
- package/dist/useHover.module.js +137 -0
- package/dist/useHover.module.js.map +1 -0
- package/dist/useInteractOutside.main.js +101 -0
- package/dist/useInteractOutside.main.js.map +1 -0
- package/dist/useInteractOutside.mjs +96 -0
- package/dist/useInteractOutside.module.js +96 -0
- package/dist/useInteractOutside.module.js.map +1 -0
- package/dist/useKeyboard.main.js +30 -0
- package/dist/useKeyboard.main.js.map +1 -0
- package/dist/useKeyboard.mjs +25 -0
- package/dist/useKeyboard.module.js +25 -0
- package/dist/useKeyboard.module.js.map +1 -0
- package/dist/useLongPress.main.js +84 -0
- package/dist/useLongPress.main.js.map +1 -0
- package/dist/useLongPress.mjs +79 -0
- package/dist/useLongPress.module.js +79 -0
- package/dist/useLongPress.module.js.map +1 -0
- package/dist/useMove.main.js +236 -0
- package/dist/useMove.main.js.map +1 -0
- package/dist/useMove.mjs +231 -0
- package/dist/useMove.module.js +231 -0
- package/dist/useMove.module.js.map +1 -0
- package/dist/usePress.main.js +571 -0
- package/dist/usePress.main.js.map +1 -0
- package/dist/usePress.mjs +566 -0
- package/dist/usePress.module.js +566 -0
- package/dist/usePress.module.js.map +1 -0
- package/dist/useScrollWheel.main.js +41 -0
- package/dist/useScrollWheel.main.js.map +1 -0
- package/dist/useScrollWheel.mjs +36 -0
- package/dist/useScrollWheel.module.js +36 -0
- package/dist/useScrollWheel.module.js.map +1 -0
- package/dist/utils.main.js +120 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +115 -0
- package/dist/utils.module.js +115 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +5 -5
- package/src/useFocus.ts +5 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var $9Icr4$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $9Icr4$react = require("react");
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
$parcel$export(module.exports, "useInteractOutside", () => $edcfa848c42f94f4$export$872b660ac5a1ff98);
|
|
10
|
+
/*
|
|
11
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
12
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
14
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
+
*
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
17
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
18
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
19
|
+
* governing permissions and limitations under the License.
|
|
20
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
21
|
+
// Original licensing for the following can be found in the
|
|
22
|
+
// NOTICE file in the root directory of this source tree.
|
|
23
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function $edcfa848c42f94f4$export$872b660ac5a1ff98(props) {
|
|
27
|
+
let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
28
|
+
let stateRef = (0, $9Icr4$react.useRef)({
|
|
29
|
+
isPointerDown: false,
|
|
30
|
+
ignoreEmulatedMouseEvents: false
|
|
31
|
+
});
|
|
32
|
+
let onPointerDown = (0, $9Icr4$reactariautils.useEffectEvent)((e)=>{
|
|
33
|
+
if (onInteractOutside && $edcfa848c42f94f4$var$isValidEvent(e, ref)) {
|
|
34
|
+
if (onInteractOutsideStart) onInteractOutsideStart(e);
|
|
35
|
+
stateRef.current.isPointerDown = true;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
let triggerInteractOutside = (0, $9Icr4$reactariautils.useEffectEvent)((e)=>{
|
|
39
|
+
if (onInteractOutside) onInteractOutside(e);
|
|
40
|
+
});
|
|
41
|
+
(0, $9Icr4$react.useEffect)(()=>{
|
|
42
|
+
let state = stateRef.current;
|
|
43
|
+
if (isDisabled) return;
|
|
44
|
+
const element = ref.current;
|
|
45
|
+
const documentObject = (0, $9Icr4$reactariautils.getOwnerDocument)(element);
|
|
46
|
+
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
47
|
+
if (typeof PointerEvent !== "undefined") {
|
|
48
|
+
let onPointerUp = (e)=>{
|
|
49
|
+
if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
50
|
+
state.isPointerDown = false;
|
|
51
|
+
};
|
|
52
|
+
// changing these to capture phase fixed combobox
|
|
53
|
+
documentObject.addEventListener("pointerdown", onPointerDown, true);
|
|
54
|
+
documentObject.addEventListener("pointerup", onPointerUp, true);
|
|
55
|
+
return ()=>{
|
|
56
|
+
documentObject.removeEventListener("pointerdown", onPointerDown, true);
|
|
57
|
+
documentObject.removeEventListener("pointerup", onPointerUp, true);
|
|
58
|
+
};
|
|
59
|
+
} else {
|
|
60
|
+
let onMouseUp = (e)=>{
|
|
61
|
+
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
62
|
+
else if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
63
|
+
state.isPointerDown = false;
|
|
64
|
+
};
|
|
65
|
+
let onTouchEnd = (e)=>{
|
|
66
|
+
state.ignoreEmulatedMouseEvents = true;
|
|
67
|
+
if (state.isPointerDown && $edcfa848c42f94f4$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
68
|
+
state.isPointerDown = false;
|
|
69
|
+
};
|
|
70
|
+
documentObject.addEventListener("mousedown", onPointerDown, true);
|
|
71
|
+
documentObject.addEventListener("mouseup", onMouseUp, true);
|
|
72
|
+
documentObject.addEventListener("touchstart", onPointerDown, true);
|
|
73
|
+
documentObject.addEventListener("touchend", onTouchEnd, true);
|
|
74
|
+
return ()=>{
|
|
75
|
+
documentObject.removeEventListener("mousedown", onPointerDown, true);
|
|
76
|
+
documentObject.removeEventListener("mouseup", onMouseUp, true);
|
|
77
|
+
documentObject.removeEventListener("touchstart", onPointerDown, true);
|
|
78
|
+
documentObject.removeEventListener("touchend", onTouchEnd, true);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}, [
|
|
82
|
+
ref,
|
|
83
|
+
isDisabled,
|
|
84
|
+
onPointerDown,
|
|
85
|
+
triggerInteractOutside
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
function $edcfa848c42f94f4$var$isValidEvent(event, ref) {
|
|
89
|
+
if (event.button > 0) return false;
|
|
90
|
+
if (event.target) {
|
|
91
|
+
// if the event target is no longer in the document, ignore
|
|
92
|
+
const ownerDocument = event.target.ownerDocument;
|
|
93
|
+
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
94
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
95
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
96
|
+
}
|
|
97
|
+
return ref.current && !ref.current.contains(event.target);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
//# sourceMappingURL=useInteractOutside.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC,GAED,kEAAkE;AAClE,2DAA2D;AAC3D,yDAAyD;AACzD,kHAAkH;;;AAiB3G,SAAS,0CAAmB,KAA2B;IAC5D,IAAI,OAAC,GAAG,qBAAE,iBAAiB,cAAE,UAAU,0BAAE,sBAAsB,EAAC,GAAG;IACnE,IAAI,WAAW,CAAA,GAAA,mBAAK,EAAE;QACpB,eAAe;QACf,2BAA2B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B,CAAC,YAAY,YAAY;YAExD,OAAO;gBACL,eAAe,mBAAmB,CAAC,aAAa,eAAe;gBAC/D,eAAe,mBAAmB,CAAC,WAAW,WAAW;gBACzD,eAAe,mBAAmB,CAAC,cAAc,eAAe;gBAChE,eAAe,mBAAmB,CAAC,YAAY,YAAY;YAC7D;QACF;IACF,GAAG;QAAC;QAAK;QAAY;QAAe;KAAuB;AAC7D;AAEA,SAAS,mCAAa,KAAK,EAAE,GAAG;IAC9B,IAAI,MAAM,MAAM,GAAG,GACjB,OAAO;IAGT,IAAI,MAAM,MAAM,EAAE;QAChB,2DAA2D;QAC3D,MAAM,gBAAgB,MAAM,MAAM,CAAC,aAAa;QAChD,IAAI,CAAC,iBAAiB,CAAC,cAAc,eAAe,CAAC,QAAQ,CAAC,MAAM,MAAM,GACxE,OAAO;QAGT,qEAAqE;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,OAAO,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,MAAM;AAC1D","sources":["packages/@react-aria/interactions/src/useInteractOutside.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from react.\n// Original licensing for the following can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions\n\nimport {getOwnerDocument, useEffectEvent} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps) {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onPointerUp = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('pointerup', onPointerUp, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('pointerup', onPointerUp, true);\n };\n } else {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled, onPointerDown, triggerInteractOutside]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) {\n return false;\n }\n\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n return ref.current && !ref.current.contains(event.target);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.main.js.map"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument} from "@react-aria/utils";
|
|
2
|
+
import {useRef as $ispOf$useRef, useEffect as $ispOf$useEffect} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
15
|
+
// Original licensing for the following can be found in the
|
|
16
|
+
// NOTICE file in the root directory of this source tree.
|
|
17
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
21
|
+
let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
22
|
+
let stateRef = (0, $ispOf$useRef)({
|
|
23
|
+
isPointerDown: false,
|
|
24
|
+
ignoreEmulatedMouseEvents: false
|
|
25
|
+
});
|
|
26
|
+
let onPointerDown = (0, $ispOf$useEffectEvent)((e)=>{
|
|
27
|
+
if (onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
|
|
28
|
+
if (onInteractOutsideStart) onInteractOutsideStart(e);
|
|
29
|
+
stateRef.current.isPointerDown = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
let triggerInteractOutside = (0, $ispOf$useEffectEvent)((e)=>{
|
|
33
|
+
if (onInteractOutside) onInteractOutside(e);
|
|
34
|
+
});
|
|
35
|
+
(0, $ispOf$useEffect)(()=>{
|
|
36
|
+
let state = stateRef.current;
|
|
37
|
+
if (isDisabled) return;
|
|
38
|
+
const element = ref.current;
|
|
39
|
+
const documentObject = (0, $ispOf$getOwnerDocument)(element);
|
|
40
|
+
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
41
|
+
if (typeof PointerEvent !== "undefined") {
|
|
42
|
+
let onPointerUp = (e)=>{
|
|
43
|
+
if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
44
|
+
state.isPointerDown = false;
|
|
45
|
+
};
|
|
46
|
+
// changing these to capture phase fixed combobox
|
|
47
|
+
documentObject.addEventListener("pointerdown", onPointerDown, true);
|
|
48
|
+
documentObject.addEventListener("pointerup", onPointerUp, true);
|
|
49
|
+
return ()=>{
|
|
50
|
+
documentObject.removeEventListener("pointerdown", onPointerDown, true);
|
|
51
|
+
documentObject.removeEventListener("pointerup", onPointerUp, true);
|
|
52
|
+
};
|
|
53
|
+
} else {
|
|
54
|
+
let onMouseUp = (e)=>{
|
|
55
|
+
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
56
|
+
else if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
57
|
+
state.isPointerDown = false;
|
|
58
|
+
};
|
|
59
|
+
let onTouchEnd = (e)=>{
|
|
60
|
+
state.ignoreEmulatedMouseEvents = true;
|
|
61
|
+
if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
62
|
+
state.isPointerDown = false;
|
|
63
|
+
};
|
|
64
|
+
documentObject.addEventListener("mousedown", onPointerDown, true);
|
|
65
|
+
documentObject.addEventListener("mouseup", onMouseUp, true);
|
|
66
|
+
documentObject.addEventListener("touchstart", onPointerDown, true);
|
|
67
|
+
documentObject.addEventListener("touchend", onTouchEnd, true);
|
|
68
|
+
return ()=>{
|
|
69
|
+
documentObject.removeEventListener("mousedown", onPointerDown, true);
|
|
70
|
+
documentObject.removeEventListener("mouseup", onMouseUp, true);
|
|
71
|
+
documentObject.removeEventListener("touchstart", onPointerDown, true);
|
|
72
|
+
documentObject.removeEventListener("touchend", onTouchEnd, true);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}, [
|
|
76
|
+
ref,
|
|
77
|
+
isDisabled,
|
|
78
|
+
onPointerDown,
|
|
79
|
+
triggerInteractOutside
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
|
|
83
|
+
if (event.button > 0) return false;
|
|
84
|
+
if (event.target) {
|
|
85
|
+
// if the event target is no longer in the document, ignore
|
|
86
|
+
const ownerDocument = event.target.ownerDocument;
|
|
87
|
+
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
88
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
89
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
90
|
+
}
|
|
91
|
+
return ref.current && !ref.current.contains(event.target);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
export {$e0b6e0b68ec7f50f$export$872b660ac5a1ff98 as useInteractOutside};
|
|
96
|
+
//# sourceMappingURL=useInteractOutside.mjs.map
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {useEffectEvent as $ispOf$useEffectEvent, getOwnerDocument as $ispOf$getOwnerDocument} from "@react-aria/utils";
|
|
2
|
+
import {useRef as $ispOf$useRef, useEffect as $ispOf$useEffect} from "react";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/ // Portions of the code in this file are based on code from react.
|
|
15
|
+
// Original licensing for the following can be found in the
|
|
16
|
+
// NOTICE file in the root directory of this source tree.
|
|
17
|
+
// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
function $e0b6e0b68ec7f50f$export$872b660ac5a1ff98(props) {
|
|
21
|
+
let { ref: ref, onInteractOutside: onInteractOutside, isDisabled: isDisabled, onInteractOutsideStart: onInteractOutsideStart } = props;
|
|
22
|
+
let stateRef = (0, $ispOf$useRef)({
|
|
23
|
+
isPointerDown: false,
|
|
24
|
+
ignoreEmulatedMouseEvents: false
|
|
25
|
+
});
|
|
26
|
+
let onPointerDown = (0, $ispOf$useEffectEvent)((e)=>{
|
|
27
|
+
if (onInteractOutside && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) {
|
|
28
|
+
if (onInteractOutsideStart) onInteractOutsideStart(e);
|
|
29
|
+
stateRef.current.isPointerDown = true;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
let triggerInteractOutside = (0, $ispOf$useEffectEvent)((e)=>{
|
|
33
|
+
if (onInteractOutside) onInteractOutside(e);
|
|
34
|
+
});
|
|
35
|
+
(0, $ispOf$useEffect)(()=>{
|
|
36
|
+
let state = stateRef.current;
|
|
37
|
+
if (isDisabled) return;
|
|
38
|
+
const element = ref.current;
|
|
39
|
+
const documentObject = (0, $ispOf$getOwnerDocument)(element);
|
|
40
|
+
// Use pointer events if available. Otherwise, fall back to mouse and touch events.
|
|
41
|
+
if (typeof PointerEvent !== "undefined") {
|
|
42
|
+
let onPointerUp = (e)=>{
|
|
43
|
+
if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
44
|
+
state.isPointerDown = false;
|
|
45
|
+
};
|
|
46
|
+
// changing these to capture phase fixed combobox
|
|
47
|
+
documentObject.addEventListener("pointerdown", onPointerDown, true);
|
|
48
|
+
documentObject.addEventListener("pointerup", onPointerUp, true);
|
|
49
|
+
return ()=>{
|
|
50
|
+
documentObject.removeEventListener("pointerdown", onPointerDown, true);
|
|
51
|
+
documentObject.removeEventListener("pointerup", onPointerUp, true);
|
|
52
|
+
};
|
|
53
|
+
} else {
|
|
54
|
+
let onMouseUp = (e)=>{
|
|
55
|
+
if (state.ignoreEmulatedMouseEvents) state.ignoreEmulatedMouseEvents = false;
|
|
56
|
+
else if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
57
|
+
state.isPointerDown = false;
|
|
58
|
+
};
|
|
59
|
+
let onTouchEnd = (e)=>{
|
|
60
|
+
state.ignoreEmulatedMouseEvents = true;
|
|
61
|
+
if (state.isPointerDown && $e0b6e0b68ec7f50f$var$isValidEvent(e, ref)) triggerInteractOutside(e);
|
|
62
|
+
state.isPointerDown = false;
|
|
63
|
+
};
|
|
64
|
+
documentObject.addEventListener("mousedown", onPointerDown, true);
|
|
65
|
+
documentObject.addEventListener("mouseup", onMouseUp, true);
|
|
66
|
+
documentObject.addEventListener("touchstart", onPointerDown, true);
|
|
67
|
+
documentObject.addEventListener("touchend", onTouchEnd, true);
|
|
68
|
+
return ()=>{
|
|
69
|
+
documentObject.removeEventListener("mousedown", onPointerDown, true);
|
|
70
|
+
documentObject.removeEventListener("mouseup", onMouseUp, true);
|
|
71
|
+
documentObject.removeEventListener("touchstart", onPointerDown, true);
|
|
72
|
+
documentObject.removeEventListener("touchend", onTouchEnd, true);
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}, [
|
|
76
|
+
ref,
|
|
77
|
+
isDisabled,
|
|
78
|
+
onPointerDown,
|
|
79
|
+
triggerInteractOutside
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
function $e0b6e0b68ec7f50f$var$isValidEvent(event, ref) {
|
|
83
|
+
if (event.button > 0) return false;
|
|
84
|
+
if (event.target) {
|
|
85
|
+
// if the event target is no longer in the document, ignore
|
|
86
|
+
const ownerDocument = event.target.ownerDocument;
|
|
87
|
+
if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) return false;
|
|
88
|
+
// If the target is within a top layer element (e.g. toasts), ignore.
|
|
89
|
+
if (event.target.closest("[data-react-aria-top-layer]")) return false;
|
|
90
|
+
}
|
|
91
|
+
return ref.current && !ref.current.contains(event.target);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
export {$e0b6e0b68ec7f50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B,GAAG;qBAC7B,IAAI,MAAM,aAAa,IAAI,mCAAa,GAAG,MAChD,uBAAuB;gBAEzB,MAAM,aAAa,GAAG;YACxB;YAEA,IAAI,aAAa,CAAC;gBAChB,MAAM,yBAAyB,GAAG;gBAClC,IAAI,MAAM,aAAa,IAAI,mCAAa,GAAG,MACzC,uBAAuB;gBAEzB,MAAM,aAAa,GAAG;YACxB;YAEA,eAAe,gBAAgB,CAAC,aAAa,eAAe;YAC5D,eAAe,gBAAgB,CAAC,WAAW,WAAW;YACtD,eAAe,gBAAgB,CAAC,cAAc,eAAe;YAC7D,eAAe,gBAAgB,CAAC,YAAY,YAAY;YAExD,OAAO;gBACL,eAAe,mBAAmB,CAAC,aAAa,eAAe;gBAC/D,eAAe,mBAAmB,CAAC,WAAW,WAAW;gBACzD,eAAe,mBAAmB,CAAC,cAAc,eAAe;gBAChE,eAAe,mBAAmB,CAAC,YAAY,YAAY;YAC7D;QACF;IACF,GAAG;QAAC;QAAK;QAAY;QAAe;KAAuB;AAC7D;AAEA,SAAS,mCAAa,KAAK,EAAE,GAAG;IAC9B,IAAI,MAAM,MAAM,GAAG,GACjB,OAAO;IAGT,IAAI,MAAM,MAAM,EAAE;QAChB,2DAA2D;QAC3D,MAAM,gBAAgB,MAAM,MAAM,CAAC,aAAa;QAChD,IAAI,CAAC,iBAAiB,CAAC,cAAc,eAAe,CAAC,QAAQ,CAAC,MAAM,MAAM,GACxE,OAAO;QAGT,qEAAqE;QACrE,IAAI,MAAM,MAAM,CAAC,OAAO,CAAC,gCACvB,OAAO;IAEX;IAEA,OAAO,IAAI,OAAO,IAAI,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,MAAM;AAC1D","sources":["packages/@react-aria/interactions/src/useInteractOutside.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n// Portions of the code in this file are based on code from react.\n// Original licensing for the following can be found in the\n// NOTICE file in the root directory of this source tree.\n// See https://github.com/facebook/react/tree/cc7c1aece46a6b69b41958d731e0fd27c94bfc6c/packages/react-interactions\n\nimport {getOwnerDocument, useEffectEvent} from '@react-aria/utils';\nimport {RefObject, useEffect, useRef} from 'react';\n\nexport interface InteractOutsideProps {\n ref: RefObject<Element>,\n onInteractOutside?: (e: PointerEvent) => void,\n onInteractOutsideStart?: (e: PointerEvent) => void,\n /** Whether the interact outside events should be disabled. */\n isDisabled?: boolean\n}\n\n/**\n * Example, used in components like Dialogs and Popovers so they can close\n * when a user clicks outside them.\n */\nexport function useInteractOutside(props: InteractOutsideProps) {\n let {ref, onInteractOutside, isDisabled, onInteractOutsideStart} = props;\n let stateRef = useRef({\n isPointerDown: false,\n ignoreEmulatedMouseEvents: false\n });\n\n let onPointerDown = useEffectEvent((e) => {\n if (onInteractOutside && isValidEvent(e, ref)) {\n if (onInteractOutsideStart) {\n onInteractOutsideStart(e);\n }\n stateRef.current.isPointerDown = true;\n }\n });\n\n let triggerInteractOutside = useEffectEvent((e: PointerEvent) => {\n if (onInteractOutside) {\n onInteractOutside(e);\n }\n });\n\n useEffect(() => {\n let state = stateRef.current;\n if (isDisabled) {\n return;\n }\n\n const element = ref.current;\n const documentObject = getOwnerDocument(element);\n\n // Use pointer events if available. Otherwise, fall back to mouse and touch events.\n if (typeof PointerEvent !== 'undefined') {\n let onPointerUp = (e) => {\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n // changing these to capture phase fixed combobox\n documentObject.addEventListener('pointerdown', onPointerDown, true);\n documentObject.addEventListener('pointerup', onPointerUp, true);\n\n return () => {\n documentObject.removeEventListener('pointerdown', onPointerDown, true);\n documentObject.removeEventListener('pointerup', onPointerUp, true);\n };\n } else {\n let onMouseUp = (e) => {\n if (state.ignoreEmulatedMouseEvents) {\n state.ignoreEmulatedMouseEvents = false;\n } else if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n let onTouchEnd = (e) => {\n state.ignoreEmulatedMouseEvents = true;\n if (state.isPointerDown && isValidEvent(e, ref)) {\n triggerInteractOutside(e);\n }\n state.isPointerDown = false;\n };\n\n documentObject.addEventListener('mousedown', onPointerDown, true);\n documentObject.addEventListener('mouseup', onMouseUp, true);\n documentObject.addEventListener('touchstart', onPointerDown, true);\n documentObject.addEventListener('touchend', onTouchEnd, true);\n\n return () => {\n documentObject.removeEventListener('mousedown', onPointerDown, true);\n documentObject.removeEventListener('mouseup', onMouseUp, true);\n documentObject.removeEventListener('touchstart', onPointerDown, true);\n documentObject.removeEventListener('touchend', onTouchEnd, true);\n };\n }\n }, [ref, isDisabled, onPointerDown, triggerInteractOutside]);\n}\n\nfunction isValidEvent(event, ref) {\n if (event.button > 0) {\n return false;\n }\n\n if (event.target) {\n // if the event target is no longer in the document, ignore\n const ownerDocument = event.target.ownerDocument;\n if (!ownerDocument || !ownerDocument.documentElement.contains(event.target)) {\n return false;\n }\n\n // If the target is within a top layer element (e.g. toasts), ignore.\n if (event.target.closest('[data-react-aria-top-layer]')) {\n return false;\n }\n }\n\n return ref.current && !ref.current.contains(event.target);\n}\n"],"names":[],"version":3,"file":"useInteractOutside.module.js.map"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var $951fbcbbca8db6ce$exports = require("./createEventHandler.main.js");
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function $parcel$export(e, n, v, s) {
|
|
5
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
$parcel$export(module.exports, "useKeyboard", () => $892d64db2a3c53b0$export$8f71654801c2f7cd);
|
|
9
|
+
/*
|
|
10
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
11
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
12
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
13
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
+
*
|
|
15
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
16
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
17
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
18
|
+
* governing permissions and limitations under the License.
|
|
19
|
+
*/
|
|
20
|
+
function $892d64db2a3c53b0$export$8f71654801c2f7cd(props) {
|
|
21
|
+
return {
|
|
22
|
+
keyboardProps: props.isDisabled ? {} : {
|
|
23
|
+
onKeyDown: (0, $951fbcbbca8db6ce$exports.createEventHandler)(props.onKeyDown),
|
|
24
|
+
onKeyUp: (0, $951fbcbbca8db6ce$exports.createEventHandler)(props.onKeyUp)
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=useKeyboard.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAkBM,SAAS,0CAAY,KAAoB;IAC9C,OAAO;QACL,eAAe,MAAM,UAAU,GAAG,CAAC,IAAI;YACrC,WAAW,CAAA,GAAA,4CAAiB,EAAE,MAAM,SAAS;YAC7C,SAAS,CAAA,GAAA,4CAAiB,EAAE,MAAM,OAAO;QAC3C;IACF;AACF","sources":["packages/@react-aria/interactions/src/useKeyboard.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {createEventHandler} from './createEventHandler';\nimport {DOMAttributes, KeyboardEvents} from '@react-types/shared';\n\nexport interface KeyboardProps extends KeyboardEvents {\n /** Whether the keyboard events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface KeyboardResult {\n /** Props to spread onto the target element. */\n keyboardProps: DOMAttributes\n}\n\n/**\n * Handles keyboard interactions for a focusable element.\n */\nexport function useKeyboard(props: KeyboardProps): KeyboardResult {\n return {\n keyboardProps: props.isDisabled ? {} : {\n onKeyDown: createEventHandler(props.onKeyDown),\n onKeyUp: createEventHandler(props.onKeyUp)\n }\n };\n}\n"],"names":[],"version":3,"file":"useKeyboard.main.js.map"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {createEventHandler as $93925083ecbb358c$export$48d1ea6320830260} from "./createEventHandler.mjs";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
|
|
15
|
+
return {
|
|
16
|
+
keyboardProps: props.isDisabled ? {} : {
|
|
17
|
+
onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
|
|
18
|
+
onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export {$46d819fcbaf35654$export$8f71654801c2f7cd as useKeyboard};
|
|
25
|
+
//# sourceMappingURL=useKeyboard.mjs.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {createEventHandler as $93925083ecbb358c$export$48d1ea6320830260} from "./createEventHandler.module.js";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
5
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
7
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
10
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
11
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
12
|
+
* governing permissions and limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
function $46d819fcbaf35654$export$8f71654801c2f7cd(props) {
|
|
15
|
+
return {
|
|
16
|
+
keyboardProps: props.isDisabled ? {} : {
|
|
17
|
+
onKeyDown: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyDown),
|
|
18
|
+
onKeyUp: (0, $93925083ecbb358c$export$48d1ea6320830260)(props.onKeyUp)
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export {$46d819fcbaf35654$export$8f71654801c2f7cd as useKeyboard};
|
|
25
|
+
//# sourceMappingURL=useKeyboard.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;AAAA;;;;;;;;;;CAUC;AAkBM,SAAS,0CAAY,KAAoB;IAC9C,OAAO;QACL,eAAe,MAAM,UAAU,GAAG,CAAC,IAAI;YACrC,WAAW,CAAA,GAAA,yCAAiB,EAAE,MAAM,SAAS;YAC7C,SAAS,CAAA,GAAA,yCAAiB,EAAE,MAAM,OAAO;QAC3C;IACF;AACF","sources":["packages/@react-aria/interactions/src/useKeyboard.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {createEventHandler} from './createEventHandler';\nimport {DOMAttributes, KeyboardEvents} from '@react-types/shared';\n\nexport interface KeyboardProps extends KeyboardEvents {\n /** Whether the keyboard events should be disabled. */\n isDisabled?: boolean\n}\n\nexport interface KeyboardResult {\n /** Props to spread onto the target element. */\n keyboardProps: DOMAttributes\n}\n\n/**\n * Handles keyboard interactions for a focusable element.\n */\nexport function useKeyboard(props: KeyboardProps): KeyboardResult {\n return {\n keyboardProps: props.isDisabled ? {} : {\n onKeyDown: createEventHandler(props.onKeyDown),\n onKeyUp: createEventHandler(props.onKeyUp)\n }\n };\n}\n"],"names":[],"version":3,"file":"useKeyboard.module.js.map"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var $0294ea432cd92340$exports = require("./usePress.main.js");
|
|
2
|
+
var $5sxTM$reactariautils = require("@react-aria/utils");
|
|
3
|
+
var $5sxTM$react = require("react");
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
function $parcel$export(e, n, v, s) {
|
|
7
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
$parcel$export(module.exports, "useLongPress", () => $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
*
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD = 500;
|
|
25
|
+
function $3cd7b5d0eebf0ca9$export$c24ed0104d07eab9(props) {
|
|
26
|
+
let { isDisabled: isDisabled, onLongPressStart: onLongPressStart, onLongPressEnd: onLongPressEnd, onLongPress: onLongPress, threshold: threshold = $3cd7b5d0eebf0ca9$var$DEFAULT_THRESHOLD, accessibilityDescription: accessibilityDescription } = props;
|
|
27
|
+
const timeRef = (0, $5sxTM$react.useRef)();
|
|
28
|
+
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $5sxTM$reactariautils.useGlobalListeners)();
|
|
29
|
+
let { pressProps: pressProps } = (0, $0294ea432cd92340$exports.usePress)({
|
|
30
|
+
isDisabled: isDisabled,
|
|
31
|
+
onPressStart (e) {
|
|
32
|
+
e.continuePropagation();
|
|
33
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
34
|
+
if (onLongPressStart) onLongPressStart({
|
|
35
|
+
...e,
|
|
36
|
+
type: "longpressstart"
|
|
37
|
+
});
|
|
38
|
+
timeRef.current = setTimeout(()=>{
|
|
39
|
+
// Prevent other usePress handlers from also handling this event.
|
|
40
|
+
e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
|
41
|
+
bubbles: true
|
|
42
|
+
}));
|
|
43
|
+
if (onLongPress) onLongPress({
|
|
44
|
+
...e,
|
|
45
|
+
type: "longpress"
|
|
46
|
+
});
|
|
47
|
+
timeRef.current = undefined;
|
|
48
|
+
}, threshold);
|
|
49
|
+
// Prevent context menu, which may be opened on long press on touch devices
|
|
50
|
+
if (e.pointerType === "touch") {
|
|
51
|
+
let onContextMenu = (e)=>{
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
};
|
|
54
|
+
addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
|
55
|
+
once: true
|
|
56
|
+
});
|
|
57
|
+
addGlobalListener(window, "pointerup", ()=>{
|
|
58
|
+
// If no contextmenu event is fired quickly after pointerup, remove the handler
|
|
59
|
+
// so future context menu events outside a long press are not prevented.
|
|
60
|
+
setTimeout(()=>{
|
|
61
|
+
removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
|
62
|
+
}, 30);
|
|
63
|
+
}, {
|
|
64
|
+
once: true
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
onPressEnd (e) {
|
|
70
|
+
if (timeRef.current) clearTimeout(timeRef.current);
|
|
71
|
+
if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
|
72
|
+
...e,
|
|
73
|
+
type: "longpressend"
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
let descriptionProps = (0, $5sxTM$reactariautils.useDescription)(onLongPress && !isDisabled ? accessibilityDescription : undefined);
|
|
78
|
+
return {
|
|
79
|
+
longPressProps: (0, $5sxTM$reactariautils.mergeProps)(pressProps, descriptionProps)
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=useLongPress.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mapp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AW,EAAE,WAAW,KAAK,OAAM,GAC1E,eAAe;gBACb,GAAG,CAAC;gBACJ,MAAM;YACR;QAEJ;IACF;IAEA,IAAI,mBAAmB,CAAA,GAAA,oCAAa,EAAE,eAAe,CAAC,aAAa,2BAA2B;IAE9F,OAAO;QACL,gBAAgB,CAAA,GAAA,gCAAS,EAAE,YAAY;IACzC;AACF","sources":["packages/@react-aria/interactions/src/useLongPress.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DOMAttributes, LongPressEvent} from '@react-types/shared';\nimport {mergeProps, useDescription, useGlobalListeners} from '@react-aria/utils';\nimport {usePress} from './usePress';\nimport {useRef} from 'react';\n\nexport interface LongPressProps {\n /** Whether long press events should be disabled. */\n isDisabled?: boolean,\n /** Handler that is called when a long press interaction starts. */\n onLongPressStart?: (e: LongPressEvent) => void,\n /**\n * Handler that is called when a long press interaction ends, either\n * over the target or when the pointer leaves the target.\n */\n onLongPressEnd?: (e: LongPressEvent) => void,\n /**\n * Handler that is called when the threshold time is met while\n * the press is over the target.\n */\n onLongPress?: (e: LongPressEvent) => void,\n /**\n * The amount of time in milliseconds to wait before triggering a long press.\n * @default 500ms\n */\n threshold?: number,\n /**\n * A description for assistive techology users indicating that a long press\n * action is available, e.g. \"Long press to open menu\".\n */\n accessibilityDescription?: string\n}\n\nexport interface LongPressResult {\n /** Props to spread on the target element. */\n longPressProps: DOMAttributes\n}\n\nconst DEFAULT_THRESHOLD = 500;\n\n/**\n * Handles long press interactions across mouse and touch devices. Supports a customizable time threshold,\n * accessibility description, and normalizes behavior across browsers and devices.\n */\nexport function useLongPress(props: LongPressProps): LongPressResult {\n let {\n isDisabled,\n onLongPressStart,\n onLongPressEnd,\n onLongPress,\n threshold = DEFAULT_THRESHOLD,\n accessibilityDescription\n } = props;\n\n const timeRef = useRef<ReturnType<typeof setTimeout> | undefined>();\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let {pressProps} = usePress({\n isDisabled,\n onPressStart(e) {\n e.continuePropagation();\n if (e.pointerType === 'mouse' || e.pointerType === 'touch') {\n if (onLongPressStart) {\n onLongPressStart({\n ...e,\n type: 'longpressstart'\n });\n }\n\n timeRef.current = setTimeout(() => {\n // Prevent other usePress handlers from also handling this event.\n e.target.dispatchEvent(new PointerEvent('pointercancel', {bubbles: true}));\n if (onLongPress) {\n onLongPress({\n ...e,\n type: 'longpress'\n });\n }\n timeRef.current = undefined;\n }, threshold);\n\n // Prevent context menu, which may be opened on long press on touch devices\n if (e.pointerType === 'touch') {\n let onContextMenu = e => {\n e.preventDefault();\n };\n\n addGlobalListener(e.target, 'contextmenu', onContextMenu, {once: true});\n addGlobalListener(window, 'pointerup', () => {\n // If no contextmenu event is fired quickly after pointerup, remove the handler\n // so future context menu events outside a long press are not prevented.\n setTimeout(() => {\n removeGlobalListener(e.target, 'contextmenu', onContextMenu);\n }, 30);\n }, {once: true});\n }\n }\n },\n onPressEnd(e) {\n if (timeRef.current) {\n clearTimeout(timeRef.current);\n }\n\n if (onLongPressEnd && (e.pointerType === 'mouse' || e.pointerType === 'touch')) {\n onLongPressEnd({\n ...e,\n type: 'longpressend'\n });\n }\n }\n });\n\n let descriptionProps = useDescription(onLongPress && !isDisabled ? accessibilityDescription : undefined);\n\n return {\n longPressProps: mergeProps(pressProps, descriptionProps)\n };\n}\n"],"names":[],"version":3,"file":"useLongPress.main.js.map"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {usePress as $f6c31cce2adf654f$export$45712eceda6fad21} from "./usePress.mjs";
|
|
2
|
+
import {useGlobalListeners as $4k2kv$useGlobalListeners, useDescription as $4k2kv$useDescription, mergeProps as $4k2kv$mergeProps} from "@react-aria/utils";
|
|
3
|
+
import {useRef as $4k2kv$useRef} from "react";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
+
* governing permissions and limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const $8a26561d2877236e$var$DEFAULT_THRESHOLD = 500;
|
|
19
|
+
function $8a26561d2877236e$export$c24ed0104d07eab9(props) {
|
|
20
|
+
let { isDisabled: isDisabled, onLongPressStart: onLongPressStart, onLongPressEnd: onLongPressEnd, onLongPress: onLongPress, threshold: threshold = $8a26561d2877236e$var$DEFAULT_THRESHOLD, accessibilityDescription: accessibilityDescription } = props;
|
|
21
|
+
const timeRef = (0, $4k2kv$useRef)();
|
|
22
|
+
let { addGlobalListener: addGlobalListener, removeGlobalListener: removeGlobalListener } = (0, $4k2kv$useGlobalListeners)();
|
|
23
|
+
let { pressProps: pressProps } = (0, $f6c31cce2adf654f$export$45712eceda6fad21)({
|
|
24
|
+
isDisabled: isDisabled,
|
|
25
|
+
onPressStart (e) {
|
|
26
|
+
e.continuePropagation();
|
|
27
|
+
if (e.pointerType === "mouse" || e.pointerType === "touch") {
|
|
28
|
+
if (onLongPressStart) onLongPressStart({
|
|
29
|
+
...e,
|
|
30
|
+
type: "longpressstart"
|
|
31
|
+
});
|
|
32
|
+
timeRef.current = setTimeout(()=>{
|
|
33
|
+
// Prevent other usePress handlers from also handling this event.
|
|
34
|
+
e.target.dispatchEvent(new PointerEvent("pointercancel", {
|
|
35
|
+
bubbles: true
|
|
36
|
+
}));
|
|
37
|
+
if (onLongPress) onLongPress({
|
|
38
|
+
...e,
|
|
39
|
+
type: "longpress"
|
|
40
|
+
});
|
|
41
|
+
timeRef.current = undefined;
|
|
42
|
+
}, threshold);
|
|
43
|
+
// Prevent context menu, which may be opened on long press on touch devices
|
|
44
|
+
if (e.pointerType === "touch") {
|
|
45
|
+
let onContextMenu = (e)=>{
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
};
|
|
48
|
+
addGlobalListener(e.target, "contextmenu", onContextMenu, {
|
|
49
|
+
once: true
|
|
50
|
+
});
|
|
51
|
+
addGlobalListener(window, "pointerup", ()=>{
|
|
52
|
+
// If no contextmenu event is fired quickly after pointerup, remove the handler
|
|
53
|
+
// so future context menu events outside a long press are not prevented.
|
|
54
|
+
setTimeout(()=>{
|
|
55
|
+
removeGlobalListener(e.target, "contextmenu", onContextMenu);
|
|
56
|
+
}, 30);
|
|
57
|
+
}, {
|
|
58
|
+
once: true
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
onPressEnd (e) {
|
|
64
|
+
if (timeRef.current) clearTimeout(timeRef.current);
|
|
65
|
+
if (onLongPressEnd && (e.pointerType === "mouse" || e.pointerType === "touch")) onLongPressEnd({
|
|
66
|
+
...e,
|
|
67
|
+
type: "longpressend"
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
let descriptionProps = (0, $4k2kv$useDescription)(onLongPress && !isDisabled ? accessibilityDescription : undefined);
|
|
72
|
+
return {
|
|
73
|
+
longPressProps: (0, $4k2kv$mergeProps)(pressProps, descriptionProps)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
export {$8a26561d2877236e$export$c24ed0104d07eab9 as useLongPress};
|
|
79
|
+
//# sourceMappingURL=useLongPress.mjs.map
|