@muibook/components 19.6.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 +53 -2
- package/dist/esm/agent/keywords/index.js +2 -173
- package/dist/esm/agent/prompts/index.js +6 -432
- package/dist/esm/components/mui-accordion/core/index.js +25 -17
- package/dist/esm/components/mui-addon/index.js +14 -14
- package/dist/esm/components/mui-avatar/index.js +103 -43
- 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 +37 -20
- package/dist/esm/components/mui-body/index.js +20 -11
- package/dist/esm/components/mui-button/index.js +265 -78
- package/dist/esm/components/mui-calendar/index.js +199 -0
- package/dist/esm/components/mui-card/body/index.js +33 -18
- 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 +219 -73
- package/dist/esm/components/mui-chip-input/index.js +146 -137
- package/dist/esm/components/mui-chip-rail/index.js +342 -0
- package/dist/esm/components/mui-code/index.js +26 -7
- 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 +255 -59
- package/dist/esm/components/mui-field/index.js +1 -1
- package/dist/esm/components/mui-file-upload/index.js +14 -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-heading/index.js +3 -2
- 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 +96 -67
- package/dist/esm/components/mui-link/index.js +352 -96
- package/dist/esm/components/mui-media-player/index.js +1577 -83
- package/dist/esm/components/mui-message/index.js +7 -6
- 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 +143 -115
- 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 +235 -46
- 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-stack/hstack/index.js +10 -5
- package/dist/esm/components/mui-status/index.js +239 -0
- package/dist/esm/components/mui-stepper/step/index.js +46 -32
- package/dist/esm/components/mui-switch/index.js +37 -26
- 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-tabs/controller/index.js +17 -6
- package/dist/esm/components/mui-tabs/item/index.js +17 -5
- package/dist/esm/components/mui-tabs/tab-bar/index.js +93 -39
- 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 +205 -0
- package/dist/esm/css/mui-brand.css +12 -8
- package/dist/esm/css/mui-tokens.css +646 -344
- package/dist/esm/css/readme.md +2 -2
- package/dist/esm/custom-elements.json +4506 -1707
- package/dist/esm/dynamic-attrs.json +271 -54
- package/dist/esm/index.js +33 -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 +6 -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/api.d.ts +4 -0
- package/dist/types/components/mui-chip-input/api.d.ts +4 -0
- package/dist/types/components/mui-chip-rail/api.d.ts +21 -0
- package/dist/types/components/mui-chip-rail/doc.d.ts +2 -0
- package/dist/types/components/mui-chip-rail/index.d.ts +4 -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-link/api.d.ts +4 -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-status/api.d.ts +24 -0
- package/dist/types/components/mui-status/doc.d.ts +2 -0
- package/dist/types/components/mui-status/index.d.ts +1 -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/components/mui-video-thumbnail/api.d.ts +28 -0
- package/dist/types/components/mui-video-thumbnail/doc.d.ts +2 -0
- package/dist/types/components/mui-video-thumbnail/index.d.ts +1 -0
- package/dist/types/index.d.ts +27 -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 +131 -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
|
@@ -6,41 +6,62 @@ class c extends HTMLElement {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), this.attachShadow({ mode: "open" });
|
|
8
8
|
}
|
|
9
|
+
get checked() {
|
|
10
|
+
var t;
|
|
11
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
|
|
12
|
+
return (e == null ? void 0 : e.checked) ?? this.hasAttribute("checked");
|
|
13
|
+
}
|
|
14
|
+
set checked(e) {
|
|
15
|
+
this.toggleAttribute("checked", !!e);
|
|
16
|
+
}
|
|
17
|
+
get value() {
|
|
18
|
+
var t;
|
|
19
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
|
|
20
|
+
return (e == null ? void 0 : e.value) ?? this.getAttribute("value") ?? "";
|
|
21
|
+
}
|
|
22
|
+
set value(e) {
|
|
23
|
+
this.setAttribute("value", e ?? "");
|
|
24
|
+
}
|
|
25
|
+
focus(e) {
|
|
26
|
+
var a;
|
|
27
|
+
const t = (a = this.shadowRoot) == null ? void 0 : a.querySelector("input");
|
|
28
|
+
t ? t.focus(e) : super.focus(e);
|
|
29
|
+
}
|
|
9
30
|
connectedCallback() {
|
|
10
31
|
this.hasAttribute("size") || this.setAttribute("size", "medium"), this.render(), this.setupListener();
|
|
11
32
|
}
|
|
12
33
|
disconnectedCallback() {
|
|
13
34
|
this.cleanupListeners();
|
|
14
35
|
}
|
|
15
|
-
attributeChangedCallback(e,
|
|
36
|
+
attributeChangedCallback(e, t, a) {
|
|
16
37
|
var r;
|
|
17
|
-
const
|
|
38
|
+
const i = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
|
|
18
39
|
if (e === "checked") {
|
|
19
|
-
|
|
40
|
+
i && (i.checked = a !== null);
|
|
20
41
|
return;
|
|
21
42
|
}
|
|
22
43
|
if (e === "disabled") {
|
|
23
|
-
|
|
44
|
+
i && (i.disabled = a !== null);
|
|
24
45
|
return;
|
|
25
46
|
}
|
|
26
47
|
["id", "name", "value", "aria-label", "size"].includes(e) && (this.render(), this.setupListener());
|
|
27
48
|
}
|
|
28
49
|
cleanupListeners() {
|
|
29
|
-
var
|
|
30
|
-
const e = (
|
|
50
|
+
var t;
|
|
51
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
|
|
31
52
|
e && this._changeHandler && e.removeEventListener("change", this._changeHandler);
|
|
32
53
|
}
|
|
33
54
|
setupListener() {
|
|
34
|
-
var
|
|
35
|
-
const e = (
|
|
55
|
+
var t;
|
|
56
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector("input");
|
|
36
57
|
e && (this.cleanupListeners(), this._changeHandler = (a) => {
|
|
37
|
-
const
|
|
38
|
-
|
|
58
|
+
const i = a.target;
|
|
59
|
+
i.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.dispatchEvent(
|
|
39
60
|
new CustomEvent("change", {
|
|
40
61
|
detail: {
|
|
41
|
-
checked:
|
|
42
|
-
value:
|
|
43
|
-
name:
|
|
62
|
+
checked: i.checked,
|
|
63
|
+
value: i.value,
|
|
64
|
+
name: i.name
|
|
44
65
|
},
|
|
45
66
|
bubbles: !0,
|
|
46
67
|
composed: !0
|
|
@@ -49,7 +70,7 @@ class c extends HTMLElement {
|
|
|
49
70
|
}, e.addEventListener("change", this._changeHandler));
|
|
50
71
|
}
|
|
51
72
|
render() {
|
|
52
|
-
const e = this.getAttribute("id") || `mui-radio-${Math.random().toString(36).substr(2, 9)}`,
|
|
73
|
+
const e = this.getAttribute("id") || `mui-radio-${Math.random().toString(36).substr(2, 9)}`, t = this.getAttribute("name") || "", a = this.getAttribute("value") || "", i = this.hasAttribute("checked"), r = this.hasAttribute("disabled"), s = this.getAttribute("aria-label") || "", o = this.getAttribute("size") || "medium", d = ["x-small", "small", "medium", "large"].includes(o) ? o : "medium", l = this.innerHTML.trim().length > 0;
|
|
53
74
|
this.shadowRoot.innerHTML = /*html*/
|
|
54
75
|
`
|
|
55
76
|
<style>
|
|
@@ -141,11 +162,11 @@ class c extends HTMLElement {
|
|
|
141
162
|
<input
|
|
142
163
|
type="radio"
|
|
143
164
|
id="${e}"
|
|
144
|
-
name="${
|
|
165
|
+
name="${t}"
|
|
145
166
|
value="${a}"
|
|
146
|
-
${
|
|
167
|
+
${i ? "checked" : ""}
|
|
147
168
|
${r ? "disabled" : ""}
|
|
148
|
-
${
|
|
169
|
+
${s ? `aria-label="${s}"` : ""}
|
|
149
170
|
/>
|
|
150
171
|
${l ? `<mui-body size="${d === "x-small" || d === "small" ? "x-small" : "small"}"><slot></slot></mui-body>` : ""}
|
|
151
172
|
</label>
|
|
@@ -18,6 +18,11 @@ class u extends HTMLElement {
|
|
|
18
18
|
set value(e) {
|
|
19
19
|
this.setAttribute("value", String(Number.isFinite(e) ? e : 0));
|
|
20
20
|
}
|
|
21
|
+
focus(e) {
|
|
22
|
+
var r;
|
|
23
|
+
const t = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
|
|
24
|
+
t ? t.focus(e) : super.focus(e);
|
|
25
|
+
}
|
|
21
26
|
getThumbSize() {
|
|
22
27
|
return Number(this.getAttribute("thumb-size") || "16");
|
|
23
28
|
}
|
|
@@ -32,8 +37,8 @@ class u extends HTMLElement {
|
|
|
32
37
|
if (!this.shadowRoot) return;
|
|
33
38
|
const e = this.shadowRoot.querySelector("input"), t = this.shadowRoot.querySelector('[data-role="bubble"]');
|
|
34
39
|
if (!e || !t) return;
|
|
35
|
-
const r = Number(e.min || "0"), a = Number(e.max || "0"), i = Number(e.value || "0"),
|
|
36
|
-
t.textContent = this.formatBubble(i), t.style.left = `calc(${
|
|
40
|
+
const r = Number(e.min || "0"), a = Number(e.max || "0"), i = Number(e.value || "0"), s = Math.max(0, a - r), o = s > 0 ? Math.max(0, Math.min(1, (i - r) / s)) : 0, n = this.getThumbSize();
|
|
41
|
+
t.textContent = this.formatBubble(i), t.style.left = `calc(${o * 100}% - ${(o - 0.5) * n}px)`;
|
|
37
42
|
}
|
|
38
43
|
bind() {
|
|
39
44
|
if (!this.shadowRoot) return;
|
|
@@ -64,7 +69,7 @@ class u extends HTMLElement {
|
|
|
64
69
|
}
|
|
65
70
|
render() {
|
|
66
71
|
if (!this.shadowRoot) return;
|
|
67
|
-
const e = this.getAttribute("min") || "0", t = this.getAttribute("max") || "100", r = this.getAttribute("value") || "0", a = this.getAttribute("step") || "1", i = this.hasAttribute("disabled"),
|
|
72
|
+
const e = this.getAttribute("min") || "0", t = this.getAttribute("max") || "100", r = this.getAttribute("value") || "0", a = this.getAttribute("step") || "1", i = this.hasAttribute("disabled"), s = this.getAttribute("label") || "Range input";
|
|
68
73
|
this.shadowRoot.innerHTML = /*html*/
|
|
69
74
|
`
|
|
70
75
|
<style>
|
|
@@ -111,7 +116,7 @@ class u extends HTMLElement {
|
|
|
111
116
|
max="${t}"
|
|
112
117
|
value="${r}"
|
|
113
118
|
step="${a}"
|
|
114
|
-
aria-label="${
|
|
119
|
+
aria-label="${s.replace(/"/g, """)}"
|
|
115
120
|
${i ? "disabled" : ""}
|
|
116
121
|
/>
|
|
117
122
|
<mui-body data-role="bubble" size="x-small" variant="optional" aria-hidden="true">0</mui-body>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
class a extends HTMLElement {
|
|
2
2
|
constructor() {
|
|
3
|
-
super(), this.slotEl = null, this.mqlLow = null, this.mqlHigh = null, this.mqlSingle = null, this.cleanup = null;
|
|
4
|
-
const
|
|
3
|
+
super(), this.slotEl = null, this.mqlLow = null, this.mqlHigh = null, this.mqlSingle = null, this.resizeObserver = null, this.cleanup = null;
|
|
4
|
+
const e = this.attachShadow({ mode: "open" }), s = (
|
|
5
5
|
/*css*/
|
|
6
6
|
`
|
|
7
7
|
:host { display: block; }
|
|
8
8
|
`
|
|
9
9
|
);
|
|
10
|
-
|
|
10
|
+
e.innerHTML = `
|
|
11
11
|
<style>${s}</style>
|
|
12
12
|
<slot></slot>
|
|
13
|
-
`, this.slotEl =
|
|
13
|
+
`, this.slotEl = e.querySelector("slot");
|
|
14
14
|
}
|
|
15
15
|
static get observedAttributes() {
|
|
16
|
-
return ["breakpoint", "breakpoint-low", "breakpoint-high"];
|
|
16
|
+
return ["variant", "observe", "breakpoint", "breakpoint-low", "breakpoint-high"];
|
|
17
17
|
}
|
|
18
18
|
connectedCallback() {
|
|
19
19
|
this.setupResponsive();
|
|
@@ -21,41 +21,74 @@ class a extends HTMLElement {
|
|
|
21
21
|
disconnectedCallback() {
|
|
22
22
|
this.teardownResponsive();
|
|
23
23
|
}
|
|
24
|
-
attributeChangedCallback(
|
|
25
|
-
s !==
|
|
24
|
+
attributeChangedCallback(e, s, o) {
|
|
25
|
+
s !== o && a.observedAttributes.includes(e) && this.setupResponsive();
|
|
26
26
|
}
|
|
27
27
|
teardownResponsive() {
|
|
28
|
-
var
|
|
29
|
-
(
|
|
28
|
+
var e, s;
|
|
29
|
+
(e = this.cleanup) == null || e.call(this), this.cleanup = null, this.mqlLow = null, this.mqlHigh = null, this.mqlSingle = null, (s = this.resizeObserver) == null || s.disconnect(), this.resizeObserver = null;
|
|
30
|
+
}
|
|
31
|
+
getSlotName(e, s, o, r) {
|
|
32
|
+
if (s && o) {
|
|
33
|
+
const t = parseInt(s), i = parseInt(o);
|
|
34
|
+
return Number.isNaN(t) || Number.isNaN(i) ? null : e <= t ? "showBelow" : e >= i ? "showAbove" : "showMiddle";
|
|
35
|
+
}
|
|
36
|
+
if (r) {
|
|
37
|
+
const t = parseInt(r);
|
|
38
|
+
return Number.isNaN(t) ? null : e <= t ? "showBelow" : "showAbove";
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
getObservedElement() {
|
|
43
|
+
const e = this.getAttribute("observe");
|
|
44
|
+
if (!e || e === "self") return this;
|
|
45
|
+
if (e === "parent") return this.parentElement || this;
|
|
46
|
+
try {
|
|
47
|
+
return this.closest(e) || this;
|
|
48
|
+
} catch {
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
30
51
|
}
|
|
31
52
|
setupResponsive() {
|
|
32
|
-
const
|
|
33
|
-
if (this.teardownResponsive(), !!this.slotEl)
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
53
|
+
const e = this.getAttribute("variant") || "viewport", s = this.getAttribute("breakpoint"), o = this.getAttribute("breakpoint-low"), r = this.getAttribute("breakpoint-high");
|
|
54
|
+
if (this.teardownResponsive(), !!this.slotEl) {
|
|
55
|
+
if (e === "container") {
|
|
56
|
+
const t = this.getObservedElement(), i = (n) => {
|
|
57
|
+
const l = this.getSlotName(n, o, r, s);
|
|
58
|
+
l ? this.slotEl.setAttribute("name", l) : this.slotEl.removeAttribute("name");
|
|
59
|
+
};
|
|
60
|
+
i(t.getBoundingClientRect().width), this.resizeObserver = new ResizeObserver((n) => {
|
|
61
|
+
const l = n[0];
|
|
62
|
+
l && i(l.contentRect.width);
|
|
63
|
+
}), this.resizeObserver.observe(t);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (o && r) {
|
|
67
|
+
const t = parseInt(o), i = parseInt(r);
|
|
68
|
+
if (Number.isNaN(t) || Number.isNaN(i)) return;
|
|
69
|
+
this.mqlLow = window.matchMedia(`(max-width: ${t}px)`), this.mqlHigh = window.matchMedia(`(min-width: ${i}px)`);
|
|
70
|
+
const n = () => {
|
|
71
|
+
const l = this.mqlLow.matches, h = this.mqlHigh.matches, u = l ? "showBelow" : h ? "showAbove" : "showMiddle";
|
|
72
|
+
this.slotEl.setAttribute("name", u);
|
|
41
73
|
};
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
(
|
|
74
|
+
n(), this.mqlLow.addEventListener("change", n), this.mqlHigh.addEventListener("change", n), this.cleanup = () => {
|
|
75
|
+
var l, h;
|
|
76
|
+
(l = this.mqlLow) == null || l.removeEventListener("change", n), (h = this.mqlHigh) == null || h.removeEventListener("change", n);
|
|
45
77
|
};
|
|
46
|
-
} else if (
|
|
47
|
-
const
|
|
48
|
-
if (Number.isNaN(
|
|
49
|
-
this.mqlSingle = window.matchMedia(`(max-width: ${
|
|
78
|
+
} else if (s) {
|
|
79
|
+
const t = parseInt(s);
|
|
80
|
+
if (Number.isNaN(t)) return;
|
|
81
|
+
this.mqlSingle = window.matchMedia(`(max-width: ${t}px)`);
|
|
50
82
|
const i = () => {
|
|
51
83
|
this.slotEl.setAttribute("name", this.mqlSingle.matches ? "showBelow" : "showAbove");
|
|
52
84
|
};
|
|
53
85
|
i(), this.mqlSingle.addEventListener("change", i), this.cleanup = () => {
|
|
54
|
-
var
|
|
55
|
-
(
|
|
86
|
+
var n;
|
|
87
|
+
(n = this.mqlSingle) == null || n.removeEventListener("change", i);
|
|
56
88
|
};
|
|
57
89
|
} else
|
|
58
90
|
this.slotEl.removeAttribute("name");
|
|
91
|
+
}
|
|
59
92
|
}
|
|
60
93
|
}
|
|
61
94
|
customElements.get("mui-responsive") || customElements.define("mui-responsive", a);
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import "../mui-button/index.js";
|
|
2
|
+
import "../mui-icons/search/index.js";
|
|
3
|
+
import "../mui-input/index.js";
|
|
4
|
+
class l extends HTMLElement {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.slotChangeHandler = () => this.syncAfterSlotState(), this.actionSlotChangeHandler = () => {
|
|
7
|
+
this.syncAction(), this.syncOpenState();
|
|
8
|
+
}, this.animationFrame = 0, this.attachShadow({ mode: "open" });
|
|
9
|
+
}
|
|
10
|
+
static get observedAttributes() {
|
|
11
|
+
return ["id", "label", "placeholder", "value", "name", "size", "disabled", "open", "autofocus", "cancel-label"];
|
|
12
|
+
}
|
|
13
|
+
get value() {
|
|
14
|
+
return this.getAttribute("value") || "";
|
|
15
|
+
}
|
|
16
|
+
set value(t) {
|
|
17
|
+
this.setAttribute("value", t ?? "");
|
|
18
|
+
}
|
|
19
|
+
get open() {
|
|
20
|
+
return this.hasAttribute("open");
|
|
21
|
+
}
|
|
22
|
+
set open(t) {
|
|
23
|
+
t ? this.setAttribute("open", "") : this.removeAttribute("open");
|
|
24
|
+
}
|
|
25
|
+
connectedCallback() {
|
|
26
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium"), this.hasAttribute("label") || this.setAttribute("label", "Search"), this.hasAttribute("placeholder") || this.setAttribute("placeholder", "Search..."), this.render(), this.setupListeners(), this.syncAfterSlotState(), this.queueAutofocus();
|
|
27
|
+
}
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
this.animationFrame && cancelAnimationFrame(this.animationFrame);
|
|
30
|
+
}
|
|
31
|
+
attributeChangedCallback(t, i, s) {
|
|
32
|
+
if (i !== s) {
|
|
33
|
+
if (t === "value") {
|
|
34
|
+
const e = this.inputEl;
|
|
35
|
+
e && e.getAttribute("value") !== (s || "") && e.setAttribute("value", s || "");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (t === "open") {
|
|
39
|
+
this.syncOpenState(!0), s !== null && this.queueAutofocus();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.render(), this.setupListeners(), this.syncAfterSlotState(), this.queueAutofocus();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
focus(t) {
|
|
46
|
+
var i;
|
|
47
|
+
(i = this.inputEl) == null || i.focus(t);
|
|
48
|
+
}
|
|
49
|
+
openSearch() {
|
|
50
|
+
this.open = !0;
|
|
51
|
+
}
|
|
52
|
+
closeSearch() {
|
|
53
|
+
this.open = !1;
|
|
54
|
+
}
|
|
55
|
+
toggleSearch() {
|
|
56
|
+
this.open = !this.open;
|
|
57
|
+
}
|
|
58
|
+
get inputEl() {
|
|
59
|
+
var t;
|
|
60
|
+
return (t = this.shadowRoot) == null ? void 0 : t.querySelector("mui-input");
|
|
61
|
+
}
|
|
62
|
+
get actionEl() {
|
|
63
|
+
var s, e;
|
|
64
|
+
const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector('slot[name="action"]');
|
|
65
|
+
return (t == null ? void 0 : t.assignedElements({ flatten: !0 }).find((a) => a instanceof HTMLElement)) || ((e = this.shadowRoot) == null ? void 0 : e.querySelector(".search-trigger"));
|
|
66
|
+
}
|
|
67
|
+
syncAction() {
|
|
68
|
+
var i;
|
|
69
|
+
const t = this.actionEl;
|
|
70
|
+
t && (t.classList.add("search-trigger"), t.setAttribute("aria-expanded", this.open ? "true" : "false"), !t.hasAttribute("aria-label") && !((i = t.textContent) != null && i.trim()) && t.setAttribute("aria-label", "Search"), this.hasAttribute("disabled") ? t.setAttribute("disabled", "") : t.removeAttribute("disabled"), t.onclick = () => this.openSearch());
|
|
71
|
+
}
|
|
72
|
+
emitToggleEvent() {
|
|
73
|
+
this.dispatchEvent(
|
|
74
|
+
new CustomEvent("toggle", {
|
|
75
|
+
detail: { open: this.open },
|
|
76
|
+
bubbles: !0,
|
|
77
|
+
composed: !0
|
|
78
|
+
})
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
syncAfterSlotState() {
|
|
82
|
+
var s;
|
|
83
|
+
const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector('slot[name="after"]'), i = !!(t != null && t.assignedNodes({ flatten: !0 }).some((e) => e.nodeType === Node.ELEMENT_NODE || (e.textContent || "").trim()));
|
|
84
|
+
this.toggleAttribute("has-after", i), this.syncOpenState();
|
|
85
|
+
}
|
|
86
|
+
syncOpenState(t = !1) {
|
|
87
|
+
var n, r, c;
|
|
88
|
+
const i = this.actionEl, s = (n = this.shadowRoot) == null ? void 0 : n.querySelector(".cancel"), e = (r = this.shadowRoot) == null ? void 0 : r.querySelector(".after-panel"), a = (c = this.shadowRoot) == null ? void 0 : c.querySelector(".search-panel"), o = this.hasAttribute("has-after");
|
|
89
|
+
this.open ? (i == null || i.setAttribute("aria-expanded", "true"), s == null || s.removeAttribute("tabindex"), e == null || e.setAttribute("aria-hidden", "true"), e == null || e.setAttribute("inert", ""), a == null || a.removeAttribute("inert")) : (i == null || i.setAttribute("aria-expanded", "false"), s == null || s.setAttribute("tabindex", "-1"), e == null || e.setAttribute("aria-hidden", "false"), e == null || e.removeAttribute("inert"), o ? a == null || a.setAttribute("inert", "") : a == null || a.removeAttribute("inert")), t && this.emitToggleEvent();
|
|
90
|
+
}
|
|
91
|
+
queueAutofocus() {
|
|
92
|
+
!this.hasAttribute("autofocus") && !this.open || (this.animationFrame && cancelAnimationFrame(this.animationFrame), this.animationFrame = requestAnimationFrame(() => {
|
|
93
|
+
this.animationFrame = requestAnimationFrame(() => {
|
|
94
|
+
this.focus({ preventScroll: !0 });
|
|
95
|
+
});
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
setupListeners() {
|
|
99
|
+
if (!this.shadowRoot) return;
|
|
100
|
+
const t = this.inputEl, i = this.shadowRoot.querySelector('slot[name="after"]'), s = this.shadowRoot.querySelector('slot[name="action"]'), e = this.shadowRoot.querySelector(".cancel");
|
|
101
|
+
i == null || i.removeEventListener("slotchange", this.slotChangeHandler), i == null || i.addEventListener("slotchange", this.slotChangeHandler), s == null || s.removeEventListener("slotchange", this.actionSlotChangeHandler), s == null || s.addEventListener("slotchange", this.actionSlotChangeHandler), t && (t.oninput = (a) => {
|
|
102
|
+
var r;
|
|
103
|
+
a.stopPropagation();
|
|
104
|
+
const n = ((r = a.detail) == null ? void 0 : r.value) ?? t.getAttribute("value") ?? "";
|
|
105
|
+
this.setAttribute("value", n), this.dispatchEvent(
|
|
106
|
+
new CustomEvent("input", {
|
|
107
|
+
detail: { value: n },
|
|
108
|
+
bubbles: !0,
|
|
109
|
+
composed: !0
|
|
110
|
+
})
|
|
111
|
+
);
|
|
112
|
+
}, t.onchange = (a) => {
|
|
113
|
+
var r;
|
|
114
|
+
a.stopPropagation();
|
|
115
|
+
const n = ((r = a.detail) == null ? void 0 : r.value) ?? t.getAttribute("value") ?? "";
|
|
116
|
+
this.dispatchEvent(
|
|
117
|
+
new CustomEvent("change", {
|
|
118
|
+
detail: { value: n },
|
|
119
|
+
bubbles: !0,
|
|
120
|
+
composed: !0
|
|
121
|
+
})
|
|
122
|
+
);
|
|
123
|
+
}, t.onkeydown = (a) => {
|
|
124
|
+
var o;
|
|
125
|
+
a.key === "Escape" && this.open && (a.preventDefault(), this.closeSearch(), (o = this.actionEl) == null || o.focus());
|
|
126
|
+
}), this.syncAction(), e == null || e.addEventListener("click", () => {
|
|
127
|
+
var a;
|
|
128
|
+
this.closeSearch(), (a = this.actionEl) == null || a.focus();
|
|
129
|
+
}), this.syncOpenState();
|
|
130
|
+
}
|
|
131
|
+
render() {
|
|
132
|
+
const t = this.getAttribute("id") || `mui-search-input-${Math.random().toString(36).slice(2, 9)}`, i = this.getAttribute("label") || "Search", s = this.getAttribute("placeholder") || "Search...", e = this.getAttribute("name") || "", a = this.value, o = this.getAttribute("size") || "medium", n = this.hasAttribute("disabled"), r = this.getAttribute("cancel-label") || "Cancel";
|
|
133
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
134
|
+
`
|
|
135
|
+
<style>
|
|
136
|
+
:host {
|
|
137
|
+
display: block;
|
|
138
|
+
width: 100%;
|
|
139
|
+
--search-transition-duration: 280ms;
|
|
140
|
+
--search-transition-easing: cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.shell {
|
|
144
|
+
display: grid;
|
|
145
|
+
grid-template-columns: minmax(0, 1fr);
|
|
146
|
+
align-items: center;
|
|
147
|
+
width: 100%;
|
|
148
|
+
gap: var(--space-200);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.after-panel {
|
|
152
|
+
grid-area: 1 / 1;
|
|
153
|
+
display: none;
|
|
154
|
+
min-width: 0;
|
|
155
|
+
opacity: 0;
|
|
156
|
+
transform: translateY(calc(var(--space-400) * -1));
|
|
157
|
+
transition:
|
|
158
|
+
opacity 180ms ease,
|
|
159
|
+
transform var(--search-transition-duration) var(--search-transition-easing);
|
|
160
|
+
z-index: 1;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host([has-after]) .after-panel {
|
|
164
|
+
display: grid;
|
|
165
|
+
grid-template-columns: auto minmax(0, 1fr);
|
|
166
|
+
align-items: center;
|
|
167
|
+
gap: var(--space-200);
|
|
168
|
+
opacity: 1;
|
|
169
|
+
transform: translateY(0);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
:host([has-after][open]) .after-panel {
|
|
173
|
+
opacity: 0;
|
|
174
|
+
transform: translateY(var(--space-500));
|
|
175
|
+
pointer-events: none;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.after-content {
|
|
179
|
+
min-width: 0;
|
|
180
|
+
overflow: hidden;
|
|
181
|
+
opacity: 1;
|
|
182
|
+
transition: opacity 180ms ease;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
:host([has-after][open]) .after-content {
|
|
186
|
+
opacity: 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.search-panel {
|
|
190
|
+
grid-area: 1 / 1;
|
|
191
|
+
display: grid;
|
|
192
|
+
grid-template-columns: minmax(0, 1fr) auto;
|
|
193
|
+
align-items: center;
|
|
194
|
+
gap: var(--space-300);
|
|
195
|
+
min-width: 0;
|
|
196
|
+
opacity: 1;
|
|
197
|
+
transform: translateY(0);
|
|
198
|
+
transition:
|
|
199
|
+
opacity 180ms ease,
|
|
200
|
+
transform var(--search-transition-duration) var(--search-transition-easing);
|
|
201
|
+
z-index: 2;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
:host(:not([open])) .search-panel {
|
|
205
|
+
grid-template-columns: minmax(0, 1fr) 0fr;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
:host([has-after]:not([open])) .search-panel {
|
|
209
|
+
opacity: 0;
|
|
210
|
+
transform: translateY(calc(var(--space-500) * -1));
|
|
211
|
+
pointer-events: none;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.cancel-wrap {
|
|
215
|
+
min-width: 0;
|
|
216
|
+
overflow: hidden;
|
|
217
|
+
opacity: 1;
|
|
218
|
+
transition: opacity 180ms ease;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
:host(:not([open])) .cancel-wrap {
|
|
222
|
+
opacity: 0;
|
|
223
|
+
pointer-events: none;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.search-trigger {
|
|
227
|
+
--action-focus-outline-offset: var(--stroke-size-200);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.input-wrap {
|
|
231
|
+
min-width: 0;
|
|
232
|
+
opacity: 1;
|
|
233
|
+
transition: opacity 120ms ease;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
:host([has-after]:not([open])) .input-wrap {
|
|
237
|
+
opacity: 0;
|
|
238
|
+
pointer-events: none;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
mui-input {
|
|
242
|
+
display: block;
|
|
243
|
+
width: 100%;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
mui-icon-search {
|
|
247
|
+
pointer-events: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
@media (prefers-reduced-motion: reduce) {
|
|
251
|
+
.shell,
|
|
252
|
+
.after-panel,
|
|
253
|
+
.search-panel,
|
|
254
|
+
.input-wrap,
|
|
255
|
+
.cancel-wrap {
|
|
256
|
+
transition: none;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
</style>
|
|
260
|
+
|
|
261
|
+
<div class="shell">
|
|
262
|
+
<div class="after-panel" aria-hidden="${this.open ? "true" : "false"}">
|
|
263
|
+
<slot name="action">
|
|
264
|
+
<mui-button class="search-trigger" variant="tertiary" icon-only aria-label="Search" aria-expanded="${this.open ? "true" : "false"}" ${n ? "disabled" : ""}>
|
|
265
|
+
<mui-icon-search></mui-icon-search>
|
|
266
|
+
</mui-button>
|
|
267
|
+
</slot>
|
|
268
|
+
<div class="after-content">
|
|
269
|
+
<slot name="after"></slot>
|
|
270
|
+
</div>
|
|
271
|
+
</div>
|
|
272
|
+
|
|
273
|
+
<div class="search-panel">
|
|
274
|
+
<div class="input-wrap">
|
|
275
|
+
<mui-input
|
|
276
|
+
id="${t}"
|
|
277
|
+
type="search"
|
|
278
|
+
name="${e}"
|
|
279
|
+
size="${o}"
|
|
280
|
+
label="${i}"
|
|
281
|
+
hide-label
|
|
282
|
+
placeholder="${s}"
|
|
283
|
+
value="${a}"
|
|
284
|
+
${n ? "disabled" : ""}
|
|
285
|
+
${this.hasAttribute("autofocus") ? "autofocus" : ""}
|
|
286
|
+
>
|
|
287
|
+
<mui-icon-search slot="inside-before"></mui-icon-search>
|
|
288
|
+
</mui-input>
|
|
289
|
+
</div>
|
|
290
|
+
<div class="cancel-wrap">
|
|
291
|
+
<mui-button class="cancel" variant="tertiary" ${n ? "disabled" : ""} ${this.open ? "" : 'tabindex="-1"'}>
|
|
292
|
+
${r}
|
|
293
|
+
</mui-button>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
</div>
|
|
297
|
+
`;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
customElements.get("mui-search-input") || customElements.define("mui-search-input", l);
|