@muibook/components 10.0.0 → 11.0.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/LICENSE +27 -11
- package/README.md +7 -7
- package/dist/esm/components/mui-accordion/block/index.js +9 -5
- package/dist/esm/components/mui-alert/index.js +88 -52
- package/dist/esm/components/mui-badge/index.js +61 -16
- package/dist/esm/components/mui-body/index.js +76 -10
- package/dist/esm/components/mui-button/index.js +152 -32
- package/dist/esm/components/mui-card/card/index.js +13 -8
- package/dist/esm/components/mui-checkbox/index.js +64 -30
- package/dist/esm/components/mui-chip/index.js +153 -33
- package/dist/esm/components/mui-chip-input/index.js +407 -0
- package/dist/esm/components/mui-code/index.js +11 -9
- package/dist/esm/components/mui-dialog/index.js +17 -8
- package/dist/esm/components/mui-dropdown/index.js +44 -44
- package/dist/esm/components/mui-field/index.js +56 -21
- package/dist/esm/components/mui-form-group/index.js +88 -0
- package/dist/esm/components/mui-form-hint/index.js +1 -0
- package/dist/esm/components/mui-form-message/index.js +72 -0
- package/dist/esm/components/mui-form-section/index.js +108 -0
- package/dist/esm/components/mui-form-section-footer/index.js +46 -0
- package/dist/esm/components/mui-hint/index.js +146 -0
- package/dist/esm/components/mui-icons/accessibility/index.js +5 -4
- package/dist/esm/components/mui-icons/add/index.js +1 -0
- package/dist/esm/components/mui-icons/ai/index.js +9 -14
- package/dist/esm/components/mui-icons/attention/index.js +1 -0
- package/dist/esm/components/mui-icons/calendar/index.js +5 -4
- package/dist/esm/components/mui-icons/check/index.js +6 -5
- package/dist/esm/components/mui-icons/checkmark/index.js +9 -8
- package/dist/esm/components/mui-icons/close/index.js +6 -5
- package/dist/esm/components/mui-icons/down-arrow-circle/index.js +9 -8
- package/dist/esm/components/mui-icons/down-chevron/index.js +8 -7
- package/dist/esm/components/mui-icons/ellipsis/index.js +1 -0
- package/dist/esm/components/mui-icons/exclamationmark/index.js +49 -0
- package/dist/esm/components/mui-icons/game-controller/index.js +8 -7
- package/dist/esm/components/mui-icons/gear/index.js +5 -4
- package/dist/esm/components/mui-icons/globe/index.js +8 -7
- package/dist/esm/components/mui-icons/grid/index.js +1 -0
- package/dist/esm/components/mui-icons/home/index.js +9 -8
- package/dist/esm/components/mui-icons/index.js +3 -0
- package/dist/esm/components/mui-icons/info/index.js +3 -2
- package/dist/esm/components/mui-icons/left-arrow/index.js +1 -0
- package/dist/esm/components/mui-icons/left-chevron/index.js +6 -5
- package/dist/esm/components/mui-icons/left-sidebar/index.js +6 -5
- package/dist/esm/components/mui-icons/list-and-film/index.js +1 -0
- package/dist/esm/components/mui-icons/menu/index.js +8 -7
- package/dist/esm/components/mui-icons/message/index.js +5 -4
- package/dist/esm/components/mui-icons/moon/index.js +3 -2
- package/dist/esm/components/mui-icons/movie-clapper/index.js +5 -4
- package/dist/esm/components/mui-icons/music-microphone/index.js +6 -5
- package/dist/esm/components/mui-icons/music-quarter-note/index.js +1 -0
- package/dist/esm/components/mui-icons/notification/index.js +5 -4
- package/dist/esm/components/mui-icons/pin/index.js +3 -2
- package/dist/esm/components/mui-icons/pin-slash/index.js +6 -5
- package/dist/esm/components/mui-icons/play-rectangle/index.js +9 -8
- package/dist/esm/components/mui-icons/play-stack/index.js +5 -4
- package/dist/esm/components/mui-icons/rectangle/index.js +6 -5
- package/dist/esm/components/mui-icons/rectangle-bottom-panel/index.js +1 -0
- package/dist/esm/components/mui-icons/rectangle-dashed/index.js +1 -0
- package/dist/esm/components/mui-icons/rectangle-left-drawer/index.js +1 -0
- package/dist/esm/components/mui-icons/rectangle-media-text/index.js +6 -5
- package/dist/esm/components/mui-icons/right-chevron/index.js +1 -0
- package/dist/esm/components/mui-icons/search/index.js +6 -5
- package/dist/esm/components/mui-icons/spinner/index.js +56 -0
- package/dist/esm/components/mui-icons/stop/index.js +3 -2
- package/dist/esm/components/mui-icons/subtract/index.js +1 -0
- package/dist/esm/components/mui-icons/sun/index.js +1 -0
- package/dist/esm/components/mui-icons/text-below-folder/index.js +55 -0
- package/dist/esm/components/mui-icons/toggle/index.js +8 -6
- package/dist/esm/components/mui-icons/translate/index.js +5 -4
- package/dist/esm/components/mui-icons/up-arrow/index.js +5 -4
- package/dist/esm/components/mui-icons/up-chevron/index.js +6 -5
- package/dist/esm/components/mui-icons/warning/index.js +7 -6
- package/dist/esm/components/mui-input/index.js +298 -47
- package/dist/esm/components/mui-link/index.js +187 -59
- package/dist/esm/components/mui-list/item/index.js +3 -0
- package/dist/esm/components/mui-markdown/index.js +149 -0
- package/dist/esm/components/mui-media-player/index.js +184 -0
- package/dist/esm/components/mui-message/index.js +50 -20
- package/dist/esm/components/mui-progress/index.js +15 -15
- package/dist/esm/components/mui-prompt/index.js +1461 -0
- package/dist/esm/components/mui-prompt-message/index.js +114 -0
- package/dist/esm/components/mui-prompt-preview/index.js +497 -0
- package/dist/esm/components/mui-prompt-toggle/index.js +48 -0
- package/dist/esm/components/mui-radio/index.js +155 -0
- package/dist/esm/components/mui-radio-group/index.js +104 -0
- package/dist/esm/components/mui-range-input/index.js +122 -0
- package/dist/esm/components/mui-rule/index.js +11 -3
- package/dist/esm/components/mui-select/index.js +89 -30
- package/dist/esm/components/mui-spinner/index.js +70 -0
- package/dist/esm/components/mui-stepper/step/index.js +255 -18
- package/dist/esm/components/mui-stepper/stepper/index.js +68 -72
- package/dist/esm/components/mui-table/row/index.js +16 -3
- package/dist/esm/components/mui-tabs/controller/index.js +21 -14
- package/dist/esm/components/mui-tabs/item/index.js +285 -29
- package/dist/esm/components/mui-tabs/panel/index.js +3 -0
- package/dist/esm/components/mui-tabs/tab-bar/index.js +85 -34
- package/dist/esm/components/mui-textarea/index.js +257 -0
- package/dist/esm/css/mui-base.css +27 -0
- package/dist/esm/css/mui-brand.css +3 -1
- package/dist/esm/css/mui-tokens.css +234 -7
- package/dist/esm/custom-elements.json +5450 -2039
- package/dist/esm/index.js +24 -4
- package/dist/esm/tokens/js/index.js +107 -105
- package/dist/types/components/mui-agent-bubble/doc.d.ts +2 -0
- package/dist/types/components/mui-agent-bubble/index.d.ts +1 -0
- package/dist/types/components/mui-agent-prompt/doc.d.ts +2 -0
- package/dist/types/components/mui-agent-prompt/index.d.ts +1 -0
- package/dist/types/components/mui-chip-input/doc.d.ts +2 -0
- package/dist/types/components/mui-chip-input/index.d.ts +3 -0
- package/dist/types/components/mui-form-group/doc.d.ts +2 -0
- package/dist/types/components/mui-form-group/index.d.ts +2 -0
- package/dist/types/components/mui-form-group-horizontal/index.d.ts +1 -0
- package/dist/types/components/mui-form-hint/doc.d.ts +2 -0
- package/dist/types/components/mui-form-hint/index.d.ts +1 -0
- package/dist/types/components/mui-form-message/index.d.ts +2 -0
- package/dist/types/components/mui-form-section/doc.d.ts +2 -0
- package/dist/types/components/mui-form-section/index.d.ts +1 -0
- package/dist/types/components/mui-form-section-footer/doc.d.ts +2 -0
- package/dist/types/components/mui-form-section-footer/index.d.ts +1 -0
- package/dist/types/components/mui-hint/doc.d.ts +2 -0
- package/dist/types/components/mui-hint/index.d.ts +1 -0
- package/dist/types/components/mui-icons/exclamationmark.d.ts +1 -0
- package/dist/types/components/mui-icons/index.d.ts +3 -0
- package/dist/types/components/mui-icons/spinner.d.ts +1 -0
- package/dist/types/components/mui-icons/text-below-folder.d.ts +1 -0
- package/dist/types/components/mui-markdown/doc.d.ts +2 -0
- package/dist/types/components/mui-markdown/index.d.ts +1 -0
- package/dist/types/components/mui-media-player/doc.d.ts +2 -0
- package/dist/types/components/mui-media-player/index.d.ts +8 -0
- package/dist/types/components/mui-prompt/doc.d.ts +2 -0
- package/dist/types/components/mui-prompt/index.d.ts +18 -0
- package/dist/types/components/mui-prompt-chip/index.d.ts +1 -0
- package/dist/types/components/mui-prompt-message/doc.d.ts +2 -0
- package/dist/types/components/mui-prompt-message/index.d.ts +1 -0
- package/dist/types/components/mui-prompt-preview/doc.d.ts +2 -0
- package/dist/types/components/mui-prompt-preview/index.d.ts +7 -0
- package/dist/types/components/mui-prompt-toggle/index.d.ts +1 -0
- package/dist/types/components/mui-radio/doc.d.ts +2 -0
- package/dist/types/components/mui-radio/index.d.ts +1 -0
- package/dist/types/components/mui-radio-group/index.d.ts +1 -0
- package/dist/types/components/mui-range-input/doc.d.ts +2 -0
- package/dist/types/components/mui-range-input/index.d.ts +1 -0
- package/dist/types/components/mui-spinner/doc.d.ts +2 -0
- package/dist/types/components/mui-spinner/index.d.ts +1 -0
- package/dist/types/components/mui-stepper/step/index.d.ts +4 -1
- package/dist/types/components/mui-textarea/doc.d.ts +2 -0
- package/dist/types/components/mui-textarea/index.d.ts +1 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/tokens/js/index.d.ts +2 -0
- package/package.json +88 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const s = class s extends HTMLElement {
|
|
2
2
|
constructor() {
|
|
3
3
|
super(), this.button = null, this.menu = null, this.handleResize = () => {
|
|
4
4
|
var t;
|
|
@@ -8,13 +8,13 @@ const n = class n extends HTMLElement {
|
|
|
8
8
|
(t = this.menu) != null && t.classList.contains("show") && this.adjustPosition();
|
|
9
9
|
}, this.handleFocusOut = (t) => {
|
|
10
10
|
var e;
|
|
11
|
-
this.persistent || this.contains(t.relatedTarget) || (this.closeWithAnimation(), (e = this.menu) == null || e.setAttribute("inert", "true"),
|
|
11
|
+
this.persistent || this.contains(t.relatedTarget) || (this.closeWithAnimation(), (e = this.menu) == null || e.setAttribute("inert", "true"), s.openDropdown === this && (s.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
|
|
12
12
|
}, this.attachShadow({ mode: "open" });
|
|
13
13
|
}
|
|
14
14
|
handleKeyDown(t) {
|
|
15
15
|
if (t.key === "Escape") {
|
|
16
16
|
if (!this.menu) return;
|
|
17
|
-
this.menu.classList.remove("show"), this.menu.setAttribute("inert", "true"),
|
|
17
|
+
this.menu.classList.remove("show"), this.menu.setAttribute("inert", "true"), s.openDropdown === this && (s.openDropdown = null), this.dispatchEvent(
|
|
18
18
|
new CustomEvent("dropdown-toggle", {
|
|
19
19
|
detail: { open: !1 },
|
|
20
20
|
bubbles: !0
|
|
@@ -23,39 +23,39 @@ const n = class n extends HTMLElement {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
static get observedAttributes() {
|
|
26
|
-
return ["zindex", "position", "persistent"];
|
|
26
|
+
return ["zindex", "position", "vertical-position", "persistent"];
|
|
27
27
|
}
|
|
28
28
|
get persistent() {
|
|
29
29
|
return this.hasAttribute("persistent");
|
|
30
30
|
}
|
|
31
|
-
attributeChangedCallback(t, e,
|
|
32
|
-
t === "zindex" && this.menu && (this.menu.style.zIndex =
|
|
31
|
+
attributeChangedCallback(t, e, n) {
|
|
32
|
+
t === "zindex" && this.menu && (this.menu.style.zIndex = n ?? "1"), (t === "position" || t === "vertical-position") && this.menu && this.adjustPosition();
|
|
33
33
|
}
|
|
34
34
|
connectedCallback() {
|
|
35
|
-
var
|
|
36
|
-
this.render(), this.menu = (
|
|
35
|
+
var i, r, l, a, h;
|
|
36
|
+
this.render(), this.menu = (i = this.shadowRoot) == null ? void 0 : i.querySelector(".dropdown-menu");
|
|
37
37
|
const t = this.getAttribute("zindex") || "1";
|
|
38
|
-
this.menu && (this.menu.style.zIndex = t), this.menu && this.menu.setAttribute("inert", "true"), (
|
|
39
|
-
const e = (
|
|
40
|
-
this.button =
|
|
41
|
-
(
|
|
38
|
+
this.menu && (this.menu.style.zIndex = t), this.menu && this.menu.setAttribute("inert", "true"), (r = this.menu) == null || r.addEventListener("focusout", this.handleFocusOut);
|
|
39
|
+
const e = (l = this.shadowRoot) == null ? void 0 : l.querySelector('slot[name="action"]'), n = (e == null ? void 0 : e.assignedNodes({ flatten: !0 })) || [];
|
|
40
|
+
this.button = n.find(
|
|
41
|
+
(u) => u instanceof HTMLElement && u.tagName.toLowerCase() === "mui-button"
|
|
42
42
|
);
|
|
43
|
-
const d = (
|
|
43
|
+
const d = (a = this.shadowRoot) == null ? void 0 : a.querySelector("slot:not([name])");
|
|
44
44
|
if (d) {
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
this.persistent || ((
|
|
53
|
-
}),
|
|
45
|
+
const u = () => {
|
|
46
|
+
const c = d.assignedElements({ flatten: !0 });
|
|
47
|
+
c.forEach((o) => {
|
|
48
|
+
o.removeAttribute("dropdown-slot"), o.removeAttribute("dropdown-slot-first"), o.removeAttribute("dropdown-slot-last");
|
|
49
|
+
}), c.forEach((o, w) => {
|
|
50
|
+
o.setAttribute("variant", "tertiary"), o.setAttribute("dropdown-slot", ""), w === 0 && o.setAttribute("dropdown-slot-first", ""), w === c.length - 1 && o.setAttribute("dropdown-slot-last", ""), o._dropdownListenerAdded || (o.addEventListener("click", () => {
|
|
51
|
+
var f, p;
|
|
52
|
+
this.persistent || ((f = this.menu) == null || f.classList.remove("show"), (p = this.menu) == null || p.setAttribute("inert", "true"), s.openDropdown === this && (s.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
|
|
53
|
+
}), o._dropdownListenerAdded = !0);
|
|
54
54
|
});
|
|
55
55
|
};
|
|
56
|
-
d.addEventListener("slotchange",
|
|
56
|
+
d.addEventListener("slotchange", u), u();
|
|
57
57
|
}
|
|
58
|
-
this.toggleMenu = this.toggleMenu.bind(this), this.closeMenu = this.closeMenu.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), (
|
|
58
|
+
this.toggleMenu = this.toggleMenu.bind(this), this.closeMenu = this.closeMenu.bind(this), this.handleKeyDown = this.handleKeyDown.bind(this), (h = this.button) == null || h.addEventListener("click", this.toggleMenu), document.addEventListener("click", this.closeMenu), document.addEventListener("keydown", this.handleKeyDown), window.addEventListener("resize", this.handleResize), window.addEventListener("scroll", this.handleScroll, !0);
|
|
59
59
|
}
|
|
60
60
|
disconnectedCallback() {
|
|
61
61
|
var t, e;
|
|
@@ -68,41 +68,41 @@ const n = class n extends HTMLElement {
|
|
|
68
68
|
}, 150);
|
|
69
69
|
}
|
|
70
70
|
toggleMenu(t) {
|
|
71
|
-
var
|
|
71
|
+
var n;
|
|
72
72
|
if (t.stopPropagation(), !this.menu) return;
|
|
73
73
|
const e = this.menu.classList.contains("show");
|
|
74
|
-
!e &&
|
|
75
|
-
var d,
|
|
76
|
-
(d = this.menu) == null || d.classList.add("show"), (
|
|
77
|
-
}),
|
|
74
|
+
!e && s.openDropdown && s.openDropdown !== this && s.openDropdown.closeWithAnimation(), e ? (this.closeWithAnimation(), (n = this.menu) == null || n.setAttribute("inert", "true"), s.openDropdown === this && (s.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 }))) : (this.menu.style.display = "block", requestAnimationFrame(() => {
|
|
75
|
+
var d, i;
|
|
76
|
+
(d = this.menu) == null || d.classList.add("show"), (i = this.menu) == null || i.removeAttribute("inert"), this.adjustPosition();
|
|
77
|
+
}), s.openDropdown = this, this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !0 }, bubbles: !0 })));
|
|
78
78
|
}
|
|
79
79
|
closeMenu(t) {
|
|
80
|
-
var
|
|
80
|
+
var n;
|
|
81
81
|
const e = t.composedPath();
|
|
82
|
-
this.menu && e.includes(this.menu) || this.button && e.includes(this.button) || (this.closeWithAnimation(), (
|
|
82
|
+
this.menu && e.includes(this.menu) || this.button && e.includes(this.button) || (this.closeWithAnimation(), (n = this.menu) == null || n.setAttribute("inert", "true"), s.openDropdown === this && (s.openDropdown = null), this.dispatchEvent(new CustomEvent("dropdown-toggle", { detail: { open: !1 }, bubbles: !0 })));
|
|
83
83
|
}
|
|
84
84
|
adjustPosition() {
|
|
85
85
|
if (!this.menu) return;
|
|
86
|
-
const t = this.menu, e = 8,
|
|
86
|
+
const t = this.menu, e = 8, n = getComputedStyle(this).getPropertyValue("--dropdown-offset").trim() || "0.8rem", d = parseFloat(getComputedStyle(document.documentElement).fontSize) || 10, i = n.endsWith("rem") ? parseFloat(n) * d : parseFloat(n) || 8;
|
|
87
87
|
t.style.top = "", t.style.bottom = "", t.style.left = "", t.style.right = "", t.style.maxWidth = "";
|
|
88
|
-
const
|
|
89
|
-
let
|
|
90
|
-
|
|
91
|
-
let
|
|
88
|
+
const r = this.getBoundingClientRect(), l = t.offsetWidth, a = t.offsetHeight, h = window.innerWidth, u = window.innerHeight, c = (this.getAttribute("vertical-position") || "auto").toLowerCase(), o = u - r.bottom, w = r.top, f = a + i, p = o >= f, g = w >= f;
|
|
89
|
+
let b = r.height + i;
|
|
90
|
+
c === "up" ? b = g || !p ? -(a + i) : r.height + i : c === "down" ? b = p || !g ? r.height + i : -(a + i) : !p && w > o && (b = -(a + i));
|
|
91
|
+
let m = 0;
|
|
92
92
|
switch (this.getAttribute("position") || "left") {
|
|
93
93
|
case "left":
|
|
94
|
-
|
|
94
|
+
m = 0;
|
|
95
95
|
break;
|
|
96
96
|
case "center":
|
|
97
|
-
|
|
97
|
+
m = (r.width - l) / 2;
|
|
98
98
|
break;
|
|
99
99
|
case "right":
|
|
100
100
|
default:
|
|
101
|
-
|
|
101
|
+
m = r.width - l;
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
104
|
+
const y = e - r.left, E = h - e - (r.left + l);
|
|
105
|
+
m = Math.max(y, Math.min(m, E)), l > h - e * 2 && (t.style.maxWidth = `${h - e * 2}px`), t.style.top = `${b}px`, t.style.left = `${m}px`;
|
|
106
106
|
}
|
|
107
107
|
render() {
|
|
108
108
|
this.shadowRoot.innerHTML = /*html*/
|
|
@@ -168,6 +168,6 @@ const n = class n extends HTMLElement {
|
|
|
168
168
|
`;
|
|
169
169
|
}
|
|
170
170
|
};
|
|
171
|
-
|
|
172
|
-
let
|
|
173
|
-
customElements.get("mui-dropdown") || customElements.define("mui-dropdown",
|
|
171
|
+
s.openDropdown = null;
|
|
172
|
+
let v = s;
|
|
173
|
+
customElements.get("mui-dropdown") || customElements.define("mui-dropdown", v);
|
|
@@ -1,22 +1,40 @@
|
|
|
1
|
-
class
|
|
1
|
+
class o extends HTMLElement {
|
|
2
2
|
static get observedAttributes() {
|
|
3
|
-
return ["variant", "message", "label", "hide-label"];
|
|
3
|
+
return ["variant", "message", "label", "hide-label", "size"];
|
|
4
4
|
}
|
|
5
5
|
constructor() {
|
|
6
6
|
super(), this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
7
7
|
<style>
|
|
8
|
-
:host {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
:host {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-direction: column;
|
|
11
|
+
}
|
|
12
|
+
.field-content {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
}
|
|
16
|
+
.message-container {
|
|
17
|
+
display: none;
|
|
18
|
+
}
|
|
19
|
+
:host([has-message]) .message-container {
|
|
20
|
+
display: flex;
|
|
21
|
+
margin-top: var(--space-300);
|
|
22
|
+
}
|
|
23
|
+
:host([size="x-small"][has-message]) .message-container { margin-top: var(--space-100); }
|
|
24
|
+
:host([size="small"][has-message]) .message-container { margin-top: var(--space-100); }
|
|
25
|
+
:host([size="medium"][has-message]) .message-container { margin-top: var(--space-300); }
|
|
26
|
+
:host([size="large"][has-message]) .message-container { margin-top: var(--space-300); }
|
|
14
27
|
|
|
15
28
|
::slotted(mui-checkbox) { padding-left: var(--space-025); }
|
|
16
29
|
</style>
|
|
17
30
|
|
|
18
|
-
<
|
|
19
|
-
|
|
31
|
+
<div class="field-content">
|
|
32
|
+
<slot></slot>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="message-container">
|
|
35
|
+
<slot name="message"></slot>
|
|
36
|
+
<div class="message-fallback"></div>
|
|
37
|
+
</div>
|
|
20
38
|
`;
|
|
21
39
|
}
|
|
22
40
|
// -----------------------
|
|
@@ -46,33 +64,50 @@ class a extends HTMLElement {
|
|
|
46
64
|
set hideLabel(e) {
|
|
47
65
|
e ? this.setAttribute("hide-label", "") : this.removeAttribute("hide-label");
|
|
48
66
|
}
|
|
67
|
+
get size() {
|
|
68
|
+
return this.getAttribute("size") || "medium";
|
|
69
|
+
}
|
|
70
|
+
set size(e) {
|
|
71
|
+
this.setAttribute("size", e);
|
|
72
|
+
}
|
|
49
73
|
// -----------------------
|
|
50
74
|
// Lifecycle methods
|
|
51
75
|
// -----------------------
|
|
52
76
|
connectedCallback() {
|
|
53
|
-
this.renderMessage(), this.passAttributesToChild();
|
|
77
|
+
this.bindSlotEvents(), this.renderMessage(), this.passAttributesToChild();
|
|
54
78
|
}
|
|
55
79
|
attributeChangedCallback(e) {
|
|
56
|
-
["variant", "message", "label", "hide-label"].includes(e) && (this.renderMessage(), this.passAttributesToChild());
|
|
80
|
+
["variant", "message", "label", "hide-label", "size"].includes(e) && (this.renderMessage(), this.passAttributesToChild());
|
|
57
81
|
}
|
|
58
82
|
// -----------------------
|
|
59
83
|
// Helper methods
|
|
60
84
|
// -----------------------
|
|
61
85
|
passAttributesToChild() {
|
|
62
|
-
var
|
|
86
|
+
var i;
|
|
63
87
|
if (!this.shadowRoot) return;
|
|
64
|
-
const e = this.shadowRoot.querySelector("slot"),
|
|
65
|
-
|
|
66
|
-
this.hasAttribute(
|
|
88
|
+
const e = this.shadowRoot.querySelector("slot"), t = (i = e == null ? void 0 : e.assignedElements) == null ? void 0 : i.call(e)[0];
|
|
89
|
+
t && ["variant", "label", "hide-label", "size"].forEach((s) => {
|
|
90
|
+
this.hasAttribute(s) ? t.setAttribute(s, this.getAttribute(s) || "") : t.removeAttribute(s);
|
|
67
91
|
});
|
|
68
92
|
}
|
|
69
93
|
renderMessage() {
|
|
70
94
|
if (!this.shadowRoot) return;
|
|
71
|
-
const e = this.shadowRoot.querySelector(".message-
|
|
72
|
-
if (!e) return;
|
|
95
|
+
const e = this.shadowRoot.querySelector(".message-fallback"), t = this.shadowRoot.querySelector('slot[name="message"]');
|
|
96
|
+
if (!e || !t) return;
|
|
73
97
|
const i = this.variant, s = this.message;
|
|
74
|
-
let
|
|
75
|
-
i === "success" ?
|
|
98
|
+
let a = "";
|
|
99
|
+
if (i === "success" ? a = '<mui-icon-check slot="before"></mui-icon-check>' : i === "warning" ? a = '<mui-icon-warning slot="before"></mui-icon-warning>' : i === "error" && (a = '<mui-icon-attention slot="before"></mui-icon-attention>'), t.assignedNodes({ flatten: !0 }).some((n) => n.nodeType === Node.ELEMENT_NODE ? !0 : n.nodeType === Node.TEXT_NODE ? (n.textContent || "").trim().length > 0 : !1)) {
|
|
100
|
+
e.innerHTML = "", this.setAttribute("has-message", "");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
e.innerHTML = s ? `<mui-body size="small" variant="${i}">${a}${s}</mui-body>` : "", s ? this.setAttribute("has-message", "") : this.removeAttribute("has-message");
|
|
104
|
+
}
|
|
105
|
+
bindSlotEvents() {
|
|
106
|
+
if (!this.shadowRoot) return;
|
|
107
|
+
const e = this.shadowRoot.querySelector('slot[name="message"]');
|
|
108
|
+
e && e.addEventListener("slotchange", () => this.renderMessage());
|
|
109
|
+
const t = this.shadowRoot.querySelector("slot:not([name])");
|
|
110
|
+
t && t.addEventListener("slotchange", () => this.passAttributesToChild());
|
|
76
111
|
}
|
|
77
112
|
}
|
|
78
|
-
customElements.get("mui-field") || customElements.define("mui-field",
|
|
113
|
+
customElements.get("mui-field") || customElements.define("mui-field", o);
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import "../mui-heading/index.js";
|
|
2
|
+
import "../mui-body/index.js";
|
|
3
|
+
class h extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ["heading", "hide-label", "variant"];
|
|
6
|
+
}
|
|
7
|
+
constructor() {
|
|
8
|
+
super(), this.attachShadow({ mode: "open" });
|
|
9
|
+
}
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
this.render(), this.setupSlotBehavior();
|
|
12
|
+
}
|
|
13
|
+
attributeChangedCallback() {
|
|
14
|
+
this.render();
|
|
15
|
+
}
|
|
16
|
+
render() {
|
|
17
|
+
if (!this.shadowRoot) return;
|
|
18
|
+
const t = this.getAttribute("heading") || "", e = this.hasAttribute("hide-label"), r = this.hasAttribute("choice-group");
|
|
19
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
20
|
+
`
|
|
21
|
+
<style>
|
|
22
|
+
:host {
|
|
23
|
+
display: block;
|
|
24
|
+
}
|
|
25
|
+
.group {
|
|
26
|
+
display: grid;
|
|
27
|
+
gap: var(--space-500);
|
|
28
|
+
}
|
|
29
|
+
.group-heading {
|
|
30
|
+
display: block;
|
|
31
|
+
margin: 0;
|
|
32
|
+
}
|
|
33
|
+
.group-label {
|
|
34
|
+
display: inline-flex;
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
.content {
|
|
38
|
+
display: grid;
|
|
39
|
+
gap: var(--space-500);
|
|
40
|
+
min-inline-size: 0;
|
|
41
|
+
}
|
|
42
|
+
.content-inner {
|
|
43
|
+
display: contents;
|
|
44
|
+
}
|
|
45
|
+
:host([variant="horizontal"]) .content {
|
|
46
|
+
grid-template-columns: var(--form-group-horizontal-template, minmax(0, 1fr) minmax(0, 20rem));
|
|
47
|
+
align-items: start;
|
|
48
|
+
}
|
|
49
|
+
:host([variant="horizontal"]) .content-inner ::slotted(*) {
|
|
50
|
+
min-inline-size: 0;
|
|
51
|
+
}
|
|
52
|
+
:host([variant="horizontal"]) .content-inner ::slotted(mui-form-message),
|
|
53
|
+
:host([variant="horizontal"]) .content-inner ::slotted(mui-form-hint) {
|
|
54
|
+
grid-column: 1 / -1;
|
|
55
|
+
}
|
|
56
|
+
@media (max-width: 767px) {
|
|
57
|
+
:host([variant="horizontal"]) .content {
|
|
58
|
+
grid-template-columns: 1fr;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
</style>
|
|
62
|
+
|
|
63
|
+
<div class="group">
|
|
64
|
+
${t && !e ? r ? `<mui-body class="group-label" size="small" weight="bold" variant="optional">${t}</mui-body>` : `<mui-heading class="group-heading" size="5" level="5">${t}</mui-heading>` : ""}
|
|
65
|
+
<div class="content">
|
|
66
|
+
<div class="content-inner">
|
|
67
|
+
<slot></slot>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
setupSlotBehavior() {
|
|
74
|
+
if (!this.shadowRoot) return;
|
|
75
|
+
const t = this.shadowRoot.querySelector("slot");
|
|
76
|
+
if (!t) return;
|
|
77
|
+
const e = () => {
|
|
78
|
+
const r = t.assignedElements({ flatten: !0 }), a = "mui-radio-group, mui-radio, mui-checkbox, mui-switch", n = r.some((i) => {
|
|
79
|
+
var s;
|
|
80
|
+
const o = i.tagName.toLowerCase();
|
|
81
|
+
return o === "mui-radio-group" || o === "mui-radio" || o === "mui-checkbox" || o === "mui-switch" ? !0 : !!((s = i.querySelector) != null && s.call(i, a));
|
|
82
|
+
});
|
|
83
|
+
n && !this.hasAttribute("choice-group") ? (this.setAttribute("choice-group", ""), this.render()) : !n && this.hasAttribute("choice-group") && (this.removeAttribute("choice-group"), this.render());
|
|
84
|
+
};
|
|
85
|
+
t.addEventListener("slotchange", e), e();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
customElements.get("mui-form-group") || customElements.define("mui-form-group", h);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../mui-form-message/index.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import "../mui-body/index.js";
|
|
2
|
+
import "../mui-icons/info/index.js";
|
|
3
|
+
class a extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ["size", "weight", "variant"];
|
|
6
|
+
}
|
|
7
|
+
constructor() {
|
|
8
|
+
super(), this.attachShadow({ mode: "open" });
|
|
9
|
+
}
|
|
10
|
+
getIconColor(t) {
|
|
11
|
+
return {
|
|
12
|
+
optional: "var(--text-color-optional)",
|
|
13
|
+
warning: "var(--text-color-warning)",
|
|
14
|
+
success: "var(--text-color-success)",
|
|
15
|
+
error: "var(--text-color-error)"
|
|
16
|
+
}[t] || "var(--text-color)";
|
|
17
|
+
}
|
|
18
|
+
getIconSize(t) {
|
|
19
|
+
return {
|
|
20
|
+
"x-small": "x-small",
|
|
21
|
+
small: "small",
|
|
22
|
+
medium: "small",
|
|
23
|
+
large: "medium"
|
|
24
|
+
}[t] || "small";
|
|
25
|
+
}
|
|
26
|
+
syncBeforeIcon() {
|
|
27
|
+
if (!this.shadowRoot) return;
|
|
28
|
+
const t = this.shadowRoot.querySelector('slot[name="before"]'), e = this.getIconColor(this.getAttribute("variant") || "optional"), o = this.getIconSize(this.getAttribute("size") || "small");
|
|
29
|
+
((t == null ? void 0 : t.assignedElements({ flatten: !0 })) ?? []).forEach((s) => {
|
|
30
|
+
s.tagName.toLowerCase().startsWith("mui-icon-") && (s.hasAttribute("color") || s.setAttribute("color", e), s.hasAttribute("size") || s.setAttribute("size", o));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
connectedCallback() {
|
|
34
|
+
this.hasAttribute("size") || this.setAttribute("size", "small"), this.render();
|
|
35
|
+
}
|
|
36
|
+
attributeChangedCallback() {
|
|
37
|
+
this.render();
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
if (!this.shadowRoot) return;
|
|
41
|
+
const t = this.getAttribute("size") || "small", e = this.getAttribute("weight") || "regular", o = this.getAttribute("variant") || "optional";
|
|
42
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
43
|
+
`
|
|
44
|
+
<style>
|
|
45
|
+
:host {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
width: 100%;
|
|
48
|
+
}
|
|
49
|
+
mui-body {
|
|
50
|
+
margin-inline-start: var(--stroke-size-100);
|
|
51
|
+
margin-block-start: var(--space-200);
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
54
|
+
|
|
55
|
+
<mui-body size="${t}" weight="${e}" variant="${o}">
|
|
56
|
+
<slot slot="before" name="before">
|
|
57
|
+
<mui-icon-info id="default-before-icon" size="${this.getIconSize(t)}" color="${this.getIconColor(o)}"></mui-icon-info>
|
|
58
|
+
</slot>
|
|
59
|
+
<slot></slot>
|
|
60
|
+
<slot slot="after" name="after"></slot>
|
|
61
|
+
</mui-body>
|
|
62
|
+
`;
|
|
63
|
+
const i = this.shadowRoot.querySelector('slot[name="before"]');
|
|
64
|
+
i == null || i.addEventListener("slotchange", () => this.syncBeforeIcon()), this.syncBeforeIcon();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
customElements.get("mui-form-message") || customElements.define("mui-form-message", a);
|
|
68
|
+
if (!customElements.get("mui-form-hint")) {
|
|
69
|
+
class r extends a {
|
|
70
|
+
}
|
|
71
|
+
customElements.define("mui-form-hint", r);
|
|
72
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import "../mui-heading/index.js";
|
|
2
|
+
class n extends HTMLElement {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(), this.onSlotChange = () => {
|
|
5
|
+
if (!this.shadowRoot) return;
|
|
6
|
+
const e = this.shadowRoot.querySelector('slot[name="header"]'), t = this.shadowRoot.querySelector('slot[name="footer"]'), o = !!(e != null && e.assignedElements({ flatten: !0 }).length), s = !!(t != null && t.assignedElements({ flatten: !0 }).length);
|
|
7
|
+
this.toggleAttribute("has-header", o), this.toggleAttribute("has-footer", s);
|
|
8
|
+
}, this.attachShadow({ mode: "open" });
|
|
9
|
+
}
|
|
10
|
+
static get observedAttributes() {
|
|
11
|
+
return ["heading", "heading-level", "disabled", "borderless"];
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
this.render();
|
|
15
|
+
}
|
|
16
|
+
attributeChangedCallback() {
|
|
17
|
+
this.render();
|
|
18
|
+
}
|
|
19
|
+
render() {
|
|
20
|
+
if (!this.shadowRoot) return;
|
|
21
|
+
const e = this.getAttribute("heading") || "", t = Number(this.getAttribute("heading-level") || "4"), o = Number.isFinite(t) ? Math.min(6, Math.max(1, Math.trunc(t))) : 4, s = this.hasAttribute("disabled");
|
|
22
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
23
|
+
`
|
|
24
|
+
<style>
|
|
25
|
+
:host {
|
|
26
|
+
display: block;
|
|
27
|
+
}
|
|
28
|
+
fieldset {
|
|
29
|
+
border: var(--border-thin);
|
|
30
|
+
border-color: var(--border-color);
|
|
31
|
+
border-radius: var(--radius-200);
|
|
32
|
+
padding: var(--space-500);
|
|
33
|
+
background: var(--surface-elevated-100);
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
min-inline-size: 0;
|
|
36
|
+
margin: 0;
|
|
37
|
+
}
|
|
38
|
+
:host([borderless]) fieldset {
|
|
39
|
+
border: none;
|
|
40
|
+
}
|
|
41
|
+
@media (min-width: 768px) {
|
|
42
|
+
fieldset {
|
|
43
|
+
padding: var(--space-600);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
legend {
|
|
47
|
+
margin: 0;
|
|
48
|
+
padding: 0;
|
|
49
|
+
}
|
|
50
|
+
.legend-row {
|
|
51
|
+
margin-bottom: var(--space-600);
|
|
52
|
+
}
|
|
53
|
+
:host([has-header]) .legend-row {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
.header {
|
|
57
|
+
margin-bottom: var(--space-600);
|
|
58
|
+
}
|
|
59
|
+
:host(:not([has-header])) .header {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
.vh {
|
|
63
|
+
position: absolute;
|
|
64
|
+
width: 1px;
|
|
65
|
+
height: 1px;
|
|
66
|
+
margin: -1px;
|
|
67
|
+
padding: 0;
|
|
68
|
+
overflow: hidden;
|
|
69
|
+
clip: rect(0 0 0 0);
|
|
70
|
+
white-space: nowrap;
|
|
71
|
+
border: 0;
|
|
72
|
+
}
|
|
73
|
+
.content {
|
|
74
|
+
display: grid;
|
|
75
|
+
gap: var(--space-500);
|
|
76
|
+
}
|
|
77
|
+
.footer {
|
|
78
|
+
margin-top: var(--space-600);
|
|
79
|
+
}
|
|
80
|
+
:host(:not([has-footer])) .footer {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
:host([disabled]) {
|
|
84
|
+
cursor: not-allowed;
|
|
85
|
+
}
|
|
86
|
+
:host([disabled]) fieldset {
|
|
87
|
+
opacity: 0.7;
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
90
|
+
|
|
91
|
+
<fieldset ${s ? "disabled" : ""}>
|
|
92
|
+
${e ? `<legend class="vh">${e}</legend><div class="legend-row"><mui-heading size="4" level="${o}">${e}</mui-heading></div>` : ""}
|
|
93
|
+
<div class="header">
|
|
94
|
+
<slot name="header"></slot>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="content">
|
|
97
|
+
<slot></slot>
|
|
98
|
+
</div>
|
|
99
|
+
<div class="footer">
|
|
100
|
+
<slot name="footer"></slot>
|
|
101
|
+
</div>
|
|
102
|
+
</fieldset>
|
|
103
|
+
`;
|
|
104
|
+
const a = this.shadowRoot.querySelector('slot[name="header"]'), i = this.shadowRoot.querySelector('slot[name="footer"]');
|
|
105
|
+
a == null || a.addEventListener("slotchange", this.onSlotChange), i == null || i.addEventListener("slotchange", this.onSlotChange), this.onSlotChange();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
customElements.get("mui-form-section") || customElements.define("mui-form-section", n);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class s extends HTMLElement {
|
|
2
|
+
constructor() {
|
|
3
|
+
super(), this.onSlotChange = () => {
|
|
4
|
+
if (!this.shadowRoot) return;
|
|
5
|
+
const e = this.shadowRoot.querySelector("slot"), o = ((e == null ? void 0 : e.assignedElements({ flatten: !0 })) ?? []).some((t) => t.tagName.toLowerCase() === "mui-rule" || !!t.querySelector("mui-rule"));
|
|
6
|
+
this.toggleAttribute("has-rule", o);
|
|
7
|
+
}, this.attachShadow({ mode: "open" });
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.render();
|
|
11
|
+
}
|
|
12
|
+
render() {
|
|
13
|
+
if (!this.shadowRoot) return;
|
|
14
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
15
|
+
`
|
|
16
|
+
<style>
|
|
17
|
+
:host {
|
|
18
|
+
display: block;
|
|
19
|
+
width: 100%;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.content {
|
|
24
|
+
display: grid;
|
|
25
|
+
gap: var(--form-section-footer-gap, var(--space-300));
|
|
26
|
+
width: 100%;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
:host([has-rule]) .content {
|
|
31
|
+
gap: var(--form-section-footer-gap-with-rule, var(--space-400));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
::slotted(mui-rule) {
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
38
|
+
<div class="content">
|
|
39
|
+
<slot></slot>
|
|
40
|
+
</div>
|
|
41
|
+
`;
|
|
42
|
+
const e = this.shadowRoot.querySelector("slot");
|
|
43
|
+
e == null || e.addEventListener("slotchange", this.onSlotChange), this.onSlotChange();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
customElements.get("mui-form-section-footer") || customElements.define("mui-form-section-footer", s);
|