@tamagui/floating 2.7.7 → 3.0.0-beta.643.1
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.cjs +10 -11
- package/dist/cjs/Floating.native.cjs +37 -0
- package/dist/cjs/Floating.native.js +20 -20
- package/dist/cjs/Floating.native.js.map +1 -1
- package/dist/cjs/index.cjs +45 -46
- package/dist/cjs/index.native.cjs +74 -0
- package/dist/cjs/index.native.js +45 -45
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/interactions/PopupTriggerMap.cjs +36 -39
- package/dist/cjs/interactions/PopupTriggerMap.native.cjs +96 -0
- package/dist/cjs/interactions/PopupTriggerMap.native.js +76 -75
- package/dist/cjs/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/cjs/interactions/createFloatingEvents.cjs +36 -39
- package/dist/cjs/interactions/createFloatingEvents.native.cjs +52 -0
- package/dist/cjs/interactions/createFloatingEvents.native.js +39 -41
- package/dist/cjs/interactions/createFloatingEvents.native.js.map +1 -1
- package/dist/cjs/interactions/safePolygon.cjs +263 -252
- package/dist/cjs/interactions/safePolygon.native.cjs +294 -0
- package/dist/cjs/interactions/safePolygon.native.js +271 -259
- package/dist/cjs/interactions/safePolygon.native.js.map +1 -1
- package/dist/cjs/interactions/types.cjs +10 -11
- package/dist/cjs/interactions/types.native.cjs +19 -0
- package/dist/cjs/interactions/types.native.js +10 -10
- package/dist/cjs/interactions/types.native.js.map +1 -1
- package/dist/cjs/interactions/useClick.cjs +96 -105
- package/dist/cjs/interactions/useClick.native.cjs +122 -0
- package/dist/cjs/interactions/useClick.native.js +101 -109
- package/dist/cjs/interactions/useClick.native.js.map +1 -1
- package/dist/cjs/interactions/useDelayGroup.cjs +86 -91
- package/dist/cjs/interactions/useDelayGroup.native.cjs +119 -0
- package/dist/cjs/interactions/useDelayGroup.native.js +92 -96
- package/dist/cjs/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/cjs/interactions/useFocus.cjs +108 -115
- package/dist/cjs/interactions/useFocus.native.cjs +131 -0
- package/dist/cjs/interactions/useFocus.native.js +114 -120
- package/dist/cjs/interactions/useFocus.native.js.map +1 -1
- package/dist/cjs/interactions/useHover.cjs +321 -335
- package/dist/cjs/interactions/useHover.native.cjs +357 -0
- package/dist/cjs/interactions/useHover.native.js +333 -347
- package/dist/cjs/interactions/useHover.native.js.map +1 -1
- package/dist/cjs/interactions/useInnerOffset.cjs +103 -111
- package/dist/cjs/interactions/useInnerOffset.native.cjs +132 -0
- package/dist/cjs/interactions/useInnerOffset.native.js +113 -120
- package/dist/cjs/interactions/useInnerOffset.native.js.map +1 -1
- package/dist/cjs/interactions/useInteractions.cjs +85 -90
- package/dist/cjs/interactions/useInteractions.native.cjs +199 -0
- package/dist/cjs/interactions/useInteractions.native.js +180 -195
- package/dist/cjs/interactions/useInteractions.native.js.map +1 -1
- package/dist/cjs/interactions/useListNavigation.cjs +404 -390
- package/dist/cjs/interactions/useListNavigation.native.cjs +446 -0
- package/dist/cjs/interactions/useListNavigation.native.js +416 -401
- package/dist/cjs/interactions/useListNavigation.native.js.map +1 -1
- package/dist/cjs/interactions/useRole.cjs +92 -106
- package/dist/cjs/interactions/useRole.native.cjs +121 -0
- package/dist/cjs/interactions/useRole.native.js +103 -116
- package/dist/cjs/interactions/useRole.native.js.map +1 -1
- package/dist/cjs/interactions/useTypeahead.cjs +115 -129
- package/dist/cjs/interactions/useTypeahead.native.cjs +144 -0
- package/dist/cjs/interactions/useTypeahead.native.js +128 -141
- package/dist/cjs/interactions/useTypeahead.native.js.map +1 -1
- package/dist/cjs/interactions/utils.cjs +126 -143
- package/dist/cjs/interactions/utils.native.cjs +209 -0
- package/dist/cjs/interactions/utils.native.js +138 -154
- package/dist/cjs/interactions/utils.native.js.map +1 -1
- package/dist/cjs/middleware/inner.cjs +74 -101
- package/dist/cjs/middleware/inner.native.cjs +102 -0
- package/dist/cjs/middleware/inner.native.js +83 -109
- package/dist/cjs/middleware/inner.native.js.map +1 -1
- package/dist/cjs/useFloating.cjs +34 -46
- package/dist/cjs/useFloating.native.cjs +56 -0
- package/dist/cjs/useFloating.native.js +37 -48
- package/dist/cjs/useFloating.native.js.map +1 -1
- package/dist/esm/Floating.mjs +1 -2
- package/dist/esm/Floating.native.js +6 -4
- package/dist/esm/Floating.native.js.map +1 -1
- package/dist/esm/index.js +4 -5
- package/dist/esm/index.mjs +4 -5
- package/dist/esm/index.native.js +4 -5
- package/dist/esm/interactions/PopupTriggerMap.mjs +23 -22
- package/dist/esm/interactions/PopupTriggerMap.mjs.map +1 -1
- package/dist/esm/interactions/PopupTriggerMap.native.js +62 -58
- package/dist/esm/interactions/PopupTriggerMap.native.js.map +1 -1
- package/dist/esm/interactions/createFloatingEvents.mjs +22 -21
- package/dist/esm/interactions/createFloatingEvents.mjs.map +1 -1
- package/dist/esm/interactions/createFloatingEvents.native.js +25 -24
- package/dist/esm/interactions/createFloatingEvents.native.js.map +1 -1
- package/dist/esm/interactions/safePolygon.mjs +250 -234
- package/dist/esm/interactions/safePolygon.mjs.map +1 -1
- package/dist/esm/interactions/safePolygon.native.js +258 -242
- package/dist/esm/interactions/safePolygon.native.js.map +1 -1
- package/dist/esm/interactions/types.mjs +0 -2
- package/dist/esm/interactions/types.native.js +0 -2
- package/dist/esm/interactions/useClick.mjs +83 -87
- package/dist/esm/interactions/useClick.mjs.map +1 -1
- package/dist/esm/interactions/useClick.native.js +88 -92
- package/dist/esm/interactions/useClick.native.js.map +1 -1
- package/dist/esm/interactions/useDelayGroup.mjs +68 -65
- package/dist/esm/interactions/useDelayGroup.mjs.map +1 -1
- package/dist/esm/interactions/useDelayGroup.native.js +74 -71
- package/dist/esm/interactions/useDelayGroup.native.js.map +1 -1
- package/dist/esm/interactions/useFocus.mjs +95 -97
- package/dist/esm/interactions/useFocus.mjs.map +1 -1
- package/dist/esm/interactions/useFocus.native.js +101 -103
- package/dist/esm/interactions/useFocus.native.js.map +1 -1
- package/dist/esm/interactions/useHover.mjs +304 -310
- package/dist/esm/interactions/useHover.mjs.map +1 -1
- package/dist/esm/interactions/useHover.native.js +316 -323
- package/dist/esm/interactions/useHover.native.js.map +1 -1
- package/dist/esm/interactions/useInnerOffset.mjs +87 -85
- package/dist/esm/interactions/useInnerOffset.mjs.map +1 -1
- package/dist/esm/interactions/useInnerOffset.native.js +97 -95
- package/dist/esm/interactions/useInnerOffset.native.js.map +1 -1
- package/dist/esm/interactions/useInteractions.mjs +71 -72
- package/dist/esm/interactions/useInteractions.mjs.map +1 -1
- package/dist/esm/interactions/useInteractions.native.js +166 -178
- package/dist/esm/interactions/useInteractions.native.js.map +1 -1
- package/dist/esm/interactions/useListNavigation.mjs +392 -373
- package/dist/esm/interactions/useListNavigation.mjs.map +1 -1
- package/dist/esm/interactions/useListNavigation.native.js +404 -385
- package/dist/esm/interactions/useListNavigation.native.js.map +1 -1
- package/dist/esm/interactions/useRole.mjs +76 -80
- package/dist/esm/interactions/useRole.mjs.map +1 -1
- package/dist/esm/interactions/useRole.native.js +87 -91
- package/dist/esm/interactions/useRole.native.js.map +1 -1
- package/dist/esm/interactions/useTypeahead.mjs +102 -111
- package/dist/esm/interactions/useTypeahead.mjs.map +1 -1
- package/dist/esm/interactions/useTypeahead.native.js +115 -124
- package/dist/esm/interactions/useTypeahead.native.js.map +1 -1
- package/dist/esm/interactions/utils.mjs +91 -106
- package/dist/esm/interactions/utils.mjs.map +1 -1
- package/dist/esm/interactions/utils.native.js +103 -118
- package/dist/esm/interactions/utils.native.js.map +1 -1
- package/dist/esm/middleware/inner.mjs +58 -75
- package/dist/esm/middleware/inner.mjs.map +1 -1
- package/dist/esm/middleware/inner.native.js +67 -84
- package/dist/esm/middleware/inner.native.js.map +1 -1
- package/dist/esm/useFloating.mjs +17 -21
- package/dist/esm/useFloating.mjs.map +1 -1
- package/dist/esm/useFloating.native.js +19 -23
- package/dist/esm/useFloating.native.js.map +1 -1
- package/package.json +6 -5
- package/types/interactions/PopupTriggerMap.d.ts.map +1 -1
- package/types/interactions/useInteractions.d.ts.map +1 -1
- package/types/middleware/inner.d.ts.map +1 -1
- package/types/useFloating.d.ts.map +1 -1
- package/dist/esm/Floating.mjs.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
- package/dist/esm/interactions/types.mjs.map +0 -1
- package/dist/esm/interactions/types.native.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
5
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -7,119 +8,114 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
7
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
10
|
var __export = (target, all) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
14
15
|
};
|
|
15
16
|
var __copyProps = (to, from, except, desc) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
19
|
+
get: () => from[key],
|
|
20
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
23
24
|
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
30
|
-
value: mod,
|
|
31
|
-
enumerable: true
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
32
28
|
}) : target, mod));
|
|
33
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
34
|
-
value: true
|
|
35
|
-
}), mod);
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
30
|
var useDelayGroup_exports = {};
|
|
37
31
|
__export(useDelayGroup_exports, {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
FloatingDelayGroup: () => FloatingDelayGroup,
|
|
33
|
+
useDelayGroup: () => useDelayGroup,
|
|
34
|
+
useDelayGroupContext: () => useDelayGroupContext
|
|
41
35
|
});
|
|
42
36
|
module.exports = __toCommonJS(useDelayGroup_exports);
|
|
43
37
|
var React = __toESM(require("react"), 1);
|
|
44
38
|
var DelayGroupContext = React.createContext({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
currentId: null,
|
|
40
|
+
setCurrentId: function() {},
|
|
41
|
+
delay: 0,
|
|
42
|
+
timeoutMs: 0,
|
|
43
|
+
initialDelay: 0
|
|
50
44
|
});
|
|
51
45
|
function useDelayGroupContext() {
|
|
52
|
-
|
|
46
|
+
return React.useContext(DelayGroupContext);
|
|
53
47
|
}
|
|
54
48
|
function FloatingDelayGroup(param) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, children);
|
|
49
|
+
var { children, delay, timeoutMs = 0 } = param;
|
|
50
|
+
var [currentId, setCurrentIdRaw] = React.useState(null);
|
|
51
|
+
var timeoutRef = React.useRef(void 0);
|
|
52
|
+
var setCurrentId = React.useCallback(function(id) {
|
|
53
|
+
clearTimeout(timeoutRef.current);
|
|
54
|
+
if (id == null && timeoutMs > 0) {
|
|
55
|
+
timeoutRef.current = setTimeout(function() {
|
|
56
|
+
setCurrentIdRaw(null);
|
|
57
|
+
}, timeoutMs);
|
|
58
|
+
} else {
|
|
59
|
+
setCurrentIdRaw(id);
|
|
60
|
+
}
|
|
61
|
+
}, [timeoutMs]);
|
|
62
|
+
React.useEffect(function() {
|
|
63
|
+
return function() {
|
|
64
|
+
return clearTimeout(timeoutRef.current);
|
|
65
|
+
};
|
|
66
|
+
}, []);
|
|
67
|
+
var value = React.useMemo(function() {
|
|
68
|
+
return {
|
|
69
|
+
currentId,
|
|
70
|
+
setCurrentId,
|
|
71
|
+
delay,
|
|
72
|
+
timeoutMs,
|
|
73
|
+
initialDelay: delay
|
|
74
|
+
};
|
|
75
|
+
}, [
|
|
76
|
+
currentId,
|
|
77
|
+
setCurrentId,
|
|
78
|
+
delay,
|
|
79
|
+
timeoutMs
|
|
80
|
+
]);
|
|
81
|
+
return React.createElement(DelayGroupContext.Provider, { value }, children);
|
|
89
82
|
}
|
|
90
83
|
function useDelayGroup(context) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
84
|
+
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
85
|
+
var { id } = options;
|
|
86
|
+
var groupContext = React.useContext(DelayGroupContext);
|
|
87
|
+
React.useEffect(function() {
|
|
88
|
+
if (!context.open && groupContext.currentId === id) {
|
|
89
|
+
groupContext.setCurrentId(null);
|
|
90
|
+
}
|
|
91
|
+
}, [context.open, id]);
|
|
92
|
+
React.useEffect(function() {
|
|
93
|
+
if (groupContext.currentId != null && groupContext.currentId !== id && context.open) {
|
|
94
|
+
context.onOpenChange(false);
|
|
95
|
+
}
|
|
96
|
+
}, [
|
|
97
|
+
groupContext.currentId,
|
|
98
|
+
id,
|
|
99
|
+
context.open
|
|
100
|
+
]);
|
|
101
|
+
if (groupContext.currentId != null) {
|
|
102
|
+
return {
|
|
103
|
+
delay: {
|
|
104
|
+
open: 1,
|
|
105
|
+
close: getClose(groupContext.initialDelay)
|
|
106
|
+
},
|
|
107
|
+
currentId: groupContext.currentId
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
delay: groupContext.initialDelay,
|
|
112
|
+
currentId: groupContext.currentId
|
|
113
|
+
};
|
|
119
114
|
}
|
|
120
115
|
function getClose(delay) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
if (typeof delay === "number") return delay;
|
|
117
|
+
var _delay_close;
|
|
118
|
+
return (_delay_close = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _delay_close !== void 0 ? _delay_close : 0;
|
|
124
119
|
}
|
|
120
|
+
|
|
125
121
|
//# sourceMappingURL=useDelayGroup.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"useDelayGroup.native.js","names":[],"sources":["cjs/interactions/useDelayGroup.native.js"],"sourcesContent":["\"use strict\";\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(\n // If the importer is in node compatibility mode or this is not an ESM\n // file that has been converted to a CommonJS file using a Babel-\n // compatible transform (i.e. \"__esModule\" has not been set), then set\n // \"default\" to the CommonJS \"module.exports\" for node compatibility.\n isNodeMode || !mod || !mod.__esModule ? __defProp(target, \"default\", { value: mod, enumerable: true }) : target,\n mod\n));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar useDelayGroup_exports = {};\n__export(useDelayGroup_exports, {\n FloatingDelayGroup: () => FloatingDelayGroup,\n useDelayGroup: () => useDelayGroup,\n useDelayGroupContext: () => useDelayGroupContext\n});\nmodule.exports = __toCommonJS(useDelayGroup_exports);\nvar React = __toESM(require(\"react\"), 1);\nvar DelayGroupContext = React.createContext({\n currentId: null,\n setCurrentId: function() {\n },\n delay: 0,\n timeoutMs: 0,\n initialDelay: 0\n});\nfunction useDelayGroupContext() {\n return React.useContext(DelayGroupContext);\n}\nfunction FloatingDelayGroup(param) {\n var { children, delay, timeoutMs = 0 } = param;\n var [currentId, setCurrentIdRaw] = React.useState(null);\n var timeoutRef = React.useRef(void 0);\n var setCurrentId = React.useCallback(function(id) {\n clearTimeout(timeoutRef.current);\n if (id == null && timeoutMs > 0) {\n timeoutRef.current = setTimeout(function() {\n setCurrentIdRaw(null);\n }, timeoutMs);\n } else {\n setCurrentIdRaw(id);\n }\n }, [\n timeoutMs\n ]);\n React.useEffect(function() {\n return function() {\n return clearTimeout(timeoutRef.current);\n };\n }, []);\n var value = React.useMemo(function() {\n return {\n currentId,\n setCurrentId,\n delay,\n timeoutMs,\n initialDelay: delay\n };\n }, [\n currentId,\n setCurrentId,\n delay,\n timeoutMs\n ]);\n return React.createElement(DelayGroupContext.Provider, {\n value\n }, children);\n}\nfunction useDelayGroup(context) {\n var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};\n var { id } = options;\n var groupContext = React.useContext(DelayGroupContext);\n React.useEffect(function() {\n if (!context.open && groupContext.currentId === id) {\n groupContext.setCurrentId(null);\n }\n }, [\n context.open,\n id\n ]);\n React.useEffect(function() {\n if (groupContext.currentId != null && groupContext.currentId !== id && context.open) {\n context.onOpenChange(false);\n }\n }, [\n groupContext.currentId,\n id,\n context.open\n ]);\n if (groupContext.currentId != null) {\n return {\n delay: {\n open: 1,\n close: getClose(groupContext.initialDelay)\n },\n currentId: groupContext.currentId\n };\n }\n return {\n delay: groupContext.initialDelay,\n currentId: groupContext.currentId\n };\n}\nfunction getClose(delay) {\n if (typeof delay === \"number\") return delay;\n var _delay_close;\n return (_delay_close = delay === null || delay === void 0 ? void 0 : delay.close) !== null && _delay_close !== void 0 ? _delay_close : 0;\n}\n//# sourceMappingURL=useDelayGroup.js.map\n"],"mappings":";;;;AACA,IAAI,WAAW,OAAO;AACtB,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B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ACA,WAAW,aAAa;EAC1B;CACF;CACA,OAAO;EACL,OAAO,aAAa;EACpB,WAAW,aAAa;CAC1B;AACF;AACA,SAAS,SAAS,OAAO;CACvB,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,IAAI;CACJ,QAAQ,eAAe,UAAU,QAAQ,UAAU,KAAK,IAAI,KAAK,IAAI,MAAM,WAAW,QAAQ,iBAAiB,KAAK,IAAI,eAAe;AACzI"}
|
|
@@ -1,130 +1,123 @@
|
|
|
1
|
+
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
6
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
for (var name in all) __defProp(target, name, {
|
|
8
|
+
get: all[name],
|
|
9
|
+
enumerable: true
|
|
10
|
+
});
|
|
10
11
|
};
|
|
11
12
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
19
20
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
22
|
var useFocus_exports = {};
|
|
24
|
-
__export(useFocus_exports, {
|
|
25
|
-
useFocus: () => useFocus
|
|
26
|
-
});
|
|
23
|
+
__export(useFocus_exports, { useFocus: () => useFocus });
|
|
27
24
|
module.exports = __toCommonJS(useFocus_exports);
|
|
28
25
|
var import_react = require("react");
|
|
29
26
|
var import_utils = require("./utils.cjs");
|
|
30
27
|
function isMacSafari() {
|
|
31
|
-
|
|
28
|
+
return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
|
|
32
29
|
}
|
|
33
30
|
function useFocus(context, props = {}) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
return (0, import_react.useMemo)(() => enabled ? {
|
|
128
|
-
reference
|
|
129
|
-
} : {}, [enabled, reference]);
|
|
130
|
-
}
|
|
31
|
+
const { open, onOpenChange, events, dataRef, elements } = context;
|
|
32
|
+
const { enabled = true, visibleOnly = true } = props;
|
|
33
|
+
const blockFocusRef = (0, import_react.useRef)(false);
|
|
34
|
+
const timeoutRef = (0, import_react.useRef)(-1);
|
|
35
|
+
const keyboardModalityRef = (0, import_react.useRef)(true);
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
if (!enabled) return;
|
|
38
|
+
const win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
|
|
39
|
+
function onBlur() {
|
|
40
|
+
if (!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference))) {
|
|
41
|
+
blockFocusRef.current = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function onKeyDown() {
|
|
45
|
+
keyboardModalityRef.current = true;
|
|
46
|
+
}
|
|
47
|
+
function onPointerDown() {
|
|
48
|
+
keyboardModalityRef.current = false;
|
|
49
|
+
}
|
|
50
|
+
win.addEventListener("blur", onBlur);
|
|
51
|
+
if (isMacSafari()) {
|
|
52
|
+
win.addEventListener("keydown", onKeyDown, true);
|
|
53
|
+
win.addEventListener("pointerdown", onPointerDown, true);
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
win.removeEventListener("blur", onBlur);
|
|
57
|
+
if (isMacSafari()) {
|
|
58
|
+
win.removeEventListener("keydown", onKeyDown, true);
|
|
59
|
+
win.removeEventListener("pointerdown", onPointerDown, true);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}, [
|
|
63
|
+
elements.domReference,
|
|
64
|
+
open,
|
|
65
|
+
enabled
|
|
66
|
+
]);
|
|
67
|
+
(0, import_react.useEffect)(() => {
|
|
68
|
+
if (!enabled) return;
|
|
69
|
+
if (!events) return;
|
|
70
|
+
function handleOpenChange({ reason }) {
|
|
71
|
+
if (reason === "reference-press" || reason === "escape-key") {
|
|
72
|
+
blockFocusRef.current = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
events.on("openchange", handleOpenChange);
|
|
76
|
+
return () => {
|
|
77
|
+
events.off("openchange", handleOpenChange);
|
|
78
|
+
};
|
|
79
|
+
}, [events, enabled]);
|
|
80
|
+
(0, import_react.useEffect)(() => {
|
|
81
|
+
return () => {
|
|
82
|
+
(0, import_utils.clearTimeoutIfSet)(timeoutRef);
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
const reference = (0, import_react.useMemo)(() => ({
|
|
86
|
+
onMouseLeave() {
|
|
87
|
+
blockFocusRef.current = false;
|
|
88
|
+
},
|
|
89
|
+
onFocus(event) {
|
|
90
|
+
if (blockFocusRef.current) return;
|
|
91
|
+
const target = (0, import_utils.getTarget)(event.nativeEvent);
|
|
92
|
+
if (visibleOnly && (0, import_utils.isElement)(target)) {
|
|
93
|
+
if (isMacSafari() && !event.relatedTarget) {
|
|
94
|
+
if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
} else if (!(0, import_utils.matchesFocusVisible)(target)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
onOpenChange(true, event.nativeEvent, "focus");
|
|
102
|
+
},
|
|
103
|
+
onBlur(event) {
|
|
104
|
+
blockFocusRef.current = false;
|
|
105
|
+
const relatedTarget = event.relatedTarget;
|
|
106
|
+
const nativeEvent = event.nativeEvent;
|
|
107
|
+
timeoutRef.current = window.setTimeout(() => {
|
|
108
|
+
const activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
|
|
109
|
+
if (!relatedTarget && activeEl === elements.domReference) return;
|
|
110
|
+
if ((0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl)) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
onOpenChange(false, nativeEvent, "focus");
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}), [
|
|
117
|
+
context.refs.floating,
|
|
118
|
+
elements.domReference,
|
|
119
|
+
onOpenChange,
|
|
120
|
+
visibleOnly
|
|
121
|
+
]);
|
|
122
|
+
return (0, import_react.useMemo)(() => enabled ? { reference } : {}, [enabled, reference]);
|
|
123
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all) __defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: () => from[key],
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var useFocus_exports = {};
|
|
25
|
+
__export(useFocus_exports, { useFocus: () => useFocus });
|
|
26
|
+
module.exports = __toCommonJS(useFocus_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_utils = require("./utils.native.js");
|
|
29
|
+
function isMacSafari() {
|
|
30
|
+
return (0, import_utils.isMac)() && (0, import_utils.isSafari)();
|
|
31
|
+
}
|
|
32
|
+
function useFocus(context) {
|
|
33
|
+
var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
34
|
+
var { open, onOpenChange, events, dataRef, elements } = context;
|
|
35
|
+
var { enabled = true, visibleOnly = true } = props;
|
|
36
|
+
var blockFocusRef = (0, import_react.useRef)(false);
|
|
37
|
+
var timeoutRef = (0, import_react.useRef)(-1);
|
|
38
|
+
var keyboardModalityRef = (0, import_react.useRef)(true);
|
|
39
|
+
(0, import_react.useEffect)(function() {
|
|
40
|
+
if (!enabled) return;
|
|
41
|
+
var win = (0, import_utils.getDocument)(elements.domReference).defaultView || window;
|
|
42
|
+
function onBlur() {
|
|
43
|
+
if (!open && (0, import_utils.isHTMLElement)(elements.domReference) && elements.domReference === (0, import_utils.activeElement)((0, import_utils.getDocument)(elements.domReference))) {
|
|
44
|
+
blockFocusRef.current = true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function onKeyDown() {
|
|
48
|
+
keyboardModalityRef.current = true;
|
|
49
|
+
}
|
|
50
|
+
function onPointerDown() {
|
|
51
|
+
keyboardModalityRef.current = false;
|
|
52
|
+
}
|
|
53
|
+
win.addEventListener("blur", onBlur);
|
|
54
|
+
if (isMacSafari()) {
|
|
55
|
+
win.addEventListener("keydown", onKeyDown, true);
|
|
56
|
+
win.addEventListener("pointerdown", onPointerDown, true);
|
|
57
|
+
}
|
|
58
|
+
return function() {
|
|
59
|
+
win.removeEventListener("blur", onBlur);
|
|
60
|
+
if (isMacSafari()) {
|
|
61
|
+
win.removeEventListener("keydown", onKeyDown, true);
|
|
62
|
+
win.removeEventListener("pointerdown", onPointerDown, true);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
elements.domReference,
|
|
67
|
+
open,
|
|
68
|
+
enabled
|
|
69
|
+
]);
|
|
70
|
+
(0, import_react.useEffect)(function() {
|
|
71
|
+
if (!enabled) return;
|
|
72
|
+
if (!events) return;
|
|
73
|
+
function handleOpenChange(param) {
|
|
74
|
+
var { reason } = param;
|
|
75
|
+
if (reason === "reference-press" || reason === "escape-key") {
|
|
76
|
+
blockFocusRef.current = true;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
events.on("openchange", handleOpenChange);
|
|
80
|
+
return function() {
|
|
81
|
+
events.off("openchange", handleOpenChange);
|
|
82
|
+
};
|
|
83
|
+
}, [events, enabled]);
|
|
84
|
+
(0, import_react.useEffect)(function() {
|
|
85
|
+
return function() {
|
|
86
|
+
(0, import_utils.clearTimeoutIfSet)(timeoutRef);
|
|
87
|
+
};
|
|
88
|
+
}, []);
|
|
89
|
+
var reference = (0, import_react.useMemo)(function() {
|
|
90
|
+
return {
|
|
91
|
+
onMouseLeave() {
|
|
92
|
+
blockFocusRef.current = false;
|
|
93
|
+
},
|
|
94
|
+
onFocus(event) {
|
|
95
|
+
if (blockFocusRef.current) return;
|
|
96
|
+
var target = (0, import_utils.getTarget)(event.nativeEvent);
|
|
97
|
+
if (visibleOnly && (0, import_utils.isElement)(target)) {
|
|
98
|
+
if (isMacSafari() && !event.relatedTarget) {
|
|
99
|
+
if (!keyboardModalityRef.current && !(0, import_utils.isTypeableElement)(target)) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
} else if (!(0, import_utils.matchesFocusVisible)(target)) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
onOpenChange(true, event.nativeEvent, "focus");
|
|
107
|
+
},
|
|
108
|
+
onBlur(event) {
|
|
109
|
+
blockFocusRef.current = false;
|
|
110
|
+
var relatedTarget = event.relatedTarget;
|
|
111
|
+
var nativeEvent = event.nativeEvent;
|
|
112
|
+
timeoutRef.current = window.setTimeout(function() {
|
|
113
|
+
var activeEl = (0, import_utils.activeElement)(elements.domReference ? elements.domReference.ownerDocument : document);
|
|
114
|
+
if (!relatedTarget && activeEl === elements.domReference) return;
|
|
115
|
+
if ((0, import_utils.contains)(context.refs.floating.current, activeEl) || (0, import_utils.contains)(elements.domReference, activeEl)) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
onOpenChange(false, nativeEvent, "focus");
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}, [
|
|
123
|
+
context.refs.floating,
|
|
124
|
+
elements.domReference,
|
|
125
|
+
onOpenChange,
|
|
126
|
+
visibleOnly
|
|
127
|
+
]);
|
|
128
|
+
return (0, import_react.useMemo)(function() {
|
|
129
|
+
return enabled ? { reference } : {};
|
|
130
|
+
}, [enabled, reference]);
|
|
131
|
+
}
|