@mintplayer/web-components 2.2.0 → 2.3.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.
Files changed (107) hide show
  1. package/a11y/index.mjs +26 -2
  2. package/a11y/src/dismiss-stack.d.ts +25 -0
  3. package/a11y/src/error-text.d.ts +41 -0
  4. package/a11y/src/focus-restore.d.ts +116 -0
  5. package/a11y/src/focus-trap.d.ts +69 -0
  6. package/a11y/src/form-associated.d.ts +48 -0
  7. package/a11y/src/host-aria.d.ts +154 -0
  8. package/a11y/src/index.d.ts +16 -0
  9. package/a11y/src/inert-regions.d.ts +52 -0
  10. package/a11y/src/live-announcer.d.ts +8 -0
  11. package/a11y/src/roving-focus.d.ts +118 -0
  12. package/a11y/src/testing/expect-idref-resolves.d.ts +31 -0
  13. package/a11y/src/testing/index.d.ts +1 -0
  14. package/accordion/index.mjs +180 -174
  15. package/accordion/src/components/mp-accordion.d.ts +18 -13
  16. package/calendar/index.mjs +1 -1
  17. package/calendar/src/mp-calendar.element.d.ts +2 -0
  18. package/carousel/index.mjs +211 -164
  19. package/carousel/src/components/mp-carousel.d.ts +1 -0
  20. package/checkbox/index.mjs +1 -1
  21. package/checkbox/src/components/mp-checkbox.d.ts +59 -1
  22. package/chunks/focus-restore-DxuP1Oe2.mjs +94 -0
  23. package/chunks/focus-trap-DTOLJ5bb.mjs +121 -0
  24. package/chunks/form-associated-axmc5sY0.mjs +58 -0
  25. package/chunks/host-aria-WSGs7SPQ.mjs +152 -0
  26. package/chunks/inert-regions-DXCnn1LN.mjs +48 -0
  27. package/chunks/invalid-feedback.styles-he0JYrJm.mjs +11 -0
  28. package/chunks/{live-announcer-CZDTKulf.mjs → live-announcer-Bi0orG4n.mjs} +9 -9
  29. package/chunks/{mp-calendar.element-UC68iDbi.mjs → mp-calendar.element-u6uS31_j.mjs} +136 -105
  30. package/chunks/mp-checkbox-Ph2mMRGz.mjs +312 -0
  31. package/chunks/{mp-datatable-Bfw0KGkV.mjs → mp-datatable-BwTlh9A_.mjs} +265 -103
  32. package/chunks/{mp-pagination-BGxsawFL.mjs → mp-pagination-Dea75mD4.mjs} +25 -22
  33. package/chunks/mp-radio-BjW1HNSc.mjs +300 -0
  34. package/chunks/{mp-select-BDS1-YGn.mjs → mp-select-Ctu-v1-p.mjs} +163 -40
  35. package/chunks/{mp-splitter-C8cGCmac.mjs → mp-splitter-LszuRDbR.mjs} +53 -46
  36. package/chunks/{mp-tab-page-D1b4x-y2.mjs → mp-tab-page-CaCzX1ym.mjs} +46 -45
  37. package/chunks/{mp-timepicker.element-BwEiwX92.mjs → mp-timepicker.element-Bz393NDQ.mjs} +93 -86
  38. package/chunks/{mp-toggle-button-dLZNDUVz.mjs → mp-toggle-button-Kz6sIgBJ.mjs} +131 -37
  39. package/chunks/{mp-treeview-C48F63xb.mjs → mp-treeview-tkWu28iF.mjs} +67 -43
  40. package/chunks/overlay-controller-DPt13i8p.mjs +314 -0
  41. package/chunks/roving-focus-CrL9982a.mjs +129 -0
  42. package/code-snippet/index.mjs +21 -13
  43. package/code-snippet/src/mp-code-snippet.element.d.ts +6 -0
  44. package/datatable/index.mjs +1 -1
  45. package/datatable/src/components/mp-datatable.d.ts +50 -0
  46. package/datatable/src/types/index.d.ts +2 -0
  47. package/datatable/src/types/labels.d.ts +30 -0
  48. package/datepicker/index.mjs +45 -22
  49. package/datepicker/src/mp-datepicker.element.d.ts +30 -0
  50. package/datetime-picker/index.mjs +15 -9
  51. package/dock/index.mjs +365 -209
  52. package/dock/src/components/mint-dock-manager.element.d.ts +63 -3
  53. package/dropdown-menu/index.mjs +135 -90
  54. package/dropdown-menu/src/components/mp-dropdown-menu.d.ts +12 -3
  55. package/file-manager/index.mjs +279 -214
  56. package/file-manager/src/components/mp-file-manager.d.ts +22 -0
  57. package/file-manager/src/types/messages.d.ts +9 -0
  58. package/multi-range/index.mjs +26 -10
  59. package/multi-range/src/mint-multi-range.element.d.ts +7 -0
  60. package/navbar/index.mjs +53 -39
  61. package/navbar/src/components/mp-navbar.d.ts +1 -0
  62. package/otp-input/index.mjs +82 -48
  63. package/otp-input/src/mint-otp-input.element.d.ts +31 -3
  64. package/overlay/index.mjs +2 -258
  65. package/overlay/src/overlay-controller.d.ts +64 -4
  66. package/package.json +9 -1
  67. package/pagination/index.mjs +1 -1
  68. package/query-builder/index.mjs +117 -87
  69. package/query-builder/src/model/messages.d.ts +9 -0
  70. package/radio/index.mjs +2 -160
  71. package/radio/src/components/mp-radio.d.ts +58 -3
  72. package/radio-group/index.d.ts +1 -0
  73. package/radio-group/index.mjs +145 -0
  74. package/radio-group/src/components/mp-radio-group.d.ts +52 -0
  75. package/radio-group/src/index.d.ts +1 -0
  76. package/radio-group/src/styles/radio-group.styles.d.ts +2 -0
  77. package/ribbon/index.mjs +316 -304
  78. package/ribbon/src/mp-ribbon.element.d.ts +16 -0
  79. package/scheduler/index.mjs +219 -132
  80. package/scheduler/src/components/mp-scheduler.d.ts +3 -0
  81. package/scheduler/src/views/base-view.d.ts +23 -0
  82. package/select/index.mjs +1 -1
  83. package/select/src/components/mp-select.d.ts +60 -3
  84. package/shell/index.mjs +142 -31
  85. package/shell/src/components/mp-shell.d.ts +1 -0
  86. package/signature-pad/index.d.ts +1 -0
  87. package/signature-pad/index.mjs +230 -0
  88. package/signature-pad/src/index.d.ts +2 -0
  89. package/signature-pad/src/mp-signature-pad.element.d.ts +143 -0
  90. package/signature-pad/src/mp-signature-pad.element.template.d.ts +2 -0
  91. package/signature-pad/src/types/signature.d.ts +12 -0
  92. package/splitter/index.mjs +1 -1
  93. package/splitter/src/components/mp-splitter.d.ts +7 -0
  94. package/tab-control/index.mjs +1 -1
  95. package/tile-manager/index.mjs +110 -93
  96. package/timeline/index.mjs +138 -54
  97. package/timeline/src/components/mp-timeline.d.ts +15 -0
  98. package/timepicker/index.mjs +1 -1
  99. package/timepicker/src/mp-time-list.element.d.ts +13 -4
  100. package/timepicker/src/mp-timepicker.element.d.ts +29 -0
  101. package/toggle-button/index.mjs +1 -1
  102. package/toggle-button/src/components/mp-toggle-button.d.ts +32 -1
  103. package/tree-select/index.mjs +233 -121
  104. package/tree-select/src/components/mp-tree-select.d.ts +37 -0
  105. package/treeview/index.mjs +1 -1
  106. package/treeview/src/components/mp-treeview.d.ts +10 -1
  107. package/chunks/mp-checkbox-BokLL7BS.mjs +0 -211
