@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
package/radio/index.mjs
CHANGED
|
@@ -1,162 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as o } from "../chunks/mp-toggle-button-dLZNDUVz.mjs";
|
|
3
|
-
import { f as c } from "../chunks/form-check.styles-jBlHetYX.mjs";
|
|
4
|
-
const n = /* @__PURE__ */ new Set(["radio", "toggle_button"]), h = /* @__PURE__ */ new Set([
|
|
5
|
-
"primary",
|
|
6
|
-
"secondary",
|
|
7
|
-
"success",
|
|
8
|
-
"danger",
|
|
9
|
-
"warning",
|
|
10
|
-
"info",
|
|
11
|
-
"light",
|
|
12
|
-
"dark",
|
|
13
|
-
"outline-primary",
|
|
14
|
-
"outline-secondary",
|
|
15
|
-
"outline-success",
|
|
16
|
-
"outline-danger",
|
|
17
|
-
"outline-warning",
|
|
18
|
-
"outline-info",
|
|
19
|
-
"outline-light",
|
|
20
|
-
"outline-dark"
|
|
21
|
-
]);
|
|
22
|
-
let d = 0;
|
|
23
|
-
class l extends r {
|
|
24
|
-
constructor() {
|
|
25
|
-
super(...arguments), this._type = "radio", this._checked = !1, this._disabled = !1, this._name = null, this._value = null, this._color = "secondary", this._inputId = `mp-radio-${++d}`, this.onInputChange = (e) => {
|
|
26
|
-
const t = e.target.checked;
|
|
27
|
-
this._checked = t, this.reflectBoolean("checked", t), this.dispatchEvent(
|
|
28
|
-
new CustomEvent("change", {
|
|
29
|
-
detail: { checked: t, value: this._value },
|
|
30
|
-
bubbles: !0,
|
|
31
|
-
composed: !0
|
|
32
|
-
})
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
static {
|
|
37
|
-
this.styles = [c, o];
|
|
38
|
-
}
|
|
39
|
-
static {
|
|
40
|
-
this.shadowRootOptions = {
|
|
41
|
-
...r.shadowRootOptions,
|
|
42
|
-
delegatesFocus: !0
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
static get observedAttributes() {
|
|
46
|
-
return [
|
|
47
|
-
...super.observedAttributes ?? [],
|
|
48
|
-
"type",
|
|
49
|
-
"checked",
|
|
50
|
-
"disabled",
|
|
51
|
-
"name",
|
|
52
|
-
"value",
|
|
53
|
-
"color"
|
|
54
|
-
];
|
|
55
|
-
}
|
|
56
|
-
get type() {
|
|
57
|
-
return this._type;
|
|
58
|
-
}
|
|
59
|
-
set type(e) {
|
|
60
|
-
!n.has(e) || this._type === e || (this._type = e, this.requestUpdate());
|
|
61
|
-
}
|
|
62
|
-
get checked() {
|
|
63
|
-
return this._checked;
|
|
64
|
-
}
|
|
65
|
-
set checked(e) {
|
|
66
|
-
const t = !!e;
|
|
67
|
-
this._checked !== t && (this._checked = t, this.reflectBoolean("checked", t), this.requestUpdate());
|
|
68
|
-
}
|
|
69
|
-
get disabled() {
|
|
70
|
-
return this._disabled;
|
|
71
|
-
}
|
|
72
|
-
set disabled(e) {
|
|
73
|
-
const t = !!e;
|
|
74
|
-
this._disabled !== t && (this._disabled = t, this.reflectBoolean("disabled", t), this.requestUpdate());
|
|
75
|
-
}
|
|
76
|
-
get name() {
|
|
77
|
-
return this._name;
|
|
78
|
-
}
|
|
79
|
-
set name(e) {
|
|
80
|
-
const t = e ?? null;
|
|
81
|
-
this._name !== t && (this._name = t, this.requestUpdate());
|
|
82
|
-
}
|
|
83
|
-
get value() {
|
|
84
|
-
return this._value;
|
|
85
|
-
}
|
|
86
|
-
set value(e) {
|
|
87
|
-
const t = e ?? null;
|
|
88
|
-
this._value !== t && (this._value = t, this.requestUpdate());
|
|
89
|
-
}
|
|
90
|
-
get color() {
|
|
91
|
-
return this._color;
|
|
92
|
-
}
|
|
93
|
-
set color(e) {
|
|
94
|
-
!h.has(e) || this._color === e || (this._color = e, this.requestUpdate());
|
|
95
|
-
}
|
|
96
|
-
attributeChangedCallback(e, t, s) {
|
|
97
|
-
switch (super.attributeChangedCallback(e, t, s), e) {
|
|
98
|
-
case "type":
|
|
99
|
-
s && n.has(s) && (this._type = s, this.requestUpdate());
|
|
100
|
-
break;
|
|
101
|
-
case "checked":
|
|
102
|
-
this._checked = s !== null, this.requestUpdate();
|
|
103
|
-
break;
|
|
104
|
-
case "disabled":
|
|
105
|
-
this._disabled = s !== null, this.requestUpdate();
|
|
106
|
-
break;
|
|
107
|
-
case "name":
|
|
108
|
-
this._name = s, this.requestUpdate();
|
|
109
|
-
break;
|
|
110
|
-
case "value":
|
|
111
|
-
this._value = s, this.requestUpdate();
|
|
112
|
-
break;
|
|
113
|
-
case "color":
|
|
114
|
-
s && h.has(s) && (this._color = s, this.requestUpdate());
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
render() {
|
|
119
|
-
return this._type === "toggle_button" ? this.renderToggleButton() : this.renderRadio();
|
|
120
|
-
}
|
|
121
|
-
renderRadio() {
|
|
122
|
-
return a`
|
|
123
|
-
<label class="form-check">
|
|
124
|
-
<input
|
|
125
|
-
type="radio"
|
|
126
|
-
class="form-check-input"
|
|
127
|
-
id=${this._inputId}
|
|
128
|
-
.checked=${this._checked}
|
|
129
|
-
?disabled=${this._disabled}
|
|
130
|
-
name=${this._name ?? i}
|
|
131
|
-
value=${this._value ?? i}
|
|
132
|
-
@change=${this.onInputChange}
|
|
133
|
-
/>
|
|
134
|
-
<span class="form-check-label"><slot></slot></span>
|
|
135
|
-
</label>
|
|
136
|
-
`;
|
|
137
|
-
}
|
|
138
|
-
renderToggleButton() {
|
|
139
|
-
return a`
|
|
140
|
-
<input
|
|
141
|
-
type="radio"
|
|
142
|
-
class="btn-check"
|
|
143
|
-
id=${this._inputId}
|
|
144
|
-
.checked=${this._checked}
|
|
145
|
-
?disabled=${this._disabled}
|
|
146
|
-
name=${this._name ?? i}
|
|
147
|
-
value=${this._value ?? i}
|
|
148
|
-
@change=${this.onInputChange}
|
|
149
|
-
/>
|
|
150
|
-
<label class="btn btn-${this._color}" for=${this._inputId}>
|
|
151
|
-
<slot></slot>
|
|
152
|
-
</label>
|
|
153
|
-
`;
|
|
154
|
-
}
|
|
155
|
-
reflectBoolean(e, t) {
|
|
156
|
-
t ? this.setAttribute(e, "") : this.removeAttribute(e);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
typeof customElements < "u" && !customElements.get("mp-radio") && customElements.define("mp-radio", l);
|
|
1
|
+
import { M as p } from "../chunks/mp-radio-BjW1HNSc.mjs";
|
|
160
2
|
export {
|
|
161
|
-
|
|
3
|
+
p as MpRadio
|
|
162
4
|
};
|
|
@@ -17,9 +17,9 @@ export interface RadioChangeEventDetail {
|
|
|
17
17
|
* Native one-of-N behaviour relies on multiple inputs sharing a `name` in
|
|
18
18
|
* the same scope. Each `<mp-radio>` keeps its `<input>` inside its own
|
|
19
19
|
* shadow root, so the browser cannot auto-uncheck a sibling for us. A
|
|
20
|
-
* coordinating parent
|
|
21
|
-
*
|
|
22
|
-
* other radios' `checked` properties.
|
|
20
|
+
* coordinating parent — `<mp-radio-group>`, or the Angular `[bsRadioGroup]`
|
|
21
|
+
* directive on hosts where that element can't be used — must listen for
|
|
22
|
+
* `change` and update the other radios' `checked` properties.
|
|
23
23
|
*
|
|
24
24
|
* Emits `change` with `detail: { checked, value }` when this radio
|
|
25
25
|
* transitions to the checked state.
|
|
@@ -41,7 +41,38 @@ export declare class MpRadio extends LitElement {
|
|
|
41
41
|
private _name;
|
|
42
42
|
private _value;
|
|
43
43
|
private _color;
|
|
44
|
+
private _inputLabel;
|
|
45
|
+
private _errorText;
|
|
46
|
+
/**
|
|
47
|
+
* Tier-2 naming. No role on the host: the inner <input> is the real control, so
|
|
48
|
+
* a host role would announce the radio twice. References target that <input>.
|
|
49
|
+
*/
|
|
50
|
+
private readonly hostAria;
|
|
44
51
|
private readonly _inputId;
|
|
52
|
+
private readonly _errorId;
|
|
53
|
+
private readonly _inputRef;
|
|
54
|
+
/**
|
|
55
|
+
* Optional override for the inner <input>'s accessible name. Usually
|
|
56
|
+
* unnecessary: the slotted visible text already names the control through the
|
|
57
|
+
* flat-tree label association (slotted-label spike; verdict in the plan). For a radio
|
|
58
|
+
* with no visible text, or a name that must differ from it, set this.
|
|
59
|
+
*/
|
|
60
|
+
get inputLabel(): string | null;
|
|
61
|
+
set inputLabel(value: string | null);
|
|
62
|
+
/**
|
|
63
|
+
* Validation message, as `errorText` / `error-text`. Rendered as a
|
|
64
|
+
* `.invalid-feedback` node inside the shadow root and referenced from the inner
|
|
65
|
+
* `<input>` by `aria-errormessage` **and** `aria-describedby`, but only while
|
|
66
|
+
* `invalid` is set — `aria-errormessage` is meaningless on a control that is not
|
|
67
|
+
* `aria-invalid`.
|
|
68
|
+
*
|
|
69
|
+
* On a radio the message belongs to the whole group, not to one option, so put
|
|
70
|
+
* it on the radio the group's validity is anchored to (or on each, which
|
|
71
|
+
* repeats it). Text rather than a node because a consumer's own element lives
|
|
72
|
+
* outside this shadow root, where an IDREF from the inner input cannot reach it.
|
|
73
|
+
*/
|
|
74
|
+
get errorText(): string | null;
|
|
75
|
+
set errorText(value: string | null);
|
|
45
76
|
get type(): MpRadioType;
|
|
46
77
|
set type(value: MpRadioType);
|
|
47
78
|
get checked(): boolean;
|
|
@@ -54,9 +85,33 @@ export declare class MpRadio extends LitElement {
|
|
|
54
85
|
set value(value: string | null);
|
|
55
86
|
get color(): ToggleButtonColor;
|
|
56
87
|
set color(value: ToggleButtonColor);
|
|
88
|
+
private _groupTabIndex;
|
|
89
|
+
private _groupPosInSet;
|
|
90
|
+
private _groupSetSize;
|
|
91
|
+
/**
|
|
92
|
+
* Roving tab stop, written by an enclosing `<mp-radio-group>`. With
|
|
93
|
+
* delegatesFocus a tabindex on the HOST cannot take the inner input out of
|
|
94
|
+
* the tab order — the input's own tabindex is the only lever, and it lives
|
|
95
|
+
* behind the shadow boundary, hence this property. Coordination state, not
|
|
96
|
+
* author API: property-only, no attribute.
|
|
97
|
+
*/
|
|
98
|
+
get groupTabIndex(): number | null;
|
|
99
|
+
set groupTabIndex(value: number | null);
|
|
100
|
+
/**
|
|
101
|
+
* Set-position pair, written by the enclosing group. They belong on the
|
|
102
|
+
* inner `<input>` — the role bearer — because aria-posinset on a role-less
|
|
103
|
+
* host is dropped by AT, and shadow roots keep native name-grouping (the
|
|
104
|
+
* usual "2 of 3" source) from ever forming.
|
|
105
|
+
*/
|
|
106
|
+
get groupPosInSet(): number | null;
|
|
107
|
+
set groupPosInSet(value: number | null);
|
|
108
|
+
get groupSetSize(): number | null;
|
|
109
|
+
set groupSetSize(value: number | null);
|
|
57
110
|
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
111
|
+
protected updated(): void;
|
|
58
112
|
render(): TemplateResult;
|
|
59
113
|
private renderRadio;
|
|
114
|
+
private errorFeedback;
|
|
60
115
|
private renderToggleButton;
|
|
61
116
|
private reflectBoolean;
|
|
62
117
|
private onInputChange;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './src';
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { unsafeCSS as d, LitElement as f, html as b } from "lit";
|
|
2
|
+
import "lit/directives/ref.js";
|
|
3
|
+
import { l as m, f as c, n as h } from "../chunks/roving-focus-CrL9982a.mjs";
|
|
4
|
+
import { F as g } from "../chunks/form-associated-axmc5sY0.mjs";
|
|
5
|
+
import "../chunks/mp-radio-BjW1HNSc.mjs";
|
|
6
|
+
const p = d(`:host {
|
|
7
|
+
display: block;
|
|
8
|
+
}`);
|
|
9
|
+
class k extends g(f) {
|
|
10
|
+
static {
|
|
11
|
+
this.styles = [p];
|
|
12
|
+
}
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return [...super.observedAttributes ?? [], "name", "required", "disabled"];
|
|
15
|
+
}
|
|
16
|
+
#s = null;
|
|
17
|
+
/** Value to restore on form reset — captured from the initially-checked radio. */
|
|
18
|
+
#r = null;
|
|
19
|
+
#i = !1;
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
super.connectedCallback(), this.hasAttribute("role") || this.setAttribute("role", "radiogroup"), this.addEventListener("change", this.#a), this.addEventListener("keydown", this.#n), this.#s = new MutationObserver(() => this.#e()), this.#s.observe(this, {
|
|
22
|
+
childList: !0,
|
|
23
|
+
subtree: !0,
|
|
24
|
+
attributes: !0,
|
|
25
|
+
attributeFilter: ["checked", "disabled"]
|
|
26
|
+
}), queueMicrotask(() => this.#e());
|
|
27
|
+
}
|
|
28
|
+
attributeChangedCallback(e, t, r) {
|
|
29
|
+
super.attributeChangedCallback(e, t, r), (e === "required" || e === "disabled") && this.#e(), e === "name" && this.syncFormValue();
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
super.disconnectedCallback(), this.removeEventListener("change", this.#a), this.removeEventListener("keydown", this.#n), this.#s?.disconnect(), this.#s = null;
|
|
33
|
+
}
|
|
34
|
+
/** The group's radios, excluding any nested group's. */
|
|
35
|
+
#t() {
|
|
36
|
+
return [...this.querySelectorAll("mp-radio")].filter(
|
|
37
|
+
(e) => e.closest("mp-radio-group") === this
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
/** Submission key, reflected to the attribute ElementInternals submits
|
|
41
|
+
* under. A property accessor so typed wrappers (@lit/react) accept it. */
|
|
42
|
+
get name() {
|
|
43
|
+
return this.getAttribute("name");
|
|
44
|
+
}
|
|
45
|
+
set name(e) {
|
|
46
|
+
e === null ? this.removeAttribute("name") : this.setAttribute("name", e);
|
|
47
|
+
}
|
|
48
|
+
get value() {
|
|
49
|
+
return this.#t().find((e) => e.checked)?.value ?? null;
|
|
50
|
+
}
|
|
51
|
+
set value(e) {
|
|
52
|
+
this.#t().forEach((t) => {
|
|
53
|
+
t.checked = t.value === e && e !== null;
|
|
54
|
+
}), this.#e(), this.syncFormValue();
|
|
55
|
+
}
|
|
56
|
+
#a = (e) => {
|
|
57
|
+
const t = e.target;
|
|
58
|
+
if (!(t instanceof HTMLElement) || t.tagName !== "MP-RADIO") return;
|
|
59
|
+
const r = this.#t();
|
|
60
|
+
r.includes(t) && (r.forEach((i) => {
|
|
61
|
+
i !== t && (i.checked = !1);
|
|
62
|
+
}), this.#e(), this.syncFormValue(), this.dispatchEvent(
|
|
63
|
+
new CustomEvent("group-change", {
|
|
64
|
+
detail: { value: this.value },
|
|
65
|
+
bubbles: !0,
|
|
66
|
+
composed: !0
|
|
67
|
+
})
|
|
68
|
+
));
|
|
69
|
+
};
|
|
70
|
+
/** APG radio group: arrows move AND select, wrapping; Home/End to the ends. */
|
|
71
|
+
#n = (e) => {
|
|
72
|
+
if (e.altKey || e.ctrlKey || e.metaKey) return;
|
|
73
|
+
const t = this.#t();
|
|
74
|
+
if (t.length === 0) return;
|
|
75
|
+
const r = getComputedStyle(this).direction === "rtl", i = r ? "ArrowLeft" : "ArrowRight", s = r ? "ArrowRight" : "ArrowLeft", a = t.findIndex((o) => o.contains(e.target));
|
|
76
|
+
if (a < 0) return;
|
|
77
|
+
const u = (o) => t[o].hasAttribute("disabled");
|
|
78
|
+
let n = -1;
|
|
79
|
+
switch (e.key) {
|
|
80
|
+
case i:
|
|
81
|
+
case "ArrowDown":
|
|
82
|
+
n = h(t.length, a, 1, !0, u);
|
|
83
|
+
break;
|
|
84
|
+
case s:
|
|
85
|
+
case "ArrowUp":
|
|
86
|
+
n = h(t.length, a, -1, !0, u);
|
|
87
|
+
break;
|
|
88
|
+
case "Home":
|
|
89
|
+
n = c(t.length, u);
|
|
90
|
+
break;
|
|
91
|
+
case "End":
|
|
92
|
+
n = m(t.length, u);
|
|
93
|
+
break;
|
|
94
|
+
default:
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (n < 0 || n === a) {
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
e.preventDefault();
|
|
102
|
+
const l = t[n];
|
|
103
|
+
l.checked = !0, t.forEach((o) => {
|
|
104
|
+
o !== l && (o.checked = !1);
|
|
105
|
+
}), this.#e(), l.focus(), this.syncFormValue(), this.dispatchEvent(
|
|
106
|
+
new CustomEvent("group-change", {
|
|
107
|
+
detail: { value: this.value },
|
|
108
|
+
bubbles: !0,
|
|
109
|
+
composed: !0
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
/** Roving tab stop (checked, else first enabled) + posinset/setsize. */
|
|
114
|
+
#e() {
|
|
115
|
+
const e = this.#t();
|
|
116
|
+
if (e.length === 0) return;
|
|
117
|
+
this.#i || (this.#i = !0, this.#r = e.find((s) => s.checked)?.value ?? null, this.syncFormValue());
|
|
118
|
+
const t = e.findIndex((s) => s.checked), r = t >= 0 ? t : c(e.length, (s) => e[s].hasAttribute("disabled"));
|
|
119
|
+
e.forEach((s, a) => {
|
|
120
|
+
s.groupTabIndex = a === r ? 0 : -1, s.groupPosInSet = a + 1, s.groupSetSize = e.length;
|
|
121
|
+
});
|
|
122
|
+
const i = this.hasAttribute("required");
|
|
123
|
+
i ? this.setAttribute("aria-required", "true") : this.removeAttribute("aria-required"), this.setFormValidity(
|
|
124
|
+
{ valueMissing: i && t < 0 },
|
|
125
|
+
"Please select an option."
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
// ---- form association (FormAssociatedHost) ----
|
|
129
|
+
formValue() {
|
|
130
|
+
return this.value;
|
|
131
|
+
}
|
|
132
|
+
formReset() {
|
|
133
|
+
this.value = this.#r;
|
|
134
|
+
}
|
|
135
|
+
formRestore(e) {
|
|
136
|
+
typeof e == "string" && (this.value = e);
|
|
137
|
+
}
|
|
138
|
+
render() {
|
|
139
|
+
return b`<slot @slotchange=${() => this.#e()}></slot>`;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
typeof customElements < "u" && !customElements.get("mp-radio-group") && customElements.define("mp-radio-group", k);
|
|
143
|
+
export {
|
|
144
|
+
k as MpRadioGroup
|
|
145
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export interface RadioGroupChangeEventDetail {
|
|
3
|
+
value: string | null;
|
|
4
|
+
}
|
|
5
|
+
declare const MpRadioGroup_base: typeof LitElement & (new (...args: any[]) => import('@mintplayer/web-components/a11y').FormAssociatedElement);
|
|
6
|
+
/**
|
|
7
|
+
* `<mp-radio-group>` — the form-associated element for radios (Phase F /
|
|
8
|
+
* decision D5). Individual `<mp-radio>`s each own a shadow root, so native
|
|
9
|
+
* `name` grouping can NEVER form across them (a radio group only exists
|
|
10
|
+
* within one node tree) — this element supplies everything the platform
|
|
11
|
+
* would have: exclusivity, the roving tab stop, arrow move-and-select, and
|
|
12
|
+
* ONE submission entry.
|
|
13
|
+
*
|
|
14
|
+
* Light-DOM `<mp-radio>` children (any nesting, scoped to the nearest group)
|
|
15
|
+
* are the API. The group:
|
|
16
|
+
* - claims `role="radiogroup"` on itself (a light-DOM host: consumer
|
|
17
|
+
* `aria-label`/`aria-labelledby` work natively);
|
|
18
|
+
* - keeps exactly one radio checked (listens for their `change`);
|
|
19
|
+
* - roves the tab stop THROUGH each radio's inner input via `groupTabIndex`
|
|
20
|
+
* (`delegatesFocus` means a host tabindex can't remove the input from the
|
|
21
|
+
* tab order — the input's own tabindex is the only lever);
|
|
22
|
+
* - moves-and-selects on Arrow keys with wrap and RTL inversion, Home/End;
|
|
23
|
+
* - stamps aria-posinset/aria-setsize on each radio's inner input (the
|
|
24
|
+
* role bearer — a role-less host would drop them);
|
|
25
|
+
* - submits the checked radio's value under ITS OWN `name` attribute.
|
|
26
|
+
*
|
|
27
|
+
* Emits `group-change` with `detail: { value }` on user changes.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MpRadioGroup extends MpRadioGroup_base {
|
|
30
|
+
#private;
|
|
31
|
+
static styles: import('lit').CSSResult[];
|
|
32
|
+
static get observedAttributes(): string[];
|
|
33
|
+
connectedCallback(): void;
|
|
34
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
35
|
+
disconnectedCallback(): void;
|
|
36
|
+
/** Submission key, reflected to the attribute ElementInternals submits
|
|
37
|
+
* under. A property accessor so typed wrappers (@lit/react) accept it. */
|
|
38
|
+
get name(): string | null;
|
|
39
|
+
set name(value: string | null);
|
|
40
|
+
get value(): string | null;
|
|
41
|
+
set value(next: string | null);
|
|
42
|
+
formValue(): string | null;
|
|
43
|
+
formReset(): void;
|
|
44
|
+
formRestore(state: string | FormData | File | null): void;
|
|
45
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
46
|
+
}
|
|
47
|
+
declare global {
|
|
48
|
+
interface HTMLElementTagNameMap {
|
|
49
|
+
'mp-radio-group': MpRadioGroup;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/mp-radio-group';
|