@cngx/common 0.1.0-rc.8 → 0.1.0-rc.9
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/command/README.md +29 -0
- package/data/README.md +5 -2
- package/fesm2022/cngx-common-a11y.mjs +403 -84
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +16 -13
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +4 -3
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +55 -36
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +60 -6
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +185 -37
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +86 -48
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +27 -23
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +324 -122
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +129 -26
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +947 -33
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +300 -166
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +251 -80
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +16 -10
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/layout/README.md +16 -0
- package/package.json +20 -7
- package/popover/README.md +40 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +91 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -4
- package/theming/components/cngx-popover-sheet.css +402 -0
- package/theming/components/cngx-popover.css +10 -6
- package/types/cngx-common-a11y.d.ts +167 -14
- package/types/cngx-common-chart.d.ts +8 -7
- package/types/cngx-common-command.d.ts +19 -2
- package/types/cngx-common-data.d.ts +164 -26
- package/types/cngx-common-dialog.d.ts +3 -7
- package/types/cngx-common-interactive.d.ts +52 -17
- package/types/cngx-common-layout.d.ts +37 -5
- package/types/cngx-common-popover.d.ts +353 -13
- package/types/cngx-common-stepper.d.ts +168 -129
- package/types/cngx-common-tabs.d.ts +149 -30
- package/types/cngx-common-timeline.d.ts +27 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { OnDestroy,
|
|
2
|
+
import { OnDestroy, InjectionToken, Signal, ElementRef } from '@angular/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Manages `aria-expanded` and optionally `aria-controls` on the host element.
|
|
@@ -126,6 +126,24 @@ type AriaLivePoliteness = 'polite' | 'assertive';
|
|
|
126
126
|
* polite one. Per region, the text is cleared and re-set one frame later so an
|
|
127
127
|
* identical consecutive message is still re-read by the screen reader.
|
|
128
128
|
*
|
|
129
|
+
* A modal dialog hides everything outside it from assistive technology, so a
|
|
130
|
+
* body region is silent while one is open. Pass the announcing element as the
|
|
131
|
+
* third argument and the message goes to a region pair inside its enclosing
|
|
132
|
+
* `[aria-modal="true"]` container instead; without a modal ancestor it goes to
|
|
133
|
+
* the body regions as before. When another modal covers that one, the topmost
|
|
134
|
+
* open modal receives it: the last `[aria-modal="true"]` element in document
|
|
135
|
+
* order that is open and not inside an `[inert]` subtree. That covers a modal
|
|
136
|
+
* nested inside the scope's own one as well as a sibling stacked on top of it,
|
|
137
|
+
* which is how `CngxDialog` stacks dialogs (every host is appended to
|
|
138
|
+
* `document.body`); a covered modal is hidden from assistive technology, so
|
|
139
|
+
* its region would be silent. The pair is created with both regions on first
|
|
140
|
+
* use and its first write waits until the regions have settled in the DOM. A
|
|
141
|
+
* message still pending when its modal closes moves to the next enclosing open
|
|
142
|
+
* modal, else to the topmost modal still open, else to the body regions, and
|
|
143
|
+
* the pair is removed. The scope is opt-in per call - an unscoped announcement
|
|
144
|
+
* never guesses a modal. {@link injectScopedLiveRegion} is the injection-time
|
|
145
|
+
* alternative when the caller knows its overlay host up front.
|
|
146
|
+
*
|
|
129
147
|
* SSR-safe: all DOM access is guarded by `isPlatformBrowser`; on the server
|
|
130
148
|
* `announce()` is a no-op and no region is created.
|
|
131
149
|
*
|
|
@@ -133,6 +151,7 @@ type AriaLivePoliteness = 'polite' | 'assertive';
|
|
|
133
151
|
* const announcer = inject(CngxLiveAnnouncer);
|
|
134
152
|
* announcer.announce('Copied');
|
|
135
153
|
* announcer.announce('Save failed', 'assertive');
|
|
154
|
+
* announcer.announce('Alert dismissed', 'polite', hostElement); // inside a modal
|
|
136
155
|
* ```
|
|
137
156
|
*
|
|
138
157
|
* @category common/a11y
|
|
@@ -144,9 +163,13 @@ type AriaLivePoliteness = 'polite' | 'assertive';
|
|
|
144
163
|
declare class CngxLiveAnnouncer implements OnDestroy {
|
|
145
164
|
private readonly doc;
|
|
146
165
|
private readonly isBrowser;
|
|
147
|
-
private
|
|
148
|
-
|
|
149
|
-
|
|
166
|
+
private regions;
|
|
167
|
+
/**
|
|
168
|
+
* One pair per open `aria-modal` container, released once it closes.
|
|
169
|
+
* `outer` is the container's parent at creation, the route for its unwritten
|
|
170
|
+
* messages when it is removed from the DOM.
|
|
171
|
+
*/
|
|
172
|
+
private readonly modalRegions;
|
|
150
173
|
/**
|
|
151
174
|
* Announces `message` through the fixed-politeness live region.
|
|
152
175
|
*
|
|
@@ -154,14 +177,93 @@ declare class CngxLiveAnnouncer implements OnDestroy {
|
|
|
154
177
|
* @param politeness `'polite'` (default) queues after the current
|
|
155
178
|
* utterance; `'assertive'` interrupts immediately. Each politeness owns its
|
|
156
179
|
* own region, so the two never overwrite each other.
|
|
180
|
+
* @param scope The announcing element. When it sits inside an
|
|
181
|
+
* `[aria-modal="true"]` container, the message is written into a region
|
|
182
|
+
* inside the topmost open modal (that container unless another modal
|
|
183
|
+
* covers it), which a screen reader still reads while the modal hides the
|
|
184
|
+
* rest of the page. `null` / omitted: the body regions.
|
|
157
185
|
*/
|
|
158
|
-
announce(message: string, politeness?: AriaLivePoliteness): void;
|
|
186
|
+
announce(message: string, politeness?: AriaLivePoliteness, scope?: Element | null): void;
|
|
159
187
|
ngOnDestroy(): void;
|
|
160
|
-
|
|
188
|
+
/**
|
|
189
|
+
* `fromModal` marks a message that was already scoped to a modal which has
|
|
190
|
+
* since closed: with no open modal around its new scope it still goes to the
|
|
191
|
+
* topmost open modal rather than to the silent body regions.
|
|
192
|
+
*/
|
|
193
|
+
private route;
|
|
194
|
+
/**
|
|
195
|
+
* The topmost open modal when `scope` sits in an open modal (or the message
|
|
196
|
+
* comes from a closed one), else `null` for the body regions. Falls back to
|
|
197
|
+
* the scope's own modal when no candidate outside an inert subtree is open.
|
|
198
|
+
*/
|
|
199
|
+
private targetModal;
|
|
200
|
+
private enclosingOpenModal;
|
|
201
|
+
private redirectIfClosed;
|
|
202
|
+
private releaseClosedModals;
|
|
203
|
+
/** Drop the pair of a closed modal; its unwritten messages move outward. */
|
|
204
|
+
private release;
|
|
205
|
+
private outerOf;
|
|
161
206
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxLiveAnnouncer, never>;
|
|
162
207
|
static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxLiveAnnouncer>;
|
|
163
208
|
}
|
|
164
209
|
|
|
210
|
+
/**
|
|
211
|
+
* A message whose write into its live region has not landed yet.
|
|
212
|
+
*
|
|
213
|
+
* @category common/a11y
|
|
214
|
+
*/
|
|
215
|
+
interface CngxPendingAnnouncement {
|
|
216
|
+
readonly message: string;
|
|
217
|
+
readonly politeness: AriaLivePoliteness;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Polite + assertive live regions inside one host element.
|
|
222
|
+
*
|
|
223
|
+
* @category common/a11y
|
|
224
|
+
*/
|
|
225
|
+
interface CngxScopedLiveRegion {
|
|
226
|
+
/** Speak `message` from the region of `politeness` (default `'polite'`). */
|
|
227
|
+
announce(message: string, politeness?: AriaLivePoliteness): void;
|
|
228
|
+
/** Create both regions now, so they are in the DOM before the first message. */
|
|
229
|
+
ensure(): void;
|
|
230
|
+
/** Cancel every write that has not landed yet and return what it would have said. */
|
|
231
|
+
takePending(): readonly CngxPendingAnnouncement[];
|
|
232
|
+
/** Cancel pending writes and remove the regions. Runs on destroy as well. */
|
|
233
|
+
destroy(): void;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Create a polite + assertive live-region pair inside `host`.
|
|
237
|
+
*
|
|
238
|
+
* The scoped counterpart to {@link CngxLiveAnnouncer}: same regions, same
|
|
239
|
+
* clear-then-set timing, but appended to an overlay host instead of
|
|
240
|
+
* `document.body`. Use it for modal overlays: under `aria-modal` VoiceOver
|
|
241
|
+
* drops body-level live regions and speaks them late after the overlay
|
|
242
|
+
* closes, while a region inside the modal is spoken on every platform.
|
|
243
|
+
* Polite and assertive keep separate regions, so an assertive error never
|
|
244
|
+
* clobbers a polite status.
|
|
245
|
+
*
|
|
246
|
+
* Must run in an injection context; the regions are removed when that context
|
|
247
|
+
* is destroyed. No-op on the server.
|
|
248
|
+
*
|
|
249
|
+
* ```typescript
|
|
250
|
+
* private readonly region = injectScopedLiveRegion(inject(ElementRef).nativeElement);
|
|
251
|
+
*
|
|
252
|
+
* protected handleSaveFailed(): void {
|
|
253
|
+
* this.region.announce('Save failed', 'assertive');
|
|
254
|
+
* }
|
|
255
|
+
* ```
|
|
256
|
+
*
|
|
257
|
+
* @param host - Element that receives the two visually hidden regions.
|
|
258
|
+
*
|
|
259
|
+
* @category common/a11y
|
|
260
|
+
* @wcag AA
|
|
261
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/a11y/aria/scoped-live-region.ts
|
|
262
|
+
* @since 0.1.0
|
|
263
|
+
* @relatedTo CngxLiveAnnouncer, CngxLiveRegion
|
|
264
|
+
*/
|
|
265
|
+
declare function injectScopedLiveRegion(host: HTMLElement): CngxScopedLiveRegion;
|
|
266
|
+
|
|
165
267
|
/**
|
|
166
268
|
* Reactive autofocus for dynamically inserted elements.
|
|
167
269
|
*
|
|
@@ -303,6 +405,21 @@ declare class CngxFocusRestore {
|
|
|
303
405
|
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>;
|
|
304
406
|
}
|
|
305
407
|
|
|
408
|
+
/**
|
|
409
|
+
* @internal Lets a directive that composes `CngxFocusTrap` as a host
|
|
410
|
+
* directive drive it from its own state instead of the inputs. Provided by
|
|
411
|
+
* the composer on the same element (`useExisting`); the trap resolves it
|
|
412
|
+
* lazily with `self: true`, because the composer constructs after its host
|
|
413
|
+
* directives.
|
|
414
|
+
*/
|
|
415
|
+
interface CngxFocusTrapDriver {
|
|
416
|
+
/** Whether the trap is active; wins over `[enabled]`. */
|
|
417
|
+
readonly focusTrapEnabled: Signal<boolean>;
|
|
418
|
+
/** Whether activation auto-focuses; wins over `[autoFocus]`. */
|
|
419
|
+
readonly focusTrapAutoFocus: boolean;
|
|
420
|
+
}
|
|
421
|
+
/** @internal See {@link CngxFocusTrapDriver}. */
|
|
422
|
+
declare const CNGX_FOCUS_TRAP_DRIVER: InjectionToken<CngxFocusTrapDriver>;
|
|
306
423
|
/**
|
|
307
424
|
* Traps keyboard focus within the host element using the CDK `FocusTrap`.
|
|
308
425
|
*
|
|
@@ -351,17 +468,35 @@ declare class CngxFocusTrap {
|
|
|
351
468
|
readonly enabled: _angular_core.InputSignal<boolean>;
|
|
352
469
|
/** Whether to auto-focus the first tabbable element when the trap activates. */
|
|
353
470
|
readonly autoFocus: _angular_core.InputSignal<boolean>;
|
|
471
|
+
private readonly injector;
|
|
472
|
+
private resolvedDriver;
|
|
473
|
+
private driver;
|
|
474
|
+
/**
|
|
475
|
+
* The enabled state the trap actually follows: a composer's driver
|
|
476
|
+
* (see {@link CngxFocusTrapDriver}) wins over the `[enabled]` input.
|
|
477
|
+
*/
|
|
478
|
+
private readonly effectiveEnabled;
|
|
354
479
|
/**
|
|
355
|
-
* Readable alias of
|
|
480
|
+
* Readable alias of the effective enabled state for `exportAs` consumers
|
|
356
481
|
* (`trap.isActive()` reads better than re-binding the input).
|
|
357
482
|
*/
|
|
358
|
-
readonly isActive:
|
|
359
|
-
private readonly
|
|
483
|
+
readonly isActive: Signal<boolean>;
|
|
484
|
+
private readonly host;
|
|
485
|
+
private readonly factory;
|
|
486
|
+
private trap;
|
|
360
487
|
constructor();
|
|
361
488
|
/** Programmatically focus the first tabbable element within the trap. */
|
|
362
489
|
focusFirst(): void;
|
|
363
490
|
/** Programmatically focus the last tabbable element within the trap. */
|
|
364
491
|
focusLast(): void;
|
|
492
|
+
/**
|
|
493
|
+
* @internal Focus the first tabbable element right now, in the caller's
|
|
494
|
+
* stack. `focusFirst()` waits for the next render, which is too late for a
|
|
495
|
+
* composer that must move focus inside the user gesture that opened it.
|
|
496
|
+
* Returns `false` when nothing inside is tabbable.
|
|
497
|
+
*/
|
|
498
|
+
focusFirstNow(): boolean;
|
|
499
|
+
private ensureTrap;
|
|
365
500
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFocusTrap, never>;
|
|
366
501
|
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
502
|
}
|
|
@@ -723,6 +858,15 @@ declare class CngxActiveDescendant {
|
|
|
723
858
|
* Ignored when `virtualCount` is unset.
|
|
724
859
|
*/
|
|
725
860
|
readonly windowStart: _angular_core.InputSignal<number>;
|
|
861
|
+
/**
|
|
862
|
+
* Equality used to find the previously active value again after the item
|
|
863
|
+
* list changes. Defaults to `Object.is`; pass the same comparator as the
|
|
864
|
+
* surrounding listbox / select when options are re-fetched as new objects
|
|
865
|
+
* with equal identity, or the highlight drops on every refresh. The
|
|
866
|
+
* parameters are typed `never` so a comparator over any value type binds
|
|
867
|
+
* while the directive itself stays non-generic.
|
|
868
|
+
*/
|
|
869
|
+
readonly compareWith: _angular_core.InputSignal<(a: never, b: never) => boolean>;
|
|
726
870
|
/** Emitted when `activateCurrent()` is called with an active item. */
|
|
727
871
|
readonly activated: _angular_core.OutputEmitterRef<unknown>;
|
|
728
872
|
/** Emitted whenever the highlighted item changes. */
|
|
@@ -743,8 +887,6 @@ declare class CngxActiveDescendant {
|
|
|
743
887
|
private readonly direction;
|
|
744
888
|
/** Guards host attribute writes until after first render. */
|
|
745
889
|
private readonly initialized;
|
|
746
|
-
/** -1 means "no active item". Range is [0, resolvedItems().length). */
|
|
747
|
-
private readonly activeIndexState;
|
|
748
890
|
/** Index of an item that should be highlighted but is not in the DOM. */
|
|
749
891
|
private readonly pendingHighlightState;
|
|
750
892
|
readonly pendingHighlight: _angular_core.Signal<number | null>;
|
|
@@ -753,6 +895,17 @@ declare class CngxActiveDescendant {
|
|
|
753
895
|
* handles are projected into `ActiveDescendantItem` shape.
|
|
754
896
|
*/
|
|
755
897
|
readonly resolvedItems: _angular_core.Signal<ActiveDescendantItem[]>;
|
|
898
|
+
/**
|
|
899
|
+
* -1 means "no active item". Range is `[0, totalCount())`.
|
|
900
|
+
*
|
|
901
|
+
* Navigation writes the index; a change of the item space re-derives it.
|
|
902
|
+
* The highlight follows its value, not its index: after the item list
|
|
903
|
+
* changes, the previously active value is looked up again with
|
|
904
|
+
* `compareWith`. Gone from a plain list means no highlight; in a virtual
|
|
905
|
+
* window a value that merely scrolled out keeps its absolute index. The result is clamped to the new
|
|
906
|
+
* item space, so the next arrow press never starts from a ghost index.
|
|
907
|
+
*/
|
|
908
|
+
private readonly activeIndexState;
|
|
756
909
|
/** Current active index. `-1` when no item is highlighted. */
|
|
757
910
|
readonly activeIndex: _angular_core.Signal<number>;
|
|
758
911
|
/**
|
|
@@ -825,7 +978,7 @@ declare class CngxActiveDescendant {
|
|
|
825
978
|
private isRendered;
|
|
826
979
|
private scrollActiveIntoView;
|
|
827
980
|
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>;
|
|
981
|
+
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; }; "compareWith": { "alias": "compareWith"; "required": false; "isSignal": true; }; }, { "activated": "activated"; "highlighted": "highlighted"; "typeaheadMissed": "typeaheadMissed"; }, ["registered"], never, true, never>;
|
|
829
982
|
}
|
|
830
983
|
|
|
831
984
|
/**
|
|
@@ -868,5 +1021,5 @@ declare class CngxReducedMotion {
|
|
|
868
1021
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxReducedMotion, "[cngxReducedMotion]", ["cngxReducedMotion"], {}, {}, never, never, true, never>;
|
|
869
1022
|
}
|
|
870
1023
|
|
|
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 };
|
|
1024
|
+
export { CNGX_AD_ITEM, CNGX_FOCUSABLE_SELECTOR, CNGX_FOCUS_TRAP_DRIVER, CngxActiveDescendant, CngxAriaExpanded, CngxAutofocus, CngxFocusRestore, CngxFocusTrap, CngxFocusVisible, CngxLiveAnnouncer, CngxLiveRegion, CngxReducedMotion, CngxRovingItem, CngxRovingTabindex, injectScopedLiveRegion };
|
|
1025
|
+
export type { ActiveDescendantItem, AriaLivePoliteness, CngxAdItemHandle, CngxFocusTrapDriver, CngxPendingAnnouncement, CngxScopedLiveRegion };
|
|
@@ -80,7 +80,8 @@ declare function createBandScale<T>(domain: readonly T[], range: readonly [numbe
|
|
|
80
80
|
* @param domain Ordered list of categorical values. Values are matched
|
|
81
81
|
* by reference equality on lookup.
|
|
82
82
|
* @param colors Palette to cycle through. Must have at least one entry;
|
|
83
|
-
* an empty palette throws
|
|
83
|
+
* an empty palette throws a `CngxRuntimeError` (`CNGX1049`)
|
|
84
|
+
* synchronously at construction time.
|
|
84
85
|
* @returns Callable `(v: T) => string` returning the palette entry for
|
|
85
86
|
* `v`. Lookup of an unknown value returns the palette's first entry.
|
|
86
87
|
*
|
|
@@ -296,11 +297,11 @@ interface CngxChartContext<TX = XScaleInput, TY = number> {
|
|
|
296
297
|
*/
|
|
297
298
|
declare const CNGX_CHART_CONTEXT: InjectionToken<CngxChartContext<XScaleInput, number>>;
|
|
298
299
|
/**
|
|
299
|
-
* Inject the parent chart's reactive context. Throws a
|
|
300
|
-
*
|
|
301
|
-
* `<cngx-chart
|
|
302
|
-
*
|
|
303
|
-
*
|
|
300
|
+
* Inject the parent chart's reactive context. Throws a `CngxRuntimeError`
|
|
301
|
+
* with code `CNGX1048` when the consumer is not mounted as a content child
|
|
302
|
+
* of `<cngx-chart>`, in development and production alike. The `selector`
|
|
303
|
+
* argument is the consumer's public selector without brackets (`'cngxLine'`)
|
|
304
|
+
* and names it in the development message.
|
|
304
305
|
*
|
|
305
306
|
* Use it from custom layer directives mounted on `<svg:g>` hosts to
|
|
306
307
|
* read `plot`, the scales and `renderSvg` the same way the built-in
|
|
@@ -310,7 +311,7 @@ declare const CNGX_CHART_CONTEXT: InjectionToken<CngxChartContext<XScaleInput, n
|
|
|
310
311
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/chart/chart/chart-context.ts
|
|
311
312
|
* @since 0.1.0
|
|
312
313
|
*/
|
|
313
|
-
declare function injectChartContext(
|
|
314
|
+
declare function injectChartContext(selector: string): CngxChartContext;
|
|
314
315
|
|
|
315
316
|
/**
|
|
316
317
|
* Common context shape passed into every chart slot template
|
|
@@ -75,7 +75,14 @@ type CngxCommandSource = Signal<readonly CngxCommand[]> | readonly CngxCommand[]
|
|
|
75
75
|
* Multi-token every `provideCommands` call contributes to. App parts register
|
|
76
76
|
* command sets against it without a central list, mirroring `provideCngxMenu`.
|
|
77
77
|
* The generic is the collected array (as with Angular's `HTTP_INTERCEPTORS`),
|
|
78
|
-
* so `inject(CNGX_COMMAND_SOURCE)` returns
|
|
78
|
+
* so `inject(CNGX_COMMAND_SOURCE)` returns the sources of the nearest level
|
|
79
|
+
* that provides it.
|
|
80
|
+
*
|
|
81
|
+
* This is the low-level form. Register through `provideCommands`, which also
|
|
82
|
+
* carries a level's sources into every scope below it. A raw multi-provider on
|
|
83
|
+
* this token is carried down only from a level that also calls
|
|
84
|
+
* `provideCommands`; on any other level it is read only when that level is the
|
|
85
|
+
* one `injectCommands` resolves as nearest.
|
|
79
86
|
*
|
|
80
87
|
* @category common/command
|
|
81
88
|
* @since 0.1.0
|
|
@@ -91,9 +98,18 @@ declare const CNGX_COMMAND_SOURCE: InjectionToken<readonly CngxCommandSource[]>;
|
|
|
91
98
|
* `viewProviders` - letting a route or component contribute a scoped command
|
|
92
99
|
* set without reaching for the raw {@link CNGX_COMMAND_SOURCE} multi-provider.
|
|
93
100
|
*
|
|
101
|
+
* A scoped call adds to the sets above it and never hides them, across route
|
|
102
|
+
* and component scopes: root and route scopes come first (outer to inner), then
|
|
103
|
+
* component scopes outer to inner. The same source reference registered at two
|
|
104
|
+
* levels is listed once. Command ids are unique in the merged list: a command
|
|
105
|
+
* whose `id` is already registered further out replaces that command in place,
|
|
106
|
+
* so a scope can swap a global command for its own version.
|
|
107
|
+
*
|
|
94
108
|
* ```ts
|
|
95
109
|
* // app root
|
|
96
110
|
* bootstrapApplication(AppComponent, { providers: [provideCommands(fileCommands)] });
|
|
111
|
+
* // a lazy route adds its set; its pages see fileCommands + reportCommands
|
|
112
|
+
* { path: 'reports', providers: [provideCommands(reportCommands)], component: Reports }
|
|
97
113
|
* // or component scope
|
|
98
114
|
* @Component({ viewProviders: [provideCommands(editorCommands)] })
|
|
99
115
|
* ```
|
|
@@ -103,7 +119,8 @@ declare const CNGX_COMMAND_SOURCE: InjectionToken<readonly CngxCommandSource[]>;
|
|
|
103
119
|
*/
|
|
104
120
|
declare function provideCommands(...sources: CngxCommandSource[]): Provider[];
|
|
105
121
|
/**
|
|
106
|
-
* Merges
|
|
122
|
+
* Merges the command sources registered at this injector level and every level
|
|
123
|
+
* above it - route and component scopes alike - into one reactive
|
|
107
124
|
* `Signal<readonly CngxCommand[]>`. The merge carries an explicit `equal`
|
|
108
125
|
* (length + per-command identity) so re-emitting an identical set - the same
|
|
109
126
|
* command references in the same order - does not produce a fresh array and
|