package/a11y/index.mjs CHANGED
@@ -1,4 +1,28 @@
1
- import { L as e } from "../chunks/live-announcer-CZDTKulf.mjs";
1
+ import { L as a } from "../chunks/live-announcer-Bi0orG4n.mjs";
2
+ import { F as r, a as t, d as n } from "../chunks/focus-restore-DxuP1Oe2.mjs";
3
+ import { i as c } from "../chunks/inert-regions-DXCnn1LN.mjs";
4
+ import { F as i, c as m, a as p, d as x } from "../chunks/focus-trap-DTOLJ5bb.mjs";
5
+ import { R as F, f as b, l as u, n as E } from "../chunks/roving-focus-CrL9982a.mjs";
6
+ import { H as A, s as C, a as I } from "../chunks/host-aria-WSGs7SPQ.mjs";
7
+ import { F as v, e as g, a as H } from "../chunks/form-associated-axmc5sY0.mjs";
2
8
  export {
3
- e as LiveAnnouncerController
9
+ r as FocusRestore,
10
+ t as FocusRestoreController,
11
+ i as FocusTrap,
12
+ v as FormAssociatedMixin,
13
+ A as HostAriaController,
14
+ a as LiveAnnouncerController,
15
+ F as RovingFocus,
16
+ m as collectTabbables,
17
+ p as containsComposed,
18
+ n as deepActiveElement,
19
+ x as dismissStack,
20
+ g as errorFeedback,
21
+ H as errorFeedbackElements,
22
+ b as firstEnabledIndex,
23
+ c as inertRegions,
24
+ u as lastEnabledIndex,
25
+ E as nextEnabledIndex,
26
+ C as sharedInternals,
27
+ I as supportsAriaElementReferences
4
28
  };
