@muibook/components 20.0.0 → 20.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.
Files changed (153) hide show
  1. package/AGENTS.md +67 -0
  2. package/DESIGN.md +358 -0
  3. package/README.md +52 -1
  4. package/dist/esm/agent/keywords/index.js +2 -204
  5. package/dist/esm/agent/prompts/index.js +6 -434
  6. package/dist/esm/components/mui-accordion/core/index.js +25 -17
  7. package/dist/esm/components/mui-avatar/index.js +99 -42
  8. package/dist/esm/components/mui-avatar-chip/index.js +158 -0
  9. package/dist/esm/components/mui-avatar-group/index.js +88 -0
  10. package/dist/esm/components/mui-badge/index.js +2 -2
  11. package/dist/esm/components/mui-body/index.js +20 -11
  12. package/dist/esm/components/mui-button/index.js +117 -65
  13. package/dist/esm/components/mui-calendar/index.js +199 -0
  14. package/dist/esm/components/mui-card/body/index.js +32 -17
  15. package/dist/esm/components/mui-card/footer/index.js +11 -9
  16. package/dist/esm/components/mui-carousel/controller/index.js +1 -1
  17. package/dist/esm/components/mui-checkbox/index.js +23 -18
  18. package/dist/esm/components/mui-chip/index.js +184 -68
  19. package/dist/esm/components/mui-chip-input/index.js +146 -137
  20. package/dist/esm/components/mui-chip-rail/index.js +154 -51
  21. package/dist/esm/components/mui-code/index.js +27 -8
  22. package/dist/esm/components/mui-container/index.js +68 -45
  23. package/dist/esm/components/mui-date-picker/index.js +169 -0
  24. package/dist/esm/components/mui-drawer/index.js +968 -100
  25. package/dist/esm/components/mui-dropdown/index.js +250 -63
  26. package/dist/esm/components/mui-field/index.js +1 -1
  27. package/dist/esm/components/mui-file-upload/index.js +13 -4
  28. package/dist/esm/components/mui-form-group/index.js +1 -2
  29. package/dist/esm/components/mui-form-message/index.js +4 -9
  30. package/dist/esm/components/mui-hint/index.js +178 -72
  31. package/dist/esm/components/mui-icons/copy/index.js +54 -0
  32. package/dist/esm/components/mui-icons/fullscreen/index.js +5 -0
  33. package/dist/esm/components/mui-icons/icon-helper/index.js +56 -0
  34. package/dist/esm/components/mui-icons/index.js +14 -1
  35. package/dist/esm/components/mui-icons/moon/index.js +3 -1
  36. package/dist/esm/components/mui-icons/{rectangle-bottom-panel → panel}/index.js +6 -6
  37. package/dist/esm/components/mui-icons/pause/index.js +5 -0
  38. package/dist/esm/components/mui-icons/picture-in-picture/index.js +5 -0
  39. package/dist/esm/components/mui-icons/play-fill/index.js +5 -0
  40. package/dist/esm/components/mui-icons/rectangle-right-drawer/index.js +56 -0
  41. package/dist/esm/components/mui-icons/reload/index.js +5 -0
  42. package/dist/esm/components/mui-icons/speaker-mute/index.js +5 -0
  43. package/dist/esm/components/mui-icons/speaker-one-wave/index.js +5 -0
  44. package/dist/esm/components/mui-icons/speaker-two-wave/index.js +5 -0
  45. package/dist/esm/components/mui-icons/spinner/index.js +7 -5
  46. package/dist/esm/components/mui-icons/stop-fill/index.js +5 -0
  47. package/dist/esm/components/mui-icons/sun/index.js +5 -5
  48. package/dist/esm/components/mui-icons/timer/index.js +54 -0
  49. package/dist/esm/components/mui-icons/toggle/index.js +16 -6
  50. package/dist/esm/components/mui-icons/vertical-ellipsis/index.js +5 -0
  51. package/dist/esm/components/mui-illustrations/trash/index.js +6 -5
  52. package/dist/esm/components/mui-input/index.js +87 -62
  53. package/dist/esm/components/mui-link/index.js +195 -83
  54. package/dist/esm/components/mui-media-player/index.js +1577 -83
  55. package/dist/esm/components/mui-model-viewer/index.js +258 -0
  56. package/dist/esm/components/mui-progress-ring/index.js +349 -0
  57. package/dist/esm/components/mui-prompt/index.js +99 -71
  58. package/dist/esm/components/mui-prompt-preview/index.js +11 -23
  59. package/dist/esm/components/mui-radio/index.js +38 -17
  60. package/dist/esm/components/mui-range-input/index.js +9 -4
  61. package/dist/esm/components/mui-responsive/index.js +60 -27
  62. package/dist/esm/components/mui-search-input/index.js +300 -0
  63. package/dist/esm/components/mui-select/index.js +231 -42
  64. package/dist/esm/components/mui-slat/slat/index.js +40 -12
  65. package/dist/esm/components/mui-spinner/index.js +11 -9
  66. package/dist/esm/components/mui-switch/index.js +23 -20
  67. package/dist/esm/components/mui-table/row/index.js +2 -6
  68. package/dist/esm/components/mui-table/table/index.js +157 -14
  69. package/dist/esm/components/mui-textarea/index.js +43 -26
  70. package/dist/esm/components/mui-time/index/index.js +336 -0
  71. package/dist/esm/components/mui-time-picker/index.js +126 -0
  72. package/dist/esm/components/mui-video-thumbnail/index.js +5 -5
  73. package/dist/esm/css/mui-brand.css +12 -8
  74. package/dist/esm/css/mui-tokens.css +417 -305
  75. package/dist/esm/css/readme.md +2 -2
  76. package/dist/esm/custom-elements.json +3678 -1553
  77. package/dist/esm/dynamic-attrs.json +263 -66
  78. package/dist/esm/index.js +30 -6
  79. package/dist/esm/knowledge/compositions/index.js +1560 -0
  80. package/dist/esm/knowledge/index.js +28 -0
  81. package/dist/esm/knowledge/keywords/index.js +306 -0
  82. package/dist/esm/knowledge/rules/index.js +199 -0
  83. package/dist/esm/tokens/js/index.js +143 -139
  84. package/dist/types/agent/keywords/index.d.ts +1 -1
  85. package/dist/types/components/mui-avatar-chip/api.d.ts +28 -0
  86. package/dist/types/components/mui-avatar-chip/index.d.ts +18 -0
  87. package/dist/types/components/mui-avatar-group/api.d.ts +28 -0
  88. package/dist/types/components/mui-avatar-group/doc.d.ts +2 -0
  89. package/dist/types/components/mui-avatar-group/index.d.ts +1 -0
  90. package/dist/types/components/mui-button/api.d.ts +2 -2
  91. package/dist/types/components/mui-calendar/api.d.ts +41 -0
  92. package/dist/types/components/mui-calendar/doc.d.ts +2 -0
  93. package/dist/types/components/mui-calendar/index.d.ts +3 -0
  94. package/dist/types/components/mui-checkbox/api.d.ts +4 -0
  95. package/dist/types/components/mui-chip-input/api.d.ts +4 -0
  96. package/dist/types/components/mui-chip-rail/index.d.ts +1 -0
  97. package/dist/types/components/mui-date-picker/api.d.ts +38 -0
  98. package/dist/types/components/mui-date-picker/doc.d.ts +2 -0
  99. package/dist/types/components/mui-date-picker/index.d.ts +6 -0
  100. package/dist/types/components/mui-drawer/api.d.ts +4 -0
  101. package/dist/types/components/mui-drawer/index.d.ts +2 -0
  102. package/dist/types/components/mui-file-upload/api.d.ts +4 -0
  103. package/dist/types/components/mui-icons/fullscreen.d.ts +1 -0
  104. package/dist/types/components/mui-icons/icon-helper.d.ts +1 -0
  105. package/dist/types/components/mui-icons/index.d.ts +14 -1
  106. package/dist/types/components/mui-icons/panel.d.ts +1 -0
  107. package/dist/types/components/mui-icons/pause.d.ts +1 -0
  108. package/dist/types/components/mui-icons/picture-in-picture.d.ts +1 -0
  109. package/dist/types/components/mui-icons/play-fill.d.ts +1 -0
  110. package/dist/types/components/mui-icons/rectangle-right-drawer.d.ts +1 -0
  111. package/dist/types/components/mui-icons/reload.d.ts +1 -0
  112. package/dist/types/components/mui-icons/speaker-mute.d.ts +1 -0
  113. package/dist/types/components/mui-icons/speaker-one-wave.d.ts +1 -0
  114. package/dist/types/components/mui-icons/speaker-two-wave.d.ts +1 -0
  115. package/dist/types/components/mui-icons/stop-fill.d.ts +1 -0
  116. package/dist/types/components/mui-icons/timer.d.ts +1 -0
  117. package/dist/types/components/mui-icons/vertical-ellipsis.d.ts +1 -0
  118. package/dist/types/components/mui-input/api.d.ts +12 -0
  119. package/dist/types/components/mui-media-player/api.d.ts +4 -0
  120. package/dist/types/components/mui-media-player/index.d.ts +13 -4
  121. package/dist/types/components/mui-model-viewer/api.d.ts +28 -0
  122. package/dist/types/components/mui-model-viewer/doc.d.ts +2 -0
  123. package/dist/types/components/mui-model-viewer/index.d.ts +17 -0
  124. package/dist/types/components/mui-progress-ring/api.d.ts +24 -0
  125. package/dist/types/components/mui-progress-ring/doc.d.ts +2 -0
  126. package/dist/types/components/mui-progress-ring/index.d.ts +1 -0
  127. package/dist/types/components/mui-radio/api.d.ts +12 -0
  128. package/dist/types/components/mui-range-input/api.d.ts +4 -0
  129. package/dist/types/components/mui-responsive/api.d.ts +10 -2
  130. package/dist/types/components/mui-search-input/api.d.ts +40 -0
  131. package/dist/types/components/mui-search-input/doc.d.ts +2 -0
  132. package/dist/types/components/mui-search-input/index.d.ts +3 -0
  133. package/dist/types/components/mui-select/api.d.ts +12 -0
  134. package/dist/types/components/mui-switch/api.d.ts +4 -0
  135. package/dist/types/components/mui-table/api.d.ts +15 -0
  136. package/dist/types/components/mui-textarea/api.d.ts +12 -0
  137. package/dist/types/components/mui-time/api.d.ts +41 -0
  138. package/dist/types/components/mui-time/doc.d.ts +2 -0
  139. package/dist/types/components/mui-time/index.d.ts +1 -0
  140. package/dist/types/components/mui-time-picker/api.d.ts +38 -0
  141. package/dist/types/components/mui-time-picker/doc.d.ts +2 -0
  142. package/dist/types/components/mui-time-picker/index.d.ts +4 -0
  143. package/dist/types/index.d.ts +24 -2
  144. package/dist/types/knowledge/compositions.d.ts +4644 -0
  145. package/dist/types/knowledge/index.d.ts +4657 -0
  146. package/dist/types/knowledge/keywords.d.ts +4 -0
  147. package/dist/types/knowledge/rules.d.ts +1 -0
  148. package/dist/types/tokens/js/index.d.ts +11 -7
  149. package/package.json +119 -12
  150. package/dist/esm/components/mui-form-hint/index.js +0 -1
  151. package/dist/types/components/mui-form-hint/index.d.ts +0 -1
  152. /package/dist/types/components/{mui-form-hint → mui-avatar-chip}/doc.d.ts +0 -0
  153. /package/dist/types/components/mui-icons/{rectangle-bottom-panel.d.ts → copy.d.ts} +0 -0
