@cngx/common 0.1.0-rc.8 → 0.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 (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
@@ -1,6 +1,36 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { OnDestroy, ElementRef, InjectionToken, Signal } from '@angular/core';
2
+ import { InjectionToken, Signal, OnDestroy, ElementRef } from '@angular/core';
3
3
 
4
+ /**
5
+ * Lets a directive that composes `CngxAriaExpanded` as a host directive drive
6
+ * `aria-expanded` from its own state instead of `[cngxAriaExpanded]`.
7
+ * Provided by the composer on the same element (`useExisting`); the ARIA
8
+ * directive resolves it lazily with `self: true`, because the composer
9
+ * constructs after its host directives. `CngxExpandable` is the in-library
10
+ * composer.
11
+ *
12
+ * @relatedTo CngxAriaExpanded, CNGX_ARIA_EXPANDED_DRIVER
13
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/aria-expanded.directive.ts
14
+ * @since 0.3.0
15
+ */
16
+ interface CngxAriaExpandedDriver {
17
+ /**
18
+ * The `aria-expanded` value; wins over `[cngxAriaExpanded]`. `null` omits
19
+ * the attribute, for a host that has nothing to expand (a leaf tree item).
20
+ */
21
+ readonly ariaExpanded: Signal<boolean | null>;
22
+ }
23
+ /**
24
+ * Injection token for a {@link CngxAriaExpandedDriver}. A composer provides it
25
+ * on its own element (`useExisting`) to override `[cngxAriaExpanded]` of its
26
+ * `CngxAriaExpanded` host directive; `aria-controls` still follows
27
+ * `[controls]`. Used by `CngxExpandable`.
28
+ *
29
+ * @relatedTo CngxAriaExpanded
30
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/aria-expanded.directive.ts
31
+ * @since 0.3.0
32
+ */
33
+ declare const CNGX_ARIA_EXPANDED_DRIVER: InjectionToken<CngxAriaExpandedDriver>;
4
34
  /**
5
35
  * Manages `aria-expanded` and optionally `aria-controls` on the host element.
6
36
  *
@@ -32,19 +62,24 @@ import { OnDestroy, ElementRef, InjectionToken, Signal } from '@angular/core';
32
62
  * }
33
63
  * ```
34
64
  *
35
- * @category common/a11y
36
65
  * @wcag AA
37
66
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/aria-expanded.directive.ts
38
- * @since 0.1.0
67
+ * @since 0.3.0
39
68
  * @relatedTo CngxLiveRegion, CngxExpandable, CngxDisclosure
40
- * <example-url>http://localhost:4200/#/common/a11y/aria-expanded/accordion-multiple-panels</example-url>
41
- * <example-url>http://localhost:4200/#/common/a11y/aria-expanded/disclosure-pattern</example-url>
69
+ * <example-url>/#/common/a11y/aria-expanded/accordion-multiple-panels</example-url>
70
+ * <example-url>/#/common/a11y/aria-expanded/disclosure-pattern</example-url>
71
+ * @axis level atom
42
72
  */
43
73
  declare class CngxAriaExpanded {
44
74
  /** Whether the controlled element is currently expanded. Sets `aria-expanded`. */
45
- readonly expanded: _angular_core.InputSignal<boolean>;
75
+ readonly expanded: _angular_core.InputSignalWithTransform<boolean, unknown>;
46
76
  /** The `id` of the controlled element. Sets `aria-controls`. */
47
77
  readonly controls: _angular_core.InputSignal<string | undefined>;
78
+ private readonly injector;
79
+ private resolvedDriver;
80
+ private driver;
81
+ /** @internal The written attribute value: the driver's when composed, else the input. */
82
+ protected readonly ariaExpanded: Signal<boolean | null>;
48
83
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAriaExpanded, never>;
49
84
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAriaExpanded, "[cngxAriaExpanded]", ["cngxAriaExpanded"], { "expanded": { "alias": "cngxAriaExpanded"; "required": false; "isSignal": true; }; "controls": { "alias": "controls"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
50
85
  }
@@ -59,9 +94,9 @@ declare class CngxAriaExpanded {
59
94
  * Sets `role="alert"` for assertive regions and `role="status"` for polite regions
60
95
  * via a host binding - no manual attribute wiring needed.
61
96
  *
62
- * Unlike CDK's `LiveAnnouncer` service (which creates a hidden DOM element and
63
- * requires imperative `announce()` calls), this directive decorates your own
64
- * element declaratively - the content you render IS the announcement.
97
+ * Unlike `CngxLiveAnnouncer` (hidden regions it owns, imperative
98
+ * `announce()` calls), this directive decorates your own element
99
+ * declaratively - the content you render IS the announcement.
65
100
  *
66
101
  * ### Status message
67
102
  * ```html
@@ -78,13 +113,13 @@ declare class CngxAriaExpanded {
78
113
  * </div>
79
114
  * ```
80
115
  *
81
- * @category common/a11y
82
116
  * @wcag AA
83
117
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-region.directive.ts
84
- * @since 0.1.0
85
- * @relatedTo CngxAriaExpanded
86
- * <example-url>http://localhost:4200/#/common/a11y/live-region/form-validation-assertive-error-announcements</example-url>
87
- * <example-url>http://localhost:4200/#/common/a11y/live-region/polite-vs-assertive</example-url>
118
+ * @since 0.3.0
119
+ * @relatedTo CngxLiveAnnouncer
120
+ * <example-url>/#/common/a11y/live-region/form-validation-assertive-error-announcements</example-url>
121
+ * <example-url>/#/common/a11y/live-region/polite-vs-assertive</example-url>
122
+ * @axis level atom
88
123
  */
89
124
  declare class CngxLiveRegion {
90
125
  /**
@@ -105,8 +140,6 @@ declare class CngxLiveRegion {
105
140
  /**
106
141
  * Politeness channel for {@link CngxLiveAnnouncer.announce}: `'polite'` queues
107
142
  * after the current utterance, `'assertive'` interrupts it immediately.
108
- *
109
- * @category common/a11y
110
143
  */
111
144
  type AriaLivePoliteness = 'polite' | 'assertive';
112
145
  /**
@@ -120,11 +153,32 @@ type AriaLivePoliteness = 'polite' | 'assertive';
120
153
  * directives and event handlers (e.g. `CngxCopyValue` copy success,
121
154
  * `CngxOtpInput` completion).
122
155
  *
123
- * Each region is created lazily on the first announcement of its politeness and
124
- * reused thereafter. Because polite and assertive live in separate fixed-
125
- * politeness nodes, an assertive announcement never clobbers a concurrent
126
- * polite one. Per region, the text is cleared and re-set one frame later so an
127
- * identical consecutive message is still re-read by the screen reader.
156
+ * Both body regions are created when the service is created, so they are in
157
+ * the DOM before the first announcement (a screen reader commonly misses a
158
+ * change to a region inserted a frame earlier), and reused thereafter.
159
+ * Because polite and assertive live in separate fixed-politeness nodes, an
160
+ * assertive announcement never clobbers a concurrent polite one. Per region,
161
+ * the text is cleared and re-set one frame later so an identical consecutive
162
+ * message is still re-read by the screen reader. A written message is cleared
163
+ * again after 7 s, so no stale text stays in the region.
164
+ *
165
+ * A modal dialog hides everything outside it from assistive technology, so a
166
+ * body region is silent while one is open. Pass the announcing element as the
167
+ * third argument and the message goes to a region pair inside its enclosing
168
+ * `[aria-modal="true"]` container instead; without a modal ancestor it goes to
169
+ * the body regions as before. When another modal covers that one, the topmost
170
+ * open modal receives it: the last `[aria-modal="true"]` element in document
171
+ * order that is open and not inside an `[inert]` subtree. That covers a modal
172
+ * nested inside the scope's own one as well as a sibling stacked on top of it,
173
+ * which is how `CngxDialog` stacks dialogs (every host is appended to
174
+ * `document.body`); a covered modal is hidden from assistive technology, so
175
+ * its region would be silent. The pair is created with both regions on first
176
+ * use and its first write waits until the regions have settled in the DOM. A
177
+ * message still pending when its modal closes moves to the next enclosing open
178
+ * modal, else to the topmost modal still open, else to the body regions, and
179
+ * the pair is removed. The scope is opt-in per call - an unscoped announcement
180
+ * never guesses a modal. {@link injectScopedLiveRegion} is the injection-time
181
+ * alternative when the caller knows its overlay host up front.
128
182
  *
129
183
  * SSR-safe: all DOM access is guarded by `isPlatformBrowser`; on the server
130
184
  * `announce()` is a no-op and no region is created.
@@ -133,20 +187,26 @@ type AriaLivePoliteness = 'polite' | 'assertive';
133
187
  * const announcer = inject(CngxLiveAnnouncer);
134
188
  * announcer.announce('Copied');
135
189
  * announcer.announce('Save failed', 'assertive');
190
+ * announcer.announce('Alert dismissed', 'polite', hostElement); // inside a modal
136
191
  * ```
137
192
  *
138
- * @category common/a11y
139
193
  * @wcag AA
140
194
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/live-announcer.ts
141
- * @since 0.1.0
195
+ * @since 0.3.0
142
196
  * @relatedTo CngxLiveRegion
197
+ * <example-url>/#/common/a11y/live-announcer/polite-vs-assertive</example-url>
143
198
  */
144
199
  declare class CngxLiveAnnouncer implements OnDestroy {
145
200
  private readonly doc;
146
201
  private readonly isBrowser;
147
- private politeRegion;
148
- private assertiveRegion;
149
- private readonly pending;
202
+ private regions;
203
+ constructor();
204
+ /**
205
+ * One pair per open `aria-modal` container, released once it closes.
206
+ * `outer` is the container's parent at creation, the route for its unwritten
207
+ * messages when it is removed from the DOM.
208
+ */
209
+ private readonly modalRegions;
150
210
  /**
151
211
  * Announces `message` through the fixed-politeness live region.
152
212
  *
@@ -154,14 +214,89 @@ declare class CngxLiveAnnouncer implements OnDestroy {
154
214
  * @param politeness `'polite'` (default) queues after the current
155
215
  * utterance; `'assertive'` interrupts immediately. Each politeness owns its
156
216
  * own region, so the two never overwrite each other.
217
+ * @param scope The announcing element. When it sits inside an
218
+ * `[aria-modal="true"]` container, the message is written into a region
219
+ * inside the topmost open modal (that container unless another modal
220
+ * covers it), which a screen reader still reads while the modal hides the
221
+ * rest of the page. `null` / omitted: the body regions.
157
222
  */
158
- announce(message: string, politeness?: AriaLivePoliteness): void;
223
+ announce(message: string, politeness?: AriaLivePoliteness, scope?: Element | null): void;
159
224
  ngOnDestroy(): void;
160
- private ensureRegion;
225
+ /**
226
+ * `fromModal` marks a message that was already scoped to a modal which has
227
+ * since closed: with no open modal around its new scope it still goes to the
228
+ * topmost open modal rather than to the silent body regions.
229
+ */
230
+ private route;
231
+ /**
232
+ * The topmost open modal when `scope` sits in an open modal (or the message
233
+ * comes from a closed one), else `null` for the body regions. Falls back to
234
+ * the scope's own modal when no candidate outside an inert subtree is open.
235
+ */
236
+ private targetModal;
237
+ private enclosingOpenModal;
238
+ private redirectIfClosed;
239
+ private releaseClosedModals;
240
+ /** Drop the pair of a closed modal; its unwritten messages move outward. */
241
+ private release;
242
+ private outerOf;
161
243
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxLiveAnnouncer, never>;
162
244
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxLiveAnnouncer>;
163
245
  }
164
246
 
247
+ /**
248
+ * A message whose write into its live region has not landed yet.
249
+ */
250
+ interface CngxPendingAnnouncement {
251
+ readonly message: string;
252
+ readonly politeness: AriaLivePoliteness;
253
+ }
254
+
255
+ /**
256
+ * Polite + assertive live regions inside one host element.
257
+ */
258
+ interface CngxScopedLiveRegion {
259
+ /** Speak `message` from the region of `politeness` (default `'polite'`). */
260
+ announce(message: string, politeness?: AriaLivePoliteness): void;
261
+ /** Create both regions now, so they are in the DOM before the first message. */
262
+ ensure(): void;
263
+ /** Cancel every write that has not landed yet and return what it would have said. */
264
+ takePending(): readonly CngxPendingAnnouncement[];
265
+ /** Cancel pending writes and remove the regions. Runs on destroy as well. */
266
+ destroy(): void;
267
+ }
268
+ /**
269
+ * Create a polite + assertive live-region pair inside `host`.
270
+ *
271
+ * The scoped counterpart to {@link CngxLiveAnnouncer}: same regions, same
272
+ * clear-then-set timing, but appended to an overlay host instead of
273
+ * `document.body`. Use it for modal overlays: under `aria-modal` VoiceOver
274
+ * drops body-level live regions and speaks them late after the overlay
275
+ * closes, while a region inside the modal is spoken on every platform.
276
+ * Polite and assertive keep separate regions, so an assertive error never
277
+ * clobbers a polite status.
278
+ *
279
+ * Must run in an injection context; the regions are removed when that context
280
+ * is destroyed, and later calls are no-ops. No-op on the server.
281
+ *
282
+ * ```typescript
283
+ * private readonly region = injectScopedLiveRegion(inject(ElementRef).nativeElement);
284
+ *
285
+ * protected handleSaveFailed(): void {
286
+ * this.region.announce('Save failed', 'assertive');
287
+ * }
288
+ * ```
289
+ *
290
+ * @param host - Element that receives the two visually hidden regions.
291
+ *
292
+ * @wcag AA
293
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/scoped-live-region.ts
294
+ * @since 0.3.0
295
+ * @relatedTo CngxLiveAnnouncer, CngxLiveRegion
296
+ * <example-url>/#/common/a11y/live-announcer/scoped-announcing-in-a-modal</example-url>
297
+ */
298
+ declare function injectScopedLiveRegion(host: HTMLElement): CngxScopedLiveRegion;
299
+
165
300
  /**
166
301
  * Reactive autofocus for dynamically inserted elements.
167
302
  *
@@ -189,17 +324,17 @@ declare class CngxLiveAnnouncer implements OnDestroy {
189
324
  * <input cngxAutofocus [autofocusDelay]="200" />
190
325
  * ```
191
326
  *
192
- * @category common/a11y
193
327
  * @wcag AA
194
328
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/autofocus.directive.ts
195
- * @since 0.1.0
329
+ * @since 0.3.0
196
330
  * @relatedTo CngxFocusRestore, CngxFocusTrap, CngxFocusVisible
197
- * <example-url>http://localhost:4200/#/common/a11y/autofocus/conditional-focus</example-url>
198
- * <example-url>http://localhost:4200/#/common/a11y/autofocus/focus-on-insert</example-url>
331
+ * <example-url>/#/common/a11y/autofocus/conditional-focus</example-url>
332
+ * <example-url>/#/common/a11y/autofocus/focus-on-insert</example-url>
333
+ * @axis level atom
199
334
  */
200
335
  declare class CngxAutofocus {
201
336
  /** Whether to focus the element. Defaults to `true` (always focus on render). */
202
- readonly when: _angular_core.InputSignal<boolean>;
337
+ readonly when: _angular_core.InputSignalWithTransform<boolean, unknown>;
203
338
  /** Delay in ms before focusing - useful when the element appears during a transition. */
204
339
  readonly delay: _angular_core.InputSignal<number>;
205
340
  /** `FocusOptions` passed to `element.focus()`. */
@@ -218,27 +353,62 @@ declare class CngxAutofocus {
218
353
 
219
354
  /**
220
355
  * CSS selector matching natively-focusable elements: links with an
221
- * `href`, the enabled form controls, and anything with an explicit
222
- * non-negative `tabindex`. Form controls carry `:not(:disabled)` because
223
- * a disabled control is not in the tab order - without it a descendant
224
- * probe would count a disabled button as focusable and a restore target
225
- * could land on an unfocusable element. Single source of truth for "is
226
- * this focusable" - the element-level {@link CngxFocusRestore} predicate
227
- * matches against it, and descendant probes (e.g. "does this panel
228
- * contain a focusable child?") query against it. Keeping one selector
229
- * stops the two uses from drifting apart.
230
- *
231
- * @category common/a11y
232
- * @since 0.1.0
356
+ * `href`, the enabled form controls, the summary of a `<details>`,
357
+ * editable content, and anything with an explicit non-negative `tabindex`.
358
+ * Form controls carry `:not(:disabled)` because a disabled control is not in
359
+ * the tab order - without it a descendant probe would count a disabled button
360
+ * as focusable and a restore target could land on an unfocusable element.
361
+ * Single source of truth for "is this focusable" - the element-level
362
+ * {@link CngxFocusRestore} predicate matches against it, and descendant probes
363
+ * (e.g. "does this panel contain a focusable child?") query against it.
364
+ * Keeping one selector stops the two uses from drifting apart.
365
+ *
366
+ * @since 0.3.0
367
+ */
368
+ declare const CNGX_FOCUSABLE_SELECTOR = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), details > summary:first-of-type, [contenteditable]:not([contenteditable=\"false\"]), [tabindex]:not([tabindex=\"-1\"])";
369
+ /**
370
+ * Lets a directive that composes `CngxFocusRestore` as a host directive drive
371
+ * its capture / restore edges from its own state instead of
372
+ * `[cngxFocusRestoreWhile]`. Provided by the composer on the same element
373
+ * (`useExisting`); the restore directive resolves it lazily with
374
+ * `self: true`, because the composer constructs after its host directives.
375
+ * `CngxDrawerSurface` is the in-library composer.
376
+ *
377
+ * @relatedTo CngxFocusRestore, CNGX_FOCUS_RESTORE_DRIVER
378
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
379
+ * @since 0.3.0
233
380
  */
234
- declare const CNGX_FOCUSABLE_SELECTOR = "a[href], button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
381
+ interface CngxFocusRestoreDriver {
382
+ /** Whether the surface is engaged; wins over `[cngxFocusRestoreWhile]`. */
383
+ readonly focusRestoreActive: Signal<boolean>;
384
+ /**
385
+ * The fallback when the stored element cannot take focus back; wins over
386
+ * the `[fallback]` input. Read at restore time, so a composer can derive
387
+ * it from the DOM (the element that controls the host).
388
+ */
389
+ focusRestoreFallback?(): HTMLElement | null;
390
+ }
391
+ /**
392
+ * Injection token for a {@link CngxFocusRestoreDriver}. A composer provides it
393
+ * on its own element (`useExisting`) to override `[cngxFocusRestoreWhile]`
394
+ * and `[fallback]` of its `CngxFocusRestore` host directive. Used by
395
+ * `CngxDrawerSurface`.
396
+ *
397
+ * @relatedTo CngxFocusRestore
398
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
399
+ * @since 0.3.0
400
+ */
401
+ declare const CNGX_FOCUS_RESTORE_DRIVER: InjectionToken<CngxFocusRestoreDriver>;
235
402
  /**
236
- * Stores the previously focused element and restores focus on destroy.
403
+ * Stores the previously focused element and restores focus on destroy, or on
404
+ * the falling edge of `[cngxFocusRestoreWhile]` for a surface that stays in
405
+ * the DOM while closed.
237
406
  *
238
407
  * Prevents focus from falling to `<body>` when dynamic content is removed
239
408
  * (dialogs closing, panels collapsing, tabs switching). The directive captures
240
409
  * `document.activeElement` at initialization time and restores it when the
241
- * host element is destroyed.
410
+ * host element is destroyed while focus is inside it or has dropped to
411
+ * `<body>`. Focus the user moved elsewhere before the destroy stays put.
242
412
  *
243
413
  * Fallback chain: stored element → provided fallback → nearest focusable ancestor.
244
414
  * When none resolves, focus is left where the browser put it - `<body>` is
@@ -254,39 +424,73 @@ declare const CNGX_FOCUSABLE_SELECTOR = "a[href], button:not(:disabled), input:n
254
424
  * }
255
425
  * ```
256
426
  *
427
+ * ### Persistent surface (drawer, sidebar overlay)
428
+ * ```html
429
+ * <aside cngxFocusRestore [cngxFocusRestoreWhile]="open()">…</aside>
430
+ * ```
431
+ * `true` captures the focused element, `false` restores it when focus is
432
+ * still inside the host or has dropped to `<body>`. Focus the user moved
433
+ * elsewhere in the meantime stays where it is. A target that is still
434
+ * `inert` at the falling edge (a backdrop released in the same pass) is
435
+ * focused after the next render instead.
436
+ *
257
437
  * ### With explicit fallback
258
438
  * ```html
259
- * <div cngxFocusRestore [focusRestoreFallback]="fallbackBtn">
439
+ * <div cngxFocusRestore [fallback]="fallbackBtn">
260
440
  * Dynamic content…
261
441
  * </div>
262
442
  * <button #fallbackBtn>Fallback target</button>
263
443
  * ```
264
444
  *
265
- * @category common/a11y
266
445
  * @wcag AA
267
446
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-restore.directive.ts
268
- * @since 0.1.0
447
+ * @since 0.3.0
269
448
  * @relatedTo CngxAutofocus, CngxFocusTrap, CngxFocusVisible
270
- * <example-url>http://localhost:4200/#/common/a11y/focus-restore/inline-details</example-url>
271
- * <example-url>http://localhost:4200/#/common/a11y/focus-restore/panel-with-automatic-restore</example-url>
449
+ * <example-url>/#/common/a11y/focus-restore/inline-details</example-url>
450
+ * <example-url>/#/common/a11y/focus-restore/panel-with-automatic-restore</example-url>
451
+ * <example-url>/#/common/a11y/focus-restore/persistent-panel-restore-while-open</example-url>
452
+ * @axis level atom
272
453
  */
273
454
  declare class CngxFocusRestore {
274
- /** Whether to restore focus when the host element is destroyed. */
455
+ /**
456
+ * Whether to restore focus when the host element is destroyed. Applies only
457
+ * when focus is inside the host or on `<body>` at that moment.
458
+ */
275
459
  readonly restoreOnDestroy: _angular_core.InputSignal<boolean>;
276
460
  /** Explicit fallback element if the stored element is no longer in the DOM. */
277
461
  readonly fallback: _angular_core.InputSignal<HTMLElement | null>;
462
+ /**
463
+ * Bind to the open state of a surface that stays in the DOM while closed.
464
+ * The `false -> true` edge captures the focused element, the
465
+ * `true -> false` edge restores it when focus is inside the host or on
466
+ * `<body>`. While bound, destroying the host restores only when it is
467
+ * engaged. Unbound (`undefined`), only destroy and the manual
468
+ * `capture()` / `restore()` apply.
469
+ */
470
+ readonly whileActive: _angular_core.InputSignal<boolean | undefined>;
278
471
  private readonly doc;
279
472
  private readonly el;
280
- private readonly storedElement;
473
+ private readonly injector;
474
+ private storedElement;
475
+ private lastParent;
476
+ private resolvedDriver;
477
+ private driver;
478
+ private readonly engaged;
479
+ private readonly engagement;
281
480
  constructor();
282
481
  /** Manually store the current focus target for later restoration. */
283
482
  capture(): void;
284
483
  /** Manually restore focus to the stored element. */
285
484
  restore(): void;
485
+ private edgeDriven;
486
+ private captureOutside;
487
+ private restoreIfFocusInside;
488
+ private focusLost;
489
+ private host;
286
490
  /**
287
491
  * Walks the fallback chain:
288
492
  * 1. Stored element (if still in DOM and not body/self)
289
- * 2. Explicit fallback input
493
+ * 2. The driver's fallback, else the explicit fallback input
290
494
  * 3. Nearest focusable ancestor
291
495
  */
292
496
  private resolveTarget;
@@ -300,9 +504,37 @@ declare class CngxFocusRestore {
300
504
  */
301
505
  private isFocusable;
302
506
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFocusRestore, never>;
303
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxFocusRestore, "[cngxFocusRestore]", ["cngxFocusRestore"], { "restoreOnDestroy": { "alias": "restoreOnDestroy"; "required": false; "isSignal": true; }; "fallback": { "alias": "fallback"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
507
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxFocusRestore, "[cngxFocusRestore]", ["cngxFocusRestore"], { "restoreOnDestroy": { "alias": "restoreOnDestroy"; "required": false; "isSignal": true; }; "fallback": { "alias": "fallback"; "required": false; "isSignal": true; }; "whileActive": { "alias": "cngxFocusRestoreWhile"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
304
508
  }
305
509
 
510
+ /**
511
+ * Lets a directive that composes `CngxFocusTrap` as a host directive drive it
512
+ * from its own state instead of the inputs. Provided by the composer on the
513
+ * same element (`useExisting`); the trap resolves it lazily with
514
+ * `self: true`, because the composer constructs after its host directives.
515
+ * `CngxDrawerSurface` and `CngxPopoverSheet` are the in-library composers.
516
+ *
517
+ * @relatedTo CngxFocusTrap, CNGX_FOCUS_TRAP_DRIVER
518
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-trap.directive.ts
519
+ * @since 0.3.0
520
+ */
521
+ interface CngxFocusTrapDriver {
522
+ /** Whether the trap is active; wins over `[enabled]`. */
523
+ readonly focusTrapEnabled: Signal<boolean>;
524
+ /** Whether activation auto-focuses; wins over `[autoFocus]`. */
525
+ readonly focusTrapAutoFocus: boolean;
526
+ }
527
+ /**
528
+ * Injection token for a {@link CngxFocusTrapDriver}. A composer provides it on
529
+ * its own element (`useExisting`) to override `[enabled]` and `[autoFocus]` of
530
+ * its `CngxFocusTrap` host directive. Used by `CngxDrawerSurface` and
531
+ * `CngxPopoverSheet`.
532
+ *
533
+ * @relatedTo CngxFocusTrap
534
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-trap.directive.ts
535
+ * @since 0.3.0
536
+ */
537
+ declare const CNGX_FOCUS_TRAP_DRIVER: InjectionToken<CngxFocusTrapDriver>;
306
538
  /**
307
539
  * Traps keyboard focus within the host element using the CDK `FocusTrap`.
308
540
  *
@@ -337,31 +569,48 @@ declare class CngxFocusRestore {
337
569
  * </nav>
338
570
  * ```
339
571
  *
340
- * @category common/a11y
341
- * @docsKind primary
342
572
  * @wcag AA
343
573
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-trap.directive.ts
344
- * @since 0.1.0
574
+ * @since 0.3.0
345
575
  * @relatedTo CngxAutofocus, CngxFocusRestore, CngxDialog
346
- * <example-url>http://localhost:4200/#/common/a11y/focus-trap/modal-dialog</example-url>
347
- * <example-url>http://localhost:4200/#/common/a11y/focus-trap/slide-out-drawer</example-url>
576
+ * <example-url>/#/common/a11y/focus-trap/modal-dialog</example-url>
577
+ * <example-url>/#/common/a11y/focus-trap/slide-out-drawer</example-url>
578
+ * @axis level atom
348
579
  */
349
580
  declare class CngxFocusTrap {
350
581
  /** Whether the focus trap is active. When `false`, Tab navigates normally. */
351
582
  readonly enabled: _angular_core.InputSignal<boolean>;
352
583
  /** Whether to auto-focus the first tabbable element when the trap activates. */
353
584
  readonly autoFocus: _angular_core.InputSignal<boolean>;
585
+ private readonly injector;
586
+ private resolvedDriver;
587
+ private driver;
588
+ /**
589
+ * The enabled state the trap actually follows: a composer's driver
590
+ * (see {@link CngxFocusTrapDriver}) wins over the `[enabled]` input.
591
+ */
592
+ private readonly effectiveEnabled;
354
593
  /**
355
- * Readable alias of `enabled` for `exportAs` consumers
594
+ * Readable alias of the effective enabled state for `exportAs` consumers
356
595
  * (`trap.isActive()` reads better than re-binding the input).
357
596
  */
358
- readonly isActive: _angular_core.Signal<boolean>;
359
- private readonly trap;
597
+ readonly isActive: Signal<boolean>;
598
+ private readonly host;
599
+ private readonly factory;
600
+ private trap;
360
601
  constructor();
361
602
  /** Programmatically focus the first tabbable element within the trap. */
362
603
  focusFirst(): void;
363
604
  /** Programmatically focus the last tabbable element within the trap. */
364
605
  focusLast(): void;
606
+ /**
607
+ * @internal Focus the first tabbable element right now, in the caller's
608
+ * stack. `focusFirst()` waits for the next render, which is too late for a
609
+ * composer that must move focus inside the user gesture that opened it.
610
+ * Returns `false` when nothing inside is tabbable.
611
+ */
612
+ focusFirstNow(): boolean;
613
+ private ensureTrap;
365
614
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFocusTrap, never>;
366
615
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxFocusTrap, "[cngxFocusTrap]", ["cngxFocusTrap"], { "enabled": { "alias": "enabled"; "required": false; "isSignal": true; }; "autoFocus": { "alias": "autoFocus"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
367
616
  }
@@ -379,13 +628,13 @@ declare class CngxFocusTrap {
379
628
  * </button>
380
629
  * ```
381
630
  *
382
- * @category common/a11y
383
631
  * @wcag AA
384
632
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/focus/focus-visible.directive.ts
385
- * @since 0.1.0
633
+ * @since 0.3.0
386
634
  * @relatedTo CngxAutofocus, CngxFocusRestore, CngxFocusTrap
387
- * <example-url>http://localhost:4200/#/common/a11y/focus-visible/form-fields-custom-focus-ring</example-url>
388
- * <example-url>http://localhost:4200/#/common/a11y/focus-visible/keyboard-vs-pointer</example-url>
635
+ * <example-url>/#/common/a11y/focus-visible/form-fields-custom-focus-ring</example-url>
636
+ * <example-url>/#/common/a11y/focus-visible/keyboard-vs-pointer</example-url>
637
+ * @axis level atom
389
638
  */
390
639
  declare class CngxFocusVisible {
391
640
  private readonly doc;
@@ -394,10 +643,12 @@ declare class CngxFocusVisible {
394
643
  readonly focusVisible: _angular_core.Signal<boolean>;
395
644
  private pointerActive;
396
645
  private pointerClearTimer;
646
+ private readonly releasePointer;
397
647
  private readonly schedulePointerClear;
398
648
  constructor();
399
649
  /** @internal Arms the pointer flag for the imminent focusin. */
400
650
  protected handlePointerDown(): void;
651
+ private removeReleaseListeners;
401
652
  /** @internal Sets focus-visible state; clears pointer flag. */
402
653
  protected handleFocus(): void;
403
654
  /** @internal Clears focus-visible state on blur. */
@@ -421,13 +672,12 @@ declare class CngxFocusVisible {
421
672
  * </div>
422
673
  * ```
423
674
  *
424
- * @category common/a11y
425
675
  * @wcag AA
426
676
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
427
- * @since 0.1.0
677
+ * @since 0.3.0
428
678
  * @relatedTo CngxRovingTabindex, CngxButtonToggle
429
- * <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
430
- * <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
679
+ * <example-url>/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
680
+ * <example-url>/#/common/a11y/roving-tabindex/vertical-menu</example-url>
431
681
  */
432
682
  declare class CngxRovingItem {
433
683
  /** @internal Reference used by the parent `CngxRovingTabindex` to set `tabindex`. */
@@ -449,6 +699,17 @@ declare class CngxRovingItem {
449
699
  * Works for toolbars, tab lists, card grids, menu bars, and any composite
450
700
  * widget where only one item should be in the tab order at a time.
451
701
  *
702
+ * ### Keys the group leaves alone
703
+ *
704
+ * A key from a text field (an `<input>` item, a field inside an item), a key
705
+ * of an IME composition, and an arrow from inside a nested widget that owns
706
+ * its arrows (a range input or an element with a slider, spinbutton,
707
+ * scrollbar, combobox, listbox, tree, treegrid, grid, menu, menubar,
708
+ * tablist, radiogroup or toolbar role)
709
+ * stays with that element. A custom widget without one of those roles keeps
710
+ * its arrows by calling `preventDefault()` on the keys it handles: the group
711
+ * skips every key that arrives already handled.
712
+ *
452
713
  * ### Virtual mode
453
714
  *
454
715
  * When `virtualCount` is set, `activeIndex` ranges from 0 to `virtualCount - 1`
@@ -486,14 +747,13 @@ declare class CngxRovingItem {
486
747
  * </div>
487
748
  * ```
488
749
  *
489
- * @category common/a11y
490
- * @docsKind primary
491
750
  * @wcag AA
492
751
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/roving/roving-tabindex.directive.ts
493
- * @since 0.1.0
752
+ * @since 0.3.0
494
753
  * @relatedTo CngxRovingItem, CngxActiveDescendant
495
- * <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
496
- * <example-url>http://localhost:4200/#/common/a11y/roving-tabindex/vertical-menu</example-url>
754
+ * <example-url>/#/common/a11y/roving-tabindex/horizontal-toolbar</example-url>
755
+ * <example-url>/#/common/a11y/roving-tabindex/vertical-menu</example-url>
756
+ * @axis level atom
497
757
  */
498
758
  declare class CngxRovingTabindex {
499
759
  /**
@@ -516,8 +776,15 @@ declare class CngxRovingTabindex {
516
776
  readonly virtualCount: _angular_core.InputSignal<number | undefined>;
517
777
  /** All `CngxRovingItem` children discovered via `contentChildren`. */
518
778
  private readonly items;
519
- /** Guards against setting `tabindex` before the DOM is ready. */
520
- private readonly initialized;
779
+ /**
780
+ * Flips after the first browser render. Virtual mode waits for it: it reads
781
+ * the `data-cngx-recycle-index` attributes, which the item bindings write
782
+ * during that render. Standard mode writes before it (so a server render
783
+ * carries the tab stops) and once more after it, because an item's own
784
+ * `[attr.tabindex]` binding (null under a roving parent) clears the
785
+ * attribute during that render.
786
+ */
787
+ private readonly rendered;
521
788
  /** Host element for `data-cngx-recycle-index` queries in virtual mode. */
522
789
  private readonly hostEl;
523
790
  private readonly pendingFocusState;
@@ -559,6 +826,13 @@ declare class CngxRovingTabindex {
559
826
  * based on whether `virtualCount` is set.
560
827
  */
561
828
  protected handleKeyDown(event: KeyboardEvent): void;
829
+ /**
830
+ * Whether the group may take the key: not one a nested widget already
831
+ * handled, not part of an IME composition, not from a text field (an
832
+ * `<input>` item or one inside an item keeps its caret keys) and not from
833
+ * inside a nested widget that owns its arrows.
834
+ */
835
+ private ownsKey;
562
836
  /**
563
837
  * Keeps `activeIndex` in sync with real focus (APG): when an item gains
564
838
  * focus by any means - pointer click, script focus, assistive tech - the
@@ -596,8 +870,6 @@ declare class CngxRovingTabindex {
596
870
  *
597
871
  * `id` must be unique and stable across change detection runs (use `nextUid()`
598
872
  * from `@cngx/core/utils`). `label` is used by typeahead matching.
599
- *
600
- * @category common/a11y
601
873
  */
602
874
  interface ActiveDescendantItem {
603
875
  /** Unique DOM `id` on the element - required for `aria-activedescendant`. */
@@ -622,18 +894,15 @@ interface ActiveDescendantItem {
622
894
  * The contained directive must expose `id`, `value`, `label`, and optionally
623
895
  * `disabled` as signals - the AD reads them reactively.
624
896
  *
625
- * @category common/a11y
626
897
  * @wcag AA
627
898
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/ad-item.token.ts
628
- * @since 0.1.0
899
+ * @since 0.3.0
629
900
  */
630
901
  declare const CNGX_AD_ITEM: InjectionToken<CngxAdItemHandle>;
631
902
  /**
632
903
  * Minimum shape an AD-registered directive must expose.
633
904
  *
634
905
  * The shape is signal-based so the AD recomputes when any field changes.
635
- *
636
- * @category common/a11y
637
906
  */
638
907
  interface CngxAdItemHandle {
639
908
  readonly id: string;
@@ -673,21 +942,22 @@ interface CngxAdItemHandle {
673
942
  * checks, typeahead labels) map absolute indices onto the rendered subset.
674
943
  * Targets outside the window surface as `pendingHighlight`; the consumer
675
944
  * scrolls them into view (`connectRecyclerToActiveDescendant`) and the
676
- * directive clears the pending state once the target renders.
945
+ * directive clears the pending state once the target renders; no
946
+ * `clearPendingHighlight()` call is needed.
677
947
  *
678
948
  * ### Material/CDK equivalent
679
949
  *
680
950
  * Same model as `cdk-listbox` and `mat-select`, without the visual shell and
681
951
  * driven by signals instead of `ListKeyManager`.
682
952
  *
683
- * @category common/a11y
684
- * @docsKind primary
685
953
  * @wcag AA
686
954
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/active-descendant/active-descendant.directive.ts
687
- * @since 0.1.0
955
+ * @since 0.3.0
688
956
  * @relatedTo CngxRovingTabindex, CngxListbox, CngxMenu
689
- * <example-url>http://localhost:4200/#/common/a11y/active-descendant/listbox-with-items-input</example-url>
690
- * <example-url>http://localhost:4200/#/common/a11y/active-descendant/typeahead</example-url>
957
+ * <example-url>/#/common/a11y/active-descendant/listbox-with-items-input</example-url>
958
+ * <example-url>/#/common/a11y/active-descendant/typeahead</example-url>
959
+ * <example-url>/#/common/a11y/active-descendant/horizontal-option-row</example-url>
960
+ * @axis level atom
691
961
  */
692
962
  declare class CngxActiveDescendant {
693
963
  /**
@@ -723,6 +993,23 @@ declare class CngxActiveDescendant {
723
993
  * Ignored when `virtualCount` is unset.
724
994
  */
725
995
  readonly windowStart: _angular_core.InputSignal<number>;
996
+ /**
997
+ * The full list in absolute index space, for a windowed list whose rendered
998
+ * rows are only part of it. When bound, typeahead searches this list and a
999
+ * match anywhere in it becomes the highlight; `typeaheadMissed` then means no
1000
+ * match in the whole list. Unbound, the rendered window stays the search
1001
+ * space. Items are read for `label` and `disabled` only, so `id` may be empty.
1002
+ */
1003
+ readonly typeaheadItems: _angular_core.InputSignal<readonly ActiveDescendantItem[] | undefined>;
1004
+ /**
1005
+ * Equality used to find the previously active value again after the item
1006
+ * list changes. Defaults to `Object.is`; pass the same comparator as the
1007
+ * surrounding listbox / select when options are re-fetched as new objects
1008
+ * with equal identity, or the highlight drops on every refresh. The
1009
+ * parameters are typed `never` so a comparator over any value type binds
1010
+ * while the directive itself stays non-generic.
1011
+ */
1012
+ readonly compareWith: _angular_core.InputSignal<(a: never, b: never) => boolean>;
726
1013
  /** Emitted when `activateCurrent()` is called with an active item. */
727
1014
  readonly activated: _angular_core.OutputEmitterRef<unknown>;
728
1015
  /** Emitted whenever the highlighted item changes. */
@@ -741,20 +1028,55 @@ declare class CngxActiveDescendant {
741
1028
  private readonly registered;
742
1029
  /** Document writing direction - flips the horizontal-arrow steps under `rtl` (APG). */
743
1030
  private readonly direction;
744
- /** Guards host attribute writes until after first render. */
1031
+ /** Holds `autoHighlightFirst` back until after first render. */
745
1032
  private readonly initialized;
746
- /** -1 means "no active item". Range is [0, resolvedItems().length). */
747
- private readonly activeIndexState;
748
- /** Index of an item that should be highlighted but is not in the DOM. */
749
- private readonly pendingHighlightState;
750
- readonly pendingHighlight: _angular_core.Signal<number | null>;
1033
+ /**
1034
+ * A highlight gesture that fired while the option rows were not in the DOM
1035
+ * (a deferred-render panel just opened, OD5): the id space does not exist
1036
+ * yet, so the gesture is kept as INTENT - not a resolved index, which an
1037
+ * empty item space resolves to nothing. It is a source of
1038
+ * `activeIndexState` and resolves there once the rows render. Written only
1039
+ * by the imperative highlight methods; every index write clears it.
1040
+ * Non-virtual path only; the virtual path uses `pendingHighlight`.
1041
+ */
1042
+ private readonly pendingIntentState;
751
1043
  /**
752
1044
  * Resolved item list. Input `items` wins; otherwise the contentChildren
753
1045
  * handles are projected into `ActiveDescendantItem` shape.
754
1046
  */
755
1047
  readonly resolvedItems: _angular_core.Signal<ActiveDescendantItem[]>;
1048
+ /**
1049
+ * -1 means "no active item". Range is `[0, totalCount())`.
1050
+ *
1051
+ * Navigation writes the index; a change of the item space re-derives it.
1052
+ * In a plain list the highlight follows its value: after the item list
1053
+ * changes, the previously active value is looked up again with `compareWith`,
1054
+ * and gone means no highlight. In a virtual window it holds its absolute
1055
+ * index, because the rendered rows trail `windowStart` and cannot say where a
1056
+ * value sits; a window turning plain drops it. The result is clamped to the
1057
+ * new item space, so the next arrow press never starts from a ghost index.
1058
+ *
1059
+ * A pending open gesture (`pendingIntentState`) resolves here against every
1060
+ * populated item space until an index write clears it, so rows that arrive
1061
+ * in several passes settle on the gesture's target.
1062
+ */
1063
+ private readonly activeIndexState;
756
1064
  /** Current active index. `-1` when no item is highlighted. */
757
1065
  readonly activeIndex: _angular_core.Signal<number>;
1066
+ /**
1067
+ * The highlight plus whether its row is rendered. Structural equal: a window
1068
+ * move that leaves both unchanged notifies nobody.
1069
+ */
1070
+ private readonly highlightPlacement;
1071
+ /**
1072
+ * Index the highlight moved to while its row is not rendered. Armed by the
1073
+ * highlight change alone and cleared when the row renders; the same highlight
1074
+ * leaving the window later stays cleared, so scrolling a virtual list away
1075
+ * never asks to be scrolled back.
1076
+ */
1077
+ private readonly pendingHighlightState;
1078
+ /** Index of an item that should be highlighted but is not in the DOM. */
1079
+ readonly pendingHighlight: _angular_core.Signal<number | null>;
758
1080
  /**
759
1081
  * `activeIndex` always mapped back to an item. `null` when no active index
760
1082
  * or the item is out of rendered range (virtual mode).
@@ -769,12 +1091,51 @@ declare class CngxActiveDescendant {
769
1091
  private readonly highlightedItem;
770
1092
  readonly activeId: _angular_core.Signal<string | null>;
771
1093
  readonly activeValue: _angular_core.Signal<unknown>;
772
- private readonly typeaheadBuffer;
773
- private typeaheadTimer;
1094
+ private readonly typeaheadWalker;
1095
+ /**
1096
+ * `true` while a typeahead term is being typed (the buffer has not reset
1097
+ * yet). A space typed then belongs to the term ("new y" reaches "New
1098
+ * York") instead of activating the highlight. External keyboard hosts read
1099
+ * it to route Space through {@link typeaheadChar}.
1100
+ */
1101
+ readonly typeaheadActive: _angular_core.Signal<boolean>;
774
1102
  constructor();
1103
+ /**
1104
+ * Non-virtual path with no rendered rows yet (a deferred-render panel just
1105
+ * opened, OD5): the option id space does not exist, so a highlight resolves
1106
+ * against nothing and is lost. Remember the gesture as intent -
1107
+ * `activeIndexState` resolves it once the rows render - and report that it
1108
+ * was deferred. The virtual path never defers here; its out-of-window
1109
+ * targets surface through `pendingHighlight` instead.
1110
+ */
1111
+ private deferIfUnrendered;
1112
+ /** Index write of a navigation step; a resolved intent never re-applies after it. */
1113
+ private writeIndex;
1114
+ /**
1115
+ * Moves the highlight to the next item after the active one. Disabled items
1116
+ * are skipped while `skipDisabled` is true; past the last item it wraps to the
1117
+ * first when `loop` is true and stays put otherwise. With no rows it does
1118
+ * nothing: a step inside an empty list is not an open gesture to keep.
1119
+ */
775
1120
  highlightNext(): void;
1121
+ /**
1122
+ * Moves the highlight to the item before the active one. Disabled items are
1123
+ * skipped while `skipDisabled` is true; before the first item it wraps to the
1124
+ * last when `loop` is true and stays put otherwise. With no rows it does
1125
+ * nothing.
1126
+ */
776
1127
  highlightPrev(): void;
1128
+ /**
1129
+ * Moves the highlight to the first enabled item (the first item when
1130
+ * `skipDisabled` is false). Does nothing when no item qualifies.
1131
+ */
777
1132
  highlightFirst(): void;
1133
+ /**
1134
+ * Moves the highlight to the last enabled item (the last item when
1135
+ * `skipDisabled` is false). With a virtual count it targets the last absolute
1136
+ * index even when that item is not rendered yet. Does nothing when no item
1137
+ * qualifies.
1138
+ */
778
1139
  highlightLast(): void;
779
1140
  /**
780
1141
  * Highlight by zero-based index. Out-of-range indices are ignored.
@@ -782,19 +1143,28 @@ declare class CngxActiveDescendant {
782
1143
  */
783
1144
  highlightByIndex(index: number): void;
784
1145
  /**
785
- * Highlight the first rendered item whose value matches (via `Object.is`).
1146
+ * Highlight the first rendered item whose value matches (via `compareWith`).
786
1147
  * No-op if no match. Disabled items are rejected when `skipDisabled()` is
787
1148
  * true. In virtual mode only the rendered window is searched; the resolved
788
1149
  * index is absolute.
789
1150
  */
790
1151
  highlightByValue(value: unknown): void;
791
- /** Clear the highlight. */
1152
+ /** Clear the highlight, including a gesture still pending a deferred render. */
792
1153
  resetHighlight(): void;
793
1154
  /** Emit `activated` with the current item's value. No-op if nothing active. */
794
1155
  activateCurrent(): void;
795
- /** Called by recycler bridges after scrolling the pending index into view. */
1156
+ /**
1157
+ * Drops `pendingHighlight` without waiting for the row to render. Optional:
1158
+ * the directive clears it on its own once the target row renders, and
1159
+ * `connectRecyclerToActiveDescendant` never calls this.
1160
+ */
796
1161
  clearPendingHighlight(): void;
797
1162
  protected handleKeydown(event: KeyboardEvent): void;
1163
+ /** @internal True when `el` renders one of the host's own items. */
1164
+ private isOwnItemElement;
1165
+ /** Descendants that own Enter / Space; `CNGX_NESTED_INTERACTIVE_SELECTOR`. */
1166
+ private readonly nestedInteractive;
1167
+ private handleActivationKey;
798
1168
  private isNavKey;
799
1169
  private dispatchNav;
800
1170
  /**
@@ -804,7 +1174,8 @@ declare class CngxActiveDescendant {
804
1174
  * semantics on a separate listbox.
805
1175
  *
806
1176
  * Consumers should only forward single-character printable keys (`length === 1`,
807
- * non-whitespace). Navigation keys and non-printables must not be forwarded.
1177
+ * non-whitespace), plus a space while {@link typeaheadActive} is `true`.
1178
+ * Navigation keys and non-printables must not be forwarded.
808
1179
  */
809
1180
  typeaheadChar(ch: string): void;
810
1181
  private handleTypeahead;
@@ -825,7 +1196,7 @@ declare class CngxActiveDescendant {
825
1196
  private isRendered;
826
1197
  private scrollActiveIntoView;
827
1198
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxActiveDescendant, never>;
828
- static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxActiveDescendant, "[cngxActiveDescendant]", ["cngxActiveDescendant"], { "items": { "alias": "items"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "typeahead": { "alias": "typeahead"; "required": false; "isSignal": true; }; "typeaheadDebounce": { "alias": "typeaheadDebounce"; "required": false; "isSignal": true; }; "autoHighlightFirst": { "alias": "autoHighlightFirst"; "required": false; "isSignal": true; }; "skipDisabled": { "alias": "skipDisabled"; "required": false; "isSignal": true; }; "virtualCount": { "alias": "virtualCount"; "required": false; "isSignal": true; }; "windowStart": { "alias": "windowStart"; "required": false; "isSignal": true; }; }, { "activated": "activated"; "highlighted": "highlighted"; "typeaheadMissed": "typeaheadMissed"; }, ["registered"], never, true, never>;
1199
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxActiveDescendant, "[cngxActiveDescendant]", ["cngxActiveDescendant"], { "items": { "alias": "items"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "typeahead": { "alias": "typeahead"; "required": false; "isSignal": true; }; "typeaheadDebounce": { "alias": "typeaheadDebounce"; "required": false; "isSignal": true; }; "autoHighlightFirst": { "alias": "autoHighlightFirst"; "required": false; "isSignal": true; }; "skipDisabled": { "alias": "skipDisabled"; "required": false; "isSignal": true; }; "virtualCount": { "alias": "virtualCount"; "required": false; "isSignal": true; }; "windowStart": { "alias": "windowStart"; "required": false; "isSignal": true; }; "typeaheadItems": { "alias": "typeaheadItems"; "required": false; "isSignal": true; }; "compareWith": { "alias": "compareWith"; "required": false; "isSignal": true; }; }, { "activated": "activated"; "highlighted": "highlighted"; "typeaheadMissed": "typeaheadMissed"; }, ["registered"], never, true, never>;
829
1200
  }
830
1201
 
831
1202
  /**
@@ -840,6 +1211,11 @@ declare class CngxActiveDescendant {
840
1211
  * directive makes the preference available in component logic (e.g., to pick
841
1212
  * a different animation strategy or suppress requestAnimationFrame loops).
842
1213
  *
1214
+ * This is the OS preference only. An in-app pick through `provideMotion` /
1215
+ * `injectMotion` (`CNGX_MOTION`, `<html data-motion>`) is not seen here; to
1216
+ * decide on the motion the user actually gets, read `injectEffectiveMotion()`
1217
+ * from `@cngx/core` instead.
1218
+ *
843
1219
  * ### Conditional animation
844
1220
  * ```html
845
1221
  * <div cngxReducedMotion #rm="cngxReducedMotion"
@@ -853,20 +1229,20 @@ declare class CngxActiveDescendant {
853
1229
  * readonly duration = computed(() => this.rm()?.prefersReducedMotion() ? 0 : 300);
854
1230
  * ```
855
1231
  *
856
- * @category common/a11y
857
1232
  * @wcag AA
858
1233
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/motion/reduced-motion.directive.ts
859
- * @since 0.1.0
860
- * <example-url>http://localhost:4200/#/common/a11y/reduced-motion/animation-toggle</example-url>
861
- * <example-url>http://localhost:4200/#/common/a11y/reduced-motion/toast-notifications-motion-aware</example-url>
1234
+ * @since 0.3.0
1235
+ * <example-url>/#/common/a11y/reduced-motion/animation-toggle</example-url>
1236
+ * <example-url>/#/common/a11y/reduced-motion/toast-notifications-motion-aware</example-url>
1237
+ * @axis level atom
862
1238
  */
863
1239
  declare class CngxReducedMotion {
864
- /** `true` when the user's OS is set to prefer reduced motion. Updates reactively. */
1240
+ /** `true` when the user's OS is set to prefer reduced motion (ignores `CNGX_MOTION`). Updates reactively. */
865
1241
  readonly prefersReducedMotion: Signal<boolean>;
866
1242
  constructor();
867
1243
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxReducedMotion, never>;
868
1244
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxReducedMotion, "[cngxReducedMotion]", ["cngxReducedMotion"], {}, {}, never, never, true, never>;
869
1245
  }
870
1246
 
871
- export { CNGX_AD_ITEM, CNGX_FOCUSABLE_SELECTOR, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveAnnouncer, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex };
872
- export type { ActiveDescendantItem, AriaLivePoliteness, CngxAdItemHandle };
1247
+ export { CNGX_AD_ITEM, CNGX_ARIA_EXPANDED_DRIVER, CNGX_FOCUSABLE_SELECTOR, CNGX_FOCUS_RESTORE_DRIVER, CNGX_FOCUS_TRAP_DRIVER, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveAnnouncer, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex, injectScopedLiveRegion };
1248
+ export type { ActiveDescendantItem, AriaLivePoliteness, CngxAdItemHandle, CngxAriaExpandedDriver, CngxFocusRestoreDriver, CngxFocusTrapDriver, CngxPendingAnnouncement, CngxScopedLiveRegion };