@@ -0,0 +1,25 @@
1
+ /** Allocate a frame on top of the stack. Pair every push with a release. */
2
+ export declare function push(description?: string): symbol;
3
+ /**
4
+ * Remove `token`. Releasing a non-top token is allowed and intentional — it is
5
+ * how an inner layer closes itself programmatically without an Escape press
6
+ * (a popover dismissed by clicking its trigger again).
7
+ */
8
+ export declare function release(token: symbol): void;
9
+ /** True while `token` is the top-most frame. */
10
+ export declare function isTop(token: symbol): boolean;
11
+ /** Top-most token, or null when nothing is open. */
12
+ export declare function peek(): symbol | null;
13
+ /** Number of open frames. Exposed for tests and diagnostics. */
14
+ export declare function depth(): number;
15
+ /** Drop every frame. Tests only — never call this from component code. */
16
+ export declare function resetForTesting(): void;
17
+ /** Namespaced access, for call sites that prefer one import. */
18
+ export declare const dismissStack: {
19
+ push: typeof push;
20
+ release: typeof release;
21
+ isTop: typeof isTop;
22
+ peek: typeof peek;
23
+ depth: typeof depth;
24
+ resetForTesting: typeof resetForTesting;
25
+ };
@@ -0,0 +1,41 @@
1
+ import { nothing, TemplateResult } from 'lit';
2
+ /** What a render branch needs in order to expose an `error-text` message. */
3
+ export interface ErrorFeedback {
4
+ /**
5
+ * Value for BOTH `aria-errormessage` and `aria-describedby` on the
6
+ * role-bearing control, or `nothing` when there is no message to point at.
7
+ */
8
+ readonly id: string | typeof nothing;
9
+ /** The message node, or `nothing`. Render it after the control. */
10
+ readonly node: TemplateResult | typeof nothing;
11
+ }
12
+ /**
13
+ * The `error-text` channel: a validation message a form WC renders inside its
14
+ * **own** shadow root, so that a control whose role lives behind that boundary
15
+ * can still be described by one. A consumer cannot do this from outside — an
16
+ * IDREF does not cross the boundary — so the message has to come in as text
17
+ * (`error-text`) and be wired up in here.
18
+ *
19
+ * Shared rather than copied because the contract has two ways to be quietly
20
+ * wrong, across five controls and seven render branches:
21
+ *
22
+ * - `aria-errormessage` is defined **only** while `aria-invalid="true"`. On a
23
+ * valid control it is not merely redundant, it is invalid markup that some AT
24
+ * announces anyway — hence the `invalid` argument, and hence no message node
25
+ * at all when the control is valid.
26
+ * - Support for `aria-errormessage` is uneven, so `aria-describedby` points at
27
+ * the same node as the fallback. Both references therefore appear and vanish
28
+ * together, which is what returning one `id` for both guarantees.
29
+ */
30
+ export declare function errorFeedback(id: string, text: string | null, invalid: boolean): ErrorFeedback;
31
+ /**
32
+ * The rendered message nodes, to hand to `HostAriaController`'s
33
+ * `describedByExtras`.
34
+ *
35
+ * The `aria-describedby` attribute written by `errorFeedback` survives only
36
+ * where the browser has no ARIA element references. Where it does have them,
37
+ * assigning `ariaDescribedByElements` — which the controller does after every
38
+ * render — removes that attribute outright, so the in-shadow description has to
39
+ * travel through the same channel as the consumer's. See `describedByExtras`.
40
+ */
41
+ export declare function errorFeedbackElements(root: ParentNode | null | undefined): HTMLElement[];
@@ -0,0 +1,116 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ /**
3
+ * Where focus ended up after `restore()`. Callers rarely branch on this; tests do.
4
+ *
5
+ * - `unchanged` — nothing was captured, so nothing moved (focus was outside the root)
6
+ * - `same` — the captured node survived the rebuild and holds focus again
7
+ * - `neighbour` — the captured node is gone; the item at the same index has focus
8
+ * - `container` — nothing restorable survived; the container holds focus
9
+ * - `none` — no root, or nothing focusable at all
10
+ */
11
+ export type FocusRestoreOutcome = 'unchanged' | 'same' | 'neighbour' | 'container' | 'none';
12
+ export interface FocusRestoreOptions {
13
+ /** Selector matching every restorable node, in document order. */
14
+ selector: string;
15
+ /**
16
+ * Stable identity that survives the rebuild. Defaults to
17
+ * `el.id || el.dataset.focusKey`. Return null to exclude a node.
18
+ */
19
+ keyOf?: (el: HTMLElement) => string | null;
20
+ /**
21
+ * Focusable last resort when no candidate survives. `tabindex="-1"` is
22
+ * enough, and is applied automatically if absent. Defaults to the root's
23
+ * first element child.
24
+ */
25
+ container?: () => HTMLElement | null;
26
+ /** Human-readable name of a node, used only in the fallback announcement. */
27
+ nameOf?: (el: HTMLElement) => string;
28
+ /**
29
+ * Wire to `LiveAnnouncerController.announce`. Called **only** on the
30
+ * fallback paths — never when the captured node survived, because an
31
+ * announcement on every keystroke trains users to tune the region out.
32
+ */
33
+ announce?: (message: string) => void;
34
+ /** Default true — a DOM rebuild is not a navigation and must not scroll. */
35
+ preventScroll?: boolean;
36
+ }
37
+ /**
38
+ * Resolve the truly focused element through any number of nested shadow roots.
39
+ * `document.activeElement` stops at the outermost custom element, so a button
40
+ * inside a nested web component's shadow root is invisible without this.
41
+ */
42
+ export declare function deepActiveElement(from?: Document | ShadowRoot): Element | null;
43
+ /**
44
+ * Keeps keyboard focus continuous across an imperative DOM rebuild.
45
+ *
46
+ * Components that render by clearing a container (`innerHTML = ''`,
47
+ * `replaceChildren()`) destroy the element that currently has focus, which
48
+ * drops focus to `<body>` — the user loses their place in the page entirely
49
+ * and their next keystroke goes nowhere. `capture()` before the rebuild and
50
+ * `restore()` after re-focuses the same *logical* item, identified by a stable
51
+ * key rather than by DOM identity or index.
52
+ *
53
+ * Deliberately **not** a Lit `ReactiveController` at its core, unlike
54
+ * `LiveAnnouncerController`: three of the four call sites rebuild from plain
55
+ * non-Lit classes (a scheduler view has no host reference), so the core is a
56
+ * bare object and `FocusRestoreController` is thin sugar over it.
57
+ *
58
+ * Three properties are load-bearing and are the reason this exists as a shared
59
+ * primitive rather than a snippet:
60
+ *
61
+ * 1. **Capture is scoped.** It records nothing unless focus is already inside
62
+ * the root. Without that test, a rebuild triggered by an unrelated data
63
+ * change would *steal* focus from elsewhere on the page — worse than the
64
+ * bug being fixed.
65
+ * 2. **Restore is synchronous.** After `replaceChildren()` the new nodes are
66
+ * already focusable; deferring to `requestAnimationFrame` leaves a frame in
67
+ * which focus genuinely sits on `<body>`. The one case that needs deferral
68
+ * — a nested custom element that has not upgraded yet — gets a single
69
+ * bounded `queueMicrotask` retry, never a loop.
70
+ * 3. **Announcements only on fallback.** Surviving the rebuild is the normal
71
+ * case and must be silent.
72
+ *
73
+ * This is a safety net, not a licence: preferring to reposition existing nodes
74
+ * over destroying and recreating them is still the better fix where possible.
75
+ */
76
+ export declare class FocusRestore {
77
+ private readonly root;
78
+ private readonly options;
79
+ private snapshot;
80
+ private retried;
81
+ constructor(root: () => ShadowRoot | HTMLElement | null, options: FocusRestoreOptions);
82
+ /** Snapshot the focused item's key and index. No-op unless focus is inside the root. */
83
+ capture(): void;
84
+ /** Re-focus after the rebuild. Safe to call with nothing captured. */
85
+ restore(): FocusRestoreOutcome;
86
+ /** `capture()` → `rebuild()` → `restore()`. The shape most call sites want. */
87
+ around<T>(rebuild: () => T): T;
88
+ private candidates;
89
+ private resolveKey;
90
+ /**
91
+ * The focused element within `root`, or null when focus is elsewhere.
92
+ *
93
+ * For a ShadowRoot this is exactly `activeElement`, which is null unless
94
+ * focus is inside that root — both the cheap check and the correctness
95
+ * guarantee. A plain element root has no such property, so fall back to a
96
+ * containment test against the deep active element.
97
+ */
98
+ private activeInsideRoot;
99
+ private tryFocus;
100
+ }
101
+ /**
102
+ * Lit sugar for hosts whose rebuild happens inside Lit's own update cycle
103
+ * (a `lit-html` re-render rather than a manual `innerHTML` wipe). Captures
104
+ * before Lit commits DOM and restores immediately after, so no
105
+ * `requestAnimationFrame` is involved.
106
+ *
107
+ * Composes with `LiveAnnouncerController` by construction — pass
108
+ * `announce: (m) => this.liveAnnouncer.announce(m)` in the options. Neither
109
+ * class imports the other.
110
+ */
111
+ export declare class FocusRestoreController implements ReactiveController {
112
+ private readonly inner;
113
+ constructor(host: ReactiveControllerHost, inner: FocusRestore);
114
+ hostUpdate(): void;
115
+ hostUpdated(): void;
116
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Where focus goes when a trap activates. `'none'` means the caller manages it.
3
+ * The callback form exists because dialog content is usually rendered lazily —
4
+ * a date picker's "selected date cell" does not exist until the popup renders,
5
+ * so a static element reference captured at construction would always be stale.
6
+ * Resolved at activation time; a null return degrades to `'first'`.
7
+ */
8
+ export type InitialFocusTarget = HTMLElement | (() => HTMLElement | null) | 'first' | 'self' | 'none';
9
+ export interface FocusTrapOptions {
10
+ /** Default `'first'`. */
11
+ initialFocus?: InitialFocusTarget;
12
+ /** Return focus to whatever had it at activation. Default true. */
13
+ returnFocus?: boolean;
14
+ /**
15
+ * Consulted on every Tab. When it returns false the trap lets Tab through
16
+ * untouched — used to gate a nested trap on being the top dismiss frame, so
17
+ * an inner trap does not fight its parent's.
18
+ */
19
+ enabled?: () => boolean;
20
+ }
21
+ /**
22
+ * Contains Tab and Shift+Tab within a region, moves focus into it on activation
23
+ * and returns focus on deactivation.
24
+ *
25
+ * The web-component layer had no equivalent of Angular's
26
+ * `BsOverlayFocusDirective`, and the consequence was blunt: `grep` for `Tab`
27
+ * across every web component matched only comments, so six popups marked
28
+ * `role="dialog"` opened with focus still on the trigger and Tab walked
29
+ * straight out the far side while the dialog stayed visible.
30
+ *
31
+ * Deliberately not built on `@angular/cdk/a11y`: this layer is
32
+ * framework-agnostic. That costs a tabbable-collection walk, which is the bulk
33
+ * of the file.
34
+ *
35
+ * **Background `inert` / `aria-hidden` is intentionally not handled here.** A
36
+ * trap cannot know whether its region is a modal dialog or a menu, and
37
+ * `aria-modal="true"` on a non-modal popup hides the rest of the page from
38
+ * assistive tech while it stays visible and clickable to everyone else. That
39
+ * decision belongs to the consuming component (a modal hides app-root; a
40
+ * popover does not) — see `inertRegions` for the mechanism.
41
+ */
42
+ export declare class FocusTrap {
43
+ private readonly region;
44
+ private active;
45
+ private restoreTo;
46
+ private readonly options;
47
+ constructor(region: () => HTMLElement | null, options?: FocusTrapOptions);
48
+ get isActive(): boolean;
49
+ activate(): void;
50
+ deactivate(): void;
51
+ private onKeyDown;
52
+ }
53
+ /** True when `descendant` is inside `root`, crossing shadow and slot boundaries. */
54
+ export declare function containsComposed(root: Element, descendant: Node): boolean;
55
+ /**
56
+ * Tabbable elements inside `root`, in tab order, descending into shadow roots
57
+ * and following slots to the light-DOM content actually rendered there.
58
+ *
59
+ * A plain `querySelectorAll` inside one root misses slotted consumer content
60
+ * entirely, which for this library is the common case — a dialog's contents are
61
+ * almost always projected in.
62
+ *
63
+ * Visibility is deliberately **not** checked via layout (`getClientRects`),
64
+ * because jsdom does not lay elements out and every element would be rejected
65
+ * under test. `display: none` / `visibility: hidden` subtrees are excluded by
66
+ * inline style and by the `hidden` attribute, which covers the cases this
67
+ * library actually produces; real browsers agree for anything visible.
68
+ */
69
+ export declare function collectTabbables(root: Element | ShadowRoot): HTMLElement[];
@@ -0,0 +1,48 @@
1
+ type Constructor<T = object> = new (...args: any[]) => T;
2
+ /**
3
+ * The protocol a form-associated host implements on top of the mixin: the
4
+ * mixin owns the ElementInternals plumbing; the host owns its value shape.
5
+ * (Structurally typed — the mixin cannot require it in its base constraint
6
+ * without breaking the TS mixin pattern, so implement it on the class.)
7
+ */
8
+ export interface FormAssociatedHost {
9
+ /** Current submission value (null = submit nothing). */
10
+ formValue(): string | FormData | File | null;
11
+ /** Reset to the markup-declared default (formResetCallback). */
12
+ formReset(): void;
13
+ /** Restore a value the browser saved (bfcache / autofill), default = adopt it. */
14
+ formRestore?(state: string | FormData | File | null): void;
15
+ /**
16
+ * The focusable in-shadow control validity UI anchors to. Every choice
17
+ * control already sets delegatesFocus, so this is its real input.
18
+ */
19
+ formValidityAnchor?(): HTMLElement | null;
20
+ }
21
+ export interface FormAssociatedElement {
22
+ readonly internals: ElementInternals | null;
23
+ /** Author-or-form-owner disabled — the only safe read (spike 0.3a). */
24
+ readonly effectiveDisabled: boolean;
25
+ syncFormValue(): void;
26
+ setFormValidity(flags: ValidityStateFlags, message?: string): void;
27
+ }
28
+ /**
29
+ * Form association (FACE) for the WC form controls — decision D5.
30
+ *
31
+ * Shares `attachInternals()` with `HostAriaController` through
32
+ * `sharedInternals` (the call throws if made twice). Degrades to a no-op
33
+ * where ElementInternals is missing (jsdom): the control still works, it
34
+ * just does not submit.
35
+ *
36
+ * Disabled state carries spike 0.3a's mandatory design:
37
+ * - The UA writes NO attribute when a `<fieldset disabled>` disables the
38
+ * element, so the attribute alone is not a usable source of truth.
39
+ * - `formDisabledCallback` reports the PLATFORM's effective state (own
40
+ * attribute OR any ancestor fieldset) and its order relative to
41
+ * attributeChangedCallback is engine-dependent — so the mixin stores the
42
+ * callback value verbatim and `effectiveDisabled` ORs it with the author
43
+ * attribute. Order-independent and idempotent by construction; a property
44
+ * write can therefore never silently defeat a disabled fieldset
45
+ * (0.3a finding 4 — Angular's setDisabledState is exactly such a writer).
46
+ */
47
+ export declare function FormAssociatedMixin<TBase extends Constructor<HTMLElement>>(Base: TBase): TBase & Constructor<FormAssociatedElement>;
48
+ export {};
@@ -0,0 +1,154 @@
1
+ export declare function sharedInternals(host: HTMLElement): ElementInternals | null;
2
+ /**
3
+ * True when the browser supports assigning cross-root ARIA element references.
4
+ *
5
+ * Checked on both surfaces because references land in one of two places depending
6
+ * on where the role lives: on `ElementInternals` when the host itself carries the
7
+ * role, or on a plain `Element` when the role belongs to a focusable node inside
8
+ * the shadow root (`mp-select`'s `<select>`, `mp-checkbox`'s `<input>`). Spike 0.2
9
+ * measured both as present in Chromium, Firefox and WebKit, so in practice this
10
+ * returns true everywhere and the degraded path below is insurance rather than a
11
+ * tested branch.
12
+ */
13
+ export declare function supportsAriaElementReferences(): boolean;
14
+ /** ARIA state this controller can reflect onto the host. Values of `null` remove the state. */
15
+ export interface HostAriaState {
16
+ expanded?: boolean | null;
17
+ selected?: boolean | null;
18
+ checked?: boolean | 'mixed' | null;
19
+ pressed?: boolean | null;
20
+ disabled?: boolean | null;
21
+ invalid?: boolean | null;
22
+ required?: boolean | null;
23
+ readOnly?: boolean | null;
24
+ current?: string | null;
25
+ hasPopup?: string | null;
26
+ level?: number | null;
27
+ orientation?: string | null;
28
+ multiSelectable?: boolean | null;
29
+ valueNow?: number | null;
30
+ valueMin?: number | null;
31
+ valueMax?: number | null;
32
+ valueText?: string | null;
33
+ label?: string | null;
34
+ }
35
+ export interface HostAriaOptions {
36
+ /**
37
+ * Default role for the host. An author-supplied `role` attribute still wins,
38
+ * which is the point — this is a default, not an override.
39
+ */
40
+ role?: string;
41
+ /**
42
+ * Host attributes to resolve into cross-root element references.
43
+ * Default: `['aria-labelledby', 'aria-describedby']`.
44
+ */
45
+ referenceAttributes?: string[];
46
+ /**
47
+ * The node the resolved references should be assigned to, when it is **not** the
48
+ * host.
49
+ *
50
+ * Which node it must be is determined by where the role is, and getting it wrong
51
+ * produces a name nothing announces. Two shapes exist in this library:
52
+ *
53
+ * - The host carries the role via `internals.role` (`mp-datatable`,
54
+ * `mp-timeline`). Omit this — references go on `ElementInternals`.
55
+ * - The role belongs to a real focusable element inside the shadow root, because
56
+ * it is a native control (`mp-select`'s `<select>`, `mp-checkbox`'s `<input>`).
57
+ * Return that element. Naming the host instead would either be ignored, or
58
+ * announce twice — once for the host's role and once for the control's.
59
+ *
60
+ * A callback rather than an element because these components re-render and the
61
+ * node identity changes; it is re-read on every `syncReferences()`.
62
+ */
63
+ referenceTarget?: () => Element | null | undefined;
64
+ /**
65
+ * Nodes the component itself renders that describe the control, appended to
66
+ * whatever the consumer's `aria-describedby` resolved to. The `error-text`
67
+ * message node is the only user today (`errorFeedbackElements`).
68
+ *
69
+ * This exists because the two ways of expressing a description are not
70
+ * additive — they are the same channel, and this one wins. Assigning
71
+ * `ariaDescribedByElements` a non-null array blanks the `aria-describedby`
72
+ * content attribute, and assigning `null` removes it (measured in Chromium);
73
+ * since that assignment happens after every render, an in-shadow
74
+ * `aria-describedby="…-error"` written in `render()` would be silently erased
75
+ * on every browser that supports element references — and preserved in jsdom,
76
+ * where nothing supports them. So an in-shadow description has to be handed
77
+ * over here to survive, and the rendered attribute is left in place as the
78
+ * fallback for engines without the API.
79
+ */
80
+ describedByExtras?: () => HTMLElement[];
81
+ }
82
+ /** Re-arm the once-only reference warning. Tests only. */
83
+ export declare function resetReferenceWarningForTesting(): void;
84
+ /**
85
+ * Puts a web component's role and ARIA state on its **host**, and makes the
86
+ * consumer's `aria-labelledby` / `aria-describedby` actually work.
87
+ *
88
+ * Two problems, one platform answer.
89
+ *
90
+ * **The role is in the wrong place.** Most components in this library render
91
+ * their semantic role onto a node inside the shadow root. A consumer can only
92
+ * reach the host, and `aria-label` on a host with no role is ignored by
93
+ * browsers (naming is prohibited on `role="generic"`), so components end up
94
+ * unnameable from outside — the audit found `mp-select` unnamed by default and
95
+ * `mp-datatable`, `mp-timeline` and `mp-tree-select` with no naming path at all.
96
+ * `internals.role` puts the role on the host, so a host `aria-label` applies to
97
+ * the right node with no forwarding.
98
+ *
99
+ * **IDREFs cannot cross a shadow boundary.** `aria-labelledby="my-label"` on a
100
+ * host, copied onto an `<input>` inside the shadow root, resolves to nothing:
101
+ * IDREF *strings* are scoped to the holder's own tree. `mp-checkbox` does
102
+ * exactly this today and it is silently dead — the attribute is visibly present
103
+ * on the input in devtools and conveys nothing. The fix is that reflected ARIA
104
+ * *element reference* properties take elements, not ids, and may point at the
105
+ * same scope **or a parent scope** — so resolving the ids in the *host's* tree
106
+ * (where they do resolve) and assigning the elements inward is the permitted
107
+ * direction. `ariaLabelledByElements` has been Baseline since April 2025.
108
+ *
109
+ * Where the element-reference API is unavailable, references are skipped rather
110
+ * than approximated: copying the referenced element's `textContent` into
111
+ * `aria-label` drifts silently the moment the label is edited or translated, and
112
+ * a stale name is worse than a missing one. The documented fallback is the
113
+ * component's own `inputLabel` property.
114
+ *
115
+ * **References land on one of two nodes, and the choice is not cosmetic.** By
116
+ * default they go on the host's `ElementInternals`, which is right when the host
117
+ * carries the role. When the role belongs to a native control inside the shadow
118
+ * root — `mp-select`'s `<select>`, `mp-checkbox`'s `<input>` — pass
119
+ * `referenceTarget` and they go on that element instead. Naming the host in that
120
+ * case gives either nothing (the host is `generic`) or a double announcement, one
121
+ * for each role. Spike 0.2 verified both directions against a real accessibility
122
+ * tree; jsdom implements neither, so the positive path has **no** unit coverage by
123
+ * construction and the specs below assert only the degraded contract.
124
+ */
125
+ export declare class HostAriaController {
126
+ private readonly host;
127
+ private readonly options;
128
+ private readonly internals;
129
+ private readonly referenceAttributes;
130
+ constructor(host: HTMLElement, options?: HostAriaOptions);
131
+ /** True when the role and state are going through `ElementInternals`. */
132
+ get usesInternals(): boolean;
133
+ /**
134
+ * Reflect ARIA state onto the host.
135
+ *
136
+ * Call from `render()` or `updated()` — from wherever the visual state is
137
+ * derived — never as a side effect of an event handler. State written only on
138
+ * an event is stale for every other path that changes it (programmatic
139
+ * setters, server-rendered markup, a sibling closing this one), which is the
140
+ * defect class behind the frozen `aria-expanded` and write-only-when-true
141
+ * `aria-pressed` findings.
142
+ */
143
+ setState(state: HostAriaState): void;
144
+ /**
145
+ * Resolve the host's IDREF attributes into cross-root element references.
146
+ *
147
+ * Call from `connectedCallback` and whenever a reference attribute changes.
148
+ * Returns the attributes it could not honour, so a caller can warn.
149
+ */
150
+ syncReferences(): string[];
151
+ private assignReferences;
152
+ private write;
153
+ private clear;
154
+ }
@@ -1,2 +1,18 @@
1
1
  export { LiveAnnouncerController } from './live-announcer';
2
2
  export type { LiveAnnouncerOptions } from './live-announcer';
3
+ export { FocusRestore, FocusRestoreController, deepActiveElement } from './focus-restore';
4
+ export type { FocusRestoreOptions, FocusRestoreOutcome } from './focus-restore';
5
+ export { inertRegions } from './inert-regions';
6
+ export type { InertRegions } from './inert-regions';
7
+ export { dismissStack } from './dismiss-stack';
8
+ export { FocusTrap, collectTabbables, containsComposed } from './focus-trap';
9
+ export type { FocusTrapOptions, InitialFocusTarget } from './focus-trap';
10
+ export { RovingFocus } from './roving-focus';
11
+ export type { RovingFocusOptions, RovingFocusOrientation } from './roving-focus';
12
+ export { HostAriaController, sharedInternals, supportsAriaElementReferences } from './host-aria';
13
+ export type { HostAriaOptions, HostAriaState } from './host-aria';
14
+ export { nextEnabledIndex, firstEnabledIndex, lastEnabledIndex } from './roving-focus';
15
+ export { errorFeedback, errorFeedbackElements } from './error-text';
16
+ export type { ErrorFeedback } from './error-text';
17
+ export { FormAssociatedMixin } from './form-associated';
18
+ export type { FormAssociatedHost, FormAssociatedElement } from './form-associated';
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Keeps a set of regions hidden from **both** the accessibility tree and the
3
+ * tab order, so `aria-hidden` and focusability can never disagree.
4
+ *
5
+ * The defect this exists to prevent: hiding a region with `aria-hidden="true"`
6
+ * while it stays in the layout (translated off-screen, `opacity: 0`, clipped)
7
+ * leaves its controls focusable. Tab then lands on a node the screen reader is
8
+ * required *not* to announce — the reader goes silent and focus is effectively
9
+ * lost. It is an outright authoring violation, and it is easy to introduce
10
+ * because the two attributes are written in different places.
11
+ *
12
+ * Callers declare the **complete current hidden set**, never deltas. An
13
+ * interrupted animation therefore cannot leave a stale `inert` behind: the next
14
+ * declaration is authoritative regardless of what the previous transition was
15
+ * doing.
16
+ *
17
+ * Note `inert` propagates down the **flat tree**, so marking a shadow-DOM
18
+ * wrapper inert also inerts the consumer's light-DOM content slotted into it.
19
+ * A hand-rolled `tabindex="-1"` sweep cannot reach across a slot boundary
20
+ * without walking assigned nodes, which is the main reason this uses `inert`.
21
+ *
22
+ * `visibility: hidden` in CSS achieves the same thing and is preferable where
23
+ * the hiding is purely declarative (see the collapsing-region rule in
24
+ * `CLAUDE.md`); this is for the JS-driven cases and for defence in depth.
25
+ */
26
+ export interface InertRegions {
27
+ /** Declare the complete set that should be hidden right now. Idempotent. */
28
+ setHidden(hidden: Iterable<Element>): void;
29
+ /**
30
+ * Nothing is hidden while suspended. Reference-counted, because overlapping
31
+ * transitions are real — a carousel can start a drag while a wrap teleport
32
+ * is still in flight. Pair with `resume()`.
33
+ */
34
+ suspend(): void;
35
+ resume(): void;
36
+ /** Clear every attribute this controller wrote. */
37
+ dispose(): void;
38
+ }
39
+ /**
40
+ * Why `suspend()`/`resume()` exists rather than callers just recomputing the
41
+ * set: during a transition **both** the outgoing and the incoming region must
42
+ * be non-inert. Inert the outgoing one too early and it vanishes from the
43
+ * accessibility tree mid-animation; inert the incoming one too late and it is
44
+ * still inert when it lands. Suspending wholesale is simpler and strictly safer
45
+ * than computing the union, and it generalises — every animated panel has
46
+ * exactly this requirement.
47
+ *
48
+ * A zero-duration transition needs no special case: `suspend()` immediately
49
+ * followed by `resume()` writes the same attributes twice, which is idempotent.
50
+ * So the `prefers-reduced-motion` path requires no branch.
51
+ */
52
+ export declare function inertRegions(): InertRegions;
@@ -4,6 +4,13 @@ export interface LiveAnnouncerOptions {
4
4
  politeness?: 'polite' | 'assertive';
5
5
  /** ms after which the live region is blanked so the same message can re-announce later. Default: 1500. */
6
6
  clearAfterMs?: number;
7
+ /**
8
+ * Emit NO role on the region — aria-live alone makes it a live region.
9
+ * Required when the host carries a role with a strict children contract
10
+ * (role=tree owns everything in its shadow through transparent generics,
11
+ * and an owned role=status is invalid — axe aria-required-children).
12
+ */
13
+ omitRole?: boolean;
7
14
  }
8
15
  /**
9
16
  * Lit reactive controller that owns a visually-hidden live region for a Lit
@@ -26,6 +33,7 @@ export declare class LiveAnnouncerController implements ReactiveController {
26
33
  private pendingMessage;
27
34
  private readonly politeness;
28
35
  private readonly clearAfterMs;
36
+ private readonly omitRole;
29
37
  private readonly regionRef;
30
38
  constructor(host: ReactiveControllerHost, options?: LiveAnnouncerOptions);
31
39
  hostUpdated(): void;