@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.
@@ -3,23 +3,31 @@ import "../mui-icons/check/index.js";
3
3
  import "../mui-icons/info/index.js";
4
4
  import "../mui-icons/warning/index.js";
5
5
  import "../mui-icons/attention/index.js";
6
- function A(n) {
7
- return ["positive", "info", "warning", "attention"].includes(n);
6
+ function b(d) {
7
+ return ["positive", "info", "warning", "attention"].includes(d);
8
8
  }
9
- class x extends HTMLElement {
9
+ class m extends HTMLElement {
10
+ constructor() {
11
+ super(), this.actionSlotListener = null, this.attachShadow({ mode: "open" });
12
+ }
10
13
  static get observedAttributes() {
11
14
  return ["variant"];
12
15
  }
13
- constructor() {
14
- super(), this.attachShadow({ mode: "open" });
15
- }
16
16
  connectedCallback() {
17
- var c;
18
- const a = this.getAttribute("variant") || "positive", p = {
17
+ this.render();
18
+ }
19
+ attributeChangedCallback(i, o, t) {
20
+ i === "variant" && o !== t && this.shadowRoot && this.render();
21
+ }
22
+ render() {
23
+ const i = this.getAttribute("variant") || "positive", o = {
19
24
  success: "positive",
20
25
  error: "attention"
21
- }, t = A(a) ? a : p[a] || "positive";
22
- this.setAttribute("variant", t);
26
+ }, t = b(i) ? i : o[i] || "positive";
27
+ if (i !== t) {
28
+ this.setAttribute("variant", t);
29
+ return;
30
+ }
23
31
  const s = {
24
32
  positive: "polite",
25
33
  info: "polite",
@@ -27,29 +35,27 @@ class x extends HTMLElement {
27
35
  attention: "assertive"
28
36
  };
29
37
  this.setAttribute("role", "alert"), this.setAttribute("aria-live", s[t] || "polite");
30
- const g = {
38
+ const r = {
31
39
  positive: "mui-icon-check",
32
40
  info: "mui-icon-info",
33
41
  warning: "mui-icon-warning",
34
42
  attention: "mui-icon-attention"
35
- }, u = {
43
+ }, a = {
36
44
  positive: "--feedback-positive-icon",
37
45
  info: "--feedback-info-icon",
38
46
  warning: "--feedback-warning-icon",
39
47
  attention: "--feedback-attention-icon"
40
- }, b = {
48
+ }, e = {
41
49
  positive: "--feedback-positive-text",
42
50
  info: "--feedback-info-text",
43
51
  warning: "--feedback-warning-text",
44
52
  attention: "--feedback-attention-text"
45
- }, m = {
53
+ }, n = {
46
54
  positive: "Success!",
47
55
  info: "Info:",
48
56
  warning: "Warning!",
49
57
  attention: "Error!"
50
- };
51
- this.setAttribute("aria-live", s[t]);
52
- const r = g[t], v = u[t], h = b[t], f = m[t], w = (
58
+ }, c = r[t], p = a[t], g = e[t], u = n[t], h = (
53
59
  /*css*/
54
60
  `
55
61
  :host {
@@ -79,7 +85,6 @@ class x extends HTMLElement {
79
85
  ::slotted(mui-button[slot="action"]),
80
86
  ::slotted(mui-link[slot="action"]) { padding-top: var(--space-100); }
81
87
 
82
-
83
88
  @media (min-width: 600px) {
84
89
  :host { gap: var(--alert-gap-horizontal-desktop); }
85
90
  :host([has-action]) { padding-right: var(--space-100); }
@@ -88,7 +93,7 @@ class x extends HTMLElement {
88
93
  }
89
94
 
90
95
  .label {
91
- color: var(${h});
96
+ color: var(${g});
92
97
  font-weight: var(--font-weight-bold);
93
98
  }
94
99
 
@@ -101,41 +106,44 @@ class x extends HTMLElement {
101
106
  }
102
107
 
103
108
  ${["positive", "info", "warning", "attention"].map(
104
- (i) => (
109
+ (l) => (
105
110
  /*css*/
106
111
  `
107
- :host([variant="${i}"]) {
108
- border: var(--feedback-${i}-border);
109
- background: var(--feedback-${i}-background);
112
+ :host([variant="${l}"]) {
113
+ border: var(--feedback-${l}-border);
114
+ background: var(--feedback-${l}-background);
110
115
  }
111
116
  `
112
117
  )
113
118
  ).join("")}
114
119
  `
115
120
  );
116
- if (!this.shadowRoot) return;
117
- this.shadowRoot.innerHTML = /*html*/
121
+ this.shadowRoot && (this.shadowRoot.innerHTML = /*html*/
118
122
  `
119
- <style>${w}</style>
120
- <${r} size="medium" color="var(${v})" class="icon"></${r}>
123
+ <style>${h}</style>
124
+ <${c} size="medium" color="var(${p})" class="icon"></${c}>
121
125
  <mui-body>
122
- <span class="label">${f}</span>
126
+ <span class="label">${u}</span>
123
127
  <slot></slot>
124
128
  </mui-body>
125
129
  <slot name="action"></slot>
126
- `;
127
- const o = (c = this.shadowRoot) == null ? void 0 : c.querySelector('slot[name="action"]');
128
- if (o) {
129
- const i = () => {
130
- const k = o.assignedElements();
131
- let l = !1;
132
- k.forEach((e) => {
133
- const d = e.tagName;
134
- (d === "MUI-BUTTON" || d === "MUI-LINK") && (l = !0, e.setAttribute("variant", "tertiary"), e.classList.add("alert-slot", `alert-${t}-slot`));
135
- }), l ? this.setAttribute("has-action", "") : this.removeAttribute("has-action");
130
+ `, this.setupActionSlot());
131
+ }
132
+ setupActionSlot() {
133
+ var o;
134
+ const i = (o = this.shadowRoot) == null ? void 0 : o.querySelector('slot[name="action"]');
135
+ if (i) {
136
+ this.actionSlotListener && i.removeEventListener("slotchange", this.actionSlotListener);
137
+ const t = () => {
138
+ const s = this.getAttribute("variant") || "positive", r = i.assignedElements();
139
+ let a = !1;
140
+ r.forEach((e) => {
141
+ const n = e.tagName;
142
+ (n === "MUI-BUTTON" || n === "MUI-LINK") && (a = !0, e.setAttribute("variant", "tertiary"), e.classList.add("alert-slot", `alert-${s}-slot`));
143
+ }), a ? this.setAttribute("has-action", "") : this.removeAttribute("has-action");
136
144
  };
137
- o.addEventListener("slotchange", i), requestAnimationFrame(i);
145
+ this.actionSlotListener = t, i.addEventListener("slotchange", this.actionSlotListener), requestAnimationFrame(t);
138
146
  }
139
147
  }
140
148
  }
141
- customElements.get("mui-alert") || customElements.define("mui-alert", x);
149
+ customElements.get("mui-alert") || customElements.define("mui-alert", m);
@@ -55,6 +55,11 @@ class r extends HTMLElement {
55
55
  :host([variant="default"]) p {
56
56
  color: var(--text-color);
57
57
  }
58
+
59
+ :host([variant="optional"]) p {
60
+ color: var(--text-color-optional);
61
+ }
62
+
58
63
  :host([variant="success"]) p {
59
64
  color: var(--text-color-success);
60
65
  }
@@ -68,6 +73,9 @@ class r extends HTMLElement {
68
73
  :host([variant="default"]) ::slotted(.mui-icon) {
69
74
  fill: var(--text-color);
70
75
  }
76
+ :host([variant="optional"]) ::slotted(.mui-icon) {
77
+ fill: var(--text-color-optional);
78
+ }
71
79
  :host([variant="success"]) ::slotted(.mui-icon) {
72
80
  fill: var(--text-color-success);
73
81
  }
@@ -1,4 +1,4 @@
1
- import { getPartMap as u } from "../../utils/part-map/index.js";
1
+ import { getPartMap as b } from "../../utils/part-map/index.js";
2
2
  class h extends HTMLElement {
3
3
  static get observedAttributes() {
4
4
  return ["onclick", "type", "aria-label", "disabled", "variant", "size", "usage"];
@@ -8,7 +8,7 @@ class h extends HTMLElement {
8
8
  }
9
9
  async connectedCallback() {
10
10
  if (this.hasAttribute("size") || this.setAttribute("size", "medium"), await this.waitForPartMap(), !this.shadowRoot) return;
11
- let a = (
11
+ let o = (
12
12
  /*html*/
13
13
  `
14
14
  <style>
@@ -24,7 +24,7 @@ class h extends HTMLElement {
24
24
  border: none;
25
25
  cursor: pointer;
26
26
  width: 100%;
27
- border-radius: var(--action-radius);
27
+ border-radius: var(--action-radius-medium);
28
28
  padding: var(--action-padding);
29
29
  text-decoration: none;
30
30
  line-height: var(--action-line-height);
@@ -524,7 +524,7 @@ class h extends HTMLElement {
524
524
  </style>
525
525
 
526
526
  <button
527
- part="${u("text", "spacing", "layout", "visual")}"
527
+ part="${b("text", "spacing", "layout", "visual")}"
528
528
  onclick="${this.getAttribute("onclick")}"
529
529
  type="${this.getAttribute("type") || "button"}"
530
530
  aria-label="${this.getAttribute("aria-label") || ""}"
@@ -537,23 +537,23 @@ class h extends HTMLElement {
537
537
 
538
538
  `
539
539
  );
540
- this.shadowRoot.innerHTML = a, await customElements.whenDefined("mui-button"), requestAnimationFrame(() => {
541
- const i = this.shadowRoot;
542
- if (!i) return;
543
- const t = i.querySelector("slot:not([name])"), n = i.querySelector('slot[name="before"]'), r = i.querySelector('slot[name="after"]'), o = (l) => l ? l.assignedNodes({ flatten: !0 }).some((s) => {
540
+ this.shadowRoot.innerHTML = o, await customElements.whenDefined("mui-button"), requestAnimationFrame(() => {
541
+ const n = this.shadowRoot;
542
+ if (!n) return;
543
+ const e = n.querySelector("slot:not([name])"), t = n.querySelector('slot[name="before"]'), i = n.querySelector('slot[name="after"]'), a = (l) => l ? l.assignedNodes({ flatten: !0 }).some((s) => {
544
544
  var c;
545
545
  return s.nodeType === Node.ELEMENT_NODE || s.nodeType === Node.TEXT_NODE && !!((c = s.textContent) != null && c.trim());
546
- }) : !1, d = o(n), v = o(r);
547
- this.classList.toggle("has-before", d), this.classList.toggle("has-after", v);
548
- const b = (t == null ? void 0 : t.assignedNodes({ flatten: !0 })) ?? [];
549
- b.every((l) => {
546
+ }) : !1, d = a(t), u = a(i);
547
+ this.classList.toggle("has-before", d), this.classList.toggle("has-after", u);
548
+ const v = (e == null ? void 0 : e.assignedNodes({ flatten: !0 })) ?? [];
549
+ v.every((l) => {
550
550
  var s;
551
551
  if (l.nodeType === Node.ELEMENT_NODE) {
552
552
  const c = l;
553
553
  return c.tagName.toLowerCase() === "svg" || c.classList.contains("mui-icon");
554
554
  }
555
555
  return l.nodeType === Node.TEXT_NODE && !((s = l.textContent) != null && s.trim());
556
- }) ? (this.setAttribute("icon-only", ""), this.updateIconSizes(b, !0)) : (this.removeAttribute("icon-only"), [n, t, r].forEach((s) => {
556
+ }) ? (this.setAttribute("icon-only", ""), this.updateIconSizes(v, !0)) : (this.removeAttribute("icon-only"), [t, e, i].forEach((s) => {
557
557
  if (s) {
558
558
  const c = s.assignedNodes({ flatten: !0 });
559
559
  this.updateIconSizes(c, !1), this.updateAvatarSizes(c);
@@ -561,60 +561,65 @@ class h extends HTMLElement {
561
561
  }));
562
562
  });
563
563
  }
564
- attributeChangedCallback(e, a, i) {
565
- e === "size" && a !== i && this.shadowRoot && requestAnimationFrame(() => {
564
+ attributeChangedCallback(r, o, n) {
565
+ var e;
566
+ if (r === "disabled") {
567
+ const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("button");
568
+ t && (this.hasAttribute("disabled") ? t.setAttribute("disabled", "") : t.removeAttribute("disabled"));
569
+ }
570
+ r === "size" && o !== n && this.shadowRoot && requestAnimationFrame(() => {
566
571
  const t = this.shadowRoot;
567
572
  if (!t) return;
568
- const n = [
573
+ const i = [
569
574
  t.querySelector("slot:not([name])"),
570
575
  t.querySelector('slot[name="before"]'),
571
576
  t.querySelector('slot[name="after"]')
572
- ], r = this.hasAttribute("icon-only");
573
- n.forEach((o) => {
574
- if (o) {
575
- const d = o.assignedNodes({ flatten: !0 });
576
- this.updateIconSizes(d, r), this.updateAvatarSizes(d);
577
+ ], a = this.hasAttribute("icon-only");
578
+ i.forEach((d) => {
579
+ if (d) {
580
+ const u = d.assignedNodes({ flatten: !0 });
581
+ this.updateIconSizes(u, a), this.updateAvatarSizes(u);
577
582
  }
578
583
  });
579
584
  });
580
585
  }
581
586
  // Update avatar sizes based on button size
582
- updateAvatarSizes(e) {
583
- const a = this.getAttribute("size") || "medium", t = {
587
+ updateAvatarSizes(r) {
588
+ const o = this.getAttribute("size") || "medium", e = {
584
589
  "x-small": "x-small",
585
590
  small: "x-small",
586
591
  medium: "small",
587
592
  large: "medium"
588
- }[a] || "small";
589
- e.forEach((n) => {
590
- if (n.nodeType === Node.ELEMENT_NODE) {
591
- const r = n;
592
- r.tagName.toLowerCase() === "mui-avatar" && r.setAttribute("size", t);
593
+ }[o] || "small";
594
+ r.forEach((t) => {
595
+ if (t.nodeType === Node.ELEMENT_NODE) {
596
+ const i = t;
597
+ i.tagName.toLowerCase() === "mui-avatar" && i.setAttribute("size", e);
593
598
  }
594
599
  });
595
600
  }
596
- updateIconSizes(e, a) {
597
- const i = this.getAttribute("size") || "medium", n = {
601
+ updateIconSizes(r, o) {
602
+ const n = this.getAttribute("size") || "medium", t = {
598
603
  "x-small": "x-small",
599
604
  small: "x-small",
600
- medium: a ? "medium" : "small",
605
+ medium: o ? "medium" : "small",
601
606
  // small for regular, medium for icon-only
602
- large: a ? "large" : "medium"
603
- }[i] || "small";
604
- e.forEach((r) => {
605
- if (r.nodeType === Node.ELEMENT_NODE) {
606
- const o = r;
607
- (o.tagName.toLowerCase() === "svg" || o.classList.contains("mui-icon") || o.tagName.toLowerCase() === "mui-icon") && !o.hasAttribute("size") && o.setAttribute("size", n);
607
+ large: o ? "large" : "medium"
608
+ }[n] || "small";
609
+ r.forEach((i) => {
610
+ if (i.nodeType === Node.ELEMENT_NODE) {
611
+ const a = i;
612
+ (a.tagName.toLowerCase() === "svg" || a.classList.contains("mui-icon") || a.tagName.toLowerCase() === "mui-icon") && !a.hasAttribute("size") && a.setAttribute("size", t);
608
613
  }
609
614
  });
610
615
  }
611
616
  waitForPartMap() {
612
- return new Promise((e) => {
613
- if (typeof u == "function") return e();
614
- const a = () => {
615
- typeof u == "function" ? e() : requestAnimationFrame(a);
617
+ return new Promise((r) => {
618
+ if (typeof b == "function") return r();
619
+ const o = () => {
620
+ typeof b == "function" ? r() : requestAnimationFrame(o);
616
621
  };
617
- a();
622
+ o();
618
623
  });
619
624
  }
620
625
  }
@@ -1,10 +1,48 @@
1
- class u extends HTMLElement {
1
+ class l extends HTMLElement {
2
+ static get observedAttributes() {
3
+ return ["condensed"];
4
+ }
2
5
  constructor() {
3
6
  super(), this.attachShadow({ mode: "open" });
4
7
  }
5
8
  connectedCallback() {
9
+ this.render();
10
+ }
11
+ attributeChangedCallback(o, r, a) {
12
+ o === "condensed" && this.updateSlottedContent();
13
+ }
14
+ updateSlottedContent() {
15
+ requestAnimationFrame(() => {
16
+ if (!this.shadowRoot) return;
17
+ const o = this.shadowRoot.querySelector("slot");
18
+ if (!o) return;
19
+ const r = o.assignedNodes({ flatten: !0 });
20
+ this.classList.remove("inner-space", "has-card-slat-group", "has-accordion-slat-group");
21
+ let a = !1;
22
+ r.forEach((c) => {
23
+ if (c.nodeType === Node.ELEMENT_NODE) {
24
+ const t = c, i = t.tagName.toLowerCase() === "mui-accordion-group" ? t : t.querySelector("mui-accordion-group");
25
+ i instanceof HTMLElement && (i.querySelectorAll("mui-accordion-block").forEach((s) => {
26
+ s.classList.add("card-slot");
27
+ }), a = !0), (t.tagName.toLowerCase() === "mui-slat" ? [t] : Array.from(t.querySelectorAll("mui-slat"))).forEach((e) => {
28
+ const s = e.getAttribute("variant");
29
+ (s === "action" || s === "row") && (e.classList.add("card-slot"), this.hasAttribute("condensed") ? e.classList.add("condensed-slot") : e.classList.remove("condensed-slot"));
30
+ });
31
+ const n = t.tagName.toLowerCase() === "mui-table" ? t : t.querySelector("mui-table");
32
+ n instanceof HTMLElement && (n.querySelectorAll("mui-cell").forEach((s) => {
33
+ s.classList.add("card-slot");
34
+ }), a = !0);
35
+ const d = t.tagName.toLowerCase() === "mui-slat-group" ? [t] : Array.from(t.querySelectorAll("mui-slat-group"));
36
+ d.length && (a = !0, d.forEach((e) => {
37
+ e.setAttribute("usage", "card"), e.closest("mui-accordion-block") ? this.classList.add("has-accordion-slat-group") : this.classList.add("inner-space", "has-card-slat-group");
38
+ }));
39
+ }
40
+ }), !a && !this.hasAttribute("condensed") && this.classList.add("inner-space");
41
+ });
42
+ }
43
+ render() {
6
44
  if (!this.shadowRoot) return;
7
- const l = (
45
+ const o = (
8
46
  /*html*/
9
47
  `
10
48
  <style>
@@ -35,32 +73,7 @@ class u extends HTMLElement {
35
73
  <slot></slot>
36
74
  `
37
75
  );
38
- this.shadowRoot.innerHTML = l, requestAnimationFrame(() => {
39
- if (!this.shadowRoot) return;
40
- const a = this.shadowRoot.querySelector("slot");
41
- if (!a) return;
42
- const d = a.assignedNodes({ flatten: !0 });
43
- let e = !1;
44
- d.forEach((c) => {
45
- if (c.nodeType === Node.ELEMENT_NODE) {
46
- const t = c, i = t.tagName.toLowerCase() === "mui-accordion-group" ? t : t.querySelector("mui-accordion-group");
47
- i instanceof HTMLElement && (i.querySelectorAll("mui-accordion-block").forEach((o) => {
48
- o.classList.add("card-slot");
49
- }), e = !0), (t.tagName.toLowerCase() === "mui-slat" ? [t] : Array.from(t.querySelectorAll("mui-slat"))).forEach((s) => {
50
- const o = s.getAttribute("variant");
51
- (o === "action" || o === "row") && (s.classList.add("card-slot"), this.hasAttribute("condensed") && s.classList.add("condensed-slot"));
52
- });
53
- const r = t.tagName.toLowerCase() === "mui-table" ? t : t.querySelector("mui-table");
54
- r instanceof HTMLElement && (r.querySelectorAll("mui-cell").forEach((o) => {
55
- o.classList.add("card-slot");
56
- }), e = !0);
57
- const n = t.tagName.toLowerCase() === "mui-slat-group" ? [t] : Array.from(t.querySelectorAll("mui-slat-group"));
58
- n.length && (e = !0, n.forEach((s) => {
59
- s.setAttribute("usage", "card"), s.closest("mui-accordion-block") ? this.classList.add("has-accordion-slat-group") : this.classList.add("inner-space", "has-card-slat-group");
60
- }));
61
- }
62
- }), !e && !this.hasAttribute("condensed") && this.classList.add("inner-space");
63
- });
76
+ this.shadowRoot.innerHTML = o, this.updateSlottedContent();
64
77
  }
65
78
  }
66
- customElements.get("mui-card-body") || customElements.define("mui-card-body", u);
79
+ customElements.get("mui-card-body") || customElements.define("mui-card-body", l);
@@ -1,5 +1,5 @@
1
1
  import "../mui-body/index.js";
2
- class d extends HTMLElement {
2
+ class a extends HTMLElement {
3
3
  static get observedAttributes() {
4
4
  return ["checked", "disabled", "id", "indeterminate"];
5
5
  }
@@ -9,55 +9,54 @@ class d extends HTMLElement {
9
9
  connectedCallback() {
10
10
  this.render(), this.setupListener();
11
11
  }
12
- attributeChangedCallback(e, r, i) {
13
- var c, o, s;
12
+ disconnectedCallback() {
13
+ this.cleanupListeners();
14
+ }
15
+ attributeChangedCallback(e, t, c) {
16
+ var r, o, s;
14
17
  if (e === "checked") {
15
- const t = (c = this.shadowRoot) == null ? void 0 : c.querySelector("input");
16
- if (!t) return;
17
- t.checked = i !== null;
18
+ const i = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
19
+ if (!i) return;
20
+ i.checked = c !== null;
18
21
  }
19
22
  if (e === "disabled") {
20
- const t = (o = this.shadowRoot) == null ? void 0 : o.querySelector("input");
21
- if (!t) return;
22
- t.disabled = i !== null;
23
+ const i = (o = this.shadowRoot) == null ? void 0 : o.querySelector("input");
24
+ if (!i) return;
25
+ i.disabled = c !== null;
23
26
  }
24
27
  if (e === "indeterminate") {
25
- const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector("input");
26
- if (!t) return;
27
- const n = i !== null;
28
- t.indeterminate = n, n && (t.checked = !0, this.setAttribute("checked", ""));
28
+ const i = (s = this.shadowRoot) == null ? void 0 : s.querySelector("input");
29
+ if (!i) return;
30
+ const n = c !== null;
31
+ i.indeterminate = n, n && (i.checked = !0, this.setAttribute("checked", ""));
29
32
  }
30
33
  "id".includes(e) && (this.render(), this.setupListener());
31
34
  }
35
+ cleanupListeners() {
36
+ var t;
37
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
38
+ e && this._changeHandler && e.removeEventListener("change", this._changeHandler);
39
+ }
32
40
  setupListener() {
33
- var r;
34
- const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
35
- e && (e.addEventListener("change", (i) => {
36
- const c = i.target;
37
- this.dispatchEvent(
38
- new CustomEvent("change", {
39
- detail: { checked: c.checked },
40
- bubbles: !0,
41
- composed: !0
42
- })
43
- ), c.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked");
44
- }), e.indeterminate = this.hasAttribute("indeterminate"), e.addEventListener("change", (i) => {
45
- const c = i.target;
46
- this.dispatchEvent(
41
+ var t;
42
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
43
+ e && (this.cleanupListeners(), e.indeterminate = this.hasAttribute("indeterminate"), this._changeHandler = (c) => {
44
+ const r = c.target;
45
+ r.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.removeAttribute("indeterminate"), this.dispatchEvent(
47
46
  new CustomEvent("change", {
48
- detail: { checked: c.checked },
47
+ detail: { checked: r.checked },
49
48
  bubbles: !0,
50
49
  composed: !0
51
50
  })
52
- ), this.removeAttribute("indeterminate"), c.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked");
53
- }));
51
+ );
52
+ }, e.addEventListener("change", this._changeHandler));
54
53
  }
55
54
  render() {
56
- const e = this.getAttribute("id") || `mui-checkbox-${Math.random().toString(36).substr(2, 9)}`, r = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), c = `
55
+ const e = this.getAttribute("id") || `mui-checkbox-${Math.random().toString(36).substr(2, 9)}`, t = this.hasAttribute("checked"), c = this.hasAttribute("disabled"), r = `
57
56
  <mui-icon-checkmark class="icon" size="x-small" color="inverted"></mui-icon-checkmark>
58
- `, o = this.hasAttribute("indeterminate"), t = o ? `
57
+ `, o = this.hasAttribute("indeterminate"), i = o ? `
59
58
  <mui-icon-subtract class="icon" size="x-small" color="inverted"></mui-icon-subtract>
60
- ` : c, n = this.innerHTML.trim().length > 0;
59
+ ` : r, n = this.innerHTML.trim().length > 0;
61
60
  this.shadowRoot.innerHTML = /*html*/
62
61
  `
63
62
  <style>
@@ -139,22 +138,22 @@ class d extends HTMLElement {
139
138
  type="checkbox"
140
139
  id="${e}"
141
140
  ${o ? "indeterminate" : ""}
142
- ${o || r ? "checked" : ""}
143
- ${i ? "disabled" : ""}
141
+ ${o || t ? "checked" : ""}
142
+ ${c ? "disabled" : ""}
144
143
  />
145
- ${t}
144
+ ${i}
146
145
  </span>
147
146
  ${n ? '<mui-body size="small"><slot></slot></mui-body>' : ""}
148
147
  </label>
149
148
  `;
150
149
  }
151
150
  get checked() {
152
- var r;
153
- const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
151
+ var t;
152
+ const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
154
153
  return (e == null ? void 0 : e.checked) ?? !1;
155
154
  }
156
155
  set checked(e) {
157
156
  e ? this.setAttribute("checked", "") : this.removeAttribute("checked");
158
157
  }
159
158
  }
160
- customElements.get("mui-checkbox") || customElements.define("mui-checkbox", d);
159
+ customElements.get("mui-checkbox") || customElements.define("mui-checkbox", a);
@@ -13,6 +13,10 @@ class l extends HTMLElement {
13
13
  const s = (
14
14
  /*css*/
15
15
  `
16
+ :host {
17
+ display: contents;
18
+ }
19
+
16
20
  dialog {
17
21
  border: none;
18
22
  width: ${this.getAttribute("width") || "350px"};
@@ -1,7 +1,13 @@
1
1
  import "../mui-button/index.js";
2
2
  class r extends HTMLElement {
3
3
  constructor() {
4
- super(), this.attachShadow({ mode: "open" }), this.acceptedFileTypes = this.getAttribute("acceptedFileTypes") || "", this.currentFileName = this.getAttribute("currentFileName") || "", this.selectedFileName = null, this.render(), this.cacheElements(), this.attachEvents();
4
+ super(), this.attachShadow({ mode: "open" }), this.acceptedFileTypes = this.getAttribute("acceptedFileTypes") || "", this.currentFileName = this.getAttribute("currentFileName") || "", this.selectedFileName = null;
5
+ }
6
+ connectedCallback() {
7
+ this.render(), this.cacheElements(), this.attachEvents();
8
+ }
9
+ disconnectedCallback() {
10
+ this.cleanupListeners();
5
11
  }
6
12
  render() {
7
13
  this.shadowRoot && (this.shadowRoot.innerHTML = /*html*/
@@ -81,10 +87,13 @@ class r extends HTMLElement {
81
87
  cacheElements() {
82
88
  this.shadowRoot && (this.wrapper = this.shadowRoot.querySelector(".wrapper"), this.label = this.shadowRoot.querySelector(".label"), this.button = this.shadowRoot.querySelector(".button"), this.input = this.shadowRoot.querySelector('input[type="file"]'));
83
89
  }
90
+ cleanupListeners() {
91
+ this.wrapper && this._wrapperClickHandler && this.wrapper.removeEventListener("click", this._wrapperClickHandler), this.input && this._inputChangeHandler && this.input.removeEventListener("change", this._inputChangeHandler);
92
+ }
84
93
  attachEvents() {
85
- this.wrapper.addEventListener("click", () => {
94
+ this._wrapperClickHandler = () => {
86
95
  this.input.click();
87
- }), this.input.addEventListener("change", this.handleFileChange.bind(this));
96
+ }, this._inputChangeHandler = this.handleFileChange.bind(this), this.wrapper.addEventListener("click", this._wrapperClickHandler), this.input.addEventListener("change", this._inputChangeHandler);
88
97
  }
89
98
  handleFileChange(i) {
90
99
  var t;