@cngx/common 0.0.1-rc.0 → 0.1.0-rc.1

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 (61) hide show
  1. package/a11y/README.md +13 -16
  2. package/card/README.md +2 -21
  3. package/chart/README.md +5 -8
  4. package/data/README.md +45 -47
  5. package/dialog/README.md +12 -15
  6. package/display/README.md +5 -9
  7. package/fesm2022/cngx-common-a11y.mjs +164 -51
  8. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  9. package/fesm2022/cngx-common-card.mjs +157 -69
  10. package/fesm2022/cngx-common-card.mjs.map +1 -1
  11. package/fesm2022/cngx-common-chart.mjs +389 -92
  12. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  13. package/fesm2022/cngx-common-data.mjs +311 -151
  14. package/fesm2022/cngx-common-data.mjs.map +1 -1
  15. package/fesm2022/cngx-common-dialog.mjs +167 -29
  16. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  17. package/fesm2022/cngx-common-display.mjs +445 -110
  18. package/fesm2022/cngx-common-display.mjs.map +1 -1
  19. package/fesm2022/cngx-common-interactive.mjs +2059 -435
  20. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  21. package/fesm2022/cngx-common-layout.mjs +188 -31
  22. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  23. package/fesm2022/cngx-common-popover.mjs +711 -90
  24. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  25. package/fesm2022/cngx-common-stepper.mjs +1479 -73
  26. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  27. package/fesm2022/cngx-common-tabs.mjs +1144 -85
  28. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  29. package/fesm2022/cngx-common.mjs +2 -2
  30. package/fesm2022/cngx-common.mjs.map +1 -1
  31. package/interactive/README.md +5 -5
  32. package/layout/README.md +2 -2
  33. package/package.json +7 -6
  34. package/popover/README.md +8 -34
  35. package/stepper/README.md +69 -8
  36. package/tabs/README.md +6 -6
  37. package/theming/components/cngx-async.css +74 -0
  38. package/theming/components/cngx-backdrop.css +73 -0
  39. package/theming/components/cngx-badge.css +340 -0
  40. package/theming/components/cngx-bottom-sheet.css +201 -0
  41. package/theming/components/cngx-button-toggle.css +99 -0
  42. package/theming/components/cngx-dialog.css +358 -0
  43. package/theming/components/cngx-divider.css +145 -0
  44. package/theming/components/cngx-listbox.css +220 -0
  45. package/theming/components/cngx-menu.css +371 -0
  46. package/theming/components/cngx-ripple.css +116 -0
  47. package/theming/components/cngx-tooltip.css +265 -0
  48. package/theming/system-tokens.css +24 -0
  49. package/types/cngx-common-a11y.d.ts +159 -38
  50. package/types/cngx-common-card.d.ts +137 -22
  51. package/types/cngx-common-chart.d.ts +337 -40
  52. package/types/cngx-common-data.d.ts +277 -45
  53. package/types/cngx-common-dialog.d.ts +162 -22
  54. package/types/cngx-common-display.d.ts +422 -78
  55. package/types/cngx-common-interactive.d.ts +1880 -305
  56. package/types/cngx-common-layout.d.ts +191 -28
  57. package/types/cngx-common-popover.d.ts +632 -87
  58. package/types/cngx-common-stepper.d.ts +1360 -45
  59. package/types/cngx-common-tabs.d.ts +1139 -56
  60. package/types/cngx-common.d.ts +1 -1
  61. package/README.md +0 -18
@@ -5,6 +5,7 @@ import { CngxChip } from '@cngx/common/display';
5
5
  import { CngxMultiChipGroup, CngxChipInGroup, CngxSearch } from '@cngx/common/interactive';
6
6
  import { DataSource } from '@angular/cdk/collections';
7
7
  import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
8
+ import { arrayEqual } from '@cngx/utils';
8
9
  import { buildAsyncStateView, createTransitionTracker } from '@cngx/core/utils';
9
10
  import { isObservable, firstValueFrom, defer, tap, filter, map } from 'rxjs';
10
11
 
@@ -13,7 +14,7 @@ import { isObservable, firstValueFrom, defer, tap, filter, map } from 'rxjs';
13
14
  *
14
15
  * Supports both **uncontrolled** (internal state) and **controlled** modes.
15
16
  * In controlled mode the `cngxSortActive` / `cngxSortDirection` inputs take
16
- * precedence over the internal state — pair with `sortChange` to keep them
17
+ * precedence over the internal state - pair with `sortChange` to keep them
17
18
  * in sync.
18
19
  *
19
20
  * When `multiSort` is `true`, holding **Shift** while clicking a sort header
@@ -21,8 +22,22 @@ import { isObservable, firstValueFrom, defer, tap, filter, map } from 'rxjs';
21
22
  * primary one. Shift-clicking an active column cycles it asc → desc → removed.
22
23
  * Multi-sort state is always uncontrolled; use `sortsChange` to read it.
23
24
  *
24
- * Consumer connects this to a table or list via a `computed()` — nothing is
25
+ * Consumer connects this to a table or list via a `computed()` - nothing is
25
26
  * injected automatically.
27
+ *
28
+ * @category common/data/sort
29
+ * @docsKind primary
30
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/sort/sort.directive.ts
31
+ * @since 0.1.0
32
+ * @relatedTo CngxSortHeader, CngxFilter, CngxPaginate, CngxSmartDataSource
33
+ *
34
+ * <example-url>http://localhost:4200/#/common/data/sort/basic</example-url>
35
+ * <example-url>http://localhost:4200/#/common/data/sort/multi-sort</example-url>
36
+ * <example-url>http://localhost:4200/#/common/data/sort/controlled</example-url>
37
+ * <example-url>http://localhost:4200/#/common/data/sort/aria-and-keyboard</example-url>
38
+ // * <example-url>http://localhost:4200/#/common/data/smart-data-source/auto-wired</example-url>
39
+ // * <example-url>http://localhost:4200/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
40
+ // * <example-url>http://localhost:4200/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
26
41
  */
