@muibook/components 8.0.1 → 9.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/README.md +23 -0
- package/dist/esm/agent/prompts/index.js +1 -1
- package/dist/esm/components/mui-alert/index.js +48 -40
- package/dist/esm/components/mui-button/index.js +1 -1
- package/dist/esm/components/mui-card/body/index.js +42 -29
- package/dist/esm/components/mui-checkbox/index.js +38 -39
- package/dist/esm/components/mui-dialog/index.js +4 -0
- package/dist/esm/components/mui-file-upload/index.js +12 -3
- package/dist/esm/components/mui-grid/index.js +19 -12
- package/dist/esm/components/mui-heading/index.js +11 -5
- package/dist/esm/components/mui-input/index.js +35 -38
- package/dist/esm/components/mui-select/index.js +34 -30
- package/dist/esm/components/mui-stack/hstack/index.js +13 -13
- package/dist/esm/components/mui-stack/vstack/index.js +13 -13
- package/dist/esm/components/mui-switch/index.js +38 -30
- package/dist/esm/components/mui-tabs/item/index.js +18 -12
- package/dist/esm/css/mui-brand.css +179 -0
- package/dist/esm/css/mui-tokens.css +29 -219
- package/dist/esm/css/readme.md +129 -0
- package/dist/esm/custom-elements.json +680 -505
- package/dist/esm/tokens/js/index.js +140 -0
- package/dist/types/tokens/js/index.d.ts +140 -0
- package/dist/types/tokens/js/mui-brand.d.ts +140 -0
- package/package.json +14 -3
|
@@ -8,53 +8,50 @@ class m extends HTMLElement {
|
|
|
8
8
|
connectedCallback() {
|
|
9
9
|
this.render(), this.setupListener();
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
disconnectedCallback() {
|
|
12
|
+
this.cleanupListeners();
|
|
13
|
+
}
|
|
14
|
+
attributeChangedCallback(e, r, o) {
|
|
15
|
+
var a;
|
|
16
|
+
const t = (a = this.shadowRoot) == null ? void 0 : a.querySelector("input");
|
|
17
|
+
t && (e === "value" && (t.value = o ?? ""), e === "disabled" && (o === null || o === "false" ? t.removeAttribute("disabled") : t.setAttribute("disabled", "")), (e === "type" || e === "placeholder" || e === "label" || e === "hide-label" || e === "variant") && (this.render(), this.setupListener()));
|
|
18
|
+
}
|
|
19
|
+
cleanupListeners() {
|
|
12
20
|
var r;
|
|
13
|
-
const
|
|
14
|
-
|
|
21
|
+
const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("input");
|
|
22
|
+
e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
|
|
15
23
|
}
|
|
16
24
|
setupListener() {
|
|
17
|
-
|
|
18
|
-
const e =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
}), a.addEventListener("change", (r) => {
|
|
31
|
-
const s = r.target;
|
|
32
|
-
this.dispatchEvent(
|
|
33
|
-
new CustomEvent("change", {
|
|
34
|
-
detail: { value: s.value },
|
|
35
|
-
bubbles: !0,
|
|
36
|
-
composed: !0
|
|
37
|
-
})
|
|
38
|
-
);
|
|
39
|
-
});
|
|
25
|
+
if (!this.shadowRoot) return;
|
|
26
|
+
const e = this.shadowRoot.querySelector("input");
|
|
27
|
+
e && (this.cleanupListeners(), this._changeHandler = (r) => {
|
|
28
|
+
const o = r.target;
|
|
29
|
+
this.setAttribute("value", o.value);
|
|
30
|
+
const t = {
|
|
31
|
+
detail: { value: o.value },
|
|
32
|
+
bubbles: !0,
|
|
33
|
+
composed: !0
|
|
34
|
+
};
|
|
35
|
+
this.dispatchEvent(new CustomEvent("change", t)), this.dispatchEvent(new CustomEvent("input", t));
|
|
36
|
+
}, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler));
|
|
40
37
|
}
|
|
41
38
|
updateSlottedButtons() {
|
|
42
39
|
requestAnimationFrame(() => {
|
|
43
|
-
var t,
|
|
44
|
-
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector('slot[name="before"]'),
|
|
45
|
-
if (!
|
|
46
|
-
|
|
40
|
+
var t, a;
|
|
41
|
+
const e = (t = this.shadowRoot) == null ? void 0 : t.querySelector('slot[name="before"]'), r = (a = this.shadowRoot) == null ? void 0 : a.querySelector('slot[name="after"]'), o = (l) => {
|
|
42
|
+
if (!l) return;
|
|
43
|
+
l.assignedNodes({ flatten: !0 }).forEach((i) => {
|
|
47
44
|
if (i.nodeType === Node.ELEMENT_NODE) {
|
|
48
|
-
const
|
|
49
|
-
(n === "mui-button" || n === "mui-link") && (
|
|
45
|
+
const s = i, n = s.tagName.toLowerCase();
|
|
46
|
+
(n === "mui-button" || n === "mui-link") && (s.setAttribute("usage", "input"), s.setAttribute("size", "medium"), s.removeAttribute("variant"), s.removeAttribute("weight"));
|
|
50
47
|
}
|
|
51
48
|
});
|
|
52
49
|
};
|
|
53
|
-
o(e), o(
|
|
50
|
+
o(e), o(r);
|
|
54
51
|
});
|
|
55
52
|
}
|
|
56
53
|
render() {
|
|
57
|
-
const e = ["text", "password", "email", "number", "search", "tel", "url", "date", "time"],
|
|
54
|
+
const e = ["text", "password", "email", "number", "search", "tel", "url", "date", "time"], r = this.getAttribute("type") || "text", o = e.includes(r) ? r : "text", t = this.getAttribute("name") || "", a = this.getAttribute("value") || "", l = this.getAttribute("placeholder") || "", d = this.getAttribute("id") || `mui-input-${Math.random().toString(36).substr(2, 9)}`, i = this.getAttribute("label") || "", s = this.hasAttribute("hide-label"), n = this.hasAttribute("disabled"), u = s && i ? `aria-label="${i}"` : "", c = this.getAttribute("variant") || "", h = c || "", b = this.querySelector('[slot="before"]') !== null, p = this.querySelector('[slot="after"]') !== null, f = [h, b ? "before" : "", p ? "after" : ""].filter(Boolean).join(" "), v = (
|
|
58
55
|
/*html*/
|
|
59
56
|
`
|
|
60
57
|
<style>
|
|
@@ -225,7 +222,7 @@ class m extends HTMLElement {
|
|
|
225
222
|
|
|
226
223
|
|
|
227
224
|
</style>
|
|
228
|
-
${i ? `<label for="${d}" class="${
|
|
225
|
+
${i ? `<label for="${d}" class="${s ? "vh" : ""}">${i}</label>` : ""}
|
|
229
226
|
<div class="input-wrapper">
|
|
230
227
|
<slot name="before"></slot>
|
|
231
228
|
<input
|
|
@@ -233,10 +230,10 @@ class m extends HTMLElement {
|
|
|
233
230
|
type="${o}"
|
|
234
231
|
name="${t}"
|
|
235
232
|
id="${d}"
|
|
236
|
-
value="${
|
|
237
|
-
placeholder="${
|
|
233
|
+
value="${a}"
|
|
234
|
+
placeholder="${l}"
|
|
238
235
|
${n ? 'disabled aria-disabled="true"' : ""}
|
|
239
|
-
${
|
|
236
|
+
${u}
|
|
240
237
|
/>
|
|
241
238
|
<slot name="after"></slot>
|
|
242
239
|
</div>
|
|
@@ -10,41 +10,45 @@ class p extends HTMLElement {
|
|
|
10
10
|
async connectedCallback() {
|
|
11
11
|
await this.waitForPartMap(), this.partMap = s("text", "visual"), this.render(), this.setupListener();
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
e === "value" && o && (o.value =
|
|
13
|
+
disconnectedCallback() {
|
|
14
|
+
this.cleanupListeners();
|
|
15
|
+
}
|
|
16
|
+
attributeChangedCallback(e, r, t) {
|
|
17
|
+
if (!this.shadowRoot || r === t) return;
|
|
18
|
+
const o = this.shadowRoot.querySelector("select");
|
|
19
|
+
e === "value" && o && (o.value = t || ""), e === "disabled" && o && (t === null || t === "false" ? o.removeAttribute("disabled") : o.setAttribute("disabled", "")), ["options", "label", "hide-label", "variant", "disabled"].includes(e) && (this.render(), this.setupListener());
|
|
20
|
+
}
|
|
21
|
+
cleanupListeners() {
|
|
22
|
+
var r;
|
|
23
|
+
const e = (r = this.shadowRoot) == null ? void 0 : r.querySelector("select");
|
|
24
|
+
e && this._changeHandler && (e.removeEventListener("change", this._changeHandler), e.removeEventListener("input", this._changeHandler));
|
|
20
25
|
}
|
|
21
26
|
setupListener() {
|
|
22
27
|
if (!this.shadowRoot) return;
|
|
23
28
|
const e = this.shadowRoot.querySelector("select");
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
29
|
+
e && (this.cleanupListeners(), this._changeHandler = (r) => {
|
|
30
|
+
const t = r.target;
|
|
31
|
+
this.setAttribute("value", t.value);
|
|
32
|
+
const o = {
|
|
33
|
+
detail: { value: t.value },
|
|
34
|
+
bubbles: !0,
|
|
35
|
+
composed: !0
|
|
36
|
+
};
|
|
37
|
+
this.dispatchEvent(new CustomEvent("change", o)), this.dispatchEvent(new CustomEvent("input", o));
|
|
38
|
+
}, e.addEventListener("change", this._changeHandler), e.addEventListener("input", this._changeHandler));
|
|
37
39
|
}
|
|
38
40
|
render() {
|
|
39
41
|
if (!this.shadowRoot) return;
|
|
40
|
-
const e = this.getAttribute("name") || "", r = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`,
|
|
41
|
-
let
|
|
42
|
+
const e = this.getAttribute("name") || "", r = this.getAttribute("id") || `mui-select-${Math.random().toString(36).substr(2, 9)}`, t = this.getAttribute("label") || "", o = this.getAttribute("value") || "", i = this.hasAttribute("hide-label"), c = this.hasAttribute("disabled"), d = this.getAttribute("options") || "[]", n = this.getAttribute("variant") || "", h = n || "", u = i && t ? `aria-label="${t}"` : "";
|
|
43
|
+
let l = [];
|
|
42
44
|
try {
|
|
43
|
-
|
|
44
|
-
} catch (
|
|
45
|
-
console.error("Invalid JSON in options attribute",
|
|
45
|
+
l = JSON.parse(d);
|
|
46
|
+
} catch (a) {
|
|
47
|
+
console.error("Invalid JSON in options attribute", a);
|
|
46
48
|
}
|
|
47
|
-
const
|
|
49
|
+
const b = l.map(
|
|
50
|
+
(a) => `<option value="${a.value}" ${a.value === o ? "selected" : ""} ${a.disabled ? "disabled" : ""}>${a.label}</option>`
|
|
51
|
+
).join(""), v = (
|
|
48
52
|
/*html*/
|
|
49
53
|
`
|
|
50
54
|
<style>
|
|
@@ -180,14 +184,14 @@ class p extends HTMLElement {
|
|
|
180
184
|
/* ========================================================================== */
|
|
181
185
|
|
|
182
186
|
</style>
|
|
183
|
-
${
|
|
187
|
+
${t ? (
|
|
184
188
|
/*html*/
|
|
185
|
-
`<label for="${r}" class="${i ? "vh" : ""}">${
|
|
189
|
+
`<label for="${r}" class="${i ? "vh" : ""}">${t}</label>`
|
|
186
190
|
) : ""}
|
|
187
191
|
<div style="position: relative;">
|
|
188
|
-
<select class="${h}" part="${this.partMap || ""}" name="${e}" id="${r}" ${
|
|
192
|
+
<select class="${h}" part="${this.partMap || ""}" name="${e}" id="${r}" ${u}
|
|
189
193
|
${c ? "disabled" : ""}>
|
|
190
|
-
${
|
|
194
|
+
${b}
|
|
191
195
|
</select>
|
|
192
196
|
<mui-icon-down-chevron class="chevron" size="x-small"></mui-icon-down-chevron>
|
|
193
197
|
</div>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getPartMap as
|
|
2
|
-
class
|
|
1
|
+
import { getPartMap as e } from "../../../utils/part-map/index.js";
|
|
2
|
+
class r extends HTMLElement {
|
|
3
3
|
static get observedAttributes() {
|
|
4
|
-
return ["space", "
|
|
4
|
+
return ["space", "aligny", "alignx"];
|
|
5
5
|
}
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), this.attachShadow({ mode: "open" }), this.space = "var(--space-500)", this.alignY = "flex-start", this.alignX = "flex-start", this.styles = /*css*/
|
|
@@ -20,7 +20,7 @@ class e extends HTMLElement {
|
|
|
20
20
|
async connectedCallback() {
|
|
21
21
|
if (!this.shadowRoot) return;
|
|
22
22
|
await this.waitForPartMap();
|
|
23
|
-
const t =
|
|
23
|
+
const t = e("spacing", "layout", "visual");
|
|
24
24
|
this.shadowRoot.innerHTML = /*html*/
|
|
25
25
|
`
|
|
26
26
|
<style>${this.styles}</style>
|
|
@@ -28,25 +28,25 @@ class e extends HTMLElement {
|
|
|
28
28
|
part="${t}"
|
|
29
29
|
style="
|
|
30
30
|
--space: ${this.getAttribute("space") || this.space};
|
|
31
|
-
--alignY: ${this.getAttribute("
|
|
32
|
-
--alignX: ${this.getAttribute("
|
|
31
|
+
--alignY: ${this.getAttribute("aligny") || this.alignY};
|
|
32
|
+
--alignX: ${this.getAttribute("alignx") || this.alignX};
|
|
33
33
|
">
|
|
34
34
|
</slot>
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
37
|
-
attributeChangedCallback(t, s) {
|
|
38
|
-
if (!this.shadowRoot) return;
|
|
39
|
-
const
|
|
40
|
-
|
|
37
|
+
attributeChangedCallback(t, s, i) {
|
|
38
|
+
if (s === i || !this.shadowRoot) return;
|
|
39
|
+
const a = this.shadowRoot.querySelector("slot");
|
|
40
|
+
a && (t === "space" && a.style.setProperty("--space", i || this.space), t === "aligny" && a.style.setProperty("--alignY", i || this.alignY), t === "alignx" && a.style.setProperty("--alignX", i || this.alignX));
|
|
41
41
|
}
|
|
42
42
|
waitForPartMap() {
|
|
43
43
|
return new Promise((t) => {
|
|
44
|
-
if (typeof
|
|
44
|
+
if (typeof e == "function") return t();
|
|
45
45
|
const s = () => {
|
|
46
|
-
typeof
|
|
46
|
+
typeof e == "function" ? t() : requestAnimationFrame(s);
|
|
47
47
|
};
|
|
48
48
|
s();
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
customElements.get("mui-h-stack") || customElements.define("mui-h-stack",
|
|
52
|
+
customElements.get("mui-h-stack") || customElements.define("mui-h-stack", r);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getPartMap as
|
|
2
|
-
class
|
|
1
|
+
import { getPartMap as e } from "../../../utils/part-map/index.js";
|
|
2
|
+
class r extends HTMLElement {
|
|
3
3
|
static get observedAttributes() {
|
|
4
|
-
return ["space", "
|
|
4
|
+
return ["space", "alignx", "aligny"];
|
|
5
5
|
}
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), this.attachShadow({ mode: "open" }), this.space = "var(--space-500)", this.alignX = "normal", this.alignY = "normal", this.styles = /*css*/
|
|
@@ -20,7 +20,7 @@ class e extends HTMLElement {
|
|
|
20
20
|
async connectedCallback() {
|
|
21
21
|
if (!this.shadowRoot) return;
|
|
22
22
|
await this.waitForPartMap();
|
|
23
|
-
const t =
|
|
23
|
+
const t = e("spacing", "layout", "visual");
|
|
24
24
|
this.shadowRoot.innerHTML = /*html*/
|
|
25
25
|
`
|
|
26
26
|
<style>${this.styles}</style>
|
|
@@ -28,25 +28,25 @@ class e extends HTMLElement {
|
|
|
28
28
|
part="${t}"
|
|
29
29
|
style="
|
|
30
30
|
--space: ${this.getAttribute("space") || this.space};
|
|
31
|
-
--alignX: ${this.getAttribute("
|
|
32
|
-
--alignY: ${this.getAttribute("
|
|
31
|
+
--alignX: ${this.getAttribute("alignx") || this.alignX};
|
|
32
|
+
--alignY: ${this.getAttribute("aligny") || this.alignY};
|
|
33
33
|
">
|
|
34
34
|
</slot>
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
37
|
-
attributeChangedCallback(t, s) {
|
|
38
|
-
if (!this.shadowRoot) return;
|
|
39
|
-
const
|
|
40
|
-
|
|
37
|
+
attributeChangedCallback(t, s, i) {
|
|
38
|
+
if (s === i || !this.shadowRoot) return;
|
|
39
|
+
const a = this.shadowRoot.querySelector("slot");
|
|
40
|
+
a && (t === "space" && a.style.setProperty("--space", i || this.space), t === "alignx" && a.style.setProperty("--alignX", i || this.alignX), t === "aligny" && a.style.setProperty("--alignY", i || this.alignY));
|
|
41
41
|
}
|
|
42
42
|
waitForPartMap() {
|
|
43
43
|
return new Promise((t) => {
|
|
44
|
-
if (typeof
|
|
44
|
+
if (typeof e == "function") return t();
|
|
45
45
|
const s = () => {
|
|
46
|
-
typeof
|
|
46
|
+
typeof e == "function" ? t() : requestAnimationFrame(s);
|
|
47
47
|
};
|
|
48
48
|
s();
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
customElements.get("mui-v-stack") || customElements.define("mui-v-stack",
|
|
52
|
+
customElements.get("mui-v-stack") || customElements.define("mui-v-stack", r);
|
|
@@ -1,61 +1,69 @@
|
|
|
1
|
-
class
|
|
1
|
+
class o extends HTMLElement {
|
|
2
2
|
constructor() {
|
|
3
3
|
super(), this._checked = !1, this._checkbox = null, this.attachShadow({ mode: "open" }), this._checked = !1;
|
|
4
4
|
}
|
|
5
5
|
connectedCallback() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
detail: { checked: this.checked },
|
|
11
|
-
bubbles: !0,
|
|
12
|
-
composed: !0
|
|
13
|
-
})
|
|
14
|
-
));
|
|
15
|
-
});
|
|
6
|
+
this.render(), this._checkbox = this.shadowRoot.querySelector('input[type="checkbox"]'), this._checked = this.hasAttribute("checked"), this._checkbox && (this._checkbox.checked = this._checked), this._updateIcons(), this._updateDisabledState(), this._enforceIconSize(), this._setupListener();
|
|
7
|
+
}
|
|
8
|
+
disconnectedCallback() {
|
|
9
|
+
this._cleanupListeners();
|
|
16
10
|
}
|
|
17
11
|
static get observedAttributes() {
|
|
18
12
|
return ["label", "disabled", "checked"];
|
|
19
13
|
}
|
|
20
|
-
attributeChangedCallback(
|
|
21
|
-
if (
|
|
22
|
-
const i =
|
|
14
|
+
attributeChangedCallback(s, e, t) {
|
|
15
|
+
if (s === "checked" && e !== t && (this._checked = t !== null, this._checkbox && (this._checkbox.checked = this._checked, this._updateIcons())), s === "disabled" && e !== t) {
|
|
16
|
+
const i = t !== null;
|
|
23
17
|
this._checkbox && (this._checkbox.disabled = i, this._checkbox.setAttribute("aria-disabled", i.toString())), this._updateDisabledState();
|
|
24
18
|
}
|
|
25
19
|
}
|
|
26
20
|
get checked() {
|
|
27
21
|
return this._checked;
|
|
28
22
|
}
|
|
29
|
-
set checked(
|
|
30
|
-
const e = !!
|
|
23
|
+
set checked(s) {
|
|
24
|
+
const e = !!s;
|
|
31
25
|
this._checked !== e && (this._checked = e, e ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._checkbox && (this._checkbox.checked = this._checked, this._checkbox.setAttribute("aria-checked", this._checked.toString()), this._updateIcons()));
|
|
32
26
|
}
|
|
27
|
+
_cleanupListeners() {
|
|
28
|
+
this._checkbox && this._changeHandler && this._checkbox.removeEventListener("change", this._changeHandler);
|
|
29
|
+
}
|
|
33
30
|
_updateDisabledState() {
|
|
34
|
-
var e,
|
|
35
|
-
this.hasAttribute("disabled") ? (this.shadowRoot.host.classList.add("disabled"), (e = this._checkbox) == null || e.setAttribute("aria-disabled", "true"), (
|
|
31
|
+
var e, t, i, c;
|
|
32
|
+
this.hasAttribute("disabled") ? (this.shadowRoot.host.classList.add("disabled"), (e = this._checkbox) == null || e.setAttribute("aria-disabled", "true"), (t = this._checkbox) == null || t.setAttribute("tabindex", "-1")) : (this.shadowRoot.host.classList.remove("disabled"), (i = this._checkbox) == null || i.removeAttribute("aria-disabled"), (c = this._checkbox) == null || c.removeAttribute("tabindex"));
|
|
33
|
+
}
|
|
34
|
+
_setupListener() {
|
|
35
|
+
this._checkbox && (this._cleanupListeners(), this._changeHandler = () => {
|
|
36
|
+
this._checkbox && (this.checked = this._checkbox.checked, this.dispatchEvent(
|
|
37
|
+
new CustomEvent("change", {
|
|
38
|
+
detail: { checked: this.checked },
|
|
39
|
+
bubbles: !0,
|
|
40
|
+
composed: !0
|
|
41
|
+
})
|
|
42
|
+
));
|
|
43
|
+
}, this._checkbox.addEventListener("change", this._changeHandler));
|
|
36
44
|
}
|
|
37
45
|
_enforceIconSize() {
|
|
38
|
-
const
|
|
46
|
+
const s = this.shadowRoot.querySelector('slot[name="on-icon"]'), e = this.shadowRoot.querySelector('slot[name="off-icon"]'), t = (i) => {
|
|
39
47
|
if (!i) return;
|
|
40
48
|
const c = () => {
|
|
41
|
-
i.assignedElements().forEach((
|
|
42
|
-
|
|
49
|
+
i.assignedElements().forEach((h) => {
|
|
50
|
+
h.tagName.toLowerCase().startsWith("mui-icon") && h.setAttribute("size", "x-small");
|
|
43
51
|
});
|
|
44
52
|
};
|
|
45
53
|
i.addEventListener("slotchange", c), setTimeout(c, 0);
|
|
46
54
|
};
|
|
47
|
-
s
|
|
55
|
+
t(s), t(e);
|
|
48
56
|
}
|
|
49
57
|
_updateIcons() {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}), e && e.assignedElements().forEach((
|
|
54
|
-
|
|
58
|
+
const s = this.shadowRoot.querySelector('slot[name="on-icon"]'), e = this.shadowRoot.querySelector('slot[name="off-icon"]');
|
|
59
|
+
s && s.assignedElements().forEach((t) => {
|
|
60
|
+
t.style.display = this._checked ? "inline" : "none";
|
|
61
|
+
}), e && e.assignedElements().forEach((t) => {
|
|
62
|
+
t.style.display = this._checked ? "none" : "inline";
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
65
|
render() {
|
|
58
|
-
const
|
|
66
|
+
const s = this.getAttribute("label");
|
|
59
67
|
this.shadowRoot.innerHTML = /*html*/
|
|
60
68
|
`
|
|
61
69
|
<style>
|
|
@@ -132,7 +140,7 @@ class h extends HTMLElement {
|
|
|
132
140
|
type="checkbox"
|
|
133
141
|
role="switch"
|
|
134
142
|
aria-checked="${this._checked}"
|
|
135
|
-
${
|
|
143
|
+
${s ? `aria-label="${s}"` : ""}
|
|
136
144
|
>
|
|
137
145
|
<span class="track">
|
|
138
146
|
<span class="thumb">
|
|
@@ -144,4 +152,4 @@ class h extends HTMLElement {
|
|
|
144
152
|
`;
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
|
-
customElements.get("mui-switch") || customElements.define("mui-switch",
|
|
155
|
+
customElements.get("mui-switch") || customElements.define("mui-switch", o);
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
class
|
|
1
|
+
class o extends HTMLElement {
|
|
2
|
+
updateIcon(t) {
|
|
3
|
+
if (this.shadowRoot && (this.iconEl && (this.shadowRoot.removeChild(this.iconEl), this.iconEl = void 0), t && t.trim() !== "" && customElements.get(t))) {
|
|
4
|
+
const e = document.createElement(t);
|
|
5
|
+
e.setAttribute("color", this.hasAttribute("active") ? "var(--tab-icon-active)" : "var(--tab-icon)"), e.setAttribute("size", "small"), this.shadowRoot.insertBefore(e, this.shadowRoot.firstChild), this.iconEl = e;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
2
8
|
constructor() {
|
|
3
9
|
super(), this.attachShadow({ mode: "open" });
|
|
4
10
|
}
|
|
5
11
|
static get observedAttributes() {
|
|
6
|
-
return ["active"];
|
|
12
|
+
return ["active", "icon"];
|
|
7
13
|
}
|
|
8
|
-
attributeChangedCallback(t,
|
|
9
|
-
t === "active"
|
|
14
|
+
attributeChangedCallback(t, e, s) {
|
|
15
|
+
t === "active" ? this.updateActiveState() : t === "icon" && this.updateIcon(s);
|
|
10
16
|
}
|
|
11
17
|
connectedCallback() {
|
|
12
18
|
if (!this.shadowRoot) return;
|
|
13
19
|
const t = this.getAttribute("icon");
|
|
14
20
|
this.setAttribute("tabindex", this.hasAttribute("active") ? "0" : "-1"), this.shadowRoot.innerHTML = "";
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
21
|
+
const e = document.createElement("style");
|
|
22
|
+
if (e.textContent = /*css*/
|
|
17
23
|
`
|
|
18
24
|
:host {
|
|
19
25
|
user-select: none;
|
|
@@ -46,16 +52,16 @@ class s extends HTMLElement {
|
|
|
46
52
|
::slotted(*) {
|
|
47
53
|
margin-left: var(--space-100);
|
|
48
54
|
}
|
|
49
|
-
`, this.shadowRoot.appendChild(
|
|
50
|
-
const
|
|
51
|
-
|
|
55
|
+
`, this.shadowRoot.appendChild(e), t && t.trim() !== "" && customElements.get(t)) {
|
|
56
|
+
const i = document.createElement(t);
|
|
57
|
+
i.setAttribute("color", "var(--tab-icon)"), i.setAttribute("size", "small"), this.shadowRoot.appendChild(i), this.iconEl = i;
|
|
52
58
|
}
|
|
53
|
-
const
|
|
54
|
-
this.shadowRoot.appendChild(
|
|
59
|
+
const s = document.createElement("slot");
|
|
60
|
+
this.shadowRoot.appendChild(s), this.updateActiveState();
|
|
55
61
|
}
|
|
56
62
|
updateActiveState() {
|
|
57
63
|
const t = this.hasAttribute("active");
|
|
58
64
|
this.classList.toggle("active", t), this.setAttribute("role", "tab"), this.setAttribute("aria-selected", t ? "true" : "false"), this.setAttribute("tabindex", t ? "0" : "-1"), this.iconEl && this.iconEl.setAttribute("color", t ? "var(--tab-icon-active)" : "var(--tab-icon)");
|
|
59
65
|
}
|
|
60
66
|
}
|
|
61
|
-
customElements.get("mui-tab-item") || customElements.define("mui-tab-item",
|
|
67
|
+
customElements.get("mui-tab-item") || customElements.define("mui-tab-item", o);
|