@justeattakeaway/pie-switch 0.24.0 → 0.24.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/dist/index.js +532 -529
- package/dist/react.d.ts +2 -2
- package/package.json +5 -5
- package/src/react.ts +4 -3
package/dist/index.js
CHANGED
|
@@ -1,502 +1,505 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { query as
|
|
3
|
-
import { FormControlMixin as
|
|
1
|
+
import { LitElement as Ct, html as A, nothing as x, unsafeCSS as xt } from "lit";
|
|
2
|
+
import { query as Ft, property as E } from "lit/decorators.js";
|
|
3
|
+
import { FormControlMixin as At, RtlMixin as It, wrapNativeEvent as St, validPropertyValues as Vt, defineCustomElement as Tt } from "@justeattakeaway/pie-webc-core";
|
|
4
4
|
import "@justeattakeaway/pie-icons-webc/IconCheck";
|
|
5
|
-
const
|
|
6
|
-
`,
|
|
5
|
+
const Lt = `*,*:before,*:after{box-sizing:border-box;cursor:inherit}.c-switch-wrapper{display:inline-flex;align-items:center;gap:var(--dt-spacing-b);font-family:var(--dt-font-body-l-family);cursor:pointer}.c-switch-wrapper[disabled]{cursor:not-allowed}.c-switch{--switch-bg-color: var(--dt-color-interactive-form);--switch-bg-color--checked: var(--dt-color-interactive-brand);--switch-bg-color--disabled: var(--dt-color-disabled-01);--switch-width: 48px;--switch-height: 24px;--switch-control-size: 20px;--switch-padding: 2px;--switch-radius: var(--dt-radius-rounded-e);--switch-translation: calc(var(--switch-width) - var(--switch-control-size) - 2 * var(--switch-padding));position:relative;display:flex;width:var(--switch-width);height:var(--switch-height);flex-shrink:0;padding:var(--switch-padding);border-radius:var(--switch-radius);background-color:var(--switch-bg-color)}@media (prefers-reduced-motion: no-preference){.c-switch{transition:background-color .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch:hover{background-color:hsl(var(--dt-color-interactive-form-h),var(--dt-color-interactive-form-s),calc(var(--dt-color-interactive-form-l) - var(--dt-color-hover-01)))}.c-switch:focus,.c-switch:focus-within{box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-switch:active{background-color:hsl(var(--dt-color-interactive-form-h),var(--dt-color-interactive-form-s),calc(var(--dt-color-interactive-form-l) - var(--dt-color-active-01)))}.c-switch[checked]{background-color:var(--switch-bg-color--checked)}@media (prefers-reduced-motion: no-preference){.c-switch[checked]{transition:background-color .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch[checked]:hover{background-color:hsl(var(--dt-color-interactive-brand-h),var(--dt-color-interactive-brand-s),calc(var(--dt-color-interactive-brand-l) - var(--dt-color-hover-01)))}.c-switch[checked]:focus,.c-switch[checked]:focus-within{background-color:var(--switch-bg-color--checked)}.c-switch[checked]:active{background-color:hsl(var(--dt-color-interactive-brand-h),var(--dt-color-interactive-brand-s),calc(var(--dt-color-interactive-brand-l) - var(--dt-color-active-01)))}[disabled] .c-switch{background-color:var(--switch-bg-color--disabled);pointer-events:none}.c-switch-input{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;left:50%;transform:translate(-50%) translateY(-50%);bottom:0}.c-switch-input:disabled{background-color:transparent}.c-switch-control{position:absolute;left:2px;width:var(--switch-control-size);height:var(--switch-control-size);border-radius:var(--switch-radius);background-color:var(--dt-color-interactive-light);padding:var(--switch-padding)}@media (prefers-reduced-motion: no-preference){.c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch-input:checked+.c-switch-control{transform:translate(var(--switch-translation))}@media (prefers-reduced-motion: no-preference){.c-switch-input:checked+.c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch-input:checked+.c-switch-control .c-pieIcon--check{color:var(--switch-bg-color--checked)}@media (prefers-reduced-motion: no-preference){.c-switch-input:checked+.c-switch-control .c-pieIcon--check{transition:color .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch-input:disabled~.c-switch-control{color:var(--switch-bg-color--disabled)}.c-switch-input:disabled~.c-switch-control .c-pieIcon--check{color:var(--switch-bg-color--disabled)}@media (prefers-reduced-motion: no-preference){.c-switch-input:disabled~.c-switch-control .c-pieIcon--check{transition:color .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch-description{position:absolute;display:block;height:1px;width:1px;overflow:hidden;padding:1px;white-space:nowrap}.c-switch-wrapper[isRTL] .c-switch-control{position:absolute;left:initial;right:2px}.c-switch-wrapper[isRTL] .c-switch-input:checked+.c-switch-control{transform:translate(calc(-1 * var(--switch-translation)))}@media (prefers-reduced-motion: no-preference){.c-switch-wrapper[isRTL] .c-switch-input:checked+.c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}
|
|
6
|
+
`, Nt = ["leading", "trailing"], Wt = "change";
|
|
7
7
|
(function() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
8
|
+
(function(v) {
|
|
9
|
+
const n = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), m = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), y = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), z = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), S = /* @__PURE__ */ new WeakMap(), V = {
|
|
10
|
+
ariaAtomic: "aria-atomic",
|
|
11
|
+
ariaAutoComplete: "aria-autocomplete",
|
|
12
|
+
ariaBusy: "aria-busy",
|
|
13
|
+
ariaChecked: "aria-checked",
|
|
14
|
+
ariaColCount: "aria-colcount",
|
|
15
|
+
ariaColIndex: "aria-colindex",
|
|
16
|
+
ariaColIndexText: "aria-colindextext",
|
|
17
|
+
ariaColSpan: "aria-colspan",
|
|
18
|
+
ariaCurrent: "aria-current",
|
|
19
|
+
ariaDisabled: "aria-disabled",
|
|
20
|
+
ariaExpanded: "aria-expanded",
|
|
21
|
+
ariaHasPopup: "aria-haspopup",
|
|
22
|
+
ariaHidden: "aria-hidden",
|
|
23
|
+
ariaInvalid: "aria-invalid",
|
|
24
|
+
ariaKeyShortcuts: "aria-keyshortcuts",
|
|
25
|
+
ariaLabel: "aria-label",
|
|
26
|
+
ariaLevel: "aria-level",
|
|
27
|
+
ariaLive: "aria-live",
|
|
28
|
+
ariaModal: "aria-modal",
|
|
29
|
+
ariaMultiLine: "aria-multiline",
|
|
30
|
+
ariaMultiSelectable: "aria-multiselectable",
|
|
31
|
+
ariaOrientation: "aria-orientation",
|
|
32
|
+
ariaPlaceholder: "aria-placeholder",
|
|
33
|
+
ariaPosInSet: "aria-posinset",
|
|
34
|
+
ariaPressed: "aria-pressed",
|
|
35
|
+
ariaReadOnly: "aria-readonly",
|
|
36
|
+
ariaRelevant: "aria-relevant",
|
|
37
|
+
ariaRequired: "aria-required",
|
|
38
|
+
ariaRoleDescription: "aria-roledescription",
|
|
39
|
+
ariaRowCount: "aria-rowcount",
|
|
40
|
+
ariaRowIndex: "aria-rowindex",
|
|
41
|
+
ariaRowIndexText: "aria-rowindextext",
|
|
42
|
+
ariaRowSpan: "aria-rowspan",
|
|
43
|
+
ariaSelected: "aria-selected",
|
|
44
|
+
ariaSetSize: "aria-setsize",
|
|
45
|
+
ariaSort: "aria-sort",
|
|
46
|
+
ariaValueMax: "aria-valuemax",
|
|
47
|
+
ariaValueMin: "aria-valuemin",
|
|
48
|
+
ariaValueNow: "aria-valuenow",
|
|
49
|
+
ariaValueText: "aria-valuetext",
|
|
50
|
+
role: "role"
|
|
51
|
+
}, ct = (e, t) => {
|
|
52
|
+
for (let i in V) {
|
|
53
|
+
t[i] = null;
|
|
54
|
+
let a = null;
|
|
55
|
+
const r = V[i];
|
|
56
|
+
Object.defineProperty(t, i, {
|
|
57
|
+
get() {
|
|
58
|
+
return a;
|
|
59
|
+
},
|
|
60
|
+
set(o) {
|
|
61
|
+
a = o, e.isConnected ? e.setAttribute(r, o) : I.set(e, t);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
function K(e) {
|
|
67
|
+
const t = l.get(e), { form: i } = t;
|
|
68
|
+
X(e, i, t), Q(e, t.labels);
|
|
69
|
+
}
|
|
70
|
+
const j = (e, t = !1) => {
|
|
71
|
+
const i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
|
|
72
|
+
acceptNode(o) {
|
|
73
|
+
return l.has(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
61
74
|
}
|
|
62
75
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
});
|
|
75
|
-
let a = e.nextNode();
|
|
76
|
-
const r = !t || i.disabled;
|
|
77
|
-
for (; a; )
|
|
78
|
-
a.formDisabledCallback && r && $(a, i.disabled), a = e.nextNode();
|
|
79
|
-
}, K = { attributes: !0, attributeFilter: ["disabled", "name"] }, M = L() ? new MutationObserver((i) => {
|
|
80
|
-
for (const t of i) {
|
|
81
|
-
const e = t.target;
|
|
82
|
-
if (t.attributeName === "disabled" && (e.constructor.formAssociated ? $(e, e.hasAttribute("disabled")) : e.localName === "fieldset" && U(e)), t.attributeName === "name" && e.constructor.formAssociated) {
|
|
83
|
-
const a = l.get(e), r = H.get(e);
|
|
84
|
-
a.setFormValue(r);
|
|
76
|
+
let a = i.nextNode();
|
|
77
|
+
const r = !t || e.disabled;
|
|
78
|
+
for (; a; )
|
|
79
|
+
a.formDisabledCallback && r && $(a, e.disabled), a = i.nextNode();
|
|
80
|
+
}, G = { attributes: !0, attributeFilter: ["disabled", "name"] }, C = N() ? new MutationObserver((e) => {
|
|
81
|
+
for (const t of e) {
|
|
82
|
+
const i = t.target;
|
|
83
|
+
if (t.attributeName === "disabled" && (i.constructor.formAssociated ? $(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && j(i)), t.attributeName === "name" && i.constructor.formAssociated) {
|
|
84
|
+
const a = l.get(i), r = W.get(i);
|
|
85
|
+
a.setFormValue(r);
|
|
86
|
+
}
|
|
85
87
|
}
|
|
88
|
+
}) : {};
|
|
89
|
+
function P(e) {
|
|
90
|
+
e.forEach((t) => {
|
|
91
|
+
const { addedNodes: i, removedNodes: a } = t, r = Array.from(i), o = Array.from(a);
|
|
92
|
+
r.forEach((s) => {
|
|
93
|
+
var u;
|
|
94
|
+
if (l.has(s) && s.constructor.formAssociated && K(s), I.has(s)) {
|
|
95
|
+
const d = I.get(s);
|
|
96
|
+
Object.keys(V).filter((f) => d[f] !== null).forEach((f) => {
|
|
97
|
+
s.setAttribute(V[f], d[f]);
|
|
98
|
+
}), I.delete(s);
|
|
99
|
+
}
|
|
100
|
+
if (S.has(s)) {
|
|
101
|
+
const d = S.get(s);
|
|
102
|
+
s.setAttribute("internals-valid", d.validity.valid.toString()), s.setAttribute("internals-invalid", (!d.validity.valid).toString()), s.setAttribute("aria-invalid", (!d.validity.valid).toString()), S.delete(s);
|
|
103
|
+
}
|
|
104
|
+
if (s.localName === "form") {
|
|
105
|
+
const d = y.get(s), b = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
106
|
+
acceptNode(D) {
|
|
107
|
+
return l.has(D) && D.constructor.formAssociated && !(d && d.has(D)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
let f = b.nextNode();
|
|
111
|
+
for (; f; )
|
|
112
|
+
K(f), f = b.nextNode();
|
|
113
|
+
}
|
|
114
|
+
s.localName === "fieldset" && ((u = C.observe) == null || u.call(C, s, G), j(s, !0));
|
|
115
|
+
}), o.forEach((s) => {
|
|
116
|
+
const u = l.get(s);
|
|
117
|
+
u && h.get(u) && Y(u), M.has(s) && M.get(s).disconnect();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
86
120
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
121
|
+
function lt(e) {
|
|
122
|
+
e.forEach((t) => {
|
|
123
|
+
const { removedNodes: i } = t;
|
|
124
|
+
i.forEach((a) => {
|
|
125
|
+
const r = q.get(t.target);
|
|
126
|
+
l.has(a) && tt(a), r.disconnect();
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const dt = (e) => {
|
|
131
|
+
var i, a;
|
|
132
|
+
const t = new MutationObserver(lt);
|
|
133
|
+
(i = window == null ? void 0 : window.ShadyDOM) != null && i.inUse && e.mode && e.host && (e = e.host), (a = t.observe) == null || a.call(t, e, { childList: !0 }), q.set(e, t);
|
|
134
|
+
};
|
|
135
|
+
N() && new MutationObserver(P);
|
|
136
|
+
const R = {
|
|
137
|
+
childList: !0,
|
|
138
|
+
subtree: !0
|
|
139
|
+
}, $ = (e, t) => {
|
|
140
|
+
e.toggleAttribute("internals-disabled", t), t ? e.setAttribute("aria-disabled", "true") : e.removeAttribute("aria-disabled"), e.formDisabledCallback && e.formDisabledCallback.apply(e, [t]);
|
|
141
|
+
}, Y = (e) => {
|
|
142
|
+
h.get(e).forEach((i) => {
|
|
143
|
+
i.remove();
|
|
144
|
+
}), h.set(e, []);
|
|
145
|
+
}, J = (e, t) => {
|
|
146
|
+
const i = document.createElement("input");
|
|
147
|
+
return i.type = "hidden", i.name = e.getAttribute("name"), e.after(i), h.get(t).push(i), i;
|
|
148
|
+
}, ht = (e, t) => {
|
|
149
|
+
var i;
|
|
150
|
+
h.set(t, []), (i = C.observe) == null || i.call(C, e, G);
|
|
151
|
+
}, Q = (e, t) => {
|
|
152
|
+
if (t.length) {
|
|
153
|
+
Array.from(t).forEach((a) => a.addEventListener("click", e.click.bind(e)));
|
|
154
|
+
let i = t[0].id;
|
|
155
|
+
t[0].id || (i = `${t[0].htmlFor}_Label`, t[0].id = i), e.setAttribute("aria-labelledby", i);
|
|
156
|
+
}
|
|
157
|
+
}, T = (e) => {
|
|
158
|
+
const t = Array.from(e.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = y.get(e) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => l.get(o).validity.valid), r = [...t, ...a].includes(!1);
|
|
159
|
+
e.toggleAttribute("internals-invalid", r), e.toggleAttribute("internals-valid", !r);
|
|
160
|
+
}, ut = (e) => {
|
|
161
|
+
T(L(e.target));
|
|
162
|
+
}, pt = (e) => {
|
|
163
|
+
T(L(e.target));
|
|
164
|
+
}, ft = (e) => {
|
|
165
|
+
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((i) => `${i}:not([disabled])`).map((i) => `${i}:not([form])${e.id ? `,${i}[form='${e.id}']` : ""}`).join(",");
|
|
166
|
+
e.addEventListener("click", (i) => {
|
|
167
|
+
if (i.target.closest(t)) {
|
|
168
|
+
const r = y.get(e);
|
|
169
|
+
if (e.noValidate)
|
|
170
|
+
return;
|
|
171
|
+
r.size && Array.from(r).reverse().map((u) => l.get(u).reportValidity()).includes(!1) && i.preventDefault();
|
|
112
172
|
}
|
|
113
|
-
o.localName === "fieldset" && ((u = M.observe) == null || u.call(M, o, K), U(o, !0));
|
|
114
|
-
}), n.forEach((o) => {
|
|
115
|
-
const u = l.get(o);
|
|
116
|
-
u && s.get(u) && j(u), b.has(o) && b.get(o).disconnect();
|
|
117
173
|
});
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
const { removedNodes: e } = t;
|
|
123
|
-
e.forEach((a) => {
|
|
124
|
-
const r = z.get(t.target);
|
|
125
|
-
l.has(a) && X(a), r.disconnect();
|
|
174
|
+
}, mt = (e) => {
|
|
175
|
+
const t = y.get(e.target);
|
|
176
|
+
t && t.size && t.forEach((i) => {
|
|
177
|
+
i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
|
|
126
178
|
});
|
|
127
|
-
})
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
i.toggleAttribute("internals-disabled", t), t ? i.setAttribute("aria-disabled", "true") : i.removeAttribute("aria-disabled"), i.formDisabledCallback && i.formDisabledCallback.apply(i, [t]);
|
|
140
|
-
}, j = (i) => {
|
|
141
|
-
s.get(i).forEach((e) => {
|
|
142
|
-
e.remove();
|
|
143
|
-
}), s.set(i, []);
|
|
144
|
-
}, G = (i, t) => {
|
|
145
|
-
const e = document.createElement("input");
|
|
146
|
-
return e.type = "hidden", e.name = i.getAttribute("name"), i.after(e), s.get(t).push(e), e;
|
|
147
|
-
}, st = (i, t) => {
|
|
148
|
-
var e;
|
|
149
|
-
s.set(t, []), (e = M.observe) == null || e.call(M, i, K);
|
|
150
|
-
}, Y = (i, t) => {
|
|
151
|
-
if (t.length) {
|
|
152
|
-
Array.from(t).forEach((a) => a.addEventListener("click", i.click.bind(i)));
|
|
153
|
-
let e = t[0].id;
|
|
154
|
-
t[0].id || (e = `${t[0].htmlFor}_Label`, t[0].id = e), i.setAttribute("aria-labelledby", e);
|
|
155
|
-
}
|
|
156
|
-
}, T = (i) => {
|
|
157
|
-
const t = Array.from(i.elements).filter((n) => !n.tagName.includes("-") && n.validity).map((n) => n.validity.valid), e = m.get(i) || [], a = Array.from(e).filter((n) => n.isConnected).map((n) => l.get(n).validity.valid), r = [...t, ...a].includes(!1);
|
|
158
|
-
i.toggleAttribute("internals-invalid", r), i.toggleAttribute("internals-valid", !r);
|
|
159
|
-
}, nt = (i) => {
|
|
160
|
-
T(S(i.target));
|
|
161
|
-
}, ct = (i) => {
|
|
162
|
-
T(S(i.target));
|
|
163
|
-
}, lt = (i) => {
|
|
164
|
-
const t = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((e) => `${e}:not([disabled])`).map((e) => `${e}:not([form])${i.id ? `,${e}[form='${i.id}']` : ""}`).join(",");
|
|
165
|
-
i.addEventListener("click", (e) => {
|
|
166
|
-
if (e.target.closest(t)) {
|
|
167
|
-
const r = m.get(i);
|
|
168
|
-
if (i.noValidate)
|
|
169
|
-
return;
|
|
170
|
-
r.size && Array.from(r).reverse().map((u) => l.get(u).reportValidity()).includes(!1) && e.preventDefault();
|
|
179
|
+
}, X = (e, t, i) => {
|
|
180
|
+
if (t) {
|
|
181
|
+
const a = y.get(t);
|
|
182
|
+
if (a)
|
|
183
|
+
a.add(e);
|
|
184
|
+
else {
|
|
185
|
+
const r = /* @__PURE__ */ new Set();
|
|
186
|
+
r.add(e), y.set(t, r), ft(t), t.addEventListener("reset", mt), t.addEventListener("input", ut), t.addEventListener("change", pt);
|
|
187
|
+
}
|
|
188
|
+
k.set(t, { ref: e, internals: i }), e.constructor.formAssociated && e.formAssociatedCallback && setTimeout(() => {
|
|
189
|
+
e.formAssociatedCallback.apply(e, [t]);
|
|
190
|
+
}, 0), T(t);
|
|
171
191
|
}
|
|
172
|
-
})
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
e.constructor.formAssociated
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
E.set(t, { ref: i, internals: e }), i.constructor.formAssociated && i.formAssociatedCallback && setTimeout(() => {
|
|
188
|
-
i.formAssociatedCallback.apply(i, [t]);
|
|
189
|
-
}, 0), T(t);
|
|
190
|
-
}
|
|
191
|
-
}, S = (i) => {
|
|
192
|
-
let t = i.parentNode;
|
|
193
|
-
return t && t.tagName !== "FORM" && (t = S(t)), t;
|
|
194
|
-
}, g = (i, t, e = DOMException) => {
|
|
195
|
-
if (!i.constructor.formAssociated)
|
|
196
|
-
throw new e(t);
|
|
197
|
-
}, Q = (i, t, e) => {
|
|
198
|
-
const a = m.get(i);
|
|
199
|
-
return a && a.size && a.forEach((r) => {
|
|
200
|
-
l.get(r)[e]() || (t = !1);
|
|
201
|
-
}), t;
|
|
202
|
-
}, X = (i) => {
|
|
203
|
-
if (i.constructor.formAssociated) {
|
|
204
|
-
const t = l.get(i), { labels: e, form: a } = t;
|
|
205
|
-
Y(i, e), J(i, a, t);
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
function L() {
|
|
209
|
-
return typeof MutationObserver < "u";
|
|
210
|
-
}
|
|
211
|
-
class ht {
|
|
212
|
-
constructor() {
|
|
213
|
-
this.badInput = !1, this.customError = !1, this.patternMismatch = !1, this.rangeOverflow = !1, this.rangeUnderflow = !1, this.stepMismatch = !1, this.tooLong = !1, this.tooShort = !1, this.typeMismatch = !1, this.valid = !0, this.valueMissing = !1, Object.seal(this);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const ut = (i) => (i.badInput = !1, i.customError = !1, i.patternMismatch = !1, i.rangeOverflow = !1, i.rangeUnderflow = !1, i.stepMismatch = !1, i.tooLong = !1, i.tooShort = !1, i.typeMismatch = !1, i.valid = !0, i.valueMissing = !1, i), pt = (i, t, e) => (i.valid = mt(t), Object.keys(t).forEach((a) => i[a] = t[a]), e && T(e), i), mt = (i) => {
|
|
217
|
-
let t = !0;
|
|
218
|
-
for (let e in i)
|
|
219
|
-
e !== "valid" && i[e] !== !1 && (t = !1);
|
|
220
|
-
return t;
|
|
221
|
-
}, O = /* @__PURE__ */ new WeakMap();
|
|
222
|
-
function Z(i, t) {
|
|
223
|
-
i.toggleAttribute(t, !0), i.part && i.part.add(t);
|
|
224
|
-
}
|
|
225
|
-
class N extends Set {
|
|
226
|
-
static get isPolyfilled() {
|
|
227
|
-
return !0;
|
|
228
|
-
}
|
|
229
|
-
constructor(t) {
|
|
230
|
-
if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
231
|
-
throw new TypeError("Illegal constructor");
|
|
232
|
-
O.set(this, t);
|
|
233
|
-
}
|
|
234
|
-
add(t) {
|
|
235
|
-
if (!/^--/.test(t) || typeof t != "string")
|
|
236
|
-
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
237
|
-
const e = super.add(t), a = O.get(this), r = `state${t}`;
|
|
238
|
-
return a.isConnected ? Z(a, r) : setTimeout(() => {
|
|
239
|
-
Z(a, r);
|
|
240
|
-
}), e;
|
|
241
|
-
}
|
|
242
|
-
clear() {
|
|
243
|
-
for (let [t] of this.entries())
|
|
244
|
-
this.delete(t);
|
|
245
|
-
super.clear();
|
|
246
|
-
}
|
|
247
|
-
delete(t) {
|
|
248
|
-
const e = super.delete(t), a = O.get(this);
|
|
249
|
-
return a.isConnected ? (a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`)) : setTimeout(() => {
|
|
250
|
-
a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`);
|
|
251
|
-
}), e;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
function tt(i, t, e, a) {
|
|
255
|
-
if (e === "a" && !a)
|
|
256
|
-
throw new TypeError("Private accessor was defined without a getter");
|
|
257
|
-
if (typeof t == "function" ? i !== t || !a : !t.has(i))
|
|
258
|
-
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
259
|
-
return e === "m" ? a : e === "a" ? a.call(i) : a ? a.value : t.get(i);
|
|
260
|
-
}
|
|
261
|
-
function ft(i, t, e, a, r) {
|
|
262
|
-
if (a === "m")
|
|
263
|
-
throw new TypeError("Private method is not writable");
|
|
264
|
-
if (a === "a" && !r)
|
|
265
|
-
throw new TypeError("Private accessor was defined without a setter");
|
|
266
|
-
if (typeof t == "function" ? i !== t || !r : !t.has(i))
|
|
267
|
-
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
268
|
-
return a === "a" ? r.call(i, e) : r ? r.value = e : t.set(i, e), e;
|
|
269
|
-
}
|
|
270
|
-
var F;
|
|
271
|
-
class wt {
|
|
272
|
-
constructor(t) {
|
|
273
|
-
F.set(this, void 0), ft(this, F, t, "f");
|
|
274
|
-
for (let e = 0; e < t.length; e++) {
|
|
275
|
-
let a = t[e];
|
|
276
|
-
this[e] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
|
|
277
|
-
}
|
|
278
|
-
Object.freeze(this);
|
|
279
|
-
}
|
|
280
|
-
get length() {
|
|
281
|
-
return tt(this, F, "f").length;
|
|
282
|
-
}
|
|
283
|
-
[(F = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
|
|
284
|
-
return tt(this, F, "f")[Symbol.iterator]();
|
|
285
|
-
}
|
|
286
|
-
item(t) {
|
|
287
|
-
return this[t] == null ? null : this[t];
|
|
288
|
-
}
|
|
289
|
-
namedItem(t) {
|
|
290
|
-
return this[t] == null ? null : this[t];
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
function bt() {
|
|
294
|
-
const i = HTMLFormElement.prototype.checkValidity;
|
|
295
|
-
HTMLFormElement.prototype.checkValidity = e;
|
|
296
|
-
const t = HTMLFormElement.prototype.reportValidity;
|
|
297
|
-
HTMLFormElement.prototype.reportValidity = a;
|
|
298
|
-
function e(...n) {
|
|
299
|
-
let o = i.apply(this, n);
|
|
300
|
-
return Q(this, o, "checkValidity");
|
|
301
|
-
}
|
|
302
|
-
function a(...n) {
|
|
303
|
-
let o = t.apply(this, n);
|
|
304
|
-
return Q(this, o, "reportValidity");
|
|
305
|
-
}
|
|
306
|
-
const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
307
|
-
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
308
|
-
get(...n) {
|
|
309
|
-
const o = r.call(this, ...n), u = Array.from(m.get(this) || []);
|
|
310
|
-
if (u.length === 0)
|
|
311
|
-
return o;
|
|
312
|
-
const d = Array.from(o).concat(u).sort((v, w) => v.compareDocumentPosition ? v.compareDocumentPosition(w) & 2 ? 1 : -1 : 0);
|
|
313
|
-
return new wt(d);
|
|
192
|
+
}, L = (e) => {
|
|
193
|
+
let t = e.parentNode;
|
|
194
|
+
return t && t.tagName !== "FORM" && (t = L(t)), t;
|
|
195
|
+
}, w = (e, t, i = DOMException) => {
|
|
196
|
+
if (!e.constructor.formAssociated)
|
|
197
|
+
throw new i(t);
|
|
198
|
+
}, Z = (e, t, i) => {
|
|
199
|
+
const a = y.get(e);
|
|
200
|
+
return a && a.size && a.forEach((r) => {
|
|
201
|
+
l.get(r)[i]() || (t = !1);
|
|
202
|
+
}), t;
|
|
203
|
+
}, tt = (e) => {
|
|
204
|
+
if (e.constructor.formAssociated) {
|
|
205
|
+
const t = l.get(e), { labels: i, form: a } = t;
|
|
206
|
+
Q(e, i), X(e, a, t);
|
|
314
207
|
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
static get isPolyfilled() {
|
|
319
|
-
return !0;
|
|
208
|
+
};
|
|
209
|
+
function N() {
|
|
210
|
+
return typeof MutationObserver < "u";
|
|
320
211
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
this.states = new N(t), h.set(this, t), c.set(this, a), l.set(t, this), at(t, this), st(t, this), Object.seal(this), e instanceof DocumentFragment && ot(e);
|
|
212
|
+
class wt {
|
|
213
|
+
constructor() {
|
|
214
|
+
this.badInput = !1, this.customError = !1, this.patternMismatch = !1, this.rangeOverflow = !1, this.rangeUnderflow = !1, this.stepMismatch = !1, this.tooLong = !1, this.tooShort = !1, this.typeMismatch = !1, this.valid = !0, this.valueMissing = !1, Object.seal(this);
|
|
215
|
+
}
|
|
326
216
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
217
|
+
const bt = (e) => (e.badInput = !1, e.customError = !1, e.patternMismatch = !1, e.rangeOverflow = !1, e.rangeUnderflow = !1, e.stepMismatch = !1, e.tooLong = !1, e.tooShort = !1, e.typeMismatch = !1, e.valid = !0, e.valueMissing = !1, e), gt = (e, t, i) => (e.valid = vt(t), Object.keys(t).forEach((a) => e[a] = t[a]), i && T(i), e), vt = (e) => {
|
|
218
|
+
let t = !0;
|
|
219
|
+
for (let i in e)
|
|
220
|
+
i !== "valid" && e[i] !== !1 && (t = !1);
|
|
221
|
+
return t;
|
|
222
|
+
}, O = /* @__PURE__ */ new WeakMap();
|
|
223
|
+
function et(e, t) {
|
|
224
|
+
e.toggleAttribute(t, !0), e.part && e.part.add(t);
|
|
225
|
+
}
|
|
226
|
+
class _ extends Set {
|
|
227
|
+
static get isPolyfilled() {
|
|
330
228
|
return !0;
|
|
331
|
-
const e = c.get(this);
|
|
332
|
-
if (!e.valid) {
|
|
333
|
-
const a = new Event("invalid", {
|
|
334
|
-
bubbles: !1,
|
|
335
|
-
cancelable: !0,
|
|
336
|
-
composed: !1
|
|
337
|
-
});
|
|
338
|
-
t.dispatchEvent(a);
|
|
339
229
|
}
|
|
340
|
-
|
|
230
|
+
constructor(t) {
|
|
231
|
+
if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
232
|
+
throw new TypeError("Illegal constructor");
|
|
233
|
+
O.set(this, t);
|
|
234
|
+
}
|
|
235
|
+
add(t) {
|
|
236
|
+
if (!/^--/.test(t) || typeof t != "string")
|
|
237
|
+
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
238
|
+
const i = super.add(t), a = O.get(this), r = `state${t}`;
|
|
239
|
+
return a.isConnected ? et(a, r) : setTimeout(() => {
|
|
240
|
+
et(a, r);
|
|
241
|
+
}), i;
|
|
242
|
+
}
|
|
243
|
+
clear() {
|
|
244
|
+
for (let [t] of this.entries())
|
|
245
|
+
this.delete(t);
|
|
246
|
+
super.clear();
|
|
247
|
+
}
|
|
248
|
+
delete(t) {
|
|
249
|
+
const i = super.delete(t), a = O.get(this);
|
|
250
|
+
return a.isConnected ? (a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`)) : setTimeout(() => {
|
|
251
|
+
a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`);
|
|
252
|
+
}), i;
|
|
253
|
+
}
|
|
341
254
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
255
|
+
function it(e, t, i, a) {
|
|
256
|
+
if (i === "a" && !a)
|
|
257
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
258
|
+
if (typeof t == "function" ? e !== t || !a : !t.has(e))
|
|
259
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
260
|
+
return i === "m" ? a : i === "a" ? a.call(e) : a ? a.value : t.get(e);
|
|
261
|
+
}
|
|
262
|
+
function yt(e, t, i, a, r) {
|
|
263
|
+
if (a === "m")
|
|
264
|
+
throw new TypeError("Private method is not writable");
|
|
265
|
+
if (a === "a" && !r)
|
|
266
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
267
|
+
if (typeof t == "function" ? e !== t || !r : !t.has(e))
|
|
268
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
269
|
+
return a === "a" ? r.call(e, i) : r ? r.value = i : t.set(e, i), i;
|
|
270
|
+
}
|
|
271
|
+
var F;
|
|
272
|
+
class Et {
|
|
273
|
+
constructor(t) {
|
|
274
|
+
F.set(this, void 0), yt(this, F, t, "f");
|
|
275
|
+
for (let i = 0; i < t.length; i++) {
|
|
276
|
+
let a = t[i];
|
|
277
|
+
this[i] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
|
|
278
|
+
}
|
|
279
|
+
Object.freeze(this);
|
|
280
|
+
}
|
|
281
|
+
get length() {
|
|
282
|
+
return it(this, F, "f").length;
|
|
283
|
+
}
|
|
284
|
+
[(F = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
|
|
285
|
+
return it(this, F, "f")[Symbol.iterator]();
|
|
286
|
+
}
|
|
287
|
+
item(t) {
|
|
288
|
+
return this[t] == null ? null : this[t];
|
|
289
|
+
}
|
|
290
|
+
namedItem(t) {
|
|
291
|
+
return this[t] == null ? null : this[t];
|
|
292
|
+
}
|
|
347
293
|
}
|
|
348
|
-
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
|
|
294
|
+
function kt() {
|
|
295
|
+
const e = HTMLFormElement.prototype.checkValidity;
|
|
296
|
+
HTMLFormElement.prototype.checkValidity = i;
|
|
297
|
+
const t = HTMLFormElement.prototype.reportValidity;
|
|
298
|
+
HTMLFormElement.prototype.reportValidity = a;
|
|
299
|
+
function i(...o) {
|
|
300
|
+
let s = e.apply(this, o);
|
|
301
|
+
return Z(this, s, "checkValidity");
|
|
302
|
+
}
|
|
303
|
+
function a(...o) {
|
|
304
|
+
let s = t.apply(this, o);
|
|
305
|
+
return Z(this, s, "reportValidity");
|
|
306
|
+
}
|
|
307
|
+
const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
308
|
+
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
309
|
+
get(...o) {
|
|
310
|
+
const s = r.call(this, ...o), u = Array.from(y.get(this) || []);
|
|
311
|
+
if (u.length === 0)
|
|
312
|
+
return s;
|
|
313
|
+
const d = Array.from(s).concat(u).sort((b, f) => b.compareDocumentPosition ? b.compareDocumentPosition(f) & 2 ? 1 : -1 : 0);
|
|
314
|
+
return new Et(d);
|
|
315
|
+
}
|
|
316
|
+
});
|
|
353
317
|
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (g(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
318
|
+
class at {
|
|
319
|
+
static get isPolyfilled() {
|
|
357
320
|
return !0;
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
321
|
+
}
|
|
322
|
+
constructor(t) {
|
|
323
|
+
if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
324
|
+
throw new TypeError("Illegal constructor");
|
|
325
|
+
const i = t.getRootNode(), a = new wt();
|
|
326
|
+
this.states = new _(t), n.set(this, t), c.set(this, a), l.set(t, this), ct(t, this), ht(t, this), Object.seal(this), i instanceof DocumentFragment && dt(i);
|
|
327
|
+
}
|
|
328
|
+
checkValidity() {
|
|
329
|
+
const t = n.get(this);
|
|
330
|
+
if (w(t, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
331
|
+
return !0;
|
|
332
|
+
const i = c.get(this);
|
|
333
|
+
if (!i.valid) {
|
|
334
|
+
const a = new Event("invalid", {
|
|
335
|
+
bubbles: !1,
|
|
336
|
+
cancelable: !0,
|
|
337
|
+
composed: !1
|
|
338
|
+
});
|
|
339
|
+
t.dispatchEvent(a);
|
|
369
340
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
341
|
+
return i.valid;
|
|
342
|
+
}
|
|
343
|
+
get form() {
|
|
344
|
+
const t = n.get(this);
|
|
345
|
+
w(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
346
|
+
let i;
|
|
347
|
+
return t.constructor.formAssociated === !0 && (i = L(t)), i;
|
|
348
|
+
}
|
|
349
|
+
get labels() {
|
|
350
|
+
const t = n.get(this);
|
|
351
|
+
w(t, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
352
|
+
const i = t.getAttribute("id"), a = t.getRootNode();
|
|
353
|
+
return a && i ? a.querySelectorAll(`[for="${i}"]`) : [];
|
|
354
|
+
}
|
|
355
|
+
reportValidity() {
|
|
356
|
+
const t = n.get(this);
|
|
357
|
+
if (w(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
358
|
+
return !0;
|
|
359
|
+
const i = this.checkValidity(), a = B.get(this);
|
|
360
|
+
if (a && !t.constructor.formAssociated)
|
|
361
|
+
throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
|
|
362
|
+
return !i && a && (t.focus(), a.focus()), i;
|
|
363
|
+
}
|
|
364
|
+
setFormValue(t) {
|
|
365
|
+
const i = n.get(this);
|
|
366
|
+
if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), Y(this), t != null && !(t instanceof FormData)) {
|
|
367
|
+
if (i.getAttribute("name")) {
|
|
368
|
+
const a = J(i, this);
|
|
369
|
+
a.value = t;
|
|
375
370
|
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
constructor() {
|
|
417
|
-
super(), this.internals = this.attachInternals();
|
|
371
|
+
} else
|
|
372
|
+
t != null && t instanceof FormData && Array.from(t).reverse().forEach(([a, r]) => {
|
|
373
|
+
if (typeof r == "string") {
|
|
374
|
+
const o = J(i, this);
|
|
375
|
+
o.name = a, o.value = r;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
W.set(i, t);
|
|
379
|
+
}
|
|
380
|
+
setValidity(t, i, a) {
|
|
381
|
+
const r = n.get(this);
|
|
382
|
+
if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
|
|
383
|
+
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
384
|
+
B.set(this, a);
|
|
385
|
+
const o = c.get(this), s = {};
|
|
386
|
+
for (const b in t)
|
|
387
|
+
s[b] = t[b];
|
|
388
|
+
Object.keys(s).length === 0 && bt(o);
|
|
389
|
+
const u = { ...o, ...s };
|
|
390
|
+
delete u.valid;
|
|
391
|
+
const { valid: d } = gt(o, u, this.form);
|
|
392
|
+
if (!d && !i)
|
|
393
|
+
throw new DOMException("Failed to execute 'setValidity' on 'ElementInternals': The second argument should not be empty if one or more flags in the first argument are true.");
|
|
394
|
+
m.set(this, d ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !d), r.toggleAttribute("internals-valid", d), r.setAttribute("aria-invalid", `${!d}`)) : S.set(r, this);
|
|
395
|
+
}
|
|
396
|
+
get shadowRoot() {
|
|
397
|
+
const t = n.get(this), i = z.get(t);
|
|
398
|
+
return i || null;
|
|
399
|
+
}
|
|
400
|
+
get validationMessage() {
|
|
401
|
+
const t = n.get(this);
|
|
402
|
+
return w(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), m.get(this);
|
|
403
|
+
}
|
|
404
|
+
get validity() {
|
|
405
|
+
const t = n.get(this);
|
|
406
|
+
return w(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), c.get(this);
|
|
407
|
+
}
|
|
408
|
+
get willValidate() {
|
|
409
|
+
const t = n.get(this);
|
|
410
|
+
return w(t, "Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element."), !(t.disabled || t.hasAttribute("disabled") || t.hasAttribute("readonly"));
|
|
418
411
|
}
|
|
419
412
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
"
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
413
|
+
function Mt() {
|
|
414
|
+
if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
|
|
415
|
+
return !1;
|
|
416
|
+
class e extends HTMLElement {
|
|
417
|
+
constructor() {
|
|
418
|
+
super(), this.internals = this.attachInternals();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
const t = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`;
|
|
422
|
+
customElements.define(t, e);
|
|
423
|
+
const i = new e();
|
|
424
|
+
return [
|
|
425
|
+
"shadowRoot",
|
|
426
|
+
"form",
|
|
427
|
+
"willValidate",
|
|
428
|
+
"validity",
|
|
429
|
+
"validationMessage",
|
|
430
|
+
"labels",
|
|
431
|
+
"setFormValue",
|
|
432
|
+
"setValidity",
|
|
433
|
+
"checkValidity",
|
|
434
|
+
"reportValidity"
|
|
435
|
+
].every((a) => a in i.internals);
|
|
436
|
+
}
|
|
437
|
+
let rt = !1, ot = !1;
|
|
438
|
+
function H(e) {
|
|
439
|
+
ot || (ot = !0, window.CustomStateSet = _, e && (HTMLElement.prototype.attachInternals = function(...t) {
|
|
440
|
+
const i = e.call(this, t);
|
|
441
|
+
return i.states = new _(this), i;
|
|
442
|
+
}));
|
|
443
|
+
}
|
|
444
|
+
function st(e = !0) {
|
|
445
|
+
if (!rt) {
|
|
446
|
+
if (rt = !0, typeof window < "u" && (window.ElementInternals = at), typeof CustomElementRegistry < "u") {
|
|
447
|
+
const t = CustomElementRegistry.prototype.define;
|
|
448
|
+
CustomElementRegistry.prototype.define = function(i, a, r) {
|
|
449
|
+
if (a.formAssociated) {
|
|
450
|
+
const o = a.prototype.connectedCallback;
|
|
451
|
+
a.prototype.connectedCallback = function() {
|
|
452
|
+
U.has(this) || (U.set(this, !0), this.hasAttribute("disabled") && $(this, !0)), o != null && o.apply(this), tt(this);
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
t.call(this, i, a, r);
|
|
453
456
|
};
|
|
454
457
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
458
|
+
if (typeof HTMLElement < "u" && (HTMLElement.prototype.attachInternals = function() {
|
|
459
|
+
if (this.tagName) {
|
|
460
|
+
if (this.tagName.indexOf("-") === -1)
|
|
461
|
+
throw new Error("Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.");
|
|
462
|
+
} else
|
|
463
|
+
return {};
|
|
464
|
+
if (l.has(this))
|
|
465
|
+
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
466
|
+
return new at(this);
|
|
467
|
+
}), typeof Element < "u") {
|
|
468
|
+
let t = function(...a) {
|
|
469
|
+
const r = i.apply(this, a);
|
|
470
|
+
if (z.set(this, r), N()) {
|
|
471
|
+
const o = new MutationObserver(P);
|
|
472
|
+
window.ShadyDOM ? o.observe(this, R) : o.observe(r, R), M.set(this, o);
|
|
473
|
+
}
|
|
474
|
+
return r;
|
|
475
|
+
};
|
|
476
|
+
const i = Element.prototype.attachShadow;
|
|
477
|
+
Element.prototype.attachShadow = t;
|
|
473
478
|
}
|
|
474
|
-
|
|
475
|
-
}
|
|
476
|
-
const t = Element.prototype.attachShadow;
|
|
477
|
-
Element.prototype.attachShadow = i;
|
|
479
|
+
N() && typeof document < "u" && new MutationObserver(P).observe(document.documentElement, R), typeof HTMLFormElement < "u" && kt(), (e || typeof window < "u" && !window.CustomStateSet) && H();
|
|
480
|
+
}
|
|
478
481
|
}
|
|
479
|
-
|
|
480
|
-
}
|
|
482
|
+
return !!customElements.polyfillWrapFlushCallback || (Mt() ? typeof window < "u" && !window.CustomStateSet && H(HTMLElement.prototype.attachInternals) : st(!1)), v.forceCustomStateSetPolyfill = H, v.forceElementInternalsPolyfill = st, Object.defineProperty(v, "__esModule", { value: !0 }), v;
|
|
483
|
+
})({});
|
|
481
484
|
})();
|
|
482
|
-
var
|
|
483
|
-
for (var
|
|
484
|
-
(
|
|
485
|
-
return
|
|
485
|
+
var Pt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, g = (v, n, c, h) => {
|
|
486
|
+
for (var l = h > 1 ? void 0 : h ? Rt(n, c) : n, m = v.length - 1, k; m >= 0; m--)
|
|
487
|
+
(k = v[m]) && (l = (h ? k(n, c, l) : k(l)) || l);
|
|
488
|
+
return h && l && Pt(n, c, l), l;
|
|
486
489
|
};
|
|
487
|
-
const
|
|
488
|
-
class
|
|
490
|
+
const nt = "pie-switch";
|
|
491
|
+
class p extends At(It(Ct)) {
|
|
489
492
|
constructor() {
|
|
490
493
|
super(...arguments), this.labelPlacement = "leading", this.checked = !1, this.required = !1, this.value = "on", this.disabled = !1;
|
|
491
494
|
}
|
|
492
|
-
firstUpdated(
|
|
493
|
-
var
|
|
494
|
-
super.firstUpdated(
|
|
495
|
-
this.dispatchEvent(new Event("invalid",
|
|
495
|
+
firstUpdated(n) {
|
|
496
|
+
var c;
|
|
497
|
+
super.firstUpdated(n), this.handleFormAssociation(), (c = this.input) == null || c.addEventListener("invalid", (h) => {
|
|
498
|
+
this.dispatchEvent(new Event("invalid", h));
|
|
496
499
|
});
|
|
497
500
|
}
|
|
498
|
-
updated(
|
|
499
|
-
super.updated(
|
|
501
|
+
updated(n) {
|
|
502
|
+
super.updated(n), this.handleFormAssociation();
|
|
500
503
|
}
|
|
501
504
|
/**
|
|
502
505
|
* Ensures that the form value and validation state are in sync with the component.
|
|
@@ -508,11 +511,11 @@ class f extends kt(Mt(vt)) {
|
|
|
508
511
|
* The onChange function updates the checkbox state and emits an event for consumers.
|
|
509
512
|
* @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
|
|
510
513
|
*/
|
|
511
|
-
onChange(
|
|
512
|
-
const { checked:
|
|
513
|
-
this.checked =
|
|
514
|
-
const
|
|
515
|
-
this.dispatchEvent(
|
|
514
|
+
onChange(n) {
|
|
515
|
+
const { checked: c } = n == null ? void 0 : n.currentTarget;
|
|
516
|
+
this.checked = c;
|
|
517
|
+
const h = St(n);
|
|
518
|
+
this.dispatchEvent(h), this.handleFormAssociation();
|
|
516
519
|
}
|
|
517
520
|
/**
|
|
518
521
|
* Returns a boolean value which indicates validity of the value of the component. If the value is invalid, this method also fires the invalid event on the component.
|
|
@@ -534,9 +537,9 @@ class f extends kt(Mt(vt)) {
|
|
|
534
537
|
* Allows a consumer to set a custom validation message on the switch. An empty string counts as valid.
|
|
535
538
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
536
539
|
*/
|
|
537
|
-
setCustomValidity(
|
|
538
|
-
var
|
|
539
|
-
(
|
|
540
|
+
setCustomValidity(n) {
|
|
541
|
+
var c;
|
|
542
|
+
(c = this.input) == null || c.setCustomValidity(n), this._internals.setValidity(this.validity, this.validationMessage, this.input);
|
|
540
543
|
}
|
|
541
544
|
/**
|
|
542
545
|
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
@@ -560,87 +563,87 @@ class f extends kt(Mt(vt)) {
|
|
|
560
563
|
* @private
|
|
561
564
|
*/
|
|
562
565
|
renderSwitchLabel() {
|
|
563
|
-
const { label:
|
|
564
|
-
return
|
|
566
|
+
const { label: n, labelPlacement: c } = this;
|
|
567
|
+
return n ? A`
|
|
565
568
|
<label
|
|
566
569
|
for="switch"
|
|
567
|
-
data-test-id="switch-label-${
|
|
568
|
-
${
|
|
570
|
+
data-test-id="switch-label-${c}">
|
|
571
|
+
${n}
|
|
569
572
|
</label>` : A``;
|
|
570
573
|
}
|
|
571
574
|
render() {
|
|
572
575
|
const {
|
|
573
|
-
labelPlacement:
|
|
574
|
-
aria:
|
|
575
|
-
checked:
|
|
576
|
-
required:
|
|
577
|
-
disabled:
|
|
578
|
-
isRTL:
|
|
579
|
-
} = this,
|
|
576
|
+
labelPlacement: n,
|
|
577
|
+
aria: c,
|
|
578
|
+
checked: h,
|
|
579
|
+
required: l,
|
|
580
|
+
disabled: m,
|
|
581
|
+
isRTL: k
|
|
582
|
+
} = this, M = "switch-description";
|
|
580
583
|
return A`
|
|
581
584
|
<div
|
|
582
585
|
class="c-switch-wrapper"
|
|
583
|
-
?isRTL=${
|
|
584
|
-
?disabled=${
|
|
585
|
-
${
|
|
586
|
+
?isRTL=${k}
|
|
587
|
+
?disabled=${m}>
|
|
588
|
+
${n === "leading" ? this.renderSwitchLabel() : x}
|
|
586
589
|
<label
|
|
587
590
|
data-test-id="switch-component"
|
|
588
591
|
class="c-switch"
|
|
589
|
-
?checked=${
|
|
592
|
+
?checked=${h}>
|
|
590
593
|
<input
|
|
591
594
|
id="switch"
|
|
592
595
|
data-test-id="switch-input"
|
|
593
596
|
role="switch"
|
|
594
597
|
type="checkbox"
|
|
595
598
|
class="c-switch-input"
|
|
596
|
-
.required=${
|
|
597
|
-
.checked="${
|
|
598
|
-
.disabled="${
|
|
599
|
+
.required=${l}
|
|
600
|
+
.checked="${h}"
|
|
601
|
+
.disabled="${m}"
|
|
599
602
|
@change="${this.onChange}"
|
|
600
|
-
aria-label="${(
|
|
601
|
-
aria-describedby="${
|
|
603
|
+
aria-label="${(c == null ? void 0 : c.label) || x}"
|
|
604
|
+
aria-describedby="${c != null && c.describedBy ? M : x}">
|
|
602
605
|
<div class="c-switch-control">
|
|
603
|
-
${
|
|
606
|
+
${h ? A`<icon-check></icon-check>` : x}
|
|
604
607
|
</div>
|
|
605
608
|
</label>
|
|
606
|
-
${
|
|
607
|
-
${
|
|
609
|
+
${c != null && c.describedBy ? A`<div id="${M}" data-test-id="${M}" class="c-switch-description">${c == null ? void 0 : c.describedBy}</div>` : x}
|
|
610
|
+
${n === "trailing" ? this.renderSwitchLabel() : x}
|
|
608
611
|
</div>
|
|
609
612
|
`;
|
|
610
613
|
}
|
|
611
614
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
],
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
],
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
],
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
],
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
],
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
],
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
],
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
],
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
],
|
|
641
|
-
|
|
615
|
+
p.styles = xt(Lt);
|
|
616
|
+
g([
|
|
617
|
+
Ft('input[type="checkbox"]')
|
|
618
|
+
], p.prototype, "input", 2);
|
|
619
|
+
g([
|
|
620
|
+
E({ type: String })
|
|
621
|
+
], p.prototype, "label", 2);
|
|
622
|
+
g([
|
|
623
|
+
E({ type: String }),
|
|
624
|
+
Vt(nt, Nt, "leading")
|
|
625
|
+
], p.prototype, "labelPlacement", 2);
|
|
626
|
+
g([
|
|
627
|
+
E({ type: Object })
|
|
628
|
+
], p.prototype, "aria", 2);
|
|
629
|
+
g([
|
|
630
|
+
E({ type: Boolean, reflect: !0 })
|
|
631
|
+
], p.prototype, "checked", 2);
|
|
632
|
+
g([
|
|
633
|
+
E({ type: Boolean, reflect: !0 })
|
|
634
|
+
], p.prototype, "required", 2);
|
|
635
|
+
g([
|
|
636
|
+
E({ type: String })
|
|
637
|
+
], p.prototype, "value", 2);
|
|
638
|
+
g([
|
|
639
|
+
E({ type: String })
|
|
640
|
+
], p.prototype, "name", 2);
|
|
641
|
+
g([
|
|
642
|
+
E({ type: Boolean, reflect: !0 })
|
|
643
|
+
], p.prototype, "disabled", 2);
|
|
644
|
+
Tt(nt, p);
|
|
642
645
|
export {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
+
Wt as ON_SWITCH_CHANGED_EVENT,
|
|
647
|
+
p as PieSwitch,
|
|
648
|
+
Nt as labelPlacements
|
|
646
649
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -92,8 +92,8 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps {
|
|
|
92
92
|
declare const PieSwitch_base: GenericConstructor<FormControlInterface> & GenericConstructor<RTLInterface> & typeof LitElement;
|
|
93
93
|
|
|
94
94
|
declare type PieSwitchEvents = {
|
|
95
|
-
onInvalid?: (event: Event
|
|
96
|
-
onChange?: (event: CustomEvent
|
|
95
|
+
onInvalid?: (event: Event) => void;
|
|
96
|
+
onChange?: (event: CustomEvent) => void;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
declare type ReactBaseType = React_2.InputHTMLAttributes<HTMLInputElement>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-switch",
|
|
3
3
|
"description": "PIE Design System Switch built using Web Components",
|
|
4
|
-
"version": "0.24.
|
|
4
|
+
"version": "0.24.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@justeattakeaway/pie-icons-webc": "0.17.
|
|
40
|
-
"@justeattakeaway/pie-webc-core": "0.17.
|
|
41
|
-
"@justeattakeaway/pie-wrapper-react": "0.
|
|
42
|
-
"element-internals-polyfill": "1.3.
|
|
39
|
+
"@justeattakeaway/pie-icons-webc": "0.17.2",
|
|
40
|
+
"@justeattakeaway/pie-webc-core": "0.17.1",
|
|
41
|
+
"@justeattakeaway/pie-wrapper-react": "0.14.0",
|
|
42
|
+
"element-internals-polyfill": "1.3.10"
|
|
43
43
|
},
|
|
44
44
|
"volta": {
|
|
45
45
|
"extends": "../../../package.json"
|
package/src/react.ts
CHANGED
|
@@ -19,8 +19,9 @@ const PieSwitchReact = createComponent({
|
|
|
19
19
|
type ReactBaseType = React.InputHTMLAttributes<HTMLInputElement>
|
|
20
20
|
|
|
21
21
|
type PieSwitchEvents = {
|
|
22
|
-
onInvalid?: (event: Event
|
|
23
|
-
onChange?: (event: CustomEvent
|
|
22
|
+
onInvalid?: (event: Event) => void;
|
|
23
|
+
onChange?: (event: CustomEvent) => void;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
export const PieSwitch = PieSwitchReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<SwitchProps>
|
|
26
|
+
export const PieSwitch = PieSwitchReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<SwitchProps>
|
|
27
|
+
& React.RefAttributes<PieSwitchLit> & PieSwitchEvents & ReactBaseType>;
|