@muibook/components 7.1.0 → 8.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/agent/keywords/index.js +1 -0
- package/dist/esm/agent/prompts/index.js +13 -1
- package/dist/esm/components/mui-addon/index.js +0 -1
- package/dist/esm/components/mui-avatar/index.js +136 -0
- package/dist/esm/components/mui-button/index.js +91 -47
- package/dist/esm/components/mui-checkbox/index.js +30 -56
- package/dist/esm/components/mui-chip/index.js +17 -10
- package/dist/esm/components/mui-dialog/index.js +17 -17
- package/dist/esm/components/mui-drawer/index.js +38 -39
- package/dist/esm/components/mui-file-upload/index.js +6 -6
- package/dist/esm/components/mui-icons/checkmark/index.js +53 -0
- package/dist/esm/components/mui-icons/game-controller/index.js +55 -0
- package/dist/esm/components/mui-icons/home/index.js +55 -0
- package/dist/esm/components/mui-icons/index.js +8 -0
- package/dist/esm/components/mui-icons/list-and-film/index.js +55 -0
- package/dist/esm/components/mui-icons/movie-clapper/index.js +55 -0
- package/dist/esm/components/mui-icons/music-microphone/index.js +55 -0
- package/dist/esm/components/mui-icons/music-quarter-note/index.js +55 -0
- package/dist/esm/components/mui-icons/play-rectangle/index.js +55 -0
- package/dist/esm/components/mui-icons/play-stack/index.js +55 -0
- package/dist/esm/components/mui-icons/search/index.js +53 -0
- package/dist/esm/components/mui-input/index.js +43 -19
- package/dist/esm/components/mui-link/index.js +120 -42
- package/dist/esm/components/mui-select/index.js +2 -1
- package/dist/esm/components/mui-slat/index.js +0 -1
- package/dist/esm/components/mui-slat/slat/index.js +36 -9
- package/dist/esm/components/mui-switch/index.js +23 -13
- package/dist/esm/css/mui-tokens.css +120 -12
- package/dist/esm/custom-elements.json +6186 -0
- package/dist/esm/index.js +15 -5
- package/dist/types/components/mui-accordion/doc.d.ts +2 -0
- package/dist/types/components/mui-addon/doc.d.ts +2 -0
- package/dist/types/components/mui-alert/doc.d.ts +2 -0
- package/dist/types/components/mui-avatar/doc.d.ts +2 -0
- package/dist/types/components/mui-avatar/index.d.ts +1 -0
- package/dist/types/components/mui-badge/doc.d.ts +2 -0
- package/dist/types/components/mui-body/doc.d.ts +2 -0
- package/dist/types/components/mui-button/doc.d.ts +2 -0
- package/dist/types/components/mui-button-group/doc.d.ts +2 -0
- package/dist/types/components/mui-card/doc.d.ts +2 -0
- package/dist/types/components/mui-carousel/doc.d.ts +2 -0
- package/dist/types/components/mui-checkbox/doc.d.ts +2 -0
- package/dist/types/components/mui-chip/doc.d.ts +2 -0
- package/dist/types/components/mui-code/doc.d.ts +2 -0
- package/dist/types/components/mui-container/doc.d.ts +2 -0
- package/dist/types/components/mui-dialog/doc.d.ts +2 -0
- package/dist/types/components/mui-drawer/doc.d.ts +2 -0
- package/dist/types/components/mui-dropdown/doc.d.ts +2 -0
- package/dist/types/components/mui-field/doc.d.ts +2 -0
- package/dist/types/components/mui-file-upload/doc.d.ts +2 -0
- package/dist/types/components/mui-grid/doc.d.ts +2 -0
- package/dist/types/components/mui-heading/doc.d.ts +2 -0
- package/dist/types/components/mui-icons/checkmark.d.ts +1 -0
- package/dist/types/components/mui-icons/doc.d.ts +2 -0
- package/dist/types/components/mui-icons/game-controller.d.ts +1 -0
- package/dist/types/components/mui-icons/home.d.ts +1 -0
- package/dist/types/components/mui-icons/index.d.ts +8 -0
- package/dist/types/components/mui-icons/list-and-film.d.ts +1 -0
- package/dist/types/components/mui-icons/movie-clapper.d.ts +1 -0
- package/dist/types/components/mui-icons/music-microphone.d.ts +1 -0
- package/dist/types/components/mui-icons/music-quarter-note.d.ts +1 -0
- package/dist/types/components/mui-icons/play-rectangle.d.ts +1 -0
- package/dist/types/components/mui-icons/play-stack.d.ts +1 -0
- package/dist/types/components/mui-icons/search.d.ts +1 -0
- package/dist/types/components/mui-image/doc.d.ts +2 -0
- package/dist/types/components/mui-input/doc.d.ts +2 -0
- package/dist/types/components/mui-link/doc.d.ts +2 -0
- package/dist/types/components/mui-list/doc.d.ts +2 -0
- package/dist/types/components/mui-loader/doc.d.ts +2 -0
- package/dist/types/components/mui-message/doc.d.ts +2 -0
- package/dist/types/components/mui-progress/doc.d.ts +2 -0
- package/dist/types/components/mui-quote/doc.d.ts +2 -0
- package/dist/types/components/mui-responsive/doc.d.ts +2 -0
- package/dist/types/components/mui-rule/doc.d.ts +2 -0
- package/dist/types/components/mui-select/doc.d.ts +2 -0
- package/dist/types/components/mui-slat/doc.d.ts +67 -0
- package/dist/types/components/mui-slat/index.d.ts +0 -1
- package/dist/types/components/mui-smart-card/doc.d.ts +2 -0
- package/dist/types/components/mui-stack/doc.d.ts +2 -0
- package/dist/types/components/mui-stepper/doc.d.ts +2 -0
- package/dist/types/components/mui-switch/doc.d.ts +2 -0
- package/dist/types/components/mui-table/doc.d.ts +2 -0
- package/dist/types/components/mui-tabs/doc.d.ts +2 -0
- package/dist/types/index.d.ts +11 -1
- package/package.json +55 -9
- package/dist/esm/components/mui-slat/accessory/index.js +0 -29
|
@@ -30,7 +30,19 @@ Rules:
|
|
|
30
30
|
select: `<mui-field label="Brand"><mui-select options='[{ "value": "jpy", "label": "JPY" },{ "value": "usd", "label": "USD" }]'></mui-select></mui-field>`,
|
|
31
31
|
inputAndSelect: `<mui-field label="Amount to transfer" slot="body"><mui-input type="number"><mui-select slot="after" label="Currency" hide-label style="width: 100px;" options='[{ "value": "jpy", "label": "JPY" },{ "value": "usd", "label": "USD" }]'></mui-select></mui-input></mui-field>`
|
|
32
32
|
},
|
|
33
|
-
addon:
|
|
33
|
+
addon: {
|
|
34
|
+
text: [
|
|
35
|
+
'<mui-input><mui-addon slot="before">$</mui-addon></mui-input>',
|
|
36
|
+
'<mui-input><mui-addon slot="after">kg</mui-addon></mui-input>',
|
|
37
|
+
'<mui-input><mui-addon slot="before">%</mui-addon></mui-input>',
|
|
38
|
+
'<mui-field label="Website"><mui-input><mui-addon slot="before">https://</mui-addon></mui-input></mui-field>'
|
|
39
|
+
],
|
|
40
|
+
icon: [
|
|
41
|
+
'<mui-input><mui-addon slot="before"><mui-icon name="search"></mui-icon></mui-addon></mui-input>',
|
|
42
|
+
'<mui-input><mui-addon slot="after"><mui-icon name="calendar"></mui-icon></mui-addon></mui-input>',
|
|
43
|
+
'<mui-field label="Email"><mui-input type="email"><mui-addon slot="before"><mui-icon name="mail"></mui-icon></mui-addon></mui-input></mui-field>'
|
|
44
|
+
]
|
|
45
|
+
},
|
|
34
46
|
checkbox: "<mui-checkbox>...</mui-checkbox>",
|
|
35
47
|
fileUpload: "<mui-file-upload>...</mui-file-upload>",
|
|
36
48
|
input: "<mui-input>...</mui-input>",
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
class y extends HTMLElement {
|
|
2
|
+
static get observedAttributes() {
|
|
3
|
+
return ["label", "image", "size", "background", "background-color"];
|
|
4
|
+
}
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.attachShadow({ mode: "open" });
|
|
7
|
+
}
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
this._imageFailed === void 0 && (this._imageFailed = !1), this.render();
|
|
10
|
+
}
|
|
11
|
+
attributeChangedCallback() {
|
|
12
|
+
this._imageFailed === void 0 && (this._imageFailed = !1), this.render();
|
|
13
|
+
}
|
|
14
|
+
// Check if slot has content
|
|
15
|
+
hasSlottedContent() {
|
|
16
|
+
var a;
|
|
17
|
+
const e = (a = this.shadowRoot) == null ? void 0 : a.querySelector("slot");
|
|
18
|
+
return e ? e.assignedNodes({ flatten: !0 }).some(
|
|
19
|
+
(r) => {
|
|
20
|
+
var n;
|
|
21
|
+
return r.nodeType === Node.ELEMENT_NODE || r.nodeType === Node.TEXT_NODE && ((n = r.textContent) == null ? void 0 : n.trim());
|
|
22
|
+
}
|
|
23
|
+
) : !1;
|
|
24
|
+
}
|
|
25
|
+
// Generate initials from label
|
|
26
|
+
getInitials(e) {
|
|
27
|
+
if (!e) return "?";
|
|
28
|
+
const t = e.trim().split(/\s+/);
|
|
29
|
+
let a = t[0][0] ?? "";
|
|
30
|
+
return t.length > 1 && (a += t[t.length - 1][0] ?? ""), a.toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
// Map background prop to token or app-supplied colour
|
|
33
|
+
getBackgroundCSS() {
|
|
34
|
+
const e = this.getAttribute("background") || "neutral", t = this.getAttribute("background-color");
|
|
35
|
+
if (t)
|
|
36
|
+
return t;
|
|
37
|
+
const a = {
|
|
38
|
+
neutral: "var(--avatar-background-neutral)",
|
|
39
|
+
positive: "var(--avatar-background-positive)",
|
|
40
|
+
warning: "var(--avatar-background-warning)",
|
|
41
|
+
attention: "var(--avatar-background-attention)",
|
|
42
|
+
// Random-use profile colours
|
|
43
|
+
purple: "var(--avatar-background-purple)",
|
|
44
|
+
violet: "var(--avatar-background-violet)",
|
|
45
|
+
pink: "var(--avatar-background-pink)",
|
|
46
|
+
magenta: "var(--avatar-background-magenta)",
|
|
47
|
+
red: "var(--avatar-background-red)",
|
|
48
|
+
orange: "var(--avatar-background-orange)",
|
|
49
|
+
amber: "var(--avatar-background-amber)",
|
|
50
|
+
yellow: "var(--avatar-background-yellow)",
|
|
51
|
+
lime: "var(--avatar-background-lime)",
|
|
52
|
+
green: "var(--avatar-background-green)",
|
|
53
|
+
teal: "var(--avatar-background-teal)",
|
|
54
|
+
cyan: "var(--avatar-background-cyan)",
|
|
55
|
+
blue: "var(--avatar-background-blue)",
|
|
56
|
+
indigo: "var(--avatar-background-indigo)"
|
|
57
|
+
};
|
|
58
|
+
return a[e] ?? a.neutral;
|
|
59
|
+
}
|
|
60
|
+
render() {
|
|
61
|
+
const e = this.getAttribute("label"), t = this.getAttribute("image"), a = (this.getAttribute("size") || "medium").toLowerCase(), r = this.getAttribute("background") || "neutral", n = this.getAttribute("background-color"), l = e || "Avatar", o = this.hasSlottedContent(), i = t && !this._imageFailed && !o, c = !i && !o, h = this.getInitials(e), d = {
|
|
62
|
+
"x-small": "var(--avatar-x-small)",
|
|
63
|
+
small: "var(--avatar-small)",
|
|
64
|
+
medium: "var(--avatar-medium)",
|
|
65
|
+
large: "var(--avatar-large)"
|
|
66
|
+
}, s = d[a] ?? d.medium, g = {
|
|
67
|
+
"x-small": "var(--font-size-15)",
|
|
68
|
+
small: "var(--font-size-200)",
|
|
69
|
+
medium: "var(--font-size-300)",
|
|
70
|
+
large: "var(--font-size-400)"
|
|
71
|
+
}, k = g[a] ?? g.medium, u = {
|
|
72
|
+
"x-small": "x-small",
|
|
73
|
+
small: "small",
|
|
74
|
+
medium: "medium",
|
|
75
|
+
large: "large"
|
|
76
|
+
}, f = u[a] ?? u.medium, m = this.getBackgroundCSS(), p = r === "neutral" && !n ? `var(--avatar-background-override, ${m})` : m, w = (
|
|
77
|
+
/*css*/
|
|
78
|
+
`
|
|
79
|
+
:host {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
width: ${s};
|
|
82
|
+
height: ${s};
|
|
83
|
+
border-radius: ${s};
|
|
84
|
+
font-weight: var(--font-weight-bold);
|
|
85
|
+
letter-spacing: -0.05rem;
|
|
86
|
+
font-size: ${k};
|
|
87
|
+
color: var(--text-color);
|
|
88
|
+
background: ${p};
|
|
89
|
+
overflow: hidden;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
user-select: none;
|
|
93
|
+
box-sizing: border-box;
|
|
94
|
+
padding: ${c || o ? `calc(${s} * 0.1)` : "0"};
|
|
95
|
+
flex: none;
|
|
96
|
+
}
|
|
97
|
+
img {
|
|
98
|
+
width: 100%;
|
|
99
|
+
height: 100%;
|
|
100
|
+
object-fit: cover;
|
|
101
|
+
display: ${i ? "block" : "none"};
|
|
102
|
+
}
|
|
103
|
+
.initials {
|
|
104
|
+
display: ${c ? "flex" : "none"};
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
width: 100%;
|
|
108
|
+
height: 100%;
|
|
109
|
+
text-transform: uppercase;
|
|
110
|
+
text-decoration: none;
|
|
111
|
+
}
|
|
112
|
+
slot {
|
|
113
|
+
display: ${o ? "flex" : "none"};
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
width: 100%;
|
|
117
|
+
height: 100%;
|
|
118
|
+
}
|
|
119
|
+
`
|
|
120
|
+
);
|
|
121
|
+
if (this.shadowRoot.innerHTML = `
|
|
122
|
+
<style>${w}</style>
|
|
123
|
+
${i ? `<img src="${t}" alt="${l}" />` : ""}
|
|
124
|
+
<div class="initials" role="img" aria-label="${l}">${h}</div>
|
|
125
|
+
<slot></slot>
|
|
126
|
+
`, o && this.shadowRoot.querySelector("slot").assignedElements().forEach((b) => {
|
|
127
|
+
b.tagName.toLowerCase().startsWith("mui-icon-") && b.setAttribute("size", f);
|
|
128
|
+
}), i && t) {
|
|
129
|
+
const v = this.shadowRoot.querySelector("img");
|
|
130
|
+
v.onerror = () => {
|
|
131
|
+
this._imageFailed = !0, this.render();
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
customElements.get("mui-avatar") || customElements.define("mui-avatar", y);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getPartMap as u } from "../../utils/part-map/index.js";
|
|
2
|
-
class
|
|
2
|
+
class h extends HTMLElement {
|
|
3
3
|
static get observedAttributes() {
|
|
4
4
|
return ["onclick", "type", "aria-label", "disabled", "variant", "size", "usage"];
|
|
5
5
|
}
|
|
@@ -337,7 +337,7 @@ class v extends HTMLElement {
|
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
/* Dropdown Slot */
|
|
340
|
-
:host(.dropdown-slot) button {
|
|
340
|
+
:host([size].dropdown-slot) button {
|
|
341
341
|
border-radius: var(--radius-000);
|
|
342
342
|
}
|
|
343
343
|
|
|
@@ -346,16 +346,40 @@ class v extends HTMLElement {
|
|
|
346
346
|
background: var(--dropdown-button-background-hover);
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
:host(.dropdown-slot-first) button {
|
|
349
|
+
:host([size].dropdown-slot-first) button {
|
|
350
350
|
border-top-left-radius: calc(var(--radius-100) / 2);
|
|
351
351
|
border-top-right-radius: calc(var(--radius-100) / 2);
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
:host(.dropdown-slot-last) button
|
|
354
|
+
:host([size].dropdown-slot-last) button {
|
|
355
355
|
border-bottom-left-radius: calc(var(--radius-100) / 2);
|
|
356
356
|
border-bottom-right-radius: calc(var(--radius-100) / 2);
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
+
:host button ::slotted(mui-avatar) {
|
|
360
|
+
--avatar-background-override: var(--action-avatar-background);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
:host([size="x-small"]) button ::slotted(mui-avatar) {
|
|
364
|
+
margin-right: var(--space-025);
|
|
365
|
+
}
|
|
366
|
+
:host([size="small"]) button ::slotted(mui-avatar),
|
|
367
|
+
:host([size="medium"]) button ::slotted(mui-avatar),
|
|
368
|
+
:host([size="large"]) button ::slotted(mui-avatar) {
|
|
369
|
+
margin-right: var(--space-050);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
:host button:disabled ::slotted(mui-avatar),
|
|
373
|
+
:host button:disabled:hover ::slotted(mui-avatar),
|
|
374
|
+
:host button:disabled:focus ::slotted(mui-avatar) {
|
|
375
|
+
opacity: 0.5;
|
|
376
|
+
--avatar-background-override: var(--action-avatar-background);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
:host button:hover ::slotted(mui-avatar),
|
|
380
|
+
:host button:focus ::slotted(mui-avatar) {
|
|
381
|
+
--avatar-background-override: var(--action-avatar-background-hover);
|
|
382
|
+
}
|
|
359
383
|
|
|
360
384
|
/* Before & After Icon
|
|
361
385
|
========================================= */
|
|
@@ -388,29 +412,34 @@ class v extends HTMLElement {
|
|
|
388
412
|
========================================= */
|
|
389
413
|
:host([size="x-small"]) button,
|
|
390
414
|
:host([size="x-small"]) button:hover,
|
|
391
|
-
:host([size="x-small"]) button:focus
|
|
415
|
+
:host([size="x-small"]) button:focus,
|
|
416
|
+
:host([size="x-small"]) button:disabled {
|
|
392
417
|
font-size: var(--text-font-size-xs);
|
|
393
418
|
line-height: var(--text-line-height-xs);
|
|
394
419
|
font-weight: var(--font-weight-semi-bold);
|
|
395
420
|
padding: var(--action-padding-x-small);
|
|
396
421
|
border-width: var(--stroke-size-100);
|
|
422
|
+
border-radius: var(--action-radius-x-small);
|
|
397
423
|
}
|
|
398
424
|
|
|
399
425
|
:host([size="small"]) button {
|
|
400
426
|
font-size: var(--text-font-size-s);
|
|
401
427
|
line-height: var(--text-line-height-s);
|
|
402
428
|
padding: var(--action-padding-small);
|
|
429
|
+
border-radius: var(--action-radius-small);
|
|
403
430
|
}
|
|
404
431
|
|
|
405
432
|
:host([size="medium"]) button {
|
|
406
433
|
font-size: var(--text-font-size-m);
|
|
407
434
|
line-height: var(--text-line-height-m);
|
|
435
|
+
border-radius: var(--action-radius-medium);
|
|
408
436
|
}
|
|
409
437
|
|
|
410
438
|
:host([size="large"]) button {
|
|
411
439
|
font-size: var(--text-font-size-l);
|
|
412
440
|
line-height: var(--text-line-height-l);
|
|
413
441
|
padding: var(--action-padding-large);
|
|
442
|
+
border-radius: var(--action-radius-large);
|
|
414
443
|
}
|
|
415
444
|
|
|
416
445
|
:host([size="x-small"][icon-only]) button {
|
|
@@ -509,69 +538,84 @@ class v extends HTMLElement {
|
|
|
509
538
|
`
|
|
510
539
|
);
|
|
511
540
|
this.shadowRoot.innerHTML = a, await customElements.whenDefined("mui-button"), requestAnimationFrame(() => {
|
|
512
|
-
const
|
|
513
|
-
if (!
|
|
514
|
-
const
|
|
515
|
-
var
|
|
516
|
-
return
|
|
517
|
-
}) : !1, d =
|
|
518
|
-
this.classList.toggle("has-before", d), this.classList.toggle("has-after",
|
|
519
|
-
const b = (
|
|
520
|
-
b.every((
|
|
521
|
-
var
|
|
522
|
-
if (
|
|
523
|
-
const
|
|
524
|
-
return
|
|
541
|
+
const i = this.shadowRoot;
|
|
542
|
+
if (!i) return;
|
|
543
|
+
const t = i.querySelector("slot:not([name])"), n = i.querySelector('slot[name="before"]'), r = i.querySelector('slot[name="after"]'), o = (l) => l ? l.assignedNodes({ flatten: !0 }).some((s) => {
|
|
544
|
+
var c;
|
|
545
|
+
return s.nodeType === Node.ELEMENT_NODE || s.nodeType === Node.TEXT_NODE && !!((c = s.textContent) != null && c.trim());
|
|
546
|
+
}) : !1, d = o(n), v = o(r);
|
|
547
|
+
this.classList.toggle("has-before", d), this.classList.toggle("has-after", v);
|
|
548
|
+
const b = (t == null ? void 0 : t.assignedNodes({ flatten: !0 })) ?? [];
|
|
549
|
+
b.every((l) => {
|
|
550
|
+
var s;
|
|
551
|
+
if (l.nodeType === Node.ELEMENT_NODE) {
|
|
552
|
+
const c = l;
|
|
553
|
+
return c.tagName.toLowerCase() === "svg" || c.classList.contains("mui-icon");
|
|
525
554
|
}
|
|
526
|
-
return
|
|
527
|
-
}) ? (this.setAttribute("icon-only", ""), this.updateIconSizes(b, !0)) : (this.removeAttribute("icon-only"), [
|
|
528
|
-
if (
|
|
529
|
-
const
|
|
530
|
-
this.updateIconSizes(
|
|
555
|
+
return l.nodeType === Node.TEXT_NODE && !((s = l.textContent) != null && s.trim());
|
|
556
|
+
}) ? (this.setAttribute("icon-only", ""), this.updateIconSizes(b, !0)) : (this.removeAttribute("icon-only"), [n, t, r].forEach((s) => {
|
|
557
|
+
if (s) {
|
|
558
|
+
const c = s.assignedNodes({ flatten: !0 });
|
|
559
|
+
this.updateIconSizes(c, !1), this.updateAvatarSizes(c);
|
|
531
560
|
}
|
|
532
561
|
}));
|
|
533
562
|
});
|
|
534
563
|
}
|
|
535
|
-
attributeChangedCallback(
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
539
|
-
const
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
],
|
|
544
|
-
|
|
545
|
-
if (
|
|
546
|
-
const d =
|
|
547
|
-
this.updateIconSizes(d,
|
|
564
|
+
attributeChangedCallback(e, a, i) {
|
|
565
|
+
e === "size" && a !== i && this.shadowRoot && requestAnimationFrame(() => {
|
|
566
|
+
const t = this.shadowRoot;
|
|
567
|
+
if (!t) return;
|
|
568
|
+
const n = [
|
|
569
|
+
t.querySelector("slot:not([name])"),
|
|
570
|
+
t.querySelector('slot[name="before"]'),
|
|
571
|
+
t.querySelector('slot[name="after"]')
|
|
572
|
+
], r = this.hasAttribute("icon-only");
|
|
573
|
+
n.forEach((o) => {
|
|
574
|
+
if (o) {
|
|
575
|
+
const d = o.assignedNodes({ flatten: !0 });
|
|
576
|
+
this.updateIconSizes(d, r), this.updateAvatarSizes(d);
|
|
548
577
|
}
|
|
549
578
|
});
|
|
550
579
|
});
|
|
551
580
|
}
|
|
552
|
-
|
|
553
|
-
|
|
581
|
+
// Update avatar sizes based on button size
|
|
582
|
+
updateAvatarSizes(e) {
|
|
583
|
+
const a = this.getAttribute("size") || "medium", t = {
|
|
584
|
+
"x-small": "x-small",
|
|
585
|
+
small: "x-small",
|
|
586
|
+
medium: "small",
|
|
587
|
+
large: "medium"
|
|
588
|
+
}[a] || "small";
|
|
589
|
+
e.forEach((n) => {
|
|
590
|
+
if (n.nodeType === Node.ELEMENT_NODE) {
|
|
591
|
+
const r = n;
|
|
592
|
+
r.tagName.toLowerCase() === "mui-avatar" && r.setAttribute("size", t);
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
updateIconSizes(e, a) {
|
|
597
|
+
const i = this.getAttribute("size") || "medium", n = {
|
|
554
598
|
"x-small": "x-small",
|
|
555
599
|
small: "x-small",
|
|
556
600
|
medium: a ? "medium" : "small",
|
|
557
601
|
// small for regular, medium for icon-only
|
|
558
602
|
large: a ? "large" : "medium"
|
|
559
|
-
}[
|
|
560
|
-
|
|
561
|
-
if (
|
|
562
|
-
const
|
|
563
|
-
(
|
|
603
|
+
}[i] || "small";
|
|
604
|
+
e.forEach((r) => {
|
|
605
|
+
if (r.nodeType === Node.ELEMENT_NODE) {
|
|
606
|
+
const o = r;
|
|
607
|
+
(o.tagName.toLowerCase() === "svg" || o.classList.contains("mui-icon") || o.tagName.toLowerCase() === "mui-icon") && !o.hasAttribute("size") && o.setAttribute("size", n);
|
|
564
608
|
}
|
|
565
609
|
});
|
|
566
610
|
}
|
|
567
611
|
waitForPartMap() {
|
|
568
|
-
return new Promise((
|
|
569
|
-
if (typeof u == "function") return
|
|
612
|
+
return new Promise((e) => {
|
|
613
|
+
if (typeof u == "function") return e();
|
|
570
614
|
const a = () => {
|
|
571
|
-
typeof u == "function" ?
|
|
615
|
+
typeof u == "function" ? e() : requestAnimationFrame(a);
|
|
572
616
|
};
|
|
573
617
|
a();
|
|
574
618
|
});
|
|
575
619
|
}
|
|
576
620
|
}
|
|
577
|
-
customElements.get("mui-button") || customElements.define("mui-button",
|
|
621
|
+
customElements.get("mui-button") || customElements.define("mui-button", h);
|
|
@@ -9,79 +9,55 @@ class d extends HTMLElement {
|
|
|
9
9
|
connectedCallback() {
|
|
10
10
|
this.render(), this.setupListener();
|
|
11
11
|
}
|
|
12
|
-
attributeChangedCallback(e,
|
|
13
|
-
var
|
|
12
|
+
attributeChangedCallback(e, r, i) {
|
|
13
|
+
var c, o, s;
|
|
14
14
|
if (e === "checked") {
|
|
15
|
-
const t = (
|
|
15
|
+
const t = (c = this.shadowRoot) == null ? void 0 : c.querySelector("input");
|
|
16
16
|
if (!t) return;
|
|
17
|
-
t.checked =
|
|
17
|
+
t.checked = i !== null;
|
|
18
18
|
}
|
|
19
19
|
if (e === "disabled") {
|
|
20
|
-
const t = (
|
|
20
|
+
const t = (o = this.shadowRoot) == null ? void 0 : o.querySelector("input");
|
|
21
21
|
if (!t) return;
|
|
22
|
-
t.disabled =
|
|
22
|
+
t.disabled = i !== null;
|
|
23
23
|
}
|
|
24
24
|
if (e === "indeterminate") {
|
|
25
25
|
const t = (s = this.shadowRoot) == null ? void 0 : s.querySelector("input");
|
|
26
26
|
if (!t) return;
|
|
27
|
-
const n =
|
|
27
|
+
const n = i !== null;
|
|
28
28
|
t.indeterminate = n, n && (t.checked = !0, this.setAttribute("checked", ""));
|
|
29
29
|
}
|
|
30
30
|
"id".includes(e) && (this.render(), this.setupListener());
|
|
31
31
|
}
|
|
32
32
|
setupListener() {
|
|
33
|
-
var
|
|
34
|
-
const e = (
|
|
35
|
-
e && (e.addEventListener("change", (
|
|
36
|
-
const
|
|
33
|
+
var r;
|
|
34
|
+
const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
|
|
35
|
+
e && (e.addEventListener("change", (i) => {
|
|
36
|
+
const c = i.target;
|
|
37
37
|
this.dispatchEvent(
|
|
38
38
|
new CustomEvent("change", {
|
|
39
|
-
detail: { checked:
|
|
39
|
+
detail: { checked: c.checked },
|
|
40
40
|
bubbles: !0,
|
|
41
41
|
composed: !0
|
|
42
42
|
})
|
|
43
|
-
),
|
|
44
|
-
}), e.indeterminate = this.hasAttribute("indeterminate"), e.addEventListener("change", (
|
|
45
|
-
const
|
|
43
|
+
), c.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked");
|
|
44
|
+
}), e.indeterminate = this.hasAttribute("indeterminate"), e.addEventListener("change", (i) => {
|
|
45
|
+
const c = i.target;
|
|
46
46
|
this.dispatchEvent(
|
|
47
47
|
new CustomEvent("change", {
|
|
48
|
-
detail: { checked:
|
|
48
|
+
detail: { checked: c.checked },
|
|
49
49
|
bubbles: !0,
|
|
50
50
|
composed: !0
|
|
51
51
|
})
|
|
52
|
-
), this.removeAttribute("indeterminate"),
|
|
52
|
+
), this.removeAttribute("indeterminate"), c.checked ? this.setAttribute("checked", "") : this.removeAttribute("checked");
|
|
53
53
|
}));
|
|
54
54
|
}
|
|
55
55
|
render() {
|
|
56
|
-
const e = this.getAttribute("id") || `mui-checkbox-${Math.random().toString(36).substr(2, 9)}`,
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
height="16"
|
|
62
|
-
fill="none"
|
|
63
|
-
viewBox="0 0 16 16"
|
|
64
|
-
>
|
|
65
|
-
<path
|
|
66
|
-
fill="currentColor"
|
|
67
|
-
d="M12.783 3.59a1 1 0 0 1 1.414 1.414L6.791 12.41a1 1 0 0 1-1.414 0L1.803 8.837l-.069-.076A1 1 0 0 1 3.14 7.353l.077.07 2.866 2.866z"
|
|
68
|
-
></path>
|
|
69
|
-
</svg>
|
|
70
|
-
`, r = this.hasAttribute("indeterminate"), t = r ? `
|
|
71
|
-
<svg
|
|
72
|
-
class="icon"
|
|
73
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
74
|
-
width="16"
|
|
75
|
-
height="16"
|
|
76
|
-
fill="none"
|
|
77
|
-
viewBox="0 0 16 16"
|
|
78
|
-
>
|
|
79
|
-
<path
|
|
80
|
-
fill="currentColor"
|
|
81
|
-
d="m12.5 7 .102.005a1 1 0 0 1 0 1.99L12.5 9h-9a1 1 0 0 1 0-2z"
|
|
82
|
-
></path>
|
|
83
|
-
</svg>
|
|
84
|
-
` : i, n = this.innerHTML.trim().length > 0;
|
|
56
|
+
const e = this.getAttribute("id") || `mui-checkbox-${Math.random().toString(36).substr(2, 9)}`, r = this.hasAttribute("checked"), i = this.hasAttribute("disabled"), c = `
|
|
57
|
+
<mui-icon-checkmark class="icon" size="x-small" color="inverted"></mui-icon-checkmark>
|
|
58
|
+
`, o = this.hasAttribute("indeterminate"), t = o ? `
|
|
59
|
+
<mui-icon-subtract class="icon" size="x-small" color="inverted"></mui-icon-subtract>
|
|
60
|
+
` : c, n = this.innerHTML.trim().length > 0;
|
|
85
61
|
this.shadowRoot.innerHTML = /*html*/
|
|
86
62
|
`
|
|
87
63
|
<style>
|
|
@@ -98,8 +74,8 @@ class d extends HTMLElement {
|
|
|
98
74
|
|
|
99
75
|
input[type="checkbox"] {
|
|
100
76
|
all: unset;
|
|
101
|
-
width:
|
|
102
|
-
height:
|
|
77
|
+
width: var(--checkbox-size);
|
|
78
|
+
height: var(--checkbox-size);
|
|
103
79
|
border: var(--border-thin);
|
|
104
80
|
border-color: var(--form-default-border-color);
|
|
105
81
|
border-radius: var(--checkbox-radius);
|
|
@@ -142,11 +118,9 @@ class d extends HTMLElement {
|
|
|
142
118
|
top: 50%;
|
|
143
119
|
left: 50%;
|
|
144
120
|
transform: translate(-50%, -50%);
|
|
145
|
-
width: 16px;
|
|
146
|
-
height: 16px;
|
|
147
121
|
pointer-events: none;
|
|
148
122
|
display: none;
|
|
149
|
-
|
|
123
|
+
fill: var(--checkbox-icon-color-checked);
|
|
150
124
|
}
|
|
151
125
|
|
|
152
126
|
.checkbox-wrapper input:checked + .icon {
|
|
@@ -164,9 +138,9 @@ class d extends HTMLElement {
|
|
|
164
138
|
<input
|
|
165
139
|
type="checkbox"
|
|
166
140
|
id="${e}"
|
|
167
|
-
${
|
|
168
|
-
${
|
|
169
|
-
${
|
|
141
|
+
${o ? "indeterminate" : ""}
|
|
142
|
+
${o || r ? "checked" : ""}
|
|
143
|
+
${i ? "disabled" : ""}
|
|
170
144
|
/>
|
|
171
145
|
${t}
|
|
172
146
|
</span>
|
|
@@ -175,8 +149,8 @@ class d extends HTMLElement {
|
|
|
175
149
|
`;
|
|
176
150
|
}
|
|
177
151
|
get checked() {
|
|
178
|
-
var
|
|
179
|
-
const e = (
|
|
152
|
+
var r;
|
|
153
|
+
const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
|
|
180
154
|
return (e == null ? void 0 : e.checked) ?? !1;
|
|
181
155
|
}
|
|
182
156
|
set checked(e) {
|
|
@@ -17,15 +17,24 @@ class d extends HTMLElement {
|
|
|
17
17
|
requestAnimationFrame(() => {
|
|
18
18
|
const t = this.shadowRoot;
|
|
19
19
|
if (!t) return;
|
|
20
|
-
const
|
|
21
|
-
var
|
|
22
|
-
return
|
|
23
|
-
}) : !1,
|
|
24
|
-
this.classList.toggle("has-before",
|
|
20
|
+
const i = t.querySelector('slot[name="before"]'), e = t.querySelector('slot[name="after"]'), a = (o) => o ? o.assignedNodes({ flatten: !0 }).some((s) => {
|
|
21
|
+
var c;
|
|
22
|
+
return s.nodeType === Node.ELEMENT_NODE || s.nodeType === Node.TEXT_NODE && !!((c = s.textContent) != null && c.trim());
|
|
23
|
+
}) : !1, r = a(i), n = a(e);
|
|
24
|
+
this.classList.toggle("has-before", r), this.classList.toggle("has-after", n), this.forceAvatarSize(i), this.forceAvatarSize(e);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
forceAvatarSize(t) {
|
|
28
|
+
if (!t) return;
|
|
29
|
+
t.assignedNodes({ flatten: !0 }).forEach((e) => {
|
|
30
|
+
if (e.nodeType === Node.ELEMENT_NODE) {
|
|
31
|
+
const a = e, r = a.tagName.toLowerCase();
|
|
32
|
+
r === "mui-avatar" ? a.setAttribute("size", "x-small") : r.startsWith("mui-icon-") && a.setAttribute("size", "medium");
|
|
33
|
+
}
|
|
25
34
|
});
|
|
26
35
|
}
|
|
27
36
|
render() {
|
|
28
|
-
var
|
|
37
|
+
var i;
|
|
29
38
|
const t = (
|
|
30
39
|
/*css*/
|
|
31
40
|
`
|
|
@@ -105,8 +114,6 @@ class d extends HTMLElement {
|
|
|
105
114
|
::slotted(.mui-icon) {
|
|
106
115
|
box-sizing: border-box;
|
|
107
116
|
padding: var(--space-025);
|
|
108
|
-
width: var(--space-500);
|
|
109
|
-
height: var(--space-500);
|
|
110
117
|
fill: var(--chip-icon-fill);
|
|
111
118
|
}
|
|
112
119
|
|
|
@@ -157,8 +164,8 @@ class d extends HTMLElement {
|
|
|
157
164
|
<mui-button part="dismiss-btn" variant="tertiary" aria-label="Remove chip">
|
|
158
165
|
<mui-icon-close size="x-small"></mui-icon-close>
|
|
159
166
|
</mui-button>
|
|
160
|
-
`, (
|
|
161
|
-
|
|
167
|
+
`, (i = this.shadowRoot.querySelector('[part="dismiss-btn"]')) == null || i.addEventListener("click", (e) => {
|
|
168
|
+
e.stopPropagation(), this.dispatchEvent(
|
|
162
169
|
new CustomEvent("dismiss", {
|
|
163
170
|
bubbles: !0,
|
|
164
171
|
composed: !0,
|