@muibook/components 19.2.0 → 19.3.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,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 o = (
11
+ let t = (
12
12
  /*html*/
13
13
  `
14
14
  <style>
@@ -662,6 +662,35 @@ class h extends HTMLElement {
662
662
  padding-left: var(--action-before-slot-padding-large);
663
663
  }
664
664
 
665
+ :host([avatar-only]) {
666
+ width: auto;
667
+ display: flex;
668
+ }
669
+
670
+ :host([avatar-only]) button,
671
+ :host([avatar-only]) button:hover,
672
+ :host([avatar-only]) button:focus,
673
+ :host([avatar-only]) button:focus-visible,
674
+ :host([avatar-only]) button:disabled {
675
+ width: auto;
676
+ min-width: 0;
677
+ min-height: 0;
678
+ padding: var(--space-000);
679
+ border: none;
680
+ background: transparent;
681
+ display: inline-flex;
682
+ align-items: center;
683
+ justify-content: center;
684
+ gap: var(--space-000);
685
+ line-height: 0;
686
+ border-radius: 999rem;
687
+ }
688
+
689
+ :host([avatar-only]) button ::slotted(mui-avatar) {
690
+ margin-right: var(--space-000);
691
+ margin-left: var(--space-000);
692
+ }
693
+
665
694
 
666
695
  </style>
667
696
 
@@ -679,106 +708,103 @@ class h extends HTMLElement {
679
708
 
680
709
  `
681
710
  );
682
- this.shadowRoot.innerHTML = o, await customElements.whenDefined("mui-button"), requestAnimationFrame(() => {
683
- const s = this.shadowRoot;
684
- if (!s) return;
685
- const e = s.querySelector("slot:not([name])"), t = s.querySelector('slot[name="before"]'), a = s.querySelector('slot[name="after"]'), i = (d) => d ? d.assignedNodes({ flatten: !0 }).some((n) => {
686
- var l;
687
- return n.nodeType === Node.ELEMENT_NODE || n.nodeType === Node.TEXT_NODE && !!((l = n.textContent) != null && l.trim());
688
- }) : !1, c = i(t), u = i(a);
689
- this.toggleAttribute("has-before", c), this.toggleAttribute("has-after", u);
690
- const v = (e == null ? void 0 : e.assignedNodes({ flatten: !0 })) ?? [];
691
- v.every((d) => {
692
- var n;
693
- if (d.nodeType === Node.ELEMENT_NODE) {
694
- const l = d;
695
- return l.tagName.toLowerCase() === "svg" || l.classList.contains("mui-icon");
696
- }
697
- return d.nodeType === Node.TEXT_NODE && !((n = d.textContent) != null && n.trim());
698
- }) ? (this.setAttribute("icon-only", ""), this.updateIconSizes(v, !0)) : (this.removeAttribute("icon-only"), [t, e, a].forEach((n) => {
699
- if (n) {
700
- const l = n.assignedNodes({ flatten: !0 });
701
- this.updateIconSizes(l, !1), this.updateAvatarSizes(l), this.updateBadgeSizes(l);
702
- }
703
- }));
704
- });
711
+ this.shadowRoot.innerHTML = t, await customElements.whenDefined("mui-button"), [
712
+ this.shadowRoot.querySelector("slot:not([name])"),
713
+ this.shadowRoot.querySelector('slot[name="before"]'),
714
+ this.shadowRoot.querySelector('slot[name="after"]')
715
+ ].forEach((r) => r == null ? void 0 : r.addEventListener("slotchange", () => this.syncButtonState())), requestAnimationFrame(() => this.syncButtonState());
716
+ }
717
+ attributeChangedCallback(o, t, n) {
718
+ var r;
719
+ if (o === "disabled") {
720
+ const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("button");
721
+ e && (this.hasAttribute("disabled") ? e.setAttribute("disabled", "") : e.removeAttribute("disabled"));
722
+ }
723
+ o === "size" && t !== n && this.shadowRoot && requestAnimationFrame(() => this.syncButtonState());
705
724
  }
