@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { unsafeCSS as I, LitElement as S, nothing as h, html as b } from "lit";
|
|
2
|
-
|
|
2
|
+
import { repeat as j } from "lit/directives/repeat.js";
|
|
3
|
+
const G = I(`:host {
|
|
3
4
|
display: block;
|
|
4
5
|
--mp-pagination-bg: var(--bs-pagination-bg, transparent);
|
|
5
6
|
--mp-pagination-color: var(--bs-pagination-color, var(--bs-link-color, #0d6efd));
|
|
@@ -134,12 +135,12 @@ li:last-child .page-link {
|
|
|
134
135
|
white-space: nowrap !important;
|
|
135
136
|
border: 0 !important;
|
|
136
137
|
}`);
|
|
137
|
-
class
|
|
138
|
+
class H extends S {
|
|
138
139
|
constructor() {
|
|
139
140
|
super(...arguments), this._pageNumbers = [], this._selectedPageNumber = 1, this._numberOfBoxes = 0, this._showArrows = !0, this._size = "medium", this._ariaLabel = "Pagination";
|
|
140
141
|
}
|
|
141
142
|
static {
|
|
142
|
-
this.styles = [
|
|
143
|
+
this.styles = [G];
|
|
143
144
|
}
|
|
144
145
|
static get observedAttributes() {
|
|
145
146
|
return [
|
|
@@ -187,7 +188,7 @@ class G extends S {
|
|
|
187
188
|
}
|
|
188
189
|
attributeChangedCallback(e, r, n) {
|
|
189
190
|
if (super.attributeChangedCallback(e, r, n), e === "page-numbers" && n) {
|
|
190
|
-
const t = n.split(",").map((
|
|
191
|
+
const t = n.split(",").map((i) => Number(i.trim())).filter((i) => Number.isFinite(i));
|
|
191
192
|
this.pageNumbers = t;
|
|
192
193
|
} else if (e === "selected-page-number") {
|
|
193
194
|
const t = Number(n);
|
|
@@ -211,7 +212,7 @@ class G extends S {
|
|
|
211
212
|
}
|
|
212
213
|
/** Build the full layout — arrows + page items. Pure — no DOM access. */
|
|
213
214
|
computeLayout() {
|
|
214
|
-
return
|
|
215
|
+
return R(
|
|
215
216
|
this._pageNumbers,
|
|
216
217
|
this._selectedPageNumber,
|
|
217
218
|
this.effectiveBudget(),
|
|
@@ -235,7 +236,9 @@ class G extends S {
|
|
|
235
236
|
<span class="visually-hidden">Previous</span>
|
|
236
237
|
</button>
|
|
237
238
|
</li>` : h}
|
|
238
|
-
${
|
|
239
|
+
${j(
|
|
240
|
+
e.items,
|
|
241
|
+
(t, i) => t.kind === "gap" ? `gap-${i}` : `page-${t.page}`,
|
|
239
242
|
(t) => t.kind === "gap" ? b`<li>
|
|
240
243
|
<span class="ellipsis" aria-hidden="true">…</span>
|
|
241
244
|
</li>` : b`<li>
|
|
@@ -290,37 +293,37 @@ class G extends S {
|
|
|
290
293
|
n != null && this.selectPage(n);
|
|
291
294
|
}
|
|
292
295
|
}
|
|
293
|
-
function
|
|
296
|
+
function R(g, e, r, n) {
|
|
294
297
|
const t = g.length;
|
|
295
298
|
if (t === 0) return { showPrev: !1, showNext: !1, items: [] };
|
|
296
|
-
const
|
|
297
|
-
let v = !1, x = !1, p = 0, s = 0, o = 0, l = 0,
|
|
298
|
-
n &&
|
|
299
|
-
const m = () => !(p >=
|
|
300
|
-
for (
|
|
301
|
-
const d =
|
|
302
|
-
if (_() && (o++,
|
|
299
|
+
const i = D(g.indexOf(e), t), z = Math.max(1, Math.floor(r));
|
|
300
|
+
let v = !1, x = !1, p = 0, s = 0, o = 0, l = 0, a = z - 1;
|
|
301
|
+
n && a > 0 && (x = !0, a--), n && a > 0 && (v = !0, a--);
|
|
302
|
+
const m = () => !(p >= i || p >= t - s || o >= 2 && p >= i - (o - 1)), f = () => !(t - 1 - s <= i || t - 1 - s < p || l >= 2 && t - 1 - s <= i + (l - 1)), _ = () => i === 0 ? !1 : o === 0 ? p + 1 < i : i - o >= p, N = () => i === t - 1 ? !1 : l === 0 ? i + 1 < t - 1 - s : i + l <= t - 1 - s, P = () => i - p - Math.max(0, o - 1), y = () => t - 1 - i - s - Math.max(0, l - 1);
|
|
303
|
+
for (a > 0 && m() && (p++, a--), a > 0 && f() && (s++, a--), a > 0 && (_() ? (o++, a--) : P() > 0 && m() && (p++, a--)), a > 0 && (N() ? (l++, a--) : y() > 0 && f() && (s++, a--)); a > 0; ) {
|
|
304
|
+
const d = a;
|
|
305
|
+
if (_() && (o++, a--), a === 0 || (N() && (l++, a--), a === 0) || (m() && (p++, a--), a === 0) || (f() && (s++, a--), d === a)) break;
|
|
303
306
|
}
|
|
304
307
|
const u = (d) => ({
|
|
305
308
|
kind: "page",
|
|
306
309
|
page: g[d],
|
|
307
310
|
current: g[d] === e
|
|
308
|
-
}), A = Array.from({ length: p }, (d, c) => u(c)),
|
|
311
|
+
}), A = Array.from({ length: p }, (d, c) => u(c)), $ = o >= 2 ? Array.from({ length: o - 1 }, (d, c) => u(i - (o - 1) + c)) : [], O = l >= 2 ? Array.from({ length: l - 1 }, (d, c) => u(i + 1 + c)) : [], B = Array.from({ length: s }, (d, c) => u(t - s + c)), k = p - 1, L = o >= 2 ? i - (o - 1) : i, C = P(), q = o >= 1 && k + 1 < L ? C === 1 ? [u(k + 1)] : [{ kind: "gap" }] : [], w = l >= 2 ? i + (l - 1) : i, M = t - s, E = y(), F = l >= 1 && w + 1 < M ? E === 1 ? [u(w + 1)] : [{ kind: "gap" }] : [], U = [
|
|
309
312
|
...A,
|
|
310
313
|
...q,
|
|
314
|
+
...$,
|
|
315
|
+
u(i),
|
|
311
316
|
...O,
|
|
312
|
-
u(a),
|
|
313
|
-
...B,
|
|
314
317
|
...F,
|
|
315
|
-
|
|
318
|
+
...B
|
|
316
319
|
];
|
|
317
320
|
return { showPrev: v, showNext: x, items: U };
|
|
318
321
|
}
|
|
319
|
-
function
|
|
322
|
+
function D(g, e) {
|
|
320
323
|
return g < 0 ? 0 : g >= e ? e - 1 : g;
|
|
321
324
|
}
|
|
322
|
-
typeof customElements < "u" && !customElements.get("mp-pagination") && customElements.define("mp-pagination",
|
|
325
|
+
typeof customElements < "u" && !customElements.get("mp-pagination") && customElements.define("mp-pagination", H);
|
|
323
326
|
export {
|
|
324
|
-
|
|
325
|
-
|
|
327
|
+
H as M,
|
|
328
|
+
R as b
|
|
326
329
|
};
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { LitElement as i, nothing as r, html as a } from "lit";
|
|
2
|
+
import { createRef as d, ref as n } from "lit/directives/ref.js";
|
|
3
|
+
import { t as l } from "./mp-toggle-button-Kz6sIgBJ.mjs";
|
|
4
|
+
import { f as c } from "./form-check.styles-jBlHetYX.mjs";
|
|
5
|
+
import { i as p } from "./invalid-feedback.styles-he0JYrJm.mjs";
|
|
6
|
+
import { H as b } from "./host-aria-WSGs7SPQ.mjs";
|
|
7
|
+
import { a as _, e as g } from "./form-associated-axmc5sY0.mjs";
|
|
8
|
+
const o = /* @__PURE__ */ new Set(["radio", "toggle_button"]), h = /* @__PURE__ */ new Set([
|
|
9
|
+
"primary",
|
|
10
|
+
"secondary",
|
|
11
|
+
"success",
|
|
12
|
+
"danger",
|
|
13
|
+
"warning",
|
|
14
|
+
"info",
|
|
15
|
+
"light",
|
|
16
|
+
"dark",
|
|
17
|
+
"outline-primary",
|
|
18
|
+
"outline-secondary",
|
|
19
|
+
"outline-success",
|
|
20
|
+
"outline-danger",
|
|
21
|
+
"outline-warning",
|
|
22
|
+
"outline-info",
|
|
23
|
+
"outline-light",
|
|
24
|
+
"outline-dark"
|
|
25
|
+
]);
|
|
26
|
+
let u = 0;
|
|
27
|
+
class m extends i {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments), this._type = "radio", this._checked = !1, this._disabled = !1, this._name = null, this._value = null, this._color = "secondary", this._inputLabel = null, this._errorText = null, this.hostAria = new b(this, {
|
|
30
|
+
referenceTarget: () => this._inputRef.value ?? null,
|
|
31
|
+
describedByExtras: () => _(this.renderRoot)
|
|
32
|
+
}), this._inputId = `mp-radio-${++u}`, this._errorId = `mp-radio-${u}-error`, this._inputRef = d(), this._groupTabIndex = null, this._groupPosInSet = null, this._groupSetSize = null, this.onInputChange = (e) => {
|
|
33
|
+
const t = e.target.checked;
|
|
34
|
+
this._checked = t, this.reflectBoolean("checked", t), this.dispatchEvent(
|
|
35
|
+
new CustomEvent("change", {
|
|
36
|
+
detail: { checked: t, value: this._value },
|
|
37
|
+
bubbles: !0,
|
|
38
|
+
composed: !0
|
|
39
|
+
})
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
static {
|
|
44
|
+
this.styles = [c, l, p];
|
|
45
|
+
}
|
|
46
|
+
static {
|
|
47
|
+
this.shadowRootOptions = {
|
|
48
|
+
...i.shadowRootOptions,
|
|
49
|
+
delegatesFocus: !0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static get observedAttributes() {
|
|
53
|
+
return [
|
|
54
|
+
...super.observedAttributes ?? [],
|
|
55
|
+
"invalid",
|
|
56
|
+
"required",
|
|
57
|
+
// Validation message rendered inside the shadow root and referenced by the
|
|
58
|
+
// inner <input>; shown only while `invalid` is also set.
|
|
59
|
+
"error-text",
|
|
60
|
+
"type",
|
|
61
|
+
"checked",
|
|
62
|
+
"disabled",
|
|
63
|
+
"name",
|
|
64
|
+
"value",
|
|
65
|
+
"color",
|
|
66
|
+
// Copied to the inner <input> in render(); the slotted label already names
|
|
67
|
+
// the control (flat-tree label association), so these are overrides.
|
|
68
|
+
"aria-label",
|
|
69
|
+
"input-label",
|
|
70
|
+
// NOT copied inward — resolved into element references against the host's
|
|
71
|
+
// tree by hostAria.syncReferences(); an IDREF string cannot cross the
|
|
72
|
+
// shadow boundary.
|
|
73
|
+
"aria-labelledby",
|
|
74
|
+
"aria-describedby"
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Optional override for the inner <input>'s accessible name. Usually
|
|
79
|
+
* unnecessary: the slotted visible text already names the control through the
|
|
80
|
+
* flat-tree label association (slotted-label spike; verdict in the plan). For a radio
|
|
81
|
+
* with no visible text, or a name that must differ from it, set this.
|
|
82
|
+
*/
|
|
83
|
+
get inputLabel() {
|
|
84
|
+
return this._inputLabel;
|
|
85
|
+
}
|
|
86
|
+
set inputLabel(e) {
|
|
87
|
+
const t = e ?? null;
|
|
88
|
+
this._inputLabel !== t && (this._inputLabel = t, this.requestUpdate());
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Validation message, as `errorText` / `error-text`. Rendered as a
|
|
92
|
+
* `.invalid-feedback` node inside the shadow root and referenced from the inner
|
|
93
|
+
* `<input>` by `aria-errormessage` **and** `aria-describedby`, but only while
|
|
94
|
+
* `invalid` is set — `aria-errormessage` is meaningless on a control that is not
|
|
95
|
+
* `aria-invalid`.
|
|
96
|
+
*
|
|
97
|
+
* On a radio the message belongs to the whole group, not to one option, so put
|
|
98
|
+
* it on the radio the group's validity is anchored to (or on each, which
|
|
99
|
+
* repeats it). Text rather than a node because a consumer's own element lives
|
|
100
|
+
* outside this shadow root, where an IDREF from the inner input cannot reach it.
|
|
101
|
+
*/
|
|
102
|
+
get errorText() {
|
|
103
|
+
return this._errorText;
|
|
104
|
+
}
|
|
105
|
+
set errorText(e) {
|
|
106
|
+
const t = e ?? null;
|
|
107
|
+
this._errorText !== t && (this._errorText = t, this.requestUpdate());
|
|
108
|
+
}
|
|
109
|
+
get type() {
|
|
110
|
+
return this._type;
|
|
111
|
+
}
|
|
112
|
+
set type(e) {
|
|
113
|
+
!o.has(e) || this._type === e || (this._type = e, this.requestUpdate());
|
|
114
|
+
}
|
|
115
|
+
get checked() {
|
|
116
|
+
return this._checked;
|
|
117
|
+
}
|
|
118
|
+
set checked(e) {
|
|
119
|
+
const t = !!e;
|
|
120
|
+
this._checked !== t && (this._checked = t, this.reflectBoolean("checked", t), this.requestUpdate());
|
|
121
|
+
}
|
|
122
|
+
get disabled() {
|
|
123
|
+
return this._disabled;
|
|
124
|
+
}
|
|
125
|
+
set disabled(e) {
|
|
126
|
+
const t = !!e;
|
|
127
|
+
this._disabled !== t && (this._disabled = t, this.reflectBoolean("disabled", t), this.requestUpdate());
|
|
128
|
+
}
|
|
129
|
+
get name() {
|
|
130
|
+
return this._name;
|
|
131
|
+
}
|
|
132
|
+
set name(e) {
|
|
133
|
+
const t = e ?? null;
|
|
134
|
+
this._name !== t && (this._name = t, this.requestUpdate());
|
|
135
|
+
}
|
|
136
|
+
get value() {
|
|
137
|
+
return this._value;
|
|
138
|
+
}
|
|
139
|
+
set value(e) {
|
|
140
|
+
const t = e ?? null;
|
|
141
|
+
this._value !== t && (this._value = t, this.requestUpdate());
|
|
142
|
+
}
|
|
143
|
+
get color() {
|
|
144
|
+
return this._color;
|
|
145
|
+
}
|
|
146
|
+
set color(e) {
|
|
147
|
+
!h.has(e) || this._color === e || (this._color = e, this.requestUpdate());
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Roving tab stop, written by an enclosing `<mp-radio-group>`. With
|
|
151
|
+
* delegatesFocus a tabindex on the HOST cannot take the inner input out of
|
|
152
|
+
* the tab order — the input's own tabindex is the only lever, and it lives
|
|
153
|
+
* behind the shadow boundary, hence this property. Coordination state, not
|
|
154
|
+
* author API: property-only, no attribute.
|
|
155
|
+
*/
|
|
156
|
+
get groupTabIndex() {
|
|
157
|
+
return this._groupTabIndex;
|
|
158
|
+
}
|
|
159
|
+
set groupTabIndex(e) {
|
|
160
|
+
const t = e ?? null;
|
|
161
|
+
this._groupTabIndex !== t && (this._groupTabIndex = t, this.requestUpdate());
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Set-position pair, written by the enclosing group. They belong on the
|
|
165
|
+
* inner `<input>` — the role bearer — because aria-posinset on a role-less
|
|
166
|
+
* host is dropped by AT, and shadow roots keep native name-grouping (the
|
|
167
|
+
* usual "2 of 3" source) from ever forming.
|
|
168
|
+
*/
|
|
169
|
+
get groupPosInSet() {
|
|
170
|
+
return this._groupPosInSet;
|
|
171
|
+
}
|
|
172
|
+
set groupPosInSet(e) {
|
|
173
|
+
const t = e ?? null;
|
|
174
|
+
this._groupPosInSet !== t && (this._groupPosInSet = t, this.requestUpdate());
|
|
175
|
+
}
|
|
176
|
+
get groupSetSize() {
|
|
177
|
+
return this._groupSetSize;
|
|
178
|
+
}
|
|
179
|
+
set groupSetSize(e) {
|
|
180
|
+
const t = e ?? null;
|
|
181
|
+
this._groupSetSize !== t && (this._groupSetSize = t, this.requestUpdate());
|
|
182
|
+
}
|
|
183
|
+
attributeChangedCallback(e, t, s) {
|
|
184
|
+
switch (super.attributeChangedCallback(e, t, s), e) {
|
|
185
|
+
// Read from the host in render(), so a change has to ask for one — without
|
|
186
|
+
// this, aria-invalid / aria-required froze at their first-render values and
|
|
187
|
+
// an error message could never appear on a control that started out valid.
|
|
188
|
+
case "invalid":
|
|
189
|
+
case "required":
|
|
190
|
+
this.requestUpdate();
|
|
191
|
+
break;
|
|
192
|
+
case "error-text":
|
|
193
|
+
this._errorText = s, this.requestUpdate();
|
|
194
|
+
break;
|
|
195
|
+
case "type":
|
|
196
|
+
s && o.has(s) && (this._type = s, this.requestUpdate());
|
|
197
|
+
break;
|
|
198
|
+
case "checked":
|
|
199
|
+
this._checked = s !== null, this.requestUpdate();
|
|
200
|
+
break;
|
|
201
|
+
case "disabled":
|
|
202
|
+
this._disabled = s !== null, this.requestUpdate();
|
|
203
|
+
break;
|
|
204
|
+
case "name":
|
|
205
|
+
this._name = s, this.requestUpdate();
|
|
206
|
+
break;
|
|
207
|
+
case "value":
|
|
208
|
+
this._value = s, this.requestUpdate();
|
|
209
|
+
break;
|
|
210
|
+
case "color":
|
|
211
|
+
s && h.has(s) && (this._color = s, this.requestUpdate());
|
|
212
|
+
break;
|
|
213
|
+
case "aria-label":
|
|
214
|
+
this.requestUpdate();
|
|
215
|
+
break;
|
|
216
|
+
case "input-label":
|
|
217
|
+
this._inputLabel = s, this.requestUpdate();
|
|
218
|
+
break;
|
|
219
|
+
case "aria-labelledby":
|
|
220
|
+
case "aria-describedby":
|
|
221
|
+
this.hostAria.syncReferences();
|
|
222
|
+
break;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// After every render, not once: element references point at a specific node,
|
|
226
|
+
// and switching `type` replaces the <input> outright. See mp-checkbox's aria
|
|
227
|
+
// spec, where the same transition is exercised.
|
|
228
|
+
updated() {
|
|
229
|
+
this.hostAria.syncReferences();
|
|
230
|
+
}
|
|
231
|
+
render() {
|
|
232
|
+
return this._type === "toggle_button" ? this.renderToggleButton() : this.renderRadio();
|
|
233
|
+
}
|
|
234
|
+
renderRadio() {
|
|
235
|
+
const e = this.errorFeedback();
|
|
236
|
+
return a`
|
|
237
|
+
<label class="form-check">
|
|
238
|
+
<input
|
|
239
|
+
${n(this._inputRef)}
|
|
240
|
+
type="radio"
|
|
241
|
+
class="form-check-input"
|
|
242
|
+
id=${this._inputId}
|
|
243
|
+
.checked=${this._checked}
|
|
244
|
+
?disabled=${this._disabled}
|
|
245
|
+
aria-invalid=${this.hasAttribute("invalid") ? "true" : r}
|
|
246
|
+
aria-required=${this.hasAttribute("required") ? "true" : r}
|
|
247
|
+
aria-errormessage=${e.id}
|
|
248
|
+
aria-describedby=${e.id}
|
|
249
|
+
name=${this._name ?? r}
|
|
250
|
+
value=${this._value ?? r}
|
|
251
|
+
tabindex=${this._groupTabIndex ?? r}
|
|
252
|
+
aria-posinset=${this._groupPosInSet ?? r}
|
|
253
|
+
aria-setsize=${this._groupSetSize ?? r}
|
|
254
|
+
aria-label=${this.getAttribute("aria-label") ?? this._inputLabel ?? r}
|
|
255
|
+
@change=${this.onInputChange}
|
|
256
|
+
/>
|
|
257
|
+
<span class="form-check-label"><slot></slot></span>
|
|
258
|
+
</label>
|
|
259
|
+
${e.node}
|
|
260
|
+
`;
|
|
261
|
+
}
|
|
262
|
+
errorFeedback() {
|
|
263
|
+
return g(this._errorId, this._errorText, this.hasAttribute("invalid"));
|
|
264
|
+
}
|
|
265
|
+
renderToggleButton() {
|
|
266
|
+
const e = this.errorFeedback();
|
|
267
|
+
return a`
|
|
268
|
+
<input
|
|
269
|
+
${n(this._inputRef)}
|
|
270
|
+
type="radio"
|
|
271
|
+
class="btn-check"
|
|
272
|
+
id=${this._inputId}
|
|
273
|
+
.checked=${this._checked}
|
|
274
|
+
?disabled=${this._disabled}
|
|
275
|
+
aria-invalid=${this.hasAttribute("invalid") ? "true" : r}
|
|
276
|
+
aria-required=${this.hasAttribute("required") ? "true" : r}
|
|
277
|
+
aria-errormessage=${e.id}
|
|
278
|
+
aria-describedby=${e.id}
|
|
279
|
+
name=${this._name ?? r}
|
|
280
|
+
value=${this._value ?? r}
|
|
281
|
+
tabindex=${this._groupTabIndex ?? r}
|
|
282
|
+
aria-posinset=${this._groupPosInSet ?? r}
|
|
283
|
+
aria-setsize=${this._groupSetSize ?? r}
|
|
284
|
+
aria-label=${this.getAttribute("aria-label") ?? this._inputLabel ?? r}
|
|
285
|
+
@change=${this.onInputChange}
|
|
286
|
+
/>
|
|
287
|
+
<label class="btn btn-${this._color}" for=${this._inputId}>
|
|
288
|
+
<slot></slot>
|
|
289
|
+
</label>
|
|
290
|
+
${e.node}
|
|
291
|
+
`;
|
|
292
|
+
}
|
|
293
|
+
reflectBoolean(e, t) {
|
|
294
|
+
t ? this.setAttribute(e, "") : this.removeAttribute(e);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
typeof customElements < "u" && !customElements.get("mp-radio") && customElements.define("mp-radio", m);
|
|
298
|
+
export {
|
|
299
|
+
m as M
|
|
300
|
+
};
|