@cngx/ui 0.1.0-rc.6 → 0.1.0-rc.8

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 (102) hide show
  1. package/README.md +112 -1
  2. package/a11y/README.md +87 -0
  3. package/accordion/README.md +4 -2
  4. package/breadcrumb/README.md +262 -0
  5. package/collection/README.md +6 -0
  6. package/command-palette/README.md +224 -0
  7. package/context-menu/README.md +98 -0
  8. package/data-grid-accordion/README.md +103 -2
  9. package/feedback/README.md +42 -0
  10. package/fesm2022/cngx-ui-a11y.mjs +452 -0
  11. package/fesm2022/cngx-ui-a11y.mjs.map +1 -0
  12. package/fesm2022/cngx-ui-accordion.mjs +116 -38
  13. package/fesm2022/cngx-ui-accordion.mjs.map +1 -1
  14. package/fesm2022/cngx-ui-action-button.mjs +115 -50
  15. package/fesm2022/cngx-ui-action-button.mjs.map +1 -1
  16. package/fesm2022/cngx-ui-breadcrumb.mjs +181 -96
  17. package/fesm2022/cngx-ui-breadcrumb.mjs.map +1 -1
  18. package/fesm2022/cngx-ui-chart-panel.mjs +586 -0
  19. package/fesm2022/cngx-ui-chart-panel.mjs.map +1 -0
  20. package/fesm2022/cngx-ui-collection.mjs +207 -66
  21. package/fesm2022/cngx-ui-collection.mjs.map +1 -1
  22. package/fesm2022/cngx-ui-command-palette.mjs +1281 -0
  23. package/fesm2022/cngx-ui-command-palette.mjs.map +1 -0
  24. package/fesm2022/cngx-ui-context-menu.mjs +857 -0
  25. package/fesm2022/cngx-ui-context-menu.mjs.map +1 -0
  26. package/fesm2022/cngx-ui-data-grid-accordion.mjs +498 -111
  27. package/fesm2022/cngx-ui-data-grid-accordion.mjs.map +1 -1
  28. package/fesm2022/cngx-ui-empty-state.mjs +16 -6
  29. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -1
  30. package/fesm2022/cngx-ui-feedback.mjs +1095 -521
  31. package/fesm2022/cngx-ui-feedback.mjs.map +1 -1
  32. package/fesm2022/cngx-ui-layout.mjs +18 -9
  33. package/fesm2022/cngx-ui-layout.mjs.map +1 -1
  34. package/fesm2022/cngx-ui-mat-accordion.mjs +84 -16
  35. package/fesm2022/cngx-ui-mat-accordion.mjs.map +1 -1
  36. package/fesm2022/cngx-ui-mat-paginator.mjs +67 -24
  37. package/fesm2022/cngx-ui-mat-paginator.mjs.map +1 -1
  38. package/fesm2022/cngx-ui-mat-stepper.mjs +72 -47
  39. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -1
  40. package/fesm2022/cngx-ui-mat-tabs.mjs +370 -203
  41. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -1
  42. package/fesm2022/cngx-ui-overlay.mjs +69 -13
  43. package/fesm2022/cngx-ui-overlay.mjs.map +1 -1
  44. package/fesm2022/cngx-ui-paginator.mjs +501 -182
  45. package/fesm2022/cngx-ui-paginator.mjs.map +1 -1
  46. package/fesm2022/cngx-ui-sidenav.mjs +327 -106
  47. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -1
  48. package/fesm2022/cngx-ui-skeleton.mjs +22 -21
  49. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -1
  50. package/fesm2022/cngx-ui-speak.mjs +107 -8
  51. package/fesm2022/cngx-ui-speak.mjs.map +1 -1
  52. package/fesm2022/cngx-ui-stat-card.mjs +718 -0
  53. package/fesm2022/cngx-ui-stat-card.mjs.map +1 -0
  54. package/fesm2022/cngx-ui-stepper.mjs +217 -76
  55. package/fesm2022/cngx-ui-stepper.mjs.map +1 -1
  56. package/fesm2022/cngx-ui-tabs.mjs +40 -19
  57. package/fesm2022/cngx-ui-tabs.mjs.map +1 -1
  58. package/fesm2022/cngx-ui-timeline.mjs +548 -0
  59. package/fesm2022/cngx-ui-timeline.mjs.map +1 -0
  60. package/fesm2022/cngx-ui-toc.mjs +748 -0
  61. package/fesm2022/cngx-ui-toc.mjs.map +1 -0
  62. package/fesm2022/cngx-ui.mjs +16 -21
  63. package/fesm2022/cngx-ui.mjs.map +1 -1
  64. package/mat-accordion/README.md +1 -1
  65. package/mat-paginator/README.md +9 -2
  66. package/mat-tabs/styles/mat-tabs.css +29 -27
  67. package/overlay/README.md +9 -4
  68. package/package.json +32 -1
  69. package/paginator/README.md +8 -4
  70. package/sidenav/README.md +33 -11
  71. package/skeleton/README.md +2 -0
  72. package/speak/README.md +3 -2
  73. package/stepper/README.md +15 -3
  74. package/timeline/README.md +350 -0
  75. package/toc/README.md +186 -0
  76. package/types/cngx-ui-a11y.d.ts +394 -0
  77. package/types/cngx-ui-accordion.d.ts +100 -30
  78. package/types/cngx-ui-action-button.d.ts +47 -3
  79. package/types/cngx-ui-breadcrumb.d.ts +159 -58
  80. package/types/cngx-ui-chart-panel.d.ts +382 -0
  81. package/types/cngx-ui-collection.d.ts +159 -58
  82. package/types/cngx-ui-command-palette.d.ts +565 -0
  83. package/types/cngx-ui-context-menu.d.ts +559 -0
  84. package/types/cngx-ui-data-grid-accordion.d.ts +344 -51
  85. package/types/cngx-ui-empty-state.d.ts +9 -2
  86. package/types/cngx-ui-feedback.d.ts +664 -73
  87. package/types/cngx-ui-layout.d.ts +8 -3
  88. package/types/cngx-ui-mat-accordion.d.ts +32 -4
  89. package/types/cngx-ui-mat-paginator.d.ts +37 -8
  90. package/types/cngx-ui-mat-stepper.d.ts +23 -11
  91. package/types/cngx-ui-mat-tabs.d.ts +218 -23
  92. package/types/cngx-ui-overlay.d.ts +56 -10
  93. package/types/cngx-ui-paginator.d.ts +416 -132
  94. package/types/cngx-ui-sidenav.d.ts +248 -74
  95. package/types/cngx-ui-skeleton.d.ts +18 -7
  96. package/types/cngx-ui-speak.d.ts +118 -5
  97. package/types/cngx-ui-stat-card.d.ts +411 -0
  98. package/types/cngx-ui-stepper.d.ts +81 -29
  99. package/types/cngx-ui-tabs.d.ts +22 -6
  100. package/types/cngx-ui-timeline.d.ts +495 -0
  101. package/types/cngx-ui-toc.d.ts +581 -0
  102. package/types/cngx-ui.d.ts +8 -5
