@justeattakeaway/pie-switch 2.5.0 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -355,6 +355,10 @@
355
355
  }
356
356
  ],
357
357
  "mixins": [
358
+ {
359
+ "name": "AssociatedLabelMixin",
360
+ "package": "@justeattakeaway/pie-webc-core"
361
+ },
358
362
  {
359
363
  "name": "FormControlMixin",
360
364
  "package": "@justeattakeaway/pie-webc-core"
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import { AssociatedLabelInterface } from '@justeattakeaway/pie-webc-core';
1
2
  import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
3
  import { CSSResult } from 'lit';
3
4
  import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
5
  import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
5
6
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
6
7
  import { PIEInputElement } from '@justeattakeaway/pie-webc-core';
8
+ import { PropertyValues } from 'lit';
7
9
  import { TemplateResult } from 'lit-html';
8
10
 
9
11
  declare type AriaProps = {
@@ -43,7 +45,7 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
43
45
  focusTarget: HTMLElement;
44
46
  private _abortController;
45
47
  private _isAnimationAllowed;
46
- protected firstUpdated(): void;
48
+ protected firstUpdated(changedProperties: PropertyValues): void;
47
49
  connectedCallback(): void;
48
50
  disconnectedCallback(): void;
49
51
  protected updated(): void;
@@ -95,7 +97,7 @@ export declare class PieSwitch extends PieSwitch_base implements SwitchProps, PI
95
97
  render(): TemplateResult;
96
98
  }
97
99
 
98
- declare const PieSwitch_base: GenericConstructor<FormControlInterface> & typeof PieElement;
100
+ declare const PieSwitch_base: GenericConstructor<AssociatedLabelInterface> & GenericConstructor<FormControlInterface> & typeof PieElement;
99
101
 
100
102
  export declare interface SwitchProps {
101
103
  /**
package/dist/index.js CHANGED
@@ -1,23 +1,23 @@
1
- import { LitElement as St, nothing as N, html as z, unsafeCSS as Vt } from "lit";
2
- import { unsafeStatic as Tt, html as Lt } from "lit/static-html.js";
3
- import { property as y, query as q, state as Nt } from "lit/decorators.js";
4
- import { classMap as Pt } from "lit/directives/class-map.js";
5
- import { ifDefined as Ot } from "lit/directives/if-defined.js";
6
- import { live as _t } from "lit/directives/live.js";
7
- import { FormControlMixin as $t, DelegatesFocusMixin as Dt, wrapNativeEvent as Rt, validPropertyValues as Ht, safeCustomElement as Wt } from "@justeattakeaway/pie-webc-core";
1
+ import { LitElement as Se, nothing as P, html as B, unsafeCSS as Ve } from "lit";
2
+ import { unsafeStatic as Te, html as Le } from "lit/static-html.js";
3
+ import { property as y, query as U, state as Ne } from "lit/decorators.js";
4
+ import { classMap as Pe } from "lit/directives/class-map.js";
5
+ import { ifDefined as _e } from "lit/directives/if-defined.js";
6
+ import { live as Oe } from "lit/directives/live.js";
7
+ import { AssociatedLabelMixin as $e, FormControlMixin as De, DelegatesFocusMixin as Re, wrapNativeEvent as He, validPropertyValues as We, safeCustomElement as ze } from "@justeattakeaway/pie-webc-core";
8
8
  import "@justeattakeaway/pie-icons-webc/dist/IconCheck.js";
9
- const P = class P extends St {
9
+ const _ = class _ extends Se {
10
10
  willUpdate() {
11
- this.getAttribute("v") || this.setAttribute("v", P.v);
11
+ this.getAttribute("v") || this.setAttribute("v", _.v);
12
12
  }
13
13
  };
14
- P.v = "2.5.0";
15
- let B = P;
16
- var ht = {}, ut;
17
- function zt() {
18
- return ut || (ut = 1, (function() {
14
+ _.v = "2.5.2";
15
+ let q = _;
16
+ var he = {}, ue;
17
+ function Be() {
18
+ return ue || (ue = 1, (function() {
19
19
  (function(n) {
20
- const l = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), x = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), U = /* @__PURE__ */ new WeakMap(), A = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), I = {
20
+ const l = /* @__PURE__ */ new WeakMap(), d = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap(), E = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new WeakMap(), b = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), M = /* @__PURE__ */ new WeakMap(), j = /* @__PURE__ */ new WeakMap(), K = /* @__PURE__ */ new WeakMap(), G = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), I = /* @__PURE__ */ new WeakMap(), S = {
21
21
  ariaAtomic: "aria-atomic",
22
22
  ariaAutoComplete: "aria-autocomplete",
23
23
  ariaBusy: "aria-busy",
@@ -60,253 +60,253 @@ function zt() {
60
60
  ariaValueNow: "aria-valuenow",
61
61
  ariaValueText: "aria-valuetext",
62
62
  role: "role"
63
- }, pt = (e, t) => {
64
- for (let i in I) {
65
- t[i] = null;
63
+ }, pe = (t, e) => {
64
+ for (let i in S) {
65
+ e[i] = null;
66
66
  let a = null;
67
- const r = I[i];
68
- Object.defineProperty(t, i, {
67
+ const r = S[i];
68
+ Object.defineProperty(e, i, {
69
69
  get() {
70
70
  return a;
71
71
  },
72
72
  set(o) {
73
- a = o, e.isConnected ? e.setAttribute(r, o) : A.set(e, t);
73
+ a = o, t.isConnected ? t.setAttribute(r, o) : M.set(t, e);
74
74
  }
75
75
  });
76
76
  }
77
77
  };
78
- function Q(e) {
79
- const t = c.get(e), { form: i } = t;
80
- it(e, i, t), et(e, t.labels);
78
+ function Q(t) {
79
+ const e = c.get(t), { form: i } = e;
80
+ ie(t, i, e), te(t, e.labels);
81
81
  }
82
- const X = (e, t = !1) => {
83
- const i = document.createTreeWalker(e, NodeFilter.SHOW_ELEMENT, {
82
+ const X = (t, e = !1) => {
83
+ const i = document.createTreeWalker(t, NodeFilter.SHOW_ELEMENT, {
84
84
  acceptNode(o) {
85
85
  return c.has(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
86
86
  }
87
87
  });
88
88
  let a = i.nextNode();
89
- const r = !t || e.disabled;
89
+ const r = !e || t.disabled;
90
90
  for (; a; )
91
- a.formDisabledCallback && r && $(a, e.disabled), a = i.nextNode();
92
- }, Y = { attributes: !0, attributeFilter: ["disabled", "name"] }, S = L() ? new MutationObserver((e) => {
93
- for (const t of e) {
94
- const i = t.target;
95
- if (t.attributeName === "disabled" && (i.constructor.formAssociated ? $(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && X(i)), t.attributeName === "name" && i.constructor.formAssociated) {
96
- const a = c.get(i), r = U.get(i);
91
+ a.formDisabledCallback && r && D(a, t.disabled), a = i.nextNode();
92
+ }, Y = { attributes: !0, attributeFilter: ["disabled", "name"] }, V = N() ? new MutationObserver((t) => {
93
+ for (const e of t) {
94
+ const i = e.target;
95
+ if (e.attributeName === "disabled" && (i.constructor.formAssociated ? D(i, i.hasAttribute("disabled")) : i.localName === "fieldset" && X(i)), e.attributeName === "name" && i.constructor.formAssociated) {
96
+ const a = c.get(i), r = F.get(i);
97
97
  a.setFormValue(r);
98
98
  }
99
99
  }
100
100
  }) : {};
101
- function O(e) {
102
- e.forEach((t) => {
103
- const { addedNodes: i, removedNodes: a } = t, r = Array.from(i), o = Array.from(a);
101
+ function O(t) {
102
+ t.forEach((e) => {
103
+ const { addedNodes: i, removedNodes: a } = e, r = Array.from(i), o = Array.from(a);
104
104
  r.forEach((s) => {
105
105
  var m;
106
- if (c.has(s) && s.constructor.formAssociated && Q(s), A.has(s)) {
107
- const h = A.get(s);
108
- Object.keys(I).filter((v) => h[v] !== null).forEach((v) => {
109
- s.setAttribute(I[v], h[v]);
110
- }), A.delete(s);
106
+ if (c.has(s) && s.constructor.formAssociated && Q(s), M.has(s)) {
107
+ const h = M.get(s);
108
+ Object.keys(S).filter((v) => h[v] !== null).forEach((v) => {
109
+ s.setAttribute(S[v], h[v]);
110
+ }), M.delete(s);
111
111
  }
112
- if (F.has(s)) {
113
- const h = F.get(s);
114
- s.setAttribute("internals-valid", h.validity.valid.toString()), s.setAttribute("internals-invalid", (!h.validity.valid).toString()), s.setAttribute("aria-invalid", (!h.validity.valid).toString()), F.delete(s);
112
+ if (I.has(s)) {
113
+ const h = I.get(s);
114
+ s.setAttribute("internals-valid", h.validity.valid.toString()), s.setAttribute("internals-invalid", (!h.validity.valid).toString()), s.setAttribute("aria-invalid", (!h.validity.valid).toString()), I.delete(s);
115
115
  }
116
116
  if (s.localName === "form") {
117
117
  const h = b.get(s), g = document.createTreeWalker(s, NodeFilter.SHOW_ELEMENT, {
118
- acceptNode(W) {
119
- return c.has(W) && W.constructor.formAssociated && !(h && h.has(W)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
118
+ acceptNode(z) {
119
+ return c.has(z) && z.constructor.formAssociated && !(h && h.has(z)) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
120
120
  }
121
121
  });
122
122
  let v = g.nextNode();
123
123
  for (; v; )
124
124
  Q(v), v = g.nextNode();
125
125
  }
126
- s.localName === "fieldset" && ((m = S.observe) === null || m === void 0 || m.call(S, s, Y), X(s, !0));
126
+ s.localName === "fieldset" && ((m = V.observe) === null || m === void 0 || m.call(V, s, Y), X(s, !0));
127
127
  }), o.forEach((s) => {
128
128
  const m = c.get(s);
129
- m && u.get(m) && Z(m), x.has(s) && x.get(s).disconnect();
129
+ m && u.get(m) && Z(m), C.has(s) && C.get(s).disconnect();
130
130
  });
131
131
  });
132
132
  }
133
- function mt(e) {
134
- e.forEach((t) => {
135
- const { removedNodes: i } = t;
133
+ function me(t) {
134
+ t.forEach((e) => {
135
+ const { removedNodes: i } = e;
136
136
  i.forEach((a) => {
137
- const r = G.get(t.target);
138
- c.has(a) && rt(a), r.disconnect();
137
+ const r = G.get(e.target);
138
+ c.has(a) && re(a), r.disconnect();
139
139
  });
140
140
  });
141
141
  }
142
- const ft = (e) => {
143
- var t, i;
144
- const a = new MutationObserver(mt);
145
- !((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 }), G.set(e, a);
142
+ const fe = (t) => {
143
+ var e, i;
144
+ const a = new MutationObserver(me);
145
+ !((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 }), G.set(t, a);
146
146
  };
147
- L() && new MutationObserver(O);
148
- const _ = {
147
+ N() && new MutationObserver(O);
148
+ const $ = {
149
149
  childList: !0,
150
150
  subtree: !0
151
- }, $ = (e, t) => {
152
- e.toggleAttribute("internals-disabled", t), t ? e.setAttribute("aria-disabled", "true") : e.removeAttribute("aria-disabled"), e.formDisabledCallback && e.formDisabledCallback.apply(e, [t]);
153
- }, Z = (e) => {
154
- u.get(e).forEach((i) => {
151
+ }, D = (t, e) => {
152
+ t.toggleAttribute("internals-disabled", e), e ? t.setAttribute("aria-disabled", "true") : t.removeAttribute("aria-disabled"), t.formDisabledCallback && t.formDisabledCallback.apply(t, [e]);
153
+ }, Z = (t) => {
154
+ u.get(t).forEach((i) => {
155
155
  i.remove();
156
- }), u.set(e, []);
157
- }, tt = (e, t) => {
156
+ }), u.set(t, []);
157
+ }, ee = (t, e) => {
158
158
  const i = document.createElement("input");
159
- return i.type = "hidden", i.name = e.getAttribute("name"), e.after(i), u.get(t).push(i), i;
160
- }, bt = (e, t) => {
159
+ return i.type = "hidden", i.name = t.getAttribute("name"), t.after(i), u.get(e).push(i), i;
160
+ }, be = (t, e) => {
161
161
  var i;
162
- u.set(t, []), (i = S.observe) === null || i === void 0 || i.call(S, e, Y);
163
- }, et = (e, t) => {
164
- if (t.length) {
165
- Array.from(t).forEach((a) => a.addEventListener("click", e.click.bind(e)));
166
- let i = t[0].id;
167
- t[0].id || (i = `${t[0].htmlFor}_Label`, t[0].id = i), e.setAttribute("aria-labelledby", i);
168
- }
169
- }, V = (e) => {
170
- const t = Array.from(e.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = b.get(e) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => c.get(o).validity.valid), r = [...t, ...a].includes(!1);
171
- e.toggleAttribute("internals-invalid", r), e.toggleAttribute("internals-valid", !r);
172
- }, vt = (e) => {
173
- V(T(e.target));
174
- }, wt = (e) => {
175
- V(T(e.target));
176
- }, gt = (e) => {
177
- 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(",");
178
- e.addEventListener("click", (i) => {
179
- if (i.target.closest(t)) {
180
- const r = b.get(e);
181
- if (e.noValidate)
162
+ u.set(e, []), (i = V.observe) === null || i === void 0 || i.call(V, t, Y);
163
+ }, te = (t, e) => {
164
+ if (e.length) {
165
+ Array.from(e).forEach((a) => a.addEventListener("click", t.click.bind(t)));
166
+ let i = e[0].id;
167
+ e[0].id || (i = `${e[0].htmlFor}_Label`, e[0].id = i), t.setAttribute("aria-labelledby", i);
168
+ }
169
+ }, T = (t) => {
170
+ const e = Array.from(t.elements).filter((o) => !o.tagName.includes("-") && o.validity).map((o) => o.validity.valid), i = b.get(t) || [], a = Array.from(i).filter((o) => o.isConnected).map((o) => c.get(o).validity.valid), r = [...e, ...a].includes(!1);
171
+ t.toggleAttribute("internals-invalid", r), t.toggleAttribute("internals-valid", !r);
172
+ }, ve = (t) => {
173
+ T(L(t.target));
174
+ }, we = (t) => {
175
+ T(L(t.target));
176
+ }, ge = (t) => {
177
+ 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(",");
178
+ t.addEventListener("click", (i) => {
179
+ if (i.target.closest(e)) {
180
+ const r = b.get(t);
181
+ if (t.noValidate)
182
182
  return;
183
183
  r.size && Array.from(r).reverse().map((m) => c.get(m).reportValidity()).includes(!1) && i.preventDefault();
184
184
  }
185
185
  });
186
- }, yt = (e) => {
187
- const t = b.get(e.target);
188
- t && t.size && t.forEach((i) => {
186
+ }, ye = (t) => {
187
+ const e = b.get(t.target);
188
+ e && e.size && e.forEach((i) => {
189
189
  i.constructor.formAssociated && i.formResetCallback && i.formResetCallback.apply(i);
190
190
  });
191
- }, it = (e, t, i) => {
192
- if (t) {
193
- const a = b.get(t);
191
+ }, ie = (t, e, i) => {
192
+ if (e) {
193
+ const a = b.get(e);
194
194
  if (a)
195
- a.add(e);
195
+ a.add(t);
196
196
  else {
197
197
  const r = /* @__PURE__ */ new Set();
198
- r.add(e), b.set(t, r), gt(t), t.addEventListener("reset", yt), t.addEventListener("input", vt), t.addEventListener("change", wt);
198
+ r.add(t), b.set(e, r), ge(e), e.addEventListener("reset", ye), e.addEventListener("input", ve), e.addEventListener("change", we);
199
199
  }
200
- E.set(t, { ref: e, internals: i }), e.constructor.formAssociated && e.formAssociatedCallback && setTimeout(() => {
201
- e.formAssociatedCallback.apply(e, [t]);
202
- }, 0), V(t);
203
- }
204
- }, T = (e) => {
205
- let t = e.parentNode;
206
- return t && t.tagName !== "FORM" && (t = T(t)), t;
207
- }, w = (e, t, i = DOMException) => {
208
- if (!e.constructor.formAssociated)
209
- throw new i(t);
210
- }, at = (e, t, i) => {
211
- const a = b.get(e);
200
+ E.set(e, { ref: t, internals: i }), t.constructor.formAssociated && t.formAssociatedCallback && setTimeout(() => {
201
+ t.formAssociatedCallback.apply(t, [e]);
202
+ }, 0), T(e);
203
+ }
204
+ }, L = (t) => {
205
+ let e = t.parentNode;
206
+ return e && e.tagName !== "FORM" && (e = L(e)), e;
207
+ }, w = (t, e, i = DOMException) => {
208
+ if (!t.constructor.formAssociated)
209
+ throw new i(e);
210
+ }, ae = (t, e, i) => {
211
+ const a = b.get(t);
212
212
  return a && a.size && a.forEach((r) => {
213
- c.get(r)[i]() || (t = !1);
214
- }), t;
215
- }, rt = (e) => {
216
- if (e.constructor.formAssociated) {
217
- const t = c.get(e), { labels: i, form: a } = t;
218
- et(e, i), it(e, a, t);
213
+ c.get(r)[i]() || (e = !1);
214
+ }), e;
215
+ }, re = (t) => {
216
+ if (t.constructor.formAssociated) {
217
+ const e = c.get(t), { labels: i, form: a } = e;
218
+ te(t, i), ie(t, a, e);
219
219
  }
220
220
  };
221
- function L() {
221
+ function N() {
222
222
  return typeof MutationObserver < "u";
223
223
  }
224
- class kt {
224
+ class ke {
225
225
  constructor() {
226
226
  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);
227
227
  }
228
228
  }
229
- 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), Mt = (e, t, i) => (e.valid = xt(t), Object.keys(t).forEach((a) => e[a] = t[a]), i && V(i), e), xt = (e) => {
230
- let t = !0;
231
- for (let i in e)
232
- i !== "valid" && e[i] !== !1 && (t = !1);
233
- return t;
234
- }, D = /* @__PURE__ */ new WeakMap();
235
- function ot(e, t) {
236
- e.toggleAttribute(t, !0), e.part && e.part.add(t);
229
+ 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), Me = (t, e, i) => (t.valid = xe(e), Object.keys(e).forEach((a) => t[a] = e[a]), i && T(i), t), xe = (t) => {
230
+ let e = !0;
231
+ for (let i in t)
232
+ i !== "valid" && t[i] !== !1 && (e = !1);
233
+ return e;
234
+ }, R = /* @__PURE__ */ new WeakMap();
235
+ function oe(t, e) {
236
+ t.toggleAttribute(e, !0), t.part && t.part.add(e);
237
237
  }
238
- class R extends Set {
238
+ class H extends Set {
239
239
  static get isPolyfilled() {
240
240
  return !0;
241
241
  }
242
- constructor(t) {
243
- if (super(), !t || !t.tagName || t.tagName.indexOf("-") === -1)
242
+ constructor(e) {
243
+ if (super(), !e || !e.tagName || e.tagName.indexOf("-") === -1)
244
244
  throw new TypeError("Illegal constructor");
245
- D.set(this, t);
246
- }
247
- add(t) {
248
- if (!/^--/.test(t) || typeof t != "string")
249
- throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${t} must start with '--'.`);
250
- const i = super.add(t), a = D.get(this), r = `state${t}`;
251
- return a.isConnected ? ot(a, r) : setTimeout(() => {
252
- ot(a, r);
245
+ R.set(this, e);
246
+ }
247
+ add(e) {
248
+ if (!/^--/.test(e) || typeof e != "string")
249
+ throw new DOMException(`Failed to execute 'add' on 'CustomStateSet': The specified value ${e} must start with '--'.`);
250
+ const i = super.add(e), a = R.get(this), r = `state${e}`;
251
+ return a.isConnected ? oe(a, r) : setTimeout(() => {
252
+ oe(a, r);
253
253
  }), i;
254
254
  }
255
255
  clear() {
256
- for (let [t] of this.entries())
257
- this.delete(t);
256
+ for (let [e] of this.entries())
257
+ this.delete(e);
258
258
  super.clear();
259
259
  }
260
- delete(t) {
261
- const i = super.delete(t), a = D.get(this);
262
- return a.isConnected ? (a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`)) : setTimeout(() => {
263
- a.toggleAttribute(`state${t}`, !1), a.part && a.part.remove(`state${t}`);
260
+ delete(e) {
261
+ const i = super.delete(e), a = R.get(this);
262
+ return a.isConnected ? (a.toggleAttribute(`state${e}`, !1), a.part && a.part.remove(`state${e}`)) : setTimeout(() => {
263
+ a.toggleAttribute(`state${e}`, !1), a.part && a.part.remove(`state${e}`);
264
264
  }), i;
265
265
  }
266
266
  }
267
- function st(e, t, i, a) {
268
- 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");
269
- return i === "m" ? a : i === "a" ? a.call(e) : a ? a.value : t.get(e);
267
+ function se(t, e, i, a) {
268
+ 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");
269
+ return i === "m" ? a : i === "a" ? a.call(t) : a ? a.value : e.get(t);
270
270
  }
271
- function Ct(e, t, i, a, r) {
272
- 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");
273
- return t.set(e, i), i;
271
+ function Ce(t, e, i, a, r) {
272
+ 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");
273
+ return e.set(t, i), i;
274
274
  }
275
- var C;
276
- class At {
277
- constructor(t) {
278
- C.set(this, void 0), Ct(this, C, t);
279
- for (let i = 0; i < t.length; i++) {
280
- let a = t[i];
275
+ var A;
276
+ class Ae {
277
+ constructor(e) {
278
+ A.set(this, void 0), Ce(this, A, e);
279
+ for (let i = 0; i < e.length; i++) {
280
+ let a = e[i];
281
281
  this[i] = a, a.hasAttribute("name") && (this[a.getAttribute("name")] = a);
282
282
  }
283
283
  Object.freeze(this);
284
284
  }
285
285
  get length() {
286
- return st(this, C, "f").length;
286
+ return se(this, A, "f").length;
287
287
  }
288
- [(C = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
289
- return st(this, C, "f")[Symbol.iterator]();
288
+ [(A = /* @__PURE__ */ new WeakMap(), Symbol.iterator)]() {
289
+ return se(this, A, "f")[Symbol.iterator]();
290
290
  }
291
- item(t) {
292
- return this[t] == null ? null : this[t];
291
+ item(e) {
292
+ return this[e] == null ? null : this[e];
293
293
  }
294
- namedItem(t) {
295
- return this[t] == null ? null : this[t];
294
+ namedItem(e) {
295
+ return this[e] == null ? null : this[e];
296
296
  }
297
297
  }
298
- function Ft() {
299
- const e = HTMLFormElement.prototype.checkValidity;
298
+ function Fe() {
299
+ const t = HTMLFormElement.prototype.checkValidity;
300
300
  HTMLFormElement.prototype.checkValidity = i;
301
- const t = HTMLFormElement.prototype.reportValidity;
301
+ const e = HTMLFormElement.prototype.reportValidity;
302
302
  HTMLFormElement.prototype.reportValidity = a;
303
303
  function i(...o) {
304
- let s = e.apply(this, o);
305
- return at(this, s, "checkValidity");
304
+ let s = t.apply(this, o);
305
+ return ae(this, s, "checkValidity");
306
306
  }
307
307
  function a(...o) {
308
- let s = t.apply(this, o);
309
- return at(this, s, "reportValidity");
308
+ let s = e.apply(this, o);
309
+ return ae(this, s, "reportValidity");
310
310
  }
311
311
  const { get: r } = Object.getOwnPropertyDescriptor(HTMLFormElement.prototype, "elements");
312
312
  Object.defineProperty(HTMLFormElement.prototype, "elements", {
@@ -315,23 +315,23 @@ function zt() {
315
315
  if (m.length === 0)
316
316
  return s;
317
317
  const h = Array.from(s).concat(m).sort((g, v) => g.compareDocumentPosition ? g.compareDocumentPosition(v) & 2 ? 1 : -1 : 0);
318
- return new At(h);
318
+ return new Ae(h);
319
319
  }
320
320
  });
321
321
  }
322
- class nt {
322
+ class ne {
323
323
  static get isPolyfilled() {
324
324
  return !0;
325
325
  }
326
- constructor(t) {
327
- if (!t || !t.tagName || t.tagName.indexOf("-") === -1)
326
+ constructor(e) {
327
+ if (!e || !e.tagName || e.tagName.indexOf("-") === -1)
328
328
  throw new TypeError("Illegal constructor");
329
- const i = t.getRootNode(), a = new kt();
330
- this.states = new R(t), l.set(this, t), d.set(this, a), c.set(t, this), pt(t, this), bt(t, this), Object.seal(this), i instanceof DocumentFragment && ft(i);
329
+ const i = e.getRootNode(), a = new ke();
330
+ this.states = new H(e), l.set(this, e), d.set(this, a), c.set(e, this), pe(e, this), be(e, this), Object.seal(this), i instanceof DocumentFragment && fe(i);
331
331
  }
332
332
  checkValidity() {
333
- const t = l.get(this);
334
- if (w(t, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
333
+ const e = l.get(this);
334
+ if (w(e, "Failed to execute 'checkValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
335
335
  return !0;
336
336
  const i = d.get(this);
337
337
  if (!i.valid) {
@@ -340,90 +340,90 @@ function zt() {
340
340
  cancelable: !0,
341
341
  composed: !1
342
342
  });
343
- t.dispatchEvent(a);
343
+ e.dispatchEvent(a);
344
344
  }
345
345
  return i.valid;
346
346
  }
347
347
  get form() {
348
- const t = l.get(this);
349
- w(t, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
348
+ const e = l.get(this);
349
+ w(e, "Failed to read the 'form' property from 'ElementInternals': The target element is not a form-associated custom element.");
350
350
  let i;
351
- return t.constructor.formAssociated === !0 && (i = T(t)), i;
351
+ return e.constructor.formAssociated === !0 && (i = L(e)), i;
352
352
  }
353
353
  get labels() {
354
- const t = l.get(this);
355
- w(t, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
356
- const i = t.getAttribute("id"), a = t.getRootNode();
354
+ const e = l.get(this);
355
+ w(e, "Failed to read the 'labels' property from 'ElementInternals': The target element is not a form-associated custom element.");
356
+ const i = e.getAttribute("id"), a = e.getRootNode();
357
357
  return a && i ? a.querySelectorAll(`[for="${i}"]`) : [];
358
358
  }
359
359
  reportValidity() {
360
- const t = l.get(this);
361
- if (w(t, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
360
+ const e = l.get(this);
361
+ if (w(e, "Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !this.willValidate)
362
362
  return !0;
363
363
  const i = this.checkValidity(), a = K.get(this);
364
- if (a && !t.constructor.formAssociated)
364
+ if (a && !e.constructor.formAssociated)
365
365
  throw new DOMException("Failed to execute 'reportValidity' on 'ElementInternals': The target element is not a form-associated custom element.");
366
- return !i && a && (t.focus(), a.focus()), i;
366
+ return !i && a && (e.focus(), a.focus()), i;
367
367
  }
368
- setFormValue(t) {
368
+ setFormValue(e) {
369
369
  const i = l.get(this);
370
- if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), Z(this), t != null && !(t instanceof FormData)) {
370
+ if (w(i, "Failed to execute 'setFormValue' on 'ElementInternals': The target element is not a form-associated custom element."), Z(this), e != null && !(e instanceof FormData)) {
371
371
  if (i.getAttribute("name")) {
372
- const a = tt(i, this);
373
- a.value = t;
372
+ const a = ee(i, this);
373
+ a.value = e;
374
374
  }
375
- } else t != null && t instanceof FormData && Array.from(t).reverse().forEach(([a, r]) => {
375
+ } else e != null && e instanceof FormData && Array.from(e).reverse().forEach(([a, r]) => {
376
376
  if (typeof r == "string") {
377
- const o = tt(i, this);
377
+ const o = ee(i, this);
378
378
  o.name = a, o.value = r;
379
379
  }
380
380
  });
381
- U.set(i, t);
381
+ F.set(i, e);
382
382
  }
383
- setValidity(t, i, a) {
383
+ setValidity(e, i, a) {
384
384
  const r = l.get(this);
385
- if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !t)
385
+ if (w(r, "Failed to execute 'setValidity' on 'ElementInternals': The target element is not a form-associated custom element."), !e)
386
386
  throw new TypeError("Failed to execute 'setValidity' on 'ElementInternals': 1 argument required, but only 0 present.");
387
387
  K.set(this, a);
388
388
  const o = d.get(this), s = {};
389
- for (const g in t)
390
- s[g] = t[g];
391
- Object.keys(s).length === 0 && Et(o);
389
+ for (const g in e)
390
+ s[g] = e[g];
391
+ Object.keys(s).length === 0 && Ee(o);
392
392
  const m = Object.assign(Object.assign({}, o), s);
393
393
  delete m.valid;
394
- const { valid: h } = Mt(o, m, this.form);
394
+ const { valid: h } = Me(o, m, this.form);
395
395
  if (!h && !i)
396
396
  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.");
397
- k.set(this, h ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !h), r.toggleAttribute("internals-valid", h), r.setAttribute("aria-invalid", `${!h}`)) : F.set(r, this);
397
+ k.set(this, h ? "" : i), r.isConnected ? (r.toggleAttribute("internals-invalid", !h), r.toggleAttribute("internals-valid", h), r.setAttribute("aria-invalid", `${!h}`)) : I.set(r, this);
398
398
  }
399
399
  get shadowRoot() {
400
- const t = l.get(this), i = j.get(t);
400
+ const e = l.get(this), i = j.get(e);
401
401
  return i || null;
402
402
  }
403
403
  get validationMessage() {
404
- const t = l.get(this);
405
- return w(t, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), k.get(this);
404
+ const e = l.get(this);
405
+ return w(e, "Failed to read the 'validationMessage' property from 'ElementInternals': The target element is not a form-associated custom element."), k.get(this);
406
406
  }
407
407
  get validity() {
408
- const t = l.get(this);
409
- return w(t, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), d.get(this);
408
+ const e = l.get(this);
409
+ return w(e, "Failed to read the 'validity' property from 'ElementInternals': The target element is not a form-associated custom element."), d.get(this);
410
410
  }
411
411
  get willValidate() {
412
- const t = l.get(this);
413
- 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"));
412
+ const e = l.get(this);
413
+ 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"));
414
414
  }
415
415
  }
416
- function It() {
416
+ function Ie() {
417
417
  if (typeof window > "u" || !window.ElementInternals || !HTMLElement.prototype.attachInternals)
418
418
  return !1;
419
- class e extends HTMLElement {
419
+ class t extends HTMLElement {
420
420
  constructor() {
421
421
  super(), this.internals = this.attachInternals();
422
422
  }
423
423
  }
424
- const t = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`;
425
- customElements.define(t, e);
426
- const i = new e();
424
+ const e = `element-internals-feature-detection-${Math.random().toString(36).replace(/[^a-z]+/g, "")}`;
425
+ customElements.define(e, t);
426
+ const i = new t();
427
427
  return [
428
428
  "shadowRoot",
429
429
  "form",
@@ -437,25 +437,25 @@ function zt() {
437
437
  "reportValidity"
438
438
  ].every((a) => a in i.internals);
439
439
  }
440
- let lt = !1, ct = !1;
441
- function H(e) {
442
- ct || (ct = !0, window.CustomStateSet = R, e && (HTMLElement.prototype.attachInternals = function(...t) {
443
- const i = e.call(this, t);
444
- return i.states = new R(this), i;
440
+ let le = !1, ce = !1;
441
+ function W(t) {
442
+ ce || (ce = !0, window.CustomStateSet = H, t && (HTMLElement.prototype.attachInternals = function(...e) {
443
+ const i = t.call(this, e);
444
+ return i.states = new H(this), i;
445
445
  }));
446
446
  }
447
- function dt(e = !0) {
448
- if (!lt) {
449
- if (lt = !0, typeof window < "u" && (window.ElementInternals = nt), typeof CustomElementRegistry < "u") {
450
- const t = CustomElementRegistry.prototype.define;
447
+ function de(t = !0) {
448
+ if (!le) {
449
+ if (le = !0, typeof window < "u" && (window.ElementInternals = ne), typeof CustomElementRegistry < "u") {
450
+ const e = CustomElementRegistry.prototype.define;
451
451
  CustomElementRegistry.prototype.define = function(i, a, r) {
452
452
  if (a.formAssociated) {
453
453
  const o = a.prototype.connectedCallback;
454
454
  a.prototype.connectedCallback = function() {
455
- J.has(this) || (J.set(this, !0), this.hasAttribute("disabled") && $(this, !0)), o != null && o.apply(this), rt(this);
455
+ J.has(this) || (J.set(this, !0), this.hasAttribute("disabled") && D(this, !0)), o != null && o.apply(this), re(this);
456
456
  };
457
457
  }
458
- t.call(this, i, a, r);
458
+ e.call(this, i, a, r);
459
459
  };
460
460
  }
461
461
  if (typeof HTMLElement < "u" && (HTMLElement.prototype.attachInternals = function() {
@@ -465,28 +465,28 @@ function zt() {
465
465
  } else return {};
466
466
  if (c.has(this))
467
467
  throw new DOMException("DOMException: Failed to execute 'attachInternals' on 'HTMLElement': ElementInternals for the specified element was already attached.");
468
- return new nt(this);
468
+ return new ne(this);
469
469
  }), typeof Element < "u") {
470
- let t = function(...a) {
470
+ let e = function(...a) {
471
471
  const r = i.apply(this, a);
472
- if (j.set(this, r), L()) {
472
+ if (j.set(this, r), N()) {
473
473
  const o = new MutationObserver(O);
474
- window.ShadyDOM ? o.observe(this, _) : o.observe(r, _), x.set(this, o);
474
+ window.ShadyDOM ? o.observe(this, $) : o.observe(r, $), C.set(this, o);
475
475
  }
476
476
  return r;
477
477
  };
478
478
  const i = Element.prototype.attachShadow;
479
- Element.prototype.attachShadow = t;
479
+ Element.prototype.attachShadow = e;
480
480
  }
481
- L() && typeof document < "u" && new MutationObserver(O).observe(document.documentElement, _), typeof HTMLFormElement < "u" && Ft(), (e || typeof window < "u" && !window.CustomStateSet) && H();
481
+ N() && typeof document < "u" && new MutationObserver(O).observe(document.documentElement, $), typeof HTMLFormElement < "u" && Fe(), (t || typeof window < "u" && !window.CustomStateSet) && W();
482
482
  }
483
483
  }
484
- return !!customElements.polyfillWrapFlushCallback || (It() ? typeof window < "u" && !window.CustomStateSet && H(HTMLElement.prototype.attachInternals) : dt(!1)), n.forceCustomStateSetPolyfill = H, n.forceElementInternalsPolyfill = dt, Object.defineProperty(n, "__esModule", { value: !0 }), n;
484
+ return !!customElements.polyfillWrapFlushCallback || (Ie() ? typeof window < "u" && !window.CustomStateSet && W(HTMLElement.prototype.attachInternals) : de(!1)), n.forceCustomStateSetPolyfill = W, n.forceElementInternalsPolyfill = de, Object.defineProperty(n, "__esModule", { value: !0 }), n;
485
485
  })({});
486
- })()), ht;
486
+ })()), he;
487
487
  }
488
- zt();
489
- const Bt = "*,*: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)}@media(hover:hover){.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)){@media(hover:hover){.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)}@media(hover:hover){.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)){@media(hover:hover){.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;display:block;height:1px;width:1px;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.c-switch-input *{overflow:hidden}.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;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.c-switch-description *{overflow:hidden}.c-switch-wrapper--label-leading{flex-direction:row-reverse}.c-switch-wrapper--label-trailing{flex-direction:row}@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)))}", qt = ["leading", "trailing"], ae = "change", M = {
488
+ Be();
489
+ const qe = "*,*: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)}@media(hover:hover){.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)){@media(hover:hover){.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)}@media(hover:hover){.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)){@media(hover:hover){.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;display:block;height:1px;width:1px;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.c-switch-input *{overflow:hidden}.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[checked] .c-switch-control{transform:translate(var(--switch-translation))}.c-switch[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;border:0;padding:0;margin:-1px;overflow:hidden;white-space:nowrap;clip:rect(0,0,0,0);clip-path:inset(50%)}.c-switch-description *{overflow:hidden}.c-switch-wrapper--label-leading{flex-direction:row-reverse}.c-switch-wrapper--label-trailing{flex-direction:row}@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[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[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[checked] .c-switch-control{transform:translate(calc(-1 * var(--switch-translation)))}", Ue = ["leading", "trailing"], rt = "change", x = {
490
490
  checked: !1,
491
491
  defaultChecked: !1,
492
492
  disabled: !1,
@@ -494,20 +494,22 @@ const Bt = "*,*:after,*:before{box-sizing:inherit}:host{display:block}*,*:before
494
494
  required: !1,
495
495
  value: "on"
496
496
  };
497
- var Ut = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, f = (n, l, d, u) => {
498
- for (var c = u > 1 ? void 0 : u ? jt(l, d) : l, k = n.length - 1, E; k >= 0; k--)
497
+ var je = Object.defineProperty, Ke = Object.getOwnPropertyDescriptor, f = (n, l, d, u) => {
498
+ for (var c = u > 1 ? void 0 : u ? Ke(l, d) : l, k = n.length - 1, E; k >= 0; k--)
499
499
  (E = n[k]) && (c = (u ? E(l, d, c) : E(c)) || c);
500
- return u && c && Ut(l, d, c), c;
500
+ return u && c && je(l, d, c), c;
501
501
  };
502
- const Kt = "pie-switch";
503
- let p = class extends $t(Dt(B)) {
502
+ const Ge = "pie-switch";
503
+ let p = class extends $e(De(Re(q))) {
504
504
  constructor() {
505
- super(...arguments), this.labelPlacement = M.labelPlacement, this.checked = M.checked, this.defaultChecked = M.defaultChecked, this.required = M.required, this.value = M.value, this.disabled = M.disabled, this._isAnimationAllowed = !1;
505
+ super(...arguments), this.labelPlacement = x.labelPlacement, this.checked = x.checked, this.defaultChecked = x.defaultChecked, this.required = x.required, this.value = x.value, this.disabled = x.disabled, this._isAnimationAllowed = !1;
506
506
  }
507
- firstUpdated() {
508
- this.handleFormAssociation(), this.input.addEventListener("invalid", (n) => {
509
- this.dispatchEvent(new Event("invalid", n));
510
- });
507
+ firstUpdated(n) {
508
+ super.firstUpdated(n);
509
+ const { signal: l } = this._abortController;
510
+ this.handleFormAssociation(), this.input.addEventListener("invalid", (d) => {
511
+ this.dispatchEvent(new Event("invalid", d));
512
+ }, { signal: l });
511
513
  }
512
514
  connectedCallback() {
513
515
  super.connectedCallback(), this._abortController = new AbortController();
@@ -540,7 +542,7 @@ let p = class extends $t(Dt(B)) {
540
542
  handleChange(n) {
541
543
  const { checked: l } = n == null ? void 0 : n.currentTarget;
542
544
  this.checked = l;
543
- const d = Rt(n);
545
+ const d = He(n);
544
546
  this._isAnimationAllowed || (this._isAnimationAllowed = !0), this.dispatchEvent(d), this.handleFormAssociation();
545
547
  }
546
548
  /**
@@ -594,24 +596,24 @@ let p = class extends $t(Dt(B)) {
594
596
  }
595
597
  renderAriaDescription() {
596
598
  var n;
597
- return (n = this.aria) != null && n.describedBy ? z`
599
+ return (n = this.aria) != null && n.describedBy ? B`
598
600
  <div
599
601
  aria-hidden="true"
600
602
  id="switch-description"
601
603
  data-test-id="switch-description"
602
604
  class="c-switch-description">
603
605
  ${this.aria.describedBy}
604
- </div>` : N;
606
+ </div>` : P;
605
607
  }
606
608
  renderSwitchLabel() {
607
609
  const { label: n, labelPlacement: l } = this;
608
- return n ? z`
610
+ return n ? B`
609
611
  <span
610
612
  aria-hidden="true"
611
613
  data-test-id="switch-label-${l}"
612
614
  class="c-switch-label">
613
615
  ${n}
614
- </span>` : N;
616
+ </span>` : P;
615
617
  }
616
618
  render() {
617
619
  const {
@@ -621,15 +623,16 @@ let p = class extends $t(Dt(B)) {
621
623
  checked: u,
622
624
  disabled: c,
623
625
  required: k,
624
- _isAnimationAllowed: E
625
- } = this, x = {
626
+ _isAnimationAllowed: E,
627
+ associatedLabelText: C
628
+ } = this, b = (d == null ? void 0 : d.label) || n || C, F = {
626
629
  "c-switch-wrapper": !0,
627
630
  "c-switch-wrapper--allow-animation": E,
628
631
  [`c-switch-wrapper--label-${l}`]: !0
629
- }, b = Tt(n ? "label" : "div");
630
- return Lt`
631
- <${b}
632
- class="${Pt(x)}"
632
+ }, M = Te(n ? "label" : "div");
633
+ return Le`
634
+ <${M}
635
+ class="${Pe(F)}"
633
636
  ?disabled=${c}>
634
637
  <div
635
638
  data-test-id="switch-component"
@@ -640,28 +643,28 @@ let p = class extends $t(Dt(B)) {
640
643
  role="switch"
641
644
  type="checkbox"
642
645
  class="c-switch-input"
643
- .required=${k}
644
- .checked="${_t(u)}"
645
- .disabled="${c}"
646
+ ?required=${k}
647
+ .checked="${Oe(u)}"
648
+ ?disabled="${c}"
646
649
  @change="${this.handleChange}"
647
- aria-label="${Ot((d == null ? void 0 : d.label) || n)}"
648
- aria-describedby="${d != null && d.describedBy ? "switch-description" : N}">
650
+ aria-label="${_e(b)}"
651
+ aria-describedby="${d != null && d.describedBy ? "switch-description" : P}">
649
652
  <div class="c-switch-control">
650
- ${u ? z`<icon-check></icon-check>` : N}
653
+ ${u ? B`<icon-check></icon-check>` : P}
651
654
  </div>
652
655
  </div>
653
656
  ${this.renderSwitchLabel()}
654
657
  ${this.renderAriaDescription()}
655
- </${b}>`;
658
+ </${M}>`;
656
659
  }
657
660
  };
658
- p.styles = Vt(Bt);
661
+ p.styles = Ve(qe);
659
662
  f([
660
663
  y({ type: String })
661
664
  ], p.prototype, "label", 2);
662
665
  f([
663
666
  y({ type: String }),
664
- Ht(Kt, qt, M.labelPlacement)
667
+ We(Ge, Ue, x.labelPlacement)
665
668
  ], p.prototype, "labelPlacement", 2);
666
669
  f([
667
670
  y({ type: Object })
@@ -685,23 +688,23 @@ f([
685
688
  y({ type: Boolean, reflect: !0 })
686
689
  ], p.prototype, "disabled", 2);
687
690
  f([
688
- q('input[type="checkbox"]')
691
+ U('input[type="checkbox"]')
689
692
  ], p.prototype, "input", 2);
690
693
  f([
691
- q(".c-switch")
694
+ U(".c-switch")
692
695
  ], p.prototype, "switchBody", 2);
693
696
  f([
694
- q('label, input[type="checkbox"]')
697
+ U('label, input[type="checkbox"]')
695
698
  ], p.prototype, "focusTarget", 2);
696
699
  f([
697
- Nt()
700
+ Ne()
698
701
  ], p.prototype, "_isAnimationAllowed", 2);
699
702
  p = f([
700
- Wt("pie-switch")
703
+ ze("pie-switch")
701
704
  ], p);
702
705
  export {
703
- ae as ON_SWITCH_CHANGED_EVENT,
706
+ rt as ON_SWITCH_CHANGED_EVENT,
704
707
  p as PieSwitch,
705
- M as defaultProps,
706
- qt as labelPlacements
708
+ x as defaultProps,
709
+ Ue as labelPlacements
707
710
  };
package/dist/react.d.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import { AssociatedLabelInterface } from '@justeattakeaway/pie-webc-core';
1
2
  import { ComponentDefaultProps } from '@justeattakeaway/pie-webc-core';
2
3
  import { CSSResult } from 'lit';
3
4
  import { FormControlInterface } from '@justeattakeaway/pie-webc-core';
4
5
  import { GenericConstructor } from '@justeattakeaway/pie-webc-core';
5
6
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
6
7
  import { PIEInputElement } from '@justeattakeaway/pie-webc-core';
8
+ import { PropertyValues } from 'lit';
7
9
  import * as React_2 from 'react';
8
10
  import { TemplateResult } from 'lit-html';
9
11
 
@@ -46,7 +48,7 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInpu
46
48
  focusTarget: HTMLElement;
47
49
  private _abortController;
48
50
  private _isAnimationAllowed;
49
- protected firstUpdated(): void;
51
+ protected firstUpdated(changedProperties: PropertyValues): void;
50
52
  connectedCallback(): void;
51
53
  disconnectedCallback(): void;
52
54
  protected updated(): void;
@@ -98,7 +100,7 @@ declare class PieSwitch_2 extends PieSwitch_base implements SwitchProps, PIEInpu
98
100
  render(): TemplateResult;
99
101
  }
100
102
 
101
- declare const PieSwitch_base: GenericConstructor<FormControlInterface> & typeof PieElement;
103
+ declare const PieSwitch_base: GenericConstructor<AssociatedLabelInterface> & GenericConstructor<FormControlInterface> & typeof PieElement;
102
104
 
103
105
  declare type PieSwitchEvents = {
104
106
  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": "2.5.0",
4
+ "version": "2.5.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/justeattakeaway/pie",
@@ -49,8 +49,8 @@
49
49
  "@justeattakeaway/pie-wrapper-react": "0.14.5"
50
50
  },
51
51
  "dependencies": {
52
- "@justeattakeaway/pie-icons-webc": "1.25.1",
53
- "@justeattakeaway/pie-webc-core": "15.0.0",
52
+ "@justeattakeaway/pie-icons-webc": "1.25.3",
53
+ "@justeattakeaway/pie-webc-core": "15.1.0",
54
54
  "element-internals-polyfill": "1.3.11"
55
55
  },
56
56
  "customElements": "custom-elements.json",
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import {
2
- html, unsafeCSS, nothing,
2
+ html, unsafeCSS, nothing, type PropertyValues,
3
3
  } from 'lit';
4
4
  import { html as staticHtml, unsafeStatic } from 'lit/static-html.js';
5
5
  import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
@@ -13,6 +13,7 @@ import {
13
13
  validPropertyValues,
14
14
  FormControlMixin,
15
15
  DelegatesFocusMixin,
16
+ AssociatedLabelMixin,
16
17
  wrapNativeEvent,
17
18
  safeCustomElement,
18
19
  type PIEInputElement,
@@ -32,7 +33,7 @@ const componentSelector = 'pie-switch';
32
33
  * @event {CustomEvent} change - when the switch checked state is changed.
33
34
  */
34
35
  @safeCustomElement('pie-switch')
35
- export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement)) implements SwitchProps, PIEInputElement {
36
+ export class PieSwitch extends AssociatedLabelMixin(FormControlMixin(DelegatesFocusMixin(PieElement))) implements SwitchProps, PIEInputElement {
36
37
  @property({ type: String })
37
38
  public label: SwitchProps['label'];
38
39
 
@@ -75,13 +76,15 @@ export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement))
75
76
  @state()
76
77
  private _isAnimationAllowed = false;
77
78
 
78
- protected firstUpdated (): void {
79
+ protected firstUpdated (changedProperties: PropertyValues): void {
80
+ super.firstUpdated(changedProperties);
81
+ const { signal } = this._abortController;
79
82
  this.handleFormAssociation();
80
83
  // This ensures that invalid events triggered by checkValidity() are propagated to the custom element
81
84
  // for consumers to listen to: https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
82
85
  this.input.addEventListener('invalid', (event) => {
83
86
  this.dispatchEvent(new Event('invalid', event));
84
- });
87
+ }, { signal });
85
88
  }
86
89
 
87
90
  connectedCallback (): void {
@@ -260,8 +263,11 @@ export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement))
260
263
  disabled,
261
264
  required,
262
265
  _isAnimationAllowed,
266
+ associatedLabelText,
263
267
  } = this;
264
268
 
269
+ const ariaLabel = aria?.label || label || associatedLabelText;
270
+
265
271
  const classes = {
266
272
  'c-switch-wrapper': true,
267
273
  'c-switch-wrapper--allow-animation': _isAnimationAllowed,
@@ -283,11 +289,11 @@ export class PieSwitch extends FormControlMixin(DelegatesFocusMixin(PieElement))
283
289
  role="switch"
284
290
  type="checkbox"
285
291
  class="c-switch-input"
286
- .required=${required}
292
+ ?required=${required}
287
293
  .checked="${live(checked)}"
288
- .disabled="${disabled}"
294
+ ?disabled="${disabled}"
289
295
  @change="${this.handleChange}"
290
- aria-label="${ifDefined(aria?.label || label)}"
296
+ aria-label="${ifDefined(ariaLabel)}"
291
297
  aria-describedby="${aria?.describedBy ? 'switch-description' : nothing}">
292
298
  <div class="c-switch-control">
293
299
  ${checked ? html`<icon-check></icon-check>` : nothing}
package/src/switch.scss CHANGED
@@ -95,7 +95,7 @@
95
95
  vertical-align: top;
96
96
  }
97
97
 
98
- .c-switch-input:checked + & {
98
+ .c-switch[checked] & {
99
99
  transform: translateX(var(--switch-translation));
100
100
 
101
101
  .c-pieIcon--check {
@@ -143,7 +143,7 @@
143
143
  .c-switch-control {
144
144
  @include switch-transition(transform);
145
145
 
146
- .c-switch-input:checked + & {
146
+ .c-switch[checked] & {
147
147
  @include switch-transition(transform);
148
148
 
149
149
  .c-pieIcon--check {
@@ -160,7 +160,7 @@
160
160
  }
161
161
 
162
162
  .c-switch-wrapper:dir(rtl) {
163
- .c-switch-input:checked + .c-switch-control {
163
+ .c-switch[checked] .c-switch-control {
164
164
  transform: translateX(calc(-1 * var(--switch-translation)));
165
165
  }
166
166
  }