@cngx/ui 0.1.0-rc.5 → 0.1.0-rc.7

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 (79) hide show
  1. package/README.md +112 -0
  2. package/a11y/README.md +81 -0
  3. package/context-menu/README.md +98 -0
  4. package/data-grid-accordion/README.md +27 -0
  5. package/feedback/README.md +2 -0
  6. package/fesm2022/cngx-ui-a11y.mjs +320 -0
  7. package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
  8. package/fesm2022/cngx-ui-accordion.mjs +19 -8
  9. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  10. package/fesm2022/cngx-ui-action-button.mjs +5 -2
  11. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  12. package/fesm2022/cngx-ui-breadcrumb.mjs +11 -6
  13. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  14. package/fesm2022/cngx-ui-chart-panel.mjs +429 -0
  15. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
  16. package/fesm2022/cngx-ui-collection.mjs +15 -6
  17. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  18. package/fesm2022/cngx-ui-command-palette.mjs +1005 -0
  19. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
  20. package/fesm2022/cngx-ui-context-menu.mjs +742 -0
  21. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
  22. package/fesm2022/cngx-ui-data-grid-accordion.mjs +90 -20
  23. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  24. package/fesm2022/cngx-ui-feedback.mjs +97 -106
  25. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  26. package/fesm2022/cngx-ui-layout.mjs +18 -9
  27. package/fesm2022/cngx-ui-layout.mjs.map +1 -1
  28. package/fesm2022/cngx-ui-mat-accordion.mjs +9 -9
  29. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  30. package/fesm2022/cngx-ui-mat-tabs.mjs +64 -70
  31. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  32. package/fesm2022/cngx-ui-paginator.mjs +18 -8
  33. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  34. package/fesm2022/cngx-ui-sidenav.mjs +2 -2
  35. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  36. package/fesm2022/cngx-ui-skeleton.mjs +20 -7
  37. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  38. package/fesm2022/cngx-ui-speak.mjs +2 -2
  39. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  40. package/fesm2022/cngx-ui-stat-card.mjs +618 -0
  41. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
  42. package/fesm2022/cngx-ui-stepper.mjs +38 -19
  43. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  44. package/fesm2022/cngx-ui-tabs.mjs +36 -19
  45. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  46. package/fesm2022/cngx-ui-timeline.mjs +495 -0
  47. package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
  48. package/fesm2022/cngx-ui-toc.mjs +704 -0
  49. package/fesm2022/cngx-ui-toc.mjs.map +1 -0
  50. package/fesm2022/cngx-ui.mjs +2 -2
  51. package/fesm2022/cngx-ui.mjs.map +1 -1
  52. package/mat-accordion/README.md +1 -1
  53. package/mat-tabs/styles/mat-tabs.css +20 -17
  54. package/package.json +32 -1
  55. package/skeleton/README.md +2 -0
  56. package/stepper/README.md +2 -2
  57. package/timeline/README.md +350 -0
  58. package/toc/README.md +183 -0
  59. package/types/cngx-ui-a11y.d.ts +303 -0
  60. package/types/cngx-ui-accordion.d.ts +9 -4
  61. package/types/cngx-ui-action-button.d.ts +3 -0
  62. package/types/cngx-ui-breadcrumb.d.ts +5 -0
  63. package/types/cngx-ui-chart-panel.d.ts +278 -0
  64. package/types/cngx-ui-collection.d.ts +12 -3
  65. package/types/cngx-ui-command-palette.d.ts +451 -0
  66. package/types/cngx-ui-context-menu.d.ts +467 -0
  67. package/types/cngx-ui-data-grid-accordion.d.ts +72 -15
  68. package/types/cngx-ui-feedback.d.ts +71 -18
  69. package/types/cngx-ui-layout.d.ts +8 -3
  70. package/types/cngx-ui-mat-accordion.d.ts +3 -3
  71. package/types/cngx-ui-mat-tabs.d.ts +11 -9
  72. package/types/cngx-ui-paginator.d.ts +13 -3
  73. package/types/cngx-ui-skeleton.d.ts +13 -1
  74. package/types/cngx-ui-stat-card.d.ts +327 -0
  75. package/types/cngx-ui-stepper.d.ts +18 -4
  76. package/types/cngx-ui-tabs.d.ts +20 -4
  77. package/types/cngx-ui-timeline.d.ts +479 -0
  78. package/types/cngx-ui-toc.d.ts +514 -0
  79. package/types/cngx-ui.d.ts +1 -1
