@muibook/components 8.0.1 → 9.0.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.
@@ -8,53 +8,50 @@ 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 a;
16
+ const t = (a = this.shadowRoot) == null ? void 0 : a.querySelector("input");
17
+ 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" || e === "variant") && (this.render(), this.setupListener()));
18
+ }
19
+ cleanupListeners() {
12
20
  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()));
21
+ const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
22
+ e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
15
23
  }
16
24
  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
- });
25
+ if (!this.shadowRoot) return;
26
+ const e = this.shadowRoot.querySelector("input");
27
+ e && (this.cleanupListeners(), this._changeHandler = (r) => {
28
+ const o = r.target;
29
+ this.setAttribute("value", o.value);
30
+ const t = {
31
+ detail: { value: o.value },
32
+ bubbles: !0,
33
+ composed: !0
34
+ };
35
+ this.dispatchEvent(new CustomEvent("change", t)), this.dispatchEvent(new CustomEvent("input", t));
36
+ }, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler));
40
37
  }
41
38
  updateSlottedButtons() {
42
39
  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) => {
40
+ var t, a;
41
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector('slot[name="before"]'), r = (a = this.shadowRoot) == null ? void 0 : a.querySelector('slot[name="after"]'), o = (l) => {
42
+ if (!l) return;
43
+ l.assignedNodes({ flatten: !0 }).forEach((i) => {
47
44
  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"));
45
+ const s = i, n = s.tagName.toLowerCase();
46
+ (n === "mui-button" || n === "mui-link") && (s.setAttribute("usage", "input"), s.setAttribute("size", "medium"), s.removeAttribute("variant"), s.removeAttribute("weight"));
50
47
  }
51
48
  });
52
49
  };
53
- o(e), o(a);
50
+ o(e), o(r);
54
51
  });
55
52
  }
56
53
  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 = (
54
+ 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") || "", a = this.getAttribute("value") || "", l = this.getAttribute("placeholder") || "", d = this.getAttribute("id") || `mui-input-${Math.random().toString(36).substr(2, 9)}`, i = this.getAttribute("label") || "", s = this.hasAttribute("hide-label"), n = this.hasAttribute("disabled"), u = s && 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
55
  /*html*/
59
56
  `
60
57
  <style>
@@ -225,7 +222,7 @@ class m extends HTMLElement {
225
222
 
226
223
 
227
224
  </style>
228
- ${i ? `<label for="${d}" class="${l ? "vh" : ""}">${i}</label>` : ""}
225
+ ${i ? `<label for="${d}" class="${s ? "vh" : ""}">${i}</label>` : ""}
229
226
  <div class="input-wrapper">
230
227
  <slot name="before"></slot>
231
228
  <input
@@ -233,10 +230,10 @@ class m extends HTMLElement {
233
230
  type="${o}"
234
231
  name="${t}"
235
232
  id="${d}"
236
- value="${r}"
237
- placeholder="${s}"
233
+ value="${a}"
234
+ placeholder="${l}"
238
235
  ${n ? 'disabled aria-disabled="true"' : ""}
239
- ${c}
236
+ ${u}
240
237
  />
241
238
  <slot name="after"></slot>
242
239
  </div>
@@ -10,41 +10,45 @@ 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
+ e === "value" && o && (o.value = t || ""), e === "disabled" && o && (t === null || t === "false" ? o.removeAttribute("disabled") : o.setAttribute("disabled", "")), ["options", "label", "hide-label", "variant", "disabled"].includes(e) && (this.render(), this.setupListener());
20
+ }
21
+ cleanupListeners() {
22
+ var r;
23
+ const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("select");
24
+ e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
20
25
  }
21
26
  setupListener() {
22
27
  if (!this.shadowRoot) return;
23
28
  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
- }
29
+ e && (this.cleanupListeners(), this._changeHandler = (r) => {
30
+ const t = r.target;
31
+ this.setAttribute("value", t.value);
32
+ const o = {
33
+ detail: { value: t.value },
34
+ bubbles: !0,
35
+ composed: !0
36
+ };
37
+ this.dispatchEvent(new CustomEvent("change", o)), this.dispatchEvent(new CustomEvent("input", o));
38
+ }, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler));
37
39
  }
38
40
  render() {
39
41
  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 = [];
42
+ 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}"` : "";
43
+ let l = [];
42
44
  try {
43
- n = JSON.parse(d);
44
- } catch (t) {
45
- console.error("Invalid JSON in options attribute", t);
45
+ l = JSON.parse(d);
46
+ } catch (a) {
47
+ console.error("Invalid JSON in options attribute", a);
46
48
  }
47
- const u = n.map((t) => `<option value="${t.value}" ${t.value === a ? "selected" : ""}>${t.label}</option>`).join(""), v = (
49
+ const b = l.map(
50
+ (a) => `<option value="${a.value}" ${a.value === o ? "selected" : ""} ${a.disabled ? "disabled" : ""}>${a.label}</option>`
51
+ ).join(""), v = (
48
52
  /*html*/
49
53
  `
50
54
  <style>
@@ -180,14 +184,14 @@ class p extends HTMLElement {
180
184
  /* ========================================================================== */
181
185
 
182
186
  </style>
183
- ${o ? (
187
+ ${t ? (
184
188
  /*html*/
185
- `<label for="${r}" class="${i ? "vh" : ""}">${o}</label>`
189
+ `<label for="${r}" class="${i ? "vh" : ""}">${t}</label>`
186
190
  ) : ""}
187
191
  <div style="position: relative;">
188
- <select class="${h}" part="${this.partMap || ""}" name="${e}" id="${r}" ${b}
192
+ <select class="${h}" part="${this.partMap || ""}" name="${e}" id="${r}" ${u}
189
193
  ${c ? "disabled" : ""}>
190
- ${u}
194
+ ${b}
191
195
  </select>
192
196
  <mui-icon-down-chevron class="chevron" size="x-small"></mui-icon-down-chevron>
193
197
  </div>
@@ -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);