@cngx/ui 0.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +550 -0
  3. package/action-button/README.md +98 -0
  4. package/empty-state/README.md +103 -0
  5. package/feedback/README.md +33 -0
  6. package/fesm2022/cngx-ui-action-button.mjs +319 -0
  7. package/fesm2022/cngx-ui-action-button.mjs.map +1 -0
  8. package/fesm2022/cngx-ui-empty-state.mjs +138 -0
  9. package/fesm2022/cngx-ui-empty-state.mjs.map +1 -0
  10. package/fesm2022/cngx-ui-feedback.mjs +2962 -0
  11. package/fesm2022/cngx-ui-feedback.mjs.map +1 -0
  12. package/fesm2022/cngx-ui-layout.mjs +89 -0
  13. package/fesm2022/cngx-ui-layout.mjs.map +1 -0
  14. package/fesm2022/cngx-ui-mat-stepper.mjs +567 -0
  15. package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -0
  16. package/fesm2022/cngx-ui-mat-tabs.mjs +1405 -0
  17. package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -0
  18. package/fesm2022/cngx-ui-material.mjs +79 -0
  19. package/fesm2022/cngx-ui-material.mjs.map +1 -0
  20. package/fesm2022/cngx-ui-overlay.mjs +91 -0
  21. package/fesm2022/cngx-ui-overlay.mjs.map +1 -0
  22. package/fesm2022/cngx-ui-sidenav.mjs +521 -0
  23. package/fesm2022/cngx-ui-sidenav.mjs.map +1 -0
  24. package/fesm2022/cngx-ui-skeleton.mjs +158 -0
  25. package/fesm2022/cngx-ui-skeleton.mjs.map +1 -0
  26. package/fesm2022/cngx-ui-speak.mjs +112 -0
  27. package/fesm2022/cngx-ui-speak.mjs.map +1 -0
  28. package/fesm2022/cngx-ui-stepper.mjs +312 -0
  29. package/fesm2022/cngx-ui-stepper.mjs.map +1 -0
  30. package/fesm2022/cngx-ui-tabs.mjs +507 -0
  31. package/fesm2022/cngx-ui-tabs.mjs.map +1 -0
  32. package/fesm2022/cngx-ui.mjs +45 -0
  33. package/fesm2022/cngx-ui.mjs.map +1 -0
  34. package/layout/README.md +133 -0
  35. package/mat-stepper/README.md +34 -0
  36. package/mat-tabs/README.md +163 -0
  37. package/mat-tabs/styles/mat-tabs.css +233 -0
  38. package/material/README.md +90 -0
  39. package/overlay/README.md +99 -0
  40. package/package.json +98 -0
  41. package/sidenav/README.md +127 -0
  42. package/skeleton/README.md +98 -0
  43. package/speak/README.md +93 -0
  44. package/speak/speak-button-theme.scss +78 -0
  45. package/stepper/README.md +40 -0
  46. package/tabs/README.md +28 -0
  47. package/types/cngx-ui-action-button.d.ts +126 -0
  48. package/types/cngx-ui-empty-state.d.ts +41 -0
  49. package/types/cngx-ui-feedback.d.ts +1174 -0
  50. package/types/cngx-ui-layout.d.ts +56 -0
  51. package/types/cngx-ui-mat-stepper.d.ts +234 -0
  52. package/types/cngx-ui-mat-tabs.d.ts +664 -0
  53. package/types/cngx-ui-material.d.ts +36 -0
  54. package/types/cngx-ui-overlay.d.ts +57 -0
  55. package/types/cngx-ui-sidenav.d.ts +209 -0
  56. package/types/cngx-ui-skeleton.d.ts +97 -0
  57. package/types/cngx-ui-speak.d.ts +31 -0
  58. package/types/cngx-ui-stepper.d.ts +129 -0
  59. package/types/cngx-ui-tabs.d.ts +165 -0
  60. package/types/cngx-ui.d.ts +18 -0
