@cngx/common 0.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/a11y/README.md +77 -0
  4. package/card/README.md +79 -0
  5. package/chart/README.md +31 -0
  6. package/data/README.md +883 -0
  7. package/dialog/README.md +84 -0
  8. package/display/README.md +30 -0
  9. package/fesm2022/cngx-common-a11y.mjs +1260 -0
  10. package/fesm2022/cngx-common-a11y.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +765 -0
  12. package/fesm2022/cngx-common-card.mjs.map +1 -0
  13. package/fesm2022/cngx-common-chart.mjs +2943 -0
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -0
  15. package/fesm2022/cngx-common-data.mjs +2886 -0
  16. package/fesm2022/cngx-common-data.mjs.map +1 -0
  17. package/fesm2022/cngx-common-dialog.mjs +1366 -0
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -0
  19. package/fesm2022/cngx-common-display.mjs +1603 -0
  20. package/fesm2022/cngx-common-display.mjs.map +1 -0
  21. package/fesm2022/cngx-common-interactive.mjs +8185 -0
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -0
  23. package/fesm2022/cngx-common-layout.mjs +1335 -0
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -0
  25. package/fesm2022/cngx-common-popover.mjs +1200 -0
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -0
  27. package/fesm2022/cngx-common-stepper.mjs +1350 -0
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -0
  29. package/fesm2022/cngx-common-tabs.mjs +1551 -0
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -0
  31. package/fesm2022/cngx-common.mjs +34 -0
  32. package/fesm2022/cngx-common.mjs.map +1 -0
  33. package/interactive/README.md +211 -0
  34. package/layout/README.md +117 -0
  35. package/package.json +100 -0
  36. package/popover/README.md +218 -0
  37. package/stepper/README.md +102 -0
  38. package/tabs/README.md +32 -0
  39. package/types/cngx-common-a11y.d.ts +616 -0
  40. package/types/cngx-common-card.d.ts +413 -0
  41. package/types/cngx-common-chart.d.ts +1081 -0
  42. package/types/cngx-common-data.d.ts +1460 -0
  43. package/types/cngx-common-dialog.d.ts +772 -0
  44. package/types/cngx-common-display.d.ts +1136 -0
  45. package/types/cngx-common-interactive.d.ts +5013 -0
  46. package/types/cngx-common-layout.d.ts +737 -0
  47. package/types/cngx-common-popover.d.ts +520 -0
  48. package/types/cngx-common-stepper.d.ts +982 -0
  49. package/types/cngx-common-tabs.d.ts +1237 -0
  50. package/types/cngx-common.d.ts +13 -0
