@justeattakeaway/pie-switch 1.0.1 → 1.0.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/dist/index.js +90 -90
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { FormControlMixin as Te, RtlMixin as Le, wrapNativeEvent as Ne, validPro
|
|
|
6
6
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
7
7
|
(function() {
|
|
8
8
|
(function(E) {
|
|
9
|
-
const
|
|
9
|
+
const o = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), q = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), F = {
|
|
10
10
|
ariaAtomic: "aria-atomic",
|
|
11
11
|
ariaAutoComplete: "aria-autocomplete",
|
|
12
12
|
ariaBusy: "aria-busy",
|
|
@@ -58,8 +58,8 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
58
58
|
get() {
|
|
59
59
|
return a;
|
|
60
60
|
},
|
|
61
|
-
set(
|
|
62
|
-
a =
|
|
61
|
+
set(n) {
|
|
62
|
+
a = n, t.isConnected ? t.setAttribute(r, n) : A.set(t, e);
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -70,8 +70,8 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
70
70
|
}
|
|
71
71
|
const Y = (t, e = !1) => {
|
|
72
72
|
const i = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
|
|
73
|
-
acceptNode(
|
|
74
|
-
return l.has(
|
|
73
|
+
acceptNode(n) {
|
|
74
|
+
return l.has(n) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
let a = i.nextNode();
|
|
@@ -89,21 +89,21 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
89
89
|
}) : {};
|
|
90
90
|
function P(t) {
|
|
91
91
|
t.forEach((e) => {
|
|
92
|
-
const { addedNodes: i, removedNodes: a } = e, r = Array.from(i),
|
|
93
|
-
r.forEach((
|
|
92
|
+
const { addedNodes: i, removedNodes: a } = e, r = Array.from(i), n = Array.from(a);
|
|
93
|
+
r.forEach((s) => {
|
|
94
94
|
var h;
|
|
95
|
-
if (l.has(
|
|
96
|
-
const c = A.get(
|
|
95
|
+
if (l.has(s) && s.constructor.formAssociated && G(s), A.has(s)) {
|
|
96
|
+
const c = A.get(s);
|
|
97
97
|
Object.keys(F).filter((f) => c[f] !== null).forEach((f) => {
|
|
98
|
-
|
|
99
|
-
}), A.delete(
|
|
98
|
+
s.setAttribute(F[f], c[f]);
|
|
99
|
+
}), A.delete(s);
|
|
100
100
|
}
|
|
101
|
-
if (x.has(
|
|
102
|
-
const c = x.get(
|
|
103
|
-
|
|
101
|
+
if (x.has(s)) {
|
|
102
|
+
const c = x.get(s);
|
|
103
|
+
s.setAttribute("internals-valid", c.validity.valid.toString()), s.setAttribute("internals-invalid", (!c.validity.valid).toString()), s.setAttribute("aria-invalid", (!c.validity.valid).toString()), x.delete(s);
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
106
|
-
const c =
|
|
105
|
+
if (s.localName === "form") {
|
|
106
|
+
const c = v.get(s), b = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
|
|
107
107
|
acceptNode(W) {
|
|
108
108
|
return l.has(W) && W.constructor.formAssociated && !(c && c.has(W)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
109
109
|
}
|
|
@@ -112,10 +112,10 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
112
112
|
for (; f; )
|
|
113
113
|
G(f), f = b.nextNode();
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
}),
|
|
117
|
-
const h = l.get(
|
|
118
|
-
h && u.get(h) && Q(h), O.has(
|
|
115
|
+
s.localName === "fieldset" && ((h = I.observe) === null || h === void 0 || h.call(I, s, J), Y(s, !0));
|
|
116
|
+
}), n.forEach((s) => {
|
|
117
|
+
const h = l.get(s);
|
|
118
|
+
h && u.get(h) && Q(h), O.has(s) && O.get(s).disconnect();
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -156,7 +156,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
156
156
|
e[0].id || (i = `${e[0].htmlFor}_Label`, e[0].id = i), t.setAttribute("aria-labelledby", i);
|
|
157
157
|
}
|
|
158
158
|
}, V = (t) => {
|
|
159
|
-
const e = Array.from(t.elements).filter((
|
|
159
|
+
const e = Array.from(t.elements).filter((n) => !n.tagName.includes("-") && n.validity).map((n) => n.validity.valid), i = v.get(t) || [], a = Array.from(i).filter((n) => n.isConnected).map((n) => l.get(n).validity.valid), r = [...e, ...a].includes(!1);
|
|
160
160
|
t.toggleAttribute("internals-invalid", r), t.toggleAttribute("internals-valid", !r);
|
|
161
161
|
}, me = (t) => {
|
|
162
162
|
V(S(t.target));
|
|
@@ -166,25 +166,25 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
166
166
|
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(",");
|
|
167
167
|
t.addEventListener("click", (i) => {
|
|
168
168
|
if (i.target.closest(e)) {
|
|
169
|
-
const r =
|
|
169
|
+
const r = v.get(t);
|
|
170
170
|
if (t.noValidate)
|
|
171
171
|
return;
|
|
172
172
|
r.size && Array.from(r).reverse().map((h) => l.get(h).reportValidity()).includes(!1) && i.preventDefault();
|
|
173
173
|
}
|
|
174
174
|
});
|
|
175
|
-
},
|
|
176
|
-
const e =
|
|
175
|
+
}, ge = (t) => {
|
|
176
|
+
const e = v.get(t.target);
|
|
177
177
|
e && e.size && e.forEach((i) => {
|
|
178
178
|
i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
|
|
179
179
|
});
|
|
180
180
|
}, ee = (t, e, i) => {
|
|
181
181
|
if (e) {
|
|
182
|
-
const a =
|
|
182
|
+
const a = v.get(e);
|
|
183
183
|
if (a)
|
|
184
184
|
a.add(t);
|
|
185
185
|
else {
|
|
186
186
|
const r = /* @__PURE__ */ new Set();
|
|
187
|
-
r.add(t),
|
|
187
|
+
r.add(t), v.set(e, r), be(e), e.addEventListener("reset", ge), e.addEventListener("input", me), e.addEventListener("change", we);
|
|
188
188
|
}
|
|
189
189
|
M.set(e, { ref: t, internals: i }), t.constructor.formAssociated && t.formAssociatedCallback && setTimeout(() => {
|
|
190
190
|
t.formAssociatedCallback.apply(t, [e]);
|
|
@@ -197,7 +197,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
197
197
|
if (!t.constructor.formAssociated)
|
|
198
198
|
throw new i(e);
|
|
199
199
|
}, te = (t, e, i) => {
|
|
200
|
-
const a =
|
|
200
|
+
const a = v.get(t);
|
|
201
201
|
return a && a.size && a.forEach((r) => {
|
|
202
202
|
l.get(r)[i]() || (e = !1);
|
|
203
203
|
}), e;
|
|
@@ -210,7 +210,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
210
210
|
function T() {
|
|
211
211
|
return typeof MutationObserver < "u";
|
|
212
212
|
}
|
|
213
|
-
class
|
|
213
|
+
class ve {
|
|
214
214
|
constructor() {
|
|
215
215
|
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);
|
|
216
216
|
}
|
|
@@ -259,7 +259,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
259
259
|
return i === "m" ? a : i === "a" ? a.call(t) : a ? a.value : e.get(t);
|
|
260
260
|
}
|
|
261
261
|
function Me(t, e, i, a, r) {
|
|
262
|
-
if (typeof e == "function" ? t !== e || !
|
|
262
|
+
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");
|
|
263
263
|
return e.set(t, i), i;
|
|
264
264
|
}
|
|
265
265
|
var C;
|
|
@@ -290,37 +290,37 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
290
290
|
HTMLFormElement.prototype.checkValidity = i;
|
|
291
291
|
const e = HTMLFormElement.prototype.reportValidity;
|
|
292
292
|
HTMLFormElement.prototype.reportValidity = a;
|
|
293
|
-
function i(...
|
|
294
|
-
let
|
|
295
|
-
return te(this,
|
|
293
|
+
function i(...n) {
|
|
294
|
+
let s = t.apply(this, n);
|
|
295
|
+
return te(this, s, "checkValidity");
|
|
296
296
|
}
|
|
297
|
-
function a(...
|
|
298
|
-
let
|
|
299
|
-
return te(this,
|
|
297
|
+
function a(...n) {
|
|
298
|
+
let s = e.apply(this, n);
|
|
299
|
+
return te(this, s, "reportValidity");
|
|
300
300
|
}
|
|
301
301
|
const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
302
302
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
303
|
-
get(...
|
|
304
|
-
const
|
|
303
|
+
get(...n) {
|
|
304
|
+
const s = r.call(this, ...n), h = Array.from(v.get(this) || []);
|
|
305
305
|
if (h.length === 0)
|
|
306
|
-
return
|
|
307
|
-
const c = Array.from(
|
|
306
|
+
return s;
|
|
307
|
+
const c = Array.from(s).concat(h).sort((b, f) => b.compareDocumentPosition ? b.compareDocumentPosition(f) & 2 ? 1 : -1 : 0);
|
|
308
308
|
return new Ce(c);
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
311
|
}
|
|
312
|
-
class
|
|
312
|
+
class ne {
|
|
313
313
|
static get isPolyfilled() {
|
|
314
314
|
return !0;
|
|
315
315
|
}
|
|
316
316
|
constructor(e) {
|
|
317
317
|
if (!e || !e.tagName || e.tagName.indexOf("-") === -1)
|
|
318
318
|
throw new TypeError("Illegal constructor");
|
|
319
|
-
const i = e.getRootNode(), a = new
|
|
320
|
-
this.states = new D(e),
|
|
319
|
+
const i = e.getRootNode(), a = new ve();
|
|
320
|
+
this.states = new D(e), o.set(this, e), d.set(this, a), l.set(e, this), he(e, this), fe(e, this), Object.seal(this), i instanceof DocumentFragment && pe(i);
|
|
321
321
|
}
|
|
322
322
|
checkValidity() {
|
|
323
|
-
const e =
|
|
323
|
+
const e = o.get(this);
|
|
324
324
|
if (w(e, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
325
325
|
return !0;
|
|
326
326
|
const i = d.get(this);
|
|
@@ -335,19 +335,19 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
335
335
|
return i.valid;
|
|
336
336
|
}
|
|
337
337
|
get form() {
|
|
338
|
-
const e =
|
|
338
|
+
const e = o.get(this);
|
|
339
339
|
w(e, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
340
340
|
let i;
|
|
341
341
|
return e.constructor.formAssociated === !0 && (i = S(e)), i;
|
|
342
342
|
}
|
|
343
343
|
get labels() {
|
|
344
|
-
const e =
|
|
344
|
+
const e = o.get(this);
|
|
345
345
|
w(e, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
346
346
|
const i = e.getAttribute("id"), a = e.getRootNode();
|
|
347
347
|
return a && i ? a.querySelectorAll(`[for="${i}"]`) : [];
|
|
348
348
|
}
|
|
349
349
|
reportValidity() {
|
|
350
|
-
const e =
|
|
350
|
+
const e = o.get(this);
|
|
351
351
|
if (w(e, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
352
352
|
return !0;
|
|
353
353
|
const i = this.checkValidity(), a = U.get(this);
|
|
@@ -356,7 +356,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
356
356
|
return !i && a && (e.focus(), a.focus()), i;
|
|
357
357
|
}
|
|
358
358
|
setFormValue(e) {
|
|
359
|
-
const i =
|
|
359
|
+
const i = o.get(this);
|
|
360
360
|
if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), Q(this), e != null && !(e instanceof FormData)) {
|
|
361
361
|
if (i.getAttribute("name")) {
|
|
362
362
|
const a = X(i, this);
|
|
@@ -364,42 +364,42 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
364
364
|
}
|
|
365
365
|
} else e != null && e instanceof FormData && Array.from(e).reverse().forEach(([a, r]) => {
|
|
366
366
|
if (typeof r == "string") {
|
|
367
|
-
const
|
|
368
|
-
|
|
367
|
+
const n = X(i, this);
|
|
368
|
+
n.name = a, n.value = r;
|
|
369
369
|
}
|
|
370
370
|
});
|
|
371
371
|
q.set(i, e);
|
|
372
372
|
}
|
|
373
373
|
setValidity(e, i, a) {
|
|
374
|
-
const r =
|
|
374
|
+
const r = o.get(this);
|
|
375
375
|
if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !e)
|
|
376
376
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
377
377
|
U.set(this, a);
|
|
378
|
-
const
|
|
378
|
+
const n = d.get(this), s = {};
|
|
379
379
|
for (const b in e)
|
|
380
|
-
|
|
381
|
-
Object.keys(
|
|
382
|
-
const h = Object.assign(Object.assign({},
|
|
380
|
+
s[b] = e[b];
|
|
381
|
+
Object.keys(s).length === 0 && ye(n);
|
|
382
|
+
const h = Object.assign(Object.assign({}, n), s);
|
|
383
383
|
delete h.valid;
|
|
384
|
-
const { valid: c } = Ee(
|
|
384
|
+
const { valid: c } = Ee(n, h, this.form);
|
|
385
385
|
if (!c && !i)
|
|
386
386
|
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.");
|
|
387
|
-
|
|
387
|
+
g.set(this, c ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !c), r.toggleAttribute("internals-valid", c), r.setAttribute("aria-invalid", `${!c}`)) : x.set(r, this);
|
|
388
388
|
}
|
|
389
389
|
get shadowRoot() {
|
|
390
|
-
const e =
|
|
390
|
+
const e = o.get(this), i = B.get(e);
|
|
391
391
|
return i || null;
|
|
392
392
|
}
|
|
393
393
|
get validationMessage() {
|
|
394
|
-
const e =
|
|
395
|
-
return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."),
|
|
394
|
+
const e = o.get(this);
|
|
395
|
+
return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), g.get(this);
|
|
396
396
|
}
|
|
397
397
|
get validity() {
|
|
398
|
-
const e =
|
|
398
|
+
const e = o.get(this);
|
|
399
399
|
return w(e, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), d.get(this);
|
|
400
400
|
}
|
|
401
401
|
get willValidate() {
|
|
402
|
-
const e =
|
|
402
|
+
const e = o.get(this);
|
|
403
403
|
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"));
|
|
404
404
|
}
|
|
405
405
|
}
|
|
@@ -427,22 +427,22 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
427
427
|
"reportValidity"
|
|
428
428
|
].every((a) => a in i.internals);
|
|
429
429
|
}
|
|
430
|
-
let
|
|
430
|
+
let oe = !1, se = !1;
|
|
431
431
|
function H(t) {
|
|
432
|
-
|
|
432
|
+
se || (se = !0, window.CustomStateSet = D, t && (HTMLElement.prototype.attachInternals = function(...e) {
|
|
433
433
|
const i = t.call(this, e);
|
|
434
434
|
return i.states = new D(this), i;
|
|
435
435
|
}));
|
|
436
436
|
}
|
|
437
437
|
function le(t = !0) {
|
|
438
|
-
if (!
|
|
439
|
-
if (
|
|
438
|
+
if (!oe) {
|
|
439
|
+
if (oe = !0, typeof window < "u" && (window.ElementInternals = ne), typeof CustomElementRegistry < "u") {
|
|
440
440
|
const e = CustomElementRegistry.prototype.define;
|
|
441
441
|
CustomElementRegistry.prototype.define = function(i, a, r) {
|
|
442
442
|
if (a.formAssociated) {
|
|
443
|
-
const
|
|
443
|
+
const n = a.prototype.connectedCallback;
|
|
444
444
|
a.prototype.connectedCallback = function() {
|
|
445
|
-
K.has(this) || (K.set(this, !0), this.hasAttribute("disabled") && $(this, !0)),
|
|
445
|
+
K.has(this) || (K.set(this, !0), this.hasAttribute("disabled") && $(this, !0)), n != null && n.apply(this), ie(this);
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
e.call(this, i, a, r);
|
|
@@ -455,13 +455,13 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
455
455
|
} else return {};
|
|
456
456
|
if (l.has(this))
|
|
457
457
|
throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
|
|
458
|
-
return new
|
|
458
|
+
return new ne(this);
|
|
459
459
|
}), typeof Element < "u") {
|
|
460
460
|
let e = function(...a) {
|
|
461
461
|
const r = i.apply(this, a);
|
|
462
462
|
if (B.set(this, r), T()) {
|
|
463
|
-
const
|
|
464
|
-
window.ShadyDOM ?
|
|
463
|
+
const n = new MutationObserver(P);
|
|
464
|
+
window.ShadyDOM ? n.observe(this, _) : n.observe(r, _), O.set(this, n);
|
|
465
465
|
}
|
|
466
466
|
return r;
|
|
467
467
|
};
|
|
@@ -481,18 +481,18 @@ const _e = "*,*:after,*:before{box-sizing:inherit}*,*:before,*:after{cursor:inhe
|
|
|
481
481
|
required: !1,
|
|
482
482
|
value: "on"
|
|
483
483
|
};
|
|
484
|
-
var Re = Object.defineProperty, m = (E,
|
|
485
|
-
for (var l = void 0,
|
|
486
|
-
(M = E[
|
|
487
|
-
return l && Re(
|
|
484
|
+
var Re = Object.defineProperty, m = (E, o, d, u) => {
|
|
485
|
+
for (var l = void 0, g = E.length - 1, M; g >= 0; g--)
|
|
486
|
+
(M = E[g]) && (l = M(o, d, l) || l);
|
|
487
|
+
return l && Re(o, d, l), l;
|
|
488
488
|
};
|
|
489
489
|
const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
490
490
|
constructor() {
|
|
491
491
|
super(...arguments), this.labelPlacement = k.labelPlacement, this.checked = k.checked, this.required = k.required, this.value = k.value, this.disabled = k.disabled;
|
|
492
492
|
}
|
|
493
493
|
firstUpdated() {
|
|
494
|
-
this.handleFormAssociation(), this.input.addEventListener("invalid", (
|
|
495
|
-
this.dispatchEvent(new Event("invalid",
|
|
494
|
+
this.handleFormAssociation(), this.input.addEventListener("invalid", (o) => {
|
|
495
|
+
this.dispatchEvent(new Event("invalid", o));
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
498
|
updated() {
|
|
@@ -508,10 +508,10 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
508
508
|
* The handleChange function updates the checkbox state and emits an event for consumers.
|
|
509
509
|
* @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
|
|
510
510
|
*/
|
|
511
|
-
handleChange(
|
|
512
|
-
const { checked: d } =
|
|
511
|
+
handleChange(o) {
|
|
512
|
+
const { checked: d } = o == null ? void 0 : o.currentTarget;
|
|
513
513
|
this.checked = d;
|
|
514
|
-
const u = Ne(
|
|
514
|
+
const u = Ne(o);
|
|
515
515
|
this.dispatchEvent(u), this.handleFormAssociation();
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
@@ -534,8 +534,8 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
534
534
|
* Allows a consumer to set a custom validation message on the switch. An empty string counts as valid.
|
|
535
535
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
536
536
|
*/
|
|
537
|
-
setCustomValidity(
|
|
538
|
-
this.input.setCustomValidity(
|
|
537
|
+
setCustomValidity(o) {
|
|
538
|
+
this.input.setCustomValidity(o), this._internals.setValidity(this.validity, this.validationMessage, this.input);
|
|
539
539
|
}
|
|
540
540
|
/**
|
|
541
541
|
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
@@ -558,16 +558,16 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
558
558
|
*
|
|
559
559
|
* @private
|
|
560
560
|
*/
|
|
561
|
-
renderSwitchLabel(
|
|
561
|
+
renderSwitchLabel(o) {
|
|
562
562
|
const { label: d, labelPlacement: u } = this;
|
|
563
|
-
return !d || u !==
|
|
563
|
+
return !d || u !== o ? L : N`
|
|
564
564
|
<span data-test-id="switch-label-${u}">
|
|
565
565
|
${d}
|
|
566
566
|
</span>`;
|
|
567
567
|
}
|
|
568
568
|
renderAriaDescription() {
|
|
569
|
-
var
|
|
570
|
-
return (
|
|
569
|
+
var o;
|
|
570
|
+
return (o = this.aria) != null && o.describedBy ? N`
|
|
571
571
|
<div
|
|
572
572
|
id="switch-description"
|
|
573
573
|
data-test-id="switch-description"
|
|
@@ -577,11 +577,11 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
577
577
|
}
|
|
578
578
|
render() {
|
|
579
579
|
const {
|
|
580
|
-
aria:
|
|
580
|
+
aria: o,
|
|
581
581
|
checked: d,
|
|
582
582
|
disabled: u,
|
|
583
583
|
isRTL: l,
|
|
584
|
-
required:
|
|
584
|
+
required: g
|
|
585
585
|
} = this;
|
|
586
586
|
return N`
|
|
587
587
|
<label
|
|
@@ -600,12 +600,12 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
600
600
|
role="switch"
|
|
601
601
|
type="checkbox"
|
|
602
602
|
class="c-switch-input"
|
|
603
|
-
.required=${
|
|
603
|
+
.required=${g}
|
|
604
604
|
.checked="${d}"
|
|
605
605
|
.disabled="${u}"
|
|
606
606
|
@change="${this.handleChange}"
|
|
607
|
-
aria-label="${Se(
|
|
608
|
-
aria-describedby="${
|
|
607
|
+
aria-label="${Se(o == null ? void 0 : o.label)}"
|
|
608
|
+
aria-describedby="${o != null && o.describedBy ? "switch-description" : L}">
|
|
609
609
|
<div class="c-switch-control">
|
|
610
610
|
${d ? N`<icon-check></icon-check>` : L}
|
|
611
611
|
</div>
|
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": "1.0.
|
|
4
|
+
"version": "1.0.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
39
39
|
"@justeattakeaway/pie-components-config": "0.18.0",
|
|
40
|
-
"@justeattakeaway/pie-css": "0.
|
|
40
|
+
"@justeattakeaway/pie-css": "0.14.1",
|
|
41
41
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@justeattakeaway/pie-icons-webc": "1.
|
|
44
|
+
"@justeattakeaway/pie-icons-webc": "1.3.0",
|
|
45
45
|
"@justeattakeaway/pie-webc-core": "0.24.2",
|
|
46
46
|
"@justeattakeaway/pie-wrapper-react": "0.14.2",
|
|
47
47
|
"element-internals-polyfill": "1.3.11"
|