@cngx/common 0.1.0-rc.8 → 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 (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  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 +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  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 +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  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 +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
@@ -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, isDevMode, 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, clamp, cngxDevError } from '@cngx/utils';
6
7
  import { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';
7
8
  import { Router, ActivatedRoute } from '@angular/router';
8
9
  import { DataSource } from '@angular/cdk/collections';
9
- import { foldForMatching, memoize, injectLocale, buildAsyncStateView, nextUid, createAggregateAsyncState, CNGX_STATEFUL, createLatencyProbe, numberFormatterFor, createOverrideMerge, createVisibilityGate, createTransitionTracker, createMediaQuerySignal } from '@cngx/core/utils';
10
- import { arrayEqual, clamp } from '@cngx/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,24 +542,65 @@ 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 */ []));
584
+ /**
585
+ * Extracts the comparable value from a filtered list item, when the list
586
+ * is shaped unlike the chip options: role options `{ id, label }` filtering
587
+ * an employee list by `employee.roleId`. Return an array for an item that
588
+ * carries several values (`employee.tags`); it matches when any of them is
589
+ * selected. Unbound, the predicate applies `optionValue` to the list items,
590
+ * which fits a list shaped like the options.
591
+ */
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
+ */
567
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
+ */
568
604
  state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
569
605
  /**
570
606
  * Form-state surface forwarded transparently to the inner
@@ -574,9 +610,28 @@ class CngxFilterChips {
574
610
  * / `CngxButtonToggleGroup` precedent.
575
611
  */
576
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
+ */
577
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
+ */
578
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
+ */
579
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
+ */
580
635
  orientation = input('horizontal', ...(ngDevMode ? [{ debugName: "orientation" }] : /* istanbul ignore next */ []));
581
636
  /**
582
637
  * Membership key extractor for object-valued chip values. When
@@ -600,14 +655,14 @@ class CngxFilterChips {
600
655
  /**
601
656
  * Build the slot context for a given chip option. `optionValue` is
602
657
  * invoked here per option for the chip rendering pass; the predicate
603
- * closure invokes it again per LIST item for membership filtering.
604
- * Both invocations are necessary because option items (the chip
605
- * pool) and filtered list items (the consumer's filtered data) are
606
- * separate data paths - they happen to share a shape under the
607
- * Phase-5 single-shape limitation, but the bridge cannot memoise
608
- * across the two paths without conflating them. Consumers should
609
- * keep `optionValue` cheap (typically a property lookup); a future
610
- * `[itemValue]` input will separate the two extractors.
658
+ * closure invokes it again per LIST item for membership filtering
659
+ * while `[itemValue]` is unbound. Both invocations are necessary
660
+ * because option items (the chip pool) and filtered list items (the
661
+ * consumer's filtered data) are separate data paths - they share a
662
+ * shape only when `[itemValue]` is unbound, and the bridge cannot
663
+ * memoise across the two paths without conflating them. Consumers
664
+ * should keep `optionValue` cheap (typically a property lookup); bind
665
+ * `[itemValue]` when the list is shaped unlike the options.
611
666
  */
612
667
  chipContext = (option) => {
613
668
  const value = this.optionValue()(option);
@@ -633,8 +688,11 @@ class CngxFilterChips {
633
688
  return true;
634
689
  }
635
690
  const extract = this.keyFn();
636
- const key = extract(this.optionValue()(item));
637
- return values.some((v) => Object.is(extract(v), key));
691
+ const keys = this.itemKeys(item, extract);
692
+ return values.some((v) => {
693
+ const selected = extract(v);
694
+ return keys.some((key) => Object.is(selected, key));
695
+ });
638
696
  };
639
697
  // Binding effect: tracks only filterRef/filterKey, so a rebind moves the
640
698
  // registration. Cleanup is identity-guarded - it removes the key only
@@ -674,8 +732,21 @@ class CngxFilterChips {
674
732
  }
675
733
  });
676
734
  }
735
+ itemKeys(item, extract) {
736
+ const itemValue = this.itemValue();
737
+ if (!itemValue) {
738
+ // Without [itemValue] the list is shaped like the options (the
739
+ // `TListItem = TItem` default), and an array-valued option stays one value.
740
+ const optionValue = this.optionValue();
741
+ return [extract(optionValue(item))];
742
+ }
743
+ const values = itemValue(item);
744
+ return Array.isArray(values)
745
+ ? values.map(extract)
746
+ : [extract(values)];
747
+ }
677
748
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxFilterChips, deps: [], target: i0.ɵɵFactoryTarget.Component });
678
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxFilterChips, isStandalone: true, selector: "cngx-filter-chips", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: true, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: true, transformFunction: null }, filterRef: { classPropertyName: "filterRef", publicName: "filterRef", isSignal: true, isRequired: true, transformFunction: null }, filterKey: { classPropertyName: "filterKey", publicName: "filterKey", isSignal: true, isRequired: true, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null }, selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange", selectedValues: "selectedValuesChange" }, host: { properties: { "class.cngx-filter-chips--vertical": "orientation() === \"vertical\"" }, classAttribute: "cngx-filter-chips" }, queries: [{ propertyName: "chipTemplate", first: true, predicate: (CngxFilterChip), descendants: true, isSignal: true }], exportAs: ["cngxFilterChips"], ngImport: i0, template: `
749
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxFilterChips, isStandalone: true, selector: "cngx-filter-chips", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, options: { classPropertyName: "options", publicName: "options", isSignal: true, isRequired: true, transformFunction: null }, optionLabel: { classPropertyName: "optionLabel", publicName: "optionLabel", isSignal: true, isRequired: true, transformFunction: null }, optionValue: { classPropertyName: "optionValue", publicName: "optionValue", isSignal: true, isRequired: true, transformFunction: null }, filterRef: { classPropertyName: "filterRef", publicName: "filterRef", isSignal: true, isRequired: true, transformFunction: null }, itemValue: { classPropertyName: "itemValue", publicName: "itemValue", isSignal: true, isRequired: false, transformFunction: null }, filterKey: { classPropertyName: "filterKey", publicName: "filterKey", isSignal: true, isRequired: true, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, errorMessageId: { classPropertyName: "errorMessageId", publicName: "errorMessageId", isSignal: true, isRequired: false, transformFunction: null }, orientation: { classPropertyName: "orientation", publicName: "orientation", isSignal: true, isRequired: false, transformFunction: null }, keyFn: { classPropertyName: "keyFn", publicName: "keyFn", isSignal: true, isRequired: false, transformFunction: null }, selectedValues: { classPropertyName: "selectedValues", publicName: "selectedValues", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { disabled: "disabledChange", required: "requiredChange", invalid: "invalidChange", selectedValues: "selectedValuesChange" }, host: { properties: { "class.cngx-filter-chips--vertical": "orientation() === \"vertical\"" }, classAttribute: "cngx-filter-chips" }, queries: [{ propertyName: "chipTemplate", first: true, predicate: (CngxFilterChip), descendants: true, isSignal: true }], exportAs: ["cngxFilterChips"], ngImport: i0, template: `
679
750
  <span class="cngx-filter-chips__label" aria-hidden="true">{{ label() }}</span>
680
751
  <cngx-multi-chip-group
681
752
  [label]="label()"
@@ -729,7 +800,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
729
800
  }
730
801
  </cngx-multi-chip-group>
731
802
  `, styles: [":host{display:flex;flex-direction:row;align-items:center;--cngx-filter-chips-gap: var(--cngx-space-sm, 8px);gap:var(--cngx-filter-chips-gap, 8px)}:host(.cngx-filter-chips--vertical){flex-direction:column;align-items:flex-start}.cngx-filter-chips__label{color:var(--cngx-filter-chips-label-color, inherit);font-size:var(--cngx-filter-chips-label-font-size, .8125rem);font-weight:var(--cngx-filter-chips-label-font-weight, 600)}\n"] }]
732
- }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: true }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: true }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: true }] }], filterRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterRef", required: true }] }], filterKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterKey", required: true }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }], chipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxFilterChip), { isSignal: true }] }], selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }] } });
803
+ }], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], options: [{ type: i0.Input, args: [{ isSignal: true, alias: "options", required: true }] }], optionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionLabel", required: true }] }], optionValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionValue", required: true }] }], filterRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterRef", required: true }] }], itemValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "itemValue", required: false }] }], filterKey: [{ type: i0.Input, args: [{ isSignal: true, alias: "filterKey", required: true }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }, { type: i0.Output, args: ["disabledChange"] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }, { type: i0.Output, args: ["requiredChange"] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }, { type: i0.Output, args: ["invalidChange"] }], errorMessageId: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMessageId", required: false }] }], orientation: [{ type: i0.Input, args: [{ isSignal: true, alias: "orientation", required: false }] }], keyFn: [{ type: i0.Input, args: [{ isSignal: true, alias: "keyFn", required: false }] }], chipTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxFilterChip), { isSignal: true }] }], selectedValues: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedValues", required: false }] }, { type: i0.Output, args: ["selectedValuesChange"] }] } });
733
804
 
734
805
  /**
735
806
  * Atom directive that tracks pagination state (current page index and page size).
@@ -754,17 +825,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
754
825
  * [length]="pg.total()" [pageIndex]="pg.pageIndex()" [pageSize]="pg.pageSize()"
755
826
  * (page)="pg.setPageSize($event.pageSize, false); pg.setPage($event.pageIndex)" />
756
827
  * ```
757
- * @category common/data/paginate
758
- * @docsKind primary
759
828
  * @wcag AA
760
829
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate.directive.ts
761
- * @since 0.1.0
830
+ * @since 0.3.0
762
831
  * @relatedTo CngxSort, CngxFilter, CngxSmartDataSource
763
832
  *
764
- * <example-url>http://localhost:4200/#/common/data/data-source/datasource-cngxpaginate-manual-pipeline</example-url>
765
- * <example-url>http://localhost:4200/#/common/data/paginate-list/paginated-list-cngxpaginate-cngxmatpaginator</example-url>
766
- * <example-url>http://localhost:4200/#/common/data/paginate-list/uncontrolled-mode-zero-class-boilerplate</example-url>
767
- * <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
768
838
  */
769
839
  class CngxPaginate {
770
840
  /** Controlled page index. When bound, takes precedence over internal state. */
@@ -892,6 +962,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
892
962
  }]
893
963
  }], propDecorators: { pageIndexInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPageIndex", required: false }] }], pageSizeInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPageSize", required: false }] }], total: [{ type: i0.Input, args: [{ isSignal: true, alias: "total", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], pageChange: [{ type: i0.Output, args: ["pageChange"] }], pageSizeChange: [{ type: i0.Output, args: ["pageSizeChange"] }] } });
894
964
 
965
+ /**
966
+ * Inject the surrounding {@link CngxPaginate} from a paginate add-on
967
+ * directive. Throws a `CngxRuntimeError` with code `CNGX1063` when no
968
+ * `[cngxPaginate]` is on the element or above it, in development and
969
+ * production alike. `selector` names the add-on in the development message.
970
+ *
971
+ * @internal
972
+ */
973
+ function injectPaginate(selector) {
974
+ const paginate = inject(CngxPaginate, { optional: true });
975
+ if (!paginate) {
976
+ throw new CngxRuntimeError('CNGX1063', typeof ngDevMode !== 'undefined' &&
977
+ ngDevMode &&
978
+ `[${selector}] must be placed on or inside an element with [cngxPaginate], such as <cngx-paginator>.`);
979
+ }
980
+ return paginate;
981
+ }
982
+
895
983
  /**
896
984
  * Wires the reset-on-change behaviour onto a {@link CngxPaginate} brain: when
897
985
  * `key()` changes (after the initial run) the paginator jumps to the first
@@ -903,8 +991,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
903
991
  * is byte-identical across all three. Call inside an injection context
904
992
  * (constructor or field initialiser).
905
993
  *
906
- * @category common/data/paginate
907
- * @since 0.1.0
994
+ * @since 0.3.0
908
995
  */
