@muibook/components 9.0.0 → 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.
@@ -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>
@@ -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
  }
@@ -12,9 +12,19 @@ class m extends HTMLElement {
12
12
  this.cleanupListeners();
13
13
  }
14
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()));
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
+ }
18
28
  }
19
29
  cleanupListeners() {
20
30
  var r;
@@ -37,13 +47,13 @@ class m extends HTMLElement {
37
47
  }
38
48
  updateSlottedButtons() {
39
49
  requestAnimationFrame(() => {
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) => {
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) => {
42
52
  if (!l) return;
43
53
  l.assignedNodes({ flatten: !0 }).forEach((i) => {
44
54
  if (i.nodeType === Node.ELEMENT_NODE) {
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"));
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"));
47
57
  }
48
58
  });
49
59
  };
@@ -51,7 +61,7 @@ class m extends HTMLElement {
51
61
  });
52
62
  }
53
63
  render() {
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 = (
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 = (
55
65
  /*html*/
56
66
  `
57
67
  <style>
@@ -222,7 +232,7 @@ class m extends HTMLElement {
222
232
 
223
233
 
224
234
  </style>
225
- ${i ? `<label for="${d}" class="${s ? "vh" : ""}">${i}</label>` : ""}
235
+ ${i ? `<label for="${d}" class="${a ? "vh" : ""}">${i}</label>` : ""}
226
236
  <div class="input-wrapper">
227
237
  <slot name="before"></slot>
228
238
  <input
@@ -230,7 +240,7 @@ class m extends HTMLElement {
230
240
  type="${o}"
231
241
  name="${t}"
232
242
  id="${d}"
233
- value="${a}"
243
+ value="${s}"
234
244
  placeholder="${l}"
235
245
  ${n ? 'disabled aria-disabled="true"' : ""}
236
246
  ${u}
@@ -16,7 +16,15 @@ class p extends HTMLElement {
16
16
  attributeChangedCallback(e, r, t) {
17
17
  if (!this.shadowRoot || r === t) return;
18
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());
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());
20
28
  }
21
29
  cleanupListeners() {
22
30
  var r;
@@ -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,6 +1,6 @@
1
1
 
2
2
  /* ================================================================================================== */
3
- /* Don't edit directly • Generated on Wed, 31 Dec 2025 01:53:05 GMT • muibook.com */
3
+ /* Don't edit directly • Generated on Thu, 08 Jan 2026 02:39:52 GMT • muibook.com */
4
4
  /* ================================================================================================== */
5
5
 
6
6
  /* ================================================================================================== */
@@ -169,7 +169,7 @@ html[data-theme="light"] {
169
169
  --text-color-success: var(--green-600);
170
170
  --text-color-warning: var(--orange-600);
171
171
  --text-color-error: var(--red-600);
172
- --text-color-optional: var(--grey-600);
172
+ --text-color-optional: var(--grey-500);
173
173
  /* Overlay */
174
174
  --backdrop-overlay: var(--black-opacity-70);
175
175
  /* ================================================================================================== */
@@ -426,7 +426,7 @@ html[data-theme="dark"] {
426
426
  --text-color-success: var(--green-400);
427
427
  --text-color-warning: var(--orange-400);
428
428
  --text-color-error: var(--red-400);
429
- --text-color-optional: var(--grey-300);
429
+ --text-color-optional: var(--grey-400);
430
430
  /* Overlay */
431
431
  --backdrop-overlay: var(--black-opacity-70);
432
432
  /* ================================================================================================== */