@tamagui/floating 2.0.0-rc.3 → 2.0.0-rc.31
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/cjs/Floating.native.js +4 -0
- package/dist/cjs/Floating.native.js.map +1 -1
- package/dist/cjs/index.cjs +33 -2
- package/dist/cjs/index.native.js +33 -2
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/interactions/PopupTriggerMap.cjs +40 -0
- package/dist/cjs/interactions/PopupTriggerMap.native.js +73 -0
- package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -0
- package/dist/cjs/interactions/createFloatingEvents.cjs +41 -0
- package/dist/cjs/interactions/createFloatingEvents.native.js +47 -0
- package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -0
- package/dist/cjs/interactions/safePolygon.cjs +191 -0
- package/dist/cjs/interactions/safePolygon.native.js +205 -0
- package/dist/cjs/interactions/safePolygon.native.js.map +1 -0
- package/dist/cjs/interactions/types.cjs +16 -0
- package/dist/cjs/interactions/types.native.js +19 -0
- package/dist/cjs/interactions/types.native.js.map +1 -0
- package/dist/cjs/interactions/useClick.cjs +82 -0
- package/dist/cjs/interactions/useClick.native.js +90 -0
- package/dist/cjs/interactions/useClick.native.js.map +1 -0
- package/dist/cjs/interactions/useDelayGroup.cjs +96 -0
- package/dist/cjs/interactions/useDelayGroup.native.js +109 -0
- package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -0
- package/dist/cjs/interactions/useFocus.cjs +101 -0
- package/dist/cjs/interactions/useFocus.native.js +113 -0
- package/dist/cjs/interactions/useFocus.native.js.map +1 -0
- package/dist/cjs/interactions/useHover.cjs +224 -0
- package/dist/cjs/interactions/useHover.native.js +248 -0
- package/dist/cjs/interactions/useHover.native.js.map +1 -0
- package/dist/cjs/interactions/useInnerOffset.cjs +104 -0
- package/dist/cjs/interactions/useInnerOffset.native.js +118 -0
- package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -0
- package/dist/cjs/interactions/useInteractions.cjs +76 -0
- package/dist/cjs/interactions/useInteractions.native.js +164 -0
- package/dist/cjs/interactions/useInteractions.native.js.map +1 -0
- package/dist/cjs/interactions/useListNavigation.cjs +253 -0
- package/dist/cjs/interactions/useListNavigation.native.js +297 -0
- package/dist/cjs/interactions/useListNavigation.native.js.map +1 -0
- package/dist/cjs/interactions/useRole.cjs +112 -0
- package/dist/cjs/interactions/useRole.native.js +128 -0
- package/dist/cjs/interactions/useRole.native.js.map +1 -0
- package/dist/cjs/interactions/useTypeahead.cjs +93 -0
- package/dist/cjs/interactions/useTypeahead.native.js +114 -0
- package/dist/cjs/interactions/useTypeahead.native.js.map +1 -0
- package/dist/cjs/interactions/utils.cjs +178 -0
- package/dist/cjs/interactions/utils.native.js +188 -0
- package/dist/cjs/interactions/utils.native.js.map +1 -0
- package/dist/cjs/middleware/inner.cjs +106 -0
- package/dist/cjs/middleware/inner.native.js +120 -0
- package/dist/cjs/middleware/inner.native.js.map +1 -0
- package/dist/cjs/useFloating.cjs +21 -17
- package/dist/cjs/useFloating.native.js +2 -0
- package/dist/cjs/useFloating.native.js.map +1 -1
- package/dist/esm/Floating.native.js +4 -1
- package/dist/esm/Floating.native.js.map +1 -1
- package/dist/esm/index.js +17 -34
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.mjs +16 -2
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +16 -2
- package/dist/esm/index.native.js.map +1 -1
- package/dist/esm/interactions/PopupTriggerMap.mjs +17 -0
- package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -0
- package/dist/esm/interactions/PopupTriggerMap.native.js +47 -0
- package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -0
- package/dist/esm/interactions/createFloatingEvents.mjs +18 -0
- package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -0
- package/dist/esm/interactions/createFloatingEvents.native.js +21 -0
- package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -0
- package/dist/esm/interactions/safePolygon.mjs +168 -0
- package/dist/esm/interactions/safePolygon.mjs.map +1 -0
- package/dist/esm/interactions/safePolygon.native.js +179 -0
- package/dist/esm/interactions/safePolygon.native.js.map +1 -0
- package/dist/esm/interactions/types.mjs +2 -0
- package/dist/esm/interactions/types.mjs.map +1 -0
- package/dist/esm/interactions/types.native.js +2 -0
- package/dist/esm/interactions/types.native.js.map +1 -0
- package/dist/esm/interactions/useClick.mjs +59 -0
- package/dist/esm/interactions/useClick.mjs.map +1 -0
- package/dist/esm/interactions/useClick.native.js +64 -0
- package/dist/esm/interactions/useClick.native.js.map +1 -0
- package/dist/esm/interactions/useDelayGroup.mjs +60 -0
- package/dist/esm/interactions/useDelayGroup.mjs.map +1 -0
- package/dist/esm/interactions/useDelayGroup.native.js +70 -0
- package/dist/esm/interactions/useDelayGroup.native.js.map +1 -0
- package/dist/esm/interactions/useFocus.mjs +78 -0
- package/dist/esm/interactions/useFocus.mjs.map +1 -0
- package/dist/esm/interactions/useFocus.native.js +87 -0
- package/dist/esm/interactions/useFocus.native.js.map +1 -0
- package/dist/esm/interactions/useHover.mjs +189 -0
- package/dist/esm/interactions/useHover.mjs.map +1 -0
- package/dist/esm/interactions/useHover.native.js +210 -0
- package/dist/esm/interactions/useHover.native.js.map +1 -0
- package/dist/esm/interactions/useInnerOffset.mjs +70 -0
- package/dist/esm/interactions/useInnerOffset.mjs.map +1 -0
- package/dist/esm/interactions/useInnerOffset.native.js +81 -0
- package/dist/esm/interactions/useInnerOffset.native.js.map +1 -0
- package/dist/esm/interactions/useInteractions.mjs +53 -0
- package/dist/esm/interactions/useInteractions.mjs.map +1 -0
- package/dist/esm/interactions/useInteractions.native.js +138 -0
- package/dist/esm/interactions/useInteractions.native.js.map +1 -0
- package/dist/esm/interactions/useListNavigation.mjs +230 -0
- package/dist/esm/interactions/useListNavigation.mjs.map +1 -0
- package/dist/esm/interactions/useListNavigation.native.js +271 -0
- package/dist/esm/interactions/useListNavigation.native.js.map +1 -0
- package/dist/esm/interactions/useRole.mjs +78 -0
- package/dist/esm/interactions/useRole.mjs.map +1 -0
- package/dist/esm/interactions/useRole.native.js +91 -0
- package/dist/esm/interactions/useRole.native.js.map +1 -0
- package/dist/esm/interactions/useTypeahead.mjs +70 -0
- package/dist/esm/interactions/useTypeahead.mjs.map +1 -0
- package/dist/esm/interactions/useTypeahead.native.js +88 -0
- package/dist/esm/interactions/useTypeahead.native.js.map +1 -0
- package/dist/esm/interactions/utils.mjs +134 -0
- package/dist/esm/interactions/utils.mjs.map +1 -0
- package/dist/esm/interactions/utils.native.js +141 -0
- package/dist/esm/interactions/utils.native.js.map +1 -0
- package/dist/esm/middleware/inner.mjs +72 -0
- package/dist/esm/middleware/inner.mjs.map +1 -0
- package/dist/esm/middleware/inner.native.js +83 -0
- package/dist/esm/middleware/inner.native.js.map +1 -0
- package/dist/esm/useFloating.mjs +21 -17
- package/dist/esm/useFloating.mjs.map +1 -1
- package/dist/esm/useFloating.native.js +2 -0
- package/dist/esm/useFloating.native.js.map +1 -1
- package/package.json +8 -10
- package/src/Floating.native.tsx +1 -0
- package/src/index.ts +49 -0
- package/src/interactions/PopupTriggerMap.ts +30 -0
- package/src/interactions/createFloatingEvents.ts +34 -0
- package/src/interactions/safePolygon.ts +500 -0
- package/src/interactions/types.ts +165 -0
- package/src/interactions/useClick.ts +148 -0
- package/src/interactions/useDelayGroup.ts +114 -0
- package/src/interactions/useFocus.ts +164 -0
- package/src/interactions/useHover.ts +453 -0
- package/src/interactions/useInnerOffset.ts +116 -0
- package/src/interactions/useInteractions.ts +101 -0
- package/src/interactions/useListNavigation.ts +578 -0
- package/src/interactions/useRole.ts +103 -0
- package/src/interactions/useTypeahead.ts +173 -0
- package/src/interactions/utils.ts +234 -0
- package/src/middleware/inner.ts +142 -0
- package/src/useFloating.tsx +13 -1
- package/types/Floating.native.d.ts +1 -0
- package/types/Floating.native.d.ts.map +1 -1
- package/types/index.d.ts +17 -2
- package/types/index.d.ts.map +1 -1
- package/types/interactions/PopupTriggerMap.d.ts +8 -0
- package/types/interactions/PopupTriggerMap.d.ts.map +1 -0
- package/types/interactions/createFloatingEvents.d.ts +7 -0
- package/types/interactions/createFloatingEvents.d.ts.map +1 -0
- package/types/interactions/safePolygon.d.ts +4 -0
- package/types/interactions/safePolygon.d.ts.map +1 -0
- package/types/interactions/types.d.ts +123 -0
- package/types/interactions/types.d.ts.map +1 -0
- package/types/interactions/useClick.d.ts +3 -0
- package/types/interactions/useClick.d.ts.map +1 -0
- package/types/interactions/useDelayGroup.d.ts +23 -0
- package/types/interactions/useDelayGroup.d.ts.map +1 -0
- package/types/interactions/useFocus.d.ts +3 -0
- package/types/interactions/useFocus.d.ts.map +1 -0
- package/types/interactions/useHover.d.ts +6 -0
- package/types/interactions/useHover.d.ts.map +1 -0
- package/types/interactions/useInnerOffset.d.ts +3 -0
- package/types/interactions/useInnerOffset.d.ts.map +1 -0
- package/types/interactions/useInteractions.d.ts +8 -0
- package/types/interactions/useInteractions.d.ts.map +1 -0
- package/types/interactions/useListNavigation.d.ts +3 -0
- package/types/interactions/useListNavigation.d.ts.map +1 -0
- package/types/interactions/useRole.d.ts +3 -0
- package/types/interactions/useRole.d.ts.map +1 -0
- package/types/interactions/useTypeahead.d.ts +3 -0
- package/types/interactions/useTypeahead.d.ts.map +1 -0
- package/types/interactions/utils.d.ts +46 -0
- package/types/interactions/utils.d.ts.map +1 -0
- package/types/middleware/inner.d.ts +14 -0
- package/types/middleware/inner.d.ts.map +1 -0
- package/types/useFloating.d.ts +7 -1
- package/types/useFloating.d.ts.map +1 -1
- package/dist/cjs/Floating.js +0 -15
- package/dist/cjs/Floating.js.map +0 -6
- package/dist/cjs/index.js +0 -34
- package/dist/cjs/index.js.map +0 -6
- package/dist/cjs/useFloating.js +0 -46
- package/dist/cjs/useFloating.js.map +0 -6
- package/dist/esm/Floating.js +0 -2
- package/dist/esm/Floating.js.map +0 -6
- package/dist/esm/useFloating.js +0 -23
- package/dist/esm/useFloating.js.map +0 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useDelayGroup_exports","__export","FloatingDelayGroup","useDelayGroup","useDelayGroupContext","module","exports","React","__toESM","require","DelayGroupContext","createContext","currentId","setCurrentId","delay","timeoutMs","initialDelay","useContext","param","children","setCurrentIdRaw","useState","timeoutRef","useRef","useCallback","id","clearTimeout","current","setTimeout","useEffect","useMemo","createElement","Provider","context","options","arguments","length","groupContext","open","onOpenChange"],"sources":["../../../src/interactions/useDelayGroup.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAAA;EAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;IAAAC,KAAA;EAAA,IAAAH,GAAA;AAAA,IAAAI,qBAAA;AAAAC,QAAA,CAAAD,qBAAA;EAAAE,kBAAA,EAAAA,CAAA,KAAAA,kBAAA;EAAAC,aAAA,EAAAA,CAAA,KAAAA,aAAA;EAAAC,oBAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAuB,GAAAX,YAAA,CAAAK,qBAAA;AAWvB,IAAAO,KAAM,GAAAC,OAAA,CAAAC,OAAoB,QAAM;EAAAC,iBAAsC,GAAAH,KAAA,CAAAI,aAAA;IACpEC,SAAA,EAAW;IACXC,YAAA,EAAc,SAAAA,CAAA,EAAM,CAAC;IACrBC,KAAA,EAAO;IACPC,SAAA,EAAW;IACXC,YAAA,EAAc;EAChB,CAAC;AAEM,SAASZ,qBAAA,EAAuB;EACrC,OAAOG,KAAA,CAAMU,UAAA,CAAWP,iBAAiB;AAC3C;AAKO,SAASR,mBAAmBgB,KAAA;EACjC;MAAAC,QAAA;MAAAL,KAAA;MAAAC,SAAA;IAAA,IAAAG,KAAA;IAAA,CAAAN,SAAA,EAAAQ,eAAA,IAAAb,KAAA,CAAAc,QAAA;IAAAC,UAAA,GAAAf,KAAA,CAAAgB,MAAA;IAAAV,YAAA,GAAA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F,YAAW,CAAAzB,SAAU,EAEvBa,EAAA,E","ignoreList":[]}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
21
|
+
var useFocus_exports = {};
|
|
22
|
+
__export(useFocus_exports, {
|
|
23
|
+
useFocus: () => useFocus
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(useFocus_exports);
|
|
26
|
+
var import_react = require("react"),
|
|
27
|
+
import_utils = require("./utils.cjs");
|
|
28
|
+
function isMacSafari() {
|
|
29
|
+
return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
|
|
30
|
+
}
|
|
31
|
+
function useFocus(context, props = {}) {
|
|
32
|
+
const {
|
|
33
|
+
open,
|
|
34
|
+
onOpenChange,
|
|
35
|
+
events,
|
|
36
|
+
dataRef,
|
|
37
|
+
elements
|
|
38
|
+
} = context,
|
|
39
|
+
{
|
|
40
|
+
enabled = !0,
|
|
41
|
+
visibleOnly = !0
|
|
42
|
+
} = props,
|
|
43
|
+
blockFocusRef = (0, import_react.useRef)(!1),
|
|
44
|
+
timeoutRef = (0, import_react.useRef)(-1),
|
|
45
|
+
keyboardModalityRef = (0, import_react.useRef)(!0);
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
if (!enabled) return;
|
|
48
|
+
const win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
|
|
49
|
+
function onBlur() {
|
|
50
|
+
!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference)) && (blockFocusRef.current = !0);
|
|
51
|
+
}
|
|
52
|
+
function onKeyDown() {
|
|
53
|
+
keyboardModalityRef.current = !0;
|
|
54
|
+
}
|
|
55
|
+
function onPointerDown() {
|
|
56
|
+
keyboardModalityRef.current = !1;
|
|
57
|
+
}
|
|
58
|
+
return win.addEventListener("blur", onBlur), isMacSafari() && (win.addEventListener("keydown", onKeyDown, !0), win.addEventListener("pointerdown", onPointerDown, !0)), () => {
|
|
59
|
+
win.removeEventListener("blur", onBlur), isMacSafari() && (win.removeEventListener("keydown", onKeyDown, !0), win.removeEventListener("pointerdown", onPointerDown, !0));
|
|
60
|
+
};
|
|
61
|
+
}, [elements.domReference, open, enabled]), (0, import_react.useEffect)(() => {
|
|
62
|
+
if (!enabled || !events) return;
|
|
63
|
+
function handleOpenChange({
|
|
64
|
+
reason
|
|
65
|
+
}) {
|
|
66
|
+
(reason === "reference-press" || reason === "escape-key") && (blockFocusRef.current = !0);
|
|
67
|
+
}
|
|
68
|
+
return events.on("openchange", handleOpenChange), () => {
|
|
69
|
+
events.off("openchange", handleOpenChange);
|
|
70
|
+
};
|
|
71
|
+
}, [events, enabled]), (0, import_react.useEffect)(() => () => {
|
|
72
|
+
(0, import_utils.clearTimeoutIfSet)(timeoutRef);
|
|
73
|
+
}, []);
|
|
74
|
+
const reference = (0, import_react.useMemo)(() => ({
|
|
75
|
+
onMouseLeave() {
|
|
76
|
+
blockFocusRef.current = !1;
|
|
77
|
+
},
|
|
78
|
+
onFocus(event) {
|
|
79
|
+
if (blockFocusRef.current) return;
|
|
80
|
+
const target = (0, import_utils.getTarget)(event.nativeEvent);
|
|
81
|
+
if (visibleOnly && (0, import_utils.isElement)(target)) {
|
|
82
|
+
if (isMacSafari() && !event.relatedTarget) {
|
|
83
|
+
if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) return;
|
|
84
|
+
} else if (!(0, import_utils.matchesFocusVisible)(target)) return;
|
|
85
|
+
}
|
|
86
|
+
onOpenChange(!0, event.nativeEvent, "focus");
|
|
87
|
+
},
|
|
88
|
+
onBlur(event) {
|
|
89
|
+
blockFocusRef.current = !1;
|
|
90
|
+
const relatedTarget = event.relatedTarget,
|
|
91
|
+
nativeEvent = event.nativeEvent;
|
|
92
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
93
|
+
const activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
|
|
94
|
+
!relatedTarget && activeEl === elements.domReference || (0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl) || onOpenChange(!1, nativeEvent, "focus");
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}), [context.refs.floating, elements.domReference, onOpenChange, visibleOnly]);
|
|
98
|
+
return (0, import_react.useMemo)(() => enabled ? {
|
|
99
|
+
reference
|
|
100
|
+
} : {}, [enabled, reference]);
|
|
101
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
+
value: !0
|
|
22
|
+
}), mod);
|
|
23
|
+
var useFocus_exports = {};
|
|
24
|
+
__export(useFocus_exports, {
|
|
25
|
+
useFocus: () => useFocus
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(useFocus_exports);
|
|
28
|
+
var import_react = require("react"),
|
|
29
|
+
import_utils = require("./utils.native.js");
|
|
30
|
+
function isMacSafari() {
|
|
31
|
+
return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
|
|
32
|
+
}
|
|
33
|
+
function useFocus(context) {
|
|
34
|
+
var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {},
|
|
35
|
+
{
|
|
36
|
+
open,
|
|
37
|
+
onOpenChange,
|
|
38
|
+
events,
|
|
39
|
+
dataRef,
|
|
40
|
+
elements
|
|
41
|
+
} = context,
|
|
42
|
+
{
|
|
43
|
+
enabled = !0,
|
|
44
|
+
visibleOnly = !0
|
|
45
|
+
} = props,
|
|
46
|
+
blockFocusRef = (0, import_react.useRef)(!1),
|
|
47
|
+
timeoutRef = (0, import_react.useRef)(-1),
|
|
48
|
+
keyboardModalityRef = (0, import_react.useRef)(!0);
|
|
49
|
+
(0, import_react.useEffect)(function () {
|
|
50
|
+
if (!enabled) return;
|
|
51
|
+
var win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
|
|
52
|
+
function onBlur() {
|
|
53
|
+
!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference)) && (blockFocusRef.current = !0);
|
|
54
|
+
}
|
|
55
|
+
function onKeyDown() {
|
|
56
|
+
keyboardModalityRef.current = !0;
|
|
57
|
+
}
|
|
58
|
+
function onPointerDown() {
|
|
59
|
+
keyboardModalityRef.current = !1;
|
|
60
|
+
}
|
|
61
|
+
return win.addEventListener("blur", onBlur), isMacSafari() && (win.addEventListener("keydown", onKeyDown, !0), win.addEventListener("pointerdown", onPointerDown, !0)), function () {
|
|
62
|
+
win.removeEventListener("blur", onBlur), isMacSafari() && (win.removeEventListener("keydown", onKeyDown, !0), win.removeEventListener("pointerdown", onPointerDown, !0));
|
|
63
|
+
};
|
|
64
|
+
}, [elements.domReference, open, enabled]), (0, import_react.useEffect)(function () {
|
|
65
|
+
if (!enabled || !events) return;
|
|
66
|
+
function handleOpenChange(param) {
|
|
67
|
+
var {
|
|
68
|
+
reason
|
|
69
|
+
} = param;
|
|
70
|
+
(reason === "reference-press" || reason === "escape-key") && (blockFocusRef.current = !0);
|
|
71
|
+
}
|
|
72
|
+
return events.on("openchange", handleOpenChange), function () {
|
|
73
|
+
events.off("openchange", handleOpenChange);
|
|
74
|
+
};
|
|
75
|
+
}, [events, enabled]), (0, import_react.useEffect)(function () {
|
|
76
|
+
return function () {
|
|
77
|
+
(0, import_utils.clearTimeoutIfSet)(timeoutRef);
|
|
78
|
+
};
|
|
79
|
+
}, []);
|
|
80
|
+
var reference = (0, import_react.useMemo)(function () {
|
|
81
|
+
return {
|
|
82
|
+
onMouseLeave() {
|
|
83
|
+
blockFocusRef.current = !1;
|
|
84
|
+
},
|
|
85
|
+
onFocus(event) {
|
|
86
|
+
if (!blockFocusRef.current) {
|
|
87
|
+
var target = (0, import_utils.getTarget)(event.nativeEvent);
|
|
88
|
+
if (visibleOnly && (0, import_utils.isElement)(target)) {
|
|
89
|
+
if (isMacSafari() && !event.relatedTarget) {
|
|
90
|
+
if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) return;
|
|
91
|
+
} else if (!(0, import_utils.matchesFocusVisible)(target)) return;
|
|
92
|
+
}
|
|
93
|
+
onOpenChange(!0, event.nativeEvent, "focus");
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
onBlur(event) {
|
|
97
|
+
blockFocusRef.current = !1;
|
|
98
|
+
var relatedTarget = event.relatedTarget,
|
|
99
|
+
nativeEvent = event.nativeEvent;
|
|
100
|
+
timeoutRef.current = window.setTimeout(function () {
|
|
101
|
+
var activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
|
|
102
|
+
!relatedTarget && activeEl === elements.domReference || (0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl) || onOpenChange(!1, nativeEvent, "focus");
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}, [context.refs.floating, elements.domReference, onOpenChange, visibleOnly]);
|
|
107
|
+
return (0, import_react.useMemo)(function () {
|
|
108
|
+
return enabled ? {
|
|
109
|
+
reference
|
|
110
|
+
} : {};
|
|
111
|
+
}, [enabled, reference]);
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=useFocus.native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","useFocus_exports","__export","useFocus","module","exports","import_react","require","import_utils","isMacSafari","isMac","isSafari","context","props","arguments","length","open","onOpenChange","events","dataRef","elements","enabled","visibleOnly","blockFocusRef","useRef","timeoutRef","keyboardModalityRef","useEffect","win","getDocument","domReference","defaultView","window","onBlur","isHTMLElement","activeElement","current","onKeyDown","onPointerDown","addEventListener","removeEventListener","handleOpenChange","param","reason","on","off","clearTimeoutIfSet","reference","useMemo","onMouseLeave","onFocus","event","target","getTarget","nativeEvent","isElement","relatedTarget","isTypeableElement","matchesFocusVisible"],"sources":["../../../src/interactions/useFocus.ts"],"sourcesContent":[null],"mappings":";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AAAH,MAAA,GAAc;YAGpB,IAAA3C,WAAW,EAAU,KAAA0C,KAAO,CAAAK,aAAiB;cAC3C,IAAM,CAAA9B,mBAAW,CAAAU,OAAA,SAAA5B,YAAA,CAAAiD,iBAAA,EAAAL,MAAA,GACf;YACF,gBAAA5C,YAAA,CAAAkD,mBAAA,EAAAN,MAAA,GAGK;UAaN;UACHnC,YAAA,KAAAkC,KAAA,CAAAG,WAAA;QACF;MACC;MACHrB,OAAAkB,KAAA;QAEA5B,aAAO,CAAAa,OAAA;QACT,IAAAoB,aAAA,GAAAL,KAAA,CAAAK,aAAA;UAAAF,WAAA,GAAAH,KAAA,CAAAG,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var useHover_exports = {};
|
|
33
|
+
__export(useHover_exports, {
|
|
34
|
+
getDelay: () => getDelay,
|
|
35
|
+
useHover: () => useHover
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(useHover_exports);
|
|
38
|
+
var React = __toESM(require("react"), 1),
|
|
39
|
+
import_use_event = require("@tamagui/use-event"),
|
|
40
|
+
import_utils = require("./utils.cjs");
|
|
41
|
+
const safePolygonIdentifier = "data-floating-ui-safe-polygon";
|
|
42
|
+
function getDelay(value, prop, pointerType) {
|
|
43
|
+
return pointerType && !(0, import_utils.isMouseLikePointerType)(pointerType) ? 0 : typeof value == "number" ? value : value?.[prop];
|
|
44
|
+
}
|
|
45
|
+
function useHover(context, props = {}) {
|
|
46
|
+
const {
|
|
47
|
+
open,
|
|
48
|
+
onOpenChange,
|
|
49
|
+
dataRef,
|
|
50
|
+
events,
|
|
51
|
+
elements
|
|
52
|
+
} = context,
|
|
53
|
+
{
|
|
54
|
+
enabled = !0,
|
|
55
|
+
delay = 0,
|
|
56
|
+
handleClose = null,
|
|
57
|
+
mouseOnly = !1,
|
|
58
|
+
restMs = 0,
|
|
59
|
+
move = !0
|
|
60
|
+
} = props,
|
|
61
|
+
handleCloseRef = React.useRef(handleClose);
|
|
62
|
+
handleCloseRef.current = handleClose;
|
|
63
|
+
const delayRef = React.useRef(delay);
|
|
64
|
+
delayRef.current = delay;
|
|
65
|
+
const openRef = React.useRef(open);
|
|
66
|
+
openRef.current = open;
|
|
67
|
+
const restMsRef = React.useRef(restMs);
|
|
68
|
+
restMsRef.current = restMs;
|
|
69
|
+
const stableOnOpenChange = (0, import_use_event.useEvent)(onOpenChange),
|
|
70
|
+
pointerTypeRef = React.useRef(void 0),
|
|
71
|
+
timeoutRef = React.useRef(-1),
|
|
72
|
+
handlerRef = React.useRef(void 0),
|
|
73
|
+
restTimeoutRef = React.useRef(-1),
|
|
74
|
+
blockMouseMoveRef = React.useRef(!0),
|
|
75
|
+
performedPointerEventsMutationRef = React.useRef(!1),
|
|
76
|
+
unbindMouseMoveRef = React.useRef(() => {}),
|
|
77
|
+
restTimeoutPendingRef = React.useRef(!1),
|
|
78
|
+
isHoverOpen = (0, import_use_event.useEvent)(() => {
|
|
79
|
+
const type = dataRef.current.openEvent?.type;
|
|
80
|
+
return type?.includes("mouse") && type !== "mousedown";
|
|
81
|
+
});
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
if (!enabled || !events) return;
|
|
84
|
+
function onOpenChange2({
|
|
85
|
+
open: open2
|
|
86
|
+
}) {
|
|
87
|
+
open2 || ((0, import_utils.clearTimeoutIfSet)(timeoutRef), (0, import_utils.clearTimeoutIfSet)(restTimeoutRef), blockMouseMoveRef.current = !0, restTimeoutPendingRef.current = !1);
|
|
88
|
+
}
|
|
89
|
+
return events.on("openchange", onOpenChange2), () => {
|
|
90
|
+
events.off("openchange", onOpenChange2);
|
|
91
|
+
};
|
|
92
|
+
}, [enabled, events]);
|
|
93
|
+
const closeWithDelay = (0, import_use_event.useEvent)((event, runElseBranch = !0, reason = "hover") => {
|
|
94
|
+
const closeDelay = getDelay(delayRef.current, "close", pointerTypeRef.current);
|
|
95
|
+
closeDelay && !handlerRef.current ? ((0, import_utils.clearTimeoutIfSet)(timeoutRef), timeoutRef.current = window.setTimeout(() => stableOnOpenChange(!1, event, reason), closeDelay)) : runElseBranch && ((0, import_utils.clearTimeoutIfSet)(timeoutRef), stableOnOpenChange(!1, event, reason));
|
|
96
|
+
}),
|
|
97
|
+
cleanupMouseMoveHandler = (0, import_use_event.useEvent)(() => {
|
|
98
|
+
unbindMouseMoveRef.current(), handlerRef.current = void 0, context.handleCloseActiveRef && (context.handleCloseActiveRef.current = !1);
|
|
99
|
+
}),
|
|
100
|
+
clearPointerEvents = (0, import_use_event.useEvent)(() => {
|
|
101
|
+
if (performedPointerEventsMutationRef.current) {
|
|
102
|
+
const body = (0, import_utils.getDocument)(elements.floating).body;
|
|
103
|
+
body.style.pointerEvents = "", body.removeAttribute(safePolygonIdentifier), performedPointerEventsMutationRef.current = !1;
|
|
104
|
+
}
|
|
105
|
+
}),
|
|
106
|
+
isClickLikeOpenEvent = (0, import_use_event.useEvent)(() => dataRef.current.openEvent ? ["click", "mousedown"].includes(dataRef.current.openEvent.type) : !1);
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
if (!enabled) return;
|
|
109
|
+
function onReferenceMouseEnter(event) {
|
|
110
|
+
if ((0, import_utils.clearTimeoutIfSet)(timeoutRef), blockMouseMoveRef.current = !1, mouseOnly && !(0, import_utils.isMouseLikePointerType)(pointerTypeRef.current) || restMsRef.current > 0 && !getDelay(delayRef.current, "open")) return;
|
|
111
|
+
const openDelay = getDelay(delayRef.current, "open", pointerTypeRef.current);
|
|
112
|
+
openDelay ? timeoutRef.current = window.setTimeout(() => {
|
|
113
|
+
openRef.current || stableOnOpenChange(!0, event, "hover");
|
|
114
|
+
}, openDelay) : open || stableOnOpenChange(!0, event, "hover");
|
|
115
|
+
}
|
|
116
|
+
function onReferenceMouseLeave(event) {
|
|
117
|
+
if (isClickLikeOpenEvent()) {
|
|
118
|
+
clearPointerEvents();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
if (context.triggerElements?.hasElement(event.relatedTarget)) return;
|
|
122
|
+
unbindMouseMoveRef.current();
|
|
123
|
+
const doc = (0, import_utils.getDocument)(elements.floating);
|
|
124
|
+
if ((0, import_utils.clearTimeoutIfSet)(restTimeoutRef), restTimeoutPendingRef.current = !1, handleCloseRef.current) {
|
|
125
|
+
open || (0, import_utils.clearTimeoutIfSet)(timeoutRef);
|
|
126
|
+
const placement = dataRef.current.placement || "bottom",
|
|
127
|
+
reference2 = elements.domReference,
|
|
128
|
+
floating = elements.floating;
|
|
129
|
+
if (!reference2 || !floating) return;
|
|
130
|
+
handlerRef.current = handleCloseRef.current({
|
|
131
|
+
x: event.clientX,
|
|
132
|
+
y: event.clientY,
|
|
133
|
+
placement,
|
|
134
|
+
elements: {
|
|
135
|
+
reference: reference2,
|
|
136
|
+
floating,
|
|
137
|
+
domReference: reference2
|
|
138
|
+
},
|
|
139
|
+
onClose() {
|
|
140
|
+
context.handleCloseActiveRef && (context.handleCloseActiveRef.current = !1), clearPointerEvents(), cleanupMouseMoveHandler(), isClickLikeOpenEvent() || closeWithDelay(event, !0, "safe-polygon");
|
|
141
|
+
}
|
|
142
|
+
}), context.handleCloseActiveRef && (context.handleCloseActiveRef.current = !0);
|
|
143
|
+
const handler = handlerRef.current;
|
|
144
|
+
doc.addEventListener("mousemove", handler), unbindMouseMoveRef.current = () => {
|
|
145
|
+
doc.removeEventListener("mousemove", handler);
|
|
146
|
+
};
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
(pointerTypeRef.current !== "touch" || !(0, import_utils.contains)(elements.floating, event.relatedTarget)) && closeWithDelay(event);
|
|
150
|
+
}
|
|
151
|
+
function onScrollMouseLeave(event) {
|
|
152
|
+
if (isClickLikeOpenEvent() || context.triggerElements?.hasElement(event.relatedTarget)) return;
|
|
153
|
+
const placement = dataRef.current.placement || "bottom",
|
|
154
|
+
reference2 = elements.domReference,
|
|
155
|
+
floating = elements.floating;
|
|
156
|
+
!reference2 || !floating || handleCloseRef.current?.({
|
|
157
|
+
x: event.clientX,
|
|
158
|
+
y: event.clientY,
|
|
159
|
+
placement,
|
|
160
|
+
elements: {
|
|
161
|
+
reference: reference2,
|
|
162
|
+
floating,
|
|
163
|
+
domReference: reference2
|
|
164
|
+
},
|
|
165
|
+
onClose() {
|
|
166
|
+
clearPointerEvents(), cleanupMouseMoveHandler(), isClickLikeOpenEvent() || closeWithDelay(event);
|
|
167
|
+
}
|
|
168
|
+
})(event);
|
|
169
|
+
}
|
|
170
|
+
function onFloatingMouseEnter() {
|
|
171
|
+
(0, import_utils.clearTimeoutIfSet)(timeoutRef);
|
|
172
|
+
}
|
|
173
|
+
function onFloatingMouseLeave(event) {
|
|
174
|
+
isClickLikeOpenEvent() || context.triggerElements?.hasElement(event.relatedTarget) || closeWithDelay(event, !1);
|
|
175
|
+
}
|
|
176
|
+
if ((0, import_utils.isElement)(elements.domReference)) {
|
|
177
|
+
const reference2 = elements.domReference,
|
|
178
|
+
floating = elements.floating;
|
|
179
|
+
return open && reference2.addEventListener("mouseleave", onScrollMouseLeave), move && reference2.addEventListener("mousemove", onReferenceMouseEnter, {
|
|
180
|
+
once: !0
|
|
181
|
+
}), reference2.addEventListener("mouseenter", onReferenceMouseEnter), reference2.addEventListener("mouseleave", onReferenceMouseLeave), floating && (floating.addEventListener("mouseleave", onScrollMouseLeave), floating.addEventListener("mouseenter", onFloatingMouseEnter), floating.addEventListener("mouseleave", onFloatingMouseLeave)), () => {
|
|
182
|
+
open && reference2.removeEventListener("mouseleave", onScrollMouseLeave), move && reference2.removeEventListener("mousemove", onReferenceMouseEnter), reference2.removeEventListener("mouseenter", onReferenceMouseEnter), reference2.removeEventListener("mouseleave", onReferenceMouseLeave), floating && (floating.removeEventListener("mouseleave", onScrollMouseLeave), floating.removeEventListener("mouseenter", onFloatingMouseEnter), floating.removeEventListener("mouseleave", onFloatingMouseLeave)), cleanupMouseMoveHandler();
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}, [elements, enabled, context, mouseOnly, move, open, dataRef]), React.useLayoutEffect(() => {
|
|
186
|
+
if (enabled && open && handleCloseRef.current?.__options?.blockPointerEvents && isHoverOpen()) {
|
|
187
|
+
performedPointerEventsMutationRef.current = !0;
|
|
188
|
+
const floatingEl = elements.floating;
|
|
189
|
+
if ((0, import_utils.isElement)(elements.domReference) && floatingEl) {
|
|
190
|
+
const body = (0, import_utils.getDocument)(elements.floating).body;
|
|
191
|
+
body.setAttribute(safePolygonIdentifier, "");
|
|
192
|
+
const ref = elements.domReference;
|
|
193
|
+
return body.style.pointerEvents = "none", ref.style.pointerEvents = "auto", floatingEl.style.pointerEvents = "auto", () => {
|
|
194
|
+
body.style.pointerEvents = "", ref.style.pointerEvents = "", floatingEl.style.pointerEvents = "";
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, [enabled, open, elements, isHoverOpen]), React.useLayoutEffect(() => {
|
|
199
|
+
open || (pointerTypeRef.current = void 0, restTimeoutPendingRef.current = !1, cleanupMouseMoveHandler(), clearPointerEvents());
|
|
200
|
+
}, [open]), React.useEffect(() => () => {
|
|
201
|
+
cleanupMouseMoveHandler(), (0, import_utils.clearTimeoutIfSet)(timeoutRef), (0, import_utils.clearTimeoutIfSet)(restTimeoutRef), clearPointerEvents();
|
|
202
|
+
}, [enabled, elements.domReference]);
|
|
203
|
+
const reference = React.useMemo(() => {
|
|
204
|
+
function setPointerRef(event) {
|
|
205
|
+
pointerTypeRef.current = event.pointerType;
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
onPointerDown: setPointerRef,
|
|
209
|
+
onPointerEnter: setPointerRef,
|
|
210
|
+
onMouseMove(event) {
|
|
211
|
+
const {
|
|
212
|
+
nativeEvent
|
|
213
|
+
} = event;
|
|
214
|
+
function handleMouseMove() {
|
|
215
|
+
!blockMouseMoveRef.current && !openRef.current && stableOnOpenChange(!0, nativeEvent, "hover");
|
|
216
|
+
}
|
|
217
|
+
mouseOnly && !(0, import_utils.isMouseLikePointerType)(pointerTypeRef.current) || open || restMsRef.current === 0 || restTimeoutPendingRef.current && event.movementX ** 2 + event.movementY ** 2 < 2 || ((0, import_utils.clearTimeoutIfSet)(restTimeoutRef), pointerTypeRef.current === "touch" ? handleMouseMove() : (restTimeoutPendingRef.current = !0, restTimeoutRef.current = window.setTimeout(handleMouseMove, restMsRef.current)));
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
}, [mouseOnly, open]);
|
|
221
|
+
return React.useMemo(() => enabled ? {
|
|
222
|
+
reference
|
|
223
|
+
} : {}, [enabled, reference]);
|
|
224
|
+
}
|