@cngx/common 0.1.0-rc.6 → 0.1.0-rc.8
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/card/README.md +2 -1
- package/chart/README.md +85 -0
- package/command/README.md +157 -0
- package/data/README.md +33 -1
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +356 -180
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +84 -42
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +311 -53
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +4360 -1625
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +171 -0
- package/fesm2022/cngx-common-command.mjs.map +1 -0
- package/fesm2022/cngx-common-data.mjs +1556 -616
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +518 -112
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +468 -87
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2725 -1303
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +943 -164
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +769 -103
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +816 -348
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +2330 -1554
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +1170 -0
- package/fesm2022/cngx-common-timeline.mjs.map +1 -0
- package/fesm2022/cngx-common.mjs +2 -2
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +21 -1
- package/package.json +11 -1
- package/popover/README.md +18 -2
- package/stepper/README.md +7 -5
- package/theming/components/cngx-accordion.css +4 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-badge.css +22 -0
- package/theming/components/cngx-bottom-sheet.css +14 -2
- package/theming/components/cngx-breadcrumb.css +8 -0
- package/theming/components/cngx-button-toggle.css +73 -5
- package/theming/components/cngx-data-grid.css +234 -1
- package/theming/components/cngx-dialog.css +25 -0
- package/theming/components/cngx-divider.css +12 -0
- package/theming/components/cngx-listbox.css +48 -12
- package/theming/components/cngx-menu.css +91 -15
- package/theming/components/cngx-popover.css +24 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +2 -2
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +23 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +101 -31
- package/types/cngx-common-audio.d.ts +32 -32
- package/types/cngx-common-card.d.ts +211 -20
- package/types/cngx-common-chart.d.ts +1605 -169
- package/types/cngx-common-command.d.ts +190 -0
- package/types/cngx-common-data.d.ts +842 -163
- package/types/cngx-common-dialog.d.ts +372 -28
- package/types/cngx-common-display.d.ts +432 -148
- package/types/cngx-common-interactive.d.ts +1553 -370
- package/types/cngx-common-layout.d.ts +613 -27
- package/types/cngx-common-popover.d.ts +376 -36
- package/types/cngx-common-stepper.d.ts +414 -114
- package/types/cngx-common-tabs.d.ts +597 -72
- package/types/cngx-common-timeline.d.ts +1125 -0
- package/types/cngx-common.d.ts +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { Signal, TemplateRef, OnInit, InjectionToken, Resource, EnvironmentProviders, ElementRef, Injector, DestroyRef } from '@angular/core';
|
|
3
|
-
import { CngxAsyncState, AsyncStatus } from '@cngx/core/utils';
|
|
2
|
+
import { Signal, TemplateRef, OnInit, InjectionToken, Resource, EnvironmentProviders, Provider, ElementRef, Injector, DestroyRef } from '@angular/core';
|
|
3
|
+
import { CngxAsyncState, AsyncStatus, CngxStateful, CngxLatencyProbe } from '@cngx/core/utils';
|
|
4
|
+
export { CngxLatencyProbe } from '@cngx/core/utils';
|
|
4
5
|
import { DataSource } from '@angular/cdk/collections';
|
|
5
6
|
import { Observable, MonoTypeOperatorFunction, OperatorFunction } from 'rxjs';
|
|
7
|
+
import { CngxSearch } from '@cngx/common/interactive';
|
|
6
8
|
import { HttpContextToken, HttpContext, HttpInterceptorFn } from '@angular/common/http';
|
|
9
|
+
import * as _cngx_common_data from '@cngx/common/data';
|
|
7
10
|
import { CngxRovingTabindex, CngxActiveDescendant } from '@cngx/common/a11y';
|
|
11
|
+
import { CngxMessage } from '@cngx/core/i18n';
|
|
8
12
|
|
|
9
13
|
/**
|
|
10
14
|
* A single sort entry: the active field key and its direction.
|
|
@@ -32,6 +36,8 @@ interface SortEntry {
|
|
|
32
36
|
* adds it as a secondary (tertiary, …) sort key instead of replacing the
|
|
33
37
|
* primary one. Shift-clicking an active column cycles it asc → desc → removed.
|
|
34
38
|
* Multi-sort state is always uncontrolled; use `sortsChange` to read it.
|
|
39
|
+
* While a controlled pin is bound, additive clicks degrade to the
|
|
40
|
+
* single-sort cycle.
|
|
35
41
|
*
|
|
36
42
|
* Consumer connects this to a table or list via a `computed()` - nothing is
|
|
37
43
|
* injected automatically.
|
|
@@ -80,6 +86,9 @@ declare class CngxSort {
|
|
|
80
86
|
/**
|
|
81
87
|
* All active sort entries in priority order.
|
|
82
88
|
* Contains at most one entry when additive mode has not been used.
|
|
89
|
+
* In controlled mode the entry is derived from `cngxSortActive` /
|
|
90
|
+
* `cngxSortDirection` (a falsy active key means no sort); headers and
|
|
91
|
+
* data sources read this signal, so the controlled pin drives them too.
|
|
83
92
|
*/
|
|
84
93
|
readonly sorts: _angular_core.Signal<SortEntry[]>;
|
|
85
94
|
/** `true` when at least one sort is active. */
|
|
@@ -102,6 +111,12 @@ declare class CngxSort {
|
|
|
102
111
|
* - Field not in stack → append as asc
|
|
103
112
|
* - Field in stack as asc → change to desc
|
|
104
113
|
* - Field in stack as desc → remove from stack
|
|
114
|
+
*
|
|
115
|
+
* With a controlled `cngxSortActive` pin bound, the sort is event-only: the
|
|
116
|
+
* cycle is computed off the effective entry and emitted, the internal state
|
|
117
|
+
* stays untouched (nothing stale surfaces if the pin unbinds later). Since
|
|
118
|
+
* multi-sort is always uncontrolled, an additive call degrades to the
|
|
119
|
+
* non-additive controlled cycle while a pin is bound.
|
|
105
120
|
*/
|
|
106
121
|
setSort(field: string, additive?: boolean): void;
|
|
107
122
|
/** Clears all active sorts. Emits both `sortChange(undefined)` and `sortsChange([])`. */
|
|
@@ -362,17 +377,19 @@ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
|
|
|
362
377
|
* is intentionally out of scope. Consumers needing a single-select
|
|
363
378
|
* filter wire `<cngx-chip-group>` to a custom predicate themselves.
|
|
364
379
|
*
|
|
365
|
-
* **Sync contract - derivation, not effect.**
|
|
366
|
-
* `filterRef.addPredicate(filterKey, predicateFn)` EXACTLY ONCE
|
|
367
|
-
* during mount (in `afterNextRender`, because `input.required()`
|
|
368
|
-
* cannot be read from the constructor body). `predicateFn` is a
|
|
380
|
+
* **Sync contract - derivation, not effect.** `predicateFn` is a
|
|
369
381
|
* closure that reads `this.selectedValues()` and
|
|
370
|
-
* `this.
|
|
382
|
+
* `this.optionValue()` on every invocation. Because
|
|
371
383
|
* `CngxFilter.predicate` is itself a `computed()` consumed by
|
|
372
384
|
* downstream filtered lists, each item-evaluation flows through
|
|
373
385
|
* `selectedValues()` in the consumer's reactive context - chip
|
|
374
386
|
* toggles propagate without any `effect()` writing back into the
|
|
375
|
-
* filter.
|
|
387
|
+
* filter. Registration itself is reactive: a binding effect tracks
|
|
388
|
+
* `filterRef`/`filterKey` (a rebind moves the registration), and an
|
|
389
|
+
* eviction watcher re-registers the key after `filter.clear()` wiped
|
|
390
|
+
* the stack, so visible chip selection and predicate stack cannot
|
|
391
|
+
* diverge. Selections whose option vanished from `[options]` are
|
|
392
|
+
* pruned - a removed option never keeps filtering invisibly.
|
|
376
393
|
*
|
|
377
394
|
* **Empty-selection semantics.** When `selectedValues()` is `[]`,
|
|
378
395
|
* the closure returns `true` for every item - equivalent to "no
|
|
@@ -382,13 +399,21 @@ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
|
|
|
382
399
|
* re-registering on every empty/non-empty boundary, and keeps the
|
|
383
400
|
* predicate-stack stable (no `predicatesChange` emission churn).
|
|
384
401
|
*
|
|
385
|
-
* **Teardown.**
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* `
|
|
402
|
+
* **Teardown.** The binding effect's cleanup removes the key only
|
|
403
|
+
* while it still maps to this strip's own `predicateFn` (identity
|
|
404
|
+
* guard) - destroying one of two strips that share a key never
|
|
405
|
+
* detaches the live sibling's registration.
|
|
406
|
+
*
|
|
407
|
+
* **Visible caption.** The required `label` renders as a
|
|
408
|
+
* `.cngx-filter-chips__label` caption above the strip so a sighted user
|
|
409
|
+
* can tell which facet a chip row belongs to. The caption is
|
|
410
|
+
* `aria-hidden="true"`: the inner `<cngx-multi-chip-group>` is already
|
|
411
|
+
* named by the same string via `[label]`, so exposing the visible node
|
|
412
|
+
* to AT would announce the facet twice. Spacing between caption and
|
|
413
|
+
* strip is the `--cngx-filter-chips-gap` token; the caption's own
|
|
414
|
+
* appearance is `--cngx-filter-chips-label-color`,
|
|
415
|
+
* `--cngx-filter-chips-label-font-size` and
|
|
416
|
+
* `--cngx-filter-chips-label-font-weight`.
|
|
392
417
|
*
|
|
393
418
|
* ```html
|
|
394
419
|
* <cngx-filter-chips
|
|
@@ -413,6 +438,7 @@ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
|
|
|
413
438
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter-chips/filter-chips.component.ts
|
|
414
439
|
* @since 0.1.0
|
|
415
440
|
* @relatedTo CngxFilter, CngxFilterChip, CngxMultiChipGroup
|
|
441
|
+
* @slot cngxFilterChip Renders one active filter chip; gets the filter entry and a remove callback.
|
|
416
442
|
*
|
|
417
443
|
* <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
|
|
418
444
|
* <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
|
|
@@ -477,7 +503,6 @@ declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
|
|
|
477
503
|
* `CngxFilter.predicate`.
|
|
478
504
|
*/
|
|
479
505
|
readonly selectedValues: _angular_core.ModelSignal<TValue[]>;
|
|
480
|
-
private registered;
|
|
481
506
|
constructor();
|
|
482
507
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFilterChips<any, any>, never>;
|
|
483
508
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxFilterChips<any, any>, "cngx-filter-chips", ["cngxFilterChips"], { "label": { "alias": "label"; "required": true; "isSignal": true; }; "options": { "alias": "options"; "required": true; "isSignal": true; }; "optionLabel": { "alias": "optionLabel"; "required": true; "isSignal": true; }; "optionValue": { "alias": "optionValue"; "required": true; "isSignal": true; }; "filterRef": { "alias": "filterRef"; "required": true; "isSignal": true; }; "filterKey": { "alias": "filterKey"; "required": true; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "invalid": { "alias": "invalid"; "required": false; "isSignal": true; }; "errorMessageId": { "alias": "errorMessageId"; "required": false; "isSignal": true; }; "orientation": { "alias": "orientation"; "required": false; "isSignal": true; }; "keyFn": { "alias": "keyFn"; "required": false; "isSignal": true; }; "selectedValues": { "alias": "selectedValues"; "required": false; "isSignal": true; }; }, { "disabled": "disabledChange"; "required": "requiredChange"; "invalid": "invalidChange"; "selectedValues": "selectedValuesChange"; }, ["chipTemplate"], never, true, never>;
|
|
@@ -562,6 +587,18 @@ declare class CngxPaginate {
|
|
|
562
587
|
* stops a fresh-array identity from cascading downstream.
|
|
563
588
|
*/
|
|
564
589
|
readonly cumulativeRange: _angular_core.Signal<[number, number]>;
|
|
590
|
+
/**
|
|
591
|
+
* `range()` with both bounds capped at `total` - the honest in-bounds window
|
|
592
|
+
* for readouts and announcements. `range()`'s upper bound is
|
|
593
|
+
* `start + pageSize`, so a partial final page overshoots `total`; this caps
|
|
594
|
+
* it (and yields `[0, 0]` while the list is empty). The capped end doubles as
|
|
595
|
+
* the cumulative reveal count for load-more consumers: `range()[1]` and
|
|
596
|
+
* `cumulativeRange()[1]` are the same number (`(pageIndex + 1) * pageSize`),
|
|
597
|
+
* so `clampedRange()[1]` is "items shown so far" in both replace and append
|
|
598
|
+
* modes. The explicit tuple `equal` stops a fresh-array identity from
|
|
599
|
+
* cascading downstream.
|
|
600
|
+
*/
|
|
601
|
+
readonly clampedRange: _angular_core.Signal<[number, number]>;
|
|
565
602
|
/** Emitted when the page index changes. */
|
|
566
603
|
readonly pageChange: _angular_core.OutputEmitterRef<number>;
|
|
567
604
|
/** Emitted when the page size changes. */
|
|
@@ -657,7 +694,10 @@ interface CngxPaginateEmitHandlers {
|
|
|
657
694
|
* brain's `pageIndex()` stays pinned to the input until the consumer feeds it
|
|
658
695
|
* back;
|
|
659
696
|
* - an `effect()` reads the effective `pageIndex()` / `pageSize()` and covers a
|
|
660
|
-
* `total`-shrink clamp the nav-only output misses.
|
|
697
|
+
* `total`-shrink clamp the nav-only output misses. The index half of the
|
|
698
|
+
* clamp path is suppressed while the brain is busy or `total` is 0, so a
|
|
699
|
+
* transient total drop during a refetch never persists a page-0 clamp into a
|
|
700
|
+
* controlled consumer; a clamp that survives the settle emits then.
|
|
661
701
|
*
|
|
662
702
|
* The shared guard makes a value one path already emitted a no-op on the other,
|
|
663
703
|
* so each change emits exactly once. Seeded with the current effective values,
|
|
@@ -709,8 +749,10 @@ declare class CngxPaginateRouting implements OnInit {
|
|
|
709
749
|
/** Query-param name for the page size. */
|
|
710
750
|
readonly sizeParam: _angular_core.InputSignal<string>;
|
|
711
751
|
private applyingFromUrl;
|
|
752
|
+
private readonly pendingUrl;
|
|
712
753
|
constructor();
|
|
713
754
|
ngOnInit(): void;
|
|
755
|
+
private applyFromUrl;
|
|
714
756
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxPaginateRouting, never>;
|
|
715
757
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPaginateRouting, "[cngxPaginateRouting]", ["cngxPaginateRouting"], { "pageParam": { "alias": "cngxPaginatePageParam"; "required": false; "isSignal": true; }; "sizeParam": { "alias": "cngxPaginateSizeParam"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
716
758
|
}
|
|
@@ -910,15 +952,35 @@ declare function injectDataSource<T>(data: Signal<T[]>): CngxDataSource<T>;
|
|
|
910
952
|
interface CngxSmartDataSourceOptions<T> {
|
|
911
953
|
/**
|
|
912
954
|
* Custom full-text search function. Receives an item and the current search
|
|
913
|
-
* term; return `true` to keep the item. Defaults to a
|
|
914
|
-
*
|
|
955
|
+
* term; return `true` to keep the item. Defaults to a substring match across
|
|
956
|
+
* all primitive-valued properties that ignores case and accents in the app
|
|
957
|
+
* locale.
|
|
915
958
|
*/
|
|
916
959
|
searchFn?: (item: T, term: string) => boolean;
|
|
917
960
|
/**
|
|
918
961
|
* Custom sort comparator. Receives two items, the active field key, and
|
|
919
|
-
* direction. Defaults to a
|
|
962
|
+
* direction. Defaults to a string comparison collated in the app locale
|
|
963
|
+
* (`CNGX_LOCALE`), numeric-aware and case- and accent-insensitive.
|
|
920
964
|
*/
|
|
921
965
|
sortFn?: (a: T, b: T, field: string, direction: 'asc' | 'desc') => number;
|
|
966
|
+
/**
|
|
967
|
+
* Resolve the `CngxSort` atom explicitly instead of relying on injection.
|
|
968
|
+
* A thunk, not an instance, so a `viewChild` that is `undefined` on the
|
|
969
|
+
* first pass resolves on a later read. A thunk result takes precedence over
|
|
970
|
+
* an injected instance whenever it yields one; on `undefined` / `null` the
|
|
971
|
+
* source falls back to the injected atom - so with both present, the
|
|
972
|
+
* injected atom drives the frames before the thunk's target mounts, and the
|
|
973
|
+
* thunk cannot express "use none".
|
|
974
|
+
* Use for atoms hosted below this source's injector, e.g.
|
|
975
|
+
* `{ sort: () => this.grid()?.sort }` against a `CngxDataGridAccordion`.
|
|
976
|
+
*/
|
|
977
|
+
sort?: () => CngxSort | null | undefined;
|
|
978
|
+
/** Same as `sort`, for the `CngxFilter` atom. */
|
|
979
|
+
filter?: () => CngxFilter<T> | null | undefined;
|
|
980
|
+
/** Same as `sort`, for the `CngxSearch` atom. */
|
|
981
|
+
search?: () => CngxSearch | null | undefined;
|
|
982
|
+
/** Same as `sort`, for the `CngxPaginate` atom. */
|
|
983
|
+
paginate?: () => CngxPaginate | null | undefined;
|
|
922
984
|
}
|
|
923
985
|
/**
|
|
924
986
|
* A CDK `DataSource` that optionally integrates with `CngxSort`,
|
|
@@ -926,6 +988,22 @@ interface CngxSmartDataSourceOptions<T> {
|
|
|
926
988
|
* tree. Each directive is injected optionally - if absent, that processing
|
|
927
989
|
* step is skipped.
|
|
928
990
|
*
|
|
991
|
+
* Injection resolves UPWARD only. Any atom hosted by a descendant component
|
|
992
|
+
* - a `hostDirective` on an element below the consumer's injector - is
|
|
993
|
+
* invisible to these injects, and the matching step is silently skipped:
|
|
994
|
+
* the atom's own state still toggles (headers flip their arrows) while the
|
|
995
|
+
* rows never move. `CngxDataGridAccordion` is the case where this is always
|
|
996
|
+
* true: it hosts `CngxSort` and `CngxFilter` on the group element. Hand
|
|
997
|
+
* such atoms in through the options thunks instead:
|
|
998
|
+
*
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* readonly grid = viewChild(CngxDataGridAccordion);
|
|
1001
|
+
* readonly dataSource = injectSmartDataSource(this.rows, {
|
|
1002
|
+
* sort: () => this.grid()?.sort,
|
|
1003
|
+
* filter: () => this.grid()?.filter,
|
|
1004
|
+
* });
|
|
1005
|
+
* ```
|
|
1006
|
+
*
|
|
929
1007
|
* Accepts either a plain `Signal<T[]>` or a `CngxAsyncState<T[]>`.
|
|
930
1008
|
* When a `CngxAsyncState` is provided, the data source exposes the full
|
|
931
1009
|
* UX state (`isLoading`, `isRefreshing`, `error`, `isEmpty`) so the
|
|
@@ -952,10 +1030,11 @@ interface CngxSmartDataSourceOptions<T> {
|
|
|
952
1030
|
declare class CngxSmartDataSource<T> extends DataSource<T> {
|
|
953
1031
|
private readonly options?;
|
|
954
1032
|
private readonly injector;
|
|
955
|
-
private readonly
|
|
956
|
-
private readonly
|
|
957
|
-
private readonly
|
|
958
|
-
private readonly
|
|
1033
|
+
private readonly injectedSort;
|
|
1034
|
+
private readonly injectedFilter;
|
|
1035
|
+
private readonly injectedSearch;
|
|
1036
|
+
private readonly injectedPaginate;
|
|
1037
|
+
private readonly locale;
|
|
959
1038
|
/**
|
|
960
1039
|
* Items after filter and search are applied, before sort and pagination.
|
|
961
1040
|
* Use `filteredCount()` to get the pre-pagination count for paginator `total`.
|
|
@@ -1010,7 +1089,7 @@ declare function injectSmartDataSource<T>(source: Signal<T[]> | CngxAsyncState<T
|
|
|
1010
1089
|
/**
|
|
1011
1090
|
* Writable extension of `CngxAsyncState` for manual control.
|
|
1012
1091
|
*
|
|
1013
|
-
* Returned by `createManualState()`
|
|
1092
|
+
* Returned by `createManualState()` - provides imperative setters
|
|
1014
1093
|
* while the read-side stays the standard `CngxAsyncState` interface.
|
|
1015
1094
|
*
|
|
1016
1095
|
* @category common/data/async-state
|
|
@@ -1028,10 +1107,10 @@ interface ManualAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1028
1107
|
reset(): void;
|
|
1029
1108
|
}
|
|
1030
1109
|
/**
|
|
1031
|
-
* Create a fully manual async state
|
|
1110
|
+
* Create a fully manual async state - no HTTP, no automatic loading.
|
|
1032
1111
|
*
|
|
1033
1112
|
* Use for local operations: heavy computations, Web Workers, complex local processes.
|
|
1034
|
-
* Does **not** require an injection context
|
|
1113
|
+
* Does **not** require an injection context - uses only `signal()` and `computed()`.
|
|
1035
1114
|
*
|
|
1036
1115
|
* ```typescript
|
|
1037
1116
|
* readonly processState = createManualState<ProcessResult>();
|
|
@@ -1048,6 +1127,25 @@ interface ManualAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1048
1127
|
*/
|
|
1049
1128
|
declare function createManualState<T>(): ManualAsyncState<T>;
|
|
1050
1129
|
|
|
1130
|
+
/**
|
|
1131
|
+
* Configuration options for `createAsyncState`.
|
|
1132
|
+
*
|
|
1133
|
+
* @category common/data/async-state
|
|
1134
|
+
*/
|
|
1135
|
+
interface CreateAsyncStateOptions {
|
|
1136
|
+
/**
|
|
1137
|
+
* Human-readable label surfaced in `CngxAsyncRegistry.activeOperations`.
|
|
1138
|
+
* Display only - never the registry key. Ignored unless `register` is set.
|
|
1139
|
+
*/
|
|
1140
|
+
label?: string;
|
|
1141
|
+
/**
|
|
1142
|
+
* When `true`, register this state in the ambient `CngxAsyncRegistry` (if
|
|
1143
|
+
* one is provided via `provideAsyncRegistry()`) for the injector's lifetime,
|
|
1144
|
+
* and unregister automatically on destroy. Defaults to `false` - a no-op for
|
|
1145
|
+
* existing callers, and a no-op when no registry is provided.
|
|
1146
|
+
*/
|
|
1147
|
+
register?: boolean;
|
|
1148
|
+
}
|
|
1051
1149
|
/**
|
|
1052
1150
|
* Writable async state for mutations (POST/PUT/DELETE).
|
|
1053
1151
|
*
|
|
@@ -1061,7 +1159,7 @@ interface MutableAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1061
1159
|
* Execute an async action.
|
|
1062
1160
|
*
|
|
1063
1161
|
* Sets status to `pending`, then `success` or `error` on completion.
|
|
1064
|
-
* Supersedes any in-flight execution
|
|
1162
|
+
* Supersedes any in-flight execution - the previous result is discarded
|
|
1065
1163
|
* but the underlying network request is not aborted.
|
|
1066
1164
|
*/
|
|
1067
1165
|
execute(fn: () => Promise<T> | Observable<T>): Promise<void>;
|
|
@@ -1071,7 +1169,7 @@ interface MutableAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1071
1169
|
reset(): void;
|
|
1072
1170
|
}
|
|
1073
1171
|
/**
|
|
1074
|
-
* Create a mutation async state
|
|
1172
|
+
* Create a mutation async state - for explicit user-triggered actions.
|
|
1075
1173
|
*
|
|
1076
1174
|
* Must be called in an injection context (field initializer or constructor)
|
|
1077
1175
|
* because it uses `inject(DestroyRef)` for cleanup.
|
|
@@ -1088,7 +1186,42 @@ interface MutableAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1088
1186
|
*
|
|
1089
1187
|
* @category common/data/async-state
|
|
1090
1188
|
*/
|
|
1091
|
-
declare function createAsyncState<T>(): MutableAsyncState<T>;
|
|
1189
|
+
declare function createAsyncState<T>(options?: CreateAsyncStateOptions): MutableAsyncState<T>;
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* Wraps a *changing* source of async state in a stable
|
|
1193
|
+
* {@link CngxAsyncState} façade.
|
|
1194
|
+
*
|
|
1195
|
+
* A component that receives its state through an `Input` cannot publish that
|
|
1196
|
+
* object through `CNGX_STATEFUL` directly: the token is resolved once when a
|
|
1197
|
+
* bridge injects it, while the input can be rebound or absent. Capturing the
|
|
1198
|
+
* object would hand the bridge a stale state - or `undefined` before the
|
|
1199
|
+
* first binding.
|
|
1200
|
+
*
|
|
1201
|
+
* This returns one object whose every member is a `computed()` that reads the
|
|
1202
|
+
* source on each access, so bridges observe transitions of whatever is bound
|
|
1203
|
+
* right now. With nothing bound it reports a quiet `idle` state rather than
|
|
1204
|
+
* throwing, which is what lets a bridge sit inside a timeline that has not
|
|
1205
|
+
* been given a state yet.
|
|
1206
|
+
*
|
|
1207
|
+
* Contrast the select family, which provides `CNGX_STATEFUL` with
|
|
1208
|
+
* `useFactory` over a concrete `commitState` field - no forwarding needed
|
|
1209
|
+
* there, because the state is created by the component rather than passed in.
|
|
1210
|
+
* The split is not about the component, it is about where the state is born:
|
|
1211
|
+
* created locally, capture it; arriving through an `Input`, forward it.
|
|
1212
|
+
*
|
|
1213
|
+
* ```ts
|
|
1214
|
+
* readonly asyncState = createForwardedAsyncState(this.state);
|
|
1215
|
+
*
|
|
1216
|
+
* // providers:
|
|
1217
|
+
* { provide: CNGX_STATEFUL, useFactory: () => ({ state: inject(Host).asyncState }) }
|
|
1218
|
+
* ```
|
|
1219
|
+
*
|
|
1220
|
+
* @category common/data/async-state
|
|
1221
|
+
* @relatedTo createAsyncState, createManualState
|
|
1222
|
+
* @since 0.1.0
|
|
1223
|
+
*/
|
|
1224
|
+
declare function createForwardedAsyncState<T>(source: () => CngxAsyncState<T> | undefined): CngxAsyncState<T>;
|
|
1092
1225
|
|
|
1093
1226
|
/**
|
|
1094
1227
|
* Configuration options for `injectAsyncState`.
|
|
@@ -1098,7 +1231,12 @@ declare function createAsyncState<T>(): MutableAsyncState<T>;
|
|
|
1098
1231
|
interface InjectAsyncStateOptions {
|
|
1099
1232
|
/**
|
|
1100
1233
|
* Debounce time in ms for signal dependency changes.
|
|
1101
|
-
*
|
|
1234
|
+
* Coalesces rapid changes into one state transition and one consumed
|
|
1235
|
+
* result. Note: a promise-returning `fn` still runs once per change -
|
|
1236
|
+
* the invocation is what tracks its signals - but only the freshest
|
|
1237
|
+
* capture is consumed; superseded captures are observed and discarded.
|
|
1238
|
+
* Cold Observables cost nothing until subscribed, so for them the
|
|
1239
|
+
* debounce fully prevents request storms.
|
|
1102
1240
|
* @default 50
|
|
1103
1241
|
*/
|
|
1104
1242
|
debounce?: number;
|
|
@@ -1131,7 +1269,7 @@ interface ReactiveAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1131
1269
|
* Create a reactive async state that auto-loads when signal dependencies change.
|
|
1132
1270
|
*
|
|
1133
1271
|
* Must be called in an injection context (field initializer or constructor).
|
|
1134
|
-
* The computation function is tracked by Angular's `effect()`
|
|
1272
|
+
* The computation function is tracked by Angular's `effect()` - any signal
|
|
1135
1273
|
* read inside `fn` will cause a re-load when it changes.
|
|
1136
1274
|
*
|
|
1137
1275
|
* ```typescript
|
|
@@ -1156,7 +1294,7 @@ type AsyncView = 'none' | 'skeleton' | 'content' | 'empty' | 'error' | 'content+
|
|
|
1156
1294
|
/**
|
|
1157
1295
|
* Pure function that resolves which view to show based on async state.
|
|
1158
1296
|
*
|
|
1159
|
-
* Encodes the state machine as a lookup table
|
|
1297
|
+
* Encodes the state machine as a lookup table - no branching:
|
|
1160
1298
|
*
|
|
1161
1299
|
* | status | firstLoad | empty | view |
|
|
1162
1300
|
* |-------------|-----------|-------|---------------|
|
|
@@ -1173,13 +1311,82 @@ type AsyncView = 'none' | 'skeleton' | 'content' | 'empty' | 'error' | 'content+
|
|
|
1173
1311
|
*/
|
|
1174
1312
|
declare function resolveAsyncView(status: AsyncStatus, firstLoad: boolean, empty: boolean): AsyncView;
|
|
1175
1313
|
|
|
1314
|
+
/**
|
|
1315
|
+
* One keyed upstream source feeding a {@link CngxAsyncBoundary}.
|
|
1316
|
+
*
|
|
1317
|
+
* The `key` (and optional `label`) travel with the state so per-source
|
|
1318
|
+
* attribution never relies on a parallel index array (Pillar 1).
|
|
1319
|
+
*
|
|
1320
|
+
* @category common/data/async-state
|
|
1321
|
+
* @since 0.1.0
|
|
1322
|
+
*/
|
|
1323
|
+
interface AggregateSource<T = unknown> {
|
|
1324
|
+
/** Stable identity for this source, used to key attribution and `@for`. */
|
|
1325
|
+
readonly key: string;
|
|
1326
|
+
/** Human-readable label for the source, surfaced in the failures list. */
|
|
1327
|
+
readonly label?: string;
|
|
1328
|
+
/** The upstream state this source contributes to the aggregate. */
|
|
1329
|
+
readonly state: CngxAsyncState<T>;
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* One errored source, surfaced by {@link CngxAsyncBoundary.failures}.
|
|
1333
|
+
*
|
|
1334
|
+
* @category common/data/async-state
|
|
1335
|
+
* @since 0.1.0
|
|
1336
|
+
*/
|
|
1337
|
+
interface AggregateFailure {
|
|
1338
|
+
/** The failing source's key. */
|
|
1339
|
+
readonly key: string;
|
|
1340
|
+
/** The failing source's label, if it declared one. */
|
|
1341
|
+
readonly label?: string;
|
|
1342
|
+
/** The raw error from that source. */
|
|
1343
|
+
readonly error: unknown;
|
|
1344
|
+
}
|
|
1345
|
+
/**
|
|
1346
|
+
* Headless boundary that aggregates N keyed `CngxAsyncState`s into one derived
|
|
1347
|
+
* `CngxAsyncState` and provides it as `CNGX_STATEFUL`.
|
|
1348
|
+
*
|
|
1349
|
+
* The aggregate `state` is a first-class `CngxAsyncState`, so it renders
|
|
1350
|
+
* through `<cngx-async-container [state]="b.state">` and every other consumer
|
|
1351
|
+
* unchanged, and any transition bridge (`cngxToastOn`, `cngxAlertOn`,
|
|
1352
|
+
* `cngxBannerOn`) nested in the host fires on the combined status with zero
|
|
1353
|
+
* `[state]` wiring. `failures` exposes the errored sources - keyed, so a
|
|
1354
|
+
* consumer's `@for` can render per-source attribution through any feedback
|
|
1355
|
+
* component. `state.error` stays the first error for the single-error path.
|
|
1356
|
+
*
|
|
1357
|
+
* ```html
|
|
1358
|
+
* <div [cngxAsyncBoundary]="sources" #b="cngxAsyncBoundary">
|
|
1359
|
+
* <cngx-async-container [state]="b.state"> ... </cngx-async-container>
|
|
1360
|
+
* <cngx-toast-on />
|
|
1361
|
+
* @for (f of b.failures(); track f.key) {
|
|
1362
|
+
* <cngx-banner>{{ f.label }} failed</cngx-banner>
|
|
1363
|
+
* }
|
|
1364
|
+
* </div>
|
|
1365
|
+
* ```
|
|
1366
|
+
*
|
|
1367
|
+
* @category common/data/async-state
|
|
1368
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async-state/async-boundary.directive.ts
|
|
1369
|
+
* @since 0.1.0
|
|
1370
|
+
*/
|
|
1371
|
+
declare class CngxAsyncBoundary implements CngxStateful<readonly unknown[]> {
|
|
1372
|
+
/** The keyed source list to aggregate. */
|
|
1373
|
+
readonly sources: _angular_core.InputSignal<readonly AggregateSource<unknown>[]>;
|
|
1374
|
+
private readonly states;
|
|
1375
|
+
/** The derived aggregate state - also exposed via `CNGX_STATEFUL`. */
|
|
1376
|
+
readonly state: CngxAsyncState<readonly unknown[]>;
|
|
1377
|
+
/** The errored sources, keyed for per-source attribution. */
|
|
1378
|
+
readonly failures: _angular_core.Signal<readonly AggregateFailure[]>;
|
|
1379
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsyncBoundary, never>;
|
|
1380
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAsyncBoundary, "[cngxAsyncBoundary]", ["cngxAsyncBoundary"], { "sources": { "alias": "cngxAsyncBoundary"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1176
1383
|
/**
|
|
1177
1384
|
* Bridge that projects an Angular `Resource<T>` onto `CngxAsyncState<T>`.
|
|
1178
1385
|
*
|
|
1179
1386
|
* Must be called in an injection context (the `effect()` that tracks
|
|
1180
1387
|
* `hadSuccess` requires one).
|
|
1181
1388
|
*
|
|
1182
|
-
* All signals are derived reactively from the resource
|
|
1389
|
+
* All signals are derived reactively from the resource - no manual
|
|
1183
1390
|
* synchronization. The resource stays the single source of truth.
|
|
1184
1391
|
*
|
|
1185
1392
|
* ```typescript
|
|
@@ -1191,8 +1398,8 @@ declare function resolveAsyncView(status: AsyncStatus, firstLoad: boolean, empty
|
|
|
1191
1398
|
* });
|
|
1192
1399
|
*
|
|
1193
1400
|
* readonly items = fromResource(this.res);
|
|
1194
|
-
* // items.status(), items.data(), items.isFirstLoad()
|
|
1195
|
-
* // <cngx-async-container [state]="items">
|
|
1401
|
+
* // items.status(), items.data(), items.isFirstLoad() - all work
|
|
1402
|
+
* // <cngx-async-container [state]="items"> - direct binding
|
|
1196
1403
|
* ```
|
|
1197
1404
|
*
|
|
1198
1405
|
* @category common/data/async-state
|
|
@@ -1200,7 +1407,7 @@ declare function resolveAsyncView(status: AsyncStatus, firstLoad: boolean, empty
|
|
|
1200
1407
|
declare function fromResource<T>(ref: Resource<T>): CngxAsyncState<T>;
|
|
1201
1408
|
|
|
1202
1409
|
/**
|
|
1203
|
-
* Shape of an `HttpResourceRef`
|
|
1410
|
+
* Shape of an `HttpResourceRef` - only the signals we need.
|
|
1204
1411
|
*
|
|
1205
1412
|
* Declared here to avoid a hard dependency on `@angular/common/http`.
|
|
1206
1413
|
* The consumer passes the actual `httpResource()` return value which
|
|
@@ -1225,7 +1432,7 @@ interface HttpResourceLike<T> extends Resource<T> {
|
|
|
1225
1432
|
*
|
|
1226
1433
|
* readonly items = fromHttpResource(this.res);
|
|
1227
1434
|
* // items.progress() tracks upload/download progress
|
|
1228
|
-
* // <cngx-progress [state]="items">
|
|
1435
|
+
* // <cngx-progress [state]="items"> - auto-wired progress bar
|
|
1229
1436
|
* ```
|
|
1230
1437
|
*
|
|
1231
1438
|
* @category common/data/async-state
|
|
@@ -1235,22 +1442,31 @@ declare function fromHttpResource<T>(ref: HttpResourceLike<T>): CngxAsyncState<T
|
|
|
1235
1442
|
/**
|
|
1236
1443
|
* Minimal write interface for async state operators.
|
|
1237
1444
|
*
|
|
1238
|
-
* Any `ManualAsyncState<T>` satisfies this
|
|
1445
|
+
* Any `ManualAsyncState<T>` satisfies this - operators only need the write side.
|
|
1239
1446
|
*/
|
|
1240
1447
|
interface AsyncStateSink<T> {
|
|
1241
|
-
set(status: 'loading' | 'refreshing' | 'pending'): void;
|
|
1448
|
+
set(status: 'idle' | 'loading' | 'refreshing' | 'pending'): void;
|
|
1242
1449
|
setSuccess(data: T): void;
|
|
1243
1450
|
setError(error: unknown): void;
|
|
1244
1451
|
setProgress(value: number | undefined): void;
|
|
1452
|
+
/**
|
|
1453
|
+
* Optional read side: when present, `tapAsyncState` picks `refreshing`
|
|
1454
|
+
* over `loading` for a re-subscribe after data has already landed.
|
|
1455
|
+
* Any `ManualAsyncState<T>` provides it.
|
|
1456
|
+
*/
|
|
1457
|
+
isFirstLoad?: () => boolean;
|
|
1245
1458
|
}
|
|
1246
1459
|
/**
|
|
1247
1460
|
* RxJS operator that wires an Observable's lifecycle to a `ManualAsyncState`.
|
|
1248
1461
|
*
|
|
1249
|
-
* On subscribe: sets `loading` (or `refreshing` if data was already loaded
|
|
1462
|
+
* On subscribe: sets `loading` (or `refreshing` if data was already loaded,
|
|
1463
|
+
* read via the sink's `isFirstLoad`; an explicit `options.status` wins).
|
|
1250
1464
|
* On next: calls `setSuccess(value)`.
|
|
1251
1465
|
* On error: calls `setError(err)` and **re-throws** (does not swallow).
|
|
1466
|
+
* On teardown without a value (unsubscribe mid-flight, empty complete):
|
|
1467
|
+
* resets the sink to `idle` so a cancelled request never leaves it busy.
|
|
1252
1468
|
*
|
|
1253
|
-
* The Observable passes through unchanged
|
|
1469
|
+
* The Observable passes through unchanged - `tapAsyncState` is a side-effect operator.
|
|
1254
1470
|
*
|
|
1255
1471
|
* ```typescript
|
|
1256
1472
|
* readonly residents = createManualState<Resident[]>();
|
|
@@ -1319,7 +1535,7 @@ declare function tapAsyncProgress<E>(state: Pick<AsyncStateSink<unknown>, 'setPr
|
|
|
1319
1535
|
* tapHttpAsyncState(this.upload),
|
|
1320
1536
|
* takeUntilDestroyed(this.destroyRef),
|
|
1321
1537
|
* ).subscribe();
|
|
1322
|
-
* // upload.status(), upload.progress(), upload.data()
|
|
1538
|
+
* // upload.status(), upload.progress(), upload.data() - all wired
|
|
1323
1539
|
* }
|
|
1324
1540
|
* ```
|
|
1325
1541
|
*
|
|
@@ -1413,6 +1629,30 @@ declare function provideAsyncRegistry(): EnvironmentProviders;
|
|
|
1413
1629
|
*/
|
|
1414
1630
|
declare function injectAsyncRegistry(): CngxAsyncRegistry | null;
|
|
1415
1631
|
|
|
1632
|
+
/**
|
|
1633
|
+
* Bridges {@link CngxAsyncRegistry} into a {@link CngxLatencyProbe} measuring the
|
|
1634
|
+
* registry's observed busy-envelope: how long the app was "anything loading"
|
|
1635
|
+
* during the last in-flight window.
|
|
1636
|
+
*
|
|
1637
|
+
* An app-shell indicator compares `lastDuration()` against
|
|
1638
|
+
* `CNGX_LOADING_CONFIG.spinnerVsSkeletonCutoff` to pick a spinner (fast last
|
|
1639
|
+
* aggregate) vs a skeleton (slow last aggregate) before the next load renders.
|
|
1640
|
+
*
|
|
1641
|
+
* When the registry is absent (`provideAsyncRegistry` never called),
|
|
1642
|
+
* `injectAsyncRegistry()` returns `null`, so the probe's source is permanently
|
|
1643
|
+
* `false`: it is never busy and never throws.
|
|
1644
|
+
*
|
|
1645
|
+
* Must run in an injection context.
|
|
1646
|
+
*
|
|
1647
|
+
* @returns A probe over `CngxAsyncRegistry.isAnythingLoading`.
|
|
1648
|
+
*
|
|
1649
|
+
* @category common/data/async-registry
|
|
1650
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async-registry/inject-latency-probe.ts
|
|
1651
|
+
* @since 0.1.0
|
|
1652
|
+
* @relatedTo provideAsyncRegistry, injectAsyncRegistry, createLatencyProbe
|
|
1653
|
+
*/
|
|
1654
|
+
declare function injectLatencyProbe(): CngxLatencyProbe;
|
|
1655
|
+
|
|
1416
1656
|
/**
|
|
1417
1657
|
* Per-request label surfaced in `CngxAsyncRegistry.activeOperations` when the
|
|
1418
1658
|
* request is tracked by `cngxAsyncInterceptor`. Display only, never a key.
|
|
@@ -1525,7 +1765,10 @@ interface CngxAsyncContext<T> {
|
|
|
1525
1765
|
* - **success + empty** → empty template (or nothing)
|
|
1526
1766
|
* - **error (first load)** → error template (or nothing)
|
|
1527
1767
|
* - **refreshing / loading (with data)** → content template (old data stays visible)
|
|
1528
|
-
* - **error (with data)** → content template (old data stays visible)
|
|
1768
|
+
* - **error (with data)** → content template (old data stays visible) -
|
|
1769
|
+
* `resolveAsyncView` reports this as `content+error`, but a structural
|
|
1770
|
+
* directive renders exactly one template, so the error half is flattened
|
|
1771
|
+
* away here; surface it separately (toast, alert) when it must be visible
|
|
1529
1772
|
*
|
|
1530
1773
|
* ### Minimal - just content
|
|
1531
1774
|
* ```html
|
|
@@ -1581,7 +1824,7 @@ declare class CngxAsync<T> {
|
|
|
1581
1824
|
$implicit: unknown;
|
|
1582
1825
|
}> | undefined>;
|
|
1583
1826
|
private readonly view;
|
|
1584
|
-
private
|
|
1827
|
+
private currentView;
|
|
1585
1828
|
private contentViewRef;
|
|
1586
1829
|
constructor();
|
|
1587
1830
|
private updateContentContext;
|
|
@@ -1596,8 +1839,9 @@ declare class CngxAsync<T> {
|
|
|
1596
1839
|
/**
|
|
1597
1840
|
* Displays a formatted numeric value with optional unit.
|
|
1598
1841
|
*
|
|
1599
|
-
* Uses `Intl.NumberFormat` with the
|
|
1600
|
-
*
|
|
1842
|
+
* Uses `Intl.NumberFormat` with the app locale (`CNGX_LOCALE`, falling back to
|
|
1843
|
+
* the nearest `LOCALE_ID`) for locale-aware formatting; a locale flip
|
|
1844
|
+
* re-formats. A `null` value renders the placeholder glyph without its unit.
|
|
1601
1845
|
*
|
|
1602
1846
|
* Composable - works inside any card variant, header, body, or standalone.
|
|
1603
1847
|
*
|
|
@@ -1631,7 +1875,11 @@ declare class CngxAsync<T> {
|
|
|
1631
1875
|
*/
|
|
1632
1876
|
declare class CngxMetric {
|
|
1633
1877
|
private readonly locale;
|
|
1634
|
-
|
|
1878
|
+
private readonly i18n;
|
|
1879
|
+
/**
|
|
1880
|
+
* Numeric or string value. `null` renders the `metricPlaceholder` glyph of
|
|
1881
|
+
* the kpi language section and is announced as its `metricNoValue` text.
|
|
1882
|
+
*/
|
|
1635
1883
|
readonly value: _angular_core.InputSignal<string | number | null>;
|
|
1636
1884
|
/** Unit suffix (e.g. "bpm", "h", "%", "kg"). */
|
|
1637
1885
|
readonly unit: _angular_core.InputSignal<string | undefined>;
|
|
@@ -1639,6 +1887,13 @@ declare class CngxMetric {
|
|
|
1639
1887
|
readonly format: _angular_core.InputSignal<Intl.NumberFormatOptions | undefined>;
|
|
1640
1888
|
/** @internal */
|
|
1641
1889
|
readonly formattedValue: _angular_core.Signal<string>;
|
|
1890
|
+
/**
|
|
1891
|
+
* @internal The unit to render, `undefined` while there is no value: a
|
|
1892
|
+
* missing reading has no unit, so "No value km" is never shown or spoken.
|
|
1893
|
+
*/
|
|
1894
|
+
protected readonly shownUnit: _angular_core.Signal<string | undefined>;
|
|
1895
|
+
/** @internal Unit before value, per the `metricValueWithUnit` message. */
|
|
1896
|
+
protected readonly unitFirst: _angular_core.Signal<boolean>;
|
|
1642
1897
|
/** @internal Full accessible description including unit. */
|
|
1643
1898
|
readonly accessibleValue: _angular_core.Signal<string>;
|
|
1644
1899
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMetric, never>;
|
|
@@ -1684,6 +1939,7 @@ declare class CngxMetric {
|
|
|
1684
1939
|
*/
|
|
1685
1940
|
declare class CngxTrend {
|
|
1686
1941
|
private readonly locale;
|
|
1942
|
+
private readonly i18n;
|
|
1687
1943
|
/** Trend percentage. Positive = up, negative = down, zero = flat. */
|
|
1688
1944
|
readonly value: _angular_core.InputSignal<number>;
|
|
1689
1945
|
/** Consumer-provided SR label override. When set, replaces the generated default. */
|
|
@@ -1698,18 +1954,6 @@ declare class CngxTrend {
|
|
|
1698
1954
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxTrend, "cngx-trend", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1699
1955
|
}
|
|
1700
1956
|
|
|
1701
|
-
/**
|
|
1702
|
-
* Pure, framework-agnostic helpers that turn a signed delta value into the
|
|
1703
|
-
* three orthogonal signals a KPI atom renders: **direction** (which way the
|
|
1704
|
-
* arrow points), **sentiment** (whether the change is good or bad, which
|
|
1705
|
-
* drives colour and the SR word), and the formatted magnitude.
|
|
1706
|
-
*
|
|
1707
|
-
* Direction and sentiment are deliberately separate. `CngxTrend` colours by
|
|
1708
|
-
* direction (up = green); `CngxDelta` colours by sentiment, so a value that
|
|
1709
|
-
* dropped can still read as an improvement (churn down, latency down). Both
|
|
1710
|
-
* consume these helpers so the direction / glyph / format logic has a single
|
|
1711
|
-
* source of truth (Pillar 1) with no Angular dependency.
|
|
1712
|
-
*/
|
|
1713
1957
|
/** Which way the delta moved. `flat` is exactly zero. */
|
|
1714
1958
|
type DeltaDirection = 'up' | 'down' | 'flat';
|
|
1715
1959
|
/**
|
|
@@ -1761,6 +2005,7 @@ type DeltaMode = 'percent' | 'absolute';
|
|
|
1761
2005
|
*/
|
|
1762
2006
|
declare class CngxDelta {
|
|
1763
2007
|
private readonly locale;
|
|
2008
|
+
private readonly i18n;
|
|
1764
2009
|
/** Signed delta. Positive = up, negative = down, zero = flat. */
|
|
1765
2010
|
readonly value: _angular_core.InputSignal<number>;
|
|
1766
2011
|
/**
|
|
@@ -1776,19 +2021,115 @@ declare class CngxDelta {
|
|
|
1776
2021
|
/** Consumer-provided SR label override. Replaces the generated default. */
|
|
1777
2022
|
readonly label: _angular_core.InputSignal<string | undefined>;
|
|
1778
2023
|
/** @internal Raw movement, independent of polarity. Drives the glyph. */
|
|
1779
|
-
protected readonly direction: _angular_core.Signal<DeltaDirection>;
|
|
2024
|
+
protected readonly direction: _angular_core.Signal<_cngx_common_data.DeltaDirection>;
|
|
1780
2025
|
/** @internal Good / bad / indifferent. Drives colour and the SR word. */
|
|
1781
|
-
protected readonly sentiment: _angular_core.Signal<DeltaSentiment>;
|
|
2026
|
+
protected readonly sentiment: _angular_core.Signal<_cngx_common_data.DeltaSentiment>;
|
|
1782
2027
|
/** @internal Arrow glyph bound from direction only. */
|
|
1783
2028
|
protected readonly glyph: _angular_core.Signal<string>;
|
|
1784
2029
|
/** @internal Formatted magnitude. */
|
|
1785
2030
|
protected readonly formattedValue: _angular_core.Signal<string>;
|
|
1786
|
-
/**
|
|
2031
|
+
/**
|
|
2032
|
+
* @internal Full SR label: magnitude plus the sentiment word, composed by
|
|
2033
|
+
* `CNGX_KPI_I18N.deltaLabel` unless `[label]` is bound.
|
|
2034
|
+
*/
|
|
1787
2035
|
protected readonly resolvedLabel: _angular_core.Signal<string>;
|
|
1788
2036
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDelta, never>;
|
|
1789
2037
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxDelta, "cngx-delta", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "polarity": { "alias": "polarity"; "required": false; "isSignal": true; }; "mode": { "alias": "mode"; "required": false; "isSignal": true; }; "format": { "alias": "format"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1790
2038
|
}
|
|
1791
2039
|
|
|
2040
|
+
/**
|
|
2041
|
+
* KPI atom i18n surface. Library defaults are English; consumers override
|
|
2042
|
+
* via {@link provideKpiI18n}. Reactive from birth: the token carries a
|
|
2043
|
+
* `Signal`, and {@link withKpiI18nLabels} accepts a `Signal` of a partial
|
|
2044
|
+
* bundle, so a runtime language switch re-derives every label.
|
|
2045
|
+
*
|
|
2046
|
+
* Every key is a formatter, so word order and plural rules belong to the
|
|
2047
|
+
* translator. The magnitude arrives already formatted in the app locale
|
|
2048
|
+
* (`CNGX_LOCALE`); the per-instance `label` / `valueTextFormat` inputs still
|
|
2049
|
+
* win over the bundle.
|
|
2050
|
+
*
|
|
2051
|
+
* @category common/data/i18n
|
|
2052
|
+
* @since 0.1.0
|
|
2053
|
+
*/
|
|
2054
|
+
interface CngxKpiI18n {
|
|
2055
|
+
/** `CngxDelta` accessible name: formatted magnitude plus the sentiment word. */
|
|
2056
|
+
readonly deltaLabel: (formatted: string, sentiment: DeltaSentiment) => string;
|
|
2057
|
+
/** `CngxTrend` accessible name: formatted magnitude plus the direction word. */
|
|
2058
|
+
readonly trendLabel: (formatted: string, direction: DeltaDirection) => string;
|
|
2059
|
+
/** `CngxGoal` `aria-valuetext`: clamped value and target. */
|
|
2060
|
+
readonly goalValueText: (now: number, max: number) => string;
|
|
2061
|
+
/**
|
|
2062
|
+
* `CngxMetric` order of value and unit: `{value}` and `{unit}` in reading
|
|
2063
|
+
* order, a plain template the metric renders as two elements. English
|
|
2064
|
+
* `'{value} {unit}'`.
|
|
2065
|
+
*/
|
|
2066
|
+
readonly metricValueWithUnit: string;
|
|
2067
|
+
/** Shown in place of a `CngxMetric` without a value. English: the U+2014 glyph. */
|
|
2068
|
+
readonly metricPlaceholder: string;
|
|
2069
|
+
/** Accessible name of a `CngxMetric` without a value. English `No value`. */
|
|
2070
|
+
readonly metricNoValue: string;
|
|
2071
|
+
}
|
|
2072
|
+
/**
|
|
2073
|
+
* DI token for the KPI i18n bundle. `providedIn: 'root'`: the kpi section
|
|
2074
|
+
* of the active language pack over the English defaults, formatted for the
|
|
2075
|
+
* app locale; the value is a `Signal`, shared by every reader under one
|
|
2076
|
+
* injector.
|
|
2077
|
+
*
|
|
2078
|
+
* @category common/data/i18n
|
|
2079
|
+
* @wcag AA
|
|
2080
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/shared/kpi-i18n.ts
|
|
2081
|
+
* @since 0.1.0
|
|
2082
|
+
* @relatedTo CngxDelta, CngxTrend, CngxGoal
|
|
2083
|
+
*/
|
|
2084
|
+
declare const CNGX_KPI_I18N: InjectionToken<Signal<CngxKpiI18n>>;
|
|
2085
|
+
/**
|
|
2086
|
+
* Branded feature-fn for {@link provideKpiI18n}.
|
|
2087
|
+
*
|
|
2088
|
+
* @category common/data/i18n
|
|
2089
|
+
* @since 0.1.0
|
|
2090
|
+
*/
|
|
2091
|
+
type CngxKpiI18nFeature = ((bundle: Signal<CngxKpiI18n>) => Signal<CngxKpiI18n>) & {
|
|
2092
|
+
readonly _target: 'i18n';
|
|
2093
|
+
};
|
|
2094
|
+
/**
|
|
2095
|
+
* Override KPI labels via a partial bundle - unset keys keep the language
|
|
2096
|
+
* pack's copy, or the English default. Pass a `Signal` of a partial bundle to switch languages at
|
|
2097
|
+
* runtime.
|
|
2098
|
+
*
|
|
2099
|
+
* @category common/data/i18n
|
|
2100
|
+
* @since 0.1.0
|
|
2101
|
+
*/
|
|
2102
|
+
declare function withKpiI18nLabels(overrides: Partial<CngxKpiI18n> | Signal<Partial<CngxKpiI18n>>): CngxKpiI18nFeature;
|
|
2103
|
+
/**
|
|
2104
|
+
* Provider for the KPI i18n bundle. Returns a plain `Provider`, so it also
|
|
2105
|
+
* scopes a subtree through `viewProviders`. The features apply on top of the
|
|
2106
|
+
* active language pack.
|
|
2107
|
+
*
|
|
2108
|
+
* ```ts
|
|
2109
|
+
* bootstrapApplication(AppComponent, {
|
|
2110
|
+
* providers: [
|
|
2111
|
+
* provideKpiI18n(
|
|
2112
|
+
* withKpiI18nLabels({
|
|
2113
|
+
* goalValueText: (now, max) => `${now} von ${max}`,
|
|
2114
|
+
* }),
|
|
2115
|
+
* ),
|
|
2116
|
+
* ],
|
|
2117
|
+
* });
|
|
2118
|
+
* ```
|
|
2119
|
+
*
|
|
2120
|
+
* @category common/data/i18n
|
|
2121
|
+
* @since 0.1.0
|
|
2122
|
+
*/
|
|
2123
|
+
declare function provideKpiI18n(...features: readonly CngxKpiI18nFeature[]): Provider;
|
|
2124
|
+
/**
|
|
2125
|
+
* Inject the resolved KPI i18n bundle signal. Read it inside a `computed()`
|
|
2126
|
+
* or template so a runtime override flip re-derives.
|
|
2127
|
+
*
|
|
2128
|
+
* @category common/data/i18n
|
|
2129
|
+
* @since 0.1.0
|
|
2130
|
+
*/
|
|
2131
|
+
declare function injectKpiI18n(): Signal<CngxKpiI18n>;
|
|
2132
|
+
|
|
1792
2133
|
/** The four coordinated slots of a {@link CngxStat}, in reading order. */
|
|
1793
2134
|
type CngxStatSlotKind = 'label' | 'value' | 'delta' | 'caption';
|
|
1794
2135
|
/**
|
|
@@ -1802,12 +2143,62 @@ type CngxStatSlotKind = 'label' | 'value' | 'delta' | 'caption';
|
|
|
1802
2143
|
interface CngxStatRegistry {
|
|
1803
2144
|
/** Register (or replace) the id contributed by `kind`. */
|
|
1804
2145
|
register(kind: CngxStatSlotKind, id: string): void;
|
|
1805
|
-
/**
|
|
1806
|
-
|
|
2146
|
+
/**
|
|
2147
|
+
* Withdraw the id contributed by `kind`. When `id` is given, the
|
|
2148
|
+
* withdrawal applies only while that id is still the registered one -
|
|
2149
|
+
* a register-before-destroy replacement is left alone.
|
|
2150
|
+
*/
|
|
2151
|
+
unregister(kind: CngxStatSlotKind, id?: string): void;
|
|
1807
2152
|
}
|
|
1808
2153
|
/** DI token carrying the {@link CngxStatRegistry} a `CngxStat` provides. */
|
|
1809
2154
|
declare const CNGX_STAT: InjectionToken<CngxStatRegistry>;
|
|
1810
2155
|
|
|
2156
|
+
/**
|
|
2157
|
+
* The slot-id coordination brain behind {@link CNGX_STAT}. Collects the id each
|
|
2158
|
+
* `cngxStat*` slot registers and derives one `aria-labelledby` that reads the
|
|
2159
|
+
* whole stat as a single accessible name in reading order.
|
|
2160
|
+
*
|
|
2161
|
+
* Lives as a host directive rather than inside `CngxStat` because the slot
|
|
2162
|
+
* directives resolve `CNGX_STAT` against their **declaration** site: content
|
|
2163
|
+
* written inside an organism never reaches a `<cngx-stat>` that sits in that
|
|
2164
|
+
* organism's own template. Any component that wants to host the four slots
|
|
2165
|
+
* therefore applies this brain and re-points the token at it:
|
|
2166
|
+
*
|
|
2167
|
+
* ```ts
|
|
2168
|
+
* hostDirectives: [CngxStatCoordinator],
|
|
2169
|
+
* providers: [{ provide: CNGX_STAT, useExisting: CngxStatCoordinator }],
|
|
2170
|
+
* ```
|
|
2171
|
+
*
|
|
2172
|
+
* Same shape as `CngxPaginate` behind `CNGX_PAGINATOR_HOST`, which
|
|
2173
|
+
* `CngxPaginator` and `CngxIncrementalList` share the same way.
|
|
2174
|
+
*
|
|
2175
|
+
* @category common/data/metric
|
|
2176
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/stat/stat-coordinator.directive.ts
|
|
2177
|
+
* @since 0.1.0
|
|
2178
|
+
* @relatedTo CngxStat, CNGX_STAT
|
|
2179
|
+
*/
|
|
2180
|
+
declare class CngxStatCoordinator implements CngxStatRegistry {
|
|
2181
|
+
private readonly slots;
|
|
2182
|
+
/** {@inheritDoc CngxStatRegistry.register} */
|
|
2183
|
+
register(kind: CngxStatSlotKind, id: string): void;
|
|
2184
|
+
/** {@inheritDoc CngxStatRegistry.unregister} */
|
|
2185
|
+
unregister(kind: CngxStatSlotKind, id?: string): void;
|
|
2186
|
+
/** Present slot ids in reading order; structurally stable. */
|
|
2187
|
+
readonly orderedIds: _angular_core.Signal<string[]>;
|
|
2188
|
+
/** Combined accessible name for the host; `null` when no slot is present. */
|
|
2189
|
+
readonly labelledBy: _angular_core.Signal<string | null>;
|
|
2190
|
+
/**
|
|
2191
|
+
* Which slots a consumer actually projected, in reading order. Registration
|
|
2192
|
+
* happens when the slot directive is constructed in the consumer's template,
|
|
2193
|
+
* so this stays accurate even while the host renders a branch that does not
|
|
2194
|
+
* include the `<ng-content>` outlets - which is what lets a placeholder mirror
|
|
2195
|
+
* the real tile instead of guessing at it.
|
|
2196
|
+
*/
|
|
2197
|
+
readonly presentKinds: _angular_core.Signal<CngxStatSlotKind[]>;
|
|
2198
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxStatCoordinator, never>;
|
|
2199
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxStatCoordinator, never, never, {}, {}, never, never, true, never>;
|
|
2200
|
+
}
|
|
2201
|
+
|
|
1811
2202
|
/**
|
|
1812
2203
|
* Coordination molecule for a KPI stat. Its sole reason to exist is the
|
|
1813
2204
|
* screen-reader layer (Pillar 2): hand-assembling a heading, a `<cngx-metric>`
|
|
@@ -1816,9 +2207,10 @@ declare const CNGX_STAT: InjectionToken<CngxStatRegistry>;
|
|
|
1816
2207
|
* collects the id each slot registers, and derives one `aria-labelledby` that
|
|
1817
2208
|
* reads the whole stat as a single accessible name in reading order.
|
|
1818
2209
|
*
|
|
1819
|
-
* Composition, never a config bag (Pillar 3): the
|
|
1820
|
-
*
|
|
1821
|
-
*
|
|
2210
|
+
* Composition, never a config bag (Pillar 3): the id coordination lives in the
|
|
2211
|
+
* {@link CngxStatCoordinator} host directive, so another component that hosts
|
|
2212
|
+
* the same four slots applies the identical brain instead of reimplementing it.
|
|
2213
|
+
* The visuals stay whatever atoms the consumer projects into the slots.
|
|
1822
2214
|
*
|
|
1823
2215
|
* ```html
|
|
1824
2216
|
* <cngx-stat aria-live="polite">
|
|
@@ -1834,27 +2226,20 @@ declare const CNGX_STAT: InjectionToken<CngxStatRegistry>;
|
|
|
1834
2226
|
* @wcag AA
|
|
1835
2227
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/stat/stat.component.ts
|
|
1836
2228
|
* @since 0.1.0
|
|
1837
|
-
* @relatedTo CngxMetric, CngxDelta, CngxTrend
|
|
2229
|
+
* @relatedTo CngxMetric, CngxDelta, CngxTrend, CngxStatCoordinator
|
|
1838
2230
|
*
|
|
1839
2231
|
* <example-url>http://localhost:4200/#/common/data/stat/composed-kpi</example-url>
|
|
1840
2232
|
*/
|
|
1841
|
-
declare class CngxStat
|
|
1842
|
-
|
|
2233
|
+
declare class CngxStat {
|
|
2234
|
+
/** @internal The shared slot-id brain, applied as a host directive. */
|
|
2235
|
+
protected readonly coordinator: CngxStatCoordinator;
|
|
1843
2236
|
/**
|
|
1844
2237
|
* Politeness of the live region. `off` (default) for a static stat;
|
|
1845
2238
|
* `polite` / `assertive` for a KPI whose value updates in place.
|
|
1846
2239
|
*/
|
|
1847
2240
|
readonly live: _angular_core.InputSignal<"off" | "polite" | "assertive">;
|
|
1848
|
-
/** {@inheritDoc CngxStatRegistry.register} */
|
|
1849
|
-
register(kind: CngxStatSlotKind, id: string): void;
|
|
1850
|
-
/** {@inheritDoc CngxStatRegistry.unregister} */
|
|
1851
|
-
unregister(kind: CngxStatSlotKind): void;
|
|
1852
|
-
/** @internal Present slot ids in reading order; structurally stable. */
|
|
1853
|
-
protected readonly orderedIds: _angular_core.Signal<string[]>;
|
|
1854
|
-
/** @internal Combined accessible name; `null` when no slot is present. */
|
|
1855
|
-
protected readonly labelledBy: _angular_core.Signal<string | null>;
|
|
1856
2241
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxStat, never>;
|
|
1857
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxStat, "cngx-stat", never, { "live": { "alias": "live"; "required": false; "isSignal": true; }; }, {}, never, ["[cngxStatLabel]", "[cngxStatValue]", "[cngxStatDelta]", "[cngxStatCaption]"], true,
|
|
2242
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxStat, "cngx-stat", never, { "live": { "alias": "live"; "required": false; "isSignal": true; }; }, {}, never, ["[cngxStatLabel]", "[cngxStatValue]", "[cngxStatDelta]", "[cngxStatCaption]"], true, [{ directive: typeof CngxStatCoordinator; inputs: {}; outputs: {}; }]>;
|
|
1858
2243
|
}
|
|
1859
2244
|
|
|
1860
2245
|
/**
|
|
@@ -1914,56 +2299,6 @@ declare class CngxStatCaption {
|
|
|
1914
2299
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxStatCaption, "[cngxStatCaption]", never, {}, {}, never, never, true, never>;
|
|
1915
2300
|
}
|
|
1916
2301
|
|
|
1917
|
-
/** Semantic health of a {@link CngxStatus}. */
|
|
1918
|
-
type StatusTone = 'success' | 'warning' | 'danger' | 'info' | 'neutral';
|
|
1919
|
-
/**
|
|
1920
|
-
* Semantic health indicator - a decorative tone dot paired with a visible
|
|
1921
|
-
* label. Distinct from `CngxBadge` (count overlay), `CngxChip` (interactive)
|
|
1922
|
-
* and `CngxTag` (labeled token): its single job is to communicate a status
|
|
1923
|
-
* (operational / degraded / down / info).
|
|
1924
|
-
*
|
|
1925
|
-
* Colour is never the only signal (Pillar 2): the tone drives the dot colour
|
|
1926
|
-
* *and* a tone glyph, so a colour-blind reader still distinguishes the states,
|
|
1927
|
-
* and the visible `label` carries the meaning for assistive tech (the dot is
|
|
1928
|
-
* `aria-hidden`). Set `live` for a status that changes in place.
|
|
1929
|
-
*
|
|
1930
|
-
* ### Basic
|
|
1931
|
-
* ```html
|
|
1932
|
-
* <cngx-status tone="success" label="Operational" />
|
|
1933
|
-
* ```
|
|
1934
|
-
*
|
|
1935
|
-
* ### Live-updating
|
|
1936
|
-
* ```html
|
|
1937
|
-
* <cngx-status tone="danger" label="Outage" live="assertive" />
|
|
1938
|
-
* ```
|
|
1939
|
-
*
|
|
1940
|
-
* @category common/data/metric
|
|
1941
|
-
* @docsKind primary
|
|
1942
|
-
* @wcag AA
|
|
1943
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/status/status.component.ts
|
|
1944
|
-
* @since 0.1.0
|
|
1945
|
-
* @relatedTo CngxBadge, CngxTag, CngxChip
|
|
1946
|
-
*
|
|
1947
|
-
* <example-url>http://localhost:4200/#/common/data/status/tone-matrix</example-url>
|
|
1948
|
-
*/
|
|
1949
|
-
declare class CngxStatus {
|
|
1950
|
-
private readonly elRef;
|
|
1951
|
-
/** Semantic health. Drives both the dot colour and the tone glyph. */
|
|
1952
|
-
readonly tone: _angular_core.InputSignal<StatusTone>;
|
|
1953
|
-
/** Visible status text. Carries the meaning for assistive tech. */
|
|
1954
|
-
readonly label: _angular_core.InputSignal<string | undefined>;
|
|
1955
|
-
/**
|
|
1956
|
-
* Politeness of the live region. `off` (default) for a static status;
|
|
1957
|
-
* `polite` / `assertive` for a status that changes in place.
|
|
1958
|
-
*/
|
|
1959
|
-
readonly live: _angular_core.InputSignal<"off" | "polite" | "assertive">;
|
|
1960
|
-
/** @internal Tone glyph bound into the decorative dot. */
|
|
1961
|
-
protected readonly glyph: _angular_core.Signal<string>;
|
|
1962
|
-
constructor();
|
|
1963
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxStatus, never>;
|
|
1964
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxStatus, "cngx-status", never, { "tone": { "alias": "tone"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "live": { "alias": "live"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1965
|
-
}
|
|
1966
|
-
|
|
1967
2302
|
/**
|
|
1968
2303
|
* Determinate attainment bar - a continuous progress toward a target
|
|
1969
2304
|
* (quota reached, budget spent, goal met). Named `CngxGoal` because
|
|
@@ -1977,7 +2312,7 @@ declare class CngxStatus {
|
|
|
1977
2312
|
* derived percent bound as a CSS custom property.
|
|
1978
2313
|
*
|
|
1979
2314
|
* ```html
|
|
1980
|
-
* <cngx-goal [value]="73" [max]="100" />
|
|
2315
|
+
* <cngx-goal [value]="73" [max]="100" label="Quota attainment" />
|
|
1981
2316
|
* <cngx-goal [value]="q()" [max]="target()" [valueTextFormat]="quotaText" />
|
|
1982
2317
|
* ```
|
|
1983
2318
|
*
|
|
@@ -1991,14 +2326,23 @@ declare class CngxStatus {
|
|
|
1991
2326
|
* <example-url>http://localhost:4200/#/common/data/goal/quota-attainment</example-url>
|
|
1992
2327
|
*/
|
|
1993
2328
|
declare class CngxGoal {
|
|
2329
|
+
private readonly i18n;
|
|
1994
2330
|
/** Current attainment. Clamped to `[0, max]`. */
|
|
1995
2331
|
readonly value: _angular_core.InputSignal<number>;
|
|
1996
2332
|
/** Target the value works toward. Defaults to `100`. */
|
|
1997
2333
|
readonly max: _angular_core.InputSignal<number>;
|
|
2334
|
+
/**
|
|
2335
|
+
* Accessible name for the progressbar (what the attainment measures, e.g.
|
|
2336
|
+
* "Quarterly quota"). Mirrors the `label` input of the sibling KPI atoms;
|
|
2337
|
+
* omit it only when an external `aria-labelledby` (e.g. a `cngxStatLabel`)
|
|
2338
|
+
* names the bar instead.
|
|
2339
|
+
*/
|
|
2340
|
+
readonly label: _angular_core.InputSignal<string | undefined>;
|
|
1998
2341
|
/**
|
|
1999
2342
|
* Override the `aria-valuetext` string. Receives `(now, max)` - the clamped
|
|
2000
|
-
* value and the target.
|
|
2001
|
-
*
|
|
2343
|
+
* value and the target. Wins over the app-wide `CNGX_KPI_I18N.goalValueText`
|
|
2344
|
+
* (English default `(now, max) => \`${now} of ${max}\``). Supply a closure
|
|
2345
|
+
* for richer per-instance text (e.g.
|
|
2002
2346
|
* `(n, m) => \`${n} of ${m}, ${Math.round((n / m) * 100)}% of quota\``).
|
|
2003
2347
|
*/
|
|
2004
2348
|
readonly valueTextFormat: _angular_core.InputSignal<((now: number, max: number) => string) | undefined>;
|
|
@@ -2011,7 +2355,7 @@ declare class CngxGoal {
|
|
|
2011
2355
|
/** `aria-valuetext` - human-readable attainment via the resolved closure. */
|
|
2012
2356
|
protected readonly valueText: Signal<string>;
|
|
2013
2357
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxGoal, never>;
|
|
2014
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxGoal, "cngx-goal", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "valueTextFormat": { "alias": "valueTextFormat"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2358
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxGoal, "cngx-goal", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "valueTextFormat": { "alias": "valueTextFormat"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2015
2359
|
}
|
|
2016
2360
|
|
|
2017
2361
|
/**
|
|
@@ -2031,33 +2375,51 @@ interface RecyclerI18n {
|
|
|
2031
2375
|
error(): string;
|
|
2032
2376
|
}
|
|
2033
2377
|
/**
|
|
2034
|
-
* Injection token for recycler SR announcement texts
|
|
2035
|
-
*
|
|
2378
|
+
* Injection token for recycler SR announcement texts, a `Signal` so the
|
|
2379
|
+
* texts follow a runtime language switch. Defaults to the recycler section
|
|
2380
|
+
* of the active language pack over English, counts formatted for the app
|
|
2381
|
+
* locale. Override with `provideRecyclerI18n()`.
|
|
2036
2382
|
*
|
|
2037
2383
|
* @category common/data/recycler
|
|
2038
2384
|
* @wcag AA
|
|
2039
2385
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler.ts
|
|
2040
2386
|
* @since 0.1.0
|
|
2041
2387
|
*/
|
|
2042
|
-
declare const CNGX_RECYCLER_I18N: InjectionToken<RecyclerI18n
|
|
2388
|
+
declare const CNGX_RECYCLER_I18N: InjectionToken<Signal<RecyclerI18n>>;
|
|
2043
2389
|
/**
|
|
2044
|
-
*
|
|
2390
|
+
* Branded feature-fn for {@link provideRecyclerI18n}.
|
|
2391
|
+
*
|
|
2392
|
+
* @category common/data/recycler
|
|
2393
|
+
*/
|
|
2394
|
+
type CngxRecyclerI18nFeature = ((bundle: Signal<RecyclerI18n>) => Signal<RecyclerI18n>) & {
|
|
2395
|
+
readonly _target: 'i18n';
|
|
2396
|
+
};
|
|
2397
|
+
/**
|
|
2398
|
+
* Override recycler announcements via a partial bundle - keys you leave out
|
|
2399
|
+
* keep the language pack's text, or the English default. Pass a `Signal` to
|
|
2400
|
+
* switch the language at runtime.
|
|
2401
|
+
*
|
|
2402
|
+
* @category common/data/recycler
|
|
2403
|
+
*/
|
|
2404
|
+
declare function withRecyclerI18nLabels(overrides: Partial<RecyclerI18n> | Signal<Partial<RecyclerI18n>>): CngxRecyclerI18nFeature;
|
|
2405
|
+
/**
|
|
2406
|
+
* Provider for the recycler announcement texts. The features apply on top of
|
|
2407
|
+
* the active language pack.
|
|
2045
2408
|
*
|
|
2046
2409
|
* ```typescript
|
|
2047
|
-
* providers: [
|
|
2048
|
-
*
|
|
2049
|
-
*
|
|
2050
|
-
*
|
|
2051
|
-
*
|
|
2052
|
-
*
|
|
2410
|
+
* providers: [
|
|
2411
|
+
* provideRecyclerI18n(
|
|
2412
|
+
* withRecyclerI18nLabels({
|
|
2413
|
+
* empty: () => 'Keine Ergebnisse.',
|
|
2414
|
+
* error: () => 'Fehler beim Laden.',
|
|
2415
|
+
* }),
|
|
2416
|
+
* ),
|
|
2417
|
+
* ]
|
|
2053
2418
|
* ```
|
|
2054
2419
|
*
|
|
2055
2420
|
* @category common/data/recycler
|
|
2056
2421
|
*/
|
|
2057
|
-
declare function provideRecyclerI18n(
|
|
2058
|
-
provide: InjectionToken<RecyclerI18n>;
|
|
2059
|
-
useValue: RecyclerI18n;
|
|
2060
|
-
};
|
|
2422
|
+
declare function provideRecyclerI18n(...features: readonly CngxRecyclerI18nFeature[]): Provider;
|
|
2061
2423
|
/**
|
|
2062
2424
|
* Configuration for {@link injectRecycler}.
|
|
2063
2425
|
*
|
|
@@ -2126,6 +2488,15 @@ interface CngxRecycler {
|
|
|
2126
2488
|
readonly offsetAfter: Signal<number>;
|
|
2127
2489
|
/** Total scrollable height of all items (px). */
|
|
2128
2490
|
readonly totalSize: Signal<number>;
|
|
2491
|
+
/**
|
|
2492
|
+
* Representative row height (px) for a placeholder layer's repeat rhythm.
|
|
2493
|
+
* A numeric or `Signal<number>` `estimateSize` is already uniform, so it is
|
|
2494
|
+
* used verbatim; a per-index variable estimate has no single height, so the
|
|
2495
|
+
* average (`totalSize / totalCount`) stands in. Consumed by
|
|
2496
|
+
* {@link CngxRecyclerPlaceholder} to key its repeating skeleton interval off
|
|
2497
|
+
* the same rhythm the range uses. `0` on an empty list.
|
|
2498
|
+
*/
|
|
2499
|
+
readonly rowSizeHint: Signal<number>;
|
|
2129
2500
|
/** Placeholder count before rendered items. Only non-zero in grid mode. */
|
|
2130
2501
|
readonly placeholdersBefore: Signal<number>;
|
|
2131
2502
|
/** Placeholder count after rendered items. Only non-zero in grid mode. */
|
|
@@ -2280,6 +2651,7 @@ declare class CngxMeasure {
|
|
|
2280
2651
|
/** The absolute index of this item in the full dataset. */
|
|
2281
2652
|
readonly cngxMeasureIndex: _angular_core.InputSignal<number>;
|
|
2282
2653
|
private readonly el;
|
|
2654
|
+
private readonly win;
|
|
2283
2655
|
constructor();
|
|
2284
2656
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMeasure, never>;
|
|
2285
2657
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxMeasure, "[cngxMeasure]", never, { "cngxMeasure": { "alias": "cngxMeasure"; "required": true; "isSignal": true; }; "cngxMeasureIndex": { "alias": "cngxMeasureIndex"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
@@ -2331,6 +2703,228 @@ declare class CngxVirtualItem {
|
|
|
2331
2703
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxVirtualItem, "[cngxVirtualItem]", never, { "cngxVirtualItem": { "alias": "cngxVirtualItem"; "required": true; "isSignal": true; }; "cngxVirtualItemIndex": { "alias": "cngxVirtualItemIndex"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2332
2704
|
}
|
|
2333
2705
|
|
|
2706
|
+
/**
|
|
2707
|
+
* Paints a row-aligned skeleton background under a virtualized scroll region so
|
|
2708
|
+
* a fast fling or teleport jump reveals placeholder bars instead of the bare
|
|
2709
|
+
* panel/page surface for the single frame the rendered rows lag `scrollTop`.
|
|
2710
|
+
*
|
|
2711
|
+
* The mechanism is a static CSS layer, not a reactive template: by the time a
|
|
2712
|
+
* `@for` over "uncovered indices" could render, change detection has already
|
|
2713
|
+
* produced the real rows, so the lag frame is never painted reactively. A
|
|
2714
|
+
* `background` on the offset element always paints and also covers teleport
|
|
2715
|
+
* jumps no reactive window can, at zero per-frame cost.
|
|
2716
|
+
*
|
|
2717
|
+
* Host it on the **offset spacer element(s)** - the empty divs (or presentation
|
|
2718
|
+
* `<li>`s) whose height reserves `offsetBefore` / `offsetAfter` - one directive
|
|
2719
|
+
* instance per spacer. Do NOT host it on a `padding-block`ed content element
|
|
2720
|
+
* that also contains the rows: a background paints across the whole padding box,
|
|
2721
|
+
* so it would show through *behind* every rendered row, not just in the gap.
|
|
2722
|
+
* The spacers carry no rows, so the layer is only ever visible where the window
|
|
2723
|
+
* has not caught up.
|
|
2724
|
+
*
|
|
2725
|
+
* The repeat interval keys off a single representative row height: bind the
|
|
2726
|
+
* recycler to read its `rowSizeHint`, or pass an explicit `[rowHeight]`
|
|
2727
|
+
* fallback so the directive is usable standalone. Visuals are driven by
|
|
2728
|
+
* `--cngx-recycler-placeholder-*` CSS custom properties (see
|
|
2729
|
+
* `@cngx/common/theming/components/cngx-recycler-placeholder.css`); the shimmer
|
|
2730
|
+
* drops under `prefers-reduced-motion` via a spec-observable host class.
|
|
2731
|
+
*
|
|
2732
|
+
* ### One instance per offset spacer, keyed off the recycler's rhythm
|
|
2733
|
+
* ```html
|
|
2734
|
+
* <ul>
|
|
2735
|
+
* @if (recycler.offsetBefore(); as before) {
|
|
2736
|
+
* <li role="presentation" aria-hidden="true"
|
|
2737
|
+
* [cngxRecyclerPlaceholder]="recycler" [style.height.px]="before"></li>
|
|
2738
|
+
* }
|
|
2739
|
+
* @for (item of visibleItems(); track item.id) { <li>...</li> }
|
|
2740
|
+
* @if (recycler.offsetAfter(); as after) {
|
|
2741
|
+
* <li role="presentation" aria-hidden="true"
|
|
2742
|
+
* [cngxRecyclerPlaceholder]="recycler" [style.height.px]="after"></li>
|
|
2743
|
+
* }
|
|
2744
|
+
* </ul>
|
|
2745
|
+
* ```
|
|
2746
|
+
*
|
|
2747
|
+
* ### Standalone with an explicit row height
|
|
2748
|
+
* ```html
|
|
2749
|
+
* <div cngxRecyclerPlaceholder [rowHeight]="48"
|
|
2750
|
+
* [style.height.px]="recycler.offsetBefore()"></div>
|
|
2751
|
+
* ```
|
|
2752
|
+
*
|
|
2753
|
+
* @category common/data/recycler
|
|
2754
|
+
* @docsKind primary
|
|
2755
|
+
* @wcag AA
|
|
2756
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-placeholder.directive.ts
|
|
2757
|
+
* @since 0.1.0
|
|
2758
|
+
* @relatedTo injectRecycler, CngxRecyclerRow, CngxVirtualItem, CngxMeasure
|
|
2759
|
+
* <example-url>http://localhost:4200/#/common/data/recycler/fast-fling-placeholders</example-url>
|
|
2760
|
+
*/
|
|
2761
|
+
declare class CngxRecyclerPlaceholder {
|
|
2762
|
+
/**
|
|
2763
|
+
* The recycler whose `rowSizeHint` sets the placeholder repeat rhythm.
|
|
2764
|
+
* Optional: the directive also works from an explicit `[rowHeight]`, so this
|
|
2765
|
+
* follows the bridge-input shape (optional + empty-string transform) rather
|
|
2766
|
+
* than `input.required` - a bare `cngxRecyclerPlaceholder` attribute paired
|
|
2767
|
+
* with `[rowHeight]` is a valid, unbound usage.
|
|
2768
|
+
*/
|
|
2769
|
+
readonly recycler: _angular_core.InputSignalWithTransform<CngxRecycler | undefined, "" | CngxRecycler | undefined>;
|
|
2770
|
+
/** Explicit row height (px) used when no recycler is bound, or as a fallback. */
|
|
2771
|
+
readonly rowHeight: _angular_core.InputSignal<number | undefined>;
|
|
2772
|
+
private readonly prefersReducedMotion;
|
|
2773
|
+
constructor();
|
|
2774
|
+
/**
|
|
2775
|
+
* Representative row height (px) for the repeat interval. The recycler's
|
|
2776
|
+
* `rowSizeHint` wins when it resolves to a positive value; otherwise the
|
|
2777
|
+
* explicit `[rowHeight]` fallback applies.
|
|
2778
|
+
*/
|
|
2779
|
+
protected readonly resolvedRowHeight: Signal<number>;
|
|
2780
|
+
/**
|
|
2781
|
+
* The `--cngx-recycler-placeholder-row-height` style value. `null` when no
|
|
2782
|
+
* row height resolves, so the registered `@property` default (or an inherited
|
|
2783
|
+
* token from an ancestor mapping) applies instead of a broken `0px` interval.
|
|
2784
|
+
*/
|
|
2785
|
+
protected readonly rowHeightVar: Signal<string | null>;
|
|
2786
|
+
/** Whether the shimmer host class is applied (dropped under reduced-motion). */
|
|
2787
|
+
protected readonly showShimmer: Signal<boolean>;
|
|
2788
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxRecyclerPlaceholder, never>;
|
|
2789
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxRecyclerPlaceholder, "[cngxRecyclerPlaceholder]", never, { "recycler": { "alias": "cngxRecyclerPlaceholder"; "required": false; "isSignal": true; }; "rowHeight": { "alias": "rowHeight"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2790
|
+
}
|
|
2791
|
+
|
|
2792
|
+
/**
|
|
2793
|
+
* Context for the placeholder branch of `*cngxRecyclerRow` - the window slot
|
|
2794
|
+
* whose item has not loaded yet (`undefined`). A custom `placeholder:` template
|
|
2795
|
+
* reads this to keep the list count honest for assistive technology:
|
|
2796
|
+
* `aria-posinset = index + 1`, `aria-setsize = setSize`.
|
|
2797
|
+
*
|
|
2798
|
+
* The real-row branch (item defined) binds `$implicit` to the item value
|
|
2799
|
+
* instead; that context is internal and narrowed by `ngTemplateContextGuard`.
|
|
2800
|
+
*
|
|
2801
|
+
* @category common/data/recycler
|
|
2802
|
+
*/
|
|
2803
|
+
interface CngxRecyclerRowContext {
|
|
2804
|
+
/** The absolute dataset index of this slot. Alias of `index`. */
|
|
2805
|
+
$implicit: number;
|
|
2806
|
+
/** The absolute dataset index of this slot. */
|
|
2807
|
+
index: number;
|
|
2808
|
+
/** Pixel offset of the slot from the top of the scroll content. */
|
|
2809
|
+
top: number;
|
|
2810
|
+
/** Total set size (`recycler.ariaSetSize()`) for `aria-setsize`. */
|
|
2811
|
+
setSize: number;
|
|
2812
|
+
}
|
|
2813
|
+
/** Internal real-row context: the loaded item at this window position. */
|
|
2814
|
+
interface CngxRecyclerRowRealContext<T> {
|
|
2815
|
+
$implicit: T;
|
|
2816
|
+
cngxRecyclerRow: T;
|
|
2817
|
+
}
|
|
2818
|
+
/**
|
|
2819
|
+
* App-wide default placeholder template for `*cngxRecyclerRow`. Middle rung of
|
|
2820
|
+
* the cascade: microsyntax `placeholder:` template wins over this, and this wins
|
|
2821
|
+
* over the built-in imperative `<li>` default. Defaults to `null` (imperative
|
|
2822
|
+
* default applies).
|
|
2823
|
+
*
|
|
2824
|
+
* @category common/data/recycler
|
|
2825
|
+
*/
|
|
2826
|
+
declare const CNGX_RECYCLER_PLACEHOLDER_ROW: InjectionToken<TemplateRef<CngxRecyclerRowContext> | null>;
|
|
2827
|
+
/**
|
|
2828
|
+
* Provides an app-wide default placeholder template for every `*cngxRecyclerRow`
|
|
2829
|
+
* that supplies no `placeholder:` template of its own.
|
|
2830
|
+
*
|
|
2831
|
+
* @category common/data/recycler
|
|
2832
|
+
*/
|
|
2833
|
+
declare function provideRecyclerPlaceholderRow(template: TemplateRef<CngxRecyclerRowContext>): Provider;
|
|
2834
|
+
/**
|
|
2835
|
+
* Per-window-position render switch for a sparse/windowed recycler: renders the
|
|
2836
|
+
* consumer's real-row template when the sliced item is defined, and a
|
|
2837
|
+
* placeholder branch when the item is still `undefined` (loaded window, data
|
|
2838
|
+
* not yet resolved).
|
|
2839
|
+
*
|
|
2840
|
+
* Mirrors the `*cngxAsync` structural-directive shape (own `TemplateRef` +
|
|
2841
|
+
* microsyntax alternate template + `ngTemplateContextGuard`). The switch axis is
|
|
2842
|
+
* data availability, not async status, so the two are siblings, not the same
|
|
2843
|
+
* class. Unlike `*cngxAsync` (which clears on every switch) the real-row view is
|
|
2844
|
+
* cached and re-attached across a placeholder detour, so a
|
|
2845
|
+
* defined -> undefined -> defined flip never remounts the expensive real row.
|
|
2846
|
+
*
|
|
2847
|
+
* The placeholder branch resolves through a 3-stage cascade: the microsyntax
|
|
2848
|
+
* `placeholder:` template, then {@link CNGX_RECYCLER_PLACEHOLDER_ROW}, then a
|
|
2849
|
+
* built-in imperative `<li>` default. The default assumes a `<ul>`/`<li>` list;
|
|
2850
|
+
* a non-`<li>` container (`<div role="list">`) supplies a `placeholder:`
|
|
2851
|
+
* template or the config token instead.
|
|
2852
|
+
*
|
|
2853
|
+
* The two placeholder layers are orthogonal and non-overlapping by
|
|
2854
|
+
* construction: {@link CngxRecyclerPlaceholder} paints a decorative background
|
|
2855
|
+
* on the offset spacers (indices outside the rendered window), while this
|
|
2856
|
+
* directive fills holes inside the window whose item is still `undefined`.
|
|
2857
|
+
*
|
|
2858
|
+
* ### Windowed list with the built-in placeholder row
|
|
2859
|
+
* ```html
|
|
2860
|
+
* <ul>
|
|
2861
|
+
* @for (item of visibleItems(); track item?.id ?? ('ph:' + (recycler.start() + $index)); let i = $index) {
|
|
2862
|
+
* <li *cngxRecyclerRow="item; index: recycler.start() + i; recycler: recycler; let row">
|
|
2863
|
+
* {{ row?.name }}
|
|
2864
|
+
* </li>
|
|
2865
|
+
* }
|
|
2866
|
+
* </ul>
|
|
2867
|
+
* ```
|
|
2868
|
+
*
|
|
2869
|
+
* ### Custom placeholder template
|
|
2870
|
+
* ```html
|
|
2871
|
+
* <ul>
|
|
2872
|
+
* @for (item of visibleItems(); track item?.id ?? ('ph:' + (recycler.start() + $index)); let i = $index) {
|
|
2873
|
+
* <li *cngxRecyclerRow="item; index: recycler.start() + i; recycler: recycler; placeholder: ph; let row">
|
|
2874
|
+
* {{ row?.name }}
|
|
2875
|
+
* </li>
|
|
2876
|
+
* }
|
|
2877
|
+
* <ng-template #ph let-index let-setSize="setSize">
|
|
2878
|
+
* <li role="listitem" aria-busy="true" [attr.aria-posinset]="index + 1" [attr.aria-setsize]="setSize">
|
|
2879
|
+
* Loading row {{ index + 1 }}
|
|
2880
|
+
* </li>
|
|
2881
|
+
* </ng-template>
|
|
2882
|
+
* </ul>
|
|
2883
|
+
* ```
|
|
2884
|
+
*
|
|
2885
|
+
* @category common/data/recycler
|
|
2886
|
+
* @docsKind primary
|
|
2887
|
+
* @wcag AA
|
|
2888
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-row.directive.ts
|
|
2889
|
+
* @since 0.1.0
|
|
2890
|
+
* @relatedTo injectRecycler, CngxRecyclerPlaceholder, CngxVirtualItem, CngxMeasure
|
|
2891
|
+
* <example-url>http://localhost:4200/#/common/data/recycler/windowed-data-availability</example-url>
|
|
2892
|
+
*/
|
|
2893
|
+
declare class CngxRecyclerRow<T> {
|
|
2894
|
+
private readonly vcr;
|
|
2895
|
+
private readonly rowTpl;
|
|
2896
|
+
private readonly renderer;
|
|
2897
|
+
private readonly configTpl;
|
|
2898
|
+
/** The sliced item at this window position. `undefined` selects the placeholder branch. */
|
|
2899
|
+
readonly cngxRecyclerRow: _angular_core.InputSignal<T | undefined>;
|
|
2900
|
+
/** Absolute dataset index of this slot (`recycler.start() + $index`). */
|
|
2901
|
+
readonly cngxRecyclerRowIndex: _angular_core.InputSignal<number>;
|
|
2902
|
+
/** The recycler driving the window, read for `rowSizeHint` (-> `top`) and `ariaSetSize`. */
|
|
2903
|
+
readonly cngxRecyclerRowRecycler: _angular_core.InputSignal<CngxRecycler>;
|
|
2904
|
+
/** Optional placeholder template for the `undefined` branch. Context: {@link CngxRecyclerRowContext}. */
|
|
2905
|
+
readonly cngxRecyclerRowPlaceholder: _angular_core.InputSignal<TemplateRef<CngxRecyclerRowContext> | undefined>;
|
|
2906
|
+
private currentBranch;
|
|
2907
|
+
private rowViewRef;
|
|
2908
|
+
private placeholderViewRef;
|
|
2909
|
+
private defaultEl;
|
|
2910
|
+
constructor();
|
|
2911
|
+
private showRow;
|
|
2912
|
+
private showPlaceholder;
|
|
2913
|
+
private setRowContext;
|
|
2914
|
+
private detachRow;
|
|
2915
|
+
private teardownPlaceholder;
|
|
2916
|
+
private renderPlaceholder;
|
|
2917
|
+
private refreshPlaceholder;
|
|
2918
|
+
private stampDefault;
|
|
2919
|
+
private applyDefaultAttrs;
|
|
2920
|
+
private removeDefault;
|
|
2921
|
+
private buildPlaceholderContext;
|
|
2922
|
+
/** Narrows the directive's own template context to the loaded item type. */
|
|
2923
|
+
static ngTemplateContextGuard<T>(_dir: CngxRecyclerRow<T>, _ctx: unknown): _ctx is CngxRecyclerRowRealContext<T>;
|
|
2924
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxRecyclerRow<any>, never>;
|
|
2925
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxRecyclerRow<any>, "[cngxRecyclerRow]", never, { "cngxRecyclerRow": { "alias": "cngxRecyclerRow"; "required": false; "isSignal": true; }; "cngxRecyclerRowIndex": { "alias": "cngxRecyclerRowIndex"; "required": true; "isSignal": true; }; "cngxRecyclerRowRecycler": { "alias": "cngxRecyclerRowRecycler"; "required": true; "isSignal": true; }; "cngxRecyclerRowPlaceholder": { "alias": "cngxRecyclerRowPlaceholder"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2926
|
+
}
|
|
2927
|
+
|
|
2334
2928
|
/**
|
|
2335
2929
|
* Convenience component that renders the `aria-live="polite"` region
|
|
2336
2930
|
* for recycler SR announcements. Eliminates manual boilerplate.
|
|
@@ -2372,7 +2966,7 @@ declare class CngxRecyclerAnnouncer {
|
|
|
2372
2966
|
* Must be called in an injection context (constructor or field initializer)
|
|
2373
2967
|
* **on the component that hosts both the recycler's scroll container and the
|
|
2374
2968
|
* `CngxRovingTabindex` directive**. The injected `ElementRef` is used to query
|
|
2375
|
-
* `[data-cngx-recycle-index]`
|
|
2969
|
+
* `[data-cngx-recycle-index]` - calling from a child component would query the
|
|
2376
2970
|
* wrong subtree.
|
|
2377
2971
|
*
|
|
2378
2972
|
* ```typescript
|
|
@@ -2410,7 +3004,7 @@ declare function connectRecyclerToRoving(recycler: CngxRecycler, roving: CngxRov
|
|
|
2410
3004
|
*
|
|
2411
3005
|
* Unlike {@link /projects/common/data/src/recycler/connect-recycler-roving.ts
|
|
2412
3006
|
* connectRecyclerToRoving}, we don't re-focus a DOM element after the
|
|
2413
|
-
* scroll
|
|
3007
|
+
* scroll - AD doesn't move real focus, it only rebinds
|
|
2414
3008
|
* `aria-activedescendant`. Once the target index enters the rendered
|
|
2415
3009
|
* range, the `[attr.aria-activedescendant]` binding on the combobox
|
|
2416
3010
|
* trigger resolves to the now-present option element for free.
|
|
@@ -2422,7 +3016,7 @@ declare function connectRecyclerToRoving(recycler: CngxRecycler, roving: CngxRov
|
|
|
2422
3016
|
* ```typescript
|
|
2423
3017
|
* @Component({
|
|
2424
3018
|
* hostDirectives: [
|
|
2425
|
-
* { directive: CngxActiveDescendant, inputs: ['items', 'virtualCount'] },
|
|
3019
|
+
* { directive: CngxActiveDescendant, inputs: ['items', 'virtualCount', 'windowStart'] },
|
|
2426
3020
|
* ],
|
|
2427
3021
|
* })
|
|
2428
3022
|
* class MyVirtualSelect {
|
|
@@ -2454,7 +3048,7 @@ interface CngxCommitHandle {
|
|
|
2454
3048
|
/**
|
|
2455
3049
|
* Action runner contract. Receives the controller's success/error
|
|
2456
3050
|
* routes and returns a cancel handle. The runner is opaque to the
|
|
2457
|
-
* controller
|
|
3051
|
+
* controller - it can wrap any async source (Observable, Promise,
|
|
2458
3052
|
* sync value) and any cancellation primitive.
|
|
2459
3053
|
*
|
|
2460
3054
|
* Variants supply their own runner adapter (e.g. select's
|
|
@@ -2503,7 +3097,7 @@ interface CngxCommitController<T> {
|
|
|
2503
3097
|
/** `true` while a commit is in flight. */
|
|
2504
3098
|
readonly isCommitting: Signal<boolean>;
|
|
2505
3099
|
/**
|
|
2506
|
-
* The most recent intended value
|
|
3100
|
+
* The most recent intended value - what the user was trying to
|
|
2507
3101
|
* commit. Used by the option-row spinner and the commit-error
|
|
2508
3102
|
* template context to identify *which* option the failure belongs
|
|
2509
3103
|
* to.
|
|
@@ -2518,7 +3112,7 @@ interface CngxCommitController<T> {
|
|
|
2518
3112
|
* action and the intended value)
|
|
2519
3113
|
* @param intended the value the user clicked
|
|
2520
3114
|
* @param previous the value to roll back to on error
|
|
2521
|
-
* @param handlers success/error routes
|
|
3115
|
+
* @param handlers success/error routes - the controller only
|
|
2522
3116
|
* updates its own state and calls these; it does
|
|
2523
3117
|
* NOT touch external value signals, panel open
|
|
2524
3118
|
* state, or component outputs.
|
|
@@ -2528,13 +3122,21 @@ interface CngxCommitController<T> {
|
|
|
2528
3122
|
* Abort the currently in-flight commit without firing callbacks.
|
|
2529
3123
|
* Use when the host component is destroyed or the commit-action
|
|
2530
3124
|
* input changes mid-flight.
|
|
2531
|
-
|
|
2532
|
-
|
|
3125
|
+
*
|
|
3126
|
+
* By default the state slot keeps its current status (a destroyed
|
|
3127
|
+
* host never reads it again). Pass `settle: true` when the surface
|
|
3128
|
+
* lives on - an explicit back-navigation or reset that supersedes a
|
|
3129
|
+
* pending commit must return `state` to `'idle'`, or `busy` latches
|
|
3130
|
+
* true forever.
|
|
3131
|
+
*/
|
|
3132
|
+
cancel(options?: {
|
|
3133
|
+
readonly settle?: boolean;
|
|
3134
|
+
}): void;
|
|
2533
3135
|
}
|
|
2534
3136
|
/**
|
|
2535
3137
|
* Factory for the commit controller.
|
|
2536
3138
|
*
|
|
2537
|
-
* Plain function, not a class
|
|
3139
|
+
* Plain function, not a class - matches the rest of the repo
|
|
2538
3140
|
* (`createManualState`, `createAsyncState`, `createTransitionTracker`).
|
|
2539
3141
|
* See `reference_api_prefix_convention.md`.
|
|
2540
3142
|
*
|
|
@@ -2594,7 +3196,7 @@ declare const CNGX_COMMIT_CONTROLLER_FACTORY: InjectionToken<CngxCommitControlle
|
|
|
2594
3196
|
interface CngxMaterialBidirectionalSyncOptions {
|
|
2595
3197
|
/**
|
|
2596
3198
|
* Reactive source for the presenter's current index. The factory's
|
|
2597
|
-
* `effect()` tracks this signal
|
|
3199
|
+
* `effect()` tracks this signal - when it changes, Material is
|
|
2598
3200
|
* written (subject to the equality guard against the Material
|
|
2599
3201
|
* read-side).
|
|
2600
3202
|
*/
|
|
@@ -2652,7 +3254,7 @@ interface CngxMaterialBidirectionalSyncHandle {
|
|
|
2652
3254
|
* (`<mat-tab-group>`, `<mat-stepper>`, etc.).
|
|
2653
3255
|
*
|
|
2654
3256
|
* Lives at Level 2 in `@cngx/common/data` parallel to
|
|
2655
|
-
* `createCommitController`. Material types never enter the signature
|
|
3257
|
+
* `createCommitController`. Material types never enter the signature -
|
|
2656
3258
|
* the caller maps Material-specific events and property accessors to a
|
|
2657
3259
|
* host-agnostic shape at the directive boundary.
|
|
2658
3260
|
*
|
|
@@ -2666,7 +3268,7 @@ interface CngxMaterialBidirectionalSyncHandle {
|
|
|
2666
3268
|
* 2. A Material→presenter subscription that forwards each
|
|
2667
3269
|
* `selectionChange$` emission to `onMaterialSelection`
|
|
2668
3270
|
* (equality-guarded against `presenterIndex()` so a Material event
|
|
2669
|
-
* whose value already matches the presenter is dropped
|
|
3271
|
+
* whose value already matches the presenter is dropped - closes
|
|
2670
3272
|
* the re-entrancy loop).
|
|
2671
3273
|
*
|
|
2672
3274
|
* Both sides clean up via `destroyRef`.
|
|
@@ -2694,7 +3296,7 @@ interface CngxMaterialBidirectionalSyncHandle {
|
|
|
2694
3296
|
* load-bearing for an ASYNC commit-action: Material emits the echo a
|
|
2695
3297
|
* microtask later, by which point the commit may have advanced
|
|
2696
3298
|
* `presenterIndex`, so an equality-only guard (`presenterIndex() ===
|
|
2697
|
-
* idx`) would FAIL to drop the echo
|
|
3299
|
+
* idx`) would FAIL to drop the echo - it would re-enter the subscriber
|
|
2698
3300
|
* and ping-pong against the in-flight navigation (the demo freezes).
|
|
2699
3301
|
* Matching the echo by the value we wrote drops it regardless of where
|
|
2700
3302
|
* the presenter has moved.
|
|
@@ -2703,5 +3305,82 @@ interface CngxMaterialBidirectionalSyncHandle {
|
|
|
2703
3305
|
*/
|
|
2704
3306
|
declare function createMaterialBidirectionalSync(opts: CngxMaterialBidirectionalSyncOptions): CngxMaterialBidirectionalSyncHandle;
|
|
2705
3307
|
|
|
2706
|
-
|
|
2707
|
-
|
|
3308
|
+
/**
|
|
3309
|
+
* The kpi section of a {@link CngxLanguagePack}: the copy of the KPI atoms
|
|
3310
|
+
* `CngxMetric`, `CngxDelta`, `CngxTrend` and `CngxGoal`. Magnitudes reach the
|
|
3311
|
+
* messages already formatted for the app locale.
|
|
3312
|
+
*
|
|
3313
|
+
* @category common/data/i18n
|
|
3314
|
+
* @since 0.1.0
|
|
3315
|
+
* @relatedTo CNGX_KPI_I18N
|
|
3316
|
+
*/
|
|
3317
|
+
interface CngxKpiLanguageSection {
|
|
3318
|
+
/** `{value}`, `{sentiment}`: the accessible name of a delta. */
|
|
3319
|
+
readonly deltaLabel: CngxMessage;
|
|
3320
|
+
readonly deltaImproved: string;
|
|
3321
|
+
readonly deltaDeclined: string;
|
|
3322
|
+
readonly deltaUnchanged: string;
|
|
3323
|
+
/** `{value}`, `{direction}`: the accessible name of a trend. */
|
|
3324
|
+
readonly trendLabel: CngxMessage;
|
|
3325
|
+
readonly trendUp: string;
|
|
3326
|
+
readonly trendDown: string;
|
|
3327
|
+
readonly trendFlat: string;
|
|
3328
|
+
/** `{now}`, `{max}`: a goal's `aria-valuetext`. */
|
|
3329
|
+
readonly goalValueText: CngxMessage;
|
|
3330
|
+
/** `{value}`, `{unit}`: a metric's value and unit, in reading order. */
|
|
3331
|
+
readonly metricValueWithUnit: string;
|
|
3332
|
+
/** Shown in place of a metric without a value. */
|
|
3333
|
+
readonly metricPlaceholder: string;
|
|
3334
|
+
/** Accessible name of a metric without a value. */
|
|
3335
|
+
readonly metricNoValue: string;
|
|
3336
|
+
}
|
|
3337
|
+
/**
|
|
3338
|
+
* The English kpi section: the single source of the KPI atoms' English copy.
|
|
3339
|
+
* `CNGX_KPI_I18N` defaults to it.
|
|
3340
|
+
*
|
|
3341
|
+
* @category common/data/i18n
|
|
3342
|
+
* @since 0.1.0
|
|
3343
|
+
* @relatedTo CNGX_KPI_I18N
|
|
3344
|
+
*/
|
|
3345
|
+
declare const CNGX_KPI_LANGUAGE_EN: CngxKpiLanguageSection;
|
|
3346
|
+
declare module '@cngx/core/i18n' {
|
|
3347
|
+
interface CngxLanguagePack {
|
|
3348
|
+
readonly kpi: CngxKpiLanguageSection;
|
|
3349
|
+
}
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
/**
|
|
3353
|
+
* The recycler section of a {@link CngxLanguagePack}: the screen-reader
|
|
3354
|
+
* announcements of a virtualised list.
|
|
3355
|
+
*
|
|
3356
|
+
* @category common/data/i18n
|
|
3357
|
+
* @since 0.1.0
|
|
3358
|
+
* @relatedTo CNGX_RECYCLER_I18N
|
|
3359
|
+
*/
|
|
3360
|
+
interface CngxRecyclerLanguageSection {
|
|
3361
|
+
/** Plural on `{count}` (new items), with `{total}`: announced after a load. */
|
|
3362
|
+
readonly loaded: CngxMessage;
|
|
3363
|
+
/** Plural on `{count}`: announced when filter or search results change. */
|
|
3364
|
+
readonly filtered: CngxMessage;
|
|
3365
|
+
/** Announced when the list becomes empty. */
|
|
3366
|
+
readonly empty: string;
|
|
3367
|
+
/** Announced when loading fails. */
|
|
3368
|
+
readonly error: string;
|
|
3369
|
+
}
|
|
3370
|
+
/**
|
|
3371
|
+
* The English recycler section: the single source of the recycler's English
|
|
3372
|
+
* copy. `CNGX_RECYCLER_I18N` defaults to it.
|
|
3373
|
+
*
|
|
3374
|
+
* @category common/data/i18n
|
|
3375
|
+
* @since 0.1.0
|
|
3376
|
+
* @relatedTo CNGX_RECYCLER_I18N
|
|
3377
|
+
*/
|
|
3378
|
+
declare const CNGX_RECYCLER_LANGUAGE_EN: CngxRecyclerLanguageSection;
|
|
3379
|
+
declare module '@cngx/core/i18n' {
|
|
3380
|
+
interface CngxLanguagePack {
|
|
3381
|
+
readonly recycler: CngxRecyclerLanguageSection;
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
|
|
3385
|
+
export { CNGX_ASYNC_LABEL, CNGX_ASYNC_SKIP, CNGX_BUCKET_PAGINATE_HOST, CNGX_COMMIT_CONTROLLER_FACTORY, CNGX_KPI_I18N, CNGX_KPI_LANGUAGE_EN, CNGX_RECYCLER_I18N, CNGX_RECYCLER_LANGUAGE_EN, CNGX_RECYCLER_PLACEHOLDER_ROW, CNGX_STAT, CngxAsync, CngxAsyncBoundary, CngxAsyncRegistry, CngxBucketPaginate, CngxDataSource, CngxDelta, CngxFilter, CngxFilterChip, CngxFilterChips, CngxGoal, CngxMeasure, CngxMetric, CngxPaginate, CngxPaginateResetOn, CngxPaginateRouting, CngxRecyclerAnnouncer, CngxRecyclerPlaceholder, CngxRecyclerRow, CngxSmartDataSource, CngxSort, CngxSortHeader, CngxStat, CngxStatCaption, CngxStatCoordinator, CngxStatDelta, CngxStatLabel, CngxStatValue, CngxTrend, CngxVirtualItem, cngxAsyncInterceptor, connectPaginateEmit, connectPaginateResetOn, connectRecyclerToActiveDescendant, connectRecyclerToRoving, createAsyncState, createCommitController, createForwardedAsyncState, createManualState, createMaterialBidirectionalSync, createSortHeaderState, fromHttpResource, fromResource, injectAsyncRegistry, injectAsyncState, injectDataSource, injectKpiI18n, injectLatencyProbe, injectRecycler, injectSmartDataSource, provideAsyncHttpObservability, provideAsyncRegistry, provideKpiI18n, provideRecyclerI18n, provideRecyclerPlaceholderRow, resolveAsyncView, tapAsyncProgress, tapAsyncState, tapHttpAsyncState, withAsyncLabel, withAsyncSkip, withKpiI18nLabels, withRecyclerI18nLabels };
|
|
3386
|
+
export type { AggregateFailure, AggregateSource, AsyncView, CngxAsyncContext, CngxAsyncOperation, CngxBucket, CngxBucketPaginateHost, CngxBucketPaginateView, CngxCommitBeginHandlers, CngxCommitController, CngxCommitControllerFactory, CngxCommitHandle, CngxCommitRunner, CngxFilterChipContext, CngxKpiI18n, CngxKpiI18nFeature, CngxKpiLanguageSection, CngxMaterialBidirectionalSyncHandle, CngxMaterialBidirectionalSyncOptions, CngxPaginateEmitHandlers, CngxRecycler, CngxRecyclerI18nFeature, CngxRecyclerLanguageSection, CngxRecyclerRowContext, CngxSmartDataSourceOptions, CngxStatRegistry, CngxStatSlotKind, CreateAsyncStateOptions, DeltaDirection, DeltaMode, DeltaPolarity, DeltaSentiment, InjectAsyncStateOptions, ManualAsyncState, MutableAsyncState, ReactiveAsyncState, RecyclerConfig, RecyclerI18n, SortEntry, SortHeaderState };
|