909
996
  function connectPaginateResetOn(paginate, key) {
910
997
  let seen = false;
@@ -935,17 +1022,15 @@ function connectPaginateResetOn(paginate, key) {
935
1022
  * ```html
936
1023
  * <table cngxPaginate [cngxPaginateResetOn]="filter()"><!-- ... --></table>
937
1024
  * ```
938
- * <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>
939
1026
  *
940
- * @category common/data/paginate
941
- * @docsKind primary
942
1027
  * @wcag AA
943
1028
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate-reset.directive.ts
944
- * @since 0.1.0
1029
+ * @since 0.3.0
945
1030
  * @relatedTo CngxPaginate, CngxPaginator, CngxMatPaginator
946
1031
  */
947
1032
  class CngxPaginateResetOn {
948
- paginate = inject(CngxPaginate);
1033
+ paginate = injectPaginate('cngxPaginateResetOn');
949
1034
  /** The reset key. A change (after mount) jumps the paginator to page 0. */
950
1035
  key = input(undefined, { ...(ngDevMode ? { debugName: "key" } : /* istanbul ignore next */ {}), alias: 'cngxPaginateResetOn' });
951
1036
  constructor() {
@@ -986,8 +1071,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
986
1071
  * injection context (constructor or field initialiser) - it reads `DestroyRef`
987
1072
  * and creates effects.
988
1073
  *
989
- * @category common/data/paginate
990
- * @since 0.1.0
1074
+ * @since 0.3.0
991
1075
  */
992
1076
  function connectPaginateEmit(paginate, handlers) {
993
1077
  const destroyRef = inject(DestroyRef);
@@ -1063,16 +1147,15 @@ function connectPaginateEmit(paginate, handlers) {
1063
1147
  * inert no-op (a dev-mode warning is logged). Framework-agnostic of any UI - it
1064
1148
  * needs only the brain and the router.
1065
1149
  *
1066
- * @category common/data/paginate
1067
- * @docsKind primary
1068
1150
  * @wcag AA
1069
1151
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/paginate-routing.directive.ts
1070
- * @since 0.1.0
1152
+ * @since 0.3.0
1071
1153
  * @relatedTo CngxPaginate, CngxPaginator, CngxMatPaginator
1072
- * <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
1073
1156
  */
1074
1157
  class CngxPaginateRouting {
1075
- paginate = inject(CngxPaginate);
1158
+ paginate = injectPaginate('cngxPaginateRouting');
1076
1159
  router = inject(Router, { optional: true });
1077
1160
  route = inject(ActivatedRoute, { optional: true });
1078
1161
  destroyRef = inject(DestroyRef);
@@ -1097,7 +1180,7 @@ class CngxPaginateRouting {
1097
1180
  const route = this.route;
1098
1181
  if (!router || !route) {
1099
1182
  if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1100
- console.warn('[cngxPaginateRouting]: no Router available - directive is a no-op. ' +
1183
+ cngxDevWarn('CNGX1031', '[cngxPaginateRouting] no Router / ActivatedRoute available - the URL sync is a no-op. ' +
1101
1184
  'Provide @angular/router via provideRouter(...) to enable URL-synced pagination.');
1102
1185
  }
1103
1186
  return;
@@ -1221,10 +1304,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1221
1304
  * concrete directive class, keeping the strip decompose-ready and the model
1222
1305
  * swappable.
1223
1306
  *
1224
- * @category common/data/paginate
1225
1307
  * @wcag AA
1226
1308
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/bucket-paginate-host.token.ts
1227
- * @since 0.1.0
1309
+ * @since 0.3.0
1228
1310
  */
1229
1311
  const CNGX_BUCKET_PAGINATE_HOST = new InjectionToken('CngxBucketPaginateHost');
1230
1312
 
@@ -1268,13 +1350,12 @@ function setEquals(a, b) {
1268
1350
  * </div>
1269
1351
  * ```
1270
1352
  *
1271
- * @category common/data/paginate
1272
- * @docsKind primary
1273
1353
  * @wcag AA
1274
1354
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/paginate/bucket-paginate.directive.ts
1275
- * @since 0.1.0
1355
+ * @since 0.3.0
1276
1356
  * @relatedTo CngxPaginate, CngxFilter
1277
- * <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
1278
1359
  */
1279
1360
  class CngxBucketPaginate {
1280
1361
  /** The buckets to partition into, in render order. One chip per entry. */
@@ -1352,10 +1433,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1352
1433
  *
1353
1434
  * @typeParam T - The row item type.
1354
1435
  *
1355
- * @category common/data/data-source
1356
- * @docsKind primary
1357
1436
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/data-source/data-source.ts
1358
- * @since 0.1.0
1437
+ * @since 0.3.0
1359
1438
  * @relatedTo CngxSmartDataSource, CngxSort, CngxFilter, CngxPaginate
1360
1439
  */
1361
1440
  class CngxDataSource extends DataSource {
@@ -1365,9 +1444,18 @@ class CngxDataSource extends DataSource {
1365
1444
  super();
1366
1445
  this.data = data;
1367
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
+ */
1368
1452
  connect() {
1369
1453
  return toObservable(this.data, { injector: this.injector });
1370
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
+ */
1371
1459
  disconnect() {
1372
1460
  // Signal cleanup is handled by Angular's DestroyRef - no manual teardown needed.
1373
1461
  }
@@ -1380,8 +1468,6 @@ class CngxDataSource extends DataSource {
1380
1468
  * ```typescript
1381
1469
  * readonly dataSource = injectDataSource(this.items);
1382
1470
  * ```
1383
- *
1384
- * @category common/data/data-source
1385
1471
  */
1386
1472
  function injectDataSource(data) {
1387
1473
  return new CngxDataSource(data);
@@ -1485,11 +1571,13 @@ function isAsyncState(source) {
1485
1571
  *
1486
1572
  * @typeParam T - The row item type.
1487
1573
  *
1488
- * @category common/data/data-source
1489
- * @docsKind primary
1490
1574
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/data-source/smart-data-source.ts
1491
- * @since 0.1.0
1575
+ * @since 0.3.0
1492
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>
1493
1581
  */
1494
1582
  class CngxSmartDataSource extends DataSource {
1495
1583
  options;
@@ -1580,9 +1668,18 @@ class CngxSmartDataSource extends DataSource {
1580
1668
  return range ? sorted.slice(range[0], range[1]) : sorted;
1581
1669
  }, { ...(ngDevMode ? { debugName: "processed" } : /* istanbul ignore next */ {}), equal: arrayEqual });
1582
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
+ */
1583
1676
  connect() {
1584
1677
  return toObservable(this.processed, { injector: this.injector });
1585
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
+ */
1586
1683
  disconnect() {
1587
1684
  // Signal cleanup is handled by Angular's DestroyRef - no manual teardown needed.
1588
1685
  }
@@ -1602,8 +1699,7 @@ class CngxSmartDataSource extends DataSource {
1602
1699
  * readonly residents = injectAsyncState(() => this.api.getAll());
1603
1700
  * readonly dataSource = injectSmartDataSource(this.residents);
1604
1701
  * ```
1605
- *
1606
- * @category common/data/data-source
1702
+ * <example-url>/#/ui/data-grid-accordion/smart-data-source-options-sort</example-url>
1607
1703
  */
1608
1704
  function injectSmartDataSource(source, options) {
1609
1705
  return new CngxSmartDataSource(source, options);
@@ -1625,8 +1721,6 @@ function injectSmartDataSource(source, options) {
1625
1721
  * this.processState.setSuccess(result);
1626
1722
  * }
1627
1723
  * ```
1628
- *
1629
- * @category common/data/async-state
1630
1724
  */
1631
1725
  function createManualState() {
1632
1726
  const statusState = signal('idle', ...(ngDevMode ? [{ debugName: "statusState" }] : /* istanbul ignore next */ []));
@@ -1640,10 +1734,12 @@ function createManualState() {
1640
1734
  data: dataState.asReadonly(),
1641
1735
  error: errorState.asReadonly(),
1642
1736
  progress: progressState.asReadonly(),
1643
- isFirstLoad: computed(() => !hadSuccess()),
1737
+ isFirstLoad: computed(() => !hadSuccess(), typeof ngDevMode !== 'undefined' && ngDevMode
1738
+ ? { debugName: 'manualState.isFirstLoad' }
1739
+ : undefined),
1644
1740
  lastUpdated: lastUpdatedState.asReadonly(),
1645
1741
  });
1646
- return {
1742
+ const state = {
1647
1743
  ...view,
1648
1744
  set(newStatus) {
1649
1745
  statusState.set(newStatus);
@@ -1669,6 +1765,11 @@ function createManualState() {
1669
1765
  progressState.set(undefined);
1670
1766
  statusState.set('error');
1671
1767
  },
1768
+ setIdle() {
1769
+ errorState.set(undefined);
1770
+ progressState.set(undefined);
1771
+ statusState.set('idle');
1772
+ },
1672
1773
  setProgress(value) {
1673
1774
  progressState.set(value);
1674
1775
  },
@@ -1681,6 +1782,14 @@ function createManualState() {
1681
1782
  hadSuccess.set(false);
1682
1783
  },
1683
1784
  };
1785
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1786
+ CNGX_DEV_DESCRIPTORS.tag(state, {
1787
+ kind: 'cngx-dev:factory',
1788
+ factory: 'createManualState',
1789
+ inputs: {},
1790
+ });
1791
+ }
1792
+ return state;
1684
1793
  }
1685
1794
 
1686
1795
  /** @internal Length-then-key-set equality for the operations Map signal. */
@@ -1736,8 +1845,6 @@ function operationsEqual(a, b) {
1736
1845
  * status reactivity flows through each entry's `CngxAsyncState` signals; the
1737
1846
  * Map signal's `mapKeySetEqual` short-circuits register/unregister churn
1738
1847
  * without hiding status changes.
1739
- *
1740
- * @category common/data/async-registry
1741
1848
  */
1742
1849
  class CngxAsyncRegistry {
1743
1850
  entriesState = signal(new Map(), { ...(ngDevMode ? { debugName: "entriesState" } : /* istanbul ignore next */ {}), equal: mapKeySetEqual });
@@ -1766,14 +1873,15 @@ class CngxAsyncRegistry {
1766
1873
  */
1767
1874
  register(state, label) {
1768
1875
  const id = nextUid('cngx-async-op');
1769
- 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));
1770
1878
  next.set(id, { label, state });
1771
1879
  this.entriesState.set(next);
1772
1880
  return id;
1773
1881
  }
1774
1882
  /** Removes the operation with the given uid. No-op if absent. */
1775
1883
  unregister(id) {
1776
- const current = this.entriesState();
1884
+ const current = untracked(this.entriesState);
1777
1885
  if (!current.has(id)) {
1778
1886
  return;
1779
1887
  }
@@ -1801,8 +1909,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1801
1909
  * providers: [provideAsyncRegistry()],
1802
1910
  * });
1803
1911
  * ```
1804
- *
1805
- * @category common/data/async-registry
1912
+ * <example-url>/#/common/data/async-registry/http-requests-in-the-registry</example-url>
1806
1913
  */
1807
1914
  function provideAsyncRegistry() {
1808
1915
  return makeEnvironmentProviders([CngxAsyncRegistry]);
@@ -1811,8 +1918,6 @@ function provideAsyncRegistry() {
1811
1918
  * Returns the ambient {@link CngxAsyncRegistry}, or `null` when the consumer
1812
1919
  * did not opt in via {@link provideAsyncRegistry}. Must run in an injection
1813
1920
  * context.
1814
- *
1815
- * @category common/data/async-registry
1816
1921
  */
1817
1922
  function injectAsyncRegistry() {
1818
1923
  return inject(CngxAsyncRegistry, { optional: true });
@@ -1833,16 +1938,21 @@ function injectAsyncRegistry() {
1833
1938
  * );
1834
1939
  * }
1835
1940
  * ```
1836
- *
1837
- * @category common/data/async-state
1838
1941
  */
1839
1942
  function createAsyncState(options) {
1840
1943
  const destroyRef = inject(DestroyRef);
1841
1944
  const state = createManualState();
1842
- 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
+ };
1843
1953
  destroyRef.onDestroy(() => {
1844
- abortController?.abort();
1845
- abortController = undefined;
1954
+ destroyed = true;
1955
+ cancelActive();
1846
1956
  });
1847
1957
  // Same opt-in observability injectAsyncState offers: without it, mutations
1848
1958
  // built here are invisible to CngxAsyncRegistry.isAnythingLoading.
@@ -1853,7 +1963,7 @@ function createAsyncState(options) {
1853
1963
  destroyRef.onDestroy(() => registry.unregister(operationId));
1854
1964
  }
1855
1965
  }
1856
- return {
1966
+ const mutation = {
1857
1967
  status: state.status,
1858
1968
  data: state.data,
1859
1969
  error: state.error,
@@ -1867,41 +1977,52 @@ function createAsyncState(options) {
1867
1977
  hasData: state.hasData,
1868
1978
  isSettled: state.isSettled,
1869
1979
  lastUpdated: state.lastUpdated,
1870
- async execute(fn) {
1871
- abortController?.abort();
1872
- const controller = new AbortController();
1873
- abortController = controller;
1980
+ execute(fn) {
1981
+ if (destroyed) {
1982
+ return Promise.resolve();
1983
+ }
1984
+ cancelActive();
1874
1985
  state.set('pending');
1875
1986
  state.setProgress(undefined);
1876
- try {
1877
- const result$ = fn();
1878
- const result = isObservable(result$) ? await firstValueFrom(result$) : await result$;
1879
- if (controller.signal.aborted) {
1880
- return;
1881
- }
1882
- state.setSuccess(result);
1883
- }
1884
- catch (err) {
1885
- if (controller.signal.aborted) {
1886
- return;
1887
- }
1888
- state.setError(err);
1889
- }
1890
- finally {
1891
- if (abortController === controller) {
1892
- abortController = undefined;
1893
- }
1894
- }
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
+ });
1895
2006
  },
1896
2007
  reportProgress(value) {
1897
2008
  state.setProgress(value);
1898
2009
  },
1899
2010
  reset() {
1900
- abortController?.abort();
1901
- abortController = undefined;
2011
+ cancelActive();
1902
2012
  state.reset();
1903
2013
  },
1904
2014
  };
2015
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2016
+ CNGX_DEV_DESCRIPTORS.tag(mutation, {
2017
+ kind: 'cngx-dev:factory',
2018
+ factory: 'createAsyncState',
2019
+ // The inner manual state carries its own tag; listing it here is the
2020
+ // only way an inspector reaches it, since the mutation exposes its
2021
+ // signals, not the state object.
2022
+ inputs: { options, state },
2023
+ });
2024
+ }
2025
+ return mutation;
1905
2026
  }
1906
2027
 
1907
2028
  /**
@@ -1918,7 +2039,10 @@ function createAsyncState(options) {
1918
2039
  * source on each access, so bridges observe transitions of whatever is bound
1919
2040
  * right now. With nothing bound it reports a quiet `idle` state rather than
1920
2041
  * throwing, which is what lets a bridge sit inside a timeline that has not
1921
- * 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.
1922
2046
  *
1923
2047
  * Contrast the select family, which provides `CNGX_STATEFUL` with
1924
2048
  * `useFactory` over a concrete `commitState` field - no forwarding needed
@@ -1933,9 +2057,9 @@ function createAsyncState(options) {
1933
2057
  * { provide: CNGX_STATEFUL, useFactory: () => ({ state: inject(Host).asyncState }) }
1934
2058
  * ```
1935
2059
  *
1936
- * @category common/data/async-state
1937
2060
  * @relatedTo createAsyncState, createManualState
1938
- * @since 0.1.0
2061
+ * @since 0.3.0
2062
+ * <example-url>/#/common/data/async-state/forwarded-state-through-an-input</example-url>
1939
2063
  */
1940
2064
  function createForwardedAsyncState(source) {
1941
2065
  return {
@@ -1968,10 +2092,10 @@ function createForwardedAsyncState(source) {
1968
2092
  * );
1969
2093
  * // Loads automatically when filter() changes.
1970
2094
  * // Caches last result during refresh (refreshing state).
1971
- * // 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.
1972
2098
  * ```
1973
- *
1974
- * @category common/data/async-state
1975
2099
  */
1976
2100
  function injectAsyncState(fn, options) {
1977
2101
  const destroyRef = inject(DestroyRef);
@@ -1980,6 +2104,7 @@ function injectAsyncState(fn, options) {
1980
2104
  let activeSubscription;
1981
2105
  let abortController;
1982
2106
  let debounceTimer;
2107
+ let destroyed = false;
1983
2108
  function cancelInFlight() {
1984
2109
  activeSubscription?.unsubscribe();
1985
2110
  activeSubscription = undefined;
@@ -1987,6 +2112,7 @@ function injectAsyncState(fn, options) {
1987
2112
  abortController = undefined;
1988
2113
  }
1989
2114
  destroyRef.onDestroy(() => {
2115
+ destroyed = true;
1990
2116
  cancelInFlight();
1991
2117
  if (debounceTimer !== undefined) {
1992
2118
  clearTimeout(debounceTimer);
@@ -2008,7 +2134,15 @@ function injectAsyncState(fn, options) {
2008
2134
  // first load -> loading, subsequent -> refreshing
2009
2135
  const status = untracked(state.isFirstLoad) ? 'loading' : 'refreshing';
2010
2136
  state.set(status);
2011
- 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
+ }
2012
2146
  if (isObservable(result$)) {
2013
2147
  let hasEmitted = false;
2014
2148
  activeSubscription = result$.subscribe({
@@ -2095,6 +2229,9 @@ function injectAsyncState(fn, options) {
2095
2229
  isSettled: state.isSettled,
2096
2230
  lastUpdated: state.lastUpdated,
2097
2231
  refresh() {
2232
+ if (destroyed) {
2233
+ return;
2234
+ }
2098
2235
  if (debounceTimer !== undefined) {
2099
2236
  clearTimeout(debounceTimer);
2100
2237
  debounceTimer = undefined;
@@ -2119,8 +2256,6 @@ function injectAsyncState(fn, options) {
2119
2256
  * | success | * | true | empty |
2120
2257
  * | error | false | * | content+error |
2121
2258
  * | (all other) | * | * | content |
2122
- *
2123
- * @category common/data/async-state
2124
2259
  */
2125
2260
  function resolveAsyncView(status, firstLoad, empty) {
2126
2261
  if (firstLoad) {
@@ -2155,20 +2290,27 @@ function resolveAsyncView(status, firstLoad, empty) {
2155
2290
  * `[state]` wiring. `failures` exposes the errored sources - keyed, so a
2156
2291
  * consumer's `@for` can render per-source attribution through any feedback
2157
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]`.
2158
2296
  *
2159
2297
  * ```html
2160
- * <div [cngxAsyncBoundary]="sources" #b="cngxAsyncBoundary">
2298
+ * <div [cngxAsyncBoundary]="sources" #b="cngxAsyncBoundary"
2299
+ * cngxToastOn [toastError]="'Loading failed'">
2161
2300
  * <cngx-async-container [state]="b.state"> ... </cngx-async-container>
2162
- * <cngx-toast-on />
2163
2301
  * @for (f of b.failures(); track f.key) {
2164
- * <cngx-banner>{{ f.label }} failed</cngx-banner>
2302
+ * <cngx-alert severity="error" [title]="f.label ?? f.key">{{ messageOf(f.error) }}</cngx-alert>
2165
2303
  * }
2166
2304
  * </div>
2167
2305
  * ```
2168
2306
  *
2169
- * @category common/data/async-state
2170
2307
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async-state/async-boundary.directive.ts
2171
- * @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
2172
2314
  */
2173
2315
  class CngxAsyncBoundary {
2174
2316
  /** The keyed source list to aggregate. */
@@ -2180,7 +2322,7 @@ class CngxAsyncBoundary {
2180
2322
  failures = computed(() => this.sources()
2181
2323
  .filter((s) => s.state.status() === 'error')
2182
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 &&
2183
- 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)) });
2184
2326
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncBoundary, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2185
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 });
2186
2328
  }
@@ -2197,29 +2339,94 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2197
2339
  }]
2198
2340
  }], propDecorators: { sources: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAsyncBoundary", required: true }] }] } });
2199
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
+
2200
2387
  /**
2201
2388
  * Shared projection core for the two resource bridges (`fromResource`,
2202
2389
  * `fromHttpResource`). Derives every flag through `buildAsyncStateView`, so
2203
2390
  * the family semantics (`isLoading` includes pending/refreshing,
2204
2391
  * `isBusy === isLoading`) cannot drift between the bridges and the factories.
2205
2392
  *
2206
- * 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.
2207
2401
  *
2208
2402
  * @internal
2209
2403
  */
2210
2404
  function buildResourceBridge(ref, progress) {
2211
- // ResourceStatus has no "first load" concept, so a successful load is
2212
- // latched here together with its timestamp.
2213
- const hadSuccess = signal(false, ...(ngDevMode ? [{ debugName: "hadSuccess" }] : /* istanbul ignore next */ []));
2214
- 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.
2215
2421
  effect(() => {
2216
- const s = ref.status();
2217
- if (s === 'resolved' || s === 'local') {
2218
- hadSuccess.set(true);
2219
- lastUpdated.set(new Date());
2220
- }
2422
+ latch();
2221
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.
2222
2428
  const status = computed(() => {
2429
+ latch();
2223
2430
  switch (ref.status()) {
2224
2431
  case 'idle':
2225
2432
  return 'idle';
@@ -2236,30 +2443,46 @@ function buildResourceBridge(ref, progress) {
2236
2443
  }, ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
2237
2444
  return buildAsyncStateView({
2238
2445
  status,
2239
- data: computed(() => (ref.hasValue() ? ref.value() : undefined)),
2240
- error: computed(() => ref.error()),
2241
- progress,
2242
- // Idle counts as "before the first load": a not-yet-triggered resource
2243
- // still shows the skeleton, not the empty state.
2244
- isFirstLoad: computed(() => !hadSuccess() && (ref.isLoading() || status() === 'idle')),
2245
- 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
+ }),
2246
2467
  });
2247
2468
  }
2248
2469
 
2249
2470
  /**
2250
2471
  * Bridge that projects an Angular `Resource<T>` onto `CngxAsyncState<T>`.
2251
2472
  *
2252
- * Must be called in an injection context (the `effect()` that tracks
2253
- * `hadSuccess` requires one).
2473
+ * Must be called in an injection context.
2254
2474
  *
2255
2475
  * All signals are derived reactively from the resource - no manual
2256
2476
  * synchronization. The resource stays the single source of truth.
2257
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
+ *
2258
2481
  * ```typescript
2259
2482
  * private readonly res = resource({
2260
- * request: () => ({ filter: this.filter() }),
2261
- * loader: ({ request, abortSignal }) =>
2262
- * 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 })
2263
2486
  * .then(r => r.json()),
2264
2487
  * });
2265
2488
  *
@@ -2267,18 +2490,32 @@ function buildResourceBridge(ref, progress) {
2267
2490
  * // items.status(), items.data(), items.isFirstLoad() - all work
2268
2491
  * // <cngx-async-container [state]="items"> - direct binding
2269
2492
  * ```
2270
- *
2271
- * @category common/data/async-state
2272
2493
  */
2273
2494
  function fromResource(ref) {
2274
2495
  return buildResourceBridge(ref);
2275
2496
  }
2276
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
+
2277
2511
  /**
2278
2512
  * Bridge that projects an Angular `httpResource()` ref onto `CngxAsyncState<T>`.
2279
2513
  *
2280
2514
  * Identical to `fromResource` but additionally maps the HTTP progress
2281
- * signal to `CngxAsyncState.progress` (0–100 scale).
2515
+ * signal to `CngxAsyncState.progress` (0-100 scale): `loaded / total`,
2516
+ * rounded and clamped. With an unknown or zero `total` the progress is
2517
+ * `undefined` (indeterminate). Angular only emits progress events when the
2518
+ * request sets `reportProgress: true`.
2282
2519
  *
2283
2520
  * Must be called in an injection context.
2284
2521
  *
@@ -2286,23 +2523,19 @@ function fromResource(ref) {
2286
2523
  * private readonly res = httpResource<Item[]>(() => ({
2287
2524
  * url: '/api/items',
2288
2525
  * params: { q: this.filter() },
2526
+ * reportProgress: true,
2289
2527
  * }));
2290
2528
  *
2291
2529
  * readonly items = fromHttpResource(this.res);
2292
- * // items.progress() tracks upload/download progress
2530
+ * // items.progress() tracks download progress 0-100
2293
2531
  * // <cngx-progress [state]="items"> - auto-wired progress bar
2294
2532
  * ```
2295
- *
2296
- * @category common/data/async-state
2297
2533
  */
2298
2534
  function fromHttpResource(ref) {
2299
- // Map HTTP progress (0-1 float) to 0-100 integer, clamped.
2535
+ // No event or no total = indeterminate.
2300
2536
  const progress = computed(() => {
2301
- const p = ref.progress();
2302
- if (p == null) {
2303
- return undefined;
2304
- }
2305
- return Math.round(Math.min(p, 1) * 100);
2537
+ const event = ref.progress();
2538
+ return event ? progressPercent(event.loaded, event.total) : undefined;
2306
2539
  }, ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
2307
2540
  return buildResourceBridge(ref, progress);
2308
2541
  }
@@ -2314,8 +2547,9 @@ function fromHttpResource(ref) {
2314
2547
  * read via the sink's `isFirstLoad`; an explicit `options.status` wins).
2315
2548
  * On next: calls `setSuccess(value)`.
2316
2549
  * On error: calls `setError(err)` and **re-throws** (does not swallow).
2317
- * On teardown without a value (unsubscribe mid-flight, empty complete):
2318
- * 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.
2319
2553
  *
2320
2554
  * The Observable passes through unchanged - `tapAsyncState` is a side-effect operator.
2321
2555
  *
@@ -2329,8 +2563,6 @@ function fromHttpResource(ref) {
2329
2563
  * ).subscribe();
2330
2564
  * }
2331
2565
  * ```
2332
- *
2333
- * @category common/data/async-state
2334
2566
  */
2335
2567
  function tapAsyncState(state, options) {
2336
2568
  return (source) => defer(() => {
@@ -2345,9 +2577,15 @@ function tapAsyncState(state, options) {
2345
2577
  settled = true;
2346
2578
  state.setError(err);
2347
2579
  },
2580
+ complete: () => {
2581
+ if (!settled) {
2582
+ settled = true;
2583
+ state.setSuccess(undefined);
2584
+ }
2585
+ },
2348
2586
  }), finalize(() => {
2349
- // Torn down without ever settling (cancelled mid-flight or an
2350
- // 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.
2351
2589
  if (!settled) {
2352
2590
  state.set('idle');
2353
2591
  }
@@ -2362,7 +2600,8 @@ const RESPONSE = 4;
2362
2600
  * RxJS operator that extracts upload/download progress from an
2363
2601
  * `HttpEvent` stream and reports it to a `ManualAsyncState`.
2364
2602
  *
2365
- * Filters progress events, calculates percentage, calls `setProgress()`.
2603
+ * Filters progress events, calculates an integer percentage clamped to
2604
+ * 0-100, calls `setProgress()`.
2366
2605
  * Non-progress events pass through unchanged.
2367
2606
  *
2368
2607
  * Use with `{ observe: 'events', reportProgress: true }` on HttpClient.
@@ -2380,16 +2619,17 @@ const RESPONSE = 4;
2380
2619
  * ).subscribe();
2381
2620
  * }
2382
2621
  * ```
2383
- *
2384
- * @category common/data/async-state
2622
+ * <example-url>/#/common/data/async-operators/tap-async-progress</example-url>
2385
2623
  */
2386
2624
  function tapAsyncProgress(state) {
2387
2625
  return tap((event) => {
2388
2626
  const e = event;
2389
- if ((e.type === UPLOAD_PROGRESS || e.type === DOWNLOAD_PROGRESS) &&
2390
- e.total != null &&
2391
- e.total > 0) {
2392
- 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);
2393
2633
  }
2394
2634
  });
2395
2635
  }
@@ -2405,7 +2645,8 @@ function tapAsyncProgress(state) {
2405
2645
  * 5. Call `setError(err)` on error
2406
2646
  *
2407
2647
  * The output Observable emits the **response body** (not HttpEvents).
2408
- * Throws if the response body is `null`.
2648
+ * Throws a `CngxRuntimeError` with code [`CNGX1054`](/error-codes/cngx1054.md) if the response body is
2649
+ * `null`; the sink receives it through `setError(err)`.
2409
2650
  *
2410
2651
  * ```typescript
2411
2652
  * readonly upload = createManualState<UploadResult>();
@@ -2421,8 +2662,7 @@ function tapAsyncProgress(state) {
2421
2662
  * // upload.status(), upload.progress(), upload.data() - all wired
2422
2663
  * }
2423
2664
  * ```
2424
- *
2425
- * @category common/data/async-state
2665
+ * <example-url>/#/common/data/async-operators/tap-http-async-state</example-url>
2426
2666
  */
2427
2667
  function tapHttpAsyncState(state, options) {
2428
2668
  return (source) => defer(() => {
@@ -2432,7 +2672,9 @@ function tapHttpAsyncState(state, options) {
2432
2672
  return event.type === RESPONSE;
2433
2673
  }), map((response) => {
2434
2674
  if (response.body == null) {
2435
- throw new Error('tapHttpAsyncState: response body is null');
2675
+ throw new CngxRuntimeError('CNGX1054', typeof ngDevMode !== 'undefined' &&
2676
+ ngDevMode &&
2677
+ 'tapHttpAsyncState(): response body is null');
2436
2678
  }
2437
2679
  return response.body;
2438
2680
  }), tap({
@@ -2469,9 +2711,8 @@ function tapHttpAsyncState(state, options) {
2469
2711
  *
2470
2712
  * @returns A probe over `CngxAsyncRegistry.isAnythingLoading`.
2471
2713
  *
2472
- * @category common/data/async-registry
2473
2714
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async-registry/inject-latency-probe.ts
2474
- * @since 0.1.0
2715
+ * @since 0.3.0
2475
2716
  * @relatedTo provideAsyncRegistry, injectAsyncRegistry, createLatencyProbe
2476
2717
  */
2477
2718
  function injectLatencyProbe() {
@@ -2482,16 +2723,12 @@ function injectLatencyProbe() {
2482
2723
  /**
2483
2724
  * Per-request label surfaced in `CngxAsyncRegistry.activeOperations` when the
2484
2725
  * request is tracked by `cngxAsyncInterceptor`. Display only, never a key.
2485
- *
2486
- * @category common/data/async-registry
2487
2726
  */
2488
2727
  const CNGX_ASYNC_LABEL = new HttpContextToken(() => undefined);
2489
2728
  /**
2490
2729
  * Per-request opt-out. When `true`, `cngxAsyncInterceptor` passes the request
2491
2730
  * through without registering it - keeps polling / telemetry pings out of the
2492
2731
  * aggregate without a global allow-list.
2493
- *
2494
- * @category common/data/async-registry
2495
2732
  */
2496
2733
  const CNGX_ASYNC_SKIP = new HttpContextToken(() => false);
2497
2734
  /**
@@ -2501,8 +2738,7 @@ const CNGX_ASYNC_SKIP = new HttpContextToken(() => false);
2501
2738
  * ```typescript
2502
2739
  * this.http.get('/api/users', { context: withAsyncLabel('users') });
2503
2740
  * ```
2504
- *
2505
- * @category common/data/async-registry
2741
+ * <example-url>/#/common/data/async-registry/label-and-skip-requests</example-url>
2506
2742
  */
2507
2743
  function withAsyncLabel(label, context = new HttpContext()) {
2508
2744
  return context.set(CNGX_ASYNC_LABEL, label);
@@ -2514,8 +2750,7 @@ function withAsyncLabel(label, context = new HttpContext()) {
2514
2750
  * ```typescript
2515
2751
  * this.http.get('/api/ping', { context: withAsyncSkip() });
2516
2752
  * ```
2517
- *
2518
- * @category common/data/async-registry
2753
+ * <example-url>/#/common/data/async-registry/label-and-skip-requests</example-url>
2519
2754
  */
2520
2755
  function withAsyncSkip(context = new HttpContext()) {
2521
2756
  return context.set(CNGX_ASYNC_SKIP, true);
@@ -2531,34 +2766,36 @@ function withAsyncSkip(context = new HttpContext()) {
2531
2766
  * request straight through when no registry is provided - zero behaviour
2532
2767
  * change for consumers who do not opt in.
2533
2768
  * - Passes through without registering when `CNGX_ASYNC_SKIP` is set.
2534
- * - Otherwise registers a fresh `createManualState` (set `loading`) under a
2535
- * per-request uid, maps the final response / error onto it, and
2536
- * `unregister`s in a `finalize` that fires on success **and** error (and on
2537
- * 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.
2538
2774
  *
2539
2775
  * Per-request uid identity (from `CngxAsyncRegistry`) means concurrent requests
2540
2776
  * sharing a label never evict one another - completing one leaves the other
2541
2777
  * tracked. The interceptor does not swallow errors: `setError` records the
2542
2778
  * failure, then the error propagates to the caller unchanged.
2543
- *
2544
- * @category common/data/async-registry
2779
+ * <example-url>/#/common/data/async-registry/http-requests-in-the-registry</example-url>
2545
2780
  */
2546
2781
  const cngxAsyncInterceptor = (req, next) => {
2547
2782
  const registry = inject(CngxAsyncRegistry, { optional: true });
2548
2783
  if (!registry || req.context.get(CNGX_ASYNC_SKIP)) {
2549
2784
  return next(req);
2550
2785
  }
2551
- const state = createManualState();
2552
- state.set('loading');
2553
- const operationId = registry.register(state, req.context.get(CNGX_ASYNC_LABEL));
2554
- return next(req).pipe(tap({
2555
- next: (event) => {
2556
- if (event.type === HttpEventType.Response) {
2557
- state.setSuccess(event.body);
2558
- }
2559
- },
2560
- error: (err) => state.setError(err),
2561
- }), 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
+ });
2562
2799
  };
2563
2800
  /**
2564
2801
  * Sets up `HttpClient` with {@link cngxAsyncInterceptor} so every request
@@ -2585,8 +2822,6 @@ const cngxAsyncInterceptor = (req, next) => {
2585
2822
  * ```ts
2586
2823
  * provideHttpClient(withFetch(), withInterceptors([authInterceptor, cngxAsyncInterceptor]))
2587
2824
  * ```
2588
- *
2589
- * @category common/data/async-registry
2590
2825
  */
2591
2826
  function provideAsyncHttpObservability() {
2592
2827
  return makeEnvironmentProviders([provideHttpClient(withInterceptors([cngxAsyncInterceptor]))]);
@@ -2606,6 +2841,14 @@ function provideAsyncHttpObservability() {
2606
2841
  * directive renders exactly one template, so the error half is flattened
2607
2842
  * away here; surface it separately (toast, alert) when it must be visible
2608
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
+ *
2609
2852
  * ### Minimal - just content
2610
2853
  * ```html
2611
2854
  * <ul *cngxAsync="residents; let data">
@@ -2632,23 +2875,24 @@ function provideAsyncHttpObservability() {
2632
2875
  * </ng-template>
2633
2876
  * ```
2634
2877
  *
2635
- * @category common/data/async-state
2636
- * @docsKind primary
2637
2878
  * @wcag AA
2638
2879
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/async/async.directive.ts
2639
- * @since 0.1.0
2880
+ * @since 0.3.0
2640
2881
  * @relatedTo injectAsyncState, createAsyncState, createManualState
2641
2882
  *
2642
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngx-async-container-full-control-toast</example-url>
2643
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngxasync-one-line</example-url>
2644
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/cngxasync-with-custom-templates</example-url>
2645
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/composition-overlay-container-toast</example-url>
2646
- * <example-url>http://localhost:4200/#/ui/feedback/async-container/createasyncstate-mutation</example-url>
2647
- * <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
2648
2890
  */
2649
2891
  class CngxAsync {
2650
2892
  vcr = inject(ViewContainerRef);
2651
2893
  contentTpl = inject(TemplateRef);
2894
+ doc = inject(DOCUMENT);
2895
+ injector = inject(Injector);
2652
2896
  /** The async state to render. */
2653
2897
  cngxAsync = input.required(...(ngDevMode ? [{ debugName: "cngxAsync" }] : /* istanbul ignore next */ []));
2654
2898
  /** Optional skeleton template shown during first load. */
@@ -2657,47 +2901,116 @@ class CngxAsync {
2657
2901
  cngxAsyncEmpty = input(undefined, ...(ngDevMode ? [{ debugName: "cngxAsyncEmpty" }] : /* istanbul ignore next */ []));
2658
2902
  /** Optional error template shown on error during first load. Context: `{ $implicit: error }`. */
2659
2903
  cngxAsyncError = input(undefined, ...(ngDevMode ? [{ debugName: "cngxAsyncError" }] : /* istanbul ignore next */ []));
2904
+ // content+error → content (structural directive has no dual-render)
2660
2905
  view = computed(() => {
2661
2906
  const s = this.cngxAsync();
2662
- 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;
2663
2909
  }, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
2664
- // Plain field, not a signal: it is only ever read and written inside the
2665
- // 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
2666
2925
  // caused one spurious re-run per view switch.
2667
2926
  currentView = 'none';
2927
+ currentTemplate = undefined;
2668
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;
2669
2933
  constructor() {
2670
2934
  effect(() => {
2671
2935
  const view = this.view();
2936
+ const tpl = this.slotTemplate();
2672
2937
  const s = this.cngxAsync();
2673
- // content+error → show content (structural directive has no dual-render)
2674
- const effective = view === 'content+error' ? 'content' : view;
2675
- if (effective === this.currentView) {
2938
+ if (view === this.currentView && tpl === this.currentTemplate) {
2676
2939
  this.updateContentContext(s);
2677
2940
  return;
2678
2941
  }
2942
+ if (this.renderedViewHoldsFocus()) {
2943
+ this.focusSwitchesLeft = 2;
2944
+ }
2679
2945
  this.vcr.clear();
2680
2946
  this.contentViewRef = null;
2681
- this.currentView = effective;
2682
- 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
+ }
2683
2954
  });
2684
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
+ }
2685
3000
  updateContentContext(s) {
2686
3001
  if (!this.contentViewRef) {
2687
3002
  return;
2688
3003
  }
2689
3004
  const data = s.data();
2690
- if (data === undefined) {
2691
- return;
2692
- }
2693
3005
  this.contentViewRef.context.$implicit = data;
2694
3006
  this.contentViewRef.context.cngxAsync = data;
2695
3007
  this.contentViewRef.markForCheck();
2696
3008
  }
2697
- renderView(view, s) {
3009
+ renderView(view, tpl, s) {
2698
3010
  switch (view) {
2699
3011
  case 'skeleton':
2700
- this.renderTemplate(this.cngxAsyncSkeleton());
3012
+ case 'empty':
3013
+ this.renderTemplate(tpl);
2701
3014
  break;
2702
3015
  case 'content':
2703
3016
  case 'content+error': {
@@ -2708,11 +3021,8 @@ class CngxAsync {
2708
3021
  });
2709
3022
  break;
2710
3023
  }
2711
- case 'empty':
2712
- this.renderTemplate(this.cngxAsyncEmpty());
2713
- break;
2714
3024
  case 'error':
2715
- this.renderTemplate(this.cngxAsyncError(), { $implicit: s.error() });
3025
+ this.renderTemplate(tpl, { $implicit: s.error() });
2716
3026
  break;
2717
3027
  }
2718
3028
  }
@@ -2740,8 +3050,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2740
3050
  * The English kpi section: the single source of the KPI atoms' English copy.
2741
3051
  * `CNGX_KPI_I18N` defaults to it.
2742
3052
  *
2743
- * @category common/data/i18n
2744
- * @since 0.1.0
3053
+ * @since 0.3.0
2745
3054
  * @relatedTo CNGX_KPI_I18N
2746
3055
  */
2747
3056
  const CNGX_KPI_LANGUAGE_EN = {
@@ -2795,30 +3104,24 @@ const kpiBundle = createSectionBundle({
2795
3104
  * app locale; the value is a `Signal`, shared by every reader under one
2796
3105
  * injector.
2797
3106
  *
2798
- * @category common/data/i18n
2799
3107
  * @wcag AA
2800
3108
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/shared/kpi-i18n.ts
2801
- * @since 0.1.0
3109
+ * @since 0.3.0
2802
3110
  * @relatedTo CngxDelta, CngxTrend, CngxGoal
2803
3111
  */
2804
3112
  const CNGX_KPI_I18N = new InjectionToken('CngxKpiI18n', {
2805
3113
  providedIn: 'root',
2806
3114
  factory: () => kpiBundle.build(),
2807
3115
  });
2808
- /** @internal */
2809
- function defineKpiI18nFeature(fn) {
2810
- return Object.assign(fn, { _target: 'i18n' });
2811
- }
2812
3116
  /**
2813
3117
  * Override KPI labels via a partial bundle - unset keys keep the language
2814
3118
  * pack's copy, or the English default. Pass a `Signal` of a partial bundle to switch languages at
2815
3119
  * runtime.
2816
3120
  *
2817
- * @category common/data/i18n
2818
- * @since 0.1.0
3121
+ * @since 0.3.0
2819
3122
  */
2820
3123
  function withKpiI18nLabels(overrides) {
2821
- return defineKpiI18nFeature((bundle) => createOverrideMerge(bundle, overrides));
3124
+ return (bundle) => createOverrideMerge(bundle, overrides);
2822
3125
  }
2823
3126
  /**
2824
3127
  * Provider for the KPI i18n bundle. Returns a plain `Provider`, so it also
@@ -2837,8 +3140,7 @@ function withKpiI18nLabels(overrides) {
2837
3140
  * });
2838
3141
  * ```
2839
3142
  *
2840
- * @category common/data/i18n
2841
- * @since 0.1.0
3143
+ * @since 0.3.0
2842
3144
  */
2843
3145
  function provideKpiI18n(...features) {
2844
3146
  return {
@@ -2850,8 +3152,7 @@ function provideKpiI18n(...features) {
2850
3152
  * Inject the resolved KPI i18n bundle signal. Read it inside a `computed()`
2851
3153
  * or template so a runtime override flip re-derives.
2852
3154
  *
2853
- * @category common/data/i18n
2854
- * @since 0.1.0
3155
+ * @since 0.3.0
2855
3156
  */
2856
3157
  function injectKpiI18n() {
2857
3158
  return kpiBundle.resolve(inject(CNGX_KPI_I18N));
@@ -2890,15 +3191,14 @@ function readsUnitFirst(message) {
2890
3191
  * </cngx-card>
2891
3192
  * ```
2892
3193
  *
2893
- * @category common/data/metric
2894
- * @docsKind primary
2895
3194
  * @wcag AA
2896
3195
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/metric/metric.component.ts
2897
- * @since 0.1.0
3196
+ * @since 0.3.0
2898
3197
  * @relatedTo CngxTrend, CngxCard
2899
3198
  *
2900
- * <example-url>http://localhost:4200/#/common/data/metric/inside-a-card</example-url>
2901
- * <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
2902
3202
  */
2903
3203
  class CngxMetric {
2904
3204
  locale = injectLocale();
@@ -2952,7 +3252,7 @@ class CngxMetric {
2952
3252
  @if (shownUnit() && !unitFirst()) {
2953
3253
  <span class="cngx-metric__unit">{{ shownUnit() }}</span>
2954
3254
  }
2955
- `, 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 });
2956
3256
  }
2957
3257
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxMetric, decorators: [{
2958
3258
  type: Component,
@@ -2972,7 +3272,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2972
3272
  @if (shownUnit() && !unitFirst()) {
2973
3273
  <span class="cngx-metric__unit">{{ shownUnit() }}</span>
2974
3274
  }
2975
- `, 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"] }]
2976
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 }] }] } });
2977
3277
 
2978
3278
  /**
@@ -2987,7 +3287,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2987
3287
  * consume these helpers so the direction / glyph / format logic has a single
2988
3288
  * source of truth (Pillar 1) with no Angular dependency.
2989
3289
  */
2990
- /** `> 0 → up`, `< 0 → down`, `0 → flat`. */
3290
+ /**
3291
+ * `> 0 → up`, `< 0 → down`, `0 → flat`.
3292
+ * @internal
3293
+ */
2991
3294
  function deltaDirection(value) {
2992
3295
  return value > 0 ? 'up' : value < 0 ? 'down' : 'flat';
2993
3296
  }
@@ -2995,6 +3298,7 @@ function deltaDirection(value) {
2995
3298
  * Combine movement with the caller's polarity. `flat` or `neutral` polarity
2996
3299
  * collapse to `neutral`; otherwise up is positive under `higher-is-better`
2997
3300
  * and negative under `lower-is-better` (and the reverse for down).
3301
+ * @internal
2998
3302
  */
2999
3303
  function deltaSentiment(direction, polarity) {
3000
3304
  if (direction === 'flat' || polarity === 'neutral') {
@@ -3004,7 +3308,10 @@ function deltaSentiment(direction, polarity) {
3004
3308
  const isGood = direction === 'up' ? upIsGood : !upIsGood;
3005
3309
  return isGood ? 'positive' : 'negative';
3006
3310
  }
3007
- /** Arrow glyph for the direction: `↑` / `↓` / `→`. */
3311
+ /**
3312
+ * Arrow glyph for the direction: `↑` / `↓` / `→`.
3313
+ * @internal
3314
+ */
3008
3315
  function directionGlyph(direction) {
3009
3316
  return direction === 'up' ? '↑' : direction === 'down' ? '↓' : '→';
3010
3317
  }
@@ -3016,6 +3323,7 @@ function directionGlyph(direction) {
3016
3323
  * absolute mode uses the locale grouping.
3017
3324
  * A supplied `Intl.NumberFormatOptions` overrides the default digit handling
3018
3325
  * in both modes.
3326
+ * @internal
3019
3327
  */
3020
3328
  function formatDelta(value, mode, locale, format) {
3021
3329
  const abs = Math.abs(value);
@@ -3060,15 +3368,14 @@ function formatDelta(value, mode, locale, format) {
3060
3368
  * </cngx-card>
3061
3369
  * ```
3062
3370
  *
3063
- * @category common/data/metric
3064
- * @docsKind primary
3065
3371
  * @wcag AA
3066
3372
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/trend/trend.component.ts
3067
- * @since 0.1.0
3373
+ * @since 0.3.0
3068
3374
  * @relatedTo CngxMetric, CngxCard
3069
3375
  *
3070
- * <example-url>http://localhost:4200/#/common/data/trend/composed-with-metric-in-a-card</example-url>
3071
- * <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
3072
3379
  */
3073
3380
  class CngxTrend {
3074
3381
  locale = injectLocale();
@@ -3088,7 +3395,7 @@ class CngxTrend {
3088
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: `
3089
3396
  <span aria-hidden="true">{{ icon() }}</span>
3090
3397
  {{ formattedValue() }}
3091
- `, 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 });
3092
3399
  }
3093
3400
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTrend, decorators: [{
3094
3401
  type: Component,
@@ -3104,7 +3411,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3104
3411
  }, template: `
3105
3412
  <span aria-hidden="true">{{ icon() }}</span>
3106
3413
  {{ formattedValue() }}
3107
- `, 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"] }]
3108
3415
  }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: true }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
3109
3416
 
3110
3417
  /**
@@ -3135,14 +3442,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3135
3442
  * <cngx-delta [value]="1240" mode="absolute" [format]="{ maximumFractionDigits: 0 }" />
3136
3443
  * ```
3137
3444
  *
3138
- * @category common/data/metric
3139
- * @docsKind primary
3140
3445
  * @wcag AA
3141
3446
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/delta/delta.component.ts
3142
- * @since 0.1.0
3447
+ * @since 0.3.0
3143
3448
  * @relatedTo CngxTrend, CngxMetric, CngxStat
3144
3449
  *
3145
- * <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
3146
3452
  */
3147
3453
  class CngxDelta {
3148
3454
  locale = injectLocale();
@@ -3178,7 +3484,7 @@ class CngxDelta {
3178
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: `
3179
3485
  <span aria-hidden="true">{{ glyph() }}</span>
3180
3486
  {{ formattedValue() }}
3181
- `, 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 });
3182
3488
  }
3183
3489
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDelta, decorators: [{
3184
3490
  type: Component,
@@ -3196,7 +3502,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3196
3502
  }, template: `
3197
3503
  <span aria-hidden="true">{{ glyph() }}</span>
3198
3504
  {{ formattedValue() }}
3199
- `, 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"] }]
3200
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 }] }] } });
3201
3507
 
3202
3508
  /** Fixed reading order for the coordinated slots. */
@@ -3224,9 +3530,8 @@ const kindsEqual = (a, b) => a.length === b.length && a.every((kind, i) => kind
3224
3530
  * Same shape as `CngxPaginate` behind `CNGX_PAGINATOR_HOST`, which
3225
3531
  * `CngxPaginator` and `CngxIncrementalList` share the same way.
3226
3532
  *
3227
- * @category common/data/metric
3228
3533
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/stat/stat-coordinator.directive.ts
3229
- * @since 0.1.0
3534
+ * @since 0.3.0
3230
3535
  * @relatedTo CngxStat, CNGX_STAT
3231
3536
  */
3232
3537
  class CngxStatCoordinator {
@@ -3301,14 +3606,13 @@ const CNGX_STAT = new InjectionToken('CNGX_STAT');
3301
3606
  * </cngx-stat>
3302
3607
  * ```
3303
3608
  *
3304
- * @category common/data/metric
3305
- * @docsKind primary
3306
3609
  * @wcag AA
3307
3610
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/stat/stat.component.ts
3308
- * @since 0.1.0
3611
+ * @since 0.3.0
3309
3612
  * @relatedTo CngxMetric, CngxDelta, CngxTrend, CngxStatCoordinator
3310
3613
  *
3311
- * <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
3312
3616
  */
3313
3617
  class CngxStat {
3314
3618
  /** @internal The shared slot-id brain, applied as a host directive. */
@@ -3361,8 +3665,7 @@ function useStatSlot(kind) {
3361
3665
  * Marks the label element of a {@link CngxStat}. Its generated id leads the
3362
3666
  * molecule's `aria-labelledby`.
3363
3667
  *
3364
- * @category common/data/metric
3365
- * @since 0.1.0
3668
+ * @since 0.3.0
3366
3669
  * @relatedTo CngxStat
3367
3670
  */
3368
3671
  class CngxStatLabel {
@@ -3383,8 +3686,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3383
3686
  * Marks the primary value element of a {@link CngxStat} (typically a
3384
3687
  * `<cngx-metric>`).
3385
3688
  *
3386
- * @category common/data/metric
3387
- * @since 0.1.0
3689
+ * @since 0.3.0
3388
3690
  * @relatedTo CngxStat
3389
3691
  */
3390
3692
  class CngxStatValue {
@@ -3405,8 +3707,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3405
3707
  * Marks the delta element of a {@link CngxStat} (typically a `<cngx-delta>`
3406
3708
  * or `<cngx-trend>`).
3407
3709
  *
3408
- * @category common/data/metric
3409
- * @since 0.1.0
3710
+ * @since 0.3.0
3410
3711
  * @relatedTo CngxStat
3411
3712
  */
3412
3713
  class CngxStatDelta {
@@ -3427,8 +3728,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3427
3728
  * Marks the caption element of a {@link CngxStat} - the trailing context
3428
3729
  * line (e.g. "vs. last quarter").
3429
3730
  *
3430
- * @category common/data/metric
3431
- * @since 0.1.0
3731
+ * @since 0.3.0
3432
3732
  * @relatedTo CngxStat
3433
3733
  */
3434
3734
  class CngxStatCaption {
@@ -3463,14 +3763,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3463
3763
  * <cngx-goal [value]="q()" [max]="target()" [valueTextFormat]="quotaText" />
3464
3764
  * ```
3465
3765
  *
3466
- * @category common/data/metric
3467
- * @docsKind primary
3468
3766
  * @wcag AA
3469
3767
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/display/goal/goal.component.ts
3470
- * @since 0.1.0
3768
+ * @since 0.3.0
3471
3769
  * @relatedTo CngxSegmentedProgress, CngxMetric
3472
3770
  *
3473
- * <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
3474
3773
  */
3475
3774
  class CngxGoal {
3476
3775
  i18n = injectKpiI18n();
@@ -3508,7 +3807,7 @@ class CngxGoal {
3508
3807
  return fmt(this.now(), this.maxValue());
3509
3808
  }, ...(ngDevMode ? [{ debugName: "valueText" }] : /* istanbul ignore next */ []));
3510
3809
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxGoal, deps: [], target: i0.ɵɵFactoryTarget.Component });
3511
- 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 });
3512
3811
  }
3513
3812
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxGoal, decorators: [{
3514
3813
  type: Component,
@@ -3521,15 +3820,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
3521
3820
  '[attr.aria-valuetext]': 'valueText()',
3522
3821
  '[attr.aria-label]': 'label() ?? null',
3523
3822
  '[style.--cngx-goal-fill.%]': 'fillPercent()',
3524
- }, 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"] }]
3525
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 }] }] } });
3526
3825
 
3527
3826
  /**
3528
3827
  * The English recycler section: the single source of the recycler's English
3529
3828
  * copy. `CNGX_RECYCLER_I18N` defaults to it.
3530
3829
  *
3531
- * @category common/data/i18n
3532
- * @since 0.1.0
3830
+ * @since 0.3.0
3533
3831
  * @relatedTo CNGX_RECYCLER_I18N
3534
3832
  */
3535
3833
  const CNGX_RECYCLER_LANGUAGE_EN = {
@@ -3566,10 +3864,15 @@ const EMPTY_RANGE = {
3566
3864
  * @param overscanAfter Extra items to render below the viewport (leading edge when
3567
3865
  * scrolling down). Defaults to `overscanBefore` for a symmetric range. Callers pass
3568
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.
3569
3872
  * @returns The computed range with spacer offsets.
3570
3873
  * @internal
3571
3874
  */
3572
- function computeRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, columns = 1, overscanAfter = overscanBefore) {
3875
+ function computeRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, columns = 1, overscanAfter = overscanBefore, maxLead) {
3573
3876
  if (totalCount <= 0) {
3574
3877
  return EMPTY_RANGE;
3575
3878
  }
@@ -3587,7 +3890,7 @@ function computeRange(scrollTop, clientHeight, totalCount, estimateSize, oversca
3587
3890
  return computeFixedRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter, columns);
3588
3891
  }
3589
3892
  // variable heights: grid mode unsupported, columns ignored
3590
- return computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter);
3893
+ return computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter, maxLead);
3591
3894
  }
3592
3895
  function estimateTotalSize(totalCount, estimateSize, columns) {
3593
3896
  if (typeof estimateSize === 'number') {
@@ -3648,7 +3951,7 @@ function computeGridRange(scrollTop, clientHeight, totalCount, rowHeight, oversc
3648
3951
  totalSize,
3649
3952
  };
3650
3953
  }
3651
- function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter) {
3954
+ function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize, overscanBefore, overscanAfter, maxLead) {
3652
3955
  let totalSize = 0;
3653
3956
  const offsets = new Array(totalCount + 1);
3654
3957
  offsets[0] = 0;
@@ -3659,8 +3962,15 @@ function computeVariableRange(scrollTop, clientHeight, totalCount, estimateSize,
3659
3962
  // binary search: first item whose bottom edge is past scrollTop
3660
3963
  const rawStart = binarySearch(offsets, scrollTop, totalCount);
3661
3964
  const rawEnd = binarySearch(offsets, scrollTop + clientHeight, totalCount);
3662
- const start = Math.max(0, rawStart - overscanBefore);
3663
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);
3664
3974
  return {
3665
3975
  start,
3666
3976
  end,
@@ -3782,8 +4092,12 @@ function createScrollObserver(elementRef, destroyRef) {
3782
4092
  if (typeof elementRef !== 'string' || typeof MutationObserver === 'undefined') {
3783
4093
  return;
3784
4094
  }
3785
- if (isDevMode()) {
3786
- console.warn(`recycler scrollElement '${elementRef}' not found on first render; ` +
4095
+ // Mounted between the first effect run and now: the bump above attaches it.
4096
+ if (resolveElement(elementRef, doc) != null) {
4097
+ return;
4098
+ }
4099
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
4100
+ cngxDevWarn('CNGX1013', `injectRecycler(): scrollElement '${elementRef}' not found on first render; ` +
3787
4101
  'it will attach automatically once it mounts. If it never does, check the selector.');
3788
4102
  }
3789
4103
  mutationObserver = new MutationObserver(() => {
@@ -3881,27 +4195,20 @@ const recyclerBundle = createSectionBundle({
3881
4195
  * of the active language pack over English, counts formatted for the app
3882
4196
  * locale. Override with `provideRecyclerI18n()`.
3883
4197
  *
3884
- * @category common/data/recycler
3885
4198
  * @wcag AA
3886
4199
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler.ts
3887
- * @since 0.1.0
4200
+ * @since 0.3.0
3888
4201
  */
3889
4202
  const CNGX_RECYCLER_I18N = new InjectionToken('CngxRecyclerI18n', {
3890
4203
  factory: () => recyclerBundle.build(),
3891
4204
  });
3892
- /** @internal */
3893
- function defineRecyclerI18nFeature(fn) {
3894
- return Object.assign(fn, { _target: 'i18n' });
3895
- }
3896
4205
  /**
3897
4206
  * Override recycler announcements via a partial bundle - keys you leave out
3898
4207
  * keep the language pack's text, or the English default. Pass a `Signal` to
3899
4208
  * switch the language at runtime.
3900
- *
3901
- * @category common/data/recycler
3902
4209
  */
3903
4210
  function withRecyclerI18nLabels(overrides) {
3904
- return defineRecyclerI18nFeature((bundle) => createOverrideMerge(bundle, overrides));
4211
+ return (bundle) => createOverrideMerge(bundle, overrides);
3905
4212
  }
3906
4213
  /**
3907
4214
  * Provider for the recycler announcement texts. The features apply on top of
@@ -3917,8 +4224,6 @@ function withRecyclerI18nLabels(overrides) {
3917
4224
  * ),
3918
4225
  * ]
3919
4226
  * ```
3920
- *
3921
- * @category common/data/recycler
3922
4227
  */
3923
4228
  function provideRecyclerI18n(...features) {
3924
4229
  return {
@@ -3952,16 +4257,14 @@ function provideRecyclerI18n(...features) {
3952
4257
  * state: this.state,
3953
4258
  * });
3954
4259
  * ```
3955
- *
3956
- * @category common/data/recycler
3957
4260
  */
3958
4261
  function injectRecycler(config) {
3959
4262
  const destroyRef = inject(DestroyRef);
3960
4263
  const i18n = recyclerBundle.resolve(inject(CNGX_RECYCLER_I18N));
3961
4264
  const overscan = config.overscan ?? 5;
3962
4265
  const isGrid = (config.layout ?? 'list') === 'grid';
3963
- if (isGrid && config.columns == null && isDevMode()) {
3964
- console.error('[CngxRecycler] layout: "grid" requires explicit `columns`. Falling back to columns=1.');
4266
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && isGrid && config.columns == null) {
4267
+ cngxDevError('CNGX1011', 'injectRecycler(): layout: "grid" requires explicit `columns`. Falling back to columns=1.');
3965
4268
  }
3966
4269
  // Reactive columns - reactive only if the function reads a Signal internally
3967
4270
  const columns = computed(() => {
@@ -3974,10 +4277,13 @@ function injectRecycler(config) {
3974
4277
  // per-index measurement - it carries no O(n) per-frame cost, so exclude it
3975
4278
  // from the variable-height warning (a reactive scalar estimate is a
3976
4279
  // sanctioned pattern; see the resolveSize note below).
3977
- if (typeof config.estimateSize === 'function' && !isSignal(config.estimateSize) && isDevMode()) {
4280
+ if (typeof ngDevMode !== 'undefined' &&
4281
+ ngDevMode &&
4282
+ typeof config.estimateSize === 'function' &&
4283
+ !isSignal(config.estimateSize)) {
3978
4284
  const count = config.totalCount();
3979
4285
  if (count > 10_000) {
3980
- console.warn(`[CngxRecycler] estimateSize as a function with ${count} items has O(n) ` +
4286
+ cngxDevWarn('CNGX1012', `injectRecycler(): estimateSize as a function with ${count} items has O(n) ` +
3981
4287
  `per-frame cost. Consider using a fixed estimateSize for large datasets.`);
3982
4288
  }
3983
4289
  }
@@ -4016,14 +4322,15 @@ function injectRecycler(config) {
4016
4322
  // lead with velocity, capped at one viewport of items so a teleport jump
4017
4323
  // never expands the window unbounded. Trailing edge keeps the base overscan.
4018
4324
  const estimate = config.estimateSize;
4019
- 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);
4020
4327
  const itemsPerViewport = Math.max(1, Math.ceil(clientHeight / refPx));
4021
4328
  const velocity = scrollVelocity();
4022
4329
  const leadItems = Math.min(Math.ceil(Math.abs(velocity) / refPx), itemsPerViewport);
4023
4330
  const scrollingDown = velocity >= 0;
4024
4331
  const overscanBefore = overscan + (scrollingDown ? 0 : leadItems);
4025
4332
  const overscanAfter = overscan + (scrollingDown ? leadItems : 0);
4026
- return computeRange(scrollTop, clientHeight, total, size, overscanBefore, cols, overscanAfter);
4333
+ return computeRange(scrollTop, clientHeight, total, size, overscanBefore, cols, overscanAfter, itemsPerViewport);
4027
4334
  }, ...(ngDevMode ? [{ debugName: "range" }] : /* istanbul ignore next */ []));
4028
4335
  const start = computed(() => range().start, ...(ngDevMode ? [{ debugName: "start" }] : /* istanbul ignore next */ []));
4029
4336
  const end = computed(() => range().end, ...(ngDevMode ? [{ debugName: "end" }] : /* istanbul ignore next */ []));
@@ -4084,8 +4391,12 @@ function injectRecycler(config) {
4084
4391
  const state = config.state;
4085
4392
  const isLoading = computed(() => state?.isFirstLoad() ?? false, ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
4086
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));
4087
4398
  const isEmpty = computed(() => {
4088
- if (state?.isBusy()) {
4399
+ if (state?.isBusy() || showSkeleton()) {
4089
4400
  return false;
4090
4401
  }
4091
4402
  return config.totalCount() === 0;
@@ -4099,7 +4410,6 @@ function injectRecycler(config) {
4099
4410
  const itemHeight = typeof config.estimateSize === 'number' ? config.estimateSize : config.estimateSize(0);
4100
4411
  return Math.ceil(ch / itemHeight);
4101
4412
  }, ...(ngDevMode ? [{ debugName: "skeletonSlots" }] : /* istanbul ignore next */ []));
4102
- const showSkeleton = createVisibilityGate(isLoading, computed(() => config.skeletonDelay ?? 0), computed(() => 0));
4103
4413
  // previousTotal is a signal, not a mutable let - reactive, no stale-value risk.
4104
4414
  const announcementState = signal('', ...(ngDevMode ? [{ debugName: "announcementState" }] : /* istanbul ignore next */ []));
4105
4415
  const previousTotal = signal(config.totalCount(), ...(ngDevMode ? [{ debugName: "previousTotal" }] : /* istanbul ignore next */ []));
@@ -4199,14 +4509,18 @@ function injectRecycler(config) {
4199
4509
  if (!el) {
4200
4510
  return;
4201
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.
4202
4516
  const handleFocusIn = (e) => {
4203
4517
  const target = e.target.closest('[data-cngx-recycle-index]');
4204
4518
  if (target) {
4205
- focusedIndex.set(Number(target.getAttribute('data-cngx-recycle-index')));
4519
+ untracked(() => focusedIndex.set(Number(target.getAttribute('data-cngx-recycle-index'))));
4206
4520
  }
4207
4521
  };
4208
4522
  const handleFocusOut = () => {
4209
- focusedIndex.set(null);
4523
+ untracked(() => focusedIndex.set(null));
4210
4524
  };
4211
4525
  el.addEventListener('focusin', handleFocusIn);
4212
4526
  el.addEventListener('focusout', handleFocusOut);
@@ -4333,18 +4647,16 @@ function injectRecycler(config) {
4333
4647
  * }
4334
4648
  * ```
4335
4649
  *
4336
- * @category common/data/recycler
4337
- * @docsKind primary
4338
4650
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/measure.directive.ts
4339
- * @since 0.1.0
4651
+ * @since 0.3.0
4340
4652
  * @relatedTo CngxVirtualItem, CngxRecyclerAnnouncer, injectRecycler
4341
4653
  *
4342
- * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4343
- * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
4344
- * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
4345
- * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4346
- * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4347
- * <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>
4348
4660
  */
4349
4661
  class CngxMeasure {
4350
4662
  /** The recycler instance to report measurements to. */
@@ -4400,19 +4712,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4400
4712
  * }
4401
4713
  * ```
4402
4714
  *
4403
- * @category common/data/recycler
4404
- * @docsKind primary
4405
4715
  * @wcag AA
4406
4716
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/virtual-item.directive.ts
4407
- * @since 0.1.0
4717
+ * @since 0.3.0
4408
4718
  * @relatedTo CngxMeasure, CngxRecyclerAnnouncer, injectRecycler
4409
4719
  *
4410
- * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4411
- * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
4412
- * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
4413
- * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4414
- * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4415
- * <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>
4416
4726
  */
4417
4727
  class CngxVirtualItem {
4418
4728
  /** The recycler instance providing `ariaSetSize`. */
@@ -4486,13 +4796,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4486
4796
  * [style.height.px]="recycler.offsetBefore()"></div>
4487
4797
  * ```
4488
4798
  *
4489
- * @category common/data/recycler
4490
- * @docsKind primary
4491
4799
  * @wcag AA
4492
4800
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-placeholder.directive.ts
4493
- * @since 0.1.0
4801
+ * @since 0.3.0
4494
4802
  * @relatedTo injectRecycler, CngxRecyclerRow, CngxVirtualItem, CngxMeasure
4495
- * <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
4496
4805
  */
4497
4806
  class CngxRecyclerPlaceholder {
4498
4807
  /**
@@ -4558,15 +4867,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4558
4867
  * the cascade: microsyntax `placeholder:` template wins over this, and this wins
4559
4868
  * over the built-in imperative `<li>` default. Defaults to `null` (imperative
4560
4869
  * default applies).
4561
- *
4562
- * @category common/data/recycler
4563
4870
  */
4564
4871
  const CNGX_RECYCLER_PLACEHOLDER_ROW = new InjectionToken('CNGX_RECYCLER_PLACEHOLDER_ROW', { providedIn: 'root', factory: () => null });
4565
4872
  /**
4566
4873
  * Provides an app-wide default placeholder template for every `*cngxRecyclerRow`
4567
4874
  * that supplies no `placeholder:` template of its own.
4568
- *
4569
- * @category common/data/recycler
4570
4875
  */
4571
4876
  function provideRecyclerPlaceholderRow(template) {
4572
4877
  return { provide: CNGX_RECYCLER_PLACEHOLDER_ROW, useValue: template };
@@ -4622,13 +4927,12 @@ function provideRecyclerPlaceholderRow(template) {
4622
4927
  * </ul>
4623
4928
  * ```
4624
4929
  *
4625
- * @category common/data/recycler
4626
- * @docsKind primary
4627
4930
  * @wcag AA
4628
4931
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-row.directive.ts
4629
- * @since 0.1.0
4932
+ * @since 0.3.0
4630
4933
  * @relatedTo injectRecycler, CngxRecyclerPlaceholder, CngxVirtualItem, CngxMeasure
4631
- * <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
4632
4936
  */
4633
4937
  class CngxRecyclerRow {
4634
4938
  vcr = inject(ViewContainerRef);
@@ -4823,19 +5127,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4823
5127
  * <cngx-recycler-announcer [cngxRecyclerAnnouncer]="recycler" />
4824
5128
  * ```
4825
5129
  *
4826
- * @category common/data/recycler
4827
- * @docsKind primary
4828
5130
  * @wcag AA
4829
5131
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/recycler/recycler-announcer.component.ts
4830
- * @since 0.1.0
5132
+ * @since 0.3.0
4831
5133
  * @relatedTo CngxMeasure, CngxVirtualItem, injectRecycler, CNGX_RECYCLER_I18N
4832
5134
  *
4833
- * <example-url>http://localhost:4200/#/common/data/recycler/basic-list-fixed-item-height</example-url>
4834
- * <example-url>http://localhost:4200/#/common/data/recycler/content-visibility-css-only</example-url>
4835
- * <example-url>http://localhost:4200/#/common/data/recycler/infinite-scroll-recycler</example-url>
4836
- * <example-url>http://localhost:4200/#/common/data/recycler/scrolltoindex-deep-link</example-url>
4837
- * <example-url>http://localhost:4200/#/common/data/recycler/variable-heights-cngxmeasure</example-url>
4838
- * <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>
4839
5141
  */
4840
5142
  class CngxRecyclerAnnouncer {
4841
5143
  /** The recycler instance providing `announcement()`. */
@@ -4886,8 +5188,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
4886
5188
  * }
4887
5189
  * }
4888
5190
  * ```
4889
- *
4890
- * @category common/data/recycler
4891
5191
  */
4892
5192
  function connectRecyclerToRoving(recycler, roving) {
4893
5193
  const hostEl = inject(ElementRef).nativeElement;
@@ -4958,11 +5258,10 @@ function connectRecyclerToRoving(recycler, roving) {
4958
5258
  * When the AD directive navigates to an item whose index is not in the
4959
5259
  * recycler's rendered range, it sets `pendingHighlight` (via the
4960
5260
  * `virtualCount` path). This helper watches that signal and scrolls
4961
- * the recycler to the target index; AD's own effect observes the
4962
- * resulting DOM update and clears the pending state automatically
4963
- * (see the `pendingHighlightState.set(null)` branch in
4964
- * `CngxActiveDescendant` after a re-render brings the target into the
4965
- * 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.
4966
5265
  *
4967
5266
  * Unlike {@link /projects/common/data/src/recycler/connect-recycler-roving.ts
4968
5267
  * connectRecyclerToRoving}, we don't re-focus a DOM element after the
@@ -4990,8 +5289,6 @@ function connectRecyclerToRoving(recycler, roving) {
4990
5289
  * }
4991
5290
  * }
4992
5291
  * ```
4993
- *
4994
- * @category common/data/recycler
4995
5292
  */
4996
5293
  function connectRecyclerToActiveDescendant(recycler, ad) {
4997
5294
  // rAF-debounced: held ArrowDown otherwise enqueues one scroll per keystroke.
@@ -5027,21 +5324,46 @@ function connectRecyclerToActiveDescendant(recycler, ad) {
5027
5324
  *
5028
5325
  * Plain function, not a class - matches the rest of the repo
5029
5326
  * (`createManualState`, `createAsyncState`, `createTransitionTracker`).
5030
- * See `reference_api_prefix_convention.md`.
5031
- *
5032
- * @category common/data/commit
5327
+ * <example-url>/#/common/data/commit-controller/begin-supersede-cancel</example-url>
5033
5328
  */
5034
5329
  function createCommitController() {
5035
- // read-only `state` view; consumers can't flip status directly
5036
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
+ }
5037
5357
  // monotonic supersede id; stale callbacks compare captured id against this
5038
5358
  let commitId = 0;
5039
5359
  let active = null;
5040
5360
  // drives the pending spinner on the specific row the user clicked
5041
5361
  const intendedState = signal(undefined, ...(ngDevMode ? [{ debugName: "intendedState" }] : /* istanbul ignore next */ []));
5042
5362
  return {
5043
- state: slot,
5044
- isCommitting: computed(() => slot.isPending()),
5363
+ state,
5364
+ isCommitting: computed(() => slot.isPending(), typeof ngDevMode !== 'undefined' && ngDevMode
5365
+ ? { debugName: 'commitController.isCommitting' }
5366
+ : undefined),
5045
5367
  intendedValue: intendedState.asReadonly(),
5046
5368
  begin(runner, intended, previous, handlers) {
5047
5369
  // bump commitId BEFORE tearing down the previous runner: a runner that
@@ -5049,34 +5371,74 @@ function createCommitController() {
5049
5371
  // and fire its callbacks after all
5050
5372
  const id = ++commitId;
5051
5373
  active?.cancel();
5374
+ active = null;
5052
5375
  intendedState.set(intended);
5053
5376
  slot.set('pending');
5054
5377
  // A runner may settle synchronously, i.e. before its handle is even
5055
5378
  // returned. The settled flag keeps such a finished handle out of
5056
5379
  // `active`, so a later begin()/cancel() never calls cancel() on a
5057
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.
5058
5383
  let settled = false;
5059
- const handle = runner({
5060
- onSuccess: (committed) => {
5061
- if (id !== commitId) {
5062
- return;
5063
- }
5064
- settled = true;
5065
- slot.setSuccess(committed);
5066
- active = null;
5067
- handlers.onSuccess(committed);
5068
- },
5069
- onError: (err) => {
5070
- if (id !== commitId) {
5071
- return;
5072
- }
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) {
5073
5424
  settled = true;
5074
5425
  slot.setError(err);
5075
- active = null;
5076
5426
  handlers.onError(err, previous);
5077
- },
5078
- });
5079
- 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;
5080
5442
  },
5081
5443
  cancel(options) {
5082
5444
  // bump first: callbacks of a synchronously-cancelling runner must
@@ -5094,6 +5456,58 @@ function createCommitController() {
5094
5456
  };
5095
5457
  }
5096
5458
 
5459
+ /**
5460
+ * Live-region phrase for a refused commit-gated transition (a step
5461
+ * change or tab switch whose `commitAction` answered `false`).
5462
+ *
5463
+ * A refusal settles the commit status back to `'idle'`, so no status
5464
+ * edge can voice it. This phrase arms on each new refused outcome (a new
5465
+ * `sequence`) and is spent by the next commit status change, an
5466
+ * active-index move, a cleared outcome or, when given, a changed
5467
+ * `extraSpend` value. A failed outcome never arms it. Arm wins over
5468
+ * spend in the same flush, so an optimistic rollback that moves the
5469
+ * active index still voices the refusal.
5470
+ *
5471
+ * Built on {@link createAnnouncementPhrase}: fully derived, no `effect`.
5472
+ * The same eager-read caveat applies - read the phrase before branching
5473
+ * on another arm of the live announcement, otherwise a spend transition
5474
+ * can be skipped.
5475
+ *
5476
+ * ```ts
5477
+ * const refusedPhrase = createRefusedPhrase({
5478
+ * outcome: () => presenter.lastOutcome(),
5479
+ * status: () => presenter.commitTransition.current(),
5480
+ * activeIndex: () => presenter.activeIndex(),
5481
+ * copy: () => i18n().commitRefusedGeneric,
5482
+ * });
5483
+ * ```
5484
+ *
5485
+ * @wcag AA
5486
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/commit/refused-phrase.ts
5487
+ * @since 0.3.0
5488
+ * @relatedTo CngxTransitionOutcome, createAnnouncementPhrase
5489
+ */
5490
+ function createRefusedPhrase(options) {
5491
+ const { outcome, status, activeIndex, copy, extraSpend } = options;
5492
+ return createAnnouncementPhrase({
5493
+ source: () => {
5494
+ const current = outcome();
5495
+ return {
5496
+ sequence: current?.sequence,
5497
+ kind: current?.kind,
5498
+ status: status(),
5499
+ activeIndex: activeIndex(),
5500
+ extra: extraSpend?.(),
5501
+ };
5502
+ },
5503
+ arm: (curr, prev) => curr.kind === 'refused' && curr.sequence !== prev.sequence ? untracked(copy) : null,
5504
+ spend: (curr, prev) => curr.status !== prev.status ||
5505
+ curr.activeIndex !== prev.activeIndex ||
5506
+ curr.sequence === undefined ||
5507
+ curr.extra !== prev.extra,
5508
+ });
5509
+ }
5510
+
5097
5511
  /**
5098
5512
  * DI token carrying the factory that every cngx feature uses to
5099
5513
  * allocate its commit controller. Default `providedIn: 'root'`
@@ -5102,23 +5516,49 @@ function createCommitController() {
5102
5516
  *
5103
5517
  * Symmetrical to `CNGX_SELECT_COMMIT_CONTROLLER_FACTORY`
5104
5518
  * (`@cngx/forms/select`); the select-side token's default factory
5105
- * delegates to this one, so a single override here cascades into
5106
- * 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):
5107
5528
  *
5108
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
+ *
5109
5553
  * bootstrapApplication(App, {
5110
5554
  * providers: [
5111
- * {
5112
- * provide: CNGX_COMMIT_CONTROLLER_FACTORY,
5113
- * useValue: <T>() => createRetryingCommitController<T>({ attempts: 3 }),
5114
- * },
5555
+ * { provide: CNGX_COMMIT_CONTROLLER_FACTORY, useValue: createTimedCommitController },
5115
5556
  * ],
5116
5557
  * });
5117
5558
  * ```
5118
5559
  *
5119
- * @category common/data/commit
5120
5560
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/data/commit/commit-controller.token.ts
5121
- * @since 0.1.0
5561
+ * @since 0.3.0
5122
5562
  */
5123
5563
  const CNGX_COMMIT_CONTROLLER_FACTORY = new InjectionToken('CngxCommitControllerFactory', {
5124
5564
  providedIn: 'root',
@@ -5177,8 +5617,6 @@ const CNGX_COMMIT_CONTROLLER_FACTORY = new InjectionToken('CngxCommitControllerF
5177
5617
  * and ping-pong against the in-flight navigation (the demo freezes).
5178
5618
  * Matching the echo by the value we wrote drops it regardless of where
5179
5619
  * the presenter has moved.
5180
- *
5181
- * @category common/data/material-bridge
5182
5620
  */
5183
5621
  function createMaterialBidirectionalSync(opts) {
5184
5622
  const { presenterIndex, readSelectedIndex, writeSelectedIndex, selectionChange$, onMaterialSelection, injector, destroyRef, } = opts;
@@ -5238,12 +5676,12 @@ function createMaterialBidirectionalSync(opts) {
5238
5676
  }
5239
5677
 
5240
5678
  /**
5241
- * @module @cngx/common/data
5679
+ * @module `@cngx/common/data`
5242
5680
  */
5243
5681
 
5244
5682
  /**
5245
5683
  * Generated bundle index. Do not edit.
5246
5684
  */
5247
5685
 
5248
- export { CNGX_ASYNC_LABEL, CNGX_ASYNC_SKIP, CNGX_BUCKET_PAGINATE_HOST, CNGX_COMMIT_CONTROLLER_FACTORY, CNGX_KPI_I18N, CNGX_KPI_LANGUAGE_EN, CNGX_RECYCLER_I18N, CNGX_RECYCLER_LANGUAGE_EN, CNGX_RECYCLER_PLACEHOLDER_ROW, CNGX_STAT, CngxAsync, CngxAsyncBoundary, CngxAsyncRegistry, CngxBucketPaginate, CngxDataSource, CngxDelta, CngxFilter, CngxFilterChip, CngxFilterChips, CngxGoal, CngxMeasure, CngxMetric, CngxPaginate, CngxPaginateResetOn, CngxPaginateRouting, CngxRecyclerAnnouncer, CngxRecyclerPlaceholder, CngxRecyclerRow, CngxSmartDataSource, CngxSort, CngxSortHeader, CngxStat, CngxStatCaption, CngxStatCoordinator, CngxStatDelta, CngxStatLabel, CngxStatValue, CngxTrend, CngxVirtualItem, cngxAsyncInterceptor, connectPaginateEmit, connectPaginateResetOn, connectRecyclerToActiveDescendant, connectRecyclerToRoving, createAsyncState, createCommitController, createForwardedAsyncState, createManualState, createMaterialBidirectionalSync, createSortHeaderState, fromHttpResource, fromResource, injectAsyncRegistry, injectAsyncState, injectDataSource, injectKpiI18n, injectLatencyProbe, injectRecycler, injectSmartDataSource, provideAsyncHttpObservability, provideAsyncRegistry, provideKpiI18n, provideRecyclerI18n, provideRecyclerPlaceholderRow, resolveAsyncView, tapAsyncProgress, tapAsyncState, tapHttpAsyncState, withAsyncLabel, withAsyncSkip, withKpiI18nLabels, withRecyclerI18nLabels };
5686
+ export { CNGX_ASYNC_LABEL, CNGX_ASYNC_SKIP, CNGX_BUCKET_PAGINATE_HOST, CNGX_COMMIT_CONTROLLER_FACTORY, CNGX_KPI_I18N, CNGX_KPI_LANGUAGE_EN, CNGX_RECYCLER_I18N, CNGX_RECYCLER_LANGUAGE_EN, CNGX_RECYCLER_PLACEHOLDER_ROW, CNGX_STAT, CngxAsync, CngxAsyncBoundary, CngxAsyncRegistry, CngxBucketPaginate, CngxDataSource, CngxDelta, CngxFilter, CngxFilterChip, CngxFilterChips, CngxGoal, CngxMeasure, CngxMetric, CngxPaginate, CngxPaginateResetOn, CngxPaginateRouting, CngxRecyclerAnnouncer, CngxRecyclerPlaceholder, CngxRecyclerRow, CngxSmartDataSource, CngxSort, CngxSortHeader, CngxStat, CngxStatCaption, CngxStatCoordinator, CngxStatDelta, CngxStatLabel, CngxStatValue, CngxTrend, CngxVirtualItem, cngxAsyncInterceptor, connectPaginateEmit, connectPaginateResetOn, connectRecyclerToActiveDescendant, connectRecyclerToRoving, createAsyncState, createCommitController, createForwardedAsyncState, createManualState, createMaterialBidirectionalSync, createRefusedPhrase, createSortHeaderState, fromHttpResource, fromResource, injectAsyncRegistry, injectAsyncState, injectDataSource, injectKpiI18n, injectLatencyProbe, injectRecycler, injectSmartDataSource, provideAsyncHttpObservability, provideAsyncRegistry, provideKpiI18n, provideRecyclerI18n, provideRecyclerPlaceholderRow, resolveAsyncView, tapAsyncProgress, tapAsyncState, tapHttpAsyncState, withAsyncLabel, withAsyncSkip, withKpiI18nLabels, withRecyclerI18nLabels };
5249
5687
  //# sourceMappingURL=cngx-common-data.mjs.map