@justeattakeaway/pie-switch 2.2.0 → 2.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 +4 -9
- package/dist/index.d.ts +0 -6
- package/dist/index.js +49 -50
- package/dist/react.d.ts +0 -6
- package/package.json +10 -5
- package/src/index.ts +2 -4
- package/src/switch.scss +1 -1
package/custom-elements.json
CHANGED
|
@@ -148,15 +148,6 @@
|
|
|
148
148
|
"privacy": "private",
|
|
149
149
|
"default": "false"
|
|
150
150
|
},
|
|
151
|
-
{
|
|
152
|
-
"kind": "field",
|
|
153
|
-
"name": "shadowRootOptions",
|
|
154
|
-
"type": {
|
|
155
|
-
"text": "object"
|
|
156
|
-
},
|
|
157
|
-
"static": true,
|
|
158
|
-
"default": "{ ...LitElement.shadowRootOptions, delegatesFocus: true }"
|
|
159
|
-
},
|
|
160
151
|
{
|
|
161
152
|
"kind": "method",
|
|
162
153
|
"name": "handleFormAssociation",
|
|
@@ -283,6 +274,10 @@
|
|
|
283
274
|
{
|
|
284
275
|
"name": "FormControlMixin",
|
|
285
276
|
"package": "@justeattakeaway/pie-webc-core"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"name": "DelegatesFocusMixin",
|
|
280
|
+
"package": "@justeattakeaway/pie-webc-core"
|
|
286
281
|
}
|
|
287
282
|
],
|
|
288
283
|
"superclass": {
|
package/dist/index.d.ts
CHANGED
|
@@ -40,12 +40,6 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
|
|
|
40
40
|
private input;
|
|
41
41
|
focusTarget: HTMLElement;
|
|
42
42
|
private _isAnimationAllowed;
|
|
43
|
-
static shadowRootOptions: {
|
|
44
|
-
delegatesFocus: boolean;
|
|
45
|
-
mode: ShadowRootMode;
|
|
46
|
-
serializable?: boolean;
|
|
47
|
-
slotAssignment?: SlotAssignmentMode;
|
|
48
|
-
};
|
|
49
43
|
protected firstUpdated(): void;
|
|
50
44
|
protected updated(): void;
|
|
51
45
|
static styles: CSSResult;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { LitElement as
|
|
2
|
-
import { property as E, query as
|
|
1
|
+
import { LitElement as Ft, nothing as L, html as N, unsafeCSS as It } from "lit";
|
|
2
|
+
import { property as E, query as dt, state as St } from "lit/decorators.js";
|
|
3
3
|
import { classMap as Vt } from "lit/directives/class-map.js";
|
|
4
4
|
import { ifDefined as Tt } from "lit/directives/if-defined.js";
|
|
5
|
-
import { FormControlMixin as Lt,
|
|
5
|
+
import { FormControlMixin as Lt, DelegatesFocusMixin as Nt, wrapNativeEvent as Ot, validPropertyValues as Pt, safeCustomElement as _t } from "@justeattakeaway/pie-webc-core";
|
|
6
6
|
import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
|
|
7
|
-
const O = class O extends
|
|
7
|
+
const O = class O extends Ft {
|
|
8
8
|
willUpdate() {
|
|
9
9
|
this.getAttribute("v") || this.setAttribute("v", O.v);
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
O.v = "2.
|
|
12
|
+
O.v = "2.3.1";
|
|
13
13
|
let q = O;
|
|
14
14
|
(function() {
|
|
15
15
|
(function(l) {
|
|
@@ -56,7 +56,7 @@ let q = O;
|
|
|
56
56
|
ariaValueNow: "aria-valuenow",
|
|
57
57
|
ariaValueText: "aria-valuetext",
|
|
58
58
|
role: "role"
|
|
59
|
-
},
|
|
59
|
+
}, ht = (e, t) => {
|
|
60
60
|
for (let i in F) {
|
|
61
61
|
t[i] = null;
|
|
62
62
|
let a = null;
|
|
@@ -84,11 +84,11 @@ let q = O;
|
|
|
84
84
|
let a = i.nextNode();
|
|
85
85
|
const r = !t || e.disabled;
|
|
86
86
|
for (; a; )
|
|
87
|
-
a.formDisabledCallback && r &&
|
|
87
|
+
a.formDisabledCallback && r && D(a, e.disabled), a = i.nextNode();
|
|
88
88
|
}, Q = { attributes: !0, attributeFilter: ["disabled", "name"] }, I = T() ? new MutationObserver((e) => {
|
|
89
89
|
for (const t of e) {
|
|
90
90
|
const i = t.target;
|
|
91
|
-
if (t.attributeName === "disabled" && (i.constructor.formAssociated ?
|
|
91
|
+
if (t.attributeName === "disabled" && (i.constructor.formAssociated ? D(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && J(i)), t.attributeName === "name" && i.constructor.formAssociated) {
|
|
92
92
|
const a = c.get(i), r = B.get(i);
|
|
93
93
|
a.setFormValue(r);
|
|
94
94
|
}
|
|
@@ -126,7 +126,7 @@ let q = O;
|
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function ut(e) {
|
|
130
130
|
e.forEach((t) => {
|
|
131
131
|
const { removedNodes: i } = t;
|
|
132
132
|
i.forEach((a) => {
|
|
@@ -135,16 +135,16 @@ let q = O;
|
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
-
const
|
|
138
|
+
const pt = (e) => {
|
|
139
139
|
var t, i;
|
|
140
|
-
const a = new MutationObserver(
|
|
140
|
+
const a = new MutationObserver(ut);
|
|
141
141
|
!((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 }), K.set(e, a);
|
|
142
142
|
};
|
|
143
143
|
T() && new MutationObserver(_);
|
|
144
144
|
const $ = {
|
|
145
145
|
childList: !0,
|
|
146
146
|
subtree: !0
|
|
147
|
-
},
|
|
147
|
+
}, D = (e, t) => {
|
|
148
148
|
e.toggleAttribute("internals-disabled", t), t ? e.setAttribute("aria-disabled", "true") : e.removeAttribute("aria-disabled"), e.formDisabledCallback && e.formDisabledCallback.apply(e, [t]);
|
|
149
149
|
}, X = (e) => {
|
|
150
150
|
m.get(e).forEach((i) => {
|
|
@@ -153,7 +153,7 @@ let q = O;
|
|
|
153
153
|
}, Z = (e, t) => {
|
|
154
154
|
const i = document.createElement("input");
|
|
155
155
|
return i.type = "hidden", i.name = e.getAttribute("name"), e.after(i), m.get(t).push(i), i;
|
|
156
|
-
},
|
|
156
|
+
}, mt = (e, t) => {
|
|
157
157
|
var i;
|
|
158
158
|
m.set(t, []), (i = I.observe) === null || i === void 0 || i.call(I, e, Q);
|
|
159
159
|
}, tt = (e, t) => {
|
|
@@ -165,11 +165,11 @@ let q = O;
|
|
|
165
165
|
}, S = (e) => {
|
|
166
166
|
const t = Array.from(e.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = y.get(e) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => c.get(o).validity.valid), r = [...t, ...a].includes(!1);
|
|
167
167
|
e.toggleAttribute("internals-invalid", r), e.toggleAttribute("internals-valid", !r);
|
|
168
|
+
}, ft = (e) => {
|
|
169
|
+
S(V(e.target));
|
|
168
170
|
}, bt = (e) => {
|
|
169
171
|
S(V(e.target));
|
|
170
172
|
}, vt = (e) => {
|
|
171
|
-
S(V(e.target));
|
|
172
|
-
}, wt = (e) => {
|
|
173
173
|
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(",");
|
|
174
174
|
e.addEventListener("click", (i) => {
|
|
175
175
|
if (i.target.closest(t)) {
|
|
@@ -179,7 +179,7 @@ let q = O;
|
|
|
179
179
|
r.size && Array.from(r).reverse().map((u) => c.get(u).reportValidity()).includes(!1) && i.preventDefault();
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
|
-
},
|
|
182
|
+
}, wt = (e) => {
|
|
183
183
|
const t = y.get(e.target);
|
|
184
184
|
t && t.size && t.forEach((i) => {
|
|
185
185
|
i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
|
|
@@ -191,7 +191,7 @@ let q = O;
|
|
|
191
191
|
a.add(e);
|
|
192
192
|
else {
|
|
193
193
|
const r = /* @__PURE__ */ new Set();
|
|
194
|
-
r.add(e), y.set(t, r),
|
|
194
|
+
r.add(e), y.set(t, r), vt(t), t.addEventListener("reset", wt), t.addEventListener("input", ft), t.addEventListener("change", bt);
|
|
195
195
|
}
|
|
196
196
|
k.set(t, { ref: e, internals: i }), e.constructor.formAssociated && e.formAssociatedCallback && setTimeout(() => {
|
|
197
197
|
e.formAssociatedCallback.apply(e, [t]);
|
|
@@ -217,17 +217,17 @@ let q = O;
|
|
|
217
217
|
function T() {
|
|
218
218
|
return typeof MutationObserver < "u";
|
|
219
219
|
}
|
|
220
|
-
class
|
|
220
|
+
class gt {
|
|
221
221
|
constructor() {
|
|
222
222
|
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);
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const yt = (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), Et = (e, t, i) => (e.valid = kt(t), Object.keys(t).forEach((a) => e[a] = t[a]), i && S(i), e), kt = (e) => {
|
|
226
226
|
let t = !0;
|
|
227
227
|
for (let i in e)
|
|
228
228
|
i !== "valid" && e[i] !== !1 && (t = !1);
|
|
229
229
|
return t;
|
|
230
|
-
},
|
|
230
|
+
}, R = /* @__PURE__ */ new WeakMap();
|
|
231
231
|
function rt(e, t) {
|
|
232
232
|
e.toggleAttribute(t, !0), e.part && e.part.add(t);
|
|
233
233
|
}
|
|
@@ -238,12 +238,12 @@ let q = O;
|
|
|
238
238
|
constructor(t) {
|
|
239
239
|
if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
240
240
|
throw new TypeError("Illegal constructor");
|
|
241
|
-
|
|
241
|
+
R.set(this, t);
|
|
242
242
|
}
|
|
243
243
|
add(t) {
|
|
244
244
|
if (!/^--/.test(t) || typeof t != "string")
|
|
245
245
|
throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
|
|
246
|
-
const i = super.add(t), a =
|
|
246
|
+
const i = super.add(t), a = R.get(this), r = `state${t}`;
|
|
247
247
|
return a.isConnected ? rt(a, r) : setTimeout(() => {
|
|
248
248
|
rt(a, r);
|
|
249
249
|
}), i;
|
|
@@ -254,7 +254,7 @@ let q = O;
|
|
|
254
254
|
super.clear();
|
|
255
255
|
}
|
|
256
256
|
delete(t) {
|
|
257
|
-
const i = super.delete(t), a =
|
|
257
|
+
const i = super.delete(t), a = R.get(this);
|
|
258
258
|
return a.isConnected ? (a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`)) : setTimeout(() => {
|
|
259
259
|
a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`);
|
|
260
260
|
}), i;
|
|
@@ -264,14 +264,14 @@ let q = O;
|
|
|
264
264
|
if (typeof t == "function" ? e !== t || !a : !t.has(e)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
265
265
|
return i === "m" ? a : i === "a" ? a.call(e) : a ? a.value : t.get(e);
|
|
266
266
|
}
|
|
267
|
-
function
|
|
267
|
+
function Mt(e, t, i, a, r) {
|
|
268
268
|
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");
|
|
269
269
|
return t.set(e, i), i;
|
|
270
270
|
}
|
|
271
271
|
var x;
|
|
272
|
-
class
|
|
272
|
+
class xt {
|
|
273
273
|
constructor(t) {
|
|
274
|
-
x.set(this, void 0),
|
|
274
|
+
x.set(this, void 0), Mt(this, x, t);
|
|
275
275
|
for (let i = 0; i < t.length; i++) {
|
|
276
276
|
let a = t[i];
|
|
277
277
|
this[i] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
|
|
@@ -291,7 +291,7 @@ let q = O;
|
|
|
291
291
|
return this[t] == null ? null : this[t];
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
|
-
function
|
|
294
|
+
function At() {
|
|
295
295
|
const e = HTMLFormElement.prototype.checkValidity;
|
|
296
296
|
HTMLFormElement.prototype.checkValidity = i;
|
|
297
297
|
const t = HTMLFormElement.prototype.reportValidity;
|
|
@@ -311,7 +311,7 @@ let q = O;
|
|
|
311
311
|
if (u.length === 0)
|
|
312
312
|
return s;
|
|
313
313
|
const d = Array.from(s).concat(u).sort((w, b) => w.compareDocumentPosition ? w.compareDocumentPosition(b) & 2 ? 1 : -1 : 0);
|
|
314
|
-
return new
|
|
314
|
+
return new xt(d);
|
|
315
315
|
}
|
|
316
316
|
});
|
|
317
317
|
}
|
|
@@ -322,8 +322,8 @@ let q = O;
|
|
|
322
322
|
constructor(t) {
|
|
323
323
|
if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
|
|
324
324
|
throw new TypeError("Illegal constructor");
|
|
325
|
-
const i = t.getRootNode(), a = new
|
|
326
|
-
this.states = new H(t), n.set(this, t), h.set(this, a), c.set(t, this),
|
|
325
|
+
const i = t.getRootNode(), a = new gt();
|
|
326
|
+
this.states = new H(t), n.set(this, t), h.set(this, a), c.set(t, this), ht(t, this), mt(t, this), Object.seal(this), i instanceof DocumentFragment && pt(i);
|
|
327
327
|
}
|
|
328
328
|
checkValidity() {
|
|
329
329
|
const t = n.get(this);
|
|
@@ -384,10 +384,10 @@ let q = O;
|
|
|
384
384
|
const o = h.get(this), s = {};
|
|
385
385
|
for (const w in t)
|
|
386
386
|
s[w] = t[w];
|
|
387
|
-
Object.keys(s).length === 0 &&
|
|
387
|
+
Object.keys(s).length === 0 && yt(o);
|
|
388
388
|
const u = Object.assign(Object.assign({}, o), s);
|
|
389
389
|
delete u.valid;
|
|
390
|
-
const { valid: d } =
|
|
390
|
+
const { valid: d } = Et(o, u, this.form);
|
|
391
391
|
if (!d && !i)
|
|
392
392
|
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.");
|
|
393
393
|
g.set(this, d ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !d), r.toggleAttribute("internals-valid", d), r.setAttribute("aria-invalid", `${!d}`)) : C.set(r, this);
|
|
@@ -409,7 +409,7 @@ let q = O;
|
|
|
409
409
|
return v(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"));
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
-
function
|
|
412
|
+
function Ct() {
|
|
413
413
|
if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
|
|
414
414
|
return !1;
|
|
415
415
|
class e extends HTMLElement {
|
|
@@ -448,7 +448,7 @@ let q = O;
|
|
|
448
448
|
if (a.formAssociated) {
|
|
449
449
|
const o = a.prototype.connectedCallback;
|
|
450
450
|
a.prototype.connectedCallback = function() {
|
|
451
|
-
G.has(this) || (G.set(this, !0), this.hasAttribute("disabled") &&
|
|
451
|
+
G.has(this) || (G.set(this, !0), this.hasAttribute("disabled") && D(this, !0)), o != null && o.apply(this), at(this);
|
|
452
452
|
};
|
|
453
453
|
}
|
|
454
454
|
t.call(this, i, a, r);
|
|
@@ -474,26 +474,26 @@ let q = O;
|
|
|
474
474
|
const i = Element.prototype.attachShadow;
|
|
475
475
|
Element.prototype.attachShadow = t;
|
|
476
476
|
}
|
|
477
|
-
T() && typeof document < "u" && new MutationObserver(_).observe(document.documentElement, $), typeof HTMLFormElement < "u" &&
|
|
477
|
+
T() && typeof document < "u" && new MutationObserver(_).observe(document.documentElement, $), typeof HTMLFormElement < "u" && At(), (e || typeof window < "u" && !window.CustomStateSet) && W();
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
|
-
return !!customElements.polyfillWrapFlushCallback || (
|
|
480
|
+
return !!customElements.polyfillWrapFlushCallback || (Ct() ? typeof window < "u" && !window.CustomStateSet && W(HTMLElement.prototype.attachInternals) : ct(!1)), l.forceCustomStateSetPolyfill = W, l.forceElementInternalsPolyfill = ct, Object.defineProperty(l, "__esModule", { value: !0 }), l;
|
|
481
481
|
})({});
|
|
482
482
|
})();
|
|
483
|
-
const
|
|
483
|
+
const $t = "*,*:after,*:before{box-sizing:inherit}:host{display:block}*,*:before,*:after{cursor:inherit}.c-switch-wrapper{display:inline-flex;align-items:center;gap:var(--dt-spacing-b);vertical-align:top;font-family:var(--dt-font-body-l-family);cursor:pointer}.c-switch-wrapper[disabled]{cursor:not-allowed}.c-switch{--int-states-mixin-bg-color: var(--dt-color-interactive-form);--switch-bg-color--checked: var(--dt-color-interactive-brand);--switch-bg-color--disabled: var(--dt-color-disabled-01);--switch-width: 48px;--switch-height: 24px;--switch-control-size: 20px;--switch-padding: 2px;--switch-radius: var(--dt-radius-rounded-e);--switch-translation: calc(var(--switch-width) - var(--switch-control-size) - 2 * var(--switch-padding));position:relative;display:flex;width:var(--switch-width);height:var(--switch-height);flex-shrink:0;padding:var(--switch-padding);border-radius:var(--switch-radius);background-color:var(--int-states-mixin-bg-color)}.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[checked]{--int-states-mixin-bg-color: var(--dt-color-interactive-brand)}.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:has(.c-switch-input:focus-visible){box-shadow:0 0 0 2px var(--dt-color-focus-inner),0 0 0 4px var(--dt-color-focus-outer);outline:none}.c-switch-input{position:absolute;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)}.c-switch-wrapper:dir(rtl) .c-switch-control{position:absolute;left:initial;right:2px}.c-switch-control .c-pieIcon--check{vertical-align:top}.c-switch-input:checked+.c-switch-control{transform:translate(var(--switch-translation))}.c-switch-input:checked+.c-switch-control .c-pieIcon--check{color:var(--dt-color-interactive-brand)}.c-switch-input:disabled~.c-switch-control{color:var(--switch-bg-color--disabled)}.c-switch-input:disabled~.c-switch-control .c-pieIcon--check{color:var(--switch-bg-color--disabled)}.c-switch-label{color:var(--dt-color-content-default-solid)}.c-switch-description{position:absolute;display:block;height:1px;width:1px;overflow:hidden;padding:1px;white-space:nowrap}@media (prefers-reduced-motion: no-preference){.c-switch-wrapper--allow-animation .c-switch{transition:background-color .15s cubic-bezier(.4,0,.9,1) 0s}}@media (prefers-reduced-motion: no-preference){.c-switch-wrapper--allow-animation .c-switch[checked]{transition:background-color .15s cubic-bezier(.4,0,.9,1) 0s}}@media (prefers-reduced-motion: no-preference){.c-switch-wrapper--allow-animation .c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}@media (prefers-reduced-motion: no-preference){.c-switch-input:checked+.c-switch-wrapper--allow-animation .c-switch-control{transition:transform .15s cubic-bezier(.4,0,.9,1) 0s}}@media (prefers-reduced-motion: no-preference){.c-switch-input:checked+.c-switch-wrapper--allow-animation .c-switch-control .c-pieIcon--check{transition:color .15s cubic-bezier(.4,0,.9,1) 0s}}@media (prefers-reduced-motion: no-preference){.c-switch-input:disabled~.c-switch-wrapper--allow-animation .c-switch-control .c-pieIcon--check{transition:color .15s cubic-bezier(.4,0,.9,1) 0s}}.c-switch-wrapper:dir(rtl) .c-switch-input:checked+.c-switch-control{transform:translate(calc(-1 * var(--switch-translation)))}", Dt = ["leading", "trailing"], Yt = "change", M = {
|
|
484
484
|
checked: !1,
|
|
485
485
|
disabled: !1,
|
|
486
486
|
labelPlacement: "leading",
|
|
487
487
|
required: !1,
|
|
488
488
|
value: "on"
|
|
489
489
|
};
|
|
490
|
-
var Rt = Object.defineProperty,
|
|
491
|
-
for (var c = m > 1 ? void 0 : m ?
|
|
490
|
+
var Rt = Object.defineProperty, Ht = Object.getOwnPropertyDescriptor, f = (l, n, h, m) => {
|
|
491
|
+
for (var c = m > 1 ? void 0 : m ? Ht(n, h) : n, g = l.length - 1, k; g >= 0; g--)
|
|
492
492
|
(k = l[g]) && (c = (m ? k(n, h, c) : k(c)) || c);
|
|
493
493
|
return m && c && Rt(n, h, c), c;
|
|
494
494
|
};
|
|
495
|
-
const
|
|
496
|
-
let p = class extends Lt(q) {
|
|
495
|
+
const Wt = "pie-switch";
|
|
496
|
+
let p = class extends Lt(Nt(q)) {
|
|
497
497
|
constructor() {
|
|
498
498
|
super(...arguments), this.labelPlacement = M.labelPlacement, this.checked = M.checked, this.required = M.required, this.value = M.value, this.disabled = M.disabled, this._isAnimationAllowed = !1;
|
|
499
499
|
}
|
|
@@ -518,7 +518,7 @@ let p = class extends Lt(q) {
|
|
|
518
518
|
handleChange(l) {
|
|
519
519
|
const { checked: n } = l == null ? void 0 : l.currentTarget;
|
|
520
520
|
this.checked = n;
|
|
521
|
-
const h =
|
|
521
|
+
const h = Ot(l);
|
|
522
522
|
this._isAnimationAllowed || (this._isAnimationAllowed = !0), this.dispatchEvent(h), this.handleFormAssociation();
|
|
523
523
|
}
|
|
524
524
|
/**
|
|
@@ -627,14 +627,13 @@ let p = class extends Lt(q) {
|
|
|
627
627
|
</label>`;
|
|
628
628
|
}
|
|
629
629
|
};
|
|
630
|
-
p.
|
|
631
|
-
p.styles = It(_t);
|
|
630
|
+
p.styles = It($t);
|
|
632
631
|
f([
|
|
633
632
|
E({ type: String })
|
|
634
633
|
], p.prototype, "label", 2);
|
|
635
634
|
f([
|
|
636
635
|
E({ type: String }),
|
|
637
|
-
|
|
636
|
+
Pt(Wt, Dt, M.labelPlacement)
|
|
638
637
|
], p.prototype, "labelPlacement", 2);
|
|
639
638
|
f([
|
|
640
639
|
E({ type: Object })
|
|
@@ -655,20 +654,20 @@ f([
|
|
|
655
654
|
E({ type: Boolean, reflect: !0 })
|
|
656
655
|
], p.prototype, "disabled", 2);
|
|
657
656
|
f([
|
|
658
|
-
|
|
657
|
+
dt('input[type="checkbox"]')
|
|
659
658
|
], p.prototype, "input", 2);
|
|
660
659
|
f([
|
|
661
|
-
|
|
660
|
+
dt("label")
|
|
662
661
|
], p.prototype, "focusTarget", 2);
|
|
663
662
|
f([
|
|
664
663
|
St()
|
|
665
664
|
], p.prototype, "_isAnimationAllowed", 2);
|
|
666
665
|
p = f([
|
|
667
|
-
|
|
666
|
+
_t("pie-switch")
|
|
668
667
|
], p);
|
|
669
668
|
export {
|
|
670
|
-
|
|
669
|
+
Yt as ON_SWITCH_CHANGED_EVENT,
|
|
671
670
|
p as PieSwitch,
|
|
672
671
|
M as defaultProps,
|
|
673
|
-
|
|
672
|
+
Dt as labelPlacements
|
|
674
673
|
};
|
package/dist/react.d.ts
CHANGED
|
@@ -43,12 +43,6 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInpu
|
|
|
43
43
|
private input;
|
|
44
44
|
focusTarget: HTMLElement;
|
|
45
45
|
private _isAnimationAllowed;
|
|
46
|
-
static shadowRootOptions: {
|
|
47
|
-
delegatesFocus: boolean;
|
|
48
|
-
mode: ShadowRootMode;
|
|
49
|
-
serializable?: boolean;
|
|
50
|
-
slotAssignment?: SlotAssignmentMode;
|
|
51
|
-
};
|
|
52
46
|
protected firstUpdated(): void;
|
|
53
47
|
protected updated(): void;
|
|
54
48
|
static styles: CSSResult;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justeattakeaway/pie-switch",
|
|
3
3
|
"description": "PIE Design System Switch built using Web Components",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/justeattakeaway/pie",
|
|
@@ -19,7 +19,12 @@
|
|
|
19
19
|
"**/*.d.ts"
|
|
20
20
|
],
|
|
21
21
|
"pieMetadata": {
|
|
22
|
-
"componentStatus": "stable"
|
|
22
|
+
"componentStatus": "stable",
|
|
23
|
+
"replaces": {
|
|
24
|
+
"snacks": [
|
|
25
|
+
"Switch"
|
|
26
|
+
]
|
|
27
|
+
}
|
|
23
28
|
},
|
|
24
29
|
"scripts": {
|
|
25
30
|
"build": "run -T vite build",
|
|
@@ -40,14 +45,14 @@
|
|
|
40
45
|
"devDependencies": {
|
|
41
46
|
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
42
47
|
"@justeattakeaway/pie-components-config": "0.21.0",
|
|
43
|
-
"@justeattakeaway/pie-css": "0.
|
|
48
|
+
"@justeattakeaway/pie-css": "0.23.0",
|
|
44
49
|
"@justeattakeaway/pie-monorepo-utils": "0.7.0",
|
|
45
50
|
"@justeattakeaway/pie-wrapper-react": "0.14.3",
|
|
46
51
|
"cem-plugin-module-file-extensions": "0.0.5"
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@justeattakeaway/pie-icons-webc": "1.
|
|
50
|
-
"@justeattakeaway/pie-webc-core": "
|
|
54
|
+
"@justeattakeaway/pie-icons-webc": "1.15.1",
|
|
55
|
+
"@justeattakeaway/pie-webc-core": "3.0.0",
|
|
51
56
|
"element-internals-polyfill": "1.3.11"
|
|
52
57
|
},
|
|
53
58
|
"volta": {
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
html, unsafeCSS, nothing,
|
|
3
|
-
LitElement,
|
|
4
3
|
} from 'lit';
|
|
5
4
|
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
6
5
|
import { property, query, state } from 'lit/decorators.js';
|
|
@@ -11,6 +10,7 @@ import 'element-internals-polyfill';
|
|
|
11
10
|
import {
|
|
12
11
|
validPropertyValues,
|
|
13
12
|
FormControlMixin,
|
|
13
|
+
DelegatesFocusMixin,
|
|
14
14
|
wrapNativeEvent,
|
|
15
15
|
safeCustomElement,
|
|
16
16
|
type PIEInputElement,
|
|
@@ -30,7 +30,7 @@ const componentSelector = 'pie-switch';
|
|
|
30
30
|
* @event {CustomEvent} change - when the switch checked state is changed.
|
|
31
31
|
*/
|
|
32
32
|
@safeCustomElement('pie-switch')
|
|
33
|
-
export class PieSwitch extends FormControlMixin(PieElement) implements SwitchProps, PIEInputElement {
|
|
33
|
+
export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement)) implements SwitchProps, PIEInputElement {
|
|
34
34
|
@property({ type: String })
|
|
35
35
|
public label: SwitchProps['label'];
|
|
36
36
|
|
|
@@ -65,8 +65,6 @@ export class PieSwitch extends FormControlMixin(PieElement) implements SwitchPro
|
|
|
65
65
|
@state()
|
|
66
66
|
private _isAnimationAllowed = false;
|
|
67
67
|
|
|
68
|
-
static shadowRootOptions = { ...LitElement.shadowRootOptions, delegatesFocus: true };
|
|
69
|
-
|
|
70
68
|
protected firstUpdated (): void {
|
|
71
69
|
this.handleFormAssociation();
|
|
72
70
|
// This ensures that invalid events triggered by checkValidity() are propagated to the custom element
|
package/src/switch.scss
CHANGED