@@ -0,0 +1,1460 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { TemplateRef, Signal, InjectionToken, ElementRef, Injector, DestroyRef } from '@angular/core';
3
+ import { CngxAsyncState, AsyncStatus } from '@cngx/core/utils';
4
+ import { DataSource } from '@angular/cdk/collections';
5
+ import { Observable } from 'rxjs';
6
+ import { CngxRovingTabindex, CngxActiveDescendant } from '@cngx/common/a11y';
7
+
8
+ /**
9
+ * A single sort entry: the active field key and its direction.
10
+ */
11
+ interface SortEntry {
12
+ active: string;
13
+ direction: 'asc' | 'desc';
14
+ }
15
+ /**
16
+ * Atom directive that tracks sort state (active field + direction).
17
+ *
18
+ * Supports both **uncontrolled** (internal state) and **controlled** modes.
19
+ * In controlled mode the `cngxSortActive` / `cngxSortDirection` inputs take
20
+ * precedence over the internal state — pair with `sortChange` to keep them
21
+ * in sync.
22
+ *
23
+ * When `multiSort` is `true`, holding **Shift** while clicking a sort header
24
+ * adds it as a secondary (tertiary, …) sort key instead of replacing the
25
+ * primary one. Shift-clicking an active column cycles it asc → desc → removed.
26
+ * Multi-sort state is always uncontrolled; use `sortsChange` to read it.
27
+ *
28
+ * Consumer connects this to a table or list via a `computed()` — nothing is
29
+ * injected automatically.
30
+ */
31
+ declare class CngxSort {
32
+ /** Controlled active column. When bound, takes precedence over internal state (single-sort only). */
33
+ readonly activeInput: _angular_core.InputSignal<string | undefined>;
34
+ /** Controlled direction. When bound, takes precedence over internal state (single-sort only). */
35
+ readonly directionInput: _angular_core.InputSignal<"asc" | "desc" | undefined>;
36
+ /**
37
+ * When `true`, Shift+click on a sort header adds it to the sort stack instead of
38
+ * replacing the current sort.
39
+ */
40
+ readonly multiSort: _angular_core.InputSignal<boolean>;
41
+ private readonly sortsState;
42
+ /** The active sort column of the primary entry (controlled takes precedence in single-sort mode). */
43
+ readonly active: _angular_core.Signal<string>;
44
+ /** The active sort direction of the primary entry (controlled takes precedence in single-sort mode). */
45
+ readonly direction: _angular_core.Signal<"asc" | "desc">;
46
+ /**
47
+ * The primary sort state, or `null` when no sort is active.
48
+ * In multi-sort mode this is the first entry in `sorts`.
49
+ */
50
+ readonly sort: _angular_core.Signal<{
51
+ active: string;
52
+ direction: "asc" | "desc";
53
+ } | null>;
54
+ /**
55
+ * All active sort entries in priority order.
56
+ * Contains at most one entry when additive mode has not been used.
57
+ */
58
+ readonly sorts: _angular_core.Signal<SortEntry[]>;
59
+ /** `true` when at least one sort is active. */
60
+ readonly isActive: _angular_core.Signal<boolean>;
61
+ /** Emitted when the primary sort state changes. Emits `undefined` on clear. */
62
+ readonly sortChange: _angular_core.OutputEmitterRef<SortEntry | undefined>;
63
+ /**
64
+ * Emitted whenever the sort stack changes (including removals and full clears).
65
+ * Always reflects the full `sorts` array at the time of emission.
66
+ */
67
+ readonly sortsChange: _angular_core.OutputEmitterRef<SortEntry[]>;
68
+ /**
69
+ * Sets or toggles the sort for `field`.
70
+ *
71
+ * **`additive = false`** (default, plain click):
72
+ * - Same field → toggle direction (asc → desc → asc)
73
+ * - Different field → replace stack with `{ field, asc }`
74
+ *
75
+ * **`additive = true`** (Shift+click when `multiSort` is enabled on the header):
76
+ * - Field not in stack → append as asc
77
+ * - Field in stack as asc → change to desc
78
+ * - Field in stack as desc → remove from stack
79
+ */
80
+ setSort(field: string, additive?: boolean): void;
81
+ /** Clears all active sorts. Emits both `sortChange(undefined)` and `sortsChange([])`. */
82
+ clear(): void;
83
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxSort, never>;
84
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxSort, "[cngxSort]", ["cngxSort"], { "activeInput": { "alias": "cngxSortActive"; "required": false; "isSignal": true; }; "directionInput": { "alias": "cngxSortDirection"; "required": false; "isSignal": true; }; "multiSort": { "alias": "multiSort"; "required": false; "isSignal": true; }; }, { "sortChange": "sortChange"; "sortsChange": "sortsChange"; }, never, never, true, never>;
85
+ }
86
+
87
+ /**
88
+ * Molecule directive for sort-header elements.
89
+ *
90
+ * Apply to any clickable header element. Consumer provides an explicit
91
+ * `[cngxSortRef]` binding — no ancestor injection, no hidden wiring.
92
+ *
93
+ * In multi-sort mode, Shift+click adds this column to the sort stack.
94
+ * The `priority()` signal returns the 1-based position in the stack
95
+ * (0 when not active), useful for showing sort-order badges.
96
+ *
97
+ * ```html
98
+ * <div cngxSort [multiSort]="true" #sort="cngxSort">
99
+ * <button cngxSortHeader="name" [cngxSortRef]="sort" #h="cngxSortHeader">
100
+ * Name
101
+ * @if (h.isActive()) {
102
+ * {{ h.isAsc() ? '↑' : '↓' }}
103
+ * @if (sort.multiSort()) { <span>{{ h.priority() }}</span> }
104
+ * }
105
+ * </button>
106
+ * </div>
107
+ * ```
108
+ */
109
+ declare class CngxSortHeader {
110
+ /** The field key this header cell represents. */
111
+ readonly field: _angular_core.InputSignal<string>;
112
+ /** Explicit reference to the owning `CngxSort`. */
113
+ readonly cngxSortRef: _angular_core.InputSignal<CngxSort>;
114
+ private readonly entry;
115
+ /** `true` when this column is part of the active sort (primary or secondary). */
116
+ readonly isActive: _angular_core.Signal<boolean>;
117
+ /** `true` when this column is active and sorted ascending. */
118
+ readonly isAsc: _angular_core.Signal<boolean>;
119
+ /** `true` when this column is active and sorted descending. */
120
+ readonly isDesc: _angular_core.Signal<boolean>;
121
+ /**
122
+ * 1-based position of this column in the sort stack.
123
+ * Returns `0` when the column is not part of the active sort.
124
+ * Only meaningful when `multiSort` is enabled on the owning `CngxSort`.
125
+ */
126
+ readonly priority: _angular_core.Signal<number>;
127
+ /** The `aria-sort` attribute value for the host element. */
128
+ readonly ariaSort: _angular_core.Signal<"ascending" | "descending" | null>;
129
+ protected handleSort(event?: MouseEvent): void;
130
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxSortHeader, never>;
131
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxSortHeader, "[cngxSortHeader]", ["cngxSortHeader"], { "field": { "alias": "cngxSortHeader"; "required": true; "isSignal": true; }; "cngxSortRef": { "alias": "cngxSortRef"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
132
+ }
133
+
134
+ /**
135
+ * Atom directive that holds one or more named filter predicates.
136
+ *
137
+ * Supports both **uncontrolled** (internal state) and **controlled** modes.
138
+ * In controlled mode the `cngxFilter` input takes precedence over the internal
139
+ * `'default'` predicate — pair with `filterChange` to keep it in sync.
140
+ *
141
+ * **Multi-filter** — use `addPredicate(key, fn)` / `removePredicate(key)` to
142
+ * maintain a named stack of predicates. All active predicates are **AND-combined**
143
+ * across keys: an item must pass every registered predicate to appear in results.
144
+ *
145
+ * AND vs OR — the directive enforces AND across dimensions (keys). OR logic
146
+ * within a single dimension stays inside the predicate function itself:
147
+ *
148
+ * ```typescript
149
+ * // AND across dimensions: location AND role must both match
150
+ * filter.addPredicate('location', p => selectedLocations.has(p.location));
151
+ * filter.addPredicate('role', p => selectedRoles.has(p.role));
152
+ *
153
+ * // OR within a dimension: London OR Rome — just put a Set inside one predicate
154
+ * filter.addPredicate('location', p => selectedLocations.has(p.location));
155
+ * ```
156
+ *
157
+ * `setPredicate` / `clear` operate on the `'default'` key and remain fully
158
+ * backward-compatible with single-predicate usage.
159
+ *
160
+ * Consumer connects this to a list via a `computed()` — nothing is injected
161
+ * automatically.
162
+ *
163
+ * @typeParam T - The item type the predicate operates on.
164
+ */
165
+ declare class CngxFilter<T = unknown> {
166
+ /** Controlled predicate. When bound, takes precedence over the `'default'` internal predicate. */
167
+ readonly predicateInput: _angular_core.InputSignal<((value: T) => boolean) | null>;
168
+ private readonly predicatesState;
169
+ /**
170
+ * All active named predicates.
171
+ * Use `addPredicate` / `removePredicate` to manage this map.
172
+ */
173
+ readonly predicates: _angular_core.Signal<Map<string, (value: T) => boolean>>;
174
+ /** Number of active named predicates (controlled input not counted). */
175
+ readonly activeCount: _angular_core.Signal<number>;
176
+ /**
177
+ * The combined predicate — AND of all active named predicates plus the
178
+ * controlled input (when bound). Returns `null` when nothing is active.
179
+ */
180
+ readonly predicate: _angular_core.Signal<((value: T) => boolean) | null>;
181
+ /** `true` when at least one predicate is active. */
182
+ readonly isActive: _angular_core.Signal<boolean>;
183
+ /** Emitted whenever the `'default'` predicate changes (backward-compat single-filter output). */
184
+ readonly filterChange: _angular_core.OutputEmitterRef<((value: T) => boolean) | null>;
185
+ /** Emitted whenever any named predicate is added or removed. */
186
+ readonly predicatesChange: _angular_core.OutputEmitterRef<Map<string, (value: T) => boolean>>;
187
+ /**
188
+ * Adds or replaces the named predicate `key`.
189
+ * Emits `predicatesChange` with the updated map.
190
+ */
191
+ addPredicate(key: string, fn: (value: T) => boolean): void;
192
+ /**
193
+ * Removes the named predicate `key` (no-op if not present).
194
+ * Emits `predicatesChange` with the updated map.
195
+ */
196
+ removePredicate(key: string): void;
197
+ /**
198
+ * Sets the `'default'` predicate and emits `filterChange`.
199
+ * Pass `null` to clear it (same as `clear()`).
200
+ */
201
+ setPredicate(fn: ((value: T) => boolean) | null): void;
202
+ /** Removes all named predicates and emits `filterChange` with `null`. */
203
+ clear(): void;
204
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFilter<any>, never>;
205
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxFilter<any>, "[cngxFilter]", ["cngxFilter"], { "predicateInput": { "alias": "cngxFilter"; "required": false; "isSignal": true; }; }, { "filterChange": "filterChange"; "predicatesChange": "predicatesChange"; }, never, never, true, never>;
206
+ }
207
+
208
+ /**
209
+ * Per-chip override slot context. Consumers project an
210
+ * `<ng-template cngxFilterChip let-option let-value="value" let-label="label">`
211
+ * to customize chip body decoration — icons, count badges, colour
212
+ * swatches, anything beyond the default text label.
213
+ *
214
+ * **Decoration-only semantics.** The bridge ALWAYS wraps each option
215
+ * in `<cngx-chip cngxChipInGroup [value]>` itself; the slot only
216
+ * customizes what renders INSIDE that wrapper. Consumers do NOT
217
+ * redeclare selection wiring — it is handled by the bridge so the
218
+ * projected content survives Angular's `*ngTemplateOutlet`
219
+ * lexical-injector semantics (the projected template injects against
220
+ * the consumer's component, NOT the bridge's inner
221
+ * `<cngx-multi-chip-group>`, so a consumer-supplied
222
+ * `cngxChipInGroup` would fail to resolve `CNGX_CHIP_GROUP_HOST`).
223
+ */
224
+ interface CngxFilterChipContext<TItem = unknown, TValue = unknown> {
225
+ readonly $implicit: TItem;
226
+ readonly option: TItem;
227
+ readonly value: TValue;
228
+ readonly label: string;
229
+ }
230
+ /**
231
+ * Template-slot directive overriding the default chip body inside
232
+ * `<cngx-filter-chips>`. Consumers attach
233
+ * `<ng-template cngxFilterChip>` to project decoration; the bridge
234
+ * wraps that decoration in `cngxChipInGroup`-bound chip wrappers
235
+ * automatically. Absence falls back to the default text-only label.
236
+ */
237
+ declare class CngxFilterChip<TItem = unknown, TValue = unknown> {
238
+ readonly template: TemplateRef<CngxFilterChipContext<TItem, TValue>>;
239
+ static ngTemplateContextGuard<TItem, TValue>(_dir: CngxFilterChip<TItem, TValue>, _ctx: unknown): _ctx is CngxFilterChipContext<TItem, TValue>;
240
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFilterChip<any, any>, never>;
241
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxFilterChip<any, any>, "ng-template[cngxFilterChip]", never, {}, {}, never, never, true, never>;
242
+ }
243
+ /**
244
+ * Bridge that connects a multi-select chip strip to a `CngxFilter`
245
+ * predicate via Pillar-1 derivation — no `effect()` write-back, no
246
+ * manual sync. The bridge composes `<cngx-multi-chip-group>` for
247
+ * the visible chip strip and registers a single closure-style
248
+ * predicate on the parent `[filterRef]`. Chip toggles update
249
+ * `selectedValues`; the registered closure reads `selectedValues()`
250
+ * lazily on every invocation so downstream filtered consumers
251
+ * recompute without the bridge ever re-registering.
252
+ *
253
+ * Filter chips are inherently multi-select per
254
+ * `feedback_select_family_split`; a single-mode filter-chip pattern
255
+ * is intentionally out of scope. Consumers needing a single-select
256
+ * filter wire `<cngx-chip-group>` to a custom predicate themselves.
257
+ *
258
+ * **Sync contract — derivation, not effect.** The bridge calls
259
+ * `filterRef.addPredicate(filterKey, predicateFn)` EXACTLY ONCE
260
+ * during mount (in `afterNextRender`, because `input.required()`
261
+ * cannot be read from the constructor body). `predicateFn` is a
262
+ * closure that reads `this.selectedValues()` and
263
+ * `this.optionValueFn()` on every invocation. Because
264
+ * `CngxFilter.predicate` is itself a `computed()` consumed by
265
+ * downstream filtered lists, each item-evaluation flows through
266
+ * `selectedValues()` in the consumer's reactive context — chip
267
+ * toggles propagate without any `effect()` writing back into the
268
+ * filter.
269
+ *
270
+ * **Empty-selection semantics.** When `selectedValues()` is `[]`,
271
+ * the closure returns `true` for every item — equivalent to "no
272
+ * filter applied". The bridge deliberately does NOT call
273
+ * `removePredicate` on empty selection: leaving the predicate
274
+ * registered with a constant-`true` short-circuit is cheaper than
275
+ * re-registering on every empty/non-empty boundary, and keeps the
276
+ * predicate-stack stable (no `predicatesChange` emission churn).
277
+ *
278
+ * **Teardown.** `DestroyRef.onDestroy` calls `removePredicate` only
279
+ * when registration actually happened (`registered` flag) — guards
280
+ * against the case where the component is destroyed before
281
+ * `afterNextRender` fires. The destroy callback reads `filterRef`
282
+ * and `filterKey` lazily so a consumer that re-binds these between
283
+ * mount and unmount cleans the latest binding (per
284
+ * `reference_signal_architecture` memory-hygiene rule).
285
+ *
286
+ * ```html
287
+ * <cngx-filter-chips
288
+ * label="Tags"
289
+ * [options]="tagOptions"
290
+ * optionLabel="label"
291
+ * optionValue="id"
292
+ * [filterRef]="employees"
293
+ * filterKey="tags"
294
+ * />
295
+ *
296
+ * <ng-container cngxFilter #employees="cngxFilter">
297
+ * @for (emp of filteredEmployees(); track emp.id) {
298
+ * ...
299
+ * }
300
+ * </ng-container>
301
+ * ```
302
+ */
303
+ declare class CngxFilterChips<TItem = unknown, TValue = unknown> {
304
+ readonly label: _angular_core.InputSignal<string>;
305
+ readonly options: _angular_core.InputSignal<readonly TItem[]>;
306
+ readonly optionLabel: _angular_core.InputSignal<(item: TItem) => string>;
307
+ readonly optionValue: _angular_core.InputSignal<(item: TItem) => TValue>;
308
+ readonly filterRef: _angular_core.InputSignal<CngxFilter<TItem>>;
309
+ readonly filterKey: _angular_core.InputSignal<string>;
310
+ readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
311
+ /**
312
+ * Form-state surface forwarded transparently to the inner
313
+ * `<cngx-multi-chip-group>`. Each is a `model<boolean>` matching the
314
+ * inner shape so consumers can two-way bind with their own forms
315
+ * state without reaching past the bridge. Mirrors `CngxCheckboxGroup`
316
+ * / `CngxButtonToggleGroup` precedent.
317
+ */
318
+ readonly disabled: _angular_core.ModelSignal<boolean>;
319
+ readonly required: _angular_core.ModelSignal<boolean>;
320
+ readonly invalid: _angular_core.ModelSignal<boolean>;
321
+ readonly errorMessageId: _angular_core.InputSignal<string | null>;
322
+ readonly orientation: _angular_core.InputSignal<"horizontal" | "vertical">;
323
+ /**
324
+ * Membership key extractor for object-valued chip values. When
325
+ * `TValue` is an object (e.g. `{ id, label }` rather than a
326
+ * primitive id), this fn extracts a stable identity key so chip
327
+ * membership survives re-emissions with fresh references. Forwarded
328
+ * to the inner `<cngx-multi-chip-group>` AND used inside the
329
+ * predicate's `Object.is` comparison. Defaults to identity — works
330
+ * for primitive values.
331
+ */
332
+ readonly keyFn: _angular_core.InputSignal<(value: TValue) => unknown>;
333
+ /**
334
+ * Resolved consumer-supplied chip template. The query uses an
335
+ * instantiation expression (`CngxFilterChip<TItem, TValue>`) so the
336
+ * bridge's class generics propagate into the slot directive type;
337
+ * absent that propagation, `contentChild(CngxFilterChip)` returns
338
+ * `Signal<CngxFilterChip<unknown, unknown> | undefined>` and the
339
+ * `chipContext()` helper would have to widen on every call.
340
+ */
341
+ protected readonly chipTemplate: Signal<CngxFilterChip<TItem, TValue> | undefined>;
342
+ /**
343
+ * Build the slot context for a given chip option. `optionValue` is
344
+ * invoked here per option for the chip rendering pass; the predicate
345
+ * closure invokes it again per LIST item for membership filtering.
346
+ * Both invocations are necessary because option items (the chip
347
+ * pool) and filtered list items (the consumer's filtered data) are
348
+ * separate data paths — they happen to share a shape under the
349
+ * Phase-5 single-shape limitation, but the bridge cannot memoise
350
+ * across the two paths without conflating them. Consumers should
351
+ * keep `optionValue` cheap (typically a property lookup); a future
352
+ * `[itemValue]` input will separate the two extractors.
353
+ */
354
+ protected readonly chipContext: (option: TItem) => CngxFilterChipContext<TItem, TValue>;
355
+ /**
356
+ * Internal multi-select state driven by chip toggles. Exposed as
357
+ * a `model` so consumers may seed initial selection via
358
+ * `[(selectedValues)]` if they need to; usually the consumer leaves
359
+ * this internal and reads results via the parent
360
+ * `CngxFilter.predicate`.
361
+ */
362
+ readonly selectedValues: _angular_core.ModelSignal<TValue[]>;
363
+ private registered;
364
+ constructor();
365
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxFilterChips<any, any>, never>;
366
+ 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>;
367
+ }
368
+
369
+ /**
370
+ * Atom directive that tracks pagination state (current page index and page size).
371
+ *
372
+ * Supports both **uncontrolled** (internal state) and **controlled** modes.
373
+ * In controlled mode the `cngxPageIndex` / `cngxPageSize` inputs take precedence
374
+ * over internal state — pair with `pageChange` / `pageSizeChange` to keep them
375
+ * in sync.
376
+ *
377
+ * Consumer connects this to a list or table via `range()` — nothing is injected
378
+ * automatically.
379
+ *
380
+ * // Headless: read range() from a template ref
381
+ * <div cngxPaginate #pg="cngxPaginate" [total]="items.length">
382
+ * @for (item of items.slice(pg.range()[0], pg.range()[1]); track item.id) { ... }
383
+ * </div>
384
+ *
385
+ * // With CngxMatPaginator:
386
+ * <cngx-mat-paginator [cngxPaginateRef]="pg" />
387
+ */
388
+ declare class CngxPaginate {
389
+ /** Controlled page index. When bound, takes precedence over internal state. */
390
+ readonly pageIndexInput: _angular_core.InputSignal<number | undefined>;
391
+ /** Controlled page size. When bound, takes precedence over internal state. */
392
+ readonly pageSizeInput: _angular_core.InputSignal<number | undefined>;
393
+ /**
394
+ * Total number of items (before pagination). Consumer binds this from the
395
+ * filtered/sorted count so that `totalPages` stays accurate.
396
+ */
397
+ readonly total: _angular_core.InputSignal<number>;
398
+ /**
399
+ * Bind an async state — disables navigation while the data source is busy.
400
+ * When set, `isBusy` derives from `state.isBusy()`. Navigation methods
401
+ * (`setPage`, `next`, `previous`, etc.) are no-ops while busy.
402
+ */
403
+ readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
404
+ /** `true` when the bound async state is busy (loading/refreshing). */
405
+ readonly isBusy: _angular_core.Signal<boolean>;
406
+ private readonly pageIndexState;
407
+ private readonly pageSizeState;
408
+ /** Current page index (0-based). Controlled input takes precedence. Auto-clamped to totalPages. */
409
+ readonly pageIndex: _angular_core.Signal<number>;
410
+ /** Current page size. Controlled input takes precedence. */
411
+ readonly pageSize: _angular_core.Signal<number>;
412
+ /** Total number of pages (minimum 1). */
413
+ readonly totalPages: _angular_core.Signal<number>;
414
+ /** `true` when on the first page. */
415
+ readonly isFirst: _angular_core.Signal<boolean>;
416
+ /** `true` when on the last page. */
417
+ readonly isLast: _angular_core.Signal<boolean>;
418
+ /**
419
+ * `[start, end]` indices for `Array.slice()` — always in-bounds.
420
+ * Consumer: `items.slice(range()[0], range()[1])`.
421
+ */
422
+ readonly range: _angular_core.Signal<[number, number]>;
423
+ /** Emitted when the page index changes. */
424
+ readonly pageChange: _angular_core.OutputEmitterRef<number>;
425
+ /** Emitted when the page size changes. */
426
+ readonly pageSizeChange: _angular_core.OutputEmitterRef<number>;
427
+ /**
428
+ * Navigate to `index`, clamping to `[0, totalPages - 1]`.
429
+ * Emits `pageChange`.
430
+ */
431
+ setPage(index: number): void;
432
+ /**
433
+ * Change page size and optionally reset to page 0.
434
+ * Emits `pageSizeChange` and, when `resetPage` is `true`, `pageChange`.
435
+ */
436
+ setPageSize(size: number, resetPage?: boolean): void;
437
+ /** Navigate to the next page (no-op on the last page). */
438
+ next(): void;
439
+ /** Navigate to the previous page (no-op on the first page). */
440
+ previous(): void;
441
+ /** Navigate to the first page. */
442
+ first(): void;
443
+ /** Navigate to the last page. */
444
+ last(): void;
445
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxPaginate, never>;
446
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxPaginate, "[cngxPaginate]", ["cngxPaginate"], { "pageIndexInput": { "alias": "cngxPageIndex"; "required": false; "isSignal": true; }; "pageSizeInput": { "alias": "cngxPageSize"; "required": false; "isSignal": true; }; "total": { "alias": "total"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; }, { "pageChange": "pageChange"; "pageSizeChange": "pageSizeChange"; }, never, never, true, never>;
447
+ }
448
+
449
+ /**
450
+ * Minimal CDK `DataSource` that bridges a Signal to the CDK table's
451
+ * Observable-based data contract.
452
+ *
453
+ * No sort, filter, or search logic is included — the consumer builds a
454
+ * `computed()` with any transformations and passes the result here.
455
+ *
456
+ * ```typescript
457
+ * readonly processed = computed(() => {
458
+ * let items = this.raw();
459
+ * if (this.sort().sort()) { items = sortTree(items, ...); }
460
+ * return items;
461
+ * });
462
+ * readonly dataSource = injectDataSource(this.processed);
463
+ * ```
464
+ *
465
+ * @typeParam T - The row item type.
466
+ */
467
+ declare class CngxDataSource<T> extends DataSource<T> {
468
+ private readonly data;
469
+ private readonly injector;
470
+ constructor(data: Signal<T[]>);
471
+ connect(): Observable<T[]>;
472
+ disconnect(): void;
473
+ }
474
+ /**
475
+ * Factory function for {@link CngxDataSource}.
476
+ *
477
+ * Must be called within an injection context (constructor or field initializer).
478
+ *
479
+ * ```typescript
480
+ * readonly dataSource = injectDataSource(this.items);
481
+ * ```
482
+ */
483
+ declare function injectDataSource<T>(data: Signal<T[]>): CngxDataSource<T>;
484
+
485
+ /**
486
+ * Optional customization for {@link CngxSmartDataSource}.
487
+ */
488
+ interface CngxSmartDataSourceOptions<T> {
489
+ /**
490
+ * Custom full-text search function. Receives an item and the current search
491
+ * term; return `true` to keep the item. Defaults to a case-insensitive match
492
+ * across all primitive-valued properties.
493
+ */
494
+ searchFn?: (item: T, term: string) => boolean;
495
+ /**
496
+ * Custom sort comparator. Receives two items, the active field key, and
497
+ * direction. Defaults to a locale-aware string comparison.
498
+ */
499
+ sortFn?: (a: T, b: T, field: string, direction: 'asc' | 'desc') => number;
500
+ }
501
+ /**
502
+ * A CDK `DataSource` that optionally integrates with `CngxSort`,
503
+ * `CngxFilter`, `CngxSearch`, and `CngxPaginate` present in the injection
504
+ * tree. Each directive is injected optionally — if absent, that processing
505
+ * step is skipped.
506
+ *
507
+ * Accepts either a plain `Signal<T[]>` or a `CngxAsyncState<T[]>`.
508
+ * When a `CngxAsyncState` is provided, the data source exposes the full
509
+ * UX state (`isLoading`, `isRefreshing`, `error`, `isEmpty`) so the
510
+ * table can show skeleton rows, error states, and loading indicators.
511
+ *
512
+ * ```typescript
513
+ * // Plain signal
514
+ * readonly dataSource = injectSmartDataSource(this.items);
515
+ *
516
+ * // With async state — full UX lifecycle
517
+ * readonly residents = injectAsyncState(() => this.api.getAll(this.filter()));
518
+ * readonly dataSource = injectSmartDataSource(this.residents);
519
+ * // dataSource.isLoading(), dataSource.error(), dataSource.isRefreshing()
520
+ * ```
521
+ *
522
+ * @typeParam T - The row item type.
523
+ */
524
+ declare class CngxSmartDataSource<T> extends DataSource<T> {
525
+ private readonly options?;
526
+ private readonly injector;
527
+ private readonly sort;
528
+ private readonly filter;
529
+ private readonly search;
530
+ private readonly paginate;
531
+ /**
532
+ * Items after filter and search are applied, before sort and pagination.
533
+ * Use `filteredCount()` to get the pre-pagination count for paginator `total`.
534
+ */
535
+ private readonly filtered;
536
+ /** Number of items after filtering/searching, before pagination. */
537
+ readonly filteredCount: Signal<number>;
538
+ private readonly processed;
539
+ /** The async state source, or `undefined` if constructed from a plain signal. */
540
+ readonly asyncState: CngxAsyncState<T[]> | undefined;
541
+ /** `true` during initial data load (skeleton phase). */
542
+ readonly isLoading: Signal<boolean>;
543
+ /** `true` during refresh (data stays visible, loading bar). */
544
+ readonly isRefreshing: Signal<boolean>;
545
+ /** `true` when any operation is running. Maps to `aria-busy`. */
546
+ readonly isBusy: Signal<boolean>;
547
+ /** `true` if no successful load has completed yet. */
548
+ readonly isFirstLoad: Signal<boolean>;
549
+ /** Error from the async state, or `undefined`. */
550
+ readonly error: Signal<unknown>;
551
+ /** `true` when data is empty AND no operation is running. */
552
+ readonly isEmpty: Signal<boolean>;
553
+ constructor(source: Signal<T[]> | CngxAsyncState<T[]>, options?: CngxSmartDataSourceOptions<T> | undefined);
554
+ connect(): Observable<T[]>;
555
+ disconnect(): void;
556
+ }
557
+ /**
558
+ * Factory function for {@link CngxSmartDataSource}.
559
+ *
560
+ * Must be called within an injection context (constructor or field initializer).
561
+ * Accepts either a plain `Signal<T[]>` or a `CngxAsyncState<T[]>` for
562
+ * full UX state integration (loading, error, refresh, empty).
563
+ *
564
+ * ```typescript
565
+ * // Plain signal
566
+ * readonly dataSource = injectSmartDataSource(this.items);
567
+ *
568
+ * // With async state — table shows skeleton, error, loading bar
569
+ * readonly residents = injectAsyncState(() => this.api.getAll());
570
+ * readonly dataSource = injectSmartDataSource(this.residents);
571
+ * ```
572
+ */
573
+ declare function injectSmartDataSource<T>(source: Signal<T[]> | CngxAsyncState<T[]>, options?: CngxSmartDataSourceOptions<T>): CngxSmartDataSource<T>;
574
+
575
+ /**
576
+ * Writable extension of `CngxAsyncState` for manual control.
577
+ *
578
+ * Returned by `createManualState()` — provides imperative setters
579
+ * while the read-side stays the standard `CngxAsyncState` interface.
580
+ */
581
+ interface ManualAsyncState<T> extends CngxAsyncState<T> {
582
+ /** Set the status directly. */
583
+ set(status: AsyncStatus): void;
584
+ /** Transition to `success` with data. */
585
+ setSuccess(data: T): void;
586
+ /** Transition to `error`. */
587
+ setError(error: unknown): void;
588
+ /** Set progress (0–100). */
589
+ setProgress(value: number | undefined): void;
590
+ /** Reset to `idle`, clear data, error, and progress. */
591
+ reset(): void;
592
+ }
593
+ /**
594
+ * Create a fully manual async state — no HTTP, no automatic loading.
595
+ *
596
+ * Use for local operations: heavy computations, Web Workers, complex local processes.
597
+ * Does **not** require an injection context — uses only `signal()` and `computed()`.
598
+ *
599
+ * ```typescript
600
+ * readonly processState = createManualState<ProcessResult>();
601
+ *
602
+ * async handleProcess(): Promise<void> {
603
+ * this.processState.set('loading');
604
+ * this.processState.setProgress(0);
605
+ * const result = await heavyComputation((p) => this.processState.setProgress(p));
606
+ * this.processState.setSuccess(result);
607
+ * }
608
+ * ```
609
+ */
610
+ declare function createManualState<T>(): ManualAsyncState<T>;
611
+
612
+ /**
613
+ * Writable async state for mutations (POST/PUT/DELETE).
614
+ *
615
+ * Extends the read-only `CngxAsyncState` with an `execute()` method
616
+ * that runs an async action and manages the full lifecycle.
617
+ */
618
+ interface MutableAsyncState<T> extends CngxAsyncState<T> {
619
+ /**
620
+ * Execute an async action.
621
+ *
622
+ * Sets status to `pending`, then `success` or `error` on completion.
623
+ * Supersedes any in-flight execution — the previous result is discarded
624
+ * but the underlying network request is not aborted.
625
+ */
626
+ execute(fn: () => Promise<T> | Observable<T>): Promise<void>;
627
+ /** Report progress (0–100) during execution. */
628
+ reportProgress(value: number): void;
629
+ /** Reset to `idle`, clear data, error, and progress. */
630
+ reset(): void;
631
+ }
632
+ /**
633
+ * Create a mutation async state — for explicit user-triggered actions.
634
+ *
635
+ * Must be called in an injection context (field initializer or constructor)
636
+ * because it uses `inject(DestroyRef)` for cleanup.
637
+ *
638
+ * ```typescript
639
+ * readonly saveResident = createAsyncState<Resident>();
640
+ *
641
+ * async handleSave(): Promise<void> {
642
+ * await this.saveResident.execute(
643
+ * () => this.api.save(this.form().value())
644
+ * );
645
+ * }
646
+ * ```
647
+ */
648
+ declare function createAsyncState<T>(): MutableAsyncState<T>;
649
+
650
+ /**
651
+ * Configuration options for `injectAsyncState`.
652
+ */
653
+ interface InjectAsyncStateOptions {
654
+ /**
655
+ * Debounce time in ms for signal dependency changes.
656
+ * Prevents request storms when multiple signals change rapidly.
657
+ * @default 50
658
+ */
659
+ debounce?: number;
660
+ }
661
+ /**
662
+ * Reactive async state returned by `injectAsyncState`.
663
+ *
664
+ * Extends the read-only `CngxAsyncState` with a `refresh()` method
665
+ * to explicitly re-trigger the query.
666
+ */
667
+ interface ReactiveAsyncState<T> extends CngxAsyncState<T> {
668
+ /** Explicitly re-trigger the query. */
669
+ refresh(): void;
670
+ }
671
+ /**
672
+ * Create a reactive async state that auto-loads when signal dependencies change.
673
+ *
674
+ * Must be called in an injection context (field initializer or constructor).
675
+ * The computation function is tracked by Angular's `effect()` — any signal
676
+ * read inside `fn` will cause a re-load when it changes.
677
+ *
678
+ * ```typescript
679
+ * readonly residents = injectAsyncState(
680
+ * () => this.api.getResidents(this.filter())
681
+ * );
682
+ * // Loads automatically when filter() changes.
683
+ * // Caches last result during refresh (refreshing state).
684
+ * // Deduplicates parallel requests.
685
+ * ```
686
+ */
687
+ declare function injectAsyncState<T>(fn: () => Promise<T> | Observable<T>, options?: InjectAsyncStateOptions): ReactiveAsyncState<T>;
688
+
689
+ /**
690
+ * Possible view states for async content rendering.
691
+ */
692
+ type AsyncView = 'none' | 'skeleton' | 'content' | 'empty' | 'error' | 'content+error';
693
+ /**
694
+ * Pure function that resolves which view to show based on async state.
695
+ *
696
+ * Encodes the state machine as a lookup table — no branching:
697
+ *
698
+ * | status | firstLoad | empty | view |
699
+ * |-------------|-----------|-------|---------------|
700
+ * | idle | true | * | none |
701
+ * | loading | true | * | skeleton |
702
+ * | refreshing | true | * | skeleton |
703
+ * | pending | true | * | skeleton |
704
+ * | error | true | * | error |
705
+ * | success | * | true | empty |
706
+ * | error | false | * | content+error |
707
+ * | (all other) | * | * | content |
708
+ */
709
+ declare function resolveAsyncView(status: AsyncStatus, firstLoad: boolean, empty: boolean): AsyncView;
710
+
711
+ /**
712
+ * Template context for the `*cngxAsync` content template.
713
+ * `$implicit` provides the data value, typed via `ngTemplateContextGuard`.
714
+ */
715
+ interface CngxAsyncContext<T> {
716
+ /** The data value — bound via `let data` in microsyntax. */
717
+ $implicit: T;
718
+ /** Alias for `$implicit`. */
719
+ cngxAsync: T;
720
+ }
721
+ /**
722
+ * Structural directive for async state-driven content rendering.
723
+ *
724
+ * Renders different views based on the current `CngxAsyncState` status:
725
+ * - **loading (first load)** → skeleton template (or nothing)
726
+ * - **success + has data** → content template with typed data
727
+ * - **success + empty** → empty template (or nothing)
728
+ * - **error (first load)** → error template (or nothing)
729
+ * - **refreshing / loading (with data)** → content template (old data stays visible)
730
+ * - **error (with data)** → content template (old data stays visible)
731
+ *
732
+ * ### Minimal — just content
733
+ * ```html
734
+ * <ul *cngxAsync="residents; let data">
735
+ * @for (r of data; track r.id) { <li>{{ r.name }}</li> }
736
+ * </ul>
737
+ * ```
738
+ *
739
+ * ### With custom templates
740
+ * ```html
741
+ * <ul *cngxAsync="residents; let data; skeleton: skelTpl; empty: emptyTpl; error: errTpl">
742
+ * @for (r of data; track r.id) { <li>{{ r.name }}</li> }
743
+ * </ul>
744
+ *
745
+ * <ng-template #skelTpl>
746
+ * @for (i of [1,2,3]; track i) { <li class="skeleton-line"></li> }
747
+ * </ng-template>
748
+ *
749
+ * <ng-template #emptyTpl>
750
+ * <li>No residents found.</li>
751
+ * </ng-template>
752
+ *
753
+ * <ng-template #errTpl let-err>
754
+ * <li>Error: {{ err }}</li>
755
+ * </ng-template>
756
+ * ```
757
+ */
758
+ declare class CngxAsync<T> {
759
+ private readonly vcr;
760
+ private readonly contentTpl;
761
+ /** The async state to render. */
762
+ readonly cngxAsync: _angular_core.InputSignal<CngxAsyncState<T>>;
763
+ /** Optional skeleton template shown during first load. */
764
+ readonly cngxAsyncSkeleton: _angular_core.InputSignal<TemplateRef<unknown> | undefined>;
765
+ /** Optional empty template shown when data is empty after success. */
766
+ readonly cngxAsyncEmpty: _angular_core.InputSignal<TemplateRef<unknown> | undefined>;
767
+ /** Optional error template shown on error during first load. Context: `{ $implicit: error }`. */
768
+ readonly cngxAsyncError: _angular_core.InputSignal<TemplateRef<{
769
+ $implicit: unknown;
770
+ }> | undefined>;
771
+ private readonly view;
772
+ private readonly currentView;
773
+ private contentViewRef;
774
+ constructor();
775
+ private updateContentContext;
776
+ private renderView;
777
+ private renderTemplate;
778
+ /** Type guard for template type inference. */
779
+ static ngTemplateContextGuard<T>(_dir: CngxAsync<T>, _ctx: unknown): _ctx is CngxAsyncContext<T>;
780
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsync<any>, never>;
781
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAsync<any>, "[cngxAsync]", never, { "cngxAsync": { "alias": "cngxAsync"; "required": true; "isSignal": true; }; "cngxAsyncSkeleton": { "alias": "cngxAsyncSkeleton"; "required": false; "isSignal": true; }; "cngxAsyncEmpty": { "alias": "cngxAsyncEmpty"; "required": false; "isSignal": true; }; "cngxAsyncError": { "alias": "cngxAsyncError"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
782
+ }
783
+
784
+ /**
785
+ * Displays a formatted numeric value with optional unit.
786
+ *
787
+ * Uses `Intl.NumberFormat` with the injected `LOCALE_ID` for locale-aware
788
+ * formatting. Null values render as an em-dash.
789
+ *
790
+ * Composable — works inside any card variant, header, body, or standalone.
791
+ *
792
+ * ### Basic
793
+ * ```html
794
+ * <cngx-metric [value]="1234" unit="bpm" />
795
+ * ```
796
+ *
797
+ * ### With format options
798
+ * ```html
799
+ * <cngx-metric [value]="99.6" unit="%" [format]="{ maximumFractionDigits: 1 }" />
800
+ * ```
801
+ *
802
+ * ### Inside a card
803
+ * ```html
804
+ * <cngx-card>
805
+ * <header cngxCardHeader>Puls</header>
806
+ * <cngx-metric cngxCardBody [value]="75" unit="bpm" />
807
+ * </cngx-card>
808
+ * ```
809
+ */
810
+ declare class CngxMetric {
811
+ private readonly locale;
812
+ /** Numeric or string value. `null` renders as em-dash. */
813
+ readonly value: _angular_core.InputSignal<string | number | null>;
814
+ /** Unit suffix (e.g. "bpm", "h", "%", "kg"). */
815
+ readonly unit: _angular_core.InputSignal<string | undefined>;
816
+ /** `Intl.NumberFormatOptions` for the primary value. */
817
+ readonly format: _angular_core.InputSignal<Intl.NumberFormatOptions | undefined>;
818
+ /** @internal */
819
+ readonly formattedValue: _angular_core.Signal<string>;
820
+ /** @internal Full accessible description including unit. */
821
+ readonly accessibleValue: _angular_core.Signal<string>;
822
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMetric, never>;
823
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxMetric, "cngx-metric", never, { "value": { "alias": "value"; "required": true; "isSignal": true; }; "unit": { "alias": "unit"; "required": false; "isSignal": true; }; "format": { "alias": "format"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
824
+ }
825
+
826
+ /**
827
+ * Displays a trend indicator with directional arrow and formatted percentage.
828
+ *
829
+ * Positive values show an up arrow, negative a down arrow, zero a right arrow.
830
+ * The consumer can override the SR label for full context
831
+ * (e.g. "vs. last month" instead of the generic default).
832
+ *
833
+ * ### Basic
834
+ * ```html
835
+ * <cngx-trend [value]="5.3" />
836
+ * ```
837
+ *
838
+ * ### With custom label
839
+ * ```html
840
+ * <cngx-trend [value]="-2.1" label="-2.1% vs. last quarter" />
841
+ * ```
842
+ *
843
+ * ### Inside a card header
844
+ * ```html
845
+ * <cngx-card>
846
+ * <header cngxCardHeader>
847
+ * <span>Revenue</span>
848
+ * <cngx-trend [value]="revenue().trend" />
849
+ * </header>
850
+ * </cngx-card>
851
+ * ```
852
+ */
853
+ declare class CngxTrend {
854
+ /** Trend percentage. Positive = up, negative = down, zero = flat. */
855
+ readonly value: _angular_core.InputSignal<number>;
856
+ /** Consumer-provided SR label override. When set, replaces the generated default. */
857
+ readonly label: _angular_core.InputSignal<string | undefined>;
858
+ /** @internal */
859
+ readonly icon: _angular_core.Signal<"↑" | "↓" | "→">;
860
+ /** @internal */
861
+ readonly formattedValue: _angular_core.Signal<string>;
862
+ /** @internal */
863
+ readonly resolvedLabel: _angular_core.Signal<string>;
864
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxTrend, never>;
865
+ 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>;
866
+ }
867
+
868
+ /**
869
+ * I18n interface for recycler SR announcements.
870
+ * All methods return the announcement text. No hardcoded strings.
871
+ */
872
+ interface RecyclerI18n {
873
+ /** Announced when new items are loaded (infinite scroll). */
874
+ loaded(newCount: number, total: number): string;
875
+ /** Announced when filter/search results change. */
876
+ filtered(count: number): string;
877
+ /** Announced when the list becomes empty. */
878
+ empty(): string;
879
+ /** Announced when loading fails. */
880
+ error(): string;
881
+ }
882
+ /**
883
+ * Injection token for recycler SR announcement texts.
884
+ * Provides English defaults via factory. Override with `provideRecyclerI18n()`.
885
+ */
886
+ declare const CNGX_RECYCLER_I18N: InjectionToken<RecyclerI18n>;
887
+ /**
888
+ * Provider function for custom recycler i18n texts.
889
+ *
890
+ * ```typescript
891
+ * providers: [provideRecyclerI18n({
892
+ * loaded: (n, t) => `${n} weitere Einträge. ${t} gesamt.`,
893
+ * filtered: (c) => `${c} Ergebnisse.`,
894
+ * empty: () => 'Keine Ergebnisse.',
895
+ * error: () => 'Fehler beim Laden.',
896
+ * })]
897
+ * ```
898
+ */
899
+ declare function provideRecyclerI18n(i18n: RecyclerI18n): {
900
+ provide: InjectionToken<RecyclerI18n>;
901
+ useValue: RecyclerI18n;
902
+ };
903
+ /**
904
+ * Configuration for {@link injectRecycler}.
905
+ */
906
+ interface RecyclerConfig {
907
+ /** Scroll container. CSS selector, native element, or `ElementRef`. */
908
+ scrollElement: ElementRef | HTMLElement | string;
909
+ /**
910
+ * Total number of items. Reactive — changes on infinite scroll.
911
+ *
912
+ * **Important:** For infinite scroll, this is the number of *loaded* items,
913
+ * not the server-side total. Otherwise the sentinel becomes unreachable.
914
+ */
915
+ totalCount: () => number;
916
+ /** Estimated height per item (px). Number or function per index. */
917
+ estimateSize: number | ((index: number) => number);
918
+ /** Extra items to render above/below the viewport. Default: 5. */
919
+ overscan?: number;
920
+ /**
921
+ * Layout mode. `'list'` (default) uses padding spacers.
922
+ * `'grid'` is Phase 3 — passing it logs a dev-mode warning and falls back to `'list'`.
923
+ */
924
+ layout?: 'list' | 'grid';
925
+ /** Column count for grid mode. Phase 3 — ignored in Phase 1. */
926
+ columns?: number | (() => number);
927
+ /** Debounce for scroll events in ms. Default: 16 (~1 frame). */
928
+ scrollDebounce?: number;
929
+ /**
930
+ * Delay before skeletons are shown (ms). Default: 0.
931
+ * E.g. 300 means `showSkeleton` only becomes `true` after 300ms —
932
+ * fast loads (< 300ms) never show a skeleton.
933
+ */
934
+ skeletonDelay?: number;
935
+ /**
936
+ * Async state source. When set, the recycler derives skeleton rendering,
937
+ * refresh state, and empty state from it — same convention as
938
+ * `CngxCardGrid`, `CngxTreetable`, `CngxPopoverPanel`, and `CngxDialog`.
939
+ */
940
+ state?: CngxAsyncState<unknown>;
941
+ /**
942
+ * Server-side total for A11y (`aria-setsize`) and "Showing X of Y" display.
943
+ * When not set, `totalCount` is used.
944
+ */
945
+ serverTotal?: () => number;
946
+ }
947
+ /**
948
+ * Signal-based virtualizer returned by {@link injectRecycler}.
949
+ * All derived values are `computed()` — the system cannot become inconsistent.
950
+ */
951
+ interface CngxRecycler {
952
+ /** Start index (inclusive) of the rendered range, including overscan. */
953
+ readonly start: Signal<number>;
954
+ /** End index (exclusive) of the rendered range, including overscan. */
955
+ readonly end: Signal<number>;
956
+ /** Spacer height before rendered items (px). Always 0 in grid mode. */
957
+ readonly offsetBefore: Signal<number>;
958
+ /** Spacer height after rendered items (px). Always 0 in grid mode. */
959
+ readonly offsetAfter: Signal<number>;
960
+ /** Total scrollable height of all items (px). */
961
+ readonly totalSize: Signal<number>;
962
+ /** Placeholder count before rendered items. Only non-zero in grid mode. */
963
+ readonly placeholdersBefore: Signal<number>;
964
+ /** Placeholder count after rendered items. Only non-zero in grid mode. */
965
+ readonly placeholdersAfter: Signal<number>;
966
+ /** `true` during first load (`state.isFirstLoad()`). `false` without `state`. */
967
+ readonly isLoading: Signal<boolean>;
968
+ /** `true` during refresh (`state.isRefreshing()`). Data remains visible. */
969
+ readonly isRefreshing: Signal<boolean>;
970
+ /** `true` when `totalCount === 0` and not busy. */
971
+ readonly isEmpty: Signal<boolean>;
972
+ /** How many skeleton items fit in the viewport: `ceil(clientHeight / estimateSize)`. */
973
+ readonly skeletonSlots: Signal<number>;
974
+ /** `isLoading` AND `skeletonDelay` elapsed. Prevents skeleton flicker on fast loads. */
975
+ readonly showSkeleton: Signal<boolean>;
976
+ /** First actually visible index (without overscan). For UI display. */
977
+ readonly firstVisible: Signal<number>;
978
+ /** Last actually visible index (without overscan). For UI display. */
979
+ readonly lastVisible: Signal<number>;
980
+ /** Count of actually visible items (without overscan). */
981
+ readonly visibleCount: Signal<number>;
982
+ /**
983
+ * Locks scroll position relative to an item. When items are inserted above
984
+ * the anchored item, `scrollTop` is corrected to maintain visual position.
985
+ */
986
+ anchorTo(index: number): void;
987
+ /** Releases the scroll anchor set by {@link anchorTo}. */
988
+ releaseAnchor(): void;
989
+ /**
990
+ * Reports the index of the item that had focus when it left the rendered range.
991
+ * `null` when no focus was lost. Consumer can use this to restore focus.
992
+ */
993
+ readonly lostFocus: Signal<{
994
+ index: number;
995
+ } | null>;
996
+ /** SR announcement text for state transitions (load, filter, empty, error). */
997
+ readonly announcement: Signal<string>;
998
+ /** `serverTotal` when set, otherwise `totalCount`. Bind to `aria-setsize`. */
999
+ readonly ariaSetSize: Signal<number>;
1000
+ /**
1001
+ * The range of item indices that must be available for rendering.
1002
+ * Use in an effect to trigger page loads for windowed/sparse data sources.
1003
+ *
1004
+ * Unlike `firstVisible`/`lastVisible` (which exclude overscan), this includes
1005
+ * overscan items — all indices in this range may be rendered.
1006
+ *
1007
+ * ```typescript
1008
+ * effect(() => {
1009
+ * const { start, end } = recycler.neededRange();
1010
+ * const startPage = Math.floor(start / PAGE_SIZE);
1011
+ * const endPage = Math.floor(end / PAGE_SIZE);
1012
+ * for (let p = startPage; p <= endPage; p++) {
1013
+ * if (!pageCache.has(p)) { loadPage(p); }
1014
+ * }
1015
+ * });
1016
+ * ```
1017
+ */
1018
+ readonly neededRange: Signal<{
1019
+ start: number;
1020
+ end: number;
1021
+ }>;
1022
+ /**
1023
+ * Target index that `scrollToIndex()` is waiting for.
1024
+ * Non-null when the target index exceeds `totalCount` — consumer
1025
+ * can show a "Scrolling to item..." indicator or trigger page loads.
1026
+ * Clears automatically when `totalCount` grows past the target.
1027
+ */
1028
+ readonly pendingTarget: Signal<number | null>;
1029
+ /**
1030
+ * Creates a `computed()` slicing items to the visible range.
1031
+ * **Call once in a field initializer** — each call creates a new computed node.
1032
+ * Do NOT call in templates or methods.
1033
+ */
1034
+ sliced<T>(items: Signal<T[]>): Signal<T[]>;
1035
+ /**
1036
+ * Reports a measured item height to the internal SizeCache.
1037
+ * No-op in grid mode (uniform row height assumed).
1038
+ * Prefer {@link CngxMeasure} directive over calling this directly.
1039
+ */
1040
+ measure(index: number, element: HTMLElement): void;
1041
+ /**
1042
+ * Scrolls to a specific item index. When `index >= totalCount`, stores
1043
+ * the target in {@link pendingTarget} for resolution when data arrives.
1044
+ */
1045
+ scrollToIndex(index: number, behavior?: ScrollBehavior): void;
1046
+ /** Scrolls to top. Convenience for sort/filter changes. */
1047
+ reset(): void;
1048
+ }
1049
+ /**
1050
+ * Creates a Signal-based virtualizer for DOM recycling.
1051
+ *
1052
+ * Must be called in an injection context (field initializer or constructor).
1053
+ * Internally injects `DestroyRef` and `DOCUMENT` for cleanup and selector resolution.
1054
+ *
1055
+ * ### Basic list
1056
+ * ```typescript
1057
+ * readonly recycler = injectRecycler({
1058
+ * scrollElement: '.scroll-container',
1059
+ * totalCount: () => this.items().length,
1060
+ * estimateSize: 48,
1061
+ * });
1062
+ * readonly visibleItems = this.recycler.sliced(this.items);
1063
+ * ```
1064
+ *
1065
+ * ### With async state
1066
+ * ```typescript
1067
+ * readonly state = injectAsyncState(() => this.api.getAll());
1068
+ * readonly recycler = injectRecycler({
1069
+ * scrollElement: '.scroll-container',
1070
+ * totalCount: () => (this.state.data() ?? []).length,
1071
+ * estimateSize: 64,
1072
+ * state: this.state,
1073
+ * });
1074
+ * ```
1075
+ */
1076
+ declare function injectRecycler(config: RecyclerConfig): CngxRecycler;
1077
+
1078
+ /**
1079
+ * Atom directive that measures the host element's height and reports it
1080
+ * to the recycler via `recycler.measure(index, element)`.
1081
+ *
1082
+ * Uses `ResizeObserver` to detect height changes (e.g. content expansion,
1083
+ * font loading). Cleanup is automatic via `DestroyRef`.
1084
+ *
1085
+ * Also sets `data-cngx-recycle-index` on the host element for focus tracking.
1086
+ *
1087
+ * ```html
1088
+ * @for (item of visibleItems(); track item.id; let i = $index) {
1089
+ * <div [cngxMeasure]="recycler" [cngxMeasureIndex]="recycler.start() + i">
1090
+ * {{ item.content }}
1091
+ * </div>
1092
+ * }
1093
+ * ```
1094
+ */
1095
+ declare class CngxMeasure {
1096
+ /** The recycler instance to report measurements to. */
1097
+ readonly cngxMeasure: _angular_core.InputSignal<CngxRecycler>;
1098
+ /** The absolute index of this item in the full dataset. */
1099
+ readonly cngxMeasureIndex: _angular_core.InputSignal<number>;
1100
+ private readonly el;
1101
+ constructor();
1102
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxMeasure, never>;
1103
+ 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>;
1104
+ }
1105
+
1106
+ /**
1107
+ * A11y atom that sets `aria-setsize`, `aria-posinset`, and `data-cngx-recycle-index`
1108
+ * on each rendered virtual item. Replaces manual ARIA boilerplate.
1109
+ *
1110
+ * Also provides `data-cngx-recycle-index` for focus tracking — consumers who
1111
+ * don't use `CngxMeasure` (grid mode, uniform heights) get focus tracking for free.
1112
+ *
1113
+ * Does NOT set `role` — the consumer decides (`listitem`, `option`, `treeitem`, `tab`).
1114
+ *
1115
+ * ```html
1116
+ * @for (item of visibleItems(); track item.id; let i = $index) {
1117
+ * <div role="listitem"
1118
+ * [cngxVirtualItem]="recycler"
1119
+ * [cngxVirtualItemIndex]="recycler.start() + i">
1120
+ * {{ item.name }}
1121
+ * </div>
1122
+ * }
1123
+ * ```
1124
+ */
1125
+ declare class CngxVirtualItem {
1126
+ /** The recycler instance providing `ariaSetSize`. */
1127
+ readonly cngxVirtualItem: _angular_core.InputSignal<CngxRecycler>;
1128
+ /** The absolute 0-based index of this item in the full dataset. */
1129
+ readonly cngxVirtualItemIndex: _angular_core.InputSignal<number>;
1130
+ /** Total item count for `aria-setsize`. */
1131
+ protected readonly ariaSetSize: _angular_core.Signal<number>;
1132
+ /** 1-based position for `aria-posinset`. */
1133
+ protected readonly ariaPosinset: _angular_core.Signal<number>;
1134
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxVirtualItem, never>;
1135
+ 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>;
1136
+ }
1137
+
1138
+ /**
1139
+ * Convenience component that renders the `aria-live="polite"` region
1140
+ * for recycler SR announcements. Eliminates manual boilerplate.
1141
+ *
1142
+ * Uses `display: contents` — no layout impact.
1143
+ *
1144
+ * ```html
1145
+ * <cngx-recycler-announcer [cngxRecyclerAnnouncer]="recycler" />
1146
+ * ```
1147
+ */
1148
+ declare class CngxRecyclerAnnouncer {
1149
+ /** The recycler instance providing `announcement()`. */
1150
+ readonly recycler: _angular_core.InputSignal<CngxRecycler>;
1151
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxRecyclerAnnouncer, never>;
1152
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxRecyclerAnnouncer, "cngx-recycler-announcer", never, { "recycler": { "alias": "cngxRecyclerAnnouncer"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
1153
+ }
1154
+
1155
+ /**
1156
+ * Wires a `CngxRecycler` to a `CngxRovingTabindex` in virtual mode.
1157
+ *
1158
+ * When the roving tabindex navigates to an item that is not in the DOM
1159
+ * (out of rendered range), this function scrolls the recycler to that item
1160
+ * and focuses it after rendering.
1161
+ *
1162
+ * Must be called in an injection context (constructor or field initializer)
1163
+ * **on the component that hosts both the recycler's scroll container and the
1164
+ * `CngxRovingTabindex` directive**. The injected `ElementRef` is used to query
1165
+ * `[data-cngx-recycle-index]` — calling from a child component would query the
1166
+ * wrong subtree.
1167
+ *
1168
+ * ```typescript
1169
+ * @Component({
1170
+ * hostDirectives: [
1171
+ * { directive: CngxRovingTabindex, inputs: ['orientation', 'activeIndex', 'virtualCount'] },
1172
+ * ],
1173
+ * })
1174
+ * class MyVirtualList {
1175
+ * private readonly roving = inject(CngxRovingTabindex, { host: true });
1176
+ * readonly recycler = injectRecycler({ ... });
1177
+ *
1178
+ * constructor() {
1179
+ * connectRecyclerToRoving(this.recycler, this.roving);
1180
+ * }
1181
+ * }
1182
+ * ```
1183
+ */
1184
+ declare function connectRecyclerToRoving(recycler: CngxRecycler, roving: CngxRovingTabindex): void;
1185
+
1186
+ /**
1187
+ * Wires a {@link CngxRecycler} to a {@link CngxActiveDescendant} in
1188
+ * virtual mode.
1189
+ *
1190
+ * When the AD directive navigates to an item whose index is not in the
1191
+ * recycler's rendered range, it sets `pendingHighlight` (via the
1192
+ * `virtualCount` path). This helper watches that signal and scrolls
1193
+ * the recycler to the target index; AD's own effect observes the
1194
+ * resulting DOM update and clears the pending state automatically
1195
+ * (see the `pendingHighlightState.set(null)` branch in
1196
+ * `CngxActiveDescendant` after a re-render brings the target into the
1197
+ * rendered range).
1198
+ *
1199
+ * Unlike {@link /projects/common/data/src/recycler/connect-recycler-roving.ts
1200
+ * connectRecyclerToRoving}, we don't re-focus a DOM element after the
1201
+ * scroll — AD doesn't move real focus, it only rebinds
1202
+ * `aria-activedescendant`. Once the target index enters the rendered
1203
+ * range, the `[attr.aria-activedescendant]` binding on the combobox
1204
+ * trigger resolves to the now-present option element for free.
1205
+ *
1206
+ * Must be called in an injection context (typically a component
1207
+ * constructor) on the same component that owns both the recycler
1208
+ * and the AD directive.
1209
+ *
1210
+ * ```typescript
1211
+ * @Component({
1212
+ * hostDirectives: [
1213
+ * { directive: CngxActiveDescendant, inputs: ['items', 'virtualCount'] },
1214
+ * ],
1215
+ * })
1216
+ * class MyVirtualSelect {
1217
+ * private readonly ad = inject(CngxActiveDescendant, { host: true });
1218
+ * readonly recycler = injectRecycler({ ... });
1219
+ *
1220
+ * constructor() {
1221
+ * connectRecyclerToActiveDescendant(this.recycler, this.ad);
1222
+ * }
1223
+ * }
1224
+ * ```
1225
+ */
1226
+ declare function connectRecyclerToActiveDescendant(recycler: CngxRecycler, ad: CngxActiveDescendant): void;
1227
+
1228
+ /**
1229
+ * Cancel handle returned by a {@link CngxCommitRunner}. The controller
1230
+ * stores it on every `begin(...)` and calls `cancel()` synchronously
1231
+ * when a newer commit supersedes it. Action runtimes (RxJS subscription
1232
+ * teardown, AbortController abort, plain flag) implement the handle
1233
+ * however they need.
1234
+ */
1235
+ interface CngxCommitHandle {
1236
+ readonly cancel: () => void;
1237
+ }
1238
+ /**
1239
+ * Action runner contract. Receives the controller's success/error
1240
+ * routes and returns a cancel handle. The runner is opaque to the
1241
+ * controller — it can wrap any async source (Observable, Promise,
1242
+ * sync value) and any cancellation primitive.
1243
+ *
1244
+ * Variants supply their own runner adapter (e.g. select's
1245
+ * `runCommitAction` invokes a `CngxSelectCommitAction<T>`; stepper's
1246
+ * runner adapts a `CngxStepperCommitAction`); the controller has no
1247
+ * knowledge of the variant-specific action shape.
1248
+ */
1249
+ type CngxCommitRunner<T> = (handlers: {
1250
+ readonly onSuccess: (committed: T | undefined) => void;
1251
+ readonly onError: (err: unknown) => void;
1252
+ }) => CngxCommitHandle;
1253
+ /**
1254
+ * Outcome handlers passed to `controller.begin(...)`. The controller
1255
+ * invokes exactly one of `onSuccess` / `onError` per commit lifecycle
1256
+ * (unless the commit is superseded, in which case neither fires).
1257
+ */
1258
+ interface CngxCommitBeginHandlers<T> {
1259
+ readonly onSuccess: (committed: T | undefined) => void;
1260
+ readonly onError: (err: unknown, previous: T | undefined) => void;
1261
+ }
1262
+ /**
1263
+ * Encapsulated state machine for the async-commit lifecycle shared by
1264
+ * every cngx feature that has a "perform-an-async-write-then-update-
1265
+ * the-source-signal" flow (select family, stepper, future wizards).
1266
+ *
1267
+ * Owns:
1268
+ * - the `CngxAsyncState<T | undefined>` slot consumed by `CNGX_STATEFUL`
1269
+ * bridges, commit-error templates, and the pending-row spinner;
1270
+ * - begin / cancel orchestration with monotonic supersede semantics;
1271
+ * - the "intended value" signal that drives the pending-spinner on
1272
+ * the specific row / step the user just clicked.
1273
+ *
1274
+ * The controller is intentionally **not** an Angular service or
1275
+ * provider. It's a plain factory so it works in any injection context
1276
+ * (including outside Angular, for headless tests).
1277
+ */
1278
+ interface CngxCommitController<T> {
1279
+ /** Read-only async-state view of the commit lifecycle. */
1280
+ readonly state: CngxAsyncState<T | undefined>;
1281
+ /** `true` while a commit is in flight. */
1282
+ readonly isCommitting: Signal<boolean>;
1283
+ /**
1284
+ * The most recent intended value — what the user was trying to
1285
+ * commit. Used by the option-row spinner and the commit-error
1286
+ * template context to identify *which* option the failure belongs
1287
+ * to.
1288
+ */
1289
+ readonly intendedValue: Signal<T | undefined>;
1290
+ /**
1291
+ * Start a new commit. Supersedes any in-flight commit: the
1292
+ * previous runner's cancel handle fires synchronously, and the
1293
+ * previous outcome callbacks become no-ops if they fire late.
1294
+ *
1295
+ * @param runner variant-specific action runner (closes over the
1296
+ * action and the intended value)
1297
+ * @param intended the value the user clicked
1298
+ * @param previous the value to roll back to on error
1299
+ * @param handlers success/error routes — the controller only
1300
+ * updates its own state and calls these; it does
1301
+ * NOT touch external value signals, panel open
1302
+ * state, or component outputs.
1303
+ */
1304
+ begin(runner: CngxCommitRunner<T>, intended: T | undefined, previous: T | undefined, handlers: CngxCommitBeginHandlers<T>): void;
1305
+ /**
1306
+ * Abort the currently in-flight commit without firing callbacks.
1307
+ * Use when the host component is destroyed or the commit-action
1308
+ * input changes mid-flight.
1309
+ */
1310
+ cancel(): void;
1311
+ }
1312
+ /**
1313
+ * Factory for the commit controller.
1314
+ *
1315
+ * Plain function, not a class — matches the rest of the repo
1316
+ * (`createManualState`, `createAsyncState`, `createTransitionTracker`).
1317
+ * See `reference_api_prefix_convention.md`.
1318
+ */
1319
+ declare function createCommitController<T>(): CngxCommitController<T>;
1320
+
1321
+ /**
1322
+ * Factory signature for producing {@link CngxCommitController}
1323
+ * instances. Consumers override the DI token
1324
+ * {@link CNGX_COMMIT_CONTROLLER_FACTORY} with a custom factory to
1325
+ * inject retry-with-backoff, offline queues, telemetry, or any
1326
+ * other enterprise-specific commit lifecycle — without forking the
1327
+ * features that consume it (select family, stepper, future wizards).
1328
+ */
1329
+ type CngxCommitControllerFactory = <T>() => CngxCommitController<T>;
1330
+ /**
1331
+ * DI token carrying the factory that every cngx feature uses to
1332
+ * allocate its commit controller. Default `providedIn: 'root'`
1333
+ * factory returns {@link createCommitController}. Override globally
1334
+ * via app providers or per-component via `viewProviders`.
1335
+ *
1336
+ * Symmetrical to `CNGX_SELECT_COMMIT_CONTROLLER_FACTORY`
1337
+ * (`@cngx/forms/select`); the select-side token's default factory
1338
+ * delegates to this one, so a single override here cascades into
1339
+ * every select variant transparently.
1340
+ *
1341
+ * ```ts
1342
+ * bootstrapApplication(App, {
1343
+ * providers: [
1344
+ * {
1345
+ * provide: CNGX_COMMIT_CONTROLLER_FACTORY,
1346
+ * useValue: <T>() => createRetryingCommitController<T>({ attempts: 3 }),
1347
+ * },
1348
+ * ],
1349
+ * });
1350
+ * ```
1351
+ */
1352
+ declare const CNGX_COMMIT_CONTROLLER_FACTORY: InjectionToken<CngxCommitControllerFactory>;
1353
+
1354
+ /**
1355
+ * Options for {@link createMaterialBidirectionalSync}.
1356
+ *
1357
+ * Material types never enter this surface. The caller maps Material's
1358
+ * own event/property shape to a host-agnostic `Signal<number>` /
1359
+ * `Observable<number>` / getter / setter at the directive boundary.
1360
+ * That keeps `@cngx/common/data` independent of `@angular/material`
1361
+ * (Sheriff Level-2 invariant).
1362
+ */
1363
+ interface CngxMaterialBidirectionalSyncOptions {
1364
+ /**
1365
+ * Reactive source for the presenter's current index. The factory's
1366
+ * `effect()` tracks this signal — when it changes, Material is
1367
+ * written (subject to the equality guard against the Material
1368
+ * read-side).
1369
+ */
1370
+ readonly presenterIndex: Signal<number>;
1371
+ /**
1372
+ * Pulls the Material instance's current `selectedIndex` (or
1373
+ * equivalent). Called inside `untracked()` so the effect does not
1374
+ * subscribe to any signals the getter might read internally.
1375
+ */
1376
+ readonly readSelectedIndex: () => number;
1377
+ /**
1378
+ * Writes the Material instance's `selectedIndex` (or equivalent).
1379
+ * Called inside `untracked()` per
1380
+ * `reference_signal_architecture` rule 2.
1381
+ */
1382
+ readonly writeSelectedIndex: (idx: number) => void;
1383
+ /**
1384
+ * Stream of Material-driven selection changes, already mapped to a
1385
+ * plain index by the caller (`MatTabGroup.selectedIndexChange`
1386
+ * forwards directly; `MatStepper.selectionChange` needs
1387
+ * `.pipe(map(e => e.selectedIndex))`).
1388
+ */
1389
+ readonly selectionChange$: Observable<number>;
1390
+ /**
1391
+ * Routes a Material→presenter selection event into the presenter's
1392
+ * `select(idx)` method. Subject to an equality guard against
1393
+ * `presenterIndex()` so re-entrant events (the presenter's own
1394
+ * write firing back through Material) drop without re-routing.
1395
+ */
1396
+ readonly onMaterialSelection: (idx: number) => void;
1397
+ /** Injector used to install the effect inside an injection context. */
1398
+ readonly injector: Injector;
1399
+ /** DestroyRef used to clean up the effect and the subscription. */
1400
+ readonly destroyRef: DestroyRef;
1401
+ }
1402
+ /**
1403
+ * Single shared bidirectional-sync factory for cngx organisms /
1404
+ * directives that bridge a cngx presenter against a Material parent
1405
+ * (`<mat-tab-group>`, `<mat-stepper>`, etc.).
1406
+ *
1407
+ * Lives at Level 2 in `@cngx/common/data` parallel to
1408
+ * `createCommitController`. Material types never enter the signature —
1409
+ * the caller maps Material-specific events and property accessors to a
1410
+ * host-agnostic shape at the directive boundary.
1411
+ *
1412
+ * Installs:
1413
+ *
1414
+ * 1. A presenter→Material `effect()` that tracks `presenterIndex` and
1415
+ * writes through `writeSelectedIndex`, equality-guarded against
1416
+ * `readSelectedIndex()` to suppress redundant writes. The Material
1417
+ * read+write pair runs inside `untracked()` per
1418
+ * `reference_signal_architecture` rule 2.
1419
+ * 2. A Material→presenter subscription that forwards each
1420
+ * `selectionChange$` emission to `onMaterialSelection`
1421
+ * (equality-guarded against `presenterIndex()` so a Material event
1422
+ * whose value already matches the presenter is dropped — closes
1423
+ * the re-entrancy loop).
1424
+ *
1425
+ * Both sides clean up via `destroyRef`.
1426
+ *
1427
+ * **Pessimistic-commit gate (deliberately absent).** An earlier draft
1428
+ * carried a third option `commitState: CngxAsyncState<unknown>` that
1429
+ * gated the Material write while `commitState.isPending()`. The plan
1430
+ * (`global-material-bridge-and-architecture-hardening-plan` §54)
1431
+ * specified this gate "for the pessimistic flow." Implementation
1432
+ * showed the gate is redundant: cngx commit handlers already keep
1433
+ * `presenter.activeIndex` at the origin during pessimistic-pending,
1434
+ * so the equality guard alone suppresses the Material write.
1435
+ * Conversely, in optimistic mode the presenter advances IMMEDIATELY
1436
+ * (before the commit settles); a `pending`-keyed gate would suppress
1437
+ * that legitimate advance and break the optimistic UX. Dropping the
1438
+ * gate makes both modes work via the simple presenter→Material
1439
+ * mirror — same outcome as the gate version for pessimistic, and the
1440
+ * correct outcome for optimistic.
1441
+ *
1442
+ * **Material-eager-advance reconciliation.** Material's MDC click
1443
+ * handler advances `selectedIndex` synchronously *before* the
1444
+ * Material→presenter subscription forwards the click to
1445
+ * `onMaterialSelection`. When the presenter HOLDS its index
1446
+ * (pessimistic mode + bound `commitAction`, or any future contract
1447
+ * that refuses a select), the presenter→Material `effect()` does
1448
+ * NOT fire — `presenterIndex` did not change — so Material's
1449
+ * eager-advance is never reverted, and the visual diverges from the
1450
+ * cngx semantic state. Closes `tabs-accepted-debt §6` by force-
1451
+ * writing Material back to the presenter's value when the
1452
+ * forwarding callback returns and the values still diverge. Idempotent
1453
+ * with the regular presenter→Material effect (the read-equality guard
1454
+ * at the effect site suppresses a duplicate write when the presenter
1455
+ * later changes to the same value).
1456
+ */
1457
+ declare function createMaterialBidirectionalSync(opts: CngxMaterialBidirectionalSyncOptions): void;
1458
+
1459
+ export { CNGX_COMMIT_CONTROLLER_FACTORY, CNGX_RECYCLER_I18N, CngxAsync, CngxDataSource, CngxFilter, CngxFilterChip, CngxFilterChips, CngxMeasure, CngxMetric, CngxPaginate, CngxRecyclerAnnouncer, CngxSmartDataSource, CngxSort, CngxSortHeader, CngxTrend, CngxVirtualItem, connectRecyclerToActiveDescendant, connectRecyclerToRoving, createAsyncState, createCommitController, createManualState, createMaterialBidirectionalSync, injectAsyncState, injectDataSource, injectRecycler, injectSmartDataSource, provideRecyclerI18n, resolveAsyncView };
1460
+ export type { AsyncView, CngxAsyncContext, CngxCommitBeginHandlers, CngxCommitController, CngxCommitControllerFactory, CngxCommitHandle, CngxCommitRunner, CngxFilterChipContext, CngxMaterialBidirectionalSyncOptions, CngxRecycler, CngxSmartDataSourceOptions, InjectAsyncStateOptions, ManualAsyncState, MutableAsyncState, ReactiveAsyncState, RecyclerConfig, RecyclerI18n, SortEntry };