@mintplayer/web-components 2.2.0 → 2.4.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/a11y/index.mjs +26 -2
- package/a11y/src/dismiss-stack.d.ts +25 -0
- package/a11y/src/error-text.d.ts +41 -0
- package/a11y/src/focus-restore.d.ts +116 -0
- package/a11y/src/focus-trap.d.ts +69 -0
- package/a11y/src/form-associated.d.ts +48 -0
- package/a11y/src/host-aria.d.ts +154 -0
- package/a11y/src/index.d.ts +16 -0
- package/a11y/src/inert-regions.d.ts +52 -0
- package/a11y/src/live-announcer.d.ts +8 -0
- package/a11y/src/roving-focus.d.ts +118 -0
- package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
- package/a11y/src/testing/index.d.ts +1 -0
- package/accordion/index.mjs +180 -174
- package/accordion/src/components/mp-accordion.d.ts +18 -13
- package/calendar/index.mjs +1 -1
- package/calendar/src/mp-calendar.element.d.ts +2 -0
- package/carousel/index.mjs +211 -164
- package/carousel/src/components/mp-carousel.d.ts +1 -0
- package/checkbox/index.mjs +1 -1
- package/checkbox/src/components/mp-checkbox.d.ts +59 -1
- package/chunks/color-CpFtrIoX.mjs +899 -0
- package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
- package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
- package/chunks/form-associated-axmc5sY0.mjs +58 -0
- package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
- package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
- package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
- package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
- package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
- package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
- package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
- package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
- package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
- package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
- package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
- package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
- package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
- package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
- package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
- package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
- package/chunks/roving-focus-CrL9982a.mjs +129 -0
- package/code-snippet/index.mjs +21 -13
- package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
- package/datatable/index.mjs +1 -1
- package/datatable/src/components/mp-datatable.d.ts +50 -0
- package/datatable/src/types/index.d.ts +2 -0
- package/datatable/src/types/labels.d.ts +30 -0
- package/datepicker/index.mjs +45 -22
- package/datepicker/src/mp-datepicker.element.d.ts +30 -0
- package/datetime-picker/index.mjs +15 -9
- package/dock/index.mjs +365 -209
- package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
- package/dropdown-menu/index.mjs +135 -90
- package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
- package/file-manager/index.mjs +279 -214
- package/file-manager/src/components/mp-file-manager.d.ts +22 -0
- package/file-manager/src/types/messages.d.ts +9 -0
- package/multi-range/index.mjs +26 -10
- package/multi-range/src/mint-multi-range.element.d.ts +7 -0
- package/navbar/index.mjs +53 -39
- package/navbar/src/components/mp-navbar.d.ts +1 -0
- package/otp-input/index.mjs +82 -48
- package/otp-input/src/mint-otp-input.element.d.ts +31 -3
- package/overlay/index.mjs +2 -258
- package/overlay/src/overlay-controller.d.ts +64 -4
- package/package.json +9 -1
- package/pagination/index.mjs +1 -1
- package/query-builder/index.mjs +117 -87
- package/query-builder/src/model/messages.d.ts +9 -0
- package/radio/index.mjs +2 -160
- package/radio/src/components/mp-radio.d.ts +58 -3
- package/radio-group/index.d.ts +1 -0
- package/radio-group/index.mjs +145 -0
- package/radio-group/src/components/mp-radio-group.d.ts +52 -0
- package/radio-group/src/index.d.ts +1 -0
- package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
- package/ribbon/index.mjs +316 -304
- package/ribbon/src/mp-ribbon.element.d.ts +16 -0
- package/scheduler/index.mjs +892 -493
- package/scheduler/src/components/mp-scheduler.d.ts +30 -0
- package/scheduler/src/input/input-handler.d.ts +2 -0
- package/scheduler/src/views/base-view.d.ts +43 -6
- package/scheduler/src/views/timeline-view.d.ts +6 -0
- package/scheduler-core/index.mjs +73 -70
- package/scheduler-core/src/models/index.d.ts +1 -0
- package/scheduler-core/src/models/messages.d.ts +69 -0
- package/scheduler-core/src/models/options.d.ts +4 -0
- package/select/index.mjs +1 -1
- package/select/src/components/mp-select.d.ts +60 -3
- package/shell/index.mjs +142 -31
- package/shell/src/components/mp-shell.d.ts +1 -0
- package/signature-pad/index.d.ts +1 -0
- package/signature-pad/index.mjs +230 -0
- package/signature-pad/src/index.d.ts +2 -0
- package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
- package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
- package/signature-pad/src/types/signature.d.ts +12 -0
- package/splitter/index.mjs +1 -1
- package/splitter/src/components/mp-splitter.d.ts +7 -0
- package/tab-control/index.mjs +1 -1
- package/tile-manager/index.mjs +110 -93
- package/timeline/index.mjs +138 -54
- package/timeline/src/components/mp-timeline.d.ts +15 -0
- package/timepicker/index.mjs +1 -1
- package/timepicker/src/mp-time-list.element.d.ts +13 -4
- package/timepicker/src/mp-timepicker.element.d.ts +29 -0
- package/toggle-button/index.mjs +1 -1
- package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
- package/tree-select/index.mjs +233 -121
- package/tree-select/src/components/mp-tree-select.d.ts +37 -0
- package/treeview/index.mjs +1 -1
- package/treeview/src/components/mp-treeview.d.ts +10 -1
- package/chunks/color-CyamnJnn.mjs +0 -847
- package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type RovingFocusOrientation = 'vertical' | 'horizontal' | 'both';
|
|
2
|
+
/**
|
|
3
|
+
* Index arithmetic for roving navigation, with no DOM and no framework in it.
|
|
4
|
+
*
|
|
5
|
+
* Extracted so the Angular `BsRovingFocusDirective` can share it rather than
|
|
6
|
+
* keep a second copy. That directive predates this controller and the two had
|
|
7
|
+
* independently identical `step` / `firstEnabled` / `lastEnabled` logic — and
|
|
8
|
+
* they had already drifted on the wrap-vs-clamp default, which is precisely the
|
|
9
|
+
* inconsistency a shared primitive exists to remove.
|
|
10
|
+
*
|
|
11
|
+
* Only the arithmetic is shared. The adapters stay separate on purpose: Angular
|
|
12
|
+
* discovers items through `contentChildren`, exposes `activeIndex` as a signal,
|
|
13
|
+
* and writes `tabindex` through a host binding on each item directive, while
|
|
14
|
+
* this controller takes a callback and writes `tabIndex` imperatively. Making
|
|
15
|
+
* Angular delegate to the class below would put two writers on one attribute —
|
|
16
|
+
* the hazard the workspace has already been bitten by once (see
|
|
17
|
+
* `otp-input.component.ts:124-131`).
|
|
18
|
+
*
|
|
19
|
+
* @param count number of candidate items
|
|
20
|
+
* @param from current index
|
|
21
|
+
* @param delta +1 or -1
|
|
22
|
+
* @param wrap pass the ends, or stop at them
|
|
23
|
+
* @param isDisabled by index, so callers can consult signals or attributes
|
|
24
|
+
* @returns the next enabled index, or `-1` when there is nowhere to go
|
|
25
|
+
*/
|
|
26
|
+
export declare function nextEnabledIndex(count: number, from: number, delta: 1 | -1, wrap: boolean, isDisabled: (index: number) => boolean): number;
|
|
27
|
+
/** First enabled index, or `-1` when every item is disabled. */
|
|
28
|
+
export declare function firstEnabledIndex(count: number, isDisabled: (index: number) => boolean): number;
|
|
29
|
+
/** Last enabled index, or `-1` when every item is disabled. */
|
|
30
|
+
export declare function lastEnabledIndex(count: number, isDisabled: (index: number) => boolean): number;
|
|
31
|
+
export interface RovingFocusOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The navigable items, in tab order, recomputed on every interaction.
|
|
34
|
+
*
|
|
35
|
+
* A callback rather than a static list because these components rebuild their
|
|
36
|
+
* DOM constantly, and because items may live in the shadow root **or** be
|
|
37
|
+
* slotted light DOM — so no single query can be baked in.
|
|
38
|
+
*/
|
|
39
|
+
items: () => HTMLElement[];
|
|
40
|
+
/** Which arrow keys navigate. Default `'vertical'`. */
|
|
41
|
+
orientation?: RovingFocusOrientation;
|
|
42
|
+
/**
|
|
43
|
+
* Wrap past the ends. Default **false** — clamping is the APG default for
|
|
44
|
+
* grids and trees, and the audit found existing hand-rolled implementations
|
|
45
|
+
* split roughly evenly between the two, which is exactly the inconsistency
|
|
46
|
+
* this primitive exists to remove. Opt in per component where the pattern
|
|
47
|
+
* calls for it (menus wrap).
|
|
48
|
+
*/
|
|
49
|
+
wrap?: boolean;
|
|
50
|
+
/** Treated as skippable. Default: `[aria-disabled="true"]` or `:disabled`. */
|
|
51
|
+
isDisabled?: (el: HTMLElement) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Invert Left/Right under RTL. Default true — reading direction is read from
|
|
54
|
+
* the item's computed `direction`, so a mirrored layout navigates the way it
|
|
55
|
+
* looks.
|
|
56
|
+
*/
|
|
57
|
+
rtlAware?: boolean;
|
|
58
|
+
/** Called after the active item changes, for `aria-activedescendant` mirroring or announcements. */
|
|
59
|
+
onActiveChange?: (item: HTMLElement, index: number) => void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* APG roving-tabindex container: exactly one item is tabbable, arrow keys move
|
|
63
|
+
* both DOM focus and the tab stop.
|
|
64
|
+
*
|
|
65
|
+
* Fourteen components hand-rolled this, and they drifted — some wrap at the
|
|
66
|
+
* ends, some clamp; some activate on focus, some on Enter — so a user who
|
|
67
|
+
* learns one composite widget's keyboard model cannot transfer it to the next.
|
|
68
|
+
* The point of this primitive is less any individual fix than that the next
|
|
69
|
+
* component does not add a fifteenth variant.
|
|
70
|
+
*
|
|
71
|
+
* `aria-activedescendant` is **not** offered as a mode, unlike the Angular
|
|
72
|
+
* directive it is ported from. Inside a shadow root that attribute is a trap:
|
|
73
|
+
* it is an IDREF, so it resolves only within the holder's own tree, and the
|
|
74
|
+
* audit found the one component that tried it (`mp-time-list`) had a
|
|
75
|
+
* permanently dangling reference — the host held the attribute while the option
|
|
76
|
+
* ids lived in its shadow root, so arrow keys announced nothing at all. Moving
|
|
77
|
+
* real DOM focus crosses shadow boundaries where IDREFs cannot, so
|
|
78
|
+
* roving-tabindex is the only mechanism that works here.
|
|
79
|
+
*/
|
|
80
|
+
export declare class RovingFocus {
|
|
81
|
+
private readonly options;
|
|
82
|
+
private activeIndex;
|
|
83
|
+
constructor(options: RovingFocusOptions);
|
|
84
|
+
/**
|
|
85
|
+
* Apply `tabindex` across the items so exactly one is tabbable.
|
|
86
|
+
*
|
|
87
|
+
* Call from the host's `updated()`. Vital for a rebuilt DOM: if the active
|
|
88
|
+
* item disappears, something must still be tabbable or the whole widget drops
|
|
89
|
+
* out of the tab order and can never be entered again — the failure the audit
|
|
90
|
+
* found in `mp-treeview` (collapse the focused node's ancestor and the tree
|
|
91
|
+
* becomes unreachable) and in `bs-rating` (no value set, so no star is
|
|
92
|
+
* tabbable).
|
|
93
|
+
*/
|
|
94
|
+
sync(): void;
|
|
95
|
+
/** Index of the current tab stop. */
|
|
96
|
+
get index(): number;
|
|
97
|
+
get activeItem(): HTMLElement | null;
|
|
98
|
+
/**
|
|
99
|
+
* Handle a keydown. Returns true when the key was consumed, so the caller can
|
|
100
|
+
* `preventDefault()` and stop there.
|
|
101
|
+
*
|
|
102
|
+
* Only acts when the event originated on one of the items — a key typed into
|
|
103
|
+
* an input nested inside an item must reach the input, not be reinterpreted
|
|
104
|
+
* as navigation. That guard is the bug the audit found in `mp-treeview`,
|
|
105
|
+
* where a consumer's node template could not be typed into at all.
|
|
106
|
+
*/
|
|
107
|
+
onKeydown(event: KeyboardEvent): boolean;
|
|
108
|
+
/** Move the tab stop to `index` and focus it. Returns false if it could not move. */
|
|
109
|
+
moveTo(index: number): boolean;
|
|
110
|
+
/** Point the tab stop at a specific element, without focusing it. */
|
|
111
|
+
setActiveItem(item: HTMLElement): void;
|
|
112
|
+
private step;
|
|
113
|
+
/** First enabled index, falling back to 0 so a fully-disabled set still has a tab stop. */
|
|
114
|
+
private firstEnabledIndex;
|
|
115
|
+
private lastEnabledIndex;
|
|
116
|
+
private isDisabled;
|
|
117
|
+
private rtl;
|
|
118
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Assert that every token of an IDREF attribute resolves in the tree the
|
|
3
|
+
* *browser* would search.
|
|
4
|
+
*
|
|
5
|
+
* The bug this catches, and why it needs a helper rather than a convention: an
|
|
6
|
+
* IDREF attribute resolves only within the containing tree of the element that
|
|
7
|
+
* **holds** it — its shadow root if it is inside one, otherwise the document. It
|
|
8
|
+
* never crosses a shadow boundary in either direction, and a dangling reference
|
|
9
|
+
* fails completely silently: no console warning, no visual change, and the
|
|
10
|
+
* attribute sits there in devtools looking correct.
|
|
11
|
+
*
|
|
12
|
+
* Three tests in this repo were green while asserting relationships that resolve
|
|
13
|
+
* to nothing, because they checked the attribute's *string value*
|
|
14
|
+
* (`expect(el.getAttribute('aria-controls')).toBe('panel-1')`) or resolved the id
|
|
15
|
+
* in the wrong root (`shadowRoot.querySelector('#' + id)` for an attribute held
|
|
16
|
+
* on the host). Both pass regardless of whether a screen reader can follow the
|
|
17
|
+
* reference.
|
|
18
|
+
*
|
|
19
|
+
* Applied across the ~26 IDREF sites in the library this fails on exactly the
|
|
20
|
+
* six known-dead ones: `mp-time-list`'s `aria-activedescendant`, `mp-ribbon` ↔
|
|
21
|
+
* `mp-ribbon-tab` in both directions, `mp-checkbox`'s two forwarded attributes,
|
|
22
|
+
* and `mp-dropdown-menu`'s `label-id`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function expectIdrefResolves(el: Element, attribute: string): void;
|
|
25
|
+
/** Assert that an IDREF attribute is absent, or present and fully resolvable. */
|
|
26
|
+
export declare function expectNoDanglingIdref(el: Element, attribute: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Walk a subtree (crossing shadow roots) and assert that no IDREF attribute
|
|
29
|
+
* anywhere dangles. Use as a blanket regression net in a component's ARIA spec.
|
|
30
|
+
*/
|
|
31
|
+
export declare function expectNoDanglingIdrefsIn(root: Element | ShadowRoot): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { expectIdrefResolves, expectNoDanglingIdref, expectNoDanglingIdrefsIn } from './expect-idref-resolves';
|
package/accordion/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { unsafeCSS as
|
|
2
|
-
const h =
|
|
1
|
+
import { unsafeCSS as b, LitElement as d, adoptStyles as l, html as s, nothing as c, css as u } from "lit";
|
|
2
|
+
const h = b(`.accordion {
|
|
3
3
|
--bs-accordion-color: var(--bs-body-color);
|
|
4
4
|
--bs-accordion-bg: var(--bs-body-bg);
|
|
5
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;
|
|
@@ -171,48 +171,29 @@ const h = d(`.accordion {
|
|
|
171
171
|
box-sizing: border-box;
|
|
172
172
|
}
|
|
173
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
174
|
.accordion-content {
|
|
207
175
|
padding: var(--bs-accordion-body-padding-y) var(--bs-accordion-body-padding-x);
|
|
208
176
|
}
|
|
209
177
|
|
|
210
|
-
.accordion-
|
|
178
|
+
summary.accordion-button {
|
|
211
179
|
cursor: pointer;
|
|
212
180
|
user-select: none;
|
|
181
|
+
list-style: none;
|
|
182
|
+
line-height: normal;
|
|
183
|
+
}
|
|
184
|
+
summary.accordion-button::marker {
|
|
185
|
+
content: "";
|
|
186
|
+
}
|
|
187
|
+
summary.accordion-button::-webkit-details-marker {
|
|
188
|
+
display: none;
|
|
213
189
|
}
|
|
214
190
|
|
|
215
|
-
.accordion-button
|
|
191
|
+
summary.accordion-button[aria-disabled=true] {
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
opacity: 0.65;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
summary.accordion-button::after {
|
|
216
197
|
background-image: none;
|
|
217
198
|
background-color: currentColor;
|
|
218
199
|
mask-image: var(--bs-accordion-btn-icon);
|
|
@@ -223,40 +204,65 @@ const h = d(`.accordion {
|
|
|
223
204
|
-webkit-mask-size: var(--bs-accordion-btn-icon-width);
|
|
224
205
|
}
|
|
225
206
|
|
|
226
|
-
.accordion-button
|
|
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 {
|
|
207
|
+
details[open] > summary.accordion-button {
|
|
234
208
|
color: var(--bs-accordion-active-color);
|
|
235
209
|
background-color: var(--bs-accordion-active-bg);
|
|
210
|
+
box-shadow: inset 0 calc(-1 * var(--bs-accordion-border-width)) 0 var(--bs-accordion-border-color);
|
|
211
|
+
border-bottom-left-radius: 0;
|
|
212
|
+
border-bottom-right-radius: 0;
|
|
236
213
|
}
|
|
237
|
-
|
|
238
|
-
background-image:
|
|
214
|
+
details[open] > summary.accordion-button::after {
|
|
215
|
+
background-image: none;
|
|
216
|
+
mask-image: var(--bs-accordion-btn-active-icon);
|
|
217
|
+
-webkit-mask-image: var(--bs-accordion-btn-active-icon);
|
|
239
218
|
transform: var(--bs-accordion-btn-icon-transform);
|
|
240
219
|
}
|
|
241
220
|
|
|
242
|
-
.
|
|
221
|
+
summary.accordion-button:focus-visible {
|
|
243
222
|
z-index: 3;
|
|
244
223
|
outline: 0;
|
|
245
224
|
box-shadow: var(--bs-accordion-btn-focus-box-shadow);
|
|
246
225
|
}
|
|
247
226
|
|
|
248
|
-
:host(:not([highlight-active-tab])) .accordion-button
|
|
249
|
-
:host(:not([highlight-active-tab])) .acc-input:checked + .accordion-header > .accordion-button {
|
|
227
|
+
:host(:not([highlight-active-tab])) details[open] > summary.accordion-button {
|
|
250
228
|
background-color: unset;
|
|
251
229
|
color: inherit;
|
|
252
230
|
}
|
|
253
231
|
|
|
232
|
+
:host {
|
|
233
|
+
interpolate-size: allow-keywords;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
@supports (interpolate-size: allow-keywords) {
|
|
237
|
+
details.accordion-item::details-content {
|
|
238
|
+
block-size: 0;
|
|
239
|
+
overflow-y: clip;
|
|
240
|
+
transition: block-size 0.35s ease, content-visibility 0.35s allow-discrete;
|
|
241
|
+
}
|
|
242
|
+
details.accordion-item[open]::details-content {
|
|
243
|
+
block-size: auto;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
@supports (not (interpolate-size: allow-keywords)) and (selector(::details-content)) {
|
|
247
|
+
details.accordion-item::details-content {
|
|
248
|
+
display: grid;
|
|
249
|
+
grid-template-rows: 0fr;
|
|
250
|
+
transition: grid-template-rows 0.35s ease, content-visibility 0.35s allow-discrete;
|
|
251
|
+
}
|
|
252
|
+
details.accordion-item[open]::details-content {
|
|
253
|
+
grid-template-rows: 1fr;
|
|
254
|
+
}
|
|
255
|
+
details.accordion-item .accordion-content {
|
|
256
|
+
min-height: 0;
|
|
257
|
+
overflow-y: clip;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
254
260
|
@media (prefers-reduced-motion: reduce) {
|
|
255
|
-
.accordion-
|
|
261
|
+
details.accordion-item::details-content {
|
|
256
262
|
transition: none;
|
|
257
263
|
}
|
|
258
264
|
}`);
|
|
259
|
-
class
|
|
265
|
+
class n extends d {
|
|
260
266
|
static {
|
|
261
267
|
this.styles = [h];
|
|
262
268
|
}
|
|
@@ -277,11 +283,8 @@ class s extends n {
|
|
|
277
283
|
get #a() {
|
|
278
284
|
return this.hasAttribute("multi") && this.getAttribute("multi") !== "false";
|
|
279
285
|
}
|
|
280
|
-
get #p() {
|
|
281
|
-
return this.hasAttribute("highlight-active-tab");
|
|
282
|
-
}
|
|
283
286
|
/** Tab count for chrome generation, when no light DOM is present yet. */
|
|
284
|
-
get #
|
|
287
|
+
get #n() {
|
|
285
288
|
const o = Number(this.getAttribute("tab-count"));
|
|
286
289
|
return Number.isFinite(o) && o > 0 ? Math.floor(o) : 0;
|
|
287
290
|
}
|
|
@@ -289,7 +292,7 @@ class s extends n {
|
|
|
289
292
|
#o = [];
|
|
290
293
|
#t = null;
|
|
291
294
|
connectedCallback() {
|
|
292
|
-
this.shadowRoot && this.#
|
|
295
|
+
this.shadowRoot && this.#d(), super.connectedCallback(), this.setAttribute("data-js", ""), this.parentElement?.closest("mp-accordion") ? this.setAttribute("data-nested", "") : this.removeAttribute("data-nested"), this.#t = new MutationObserver(() => this.#c()), this.#t.observe(this, { childList: !0 }), this.#c();
|
|
293
296
|
}
|
|
294
297
|
disconnectedCallback() {
|
|
295
298
|
this.#t?.disconnect(), this.#t = null, super.disconnectedCallback();
|
|
@@ -297,10 +300,10 @@ class s extends n {
|
|
|
297
300
|
createRenderRoot() {
|
|
298
301
|
const o = this.constructor;
|
|
299
302
|
let r;
|
|
300
|
-
return this.shadowRoot ? (this.shadowRoot.replaceChildren(), r = this.shadowRoot) : r = this.attachShadow(o.shadowRootOptions ?? { mode: "open" }),
|
|
303
|
+
return this.shadowRoot ? (this.shadowRoot.replaceChildren(), r = this.shadowRoot) : r = this.attachShadow(o.shadowRootOptions ?? { mode: "open" }), l(r, o.elementStyles ?? []), r.addEventListener("toggle", (t) => this.#l(t), { capture: !0 }), r;
|
|
301
304
|
}
|
|
302
|
-
attributeChangedCallback(o, r,
|
|
303
|
-
super.attributeChangedCallback(o, r,
|
|
305
|
+
attributeChangedCallback(o, r, t) {
|
|
306
|
+
super.attributeChangedCallback(o, r, t), r !== t && this.requestUpdate();
|
|
304
307
|
}
|
|
305
308
|
// ---------------------------------------------------------------- public
|
|
306
309
|
/** Indexes of the currently open tabs. */
|
|
@@ -323,22 +326,22 @@ class s extends n {
|
|
|
323
326
|
* collapses an entire branch in one call.
|
|
324
327
|
*/
|
|
325
328
|
closeAll(o = null) {
|
|
326
|
-
this.#o.forEach((r,
|
|
327
|
-
r.active && this.#r(
|
|
329
|
+
this.#o.forEach((r, t) => {
|
|
330
|
+
r.active && this.#r(t, !1, o);
|
|
328
331
|
});
|
|
329
332
|
}
|
|
330
333
|
// --------------------------------------------------------------- private
|
|
331
334
|
/**
|
|
332
|
-
* Mirror the server-rendered
|
|
335
|
+
* Mirror the server-rendered rows' UA-owned open state onto the light-DOM
|
|
333
336
|
* markers, so the client render opens exactly what the user left open.
|
|
334
337
|
*/
|
|
335
|
-
#
|
|
336
|
-
const o = this.shadowRoot?.querySelectorAll(".
|
|
338
|
+
#d() {
|
|
339
|
+
const o = this.shadowRoot?.querySelectorAll("details.accordion-item");
|
|
337
340
|
if (!o?.length) return;
|
|
338
|
-
const r = this.#
|
|
339
|
-
o.forEach((
|
|
340
|
-
const
|
|
341
|
-
|
|
341
|
+
const r = this.#i();
|
|
342
|
+
o.forEach((t, e) => {
|
|
343
|
+
const a = r[e];
|
|
344
|
+
a && (t.open ? a.setAttribute("is-active", "") : a.removeAttribute("is-active"));
|
|
342
345
|
});
|
|
343
346
|
}
|
|
344
347
|
/**
|
|
@@ -349,12 +352,12 @@ class s extends n {
|
|
|
349
352
|
* one level too deep to ever be slotted. `<mp-accordion-tab>` is only the
|
|
350
353
|
* vanilla convenience element; it tags itself.
|
|
351
354
|
*/
|
|
352
|
-
#
|
|
355
|
+
#i() {
|
|
353
356
|
return Array.from(this.children).filter(
|
|
354
357
|
(o) => o instanceof HTMLElement && o.hasAttribute("accordion-tab")
|
|
355
358
|
);
|
|
356
359
|
}
|
|
357
|
-
#
|
|
360
|
+
#b() {
|
|
358
361
|
return Array.from(this.children).filter(
|
|
359
362
|
(o) => o instanceof HTMLElement && o.hasAttribute("accordion-header")
|
|
360
363
|
);
|
|
@@ -365,48 +368,70 @@ class s extends n {
|
|
|
365
368
|
* wrappers stamp the same names server-side — where no script runs to do
|
|
366
369
|
* it — so the two never disagree.
|
|
367
370
|
*/
|
|
368
|
-
#
|
|
369
|
-
const o = this.#
|
|
370
|
-
o.forEach((
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
}), r.forEach((
|
|
374
|
-
const
|
|
375
|
-
|
|
371
|
+
#c() {
|
|
372
|
+
const o = this.#i(), r = this.#b();
|
|
373
|
+
o.forEach((e, a) => {
|
|
374
|
+
const i = `c${a}`;
|
|
375
|
+
e.getAttribute("slot") !== i && e.setAttribute("slot", i);
|
|
376
|
+
}), r.forEach((e, a) => {
|
|
377
|
+
const i = `h${a}`;
|
|
378
|
+
e.getAttribute("slot") !== i && e.setAttribute("slot", i);
|
|
376
379
|
}), Array.from(this.children).forEach(
|
|
377
|
-
(
|
|
380
|
+
(e) => this.#t?.observe(e, {
|
|
378
381
|
attributes: !0,
|
|
379
382
|
attributeFilter: ["is-active", "disabled", "accordion-tab", "accordion-header"]
|
|
380
383
|
})
|
|
381
384
|
);
|
|
382
|
-
const
|
|
383
|
-
this.#e = o, this.#o = o.map((
|
|
384
|
-
active:
|
|
385
|
-
disabled:
|
|
386
|
-
})),
|
|
387
|
-
!
|
|
385
|
+
const t = this.#o;
|
|
386
|
+
this.#e = o, this.#o = o.map((e) => ({
|
|
387
|
+
active: e.hasAttribute("is-active"),
|
|
388
|
+
disabled: e.hasAttribute("disabled")
|
|
389
|
+
})), t.length === this.#o.length && this.#o.forEach((e, a) => {
|
|
390
|
+
!e.active && t[a].active && this.#s(a, null);
|
|
388
391
|
}), this.requestUpdate();
|
|
389
392
|
}
|
|
393
|
+
/**
|
|
394
|
+
* The single notification channel for UA-driven state changes: user
|
|
395
|
+
* activation, `name` exclusivity closing a sibling, or anything else that
|
|
396
|
+
* flips `open`. Per spike 0.1a the event is async, coalesced and carries no
|
|
397
|
+
* usable delta — so it is treated purely as "something changed" and every
|
|
398
|
+
* row's `open` is re-read and diffed against the state.
|
|
399
|
+
*/
|
|
400
|
+
#l(o) {
|
|
401
|
+
const r = this.renderRoot?.querySelectorAll("details.accordion-item");
|
|
402
|
+
r && r.forEach((t, e) => {
|
|
403
|
+
const a = this.#o[e];
|
|
404
|
+
if (!(!a || t.open === a.active)) {
|
|
405
|
+
if (a.disabled) {
|
|
406
|
+
t.open = a.active;
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
this.#r(e, t.open, o);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
390
413
|
/**
|
|
391
414
|
* The single write path for tab state: updates the marker (the source of
|
|
392
415
|
* truth), enforces single-open, recursively collapses nested accordions on
|
|
393
|
-
* close, and announces every change that actually happened.
|
|
416
|
+
* close, and announces every change that actually happened. The render pass
|
|
417
|
+
* reconciles `?open` from the markers, which in engines with `name` support
|
|
418
|
+
* merely confirms what the UA already did.
|
|
394
419
|
*/
|
|
395
|
-
#r(o, r,
|
|
396
|
-
const
|
|
397
|
-
!
|
|
398
|
-
|
|
399
|
-
}), this.#u(o, r),
|
|
420
|
+
#r(o, r, t) {
|
|
421
|
+
const e = this.#o[o];
|
|
422
|
+
!e || e.disabled || e.active === r || (r && !this.#a && this.#o.forEach((a, i) => {
|
|
423
|
+
i !== o && a.active && this.#r(i, !1, t);
|
|
424
|
+
}), this.#u(o, r), e.active = r, r || this.#s(o, t), this.requestUpdate(), this.dispatchEvent(
|
|
400
425
|
new CustomEvent("mp-accordion-tab-toggle", {
|
|
401
|
-
detail: { index: o, active: r, originalEvent:
|
|
426
|
+
detail: { index: o, active: r, originalEvent: t },
|
|
402
427
|
bubbles: !0,
|
|
403
428
|
composed: !0
|
|
404
429
|
})
|
|
405
430
|
));
|
|
406
431
|
}
|
|
407
432
|
#u(o, r) {
|
|
408
|
-
const
|
|
409
|
-
|
|
433
|
+
const t = this.#e[o];
|
|
434
|
+
t && (r ? t.setAttribute("is-active", "") : t.removeAttribute("is-active"));
|
|
410
435
|
}
|
|
411
436
|
/**
|
|
412
437
|
* Collapse every accordion inside a closing tab. `querySelectorAll` reaches
|
|
@@ -415,112 +440,93 @@ class s extends n {
|
|
|
415
440
|
* never be left with hidden-but-open tabs.
|
|
416
441
|
*/
|
|
417
442
|
#s(o, r) {
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
443
|
+
const t = this.#e[o];
|
|
444
|
+
t && t.querySelectorAll("mp-accordion").forEach((e) => {
|
|
445
|
+
e instanceof n && e.closeAll(r);
|
|
421
446
|
});
|
|
422
447
|
}
|
|
448
|
+
/**
|
|
449
|
+
* Enter/Space activation is native to `<summary>`. This handler adds the
|
|
450
|
+
* APG accordion extras (Up/Down between headers, Home/End to the ends) and
|
|
451
|
+
* the disabled guard: `toggle` is not cancellable, but keydown IS — cancel
|
|
452
|
+
* it before the UA acts and a disabled tab is inert with no flash.
|
|
453
|
+
*/
|
|
423
454
|
#h(o, r) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
const
|
|
429
|
-
let
|
|
455
|
+
if (this.#o[o]?.disabled && (r.key === "Enter" || r.key === " ")) {
|
|
456
|
+
r.preventDefault();
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
const t = this.#o.length - 1;
|
|
460
|
+
let e = null;
|
|
430
461
|
switch (r.key) {
|
|
431
462
|
case "ArrowDown":
|
|
432
|
-
|
|
463
|
+
e = o === t ? 0 : o + 1;
|
|
433
464
|
break;
|
|
434
465
|
case "ArrowUp":
|
|
435
|
-
|
|
466
|
+
e = o === 0 ? t : o - 1;
|
|
436
467
|
break;
|
|
437
468
|
case "Home":
|
|
438
|
-
|
|
469
|
+
e = 0;
|
|
439
470
|
break;
|
|
440
471
|
case "End":
|
|
441
|
-
|
|
472
|
+
e = t;
|
|
442
473
|
break;
|
|
443
474
|
default:
|
|
444
475
|
return;
|
|
445
476
|
}
|
|
446
|
-
r.preventDefault(), this.shadowRoot?.querySelector(`#
|
|
477
|
+
r.preventDefault(), this.shadowRoot?.querySelector(`#h${e}`)?.focus();
|
|
478
|
+
}
|
|
479
|
+
/** A disabled summary must also ignore the pointer (pointer-events: none in CSS is the primary guard; this covers synthesized clicks). */
|
|
480
|
+
#m(o, r) {
|
|
481
|
+
this.#o[o]?.disabled && (r.preventDefault(), r.stopPropagation());
|
|
447
482
|
}
|
|
448
483
|
render() {
|
|
449
|
-
const o = this
|
|
450
|
-
{ length:
|
|
484
|
+
const o = this.#o.length || this.#n, r = Array.from(
|
|
485
|
+
{ length: o },
|
|
451
486
|
(t, e) => this.#o[e] ?? { active: !1, disabled: !1 }
|
|
452
487
|
);
|
|
453
|
-
return
|
|
488
|
+
return s`
|
|
454
489
|
<div class="accordion-root" part="accordion">
|
|
455
|
-
${
|
|
456
|
-
(t, e) => o ? this.#m(t, e) : this.#g(t, e)
|
|
457
|
-
)}
|
|
490
|
+
${r.map((t, e) => this.#v(t, e))}
|
|
458
491
|
<slot></slot>
|
|
459
492
|
</div>
|
|
460
493
|
`;
|
|
461
494
|
}
|
|
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
495
|
/**
|
|
504
|
-
*
|
|
505
|
-
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* `
|
|
496
|
+
* One template for both tiers. `name` is constant: `<details name>` groups
|
|
497
|
+
* per node tree (spike 0.1a), and every accordion owns its own shadow root,
|
|
498
|
+
* so instances can never capture each other's exclusivity. The summary
|
|
499
|
+
* keeps a static `collapsed` class so Bootstrap's own
|
|
500
|
+
* `.accordion-button:not(.collapsed)` rules never fire — the open state is
|
|
501
|
+
* styled from `details[open]` (spike 0.1b).
|
|
509
502
|
*/
|
|
510
|
-
#
|
|
511
|
-
return
|
|
512
|
-
<
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
503
|
+
#v(o, r) {
|
|
504
|
+
return s`
|
|
505
|
+
<details
|
|
506
|
+
class="accordion-item"
|
|
507
|
+
name=${this.#a ? c : "acc"}
|
|
508
|
+
?open=${o.active}
|
|
509
|
+
part="item">
|
|
510
|
+
<summary
|
|
511
|
+
id="h${r}"
|
|
512
|
+
class="accordion-button collapsed"
|
|
513
|
+
aria-controls="c${r}"
|
|
514
|
+
aria-disabled=${o.disabled ? "true" : c}
|
|
515
|
+
tabindex=${o.disabled ? "-1" : c}
|
|
516
|
+
part="button"
|
|
517
|
+
@click=${(t) => this.#m(r, t)}
|
|
518
|
+
@keydown=${(t) => this.#h(r, t)}>
|
|
519
|
+
<slot name="h${r}"></slot>
|
|
520
|
+
</summary>
|
|
521
|
+
<div class="accordion-content" id="c${r}" role="region" aria-labelledby="h${r}" part="content">
|
|
522
|
+
<slot name="c${r}"></slot>
|
|
517
523
|
</div>
|
|
518
|
-
</
|
|
524
|
+
</details>
|
|
519
525
|
`;
|
|
520
526
|
}
|
|
521
527
|
}
|
|
522
|
-
typeof customElements < "u" && !customElements.get("mp-accordion") && customElements.define("mp-accordion",
|
|
523
|
-
class
|
|
528
|
+
typeof customElements < "u" && !customElements.get("mp-accordion") && customElements.define("mp-accordion", n);
|
|
529
|
+
class m extends d {
|
|
524
530
|
static {
|
|
525
531
|
this.styles = u`
|
|
526
532
|
:host {
|
|
@@ -532,12 +538,12 @@ class v extends n {
|
|
|
532
538
|
super.connectedCallback(), this.setAttribute("accordion-tab", "");
|
|
533
539
|
}
|
|
534
540
|
render() {
|
|
535
|
-
return
|
|
541
|
+
return s`<slot></slot>`;
|
|
536
542
|
}
|
|
537
543
|
}
|
|
538
|
-
typeof customElements < "u" && !customElements.get("mp-accordion-tab") && customElements.define("mp-accordion-tab",
|
|
544
|
+
typeof customElements < "u" && !customElements.get("mp-accordion-tab") && customElements.define("mp-accordion-tab", m);
|
|
539
545
|
export {
|
|
540
|
-
|
|
541
|
-
|
|
546
|
+
n as MpAccordion,
|
|
547
|
+
m as MpAccordionTab,
|
|
542
548
|
h as accordionStyles
|
|
543
549
|
};
|