@zag-js/popover 0.0.0-dev-20220413175519 → 0.0.0-dev-20220415160434
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/index.js +284 -3031
- package/dist/index.js.map +3 -3
- package/dist/index.mjs +322 -3069
- package/dist/index.mjs.map +3 -3
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -19,18 +19,6 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
return a;
|
|
20
20
|
};
|
|
21
21
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
-
var __objRest = (source, exclude) => {
|
|
23
|
-
var target = {};
|
|
24
|
-
for (var prop in source)
|
|
25
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
-
target[prop] = source[prop];
|
|
27
|
-
if (source != null && __getOwnPropSymbols)
|
|
28
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
-
target[prop] = source[prop];
|
|
31
|
-
}
|
|
32
|
-
return target;
|
|
33
|
-
};
|
|
34
22
|
var __export = (target, all) => {
|
|
35
23
|
for (var name in all)
|
|
36
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -44,26 +32,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
44
32
|
return to;
|
|
45
33
|
};
|
|
46
34
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
47
|
-
var __async = (__this, __arguments, generator) => {
|
|
48
|
-
return new Promise((resolve, reject) => {
|
|
49
|
-
var fulfilled = (value) => {
|
|
50
|
-
try {
|
|
51
|
-
step(generator.next(value));
|
|
52
|
-
} catch (e2) {
|
|
53
|
-
reject(e2);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var rejected = (value) => {
|
|
57
|
-
try {
|
|
58
|
-
step(generator.throw(value));
|
|
59
|
-
} catch (e2) {
|
|
60
|
-
reject(e2);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
64
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
35
|
|
|
68
36
|
// src/index.ts
|
|
69
37
|
var src_exports = {};
|
|
@@ -73,27 +41,137 @@ __export(src_exports, {
|
|
|
73
41
|
});
|
|
74
42
|
module.exports = __toCommonJS(src_exports);
|
|
75
43
|
|
|
76
|
-
//
|
|
44
|
+
// ../../../node_modules/compute-scroll-into-view/dist/index.module.js
|
|
45
|
+
function t(t3) {
|
|
46
|
+
return typeof t3 == "object" && t3 != null && t3.nodeType === 1;
|
|
47
|
+
}
|
|
48
|
+
function e(t3, e2) {
|
|
49
|
+
return (!e2 || t3 !== "hidden") && t3 !== "visible" && t3 !== "clip";
|
|
50
|
+
}
|
|
51
|
+
function n(t3, n2) {
|
|
52
|
+
if (t3.clientHeight < t3.scrollHeight || t3.clientWidth < t3.scrollWidth) {
|
|
53
|
+
var r2 = getComputedStyle(t3, null);
|
|
54
|
+
return e(r2.overflowY, n2) || e(r2.overflowX, n2) || function(t4) {
|
|
55
|
+
var e2 = function(t5) {
|
|
56
|
+
if (!t5.ownerDocument || !t5.ownerDocument.defaultView)
|
|
57
|
+
return null;
|
|
58
|
+
try {
|
|
59
|
+
return t5.ownerDocument.defaultView.frameElement;
|
|
60
|
+
} catch (t6) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}(t4);
|
|
64
|
+
return !!e2 && (e2.clientHeight < t4.scrollHeight || e2.clientWidth < t4.scrollWidth);
|
|
65
|
+
}(t3);
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
function r(t3, e2, n2, r2, i, o, l, d) {
|
|
70
|
+
return o < t3 && l > e2 || o > t3 && l < e2 ? 0 : o <= t3 && d <= n2 || l >= e2 && d >= n2 ? o - t3 - r2 : l > e2 && d < n2 || o < t3 && d > n2 ? l - e2 + i : 0;
|
|
71
|
+
}
|
|
72
|
+
function index_module_default(e2, i) {
|
|
73
|
+
var o = window, l = i.scrollMode, d = i.block, u = i.inline, h = i.boundary, a = i.skipOverflowHiddenElements, c = typeof h == "function" ? h : function(t3) {
|
|
74
|
+
return t3 !== h;
|
|
75
|
+
};
|
|
76
|
+
if (!t(e2))
|
|
77
|
+
throw new TypeError("Invalid target");
|
|
78
|
+
for (var f = document.scrollingElement || document.documentElement, s = [], p = e2; t(p) && c(p); ) {
|
|
79
|
+
if ((p = p.parentElement) === f) {
|
|
80
|
+
s.push(p);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
p != null && p === document.body && n(p) && !n(document.documentElement) || p != null && n(p, a) && s.push(p);
|
|
84
|
+
}
|
|
85
|
+
for (var m = o.visualViewport ? o.visualViewport.width : innerWidth, g = o.visualViewport ? o.visualViewport.height : innerHeight, w = window.scrollX || pageXOffset, v = window.scrollY || pageYOffset, W = e2.getBoundingClientRect(), b = W.height, H = W.width, y = W.top, E = W.right, M = W.bottom, V = W.left, x = d === "start" || d === "nearest" ? y : d === "end" ? M : y + b / 2, I = u === "center" ? V + H / 2 : u === "end" ? E : V, C = [], T = 0; T < s.length; T++) {
|
|
86
|
+
var k = s[T], B = k.getBoundingClientRect(), D = B.height, O = B.width, R = B.top, X = B.right, Y = B.bottom, L = B.left;
|
|
87
|
+
if (l === "if-needed" && y >= 0 && V >= 0 && M <= g && E <= m && y >= R && M <= Y && V >= L && E <= X)
|
|
88
|
+
return C;
|
|
89
|
+
var S = getComputedStyle(k), j = parseInt(S.borderLeftWidth, 10), q = parseInt(S.borderTopWidth, 10), z = parseInt(S.borderRightWidth, 10), A = parseInt(S.borderBottomWidth, 10), F = 0, G = 0, J = "offsetWidth" in k ? k.offsetWidth - k.clientWidth - j - z : 0, K = "offsetHeight" in k ? k.offsetHeight - k.clientHeight - q - A : 0;
|
|
90
|
+
if (f === k)
|
|
91
|
+
F = d === "start" ? x : d === "end" ? x - g : d === "nearest" ? r(v, v + g, g, q, A, v + x, v + x + b, b) : x - g / 2, G = u === "start" ? I : u === "center" ? I - m / 2 : u === "end" ? I - m : r(w, w + m, m, j, z, w + I, w + I + H, H), F = Math.max(0, F + v), G = Math.max(0, G + w);
|
|
92
|
+
else {
|
|
93
|
+
F = d === "start" ? x - R - q : d === "end" ? x - Y + A + K : d === "nearest" ? r(R, Y, D, q, A + K, x, x + b, b) : x - (R + D / 2) + K / 2, G = u === "start" ? I - L - j : u === "center" ? I - (L + O / 2) + J / 2 : u === "end" ? I - X + z + J : r(L, X, O, j, z + J, I, I + H, H);
|
|
94
|
+
var N = k.scrollLeft, P = k.scrollTop;
|
|
95
|
+
x += P - (F = Math.max(0, Math.min(P + F, k.scrollHeight - D + K))), I += N - (G = Math.max(0, Math.min(N + G, k.scrollWidth - O + J)));
|
|
96
|
+
}
|
|
97
|
+
C.push({ el: k, top: F, left: G });
|
|
98
|
+
}
|
|
99
|
+
return C;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// ../../utilities/dom/node_modules/scroll-into-view-if-needed/es/index.js
|
|
103
|
+
function isOptionsObject(options) {
|
|
104
|
+
return options === Object(options) && Object.keys(options).length !== 0;
|
|
105
|
+
}
|
|
106
|
+
function defaultBehavior(actions, behavior) {
|
|
107
|
+
if (behavior === void 0) {
|
|
108
|
+
behavior = "auto";
|
|
109
|
+
}
|
|
110
|
+
var canSmoothScroll = "scrollBehavior" in document.body.style;
|
|
111
|
+
actions.forEach(function(_ref) {
|
|
112
|
+
var el = _ref.el, top = _ref.top, left = _ref.left;
|
|
113
|
+
if (el.scroll && canSmoothScroll) {
|
|
114
|
+
el.scroll({
|
|
115
|
+
top,
|
|
116
|
+
left,
|
|
117
|
+
behavior
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
el.scrollTop = top;
|
|
121
|
+
el.scrollLeft = left;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function getOptions(options) {
|
|
126
|
+
if (options === false) {
|
|
127
|
+
return {
|
|
128
|
+
block: "end",
|
|
129
|
+
inline: "nearest"
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
if (isOptionsObject(options)) {
|
|
133
|
+
return options;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
block: "start",
|
|
137
|
+
inline: "nearest"
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function scrollIntoView(target, options) {
|
|
141
|
+
var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);
|
|
142
|
+
if (isOptionsObject(options) && typeof options.behavior === "function") {
|
|
143
|
+
return options.behavior(isTargetAttached ? index_module_default(target, options) : []);
|
|
144
|
+
}
|
|
145
|
+
if (!isTargetAttached) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
var computeOptions = getOptions(options);
|
|
149
|
+
return defaultBehavior(index_module_default(target, computeOptions), computeOptions.behavior);
|
|
150
|
+
}
|
|
151
|
+
var es_default = scrollIntoView;
|
|
152
|
+
|
|
153
|
+
// ../../utilities/dom/dist/index.mjs
|
|
77
154
|
var dataAttr = (guard) => {
|
|
78
155
|
return guard ? "" : void 0;
|
|
79
156
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
157
|
+
function getStyleCache() {
|
|
158
|
+
;
|
|
159
|
+
globalThis.__styleCache__ = globalThis.__styleCache__ || /* @__PURE__ */ new WeakMap();
|
|
160
|
+
return globalThis.__styleCache__;
|
|
161
|
+
}
|
|
83
162
|
function getComputedStyle2(el) {
|
|
84
163
|
var _a;
|
|
85
164
|
if (!el)
|
|
86
165
|
return {};
|
|
87
|
-
|
|
166
|
+
const cache = getStyleCache();
|
|
167
|
+
let style = cache.get(el);
|
|
88
168
|
if (!style) {
|
|
89
169
|
const win = (_a = el == null ? void 0 : el.ownerDocument.defaultView) != null ? _a : window;
|
|
90
170
|
style = win.getComputedStyle(el);
|
|
91
|
-
|
|
171
|
+
cache.set(el, style);
|
|
92
172
|
}
|
|
93
173
|
return style;
|
|
94
174
|
}
|
|
95
|
-
|
|
96
|
-
// ../../utilities/dom/src/next-tick.ts
|
|
97
175
|
function nextTick(fn) {
|
|
98
176
|
const set = /* @__PURE__ */ new Set();
|
|
99
177
|
function raf2(fn2) {
|
|
@@ -113,111 +191,56 @@ function raf(fn) {
|
|
|
113
191
|
globalThis.cancelAnimationFrame(id);
|
|
114
192
|
};
|
|
115
193
|
}
|
|
116
|
-
|
|
117
|
-
// ../../utilities/core/src/array.ts
|
|
118
|
-
var first = (v) => v[0];
|
|
119
|
-
var last = (v) => v[v.length - 1];
|
|
120
|
-
function clear(v) {
|
|
121
|
-
while (v.length > 0)
|
|
122
|
-
v.pop();
|
|
123
|
-
return v;
|
|
124
|
-
}
|
|
125
|
-
function nextIndex(v, idx, opts = {}) {
|
|
126
|
-
const { step = 1, loop = true } = opts;
|
|
127
|
-
const next2 = idx + step;
|
|
128
|
-
const len = v.length;
|
|
129
|
-
const last2 = len - 1;
|
|
130
|
-
if (idx === -1)
|
|
131
|
-
return step > 0 ? 0 : last2;
|
|
132
|
-
if (next2 < 0)
|
|
133
|
-
return loop ? last2 : 0;
|
|
134
|
-
if (next2 >= len)
|
|
135
|
-
return loop ? 0 : idx > len ? len : idx;
|
|
136
|
-
return next2;
|
|
137
|
-
}
|
|
138
|
-
function next(v, idx, opts = {}) {
|
|
139
|
-
return v[nextIndex(v, idx, opts)];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// ../../utilities/core/src/functions.ts
|
|
143
|
-
var runIfFn = (v, ...a) => {
|
|
144
|
-
const res = typeof v === "function" ? v(...a) : v;
|
|
145
|
-
return res != null ? res : void 0;
|
|
146
|
-
};
|
|
147
|
-
var cast = (v) => v;
|
|
148
194
|
var noop = () => {
|
|
149
195
|
};
|
|
150
196
|
var pipe = (...fns) => (v) => fns.reduce((a, b) => b(a), v);
|
|
151
|
-
var uuid = /* @__PURE__ */ (() => {
|
|
152
|
-
let id = 0;
|
|
153
|
-
return () => {
|
|
154
|
-
id++;
|
|
155
|
-
return id.toString(36);
|
|
156
|
-
};
|
|
157
|
-
})();
|
|
158
|
-
|
|
159
|
-
// ../../utilities/core/src/guard.ts
|
|
160
197
|
var platform = (v) => isDom() && v.test(navigator.platform);
|
|
161
198
|
var isDom = () => !!(typeof window !== "undefined");
|
|
162
199
|
var isMac = () => platform(/^Mac/);
|
|
163
200
|
var isIPhone = () => platform(/^iPhone/);
|
|
164
201
|
var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1;
|
|
165
202
|
var isIos = () => isIPhone() || isIPad();
|
|
166
|
-
var isArray = (v) => Array.isArray(v);
|
|
167
|
-
var isBoolean = (v) => v === true || v === false;
|
|
168
|
-
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
|
|
169
|
-
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v);
|
|
170
|
-
var isString = (v) => typeof v === "string";
|
|
171
|
-
var isFunction = (v) => typeof v === "function";
|
|
172
203
|
var isLeftClick = (v) => v.button === 0;
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const c = a.length === 2 ? a[0] : true;
|
|
178
|
-
if (c && void 0 !== "production") {
|
|
179
|
-
console.warn(m);
|
|
180
|
-
}
|
|
204
|
+
function getListenerElements() {
|
|
205
|
+
;
|
|
206
|
+
globalThis.__listenerElements__ = globalThis.__listenerElements__ || /* @__PURE__ */ new Map();
|
|
207
|
+
return globalThis.__listenerElements__;
|
|
181
208
|
}
|
|
182
|
-
function
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
throw new Error(m);
|
|
187
|
-
}
|
|
209
|
+
function getListenerCache() {
|
|
210
|
+
;
|
|
211
|
+
globalThis.__listenerCache__ = globalThis.__listenerCache__ || /* @__PURE__ */ new Map();
|
|
212
|
+
return globalThis.__listenerCache__;
|
|
188
213
|
}
|
|
189
|
-
|
|
190
|
-
// ../../utilities/dom/src/event-bus.ts
|
|
191
|
-
var listenerElements = /* @__PURE__ */ new Map();
|
|
192
|
-
var listenerCache = /* @__PURE__ */ new Map();
|
|
193
214
|
function globalEventBus(node, type, handler, options) {
|
|
194
215
|
var _a;
|
|
195
216
|
if (!node)
|
|
196
217
|
return noop;
|
|
197
|
-
const
|
|
218
|
+
const hash = JSON.stringify({ type, options });
|
|
219
|
+
const listenerElements = getListenerElements();
|
|
220
|
+
const listenerCache = getListenerCache();
|
|
198
221
|
const group = listenerElements.get(node);
|
|
199
222
|
if (!listenerElements.has(node)) {
|
|
200
|
-
const group2 = /* @__PURE__ */ new Map([[
|
|
223
|
+
const group2 = /* @__PURE__ */ new Map([[hash, /* @__PURE__ */ new Set([handler])]]);
|
|
201
224
|
listenerElements.set(node, group2);
|
|
202
|
-
} else if (group == null ? void 0 : group.has(
|
|
203
|
-
(_a = group == null ? void 0 : group.get(
|
|
225
|
+
} else if (group == null ? void 0 : group.has(hash)) {
|
|
226
|
+
(_a = group == null ? void 0 : group.get(hash)) == null ? void 0 : _a.add(handler);
|
|
204
227
|
} else {
|
|
205
|
-
group == null ? void 0 : group.set(
|
|
228
|
+
group == null ? void 0 : group.set(hash, /* @__PURE__ */ new Set([handler]));
|
|
206
229
|
}
|
|
207
230
|
function attach(node2) {
|
|
208
231
|
var _a2, _b;
|
|
209
232
|
function listener(event) {
|
|
210
233
|
var _a3;
|
|
211
234
|
const group2 = listenerElements.get(node2);
|
|
212
|
-
(_a3 = group2 == null ? void 0 : group2.get(
|
|
235
|
+
(_a3 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a3.forEach((fn) => fn(event));
|
|
213
236
|
}
|
|
214
237
|
if (!(listenerCache == null ? void 0 : listenerCache.has(node2))) {
|
|
215
|
-
listenerCache.set(node2, /* @__PURE__ */ new Map([[
|
|
238
|
+
listenerCache.set(node2, /* @__PURE__ */ new Map([[hash, listener]]));
|
|
216
239
|
node2.addEventListener(type, listener, options);
|
|
217
240
|
return;
|
|
218
241
|
}
|
|
219
|
-
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(
|
|
220
|
-
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(
|
|
242
|
+
if (!((_a2 = listenerCache == null ? void 0 : listenerCache.get(node2)) == null ? void 0 : _a2.has(hash))) {
|
|
243
|
+
(_b = listenerCache.get(node2)) == null ? void 0 : _b.set(hash, listener);
|
|
221
244
|
node2.addEventListener(type, listener, options);
|
|
222
245
|
}
|
|
223
246
|
}
|
|
@@ -227,12 +250,12 @@ function globalEventBus(node, type, handler, options) {
|
|
|
227
250
|
if (!listenerElements.has(node))
|
|
228
251
|
return;
|
|
229
252
|
const group2 = listenerElements.get(node);
|
|
230
|
-
(_a2 = group2 == null ? void 0 : group2.get(
|
|
231
|
-
if (((_b = group2 == null ? void 0 : group2.get(
|
|
232
|
-
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(
|
|
253
|
+
(_a2 = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _a2.delete(handler);
|
|
254
|
+
if (((_b = group2 == null ? void 0 : group2.get(hash)) == null ? void 0 : _b.size) === 0) {
|
|
255
|
+
const listener = (_c = listenerCache.get(node)) == null ? void 0 : _c.get(hash);
|
|
233
256
|
node.removeEventListener(type, listener, options);
|
|
234
|
-
group2 == null ? void 0 : group2.delete(
|
|
235
|
-
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(
|
|
257
|
+
group2 == null ? void 0 : group2.delete(hash);
|
|
258
|
+
(_d = listenerCache.get(node)) == null ? void 0 : _d.delete(hash);
|
|
236
259
|
if ((group2 == null ? void 0 : group2.size) === 0) {
|
|
237
260
|
listenerElements.delete(node);
|
|
238
261
|
listenerCache.delete(node);
|
|
@@ -240,17 +263,13 @@ function globalEventBus(node, type, handler, options) {
|
|
|
240
263
|
}
|
|
241
264
|
};
|
|
242
265
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
var
|
|
246
|
-
var isRef = (v) => t(v) === "Object" && "current" in v;
|
|
247
|
-
var runIfFn2 = (fn) => t(fn) === "Function" ? fn() : fn;
|
|
266
|
+
var t2 = (v) => Object.prototype.toString.call(v).slice(8, -1);
|
|
267
|
+
var isRef = (v) => t2(v) === "Object" && "current" in v;
|
|
268
|
+
var runIfFn = (fn) => t2(fn) === "Function" ? fn() : fn;
|
|
248
269
|
function addDomEvent(target, event, listener, options) {
|
|
249
|
-
const node = isRef(target) ? target.current :
|
|
270
|
+
const node = isRef(target) ? target.current : runIfFn(target);
|
|
250
271
|
return globalEventBus(node, event, listener, options);
|
|
251
272
|
}
|
|
252
|
-
|
|
253
|
-
// ../../utilities/dom/src/body-pointer-event.ts
|
|
254
273
|
var changeCount = 0;
|
|
255
274
|
var originalBodyPointerEvents;
|
|
256
275
|
function preventBodyPointerEvents(el, opts = {}) {
|
|
@@ -309,163 +328,48 @@ function preventBodyPointerEvents(el, opts = {}) {
|
|
|
309
328
|
cleanups.forEach((cleanup) => cleanup == null ? void 0 : cleanup());
|
|
310
329
|
};
|
|
311
330
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
331
|
+
function getOwnerDocument(el) {
|
|
332
|
+
var _a;
|
|
333
|
+
if (isWindow(el))
|
|
334
|
+
return el.document;
|
|
335
|
+
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
316
336
|
}
|
|
317
|
-
function
|
|
318
|
-
return (
|
|
337
|
+
function getNodeName(node) {
|
|
338
|
+
return isWindow(node) ? "" : node ? node.localName || "" : "";
|
|
319
339
|
}
|
|
320
|
-
function
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return
|
|
324
|
-
|
|
325
|
-
if (!t5.ownerDocument || !t5.ownerDocument.defaultView)
|
|
326
|
-
return null;
|
|
327
|
-
try {
|
|
328
|
-
return t5.ownerDocument.defaultView.frameElement;
|
|
329
|
-
} catch (t6) {
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
}(t4);
|
|
333
|
-
return !!e2 && (e2.clientHeight < t4.scrollHeight || e2.clientWidth < t4.scrollWidth);
|
|
334
|
-
}(t3);
|
|
335
|
-
}
|
|
336
|
-
return false;
|
|
340
|
+
function getParent(el) {
|
|
341
|
+
const doc = getOwnerDocument(el);
|
|
342
|
+
if (getNodeName(el) === "html")
|
|
343
|
+
return el;
|
|
344
|
+
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
337
345
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
346
|
+
function contains(parent, child) {
|
|
347
|
+
if (!parent)
|
|
348
|
+
return false;
|
|
349
|
+
return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
|
|
340
350
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
343
|
-
return t3 !== h;
|
|
344
|
-
};
|
|
345
|
-
if (!t2(e2))
|
|
346
|
-
throw new TypeError("Invalid target");
|
|
347
|
-
for (var f = document.scrollingElement || document.documentElement, s = [], p = e2; t2(p) && c(p); ) {
|
|
348
|
-
if ((p = p.parentElement) === f) {
|
|
349
|
-
s.push(p);
|
|
350
|
-
break;
|
|
351
|
-
}
|
|
352
|
-
p != null && p === document.body && n(p) && !n(document.documentElement) || p != null && n(p, a) && s.push(p);
|
|
353
|
-
}
|
|
354
|
-
for (var m = o.visualViewport ? o.visualViewport.width : innerWidth, g = o.visualViewport ? o.visualViewport.height : innerHeight, w = window.scrollX || pageXOffset, v = window.scrollY || pageYOffset, W = e2.getBoundingClientRect(), b = W.height, H = W.width, y = W.top, E = W.right, M = W.bottom, V = W.left, x = d === "start" || d === "nearest" ? y : d === "end" ? M : y + b / 2, I = u === "center" ? V + H / 2 : u === "end" ? E : V, C = [], T = 0; T < s.length; T++) {
|
|
355
|
-
var k = s[T], B = k.getBoundingClientRect(), D = B.height, O = B.width, R = B.top, X = B.right, Y = B.bottom, L = B.left;
|
|
356
|
-
if (l === "if-needed" && y >= 0 && V >= 0 && M <= g && E <= m && y >= R && M <= Y && V >= L && E <= X)
|
|
357
|
-
return C;
|
|
358
|
-
var S = getComputedStyle(k), j = parseInt(S.borderLeftWidth, 10), q = parseInt(S.borderTopWidth, 10), z = parseInt(S.borderRightWidth, 10), A = parseInt(S.borderBottomWidth, 10), F = 0, G = 0, J = "offsetWidth" in k ? k.offsetWidth - k.clientWidth - j - z : 0, K = "offsetHeight" in k ? k.offsetHeight - k.clientHeight - q - A : 0;
|
|
359
|
-
if (f === k)
|
|
360
|
-
F = d === "start" ? x : d === "end" ? x - g : d === "nearest" ? r(v, v + g, g, q, A, v + x, v + x + b, b) : x - g / 2, G = u === "start" ? I : u === "center" ? I - m / 2 : u === "end" ? I - m : r(w, w + m, m, j, z, w + I, w + I + H, H), F = Math.max(0, F + v), G = Math.max(0, G + w);
|
|
361
|
-
else {
|
|
362
|
-
F = d === "start" ? x - R - q : d === "end" ? x - Y + A + K : d === "nearest" ? r(R, Y, D, q, A + K, x, x + b, b) : x - (R + D / 2) + K / 2, G = u === "start" ? I - L - j : u === "center" ? I - (L + O / 2) + J / 2 : u === "end" ? I - X + z + J : r(L, X, O, j, z + J, I, I + H, H);
|
|
363
|
-
var N = k.scrollLeft, P = k.scrollTop;
|
|
364
|
-
x += P - (F = Math.max(0, Math.min(P + F, k.scrollHeight - D + K))), I += N - (G = Math.max(0, Math.min(N + G, k.scrollWidth - O + J)));
|
|
365
|
-
}
|
|
366
|
-
C.push({ el: k, top: F, left: G });
|
|
367
|
-
}
|
|
368
|
-
return C;
|
|
351
|
+
function isHTMLElement(v) {
|
|
352
|
+
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
369
353
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
function isOptionsObject(options) {
|
|
373
|
-
return options === Object(options) && Object.keys(options).length !== 0;
|
|
354
|
+
function isWindow(value) {
|
|
355
|
+
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
374
356
|
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
357
|
+
var isDisabled = (el) => {
|
|
358
|
+
return (el == null ? void 0 : el.getAttribute("disabled")) != null || !!(el == null ? void 0 : el.getAttribute("aria-disabled")) === true;
|
|
359
|
+
};
|
|
360
|
+
function isScrollParent(el) {
|
|
361
|
+
const { overflow, overflowX, overflowY } = getComputedStyle2(el);
|
|
362
|
+
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
363
|
+
}
|
|
364
|
+
function getScrollParent(el) {
|
|
365
|
+
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
366
|
+
return getOwnerDocument(el).body;
|
|
378
367
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
el.scroll({
|
|
384
|
-
top,
|
|
385
|
-
left,
|
|
386
|
-
behavior
|
|
387
|
-
});
|
|
388
|
-
} else {
|
|
389
|
-
el.scrollTop = top;
|
|
390
|
-
el.scrollLeft = left;
|
|
391
|
-
}
|
|
392
|
-
});
|
|
368
|
+
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
369
|
+
return el;
|
|
370
|
+
}
|
|
371
|
+
return getScrollParent(getParent(el));
|
|
393
372
|
}
|
|
394
|
-
function getOptions(options) {
|
|
395
|
-
if (options === false) {
|
|
396
|
-
return {
|
|
397
|
-
block: "end",
|
|
398
|
-
inline: "nearest"
|
|
399
|
-
};
|
|
400
|
-
}
|
|
401
|
-
if (isOptionsObject(options)) {
|
|
402
|
-
return options;
|
|
403
|
-
}
|
|
404
|
-
return {
|
|
405
|
-
block: "start",
|
|
406
|
-
inline: "nearest"
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
function scrollIntoView(target, options) {
|
|
410
|
-
var isTargetAttached = target.isConnected || target.ownerDocument.documentElement.contains(target);
|
|
411
|
-
if (isOptionsObject(options) && typeof options.behavior === "function") {
|
|
412
|
-
return options.behavior(isTargetAttached ? index_module_default(target, options) : []);
|
|
413
|
-
}
|
|
414
|
-
if (!isTargetAttached) {
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
var computeOptions = getOptions(options);
|
|
418
|
-
return defaultBehavior(index_module_default(target, computeOptions), computeOptions.behavior);
|
|
419
|
-
}
|
|
420
|
-
var es_default = scrollIntoView;
|
|
421
|
-
|
|
422
|
-
// ../../utilities/dom/src/query.ts
|
|
423
|
-
function getOwnerDocument(el) {
|
|
424
|
-
var _a;
|
|
425
|
-
if (isWindow(el))
|
|
426
|
-
return el.document;
|
|
427
|
-
return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
|
|
428
|
-
}
|
|
429
|
-
function getNodeName(node) {
|
|
430
|
-
return isWindow(node) ? "" : node ? node.localName || "" : "";
|
|
431
|
-
}
|
|
432
|
-
function getParent(el) {
|
|
433
|
-
const doc = getOwnerDocument(el);
|
|
434
|
-
if (getNodeName(el) === "html")
|
|
435
|
-
return el;
|
|
436
|
-
return el.assignedSlot || el.parentElement || doc.documentElement;
|
|
437
|
-
}
|
|
438
|
-
function contains(parent, child) {
|
|
439
|
-
if (!parent)
|
|
440
|
-
return false;
|
|
441
|
-
return parent === child || isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child);
|
|
442
|
-
}
|
|
443
|
-
function isHTMLElement(v) {
|
|
444
|
-
return typeof v === "object" && (v == null ? void 0 : v.nodeType) === Node.ELEMENT_NODE && typeof (v == null ? void 0 : v.nodeName) === "string";
|
|
445
|
-
}
|
|
446
|
-
function isWindow(value) {
|
|
447
|
-
return (value == null ? void 0 : value.toString()) === "[object Window]";
|
|
448
|
-
}
|
|
449
|
-
var isDisabled = (el) => {
|
|
450
|
-
return (el == null ? void 0 : el.getAttribute("disabled")) != null || !!(el == null ? void 0 : el.getAttribute("aria-disabled")) === true;
|
|
451
|
-
};
|
|
452
|
-
|
|
453
|
-
// ../../utilities/dom/src/scrollable.ts
|
|
454
|
-
function isScrollParent(el) {
|
|
455
|
-
const { overflow, overflowX, overflowY } = getComputedStyle2(el);
|
|
456
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
457
|
-
}
|
|
458
|
-
function getScrollParent(el) {
|
|
459
|
-
if (["html", "body", "#document"].includes(getNodeName(el))) {
|
|
460
|
-
return getOwnerDocument(el).body;
|
|
461
|
-
}
|
|
462
|
-
if (isHTMLElement(el) && isScrollParent(el)) {
|
|
463
|
-
return el;
|
|
464
|
-
}
|
|
465
|
-
return getScrollParent(getParent(el));
|
|
466
|
-
}
|
|
467
|
-
|
|
468
|
-
// ../../utilities/dom/src/body-scroll-lock.ts
|
|
469
373
|
var nonTextInputTypes = /* @__PURE__ */ new Set(["checkbox", "radio", "range", "color", "file", "image", "button", "submit", "reset"]);
|
|
470
374
|
function preventBodyScroll(opts) {
|
|
471
375
|
var _a;
|
|
@@ -560,16 +464,12 @@ function setStyle(el, key, value) {
|
|
|
560
464
|
el.style[key] = cur;
|
|
561
465
|
};
|
|
562
466
|
}
|
|
563
|
-
|
|
564
|
-
// ../../utilities/dom/src/focus-event.ts
|
|
565
467
|
function validateBlur(event, opts) {
|
|
566
468
|
var _a;
|
|
567
469
|
const exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude];
|
|
568
470
|
const relatedTarget = (_a = event.relatedTarget) != null ? _a : opts.fallback;
|
|
569
471
|
return exclude.every((el) => !(el == null ? void 0 : el.contains(relatedTarget)));
|
|
570
472
|
}
|
|
571
|
-
|
|
572
|
-
// ../../utilities/dom/src/focusable.ts
|
|
573
473
|
var focusableSelector = /* @__PURE__ */ [
|
|
574
474
|
"input:not([disabled]):not([type=hidden])",
|
|
575
475
|
"select:not([disabled])",
|
|
@@ -620,8 +520,6 @@ var getTabbables = (el, includeContainer = false) => {
|
|
|
620
520
|
var isTabbable = (el) => {
|
|
621
521
|
return isFocusable(el) && !isDisabled(el) && !isHidden(el);
|
|
622
522
|
};
|
|
623
|
-
|
|
624
|
-
// ../../utilities/dom/src/pointer-event.ts
|
|
625
523
|
function trackPointerDown(doc, onPointerDown) {
|
|
626
524
|
var _a;
|
|
627
525
|
const win = (_a = doc.defaultView) != null ? _a : window;
|
|
@@ -633,1307 +531,101 @@ function trackPointerDown(doc, onPointerDown) {
|
|
|
633
531
|
return addDomEvent(doc, "pointerdown", fn);
|
|
634
532
|
}
|
|
635
533
|
|
|
636
|
-
//
|
|
637
|
-
var
|
|
638
|
-
function observeElementRect(el, fn) {
|
|
639
|
-
const data = observedElements.get(el);
|
|
640
|
-
if (!data) {
|
|
641
|
-
observedElements.set(el, { rect: {}, callbacks: [fn] });
|
|
642
|
-
if (observedElements.size === 1) {
|
|
643
|
-
rafId = requestAnimationFrame(runLoop);
|
|
644
|
-
}
|
|
645
|
-
} else {
|
|
646
|
-
data.callbacks.push(fn);
|
|
647
|
-
fn(el.getBoundingClientRect());
|
|
648
|
-
}
|
|
649
|
-
return function unobserve() {
|
|
650
|
-
const data2 = observedElements.get(el);
|
|
651
|
-
if (!data2)
|
|
652
|
-
return;
|
|
653
|
-
const index = data2.callbacks.indexOf(fn);
|
|
654
|
-
if (index > -1) {
|
|
655
|
-
data2.callbacks.splice(index, 1);
|
|
656
|
-
}
|
|
657
|
-
if (data2.callbacks.length === 0) {
|
|
658
|
-
observedElements.delete(el);
|
|
659
|
-
if (observedElements.size === 0) {
|
|
660
|
-
cancelAnimationFrame(rafId);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
var rafId;
|
|
666
|
-
function runLoop() {
|
|
667
|
-
const changedRectsData = [];
|
|
668
|
-
observedElements.forEach((data, element) => {
|
|
669
|
-
const newRect = element.getBoundingClientRect();
|
|
670
|
-
if (!isEqual(data.rect, newRect)) {
|
|
671
|
-
data.rect = newRect;
|
|
672
|
-
changedRectsData.push(data);
|
|
673
|
-
}
|
|
674
|
-
});
|
|
675
|
-
changedRectsData.forEach((data) => {
|
|
676
|
-
data.callbacks.forEach((callback) => callback(data.rect));
|
|
677
|
-
});
|
|
678
|
-
rafId = requestAnimationFrame(runLoop);
|
|
679
|
-
}
|
|
680
|
-
function isEqual(rect1, rect2) {
|
|
681
|
-
return rect1.width === rect2.width && rect1.height === rect2.height && rect1.top === rect2.top && rect1.right === rect2.right && rect1.bottom === rect2.bottom && rect1.left === rect2.left;
|
|
682
|
-
}
|
|
534
|
+
// src/popover.connect.ts
|
|
535
|
+
var import_popper = require("@zag-js/popper");
|
|
683
536
|
|
|
684
|
-
//
|
|
685
|
-
function
|
|
686
|
-
return
|
|
687
|
-
}
|
|
688
|
-
function getAlignment(placement) {
|
|
689
|
-
return placement.split("-")[1];
|
|
690
|
-
}
|
|
691
|
-
function getMainAxisFromPlacement(placement) {
|
|
692
|
-
return ["top", "bottom"].includes(getSide(placement)) ? "x" : "y";
|
|
693
|
-
}
|
|
694
|
-
function getLengthFromAxis(axis) {
|
|
695
|
-
return axis === "y" ? "height" : "width";
|
|
696
|
-
}
|
|
697
|
-
function computeCoordsFromPlacement(_ref, placement, rtl) {
|
|
698
|
-
let {
|
|
699
|
-
reference,
|
|
700
|
-
floating
|
|
701
|
-
} = _ref;
|
|
702
|
-
const commonX = reference.x + reference.width / 2 - floating.width / 2;
|
|
703
|
-
const commonY = reference.y + reference.height / 2 - floating.height / 2;
|
|
704
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
705
|
-
const length = getLengthFromAxis(mainAxis);
|
|
706
|
-
const commonAlign = reference[length] / 2 - floating[length] / 2;
|
|
707
|
-
const side = getSide(placement);
|
|
708
|
-
const isVertical = mainAxis === "x";
|
|
709
|
-
let coords;
|
|
710
|
-
switch (side) {
|
|
711
|
-
case "top":
|
|
712
|
-
coords = {
|
|
713
|
-
x: commonX,
|
|
714
|
-
y: reference.y - floating.height
|
|
715
|
-
};
|
|
716
|
-
break;
|
|
717
|
-
case "bottom":
|
|
718
|
-
coords = {
|
|
719
|
-
x: commonX,
|
|
720
|
-
y: reference.y + reference.height
|
|
721
|
-
};
|
|
722
|
-
break;
|
|
723
|
-
case "right":
|
|
724
|
-
coords = {
|
|
725
|
-
x: reference.x + reference.width,
|
|
726
|
-
y: commonY
|
|
727
|
-
};
|
|
728
|
-
break;
|
|
729
|
-
case "left":
|
|
730
|
-
coords = {
|
|
731
|
-
x: reference.x - floating.width,
|
|
732
|
-
y: commonY
|
|
733
|
-
};
|
|
734
|
-
break;
|
|
735
|
-
default:
|
|
736
|
-
coords = {
|
|
737
|
-
x: reference.x,
|
|
738
|
-
y: reference.y
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
switch (getAlignment(placement)) {
|
|
742
|
-
case "start":
|
|
743
|
-
coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
|
|
744
|
-
break;
|
|
745
|
-
case "end":
|
|
746
|
-
coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
|
|
747
|
-
break;
|
|
748
|
-
}
|
|
749
|
-
return coords;
|
|
750
|
-
}
|
|
751
|
-
var computePosition = (reference, floating, config) => __async(void 0, null, function* () {
|
|
752
|
-
const {
|
|
753
|
-
placement = "bottom",
|
|
754
|
-
strategy = "absolute",
|
|
755
|
-
middleware = [],
|
|
756
|
-
platform: platform3
|
|
757
|
-
} = config;
|
|
758
|
-
const rtl = yield platform3.isRTL == null ? void 0 : platform3.isRTL(floating);
|
|
759
|
-
if (void 0 !== "production") {
|
|
760
|
-
if (platform3 == null) {
|
|
761
|
-
console.error(["Floating UI: `platform` property was not passed to config. If you", "want to use Floating UI on the web, install @floating-ui/dom", "instead of the /core package. Otherwise, you can create your own", "`platform`: https://floating-ui.com/docs/platform"].join(" "));
|
|
762
|
-
}
|
|
763
|
-
if (middleware.filter((_ref) => {
|
|
764
|
-
let {
|
|
765
|
-
name
|
|
766
|
-
} = _ref;
|
|
767
|
-
return name === "autoPlacement" || name === "flip";
|
|
768
|
-
}).length > 1) {
|
|
769
|
-
throw new Error(["Floating UI: duplicate `flip` and/or `autoPlacement`", "middleware detected. This will lead to an infinite loop. Ensure only", "one of either has been passed to the `middleware` array."].join(" "));
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
let rects = yield platform3.getElementRects({
|
|
773
|
-
reference,
|
|
774
|
-
floating,
|
|
775
|
-
strategy
|
|
776
|
-
});
|
|
777
|
-
let {
|
|
778
|
-
x,
|
|
779
|
-
y
|
|
780
|
-
} = computeCoordsFromPlacement(rects, placement, rtl);
|
|
781
|
-
let statefulPlacement = placement;
|
|
782
|
-
let middlewareData = {};
|
|
783
|
-
let _debug_loop_count_ = 0;
|
|
784
|
-
for (let i = 0; i < middleware.length; i++) {
|
|
785
|
-
if (void 0 !== "production") {
|
|
786
|
-
_debug_loop_count_++;
|
|
787
|
-
if (_debug_loop_count_ > 100) {
|
|
788
|
-
throw new Error(["Floating UI: The middleware lifecycle appears to be", "running in an infinite loop. This is usually caused by a `reset`", "continually being returned without a break condition."].join(" "));
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
const {
|
|
792
|
-
name,
|
|
793
|
-
fn
|
|
794
|
-
} = middleware[i];
|
|
795
|
-
const {
|
|
796
|
-
x: nextX,
|
|
797
|
-
y: nextY,
|
|
798
|
-
data,
|
|
799
|
-
reset
|
|
800
|
-
} = yield fn({
|
|
801
|
-
x,
|
|
802
|
-
y,
|
|
803
|
-
initialPlacement: placement,
|
|
804
|
-
placement: statefulPlacement,
|
|
805
|
-
strategy,
|
|
806
|
-
middlewareData,
|
|
807
|
-
rects,
|
|
808
|
-
platform: platform3,
|
|
809
|
-
elements: {
|
|
810
|
-
reference,
|
|
811
|
-
floating
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
x = nextX != null ? nextX : x;
|
|
815
|
-
y = nextY != null ? nextY : y;
|
|
816
|
-
middlewareData = __spreadProps(__spreadValues({}, middlewareData), {
|
|
817
|
-
[name]: __spreadValues(__spreadValues({}, middlewareData[name]), data)
|
|
818
|
-
});
|
|
819
|
-
if (reset) {
|
|
820
|
-
if (typeof reset === "object") {
|
|
821
|
-
if (reset.placement) {
|
|
822
|
-
statefulPlacement = reset.placement;
|
|
823
|
-
}
|
|
824
|
-
if (reset.rects) {
|
|
825
|
-
rects = reset.rects === true ? yield platform3.getElementRects({
|
|
826
|
-
reference,
|
|
827
|
-
floating,
|
|
828
|
-
strategy
|
|
829
|
-
}) : reset.rects;
|
|
830
|
-
}
|
|
831
|
-
({
|
|
832
|
-
x,
|
|
833
|
-
y
|
|
834
|
-
} = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
|
|
835
|
-
}
|
|
836
|
-
i = -1;
|
|
837
|
-
continue;
|
|
838
|
-
}
|
|
839
|
-
}
|
|
840
|
-
return {
|
|
841
|
-
x,
|
|
842
|
-
y,
|
|
843
|
-
placement: statefulPlacement,
|
|
844
|
-
strategy,
|
|
845
|
-
middlewareData
|
|
846
|
-
};
|
|
847
|
-
});
|
|
848
|
-
function expandPaddingObject(padding) {
|
|
849
|
-
return __spreadValues({
|
|
850
|
-
top: 0,
|
|
851
|
-
right: 0,
|
|
852
|
-
bottom: 0,
|
|
853
|
-
left: 0
|
|
854
|
-
}, padding);
|
|
855
|
-
}
|
|
856
|
-
function getSideObjectFromPadding(padding) {
|
|
857
|
-
return typeof padding !== "number" ? expandPaddingObject(padding) : {
|
|
858
|
-
top: padding,
|
|
859
|
-
right: padding,
|
|
860
|
-
bottom: padding,
|
|
861
|
-
left: padding
|
|
862
|
-
};
|
|
863
|
-
}
|
|
864
|
-
function rectToClientRect(rect) {
|
|
865
|
-
return __spreadProps(__spreadValues({}, rect), {
|
|
866
|
-
top: rect.y,
|
|
867
|
-
left: rect.x,
|
|
868
|
-
right: rect.x + rect.width,
|
|
869
|
-
bottom: rect.y + rect.height
|
|
870
|
-
});
|
|
871
|
-
}
|
|
872
|
-
function detectOverflow(middlewareArguments, options) {
|
|
873
|
-
return __async(this, null, function* () {
|
|
874
|
-
var _await$platform$isEle;
|
|
875
|
-
if (options === void 0) {
|
|
876
|
-
options = {};
|
|
877
|
-
}
|
|
878
|
-
const {
|
|
879
|
-
x,
|
|
880
|
-
y,
|
|
881
|
-
platform: platform3,
|
|
882
|
-
rects,
|
|
883
|
-
elements,
|
|
884
|
-
strategy
|
|
885
|
-
} = middlewareArguments;
|
|
886
|
-
const {
|
|
887
|
-
boundary = "clippingAncestors",
|
|
888
|
-
rootBoundary = "viewport",
|
|
889
|
-
elementContext = "floating",
|
|
890
|
-
altBoundary = false,
|
|
891
|
-
padding = 0
|
|
892
|
-
} = options;
|
|
893
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
894
|
-
const altContext = elementContext === "floating" ? "reference" : "floating";
|
|
895
|
-
const element = elements[altBoundary ? altContext : elementContext];
|
|
896
|
-
const clippingClientRect = rectToClientRect(yield platform3.getClippingRect({
|
|
897
|
-
element: ((_await$platform$isEle = yield platform3.isElement == null ? void 0 : platform3.isElement(element)) != null ? _await$platform$isEle : true) ? element : element.contextElement || (yield platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements.floating)),
|
|
898
|
-
boundary,
|
|
899
|
-
rootBoundary,
|
|
900
|
-
strategy
|
|
901
|
-
}));
|
|
902
|
-
const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? yield platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
903
|
-
rect: elementContext === "floating" ? __spreadProps(__spreadValues({}, rects.floating), {
|
|
904
|
-
x,
|
|
905
|
-
y
|
|
906
|
-
}) : rects.reference,
|
|
907
|
-
offsetParent: yield platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements.floating),
|
|
908
|
-
strategy
|
|
909
|
-
}) : rects[elementContext]);
|
|
910
|
-
return {
|
|
911
|
-
top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
|
|
912
|
-
bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
|
|
913
|
-
left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
|
|
914
|
-
right: elementClientRect.right - clippingClientRect.right + paddingObject.right
|
|
915
|
-
};
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
var min = Math.min;
|
|
919
|
-
var max = Math.max;
|
|
920
|
-
function within(min$1, value, max$1) {
|
|
921
|
-
return max(min$1, min(value, max$1));
|
|
922
|
-
}
|
|
923
|
-
var arrow = (options) => ({
|
|
924
|
-
name: "arrow",
|
|
925
|
-
options,
|
|
926
|
-
fn(middlewareArguments) {
|
|
927
|
-
return __async(this, null, function* () {
|
|
928
|
-
const {
|
|
929
|
-
element,
|
|
930
|
-
padding = 0
|
|
931
|
-
} = options != null ? options : {};
|
|
932
|
-
const {
|
|
933
|
-
x,
|
|
934
|
-
y,
|
|
935
|
-
placement,
|
|
936
|
-
rects,
|
|
937
|
-
platform: platform3
|
|
938
|
-
} = middlewareArguments;
|
|
939
|
-
if (element == null) {
|
|
940
|
-
if (void 0 !== "production") {
|
|
941
|
-
console.warn("Floating UI: No `element` was passed to the `arrow` middleware.");
|
|
942
|
-
}
|
|
943
|
-
return {};
|
|
944
|
-
}
|
|
945
|
-
const paddingObject = getSideObjectFromPadding(padding);
|
|
946
|
-
const coords = {
|
|
947
|
-
x,
|
|
948
|
-
y
|
|
949
|
-
};
|
|
950
|
-
const axis = getMainAxisFromPlacement(placement);
|
|
951
|
-
const length = getLengthFromAxis(axis);
|
|
952
|
-
const arrowDimensions = yield platform3.getDimensions(element);
|
|
953
|
-
const minProp = axis === "y" ? "top" : "left";
|
|
954
|
-
const maxProp = axis === "y" ? "bottom" : "right";
|
|
955
|
-
const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
|
|
956
|
-
const startDiff = coords[axis] - rects.reference[axis];
|
|
957
|
-
const arrowOffsetParent = yield platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(element);
|
|
958
|
-
const clientSize = arrowOffsetParent ? axis === "y" ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
|
|
959
|
-
const centerToReference = endDiff / 2 - startDiff / 2;
|
|
960
|
-
const min3 = paddingObject[minProp];
|
|
961
|
-
const max3 = clientSize - arrowDimensions[length] - paddingObject[maxProp];
|
|
962
|
-
const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
|
|
963
|
-
const offset2 = within(min3, center, max3);
|
|
964
|
-
return {
|
|
965
|
-
data: {
|
|
966
|
-
[axis]: offset2,
|
|
967
|
-
centerOffset: center - offset2
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
});
|
|
973
|
-
var hash$1 = {
|
|
974
|
-
left: "right",
|
|
975
|
-
right: "left",
|
|
976
|
-
bottom: "top",
|
|
977
|
-
top: "bottom"
|
|
978
|
-
};
|
|
979
|
-
function getOppositePlacement(placement) {
|
|
980
|
-
return placement.replace(/left|right|bottom|top/g, (matched) => hash$1[matched]);
|
|
981
|
-
}
|
|
982
|
-
function getAlignmentSides(placement, rects, rtl) {
|
|
983
|
-
if (rtl === void 0) {
|
|
984
|
-
rtl = false;
|
|
985
|
-
}
|
|
986
|
-
const alignment = getAlignment(placement);
|
|
987
|
-
const mainAxis = getMainAxisFromPlacement(placement);
|
|
988
|
-
const length = getLengthFromAxis(mainAxis);
|
|
989
|
-
let mainAlignmentSide = mainAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
|
|
990
|
-
if (rects.reference[length] > rects.floating[length]) {
|
|
991
|
-
mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
|
|
992
|
-
}
|
|
993
|
-
return {
|
|
994
|
-
main: mainAlignmentSide,
|
|
995
|
-
cross: getOppositePlacement(mainAlignmentSide)
|
|
996
|
-
};
|
|
537
|
+
// ../../types/dist/index.mjs
|
|
538
|
+
function createNormalizer(fn) {
|
|
539
|
+
return { button: fn, label: fn, input: fn, output: fn, element: fn };
|
|
997
540
|
}
|
|
998
|
-
var
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
541
|
+
var normalizeProp = createNormalizer((v) => v);
|
|
542
|
+
|
|
543
|
+
// ../../utilities/core/dist/index.mjs
|
|
544
|
+
var first = (v) => v[0];
|
|
545
|
+
var last = (v) => v[v.length - 1];
|
|
546
|
+
function nextIndex(v, idx, opts = {}) {
|
|
547
|
+
const { step = 1, loop = true } = opts;
|
|
548
|
+
const next2 = idx + step;
|
|
549
|
+
const len = v.length;
|
|
550
|
+
const last2 = len - 1;
|
|
551
|
+
if (idx === -1)
|
|
552
|
+
return step > 0 ? 0 : last2;
|
|
553
|
+
if (next2 < 0)
|
|
554
|
+
return loop ? last2 : 0;
|
|
555
|
+
if (next2 >= len)
|
|
556
|
+
return loop ? 0 : idx > len ? len : idx;
|
|
557
|
+
return next2;
|
|
1004
558
|
}
|
|
1005
|
-
function
|
|
1006
|
-
|
|
1007
|
-
return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
|
|
559
|
+
function next(v, idx, opts = {}) {
|
|
560
|
+
return v[nextIndex(v, idx, opts)];
|
|
1008
561
|
}
|
|
1009
|
-
var
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
}
|
|
1013
|
-
return {
|
|
1014
|
-
name: "flip",
|
|
1015
|
-
options,
|
|
1016
|
-
fn(middlewareArguments) {
|
|
1017
|
-
return __async(this, null, function* () {
|
|
1018
|
-
var _middlewareData$flip;
|
|
1019
|
-
const {
|
|
1020
|
-
placement,
|
|
1021
|
-
middlewareData,
|
|
1022
|
-
rects,
|
|
1023
|
-
initialPlacement,
|
|
1024
|
-
platform: platform3,
|
|
1025
|
-
elements
|
|
1026
|
-
} = middlewareArguments;
|
|
1027
|
-
const _a2 = options, {
|
|
1028
|
-
mainAxis: checkMainAxis = true,
|
|
1029
|
-
crossAxis: checkCrossAxis = true,
|
|
1030
|
-
fallbackPlacements: specifiedFallbackPlacements,
|
|
1031
|
-
fallbackStrategy = "bestFit",
|
|
1032
|
-
flipAlignment = true
|
|
1033
|
-
} = _a2, detectOverflowOptions = __objRest(_a2, [
|
|
1034
|
-
"mainAxis",
|
|
1035
|
-
"crossAxis",
|
|
1036
|
-
"fallbackPlacements",
|
|
1037
|
-
"fallbackStrategy",
|
|
1038
|
-
"flipAlignment"
|
|
1039
|
-
]);
|
|
1040
|
-
const side = getSide(placement);
|
|
1041
|
-
const isBasePlacement = side === initialPlacement;
|
|
1042
|
-
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
|
|
1043
|
-
const placements = [initialPlacement, ...fallbackPlacements];
|
|
1044
|
-
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
1045
|
-
const overflows = [];
|
|
1046
|
-
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
|
|
1047
|
-
if (checkMainAxis) {
|
|
1048
|
-
overflows.push(overflow[side]);
|
|
1049
|
-
}
|
|
1050
|
-
if (checkCrossAxis) {
|
|
1051
|
-
const {
|
|
1052
|
-
main,
|
|
1053
|
-
cross
|
|
1054
|
-
} = getAlignmentSides(placement, rects, yield platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
|
|
1055
|
-
overflows.push(overflow[main], overflow[cross]);
|
|
1056
|
-
}
|
|
1057
|
-
overflowsData = [...overflowsData, {
|
|
1058
|
-
placement,
|
|
1059
|
-
overflows
|
|
1060
|
-
}];
|
|
1061
|
-
if (!overflows.every((side2) => side2 <= 0)) {
|
|
1062
|
-
var _middlewareData$flip$, _middlewareData$flip2;
|
|
1063
|
-
const nextIndex2 = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
|
|
1064
|
-
const nextPlacement = placements[nextIndex2];
|
|
1065
|
-
if (nextPlacement) {
|
|
1066
|
-
return {
|
|
1067
|
-
data: {
|
|
1068
|
-
index: nextIndex2,
|
|
1069
|
-
overflows: overflowsData
|
|
1070
|
-
},
|
|
1071
|
-
reset: {
|
|
1072
|
-
placement: nextPlacement
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
}
|
|
1076
|
-
let resetPlacement = "bottom";
|
|
1077
|
-
switch (fallbackStrategy) {
|
|
1078
|
-
case "bestFit": {
|
|
1079
|
-
var _overflowsData$slice$;
|
|
1080
|
-
const placement2 = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0) - b.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;
|
|
1081
|
-
if (placement2) {
|
|
1082
|
-
resetPlacement = placement2;
|
|
1083
|
-
}
|
|
1084
|
-
break;
|
|
1085
|
-
}
|
|
1086
|
-
case "initialPlacement":
|
|
1087
|
-
resetPlacement = initialPlacement;
|
|
1088
|
-
break;
|
|
1089
|
-
}
|
|
1090
|
-
if (placement !== resetPlacement) {
|
|
1091
|
-
return {
|
|
1092
|
-
reset: {
|
|
1093
|
-
placement: resetPlacement
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
return {};
|
|
1099
|
-
});
|
|
1100
|
-
}
|
|
1101
|
-
};
|
|
562
|
+
var runIfFn2 = (v, ...a) => {
|
|
563
|
+
const res = typeof v === "function" ? v(...a) : v;
|
|
564
|
+
return res != null ? res : void 0;
|
|
1102
565
|
};
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
566
|
+
var cast = (v) => v;
|
|
567
|
+
|
|
568
|
+
// src/popover.dom.ts
|
|
569
|
+
var dom = {
|
|
570
|
+
getDoc: (ctx) => {
|
|
571
|
+
var _a;
|
|
572
|
+
return (_a = ctx.doc) != null ? _a : document;
|
|
573
|
+
},
|
|
574
|
+
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
575
|
+
getAnchorId: (ctx) => {
|
|
576
|
+
var _a, _b;
|
|
577
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.anchor) != null ? _b : `popover-${ctx.uid}-anchor`;
|
|
578
|
+
},
|
|
579
|
+
getTriggerId: (ctx) => {
|
|
580
|
+
var _a, _b;
|
|
581
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `popover-${ctx.uid}-trigger`;
|
|
582
|
+
},
|
|
583
|
+
getContentId: (ctx) => {
|
|
584
|
+
var _a, _b;
|
|
585
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `popover-${ctx.uid}-content`;
|
|
586
|
+
},
|
|
587
|
+
getPositionerId: (ctx) => `popover-${ctx.uid}-popper`,
|
|
588
|
+
getArrowId: (ctx) => `popover-${ctx.uid}-arrow`,
|
|
589
|
+
getTitleId: (ctx) => {
|
|
590
|
+
var _a, _b;
|
|
591
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.title) != null ? _b : `popover-${ctx.uid}-title`;
|
|
592
|
+
},
|
|
593
|
+
getDescriptionId: (ctx) => {
|
|
594
|
+
var _a, _b;
|
|
595
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.description) != null ? _b : `popover-${ctx.uid}-desc`;
|
|
596
|
+
},
|
|
597
|
+
getCloseButtonId: (ctx) => {
|
|
598
|
+
var _a, _b;
|
|
599
|
+
return (_b = (_a = ctx.ids) == null ? void 0 : _a.closeBtn) != null ? _b : `popover-${ctx.uid}-close-button`;
|
|
600
|
+
},
|
|
601
|
+
getAnchorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getAnchorId(ctx)),
|
|
602
|
+
getTriggerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTriggerId(ctx)),
|
|
603
|
+
getContentEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getContentId(ctx)),
|
|
604
|
+
getPositionerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPositionerId(ctx)),
|
|
605
|
+
getTitleEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTitleId(ctx)),
|
|
606
|
+
getDescriptionEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getDescriptionId(ctx)),
|
|
607
|
+
getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
|
|
608
|
+
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
609
|
+
getDocTabbableEls: (ctx) => getTabbables(cast(dom.getDoc(ctx))),
|
|
610
|
+
getTabbableEls: (ctx) => {
|
|
611
|
+
const el = dom.getContentEl(ctx);
|
|
612
|
+
return el ? getTabbables(el) : [];
|
|
613
|
+
},
|
|
614
|
+
getFirstTabbableEl: (ctx) => first(dom.getTabbableEls(ctx)),
|
|
615
|
+
getLastTabbableEl: (ctx) => last(dom.getTabbableEls(ctx)),
|
|
616
|
+
getInitialFocusEl: (ctx) => {
|
|
617
|
+
var _a;
|
|
618
|
+
return (_a = runIfFn2(ctx.initialFocusEl)) != null ? _a : dom.getFirstFocusableEl(ctx);
|
|
1143
619
|
}
|
|
1144
|
-
return {
|
|
1145
|
-
name: "offset",
|
|
1146
|
-
options: value,
|
|
1147
|
-
fn(middlewareArguments) {
|
|
1148
|
-
return __async(this, null, function* () {
|
|
1149
|
-
const {
|
|
1150
|
-
x,
|
|
1151
|
-
y,
|
|
1152
|
-
placement,
|
|
1153
|
-
rects,
|
|
1154
|
-
platform: platform3,
|
|
1155
|
-
elements
|
|
1156
|
-
} = middlewareArguments;
|
|
1157
|
-
const diffCoords = convertValueToCoords(placement, rects, value, yield platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating));
|
|
1158
|
-
return {
|
|
1159
|
-
x: x + diffCoords.x,
|
|
1160
|
-
y: y + diffCoords.y,
|
|
1161
|
-
data: diffCoords
|
|
1162
|
-
};
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
};
|
|
1166
620
|
};
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
name: "shift",
|
|
1176
|
-
options,
|
|
1177
|
-
fn(middlewareArguments) {
|
|
1178
|
-
return __async(this, null, function* () {
|
|
1179
|
-
const {
|
|
1180
|
-
x,
|
|
1181
|
-
y,
|
|
1182
|
-
placement
|
|
1183
|
-
} = middlewareArguments;
|
|
1184
|
-
const _a2 = options, {
|
|
1185
|
-
mainAxis: checkMainAxis = true,
|
|
1186
|
-
crossAxis: checkCrossAxis = false,
|
|
1187
|
-
limiter = {
|
|
1188
|
-
fn: (_ref) => {
|
|
1189
|
-
let {
|
|
1190
|
-
x: x2,
|
|
1191
|
-
y: y2
|
|
1192
|
-
} = _ref;
|
|
1193
|
-
return {
|
|
1194
|
-
x: x2,
|
|
1195
|
-
y: y2
|
|
1196
|
-
};
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
} = _a2, detectOverflowOptions = __objRest(_a2, [
|
|
1200
|
-
"mainAxis",
|
|
1201
|
-
"crossAxis",
|
|
1202
|
-
"limiter"
|
|
1203
|
-
]);
|
|
1204
|
-
const coords = {
|
|
1205
|
-
x,
|
|
1206
|
-
y
|
|
1207
|
-
};
|
|
1208
|
-
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
1209
|
-
const mainAxis = getMainAxisFromPlacement(getSide(placement));
|
|
1210
|
-
const crossAxis = getCrossAxis(mainAxis);
|
|
1211
|
-
let mainAxisCoord = coords[mainAxis];
|
|
1212
|
-
let crossAxisCoord = coords[crossAxis];
|
|
1213
|
-
if (checkMainAxis) {
|
|
1214
|
-
const minSide = mainAxis === "y" ? "top" : "left";
|
|
1215
|
-
const maxSide = mainAxis === "y" ? "bottom" : "right";
|
|
1216
|
-
const min3 = mainAxisCoord + overflow[minSide];
|
|
1217
|
-
const max3 = mainAxisCoord - overflow[maxSide];
|
|
1218
|
-
mainAxisCoord = within(min3, mainAxisCoord, max3);
|
|
1219
|
-
}
|
|
1220
|
-
if (checkCrossAxis) {
|
|
1221
|
-
const minSide = crossAxis === "y" ? "top" : "left";
|
|
1222
|
-
const maxSide = crossAxis === "y" ? "bottom" : "right";
|
|
1223
|
-
const min3 = crossAxisCoord + overflow[minSide];
|
|
1224
|
-
const max3 = crossAxisCoord - overflow[maxSide];
|
|
1225
|
-
crossAxisCoord = within(min3, crossAxisCoord, max3);
|
|
1226
|
-
}
|
|
1227
|
-
const limitedCoords = limiter.fn(__spreadProps(__spreadValues({}, middlewareArguments), {
|
|
1228
|
-
[mainAxis]: mainAxisCoord,
|
|
1229
|
-
[crossAxis]: crossAxisCoord
|
|
1230
|
-
}));
|
|
1231
|
-
return __spreadProps(__spreadValues({}, limitedCoords), {
|
|
1232
|
-
data: {
|
|
1233
|
-
x: limitedCoords.x - x,
|
|
1234
|
-
y: limitedCoords.y - y
|
|
1235
|
-
}
|
|
1236
|
-
});
|
|
1237
|
-
});
|
|
1238
|
-
}
|
|
1239
|
-
};
|
|
1240
|
-
};
|
|
1241
|
-
var size = function(options) {
|
|
1242
|
-
if (options === void 0) {
|
|
1243
|
-
options = {};
|
|
1244
|
-
}
|
|
1245
|
-
return {
|
|
1246
|
-
name: "size",
|
|
1247
|
-
options,
|
|
1248
|
-
fn(middlewareArguments) {
|
|
1249
|
-
return __async(this, null, function* () {
|
|
1250
|
-
const {
|
|
1251
|
-
placement,
|
|
1252
|
-
rects,
|
|
1253
|
-
platform: platform3,
|
|
1254
|
-
elements
|
|
1255
|
-
} = middlewareArguments;
|
|
1256
|
-
const _a2 = options, {
|
|
1257
|
-
apply
|
|
1258
|
-
} = _a2, detectOverflowOptions = __objRest(_a2, [
|
|
1259
|
-
"apply"
|
|
1260
|
-
]);
|
|
1261
|
-
const overflow = yield detectOverflow(middlewareArguments, detectOverflowOptions);
|
|
1262
|
-
const side = getSide(placement);
|
|
1263
|
-
const alignment = getAlignment(placement);
|
|
1264
|
-
let heightSide;
|
|
1265
|
-
let widthSide;
|
|
1266
|
-
if (side === "top" || side === "bottom") {
|
|
1267
|
-
heightSide = side;
|
|
1268
|
-
widthSide = alignment === ((yield platform3.isRTL == null ? void 0 : platform3.isRTL(elements.floating)) ? "start" : "end") ? "left" : "right";
|
|
1269
|
-
} else {
|
|
1270
|
-
widthSide = side;
|
|
1271
|
-
heightSide = alignment === "end" ? "top" : "bottom";
|
|
1272
|
-
}
|
|
1273
|
-
const xMin = max(overflow.left, 0);
|
|
1274
|
-
const xMax = max(overflow.right, 0);
|
|
1275
|
-
const yMin = max(overflow.top, 0);
|
|
1276
|
-
const yMax = max(overflow.bottom, 0);
|
|
1277
|
-
const dimensions = {
|
|
1278
|
-
height: rects.floating.height - (["left", "right"].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),
|
|
1279
|
-
width: rects.floating.width - (["top", "bottom"].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])
|
|
1280
|
-
};
|
|
1281
|
-
const prevDimensions = yield platform3.getDimensions(elements.floating);
|
|
1282
|
-
apply == null ? void 0 : apply(__spreadValues(__spreadValues({}, dimensions), rects));
|
|
1283
|
-
const nextDimensions = yield platform3.getDimensions(elements.floating);
|
|
1284
|
-
if (prevDimensions.width !== nextDimensions.width || prevDimensions.height !== nextDimensions.height) {
|
|
1285
|
-
return {
|
|
1286
|
-
reset: {
|
|
1287
|
-
rects: true
|
|
1288
|
-
}
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
return {};
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
};
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
|
-
// ../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js
|
|
1298
|
-
function isWindow2(value) {
|
|
1299
|
-
return value && value.document && value.location && value.alert && value.setInterval;
|
|
1300
|
-
}
|
|
1301
|
-
function getWindow(node) {
|
|
1302
|
-
if (node == null) {
|
|
1303
|
-
return window;
|
|
1304
|
-
}
|
|
1305
|
-
if (!isWindow2(node)) {
|
|
1306
|
-
const ownerDocument = node.ownerDocument;
|
|
1307
|
-
return ownerDocument ? ownerDocument.defaultView || window : window;
|
|
1308
|
-
}
|
|
1309
|
-
return node;
|
|
1310
|
-
}
|
|
1311
|
-
function getComputedStyle$1(element) {
|
|
1312
|
-
return getWindow(element).getComputedStyle(element);
|
|
1313
|
-
}
|
|
1314
|
-
function getNodeName2(node) {
|
|
1315
|
-
return isWindow2(node) ? "" : node ? (node.nodeName || "").toLowerCase() : "";
|
|
1316
|
-
}
|
|
1317
|
-
function isHTMLElement2(value) {
|
|
1318
|
-
return value instanceof getWindow(value).HTMLElement;
|
|
1319
|
-
}
|
|
1320
|
-
function isElement(value) {
|
|
1321
|
-
return value instanceof getWindow(value).Element;
|
|
1322
|
-
}
|
|
1323
|
-
function isNode(value) {
|
|
1324
|
-
return value instanceof getWindow(value).Node;
|
|
1325
|
-
}
|
|
1326
|
-
function isShadowRoot(node) {
|
|
1327
|
-
const OwnElement = getWindow(node).ShadowRoot;
|
|
1328
|
-
return node instanceof OwnElement || node instanceof ShadowRoot;
|
|
1329
|
-
}
|
|
1330
|
-
function isOverflowElement(element) {
|
|
1331
|
-
const {
|
|
1332
|
-
overflow,
|
|
1333
|
-
overflowX,
|
|
1334
|
-
overflowY
|
|
1335
|
-
} = getComputedStyle$1(element);
|
|
1336
|
-
return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
|
|
1337
|
-
}
|
|
1338
|
-
function isTableElement(element) {
|
|
1339
|
-
return ["table", "td", "th"].includes(getNodeName2(element));
|
|
1340
|
-
}
|
|
1341
|
-
function isContainingBlock(element) {
|
|
1342
|
-
const isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
|
|
1343
|
-
const css = getComputedStyle$1(element);
|
|
1344
|
-
return css.transform !== "none" || css.perspective !== "none" || css.contain === "paint" || ["transform", "perspective"].includes(css.willChange) || isFirefox && css.willChange === "filter" || isFirefox && (css.filter ? css.filter !== "none" : false);
|
|
1345
|
-
}
|
|
1346
|
-
function isLayoutViewport() {
|
|
1347
|
-
return !/^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
1348
|
-
}
|
|
1349
|
-
var min2 = Math.min;
|
|
1350
|
-
var max2 = Math.max;
|
|
1351
|
-
var round = Math.round;
|
|
1352
|
-
function getBoundingClientRect(element, includeScale, isFixedStrategy) {
|
|
1353
|
-
if (includeScale === void 0) {
|
|
1354
|
-
includeScale = false;
|
|
1355
|
-
}
|
|
1356
|
-
if (isFixedStrategy === void 0) {
|
|
1357
|
-
isFixedStrategy = false;
|
|
1358
|
-
}
|
|
1359
|
-
const clientRect = element.getBoundingClientRect();
|
|
1360
|
-
let scaleX = 1;
|
|
1361
|
-
let scaleY = 1;
|
|
1362
|
-
if (includeScale && isHTMLElement2(element)) {
|
|
1363
|
-
scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
|
|
1364
|
-
scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
|
|
1365
|
-
}
|
|
1366
|
-
const win = isElement(element) ? getWindow(element) : window;
|
|
1367
|
-
const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
|
|
1368
|
-
const x = (clientRect.left + (addVisualOffsets ? win.visualViewport.offsetLeft : 0)) / scaleX;
|
|
1369
|
-
const y = (clientRect.top + (addVisualOffsets ? win.visualViewport.offsetTop : 0)) / scaleY;
|
|
1370
|
-
const width = clientRect.width / scaleX;
|
|
1371
|
-
const height = clientRect.height / scaleY;
|
|
1372
|
-
return {
|
|
1373
|
-
width,
|
|
1374
|
-
height,
|
|
1375
|
-
top: y,
|
|
1376
|
-
right: x + width,
|
|
1377
|
-
bottom: y + height,
|
|
1378
|
-
left: x,
|
|
1379
|
-
x,
|
|
1380
|
-
y
|
|
1381
|
-
};
|
|
1382
|
-
}
|
|
1383
|
-
function getDocumentElement(node) {
|
|
1384
|
-
return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
|
|
1385
|
-
}
|
|
1386
|
-
function getNodeScroll(element) {
|
|
1387
|
-
if (isElement(element)) {
|
|
1388
|
-
return {
|
|
1389
|
-
scrollLeft: element.scrollLeft,
|
|
1390
|
-
scrollTop: element.scrollTop
|
|
1391
|
-
};
|
|
1392
|
-
}
|
|
1393
|
-
return {
|
|
1394
|
-
scrollLeft: element.pageXOffset,
|
|
1395
|
-
scrollTop: element.pageYOffset
|
|
1396
|
-
};
|
|
1397
|
-
}
|
|
1398
|
-
function getWindowScrollBarX(element) {
|
|
1399
|
-
return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
|
|
1400
|
-
}
|
|
1401
|
-
function isScaled(element) {
|
|
1402
|
-
const rect = getBoundingClientRect(element);
|
|
1403
|
-
return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
|
|
1404
|
-
}
|
|
1405
|
-
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
|
|
1406
|
-
const isOffsetParentAnElement = isHTMLElement2(offsetParent);
|
|
1407
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1408
|
-
const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent), strategy === "fixed");
|
|
1409
|
-
let scroll = {
|
|
1410
|
-
scrollLeft: 0,
|
|
1411
|
-
scrollTop: 0
|
|
1412
|
-
};
|
|
1413
|
-
const offsets = {
|
|
1414
|
-
x: 0,
|
|
1415
|
-
y: 0
|
|
1416
|
-
};
|
|
1417
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
1418
|
-
if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1419
|
-
scroll = getNodeScroll(offsetParent);
|
|
1420
|
-
}
|
|
1421
|
-
if (isHTMLElement2(offsetParent)) {
|
|
1422
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1423
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1424
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1425
|
-
} else if (documentElement) {
|
|
1426
|
-
offsets.x = getWindowScrollBarX(documentElement);
|
|
1427
|
-
}
|
|
1428
|
-
}
|
|
1429
|
-
return {
|
|
1430
|
-
x: rect.left + scroll.scrollLeft - offsets.x,
|
|
1431
|
-
y: rect.top + scroll.scrollTop - offsets.y,
|
|
1432
|
-
width: rect.width,
|
|
1433
|
-
height: rect.height
|
|
1434
|
-
};
|
|
1435
|
-
}
|
|
1436
|
-
function getParentNode(node) {
|
|
1437
|
-
if (getNodeName2(node) === "html") {
|
|
1438
|
-
return node;
|
|
1439
|
-
}
|
|
1440
|
-
return node.assignedSlot || node.parentNode || (isShadowRoot(node) ? node.host : null) || getDocumentElement(node);
|
|
1441
|
-
}
|
|
1442
|
-
function getTrueOffsetParent(element) {
|
|
1443
|
-
if (!isHTMLElement2(element) || getComputedStyle(element).position === "fixed") {
|
|
1444
|
-
return null;
|
|
1445
|
-
}
|
|
1446
|
-
return element.offsetParent;
|
|
1447
|
-
}
|
|
1448
|
-
function getContainingBlock(element) {
|
|
1449
|
-
let currentNode = getParentNode(element);
|
|
1450
|
-
if (isShadowRoot(currentNode)) {
|
|
1451
|
-
currentNode = currentNode.host;
|
|
1452
|
-
}
|
|
1453
|
-
while (isHTMLElement2(currentNode) && !["html", "body"].includes(getNodeName2(currentNode))) {
|
|
1454
|
-
if (isContainingBlock(currentNode)) {
|
|
1455
|
-
return currentNode;
|
|
1456
|
-
} else {
|
|
1457
|
-
currentNode = currentNode.parentNode;
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
1460
|
-
return null;
|
|
1461
|
-
}
|
|
1462
|
-
function getOffsetParent(element) {
|
|
1463
|
-
const window2 = getWindow(element);
|
|
1464
|
-
let offsetParent = getTrueOffsetParent(element);
|
|
1465
|
-
while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === "static") {
|
|
1466
|
-
offsetParent = getTrueOffsetParent(offsetParent);
|
|
1467
|
-
}
|
|
1468
|
-
if (offsetParent && (getNodeName2(offsetParent) === "html" || getNodeName2(offsetParent) === "body" && getComputedStyle(offsetParent).position === "static" && !isContainingBlock(offsetParent))) {
|
|
1469
|
-
return window2;
|
|
1470
|
-
}
|
|
1471
|
-
return offsetParent || getContainingBlock(element) || window2;
|
|
1472
|
-
}
|
|
1473
|
-
function getDimensions(element) {
|
|
1474
|
-
if (isHTMLElement2(element)) {
|
|
1475
|
-
return {
|
|
1476
|
-
width: element.offsetWidth,
|
|
1477
|
-
height: element.offsetHeight
|
|
1478
|
-
};
|
|
1479
|
-
}
|
|
1480
|
-
const rect = getBoundingClientRect(element);
|
|
1481
|
-
return {
|
|
1482
|
-
width: rect.width,
|
|
1483
|
-
height: rect.height
|
|
1484
|
-
};
|
|
1485
|
-
}
|
|
1486
|
-
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
1487
|
-
let {
|
|
1488
|
-
rect,
|
|
1489
|
-
offsetParent,
|
|
1490
|
-
strategy
|
|
1491
|
-
} = _ref;
|
|
1492
|
-
const isOffsetParentAnElement = isHTMLElement2(offsetParent);
|
|
1493
|
-
const documentElement = getDocumentElement(offsetParent);
|
|
1494
|
-
if (offsetParent === documentElement) {
|
|
1495
|
-
return rect;
|
|
1496
|
-
}
|
|
1497
|
-
let scroll = {
|
|
1498
|
-
scrollLeft: 0,
|
|
1499
|
-
scrollTop: 0
|
|
1500
|
-
};
|
|
1501
|
-
const offsets = {
|
|
1502
|
-
x: 0,
|
|
1503
|
-
y: 0
|
|
1504
|
-
};
|
|
1505
|
-
if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== "fixed") {
|
|
1506
|
-
if (getNodeName2(offsetParent) !== "body" || isOverflowElement(documentElement)) {
|
|
1507
|
-
scroll = getNodeScroll(offsetParent);
|
|
1508
|
-
}
|
|
1509
|
-
if (isHTMLElement2(offsetParent)) {
|
|
1510
|
-
const offsetRect = getBoundingClientRect(offsetParent, true);
|
|
1511
|
-
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
1512
|
-
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
1513
|
-
}
|
|
1514
|
-
}
|
|
1515
|
-
return __spreadProps(__spreadValues({}, rect), {
|
|
1516
|
-
x: rect.x - scroll.scrollLeft + offsets.x,
|
|
1517
|
-
y: rect.y - scroll.scrollTop + offsets.y
|
|
1518
|
-
});
|
|
1519
|
-
}
|
|
1520
|
-
function getViewportRect(element, strategy) {
|
|
1521
|
-
const win = getWindow(element);
|
|
1522
|
-
const html = getDocumentElement(element);
|
|
1523
|
-
const visualViewport = win.visualViewport;
|
|
1524
|
-
let width = html.clientWidth;
|
|
1525
|
-
let height = html.clientHeight;
|
|
1526
|
-
let x = 0;
|
|
1527
|
-
let y = 0;
|
|
1528
|
-
if (visualViewport) {
|
|
1529
|
-
width = visualViewport.width;
|
|
1530
|
-
height = visualViewport.height;
|
|
1531
|
-
const layoutViewport = isLayoutViewport();
|
|
1532
|
-
if (layoutViewport || !layoutViewport && strategy === "fixed") {
|
|
1533
|
-
x = visualViewport.offsetLeft;
|
|
1534
|
-
y = visualViewport.offsetTop;
|
|
1535
|
-
}
|
|
1536
|
-
}
|
|
1537
|
-
return {
|
|
1538
|
-
width,
|
|
1539
|
-
height,
|
|
1540
|
-
x,
|
|
1541
|
-
y
|
|
1542
|
-
};
|
|
1543
|
-
}
|
|
1544
|
-
function getDocumentRect(element) {
|
|
1545
|
-
var _element$ownerDocumen;
|
|
1546
|
-
const html = getDocumentElement(element);
|
|
1547
|
-
const scroll = getNodeScroll(element);
|
|
1548
|
-
const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
|
|
1549
|
-
const width = max2(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
|
|
1550
|
-
const height = max2(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
|
|
1551
|
-
let x = -scroll.scrollLeft + getWindowScrollBarX(element);
|
|
1552
|
-
const y = -scroll.scrollTop;
|
|
1553
|
-
if (getComputedStyle$1(body || html).direction === "rtl") {
|
|
1554
|
-
x += max2(html.clientWidth, body ? body.clientWidth : 0) - width;
|
|
1555
|
-
}
|
|
1556
|
-
return {
|
|
1557
|
-
width,
|
|
1558
|
-
height,
|
|
1559
|
-
x,
|
|
1560
|
-
y
|
|
1561
|
-
};
|
|
1562
|
-
}
|
|
1563
|
-
function getNearestOverflowAncestor(node) {
|
|
1564
|
-
const parentNode = getParentNode(node);
|
|
1565
|
-
if (["html", "body", "#document"].includes(getNodeName2(parentNode))) {
|
|
1566
|
-
return node.ownerDocument.body;
|
|
1567
|
-
}
|
|
1568
|
-
if (isHTMLElement2(parentNode) && isOverflowElement(parentNode)) {
|
|
1569
|
-
return parentNode;
|
|
1570
|
-
}
|
|
1571
|
-
return getNearestOverflowAncestor(parentNode);
|
|
1572
|
-
}
|
|
1573
|
-
function getOverflowAncestors(node, list) {
|
|
1574
|
-
var _node$ownerDocument;
|
|
1575
|
-
if (list === void 0) {
|
|
1576
|
-
list = [];
|
|
1577
|
-
}
|
|
1578
|
-
const scrollableAncestor = getNearestOverflowAncestor(node);
|
|
1579
|
-
const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
|
|
1580
|
-
const win = getWindow(scrollableAncestor);
|
|
1581
|
-
const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
|
|
1582
|
-
const updatedList = list.concat(target);
|
|
1583
|
-
return isBody ? updatedList : updatedList.concat(getOverflowAncestors(getParentNode(target)));
|
|
1584
|
-
}
|
|
1585
|
-
function contains2(parent, child) {
|
|
1586
|
-
const rootNode = child.getRootNode == null ? void 0 : child.getRootNode();
|
|
1587
|
-
if (parent.contains(child)) {
|
|
1588
|
-
return true;
|
|
1589
|
-
} else if (rootNode && isShadowRoot(rootNode)) {
|
|
1590
|
-
let next2 = child;
|
|
1591
|
-
do {
|
|
1592
|
-
if (next2 && parent === next2) {
|
|
1593
|
-
return true;
|
|
1594
|
-
}
|
|
1595
|
-
next2 = next2.parentNode || next2.host;
|
|
1596
|
-
} while (next2);
|
|
1597
|
-
}
|
|
1598
|
-
return false;
|
|
1599
|
-
}
|
|
1600
|
-
function getInnerBoundingClientRect(element, strategy) {
|
|
1601
|
-
const clientRect = getBoundingClientRect(element, false, strategy === "fixed");
|
|
1602
|
-
const top = clientRect.top + element.clientTop;
|
|
1603
|
-
const left = clientRect.left + element.clientLeft;
|
|
1604
|
-
return {
|
|
1605
|
-
top,
|
|
1606
|
-
left,
|
|
1607
|
-
x: left,
|
|
1608
|
-
y: top,
|
|
1609
|
-
right: left + element.clientWidth,
|
|
1610
|
-
bottom: top + element.clientHeight,
|
|
1611
|
-
width: element.clientWidth,
|
|
1612
|
-
height: element.clientHeight
|
|
1613
|
-
};
|
|
1614
|
-
}
|
|
1615
|
-
function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
|
|
1616
|
-
if (clippingParent === "viewport") {
|
|
1617
|
-
return rectToClientRect(getViewportRect(element, strategy));
|
|
1618
|
-
}
|
|
1619
|
-
if (isElement(clippingParent)) {
|
|
1620
|
-
return getInnerBoundingClientRect(clippingParent, strategy);
|
|
1621
|
-
}
|
|
1622
|
-
return rectToClientRect(getDocumentRect(getDocumentElement(element)));
|
|
1623
|
-
}
|
|
1624
|
-
function getClippingAncestors(element) {
|
|
1625
|
-
const clippingAncestors = getOverflowAncestors(element);
|
|
1626
|
-
const canEscapeClipping = ["absolute", "fixed"].includes(getComputedStyle$1(element).position);
|
|
1627
|
-
const clipperElement = canEscapeClipping && isHTMLElement2(element) ? getOffsetParent(element) : element;
|
|
1628
|
-
if (!isElement(clipperElement)) {
|
|
1629
|
-
return [];
|
|
1630
|
-
}
|
|
1631
|
-
return clippingAncestors.filter((clippingAncestors2) => isElement(clippingAncestors2) && contains2(clippingAncestors2, clipperElement) && getNodeName2(clippingAncestors2) !== "body");
|
|
1632
|
-
}
|
|
1633
|
-
function getClippingRect(_ref) {
|
|
1634
|
-
let {
|
|
1635
|
-
element,
|
|
1636
|
-
boundary,
|
|
1637
|
-
rootBoundary,
|
|
1638
|
-
strategy
|
|
1639
|
-
} = _ref;
|
|
1640
|
-
const mainClippingAncestors = boundary === "clippingAncestors" ? getClippingAncestors(element) : [].concat(boundary);
|
|
1641
|
-
const clippingAncestors = [...mainClippingAncestors, rootBoundary];
|
|
1642
|
-
const firstClippingAncestor = clippingAncestors[0];
|
|
1643
|
-
const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
|
|
1644
|
-
const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
|
|
1645
|
-
accRect.top = max2(rect.top, accRect.top);
|
|
1646
|
-
accRect.right = min2(rect.right, accRect.right);
|
|
1647
|
-
accRect.bottom = min2(rect.bottom, accRect.bottom);
|
|
1648
|
-
accRect.left = max2(rect.left, accRect.left);
|
|
1649
|
-
return accRect;
|
|
1650
|
-
}, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
|
|
1651
|
-
return {
|
|
1652
|
-
width: clippingRect.right - clippingRect.left,
|
|
1653
|
-
height: clippingRect.bottom - clippingRect.top,
|
|
1654
|
-
x: clippingRect.left,
|
|
1655
|
-
y: clippingRect.top
|
|
1656
|
-
};
|
|
1657
|
-
}
|
|
1658
|
-
var platform2 = {
|
|
1659
|
-
getClippingRect,
|
|
1660
|
-
convertOffsetParentRelativeRectToViewportRelativeRect,
|
|
1661
|
-
isElement,
|
|
1662
|
-
getDimensions,
|
|
1663
|
-
getOffsetParent,
|
|
1664
|
-
getDocumentElement,
|
|
1665
|
-
getElementRects: (_ref) => {
|
|
1666
|
-
let {
|
|
1667
|
-
reference,
|
|
1668
|
-
floating,
|
|
1669
|
-
strategy
|
|
1670
|
-
} = _ref;
|
|
1671
|
-
return {
|
|
1672
|
-
reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
|
|
1673
|
-
floating: __spreadProps(__spreadValues({}, getDimensions(floating)), {
|
|
1674
|
-
x: 0,
|
|
1675
|
-
y: 0
|
|
1676
|
-
})
|
|
1677
|
-
};
|
|
1678
|
-
},
|
|
1679
|
-
getClientRects: (element) => Array.from(element.getClientRects()),
|
|
1680
|
-
isRTL: (element) => getComputedStyle$1(element).direction === "rtl"
|
|
1681
|
-
};
|
|
1682
|
-
var computePosition2 = (reference, floating, options) => computePosition(reference, floating, __spreadValues({
|
|
1683
|
-
platform: platform2
|
|
1684
|
-
}, options));
|
|
1685
|
-
|
|
1686
|
-
// ../../utilities/popper/src/auto-update.ts
|
|
1687
|
-
function resolveOptions(option) {
|
|
1688
|
-
if (isBoolean(option))
|
|
1689
|
-
return { ancestorResize: option, ancestorScroll: option, referenceResize: option };
|
|
1690
|
-
return Object.assign({ ancestorResize: true, ancestorScroll: true, referenceResize: true }, option);
|
|
1691
|
-
}
|
|
1692
|
-
function autoUpdate(reference, floating, update, options = false) {
|
|
1693
|
-
const { ancestorScroll, ancestorResize, referenceResize } = resolveOptions(options);
|
|
1694
|
-
const useAncestors = ancestorScroll || ancestorResize;
|
|
1695
|
-
const ancestors = [];
|
|
1696
|
-
if (useAncestors && isHTMLElement(reference)) {
|
|
1697
|
-
ancestors.push(...getOverflowAncestors(reference));
|
|
1698
|
-
}
|
|
1699
|
-
function addResizeListeners() {
|
|
1700
|
-
let cleanups = [observeElementRect(floating, update)];
|
|
1701
|
-
if (referenceResize && isHTMLElement(reference)) {
|
|
1702
|
-
cleanups.push(observeElementRect(reference, update));
|
|
1703
|
-
}
|
|
1704
|
-
cleanups.push(pipe(...ancestors.map((el) => addDomEvent(el, "resize", update))));
|
|
1705
|
-
return () => cleanups.forEach((fn) => fn());
|
|
1706
|
-
}
|
|
1707
|
-
function addScrollListeners() {
|
|
1708
|
-
return pipe(...ancestors.map((el) => addDomEvent(el, "scroll", update, { passive: true })));
|
|
1709
|
-
}
|
|
1710
|
-
return pipe(addResizeListeners(), addScrollListeners());
|
|
1711
|
-
}
|
|
1712
|
-
|
|
1713
|
-
// ../../utilities/popper/src/middleware.ts
|
|
1714
|
-
var toVar = (value) => ({ variable: value, reference: `var(${value})` });
|
|
1715
|
-
var cssVars = {
|
|
1716
|
-
arrowShadowColor: toVar("--arrow-shadow-color"),
|
|
1717
|
-
arrowSize: toVar("--arrow-size"),
|
|
1718
|
-
arrowSizeHalf: toVar("--arrow-size-half"),
|
|
1719
|
-
arrowBg: toVar("--arrow-background"),
|
|
1720
|
-
transformOrigin: toVar("--transform-origin"),
|
|
1721
|
-
arrowOffset: toVar("--arrow-offset"),
|
|
1722
|
-
boxShadow: toVar("--arrow-box-shadow")
|
|
1723
|
-
};
|
|
1724
|
-
var transforms = {
|
|
1725
|
-
top: "bottom center",
|
|
1726
|
-
"top-start": "bottom left",
|
|
1727
|
-
"top-end": "bottom right",
|
|
1728
|
-
bottom: "top center",
|
|
1729
|
-
"bottom-start": "top left",
|
|
1730
|
-
"bottom-end": "top right",
|
|
1731
|
-
left: "right center",
|
|
1732
|
-
"left-start": "right top",
|
|
1733
|
-
"left-end": "right bottom",
|
|
1734
|
-
right: "left center",
|
|
1735
|
-
"right-start": "left top",
|
|
1736
|
-
"right-end": "left bottom"
|
|
1737
|
-
};
|
|
1738
|
-
var transformOrigin = {
|
|
1739
|
-
name: "transformOrigin",
|
|
1740
|
-
fn({ placement, elements }) {
|
|
1741
|
-
const { floating } = elements;
|
|
1742
|
-
floating.style.setProperty(cssVars.transformOrigin.variable, transforms[placement]);
|
|
1743
|
-
return {
|
|
1744
|
-
data: { transformOrigin: transforms[placement] }
|
|
1745
|
-
};
|
|
1746
|
-
}
|
|
1747
|
-
};
|
|
1748
|
-
var shiftArrow = (opts) => ({
|
|
1749
|
-
name: "shiftArrow",
|
|
1750
|
-
fn({ placement, middlewareData }) {
|
|
1751
|
-
var _a;
|
|
1752
|
-
const { element: arrow2 } = opts;
|
|
1753
|
-
const { x, y } = (_a = middlewareData.arrow) != null ? _a : { x: 0, y: 0 };
|
|
1754
|
-
const staticSide = {
|
|
1755
|
-
top: "bottom",
|
|
1756
|
-
right: "left",
|
|
1757
|
-
bottom: "top",
|
|
1758
|
-
left: "right"
|
|
1759
|
-
}[placement.split("-")[0]];
|
|
1760
|
-
Object.assign(arrow2.style, {
|
|
1761
|
-
top: `${y}px`,
|
|
1762
|
-
left: `${x}px`,
|
|
1763
|
-
[staticSide]: cssVars.arrowOffset.reference,
|
|
1764
|
-
[cssVars.boxShadow.variable]: getBoxShadow(placement)
|
|
1765
|
-
});
|
|
1766
|
-
return {};
|
|
1767
|
-
}
|
|
1768
|
-
});
|
|
1769
|
-
function getBoxShadow(placement) {
|
|
1770
|
-
if (placement.includes("top"))
|
|
1771
|
-
return `1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1772
|
-
if (placement.includes("bottom"))
|
|
1773
|
-
return `-1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1774
|
-
if (placement.includes("right"))
|
|
1775
|
-
return `-1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1776
|
-
if (placement.includes("left"))
|
|
1777
|
-
return `1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`;
|
|
1778
|
-
}
|
|
1779
|
-
|
|
1780
|
-
// ../../utilities/popper/src/get-placement.ts
|
|
1781
|
-
var defaultOptions = {
|
|
1782
|
-
strategy: "absolute",
|
|
1783
|
-
placement: "bottom",
|
|
1784
|
-
listeners: true,
|
|
1785
|
-
gutter: 8,
|
|
1786
|
-
flip: true,
|
|
1787
|
-
sameWidth: false
|
|
1788
|
-
};
|
|
1789
|
-
function getPlacement(reference, floating, options = {}) {
|
|
1790
|
-
var _a;
|
|
1791
|
-
if (reference == null || floating == null)
|
|
1792
|
-
return noop;
|
|
1793
|
-
options = Object.assign({}, defaultOptions, options);
|
|
1794
|
-
const middleware = [transformOrigin];
|
|
1795
|
-
if (options.flip) {
|
|
1796
|
-
middleware.push(flip({ boundary: options.boundary, padding: 8 }));
|
|
1797
|
-
}
|
|
1798
|
-
if (options.gutter || options.offset) {
|
|
1799
|
-
const data = options.gutter ? { mainAxis: options.gutter } : options.offset;
|
|
1800
|
-
middleware.push(offset(data));
|
|
1801
|
-
}
|
|
1802
|
-
middleware.push(shift({ boundary: options.boundary }));
|
|
1803
|
-
const doc = getOwnerDocument(floating);
|
|
1804
|
-
const arrowEl = doc.querySelector("[data-part=arrow]");
|
|
1805
|
-
if (arrowEl) {
|
|
1806
|
-
middleware.push(arrow({ element: arrowEl, padding: 8 }), shiftArrow({ element: arrowEl }));
|
|
1807
|
-
}
|
|
1808
|
-
if (options.sameWidth) {
|
|
1809
|
-
middleware.push(size({
|
|
1810
|
-
apply(data) {
|
|
1811
|
-
const { width } = data.reference;
|
|
1812
|
-
Object.assign(floating.style, { width: `${width}px`, minWidth: "unset" });
|
|
1813
|
-
}
|
|
1814
|
-
}));
|
|
1815
|
-
}
|
|
1816
|
-
function compute() {
|
|
1817
|
-
if (reference == null || floating == null)
|
|
1818
|
-
return;
|
|
1819
|
-
const { placement, strategy } = options;
|
|
1820
|
-
computePosition2(reference, floating, { placement, middleware, strategy }).then((data) => {
|
|
1821
|
-
const { x, y, strategy: strategy2 } = data;
|
|
1822
|
-
Object.assign(floating.style, { left: `${x}px`, top: `${y}px`, position: strategy2 });
|
|
1823
|
-
return data;
|
|
1824
|
-
}).then((data) => {
|
|
1825
|
-
var _a2;
|
|
1826
|
-
(_a2 = options.onComplete) == null ? void 0 : _a2.call(options, data);
|
|
1827
|
-
});
|
|
1828
|
-
}
|
|
1829
|
-
compute();
|
|
1830
|
-
return pipe(autoUpdate(reference, floating, compute, options.listeners), (_a = options.onCleanup) != null ? _a : noop);
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
// ../../utilities/popper/src/get-styles.ts
|
|
1834
|
-
var UNMEASURED_FLOATING_STYLE = {
|
|
1835
|
-
position: "fixed",
|
|
1836
|
-
top: 0,
|
|
1837
|
-
left: 0,
|
|
1838
|
-
opacity: 0,
|
|
1839
|
-
transform: "translate3d(0, -200%, 0)",
|
|
1840
|
-
pointerEvents: "none"
|
|
1841
|
-
};
|
|
1842
|
-
function getPlacementStyles(options) {
|
|
1843
|
-
const { measured, strategy = "absolute" } = options;
|
|
1844
|
-
return {
|
|
1845
|
-
arrow: {
|
|
1846
|
-
position: "absolute",
|
|
1847
|
-
width: cssVars.arrowSize.reference,
|
|
1848
|
-
height: cssVars.arrowSize.reference,
|
|
1849
|
-
[cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,
|
|
1850
|
-
[cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,
|
|
1851
|
-
opacity: !measured ? 0 : void 0
|
|
1852
|
-
},
|
|
1853
|
-
innerArrow: {
|
|
1854
|
-
transform: "rotate(45deg)",
|
|
1855
|
-
background: cssVars.arrowBg.reference,
|
|
1856
|
-
top: "0",
|
|
1857
|
-
left: "0",
|
|
1858
|
-
width: "100%",
|
|
1859
|
-
height: "100%",
|
|
1860
|
-
position: "absolute",
|
|
1861
|
-
zIndex: "inherit"
|
|
1862
|
-
},
|
|
1863
|
-
floating: __spreadValues({
|
|
1864
|
-
position: strategy,
|
|
1865
|
-
minWidth: "max-content"
|
|
1866
|
-
}, !measured && UNMEASURED_FLOATING_STYLE)
|
|
1867
|
-
};
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
// ../../types/src/prop-types.ts
|
|
1871
|
-
function createNormalizer(fn) {
|
|
1872
|
-
return { button: fn, label: fn, input: fn, output: fn, element: fn };
|
|
1873
|
-
}
|
|
1874
|
-
var normalizeProp = createNormalizer((v) => v);
|
|
1875
|
-
|
|
1876
|
-
// src/popover.dom.ts
|
|
1877
|
-
var dom = {
|
|
1878
|
-
getDoc: (ctx) => {
|
|
1879
|
-
var _a;
|
|
1880
|
-
return (_a = ctx.doc) != null ? _a : document;
|
|
1881
|
-
},
|
|
1882
|
-
getActiveEl: (ctx) => dom.getDoc(ctx).activeElement,
|
|
1883
|
-
getAnchorId: (ctx) => {
|
|
1884
|
-
var _a, _b;
|
|
1885
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.anchor) != null ? _b : `popover-${ctx.uid}-anchor`;
|
|
1886
|
-
},
|
|
1887
|
-
getTriggerId: (ctx) => {
|
|
1888
|
-
var _a, _b;
|
|
1889
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.trigger) != null ? _b : `popover-${ctx.uid}-trigger`;
|
|
1890
|
-
},
|
|
1891
|
-
getContentId: (ctx) => {
|
|
1892
|
-
var _a, _b;
|
|
1893
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.content) != null ? _b : `popover-${ctx.uid}-content`;
|
|
1894
|
-
},
|
|
1895
|
-
getPositionerId: (ctx) => `popover-${ctx.uid}-popper`,
|
|
1896
|
-
getArrowId: (ctx) => `popover-${ctx.uid}-arrow`,
|
|
1897
|
-
getTitleId: (ctx) => {
|
|
1898
|
-
var _a, _b;
|
|
1899
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.title) != null ? _b : `popover-${ctx.uid}-title`;
|
|
1900
|
-
},
|
|
1901
|
-
getDescriptionId: (ctx) => {
|
|
1902
|
-
var _a, _b;
|
|
1903
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.description) != null ? _b : `popover-${ctx.uid}-desc`;
|
|
1904
|
-
},
|
|
1905
|
-
getCloseButtonId: (ctx) => {
|
|
1906
|
-
var _a, _b;
|
|
1907
|
-
return (_b = (_a = ctx.ids) == null ? void 0 : _a.closeBtn) != null ? _b : `popover-${ctx.uid}-close-button`;
|
|
1908
|
-
},
|
|
1909
|
-
getAnchorEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getAnchorId(ctx)),
|
|
1910
|
-
getTriggerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTriggerId(ctx)),
|
|
1911
|
-
getContentEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getContentId(ctx)),
|
|
1912
|
-
getPositionerEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPositionerId(ctx)),
|
|
1913
|
-
getTitleEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getTitleId(ctx)),
|
|
1914
|
-
getDescriptionEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getDescriptionId(ctx)),
|
|
1915
|
-
getFocusableEls: (ctx) => getFocusables(dom.getContentEl(ctx)),
|
|
1916
|
-
getFirstFocusableEl: (ctx) => dom.getFocusableEls(ctx)[0],
|
|
1917
|
-
getDocTabbableEls: (ctx) => getTabbables(cast(dom.getDoc(ctx))),
|
|
1918
|
-
getTabbableEls: (ctx) => {
|
|
1919
|
-
const el = dom.getContentEl(ctx);
|
|
1920
|
-
return el ? getTabbables(el) : [];
|
|
1921
|
-
},
|
|
1922
|
-
getFirstTabbableEl: (ctx) => first(dom.getTabbableEls(ctx)),
|
|
1923
|
-
getLastTabbableEl: (ctx) => last(dom.getTabbableEls(ctx)),
|
|
1924
|
-
getInitialFocusEl: (ctx) => {
|
|
1925
|
-
var _a;
|
|
1926
|
-
return (_a = runIfFn(ctx.initialFocusEl)) != null ? _a : dom.getFirstFocusableEl(ctx);
|
|
1927
|
-
}
|
|
1928
|
-
};
|
|
1929
|
-
|
|
1930
|
-
// src/popover.connect.ts
|
|
1931
|
-
function connect(state, send, normalize = normalizeProp) {
|
|
1932
|
-
const isOpen = state.matches("open");
|
|
1933
|
-
const pointerdownNode = state.context.pointerdownNode;
|
|
1934
|
-
const popperStyles = getPlacementStyles({
|
|
1935
|
-
measured: !!state.context.isPlacementComplete
|
|
1936
|
-
});
|
|
621
|
+
|
|
622
|
+
// src/popover.connect.ts
|
|
623
|
+
function connect(state, send, normalize = normalizeProp) {
|
|
624
|
+
const isOpen = state.matches("open");
|
|
625
|
+
const pointerdownNode = state.context.pointerdownNode;
|
|
626
|
+
const popperStyles = (0, import_popper.getPlacementStyles)({
|
|
627
|
+
measured: !!state.context.isPlacementComplete
|
|
628
|
+
});
|
|
1937
629
|
return {
|
|
1938
630
|
portalled: state.context.currentPortalled,
|
|
1939
631
|
isOpen,
|
|
@@ -2029,1444 +721,13 @@ function connect(state, send, normalize = normalizeProp) {
|
|
|
2029
721
|
};
|
|
2030
722
|
}
|
|
2031
723
|
|
|
2032
|
-
// ../../../node_modules/@zag-js/core/src/index.ts
|
|
2033
|
-
var import_vanilla3 = require("valtio/vanilla");
|
|
2034
|
-
|
|
2035
|
-
// ../../core/src/action-utils.ts
|
|
2036
|
-
function choose(actions) {
|
|
2037
|
-
return {
|
|
2038
|
-
predicate: (guardMap) => (ctx, event) => {
|
|
2039
|
-
var _a;
|
|
2040
|
-
return (_a = actions.find((def) => {
|
|
2041
|
-
var _a2;
|
|
2042
|
-
def.guard = def.guard || (() => true);
|
|
2043
|
-
if (isString(def.guard)) {
|
|
2044
|
-
return !!((_a2 = guardMap[def.guard]) == null ? void 0 : _a2.call(guardMap, ctx, event));
|
|
2045
|
-
}
|
|
2046
|
-
if (isGuardHelper(def.guard)) {
|
|
2047
|
-
return def.guard.predicate(guardMap != null ? guardMap : {})(ctx, event);
|
|
2048
|
-
}
|
|
2049
|
-
return def.guard(ctx, event);
|
|
2050
|
-
})) == null ? void 0 : _a.actions;
|
|
2051
|
-
}
|
|
2052
|
-
};
|
|
2053
|
-
}
|
|
2054
|
-
function isGuardHelper(value) {
|
|
2055
|
-
return isObject(value) && value.predicate != null;
|
|
2056
|
-
}
|
|
2057
|
-
function determineActionsFn(values, guardMap) {
|
|
2058
|
-
return (context, event) => {
|
|
2059
|
-
if (isGuardHelper(values))
|
|
2060
|
-
return values.predicate(guardMap != null ? guardMap : {})(context, event);
|
|
2061
|
-
return values;
|
|
2062
|
-
};
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
// ../../core/src/guard-utils.ts
|
|
2066
|
-
function or(...conditions) {
|
|
2067
|
-
return {
|
|
2068
|
-
predicate: (guards2) => (ctx, event) => conditions.map((condition) => {
|
|
2069
|
-
var _a;
|
|
2070
|
-
if (isString(condition)) {
|
|
2071
|
-
return !!((_a = guards2[condition]) == null ? void 0 : _a.call(guards2, ctx, event));
|
|
2072
|
-
}
|
|
2073
|
-
if (isFunction(condition)) {
|
|
2074
|
-
return condition(ctx, event);
|
|
2075
|
-
}
|
|
2076
|
-
return condition.predicate(guards2)(ctx, event);
|
|
2077
|
-
}).some(Boolean)
|
|
2078
|
-
};
|
|
2079
|
-
}
|
|
2080
|
-
function and(...conditions) {
|
|
2081
|
-
return {
|
|
2082
|
-
predicate: (guards2) => (ctx, event) => conditions.map((condition) => {
|
|
2083
|
-
var _a;
|
|
2084
|
-
if (isString(condition)) {
|
|
2085
|
-
return !!((_a = guards2[condition]) == null ? void 0 : _a.call(guards2, ctx, event));
|
|
2086
|
-
}
|
|
2087
|
-
if (isFunction(condition)) {
|
|
2088
|
-
return condition(ctx, event);
|
|
2089
|
-
}
|
|
2090
|
-
return condition.predicate(guards2)(ctx, event);
|
|
2091
|
-
}).every(Boolean)
|
|
2092
|
-
};
|
|
2093
|
-
}
|
|
2094
|
-
function not(condition) {
|
|
2095
|
-
return {
|
|
2096
|
-
predicate: (guardMap) => (ctx, event) => {
|
|
2097
|
-
var _a;
|
|
2098
|
-
if (isString(condition)) {
|
|
2099
|
-
return !((_a = guardMap[condition]) == null ? void 0 : _a.call(guardMap, ctx, event));
|
|
2100
|
-
}
|
|
2101
|
-
if (isFunction(condition)) {
|
|
2102
|
-
return !condition(ctx, event);
|
|
2103
|
-
}
|
|
2104
|
-
return !condition.predicate(guardMap)(ctx, event);
|
|
2105
|
-
}
|
|
2106
|
-
};
|
|
2107
|
-
}
|
|
2108
|
-
var guards = { or, and, not };
|
|
2109
|
-
function isGuardHelper2(value) {
|
|
2110
|
-
return isObject(value) && value.predicate != null;
|
|
2111
|
-
}
|
|
2112
|
-
var TruthyGuard = () => true;
|
|
2113
|
-
function determineGuardFn(guard, guardMap) {
|
|
2114
|
-
guard = guard != null ? guard : TruthyGuard;
|
|
2115
|
-
return (context, event) => {
|
|
2116
|
-
if (isString(guard)) {
|
|
2117
|
-
const value = guardMap == null ? void 0 : guardMap[guard];
|
|
2118
|
-
return isFunction(value) ? value(context, event) : value;
|
|
2119
|
-
}
|
|
2120
|
-
if (isGuardHelper2(guard)) {
|
|
2121
|
-
return guard.predicate(guardMap != null ? guardMap : {})(context, event);
|
|
2122
|
-
}
|
|
2123
|
-
return guard == null ? void 0 : guard(context, event);
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
2126
|
-
|
|
2127
|
-
// ../../../node_modules/klona/json/index.mjs
|
|
2128
|
-
function klona(val) {
|
|
2129
|
-
var k, out, tmp;
|
|
2130
|
-
if (Array.isArray(val)) {
|
|
2131
|
-
out = Array(k = val.length);
|
|
2132
|
-
while (k--)
|
|
2133
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
2134
|
-
return out;
|
|
2135
|
-
}
|
|
2136
|
-
if (Object.prototype.toString.call(val) === "[object Object]") {
|
|
2137
|
-
out = {};
|
|
2138
|
-
for (k in val) {
|
|
2139
|
-
if (k === "__proto__") {
|
|
2140
|
-
Object.defineProperty(out, k, {
|
|
2141
|
-
value: klona(val[k]),
|
|
2142
|
-
configurable: true,
|
|
2143
|
-
enumerable: true,
|
|
2144
|
-
writable: true
|
|
2145
|
-
});
|
|
2146
|
-
} else {
|
|
2147
|
-
out[k] = (tmp = val[k]) && typeof tmp === "object" ? klona(tmp) : tmp;
|
|
2148
|
-
}
|
|
2149
|
-
}
|
|
2150
|
-
return out;
|
|
2151
|
-
}
|
|
2152
|
-
return val;
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
// ../../core/src/machine.ts
|
|
2156
|
-
var import_utils16 = require("valtio/utils");
|
|
2157
|
-
var import_vanilla2 = require("valtio/vanilla");
|
|
2158
|
-
|
|
2159
|
-
// ../../core/src/create-proxy.ts
|
|
2160
|
-
var import_vanilla = require("valtio/vanilla");
|
|
2161
|
-
function createProxy(config) {
|
|
2162
|
-
var _a;
|
|
2163
|
-
const state = (0, import_vanilla.proxy)({
|
|
2164
|
-
value: "",
|
|
2165
|
-
previousValue: "",
|
|
2166
|
-
event: cast({}),
|
|
2167
|
-
context: (_a = config.context) != null ? _a : cast({}),
|
|
2168
|
-
done: false,
|
|
2169
|
-
tags: [],
|
|
2170
|
-
hasTag(tag) {
|
|
2171
|
-
return this.tags.includes(tag);
|
|
2172
|
-
},
|
|
2173
|
-
matches(...value) {
|
|
2174
|
-
return value.includes(this.value);
|
|
2175
|
-
},
|
|
2176
|
-
can(event) {
|
|
2177
|
-
return cast(this).nextEvents.includes(event);
|
|
2178
|
-
},
|
|
2179
|
-
get nextEvents() {
|
|
2180
|
-
var _a2, _b, _c, _d;
|
|
2181
|
-
const stateEvents = (_c = (_b = (_a2 = config.states) == null ? void 0 : _a2[this.value]) == null ? void 0 : _b["on"]) != null ? _c : {};
|
|
2182
|
-
const globalEvents = (_d = config == null ? void 0 : config.on) != null ? _d : {};
|
|
2183
|
-
return Object.keys(__spreadValues(__spreadValues({}, stateEvents), globalEvents));
|
|
2184
|
-
},
|
|
2185
|
-
get changed() {
|
|
2186
|
-
if (this.event.value === "machine.init" /* Init */ || !this.previousValue)
|
|
2187
|
-
return false;
|
|
2188
|
-
return this.value !== this.previousValue;
|
|
2189
|
-
}
|
|
2190
|
-
});
|
|
2191
|
-
return cast(state);
|
|
2192
|
-
}
|
|
2193
|
-
|
|
2194
|
-
// ../../core/src/delay-utils.ts
|
|
2195
|
-
function determineDelayFn(delay3, delaysMap) {
|
|
2196
|
-
return (context, event) => {
|
|
2197
|
-
if (isNumber(delay3))
|
|
2198
|
-
return delay3;
|
|
2199
|
-
if (isFunction(delay3)) {
|
|
2200
|
-
return delay3(context, event);
|
|
2201
|
-
}
|
|
2202
|
-
if (isString(delay3)) {
|
|
2203
|
-
const value = Number.parseFloat(delay3);
|
|
2204
|
-
if (!Number.isNaN(value)) {
|
|
2205
|
-
return value;
|
|
2206
|
-
}
|
|
2207
|
-
if (delaysMap) {
|
|
2208
|
-
const valueOrFn = delaysMap == null ? void 0 : delaysMap[delay3];
|
|
2209
|
-
if (valueOrFn == null) {
|
|
2210
|
-
const msg = `[machine] Cannot determine delay for ${delay3}. It doesn't exist in options.delays`;
|
|
2211
|
-
throw new Error(msg);
|
|
2212
|
-
}
|
|
2213
|
-
return isFunction(valueOrFn) ? valueOrFn(context, event) : valueOrFn;
|
|
2214
|
-
}
|
|
2215
|
-
}
|
|
2216
|
-
};
|
|
2217
|
-
}
|
|
2218
|
-
|
|
2219
|
-
// ../../core/src/utils.ts
|
|
2220
|
-
function toEvent(event) {
|
|
2221
|
-
const obj = isString(event) ? { type: event } : event;
|
|
2222
|
-
return obj;
|
|
2223
|
-
}
|
|
2224
|
-
function toArray(value) {
|
|
2225
|
-
if (!value)
|
|
2226
|
-
return [];
|
|
2227
|
-
return isArray(value) ? value : [value];
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
// ../../core/src/transition-utils.ts
|
|
2231
|
-
function toTarget(target) {
|
|
2232
|
-
return isString(target) ? { target } : target;
|
|
2233
|
-
}
|
|
2234
|
-
function determineTransitionFn(transitions, guardMap) {
|
|
2235
|
-
return (context, event) => {
|
|
2236
|
-
return toArray(transitions).map(toTarget).find((transition) => {
|
|
2237
|
-
var _a;
|
|
2238
|
-
const determineGuard = determineGuardFn(transition.guard, guardMap);
|
|
2239
|
-
const guard = determineGuard(context, event);
|
|
2240
|
-
return (_a = guard != null ? guard : transition.target) != null ? _a : transition.actions;
|
|
2241
|
-
});
|
|
2242
|
-
};
|
|
2243
|
-
}
|
|
2244
|
-
function toTransition(transition, current) {
|
|
2245
|
-
const _transition = isString(transition) ? toTarget(transition) : transition;
|
|
2246
|
-
const fn = (t3) => {
|
|
2247
|
-
const isTargetless = t3.actions && !t3.target;
|
|
2248
|
-
if (isTargetless && current)
|
|
2249
|
-
t3.target = current;
|
|
2250
|
-
return t3;
|
|
2251
|
-
};
|
|
2252
|
-
if (isArray(_transition)) {
|
|
2253
|
-
return _transition.map(fn);
|
|
2254
|
-
}
|
|
2255
|
-
if (isObject(_transition)) {
|
|
2256
|
-
return fn(cast(_transition));
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
// ../../core/src/machine.ts
|
|
2261
|
-
var Machine = class {
|
|
2262
|
-
constructor(config, options) {
|
|
2263
|
-
this.config = config;
|
|
2264
|
-
this.status = "Not Started" /* NotStarted */;
|
|
2265
|
-
this.type = "machine" /* Machine */;
|
|
2266
|
-
this.activityEvents = /* @__PURE__ */ new Map();
|
|
2267
|
-
this.delayedEvents = /* @__PURE__ */ new Map();
|
|
2268
|
-
this.stateListeners = /* @__PURE__ */ new Set();
|
|
2269
|
-
this.eventListeners = /* @__PURE__ */ new Set();
|
|
2270
|
-
this.doneListeners = /* @__PURE__ */ new Set();
|
|
2271
|
-
this.contextWatchers = /* @__PURE__ */ new Set();
|
|
2272
|
-
this.removeStateListener = noop;
|
|
2273
|
-
this.removeEventListener = noop;
|
|
2274
|
-
this.children = /* @__PURE__ */ new Map();
|
|
2275
|
-
this.start = (init) => {
|
|
2276
|
-
if (this.status === "Running" /* Running */) {
|
|
2277
|
-
return this;
|
|
2278
|
-
}
|
|
2279
|
-
this.status = "Running" /* Running */;
|
|
2280
|
-
const event = toEvent("machine.init" /* Init */);
|
|
2281
|
-
if (init) {
|
|
2282
|
-
const resolved = isObject(init) ? init : { context: this.config.context, value: init };
|
|
2283
|
-
this.setState(resolved.value);
|
|
2284
|
-
this.setContext(resolved.context);
|
|
2285
|
-
}
|
|
2286
|
-
const transition = {
|
|
2287
|
-
target: !!init ? void 0 : this.config.initial
|
|
2288
|
-
};
|
|
2289
|
-
const info = this.getNextStateInfo(transition, event);
|
|
2290
|
-
info.target = cast(info.target || transition.target);
|
|
2291
|
-
this.initialState = info;
|
|
2292
|
-
this.performStateChangeEffects(info.target, info, event);
|
|
2293
|
-
this.removeStateListener = (0, import_vanilla2.subscribe)(this.state, () => {
|
|
2294
|
-
this.stateListeners.forEach((listener) => {
|
|
2295
|
-
listener(this.stateSnapshot);
|
|
2296
|
-
});
|
|
2297
|
-
}, this.sync);
|
|
2298
|
-
this.removeEventListener = (0, import_utils16.subscribeKey)(this.state, "event", (value) => {
|
|
2299
|
-
if (this.config.onEvent) {
|
|
2300
|
-
this.executeActions(this.config.onEvent, value);
|
|
2301
|
-
}
|
|
2302
|
-
for (const listener of this.eventListeners) {
|
|
2303
|
-
listener(value);
|
|
2304
|
-
}
|
|
2305
|
-
});
|
|
2306
|
-
this.setupContextWatchers();
|
|
2307
|
-
this.executeActivities(toEvent("machine.start" /* Start */), toArray(this.config.activities), "machine.start" /* Start */);
|
|
2308
|
-
this.executeActions(this.config.entry, toEvent("machine.start" /* Start */));
|
|
2309
|
-
return this;
|
|
2310
|
-
};
|
|
2311
|
-
this.setupContextWatchers = () => {
|
|
2312
|
-
var _a;
|
|
2313
|
-
for (const [key, fn] of Object.entries((_a = this.config.watch) != null ? _a : {})) {
|
|
2314
|
-
this.contextWatchers.add((0, import_utils16.subscribeKey)(this.state.context, key, () => {
|
|
2315
|
-
this.executeActions(fn, this.state.event);
|
|
2316
|
-
}));
|
|
2317
|
-
}
|
|
2318
|
-
};
|
|
2319
|
-
this.setupComputed = () => {
|
|
2320
|
-
var _a;
|
|
2321
|
-
const computed = cast((_a = this.config.computed) != null ? _a : {});
|
|
2322
|
-
const deriveFns = Object.fromEntries(Object.entries(computed).map(([key, fn]) => [key, (get) => fn(get(this.state.context))]));
|
|
2323
|
-
(0, import_utils16.derive)(deriveFns, { proxy: this.state.context });
|
|
2324
|
-
};
|
|
2325
|
-
this.detachComputed = () => {
|
|
2326
|
-
(0, import_utils16.underive)(this.state.context, { delete: true });
|
|
2327
|
-
};
|
|
2328
|
-
this.stop = () => {
|
|
2329
|
-
if (this.status === "Stopped" /* Stopped */)
|
|
2330
|
-
return;
|
|
2331
|
-
this.setState(null);
|
|
2332
|
-
this.setEvent("machine.stop" /* Stop */);
|
|
2333
|
-
if (this.config.context) {
|
|
2334
|
-
this.setContext(this.config.context);
|
|
2335
|
-
}
|
|
2336
|
-
this.stopStateListeners();
|
|
2337
|
-
this.stopChildren();
|
|
2338
|
-
this.stopActivities();
|
|
2339
|
-
this.stopDelayedEvents();
|
|
2340
|
-
this.stopContextWatchers();
|
|
2341
|
-
this.stopEventListeners();
|
|
2342
|
-
this.detachComputed();
|
|
2343
|
-
this.status = "Stopped" /* Stopped */;
|
|
2344
|
-
this.executeActions(this.config.exit, toEvent("machine.stop" /* Stop */));
|
|
2345
|
-
return this;
|
|
2346
|
-
};
|
|
2347
|
-
this.stopEventListeners = () => {
|
|
2348
|
-
this.eventListeners.clear();
|
|
2349
|
-
this.removeEventListener();
|
|
2350
|
-
};
|
|
2351
|
-
this.stopStateListeners = () => {
|
|
2352
|
-
this.removeStateListener();
|
|
2353
|
-
this.stateListeners.clear();
|
|
2354
|
-
};
|
|
2355
|
-
this.stopContextWatchers = () => {
|
|
2356
|
-
this.contextWatchers.forEach((fn) => fn());
|
|
2357
|
-
this.contextWatchers.clear();
|
|
2358
|
-
};
|
|
2359
|
-
this.stopDelayedEvents = () => {
|
|
2360
|
-
this.delayedEvents.forEach((state) => {
|
|
2361
|
-
state.forEach((stop) => stop());
|
|
2362
|
-
});
|
|
2363
|
-
this.delayedEvents.clear();
|
|
2364
|
-
};
|
|
2365
|
-
this.stopActivities = (state) => {
|
|
2366
|
-
var _a, _b;
|
|
2367
|
-
if (state) {
|
|
2368
|
-
(_a = this.activityEvents.get(state)) == null ? void 0 : _a.forEach((stop) => stop());
|
|
2369
|
-
(_b = this.activityEvents.get(state)) == null ? void 0 : _b.clear();
|
|
2370
|
-
this.activityEvents.delete(state);
|
|
2371
|
-
} else {
|
|
2372
|
-
this.activityEvents.forEach((state2) => {
|
|
2373
|
-
state2.forEach((stop) => stop());
|
|
2374
|
-
state2.clear();
|
|
2375
|
-
});
|
|
2376
|
-
this.activityEvents.clear();
|
|
2377
|
-
}
|
|
2378
|
-
};
|
|
2379
|
-
this.sendChild = (evt, to) => {
|
|
2380
|
-
const event = toEvent(evt);
|
|
2381
|
-
const id = runIfFn(to, this.contextSnapshot);
|
|
2382
|
-
const child = this.children.get(id);
|
|
2383
|
-
if (!child) {
|
|
2384
|
-
invariant(`[machine/send-child] Cannot send '${event.type}' event to unknown child`);
|
|
2385
|
-
}
|
|
2386
|
-
child.send(event);
|
|
2387
|
-
};
|
|
2388
|
-
this.stopChild = (id) => {
|
|
2389
|
-
if (!this.children.has(id)) {
|
|
2390
|
-
invariant("[machine/stop-child] Cannot stop unknown child");
|
|
2391
|
-
}
|
|
2392
|
-
this.children.get(id).stop();
|
|
2393
|
-
this.children.delete(id);
|
|
2394
|
-
};
|
|
2395
|
-
this.removeChild = (id) => {
|
|
2396
|
-
this.children.delete(id);
|
|
2397
|
-
};
|
|
2398
|
-
this.stopChildren = () => {
|
|
2399
|
-
this.children.forEach((child) => child.stop());
|
|
2400
|
-
this.children.clear();
|
|
2401
|
-
};
|
|
2402
|
-
this.setParent = (parent) => {
|
|
2403
|
-
this.parent = parent;
|
|
2404
|
-
};
|
|
2405
|
-
this.spawn = (src, id) => {
|
|
2406
|
-
const actor = runIfFn(src);
|
|
2407
|
-
if (id)
|
|
2408
|
-
actor.id = id;
|
|
2409
|
-
actor.type = "machine.actor" /* Actor */;
|
|
2410
|
-
actor.setParent(this);
|
|
2411
|
-
this.children.set(actor.id, cast(actor));
|
|
2412
|
-
actor.onDone(() => {
|
|
2413
|
-
this.removeChild(actor.id);
|
|
2414
|
-
}).start();
|
|
2415
|
-
return cast((0, import_vanilla2.ref)(actor));
|
|
2416
|
-
};
|
|
2417
|
-
this.addActivityCleanup = (state, cleanup) => {
|
|
2418
|
-
var _a;
|
|
2419
|
-
if (!state)
|
|
2420
|
-
return;
|
|
2421
|
-
if (!this.activityEvents.has(state)) {
|
|
2422
|
-
this.activityEvents.set(state, /* @__PURE__ */ new Set([cleanup]));
|
|
2423
|
-
} else {
|
|
2424
|
-
(_a = this.activityEvents.get(state)) == null ? void 0 : _a.add(cleanup);
|
|
2425
|
-
}
|
|
2426
|
-
};
|
|
2427
|
-
this.setState = (target) => {
|
|
2428
|
-
this.state.previousValue = this.state.value;
|
|
2429
|
-
this.state.value = target;
|
|
2430
|
-
const stateNode = this.getStateNode(target);
|
|
2431
|
-
if (target == null) {
|
|
2432
|
-
clear(this.state.tags);
|
|
2433
|
-
} else {
|
|
2434
|
-
this.state.tags = toArray(stateNode == null ? void 0 : stateNode.tags);
|
|
2435
|
-
}
|
|
2436
|
-
};
|
|
2437
|
-
this.setContext = (context) => {
|
|
2438
|
-
for (const key in context) {
|
|
2439
|
-
this.state.context[key] = context[key];
|
|
2440
|
-
}
|
|
2441
|
-
};
|
|
2442
|
-
this.withContext = (context) => {
|
|
2443
|
-
this.detachComputed();
|
|
2444
|
-
const newContext = __spreadValues(__spreadValues({}, this.config.context), context);
|
|
2445
|
-
return new Machine(__spreadProps(__spreadValues({}, this.config), { context: newContext }), this.options);
|
|
2446
|
-
};
|
|
2447
|
-
this.withOptions = (options) => {
|
|
2448
|
-
this.detachComputed();
|
|
2449
|
-
return new Machine(this.config, __spreadValues(__spreadValues({}, this.options), options));
|
|
2450
|
-
};
|
|
2451
|
-
this.setActions = (actions) => {
|
|
2452
|
-
this.actionMap = __spreadValues(__spreadValues({}, this.actionMap), actions);
|
|
2453
|
-
};
|
|
2454
|
-
this.clone = () => {
|
|
2455
|
-
this.detachComputed();
|
|
2456
|
-
return new Machine(this.config, this.options);
|
|
2457
|
-
};
|
|
2458
|
-
this.getStateNode = (state) => {
|
|
2459
|
-
var _a;
|
|
2460
|
-
if (!state)
|
|
2461
|
-
return;
|
|
2462
|
-
return (_a = this.config.states) == null ? void 0 : _a[state];
|
|
2463
|
-
};
|
|
2464
|
-
this.getNextStateInfo = (transitions, event) => {
|
|
2465
|
-
var _a;
|
|
2466
|
-
const transition = this.determineTransition(transitions, event);
|
|
2467
|
-
const target = (_a = transition == null ? void 0 : transition.target) != null ? _a : this.state.value;
|
|
2468
|
-
const stateNode = this.getStateNode(target);
|
|
2469
|
-
return {
|
|
2470
|
-
transition,
|
|
2471
|
-
stateNode,
|
|
2472
|
-
target
|
|
2473
|
-
};
|
|
2474
|
-
};
|
|
2475
|
-
this.getActionFromDelayedTransition = (transition) => {
|
|
2476
|
-
const event = toEvent("machine.after" /* After */);
|
|
2477
|
-
const determineDelay = determineDelayFn(transition.delay, this.delayMap);
|
|
2478
|
-
const delay3 = determineDelay(this.contextSnapshot, event);
|
|
2479
|
-
let id;
|
|
2480
|
-
return {
|
|
2481
|
-
entry: () => {
|
|
2482
|
-
id = globalThis.setTimeout(() => {
|
|
2483
|
-
const current = this.state.value;
|
|
2484
|
-
const next2 = this.getNextStateInfo(transition, event);
|
|
2485
|
-
this.performStateChangeEffects(current, next2, event);
|
|
2486
|
-
}, delay3);
|
|
2487
|
-
},
|
|
2488
|
-
exit: () => {
|
|
2489
|
-
globalThis.clearTimeout(id);
|
|
2490
|
-
}
|
|
2491
|
-
};
|
|
2492
|
-
};
|
|
2493
|
-
this.getDelayedEventActions = (state) => {
|
|
2494
|
-
const stateNode = this.getStateNode(state);
|
|
2495
|
-
const event = toEvent("machine.after" /* After */);
|
|
2496
|
-
if (!stateNode || !stateNode.after)
|
|
2497
|
-
return;
|
|
2498
|
-
const entries = [];
|
|
2499
|
-
const exits = [];
|
|
2500
|
-
if (isArray(stateNode.after)) {
|
|
2501
|
-
const transition = this.determineTransition(stateNode.after, event);
|
|
2502
|
-
if (!transition)
|
|
2503
|
-
return;
|
|
2504
|
-
const actions = this.getActionFromDelayedTransition(transition);
|
|
2505
|
-
entries.push(actions.entry);
|
|
2506
|
-
exits.push(actions.exit);
|
|
2507
|
-
} else if (isObject(stateNode.after)) {
|
|
2508
|
-
for (const delay3 in stateNode.after) {
|
|
2509
|
-
const transition = stateNode.after[delay3];
|
|
2510
|
-
let resolvedTransition = {};
|
|
2511
|
-
if (isArray(transition)) {
|
|
2512
|
-
const picked = this.determineTransition(transition, event);
|
|
2513
|
-
if (picked)
|
|
2514
|
-
resolvedTransition = picked;
|
|
2515
|
-
} else if (isString(transition)) {
|
|
2516
|
-
resolvedTransition = { target: transition, delay: delay3 };
|
|
2517
|
-
} else {
|
|
2518
|
-
resolvedTransition = __spreadProps(__spreadValues({}, transition), { delay: delay3 });
|
|
2519
|
-
}
|
|
2520
|
-
const actions = this.getActionFromDelayedTransition(resolvedTransition);
|
|
2521
|
-
entries.push(actions.entry);
|
|
2522
|
-
exits.push(actions.exit);
|
|
2523
|
-
}
|
|
2524
|
-
}
|
|
2525
|
-
return { entries, exits };
|
|
2526
|
-
};
|
|
2527
|
-
this.executeActions = (actions, event) => {
|
|
2528
|
-
var _a;
|
|
2529
|
-
const _actions = determineActionsFn(actions, this.guardMap)(this.contextSnapshot, event);
|
|
2530
|
-
for (const action of toArray(_actions)) {
|
|
2531
|
-
const fn = isString(action) ? (_a = this.actionMap) == null ? void 0 : _a[action] : action;
|
|
2532
|
-
warn(isString(action) && !fn, `[machine/exec-action] No implementation found for action: \`${action}\``);
|
|
2533
|
-
fn == null ? void 0 : fn(this.state.context, event, this.meta);
|
|
2534
|
-
}
|
|
2535
|
-
};
|
|
2536
|
-
this.executeActivities = (event, activities, state) => {
|
|
2537
|
-
var _a;
|
|
2538
|
-
for (const activity of activities) {
|
|
2539
|
-
const fn = isString(activity) ? (_a = this.activityMap) == null ? void 0 : _a[activity] : activity;
|
|
2540
|
-
if (!fn) {
|
|
2541
|
-
warn(`[machine/exec-activity] No implementation found for activity: \`${activity}\``);
|
|
2542
|
-
continue;
|
|
2543
|
-
}
|
|
2544
|
-
const cleanup = fn(this.state.context, event, this.meta);
|
|
2545
|
-
if (cleanup) {
|
|
2546
|
-
this.addActivityCleanup(state != null ? state : this.state.value, cleanup);
|
|
2547
|
-
}
|
|
2548
|
-
}
|
|
2549
|
-
};
|
|
2550
|
-
this.createEveryActivities = (every, callbackfn) => {
|
|
2551
|
-
if (!every)
|
|
2552
|
-
return;
|
|
2553
|
-
const event = toEvent("machine.every" /* Every */);
|
|
2554
|
-
if (isArray(every)) {
|
|
2555
|
-
const picked = toArray(every).find((t3) => {
|
|
2556
|
-
const determineDelay2 = determineDelayFn(t3.delay, this.delayMap);
|
|
2557
|
-
t3.delay = determineDelay2(this.contextSnapshot, event);
|
|
2558
|
-
const determineGuard = determineGuardFn(t3.guard, this.guardMap);
|
|
2559
|
-
const guard = determineGuard(this.contextSnapshot, event);
|
|
2560
|
-
return guard != null ? guard : t3.delay;
|
|
2561
|
-
});
|
|
2562
|
-
if (!picked)
|
|
2563
|
-
return;
|
|
2564
|
-
const determineDelay = determineDelayFn(picked.delay, this.delayMap);
|
|
2565
|
-
const delay3 = determineDelay(this.contextSnapshot, event);
|
|
2566
|
-
const activity = () => {
|
|
2567
|
-
const id = globalThis.setInterval(() => {
|
|
2568
|
-
this.executeActions(picked.actions, event);
|
|
2569
|
-
}, delay3);
|
|
2570
|
-
return () => {
|
|
2571
|
-
globalThis.clearInterval(id);
|
|
2572
|
-
};
|
|
2573
|
-
};
|
|
2574
|
-
callbackfn(activity);
|
|
2575
|
-
} else {
|
|
2576
|
-
for (const interval in every) {
|
|
2577
|
-
const actions = every == null ? void 0 : every[interval];
|
|
2578
|
-
const determineDelay = determineDelayFn(interval, this.delayMap);
|
|
2579
|
-
const delay3 = determineDelay(this.contextSnapshot, event);
|
|
2580
|
-
const activity = () => {
|
|
2581
|
-
const id = globalThis.setInterval(() => {
|
|
2582
|
-
this.executeActions(actions, event);
|
|
2583
|
-
}, delay3);
|
|
2584
|
-
return () => {
|
|
2585
|
-
globalThis.clearInterval(id);
|
|
2586
|
-
};
|
|
2587
|
-
};
|
|
2588
|
-
callbackfn(activity);
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
};
|
|
2592
|
-
this.setEvent = (event) => {
|
|
2593
|
-
this.state.event = (0, import_vanilla2.ref)(toEvent(event));
|
|
2594
|
-
};
|
|
2595
|
-
this.performExitEffects = (current, event) => {
|
|
2596
|
-
const currentState = this.state.value;
|
|
2597
|
-
const stateNode = current ? this.getStateNode(current) : void 0;
|
|
2598
|
-
this.stopActivities(currentState);
|
|
2599
|
-
const _exit = determineActionsFn(stateNode == null ? void 0 : stateNode.exit, this.guardMap)(this.contextSnapshot, event);
|
|
2600
|
-
const exitActions = toArray(_exit);
|
|
2601
|
-
const afterExitActions = this.delayedEvents.get(currentState);
|
|
2602
|
-
if (afterExitActions) {
|
|
2603
|
-
exitActions.push(...afterExitActions);
|
|
2604
|
-
}
|
|
2605
|
-
this.executeActions(exitActions, event);
|
|
2606
|
-
this.eventListeners.clear();
|
|
2607
|
-
};
|
|
2608
|
-
this.performEntryEffects = (next2, event) => {
|
|
2609
|
-
const stateNode = this.getStateNode(next2);
|
|
2610
|
-
const activities = toArray(stateNode == null ? void 0 : stateNode.activities);
|
|
2611
|
-
this.createEveryActivities(stateNode == null ? void 0 : stateNode.every, (activity) => {
|
|
2612
|
-
activities.unshift(activity);
|
|
2613
|
-
});
|
|
2614
|
-
if (activities.length > 0) {
|
|
2615
|
-
this.executeActivities(event, activities);
|
|
2616
|
-
}
|
|
2617
|
-
const _entry = determineActionsFn(stateNode == null ? void 0 : stateNode.entry, this.guardMap)(this.contextSnapshot, event);
|
|
2618
|
-
const entryActions = toArray(_entry);
|
|
2619
|
-
const afterActions = this.getDelayedEventActions(next2);
|
|
2620
|
-
if ((stateNode == null ? void 0 : stateNode.after) && afterActions) {
|
|
2621
|
-
this.delayedEvents.set(next2, afterActions == null ? void 0 : afterActions.exits);
|
|
2622
|
-
entryActions.push(...afterActions.entries);
|
|
2623
|
-
}
|
|
2624
|
-
this.executeActions(entryActions, event);
|
|
2625
|
-
if ((stateNode == null ? void 0 : stateNode.type) === "final") {
|
|
2626
|
-
this.state.done = true;
|
|
2627
|
-
this.doneListeners.forEach((listener) => {
|
|
2628
|
-
listener(this.stateSnapshot);
|
|
2629
|
-
});
|
|
2630
|
-
this.stop();
|
|
2631
|
-
}
|
|
2632
|
-
};
|
|
2633
|
-
this.performTransitionEffects = (transition, event) => {
|
|
2634
|
-
const t3 = this.determineTransition(transition, event);
|
|
2635
|
-
this.executeActions(t3 == null ? void 0 : t3.actions, event);
|
|
2636
|
-
};
|
|
2637
|
-
this.performStateChangeEffects = (current, next2, event) => {
|
|
2638
|
-
var _a, _b;
|
|
2639
|
-
this.setEvent(event);
|
|
2640
|
-
next2.target = (_b = (_a = next2.target) != null ? _a : this.state.value) != null ? _b : void 0;
|
|
2641
|
-
const ok = next2.target && next2.target !== this.state.value;
|
|
2642
|
-
if (ok) {
|
|
2643
|
-
this.performExitEffects(current, event);
|
|
2644
|
-
}
|
|
2645
|
-
this.performTransitionEffects(next2 == null ? void 0 : next2.transition, event);
|
|
2646
|
-
this.setState(next2.target);
|
|
2647
|
-
if (ok) {
|
|
2648
|
-
this.performEntryEffects(next2.target, event);
|
|
2649
|
-
}
|
|
2650
|
-
};
|
|
2651
|
-
this.determineTransition = (transition, event) => {
|
|
2652
|
-
const fn = determineTransitionFn(transition, this.guardMap);
|
|
2653
|
-
return fn == null ? void 0 : fn(this.contextSnapshot, event);
|
|
2654
|
-
};
|
|
2655
|
-
this.sendParent = (evt) => {
|
|
2656
|
-
var _a;
|
|
2657
|
-
if (!this.parent) {
|
|
2658
|
-
invariant("[machine/send-parent] Cannot send event to an unknown parent");
|
|
2659
|
-
}
|
|
2660
|
-
const event = toEvent(evt);
|
|
2661
|
-
(_a = this.parent) == null ? void 0 : _a.send(event);
|
|
2662
|
-
};
|
|
2663
|
-
this.send = (evt) => {
|
|
2664
|
-
const event = toEvent(evt);
|
|
2665
|
-
this.transition(this.state.value, event);
|
|
2666
|
-
};
|
|
2667
|
-
this.transition = (state, evt) => {
|
|
2668
|
-
var _a, _b, _c;
|
|
2669
|
-
const stateNode = isString(state) ? this.getStateNode(state) : state == null ? void 0 : state.stateNode;
|
|
2670
|
-
const event = toEvent(evt);
|
|
2671
|
-
if (!stateNode && !this.config.on) {
|
|
2672
|
-
const msg = this.status === "Stopped" /* Stopped */ ? "[machine/transition] Cannot transition a stopped machine" : "[machine/transition] State does not have a definition";
|
|
2673
|
-
warn(msg);
|
|
2674
|
-
return;
|
|
2675
|
-
}
|
|
2676
|
-
const transitionConfig = (_c = (_a = stateNode == null ? void 0 : stateNode.on) == null ? void 0 : _a[event.type]) != null ? _c : (_b = this.config.on) == null ? void 0 : _b[event.type];
|
|
2677
|
-
const transition = toTransition(transitionConfig, this.state.value);
|
|
2678
|
-
if (!transition)
|
|
2679
|
-
return;
|
|
2680
|
-
const info = this.getNextStateInfo(transition, event);
|
|
2681
|
-
this.performStateChangeEffects(this.state.value, info, event);
|
|
2682
|
-
return info.stateNode;
|
|
2683
|
-
};
|
|
2684
|
-
this.subscribe = (listener) => {
|
|
2685
|
-
this.stateListeners.add(listener);
|
|
2686
|
-
if (this.status === "Running" /* Running */) {
|
|
2687
|
-
listener(this.stateSnapshot);
|
|
2688
|
-
}
|
|
2689
|
-
return () => {
|
|
2690
|
-
this.stateListeners.delete(listener);
|
|
2691
|
-
};
|
|
2692
|
-
};
|
|
2693
|
-
this.onDone = (listener) => {
|
|
2694
|
-
this.doneListeners.add(listener);
|
|
2695
|
-
return this;
|
|
2696
|
-
};
|
|
2697
|
-
this.onTransition = (listener) => {
|
|
2698
|
-
this.stateListeners.add(listener);
|
|
2699
|
-
if (this.status === "Running" /* Running */) {
|
|
2700
|
-
listener(this.stateSnapshot);
|
|
2701
|
-
}
|
|
2702
|
-
return this;
|
|
2703
|
-
};
|
|
2704
|
-
this.onEvent = (listener) => {
|
|
2705
|
-
listener(this.state.event);
|
|
2706
|
-
this.eventListeners.add(listener);
|
|
2707
|
-
return this;
|
|
2708
|
-
};
|
|
2709
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2710
|
-
this.options = klona(options);
|
|
2711
|
-
this.id = (_a = config.id) != null ? _a : `machine-${uuid()}`;
|
|
2712
|
-
this.guardMap = (_c = (_b = this.options) == null ? void 0 : _b.guards) != null ? _c : {};
|
|
2713
|
-
this.actionMap = (_e = (_d = this.options) == null ? void 0 : _d.actions) != null ? _e : {};
|
|
2714
|
-
this.delayMap = (_g = (_f = this.options) == null ? void 0 : _f.delays) != null ? _g : {};
|
|
2715
|
-
this.activityMap = (_i = (_h = this.options) == null ? void 0 : _h.activities) != null ? _i : {};
|
|
2716
|
-
this.sync = (_k = (_j = this.options) == null ? void 0 : _j.sync) != null ? _k : false;
|
|
2717
|
-
this.state = createProxy(klona(config));
|
|
2718
|
-
this.setupComputed();
|
|
2719
|
-
const event = toEvent("machine.created" /* Created */);
|
|
2720
|
-
this.executeActions(config == null ? void 0 : config.created, event);
|
|
2721
|
-
}
|
|
2722
|
-
get stateSnapshot() {
|
|
2723
|
-
return cast((0, import_vanilla2.snapshot)(this.state));
|
|
2724
|
-
}
|
|
2725
|
-
get contextSnapshot() {
|
|
2726
|
-
return this.stateSnapshot.context;
|
|
2727
|
-
}
|
|
2728
|
-
get self() {
|
|
2729
|
-
const _self = this;
|
|
2730
|
-
return {
|
|
2731
|
-
id: this.id,
|
|
2732
|
-
send: this.send.bind(this),
|
|
2733
|
-
sendParent: this.sendParent.bind(this),
|
|
2734
|
-
sendChild: this.sendChild.bind(this),
|
|
2735
|
-
stop: this.stop.bind(this),
|
|
2736
|
-
stopChild: this.stopChild.bind(this),
|
|
2737
|
-
spawn: this.spawn.bind(this),
|
|
2738
|
-
get state() {
|
|
2739
|
-
return _self.stateSnapshot;
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
}
|
|
2743
|
-
get meta() {
|
|
2744
|
-
return {
|
|
2745
|
-
state: this.stateSnapshot,
|
|
2746
|
-
guards: this.guardMap,
|
|
2747
|
-
send: this.send.bind(this),
|
|
2748
|
-
listen: this.onEvent.bind(this),
|
|
2749
|
-
self: this.self,
|
|
2750
|
-
getState: () => this.stateSnapshot
|
|
2751
|
-
};
|
|
2752
|
-
}
|
|
2753
|
-
};
|
|
2754
|
-
var createMachine = (config, options) => new Machine(config, options);
|
|
2755
|
-
|
|
2756
|
-
// ../../../node_modules/aria-hidden/dist/es2015/index.js
|
|
2757
|
-
var getDefaultParent = function(originalTarget) {
|
|
2758
|
-
if (typeof document === "undefined") {
|
|
2759
|
-
return null;
|
|
2760
|
-
}
|
|
2761
|
-
var sampleTarget = Array.isArray(originalTarget) ? originalTarget[0] : originalTarget;
|
|
2762
|
-
return sampleTarget.ownerDocument.body;
|
|
2763
|
-
};
|
|
2764
|
-
var counterMap = /* @__PURE__ */ new WeakMap();
|
|
2765
|
-
var uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
2766
|
-
var markerMap = {};
|
|
2767
|
-
var lockCount = 0;
|
|
2768
|
-
var hideOthers = function(originalTarget, parentNode, markerName) {
|
|
2769
|
-
if (parentNode === void 0) {
|
|
2770
|
-
parentNode = getDefaultParent(originalTarget);
|
|
2771
|
-
}
|
|
2772
|
-
if (markerName === void 0) {
|
|
2773
|
-
markerName = "data-aria-hidden";
|
|
2774
|
-
}
|
|
2775
|
-
var targets = Array.isArray(originalTarget) ? originalTarget : [originalTarget];
|
|
2776
|
-
if (!markerMap[markerName]) {
|
|
2777
|
-
markerMap[markerName] = /* @__PURE__ */ new WeakMap();
|
|
2778
|
-
}
|
|
2779
|
-
var markerCounter = markerMap[markerName];
|
|
2780
|
-
var hiddenNodes = [];
|
|
2781
|
-
var elementsToKeep = /* @__PURE__ */ new Set();
|
|
2782
|
-
var keep = function(el) {
|
|
2783
|
-
if (!el || elementsToKeep.has(el)) {
|
|
2784
|
-
return;
|
|
2785
|
-
}
|
|
2786
|
-
elementsToKeep.add(el);
|
|
2787
|
-
keep(el.parentNode);
|
|
2788
|
-
};
|
|
2789
|
-
targets.forEach(keep);
|
|
2790
|
-
var deep = function(parent) {
|
|
2791
|
-
if (!parent || targets.indexOf(parent) >= 0) {
|
|
2792
|
-
return;
|
|
2793
|
-
}
|
|
2794
|
-
Array.prototype.forEach.call(parent.children, function(node) {
|
|
2795
|
-
if (elementsToKeep.has(node)) {
|
|
2796
|
-
deep(node);
|
|
2797
|
-
} else {
|
|
2798
|
-
var attr = node.getAttribute("aria-hidden");
|
|
2799
|
-
var alreadyHidden = attr !== null && attr !== "false";
|
|
2800
|
-
var counterValue = (counterMap.get(node) || 0) + 1;
|
|
2801
|
-
var markerValue = (markerCounter.get(node) || 0) + 1;
|
|
2802
|
-
counterMap.set(node, counterValue);
|
|
2803
|
-
markerCounter.set(node, markerValue);
|
|
2804
|
-
hiddenNodes.push(node);
|
|
2805
|
-
if (counterValue === 1 && alreadyHidden) {
|
|
2806
|
-
uncontrolledNodes.set(node, true);
|
|
2807
|
-
}
|
|
2808
|
-
if (markerValue === 1) {
|
|
2809
|
-
node.setAttribute(markerName, "true");
|
|
2810
|
-
}
|
|
2811
|
-
if (!alreadyHidden) {
|
|
2812
|
-
node.setAttribute("aria-hidden", "true");
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
});
|
|
2816
|
-
};
|
|
2817
|
-
deep(parentNode);
|
|
2818
|
-
elementsToKeep.clear();
|
|
2819
|
-
lockCount++;
|
|
2820
|
-
return function() {
|
|
2821
|
-
hiddenNodes.forEach(function(node) {
|
|
2822
|
-
var counterValue = counterMap.get(node) - 1;
|
|
2823
|
-
var markerValue = markerCounter.get(node) - 1;
|
|
2824
|
-
counterMap.set(node, counterValue);
|
|
2825
|
-
markerCounter.set(node, markerValue);
|
|
2826
|
-
if (!counterValue) {
|
|
2827
|
-
if (!uncontrolledNodes.has(node)) {
|
|
2828
|
-
node.removeAttribute("aria-hidden");
|
|
2829
|
-
}
|
|
2830
|
-
uncontrolledNodes.delete(node);
|
|
2831
|
-
}
|
|
2832
|
-
if (!markerValue) {
|
|
2833
|
-
node.removeAttribute(markerName);
|
|
2834
|
-
}
|
|
2835
|
-
});
|
|
2836
|
-
lockCount--;
|
|
2837
|
-
if (!lockCount) {
|
|
2838
|
-
counterMap = /* @__PURE__ */ new WeakMap();
|
|
2839
|
-
counterMap = /* @__PURE__ */ new WeakMap();
|
|
2840
|
-
uncontrolledNodes = /* @__PURE__ */ new WeakMap();
|
|
2841
|
-
markerMap = {};
|
|
2842
|
-
}
|
|
2843
|
-
};
|
|
2844
|
-
};
|
|
2845
|
-
|
|
2846
|
-
// ../../../node_modules/tabbable/dist/index.esm.js
|
|
2847
|
-
var candidateSelectors = ["input", "select", "textarea", "a[href]", "button", "[tabindex]", "audio[controls]", "video[controls]", '[contenteditable]:not([contenteditable="false"])', "details>summary:first-of-type", "details"];
|
|
2848
|
-
var candidateSelector = /* @__PURE__ */ candidateSelectors.join(",");
|
|
2849
|
-
var matches = typeof Element === "undefined" ? function() {
|
|
2850
|
-
} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
|
|
2851
|
-
var getCandidates = function getCandidates2(el, includeContainer, filter) {
|
|
2852
|
-
var candidates = Array.prototype.slice.apply(el.querySelectorAll(candidateSelector));
|
|
2853
|
-
if (includeContainer && matches.call(el, candidateSelector)) {
|
|
2854
|
-
candidates.unshift(el);
|
|
2855
|
-
}
|
|
2856
|
-
candidates = candidates.filter(filter);
|
|
2857
|
-
return candidates;
|
|
2858
|
-
};
|
|
2859
|
-
var isContentEditable = function isContentEditable2(node) {
|
|
2860
|
-
return node.contentEditable === "true";
|
|
2861
|
-
};
|
|
2862
|
-
var getTabindex = function getTabindex2(node) {
|
|
2863
|
-
var tabindexAttr = parseInt(node.getAttribute("tabindex"), 10);
|
|
2864
|
-
if (!isNaN(tabindexAttr)) {
|
|
2865
|
-
return tabindexAttr;
|
|
2866
|
-
}
|
|
2867
|
-
if (isContentEditable(node)) {
|
|
2868
|
-
return 0;
|
|
2869
|
-
}
|
|
2870
|
-
if ((node.nodeName === "AUDIO" || node.nodeName === "VIDEO" || node.nodeName === "DETAILS") && node.getAttribute("tabindex") === null) {
|
|
2871
|
-
return 0;
|
|
2872
|
-
}
|
|
2873
|
-
return node.tabIndex;
|
|
2874
|
-
};
|
|
2875
|
-
var sortOrderedTabbables = function sortOrderedTabbables2(a, b) {
|
|
2876
|
-
return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
|
|
2877
|
-
};
|
|
2878
|
-
var isInput = function isInput2(node) {
|
|
2879
|
-
return node.tagName === "INPUT";
|
|
2880
|
-
};
|
|
2881
|
-
var isHiddenInput = function isHiddenInput2(node) {
|
|
2882
|
-
return isInput(node) && node.type === "hidden";
|
|
2883
|
-
};
|
|
2884
|
-
var isDetailsWithSummary = function isDetailsWithSummary2(node) {
|
|
2885
|
-
var r2 = node.tagName === "DETAILS" && Array.prototype.slice.apply(node.children).some(function(child) {
|
|
2886
|
-
return child.tagName === "SUMMARY";
|
|
2887
|
-
});
|
|
2888
|
-
return r2;
|
|
2889
|
-
};
|
|
2890
|
-
var getCheckedRadio = function getCheckedRadio2(nodes, form) {
|
|
2891
|
-
for (var i = 0; i < nodes.length; i++) {
|
|
2892
|
-
if (nodes[i].checked && nodes[i].form === form) {
|
|
2893
|
-
return nodes[i];
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
};
|
|
2897
|
-
var isTabbableRadio = function isTabbableRadio2(node) {
|
|
2898
|
-
if (!node.name) {
|
|
2899
|
-
return true;
|
|
2900
|
-
}
|
|
2901
|
-
var radioScope = node.form || node.ownerDocument;
|
|
2902
|
-
var queryRadios = function queryRadios2(name) {
|
|
2903
|
-
return radioScope.querySelectorAll('input[type="radio"][name="' + name + '"]');
|
|
2904
|
-
};
|
|
2905
|
-
var radioSet;
|
|
2906
|
-
if (typeof window !== "undefined" && typeof window.CSS !== "undefined" && typeof window.CSS.escape === "function") {
|
|
2907
|
-
radioSet = queryRadios(window.CSS.escape(node.name));
|
|
2908
|
-
} else {
|
|
2909
|
-
try {
|
|
2910
|
-
radioSet = queryRadios(node.name);
|
|
2911
|
-
} catch (err) {
|
|
2912
|
-
console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s", err.message);
|
|
2913
|
-
return false;
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
var checked = getCheckedRadio(radioSet, node.form);
|
|
2917
|
-
return !checked || checked === node;
|
|
2918
|
-
};
|
|
2919
|
-
var isRadio = function isRadio2(node) {
|
|
2920
|
-
return isInput(node) && node.type === "radio";
|
|
2921
|
-
};
|
|
2922
|
-
var isNonTabbableRadio = function isNonTabbableRadio2(node) {
|
|
2923
|
-
return isRadio(node) && !isTabbableRadio(node);
|
|
2924
|
-
};
|
|
2925
|
-
var isHidden2 = function isHidden3(node, displayCheck) {
|
|
2926
|
-
if (getComputedStyle(node).visibility === "hidden") {
|
|
2927
|
-
return true;
|
|
2928
|
-
}
|
|
2929
|
-
var isDirectSummary = matches.call(node, "details>summary:first-of-type");
|
|
2930
|
-
var nodeUnderDetails = isDirectSummary ? node.parentElement : node;
|
|
2931
|
-
if (matches.call(nodeUnderDetails, "details:not([open]) *")) {
|
|
2932
|
-
return true;
|
|
2933
|
-
}
|
|
2934
|
-
if (!displayCheck || displayCheck === "full") {
|
|
2935
|
-
while (node) {
|
|
2936
|
-
if (getComputedStyle(node).display === "none") {
|
|
2937
|
-
return true;
|
|
2938
|
-
}
|
|
2939
|
-
node = node.parentElement;
|
|
2940
|
-
}
|
|
2941
|
-
} else if (displayCheck === "non-zero-area") {
|
|
2942
|
-
var _node$getBoundingClie = node.getBoundingClientRect(), width = _node$getBoundingClie.width, height = _node$getBoundingClie.height;
|
|
2943
|
-
return width === 0 && height === 0;
|
|
2944
|
-
}
|
|
2945
|
-
return false;
|
|
2946
|
-
};
|
|
2947
|
-
var isDisabledFromFieldset = function isDisabledFromFieldset2(node) {
|
|
2948
|
-
if (isInput(node) || node.tagName === "SELECT" || node.tagName === "TEXTAREA" || node.tagName === "BUTTON") {
|
|
2949
|
-
var parentNode = node.parentElement;
|
|
2950
|
-
while (parentNode) {
|
|
2951
|
-
if (parentNode.tagName === "FIELDSET" && parentNode.disabled) {
|
|
2952
|
-
for (var i = 0; i < parentNode.children.length; i++) {
|
|
2953
|
-
var child = parentNode.children.item(i);
|
|
2954
|
-
if (child.tagName === "LEGEND") {
|
|
2955
|
-
if (child.contains(node)) {
|
|
2956
|
-
return false;
|
|
2957
|
-
}
|
|
2958
|
-
return true;
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
return true;
|
|
2962
|
-
}
|
|
2963
|
-
parentNode = parentNode.parentElement;
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
|
-
return false;
|
|
2967
|
-
};
|
|
2968
|
-
var isNodeMatchingSelectorFocusable = function isNodeMatchingSelectorFocusable2(options, node) {
|
|
2969
|
-
if (node.disabled || isHiddenInput(node) || isHidden2(node, options.displayCheck) || isDetailsWithSummary(node) || isDisabledFromFieldset(node)) {
|
|
2970
|
-
return false;
|
|
2971
|
-
}
|
|
2972
|
-
return true;
|
|
2973
|
-
};
|
|
2974
|
-
var isNodeMatchingSelectorTabbable = function isNodeMatchingSelectorTabbable2(options, node) {
|
|
2975
|
-
if (!isNodeMatchingSelectorFocusable(options, node) || isNonTabbableRadio(node) || getTabindex(node) < 0) {
|
|
2976
|
-
return false;
|
|
2977
|
-
}
|
|
2978
|
-
return true;
|
|
2979
|
-
};
|
|
2980
|
-
var tabbable = function tabbable2(el, options) {
|
|
2981
|
-
options = options || {};
|
|
2982
|
-
var regularTabbables = [];
|
|
2983
|
-
var orderedTabbables = [];
|
|
2984
|
-
var candidates = getCandidates(el, options.includeContainer, isNodeMatchingSelectorTabbable.bind(null, options));
|
|
2985
|
-
candidates.forEach(function(candidate, i) {
|
|
2986
|
-
var candidateTabindex = getTabindex(candidate);
|
|
2987
|
-
if (candidateTabindex === 0) {
|
|
2988
|
-
regularTabbables.push(candidate);
|
|
2989
|
-
} else {
|
|
2990
|
-
orderedTabbables.push({
|
|
2991
|
-
documentOrder: i,
|
|
2992
|
-
tabIndex: candidateTabindex,
|
|
2993
|
-
node: candidate
|
|
2994
|
-
});
|
|
2995
|
-
}
|
|
2996
|
-
});
|
|
2997
|
-
var tabbableNodes = orderedTabbables.sort(sortOrderedTabbables).map(function(a) {
|
|
2998
|
-
return a.node;
|
|
2999
|
-
}).concat(regularTabbables);
|
|
3000
|
-
return tabbableNodes;
|
|
3001
|
-
};
|
|
3002
|
-
var focusableCandidateSelector = /* @__PURE__ */ candidateSelectors.concat("iframe").join(",");
|
|
3003
|
-
var isFocusable2 = function isFocusable3(node, options) {
|
|
3004
|
-
options = options || {};
|
|
3005
|
-
if (!node) {
|
|
3006
|
-
throw new Error("No node provided");
|
|
3007
|
-
}
|
|
3008
|
-
if (matches.call(node, focusableCandidateSelector) === false) {
|
|
3009
|
-
return false;
|
|
3010
|
-
}
|
|
3011
|
-
return isNodeMatchingSelectorFocusable(options, node);
|
|
3012
|
-
};
|
|
3013
|
-
|
|
3014
|
-
// ../../../node_modules/focus-trap/dist/focus-trap.esm.js
|
|
3015
|
-
function ownKeys(object, enumerableOnly) {
|
|
3016
|
-
var keys = Object.keys(object);
|
|
3017
|
-
if (Object.getOwnPropertySymbols) {
|
|
3018
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
3019
|
-
if (enumerableOnly) {
|
|
3020
|
-
symbols = symbols.filter(function(sym) {
|
|
3021
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
3022
|
-
});
|
|
3023
|
-
}
|
|
3024
|
-
keys.push.apply(keys, symbols);
|
|
3025
|
-
}
|
|
3026
|
-
return keys;
|
|
3027
|
-
}
|
|
3028
|
-
function _objectSpread2(target) {
|
|
3029
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
3030
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
3031
|
-
if (i % 2) {
|
|
3032
|
-
ownKeys(Object(source), true).forEach(function(key) {
|
|
3033
|
-
_defineProperty(target, key, source[key]);
|
|
3034
|
-
});
|
|
3035
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
3036
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
3037
|
-
} else {
|
|
3038
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
3039
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
3040
|
-
});
|
|
3041
|
-
}
|
|
3042
|
-
}
|
|
3043
|
-
return target;
|
|
3044
|
-
}
|
|
3045
|
-
function _defineProperty(obj, key, value) {
|
|
3046
|
-
if (key in obj) {
|
|
3047
|
-
Object.defineProperty(obj, key, {
|
|
3048
|
-
value,
|
|
3049
|
-
enumerable: true,
|
|
3050
|
-
configurable: true,
|
|
3051
|
-
writable: true
|
|
3052
|
-
});
|
|
3053
|
-
} else {
|
|
3054
|
-
obj[key] = value;
|
|
3055
|
-
}
|
|
3056
|
-
return obj;
|
|
3057
|
-
}
|
|
3058
|
-
var activeFocusTraps = function() {
|
|
3059
|
-
var trapQueue = [];
|
|
3060
|
-
return {
|
|
3061
|
-
activateTrap: function activateTrap(trap) {
|
|
3062
|
-
if (trapQueue.length > 0) {
|
|
3063
|
-
var activeTrap = trapQueue[trapQueue.length - 1];
|
|
3064
|
-
if (activeTrap !== trap) {
|
|
3065
|
-
activeTrap.pause();
|
|
3066
|
-
}
|
|
3067
|
-
}
|
|
3068
|
-
var trapIndex = trapQueue.indexOf(trap);
|
|
3069
|
-
if (trapIndex === -1) {
|
|
3070
|
-
trapQueue.push(trap);
|
|
3071
|
-
} else {
|
|
3072
|
-
trapQueue.splice(trapIndex, 1);
|
|
3073
|
-
trapQueue.push(trap);
|
|
3074
|
-
}
|
|
3075
|
-
},
|
|
3076
|
-
deactivateTrap: function deactivateTrap(trap) {
|
|
3077
|
-
var trapIndex = trapQueue.indexOf(trap);
|
|
3078
|
-
if (trapIndex !== -1) {
|
|
3079
|
-
trapQueue.splice(trapIndex, 1);
|
|
3080
|
-
}
|
|
3081
|
-
if (trapQueue.length > 0) {
|
|
3082
|
-
trapQueue[trapQueue.length - 1].unpause();
|
|
3083
|
-
}
|
|
3084
|
-
}
|
|
3085
|
-
};
|
|
3086
|
-
}();
|
|
3087
|
-
var isSelectableInput = function isSelectableInput2(node) {
|
|
3088
|
-
return node.tagName && node.tagName.toLowerCase() === "input" && typeof node.select === "function";
|
|
3089
|
-
};
|
|
3090
|
-
var isEscapeEvent = function isEscapeEvent2(e2) {
|
|
3091
|
-
return e2.key === "Escape" || e2.key === "Esc" || e2.keyCode === 27;
|
|
3092
|
-
};
|
|
3093
|
-
var isTabEvent = function isTabEvent2(e2) {
|
|
3094
|
-
return e2.key === "Tab" || e2.keyCode === 9;
|
|
3095
|
-
};
|
|
3096
|
-
var delay = function delay2(fn) {
|
|
3097
|
-
return setTimeout(fn, 0);
|
|
3098
|
-
};
|
|
3099
|
-
var findIndex = function findIndex2(arr, fn) {
|
|
3100
|
-
var idx = -1;
|
|
3101
|
-
arr.every(function(value, i) {
|
|
3102
|
-
if (fn(value)) {
|
|
3103
|
-
idx = i;
|
|
3104
|
-
return false;
|
|
3105
|
-
}
|
|
3106
|
-
return true;
|
|
3107
|
-
});
|
|
3108
|
-
return idx;
|
|
3109
|
-
};
|
|
3110
|
-
var valueOrHandler = function valueOrHandler2(value) {
|
|
3111
|
-
for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
3112
|
-
params[_key - 1] = arguments[_key];
|
|
3113
|
-
}
|
|
3114
|
-
return typeof value === "function" ? value.apply(void 0, params) : value;
|
|
3115
|
-
};
|
|
3116
|
-
var getActualTarget = function getActualTarget2(event) {
|
|
3117
|
-
return event.target.shadowRoot && typeof event.composedPath === "function" ? event.composedPath()[0] : event.target;
|
|
3118
|
-
};
|
|
3119
|
-
var createFocusTrap = function createFocusTrap2(elements, userOptions) {
|
|
3120
|
-
var doc = (userOptions === null || userOptions === void 0 ? void 0 : userOptions.document) || document;
|
|
3121
|
-
var config = _objectSpread2({
|
|
3122
|
-
returnFocusOnDeactivate: true,
|
|
3123
|
-
escapeDeactivates: true,
|
|
3124
|
-
delayInitialFocus: true
|
|
3125
|
-
}, userOptions);
|
|
3126
|
-
var state = {
|
|
3127
|
-
containers: [],
|
|
3128
|
-
tabbableGroups: [],
|
|
3129
|
-
nodeFocusedBeforeActivation: null,
|
|
3130
|
-
mostRecentlyFocusedNode: null,
|
|
3131
|
-
active: false,
|
|
3132
|
-
paused: false,
|
|
3133
|
-
delayInitialFocusTimer: void 0
|
|
3134
|
-
};
|
|
3135
|
-
var trap;
|
|
3136
|
-
var getOption = function getOption2(configOverrideOptions, optionName, configOptionName) {
|
|
3137
|
-
return configOverrideOptions && configOverrideOptions[optionName] !== void 0 ? configOverrideOptions[optionName] : config[configOptionName || optionName];
|
|
3138
|
-
};
|
|
3139
|
-
var containersContain = function containersContain2(element) {
|
|
3140
|
-
return !!(element && state.containers.some(function(container) {
|
|
3141
|
-
return container.contains(element);
|
|
3142
|
-
}));
|
|
3143
|
-
};
|
|
3144
|
-
var getNodeForOption = function getNodeForOption2(optionName) {
|
|
3145
|
-
var optionValue = config[optionName];
|
|
3146
|
-
if (typeof optionValue === "function") {
|
|
3147
|
-
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
3148
|
-
params[_key2 - 1] = arguments[_key2];
|
|
3149
|
-
}
|
|
3150
|
-
optionValue = optionValue.apply(void 0, params);
|
|
3151
|
-
}
|
|
3152
|
-
if (!optionValue) {
|
|
3153
|
-
if (optionValue === void 0 || optionValue === false) {
|
|
3154
|
-
return optionValue;
|
|
3155
|
-
}
|
|
3156
|
-
throw new Error("`".concat(optionName, "` was specified but was not a node, or did not return a node"));
|
|
3157
|
-
}
|
|
3158
|
-
var node = optionValue;
|
|
3159
|
-
if (typeof optionValue === "string") {
|
|
3160
|
-
node = doc.querySelector(optionValue);
|
|
3161
|
-
if (!node) {
|
|
3162
|
-
throw new Error("`".concat(optionName, "` as selector refers to no known node"));
|
|
3163
|
-
}
|
|
3164
|
-
}
|
|
3165
|
-
return node;
|
|
3166
|
-
};
|
|
3167
|
-
var getInitialFocusNode = function getInitialFocusNode2() {
|
|
3168
|
-
var node = getNodeForOption("initialFocus");
|
|
3169
|
-
if (node === false) {
|
|
3170
|
-
return false;
|
|
3171
|
-
}
|
|
3172
|
-
if (node === void 0) {
|
|
3173
|
-
if (containersContain(doc.activeElement)) {
|
|
3174
|
-
node = doc.activeElement;
|
|
3175
|
-
} else {
|
|
3176
|
-
var firstTabbableGroup = state.tabbableGroups[0];
|
|
3177
|
-
var firstTabbableNode = firstTabbableGroup && firstTabbableGroup.firstTabbableNode;
|
|
3178
|
-
node = firstTabbableNode || getNodeForOption("fallbackFocus");
|
|
3179
|
-
}
|
|
3180
|
-
}
|
|
3181
|
-
if (!node) {
|
|
3182
|
-
throw new Error("Your focus-trap needs to have at least one focusable element");
|
|
3183
|
-
}
|
|
3184
|
-
return node;
|
|
3185
|
-
};
|
|
3186
|
-
var updateTabbableNodes = function updateTabbableNodes2() {
|
|
3187
|
-
state.tabbableGroups = state.containers.map(function(container) {
|
|
3188
|
-
var tabbableNodes = tabbable(container);
|
|
3189
|
-
if (tabbableNodes.length > 0) {
|
|
3190
|
-
return {
|
|
3191
|
-
container,
|
|
3192
|
-
firstTabbableNode: tabbableNodes[0],
|
|
3193
|
-
lastTabbableNode: tabbableNodes[tabbableNodes.length - 1]
|
|
3194
|
-
};
|
|
3195
|
-
}
|
|
3196
|
-
return void 0;
|
|
3197
|
-
}).filter(function(group) {
|
|
3198
|
-
return !!group;
|
|
3199
|
-
});
|
|
3200
|
-
if (state.tabbableGroups.length <= 0 && !getNodeForOption("fallbackFocus")) {
|
|
3201
|
-
throw new Error("Your focus-trap must have at least one container with at least one tabbable node in it at all times");
|
|
3202
|
-
}
|
|
3203
|
-
};
|
|
3204
|
-
var tryFocus = function tryFocus2(node) {
|
|
3205
|
-
if (node === false) {
|
|
3206
|
-
return;
|
|
3207
|
-
}
|
|
3208
|
-
if (node === doc.activeElement) {
|
|
3209
|
-
return;
|
|
3210
|
-
}
|
|
3211
|
-
if (!node || !node.focus) {
|
|
3212
|
-
tryFocus2(getInitialFocusNode());
|
|
3213
|
-
return;
|
|
3214
|
-
}
|
|
3215
|
-
node.focus({
|
|
3216
|
-
preventScroll: !!config.preventScroll
|
|
3217
|
-
});
|
|
3218
|
-
state.mostRecentlyFocusedNode = node;
|
|
3219
|
-
if (isSelectableInput(node)) {
|
|
3220
|
-
node.select();
|
|
3221
|
-
}
|
|
3222
|
-
};
|
|
3223
|
-
var getReturnFocusNode = function getReturnFocusNode2(previousActiveElement) {
|
|
3224
|
-
var node = getNodeForOption("setReturnFocus", previousActiveElement);
|
|
3225
|
-
return node ? node : node === false ? false : previousActiveElement;
|
|
3226
|
-
};
|
|
3227
|
-
var checkPointerDown = function checkPointerDown2(e2) {
|
|
3228
|
-
var target = getActualTarget(e2);
|
|
3229
|
-
if (containersContain(target)) {
|
|
3230
|
-
return;
|
|
3231
|
-
}
|
|
3232
|
-
if (valueOrHandler(config.clickOutsideDeactivates, e2)) {
|
|
3233
|
-
trap.deactivate({
|
|
3234
|
-
returnFocus: config.returnFocusOnDeactivate && !isFocusable2(target)
|
|
3235
|
-
});
|
|
3236
|
-
return;
|
|
3237
|
-
}
|
|
3238
|
-
if (valueOrHandler(config.allowOutsideClick, e2)) {
|
|
3239
|
-
return;
|
|
3240
|
-
}
|
|
3241
|
-
e2.preventDefault();
|
|
3242
|
-
};
|
|
3243
|
-
var checkFocusIn = function checkFocusIn2(e2) {
|
|
3244
|
-
var target = getActualTarget(e2);
|
|
3245
|
-
var targetContained = containersContain(target);
|
|
3246
|
-
if (targetContained || target instanceof Document) {
|
|
3247
|
-
if (targetContained) {
|
|
3248
|
-
state.mostRecentlyFocusedNode = target;
|
|
3249
|
-
}
|
|
3250
|
-
} else {
|
|
3251
|
-
e2.stopImmediatePropagation();
|
|
3252
|
-
tryFocus(state.mostRecentlyFocusedNode || getInitialFocusNode());
|
|
3253
|
-
}
|
|
3254
|
-
};
|
|
3255
|
-
var checkTab = function checkTab2(e2) {
|
|
3256
|
-
var target = getActualTarget(e2);
|
|
3257
|
-
updateTabbableNodes();
|
|
3258
|
-
var destinationNode = null;
|
|
3259
|
-
if (state.tabbableGroups.length > 0) {
|
|
3260
|
-
var containerIndex = findIndex(state.tabbableGroups, function(_ref) {
|
|
3261
|
-
var container = _ref.container;
|
|
3262
|
-
return container.contains(target);
|
|
3263
|
-
});
|
|
3264
|
-
if (containerIndex < 0) {
|
|
3265
|
-
if (e2.shiftKey) {
|
|
3266
|
-
destinationNode = state.tabbableGroups[state.tabbableGroups.length - 1].lastTabbableNode;
|
|
3267
|
-
} else {
|
|
3268
|
-
destinationNode = state.tabbableGroups[0].firstTabbableNode;
|
|
3269
|
-
}
|
|
3270
|
-
} else if (e2.shiftKey) {
|
|
3271
|
-
var startOfGroupIndex = findIndex(state.tabbableGroups, function(_ref2) {
|
|
3272
|
-
var firstTabbableNode = _ref2.firstTabbableNode;
|
|
3273
|
-
return target === firstTabbableNode;
|
|
3274
|
-
});
|
|
3275
|
-
if (startOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
|
|
3276
|
-
startOfGroupIndex = containerIndex;
|
|
3277
|
-
}
|
|
3278
|
-
if (startOfGroupIndex >= 0) {
|
|
3279
|
-
var destinationGroupIndex = startOfGroupIndex === 0 ? state.tabbableGroups.length - 1 : startOfGroupIndex - 1;
|
|
3280
|
-
var destinationGroup = state.tabbableGroups[destinationGroupIndex];
|
|
3281
|
-
destinationNode = destinationGroup.lastTabbableNode;
|
|
3282
|
-
}
|
|
3283
|
-
} else {
|
|
3284
|
-
var lastOfGroupIndex = findIndex(state.tabbableGroups, function(_ref3) {
|
|
3285
|
-
var lastTabbableNode = _ref3.lastTabbableNode;
|
|
3286
|
-
return target === lastTabbableNode;
|
|
3287
|
-
});
|
|
3288
|
-
if (lastOfGroupIndex < 0 && state.tabbableGroups[containerIndex].container === target) {
|
|
3289
|
-
lastOfGroupIndex = containerIndex;
|
|
3290
|
-
}
|
|
3291
|
-
if (lastOfGroupIndex >= 0) {
|
|
3292
|
-
var _destinationGroupIndex = lastOfGroupIndex === state.tabbableGroups.length - 1 ? 0 : lastOfGroupIndex + 1;
|
|
3293
|
-
var _destinationGroup = state.tabbableGroups[_destinationGroupIndex];
|
|
3294
|
-
destinationNode = _destinationGroup.firstTabbableNode;
|
|
3295
|
-
}
|
|
3296
|
-
}
|
|
3297
|
-
} else {
|
|
3298
|
-
destinationNode = getNodeForOption("fallbackFocus");
|
|
3299
|
-
}
|
|
3300
|
-
if (destinationNode) {
|
|
3301
|
-
e2.preventDefault();
|
|
3302
|
-
tryFocus(destinationNode);
|
|
3303
|
-
}
|
|
3304
|
-
};
|
|
3305
|
-
var checkKey = function checkKey2(e2) {
|
|
3306
|
-
if (isEscapeEvent(e2) && valueOrHandler(config.escapeDeactivates, e2) !== false) {
|
|
3307
|
-
e2.preventDefault();
|
|
3308
|
-
trap.deactivate();
|
|
3309
|
-
return;
|
|
3310
|
-
}
|
|
3311
|
-
if (isTabEvent(e2)) {
|
|
3312
|
-
checkTab(e2);
|
|
3313
|
-
return;
|
|
3314
|
-
}
|
|
3315
|
-
};
|
|
3316
|
-
var checkClick = function checkClick2(e2) {
|
|
3317
|
-
if (valueOrHandler(config.clickOutsideDeactivates, e2)) {
|
|
3318
|
-
return;
|
|
3319
|
-
}
|
|
3320
|
-
var target = getActualTarget(e2);
|
|
3321
|
-
if (containersContain(target)) {
|
|
3322
|
-
return;
|
|
3323
|
-
}
|
|
3324
|
-
if (valueOrHandler(config.allowOutsideClick, e2)) {
|
|
3325
|
-
return;
|
|
3326
|
-
}
|
|
3327
|
-
e2.preventDefault();
|
|
3328
|
-
e2.stopImmediatePropagation();
|
|
3329
|
-
};
|
|
3330
|
-
var addListeners = function addListeners2() {
|
|
3331
|
-
if (!state.active) {
|
|
3332
|
-
return;
|
|
3333
|
-
}
|
|
3334
|
-
activeFocusTraps.activateTrap(trap);
|
|
3335
|
-
state.delayInitialFocusTimer = config.delayInitialFocus ? delay(function() {
|
|
3336
|
-
tryFocus(getInitialFocusNode());
|
|
3337
|
-
}) : tryFocus(getInitialFocusNode());
|
|
3338
|
-
doc.addEventListener("focusin", checkFocusIn, true);
|
|
3339
|
-
doc.addEventListener("mousedown", checkPointerDown, {
|
|
3340
|
-
capture: true,
|
|
3341
|
-
passive: false
|
|
3342
|
-
});
|
|
3343
|
-
doc.addEventListener("touchstart", checkPointerDown, {
|
|
3344
|
-
capture: true,
|
|
3345
|
-
passive: false
|
|
3346
|
-
});
|
|
3347
|
-
doc.addEventListener("click", checkClick, {
|
|
3348
|
-
capture: true,
|
|
3349
|
-
passive: false
|
|
3350
|
-
});
|
|
3351
|
-
doc.addEventListener("keydown", checkKey, {
|
|
3352
|
-
capture: true,
|
|
3353
|
-
passive: false
|
|
3354
|
-
});
|
|
3355
|
-
return trap;
|
|
3356
|
-
};
|
|
3357
|
-
var removeListeners = function removeListeners2() {
|
|
3358
|
-
if (!state.active) {
|
|
3359
|
-
return;
|
|
3360
|
-
}
|
|
3361
|
-
doc.removeEventListener("focusin", checkFocusIn, true);
|
|
3362
|
-
doc.removeEventListener("mousedown", checkPointerDown, true);
|
|
3363
|
-
doc.removeEventListener("touchstart", checkPointerDown, true);
|
|
3364
|
-
doc.removeEventListener("click", checkClick, true);
|
|
3365
|
-
doc.removeEventListener("keydown", checkKey, true);
|
|
3366
|
-
return trap;
|
|
3367
|
-
};
|
|
3368
|
-
trap = {
|
|
3369
|
-
activate: function activate(activateOptions) {
|
|
3370
|
-
if (state.active) {
|
|
3371
|
-
return this;
|
|
3372
|
-
}
|
|
3373
|
-
var onActivate = getOption(activateOptions, "onActivate");
|
|
3374
|
-
var onPostActivate = getOption(activateOptions, "onPostActivate");
|
|
3375
|
-
var checkCanFocusTrap = getOption(activateOptions, "checkCanFocusTrap");
|
|
3376
|
-
if (!checkCanFocusTrap) {
|
|
3377
|
-
updateTabbableNodes();
|
|
3378
|
-
}
|
|
3379
|
-
state.active = true;
|
|
3380
|
-
state.paused = false;
|
|
3381
|
-
state.nodeFocusedBeforeActivation = doc.activeElement;
|
|
3382
|
-
if (onActivate) {
|
|
3383
|
-
onActivate();
|
|
3384
|
-
}
|
|
3385
|
-
var finishActivation = function finishActivation2() {
|
|
3386
|
-
if (checkCanFocusTrap) {
|
|
3387
|
-
updateTabbableNodes();
|
|
3388
|
-
}
|
|
3389
|
-
addListeners();
|
|
3390
|
-
if (onPostActivate) {
|
|
3391
|
-
onPostActivate();
|
|
3392
|
-
}
|
|
3393
|
-
};
|
|
3394
|
-
if (checkCanFocusTrap) {
|
|
3395
|
-
checkCanFocusTrap(state.containers.concat()).then(finishActivation, finishActivation);
|
|
3396
|
-
return this;
|
|
3397
|
-
}
|
|
3398
|
-
finishActivation();
|
|
3399
|
-
return this;
|
|
3400
|
-
},
|
|
3401
|
-
deactivate: function deactivate(deactivateOptions) {
|
|
3402
|
-
if (!state.active) {
|
|
3403
|
-
return this;
|
|
3404
|
-
}
|
|
3405
|
-
clearTimeout(state.delayInitialFocusTimer);
|
|
3406
|
-
state.delayInitialFocusTimer = void 0;
|
|
3407
|
-
removeListeners();
|
|
3408
|
-
state.active = false;
|
|
3409
|
-
state.paused = false;
|
|
3410
|
-
activeFocusTraps.deactivateTrap(trap);
|
|
3411
|
-
var onDeactivate = getOption(deactivateOptions, "onDeactivate");
|
|
3412
|
-
var onPostDeactivate = getOption(deactivateOptions, "onPostDeactivate");
|
|
3413
|
-
var checkCanReturnFocus = getOption(deactivateOptions, "checkCanReturnFocus");
|
|
3414
|
-
if (onDeactivate) {
|
|
3415
|
-
onDeactivate();
|
|
3416
|
-
}
|
|
3417
|
-
var returnFocus = getOption(deactivateOptions, "returnFocus", "returnFocusOnDeactivate");
|
|
3418
|
-
var finishDeactivation = function finishDeactivation2() {
|
|
3419
|
-
delay(function() {
|
|
3420
|
-
if (returnFocus) {
|
|
3421
|
-
tryFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation));
|
|
3422
|
-
}
|
|
3423
|
-
if (onPostDeactivate) {
|
|
3424
|
-
onPostDeactivate();
|
|
3425
|
-
}
|
|
3426
|
-
});
|
|
3427
|
-
};
|
|
3428
|
-
if (returnFocus && checkCanReturnFocus) {
|
|
3429
|
-
checkCanReturnFocus(getReturnFocusNode(state.nodeFocusedBeforeActivation)).then(finishDeactivation, finishDeactivation);
|
|
3430
|
-
return this;
|
|
3431
|
-
}
|
|
3432
|
-
finishDeactivation();
|
|
3433
|
-
return this;
|
|
3434
|
-
},
|
|
3435
|
-
pause: function pause() {
|
|
3436
|
-
if (state.paused || !state.active) {
|
|
3437
|
-
return this;
|
|
3438
|
-
}
|
|
3439
|
-
state.paused = true;
|
|
3440
|
-
removeListeners();
|
|
3441
|
-
return this;
|
|
3442
|
-
},
|
|
3443
|
-
unpause: function unpause() {
|
|
3444
|
-
if (!state.paused || !state.active) {
|
|
3445
|
-
return this;
|
|
3446
|
-
}
|
|
3447
|
-
state.paused = false;
|
|
3448
|
-
updateTabbableNodes();
|
|
3449
|
-
addListeners();
|
|
3450
|
-
return this;
|
|
3451
|
-
},
|
|
3452
|
-
updateContainerElements: function updateContainerElements(containerElements) {
|
|
3453
|
-
var elementsAsArray = [].concat(containerElements).filter(Boolean);
|
|
3454
|
-
state.containers = elementsAsArray.map(function(element) {
|
|
3455
|
-
return typeof element === "string" ? doc.querySelector(element) : element;
|
|
3456
|
-
});
|
|
3457
|
-
if (state.active) {
|
|
3458
|
-
updateTabbableNodes();
|
|
3459
|
-
}
|
|
3460
|
-
return this;
|
|
3461
|
-
}
|
|
3462
|
-
};
|
|
3463
|
-
trap.updateContainerElements(elements);
|
|
3464
|
-
return trap;
|
|
3465
|
-
};
|
|
3466
|
-
|
|
3467
724
|
// src/popover.machine.ts
|
|
3468
|
-
var
|
|
3469
|
-
var
|
|
725
|
+
var import_core = require("@zag-js/core");
|
|
726
|
+
var import_popper2 = require("@zag-js/popper");
|
|
727
|
+
var import_aria_hidden = require("aria-hidden");
|
|
728
|
+
var import_focus_trap = require("focus-trap");
|
|
729
|
+
var { and, or } = import_core.guards;
|
|
730
|
+
var machine = (0, import_core.createMachine)({
|
|
3470
731
|
id: "popover",
|
|
3471
732
|
initial: "unknown",
|
|
3472
733
|
context: {
|
|
@@ -3509,7 +770,7 @@ var machine = createMachine({
|
|
|
3509
770
|
"disableOutsidePointerEvents",
|
|
3510
771
|
"computePlacement"
|
|
3511
772
|
],
|
|
3512
|
-
entry: choose([
|
|
773
|
+
entry: (0, import_core.choose)([
|
|
3513
774
|
{
|
|
3514
775
|
guard: "autoFocus",
|
|
3515
776
|
actions: ["setInitialFocus", "invokeOnOpen"]
|
|
@@ -3531,18 +792,18 @@ var machine = createMachine({
|
|
|
3531
792
|
actions: "focusTrigger"
|
|
3532
793
|
},
|
|
3533
794
|
TAB: {
|
|
3534
|
-
guard:
|
|
795
|
+
guard: and("isLastTabbableElement", "closeOnBlur", "portalled"),
|
|
3535
796
|
target: "closed",
|
|
3536
797
|
actions: "focusNextTabbableElementAfterTrigger"
|
|
3537
798
|
},
|
|
3538
799
|
SHIFT_TAB: {
|
|
3539
|
-
guard:
|
|
800
|
+
guard: and(or("isFirstTabbableElement", "isContentFocused"), "closeOnBlur", "portalled"),
|
|
3540
801
|
target: "closed",
|
|
3541
802
|
actions: "focusTrigger"
|
|
3542
803
|
},
|
|
3543
804
|
INTERACT_OUTSIDE: [
|
|
3544
805
|
{
|
|
3545
|
-
guard:
|
|
806
|
+
guard: and("closeOnBlur", "isRelatedTargetFocusable"),
|
|
3546
807
|
target: "closed"
|
|
3547
808
|
},
|
|
3548
809
|
{
|
|
@@ -3559,7 +820,7 @@ var machine = createMachine({
|
|
|
3559
820
|
computePlacement(ctx) {
|
|
3560
821
|
ctx.currentPlacement = ctx.positioning.placement;
|
|
3561
822
|
const anchorEl = ctx.isAnchorRendered ? dom.getAnchorEl(ctx) : dom.getTriggerEl(ctx);
|
|
3562
|
-
return getPlacement(anchorEl, dom.getPositionerEl(ctx), __spreadProps(__spreadValues({}, ctx.positioning), {
|
|
823
|
+
return (0, import_popper2.getPlacement)(anchorEl, dom.getPositionerEl(ctx), __spreadProps(__spreadValues({}, ctx.positioning), {
|
|
3563
824
|
onComplete(data) {
|
|
3564
825
|
ctx.currentPlacement = data.placement;
|
|
3565
826
|
ctx.isPlacementComplete = true;
|
|
@@ -3572,7 +833,7 @@ var machine = createMachine({
|
|
|
3572
833
|
},
|
|
3573
834
|
trackPointerDown(ctx) {
|
|
3574
835
|
return trackPointerDown(dom.getDoc(ctx), (el) => {
|
|
3575
|
-
ctx.pointerdownNode = (0,
|
|
836
|
+
ctx.pointerdownNode = (0, import_core.ref)(el);
|
|
3576
837
|
});
|
|
3577
838
|
},
|
|
3578
839
|
disableOutsidePointerEvents(ctx) {
|
|
@@ -3591,7 +852,7 @@ var machine = createMachine({
|
|
|
3591
852
|
if (!el)
|
|
3592
853
|
return;
|
|
3593
854
|
try {
|
|
3594
|
-
unhide = hideOthers(el);
|
|
855
|
+
unhide = (0, import_aria_hidden.hideOthers)(el);
|
|
3595
856
|
} catch (e2) {
|
|
3596
857
|
}
|
|
3597
858
|
});
|
|
@@ -3612,13 +873,13 @@ var machine = createMachine({
|
|
|
3612
873
|
const el = dom.getContentEl(ctx);
|
|
3613
874
|
if (!el)
|
|
3614
875
|
return;
|
|
3615
|
-
trap = createFocusTrap(el, {
|
|
876
|
+
trap = (0, import_focus_trap.createFocusTrap)(el, {
|
|
3616
877
|
escapeDeactivates: false,
|
|
3617
878
|
allowOutsideClick: true,
|
|
3618
879
|
returnFocusOnDeactivate: true,
|
|
3619
880
|
document: dom.getDoc(ctx),
|
|
3620
881
|
fallbackFocus: el,
|
|
3621
|
-
initialFocus:
|
|
882
|
+
initialFocus: runIfFn2(ctx.initialFocusEl)
|
|
3622
883
|
});
|
|
3623
884
|
try {
|
|
3624
885
|
trap.activate();
|
|
@@ -3649,7 +910,7 @@ var machine = createMachine({
|
|
|
3649
910
|
},
|
|
3650
911
|
setupDocument(ctx, evt) {
|
|
3651
912
|
if (evt.doc)
|
|
3652
|
-
ctx.doc = (0,
|
|
913
|
+
ctx.doc = (0, import_core.ref)(evt.doc);
|
|
3653
914
|
ctx.uid = evt.id;
|
|
3654
915
|
},
|
|
3655
916
|
clearPointerDown(ctx) {
|
|
@@ -3707,12 +968,4 @@ var machine = createMachine({
|
|
|
3707
968
|
}
|
|
3708
969
|
}
|
|
3709
970
|
});
|
|
3710
|
-
/*!
|
|
3711
|
-
* focus-trap 6.7.1
|
|
3712
|
-
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
|
3713
|
-
*/
|
|
3714
|
-
/*!
|
|
3715
|
-
* tabbable 5.2.1
|
|
3716
|
-
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
|
3717
|
-
*/
|
|
3718
971
|
//# sourceMappingURL=index.js.map
|