@@ -0,0 +1,2962 @@
1
+ import { NgComponentOutlet, DOCUMENT, NgTemplateOutlet } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { inject, DestroyRef, signal, Injectable, makeEnvironmentProviders, InjectionToken, effect, input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, viewChild, TemplateRef, Directive, output, contentChild, untracked, linkedSignal, isDevMode, afterNextRender } from '@angular/core';
4
+ import { CNGX_CLOSE_ICON, CngxCloseButton } from '@cngx/common/interactive';
5
+ import { Subject } from 'rxjs';
6
+ import { CNGX_STATEFUL, createTransitionTracker } from '@cngx/core/utils';
7
+ import { resolveAsyncView } from '@cngx/common/data';
8
+
9
+ /**
10
+ * Scoped alert service — manages an alert stack as a signal array.
11
+ *
12
+ * Not `providedIn: 'root'`. Each `CngxAlertStack` provides its own instance
13
+ * via `viewProviders`, scoping alerts to that stack's subtree.
14
+ *
15
+ * For root-level injection, use `provideFeedback(withAlerts())`.
16
+ */
17
+ class CngxAlerter {
18
+ destroyRef = inject(DestroyRef);
19
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
20
+ nextId = 0;
21
+ /** Reactive alert stack — read by `CngxAlertStack`. */
22
+ alerts = signal([], ...(ngDevMode ? [{ debugName: "alerts" }] : /* istanbul ignore next */ []));
23
+ dedupWindow = this.config?.alertDedupWindow ?? 1000;
24
+ defaultDuration = this.config?.alertDefaultDuration;
25
+ constructor() {
26
+ this.destroyRef.onDestroy(() => {
27
+ for (const a of this.alerts()) {
28
+ a.dismissed$.next();
29
+ a.dismissed$.complete();
30
+ }
31
+ });
32
+ }
33
+ /** Show an alert. Returns a ref for programmatic dismiss. */
34
+ show(config) {
35
+ const severity = config.severity ?? 'info';
36
+ const persistent = config.persistent ?? true;
37
+ const dismissible = config.dismissible ?? true;
38
+ // Dedup: message + severity + scope within window
39
+ const now = Date.now();
40
+ const existing = this.alerts().find((a) => a.config.message === config.message &&
41
+ a.config.severity === severity &&
42
+ (a.config.scope ?? '') === (config.scope ?? '') &&
43
+ now - a.createdAt < this.dedupWindow);
44
+ if (existing) {
45
+ return this.createRef(existing);
46
+ }
47
+ const id = this.nextId++;
48
+ const dismissed$ = new Subject();
49
+ const state = {
50
+ id,
51
+ config: {
52
+ message: config.message,
53
+ severity,
54
+ persistent,
55
+ dismissible,
56
+ title: config.title,
57
+ duration: config.duration ?? this.defaultDuration,
58
+ scope: config.scope,
59
+ },
60
+ createdAt: now,
61
+ dismissed$,
62
+ };
63
+ this.alerts.update((as) => [state, ...as]);
64
+ return this.createRef(state);
65
+ }
66
+ /** Dismiss a single alert by id. */
67
+ dismiss(id) {
68
+ const alert = this.alerts().find((a) => a.id === id);
69
+ if (!alert) {
70
+ return;
71
+ }
72
+ this.alerts.update((as) => as.filter((a) => a.id !== id));
73
+ alert.dismissed$.next();
74
+ alert.dismissed$.complete();
75
+ }
76
+ /** Dismiss all alerts (optionally filtered by scope). */
77
+ dismissAll(scope) {
78
+ const current = this.alerts();
79
+ const toRemove = scope ? current.filter((a) => a.config.scope === scope) : current;
80
+ const toKeep = scope ? current.filter((a) => a.config.scope !== scope) : [];
81
+ for (const a of toRemove) {
82
+ a.dismissed$.next();
83
+ a.dismissed$.complete();
84
+ }
85
+ this.alerts.set(toKeep);
86
+ }
87
+ createRef(state) {
88
+ return {
89
+ dismiss: () => this.dismiss(state.id),
90
+ afterDismissed: () => state.dismissed$.asObservable(),
91
+ };
92
+ }
93
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlerter, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
94
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlerter });
95
+ }
96
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlerter, decorators: [{
97
+ type: Injectable
98
+ }], ctorParameters: () => [] });
99
+
100
+ /**
101
+ * Global banner service — manages system-level banners as a signal array.
102
+ *
103
+ * Not `providedIn: 'root'`. Provide via `provideFeedback(withBanners())`.
104
+ *
105
+ * Banners are always persistent — no auto-dismiss. Use `dismiss(id)` to remove
106
+ * programmatically (e.g., on reconnect, on session extend).
107
+ *
108
+ * `id` is required and serves as the dedup key. Calling `show()` with an existing
109
+ * `id` calls `update()` instead (e.g., session timeout countdown).
110
+ *
111
+ * ```typescript
112
+ * private readonly banner = inject(CngxBanner);
113
+ *
114
+ * this.banner.show({
115
+ * message: 'Your session expires in 5 minutes',
116
+ * severity: 'warning',
117
+ * id: 'auth:session-timeout',
118
+ * action: { label: 'Extend', handler: () => this.extendSession() },
119
+ * });
120
+ * ```
121
+ */
122
+ class CngxBanner {
123
+ destroyRef = inject(DestroyRef);
124
+ /** Reactive banner stack — read by `CngxBannerOutlet`. */
125
+ banners = signal([], ...(ngDevMode ? [{ debugName: "banners" }] : /* istanbul ignore next */ []));
126
+ constructor() {
127
+ this.destroyRef.onDestroy(() => {
128
+ for (const b of this.banners()) {
129
+ b.dismissed$.next();
130
+ b.dismissed$.complete();
131
+ }
132
+ });
133
+ }
134
+ /** Show a banner. If `id` already exists, updates it instead. */
135
+ show(config) {
136
+ const existing = this.banners().find((b) => b.id === config.id);
137
+ if (existing) {
138
+ this.update(config.id, config);
139
+ return this.createRef(existing);
140
+ }
141
+ const severity = config.severity ?? 'info';
142
+ const dismissible = config.dismissible ?? true;
143
+ const dismissed$ = new Subject();
144
+ const state = {
145
+ id: config.id,
146
+ config: {
147
+ message: config.message,
148
+ id: config.id,
149
+ severity,
150
+ dismissible,
151
+ action: config.action,
152
+ },
153
+ actionPending: false,
154
+ actionError: undefined,
155
+ dismissed$,
156
+ };
157
+ this.banners.update((bs) => [state, ...bs]);
158
+ return this.createRef(state);
159
+ }
160
+ /** Update an existing banner in-place by id. */
161
+ update(id, patch) {
162
+ this.banners.update((bs) => bs.map((b) => b.id === id
163
+ ? {
164
+ ...b,
165
+ config: {
166
+ ...b.config,
167
+ ...(patch.message !== undefined && { message: patch.message }),
168
+ ...(patch.severity !== undefined && { severity: patch.severity }),
169
+ ...(patch.dismissible !== undefined && { dismissible: patch.dismissible }),
170
+ ...(patch.action !== undefined && { action: patch.action }),
171
+ },
172
+ }
173
+ : b));
174
+ }
175
+ /** Dismiss a banner by id. */
176
+ dismiss(id) {
177
+ const banner = this.banners().find((b) => b.id === id);
178
+ if (!banner) {
179
+ return;
180
+ }
181
+ this.banners.update((bs) => bs.filter((b) => b.id !== id));
182
+ banner.dismissed$.next();
183
+ banner.dismissed$.complete();
184
+ }
185
+ /** Dismiss all banners. */
186
+ dismissAll() {
187
+ for (const b of this.banners()) {
188
+ b.dismissed$.next();
189
+ b.dismissed$.complete();
190
+ }
191
+ this.banners.set([]);
192
+ }
193
+ /**
194
+ * @internal — execute an action handler with async lifecycle.
195
+ * Sets `actionPending` during execution, `actionError` on failure.
196
+ */
197
+ async executeAction(id) {
198
+ const banner = this.banners().find((b) => b.id === id);
199
+ if (!banner?.config.action) {
200
+ return;
201
+ }
202
+ this.banners.update((bs) => bs.map((b) => (b.id === id ? { ...b, actionPending: true, actionError: undefined } : b)));
203
+ try {
204
+ await banner.config.action.handler();
205
+ this.banners.update((bs) => bs.map((b) => (b.id === id ? { ...b, actionPending: false } : b)));
206
+ this.dismiss(id);
207
+ }
208
+ catch (err) {
209
+ this.banners.update((bs) => bs.map((b) => (b.id === id ? { ...b, actionPending: false, actionError: err } : b)));
210
+ }
211
+ }
212
+ createRef(state) {
213
+ return {
214
+ dismiss: () => this.dismiss(state.id),
215
+ afterDismissed: () => state.dismissed$.asObservable(),
216
+ };
217
+ }
218
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBanner, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
219
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBanner });
220
+ }
221
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBanner, decorators: [{
222
+ type: Injectable
223
+ }], ctorParameters: () => [] });
224
+
225
+ /**
226
+ * Feature-scoped toast service — not `providedIn: 'root'`.
227
+ *
228
+ * Provide via `provideFeedback(withToasts())` or `provideToasts()` at the
229
+ * app-shell or route level.
230
+ *
231
+ * Manages the toast stack as a signal array. `CngxToastOutlet` reads it reactively.
232
+ */
233
+ class CngxToaster {
234
+ destroyRef = inject(DestroyRef);
235
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
236
+ nextId = 0;
237
+ /** Reactive toast stack — read by `CngxToastOutlet`. */
238
+ toasts = signal([], ...(ngDevMode ? [{ debugName: "toasts" }] : /* istanbul ignore next */ []));
239
+ /** Default duration for non-error toasts. */
240
+ defaultDuration = signal(this.config?.toastDefaultDuration ?? 5000, ...(ngDevMode ? [{ debugName: "defaultDuration" }] : /* istanbul ignore next */ []));
241
+ /** Dedup window in ms — identical toasts within this window are merged. */
242
+ dedupWindow = signal(this.config?.toastDedupWindow ?? 1000, ...(ngDevMode ? [{ debugName: "dedupWindow" }] : /* istanbul ignore next */ []));
243
+ constructor() {
244
+ this.destroyRef.onDestroy(() => {
245
+ for (const t of this.toasts()) {
246
+ if (t.timer !== undefined) {
247
+ clearTimeout(t.timer);
248
+ }
249
+ }
250
+ });
251
+ }
252
+ /** Show a toast. Returns a ref for programmatic control. */
253
+ show(config) {
254
+ const severity = config.severity ?? 'info';
255
+ const duration = config.duration ?? (severity === 'error' ? 'persistent' : this.defaultDuration());
256
+ const dismissible = config.dismissible ?? true;
257
+ // Dedup check — title is included, description is intentionally excluded
258
+ // (same event with different context detail is still the same event)
259
+ const now = Date.now();
260
+ const existing = this.toasts().find((t) => t.config.message === config.message &&
261
+ t.config.severity === severity &&
262
+ (t.config.title ?? '') === (config.title ?? '') &&
263
+ now - t.createdAt < this.dedupWindow());
264
+ if (existing) {
265
+ if (existing.timer !== undefined) {
266
+ clearTimeout(existing.timer);
267
+ }
268
+ const newTimer = duration !== 'persistent' ? this.startTimer(existing.id, duration) : undefined;
269
+ this.toasts.update((ts) => ts.map((t) => t.id === existing.id
270
+ ? { ...t, count: t.count + 1, timer: newTimer, pausedRemaining: undefined }
271
+ : t));
272
+ return this.createRef(existing);
273
+ }
274
+ const id = this.nextId++;
275
+ const dismissed$ = new Subject();
276
+ const state = {
277
+ id,
278
+ config: {
279
+ message: config.message,
280
+ severity,
281
+ duration,
282
+ dismissible,
283
+ action: config.action,
284
+ title: config.title,
285
+ description: config.description,
286
+ content: config.content,
287
+ contentInputs: config.contentInputs,
288
+ },
289
+ createdAt: now,
290
+ timerStartedAt: now,
291
+ count: 1,
292
+ pausedRemaining: undefined,
293
+ timer: duration !== 'persistent' ? this.startTimer(id, duration) : undefined,
294
+ dismissed$,
295
+ };
296
+ this.toasts.update((ts) => [state, ...ts]);
297
+ return this.createRef(state);
298
+ }
299
+ /** @internal — called by toast-outlet on hover/focus. */
300
+ pauseTimer(id) {
301
+ this.toasts.update((ts) => ts.map((t) => {
302
+ if (t.id !== id || t.timer === undefined) {
303
+ return t;
304
+ }
305
+ const elapsed = Date.now() - t.timerStartedAt;
306
+ const duration = t.config.duration;
307
+ if (typeof duration !== 'number') {
308
+ return t;
309
+ }
310
+ clearTimeout(t.timer);
311
+ return { ...t, timer: undefined, pausedRemaining: Math.max(0, duration - elapsed) };
312
+ }));
313
+ }
314
+ /** @internal — called by toast-outlet on mouse-leave/focus-out. */
315
+ resumeTimer(id) {
316
+ this.toasts.update((ts) => ts.map((t) => {
317
+ if (t.id !== id || t.pausedRemaining === undefined) {
318
+ return t;
319
+ }
320
+ return {
321
+ ...t,
322
+ pausedRemaining: undefined,
323
+ timerStartedAt: Date.now(),
324
+ timer: this.startTimer(t.id, t.pausedRemaining),
325
+ };
326
+ }));
327
+ }
328
+ /** Dismiss a toast by id. */
329
+ dismiss(id) {
330
+ const toast = this.toasts().find((t) => t.id === id);
331
+ if (!toast) {
332
+ return;
333
+ }
334
+ if (toast.timer !== undefined) {
335
+ clearTimeout(toast.timer);
336
+ }
337
+ this.toasts.update((ts) => ts.filter((t) => t.id !== id));
338
+ toast.dismissed$.next();
339
+ toast.dismissed$.complete();
340
+ }
341
+ /** Dismiss all toasts. */
342
+ dismissAll() {
343
+ for (const t of this.toasts()) {
344
+ if (t.timer !== undefined) {
345
+ clearTimeout(t.timer);
346
+ }
347
+ t.dismissed$.next();
348
+ t.dismissed$.complete();
349
+ }
350
+ this.toasts.set([]);
351
+ }
352
+ startTimer(id, ms) {
353
+ return setTimeout(() => this.dismiss(id), ms);
354
+ }
355
+ createRef(state) {
356
+ return {
357
+ dismiss: () => this.dismiss(state.id),
358
+ afterDismissed: () => state.dismissed$.asObservable(),
359
+ };
360
+ }
361
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToaster, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
362
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToaster });
363
+ }
364
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToaster, decorators: [{
365
+ type: Injectable
366
+ }], ctorParameters: () => [] });
367
+ /**
368
+ * Standalone provider for the toast system — use when not using `provideFeedback()`.
369
+ *
370
+ * ```ts
371
+ * bootstrapApplication(AppComponent, {
372
+ * providers: [provideToasts()],
373
+ * });
374
+ * ```
375
+ */
376
+ function provideToasts() {
377
+ return makeEnvironmentProviders([CngxToaster]);
378
+ }
379
+
380
+ /**
381
+ * Injection token for the global feedback configuration.
382
+ * Components read this with `inject(CNGX_FEEDBACK_CONFIG, { optional: true })`.
383
+ */
384
+ const CNGX_FEEDBACK_CONFIG = new InjectionToken('CngxFeedbackConfig');
385
+ /**
386
+ * Register global defaults for all feedback components.
387
+ *
388
+ * ```ts
389
+ * bootstrapApplication(AppComponent, {
390
+ * providers: [
391
+ * provideFeedback(
392
+ * withSpinnerTemplate(MyLucideSpinner),
393
+ * withAlertIcons({ error: MyErrorIcon, warning: MyWarningIcon }),
394
+ * withLoadingDefaults({ delay: 300, minDuration: 600 }),
395
+ * ),
396
+ * ],
397
+ * });
398
+ * ```
399
+ */
400
+ function provideFeedback(...features) {
401
+ let config = {};
402
+ const extraProviders = [];
403
+ for (const f of features) {
404
+ config = f._apply(config);
405
+ if (f._providers) {
406
+ extraProviders.push(...f._providers);
407
+ }
408
+ }
409
+ return makeEnvironmentProviders([
410
+ { provide: CNGX_FEEDBACK_CONFIG, useValue: config },
411
+ ...extraProviders,
412
+ ]);
413
+ }
414
+ /**
415
+ * Replace the built-in SVG spinner in `CngxLoadingIndicator` and `CngxLoadingOverlay`.
416
+ *
417
+ * The component receives no inputs — it should be a self-contained spinner
418
+ * (e.g. a Lucide `<loader-2>` with CSS animation, or a Material `<mat-spinner>`).
419
+ *
420
+ * ```ts
421
+ * provideFeedback(withSpinnerTemplate(MatProgressSpinner))
422
+ * ```
423
+ */
424
+ function withSpinnerTemplate(component) {
425
+ return { _apply: (c) => ({ ...c, spinnerComponent: component }) };
426
+ }
427
+ /**
428
+ * Replace the built-in SVG icons in `CngxAlert` per severity.
429
+ *
430
+ * Each component receives no inputs — it should render a single icon.
431
+ * Only specified severities are replaced; others keep the built-in SVG.
432
+ *
433
+ * ```ts
434
+ * provideFeedback(withAlertIcons({
435
+ * error: MyErrorIcon,
436
+ * warning: MyWarningIcon,
437
+ * success: MyCheckIcon,
438
+ * info: MyInfoIcon,
439
+ * }))
440
+ * ```
441
+ */
442
+ function withAlertIcons(icons) {
443
+ return {
444
+ _apply: (c) => ({
445
+ ...c,
446
+ alertIcons: { ...c.alertIcons, ...icons },
447
+ }),
448
+ };
449
+ }
450
+ /**
451
+ * Set default timing for all loading indicators and overlays.
452
+ *
453
+ * Individual components can still override via their `[delay]` and `[minDuration]` inputs.
454
+ *
455
+ * ```ts
456
+ * provideFeedback(withLoadingDefaults({ delay: 300, minDuration: 600 }))
457
+ * ```
458
+ */
459
+ function withLoadingDefaults(opts) {
460
+ return {
461
+ _apply: (c) => ({
462
+ ...c,
463
+ loadingDelay: opts.delay ?? c.loadingDelay,
464
+ loadingMinDuration: opts.minDuration ?? c.loadingMinDuration,
465
+ }),
466
+ };
467
+ }
468
+ /**
469
+ * Replace the built-in X SVG in all close/dismiss buttons globally.
470
+ *
471
+ * The component receives no inputs — it should render a single icon.
472
+ * Per-instance override via content projection on `CngxCloseButton` takes precedence.
473
+ *
474
+ * ```ts
475
+ * provideFeedback(withCloseIcon(MyLucideXIcon))
476
+ * ```
477
+ */
478
+ function withCloseIcon(component) {
479
+ return {
480
+ _apply: (c) => ({ ...c, closeIconComponent: component }),
481
+ _providers: [{ provide: CNGX_CLOSE_ICON, useValue: component }],
482
+ };
483
+ }
484
+ /**
485
+ * Enable the toast system within `provideFeedback()`.
486
+ *
487
+ * Provides `CngxToaster` at the environment level.
488
+ * Without this feature, `CngxToastOn` and `CngxToastOutlet` will throw
489
+ * a `NullInjectorError` at runtime.
490
+ *
491
+ * @param opts Optional toast defaults.
492
+ *
493
+ * ```ts
494
+ * provideFeedback(
495
+ * withToasts(),
496
+ * withAlertIcons({ error: MyErrorIcon }),
497
+ * )
498
+ * ```
499
+ */
500
+ function withToasts(opts) {
501
+ return {
502
+ _apply: (c) => ({
503
+ ...c,
504
+ toastDefaultDuration: opts?.defaultDuration,
505
+ toastDedupWindow: opts?.dedupWindow,
506
+ }),
507
+ _providers: [CngxToaster],
508
+ };
509
+ }
510
+ /**
511
+ * Enable the scoped alert system within `provideFeedback()`.
512
+ *
513
+ * Provides `CngxAlerter` at the environment level for root-level injection.
514
+ * Without this feature, `CngxAlerter` is only available via `CngxAlertStack`'s
515
+ * `viewProviders` (scoped injection).
516
+ *
517
+ * The token is opaque — always use `provideFeedback()` with feature functions,
518
+ * never construct the config object manually.
519
+ *
520
+ * @param opts Optional alert defaults.
521
+ *
522
+ * ```ts
523
+ * provideFeedback(
524
+ * withToasts(),
525
+ * withAlerts(),
526
+ * )
527
+ * ```
528
+ */
529
+ function withAlerts(opts) {
530
+ return {
531
+ _apply: (c) => ({
532
+ ...c,
533
+ alertDefaultDuration: opts?.defaultDuration,
534
+ alertDedupWindow: opts?.dedupWindow ?? c.alertDedupWindow,
535
+ alertMaxVisible: opts?.maxVisible ?? c.alertMaxVisible,
536
+ }),
537
+ _providers: [CngxAlerter],
538
+ };
539
+ }
540
+ /**
541
+ * Enable the global banner system within `provideFeedback()`.
542
+ *
543
+ * Provides `CngxBanner` at the environment level.
544
+ * Without this feature, `CngxBannerOutlet` will throw a `NullInjectorError`.
545
+ *
546
+ * Banners are always persistent — no `duration`. Dismiss programmatically
547
+ * via `banner.dismiss(id)` when the condition resolves.
548
+ *
549
+ * ```ts
550
+ * provideFeedback(
551
+ * withToasts(),
552
+ * withAlerts(),
553
+ * withBanners(),
554
+ * )
555
+ * ```
556
+ */
557
+ function withBanners() {
558
+ return {
559
+ _apply: (c) => c,
560
+ _providers: [CngxBanner],
561
+ };
562
+ }
563
+
564
+ /**
565
+ * Creates a debounced visibility signal from an active-state signal.
566
+ *
567
+ * Implements two timing rules:
568
+ * - `delay`: suppresses visibility for fast operations (no flash)
569
+ * - `minDuration`: keeps visible for at least this long once shown (no jarring disappearance)
570
+ *
571
+ * Must be called in an injection context (uses `inject(DestroyRef)` for cleanup).
572
+ *
573
+ * @returns A readonly signal that is `true` when the indicator should be visible.
574
+ */
575
+ function createVisibilityTimer(isActive, delay, minDuration) {
576
+ const destroyRef = inject(DestroyRef);
577
+ const visible = signal(false, ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
578
+ let delayTimer;
579
+ let minDurationTimer;
580
+ let minDurationElapsed = true;
581
+ effect(() => {
582
+ const active = isActive();
583
+ const delayMs = delay();
584
+ const minMs = minDuration();
585
+ if (active) {
586
+ clearTimer('delay');
587
+ delayTimer = setTimeout(() => {
588
+ delayTimer = undefined;
589
+ visible.set(true);
590
+ minDurationElapsed = false;
591
+ clearTimer('minDuration');
592
+ minDurationTimer = setTimeout(() => {
593
+ minDurationTimer = undefined;
594
+ minDurationElapsed = true;
595
+ if (!isActive()) {
596
+ visible.set(false);
597
+ }
598
+ }, minMs);
599
+ }, delayMs);
600
+ }
601
+ else {
602
+ clearTimer('delay');
603
+ if (minDurationElapsed) {
604
+ visible.set(false);
605
+ }
606
+ }
607
+ });
608
+ destroyRef.onDestroy(() => {
609
+ clearTimer('delay');
610
+ clearTimer('minDuration');
611
+ });
612
+ function clearTimer(which) {
613
+ if (which === 'delay' && delayTimer !== undefined) {
614
+ clearTimeout(delayTimer);
615
+ delayTimer = undefined;
616
+ }
617
+ if (which === 'minDuration' && minDurationTimer !== undefined) {
618
+ clearTimeout(minDurationTimer);
619
+ minDurationTimer = undefined;
620
+ }
621
+ }
622
+ return visible.asReadonly();
623
+ }
624
+
625
+ /**
626
+ * Loading indicator atom — purely visual, blocks no interaction.
627
+ *
628
+ * Two variants:
629
+ * - `spinner` — rotating circle, inline or centered
630
+ * - `bar` — thin line at the top of the container (YouTube-style)
631
+ *
632
+ * Timing:
633
+ * - `delay` (default 200ms): operations faster than this never show the indicator
634
+ * - `minDuration` (default 500ms): once visible, stays for at least this long
635
+ *
636
+ * For content-blocking overlays, use `cngx-loading-overlay` instead.
637
+ *
638
+ * ### With async state
639
+ * ```html
640
+ * <cngx-loading-indicator [state]="residents" variant="bar" />
641
+ * ```
642
+ *
643
+ * ### Manual boolean
644
+ * ```html
645
+ * <cngx-loading-indicator [loading]="isLoading()" label="Fetching data" />
646
+ * ```
647
+ */
648
+ class CngxLoadingIndicator {
649
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
650
+ /** Bind an async state — shows indicator when `isBusy()`. */
651
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
652
+ /** Direct boolean control — alternative to `[state]`. */
653
+ loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
654
+ /** Visual variant. */
655
+ variant = input('spinner', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
656
+ /** Screen reader label. */
657
+ label = input('Loading', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
658
+ /** Delay in ms before showing the indicator. Falls back to global config, then 200ms. */
659
+ delay = input(this.config?.loadingDelay ?? 200, ...(ngDevMode ? [{ debugName: "delay" }] : /* istanbul ignore next */ []));
660
+ /** Minimum display time in ms once visible. Falls back to global config, then 500ms. */
661
+ minDuration = input(this.config?.loadingMinDuration ?? 500, ...(ngDevMode ? [{ debugName: "minDuration" }] : /* istanbul ignore next */ []));
662
+ /** @internal — true when the underlying source says "loading". */
663
+ isActive = computed(() => this.state()?.isBusy() ?? this.loading(), ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
664
+ /** @internal — custom spinner component from global config. */
665
+ customSpinner = computed(() => this.config?.spinnerComponent ?? null, ...(ngDevMode ? [{ debugName: "customSpinner" }] : /* istanbul ignore next */ []));
666
+ /** @internal — final visibility after delay + minDuration. */
667
+ visible = createVisibilityTimer(this.isActive, this.delay, this.minDuration);
668
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLoadingIndicator, deps: [], target: i0.ɵɵFactoryTarget.Component });
669
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxLoadingIndicator, isStandalone: true, selector: "cngx-loading-indicator", inputs: { state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, delay: { classPropertyName: "delay", publicName: "delay", isSignal: true, isRequired: false, transformFunction: null }, minDuration: { classPropertyName: "minDuration", publicName: "minDuration", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.cngx-loading-indicator--visible": "visible()", "class.cngx-loading-indicator--spinner": "variant() === \"spinner\"", "class.cngx-loading-indicator--bar": "variant() === \"bar\"", "attr.role": "\"status\"", "attr.aria-label": "visible() ? label() : null", "attr.aria-busy": "isActive() || null" }, classAttribute: "cngx-loading-indicator" }, ngImport: i0, template: `
670
+ @if (visible()) {
671
+ @if (variant() === 'spinner') {
672
+ @if (customSpinner(); as cmp) {
673
+ <ng-container *ngComponentOutlet="cmp" />
674
+ } @else {
675
+ <svg class="cngx-loading-indicator__spinner" aria-hidden="true" viewBox="0 0 50 50">
676
+ <circle
677
+ class="cngx-loading-indicator__spinner-track"
678
+ cx="25"
679
+ cy="25"
680
+ r="20"
681
+ fill="none"
682
+ stroke-width="4"
683
+ />
684
+ <circle
685
+ class="cngx-loading-indicator__spinner-arc"
686
+ cx="25"
687
+ cy="25"
688
+ r="20"
689
+ fill="none"
690
+ stroke-width="4"
691
+ stroke-dasharray="80, 200"
692
+ stroke-dashoffset="0"
693
+ stroke-linecap="round"
694
+ />
695
+ </svg>
696
+ }
697
+ } @else {
698
+ <div class="cngx-loading-indicator__bar">
699
+ <div class="cngx-loading-indicator__bar-fill"></div>
700
+ </div>
701
+ }
702
+ }
703
+ `, isInline: true, styles: [".cngx-loading-indicator{display:inline-flex;align-items:center;justify-content:center}.cngx-loading-indicator--bar{display:block;width:100%;height:var(--cngx-loading-bar-height, 3px)}.cngx-loading-indicator__spinner{width:var(--cngx-loading-indicator-size, 24px);height:var(--cngx-loading-indicator-size, 24px);animation:cngx-spin var(--cngx-spin-duration, .8s) var(--cngx-spin-easing, linear) infinite}.cngx-loading-indicator__spinner-track{stroke:var(--cngx-loading-indicator-track, rgba(0, 0, 0, .1))}.cngx-loading-indicator__spinner-arc{stroke:var(--cngx-loading-indicator-color, currentColor)}.cngx-loading-indicator__bar{width:100%;height:100%;background:var(--cngx-loading-indicator-track, rgba(0, 0, 0, .1));overflow:hidden;border-radius:var(--cngx-loading-bar-radius, 0)}.cngx-loading-indicator__bar-fill{width:40%;height:100%;background:var(--cngx-loading-indicator-color, currentColor);border-radius:inherit;animation:cngx-bar-indeterminate var(--cngx-bar-duration, 1.5s) var(--cngx-bar-easing, ease-in-out) infinite}@keyframes cngx-spin{to{transform:rotate(360deg)}}@keyframes cngx-bar-indeterminate{0%{transform:translate(-100%)}50%{transform:translate(150%)}to{transform:translate(400%)}}@media(prefers-reduced-motion:reduce){.cngx-loading-indicator__spinner{animation:cngx-pulse var(--cngx-pulse-duration, 2s) var(--cngx-pulse-easing, ease-in-out) infinite}.cngx-loading-indicator__bar-fill{animation:cngx-pulse var(--cngx-pulse-duration, 2s) var(--cngx-pulse-easing, ease-in-out) infinite;width:100%;transform:none}@keyframes cngx-pulse{0%,to{opacity:.4}50%{opacity:1}}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
704
+ }
705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLoadingIndicator, decorators: [{
706
+ type: Component,
707
+ args: [{ selector: 'cngx-loading-indicator', standalone: true, imports: [NgComponentOutlet], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
708
+ class: 'cngx-loading-indicator',
709
+ '[class.cngx-loading-indicator--visible]': 'visible()',
710
+ '[class.cngx-loading-indicator--spinner]': 'variant() === "spinner"',
711
+ '[class.cngx-loading-indicator--bar]': 'variant() === "bar"',
712
+ '[attr.role]': '"status"',
713
+ '[attr.aria-label]': 'visible() ? label() : null',
714
+ '[attr.aria-busy]': 'isActive() || null',
715
+ }, template: `
716
+ @if (visible()) {
717
+ @if (variant() === 'spinner') {
718
+ @if (customSpinner(); as cmp) {
719
+ <ng-container *ngComponentOutlet="cmp" />
720
+ } @else {
721
+ <svg class="cngx-loading-indicator__spinner" aria-hidden="true" viewBox="0 0 50 50">
722
+ <circle
723
+ class="cngx-loading-indicator__spinner-track"
724
+ cx="25"
725
+ cy="25"
726
+ r="20"
727
+ fill="none"
728
+ stroke-width="4"
729
+ />
730
+ <circle
731
+ class="cngx-loading-indicator__spinner-arc"
732
+ cx="25"
733
+ cy="25"
734
+ r="20"
735
+ fill="none"
736
+ stroke-width="4"
737
+ stroke-dasharray="80, 200"
738
+ stroke-dashoffset="0"
739
+ stroke-linecap="round"
740
+ />
741
+ </svg>
742
+ }
743
+ } @else {
744
+ <div class="cngx-loading-indicator__bar">
745
+ <div class="cngx-loading-indicator__bar-fill"></div>
746
+ </div>
747
+ }
748
+ }
749
+ `, styles: [".cngx-loading-indicator{display:inline-flex;align-items:center;justify-content:center}.cngx-loading-indicator--bar{display:block;width:100%;height:var(--cngx-loading-bar-height, 3px)}.cngx-loading-indicator__spinner{width:var(--cngx-loading-indicator-size, 24px);height:var(--cngx-loading-indicator-size, 24px);animation:cngx-spin var(--cngx-spin-duration, .8s) var(--cngx-spin-easing, linear) infinite}.cngx-loading-indicator__spinner-track{stroke:var(--cngx-loading-indicator-track, rgba(0, 0, 0, .1))}.cngx-loading-indicator__spinner-arc{stroke:var(--cngx-loading-indicator-color, currentColor)}.cngx-loading-indicator__bar{width:100%;height:100%;background:var(--cngx-loading-indicator-track, rgba(0, 0, 0, .1));overflow:hidden;border-radius:var(--cngx-loading-bar-radius, 0)}.cngx-loading-indicator__bar-fill{width:40%;height:100%;background:var(--cngx-loading-indicator-color, currentColor);border-radius:inherit;animation:cngx-bar-indeterminate var(--cngx-bar-duration, 1.5s) var(--cngx-bar-easing, ease-in-out) infinite}@keyframes cngx-spin{to{transform:rotate(360deg)}}@keyframes cngx-bar-indeterminate{0%{transform:translate(-100%)}50%{transform:translate(150%)}to{transform:translate(400%)}}@media(prefers-reduced-motion:reduce){.cngx-loading-indicator__spinner{animation:cngx-pulse var(--cngx-pulse-duration, 2s) var(--cngx-pulse-easing, ease-in-out) infinite}.cngx-loading-indicator__bar-fill{animation:cngx-pulse var(--cngx-pulse-duration, 2s) var(--cngx-pulse-easing, ease-in-out) infinite;width:100%;transform:none}@keyframes cngx-pulse{0%,to{opacity:.4}50%{opacity:1}}}\n"] }]
750
+ }], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], delay: [{ type: i0.Input, args: [{ isSignal: true, alias: "delay", required: false }] }], minDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "minDuration", required: false }] }] } });
751
+
752
+ /**
753
+ * Loading overlay — content container that blocks interaction while loading.
754
+ *
755
+ * Projects content inside a wrapper that receives `inert` during loading.
756
+ * Renders a centered spinner over a semi-transparent backdrop.
757
+ * Manages focus save/restore across the inert lifecycle.
758
+ *
759
+ * Uses `display: grid` with a shared grid cell — backdrop and content
760
+ * overlap naturally without `position: absolute` or `display: contents`.
761
+ *
762
+ * ### With async state
763
+ * ```html
764
+ * <cngx-loading-overlay [state]="tableData">
765
+ * <table>...</table>
766
+ * </cngx-loading-overlay>
767
+ * ```
768
+ *
769
+ * ### Manual boolean
770
+ * ```html
771
+ * <cngx-loading-overlay [loading]="isSaving()">
772
+ * <form>...</form>
773
+ * </cngx-loading-overlay>
774
+ * ```
775
+ *
776
+ * ### First load only (refresh uses the container's built-in bar)
777
+ * ```html
778
+ * <cngx-loading-overlay [state]="query" [firstLoadOnly]="true">
779
+ * <cngx-async-container [state]="query">...</cngx-async-container>
780
+ * </cngx-loading-overlay>
781
+ * ```
782
+ */
783
+ class CngxLoadingOverlay {
784
+ doc = inject(DOCUMENT);
785
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
786
+ /** Bind an async state — shows overlay when `isBusy()`. */
787
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
788
+ /** Direct boolean control — alternative to `[state]`. */
789
+ loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
790
+ /** Screen reader label for the spinner. */
791
+ label = input('Loading', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
792
+ /** Delay in ms before showing the overlay. Falls back to global config, then 200ms. */
793
+ delay = input(this.config?.loadingDelay ?? 200, ...(ngDevMode ? [{ debugName: "delay" }] : /* istanbul ignore next */ []));
794
+ /** Minimum display time in ms once visible. Falls back to global config, then 500ms. */
795
+ minDuration = input(this.config?.loadingMinDuration ?? 500, ...(ngDevMode ? [{ debugName: "minDuration" }] : /* istanbul ignore next */ []));
796
+ /**
797
+ * When `true`, the overlay only activates during the first load (`isFirstLoad()`),
798
+ * not during refreshes. Use the async container's built-in refresh bar for
799
+ * subsequent loads to avoid content jumps under the backdrop.
800
+ */
801
+ firstLoadOnly = input(false, ...(ngDevMode ? [{ debugName: "firstLoadOnly" }] : /* istanbul ignore next */ []));
802
+ /** @internal */
803
+ isActive = computed(() => {
804
+ const s = this.state();
805
+ if (s) {
806
+ return this.firstLoadOnly() ? s.isFirstLoad() : s.isBusy();
807
+ }
808
+ return this.loading();
809
+ }, ...(ngDevMode ? [{ debugName: "isActive" }] : /* istanbul ignore next */ []));
810
+ /** @internal — debounced visibility via shared timer factory. */
811
+ visible = createVisibilityTimer(this.isActive, this.delay, this.minDuration);
812
+ savedFocus = signal(null, ...(ngDevMode ? [{ debugName: "savedFocus" }] : /* istanbul ignore next */ []));
813
+ contentWrapper = viewChild.required('contentWrapper');
814
+ spinnerEl = viewChild('spinnerEl', ...(ngDevMode ? [{ debugName: "spinnerEl" }] : /* istanbul ignore next */ []));
815
+ constructor() {
816
+ // Save focus when loading starts (immediate, before delay)
817
+ effect(() => {
818
+ const active = this.isActive();
819
+ if (active) {
820
+ const activeEl = this.doc.activeElement;
821
+ const wrapper = this.contentWrapper().nativeElement;
822
+ if (activeEl && wrapper.contains(activeEl)) {
823
+ this.savedFocus.set(activeEl);
824
+ }
825
+ }
826
+ });
827
+ // Move focus to spinner when overlay becomes visible (after delay)
828
+ effect(() => {
829
+ const vis = this.visible();
830
+ if (vis) {
831
+ queueMicrotask(() => {
832
+ const spinner = this.spinnerEl()?.nativeElement;
833
+ if (spinner) {
834
+ spinner.focus({ preventScroll: true });
835
+ }
836
+ });
837
+ }
838
+ });
839
+ // Restore focus when loading ends
840
+ effect(() => {
841
+ const active = this.isActive();
842
+ if (!active) {
843
+ const saved = this.savedFocus();
844
+ if (saved) {
845
+ this.savedFocus.set(null);
846
+ queueMicrotask(() => {
847
+ if (saved.isConnected && typeof saved.focus === 'function') {
848
+ saved.focus({ preventScroll: true });
849
+ }
850
+ else {
851
+ const wrapper = this.contentWrapper().nativeElement;
852
+ wrapper.setAttribute('tabindex', '-1');
853
+ wrapper.focus({ preventScroll: true });
854
+ wrapper.removeAttribute('tabindex');
855
+ }
856
+ });
857
+ }
858
+ }
859
+ });
860
+ }
861
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLoadingOverlay, deps: [], target: i0.ɵɵFactoryTarget.Component });
862
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxLoadingOverlay, isStandalone: true, selector: "cngx-loading-overlay", inputs: { state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, delay: { classPropertyName: "delay", publicName: "delay", isSignal: true, isRequired: false, transformFunction: null }, minDuration: { classPropertyName: "minDuration", publicName: "minDuration", isSignal: true, isRequired: false, transformFunction: null }, firstLoadOnly: { classPropertyName: "firstLoadOnly", publicName: "firstLoadOnly", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "cngx-loading-overlay" }, viewQueries: [{ propertyName: "contentWrapper", first: true, predicate: ["contentWrapper"], descendants: true, isSignal: true }, { propertyName: "spinnerEl", first: true, predicate: ["spinnerEl"], descendants: true, isSignal: true }], ngImport: i0, template: `
863
+ <div
864
+ class="cngx-loading-overlay__content"
865
+ #contentWrapper
866
+ [attr.inert]="isActive() || null"
867
+ [attr.aria-busy]="isActive() || null"
868
+ >
869
+ <ng-content />
870
+ </div>
871
+ @if (visible()) {
872
+ <div class="cngx-loading-overlay__backdrop" aria-hidden="true">
873
+ <div
874
+ class="cngx-loading-overlay__spinner-wrapper"
875
+ #spinnerEl
876
+ tabindex="-1"
877
+ role="status"
878
+ [attr.aria-label]="label()"
879
+ >
880
+ <cngx-loading-indicator [loading]="true" variant="spinner" />
881
+ </div>
882
+ </div>
883
+ }
884
+ `, isInline: true, styles: [".cngx-loading-overlay{display:grid;grid-template:1fr / 1fr}.cngx-loading-overlay__content{grid-area:1 / 1}.cngx-loading-overlay__backdrop{grid-area:1 / 1;z-index:var(--cngx-loading-overlay-z-index, 10);display:flex;align-items:center;justify-content:center;background:var(--cngx-loading-overlay-backdrop-bg, rgba(255, 255, 255, .5));opacity:var(--cngx-loading-overlay-backdrop-opacity, 1);transition:opacity var(--cngx-overlay-transition-duration, .15s) var(--cngx-overlay-transition-easing, ease)}.cngx-loading-overlay__spinner-wrapper{outline:none}.cngx-loading-overlay__spinner-wrapper:focus-visible{outline:2px solid var(--cngx-loading-indicator-color, currentColor);outline-offset:2px;border-radius:50%}@media(prefers-reduced-motion:reduce){.cngx-loading-overlay__backdrop{transition:none}}\n"], dependencies: [{ kind: "component", type: CngxLoadingIndicator, selector: "cngx-loading-indicator", inputs: ["state", "loading", "variant", "label", "delay", "minDuration"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
885
+ }
886
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxLoadingOverlay, decorators: [{
887
+ type: Component,
888
+ args: [{ selector: 'cngx-loading-overlay', standalone: true, imports: [CngxLoadingIndicator], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
889
+ class: 'cngx-loading-overlay',
890
+ }, template: `
891
+ <div
892
+ class="cngx-loading-overlay__content"
893
+ #contentWrapper
894
+ [attr.inert]="isActive() || null"
895
+ [attr.aria-busy]="isActive() || null"
896
+ >
897
+ <ng-content />
898
+ </div>
899
+ @if (visible()) {
900
+ <div class="cngx-loading-overlay__backdrop" aria-hidden="true">
901
+ <div
902
+ class="cngx-loading-overlay__spinner-wrapper"
903
+ #spinnerEl
904
+ tabindex="-1"
905
+ role="status"
906
+ [attr.aria-label]="label()"
907
+ >
908
+ <cngx-loading-indicator [loading]="true" variant="spinner" />
909
+ </div>
910
+ </div>
911
+ }
912
+ `, styles: [".cngx-loading-overlay{display:grid;grid-template:1fr / 1fr}.cngx-loading-overlay__content{grid-area:1 / 1}.cngx-loading-overlay__backdrop{grid-area:1 / 1;z-index:var(--cngx-loading-overlay-z-index, 10);display:flex;align-items:center;justify-content:center;background:var(--cngx-loading-overlay-backdrop-bg, rgba(255, 255, 255, .5));opacity:var(--cngx-loading-overlay-backdrop-opacity, 1);transition:opacity var(--cngx-overlay-transition-duration, .15s) var(--cngx-overlay-transition-easing, ease)}.cngx-loading-overlay__spinner-wrapper{outline:none}.cngx-loading-overlay__spinner-wrapper:focus-visible{outline:2px solid var(--cngx-loading-indicator-color, currentColor);outline-offset:2px;border-radius:50%}@media(prefers-reduced-motion:reduce){.cngx-loading-overlay__backdrop{transition:none}}\n"] }]
913
+ }], ctorParameters: () => [], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], delay: [{ type: i0.Input, args: [{ isSignal: true, alias: "delay", required: false }] }], minDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "minDuration", required: false }] }], firstLoadOnly: [{ type: i0.Input, args: [{ isSignal: true, alias: "firstLoadOnly", required: false }] }], contentWrapper: [{ type: i0.ViewChild, args: ['contentWrapper', { isSignal: true }] }], spinnerEl: [{ type: i0.ViewChild, args: ['spinnerEl', { isSignal: true }] }] } });
914
+
915
+ const CIRCUMFERENCE = 2 * Math.PI * 20; // r=20
916
+ const CIRCLE_DASH_ARRAY = `${CIRCUMFERENCE}, ${CIRCUMFERENCE}`;
917
+ /**
918
+ * Progress indicator atom — determinate or indeterminate.
919
+ *
920
+ * Automatically switches between modes based on whether `progress` is defined:
921
+ * - **Indeterminate** (`progress === undefined`) — animated line, no value
922
+ * - **Determinate** (`progress` 0–100) — bar with percentage
923
+ *
924
+ * CSS `transition` on bar width (300ms ease-out) smooths jumpy updates.
925
+ * `aria-valuenow` is only present in determinate mode — AT uses its
926
+ * absence to distinguish the two modes.
927
+ *
928
+ * ### With async state
929
+ * ```html
930
+ * <cngx-progress [state]="uploadState" label="File upload" [showLabel]="true" />
931
+ * ```
932
+ *
933
+ * ### Manual progress
934
+ * ```html
935
+ * <cngx-progress [progress]="percent()" label="Processing" />
936
+ * ```
937
+ */
938
+ class CngxProgress {
939
+ /** Bind an async state — reads `progress()` for determinate mode. */
940
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
941
+ /** Direct progress value (0–100). `undefined` = indeterminate. */
942
+ progress = input(undefined, ...(ngDevMode ? [{ debugName: "progress" }] : /* istanbul ignore next */ []));
943
+ /** Visual variant. */
944
+ variant = input('linear', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
945
+ /** Show percentage label next to the bar. */
946
+ showLabel = input(false, ...(ngDevMode ? [{ debugName: "showLabel" }] : /* istanbul ignore next */ []));
947
+ /** Screen reader label describing *what* is progressing. */
948
+ label = input('Progress', ...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
949
+ /** @internal */
950
+ effectiveProgress = computed(() => {
951
+ const p = this.state()?.progress() ?? this.progress();
952
+ if (p === undefined) {
953
+ return undefined;
954
+ }
955
+ return Math.max(0, Math.min(100, Math.round(p)));
956
+ }, ...(ngDevMode ? [{ debugName: "effectiveProgress" }] : /* istanbul ignore next */ []));
957
+ /** @internal */
958
+ isDeterminate = computed(() => this.effectiveProgress() !== undefined, ...(ngDevMode ? [{ debugName: "isDeterminate" }] : /* istanbul ignore next */ []));
959
+ /** @internal — `null` removes the attribute from the DOM for indeterminate mode. */
960
+ ariaValueNow = computed(() => this.effectiveProgress() ?? null, ...(ngDevMode ? [{ debugName: "ariaValueNow" }] : /* istanbul ignore next */ []));
961
+ /** @internal */
962
+ ariaValueText = computed(() => {
963
+ const p = this.effectiveProgress();
964
+ return p !== undefined ? `${p} percent` : null;
965
+ }, ...(ngDevMode ? [{ debugName: "ariaValueText" }] : /* istanbul ignore next */ []));
966
+ /** @internal */
967
+ circleDashArray = CIRCLE_DASH_ARRAY;
968
+ /** @internal — SVG circle dash offset for determinate circular mode. */
969
+ circleDashOffset = computed(() => {
970
+ const p = this.effectiveProgress();
971
+ if (p === undefined) {
972
+ return 0;
973
+ }
974
+ return CIRCUMFERENCE - (p / 100) * CIRCUMFERENCE;
975
+ }, ...(ngDevMode ? [{ debugName: "circleDashOffset" }] : /* istanbul ignore next */ []));
976
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxProgress, deps: [], target: i0.ɵɵFactoryTarget.Component });
977
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxProgress, isStandalone: true, selector: "cngx-progress", inputs: { state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, progress: { classPropertyName: "progress", publicName: "progress", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, showLabel: { classPropertyName: "showLabel", publicName: "showLabel", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "progressbar" }, properties: { "class.cngx-progress--linear": "variant() === \"linear\"", "class.cngx-progress--circular": "variant() === \"circular\"", "class.cngx-progress--determinate": "isDeterminate()", "class.cngx-progress--indeterminate": "!isDeterminate()", "attr.aria-valuemin": "isDeterminate() ? 0 : null", "attr.aria-valuemax": "isDeterminate() ? 100 : null", "attr.aria-valuenow": "ariaValueNow()", "attr.aria-valuetext": "ariaValueText()", "attr.aria-label": "label()" }, classAttribute: "cngx-progress" }, ngImport: i0, template: `
978
+ @if (variant() === 'linear') {
979
+ <div class="cngx-progress__track">
980
+ <div
981
+ class="cngx-progress__fill"
982
+ [style.width]="isDeterminate() ? effectiveProgress() + '%' : null"
983
+ ></div>
984
+ </div>
985
+ @if (showLabel() && isDeterminate()) {
986
+ <span class="cngx-progress__label" aria-hidden="true"> {{ effectiveProgress() }}% </span>
987
+ }
988
+ } @else {
989
+ <svg class="cngx-progress__circle" viewBox="0 0 50 50" aria-hidden="true">
990
+ <circle
991
+ class="cngx-progress__circle-track"
992
+ cx="25"
993
+ cy="25"
994
+ r="20"
995
+ fill="none"
996
+ stroke-width="4"
997
+ />
998
+ <circle
999
+ class="cngx-progress__circle-fill"
1000
+ cx="25"
1001
+ cy="25"
1002
+ r="20"
1003
+ fill="none"
1004
+ stroke-width="4"
1005
+ stroke-linecap="round"
1006
+ [attr.stroke-dasharray]="circleDashArray"
1007
+ [attr.stroke-dashoffset]="circleDashOffset()"
1008
+ />
1009
+ </svg>
1010
+ @if (showLabel() && isDeterminate()) {
1011
+ <span class="cngx-progress__label" aria-hidden="true"> {{ effectiveProgress() }}% </span>
1012
+ }
1013
+ }
1014
+ `, isInline: true, styles: [".cngx-progress{display:block}.cngx-progress--linear{display:flex;align-items:center;gap:var(--cngx-progress-label-gap, 8px)}.cngx-progress__track{flex:1;height:var(--cngx-progress-height, 4px);background:var(--cngx-progress-track-color, rgba(0, 0, 0, .1));border-radius:var(--cngx-progress-border-radius, 2px);overflow:hidden}.cngx-progress__fill{height:100%;background:var(--cngx-progress-color, currentColor);border-radius:inherit;transition:width var(--cngx-progress-transition-duration, .3s) var(--cngx-progress-transition-easing, ease-out)}.cngx-progress--indeterminate .cngx-progress__fill{width:40%;animation:cngx-progress-indeterminate var(--cngx-progress-indeterminate-duration, 1.5s) var(--cngx-progress-indeterminate-easing, ease-in-out) infinite}.cngx-progress__label{font-size:var(--cngx-progress-label-size, .75rem);color:var(--cngx-progress-label-color, currentColor);min-width:3ch;text-align:right}.cngx-progress--circular{display:inline-flex;align-items:center;justify-content:center;position:relative}.cngx-progress__circle{width:var(--cngx-progress-circle-size, 48px);height:var(--cngx-progress-circle-size, 48px);transform:rotate(-90deg)}.cngx-progress__circle-track{stroke:var(--cngx-progress-track-color, rgba(0, 0, 0, .1))}.cngx-progress__circle-fill{stroke:var(--cngx-progress-color, currentColor);transition:stroke-dashoffset var(--cngx-progress-transition-duration, .3s) var(--cngx-progress-transition-easing, ease-out)}.cngx-progress--indeterminate .cngx-progress__circle{animation:cngx-spin var(--cngx-spin-duration, .8s) var(--cngx-spin-easing, linear) infinite}.cngx-progress--indeterminate .cngx-progress__circle-fill{stroke-dasharray:80,200;stroke-dashoffset:0;transition:none}.cngx-progress--circular .cngx-progress__label{position:absolute;font-size:var(--cngx-progress-circle-label-size, .625rem)}@keyframes cngx-progress-indeterminate{0%{transform:translate(-100%)}50%{transform:translate(150%)}to{transform:translate(400%)}}@keyframes cngx-spin{to{transform:rotate(270deg)}}@media(prefers-reduced-motion:reduce){.cngx-progress--indeterminate .cngx-progress__fill,.cngx-progress--indeterminate .cngx-progress__circle{animation:cngx-pulse var(--cngx-pulse-duration, 2s) var(--cngx-pulse-easing, ease-in-out) infinite}.cngx-progress--indeterminate .cngx-progress__fill{width:100%;transform:none}@keyframes cngx-pulse{0%,to{opacity:.4}50%{opacity:1}}}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1015
+ }
1016
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxProgress, decorators: [{
1017
+ type: Component,
1018
+ args: [{ selector: 'cngx-progress', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1019
+ class: 'cngx-progress',
1020
+ '[class.cngx-progress--linear]': 'variant() === "linear"',
1021
+ '[class.cngx-progress--circular]': 'variant() === "circular"',
1022
+ '[class.cngx-progress--determinate]': 'isDeterminate()',
1023
+ '[class.cngx-progress--indeterminate]': '!isDeterminate()',
1024
+ role: 'progressbar',
1025
+ '[attr.aria-valuemin]': 'isDeterminate() ? 0 : null',
1026
+ '[attr.aria-valuemax]': 'isDeterminate() ? 100 : null',
1027
+ '[attr.aria-valuenow]': 'ariaValueNow()',
1028
+ '[attr.aria-valuetext]': 'ariaValueText()',
1029
+ '[attr.aria-label]': 'label()',
1030
+ }, template: `
1031
+ @if (variant() === 'linear') {
1032
+ <div class="cngx-progress__track">
1033
+ <div
1034
+ class="cngx-progress__fill"
1035
+ [style.width]="isDeterminate() ? effectiveProgress() + '%' : null"
1036
+ ></div>
1037
+ </div>
1038
+ @if (showLabel() && isDeterminate()) {
1039
+ <span class="cngx-progress__label" aria-hidden="true"> {{ effectiveProgress() }}% </span>
1040
+ }
1041
+ } @else {
1042
+ <svg class="cngx-progress__circle" viewBox="0 0 50 50" aria-hidden="true">
1043
+ <circle
1044
+ class="cngx-progress__circle-track"
1045
+ cx="25"
1046
+ cy="25"
1047
+ r="20"
1048
+ fill="none"
1049
+ stroke-width="4"
1050
+ />
1051
+ <circle
1052
+ class="cngx-progress__circle-fill"
1053
+ cx="25"
1054
+ cy="25"
1055
+ r="20"
1056
+ fill="none"
1057
+ stroke-width="4"
1058
+ stroke-linecap="round"
1059
+ [attr.stroke-dasharray]="circleDashArray"
1060
+ [attr.stroke-dashoffset]="circleDashOffset()"
1061
+ />
1062
+ </svg>
1063
+ @if (showLabel() && isDeterminate()) {
1064
+ <span class="cngx-progress__label" aria-hidden="true"> {{ effectiveProgress() }}% </span>
1065
+ }
1066
+ }
1067
+ `, styles: [".cngx-progress{display:block}.cngx-progress--linear{display:flex;align-items:center;gap:var(--cngx-progress-label-gap, 8px)}.cngx-progress__track{flex:1;height:var(--cngx-progress-height, 4px);background:var(--cngx-progress-track-color, rgba(0, 0, 0, .1));border-radius:var(--cngx-progress-border-radius, 2px);overflow:hidden}.cngx-progress__fill{height:100%;background:var(--cngx-progress-color, currentColor);border-radius:inherit;transition:width var(--cngx-progress-transition-duration, .3s) var(--cngx-progress-transition-easing, ease-out)}.cngx-progress--indeterminate .cngx-progress__fill{width:40%;animation:cngx-progress-indeterminate var(--cngx-progress-indeterminate-duration, 1.5s) var(--cngx-progress-indeterminate-easing, ease-in-out) infinite}.cngx-progress__label{font-size:var(--cngx-progress-label-size, .75rem);color:var(--cngx-progress-label-color, currentColor);min-width:3ch;text-align:right}.cngx-progress--circular{display:inline-flex;align-items:center;justify-content:center;position:relative}.cngx-progress__circle{width:var(--cngx-progress-circle-size, 48px);height:var(--cngx-progress-circle-size, 48px);transform:rotate(-90deg)}.cngx-progress__circle-track{stroke:var(--cngx-progress-track-color, rgba(0, 0, 0, .1))}.cngx-progress__circle-fill{stroke:var(--cngx-progress-color, currentColor);transition:stroke-dashoffset var(--cngx-progress-transition-duration, .3s) var(--cngx-progress-transition-easing, ease-out)}.cngx-progress--indeterminate .cngx-progress__circle{animation:cngx-spin var(--cngx-spin-duration, .8s) var(--cngx-spin-easing, linear) infinite}.cngx-progress--indeterminate .cngx-progress__circle-fill{stroke-dasharray:80,200;stroke-dashoffset:0;transition:none}.cngx-progress--circular .cngx-progress__label{position:absolute;font-size:var(--cngx-progress-circle-label-size, .625rem)}@keyframes cngx-progress-indeterminate{0%{transform:translate(-100%)}50%{transform:translate(150%)}to{transform:translate(400%)}}@keyframes cngx-spin{to{transform:rotate(270deg)}}@media(prefers-reduced-motion:reduce){.cngx-progress--indeterminate .cngx-progress__fill,.cngx-progress--indeterminate .cngx-progress__circle{animation:cngx-pulse var(--cngx-pulse-duration, 2s) var(--cngx-pulse-easing, ease-in-out) infinite}.cngx-progress--indeterminate .cngx-progress__fill{width:100%;transform:none}@keyframes cngx-pulse{0%,to{opacity:.4}50%{opacity:1}}}\n"] }]
1068
+ }], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], progress: [{ type: i0.Input, args: [{ isSignal: true, alias: "progress", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], showLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "showLabel", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }] } });
1069
+
1070
+ /**
1071
+ * @internal — shared default SVG icon for alert severity.
1072
+ *
1073
+ * Renders the built-in severity icons used by `CngxAlert`, `CngxAlertStack`,
1074
+ * and `CngxBannerOutlet`. Each severity has a distinct icon shape so color
1075
+ * is never the only indicator (WCAG 1.4.1).
1076
+ */
1077
+ class CngxSeverityIcon {
1078
+ /** Which severity icon to render. */
1079
+ severity = input.required(...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
1080
+ /** CSS class applied to the SVG element. */
1081
+ iconClass = input('', ...(ngDevMode ? [{ debugName: "iconClass" }] : /* istanbul ignore next */ []));
1082
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSeverityIcon, deps: [], target: i0.ɵɵFactoryTarget.Component });
1083
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxSeverityIcon, isStandalone: true, selector: "cngx-severity-icon", inputs: { severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: true, transformFunction: null }, iconClass: { classPropertyName: "iconClass", publicName: "iconClass", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, ngImport: i0, template: `
1084
+ <svg
1085
+ aria-hidden="true"
1086
+ viewBox="0 0 24 24"
1087
+ fill="none"
1088
+ stroke="currentColor"
1089
+ stroke-width="2"
1090
+ stroke-linecap="round"
1091
+ stroke-linejoin="round"
1092
+ [class]="iconClass()"
1093
+ >
1094
+ @switch (severity()) {
1095
+ @case ('info') {
1096
+ <circle cx="12" cy="12" r="10" />
1097
+ <line x1="12" y1="16" x2="12" y2="12" />
1098
+ <line x1="12" y1="8" x2="12.01" y2="8" />
1099
+ }
1100
+ @case ('success') {
1101
+ <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
1102
+ <polyline points="22 4 12 14.01 9 11.01" />
1103
+ }
1104
+ @case ('warning') {
1105
+ <path
1106
+ d="M10.29 3.86L1.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"
1107
+ />
1108
+ <line x1="12" y1="9" x2="12" y2="13" />
1109
+ <line x1="12" y1="17" x2="12.01" y2="17" />
1110
+ }
1111
+ @case ('error') {
1112
+ <circle cx="12" cy="12" r="10" />
1113
+ <line x1="15" y1="9" x2="9" y2="15" />
1114
+ <line x1="9" y1="9" x2="15" y2="15" />
1115
+ }
1116
+ }
1117
+ </svg>
1118
+ `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1119
+ }
1120
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxSeverityIcon, decorators: [{
1121
+ type: Component,
1122
+ args: [{
1123
+ selector: 'cngx-severity-icon',
1124
+ standalone: true,
1125
+ changeDetection: ChangeDetectionStrategy.OnPush,
1126
+ encapsulation: ViewEncapsulation.None,
1127
+ host: { style: 'display: contents' },
1128
+ template: `
1129
+ <svg
1130
+ aria-hidden="true"
1131
+ viewBox="0 0 24 24"
1132
+ fill="none"
1133
+ stroke="currentColor"
1134
+ stroke-width="2"
1135
+ stroke-linecap="round"
1136
+ stroke-linejoin="round"
1137
+ [class]="iconClass()"
1138
+ >
1139
+ @switch (severity()) {
1140
+ @case ('info') {
1141
+ <circle cx="12" cy="12" r="10" />
1142
+ <line x1="12" y1="16" x2="12" y2="12" />
1143
+ <line x1="12" y1="8" x2="12.01" y2="8" />
1144
+ }
1145
+ @case ('success') {
1146
+ <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
1147
+ <polyline points="22 4 12 14.01 9 11.01" />
1148
+ }
1149
+ @case ('warning') {
1150
+ <path
1151
+ d="M10.29 3.86L1.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"
1152
+ />
1153
+ <line x1="12" y1="9" x2="12" y2="13" />
1154
+ <line x1="12" y1="17" x2="12.01" y2="17" />
1155
+ }
1156
+ @case ('error') {
1157
+ <circle cx="12" cy="12" r="10" />
1158
+ <line x1="15" y1="9" x2="9" y2="15" />
1159
+ <line x1="9" y1="9" x2="15" y2="15" />
1160
+ }
1161
+ }
1162
+ </svg>
1163
+ `,
1164
+ }]
1165
+ }], propDecorators: { severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: true }] }], iconClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "iconClass", required: false }] }] } });
1166
+
1167
+ function createPausableTimer() {
1168
+ let id;
1169
+ let remaining = 0;
1170
+ let startedAt = 0;
1171
+ let onComplete;
1172
+ const clear = () => {
1173
+ if (id !== undefined) {
1174
+ clearTimeout(id);
1175
+ id = undefined;
1176
+ }
1177
+ remaining = 0;
1178
+ onComplete = undefined;
1179
+ };
1180
+ const resume = () => {
1181
+ if (remaining > 0 && id === undefined && onComplete) {
1182
+ startedAt = Date.now();
1183
+ const cb = onComplete;
1184
+ id = setTimeout(() => {
1185
+ id = undefined;
1186
+ remaining = 0;
1187
+ cb();
1188
+ }, remaining);
1189
+ }
1190
+ };
1191
+ const pause = () => {
1192
+ if (id !== undefined) {
1193
+ clearTimeout(id);
1194
+ id = undefined;
1195
+ remaining = Math.max(0, remaining - (Date.now() - startedAt));
1196
+ }
1197
+ };
1198
+ return {
1199
+ start: (duration, cb) => {
1200
+ clear();
1201
+ onComplete = cb;
1202
+ remaining = duration;
1203
+ resume();
1204
+ },
1205
+ pause,
1206
+ resume,
1207
+ clear,
1208
+ };
1209
+ }
1210
+ /** Content slot directive for custom alert icons. */
1211
+ class CngxAlertIcon {
1212
+ templateRef = inject(TemplateRef, { optional: true });
1213
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertIcon, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1214
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxAlertIcon, isStandalone: true, selector: "[cngxAlertIcon]", ngImport: i0 });
1215
+ }
1216
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertIcon, decorators: [{
1217
+ type: Directive,
1218
+ args: [{ selector: '[cngxAlertIcon]', standalone: true }]
1219
+ }] });
1220
+ /**
1221
+ * Action button marker inside an alert. Restricts to button and anchor elements.
1222
+ *
1223
+ * When present, the alert container uses `aria-atomic="false"` to prevent
1224
+ * re-announcing the entire alert on button interaction.
1225
+ *
1226
+ * ```html
1227
+ * <cngx-alert severity="error" title="Save failed" [state]="saveState">
1228
+ * Check your connection and try again.
1229
+ * <button cngxAlertAction (click)="retry()">Retry</button>
1230
+ * </cngx-alert>
1231
+ * ```
1232
+ */
1233
+ class CngxAlertAction {
1234
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertAction, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1235
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxAlertAction, isStandalone: true, selector: "button[cngxAlertAction], a[cngxAlertAction]", host: { classAttribute: "cngx-alert__action" }, ngImport: i0 });
1236
+ }
1237
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertAction, decorators: [{
1238
+ type: Directive,
1239
+ args: [{
1240
+ selector: 'button[cngxAlertAction], a[cngxAlertAction]',
1241
+ standalone: true,
1242
+ host: { class: 'cngx-alert__action' },
1243
+ }]
1244
+ }] });
1245
+ /**
1246
+ * Inline alert atom with enter/exit animations, state-driven visibility,
1247
+ * auto-dismiss with pause-on-hover/focus, and optional auto-collapse.
1248
+ *
1249
+ * Three visibility modes:
1250
+ * - **Static** (no `[state]` or `[when]`): always visible
1251
+ * - **State-driven** (`[state]`): auto-shows on error/success/loading, auto-hides on idle
1252
+ * - **Boolean-driven** (`[when]`): visible when true, hidden when false
1253
+ *
1254
+ * `[state]` takes precedence over `[when]`.
1255
+ */
1256
+ class CngxAlert {
1257
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
1258
+ destroyRef = inject(DestroyRef);
1259
+ /** Alert severity — determines visual style, default icon, and ARIA role. */
1260
+ severity = input('info', ...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
1261
+ /** Optional title displayed above the content. */
1262
+ title = input(undefined, ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
1263
+ /**
1264
+ * Shows a dismiss button.
1265
+ * @deprecated Use `closable` instead.
1266
+ */
1267
+ dismissible = input(false, ...(ngDevMode ? [{ debugName: "dismissible" }] : /* istanbul ignore next */ []));
1268
+ /** Shows a dismiss button. Preferred over deprecated `dismissible`. */
1269
+ closable = input(false, ...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
1270
+ /** Bind an async state — auto-shows on error/success/loading, auto-hides on idle. */
1271
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
1272
+ /**
1273
+ * Boolean visibility trigger. When set, controls alert visibility directly.
1274
+ * `[state]` takes precedence over `[when]`.
1275
+ */
1276
+ when = input(undefined, ...(ngDevMode ? [{ debugName: "when" }] : /* istanbul ignore next */ []));
1277
+ /**
1278
+ * Auto-dismiss delay in ms for success state or timed alerts.
1279
+ * Set to `undefined` to disable auto-dismiss (persistent).
1280
+ */
1281
+ autoDismissDelay = input(5000, ...(ngDevMode ? [{ debugName: "autoDismissDelay" }] : /* istanbul ignore next */ []));
1282
+ /** Enables auto-collapse after `collapseDelay`. Visual only — SR reads full content. */
1283
+ collapsible = input(false, ...(ngDevMode ? [{ debugName: "collapsible" }] : /* istanbul ignore next */ []));
1284
+ /** Delay in ms before auto-collapsing. Defaults to `autoDismissDelay`. */
1285
+ collapseDelay = input(undefined, ...(ngDevMode ? [{ debugName: "collapseDelay" }] : /* istanbul ignore next */ []));
1286
+ /** Emitted when the dismiss button is clicked. */
1287
+ dismissed = output();
1288
+ /** @internal — detects projected custom icon to hide default/global icon. */
1289
+ customIcon = contentChild(CngxAlertIcon, ...(ngDevMode ? [{ debugName: "customIcon" }] : /* istanbul ignore next */ []));
1290
+ /** @internal — detects projected action buttons for aria-atomic strategy. */
1291
+ hasActions = contentChild(CngxAlertAction, ...(ngDevMode ? [{ debugName: "hasActions" }] : /* istanbul ignore next */ []));
1292
+ manualDismissed = signal(false, ...(ngDevMode ? [{ debugName: "manualDismissed" }] : /* istanbul ignore next */ []));
1293
+ autoDismissed = signal(false, ...(ngDevMode ? [{ debugName: "autoDismissed" }] : /* istanbul ignore next */ []));
1294
+ collapsedState = signal(false, ...(ngDevMode ? [{ debugName: "collapsedState" }] : /* istanbul ignore next */ []));
1295
+ announcementState = signal('', ...(ngDevMode ? [{ debugName: "announcementState" }] : /* istanbul ignore next */ []));
1296
+ /** @internal — animation phase, drives host CSS classes. */
1297
+ visibilityPhase = signal('hidden', ...(ngDevMode ? [{ debugName: "visibilityPhase" }] : /* istanbul ignore next */ []));
1298
+ autoDismissTimer = createPausableTimer();
1299
+ collapseTimer = createPausableTimer();
1300
+ animationFallbackId;
1301
+ /** @internal — global icon component for the current severity (from provideFeedback config). */
1302
+ globalIcon = computed(() => this.config?.alertIcons?.[this.severity()] ?? null, ...(ngDevMode ? [{ debugName: "globalIcon" }] : /* istanbul ignore next */ []));
1303
+ /** @internal — merged closable from new and deprecated input. */
1304
+ effectiveClosable = computed(() => this.closable() || this.dismissible(), ...(ngDevMode ? [{ debugName: "effectiveClosable" }] : /* istanbul ignore next */ []));
1305
+ /** @internal — ARIA role: 'alert' for error/warning, 'status' for info/success. */
1306
+ ariaRole = computed(() => {
1307
+ const s = this.severity();
1308
+ return s === 'error' || s === 'warning' ? 'alert' : 'status';
1309
+ }, ...(ngDevMode ? [{ debugName: "ariaRole" }] : /* istanbul ignore next */ []));
1310
+ /** @internal — false when actions are projected to prevent full re-announcement. */
1311
+ ariaAtomic = computed(() => (this.hasActions() ? 'false' : 'true'), ...(ngDevMode ? [{ debugName: "ariaAtomic" }] : /* istanbul ignore next */ []));
1312
+ /** @internal — true when bound state is in a busy status. */
1313
+ isStateBusy = computed(() => {
1314
+ const s = this.state();
1315
+ if (!s) {
1316
+ return false;
1317
+ }
1318
+ const status = s.status();
1319
+ return status === 'loading' || status === 'pending' || status === 'refreshing';
1320
+ }, ...(ngDevMode ? [{ debugName: "isStateBusy" }] : /* istanbul ignore next */ []));
1321
+ /**
1322
+ * @internal — whether the alert SHOULD be visible (before animation).
1323
+ * Drives the animation effect which manages visibilityPhase.
1324
+ */
1325
+ shouldBeVisible = computed(() => {
1326
+ if (this.manualDismissed()) {
1327
+ return false;
1328
+ }
1329
+ if (this.autoDismissed()) {
1330
+ return false;
1331
+ }
1332
+ const s = this.state();
1333
+ if (s) {
1334
+ const status = s.status();
1335
+ return status !== 'idle';
1336
+ }
1337
+ const w = this.when();
1338
+ if (w !== undefined) {
1339
+ return w;
1340
+ }
1341
+ // Static: always visible
1342
+ return true;
1343
+ }, ...(ngDevMode ? [{ debugName: "shouldBeVisible" }] : /* istanbul ignore next */ []));
1344
+ /** @internal — true when the alert is currently visible (post-animation). */
1345
+ isVisible = computed(() => {
1346
+ const phase = this.visibilityPhase();
1347
+ return phase === 'entering' || phase === 'visible';
1348
+ }, ...(ngDevMode ? [{ debugName: "isVisible" }] : /* istanbul ignore next */ []));
1349
+ /** @internal — collapsed state (read-only public view). */
1350
+ collapsed = this.collapsedState.asReadonly();
1351
+ /** @internal — SR announcement text for state transitions. */
1352
+ announcement = this.announcementState.asReadonly();
1353
+ effectiveCollapseDelay = computed(() => this.collapseDelay() ?? this.autoDismissDelay() ?? 5000, ...(ngDevMode ? [{ debugName: "effectiveCollapseDelay" }] : /* istanbul ignore next */ []));
1354
+ constructor() {
1355
+ effect(() => {
1356
+ const s = this.state();
1357
+ if (!s) {
1358
+ return;
1359
+ }
1360
+ const status = s.status();
1361
+ if (status === 'error') {
1362
+ // Error: persistent — reset any dismiss, clear timer
1363
+ this.manualDismissed.set(false);
1364
+ this.autoDismissed.set(false);
1365
+ this.autoDismissTimer.clear();
1366
+ }
1367
+ else if (status === 'success') {
1368
+ // Success: show briefly, then auto-dismiss
1369
+ this.manualDismissed.set(false);
1370
+ this.autoDismissed.set(false);
1371
+ const delay = this.autoDismissDelay();
1372
+ if (delay !== undefined) {
1373
+ this.autoDismissTimer.start(delay, () => this.autoDismissed.set(true));
1374
+ }
1375
+ }
1376
+ else if (status === 'idle') {
1377
+ this.autoDismissTimer.clear();
1378
+ }
1379
+ // loading/pending/refreshing: keep current state, don't touch timers
1380
+ });
1381
+ effect(() => {
1382
+ const show = this.shouldBeVisible();
1383
+ const phase = untracked(() => this.visibilityPhase());
1384
+ if (show && (phase === 'hidden' || phase === 'exiting')) {
1385
+ this.beginEnter();
1386
+ }
1387
+ else if (!show && (phase === 'visible' || phase === 'entering')) {
1388
+ this.beginExit();
1389
+ }
1390
+ });
1391
+ this.destroyRef.onDestroy(() => {
1392
+ this.autoDismissTimer.clear();
1393
+ this.collapseTimer.clear();
1394
+ this.clearAnimationFallback();
1395
+ });
1396
+ }
1397
+ beginEnter() {
1398
+ this.collapsedState.set(false);
1399
+ this.visibilityPhase.set('entering');
1400
+ this.scheduleAnimationFallback();
1401
+ }
1402
+ beginExit() {
1403
+ this.visibilityPhase.set('exiting');
1404
+ this.scheduleAnimationFallback();
1405
+ }
1406
+ onBecameVisible() {
1407
+ if (this.collapsible()) {
1408
+ this.collapseTimer.start(this.effectiveCollapseDelay(), () => this.collapsedState.set(true));
1409
+ }
1410
+ }
1411
+ onBecameHidden() {
1412
+ this.autoDismissTimer.clear();
1413
+ this.collapseTimer.clear();
1414
+ this.collapsedState.set(false);
1415
+ }
1416
+ scheduleAnimationFallback() {
1417
+ this.clearAnimationFallback();
1418
+ // When reduced-motion is active (or no window — SSR/test), transition immediately.
1419
+ // Otherwise use a generous timeout as safety net (animationend normally fires first
1420
+ // and clears this via clearAnimationFallback).
1421
+ const reducedMotion = typeof window === 'undefined' ||
1422
+ !window.matchMedia?.('(prefers-reduced-motion: no-preference)').matches;
1423
+ this.animationFallbackId = setTimeout(() => {
1424
+ this.animationFallbackId = undefined;
1425
+ const phase = this.visibilityPhase();
1426
+ if (phase === 'entering') {
1427
+ this.visibilityPhase.set('visible');
1428
+ this.onBecameVisible();
1429
+ }
1430
+ else if (phase === 'exiting') {
1431
+ this.visibilityPhase.set('hidden');
1432
+ this.onBecameHidden();
1433
+ }
1434
+ }, reducedMotion ? 0 : 500);
1435
+ }
1436
+ clearAnimationFallback() {
1437
+ if (this.animationFallbackId !== undefined) {
1438
+ clearTimeout(this.animationFallbackId);
1439
+ this.animationFallbackId = undefined;
1440
+ }
1441
+ }
1442
+ /** @internal */
1443
+ handleAnimationEnd(event) {
1444
+ if (event.animationName === 'cngx-alert-enter') {
1445
+ this.clearAnimationFallback();
1446
+ this.visibilityPhase.set('visible');
1447
+ this.onBecameVisible();
1448
+ }
1449
+ else if (event.animationName === 'cngx-alert-exit') {
1450
+ this.clearAnimationFallback();
1451
+ this.visibilityPhase.set('hidden');
1452
+ this.onBecameHidden();
1453
+ }
1454
+ }
1455
+ /** @internal */
1456
+ handleDismiss() {
1457
+ this.manualDismissed.set(true);
1458
+ this.autoDismissTimer.clear();
1459
+ this.collapseTimer.clear();
1460
+ this.announcementState.set('Alert dismissed');
1461
+ this.dismissed.emit();
1462
+ }
1463
+ /** @internal — WCAG 2.2.1: pause auto-dismiss on hover. */
1464
+ handlePointerEnter() {
1465
+ this.autoDismissTimer.pause();
1466
+ this.collapseTimer.pause();
1467
+ // Expand on hover if collapsed
1468
+ if (this.collapsedState()) {
1469
+ this.collapsedState.set(false);
1470
+ }
1471
+ }
1472
+ /** @internal — resume timers on pointer leave. */
1473
+ handlePointerLeave() {
1474
+ this.autoDismissTimer.resume();
1475
+ // Restart collapse timer from full delay on leave
1476
+ if (this.collapsible() && this.isVisible()) {
1477
+ this.collapseTimer.start(this.effectiveCollapseDelay(), () => this.collapsedState.set(true));
1478
+ }
1479
+ }
1480
+ /** @internal — WCAG 2.2.1: pause auto-dismiss on focus. */
1481
+ handleFocusIn() {
1482
+ this.autoDismissTimer.pause();
1483
+ this.collapseTimer.pause();
1484
+ if (this.collapsedState()) {
1485
+ this.collapsedState.set(false);
1486
+ }
1487
+ }
1488
+ /** @internal — resume timers on focus out. */
1489
+ handleFocusOut() {
1490
+ this.autoDismissTimer.resume();
1491
+ if (this.collapsible() && this.isVisible()) {
1492
+ this.collapseTimer.start(this.effectiveCollapseDelay(), () => this.collapsedState.set(true));
1493
+ }
1494
+ }
1495
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlert, deps: [], target: i0.ɵɵFactoryTarget.Component });
1496
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxAlert, isStandalone: true, selector: "cngx-alert", inputs: { severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, when: { classPropertyName: "when", publicName: "when", isSignal: true, isRequired: false, transformFunction: null }, autoDismissDelay: { classPropertyName: "autoDismissDelay", publicName: "autoDismissDelay", isSignal: true, isRequired: false, transformFunction: null }, collapsible: { classPropertyName: "collapsible", publicName: "collapsible", isSignal: true, isRequired: false, transformFunction: null }, collapseDelay: { classPropertyName: "collapseDelay", publicName: "collapseDelay", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dismissed: "dismissed" }, host: { listeners: { "animationend": "handleAnimationEnd($event)", "pointerenter": "handlePointerEnter()", "pointerleave": "handlePointerLeave()", "focusin": "handleFocusIn()", "focusout": "handleFocusOut()" }, properties: { "class.cngx-alert--info": "severity() === \"info\"", "class.cngx-alert--success": "severity() === \"success\"", "class.cngx-alert--warning": "severity() === \"warning\"", "class.cngx-alert--error": "severity() === \"error\"", "class.cngx-alert--hidden": "visibilityPhase() === \"hidden\"", "class.cngx-alert--entering": "visibilityPhase() === \"entering\"", "class.cngx-alert--visible": "visibilityPhase() === \"visible\"", "class.cngx-alert--exiting": "visibilityPhase() === \"exiting\"", "class.cngx-alert--collapsed": "collapsed()", "attr.role": "isVisible() ? ariaRole() : null", "attr.aria-atomic": "isVisible() ? ariaAtomic() : null", "attr.aria-label": "isVisible() ? (title() || null) : null", "attr.aria-expanded": "collapsible() ? !collapsed() : null", "attr.aria-busy": "isStateBusy() || null", "attr.hidden": "!isVisible() || null" }, classAttribute: "cngx-alert" }, queries: [{ propertyName: "customIcon", first: true, predicate: CngxAlertIcon, descendants: true, isSignal: true }, { propertyName: "hasActions", first: true, predicate: CngxAlertAction, descendants: true, isSignal: true }], ngImport: i0, template: `
1497
+ <div class="cngx-alert__icon">
1498
+ <ng-content select="[cngxAlertIcon]" />
1499
+ @if (globalIcon(); as iconCmp) {
1500
+ @if (!customIcon()) {
1501
+ <ng-container *ngComponentOutlet="iconCmp" />
1502
+ }
1503
+ } @else if (!customIcon()) {
1504
+ <cngx-severity-icon [severity]="severity()" iconClass="cngx-alert__default-icon" />
1505
+ }
1506
+ </div>
1507
+ <div class="cngx-alert__body">
1508
+ @if (title()) {
1509
+ <strong class="cngx-alert__title">{{ title() }}</strong>
1510
+ }
1511
+ <div class="cngx-alert__collapsible">
1512
+ <div class="cngx-alert__content">
1513
+ <ng-content />
1514
+ </div>
1515
+ <div class="cngx-alert__actions">
1516
+ <ng-content select="[cngxAlertAction]" />
1517
+ </div>
1518
+ </div>
1519
+ </div>
1520
+ @if (effectiveClosable()) {
1521
+ <cngx-close-button label="Dismiss" class="cngx-alert__dismiss" (click)="handleDismiss()" />
1522
+ }
1523
+ <span class="cngx-sr-only" aria-live="polite" aria-atomic="true">{{ announcement() }}</span>
1524
+ `, isInline: true, styles: [".cngx-alert{display:flex;align-items:flex-start;gap:var(--cngx-alert-gap, 12px);padding:var(--cngx-alert-padding, 12px 16px);border-radius:var(--cngx-alert-border-radius, 8px);border:1px solid var(--cngx-alert-border-color, transparent);background:var(--cngx-alert-bg, #f8fafc);color:var(--cngx-alert-color, inherit)}.cngx-alert--info{--cngx-alert-bg: var(--cngx-alert-info-bg, #eff6ff);--cngx-alert-border-color: var(--cngx-alert-info-border, #bfdbfe);--cngx-alert-icon-color: var(--cngx-alert-info-icon, #3b82f6)}.cngx-alert--success{--cngx-alert-bg: var(--cngx-alert-success-bg, #f0fdf4);--cngx-alert-border-color: var(--cngx-alert-success-border, #bbf7d0);--cngx-alert-icon-color: var(--cngx-alert-success-icon, #22c55e)}.cngx-alert--warning{--cngx-alert-bg: var(--cngx-alert-warning-bg, #fffbeb);--cngx-alert-border-color: var(--cngx-alert-warning-border, #fde68a);--cngx-alert-icon-color: var(--cngx-alert-warning-icon, #f59e0b)}.cngx-alert--error{--cngx-alert-bg: var(--cngx-alert-error-bg, #fef2f2);--cngx-alert-border-color: var(--cngx-alert-error-border, #fecaca);--cngx-alert-icon-color: var(--cngx-alert-error-icon, #ef4444)}.cngx-alert__icon{flex-shrink:0;color:var(--cngx-alert-icon-color, currentColor)}.cngx-alert__default-icon{width:var(--cngx-alert-icon-size, 20px);height:var(--cngx-alert-icon-size, 20px)}.cngx-alert__body{flex:1;min-width:0}.cngx-alert__title{display:block;font-weight:var(--cngx-alert-title-weight, 600);margin-bottom:var(--cngx-alert-title-gap, 4px)}.cngx-alert__collapsible{display:grid;grid-template-rows:1fr;transition:grid-template-rows var(--cngx-alert-collapse-duration, .2s) ease}.cngx-alert__collapsible>*{overflow:hidden}.cngx-alert--collapsed .cngx-alert__collapsible{grid-template-rows:0fr}.cngx-alert--collapsed{cursor:pointer}.cngx-alert--collapsed:hover{background:var(--cngx-alert-collapsed-hover-bg, rgba(0, 0, 0, .02))}.cngx-alert__actions:empty{display:none}.cngx-alert__actions{margin-top:var(--cngx-alert-actions-gap, 8px)}.cngx-alert__dismiss{flex-shrink:0}.cngx-alert--hidden{display:none}.cngx-alert--entering{animation:cngx-alert-enter var(--cngx-alert-enter-duration, .2s) ease-out both}.cngx-alert--entering .cngx-alert__icon{animation:cngx-alert-icon-pulse var(--cngx-alert-icon-pulse-duration, .3s) ease-out}.cngx-alert--exiting{animation:cngx-alert-exit var(--cngx-alert-exit-duration, .15s) ease-in both}@keyframes cngx-alert-enter{0%{opacity:0;transform:translateY(calc(-1 * var(--cngx-alert-enter-offset, 8px)))}to{opacity:1;transform:translateY(0)}}@keyframes cngx-alert-exit{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(calc(-1 * var(--cngx-alert-exit-offset, 8px)))}}@keyframes cngx-alert-icon-pulse{0%{transform:scale(1)}50%{transform:scale(1.1)}to{transform:scale(1)}}@media(prefers-reduced-motion:reduce){.cngx-alert--entering,.cngx-alert--entering .cngx-alert__icon,.cngx-alert--exiting{animation:none}.cngx-alert__collapsible{transition:none!important}}.cngx-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: CngxCloseButton, selector: "cngx-close-button", inputs: ["label"] }, { kind: "component", type: CngxSeverityIcon, selector: "cngx-severity-icon", inputs: ["severity", "iconClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1525
+ }
1526
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlert, decorators: [{
1527
+ type: Component,
1528
+ args: [{ selector: 'cngx-alert', standalone: true, imports: [NgComponentOutlet, CngxCloseButton, CngxSeverityIcon], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1529
+ class: 'cngx-alert',
1530
+ '[class.cngx-alert--info]': 'severity() === "info"',
1531
+ '[class.cngx-alert--success]': 'severity() === "success"',
1532
+ '[class.cngx-alert--warning]': 'severity() === "warning"',
1533
+ '[class.cngx-alert--error]': 'severity() === "error"',
1534
+ // Visibility phase classes (drive CSS animations)
1535
+ '[class.cngx-alert--hidden]': 'visibilityPhase() === "hidden"',
1536
+ '[class.cngx-alert--entering]': 'visibilityPhase() === "entering"',
1537
+ '[class.cngx-alert--visible]': 'visibilityPhase() === "visible"',
1538
+ '[class.cngx-alert--exiting]': 'visibilityPhase() === "exiting"',
1539
+ '[class.cngx-alert--collapsed]': 'collapsed()',
1540
+ // ARIA — role present only when visible
1541
+ '[attr.role]': 'isVisible() ? ariaRole() : null',
1542
+ '[attr.aria-atomic]': 'isVisible() ? ariaAtomic() : null',
1543
+ '[attr.aria-label]': 'isVisible() ? (title() || null) : null',
1544
+ '[attr.aria-expanded]': 'collapsible() ? !collapsed() : null',
1545
+ '[attr.aria-busy]': 'isStateBusy() || null',
1546
+ '[attr.hidden]': '!isVisible() || null',
1547
+ '(animationend)': 'handleAnimationEnd($event)',
1548
+ '(pointerenter)': 'handlePointerEnter()',
1549
+ '(pointerleave)': 'handlePointerLeave()',
1550
+ '(focusin)': 'handleFocusIn()',
1551
+ '(focusout)': 'handleFocusOut()',
1552
+ }, template: `
1553
+ <div class="cngx-alert__icon">
1554
+ <ng-content select="[cngxAlertIcon]" />
1555
+ @if (globalIcon(); as iconCmp) {
1556
+ @if (!customIcon()) {
1557
+ <ng-container *ngComponentOutlet="iconCmp" />
1558
+ }
1559
+ } @else if (!customIcon()) {
1560
+ <cngx-severity-icon [severity]="severity()" iconClass="cngx-alert__default-icon" />
1561
+ }
1562
+ </div>
1563
+ <div class="cngx-alert__body">
1564
+ @if (title()) {
1565
+ <strong class="cngx-alert__title">{{ title() }}</strong>
1566
+ }
1567
+ <div class="cngx-alert__collapsible">
1568
+ <div class="cngx-alert__content">
1569
+ <ng-content />
1570
+ </div>
1571
+ <div class="cngx-alert__actions">
1572
+ <ng-content select="[cngxAlertAction]" />
1573
+ </div>
1574
+ </div>
1575
+ </div>
1576
+ @if (effectiveClosable()) {
1577
+ <cngx-close-button label="Dismiss" class="cngx-alert__dismiss" (click)="handleDismiss()" />
1578
+ }
1579
+ <span class="cngx-sr-only" aria-live="polite" aria-atomic="true">{{ announcement() }}</span>
1580
+ `, styles: [".cngx-alert{display:flex;align-items:flex-start;gap:var(--cngx-alert-gap, 12px);padding:var(--cngx-alert-padding, 12px 16px);border-radius:var(--cngx-alert-border-radius, 8px);border:1px solid var(--cngx-alert-border-color, transparent);background:var(--cngx-alert-bg, #f8fafc);color:var(--cngx-alert-color, inherit)}.cngx-alert--info{--cngx-alert-bg: var(--cngx-alert-info-bg, #eff6ff);--cngx-alert-border-color: var(--cngx-alert-info-border, #bfdbfe);--cngx-alert-icon-color: var(--cngx-alert-info-icon, #3b82f6)}.cngx-alert--success{--cngx-alert-bg: var(--cngx-alert-success-bg, #f0fdf4);--cngx-alert-border-color: var(--cngx-alert-success-border, #bbf7d0);--cngx-alert-icon-color: var(--cngx-alert-success-icon, #22c55e)}.cngx-alert--warning{--cngx-alert-bg: var(--cngx-alert-warning-bg, #fffbeb);--cngx-alert-border-color: var(--cngx-alert-warning-border, #fde68a);--cngx-alert-icon-color: var(--cngx-alert-warning-icon, #f59e0b)}.cngx-alert--error{--cngx-alert-bg: var(--cngx-alert-error-bg, #fef2f2);--cngx-alert-border-color: var(--cngx-alert-error-border, #fecaca);--cngx-alert-icon-color: var(--cngx-alert-error-icon, #ef4444)}.cngx-alert__icon{flex-shrink:0;color:var(--cngx-alert-icon-color, currentColor)}.cngx-alert__default-icon{width:var(--cngx-alert-icon-size, 20px);height:var(--cngx-alert-icon-size, 20px)}.cngx-alert__body{flex:1;min-width:0}.cngx-alert__title{display:block;font-weight:var(--cngx-alert-title-weight, 600);margin-bottom:var(--cngx-alert-title-gap, 4px)}.cngx-alert__collapsible{display:grid;grid-template-rows:1fr;transition:grid-template-rows var(--cngx-alert-collapse-duration, .2s) ease}.cngx-alert__collapsible>*{overflow:hidden}.cngx-alert--collapsed .cngx-alert__collapsible{grid-template-rows:0fr}.cngx-alert--collapsed{cursor:pointer}.cngx-alert--collapsed:hover{background:var(--cngx-alert-collapsed-hover-bg, rgba(0, 0, 0, .02))}.cngx-alert__actions:empty{display:none}.cngx-alert__actions{margin-top:var(--cngx-alert-actions-gap, 8px)}.cngx-alert__dismiss{flex-shrink:0}.cngx-alert--hidden{display:none}.cngx-alert--entering{animation:cngx-alert-enter var(--cngx-alert-enter-duration, .2s) ease-out both}.cngx-alert--entering .cngx-alert__icon{animation:cngx-alert-icon-pulse var(--cngx-alert-icon-pulse-duration, .3s) ease-out}.cngx-alert--exiting{animation:cngx-alert-exit var(--cngx-alert-exit-duration, .15s) ease-in both}@keyframes cngx-alert-enter{0%{opacity:0;transform:translateY(calc(-1 * var(--cngx-alert-enter-offset, 8px)))}to{opacity:1;transform:translateY(0)}}@keyframes cngx-alert-exit{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(calc(-1 * var(--cngx-alert-exit-offset, 8px)))}}@keyframes cngx-alert-icon-pulse{0%{transform:scale(1)}50%{transform:scale(1.1)}to{transform:scale(1)}}@media(prefers-reduced-motion:reduce){.cngx-alert--entering,.cngx-alert--entering .cngx-alert__icon,.cngx-alert--exiting{animation:none}.cngx-alert__collapsible{transition:none!important}}.cngx-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}\n"] }]
1581
+ }], ctorParameters: () => [], propDecorators: { severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], when: [{ type: i0.Input, args: [{ isSignal: true, alias: "when", required: false }] }], autoDismissDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoDismissDelay", required: false }] }], collapsible: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapsible", required: false }] }], collapseDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "collapseDelay", required: false }] }], dismissed: [{ type: i0.Output, args: ["dismissed"] }], customIcon: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxAlertIcon), { isSignal: true }] }], hasActions: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxAlertAction), { isSignal: true }] }] } });
1582
+
1583
+ /**
1584
+ * Scoped alert stack — renders alerts from its own `CngxAlerter` instance.
1585
+ *
1586
+ * Provides `CngxAlerter` via `viewProviders` — child components that
1587
+ * `inject(CngxAlerter)` get this stack's instance. Supports nesting
1588
+ * (each stack is independent).
1589
+ *
1590
+ * ### In a dialog
1591
+ * ```html
1592
+ * <dialog cngxDialog [submitAction]="save">
1593
+ * <header cngxDialogTitle>Edit user</header>
1594
+ * <cngx-alert-stack scope="user-form" position="top" />
1595
+ * <form>...</form>
1596
+ * </dialog>
1597
+ * ```
1598
+ *
1599
+ * ### Programmatic usage
1600
+ * ```typescript
1601
+ * private readonly alerter = inject(CngxAlerter);
1602
+ *
1603
+ * handleErrors(errors: string[]) {
1604
+ * this.alerter.dismissAll();
1605
+ * errors.forEach(e => this.alerter.show({ message: e, severity: 'error' }));
1606
+ * }
1607
+ * ```
1608
+ */
1609
+ class CngxAlertStack {
1610
+ /** The scoped alerter instance — use to add/dismiss alerts programmatically. */
1611
+ alerter = inject(CngxAlerter);
1612
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
1613
+ /** Scope filter — only shows alerts matching this scope. */
1614
+ scope = input(undefined, ...(ngDevMode ? [{ debugName: "scope" }] : /* istanbul ignore next */ []));
1615
+ /** Maximum visible alerts before collapse overflow. */
1616
+ maxVisible = input(5, ...(ngDevMode ? [{ debugName: "maxVisible" }] : /* istanbul ignore next */ []));
1617
+ /** Where new alerts appear. */
1618
+ position = input('top', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
1619
+ /** Reserve min-height for one alert to prevent layout shift. */
1620
+ reserveSpace = input(false, ...(ngDevMode ? [{ debugName: "reserveSpace" }] : /* istanbul ignore next */ []));
1621
+ /** Auto-scroll stack into view when new alert appears. */
1622
+ autoScroll = input(true, ...(ngDevMode ? [{ debugName: "autoScroll" }] : /* istanbul ignore next */ []));
1623
+ /** @internal — expanded state. Resets when alert count drops to maxVisible or below. */
1624
+ expanded = linkedSignal({ ...(ngDevMode ? { debugName: "expanded" } : /* istanbul ignore next */ {}), source: () => this.scopedAlerts().length <= this.maxVisible(),
1625
+ computation: (fitsInMax, previous) => (fitsInMax ? false : (previous?.value ?? false)) });
1626
+ /** @internal — alerts filtered by scope. */
1627
+ scopedAlerts = computed(() => {
1628
+ const s = this.scope();
1629
+ const all = this.alerter.alerts();
1630
+ return s !== undefined ? all.filter((a) => a.config.scope === s) : all;
1631
+ }, ...(ngDevMode ? [{ debugName: "scopedAlerts" }] : /* istanbul ignore next */ []));
1632
+ /** @internal — alerts visible within maxVisible limit. */
1633
+ visibleAlerts = computed(() => {
1634
+ const all = this.scopedAlerts();
1635
+ if (this.expanded()) {
1636
+ return all;
1637
+ }
1638
+ const max = this.maxVisible();
1639
+ return all.length > max ? all.slice(0, max) : all;
1640
+ }, ...(ngDevMode ? [{ debugName: "visibleAlerts" }] : /* istanbul ignore next */ []));
1641
+ /** @internal — number of hidden overflow alerts. */
1642
+ overflowCount = computed(() => {
1643
+ if (this.expanded()) {
1644
+ return 0;
1645
+ }
1646
+ return Math.max(0, this.scopedAlerts().length - this.maxVisible());
1647
+ }, ...(ngDevMode ? [{ debugName: "overflowCount" }] : /* istanbul ignore next */ []));
1648
+ /** @internal — IDs of overflow alerts for aria-controls. */
1649
+ overflowIds = computed(() => this.scopedAlerts()
1650
+ .slice(this.maxVisible())
1651
+ .map((a) => `cngx-alert-${a.id}`)
1652
+ .join(' '), ...(ngDevMode ? [{ debugName: "overflowIds" }] : /* istanbul ignore next */ []));
1653
+ /** @internal — resolve icon component from global config. */
1654
+ iconFor(alert) {
1655
+ return this.config?.alertIcons?.[alert.config.severity] ?? null;
1656
+ }
1657
+ /** @internal */
1658
+ handleExpandOverflow() {
1659
+ this.expanded.set(true);
1660
+ }
1661
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertStack, deps: [], target: i0.ɵɵFactoryTarget.Component });
1662
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxAlertStack, isStandalone: true, selector: "cngx-alert-stack", inputs: { scope: { classPropertyName: "scope", publicName: "scope", isSignal: true, isRequired: false, transformFunction: null }, maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null }, position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, reserveSpace: { classPropertyName: "reserveSpace", publicName: "reserveSpace", isSignal: true, isRequired: false, transformFunction: null }, autoScroll: { classPropertyName: "autoScroll", publicName: "autoScroll", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "log", "aria-live": "polite" }, properties: { "class.cngx-alert-stack--reserve-space": "reserveSpace()" }, classAttribute: "cngx-alert-stack" }, ngImport: i0, template: `
1663
+ @for (alert of visibleAlerts(); track alert.id) {
1664
+ <div
1665
+ [id]="'cngx-alert-' + alert.id"
1666
+ class="cngx-alert-stack__item"
1667
+ [class.cngx-alert-stack__item--info]="alert.config.severity === 'info'"
1668
+ [class.cngx-alert-stack__item--success]="alert.config.severity === 'success'"
1669
+ [class.cngx-alert-stack__item--warning]="alert.config.severity === 'warning'"
1670
+ [class.cngx-alert-stack__item--error]="alert.config.severity === 'error'"
1671
+ [attr.role]="
1672
+ alert.config.severity === 'error' || alert.config.severity === 'warning'
1673
+ ? 'alert'
1674
+ : 'status'
1675
+ "
1676
+ >
1677
+ <div class="cngx-alert-stack__icon">
1678
+ @if (iconFor(alert); as iconCmp) {
1679
+ <ng-container *ngComponentOutlet="iconCmp" />
1680
+ } @else {
1681
+ <cngx-severity-icon
1682
+ [severity]="alert.config.severity"
1683
+ iconClass="cngx-alert-stack__default-icon"
1684
+ />
1685
+ }
1686
+ </div>
1687
+ <div class="cngx-alert-stack__body">
1688
+ @if (alert.config.title) {
1689
+ <strong class="cngx-alert-stack__title">{{ alert.config.title }}</strong>
1690
+ }
1691
+ <span class="cngx-alert-stack__message">{{ alert.config.message }}</span>
1692
+ </div>
1693
+ @if (alert.config.dismissible) {
1694
+ <cngx-close-button
1695
+ label="Dismiss"
1696
+ class="cngx-alert-stack__dismiss"
1697
+ (click)="alerter.dismiss(alert.id)"
1698
+ />
1699
+ }
1700
+ </div>
1701
+ }
1702
+ @if (overflowCount() > 0) {
1703
+ <button
1704
+ type="button"
1705
+ class="cngx-alert-stack__overflow"
1706
+ [attr.aria-expanded]="false"
1707
+ [attr.aria-controls]="overflowIds()"
1708
+ (click)="handleExpandOverflow()"
1709
+ >
1710
+ + {{ overflowCount() }} more
1711
+ </button>
1712
+ }
1713
+ `, isInline: true, styles: [".cngx-alert-stack{display:flex;flex-direction:column;gap:var(--cngx-alert-stack-gap, 8px)}.cngx-alert-stack--reserve-space{min-height:var(--cngx-alert-stack-reserve-height, 56px)}.cngx-alert-stack__item{display:flex;align-items:flex-start;gap:var(--cngx-alert-gap, 12px);padding:var(--cngx-alert-padding, 12px 16px);border-radius:var(--cngx-alert-border-radius, 8px);border:1px solid var(--cngx-alert-border-color, transparent);background:var(--cngx-alert-bg, #f8fafc);color:var(--cngx-alert-color, inherit);animation:cngx-alert-enter var(--cngx-alert-enter-duration, .2s) ease-out both}.cngx-alert-stack__item--info{--cngx-alert-bg: var(--cngx-alert-info-bg, #eff6ff);--cngx-alert-border-color: var(--cngx-alert-info-border, #bfdbfe);--cngx-alert-icon-color: var(--cngx-alert-info-icon, #3b82f6)}.cngx-alert-stack__item--success{--cngx-alert-bg: var(--cngx-alert-success-bg, #f0fdf4);--cngx-alert-border-color: var(--cngx-alert-success-border, #bbf7d0);--cngx-alert-icon-color: var(--cngx-alert-success-icon, #22c55e)}.cngx-alert-stack__item--warning{--cngx-alert-bg: var(--cngx-alert-warning-bg, #fffbeb);--cngx-alert-border-color: var(--cngx-alert-warning-border, #fde68a);--cngx-alert-icon-color: var(--cngx-alert-warning-icon, #f59e0b)}.cngx-alert-stack__item--error{--cngx-alert-bg: var(--cngx-alert-error-bg, #fef2f2);--cngx-alert-border-color: var(--cngx-alert-error-border, #fecaca);--cngx-alert-icon-color: var(--cngx-alert-error-icon, #ef4444)}.cngx-alert-stack__icon{flex-shrink:0;color:var(--cngx-alert-icon-color, currentColor)}.cngx-alert-stack__default-icon{width:var(--cngx-alert-icon-size, 20px);height:var(--cngx-alert-icon-size, 20px)}.cngx-alert-stack__body{flex:1;min-width:0}.cngx-alert-stack__title{display:block;font-weight:var(--cngx-alert-title-weight, 600);margin-bottom:var(--cngx-alert-title-gap, 4px)}.cngx-alert-stack__message{font-size:var(--cngx-alert-stack-message-size, .875rem);line-height:var(--cngx-alert-stack-message-line-height, 1.5)}.cngx-alert-stack__dismiss{flex-shrink:0}.cngx-alert-stack__overflow{appearance:none;background:var(--cngx-alert-stack-overflow-bg, transparent);border:1px dashed var(--cngx-alert-stack-overflow-border, #cbd5e1);border-radius:var(--cngx-alert-border-radius, 8px);padding:var(--cngx-alert-stack-overflow-padding, 8px 16px);cursor:pointer;font-size:var(--cngx-alert-stack-overflow-size, .8125rem);color:var(--cngx-alert-stack-overflow-color, #64748b);text-align:center;width:100%}.cngx-alert-stack__overflow:hover{background:var(--cngx-alert-stack-overflow-hover-bg, #f1f5f9)}.cngx-alert-stack__overflow:focus-visible{outline:2px solid currentColor;outline-offset:2px}@keyframes cngx-alert-enter{0%{opacity:0;transform:translateY(calc(-1 * var(--cngx-alert-enter-offset, 8px)))}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.cngx-alert-stack__item{animation:none}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: CngxCloseButton, selector: "cngx-close-button", inputs: ["label"] }, { kind: "component", type: CngxSeverityIcon, selector: "cngx-severity-icon", inputs: ["severity", "iconClass"] }], viewProviders: [CngxAlerter], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1714
+ }
1715
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertStack, decorators: [{
1716
+ type: Component,
1717
+ args: [{ selector: 'cngx-alert-stack', standalone: true, imports: [NgComponentOutlet, CngxCloseButton, CngxSeverityIcon], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, viewProviders: [CngxAlerter], host: {
1718
+ class: 'cngx-alert-stack',
1719
+ role: 'log',
1720
+ 'aria-live': 'polite',
1721
+ '[class.cngx-alert-stack--reserve-space]': 'reserveSpace()',
1722
+ }, template: `
1723
+ @for (alert of visibleAlerts(); track alert.id) {
1724
+ <div
1725
+ [id]="'cngx-alert-' + alert.id"
1726
+ class="cngx-alert-stack__item"
1727
+ [class.cngx-alert-stack__item--info]="alert.config.severity === 'info'"
1728
+ [class.cngx-alert-stack__item--success]="alert.config.severity === 'success'"
1729
+ [class.cngx-alert-stack__item--warning]="alert.config.severity === 'warning'"
1730
+ [class.cngx-alert-stack__item--error]="alert.config.severity === 'error'"
1731
+ [attr.role]="
1732
+ alert.config.severity === 'error' || alert.config.severity === 'warning'
1733
+ ? 'alert'
1734
+ : 'status'
1735
+ "
1736
+ >
1737
+ <div class="cngx-alert-stack__icon">
1738
+ @if (iconFor(alert); as iconCmp) {
1739
+ <ng-container *ngComponentOutlet="iconCmp" />
1740
+ } @else {
1741
+ <cngx-severity-icon
1742
+ [severity]="alert.config.severity"
1743
+ iconClass="cngx-alert-stack__default-icon"
1744
+ />
1745
+ }
1746
+ </div>
1747
+ <div class="cngx-alert-stack__body">
1748
+ @if (alert.config.title) {
1749
+ <strong class="cngx-alert-stack__title">{{ alert.config.title }}</strong>
1750
+ }
1751
+ <span class="cngx-alert-stack__message">{{ alert.config.message }}</span>
1752
+ </div>
1753
+ @if (alert.config.dismissible) {
1754
+ <cngx-close-button
1755
+ label="Dismiss"
1756
+ class="cngx-alert-stack__dismiss"
1757
+ (click)="alerter.dismiss(alert.id)"
1758
+ />
1759
+ }
1760
+ </div>
1761
+ }
1762
+ @if (overflowCount() > 0) {
1763
+ <button
1764
+ type="button"
1765
+ class="cngx-alert-stack__overflow"
1766
+ [attr.aria-expanded]="false"
1767
+ [attr.aria-controls]="overflowIds()"
1768
+ (click)="handleExpandOverflow()"
1769
+ >
1770
+ + {{ overflowCount() }} more
1771
+ </button>
1772
+ }
1773
+ `, styles: [".cngx-alert-stack{display:flex;flex-direction:column;gap:var(--cngx-alert-stack-gap, 8px)}.cngx-alert-stack--reserve-space{min-height:var(--cngx-alert-stack-reserve-height, 56px)}.cngx-alert-stack__item{display:flex;align-items:flex-start;gap:var(--cngx-alert-gap, 12px);padding:var(--cngx-alert-padding, 12px 16px);border-radius:var(--cngx-alert-border-radius, 8px);border:1px solid var(--cngx-alert-border-color, transparent);background:var(--cngx-alert-bg, #f8fafc);color:var(--cngx-alert-color, inherit);animation:cngx-alert-enter var(--cngx-alert-enter-duration, .2s) ease-out both}.cngx-alert-stack__item--info{--cngx-alert-bg: var(--cngx-alert-info-bg, #eff6ff);--cngx-alert-border-color: var(--cngx-alert-info-border, #bfdbfe);--cngx-alert-icon-color: var(--cngx-alert-info-icon, #3b82f6)}.cngx-alert-stack__item--success{--cngx-alert-bg: var(--cngx-alert-success-bg, #f0fdf4);--cngx-alert-border-color: var(--cngx-alert-success-border, #bbf7d0);--cngx-alert-icon-color: var(--cngx-alert-success-icon, #22c55e)}.cngx-alert-stack__item--warning{--cngx-alert-bg: var(--cngx-alert-warning-bg, #fffbeb);--cngx-alert-border-color: var(--cngx-alert-warning-border, #fde68a);--cngx-alert-icon-color: var(--cngx-alert-warning-icon, #f59e0b)}.cngx-alert-stack__item--error{--cngx-alert-bg: var(--cngx-alert-error-bg, #fef2f2);--cngx-alert-border-color: var(--cngx-alert-error-border, #fecaca);--cngx-alert-icon-color: var(--cngx-alert-error-icon, #ef4444)}.cngx-alert-stack__icon{flex-shrink:0;color:var(--cngx-alert-icon-color, currentColor)}.cngx-alert-stack__default-icon{width:var(--cngx-alert-icon-size, 20px);height:var(--cngx-alert-icon-size, 20px)}.cngx-alert-stack__body{flex:1;min-width:0}.cngx-alert-stack__title{display:block;font-weight:var(--cngx-alert-title-weight, 600);margin-bottom:var(--cngx-alert-title-gap, 4px)}.cngx-alert-stack__message{font-size:var(--cngx-alert-stack-message-size, .875rem);line-height:var(--cngx-alert-stack-message-line-height, 1.5)}.cngx-alert-stack__dismiss{flex-shrink:0}.cngx-alert-stack__overflow{appearance:none;background:var(--cngx-alert-stack-overflow-bg, transparent);border:1px dashed var(--cngx-alert-stack-overflow-border, #cbd5e1);border-radius:var(--cngx-alert-border-radius, 8px);padding:var(--cngx-alert-stack-overflow-padding, 8px 16px);cursor:pointer;font-size:var(--cngx-alert-stack-overflow-size, .8125rem);color:var(--cngx-alert-stack-overflow-color, #64748b);text-align:center;width:100%}.cngx-alert-stack__overflow:hover{background:var(--cngx-alert-stack-overflow-hover-bg, #f1f5f9)}.cngx-alert-stack__overflow:focus-visible{outline:2px solid currentColor;outline-offset:2px}@keyframes cngx-alert-enter{0%{opacity:0;transform:translateY(calc(-1 * var(--cngx-alert-enter-offset, 8px)))}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.cngx-alert-stack__item{animation:none}}\n"] }]
1774
+ }], propDecorators: { scope: [{ type: i0.Input, args: [{ isSignal: true, alias: "scope", required: false }] }], maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }], position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], reserveSpace: [{ type: i0.Input, args: [{ isSignal: true, alias: "reserveSpace", required: false }] }], autoScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoScroll", required: false }] }] } });
1775
+
1776
+ /**
1777
+ * Declarative state-to-alert bridge for scoped alert stacks.
1778
+ *
1779
+ * Place on any element inside a `CngxAlertStack` subtree — fires an alert
1780
+ * when the bound `CngxAsyncState` transitions to `error` (or optionally `success`).
1781
+ * Only fires on actual transitions, not on initial `idle` state.
1782
+ *
1783
+ * ```html
1784
+ * <cngx-alert-stack scope="form" />
1785
+ *
1786
+ * <button [cngxAsyncClick]="save"
1787
+ * [cngxAlertOn]="saveState"
1788
+ * alertError="Save failed"
1789
+ * [alertErrorDetail]="true">
1790
+ * Save
1791
+ * </button>
1792
+ * ```
1793
+ */
1794
+ class CngxAlertOn {
1795
+ alerter = inject(CngxAlerter, { optional: true });
1796
+ statefulFallback = inject(CNGX_STATEFUL, { optional: true });
1797
+ /**
1798
+ * The async state to watch. Optional — when omitted, falls back to
1799
+ * `CNGX_STATEFUL` from an ancestor/self component. A bare `cngxAlertOn`
1800
+ * attribute is treated as "no input bound".
1801
+ */
1802
+ state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), alias: 'cngxAlertOn',
1803
+ transform: (v) => (typeof v === 'string' ? undefined : v) });
1804
+ /** Effective state — input wins over ancestor `CNGX_STATEFUL`. */
1805
+ effectiveState = computed(() => this.state() ?? this.statefulFallback?.state, ...(ngDevMode ? [{ debugName: "effectiveState" }] : /* istanbul ignore next */ []));
1806
+ /** Alert message on success. If not set, no success alert fires. */
1807
+ alertSuccess = input(undefined, ...(ngDevMode ? [{ debugName: "alertSuccess" }] : /* istanbul ignore next */ []));
1808
+ /** Alert message on error. If not set, no error alert fires. */
1809
+ alertError = input(undefined, ...(ngDevMode ? [{ debugName: "alertError" }] : /* istanbul ignore next */ []));
1810
+ /** Include the error detail message in the alert body. */
1811
+ alertErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "alertErrorDetail" }] : /* istanbul ignore next */ []));
1812
+ /** Scope for the alert — matches against `CngxAlertStack`'s `[scope]` input. */
1813
+ alertScope = input(undefined, ...(ngDevMode ? [{ debugName: "alertScope" }] : /* istanbul ignore next */ []));
1814
+ constructor() {
1815
+ if (!this.alerter) {
1816
+ throw new Error('[cngxAlertOn] CngxAlerter not found. ' +
1817
+ 'Place inside a CngxAlertStack subtree or add withAlerts() to provideFeedback().');
1818
+ }
1819
+ const alerter = this.alerter;
1820
+ if (isDevMode()) {
1821
+ // One-shot post-binding check — runs once after inputs are bound. Uses
1822
+ // afterNextRender instead of an effect so we don't leave a dead node in
1823
+ // the reactive graph for the lifetime of the directive.
1824
+ afterNextRender(() => {
1825
+ if (this.state() === undefined && !this.statefulFallback) {
1826
+ console.error('[cngxAlertOn] No state source. Bind [cngxAlertOn]="state" explicitly or ' +
1827
+ 'place inside a component that provides CNGX_STATEFUL.');
1828
+ }
1829
+ });
1830
+ }
1831
+ const tracker = createTransitionTracker(() => this.effectiveState()?.status() ?? 'idle');
1832
+ effect(() => {
1833
+ // Only tracker is tracked. All other signal reads happen inside untracked()
1834
+ // below to keep the effect's dependency graph flat.
1835
+ const status = tracker.current();
1836
+ const previous = tracker.previous();
1837
+ if (status === previous) {
1838
+ return;
1839
+ }
1840
+ untracked(() => {
1841
+ const s = this.effectiveState();
1842
+ if (!s) {
1843
+ return;
1844
+ }
1845
+ if (status === 'success') {
1846
+ const msg = this.alertSuccess();
1847
+ if (msg) {
1848
+ alerter.show({
1849
+ message: msg,
1850
+ severity: 'success',
1851
+ persistent: false,
1852
+ scope: this.alertScope(),
1853
+ });
1854
+ }
1855
+ }
1856
+ if (status === 'error') {
1857
+ const msg = this.alertError();
1858
+ if (msg) {
1859
+ const err = s.error();
1860
+ const detail = this.alertErrorDetail() && err != null
1861
+ ? err instanceof Error
1862
+ ? err.message
1863
+ : typeof err === 'string'
1864
+ ? err
1865
+ : undefined
1866
+ : undefined;
1867
+ alerter.show({
1868
+ message: detail ? `${msg}: ${detail}` : msg,
1869
+ severity: 'error',
1870
+ scope: this.alertScope(),
1871
+ });
1872
+ }
1873
+ }
1874
+ });
1875
+ });
1876
+ }
1877
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertOn, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1878
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxAlertOn, isStandalone: true, selector: "[cngxAlertOn]", inputs: { state: { classPropertyName: "state", publicName: "cngxAlertOn", isSignal: true, isRequired: false, transformFunction: null }, alertSuccess: { classPropertyName: "alertSuccess", publicName: "alertSuccess", isSignal: true, isRequired: false, transformFunction: null }, alertError: { classPropertyName: "alertError", publicName: "alertError", isSignal: true, isRequired: false, transformFunction: null }, alertErrorDetail: { classPropertyName: "alertErrorDetail", publicName: "alertErrorDetail", isSignal: true, isRequired: false, transformFunction: null }, alertScope: { classPropertyName: "alertScope", publicName: "alertScope", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
1879
+ }
1880
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAlertOn, decorators: [{
1881
+ type: Directive,
1882
+ args: [{
1883
+ selector: '[cngxAlertOn]',
1884
+ standalone: true,
1885
+ }]
1886
+ }], ctorParameters: () => [], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxAlertOn", required: false }] }], alertSuccess: [{ type: i0.Input, args: [{ isSignal: true, alias: "alertSuccess", required: false }] }], alertError: [{ type: i0.Input, args: [{ isSignal: true, alias: "alertError", required: false }] }], alertErrorDetail: [{ type: i0.Input, args: [{ isSignal: true, alias: "alertErrorDetail", required: false }] }], alertScope: [{ type: i0.Input, args: [{ isSignal: true, alias: "alertScope", required: false }] }] } });
1887
+
1888
+ /**
1889
+ * Banner outlet — renders the global banner stack at the top of the page.
1890
+ *
1891
+ * Place once in the app shell, above `<router-outlet>`.
1892
+ * Requires `provideFeedback(withBanners())`.
1893
+ *
1894
+ * Banners present at first render appear without animation to avoid
1895
+ * layout jump on page load.
1896
+ *
1897
+ * ```html
1898
+ * <cngx-banner-outlet />
1899
+ * <router-outlet />
1900
+ * ```
1901
+ */
1902
+ class CngxBannerOutlet {
1903
+ service = inject(CngxBanner);
1904
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
1905
+ /**
1906
+ * @internal — skip enter animation for banners present at first render.
1907
+ * Prevents layout jump when banners are known before first paint (e.g., offline state).
1908
+ */
1909
+ pastFirstRender = signal(false, ...(ngDevMode ? [{ debugName: "pastFirstRender" }] : /* istanbul ignore next */ []));
1910
+ constructor() {
1911
+ afterNextRender(() => this.pastFirstRender.set(true));
1912
+ }
1913
+ /** @internal — resolve icon from global config. */
1914
+ iconFor(banner) {
1915
+ return this.config?.alertIcons?.[banner.config.severity] ?? null;
1916
+ }
1917
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBannerOutlet, deps: [], target: i0.ɵɵFactoryTarget.Component });
1918
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxBannerOutlet, isStandalone: true, selector: "cngx-banner-outlet", host: { classAttribute: "cngx-banner-outlet" }, ngImport: i0, template: `
1919
+ @for (banner of service.banners(); track banner.id) {
1920
+ <div
1921
+ class="cngx-banner"
1922
+ [class.cngx-banner--info]="banner.config.severity === 'info'"
1923
+ [class.cngx-banner--success]="banner.config.severity === 'success'"
1924
+ [class.cngx-banner--warning]="banner.config.severity === 'warning'"
1925
+ [class.cngx-banner--error]="banner.config.severity === 'error'"
1926
+ [class.cngx-banner--animate]="pastFirstRender()"
1927
+ [class.cngx-banner--pending]="banner.actionPending"
1928
+ [attr.role]="
1929
+ banner.config.severity === 'error' || banner.config.severity === 'warning'
1930
+ ? 'alert'
1931
+ : 'status'
1932
+ "
1933
+ [attr.aria-live]="banner.config.severity === 'error' ? 'assertive' : 'polite'"
1934
+ [attr.aria-busy]="banner.actionPending || null"
1935
+ >
1936
+ <div class="cngx-banner__icon">
1937
+ @if (iconFor(banner); as iconCmp) {
1938
+ <ng-container *ngComponentOutlet="iconCmp" />
1939
+ } @else {
1940
+ <cngx-severity-icon
1941
+ [severity]="banner.config.severity"
1942
+ iconClass="cngx-banner__default-icon"
1943
+ />
1944
+ }
1945
+ </div>
1946
+ <div class="cngx-banner__body">
1947
+ <span class="cngx-banner__message">{{ banner.config.message }}</span>
1948
+ @if (banner.actionError) {
1949
+ <span class="cngx-banner__error" role="alert">Action failed</span>
1950
+ }
1951
+ </div>
1952
+ @if (banner.config.action; as action) {
1953
+ <button
1954
+ type="button"
1955
+ class="cngx-banner__action"
1956
+ [disabled]="banner.actionPending"
1957
+ [attr.aria-busy]="banner.actionPending || null"
1958
+ (click)="service.executeAction(banner.id)"
1959
+ >
1960
+ {{ action.label }}
1961
+ </button>
1962
+ }
1963
+ @if (banner.config.dismissible && !banner.actionPending) {
1964
+ <cngx-close-button
1965
+ label="Dismiss"
1966
+ class="cngx-banner__dismiss"
1967
+ (click)="service.dismiss(banner.id)"
1968
+ />
1969
+ }
1970
+ </div>
1971
+ }
1972
+ `, isInline: true, styles: [".cngx-banner-outlet{display:block;position:sticky;top:0;z-index:var(--cngx-banner-z-index, 900);width:100%}.cngx-banner-outlet:empty{display:none}.cngx-banner{display:flex;align-items:center;gap:var(--cngx-banner-gap, 12px);padding:var(--cngx-banner-padding, 10px 16px);background:var(--cngx-banner-bg, #f8fafc);color:var(--cngx-banner-color, inherit);border-bottom:1px solid var(--cngx-banner-border-color, transparent)}.cngx-banner--animate{animation:cngx-banner-enter var(--cngx-banner-enter-duration, .2s) ease-out both}.cngx-banner--info{--cngx-banner-bg: var(--cngx-banner-info-bg, #eff6ff);--cngx-banner-border-color: var(--cngx-banner-info-border, #bfdbfe);--cngx-banner-icon-color: var(--cngx-banner-info-icon, #3b82f6);--cngx-banner-accent: var(--cngx-banner-info-icon, #3b82f6)}.cngx-banner--success{--cngx-banner-bg: var(--cngx-banner-success-bg, #f0fdf4);--cngx-banner-border-color: var(--cngx-banner-success-border, #bbf7d0);--cngx-banner-icon-color: var(--cngx-banner-success-icon, #22c55e);--cngx-banner-accent: var(--cngx-banner-success-icon, #22c55e)}.cngx-banner--warning{--cngx-banner-bg: var(--cngx-banner-warning-bg, #fffbeb);--cngx-banner-border-color: var(--cngx-banner-warning-border, #fde68a);--cngx-banner-icon-color: var(--cngx-banner-warning-icon, #f59e0b);--cngx-banner-accent: var(--cngx-banner-warning-icon, #f59e0b)}.cngx-banner--error{--cngx-banner-bg: var(--cngx-banner-error-bg, #fef2f2);--cngx-banner-border-color: var(--cngx-banner-error-border, #fecaca);--cngx-banner-icon-color: var(--cngx-banner-error-icon, #ef4444);--cngx-banner-accent: var(--cngx-banner-error-icon, #ef4444)}.cngx-banner--pending{opacity:var(--cngx-banner-pending-opacity, .85);pointer-events:none}.cngx-banner__icon{flex-shrink:0;color:var(--cngx-banner-icon-color, currentColor)}.cngx-banner__default-icon{width:var(--cngx-banner-icon-size, 20px);height:var(--cngx-banner-icon-size, 20px)}.cngx-banner__body{flex:1;min-width:0}.cngx-banner__message{font-size:var(--cngx-banner-font-size, .9375rem);line-height:var(--cngx-banner-line-height, 1.5)}.cngx-banner__error{display:block;font-size:var(--cngx-banner-error-font-size, .875rem);color:var(--cngx-banner-error-color, #ef4444);margin-top:2px}.cngx-banner__action{appearance:none;background:var(--cngx-banner-action-bg, transparent);border:1px solid var(--cngx-banner-accent, currentColor);border-radius:var(--cngx-banner-action-radius, 4px);padding:var(--cngx-banner-action-padding, 6px 12px);min-width:var(--cngx-banner-action-min-size, 44px);min-height:var(--cngx-banner-action-min-size, 44px);cursor:pointer;font-size:var(--cngx-banner-action-font-size, .875rem);font-weight:var(--cngx-banner-action-font-weight, 600);color:var(--cngx-banner-accent, currentColor);white-space:nowrap;flex-shrink:0}.cngx-banner__action:hover:not(:disabled){background:var(--cngx-banner-action-hover-bg, rgba(0, 0, 0, .04))}.cngx-banner__action:focus-visible{outline:2px solid currentColor;outline-offset:2px}.cngx-banner__action:disabled{cursor:not-allowed;opacity:.6}.cngx-banner__dismiss{flex-shrink:0}@keyframes cngx-banner-enter{0%{opacity:0;transform:translateY(calc(-1 * var(--cngx-banner-enter-offset, 100%)))}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.cngx-banner--animate{animation:none}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: CngxCloseButton, selector: "cngx-close-button", inputs: ["label"] }, { kind: "component", type: CngxSeverityIcon, selector: "cngx-severity-icon", inputs: ["severity", "iconClass"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1973
+ }
1974
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBannerOutlet, decorators: [{
1975
+ type: Component,
1976
+ args: [{ selector: 'cngx-banner-outlet', standalone: true, imports: [NgComponentOutlet, CngxCloseButton, CngxSeverityIcon], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
1977
+ class: 'cngx-banner-outlet',
1978
+ }, template: `
1979
+ @for (banner of service.banners(); track banner.id) {
1980
+ <div
1981
+ class="cngx-banner"
1982
+ [class.cngx-banner--info]="banner.config.severity === 'info'"
1983
+ [class.cngx-banner--success]="banner.config.severity === 'success'"
1984
+ [class.cngx-banner--warning]="banner.config.severity === 'warning'"
1985
+ [class.cngx-banner--error]="banner.config.severity === 'error'"
1986
+ [class.cngx-banner--animate]="pastFirstRender()"
1987
+ [class.cngx-banner--pending]="banner.actionPending"
1988
+ [attr.role]="
1989
+ banner.config.severity === 'error' || banner.config.severity === 'warning'
1990
+ ? 'alert'
1991
+ : 'status'
1992
+ "
1993
+ [attr.aria-live]="banner.config.severity === 'error' ? 'assertive' : 'polite'"
1994
+ [attr.aria-busy]="banner.actionPending || null"
1995
+ >
1996
+ <div class="cngx-banner__icon">
1997
+ @if (iconFor(banner); as iconCmp) {
1998
+ <ng-container *ngComponentOutlet="iconCmp" />
1999
+ } @else {
2000
+ <cngx-severity-icon
2001
+ [severity]="banner.config.severity"
2002
+ iconClass="cngx-banner__default-icon"
2003
+ />
2004
+ }
2005
+ </div>
2006
+ <div class="cngx-banner__body">
2007
+ <span class="cngx-banner__message">{{ banner.config.message }}</span>
2008
+ @if (banner.actionError) {
2009
+ <span class="cngx-banner__error" role="alert">Action failed</span>
2010
+ }
2011
+ </div>
2012
+ @if (banner.config.action; as action) {
2013
+ <button
2014
+ type="button"
2015
+ class="cngx-banner__action"
2016
+ [disabled]="banner.actionPending"
2017
+ [attr.aria-busy]="banner.actionPending || null"
2018
+ (click)="service.executeAction(banner.id)"
2019
+ >
2020
+ {{ action.label }}
2021
+ </button>
2022
+ }
2023
+ @if (banner.config.dismissible && !banner.actionPending) {
2024
+ <cngx-close-button
2025
+ label="Dismiss"
2026
+ class="cngx-banner__dismiss"
2027
+ (click)="service.dismiss(banner.id)"
2028
+ />
2029
+ }
2030
+ </div>
2031
+ }
2032
+ `, styles: [".cngx-banner-outlet{display:block;position:sticky;top:0;z-index:var(--cngx-banner-z-index, 900);width:100%}.cngx-banner-outlet:empty{display:none}.cngx-banner{display:flex;align-items:center;gap:var(--cngx-banner-gap, 12px);padding:var(--cngx-banner-padding, 10px 16px);background:var(--cngx-banner-bg, #f8fafc);color:var(--cngx-banner-color, inherit);border-bottom:1px solid var(--cngx-banner-border-color, transparent)}.cngx-banner--animate{animation:cngx-banner-enter var(--cngx-banner-enter-duration, .2s) ease-out both}.cngx-banner--info{--cngx-banner-bg: var(--cngx-banner-info-bg, #eff6ff);--cngx-banner-border-color: var(--cngx-banner-info-border, #bfdbfe);--cngx-banner-icon-color: var(--cngx-banner-info-icon, #3b82f6);--cngx-banner-accent: var(--cngx-banner-info-icon, #3b82f6)}.cngx-banner--success{--cngx-banner-bg: var(--cngx-banner-success-bg, #f0fdf4);--cngx-banner-border-color: var(--cngx-banner-success-border, #bbf7d0);--cngx-banner-icon-color: var(--cngx-banner-success-icon, #22c55e);--cngx-banner-accent: var(--cngx-banner-success-icon, #22c55e)}.cngx-banner--warning{--cngx-banner-bg: var(--cngx-banner-warning-bg, #fffbeb);--cngx-banner-border-color: var(--cngx-banner-warning-border, #fde68a);--cngx-banner-icon-color: var(--cngx-banner-warning-icon, #f59e0b);--cngx-banner-accent: var(--cngx-banner-warning-icon, #f59e0b)}.cngx-banner--error{--cngx-banner-bg: var(--cngx-banner-error-bg, #fef2f2);--cngx-banner-border-color: var(--cngx-banner-error-border, #fecaca);--cngx-banner-icon-color: var(--cngx-banner-error-icon, #ef4444);--cngx-banner-accent: var(--cngx-banner-error-icon, #ef4444)}.cngx-banner--pending{opacity:var(--cngx-banner-pending-opacity, .85);pointer-events:none}.cngx-banner__icon{flex-shrink:0;color:var(--cngx-banner-icon-color, currentColor)}.cngx-banner__default-icon{width:var(--cngx-banner-icon-size, 20px);height:var(--cngx-banner-icon-size, 20px)}.cngx-banner__body{flex:1;min-width:0}.cngx-banner__message{font-size:var(--cngx-banner-font-size, .9375rem);line-height:var(--cngx-banner-line-height, 1.5)}.cngx-banner__error{display:block;font-size:var(--cngx-banner-error-font-size, .875rem);color:var(--cngx-banner-error-color, #ef4444);margin-top:2px}.cngx-banner__action{appearance:none;background:var(--cngx-banner-action-bg, transparent);border:1px solid var(--cngx-banner-accent, currentColor);border-radius:var(--cngx-banner-action-radius, 4px);padding:var(--cngx-banner-action-padding, 6px 12px);min-width:var(--cngx-banner-action-min-size, 44px);min-height:var(--cngx-banner-action-min-size, 44px);cursor:pointer;font-size:var(--cngx-banner-action-font-size, .875rem);font-weight:var(--cngx-banner-action-font-weight, 600);color:var(--cngx-banner-accent, currentColor);white-space:nowrap;flex-shrink:0}.cngx-banner__action:hover:not(:disabled){background:var(--cngx-banner-action-hover-bg, rgba(0, 0, 0, .04))}.cngx-banner__action:focus-visible{outline:2px solid currentColor;outline-offset:2px}.cngx-banner__action:disabled{cursor:not-allowed;opacity:.6}.cngx-banner__dismiss{flex-shrink:0}@keyframes cngx-banner-enter{0%{opacity:0;transform:translateY(calc(-1 * var(--cngx-banner-enter-offset, 100%)))}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.cngx-banner--animate{animation:none}}\n"] }]
2033
+ }], ctorParameters: () => [] });
2034
+
2035
+ /**
2036
+ * Declarative state-to-banner bridge.
2037
+ *
2038
+ * Place on any element — shows a global banner when the bound `CngxAsyncState`
2039
+ * transitions to `error`. Dismisses automatically on `success` or `idle`.
2040
+ * Only fires on actual transitions, not on initial `idle` state.
2041
+ *
2042
+ * ```html
2043
+ * <div [cngxBannerOn]="connectionState"
2044
+ * bannerId="net:offline"
2045
+ * bannerError="You are offline. Changes will sync when reconnected.">
2046
+ * </div>
2047
+ * ```
2048
+ */
2049
+ class CngxBannerOn {
2050
+ bannerService = inject(CngxBanner, { optional: true });
2051
+ statefulFallback = inject(CNGX_STATEFUL, { optional: true });
2052
+ /**
2053
+ * The async state to watch. Optional — when omitted, falls back to
2054
+ * `CNGX_STATEFUL` from an ancestor/self component. A bare `cngxBannerOn`
2055
+ * attribute is treated as "no input bound".
2056
+ */
2057
+ state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), alias: 'cngxBannerOn',
2058
+ transform: (v) => (typeof v === 'string' ? undefined : v) });
2059
+ /** Effective state — input wins over ancestor `CNGX_STATEFUL`. */
2060
+ effectiveState = computed(() => this.state() ?? this.statefulFallback?.state, ...(ngDevMode ? [{ debugName: "effectiveState" }] : /* istanbul ignore next */ []));
2061
+ /** Required banner id — dedup key. */
2062
+ bannerId = input.required(...(ngDevMode ? [{ debugName: "bannerId" }] : /* istanbul ignore next */ []));
2063
+ /** Banner message on error. */
2064
+ bannerError = input(undefined, ...(ngDevMode ? [{ debugName: "bannerError" }] : /* istanbul ignore next */ []));
2065
+ /** Banner severity on error. Default `'error'`. */
2066
+ bannerSeverity = input('error', ...(ngDevMode ? [{ debugName: "bannerSeverity" }] : /* istanbul ignore next */ []));
2067
+ /** Include error detail in the message. */
2068
+ bannerErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "bannerErrorDetail" }] : /* istanbul ignore next */ []));
2069
+ constructor() {
2070
+ if (!this.bannerService) {
2071
+ throw new Error('[cngxBannerOn] CngxBanner not found. ' + 'Add withBanners() to provideFeedback().');
2072
+ }
2073
+ const banner = this.bannerService;
2074
+ if (isDevMode()) {
2075
+ // One-shot post-binding check — runs once after inputs are bound. Uses
2076
+ // afterNextRender instead of an effect so we don't leave a dead node in
2077
+ // the reactive graph for the lifetime of the directive.
2078
+ afterNextRender(() => {
2079
+ if (this.state() === undefined && !this.statefulFallback) {
2080
+ console.error('[cngxBannerOn] No state source. Bind [cngxBannerOn]="state" explicitly or ' +
2081
+ 'place inside a component that provides CNGX_STATEFUL.');
2082
+ }
2083
+ });
2084
+ }
2085
+ const tracker = createTransitionTracker(() => this.effectiveState()?.status() ?? 'idle');
2086
+ effect(() => {
2087
+ // Only tracker is tracked. All other signal reads happen inside untracked()
2088
+ // below to keep the effect's dependency graph flat.
2089
+ const status = tracker.current();
2090
+ const previous = tracker.previous();
2091
+ if (status === previous) {
2092
+ return;
2093
+ }
2094
+ untracked(() => {
2095
+ const s = this.effectiveState();
2096
+ if (!s) {
2097
+ return;
2098
+ }
2099
+ if (status === 'error') {
2100
+ const msg = this.bannerError();
2101
+ if (msg) {
2102
+ const err = s.error();
2103
+ const detail = this.bannerErrorDetail() && err != null
2104
+ ? err instanceof Error
2105
+ ? err.message
2106
+ : typeof err === 'string'
2107
+ ? err
2108
+ : undefined
2109
+ : undefined;
2110
+ banner.show({
2111
+ message: detail ? `${msg}: ${detail}` : msg,
2112
+ id: this.bannerId(),
2113
+ severity: this.bannerSeverity(),
2114
+ });
2115
+ }
2116
+ }
2117
+ // Auto-dismiss on success or idle (condition resolved)
2118
+ if (status === 'success' || status === 'idle') {
2119
+ banner.dismiss(this.bannerId());
2120
+ }
2121
+ });
2122
+ });
2123
+ }
2124
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBannerOn, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2125
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxBannerOn, isStandalone: true, selector: "[cngxBannerOn]", inputs: { state: { classPropertyName: "state", publicName: "cngxBannerOn", isSignal: true, isRequired: false, transformFunction: null }, bannerId: { classPropertyName: "bannerId", publicName: "bannerId", isSignal: true, isRequired: true, transformFunction: null }, bannerError: { classPropertyName: "bannerError", publicName: "bannerError", isSignal: true, isRequired: false, transformFunction: null }, bannerSeverity: { classPropertyName: "bannerSeverity", publicName: "bannerSeverity", isSignal: true, isRequired: false, transformFunction: null }, bannerErrorDetail: { classPropertyName: "bannerErrorDetail", publicName: "bannerErrorDetail", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
2126
+ }
2127
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBannerOn, decorators: [{
2128
+ type: Directive,
2129
+ args: [{
2130
+ selector: '[cngxBannerOn]',
2131
+ standalone: true,
2132
+ }]
2133
+ }], ctorParameters: () => [], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxBannerOn", required: false }] }], bannerId: [{ type: i0.Input, args: [{ isSignal: true, alias: "bannerId", required: true }] }], bannerError: [{ type: i0.Input, args: [{ isSignal: true, alias: "bannerError", required: false }] }], bannerSeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "bannerSeverity", required: false }] }], bannerErrorDetail: [{ type: i0.Input, args: [{ isSignal: true, alias: "bannerErrorDetail", required: false }] }] } });
2134
+
2135
+ /**
2136
+ * Declarative banner trigger — renders nothing, shows/dismisses a global banner
2137
+ * when `[when]` changes.
2138
+ *
2139
+ * When `[when]` becomes `true`, the banner appears. When `false`, it is dismissed.
2140
+ * The banner's lifecycle is tied to the signal — perfect for reactive system state
2141
+ * like `isOffline()` or `sessionExpiring()`.
2142
+ *
2143
+ * Requires `provideFeedback(withBanners())`.
2144
+ *
2145
+ * ```html
2146
+ * <cngx-banner-trigger
2147
+ * [when]="isOffline()"
2148
+ * message="You are offline. Changes will sync when reconnected."
2149
+ * id="net:offline"
2150
+ * severity="error" />
2151
+ *
2152
+ * <cngx-banner-trigger
2153
+ * [when]="sessionExpiring()"
2154
+ * message="Session expires soon."
2155
+ * id="auth:session"
2156
+ * severity="warning"
2157
+ * actionLabel="Extend"
2158
+ * [actionHandler]="extendSession" />
2159
+ * ```
2160
+ */
2161
+ class CngxBannerTrigger {
2162
+ banner = inject(CngxBanner, { optional: true });
2163
+ destroyRef = inject(DestroyRef);
2164
+ /** When `true`, the banner is shown. When `false`, it is dismissed. */
2165
+ when = input.required(...(ngDevMode ? [{ debugName: "when" }] : /* istanbul ignore next */ []));
2166
+ /** Banner message text. */
2167
+ message = input.required(...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
2168
+ /** Required unique id — dedup key. */
2169
+ id = input.required(...(ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []));
2170
+ /** Visual severity. */
2171
+ severity = input('info', ...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
2172
+ /** Show dismiss button. */
2173
+ dismissible = input(true, ...(ngDevMode ? [{ debugName: "dismissible" }] : /* istanbul ignore next */ []));
2174
+ /** Action button label. */
2175
+ actionLabel = input(undefined, ...(ngDevMode ? [{ debugName: "actionLabel" }] : /* istanbul ignore next */ []));
2176
+ /** Action button handler. */
2177
+ actionHandler = input(undefined, ...(ngDevMode ? [{ debugName: "actionHandler" }] : /* istanbul ignore next */ []));
2178
+ constructor() {
2179
+ if (!this.banner) {
2180
+ throw new Error('[cngx-banner-trigger] CngxBanner not found. ' + 'Add withBanners() to provideFeedback().');
2181
+ }
2182
+ const banner = this.banner;
2183
+ effect(() => {
2184
+ const show = this.when();
2185
+ const id = this.id();
2186
+ if (show) {
2187
+ const label = this.actionLabel();
2188
+ const handler = this.actionHandler();
2189
+ banner.show({
2190
+ message: this.message(),
2191
+ id,
2192
+ severity: this.severity(),
2193
+ dismissible: this.dismissible(),
2194
+ action: label && handler ? { label, handler } : undefined,
2195
+ });
2196
+ }
2197
+ else {
2198
+ banner.dismiss(id);
2199
+ }
2200
+ });
2201
+ this.destroyRef.onDestroy(() => {
2202
+ // Dismiss on component destroy if still showing
2203
+ const id = this.id();
2204
+ banner.dismiss(id);
2205
+ });
2206
+ }
2207
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBannerTrigger, deps: [], target: i0.ɵɵFactoryTarget.Component });
2208
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxBannerTrigger, isStandalone: true, selector: "cngx-banner-trigger", inputs: { when: { classPropertyName: "when", publicName: "when", isSignal: true, isRequired: true, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: true, transformFunction: null }, id: { classPropertyName: "id", publicName: "id", isSignal: true, isRequired: true, transformFunction: null }, severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, actionLabel: { classPropertyName: "actionLabel", publicName: "actionLabel", isSignal: true, isRequired: false, transformFunction: null }, actionHandler: { classPropertyName: "actionHandler", publicName: "actionHandler", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: none" }, ngImport: i0, template: '', isInline: true });
2209
+ }
2210
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxBannerTrigger, decorators: [{
2211
+ type: Component,
2212
+ args: [{
2213
+ selector: 'cngx-banner-trigger',
2214
+ standalone: true,
2215
+ template: '',
2216
+ host: { style: 'display: none' },
2217
+ }]
2218
+ }], ctorParameters: () => [], propDecorators: { when: [{ type: i0.Input, args: [{ isSignal: true, alias: "when", required: true }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: true }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: true }] }], severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], actionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionLabel", required: false }] }], actionHandler: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionHandler", required: false }] }] } });
2219
+
2220
+ /**
2221
+ * Toast outlet — renders the toast stack at a fixed viewport position.
2222
+ *
2223
+ * Place once in the app shell. Reads from `CngxToaster` reactively.
2224
+ * Requires `provideToasts()` or `provideFeedback(withToasts())`.
2225
+ *
2226
+ * ```html
2227
+ * <cngx-toast-outlet position="bottom-end" [maxVisible]="5" />
2228
+ * ```
2229
+ */
2230
+ class CngxToastOutlet {
2231
+ service = inject(CngxToaster);
2232
+ config = inject(CNGX_FEEDBACK_CONFIG, { optional: true });
2233
+ /** Stack position. */
2234
+ position = input('bottom-end', ...(ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []));
2235
+ /** Maximum visible toasts — oldest are evicted. */
2236
+ maxVisible = input(3, ...(ngDevMode ? [{ debugName: "maxVisible" }] : /* istanbul ignore next */ []));
2237
+ /** Insert new toasts at start or end of the stack. */
2238
+ insertPosition = input('start', ...(ngDevMode ? [{ debugName: "insertPosition" }] : /* istanbul ignore next */ []));
2239
+ /** @internal */
2240
+ positionClass = computed(() => `cngx-toast-outlet--${this.position()}`, ...(ngDevMode ? [{ debugName: "positionClass" }] : /* istanbul ignore next */ []));
2241
+ /** @internal — slice to maxVisible, respecting insert position. */
2242
+ visibleToasts = computed(() => {
2243
+ const all = this.service.toasts();
2244
+ const max = this.maxVisible();
2245
+ const sliced = all.length > max ? all.slice(0, max) : all;
2246
+ return this.insertPosition() === 'end' ? [...sliced].reverse() : sliced;
2247
+ }, ...(ngDevMode ? [{ debugName: "visibleToasts" }] : /* istanbul ignore next */ []));
2248
+ /** @internal — resolve icon component from global config or null. */
2249
+ iconFor(toast) {
2250
+ return this.config?.alertIcons?.[toast.config.severity] ?? null;
2251
+ }
2252
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToastOutlet, deps: [], target: i0.ɵɵFactoryTarget.Component });
2253
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxToastOutlet, isStandalone: true, selector: "cngx-toast-outlet", inputs: { position: { classPropertyName: "position", publicName: "position", isSignal: true, isRequired: false, transformFunction: null }, maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null }, insertPosition: { classPropertyName: "insertPosition", publicName: "insertPosition", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "region", "aria-label": "Notifications" }, properties: { "class": "positionClass()" }, classAttribute: "cngx-toast-outlet" }, ngImport: i0, template: `
2254
+ @for (toast of visibleToasts(); track toast.id) {
2255
+ <div
2256
+ class="cngx-toast"
2257
+ [class.cngx-toast--info]="toast.config.severity === 'info'"
2258
+ [class.cngx-toast--success]="toast.config.severity === 'success'"
2259
+ [class.cngx-toast--warning]="toast.config.severity === 'warning'"
2260
+ [class.cngx-toast--error]="toast.config.severity === 'error'"
2261
+ [attr.role]="
2262
+ toast.config.severity === 'error' || toast.config.severity === 'warning'
2263
+ ? 'alert'
2264
+ : 'status'
2265
+ "
2266
+ (pointerenter)="service.pauseTimer(toast.id)"
2267
+ (pointerleave)="service.resumeTimer(toast.id)"
2268
+ (focusin)="service.pauseTimer(toast.id)"
2269
+ (focusout)="service.resumeTimer(toast.id)"
2270
+ >
2271
+ <div class="cngx-toast__icon">
2272
+ @if (iconFor(toast); as iconCmp) {
2273
+ <ng-container *ngComponentOutlet="iconCmp" />
2274
+ } @else {
2275
+ <svg
2276
+ aria-hidden="true"
2277
+ viewBox="0 0 24 24"
2278
+ fill="none"
2279
+ stroke="currentColor"
2280
+ stroke-width="2"
2281
+ stroke-linecap="round"
2282
+ stroke-linejoin="round"
2283
+ class="cngx-toast__default-icon"
2284
+ >
2285
+ @switch (toast.config.severity) {
2286
+ @case ('info') {
2287
+ <circle cx="12" cy="12" r="10" />
2288
+ <line x1="12" y1="16" x2="12" y2="12" />
2289
+ <line x1="12" y1="8" x2="12.01" y2="8" />
2290
+ }
2291
+ @case ('success') {
2292
+ <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
2293
+ <polyline points="22 4 12 14.01 9 11.01" />
2294
+ }
2295
+ @case ('warning') {
2296
+ <path
2297
+ d="M10.29 3.86L1.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"
2298
+ />
2299
+ <line x1="12" y1="9" x2="12" y2="13" />
2300
+ <line x1="12" y1="17" x2="12.01" y2="17" />
2301
+ }
2302
+ @case ('error') {
2303
+ <circle cx="12" cy="12" r="10" />
2304
+ <line x1="15" y1="9" x2="9" y2="15" />
2305
+ <line x1="9" y1="9" x2="15" y2="15" />
2306
+ }
2307
+ }
2308
+ </svg>
2309
+ }
2310
+ </div>
2311
+ <div class="cngx-toast__body">
2312
+ @if (toast.config.title) {
2313
+ <span class="cngx-toast__title">{{ toast.config.title }}</span>
2314
+ @if (toast.config.content) {
2315
+ <ng-container
2316
+ *ngComponentOutlet="toast.config.content; inputs: toast.config.contentInputs"
2317
+ />
2318
+ } @else {
2319
+ <span class="cngx-toast__description">
2320
+ {{ toast.config.description ?? toast.config.message }}
2321
+ </span>
2322
+ }
2323
+ } @else if (toast.config.content) {
2324
+ <ng-container
2325
+ *ngComponentOutlet="toast.config.content; inputs: toast.config.contentInputs"
2326
+ />
2327
+ } @else {
2328
+ <span class="cngx-toast__message">
2329
+ {{ toast.config.message }}
2330
+ </span>
2331
+ }
2332
+ @if (toast.count > 1) {
2333
+ <span class="cngx-toast__count">(x{{ toast.count }})</span>
2334
+ }
2335
+ @if (toast.config.action; as action) {
2336
+ <button type="button" class="cngx-toast__action" (click)="action.handler()">
2337
+ {{ action.label }}
2338
+ </button>
2339
+ }
2340
+ </div>
2341
+ @if (toast.config.dismissible) {
2342
+ <cngx-close-button
2343
+ label="Dismiss"
2344
+ class="cngx-toast__dismiss"
2345
+ (click)="service.dismiss(toast.id)"
2346
+ />
2347
+ }
2348
+ </div>
2349
+ }
2350
+ `, isInline: true, styles: [".cngx-toast-outlet{position:fixed;z-index:var(--cngx-toast-z-index, 9999);display:flex;flex-direction:column;gap:var(--cngx-toast-gap, 8px);padding:var(--cngx-toast-outlet-padding, 16px);pointer-events:none;max-width:var(--cngx-toast-max-width, 420px);width:100%}.cngx-toast-outlet--top-start{top:0;left:0}.cngx-toast-outlet--top-center{top:0;left:50%;transform:translate(-50%)}.cngx-toast-outlet--top-end{top:0;right:0}.cngx-toast-outlet--bottom-start{bottom:0;left:0}.cngx-toast-outlet--bottom-center{bottom:0;left:50%;transform:translate(-50%)}.cngx-toast-outlet--bottom-end{bottom:0;right:0}.cngx-toast{display:flex;align-items:flex-start;gap:var(--cngx-toast-inner-gap, 10px);padding:var(--cngx-toast-padding, 12px 16px);border-radius:var(--cngx-toast-border-radius, 8px);background:var(--cngx-toast-bg, #fff);color:var(--cngx-toast-color, #1e293b);box-shadow:var(--cngx-toast-shadow, 0 4px 12px rgba(0, 0, 0, .15));pointer-events:auto;animation:cngx-toast-enter var(--cngx-toast-enter-duration, .2s) var(--cngx-toast-enter-easing, ease-out)}.cngx-toast--info{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-info-accent, #3b82f6)}.cngx-toast--success{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-success-accent, #22c55e)}.cngx-toast--warning{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-warning-accent, #f59e0b)}.cngx-toast--error{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-error-accent, #ef4444)}.cngx-toast__icon{flex-shrink:0}.cngx-toast--info .cngx-toast__icon{color:var(--cngx-toast-info-accent, #3b82f6)}.cngx-toast--success .cngx-toast__icon{color:var(--cngx-toast-success-accent, #22c55e)}.cngx-toast--warning .cngx-toast__icon{color:var(--cngx-toast-warning-accent, #f59e0b)}.cngx-toast--error .cngx-toast__icon{color:var(--cngx-toast-error-accent, #ef4444)}.cngx-toast__default-icon{width:var(--cngx-toast-icon-size, 20px);height:var(--cngx-toast-icon-size, 20px)}.cngx-toast__body{flex:1;min-width:0}.cngx-toast__message{font-size:var(--cngx-toast-font-size, .875rem);line-height:var(--cngx-toast-line-height, 1.5)}.cngx-toast__title{display:block;font-weight:var(--cngx-toast-title-font-weight, 600);font-size:var(--cngx-toast-title-font-size, var(--cngx-toast-font-size, .875rem));color:var(--cngx-toast-title-color, inherit);line-height:var(--cngx-toast-line-height, 1.5)}.cngx-toast__description{display:-webkit-box;-webkit-line-clamp:var(--cngx-toast-description-max-lines, 3);-webkit-box-orient:vertical;overflow:hidden;font-size:var(--cngx-toast-description-font-size, .8125rem);color:var(--cngx-toast-description-color, #64748b);line-height:var(--cngx-toast-description-line-height, 1.4);margin-top:2px}.cngx-toast__count{opacity:var(--cngx-toast-count-opacity, .6);font-size:var(--cngx-toast-description-font-size, .8125rem)}.cngx-toast__action{appearance:none;background:none;border:none;padding:var(--cngx-toast-action-padding, 4px 0);cursor:pointer;font-weight:var(--cngx-toast-action-weight, 600);font-size:var(--cngx-toast-action-size, .8125rem);color:inherit;text-decoration:underline}.cngx-toast__dismiss{flex-shrink:0}@keyframes cngx-toast-enter{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.cngx-toast{animation:none}}\n"], dependencies: [{ kind: "directive", type: NgComponentOutlet, selector: "[ngComponentOutlet]", inputs: ["ngComponentOutlet", "ngComponentOutletInputs", "ngComponentOutletInjector", "ngComponentOutletEnvironmentInjector", "ngComponentOutletContent", "ngComponentOutletNgModule"], exportAs: ["ngComponentOutlet"] }, { kind: "component", type: CngxCloseButton, selector: "cngx-close-button", inputs: ["label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2351
+ }
2352
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToastOutlet, decorators: [{
2353
+ type: Component,
2354
+ args: [{ selector: 'cngx-toast-outlet', standalone: true, imports: [NgComponentOutlet, CngxCloseButton], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2355
+ class: 'cngx-toast-outlet',
2356
+ '[class]': 'positionClass()',
2357
+ role: 'region',
2358
+ 'aria-label': 'Notifications',
2359
+ }, template: `
2360
+ @for (toast of visibleToasts(); track toast.id) {
2361
+ <div
2362
+ class="cngx-toast"
2363
+ [class.cngx-toast--info]="toast.config.severity === 'info'"
2364
+ [class.cngx-toast--success]="toast.config.severity === 'success'"
2365
+ [class.cngx-toast--warning]="toast.config.severity === 'warning'"
2366
+ [class.cngx-toast--error]="toast.config.severity === 'error'"
2367
+ [attr.role]="
2368
+ toast.config.severity === 'error' || toast.config.severity === 'warning'
2369
+ ? 'alert'
2370
+ : 'status'
2371
+ "
2372
+ (pointerenter)="service.pauseTimer(toast.id)"
2373
+ (pointerleave)="service.resumeTimer(toast.id)"
2374
+ (focusin)="service.pauseTimer(toast.id)"
2375
+ (focusout)="service.resumeTimer(toast.id)"
2376
+ >
2377
+ <div class="cngx-toast__icon">
2378
+ @if (iconFor(toast); as iconCmp) {
2379
+ <ng-container *ngComponentOutlet="iconCmp" />
2380
+ } @else {
2381
+ <svg
2382
+ aria-hidden="true"
2383
+ viewBox="0 0 24 24"
2384
+ fill="none"
2385
+ stroke="currentColor"
2386
+ stroke-width="2"
2387
+ stroke-linecap="round"
2388
+ stroke-linejoin="round"
2389
+ class="cngx-toast__default-icon"
2390
+ >
2391
+ @switch (toast.config.severity) {
2392
+ @case ('info') {
2393
+ <circle cx="12" cy="12" r="10" />
2394
+ <line x1="12" y1="16" x2="12" y2="12" />
2395
+ <line x1="12" y1="8" x2="12.01" y2="8" />
2396
+ }
2397
+ @case ('success') {
2398
+ <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" />
2399
+ <polyline points="22 4 12 14.01 9 11.01" />
2400
+ }
2401
+ @case ('warning') {
2402
+ <path
2403
+ d="M10.29 3.86L1.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"
2404
+ />
2405
+ <line x1="12" y1="9" x2="12" y2="13" />
2406
+ <line x1="12" y1="17" x2="12.01" y2="17" />
2407
+ }
2408
+ @case ('error') {
2409
+ <circle cx="12" cy="12" r="10" />
2410
+ <line x1="15" y1="9" x2="9" y2="15" />
2411
+ <line x1="9" y1="9" x2="15" y2="15" />
2412
+ }
2413
+ }
2414
+ </svg>
2415
+ }
2416
+ </div>
2417
+ <div class="cngx-toast__body">
2418
+ @if (toast.config.title) {
2419
+ <span class="cngx-toast__title">{{ toast.config.title }}</span>
2420
+ @if (toast.config.content) {
2421
+ <ng-container
2422
+ *ngComponentOutlet="toast.config.content; inputs: toast.config.contentInputs"
2423
+ />
2424
+ } @else {
2425
+ <span class="cngx-toast__description">
2426
+ {{ toast.config.description ?? toast.config.message }}
2427
+ </span>
2428
+ }
2429
+ } @else if (toast.config.content) {
2430
+ <ng-container
2431
+ *ngComponentOutlet="toast.config.content; inputs: toast.config.contentInputs"
2432
+ />
2433
+ } @else {
2434
+ <span class="cngx-toast__message">
2435
+ {{ toast.config.message }}
2436
+ </span>
2437
+ }
2438
+ @if (toast.count > 1) {
2439
+ <span class="cngx-toast__count">(x{{ toast.count }})</span>
2440
+ }
2441
+ @if (toast.config.action; as action) {
2442
+ <button type="button" class="cngx-toast__action" (click)="action.handler()">
2443
+ {{ action.label }}
2444
+ </button>
2445
+ }
2446
+ </div>
2447
+ @if (toast.config.dismissible) {
2448
+ <cngx-close-button
2449
+ label="Dismiss"
2450
+ class="cngx-toast__dismiss"
2451
+ (click)="service.dismiss(toast.id)"
2452
+ />
2453
+ }
2454
+ </div>
2455
+ }
2456
+ `, styles: [".cngx-toast-outlet{position:fixed;z-index:var(--cngx-toast-z-index, 9999);display:flex;flex-direction:column;gap:var(--cngx-toast-gap, 8px);padding:var(--cngx-toast-outlet-padding, 16px);pointer-events:none;max-width:var(--cngx-toast-max-width, 420px);width:100%}.cngx-toast-outlet--top-start{top:0;left:0}.cngx-toast-outlet--top-center{top:0;left:50%;transform:translate(-50%)}.cngx-toast-outlet--top-end{top:0;right:0}.cngx-toast-outlet--bottom-start{bottom:0;left:0}.cngx-toast-outlet--bottom-center{bottom:0;left:50%;transform:translate(-50%)}.cngx-toast-outlet--bottom-end{bottom:0;right:0}.cngx-toast{display:flex;align-items:flex-start;gap:var(--cngx-toast-inner-gap, 10px);padding:var(--cngx-toast-padding, 12px 16px);border-radius:var(--cngx-toast-border-radius, 8px);background:var(--cngx-toast-bg, #fff);color:var(--cngx-toast-color, #1e293b);box-shadow:var(--cngx-toast-shadow, 0 4px 12px rgba(0, 0, 0, .15));pointer-events:auto;animation:cngx-toast-enter var(--cngx-toast-enter-duration, .2s) var(--cngx-toast-enter-easing, ease-out)}.cngx-toast--info{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-info-accent, #3b82f6)}.cngx-toast--success{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-success-accent, #22c55e)}.cngx-toast--warning{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-warning-accent, #f59e0b)}.cngx-toast--error{border-left:var(--cngx-toast-accent-width, 3px) solid var(--cngx-toast-error-accent, #ef4444)}.cngx-toast__icon{flex-shrink:0}.cngx-toast--info .cngx-toast__icon{color:var(--cngx-toast-info-accent, #3b82f6)}.cngx-toast--success .cngx-toast__icon{color:var(--cngx-toast-success-accent, #22c55e)}.cngx-toast--warning .cngx-toast__icon{color:var(--cngx-toast-warning-accent, #f59e0b)}.cngx-toast--error .cngx-toast__icon{color:var(--cngx-toast-error-accent, #ef4444)}.cngx-toast__default-icon{width:var(--cngx-toast-icon-size, 20px);height:var(--cngx-toast-icon-size, 20px)}.cngx-toast__body{flex:1;min-width:0}.cngx-toast__message{font-size:var(--cngx-toast-font-size, .875rem);line-height:var(--cngx-toast-line-height, 1.5)}.cngx-toast__title{display:block;font-weight:var(--cngx-toast-title-font-weight, 600);font-size:var(--cngx-toast-title-font-size, var(--cngx-toast-font-size, .875rem));color:var(--cngx-toast-title-color, inherit);line-height:var(--cngx-toast-line-height, 1.5)}.cngx-toast__description{display:-webkit-box;-webkit-line-clamp:var(--cngx-toast-description-max-lines, 3);-webkit-box-orient:vertical;overflow:hidden;font-size:var(--cngx-toast-description-font-size, .8125rem);color:var(--cngx-toast-description-color, #64748b);line-height:var(--cngx-toast-description-line-height, 1.4);margin-top:2px}.cngx-toast__count{opacity:var(--cngx-toast-count-opacity, .6);font-size:var(--cngx-toast-description-font-size, .8125rem)}.cngx-toast__action{appearance:none;background:none;border:none;padding:var(--cngx-toast-action-padding, 4px 0);cursor:pointer;font-weight:var(--cngx-toast-action-weight, 600);font-size:var(--cngx-toast-action-size, .8125rem);color:inherit;text-decoration:underline}.cngx-toast__dismiss{flex-shrink:0}@keyframes cngx-toast-enter{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@media(prefers-reduced-motion:reduce){.cngx-toast{animation:none}}\n"] }]
2457
+ }], propDecorators: { position: [{ type: i0.Input, args: [{ isSignal: true, alias: "position", required: false }] }], maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }], insertPosition: [{ type: i0.Input, args: [{ isSignal: true, alias: "insertPosition", required: false }] }] } });
2458
+
2459
+ /**
2460
+ * Declarative state-to-toast bridge.
2461
+ *
2462
+ * Place on any element — fires a toast when the bound `CngxAsyncState`
2463
+ * transitions to `success` or `error`. Only fires on actual transitions,
2464
+ * not on initial `idle` state.
2465
+ *
2466
+ * ### On a button
2467
+ * ```html
2468
+ * <button [cngxAsyncClick]="save"
2469
+ * [cngxToastOn]="saveState"
2470
+ * toastSuccess="Saved"
2471
+ * toastError="Save failed">
2472
+ * Save
2473
+ * </button>
2474
+ * ```
2475
+ *
2476
+ * ### On a form
2477
+ * ```html
2478
+ * <form [cngxToastOn]="submitState"
2479
+ * toastSuccess="Form submitted"
2480
+ * toastError="Submission failed"
2481
+ * [toastErrorDetail]="true">
2482
+ * ...
2483
+ * </form>
2484
+ * ```
2485
+ */
2486
+ class CngxToastOn {
2487
+ toast = inject(CngxToaster, { optional: true });
2488
+ statefulFallback = inject(CNGX_STATEFUL, { optional: true });
2489
+ // Validated non-null ref — constructor throws if missing
2490
+ toastService;
2491
+ /**
2492
+ * The async state to watch. Optional — when omitted, the bridge falls back
2493
+ * to `CNGX_STATEFUL` injected from the host component (for example
2494
+ * `CngxSelect.commitState`). A bare `cngxToastOn` attribute (empty string)
2495
+ * is treated as "no input bound" so the fallback kicks in.
2496
+ */
2497
+ state = input(undefined, { ...(ngDevMode ? { debugName: "state" } : /* istanbul ignore next */ {}), alias: 'cngxToastOn',
2498
+ transform: (v) => (typeof v === 'string' ? undefined : v) });
2499
+ /** Effective state — input wins over ancestor `CNGX_STATEFUL`. */
2500
+ effectiveState = computed(() => this.state() ?? this.statefulFallback?.state, ...(ngDevMode ? [{ debugName: "effectiveState" }] : /* istanbul ignore next */ []));
2501
+ /** Toast message on success. If not set, no success toast fires. */
2502
+ toastSuccess = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccess" }] : /* istanbul ignore next */ []));
2503
+ /** Toast message on error. If not set, no error toast fires. */
2504
+ toastError = input(undefined, ...(ngDevMode ? [{ debugName: "toastError" }] : /* istanbul ignore next */ []));
2505
+ /** Include the error detail message in the toast body. */
2506
+ toastErrorDetail = input(false, ...(ngDevMode ? [{ debugName: "toastErrorDetail" }] : /* istanbul ignore next */ []));
2507
+ /** Duration for success toasts in ms. */
2508
+ toastSuccessDuration = input(3000, ...(ngDevMode ? [{ debugName: "toastSuccessDuration" }] : /* istanbul ignore next */ []));
2509
+ /** Duration for error toasts — `'persistent'` means manual dismiss only. */
2510
+ toastErrorDuration = input('persistent', ...(ngDevMode ? [{ debugName: "toastErrorDuration" }] : /* istanbul ignore next */ []));
2511
+ constructor() {
2512
+ if (!this.toast) {
2513
+ throw new Error('[cngxToastOn] CngxToaster not found. ' +
2514
+ 'Add withToasts() to provideFeedback() or call provideToasts() in your providers.');
2515
+ }
2516
+ this.toastService = this.toast;
2517
+ if (isDevMode()) {
2518
+ // One-shot post-binding check — runs once after inputs are bound. Uses
2519
+ // afterNextRender instead of an effect so we don't leave a dead node in
2520
+ // the reactive graph for the lifetime of the directive.
2521
+ afterNextRender(() => {
2522
+ if (this.state() === undefined && !this.statefulFallback) {
2523
+ console.error('[cngxToastOn] No state source. Bind [cngxToastOn]="state" explicitly or ' +
2524
+ 'place inside a component that provides CNGX_STATEFUL.');
2525
+ }
2526
+ });
2527
+ }
2528
+ const tracker = createTransitionTracker(() => this.effectiveState()?.status() ?? 'idle');
2529
+ effect(() => {
2530
+ // Only tracker is tracked. All other signal reads happen inside untracked()
2531
+ // below to keep the effect's dependency graph flat and avoid re-firing
2532
+ // when options (message strings, durations, error detail) change.
2533
+ const status = tracker.current();
2534
+ const previous = tracker.previous();
2535
+ if (status === previous) {
2536
+ return;
2537
+ }
2538
+ untracked(() => {
2539
+ const s = this.effectiveState();
2540
+ if (!s) {
2541
+ return;
2542
+ }
2543
+ if (status === 'success') {
2544
+ const msg = this.toastSuccess();
2545
+ if (msg) {
2546
+ this.toastService.show({
2547
+ message: msg,
2548
+ severity: 'success',
2549
+ duration: this.toastSuccessDuration(),
2550
+ });
2551
+ }
2552
+ }
2553
+ if (status === 'error') {
2554
+ const msg = this.toastError();
2555
+ if (msg) {
2556
+ const err = s.error();
2557
+ const detail = this.toastErrorDetail() && err != null
2558
+ ? err instanceof Error
2559
+ ? err.message
2560
+ : typeof err === 'string'
2561
+ ? err
2562
+ : undefined
2563
+ : undefined;
2564
+ this.toastService.show({
2565
+ message: detail ? `${msg}: ${detail}` : msg,
2566
+ severity: 'error',
2567
+ duration: this.toastErrorDuration(),
2568
+ });
2569
+ }
2570
+ }
2571
+ });
2572
+ });
2573
+ }
2574
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToastOn, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2575
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxToastOn, isStandalone: true, selector: "[cngxToastOn]", inputs: { state: { classPropertyName: "state", publicName: "cngxToastOn", isSignal: true, isRequired: false, transformFunction: null }, toastSuccess: { classPropertyName: "toastSuccess", publicName: "toastSuccess", isSignal: true, isRequired: false, transformFunction: null }, toastError: { classPropertyName: "toastError", publicName: "toastError", isSignal: true, isRequired: false, transformFunction: null }, toastErrorDetail: { classPropertyName: "toastErrorDetail", publicName: "toastErrorDetail", isSignal: true, isRequired: false, transformFunction: null }, toastSuccessDuration: { classPropertyName: "toastSuccessDuration", publicName: "toastSuccessDuration", isSignal: true, isRequired: false, transformFunction: null }, toastErrorDuration: { classPropertyName: "toastErrorDuration", publicName: "toastErrorDuration", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
2576
+ }
2577
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToastOn, decorators: [{
2578
+ type: Directive,
2579
+ args: [{
2580
+ selector: '[cngxToastOn]',
2581
+ standalone: true,
2582
+ }]
2583
+ }], ctorParameters: () => [], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxToastOn", required: false }] }], toastSuccess: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccess", required: false }] }], toastError: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastError", required: false }] }], toastErrorDetail: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastErrorDetail", required: false }] }], toastSuccessDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccessDuration", required: false }] }], toastErrorDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastErrorDuration", required: false }] }] } });
2584
+
2585
+ /**
2586
+ * Declarative toast — renders nothing at its position, pushes into the global `CngxToastOutlet`.
2587
+ *
2588
+ * Shows a toast when `[when]` becomes `true`. Dismisses when `[when]` becomes `false`
2589
+ * (unless already auto-dismissed). Supports projected content for custom toast bodies.
2590
+ *
2591
+ * Requires `provideToasts()` or `provideFeedback(withToasts())`.
2592
+ *
2593
+ * ### Simple message
2594
+ * ```html
2595
+ * <cngx-toast severity="success" message="Saved" [when]="saved()" />
2596
+ * ```
2597
+ *
2598
+ * ### With custom content
2599
+ * ```html
2600
+ * <cngx-toast severity="error" [when]="hasError()">
2601
+ * Something went wrong. <button (click)="retry()">Retry</button>
2602
+ * </cngx-toast>
2603
+ * ```
2604
+ *
2605
+ * ### With async state
2606
+ * ```html
2607
+ * <cngx-toast severity="success" message="Item saved" [when]="saveState.status() === 'success'" />
2608
+ * <cngx-toast severity="error" message="Save failed" [when]="saveState.status() === 'error'" />
2609
+ * ```
2610
+ */
2611
+ class CngxToast {
2612
+ toaster = inject(CngxToaster, { optional: true });
2613
+ destroyRef = inject(DestroyRef);
2614
+ /** When `true`, the toast is shown. When `false`, it is dismissed. */
2615
+ when = input.required(...(ngDevMode ? [{ debugName: "when" }] : /* istanbul ignore next */ []));
2616
+ /** Toast message text. Ignored when content is projected. */
2617
+ message = input('', ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
2618
+ /** Visual severity. */
2619
+ severity = input('info', ...(ngDevMode ? [{ debugName: "severity" }] : /* istanbul ignore next */ []));
2620
+ /** Auto-dismiss duration in ms, or `'persistent'`. */
2621
+ duration = input(undefined, ...(ngDevMode ? [{ debugName: "duration" }] : /* istanbul ignore next */ []));
2622
+ /** Show dismiss button. */
2623
+ dismissible = input(true, ...(ngDevMode ? [{ debugName: "dismissible" }] : /* istanbul ignore next */ []));
2624
+ /** Action button config. */
2625
+ actionLabel = input(undefined, ...(ngDevMode ? [{ debugName: "actionLabel" }] : /* istanbul ignore next */ []));
2626
+ actionHandler = input(undefined, ...(ngDevMode ? [{ debugName: "actionHandler" }] : /* istanbul ignore next */ []));
2627
+ /** @internal */
2628
+ action = computed(() => {
2629
+ const label = this.actionLabel();
2630
+ const handler = this.actionHandler();
2631
+ return label && handler ? { label, handler } : undefined;
2632
+ }, ...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
2633
+ activeRef = null;
2634
+ constructor() {
2635
+ if (!this.toaster) {
2636
+ throw new Error('[cngx-toast] CngxToaster not found. ' +
2637
+ 'Add withToasts() to provideFeedback() or call provideToasts() in your providers.');
2638
+ }
2639
+ const toaster = this.toaster;
2640
+ // Rising-edge trigger: fires when [when] transitions from false→true.
2641
+ // The toast then lives its own lifecycle (auto-dismiss or manual dismiss).
2642
+ // [when]=false just resets the trigger so it can fire again.
2643
+ let previousWhen = false;
2644
+ effect(() => {
2645
+ const show = this.when();
2646
+ if (show && !previousWhen) {
2647
+ // Rising edge — fire a new toast
2648
+ this.activeRef = toaster.show({
2649
+ message: this.message(),
2650
+ severity: this.severity(),
2651
+ duration: this.duration(),
2652
+ dismissible: this.dismissible(),
2653
+ action: this.action(),
2654
+ });
2655
+ this.activeRef.afterDismissed().subscribe(() => {
2656
+ this.activeRef = null;
2657
+ });
2658
+ }
2659
+ previousWhen = show;
2660
+ });
2661
+ this.destroyRef.onDestroy(() => {
2662
+ this.activeRef?.dismiss();
2663
+ this.activeRef = null;
2664
+ });
2665
+ }
2666
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToast, deps: [], target: i0.ɵɵFactoryTarget.Component });
2667
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.4", type: CngxToast, isStandalone: true, selector: "cngx-toast", inputs: { when: { classPropertyName: "when", publicName: "when", isSignal: true, isRequired: true, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, severity: { classPropertyName: "severity", publicName: "severity", isSignal: true, isRequired: false, transformFunction: null }, duration: { classPropertyName: "duration", publicName: "duration", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, actionLabel: { classPropertyName: "actionLabel", publicName: "actionLabel", isSignal: true, isRequired: false, transformFunction: null }, actionHandler: { classPropertyName: "actionHandler", publicName: "actionHandler", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: none" }, ngImport: i0, template: ``, isInline: true });
2668
+ }
2669
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxToast, decorators: [{
2670
+ type: Component,
2671
+ args: [{
2672
+ selector: 'cngx-toast',
2673
+ standalone: true,
2674
+ template: ``,
2675
+ host: { style: 'display: none' },
2676
+ }]
2677
+ }], ctorParameters: () => [], propDecorators: { when: [{ type: i0.Input, args: [{ isSignal: true, alias: "when", required: true }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], severity: [{ type: i0.Input, args: [{ isSignal: true, alias: "severity", required: false }] }], duration: [{ type: i0.Input, args: [{ isSignal: true, alias: "duration", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], actionLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionLabel", required: false }] }], actionHandler: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionHandler", required: false }] }] } });
2678
+
2679
+ /** Marks the skeleton template inside `cngx-async-container`. */
2680
+ class CngxAsyncSkeletonTpl {
2681
+ templateRef = inject(TemplateRef);
2682
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncSkeletonTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2683
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxAsyncSkeletonTpl, isStandalone: true, selector: "ng-template[cngxAsyncSkeleton]", ngImport: i0 });
2684
+ }
2685
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncSkeletonTpl, decorators: [{
2686
+ type: Directive,
2687
+ args: [{ selector: 'ng-template[cngxAsyncSkeleton]', standalone: true }]
2688
+ }] });
2689
+ /**
2690
+ * Marks the content template inside `cngx-async-container`.
2691
+ * Context: `{ $implicit: T }` — use `let-data` to access.
2692
+ */
2693
+ class CngxAsyncContentTpl {
2694
+ templateRef = inject(TemplateRef);
2695
+ static ngTemplateContextGuard(_dir, _ctx) {
2696
+ return true;
2697
+ }
2698
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncContentTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2699
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxAsyncContentTpl, isStandalone: true, selector: "ng-template[cngxAsyncContent]", ngImport: i0 });
2700
+ }
2701
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncContentTpl, decorators: [{
2702
+ type: Directive,
2703
+ args: [{ selector: 'ng-template[cngxAsyncContent]', standalone: true }]
2704
+ }] });
2705
+ /** Marks the empty-state template inside `cngx-async-container`. */
2706
+ class CngxAsyncEmptyTpl {
2707
+ templateRef = inject(TemplateRef);
2708
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncEmptyTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2709
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxAsyncEmptyTpl, isStandalone: true, selector: "ng-template[cngxAsyncEmpty]", ngImport: i0 });
2710
+ }
2711
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncEmptyTpl, decorators: [{
2712
+ type: Directive,
2713
+ args: [{ selector: 'ng-template[cngxAsyncEmpty]', standalone: true }]
2714
+ }] });
2715
+ /**
2716
+ * Marks the error template inside `cngx-async-container`.
2717
+ * Context: `{ $implicit: unknown }` — use `let-err` to access.
2718
+ */
2719
+ class CngxAsyncErrorTpl {
2720
+ templateRef = inject(TemplateRef);
2721
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncErrorTpl, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2722
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxAsyncErrorTpl, isStandalone: true, selector: "ng-template[cngxAsyncError]", ngImport: i0 });
2723
+ }
2724
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncErrorTpl, decorators: [{
2725
+ type: Directive,
2726
+ args: [{ selector: 'ng-template[cngxAsyncError]', standalone: true }]
2727
+ }] });
2728
+ /**
2729
+ * Async container molecule — coordinates all feedback states for data loading.
2730
+ *
2731
+ * Projects four named templates and switches between them based on the
2732
+ * `CngxAsyncState` lifecycle. Includes a built-in refresh indicator (bar)
2733
+ * and ARIA state announcements.
2734
+ *
2735
+ * ```html
2736
+ * <cngx-async-container [state]="residents">
2737
+ * <ng-template cngxAsyncSkeleton>
2738
+ * @for (i of [1,2,3]; track i) { <div class="skeleton-card"></div> }
2739
+ * </ng-template>
2740
+ *
2741
+ * <ng-template cngxAsyncContent let-data>
2742
+ * @for (r of data; track r.id) { <app-card [resident]="r" /> }
2743
+ * </ng-template>
2744
+ *
2745
+ * <ng-template cngxAsyncEmpty>
2746
+ * <cngx-empty-state title="No residents" />
2747
+ * </ng-template>
2748
+ *
2749
+ * <ng-template cngxAsyncError let-err>
2750
+ * <cngx-alert severity="error">{{ err }}</cngx-alert>
2751
+ * </ng-template>
2752
+ * </cngx-async-container>
2753
+ * ```
2754
+ */
2755
+ class CngxAsyncContainer {
2756
+ toaster = inject(CngxToaster, { optional: true });
2757
+ /** The async state to render. */
2758
+ state = input.required(...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
2759
+ /** Show refresh indicator bar during refresh/re-query. */
2760
+ refreshIndicator = input(true, ...(ngDevMode ? [{ debugName: "refreshIndicator" }] : /* istanbul ignore next */ []));
2761
+ /** ARIA label for the region. */
2762
+ ariaLabel = input(undefined, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
2763
+ /** Toast message on success. If set, fires a toast via CngxToaster. */
2764
+ toastSuccess = input(undefined, ...(ngDevMode ? [{ debugName: "toastSuccess" }] : /* istanbul ignore next */ []));
2765
+ /** Toast message on error. If set, fires a toast via CngxToaster. */
2766
+ toastError = input(undefined, ...(ngDevMode ? [{ debugName: "toastError" }] : /* istanbul ignore next */ []));
2767
+ /** @internal */
2768
+ skeletonTpl = contentChild(CngxAsyncSkeletonTpl, ...(ngDevMode ? [{ debugName: "skeletonTpl" }] : /* istanbul ignore next */ []));
2769
+ /** @internal */
2770
+ contentTpl = contentChild(CngxAsyncContentTpl, ...(ngDevMode ? [{ debugName: "contentTpl" }] : /* istanbul ignore next */ []));
2771
+ /** @internal */
2772
+ emptyTpl = contentChild(CngxAsyncEmptyTpl, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
2773
+ /** @internal */
2774
+ errorTpl = contentChild(CngxAsyncErrorTpl, ...(ngDevMode ? [{ debugName: "errorTpl" }] : /* istanbul ignore next */ []));
2775
+ /** @internal */
2776
+ activeView = computed(() => {
2777
+ const s = this.state();
2778
+ return resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
2779
+ }, ...(ngDevMode ? [{ debugName: "activeView" }] : /* istanbul ignore next */ []));
2780
+ /** @internal */
2781
+ showRefreshIndicator = computed(() => {
2782
+ if (!this.refreshIndicator()) {
2783
+ return false;
2784
+ }
2785
+ const s = this.state();
2786
+ const status = s.status();
2787
+ return status === 'refreshing' || (status === 'loading' && !s.isFirstLoad());
2788
+ }, ...(ngDevMode ? [{ debugName: "showRefreshIndicator" }] : /* istanbul ignore next */ []));
2789
+ /** @internal */
2790
+ contentContext = computed(() => ({
2791
+ $implicit: this.state().data(),
2792
+ }), ...(ngDevMode ? [{ debugName: "contentContext" }] : /* istanbul ignore next */ []));
2793
+ /** @internal */
2794
+ errorContext = computed(() => ({
2795
+ $implicit: this.state().error(),
2796
+ }), ...(ngDevMode ? [{ debugName: "errorContext" }] : /* istanbul ignore next */ []));
2797
+ /** @internal */
2798
+ announcement = signal('', ...(ngDevMode ? [{ debugName: "announcement" }] : /* istanbul ignore next */ []));
2799
+ constructor() {
2800
+ let previousStatus = 'idle';
2801
+ effect(() => {
2802
+ const s = this.state();
2803
+ const status = s.status();
2804
+ if (status === previousStatus) {
2805
+ return;
2806
+ }
2807
+ const prev = previousStatus;
2808
+ previousStatus = status;
2809
+ if (status === 'pending' || prev === 'pending') {
2810
+ return;
2811
+ }
2812
+ if (prev === 'idle' && status === 'loading') {
2813
+ this.announcement.set('Loading content');
2814
+ }
2815
+ else if (prev === 'loading' && status === 'success') {
2816
+ this.announcement.set('Content loaded');
2817
+ }
2818
+ else if (prev === 'loading' && status === 'error') {
2819
+ this.announcement.set('Error loading content');
2820
+ }
2821
+ else if (status === 'refreshing') {
2822
+ this.announcement.set('Refreshing content');
2823
+ }
2824
+ else if (prev === 'refreshing' && status === 'success') {
2825
+ this.announcement.set('Content refreshed');
2826
+ }
2827
+ else if (prev === 'refreshing' && status === 'error') {
2828
+ this.announcement.set('Refresh failed');
2829
+ }
2830
+ // Fire toasts if configured
2831
+ this.fireToast(status);
2832
+ });
2833
+ }
2834
+ fireToast(status) {
2835
+ if (!this.toaster) {
2836
+ return;
2837
+ }
2838
+ if (status === 'success') {
2839
+ const msg = this.toastSuccess();
2840
+ if (msg) {
2841
+ this.toaster.show({ message: msg, severity: 'success', duration: 3000 });
2842
+ }
2843
+ }
2844
+ if (status === 'error') {
2845
+ const msg = this.toastError();
2846
+ if (msg) {
2847
+ this.toaster.show({ message: msg, severity: 'error' });
2848
+ }
2849
+ }
2850
+ }
2851
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncContainer, deps: [], target: i0.ɵɵFactoryTarget.Component });
2852
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxAsyncContainer, isStandalone: true, selector: "cngx-async-container", inputs: { state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: true, transformFunction: null }, refreshIndicator: { classPropertyName: "refreshIndicator", publicName: "refreshIndicator", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null }, toastSuccess: { classPropertyName: "toastSuccess", publicName: "toastSuccess", isSignal: true, isRequired: false, transformFunction: null }, toastError: { classPropertyName: "toastError", publicName: "toastError", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "region" }, properties: { "attr.aria-busy": "state().isBusy() || null", "attr.aria-label": "ariaLabel() || null" }, styleAttribute: "display: contents", classAttribute: "cngx-async-container" }, queries: [{ propertyName: "skeletonTpl", first: true, predicate: CngxAsyncSkeletonTpl, descendants: true, isSignal: true }, { propertyName: "contentTpl", first: true, predicate: CngxAsyncContentTpl, descendants: true, isSignal: true }, { propertyName: "emptyTpl", first: true, predicate: CngxAsyncEmptyTpl, descendants: true, isSignal: true }, { propertyName: "errorTpl", first: true, predicate: CngxAsyncErrorTpl, descendants: true, isSignal: true }], ngImport: i0, template: `
2853
+ @if (showRefreshIndicator()) {
2854
+ <cngx-loading-indicator
2855
+ [loading]="true"
2856
+ variant="bar"
2857
+ label="Refreshing content"
2858
+ class="cngx-async-container__refresh"
2859
+ />
2860
+ }
2861
+
2862
+ @switch (activeView()) {
2863
+ @case ('skeleton') {
2864
+ @if (skeletonTpl(); as tpl) {
2865
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
2866
+ }
2867
+ }
2868
+ @case ('content') {
2869
+ @if (contentTpl(); as tpl) {
2870
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: contentContext()" />
2871
+ }
2872
+ }
2873
+ @case ('empty') {
2874
+ @if (emptyTpl(); as tpl) {
2875
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
2876
+ }
2877
+ }
2878
+ @case ('error') {
2879
+ @if (errorTpl(); as tpl) {
2880
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: errorContext()" />
2881
+ }
2882
+ }
2883
+ @case ('content+error') {
2884
+ @if (contentTpl(); as tpl) {
2885
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: contentContext()" />
2886
+ }
2887
+ @if (errorTpl(); as tpl) {
2888
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: errorContext()" />
2889
+ }
2890
+ }
2891
+ }
2892
+
2893
+ <span aria-live="polite" aria-atomic="true" class="cngx-async-container__sr-only">
2894
+ {{ announcement() }}
2895
+ </span>
2896
+ `, isInline: true, styles: [".cngx-async-container__refresh{position:absolute;top:0;left:0;right:0;z-index:var(--cngx-async-container-refresh-z, 5)}.cngx-async-container__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CngxLoadingIndicator, selector: "cngx-loading-indicator", inputs: ["state", "loading", "variant", "label", "delay", "minDuration"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2897
+ }
2898
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxAsyncContainer, decorators: [{
2899
+ type: Component,
2900
+ args: [{ selector: 'cngx-async-container', standalone: true, imports: [NgTemplateOutlet, CngxLoadingIndicator], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
2901
+ style: 'display: contents',
2902
+ class: 'cngx-async-container',
2903
+ role: 'region',
2904
+ '[attr.aria-busy]': 'state().isBusy() || null',
2905
+ '[attr.aria-label]': 'ariaLabel() || null',
2906
+ }, template: `
2907
+ @if (showRefreshIndicator()) {
2908
+ <cngx-loading-indicator
2909
+ [loading]="true"
2910
+ variant="bar"
2911
+ label="Refreshing content"
2912
+ class="cngx-async-container__refresh"
2913
+ />
2914
+ }
2915
+
2916
+ @switch (activeView()) {
2917
+ @case ('skeleton') {
2918
+ @if (skeletonTpl(); as tpl) {
2919
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
2920
+ }
2921
+ }
2922
+ @case ('content') {
2923
+ @if (contentTpl(); as tpl) {
2924
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: contentContext()" />
2925
+ }
2926
+ }
2927
+ @case ('empty') {
2928
+ @if (emptyTpl(); as tpl) {
2929
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
2930
+ }
2931
+ }
2932
+ @case ('error') {
2933
+ @if (errorTpl(); as tpl) {
2934
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: errorContext()" />
2935
+ }
2936
+ }
2937
+ @case ('content+error') {
2938
+ @if (contentTpl(); as tpl) {
2939
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: contentContext()" />
2940
+ }
2941
+ @if (errorTpl(); as tpl) {
2942
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: errorContext()" />
2943
+ }
2944
+ }
2945
+ }
2946
+
2947
+ <span aria-live="polite" aria-atomic="true" class="cngx-async-container__sr-only">
2948
+ {{ announcement() }}
2949
+ </span>
2950
+ `, styles: [".cngx-async-container__refresh{position:absolute;top:0;left:0;right:0;z-index:var(--cngx-async-container-refresh-z, 5)}.cngx-async-container__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\n"] }]
2951
+ }], ctorParameters: () => [], propDecorators: { state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: true }] }], refreshIndicator: [{ type: i0.Input, args: [{ isSignal: true, alias: "refreshIndicator", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], toastSuccess: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastSuccess", required: false }] }], toastError: [{ type: i0.Input, args: [{ isSignal: true, alias: "toastError", required: false }] }], skeletonTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxAsyncSkeletonTpl), { isSignal: true }] }], contentTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxAsyncContentTpl), { isSignal: true }] }], emptyTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxAsyncEmptyTpl), { isSignal: true }] }], errorTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxAsyncErrorTpl), { isSignal: true }] }] } });
2952
+
2953
+ /**
2954
+ * @module @cngx/ui/feedback
2955
+ */
2956
+
2957
+ /**
2958
+ * Generated bundle index. Do not edit.
2959
+ */
2960
+
2961
+ export { CNGX_FEEDBACK_CONFIG, CngxAlert, CngxAlertAction, CngxAlertIcon, CngxAlertOn, CngxAlertStack, CngxAlerter, CngxAsyncContainer, CngxAsyncContentTpl, CngxAsyncEmptyTpl, CngxAsyncErrorTpl, CngxAsyncSkeletonTpl, CngxBanner, CngxBannerOn, CngxBannerOutlet, CngxBannerTrigger, CngxLoadingIndicator, CngxLoadingOverlay, CngxProgress, CngxToast, CngxToastOn, CngxToastOutlet, CngxToaster, provideFeedback, provideToasts, withAlertIcons, withAlerts, withBanners, withCloseIcon, withLoadingDefaults, withSpinnerTemplate, withToasts };
2962
+ //# sourceMappingURL=cngx-ui-feedback.mjs.map