@cngx/common 0.1.0-rc.9 → 0.3.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 (88) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +19 -8
  4. package/data/README.md +10 -10
  5. package/fesm2022/cngx-common-a11y.mjs +701 -263
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +83 -64
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +135 -76
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +749 -296
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +51 -29
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +695 -405
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +112 -112
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +668 -308
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7066 -2739
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2121 -492
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +1207 -569
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +256 -261
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +202 -262
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +28 -61
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +1 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +14 -4
  43. package/popover/README.md +42 -5
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/ng-add/index.js +7 -7
  46. package/schematics/ng-add/schema.json +5 -0
  47. package/stepper/README.md +0 -1
  48. package/theming/components/cngx-accordion.css +36 -7
  49. package/theming/components/cngx-async.css +185 -37
  50. package/theming/components/cngx-backdrop.css +3 -1
  51. package/theming/components/cngx-badge.css +20 -5
  52. package/theming/components/cngx-bottom-sheet.css +2 -0
  53. package/theming/components/cngx-breadcrumb.css +3 -1
  54. package/theming/components/cngx-button-group.css +325 -0
  55. package/theming/components/cngx-button-toggle.css +55 -23
  56. package/theming/components/cngx-button.css +975 -0
  57. package/theming/components/cngx-data-grid.css +2 -0
  58. package/theming/components/cngx-dialog.css +3 -1
  59. package/theming/components/cngx-divider.css +24 -9
  60. package/theming/components/cngx-drawer.css +153 -0
  61. package/theming/components/cngx-icon-glyph.css +76 -0
  62. package/theming/components/cngx-listbox.css +79 -25
  63. package/theming/components/cngx-menu.css +112 -52
  64. package/theming/components/cngx-nav.css +1220 -0
  65. package/theming/components/cngx-popover-sheet.css +43 -11
  66. package/theming/components/cngx-popover.css +37 -13
  67. package/theming/components/cngx-recycler-placeholder.css +2 -0
  68. package/theming/components/cngx-ripple.css +74 -16
  69. package/theming/components/cngx-sidebar.css +71 -0
  70. package/theming/components/cngx-slider.css +3 -1
  71. package/theming/components/cngx-tooltip.css +2 -0
  72. package/timeline/README.md +2 -2
  73. package/types/cngx-common-a11y.d.ts +343 -120
  74. package/types/cngx-common-audio.d.ts +60 -88
  75. package/types/cngx-common-button.d.ts +698 -0
  76. package/types/cngx-common-card.d.ts +104 -78
  77. package/types/cngx-common-chart.d.ts +671 -384
  78. package/types/cngx-common-command.d.ts +44 -47
  79. package/types/cngx-common-data.d.ts +350 -342
  80. package/types/cngx-common-dialog.d.ts +91 -120
  81. package/types/cngx-common-display.d.ts +475 -300
  82. package/types/cngx-common-interactive.d.ts +4350 -1723
  83. package/types/cngx-common-layout.d.ts +1365 -286
  84. package/types/cngx-common-menu-button.d.ts +382 -0
  85. package/types/cngx-common-popover.d.ts +671 -289
  86. package/types/cngx-common-stepper.d.ts +217 -347
  87. package/types/cngx-common-tabs.d.ts +173 -386
  88. package/types/cngx-common-timeline.d.ts +25 -104
@@ -1,15 +1,17 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, signal, afterNextRender, computed, output, Directive, inject, TemplateRef, model, contentChild, effect, untracked, ChangeDetectionStrategy, Component, DestroyRef, InjectionToken, Injector, Injectable, makeEnvironmentProviders, ViewContainerRef, ViewEncapsulation, isSignal, ElementRef, Renderer2, runInInjectionContext } from '@angular/core';
2
+ import { input, signal, afterNextRender, computed, output, Directive, inject, TemplateRef, model, contentChild, effect, untracked, ChangeDetectionStrategy, Component, DestroyRef, InjectionToken, Injector, Injectable, makeEnvironmentProviders, linkedSignal, ViewContainerRef, ViewEncapsulation, isSignal, ElementRef, Renderer2, runInInjectionContext } from '@angular/core';
3
3
  import { NgTemplateOutlet, DOCUMENT } from '@angular/common';
4
4
  import { CngxChip } from '@cngx/common/display';
5
5
  import { CngxMultiChipGroup, CngxChipInGroup, CngxSearch } from '@cngx/common/interactive';
6
- import { CngxRuntimeError, cngxDevWarn, arrayEqual, cngxDevError, clamp } from '@cngx/utils';
6
+ import { CngxRuntimeError, cngxDevWarn, arrayEqual, clamp, cngxDevError } from '@cngx/utils';
7
7
  import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
8
8
  import { Router, ActivatedRoute } from '@angular/router';
9
9
  import { DataSource } from '@angular/cdk/collections';
10
- import { foldForMatching, memoize, injectLocale, buildAsyncStateView, CNGX_DEV_DESCRIPTORS, nextUid, createAggregateAsyncState, CNGX_STATEFUL, createLatencyProbe, numberFormatterFor, createOverrideMerge, createVisibilityGate, createTransitionTracker, createMediaQuerySignal, createAnnouncementPhrase } from '@cngx/core/utils';
11
- import { isObservable, firstValueFrom, defer, tap, finalize, filter, map } from 'rxjs';
10
+ import { foldForMatching, memoize, injectLocale, buildAsyncStateView, CNGX_DEV_DESCRIPTORS, nextUid, createAggregateAsyncState, CNGX_STATEFUL, createLatencyProbe, numberFormatterFor, createOverrideMerge, injectLoadingConfig, createVisibilityGate, createTransitionTracker, createMediaQuerySignal, createAnnouncementPhrase } from '@cngx/core/utils';
11
+ import { settleAction } from '@cngx/utils/rxjs-interop';
12
+ import { isObservable, defer, tap, finalize, filter, map } from 'rxjs';
12
13
  import { HttpContextToken, HttpContext, HttpEventType, provideHttpClient, withInterceptors } from '@angular/common/http';
14
+ import { CNGX_FOCUSABLE_SELECTOR } from '@cngx/common/a11y';
13
15
  import { formatMessage, createLanguageSection, createSectionBundle } from '@cngx/core/i18n';
14
16
  import { observeResize } from '@cngx/common/layout';
15
17
 
