@mintplayer/web-components 2.2.0 → 2.4.0
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/a11y/index.mjs +26 -2
- package/a11y/src/dismiss-stack.d.ts +25 -0
- package/a11y/src/error-text.d.ts +41 -0
- package/a11y/src/focus-restore.d.ts +116 -0
- package/a11y/src/focus-trap.d.ts +69 -0
- package/a11y/src/form-associated.d.ts +48 -0
- package/a11y/src/host-aria.d.ts +154 -0
- package/a11y/src/index.d.ts +16 -0
- package/a11y/src/inert-regions.d.ts +52 -0
- package/a11y/src/live-announcer.d.ts +8 -0
- package/a11y/src/roving-focus.d.ts +118 -0
- package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
- package/a11y/src/testing/index.d.ts +1 -0
- package/accordion/index.mjs +180 -174
- package/accordion/src/components/mp-accordion.d.ts +18 -13
- package/calendar/index.mjs +1 -1
- package/calendar/src/mp-calendar.element.d.ts +2 -0
- package/carousel/index.mjs +211 -164
- package/carousel/src/components/mp-carousel.d.ts +1 -0
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +59 -1
- package/chunks/color-CpFtrIoX.mjs +899 -0
- package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
- package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
- package/chunks/form-associated-axmc5sY0.mjs +58 -0
- package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
- package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
- package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
- package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
- package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
- package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
- package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
- package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
- package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
- package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
- package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
- package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
- package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
- package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
- package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
- package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
- package/chunks/roving-focus-CrL9982a.mjs +129 -0
- package/code-snippet/index.mjs +21 -13
- package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/mp-datatable.d.ts +50 -0
- package/datatable/src/types/index.d.ts +2 -0
- package/datatable/src/types/labels.d.ts +30 -0
- package/datepicker/index.mjs +45 -22
- package/datepicker/src/mp-datepicker.element.d.ts +30 -0
- package/datetime-picker/index.mjs +15 -9
- package/dock/index.mjs +365 -209
- package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
- package/dropdown-menu/index.mjs +135 -90
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
- package/file-manager/index.mjs +279 -214
- package/file-manager/src/components/mp-file-manager.d.ts +22 -0
- package/file-manager/src/types/messages.d.ts +9 -0
- package/multi-range/index.mjs +26 -10
- package/multi-range/src/mint-multi-range.element.d.ts +7 -0
- package/navbar/index.mjs +53 -39
- package/navbar/src/components/mp-navbar.d.ts +1 -0
- package/otp-input/index.mjs +82 -48
- package/otp-input/src/mint-otp-input.element.d.ts +31 -3
- package/overlay/index.mjs +2 -258
- package/overlay/src/overlay-controller.d.ts +64 -4
- package/package.json +9 -1
- package/pagination/index.mjs +1 -1
- package/query-builder/index.mjs +117 -87
- package/query-builder/src/model/messages.d.ts +9 -0
- package/radio/index.mjs +2 -160
- package/radio/src/components/mp-radio.d.ts +58 -3
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.mjs +145 -0
- package/radio-group/src/components/mp-radio-group.d.ts +52 -0
- package/radio-group/src/index.d.ts +1 -0
- package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
- package/ribbon/index.mjs +316 -304
- package/ribbon/src/mp-ribbon.element.d.ts +16 -0
- package/scheduler/index.mjs +892 -493
- package/scheduler/src/components/mp-scheduler.d.ts +30 -0
- package/scheduler/src/input/input-handler.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +43 -6
- package/scheduler/src/views/timeline-view.d.ts +6 -0
- package/scheduler-core/index.mjs +73 -70
- package/scheduler-core/src/models/index.d.ts +1 -0
- package/scheduler-core/src/models/messages.d.ts +69 -0
- package/scheduler-core/src/models/options.d.ts +4 -0
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +60 -3
- package/shell/index.mjs +142 -31
- package/shell/src/components/mp-shell.d.ts +1 -0
- package/signature-pad/index.d.ts +1 -0
- package/signature-pad/index.mjs +230 -0
- package/signature-pad/src/index.d.ts +2 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
- package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
- package/signature-pad/src/types/signature.d.ts +12 -0
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +7 -0
- package/tab-control/index.mjs +1 -1
- package/tile-manager/index.mjs +110 -93
- package/timeline/index.mjs +138 -54
- package/timeline/src/components/mp-timeline.d.ts +15 -0
- package/timepicker/index.mjs +1 -1
- package/timepicker/src/mp-time-list.element.d.ts +13 -4
- package/timepicker/src/mp-timepicker.element.d.ts +29 -0
- package/toggle-button/index.mjs +1 -1
- package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
- package/tree-select/index.mjs +233 -121
- package/tree-select/src/components/mp-tree-select.d.ts +37 -0
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +10 -1
- package/chunks/color-CyamnJnn.mjs +0 -847
- package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
function c(a = document) {
|
|
2
|
+
let t = a.activeElement;
|
|
3
|
+
for (; t?.shadowRoot?.activeElement; )
|
|
4
|
+
t = t.shadowRoot.activeElement;
|
|
5
|
+
return t;
|
|
6
|
+
}
|
|
7
|
+
class h {
|
|
8
|
+
constructor(t, e) {
|
|
9
|
+
this.root = t, this.options = e, this.snapshot = null, this.retried = !1;
|
|
10
|
+
}
|
|
11
|
+
/** Snapshot the focused item's key and index. No-op unless focus is inside the root. */
|
|
12
|
+
capture() {
|
|
13
|
+
this.snapshot = null, this.retried = !1;
|
|
14
|
+
const t = this.root();
|
|
15
|
+
if (!t) return;
|
|
16
|
+
const e = this.activeInsideRoot(t);
|
|
17
|
+
if (!e) return;
|
|
18
|
+
const s = e.shadowRoot ? c(e.shadowRoot) : e;
|
|
19
|
+
if (!s || s.assignedSlot) return;
|
|
20
|
+
const o = this.candidates(), i = this.resolveKey(s);
|
|
21
|
+
if (i === null) return;
|
|
22
|
+
const n = o.indexOf(s);
|
|
23
|
+
this.snapshot = { key: i, index: n < 0 ? 0 : n };
|
|
24
|
+
}
|
|
25
|
+
/** Re-focus after the rebuild. Safe to call with nothing captured. */
|
|
26
|
+
restore() {
|
|
27
|
+
const t = this.snapshot;
|
|
28
|
+
if (!t) return "unchanged";
|
|
29
|
+
const e = this.root();
|
|
30
|
+
if (!e)
|
|
31
|
+
return this.snapshot = null, "none";
|
|
32
|
+
const s = this.candidates(), o = { preventScroll: this.options.preventScroll ?? !0 }, i = s.find((r) => this.resolveKey(r) === t.key);
|
|
33
|
+
if (i)
|
|
34
|
+
return !this.tryFocus(i, o) && !this.retried ? (this.retried = !0, queueMicrotask(() => this.restore()), "same") : (this.snapshot = null, "same");
|
|
35
|
+
if (s.length > 0) {
|
|
36
|
+
const r = s[Math.min(t.index, s.length - 1)];
|
|
37
|
+
return this.tryFocus(r, o), this.options.announce?.(`${this.options.nameOf?.(r) ?? "Item"} focused.`), this.snapshot = null, "neighbour";
|
|
38
|
+
}
|
|
39
|
+
const n = this.options.container?.() ?? e.firstElementChild;
|
|
40
|
+
return n ? (n.hasAttribute("tabindex") || n.setAttribute("tabindex", "-1"), this.tryFocus(n, o), this.options.announce?.("Nothing left to focus."), this.snapshot = null, "container") : (this.snapshot = null, "none");
|
|
41
|
+
}
|
|
42
|
+
/** `capture()` → `rebuild()` → `restore()`. The shape most call sites want. */
|
|
43
|
+
around(t) {
|
|
44
|
+
this.capture();
|
|
45
|
+
try {
|
|
46
|
+
return t();
|
|
47
|
+
} finally {
|
|
48
|
+
this.restore();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
candidates() {
|
|
52
|
+
const t = this.root();
|
|
53
|
+
return t ? Array.from(t.querySelectorAll(this.options.selector)) : [];
|
|
54
|
+
}
|
|
55
|
+
resolveKey(t) {
|
|
56
|
+
return this.options.keyOf ? this.options.keyOf(t) : t.id || t.dataset.focusKey || null;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The focused element within `root`, or null when focus is elsewhere.
|
|
60
|
+
*
|
|
61
|
+
* For a ShadowRoot this is exactly `activeElement`, which is null unless
|
|
62
|
+
* focus is inside that root — both the cheap check and the correctness
|
|
63
|
+
* guarantee. A plain element root has no such property, so fall back to a
|
|
64
|
+
* containment test against the deep active element.
|
|
65
|
+
*/
|
|
66
|
+
activeInsideRoot(t) {
|
|
67
|
+
if (t instanceof HTMLElement) {
|
|
68
|
+
const e = c();
|
|
69
|
+
return e && t.contains(e) ? e : null;
|
|
70
|
+
}
|
|
71
|
+
return t.activeElement;
|
|
72
|
+
}
|
|
73
|
+
tryFocus(t, e) {
|
|
74
|
+
t.focus(e);
|
|
75
|
+
const s = c();
|
|
76
|
+
return s === t || s !== null && t.contains(s);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
class u {
|
|
80
|
+
constructor(t, e) {
|
|
81
|
+
this.inner = e, t.addController(this);
|
|
82
|
+
}
|
|
83
|
+
hostUpdate() {
|
|
84
|
+
this.inner.capture();
|
|
85
|
+
}
|
|
86
|
+
hostUpdated() {
|
|
87
|
+
this.inner.restore();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
h as F,
|
|
92
|
+
u as a,
|
|
93
|
+
c as d
|
|
94
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { d as l } from "./focus-restore-DxuP1Oe2.mjs";
|
|
2
|
+
const s = [];
|
|
3
|
+
function b(n = "dismiss-frame") {
|
|
4
|
+
const t = Symbol(n);
|
|
5
|
+
return s.push(t), t;
|
|
6
|
+
}
|
|
7
|
+
function g(n) {
|
|
8
|
+
const t = s.lastIndexOf(n);
|
|
9
|
+
t >= 0 && s.splice(t, 1);
|
|
10
|
+
}
|
|
11
|
+
function m(n) {
|
|
12
|
+
return s.length > 0 && s[s.length - 1] === n;
|
|
13
|
+
}
|
|
14
|
+
function v() {
|
|
15
|
+
return s.length > 0 ? s[s.length - 1] : null;
|
|
16
|
+
}
|
|
17
|
+
function y() {
|
|
18
|
+
return s.length;
|
|
19
|
+
}
|
|
20
|
+
function S() {
|
|
21
|
+
s.length = 0;
|
|
22
|
+
}
|
|
23
|
+
const x = { push: b, release: g, isTop: m, peek: v, depth: y, resetForTesting: S };
|
|
24
|
+
class D {
|
|
25
|
+
constructor(t, e = {}) {
|
|
26
|
+
this.region = t, this.active = !1, this.restoreTo = null, this.onKeyDown = (i) => {
|
|
27
|
+
if (i.key !== "Tab" || !this.active || this.options.enabled && !this.options.enabled()) return;
|
|
28
|
+
const o = this.region();
|
|
29
|
+
if (!o || !o.isConnected) return;
|
|
30
|
+
const r = h(o);
|
|
31
|
+
if (r.length === 0) {
|
|
32
|
+
i.preventDefault();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const f = r[0], u = r[r.length - 1], c = l();
|
|
36
|
+
if (!(c !== null && (o === c || T(o, c)))) {
|
|
37
|
+
i.preventDefault(), (i.shiftKey ? u : f).focus({ preventScroll: !0 });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
i.shiftKey && c === f ? (i.preventDefault(), u.focus({ preventScroll: !0 })) : !i.shiftKey && c === u && (i.preventDefault(), f.focus({ preventScroll: !0 }));
|
|
41
|
+
}, this.options = e;
|
|
42
|
+
}
|
|
43
|
+
get isActive() {
|
|
44
|
+
return this.active;
|
|
45
|
+
}
|
|
46
|
+
activate() {
|
|
47
|
+
if (this.active) return;
|
|
48
|
+
const t = this.region();
|
|
49
|
+
if (!t) return;
|
|
50
|
+
const e = l();
|
|
51
|
+
this.restoreTo = e instanceof HTMLElement ? e : null, this.active = !0, t.ownerDocument.addEventListener("keydown", this.onKeyDown, !0);
|
|
52
|
+
let i = this.options.initialFocus ?? "first";
|
|
53
|
+
if (typeof i == "function" && (i = i() ?? "first"), i instanceof HTMLElement)
|
|
54
|
+
i.focus({ preventScroll: !0 });
|
|
55
|
+
else if (i === "self")
|
|
56
|
+
t.hasAttribute("tabindex") || t.setAttribute("tabindex", "-1"), t.focus({ preventScroll: !0 });
|
|
57
|
+
else if (i === "first") {
|
|
58
|
+
const o = h(t)[0];
|
|
59
|
+
o ? o.focus({ preventScroll: !0 }) : (t.hasAttribute("tabindex") || t.setAttribute("tabindex", "-1"), t.focus({ preventScroll: !0 }));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
deactivate() {
|
|
63
|
+
if (!this.active) return;
|
|
64
|
+
this.active = !1, (this.region()?.ownerDocument ?? document).removeEventListener("keydown", this.onKeyDown, !0), (this.options.returnFocus ?? !0) && this.restoreTo?.isConnected && this.restoreTo.focus({ preventScroll: !0 }), this.restoreTo = null;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function T(n, t) {
|
|
68
|
+
let e = t;
|
|
69
|
+
for (; e; ) {
|
|
70
|
+
if (e === n) return !0;
|
|
71
|
+
if (e instanceof Element && e.assignedSlot) {
|
|
72
|
+
e = e.assignedSlot;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const i = e.parentNode;
|
|
76
|
+
e = i instanceof ShadowRoot ? i.host : i;
|
|
77
|
+
}
|
|
78
|
+
return !1;
|
|
79
|
+
}
|
|
80
|
+
const E = [
|
|
81
|
+
"a[href]",
|
|
82
|
+
"button",
|
|
83
|
+
"input",
|
|
84
|
+
"select",
|
|
85
|
+
"textarea",
|
|
86
|
+
"summary",
|
|
87
|
+
"audio[controls]",
|
|
88
|
+
"video[controls]",
|
|
89
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
90
|
+
"[tabindex]"
|
|
91
|
+
].join(",");
|
|
92
|
+
function h(n) {
|
|
93
|
+
const t = [];
|
|
94
|
+
return a(n, t), t;
|
|
95
|
+
}
|
|
96
|
+
function a(n, t) {
|
|
97
|
+
for (const e of Array.from(n.children))
|
|
98
|
+
if (e instanceof HTMLElement && !p(e)) {
|
|
99
|
+
if (e instanceof HTMLSlotElement) {
|
|
100
|
+
const i = e.assignedElements({ flatten: !0 }), o = i.length > 0 ? i : Array.from(e.children);
|
|
101
|
+
for (const r of o)
|
|
102
|
+
!(r instanceof HTMLElement) || p(r) || (d(r) && t.push(r), a(r, t));
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
d(e) && t.push(e), e.shadowRoot && a(e.shadowRoot, t), a(e, t);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function d(n) {
|
|
109
|
+
return n.tabIndex < 0 || n.hasAttribute("inert") || n.closest("[inert]") || n.matches(":disabled") || n.getAttribute("aria-hidden") === "true" ? !1 : n.matches(E);
|
|
110
|
+
}
|
|
111
|
+
function p(n) {
|
|
112
|
+
if (n.hidden) return !0;
|
|
113
|
+
const t = n.style.display, e = n.style.visibility;
|
|
114
|
+
return t === "none" || e === "hidden";
|
|
115
|
+
}
|
|
116
|
+
export {
|
|
117
|
+
D as F,
|
|
118
|
+
T as a,
|
|
119
|
+
h as c,
|
|
120
|
+
x as d
|
|
121
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { nothing as o, html as m } from "lit";
|
|
2
|
+
import { s as d } from "./host-aria-WSGs7SPQ.mjs";
|
|
3
|
+
const n = "invalid-feedback", u = { id: o, node: o };
|
|
4
|
+
function b(e, s, i) {
|
|
5
|
+
const t = s?.trim();
|
|
6
|
+
return !t || !i ? u : {
|
|
7
|
+
id: e,
|
|
8
|
+
node: m`<small class=${n} id=${e}>${t}</small>`
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function F(e) {
|
|
12
|
+
const s = e?.querySelector(`.${n}`);
|
|
13
|
+
return s ? [s] : [];
|
|
14
|
+
}
|
|
15
|
+
function y(e) {
|
|
16
|
+
class s extends e {
|
|
17
|
+
static {
|
|
18
|
+
this.formAssociated = !0;
|
|
19
|
+
}
|
|
20
|
+
/** Effective disabled per the platform, as last reported by the UA. */
|
|
21
|
+
#e = !1;
|
|
22
|
+
get internals() {
|
|
23
|
+
return d(this);
|
|
24
|
+
}
|
|
25
|
+
get effectiveDisabled() {
|
|
26
|
+
return this.#e || this.hasAttribute("disabled");
|
|
27
|
+
}
|
|
28
|
+
#t() {
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
/** Push the host's current value into the form. Call on every change. */
|
|
32
|
+
syncFormValue() {
|
|
33
|
+
const t = this.internals;
|
|
34
|
+
!t || typeof t.setFormValue != "function" || t.setFormValue(this.#t().formValue());
|
|
35
|
+
}
|
|
36
|
+
setFormValidity(t, a) {
|
|
37
|
+
const r = this.internals;
|
|
38
|
+
if (!r || typeof r.setValidity != "function") return;
|
|
39
|
+
const l = this.#t().formValidityAnchor?.() ?? void 0, c = Object.values(t).some(Boolean);
|
|
40
|
+
r.setValidity(t, c ? a : void 0, l);
|
|
41
|
+
}
|
|
42
|
+
formDisabledCallback(t) {
|
|
43
|
+
this.#e = t, this.requestUpdate?.();
|
|
44
|
+
}
|
|
45
|
+
formResetCallback() {
|
|
46
|
+
this.#t().formReset(), this.syncFormValue();
|
|
47
|
+
}
|
|
48
|
+
formStateRestoreCallback(t) {
|
|
49
|
+
this.#t().formRestore?.(t), this.syncFormValue();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return s;
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
y as F,
|
|
56
|
+
F as a,
|
|
57
|
+
b as e
|
|
58
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
const c = /* @__PURE__ */ new WeakMap();
|
|
2
|
+
function y(i) {
|
|
3
|
+
if (c.has(i)) return c.get(i) ?? null;
|
|
4
|
+
let t = null;
|
|
5
|
+
const e = i.attachInternals;
|
|
6
|
+
if (typeof e == "function")
|
|
7
|
+
try {
|
|
8
|
+
t = e.call(i);
|
|
9
|
+
} catch {
|
|
10
|
+
t = null;
|
|
11
|
+
}
|
|
12
|
+
return c.set(i, t), t;
|
|
13
|
+
}
|
|
14
|
+
function E() {
|
|
15
|
+
return typeof ElementInternals < "u" && "ariaLabelledByElements" in ElementInternals.prototype && typeof Element < "u" && "ariaLabelledByElements" in Element.prototype;
|
|
16
|
+
}
|
|
17
|
+
const m = ["aria-labelledby", "aria-describedby"];
|
|
18
|
+
let f = !1;
|
|
19
|
+
class A {
|
|
20
|
+
constructor(t, e = {}) {
|
|
21
|
+
this.host = t, this.options = e, this.internals = y(t), this.referenceAttributes = e.referenceAttributes ?? m, e.role && this.internals ? this.internals.role = e.role : e.role && !t.hasAttribute("role") && t.setAttribute("role", e.role);
|
|
22
|
+
}
|
|
23
|
+
/** True when the role and state are going through `ElementInternals`. */
|
|
24
|
+
get usesInternals() {
|
|
25
|
+
return this.internals !== null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Reflect ARIA state onto the host.
|
|
29
|
+
*
|
|
30
|
+
* Call from `render()` or `updated()` — from wherever the visual state is
|
|
31
|
+
* derived — never as a side effect of an event handler. State written only on
|
|
32
|
+
* an event is stale for every other path that changes it (programmatic
|
|
33
|
+
* setters, server-rendered markup, a sibling closing this one), which is the
|
|
34
|
+
* defect class behind the frozen `aria-expanded` and write-only-when-true
|
|
35
|
+
* `aria-pressed` findings.
|
|
36
|
+
*/
|
|
37
|
+
setState(t) {
|
|
38
|
+
for (const [e, a] of Object.entries(t)) {
|
|
39
|
+
const r = v[e];
|
|
40
|
+
if (r) {
|
|
41
|
+
if (a == null) {
|
|
42
|
+
this.clear(e, r);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
this.write(e, r, String(a));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the host's IDREF attributes into cross-root element references.
|
|
51
|
+
*
|
|
52
|
+
* Call from `connectedCallback` and whenever a reference attribute changes.
|
|
53
|
+
* Returns the attributes it could not honour, so a caller can warn.
|
|
54
|
+
*/
|
|
55
|
+
syncReferences() {
|
|
56
|
+
const e = this.options.referenceTarget?.() ?? null ?? this.internals;
|
|
57
|
+
if (!e || !E()) {
|
|
58
|
+
const n = this.referenceAttributes.filter((l) => this.host.hasAttribute(l));
|
|
59
|
+
return n.length > 0 && !f && (f = !0, console.warn(
|
|
60
|
+
`[a11y] This browser cannot assign ARIA element references, so ${n.join(", ")} on <${this.host.localName}> cannot cross its shadow boundary. Use the component's label property instead.`
|
|
61
|
+
)), n;
|
|
62
|
+
}
|
|
63
|
+
const a = [], r = this.host.getRootNode();
|
|
64
|
+
for (const n of this.referenceAttributes) {
|
|
65
|
+
const l = R[n];
|
|
66
|
+
if (!l) continue;
|
|
67
|
+
const s = n === "aria-describedby" ? this.options.describedByExtras?.() ?? [] : [], u = this.host.getAttribute(n);
|
|
68
|
+
if (u === null) {
|
|
69
|
+
this.assignReferences(e, l, s.length > 0 ? s : null);
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const d = u.split(/\s+/).filter(Boolean), h = d.map((o) => r.getElementById?.(o) ?? null).filter((o) => o instanceof HTMLElement);
|
|
73
|
+
h.length !== d.length && a.push(n);
|
|
74
|
+
const b = [...h, ...s];
|
|
75
|
+
this.assignReferences(e, l, b.length > 0 ? b : null);
|
|
76
|
+
}
|
|
77
|
+
return a;
|
|
78
|
+
}
|
|
79
|
+
assignReferences(t, e, a) {
|
|
80
|
+
try {
|
|
81
|
+
t[e] = a;
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
write(t, e, a) {
|
|
86
|
+
if (this.internals) {
|
|
87
|
+
const r = p[t];
|
|
88
|
+
if (r && r in this.internals) {
|
|
89
|
+
this.internals[r] = a;
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
this.host.setAttribute(e, a);
|
|
94
|
+
}
|
|
95
|
+
clear(t, e) {
|
|
96
|
+
if (this.internals) {
|
|
97
|
+
const a = p[t];
|
|
98
|
+
if (a && a in this.internals) {
|
|
99
|
+
this.internals[a] = null;
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
this.host.removeAttribute(e);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
const v = {
|
|
107
|
+
expanded: "aria-expanded",
|
|
108
|
+
selected: "aria-selected",
|
|
109
|
+
checked: "aria-checked",
|
|
110
|
+
pressed: "aria-pressed",
|
|
111
|
+
disabled: "aria-disabled",
|
|
112
|
+
invalid: "aria-invalid",
|
|
113
|
+
required: "aria-required",
|
|
114
|
+
readOnly: "aria-readonly",
|
|
115
|
+
current: "aria-current",
|
|
116
|
+
hasPopup: "aria-haspopup",
|
|
117
|
+
level: "aria-level",
|
|
118
|
+
orientation: "aria-orientation",
|
|
119
|
+
multiSelectable: "aria-multiselectable",
|
|
120
|
+
valueNow: "aria-valuenow",
|
|
121
|
+
valueMin: "aria-valuemin",
|
|
122
|
+
valueMax: "aria-valuemax",
|
|
123
|
+
valueText: "aria-valuetext",
|
|
124
|
+
label: "aria-label"
|
|
125
|
+
}, p = {
|
|
126
|
+
expanded: "ariaExpanded",
|
|
127
|
+
selected: "ariaSelected",
|
|
128
|
+
checked: "ariaChecked",
|
|
129
|
+
pressed: "ariaPressed",
|
|
130
|
+
disabled: "ariaDisabled",
|
|
131
|
+
invalid: "ariaInvalid",
|
|
132
|
+
required: "ariaRequired",
|
|
133
|
+
readOnly: "ariaReadOnly",
|
|
134
|
+
current: "ariaCurrent",
|
|
135
|
+
hasPopup: "ariaHasPopup",
|
|
136
|
+
level: "ariaLevel",
|
|
137
|
+
orientation: "ariaOrientation",
|
|
138
|
+
multiSelectable: "ariaMultiSelectable",
|
|
139
|
+
valueNow: "ariaValueNow",
|
|
140
|
+
valueMin: "ariaValueMin",
|
|
141
|
+
valueMax: "ariaValueMax",
|
|
142
|
+
valueText: "ariaValueText",
|
|
143
|
+
label: "ariaLabel"
|
|
144
|
+
}, R = {
|
|
145
|
+
"aria-labelledby": "ariaLabelledByElements",
|
|
146
|
+
"aria-describedby": "ariaDescribedByElements"
|
|
147
|
+
};
|
|
148
|
+
export {
|
|
149
|
+
A as H,
|
|
150
|
+
E as a,
|
|
151
|
+
y as s
|
|
152
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { d as f } from "./focus-restore-DxuP1Oe2.mjs";
|
|
2
|
+
function l() {
|
|
3
|
+
const o = /* @__PURE__ */ new Set();
|
|
4
|
+
let r = [], n = 0;
|
|
5
|
+
const s = (e) => {
|
|
6
|
+
const t = f();
|
|
7
|
+
if (t && (e === t || e.contains(t))) {
|
|
8
|
+
const c = d(e);
|
|
9
|
+
c ? c.focus({ preventScroll: !0 }) : t instanceof HTMLElement && t.blur();
|
|
10
|
+
}
|
|
11
|
+
e.setAttribute("inert", ""), e.setAttribute("aria-hidden", "true"), o.add(e);
|
|
12
|
+
}, a = (e) => {
|
|
13
|
+
e.removeAttribute("inert"), e.removeAttribute("aria-hidden");
|
|
14
|
+
}, i = () => {
|
|
15
|
+
const e = n > 0 ? /* @__PURE__ */ new Set() : new Set(r);
|
|
16
|
+
for (const t of o)
|
|
17
|
+
e.has(t) || (a(t), o.delete(t));
|
|
18
|
+
for (const t of e)
|
|
19
|
+
o.has(t) || s(t);
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
setHidden(e) {
|
|
23
|
+
r = Array.from(e), i();
|
|
24
|
+
},
|
|
25
|
+
suspend() {
|
|
26
|
+
n += 1, n === 1 && i();
|
|
27
|
+
},
|
|
28
|
+
resume() {
|
|
29
|
+
n !== 0 && (n -= 1, n === 0 && i());
|
|
30
|
+
},
|
|
31
|
+
dispose() {
|
|
32
|
+
for (const e of o) a(e);
|
|
33
|
+
o.clear(), r = [], n = 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function d(o) {
|
|
38
|
+
let r = o.parentElement;
|
|
39
|
+
for (; r; ) {
|
|
40
|
+
if (r.tabIndex >= 0) return r;
|
|
41
|
+
r = r.parentElement;
|
|
42
|
+
}
|
|
43
|
+
const n = o.getRootNode(), s = n instanceof ShadowRoot ? n.host : null;
|
|
44
|
+
return s instanceof HTMLElement && s.tabIndex >= 0 ? s : null;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
l as i
|
|
48
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { html as r } from "lit";
|
|
2
|
-
import { createRef as
|
|
3
|
-
const
|
|
4
|
-
class
|
|
1
|
+
import { nothing as s, html as r } from "lit";
|
|
2
|
+
import { createRef as n, ref as l } from "lit/directives/ref.js";
|
|
3
|
+
const o = "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0;";
|
|
4
|
+
class u {
|
|
5
5
|
constructor(e, t = {}) {
|
|
6
|
-
this.clearTimer = null, this.pendingMessage = null, this.regionRef =
|
|
6
|
+
this.clearTimer = null, this.pendingMessage = null, this.regionRef = n(), this.host = e, this.politeness = t.politeness ?? "polite", this.clearAfterMs = t.clearAfterMs ?? 1500, this.omitRole = t.omitRole ?? !1, e.addController(this);
|
|
7
7
|
}
|
|
8
8
|
hostUpdated() {
|
|
9
9
|
if (this.pendingMessage !== null && this.regionRef.value) {
|
|
@@ -24,13 +24,13 @@ class c {
|
|
|
24
24
|
}
|
|
25
25
|
/** Returns the live-region template fragment. Call once inside the host's render(). */
|
|
26
26
|
template() {
|
|
27
|
-
const e = this.politeness === "assertive" ? "alert" : "status";
|
|
27
|
+
const e = this.omitRole ? s : this.politeness === "assertive" ? "alert" : "status";
|
|
28
28
|
return r`<div
|
|
29
|
-
${
|
|
29
|
+
${l(this.regionRef)}
|
|
30
30
|
role=${e}
|
|
31
31
|
aria-live=${this.politeness}
|
|
32
32
|
aria-atomic="true"
|
|
33
|
-
style=${
|
|
33
|
+
style=${o}
|
|
34
34
|
></div>`;
|
|
35
35
|
}
|
|
36
36
|
writeMessage(e) {
|
|
@@ -54,5 +54,5 @@ class c {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
export {
|
|
57
|
-
|
|
57
|
+
u as L
|
|
58
58
|
};
|