@muibook/components 11.0.1 → 12.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/dist/esm/components/mui-addon/index.js +41 -8
- package/dist/esm/components/mui-field/index.js +26 -9
- package/dist/esm/components/mui-hint/index.js +6 -6
- package/dist/esm/components/mui-image/index.js +89 -42
- package/dist/esm/components/mui-input/index.js +67 -27
- package/dist/esm/components/mui-markdown/index.js +313 -73
- package/dist/esm/components/mui-prompt/index.js +87 -64
- package/dist/esm/components/mui-prompt-preview/index.js +43 -18
- package/dist/esm/components/mui-rule/index.js +7 -5
- package/dist/esm/components/mui-select/index.js +48 -15
- package/dist/esm/components/mui-skeleton/index.js +139 -0
- package/dist/esm/components/mui-slide-frame/index.js +410 -0
- package/dist/esm/components/mui-switch/index.js +72 -35
- package/dist/esm/components/mui-tabs/tab-bar/index.js +1 -1
- package/dist/esm/components/mui-textarea/index.js +40 -7
- package/dist/esm/css/mui-brand.css +1 -1
- package/dist/esm/css/mui-tokens.css +26 -0
- package/dist/esm/custom-elements.json +1366 -525
- package/dist/esm/index.js +6 -4
- package/dist/types/components/mui-prompt-preview/index.d.ts +1 -0
- package/dist/types/components/mui-skeleton/doc.d.ts +2 -0
- package/dist/types/components/mui-skeleton/index.d.ts +1 -0
- package/dist/types/components/mui-slide-frame/doc.d.ts +2 -0
- package/dist/types/components/mui-slide-frame/index.d.ts +7 -0
- package/dist/types/index.d.ts +2 -0
- package/package.json +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getPartMap as
|
|
1
|
+
import { getPartMap as a } from "../../utils/part-map/index.js";
|
|
2
2
|
import "../mui-icons/down-chevron/index.js";
|
|
3
3
|
class x extends HTMLElement {
|
|
4
4
|
constructor() {
|
|
@@ -8,7 +8,7 @@ class x extends HTMLElement {
|
|
|
8
8
|
return ["name", "value", "id", "label", "options", "disabled", "hide-label", "variant", "optional", "size"];
|
|
9
9
|
}
|
|
10
10
|
async connectedCallback() {
|
|
11
|
-
this.hasAttribute("size") || this.setAttribute("size", "medium"), await this.waitForPartMap(), this.partMap =
|
|
11
|
+
this.hasAttribute("size") || this.setAttribute("size", "medium"), await this.waitForPartMap(), this.partMap = a("text", "visual"), this.render(), this.setupListener();
|
|
12
12
|
}
|
|
13
13
|
disconnectedCallback() {
|
|
14
14
|
this.cleanupListeners();
|
|
@@ -47,20 +47,20 @@ class x extends HTMLElement {
|
|
|
47
47
|
}
|
|
48
48
|
render() {
|
|
49
49
|
if (!this.shadowRoot) return;
|
|
50
|
-
const e = this.getAttribute("name") || "", t = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`, r = this.getAttribute("label") || "", o = this.getAttribute("value") || "",
|
|
50
|
+
const e = this.getAttribute("name") || "", t = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`, r = this.getAttribute("label") || "", o = this.getAttribute("value") || "", s = this.hasAttribute("hide-label"), d = this.hasAttribute("optional"), v = this.hasAttribute("disabled"), p = this.getAttribute("options") || "[]", n = this.getAttribute("size") || "medium", l = ["x-small", "small", "medium", "large"].includes(n) ? n : "medium", u = {
|
|
51
51
|
"x-small": "xx-small",
|
|
52
52
|
small: "x-small",
|
|
53
53
|
medium: "x-small",
|
|
54
54
|
large: "small"
|
|
55
|
-
}[l] || "x-small", c = this.getAttribute("variant") || "",
|
|
56
|
-
let
|
|
55
|
+
}[l] || "x-small", c = this.getAttribute("variant") || "", g = c || "", b = s && r ? `aria-label="${r}"` : "";
|
|
56
|
+
let h = [];
|
|
57
57
|
try {
|
|
58
|
-
|
|
59
|
-
} catch (
|
|
60
|
-
console.error("Invalid JSON in options attribute",
|
|
58
|
+
h = JSON.parse(p);
|
|
59
|
+
} catch (i) {
|
|
60
|
+
console.error("Invalid JSON in options attribute", i);
|
|
61
61
|
}
|
|
62
|
-
const
|
|
63
|
-
(
|
|
62
|
+
const m = h.map(
|
|
63
|
+
(i) => `<option value="${i.value}" ${i.value === o ? "selected" : ""} ${i.disabled ? "disabled" : ""}>${i.label}</option>`
|
|
64
64
|
).join(""), f = (
|
|
65
65
|
/*html*/
|
|
66
66
|
`
|
|
@@ -71,11 +71,28 @@ class x extends HTMLElement {
|
|
|
71
71
|
}
|
|
72
72
|
label {
|
|
73
73
|
font-size: var(--text-font-size);
|
|
74
|
+
line-height: var(--text-line-height);
|
|
74
75
|
font-weight: var(--font-weight-medium);
|
|
75
76
|
margin-bottom: var(--space-100);
|
|
76
77
|
color: var(--text-color);
|
|
77
78
|
display: block;
|
|
78
79
|
}
|
|
80
|
+
:host([size="x-small"]) label {
|
|
81
|
+
font-size: var(--text-font-size-xs);
|
|
82
|
+
line-height: var(--text-line-height-xs);
|
|
83
|
+
}
|
|
84
|
+
:host([size="small"]) label {
|
|
85
|
+
font-size: var(--text-font-size-s);
|
|
86
|
+
line-height: var(--text-line-height-s);
|
|
87
|
+
}
|
|
88
|
+
:host([size="medium"]) label {
|
|
89
|
+
font-size: var(--text-font-size);
|
|
90
|
+
line-height: var(--text-line-height);
|
|
91
|
+
}
|
|
92
|
+
:host([size="large"]) label {
|
|
93
|
+
font-size: var(--text-font-size-l);
|
|
94
|
+
line-height: var(--text-line-height-l);
|
|
95
|
+
}
|
|
79
96
|
select {
|
|
80
97
|
min-height: 4.4rem;
|
|
81
98
|
line-height: var(--text-line-height);
|
|
@@ -177,6 +194,22 @@ class x extends HTMLElement {
|
|
|
177
194
|
text-transform: uppercase;
|
|
178
195
|
font-weight: var(--font-weight-medium);
|
|
179
196
|
}
|
|
197
|
+
:host([size="x-small"]) .optional {
|
|
198
|
+
font-size: var(--text-font-size-xs);
|
|
199
|
+
line-height: var(--text-line-height-xs);
|
|
200
|
+
}
|
|
201
|
+
:host([size="small"]) .optional {
|
|
202
|
+
font-size: var(--text-font-size-xs);
|
|
203
|
+
line-height: var(--text-line-height-xs);
|
|
204
|
+
}
|
|
205
|
+
:host([size="medium"]) .optional {
|
|
206
|
+
font-size: var(--text-font-size-s);
|
|
207
|
+
line-height: var(--text-line-height-s);
|
|
208
|
+
}
|
|
209
|
+
:host([size="large"]) .optional {
|
|
210
|
+
font-size: var(--text-font-size);
|
|
211
|
+
line-height: var(--text-line-height);
|
|
212
|
+
}
|
|
180
213
|
.optional-dot {
|
|
181
214
|
display: inline-flex;
|
|
182
215
|
align-items: center;
|
|
@@ -253,12 +286,12 @@ class x extends HTMLElement {
|
|
|
253
286
|
</style>
|
|
254
287
|
${r ? (
|
|
255
288
|
/*html*/
|
|
256
|
-
`<label for="${t}" class="${
|
|
289
|
+
`<label for="${t}" class="${s ? "vh" : ""}">${r}${d ? ' <span class="optional"><span class="optional-dot" aria-hidden="true">•</span><span class="optional-text">Optional</span></span>' : ""}</label>`
|
|
257
290
|
) : ""}
|
|
258
291
|
<div style="position: relative;">
|
|
259
|
-
<select class="${[
|
|
292
|
+
<select class="${[g, `size-${l}`].filter(Boolean).join(" ")}" part="${this.partMap || ""}" name="${e}" id="${t}" ${b}
|
|
260
293
|
${v ? "disabled" : ""}>
|
|
261
|
-
${
|
|
294
|
+
${m}
|
|
262
295
|
</select>
|
|
263
296
|
<mui-icon-down-chevron class="chevron" size="${u}"></mui-icon-down-chevron>
|
|
264
297
|
</div>
|
|
@@ -268,9 +301,9 @@ class x extends HTMLElement {
|
|
|
268
301
|
}
|
|
269
302
|
waitForPartMap() {
|
|
270
303
|
return new Promise((e) => {
|
|
271
|
-
if (typeof
|
|
304
|
+
if (typeof a == "function") return e();
|
|
272
305
|
const t = () => {
|
|
273
|
-
typeof
|
|
306
|
+
typeof a == "function" ? e() : requestAnimationFrame(t);
|
|
274
307
|
};
|
|
275
308
|
t();
|
|
276
309
|
});
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
class u extends HTMLElement {
|
|
2
|
+
static get observedAttributes() {
|
|
3
|
+
return ["shape", "size", "width", "height", "radius", "animation", "lines", "gap", "loading", "line-widths", "max-width", "duration"];
|
|
4
|
+
}
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.attachShadow({ mode: "open" });
|
|
7
|
+
}
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
this.render();
|
|
10
|
+
}
|
|
11
|
+
attributeChangedCallback(t, e) {
|
|
12
|
+
t !== e && this.render();
|
|
13
|
+
}
|
|
14
|
+
getSizeHeight(t) {
|
|
15
|
+
const e = {
|
|
16
|
+
"x-small": "var(--text-font-size-xs)",
|
|
17
|
+
small: "var(--text-font-size-s)",
|
|
18
|
+
medium: "var(--text-font-size-m)",
|
|
19
|
+
large: "var(--text-font-size-l)"
|
|
20
|
+
};
|
|
21
|
+
return e[t] || e.medium;
|
|
22
|
+
}
|
|
23
|
+
getCircleSize(t) {
|
|
24
|
+
const e = {
|
|
25
|
+
"x-small": "var(--space-200)",
|
|
26
|
+
small: "var(--space-300)",
|
|
27
|
+
medium: "var(--space-400)",
|
|
28
|
+
large: "var(--space-500)"
|
|
29
|
+
};
|
|
30
|
+
return e[t] || e.medium;
|
|
31
|
+
}
|
|
32
|
+
getLineWidths(t) {
|
|
33
|
+
const e = (this.getAttribute("line-widths") || "").trim();
|
|
34
|
+
if (!e) {
|
|
35
|
+
const i = [];
|
|
36
|
+
for (let a = 0; a < t; a += 1)
|
|
37
|
+
t > 1 && a === t - 1 ? i.push("72%") : a % 3 === 1 ? i.push("92%") : i.push("100%");
|
|
38
|
+
return i;
|
|
39
|
+
}
|
|
40
|
+
const s = e.split(",").map((i) => i.trim()).filter(Boolean);
|
|
41
|
+
if (s.length === 0) return Array.from({ length: t }).map(() => "100%");
|
|
42
|
+
const n = [];
|
|
43
|
+
for (let i = 0; i < t; i += 1) n.push(s[Math.min(i, s.length - 1)]);
|
|
44
|
+
return n;
|
|
45
|
+
}
|
|
46
|
+
render() {
|
|
47
|
+
if (!this.shadowRoot) return;
|
|
48
|
+
const t = (this.getAttribute("shape") || "line").toLowerCase(), e = (this.getAttribute("size") || "medium").toLowerCase(), s = Math.max(1, Number(this.getAttribute("lines") || "1")), n = this.getAttribute("width") || "100%", i = this.getAttribute("max-width") || "", a = this.getAttribute("gap") || "var(--skeleton-gap, var(--space-200))", o = this.getAttribute("duration") || "var(--skeleton-animation-speed, 2000ms)", r = (this.getAttribute("loading") || "true").toLowerCase() !== "false", l = this.getAttribute("height") || (t === "circle" ? this.getCircleSize(e) : t === "rect" ? "var(--space-600)" : this.getSizeHeight(e)), h = this.getAttribute("radius") || (t === "circle" ? "999px" : "var(--skeleton-radius, var(--radius-200))"), d = this.getLineWidths(s), c = Array.from({ length: s }).map((g, m) => `<span class="block" style="--block-width: ${s > 1 ? d[m] : n}; --block-height: ${l}; --block-radius: ${h}; --block-max-width: ${i || "100%"};"></span>`).join("");
|
|
49
|
+
this.shadowRoot.innerHTML = /*html*/
|
|
50
|
+
`
|
|
51
|
+
<style>
|
|
52
|
+
:host {
|
|
53
|
+
display: block;
|
|
54
|
+
}
|
|
55
|
+
.content[hidden],
|
|
56
|
+
.skeleton-shell[hidden] {
|
|
57
|
+
display: none !important;
|
|
58
|
+
}
|
|
59
|
+
.skeleton-shell {
|
|
60
|
+
display: inline-flex;
|
|
61
|
+
align-items: center;
|
|
62
|
+
gap: var(--space-200);
|
|
63
|
+
width: 100%;
|
|
64
|
+
box-sizing: border-box;
|
|
65
|
+
}
|
|
66
|
+
.stack {
|
|
67
|
+
display: grid;
|
|
68
|
+
gap: ${a};
|
|
69
|
+
width: 100%;
|
|
70
|
+
min-width: 0;
|
|
71
|
+
}
|
|
72
|
+
.block {
|
|
73
|
+
display: block;
|
|
74
|
+
position: relative;
|
|
75
|
+
width: var(--block-width);
|
|
76
|
+
max-width: var(--block-max-width, 100%);
|
|
77
|
+
height: var(--block-height);
|
|
78
|
+
border-radius: var(--block-radius);
|
|
79
|
+
background: var(--skeleton-background, var(--surface-elevated-200));
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
opacity: 1;
|
|
82
|
+
}
|
|
83
|
+
.block::after {
|
|
84
|
+
content: "";
|
|
85
|
+
position: absolute;
|
|
86
|
+
inset: 0;
|
|
87
|
+
background: linear-gradient(
|
|
88
|
+
100deg,
|
|
89
|
+
transparent 0%,
|
|
90
|
+
var(--skeleton-highlight, color-mix(in srgb, var(--white) 42%, transparent 58%)) 45%,
|
|
91
|
+
transparent 100%
|
|
92
|
+
);
|
|
93
|
+
transform: translateX(-120%);
|
|
94
|
+
opacity: var(--skeleton-shimmer-opacity, 0.6);
|
|
95
|
+
pointer-events: none;
|
|
96
|
+
}
|
|
97
|
+
:host([animation="shimmer"]) .block::after {
|
|
98
|
+
animation: skeletonShimmer ${o} linear infinite;
|
|
99
|
+
}
|
|
100
|
+
:host([animation="pulsate"]) .block {
|
|
101
|
+
animation: skeletonPulse ${o} ease-in-out infinite;
|
|
102
|
+
}
|
|
103
|
+
:host([animation="none"]) .block::after {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
:host([animation="none"]) .block {
|
|
107
|
+
animation: none;
|
|
108
|
+
}
|
|
109
|
+
@keyframes skeletonShimmer {
|
|
110
|
+
0% { transform: translateX(-120%); }
|
|
111
|
+
100% { transform: translateX(120%); }
|
|
112
|
+
}
|
|
113
|
+
@keyframes skeletonPulse {
|
|
114
|
+
0%, 100% { opacity: var(--skeleton-pulse-min-opacity, 0.55); }
|
|
115
|
+
50% { opacity: var(--skeleton-pulse-max-opacity, 1); }
|
|
116
|
+
}
|
|
117
|
+
@media (prefers-reduced-motion: reduce) {
|
|
118
|
+
:host([animation="shimmer"]) .block::after,
|
|
119
|
+
:host([animation="pulsate"]) .block {
|
|
120
|
+
animation: none !important;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
</style>
|
|
124
|
+
|
|
125
|
+
<div class="skeleton-shell" ${r ? "" : "hidden"}>
|
|
126
|
+
<slot name="before"></slot>
|
|
127
|
+
<div class="stack">
|
|
128
|
+
${c}
|
|
129
|
+
</div>
|
|
130
|
+
<slot name="after"></slot>
|
|
131
|
+
</div>
|
|
132
|
+
|
|
133
|
+
<div class="content" ${r ? "hidden" : ""}>
|
|
134
|
+
<slot></slot>
|
|
135
|
+
</div>
|
|
136
|
+
`;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
customElements.get("mui-skeleton") || customElements.define("mui-skeleton", u);
|