@muibook/components 5.2.1 → 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.
@@ -1,66 +1,78 @@
1
- import "../mui-icons/check/index.js";
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
- const t = this.getAttribute("variant") || "default";
11
- this.setAttribute("variant", t);
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.render(), this.passAttributesToChild();
53
+ this.renderMessage(), this.passAttributesToChild();
15
54
  }
16
- attributeChangedCallback(t, e, i) {
17
- (t === "variant" || t === "message") && (this.render(), this.passAttributesToChild());
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 a;
62
+ var s;
21
63
  if (!this.shadowRoot) return;
22
- const t = this.shadowRoot.querySelector("slot"), e = (a = t == null ? void 0 : t.assignedElements) == null ? void 0 : a.call(t)[0];
23
- if (!e) return;
24
- ["variant", "label", "hide-label"].forEach((s) => {
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
- render() {
29
- const t = this.getAttribute("message"), e = this.getAttribute("variant");
69
+ renderMessage() {
30
70
  if (!this.shadowRoot) return;
31
- let i = "";
32
- e === "success" ? i = "check" : e === "warning" ? i = "warning" : e === "error" && (i = "attention"), this.shadowRoot.innerHTML = /*html*/
33
- `
34
- <style>
35
- :host {
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", r);
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" }), this.setAttribute("role", "presentation"), this.hasAttribute("direction") || this.setAttribute("direction", "horizontal"), this.updateStyles();
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();
@@ -1,3 +1 @@
1
- import "../mui-icons/check";
2
- import "../mui-icons/warning";
3
- import "../mui-icons/attention";
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muibook/components",
3
- "version": "5.2.1",
3
+ "version": "6.0.0",
4
4
  "type": "module",
5
5
  "description": "A library of MUI-based design system components.",
6
6
  "author": "Michael Trilford",