@justeattakeaway/pie-switch 1.2.2 → 1.3.0
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 +168 -155
- package/dist/react.d.ts +2 -2
- package/package.json +6 -5
- package/src/index.ts +3 -2
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
|
|
1
|
+
import { LitElement as Ie, unsafeCSS as Ve, nothing as L, html as N } from "lit";
|
|
2
2
|
import { property as y, query as ce } from "lit/decorators.js";
|
|
3
|
-
import { classMap as
|
|
4
|
-
import { ifDefined as
|
|
5
|
-
import { FormControlMixin as
|
|
3
|
+
import { classMap as Se } from "lit/directives/class-map.js";
|
|
4
|
+
import { ifDefined as Te } from "lit/directives/if-defined.js";
|
|
5
|
+
import { FormControlMixin as Le, RtlMixin as Ne, wrapNativeEvent as Pe, validPropertyValues as Oe, defineCustomElement as _e } from "@justeattakeaway/pie-webc-core";
|
|
6
6
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
7
|
+
var $e = Object.defineProperty, Re = (m, s, c, h) => {
|
|
8
|
+
for (var l = void 0, f = m.length - 1, E; f >= 0; f--)
|
|
9
|
+
(E = m[f]) && (l = E(s, c, l) || l);
|
|
10
|
+
return l && $e(s, c, l), l;
|
|
11
|
+
};
|
|
12
|
+
class de extends Ie {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments), this.v = "1.3.0";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
Re([
|
|
18
|
+
y({ type: String, reflect: !0 })
|
|
19
|
+
], de.prototype, "v");
|
|
7
20
|
(function() {
|
|
8
|
-
(function(
|
|
9
|
-
const
|
|
21
|
+
(function(m) {
|
|
22
|
+
const s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), h = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), P = /* @__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,7 +62,7 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
49
62
|
ariaValueNow: "aria-valuenow",
|
|
50
63
|
ariaValueText: "aria-valuetext",
|
|
51
64
|
role: "role"
|
|
52
|
-
},
|
|
65
|
+
}, ue = (t, e) => {
|
|
53
66
|
for (let i in F) {
|
|
54
67
|
e[i] = null;
|
|
55
68
|
let a = null;
|
|
@@ -58,8 +71,8 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
58
71
|
get() {
|
|
59
72
|
return a;
|
|
60
73
|
},
|
|
61
|
-
set(
|
|
62
|
-
a =
|
|
74
|
+
set(o) {
|
|
75
|
+
a = o, t.isConnected ? t.setAttribute(r, o) : C.set(t, e);
|
|
63
76
|
}
|
|
64
77
|
});
|
|
65
78
|
}
|
|
@@ -70,8 +83,8 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
70
83
|
}
|
|
71
84
|
const Y = (t, e = !1) => {
|
|
72
85
|
const i = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
|
|
73
|
-
acceptNode(
|
|
74
|
-
return l.has(
|
|
86
|
+
acceptNode(o) {
|
|
87
|
+
return l.has(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
75
88
|
}
|
|
76
89
|
});
|
|
77
90
|
let a = i.nextNode();
|
|
@@ -87,39 +100,39 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
87
100
|
}
|
|
88
101
|
}
|
|
89
102
|
}) : {};
|
|
90
|
-
function
|
|
103
|
+
function O(t) {
|
|
91
104
|
t.forEach((e) => {
|
|
92
|
-
const { addedNodes: i, removedNodes: a } = e, r = Array.from(i),
|
|
105
|
+
const { addedNodes: i, removedNodes: a } = e, 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), P.has(n) && P.get(n).disconnect();
|
|
119
132
|
});
|
|
120
133
|
});
|
|
121
134
|
}
|
|
122
|
-
function
|
|
135
|
+
function pe(t) {
|
|
123
136
|
t.forEach((e) => {
|
|
124
137
|
const { removedNodes: i } = e;
|
|
125
138
|
i.forEach((a) => {
|
|
@@ -128,27 +141,27 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
128
141
|
});
|
|
129
142
|
});
|
|
130
143
|
}
|
|
131
|
-
const
|
|
144
|
+
const fe = (t) => {
|
|
132
145
|
var e, i;
|
|
133
|
-
const a = new MutationObserver(
|
|
146
|
+
const a = new MutationObserver(pe);
|
|
134
147
|
!((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 }), j.set(t, a);
|
|
135
148
|
};
|
|
136
|
-
T() && new MutationObserver(
|
|
149
|
+
T() && new MutationObserver(O);
|
|
137
150
|
const _ = {
|
|
138
151
|
childList: !0,
|
|
139
152
|
subtree: !0
|
|
140
153
|
}, $ = (t, e) => {
|
|
141
154
|
t.toggleAttribute("internals-disabled", e), e ? t.setAttribute("aria-disabled", "true") : t.removeAttribute("aria-disabled"), t.formDisabledCallback && t.formDisabledCallback.apply(t, [e]);
|
|
142
155
|
}, Q = (t) => {
|
|
143
|
-
|
|
156
|
+
h.get(t).forEach((i) => {
|
|
144
157
|
i.remove();
|
|
145
|
-
}),
|
|
158
|
+
}), h.set(t, []);
|
|
146
159
|
}, X = (t, e) => {
|
|
147
160
|
const i = document.createElement("input");
|
|
148
|
-
return i.type = "hidden", i.name = t.getAttribute("name"), t.after(i),
|
|
161
|
+
return i.type = "hidden", i.name = t.getAttribute("name"), t.after(i), h.get(e).push(i), i;
|
|
149
162
|
}, me = (t, e) => {
|
|
150
163
|
var i;
|
|
151
|
-
|
|
164
|
+
h.set(e, []), (i = I.observe) === null || i === void 0 || i.call(I, t, J);
|
|
152
165
|
}, Z = (t, e) => {
|
|
153
166
|
if (e.length) {
|
|
154
167
|
Array.from(e).forEach((a) => a.addEventListener("click", t.click.bind(t)));
|
|
@@ -156,48 +169,48 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
156
169
|
e[0].id || (i = `${e[0].htmlFor}_Label`, e[0].id = i), t.setAttribute("aria-labelledby", i);
|
|
157
170
|
}
|
|
158
171
|
}, V = (t) => {
|
|
159
|
-
const e = Array.from(t.elements).filter((
|
|
172
|
+
const e = Array.from(t.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = k.get(t) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => l.get(o).validity.valid), r = [...e, ...a].includes(!1);
|
|
160
173
|
t.toggleAttribute("internals-invalid", r), t.toggleAttribute("internals-valid", !r);
|
|
161
|
-
}, fe = (t) => {
|
|
162
|
-
V(S(t.target));
|
|
163
174
|
}, be = (t) => {
|
|
164
175
|
V(S(t.target));
|
|
165
176
|
}, ve = (t) => {
|
|
177
|
+
V(S(t.target));
|
|
178
|
+
}, we = (t) => {
|
|
166
179
|
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
180
|
t.addEventListener("click", (i) => {
|
|
168
181
|
if (i.target.closest(e)) {
|
|
169
|
-
const r =
|
|
182
|
+
const r = k.get(t);
|
|
170
183
|
if (t.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 e =
|
|
188
|
+
}, ge = (t) => {
|
|
189
|
+
const e = k.get(t.target);
|
|
177
190
|
e && e.size && e.forEach((i) => {
|
|
178
191
|
i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
|
|
179
192
|
});
|
|
180
193
|
}, ee = (t, e, i) => {
|
|
181
194
|
if (e) {
|
|
182
|
-
const a =
|
|
195
|
+
const a = k.get(e);
|
|
183
196
|
if (a)
|
|
184
197
|
a.add(t);
|
|
185
198
|
else {
|
|
186
199
|
const r = /* @__PURE__ */ new Set();
|
|
187
|
-
r.add(t),
|
|
200
|
+
r.add(t), k.set(e, r), we(e), e.addEventListener("reset", ge), e.addEventListener("input", be), e.addEventListener("change", ve);
|
|
188
201
|
}
|
|
189
|
-
|
|
202
|
+
E.set(e, { ref: t, internals: i }), t.constructor.formAssociated && t.formAssociatedCallback && setTimeout(() => {
|
|
190
203
|
t.formAssociatedCallback.apply(t, [e]);
|
|
191
204
|
}, 0), V(e);
|
|
192
205
|
}
|
|
193
206
|
}, S = (t) => {
|
|
194
207
|
let e = t.parentNode;
|
|
195
208
|
return e && e.tagName !== "FORM" && (e = S(e)), e;
|
|
196
|
-
},
|
|
209
|
+
}, w = (t, e, i = DOMException) => {
|
|
197
210
|
if (!t.constructor.formAssociated)
|
|
198
211
|
throw new i(e);
|
|
199
212
|
}, te = (t, e, i) => {
|
|
200
|
-
const a =
|
|
213
|
+
const a = k.get(t);
|
|
201
214
|
return a && a.size && a.forEach((r) => {
|
|
202
215
|
l.get(r)[i]() || (e = !1);
|
|
203
216
|
}), e;
|
|
@@ -210,12 +223,12 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
210
223
|
function T() {
|
|
211
224
|
return typeof MutationObserver < "u";
|
|
212
225
|
}
|
|
213
|
-
class
|
|
226
|
+
class ye {
|
|
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
|
|
231
|
+
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), ke = (t, e, i) => (t.valid = Me(e), Object.keys(e).forEach((a) => t[a] = e[a]), i && V(i), t), Me = (t) => {
|
|
219
232
|
let e = !0;
|
|
220
233
|
for (let i in t)
|
|
221
234
|
i !== "valid" && t[i] !== !1 && (e = !1);
|
|
@@ -258,14 +271,14 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
258
271
|
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");
|
|
259
272
|
return i === "m" ? a : i === "a" ? a.call(t) : a ? a.value : e.get(t);
|
|
260
273
|
}
|
|
261
|
-
function
|
|
274
|
+
function xe(t, e, i, a, r) {
|
|
262
275
|
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
276
|
return e.set(t, i), i;
|
|
264
277
|
}
|
|
265
278
|
var x;
|
|
266
|
-
class
|
|
279
|
+
class Ce {
|
|
267
280
|
constructor(e) {
|
|
268
|
-
x.set(this, void 0),
|
|
281
|
+
x.set(this, void 0), xe(this, x, e);
|
|
269
282
|
for (let i = 0; i < e.length; i++) {
|
|
270
283
|
let a = e[i];
|
|
271
284
|
this[i] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
|
|
@@ -285,27 +298,27 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
285
298
|
return this[e] == null ? null : this[e];
|
|
286
299
|
}
|
|
287
300
|
}
|
|
288
|
-
function
|
|
301
|
+
function Ae() {
|
|
289
302
|
const t = HTMLFormElement.prototype.checkValidity;
|
|
290
303
|
HTMLFormElement.prototype.checkValidity = i;
|
|
291
304
|
const e = HTMLFormElement.prototype.reportValidity;
|
|
292
305
|
HTMLFormElement.prototype.reportValidity = a;
|
|
293
|
-
function i(...
|
|
294
|
-
let n = t.apply(this,
|
|
306
|
+
function i(...o) {
|
|
307
|
+
let n = t.apply(this, o);
|
|
295
308
|
return te(this, n, "checkValidity");
|
|
296
309
|
}
|
|
297
|
-
function a(...
|
|
298
|
-
let n = e.apply(this,
|
|
310
|
+
function a(...o) {
|
|
311
|
+
let n = e.apply(this, o);
|
|
299
312
|
return te(this, n, "reportValidity");
|
|
300
313
|
}
|
|
301
314
|
const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
|
|
302
315
|
Object.defineProperty(HTMLFormElement.prototype, "elements", {
|
|
303
|
-
get(...
|
|
304
|
-
const n = r.call(this, ...
|
|
305
|
-
if (
|
|
316
|
+
get(...o) {
|
|
317
|
+
const n = r.call(this, ...o), u = Array.from(k.get(this) || []);
|
|
318
|
+
if (u.length === 0)
|
|
306
319
|
return n;
|
|
307
|
-
const
|
|
308
|
-
return new
|
|
320
|
+
const d = Array.from(n).concat(u).sort((g, b) => g.compareDocumentPosition ? g.compareDocumentPosition(b) & 2 ? 1 : -1 : 0);
|
|
321
|
+
return new Ce(d);
|
|
309
322
|
}
|
|
310
323
|
});
|
|
311
324
|
}
|
|
@@ -316,14 +329,14 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
316
329
|
constructor(e) {
|
|
317
330
|
if (!e || !e.tagName || e.tagName.indexOf("-") === -1)
|
|
318
331
|
throw new TypeError("Illegal constructor");
|
|
319
|
-
const i = e.getRootNode(), a = new
|
|
320
|
-
this.states = new D(e),
|
|
332
|
+
const i = e.getRootNode(), a = new ye();
|
|
333
|
+
this.states = new D(e), s.set(this, e), c.set(this, a), l.set(e, this), ue(e, this), me(e, this), Object.seal(this), i instanceof DocumentFragment && fe(i);
|
|
321
334
|
}
|
|
322
335
|
checkValidity() {
|
|
323
|
-
const e =
|
|
324
|
-
if (
|
|
336
|
+
const e = s.get(this);
|
|
337
|
+
if (w(e, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
325
338
|
return !0;
|
|
326
|
-
const i =
|
|
339
|
+
const i = c.get(this);
|
|
327
340
|
if (!i.valid) {
|
|
328
341
|
const a = new Event("invalid", {
|
|
329
342
|
bubbles: !1,
|
|
@@ -335,20 +348,20 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
335
348
|
return i.valid;
|
|
336
349
|
}
|
|
337
350
|
get form() {
|
|
338
|
-
const e =
|
|
339
|
-
|
|
351
|
+
const e = s.get(this);
|
|
352
|
+
w(e, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
340
353
|
let i;
|
|
341
354
|
return e.constructor.formAssociated === !0 && (i = S(e)), i;
|
|
342
355
|
}
|
|
343
356
|
get labels() {
|
|
344
|
-
const e =
|
|
345
|
-
|
|
357
|
+
const e = s.get(this);
|
|
358
|
+
w(e, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
|
|
346
359
|
const i = e.getAttribute("id"), a = e.getRootNode();
|
|
347
360
|
return a && i ? a.querySelectorAll(`[for="${i}"]`) : [];
|
|
348
361
|
}
|
|
349
362
|
reportValidity() {
|
|
350
|
-
const e =
|
|
351
|
-
if (
|
|
363
|
+
const e = s.get(this);
|
|
364
|
+
if (w(e, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
|
|
352
365
|
return !0;
|
|
353
366
|
const i = this.checkValidity(), a = U.get(this);
|
|
354
367
|
if (a && !e.constructor.formAssociated)
|
|
@@ -356,54 +369,54 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
356
369
|
return !i && a && (e.focus(), a.focus()), i;
|
|
357
370
|
}
|
|
358
371
|
setFormValue(e) {
|
|
359
|
-
const i =
|
|
360
|
-
if (
|
|
372
|
+
const i = s.get(this);
|
|
373
|
+
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
374
|
if (i.getAttribute("name")) {
|
|
362
375
|
const a = X(i, this);
|
|
363
376
|
a.value = e;
|
|
364
377
|
}
|
|
365
378
|
} else e != null && e instanceof FormData && Array.from(e).reverse().forEach(([a, r]) => {
|
|
366
379
|
if (typeof r == "string") {
|
|
367
|
-
const
|
|
368
|
-
|
|
380
|
+
const o = X(i, this);
|
|
381
|
+
o.name = a, o.value = r;
|
|
369
382
|
}
|
|
370
383
|
});
|
|
371
384
|
q.set(i, e);
|
|
372
385
|
}
|
|
373
386
|
setValidity(e, i, a) {
|
|
374
|
-
const r =
|
|
375
|
-
if (
|
|
387
|
+
const r = s.get(this);
|
|
388
|
+
if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !e)
|
|
376
389
|
throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
|
|
377
390
|
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 (!
|
|
391
|
+
const o = c.get(this), n = {};
|
|
392
|
+
for (const g in e)
|
|
393
|
+
n[g] = e[g];
|
|
394
|
+
Object.keys(n).length === 0 && Ee(o);
|
|
395
|
+
const u = Object.assign(Object.assign({}, o), n);
|
|
396
|
+
delete u.valid;
|
|
397
|
+
const { valid: d } = ke(o, u, this.form);
|
|
398
|
+
if (!d && !i)
|
|
386
399
|
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
|
-
|
|
400
|
+
f.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
401
|
}
|
|
389
402
|
get shadowRoot() {
|
|
390
|
-
const e =
|
|
403
|
+
const e = s.get(this), i = B.get(e);
|
|
391
404
|
return i || null;
|
|
392
405
|
}
|
|
393
406
|
get validationMessage() {
|
|
394
|
-
const e =
|
|
395
|
-
return
|
|
407
|
+
const e = s.get(this);
|
|
408
|
+
return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), f.get(this);
|
|
396
409
|
}
|
|
397
410
|
get validity() {
|
|
398
|
-
const e =
|
|
399
|
-
return
|
|
411
|
+
const e = s.get(this);
|
|
412
|
+
return w(e, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), c.get(this);
|
|
400
413
|
}
|
|
401
414
|
get willValidate() {
|
|
402
|
-
const e =
|
|
403
|
-
return
|
|
415
|
+
const e = s.get(this);
|
|
416
|
+
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
417
|
}
|
|
405
418
|
}
|
|
406
|
-
function
|
|
419
|
+
function Fe() {
|
|
407
420
|
if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
|
|
408
421
|
return !1;
|
|
409
422
|
class t extends HTMLElement {
|
|
@@ -440,9 +453,9 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
440
453
|
const e = CustomElementRegistry.prototype.define;
|
|
441
454
|
CustomElementRegistry.prototype.define = function(i, a, r) {
|
|
442
455
|
if (a.formAssociated) {
|
|
443
|
-
const
|
|
456
|
+
const o = a.prototype.connectedCallback;
|
|
444
457
|
a.prototype.connectedCallback = function() {
|
|
445
|
-
K.has(this) || (K.set(this, !0), this.hasAttribute("disabled") && $(this, !0)),
|
|
458
|
+
K.has(this) || (K.set(this, !0), this.hasAttribute("disabled") && $(this, !0)), o != null && o.apply(this), ie(this);
|
|
446
459
|
};
|
|
447
460
|
}
|
|
448
461
|
e.call(this, i, a, r);
|
|
@@ -460,39 +473,39 @@ import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
|
460
473
|
let e = function(...a) {
|
|
461
474
|
const r = i.apply(this, a);
|
|
462
475
|
if (B.set(this, r), T()) {
|
|
463
|
-
const
|
|
464
|
-
window.ShadyDOM ?
|
|
476
|
+
const o = new MutationObserver(O);
|
|
477
|
+
window.ShadyDOM ? o.observe(this, _) : o.observe(r, _), P.set(this, o);
|
|
465
478
|
}
|
|
466
479
|
return r;
|
|
467
480
|
};
|
|
468
481
|
const i = Element.prototype.attachShadow;
|
|
469
482
|
Element.prototype.attachShadow = e;
|
|
470
483
|
}
|
|
471
|
-
T() && typeof document < "u" && new MutationObserver(
|
|
484
|
+
T() && typeof document < "u" && new MutationObserver(O).observe(document.documentElement, _), typeof HTMLFormElement < "u" && Ae(), (t || typeof window < "u" && !window.CustomStateSet) && H();
|
|
472
485
|
}
|
|
473
486
|
}
|
|
474
|
-
return !!customElements.polyfillWrapFlushCallback || (
|
|
487
|
+
return !!customElements.polyfillWrapFlushCallback || (Fe() ? typeof window < "u" && !window.CustomStateSet && H(HTMLElement.prototype.attachInternals) : le(!1)), m.forceCustomStateSetPolyfill = H, m.forceElementInternalsPolyfill = le, Object.defineProperty(m, "__esModule", { value: !0 }), m;
|
|
475
488
|
})({});
|
|
476
489
|
})();
|
|
477
|
-
const
|
|
490
|
+
const De = "*,*: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}}", He = ["leading", "trailing"], Ye = "change", M = {
|
|
478
491
|
checked: !1,
|
|
479
492
|
disabled: !1,
|
|
480
493
|
labelPlacement: "leading",
|
|
481
494
|
required: !1,
|
|
482
495
|
value: "on"
|
|
483
496
|
};
|
|
484
|
-
var
|
|
485
|
-
for (var l = void 0,
|
|
486
|
-
(
|
|
487
|
-
return l &&
|
|
497
|
+
var We = Object.defineProperty, v = (m, s, c, h) => {
|
|
498
|
+
for (var l = void 0, f = m.length - 1, E; f >= 0; f--)
|
|
499
|
+
(E = m[f]) && (l = E(s, c, l) || l);
|
|
500
|
+
return l && We(s, c, l), l;
|
|
488
501
|
};
|
|
489
|
-
const
|
|
502
|
+
const he = "pie-switch", z = class z extends Le(Ne(de)) {
|
|
490
503
|
constructor() {
|
|
491
|
-
super(...arguments), this.labelPlacement =
|
|
504
|
+
super(...arguments), this.labelPlacement = M.labelPlacement, this.checked = M.checked, this.required = M.required, this.value = M.value, this.disabled = M.disabled;
|
|
492
505
|
}
|
|
493
506
|
firstUpdated() {
|
|
494
|
-
this.handleFormAssociation(), this.input.addEventListener("invalid", (
|
|
495
|
-
this.dispatchEvent(new Event("invalid",
|
|
507
|
+
this.handleFormAssociation(), this.input.addEventListener("invalid", (s) => {
|
|
508
|
+
this.dispatchEvent(new Event("invalid", s));
|
|
496
509
|
});
|
|
497
510
|
}
|
|
498
511
|
updated() {
|
|
@@ -508,11 +521,11 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
508
521
|
* The handleChange function updates the checkbox state and emits an event for consumers.
|
|
509
522
|
* @param {Event} event - This should be the change event that was listened for on an input element with `type="checkbox"`.
|
|
510
523
|
*/
|
|
511
|
-
handleChange(
|
|
512
|
-
const { checked:
|
|
513
|
-
this.checked =
|
|
514
|
-
const
|
|
515
|
-
this.dispatchEvent(
|
|
524
|
+
handleChange(s) {
|
|
525
|
+
const { checked: c } = s == null ? void 0 : s.currentTarget;
|
|
526
|
+
this.checked = c;
|
|
527
|
+
const h = Pe(s);
|
|
528
|
+
this.dispatchEvent(h), this.handleFormAssociation();
|
|
516
529
|
}
|
|
517
530
|
/**
|
|
518
531
|
* 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 +547,8 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
534
547
|
* Allows a consumer to set a custom validation message on the switch. An empty string counts as valid.
|
|
535
548
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setCustomValidity
|
|
536
549
|
*/
|
|
537
|
-
setCustomValidity(
|
|
538
|
-
this.input.setCustomValidity(
|
|
550
|
+
setCustomValidity(s) {
|
|
551
|
+
this.input.setCustomValidity(s), this._internals.setValidity(this.validity, this.validationMessage, this.input);
|
|
539
552
|
}
|
|
540
553
|
/**
|
|
541
554
|
* (Read-only) returns a ValidityState with the validity states that this element is in.
|
|
@@ -558,18 +571,18 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
558
571
|
*
|
|
559
572
|
* @private
|
|
560
573
|
*/
|
|
561
|
-
renderSwitchLabel(
|
|
562
|
-
const { label:
|
|
563
|
-
return !
|
|
574
|
+
renderSwitchLabel(s) {
|
|
575
|
+
const { label: c, labelPlacement: h } = this;
|
|
576
|
+
return !c || h !== s ? L : N`
|
|
564
577
|
<span
|
|
565
|
-
data-test-id="switch-label-${
|
|
578
|
+
data-test-id="switch-label-${h}"
|
|
566
579
|
class="c-switch-label">
|
|
567
|
-
${
|
|
580
|
+
${c}
|
|
568
581
|
</span>`;
|
|
569
582
|
}
|
|
570
583
|
renderAriaDescription() {
|
|
571
|
-
var
|
|
572
|
-
return (
|
|
584
|
+
var s;
|
|
585
|
+
return (s = this.aria) != null && s.describedBy ? N`
|
|
573
586
|
<div
|
|
574
587
|
id="switch-description"
|
|
575
588
|
data-test-id="switch-description"
|
|
@@ -579,37 +592,37 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
579
592
|
}
|
|
580
593
|
render() {
|
|
581
594
|
const {
|
|
582
|
-
aria:
|
|
583
|
-
checked:
|
|
584
|
-
disabled:
|
|
595
|
+
aria: s,
|
|
596
|
+
checked: c,
|
|
597
|
+
disabled: h,
|
|
585
598
|
isRTL: l,
|
|
586
|
-
required:
|
|
599
|
+
required: f
|
|
587
600
|
} = this;
|
|
588
601
|
return N`
|
|
589
602
|
<label
|
|
590
|
-
class="${
|
|
603
|
+
class="${Se({
|
|
591
604
|
"c-switch-wrapper": !0,
|
|
592
605
|
"c-switch-wrapper--rtl": l
|
|
593
606
|
})}"
|
|
594
|
-
?disabled=${
|
|
607
|
+
?disabled=${h}>
|
|
595
608
|
${this.renderSwitchLabel("leading")}
|
|
596
609
|
<div
|
|
597
610
|
data-test-id="switch-component"
|
|
598
611
|
class="c-switch"
|
|
599
|
-
?checked=${
|
|
612
|
+
?checked=${c}>
|
|
600
613
|
<input
|
|
601
614
|
data-test-id="switch-input"
|
|
602
615
|
role="switch"
|
|
603
616
|
type="checkbox"
|
|
604
617
|
class="c-switch-input"
|
|
605
|
-
.required=${
|
|
606
|
-
.checked="${
|
|
607
|
-
.disabled="${
|
|
618
|
+
.required=${f}
|
|
619
|
+
.checked="${c}"
|
|
620
|
+
.disabled="${h}"
|
|
608
621
|
@change="${this.handleChange}"
|
|
609
|
-
aria-label="${
|
|
610
|
-
aria-describedby="${
|
|
622
|
+
aria-label="${Te(s == null ? void 0 : s.label)}"
|
|
623
|
+
aria-describedby="${s != null && s.describedBy ? "switch-description" : L}">
|
|
611
624
|
<div class="c-switch-control">
|
|
612
|
-
${
|
|
625
|
+
${c ? N`<icon-check></icon-check>` : L}
|
|
613
626
|
</div>
|
|
614
627
|
</div>
|
|
615
628
|
${this.renderSwitchLabel("trailing")}
|
|
@@ -617,43 +630,43 @@ const de = "pie-switch", z = class z extends Te(Le(Fe)) {
|
|
|
617
630
|
</label>`;
|
|
618
631
|
}
|
|
619
632
|
};
|
|
620
|
-
z.styles =
|
|
633
|
+
z.styles = Ve(De);
|
|
621
634
|
let p = z;
|
|
622
|
-
|
|
635
|
+
v([
|
|
623
636
|
y({ type: String })
|
|
624
637
|
], p.prototype, "label");
|
|
625
|
-
|
|
638
|
+
v([
|
|
626
639
|
y({ type: String }),
|
|
627
|
-
Oe(
|
|
640
|
+
Oe(he, He, M.labelPlacement)
|
|
628
641
|
], p.prototype, "labelPlacement");
|
|
629
|
-
|
|
642
|
+
v([
|
|
630
643
|
y({ type: Object })
|
|
631
644
|
], p.prototype, "aria");
|
|
632
|
-
|
|
645
|
+
v([
|
|
633
646
|
y({ type: Boolean, reflect: !0 })
|
|
634
647
|
], p.prototype, "checked");
|
|
635
|
-
|
|
648
|
+
v([
|
|
636
649
|
y({ type: Boolean, reflect: !0 })
|
|
637
650
|
], p.prototype, "required");
|
|
638
|
-
|
|
651
|
+
v([
|
|
639
652
|
y({ type: String })
|
|
640
653
|
], p.prototype, "value");
|
|
641
|
-
|
|
654
|
+
v([
|
|
642
655
|
y({ type: String })
|
|
643
656
|
], p.prototype, "name");
|
|
644
|
-
|
|
657
|
+
v([
|
|
645
658
|
y({ type: Boolean, reflect: !0 })
|
|
646
659
|
], p.prototype, "disabled");
|
|
647
|
-
|
|
660
|
+
v([
|
|
648
661
|
ce('input[type="checkbox"]')
|
|
649
662
|
], p.prototype, "input");
|
|
650
|
-
|
|
663
|
+
v([
|
|
651
664
|
ce("label")
|
|
652
665
|
], p.prototype, "focusTarget");
|
|
653
|
-
|
|
666
|
+
_e(he, p);
|
|
654
667
|
export {
|
|
655
|
-
|
|
668
|
+
Ye as ON_SWITCH_CHANGED_EVENT,
|
|
656
669
|
p as PieSwitch,
|
|
657
|
-
|
|
658
|
-
|
|
670
|
+
M as defaultProps,
|
|
671
|
+
He as labelPlacements
|
|
659
672
|
};
|
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.0",
|
|
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.0",
|
|
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.1",
|
|
49
|
+
"@justeattakeaway/pie-webc-core": "0.25.0",
|
|
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
|
|