@cngx/ui 0.1.0-rc.6 → 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.
- package/README.md +112 -0
- package/a11y/README.md +81 -0
- package/context-menu/README.md +98 -0
- package/data-grid-accordion/README.md +27 -0
- package/feedback/README.md +2 -0
- package/fesm2022/cngx-ui-a11y.mjs +320 -0
- package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
- package/fesm2022/cngx-ui-accordion.mjs +17 -6
- package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-action-button.mjs +5 -2
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
- package/fesm2022/cngx-ui-breadcrumb.mjs +11 -6
- package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
- package/fesm2022/cngx-ui-chart-panel.mjs +429 -0
- package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
- package/fesm2022/cngx-ui-collection.mjs +15 -6
- package/fesm2022/cngx-ui-collection.mjs.map +1 -1
- package/fesm2022/cngx-ui-command-palette.mjs +1005 -0
- package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
- package/fesm2022/cngx-ui-context-menu.mjs +742 -0
- package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
- package/fesm2022/cngx-ui-data-grid-accordion.mjs +88 -18
- package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-feedback.mjs +97 -106
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
- package/fesm2022/cngx-ui-layout.mjs +18 -9
- package/fesm2022/cngx-ui-layout.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-accordion.mjs +9 -9
- package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
- package/fesm2022/cngx-ui-mat-tabs.mjs +64 -70
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-paginator.mjs +18 -8
- package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
- package/fesm2022/cngx-ui-sidenav.mjs +2 -2
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
- package/fesm2022/cngx-ui-skeleton.mjs +20 -7
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
- package/fesm2022/cngx-ui-speak.mjs +2 -2
- package/fesm2022/cngx-ui-speak.mjs.map +1 -1
- package/fesm2022/cngx-ui-stat-card.mjs +618 -0
- package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +30 -12
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
- package/fesm2022/cngx-ui-tabs.mjs +36 -19
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
- package/fesm2022/cngx-ui-timeline.mjs +495 -0
- package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
- package/fesm2022/cngx-ui-toc.mjs +704 -0
- package/fesm2022/cngx-ui-toc.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +2 -2
- package/fesm2022/cngx-ui.mjs.map +1 -1
- package/mat-accordion/README.md +1 -1
- package/mat-tabs/styles/mat-tabs.css +20 -17
- package/package.json +32 -1
- package/skeleton/README.md +2 -0
- package/stepper/README.md +2 -2
- package/timeline/README.md +350 -0
- package/toc/README.md +183 -0
- package/types/cngx-ui-a11y.d.ts +303 -0
- package/types/cngx-ui-accordion.d.ts +9 -4
- package/types/cngx-ui-action-button.d.ts +3 -0
- package/types/cngx-ui-breadcrumb.d.ts +5 -0
- package/types/cngx-ui-chart-panel.d.ts +278 -0
- package/types/cngx-ui-collection.d.ts +12 -3
- package/types/cngx-ui-command-palette.d.ts +451 -0
- package/types/cngx-ui-context-menu.d.ts +467 -0
- package/types/cngx-ui-data-grid-accordion.d.ts +72 -15
- package/types/cngx-ui-feedback.d.ts +71 -18
- package/types/cngx-ui-layout.d.ts +8 -3
- package/types/cngx-ui-mat-accordion.d.ts +3 -3
- package/types/cngx-ui-mat-tabs.d.ts +11 -9
- package/types/cngx-ui-paginator.d.ts +13 -3
- package/types/cngx-ui-skeleton.d.ts +13 -1
- package/types/cngx-ui-stat-card.d.ts +327 -0
- package/types/cngx-ui-stepper.d.ts +15 -2
- package/types/cngx-ui-tabs.d.ts +20 -4
- package/types/cngx-ui-timeline.d.ts +479 -0
- package/types/cngx-ui-toc.d.ts +514 -0
- package/types/cngx-ui.d.ts +1 -1
|
@@ -0,0 +1,514 @@
|
|
|
1
|
+
import * as _cngx_ui_toc from '@cngx/ui/toc';
|
|
2
|
+
import * as _angular_core from '@angular/core';
|
|
3
|
+
import { InjectionToken, Signal, OutputRef, TemplateRef, EnvironmentProviders, Provider } from '@angular/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* One entry in a table-of-contents outline. Tree-shaped: an item may nest
|
|
7
|
+
* `children`, rendered as a nested `<ul>` under its link. `id` targets the
|
|
8
|
+
* section element the link scrolls to (matched via `getElementById`), `label`
|
|
9
|
+
* is the visible link text. Explicit data input - the organism never scans
|
|
10
|
+
* the document for headings in this release (see the deferred auto-discovery
|
|
11
|
+
* phase).
|
|
12
|
+
*
|
|
13
|
+
* @category ui/toc
|
|
14
|
+
* @since 0.1.0
|
|
15
|
+
*/
|
|
16
|
+
interface CngxTocItem {
|
|
17
|
+
/** Section element id this entry links to and scrolls into view. */
|
|
18
|
+
readonly id: string;
|
|
19
|
+
/** Visible link text. */
|
|
20
|
+
readonly label: string;
|
|
21
|
+
/** Nested sub-sections, rendered as an indented child list. */
|
|
22
|
+
readonly children?: readonly CngxTocItem[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Template context handed to the `*cngxTocItem` slot and to a
|
|
26
|
+
* `CNGX_TOC_CONFIG.templates.item` default. `$implicit` is the item so
|
|
27
|
+
* `let-item` binds it positionally; `active` mirrors the item's
|
|
28
|
+
* `aria-current` state; `depth` is the zero-based nesting level for
|
|
29
|
+
* indentation-aware custom markup.
|
|
30
|
+
*
|
|
31
|
+
* @category ui/toc
|
|
32
|
+
* @since 0.1.0
|
|
33
|
+
*/
|
|
34
|
+
interface CngxTocItemContext {
|
|
35
|
+
/** The item being rendered (`let-item`). */
|
|
36
|
+
readonly $implicit: CngxTocItem;
|
|
37
|
+
/** `true` when this item is the active section. */
|
|
38
|
+
readonly active: boolean;
|
|
39
|
+
/** Zero-based nesting depth. */
|
|
40
|
+
readonly depth: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Minimal contract a toc rail exposes to its collaborators (the opt-in
|
|
45
|
+
* `CngxTocRouterSync` fragment directive): the active-section signal it
|
|
46
|
+
* derives, the activation output it emits, and the imperative `scrollTo`
|
|
47
|
+
* it owns. Injected via {@link CNGX_TOC} + `useExisting`, never by injecting
|
|
48
|
+
* the concrete `CngxToc` class - that would create a cyclic type dependency
|
|
49
|
+
* and block the decompose brain/skin split.
|
|
50
|
+
*
|
|
51
|
+
* Direction mirrors `CNGX_SIDENAV`, not `CNGX_BREADCRUMB_ITEMS_SOURCE`: the
|
|
52
|
+
* rail owns the state (`activeId`, `scrollTo`) and the collaborator consumes
|
|
53
|
+
* it, so the toc *provides* the token and the sync directive *injects* it.
|
|
54
|
+
*
|
|
55
|
+
* @category ui/toc
|
|
56
|
+
* @since 0.1.0
|
|
57
|
+
* @relatedTo CngxToc, CngxTocRouterSync
|
|
58
|
+
*/
|
|
59
|
+
interface CngxTocContract {
|
|
60
|
+
/** The section currently most visible, or `null` before the spy resolves. */
|
|
61
|
+
readonly activeId: Signal<string | null>;
|
|
62
|
+
/** Fires when a link is activated (click / Enter), carrying its item. */
|
|
63
|
+
readonly activated: OutputRef<CngxTocItem>;
|
|
64
|
+
/** Scroll the section with this id into view and move focus to it. */
|
|
65
|
+
scrollTo(id: string): void;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Contract token for a toc rail. `CngxToc` provides it via
|
|
69
|
+
* `{ provide: CNGX_TOC, useExisting: CngxToc }`, so a collaborator injects the
|
|
70
|
+
* narrow {@link CngxTocContract} instead of the concrete class.
|
|
71
|
+
*
|
|
72
|
+
* @category ui/toc
|
|
73
|
+
* @since 0.1.0
|
|
74
|
+
* @relatedTo CngxToc, CngxTocRouterSync
|
|
75
|
+
*/
|
|
76
|
+
declare const CNGX_TOC: InjectionToken<CngxTocContract>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* "On this page" navigation rail. Renders a `<nav>` of anchor links from a
|
|
80
|
+
* {@link CngxTocItem} outline, tracks the most-visible section through an
|
|
81
|
+
* internal {@link CngxScrollSpy}, and communicates the active link via
|
|
82
|
+
* `aria-current` inside the `computed()` graph. Nested items render as
|
|
83
|
+
* indented sub-lists; native link semantics and tab order stay intact (a toc
|
|
84
|
+
* is a navigation landmark of links, not a treeview).
|
|
85
|
+
*
|
|
86
|
+
* Composition over configuration: the spy is bound in this component's own
|
|
87
|
+
* template rather than via `hostDirectives`, because the organism - not the
|
|
88
|
+
* consumer - owns the flat id list the spy observes, and `[cngxScrollSpy]` is
|
|
89
|
+
* a required input. The spy resolves its targets through `getElementById`, so
|
|
90
|
+
* its host placement is irrelevant to its function.
|
|
91
|
+
*
|
|
92
|
+
* @category ui/toc
|
|
93
|
+
* @docsKind primary
|
|
94
|
+
* @wcag AA
|
|
95
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc.component.ts
|
|
96
|
+
* @since 0.1.0
|
|
97
|
+
* @relatedTo CngxScrollSpy, CngxTocRouterSync, CngxSidenav
|
|
98
|
+
* <example-url>http://localhost:4200/#/ui/toc/basic/on-this-page-rail</example-url>
|
|
99
|
+
* <example-url>http://localhost:4200/#/ui/toc/auto/heading-auto-discovery</example-url>
|
|
100
|
+
*/
|
|
101
|
+
declare class CngxToc implements CngxTocContract {
|
|
102
|
+
private readonly doc;
|
|
103
|
+
private readonly cfg;
|
|
104
|
+
private readonly reducedMotion;
|
|
105
|
+
private readonly isBrowser;
|
|
106
|
+
/**
|
|
107
|
+
* The outline to render. Tree-shaped; nested `children` become sub-lists.
|
|
108
|
+
* Ignored when `[autoDiscover]` is set - the headings under `contentRoot`
|
|
109
|
+
* become the outline instead.
|
|
110
|
+
*/
|
|
111
|
+
readonly items: _angular_core.InputSignal<readonly CngxTocItem[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Derive the outline from the heading elements under `contentRoot` instead
|
|
114
|
+
* of a hand-maintained `[items]` array. Headings nest by their level
|
|
115
|
+
* (`h2 > h3`), and a heading with no `id` gets a slugified one written onto
|
|
116
|
+
* it so the link can target it. Scans once after the first render; call
|
|
117
|
+
* {@link refresh} after you inject or remove sections at runtime.
|
|
118
|
+
*/
|
|
119
|
+
readonly autoDiscover: _angular_core.InputSignalWithTransform<boolean, unknown>;
|
|
120
|
+
/** Which headings `[autoDiscover]` collects, in CSS-selector form. */
|
|
121
|
+
readonly headingSelector: _angular_core.InputSignal<string>;
|
|
122
|
+
/**
|
|
123
|
+
* CSS selector for the scroll container the spy observes. `null` (default)
|
|
124
|
+
* uses the viewport. Forwarded to the spy's `[root]`; also the root the
|
|
125
|
+
* `[autoDiscover]` scan walks for headings.
|
|
126
|
+
*/
|
|
127
|
+
readonly contentRoot: _angular_core.InputSignal<string | null>;
|
|
128
|
+
/** Root margin forwarded to the spy. Defaults to the config cascade. */
|
|
129
|
+
readonly rootMargin: _angular_core.InputSignal<string>;
|
|
130
|
+
/** Minimum visibility ratio forwarded to the spy. Defaults to the config cascade. */
|
|
131
|
+
readonly threshold: _angular_core.InputSignal<number>;
|
|
132
|
+
/** Fires when a link is activated (click / Enter). */
|
|
133
|
+
readonly activated: _angular_core.OutputEmitterRef<CngxTocItem>;
|
|
134
|
+
private readonly spy;
|
|
135
|
+
private readonly itemSlot;
|
|
136
|
+
/** Headings discovered by the last `[autoDiscover]` scan. */
|
|
137
|
+
private readonly discovered;
|
|
138
|
+
/** The outline actually rendered: the discovered headings when `[autoDiscover]` is on, else `[items]`. */
|
|
139
|
+
protected readonly resolvedItems: Signal<readonly CngxTocItem[]>;
|
|
140
|
+
/** Accessible name of the `nav` landmark, from the config cascade. */
|
|
141
|
+
protected readonly navLabel: Signal<string>;
|
|
142
|
+
/**
|
|
143
|
+
* Depth-first flat id list feeding `[cngxScrollSpy]`. `equal: idsEqual`
|
|
144
|
+
* keeps the reference stable across same-shape re-sets so a re-render does
|
|
145
|
+
* not re-create the observer.
|
|
146
|
+
*/
|
|
147
|
+
protected readonly flatIds: Signal<string[]>;
|
|
148
|
+
constructor();
|
|
149
|
+
/**
|
|
150
|
+
* The active section, or `null`. `viewChild` is a view query, so `spy()` is
|
|
151
|
+
* `undefined` during the creation pass; `?? null` makes that an explicit
|
|
152
|
+
* value every downstream computed is defined at.
|
|
153
|
+
*/
|
|
154
|
+
readonly activeId: Signal<string | null>;
|
|
155
|
+
/**
|
|
156
|
+
* Ancestor-id chain of the active leaf - the parent links that get
|
|
157
|
+
* `data-active-trail`. Same `equal` as `flatIds`: an array-valued computed
|
|
158
|
+
* feeding an attribute binding must not allocate a fresh array every spy
|
|
159
|
+
* tick (reference_signal_architecture Equality Rule).
|
|
160
|
+
*/
|
|
161
|
+
protected readonly activeTrail: Signal<readonly string[]>;
|
|
162
|
+
/** Resolved item template: instance slot -> config default -> built-in label. */
|
|
163
|
+
protected readonly resolvedItemTpl: Signal<_angular_core.TemplateRef<_cngx_ui_toc.CngxTocItemContext> | null>;
|
|
164
|
+
/**
|
|
165
|
+
* Scroll the section with this id into view and move focus to it. Honours
|
|
166
|
+
* `prefers-reduced-motion` - the configured `scrollBehavior` is swapped for
|
|
167
|
+
* `'auto'` (instant) whenever reduced motion is requested. A visual-only
|
|
168
|
+
* jump is a silent state change for screen-reader users, so focus follows
|
|
169
|
+
* the scroll (Pillar 2).
|
|
170
|
+
*/
|
|
171
|
+
scrollTo(id: string): void;
|
|
172
|
+
/** Click / Enter handler: takes over the native anchor jump, scrolls, and announces the activation. */
|
|
173
|
+
protected handleActivate(item: CngxTocItem, event?: Event): void;
|
|
174
|
+
/**
|
|
175
|
+
* Move focus to the scrolled-to section. `preventScroll` keeps `focus()`
|
|
176
|
+
* from fighting the smooth `scrollIntoView` above with a second instant
|
|
177
|
+
* jump. Section elements are consumer-owned DOM, so `tabindex="-1"` is set
|
|
178
|
+
* imperatively only when the element is not focusable by default and the
|
|
179
|
+
* consumer set no `tabindex` - an author-set value is never overwritten.
|
|
180
|
+
* That persistent attribute on borrowed DOM is the entry's tracked debt.
|
|
181
|
+
*/
|
|
182
|
+
private focusTarget;
|
|
183
|
+
/** Elements that take focus without an author `tabindex`. */
|
|
184
|
+
private isFocusableByDefault;
|
|
185
|
+
/** Depth-first collect of every id in the outline. */
|
|
186
|
+
private collectIds;
|
|
187
|
+
/** Ancestor ids of the active leaf (path from root, excluding the leaf itself). */
|
|
188
|
+
private computeTrail;
|
|
189
|
+
/** Root-to-target id path, or `null` when the id is not in the outline. */
|
|
190
|
+
private pathTo;
|
|
191
|
+
/**
|
|
192
|
+
* Re-run the `[autoDiscover]` heading scan. No-op unless `[autoDiscover]` is
|
|
193
|
+
* set and we are on the browser. Call it after injecting or removing sections
|
|
194
|
+
* at runtime - discovery is one-shot by design, not a live observer.
|
|
195
|
+
*/
|
|
196
|
+
refresh(): void;
|
|
197
|
+
/** Walk the headings under `contentRoot` into a level-nested outline. */
|
|
198
|
+
private scanHeadings;
|
|
199
|
+
/** Numeric level of a heading element (`h2` -> 2). Non-heading matches read as level 1. */
|
|
200
|
+
private headingLevel;
|
|
201
|
+
/** Visible text of a heading, collapsed to a single spaced line. */
|
|
202
|
+
private headingLabel;
|
|
203
|
+
/**
|
|
204
|
+
* Return the heading's id, generating and writing a slug when it has none.
|
|
205
|
+
* The write mutates consumer-owned DOM (tracked debt); an author-set id is
|
|
206
|
+
* kept verbatim. Collisions against prior scan ids and existing document ids
|
|
207
|
+
* get a `-2`, `-3`, ... suffix.
|
|
208
|
+
*/
|
|
209
|
+
private ensureId;
|
|
210
|
+
/** Lowercase, strip diacritics-free non-alphanumerics to hyphens, collapse and trim. */
|
|
211
|
+
private slugify;
|
|
212
|
+
/** Freeze a mutable node into a CngxTocItem, dropping empty children arrays. */
|
|
213
|
+
private freeze;
|
|
214
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxToc, never>;
|
|
215
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxToc, "cngx-toc", never, { "items": { "alias": "items"; "required": false; "isSignal": true; }; "autoDiscover": { "alias": "autoDiscover"; "required": false; "isSignal": true; }; "headingSelector": { "alias": "headingSelector"; "required": false; "isSignal": true; }; "contentRoot": { "alias": "contentRoot"; "required": false; "isSignal": true; }; "rootMargin": { "alias": "rootMargin"; "required": false; "isSignal": true; }; "threshold": { "alias": "threshold"; "required": false; "isSignal": true; }; }, { "activated": "activated"; }, ["itemSlot"], never, true, never>;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Deep-links a `CngxToc` into the URL fragment. Opt-in via
|
|
220
|
+
* `[cngxTocRouterSync]` on the same host as `<cngx-toc>`: activating a link
|
|
221
|
+
* writes `#<section-id>` (replacing the history entry, so a scroll-driven rail
|
|
222
|
+
* never floods the back stack), and a deep link like `/guide#pricing` scrolls
|
|
223
|
+
* to that section once on load.
|
|
224
|
+
*
|
|
225
|
+
* Reaches the rail through the {@link CNGX_TOC} contract token, never the
|
|
226
|
+
* concrete `CngxToc` class. The activation subscription is torn down with the
|
|
227
|
+
* directive via `takeUntilDestroyed` - an `OutputRef` subscription would
|
|
228
|
+
* otherwise outlive route changes. Without `@angular/router` the directive
|
|
229
|
+
* dev-warns once and no-ops.
|
|
230
|
+
*
|
|
231
|
+
* @category ui/toc
|
|
232
|
+
* @docsKind primary
|
|
233
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-router-sync.directive.ts
|
|
234
|
+
* @since 0.1.0
|
|
235
|
+
* @relatedTo CngxToc, CNGX_TOC
|
|
236
|
+
* <example-url>http://localhost:4200/#/ui/toc/router/fragment-deep-link</example-url>
|
|
237
|
+
*/
|
|
238
|
+
declare class CngxTocRouterSync {
|
|
239
|
+
private readonly toc;
|
|
240
|
+
private readonly router;
|
|
241
|
+
private readonly route;
|
|
242
|
+
constructor();
|
|
243
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxTocRouterSync, never>;
|
|
244
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxTocRouterSync, "[cngxTocRouterSync]", ["cngxTocRouterSync"], {}, {}, never, never, true, never>;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Per-item template slot for `CngxToc`. Project an `<ng-template cngxTocItem>`
|
|
249
|
+
* inside `<cngx-toc>` to replace the built-in plain-label rendering with
|
|
250
|
+
* custom markup - the `let-` variables come out typed via
|
|
251
|
+
* `ngTemplateContextGuard`:
|
|
252
|
+
*
|
|
253
|
+
* ```html
|
|
254
|
+
* <cngx-toc [items]="toc" contentRoot="#article">
|
|
255
|
+
* <ng-template cngxTocItem let-item let-active="active" let-depth="depth">
|
|
256
|
+
* <span [class.is-active]="active">{{ item.label }}</span>
|
|
257
|
+
* @if (depth === 0) { <cngx-badge>{{ item.children?.length }}</cngx-badge> }
|
|
258
|
+
* </ng-template>
|
|
259
|
+
* </cngx-toc>
|
|
260
|
+
* ```
|
|
261
|
+
*
|
|
262
|
+
* Named `CngxTocItemSlot` (not `*Directive`) per the repo's no-artifact-suffix
|
|
263
|
+
* rule; the selector stays `cngxTocItem`, which is what consumers write.
|
|
264
|
+
* Resolves ahead of `CNGX_TOC_CONFIG.templates.item` and the built-in label.
|
|
265
|
+
*
|
|
266
|
+
* @category ui/toc
|
|
267
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/toc-item-slot.ts
|
|
268
|
+
* @since 0.1.0
|
|
269
|
+
* @relatedTo CngxToc
|
|
270
|
+
* <example-url>http://localhost:4200/#/ui/toc/slots/custom-item-template</example-url>
|
|
271
|
+
*/
|
|
272
|
+
declare class CngxTocItemSlot {
|
|
273
|
+
readonly templateRef: TemplateRef<CngxTocItemContext>;
|
|
274
|
+
static ngTemplateContextGuard(_dir: CngxTocItemSlot, ctx: unknown): ctx is CngxTocItemContext;
|
|
275
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxTocItemSlot, never>;
|
|
276
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxTocItemSlot, "ng-template[cngxTocItem]", ["cngxTocItem"], {}, {}, never, never, true, never>;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* App-wide cascade for the table-of-contents organism's ARIA label, its
|
|
281
|
+
* scroll behaviour, the `CngxScrollSpy` defaults it forwards, and the default
|
|
282
|
+
* item template.
|
|
283
|
+
*
|
|
284
|
+
* Resolution priority (high -> low):
|
|
285
|
+
* 1. Per-instance Input binding (e.g. `[contentRoot]`, `*cngxTocItem`).
|
|
286
|
+
* 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`
|
|
287
|
+
* (component-scoped override).
|
|
288
|
+
* 3. `provideTocConfig(...)` at the application root.
|
|
289
|
+
* 4. Library defaults (English; merged in via `CNGX_TOC_DEFAULTS`).
|
|
290
|
+
*
|
|
291
|
+
* Every key is optional - partial overrides deep-merge with the library
|
|
292
|
+
* defaults, so consumers declare only the keys they want to override.
|
|
293
|
+
*
|
|
294
|
+
* @category ui/toc
|
|
295
|
+
* @since 0.1.0
|
|
296
|
+
*/
|
|
297
|
+
interface CngxTocConfig {
|
|
298
|
+
/**
|
|
299
|
+
* ARIA-string fallback for the `nav` landmark. A per-instance
|
|
300
|
+
* `[navLabel]`-equivalent binding is not exposed; the landmark name always
|
|
301
|
+
* comes from this cascade, English by default.
|
|
302
|
+
*/
|
|
303
|
+
readonly ariaLabels?: {
|
|
304
|
+
/** Accessible name of the `nav` landmark that wraps the link list. */
|
|
305
|
+
readonly nav?: string;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* Scroll behaviour used when a link is activated and the section is
|
|
309
|
+
* brought into view. `'smooth'` by default; swapped to `'auto'` (instant)
|
|
310
|
+
* at runtime whenever `prefers-reduced-motion: reduce` matches, regardless
|
|
311
|
+
* of this value.
|
|
312
|
+
*/
|
|
313
|
+
readonly scrollBehavior?: 'auto' | 'smooth';
|
|
314
|
+
/**
|
|
315
|
+
* Defaults forwarded to the internal `CngxScrollSpy`. Per-instance
|
|
316
|
+
* `[rootMargin]` / `[threshold]` inputs still win; this only moves the
|
|
317
|
+
* cascade default. `contentRoot` has no cascade default - it is viewport
|
|
318
|
+
* (`null`) unless bound per instance.
|
|
319
|
+
*/
|
|
320
|
+
readonly spy?: {
|
|
321
|
+
/** Root margin passed to the spy's `IntersectionObserver`. */
|
|
322
|
+
readonly rootMargin?: string;
|
|
323
|
+
/** Minimum visibility ratio for a section to become active. */
|
|
324
|
+
readonly threshold?: number;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Global default template slots. The item slot resolves three-stage:
|
|
328
|
+
* per-instance `*cngxTocItem` -> this `templates.item` -> the built-in
|
|
329
|
+
* plain-label rendering. Set it to give every un-slotted toc the same
|
|
330
|
+
* custom item markup.
|
|
331
|
+
*/
|
|
332
|
+
readonly templates?: {
|
|
333
|
+
/** Default per-item template; overridden per instance by `*cngxTocItem`. */
|
|
334
|
+
readonly item?: TemplateRef<CngxTocItemContext>;
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* App-wide configuration cascade for the table-of-contents organism. Resolves
|
|
340
|
+
* in priority order:
|
|
341
|
+
*
|
|
342
|
+
* 1. Per-instance Input binding.
|
|
343
|
+
* 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.
|
|
344
|
+
* 3. `provideTocConfig(...)` at the application root.
|
|
345
|
+
* 4. Library defaults (this token's `factory`).
|
|
346
|
+
*
|
|
347
|
+
* `providedIn: 'root'` with a default factory means consumers never need to
|
|
348
|
+
* provide the token explicitly - `inject(CNGX_TOC_CONFIG)` always resolves.
|
|
349
|
+
* Consumers who want overrides call `provideTocConfig(...)` in
|
|
350
|
+
* `bootstrapApplication` providers (root cascade) or `provideTocConfigAt(...)`
|
|
351
|
+
* in a component's `viewProviders` (sub-tree cascade).
|
|
352
|
+
*
|
|
353
|
+
* @category ui/toc
|
|
354
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/ui/toc/config/toc.config.defaults.ts
|
|
355
|
+
* @since 0.1.0
|
|
356
|
+
*/
|
|
357
|
+
declare const CNGX_TOC_CONFIG: InjectionToken<CngxTocConfig>;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Discriminated-union shape returned by the toc config features -
|
|
361
|
+
* `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`, and
|
|
362
|
+
* `withTocTemplates`. The
|
|
363
|
+
* reducer in `provideTocConfig` / `provideTocConfigAt` matches on `kind` and
|
|
364
|
+
* merges `payload` into the corresponding config sub-tree. Mirrors
|
|
365
|
+
* `CngxBreadcrumbConfigFeature` so the consumer's mental model is one across
|
|
366
|
+
* feature areas.
|
|
367
|
+
*
|
|
368
|
+
* @category ui/toc
|
|
369
|
+
* @since 0.1.0
|
|
370
|
+
*/
|
|
371
|
+
type CngxTocConfigFeature = {
|
|
372
|
+
readonly kind: 'ariaLabels';
|
|
373
|
+
readonly payload: NonNullable<CngxTocConfig['ariaLabels']>;
|
|
374
|
+
} | {
|
|
375
|
+
readonly kind: 'scrollBehavior';
|
|
376
|
+
readonly payload: {
|
|
377
|
+
readonly scrollBehavior: NonNullable<CngxTocConfig['scrollBehavior']>;
|
|
378
|
+
};
|
|
379
|
+
} | {
|
|
380
|
+
readonly kind: 'spy';
|
|
381
|
+
readonly payload: NonNullable<CngxTocConfig['spy']>;
|
|
382
|
+
} | {
|
|
383
|
+
readonly kind: 'templates';
|
|
384
|
+
readonly payload: NonNullable<CngxTocConfig['templates']>;
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* Application-root configuration cascade for the toc organism. Pass any
|
|
388
|
+
* combination of `withTocAriaLabels`, `withTocScrollBehavior`, `withTocSpy`,
|
|
389
|
+
* and `withTocTemplates` features in `bootstrapApplication`'s providers array.
|
|
390
|
+
*
|
|
391
|
+
* Resolution priority (high -> low):
|
|
392
|
+
* 1. Per-instance Input binding.
|
|
393
|
+
* 2. `provideTocConfigAt(...)` in a parent component's `viewProviders`.
|
|
394
|
+
* 3. `provideTocConfig(...)` at the application root.
|
|
395
|
+
* 4. Library defaults (`CNGX_TOC_DEFAULTS`).
|
|
396
|
+
*
|
|
397
|
+
* The provider deep-merges supplied features with the library defaults so
|
|
398
|
+
* consumers only declare keys they want to override.
|
|
399
|
+
*
|
|
400
|
+
* ```ts
|
|
401
|
+
* bootstrapApplication(AppComponent, {
|
|
402
|
+
* providers: [
|
|
403
|
+
* provideTocConfig(
|
|
404
|
+
* withTocAriaLabels({ nav: 'On this page' }),
|
|
405
|
+
* withTocScrollBehavior('smooth'),
|
|
406
|
+
* ),
|
|
407
|
+
* ],
|
|
408
|
+
* });
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* @category ui/toc
|
|
412
|
+
* @since 0.1.0
|
|
413
|
+
*/
|
|
414
|
+
declare function provideTocConfig(...features: CngxTocConfigFeature[]): EnvironmentProviders;
|
|
415
|
+
/**
|
|
416
|
+
* Component-scoped configuration cascade for the toc organism. Pass any
|
|
417
|
+
* combination of feature factories in a parent component's `viewProviders`
|
|
418
|
+
* array.
|
|
419
|
+
*
|
|
420
|
+
* Unlike `provideTocConfig` (root-only), `provideTocConfigAt` injects the
|
|
421
|
+
* parent injector's `CNGX_TOC_CONFIG` value (resolves through the priority
|
|
422
|
+
* chain) and deep-merges the supplied features on top. Descendant toc
|
|
423
|
+
* instances see the merged config; sibling sub-trees keep the inherited value.
|
|
424
|
+
*
|
|
425
|
+
* ```ts
|
|
426
|
+
* @Component({
|
|
427
|
+
* viewProviders: [provideTocConfigAt(withTocScrollBehavior('auto'))],
|
|
428
|
+
* template: '<cngx-toc [items]="toc" contentRoot="#article" />',
|
|
429
|
+
* })
|
|
430
|
+
* class Guide {}
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* @category ui/toc
|
|
434
|
+
* @since 0.1.0
|
|
435
|
+
*/
|
|
436
|
+
declare function provideTocConfigAt(...features: CngxTocConfigFeature[]): Provider[];
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Override the toc's ARIA-string fallback - the accessible name of the `nav`
|
|
440
|
+
* landmark that wraps the link list (default `'On this page'`).
|
|
441
|
+
*
|
|
442
|
+
* ```ts
|
|
443
|
+
* provideTocConfig(withTocAriaLabels({ nav: 'Auf dieser Seite' }));
|
|
444
|
+
* ```
|
|
445
|
+
*
|
|
446
|
+
* @category ui/toc
|
|
447
|
+
* @since 0.1.0
|
|
448
|
+
*/
|
|
449
|
+
declare function withTocAriaLabels(payload: NonNullable<CngxTocConfig['ariaLabels']>): CngxTocConfigFeature;
|
|
450
|
+
/**
|
|
451
|
+
* Set the app-wide default scroll behaviour used when a link is activated.
|
|
452
|
+
* `'smooth'` by default; the organism still swaps to `'auto'` at runtime
|
|
453
|
+
* whenever `prefers-reduced-motion: reduce` matches, so this only chooses the
|
|
454
|
+
* motion-allowed behaviour.
|
|
455
|
+
*
|
|
456
|
+
* ```ts
|
|
457
|
+
* provideTocConfig(withTocScrollBehavior('auto'));
|
|
458
|
+
* ```
|
|
459
|
+
*
|
|
460
|
+
* @category ui/toc
|
|
461
|
+
* @since 0.1.0
|
|
462
|
+
*/
|
|
463
|
+
declare function withTocScrollBehavior(scrollBehavior: NonNullable<CngxTocConfig['scrollBehavior']>): CngxTocConfigFeature;
|
|
464
|
+
/**
|
|
465
|
+
* Move the app-wide `CngxScrollSpy` defaults - the `rootMargin` and
|
|
466
|
+
* `threshold` the rail forwards to its internal spy. Per-instance
|
|
467
|
+
* `[rootMargin]` / `[threshold]` bindings still win; this only sets the
|
|
468
|
+
* cascade default (e.g. a fixed-header offset every toc should share).
|
|
469
|
+
*
|
|
470
|
+
* ```ts
|
|
471
|
+
* provideTocConfig(withTocSpy({ rootMargin: '-80px 0px 0px 0px' }));
|
|
472
|
+
* ```
|
|
473
|
+
*
|
|
474
|
+
* @category ui/toc
|
|
475
|
+
* @since 0.1.0
|
|
476
|
+
*/
|
|
477
|
+
declare function withTocSpy(payload: NonNullable<CngxTocConfig['spy']>): CngxTocConfigFeature;
|
|
478
|
+
/**
|
|
479
|
+
* Register a global default item template. Resolves after a per-instance
|
|
480
|
+
* `*cngxTocItem` slot and before the built-in plain-label rendering, so every
|
|
481
|
+
* un-slotted toc renders the same custom item markup.
|
|
482
|
+
*
|
|
483
|
+
* ```ts
|
|
484
|
+
* @Component({
|
|
485
|
+
* viewProviders: [provideTocConfigAt(withTocTemplates({ item: myItemTpl }))],
|
|
486
|
+
* })
|
|
487
|
+
* ```
|
|
488
|
+
*
|
|
489
|
+
* @category ui/toc
|
|
490
|
+
* @since 0.1.0
|
|
491
|
+
*/
|
|
492
|
+
declare function withTocTemplates(payload: NonNullable<CngxTocConfig['templates']>): CngxTocConfigFeature;
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Convenience accessor for the toc configuration cascade. Runs in injection
|
|
496
|
+
* context; resolves through the priority chain (per-instance Input ->
|
|
497
|
+
* `provideTocConfigAt` -> `provideTocConfig` -> library defaults). Equivalent
|
|
498
|
+
* to `inject(CNGX_TOC_CONFIG)` - the helper exists so consumers don't import
|
|
499
|
+
* the token directly. Mirrors `injectBreadcrumbConfig`.
|
|
500
|
+
*
|
|
501
|
+
* ```ts
|
|
502
|
+
* export class CngxToc {
|
|
503
|
+
* private readonly cfg = injectTocConfig();
|
|
504
|
+
* protected readonly navLabel = computed(() => this.cfg.ariaLabels?.nav ?? 'On this page');
|
|
505
|
+
* }
|
|
506
|
+
* ```
|
|
507
|
+
*
|
|
508
|
+
* @category ui/toc
|
|
509
|
+
* @since 0.1.0
|
|
510
|
+
*/
|
|
511
|
+
declare function injectTocConfig(): CngxTocConfig;
|
|
512
|
+
|
|
513
|
+
export { CNGX_TOC, CNGX_TOC_CONFIG, CngxToc, CngxTocItemSlot, CngxTocRouterSync, injectTocConfig, provideTocConfig, provideTocConfigAt, withTocAriaLabels, withTocScrollBehavior, withTocSpy, withTocTemplates };
|
|
514
|
+
export type { CngxTocConfig, CngxTocConfigFeature, CngxTocContract, CngxTocItem, CngxTocItemContext };
|
package/types/cngx-ui.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { CngxFailed, CngxPending, CngxSucceeded } from '@cngx/common/interactive
|
|
|
13
13
|
* @cngx/ui/layout – CngxStack, CngxGrid
|
|
14
14
|
* @cngx/ui/overlay – CngxOverlay, CngxOverlayRef
|
|
15
15
|
*/
|
|
16
|
-
/** @internal
|
|
16
|
+
/** @internal - replaced at publish time, not part of consumer API. */
|
|
17
17
|
declare const VERSION: _cngx_utils.Version;
|
|
18
18
|
|
|
19
19
|
export { VERSION };
|