27
42
  class CngxSort {
28
43
  /** Controlled active column. When bound, takes precedence over internal state (single-sort only). */
@@ -119,7 +134,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
119
134
  * Molecule directive for sort-header elements.
120
135
  *
121
136
  * Apply to any clickable header element. Consumer provides an explicit
122
- * `[cngxSortRef]` binding — no ancestor injection, no hidden wiring.
137
+ * `[cngxSortRef]` binding - no ancestor injection, no hidden wiring.
123
138
  *
124
139
  * In multi-sort mode, Shift+click adds this column to the sort stack.
125
140
  * The `priority()` signal returns the 1-based position in the stack
@@ -136,6 +151,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
136
151
  * </button>
137
152
  * </div>
138
153
  * ```
154
+ *
155
+ * @category common/data/sort
156
+ * @docsKind primary
157
+ * @wcag AA
158
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/sort/sort-header.directive.ts
159
+ * @since 0.1.0
160
+ * @relatedTo CngxSort, CngxFilter, CngxPaginate
161
+ *
162
+ * <example-url>http://localhost:4200/#/common/data/sort/basic</example-url>
163
+ * <example-url>http://localhost:4200/#/common/data/sort/multi-sort</example-url>
164
+ * <example-url>http://localhost:4200/#/common/data/sort/controlled</example-url>
165
+ * <example-url>http://localhost:4200/#/common/data/sort/aria-and-keyboard</example-url>
139
166
  */
140
167
  class CngxSortHeader {
141
168
  /** The field key this header cell represents. */
@@ -197,13 +224,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
197
224
  *
198
225
  * Supports both **uncontrolled** (internal state) and **controlled** modes.
199
226
  * In controlled mode the `cngxFilter` input takes precedence over the internal
200
- * `'default'` predicate — pair with `filterChange` to keep it in sync.
227
+ * `'default'` predicate - pair with `filterChange` to keep it in sync.
201
228
  *
202
- * **Multi-filter** — use `addPredicate(key, fn)` / `removePredicate(key)` to
229
+ * **Multi-filter** - use `addPredicate(key, fn)` / `removePredicate(key)` to
203
230
  * maintain a named stack of predicates. All active predicates are **AND-combined**
204
231
  * across keys: an item must pass every registered predicate to appear in results.
205
232
  *
206
- * AND vs OR — the directive enforces AND across dimensions (keys). OR logic
233
+ * AND vs OR - the directive enforces AND across dimensions (keys). OR logic
207
234
  * within a single dimension stays inside the predicate function itself:
208
235
  *
209
236
  * ```typescript
@@ -211,17 +238,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
211
238
  * filter.addPredicate('location', p => selectedLocations.has(p.location));
212
239
  * filter.addPredicate('role', p => selectedRoles.has(p.role));
213
240
  *
214
- * // OR within a dimension: London OR Rome — just put a Set inside one predicate
241
+ * // OR within a dimension: London OR Rome - just put a Set inside one predicate
215
242
  * filter.addPredicate('location', p => selectedLocations.has(p.location));
216
243
  * ```
217
244
  *
218
245
  * `setPredicate` / `clear` operate on the `'default'` key and remain fully
219
246
  * backward-compatible with single-predicate usage.
220
247
  *
221
- * Consumer connects this to a list via a `computed()` — nothing is injected
248
+ * Consumer connects this to a list via a `computed()` - nothing is injected
222
249
  * automatically.
223
250
  *
224
251
  * @typeParam T - The item type the predicate operates on.
252
+ *
253
+ * @category common/data/filter
254
+ * @docsKind primary
255
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter/filter.directive.ts
256
+ * @since 0.1.0
257
+ * @relatedTo CngxFilterChips, CngxSort, CngxPaginate, CngxSmartDataSource
258
+ *
259
+ * <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
260
+ * <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
261
+ * <example-url>http://localhost:4200/#/common/data/smart-data-source/auto-wired</example-url>
262
+ * <example-url>http://localhost:4200/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
263
+ * <example-url>http://localhost:4200/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
225
264
  */
226
265
  class CngxFilter {
227
266
  /** Controlled predicate. When bound, takes precedence over the `'default'` internal predicate. */
@@ -235,7 +274,7 @@ class CngxFilter {
235
274
  /** Number of active named predicates (controlled input not counted). */
236
275
  activeCount = computed(() => this.predicatesState().size, ...(ngDevMode ? [{ debugName: "activeCount" }] : /* istanbul ignore next */ []));
237
276
  /**
238
- * The combined predicate — AND of all active named predicates plus the
277
+ * The combined predicate - AND of all active named predicates plus the
239
278
  * controlled input (when bound). Returns `null` when nothing is active.
240
279
  */
241
280
  predicate = computed(() => {
@@ -317,6 +356,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
317
356
  * `<ng-template cngxFilterChip>` to project decoration; the bridge
318
357
  * wraps that decoration in `cngxChipInGroup`-bound chip wrappers
319
358
  * automatically. Absence falls back to the default text-only label.
359
+ *
360
+ * @category common/data/filter
361
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter-chips/filter-chips.component.ts
362
+ * @since 0.1.0
363
+ * @relatedTo CngxFilterChips, CngxFilter
364
+ *
365
+ * <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
366
+ * <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
320
367
  */
321
368
  class CngxFilterChip {
322
369
  template = inject(TemplateRef);
@@ -335,7 +382,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
335
382
  }] });
336
383
  /**
337
384
  * Bridge that connects a multi-select chip strip to a `CngxFilter`
338
- * predicate via Pillar-1 derivation — no `effect()` write-back, no
385
+ * predicate via Pillar-1 derivation - no `effect()` write-back, no
339
386
  * manual sync. The bridge composes `<cngx-multi-chip-group>` for
340
387
  * the visible chip strip and registers a single closure-style
341
388
  * predicate on the parent `[filterRef]`. Chip toggles update
@@ -348,7 +395,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
348
395
  * is intentionally out of scope. Consumers needing a single-select
349
396
  * filter wire `<cngx-chip-group>` to a custom predicate themselves.
350
397
  *
351
- * **Sync contract — derivation, not effect.** The bridge calls
398
+ * **Sync contract - derivation, not effect.** The bridge calls
352
399
  * `filterRef.addPredicate(filterKey, predicateFn)` EXACTLY ONCE
353
400
  * during mount (in `afterNextRender`, because `input.required()`
354
401
  * cannot be read from the constructor body). `predicateFn` is a
@@ -356,12 +403,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
356
403
  * `this.optionValueFn()` on every invocation. Because
357
404
  * `CngxFilter.predicate` is itself a `computed()` consumed by
358
405
  * downstream filtered lists, each item-evaluation flows through
359
- * `selectedValues()` in the consumer's reactive context — chip
406
+ * `selectedValues()` in the consumer's reactive context - chip
360
407
  * toggles propagate without any `effect()` writing back into the
361
408
  * filter.
362
409
  *
363
410
  * **Empty-selection semantics.** When `selectedValues()` is `[]`,
364
- * the closure returns `true` for every item — equivalent to "no
411
+ * the closure returns `true` for every item - equivalent to "no
365
412
  * filter applied". The bridge deliberately does NOT call
366
413
  * `removePredicate` on empty selection: leaving the predicate
367
414
  * registered with a constant-`true` short-circuit is cheaper than
@@ -369,7 +416,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
369
416
  * predicate-stack stable (no `predicatesChange` emission churn).
370
417
  *
371
418
  * **Teardown.** `DestroyRef.onDestroy` calls `removePredicate` only
372
- * when registration actually happened (`registered` flag) — guards
419
+ * when registration actually happened (`registered` flag) - guards
373
420
  * against the case where the component is destroyed before
374
421
  * `afterNextRender` fires. The destroy callback reads `filterRef`
375
422
  * and `filterKey` lazily so a consumer that re-binds these between
@@ -392,6 +439,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
392
439
  * }
393
440
  * </ng-container>
394
441
  * ```
442
+ *
443
+ * @category common/data/filter
444
+ * @docsKind primary
445
+ * @wcag AA
446
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter-chips/filter-chips.component.ts
447
+ * @since 0.1.0
448
+ * @relatedTo CngxFilter, CngxFilterChip, CngxMultiChipGroup
449
+ *
450
+ * <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
451
+ * <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
395
452
  */
396
453
  class CngxFilterChips {
397
454
  label = input.required(...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
@@ -419,7 +476,7 @@ class CngxFilterChips {
419
476
  * primitive id), this fn extracts a stable identity key so chip
420
477
  * membership survives re-emissions with fresh references. Forwarded
421
478
  * to the inner `<cngx-multi-chip-group>` AND used inside the
422
- * predicate's `Object.is` comparison. Defaults to identity — works
479
+ * predicate's `Object.is` comparison. Defaults to identity - works
423
480
  * for primitive values.
424
481
  */
425
482
  keyFn = input((v) => v, ...(ngDevMode ? [{ debugName: "keyFn" }] : /* istanbul ignore next */ []));
@@ -438,7 +495,7 @@ class CngxFilterChips {
438
495
  * closure invokes it again per LIST item for membership filtering.
439
496
  * Both invocations are necessary because option items (the chip
440
497
  * pool) and filtered list items (the consumer's filtered data) are
441
- * separate data paths — they happen to share a shape under the
498
+ * separate data paths - they happen to share a shape under the
442
499
  * Phase-5 single-shape limitation, but the bridge cannot memoise
443
500
  * across the two paths without conflating them. Consumers should
444
501
  * keep `optionValue` cheap (typically a property lookup); a future
@@ -499,9 +556,7 @@ class CngxFilterChips {
499
556
  @for (option of options(); track keyFn()(optionValue()(option))) {
500
557
  <cngx-chip cngxChipInGroup [value]="optionValue()(option)">
501
558
  @if (chipTemplate()?.template; as tpl) {
502
- <ng-container
503
- *ngTemplateOutlet="tpl; context: chipContext(option)"
504
- />
559
+ <ng-container *ngTemplateOutlet="tpl; context: chipContext(option)" />
505
560
  } @else {
506
561
  {{ optionLabel()(option) }}
507
562
  }
@@ -533,9 +588,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
533
588
  @for (option of options(); track keyFn()(optionValue()(option))) {
534
589
  <cngx-chip cngxChipInGroup [value]="optionValue()(option)">
535
590
  @if (chipTemplate()?.template; as tpl) {
536
- <ng-container
537
- *ngTemplateOutlet="tpl; context: chipContext(option)"
538
- />
591
+ <ng-container *ngTemplateOutlet="tpl; context: chipContext(option)" />
539
592
  } @else {
540
593
  {{ optionLabel()(option) }}
541
594
  }
@@ -551,10 +604,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
551
604
  *
552
605
  * Supports both **uncontrolled** (internal state) and **controlled** modes.
553
606
  * In controlled mode the `cngxPageIndex` / `cngxPageSize` inputs take precedence
554
- * over internal state — pair with `pageChange` / `pageSizeChange` to keep them
607
+ * over internal state - pair with `pageChange` / `pageSizeChange` to keep them
555
608
  * in sync.
556
609
  *
557
- * Consumer connects this to a list or table via `range()` — nothing is injected
610
+ * Consumer connects this to a list or table via `range()` - nothing is injected
558
611
  * automatically.
559
612
  *
560
613
  * // Headless: read range() from a template ref
@@ -564,6 +617,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
564
617
  *
565
618
  * // With CngxMatPaginator:
566
619
  * <cngx-mat-paginator [cngxPaginateRef]="pg" />
620
+ *
621
+ * @category common/data/paginate
622
+ * @docsKind primary
623
+ * @wcag AA
624
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate.directive.ts
625
+ * @since 0.1.0
626
+ * @relatedTo CngxSort, CngxFilter, CngxSmartDataSource
627
+ *
628
+ * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
629
+ * <example-url>http://localhost:4200/#/common/data/data-source/signal-observable-bridge</example-url>
630
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
631
+ * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
632
+ * <example-url>http://localhost:4200/#/common/data/smart-data-source/auto-wired</example-url>
633
+ * <example-url>http://localhost:4200/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
634
+ * <example-url>http://localhost:4200/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
567
635
  */
568
636
  class CngxPaginate {
569
637
  /** Controlled page index. When bound, takes precedence over internal state. */
@@ -576,7 +644,7 @@ class CngxPaginate {
576
644
  */
577
645
  total = input(0, ...(ngDevMode ? [{ debugName: "total" }] : /* istanbul ignore next */ []));
578
646
  /**
579
- * Bind an async state — disables navigation while the data source is busy.
647
+ * Bind an async state - disables navigation while the data source is busy.
580
648
  * When set, `isBusy` derives from `state.isBusy()`. Navigation methods
581
649
  * (`setPage`, `next`, `previous`, etc.) are no-ops while busy.
582
650
  */
@@ -600,7 +668,7 @@ class CngxPaginate {
600
668
  /** `true` when on the last page. */
601
669
  isLast = computed(() => this.pageIndex() >= this.totalPages() - 1, ...(ngDevMode ? [{ debugName: "isLast" }] : /* istanbul ignore next */ []));
602
670
  /**
603
- * `[start, end]` indices for `Array.slice()` — always in-bounds.
671
+ * `[start, end]` indices for `Array.slice()` - always in-bounds.
604
672
  * Consumer: `items.slice(range()[0], range()[1])`.
605
673
  */
606
674
  range = computed(() => {
@@ -670,7 +738,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
670
738
  * Minimal CDK `DataSource` that bridges a Signal to the CDK table's
671
739
  * Observable-based data contract.
672
740
  *
673
- * No sort, filter, or search logic is included — the consumer builds a
741
+ * No sort, filter, or search logic is included - the consumer builds a
674
742
  * `computed()` with any transformations and passes the result here.
675
743
  *
676
744
  * ```typescript
@@ -683,6 +751,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
683
751
  * ```
684
752
  *
685
753
  * @typeParam T - The row item type.
754
+ *
755
+ * @category common/data/data-source
756
+ * @docsKind primary
757
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/data-source/data-source.ts
758
+ * @since 0.1.0
759
+ * @relatedTo CngxSmartDataSource, CngxSort, CngxFilter, CngxPaginate
686
760
  */
687
761
  class CngxDataSource extends DataSource {
688
762
  data;
@@ -695,7 +769,7 @@ class CngxDataSource extends DataSource {
695
769
  return toObservable(this.data, { injector: this.injector });
696
770
  }
697
771
  disconnect() {
698
- // Signal cleanup is handled by Angular's DestroyRef — no manual teardown needed.
772
+ // Signal cleanup is handled by Angular's DestroyRef - no manual teardown needed.
699
773
  }
700
774
  }
701
775
  /**
@@ -706,18 +780,37 @@ class CngxDataSource extends DataSource {
706
780
  * ```typescript
707
781
  * readonly dataSource = injectDataSource(this.items);
708
782
  * ```
783
+ *
784
+ * @category common/data/data-source
709
785
  */
710
786
  function injectDataSource(data) {
711
787
  return new CngxDataSource(data);
712
788
  }
713
789
 
790
+ function defaultSearchFn(item, term) {
791
+ const lower = term.toLowerCase();
792
+ return Object.values(item).some((v) => v === null || v === undefined || typeof v === 'object'
793
+ ? false
794
+ : String(v)
795
+ .toLowerCase()
796
+ .includes(lower));
797
+ }
798
+ function defaultSortFn(a, b, field, dir) {
799
+ const toStr = (v) => v === null || v === undefined || typeof v === 'object'
800
+ ? ''
801
+ : String(v);
802
+ const av = toStr(a[field]);
803
+ const bv = toStr(b[field]);
804
+ const cmp = av.localeCompare(bv, undefined, { numeric: true, sensitivity: 'base' });
805
+ return dir === 'asc' ? cmp : -cmp;
806
+ }
714
807
  function isAsyncState(source) {
715
808
  return 'status' in source && 'data' in source && 'isFirstLoad' in source;
716
809
  }
717
810
  /**
718
811
  * A CDK `DataSource` that optionally integrates with `CngxSort`,
719
812
  * `CngxFilter`, `CngxSearch`, and `CngxPaginate` present in the injection
720
- * tree. Each directive is injected optionally — if absent, that processing
813
+ * tree. Each directive is injected optionally - if absent, that processing
721
814
  * step is skipped.
722
815
  *
723
816
  * Accepts either a plain `Signal<T[]>` or a `CngxAsyncState<T[]>`.
@@ -729,13 +822,19 @@ function isAsyncState(source) {
729
822
  * // Plain signal
730
823
  * readonly dataSource = injectSmartDataSource(this.items);
731
824
  *
732
- * // With async state — full UX lifecycle
825
+ * // With async state - full UX lifecycle
733
826
  * readonly residents = injectAsyncState(() => this.api.getAll(this.filter()));
734
827
  * readonly dataSource = injectSmartDataSource(this.residents);
735
828
  * // dataSource.isLoading(), dataSource.error(), dataSource.isRefreshing()
736
829
  * ```
737
830
  *
738
831
  * @typeParam T - The row item type.
832
+ *
833
+ * @category common/data/data-source
834
+ * @docsKind primary
835
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/data-source/smart-data-source.ts
836
+ * @since 0.1.0
837
+ * @relatedTo CngxDataSource, CngxSort, CngxFilter, CngxPaginate
739
838
  */
740
839
  class CngxSmartDataSource extends DataSource {
741
840
  options;
@@ -756,7 +855,12 @@ class CngxSmartDataSource extends DataSource {
756
855
  /** Number of items after filtering/searching, before pagination. */
757
856
  filteredCount;
758
857
  processed;
759
- /** The async state source, or `undefined` if constructed from a plain signal. */
858
+ /**
859
+ * The async state source, or `undefined` if constructed from a plain
860
+ * signal. Internal-only - consumers read the derived projections
861
+ * (`isLoading`, `isRefreshing`, `isBusy`, `isFirstLoad`, `error`,
862
+ * `isEmpty`, `filteredCount`) instead of the raw source identity.
863
+ */
760
864
  asyncState;
761
865
  /** `true` during initial data load (skeleton phase). */
762
866
  isLoading;
@@ -791,23 +895,15 @@ class CngxSmartDataSource extends DataSource {
791
895
  this.filtered = computed(() => {
792
896
  const predicate = this.filter?.predicate();
793
897
  const term = this.search?.term();
794
- const searchFn = this.options?.searchFn ??
795
- ((item, t) => {
796
- const lower = t.toLowerCase();
797
- return Object.values(item).some((v) => v === null || v === undefined || typeof v === 'object'
798
- ? false
799
- : String(v)
800
- .toLowerCase()
801
- .includes(lower));
802
- });
898
+ const searchFn = this.options?.searchFn ?? (defaultSearchFn);
803
899
  // Pipeline: raw → filter → search. Cast required: CngxFilter injected as unknown.
804
900
  return data()
805
901
  .filter((v) => !predicate || predicate(v))
806
902
  .filter((item) => !term || searchFn(item, term));
807
- }, ...(ngDevMode ? [{ debugName: "filtered" }] : /* istanbul ignore next */ []));
903
+ }, { ...(ngDevMode ? { debugName: "filtered" } : /* istanbul ignore next */ {}), equal: arrayEqual });
808
904
  this.filteredCount = computed(() => this.filtered().length, ...(ngDevMode ? [{ debugName: "filteredCount" }] : /* istanbul ignore next */ []));
809
905
  this.isEmpty = computed(() => {
810
- // During loading, not "empty" yet — show skeleton instead
906
+ // During loading, not "empty" yet - show skeleton instead
811
907
  if (this.isBusy()) {
812
908
  return false;
813
909
  }
@@ -815,28 +911,19 @@ class CngxSmartDataSource extends DataSource {
815
911
  }, ...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
816
912
  this.processed = computed(() => {
817
913
  const sorts = this.sort?.sorts() ?? [];
818
- const sortFn = this.options?.sortFn ??
819
- ((a, b, field, dir) => {
820
- const toStr = (v) => v === null || v === undefined || typeof v === 'object'
821
- ? ''
822
- : String(v);
823
- const av = toStr(a[field]);
824
- const bv = toStr(b[field]);
825
- const cmp = av.localeCompare(bv, undefined, { numeric: true, sensitivity: 'base' });
826
- return dir === 'asc' ? cmp : -cmp;
827
- });
914
+ const sortFn = this.options?.sortFn ?? (defaultSortFn);
828
915
  const sorted = sorts.length > 0
829
916
  ? [...this.filtered()].sort((a, b) => sorts.reduce((cmp, { active, direction }) => cmp || sortFn(a, b, active, direction), 0))
830
917
  : this.filtered();
831
918
  const range = this.paginate?.range();
832
919
  return range ? sorted.slice(range[0], range[1]) : sorted;
833
- }, ...(ngDevMode ? [{ debugName: "processed" }] : /* istanbul ignore next */ []));
920
+ }, { ...(ngDevMode ? { debugName: "processed" } : /* istanbul ignore next */ {}), equal: arrayEqual });
834
921
  }
835
922
  connect() {
836
923
  return toObservable(this.processed, { injector: this.injector });
837
924
  }
838
925
  disconnect() {
839
- // Signal cleanup is handled by Angular's DestroyRef — no manual teardown needed.
926
+ // Signal cleanup is handled by Angular's DestroyRef - no manual teardown needed.
840
927
  }
841
928
  }
842
929
  /**
@@ -850,10 +937,12 @@ class CngxSmartDataSource extends DataSource {
850
937
  * // Plain signal
851
938
  * readonly dataSource = injectSmartDataSource(this.items);
852
939
  *
853
- * // With async state — table shows skeleton, error, loading bar
940
+ * // With async state - table shows skeleton, error, loading bar
854
941
  * readonly residents = injectAsyncState(() => this.api.getAll());
855
942
  * readonly dataSource = injectSmartDataSource(this.residents);
856
943
  * ```
944
+ *
945
+ * @category common/data/data-source
857
946
  */
858
947
  function injectSmartDataSource(source, options) {
859
948
  return new CngxSmartDataSource(source, options);
@@ -875,6 +964,8 @@ function injectSmartDataSource(source, options) {
875
964
  * this.processState.setSuccess(result);
876
965
  * }
877
966
  * ```
967
+ *
968
+ * @category common/data/async-state
878
969
  */
879
970
  function createManualState() {
880
971
  const statusState = signal('idle', ...(ngDevMode ? [{ debugName: "statusState" }] : /* istanbul ignore next */ []));
@@ -942,6 +1033,8 @@ function createManualState() {
942
1033
  * );
943
1034
  * }
944
1035
  * ```
1036
+ *
1037
+ * @category common/data/async-state
945
1038
  */
946
1039
  function createAsyncState() {
947
1040
  const destroyRef = inject(DestroyRef);
@@ -974,7 +1067,6 @@ function createAsyncState() {
974
1067
  try {
975
1068
  const result$ = fn();
976
1069
  const result = isObservable(result$) ? await firstValueFrom(result$) : await result$;
977
- // Check if this execution was superseded
978
1070
  if (controller.signal.aborted) {
979
1071
  return;
980
1072
  }
@@ -1018,6 +1110,8 @@ function createAsyncState() {
1018
1110
  * // Caches last result during refresh (refreshing state).
1019
1111
  * // Deduplicates parallel requests.
1020
1112
  * ```
1113
+ *
1114
+ * @category common/data/async-state
1021
1115
  */
1022
1116
  function injectAsyncState(fn, options) {
1023
1117
  const destroyRef = inject(DestroyRef);
@@ -1041,12 +1135,11 @@ function injectAsyncState(fn, options) {
1041
1135
  });
1042
1136
  function executeQuery(computation) {
1043
1137
  cancelInFlight();
1044
- // First load → 'loading', subsequent → 'refreshing'
1138
+ // first load -> loading, subsequent -> refreshing
1045
1139
  const status = untracked(state.isFirstLoad) ? 'loading' : 'refreshing';
1046
1140
  state.set(status);
1047
1141
  const result$ = computation();
1048
1142
  if (isObservable(result$)) {
1049
- // Observable path — subscribe, cancel via unsubscribe
1050
1143
  let hasEmitted = false;
1051
1144
  activeSubscription = result$.subscribe({
1052
1145
  next: (value) => {
@@ -1056,14 +1149,13 @@ function injectAsyncState(fn, options) {
1056
1149
  error: (err) => state.setError(err),
1057
1150
  complete: () => {
1058
1151
  if (!hasEmitted) {
1059
- // Observable completed without emitting — treat as empty success
1152
+ // completed without emitting -> empty success
1060
1153
  state.setSuccess(undefined);
1061
1154
  }
1062
1155
  },
1063
1156
  });
1064
1157
  }
1065
1158
  else {
1066
- // Promise path — cancel via AbortController
1067
1159
  const controller = new AbortController();
1068
1160
  abortController = controller;
1069
1161
  result$
@@ -1083,18 +1175,16 @@ function injectAsyncState(fn, options) {
1083
1175
  });
1084
1176
  }
1085
1177
  }
1086
- // The effect calls fn() exactly once per cycle.
1087
- // The result is captured and forwarded to executeQuery — no double invocation.
1178
+ // fn() runs once per cycle; signals read inside it track via effect.
1179
+ // Result is captured and run after debounce.
1088
1180
  effect(() => {
1089
- // fn() reads signals → tracked by effect. The returned Promise/Observable
1090
- // is captured here and executed after debounce.
1091
1181
  let result;
1092
1182
  try {
1093
1183
  result = fn();
1094
1184
  }
1095
1185
  catch (err) {
1096
- // fn() threw synchronously (e.g. required signal not yet set).
1097
- // Schedule error state after debounce to match async behavior.
1186
+ // sync throw (e.g. required signal not yet set) — debounce the error
1187
+ // to match the async path
1098
1188
  if (debounceTimer !== undefined) {
1099
1189
  clearTimeout(debounceTimer);
1100
1190
  }
@@ -1107,7 +1197,6 @@ function injectAsyncState(fn, options) {
1107
1197
  if (debounceTimer !== undefined) {
1108
1198
  clearTimeout(debounceTimer);
1109
1199
  }
1110
- // Capture result in closure — executeQuery receives it directly.
1111
1200
  const captured = result;
1112
1201
  debounceTimer = setTimeout(() => {
1113
1202
  debounceTimer = undefined;
@@ -1153,6 +1242,8 @@ function injectAsyncState(fn, options) {
1153
1242
  * | success | * | true | empty |
1154
1243
  * | error | false | * | content+error |
1155
1244
  * | (all other) | * | * | content |
1245
+ *
1246
+ * @category common/data/async-state
1156
1247
  */
1157
1248
  function resolveAsyncView(status, firstLoad, empty) {
1158
1249
  if (firstLoad) {
@@ -1197,6 +1288,8 @@ function resolveAsyncView(status, firstLoad, empty) {
1197
1288
  * // items.status(), items.data(), items.isFirstLoad() — all work
1198
1289
  * // <cngx-async-container [state]="items"> — direct binding
1199
1290
  * ```
1291
+ *
1292
+ * @category common/data/async-state
1200
1293
  */
1201
1294
  function fromResource(ref) {
1202
1295
  // Track whether a successful load has ever occurred.
@@ -1281,6 +1374,8 @@ function fromResource(ref) {
1281
1374
  * // items.progress() tracks upload/download progress
1282
1375
  * // <cngx-progress [state]="items"> — auto-wired progress bar
1283
1376
  * ```
1377
+ *
1378
+ * @category common/data/async-state
1284
1379
  */
1285
1380
  function fromHttpResource(ref) {
1286
1381
  const hadSuccess = signal(false, ...(ngDevMode ? [{ debugName: "hadSuccess" }] : /* istanbul ignore next */ []));
@@ -1372,6 +1467,8 @@ function fromHttpResource(ref) {
1372
1467
  * ).subscribe();
1373
1468
  * }
1374
1469
  * ```
1470
+ *
1471
+ * @category common/data/async-state
1375
1472
  */
1376
1473
  function tapAsyncState(state, options) {
1377
1474
  return (source) => defer(() => {
@@ -1408,6 +1505,8 @@ const RESPONSE = 4;
1408
1505
  * ).subscribe();
1409
1506
  * }
1410
1507
  * ```
1508
+ *
1509
+ * @category common/data/async-state
1411
1510
  */
1412
1511
  function tapAsyncProgress(state) {
1413
1512
  return tap((event) => {
@@ -1447,6 +1546,8 @@ function tapAsyncProgress(state) {
1447
1546
  * // upload.status(), upload.progress(), upload.data() — all wired
1448
1547
  * }
1449
1548
  * ```
1549
+ *
1550
+ * @category common/data/async-state
1450
1551
  */
1451
1552
  function tapHttpAsyncState(state, options) {
1452
1553
  return (source) => defer(() => {
@@ -1476,7 +1577,7 @@ function tapHttpAsyncState(state, options) {
1476
1577
  * - **refreshing / loading (with data)** → content template (old data stays visible)
1477
1578
  * - **error (with data)** → content template (old data stays visible)
1478
1579
  *
1479
- * ### Minimal — just content
1580
+ * ### Minimal - just content
1480
1581
  * ```html
1481
1582
  * <ul *cngxAsync="residents; let data">
1482
1583
  * @for (r of data; track r.id) { <li>{{ r.name }}</li> }
@@ -1501,6 +1602,20 @@ function tapHttpAsyncState(state, options) {
1501
1602
  * <li>Error: {{ err }}</li>
1502
1603
  * </ng-template>
1503
1604
  * ```
1605
+ *
1606
+ * @category common/data/async-state
1607
+ * @docsKind primary
1608
+ * @wcag AA
1609
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async/async.directive.ts
1610
+ * @since 0.1.0
1611
+ * @relatedTo injectAsyncState, createAsyncState, createManualState
1612
+ *
1613
+ * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngx-async-container-full-control-toast</example-url>
1614
+ * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngxasync-one-line</example-url>
1615
+ * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngxasync-with-custom-templates</example-url>
1616
+ * <example-url>http://localhost:4200/#/ui/feedback/async-container/composition-overlay-container-toast</example-url>
1617
+ * <example-url>http://localhost:4200/#/ui/feedback/async-container/createasyncstate-mutation</example-url>
1618
+ * <example-url>http://localhost:4200/#/ui/feedback/async-container/injectasyncstate-reactive-query</example-url>
1504
1619
  */
1505
1620
  class CngxAsync {
1506
1621
  vcr = inject(ViewContainerRef);
@@ -1595,7 +1710,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1595
1710
  * Uses `Intl.NumberFormat` with the injected `LOCALE_ID` for locale-aware
1596
1711
  * formatting. Null values render as an em-dash.
1597
1712
  *
1598
- * Composable — works inside any card variant, header, body, or standalone.
1713
+ * Composable - works inside any card variant, header, body, or standalone.
1599
1714
  *
1600
1715
  * ### Basic
1601
1716
  * ```html
@@ -1614,10 +1729,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1614
1729
  * <cngx-metric cngxCardBody [value]="75" unit="bpm" />
1615
1730
  * </cngx-card>
1616
1731
  * ```
1732
+ *
1733
+ * @category common/data/metric
1734
+ * @docsKind primary
1735
+ * @wcag AA
1736
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/metric/metric.component.ts
1737
+ * @since 0.1.0
1738
+ * @relatedTo CngxTrend, CngxCard
1739
+ *
1740
+ * <example-url>http://localhost:4200/#/common/data/metric/inside-a-card</example-url>
1741
+ * <example-url>http://localhost:4200/#/common/data/metric/standalone-metrics</example-url>
1617
1742
  */
1618
1743
  class CngxMetric {
1619
1744
  locale = inject(LOCALE_ID);
1620
- /** Numeric or string value. `null` renders as em-dash. */
1745
+ /** Numeric or string value. `null` renders as a placeholder hyphen. */
1621
1746
  value = input.required(...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
1622
1747
  /** Unit suffix (e.g. "bpm", "h", "%", "kg"). */
1623
1748
  unit = input(undefined, ...(ngDevMode ? [{ debugName: "unit" }] : /* istanbul ignore next */ []));
@@ -1648,26 +1773,19 @@ class CngxMetric {
1648
1773
  @if (unit()) {
1649
1774
  <span class="cngx-metric__unit">{{ unit() }}</span>
1650
1775
  }
1651
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1776
+ `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-metric-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-metric-value-size{syntax: \"*\"; inherits: true; initial-value: 1.75rem;}@property --cngx-metric-value-weight{syntax: \"<number>\"; inherits: true; initial-value: 600;}@property --cngx-metric-value-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.2 .01 290);}@property --cngx-metric-unit-size{syntax: \"*\"; inherits: true; initial-value: .875rem;}@property --cngx-metric-unit-weight{syntax: \"<number>\"; inherits: true; initial-value: 400;}@property --cngx-metric-unit-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-metric-value-color: oklch(.95 .01 290);--cngx-metric-unit-color: oklch(.7 .01 290)}}[data-color-scheme=dark],.dark{--cngx-metric-value-color: oklch(.95 .01 290);--cngx-metric-unit-color: oklch(.7 .01 290)}[data-color-scheme=light],.light{--cngx-metric-value-color: oklch(.2 .01 290);--cngx-metric-unit-color: oklch(.36 .02 290)}}@layer cngx.components{@scope(.cngx-metric){:scope{display:inline-flex;align-items:baseline;gap:var(--cngx-metric-gap, 2px)}.cngx-metric__value{font-size:var(--cngx-metric-value-size, 1.75rem);font-weight:var(--cngx-metric-value-weight, 600);color:var(--cngx-metric-value-color, var(--cngx-color-text, oklch(.2 .01 290)));line-height:1.2}.cngx-metric__unit{font-size:var(--cngx-metric-unit-size, .875rem);font-weight:var(--cngx-metric-unit-weight, 400);color:var(--cngx-metric-unit-color, oklch(.36 .02 290))}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1652
1777
  }
1653
1778
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMetric, decorators: [{
1654
1779
  type: Component,
1655
- args: [{
1656
- selector: 'cngx-metric',
1657
- standalone: true,
1658
- changeDetection: ChangeDetectionStrategy.OnPush,
1659
- encapsulation: ViewEncapsulation.None,
1660
- host: {
1780
+ args: [{ selector: 'cngx-metric', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1661
1781
  class: 'cngx-metric',
1662
1782
  '[attr.aria-label]': 'accessibleValue()',
1663
- },
1664
- template: `
1783
+ }, template: `
1665
1784
  <span class="cngx-metric__value">{{ formattedValue() }}</span>
1666
1785
  @if (unit()) {
1667
1786
  <span class="cngx-metric__unit">{{ unit() }}</span>
1668
1787
  }
1669
- `,
1670
- }]
1788
+ `, styles: ["@layer cngx.tokens{@property --cngx-metric-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-metric-value-size{syntax: \"*\"; inherits: true; initial-value: 1.75rem;}@property --cngx-metric-value-weight{syntax: \"<number>\"; inherits: true; initial-value: 600;}@property --cngx-metric-value-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.2 .01 290);}@property --cngx-metric-unit-size{syntax: \"*\"; inherits: true; initial-value: .875rem;}@property --cngx-metric-unit-weight{syntax: \"<number>\"; inherits: true; initial-value: 400;}@property --cngx-metric-unit-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-metric-value-color: oklch(.95 .01 290);--cngx-metric-unit-color: oklch(.7 .01 290)}}[data-color-scheme=dark],.dark{--cngx-metric-value-color: oklch(.95 .01 290);--cngx-metric-unit-color: oklch(.7 .01 290)}[data-color-scheme=light],.light{--cngx-metric-value-color: oklch(.2 .01 290);--cngx-metric-unit-color: oklch(.36 .02 290)}}@layer cngx.components{@scope(.cngx-metric){:scope{display:inline-flex;align-items:baseline;gap:var(--cngx-metric-gap, 2px)}.cngx-metric__value{font-size:var(--cngx-metric-value-size, 1.75rem);font-weight:var(--cngx-metric-value-weight, 600);color:var(--cngx-metric-value-color, var(--cngx-color-text, oklch(.2 .01 290)));line-height:1.2}.cngx-metric__unit{font-size:var(--cngx-metric-unit-size, .875rem);font-weight:var(--cngx-metric-unit-weight, 400);color:var(--cngx-metric-unit-color, oklch(.36 .02 290))}}}\n"] }]
1671
1789
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], unit: [{ type: i0.Input, args: [{ isSignal: true, alias: "unit", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }] } });
1672
1790
 
1673
1791
  /**
@@ -1696,6 +1814,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1696
1814
  * </header>
1697
1815
  * </cngx-card>
1698
1816
  * ```
1817
+ *
1818
+ * @category common/data/metric
1819
+ * @docsKind primary
1820
+ * @wcag AA
1821
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/trend/trend.component.ts
1822
+ * @since 0.1.0
1823
+ * @relatedTo CngxMetric, CngxCard
1824
+ *
1825
+ * <example-url>http://localhost:4200/#/common/data/trend/composed-with-metric-in-a-card</example-url>
1826
+ * <example-url>http://localhost:4200/#/common/data/trend/trend-directions</example-url>
1699
1827
  */
1700
1828
  class CngxTrend {
1701
1829
  /** Trend percentage. Positive = up, negative = down, zero = flat. */
@@ -1722,29 +1850,21 @@ class CngxTrend {
1722
1850
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxTrend, isStandalone: true, selector: "cngx-trend", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-trend--up": "value() > 0", "class.cngx-trend--down": "value() < 0", "attr.aria-label": "resolvedLabel()" }, classAttribute: "cngx-trend" }, ngImport: i0, template: `
1723
1851
  <span aria-hidden="true">{{ icon() }}</span>
1724
1852
  {{ formattedValue() }}
1725
- `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1853
+ `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-trend-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-trend-size{syntax: \"*\"; inherits: true; initial-value: .8125rem;}@property --cngx-trend-weight{syntax: \"<number>\"; inherits: true; initial-value: 500;}@property --cngx-trend-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@property --cngx-trend-up-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@property --cngx-trend-down-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .22 25);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-trend-color: oklch(.7 .01 290);--cngx-trend-up-color: oklch(.78 .16 145);--cngx-trend-down-color: oklch(.75 .18 25)}}[data-color-scheme=dark],.dark{--cngx-trend-color: oklch(.7 .01 290);--cngx-trend-up-color: oklch(.78 .16 145);--cngx-trend-down-color: oklch(.75 .18 25)}[data-color-scheme=light],.light{--cngx-trend-color: oklch(.36 .02 290);--cngx-trend-up-color: oklch(.65 .18 145);--cngx-trend-down-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-trend){:scope{display:inline-flex;align-items:center;gap:var(--cngx-trend-gap, 2px);font-size:var(--cngx-trend-size, .8125rem);font-weight:var(--cngx-trend-weight, 500);color:var(--cngx-trend-color, oklch(.36 .02 290))}:scope.cngx-trend--up{color:var(--cngx-trend-up-color, var(--cngx-color-success, oklch(.65 .18 145)))}:scope.cngx-trend--down{color:var(--cngx-trend-down-color, var(--cngx-color-danger, oklch(.65 .22 25)))}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1726
1854
  }
1727
1855
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTrend, decorators: [{
1728
1856
  type: Component,
1729
- args: [{
1730
- selector: 'cngx-trend',
1731
- standalone: true,
1732
- changeDetection: ChangeDetectionStrategy.OnPush,
1733
- encapsulation: ViewEncapsulation.None,
1734
- host: {
1857
+ args: [{ selector: 'cngx-trend', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1735
1858
  class: 'cngx-trend',
1736
1859
  '[class.cngx-trend--up]': 'value() > 0',
1737
1860
  '[class.cngx-trend--down]': 'value() < 0',
1738
1861
  '[attr.aria-label]': 'resolvedLabel()',
1739
- },
1740
- template: `
1862
+ }, template: `
1741
1863
  <span aria-hidden="true">{{ icon() }}</span>
1742
1864
  {{ formattedValue() }}
1743
- `,
1744
- }]
1865
+ `, styles: ["@layer cngx.tokens{@property --cngx-trend-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-trend-size{syntax: \"*\"; inherits: true; initial-value: .8125rem;}@property --cngx-trend-weight{syntax: \"<number>\"; inherits: true; initial-value: 500;}@property --cngx-trend-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@property --cngx-trend-up-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@property --cngx-trend-down-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .22 25);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-trend-color: oklch(.7 .01 290);--cngx-trend-up-color: oklch(.78 .16 145);--cngx-trend-down-color: oklch(.75 .18 25)}}[data-color-scheme=dark],.dark{--cngx-trend-color: oklch(.7 .01 290);--cngx-trend-up-color: oklch(.78 .16 145);--cngx-trend-down-color: oklch(.75 .18 25)}[data-color-scheme=light],.light{--cngx-trend-color: oklch(.36 .02 290);--cngx-trend-up-color: oklch(.65 .18 145);--cngx-trend-down-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-trend){:scope{display:inline-flex;align-items:center;gap:var(--cngx-trend-gap, 2px);font-size:var(--cngx-trend-size, .8125rem);font-weight:var(--cngx-trend-weight, 500);color:var(--cngx-trend-color, oklch(.36 .02 290))}:scope.cngx-trend--up{color:var(--cngx-trend-up-color, var(--cngx-color-success, oklch(.65 .18 145)))}:scope.cngx-trend--down{color:var(--cngx-trend-down-color, var(--cngx-color-danger, oklch(.65 .22 25)))}}}\n"] }]
1745
1866
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
1746
1867
 
1747
- // Step 1: range-computer.ts — pure function, zero dependencies
1748
1868
  const EMPTY_RANGE = {
1749
1869
  start: 0,
1750
1870
  end: 0,
@@ -1756,7 +1876,7 @@ const EMPTY_RANGE = {
1756
1876
  * Computes the visible range of items given scroll position, viewport size,
1757
1877
  * total item count, and item size estimation.
1758
1878
  *
1759
- * Pure function — no DOM access, no Angular dependency. Fully testable.
1879
+ * Pure function - no DOM access, no Angular dependency. Fully testable.
1760
1880
  *
1761
1881
  * @param scrollTop Current scroll offset in px.
1762
1882
  * @param clientHeight Viewport height in px.
@@ -1766,6 +1886,7 @@ const EMPTY_RANGE = {
1766
1886
  * @param columns Column count for grid mode (default 1). When > 1, range is row-aligned.
1767
1887
  * Variable `estimateSize` ignores columns (grid + variable heights not supported).
1768
1888
  * @returns The computed range with spacer offsets.
1889
+ * @internal
1769
1890
  */
1770
1891
  function computeRange(scrollTop, clientHeight, totalCount, estimateSize, overscan, columns = 1) {
1771
1892
  if (totalCount <= 0 || clientHeight <= 0) {
@@ -1774,7 +1895,7 @@ function computeRange(scrollTop, clientHeight, totalCount, estimateSize, oversca
1774
1895
  if (typeof estimateSize === 'number') {
1775
1896
  return computeFixedRange(scrollTop, clientHeight, totalCount, estimateSize, overscan, columns);
1776
1897
  }
1777
- // Variable heights — grid mode not supported, columns ignored
1898
+ // variable heights: grid mode unsupported, columns ignored
1778
1899
  return computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscan);
1779
1900
  }
1780
1901
  function computeFixedRange(scrollTop, clientHeight, totalCount, itemSize, overscan, columns) {
@@ -1799,18 +1920,19 @@ function computeFixedRange(scrollTop, clientHeight, totalCount, itemSize, oversc
1799
1920
  *
1800
1921
  * Order: raw visible rows → overscan rows → clamp → convert to item indices.
1801
1922
  * This ensures full rows are always rendered.
1923
+ *
1924
+ * @internal
1802
1925
  */
1803
1926
  function computeGridRange(scrollTop, clientHeight, totalCount, rowHeight, overscan, columns) {
1804
1927
  const totalRows = Math.ceil(totalCount / columns);
1805
1928
  const totalSize = totalRows * rowHeight;
1806
- // Step 1+2: raw visible rows (inherently row-aligned)
1929
+ // raw rows (inherently row-aligned)
1807
1930
  const rawStartRow = Math.floor(scrollTop / rowHeight);
1808
1931
  const rawEndRow = Math.ceil((scrollTop + clientHeight) / rowHeight);
1809
- // Step 3: apply overscan in rows (convert item overscan to row overscan)
1932
+ // overscan applied in rows so full rows always render
1810
1933
  const overscanRows = Math.ceil(overscan / columns);
1811
1934
  const startRow = Math.max(0, rawStartRow - overscanRows);
1812
1935
  const endRow = Math.min(totalRows, rawEndRow + overscanRows);
1813
- // Step 4: convert to item indices, clamp end to totalCount
1814
1936
  const start = startRow * columns;
1815
1937
  const end = Math.min(endRow * columns, totalCount);
1816
1938
  return {
@@ -1822,7 +1944,6 @@ function computeGridRange(scrollTop, clientHeight, totalCount, rowHeight, oversc
1822
1944
  };
1823
1945
  }
1824
1946
  function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscan) {
1825
- // Accumulate heights to find the first visible item (binary search)
1826
1947
  let totalSize = 0;
1827
1948
  const offsets = new Array(totalCount + 1);
1828
1949
  offsets[0] = 0;
@@ -1830,7 +1951,7 @@ function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize,
1830
1951
  totalSize += estimateSize(i);
1831
1952
  offsets[i + 1] = totalSize;
1832
1953
  }
1833
- // Binary search for the first item whose bottom edge is past scrollTop
1954
+ // binary search: first item whose bottom edge is past scrollTop
1834
1955
  const rawStart = binarySearch(offsets, scrollTop, totalCount);
1835
1956
  const rawEnd = binarySearch(offsets, scrollTop + clientHeight, totalCount);
1836
1957
  const start = Math.max(0, rawStart - overscan);
@@ -1843,7 +1964,11 @@ function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize,
1843
1964
  totalSize,
1844
1965
  };
1845
1966
  }
1846
- /** Finds the index of the first item whose cumulative offset exceeds `target`. */
1967
+ /**
1968
+ * Finds the index of the first item whose cumulative offset exceeds `target`.
1969
+ *
1970
+ * @internal
1971
+ */
1847
1972
  function binarySearch(offsets, target, totalCount) {
1848
1973
  let low = 0;
1849
1974
  let high = totalCount - 1;
@@ -1862,7 +1987,6 @@ function binarySearch(offsets, target, totalCount) {
1862
1987
  return Math.min(low, totalCount - 1);
1863
1988
  }
1864
1989
 
1865
- // Step 2: scroll-observer.ts — addEventListener + ResizeObserver → signals
1866
1990
  /**
1867
1991
  * Creates a reactive scroll observer for a container element.
1868
1992
  *
@@ -1912,7 +2036,7 @@ function createScrollObserver(elementRef, destroyRef) {
1912
2036
  });
1913
2037
  }
1914
2038
  effect((onCleanup) => {
1915
- retryTick(); // tracked — effect re-runs when retryTick changes
2039
+ retryTick(); // tracked: re-runs the effect after the retry tick bumps
1916
2040
  const el = resolveElement(elementRef, doc);
1917
2041
  if (!el) {
1918
2042
  return;
@@ -1933,7 +2057,6 @@ function createScrollObserver(elementRef, destroyRef) {
1933
2057
  retryTick.update((v) => v + 1);
1934
2058
  }
1935
2059
  });
1936
- // Additional cleanup via DestroyRef as safety net
1937
2060
  destroyRef.onDestroy(() => {
1938
2061
  elementState.set(null);
1939
2062
  });
@@ -1954,7 +2077,6 @@ function resolveElement(ref, doc) {
1954
2077
  return ref?.nativeElement ?? null;
1955
2078
  }
1956
2079
 
1957
- // Phase 2: size-cache.ts — Signal-based measured height cache
1958
2080
  /**
1959
2081
  * Creates a signal-based size cache for measured item heights.
1960
2082
  *
@@ -1999,6 +2121,11 @@ function createSizeCache() {
1999
2121
  /**
2000
2122
  * Injection token for recycler SR announcement texts.
2001
2123
  * Provides English defaults via factory. Override with `provideRecyclerI18n()`.
2124
+ *
2125
+ * @category common/data/recycler
2126
+ * @wcag AA
2127
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler.ts
2128
+ * @since 0.1.0
2002
2129
  */
2003
2130
  const CNGX_RECYCLER_I18N = new InjectionToken('CngxRecyclerI18n', {
2004
2131
  factory: () => ({
@@ -2019,6 +2146,8 @@ const CNGX_RECYCLER_I18N = new InjectionToken('CngxRecyclerI18n', {
2019
2146
  * error: () => 'Fehler beim Laden.',
2020
2147
  * })]
2021
2148
  * ```
2149
+ *
2150
+ * @category common/data/recycler
2022
2151
  */
2023
2152
  function provideRecyclerI18n(i18n) {
2024
2153
  return { provide: CNGX_RECYCLER_I18N, useValue: i18n };
@@ -2026,10 +2155,10 @@ function provideRecyclerI18n(i18n) {
2026
2155
  /**
2027
2156
  * Inline equivalent of `createVisibilityTimer` from `@cngx/ui/feedback` (Level 4, not importable).
2028
2157
  *
2029
- * Uses `setTimeout` inside an effect — this is a timer-driven side effect, not derived state.
2158
+ * Uses `setTimeout` inside an effect - this is a timer-driven side effect, not derived state.
2030
2159
  * Same pattern accepted in `createVisibilityTimer` for `CngxLoadingOverlay`.
2031
2160
  * Safe in zoneless: the `setTimeout` callback only writes a signal, which schedules
2032
- * Angular's own change detection — no Zone.js dependency.
2161
+ * Angular's own change detection - no Zone.js dependency.
2033
2162
  *
2034
2163
  * @param source Boolean signal to delay. When `true`, starts the timer.
2035
2164
  * @param delayMs Delay in milliseconds before the flag becomes `true`.
@@ -2082,6 +2211,8 @@ function createDelayedFlag(source, delayMs) {
2082
2211
  * state: this.state,
2083
2212
  * });
2084
2213
  * ```
2214
+ *
2215
+ * @category common/data/recycler
2085
2216
  */
2086
2217
  function injectRecycler(config) {
2087
2218
  const destroyRef = inject(DestroyRef);
@@ -2091,7 +2222,7 @@ function injectRecycler(config) {
2091
2222
  if (isGrid && config.columns == null && isDevMode()) {
2092
2223
  console.error('[CngxRecycler] layout: "grid" requires explicit `columns`. Falling back to columns=1.');
2093
2224
  }
2094
- // Reactive columns — reactive only if the function reads a Signal internally
2225
+ // Reactive columns - reactive only if the function reads a Signal internally
2095
2226
  const columns = computed(() => {
2096
2227
  if (!isGrid || config.columns == null) {
2097
2228
  return 1;
@@ -2174,12 +2305,12 @@ function injectRecycler(config) {
2174
2305
  if (ch <= 0) {
2175
2306
  return 0;
2176
2307
  }
2177
- // Resolve estimateSize reactively — function variant may read signals internally
2308
+ // Resolve estimateSize reactively - function variant may read signals internally
2178
2309
  const itemHeight = typeof config.estimateSize === 'number' ? config.estimateSize : config.estimateSize(0);
2179
2310
  return Math.ceil(ch / itemHeight);
2180
2311
  }, ...(ngDevMode ? [{ debugName: "skeletonSlots" }] : /* istanbul ignore next */ []));
2181
2312
  const showSkeleton = createDelayedFlag(isLoading, config.skeletonDelay ?? 0);
2182
- // previousTotal is a signal, not a mutable let — reactive, no stale-value risk.
2313
+ // previousTotal is a signal, not a mutable let - reactive, no stale-value risk.
2183
2314
  const announcementState = signal('', ...(ngDevMode ? [{ debugName: "announcementState" }] : /* istanbul ignore next */ []));
2184
2315
  const previousTotal = signal(config.totalCount(), ...(ngDevMode ? [{ debugName: "previousTotal" }] : /* istanbul ignore next */ []));
2185
2316
  if (state) {
@@ -2188,10 +2319,10 @@ function injectRecycler(config) {
2188
2319
  const current = tracker.current();
2189
2320
  const previous = tracker.previous();
2190
2321
  const total = config.totalCount();
2191
- // untracked: previousTotal is bookkeeping, not a dependency —
2322
+ // untracked: previousTotal is bookkeeping, not a dependency -
2192
2323
  // the effect should fire on status/totalCount changes, not on its own writes.
2193
2324
  const prevTotal = untracked(() => previousTotal());
2194
- // Transition-only — never announce on initial idle
2325
+ // Transition-only - never announce on initial idle
2195
2326
  if (previous === current) {
2196
2327
  return;
2197
2328
  }
@@ -2303,7 +2434,7 @@ function injectRecycler(config) {
2303
2434
  const neededRange = computed(() => ({ start: start(), end: end() }), ...(ngDevMode ? [{ debugName: "neededRange" }] : /* istanbul ignore next */ []));
2304
2435
  const pendingScrollTarget = signal(null, ...(ngDevMode ? [{ debugName: "pendingScrollTarget" }] : /* istanbul ignore next */ []));
2305
2436
  const pendingTarget = computed(() => pendingScrollTarget()?.index ?? null, ...(ngDevMode ? [{ debugName: "pendingTarget" }] : /* istanbul ignore next */ []));
2306
- // Watch totalCount — when it grows past the pending target, execute the scroll.
2437
+ // Watch totalCount - when it grows past the pending target, execute the scroll.
2307
2438
  // Uses untracked() for pendingScrollTarget reads/writes to avoid write-inside-read loops.
2308
2439
  // Only totalCount is a tracked dependency.
2309
2440
  effect(() => {
@@ -2357,7 +2488,7 @@ function injectRecycler(config) {
2357
2488
  return computed(() => items().slice(start(), end()));
2358
2489
  },
2359
2490
  measure(index, element) {
2360
- // Grid mode assumes uniform row height — SizeCache writes would break row-based range.
2491
+ // Grid mode assumes uniform row height - SizeCache writes would break row-based range.
2361
2492
  if (isGrid) {
2362
2493
  return;
2363
2494
  }
@@ -2369,7 +2500,7 @@ function injectRecycler(config) {
2369
2500
  scrollToIndex(index, behavior = 'auto') {
2370
2501
  const total = config.totalCount();
2371
2502
  if (index >= total) {
2372
- // Deep-link: target not loaded yet — store for later resolution
2503
+ // Deep-link: target not loaded yet - store for later resolution
2373
2504
  pendingScrollTarget.set({ index, behavior });
2374
2505
  return;
2375
2506
  }
@@ -2388,7 +2519,6 @@ function injectRecycler(config) {
2388
2519
  };
2389
2520
  }
2390
2521
 
2391
- // Phase 2: measure.directive.ts — CngxMeasure atom
2392
2522
  /**
2393
2523
  * Atom directive that measures the host element's height and reports it
2394
2524
  * to the recycler via `recycler.measure(index, element)`.
@@ -2405,6 +2535,19 @@ function injectRecycler(config) {
2405
2535
  * </div>
2406
2536
  * }
2407
2537
  * ```
2538
+ *
2539
+ * @category common/data/recycler
2540
+ * @docsKind primary
2541
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/measure.directive.ts
2542
+ * @since 0.1.0
2543
+ * @relatedTo CngxVirtualItem, CngxRecyclerAnnouncer, injectRecycler
2544
+ *
2545
+ * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
2546
+ * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
2547
+ * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
2548
+ * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
2549
+ * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
2550
+ * <example-url>http://localhost:4200/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
2408
2551
  */
2409
2552
  class CngxMeasure {
2410
2553
  /** The recycler instance to report measurements to. */
@@ -2417,9 +2560,7 @@ class CngxMeasure {
2417
2560
  const recycler = this.cngxMeasure();
2418
2561
  const index = this.cngxMeasureIndex();
2419
2562
  const element = this.el.nativeElement;
2420
- // Initial measurement
2421
2563
  recycler.measure(index, element);
2422
- // Observe size changes
2423
2564
  const observer = new ResizeObserver(() => {
2424
2565
  recycler.measure(index, element);
2425
2566
  });
@@ -2443,15 +2584,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2443
2584
  }]
2444
2585
  }], ctorParameters: () => [], propDecorators: { cngxMeasure: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMeasure", required: true }] }], cngxMeasureIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxMeasureIndex", required: true }] }] } });
2445
2586
 
2446
- // Phase 4: virtual-item.directive.ts — CngxVirtualItem A11y atom
2447
2587
  /**
2448
2588
  * A11y atom that sets `aria-setsize`, `aria-posinset`, and `data-cngx-recycle-index`
2449
2589
  * on each rendered virtual item. Replaces manual ARIA boilerplate.
2450
2590
  *
2451
- * Also provides `data-cngx-recycle-index` for focus tracking — consumers who
2591
+ * Also provides `data-cngx-recycle-index` for focus tracking - consumers who
2452
2592
  * don't use `CngxMeasure` (grid mode, uniform heights) get focus tracking for free.
2453
2593
  *
2454
- * Does NOT set `role` — the consumer decides (`listitem`, `option`, `treeitem`, `tab`).
2594
+ * Does NOT set `role` - the consumer decides (`listitem`, `option`, `treeitem`, `tab`).
2455
2595
  *
2456
2596
  * ```html
2457
2597
  * @for (item of visibleItems(); track item.id; let i = $index) {
@@ -2462,6 +2602,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2462
2602
  * </div>
2463
2603
  * }
2464
2604
  * ```
2605
+ *
2606
+ * @category common/data/recycler
2607
+ * @docsKind primary
2608
+ * @wcag AA
2609
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/virtual-item.directive.ts
2610
+ * @since 0.1.0
2611
+ * @relatedTo CngxMeasure, CngxRecyclerAnnouncer, injectRecycler
2612
+ *
2613
+ * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
2614
+ * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
2615
+ * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
2616
+ * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
2617
+ * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
2618
+ * <example-url>http://localhost:4200/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
2465
2619
  */
2466
2620
  class CngxVirtualItem {
2467
2621
  /** The recycler instance providing `ariaSetSize`. */
@@ -2488,16 +2642,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2488
2642
  }]
2489
2643
  }], propDecorators: { cngxVirtualItem: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxVirtualItem", required: true }] }], cngxVirtualItemIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxVirtualItemIndex", required: true }] }] } });
2490
2644
 
2491
- // Phase 4: recycler-announcer.component.ts — CngxRecyclerAnnouncer convenience
2492
2645
  /**
2493
2646
  * Convenience component that renders the `aria-live="polite"` region
2494
2647
  * for recycler SR announcements. Eliminates manual boilerplate.
2495
2648
  *
2496
- * Uses `display: contents` — no layout impact.
2649
+ * Uses `display: contents` - no layout impact.
2497
2650
  *
2498
2651
  * ```html
2499
2652
  * <cngx-recycler-announcer [cngxRecyclerAnnouncer]="recycler" />
2500
2653
  * ```
2654
+ *
2655
+ * @category common/data/recycler
2656
+ * @docsKind primary
2657
+ * @wcag AA
2658
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-announcer.component.ts
2659
+ * @since 0.1.0
2660
+ * @relatedTo CngxMeasure, CngxVirtualItem, injectRecycler, CNGX_RECYCLER_I18N
2661
+ *
2662
+ * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
2663
+ * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
2664
+ * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
2665
+ * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
2666
+ * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
2667
+ * <example-url>http://localhost:4200/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
2501
2668
  */
2502
2669
  class CngxRecyclerAnnouncer {
2503
2670
  /** The recycler instance providing `announcement()`. */
@@ -2520,7 +2687,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2520
2687
  }]
2521
2688
  }], propDecorators: { recycler: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxRecyclerAnnouncer", required: true }] }] } });
2522
2689
 
2523
- // Phase 4: connect-recycler-roving.ts — wires CngxRecycler to CngxRovingTabindex virtual mode
2524
2690
  /**
2525
2691
  * Wires a `CngxRecycler` to a `CngxRovingTabindex` in virtual mode.
2526
2692
  *
@@ -2549,6 +2715,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2549
2715
  * }
2550
2716
  * }
2551
2717
  * ```
2718
+ *
2719
+ * @category common/data/recycler
2552
2720
  */
2553
2721
  function connectRecyclerToRoving(recycler, roving) {
2554
2722
  const hostEl = inject(ElementRef).nativeElement;
@@ -2612,8 +2780,6 @@ function connectRecyclerToRoving(recycler, roving) {
2612
2780
  });
2613
2781
  }
2614
2782
 
2615
- // connect-recycler-active-descendant.ts
2616
- // Wires CngxRecycler to CngxActiveDescendant virtual mode.
2617
2783
  /**
2618
2784
  * Wires a {@link CngxRecycler} to a {@link CngxActiveDescendant} in
2619
2785
  * virtual mode.
@@ -2653,11 +2819,12 @@ function connectRecyclerToRoving(recycler, roving) {
2653
2819
  * }
2654
2820
  * }
2655
2821
  * ```
2822
+ *
2823
+ * @category common/data/recycler
2656
2824
  */
2657
2825
  function connectRecyclerToActiveDescendant(recycler, ad) {
2658
- // rAF-debounced scrollToIndex — rapid keypresses (e.g. ArrowDown held)
2659
- // otherwise enqueue one scroll call per keystroke. Each new pending
2660
- // target overwrites the previous rAF; only the latest lands.
2826
+ // rAF-debounced: held ArrowDown otherwise enqueues one scroll per keystroke.
2827
+ // Each new pending target overwrites the previous rAF, only the latest lands.
2661
2828
  let scrollRafId = null;
2662
2829
  effect((onCleanup) => {
2663
2830
  const target = ad.pendingHighlight();
@@ -2669,8 +2836,7 @@ function connectRecyclerToActiveDescendant(recycler, ad) {
2669
2836
  }
2670
2837
  scrollRafId = requestAnimationFrame(() => {
2671
2838
  scrollRafId = null;
2672
- // Re-read pending target inside the frame — if the user continued
2673
- // typing / arrow-pressing during the frame, the latest target wins.
2839
+ // re-read inside the frame so the latest target wins if the user kept typing
2674
2840
  const latest = untracked(() => ad.pendingHighlight());
2675
2841
  if (latest != null) {
2676
2842
  recycler.scrollToIndex(latest);
@@ -2691,41 +2857,30 @@ function connectRecyclerToActiveDescendant(recycler, ad) {
2691
2857
  * Plain function, not a class — matches the rest of the repo
2692
2858
  * (`createManualState`, `createAsyncState`, `createTransitionTracker`).
2693
2859
  * See `reference_api_prefix_convention.md`.
2860
+ *
2861
+ * @category common/data/commit
2694
2862
  */
2695
2863
  function createCommitController() {
2696
- // Writable state slot — the `state` getter returns the read-only
2697
- // `CngxAsyncState<T | undefined>` view so consumers can't bypass
2698
- // the controller to flip status directly.
2864
+ // read-only `state` view; consumers can't flip status directly
2699
2865
  const slot = createManualState();
2700
- // Monotonic commit id. Incremented on every `begin(...)`. An
2701
- // outcome callback checks its captured id against the current
2702
- // counter — if a newer commit has started, the callback is
2703
- // ignored (supersede).
2866
+ // monotonic supersede id; stale callbacks compare captured id against this
2704
2867
  let commitId = 0;
2705
- // Cancel handle for the runner currently in flight. Replaced on
2706
- // each `begin(...)` and cleared after the runner settles.
2707
2868
  let active = null;
2708
- // Public signal: what the user was trying to commit. Exposed so
2709
- // the template can render a pending spinner on THAT specific row
2710
- // and the commit-error context can surface it.
2869
+ // drives the pending spinner on the specific row the user clicked
2711
2870
  const intendedState = signal(undefined, ...(ngDevMode ? [{ debugName: "intendedState" }] : /* istanbul ignore next */ []));
2712
2871
  return {
2713
2872
  state: slot,
2714
2873
  isCommitting: computed(() => slot.isPending()),
2715
2874
  intendedValue: intendedState.asReadonly(),
2716
2875
  begin(runner, intended, previous, handlers) {
2717
- // Supersede: tear down any previous runner. Must run BEFORE
2718
- // we bump `commitId` — otherwise the previous callback's
2719
- // supersede-check would pass and fire after all.
2876
+ // tear down previous runner BEFORE bumping commitId, otherwise its
2877
+ // supersede-check would pass and fire after all
2720
2878
  active?.cancel();
2721
2879
  const id = ++commitId;
2722
2880
  intendedState.set(intended);
2723
2881
  slot.set('pending');
2724
2882
  active = runner({
2725
2883
  onSuccess: (committed) => {
2726
- // Supersede guard. `commitId` advances on every new
2727
- // `begin`; if our captured id is stale, a newer commit
2728
- // has taken over.
2729
2884
  if (id !== commitId) {
2730
2885
  return;
2731
2886
  }
@@ -2746,8 +2901,7 @@ function createCommitController() {
2746
2901
  cancel() {
2747
2902
  active?.cancel();
2748
2903
  active = null;
2749
- // Bump the id so any pending callbacks from the aborted
2750
- // runner are treated as superseded and do nothing.
2904
+ // bump id so late callbacks from the aborted runner are superseded
2751
2905
  commitId++;
2752
2906
  },
2753
2907
  };
@@ -2774,6 +2928,10 @@ function createCommitController() {
2774
2928
  * ],
2775
2929
  * });
2776
2930
  * ```
2931
+ *
2932
+ * @category common/data/commit
2933
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/commit/commit-controller.token.ts
2934
+ * @since 0.1.0
2777
2935
  */
2778
2936
  const CNGX_COMMIT_CONTROLLER_FACTORY = new InjectionToken('CngxCommitControllerFactory', {
2779
2937
  providedIn: 'root',
@@ -2834,6 +2992,8 @@ const CNGX_COMMIT_CONTROLLER_FACTORY = new InjectionToken('CngxCommitControllerF
2834
2992
  * with the regular presenter→Material effect (the read-equality guard
2835
2993
  * at the effect site suppresses a duplicate write when the presenter
2836
2994
  * later changes to the same value).
2995
+ *
2996
+ * @category common/data/material-bridge
2837
2997
  */
2838
2998
  function createMaterialBidirectionalSync(opts) {
2839
2999
  const { presenterIndex, readSelectedIndex, writeSelectedIndex, selectionChange$, onMaterialSelection, injector, destroyRef, } = opts;