@justeattakeaway/pie-switch 0.30.4 → 0.30.6
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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +72 -74
- package/dist/react.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.ts +7 -7
package/custom-elements.json
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
|
|
|
38
38
|
value: string;
|
|
39
39
|
name: SwitchProps['name'];
|
|
40
40
|
disabled: boolean;
|
|
41
|
-
private input
|
|
41
|
+
private input;
|
|
42
42
|
focusTarget: HTMLElement;
|
|
43
43
|
protected firstUpdated(): void;
|
|
44
44
|
protected updated(): void;
|
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 s = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), v = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), g = /* @__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(o) {
|
|
62
|
+
a = o, t.isConnected ? t.setAttribute(r, o) : 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(o) {
|
|
74
|
+
return l.has(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
75
75
|
}
|
|
76
76
|
});
|
|
77
77
|
let a = i.nextNode();
|
|
@@ -89,23 +89,23 @@ 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),
|
|
92
|
+
const { addedNodes: i, removedNodes: a } = e, r = Array.from(i), o = Array.from(a);
|
|
93
93
|
r.forEach((n) => {
|
|
94
94
|
var h;
|
|
95
95
|
if (l.has(n) && n.constructor.formAssociated && G(n), A.has(n)) {
|
|
96
|
-
const
|
|
97
|
-
Object.keys(F).filter((f) =>
|
|
98
|
-
n.setAttribute(F[f],
|
|
96
|
+
const c = A.get(n);
|
|
97
|
+
Object.keys(F).filter((f) => c[f] !== null).forEach((f) => {
|
|
98
|
+
n.setAttribute(F[f], c[f]);
|
|
99
99
|
}), A.delete(n);
|
|
100
100
|
}
|
|
101
101
|
if (x.has(n)) {
|
|
102
|
-
const
|
|
103
|
-
n.setAttribute("internals-valid",
|
|
102
|
+
const c = x.get(n);
|
|
103
|
+
n.setAttribute("internals-valid", c.validity.valid.toString()), n.setAttribute("internals-invalid", (!c.validity.valid).toString()), n.setAttribute("aria-invalid", (!c.validity.valid).toString()), x.delete(n);
|
|
104
104
|
}
|
|
105
105
|
if (n.localName === "form") {
|
|
106
|
-
const
|
|
106
|
+
const c = g.get(n), b = document.createTreeWalker(n, NodeFilter.SHOW_ELEMENT, {
|
|
107
107
|
acceptNode(W) {
|
|
108
|
-
return l.has(W) && W.constructor.formAssociated && !(
|
|
108
|
+
return l.has(W) && W.constructor.formAssociated && !(c && c.has(W)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
let f = b.nextNode();
|
|
@@ -113,7 +113,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
113
113
|
G(f), f = b.nextNode();
|
|
114
114
|
}
|
|
115
115
|
n.localName === "fieldset" && ((h = I.observe) === null || h === void 0 || h.call(I, n, J), Y(n, !0));
|
|
116
|
-
}),
|
|
116
|
+
}), o.forEach((n) => {
|
|
117
117
|
const h = l.get(n);
|
|
118
118
|
h && u.get(h) && Q(h), O.has(n) && O.get(n).disconnect();
|
|
119
119
|
});
|
|
@@ -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((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = g.get(t) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => l.get(o).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));
|
|
@@ -290,22 +290,22 @@ 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 n = t.apply(this,
|
|
293
|
+
function i(...o) {
|
|
294
|
+
let n = t.apply(this, o);
|
|
295
295
|
return te(this, n, "checkValidity");
|
|
296
296
|
}
|
|
297
|
-
function a(...
|
|
298
|
-
let n = e.apply(this,
|
|
297
|
+
function a(...o) {
|
|
298
|
+
let n = e.apply(this, o);
|
|
299
299
|
return te(this, n, "reportValidity");
|
|
300
300
|
}
|
|
301
301
|
const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
302
302
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
303
|
-
get(...
|
|
304
|
-
const n = r.call(this, ...
|
|
303
|
+
get(...o) {
|
|
304
|
+
const n = r.call(this, ...o), h = Array.from(g.get(this) || []);
|
|
305
305
|
if (h.length === 0)
|
|
306
306
|
return n;
|
|
307
|
-
const
|
|
308
|
-
return new Ce(
|
|
307
|
+
const c = Array.from(n).concat(h).sort((b, f) => b.compareDocumentPosition ? b.compareDocumentPosition(f) & 2 ? 1 : -1 : 0);
|
|
308
|
+
return new Ce(c);
|
|
309
309
|
}
|
|
310
310
|
});
|
|
311
311
|
}
|
|
@@ -317,13 +317,13 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
317
317
|
if (!e || !e.tagName || e.tagName.indexOf("-") === -1)
|
|
318
318
|
throw new TypeError("Illegal constructor");
|
|
319
319
|
const i = e.getRootNode(), a = new ge();
|
|
320
|
-
this.states = new D(e),
|
|
320
|
+
this.states = new D(e), s.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 = s.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
|
-
const i =
|
|
326
|
+
const i = d.get(this);
|
|
327
327
|
if (!i.valid) {
|
|
328
328
|
const a = new Event("invalid", {
|
|
329
329
|
bubbles: !1,
|
|
@@ -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 = s.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 = s.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 = s.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 = s.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 o = X(i, this);
|
|
368
|
+
o.name = a, o.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 = s.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 o = d.get(this), n = {};
|
|
379
379
|
for (const b in e)
|
|
380
380
|
n[b] = e[b];
|
|
381
|
-
Object.keys(n).length === 0 && ye(
|
|
382
|
-
const h = Object.assign(Object.assign({},
|
|
381
|
+
Object.keys(n).length === 0 && ye(o);
|
|
382
|
+
const h = Object.assign(Object.assign({}, o), n);
|
|
383
383
|
delete h.valid;
|
|
384
|
-
const { valid:
|
|
385
|
-
if (!
|
|
384
|
+
const { valid: c } = Ee(o, h, this.form);
|
|
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
|
-
v.set(this,
|
|
387
|
+
v.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 = s.get(this), i = B.get(e);
|
|
391
391
|
return i || null;
|
|
392
392
|
}
|
|
393
393
|
get validationMessage() {
|
|
394
|
-
const e =
|
|
394
|
+
const e = s.get(this);
|
|
395
395
|
return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), v.get(this);
|
|
396
396
|
}
|
|
397
397
|
get validity() {
|
|
398
|
-
const e =
|
|
399
|
-
return w(e, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."),
|
|
398
|
+
const e = s.get(this);
|
|
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 = s.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
|
}
|
|
@@ -440,9 +440,9 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
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 o = 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)), o != null && o.apply(this), ie(this);
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
e.call(this, i, a, r);
|
|
@@ -460,8 +460,8 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
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 o = new MutationObserver(P);
|
|
464
|
+
window.ShadyDOM ? o.observe(this, _) : o.observe(r, _), O.set(this, o);
|
|
465
465
|
}
|
|
466
466
|
return r;
|
|
467
467
|
};
|
|
@@ -481,19 +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,
|
|
484
|
+
var Re = Object.defineProperty, m = (E, s, d, u) => {
|
|
485
485
|
for (var l = void 0, v = E.length - 1, M; v >= 0; v--)
|
|
486
|
-
(M = E[v]) && (l = M(
|
|
487
|
-
return l && Re(
|
|
486
|
+
(M = E[v]) && (l = M(s, d, l) || l);
|
|
487
|
+
return l && Re(s, 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
|
-
|
|
495
|
-
|
|
496
|
-
this.dispatchEvent(new Event("invalid", c));
|
|
494
|
+
this.handleFormAssociation(), this.input.addEventListener("invalid", (s) => {
|
|
495
|
+
this.dispatchEvent(new Event("invalid", s));
|
|
497
496
|
});
|
|
498
497
|
}
|
|
499
498
|
updated() {
|
|
@@ -509,10 +508,10 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
509
508
|
* The handleChange function updates the checkbox state and emits an event for consumers.
|
|
510
509
|
* @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
|
|
511
510
|
*/
|
|
512
|
-
handleChange(
|
|
513
|
-
const { checked:
|
|
514
|
-
this.checked =
|
|
515
|
-
const u = Ne(
|
|
511
|
+
handleChange(s) {
|
|
512
|
+
const { checked: d } = s == null ? void 0 : s.currentTarget;
|
|
513
|
+
this.checked = d;
|
|
514
|
+
const u = Ne(s);
|
|
516
515
|
this.dispatchEvent(u), this.handleFormAssociation();
|
|
517
516
|
}
|
|
518
517
|
/**
|
|
@@ -535,9 +534,8 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
535
534
|
* Allows a consumer to set a custom validation message on the switch. An empty string counts as valid.
|
|
536
535
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
537
536
|
*/
|
|
538
|
-
setCustomValidity(
|
|
539
|
-
|
|
540
|
-
(c = this.input) == null || c.setCustomValidity(o), this._internals.setValidity(this.validity, this.validationMessage, this.input);
|
|
537
|
+
setCustomValidity(s) {
|
|
538
|
+
this.input.setCustomValidity(s), this._internals.setValidity(this.validity, this.validationMessage, this.input);
|
|
541
539
|
}
|
|
542
540
|
/**
|
|
543
541
|
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
@@ -560,16 +558,16 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
560
558
|
*
|
|
561
559
|
* @private
|
|
562
560
|
*/
|
|
563
|
-
renderSwitchLabel(
|
|
564
|
-
const { label:
|
|
565
|
-
return !
|
|
561
|
+
renderSwitchLabel(s) {
|
|
562
|
+
const { label: d, labelPlacement: u } = this;
|
|
563
|
+
return !d || u !== s ? L : N`
|
|
566
564
|
<span data-test-id="switch-label-${u}">
|
|
567
|
-
${
|
|
565
|
+
${d}
|
|
568
566
|
</span>`;
|
|
569
567
|
}
|
|
570
568
|
renderAriaDescription() {
|
|
571
|
-
var
|
|
572
|
-
return (
|
|
569
|
+
var s;
|
|
570
|
+
return (s = this.aria) != null && s.describedBy ? N`
|
|
573
571
|
<div
|
|
574
572
|
id="switch-description"
|
|
575
573
|
data-test-id="switch-description"
|
|
@@ -579,8 +577,8 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
579
577
|
}
|
|
580
578
|
render() {
|
|
581
579
|
const {
|
|
582
|
-
aria:
|
|
583
|
-
checked:
|
|
580
|
+
aria: s,
|
|
581
|
+
checked: d,
|
|
584
582
|
disabled: u,
|
|
585
583
|
isRTL: l,
|
|
586
584
|
required: v
|
|
@@ -596,20 +594,20 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
596
594
|
<div
|
|
597
595
|
data-test-id="switch-component"
|
|
598
596
|
class="c-switch"
|
|
599
|
-
?checked=${
|
|
597
|
+
?checked=${d}>
|
|
600
598
|
<input
|
|
601
599
|
data-test-id="switch-input"
|
|
602
600
|
role="switch"
|
|
603
601
|
type="checkbox"
|
|
604
602
|
class="c-switch-input"
|
|
605
603
|
.required=${v}
|
|
606
|
-
.checked="${
|
|
604
|
+
.checked="${d}"
|
|
607
605
|
.disabled="${u}"
|
|
608
606
|
@change="${this.handleChange}"
|
|
609
|
-
aria-label="${Se(
|
|
610
|
-
aria-describedby="${
|
|
607
|
+
aria-label="${Se(s == null ? void 0 : s.label)}"
|
|
608
|
+
aria-describedby="${s != null && s.describedBy ? "switch-description" : L}">
|
|
611
609
|
<div class="c-switch-control">
|
|
612
|
-
${
|
|
610
|
+
${d ? N`<icon-check></icon-check>` : L}
|
|
613
611
|
</div>
|
|
614
612
|
</div>
|
|
615
613
|
${this.renderSwitchLabel("trailing")}
|
package/dist/react.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInpu
|
|
|
41
41
|
value: string;
|
|
42
42
|
name: SwitchProps['name'];
|
|
43
43
|
disabled: boolean;
|
|
44
|
-
private input
|
|
44
|
+
private input;
|
|
45
45
|
focusTarget: HTMLElement;
|
|
46
46
|
protected firstUpdated(): void;
|
|
47
47
|
protected updated(): 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": "0.30.
|
|
4
|
+
"version": "0.30.6",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
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.1.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"
|
package/src/index.ts
CHANGED
|
@@ -50,7 +50,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
50
50
|
public disabled = defaultProps.disabled;
|
|
51
51
|
|
|
52
52
|
@query('input[type="checkbox"]')
|
|
53
|
-
private input
|
|
53
|
+
private input!: HTMLInputElement;
|
|
54
54
|
|
|
55
55
|
@query('label')
|
|
56
56
|
public focusTarget!: HTMLElement;
|
|
@@ -59,7 +59,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
59
59
|
this.handleFormAssociation();
|
|
60
60
|
// This ensures that invalid events triggered by checkValidity() are propagated to the custom element
|
|
61
61
|
// for consumers to listen to: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
|
|
62
|
-
this.input
|
|
62
|
+
this.input.addEventListener('invalid', (event) => {
|
|
63
63
|
this.dispatchEvent(new Event('invalid', event));
|
|
64
64
|
});
|
|
65
65
|
}
|
|
@@ -108,7 +108,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
108
108
|
* @returns boolean
|
|
109
109
|
*/
|
|
110
110
|
public checkValidity (): boolean {
|
|
111
|
-
return
|
|
111
|
+
return this.input.checkValidity();
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -117,7 +117,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
117
117
|
* @returns boolean
|
|
118
118
|
*/
|
|
119
119
|
public reportValidity (): boolean {
|
|
120
|
-
return
|
|
120
|
+
return this.input.reportValidity();
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
/**
|
|
@@ -125,7 +125,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
125
125
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
126
126
|
*/
|
|
127
127
|
public setCustomValidity (message: string): void {
|
|
128
|
-
this.input
|
|
128
|
+
this.input.setCustomValidity(message);
|
|
129
129
|
this._internals.setValidity(this.validity, this.validationMessage, this.input);
|
|
130
130
|
}
|
|
131
131
|
|
|
@@ -134,7 +134,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
134
134
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validity
|
|
135
135
|
*/
|
|
136
136
|
public get validity (): ValidityState {
|
|
137
|
-
return
|
|
137
|
+
return this.input.validity;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
/**
|
|
@@ -143,7 +143,7 @@ export class PieSwitch extends FormControlMixin(RtlMixin(LitElement)) implements
|
|
|
143
143
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/validationMessage
|
|
144
144
|
*/
|
|
145
145
|
public get validationMessage (): string {
|
|
146
|
-
return
|
|
146
|
+
return this.input.validationMessage;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|