@muibook/components 5.2.0 → 6.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.
|
@@ -51,7 +51,7 @@ class p extends HTMLElement {
|
|
|
51
51
|
if (!this.shadowRoot) return;
|
|
52
52
|
const t = this.getAttribute("width") || "400px", e = this.getAttribute("variant") || "overlay", i = !!this.querySelector('[slot="before"]');
|
|
53
53
|
this._computedSide = this.getAttribute("side") || (i ? "right" : "left"), this.getAttribute("side") !== this._computedSide && this.setAttribute("side", this._computedSide);
|
|
54
|
-
const
|
|
54
|
+
const o = (
|
|
55
55
|
/*css*/
|
|
56
56
|
`
|
|
57
57
|
header {
|
|
@@ -88,7 +88,7 @@ class p extends HTMLElement {
|
|
|
88
88
|
justify-content: flex-end;
|
|
89
89
|
padding: var(--space-400) var(--space-500) calc(var(--space-400) + env(safe-area-inset-bottom));
|
|
90
90
|
border-top: var(--border-thin);
|
|
91
|
-
background: var(--
|
|
91
|
+
background: var(--drawer-background);
|
|
92
92
|
gap: var(--space-300);
|
|
93
93
|
box-sizing: border-box;
|
|
94
94
|
position: fixed;
|
|
@@ -179,11 +179,11 @@ class p extends HTMLElement {
|
|
|
179
179
|
visibility: visible;
|
|
180
180
|
}
|
|
181
181
|
`
|
|
182
|
-
), r = this._computedSide === "left" ? "border-right: var(--border-thin);" : "border-left: var(--border-thin);",
|
|
182
|
+
), r = this._computedSide === "left" ? "border-right: var(--border-thin);" : "border-left: var(--border-thin);", d = (
|
|
183
183
|
/*css*/
|
|
184
184
|
`
|
|
185
185
|
.inner {
|
|
186
|
-
background: var(--
|
|
186
|
+
background: var(--drawer-background);
|
|
187
187
|
width: ${t};
|
|
188
188
|
position: fixed;
|
|
189
189
|
top: 0;
|
|
@@ -319,12 +319,12 @@ class p extends HTMLElement {
|
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
`
|
|
322
|
-
),
|
|
323
|
-
let
|
|
322
|
+
), l = this.getAttribute("side") || this._computedSide, h = e === "overlay" || e === "push";
|
|
323
|
+
let a = "";
|
|
324
324
|
const c = this.hasAttribute("drawer-space") ? "no-padding" : "";
|
|
325
|
-
e === "overlay" ?
|
|
325
|
+
e === "overlay" ? a = /*html*/
|
|
326
326
|
`
|
|
327
|
-
<style>${
|
|
327
|
+
<style>${o}${s}${n}</style>
|
|
328
328
|
<div class="overlay"></div>
|
|
329
329
|
<div class="inner" role="dialog" aria-modal="true">
|
|
330
330
|
<header hidden>
|
|
@@ -340,20 +340,20 @@ class p extends HTMLElement {
|
|
|
340
340
|
<slot name="actions"></slot>
|
|
341
341
|
</footer>
|
|
342
342
|
</div>
|
|
343
|
-
` : (e === "push" || e === "persistent") && (
|
|
343
|
+
` : (e === "push" || e === "persistent") && (a = /*html*/
|
|
344
344
|
`
|
|
345
|
-
<style>${
|
|
345
|
+
<style>${o}${d}${n}</style>
|
|
346
346
|
<div class="shell">
|
|
347
|
-
${
|
|
347
|
+
${l === "left" ? this.getDrawerTemplate(h) + '<slot name="page"></slot>' : '<slot name="page"></slot>' + this.getDrawerTemplate(h)}
|
|
348
348
|
</div>
|
|
349
|
-
`), this.shadowRoot.innerHTML =
|
|
349
|
+
`), this.shadowRoot.innerHTML = a;
|
|
350
350
|
}
|
|
351
351
|
cacheEls() {
|
|
352
352
|
this.innerEl = this.shadowRoot.querySelector(".inner"), this.overlayEl = this.shadowRoot.querySelector(".overlay"), this.footerEl = this.shadowRoot.querySelector("footer"), this.actionsSlot = this.shadowRoot.querySelector('slot[name="actions"]'), this.outer = this.shadowRoot.querySelector(".outer"), this.pushLayout = this.shadowRoot.querySelector(".shell"), this.persistentLayout = this.shadowRoot.querySelector(".shell"), this.headerEl = this.shadowRoot.querySelector("header"), this.headerSlot = this.shadowRoot.querySelector('slot[name="title"]');
|
|
353
353
|
}
|
|
354
354
|
attachEvents() {
|
|
355
|
-
var t, e, i,
|
|
356
|
-
(t = this.shadowRoot.querySelector(".close")) == null || t.addEventListener("click", () => this.close()), (e = this.overlayEl) == null || e.addEventListener("click", () => this.close()), (i = this.actionsSlot) == null || i.addEventListener("slotchange", () => this.updateFooterVisibility()), (
|
|
355
|
+
var t, e, i, o;
|
|
356
|
+
(t = this.shadowRoot.querySelector(".close")) == null || t.addEventListener("click", () => this.close()), (e = this.overlayEl) == null || e.addEventListener("click", () => this.close()), (i = this.actionsSlot) == null || i.addEventListener("slotchange", () => this.updateFooterVisibility()), (o = this.headerSlot) == null || o.addEventListener("slotchange", () => this.updateHeaderVisibility());
|
|
357
357
|
}
|
|
358
358
|
updateFooterVisibility() {
|
|
359
359
|
if (!this.footerEl || !this.actionsSlot) return;
|
|
@@ -371,17 +371,17 @@ class p extends HTMLElement {
|
|
|
371
371
|
t === "open" && this.syncOpenState(), t === "width" && this.innerEl && (this.innerEl.style.width = i || "400px"), t === "side" && (this.render(), this.cacheEls(), this.attachEvents(), this.syncOpenState()), t === "variant" && (this.render(), this.cacheEls(), this.attachEvents(), this.syncOpenState());
|
|
372
372
|
}
|
|
373
373
|
syncOpenState() {
|
|
374
|
-
const t = this.hasAttribute("open"), e = this.getAttribute("variant") || "overlay", i = this.getAttribute("z-index"),
|
|
375
|
-
e === "overlay" && this.overlayEl && (this.overlayEl.style.visibility = t ? "visible" : "hidden", this.overlayEl.style.opacity = t ? "1" : "0", this.overlayEl.style.zIndex =
|
|
374
|
+
const t = this.hasAttribute("open"), e = this.getAttribute("variant") || "overlay", i = this.getAttribute("z-index"), o = i ? Number(i) : 10, s = i ? Number(i) + 1 : 11;
|
|
375
|
+
e === "overlay" && this.overlayEl && (this.overlayEl.style.visibility = t ? "visible" : "hidden", this.overlayEl.style.opacity = t ? "1" : "0", this.overlayEl.style.zIndex = o.toString(), this.innerEl.style.zIndex = s.toString(), this.inert = !t), e === "push" && this.outer && (this.updateLayout(e, t), this.outer.style.zIndex = s.toString(), this.outer.inert = !t), e === "persistent" && this.outer && (this.updateLayout(e, t), this.outer.inert = !1);
|
|
376
376
|
}
|
|
377
377
|
updateLayout(t, e) {
|
|
378
|
-
const i = this.getAttribute("width") || "300px",
|
|
378
|
+
const i = this.getAttribute("width") || "300px", o = this.getAttribute("side") || this._computedSide, s = t === "push" ? this.pushLayout : t === "persistent" ? this.persistentLayout : null;
|
|
379
379
|
if (!s) return;
|
|
380
380
|
if (window.innerWidth <= this.getBreakpoint()) {
|
|
381
381
|
t === "push" ? s.style.removeProperty("grid-template-columns") : t === "persistent" && (s.style.display = "grid", s.style.removeProperty("grid-template-columns"));
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
|
-
s.style.display = "grid", t === "push" ? s.style.gridTemplateColumns =
|
|
384
|
+
s.style.display = "grid", t === "push" ? s.style.gridTemplateColumns = o === "left" ? e ? `${i} auto` : "0 auto" : e ? `auto ${i}` : "auto 0" : t === "persistent" && (s.style.gridTemplateColumns = o === "left" ? `${i} auto` : `auto ${i}`);
|
|
385
385
|
}
|
|
386
386
|
open() {
|
|
387
387
|
this.setAttribute("open", ""), this.dispatchEvent(new CustomEvent("mui-drawer-open", { bubbles: !0, composed: !0 }));
|
|
@@ -1,66 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
import "../mui-icons/warning/index.js";
|
|
3
|
-
import "../mui-icons/attention/index.js";
|
|
4
|
-
class r extends HTMLElement {
|
|
1
|
+
class a extends HTMLElement {
|
|
5
2
|
static get observedAttributes() {
|
|
6
|
-
return ["variant", "message"];
|
|
3
|
+
return ["variant", "message", "label", "hide-label"];
|
|
7
4
|
}
|
|
8
5
|
constructor() {
|
|
9
|
-
super(), this.attachShadow({ mode: "open" })
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
super(), this.attachShadow({ mode: "open" }), this.shadowRoot.innerHTML = `
|
|
7
|
+
<style>
|
|
8
|
+
:host { display: block; }
|
|
9
|
+
|
|
10
|
+
mui-body { margin-top: var(--space-200); }
|
|
11
|
+
mui-body::part(display) { display: flex; }
|
|
12
|
+
mui-body::part(align-items) { align-items: center; }
|
|
13
|
+
mui-body::part(gap) { gap: var(--space-100); }
|
|
14
|
+
|
|
15
|
+
::slotted(mui-checkbox) { padding-left: var(--space-025); }
|
|
16
|
+
</style>
|
|
17
|
+
|
|
18
|
+
<slot></slot>
|
|
19
|
+
<div class="message-container"></div>
|
|
20
|
+
`;
|
|
21
|
+
}
|
|
22
|
+
// -----------------------
|
|
23
|
+
// Property getters/setters
|
|
24
|
+
// -----------------------
|
|
25
|
+
get variant() {
|
|
26
|
+
return this.getAttribute("variant") || "default";
|
|
27
|
+
}
|
|
28
|
+
set variant(e) {
|
|
29
|
+
this.setAttribute("variant", e);
|
|
30
|
+
}
|
|
31
|
+
get message() {
|
|
32
|
+
return this.getAttribute("message") || "";
|
|
33
|
+
}
|
|
34
|
+
set message(e) {
|
|
35
|
+
this.setAttribute("message", e);
|
|
36
|
+
}
|
|
37
|
+
get label() {
|
|
38
|
+
return this.getAttribute("label") || "";
|
|
12
39
|
}
|
|
40
|
+
set label(e) {
|
|
41
|
+
this.setAttribute("label", e);
|
|
42
|
+
}
|
|
43
|
+
get hideLabel() {
|
|
44
|
+
return this.hasAttribute("hide-label");
|
|
45
|
+
}
|
|
46
|
+
set hideLabel(e) {
|
|
47
|
+
e ? this.setAttribute("hide-label", "") : this.removeAttribute("hide-label");
|
|
48
|
+
}
|
|
49
|
+
// -----------------------
|
|
50
|
+
// Lifecycle methods
|
|
51
|
+
// -----------------------
|
|
13
52
|
connectedCallback() {
|
|
14
|
-
this.
|
|
53
|
+
this.renderMessage(), this.passAttributesToChild();
|
|
15
54
|
}
|
|
16
|
-
attributeChangedCallback(
|
|
17
|
-
|
|
55
|
+
attributeChangedCallback(e) {
|
|
56
|
+
["variant", "message", "label", "hide-label"].includes(e) && (this.renderMessage(), this.passAttributesToChild());
|
|
18
57
|
}
|
|
58
|
+
// -----------------------
|
|
59
|
+
// Helper methods
|
|
60
|
+
// -----------------------
|
|
19
61
|
passAttributesToChild() {
|
|
20
|
-
var
|
|
62
|
+
var s;
|
|
21
63
|
if (!this.shadowRoot) return;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.hasAttribute(s) ? e.setAttribute(s, this.getAttribute(s) || "") : e.removeAttribute(s);
|
|
64
|
+
const e = this.shadowRoot.querySelector("slot"), i = (s = e == null ? void 0 : e.assignedElements) == null ? void 0 : s.call(e)[0];
|
|
65
|
+
i && ["variant", "label", "hide-label"].forEach((t) => {
|
|
66
|
+
this.hasAttribute(t) ? i.setAttribute(t, this.getAttribute(t) || "") : i.removeAttribute(t);
|
|
26
67
|
});
|
|
27
68
|
}
|
|
28
|
-
|
|
29
|
-
const t = this.getAttribute("message"), e = this.getAttribute("variant");
|
|
69
|
+
renderMessage() {
|
|
30
70
|
if (!this.shadowRoot) return;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
display: block;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
mui-body {
|
|
40
|
-
margin-top: var(--space-200);
|
|
41
|
-
}
|
|
42
|
-
mui-body::part(display) {
|
|
43
|
-
display: flex;
|
|
44
|
-
}
|
|
45
|
-
mui-body::part(align-items) {
|
|
46
|
-
align-items: center;
|
|
47
|
-
}
|
|
48
|
-
mui-body::part(gap) {
|
|
49
|
-
gap: var(--space-100);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
::slotted(mui-checkbox) {
|
|
53
|
-
padding-left: var(--space-025);
|
|
54
|
-
}
|
|
55
|
-
</style>
|
|
56
|
-
|
|
57
|
-
<slot></slot>
|
|
58
|
-
${t ? `
|
|
59
|
-
<mui-body size="small" variant="${e}">
|
|
60
|
-
${i ? `<mui-icon-${i}></mui-icon-${i}>` : ""}
|
|
61
|
-
${t}
|
|
62
|
-
</mui-body>` : ""}
|
|
63
|
-
`;
|
|
71
|
+
const e = this.shadowRoot.querySelector(".message-container");
|
|
72
|
+
if (!e) return;
|
|
73
|
+
const i = this.variant, s = this.message;
|
|
74
|
+
let t = "";
|
|
75
|
+
i === "success" ? t = "<mui-icon-check></mui-icon-check>" : i === "warning" ? t = "<mui-icon-warning></mui-icon-warning>" : i === "error" && (t = "<mui-icon-attention></mui-icon-attention>"), e.innerHTML = s ? `<mui-body size="small" variant="${i}">${t}${s}</mui-body>` : "";
|
|
64
76
|
}
|
|
65
77
|
}
|
|
66
|
-
customElements.get("mui-field") || customElements.define("mui-field",
|
|
78
|
+
customElements.get("mui-field") || customElements.define("mui-field", a);
|
|
@@ -3,7 +3,10 @@ class s extends HTMLElement {
|
|
|
3
3
|
return ["length", "weight", "direction"];
|
|
4
4
|
}
|
|
5
5
|
constructor() {
|
|
6
|
-
super(), this.attachShadow({ mode: "open" })
|
|
6
|
+
super(), this.attachShadow({ mode: "open" });
|
|
7
|
+
}
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
this.shadowRoot && (this.hasAttribute("direction") || this.setAttribute("direction", "horizontal"), this.setAttribute("role", "presentation"), this.updateStyles());
|
|
7
10
|
}
|
|
8
11
|
attributeChangedCallback() {
|
|
9
12
|
this.updateStyles();
|