@muibook/components 19.0.0 → 19.1.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.
@@ -123,7 +123,7 @@ Rules:
123
123
  },
124
124
  buttonGroup: {
125
125
  default: "<mui-button-group>...</mui-button-group>",
126
- alignedRight: "<mui-button-group right>...</mui-button-group>"
126
+ alignedRight: '<mui-button-group align="right">...</mui-button-group>'
127
127
  },
128
128
  chip: "<mui-chip>...</mui-chip>",
129
129
  dropdown: "<mui-dropdown>...</mui-dropdown>",
@@ -1,18 +1,54 @@
1
1
  import "../../mui-icons/down-chevron/index.js";
2
2
  import "../../mui-heading/index.js";
3
- class u extends HTMLElement {
3
+ class l extends HTMLElement {
4
4
  constructor() {
5
- super(), this.summaryEl = null, this.detailEl = null, this.chevronEl = null, this.attachShadow({ mode: "open" }), this.accordionId = `accordion-detail-${Math.random().toString(36).substring(2, 9)}`;
5
+ super(), this.summaryEl = null, this.detailEl = null, this.chevronEl = null, this.detailSlotEl = null, this.handleSummaryClick = () => this.toggleAccordion(), this.handleSummaryKeydown = (e) => {
6
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.toggleAccordion());
7
+ }, this.handleDetailSlotChange = () => {
8
+ this.applyAccordionUsage(), this.syncOpenHeight();
9
+ }, this.attachShadow({ mode: "open" }), this.accordionId = `accordion-detail-${Math.random().toString(36).substring(2, 9)}`;
10
+ }
11
+ static get observedAttributes() {
12
+ return ["heading", "size", "level", "detail-space"];
6
13
  }
7
14
  getDetailEl() {
8
15
  var e;
9
16
  return this.detailEl || (this.detailEl = ((e = this.shadowRoot) == null ? void 0 : e.querySelector(".accordion-detail")) || null), this.detailEl;
10
17
  }
11
18
  connectedCallback() {
12
- var s, n;
19
+ this.render();
20
+ }
21
+ attributeChangedCallback(e, t, i) {
22
+ t === i || !this.isConnected || this.render();
23
+ }
24
+ applyAccordionUsage() {
25
+ requestAnimationFrame(() => {
26
+ var i;
27
+ const e = this.detailSlotEl || ((i = this.shadowRoot) == null ? void 0 : i.querySelector('slot[name="detail"]'));
28
+ if (!e) return;
29
+ e.assignedElements({ flatten: !0 }).forEach((a) => {
30
+ var s, n;
31
+ (((s = a.tagName) == null ? void 0 : s.toLowerCase()) === "mui-slat-group" ? [a] : Array.from(((n = a.querySelectorAll) == null ? void 0 : n.call(a, "mui-slat-group")) || [])).forEach((r) => {
32
+ r.hasAttribute("usage") || r.setAttribute("usage", "accordion");
33
+ });
34
+ });
35
+ });
36
+ }
37
+ bindEvents() {
38
+ var e, t, i, a, o, s;
39
+ (e = this.summaryEl) == null || e.removeEventListener("click", this.handleSummaryClick), (t = this.summaryEl) == null || t.removeEventListener("keydown", this.handleSummaryKeydown), (i = this.summaryEl) == null || i.addEventListener("click", this.handleSummaryClick), (a = this.summaryEl) == null || a.addEventListener("keydown", this.handleSummaryKeydown), (o = this.detailSlotEl) == null || o.removeEventListener("slotchange", this.handleDetailSlotChange), (s = this.detailSlotEl) == null || s.addEventListener("slotchange", this.handleDetailSlotChange);
40
+ }
41
+ syncOpenHeight() {
42
+ const e = this.getDetailEl();
43
+ !e || !e.hasAttribute("open") || requestAnimationFrame(() => {
44
+ const t = this.getDetailEl();
45
+ !t || !t.hasAttribute("open") || (t.style.maxHeight = t.scrollHeight + "px");
46
+ });
47
+ }
48
+ render() {
49
+ var r;
13
50
  if (!this.shadowRoot) return;
14
- const e = this.getAttribute("heading") || "Heading...", t = this.getAttribute("size") || "medium", i = this.getAttribute("level") || "3", r = this.getAttribute("detail-space"), h = r ? `detail-space-${r}` : "";
15
- let m = (
51
+ const e = ((r = this.getDetailEl()) == null ? void 0 : r.hasAttribute("open")) ?? !1, t = this.getAttribute("heading") || "Heading...", i = this.getAttribute("size") || "medium", a = this.getAttribute("level") || "3", o = this.getAttribute("detail-space"), s = o ? `detail-space-${o}` : "", n = (
16
52
  /*html*/
17
53
  `
18
54
  <style>
@@ -79,7 +115,7 @@ class u extends HTMLElement {
79
115
  .size-large-summary {
80
116
  padding: var(--space-500) var(--space-600);
81
117
  }
82
-
118
+
83
119
  .size-small-detail {
84
120
  padding: var(--space-500);
85
121
  }
@@ -98,7 +134,6 @@ class u extends HTMLElement {
98
134
  border-top: none;
99
135
  }
100
136
 
101
- /* Card Slot (Supports: Table Cell, Accordion Block) */
102
137
  :host([card-slot]) .accordion-summary {
103
138
  padding-left: var(--space-500);
104
139
  padding-right: var(--space-500);
@@ -132,53 +167,41 @@ class u extends HTMLElement {
132
167
  }
133
168
  }
134
169
 
135
-
136
170
  </style>
137
171
 
138
172
  <div
139
- class="accordion-summary size-${t}-summary"
173
+ class="accordion-summary size-${i}-summary"
140
174
  role="button"
141
175
  tabindex="0"
142
176
  aria-expanded="false"
143
177
  aria-controls="${this.accordionId}"
144
178
  >
145
- <mui-heading size="6" level="${i}">${e}</mui-heading>
179
+ <mui-heading size="6" level="${a}">${t}</mui-heading>
146
180
  <div class="icon">
147
181
  <mui-icon-down-chevron size="x-small"></mui-icon-down-chevron>
148
182
  </div>
149
183
  </div>
150
184
 
151
185
  <div id="${this.accordionId}" class="accordion-detail">
152
- <div class="accordion-detail-inner size-${t}-detail ${h}" inert>
186
+ <div class="accordion-detail-inner size-${i}-detail ${s}" inert>
153
187
  <slot name="detail">Insert Content</slot>
154
188
  </div>
155
189
  </div>
156
-
157
190
  `
158
191
  );
159
- if (this.shadowRoot.innerHTML = m, requestAnimationFrame(() => {
160
- const a = this.shadowRoot.querySelector('slot[name="detail"]');
161
- a && a.assignedElements({ flatten: !0 }).forEach((o) => {
162
- var d, c;
163
- (((d = o.tagName) == null ? void 0 : d.toLowerCase()) === "mui-slat-group" ? [o] : Array.from(((c = o.querySelectorAll) == null ? void 0 : c.call(o, "mui-slat-group")) || [])).forEach((l) => {
164
- l.hasAttribute("usage") || l.setAttribute("usage", "accordion");
165
- });
166
- });
167
- }), this.summaryEl = this.shadowRoot.querySelector(".accordion-summary"), this.detailEl = this.shadowRoot.querySelector(".accordion-detail"), this.chevronEl = this.shadowRoot.querySelector("mui-icon-down-chevron"), !this.summaryEl || !this.detailEl || !this.chevronEl) {
192
+ if (this.shadowRoot.innerHTML = n, this.summaryEl = this.shadowRoot.querySelector(".accordion-summary"), this.detailEl = this.shadowRoot.querySelector(".accordion-detail"), this.chevronEl = this.shadowRoot.querySelector("mui-icon-down-chevron"), this.detailSlotEl = this.shadowRoot.querySelector('slot[name="detail"]'), !this.summaryEl || !this.detailEl || !this.chevronEl) {
168
193
  console.error("Accordion elements not found");
169
194
  return;
170
195
  }
171
- (s = this.summaryEl) == null || s.addEventListener("click", () => this.toggleAccordion()), (n = this.summaryEl) == null || n.addEventListener("keydown", (a) => {
172
- (a.key === "Enter" || a.key === " ") && (a.preventDefault(), this.toggleAccordion());
173
- });
196
+ this.bindEvents(), this.applyAccordionUsage(), this.setOpen(e), e && (this.detailEl.style.maxHeight = this.detailEl.scrollHeight + "px");
174
197
  }
175
198
  toggleAccordion() {
176
199
  const e = this.getDetailEl();
177
200
  if (!e) return;
178
201
  const i = !e.hasAttribute("open");
179
202
  if (this.setOpen(i), i) {
180
- const r = e.scrollHeight;
181
- e.style.maxHeight = r + "px";
203
+ const a = e.scrollHeight;
204
+ e.style.maxHeight = a + "px";
182
205
  } else
183
206
  e.style.maxHeight = "0";
184
207
  }
@@ -192,4 +215,4 @@ class u extends HTMLElement {
192
215
  this.setOpen(!1);
193
216
  }
194
217
  }
195
- customElements.get("mui-accordion-block") || customElements.define("mui-accordion-block", u);
218
+ customElements.get("mui-accordion-block") || customElements.define("mui-accordion-block", l);
@@ -1,18 +1,39 @@
1
1
  import "../../mui-icons/right-chevron/index.js";
2
2
  import "../../mui-heading/index.js";
3
- class a extends HTMLElement {
3
+ class l extends HTMLElement {
4
4
  constructor() {
5
- super(), this.attachShadow({ mode: "open" });
5
+ super(), this.detailSlotEl = null, this.handleSummaryClick = () => this.toggleAccordion(), this.handleSummaryKeydown = (t) => {
6
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.toggleAccordion());
7
+ }, this.handleDetailSlotChange = () => {
8
+ this.syncOpenHeight();
9
+ }, this.attachShadow({ mode: "open" });
10
+ }
11
+ static get observedAttributes() {
12
+ return ["heading", "level"];
6
13
  }
7
14
  connectedCallback() {
8
- var n, r;
15
+ this.render();
16
+ }
17
+ attributeChangedCallback(t, e, i) {
18
+ e === i || !this.isConnected || this.render();
19
+ }
20
+ bindEvents() {
21
+ var t, e, i, s, a, n;
22
+ (t = this.summaryEl) == null || t.removeEventListener("click", this.handleSummaryClick), (e = this.summaryEl) == null || e.removeEventListener("keydown", this.handleSummaryKeydown), (i = this.summaryEl) == null || i.addEventListener("click", this.handleSummaryClick), (s = this.summaryEl) == null || s.addEventListener("keydown", this.handleSummaryKeydown), (a = this.detailSlotEl) == null || a.removeEventListener("slotchange", this.handleDetailSlotChange), (n = this.detailSlotEl) == null || n.addEventListener("slotchange", this.handleDetailSlotChange);
23
+ }
24
+ syncOpenHeight() {
25
+ !this.detailEl || !this.detailEl.hasAttribute("open") || requestAnimationFrame(() => {
26
+ !this.detailEl || !this.detailEl.hasAttribute("open") || (this.detailEl.style.maxHeight = this.detailEl.scrollHeight + "px");
27
+ });
28
+ }
29
+ render() {
30
+ var a;
9
31
  if (!this.shadowRoot) return;
10
- const e = this.getAttribute("heading") || "Heading...";
11
- let t = (
32
+ const t = ((a = this.detailEl) == null ? void 0 : a.hasAttribute("open")) ?? !1, e = this.getAttribute("heading") || "Heading...", s = (
12
33
  /*html*/
13
34
  `
14
35
  <style>
15
- :host {
36
+ :host {
16
37
  display: inline-flex;
17
38
  flex-direction: column;
18
39
  }
@@ -24,7 +45,6 @@ class a extends HTMLElement {
24
45
  cursor: pointer;
25
46
  }
26
47
 
27
-
28
48
  .accordion-summary:focus-visible {
29
49
  outline: var(--outline-thick);
30
50
  }
@@ -76,23 +96,25 @@ class a extends HTMLElement {
76
96
  </div>
77
97
  `
78
98
  );
79
- this.shadowRoot.innerHTML = t, this.summaryEl = this.shadowRoot.querySelector(".accordion-summary"), this.detailEl = this.shadowRoot.querySelector(".accordion-detail"), this.chevronEl = this.shadowRoot.querySelector("mui-icon-right-chevron"), (n = this.summaryEl) == null || n.addEventListener("click", this.toggleAccordion.bind(this)), (r = this.summaryEl) == null || r.addEventListener("keydown", (o) => {
80
- (o.key === "Enter" || o.key === " ") && (o.preventDefault(), this.toggleAccordion());
81
- });
99
+ if (this.shadowRoot.innerHTML = s, this.summaryEl = this.shadowRoot.querySelector(".accordion-summary"), this.detailEl = this.shadowRoot.querySelector(".accordion-detail"), this.chevronEl = this.shadowRoot.querySelector("mui-icon-right-chevron"), this.detailSlotEl = this.shadowRoot.querySelector('slot[name="detail"]'), this.bindEvents(), t && this.detailEl && this.chevronEl && this.summaryEl) {
100
+ this.detailEl.setAttribute("open", ""), this.chevronEl.setAttribute("open", ""), this.summaryEl.setAttribute("aria-expanded", "true");
101
+ const n = this.detailEl.querySelector(".accordion-detail-inner");
102
+ n == null || n.removeAttribute("inert"), this.detailEl.style.maxHeight = this.detailEl.scrollHeight + "px";
103
+ }
82
104
  }
83
105
  toggleAccordion() {
84
106
  if (!this.detailEl || !this.chevronEl || !this.summaryEl) return;
85
- const e = this.detailEl.hasAttribute("open");
86
- this.detailEl.toggleAttribute("open"), this.chevronEl.toggleAttribute("open"), this.summaryEl.setAttribute("aria-expanded", String(!e));
87
- const i = this.detailEl.querySelector(".accordion-detail-inner");
88
- if (i)
89
- if (e)
90
- i.setAttribute("inert", ""), this.detailEl.style.maxHeight = "0";
107
+ const t = this.detailEl.hasAttribute("open");
108
+ this.detailEl.toggleAttribute("open"), this.chevronEl.toggleAttribute("open"), this.summaryEl.setAttribute("aria-expanded", String(!t));
109
+ const e = this.detailEl.querySelector(".accordion-detail-inner");
110
+ if (e)
111
+ if (t)
112
+ e.setAttribute("inert", ""), this.detailEl.style.maxHeight = "0";
91
113
  else {
92
- i.removeAttribute("inert");
93
- const t = this.detailEl.scrollHeight;
94
- this.detailEl.style.maxHeight = t + "px";
114
+ e.removeAttribute("inert");
115
+ const i = this.detailEl.scrollHeight;
116
+ this.detailEl.style.maxHeight = i + "px";
95
117
  }
96
118
  }
97
119
  }
98
- customElements.get("mui-accordion-inline") || customElements.define("mui-accordion-inline", a);
120
+ customElements.get("mui-accordion-inline") || customElements.define("mui-accordion-inline", l);
@@ -265,7 +265,7 @@ class h extends HTMLElement {
265
265
  :host([slot="before"][usage="input"]) button,
266
266
  :host([slot="after"][usage="input"]) button {
267
267
  border: var(--border-thin);
268
- min-height: 4.4rem;
268
+ min-height: var(--input-slot-min-height);
269
269
  background: var(--input-background);
270
270
  color: var(--action-secondary-text-color);
271
271
  border-color: var(--form-default-border-color);
@@ -515,6 +515,25 @@ class h extends HTMLElement {
515
515
  border-radius: var(--action-radius-large);
516
516
  }
517
517
 
518
+ /* Keep input-composed buttons flush against the input edge after size radius applies. */
519
+ :host([slot="before"][usage="input"]) button,
520
+ :host([slot="before"][usage="input"]) button:hover,
521
+ :host([slot="before"][usage="input"]) button:focus,
522
+ :host([slot="before"][usage="input"]) button:focus-visible,
523
+ :host([slot="before"][usage="input"]) button:disabled {
524
+ border-top-right-radius: var(--radius-000);
525
+ border-bottom-right-radius: var(--radius-000);
526
+ }
527
+
528
+ :host([slot="after"][usage="input"]) button,
529
+ :host([slot="after"][usage="input"]) button:hover,
530
+ :host([slot="after"][usage="input"]) button:focus,
531
+ :host([slot="after"][usage="input"]) button:focus-visible,
532
+ :host([slot="after"][usage="input"]) button:disabled {
533
+ border-top-left-radius: var(--radius-000);
534
+ border-bottom-left-radius: var(--radius-000);
535
+ }
536
+
518
537
  /* Dropdown slot corner radius must win over size radius rules */
519
538
  :host([size][dropdown-slot]) button,
520
539
  :host([size][dropdown-slot]) button:hover,
@@ -1,4 +1,7 @@
1
- class e extends HTMLElement {
1
+ class o extends HTMLElement {
2
+ static get observedAttributes() {
3
+ return ["layout", "align", "right"];
4
+ }
2
5
  constructor() {
3
6
  super(), this.attachShadow({ mode: "open" });
4
7
  }
@@ -10,8 +13,23 @@ class e extends HTMLElement {
10
13
  :host {
11
14
  display: flex;
12
15
  gap: var(--space-200);
16
+ flex-direction: row;
17
+ justify-content: flex-start;
18
+ align-items: center;
19
+ }
20
+ :host([layout="column"]) {
21
+ flex-direction: column;
22
+ align-items: stretch;
23
+ width: 100%;
24
+ }
25
+ :host([layout="column"]) ::slotted(*) {
26
+ width: 100%;
27
+ box-sizing: border-box;
28
+ }
29
+ :host([align="right"]:not([layout="column"])) {
30
+ justify-content: flex-end;
13
31
  }
14
- :host([right]) {
32
+ :host([right]:not([align]):not([layout="column"])) {
15
33
  justify-content: flex-end;
16
34
  }
17
35
  </style>
@@ -20,4 +38,4 @@ class e extends HTMLElement {
20
38
  this.shadowRoot && (this.shadowRoot.innerHTML = t);
21
39
  }
22
40
  }
23
- customElements.get("mui-button-group") || customElements.define("mui-button-group", e);
41
+ customElements.get("mui-button-group") || customElements.define("mui-button-group", o);
@@ -364,8 +364,8 @@ class w extends HTMLElement {
364
364
  overflow: hidden;
365
365
  }
366
366
  mui-h-stack.chip-slot-shell {
367
- background: var(--chip-input-background, #333333);
368
- padding: var(--chip-input-shell-padding, 2px);
367
+ background: var(--chip-input-background);
368
+ padding: var(--space-025);
369
369
  border: var(--chip-input-shell-border, 1px solid var(--form-default-border-color));
370
370
  box-sizing: border-box;
371
371
  width: 100%;
@@ -32,6 +32,7 @@ class T extends HTMLElement {
32
32
  cursor: help;
33
33
  }
34
34
  .tooltip {
35
+ display: none;
35
36
  position: absolute;
36
37
  z-index: 1000;
37
38
  min-width: max-content;
@@ -54,6 +55,7 @@ class T extends HTMLElement {
54
55
  transition-duration: 0ms;
55
56
  }
56
57
  :host([open]) .tooltip {
58
+ display: block;
57
59
  opacity: 1;
58
60
  pointer-events: auto;
59
61
  }