inclusive-elements 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +367 -0
- package/README.md +24 -20
- package/dist/index.js +1003 -0
- package/dist/types/alerts/alerts.d.ts +14 -1
- package/dist/types/index.d.ts +1 -4
- package/dist/types/menu/menu.d.ts +33 -3
- package/dist/types/tabs/tabs.d.ts +10 -3
- package/dist/types/toolbar/toolbar.d.ts +5 -2
- package/dist/types/tooltip/tooltip.d.ts +26 -18
- package/dist/types/utils.d.ts +15 -4
- package/package.json +21 -13
- package/src/accordion/README.md +36 -0
- package/src/alerts/README.md +133 -0
- package/src/dialog/README.md +57 -0
- package/src/disclosure/README.md +28 -0
- package/src/menu/README.md +103 -0
- package/src/popover/README.md +94 -0
- package/src/tabs/README.md +90 -0
- package/src/toolbar/README.md +68 -0
- package/src/tooltip/README.md +97 -0
- package/dist/inclusive-elements.js +0 -20
- package/dist/inclusive-elements10.js +0 -96
- package/dist/inclusive-elements11.js +0 -6
- package/dist/inclusive-elements2.js +0 -28
- package/dist/inclusive-elements3.js +0 -71
- package/dist/inclusive-elements4.js +0 -49
- package/dist/inclusive-elements5.js +0 -67
- package/dist/inclusive-elements6.js +0 -83
- package/dist/inclusive-elements7.js +0 -127
- package/dist/inclusive-elements8.js +0 -77
- package/dist/inclusive-elements9.js +0 -38
- package/dist/types/accordion/accordion.d.ts +0 -6
- package/dist/types/disclosure/disclosure.d.ts +0 -14
- package/dist/types/modal/modal.d.ts +0 -17
- package/dist/types/popup/popup.d.ts +0 -21
package/dist/index.js
ADDED
|
@@ -0,0 +1,1003 @@
|
|
|
1
|
+
//#region node_modules/.pnpm/transition-kit@1.0.0/node_modules/transition-kit/dist/transition-kit.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
return e?.prefix ? e.prefix + "-" : "";
|
|
4
|
+
}
|
|
5
|
+
function t() {
|
|
6
|
+
return new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(() => e())));
|
|
7
|
+
}
|
|
8
|
+
function n(e, n) {
|
|
9
|
+
return new Promise((r) => {
|
|
10
|
+
let i = !1, a = /* @__PURE__ */ new Set(), o = () => {
|
|
11
|
+
e.removeEventListener("transitionrun", c), e.removeEventListener("transitionend", l), e.removeEventListener("transitioncancel", l);
|
|
12
|
+
}, s = () => {
|
|
13
|
+
o(), r();
|
|
14
|
+
}, c = (t) => {
|
|
15
|
+
t.target === e && (i = !0, a.add(t.propertyName));
|
|
16
|
+
}, l = (t) => {
|
|
17
|
+
t.target === e && (a.delete(t.propertyName), !(!i || a.size) && s());
|
|
18
|
+
};
|
|
19
|
+
e.addEventListener("transitionrun", c), e.addEventListener("transitionend", l), e.addEventListener("transitioncancel", l), n(), t().then(() => {
|
|
20
|
+
i || s();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function r(e, t) {
|
|
25
|
+
let n = e.style, r = {};
|
|
26
|
+
for (let e of t) r[e] = n[e];
|
|
27
|
+
return r;
|
|
28
|
+
}
|
|
29
|
+
function i(e, t) {
|
|
30
|
+
let n = e.style;
|
|
31
|
+
for (let e of Object.keys(t)) n[e] = t[e] ?? "";
|
|
32
|
+
}
|
|
33
|
+
var a = /* @__PURE__ */ new WeakMap(), o = [
|
|
34
|
+
"margin",
|
|
35
|
+
"marginTop",
|
|
36
|
+
"marginRight",
|
|
37
|
+
"marginBottom",
|
|
38
|
+
"marginLeft",
|
|
39
|
+
"marginBlock",
|
|
40
|
+
"marginBlockStart",
|
|
41
|
+
"marginBlockEnd",
|
|
42
|
+
"marginInline",
|
|
43
|
+
"marginInlineStart",
|
|
44
|
+
"marginInlineEnd"
|
|
45
|
+
], s = {};
|
|
46
|
+
for (let e of o) s[e] = "0px";
|
|
47
|
+
async function c(r, i, o = {}) {
|
|
48
|
+
let s = e(o) + i + "-", c = Symbol(s), u = o.detachFromLayout ?? !1, f = u ? g(r) : void 0, p = u ? d(r, f) : void 0, m = i === "leave" ? _(r) : void 0, h = {
|
|
49
|
+
prefix: s,
|
|
50
|
+
token: c,
|
|
51
|
+
isDetached: p !== void 0,
|
|
52
|
+
restoreStyles: p,
|
|
53
|
+
restoreInert: m
|
|
54
|
+
};
|
|
55
|
+
return a.set(r, h), r.classList.add(s + "active", s + "from"), await t(), a.get(r)?.token !== c || (await n(r, () => {
|
|
56
|
+
r.classList.add(s + "to"), r.classList.remove(s + "from");
|
|
57
|
+
}), a.get(r)?.token !== c) ? !1 : (l(r, h), !0);
|
|
58
|
+
}
|
|
59
|
+
function l(e, t = a.get(e)) {
|
|
60
|
+
t && (e.classList.remove(t.prefix + "active", t.prefix + "from", t.prefix + "to"), t.restoreStyles && i(e, t.restoreStyles), t.restoreInert?.(), a.delete(e));
|
|
61
|
+
}
|
|
62
|
+
function u(e) {
|
|
63
|
+
return a.get(e)?.isDetached ?? !1;
|
|
64
|
+
}
|
|
65
|
+
function d(e, t = g(e)) {
|
|
66
|
+
let n = getComputedStyle(e).position || "static";
|
|
67
|
+
if (n === "absolute" || n === "fixed") return;
|
|
68
|
+
let a = f(e, t);
|
|
69
|
+
if (!a) return;
|
|
70
|
+
let o = {
|
|
71
|
+
position: "absolute",
|
|
72
|
+
inset: "auto",
|
|
73
|
+
insetBlock: "auto",
|
|
74
|
+
insetBlockStart: "auto",
|
|
75
|
+
insetBlockEnd: "auto",
|
|
76
|
+
insetInline: "auto",
|
|
77
|
+
insetInlineStart: "auto",
|
|
78
|
+
insetInlineEnd: "auto",
|
|
79
|
+
top: `${a.top}px`,
|
|
80
|
+
left: `${a.left}px`,
|
|
81
|
+
right: "auto",
|
|
82
|
+
bottom: "auto",
|
|
83
|
+
width: `${t.width}px`,
|
|
84
|
+
height: `${t.height}px`,
|
|
85
|
+
boxSizing: "border-box",
|
|
86
|
+
...s
|
|
87
|
+
}, c = r(e, Object.keys(o));
|
|
88
|
+
return i(e, o), c;
|
|
89
|
+
}
|
|
90
|
+
function f(e, t = g(e)) {
|
|
91
|
+
let n = p(e);
|
|
92
|
+
if (n) {
|
|
93
|
+
if (getComputedStyle(n).display === "inline") return;
|
|
94
|
+
let e = n.getBoundingClientRect();
|
|
95
|
+
return {
|
|
96
|
+
left: t.left - e.left - n.clientLeft + n.scrollLeft,
|
|
97
|
+
top: t.top - e.top - n.clientTop + n.scrollTop
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
let r = e.ownerDocument.defaultView;
|
|
101
|
+
return {
|
|
102
|
+
left: t.left + (r?.scrollX ?? 0),
|
|
103
|
+
top: t.top + (r?.scrollY ?? 0)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function p(e) {
|
|
107
|
+
for (let t = e.parentElement; t; t = t.parentElement) if (m(t)) return t;
|
|
108
|
+
}
|
|
109
|
+
function m(e) {
|
|
110
|
+
let t = getComputedStyle(e);
|
|
111
|
+
return (t.position || "static") !== "static" || h(t.transform) || h(t.translate) || h(t.scale) || h(t.rotate) || h(t.perspective) || h(t.filter) || /(^|\s)(layout|paint|strict|content)(\s|$)/i.test(t.contain) || /(^|,)\s*(transform|translate|scale|rotate|perspective|filter|contain)\s*(,|$)/i.test(t.willChange);
|
|
112
|
+
}
|
|
113
|
+
function h(e) {
|
|
114
|
+
let t = e.trim().toLowerCase();
|
|
115
|
+
return !!t && t !== "none" && t !== "auto";
|
|
116
|
+
}
|
|
117
|
+
function g(e) {
|
|
118
|
+
let t = e.style.cssText;
|
|
119
|
+
i(e, {
|
|
120
|
+
transition: "none",
|
|
121
|
+
transform: "none",
|
|
122
|
+
translate: "none",
|
|
123
|
+
scale: "none",
|
|
124
|
+
rotate: "none"
|
|
125
|
+
});
|
|
126
|
+
let n = e.getBoundingClientRect();
|
|
127
|
+
return e.style.cssText = t, {
|
|
128
|
+
left: n.left,
|
|
129
|
+
top: n.top,
|
|
130
|
+
width: n.width,
|
|
131
|
+
height: n.height
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
function _(e) {
|
|
135
|
+
let t = e.inert;
|
|
136
|
+
return e.inert = !0, () => {
|
|
137
|
+
e.inert = t;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
var v = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap();
|
|
141
|
+
function x(t, n, r = {}) {
|
|
142
|
+
let i = [];
|
|
143
|
+
for (let e of Array.from(t)) getComputedStyle(e).display !== "none" && i.push({
|
|
144
|
+
el: e,
|
|
145
|
+
before: e.getBoundingClientRect()
|
|
146
|
+
});
|
|
147
|
+
n();
|
|
148
|
+
let a = e(r) + "move", o = [];
|
|
149
|
+
for (let { el: e, before: t } of i) {
|
|
150
|
+
if (u(e)) continue;
|
|
151
|
+
let n = e.getBoundingClientRect(), r = t.left - n.left, i = t.top - n.top, s = ne(e);
|
|
152
|
+
w(e, v, !1), !(!r && !i) && o.push(ee(e, {
|
|
153
|
+
store: v,
|
|
154
|
+
className: a,
|
|
155
|
+
startStyles: { transform: D(`translate(${r}px, ${i}px)`, s) },
|
|
156
|
+
endStyles: { transform: e.style.transform }
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
return Promise.all(o).then(() => void 0);
|
|
160
|
+
}
|
|
161
|
+
function S(e) {
|
|
162
|
+
w(e, y, !1), w(e, v, !1);
|
|
163
|
+
}
|
|
164
|
+
function ee(e, a) {
|
|
165
|
+
let o = Symbol(a.className), s = {
|
|
166
|
+
transitionDuration: "0s",
|
|
167
|
+
...a.startStyles
|
|
168
|
+
}, c = {
|
|
169
|
+
transitionDuration: "",
|
|
170
|
+
...a.endStyles
|
|
171
|
+
}, l = Object.keys({
|
|
172
|
+
...s,
|
|
173
|
+
...c
|
|
174
|
+
}), u = te(e), d, f = new Promise((e) => {
|
|
175
|
+
d = e;
|
|
176
|
+
}), p = {
|
|
177
|
+
className: a.className,
|
|
178
|
+
token: o,
|
|
179
|
+
styles: r(e, l),
|
|
180
|
+
resolve: d
|
|
181
|
+
};
|
|
182
|
+
return "transitionDuration" in p.styles && (p.styles.transitionDuration = u), a.store.set(e, p), e.classList.add(a.className), i(e, s), e.getBoundingClientRect(), t().then(async () => {
|
|
183
|
+
C(e), a.store.get(e)?.token === o && (await n(e, () => {
|
|
184
|
+
i(e, c);
|
|
185
|
+
}), a.store.get(e)?.token === o && T(e, a.store, p, !0));
|
|
186
|
+
}), f;
|
|
187
|
+
}
|
|
188
|
+
function te(e) {
|
|
189
|
+
let t = b.get(e);
|
|
190
|
+
if (t) return t.count += 1, t.value;
|
|
191
|
+
let n = e.style.transitionDuration;
|
|
192
|
+
return b.set(e, {
|
|
193
|
+
value: n,
|
|
194
|
+
count: 1
|
|
195
|
+
}), n;
|
|
196
|
+
}
|
|
197
|
+
function C(e) {
|
|
198
|
+
let t = b.get(e);
|
|
199
|
+
t && (--t.count, t.count <= 0 && b.delete(e));
|
|
200
|
+
}
|
|
201
|
+
function w(e, t, n) {
|
|
202
|
+
let r = t.get(e);
|
|
203
|
+
r && T(e, t, r, n);
|
|
204
|
+
}
|
|
205
|
+
function T(e, t, n, r) {
|
|
206
|
+
E(e, n), t.delete(e), n.resolve(r);
|
|
207
|
+
}
|
|
208
|
+
function E(e, t) {
|
|
209
|
+
e.classList.remove(t.className), i(e, t.styles);
|
|
210
|
+
}
|
|
211
|
+
function ne(e) {
|
|
212
|
+
let t = getComputedStyle(e).transform;
|
|
213
|
+
return t === "none" ? "" : t;
|
|
214
|
+
}
|
|
215
|
+
function D(...e) {
|
|
216
|
+
return e.filter((e) => !!e && e !== "none").join(" ");
|
|
217
|
+
}
|
|
218
|
+
function O(e, t, n = {}) {
|
|
219
|
+
return A(e), c(e, t, n);
|
|
220
|
+
}
|
|
221
|
+
function re(e, t = {}) {
|
|
222
|
+
return O(e, "enter", t);
|
|
223
|
+
}
|
|
224
|
+
function k(e, t = {}) {
|
|
225
|
+
return O(e, "leave", {
|
|
226
|
+
...t,
|
|
227
|
+
detachFromLayout: t.detachFromLayout ?? !0
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
function A(e) {
|
|
231
|
+
l(e), S(e);
|
|
232
|
+
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/alerts/alerts.ts
|
|
235
|
+
var j = class e extends HTMLElement {
|
|
236
|
+
static duration = 1e4;
|
|
237
|
+
static politeness = "polite";
|
|
238
|
+
timeouts = /* @__PURE__ */ new WeakMap();
|
|
239
|
+
index = 0;
|
|
240
|
+
connectedCallback() {
|
|
241
|
+
this.addEventListener("focusin", this.pauseOnInteraction), this.addEventListener("focusout", this.resumeOnInteraction), this.addEventListener("mouseover", this.pauseOnInteraction), this.addEventListener("mouseout", this.resumeOnInteraction);
|
|
242
|
+
for (let e of this.getAlerts()) e.remove(), this.show(e);
|
|
243
|
+
}
|
|
244
|
+
disconnectedCallback() {
|
|
245
|
+
this.removeEventListener("focusin", this.pauseOnInteraction), this.removeEventListener("focusout", this.resumeOnInteraction), this.removeEventListener("mouseover", this.pauseOnInteraction), this.removeEventListener("mouseout", this.resumeOnInteraction), this.getAlerts().forEach((e) => this.clearTimeout(e));
|
|
246
|
+
}
|
|
247
|
+
show(e, t = {}) {
|
|
248
|
+
let n = t.key || e.dataset.key || String(this.index++);
|
|
249
|
+
e.dataset.key = n, this.syncAlertPoliteness(e, t.politeness), t.duration !== void 0 && (e.dataset.duration = String(t.duration));
|
|
250
|
+
let r = this.getAlerts().filter((t) => t !== e);
|
|
251
|
+
return x(r, () => {
|
|
252
|
+
r.filter((e) => e.dataset.key === n).forEach((e) => this.leaveAlert(e)), A(e), this.append(e), re(e);
|
|
253
|
+
}), this.startTimeout(e), n;
|
|
254
|
+
}
|
|
255
|
+
dismiss(e) {
|
|
256
|
+
(typeof e == "string" ? this.getAlerts().filter((t) => t.dataset.key === e) : [e]).forEach((e) => this.dismissAlert(e));
|
|
257
|
+
}
|
|
258
|
+
clear() {
|
|
259
|
+
this.getAlerts().forEach((e) => this.dismissAlert(e));
|
|
260
|
+
}
|
|
261
|
+
speak(e, t = {}) {
|
|
262
|
+
let n = document.createElement("div");
|
|
263
|
+
Object.assign(n.style, {
|
|
264
|
+
clip: "rect(0 0 0 0)",
|
|
265
|
+
clipPath: "inset(50%)",
|
|
266
|
+
height: "1px",
|
|
267
|
+
overflow: "hidden",
|
|
268
|
+
position: "absolute",
|
|
269
|
+
whiteSpace: "nowrap",
|
|
270
|
+
width: "1px"
|
|
271
|
+
}), n.textContent = e, this.show(n, t);
|
|
272
|
+
}
|
|
273
|
+
dismissAlert(e) {
|
|
274
|
+
x(this.getAlerts().filter((t) => t !== e), () => this.leaveAlert(e));
|
|
275
|
+
}
|
|
276
|
+
leaveAlert(e) {
|
|
277
|
+
this.clearTimeout(e), k(e).then((t) => {
|
|
278
|
+
t && e.parentElement === this && e.remove();
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
startTimeout(t) {
|
|
282
|
+
this.clearTimeout(t);
|
|
283
|
+
let n = Number(t.dataset.duration || e.duration);
|
|
284
|
+
n > 0 && this.timeouts.set(t, window.setTimeout(() => this.dismiss(t), n));
|
|
285
|
+
}
|
|
286
|
+
clearTimeout(e) {
|
|
287
|
+
let t = this.timeouts.get(e);
|
|
288
|
+
t !== void 0 && (clearTimeout(t), this.timeouts.delete(e));
|
|
289
|
+
}
|
|
290
|
+
pauseOnInteraction = (e) => {
|
|
291
|
+
this.handleInteraction(e, (e) => this.clearTimeout(e));
|
|
292
|
+
};
|
|
293
|
+
resumeOnInteraction = (e) => {
|
|
294
|
+
this.handleInteraction(e, (e) => this.startTimeout(e));
|
|
295
|
+
};
|
|
296
|
+
handleInteraction(e, t) {
|
|
297
|
+
let n = this.getAlertFromTarget(e.target);
|
|
298
|
+
n && (e.relatedTarget instanceof Node && n.contains(e.relatedTarget) || t(n));
|
|
299
|
+
}
|
|
300
|
+
getAlerts() {
|
|
301
|
+
return Array.from(this.children, (e) => e);
|
|
302
|
+
}
|
|
303
|
+
syncAlertPoliteness(t, n) {
|
|
304
|
+
if ((n || this.getAuthoredPoliteness(t) || e.politeness) === "assertive") {
|
|
305
|
+
t.setAttribute("role", "alert"), t.setAttribute("aria-live", "assertive");
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite");
|
|
309
|
+
}
|
|
310
|
+
getAuthoredPoliteness(e) {
|
|
311
|
+
if (e.getAttribute("role") === "alert" || e.getAttribute("aria-live") === "assertive") return "assertive";
|
|
312
|
+
if (e.getAttribute("role") === "status" || e.getAttribute("aria-live") === "polite") return "polite";
|
|
313
|
+
}
|
|
314
|
+
getAlertFromTarget(e) {
|
|
315
|
+
return e instanceof Node && Array.from(this.children).find((t) => t instanceof HTMLElement && t.contains(e)) || null;
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/utils.ts
|
|
320
|
+
function M(e, t) {
|
|
321
|
+
let n = !1;
|
|
322
|
+
return {
|
|
323
|
+
queue: () => {
|
|
324
|
+
n || (n = !0, queueMicrotask(() => {
|
|
325
|
+
n = !1, e.isConnected && t();
|
|
326
|
+
}));
|
|
327
|
+
},
|
|
328
|
+
disconnect() {
|
|
329
|
+
n = !1;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function N(e, t, n) {
|
|
334
|
+
let r = M(e, n), i = new MutationObserver(r.queue);
|
|
335
|
+
return {
|
|
336
|
+
observe() {
|
|
337
|
+
i.observe(e, t);
|
|
338
|
+
},
|
|
339
|
+
disconnect() {
|
|
340
|
+
i.disconnect(), r.disconnect();
|
|
341
|
+
},
|
|
342
|
+
queue: r.queue
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function P(e) {
|
|
346
|
+
let t = e.getRootNode();
|
|
347
|
+
return t instanceof ShadowRoot ? t : e.ownerDocument;
|
|
348
|
+
}
|
|
349
|
+
function F(e, t) {
|
|
350
|
+
let { currentIndex: n, length: r, vertical: i } = t;
|
|
351
|
+
if (!(r === 0 || n < 0 || n >= r)) {
|
|
352
|
+
if (e === (i ? "ArrowUp" : "ArrowLeft")) return (n - 1 + r) % r;
|
|
353
|
+
if (e === (i ? "ArrowDown" : "ArrowRight")) return (n + 1) % r;
|
|
354
|
+
if (e === "Home") return 0;
|
|
355
|
+
if (e === "End") return r - 1;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/menu/menu.ts
|
|
360
|
+
var I = class e extends HTMLElement {
|
|
361
|
+
static searchDelay = 800;
|
|
362
|
+
static observedAttributes = ["id", "popover"];
|
|
363
|
+
itemSync;
|
|
364
|
+
search = "";
|
|
365
|
+
searchTimeout;
|
|
366
|
+
connectedCallback() {
|
|
367
|
+
this.hasAttribute("role") || this.setAttribute("role", "menu"), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "-1"), this.addEventListener("keydown", this.onKeyDown), this.addEventListener("click", this.onClick), this.addEventListener("mouseenter", this.onMouseEnter, !0), this.itemSync ??= N(this, {
|
|
368
|
+
subtree: !0,
|
|
369
|
+
childList: !0,
|
|
370
|
+
attributes: !0,
|
|
371
|
+
attributeFilter: ["role", "tabindex"]
|
|
372
|
+
}, () => this.syncItems()), this.itemSync.observe(), this.itemSync.queue(), this.syncDocumentListeners();
|
|
373
|
+
}
|
|
374
|
+
disconnectedCallback() {
|
|
375
|
+
this.removeEventListener("keydown", this.onKeyDown), this.removeEventListener("click", this.onClick), this.removeEventListener("mouseenter", this.onMouseEnter, !0), this.removeDocumentListeners(), this.itemSync?.disconnect(), this.closeSelfAndDescendants(), clearTimeout(this.searchTimeout);
|
|
376
|
+
}
|
|
377
|
+
attributeChangedCallback(e, t, n) {
|
|
378
|
+
t !== n && (e !== "id" && e !== "popover" || this.syncDocumentListeners());
|
|
379
|
+
}
|
|
380
|
+
get horizontal() {
|
|
381
|
+
return this.getAttribute("aria-orientation") === "horizontal";
|
|
382
|
+
}
|
|
383
|
+
syncDocumentListeners() {
|
|
384
|
+
if (this.isConnected && this.hasAttribute("popover") && !this.getParentMenuTrigger()) {
|
|
385
|
+
this.ownerDocument.addEventListener("click", this.onDocumentClick), this.ownerDocument.addEventListener("keydown", this.onDocumentKeyDown);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
this.removeDocumentListeners();
|
|
389
|
+
}
|
|
390
|
+
removeDocumentListeners() {
|
|
391
|
+
this.ownerDocument.removeEventListener("click", this.onDocumentClick), this.ownerDocument.removeEventListener("keydown", this.onDocumentKeyDown);
|
|
392
|
+
}
|
|
393
|
+
onDocumentClick = (e) => {
|
|
394
|
+
this.getRootTriggerForEvent(e) && requestAnimationFrame(() => {
|
|
395
|
+
this.isActive() && (e.detail === 0 ? this.getEnabledItems()[0]?.focus() : this.focus({ preventScroll: !0 }));
|
|
396
|
+
});
|
|
397
|
+
};
|
|
398
|
+
onDocumentKeyDown = (e) => {
|
|
399
|
+
let t = this.getRootTriggerForEvent(e);
|
|
400
|
+
if (!t || e.key !== "ArrowDown" && e.key !== "ArrowUp" || this.hidden) return;
|
|
401
|
+
e.preventDefault(), this.isActive() || this.showPopoverWithSource(t);
|
|
402
|
+
let n = this.getEnabledItems();
|
|
403
|
+
e.key === "ArrowDown" ? n[0]?.focus() : n[n.length - 1]?.focus();
|
|
404
|
+
};
|
|
405
|
+
onKeyDown = (e) => {
|
|
406
|
+
if (!this.isActive()) return;
|
|
407
|
+
if (e.key === "Tab") {
|
|
408
|
+
this.closeMenuTree(), this.focusRootMenuTrigger();
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
if (e.key === "Escape") {
|
|
412
|
+
e.preventDefault(), this.closeMenuTree(), this.focusRootMenuTrigger();
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
let t = this.getEnabledItems(), n = this.getActiveItem(t), r = n ? t.indexOf(n) : -1;
|
|
416
|
+
if (r === -1) {
|
|
417
|
+
if (!this.horizontal && e.key === "ArrowDown" || this.horizontal && e.key === "ArrowRight") {
|
|
418
|
+
t[0]?.focus(), e.preventDefault();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
if (!this.horizontal && e.key === "ArrowUp" || this.horizontal && e.key === "ArrowLeft") {
|
|
422
|
+
t[t.length - 1]?.focus(), e.preventDefault();
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
let i = n ? this.getSubmenu(n) : null;
|
|
427
|
+
if (n && i) {
|
|
428
|
+
if (!this.horizontal && e.key === "ArrowRight" || this.horizontal && e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") {
|
|
429
|
+
this.openSubmenu(n), i.getItems()[0]?.focus();
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (this.horizontal && e.key === "ArrowUp") {
|
|
433
|
+
this.openSubmenu(n), i.getItems().at(-1)?.focus();
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
let a = this.getParentMenuTrigger(), o = a?.closest("ui-menu");
|
|
438
|
+
if (o && e.key === (o.horizontal ? "ArrowUp" : "ArrowLeft")) {
|
|
439
|
+
this.closeSelfAndDescendants(), a?.focus({ preventScroll: !0 });
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
let s = F(e.key, {
|
|
443
|
+
currentIndex: r,
|
|
444
|
+
length: t.length,
|
|
445
|
+
vertical: !this.horizontal
|
|
446
|
+
});
|
|
447
|
+
if (s !== void 0) {
|
|
448
|
+
t[s]?.focus(), e.preventDefault();
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
this.handleTypeahead(e, t, n);
|
|
452
|
+
};
|
|
453
|
+
onClick = (e) => {
|
|
454
|
+
let t = this.getItemForEvent(e);
|
|
455
|
+
if (!t) return;
|
|
456
|
+
let n = this.getSubmenu(t);
|
|
457
|
+
if (n) {
|
|
458
|
+
e.preventDefault(), n.isActive() || (this.openSubmenu(t), n.getItems()[0]?.focus());
|
|
459
|
+
return;
|
|
460
|
+
}
|
|
461
|
+
this.closeMenuTree();
|
|
462
|
+
};
|
|
463
|
+
onMouseEnter = (e) => {
|
|
464
|
+
if (!this.isActive()) return;
|
|
465
|
+
let t = this.getItemForEvent(e);
|
|
466
|
+
if (t) {
|
|
467
|
+
if (t.focus(), this.getSubmenu(t)) {
|
|
468
|
+
this.openSubmenu(t);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
this.closeSubmenus();
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
isActive() {
|
|
475
|
+
return this.hidden ? !1 : !this.hasAttribute("popover") || this.matches(":popover-open");
|
|
476
|
+
}
|
|
477
|
+
syncItems() {
|
|
478
|
+
this.getItems().forEach((e) => {
|
|
479
|
+
e.getAttribute("tabindex") !== "-1" && e.setAttribute("tabindex", "-1");
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
getItems() {
|
|
483
|
+
return Array.from(this.querySelectorAll("[role^=menuitem]")).filter((e) => this.belongsToThisMenu(e));
|
|
484
|
+
}
|
|
485
|
+
getEnabledItems() {
|
|
486
|
+
return this.getItems().filter((e) => this.isItemEnabled(e));
|
|
487
|
+
}
|
|
488
|
+
isItemEnabled(e) {
|
|
489
|
+
return !e.hidden && !e.hasAttribute("disabled") && e.getAttribute("aria-disabled") !== "true";
|
|
490
|
+
}
|
|
491
|
+
belongsToThisMenu(e) {
|
|
492
|
+
return e.closest("ui-menu") === this;
|
|
493
|
+
}
|
|
494
|
+
getActiveItem(e) {
|
|
495
|
+
let t = P(this).activeElement;
|
|
496
|
+
return e.find((e) => e === t);
|
|
497
|
+
}
|
|
498
|
+
getItemForEvent(e) {
|
|
499
|
+
let t = e.target;
|
|
500
|
+
if (!(t instanceof Element)) return null;
|
|
501
|
+
let n = t.closest("[role^=menuitem]");
|
|
502
|
+
return n && this.belongsToThisMenu(n) && this.isItemEnabled(n) ? n : null;
|
|
503
|
+
}
|
|
504
|
+
getRootTriggerForEvent(e) {
|
|
505
|
+
for (let t of e.composedPath()) if (t instanceof HTMLElement && !t.closest("ui-menu") && t.getAttribute("popovertarget") === this.id) return t;
|
|
506
|
+
return null;
|
|
507
|
+
}
|
|
508
|
+
getTriggers() {
|
|
509
|
+
return this.id ? Array.from(P(this).querySelectorAll(`[popovertarget="${CSS.escape(this.id)}"]`)) : [];
|
|
510
|
+
}
|
|
511
|
+
getParentMenuTrigger() {
|
|
512
|
+
return this.getTriggers().find((e) => e.closest("ui-menu")) || null;
|
|
513
|
+
}
|
|
514
|
+
getParentMenu() {
|
|
515
|
+
return this.getParentMenuTrigger()?.closest("ui-menu") || null;
|
|
516
|
+
}
|
|
517
|
+
getSubmenu(e) {
|
|
518
|
+
let t = e.getAttribute("popovertarget");
|
|
519
|
+
return t ? P(this).querySelector(`ui-menu#${CSS.escape(t)}`) : null;
|
|
520
|
+
}
|
|
521
|
+
openSubmenu(e) {
|
|
522
|
+
let t = this.getSubmenu(e);
|
|
523
|
+
t && (this.closeSubmenus(), t.showPopoverWithSource(e));
|
|
524
|
+
}
|
|
525
|
+
closeSubmenus() {
|
|
526
|
+
this.getItems().forEach((e) => this.getSubmenu(e)?.closeSelfAndDescendants());
|
|
527
|
+
}
|
|
528
|
+
closeSelfAndDescendants() {
|
|
529
|
+
this.closeSubmenus(), this.hasAttribute("popover") && this.matches(":popover-open") && this.hidePopover();
|
|
530
|
+
}
|
|
531
|
+
closeMenuTree() {
|
|
532
|
+
this.closeSelfAndDescendants(), this.getParentMenu()?.closeMenuTree();
|
|
533
|
+
}
|
|
534
|
+
focusRootMenuTrigger() {
|
|
535
|
+
this.getRootMenuTrigger()?.focus({ preventScroll: !0 });
|
|
536
|
+
}
|
|
537
|
+
getRootMenuTrigger() {
|
|
538
|
+
let e = this.getParentMenu();
|
|
539
|
+
return e ? e.getRootMenuTrigger() : this.getTriggers()[0] || null;
|
|
540
|
+
}
|
|
541
|
+
handleTypeahead(e, t, n) {
|
|
542
|
+
if (e.key === " " || e.key.length > 1 || e.ctrlKey || e.metaKey || e.altKey || !t.length) return;
|
|
543
|
+
e.preventDefault();
|
|
544
|
+
let r = this.updateTypeaheadSearch(e.key), i = n ? t.indexOf(n) : -1;
|
|
545
|
+
this.findTypeaheadMatch(t, r, i)?.focus();
|
|
546
|
+
}
|
|
547
|
+
updateTypeaheadSearch(t) {
|
|
548
|
+
return this.search += t.toLowerCase(), clearTimeout(this.searchTimeout), this.searchTimeout = window.setTimeout(() => {
|
|
549
|
+
this.search = "";
|
|
550
|
+
}, e.searchDelay), this.search.length > 1 && this.search.split("").every((e) => e === this.search[0]) ? this.search[0] : this.search;
|
|
551
|
+
}
|
|
552
|
+
findTypeaheadMatch(e, t, n) {
|
|
553
|
+
for (let r = 1; r <= e.length; r += 1) {
|
|
554
|
+
let i = e[(n + r + e.length) % e.length];
|
|
555
|
+
if (this.getItemLabel(i).startsWith(t)) return i;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
getItemLabel(e) {
|
|
559
|
+
return (e.getAttribute("aria-label") || e.textContent || "").trim().toLowerCase();
|
|
560
|
+
}
|
|
561
|
+
showPopoverWithSource(e) {
|
|
562
|
+
this.showPopover?.({ source: e });
|
|
563
|
+
}
|
|
564
|
+
}, L = /* @__PURE__ */ [
|
|
565
|
+
"input:not([inert]):not([inert] *)",
|
|
566
|
+
"select:not([inert]):not([inert] *)",
|
|
567
|
+
"textarea:not([inert]):not([inert] *)",
|
|
568
|
+
"a[href]:not([inert]):not([inert] *)",
|
|
569
|
+
"button:not([inert]):not([inert] *)",
|
|
570
|
+
"[tabindex]:not(slot):not([inert]):not([inert] *)",
|
|
571
|
+
"audio[controls]:not([inert]):not([inert] *)",
|
|
572
|
+
"video[controls]:not([inert]):not([inert] *)",
|
|
573
|
+
"[contenteditable]:not([contenteditable=\"false\"]):not([inert]):not([inert] *)",
|
|
574
|
+
"details>summary:first-of-type:not([inert]):not([inert] *)",
|
|
575
|
+
"details:not([inert]):not([inert] *)"
|
|
576
|
+
].join(","), R = typeof Element > "u", z = R ? function() {} : Element.prototype.matches || Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector, B = !R && Element.prototype.getRootNode ? function(e) {
|
|
577
|
+
return e?.getRootNode?.call(e);
|
|
578
|
+
} : function(e) {
|
|
579
|
+
return e?.ownerDocument;
|
|
580
|
+
}, V = function(e, t) {
|
|
581
|
+
t === void 0 && (t = !0);
|
|
582
|
+
var n = e?.getAttribute?.call(e, "inert");
|
|
583
|
+
return n === "" || n === "true" || t && e && (typeof e.closest == "function" ? e.closest("[inert]") : V(e.parentNode));
|
|
584
|
+
}, H = function(e) {
|
|
585
|
+
var t = e?.getAttribute?.call(e, "contenteditable");
|
|
586
|
+
return t === "" || t === "true";
|
|
587
|
+
}, U = function(e, t, n) {
|
|
588
|
+
if (V(e)) return [];
|
|
589
|
+
var r = Array.prototype.slice.apply(e.querySelectorAll(L));
|
|
590
|
+
return t && z.call(e, L) && r.unshift(e), r = r.filter(n), r;
|
|
591
|
+
}, W = function(e, t, n) {
|
|
592
|
+
for (var r = [], i = Array.from(e); i.length;) {
|
|
593
|
+
var a = i.shift();
|
|
594
|
+
if (!V(a, !1)) if (a.tagName === "SLOT") {
|
|
595
|
+
var o = a.assignedElements(), s = W(o.length ? o : a.children, !0, n);
|
|
596
|
+
n.flatten ? r.push.apply(r, s) : r.push({
|
|
597
|
+
scopeParent: a,
|
|
598
|
+
candidates: s
|
|
599
|
+
});
|
|
600
|
+
} else {
|
|
601
|
+
z.call(a, L) && n.filter(a) && (t || !e.includes(a)) && r.push(a);
|
|
602
|
+
var c = a.shadowRoot || typeof n.getShadowRoot == "function" && n.getShadowRoot(a), l = !V(c, !1) && (!n.shadowRootFilter || n.shadowRootFilter(a));
|
|
603
|
+
if (c && l) {
|
|
604
|
+
var u = W(c === !0 ? a.children : c.children, !0, n);
|
|
605
|
+
n.flatten ? r.push.apply(r, u) : r.push({
|
|
606
|
+
scopeParent: a,
|
|
607
|
+
candidates: u
|
|
608
|
+
});
|
|
609
|
+
} else i.unshift.apply(i, a.children);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return r;
|
|
613
|
+
}, G = function(e) {
|
|
614
|
+
return !isNaN(parseInt(e.getAttribute("tabindex"), 10));
|
|
615
|
+
}, K = function(e) {
|
|
616
|
+
if (!e) throw Error("No node provided");
|
|
617
|
+
return e.tabIndex < 0 && (/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName) || H(e)) && !G(e) ? 0 : e.tabIndex;
|
|
618
|
+
}, q = function(e, t) {
|
|
619
|
+
var n = K(e);
|
|
620
|
+
return n < 0 && t && !G(e) ? 0 : n;
|
|
621
|
+
}, J = function(e, t) {
|
|
622
|
+
return e.tabIndex === t.tabIndex ? e.documentOrder - t.documentOrder : e.tabIndex - t.tabIndex;
|
|
623
|
+
}, Y = function(e) {
|
|
624
|
+
return e.tagName === "INPUT";
|
|
625
|
+
}, ie = function(e) {
|
|
626
|
+
return Y(e) && e.type === "hidden";
|
|
627
|
+
}, ae = function(e) {
|
|
628
|
+
return e.tagName === "DETAILS" && Array.prototype.slice.apply(e.children).some(function(e) {
|
|
629
|
+
return e.tagName === "SUMMARY";
|
|
630
|
+
});
|
|
631
|
+
}, oe = function(e, t) {
|
|
632
|
+
for (var n = 0; n < e.length; n++) if (e[n].checked && e[n].form === t) return e[n];
|
|
633
|
+
}, se = function(e) {
|
|
634
|
+
if (!e.name) return !0;
|
|
635
|
+
var t = e.form || B(e), n = function(e) {
|
|
636
|
+
return t.querySelectorAll("input[type=\"radio\"][name=\"" + e + "\"]");
|
|
637
|
+
}, r;
|
|
638
|
+
if (typeof window < "u" && window.CSS !== void 0 && typeof window.CSS.escape == "function") r = n(window.CSS.escape(e.name));
|
|
639
|
+
else try {
|
|
640
|
+
r = n(e.name);
|
|
641
|
+
} catch (e) {
|
|
642
|
+
return 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", e.message), !1;
|
|
643
|
+
}
|
|
644
|
+
var i = oe(r, e.form);
|
|
645
|
+
return !i || i === e;
|
|
646
|
+
}, ce = function(e) {
|
|
647
|
+
return Y(e) && e.type === "radio";
|
|
648
|
+
}, le = function(e) {
|
|
649
|
+
return ce(e) && !se(e);
|
|
650
|
+
}, ue = function(e) {
|
|
651
|
+
var t = e && B(e), n = t?.host, r = !1;
|
|
652
|
+
if (t && t !== e) {
|
|
653
|
+
var i, a, o;
|
|
654
|
+
for (r = !!((i = n) != null && (a = i.ownerDocument) != null && a.contains(n) || e != null && (o = e.ownerDocument) != null && o.contains(e)); !r && n;) {
|
|
655
|
+
var s, c;
|
|
656
|
+
t = B(n), n = t?.host, r = !!((s = n) != null && (c = s.ownerDocument) != null && c.contains(n));
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
return r;
|
|
660
|
+
}, X = function(e) {
|
|
661
|
+
var t = e.getBoundingClientRect(), n = t.width, r = t.height;
|
|
662
|
+
return n === 0 && r === 0;
|
|
663
|
+
}, de = function(e, t) {
|
|
664
|
+
var n = t.displayCheck, r = t.getShadowRoot;
|
|
665
|
+
if (n === "full-native" && "checkVisibility" in e) return !e.checkVisibility({
|
|
666
|
+
checkOpacity: !1,
|
|
667
|
+
opacityProperty: !1,
|
|
668
|
+
contentVisibilityAuto: !0,
|
|
669
|
+
visibilityProperty: !0,
|
|
670
|
+
checkVisibilityCSS: !0
|
|
671
|
+
});
|
|
672
|
+
if (getComputedStyle(e).visibility === "hidden") return !0;
|
|
673
|
+
var i = z.call(e, "details>summary:first-of-type") ? e.parentElement : e;
|
|
674
|
+
if (z.call(i, "details:not([open]) *")) return !0;
|
|
675
|
+
if (!n || n === "full" || n === "full-native" || n === "legacy-full") {
|
|
676
|
+
if (typeof r == "function") {
|
|
677
|
+
for (var a = e; e;) {
|
|
678
|
+
var o = e.parentElement, s = B(e);
|
|
679
|
+
if (o && !o.shadowRoot && r(o) === !0) return X(e);
|
|
680
|
+
e = e.assignedSlot ? e.assignedSlot : !o && s !== e.ownerDocument ? s.host : o;
|
|
681
|
+
}
|
|
682
|
+
e = a;
|
|
683
|
+
}
|
|
684
|
+
if (ue(e)) return !e.getClientRects().length;
|
|
685
|
+
if (n !== "legacy-full") return !0;
|
|
686
|
+
} else if (n === "non-zero-area") return X(e);
|
|
687
|
+
return !1;
|
|
688
|
+
}, fe = function(e) {
|
|
689
|
+
if (/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName)) for (var t = e.parentElement; t;) {
|
|
690
|
+
if (t.tagName === "FIELDSET" && t.disabled) {
|
|
691
|
+
for (var n = 0; n < t.children.length; n++) {
|
|
692
|
+
var r = t.children.item(n);
|
|
693
|
+
if (r.tagName === "LEGEND") return z.call(t, "fieldset[disabled] *") ? !0 : !r.contains(e);
|
|
694
|
+
}
|
|
695
|
+
return !0;
|
|
696
|
+
}
|
|
697
|
+
t = t.parentElement;
|
|
698
|
+
}
|
|
699
|
+
return !1;
|
|
700
|
+
}, Z = function(e, t) {
|
|
701
|
+
return !(t.disabled || ie(t) || de(t, e) || ae(t) || fe(t));
|
|
702
|
+
}, Q = function(e, t) {
|
|
703
|
+
return !(le(t) || K(t) < 0 || !Z(e, t));
|
|
704
|
+
}, pe = function(e) {
|
|
705
|
+
var t = parseInt(e.getAttribute("tabindex"), 10);
|
|
706
|
+
return !!(isNaN(t) || t >= 0);
|
|
707
|
+
}, $ = function(e) {
|
|
708
|
+
var t = [], n = [];
|
|
709
|
+
return e.forEach(function(e, r) {
|
|
710
|
+
var i = !!e.scopeParent, a = i ? e.scopeParent : e, o = q(a, i), s = i ? $(e.candidates) : a;
|
|
711
|
+
o === 0 ? i ? t.push.apply(t, s) : t.push(a) : n.push({
|
|
712
|
+
documentOrder: r,
|
|
713
|
+
tabIndex: o,
|
|
714
|
+
item: e,
|
|
715
|
+
isScope: i,
|
|
716
|
+
content: s
|
|
717
|
+
});
|
|
718
|
+
}), n.sort(J).reduce(function(e, t) {
|
|
719
|
+
return t.isScope ? e.push.apply(e, t.content) : e.push(t.content), e;
|
|
720
|
+
}, []).concat(t);
|
|
721
|
+
}, me = function(e, t) {
|
|
722
|
+
return t ||= {}, $(t.getShadowRoot ? W([e], t.includeContainer, {
|
|
723
|
+
filter: Q.bind(null, t),
|
|
724
|
+
flatten: !1,
|
|
725
|
+
getShadowRoot: t.getShadowRoot,
|
|
726
|
+
shadowRootFilter: pe
|
|
727
|
+
}) : U(e, t.includeContainer, Q.bind(null, t)));
|
|
728
|
+
}, he = function(e, t) {
|
|
729
|
+
return t ||= {}, t.getShadowRoot ? W([e], t.includeContainer, {
|
|
730
|
+
filter: Z.bind(null, t),
|
|
731
|
+
flatten: !0,
|
|
732
|
+
getShadowRoot: t.getShadowRoot
|
|
733
|
+
}) : U(e, t.includeContainer, Z.bind(null, t));
|
|
734
|
+
}, ge = 0, _e = class extends HTMLElement {
|
|
735
|
+
idPrefix = "tabs" + ++ge;
|
|
736
|
+
structureSync;
|
|
737
|
+
managedPanelTabindex = /* @__PURE__ */ new WeakSet();
|
|
738
|
+
connectedCallback() {
|
|
739
|
+
this.addEventListener("keydown", this.onKeyDown), this.addEventListener("click", this.onClick), this.structureSync ||= N(this, {
|
|
740
|
+
subtree: !0,
|
|
741
|
+
childList: !0,
|
|
742
|
+
attributes: !0,
|
|
743
|
+
attributeFilter: ["role", "aria-selected"]
|
|
744
|
+
}, () => this.syncStructure()), this.structureSync.observe(), this.structureSync.queue();
|
|
745
|
+
}
|
|
746
|
+
disconnectedCallback() {
|
|
747
|
+
this.removeEventListener("keydown", this.onKeyDown), this.removeEventListener("click", this.onClick), this.structureSync?.disconnect();
|
|
748
|
+
}
|
|
749
|
+
selectTab(e, t = {}) {
|
|
750
|
+
return this.applySelection(this.tabPairs(), e, t);
|
|
751
|
+
}
|
|
752
|
+
onKeyDown = (e) => {
|
|
753
|
+
let t = this.tabPairs();
|
|
754
|
+
if (!t.length) return;
|
|
755
|
+
let n = F(e.key, {
|
|
756
|
+
currentIndex: this.getEventTabIndex(e.target, t),
|
|
757
|
+
length: t.length,
|
|
758
|
+
vertical: this.vertical
|
|
759
|
+
});
|
|
760
|
+
n !== void 0 && (this.applySelection(t, n, { focus: !0 }), e.stopPropagation(), e.preventDefault());
|
|
761
|
+
};
|
|
762
|
+
onClick = (e) => {
|
|
763
|
+
let t = this.tabPairs();
|
|
764
|
+
this.applySelection(t, this.getEventTabIndex(e.target, t), { focus: !0 });
|
|
765
|
+
};
|
|
766
|
+
syncStructure() {
|
|
767
|
+
let e = this.tabPairs();
|
|
768
|
+
e.length && this.applySelection(e, this.getSelectedIndex(e, 0), { emit: !1 });
|
|
769
|
+
}
|
|
770
|
+
get vertical() {
|
|
771
|
+
return this.tablist?.getAttribute("aria-orientation") === "vertical";
|
|
772
|
+
}
|
|
773
|
+
get tablist() {
|
|
774
|
+
return Array.from(this.querySelectorAll("[role=tablist]")).find((e) => e.closest("ui-tabs") === this);
|
|
775
|
+
}
|
|
776
|
+
tabPairs() {
|
|
777
|
+
let e = this.tablist;
|
|
778
|
+
if (!e) return [];
|
|
779
|
+
let t = Array.from(e.querySelectorAll("[role=tab]")), n = Array.from(this.querySelectorAll("[role=tabpanel]")).filter((e) => e.closest("ui-tabs") === this);
|
|
780
|
+
t.forEach((e, t) => {
|
|
781
|
+
e.id ||= this.idPrefix + "_tab_" + t;
|
|
782
|
+
}), n.forEach((e, t) => {
|
|
783
|
+
e.id ||= this.idPrefix + "_panel_" + t;
|
|
784
|
+
});
|
|
785
|
+
let r = t.slice(0, Math.min(t.length, n.length)).map((e, t) => ({
|
|
786
|
+
tab: e,
|
|
787
|
+
panel: n[t]
|
|
788
|
+
}));
|
|
789
|
+
return r.forEach(({ tab: e, panel: t }) => {
|
|
790
|
+
e.setAttribute("aria-controls", t.id), t.setAttribute("aria-labelledby", e.id);
|
|
791
|
+
}), r;
|
|
792
|
+
}
|
|
793
|
+
getSelectedIndex(e, t = -1) {
|
|
794
|
+
let n = e.findIndex(({ tab: e }) => e.getAttribute("aria-selected") === "true");
|
|
795
|
+
return n === -1 ? t : n;
|
|
796
|
+
}
|
|
797
|
+
getEventTabIndex(e, t) {
|
|
798
|
+
if (!(e instanceof Element)) return -1;
|
|
799
|
+
let n = e.closest("[role=tab]");
|
|
800
|
+
return n ? t.findIndex((e) => e.tab === n) : -1;
|
|
801
|
+
}
|
|
802
|
+
applySelection(e, t, n = {}) {
|
|
803
|
+
let { focus: r = !1, emit: i = !0 } = n;
|
|
804
|
+
if (t < 0 || t >= e.length) return !1;
|
|
805
|
+
let a = this.getSelectedIndex(e);
|
|
806
|
+
return e.forEach(({ tab: e, panel: n }, i) => {
|
|
807
|
+
let a = i === t;
|
|
808
|
+
e.getAttribute("aria-selected") !== String(a) && e.setAttribute("aria-selected", String(a)), a ? (e.removeAttribute("tabindex"), n.hidden = !1, r && e.focus()) : (e.setAttribute("tabindex", "-1"), n.hidden = !0), this.syncPanelTabindex(n, a);
|
|
809
|
+
}), i && a !== t && this.dispatchEvent(new Event("change")), a !== t;
|
|
810
|
+
}
|
|
811
|
+
syncPanelTabindex(e, t) {
|
|
812
|
+
let n = me(e).filter((t) => t !== e);
|
|
813
|
+
if (t && !this.hasAuthorManagedTabindex(e) && n.length === 0) {
|
|
814
|
+
e.setAttribute("tabindex", "0"), this.managedPanelTabindex.add(e);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
this.managedPanelTabindex.has(e) && (e.removeAttribute("tabindex"), this.managedPanelTabindex.delete(e));
|
|
818
|
+
}
|
|
819
|
+
hasAuthorManagedTabindex(e) {
|
|
820
|
+
return e.hasAttribute("tabindex") && !this.managedPanelTabindex.has(e);
|
|
821
|
+
}
|
|
822
|
+
}, ve = class extends HTMLElement {
|
|
823
|
+
structureSync;
|
|
824
|
+
connectedCallback() {
|
|
825
|
+
this.hasAttribute("role") || this.setAttribute("role", "toolbar"), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.addEventListener("focus", this.onFocus), this.addEventListener("keydown", this.onKeyDown), this.structureSync ||= N(this, {
|
|
826
|
+
subtree: !0,
|
|
827
|
+
childList: !0,
|
|
828
|
+
attributes: !0,
|
|
829
|
+
attributeFilter: [
|
|
830
|
+
"disabled",
|
|
831
|
+
"hidden",
|
|
832
|
+
"aria-disabled"
|
|
833
|
+
]
|
|
834
|
+
}, () => this.syncControls()), this.structureSync.observe(), this.structureSync.queue();
|
|
835
|
+
}
|
|
836
|
+
disconnectedCallback() {
|
|
837
|
+
this.removeEventListener("focus", this.onFocus), this.removeEventListener("keydown", this.onKeyDown), this.structureSync?.disconnect();
|
|
838
|
+
}
|
|
839
|
+
onFocus = (e) => {
|
|
840
|
+
e.target === this && (this.removeAttribute("tabindex"), this.syncControls()?.focus());
|
|
841
|
+
};
|
|
842
|
+
onKeyDown = (e) => {
|
|
843
|
+
let t = this.controls, n = t.indexOf(e.target);
|
|
844
|
+
if (n === -1) return;
|
|
845
|
+
let r = F(e.key, {
|
|
846
|
+
currentIndex: n,
|
|
847
|
+
length: t.length,
|
|
848
|
+
vertical: this.vertical
|
|
849
|
+
});
|
|
850
|
+
if (r === void 0) return;
|
|
851
|
+
let i = t[r];
|
|
852
|
+
this.syncCurrentControl(t, i), i?.focus(), e.preventDefault();
|
|
853
|
+
};
|
|
854
|
+
syncControls() {
|
|
855
|
+
let e = this.controls;
|
|
856
|
+
if (!e.length) {
|
|
857
|
+
this.setAttribute("tabindex", "0");
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
let t = P(this).activeElement, n = this.hasAttribute("tabindex") ? e[0] : e.find((e) => e === t) || e.find((e) => e.getAttribute("tabindex") === "0") || e[0];
|
|
861
|
+
return this.syncCurrentControl(e, n), n;
|
|
862
|
+
}
|
|
863
|
+
syncCurrentControl(e, t) {
|
|
864
|
+
e.forEach((e) => {
|
|
865
|
+
e.setAttribute("tabindex", e === t ? "0" : "-1");
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
get vertical() {
|
|
869
|
+
return this.getAttribute("aria-orientation") === "vertical";
|
|
870
|
+
}
|
|
871
|
+
get controls() {
|
|
872
|
+
return he(this);
|
|
873
|
+
}
|
|
874
|
+
}, ye = 0, be = class e extends HTMLElement {
|
|
875
|
+
static delay = 100;
|
|
876
|
+
static observedAttributes = [
|
|
877
|
+
"disabled",
|
|
878
|
+
"for",
|
|
879
|
+
"id"
|
|
880
|
+
];
|
|
881
|
+
owner;
|
|
882
|
+
timeout;
|
|
883
|
+
sync = M(this, () => this.syncOwner());
|
|
884
|
+
ownerObserver;
|
|
885
|
+
siblingObserver;
|
|
886
|
+
managedDescription;
|
|
887
|
+
connectedCallback() {
|
|
888
|
+
this.hasAttribute("popover") || this.setAttribute("popover", "hint"), this.hasAttribute("role") || this.setAttribute("role", "tooltip"), this.ensureTooltipId(), this.addEventListener("toggle", this.onToggle), this.addEventListener("pointerenter", this.onTooltipPointerEnter), this.addEventListener("pointerleave", this.onInteractivePointerLeave), this.syncOwner();
|
|
889
|
+
}
|
|
890
|
+
disconnectedCallback() {
|
|
891
|
+
this.removeEventListener("toggle", this.onToggle), this.removeEventListener("pointerenter", this.onTooltipPointerEnter), this.removeEventListener("pointerleave", this.onInteractivePointerLeave), this.ownerDocument.removeEventListener("keydown", this.onDocumentKeyDown), this.siblingObserver?.disconnect(), this.sync.disconnect(), this.setOwner(void 0), clearTimeout(this.timeout);
|
|
892
|
+
}
|
|
893
|
+
attributeChangedCallback(e, t, n) {
|
|
894
|
+
!this.isConnected || t === n || (e === "id" && !n && this.ensureTooltipId(), this.syncOwner());
|
|
895
|
+
}
|
|
896
|
+
get disabled() {
|
|
897
|
+
return this.hasAttribute("disabled");
|
|
898
|
+
}
|
|
899
|
+
set disabled(e) {
|
|
900
|
+
e ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
901
|
+
}
|
|
902
|
+
show(e = this.resolveOwner()) {
|
|
903
|
+
clearTimeout(this.timeout), this.syncOwner(e);
|
|
904
|
+
let t = this.owner;
|
|
905
|
+
!t || this.matches(":popover-open") || this.showPopover?.({ source: t });
|
|
906
|
+
}
|
|
907
|
+
hide() {
|
|
908
|
+
clearTimeout(this.timeout), this.matches(":popover-open") && this.hidePopover();
|
|
909
|
+
}
|
|
910
|
+
onToggle = (e) => {
|
|
911
|
+
if (e.target === this) {
|
|
912
|
+
if (e.newState === "open") {
|
|
913
|
+
this.ownerDocument.addEventListener("keydown", this.onDocumentKeyDown);
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
this.ownerDocument.removeEventListener("keydown", this.onDocumentKeyDown);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
onDocumentKeyDown = (e) => {
|
|
920
|
+
e.key === "Escape" && this.hide();
|
|
921
|
+
};
|
|
922
|
+
syncOwner(e = this.resolveOwner()) {
|
|
923
|
+
if (this.siblingObserver ??= new MutationObserver(this.sync.queue), this.siblingObserver.disconnect(), !this.hasAttribute("for") && this.parentElement && this.siblingObserver.observe(this.parentElement, { childList: !0 }), !e) {
|
|
924
|
+
this.hide(), this.setOwner(void 0);
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
this.owner && this.owner !== e && this.matches(":popover-open") && this.hide(), this.setOwner(e);
|
|
928
|
+
}
|
|
929
|
+
resolveOwner(e) {
|
|
930
|
+
let t = e ?? (this.hasAttribute("for") ? this.resolveExplicitOwner() : this.previousElementSibling instanceof HTMLElement ? this.previousElementSibling : void 0);
|
|
931
|
+
if (!(this.disabled || !t || !t.isConnected || t === this || this.isOwnerDisabled(t))) return t;
|
|
932
|
+
}
|
|
933
|
+
resolveExplicitOwner() {
|
|
934
|
+
let e = this.getAttribute("for");
|
|
935
|
+
if (!e) return;
|
|
936
|
+
let t = this.getRootNode(), n = t instanceof ShadowRoot && t.querySelector(`#${CSS.escape(e)}`) || this.ownerDocument.getElementById(e);
|
|
937
|
+
return n instanceof HTMLElement ? n : void 0;
|
|
938
|
+
}
|
|
939
|
+
setOwner(e) {
|
|
940
|
+
let t = this.owner !== e;
|
|
941
|
+
t && this.owner && (this.owner.removeEventListener("focusin", this.onOwnerFocusIn), this.owner.removeEventListener("focusout", this.onOwnerFocusOut), this.owner.removeEventListener("pointerenter", this.onOwnerPointerEnter), this.owner.removeEventListener("pointerleave", this.onInteractivePointerLeave), this.owner.removeEventListener("click", this.onOwnerClick)), this.owner = e, this.updateManagedDescription(e), this.ownerObserver?.disconnect(), e && (this.ownerObserver ??= new MutationObserver(this.sync.queue), this.ownerObserver.observe(e, {
|
|
942
|
+
attributes: !0,
|
|
943
|
+
attributeFilter: [
|
|
944
|
+
"aria-describedby",
|
|
945
|
+
"aria-disabled",
|
|
946
|
+
"disabled"
|
|
947
|
+
]
|
|
948
|
+
}), t && (e.addEventListener("focusin", this.onOwnerFocusIn), e.addEventListener("focusout", this.onOwnerFocusOut), e.addEventListener("pointerenter", this.onOwnerPointerEnter), e.addEventListener("pointerleave", this.onInteractivePointerLeave), e.addEventListener("click", this.onOwnerClick)));
|
|
949
|
+
}
|
|
950
|
+
onOwnerFocusIn = () => {
|
|
951
|
+
!this.owner || !this.owner.matches(":focus-visible") || this.show(this.owner);
|
|
952
|
+
};
|
|
953
|
+
onOwnerFocusOut = (e) => {
|
|
954
|
+
this.containsInteractiveTarget(e.relatedTarget) || this.hide();
|
|
955
|
+
};
|
|
956
|
+
onOwnerPointerEnter = (e) => {
|
|
957
|
+
this.supportsHoverInteraction(e) && this.owner && (this.containsInteractiveTarget(e.relatedTarget) || this.afterDelay(() => this.show(this.owner)));
|
|
958
|
+
};
|
|
959
|
+
onTooltipPointerEnter = (e) => {
|
|
960
|
+
this.supportsHoverInteraction(e) && (this.containsInteractiveTarget(e.relatedTarget) || clearTimeout(this.timeout));
|
|
961
|
+
};
|
|
962
|
+
onInteractivePointerLeave = (e) => {
|
|
963
|
+
e.pointerType && e.pointerType !== "mouse" || this.containsInteractiveTarget(e.relatedTarget) || this.afterDelay(this.hide);
|
|
964
|
+
};
|
|
965
|
+
onOwnerClick = () => {
|
|
966
|
+
this.hide();
|
|
967
|
+
};
|
|
968
|
+
afterDelay(t) {
|
|
969
|
+
clearTimeout(this.timeout);
|
|
970
|
+
let n = parseInt(this.getAttribute("delay") || "");
|
|
971
|
+
this.timeout = window.setTimeout(t, isNaN(n) ? e.delay : n);
|
|
972
|
+
}
|
|
973
|
+
containsInteractiveTarget(e) {
|
|
974
|
+
return e instanceof Node && (this.contains(e) || !!this.owner && this.owner.contains(e));
|
|
975
|
+
}
|
|
976
|
+
updateManagedDescription(e) {
|
|
977
|
+
let t = e ? this.ensureTooltipId() : void 0;
|
|
978
|
+
if (this.managedDescription && (this.managedDescription.owner !== e || this.managedDescription.id !== t)) {
|
|
979
|
+
let e = this.managedDescription, t = this.getDescriptionTokens(e.owner).filter((t) => t !== e.id);
|
|
980
|
+
t.length ? e.owner.setAttribute("aria-describedby", t.join(" ")) : e.owner.removeAttribute("aria-describedby"), this.managedDescription = void 0;
|
|
981
|
+
}
|
|
982
|
+
if (!e || !t || this.managedDescription) return;
|
|
983
|
+
let n = this.getDescriptionTokens(e);
|
|
984
|
+
n.includes(t) || (e.setAttribute("aria-describedby", [...n, t].join(" ")), this.managedDescription = {
|
|
985
|
+
owner: e,
|
|
986
|
+
id: t
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
getDescriptionTokens(e) {
|
|
990
|
+
return (e.getAttribute("aria-describedby") || "").split(/\s+/).filter(Boolean);
|
|
991
|
+
}
|
|
992
|
+
ensureTooltipId() {
|
|
993
|
+
return this.id ||= `ui-tooltip-${++ye}`, this.id;
|
|
994
|
+
}
|
|
995
|
+
supportsHoverInteraction(e) {
|
|
996
|
+
return (!e.pointerType || e.pointerType === "mouse") && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
|
|
997
|
+
}
|
|
998
|
+
isOwnerDisabled(e) {
|
|
999
|
+
return e.hasAttribute("disabled") || e.getAttribute("aria-disabled") === "true";
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
//#endregion
|
|
1003
|
+
export { j as AlertsElement, I as MenuElement, _e as TabsElement, ve as ToolbarElement, be as TooltipElement };
|