@mintplayer/web-components 2.1.1 → 2.2.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.
@@ -0,0 +1 @@
1
+ export * from './src';
@@ -0,0 +1,543 @@
1
+ import { unsafeCSS as d, LitElement as n, adoptStyles as b, html as i, nothing as l, css as u } from "lit";
2
+ const h = d(`.accordion {
3
+ --bs-accordion-color: var(--bs-body-color);
4
+ --bs-accordion-bg: var(--bs-body-bg);
5
+ --bs-accordion-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, border-radius 0.15s ease;
6
+ --bs-accordion-border-color: var(--bs-border-color);
7
+ --bs-accordion-border-width: var(--bs-border-width);
8
+ --bs-accordion-border-radius: var(--bs-border-radius);
9
+ --bs-accordion-inner-border-radius: calc(var(--bs-border-radius) - (var(--bs-border-width)));
10
+ --bs-accordion-btn-padding-x: 1.25rem;
11
+ --bs-accordion-btn-padding-y: 1rem;
12
+ --bs-accordion-btn-color: var(--bs-body-color);
13
+ --bs-accordion-btn-bg: var(--bs-accordion-bg);
14
+ --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23212529' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
15
+ --bs-accordion-btn-icon-width: 1.25rem;
16
+ --bs-accordion-btn-icon-transform: rotate(-180deg);
17
+ --bs-accordion-btn-icon-transition: transform 0.2s ease-in-out;
18
+ --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='rgb%285.2, 44, 101.2%29' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
19
+ --bs-accordion-btn-focus-box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
20
+ --bs-accordion-body-padding-x: 1.25rem;
21
+ --bs-accordion-body-padding-y: 1rem;
22
+ --bs-accordion-active-color: var(--bs-primary-text-emphasis);
23
+ --bs-accordion-active-bg: var(--bs-primary-bg-subtle);
24
+ }
25
+
26
+ .accordion-button {
27
+ position: relative;
28
+ display: flex;
29
+ align-items: center;
30
+ width: 100%;
31
+ padding: var(--bs-accordion-btn-padding-y) var(--bs-accordion-btn-padding-x);
32
+ font-size: 1rem;
33
+ color: var(--bs-accordion-btn-color);
34
+ text-align: left;
35
+ background-color: var(--bs-accordion-btn-bg);
36
+ border: 0;
37
+ border-radius: 0;
38
+ overflow-anchor: none;
39
+ transition: var(--bs-accordion-transition);
40
+ }
41
+ @media (prefers-reduced-motion: reduce) {
42
+ .accordion-button {
43
+ transition: none;
44
+ }
45
+ }
46
+ .accordion-button:not(.collapsed) {
47
+ color: var(--bs-accordion-active-color);
48
+ background-color: var(--bs-accordion-active-bg);
49
+ box-shadow: inset 0 calc(-1 * var(--bs-accordion-border-width)) 0 var(--bs-accordion-border-color);
50
+ }
51
+ .accordion-button:not(.collapsed)::after {
52
+ background-image: var(--bs-accordion-btn-active-icon);
53
+ transform: var(--bs-accordion-btn-icon-transform);
54
+ }
55
+ .accordion-button::after {
56
+ flex-shrink: 0;
57
+ width: var(--bs-accordion-btn-icon-width);
58
+ height: var(--bs-accordion-btn-icon-width);
59
+ margin-left: auto;
60
+ content: "";
61
+ background-image: var(--bs-accordion-btn-icon);
62
+ background-repeat: no-repeat;
63
+ background-size: var(--bs-accordion-btn-icon-width);
64
+ transition: var(--bs-accordion-btn-icon-transition);
65
+ }
66
+ @media (prefers-reduced-motion: reduce) {
67
+ .accordion-button::after {
68
+ transition: none;
69
+ }
70
+ }
71
+ .accordion-button:hover {
72
+ z-index: 2;
73
+ }
74
+ .accordion-button:focus {
75
+ z-index: 3;
76
+ outline: 0;
77
+ box-shadow: var(--bs-accordion-btn-focus-box-shadow);
78
+ }
79
+
80
+ .accordion-header {
81
+ margin-bottom: 0;
82
+ }
83
+
84
+ .accordion-item {
85
+ color: var(--bs-accordion-color);
86
+ background-color: var(--bs-accordion-bg);
87
+ border: var(--bs-accordion-border-width) solid var(--bs-accordion-border-color);
88
+ }
89
+ .accordion-item:first-of-type {
90
+ border-top-left-radius: var(--bs-accordion-border-radius);
91
+ border-top-right-radius: var(--bs-accordion-border-radius);
92
+ }
93
+ .accordion-item:first-of-type > .accordion-header .accordion-button {
94
+ border-top-left-radius: var(--bs-accordion-inner-border-radius);
95
+ border-top-right-radius: var(--bs-accordion-inner-border-radius);
96
+ }
97
+ .accordion-item:not(:first-of-type) {
98
+ border-top: 0;
99
+ }
100
+ .accordion-item:last-of-type {
101
+ border-bottom-right-radius: var(--bs-accordion-border-radius);
102
+ border-bottom-left-radius: var(--bs-accordion-border-radius);
103
+ }
104
+ .accordion-item:last-of-type > .accordion-header .accordion-button.collapsed {
105
+ border-bottom-right-radius: var(--bs-accordion-inner-border-radius);
106
+ border-bottom-left-radius: var(--bs-accordion-inner-border-radius);
107
+ }
108
+ .accordion-item:last-of-type > .accordion-collapse {
109
+ border-bottom-right-radius: var(--bs-accordion-border-radius);
110
+ border-bottom-left-radius: var(--bs-accordion-border-radius);
111
+ }
112
+
113
+ .accordion-body {
114
+ padding: var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x);
115
+ }
116
+
117
+ .accordion-flush > .accordion-item {
118
+ border-right: 0;
119
+ border-left: 0;
120
+ border-radius: 0;
121
+ }
122
+ .accordion-flush > .accordion-item:first-child {
123
+ border-top: 0;
124
+ }
125
+ .accordion-flush > .accordion-item:last-child {
126
+ border-bottom: 0;
127
+ }
128
+ .accordion-flush > .accordion-item > .accordion-collapse,
129
+ .accordion-flush > .accordion-item > .accordion-header .accordion-button,
130
+ .accordion-flush > .accordion-item > .accordion-header .accordion-button.collapsed {
131
+ border-radius: 0;
132
+ }
133
+
134
+ [data-bs-theme=dark] .accordion-button::after {
135
+ --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='rgb%28109.8, 168, 253.8%29'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3e%3c/svg%3e");
136
+ --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='rgb%28109.8, 168, 253.8%29'%3e%3cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708'/%3e%3c/svg%3e");
137
+ }
138
+
139
+ :host {
140
+ display: block;
141
+ --bs-accordion-color: var(--bs-body-color);
142
+ --bs-accordion-bg: var(--bs-body-bg);
143
+ --bs-accordion-transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, border-radius 0.15s ease;
144
+ --bs-accordion-border-color: var(--bs-border-color);
145
+ --bs-accordion-border-width: var(--bs-border-width);
146
+ --bs-accordion-border-radius: var(--bs-border-radius);
147
+ --bs-accordion-inner-border-radius: calc(var(--bs-border-radius) - (var(--bs-border-width)));
148
+ --bs-accordion-btn-padding-x: 1.25rem;
149
+ --bs-accordion-btn-padding-y: 1rem;
150
+ --bs-accordion-btn-color: var(--bs-body-color);
151
+ --bs-accordion-btn-bg: var(--bs-accordion-bg);
152
+ --bs-accordion-btn-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23212529' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
153
+ --bs-accordion-btn-icon-width: 1.25rem;
154
+ --bs-accordion-btn-icon-transform: rotate(-180deg);
155
+ --bs-accordion-btn-icon-transition: transform 0.2s ease-in-out;
156
+ --bs-accordion-btn-active-icon: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='rgb%285.2, 44, 101.2%29' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
157
+ --bs-accordion-btn-focus-box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
158
+ --bs-accordion-body-padding-x: 0;
159
+ --bs-accordion-body-padding-y: 0;
160
+ --bs-accordion-active-color: var(--bs-primary-text-emphasis);
161
+ --bs-accordion-active-bg: var(--bs-primary-bg-subtle);
162
+ }
163
+
164
+ :host([data-nested]) {
165
+ margin: calc(-1 * var(--bs-accordion-border-width));
166
+ }
167
+
168
+ *,
169
+ *::before,
170
+ *::after {
171
+ box-sizing: border-box;
172
+ }
173
+
174
+ .accordion-item {
175
+ position: relative;
176
+ }
177
+
178
+ .acc-input {
179
+ position: absolute;
180
+ width: 1px;
181
+ height: 1px;
182
+ padding: 0;
183
+ margin: -1px;
184
+ overflow: hidden;
185
+ clip: rect(0, 0, 0, 0);
186
+ white-space: nowrap;
187
+ border: 0;
188
+ }
189
+
190
+ .accordion-collapse {
191
+ display: grid;
192
+ grid-template-rows: 0fr;
193
+ transition: grid-template-rows 0.35s ease;
194
+ }
195
+
196
+ .accordion-collapse > .accordion-clip {
197
+ min-height: 0;
198
+ overflow: hidden;
199
+ }
200
+
201
+ .accordion-item.open > .accordion-collapse,
202
+ .acc-input:checked ~ .accordion-collapse {
203
+ grid-template-rows: 1fr;
204
+ }
205
+
206
+ .accordion-content {
207
+ padding: var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x);
208
+ }
209
+
210
+ .accordion-header > label.accordion-button {
211
+ cursor: pointer;
212
+ user-select: none;
213
+ }
214
+
215
+ .accordion-button::after {
216
+ background-image: none;
217
+ background-color: currentColor;
218
+ mask-image: var(--bs-accordion-btn-icon);
219
+ mask-repeat: no-repeat;
220
+ mask-size: var(--bs-accordion-btn-icon-width);
221
+ -webkit-mask-image: var(--bs-accordion-btn-icon);
222
+ -webkit-mask-repeat: no-repeat;
223
+ -webkit-mask-size: var(--bs-accordion-btn-icon-width);
224
+ }
225
+
226
+ .accordion-button:not(.collapsed)::after,
227
+ .acc-input:checked + .accordion-header > .accordion-button::after {
228
+ background-image: none;
229
+ mask-image: var(--bs-accordion-btn-active-icon);
230
+ -webkit-mask-image: var(--bs-accordion-btn-active-icon);
231
+ }
232
+
233
+ .acc-input:checked + .accordion-header > .accordion-button {
234
+ color: var(--bs-accordion-active-color);
235
+ background-color: var(--bs-accordion-active-bg);
236
+ }
237
+ .acc-input:checked + .accordion-header > .accordion-button::after {
238
+ background-image: var(--bs-accordion-btn-active-icon);
239
+ transform: var(--bs-accordion-btn-icon-transform);
240
+ }
241
+
242
+ .acc-input:focus-visible + .accordion-header > .accordion-button {
243
+ z-index: 3;
244
+ outline: 0;
245
+ box-shadow: var(--bs-accordion-btn-focus-box-shadow);
246
+ }
247
+
248
+ :host(:not([highlight-active-tab])) .accordion-button:not(.collapsed),
249
+ :host(:not([highlight-active-tab])) .acc-input:checked + .accordion-header > .accordion-button {
250
+ background-color: unset;
251
+ color: inherit;
252
+ }
253
+
254
+ @media (prefers-reduced-motion: reduce) {
255
+ .accordion-collapse {
256
+ transition: none;
257
+ }
258
+ }`);
259
+ class s extends n {
260
+ static {
261
+ this.styles = [h];
262
+ }
263
+ static get observedAttributes() {
264
+ return [
265
+ ...super.observedAttributes ?? [],
266
+ "multi",
267
+ "highlight-active-tab",
268
+ "tab-count"
269
+ ];
270
+ }
271
+ /**
272
+ * Config is attribute-only on purpose — a public accessor of the same name
273
+ * makes `@lit/react` treat it as a property and drop it from the
274
+ * server-rendered HTML, which would silently change the SSR chrome
275
+ * (carousel lesson, docs/prd/carousel-wc.md §8).
276
+ */
277
+ get #a() {
278
+ return this.hasAttribute("multi") && this.getAttribute("multi") !== "false";
279
+ }
280
+ get #p() {
281
+ return this.hasAttribute("highlight-active-tab");
282
+ }
283
+ /** Tab count for chrome generation, when no light DOM is present yet. */
284
+ get #d() {
285
+ const o = Number(this.getAttribute("tab-count"));
286
+ return Number.isFinite(o) && o > 0 ? Math.floor(o) : 0;
287
+ }
288
+ #e = [];
289
+ #o = [];
290
+ #t = null;
291
+ connectedCallback() {
292
+ this.shadowRoot && this.#b(), super.connectedCallback(), this.setAttribute("data-js", ""), this.parentElement?.closest("mp-accordion") ? this.setAttribute("data-nested", "") : this.removeAttribute("data-nested"), this.#t = new MutationObserver(() => this.#i()), this.#t.observe(this, { childList: !0 }), this.#i();
293
+ }
294
+ disconnectedCallback() {
295
+ this.#t?.disconnect(), this.#t = null, super.disconnectedCallback();
296
+ }
297
+ createRenderRoot() {
298
+ const o = this.constructor;
299
+ let r;
300
+ return this.shadowRoot ? (this.shadowRoot.replaceChildren(), r = this.shadowRoot) : r = this.attachShadow(o.shadowRootOptions ?? { mode: "open" }), b(r, o.elementStyles ?? []), r;
301
+ }
302
+ attributeChangedCallback(o, r, a) {
303
+ super.attributeChangedCallback(o, r, a), r !== a && this.requestUpdate();
304
+ }
305
+ // ---------------------------------------------------------------- public
306
+ /** Indexes of the currently open tabs. */
307
+ get activeIndexes() {
308
+ return this.#o.flatMap((o, r) => o.active ? [r] : []);
309
+ }
310
+ /** Open a tab (closing its siblings unless `multi`). */
311
+ open(o) {
312
+ this.#r(o, !0, null);
313
+ }
314
+ /** Close a tab, and every accordion nested inside it. */
315
+ close(o) {
316
+ this.#r(o, !1, null);
317
+ }
318
+ toggle(o) {
319
+ this.#r(o, !this.#o[o]?.active, null);
320
+ }
321
+ /**
322
+ * Close every open tab. Nested accordions are closed too, so this
323
+ * collapses an entire branch in one call.
324
+ */
325
+ closeAll(o = null) {
326
+ this.#o.forEach((r, a) => {
327
+ r.active && this.#r(a, !1, o);
328
+ });
329
+ }
330
+ // --------------------------------------------------------------- private
331
+ /**
332
+ * Mirror the server-rendered inputs' checked state onto the light-DOM
333
+ * markers, so the client render opens exactly what the user left open.
334
+ */
335
+ #b() {
336
+ const o = this.shadowRoot?.querySelectorAll(".acc-input");
337
+ if (!o?.length) return;
338
+ const r = this.#c();
339
+ o.forEach((a, t) => {
340
+ const e = r[t];
341
+ e && (a.checked ? e.setAttribute("is-active", "") : e.removeAttribute("is-active"));
342
+ });
343
+ }
344
+ /**
345
+ * Tabs and headers are identified by ATTRIBUTE, not tag name, and must be
346
+ * direct children — named slots only accept those. A framework wrapper
347
+ * always renders its own host element around the tab it contributes
348
+ * (`<bs-accordion-tab>`), so requiring a specific tag would put the marker
349
+ * one level too deep to ever be slotted. `<mp-accordion-tab>` is only the
350
+ * vanilla convenience element; it tags itself.
351
+ */
352
+ #c() {
353
+ return Array.from(this.children).filter(
354
+ (o) => o instanceof HTMLElement && o.hasAttribute("accordion-tab")
355
+ );
356
+ }
357
+ #l() {
358
+ return Array.from(this.children).filter(
359
+ (o) => o instanceof HTMLElement && o.hasAttribute("accordion-header")
360
+ );
361
+ }
362
+ /**
363
+ * Re-read the markers, (re-)stamp their slot names, and keep the per-marker
364
+ * attribute observations current. Stamping is idempotent, and framework
365
+ * wrappers stamp the same names server-side — where no script runs to do
366
+ * it — so the two never disagree.
367
+ */
368
+ #i() {
369
+ const o = this.#c(), r = this.#l();
370
+ o.forEach((t, e) => {
371
+ const c = `c${e}`;
372
+ t.getAttribute("slot") !== c && t.setAttribute("slot", c);
373
+ }), r.forEach((t, e) => {
374
+ const c = `h${e}`;
375
+ t.getAttribute("slot") !== c && t.setAttribute("slot", c);
376
+ }), Array.from(this.children).forEach(
377
+ (t) => this.#t?.observe(t, {
378
+ attributes: !0,
379
+ attributeFilter: ["is-active", "disabled", "accordion-tab", "accordion-header"]
380
+ })
381
+ );
382
+ const a = this.#o;
383
+ this.#e = o, this.#o = o.map((t) => ({
384
+ active: t.hasAttribute("is-active"),
385
+ disabled: t.hasAttribute("disabled")
386
+ })), a.length === this.#o.length && this.#o.forEach((t, e) => {
387
+ !t.active && a[e].active && this.#s(e, null);
388
+ }), this.requestUpdate();
389
+ }
390
+ /**
391
+ * The single write path for tab state: updates the marker (the source of
392
+ * truth), enforces single-open, recursively collapses nested accordions on
393
+ * close, and announces every change that actually happened.
394
+ */
395
+ #r(o, r, a) {
396
+ const t = this.#o[o];
397
+ !t || t.disabled || t.active === r || (r && !this.#a && this.#o.forEach((e, c) => {
398
+ c !== o && e.active && this.#r(c, !1, a);
399
+ }), this.#u(o, r), t.active = r, r || this.#s(o, a), this.requestUpdate(), this.dispatchEvent(
400
+ new CustomEvent("mp-accordion-tab-toggle", {
401
+ detail: { index: o, active: r, originalEvent: a },
402
+ bubbles: !0,
403
+ composed: !0
404
+ })
405
+ ));
406
+ }
407
+ #u(o, r) {
408
+ const a = this.#e[o];
409
+ a && (r ? a.setAttribute("is-active", "") : a.removeAttribute("is-active"));
410
+ }
411
+ /**
412
+ * Collapse every accordion inside a closing tab. `querySelectorAll` reaches
413
+ * ALL depths of the tab's light-DOM subtree in one pass, and each nested
414
+ * `closeAll()` collapses its own descendants in turn — so a branch can
415
+ * never be left with hidden-but-open tabs.
416
+ */
417
+ #s(o, r) {
418
+ const a = this.#e[o];
419
+ a && a.querySelectorAll("mp-accordion").forEach((t) => {
420
+ t instanceof s && t.closeAll(r);
421
+ });
422
+ }
423
+ #h(o, r) {
424
+ this.#r(o, !this.#o[o]?.active, r);
425
+ }
426
+ /** APG accordion keyboard: Up/Down between headers, Home/End to the ends. */
427
+ #v(o, r) {
428
+ const a = this.#o.length - 1;
429
+ let t = null;
430
+ switch (r.key) {
431
+ case "ArrowDown":
432
+ t = o === a ? 0 : o + 1;
433
+ break;
434
+ case "ArrowUp":
435
+ t = o === 0 ? a : o - 1;
436
+ break;
437
+ case "Home":
438
+ t = 0;
439
+ break;
440
+ case "End":
441
+ t = a;
442
+ break;
443
+ default:
444
+ return;
445
+ }
446
+ r.preventDefault(), this.shadowRoot?.querySelector(`#b${t}`)?.focus();
447
+ }
448
+ render() {
449
+ const o = this.hasAttribute("data-js"), r = this.#o.length || this.#d, a = Array.from(
450
+ { length: r },
451
+ (t, e) => this.#o[e] ?? { active: !1, disabled: !1 }
452
+ );
453
+ return i`
454
+ <div class="accordion-root" part="accordion">
455
+ ${a.map(
456
+ (t, e) => o ? this.#m(t, e) : this.#g(t, e)
457
+ )}
458
+ <slot></slot>
459
+ </div>
460
+ `;
461
+ }
462
+ #m(o, r) {
463
+ return i`
464
+ <div class="accordion-item ${o.active ? "open" : ""}">
465
+ <div class="accordion-header" role="heading" aria-level="2" id="h${r}" part="header">
466
+ <button
467
+ type="button"
468
+ id="b${r}"
469
+ class="accordion-button ${o.active ? "" : "collapsed"}"
470
+ aria-expanded=${o.active ? "true" : "false"}
471
+ aria-controls="c${r}"
472
+ ?disabled=${o.disabled}
473
+ part="button"
474
+ @click=${(a) => this.#h(r, a)}
475
+ @keydown=${(a) => this.#v(r, a)}>
476
+ <slot name="h${r}"></slot>
477
+ </button>
478
+ </div>
479
+ ${this.#n(r)}
480
+ </div>
481
+ `;
482
+ }
483
+ #g(o, r) {
484
+ return i`
485
+ <div class="accordion-item">
486
+ <input
487
+ class="acc-input"
488
+ type=${this.#a ? "checkbox" : "radio"}
489
+ name=${this.#a ? l : "acc"}
490
+ id="t${r}"
491
+ aria-controls="c${r}"
492
+ ?checked=${o.active}
493
+ ?disabled=${o.disabled} />
494
+ <div class="accordion-header" role="heading" aria-level="2" id="h${r}" part="header">
495
+ <label class="accordion-button collapsed" for="t${r}" part="button">
496
+ <slot name="h${r}"></slot>
497
+ </label>
498
+ </div>
499
+ ${this.#n(r)}
500
+ </div>
501
+ `;
502
+ }
503
+ /**
504
+ * Three nested boxes, not two: `.accordion-collapse` is the grid that
505
+ * animates, `.accordion-clip` is the zero-min-height clipper, and only
506
+ * `.accordion-content` may carry spacing. Padding on the clipper would
507
+ * survive the collapse — an element's own padding is not clipped by its
508
+ * `overflow: hidden`, so a closed tab would keep showing a padding strip.
509
+ */
510
+ #n(o) {
511
+ return i`
512
+ <div class="accordion-collapse" id="c${o}" role="region" aria-labelledby="h${o}">
513
+ <div class="accordion-clip">
514
+ <div class="accordion-content" part="content">
515
+ <slot name="c${o}"></slot>
516
+ </div>
517
+ </div>
518
+ </div>
519
+ `;
520
+ }
521
+ }
522
+ typeof customElements < "u" && !customElements.get("mp-accordion") && customElements.define("mp-accordion", s);
523
+ class v extends n {
524
+ static {
525
+ this.styles = u`
526
+ :host {
527
+ display: block;
528
+ }
529
+ `;
530
+ }
531
+ connectedCallback() {
532
+ super.connectedCallback(), this.setAttribute("accordion-tab", "");
533
+ }
534
+ render() {
535
+ return i`<slot></slot>`;
536
+ }
537
+ }
538
+ typeof customElements < "u" && !customElements.get("mp-accordion-tab") && customElements.define("mp-accordion-tab", v);
539
+ export {
540
+ s as MpAccordion,
541
+ v as MpAccordionTab,
542
+ h as accordionStyles
543
+ };
@@ -0,0 +1,3 @@
1
+ export { MpAccordion } from './mp-accordion';
2
+ export type { AccordionTabToggleDetail } from './mp-accordion';
3
+ export { MpAccordionTab } from './mp-accordion-tab';
@@ -0,0 +1,30 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ /**
3
+ * `<mp-accordion-tab>` — inert marker child of `<mp-accordion>`.
4
+ *
5
+ * Holds one tab's BODY content and carries that tab's state as attributes
6
+ * (`is-active`, `disabled`). It renders nothing of its own: the parent owns
7
+ * the entire accordion chrome in a single shadow root (headers, inputs,
8
+ * ARIA, animation), and slots this element into the matching collapse
9
+ * region. The `mp-tab-page` precedent.
10
+ *
11
+ * A tab's HEADER cannot live inside this element — named slots only accept
12
+ * direct children of the shadow host — so it is authored as a sibling
13
+ * carrying the `accordion-header` attribute. The i-th header pairs with the
14
+ * i-th tab; the framework wrappers hoist header templates automatically, so
15
+ * only vanilla consumers see the flat shape:
16
+ *
17
+ * <mp-accordion>
18
+ * <span accordion-header>Profile</span>
19
+ * <mp-accordion-tab is-active>Profile body</mp-accordion-tab>
20
+ * </mp-accordion>
21
+ *
22
+ * This element is a convenience, not a requirement: the parent recognises
23
+ * tabs by the `accordion-tab` attribute (which this one stamps on itself),
24
+ * so a wrapper's own host element can be the marker instead.
25
+ */
26
+ export declare class MpAccordionTab extends LitElement {
27
+ static styles: import('lit').CSSResult;
28
+ connectedCallback(): void;
29
+ render(): TemplateResult;
30
+ }
@@ -0,0 +1,61 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ /** Detail of the `mp-accordion-tab-toggle` event. */
3
+ export interface AccordionTabToggleDetail {
4
+ /** Zero-based position of the tab that changed. */
5
+ index: number;
6
+ /** Its new state. */
7
+ active: boolean;
8
+ /** The click / keydown / change that caused it, or `null` when programmatic. */
9
+ originalEvent: Event | null;
10
+ }
11
+ /**
12
+ * `<mp-accordion>` — Bootstrap accordion owning its whole structure in one
13
+ * shadow root.
14
+ *
15
+ * Light-DOM children are markers, not chrome: each `<mp-accordion-tab>`
16
+ * supplies one tab's body, each `[accordion-header]` element supplies one
17
+ * header, paired by position (i-th header ↔ i-th tab). This element stamps
18
+ * the `slot="hN"` / `slot="cN"` names itself, so consumers never write them.
19
+ * Children that are neither render through the default slot — an accordion
20
+ * with zero tabs is a valid styled container (the offcanvas nav uses one).
21
+ *
22
+ * Two interaction tiers, one template, branched on `data-js`:
23
+ * - JS on: `<button aria-expanded>` headers; this element owns the
24
+ * click/keyboard → state loop and animates via `grid-template-rows`.
25
+ * - JS off (server-rendered DSD): a visually-hidden `<input>` per tab —
26
+ * radio when single-open, checkbox under `multi` — plus a `<label>`
27
+ * header. `:checked` opens the collapse, rotates the chevron and paints
28
+ * the active state, so the accordion is fully interactive, and keyboard
29
+ * operable, with no script at all. Radio exclusivity is why one shadow
30
+ * root owns every tab: a group only forms within a single node tree.
31
+ *
32
+ * Active state lives on the light-DOM markers (`is-active`), which makes it
33
+ * declarative for every framework wrapper and survives the SSR handoff — the
34
+ * pre-upgrade `:checked` inputs are read back onto the markers before the
35
+ * shadow is replaced.
36
+ *
37
+ * Closing a tab closes every accordion nested inside it, at any depth, so a
38
+ * collapsed branch never hides expanded descendants.
39
+ */
40
+ export declare class MpAccordion extends LitElement {
41
+ #private;
42
+ static styles: import('lit').CSSResult[];
43
+ static get observedAttributes(): string[];
44
+ connectedCallback(): void;
45
+ disconnectedCallback(): void;
46
+ createRenderRoot(): ShadowRoot;
47
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
48
+ /** Indexes of the currently open tabs. */
49
+ get activeIndexes(): number[];
50
+ /** Open a tab (closing its siblings unless `multi`). */
51
+ open(index: number): void;
52
+ /** Close a tab, and every accordion nested inside it. */
53
+ close(index: number): void;
54
+ toggle(index: number): void;
55
+ /**
56
+ * Close every open tab. Nested accordions are closed too, so this
57
+ * collapses an entire branch in one call.
58
+ */
59
+ closeAll(originalEvent?: Event | null): void;
60
+ render(): TemplateResult;
61
+ }
@@ -0,0 +1,3 @@
1
+ export { MpAccordion, MpAccordionTab } from './components';
2
+ export type { AccordionTabToggleDetail } from './components';
3
+ export { accordionStyles } from './styles';
@@ -0,0 +1 @@
1
+ export { accordionStyles } from './accordion.styles';
@@ -0,0 +1 @@
1
+ export * from './src';