@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.
- package/AGENTS.md +67 -0
- package/DESIGN.md +358 -0
- package/README.md +52 -1
- package/dist/esm/agent/keywords/index.js +2 -204
- package/dist/esm/agent/prompts/index.js +6 -434
- package/dist/esm/components/mui-accordion/core/index.js +25 -17
- package/dist/esm/components/mui-avatar/index.js +99 -42
- package/dist/esm/components/mui-avatar-chip/index.js +158 -0
- package/dist/esm/components/mui-avatar-group/index.js +88 -0
- package/dist/esm/components/mui-badge/index.js +2 -2
- package/dist/esm/components/mui-body/index.js +20 -11
- package/dist/esm/components/mui-button/index.js +117 -65
- package/dist/esm/components/mui-calendar/index.js +199 -0
- package/dist/esm/components/mui-card/body/index.js +32 -17
- package/dist/esm/components/mui-card/footer/index.js +11 -9
- package/dist/esm/components/mui-carousel/controller/index.js +1 -1
- package/dist/esm/components/mui-checkbox/index.js +23 -18
- package/dist/esm/components/mui-chip/index.js +184 -68
- package/dist/esm/components/mui-chip-input/index.js +146 -137
- package/dist/esm/components/mui-chip-rail/index.js +154 -51
- package/dist/esm/components/mui-code/index.js +27 -8
- package/dist/esm/components/mui-container/index.js +68 -45
- package/dist/esm/components/mui-date-picker/index.js +169 -0
- package/dist/esm/components/mui-drawer/index.js +968 -100
- package/dist/esm/components/mui-dropdown/index.js +250 -63
- package/dist/esm/components/mui-field/index.js +1 -1
- package/dist/esm/components/mui-file-upload/index.js +13 -4
- package/dist/esm/components/mui-form-group/index.js +1 -2
- package/dist/esm/components/mui-form-message/index.js +4 -9
- package/dist/esm/components/mui-hint/index.js +178 -72
- package/dist/esm/components/mui-icons/copy/index.js +54 -0
- package/dist/esm/components/mui-icons/fullscreen/index.js +5 -0
- package/dist/esm/components/mui-icons/icon-helper/index.js +56 -0
- package/dist/esm/components/mui-icons/index.js +14 -1
- package/dist/esm/components/mui-icons/moon/index.js +3 -1
- package/dist/esm/components/mui-icons/{rectangle-bottom-panel → panel}/index.js +6 -6
- package/dist/esm/components/mui-icons/pause/index.js +5 -0
- package/dist/esm/components/mui-icons/picture-in-picture/index.js +5 -0
- package/dist/esm/components/mui-icons/play-fill/index.js +5 -0
- package/dist/esm/components/mui-icons/rectangle-right-drawer/index.js +56 -0
- package/dist/esm/components/mui-icons/reload/index.js +5 -0
- package/dist/esm/components/mui-icons/speaker-mute/index.js +5 -0
- package/dist/esm/components/mui-icons/speaker-one-wave/index.js +5 -0
- package/dist/esm/components/mui-icons/speaker-two-wave/index.js +5 -0
- package/dist/esm/components/mui-icons/spinner/index.js +7 -5
- package/dist/esm/components/mui-icons/stop-fill/index.js +5 -0
- package/dist/esm/components/mui-icons/sun/index.js +5 -5
- package/dist/esm/components/mui-icons/timer/index.js +54 -0
- package/dist/esm/components/mui-icons/toggle/index.js +16 -6
- package/dist/esm/components/mui-icons/vertical-ellipsis/index.js +5 -0
- package/dist/esm/components/mui-illustrations/trash/index.js +6 -5
- package/dist/esm/components/mui-input/index.js +87 -62
- package/dist/esm/components/mui-link/index.js +195 -83
- package/dist/esm/components/mui-media-player/index.js +1577 -83
- package/dist/esm/components/mui-model-viewer/index.js +258 -0
- package/dist/esm/components/mui-progress-ring/index.js +349 -0
- package/dist/esm/components/mui-prompt/index.js +99 -71
- package/dist/esm/components/mui-prompt-preview/index.js +11 -23
- package/dist/esm/components/mui-radio/index.js +38 -17
- package/dist/esm/components/mui-range-input/index.js +9 -4
- package/dist/esm/components/mui-responsive/index.js +60 -27
- package/dist/esm/components/mui-search-input/index.js +300 -0
- package/dist/esm/components/mui-select/index.js +231 -42
- package/dist/esm/components/mui-slat/slat/index.js +40 -12
- package/dist/esm/components/mui-spinner/index.js +11 -9
- package/dist/esm/components/mui-switch/index.js +23 -20
- package/dist/esm/components/mui-table/row/index.js +2 -6
- package/dist/esm/components/mui-table/table/index.js +157 -14
- package/dist/esm/components/mui-textarea/index.js +43 -26
- package/dist/esm/components/mui-time/index/index.js +336 -0
- package/dist/esm/components/mui-time-picker/index.js +126 -0
- package/dist/esm/components/mui-video-thumbnail/index.js +5 -5
- package/dist/esm/css/mui-brand.css +12 -8
- package/dist/esm/css/mui-tokens.css +417 -305
- package/dist/esm/css/readme.md +2 -2
- package/dist/esm/custom-elements.json +3678 -1553
- package/dist/esm/dynamic-attrs.json +263 -66
- package/dist/esm/index.js +30 -6
- package/dist/esm/knowledge/compositions/index.js +1560 -0
- package/dist/esm/knowledge/index.js +28 -0
- package/dist/esm/knowledge/keywords/index.js +306 -0
- package/dist/esm/knowledge/rules/index.js +199 -0
- package/dist/esm/tokens/js/index.js +143 -139
- package/dist/types/agent/keywords/index.d.ts +1 -1
- package/dist/types/components/mui-avatar-chip/api.d.ts +28 -0
- package/dist/types/components/mui-avatar-chip/index.d.ts +18 -0
- package/dist/types/components/mui-avatar-group/api.d.ts +28 -0
- package/dist/types/components/mui-avatar-group/doc.d.ts +2 -0
- package/dist/types/components/mui-avatar-group/index.d.ts +1 -0
- package/dist/types/components/mui-button/api.d.ts +2 -2
- package/dist/types/components/mui-calendar/api.d.ts +41 -0
- package/dist/types/components/mui-calendar/doc.d.ts +2 -0
- package/dist/types/components/mui-calendar/index.d.ts +3 -0
- package/dist/types/components/mui-checkbox/api.d.ts +4 -0
- package/dist/types/components/mui-chip-input/api.d.ts +4 -0
- package/dist/types/components/mui-chip-rail/index.d.ts +1 -0
- package/dist/types/components/mui-date-picker/api.d.ts +38 -0
- package/dist/types/components/mui-date-picker/doc.d.ts +2 -0
- package/dist/types/components/mui-date-picker/index.d.ts +6 -0
- package/dist/types/components/mui-drawer/api.d.ts +4 -0
- package/dist/types/components/mui-drawer/index.d.ts +2 -0
- package/dist/types/components/mui-file-upload/api.d.ts +4 -0
- package/dist/types/components/mui-icons/fullscreen.d.ts +1 -0
- package/dist/types/components/mui-icons/icon-helper.d.ts +1 -0
- package/dist/types/components/mui-icons/index.d.ts +14 -1
- package/dist/types/components/mui-icons/panel.d.ts +1 -0
- package/dist/types/components/mui-icons/pause.d.ts +1 -0
- package/dist/types/components/mui-icons/picture-in-picture.d.ts +1 -0
- package/dist/types/components/mui-icons/play-fill.d.ts +1 -0
- package/dist/types/components/mui-icons/rectangle-right-drawer.d.ts +1 -0
- package/dist/types/components/mui-icons/reload.d.ts +1 -0
- package/dist/types/components/mui-icons/speaker-mute.d.ts +1 -0
- package/dist/types/components/mui-icons/speaker-one-wave.d.ts +1 -0
- package/dist/types/components/mui-icons/speaker-two-wave.d.ts +1 -0
- package/dist/types/components/mui-icons/stop-fill.d.ts +1 -0
- package/dist/types/components/mui-icons/timer.d.ts +1 -0
- package/dist/types/components/mui-icons/vertical-ellipsis.d.ts +1 -0
- package/dist/types/components/mui-input/api.d.ts +12 -0
- package/dist/types/components/mui-media-player/api.d.ts +4 -0
- package/dist/types/components/mui-media-player/index.d.ts +13 -4
- package/dist/types/components/mui-model-viewer/api.d.ts +28 -0
- package/dist/types/components/mui-model-viewer/doc.d.ts +2 -0
- package/dist/types/components/mui-model-viewer/index.d.ts +17 -0
- package/dist/types/components/mui-progress-ring/api.d.ts +24 -0
- package/dist/types/components/mui-progress-ring/doc.d.ts +2 -0
- package/dist/types/components/mui-progress-ring/index.d.ts +1 -0
- package/dist/types/components/mui-radio/api.d.ts +12 -0
- package/dist/types/components/mui-range-input/api.d.ts +4 -0
- package/dist/types/components/mui-responsive/api.d.ts +10 -2
- package/dist/types/components/mui-search-input/api.d.ts +40 -0
- package/dist/types/components/mui-search-input/doc.d.ts +2 -0
- package/dist/types/components/mui-search-input/index.d.ts +3 -0
- package/dist/types/components/mui-select/api.d.ts +12 -0
- package/dist/types/components/mui-switch/api.d.ts +4 -0
- package/dist/types/components/mui-table/api.d.ts +15 -0
- package/dist/types/components/mui-textarea/api.d.ts +12 -0
- package/dist/types/components/mui-time/api.d.ts +41 -0
- package/dist/types/components/mui-time/doc.d.ts +2 -0
- package/dist/types/components/mui-time/index.d.ts +1 -0
- package/dist/types/components/mui-time-picker/api.d.ts +38 -0
- package/dist/types/components/mui-time-picker/doc.d.ts +2 -0
- package/dist/types/components/mui-time-picker/index.d.ts +4 -0
- package/dist/types/index.d.ts +24 -2
- package/dist/types/knowledge/compositions.d.ts +4644 -0
- package/dist/types/knowledge/index.d.ts +4657 -0
- package/dist/types/knowledge/keywords.d.ts +4 -0
- package/dist/types/knowledge/rules.d.ts +1 -0
- package/dist/types/tokens/js/index.d.ts +11 -7
- package/package.json +119 -12
- package/dist/esm/components/mui-form-hint/index.js +0 -1
- package/dist/types/components/mui-form-hint/index.d.ts +0 -1
- /package/dist/types/components/{mui-form-hint → mui-avatar-chip}/doc.d.ts +0 -0
- /package/dist/types/components/mui-icons/{rectangle-bottom-panel.d.ts → copy.d.ts} +0 -0
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
const
|
|
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.
|
|
5
|
+
(t = this.activeMenu) != null && t.classList.contains("show") && this.closeMenu();
|
|
6
6
|
}, this.handleScroll = () => {
|
|
7
7
|
var t;
|
|
8
|
-
(t = this.
|
|
8
|
+
(t = this.activeMenu) != null && t.classList.contains("show") && this.adjustPosition();
|
|
9
9
|
}, this.handleFocusOut = (t) => {
|
|
10
|
-
var e, n;
|
|
11
|
-
|
|
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
|
-
|
|
20
|
-
|
|
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,
|
|
35
|
-
t === "zindex" && this.menu && (this.menu.style.zIndex =
|
|
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
|
|
39
|
-
this.render(), this.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"), (
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
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
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
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
|
|
59
|
-
var
|
|
60
|
-
(
|
|
61
|
-
const d = (
|
|
62
|
-
if (this.button = d.find((
|
|
63
|
-
const
|
|
64
|
-
|
|
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
|
-
|
|
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), (
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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,
|
|
159
|
+
var e, n, o;
|
|
81
160
|
if (t.stopPropagation(), !this.menu) return;
|
|
82
|
-
const e = this.
|
|
83
|
-
!
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
|
98
|
-
let
|
|
99
|
-
|
|
100
|
-
let
|
|
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
|
-
|
|
288
|
+
f = this.portalMenu ? s.left : 0;
|
|
104
289
|
break;
|
|
105
290
|
case "center":
|
|
106
|
-
|
|
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
|
-
|
|
295
|
+
f = this.portalMenu ? s.right - u : s.width - u;
|
|
111
296
|
break;
|
|
112
297
|
}
|
|
113
|
-
const y =
|
|
114
|
-
|
|
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
|
-
|
|
181
|
-
let
|
|
182
|
-
customElements.get("mui-dropdown") || customElements.define("mui-dropdown",
|
|
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-
|
|
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-
|
|
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.
|
|
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
|
|
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",
|
|
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
|
-
${
|
|
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",
|
|
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);
|