@muibook/components 8.0.2 → 9.1.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.
@@ -1,14 +1,14 @@
1
- import { getPartMap as s } from "../../utils/part-map/index.js";
2
- class i extends HTMLElement {
1
+ import { getPartMap as e } from "../../utils/part-map/index.js";
2
+ class l extends HTMLElement {
3
3
  static get observedAttributes() {
4
- return ["col", "space"];
4
+ return ["col", "space", "alignx", "aligny"];
5
5
  }
6
6
  constructor() {
7
- super(), this.attachShadow({ mode: "open" });
7
+ super(), this.attachShadow({ mode: "open" }), this.col = "1fr 1fr", this.space = "var(--space-000)", this.alignX = "normal", this.alignY = "normal";
8
8
  }
9
9
  async connectedCallback() {
10
10
  await this.waitForPartMap();
11
- const t = this.getAttribute("col") || "1fr 1fr", e = this.getAttribute("space") || "var(--space-000)", a = s("layout", "spacing"), o = (
11
+ const t = this.getAttribute("col") || this.col, a = this.getAttribute("space") || this.space, i = this.getAttribute("alignx") || this.alignX, s = this.getAttribute("aligny") || this.alignY, o = e("layout", "spacing"), r = (
12
12
  /*css*/
13
13
  `
14
14
  :host {
@@ -18,25 +18,32 @@ class i extends HTMLElement {
18
18
  display: grid;
19
19
  grid-template-columns: var(--col);
20
20
  gap: var(--gap);
21
+ align-items: var(--alignY);
22
+ justify-items: var(--alignX);
21
23
  }
22
24
  `
23
25
  );
24
26
  this.shadowRoot && (this.shadowRoot.innerHTML = /*html*/
25
27
  `
26
- <style>${o}</style>
27
- <div part="${a}" style="--col: ${t}; --gap: ${e};">
28
+ <style>${r}</style>
29
+ <div part="${o}" style="--col: ${t}; --gap: ${a}; --alignX: ${i}; --alignY: ${s};">
28
30
  <slot></slot>
29
31
  </div>
30
32
  `);
31
33
  }
34
+ attributeChangedCallback(t, a, i) {
35
+ if (a === i || !this.shadowRoot) return;
36
+ const s = this.shadowRoot.querySelector("div");
37
+ s && (t === "col" && s.style.setProperty("--col", i || this.col), t === "space" && s.style.setProperty("--gap", i || this.space), t === "alignx" && s.style.setProperty("--alignX", i || this.alignX), t === "aligny" && s.style.setProperty("--alignY", i || this.alignY));
38
+ }
32
39
  waitForPartMap() {
33
40
  return new Promise((t) => {
34
- if (typeof s == "function") return t();
35
- const e = () => {
36
- typeof s == "function" ? t() : requestAnimationFrame(e);
41
+ if (typeof e == "function") return t();
42
+ const a = () => {
43
+ typeof e == "function" ? t() : requestAnimationFrame(a);
37
44
  };
38
- e();
45
+ a();
39
46
  });
40
47
  }
41
48
  }
42
- customElements.get("mui-grid") || customElements.define("mui-grid", i);
49
+ customElements.get("mui-grid") || customElements.define("mui-grid", l);
@@ -1,4 +1,4 @@
1
- class t extends HTMLElement {
1
+ class n extends HTMLElement {
2
2
  static get observedAttributes() {
3
3
  return ["size", "level"];
4
4
  }
@@ -6,8 +6,14 @@ class t extends HTMLElement {
6
6
  super(), this.attachShadow({ mode: "open" });
7
7
  }
8
8
  connectedCallback() {
9
+ this.render();
10
+ }
11
+ attributeChangedCallback(i, t, e) {
12
+ t !== e && this.shadowRoot && this.render();
13
+ }
14
+ render() {
9
15
  if (!this.shadowRoot) return;
10
- const e = this.getAttribute("size") || "1", i = `h${this.getAttribute("level") || e}`;
16
+ const i = this.getAttribute("size") || "1", e = `h${this.getAttribute("level") || i}`;
11
17
  this.shadowRoot.innerHTML = /*html*/
12
18
  `
13
19
  <style>
@@ -26,10 +32,10 @@ class t extends HTMLElement {
26
32
  .size-5 { font-size: var(--heading-font-size-500); line-height: var(--heading-line-height-500); }
27
33
  .size-6 { font-size: var(--heading-font-size-600); line-height: var(--heading-line-height-600); }
28
34
  </style>
29
- <${i} class="size-${e}">
35
+ <${e} class="size-${i}">
30
36
  <slot></slot>
31
- </${i}>
37
+ </${e}>
32
38
  `;
33
39
  }
34
40
  }
35
- customElements.get("mui-heading") || customElements.define("mui-heading", t);
41
+ customElements.get("mui-heading") || customElements.define("mui-heading", n);
@@ -8,53 +8,60 @@ class m extends HTMLElement {
8
8
  connectedCallback() {
9
9
  this.render(), this.setupListener();
10
10
  }
11
- attributeChangedCallback(e, a, o) {
11
+ disconnectedCallback() {
12
+ this.cleanupListeners();
13
+ }
14
+ attributeChangedCallback(e, r, o) {
15
+ var s;
16
+ const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector("input");
17
+ if (t) {
18
+ if (e === "value") {
19
+ t.value = o ?? "";
20
+ return;
21
+ }
22
+ if (e === "disabled") {
23
+ o === null || o === "false" ? t.removeAttribute("disabled") : t.setAttribute("disabled", "");
24
+ return;
25
+ }
26
+ ["type", "placeholder", "label", "hide-label", "variant"].includes(e) && (this.render(), this.setupListener());
27
+ }
28
+ }
29
+ cleanupListeners() {
12
30
  var r;
13
- const t = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
14
- t && (e === "value" && (t.value = o ?? ""), e === "disabled" && (o === null || o === "false" ? t.removeAttribute("disabled") : t.setAttribute("disabled", "")), (e === "type" || e === "placeholder" || e === "label" || e === "hide-label") && (this.render(), this.setupListener()));
31
+ const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
32
+ e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
15
33
  }
16
34
  setupListener() {
17
- var o, t;
18
- const e = (o = this.shadowRoot) == null ? void 0 : o.querySelector("input");
19
- if (!e) return;
20
- const a = e.cloneNode(!0);
21
- (t = e.parentNode) == null || t.replaceChild(a, e), a.addEventListener("input", (r) => {
22
- const s = r.target;
23
- this.dispatchEvent(
24
- new CustomEvent("input", {
25
- detail: { value: s.value },
26
- bubbles: !0,
27
- composed: !0
28
- })
29
- );
30
- }), a.addEventListener("change", (r) => {
31
- const s = r.target;
32
- this.dispatchEvent(
33
- new CustomEvent("change", {
34
- detail: { value: s.value },
35
- bubbles: !0,
36
- composed: !0
37
- })
38
- );
39
- });
35
+ if (!this.shadowRoot) return;
36
+ const e = this.shadowRoot.querySelector("input");
37
+ e && (this.cleanupListeners(), this._changeHandler = (r) => {
38
+ const o = r.target;
39
+ this.setAttribute("value", o.value);
40
+ const t = {
41
+ detail: { value: o.value },
42
+ bubbles: !0,
43
+ composed: !0
44
+ };
45
+ this.dispatchEvent(new CustomEvent("change", t)), this.dispatchEvent(new CustomEvent("input", t));
46
+ }, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler));
40
47
  }
41
48
  updateSlottedButtons() {
42
49
  requestAnimationFrame(() => {
43
- var t, r;
44
- const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector('slot[name="before"]'), a = (r = this.shadowRoot) == null ? void 0 : r.querySelector('slot[name="after"]'), o = (s) => {
45
- if (!s) return;
46
- s.assignedNodes({ flatten: !0 }).forEach((i) => {
50
+ var t, s;
51
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector('slot[name="before"]'), r = (s = this.shadowRoot) == null ? void 0 : s.querySelector('slot[name="after"]'), o = (l) => {
52
+ if (!l) return;
53
+ l.assignedNodes({ flatten: !0 }).forEach((i) => {
47
54
  if (i.nodeType === Node.ELEMENT_NODE) {
48
- const l = i, n = l.tagName.toLowerCase();
49
- (n === "mui-button" || n === "mui-link") && (l.setAttribute("usage", "input"), l.setAttribute("size", "medium"), l.removeAttribute("variant"), l.removeAttribute("weight"));
55
+ const a = i, n = a.tagName.toLowerCase();
56
+ (n === "mui-button" || n === "mui-link") && (a.setAttribute("usage", "input"), a.setAttribute("size", "medium"), a.removeAttribute("variant"), a.removeAttribute("weight"));
50
57
  }
51
58
  });
52
59
  };
53
- o(e), o(a);
60
+ o(e), o(r);
54
61
  });
55
62
  }
56
63
  render() {
57
- const e = ["text", "password", "email", "number", "search", "tel", "url", "date", "time"], a = this.getAttribute("type") || "text", o = e.includes(a) ? a : "text", t = this.getAttribute("name") || "", r = this.getAttribute("value") || "", s = this.getAttribute("placeholder") || "", d = this.getAttribute("id") || `mui-input-${Math.random().toString(36).substr(2, 9)}`, i = this.getAttribute("label") || "", l = this.hasAttribute("hide-label"), n = this.hasAttribute("disabled"), c = l && i ? `aria-label="${i}"` : "", u = this.getAttribute("variant") || "", h = u || "", b = this.querySelector('[slot="before"]') !== null, p = this.querySelector('[slot="after"]') !== null, f = [h, b ? "before" : "", p ? "after" : ""].filter(Boolean).join(" "), v = (
64
+ const e = ["text", "password", "email", "number", "search", "tel", "url", "date", "time"], r = this.getAttribute("type") || "text", o = e.includes(r) ? r : "text", t = this.getAttribute("name") || "", s = this.getAttribute("value") || "", l = this.getAttribute("placeholder") || "", d = this.getAttribute("id") || `mui-input-${Math.random().toString(36).substr(2, 9)}`, i = this.getAttribute("label") || "", a = this.hasAttribute("hide-label"), n = this.hasAttribute("disabled"), u = a && i ? `aria-label="${i}"` : "", c = this.getAttribute("variant") || "", h = c || "", b = this.querySelector('[slot="before"]') !== null, p = this.querySelector('[slot="after"]') !== null, f = [h, b ? "before" : "", p ? "after" : ""].filter(Boolean).join(" "), v = (
58
65
  /*html*/
59
66
  `
60
67
  <style>
@@ -225,7 +232,7 @@ class m extends HTMLElement {
225
232
 
226
233
 
227
234
  </style>
228
- ${i ? `<label for="${d}" class="${l ? "vh" : ""}">${i}</label>` : ""}
235
+ ${i ? `<label for="${d}" class="${a ? "vh" : ""}">${i}</label>` : ""}
229
236
  <div class="input-wrapper">
230
237
  <slot name="before"></slot>
231
238
  <input
@@ -233,10 +240,10 @@ class m extends HTMLElement {
233
240
  type="${o}"
234
241
  name="${t}"
235
242
  id="${d}"
236
- value="${r}"
237
- placeholder="${s}"
243
+ value="${s}"
244
+ placeholder="${l}"
238
245
  ${n ? 'disabled aria-disabled="true"' : ""}
239
- ${c}
246
+ ${u}
240
247
  />
241
248
  <slot name="after"></slot>
242
249
  </div>
@@ -10,41 +10,53 @@ class p extends HTMLElement {
10
10
  async connectedCallback() {
11
11
  await this.waitForPartMap(), this.partMap = s("text", "visual"), this.render(), this.setupListener();
12
12
  }
13
- attributeChangedCallback(e, r) {
14
- if (!this.shadowRoot) return;
15
- const o = (
16
- /** @type {HTMLSelectElement | null} */
17
- this.shadowRoot.querySelector("select")
18
- );
19
- e === "value" && o && (o.value = r || ""), e === "disabled" && o && (r === null || r === "false" ? o.removeAttribute("disabled") : o.setAttribute("disabled", "")), ["options", "label", "hide-label"].includes(e) && (this.render(), this.setupListener());
13
+ disconnectedCallback() {
14
+ this.cleanupListeners();
15
+ }
16
+ attributeChangedCallback(e, r, t) {
17
+ if (!this.shadowRoot || r === t) return;
18
+ const o = this.shadowRoot.querySelector("select");
19
+ if (e === "value" && o) {
20
+ o.value = t || "";
21
+ return;
22
+ }
23
+ if (e === "disabled" && o) {
24
+ t === null || t === "false" ? o.removeAttribute("disabled") : o.setAttribute("disabled", "");
25
+ return;
26
+ }
27
+ ["options", "label", "hide-label", "variant"].includes(e) && (this.render(), this.setupListener());
28
+ }
29
+ cleanupListeners() {
30
+ var r;
31
+ const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("select");
32
+ e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
20
33
  }
21
34
  setupListener() {
22
35
  if (!this.shadowRoot) return;
23
36
  const e = this.shadowRoot.querySelector("select");
24
- if (e) {
25
- const r = e.cloneNode(!0);
26
- e.parentNode && e.parentNode.replaceChild(r, e), r.addEventListener("change", (o) => {
27
- const a = o.target;
28
- a && this.dispatchEvent(
29
- new CustomEvent("change", {
30
- detail: { value: a.value },
31
- bubbles: !0,
32
- composed: !0
33
- })
34
- );
35
- });
36
- }
37
+ e && (this.cleanupListeners(), this._changeHandler = (r) => {
38
+ const t = r.target;
39
+ this.setAttribute("value", t.value);
40
+ const o = {
41
+ detail: { value: t.value },
42
+ bubbles: !0,
43
+ composed: !0
44
+ };
45
+ this.dispatchEvent(new CustomEvent("change", o)), this.dispatchEvent(new CustomEvent("input", o));
46
+ }, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler));
37
47
  }
38
48
  render() {
39
49
  if (!this.shadowRoot) return;
40
- const e = this.getAttribute("name") || "", r = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`, o = this.getAttribute("label") || "", a = this.getAttribute("value") || "", i = this.hasAttribute("hide-label"), c = this.hasAttribute("disabled"), d = this.getAttribute("options") || "[]", l = this.getAttribute("variant") || "", h = l || "", b = i && o ? `aria-label="${o}"` : "";
41
- let n = [];
50
+ const e = this.getAttribute("name") || "", r = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`, t = this.getAttribute("label") || "", o = this.getAttribute("value") || "", i = this.hasAttribute("hide-label"), c = this.hasAttribute("disabled"), d = this.getAttribute("options") || "[]", n = this.getAttribute("variant") || "", h = n || "", u = i && t ? `aria-label="${t}"` : "";
51
+ let l = [];
42
52
  try {
43
- n = JSON.parse(d);
44
- } catch (t) {
45
- console.error("Invalid JSON in options attribute", t);
53
+ l = JSON.parse(d);
54
+ } catch (a) {
55
+ console.error("Invalid JSON in options attribute", a);
46
56
  }
47
- const u = n.map((t) => `<option value="${t.value}" ${t.value === a ? "selected" : ""}>${t.label}</option>`).join(""), v = (
57
+ const b = l.map(
58
+ (a) => `<option value="${a.value}" ${a.value === o ? "selected" : ""} ${a.disabled ? "disabled" : ""}>${a.label}</option>`
59
+ ).join(""), v = (
48
60
  /*html*/
49
61
  `
50
62
  <style>
@@ -180,14 +192,14 @@ class p extends HTMLElement {
180
192
  /* ========================================================================== */
181
193
 
182
194
  </style>
183
- ${o ? (
195
+ ${t ? (
184
196
  /*html*/
185
- `<label for="${r}" class="${i ? "vh" : ""}">${o}</label>`
197
+ `<label for="${r}" class="${i ? "vh" : ""}">${t}</label>`
186
198
  ) : ""}
187
199
  <div style="position: relative;">
188
- <select class="${h}" part="${this.partMap || ""}" name="${e}" id="${r}" ${b}
200
+ <select class="${h}" part="${this.partMap || ""}" name="${e}" id="${r}" ${u}
189
201
  ${c ? "disabled" : ""}>
190
- ${u}
202
+ ${b}
191
203
  </select>
192
204
  <mui-icon-down-chevron class="chevron" size="x-small"></mui-icon-down-chevron>
193
205
  </div>
@@ -75,6 +75,7 @@ class u extends HTMLElement {
75
75
  }
76
76
 
77
77
  :host {
78
+ display: block;
78
79
  width: 100%;
79
80
  max-width: 395px;
80
81
  min-width: 247px;
@@ -1,7 +1,7 @@
1
- import { getPartMap as a } from "../../../utils/part-map/index.js";
2
- class e extends HTMLElement {
1
+ import { getPartMap as e } from "../../../utils/part-map/index.js";
2
+ class r extends HTMLElement {
3
3
  static get observedAttributes() {
4
- return ["space", "alignY", "alignX"];
4
+ return ["space", "aligny", "alignx"];
5
5
  }
6
6
  constructor() {
7
7
  super(), this.attachShadow({ mode: "open" }), this.space = "var(--space-500)", this.alignY = "flex-start", this.alignX = "flex-start", this.styles = /*css*/
@@ -20,7 +20,7 @@ class e extends HTMLElement {
20
20
  async connectedCallback() {
21
21
  if (!this.shadowRoot) return;
22
22
  await this.waitForPartMap();
23
- const t = a("spacing", "layout", "visual");
23
+ const t = e("spacing", "layout", "visual");
24
24
  this.shadowRoot.innerHTML = /*html*/
25
25
  `
26
26
  <style>${this.styles}</style>
@@ -28,25 +28,25 @@ class e extends HTMLElement {
28
28
  part="${t}"
29
29
  style="
30
30
  --space: ${this.getAttribute("space") || this.space};
31
- --alignY: ${this.getAttribute("alignY") || this.alignY};
32
- --alignX: ${this.getAttribute("alignX") || this.alignX};
31
+ --alignY: ${this.getAttribute("aligny") || this.alignY};
32
+ --alignX: ${this.getAttribute("alignx") || this.alignX};
33
33
  ">
34
34
  </slot>
35
35
  `;
36
36
  }
37
- attributeChangedCallback(t, s) {
38
- if (!this.shadowRoot) return;
39
- const i = this.shadowRoot.querySelector("slot");
40
- i && (t === "space" && i.style.setProperty("--space", s || this.space), t === "alignY" && i.style.setProperty("--alignY", s || this.alignY), t === "alignX" && i.style.setProperty("--alignX", s || this.alignX));
37
+ attributeChangedCallback(t, s, i) {
38
+ if (s === i || !this.shadowRoot) return;
39
+ const a = this.shadowRoot.querySelector("slot");
40
+ a && (t === "space" && a.style.setProperty("--space", i || this.space), t === "aligny" && a.style.setProperty("--alignY", i || this.alignY), t === "alignx" && a.style.setProperty("--alignX", i || this.alignX));
41
41
  }
42
42
  waitForPartMap() {
43
43
  return new Promise((t) => {
44
- if (typeof a == "function") return t();
44
+ if (typeof e == "function") return t();
45
45
  const s = () => {
46
- typeof a == "function" ? t() : requestAnimationFrame(s);
46
+ typeof e == "function" ? t() : requestAnimationFrame(s);
47
47
  };
48
48
  s();
49
49
  });
50
50
  }
51
51
  }
52
- customElements.get("mui-h-stack") || customElements.define("mui-h-stack", e);
52
+ customElements.get("mui-h-stack") || customElements.define("mui-h-stack", r);
@@ -1,7 +1,7 @@
1
- import { getPartMap as a } from "../../../utils/part-map/index.js";
2
- class e extends HTMLElement {
1
+ import { getPartMap as e } from "../../../utils/part-map/index.js";
2
+ class r extends HTMLElement {
3
3
  static get observedAttributes() {
4
- return ["space", "alignX", "alignY"];
4
+ return ["space", "alignx", "aligny"];
5
5
  }
6
6
  constructor() {
7
7
  super(), this.attachShadow({ mode: "open" }), this.space = "var(--space-500)", this.alignX = "normal", this.alignY = "normal", this.styles = /*css*/
@@ -20,7 +20,7 @@ class e extends HTMLElement {
20
20
  async connectedCallback() {
21
21
  if (!this.shadowRoot) return;
22
22
  await this.waitForPartMap();
23
- const t = a("spacing", "layout", "visual");
23
+ const t = e("spacing", "layout", "visual");
24
24
  this.shadowRoot.innerHTML = /*html*/
25
25
  `
26
26
  <style>${this.styles}</style>
@@ -28,25 +28,25 @@ class e extends HTMLElement {
28
28
  part="${t}"
29
29
  style="
30
30
  --space: ${this.getAttribute("space") || this.space};
31
- --alignX: ${this.getAttribute("alignX") || this.alignX};
32
- --alignY: ${this.getAttribute("alignY") || this.alignY};
31
+ --alignX: ${this.getAttribute("alignx") || this.alignX};
32
+ --alignY: ${this.getAttribute("aligny") || this.alignY};
33
33
  ">
34
34
  </slot>
35
35
  `;
36
36
  }
37
- attributeChangedCallback(t, s) {
38
- if (!this.shadowRoot) return;
39
- const i = this.shadowRoot.querySelector("slot");
40
- i && (t === "space" && i.style.setProperty("--space", s || this.space), t === "alignX" && i.style.setProperty("--alignX", s || this.alignX), t === "alignY" && i.style.setProperty("--alignY", s || this.alignY));
37
+ attributeChangedCallback(t, s, i) {
38
+ if (s === i || !this.shadowRoot) return;
39
+ const a = this.shadowRoot.querySelector("slot");
40
+ a && (t === "space" && a.style.setProperty("--space", i || this.space), t === "alignx" && a.style.setProperty("--alignX", i || this.alignX), t === "aligny" && a.style.setProperty("--alignY", i || this.alignY));
41
41
  }
42
42
  waitForPartMap() {
43
43
  return new Promise((t) => {
44
- if (typeof a == "function") return t();
44
+ if (typeof e == "function") return t();
45
45
  const s = () => {
46
- typeof a == "function" ? t() : requestAnimationFrame(s);
46
+ typeof e == "function" ? t() : requestAnimationFrame(s);
47
47
  };
48
48
  s();
49
49
  });
50
50
  }
51
51
  }
52
- customElements.get("mui-v-stack") || customElements.define("mui-v-stack", e);
52
+ customElements.get("mui-v-stack") || customElements.define("mui-v-stack", r);
@@ -1,61 +1,69 @@
1
- class h extends HTMLElement {
1
+ class o extends HTMLElement {
2
2
  constructor() {
3
3
  super(), this._checked = !1, this._checkbox = null, this.attachShadow({ mode: "open" }), this._checked = !1;
4
4
  }
5
5
  connectedCallback() {
6
- var t;
7
- this.render(), this._checkbox = this.shadowRoot.querySelector('input[type="checkbox"]'), this._checked = this.hasAttribute("checked"), this._checkbox && (this._checkbox.checked = this._checked), this._updateIcons(), this._updateDisabledState(), this._enforceIconSize(), (t = this._checkbox) == null || t.addEventListener("change", () => {
8
- this._checkbox && (this.checked = this._checkbox.checked, this.dispatchEvent(
9
- new CustomEvent("change", {
10
- detail: { checked: this.checked },
11
- bubbles: !0,
12
- composed: !0
13
- })
14
- ));
15
- });
6
+ this.render(), this._checkbox = this.shadowRoot.querySelector('input[type="checkbox"]'), this._checked = this.hasAttribute("checked"), this._checkbox && (this._checkbox.checked = this._checked), this._updateIcons(), this._updateDisabledState(), this._enforceIconSize(), this._setupListener();
7
+ }
8
+ disconnectedCallback() {
9
+ this._cleanupListeners();
16
10
  }
17
11
  static get observedAttributes() {
18
12
  return ["label", "disabled", "checked"];
19
13
  }
20
- attributeChangedCallback(t, e, s) {
21
- if (t === "checked" && e !== s && (this._checked = s !== null, this._checkbox && (this._checkbox.checked = this._checked, this._updateIcons())), t === "disabled" && e !== s) {
22
- const i = s !== null;
14
+ attributeChangedCallback(s, e, t) {
15
+ if (s === "checked" && e !== t && (this._checked = t !== null, this._checkbox && (this._checkbox.checked = this._checked, this._updateIcons())), s === "disabled" && e !== t) {
16
+ const i = t !== null;
23
17
  this._checkbox && (this._checkbox.disabled = i, this._checkbox.setAttribute("aria-disabled", i.toString())), this._updateDisabledState();
24
18
  }
25
19
  }
26
20
  get checked() {
27
21
  return this._checked;
28
22
  }
29
- set checked(t) {
30
- const e = !!t;
23
+ set checked(s) {
24
+ const e = !!s;
31
25
  this._checked !== e && (this._checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._checkbox && (this._checkbox.checked = this._checked, this._checkbox.setAttribute("aria-checked", this._checked.toString()), this._updateIcons()));
32
26
  }
27
+ _cleanupListeners() {
28
+ this._checkbox && this._changeHandler && this._checkbox.removeEventListener("change", this._changeHandler);
29
+ }
33
30
  _updateDisabledState() {
34
- var e, s, i, c;
35
- this.hasAttribute("disabled") ? (this.shadowRoot.host.classList.add("disabled"), (e = this._checkbox) == null || e.setAttribute("aria-disabled", "true"), (s = this._checkbox) == null || s.setAttribute("tabindex", "-1")) : (this.shadowRoot.host.classList.remove("disabled"), (i = this._checkbox) == null || i.removeAttribute("aria-disabled"), (c = this._checkbox) == null || c.removeAttribute("tabindex"));
31
+ var e, t, i, c;
32
+ this.hasAttribute("disabled") ? (this.shadowRoot.host.classList.add("disabled"), (e = this._checkbox) == null || e.setAttribute("aria-disabled", "true"), (t = this._checkbox) == null || t.setAttribute("tabindex", "-1")) : (this.shadowRoot.host.classList.remove("disabled"), (i = this._checkbox) == null || i.removeAttribute("aria-disabled"), (c = this._checkbox) == null || c.removeAttribute("tabindex"));
33
+ }
34
+ _setupListener() {
35
+ this._checkbox && (this._cleanupListeners(), this._changeHandler = () => {
36
+ this._checkbox && (this.checked = this._checkbox.checked, this.dispatchEvent(
37
+ new CustomEvent("change", {
38
+ detail: { checked: this.checked },
39
+ bubbles: !0,
40
+ composed: !0
41
+ })
42
+ ));
43
+ }, this._checkbox.addEventListener("change", this._changeHandler));
36
44
  }
37
45
  _enforceIconSize() {
38
- const t = this.shadowRoot.querySelector('slot[name="on-icon"]'), e = this.shadowRoot.querySelector('slot[name="off-icon"]'), s = (i) => {
46
+ const s = this.shadowRoot.querySelector('slot[name="on-icon"]'), e = this.shadowRoot.querySelector('slot[name="off-icon"]'), t = (i) => {
39
47
  if (!i) return;
40
48
  const c = () => {
41
- i.assignedElements().forEach((o) => {
42
- o.tagName.toLowerCase().startsWith("mui-icon") && o.setAttribute("size", "x-small");
49
+ i.assignedElements().forEach((h) => {
50
+ h.tagName.toLowerCase().startsWith("mui-icon") && h.setAttribute("size", "x-small");
43
51
  });
44
52
  };
45
53
  i.addEventListener("slotchange", c), setTimeout(c, 0);
46
54
  };
47
- s(t), s(e);
55
+ t(s), t(e);
48
56
  }
49
57
  _updateIcons() {
50
- const t = this.shadowRoot.querySelector('slot[name="on-icon"]'), e = this.shadowRoot.querySelector('slot[name="off-icon"]');
51
- t && t.assignedElements().forEach((s) => {
52
- s.style.display = this._checked ? "inline" : "none";
53
- }), e && e.assignedElements().forEach((s) => {
54
- s.style.display = this._checked ? "none" : "inline";
58
+ const s = this.shadowRoot.querySelector('slot[name="on-icon"]'), e = this.shadowRoot.querySelector('slot[name="off-icon"]');
59
+ s && s.assignedElements().forEach((t) => {
60
+ t.style.display = this._checked ? "inline" : "none";
61
+ }), e && e.assignedElements().forEach((t) => {
62
+ t.style.display = this._checked ? "none" : "inline";
55
63
  });
56
64
  }
57
65
  render() {
58
- const t = this.getAttribute("label");
66
+ const s = this.getAttribute("label");
59
67
  this.shadowRoot.innerHTML = /*html*/
60
68
  `
61
69
  <style>
@@ -132,7 +140,7 @@ class h extends HTMLElement {
132
140
  type="checkbox"
133
141
  role="switch"
134
142
  aria-checked="${this._checked}"
135
- ${t ? `aria-label="${t}"` : ""}
143
+ ${s ? `aria-label="${s}"` : ""}
136
144
  >
137
145
  <span class="track">
138
146
  <span class="thumb">
@@ -144,4 +152,4 @@ class h extends HTMLElement {
144
152
  `;
145
153
  }
146
154
  }
147
- customElements.get("mui-switch") || customElements.define("mui-switch", h);
155
+ customElements.get("mui-switch") || customElements.define("mui-switch", o);
@@ -1,19 +1,25 @@
1
- class s extends HTMLElement {
1
+ class o extends HTMLElement {
2
+ updateIcon(t) {
3
+ if (this.shadowRoot && (this.iconEl && (this.shadowRoot.removeChild(this.iconEl), this.iconEl = void 0), t && t.trim() !== "" && customElements.get(t))) {
4
+ const e = document.createElement(t);
5
+ e.setAttribute("color", this.hasAttribute("active") ? "var(--tab-icon-active)" : "var(--tab-icon)"), e.setAttribute("size", "small"), this.shadowRoot.insertBefore(e, this.shadowRoot.firstChild), this.iconEl = e;
6
+ }
7
+ }
2
8
  constructor() {
3
9
  super(), this.attachShadow({ mode: "open" });
4
10
  }
5
11
  static get observedAttributes() {
6
- return ["active"];
12
+ return ["active", "icon"];
7
13
  }
8
- attributeChangedCallback(t, i, a) {
9
- t === "active" && this.updateActiveState();
14
+ attributeChangedCallback(t, e, s) {
15
+ t === "active" ? this.updateActiveState() : t === "icon" && this.updateIcon(s);
10
16
  }
11
17
  connectedCallback() {
12
18
  if (!this.shadowRoot) return;
13
19
  const t = this.getAttribute("icon");
14
20
  this.setAttribute("tabindex", this.hasAttribute("active") ? "0" : "-1"), this.shadowRoot.innerHTML = "";
15
- const i = document.createElement("style");
16
- if (i.textContent = /*css*/
21
+ const e = document.createElement("style");
22
+ if (e.textContent = /*css*/
17
23
  `
18
24
  :host {
19
25
  user-select: none;
@@ -46,16 +52,16 @@ class s extends HTMLElement {
46
52
  ::slotted(*) {
47
53
  margin-left: var(--space-100);
48
54
  }
49
- `, this.shadowRoot.appendChild(i), t && t.trim() !== "" && customElements.get(t)) {
50
- const e = document.createElement(t);
51
- e.setAttribute("color", "var(--tab-icon)"), e.setAttribute("size", "small"), this.shadowRoot.appendChild(e), this.iconEl = e;
55
+ `, this.shadowRoot.appendChild(e), t && t.trim() !== "" && customElements.get(t)) {
56
+ const i = document.createElement(t);
57
+ i.setAttribute("color", "var(--tab-icon)"), i.setAttribute("size", "small"), this.shadowRoot.appendChild(i), this.iconEl = i;
52
58
  }
53
- const a = document.createElement("slot");
54
- this.shadowRoot.appendChild(a), this.updateActiveState();
59
+ const s = document.createElement("slot");
60
+ this.shadowRoot.appendChild(s), this.updateActiveState();
55
61
  }
56
62
  updateActiveState() {
57
63
  const t = this.hasAttribute("active");
58
64
  this.classList.toggle("active", t), this.setAttribute("role", "tab"), this.setAttribute("aria-selected", t ? "true" : "false"), this.setAttribute("tabindex", t ? "0" : "-1"), this.iconEl && this.iconEl.setAttribute("color", t ? "var(--tab-icon-active)" : "var(--tab-icon)");
59
65
  }
60
66
  }
61
- customElements.get("mui-tab-item") || customElements.define("mui-tab-item", s);
67
+ customElements.get("mui-tab-item") || customElements.define("mui-tab-item", o);