@@ -0,0 +1,718 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, inject, input, computed, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component, Directive, makeEnvironmentProviders } from '@angular/core';
3
+ import { CngxCard } from '@cngx/common/card';
4
+ import * as i1 from '@cngx/common/data';
5
+ import { CngxStatCoordinator, resolveAsyncView, CNGX_STAT } from '@cngx/common/data';
6
+ export { CNGX_STAT, CngxStatCaption, CngxStatDelta, CngxStatLabel, CngxStatValue } from '@cngx/common/data';
7
+ import { CngxSkeleton } from '@cngx/common/layout';
8
+ import { createFilledOverrideMerge, injectLoadingConfig, createLatencyProbe, resolveLoadingTreatment, createOverrideMerge } from '@cngx/core/utils';
9
+ import { CngxEmptyState } from '@cngx/ui/empty-state';
10
+ import { CngxLoadingIndicator } from '@cngx/ui/feedback';
11
+ import { createLanguageSection } from '@cngx/core/i18n';
12
+
13
+ /**
14
+ * The English stat-card section: the single source of the stat card's English
15
+ * copy. The `CNGX_STAT_CARD_CONFIG` labels default to it.
16
+ *
17
+ * @category ui/stat-card/i18n
18
+ * @since 0.1.0
19
+ * @relatedTo CNGX_STAT_CARD_CONFIG
20
+ */
21
+ const CNGX_STAT_CARD_LANGUAGE_EN = {
22
+ busy: 'Loading',
23
+ errorFallback: 'Could not load',
24
+ staleFallback: 'Showing last known value',
25
+ emptyFallback: 'No data',
26
+ };
27
+
28
+ /**
29
+ * @internal The stat-card section of the active pack over the English section,
30
+ * shared app-wide. Consumers override copy through `withStatCardAriaLabels`.
31
+ */
32
+ const injectStatCardSiteCopy = createLanguageSection('statCard', CNGX_STAT_CARD_LANGUAGE_EN);
33
+
34
+ /**
35
+ * Library defaults for the stat-card configuration cascade. Carries no copy:
36
+ * the `ariaLabels` defaults are the `statCard` section of the language pack;
37
+ * single keys ride the `withStatCardAriaLabels` feature.
38
+ *
39
+ * Exported for intra-lib consumers (`provideStatCardConfig` deep-merges with
40
+ * this base) but **NOT** re-exported from `public-api.ts` - downstream
41
+ * consumers reach the defaults via `inject(CNGX_STAT_CARD_CONFIG)` so
42
+ * `provideStatCardConfig` / `provideStatCardConfigAt` overrides take
43
+ * precedence.
44
+ *
45
+ * @internal
46
+ */
47
+ const CNGX_STAT_CARD_DEFAULTS = {
48
+ loadingTreatment: 'auto',
49
+ };
50
+ /**
51
+ * App-wide configuration cascade for the stat-card. Resolves in priority
52
+ * order:
53
+ *
54
+ * 1. Per-instance Input binding.
55
+ * 2. `provideStatCardConfigAt(...)` in a parent component's `viewProviders`.
56
+ * 3. `provideStatCardConfig(...)` at the application root.
57
+ * 4. Library defaults (this token's `factory`).
58
+ *
59
+ * `providedIn: 'root'` with a default factory means consumers never need to
60
+ * provide the token explicitly - `inject(CNGX_STAT_CARD_CONFIG)` always
61
+ * resolves.
62
+ *
63
+ * @category ui/stat-card
64
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/stat-card/config/stat-card.config.defaults.ts
65
+ * @since 0.1.0
66
+ * @relatedTo provideStatCardConfig, provideStatCardConfigAt, injectStatCardConfig
67
+ */
68
+ const CNGX_STAT_CARD_CONFIG = new InjectionToken('CNGX_STAT_CARD_CONFIG', {
69
+ providedIn: 'root',
70
+ factory: () => CNGX_STAT_CARD_DEFAULTS,
71
+ });
72
+
73
+ /**
74
+ * Convenience accessor for the stat-card configuration cascade. Runs in
75
+ * injection context; resolves through the priority chain (per-instance Input
76
+ * -> `provideStatCardConfigAt` -> `provideStatCardConfig` -> library
77
+ * defaults). Equivalent to `inject(CNGX_STAT_CARD_CONFIG)` - the helper exists
78
+ * so consumers don't import the token directly.
79
+ *
80
+ * ```ts
81
+ * export class CngxStatCard {
82
+ * private readonly cfg = injectStatCardConfig();
83
+ * readonly errorText = input<string>(this.cfg.ariaLabels?.errorFallback ?? 'Could not load');
84
+ * }
85
+ * ```
86
+ *
87
+ * @category ui/stat-card
88
+ * @since 0.1.0
89
+ */
90
+ function injectStatCardConfig() {
91
+ return inject(CNGX_STAT_CARD_CONFIG);
92
+ }
93
+ /**
94
+ * The resolved strings of the stat-card config in scope, every key the config
95
+ * leaves unset (also a key an override sets to `undefined`) filled from the
96
+ * `statCard` section of the active pack, as a Signal that follows a runtime
97
+ * language switch. Runs
98
+ * in injection context; read it inside a `computed()`, a template or a
99
+ * handler, and untracked where it builds live-region text.
100
+ *
101
+ * @category ui/stat-card
102
+ * @since 0.1.0
103
+ */
104
+ function injectStatCardAriaLabels() {
105
+ return createFilledOverrideMerge(injectStatCardSiteCopy(), injectStatCardConfig().ariaLabels);
106
+ }
107
+
108
+ /** Placeholder shape for a card whose consumer projected no stat slots at all. */
109
+ const DEFAULT_SKELETON_SLOTS = ['label', 'value', 'caption'];
110
+ /**
111
+ * Card-framed KPI tile: one `<cngx-stat-card>` renders a complete dashboard
112
+ * metric - card surface, coordinated stat slots, an inline visualisation, a
113
+ * footer, and the async view switch - from a single `[state]`.
114
+ *
115
+ * The stat slots are the existing `cngxStatLabel` / `cngxStatValue` /
116
+ * `cngxStatDelta` / `cngxStatCaption` atoms from `@cngx/common/data`, not
117
+ * copies. They resolve `CNGX_STAT` against their declaration site, so the card
118
+ * hosts the same {@link CngxStatCoordinator} brain `CngxStat` hosts and
119
+ * re-points the token at it - the shape `CngxIncrementalList` uses for
120
+ * `CNGX_PAGINATOR_HOST`. A screen reader therefore reads the tile as one
121
+ * phrase, not four fragments (Pillar 2).
122
+ *
123
+ * The view switch is a pure `computed()` off `[state]` via `resolveAsyncView`
124
+ * (Pillar 1) - there is no second state machine and no boolean fallback inputs.
125
+ *
126
+ * Like `cngx-chart`, the card does **not** provide `CNGX_STATEFUL`: the
127
+ * consumer already holds the state object it bound, so transition bridges take
128
+ * it directly, e.g. `<cngx-toast-on [state]="revenue" />`.
129
+ *
130
+ * ```html
131
+ * <cngx-stat-card [state]="revenue">
132
+ * <span cngxStatLabel>Revenue</span>
133
+ * <cngx-metric cngxStatValue [value]="1.2" unit="M EUR" />
134
+ * <cngx-delta cngxStatDelta [value]="5.3" />
135
+ * <span cngxStatCaption>vs. last quarter</span>
136
+ * <cngx-sparkline cngxStatCardViz [data]="trend()" />
137
+ * </cngx-stat-card>
138
+ * ```
139
+ *
140
+ * @category ui/stat-card
141
+ * @docsKind primary
142
+ * @wcag AA
143
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/stat-card/stat-card.component.ts
144
+ * @since 0.1.0
145
+ * @relatedTo CngxStat, CngxStatCoordinator, CngxStatCardViz, CngxStatCardFooter, CngxCard
146
+ *
147
+ * <example-url>http://localhost:4200/#/ui/stat-card/basic/composed-kpi-tile</example-url>
148
+ * <example-url>http://localhost:4200/#/ui/stat-card/async/latency-aware-loading</example-url>
149
+ * <example-url>http://localhost:4200/#/ui/stat-card/async/error-and-refresh</example-url>
150
+ */
151
+ class CngxStatCard {
152
+ /** @internal The shared slot-id brain, applied as a host directive. */
153
+ coordinator = inject(CngxStatCoordinator, { host: true });
154
+ config = injectStatCardConfig();
155
+ ariaLabels = injectStatCardAriaLabels();
156
+ /**
157
+ * The tile's async envelope. Every view decision derives from it; there are
158
+ * no discrete `loading` / `error` boolean fallbacks. Optional per the
159
+ * bridge-input rule, so `[state]` may be bound conditionally.
160
+ */
161
+ state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), transform: (v) => (typeof v === 'string' ? undefined : v) });
162
+ /**
163
+ * What the card shows while it loads. `'auto'` (default) picks from the
164
+ * latency the tile itself observed: a tile whose last load was quick shows a
165
+ * spinner blip, one whose last load dragged shows a skeleton. `'spinner'` and
166
+ * `'skeleton'` pin the choice.
167
+ */
168
+ loadingTreatment = input(this.config.loadingTreatment ?? 'auto', ...(ngDevMode ? [{ debugName: "loadingTreatment" }] : /* istanbul ignore next */ []));
169
+ /**
170
+ * Accessible label announced while the card is loading. Unbound
171
+ * (`undefined`), each copy input falls back to the config cascade and the
172
+ * `statCard` section of the language pack.
173
+ */
174
+ busyLabel = input(undefined, ...(ngDevMode ? [{ debugName: "busyLabel" }] : /* istanbul ignore next */ []));
175
+ /** Headline of the error state shown instead of the stat when the first load failed. */
176
+ errorText = input(undefined, ...(ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []));
177
+ /** Supporting detail under {@link errorText}. Omitted when unset. */
178
+ errorDescription = input(undefined, ...(ngDevMode ? [{ debugName: "errorDescription" }] : /* istanbul ignore next */ []));
179
+ /** Note appended below the stat when a refresh failed but stale data is still shown. */
180
+ staleText = input(undefined, ...(ngDevMode ? [{ debugName: "staleText" }] : /* istanbul ignore next */ []));
181
+ /** Headline of the empty state shown when a load settled with no data. */
182
+ emptyText = input(undefined, ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
183
+ /**
184
+ * Politeness of the tile's live region. `off` (default) for a static KPI;
185
+ * `polite` for a tile that refreshes on a timer, so the new figure is
186
+ * announced instead of changing silently. Mirrors `CngxStat.live`.
187
+ */
188
+ live = input('off', ...(ngDevMode ? [{ debugName: "live" }] : /* istanbul ignore next */ []));
189
+ /** @internal Whether any operation is running. Drives `aria-busy` (Pillar 2). */
190
+ busy = computed(() => this.state()?.isBusy() ?? false, ...(ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []));
191
+ /**
192
+ * @internal Which bars the placeholder draws. Mirrors the slots the consumer
193
+ * actually projected, so a tile without a delta gets no delta bar. Falls back
194
+ * to the common label / value / caption shape when nothing has registered -
195
+ * a card with no stat slots at all still needs a plausible placeholder.
196
+ */
197
+ skeletonSlots = computed(() => {
198
+ const present = this.coordinator.presentKinds();
199
+ return present.length > 0 ? present : DEFAULT_SKELETON_SLOTS;
200
+ }, ...(ngDevMode ? [{ debugName: "skeletonSlots" }] : /* istanbul ignore next */ []));
201
+ /**
202
+ * @internal A refresh over content the user can still read. The skeleton and
203
+ * spinner branches already carry their own busy signal, so the bar would be
204
+ * redundant there.
205
+ */
206
+ showRefreshIndicator = computed(() => this.busy() && this.activeView() !== 'skeleton', ...(ngDevMode ? [{ debugName: "showRefreshIndicator" }] : /* istanbul ignore next */ []));
207
+ loadingConfig = injectLoadingConfig();
208
+ /**
209
+ * Measures how long this tile's own busy windows last. The measurement is a
210
+ * wall-clock sample the probe writes from an effect; the selection below stays
211
+ * a pure `computed()`, so nothing in the reactive graph writes state.
212
+ */
213
+ probe = createLatencyProbe(() => this.busy());
214
+ /**
215
+ * Spinner or skeleton for the current load, from the observed latency and the
216
+ * cascaded cutoff. Never a hardcoded millisecond threshold - the cutoff always
217
+ * comes from `CNGX_LOADING_CONFIG`, so one `provideLoadingConfig(...)` retunes
218
+ * every tile in the app.
219
+ */
220
+ resolvedTreatment = computed(() => resolveLoadingTreatment(this.loadingTreatment(), this.probe.lastDuration(), this.loadingConfig.spinnerVsSkeletonCutoff), ...(ngDevMode ? [{ debugName: "resolvedTreatment" }] : /* istanbul ignore next */ []));
221
+ /**
222
+ * @internal The card element carries the accessible name, so the tile is one
223
+ * named region instead of an unnamed `article` wrapped around a named group.
224
+ * Null while the stat is not rendered: the slot ids live inside the content
225
+ * branch, and pointing at ids that are out of the DOM reads as unnamed anyway.
226
+ */
227
+ cardLabelledBy = computed(() => {
228
+ const view = this.activeView();
229
+ const showsStat = view === 'content' || view === 'content+error';
230
+ return showsStat ? this.coordinator.labelledBy() : null;
231
+ }, ...(ngDevMode ? [{ debugName: "cardLabelledBy" }] : /* istanbul ignore next */ []));
232
+ /**
233
+ * @internal Which body the card renders. Delegates to the shared
234
+ * `resolveAsyncView` lookup table so the tile cannot drift from every other
235
+ * async surface. Without a bound `[state]` the card always shows its content.
236
+ */
237
+ activeView = computed(() => {
238
+ const s = this.state();
239
+ if (!s) {
240
+ return 'content';
241
+ }
242
+ const view = resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
243
+ // A non-first-load busy phase over an empty tile resolves to content in
244
+ // the lookup table - blank metric slots posing as a figure. A load with
245
+ // nothing on screen is a load (same correction the timeline applies).
246
+ if (view === 'content' && s.isEmpty() && s.isBusy()) {
247
+ return 'skeleton';
248
+ }
249
+ return view;
250
+ }, ...(ngDevMode ? [{ debugName: "activeView" }] : /* istanbul ignore next */ []));
251
+ resolvedBusyLabel = computed(() => {
252
+ this.trackPhase();
253
+ return this.busyLabel() ?? untracked(() => this.ariaLabels().busy);
254
+ }, ...(ngDevMode ? [{ debugName: "resolvedBusyLabel" }] : /* istanbul ignore next */ []));
255
+ resolvedErrorText = computed(() => {
256
+ this.trackPhase();
257
+ return this.errorText() ?? untracked(() => this.ariaLabels().errorFallback);
258
+ }, ...(ngDevMode ? [{ debugName: "resolvedErrorText" }] : /* istanbul ignore next */ []));
259
+ resolvedErrorDescription = computed(() => {
260
+ this.trackPhase();
261
+ return this.errorDescription() ?? untracked(() => this.ariaLabels().errorDescription);
262
+ }, ...(ngDevMode ? [{ debugName: "resolvedErrorDescription" }] : /* istanbul ignore next */ []));
263
+ resolvedStaleText = computed(() => {
264
+ this.trackPhase();
265
+ return this.staleText() ?? untracked(() => this.ariaLabels().staleFallback);
266
+ }, ...(ngDevMode ? [{ debugName: "resolvedStaleText" }] : /* istanbul ignore next */ []));
267
+ resolvedEmptyText = computed(() => {
268
+ this.trackPhase();
269
+ return this.emptyText() ?? untracked(() => this.ariaLabels().emptyFallback);
270
+ }, ...(ngDevMode ? [{ debugName: "resolvedEmptyText" }] : /* istanbul ignore next */ []));
271
+ /**
272
+ * Keys the untracked cascade reads above on the view and busy phase, read
273
+ * straight from the signals the template polls (so a phase that returns to an
274
+ * earlier value still re-reads). The whole card can be a live region, so a
275
+ * language switch must not re-render its text; the next view or busy change
276
+ * speaks the new language. A bound input stays tracked.
277
+ */
278
+ trackPhase() {
279
+ this.activeView();
280
+ this.busy();
281
+ }
282
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStatCard, deps: [], target: i0.ɵɵFactoryTarget.Component });
283
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxStatCard, isStandalone: true, selector: "cngx-stat-card", inputs: { state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, loadingTreatment: { classPropertyName: "loadingTreatment", publicName: "loadingTreatment", isSignal: true, isRequired: false, transformFunction: null }, busyLabel: { classPropertyName: "busyLabel", publicName: "busyLabel", isSignal: true, isRequired: false, transformFunction: null }, errorText: { classPropertyName: "errorText", publicName: "errorText", isSignal: true, isRequired: false, transformFunction: null }, errorDescription: { classPropertyName: "errorDescription", publicName: "errorDescription", isSignal: true, isRequired: false, transformFunction: null }, staleText: { classPropertyName: "staleText", publicName: "staleText", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null }, live: { classPropertyName: "live", publicName: "live", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-busy": "busy() || null", "class.cngx-stat-card--busy": "busy()" }, classAttribute: "cngx-stat-card" }, providers: [{ provide: CNGX_STAT, useExisting: CngxStatCoordinator }], hostDirectives: [{ directive: i1.CngxStatCoordinator }], ngImport: i0, template: `
284
+ <cngx-card
285
+ [attr.aria-labelledby]="cardLabelledBy()"
286
+ [attr.aria-live]="live() === 'off' ? null : live()"
287
+ >
288
+ <!-- A refresh over existing content would otherwise be invisible: the view
289
+ stays 'content' and only aria-busy flips, which says nothing to a
290
+ sighted user. The indicator is absolutely placed and the figure only
291
+ dims, so the tile never reflows while refreshing - a dashboard grid
292
+ would otherwise twitch on every poll. It carries the loading config's
293
+ show-delay and min-dwell, so a fast refresh never flashes. -->
294
+ @if (showRefreshIndicator()) {
295
+ <cngx-loading-indicator
296
+ class="cngx-stat-card__refresh"
297
+ [loading]="true"
298
+ variant="spinner"
299
+ [label]="resolvedBusyLabel()"
300
+ />
301
+ }
302
+
303
+ @switch (activeView()) {
304
+ @case ('skeleton') {
305
+ @if (resolvedTreatment() === 'skeleton') {
306
+ <!-- Same container and same row structure as the content branch, so
307
+ each bar sits exactly where its text will, and the swap to
308
+ content does not resize the tile. -->
309
+ <div
310
+ class="cngx-stat-card__stat cngx-stat-card__stat--skeleton"
311
+ [cngxSkeleton]="true"
312
+ aria-hidden="true"
313
+ >
314
+ @if (skeletonSlots().includes('label')) {
315
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--label">
316
+ </span>
317
+ }
318
+ <div class="cngx-stat-card__row">
319
+ @if (skeletonSlots().includes('value')) {
320
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--value">
321
+ </span>
322
+ }
323
+ @if (skeletonSlots().includes('delta')) {
324
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--delta">
325
+ </span>
326
+ }
327
+ </div>
328
+ @if (skeletonSlots().includes('caption')) {
329
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--caption">
330
+ </span>
331
+ }
332
+ </div>
333
+ } @else {
334
+ <div class="cngx-stat-card__spinner">
335
+ <cngx-loading-indicator [loading]="true" variant="spinner" [label]="resolvedBusyLabel()" />
336
+ </div>
337
+ }
338
+ }
339
+ @case ('error') {
340
+ <cngx-empty-state
341
+ class="cngx-stat-card__error"
342
+ [title]="resolvedErrorText()"
343
+ [description]="resolvedErrorDescription()"
344
+ >
345
+ <!-- The stock empty-state glyph is an archive box, which reads
346
+ "nothing here" rather than "this failed". Projecting into the
347
+ icon slot hides it. Decorative: the title carries the message. -->
348
+ <svg
349
+ cngxEmptyStateIcon
350
+ class="cngx-stat-card__error-icon"
351
+ aria-hidden="true"
352
+ viewBox="0 0 24 24"
353
+ fill="none"
354
+ stroke="currentColor"
355
+ stroke-width="1.5"
356
+ stroke-linecap="round"
357
+ stroke-linejoin="round"
358
+ >
359
+ <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
360
+ <path d="M12 9v4" />
361
+ <path d="M12 17h.01" />
362
+ </svg>
363
+ </cngx-empty-state>
364
+ }
365
+ @case ('empty') {
366
+ <!-- A settle with no data is its own message, not blank metric
367
+ slots pretending to be a figure. -->
368
+ <cngx-empty-state class="cngx-stat-card__empty" [title]="resolvedEmptyText()" />
369
+ }
370
+ @case ('none') {
371
+ <!-- Idle first load: nothing was asked for yet, so the tile shows
372
+ nothing - projected slots over absent data would read as a
373
+ real (blank) figure. -->
374
+ }
375
+ @default {
376
+ <div class="cngx-stat-card__stat">
377
+ <ng-content select="[cngxStatLabel]" />
378
+ <div class="cngx-stat-card__row">
379
+ <ng-content select="[cngxStatValue]" />
380
+ <ng-content select="[cngxStatDelta]" />
381
+ </div>
382
+ <ng-content select="[cngxStatCaption]" />
383
+ </div>
384
+
385
+ <ng-content select="[cngxStatCardViz]" />
386
+
387
+ @if (activeView() === 'content+error') {
388
+ <p class="cngx-stat-card__stale">{{ resolvedStaleText() }}</p>
389
+ }
390
+ }
391
+ }
392
+
393
+ <ng-content select="[cngxStatCardFooter]" />
394
+ </cngx-card>
395
+ `, isInline: true, styles: ["@layer cngx.tokens{.cngx-stat-card{display:block;position:relative;--cngx-stat-card-gap: var(--cngx-space-sm, .5rem);--cngx-stat-card-row-gap: var(--cngx-space-xs, .25rem);--cngx-stat-card-viz-margin: var(--cngx-space-sm, .5rem);--cngx-stat-card-footer-padding: var(--cngx-space-xs, .25rem);--cngx-stat-card-refresh-inset: var(--cngx-space-sm, .5rem);--cngx-stat-card-body-min-height: 6rem}}@layer cngx.components{@scope(.cngx-stat-card){.cngx-stat-card__stat,.cngx-stat-card__spinner,.cngx-stat-card__error,.cngx-stat-card__empty{min-block-size:var(--cngx-stat-card-body-min-height)}.cngx-stat-card__stat{display:flex;flex-direction:column;justify-content:center;gap:var(--cngx-stat-card-gap)}.cngx-stat-card__row{display:flex;align-items:baseline;gap:var(--cngx-stat-card-row-gap);flex-wrap:wrap}.cngx-stat-card__viz{display:block;margin-block-start:var(--cngx-stat-card-viz-margin)}.cngx-stat-card__footer{display:flex;align-items:center;gap:var(--cngx-stat-card-row-gap);padding-block-start:var(--cngx-stat-card-footer-padding);font-size:var(--cngx-stat-card-footer-size, .8125rem);color:var(--cngx-stat-card-footer-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}.cngx-stat-card__footer .cngx-card-timestamp{font-size:inherit;color:inherit}.cngx-stat-card__error.cngx-empty-state,.cngx-stat-card__empty.cngx-empty-state{--cngx-empty-padding: 0px;--cngx-empty-gap: var(--cngx-space-xs, .25rem);--cngx-empty-title-size: var(--cngx-stat-card-error-title-size, .9375rem);display:flex;flex-direction:column;justify-content:center;text-align:center}.cngx-stat-card__error.cngx-empty-state{color:var(--cngx-stat-card-error-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-stat-card__error .cngx-empty-state__title{color:inherit}.cngx-stat-card__error-icon{inline-size:var(--cngx-stat-card-error-icon-size, 22px);block-size:var(--cngx-stat-card-error-icon-size, 22px)}.cngx-stat-card__refresh{position:absolute;inset-block-start:var(--cngx-stat-card-refresh-inset);inset-inline-end:var(--cngx-stat-card-refresh-inset);pointer-events:none}.cngx-stat-card__refresh .cngx-loading-indicator__spinner{--cngx-loading-indicator-size: var(--cngx-stat-card-refresh-size, 14px)}.cngx-stat-card__stale{display:flex;align-items:center;gap:var(--cngx-stat-card-row-gap);margin:0;margin-block-start:var(--cngx-stat-card-row-gap);font-size:var(--cngx-stat-card-stale-size, .8125rem);color:var(--cngx-stat-card-stale-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-stat-card__stale:before{content:\"!\" / \"\";flex:none;display:grid;place-items:center;inline-size:var(--cngx-stat-card-stale-glyph-size, 1rem);block-size:var(--cngx-stat-card-stale-glyph-size, 1rem);border-radius:50%;font-size:var(--cngx-stat-card-stale-glyph-font-size, .75rem);font-weight:700;line-height:1;color:var(--cngx-stat-card-stale-glyph-color, var(--cngx-color-surface, oklch(1 0 0)));background:var(--cngx-stat-card-stale-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-stat-card__spinner{display:flex;align-items:center;justify-content:center}.cngx-stat-card__skeleton-line{--cngx-stat-card-skeleton-base: var( --cngx-stat-card-skeleton-color, var(--cngx-skeleton-bg, var(--cngx-color-border, oklch(.88 .005 250))) );display:block;border-radius:var(--cngx-stat-card-skeleton-radius, var(--cngx-radius-sm, 6px));background:var(--cngx-stat-card-skeleton-base)}.cngx-stat-card__stat--skeleton.cngx-skeleton--shimmer .cngx-stat-card__skeleton-line{background-image:linear-gradient(90deg,var(--cngx-stat-card-skeleton-base) 0%,var( --cngx-skeleton-shimmer-color, color-mix(in oklch, var(--cngx-stat-card-skeleton-base), white 18%) ) 50%,var(--cngx-stat-card-skeleton-base) 100%);background-size:200% 100%;animation:cngx-stat-card-shimmer var(--cngx-skeleton-shimmer-duration, 1.5s) ease-in-out infinite}.cngx-stat-card__skeleton-line--label{inline-size:var(--cngx-stat-card-skeleton-label-width, 45%);block-size:1lh}.cngx-stat-card__skeleton-line--value{inline-size:var(--cngx-stat-card-skeleton-value-width, 55%);font-size:var(--cngx-metric-value-size, 1.75rem);line-height:1.2;block-size:1lh}.cngx-stat-card__skeleton-line--delta{inline-size:var(--cngx-stat-card-skeleton-delta-width, 3rem);block-size:1lh}.cngx-stat-card__skeleton-line--caption{inline-size:var(--cngx-stat-card-skeleton-caption-width, 65%);block-size:1lh}}}@keyframes cngx-stat-card-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}\n"], dependencies: [{ kind: "component", type: CngxCard, selector: "cngx-card", inputs: ["as", "href", "role", "ariaLabel", "selected", "selectable", "loading", "disabled", "disabledReason"], outputs: ["selectedChange", "clicked"] }, { kind: "directive", type: CngxSkeleton, selector: "[cngxSkeleton]", inputs: ["cngxSkeleton", "shimmer", "count"], exportAs: ["cngxSkeleton"] }, { kind: "component", type: CngxLoadingIndicator, selector: "cngx-loading-indicator", inputs: ["state", "loading", "variant", "label", "delay", "minDwell", "minDuration"] }, { kind: "component", type: CngxEmptyState, selector: "cngx-empty-state", inputs: ["title", "description", "state"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
396
+ }
397
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStatCard, decorators: [{
398
+ type: Component,
399
+ args: [{ selector: 'cngx-stat-card', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CngxCard, CngxSkeleton, CngxLoadingIndicator, CngxEmptyState], hostDirectives: [CngxStatCoordinator], providers: [{ provide: CNGX_STAT, useExisting: CngxStatCoordinator }], host: {
400
+ class: 'cngx-stat-card',
401
+ '[attr.aria-busy]': 'busy() || null',
402
+ '[class.cngx-stat-card--busy]': 'busy()',
403
+ }, template: `
404
+ <cngx-card
405
+ [attr.aria-labelledby]="cardLabelledBy()"
406
+ [attr.aria-live]="live() === 'off' ? null : live()"
407
+ >
408
+ <!-- A refresh over existing content would otherwise be invisible: the view
409
+ stays 'content' and only aria-busy flips, which says nothing to a
410
+ sighted user. The indicator is absolutely placed and the figure only
411
+ dims, so the tile never reflows while refreshing - a dashboard grid
412
+ would otherwise twitch on every poll. It carries the loading config's
413
+ show-delay and min-dwell, so a fast refresh never flashes. -->
414
+ @if (showRefreshIndicator()) {
415
+ <cngx-loading-indicator
416
+ class="cngx-stat-card__refresh"
417
+ [loading]="true"
418
+ variant="spinner"
419
+ [label]="resolvedBusyLabel()"
420
+ />
421
+ }
422
+
423
+ @switch (activeView()) {
424
+ @case ('skeleton') {
425
+ @if (resolvedTreatment() === 'skeleton') {
426
+ <!-- Same container and same row structure as the content branch, so
427
+ each bar sits exactly where its text will, and the swap to
428
+ content does not resize the tile. -->
429
+ <div
430
+ class="cngx-stat-card__stat cngx-stat-card__stat--skeleton"
431
+ [cngxSkeleton]="true"
432
+ aria-hidden="true"
433
+ >
434
+ @if (skeletonSlots().includes('label')) {
435
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--label">
436
+ </span>
437
+ }
438
+ <div class="cngx-stat-card__row">
439
+ @if (skeletonSlots().includes('value')) {
440
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--value">
441
+ </span>
442
+ }
443
+ @if (skeletonSlots().includes('delta')) {
444
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--delta">
445
+ </span>
446
+ }
447
+ </div>
448
+ @if (skeletonSlots().includes('caption')) {
449
+ <span class="cngx-stat-card__skeleton-line cngx-stat-card__skeleton-line--caption">
450
+ </span>
451
+ }
452
+ </div>
453
+ } @else {
454
+ <div class="cngx-stat-card__spinner">
455
+ <cngx-loading-indicator [loading]="true" variant="spinner" [label]="resolvedBusyLabel()" />
456
+ </div>
457
+ }
458
+ }
459
+ @case ('error') {
460
+ <cngx-empty-state
461
+ class="cngx-stat-card__error"
462
+ [title]="resolvedErrorText()"
463
+ [description]="resolvedErrorDescription()"
464
+ >
465
+ <!-- The stock empty-state glyph is an archive box, which reads
466
+ "nothing here" rather than "this failed". Projecting into the
467
+ icon slot hides it. Decorative: the title carries the message. -->
468
+ <svg
469
+ cngxEmptyStateIcon
470
+ class="cngx-stat-card__error-icon"
471
+ aria-hidden="true"
472
+ viewBox="0 0 24 24"
473
+ fill="none"
474
+ stroke="currentColor"
475
+ stroke-width="1.5"
476
+ stroke-linecap="round"
477
+ stroke-linejoin="round"
478
+ >
479
+ <path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" />
480
+ <path d="M12 9v4" />
481
+ <path d="M12 17h.01" />
482
+ </svg>
483
+ </cngx-empty-state>
484
+ }
485
+ @case ('empty') {
486
+ <!-- A settle with no data is its own message, not blank metric
487
+ slots pretending to be a figure. -->
488
+ <cngx-empty-state class="cngx-stat-card__empty" [title]="resolvedEmptyText()" />
489
+ }
490
+ @case ('none') {
491
+ <!-- Idle first load: nothing was asked for yet, so the tile shows
492
+ nothing - projected slots over absent data would read as a
493
+ real (blank) figure. -->
494
+ }
495
+ @default {
496
+ <div class="cngx-stat-card__stat">
497
+ <ng-content select="[cngxStatLabel]" />
498
+ <div class="cngx-stat-card__row">
499
+ <ng-content select="[cngxStatValue]" />
500
+ <ng-content select="[cngxStatDelta]" />
501
+ </div>
502
+ <ng-content select="[cngxStatCaption]" />
503
+ </div>
504
+
505
+ <ng-content select="[cngxStatCardViz]" />
506
+
507
+ @if (activeView() === 'content+error') {
508
+ <p class="cngx-stat-card__stale">{{ resolvedStaleText() }}</p>
509
+ }
510
+ }
511
+ }
512
+
513
+ <ng-content select="[cngxStatCardFooter]" />
514
+ </cngx-card>
515
+ `, styles: ["@layer cngx.tokens{.cngx-stat-card{display:block;position:relative;--cngx-stat-card-gap: var(--cngx-space-sm, .5rem);--cngx-stat-card-row-gap: var(--cngx-space-xs, .25rem);--cngx-stat-card-viz-margin: var(--cngx-space-sm, .5rem);--cngx-stat-card-footer-padding: var(--cngx-space-xs, .25rem);--cngx-stat-card-refresh-inset: var(--cngx-space-sm, .5rem);--cngx-stat-card-body-min-height: 6rem}}@layer cngx.components{@scope(.cngx-stat-card){.cngx-stat-card__stat,.cngx-stat-card__spinner,.cngx-stat-card__error,.cngx-stat-card__empty{min-block-size:var(--cngx-stat-card-body-min-height)}.cngx-stat-card__stat{display:flex;flex-direction:column;justify-content:center;gap:var(--cngx-stat-card-gap)}.cngx-stat-card__row{display:flex;align-items:baseline;gap:var(--cngx-stat-card-row-gap);flex-wrap:wrap}.cngx-stat-card__viz{display:block;margin-block-start:var(--cngx-stat-card-viz-margin)}.cngx-stat-card__footer{display:flex;align-items:center;gap:var(--cngx-stat-card-row-gap);padding-block-start:var(--cngx-stat-card-footer-padding);font-size:var(--cngx-stat-card-footer-size, .8125rem);color:var(--cngx-stat-card-footer-color, var(--cngx-color-text-muted, oklch(.5 .01 250)))}.cngx-stat-card__footer .cngx-card-timestamp{font-size:inherit;color:inherit}.cngx-stat-card__error.cngx-empty-state,.cngx-stat-card__empty.cngx-empty-state{--cngx-empty-padding: 0px;--cngx-empty-gap: var(--cngx-space-xs, .25rem);--cngx-empty-title-size: var(--cngx-stat-card-error-title-size, .9375rem);display:flex;flex-direction:column;justify-content:center;text-align:center}.cngx-stat-card__error.cngx-empty-state{color:var(--cngx-stat-card-error-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-stat-card__error .cngx-empty-state__title{color:inherit}.cngx-stat-card__error-icon{inline-size:var(--cngx-stat-card-error-icon-size, 22px);block-size:var(--cngx-stat-card-error-icon-size, 22px)}.cngx-stat-card__refresh{position:absolute;inset-block-start:var(--cngx-stat-card-refresh-inset);inset-inline-end:var(--cngx-stat-card-refresh-inset);pointer-events:none}.cngx-stat-card__refresh .cngx-loading-indicator__spinner{--cngx-loading-indicator-size: var(--cngx-stat-card-refresh-size, 14px)}.cngx-stat-card__stale{display:flex;align-items:center;gap:var(--cngx-stat-card-row-gap);margin:0;margin-block-start:var(--cngx-stat-card-row-gap);font-size:var(--cngx-stat-card-stale-size, .8125rem);color:var(--cngx-stat-card-stale-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-stat-card__stale:before{content:\"!\" / \"\";flex:none;display:grid;place-items:center;inline-size:var(--cngx-stat-card-stale-glyph-size, 1rem);block-size:var(--cngx-stat-card-stale-glyph-size, 1rem);border-radius:50%;font-size:var(--cngx-stat-card-stale-glyph-font-size, .75rem);font-weight:700;line-height:1;color:var(--cngx-stat-card-stale-glyph-color, var(--cngx-color-surface, oklch(1 0 0)));background:var(--cngx-stat-card-stale-color, var(--cngx-color-danger, oklch(.6 .18 25)))}.cngx-stat-card__spinner{display:flex;align-items:center;justify-content:center}.cngx-stat-card__skeleton-line{--cngx-stat-card-skeleton-base: var( --cngx-stat-card-skeleton-color, var(--cngx-skeleton-bg, var(--cngx-color-border, oklch(.88 .005 250))) );display:block;border-radius:var(--cngx-stat-card-skeleton-radius, var(--cngx-radius-sm, 6px));background:var(--cngx-stat-card-skeleton-base)}.cngx-stat-card__stat--skeleton.cngx-skeleton--shimmer .cngx-stat-card__skeleton-line{background-image:linear-gradient(90deg,var(--cngx-stat-card-skeleton-base) 0%,var( --cngx-skeleton-shimmer-color, color-mix(in oklch, var(--cngx-stat-card-skeleton-base), white 18%) ) 50%,var(--cngx-stat-card-skeleton-base) 100%);background-size:200% 100%;animation:cngx-stat-card-shimmer var(--cngx-skeleton-shimmer-duration, 1.5s) ease-in-out infinite}.cngx-stat-card__skeleton-line--label{inline-size:var(--cngx-stat-card-skeleton-label-width, 45%);block-size:1lh}.cngx-stat-card__skeleton-line--value{inline-size:var(--cngx-stat-card-skeleton-value-width, 55%);font-size:var(--cngx-metric-value-size, 1.75rem);line-height:1.2;block-size:1lh}.cngx-stat-card__skeleton-line--delta{inline-size:var(--cngx-stat-card-skeleton-delta-width, 3rem);block-size:1lh}.cngx-stat-card__skeleton-line--caption{inline-size:var(--cngx-stat-card-skeleton-caption-width, 65%);block-size:1lh}}}@keyframes cngx-stat-card-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}\n"] }]
516
+ }], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], loadingTreatment: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingTreatment", required: false }] }], busyLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "busyLabel", required: false }] }], errorText: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorText", required: false }] }], errorDescription: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorDescription", required: false }] }], staleText: [{ type: i0.Input, args: [{ isSignal: true, alias: "staleText", required: false }] }], emptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyText", required: false }] }], live: [{ type: i0.Input, args: [{ isSignal: true, alias: "live", required: false }] }] } });
517
+
518
+ /**
519
+ * Marks the inline visualisation of a {@link CngxStatCard} - a `cngx-sparkline`,
520
+ * `cngx-mini-area`, `cngx-deviation-bar`, or any other compact chart preset.
521
+ *
522
+ * Rendered beside the stat block and outside its `aria-labelledby` chain: the
523
+ * accessible name stays the numbers a screen reader can actually read, while
524
+ * the viz stays decorative unless the projected preset carries its own
525
+ * accessible name.
526
+ *
527
+ * @category ui/stat-card
528
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/stat-card/stat-card-slots.ts
529
+ * @since 0.1.0
530
+ * @relatedTo CngxStatCard, CngxStatCardFooter
531
+ */
532
+ class CngxStatCardViz {
533
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStatCardViz, deps: [], target: i0.ɵɵFactoryTarget.Directive });
534
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxStatCardViz, isStandalone: true, selector: "[cngxStatCardViz]", host: { classAttribute: "cngx-stat-card__viz" }, ngImport: i0 });
535
+ }
536
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStatCardViz, decorators: [{
537
+ type: Directive,
538
+ args: [{
539
+ selector: '[cngxStatCardViz]',
540
+ standalone: true,
541
+ host: { class: 'cngx-stat-card__viz' },
542
+ }]
543
+ }] });
544
+ /**
545
+ * Marks the footer row of a {@link CngxStatCard} - a timestamp, a drill-down
546
+ * link, a `cngx-tag` row. Rendered below the stat block and the viz slot.
547
+ *
548
+ * @category ui/stat-card
549
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/ui/stat-card/stat-card-slots.ts
550
+ * @since 0.1.0
551
+ * @relatedTo CngxStatCard, CngxStatCardViz
552
+ */
553
+ class CngxStatCardFooter {
554
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStatCardFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
555
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxStatCardFooter, isStandalone: true, selector: "[cngxStatCardFooter]", host: { classAttribute: "cngx-stat-card__footer" }, ngImport: i0 });
556
+ }
557
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxStatCardFooter, decorators: [{
558
+ type: Directive,
559
+ args: [{
560
+ selector: '[cngxStatCardFooter]',
561
+ standalone: true,
562
+ host: { class: 'cngx-stat-card__footer' },
563
+ }]
564
+ }] });
565
+
566
+ const NO_ARIA_LABELS = {};
567
+ /**
568
+ * Reduces a list of feature objects into a partial config - last write wins
569
+ * per sub-tree. Inner objects are spread-merged so partial overrides compose
570
+ * cleanly with prior writes.
571
+ *
572
+ * @internal
573
+ */
574
+ function reduceFeatures(features) {
575
+ const out = {};
576
+ for (const f of features) {
577
+ switch (f.kind) {
578
+ case 'ariaLabels':
579
+ out.ariaLabels = createOverrideMerge(out.ariaLabels ?? NO_ARIA_LABELS, f.payload);
580
+ break;
581
+ case 'loadingTreatment':
582
+ out.loadingTreatment = f.payload.loadingTreatment;
583
+ break;
584
+ }
585
+ }
586
+ return out;
587
+ }
588
+ /**
589
+ * Two-level deep merge: the nested `ariaLabels` sub-tree is spread-merged so a
590
+ * partial fills in missing keys without nuking the rest; the flat top-level
591
+ * scalar `loadingTreatment` takes the partial when present, else the base.
592
+ *
593
+ * @internal
594
+ */
595
+ function mergeConfig(base, partial) {
596
+ return {
597
+ ariaLabels: createOverrideMerge(base.ariaLabels ?? NO_ARIA_LABELS, partial.ariaLabels),
598
+ loadingTreatment: partial.loadingTreatment ?? base.loadingTreatment,
599
+ };
600
+ }
601
+ /**
602
+ * Application-root configuration cascade for the stat-card. Pass any
603
+ * combination of `withStatCardAriaLabels` and `withStatCardLoadingTreatment`
604
+ * in `bootstrapApplication`'s providers array.
605
+ *
606
+ * ```ts
607
+ * bootstrapApplication(AppComponent, {
608
+ * providers: [
609
+ * provideStatCardConfig(
610
+ * withStatCardAriaLabels({ errorFallback: 'Kennzahl nicht verfügbar' }),
611
+ * withStatCardLoadingTreatment('skeleton'),
612
+ * ),
613
+ * ],
614
+ * });
615
+ * ```
616
+ *
617
+ * @category ui/stat-card
618
+ * @since 0.1.0
619
+ */
620
+ function provideStatCardConfig(...features) {
621
+ // Empty-features: skip the override so the root factory's
622
+ // CNGX_STAT_CARD_DEFAULTS reference flows through untouched. A fresh
623
+ // mergeConfig(...) would allocate identical content under a new reference
624
+ // and bust downstream identity comparisons.
625
+ if (features.length === 0) {
626
+ return makeEnvironmentProviders([]);
627
+ }
628
+ const partial = reduceFeatures(features);
629
+ return makeEnvironmentProviders([
630
+ {
631
+ provide: CNGX_STAT_CARD_CONFIG,
632
+ useValue: mergeConfig(CNGX_STAT_CARD_DEFAULTS, partial),
633
+ },
634
+ ]);
635
+ }
636
+ /**
637
+ * Component-scoped configuration cascade for the stat-card. Pass any
638
+ * combination of feature factories in a parent component's `viewProviders`.
639
+ *
640
+ * Unlike `provideStatCardConfig` (root-only), this injects the parent
641
+ * injector's `CNGX_STAT_CARD_CONFIG` value and deep-merges the supplied
642
+ * features on top. Descendant tiles see the merged config; sibling sub-trees
643
+ * keep the inherited value untouched.
644
+ *
645
+ * ```ts
646
+ * @Component({
647
+ * viewProviders: [provideStatCardConfigAt(withStatCardLoadingTreatment('spinner'))],
648
+ * template: '<cngx-stat-card [state]="s" />',
649
+ * })
650
+ * class LiveTiles {}
651
+ * ```
652
+ *
653
+ * @category ui/stat-card
654
+ * @since 0.1.0
655
+ */
656
+ function provideStatCardConfigAt(...features) {
657
+ // Empty-features call: parent value flows through untouched. Skipping the
658
+ // factory preserves reference identity through the sub-tree.
659
+ if (features.length === 0) {
660
+ return [];
661
+ }
662
+ const partial = reduceFeatures(features);
663
+ return [
664
+ {
665
+ provide: CNGX_STAT_CARD_CONFIG,
666
+ useFactory: () => {
667
+ const parent = inject(CNGX_STAT_CARD_CONFIG, { skipSelf: true });
668
+ return mergeConfig(parent, partial);
669
+ },
670
+ },
671
+ ];
672
+ }
673
+
674
+ /**
675
+ * Override the stat-card's string fallbacks - the busy announcement, the
676
+ * first-load error message, and the stale-data note. Per-instance
677
+ * `[busyLabel]` / `[errorText]` / `[staleText]` bindings still win.
678
+ *
679
+ * The defaults come from the `statCard` section of the language pack (English
680
+ * without one); this overrides single keys on top of it. Pass a
681
+ * `Signal` to switch the language at runtime; a tile with a live region speaks
682
+ * the new language with its next state change.
683
+ *
684
+ * ```ts
685
+ * provideStatCardConfig(
686
+ * withStatCardAriaLabels({ busy: 'Lädt', errorFallback: 'Nicht verfügbar' }),
687
+ * );
688
+ * ```
689
+ *
690
+ * @category ui/stat-card
691
+ * @since 0.1.0
692
+ */
693
+ function withStatCardAriaLabels(labels) {
694
+ return { kind: 'ariaLabels', payload: labels };
695
+ }
696
+ /**
697
+ * Move the cascade default for what a tile renders while it loads. `'auto'`
698
+ * (the library default) picks spinner vs skeleton from the latency the tile
699
+ * observed; `'spinner'` and `'skeleton'` pin it app-wide. Per-instance
700
+ * `[loadingTreatment]` still wins.
701
+ *
702
+ * @category ui/stat-card
703
+ * @since 0.1.0
704
+ */
705
+ function withStatCardLoadingTreatment(treatment) {
706
+ return { kind: 'loadingTreatment', payload: { loadingTreatment: treatment } };
707
+ }
708
+
709
+ /**
710
+ * @module @cngx/ui/stat-card
711
+ */
712
+
713
+ /**
714
+ * Generated bundle index. Do not edit.
715
+ */
716
+
717
+ export { CNGX_STAT_CARD_CONFIG, CNGX_STAT_CARD_LANGUAGE_EN, CngxStatCard, CngxStatCardFooter, CngxStatCardViz, injectStatCardAriaLabels, injectStatCardConfig, provideStatCardConfig, provideStatCardConfigAt, withStatCardAriaLabels, withStatCardLoadingTreatment };
718
+ //# sourceMappingURL=cngx-ui-stat-card.mjs.map