@@ -1,23 +1,34 @@
1
- const i = class i extends HTMLElement {
1
+ const r = class r extends HTMLElement {
2
2
  constructor() {
3
- super(), this.button = null, this.menu = null, this.handleResize = () => {
3
+ super(), this.button = null, this.menu = null, this.portalMenu = null, this.portalInner = null, this.portaledItems = [], this.originalNextSibling = /* @__PURE__ */ new Map(), this.positionFrameId = null, this.positionTimeoutIds = [], this.menuResizeObserver = null, this.handleResize = () => {
4
4
  var t;
5
- (t = this.menu) != null && t.classList.contains("show") && this.adjustPosition();
5
+ (t = this.activeMenu) != null && t.classList.contains("show") && this.closeMenu();
6
6
  }, this.handleScroll = () => {
7
7
  var t;
8
- (t = this.menu) != null && t.classList.contains("show") && this.adjustPosition();
8
+ (t = this.activeMenu) != null && t.classList.contains("show") && this.adjustPosition();
9
9
  }, this.handleFocusOut = (t) => {
10
- var e, n;
11
- this.persistent || this.contains(t.relatedTarget) || (this.closeWithAnimation(), (e = this.menu) == null || e.setAttribute("inert", "true"), i.openDropdown === this && (i.openDropdown = null), (n = this.button) == null || n.setAttribute("aria-expanded", "false"), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
10
+ var e, n, o;
11
+ if (this.persistent) return;
12
+ const i = t.relatedTarget;
13
+ !this.contains(i) && !((e = this.portalMenu) != null && e.contains(i)) && (this.closeWithAnimation(), (n = this.activeMenu) == null || n.setAttribute("inert", "true"), r.openDropdown === this && (r.openDropdown = null), (o = this.button) == null || o.setAttribute("aria-expanded", "false"), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
12
14
  }, this.handleActionKeyDown = (t) => {
15
+ var i;
16
+ if (t.key === "Tab" && !t.shiftKey && ((i = this.activeMenu) != null && i.classList.contains("show"))) {
17
+ t.preventDefault(), this.focusFirstItem();
18
+ return;
19
+ }
13
20
  t.key !== "Enter" && t.key !== " " || (t.preventDefault(), this.toggleMenu(t));
14
21
  }, this.attachShadow({ mode: "open" });
15
22
  }
23
+ get activeMenu() {
24
+ return this.portalMenu || this.menu;
25
+ }
16
26
  handleKeyDown(t) {
17
- var e;
27
+ var i, e;
18
28
  if (t.key === "Escape") {
19
- if (!this.menu) return;
20
- this.menu.classList.remove("show"), this.menu.setAttribute("inert", "true"), i.openDropdown === this && (i.openDropdown = null), (e = this.button) == null || e.setAttribute("aria-expanded", "false"), this.dispatchEvent(
29
+ const n = this.activeMenu;
30
+ if (!n || !n.classList.contains("show")) return;
31
+ n.classList.remove("show"), n.setAttribute("inert", "true"), this.restorePortalItems(), r.openDropdown === this && (r.openDropdown = null), (i = this.button) == null || i.setAttribute("aria-expanded", "false"), (e = this.button) == null || e.focus(), this.dispatchEvent(
21
32
  new CustomEvent("dropdown-toggle", {
22
33
  detail: { open: !1 },
23
34
  bubbles: !0
@@ -25,93 +36,267 @@ const i = class i extends HTMLElement {
25
36
  );
26
37
  }
27
38
  }
39
+ close() {
40
+ var i, e;
41
+ const t = this.activeMenu;
42
+ !t || !t.classList.contains("show") || (t.classList.remove("show"), t.setAttribute("inert", "true"), this.restorePortalItems(), r.openDropdown === this && (r.openDropdown = null), (i = this.button) == null || i.setAttribute("aria-expanded", "false"), (e = this.button) == null || e.focus(), this.dispatchEvent(
43
+ new CustomEvent("dropdown-toggle", {
44
+ detail: { open: !1 },
45
+ bubbles: !0
46
+ })
47
+ ));
48
+ }
49
+ clearPositionSchedules() {
50
+ this.positionFrameId !== null && (cancelAnimationFrame(this.positionFrameId), this.positionFrameId = null), this.positionTimeoutIds.forEach((t) => window.clearTimeout(t)), this.positionTimeoutIds = [];
51
+ }
52
+ schedulePositionUpdate() {
53
+ this.clearPositionSchedules();
54
+ let t = 0;
55
+ const i = () => {
56
+ var e;
57
+ if (!((e = this.activeMenu) != null && e.classList.contains("show"))) {
58
+ this.positionFrameId = null;
59
+ return;
60
+ }
61
+ this.adjustPosition(), t += 1, t < 4 ? this.positionFrameId = requestAnimationFrame(i) : this.positionFrameId = null;
62
+ };
63
+ this.positionFrameId = requestAnimationFrame(i), [80, 180, 320].forEach((e) => {
64
+ const n = window.setTimeout(() => {
65
+ var o;
66
+ this.positionTimeoutIds = this.positionTimeoutIds.filter((s) => s !== n), (o = this.activeMenu) != null && o.classList.contains("show") && this.adjustPosition();
67
+ }, e);
68
+ this.positionTimeoutIds.push(n);
69
+ });
70
+ }
71
+ focusFirstItem() {
72
+ const t = this.portalInner || this.menu;
73
+ if (!t) return;
74
+ const i = (n) => {
75
+ const o = 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';
76
+ if (n instanceof HTMLElement && n.matches(o))
77
+ return n;
78
+ const s = n.children;
79
+ for (let u = 0; u < s.length; u++) {
80
+ const l = s[u];
81
+ if (l.shadowRoot) {
82
+ const h = i(l.shadowRoot);
83
+ if (h) return h;
84
+ }
85
+ if (l.tagName === "SLOT") {
86
+ const h = l.assignedElements({ flatten: !0 });
87
+ for (const p of h)
88
+ if (p instanceof HTMLElement) {
89
+ const a = i(p);
90
+ if (a) return a;
91
+ }
92
+ }
93
+ if (l.matches(o))
94
+ return l;
95
+ const d = i(l);
96
+ if (d) return d;
97
+ }
98
+ return null;
99
+ }, e = i(t);
100
+ e && e.focus();
101
+ }
28
102
  static get observedAttributes() {
29
103
  return ["zindex", "position", "vertical-position", "persistent"];
30
104
  }
31
105
  get persistent() {
32
106
  return this.hasAttribute("persistent");
33
107
  }
34
- attributeChangedCallback(t, e, n) {
35
- t === "zindex" && this.menu && (this.menu.style.zIndex = n ?? "1"), (t === "position" || t === "vertical-position") && this.menu && this.adjustPosition();
108
+ attributeChangedCallback(t, i, e) {
109
+ t === "zindex" && this.menu && (this.menu.style.zIndex = e ?? "1", this.portalMenu && (this.portalMenu.style.zIndex = e ?? "1")), (t === "position" || t === "vertical-position") && this.menu && this.adjustPosition();
36
110
  }
37
111
  connectedCallback() {
38
- var r, o, c, p;
39
- this.render(), this.menu = (r = this.shadowRoot) == null ? void 0 : r.querySelector(".dropdown-menu");
112
+ var o, s, u, l;
113
+ this.render(), this.menu = (o = this.shadowRoot) == null ? void 0 : o.querySelector(".dropdown-menu");
40
114
  const t = this.getAttribute("zindex") || "1";
41
- this.menu && (this.menu.style.zIndex = t), this.menu && this.menu.setAttribute("inert", "true"), (o = this.menu) == null || o.addEventListener("focusout", this.handleFocusOut);
42
- const e = (c = this.shadowRoot) == null ? void 0 : c.querySelector("slot:not([name])");
43
- if (e) {
115
+ this.menu && (this.menu.style.zIndex = t), this.menu && this.menu.setAttribute("inert", "true"), (s = this.menu) == null || s.addEventListener("focusout", this.handleFocusOut);
116
+ const i = (u = this.shadowRoot) == null ? void 0 : u.querySelector("slot:not([name])");
117
+ if (i) {
44
118
  const d = () => {
45
- const m = e.assignedElements({ flatten: !0 }).filter((s) => s.tagName.toLowerCase() === "mui-button");
46
- m.forEach((s) => {
47
- s.removeAttribute("dropdown-slot"), s.removeAttribute("dropdown-slot-first"), s.removeAttribute("dropdown-slot-last");
48
- }), m.forEach((s, a) => {
49
- s.hasAttribute("variant") || s.setAttribute("variant", "tertiary"), s.setAttribute("dropdown-slot", ""), a === 0 && s.setAttribute("dropdown-slot-first", ""), a === m.length - 1 && s.setAttribute("dropdown-slot-last", ""), s._dropdownListenerAdded || (s.addEventListener("click", () => {
50
- var u, l;
51
- this.persistent || ((u = this.menu) == null || u.classList.remove("show"), (l = this.menu) == null || l.setAttribute("inert", "true"), i.openDropdown === this && (i.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
52
- }), s._dropdownListenerAdded = !0);
119
+ const p = i.assignedElements({ flatten: !0 }).filter((a) => {
120
+ const c = a.tagName.toLowerCase();
121
+ return c === "mui-button" || c === "mui-link";
122
+ });
123
+ p.forEach((a) => {
124
+ a.removeAttribute("dropdown-slot"), a.removeAttribute("dropdown-slot-first"), a.removeAttribute("dropdown-slot-last");
125
+ }), p.forEach((a, c) => {
126
+ a.hasAttribute("variant") || a.setAttribute("variant", "tertiary"), a.setAttribute("dropdown-slot", ""), c === 0 && a.setAttribute("dropdown-slot-first", ""), c === p.length - 1 && a.setAttribute("dropdown-slot-last", ""), a._dropdownListenerAdded || (a.addEventListener("click", () => {
127
+ var m, b, w;
128
+ this.persistent || ((m = this.activeMenu) == null || m.classList.remove("show"), (b = this.activeMenu) == null || b.setAttribute("inert", "true"), this.restorePortalItems(), r.openDropdown === this && (r.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })), (w = this.button) == null || w.focus());
129
+ }), a._dropdownListenerAdded = !0);
53
130
  });
54
131
  };
55
- e.addEventListener("slotchange", d), d();
132
+ i.addEventListener("slotchange", d), d();
56
133
  }
57
134
  this.toggleMenu = this.toggleMenu.bind(this), this.closeMenu = this.closeMenu.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this);
58
- const n = (p = this.shadowRoot) == null ? void 0 : p.querySelector('slot[name="action"]'), h = () => {
59
- var s, a, u;
60
- (s = this.button) == null || s.removeEventListener("click", this.toggleMenu), (a = this.button) == null || a.removeEventListener("keydown", this.handleActionKeyDown);
61
- const d = (n == null ? void 0 : n.assignedElements({ flatten: !0 })) || [];
62
- if (this.button = d.find((l) => l instanceof HTMLElement), !this.button) return;
63
- const w = this.button.tagName.toLowerCase();
64
- w === "mui-button" || w === "button" || w === "a" || (this.button.hasAttribute("tabindex") || this.button.setAttribute("tabindex", "0"), this.button.setAttribute("role", "button")), this.button.setAttribute("aria-haspopup", "menu"), this.button.setAttribute("aria-expanded", (u = this.menu) != null && u.classList.contains("show") ? "true" : "false"), this.button.addEventListener("click", this.toggleMenu), this.button.addEventListener("keydown", this.handleActionKeyDown);
135
+ const e = (l = this.shadowRoot) == null ? void 0 : l.querySelector('slot[name="action"]'), n = () => {
136
+ var a, c, m;
137
+ (a = this.button) == null || a.removeEventListener("click", this.toggleMenu), (c = this.button) == null || c.removeEventListener("keydown", this.handleActionKeyDown);
138
+ const d = (e == null ? void 0 : e.assignedElements({ flatten: !0 })) || [];
139
+ if (this.button = d.find((b) => b instanceof HTMLElement), !this.button) return;
140
+ const h = this.button.tagName.toLowerCase();
141
+ h === "mui-button" || h === "button" || h === "a" || h === "mui-input" || (this.button.hasAttribute("tabindex") || this.button.setAttribute("tabindex", "0"), this.button.setAttribute("role", "button")), this.button.setAttribute("aria-haspopup", "menu"), this.button.setAttribute("aria-expanded", (m = this.menu) != null && m.classList.contains("show") ? "true" : "false"), this.button.addEventListener("click", this.toggleMenu), this.button.addEventListener("keydown", this.handleActionKeyDown);
65
142
  };
66
- n == null || n.addEventListener("slotchange", h), h(), document.addEventListener("click", this.closeMenu), document.addEventListener("keydown", this.handleKeyDown), window.addEventListener("resize", this.handleResize), window.addEventListener("scroll", this.handleScroll, !0);
143
+ e == null || e.addEventListener("slotchange", n), n(), document.addEventListener("click", this.closeMenu), document.addEventListener("keydown", this.handleKeyDown), window.addEventListener("resize", this.handleResize), window.addEventListener("scroll", this.handleScroll, !0);
67
144
  }
68
145
  disconnectedCallback() {
69
- var t, e, n;
70
- (t = this.button) == null || t.removeEventListener("click", this.toggleMenu), (e = this.button) == null || e.removeEventListener("keydown", this.handleActionKeyDown), document.removeEventListener("click", this.closeMenu), document.removeEventListener("keydown", this.handleKeyDown), window.removeEventListener("resize", this.handleResize), window.removeEventListener("scroll", this.handleScroll, !0), (n = this.menu) == null || n.removeEventListener("focusout", this.handleFocusOut);
146
+ var t, i, e, n;
147
+ (t = this.button) == null || t.removeEventListener("click", this.toggleMenu), (i = this.button) == null || i.removeEventListener("keydown", this.handleActionKeyDown), this.clearPositionSchedules(), (e = this.menuResizeObserver) == null || e.disconnect(), this.menuResizeObserver = null, document.removeEventListener("click", this.closeMenu), document.removeEventListener("keydown", this.handleKeyDown), window.removeEventListener("resize", this.handleResize), window.removeEventListener("scroll", this.handleScroll, !0), (n = this.menu) == null || n.removeEventListener("focusout", this.handleFocusOut), this.restorePortalItems();
71
148
  }
72
149
  closeWithAnimation() {
73
150
  var e;
74
- if (!this.menu) return;
75
- this.menu.classList.remove("show"), (e = this.button) == null || e.setAttribute("aria-expanded", "false"), setTimeout(() => {
76
- this.menu && (this.menu.classList.contains("show") || (this.menu.style.display = "none"));
151
+ const t = this.activeMenu;
152
+ if (!t) return;
153
+ t.classList.remove("show"), (e = this.button) == null || e.setAttribute("aria-expanded", "false"), setTimeout(() => {
154
+ const n = this.activeMenu;
155
+ n && (n.classList.contains("show") || (n.style.display = "none", this.restorePortalItems()));
77
156
  }, 150);
78
157
  }
79
158
  toggleMenu(t) {
80
- var n, h;
159
+ var e, n, o;
81
160
  if (t.stopPropagation(), !this.menu) return;
82
- const e = this.menu.classList.contains("show");
83
- !e && i.openDropdown && i.openDropdown !== this && i.openDropdown.closeWithAnimation(), e ? (this.closeWithAnimation(), (n = this.menu) == null || n.setAttribute("inert", "true"), i.openDropdown === this && (i.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 }))) : (this.menu.style.display = "block", requestAnimationFrame(() => {
84
- var r, o;
85
- (r = this.menu) == null || r.classList.add("show"), (o = this.menu) == null || o.removeAttribute("inert"), this.adjustPosition();
86
- }), (h = this.button) == null || h.setAttribute("aria-expanded", "true"), i.openDropdown = this, this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !0 }, bubbles: !0 })));
161
+ const i = (e = this.activeMenu) == null ? void 0 : e.classList.contains("show");
162
+ if (!i && r.openDropdown && r.openDropdown !== this && r.openDropdown.closeWithAnimation(), i)
163
+ this.closeWithAnimation(), (n = this.activeMenu) == null || n.setAttribute("inert", "true"), r.openDropdown === this && (r.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 }));
164
+ else {
165
+ this.portalItems();
166
+ const s = this.activeMenu;
167
+ if (!s) return;
168
+ s.style.display = "block", requestAnimationFrame(() => {
169
+ s.classList.add("show"), s.removeAttribute("inert"), this.schedulePositionUpdate();
170
+ }), (o = this.button) == null || o.setAttribute("aria-expanded", "true"), r.openDropdown = this, this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !0 }, bubbles: !0 }));
171
+ }
87
172
  }
88
173
  closeMenu(t) {
89
- var n;
90
- const e = t.composedPath();
91
- this.menu && e.includes(this.menu) || this.button && e.includes(this.button) || (this.closeWithAnimation(), (n = this.menu) == null || n.setAttribute("inert", "true"), i.openDropdown === this && (i.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
174
+ var i;
175
+ if (t) {
176
+ const e = t.composedPath();
177
+ if (this.menu && e.includes(this.menu) || this.portalMenu && e.includes(this.portalMenu) || this.button && e.includes(this.button)) return;
178
+ }
179
+ this.closeWithAnimation(), (i = this.activeMenu) == null || i.setAttribute("inert", "true"), r.openDropdown === this && (r.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 }));
180
+ }
181
+ portalItems() {
182
+ var e, n;
183
+ const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector("slot:not([name])"), i = (t == null ? void 0 : t.assignedElements({ flatten: !0 })) || [];
184
+ if (i.length) {
185
+ if (this.ensurePortalStyles(), !this.portalMenu) {
186
+ this.portalMenu = document.createElement("div"), this.portalMenu.className = "mui-dropdown-portal", this.portalMenu.setAttribute("inert", "true"), this.portalMenu.style.zIndex = this.getAttribute("zindex") || "1";
187
+ const o = () => {
188
+ const s = document.createElement("div");
189
+ return s.tabIndex = 0, s.style.position = "absolute", s.style.opacity = "0", s.style.pointerEvents = "none", s.addEventListener("focus", () => {
190
+ var u, l, d;
191
+ this.persistent || ((u = this.activeMenu) == null || u.classList.remove("show"), (l = this.activeMenu) == null || l.setAttribute("inert", "true"), this.restorePortalItems(), r.openDropdown === this && (r.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 }))), (d = this.button) == null || d.focus();
192
+ }), s;
193
+ };
194
+ this.portalMenu.appendChild(o()), this.portalInner = document.createElement("div"), this.portalInner.className = "inner", this.portalMenu.appendChild(this.portalInner), this.portalMenu.appendChild(o()), this.portalMenu.addEventListener("focusout", this.handleFocusOut), document.body.appendChild(this.portalMenu);
195
+ }
196
+ this.syncPortalStyles(), this.portaledItems = i, i.forEach((o) => {
197
+ var s;
198
+ this.originalNextSibling.has(o) || this.originalNextSibling.set(o, o.nextSibling), (s = this.portalInner) == null || s.appendChild(o);
199
+ }), typeof ResizeObserver < "u" && this.portalMenu && ((n = this.menuResizeObserver) == null || n.disconnect(), this.menuResizeObserver = new ResizeObserver(() => {
200
+ var o;
201
+ (o = this.activeMenu) != null && o.classList.contains("show") && this.adjustPosition();
202
+ }), this.menuResizeObserver.observe(this.portalMenu));
203
+ }
204
+ }
205
+ restorePortalItems() {
206
+ var t;
207
+ this.portalMenu && (this.clearPositionSchedules(), (t = this.menuResizeObserver) == null || t.disconnect(), this.menuResizeObserver = null, this.portaledItems.forEach((i) => {
208
+ const e = this.originalNextSibling.get(i);
209
+ e && e.parentNode === this ? this.insertBefore(i, e) : this.appendChild(i);
210
+ }), this.portaledItems = [], this.originalNextSibling.clear(), this.portalMenu.removeEventListener("focusout", this.handleFocusOut), this.portalMenu.remove(), this.portalMenu = null, this.portalInner = null);
211
+ }
212
+ ensurePortalStyles() {
213
+ if (r.portalStylesInjected) return;
214
+ const t = document.createElement("style");
215
+ t.textContent = `
216
+ .mui-dropdown-portal {
217
+ display: none;
218
+ opacity: 0;
219
+ transform: translateY(-0.25rem);
220
+ transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
221
+ min-width: var(--dropdown-min-width, 15rem);
222
+ position: fixed;
223
+ z-index: 1;
224
+ box-sizing: border-box;
225
+ border: var(--border-thin);
226
+ background: var(--dropdown-background);
227
+ border-color: var(--dropdown-border-color);
228
+ box-shadow: 0 var(--space-100) var(--space-200) var(--dropdown-shadow-color);
229
+ border-radius: var(--dropdown-radius);
230
+ padding: 1px;
231
+ }
232
+ .mui-dropdown-portal.show {
233
+ visibility: visible;
234
+ opacity: 1;
235
+ transform: translateY(0);
236
+ }
237
+ .mui-dropdown-portal .inner {
238
+ display: flex;
239
+ flex-direction: column;
240
+ gap: 1px;
241
+ }
242
+ .mui-dropdown-portal mui-button,
243
+ .mui-dropdown-portal mui-link {
244
+ width: 100%;
245
+ text-align: left;
246
+ }
247
+ .mui-dropdown-portal mui-button:focus,
248
+ .mui-dropdown-portal mui-link:focus {
249
+ z-index: 1;
250
+ }
251
+ `, document.head.appendChild(t), r.portalStylesInjected = !0;
252
+ }
253
+ syncPortalStyles() {
254
+ if (!this.portalMenu) return;
255
+ const t = window.getComputedStyle(this);
256
+ [
257
+ "--dropdown-background",
258
+ "--dropdown-border-color",
259
+ "--dropdown-min-width",
260
+ "--dropdown-radius",
261
+ "--dropdown-shadow-color",
262
+ "--action-tertiary-background",
263
+ "--action-tertiary-background-hover",
264
+ "--action-tertiary-background-focus",
265
+ "--action-tertiary-border",
266
+ "--action-tertiary-border-hover",
267
+ "--action-tertiary-border-focus",
268
+ "--action-tertiary-text-color",
269
+ "--action-tertiary-text-color-hover",
270
+ "--action-tertiary-text-color-focus"
271
+ ].forEach((i) => {
272
+ var n;
273
+ const e = t.getPropertyValue(i);
274
+ e && ((n = this.portalMenu) == null || n.style.setProperty(i, e));
275
+ });
92
276
  }
93
277
  adjustPosition() {
94
- if (!this.menu) return;
95
- const t = this.menu, e = 8, n = getComputedStyle(this).getPropertyValue("--dropdown-offset").trim() || "0.8rem", h = parseFloat(getComputedStyle(document.documentElement).fontSize) || 10, r = n.endsWith("rem") ? parseFloat(n) * h : parseFloat(n) || 8;
278
+ const t = this.activeMenu;
279
+ if (!t) return;
280
+ const i = 8, e = getComputedStyle(this).getPropertyValue("--dropdown-offset").trim() || "0.8rem", n = parseFloat(getComputedStyle(document.documentElement).fontSize) || 10, o = e.endsWith("rem") ? parseFloat(e) * n : parseFloat(e) || 8;
96
281
  t.style.top = "", t.style.bottom = "", t.style.left = "", t.style.right = "", t.style.maxWidth = "";
97
- const o = this.getBoundingClientRect(), c = t.offsetWidth, p = t.offsetHeight, d = window.innerWidth, w = window.innerHeight, m = (this.getAttribute("vertical-position") || "auto").toLowerCase(), s = w - o.bottom, a = o.top, u = p + r, l = s >= u, g = a >= u;
98
- let f = o.height + r;
99
- m === "up" ? f = g || !l ? -(p + r) : o.height + r : m === "down" ? f = l || !g ? o.height + r : -(p + r) : !l && a > s && (f = -(p + r));
100
- let b = 0;
282
+ const s = this.getBoundingClientRect(), u = t.offsetWidth, l = t.offsetHeight, d = window.innerWidth, h = window.innerHeight, p = (this.getAttribute("vertical-position") || "auto").toLowerCase(), a = h - s.bottom, c = s.top, m = l + o, b = a >= m, w = c >= m;
283
+ let v = this.portalMenu ? s.bottom + o : s.height + o;
284
+ p === "up" ? v = w || !b ? this.portalMenu ? s.top - l - o : -(l + o) : this.portalMenu ? s.bottom + o : s.height + o : p === "down" ? v = b || !w ? this.portalMenu ? s.bottom + o : s.height + o : this.portalMenu ? s.top - l - o : -(l + o) : !b && c > a && (v = this.portalMenu ? s.top - l - o : -(l + o));
285
+ let f = 0;
101
286
  switch (this.getAttribute("position") || "left") {
102
287
  case "left":
103
- b = 0;
288
+ f = this.portalMenu ? s.left : 0;
104
289
  break;
105
290
  case "center":
106
- b = (o.width - c) / 2;
291
+ f = this.portalMenu ? s.left + (s.width - u) / 2 : (s.width - u) / 2;
107
292
  break;
108
293
  case "right":
109
294
  default:
110
- b = o.width - c;
295
+ f = this.portalMenu ? s.right - u : s.width - u;
111
296
  break;
112
297
  }
113
- const y = e - o.left, A = d - e - (o.left + c);
114
- b = Math.max(y, Math.min(b, A)), c > d - e * 2 && (t.style.maxWidth = `${d - e * 2}px`), t.style.top = `${f}px`, t.style.left = `${b}px`;
298
+ const y = this.portalMenu ? i : i - s.left, M = this.portalMenu ? d - i - u : d - i - (s.left + u);
299
+ f = Math.max(y, Math.min(f, M)), u > d - i * 2 && (t.style.maxWidth = `${d - i * 2}px`), t.style.top = `${v}px`, t.style.left = `${f}px`;
115
300
  }
116
301
  render() {
117
302
  this.shadowRoot.innerHTML = /*html*/
@@ -148,12 +333,14 @@ const i = class i extends HTMLElement {
148
333
  transform: translateY(0);
149
334
  }
150
335
 
151
- .dropdown-menu ::slotted(mui-button) {
336
+ .dropdown-menu ::slotted(mui-button),
337
+ .dropdown-menu ::slotted(mui-link) {
152
338
  width: 100%;
153
339
  text-align: left;
154
340
  }
155
341
 
156
- .dropdown-menu ::slotted(mui-button:focus) {
342
+ .dropdown-menu ::slotted(mui-button:focus),
343
+ .dropdown-menu ::slotted(mui-link:focus) {
157
344
  z-index: 1;
158
345
  }
159
346
 
@@ -177,6 +364,6 @@ const i = class i extends HTMLElement {
177
364
  `;
178
365
  }
179
366
  };
180
- i.openDropdown = null;
181
- let v = i;
182
- customElements.get("mui-dropdown") || customElements.define("mui-dropdown", v);
367
+ r.openDropdown = null, r.portalStylesInjected = !1;
368
+ let g = r;
369
+ customElements.get("mui-dropdown") || customElements.define("mui-dropdown", g);
@@ -116,7 +116,7 @@ class r extends HTMLElement {
116
116
  if (!t) return;
117
117
  t.assignedElements({ flatten: !0 }).forEach((s) => {
118
118
  const a = s.tagName.toLowerCase();
119
- (a === "mui-form-message" || a === "mui-form-hint" || a === "mui-body") && s.setAttribute("size", e);
119
+ (a === "mui-form-message" || a === "mui-body") && s.setAttribute("size", e);
120
120
  });
121
121
  }
122
122
  bindSlotEvents() {
@@ -24,6 +24,9 @@ class a extends HTMLElement {
24
24
  connectedCallback() {
25
25
  this.acceptedFileTypes = this.readAcceptedFileTypes(), this.currentFileName = this.readCurrentFileName(), this.render(), this.cacheElements(), this.attachEvents();
26
26
  }
27
+ focus(e) {
28
+ this.wrapper ? this.wrapper.focus(e) : super.focus(e);
29
+ }
27
30
  disconnectedCallback() {
28
31
  this.cleanupListeners();
29
32
  }
@@ -42,7 +45,7 @@ class a extends HTMLElement {
42
45
  line-height: var(--text-line-height-s);
43
46
  box-sizing: border-box;
44
47
  font-size: var(--text-font-size-s);
45
- border-radius: var(--radius-100);
48
+ border-radius: var(--form-radius-medium);
46
49
  border: var(--border-thin);
47
50
  border-style: dashed;
48
51
  border-color: var(--form-default-border-color);
@@ -53,6 +56,10 @@ class a extends HTMLElement {
53
56
  .wrapper:hover {
54
57
  border-color: var(--form-default-border-color-hover);
55
58
  }
59
+ .wrapper:focus-visible {
60
+ outline: var(--outline-medium);
61
+ outline-offset: var(--outline-offset);
62
+ }
56
63
  .label {
57
64
  width: 90px;
58
65
  white-space: nowrap;
@@ -96,7 +103,7 @@ class a extends HTMLElement {
96
103
  display: none;
97
104
  }
98
105
  </style>
99
- <div class="wrapper">
106
+ <div class="wrapper" role="button" tabindex="0">
100
107
  <span class="label">${this.selectedFileName || this.currentFileName || "No file selected"}</span>
101
108
  <mui-button variant="tertiary">Browse</mui-button>
102
109
  <input type="file" accept="${this.acceptedFileTypes}" />
@@ -107,12 +114,14 @@ class a extends HTMLElement {
107
114
  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"]'));
108
115
  }
109
116
  cleanupListeners() {
110
- this.wrapper && this._wrapperClickHandler && this.wrapper.removeEventListener("click", this._wrapperClickHandler), this.input && this._inputChangeHandler && this.input.removeEventListener("change", this._inputChangeHandler);
117
+ this.wrapper && this._wrapperClickHandler && this.wrapper.removeEventListener("click", this._wrapperClickHandler), this.wrapper && this._wrapperKeydownHandler && this.wrapper.removeEventListener("keydown", this._wrapperKeydownHandler), this.input && this._inputChangeHandler && this.input.removeEventListener("change", this._inputChangeHandler);
111
118
  }
112
119
  attachEvents() {
113
120
  this._wrapperClickHandler = () => {
114
121
  this.input.click();
115
- }, this._inputChangeHandler = this.handleFileChange.bind(this), this.wrapper.addEventListener("click", this._wrapperClickHandler), this.input.addEventListener("change", this._inputChangeHandler);
122
+ }, this._wrapperKeydownHandler = (e) => {
123
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), this.input.click());
124
+ }, this._inputChangeHandler = this.handleFileChange.bind(this), this.wrapper.addEventListener("click", this._wrapperClickHandler), this.wrapper.addEventListener("keydown", this._wrapperKeydownHandler), this.input.addEventListener("change", this._inputChangeHandler);
116
125
  }
117
126
  handleFileChange(e) {
118
127
  var r;
@@ -47,8 +47,7 @@ class r extends HTMLElement {
47
47
  :host([variant="horizontal"]) .content-inner ::slotted(*) {
48
48
  min-inline-size: 0;
49
49
  }
50
- :host([variant="horizontal"]) .content-inner ::slotted(mui-form-message),
51
- :host([variant="horizontal"]) .content-inner ::slotted(mui-form-hint) {
50
+ :host([variant="horizontal"]) .content-inner ::slotted(mui-form-message) {
52
51
  grid-column: 1 / -1;
53
52
  }
54
53
  @media (max-width: 767px) {
@@ -1,6 +1,6 @@
1
1
  import "../mui-body/index.js";
2
2
  import "../mui-icons/info/index.js";
3
- class a extends HTMLElement {
3
+ class r extends HTMLElement {
4
4
  static get observedAttributes() {
5
5
  return ["size", "weight", "variant"];
6
6
  }
@@ -39,7 +39,7 @@ class a extends HTMLElement {
39
39
  }
40
40
  render() {
41
41
  if (!this.shadowRoot) return;
42
- const t = this.getAttribute("size") || "small", s = this.getAttribute("weight") || "regular", o = this.getAttribute("variant") || "optional", r = this.querySelector('[slot="after"]') !== null;
42
+ const t = this.getAttribute("size") || "small", s = this.getAttribute("weight") || "regular", o = this.getAttribute("variant") || "optional", i = this.querySelector('[slot="after"]') !== null;
43
43
  this.shadowRoot.innerHTML = /*html*/
44
44
  `
45
45
  <style>
@@ -63,7 +63,7 @@ class a extends HTMLElement {
63
63
  </slot>
64
64
  </span>
65
65
  <slot></slot>
66
- ${r ? `<span slot="after" class="slot-wrapper">
66
+ ${i ? `<span slot="after" class="slot-wrapper">
67
67
  <slot name="after"></slot>
68
68
  </span>` : ""}
69
69
  </mui-body>
@@ -72,9 +72,4 @@ class a extends HTMLElement {
72
72
  e == null || e.addEventListener("slotchange", () => this.syncBeforeIcon()), this.syncBeforeIcon();
73
73
  }
74
74
  }
75
- customElements.get("mui-form-message") || customElements.define("mui-form-message", a);
76
- if (!customElements.get("mui-form-hint")) {
77
- class i extends a {
78
- }
79
- customElements.define("mui-form-hint", i);
80
- }
75
+ customElements.get("mui-form-message") || customElements.define("mui-form-message", r);