@@ -42,16 +44,15 @@ function entriesEqual(a, b) {
42
44
  * Consumer connects this to a table or list via a `computed()` - nothing is
43
45
  * injected automatically.
44
46
  *
45
- * @category common/data/sort
46
- * @docsKind primary
47
47
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/sort/sort.directive.ts
48
- * @since 0.1.0
48
+ * @since 0.3.0
49
49
  * @relatedTo CngxSortHeader, CngxFilter, CngxPaginate, CngxSmartDataSource
50
50
  *
51
- * <example-url>http://localhost:4200/#/common/data/sort/basic</example-url>
52
- * <example-url>http://localhost:4200/#/common/data/sort/multi-sort</example-url>
53
- * <example-url>http://localhost:4200/#/common/data/sort/controlled</example-url>
54
- * <example-url>http://localhost:4200/#/common/data/sort/aria-and-keyboard</example-url>
51
+ * <example-url>/#/common/data/sort/basic</example-url>
52
+ * <example-url>/#/common/data/sort/multi-sort</example-url>
53
+ * <example-url>/#/common/data/sort/controlled</example-url>
54
+ * <example-url>/#/common/data/sort/aria-and-keyboard</example-url>
55
+ * @axis level atom
55
56
  */
56
57
  class CngxSort {
57
58
  /** Controlled active column. When bound, takes precedence over internal state (single-sort only). */
@@ -210,8 +211,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
210
211
  * @param field Getter for the column's field key.
211
212
  * @returns The derived `{ entry, isActive, isAsc, isDesc, priority, toggle }` bundle.
212
213
  *
213
- * @category common/data/sort
214
- * @since 0.1.0
214
+ * @since 0.3.0
215
215
  * @relatedTo CngxSort, CngxSortHeader
216
216
  */
217
217
  function createSortHeaderState(sort, field) {
@@ -257,17 +257,15 @@ function createSortHeaderState(sort, field) {
257
257
  * </div>
258
258
  * ```
259
259
  *
260
- * @category common/data/sort
261
- * @docsKind primary
262
260
  * @wcag AA
263
261
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/sort/sort-header.directive.ts
264
- * @since 0.1.0
262
+ * @since 0.3.0
265
263
  * @relatedTo CngxSort, CngxFilter, CngxPaginate
266
264
  *
267
- * <example-url>http://localhost:4200/#/common/data/sort/basic</example-url>
268
- * <example-url>http://localhost:4200/#/common/data/sort/multi-sort</example-url>
269
- * <example-url>http://localhost:4200/#/common/data/sort/controlled</example-url>
270
- * <example-url>http://localhost:4200/#/common/data/sort/aria-and-keyboard</example-url>
265
+ * <example-url>/#/common/data/sort/basic</example-url>
266
+ * <example-url>/#/common/data/sort/multi-sort</example-url>
267
+ * <example-url>/#/common/data/sort/controlled</example-url>
268
+ * <example-url>/#/common/data/sort/aria-and-keyboard</example-url>
271
269
  */
272
270
  class CngxSortHeader {
273
271
  /** The field key this header cell represents. */
@@ -347,17 +345,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
347
345
  *
348
346
  * @typeParam T - The item type the predicate operates on.
349
347
  *
350
- * @category common/data/filter
351
- * @docsKind primary
352
348
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter/filter.directive.ts
353
- * @since 0.1.0
349
+ * @since 0.3.0
354
350
  * @relatedTo CngxFilterChips, CngxSort, CngxPaginate, CngxSmartDataSource
355
351
  *
356
- * <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
357
- * <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
358
- * <example-url>http://localhost:4200/#/common/data/smart-data-source/auto-wired</example-url>
359
- * <example-url>http://localhost:4200/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
360
- * <example-url>http://localhost:4200/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
352
+ * <example-url>/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
353
+ * <example-url>/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
354
+ * <example-url>/#/common/data/smart-data-source/auto-wired</example-url>
355
+ * <example-url>/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
356
+ * <example-url>/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
361
357
  */
362
358
  class CngxFilter {
363
359
  /** Controlled predicate. When bound, takes precedence over the `'default'` internal predicate. */
@@ -454,13 +450,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
454
450
  * wraps that decoration in `cngxChipInGroup`-bound chip wrappers
455
451
  * automatically. Absence falls back to the default text-only label.
456
452
  *
457
- * @category common/data/filter
458
453
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter-chips/filter-chips.component.ts
459
- * @since 0.1.0
454
+ * @since 0.3.0
460
455
  * @relatedTo CngxFilterChips, CngxFilter
461
456
  *
462
- * <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
463
- * <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
457
+ * <example-url>/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
458
+ * <example-url>/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
464
459
  */
465
460
  class CngxFilterChip {
466
461
  template = inject(TemplateRef);
@@ -547,22 +542,44 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
547
542
  * </ng-container>
548
543
  * ```
549
544
  *
550
- * @category common/data/filter
551
- * @docsKind primary
552
545
  * @wcag AA
553
546
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/filter-chips/filter-chips.component.ts
554
- * @since 0.1.0
547
+ * @since 0.3.0
555
548
  * @relatedTo CngxFilter, CngxFilterChip, CngxMultiChipGroup
556
549
  * @slot cngxFilterChip Renders one active filter chip; gets the filter entry and a remove callback.
557
550
  *
558
- * <example-url>http://localhost:4200/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
559
- * <example-url>http://localhost:4200/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
551
+ * <example-url>/#/common/data/filter-chips/custom-chip-decoration-via-cngxfilterchip</example-url>
552
+ * <example-url>/#/common/data/filter-chips/multi-role-filter-wired-to-a-list</example-url>
553
+ * @axis level molecule
560
554
  */
561
555
  class CngxFilterChips {
556
+ /**
557
+ * Name of the facet this strip filters. Renders as the visible, `aria-hidden`
558
+ * `.cngx-filter-chips__label` caption and is passed to the inner chip group
559
+ * as its accessible name.
560
+ */
562
561
  label = input.required(...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
562
+ /**
563
+ * Chip pool: one chip is rendered per item, in array order. A selected value
564
+ * whose option is no longer in the array is dropped from `selectedValues`.
565
+ */
563
566
  options = input.required(...(ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []));
567
+ /**
568
+ * Maps an option to its chip text. It is the default chip body and the
569
+ * `label` field of the `cngxFilterChip` template context, which replaces the
570
+ * default body when projected.
571
+ */
564
572
  optionLabel = input.required(...(ngDevMode ? [{ debugName: "optionLabel" }] : /* istanbul ignore next */ []));
573
+ /**
574
+ * Maps an option to the value that chip toggles into `selectedValues`. While
575
+ * `itemValue` is unbound it is also applied to the filtered list items to
576
+ * read the value the predicate compares against.
577
+ */
565
578
  optionValue = input.required(...(ngDevMode ? [{ debugName: "optionValue" }] : /* istanbul ignore next */ []));
579
+ /**
580
+ * The `CngxFilter` this strip registers its predicate on, under `filterKey`.
581
+ * Rebinding moves the registration to the new filter.
582
+ */
566
583
  filterRef = input.required(...(ngDevMode ? [{ debugName: "filterRef" }] : /* istanbul ignore next */ []));
567
584
  /**
568
585
  * Extracts the comparable value from a filtered list item, when the list
@@ -573,7 +590,17 @@ class CngxFilterChips {
573
590
  * which fits a list shaped like the options.
574
591
  */
575
592
  itemValue = input(undefined, ...(ngDevMode ? [{ debugName: "itemValue" }] : /* istanbul ignore next */ []));
593
+ /**
594
+ * Key the predicate is registered under on `filterRef`. Rebinding moves the
595
+ * registration; teardown removes the key only while it still maps to this
596
+ * strip's own predicate.
597
+ */
576
598
  filterKey = input.required(...(ngDevMode ? [{ debugName: "filterKey" }] : /* istanbul ignore next */ []));
599
+ /**
600
+ * Async state forwarded to the inner chip group, which reflects `loading` as
601
+ * `aria-busy`. When unset, the group falls back to an ancestor
602
+ * `CNGX_STATEFUL` provider.
603
+ */
577
604
  state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
578
605
  /**
579
606
  * Form-state surface forwarded transparently to the inner
@@ -583,9 +610,28 @@ class CngxFilterChips {
583
610
  * / `CngxButtonToggleGroup` precedent.
584
611
  */
585
612
  disabled = model(false, ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
613
+ /**
614
+ * Two-way flag forwarded to the inner chip group, which sets
615
+ * `aria-required="true"` while it is true. Default `false`.
616
+ */
586
617
  required = model(false, ...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
618
+ /**
619
+ * Two-way flag forwarded to the inner chip group, which sets
620
+ * `aria-invalid="true"` while it is true or the group's own error state is
621
+ * active. Default `false`.
622
+ */
587
623
  invalid = model(false, ...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
624
+ /**
625
+ * Id of an external error element, forwarded to the inner chip group as
626
+ * `aria-errormessage`. The consumer renders the element. Default `null`
627
+ * omits the attribute.
628
+ */
588
629
  errorMessageId = input(null, ...(ngDevMode ? [{ debugName: "errorMessageId" }] : /* istanbul ignore next */ []));
630
+ /**
631
+ * Layout and arrow-key axis of the strip. `'vertical'` stacks the chips and
632
+ * adds the `cngx-filter-chips--vertical` host class; the value is forwarded
633
+ * to the inner chip group's roving tabindex. Default `'horizontal'`.
634
+ */
589
635
  orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
590
636
  /**
591
637
  * Membership key extractor for object-valued chip values. When
@@ -779,17 +825,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
779
825
  * [length]="pg.total()" [pageIndex]="pg.pageIndex()" [pageSize]="pg.pageSize()"
780
826
  * (page)="pg.setPageSize($event.pageSize, false); pg.setPage($event.pageIndex)" />
781
827
  * ```
782
- * @category common/data/paginate
783
- * @docsKind primary
784
828
  * @wcag AA
785
829
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate.directive.ts
786
- * @since 0.1.0
830
+ * @since 0.3.0
787
831
  * @relatedTo CngxSort, CngxFilter, CngxSmartDataSource
788
832
  *
789
- * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
790
- * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
791
- * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
792
- * <example-url>http://localhost:4200/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
833
+ * <example-url>/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
834
+ * <example-url>/#/common/data/paginate-list/paginated-list-cngxpaginate</example-url>
835
+ * <example-url>/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
836
+ * <example-url>/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
837
+ * @axis level atom
793
838
  */
794
839
  class CngxPaginate {
795
840
  /** Controlled page index. When bound, takes precedence over internal state. */
@@ -946,8 +991,7 @@ function injectPaginate(selector) {
946
991
  * is byte-identical across all three. Call inside an injection context
947
992
  * (constructor or field initialiser).
948
993
  *
949
- * @category common/data/paginate
950
- * @since 0.1.0
994
+ * @since 0.3.0
951
995
  */
952
996
  function connectPaginateResetOn(paginate, key) {
953
997
  let seen = false;
@@ -978,13 +1022,11 @@ function connectPaginateResetOn(paginate, key) {
978
1022
  * ```html
979
1023
  * <table cngxPaginate [cngxPaginateResetOn]="filter()"><!-- ... --></table>
980
1024
  * ```
981
- * <example-url>http://localhost:4200/#/ui/paginator/paginator-behaviors/reset-on-filter</example-url>
1025
+ * <example-url>/#/ui/paginator/paginator-behaviors/reset-on-filter</example-url>
982
1026
  *
983
- * @category common/data/paginate
984
- * @docsKind primary
985
1027
  * @wcag AA
986
1028
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate-reset.directive.ts
987
- * @since 0.1.0
1029
+ * @since 0.3.0
988
1030
  * @relatedTo CngxPaginate, CngxPaginator, CngxMatPaginator
989
1031
  */
990
1032
  class CngxPaginateResetOn {
@@ -1029,8 +1071,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1029
1071
  * injection context (constructor or field initialiser) - it reads `DestroyRef`
1030
1072
  * and creates effects.
1031
1073
  *
1032
- * @category common/data/paginate
1033
- * @since 0.1.0
1074
+ * @since 0.3.0
1034
1075
  */
1035
1076
  function connectPaginateEmit(paginate, handlers) {
1036
1077
  const destroyRef = inject(DestroyRef);
@@ -1106,13 +1147,12 @@ function connectPaginateEmit(paginate, handlers) {
1106
1147
  * inert no-op (a dev-mode warning is logged). Framework-agnostic of any UI - it
1107
1148
  * needs only the brain and the router.
1108
1149
  *
1109
- * @category common/data/paginate
1110
- * @docsKind primary
1111
1150
  * @wcag AA
1112
1151
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate-routing.directive.ts
1113
- * @since 0.1.0
1152
+ * @since 0.3.0
1114
1153
  * @relatedTo CngxPaginate, CngxPaginator, CngxMatPaginator
1115
- * <example-url>http://localhost:4200/#/ui/paginator/paginator-behaviors/url-synced-paging</example-url>
1154
+ * <example-url>/#/ui/paginator/paginator-behaviors/url-synced-paging</example-url>
1155
+ * @axis level organism
1116
1156
  */
1117
1157
  class CngxPaginateRouting {
1118
1158
  paginate = injectPaginate('cngxPaginateRouting');
@@ -1264,10 +1304,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1264
1304
  * concrete directive class, keeping the strip decompose-ready and the model
1265
1305
  * swappable.
1266
1306
  *
1267
- * @category common/data/paginate
1268
1307
  * @wcag AA
1269
1308
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/bucket-paginate-host.token.ts
1270
- * @since 0.1.0
1309
+ * @since 0.3.0
1271
1310
  */
1272
1311
  const CNGX_BUCKET_PAGINATE_HOST = new InjectionToken('CngxBucketPaginateHost');
1273
1312
 
@@ -1311,13 +1350,12 @@ function setEquals(a, b) {
1311
1350
  * </div>
1312
1351
  * ```
1313
1352
  *
1314
- * @category common/data/paginate
1315
- * @docsKind primary
1316
1353
  * @wcag AA
1317
1354
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/bucket-paginate.directive.ts
1318
- * @since 0.1.0
1355
+ * @since 0.3.0
1319
1356
  * @relatedTo CngxPaginate, CngxFilter
1320
- * <example-url>http://localhost:4200/#/ui/paginator/paginator-modes/alphabetical</example-url>
1357
+ * <example-url>/#/ui/paginator/paginator-modes/alphabetical</example-url>
1358
+ * @axis level organism
1321
1359
  */
1322
1360
  class CngxBucketPaginate {
1323
1361
  /** The buckets to partition into, in render order. One chip per entry. */
@@ -1395,10 +1433,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1395
1433
  *
1396
1434
  * @typeParam T - The row item type.
1397
1435
  *
1398
- * @category common/data/data-source
1399
- * @docsKind primary
1400
1436
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/data-source/data-source.ts
1401
- * @since 0.1.0
1437
+ * @since 0.3.0
1402
1438
  * @relatedTo CngxSmartDataSource, CngxSort, CngxFilter, CngxPaginate
1403
1439
  */
1404
1440
  class CngxDataSource extends DataSource {
@@ -1408,9 +1444,18 @@ class CngxDataSource extends DataSource {
1408
1444
  super();
1409
1445
  this.data = data;
1410
1446
  }
1447
+ /**
1448
+ * CDK `DataSource` contract, called by the CDK table when it attaches. Returns
1449
+ * an observable of the source signal that emits the array each time the
1450
+ * signal changes.
1451
+ */
1411
1452
  connect() {
1412
1453
  return toObservable(this.data, { injector: this.injector });
1413
1454
  }
1455
+ /**
1456
+ * CDK `DataSource` contract, called by the CDK table when it detaches. No-op;
1457
+ * the `toObservable` subscription ends with the injector's `DestroyRef`.
1458
+ */
1414
1459
  disconnect() {
1415
1460
  // Signal cleanup is handled by Angular's DestroyRef - no manual teardown needed.
1416
1461
  }
@@ -1423,8 +1468,6 @@ class CngxDataSource extends DataSource {
1423
1468
  * ```typescript
1424
1469
  * readonly dataSource = injectDataSource(this.items);
1425
1470
  * ```
1426
- *
1427
- * @category common/data/data-source
1428
1471
  */
1429
1472
  function injectDataSource(data) {
1430
1473
  return new CngxDataSource(data);
@@ -1528,11 +1571,13 @@ function isAsyncState(source) {
1528
1571
  *
1529
1572
  * @typeParam T - The row item type.
1530
1573
  *
1531
- * @category common/data/data-source
1532
- * @docsKind primary
1533
1574
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/data-source/smart-data-source.ts
1534
- * @since 0.1.0
1575
+ * @since 0.3.0
1535
1576
  * @relatedTo CngxDataSource, CngxSort, CngxFilter, CngxPaginate
1577
+ * <example-url>/#/common/data/smart-data-source/auto-wired</example-url>
1578
+ * <example-url>/#/common/data/smart-data-source/how-it-works-hostdirectives-inject</example-url>
1579
+ * <example-url>/#/common/data/smart-data-source/smartdatasource-cngxpaginate-hostdirective</example-url>
1580
+ * <example-url>/#/ui/data-grid-accordion/smart-data-source-options-sort</example-url>
1536
1581
  */
1537
1582
  class CngxSmartDataSource extends DataSource {
1538
1583
  options;
@@ -1623,9 +1668,18 @@ class CngxSmartDataSource extends DataSource {
1623
1668
  return range ? sorted.slice(range[0], range[1]) : sorted;
1624
1669
  }, { ...(ngDevMode ? { debugName: "processed" } : /* istanbul ignore next */ {}), equal: arrayEqual });
1625
1670
  }
1671
+ /**
1672
+ * CDK `DataSource` contract, called by the CDK table when it attaches. Returns
1673
+ * an observable of `processed` (filtered, searched, sorted and paginated rows)
1674
+ * that emits each time it changes.
1675
+ */
1626
1676
  connect() {
1627
1677
  return toObservable(this.processed, { injector: this.injector });
1628
1678
  }
1679
+ /**
1680
+ * CDK `DataSource` contract, called by the CDK table when it detaches. No-op;
1681
+ * the `toObservable` subscription ends with the injector's `DestroyRef`.
1682
+ */
1629
1683
  disconnect() {
1630
1684
  // Signal cleanup is handled by Angular's DestroyRef - no manual teardown needed.
1631
1685
  }
@@ -1645,8 +1699,7 @@ class CngxSmartDataSource extends DataSource {
1645
1699
  * readonly residents = injectAsyncState(() => this.api.getAll());
1646
1700
  * readonly dataSource = injectSmartDataSource(this.residents);
1647
1701
  * ```
1648
- *
1649
- * @category common/data/data-source
1702
+ * <example-url>/#/ui/data-grid-accordion/smart-data-source-options-sort</example-url>
1650
1703
  */
1651
1704
  function injectSmartDataSource(source, options) {
1652
1705
  return new CngxSmartDataSource(source, options);
@@ -1668,8 +1721,6 @@ function injectSmartDataSource(source, options) {
1668
1721
  * this.processState.setSuccess(result);
1669
1722
  * }
1670
1723
  * ```
1671
- *
1672
- * @category common/data/async-state
1673
1724
  */
1674
1725
  function createManualState() {
1675
1726
  const statusState = signal('idle', ...(ngDevMode ? [{ debugName: "statusState" }] : /* istanbul ignore next */ []));
@@ -1794,8 +1845,6 @@ function operationsEqual(a, b) {
1794
1845
  * status reactivity flows through each entry's `CngxAsyncState` signals; the
1795
1846
  * Map signal's `mapKeySetEqual` short-circuits register/unregister churn
1796
1847
  * without hiding status changes.
1797
- *
1798
- * @category common/data/async-registry
1799
1848
  */
1800
1849
  class CngxAsyncRegistry {
1801
1850
  entriesState = signal(new Map(), { ...(ngDevMode ? { debugName: "entriesState" } : /* istanbul ignore next */ {}), equal: mapKeySetEqual });
@@ -1824,14 +1873,15 @@ class CngxAsyncRegistry {
1824
1873
  */
1825
1874
  register(state, label) {
1826
1875
  const id = nextUid('cngx-async-op');
1827
- const next = new Map(this.entriesState());
1876
+ // Untracked: a register() inside an effect must not subscribe it to the map it writes.
1877
+ const next = new Map(untracked(this.entriesState));
1828
1878
  next.set(id, { label, state });
1829
1879
  this.entriesState.set(next);
1830
1880
  return id;
1831
1881
  }
1832
1882
  /** Removes the operation with the given uid. No-op if absent. */
1833
1883
  unregister(id) {
1834
- const current = this.entriesState();
1884
+ const current = untracked(this.entriesState);
1835
1885
  if (!current.has(id)) {
1836
1886
  return;
1837
1887
  }
@@ -1859,8 +1909,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1859
1909
  * providers: [provideAsyncRegistry()],
1860
1910
  * });
1861
1911
  * ```
1862
- *
1863
- * @category common/data/async-registry
1912
+ * <example-url>/#/common/data/async-registry/http-requests-in-the-registry</example-url>
1864
1913
  */
1865
1914
  function provideAsyncRegistry() {
1866
1915
  return makeEnvironmentProviders([CngxAsyncRegistry]);
@@ -1869,8 +1918,6 @@ function provideAsyncRegistry() {
1869
1918
  * Returns the ambient {@link CngxAsyncRegistry}, or `null` when the consumer
1870
1919
  * did not opt in via {@link provideAsyncRegistry}. Must run in an injection
1871
1920
  * context.
1872
- *
1873
- * @category common/data/async-registry
1874
1921
  */
1875
1922
  function injectAsyncRegistry() {
1876
1923
  return inject(CngxAsyncRegistry, { optional: true });
@@ -1891,16 +1938,21 @@ function injectAsyncRegistry() {
1891
1938
  * );
1892
1939
  * }
1893
1940
  * ```
1894
- *
1895
- * @category common/data/async-state
1896
1941
  */
1897
1942
  function createAsyncState(options) {
1898
1943
  const destroyRef = inject(DestroyRef);
1899
1944
  const state = createManualState();
1900
- let abortController;
1945
+ let active;
1946
+ let destroyed = false;
1947
+ const cancelActive = () => {
1948
+ const run = active;
1949
+ active = undefined;
1950
+ run?.handle?.cancel();
1951
+ run?.finish();
1952
+ };
1901
1953
  destroyRef.onDestroy(() => {
1902
- abortController?.abort();
1903
- abortController = undefined;
1954
+ destroyed = true;
1955
+ cancelActive();
1904
1956
  });
1905
1957
  // Same opt-in observability injectAsyncState offers: without it, mutations
1906
1958
  // built here are invisible to CngxAsyncRegistry.isAnythingLoading.
@@ -1925,38 +1977,38 @@ function createAsyncState(options) {
1925
1977
  hasData: state.hasData,
1926
1978
  isSettled: state.isSettled,
1927
1979
  lastUpdated: state.lastUpdated,
1928
- async execute(fn) {
1929
- abortController?.abort();
1930
- const controller = new AbortController();
1931
- abortController = controller;
1980
+ execute(fn) {
1981
+ if (destroyed) {
1982
+ return Promise.resolve();
1983
+ }
1984
+ cancelActive();
1932
1985
  state.set('pending');
1933
1986
  state.setProgress(undefined);
1934
- try {
1935
- const result$ = fn();
1936
- const result = isObservable(result$) ? await firstValueFrom(result$) : await result$;
1937
- if (controller.signal.aborted) {
1938
- return;
1939
- }
1940
- state.setSuccess(result);
1941
- }
1942
- catch (err) {
1943
- if (controller.signal.aborted) {
1944
- return;
1945
- }
1946
- state.setError(err);
1947
- }
1948
- finally {
1949
- if (abortController === controller) {
1950
- abortController = undefined;
1951
- }
1952
- }
1987
+ return new Promise((resolve) => {
1988
+ const run = { finish: resolve };
1989
+ active = run;
1990
+ // A superseded, reset or destroyed run is no longer `active`; its
1991
+ // handle is cancelled, so these writes only reach the current run.
1992
+ const settle = (write) => {
1993
+ if (active !== run) {
1994
+ return;
1995
+ }
1996
+ active = undefined;
1997
+ write();
1998
+ resolve();
1999
+ };
2000
+ run.handle = settleAction(fn, {
2001
+ onValue: (value) => settle(() => state.setSuccess(value)),
2002
+ onEmpty: () => settle(() => state.setSuccess(undefined)),
2003
+ onError: (err) => settle(() => state.setError(err)),
2004
+ });
2005
+ });
1953
2006
  },
1954
2007
  reportProgress(value) {
1955
2008
  state.setProgress(value);
1956
2009
  },
1957
2010
  reset() {
1958
- abortController?.abort();
1959
- abortController = undefined;
2011
+ cancelActive();
1960
2012
  state.reset();
1961
2013
  },
1962
2014
  };
@@ -1987,7 +2039,10 @@ function createAsyncState(options) {
1987
2039
  * source on each access, so bridges observe transitions of whatever is bound
1988
2040
  * right now. With nothing bound it reports a quiet `idle` state rather than
1989
2041
  * throwing, which is what lets a bridge sit inside a timeline that has not
1990
- * been given a state yet.
2042
+ * been given a state yet: `status()` is `idle`, `isFirstLoad()` and
2043
+ * `isEmpty()` are true, which `resolveAsyncView` maps to `none`. Note the
2044
+ * difference to `buildAsyncStateView`, which defaults `isFirstLoad` to false
2045
+ * when a producer passes none.
1991
2046
  *
1992
2047
  * Contrast the select family, which provides `CNGX_STATEFUL` with
1993
2048
  * `useFactory` over a concrete `commitState` field - no forwarding needed
@@ -2002,9 +2057,9 @@ function createAsyncState(options) {
2002
2057
  * { provide: CNGX_STATEFUL, useFactory: () => ({ state: inject(Host).asyncState }) }
2003
2058
  * ```
2004
2059
  *
2005
- * @category common/data/async-state
2006
2060
  * @relatedTo createAsyncState, createManualState
2007
- * @since 0.1.0
2061
+ * @since 0.3.0
2062
+ * <example-url>/#/common/data/async-state/forwarded-state-through-an-input</example-url>
2008
2063
  */
2009
2064
  function createForwardedAsyncState(source) {
2010
2065
  return {
@@ -2037,10 +2092,10 @@ function createForwardedAsyncState(source) {
2037
2092
  * );
2038
2093
  * // Loads automatically when filter() changes.
2039
2094
  * // Caches last result during refresh (refreshing state).
2040
- * // Deduplicates parallel requests.
2095
+ * // A newer run cancels the one in flight (an Observable is unsubscribed,
2096
+ * // a Promise result is dropped). Of several changes inside the debounce
2097
+ * // window (50 ms by default) only the last result is consumed.
2041
2098
  * ```
2042
- *
2043
- * @category common/data/async-state
2044
2099
  */
2045
2100
  function injectAsyncState(fn, options) {
2046
2101
  const destroyRef = inject(DestroyRef);
@@ -2049,6 +2104,7 @@ function injectAsyncState(fn, options) {
2049
2104
  let activeSubscription;
2050
2105
  let abortController;
2051
2106
  let debounceTimer;
2107
+ let destroyed = false;
2052
2108
  function cancelInFlight() {
2053
2109
  activeSubscription?.unsubscribe();
2054
2110
  activeSubscription = undefined;
@@ -2056,6 +2112,7 @@ function injectAsyncState(fn, options) {
2056
2112
  abortController = undefined;
2057
2113
  }
2058
2114
  destroyRef.onDestroy(() => {
2115
+ destroyed = true;
2059
2116
  cancelInFlight();
2060
2117
  if (debounceTimer !== undefined) {
2061
2118
  clearTimeout(debounceTimer);
@@ -2077,7 +2134,15 @@ function injectAsyncState(fn, options) {
2077
2134
  // first load -> loading, subsequent -> refreshing
2078
2135
  const status = untracked(state.isFirstLoad) ? 'loading' : 'refreshing';
2079
2136
  state.set(status);
2080
- const result$ = computation();
2137
+ let result$;
2138
+ try {
2139
+ result$ = computation();
2140
+ }
2141
+ catch (err) {
2142
+ // Same outcome as a synchronous throw on the effect path.
2143
+ state.setError(err);
2144
+ return;
2145
+ }
2081
2146
  if (isObservable(result$)) {
2082
2147
  let hasEmitted = false;
2083
2148
  activeSubscription = result$.subscribe({
@@ -2164,6 +2229,9 @@ function injectAsyncState(fn, options) {
2164
2229
  isSettled: state.isSettled,
2165
2230
  lastUpdated: state.lastUpdated,
2166
2231
  refresh() {
2232
+ if (destroyed) {
2233
+ return;
2234
+ }
2167
2235
  if (debounceTimer !== undefined) {
2168
2236
  clearTimeout(debounceTimer);
2169
2237
  debounceTimer = undefined;
@@ -2188,8 +2256,6 @@ function injectAsyncState(fn, options) {
2188
2256
  * | success | * | true | empty |
2189
2257
  * | error | false | * | content+error |
2190
2258
  * | (all other) | * | * | content |
2191
- *
2192
- * @category common/data/async-state
2193
2259
  */
2194
2260
  function resolveAsyncView(status, firstLoad, empty) {
2195
2261
  if (firstLoad) {
@@ -2224,20 +2290,27 @@ function resolveAsyncView(status, firstLoad, empty) {
2224
2290
  * `[state]` wiring. `failures` exposes the errored sources - keyed, so a
2225
2291
  * consumer's `@for` can render per-source attribution through any feedback
2226
2292
  * component. `state.error` stays the first error for the single-error path.
2293
+ * The errors are `unknown`; `messageOf` below is a component helper that
2294
+ * reads a `message` property, so an `HttpErrorResponse` does not print as
2295
+ * `[object Object]`.
2227
2296
  *
2228
2297
  * ```html
2229
- * <div [cngxAsyncBoundary]="sources" #b="cngxAsyncBoundary">
2298
+ * <div [cngxAsyncBoundary]="sources" #b="cngxAsyncBoundary"
2299
+ * cngxToastOn [toastError]="'Loading failed'">
2230
2300
  * <cngx-async-container [state]="b.state"> ... </cngx-async-container>
2231
- * <cngx-toast-on />
2232
2301
  * @for (f of b.failures(); track f.key) {
2233
- * <cngx-banner>{{ f.label }} failed</cngx-banner>
2302
+ * <cngx-alert severity="error" [title]="f.label ?? f.key">{{ messageOf(f.error) }}</cngx-alert>
2234
2303
  * }
2235
2304
  * </div>
2236
2305
  * ```
2237
2306
  *
2238
- * @category common/data/async-state
2239
2307
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async-state/async-boundary.directive.ts
2240
- * @since 0.1.0
2308
+ * @since 0.3.0
2309
+ * <example-url>/#/ui/feedback/async-container/async-boundary-bridges-aggregate-vs-per-source</example-url>
2310
+ * <example-url>/#/ui/feedback/async-container/async-boundary-per-source-errors-surface</example-url>
2311
+ * <example-url>/#/common/data/async-boundary/all-settled-renders-content</example-url>
2312
+ * <example-url>/#/common/data/async-boundary/any-loading-shows-skeleton</example-url>
2313
+ * @axis level molecule
2241
2314
  */
2242
2315
  class CngxAsyncBoundary {
2243
2316
  /** The keyed source list to aggregate. */
@@ -2249,7 +2322,7 @@ class CngxAsyncBoundary {
2249
2322
  failures = computed(() => this.sources()
2250
2323
  .filter((s) => s.state.status() === 'error')
2251
2324
  .map((s) => ({ key: s.key, label: s.label, error: s.state.error() })), { ...(ngDevMode ? { debugName: "failures" } : /* istanbul ignore next */ {}), equal: (a, b) => a.length === b.length &&
2252
- a.every((f, i) => f.key === b[i].key && Object.is(f.error, b[i].error)) });
2325
+ a.every((f, i) => f.key === b[i].key && f.label === b[i].label && Object.is(f.error, b[i].error)) });
2253
2326
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncBoundary, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2254
2327
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAsyncBoundary, isStandalone: true, selector: "[cngxAsyncBoundary]", inputs: { sources: { classPropertyName: "sources", publicName: "cngxAsyncBoundary", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "attr.aria-busy": "state.isBusy() || null" } }, providers: [{ provide: CNGX_STATEFUL, useExisting: CngxAsyncBoundary }], exportAs: ["cngxAsyncBoundary"], ngImport: i0 });
2255
2328
  }
@@ -2266,29 +2339,94 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2266
2339
  }]
2267
2340
  }], propDecorators: { sources: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAsyncBoundary", required: true }] }] } });
2268
2341
 
2342
+ /**
2343
+ * Pure latch reducer behind `buildResourceBridge`. `previous` is the last
2344
+ * reading somebody observed, not the last state that existed (the latch lives
2345
+ * in a lazy `linkedSignal`), so the latch is carried into `error` or a
2346
+ * value-less `reloading` only along a chain that proves the same request; every
2347
+ * ambiguous step clears it, which degrades to the error view, never to stale
2348
+ * data.
2349
+ *
2350
+ * @internal
2351
+ */
2352
+ function nextResourceLatch(source, previous, now) {
2353
+ const at = previous?.value.at;
2354
+ const cleared = { has: false, value: undefined, at };
2355
+ switch (source.status) {
2356
+ case 'resolved':
2357
+ case 'local':
2358
+ return { has: true, value: source.value, at: now };
2359
+ case 'idle':
2360
+ case 'loading':
2361
+ return cleared;
2362
+ case 'reloading': {
2363
+ if (source.hasValue) {
2364
+ return { has: true, value: source.value, at: at ?? now };
2365
+ }
2366
+ // Angular keeps the failed stream through a reload of the same request,
2367
+ // so an unchanged error object proves the chain.
2368
+ const sameFailedRequest = previous?.source.status === 'error' && previous.source.error === source.error;
2369
+ return sameFailedRequest ? previous.value : cleared;
2370
+ }
2371
+ case 'error':
2372
+ return previous?.source.status === 'reloading' ? previous.value : cleared;
2373
+ }
2374
+ }
2375
+ /** @internal */
2376
+ function resourceLatchEqual(a, b) {
2377
+ return a.has === b.has && Object.is(a.value, b.value) && a.at?.getTime() === b.at?.getTime();
2378
+ }
2379
+ /** @internal */
2380
+ function resourceLatchSourceEqual(a, b) {
2381
+ return (a.status === b.status &&
2382
+ a.hasValue === b.hasValue &&
2383
+ Object.is(a.value, b.value) &&
2384
+ Object.is(a.error, b.error));
2385
+ }
2386
+
2269
2387
  /**
2270
2388
  * Shared projection core for the two resource bridges (`fromResource`,
2271
2389
  * `fromHttpResource`). Derives every flag through `buildAsyncStateView`, so
2272
2390
  * the family semantics (`isLoading` includes pending/refreshing,
2273
2391
  * `isBusy === isLoading`) cannot drift between the bridges and the factories.
2274
2392
  *
2275
- * Must be called in an injection context (the tracking `effect()` requires one).
2393
+ * "First load" is per request identity: a failed reload of the same request
2394
+ * keeps the last good value, a params change or `idle` starts over. The latch
2395
+ * is a `linkedSignal` over the pure `nextResourceLatch` reducer.
2396
+ *
2397
+ * A read-only effect keeps the latch observed while no view reads the state
2398
+ * (a hidden template), so a params change that fails there is not mistaken for
2399
+ * a failed reload of the old request. Probed in jsdom only; not probed: real
2400
+ * browser schedulers and a loader that synchronously returns a resolved value.
2276
2401
  *
2277
2402
  * @internal
2278
2403
  */
2279
2404
  function buildResourceBridge(ref, progress) {
2280
- // ResourceStatus has no "first load" concept, so a successful load is
2281
- // latched here together with its timestamp.
2282
- const hadSuccess = signal(false, ...(ngDevMode ? [{ debugName: "hadSuccess" }] : /* istanbul ignore next */ []));
2283
- const lastUpdated = signal(undefined, ...(ngDevMode ? [{ debugName: "lastUpdated" }] : /* istanbul ignore next */ []));
2405
+ // Angular throws from value() in error, so the value is read only behind hasValue().
2406
+ const source = computed(() => {
2407
+ const hasValue = ref.hasValue();
2408
+ return {
2409
+ status: ref.status(),
2410
+ hasValue,
2411
+ value: hasValue ? ref.value() : undefined,
2412
+ error: ref.error(),
2413
+ };
2414
+ }, { ...(ngDevMode ? { debugName: "source" } : /* istanbul ignore next */ {}), equal: resourceLatchSourceEqual });
2415
+ // ResourceStatus has no "first load" concept; the latch holds the last good
2416
+ // value of the current request chain with its timestamp.
2417
+ const latch = linkedSignal({ ...(ngDevMode ? { debugName: "latch" } : /* istanbul ignore next */ {}), source,
2418
+ computation: (current, previous) => nextResourceLatch(current, previous, new Date()),
2419
+ equal: resourceLatchEqual });
2420
+ // Read-only keep-alive: reads the latch, never writes a signal.
2284
2421
  effect(() => {
2285
- const s = ref.status();
2286
- if (s === 'resolved' || s === 'local') {
2287
- hadSuccess.set(true);
2288
- lastUpdated.set(new Date());
2289
- }
2422
+ latch();
2290
2423
  });
2424
+ // Every signal the bridge hands out reads the latch first, so a consumer of
2425
+ // any of them (status, isLoading, error, data, ...) keeps the request chain
2426
+ // observed; a template that gates on status alone would otherwise skip the
2427
+ // steps the reducer needs to tell a reload from a params change.
2291
2428
  const status = computed(() => {
2429
+ latch();
2292
2430
  switch (ref.status()) {
2293
2431
  case 'idle':
2294
2432
  return 'idle';
@@ -2305,30 +2443,46 @@ function buildResourceBridge(ref, progress) {
2305
2443
  }, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
2306
2444
  return buildAsyncStateView({
2307
2445
  status,
2308
- data: computed(() => (ref.hasValue() ? ref.value() : undefined)),
2309
- error: computed(() => ref.error()),
2310
- progress,
2311
- // Idle counts as "before the first load": a not-yet-triggered resource
2312
- // still shows the skeleton, not the empty state.
2313
- isFirstLoad: computed(() => !hadSuccess() && (ref.isLoading() || status() === 'idle')),
2314
- lastUpdated: lastUpdated.asReadonly(),
2446
+ data: computed(() => {
2447
+ const last = latch();
2448
+ return ref.hasValue() ? ref.value() : last.value;
2449
+ }),
2450
+ error: computed(() => {
2451
+ latch();
2452
+ return ref.error();
2453
+ }),
2454
+ progress: progress
2455
+ ? computed(() => {
2456
+ latch();
2457
+ return progress();
2458
+ })
2459
+ : undefined,
2460
+ // Idle and a new request count as "before the first load", never as empty.
2461
+ isFirstLoad: computed(() => !latch().has),
2462
+ // Stamped inside the lazy latch computation: the time of the first read
2463
+ // after a successful load, not of the load itself.
2464
+ lastUpdated: computed(() => latch().at, {
2465
+ equal: (a, b) => a?.getTime() === b?.getTime(),
2466
+ }),
2315
2467
  });
2316
2468
  }
2317
2469
 
2318
2470
  /**
2319
2471
  * Bridge that projects an Angular `Resource<T>` onto `CngxAsyncState<T>`.
2320
2472
  *
2321
- * Must be called in an injection context (the `effect()` that tracks
2322
- * `hadSuccess` requires one).
2473
+ * Must be called in an injection context.
2323
2474
  *
2324
2475
  * All signals are derived reactively from the resource - no manual
2325
2476
  * synchronization. The resource stays the single source of truth.
2326
2477
  *
2478
+ * "First load" is per request: a failed reload keeps the last good value, a
2479
+ * params change or `idle` starts over with no data and `isFirstLoad()` true.
2480
+ *
2327
2481
  * ```typescript
2328
2482
  * private readonly res = resource({
2329
- * request: () => ({ filter: this.filter() }),
2330
- * loader: ({ request, abortSignal }) =>
2331
- * fetch(`/api/items?q=${request.filter}`, { signal: abortSignal })
2483
+ * params: () => ({ filter: this.filter() }),
2484
+ * loader: ({ params, abortSignal }) =>
2485
+ * fetch(`/api/items?q=${params.filter}`, { signal: abortSignal })
2332
2486
  * .then(r => r.json()),
2333
2487
  * });
2334
2488
  *
@@ -2336,13 +2490,24 @@ function buildResourceBridge(ref, progress) {
2336
2490
  * // items.status(), items.data(), items.isFirstLoad() - all work
2337
2491
  * // <cngx-async-container [state]="items"> - direct binding
2338
2492
  * ```
2339
- *
2340
- * @category common/data/async-state
2341
2493
  */
2342
2494
  function fromResource(ref) {
2343
2495
  return buildResourceBridge(ref);
2344
2496
  }
2345
2497
 
2498
+ /**
2499
+ * Loaded and total bytes as an integer percent from 0 to 100, or `undefined`
2500
+ * without a positive total (indeterminate progress).
2501
+ *
2502
+ * @internal
2503
+ */
2504
+ function progressPercent(loaded, total) {
2505
+ if (total == null || total <= 0) {
2506
+ return undefined;
2507
+ }
2508
+ return clamp(Math.round((100 * loaded) / total), 0, 100);
2509
+ }
2510
+
2346
2511
  /**
2347
2512
  * Bridge that projects an Angular `httpResource()` ref onto `CngxAsyncState<T>`.
2348
2513
  *
@@ -2365,17 +2530,12 @@ function fromResource(ref) {
2365
2530
  * // items.progress() tracks download progress 0-100
2366
2531
  * // <cngx-progress [state]="items"> - auto-wired progress bar
2367
2532
  * ```
2368
- *
2369
- * @category common/data/async-state
2370
2533
  */
2371
2534
  function fromHttpResource(ref) {
2372
- // Map loaded/total bytes to a 0-100 integer, clamped; no total = indeterminate.
2535
+ // No event or no total = indeterminate.
2373
2536
  const progress = computed(() => {
2374
2537
  const event = ref.progress();
2375
- if (event?.total == null || event.total <= 0) {
2376
- return undefined;
2377
- }
2378
- return Math.round(Math.min(event.loaded / event.total, 1) * 100);
2538
+ return event ? progressPercent(event.loaded, event.total) : undefined;
2379
2539
  }, ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
2380
2540
  return buildResourceBridge(ref, progress);
2381
2541
  }
@@ -2387,8 +2547,9 @@ function fromHttpResource(ref) {
2387
2547
  * read via the sink's `isFirstLoad`; an explicit `options.status` wins).
2388
2548
  * On next: calls `setSuccess(value)`.
2389
2549
  * On error: calls `setError(err)` and **re-throws** (does not swallow).
2390
- * On teardown without a value (unsubscribe mid-flight, empty complete):
2391
- * resets the sink to `idle` so a cancelled request never leaves it busy.
2550
+ * On complete without a value: calls `setSuccess(undefined)`.
2551
+ * On unsubscribe before any value: resets the sink to `idle` so a cancelled
2552
+ * request never leaves it busy.
2392
2553
  *
2393
2554
  * The Observable passes through unchanged - `tapAsyncState` is a side-effect operator.
2394
2555
  *
@@ -2402,8 +2563,6 @@ function fromHttpResource(ref) {
2402
2563
  * ).subscribe();
2403
2564
  * }
2404
2565
  * ```
2405
- *
2406
- * @category common/data/async-state
2407
2566
  */
2408
2567
  function tapAsyncState(state, options) {
2409
2568
  return (source) => defer(() => {
@@ -2418,9 +2577,15 @@ function tapAsyncState(state, options) {
2418
2577
  settled = true;
2419
2578
  state.setError(err);
2420
2579
  },
2580
+ complete: () => {
2581
+ if (!settled) {
2582
+ settled = true;
2583
+ state.setSuccess(undefined);
2584
+ }
2585
+ },
2421
2586
  }), finalize(() => {
2422
- // Torn down without ever settling (cancelled mid-flight or an
2423
- // empty complete) - do not leave the sink busy forever.
2587
+ // Torn down without ever settling (cancelled mid-flight) - do not
2588
+ // leave the sink busy forever.
2424
2589
  if (!settled) {
2425
2590
  state.set('idle');
2426
2591
  }
@@ -2435,7 +2600,8 @@ const RESPONSE = 4;
2435
2600
  * RxJS operator that extracts upload/download progress from an
2436
2601
  * `HttpEvent` stream and reports it to a `ManualAsyncState`.
2437
2602
  *
2438
- * Filters progress events, calculates percentage, calls `setProgress()`.
2603
+ * Filters progress events, calculates an integer percentage clamped to
2604
+ * 0-100, calls `setProgress()`.
2439
2605
  * Non-progress events pass through unchanged.
2440
2606
  *
2441
2607
  * Use with `{ observe: 'events', reportProgress: true }` on HttpClient.
@@ -2453,16 +2619,17 @@ const RESPONSE = 4;
2453
2619
  * ).subscribe();
2454
2620
  * }
2455
2621
  * ```
2456
- *
2457
- * @category common/data/async-state
2622
+ * <example-url>/#/common/data/async-operators/tap-async-progress</example-url>
2458
2623
  */
2459
2624
  function tapAsyncProgress(state) {
2460
2625
  return tap((event) => {
2461
2626
  const e = event;
2462
- if ((e.type === UPLOAD_PROGRESS || e.type === DOWNLOAD_PROGRESS) &&
2463
- e.total != null &&
2464
- e.total > 0) {
2465
- state.setProgress(Math.round((100 * e.loaded) / e.total));
2627
+ if (e.type !== UPLOAD_PROGRESS && e.type !== DOWNLOAD_PROGRESS) {
2628
+ return;
2629
+ }
2630
+ const percent = progressPercent(e.loaded, e.total);
2631
+ if (percent !== undefined) {
2632
+ state.setProgress(percent);
2466
2633
  }
2467
2634
  });
2468
2635
  }
@@ -2478,7 +2645,7 @@ function tapAsyncProgress(state) {
2478
2645
  * 5. Call `setError(err)` on error
2479
2646
  *
2480
2647
  * The output Observable emits the **response body** (not HttpEvents).
2481
- * Throws a `CngxRuntimeError` with code `CNGX1054` if the response body is
2648
+ * Throws a `CngxRuntimeError` with code [`CNGX1054`](/error-codes/cngx1054.md) if the response body is
2482
2649
  * `null`; the sink receives it through `setError(err)`.
2483
2650
  *
2484
2651
  * ```typescript
@@ -2495,8 +2662,7 @@ function tapAsyncProgress(state) {
2495
2662
  * // upload.status(), upload.progress(), upload.data() - all wired
2496
2663
  * }
2497
2664
  * ```
2498
- *
2499
- * @category common/data/async-state
2665
+ * <example-url>/#/common/data/async-operators/tap-http-async-state</example-url>
2500
2666
  */
2501
2667
  function tapHttpAsyncState(state, options) {
2502
2668
  return (source) => defer(() => {
@@ -2545,9 +2711,8 @@ function tapHttpAsyncState(state, options) {
2545
2711
  *
2546
2712
  * @returns A probe over `CngxAsyncRegistry.isAnythingLoading`.
2547
2713
  *
2548
- * @category common/data/async-registry
2549
2714
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async-registry/inject-latency-probe.ts
2550
- * @since 0.1.0
2715
+ * @since 0.3.0
2551
2716
  * @relatedTo provideAsyncRegistry, injectAsyncRegistry, createLatencyProbe
2552
2717
  */
2553
2718
  function injectLatencyProbe() {
@@ -2558,16 +2723,12 @@ function injectLatencyProbe() {
2558
2723
  /**
2559
2724
  * Per-request label surfaced in `CngxAsyncRegistry.activeOperations` when the
2560
2725
  * request is tracked by `cngxAsyncInterceptor`. Display only, never a key.
2561
- *
2562
- * @category common/data/async-registry
2563
2726
  */
2564
2727
  const CNGX_ASYNC_LABEL = new HttpContextToken(() => undefined);
2565
2728
  /**
2566
2729
  * Per-request opt-out. When `true`, `cngxAsyncInterceptor` passes the request
2567
2730
  * through without registering it - keeps polling / telemetry pings out of the
2568
2731
  * aggregate without a global allow-list.
2569
- *
2570
- * @category common/data/async-registry
2571
2732
  */
2572
2733
  const CNGX_ASYNC_SKIP = new HttpContextToken(() => false);
2573
2734
  /**
@@ -2577,8 +2738,7 @@ const CNGX_ASYNC_SKIP = new HttpContextToken(() => false);
2577
2738
  * ```typescript
2578
2739
  * this.http.get('/api/users', { context: withAsyncLabel('users') });
2579
2740
  * ```
2580
- *
2581
- * @category common/data/async-registry
2741
+ * <example-url>/#/common/data/async-registry/label-and-skip-requests</example-url>
2582
2742
  */
2583
2743
  function withAsyncLabel(label, context = new HttpContext()) {
2584
2744
  return context.set(CNGX_ASYNC_LABEL, label);
@@ -2590,8 +2750,7 @@ function withAsyncLabel(label, context = new HttpContext()) {
2590
2750
  * ```typescript
2591
2751
  * this.http.get('/api/ping', { context: withAsyncSkip() });
2592
2752
  * ```
2593
- *
2594
- * @category common/data/async-registry
2753
+ * <example-url>/#/common/data/async-registry/label-and-skip-requests</example-url>
2595
2754
  */
2596
2755
  function withAsyncSkip(context = new HttpContext()) {
2597
2756
  return context.set(CNGX_ASYNC_SKIP, true);
@@ -2607,34 +2766,36 @@ function withAsyncSkip(context = new HttpContext()) {
2607
2766
  * request straight through when no registry is provided - zero behaviour
2608
2767
  * change for consumers who do not opt in.
2609
2768
  * - Passes through without registering when `CNGX_ASYNC_SKIP` is set.
2610
- * - Otherwise registers a fresh `createManualState` (set `loading`) under a
2611
- * per-request uid, maps the final response / error onto it, and
2612
- * `unregister`s in a `finalize` that fires on success **and** error (and on
2613
- * unsubscribe), so a request can never pin the global loading state.
2769
+ * - Otherwise registers a fresh `createManualState` (set `loading`) per
2770
+ * subscription, under its own uid, maps the final response / error onto it,
2771
+ * and `unregister`s in a `finalize` that fires on success **and** error (and
2772
+ * on unsubscribe). Every retry attempt is tracked for exactly its own
2773
+ * lifetime, and a request nobody subscribes to is never registered.
2614
2774
  *
2615
2775
  * Per-request uid identity (from `CngxAsyncRegistry`) means concurrent requests
2616
2776
  * sharing a label never evict one another - completing one leaves the other
2617
2777
  * tracked. The interceptor does not swallow errors: `setError` records the
2618
2778
  * failure, then the error propagates to the caller unchanged.
2619
- *
2620
- * @category common/data/async-registry
2779
+ * <example-url>/#/common/data/async-registry/http-requests-in-the-registry</example-url>
2621
2780
  */
2622
2781
  const cngxAsyncInterceptor = (req, next) => {
2623
2782
  const registry = inject(CngxAsyncRegistry, { optional: true });
2624
2783
  if (!registry || req.context.get(CNGX_ASYNC_SKIP)) {
2625
2784
  return next(req);
2626
2785
  }
2627
- const state = createManualState();
2628
- state.set('loading');
2629
- const operationId = registry.register(state, req.context.get(CNGX_ASYNC_LABEL));
2630
- return next(req).pipe(tap({
2631
- next: (event) => {
2632
- if (event.type === HttpEventType.Response) {
2633
- state.setSuccess(event.body);
2634
- }
2635
- },
2636
- error: (err) => state.setError(err),
2637
- }), finalize(() => registry.unregister(operationId)));
2786
+ return defer(() => {
2787
+ const state = createManualState();
2788
+ state.set('loading');
2789
+ const operationId = registry.register(state, req.context.get(CNGX_ASYNC_LABEL));
2790
+ return next(req).pipe(tap({
2791
+ next: (event) => {
2792
+ if (event.type === HttpEventType.Response) {
2793
+ state.setSuccess(event.body);
2794
+ }
2795
+ },
2796
+ error: (err) => state.setError(err),
2797
+ }), finalize(() => registry.unregister(operationId)));
2798
+ });
2638
2799
  };
2639
2800
  /**
2640
2801
  * Sets up `HttpClient` with {@link cngxAsyncInterceptor} so every request
@@ -2661,8 +2822,6 @@ const cngxAsyncInterceptor = (req, next) => {
2661
2822
  * ```ts
2662
2823
  * provideHttpClient(withFetch(), withInterceptors([authInterceptor, cngxAsyncInterceptor]))
2663
2824
  * ```
2664
- *
2665
- * @category common/data/async-registry
2666
2825
  */
2667
2826
  function provideAsyncHttpObservability() {
2668
2827
  return makeEnvironmentProviders([provideHttpClient(withInterceptors([cngxAsyncInterceptor]))]);
@@ -2682,6 +2841,14 @@ function provideAsyncHttpObservability() {
2682
2841
  * directive renders exactly one template, so the error half is flattened
2683
2842
  * away here; surface it separately (toast, alert) when it must be visible
2684
2843
  *
2844
+ * ### Focus across a view switch
2845
+ * When a switch destroys the view that holds focus, focus moves to the first
2846
+ * focusable element (outside any `inert` subtree) of the next rendered view, so
2847
+ * a focused Retry button does not drop keyboard users onto `<body>`. One view
2848
+ * without a focusable element (a skeleton) is bridged; after that the hand-off
2849
+ * lapses. Focus that sits outside the directive, or that the user moved
2850
+ * elsewhere in the meantime, is never touched.
2851
+ *
2685
2852
  * ### Minimal - just content
2686
2853
  * ```html
2687
2854
  * <ul *cngxAsync="residents; let data">
@@ -2708,23 +2875,24 @@ function provideAsyncHttpObservability() {
2708
2875
  * </ng-template>
2709
2876
  * ```
2710
2877
  *
2711
- * @category common/data/async-state
2712
- * @docsKind primary
2713
2878
  * @wcag AA
2714
2879
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async/async.directive.ts
2715
- * @since 0.1.0
2880
+ * @since 0.3.0
2716
2881
  * @relatedTo injectAsyncState, createAsyncState, createManualState
2717
2882
  *
2718
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngx-async-container-full-control-toast</example-url>
2719
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngxasync-one-line</example-url>
2720
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngxasync-with-custom-templates</example-url>
2721
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/composition-overlay-container-toast</example-url>
2722
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/createasyncstate-mutation</example-url>
2723
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/injectasyncstate-reactive-query</example-url>
2883
+ * <example-url>/#/ui/feedback/async-container/cngx-async-container-full-control-toast</example-url>
2884
+ * <example-url>/#/ui/feedback/async-container/cngxasync-one-line</example-url>
2885
+ * <example-url>/#/ui/feedback/async-container/cngxasync-with-custom-templates</example-url>
2886
+ * <example-url>/#/ui/feedback/async-container/composition-overlay-container-toast</example-url>
2887
+ * <example-url>/#/ui/feedback/async-container/createasyncstate-mutation</example-url>
2888
+ * <example-url>/#/ui/feedback/async-container/injectasyncstate-reactive-query</example-url>
2889
+ * @axis level molecule
2724
2890
  */
2725
2891
  class CngxAsync {
2726
2892
  vcr = inject(ViewContainerRef);
2727
2893
  contentTpl = inject(TemplateRef);
2894
+ doc = inject(DOCUMENT);
2895
+ injector = inject(Injector);
2728
2896
  /** The async state to render. */
2729
2897
  cngxAsync = input.required(...(ngDevMode ? [{ debugName: "cngxAsync" }] : /* istanbul ignore next */ []));
2730
2898
  /** Optional skeleton template shown during first load. */
@@ -2733,47 +2901,116 @@ class CngxAsync {
2733
2901
  cngxAsyncEmpty = input(undefined, ...(ngDevMode ? [{ debugName: "cngxAsyncEmpty" }] : /* istanbul ignore next */ []));
2734
2902
  /** Optional error template shown on error during first load. Context: `{ $implicit: error }`. */
2735
2903
  cngxAsyncError = input(undefined, ...(ngDevMode ? [{ debugName: "cngxAsyncError" }] : /* istanbul ignore next */ []));
2904
+ // content+error → content (structural directive has no dual-render)
2736
2905
  view = computed(() => {
2737
2906
  const s = this.cngxAsync();
2738
- return resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
2907
+ const resolved = resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
2908
+ return resolved === 'content+error' ? 'content' : resolved;
2739
2909
  }, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
2740
- // Plain field, not a signal: it is only ever read and written inside the
2741
- // render effect - as a signal it fed the effect's own dependency graph and
2910
+ // The slot template of the current view; the content template is fixed.
2911
+ slotTemplate = computed(() => {
2912
+ switch (this.view()) {
2913
+ case 'skeleton':
2914
+ return this.cngxAsyncSkeleton();
2915
+ case 'empty':
2916
+ return this.cngxAsyncEmpty();
2917
+ case 'error':
2918
+ return this.cngxAsyncError();
2919
+ default:
2920
+ return undefined;
2921
+ }
2922
+ }, ...(ngDevMode ? [{ debugName: "slotTemplate" }] : /* istanbul ignore next */ []));
2923
+ // Plain fields, not signals: they are only ever read and written inside the
2924
+ // render effect - as signals they fed the effect's own dependency graph and
2742
2925
  // caused one spurious re-run per view switch.
2743
2926
  currentView = 'none';
2927
+ currentTemplate = undefined;
2744
2928
  contentViewRef = null;
2929
+ // View switches left in which focus lost by a destroyed view may be handed
2930
+ // on: the switch that lost it plus one more, so a short skeleton in between
2931
+ // is bridged but a much later refresh never pulls focus back.
2932
+ focusSwitchesLeft = 0;
2745
2933
  constructor() {
2746
2934
  effect(() => {
2747
2935
  const view = this.view();
2936
+ const tpl = this.slotTemplate();
2748
2937
  const s = this.cngxAsync();
2749
- // content+error → show content (structural directive has no dual-render)
2750
- const effective = view === 'content+error' ? 'content' : view;
2751
- if (effective === this.currentView) {
2938
+ if (view === this.currentView && tpl === this.currentTemplate) {
2752
2939
  this.updateContentContext(s);
2753
2940
  return;
2754
2941
  }
2942
+ if (this.renderedViewHoldsFocus()) {
2943
+ this.focusSwitchesLeft = 2;
2944
+ }
2755
2945
  this.vcr.clear();
2756
2946
  this.contentViewRef = null;
2757
- this.currentView = effective;
2758
- this.renderView(effective, s);
2947
+ this.currentView = view;
2948
+ this.currentTemplate = tpl;
2949
+ this.renderView(view, tpl, s);
2950
+ if (this.focusSwitchesLeft > 0) {
2951
+ this.focusSwitchesLeft--;
2952
+ untracked(() => afterNextRender(() => this.restoreFocus(), { injector: this.injector }));
2953
+ }
2759
2954
  });
2760
2955
  }
2956
+ renderedRoots() {
2957
+ const roots = [];
2958
+ for (let i = 0; i < this.vcr.length; i++) {
2959
+ const ref = this.vcr.get(i);
2960
+ roots.push(...(ref?.rootNodes ?? []));
2961
+ }
2962
+ return roots;
2963
+ }
2964
+ renderedViewHoldsFocus() {
2965
+ const active = this.doc.activeElement;
2966
+ if (!active || active === this.doc.body) {
2967
+ return false;
2968
+ }
2969
+ return this.renderedRoots().some((node) => node.contains(active));
2970
+ }
2971
+ // Restores focus only when it was lost to the body; a view without a
2972
+ // focusable element leaves the remaining switch budget to the next one.
2973
+ restoreFocus() {
2974
+ const active = this.doc.activeElement;
2975
+ if (active && active !== this.doc.body) {
2976
+ this.focusSwitchesLeft = 0;
2977
+ return;
2978
+ }
2979
+ const target = this.firstFocusable();
2980
+ if (target) {
2981
+ this.focusSwitchesLeft = 0;
2982
+ target.focus();
2983
+ }
2984
+ }
2985
+ firstFocusable() {
2986
+ for (const node of this.renderedRoots()) {
2987
+ if (!(node instanceof HTMLElement)) {
2988
+ continue;
2989
+ }
2990
+ if (node.matches(CNGX_FOCUSABLE_SELECTOR) && !node.closest('[inert]')) {
2991
+ return node;
2992
+ }
2993
+ const inner = Array.from(node.querySelectorAll(CNGX_FOCUSABLE_SELECTOR)).find((el) => !el.closest('[inert]'));
2994
+ if (inner) {
2995
+ return inner;
2996
+ }
2997
+ }
2998
+ return null;
2999
+ }
2761
3000
  updateContentContext(s) {
2762
3001
  if (!this.contentViewRef) {
2763
3002
  return;
2764
3003
  }
2765
3004
  const data = s.data();
2766
- if (data === undefined) {
2767
- return;
2768
- }
2769
3005
  this.contentViewRef.context.$implicit = data;
2770
3006
  this.contentViewRef.context.cngxAsync = data;
2771
3007
  this.contentViewRef.markForCheck();
2772
3008
  }
2773
- renderView(view, s) {
3009
+ renderView(view, tpl, s) {
2774
3010
  switch (view) {
2775
3011
  case 'skeleton':
2776
- this.renderTemplate(this.cngxAsyncSkeleton());
3012
+ case 'empty':
3013
+ this.renderTemplate(tpl);
2777
3014
  break;
2778
3015
  case 'content':
2779
3016
  case 'content+error': {
@@ -2784,11 +3021,8 @@ class CngxAsync {
2784
3021
  });
2785
3022
  break;
2786
3023
  }
2787
- case 'empty':
2788
- this.renderTemplate(this.cngxAsyncEmpty());
2789
- break;
2790
3024
  case 'error':
2791
- this.renderTemplate(this.cngxAsyncError(), { $implicit: s.error() });
3025
+ this.renderTemplate(tpl, { $implicit: s.error() });
2792
3026
  break;
2793
3027
  }
2794
3028
  }
@@ -2816,8 +3050,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2816
3050
  * The English kpi section: the single source of the KPI atoms' English copy.
2817
3051
  * `CNGX_KPI_I18N` defaults to it.
2818
3052
  *
2819
- * @category common/data/i18n
2820
- * @since 0.1.0
3053
+ * @since 0.3.0
2821
3054
  * @relatedTo CNGX_KPI_I18N
2822
3055
  */
2823
3056
  const CNGX_KPI_LANGUAGE_EN = {
@@ -2871,30 +3104,24 @@ const kpiBundle = createSectionBundle({
2871
3104
  * app locale; the value is a `Signal`, shared by every reader under one
2872
3105
  * injector.
2873
3106
  *
2874
- * @category common/data/i18n
2875
3107
  * @wcag AA
2876
3108
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/shared/kpi-i18n.ts
2877
- * @since 0.1.0
3109
+ * @since 0.3.0
2878
3110
  * @relatedTo CngxDelta, CngxTrend, CngxGoal
2879
3111
  */
2880
3112
  const CNGX_KPI_I18N = new InjectionToken('CngxKpiI18n', {
2881
3113
  providedIn: 'root',
2882
3114
  factory: () => kpiBundle.build(),
2883
3115
  });
2884
- /** @internal */
2885
- function defineKpiI18nFeature(fn) {
2886
- return Object.assign(fn, { _target: 'i18n' });
2887
- }
2888
3116
  /**
2889
3117
  * Override KPI labels via a partial bundle - unset keys keep the language
2890
3118
  * pack's copy, or the English default. Pass a `Signal` of a partial bundle to switch languages at
2891
3119
  * runtime.
2892
3120
  *
2893
- * @category common/data/i18n
2894
- * @since 0.1.0
3121
+ * @since 0.3.0
2895
3122
  */
2896
3123
  function withKpiI18nLabels(overrides) {
2897
- return defineKpiI18nFeature((bundle) => createOverrideMerge(bundle, overrides));
3124
+ return (bundle) => createOverrideMerge(bundle, overrides);
2898
3125
  }
2899
3126
  /**
2900
3127
  * Provider for the KPI i18n bundle. Returns a plain `Provider`, so it also
@@ -2913,8 +3140,7 @@ function withKpiI18nLabels(overrides) {
2913
3140
  * });
2914
3141
  * ```
2915
3142
  *
2916
- * @category common/data/i18n
2917
- * @since 0.1.0
3143
+ * @since 0.3.0
2918
3144
  */
2919
3145
  function provideKpiI18n(...features) {
2920
3146
  return {
@@ -2926,8 +3152,7 @@ function provideKpiI18n(...features) {
2926
3152
  * Inject the resolved KPI i18n bundle signal. Read it inside a `computed()`
2927
3153
  * or template so a runtime override flip re-derives.
2928
3154
  *
2929
- * @category common/data/i18n
2930
- * @since 0.1.0
3155
+ * @since 0.3.0
2931
3156
  */
2932
3157
  function injectKpiI18n() {
2933
3158
  return kpiBundle.resolve(inject(CNGX_KPI_I18N));
@@ -2966,15 +3191,14 @@ function readsUnitFirst(message) {
2966
3191
  * </cngx-card>
2967
3192
  * ```
2968
3193
  *
2969
- * @category common/data/metric
2970
- * @docsKind primary
2971
3194
  * @wcag AA
2972
3195
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/metric/metric.component.ts
2973
- * @since 0.1.0
3196
+ * @since 0.3.0
2974
3197
  * @relatedTo CngxTrend, CngxCard
2975
3198
  *
2976
- * <example-url>http://localhost:4200/#/common/data/metric/inside-a-card</example-url>
2977
- * <example-url>http://localhost:4200/#/common/data/metric/standalone-metrics</example-url>
3199
+ * <example-url>/#/common/data/metric/inside-a-card</example-url>
3200
+ * <example-url>/#/common/data/metric/standalone-metrics</example-url>
3201
+ * @axis level atom
2978
3202
  */
2979
3203
  class CngxMetric {
2980
3204
  locale = injectLocale();
@@ -3028,7 +3252,7 @@ class CngxMetric {
3028
3252
  @if (shownUnit() && !unitFirst()) {
3029
3253
  <span class="cngx-metric__unit">{{ shownUnit() }}</span>
3030
3254
  }
3031
- `, 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{--cngx-metric-gap: var(--cngx-space-xs);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;unicode-bidi:var(--cngx-metric-bidi, isolate)}.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 });
3255
+ `, 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{--cngx-metric-gap: var(--cngx-space-xs);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);line-height:1.2;unicode-bidi:var(--cngx-metric-bidi, isolate)}.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 });
3032
3256
  }
3033
3257
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMetric, decorators: [{
3034
3258
  type: Component,
@@ -3048,7 +3272,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3048
3272
  @if (shownUnit() && !unitFirst()) {
3049
3273
  <span class="cngx-metric__unit">{{ shownUnit() }}</span>
3050
3274
  }
3051
- `, 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{--cngx-metric-gap: var(--cngx-space-xs);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;unicode-bidi:var(--cngx-metric-bidi, isolate)}.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"] }]
3275
+ `, 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{--cngx-metric-gap: var(--cngx-space-xs);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);line-height:1.2;unicode-bidi:var(--cngx-metric-bidi, isolate)}.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"] }]
3052
3276
  }], 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 }] }] } });
3053
3277
 
3054
3278
  /**
@@ -3063,7 +3287,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3063
3287
  * consume these helpers so the direction / glyph / format logic has a single
3064
3288
  * source of truth (Pillar 1) with no Angular dependency.
3065
3289
  */
3066
- /** `> 0 → up`, `< 0 → down`, `0 → flat`. */
3290
+ /**
3291
+ * `> 0 → up`, `< 0 → down`, `0 → flat`.
3292
+ * @internal
3293
+ */
3067
3294
  function deltaDirection(value) {
3068
3295
  return value > 0 ? 'up' : value < 0 ? 'down' : 'flat';
3069
3296
  }
@@ -3071,6 +3298,7 @@ function deltaDirection(value) {
3071
3298
  * Combine movement with the caller's polarity. `flat` or `neutral` polarity
3072
3299
  * collapse to `neutral`; otherwise up is positive under `higher-is-better`
3073
3300
  * and negative under `lower-is-better` (and the reverse for down).
3301
+ * @internal
3074
3302
  */
3075
3303
  function deltaSentiment(direction, polarity) {
3076
3304
  if (direction === 'flat' || polarity === 'neutral') {
@@ -3080,7 +3308,10 @@ function deltaSentiment(direction, polarity) {
3080
3308
  const isGood = direction === 'up' ? upIsGood : !upIsGood;
3081
3309
  return isGood ? 'positive' : 'negative';
3082
3310
  }
3083
- /** Arrow glyph for the direction: `↑` / `↓` / `→`. */
3311
+ /**
3312
+ * Arrow glyph for the direction: `↑` / `↓` / `→`.
3313
+ * @internal
3314
+ */
3084
3315
  function directionGlyph(direction) {
3085
3316
  return direction === 'up' ? '↑' : direction === 'down' ? '↓' : '→';
3086
3317
  }
@@ -3092,6 +3323,7 @@ function directionGlyph(direction) {
3092
3323
  * absolute mode uses the locale grouping.
3093
3324
  * A supplied `Intl.NumberFormatOptions` overrides the default digit handling
3094
3325
  * in both modes.
3326
+ * @internal
3095
3327
  */
3096
3328
  function formatDelta(value, mode, locale, format) {
3097
3329
  const abs = Math.abs(value);
@@ -3136,15 +3368,14 @@ function formatDelta(value, mode, locale, format) {
3136
3368
  * </cngx-card>
3137
3369
  * ```
3138
3370
  *
3139
- * @category common/data/metric
3140
- * @docsKind primary
3141
3371
  * @wcag AA
3142
3372
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/trend/trend.component.ts
3143
- * @since 0.1.0
3373
+ * @since 0.3.0
3144
3374
  * @relatedTo CngxMetric, CngxCard
3145
3375
  *
3146
- * <example-url>http://localhost:4200/#/common/data/trend/composed-with-metric-in-a-card</example-url>
3147
- * <example-url>http://localhost:4200/#/common/data/trend/trend-directions</example-url>
3376
+ * <example-url>/#/common/data/trend/composed-with-metric-in-a-card</example-url>
3377
+ * <example-url>/#/common/data/trend/trend-directions</example-url>
3378
+ * @axis level atom
3148
3379
  */
3149
3380
  class CngxTrend {
3150
3381
  locale = injectLocale();
@@ -3164,7 +3395,7 @@ class CngxTrend {
3164
3395
  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: { attributes: { "role": "img" }, properties: { "class.cngx-trend--up": "value() > 0", "class.cngx-trend--down": "value() < 0", "attr.aria-label": "resolvedLabel()" }, classAttribute: "cngx-trend" }, ngImport: i0, template: `
3165
3396
  <span aria-hidden="true">{{ icon() }}</span>
3166
3397
  {{ formattedValue() }}
3167
- `, 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{--cngx-trend-gap: var(--cngx-space-xs);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));unicode-bidi:var(--cngx-trend-bidi, isolate);direction:var(--cngx-trend-direction, ltr)}: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 });
3398
+ `, 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(.46 .15 145);}@property --cngx-trend-down-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .22 25);}:root{--cngx-trend-up-color: var(--cngx-color-success-text, oklch(.46 .15 145))}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-trend-color: oklch(.7 .01 290);--cngx-trend-up-color: var(--cngx-color-success-text, oklch(.74 .14 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: var(--cngx-color-success-text, oklch(.74 .14 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: var(--cngx-color-success-text, oklch(.46 .15 145));--cngx-trend-down-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-trend){:scope{--cngx-trend-gap: var(--cngx-space-xs);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));unicode-bidi:var(--cngx-trend-bidi, isolate);direction:var(--cngx-trend-direction, ltr)}:scope.cngx-trend--up{color:var(--cngx-trend-up-color)}:scope.cngx-trend--down{color:var(--cngx-trend-down-color)}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
3168
3399
  }
3169
3400
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTrend, decorators: [{
3170
3401
  type: Component,
@@ -3180,7 +3411,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3180
3411
  }, template: `
3181
3412
  <span aria-hidden="true">{{ icon() }}</span>
3182
3413
  {{ formattedValue() }}
3183
- `, 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{--cngx-trend-gap: var(--cngx-space-xs);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));unicode-bidi:var(--cngx-trend-bidi, isolate);direction:var(--cngx-trend-direction, ltr)}: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"] }]
3414
+ `, 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(.46 .15 145);}@property --cngx-trend-down-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .22 25);}:root{--cngx-trend-up-color: var(--cngx-color-success-text, oklch(.46 .15 145))}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-trend-color: oklch(.7 .01 290);--cngx-trend-up-color: var(--cngx-color-success-text, oklch(.74 .14 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: var(--cngx-color-success-text, oklch(.74 .14 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: var(--cngx-color-success-text, oklch(.46 .15 145));--cngx-trend-down-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-trend){:scope{--cngx-trend-gap: var(--cngx-space-xs);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));unicode-bidi:var(--cngx-trend-bidi, isolate);direction:var(--cngx-trend-direction, ltr)}:scope.cngx-trend--up{color:var(--cngx-trend-up-color)}:scope.cngx-trend--down{color:var(--cngx-trend-down-color)}}}\n"] }]
3184
3415
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
3185
3416
 
3186
3417
  /**
@@ -3211,14 +3442,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3211
3442
  * <cngx-delta [value]="1240" mode="absolute" [format]="{ maximumFractionDigits: 0 }" />
3212
3443
  * ```
3213
3444
  *
3214
- * @category common/data/metric
3215
- * @docsKind primary
3216
3445
  * @wcag AA
3217
3446
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/delta/delta.component.ts
3218
- * @since 0.1.0
3447
+ * @since 0.3.0
3219
3448
  * @relatedTo CngxTrend, CngxMetric, CngxStat
3220
3449
  *
3221
- * <example-url>http://localhost:4200/#/common/data/delta/sentiment-polarity</example-url>
3450
+ * <example-url>/#/common/data/delta/sentiment-polarity</example-url>
3451
+ * @axis level atom
3222
3452
  */
3223
3453
  class CngxDelta {
3224
3454
  locale = injectLocale();
@@ -3254,7 +3484,7 @@ class CngxDelta {
3254
3484
  static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxDelta, isStandalone: true, selector: "cngx-delta", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, polarity: { classPropertyName: "polarity", publicName: "polarity", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "img" }, properties: { "class.cngx-delta--positive": "sentiment() === 'positive'", "class.cngx-delta--negative": "sentiment() === 'negative'", "class.cngx-delta--neutral": "sentiment() === 'neutral'", "attr.aria-label": "resolvedLabel()" }, classAttribute: "cngx-delta" }, ngImport: i0, template: `
3255
3485
  <span aria-hidden="true">{{ glyph() }}</span>
3256
3486
  {{ formattedValue() }}
3257
- `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-delta-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-delta-size{syntax: \"*\"; inherits: true; initial-value: .8125rem;}@property --cngx-delta-weight{syntax: \"<number>\"; inherits: true; initial-value: 500;}@property --cngx-delta-neutral-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@property --cngx-delta-positive-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@property --cngx-delta-negative-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-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: oklch(.78 .16 145);--cngx-delta-negative-color: oklch(.75 .18 25)}}[data-color-scheme=dark],.dark{--cngx-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: oklch(.78 .16 145);--cngx-delta-negative-color: oklch(.75 .18 25)}[data-color-scheme=light],.light{--cngx-delta-neutral-color: oklch(.36 .02 290);--cngx-delta-positive-color: oklch(.65 .18 145);--cngx-delta-negative-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-delta){:scope{--cngx-delta-gap: var(--cngx-space-xs);display:inline-flex;align-items:center;gap:var(--cngx-delta-gap, 2px);font-size:var(--cngx-delta-size, .8125rem);font-weight:var(--cngx-delta-weight, 500);color:var(--cngx-delta-neutral-color, oklch(.36 .02 290));unicode-bidi:var(--cngx-delta-bidi, isolate);direction:var(--cngx-delta-direction, ltr)}:scope.cngx-delta--positive{color:var(--cngx-delta-positive-color, var(--cngx-color-success, oklch(.65 .18 145)))}:scope.cngx-delta--negative{color:var(--cngx-delta-negative-color, var(--cngx-color-danger, oklch(.65 .22 25)))}:scope.cngx-delta--neutral{color:var(--cngx-delta-neutral-color, oklch(.36 .02 290))}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
3487
+ `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-delta-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-delta-size{syntax: \"*\"; inherits: true; initial-value: .8125rem;}@property --cngx-delta-weight{syntax: \"<number>\"; inherits: true; initial-value: 500;}@property --cngx-delta-neutral-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@property --cngx-delta-positive-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.46 .15 145);}@property --cngx-delta-negative-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .22 25);}:root{--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.46 .15 145))}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.74 .14 145));--cngx-delta-negative-color: oklch(.75 .18 25)}}[data-color-scheme=dark],.dark{--cngx-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.74 .14 145));--cngx-delta-negative-color: oklch(.75 .18 25)}[data-color-scheme=light],.light{--cngx-delta-neutral-color: oklch(.36 .02 290);--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.46 .15 145));--cngx-delta-negative-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-delta){:scope{--cngx-delta-gap: var(--cngx-space-xs);display:inline-flex;align-items:center;gap:var(--cngx-delta-gap, 2px);font-size:var(--cngx-delta-size, .8125rem);font-weight:var(--cngx-delta-weight, 500);color:var(--cngx-delta-neutral-color, oklch(.36 .02 290));unicode-bidi:var(--cngx-delta-bidi, isolate);direction:var(--cngx-delta-direction, ltr)}:scope.cngx-delta--positive{color:var(--cngx-delta-positive-color)}:scope.cngx-delta--negative{color:var(--cngx-delta-negative-color)}:scope.cngx-delta--neutral{color:var(--cngx-delta-neutral-color, oklch(.36 .02 290))}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
3258
3488
  }
3259
3489
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDelta, decorators: [{
3260
3490
  type: Component,
@@ -3272,7 +3502,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3272
3502
  }, template: `
3273
3503
  <span aria-hidden="true">{{ glyph() }}</span>
3274
3504
  {{ formattedValue() }}
3275
- `, styles: ["@layer cngx.tokens{@property --cngx-delta-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-delta-size{syntax: \"*\"; inherits: true; initial-value: .8125rem;}@property --cngx-delta-weight{syntax: \"<number>\"; inherits: true; initial-value: 500;}@property --cngx-delta-neutral-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@property --cngx-delta-positive-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@property --cngx-delta-negative-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-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: oklch(.78 .16 145);--cngx-delta-negative-color: oklch(.75 .18 25)}}[data-color-scheme=dark],.dark{--cngx-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: oklch(.78 .16 145);--cngx-delta-negative-color: oklch(.75 .18 25)}[data-color-scheme=light],.light{--cngx-delta-neutral-color: oklch(.36 .02 290);--cngx-delta-positive-color: oklch(.65 .18 145);--cngx-delta-negative-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-delta){:scope{--cngx-delta-gap: var(--cngx-space-xs);display:inline-flex;align-items:center;gap:var(--cngx-delta-gap, 2px);font-size:var(--cngx-delta-size, .8125rem);font-weight:var(--cngx-delta-weight, 500);color:var(--cngx-delta-neutral-color, oklch(.36 .02 290));unicode-bidi:var(--cngx-delta-bidi, isolate);direction:var(--cngx-delta-direction, ltr)}:scope.cngx-delta--positive{color:var(--cngx-delta-positive-color, var(--cngx-color-success, oklch(.65 .18 145)))}:scope.cngx-delta--negative{color:var(--cngx-delta-negative-color, var(--cngx-color-danger, oklch(.65 .22 25)))}:scope.cngx-delta--neutral{color:var(--cngx-delta-neutral-color, oklch(.36 .02 290))}}}\n"] }]
3505
+ `, styles: ["@layer cngx.tokens{@property --cngx-delta-gap{syntax: \"<length>\"; inherits: false; initial-value: 2px;}@property --cngx-delta-size{syntax: \"*\"; inherits: true; initial-value: .8125rem;}@property --cngx-delta-weight{syntax: \"<number>\"; inherits: true; initial-value: 500;}@property --cngx-delta-neutral-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.36 .02 290);}@property --cngx-delta-positive-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.46 .15 145);}@property --cngx-delta-negative-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .22 25);}:root{--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.46 .15 145))}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.74 .14 145));--cngx-delta-negative-color: oklch(.75 .18 25)}}[data-color-scheme=dark],.dark{--cngx-delta-neutral-color: oklch(.7 .01 290);--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.74 .14 145));--cngx-delta-negative-color: oklch(.75 .18 25)}[data-color-scheme=light],.light{--cngx-delta-neutral-color: oklch(.36 .02 290);--cngx-delta-positive-color: var(--cngx-color-success-text, oklch(.46 .15 145));--cngx-delta-negative-color: oklch(.65 .22 25)}}@layer cngx.components{@scope(.cngx-delta){:scope{--cngx-delta-gap: var(--cngx-space-xs);display:inline-flex;align-items:center;gap:var(--cngx-delta-gap, 2px);font-size:var(--cngx-delta-size, .8125rem);font-weight:var(--cngx-delta-weight, 500);color:var(--cngx-delta-neutral-color, oklch(.36 .02 290));unicode-bidi:var(--cngx-delta-bidi, isolate);direction:var(--cngx-delta-direction, ltr)}:scope.cngx-delta--positive{color:var(--cngx-delta-positive-color)}:scope.cngx-delta--negative{color:var(--cngx-delta-negative-color)}:scope.cngx-delta--neutral{color:var(--cngx-delta-neutral-color, oklch(.36 .02 290))}}}\n"] }]
3276
3506
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], polarity: [{ type: i0.Input, args: [{ isSignal: true, alias: "polarity", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], format: [{ type: i0.Input, args: [{ isSignal: true, alias: "format", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
3277
3507
 
3278
3508
  /** Fixed reading order for the coordinated slots. */
@@ -3300,9 +3530,8 @@ const kindsEqual = (a, b) => a.length === b.length && a.every((kind, i) => kind
3300
3530
  * Same shape as `CngxPaginate` behind `CNGX_PAGINATOR_HOST`, which
3301
3531
  * `CngxPaginator` and `CngxIncrementalList` share the same way.
3302
3532
  *
3303
- * @category common/data/metric
3304
3533
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/stat/stat-coordinator.directive.ts
3305
- * @since 0.1.0
3534
+ * @since 0.3.0
3306
3535
  * @relatedTo CngxStat, CNGX_STAT
3307
3536
  */
3308
3537
  class CngxStatCoordinator {
@@ -3377,14 +3606,13 @@ const CNGX_STAT = new InjectionToken('CNGX_STAT');
3377
3606
  * </cngx-stat>
3378
3607
  * ```
3379
3608
  *
3380
- * @category common/data/metric
3381
- * @docsKind primary
3382
3609
  * @wcag AA
3383
3610
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/stat/stat.component.ts
3384
- * @since 0.1.0
3611
+ * @since 0.3.0
3385
3612
  * @relatedTo CngxMetric, CngxDelta, CngxTrend, CngxStatCoordinator
3386
3613
  *
3387
- * <example-url>http://localhost:4200/#/common/data/stat/composed-kpi</example-url>
3614
+ * <example-url>/#/common/data/stat/composed-kpi</example-url>
3615
+ * @axis level molecule
3388
3616
  */
3389
3617
  class CngxStat {
3390
3618
  /** @internal The shared slot-id brain, applied as a host directive. */
@@ -3437,8 +3665,7 @@ function useStatSlot(kind) {
3437
3665
  * Marks the label element of a {@link CngxStat}. Its generated id leads the
3438
3666
  * molecule's `aria-labelledby`.
3439
3667
  *
3440
- * @category common/data/metric
3441
- * @since 0.1.0
3668
+ * @since 0.3.0
3442
3669
  * @relatedTo CngxStat
3443
3670
  */
3444
3671
  class CngxStatLabel {
@@ -3459,8 +3686,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3459
3686
  * Marks the primary value element of a {@link CngxStat} (typically a
3460
3687
  * `<cngx-metric>`).
3461
3688
  *
3462
- * @category common/data/metric
3463
- * @since 0.1.0
3689
+ * @since 0.3.0
3464
3690
  * @relatedTo CngxStat
3465
3691
  */
3466
3692
  class CngxStatValue {
@@ -3481,8 +3707,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3481
3707
  * Marks the delta element of a {@link CngxStat} (typically a `<cngx-delta>`
3482
3708
  * or `<cngx-trend>`).
3483
3709
  *
3484
- * @category common/data/metric
3485
- * @since 0.1.0
3710
+ * @since 0.3.0
3486
3711
  * @relatedTo CngxStat
3487
3712
  */
3488
3713
  class CngxStatDelta {
@@ -3503,8 +3728,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3503
3728
  * Marks the caption element of a {@link CngxStat} - the trailing context
3504
3729
  * line (e.g. "vs. last quarter").
3505
3730
  *
3506
- * @category common/data/metric
3507
- * @since 0.1.0
3731
+ * @since 0.3.0
3508
3732
  * @relatedTo CngxStat
3509
3733
  */
3510
3734
  class CngxStatCaption {
@@ -3539,14 +3763,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3539
3763
  * <cngx-goal [value]="q()" [max]="target()" [valueTextFormat]="quotaText" />
3540
3764
  * ```
3541
3765
  *
3542
- * @category common/data/metric
3543
- * @docsKind primary
3544
3766
  * @wcag AA
3545
3767
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/goal/goal.component.ts
3546
- * @since 0.1.0
3768
+ * @since 0.3.0
3547
3769
  * @relatedTo CngxSegmentedProgress, CngxMetric
3548
3770
  *
3549
- * <example-url>http://localhost:4200/#/common/data/goal/quota-attainment</example-url>
3771
+ * <example-url>/#/common/data/goal/quota-attainment</example-url>
3772
+ * @axis level atom
3550
3773
  */
3551
3774
  class CngxGoal {
3552
3775
  i18n = injectKpiI18n();
@@ -3584,7 +3807,7 @@ class CngxGoal {
3584
3807
  return fmt(this.now(), this.maxValue());
3585
3808
  }, ...(ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []));
3586
3809
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxGoal, deps: [], target: i0.ɵɵFactoryTarget.Component });
3587
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxGoal, isStandalone: true, selector: "cngx-goal", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, valueTextFormat: { classPropertyName: "valueTextFormat", publicName: "valueTextFormat", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar" }, properties: { "attr.aria-valuemin": "0", "attr.aria-valuemax": "maxValue()", "attr.aria-valuenow": "now()", "attr.aria-valuetext": "valueText()", "attr.aria-label": "label() ?? null", "style.--cngx-goal-fill.%": "fillPercent()" }, classAttribute: "cngx-goal" }, ngImport: i0, template: `<span class="cngx-goal__track"><span class="cngx-goal__fill"></span></span>`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-goal-fill{syntax: \"<percentage>\"; inherits: true; initial-value: 0%;}@property --cngx-goal-height{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-goal-radius{syntax: \"<length>\"; inherits: false; initial-value: 999px;}@property --cngx-goal-track-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.92 .01 290);}@property --cngx-goal-fill-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}}[data-color-scheme=dark],.dark{--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}[data-color-scheme=light],.light{--cngx-goal-track-color: oklch(.92 .01 290);--cngx-goal-fill-color: oklch(.65 .18 145)}}@layer cngx.components{@scope(.cngx-goal){:scope{display:block;inline-size:100%}.cngx-goal__track{display:block;inline-size:100%;block-size:var(--cngx-goal-height, 8px);border-radius:var(--cngx-goal-radius, 999px);background:var(--cngx-goal-track-color, oklch(.92 .01 290));overflow:hidden}.cngx-goal__fill{display:block;block-size:100%;inline-size:var(--cngx-goal-fill, 0%);border-radius:inherit;background:var(--cngx-goal-fill-color, var(--cngx-color-success, oklch(.65 .18 145)))}}}@media(forced-colors:active){.cngx-goal__track{box-sizing:border-box;border:1px solid CanvasText}.cngx-goal__fill{background:Highlight}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
3810
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxGoal, isStandalone: true, selector: "cngx-goal", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: true, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, valueTextFormat: { classPropertyName: "valueTextFormat", publicName: "valueTextFormat", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar" }, properties: { "attr.aria-valuemin": "0", "attr.aria-valuemax": "maxValue()", "attr.aria-valuenow": "now()", "attr.aria-valuetext": "valueText()", "attr.aria-label": "label() ?? null", "style.--cngx-goal-fill.%": "fillPercent()" }, classAttribute: "cngx-goal" }, ngImport: i0, template: `<span class="cngx-goal__track"><span class="cngx-goal__fill"></span></span>`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-goal-fill{syntax: \"<percentage>\"; inherits: true; initial-value: 0%;}@property --cngx-goal-height{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-goal-radius{syntax: \"<length>\"; inherits: false; initial-value: 999px;}@property --cngx-goal-track-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.92 .01 290);}@property --cngx-goal-fill-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}}[data-color-scheme=dark],.dark{--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}[data-color-scheme=light],.light{--cngx-goal-track-color: oklch(.92 .01 290);--cngx-goal-fill-color: oklch(.65 .18 145)}}@layer cngx.components{@scope(.cngx-goal){:scope{display:block;inline-size:100%}.cngx-goal__track{display:block;inline-size:100%;block-size:var(--cngx-goal-height, 8px);border-radius:var(--cngx-goal-radius, 999px);background:var(--cngx-goal-track-color, oklch(.92 .01 290));overflow:hidden}.cngx-goal__fill{display:block;block-size:100%;inline-size:var(--cngx-goal-fill, 0%);border-radius:inherit;background:var(--cngx-goal-fill-color)}}}@media(forced-colors:active){.cngx-goal__track{box-sizing:border-box;border:1px solid CanvasText}.cngx-goal__fill{background:Highlight}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
3588
3811
  }
3589
3812
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxGoal, decorators: [{
3590
3813
  type: Component,
@@ -3597,15 +3820,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3597
3820
  '[attr.aria-valuetext]': 'valueText()',
3598
3821
  '[attr.aria-label]': 'label() ?? null',
3599
3822
  '[style.--cngx-goal-fill.%]': 'fillPercent()',
3600
- }, template: `<span class="cngx-goal__track"><span class="cngx-goal__fill"></span></span>`, styles: ["@layer cngx.tokens{@property --cngx-goal-fill{syntax: \"<percentage>\"; inherits: true; initial-value: 0%;}@property --cngx-goal-height{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-goal-radius{syntax: \"<length>\"; inherits: false; initial-value: 999px;}@property --cngx-goal-track-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.92 .01 290);}@property --cngx-goal-fill-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}}[data-color-scheme=dark],.dark{--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}[data-color-scheme=light],.light{--cngx-goal-track-color: oklch(.92 .01 290);--cngx-goal-fill-color: oklch(.65 .18 145)}}@layer cngx.components{@scope(.cngx-goal){:scope{display:block;inline-size:100%}.cngx-goal__track{display:block;inline-size:100%;block-size:var(--cngx-goal-height, 8px);border-radius:var(--cngx-goal-radius, 999px);background:var(--cngx-goal-track-color, oklch(.92 .01 290));overflow:hidden}.cngx-goal__fill{display:block;block-size:100%;inline-size:var(--cngx-goal-fill, 0%);border-radius:inherit;background:var(--cngx-goal-fill-color, var(--cngx-color-success, oklch(.65 .18 145)))}}}@media(forced-colors:active){.cngx-goal__track{box-sizing:border-box;border:1px solid CanvasText}.cngx-goal__fill{background:Highlight}}\n"] }]
3823
+ }, template: `<span class="cngx-goal__track"><span class="cngx-goal__fill"></span></span>`, styles: ["@layer cngx.tokens{@property --cngx-goal-fill{syntax: \"<percentage>\"; inherits: true; initial-value: 0%;}@property --cngx-goal-height{syntax: \"<length>\"; inherits: false; initial-value: 8px;}@property --cngx-goal-radius{syntax: \"<length>\"; inherits: false; initial-value: 999px;}@property --cngx-goal-track-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.92 .01 290);}@property --cngx-goal-fill-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.65 .18 145);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}}[data-color-scheme=dark],.dark{--cngx-goal-track-color: oklch(.3 .01 290);--cngx-goal-fill-color: oklch(.78 .16 145)}[data-color-scheme=light],.light{--cngx-goal-track-color: oklch(.92 .01 290);--cngx-goal-fill-color: oklch(.65 .18 145)}}@layer cngx.components{@scope(.cngx-goal){:scope{display:block;inline-size:100%}.cngx-goal__track{display:block;inline-size:100%;block-size:var(--cngx-goal-height, 8px);border-radius:var(--cngx-goal-radius, 999px);background:var(--cngx-goal-track-color, oklch(.92 .01 290));overflow:hidden}.cngx-goal__fill{display:block;block-size:100%;inline-size:var(--cngx-goal-fill, 0%);border-radius:inherit;background:var(--cngx-goal-fill-color)}}}@media(forced-colors:active){.cngx-goal__track{box-sizing:border-box;border:1px solid CanvasText}.cngx-goal__fill{background:Highlight}}\n"] }]
3601
3824
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], valueTextFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "valueTextFormat", required: false }] }] } });
3602
3825
 
3603
3826
  /**
3604
3827
  * The English recycler section: the single source of the recycler's English
3605
3828
  * copy. `CNGX_RECYCLER_I18N` defaults to it.
3606
3829
  *
3607
- * @category common/data/i18n
3608
- * @since 0.1.0
3830
+ * @since 0.3.0
3609
3831
  * @relatedTo CNGX_RECYCLER_I18N
3610
3832
  */
3611
3833
  const CNGX_RECYCLER_LANGUAGE_EN = {
@@ -3642,10 +3864,15 @@ const EMPTY_RANGE = {
3642
3864
  * @param overscanAfter Extra items to render below the viewport (leading edge when
3643
3865
  * scrolling down). Defaults to `overscanBefore` for a symmetric range. Callers pass
3644
3866
  * an asymmetric pair to pre-render into the scroll direction.
3867
+ * @param maxLead Largest lead the caller ever adds to one overscan side. When set,
3868
+ * a list-mode window that reaches the last item holds the largest window the list
3869
+ * renders anywhere, so the scroll extent never shrinks on the way to the end.
3870
+ * Without it the window loses its trailing rows there, and WebKit pulls `scrollTop`
3871
+ * back by the height they took, on every step, so the last row stays out of reach.
3645
3872
  * @returns The computed range with spacer offsets.
3646
3873
  * @internal
3647
3874
  */
3648
- function computeRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, columns = 1, overscanAfter = overscanBefore) {
3875
+ function computeRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, columns = 1, overscanAfter = overscanBefore, maxLead) {
3649
3876
  if (totalCount <= 0) {
3650
3877
  return EMPTY_RANGE;
3651
3878
  }
@@ -3663,7 +3890,7 @@ function computeRange(scrollTop, clientHeight, totalCount, estimateSize, oversca
3663
3890
  return computeFixedRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter, columns);
3664
3891
  }
3665
3892
  // variable heights: grid mode unsupported, columns ignored
3666
- return computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter);
3893
+ return computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter, maxLead);
3667
3894
  }
3668
3895
  function estimateTotalSize(totalCount, estimateSize, columns) {
3669
3896
  if (typeof estimateSize === 'number') {
@@ -3724,7 +3951,7 @@ function computeGridRange(scrollTop, clientHeight, totalCount, rowHeight, oversc
3724
3951
  totalSize,
3725
3952
  };
3726
3953
  }
3727
- function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter) {
3954
+ function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter, maxLead) {
3728
3955
  let totalSize = 0;
3729
3956
  const offsets = new Array(totalCount + 1);
3730
3957
  offsets[0] = 0;
@@ -3735,8 +3962,15 @@ function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize,
3735
3962
  // binary search: first item whose bottom edge is past scrollTop
3736
3963
  const rawStart = binarySearch(offsets, scrollTop, totalCount);
3737
3964
  const rawEnd = binarySearch(offsets, scrollTop + clientHeight, totalCount);
3738
- const start = Math.max(0, rawStart - overscanBefore);
3739
3965
  const end = Math.min(totalCount, rawEnd + 1 + overscanAfter);
3966
+ const leadingStart = rawStart - overscanBefore;
3967
+ const endWindowStart = () => {
3968
+ const rowsInView = totalCount - binarySearch(offsets, totalSize - clientHeight, totalCount);
3969
+ const overscan = 2 * Math.min(overscanBefore, overscanAfter);
3970
+ return totalCount - (rowsInView + 1 + overscan + (maxLead ?? 0));
3971
+ };
3972
+ const holdsEndWindow = maxLead !== undefined && end === totalCount;
3973
+ const start = Math.max(0, holdsEndWindow ? Math.min(leadingStart, endWindowStart()) : leadingStart);
3740
3974
  return {
3741
3975
  start,
3742
3976
  end,
@@ -3961,27 +4195,20 @@ const recyclerBundle = createSectionBundle({
3961
4195
  * of the active language pack over English, counts formatted for the app
3962
4196
  * locale. Override with `provideRecyclerI18n()`.
3963
4197
  *
3964
- * @category common/data/recycler
3965
4198
  * @wcag AA
3966
4199
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler.ts
3967
- * @since 0.1.0
4200
+ * @since 0.3.0
3968
4201
  */
3969
4202
  const CNGX_RECYCLER_I18N = new InjectionToken('CngxRecyclerI18n', {
3970
4203
  factory: () => recyclerBundle.build(),
3971
4204
  });
3972
- /** @internal */
3973
- function defineRecyclerI18nFeature(fn) {
3974
- return Object.assign(fn, { _target: 'i18n' });
3975
- }
3976
4205
  /**
3977
4206
  * Override recycler announcements via a partial bundle - keys you leave out
3978
4207
  * keep the language pack's text, or the English default. Pass a `Signal` to
3979
4208
  * switch the language at runtime.
3980
- *
3981
- * @category common/data/recycler
3982
4209
  */
3983
4210
  function withRecyclerI18nLabels(overrides) {
3984
- return defineRecyclerI18nFeature((bundle) => createOverrideMerge(bundle, overrides));
4211
+ return (bundle) => createOverrideMerge(bundle, overrides);
3985
4212
  }
3986
4213
  /**
3987
4214
  * Provider for the recycler announcement texts. The features apply on top of
@@ -3997,8 +4224,6 @@ function withRecyclerI18nLabels(overrides) {
3997
4224
  * ),
3998
4225
  * ]
3999
4226
  * ```
4000
- *
4001
- * @category common/data/recycler
4002
4227
  */
4003
4228
  function provideRecyclerI18n(...features) {
4004
4229
  return {
@@ -4032,8 +4257,6 @@ function provideRecyclerI18n(...features) {
4032
4257
  * state: this.state,
4033
4258
  * });
4034
4259
  * ```
4035
- *
4036
- * @category common/data/recycler
4037
4260
  */
4038
4261
  function injectRecycler(config) {
4039
4262
  const destroyRef = inject(DestroyRef);
@@ -4099,14 +4322,15 @@ function injectRecycler(config) {
4099
4322
  // lead with velocity, capped at one viewport of items so a teleport jump
4100
4323
  // never expands the window unbounded. Trailing edge keeps the base overscan.
4101
4324
  const estimate = config.estimateSize;
4102
- const refPx = typeof estimate === 'number' && estimate > 0 ? estimate : Math.max(1, clientHeight / 8);
4325
+ const uniform = isSignal(estimate) ? estimate() : estimate;
4326
+ const refPx = typeof uniform === 'number' && uniform > 0 ? uniform : Math.max(1, clientHeight / 8);
4103
4327
  const itemsPerViewport = Math.max(1, Math.ceil(clientHeight / refPx));
4104
4328
  const velocity = scrollVelocity();
4105
4329
  const leadItems = Math.min(Math.ceil(Math.abs(velocity) / refPx), itemsPerViewport);
4106
4330
  const scrollingDown = velocity >= 0;
4107
4331
  const overscanBefore = overscan + (scrollingDown ? 0 : leadItems);
4108
4332
  const overscanAfter = overscan + (scrollingDown ? leadItems : 0);
4109
- return computeRange(scrollTop, clientHeight, total, size, overscanBefore, cols, overscanAfter);
4333
+ return computeRange(scrollTop, clientHeight, total, size, overscanBefore, cols, overscanAfter, itemsPerViewport);
4110
4334
  }, ...(ngDevMode ? [{ debugName: "range" }] : /* istanbul ignore next */ []));
4111
4335
  const start = computed(() => range().start, ...(ngDevMode ? [{ debugName: "start" }] : /* istanbul ignore next */ []));
4112
4336
  const end = computed(() => range().end, ...(ngDevMode ? [{ debugName: "end" }] : /* istanbul ignore next */ []));
@@ -4167,8 +4391,12 @@ function injectRecycler(config) {
4167
4391
  const state = config.state;
4168
4392
  const isLoading = computed(() => state?.isFirstLoad() ?? false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
4169
4393
  const isRefreshing = computed(() => state?.isRefreshing() ?? false, ...(ngDevMode ? [{ debugName: "isRefreshing" }] : /* istanbul ignore next */ []));
4394
+ const loading = injectLoadingConfig();
4395
+ // Declared before isEmpty so the empty state can wait on the held skeleton:
4396
+ // one truth for the template, no empty-then-skeleton flicker on first load.
4397
+ const showSkeleton = createVisibilityGate(isLoading, computed(() => config.skeletonDelay ?? loading.showDelay), computed(() => config.skeletonMinDwell ?? loading.minDwell));
4170
4398
  const isEmpty = computed(() => {
4171
- if (state?.isBusy()) {
4399
+ if (state?.isBusy() || showSkeleton()) {
4172
4400
  return false;
4173
4401
  }
4174
4402
  return config.totalCount() === 0;
@@ -4182,7 +4410,6 @@ function injectRecycler(config) {
4182
4410
  const itemHeight = typeof config.estimateSize === 'number' ? config.estimateSize : config.estimateSize(0);
4183
4411
  return Math.ceil(ch / itemHeight);
4184
4412
  }, ...(ngDevMode ? [{ debugName: "skeletonSlots" }] : /* istanbul ignore next */ []));
4185
- const showSkeleton = createVisibilityGate(isLoading, computed(() => config.skeletonDelay ?? 0), computed(() => 0));
4186
4413
  // previousTotal is a signal, not a mutable let - reactive, no stale-value risk.
4187
4414
  const announcementState = signal('', ...(ngDevMode ? [{ debugName: "announcementState" }] : /* istanbul ignore next */ []));
4188
4415
  const previousTotal = signal(config.totalCount(), ...(ngDevMode ? [{ debugName: "previousTotal" }] : /* istanbul ignore next */ []));
@@ -4282,14 +4509,18 @@ function injectRecycler(config) {
4282
4509
  if (!el) {
4283
4510
  return;
4284
4511
  }
4512
+ // Raw listeners do not get the null reactive consumer Angular gives its own
4513
+ // `(event)` bindings. Focus dropping inside a render pass (a select sheet
4514
+ // removing the listbox tabindex on rotation) runs them synchronously under
4515
+ // that template's consumer, where a bare signal write throws NG0600.
4285
4516
  const handleFocusIn = (e) => {
4286
4517
  const target = e.target.closest('[data-cngx-recycle-index]');
4287
4518
  if (target) {
4288
- focusedIndex.set(Number(target.getAttribute('data-cngx-recycle-index')));
4519
+ untracked(() => focusedIndex.set(Number(target.getAttribute('data-cngx-recycle-index'))));
4289
4520
  }
4290
4521
  };
4291
4522
  const handleFocusOut = () => {
4292
- focusedIndex.set(null);
4523
+ untracked(() => focusedIndex.set(null));
4293
4524
  };
4294
4525
  el.addEventListener('focusin', handleFocusIn);
4295
4526
  el.addEventListener('focusout', handleFocusOut);
@@ -4416,18 +4647,16 @@ function injectRecycler(config) {
4416
4647
  * }
4417
4648
  * ```
4418
4649
  *
4419
- * @category common/data/recycler
4420
- * @docsKind primary
4421
4650
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/measure.directive.ts
4422
- * @since 0.1.0
4651
+ * @since 0.3.0
4423
4652
  * @relatedTo CngxVirtualItem, CngxRecyclerAnnouncer, injectRecycler
4424
4653
  *
4425
- * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4426
- * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
4427
- * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
4428
- * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4429
- * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4430
- * <example-url>http://localhost:4200/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
4654
+ * <example-url>/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4655
+ * <example-url>/#/common/data/recycler/content-visibility-css-only</example-url>
4656
+ * <example-url>/#/common/data/recycler/infinite-scroll-recycler</example-url>
4657
+ * <example-url>/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4658
+ * <example-url>/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4659
+ * <example-url>/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
4431
4660
  */
4432
4661
  class CngxMeasure {
4433
4662
  /** The recycler instance to report measurements to. */
@@ -4483,19 +4712,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4483
4712
  * }
4484
4713
  * ```
4485
4714
  *
4486
- * @category common/data/recycler
4487
- * @docsKind primary
4488
4715
  * @wcag AA
4489
4716
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/virtual-item.directive.ts
4490
- * @since 0.1.0
4717
+ * @since 0.3.0
4491
4718
  * @relatedTo CngxMeasure, CngxRecyclerAnnouncer, injectRecycler
4492
4719
  *
4493
- * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4494
- * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
4495
- * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
4496
- * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4497
- * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4498
- * <example-url>http://localhost:4200/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
4720
+ * <example-url>/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4721
+ * <example-url>/#/common/data/recycler/content-visibility-css-only</example-url>
4722
+ * <example-url>/#/common/data/recycler/infinite-scroll-recycler</example-url>
4723
+ * <example-url>/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4724
+ * <example-url>/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4725
+ * <example-url>/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
4499
4726
  */
4500
4727
  class CngxVirtualItem {
4501
4728
  /** The recycler instance providing `ariaSetSize`. */
@@ -4569,13 +4796,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4569
4796
  * [style.height.px]="recycler.offsetBefore()"></div>
4570
4797
  * ```
4571
4798
  *
4572
- * @category common/data/recycler
4573
- * @docsKind primary
4574
4799
  * @wcag AA
4575
4800
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-placeholder.directive.ts
4576
- * @since 0.1.0
4801
+ * @since 0.3.0
4577
4802
  * @relatedTo injectRecycler, CngxRecyclerRow, CngxVirtualItem, CngxMeasure
4578
- * <example-url>http://localhost:4200/#/common/data/recycler/fast-fling-placeholders</example-url>
4803
+ * <example-url>/#/common/data/recycler/fast-fling-placeholders</example-url>
4804
+ * @axis level molecule
4579
4805
  */
4580
4806
  class CngxRecyclerPlaceholder {
4581
4807
  /**
@@ -4641,15 +4867,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4641
4867
  * the cascade: microsyntax `placeholder:` template wins over this, and this wins
4642
4868
  * over the built-in imperative `<li>` default. Defaults to `null` (imperative
4643
4869
  * default applies).
4644
- *
4645
- * @category common/data/recycler
4646
4870
  */
4647
4871
  const CNGX_RECYCLER_PLACEHOLDER_ROW = new InjectionToken('CNGX_RECYCLER_PLACEHOLDER_ROW', { providedIn: 'root', factory: () => null });
4648
4872
  /**
4649
4873
  * Provides an app-wide default placeholder template for every `*cngxRecyclerRow`
4650
4874
  * that supplies no `placeholder:` template of its own.
4651
- *
4652
- * @category common/data/recycler
4653
4875
  */
4654
4876
  function provideRecyclerPlaceholderRow(template) {
4655
4877
  return { provide: CNGX_RECYCLER_PLACEHOLDER_ROW, useValue: template };
@@ -4705,13 +4927,12 @@ function provideRecyclerPlaceholderRow(template) {
4705
4927
  * </ul>
4706
4928
  * ```
4707
4929
  *
4708
- * @category common/data/recycler
4709
- * @docsKind primary
4710
4930
  * @wcag AA
4711
4931
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-row.directive.ts
4712
- * @since 0.1.0
4932
+ * @since 0.3.0
4713
4933
  * @relatedTo injectRecycler, CngxRecyclerPlaceholder, CngxVirtualItem, CngxMeasure
4714
- * <example-url>http://localhost:4200/#/common/data/recycler/windowed-data-availability</example-url>
4934
+ * <example-url>/#/common/data/recycler/windowed-data-availability</example-url>
4935
+ * @axis level molecule
4715
4936
  */
4716
4937
  class CngxRecyclerRow {
4717
4938
  vcr = inject(ViewContainerRef);
@@ -4906,19 +5127,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4906
5127
  * <cngx-recycler-announcer [cngxRecyclerAnnouncer]="recycler" />
4907
5128
  * ```
4908
5129
  *
4909
- * @category common/data/recycler
4910
- * @docsKind primary
4911
5130
  * @wcag AA
4912
5131
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-announcer.component.ts
4913
- * @since 0.1.0
5132
+ * @since 0.3.0
4914
5133
  * @relatedTo CngxMeasure, CngxVirtualItem, injectRecycler, CNGX_RECYCLER_I18N
4915
5134
  *
4916
- * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4917
- * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
4918
- * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
4919
- * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4920
- * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4921
- * <example-url>http://localhost:4200/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
5135
+ * <example-url>/#/common/data/recycler/basic-list-fixed-item-height</example-url>
5136
+ * <example-url>/#/common/data/recycler/content-visibility-css-only</example-url>
5137
+ * <example-url>/#/common/data/recycler/infinite-scroll-recycler</example-url>
5138
+ * <example-url>/#/common/data/recycler/scrolltoindex-deep-link</example-url>
5139
+ * <example-url>/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
5140
+ * <example-url>/#/common/data/recycler/with-cngxasyncstate-skeleton-first-load</example-url>
4922
5141
  */
4923
5142
  class CngxRecyclerAnnouncer {
4924
5143
  /** The recycler instance providing `announcement()`. */
@@ -4969,8 +5188,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4969
5188
  * }
4970
5189
  * }
4971
5190
  * ```
4972
- *
4973
- * @category common/data/recycler
4974
5191
  */
4975
5192
  function connectRecyclerToRoving(recycler, roving) {
4976
5193
  const hostEl = inject(ElementRef).nativeElement;
@@ -5041,11 +5258,10 @@ function connectRecyclerToRoving(recycler, roving) {
5041
5258
  * When the AD directive navigates to an item whose index is not in the
5042
5259
  * recycler's rendered range, it sets `pendingHighlight` (via the
5043
5260
  * `virtualCount` path). This helper watches that signal and scrolls
5044
- * the recycler to the target index; AD's own effect observes the
5045
- * resulting DOM update and clears the pending state automatically
5046
- * (see the `pendingHighlightState.set(null)` branch in
5047
- * `CngxActiveDescendant` after a re-render brings the target into the
5048
- * rendered range).
5261
+ * the recycler to the target index; AD clears the pending state on its
5262
+ * own once a re-render brings the target into the rendered range, and
5263
+ * does not raise it again when the window later moves away from an
5264
+ * unchanged highlight, so a scroll by the user is never pulled back.
5049
5265
  *
5050
5266
  * Unlike {@link /projects/common/data/src/recycler/connect-recycler-roving.ts
5051
5267
  * connectRecyclerToRoving}, we don't re-focus a DOM element after the
@@ -5073,8 +5289,6 @@ function connectRecyclerToRoving(recycler, roving) {
5073
5289
  * }
5074
5290
  * }
5075
5291
  * ```
5076
- *
5077
- * @category common/data/recycler
5078
5292
  */
5079
5293
  function connectRecyclerToActiveDescendant(recycler, ad) {
5080
5294
  // rAF-debounced: held ArrowDown otherwise enqueues one scroll per keystroke.
@@ -5110,20 +5324,43 @@ function connectRecyclerToActiveDescendant(recycler, ad) {
5110
5324
  *
5111
5325
  * Plain function, not a class - matches the rest of the repo
5112
5326
  * (`createManualState`, `createAsyncState`, `createTransitionTracker`).
5113
- * See `reference_api_prefix_convention.md`.
5114
- *
5115
- * @category common/data/commit
5327
+ * <example-url>/#/common/data/commit-controller/begin-supersede-cancel</example-url>
5116
5328
  */
5117
5329
  function createCommitController() {
5118
- // read-only `state` view; consumers can't flip status directly
5119
5330
  const slot = createManualState();
5331
+ // Read-only `state` view: the slot's signals without its write methods, so
5332
+ // consumers can't flip status directly.
5333
+ const state = {
5334
+ status: slot.status,
5335
+ data: slot.data,
5336
+ error: slot.error,
5337
+ progress: slot.progress,
5338
+ isLoading: slot.isLoading,
5339
+ isPending: slot.isPending,
5340
+ isRefreshing: slot.isRefreshing,
5341
+ isBusy: slot.isBusy,
5342
+ isFirstLoad: slot.isFirstLoad,
5343
+ isEmpty: slot.isEmpty,
5344
+ hasData: slot.hasData,
5345
+ isSettled: slot.isSettled,
5346
+ lastUpdated: slot.lastUpdated,
5347
+ };
5348
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
5349
+ // The view hides the slot; listing it here is how an inspector reaches
5350
+ // the slot's own descriptor.
5351
+ CNGX_DEV_DESCRIPTORS.tag(state, {
5352
+ kind: 'cngx-dev:factory',
5353
+ factory: 'createCommitController',
5354
+ inputs: { state: slot },
5355
+ });
5356
+ }
5120
5357
  // monotonic supersede id; stale callbacks compare captured id against this
5121
5358
  let commitId = 0;
5122
5359
  let active = null;
5123
5360
  // drives the pending spinner on the specific row the user clicked
5124
5361
  const intendedState = signal(undefined, ...(ngDevMode ? [{ debugName: "intendedState" }] : /* istanbul ignore next */ []));
5125
5362
  return {
5126
- state: slot,
5363
+ state,
5127
5364
  isCommitting: computed(() => slot.isPending(), typeof ngDevMode !== 'undefined' && ngDevMode
5128
5365
  ? { debugName: 'commitController.isCommitting' }
5129
5366
  : undefined),
@@ -5134,44 +5371,74 @@ function createCommitController() {
5134
5371
  // and fire its callbacks after all
5135
5372
  const id = ++commitId;
5136
5373
  active?.cancel();
5374
+ active = null;
5137
5375
  intendedState.set(intended);
5138
5376
  slot.set('pending');
5139
5377
  // A runner may settle synchronously, i.e. before its handle is even
5140
5378
  // returned. The settled flag keeps such a finished handle out of
5141
5379
  // `active`, so a later begin()/cancel() never calls cancel() on a
5142
5380
  // completed runner (CngxCommitHandle does not require idempotence).
5381
+ // It is also the once-guard: after the first outcome every further
5382
+ // route call of this runner is ignored.
5143
5383
  let settled = false;
5144
- const handle = runner({
5145
- onSuccess: (committed) => {
5146
- if (id !== commitId) {
5147
- return;
5148
- }
5149
- settled = true;
5150
- slot.setSuccess(committed);
5151
- active = null;
5152
- handlers.onSuccess(committed);
5153
- },
5154
- onError: (err) => {
5155
- if (id !== commitId) {
5156
- return;
5157
- }
5384
+ let handle;
5385
+ try {
5386
+ handle = runner({
5387
+ onSuccess: (committed) => {
5388
+ if (id !== commitId || settled) {
5389
+ return;
5390
+ }
5391
+ settled = true;
5392
+ slot.setSuccess(committed);
5393
+ active = null;
5394
+ handlers.onSuccess(committed);
5395
+ },
5396
+ onError: (err) => {
5397
+ if (id !== commitId || settled) {
5398
+ return;
5399
+ }
5400
+ settled = true;
5401
+ slot.setError(err);
5402
+ active = null;
5403
+ handlers.onError(err, previous);
5404
+ },
5405
+ onRefused: () => {
5406
+ if (id !== commitId || settled) {
5407
+ return;
5408
+ }
5409
+ settled = true;
5410
+ slot.setIdle();
5411
+ intendedState.set(undefined);
5412
+ active = null;
5413
+ handlers.onRefused?.(previous);
5414
+ },
5415
+ });
5416
+ }
5417
+ catch (err) {
5418
+ // A throw after the runner already settled is the runner's own bug:
5419
+ // rethrow it unchanged. A throw before any outcome is the outcome.
5420
+ if (settled) {
5421
+ throw err;
5422
+ }
5423
+ if (id === commitId) {
5158
5424
  settled = true;
5159
5425
  slot.setError(err);
5160
- active = null;
5161
5426
  handlers.onError(err, previous);
5162
- },
5163
- onRefused: () => {
5164
- if (id !== commitId) {
5165
- return;
5166
- }
5167
- settled = true;
5168
- slot.setIdle();
5169
- intendedState.set(undefined);
5170
- active = null;
5171
- handlers.onRefused?.(previous);
5172
- },
5173
- });
5174
- active = settled ? null : handle;
5427
+ }
5428
+ return;
5429
+ }
5430
+ if (settled) {
5431
+ // Settled during the call: `active` is already cleared, or holds the
5432
+ // handle of a begin() that an outcome handler started.
5433
+ return;
5434
+ }
5435
+ if (id !== commitId) {
5436
+ // Superseded during its own call, before its handle existed for the
5437
+ // newer begin()/cancel() to tear down.
5438
+ handle.cancel();
5439
+ return;
5440
+ }
5441
+ active = handle;
5175
5442
  },
5176
5443
  cancel(options) {
5177
5444
  // bump first: callbacks of a synchronously-cancelling runner must
@@ -5215,10 +5482,9 @@ function createCommitController() {
5215
5482
  * });
5216
5483
  * ```
5217
5484
  *
5218
- * @category common/data/commit
5219
5485
  * @wcag AA
5220
5486
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/commit/refused-phrase.ts
5221
- * @since 0.1.0
5487
+ * @since 0.3.0
5222
5488
  * @relatedTo CngxTransitionOutcome, createAnnouncementPhrase
5223
5489
  */
5224
5490
  function createRefusedPhrase(options) {
@@ -5250,23 +5516,49 @@ function createRefusedPhrase(options) {
5250
5516
  *
5251
5517
  * Symmetrical to `CNGX_SELECT_COMMIT_CONTROLLER_FACTORY`
5252
5518
  * (`@cngx/forms/select`); the select-side token's default factory
5253
- * delegates to this one, so a single override here cascades into
5254
- * every select variant transparently.
5519
+ * delegates to this one in the root injector, so an app-level override
5520
+ * here cascades into every select variant. A subtree override reaches
5521
+ * the stepper and tabs presenters, not the select family: override
5522
+ * `CNGX_SELECT_COMMIT_CONTROLLER_FACTORY` there.
5523
+ *
5524
+ * A replacement must honour `cancel({ settle: true })`, or `busy` stays
5525
+ * latched where the surface lives on. A custom factory usually wraps the
5526
+ * default one, here to time each commit that settles (`reportCommit`
5527
+ * stands for your telemetry call):
5255
5528
  *
5256
5529
  * ```ts
5530
+ * function createTimedCommitController<T>(): CngxCommitController<T> {
5531
+ * const inner = createCommitController<T>();
5532
+ * const begin: CngxCommitController<T>['begin'] = (runner, intended, previous, handlers) => {
5533
+ * const started = performance.now();
5534
+ * const report = (outcome: string) => reportCommit(outcome, performance.now() - started);
5535
+ * inner.begin(runner, intended, previous, {
5536
+ * onSuccess: (committed) => {
5537
+ * report('success');
5538
+ * handlers.onSuccess(committed);
5539
+ * },
5540
+ * onError: (err, prev) => {
5541
+ * report('error');
5542
+ * handlers.onError(err, prev);
5543
+ * },
5544
+ * onRefused: (prev) => {
5545
+ * report('refused');
5546
+ * handlers.onRefused?.(prev);
5547
+ * },
5548
+ * });
5549
+ * };
5550
+ * return { ...inner, begin };
5551
+ * }
5552
+ *
5257
5553
  * bootstrapApplication(App, {
5258
5554
  * providers: [
5259
- * {
5260
- * provide: CNGX_COMMIT_CONTROLLER_FACTORY,
5261
- * useValue: <T>() => createRetryingCommitController<T>({ attempts: 3 }),
5262
- * },
5555
+ * { provide: CNGX_COMMIT_CONTROLLER_FACTORY, useValue: createTimedCommitController },
5263
5556
  * ],
5264
5557
  * });
5265
5558
  * ```
5266
5559
  *
5267
- * @category common/data/commit
5268
5560
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/commit/commit-controller.token.ts
5269
- * @since 0.1.0
5561
+ * @since 0.3.0
5270
5562
  */
5271
5563
  const CNGX_COMMIT_CONTROLLER_FACTORY = new InjectionToken('CngxCommitControllerFactory', {
5272
5564
  providedIn: 'root',
@@ -5325,8 +5617,6 @@ const CNGX_COMMIT_CONTROLLER_FACTORY = new InjectionToken('CngxCommitControllerF
5325
5617
  * and ping-pong against the in-flight navigation (the demo freezes).
5326
5618
  * Matching the echo by the value we wrote drops it regardless of where
5327
5619
  * the presenter has moved.
5328
- *
5329
- * @category common/data/material-bridge
5330
5620
  */
5331
5621
  function createMaterialBidirectionalSync(opts) {
5332
5622
  const { presenterIndex, readSelectedIndex, writeSelectedIndex, selectionChange$, onMaterialSelection, injector, destroyRef, } = opts;
@@ -5386,7 +5676,7 @@ function createMaterialBidirectionalSync(opts) {
5386
5676
  }
5387
5677
 
5388
5678
  /**
5389
- * @module @cngx/common/data
5679
+ * @module `@cngx/common/data`
5390
5680
  */
5391
5681
 
5392
5682
  /**