@justeattakeaway/pie-switch 2.5.1 → 2.5.2
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/custom-elements.json +4 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +273 -270
- package/dist/react.d.ts +4 -2
- package/package.json +3 -3
- package/src/index.ts +13 -7
- package/src/switch.scss +3 -3
package/custom-elements.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { AssociatedLabelInterface } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
3
|
import { CSSResult } from 'lit';
|
|
3
4
|
import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
4
5
|
import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
5
6
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
6
7
|
import { PIEInputElement } from '@justeattakeaway/pie-webc-core';
|
|
8
|
+
import { PropertyValues } from 'lit';
|
|
7
9
|
import { TemplateResult } from 'lit-html';
|
|
8
10
|
|
|
9
11
|
declare type AriaProps = {
|
|
@@ -43,7 +45,7 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
|
|
|
43
45
|
focusTarget: HTMLElement;
|
|
44
46
|
private _abortController;
|
|
45
47
|
private _isAnimationAllowed;
|
|
46
|
-
protected firstUpdated(): void;
|
|
48
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
47
49
|
connectedCallback(): void;
|
|
48
50
|
disconnectedCallback(): void;
|
|
49
51
|
protected updated(): void;
|
|
@@ -95,7 +97,7 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
|
|
|
95
97
|
render(): TemplateResult;
|
|
96
98
|
}
|
|
97
99
|
|
|
98
|
-
declare const PieSwitch_base: GenericConstructor<FormControlInterface> & typeof PieElement;
|
|
100
|
+
declare const PieSwitch_base: GenericConstructor<AssociatedLabelInterface> & GenericConstructor<FormControlInterface> & typeof PieElement;
|
|
99
101
|
|
|
100
102
|
export declare interface SwitchProps {
|
|
101
103
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { unsafeStatic as
|
|
3
|
-
import { property as y, query as
|
|
4
|
-
import { classMap as
|
|
5
|
-
import { ifDefined as
|
|
6
|
-
import { live as
|
|
7
|
-
import {
|
|
1
|
+
import { LitElement as Se, nothing as P, html as B, unsafeCSS as Ve } from "lit";
|
|
2
|
+
import { unsafeStatic as Te, html as Le } from "lit/static-html.js";
|
|
3
|
+
import { property as y, query as U, state as Ne } from "lit/decorators.js";
|
|
4
|
+
import { classMap as Pe } from "lit/directives/class-map.js";
|
|
5
|
+
import { ifDefined as _e } from "lit/directives/if-defined.js";
|
|
6
|
+
import { live as Oe } from "lit/directives/live.js";
|
|
7
|
+
import { AssociatedLabelMixin as $e, FormControlMixin as De, DelegatesFocusMixin as Re, wrapNativeEvent as He, validPropertyValues as We, safeCustomElement as ze } from "@justeattakeaway/pie-webc-core";
|
|
8
8
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
9
|
-
const
|
|
9
|
+
const _ = class _ extends Se {
|
|
10
10
|
willUpdate() {
|
|
11
|
-
this.getAttribute("v") || this.setAttribute("v",
|
|
11
|
+
this.getAttribute("v") || this.setAttribute("v", _.v);
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
|
|
15
|
-
let
|
|
16
|
-
var
|
|
17
|
-
function
|
|
18
|
-
return
|
|
14
|
+
_.v = "2.5.2";
|
|
15
|
+
let q = _;
|
|
16
|
+
var he = {}, ue;
|
|
17
|
+
function Be() {
|
|
18
|
+
return ue || (ue = 1, (function() {
|
|
19
19
|
(function(n) {
|
|
20
|
-
const l = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(),
|
|
20
|
+
const l = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), S = {
|
|
21
21
|
ariaAtomic: "aria-atomic",
|
|
22
22
|
ariaAutoComplete: "aria-autocomplete",
|
|
23
23
|
ariaBusy: "aria-busy",
|
|
@@ -60,253 +60,253 @@ function zt() {
|
|
|
60
60
|
ariaValueNow: "aria-valuenow",
|
|
61
61
|
ariaValueText: "aria-valuetext",
|
|
62
62
|
role: "role"
|
|
63
|
-
},
|
|
64
|
-
for (let i in
|
|
65
|
-
|
|
63
|
+
}, pe = (t, e) => {
|
|
64
|
+
for (let i in S) {
|
|
65
|
+
e[i] = null;
|
|
66
66
|
let a = null;
|
|
67
|
-
const r =
|
|
68
|
-
Object.defineProperty(
|
|
67
|
+
const r = S[i];
|
|
68
|
+
Object.defineProperty(e, i, {
|
|
69
69
|
get() {
|
|
70
70
|
return a;
|
|
71
71
|
},
|
|
72
72
|
set(o) {
|
|
73
|
-
a = o,
|
|
73
|
+
a = o, t.isConnected ? t.setAttribute(r, o) : M.set(t, e);
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
function Q(
|
|
79
|
-
const
|
|
80
|
-
|
|
78
|
+
function Q(t) {
|
|
79
|
+
const e = c.get(t), { form: i } = e;
|
|
80
|
+
ie(t, i, e), te(t, e.labels);
|
|
81
81
|
}
|
|
82
|
-
const X = (
|
|
83
|
-
const i = document.createTreeWalker(
|
|
82
|
+
const X = (t, e = !1) => {
|
|
83
|
+
const i = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
|
|
84
84
|
acceptNode(o) {
|
|
85
85
|
return c.has(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
let a = i.nextNode();
|
|
89
|
-
const r = !
|
|
89
|
+
const r = !e || t.disabled;
|
|
90
90
|
for (; a; )
|
|
91
|
-
a.formDisabledCallback && r &&
|
|
92
|
-
}, Y = { attributes: !0, attributeFilter: ["disabled", "name"] },
|
|
93
|
-
for (const
|
|
94
|
-
const i =
|
|
95
|
-
if (
|
|
96
|
-
const a = c.get(i), r =
|
|
91
|
+
a.formDisabledCallback && r && D(a, t.disabled), a = i.nextNode();
|
|
92
|
+
}, Y = { attributes: !0, attributeFilter: ["disabled", "name"] }, V = N() ? new MutationObserver((t) => {
|
|
93
|
+
for (const e of t) {
|
|
94
|
+
const i = e.target;
|
|
95
|
+
if (e.attributeName === "disabled" && (i.constructor.formAssociated ? D(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && X(i)), e.attributeName === "name" && i.constructor.formAssociated) {
|
|
96
|
+
const a = c.get(i), r = F.get(i);
|
|
97
97
|
a.setFormValue(r);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
}) : {};
|
|
101
|
-
function O(
|
|
102
|
-
|
|
103
|
-
const { addedNodes: i, removedNodes: a } =
|
|
101
|
+
function O(t) {
|
|
102
|
+
t.forEach((e) => {
|
|
103
|
+
const { addedNodes: i, removedNodes: a } = e, r = Array.from(i), o = Array.from(a);
|
|
104
104
|
r.forEach((s) => {
|
|
105
105
|
var m;
|
|
106
|
-
if (c.has(s) && s.constructor.formAssociated && Q(s),
|
|
107
|
-
const h =
|
|
108
|
-
Object.keys(
|
|
109
|
-
s.setAttribute(
|
|
110
|
-
}),
|
|
106
|
+
if (c.has(s) && s.constructor.formAssociated && Q(s), M.has(s)) {
|
|
107
|
+
const h = M.get(s);
|
|
108
|
+
Object.keys(S).filter((v) => h[v] !== null).forEach((v) => {
|
|
109
|
+
s.setAttribute(S[v], h[v]);
|
|
110
|
+
}), M.delete(s);
|
|
111
111
|
}
|
|
112
|
-
if (
|
|
113
|
-
const h =
|
|
114
|
-
s.setAttribute("internals-valid", h.validity.valid.toString()), s.setAttribute("internals-invalid", (!h.validity.valid).toString()), s.setAttribute("aria-invalid", (!h.validity.valid).toString()),
|
|
112
|
+
if (I.has(s)) {
|
|
113
|
+
const h = I.get(s);
|
|
114
|
+
s.setAttribute("internals-valid", h.validity.valid.toString()), s.setAttribute("internals-invalid", (!h.validity.valid).toString()), s.setAttribute("aria-invalid", (!h.validity.valid).toString()), I.delete(s);
|
|
115
115
|
}
|
|
116
116
|
if (s.localName === "form") {
|
|
117
117
|
const h = b.get(s), g = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
118
|
-
acceptNode(
|
|
119
|
-
return c.has(
|
|
118
|
+
acceptNode(z) {
|
|
119
|
+
return c.has(z) && z.constructor.formAssociated && !(h && h.has(z)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
120
120
|
}
|
|
121
121
|
});
|
|
122
122
|
let v = g.nextNode();
|
|
123
123
|
for (; v; )
|
|
124
124
|
Q(v), v = g.nextNode();
|
|
125
125
|
}
|
|
126
|
-
s.localName === "fieldset" && ((m =
|
|
126
|
+
s.localName === "fieldset" && ((m = V.observe) === null || m === void 0 || m.call(V, s, Y), X(s, !0));
|
|
127
127
|
}), o.forEach((s) => {
|
|
128
128
|
const m = c.get(s);
|
|
129
|
-
m && u.get(m) && Z(m),
|
|
129
|
+
m && u.get(m) && Z(m), C.has(s) && C.get(s).disconnect();
|
|
130
130
|
});
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
-
function
|
|
134
|
-
|
|
135
|
-
const { removedNodes: i } =
|
|
133
|
+
function me(t) {
|
|
134
|
+
t.forEach((e) => {
|
|
135
|
+
const { removedNodes: i } = e;
|
|
136
136
|
i.forEach((a) => {
|
|
137
|
-
const r = G.get(
|
|
138
|
-
c.has(a) &&
|
|
137
|
+
const r = G.get(e.target);
|
|
138
|
+
c.has(a) && re(a), r.disconnect();
|
|
139
139
|
});
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
|
-
const
|
|
143
|
-
var
|
|
144
|
-
const a = new MutationObserver(
|
|
145
|
-
!((
|
|
142
|
+
const fe = (t) => {
|
|
143
|
+
var e, i;
|
|
144
|
+
const a = new MutationObserver(me);
|
|
145
|
+
!((e = window == null ? void 0 : window.ShadyDOM) === null || e === void 0) && e.inUse && t.mode && t.host && (t = t.host), (i = a.observe) === null || i === void 0 || i.call(a, t, { childList: !0 }), G.set(t, a);
|
|
146
146
|
};
|
|
147
|
-
|
|
148
|
-
const
|
|
147
|
+
N() && new MutationObserver(O);
|
|
148
|
+
const $ = {
|
|
149
149
|
childList: !0,
|
|
150
150
|
subtree: !0
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
}, Z = (
|
|
154
|
-
u.get(
|
|
151
|
+
}, D = (t, e) => {
|
|
152
|
+
t.toggleAttribute("internals-disabled", e), e ? t.setAttribute("aria-disabled", "true") : t.removeAttribute("aria-disabled"), t.formDisabledCallback && t.formDisabledCallback.apply(t, [e]);
|
|
153
|
+
}, Z = (t) => {
|
|
154
|
+
u.get(t).forEach((i) => {
|
|
155
155
|
i.remove();
|
|
156
|
-
}), u.set(
|
|
157
|
-
},
|
|
156
|
+
}), u.set(t, []);
|
|
157
|
+
}, ee = (t, e) => {
|
|
158
158
|
const i = document.createElement("input");
|
|
159
|
-
return i.type = "hidden", i.name =
|
|
160
|
-
},
|
|
159
|
+
return i.type = "hidden", i.name = t.getAttribute("name"), t.after(i), u.get(e).push(i), i;
|
|
160
|
+
}, be = (t, e) => {
|
|
161
161
|
var i;
|
|
162
|
-
u.set(
|
|
163
|
-
},
|
|
164
|
-
if (
|
|
165
|
-
Array.from(
|
|
166
|
-
let i =
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
if (i.target.closest(
|
|
180
|
-
const r = b.get(
|
|
181
|
-
if (
|
|
162
|
+
u.set(e, []), (i = V.observe) === null || i === void 0 || i.call(V, t, Y);
|
|
163
|
+
}, te = (t, e) => {
|
|
164
|
+
if (e.length) {
|
|
165
|
+
Array.from(e).forEach((a) => a.addEventListener("click", t.click.bind(t)));
|
|
166
|
+
let i = e[0].id;
|
|
167
|
+
e[0].id || (i = `${e[0].htmlFor}_Label`, e[0].id = i), t.setAttribute("aria-labelledby", i);
|
|
168
|
+
}
|
|
169
|
+
}, T = (t) => {
|
|
170
|
+
const e = Array.from(t.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = b.get(t) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => c.get(o).validity.valid), r = [...e, ...a].includes(!1);
|
|
171
|
+
t.toggleAttribute("internals-invalid", r), t.toggleAttribute("internals-valid", !r);
|
|
172
|
+
}, ve = (t) => {
|
|
173
|
+
T(L(t.target));
|
|
174
|
+
}, we = (t) => {
|
|
175
|
+
T(L(t.target));
|
|
176
|
+
}, ge = (t) => {
|
|
177
|
+
const e = ["button[type=submit]", "input[type=submit]", "button:not([type])"].map((i) => `${i}:not([disabled])`).map((i) => `${i}:not([form])${t.id ? `,${i}[form='${t.id}']` : ""}`).join(",");
|
|
178
|
+
t.addEventListener("click", (i) => {
|
|
179
|
+
if (i.target.closest(e)) {
|
|
180
|
+
const r = b.get(t);
|
|
181
|
+
if (t.noValidate)
|
|
182
182
|
return;
|
|
183
183
|
r.size && Array.from(r).reverse().map((m) => c.get(m).reportValidity()).includes(!1) && i.preventDefault();
|
|
184
184
|
}
|
|
185
185
|
});
|
|
186
|
-
},
|
|
187
|
-
const
|
|
188
|
-
|
|
186
|
+
}, ye = (t) => {
|
|
187
|
+
const e = b.get(t.target);
|
|
188
|
+
e && e.size && e.forEach((i) => {
|
|
189
189
|
i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
|
|
190
190
|
});
|
|
191
|
-
},
|
|
192
|
-
if (
|
|
193
|
-
const a = b.get(
|
|
191
|
+
}, ie = (t, e, i) => {
|
|
192
|
+
if (e) {
|
|
193
|
+
const a = b.get(e);
|
|
194
194
|
if (a)
|
|
195
|
-
a.add(
|
|
195
|
+
a.add(t);
|
|
196
196
|
else {
|
|
197
197
|
const r = /* @__PURE__ */ new Set();
|
|
198
|
-
r.add(
|
|
198
|
+
r.add(t), b.set(e, r), ge(e), e.addEventListener("reset", ye), e.addEventListener("input", ve), e.addEventListener("change", we);
|
|
199
199
|
}
|
|
200
|
-
E.set(
|
|
201
|
-
|
|
202
|
-
}, 0),
|
|
203
|
-
}
|
|
204
|
-
},
|
|
205
|
-
let
|
|
206
|
-
return
|
|
207
|
-
}, w = (
|
|
208
|
-
if (!
|
|
209
|
-
throw new i(
|
|
210
|
-
},
|
|
211
|
-
const a = b.get(
|
|
200
|
+
E.set(e, { ref: t, internals: i }), t.constructor.formAssociated && t.formAssociatedCallback && setTimeout(() => {
|
|
201
|
+
t.formAssociatedCallback.apply(t, [e]);
|
|
202
|
+
}, 0), T(e);
|
|
203
|
+
}
|
|
204
|
+
}, L = (t) => {
|
|
205
|
+
let e = t.parentNode;
|
|
206
|
+
return e && e.tagName !== "FORM" && (e = L(e)), e;
|
|
207
|
+
}, w = (t, e, i = DOMException) => {
|
|
208
|
+
if (!t.constructor.formAssociated)
|
|
209
|
+
throw new i(e);
|
|
210
|
+
}, ae = (t, e, i) => {
|
|
211
|
+
const a = b.get(t);
|
|
212
212
|
return a && a.size && a.forEach((r) => {
|
|
213
|
-
c.get(r)[i]() || (
|
|
214
|
-
}),
|
|
215
|
-
},
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
|
|
213
|
+
c.get(r)[i]() || (e = !1);
|
|
214
|
+
}), e;
|
|
215
|
+
}, re = (t) => {
|
|
216
|
+
if (t.constructor.formAssociated) {
|
|
217
|
+
const e = c.get(t), { labels: i, form: a } = e;
|
|
218
|
+
te(t, i), ie(t, a, e);
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
|
-
function
|
|
221
|
+
function N() {
|
|
222
222
|
return typeof MutationObserver < "u";
|
|
223
223
|
}
|
|
224
|
-
class
|
|
224
|
+
class ke {
|
|
225
225
|
constructor() {
|
|
226
226
|
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);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
let
|
|
231
|
-
for (let i in
|
|
232
|
-
i !== "valid" &&
|
|
233
|
-
return
|
|
234
|
-
},
|
|
235
|
-
function
|
|
236
|
-
|
|
229
|
+
const Ee = (t) => (t.badInput = !1, t.customError = !1, t.patternMismatch = !1, t.rangeOverflow = !1, t.rangeUnderflow = !1, t.stepMismatch = !1, t.tooLong = !1, t.tooShort = !1, t.typeMismatch = !1, t.valid = !0, t.valueMissing = !1, t), Me = (t, e, i) => (t.valid = xe(e), Object.keys(e).forEach((a) => t[a] = e[a]), i && T(i), t), xe = (t) => {
|
|
230
|
+
let e = !0;
|
|
231
|
+
for (let i in t)
|
|
232
|
+
i !== "valid" && t[i] !== !1 && (e = !1);
|
|
233
|
+
return e;
|
|
234
|
+
}, R = /* @__PURE__ */ new WeakMap();
|
|
235
|
+
function oe(t, e) {
|
|
236
|
+
t.toggleAttribute(e, !0), t.part && t.part.add(e);
|
|
237
237
|
}
|
|
238
|
-
class
|
|
238
|
+
class H extends Set {
|
|
239
239
|
static get isPolyfilled() {
|
|
240
240
|
return !0;
|
|
241
241
|
}
|
|
242
|
-
constructor(
|
|
243
|
-
if (super(), !
|
|
242
|
+
constructor(e) {
|
|
243
|
+
if (super(), !e || !e.tagName || e.tagName.indexOf("-") === -1)
|
|
244
244
|
throw new TypeError("Illegal constructor");
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
add(
|
|
248
|
-
if (!/^--/.test(
|
|
249
|
-
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${
|
|
250
|
-
const i = super.add(
|
|
251
|
-
return a.isConnected ?
|
|
252
|
-
|
|
245
|
+
R.set(this, e);
|
|
246
|
+
}
|
|
247
|
+
add(e) {
|
|
248
|
+
if (!/^--/.test(e) || typeof e != "string")
|
|
249
|
+
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);
|
|
250
|
+
const i = super.add(e), a = R.get(this), r = `state${e}`;
|
|
251
|
+
return a.isConnected ? oe(a, r) : setTimeout(() => {
|
|
252
|
+
oe(a, r);
|
|
253
253
|
}), i;
|
|
254
254
|
}
|
|
255
255
|
clear() {
|
|
256
|
-
for (let [
|
|
257
|
-
this.delete(
|
|
256
|
+
for (let [e] of this.entries())
|
|
257
|
+
this.delete(e);
|
|
258
258
|
super.clear();
|
|
259
259
|
}
|
|
260
|
-
delete(
|
|
261
|
-
const i = super.delete(
|
|
262
|
-
return a.isConnected ? (a.toggleAttribute(`state${
|
|
263
|
-
a.toggleAttribute(`state${
|
|
260
|
+
delete(e) {
|
|
261
|
+
const i = super.delete(e), a = R.get(this);
|
|
262
|
+
return a.isConnected ? (a.toggleAttribute(`state${e}`, !1), a.part && a.part.remove(`state${e}`)) : setTimeout(() => {
|
|
263
|
+
a.toggleAttribute(`state${e}`, !1), a.part && a.part.remove(`state${e}`);
|
|
264
264
|
}), i;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
if (typeof
|
|
269
|
-
return i === "m" ? a : i === "a" ? a.call(
|
|
267
|
+
function se(t, e, i, a) {
|
|
268
|
+
if (typeof e == "function" ? t !== e || !a : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
269
|
+
return i === "m" ? a : i === "a" ? a.call(t) : a ? a.value : e.get(t);
|
|
270
270
|
}
|
|
271
|
-
function
|
|
272
|
-
if (typeof
|
|
273
|
-
return
|
|
271
|
+
function Ce(t, e, i, a, r) {
|
|
272
|
+
if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
273
|
+
return e.set(t, i), i;
|
|
274
274
|
}
|
|
275
|
-
var
|
|
276
|
-
class
|
|
277
|
-
constructor(
|
|
278
|
-
|
|
279
|
-
for (let i = 0; i <
|
|
280
|
-
let a =
|
|
275
|
+
var A;
|
|
276
|
+
class Ae {
|
|
277
|
+
constructor(e) {
|
|
278
|
+
A.set(this, void 0), Ce(this, A, e);
|
|
279
|
+
for (let i = 0; i < e.length; i++) {
|
|
280
|
+
let a = e[i];
|
|
281
281
|
this[i] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
|
|
282
282
|
}
|
|
283
283
|
Object.freeze(this);
|
|
284
284
|
}
|
|
285
285
|
get length() {
|
|
286
|
-
return
|
|
286
|
+
return se(this, A, "f").length;
|
|
287
287
|
}
|
|
288
|
-
[(
|
|
289
|
-
return
|
|
288
|
+
[(A = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
|
|
289
|
+
return se(this, A, "f")[Symbol.iterator]();
|
|
290
290
|
}
|
|
291
|
-
item(
|
|
292
|
-
return this[
|
|
291
|
+
item(e) {
|
|
292
|
+
return this[e] == null ? null : this[e];
|
|
293
293
|
}
|
|
294
|
-
namedItem(
|
|
295
|
-
return this[
|
|
294
|
+
namedItem(e) {
|
|
295
|
+
return this[e] == null ? null : this[e];
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
function
|
|
299
|
-
const
|
|
298
|
+
function Fe() {
|
|
299
|
+
const t = HTMLFormElement.prototype.checkValidity;
|
|
300
300
|
HTMLFormElement.prototype.checkValidity = i;
|
|
301
|
-
const
|
|
301
|
+
const e = HTMLFormElement.prototype.reportValidity;
|
|
302
302
|
HTMLFormElement.prototype.reportValidity = a;
|
|
303
303
|
function i(...o) {
|
|
304
|
-
let s =
|
|
305
|
-
return
|
|
304
|
+
let s = t.apply(this, o);
|
|
305
|
+
return ae(this, s, "checkValidity");
|
|
306
306
|
}
|
|
307
307
|
function a(...o) {
|
|
308
|
-
let s =
|
|
309
|
-
return
|
|
308
|
+
let s = e.apply(this, o);
|
|
309
|
+
return ae(this, s, "reportValidity");
|
|
310
310
|
}
|
|
311
311
|
const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
312
312
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
@@ -315,23 +315,23 @@ function zt() {
|
|
|
315
315
|
if (m.length === 0)
|
|
316
316
|
return s;
|
|
317
317
|
const h = Array.from(s).concat(m).sort((g, v) => g.compareDocumentPosition ? g.compareDocumentPosition(v) & 2 ? 1 : -1 : 0);
|
|
318
|
-
return new
|
|
318
|
+
return new Ae(h);
|
|
319
319
|
}
|
|
320
320
|
});
|
|
321
321
|
}
|
|
322
|
-
class
|
|
322
|
+
class ne {
|
|
323
323
|
static get isPolyfilled() {
|
|
324
324
|
return !0;
|
|
325
325
|
}
|
|
326
|
-
constructor(
|
|
327
|
-
if (!
|
|
326
|
+
constructor(e) {
|
|
327
|
+
if (!e || !e.tagName || e.tagName.indexOf("-") === -1)
|
|
328
328
|
throw new TypeError("Illegal constructor");
|
|
329
|
-
const i =
|
|
330
|
-
this.states = new
|
|
329
|
+
const i = e.getRootNode(), a = new ke();
|
|
330
|
+
this.states = new H(e), l.set(this, e), d.set(this, a), c.set(e, this), pe(e, this), be(e, this), Object.seal(this), i instanceof DocumentFragment && fe(i);
|
|
331
331
|
}
|
|
332
332
|
checkValidity() {
|
|
333
|
-
const
|
|
334
|
-
if (w(
|
|
333
|
+
const e = l.get(this);
|
|
334
|
+
if (w(e, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
335
335
|
return !0;
|
|
336
336
|
const i = d.get(this);
|
|
337
337
|
if (!i.valid) {
|
|
@@ -340,90 +340,90 @@ function zt() {
|
|
|
340
340
|
cancelable: !0,
|
|
341
341
|
composed: !1
|
|
342
342
|
});
|
|
343
|
-
|
|
343
|
+
e.dispatchEvent(a);
|
|
344
344
|
}
|
|
345
345
|
return i.valid;
|
|
346
346
|
}
|
|
347
347
|
get form() {
|
|
348
|
-
const
|
|
349
|
-
w(
|
|
348
|
+
const e = l.get(this);
|
|
349
|
+
w(e, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
350
350
|
let i;
|
|
351
|
-
return
|
|
351
|
+
return e.constructor.formAssociated === !0 && (i = L(e)), i;
|
|
352
352
|
}
|
|
353
353
|
get labels() {
|
|
354
|
-
const
|
|
355
|
-
w(
|
|
356
|
-
const i =
|
|
354
|
+
const e = l.get(this);
|
|
355
|
+
w(e, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
356
|
+
const i = e.getAttribute("id"), a = e.getRootNode();
|
|
357
357
|
return a && i ? a.querySelectorAll(`[for="${i}"]`) : [];
|
|
358
358
|
}
|
|
359
359
|
reportValidity() {
|
|
360
|
-
const
|
|
361
|
-
if (w(
|
|
360
|
+
const e = l.get(this);
|
|
361
|
+
if (w(e, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
362
362
|
return !0;
|
|
363
363
|
const i = this.checkValidity(), a = K.get(this);
|
|
364
|
-
if (a && !
|
|
364
|
+
if (a && !e.constructor.formAssociated)
|
|
365
365
|
throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
|
|
366
|
-
return !i && a && (
|
|
366
|
+
return !i && a && (e.focus(), a.focus()), i;
|
|
367
367
|
}
|
|
368
|
-
setFormValue(
|
|
368
|
+
setFormValue(e) {
|
|
369
369
|
const i = l.get(this);
|
|
370
|
-
if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), Z(this),
|
|
370
|
+
if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), Z(this), e != null && !(e instanceof FormData)) {
|
|
371
371
|
if (i.getAttribute("name")) {
|
|
372
|
-
const a =
|
|
373
|
-
a.value =
|
|
372
|
+
const a = ee(i, this);
|
|
373
|
+
a.value = e;
|
|
374
374
|
}
|
|
375
|
-
} else
|
|
375
|
+
} else e != null && e instanceof FormData && Array.from(e).reverse().forEach(([a, r]) => {
|
|
376
376
|
if (typeof r == "string") {
|
|
377
|
-
const o =
|
|
377
|
+
const o = ee(i, this);
|
|
378
378
|
o.name = a, o.value = r;
|
|
379
379
|
}
|
|
380
380
|
});
|
|
381
|
-
|
|
381
|
+
F.set(i, e);
|
|
382
382
|
}
|
|
383
|
-
setValidity(
|
|
383
|
+
setValidity(e, i, a) {
|
|
384
384
|
const r = l.get(this);
|
|
385
|
-
if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !
|
|
385
|
+
if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !e)
|
|
386
386
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
387
387
|
K.set(this, a);
|
|
388
388
|
const o = d.get(this), s = {};
|
|
389
|
-
for (const g in
|
|
390
|
-
s[g] =
|
|
391
|
-
Object.keys(s).length === 0 &&
|
|
389
|
+
for (const g in e)
|
|
390
|
+
s[g] = e[g];
|
|
391
|
+
Object.keys(s).length === 0 && Ee(o);
|
|
392
392
|
const m = Object.assign(Object.assign({}, o), s);
|
|
393
393
|
delete m.valid;
|
|
394
|
-
const { valid: h } =
|
|
394
|
+
const { valid: h } = Me(o, m, this.form);
|
|
395
395
|
if (!h && !i)
|
|
396
396
|
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.");
|
|
397
|
-
k.set(this, h ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !h), r.toggleAttribute("internals-valid", h), r.setAttribute("aria-invalid", `${!h}`)) :
|
|
397
|
+
k.set(this, h ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !h), r.toggleAttribute("internals-valid", h), r.setAttribute("aria-invalid", `${!h}`)) : I.set(r, this);
|
|
398
398
|
}
|
|
399
399
|
get shadowRoot() {
|
|
400
|
-
const
|
|
400
|
+
const e = l.get(this), i = j.get(e);
|
|
401
401
|
return i || null;
|
|
402
402
|
}
|
|
403
403
|
get validationMessage() {
|
|
404
|
-
const
|
|
405
|
-
return w(
|
|
404
|
+
const e = l.get(this);
|
|
405
|
+
return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), k.get(this);
|
|
406
406
|
}
|
|
407
407
|
get validity() {
|
|
408
|
-
const
|
|
409
|
-
return w(
|
|
408
|
+
const e = l.get(this);
|
|
409
|
+
return w(e, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), d.get(this);
|
|
410
410
|
}
|
|
411
411
|
get willValidate() {
|
|
412
|
-
const
|
|
413
|
-
return w(
|
|
412
|
+
const e = l.get(this);
|
|
413
|
+
return w(e, "Failed to read the 'willValidate' property from 'ElementInternals': The target element is not a form-associated custom element."), !(e.disabled || e.hasAttribute("disabled") || e.hasAttribute("readonly"));
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
function
|
|
416
|
+
function Ie() {
|
|
417
417
|
if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
|
|
418
418
|
return !1;
|
|
419
|
-
class
|
|
419
|
+
class t extends HTMLElement {
|
|
420
420
|
constructor() {
|
|
421
421
|
super(), this.internals = this.attachInternals();
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
|
-
const
|
|
425
|
-
customElements.define(
|
|
426
|
-
const i = new
|
|
424
|
+
const e = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`;
|
|
425
|
+
customElements.define(e, t);
|
|
426
|
+
const i = new t();
|
|
427
427
|
return [
|
|
428
428
|
"shadowRoot",
|
|
429
429
|
"form",
|
|
@@ -437,25 +437,25 @@ function zt() {
|
|
|
437
437
|
"reportValidity"
|
|
438
438
|
].every((a) => a in i.internals);
|
|
439
439
|
}
|
|
440
|
-
let
|
|
441
|
-
function
|
|
442
|
-
|
|
443
|
-
const i =
|
|
444
|
-
return i.states = new
|
|
440
|
+
let le = !1, ce = !1;
|
|
441
|
+
function W(t) {
|
|
442
|
+
ce || (ce = !0, window.CustomStateSet = H, t && (HTMLElement.prototype.attachInternals = function(...e) {
|
|
443
|
+
const i = t.call(this, e);
|
|
444
|
+
return i.states = new H(this), i;
|
|
445
445
|
}));
|
|
446
446
|
}
|
|
447
|
-
function
|
|
448
|
-
if (!
|
|
449
|
-
if (
|
|
450
|
-
const
|
|
447
|
+
function de(t = !0) {
|
|
448
|
+
if (!le) {
|
|
449
|
+
if (le = !0, typeof window < "u" && (window.ElementInternals = ne), typeof CustomElementRegistry < "u") {
|
|
450
|
+
const e = CustomElementRegistry.prototype.define;
|
|
451
451
|
CustomElementRegistry.prototype.define = function(i, a, r) {
|
|
452
452
|
if (a.formAssociated) {
|
|
453
453
|
const o = a.prototype.connectedCallback;
|
|
454
454
|
a.prototype.connectedCallback = function() {
|
|
455
|
-
J.has(this) || (J.set(this, !0), this.hasAttribute("disabled") &&
|
|
455
|
+
J.has(this) || (J.set(this, !0), this.hasAttribute("disabled") && D(this, !0)), o != null && o.apply(this), re(this);
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
|
-
|
|
458
|
+
e.call(this, i, a, r);
|
|
459
459
|
};
|
|
460
460
|
}
|
|
461
461
|
if (typeof HTMLElement < "u" && (HTMLElement.prototype.attachInternals = function() {
|
|
@@ -465,28 +465,28 @@ function zt() {
|
|
|
465
465
|
} else return {};
|
|
466
466
|
if (c.has(this))
|
|
467
467
|
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
468
|
-
return new
|
|
468
|
+
return new ne(this);
|
|
469
469
|
}), typeof Element < "u") {
|
|
470
|
-
let
|
|
470
|
+
let e = function(...a) {
|
|
471
471
|
const r = i.apply(this, a);
|
|
472
|
-
if (j.set(this, r),
|
|
472
|
+
if (j.set(this, r), N()) {
|
|
473
473
|
const o = new MutationObserver(O);
|
|
474
|
-
window.ShadyDOM ? o.observe(this,
|
|
474
|
+
window.ShadyDOM ? o.observe(this, $) : o.observe(r, $), C.set(this, o);
|
|
475
475
|
}
|
|
476
476
|
return r;
|
|
477
477
|
};
|
|
478
478
|
const i = Element.prototype.attachShadow;
|
|
479
|
-
Element.prototype.attachShadow =
|
|
479
|
+
Element.prototype.attachShadow = e;
|
|
480
480
|
}
|
|
481
|
-
|
|
481
|
+
N() && typeof document < "u" && new MutationObserver(O).observe(document.documentElement, $), typeof HTMLFormElement < "u" && Fe(), (t || typeof window < "u" && !window.CustomStateSet) && W();
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
return !!customElements.polyfillWrapFlushCallback || (
|
|
484
|
+
return !!customElements.polyfillWrapFlushCallback || (Ie() ? typeof window < "u" && !window.CustomStateSet && W(HTMLElement.prototype.attachInternals) : de(!1)), n.forceCustomStateSetPolyfill = W, n.forceElementInternalsPolyfill = de, Object.defineProperty(n, "__esModule", { value: !0 }), n;
|
|
485
485
|
})({});
|
|
486
|
-
})()),
|
|
486
|
+
})()), he;
|
|
487
487
|
}
|
|
488
|
-
|
|
489
|
-
const
|
|
488
|
+
Be();
|
|
489
|
+
const qe = "*,*:after,*:before{box-sizing:inherit}:host{display:block}*,*:before,*:after{cursor:inherit}.c-switch-wrapper{display:inline-flex;align-items:center;gap:var(--dt-spacing-b);vertical-align:top;font-family:var(--dt-font-body-l-family);cursor:pointer}.c-switch-wrapper[disabled]{cursor:not-allowed}.c-switch{--int-states-mixin-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(--int-states-mixin-bg-color)}@media(hover:hover){.c-switch:hover:not(:disabled,.is-disabled,.is-dismissible){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--int-states-mixin-bg-color: hsl(var(--dt-color-interactive-form-h), var(--dt-color-interactive-form-s), calc(var(--dt-color-interactive-form-l) + var(--hover-modifier)))}}.c-switch:active:not(:disabled,.is-disabled,.is-dismissible),.c-switch.is-loading:not(:disabled,.is-disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--int-states-mixin-bg-color: hsl(var(--dt-color-interactive-form-h), var(--dt-color-interactive-form-s), calc(var(--dt-color-interactive-form-l) + var(--active-modifier)))}@supports (background-color: color-mix(in srgb,black,white)){@media(hover:hover){.c-switch:hover:not(:disabled,.is-disabled,.is-dismissible){--int-states-mixin-bg-color: color-mix(in srgb, var(--dt-color-hover-01-bg) var(--dt-color-hover-01), var(--dt-color-interactive-form))}}.c-switch:active:not(:disabled,.is-disabled,.is-dismissible),.c-switch.is-loading:not(:disabled,.is-disabled){--int-states-mixin-bg-color: color-mix(in srgb, var(--dt-color-active-01-bg) var(--dt-color-active-01), var(--dt-color-interactive-form))}}.c-switch[checked]{--int-states-mixin-bg-color: var(--dt-color-interactive-brand)}@media(hover:hover){.c-switch[checked]:hover:not(:disabled,.is-disabled,.is-dismissible){--hover-modifier: calc(-1 * var(--dt-color-hover-01));--int-states-mixin-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--hover-modifier)))}}.c-switch[checked]:active:not(:disabled,.is-disabled,.is-dismissible),.c-switch[checked].is-loading:not(:disabled,.is-disabled){--active-modifier: calc(-1 * var(--dt-color-active-01));--int-states-mixin-bg-color: hsl(var(--dt-color-interactive-brand-h), var(--dt-color-interactive-brand-s), calc(var(--dt-color-interactive-brand-l) + var(--active-modifier)))}@supports (background-color: color-mix(in srgb,black,white)){@media(hover:hover){.c-switch[checked]:hover:not(:disabled,.is-disabled,.is-dismissible){--int-states-mixin-bg-color: color-mix(in srgb, var(--dt-color-hover-01-bg) var(--dt-color-hover-01), var(--dt-color-interactive-brand))}}.c-switch[checked]:active:not(:disabled,.is-disabled,.is-dismissible),.c-switch[checked].is-loading:not(:disabled,.is-disabled){--int-states-mixin-bg-color: color-mix(in srgb, var(--dt-color-active-01-bg) var(--dt-color-active-01), var(--dt-color-interactive-brand))}}[disabled] .c-switch{--int-states-mixin-bg-color: var(--switch-bg-color--disabled);pointer-events:none}.c-switch:has(.c-switch-input:focus-visible){box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-switch-input{position:absolute;display:block;height:1px;width:1px;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.c-switch-input *{overflow:hidden}.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)}.c-switch-wrapper:dir(rtl) .c-switch-control{position:absolute;left:initial;right:2px}.c-switch-control .c-pieIcon--check{vertical-align:top}.c-switch[checked] .c-switch-control{transform:translate(var(--switch-translation))}.c-switch[checked] .c-switch-control .c-pieIcon--check{color:var(--dt-color-interactive-brand)}.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)}.c-switch-label{color:var(--dt-color-content-default-solid)}.c-switch-description{position:absolute;display:block;height:1px;width:1px;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.c-switch-description *{overflow:hidden}.c-switch-wrapper--label-leading{flex-direction:row-reverse}.c-switch-wrapper--label-trailing{flex-direction:row}@media(prefers-reduced-motion:no-preference){.c-switch-wrapper--allow-animation .c-switch{transition:background-color .15s cubic-bezier(.4,0,.9,1) 0s}}@media(prefers-reduced-motion:no-preference){.c-switch-wrapper--allow-animation .c-switch[checked]{transition:background-color .15s cubic-bezier(.4,0,.9,1) 0s}}@media(prefers-reduced-motion:no-preference){.c-switch-wrapper--allow-animation .c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}@media(prefers-reduced-motion:no-preference){.c-switch[checked] .c-switch-wrapper--allow-animation .c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}@media(prefers-reduced-motion:no-preference){.c-switch[checked] .c-switch-wrapper--allow-animation .c-switch-control .c-pieIcon--check{transition:color .15s cubic-bezier(.4,0,.9,1) 0s}}@media(prefers-reduced-motion:no-preference){.c-switch-input:disabled~.c-switch-wrapper--allow-animation .c-switch-control .c-pieIcon--check{transition:color .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch-wrapper:dir(rtl) .c-switch[checked] .c-switch-control{transform:translate(calc(-1 * var(--switch-translation)))}", Ue = ["leading", "trailing"], rt = "change", x = {
|
|
490
490
|
checked: !1,
|
|
491
491
|
defaultChecked: !1,
|
|
492
492
|
disabled: !1,
|
|
@@ -494,20 +494,22 @@ const Bt = "*,*:after,*:before{box-sizing:inherit}:host{display:block}*,*:before
|
|
|
494
494
|
required: !1,
|
|
495
495
|
value: "on"
|
|
496
496
|
};
|
|
497
|
-
var
|
|
498
|
-
for (var c = u > 1 ? void 0 : u ?
|
|
497
|
+
var je = Object.defineProperty, Ke = Object.getOwnPropertyDescriptor, f = (n, l, d, u) => {
|
|
498
|
+
for (var c = u > 1 ? void 0 : u ? Ke(l, d) : l, k = n.length - 1, E; k >= 0; k--)
|
|
499
499
|
(E = n[k]) && (c = (u ? E(l, d, c) : E(c)) || c);
|
|
500
|
-
return u && c &&
|
|
500
|
+
return u && c && je(l, d, c), c;
|
|
501
501
|
};
|
|
502
|
-
const
|
|
503
|
-
let p = class extends $
|
|
502
|
+
const Ge = "pie-switch";
|
|
503
|
+
let p = class extends $e(De(Re(q))) {
|
|
504
504
|
constructor() {
|
|
505
|
-
super(...arguments), this.labelPlacement =
|
|
505
|
+
super(...arguments), this.labelPlacement = x.labelPlacement, this.checked = x.checked, this.defaultChecked = x.defaultChecked, this.required = x.required, this.value = x.value, this.disabled = x.disabled, this._isAnimationAllowed = !1;
|
|
506
506
|
}
|
|
507
|
-
firstUpdated() {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
507
|
+
firstUpdated(n) {
|
|
508
|
+
super.firstUpdated(n);
|
|
509
|
+
const { signal: l } = this._abortController;
|
|
510
|
+
this.handleFormAssociation(), this.input.addEventListener("invalid", (d) => {
|
|
511
|
+
this.dispatchEvent(new Event("invalid", d));
|
|
512
|
+
}, { signal: l });
|
|
511
513
|
}
|
|
512
514
|
connectedCallback() {
|
|
513
515
|
super.connectedCallback(), this._abortController = new AbortController();
|
|
@@ -540,7 +542,7 @@ let p = class extends $t(Dt(B)) {
|
|
|
540
542
|
handleChange(n) {
|
|
541
543
|
const { checked: l } = n == null ? void 0 : n.currentTarget;
|
|
542
544
|
this.checked = l;
|
|
543
|
-
const d =
|
|
545
|
+
const d = He(n);
|
|
544
546
|
this._isAnimationAllowed || (this._isAnimationAllowed = !0), this.dispatchEvent(d), this.handleFormAssociation();
|
|
545
547
|
}
|
|
546
548
|
/**
|
|
@@ -594,24 +596,24 @@ let p = class extends $t(Dt(B)) {
|
|
|
594
596
|
}
|
|
595
597
|
renderAriaDescription() {
|
|
596
598
|
var n;
|
|
597
|
-
return (n = this.aria) != null && n.describedBy ?
|
|
599
|
+
return (n = this.aria) != null && n.describedBy ? B`
|
|
598
600
|
<div
|
|
599
601
|
aria-hidden="true"
|
|
600
602
|
id="switch-description"
|
|
601
603
|
data-test-id="switch-description"
|
|
602
604
|
class="c-switch-description">
|
|
603
605
|
${this.aria.describedBy}
|
|
604
|
-
</div>` :
|
|
606
|
+
</div>` : P;
|
|
605
607
|
}
|
|
606
608
|
renderSwitchLabel() {
|
|
607
609
|
const { label: n, labelPlacement: l } = this;
|
|
608
|
-
return n ?
|
|
610
|
+
return n ? B`
|
|
609
611
|
<span
|
|
610
612
|
aria-hidden="true"
|
|
611
613
|
data-test-id="switch-label-${l}"
|
|
612
614
|
class="c-switch-label">
|
|
613
615
|
${n}
|
|
614
|
-
</span>` :
|
|
616
|
+
</span>` : P;
|
|
615
617
|
}
|
|
616
618
|
render() {
|
|
617
619
|
const {
|
|
@@ -621,15 +623,16 @@ let p = class extends $t(Dt(B)) {
|
|
|
621
623
|
checked: u,
|
|
622
624
|
disabled: c,
|
|
623
625
|
required: k,
|
|
624
|
-
_isAnimationAllowed: E
|
|
625
|
-
|
|
626
|
+
_isAnimationAllowed: E,
|
|
627
|
+
associatedLabelText: C
|
|
628
|
+
} = this, b = (d == null ? void 0 : d.label) || n || C, F = {
|
|
626
629
|
"c-switch-wrapper": !0,
|
|
627
630
|
"c-switch-wrapper--allow-animation": E,
|
|
628
631
|
[`c-switch-wrapper--label-${l}`]: !0
|
|
629
|
-
},
|
|
630
|
-
return
|
|
631
|
-
<${
|
|
632
|
-
class="${
|
|
632
|
+
}, M = Te(n ? "label" : "div");
|
|
633
|
+
return Le`
|
|
634
|
+
<${M}
|
|
635
|
+
class="${Pe(F)}"
|
|
633
636
|
?disabled=${c}>
|
|
634
637
|
<div
|
|
635
638
|
data-test-id="switch-component"
|
|
@@ -640,28 +643,28 @@ let p = class extends $t(Dt(B)) {
|
|
|
640
643
|
role="switch"
|
|
641
644
|
type="checkbox"
|
|
642
645
|
class="c-switch-input"
|
|
643
|
-
|
|
644
|
-
.checked="${
|
|
645
|
-
|
|
646
|
+
?required=${k}
|
|
647
|
+
.checked="${Oe(u)}"
|
|
648
|
+
?disabled="${c}"
|
|
646
649
|
@change="${this.handleChange}"
|
|
647
|
-
aria-label="${
|
|
648
|
-
aria-describedby="${d != null && d.describedBy ? "switch-description" :
|
|
650
|
+
aria-label="${_e(b)}"
|
|
651
|
+
aria-describedby="${d != null && d.describedBy ? "switch-description" : P}">
|
|
649
652
|
<div class="c-switch-control">
|
|
650
|
-
${u ?
|
|
653
|
+
${u ? B`<icon-check></icon-check>` : P}
|
|
651
654
|
</div>
|
|
652
655
|
</div>
|
|
653
656
|
${this.renderSwitchLabel()}
|
|
654
657
|
${this.renderAriaDescription()}
|
|
655
|
-
</${
|
|
658
|
+
</${M}>`;
|
|
656
659
|
}
|
|
657
660
|
};
|
|
658
|
-
p.styles =
|
|
661
|
+
p.styles = Ve(qe);
|
|
659
662
|
f([
|
|
660
663
|
y({ type: String })
|
|
661
664
|
], p.prototype, "label", 2);
|
|
662
665
|
f([
|
|
663
666
|
y({ type: String }),
|
|
664
|
-
|
|
667
|
+
We(Ge, Ue, x.labelPlacement)
|
|
665
668
|
], p.prototype, "labelPlacement", 2);
|
|
666
669
|
f([
|
|
667
670
|
y({ type: Object })
|
|
@@ -685,23 +688,23 @@ f([
|
|
|
685
688
|
y({ type: Boolean, reflect: !0 })
|
|
686
689
|
], p.prototype, "disabled", 2);
|
|
687
690
|
f([
|
|
688
|
-
|
|
691
|
+
U('input[type="checkbox"]')
|
|
689
692
|
], p.prototype, "input", 2);
|
|
690
693
|
f([
|
|
691
|
-
|
|
694
|
+
U(".c-switch")
|
|
692
695
|
], p.prototype, "switchBody", 2);
|
|
693
696
|
f([
|
|
694
|
-
|
|
697
|
+
U('label, input[type="checkbox"]')
|
|
695
698
|
], p.prototype, "focusTarget", 2);
|
|
696
699
|
f([
|
|
697
|
-
|
|
700
|
+
Ne()
|
|
698
701
|
], p.prototype, "_isAnimationAllowed", 2);
|
|
699
702
|
p = f([
|
|
700
|
-
|
|
703
|
+
ze("pie-switch")
|
|
701
704
|
], p);
|
|
702
705
|
export {
|
|
703
|
-
|
|
706
|
+
rt as ON_SWITCH_CHANGED_EVENT,
|
|
704
707
|
p as PieSwitch,
|
|
705
|
-
|
|
706
|
-
|
|
708
|
+
x as defaultProps,
|
|
709
|
+
Ue as labelPlacements
|
|
707
710
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { AssociatedLabelInterface } from '@justeattakeaway/pie-webc-core';
|
|
1
2
|
import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
|
|
2
3
|
import { CSSResult } from 'lit';
|
|
3
4
|
import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
|
|
4
5
|
import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
5
6
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
6
7
|
import { PIEInputElement } from '@justeattakeaway/pie-webc-core';
|
|
8
|
+
import { PropertyValues } from 'lit';
|
|
7
9
|
import * as React_2 from 'react';
|
|
8
10
|
import { TemplateResult } from 'lit-html';
|
|
9
11
|
|
|
@@ -46,7 +48,7 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInpu
|
|
|
46
48
|
focusTarget: HTMLElement;
|
|
47
49
|
private _abortController;
|
|
48
50
|
private _isAnimationAllowed;
|
|
49
|
-
protected firstUpdated(): void;
|
|
51
|
+
protected firstUpdated(changedProperties: PropertyValues): void;
|
|
50
52
|
connectedCallback(): void;
|
|
51
53
|
disconnectedCallback(): void;
|
|
52
54
|
protected updated(): void;
|
|
@@ -98,7 +100,7 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInpu
|
|
|
98
100
|
render(): TemplateResult;
|
|
99
101
|
}
|
|
100
102
|
|
|
101
|
-
declare const PieSwitch_base: GenericConstructor<FormControlInterface> & typeof PieElement;
|
|
103
|
+
declare const PieSwitch_base: GenericConstructor<AssociatedLabelInterface> & GenericConstructor<FormControlInterface> & typeof PieElement;
|
|
102
104
|
|
|
103
105
|
declare type PieSwitchEvents = {
|
|
104
106
|
onInvalid?: (event: Event) => void;
|
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": "2.5.
|
|
4
|
+
"version": "2.5.2",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@justeattakeaway/pie-wrapper-react": "0.14.5"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@justeattakeaway/pie-icons-webc": "1.25.
|
|
53
|
-
"@justeattakeaway/pie-webc-core": "15.0
|
|
52
|
+
"@justeattakeaway/pie-icons-webc": "1.25.3",
|
|
53
|
+
"@justeattakeaway/pie-webc-core": "15.1.0",
|
|
54
54
|
"element-internals-polyfill": "1.3.11"
|
|
55
55
|
},
|
|
56
56
|
"customElements": "custom-elements.json",
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
html, unsafeCSS, nothing,
|
|
2
|
+
html, unsafeCSS, nothing, type PropertyValues,
|
|
3
3
|
} from 'lit';
|
|
4
4
|
import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
|
|
5
5
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
validPropertyValues,
|
|
14
14
|
FormControlMixin,
|
|
15
15
|
DelegatesFocusMixin,
|
|
16
|
+
AssociatedLabelMixin,
|
|
16
17
|
wrapNativeEvent,
|
|
17
18
|
safeCustomElement,
|
|
18
19
|
type PIEInputElement,
|
|
@@ -32,7 +33,7 @@ const componentSelector = 'pie-switch';
|
|
|
32
33
|
* @event {CustomEvent} change - when the switch checked state is changed.
|
|
33
34
|
*/
|
|
34
35
|
@safeCustomElement('pie-switch')
|
|
35
|
-
export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement)) implements SwitchProps, PIEInputElement {
|
|
36
|
+
export class PieSwitch extends AssociatedLabelMixin(FormControlMixin(DelegatesFocusMixin(PieElement))) implements SwitchProps, PIEInputElement {
|
|
36
37
|
@property({ type: String })
|
|
37
38
|
public label: SwitchProps['label'];
|
|
38
39
|
|
|
@@ -75,13 +76,15 @@ export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement))
|
|
|
75
76
|
@state()
|
|
76
77
|
private _isAnimationAllowed = false;
|
|
77
78
|
|
|
78
|
-
protected firstUpdated (): void {
|
|
79
|
+
protected firstUpdated (changedProperties: PropertyValues): void {
|
|
80
|
+
super.firstUpdated(changedProperties);
|
|
81
|
+
const { signal } = this._abortController;
|
|
79
82
|
this.handleFormAssociation();
|
|
80
83
|
// This ensures that invalid events triggered by checkValidity() are propagated to the custom element
|
|
81
84
|
// for consumers to listen to: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
82
85
|
this.input.addEventListener('invalid', (event) => {
|
|
83
86
|
this.dispatchEvent(new Event('invalid', event));
|
|
84
|
-
});
|
|
87
|
+
}, { signal });
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
connectedCallback (): void {
|
|
@@ -260,8 +263,11 @@ export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement))
|
|
|
260
263
|
disabled,
|
|
261
264
|
required,
|
|
262
265
|
_isAnimationAllowed,
|
|
266
|
+
associatedLabelText,
|
|
263
267
|
} = this;
|
|
264
268
|
|
|
269
|
+
const ariaLabel = aria?.label || label || associatedLabelText;
|
|
270
|
+
|
|
265
271
|
const classes = {
|
|
266
272
|
'c-switch-wrapper': true,
|
|
267
273
|
'c-switch-wrapper--allow-animation': _isAnimationAllowed,
|
|
@@ -283,11 +289,11 @@ export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement))
|
|
|
283
289
|
role="switch"
|
|
284
290
|
type="checkbox"
|
|
285
291
|
class="c-switch-input"
|
|
286
|
-
|
|
292
|
+
?required=${required}
|
|
287
293
|
.checked="${live(checked)}"
|
|
288
|
-
|
|
294
|
+
?disabled="${disabled}"
|
|
289
295
|
@change="${this.handleChange}"
|
|
290
|
-
aria-label="${ifDefined(
|
|
296
|
+
aria-label="${ifDefined(ariaLabel)}"
|
|
291
297
|
aria-describedby="${aria?.describedBy ? 'switch-description' : nothing}">
|
|
292
298
|
<div class="c-switch-control">
|
|
293
299
|
${checked ? html`<icon-check></icon-check>` : nothing}
|
package/src/switch.scss
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
vertical-align: top;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
.c-switch
|
|
98
|
+
.c-switch[checked] & {
|
|
99
99
|
transform: translateX(var(--switch-translation));
|
|
100
100
|
|
|
101
101
|
.c-pieIcon--check {
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
.c-switch-control {
|
|
144
144
|
@include switch-transition(transform);
|
|
145
145
|
|
|
146
|
-
.c-switch
|
|
146
|
+
.c-switch[checked] & {
|
|
147
147
|
@include switch-transition(transform);
|
|
148
148
|
|
|
149
149
|
.c-pieIcon--check {
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
.c-switch-wrapper:dir(rtl) {
|
|
163
|
-
.c-switch
|
|
163
|
+
.c-switch[checked] .c-switch-control {
|
|
164
164
|
transform: translateX(calc(-1 * var(--switch-translation)));
|
|
165
165
|
}
|
|
166
166
|
}
|