@cngx/common 0.1.0-rc.7 → 0.1.0-rc.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/card/README.md +2 -1
- package/command/README.md +29 -0
- package/data/README.md +15 -3
- package/dialog/README.md +23 -1
- package/fesm2022/cngx-common-a11y.mjs +517 -184
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +62 -17
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-card.mjs +301 -46
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +1221 -479
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +97 -16
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +1496 -499
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +236 -61
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +364 -93
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +2040 -1046
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +955 -125
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-popover.mjs +1293 -89
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +997 -453
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +1794 -1265
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +151 -61
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +1 -1
- package/interactive/README.md +15 -4
- package/layout/README.md +37 -1
- package/package.json +20 -7
- package/popover/README.md +58 -2
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +91 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +11 -8
- package/theming/components/cngx-accordion.css +1 -1
- package/theming/components/cngx-backdrop.css +12 -0
- package/theming/components/cngx-button-toggle.css +29 -3
- package/theming/components/cngx-data-grid.css +168 -1
- package/theming/components/cngx-dialog.css +13 -0
- package/theming/components/cngx-listbox.css +21 -12
- package/theming/components/cngx-menu.css +56 -16
- package/theming/components/cngx-popover-sheet.css +402 -0
- package/theming/components/cngx-popover.css +28 -0
- package/theming/components/cngx-recycler-placeholder.css +196 -0
- package/theming/components/cngx-ripple.css +1 -1
- package/theming/components/cngx-slider.css +32 -1
- package/theming/components/cngx-tooltip.css +12 -0
- package/timeline/README.md +155 -0
- package/types/cngx-common-a11y.d.ts +205 -28
- package/types/cngx-common-card.d.ts +201 -17
- package/types/cngx-common-chart.d.ts +345 -48
- package/types/cngx-common-command.d.ts +50 -10
- package/types/cngx-common-data.d.ts +743 -92
- package/types/cngx-common-dialog.d.ts +161 -10
- package/types/cngx-common-display.d.ts +356 -142
- package/types/cngx-common-interactive.d.ts +910 -226
- package/types/cngx-common-layout.d.ts +603 -32
- package/types/cngx-common-popover.d.ts +612 -49
- package/types/cngx-common-stepper.d.ts +526 -237
- package/types/cngx-common-tabs.d.ts +358 -75
- package/types/cngx-common-timeline.d.ts +108 -22
|
@@ -1,12 +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';
|
|
2
|
+
import { Signal, TemplateRef, OnInit, InjectionToken, Resource, EnvironmentProviders, Provider, ElementRef, Injector, DestroyRef } from '@angular/core';
|
|
3
3
|
import { CngxAsyncState, AsyncStatus, CngxStateful, CngxLatencyProbe } from '@cngx/core/utils';
|
|
4
4
|
export { CngxLatencyProbe } from '@cngx/core/utils';
|
|
5
5
|
import { DataSource } from '@angular/cdk/collections';
|
|
6
6
|
import { Observable, MonoTypeOperatorFunction, OperatorFunction } from 'rxjs';
|
|
7
7
|
import { CngxSearch } from '@cngx/common/interactive';
|
|
8
8
|
import { HttpContextToken, HttpContext, HttpInterceptorFn } from '@angular/common/http';
|
|
9
|
+
import * as _cngx_common_data from '@cngx/common/data';
|
|
9
10
|
import { CngxRovingTabindex, CngxActiveDescendant } from '@cngx/common/a11y';
|
|
11
|
+
import { CngxMessage } from '@cngx/core/i18n';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* A single sort entry: the active field key and its direction.
|
|
@@ -34,6 +36,8 @@ interface SortEntry {
|
|
|
34
36
|
* adds it as a secondary (tertiary, …) sort key instead of replacing the
|
|
35
37
|
* primary one. Shift-clicking an active column cycles it asc → desc → removed.
|
|
36
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.
|
|
37
41
|
*
|
|
38
42
|
* Consumer connects this to a table or list via a `computed()` - nothing is
|
|
39
43
|
* injected automatically.
|
|
@@ -82,6 +86,9 @@ declare class CngxSort {
|
|
|
82
86
|
/**
|
|
83
87
|
* All active sort entries in priority order.
|
|
84
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.
|
|
85
92
|
*/
|
|
86
93
|
readonly sorts: _angular_core.Signal<SortEntry[]>;
|
|
87
94
|
/** `true` when at least one sort is active. */
|
|
@@ -104,6 +111,12 @@ declare class CngxSort {
|
|
|
104
111
|
* - Field not in stack → append as asc
|
|
105
112
|
* - Field in stack as asc → change to desc
|
|
106
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.
|
|
107
120
|
*/
|
|
108
121
|
setSort(field: string, additive?: boolean): void;
|
|
109
122
|
/** Clears all active sorts. Emits both `sortChange(undefined)` and `sortsChange([])`. */
|
|
@@ -364,17 +377,19 @@ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
|
|
|
364
377
|
* is intentionally out of scope. Consumers needing a single-select
|
|
365
378
|
* filter wire `<cngx-chip-group>` to a custom predicate themselves.
|
|
366
379
|
*
|
|
367
|
-
* **Sync contract - derivation, not effect.**
|
|
368
|
-
* `filterRef.addPredicate(filterKey, predicateFn)` EXACTLY ONCE
|
|
369
|
-
* during mount (in `afterNextRender`, because `input.required()`
|
|
370
|
-
* cannot be read from the constructor body). `predicateFn` is a
|
|
380
|
+
* **Sync contract - derivation, not effect.** `predicateFn` is a
|
|
371
381
|
* closure that reads `this.selectedValues()` and
|
|
372
|
-
* `this.
|
|
382
|
+
* `this.optionValue()` on every invocation. Because
|
|
373
383
|
* `CngxFilter.predicate` is itself a `computed()` consumed by
|
|
374
384
|
* downstream filtered lists, each item-evaluation flows through
|
|
375
385
|
* `selectedValues()` in the consumer's reactive context - chip
|
|
376
386
|
* toggles propagate without any `effect()` writing back into the
|
|
377
|
-
* 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.
|
|
378
393
|
*
|
|
379
394
|
* **Empty-selection semantics.** When `selectedValues()` is `[]`,
|
|
380
395
|
* the closure returns `true` for every item - equivalent to "no
|
|
@@ -384,13 +399,10 @@ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
|
|
|
384
399
|
* re-registering on every empty/non-empty boundary, and keeps the
|
|
385
400
|
* predicate-stack stable (no `predicatesChange` emission churn).
|
|
386
401
|
*
|
|
387
|
-
* **Teardown.**
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
* and `filterKey` lazily so a consumer that re-binds these between
|
|
392
|
-
* mount and unmount cleans the latest binding (per
|
|
393
|
-
* `reference_signal_architecture` memory-hygiene rule).
|
|
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.
|
|
394
406
|
*
|
|
395
407
|
* **Visible caption.** The required `label` renders as a
|
|
396
408
|
* `.cngx-filter-chips__label` caption above the strip so a sighted user
|
|
@@ -431,12 +443,21 @@ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
|
|
|
431
443
|
* <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
|
|
432
444
|
* <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
|
|
433
445
|
*/
|
|
434
|
-
declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
|
|
446
|
+
declare class CngxFilterChips<TItem = unknown, TValue = unknown, TListItem = TItem> {
|
|
435
447
|
readonly label: _angular_core.InputSignal<string>;
|
|
436
448
|
readonly options: _angular_core.InputSignal<readonly TItem[]>;
|
|
437
449
|
readonly optionLabel: _angular_core.InputSignal<(item: TItem) => string>;
|
|
438
450
|
readonly optionValue: _angular_core.InputSignal<(item: TItem) => TValue>;
|
|
439
|
-
readonly filterRef: _angular_core.InputSignal<CngxFilter<
|
|
451
|
+
readonly filterRef: _angular_core.InputSignal<CngxFilter<TListItem>>;
|
|
452
|
+
/**
|
|
453
|
+
* Extracts the comparable value from a filtered list item, when the list
|
|
454
|
+
* is shaped unlike the chip options: role options `{ id, label }` filtering
|
|
455
|
+
* an employee list by `employee.roleId`. Return an array for an item that
|
|
456
|
+
* carries several values (`employee.tags`); it matches when any of them is
|
|
457
|
+
* selected. Unbound, the predicate applies `optionValue` to the list items,
|
|
458
|
+
* which fits a list shaped like the options.
|
|
459
|
+
*/
|
|
460
|
+
readonly itemValue: _angular_core.InputSignal<((item: TListItem) => TValue | readonly TValue[]) | undefined>;
|
|
440
461
|
readonly filterKey: _angular_core.InputSignal<string>;
|
|
441
462
|
readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
442
463
|
/**
|
|
@@ -473,14 +494,14 @@ declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
|
|
|
473
494
|
/**
|
|
474
495
|
* Build the slot context for a given chip option. `optionValue` is
|
|
475
496
|
* invoked here per option for the chip rendering pass; the predicate
|
|
476
|
-
* closure invokes it again per LIST item for membership filtering
|
|
477
|
-
* Both invocations are necessary
|
|
478
|
-
* pool) and filtered list items (the
|
|
479
|
-
* separate data paths - they
|
|
480
|
-
*
|
|
481
|
-
* across the two paths without conflating them. Consumers
|
|
482
|
-
* keep `optionValue` cheap (typically a property lookup);
|
|
483
|
-
* `[itemValue]`
|
|
497
|
+
* closure invokes it again per LIST item for membership filtering
|
|
498
|
+
* while `[itemValue]` is unbound. Both invocations are necessary
|
|
499
|
+
* because option items (the chip pool) and filtered list items (the
|
|
500
|
+
* consumer's filtered data) are separate data paths - they share a
|
|
501
|
+
* shape only when `[itemValue]` is unbound, and the bridge cannot
|
|
502
|
+
* memoise across the two paths without conflating them. Consumers
|
|
503
|
+
* should keep `optionValue` cheap (typically a property lookup); bind
|
|
504
|
+
* `[itemValue]` when the list is shaped unlike the options.
|
|
484
505
|
*/
|
|
485
506
|
protected readonly chipContext: (option: TItem) => CngxFilterChipContext<TItem, TValue>;
|
|
486
507
|
/**
|
|
@@ -491,10 +512,10 @@ declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
|
|
|
491
512
|
* `CngxFilter.predicate`.
|
|
492
513
|
*/
|
|
493
514
|
readonly selectedValues: _angular_core.ModelSignal<TValue[]>;
|
|
494
|
-
private registered;
|
|
495
515
|
constructor();
|
|
496
|
-
|
|
497
|
-
static
|
|
516
|
+
private itemKeys;
|
|
517
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFilterChips<any, any, any>, never>;
|
|
518
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxFilterChips<any, 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; }; "itemValue": { "alias": "itemValue"; "required": false; "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>;
|
|
498
519
|
}
|
|
499
520
|
|
|
500
521
|
/**
|
|
@@ -576,6 +597,18 @@ declare class CngxPaginate {
|
|
|
576
597
|
* stops a fresh-array identity from cascading downstream.
|
|
577
598
|
*/
|
|
578
599
|
readonly cumulativeRange: _angular_core.Signal<[number, number]>;
|
|
600
|
+
/**
|
|
601
|
+
* `range()` with both bounds capped at `total` - the honest in-bounds window
|
|
602
|
+
* for readouts and announcements. `range()`'s upper bound is
|
|
603
|
+
* `start + pageSize`, so a partial final page overshoots `total`; this caps
|
|
604
|
+
* it (and yields `[0, 0]` while the list is empty). The capped end doubles as
|
|
605
|
+
* the cumulative reveal count for load-more consumers: `range()[1]` and
|
|
606
|
+
* `cumulativeRange()[1]` are the same number (`(pageIndex + 1) * pageSize`),
|
|
607
|
+
* so `clampedRange()[1]` is "items shown so far" in both replace and append
|
|
608
|
+
* modes. The explicit tuple `equal` stops a fresh-array identity from
|
|
609
|
+
* cascading downstream.
|
|
610
|
+
*/
|
|
611
|
+
readonly clampedRange: _angular_core.Signal<[number, number]>;
|
|
579
612
|
/** Emitted when the page index changes. */
|
|
580
613
|
readonly pageChange: _angular_core.OutputEmitterRef<number>;
|
|
581
614
|
/** Emitted when the page size changes. */
|
|
@@ -671,7 +704,10 @@ interface CngxPaginateEmitHandlers {
|
|
|
671
704
|
* brain's `pageIndex()` stays pinned to the input until the consumer feeds it
|
|
672
705
|
* back;
|
|
673
706
|
* - an `effect()` reads the effective `pageIndex()` / `pageSize()` and covers a
|
|
674
|
-
* `total`-shrink clamp the nav-only output misses.
|
|
707
|
+
* `total`-shrink clamp the nav-only output misses. The index half of the
|
|
708
|
+
* clamp path is suppressed while the brain is busy or `total` is 0, so a
|
|
709
|
+
* transient total drop during a refetch never persists a page-0 clamp into a
|
|
710
|
+
* controlled consumer; a clamp that survives the settle emits then.
|
|
675
711
|
*
|
|
676
712
|
* The shared guard makes a value one path already emitted a no-op on the other,
|
|
677
713
|
* so each change emits exactly once. Seeded with the current effective values,
|
|
@@ -723,8 +759,10 @@ declare class CngxPaginateRouting implements OnInit {
|
|
|
723
759
|
/** Query-param name for the page size. */
|
|
724
760
|
readonly sizeParam: _angular_core.InputSignal<string>;
|
|
725
761
|
private applyingFromUrl;
|
|
762
|
+
private readonly pendingUrl;
|
|
726
763
|
constructor();
|
|
727
764
|
ngOnInit(): void;
|
|
765
|
+
private applyFromUrl;
|
|
728
766
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxPaginateRouting, never>;
|
|
729
767
|
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>;
|
|
730
768
|
}
|
|
@@ -924,13 +962,15 @@ declare function injectDataSource<T>(data: Signal<T[]>): CngxDataSource<T>;
|
|
|
924
962
|
interface CngxSmartDataSourceOptions<T> {
|
|
925
963
|
/**
|
|
926
964
|
* Custom full-text search function. Receives an item and the current search
|
|
927
|
-
* term; return `true` to keep the item. Defaults to a
|
|
928
|
-
*
|
|
965
|
+
* term; return `true` to keep the item. Defaults to a substring match across
|
|
966
|
+
* all primitive-valued properties that ignores case and accents in the app
|
|
967
|
+
* locale.
|
|
929
968
|
*/
|
|
930
969
|
searchFn?: (item: T, term: string) => boolean;
|
|
931
970
|
/**
|
|
932
971
|
* Custom sort comparator. Receives two items, the active field key, and
|
|
933
|
-
* direction. Defaults to a
|
|
972
|
+
* direction. Defaults to a string comparison collated in the app locale
|
|
973
|
+
* (`CNGX_LOCALE`), numeric-aware and case- and accent-insensitive.
|
|
934
974
|
*/
|
|
935
975
|
sortFn?: (a: T, b: T, field: string, direction: 'asc' | 'desc') => number;
|
|
936
976
|
/**
|
|
@@ -1004,6 +1044,7 @@ declare class CngxSmartDataSource<T> extends DataSource<T> {
|
|
|
1004
1044
|
private readonly injectedFilter;
|
|
1005
1045
|
private readonly injectedSearch;
|
|
1006
1046
|
private readonly injectedPaginate;
|
|
1047
|
+
private readonly locale;
|
|
1007
1048
|
/**
|
|
1008
1049
|
* Items after filter and search are applied, before sort and pagination.
|
|
1009
1050
|
* Use `filteredCount()` to get the pre-pagination count for paginator `total`.
|
|
@@ -1070,6 +1111,16 @@ interface ManualAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1070
1111
|
setSuccess(data: T): void;
|
|
1071
1112
|
/** Transition to `error`. */
|
|
1072
1113
|
setError(error: unknown): void;
|
|
1114
|
+
/**
|
|
1115
|
+
* Transition to `idle` without dropping what the state already holds.
|
|
1116
|
+
*
|
|
1117
|
+
* Clears `error` and `progress`; keeps `data`, `lastUpdated` and the
|
|
1118
|
+
* first-load flag. Use it when an operation ends without changing
|
|
1119
|
+
* anything (a commit the action refused): nothing was replaced, so
|
|
1120
|
+
* nothing is dropped, and no `success` edge is published that a
|
|
1121
|
+
* feedback bridge would report. `reset()` is the full wipe.
|
|
1122
|
+
*/
|
|
1123
|
+
setIdle(): void;
|
|
1073
1124
|
/** Set progress (0–100). */
|
|
1074
1125
|
setProgress(value: number | undefined): void;
|
|
1075
1126
|
/** Reset to `idle`, clear data, error, and progress. */
|
|
@@ -1096,6 +1147,25 @@ interface ManualAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1096
1147
|
*/
|
|
1097
1148
|
declare function createManualState<T>(): ManualAsyncState<T>;
|
|
1098
1149
|
|
|
1150
|
+
/**
|
|
1151
|
+
* Configuration options for `createAsyncState`.
|
|
1152
|
+
*
|
|
1153
|
+
* @category common/data/async-state
|
|
1154
|
+
*/
|
|
1155
|
+
interface CreateAsyncStateOptions {
|
|
1156
|
+
/**
|
|
1157
|
+
* Human-readable label surfaced in `CngxAsyncRegistry.activeOperations`.
|
|
1158
|
+
* Display only - never the registry key. Ignored unless `register` is set.
|
|
1159
|
+
*/
|
|
1160
|
+
label?: string;
|
|
1161
|
+
/**
|
|
1162
|
+
* When `true`, register this state in the ambient `CngxAsyncRegistry` (if
|
|
1163
|
+
* one is provided via `provideAsyncRegistry()`) for the injector's lifetime,
|
|
1164
|
+
* and unregister automatically on destroy. Defaults to `false` - a no-op for
|
|
1165
|
+
* existing callers, and a no-op when no registry is provided.
|
|
1166
|
+
*/
|
|
1167
|
+
register?: boolean;
|
|
1168
|
+
}
|
|
1099
1169
|
/**
|
|
1100
1170
|
* Writable async state for mutations (POST/PUT/DELETE).
|
|
1101
1171
|
*
|
|
@@ -1136,7 +1206,7 @@ interface MutableAsyncState<T> extends CngxAsyncState<T> {
|
|
|
1136
1206
|
*
|
|
1137
1207
|
* @category common/data/async-state
|
|
1138
1208
|
*/
|
|
1139
|
-
declare function createAsyncState<T>(): MutableAsyncState<T>;
|
|
1209
|
+
declare function createAsyncState<T>(options?: CreateAsyncStateOptions): MutableAsyncState<T>;
|
|
1140
1210
|
|
|
1141
1211
|
/**
|
|
1142
1212
|
* Wraps a *changing* source of async state in a stable
|
|
@@ -1181,7 +1251,12 @@ declare function createForwardedAsyncState<T>(source: () => CngxAsyncState<T> |
|
|
|
1181
1251
|
interface InjectAsyncStateOptions {
|
|
1182
1252
|
/**
|
|
1183
1253
|
* Debounce time in ms for signal dependency changes.
|
|
1184
|
-
*
|
|
1254
|
+
* Coalesces rapid changes into one state transition and one consumed
|
|
1255
|
+
* result. Note: a promise-returning `fn` still runs once per change -
|
|
1256
|
+
* the invocation is what tracks its signals - but only the freshest
|
|
1257
|
+
* capture is consumed; superseded captures are observed and discarded.
|
|
1258
|
+
* Cold Observables cost nothing until subscribed, so for them the
|
|
1259
|
+
* debounce fully prevents request storms.
|
|
1185
1260
|
* @default 50
|
|
1186
1261
|
*/
|
|
1187
1262
|
debounce?: number;
|
|
@@ -1351,21 +1426,32 @@ declare class CngxAsyncBoundary implements CngxStateful<readonly unknown[]> {
|
|
|
1351
1426
|
*/
|
|
1352
1427
|
declare function fromResource<T>(ref: Resource<T>): CngxAsyncState<T>;
|
|
1353
1428
|
|
|
1429
|
+
/**
|
|
1430
|
+
* Structural subset of Angular's `HttpProgressEvent` - the byte counts the
|
|
1431
|
+
* bridge reads. `total` is absent when the server sends no length.
|
|
1432
|
+
*/
|
|
1433
|
+
interface HttpProgressLike {
|
|
1434
|
+
readonly loaded: number;
|
|
1435
|
+
readonly total?: number;
|
|
1436
|
+
}
|
|
1354
1437
|
/**
|
|
1355
1438
|
* Shape of an `HttpResourceRef` - only the signals we need.
|
|
1356
1439
|
*
|
|
1357
1440
|
* Declared here to avoid a hard dependency on `@angular/common/http`.
|
|
1358
|
-
* The consumer passes the actual `httpResource()` return value
|
|
1359
|
-
*
|
|
1441
|
+
* The consumer passes the actual `httpResource()` return value, whose
|
|
1442
|
+
* `progress` signal carries the latest `HttpProgressEvent`.
|
|
1360
1443
|
*/
|
|
1361
1444
|
interface HttpResourceLike<T> extends Resource<T> {
|
|
1362
|
-
progress: () =>
|
|
1445
|
+
progress: () => HttpProgressLike | undefined;
|
|
1363
1446
|
}
|
|
1364
1447
|
/**
|
|
1365
1448
|
* Bridge that projects an Angular `httpResource()` ref onto `CngxAsyncState<T>`.
|
|
1366
1449
|
*
|
|
1367
1450
|
* Identical to `fromResource` but additionally maps the HTTP progress
|
|
1368
|
-
* signal to `CngxAsyncState.progress` (0
|
|
1451
|
+
* signal to `CngxAsyncState.progress` (0-100 scale): `loaded / total`,
|
|
1452
|
+
* rounded and clamped. With an unknown or zero `total` the progress is
|
|
1453
|
+
* `undefined` (indeterminate). Angular only emits progress events when the
|
|
1454
|
+
* request sets `reportProgress: true`.
|
|
1369
1455
|
*
|
|
1370
1456
|
* Must be called in an injection context.
|
|
1371
1457
|
*
|
|
@@ -1373,10 +1459,11 @@ interface HttpResourceLike<T> extends Resource<T> {
|
|
|
1373
1459
|
* private readonly res = httpResource<Item[]>(() => ({
|
|
1374
1460
|
* url: '/api/items',
|
|
1375
1461
|
* params: { q: this.filter() },
|
|
1462
|
+
* reportProgress: true,
|
|
1376
1463
|
* }));
|
|
1377
1464
|
*
|
|
1378
1465
|
* readonly items = fromHttpResource(this.res);
|
|
1379
|
-
* // items.progress() tracks
|
|
1466
|
+
* // items.progress() tracks download progress 0-100
|
|
1380
1467
|
* // <cngx-progress [state]="items"> - auto-wired progress bar
|
|
1381
1468
|
* ```
|
|
1382
1469
|
*
|
|
@@ -1390,17 +1477,26 @@ declare function fromHttpResource<T>(ref: HttpResourceLike<T>): CngxAsyncState<T
|
|
|
1390
1477
|
* Any `ManualAsyncState<T>` satisfies this - operators only need the write side.
|
|
1391
1478
|
*/
|
|
1392
1479
|
interface AsyncStateSink<T> {
|
|
1393
|
-
set(status: 'loading' | 'refreshing' | 'pending'): void;
|
|
1480
|
+
set(status: 'idle' | 'loading' | 'refreshing' | 'pending'): void;
|
|
1394
1481
|
setSuccess(data: T): void;
|
|
1395
1482
|
setError(error: unknown): void;
|
|
1396
1483
|
setProgress(value: number | undefined): void;
|
|
1484
|
+
/**
|
|
1485
|
+
* Optional read side: when present, `tapAsyncState` picks `refreshing`
|
|
1486
|
+
* over `loading` for a re-subscribe after data has already landed.
|
|
1487
|
+
* Any `ManualAsyncState<T>` provides it.
|
|
1488
|
+
*/
|
|
1489
|
+
isFirstLoad?: () => boolean;
|
|
1397
1490
|
}
|
|
1398
1491
|
/**
|
|
1399
1492
|
* RxJS operator that wires an Observable's lifecycle to a `ManualAsyncState`.
|
|
1400
1493
|
*
|
|
1401
|
-
* On subscribe: sets `loading` (or `refreshing` if data was already loaded
|
|
1494
|
+
* On subscribe: sets `loading` (or `refreshing` if data was already loaded,
|
|
1495
|
+
* read via the sink's `isFirstLoad`; an explicit `options.status` wins).
|
|
1402
1496
|
* On next: calls `setSuccess(value)`.
|
|
1403
1497
|
* On error: calls `setError(err)` and **re-throws** (does not swallow).
|
|
1498
|
+
* On teardown without a value (unsubscribe mid-flight, empty complete):
|
|
1499
|
+
* resets the sink to `idle` so a cancelled request never leaves it busy.
|
|
1404
1500
|
*
|
|
1405
1501
|
* The Observable passes through unchanged - `tapAsyncState` is a side-effect operator.
|
|
1406
1502
|
*
|
|
@@ -1458,7 +1554,8 @@ declare function tapAsyncProgress<E>(state: Pick<AsyncStateSink<unknown>, 'setPr
|
|
|
1458
1554
|
* 5. Call `setError(err)` on error
|
|
1459
1555
|
*
|
|
1460
1556
|
* The output Observable emits the **response body** (not HttpEvents).
|
|
1461
|
-
* Throws if the response body is
|
|
1557
|
+
* Throws a `CngxRuntimeError` with code `CNGX1054` if the response body is
|
|
1558
|
+
* `null`; the sink receives it through `setError(err)`.
|
|
1462
1559
|
*
|
|
1463
1560
|
* ```typescript
|
|
1464
1561
|
* readonly upload = createManualState<UploadResult>();
|
|
@@ -1701,7 +1798,10 @@ interface CngxAsyncContext<T> {
|
|
|
1701
1798
|
* - **success + empty** → empty template (or nothing)
|
|
1702
1799
|
* - **error (first load)** → error template (or nothing)
|
|
1703
1800
|
* - **refreshing / loading (with data)** → content template (old data stays visible)
|
|
1704
|
-
* - **error (with data)** → content template (old data stays visible)
|
|
1801
|
+
* - **error (with data)** → content template (old data stays visible) -
|
|
1802
|
+
* `resolveAsyncView` reports this as `content+error`, but a structural
|
|
1803
|
+
* directive renders exactly one template, so the error half is flattened
|
|
1804
|
+
* away here; surface it separately (toast, alert) when it must be visible
|
|
1705
1805
|
*
|
|
1706
1806
|
* ### Minimal - just content
|
|
1707
1807
|
* ```html
|
|
@@ -1757,7 +1857,7 @@ declare class CngxAsync<T> {
|
|
|
1757
1857
|
$implicit: unknown;
|
|
1758
1858
|
}> | undefined>;
|
|
1759
1859
|
private readonly view;
|
|
1760
|
-
private
|
|
1860
|
+
private currentView;
|
|
1761
1861
|
private contentViewRef;
|
|
1762
1862
|
constructor();
|
|
1763
1863
|
private updateContentContext;
|
|
@@ -1772,8 +1872,9 @@ declare class CngxAsync<T> {
|
|
|
1772
1872
|
/**
|
|
1773
1873
|
* Displays a formatted numeric value with optional unit.
|
|
1774
1874
|
*
|
|
1775
|
-
* Uses `Intl.NumberFormat` with the
|
|
1776
|
-
*
|
|
1875
|
+
* Uses `Intl.NumberFormat` with the app locale (`CNGX_LOCALE`, falling back to
|
|
1876
|
+
* the nearest `LOCALE_ID`) for locale-aware formatting; a locale flip
|
|
1877
|
+
* re-formats. A `null` value renders the placeholder glyph without its unit.
|
|
1777
1878
|
*
|
|
1778
1879
|
* Composable - works inside any card variant, header, body, or standalone.
|
|
1779
1880
|
*
|
|
@@ -1807,7 +1908,11 @@ declare class CngxAsync<T> {
|
|
|
1807
1908
|
*/
|
|
1808
1909
|
declare class CngxMetric {
|
|
1809
1910
|
private readonly locale;
|
|
1810
|
-
|
|
1911
|
+
private readonly i18n;
|
|
1912
|
+
/**
|
|
1913
|
+
* Numeric or string value. `null` renders the `metricPlaceholder` glyph of
|
|
1914
|
+
* the kpi language section and is announced as its `metricNoValue` text.
|
|
1915
|
+
*/
|
|
1811
1916
|
readonly value: _angular_core.InputSignal<string | number | null>;
|
|
1812
1917
|
/** Unit suffix (e.g. "bpm", "h", "%", "kg"). */
|
|
1813
1918
|
readonly unit: _angular_core.InputSignal<string | undefined>;
|
|
@@ -1815,6 +1920,13 @@ declare class CngxMetric {
|
|
|
1815
1920
|
readonly format: _angular_core.InputSignal<Intl.NumberFormatOptions | undefined>;
|
|
1816
1921
|
/** @internal */
|
|
1817
1922
|
readonly formattedValue: _angular_core.Signal<string>;
|
|
1923
|
+
/**
|
|
1924
|
+
* @internal The unit to render, `undefined` while there is no value: a
|
|
1925
|
+
* missing reading has no unit, so "No value km" is never shown or spoken.
|
|
1926
|
+
*/
|
|
1927
|
+
protected readonly shownUnit: _angular_core.Signal<string | undefined>;
|
|
1928
|
+
/** @internal Unit before value, per the `metricValueWithUnit` message. */
|
|
1929
|
+
protected readonly unitFirst: _angular_core.Signal<boolean>;
|
|
1818
1930
|
/** @internal Full accessible description including unit. */
|
|
1819
1931
|
readonly accessibleValue: _angular_core.Signal<string>;
|
|
1820
1932
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMetric, never>;
|
|
@@ -1860,6 +1972,7 @@ declare class CngxMetric {
|
|
|
1860
1972
|
*/
|
|
1861
1973
|
declare class CngxTrend {
|
|
1862
1974
|
private readonly locale;
|
|
1975
|
+
private readonly i18n;
|
|
1863
1976
|
/** Trend percentage. Positive = up, negative = down, zero = flat. */
|
|
1864
1977
|
readonly value: _angular_core.InputSignal<number>;
|
|
1865
1978
|
/** Consumer-provided SR label override. When set, replaces the generated default. */
|
|
@@ -1874,18 +1987,6 @@ declare class CngxTrend {
|
|
|
1874
1987
|
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>;
|
|
1875
1988
|
}
|
|
1876
1989
|
|
|
1877
|
-
/**
|
|
1878
|
-
* Pure, framework-agnostic helpers that turn a signed delta value into the
|
|
1879
|
-
* three orthogonal signals a KPI atom renders: **direction** (which way the
|
|
1880
|
-
* arrow points), **sentiment** (whether the change is good or bad, which
|
|
1881
|
-
* drives colour and the SR word), and the formatted magnitude.
|
|
1882
|
-
*
|
|
1883
|
-
* Direction and sentiment are deliberately separate. `CngxTrend` colours by
|
|
1884
|
-
* direction (up = green); `CngxDelta` colours by sentiment, so a value that
|
|
1885
|
-
* dropped can still read as an improvement (churn down, latency down). Both
|
|
1886
|
-
* consume these helpers so the direction / glyph / format logic has a single
|
|
1887
|
-
* source of truth (Pillar 1) with no Angular dependency.
|
|
1888
|
-
*/
|
|
1889
1990
|
/** Which way the delta moved. `flat` is exactly zero. */
|
|
1890
1991
|
type DeltaDirection = 'up' | 'down' | 'flat';
|
|
1891
1992
|
/**
|
|
@@ -1937,6 +2038,7 @@ type DeltaMode = 'percent' | 'absolute';
|
|
|
1937
2038
|
*/
|
|
1938
2039
|
declare class CngxDelta {
|
|
1939
2040
|
private readonly locale;
|
|
2041
|
+
private readonly i18n;
|
|
1940
2042
|
/** Signed delta. Positive = up, negative = down, zero = flat. */
|
|
1941
2043
|
readonly value: _angular_core.InputSignal<number>;
|
|
1942
2044
|
/**
|
|
@@ -1952,19 +2054,115 @@ declare class CngxDelta {
|
|
|
1952
2054
|
/** Consumer-provided SR label override. Replaces the generated default. */
|
|
1953
2055
|
readonly label: _angular_core.InputSignal<string | undefined>;
|
|
1954
2056
|
/** @internal Raw movement, independent of polarity. Drives the glyph. */
|
|
1955
|
-
protected readonly direction: _angular_core.Signal<DeltaDirection>;
|
|
2057
|
+
protected readonly direction: _angular_core.Signal<_cngx_common_data.DeltaDirection>;
|
|
1956
2058
|
/** @internal Good / bad / indifferent. Drives colour and the SR word. */
|
|
1957
|
-
protected readonly sentiment: _angular_core.Signal<DeltaSentiment>;
|
|
2059
|
+
protected readonly sentiment: _angular_core.Signal<_cngx_common_data.DeltaSentiment>;
|
|
1958
2060
|
/** @internal Arrow glyph bound from direction only. */
|
|
1959
2061
|
protected readonly glyph: _angular_core.Signal<string>;
|
|
1960
2062
|
/** @internal Formatted magnitude. */
|
|
1961
2063
|
protected readonly formattedValue: _angular_core.Signal<string>;
|
|
1962
|
-
/**
|
|
2064
|
+
/**
|
|
2065
|
+
* @internal Full SR label: magnitude plus the sentiment word, composed by
|
|
2066
|
+
* `CNGX_KPI_I18N.deltaLabel` unless `[label]` is bound.
|
|
2067
|
+
*/
|
|
1963
2068
|
protected readonly resolvedLabel: _angular_core.Signal<string>;
|
|
1964
2069
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDelta, never>;
|
|
1965
2070
|
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>;
|
|
1966
2071
|
}
|
|
1967
2072
|
|
|
2073
|
+
/**
|
|
2074
|
+
* KPI atom i18n surface. Library defaults are English; consumers override
|
|
2075
|
+
* via {@link provideKpiI18n}. Reactive from birth: the token carries a
|
|
2076
|
+
* `Signal`, and {@link withKpiI18nLabels} accepts a `Signal` of a partial
|
|
2077
|
+
* bundle, so a runtime language switch re-derives every label.
|
|
2078
|
+
*
|
|
2079
|
+
* Every key is a formatter, so word order and plural rules belong to the
|
|
2080
|
+
* translator. The magnitude arrives already formatted in the app locale
|
|
2081
|
+
* (`CNGX_LOCALE`); the per-instance `label` / `valueTextFormat` inputs still
|
|
2082
|
+
* win over the bundle.
|
|
2083
|
+
*
|
|
2084
|
+
* @category common/data/i18n
|
|
2085
|
+
* @since 0.1.0
|
|
2086
|
+
*/
|
|
2087
|
+
interface CngxKpiI18n {
|
|
2088
|
+
/** `CngxDelta` accessible name: formatted magnitude plus the sentiment word. */
|
|
2089
|
+
readonly deltaLabel: (formatted: string, sentiment: DeltaSentiment) => string;
|
|
2090
|
+
/** `CngxTrend` accessible name: formatted magnitude plus the direction word. */
|
|
2091
|
+
readonly trendLabel: (formatted: string, direction: DeltaDirection) => string;
|
|
2092
|
+
/** `CngxGoal` `aria-valuetext`: clamped value and target. */
|
|
2093
|
+
readonly goalValueText: (now: number, max: number) => string;
|
|
2094
|
+
/**
|
|
2095
|
+
* `CngxMetric` order of value and unit: `{value}` and `{unit}` in reading
|
|
2096
|
+
* order, a plain template the metric renders as two elements. English
|
|
2097
|
+
* `'{value} {unit}'`.
|
|
2098
|
+
*/
|
|
2099
|
+
readonly metricValueWithUnit: string;
|
|
2100
|
+
/** Shown in place of a `CngxMetric` without a value. English: the U+2014 glyph. */
|
|
2101
|
+
readonly metricPlaceholder: string;
|
|
2102
|
+
/** Accessible name of a `CngxMetric` without a value. English `No value`. */
|
|
2103
|
+
readonly metricNoValue: string;
|
|
2104
|
+
}
|
|
2105
|
+
/**
|
|
2106
|
+
* DI token for the KPI i18n bundle. `providedIn: 'root'`: the kpi section
|
|
2107
|
+
* of the active language pack over the English defaults, formatted for the
|
|
2108
|
+
* app locale; the value is a `Signal`, shared by every reader under one
|
|
2109
|
+
* injector.
|
|
2110
|
+
*
|
|
2111
|
+
* @category common/data/i18n
|
|
2112
|
+
* @wcag AA
|
|
2113
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/shared/kpi-i18n.ts
|
|
2114
|
+
* @since 0.1.0
|
|
2115
|
+
* @relatedTo CngxDelta, CngxTrend, CngxGoal
|
|
2116
|
+
*/
|
|
2117
|
+
declare const CNGX_KPI_I18N: InjectionToken<Signal<CngxKpiI18n>>;
|
|
2118
|
+
/**
|
|
2119
|
+
* Branded feature-fn for {@link provideKpiI18n}.
|
|
2120
|
+
*
|
|
2121
|
+
* @category common/data/i18n
|
|
2122
|
+
* @since 0.1.0
|
|
2123
|
+
*/
|
|
2124
|
+
type CngxKpiI18nFeature = ((bundle: Signal<CngxKpiI18n>) => Signal<CngxKpiI18n>) & {
|
|
2125
|
+
readonly _target: 'i18n';
|
|
2126
|
+
};
|
|
2127
|
+
/**
|
|
2128
|
+
* Override KPI labels via a partial bundle - unset keys keep the language
|
|
2129
|
+
* pack's copy, or the English default. Pass a `Signal` of a partial bundle to switch languages at
|
|
2130
|
+
* runtime.
|
|
2131
|
+
*
|
|
2132
|
+
* @category common/data/i18n
|
|
2133
|
+
* @since 0.1.0
|
|
2134
|
+
*/
|
|
2135
|
+
declare function withKpiI18nLabels(overrides: Partial<CngxKpiI18n> | Signal<Partial<CngxKpiI18n>>): CngxKpiI18nFeature;
|
|
2136
|
+
/**
|
|
2137
|
+
* Provider for the KPI i18n bundle. Returns a plain `Provider`, so it also
|
|
2138
|
+
* scopes a subtree through `viewProviders`. The features apply on top of the
|
|
2139
|
+
* active language pack.
|
|
2140
|
+
*
|
|
2141
|
+
* ```ts
|
|
2142
|
+
* bootstrapApplication(AppComponent, {
|
|
2143
|
+
* providers: [
|
|
2144
|
+
* provideKpiI18n(
|
|
2145
|
+
* withKpiI18nLabels({
|
|
2146
|
+
* goalValueText: (now, max) => `${now} von ${max}`,
|
|
2147
|
+
* }),
|
|
2148
|
+
* ),
|
|
2149
|
+
* ],
|
|
2150
|
+
* });
|
|
2151
|
+
* ```
|
|
2152
|
+
*
|
|
2153
|
+
* @category common/data/i18n
|
|
2154
|
+
* @since 0.1.0
|
|
2155
|
+
*/
|
|
2156
|
+
declare function provideKpiI18n(...features: readonly CngxKpiI18nFeature[]): Provider;
|
|
2157
|
+
/**
|
|
2158
|
+
* Inject the resolved KPI i18n bundle signal. Read it inside a `computed()`
|
|
2159
|
+
* or template so a runtime override flip re-derives.
|
|
2160
|
+
*
|
|
2161
|
+
* @category common/data/i18n
|
|
2162
|
+
* @since 0.1.0
|
|
2163
|
+
*/
|
|
2164
|
+
declare function injectKpiI18n(): Signal<CngxKpiI18n>;
|
|
2165
|
+
|
|
1968
2166
|
/** The four coordinated slots of a {@link CngxStat}, in reading order. */
|
|
1969
2167
|
type CngxStatSlotKind = 'label' | 'value' | 'delta' | 'caption';
|
|
1970
2168
|
/**
|
|
@@ -1978,8 +2176,12 @@ type CngxStatSlotKind = 'label' | 'value' | 'delta' | 'caption';
|
|
|
1978
2176
|
interface CngxStatRegistry {
|
|
1979
2177
|
/** Register (or replace) the id contributed by `kind`. */
|
|
1980
2178
|
register(kind: CngxStatSlotKind, id: string): void;
|
|
1981
|
-
/**
|
|
1982
|
-
|
|
2179
|
+
/**
|
|
2180
|
+
* Withdraw the id contributed by `kind`. When `id` is given, the
|
|
2181
|
+
* withdrawal applies only while that id is still the registered one -
|
|
2182
|
+
* a register-before-destroy replacement is left alone.
|
|
2183
|
+
*/
|
|
2184
|
+
unregister(kind: CngxStatSlotKind, id?: string): void;
|
|
1983
2185
|
}
|
|
1984
2186
|
/** DI token carrying the {@link CngxStatRegistry} a `CngxStat` provides. */
|
|
1985
2187
|
declare const CNGX_STAT: InjectionToken<CngxStatRegistry>;
|
|
@@ -2013,7 +2215,7 @@ declare class CngxStatCoordinator implements CngxStatRegistry {
|
|
|
2013
2215
|
/** {@inheritDoc CngxStatRegistry.register} */
|
|
2014
2216
|
register(kind: CngxStatSlotKind, id: string): void;
|
|
2015
2217
|
/** {@inheritDoc CngxStatRegistry.unregister} */
|
|
2016
|
-
unregister(kind: CngxStatSlotKind): void;
|
|
2218
|
+
unregister(kind: CngxStatSlotKind, id?: string): void;
|
|
2017
2219
|
/** Present slot ids in reading order; structurally stable. */
|
|
2018
2220
|
readonly orderedIds: _angular_core.Signal<string[]>;
|
|
2019
2221
|
/** Combined accessible name for the host; `null` when no slot is present. */
|
|
@@ -2143,7 +2345,7 @@ declare class CngxStatCaption {
|
|
|
2143
2345
|
* derived percent bound as a CSS custom property.
|
|
2144
2346
|
*
|
|
2145
2347
|
* ```html
|
|
2146
|
-
* <cngx-goal [value]="73" [max]="100" />
|
|
2348
|
+
* <cngx-goal [value]="73" [max]="100" label="Quota attainment" />
|
|
2147
2349
|
* <cngx-goal [value]="q()" [max]="target()" [valueTextFormat]="quotaText" />
|
|
2148
2350
|
* ```
|
|
2149
2351
|
*
|
|
@@ -2157,14 +2359,23 @@ declare class CngxStatCaption {
|
|
|
2157
2359
|
* <example-url>http://localhost:4200/#/common/data/goal/quota-attainment</example-url>
|
|
2158
2360
|
*/
|
|
2159
2361
|
declare class CngxGoal {
|
|
2362
|
+
private readonly i18n;
|
|
2160
2363
|
/** Current attainment. Clamped to `[0, max]`. */
|
|
2161
2364
|
readonly value: _angular_core.InputSignal<number>;
|
|
2162
2365
|
/** Target the value works toward. Defaults to `100`. */
|
|
2163
2366
|
readonly max: _angular_core.InputSignal<number>;
|
|
2367
|
+
/**
|
|
2368
|
+
* Accessible name for the progressbar (what the attainment measures, e.g.
|
|
2369
|
+
* "Quarterly quota"). Mirrors the `label` input of the sibling KPI atoms;
|
|
2370
|
+
* omit it only when an external `aria-labelledby` (e.g. a `cngxStatLabel`)
|
|
2371
|
+
* names the bar instead.
|
|
2372
|
+
*/
|
|
2373
|
+
readonly label: _angular_core.InputSignal<string | undefined>;
|
|
2164
2374
|
/**
|
|
2165
2375
|
* Override the `aria-valuetext` string. Receives `(now, max)` - the clamped
|
|
2166
|
-
* value and the target.
|
|
2167
|
-
*
|
|
2376
|
+
* value and the target. Wins over the app-wide `CNGX_KPI_I18N.goalValueText`
|
|
2377
|
+
* (English default `(now, max) => \`${now} of ${max}\``). Supply a closure
|
|
2378
|
+
* for richer per-instance text (e.g.
|
|
2168
2379
|
* `(n, m) => \`${n} of ${m}, ${Math.round((n / m) * 100)}% of quota\``).
|
|
2169
2380
|
*/
|
|
2170
2381
|
readonly valueTextFormat: _angular_core.InputSignal<((now: number, max: number) => string) | undefined>;
|
|
@@ -2177,7 +2388,7 @@ declare class CngxGoal {
|
|
|
2177
2388
|
/** `aria-valuetext` - human-readable attainment via the resolved closure. */
|
|
2178
2389
|
protected readonly valueText: Signal<string>;
|
|
2179
2390
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxGoal, never>;
|
|
2180
|
-
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>;
|
|
2391
|
+
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>;
|
|
2181
2392
|
}
|
|
2182
2393
|
|
|
2183
2394
|
/**
|
|
@@ -2197,33 +2408,51 @@ interface RecyclerI18n {
|
|
|
2197
2408
|
error(): string;
|
|
2198
2409
|
}
|
|
2199
2410
|
/**
|
|
2200
|
-
* Injection token for recycler SR announcement texts
|
|
2201
|
-
*
|
|
2411
|
+
* Injection token for recycler SR announcement texts, a `Signal` so the
|
|
2412
|
+
* texts follow a runtime language switch. Defaults to the recycler section
|
|
2413
|
+
* of the active language pack over English, counts formatted for the app
|
|
2414
|
+
* locale. Override with `provideRecyclerI18n()`.
|
|
2202
2415
|
*
|
|
2203
2416
|
* @category common/data/recycler
|
|
2204
2417
|
* @wcag AA
|
|
2205
2418
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler.ts
|
|
2206
2419
|
* @since 0.1.0
|
|
2207
2420
|
*/
|
|
2208
|
-
declare const CNGX_RECYCLER_I18N: InjectionToken<RecyclerI18n
|
|
2421
|
+
declare const CNGX_RECYCLER_I18N: InjectionToken<Signal<RecyclerI18n>>;
|
|
2209
2422
|
/**
|
|
2210
|
-
*
|
|
2423
|
+
* Branded feature-fn for {@link provideRecyclerI18n}.
|
|
2424
|
+
*
|
|
2425
|
+
* @category common/data/recycler
|
|
2426
|
+
*/
|
|
2427
|
+
type CngxRecyclerI18nFeature = ((bundle: Signal<RecyclerI18n>) => Signal<RecyclerI18n>) & {
|
|
2428
|
+
readonly _target: 'i18n';
|
|
2429
|
+
};
|
|
2430
|
+
/**
|
|
2431
|
+
* Override recycler announcements via a partial bundle - keys you leave out
|
|
2432
|
+
* keep the language pack's text, or the English default. Pass a `Signal` to
|
|
2433
|
+
* switch the language at runtime.
|
|
2434
|
+
*
|
|
2435
|
+
* @category common/data/recycler
|
|
2436
|
+
*/
|
|
2437
|
+
declare function withRecyclerI18nLabels(overrides: Partial<RecyclerI18n> | Signal<Partial<RecyclerI18n>>): CngxRecyclerI18nFeature;
|
|
2438
|
+
/**
|
|
2439
|
+
* Provider for the recycler announcement texts. The features apply on top of
|
|
2440
|
+
* the active language pack.
|
|
2211
2441
|
*
|
|
2212
2442
|
* ```typescript
|
|
2213
|
-
* providers: [
|
|
2214
|
-
*
|
|
2215
|
-
*
|
|
2216
|
-
*
|
|
2217
|
-
*
|
|
2218
|
-
*
|
|
2443
|
+
* providers: [
|
|
2444
|
+
* provideRecyclerI18n(
|
|
2445
|
+
* withRecyclerI18nLabels({
|
|
2446
|
+
* empty: () => 'Keine Ergebnisse.',
|
|
2447
|
+
* error: () => 'Fehler beim Laden.',
|
|
2448
|
+
* }),
|
|
2449
|
+
* ),
|
|
2450
|
+
* ]
|
|
2219
2451
|
* ```
|
|
2220
2452
|
*
|
|
2221
2453
|
* @category common/data/recycler
|
|
2222
2454
|
*/
|
|
2223
|
-
declare function provideRecyclerI18n(
|
|
2224
|
-
provide: InjectionToken<RecyclerI18n>;
|
|
2225
|
-
useValue: RecyclerI18n;
|
|
2226
|
-
};
|
|
2455
|
+
declare function provideRecyclerI18n(...features: readonly CngxRecyclerI18nFeature[]): Provider;
|
|
2227
2456
|
/**
|
|
2228
2457
|
* Configuration for {@link injectRecycler}.
|
|
2229
2458
|
*
|
|
@@ -2292,6 +2521,15 @@ interface CngxRecycler {
|
|
|
2292
2521
|
readonly offsetAfter: Signal<number>;
|
|
2293
2522
|
/** Total scrollable height of all items (px). */
|
|
2294
2523
|
readonly totalSize: Signal<number>;
|
|
2524
|
+
/**
|
|
2525
|
+
* Representative row height (px) for a placeholder layer's repeat rhythm.
|
|
2526
|
+
* A numeric or `Signal<number>` `estimateSize` is already uniform, so it is
|
|
2527
|
+
* used verbatim; a per-index variable estimate has no single height, so the
|
|
2528
|
+
* average (`totalSize / totalCount`) stands in. Consumed by
|
|
2529
|
+
* {@link CngxRecyclerPlaceholder} to key its repeating skeleton interval off
|
|
2530
|
+
* the same rhythm the range uses. `0` on an empty list.
|
|
2531
|
+
*/
|
|
2532
|
+
readonly rowSizeHint: Signal<number>;
|
|
2295
2533
|
/** Placeholder count before rendered items. Only non-zero in grid mode. */
|
|
2296
2534
|
readonly placeholdersBefore: Signal<number>;
|
|
2297
2535
|
/** Placeholder count after rendered items. Only non-zero in grid mode. */
|
|
@@ -2446,6 +2684,7 @@ declare class CngxMeasure {
|
|
|
2446
2684
|
/** The absolute index of this item in the full dataset. */
|
|
2447
2685
|
readonly cngxMeasureIndex: _angular_core.InputSignal<number>;
|
|
2448
2686
|
private readonly el;
|
|
2687
|
+
private readonly win;
|
|
2449
2688
|
constructor();
|
|
2450
2689
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMeasure, never>;
|
|
2451
2690
|
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>;
|
|
@@ -2497,6 +2736,228 @@ declare class CngxVirtualItem {
|
|
|
2497
2736
|
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>;
|
|
2498
2737
|
}
|
|
2499
2738
|
|
|
2739
|
+
/**
|
|
2740
|
+
* Paints a row-aligned skeleton background under a virtualized scroll region so
|
|
2741
|
+
* a fast fling or teleport jump reveals placeholder bars instead of the bare
|
|
2742
|
+
* panel/page surface for the single frame the rendered rows lag `scrollTop`.
|
|
2743
|
+
*
|
|
2744
|
+
* The mechanism is a static CSS layer, not a reactive template: by the time a
|
|
2745
|
+
* `@for` over "uncovered indices" could render, change detection has already
|
|
2746
|
+
* produced the real rows, so the lag frame is never painted reactively. A
|
|
2747
|
+
* `background` on the offset element always paints and also covers teleport
|
|
2748
|
+
* jumps no reactive window can, at zero per-frame cost.
|
|
2749
|
+
*
|
|
2750
|
+
* Host it on the **offset spacer element(s)** - the empty divs (or presentation
|
|
2751
|
+
* `<li>`s) whose height reserves `offsetBefore` / `offsetAfter` - one directive
|
|
2752
|
+
* instance per spacer. Do NOT host it on a `padding-block`ed content element
|
|
2753
|
+
* that also contains the rows: a background paints across the whole padding box,
|
|
2754
|
+
* so it would show through *behind* every rendered row, not just in the gap.
|
|
2755
|
+
* The spacers carry no rows, so the layer is only ever visible where the window
|
|
2756
|
+
* has not caught up.
|
|
2757
|
+
*
|
|
2758
|
+
* The repeat interval keys off a single representative row height: bind the
|
|
2759
|
+
* recycler to read its `rowSizeHint`, or pass an explicit `[rowHeight]`
|
|
2760
|
+
* fallback so the directive is usable standalone. Visuals are driven by
|
|
2761
|
+
* `--cngx-recycler-placeholder-*` CSS custom properties (see
|
|
2762
|
+
* `@cngx/common/theming/components/cngx-recycler-placeholder.css`); the shimmer
|
|
2763
|
+
* drops under `prefers-reduced-motion` via a spec-observable host class.
|
|
2764
|
+
*
|
|
2765
|
+
* ### One instance per offset spacer, keyed off the recycler's rhythm
|
|
2766
|
+
* ```html
|
|
2767
|
+
* <ul>
|
|
2768
|
+
* @if (recycler.offsetBefore(); as before) {
|
|
2769
|
+
* <li role="presentation" aria-hidden="true"
|
|
2770
|
+
* [cngxRecyclerPlaceholder]="recycler" [style.height.px]="before"></li>
|
|
2771
|
+
* }
|
|
2772
|
+
* @for (item of visibleItems(); track item.id) { <li>...</li> }
|
|
2773
|
+
* @if (recycler.offsetAfter(); as after) {
|
|
2774
|
+
* <li role="presentation" aria-hidden="true"
|
|
2775
|
+
* [cngxRecyclerPlaceholder]="recycler" [style.height.px]="after"></li>
|
|
2776
|
+
* }
|
|
2777
|
+
* </ul>
|
|
2778
|
+
* ```
|
|
2779
|
+
*
|
|
2780
|
+
* ### Standalone with an explicit row height
|
|
2781
|
+
* ```html
|
|
2782
|
+
* <div cngxRecyclerPlaceholder [rowHeight]="48"
|
|
2783
|
+
* [style.height.px]="recycler.offsetBefore()"></div>
|
|
2784
|
+
* ```
|
|
2785
|
+
*
|
|
2786
|
+
* @category common/data/recycler
|
|
2787
|
+
* @docsKind primary
|
|
2788
|
+
* @wcag AA
|
|
2789
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-placeholder.directive.ts
|
|
2790
|
+
* @since 0.1.0
|
|
2791
|
+
* @relatedTo injectRecycler, CngxRecyclerRow, CngxVirtualItem, CngxMeasure
|
|
2792
|
+
* <example-url>http://localhost:4200/#/common/data/recycler/fast-fling-placeholders</example-url>
|
|
2793
|
+
*/
|
|
2794
|
+
declare class CngxRecyclerPlaceholder {
|
|
2795
|
+
/**
|
|
2796
|
+
* The recycler whose `rowSizeHint` sets the placeholder repeat rhythm.
|
|
2797
|
+
* Optional: the directive also works from an explicit `[rowHeight]`, so this
|
|
2798
|
+
* follows the bridge-input shape (optional + empty-string transform) rather
|
|
2799
|
+
* than `input.required` - a bare `cngxRecyclerPlaceholder` attribute paired
|
|
2800
|
+
* with `[rowHeight]` is a valid, unbound usage.
|
|
2801
|
+
*/
|
|
2802
|
+
readonly recycler: _angular_core.InputSignalWithTransform<CngxRecycler | undefined, "" | CngxRecycler | undefined>;
|
|
2803
|
+
/** Explicit row height (px) used when no recycler is bound, or as a fallback. */
|
|
2804
|
+
readonly rowHeight: _angular_core.InputSignal<number | undefined>;
|
|
2805
|
+
private readonly prefersReducedMotion;
|
|
2806
|
+
constructor();
|
|
2807
|
+
/**
|
|
2808
|
+
* Representative row height (px) for the repeat interval. The recycler's
|
|
2809
|
+
* `rowSizeHint` wins when it resolves to a positive value; otherwise the
|
|
2810
|
+
* explicit `[rowHeight]` fallback applies.
|
|
2811
|
+
*/
|
|
2812
|
+
protected readonly resolvedRowHeight: Signal<number>;
|
|
2813
|
+
/**
|
|
2814
|
+
* The `--cngx-recycler-placeholder-row-height` style value. `null` when no
|
|
2815
|
+
* row height resolves, so the registered `@property` default (or an inherited
|
|
2816
|
+
* token from an ancestor mapping) applies instead of a broken `0px` interval.
|
|
2817
|
+
*/
|
|
2818
|
+
protected readonly rowHeightVar: Signal<string | null>;
|
|
2819
|
+
/** Whether the shimmer host class is applied (dropped under reduced-motion). */
|
|
2820
|
+
protected readonly showShimmer: Signal<boolean>;
|
|
2821
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxRecyclerPlaceholder, never>;
|
|
2822
|
+
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>;
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
/**
|
|
2826
|
+
* Context for the placeholder branch of `*cngxRecyclerRow` - the window slot
|
|
2827
|
+
* whose item has not loaded yet (`undefined`). A custom `placeholder:` template
|
|
2828
|
+
* reads this to keep the list count honest for assistive technology:
|
|
2829
|
+
* `aria-posinset = index + 1`, `aria-setsize = setSize`.
|
|
2830
|
+
*
|
|
2831
|
+
* The real-row branch (item defined) binds `$implicit` to the item value
|
|
2832
|
+
* instead; that context is internal and narrowed by `ngTemplateContextGuard`.
|
|
2833
|
+
*
|
|
2834
|
+
* @category common/data/recycler
|
|
2835
|
+
*/
|
|
2836
|
+
interface CngxRecyclerRowContext {
|
|
2837
|
+
/** The absolute dataset index of this slot. Alias of `index`. */
|
|
2838
|
+
$implicit: number;
|
|
2839
|
+
/** The absolute dataset index of this slot. */
|
|
2840
|
+
index: number;
|
|
2841
|
+
/** Pixel offset of the slot from the top of the scroll content. */
|
|
2842
|
+
top: number;
|
|
2843
|
+
/** Total set size (`recycler.ariaSetSize()`) for `aria-setsize`. */
|
|
2844
|
+
setSize: number;
|
|
2845
|
+
}
|
|
2846
|
+
/** Internal real-row context: the loaded item at this window position. */
|
|
2847
|
+
interface CngxRecyclerRowRealContext<T> {
|
|
2848
|
+
$implicit: T;
|
|
2849
|
+
cngxRecyclerRow: T;
|
|
2850
|
+
}
|
|
2851
|
+
/**
|
|
2852
|
+
* App-wide default placeholder template for `*cngxRecyclerRow`. Middle rung of
|
|
2853
|
+
* the cascade: microsyntax `placeholder:` template wins over this, and this wins
|
|
2854
|
+
* over the built-in imperative `<li>` default. Defaults to `null` (imperative
|
|
2855
|
+
* default applies).
|
|
2856
|
+
*
|
|
2857
|
+
* @category common/data/recycler
|
|
2858
|
+
*/
|
|
2859
|
+
declare const CNGX_RECYCLER_PLACEHOLDER_ROW: InjectionToken<TemplateRef<CngxRecyclerRowContext> | null>;
|
|
2860
|
+
/**
|
|
2861
|
+
* Provides an app-wide default placeholder template for every `*cngxRecyclerRow`
|
|
2862
|
+
* that supplies no `placeholder:` template of its own.
|
|
2863
|
+
*
|
|
2864
|
+
* @category common/data/recycler
|
|
2865
|
+
*/
|
|
2866
|
+
declare function provideRecyclerPlaceholderRow(template: TemplateRef<CngxRecyclerRowContext>): Provider;
|
|
2867
|
+
/**
|
|
2868
|
+
* Per-window-position render switch for a sparse/windowed recycler: renders the
|
|
2869
|
+
* consumer's real-row template when the sliced item is defined, and a
|
|
2870
|
+
* placeholder branch when the item is still `undefined` (loaded window, data
|
|
2871
|
+
* not yet resolved).
|
|
2872
|
+
*
|
|
2873
|
+
* Mirrors the `*cngxAsync` structural-directive shape (own `TemplateRef` +
|
|
2874
|
+
* microsyntax alternate template + `ngTemplateContextGuard`). The switch axis is
|
|
2875
|
+
* data availability, not async status, so the two are siblings, not the same
|
|
2876
|
+
* class. Unlike `*cngxAsync` (which clears on every switch) the real-row view is
|
|
2877
|
+
* cached and re-attached across a placeholder detour, so a
|
|
2878
|
+
* defined -> undefined -> defined flip never remounts the expensive real row.
|
|
2879
|
+
*
|
|
2880
|
+
* The placeholder branch resolves through a 3-stage cascade: the microsyntax
|
|
2881
|
+
* `placeholder:` template, then {@link CNGX_RECYCLER_PLACEHOLDER_ROW}, then a
|
|
2882
|
+
* built-in imperative `<li>` default. The default assumes a `<ul>`/`<li>` list;
|
|
2883
|
+
* a non-`<li>` container (`<div role="list">`) supplies a `placeholder:`
|
|
2884
|
+
* template or the config token instead.
|
|
2885
|
+
*
|
|
2886
|
+
* The two placeholder layers are orthogonal and non-overlapping by
|
|
2887
|
+
* construction: {@link CngxRecyclerPlaceholder} paints a decorative background
|
|
2888
|
+
* on the offset spacers (indices outside the rendered window), while this
|
|
2889
|
+
* directive fills holes inside the window whose item is still `undefined`.
|
|
2890
|
+
*
|
|
2891
|
+
* ### Windowed list with the built-in placeholder row
|
|
2892
|
+
* ```html
|
|
2893
|
+
* <ul>
|
|
2894
|
+
* @for (item of visibleItems(); track item?.id ?? ('ph:' + (recycler.start() + $index)); let i = $index) {
|
|
2895
|
+
* <li *cngxRecyclerRow="item; index: recycler.start() + i; recycler: recycler; let row">
|
|
2896
|
+
* {{ row?.name }}
|
|
2897
|
+
* </li>
|
|
2898
|
+
* }
|
|
2899
|
+
* </ul>
|
|
2900
|
+
* ```
|
|
2901
|
+
*
|
|
2902
|
+
* ### Custom placeholder template
|
|
2903
|
+
* ```html
|
|
2904
|
+
* <ul>
|
|
2905
|
+
* @for (item of visibleItems(); track item?.id ?? ('ph:' + (recycler.start() + $index)); let i = $index) {
|
|
2906
|
+
* <li *cngxRecyclerRow="item; index: recycler.start() + i; recycler: recycler; placeholder: ph; let row">
|
|
2907
|
+
* {{ row?.name }}
|
|
2908
|
+
* </li>
|
|
2909
|
+
* }
|
|
2910
|
+
* <ng-template #ph let-index let-setSize="setSize">
|
|
2911
|
+
* <li role="listitem" aria-busy="true" [attr.aria-posinset]="index + 1" [attr.aria-setsize]="setSize">
|
|
2912
|
+
* Loading row {{ index + 1 }}
|
|
2913
|
+
* </li>
|
|
2914
|
+
* </ng-template>
|
|
2915
|
+
* </ul>
|
|
2916
|
+
* ```
|
|
2917
|
+
*
|
|
2918
|
+
* @category common/data/recycler
|
|
2919
|
+
* @docsKind primary
|
|
2920
|
+
* @wcag AA
|
|
2921
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-row.directive.ts
|
|
2922
|
+
* @since 0.1.0
|
|
2923
|
+
* @relatedTo injectRecycler, CngxRecyclerPlaceholder, CngxVirtualItem, CngxMeasure
|
|
2924
|
+
* <example-url>http://localhost:4200/#/common/data/recycler/windowed-data-availability</example-url>
|
|
2925
|
+
*/
|
|
2926
|
+
declare class CngxRecyclerRow<T> {
|
|
2927
|
+
private readonly vcr;
|
|
2928
|
+
private readonly rowTpl;
|
|
2929
|
+
private readonly renderer;
|
|
2930
|
+
private readonly configTpl;
|
|
2931
|
+
/** The sliced item at this window position. `undefined` selects the placeholder branch. */
|
|
2932
|
+
readonly cngxRecyclerRow: _angular_core.InputSignal<T | undefined>;
|
|
2933
|
+
/** Absolute dataset index of this slot (`recycler.start() + $index`). */
|
|
2934
|
+
readonly cngxRecyclerRowIndex: _angular_core.InputSignal<number>;
|
|
2935
|
+
/** The recycler driving the window, read for `rowSizeHint` (-> `top`) and `ariaSetSize`. */
|
|
2936
|
+
readonly cngxRecyclerRowRecycler: _angular_core.InputSignal<CngxRecycler>;
|
|
2937
|
+
/** Optional placeholder template for the `undefined` branch. Context: {@link CngxRecyclerRowContext}. */
|
|
2938
|
+
readonly cngxRecyclerRowPlaceholder: _angular_core.InputSignal<TemplateRef<CngxRecyclerRowContext> | undefined>;
|
|
2939
|
+
private currentBranch;
|
|
2940
|
+
private rowViewRef;
|
|
2941
|
+
private placeholderViewRef;
|
|
2942
|
+
private defaultEl;
|
|
2943
|
+
constructor();
|
|
2944
|
+
private showRow;
|
|
2945
|
+
private showPlaceholder;
|
|
2946
|
+
private setRowContext;
|
|
2947
|
+
private detachRow;
|
|
2948
|
+
private teardownPlaceholder;
|
|
2949
|
+
private renderPlaceholder;
|
|
2950
|
+
private refreshPlaceholder;
|
|
2951
|
+
private stampDefault;
|
|
2952
|
+
private applyDefaultAttrs;
|
|
2953
|
+
private removeDefault;
|
|
2954
|
+
private buildPlaceholderContext;
|
|
2955
|
+
/** Narrows the directive's own template context to the loaded item type. */
|
|
2956
|
+
static ngTemplateContextGuard<T>(_dir: CngxRecyclerRow<T>, _ctx: unknown): _ctx is CngxRecyclerRowRealContext<T>;
|
|
2957
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxRecyclerRow<any>, never>;
|
|
2958
|
+
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>;
|
|
2959
|
+
}
|
|
2960
|
+
|
|
2500
2961
|
/**
|
|
2501
2962
|
* Convenience component that renders the `aria-live="polite"` region
|
|
2502
2963
|
* for recycler SR announcements. Eliminates manual boilerplate.
|
|
@@ -2618,8 +3079,8 @@ interface CngxCommitHandle {
|
|
|
2618
3079
|
readonly cancel: () => void;
|
|
2619
3080
|
}
|
|
2620
3081
|
/**
|
|
2621
|
-
* Action runner contract. Receives the controller's success/error
|
|
2622
|
-
* routes and returns a cancel handle. The runner is opaque to the
|
|
3082
|
+
* Action runner contract. Receives the controller's success / error /
|
|
3083
|
+
* refused routes and returns a cancel handle. The runner is opaque to the
|
|
2623
3084
|
* controller - it can wrap any async source (Observable, Promise,
|
|
2624
3085
|
* sync value) and any cancellation primitive.
|
|
2625
3086
|
*
|
|
@@ -2628,22 +3089,31 @@ interface CngxCommitHandle {
|
|
|
2628
3089
|
* runner adapts a `CngxStepperCommitAction`); the controller has no
|
|
2629
3090
|
* knowledge of the variant-specific action shape.
|
|
2630
3091
|
*
|
|
3092
|
+
* `onRefused` is for an action that declined on purpose (a `false`
|
|
3093
|
+
* answer): nothing changed, so the controller stores no error. A runner
|
|
3094
|
+
* whose action shape has no refusal (the select family) never calls it.
|
|
3095
|
+
*
|
|
2631
3096
|
* @category common/data/commit
|
|
2632
3097
|
*/
|
|
2633
3098
|
type CngxCommitRunner<T> = (handlers: {
|
|
2634
3099
|
readonly onSuccess: (committed: T | undefined) => void;
|
|
2635
3100
|
readonly onError: (err: unknown) => void;
|
|
3101
|
+
readonly onRefused: () => void;
|
|
2636
3102
|
}) => CngxCommitHandle;
|
|
2637
3103
|
/**
|
|
2638
3104
|
* Outcome handlers passed to `controller.begin(...)`. The controller
|
|
2639
|
-
* invokes exactly one of `onSuccess` / `onError`
|
|
2640
|
-
* (unless the commit is superseded, in which case
|
|
3105
|
+
* invokes exactly one of `onSuccess` / `onError` / `onRefused` per
|
|
3106
|
+
* commit lifecycle (unless the commit is superseded, in which case none
|
|
3107
|
+
* fires). `onRefused` is optional because only families whose action can
|
|
3108
|
+
* refuse (the stepper) route it; when it is omitted a refusal still
|
|
3109
|
+
* settles the state slot.
|
|
2641
3110
|
*
|
|
2642
3111
|
* @category common/data/commit
|
|
2643
3112
|
*/
|
|
2644
3113
|
interface CngxCommitBeginHandlers<T> {
|
|
2645
3114
|
readonly onSuccess: (committed: T | undefined) => void;
|
|
2646
3115
|
readonly onError: (err: unknown, previous: T | undefined) => void;
|
|
3116
|
+
readonly onRefused?: (previous: T | undefined) => void;
|
|
2647
3117
|
}
|
|
2648
3118
|
/**
|
|
2649
3119
|
* Encapsulated state machine for the async-commit lifecycle shared by
|
|
@@ -2657,6 +3127,15 @@ interface CngxCommitBeginHandlers<T> {
|
|
|
2657
3127
|
* - the "intended value" signal that drives the pending-spinner on
|
|
2658
3128
|
* the specific row / step the user just clicked.
|
|
2659
3129
|
*
|
|
3130
|
+
* Three outcomes settle a commit. Success stores the committed value.
|
|
3131
|
+
* Failure stores the error (`'error'`). A refusal - the action answered
|
|
3132
|
+
* `false` - goes back to `'idle'` through `setIdle()`: the error and the
|
|
3133
|
+
* intended value are cleared, while `data`, `lastUpdated` and
|
|
3134
|
+
* `isFirstLoad()` keep what the last success left, because a refusal
|
|
3135
|
+
* changed nothing. A custom controller (`CNGX_COMMIT_CONTROLLER_FACTORY`)
|
|
3136
|
+
* must hand the runner an `onRefused` route and forward it to
|
|
3137
|
+
* `handlers.onRefused`.
|
|
3138
|
+
*
|
|
2660
3139
|
* The controller is intentionally **not** an Angular service or
|
|
2661
3140
|
* provider. It's a plain factory so it works in any injection context
|
|
2662
3141
|
* (including outside Angular, for headless tests).
|
|
@@ -2683,8 +3162,8 @@ interface CngxCommitController<T> {
|
|
|
2683
3162
|
* @param runner variant-specific action runner (closes over the
|
|
2684
3163
|
* action and the intended value)
|
|
2685
3164
|
* @param intended the value the user clicked
|
|
2686
|
-
* @param previous the value to roll back to on error
|
|
2687
|
-
* @param handlers success/error routes - the controller only
|
|
3165
|
+
* @param previous the value to roll back to on error or refusal
|
|
3166
|
+
* @param handlers success/error/refused routes - the controller only
|
|
2688
3167
|
* updates its own state and calls these; it does
|
|
2689
3168
|
* NOT touch external value signals, panel open
|
|
2690
3169
|
* state, or component outputs.
|
|
@@ -2694,8 +3173,16 @@ interface CngxCommitController<T> {
|
|
|
2694
3173
|
* Abort the currently in-flight commit without firing callbacks.
|
|
2695
3174
|
* Use when the host component is destroyed or the commit-action
|
|
2696
3175
|
* input changes mid-flight.
|
|
2697
|
-
|
|
2698
|
-
|
|
3176
|
+
*
|
|
3177
|
+
* By default the state slot keeps its current status (a destroyed
|
|
3178
|
+
* host never reads it again). Pass `settle: true` when the surface
|
|
3179
|
+
* lives on - an explicit back-navigation or reset that supersedes a
|
|
3180
|
+
* pending commit must return `state` to `'idle'`, or `busy` latches
|
|
3181
|
+
* true forever.
|
|
3182
|
+
*/
|
|
3183
|
+
cancel(options?: {
|
|
3184
|
+
readonly settle?: boolean;
|
|
3185
|
+
}): void;
|
|
2699
3186
|
}
|
|
2700
3187
|
/**
|
|
2701
3188
|
* Factory for the commit controller.
|
|
@@ -2708,6 +3195,93 @@ interface CngxCommitController<T> {
|
|
|
2708
3195
|
*/
|
|
2709
3196
|
declare function createCommitController<T>(): CngxCommitController<T>;
|
|
2710
3197
|
|
|
3198
|
+
/**
|
|
3199
|
+
* How a commit-gated transition (a step change, a tab switch) ended when
|
|
3200
|
+
* it did not land.
|
|
3201
|
+
*
|
|
3202
|
+
* Modelled on the router: a guard answering `false` cancels a navigation
|
|
3203
|
+
* (`NavigationCancel`), only a throw is a `NavigationError`. Here a
|
|
3204
|
+
* `commitAction` answering `false` is `'refused'` - the action decided to
|
|
3205
|
+
* keep the user where they are, nothing failed and no error is stored -
|
|
3206
|
+
* while a throw, a rejected promise or an erroring observable is
|
|
3207
|
+
* `'failed'`. Both roll the transition back; only `'failed'` leaves the
|
|
3208
|
+
* commit state at `'error'`.
|
|
3209
|
+
*
|
|
3210
|
+
* `index` is the target the transition was refused or failed for (the
|
|
3211
|
+
* position the user did not reach). `sequence` is a per-host counter bumped exactly
|
|
3212
|
+
* once per settled refusal or failure, so two identical outcomes in a row
|
|
3213
|
+
* are still two events; a host that only moves the index (a closed tab
|
|
3214
|
+
* before the origin) copies the sequence instead of bumping it, so
|
|
3215
|
+
* nothing downstream treats the shift as a new outcome.
|
|
3216
|
+
*
|
|
3217
|
+
* @category common/data/commit
|
|
3218
|
+
*/
|
|
3219
|
+
interface CngxTransitionOutcome {
|
|
3220
|
+
readonly kind: 'refused' | 'failed';
|
|
3221
|
+
readonly index: number;
|
|
3222
|
+
readonly sequence: number;
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
/**
|
|
3226
|
+
* Options for {@link createRefusedPhrase}. Every field is a plain
|
|
3227
|
+
* reactive read, so the factory stays independent of any host type.
|
|
3228
|
+
*
|
|
3229
|
+
* @category common/data/commit
|
|
3230
|
+
* @since 0.1.0
|
|
3231
|
+
*/
|
|
3232
|
+
interface CngxRefusedPhraseOptions {
|
|
3233
|
+
/** The host's last refused or failed outcome, `undefined` once cleared. */
|
|
3234
|
+
readonly outcome: () => CngxTransitionOutcome | undefined;
|
|
3235
|
+
/** Commit status of the host; any change spends an armed phrase. */
|
|
3236
|
+
readonly status: () => unknown;
|
|
3237
|
+
/** Active index of the host; any move spends an armed phrase. */
|
|
3238
|
+
readonly activeIndex: () => number | undefined;
|
|
3239
|
+
/**
|
|
3240
|
+
* Copy voiced for a new refusal. Read untracked at arm time only, so a
|
|
3241
|
+
* language switch never re-speaks a phrase that was already voiced.
|
|
3242
|
+
*/
|
|
3243
|
+
readonly copy: () => string;
|
|
3244
|
+
/**
|
|
3245
|
+
* Optional extra expiry trigger: a changed value (compared with
|
|
3246
|
+
* `!==`) spends an armed phrase, e.g. a newer close announcement that
|
|
3247
|
+
* must not be masked by a stale refusal.
|
|
3248
|
+
*/
|
|
3249
|
+
readonly extraSpend?: () => unknown;
|
|
3250
|
+
}
|
|
3251
|
+
/**
|
|
3252
|
+
* Live-region phrase for a refused commit-gated transition (a step
|
|
3253
|
+
* change or tab switch whose `commitAction` answered `false`).
|
|
3254
|
+
*
|
|
3255
|
+
* A refusal settles the commit status back to `'idle'`, so no status
|
|
3256
|
+
* edge can voice it. This phrase arms on each new refused outcome (a new
|
|
3257
|
+
* `sequence`) and is spent by the next commit status change, an
|
|
3258
|
+
* active-index move, a cleared outcome or, when given, a changed
|
|
3259
|
+
* `extraSpend` value. A failed outcome never arms it. Arm wins over
|
|
3260
|
+
* spend in the same flush, so an optimistic rollback that moves the
|
|
3261
|
+
* active index still voices the refusal.
|
|
3262
|
+
*
|
|
3263
|
+
* Built on {@link createAnnouncementPhrase}: fully derived, no `effect`.
|
|
3264
|
+
* The same eager-read caveat applies - read the phrase before branching
|
|
3265
|
+
* on another arm of the live announcement, otherwise a spend transition
|
|
3266
|
+
* can be skipped.
|
|
3267
|
+
*
|
|
3268
|
+
* ```ts
|
|
3269
|
+
* const refusedPhrase = createRefusedPhrase({
|
|
3270
|
+
* outcome: () => presenter.lastOutcome(),
|
|
3271
|
+
* status: () => presenter.commitTransition.current(),
|
|
3272
|
+
* activeIndex: () => presenter.activeIndex(),
|
|
3273
|
+
* copy: () => i18n().commitRefusedGeneric,
|
|
3274
|
+
* });
|
|
3275
|
+
* ```
|
|
3276
|
+
*
|
|
3277
|
+
* @category common/data/commit
|
|
3278
|
+
* @wcag AA
|
|
3279
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/commit/refused-phrase.ts
|
|
3280
|
+
* @since 0.1.0
|
|
3281
|
+
* @relatedTo CngxTransitionOutcome, createAnnouncementPhrase
|
|
3282
|
+
*/
|
|
3283
|
+
declare function createRefusedPhrase(options: CngxRefusedPhraseOptions): Signal<string>;
|
|
3284
|
+
|
|
2711
3285
|
/**
|
|
2712
3286
|
* Factory signature for producing {@link CngxCommitController}
|
|
2713
3287
|
* instances. Consumers override the DI token
|
|
@@ -2869,5 +3443,82 @@ interface CngxMaterialBidirectionalSyncHandle {
|
|
|
2869
3443
|
*/
|
|
2870
3444
|
declare function createMaterialBidirectionalSync(opts: CngxMaterialBidirectionalSyncOptions): CngxMaterialBidirectionalSyncHandle;
|
|
2871
3445
|
|
|
2872
|
-
|
|
2873
|
-
|
|
3446
|
+
/**
|
|
3447
|
+
* The kpi section of a {@link CngxLanguagePack}: the copy of the KPI atoms
|
|
3448
|
+
* `CngxMetric`, `CngxDelta`, `CngxTrend` and `CngxGoal`. Magnitudes reach the
|
|
3449
|
+
* messages already formatted for the app locale.
|
|
3450
|
+
*
|
|
3451
|
+
* @category common/data/i18n
|
|
3452
|
+
* @since 0.1.0
|
|
3453
|
+
* @relatedTo CNGX_KPI_I18N
|
|
3454
|
+
*/
|
|
3455
|
+
interface CngxKpiLanguageSection {
|
|
3456
|
+
/** `{value}`, `{sentiment}`: the accessible name of a delta. */
|
|
3457
|
+
readonly deltaLabel: CngxMessage;
|
|
3458
|
+
readonly deltaImproved: string;
|
|
3459
|
+
readonly deltaDeclined: string;
|
|
3460
|
+
readonly deltaUnchanged: string;
|
|
3461
|
+
/** `{value}`, `{direction}`: the accessible name of a trend. */
|
|
3462
|
+
readonly trendLabel: CngxMessage;
|
|
3463
|
+
readonly trendUp: string;
|
|
3464
|
+
readonly trendDown: string;
|
|
3465
|
+
readonly trendFlat: string;
|
|
3466
|
+
/** `{now}`, `{max}`: a goal's `aria-valuetext`. */
|
|
3467
|
+
readonly goalValueText: CngxMessage;
|
|
3468
|
+
/** `{value}`, `{unit}`: a metric's value and unit, in reading order. */
|
|
3469
|
+
readonly metricValueWithUnit: string;
|
|
3470
|
+
/** Shown in place of a metric without a value. */
|
|
3471
|
+
readonly metricPlaceholder: string;
|
|
3472
|
+
/** Accessible name of a metric without a value. */
|
|
3473
|
+
readonly metricNoValue: string;
|
|
3474
|
+
}
|
|
3475
|
+
/**
|
|
3476
|
+
* The English kpi section: the single source of the KPI atoms' English copy.
|
|
3477
|
+
* `CNGX_KPI_I18N` defaults to it.
|
|
3478
|
+
*
|
|
3479
|
+
* @category common/data/i18n
|
|
3480
|
+
* @since 0.1.0
|
|
3481
|
+
* @relatedTo CNGX_KPI_I18N
|
|
3482
|
+
*/
|
|
3483
|
+
declare const CNGX_KPI_LANGUAGE_EN: CngxKpiLanguageSection;
|
|
3484
|
+
declare module '@cngx/core/i18n' {
|
|
3485
|
+
interface CngxLanguagePack {
|
|
3486
|
+
readonly kpi: CngxKpiLanguageSection;
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
|
|
3490
|
+
/**
|
|
3491
|
+
* The recycler section of a {@link CngxLanguagePack}: the screen-reader
|
|
3492
|
+
* announcements of a virtualised list.
|
|
3493
|
+
*
|
|
3494
|
+
* @category common/data/i18n
|
|
3495
|
+
* @since 0.1.0
|
|
3496
|
+
* @relatedTo CNGX_RECYCLER_I18N
|
|
3497
|
+
*/
|
|
3498
|
+
interface CngxRecyclerLanguageSection {
|
|
3499
|
+
/** Plural on `{count}` (new items), with `{total}`: announced after a load. */
|
|
3500
|
+
readonly loaded: CngxMessage;
|
|
3501
|
+
/** Plural on `{count}`: announced when filter or search results change. */
|
|
3502
|
+
readonly filtered: CngxMessage;
|
|
3503
|
+
/** Announced when the list becomes empty. */
|
|
3504
|
+
readonly empty: string;
|
|
3505
|
+
/** Announced when loading fails. */
|
|
3506
|
+
readonly error: string;
|
|
3507
|
+
}
|
|
3508
|
+
/**
|
|
3509
|
+
* The English recycler section: the single source of the recycler's English
|
|
3510
|
+
* copy. `CNGX_RECYCLER_I18N` defaults to it.
|
|
3511
|
+
*
|
|
3512
|
+
* @category common/data/i18n
|
|
3513
|
+
* @since 0.1.0
|
|
3514
|
+
* @relatedTo CNGX_RECYCLER_I18N
|
|
3515
|
+
*/
|
|
3516
|
+
declare const CNGX_RECYCLER_LANGUAGE_EN: CngxRecyclerLanguageSection;
|
|
3517
|
+
declare module '@cngx/core/i18n' {
|
|
3518
|
+
interface CngxLanguagePack {
|
|
3519
|
+
readonly recycler: CngxRecyclerLanguageSection;
|
|
3520
|
+
}
|
|
3521
|
+
}
|
|
3522
|
+
|
|
3523
|
+
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, createRefusedPhrase, createSortHeaderState, fromHttpResource, fromResource, injectAsyncRegistry, injectAsyncState, injectDataSource, injectKpiI18n, injectLatencyProbe, injectRecycler, injectSmartDataSource, provideAsyncHttpObservability, provideAsyncRegistry, provideKpiI18n, provideRecyclerI18n, provideRecyclerPlaceholderRow, resolveAsyncView, tapAsyncProgress, tapAsyncState, tapHttpAsyncState, withAsyncLabel, withAsyncSkip, withKpiI18nLabels, withRecyclerI18nLabels };
|
|
3524
|
+
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, CngxRefusedPhraseOptions, CngxSmartDataSourceOptions, CngxStatRegistry, CngxStatSlotKind, CngxTransitionOutcome, CreateAsyncStateOptions, DeltaDirection, DeltaMode, DeltaPolarity, DeltaSentiment, InjectAsyncStateOptions, ManualAsyncState, MutableAsyncState, ReactiveAsyncState, RecyclerConfig, RecyclerI18n, SortEntry, SortHeaderState };
|