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