@@ -0,0 +1,704 @@
1
+ import { DOCUMENT, isPlatformBrowser, NgTemplateOutlet } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, inject, TemplateRef, Directive, PLATFORM_ID, input, booleanAttribute, output, viewChild, contentChild, signal, computed, effect, ViewEncapsulation, ChangeDetectionStrategy, Component, afterNextRender, makeEnvironmentProviders } from '@angular/core';
4
+ import { injectMediaQuery, CngxScrollSpy } from '@cngx/common/layout';
5
+ import { outputToObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';
6
+ import { Router, ActivatedRoute } from '@angular/router';
7
+
8
+ /**
9
+ * Library defaults for the toc configuration cascade. English by default per
10
+ * `feedback_en_default_locale`; locale overrides ride the `withTocAriaLabels`
11
+ * feature. The spy defaults (`rootMargin` / `threshold`) mirror
12
+ * `CngxScrollSpy`'s own input defaults so an un-configured toc tracks
13
+ * scrolling identically to a hand-wired spy.
14
+ *
15
+ * Exported for intra-lib consumers (`provideTocConfig` deep-merges with this
16
+ * base) but **NOT** re-exported from `public-api.ts` - downstream consumers
17
+ * reach the defaults via `inject(CNGX_TOC_CONFIG)` so `provideTocConfig` /
18
+ * `provideTocConfigAt` overrides take precedence.
19
+ *
20
+ * @internal
21
+ */
22
+ const CNGX_TOC_DEFAULTS = {
23
+ ariaLabels: {
24
+ nav: 'On this page',
25
+ },
26
+ scrollBehavior: 'smooth',
27
+ spy: {
28
+ rootMargin: '0px',
29
+ threshold: 0.3,
30
+ },
31
+ };
32
+ /**
33
+ * App-wide configuration cascade for the table-of-contents organism. Resolves
34
+ * in priority order:
35
+ *
36
+ * 1. Per-instance Input binding.
37
+ * 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.
38
+ * 3. `provideTocConfig(...)` at the application root.
39
+ * 4. Library defaults (this token's `factory`).
40
+ *
41
+ * `providedIn: 'root'` with a default factory means consumers never need to
42
+ * provide the token explicitly - `inject(CNGX_TOC_CONFIG)` always resolves.
43
+ * Consumers who want overrides call `provideTocConfig(...)` in
44
+ * `bootstrapApplication` providers (root cascade) or `provideTocConfigAt(...)`
45
+ * in a component's `viewProviders` (sub-tree cascade).
46
+ *
47
+ * @category ui/toc
48
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/config/toc.config.defaults.ts
49
+ * @since 0.1.0
50
+ */
51
+ const CNGX_TOC_CONFIG = new InjectionToken('CNGX_TOC_CONFIG', {
52
+ providedIn: 'root',
53
+ factory: () => CNGX_TOC_DEFAULTS,
54
+ });
55
+
56
+ /**
57
+ * Convenience accessor for the toc configuration cascade. Runs in injection
58
+ * context; resolves through the priority chain (per-instance Input ->
59
+ * `provideTocConfigAt` -> `provideTocConfig` -> library defaults). Equivalent
60
+ * to `inject(CNGX_TOC_CONFIG)` - the helper exists so consumers don't import
61
+ * the token directly. Mirrors `injectBreadcrumbConfig`.
62
+ *
63
+ * ```ts
64
+ * export class CngxToc {
65
+ * private readonly cfg = injectTocConfig();
66
+ * protected readonly navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page');
67
+ * }
68
+ * ```
69
+ *
70
+ * @category ui/toc
71
+ * @since 0.1.0
72
+ */
73
+ function injectTocConfig() {
74
+ return inject(CNGX_TOC_CONFIG);
75
+ }
76
+
77
+ /**
78
+ * Per-item template slot for `CngxToc`. Project an `<ng-template cngxTocItem>`
79
+ * inside `<cngx-toc>` to replace the built-in plain-label rendering with
80
+ * custom markup - the `let-` variables come out typed via
81
+ * `ngTemplateContextGuard`:
82
+ *
83
+ * ```html
84
+ * <cngx-toc [items]="toc" contentRoot="#article">
85
+ * <ng-template cngxTocItem let-item let-active="active" let-depth="depth">
86
+ * <span [class.is-active]="active">{{ item.label }}</span>
87
+ * @if (depth === 0) { <cngx-badge>{{ item.children?.length }}</cngx-badge> }
88
+ * </ng-template>
89
+ * </cngx-toc>
90
+ * ```
91
+ *
92
+ * Named `CngxTocItemSlot` (not `*Directive`) per the repo's no-artifact-suffix
93
+ * rule; the selector stays `cngxTocItem`, which is what consumers write.
94
+ * Resolves ahead of `CNGX_TOC_CONFIG.templates.item` and the built-in label.
95
+ *
96
+ * @category ui/toc
97
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-item-slot.ts
98
+ * @since 0.1.0
99
+ * @relatedTo CngxToc
100
+ * <example-url>http://localhost:4200/#/ui/toc/slots/custom-item-template</example-url>
101
+ */
102
+ class CngxTocItemSlot {
103
+ templateRef = inject(TemplateRef);
104
+ static ngTemplateContextGuard(_dir, ctx) {
105
+ return true;
106
+ }
107
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTocItemSlot, deps: [], target: i0.ɵɵFactoryTarget.Directive });
108
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTocItemSlot, isStandalone: true, selector: "ng-template[cngxTocItem]", exportAs: ["cngxTocItem"], ngImport: i0 });
109
+ }
110
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTocItemSlot, decorators: [{
111
+ type: Directive,
112
+ args: [{
113
+ selector: 'ng-template[cngxTocItem]',
114
+ standalone: true,
115
+ exportAs: 'cngxTocItem',
116
+ }]
117
+ }] });
118
+
119
+ /**
120
+ * Contract token for a toc rail. `CngxToc` provides it via
121
+ * `{ provide: CNGX_TOC, useExisting: CngxToc }`, so a collaborator injects the
122
+ * narrow {@link CngxTocContract} instead of the concrete class.
123
+ *
124
+ * @category ui/toc
125
+ * @since 0.1.0
126
+ * @relatedTo CngxToc, CngxTocRouterSync
127
+ */
128
+ const CNGX_TOC = new InjectionToken('CNGX_TOC');
129
+
130
+ /** Shared empty result so the no-active-section trail is reference-stable. */
131
+ const EMPTY_IDS = [];
132
+ /** Shared empty outline so the pre-scan / no-headings state is reference-stable. */
133
+ const EMPTY_ITEMS = [];
134
+ /** Element-wise string-array compare - the shared comparator for both the flat-id list and the active trail. */
135
+ function idsEqual(a, b) {
136
+ return a.length === b.length && a.every((value, index) => value === b[index]);
137
+ }
138
+ /**
139
+ * Structural compare of two discovered outlines (id + label + nesting). Guards
140
+ * the `discovered` signal so a re-scan of unchanged headings keeps the same
141
+ * reference and never re-stamps the outline outlet.
142
+ */
143
+ function itemsEqual(a, b) {
144
+ if (a.length !== b.length) {
145
+ return false;
146
+ }
147
+ for (let i = 0; i < a.length; i++) {
148
+ const x = a[i];
149
+ const y = b[i];
150
+ if (x.id !== y.id || x.label !== y.label) {
151
+ return false;
152
+ }
153
+ if (!itemsEqual(x.children ?? EMPTY_ITEMS, y.children ?? EMPTY_ITEMS)) {
154
+ return false;
155
+ }
156
+ }
157
+ return true;
158
+ }
159
+ /**
160
+ * "On this page" navigation rail. Renders a `<nav>` of anchor links from a
161
+ * {@link CngxTocItem} outline, tracks the most-visible section through an
162
+ * internal {@link CngxScrollSpy}, and communicates the active link via
163
+ * `aria-current` inside the `computed()` graph. Nested items render as
164
+ * indented sub-lists; native link semantics and tab order stay intact (a toc
165
+ * is a navigation landmark of links, not a treeview).
166
+ *
167
+ * Composition over configuration: the spy is bound in this component's own
168
+ * template rather than via `hostDirectives`, because the organism - not the
169
+ * consumer - owns the flat id list the spy observes, and `[cngxScrollSpy]` is
170
+ * a required input. The spy resolves its targets through `getElementById`, so
171
+ * its host placement is irrelevant to its function.
172
+ *
173
+ * @category ui/toc
174
+ * @docsKind primary
175
+ * @wcag AA
176
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc.component.ts
177
+ * @since 0.1.0
178
+ * @relatedTo CngxScrollSpy, CngxTocRouterSync, CngxSidenav
179
+ * <example-url>http://localhost:4200/#/ui/toc/basic/on-this-page-rail</example-url>
180
+ * <example-url>http://localhost:4200/#/ui/toc/auto/heading-auto-discovery</example-url>
181
+ */
182
+ class CngxToc {
183
+ doc = inject(DOCUMENT);
184
+ cfg = injectTocConfig();
185
+ reducedMotion = injectMediaQuery('(prefers-reduced-motion: reduce)');
186
+ isBrowser = isPlatformBrowser(inject(PLATFORM_ID));
187
+ /**
188
+ * The outline to render. Tree-shaped; nested `children` become sub-lists.
189
+ * Ignored when `[autoDiscover]` is set - the headings under `contentRoot`
190
+ * become the outline instead.
191
+ */
192
+ items = input(EMPTY_ITEMS, ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
193
+ /**
194
+ * Derive the outline from the heading elements under `contentRoot` instead
195
+ * of a hand-maintained `[items]` array. Headings nest by their level
196
+ * (`h2 > h3`), and a heading with no `id` gets a slugified one written onto
197
+ * it so the link can target it. Scans once after the first render; call
198
+ * {@link refresh} after you inject or remove sections at runtime.
199
+ */
200
+ autoDiscover = input(false, { ...(ngDevMode ? { debugName: "autoDiscover" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
201
+ /** Which headings `[autoDiscover]` collects, in CSS-selector form. */
202
+ headingSelector = input('h2, h3', ...(ngDevMode ? [{ debugName: "headingSelector" }] : /* istanbul ignore next */ []));
203
+ /**
204
+ * CSS selector for the scroll container the spy observes. `null` (default)
205
+ * uses the viewport. Forwarded to the spy's `[root]`; also the root the
206
+ * `[autoDiscover]` scan walks for headings.
207
+ */
208
+ contentRoot = input(null, ...(ngDevMode ? [{ debugName: "contentRoot" }] : /* istanbul ignore next */ []));
209
+ /** Root margin forwarded to the spy. Defaults to the config cascade. */
210
+ rootMargin = input(this.cfg.spy?.rootMargin ?? '0px', ...(ngDevMode ? [{ debugName: "rootMargin" }] : /* istanbul ignore next */ []));
211
+ /** Minimum visibility ratio forwarded to the spy. Defaults to the config cascade. */
212
+ threshold = input(this.cfg.spy?.threshold ?? 0.3, ...(ngDevMode ? [{ debugName: "threshold" }] : /* istanbul ignore next */ []));
213
+ /** Fires when a link is activated (click / Enter). */
214
+ activated = output();
215
+ spy = viewChild(CngxScrollSpy, ...(ngDevMode ? [{ debugName: "spy" }] : /* istanbul ignore next */ []));
216
+ itemSlot = contentChild(CngxTocItemSlot, ...(ngDevMode ? [{ debugName: "itemSlot" }] : /* istanbul ignore next */ []));
217
+ /** Headings discovered by the last `[autoDiscover]` scan. */
218
+ discovered = signal(EMPTY_ITEMS, { ...(ngDevMode ? { debugName: "discovered" } : /* istanbul ignore next */ {}), equal: itemsEqual });
219
+ /** The outline actually rendered: the discovered headings when `[autoDiscover]` is on, else `[items]`. */
220
+ resolvedItems = computed(() => this.autoDiscover() ? this.discovered() : this.items(), ...(ngDevMode ? [{ debugName: "resolvedItems" }] : /* istanbul ignore next */ []));
221
+ /** Accessible name of the `nav` landmark, from the config cascade. */
222
+ navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page', ...(ngDevMode ? [{ debugName: "navLabel" }] : /* istanbul ignore next */ []));
223
+ /**
224
+ * Depth-first flat id list feeding `[cngxScrollSpy]`. `equal: idsEqual`
225
+ * keeps the reference stable across same-shape re-sets so a re-render does
226
+ * not re-create the observer.
227
+ */
228
+ flatIds = computed(() => this.collectIds(this.resolvedItems()), { ...(ngDevMode ? { debugName: "flatIds" } : /* istanbul ignore next */ {}), equal: idsEqual });
229
+ constructor() {
230
+ // Re-scan whenever the discovery inputs change. The DOM read + discovered
231
+ // write are deferred to a microtask so no signal is written during effect
232
+ // execution (Pillar 1) and the just-rendered content has settled - the same
233
+ // queueMicrotask discipline the panel-lifecycle focus restore uses.
234
+ effect(() => {
235
+ if (!this.autoDiscover()) {
236
+ return;
237
+ }
238
+ this.contentRoot();
239
+ this.headingSelector();
240
+ queueMicrotask(() => this.refresh());
241
+ });
242
+ }
243
+ /**
244
+ * The active section, or `null`. `viewChild` is a view query, so `spy()` is
245
+ * `undefined` during the creation pass; `?? null` makes that an explicit
246
+ * value every downstream computed is defined at.
247
+ */
248
+ activeId = computed(() => this.spy()?.activeId() ?? null, ...(ngDevMode ? [{ debugName: "activeId" }] : /* istanbul ignore next */ []));
249
+ /**
250
+ * Ancestor-id chain of the active leaf - the parent links that get
251
+ * `data-active-trail`. Same `equal` as `flatIds`: an array-valued computed
252
+ * feeding an attribute binding must not allocate a fresh array every spy
253
+ * tick (reference_signal_architecture Equality Rule).
254
+ */
255
+ activeTrail = computed(() => this.computeTrail(), { ...(ngDevMode ? { debugName: "activeTrail" } : /* istanbul ignore next */ {}), equal: idsEqual });
256
+ /** Resolved item template: instance slot -> config default -> built-in label. */
257
+ resolvedItemTpl = computed(() => this.itemSlot()?.templateRef ?? this.cfg.templates?.item ?? null, ...(ngDevMode ? [{ debugName: "resolvedItemTpl" }] : /* istanbul ignore next */ []));
258
+ /**
259
+ * Scroll the section with this id into view and move focus to it. Honours
260
+ * `prefers-reduced-motion` - the configured `scrollBehavior` is swapped for
261
+ * `'auto'` (instant) whenever reduced motion is requested. A visual-only
262
+ * jump is a silent state change for screen-reader users, so focus follows
263
+ * the scroll (Pillar 2).
264
+ */
265
+ scrollTo(id) {
266
+ const target = this.doc.getElementById(id);
267
+ if (target === null) {
268
+ return;
269
+ }
270
+ const behavior = this.reducedMotion() ? 'auto' : (this.cfg.scrollBehavior ?? 'smooth');
271
+ target.scrollIntoView({ behavior });
272
+ this.focusTarget(target);
273
+ }
274
+ /** Click / Enter handler: takes over the native anchor jump, scrolls, and announces the activation. */
275
+ handleActivate(item, event) {
276
+ event?.preventDefault();
277
+ this.scrollTo(item.id);
278
+ this.activated.emit(item);
279
+ }
280
+ /**
281
+ * Move focus to the scrolled-to section. `preventScroll` keeps `focus()`
282
+ * from fighting the smooth `scrollIntoView` above with a second instant
283
+ * jump. Section elements are consumer-owned DOM, so `tabindex="-1"` is set
284
+ * imperatively only when the element is not focusable by default and the
285
+ * consumer set no `tabindex` - an author-set value is never overwritten.
286
+ * That persistent attribute on borrowed DOM is the entry's tracked debt.
287
+ */
288
+ focusTarget(target) {
289
+ const needsTabindex = !target.hasAttribute('tabindex') && !this.isFocusableByDefault(target);
290
+ if (needsTabindex) {
291
+ target.setAttribute('tabindex', '-1');
292
+ }
293
+ target.focus({ preventScroll: true });
294
+ }
295
+ /** Elements that take focus without an author `tabindex`. */
296
+ isFocusableByDefault(el) {
297
+ return /^(a|button|input|select|textarea|summary|iframe)$/i.test(el.tagName);
298
+ }
299
+ /** Depth-first collect of every id in the outline. */
300
+ collectIds(items, acc = []) {
301
+ for (const item of items) {
302
+ acc.push(item.id);
303
+ if (item.children?.length) {
304
+ this.collectIds(item.children, acc);
305
+ }
306
+ }
307
+ return acc;
308
+ }
309
+ /** Ancestor ids of the active leaf (path from root, excluding the leaf itself). */
310
+ computeTrail() {
311
+ const id = this.activeId();
312
+ if (id === null) {
313
+ return EMPTY_IDS;
314
+ }
315
+ const path = this.pathTo(id, this.resolvedItems());
316
+ return path ? path.slice(0, -1) : EMPTY_IDS;
317
+ }
318
+ /** Root-to-target id path, or `null` when the id is not in the outline. */
319
+ pathTo(target, items) {
320
+ for (const item of items) {
321
+ if (item.id === target) {
322
+ return [item.id];
323
+ }
324
+ const childPath = item.children?.length ? this.pathTo(target, item.children) : null;
325
+ if (childPath) {
326
+ return [item.id, ...childPath];
327
+ }
328
+ }
329
+ return null;
330
+ }
331
+ /**
332
+ * Re-run the `[autoDiscover]` heading scan. No-op unless `[autoDiscover]` is
333
+ * set and we are on the browser. Call it after injecting or removing sections
334
+ * at runtime - discovery is one-shot by design, not a live observer.
335
+ */
336
+ refresh() {
337
+ if (!this.autoDiscover() || !this.isBrowser) {
338
+ return;
339
+ }
340
+ this.discovered.set(this.scanHeadings());
341
+ }
342
+ /** Walk the headings under `contentRoot` into a level-nested outline. */
343
+ scanHeadings() {
344
+ const rootSelector = this.contentRoot();
345
+ let root = this.doc;
346
+ if (rootSelector) {
347
+ const matched = this.doc.querySelector(rootSelector);
348
+ // A set-but-unmatched root scans nothing, not the whole document -
349
+ // falling back to `doc` would sweep site chrome into the outline.
350
+ if (matched === null) {
351
+ return EMPTY_ITEMS;
352
+ }
353
+ root = matched;
354
+ }
355
+ const headings = Array.from(root.querySelectorAll(this.headingSelector()));
356
+ if (headings.length === 0) {
357
+ return EMPTY_ITEMS;
358
+ }
359
+ const roots = [];
360
+ const stack = [];
361
+ const used = new Set();
362
+ for (const el of headings) {
363
+ const level = this.headingLevel(el);
364
+ const node = { id: this.ensureId(el, used), label: this.headingLabel(el), children: [] };
365
+ while (stack.length > 0 && stack[stack.length - 1].level >= level) {
366
+ stack.pop();
367
+ }
368
+ const parent = stack[stack.length - 1];
369
+ if (parent) {
370
+ parent.node.children.push(node);
371
+ }
372
+ else {
373
+ roots.push(node);
374
+ }
375
+ stack.push({ level, node });
376
+ }
377
+ return roots.map((node) => this.freeze(node));
378
+ }
379
+ /** Numeric level of a heading element (`h2` -> 2). Non-heading matches read as level 1. */
380
+ headingLevel(el) {
381
+ const match = /^h([1-6])$/i.exec(el.tagName);
382
+ return match ? Number(match[1]) : 1;
383
+ }
384
+ /** Visible text of a heading, collapsed to a single spaced line. */
385
+ headingLabel(el) {
386
+ return (el.textContent ?? '').replace(/\s+/g, ' ').trim();
387
+ }
388
+ /**
389
+ * Return the heading's id, generating and writing a slug when it has none.
390
+ * The write mutates consumer-owned DOM (tracked debt); an author-set id is
391
+ * kept verbatim. Collisions against prior scan ids and existing document ids
392
+ * get a `-2`, `-3`, ... suffix.
393
+ */
394
+ ensureId(el, used) {
395
+ if (el.id) {
396
+ used.add(el.id);
397
+ return el.id;
398
+ }
399
+ const base = this.slugify(this.headingLabel(el)) || 'section';
400
+ let candidate = base;
401
+ let n = 2;
402
+ while (used.has(candidate) || this.doc.getElementById(candidate) !== null) {
403
+ candidate = `${base}-${n++}`;
404
+ }
405
+ used.add(candidate);
406
+ el.setAttribute('id', candidate);
407
+ return candidate;
408
+ }
409
+ /** Lowercase, strip diacritics-free non-alphanumerics to hyphens, collapse and trim. */
410
+ slugify(text) {
411
+ return text
412
+ .toLowerCase()
413
+ .replace(/[^a-z0-9]+/g, '-')
414
+ .replace(/^-+|-+$/g, '');
415
+ }
416
+ /** Freeze a mutable node into a CngxTocItem, dropping empty children arrays. */
417
+ freeze(node) {
418
+ if (node.children.length === 0) {
419
+ return { id: node.id, label: node.label };
420
+ }
421
+ return { id: node.id, label: node.label, children: node.children.map((child) => this.freeze(child)) };
422
+ }
423
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToc, deps: [], target: i0.ɵɵFactoryTarget.Component });
424
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxToc, isStandalone: true, selector: "cngx-toc", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, autoDiscover: { classPropertyName: "autoDiscover", publicName: "autoDiscover", isSignal: true, isRequired: false, transformFunction: null }, headingSelector: { classPropertyName: "headingSelector", publicName: "headingSelector", isSignal: true, isRequired: false, transformFunction: null }, contentRoot: { classPropertyName: "contentRoot", publicName: "contentRoot", isSignal: true, isRequired: false, transformFunction: null }, rootMargin: { classPropertyName: "rootMargin", publicName: "rootMargin", isSignal: true, isRequired: false, transformFunction: null }, threshold: { classPropertyName: "threshold", publicName: "threshold", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { activated: "activated" }, providers: [{ provide: CNGX_TOC, useExisting: CngxToc }], queries: [{ propertyName: "itemSlot", first: true, predicate: CngxTocItemSlot, descendants: true, isSignal: true }], viewQueries: [{ propertyName: "spy", first: true, predicate: CngxScrollSpy, descendants: true, isSignal: true }], ngImport: i0, template: "<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n", styles: ["cngx-toc{--cngx-toc-indent: var(--cngx-space-lg, 1rem);--cngx-toc-gap: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-block: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-inline: var(--cngx-space-sm, .5rem);display:block}.cngx-toc__nav{display:block}.cngx-toc__list{display:flex;flex-direction:column;gap:var(--cngx-toc-gap);margin:0;padding:0;list-style:none}.cngx-toc__item .cngx-toc__list{margin-block-start:var(--cngx-toc-gap);padding-inline-start:var(--cngx-toc-indent)}.cngx-toc__link{display:flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-block:var(--cngx-toc-link-pad-block);padding-inline:var(--cngx-toc-link-pad-inline);border-inline-start:var(--cngx-toc-rail-width, 2px) solid transparent;color:var(--cngx-toc-color, var(--cngx-color-text-muted, oklch(.5 .01 250)));line-height:1.4;text-decoration:none}.cngx-toc__link:hover{color:var(--cngx-toc-color-hover, var(--cngx-color-text, oklch(.2 .01 250)))}.cngx-toc__link:focus-visible{outline:var(--cngx-toc-focus-ring-width, 2px) solid var(--cngx-toc-focus-ring, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-toc__link[aria-current]{border-inline-start-color:var(--cngx-toc-rail-active, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-toc-color-active, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:var(--cngx-toc-weight-active, 600)}.cngx-toc__item[data-active-trail]>.cngx-toc__link{color:var(--cngx-toc-color-trail, var(--cngx-color-text, oklch(.2 .01 250)))}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxScrollSpy, selector: "[cngxScrollSpy]", inputs: ["cngxScrollSpy", "threshold", "root", "rootMargin"], outputs: ["activeIdChange"], exportAs: ["cngxScrollSpy"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
425
+ }
426
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToc, decorators: [{
427
+ type: Component,
428
+ args: [{ selector: 'cngx-toc', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [NgTemplateOutlet, CngxScrollSpy], providers: [{ provide: CNGX_TOC, useExisting: CngxToc }], template: "<nav\n class=\"cngx-toc__nav\"\n [attr.aria-label]=\"navLabel()\"\n [cngxScrollSpy]=\"flatIds()\"\n [root]=\"contentRoot()\"\n [rootMargin]=\"rootMargin()\"\n [threshold]=\"threshold()\"\n>\n <ng-container *ngTemplateOutlet=\"list; context: { $implicit: resolvedItems(), depth: 0 }\" />\n</nav>\n\n<ng-template #list let-nodes let-depth=\"depth\">\n <ul class=\"cngx-toc__list\" [style.--cngx-toc-depth]=\"depth\">\n @for (item of nodes; track item.id) {\n <li class=\"cngx-toc__item\" [attr.data-active-trail]=\"activeTrail().includes(item.id) ? '' : null\">\n <a\n class=\"cngx-toc__link\"\n [href]=\"'#' + item.id\"\n [attr.aria-current]=\"activeId() === item.id ? 'location' : null\"\n (click)=\"handleActivate(item, $event)\"\n >\n @if (resolvedItemTpl(); as tpl) {\n <ng-container\n *ngTemplateOutlet=\"\n tpl;\n context: { $implicit: item, active: activeId() === item.id, depth: depth }\n \"\n />\n } @else {\n {{ item.label }}\n }\n </a>\n @if (item.children?.length) {\n <ng-container\n *ngTemplateOutlet=\"list; context: { $implicit: item.children, depth: depth + 1 }\"\n />\n }\n </li>\n }\n </ul>\n</ng-template>\n", styles: ["cngx-toc{--cngx-toc-indent: var(--cngx-space-lg, 1rem);--cngx-toc-gap: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-block: var(--cngx-space-xs, .25rem);--cngx-toc-link-pad-inline: var(--cngx-space-sm, .5rem);display:block}.cngx-toc__nav{display:block}.cngx-toc__list{display:flex;flex-direction:column;gap:var(--cngx-toc-gap);margin:0;padding:0;list-style:none}.cngx-toc__item .cngx-toc__list{margin-block-start:var(--cngx-toc-gap);padding-inline-start:var(--cngx-toc-indent)}.cngx-toc__link{display:flex;align-items:center;min-block-size:var(--cngx-target-min, 0px);padding-block:var(--cngx-toc-link-pad-block);padding-inline:var(--cngx-toc-link-pad-inline);border-inline-start:var(--cngx-toc-rail-width, 2px) solid transparent;color:var(--cngx-toc-color, var(--cngx-color-text-muted, oklch(.5 .01 250)));line-height:1.4;text-decoration:none}.cngx-toc__link:hover{color:var(--cngx-toc-color-hover, var(--cngx-color-text, oklch(.2 .01 250)))}.cngx-toc__link:focus-visible{outline:var(--cngx-toc-focus-ring-width, 2px) solid var(--cngx-toc-focus-ring, var(--cngx-color-primary, oklch(.66 .19 50)));outline-offset:2px}.cngx-toc__link[aria-current]{border-inline-start-color:var(--cngx-toc-rail-active, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-toc-color-active, var(--cngx-color-primary, oklch(.66 .19 50)));font-weight:var(--cngx-toc-weight-active, 600)}.cngx-toc__item[data-active-trail]>.cngx-toc__link{color:var(--cngx-toc-color-trail, var(--cngx-color-text, oklch(.2 .01 250)))}\n"] }]
429
+ }], ctorParameters: () => [], propDecorators: { items: [{ type: i0.Input, args: [{ isSignal: true, alias: "items", required: false }] }], autoDiscover: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoDiscover", required: false }] }], headingSelector: [{ type: i0.Input, args: [{ isSignal: true, alias: "headingSelector", required: false }] }], contentRoot: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentRoot", required: false }] }], rootMargin: [{ type: i0.Input, args: [{ isSignal: true, alias: "rootMargin", required: false }] }], threshold: [{ type: i0.Input, args: [{ isSignal: true, alias: "threshold", required: false }] }], activated: [{ type: i0.Output, args: ["activated"] }], spy: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxScrollSpy), { isSignal: true }] }], itemSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxTocItemSlot), { isSignal: true }] }] } });
430
+
431
+ /**
432
+ * Dev-warning emitted when `@angular/router` is absent. A deliberate small
433
+ * local copy of the `@cngx/common/layout` kernel's warning rather than a
434
+ * shared import - sharing would force the helper onto a `public-api.ts`, and
435
+ * `warn*` matches no approved public-API prefix (same call the tabs and
436
+ * sidenav sync directives make).
437
+ *
438
+ * @internal
439
+ */
440
+ function warnRouterAbsent(directive, enables) {
441
+ console.warn(`${directive}: no Router available - directive is a no-op. ` +
442
+ `Provide @angular/router via provideRouter(...) to enable ${enables}.`);
443
+ }
444
+ /**
445
+ * Deep-links a `CngxToc` into the URL fragment. Opt-in via
446
+ * `[cngxTocRouterSync]` on the same host as `<cngx-toc>`: activating a link
447
+ * writes `#<section-id>` (replacing the history entry, so a scroll-driven rail
448
+ * never floods the back stack), and a deep link like `/guide#pricing` scrolls
449
+ * to that section once on load.
450
+ *
451
+ * Reaches the rail through the {@link CNGX_TOC} contract token, never the
452
+ * concrete `CngxToc` class. The activation subscription is torn down with the
453
+ * directive via `takeUntilDestroyed` - an `OutputRef` subscription would
454
+ * otherwise outlive route changes. Without `@angular/router` the directive
455
+ * dev-warns once and no-ops.
456
+ *
457
+ * @category ui/toc
458
+ * @docsKind primary
459
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-router-sync.directive.ts
460
+ * @since 0.1.0
461
+ * @relatedTo CngxToc, CNGX_TOC
462
+ * <example-url>http://localhost:4200/#/ui/toc/router/fragment-deep-link</example-url>
463
+ */
464
+ class CngxTocRouterSync {
465
+ toc = inject(CNGX_TOC, { host: true });
466
+ router = inject(Router, { optional: true });
467
+ route = inject(ActivatedRoute, { optional: true });
468
+ constructor() {
469
+ if (!this.router || !this.route) {
470
+ afterNextRender(() => warnRouterAbsent('CngxTocRouterSync', 'fragment deep-linking'));
471
+ return;
472
+ }
473
+ const router = this.router;
474
+ // Write the fragment on every activation. replaceUrl keeps a scroll-driven
475
+ // rail from pushing a history entry per section.
476
+ outputToObservable(this.toc.activated)
477
+ .pipe(takeUntilDestroyed())
478
+ .subscribe((item) => {
479
+ void router.navigate([], { fragment: item.id, replaceUrl: true });
480
+ });
481
+ // One-shot deep-link scroll: read the fragment present at load and bring
482
+ // that section into view after the first render.
483
+ const fragment = toSignal(this.route.fragment, {
484
+ initialValue: this.route.snapshot.fragment,
485
+ });
486
+ afterNextRender(() => {
487
+ const initial = fragment();
488
+ if (initial) {
489
+ this.toc.scrollTo(initial);
490
+ }
491
+ });
492
+ }
493
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTocRouterSync, deps: [], target: i0.ɵɵFactoryTarget.Directive });
494
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxTocRouterSync, isStandalone: true, selector: "[cngxTocRouterSync]", exportAs: ["cngxTocRouterSync"], ngImport: i0 });
495
+ }
496
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTocRouterSync, decorators: [{
497
+ type: Directive,
498
+ args: [{
499
+ selector: '[cngxTocRouterSync]',
500
+ exportAs: 'cngxTocRouterSync',
501
+ standalone: true,
502
+ }]
503
+ }], ctorParameters: () => [] });
504
+
505
+ /**
506
+ * Override the toc's ARIA-string fallback - the accessible name of the `nav`
507
+ * landmark that wraps the link list (default `'On this page'`).
508
+ *
509
+ * ```ts
510
+ * provideTocConfig(withTocAriaLabels({ nav: 'Auf dieser Seite' }));
511
+ * ```
512
+ *
513
+ * @category ui/toc
514
+ * @since 0.1.0
515
+ */
516
+ function withTocAriaLabels(payload) {
517
+ return { kind: 'ariaLabels', payload };
518
+ }
519
+ /**
520
+ * Set the app-wide default scroll behaviour used when a link is activated.
521
+ * `'smooth'` by default; the organism still swaps to `'auto'` at runtime
522
+ * whenever `prefers-reduced-motion: reduce` matches, so this only chooses the
523
+ * motion-allowed behaviour.
524
+ *
525
+ * ```ts
526
+ * provideTocConfig(withTocScrollBehavior('auto'));
527
+ * ```
528
+ *
529
+ * @category ui/toc
530
+ * @since 0.1.0
531
+ */
532
+ function withTocScrollBehavior(scrollBehavior) {
533
+ return { kind: 'scrollBehavior', payload: { scrollBehavior } };
534
+ }
535
+ /**
536
+ * Move the app-wide `CngxScrollSpy` defaults - the `rootMargin` and
537
+ * `threshold` the rail forwards to its internal spy. Per-instance
538
+ * `[rootMargin]` / `[threshold]` bindings still win; this only sets the
539
+ * cascade default (e.g. a fixed-header offset every toc should share).
540
+ *
541
+ * ```ts
542
+ * provideTocConfig(withTocSpy({ rootMargin: '-80px 0px 0px 0px' }));
543
+ * ```
544
+ *
545
+ * @category ui/toc
546
+ * @since 0.1.0
547
+ */
548
+ function withTocSpy(payload) {
549
+ return { kind: 'spy', payload };
550
+ }
551
+ /**
552
+ * Register a global default item template. Resolves after a per-instance
553
+ * `*cngxTocItem` slot and before the built-in plain-label rendering, so every
554
+ * un-slotted toc renders the same custom item markup.
555
+ *
556
+ * ```ts
557
+ * @Component({
558
+ * viewProviders: [provideTocConfigAt(withTocTemplates({ item: myItemTpl }))],
559
+ * })
560
+ * ```
561
+ *
562
+ * @category ui/toc
563
+ * @since 0.1.0
564
+ */
565
+ function withTocTemplates(payload) {
566
+ return { kind: 'templates', payload };
567
+ }
568
+
569
+ /**
570
+ * Reduces a list of feature objects into a partial config - last write wins
571
+ * per sub-tree. Inner objects are spread-merged so partial overrides compose
572
+ * cleanly with prior writes.
573
+ *
574
+ * @internal
575
+ */
576
+ function reduceFeatures(features) {
577
+ const out = {};
578
+ for (const f of features) {
579
+ switch (f.kind) {
580
+ case 'ariaLabels':
581
+ out.ariaLabels = { ...out.ariaLabels, ...f.payload };
582
+ break;
583
+ case 'scrollBehavior':
584
+ out.scrollBehavior = f.payload.scrollBehavior;
585
+ break;
586
+ case 'spy':
587
+ out.spy = { ...out.spy, ...f.payload };
588
+ break;
589
+ case 'templates':
590
+ out.templates = { ...out.templates, ...f.payload };
591
+ break;
592
+ }
593
+ }
594
+ return out;
595
+ }
596
+ /**
597
+ * Deep merge: the nested sub-trees (`ariaLabels` / `spy` / `templates`) are
598
+ * spread-merged so a partial fills in missing keys without nuking unrelated
599
+ * sub-trees; the flat scalar `scrollBehavior` takes the partial when present,
600
+ * else the base. Inner objects are flat (one level), so a single spread per
601
+ * key suffices.
602
+ *
603
+ * @internal
604
+ */
605
+ function mergeConfig(base, partial) {
606
+ return {
607
+ ariaLabels: { ...base.ariaLabels, ...partial.ariaLabels },
608
+ scrollBehavior: partial.scrollBehavior ?? base.scrollBehavior,
609
+ spy: { ...base.spy, ...partial.spy },
610
+ templates: { ...base.templates, ...partial.templates },
611
+ };
612
+ }
613
+ /**
614
+ * Application-root configuration cascade for the toc organism. Pass any
615
+ * combination of `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`,
616
+ * and `withTocTemplates` features in `bootstrapApplication`'s providers array.
617
+ *
618
+ * Resolution priority (high -> low):
619
+ * 1. Per-instance Input binding.
620
+ * 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.
621
+ * 3. `provideTocConfig(...)` at the application root.
622
+ * 4. Library defaults (`CNGX_TOC_DEFAULTS`).
623
+ *
624
+ * The provider deep-merges supplied features with the library defaults so
625
+ * consumers only declare keys they want to override.
626
+ *
627
+ * ```ts
628
+ * bootstrapApplication(AppComponent, {
629
+ * providers: [
630
+ * provideTocConfig(
631
+ * withTocAriaLabels({ nav: 'On this page' }),
632
+ * withTocScrollBehavior('smooth'),
633
+ * ),
634
+ * ],
635
+ * });
636
+ * ```
637
+ *
638
+ * @category ui/toc
639
+ * @since 0.1.0
640
+ */
641
+ function provideTocConfig(...features) {
642
+ // Empty-features: skip the override so the root factory's CNGX_TOC_DEFAULTS
643
+ // reference flows through untouched. A fresh mergeConfig(...) would allocate
644
+ // identical content under a new reference and bust identity comparisons.
645
+ if (features.length === 0) {
646
+ return makeEnvironmentProviders([]);
647
+ }
648
+ const partial = reduceFeatures(features);
649
+ return makeEnvironmentProviders([
650
+ {
651
+ provide: CNGX_TOC_CONFIG,
652
+ useValue: mergeConfig(CNGX_TOC_DEFAULTS, partial),
653
+ },
654
+ ]);
655
+ }
656
+ /**
657
+ * Component-scoped configuration cascade for the toc organism. Pass any
658
+ * combination of feature factories in a parent component's `viewProviders`
659
+ * array.
660
+ *
661
+ * Unlike `provideTocConfig` (root-only), `provideTocConfigAt` injects the
662
+ * parent injector's `CNGX_TOC_CONFIG` value (resolves through the priority
663
+ * chain) and deep-merges the supplied features on top. Descendant toc
664
+ * instances see the merged config; sibling sub-trees keep the inherited value.
665
+ *
666
+ * ```ts
667
+ * @Component({
668
+ * viewProviders: [provideTocConfigAt(withTocScrollBehavior('auto'))],
669
+ * template: '<cngx-toc [items]="toc" contentRoot="#article" />',
670
+ * })
671
+ * class Guide {}
672
+ * ```
673
+ *
674
+ * @category ui/toc
675
+ * @since 0.1.0
676
+ */
677
+ function provideTocConfigAt(...features) {
678
+ // Empty-features call: parent value flows through untouched. Skipping the
679
+ // factory preserves reference identity through the sub-tree.
680
+ if (features.length === 0) {
681
+ return [];
682
+ }
683
+ const partial = reduceFeatures(features);
684
+ return [
685
+ {
686
+ provide: CNGX_TOC_CONFIG,
687
+ useFactory: () => {
688
+ const parent = inject(CNGX_TOC_CONFIG, { skipSelf: true });
689
+ return mergeConfig(parent, partial);
690
+ },
691
+ },
692
+ ];
693
+ }
694
+
695
+ /**
696
+ * @module @cngx/ui/toc
697
+ */
698
+
699
+ /**
700
+ * Generated bundle index. Do not edit.
701
+ */
702
+
703
+ export { CNGX_TOC, CNGX_TOC_CONFIG, CngxToc, CngxTocItemSlot, CngxTocRouterSync, injectTocConfig, provideTocConfig, provideTocConfigAt, withTocAriaLabels, withTocScrollBehavior, withTocSpy, withTocTemplates };
704
+ //# sourceMappingURL=cngx-ui-toc.mjs.map