706
- attributeChangedCallback(r, o, s) {
707
- var e;
708
- if (r === "disabled") {
709
- const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("button");
710
- t && (this.hasAttribute("disabled") ? t.setAttribute("disabled", "") : t.removeAttribute("disabled"));
711
- }
712
- r === "size" && o !== s && this.shadowRoot && requestAnimationFrame(() => {
713
- const t = this.shadowRoot;
714
- if (!t) return;
715
- const a = [
716
- t.querySelector("slot:not([name])"),
717
- t.querySelector('slot[name="before"]'),
718
- t.querySelector('slot[name="after"]')
719
- ], i = this.hasAttribute("icon-only");
720
- a.forEach((c) => {
721
- if (c) {
722
- const u = c.assignedNodes({ flatten: !0 });
723
- this.updateIconSizes(u, i), this.updateAvatarSizes(u), this.updateBadgeSizes(u);
724
- }
725
- });
725
+ syncButtonState() {
726
+ const o = this.shadowRoot;
727
+ if (!o) return;
728
+ const t = o.querySelector("slot:not([name])"), n = o.querySelector('slot[name="before"]'), r = o.querySelector('slot[name="after"]'), e = (a) => a ? a.assignedNodes({ flatten: !0 }).some((i) => {
729
+ var d;
730
+ return i.nodeType === Node.ELEMENT_NODE || i.nodeType === Node.TEXT_NODE && !!((d = i.textContent) != null && d.trim());
731
+ }) : !1, s = e(n), l = e(r);
732
+ this.toggleAttribute("has-before", s), this.toggleAttribute("has-after", l);
733
+ const c = (t == null ? void 0 : t.assignedNodes({ flatten: !0 })) ?? [], v = (t == null ? void 0 : t.assignedElements({ flatten: !0 })) ?? [], u = v.length === 1 && v[0].tagName.toLowerCase() === "mui-avatar" && c.every((a) => {
734
+ var i;
735
+ return a.nodeType === Node.TEXT_NODE ? !((i = a.textContent) != null && i.trim()) : a.nodeType === Node.ELEMENT_NODE ? a.tagName.toLowerCase() === "mui-avatar" : !1;
736
+ });
737
+ if (this.toggleAttribute("avatar-only", u), !u && c.every((a) => {
738
+ var i;
739
+ if (a.nodeType === Node.ELEMENT_NODE) {
740
+ const d = a;
741
+ return d.tagName.toLowerCase() === "svg" || d.classList.contains("mui-icon");
742
+ }
743
+ return a.nodeType === Node.TEXT_NODE && !((i = a.textContent) != null && i.trim());
744
+ })) {
745
+ this.setAttribute("icon-only", ""), this.updateIconSizes(c, !0);
746
+ return;
747
+ }
748
+ this.removeAttribute("icon-only"), [n, t, r].forEach((a) => {
749
+ if (!a) return;
750
+ const i = a.assignedNodes({ flatten: !0 });
751
+ this.updateIconSizes(i, !1), u || this.updateAvatarSizes(i), this.updateBadgeSizes(i);
726
752
  });
727
753
  }
728
754
  // Update avatar sizes based on button size
729
- updateAvatarSizes(r) {
730
- const o = this.getAttribute("size") || "medium", e = {
755
+ updateAvatarSizes(o) {
756
+ const t = this.getAttribute("size") || "medium", r = {
731
757
  "xx-small": "x-small",
732
758
  "x-small": "x-small",
733
759
  small: "x-small",
734
760
  medium: "small",
735
761
  large: "medium"
736
- }[o] || "small";
737
- r.forEach((t) => {
738
- if (t.nodeType === Node.ELEMENT_NODE) {
739
- const a = t;
740
- a.tagName.toLowerCase() === "mui-avatar" && a.setAttribute("size", e);
762
+ }[t] || "small";
763
+ o.forEach((e) => {
764
+ if (e.nodeType === Node.ELEMENT_NODE) {
765
+ const s = e;
766
+ s.tagName.toLowerCase() === "mui-avatar" && s.setAttribute("size", r);
741
767
  }
742
768
  });
743
769
  }
744
- updateIconSizes(r, o) {
745
- const s = this.getAttribute("size") || "medium", t = {
770
+ updateIconSizes(o, t) {
771
+ const n = this.getAttribute("size") || "medium", e = {
746
772
  "xx-small": "xx-small",
747
773
  "x-small": "x-small",
748
774
  small: "x-small",
749
- medium: o ? "medium" : "small",
775
+ medium: t ? "medium" : "small",
750
776
  // small for regular, medium for icon-only
751
- large: o ? "large" : "medium"
752
- }[s] || "small";
753
- r.forEach((a) => {
754
- if (a.nodeType === Node.ELEMENT_NODE) {
755
- const i = a;
756
- (i.tagName.toLowerCase() === "svg" || i.classList.contains("mui-icon") || i.tagName.toLowerCase() === "mui-icon") && !i.hasAttribute("size") && i.setAttribute("size", t);
777
+ large: t ? "large" : "medium"
778
+ }[n] || "small";
779
+ o.forEach((s) => {
780
+ if (s.nodeType === Node.ELEMENT_NODE) {
781
+ const l = s;
782
+ (l.tagName.toLowerCase() === "svg" || l.classList.contains("mui-icon") || l.tagName.toLowerCase() === "mui-icon") && !l.hasAttribute("size") && l.setAttribute("size", e);
757
783
  }
758
784
  });
759
785
  }
760
- updateBadgeSizes(r) {
761
- const o = this.getAttribute("size") || "medium", e = {
786
+ updateBadgeSizes(o) {
787
+ const t = this.getAttribute("size") || "medium", r = {
762
788
  "xx-small": "x-small",
763
789
  "x-small": "x-small",
764
790
  small: "small",
765
791
  medium: "medium",
766
792
  large: "large"
767
- }[o] || "medium";
768
- r.forEach((t) => {
769
- if (t.nodeType === Node.ELEMENT_NODE) {
770
- const a = t;
771
- a.tagName.toLowerCase() === "mui-badge" && a.setAttribute("size", e);
793
+ }[t] || "medium";
794
+ o.forEach((e) => {
795
+ if (e.nodeType === Node.ELEMENT_NODE) {
796
+ const s = e;
797
+ s.tagName.toLowerCase() === "mui-badge" && s.setAttribute("size", r);
772
798
  }
773
799
  });
774
800
  }
775
801
  waitForPartMap() {
776
- return new Promise((r) => {
777
- if (typeof b == "function") return r();
778
- const o = () => {
779
- typeof b == "function" ? r() : requestAnimationFrame(o);
802
+ return new Promise((o) => {
803
+ if (typeof b == "function") return o();
804
+ const t = () => {
805
+ typeof b == "function" ? o() : requestAnimationFrame(t);
780
806
  };
781
- o();
807
+ t();
782
808
  });
783
809
  }
784
810
  }
@@ -1,6 +1,6 @@
1
1
 
2
2
  /* ================================================================================================== */
3
- /* Don't edit directly • Generated on Tue, 05 May 2026 05:23:52 GMT • muibook.com */
3
+ /* Don't edit directly • Generated on Thu, 07 May 2026 04:13:10 GMT • muibook.com */
4
4
  /* ================================================================================================== */
5
5
 
6
6
  /* ================================================================================================== */