@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.
- package/LICENSE +21 -0
- package/README.md +550 -0
- package/action-button/README.md +98 -0
- package/empty-state/README.md +103 -0
- package/feedback/README.md +33 -0
- package/fesm2022/cngx-ui-action-button.mjs +319 -0
- package/fesm2022/cngx-ui-action-button.mjs.map +1 -0
- package/fesm2022/cngx-ui-empty-state.mjs +138 -0
- package/fesm2022/cngx-ui-empty-state.mjs.map +1 -0
- package/fesm2022/cngx-ui-feedback.mjs +2962 -0
- package/fesm2022/cngx-ui-feedback.mjs.map +1 -0
- package/fesm2022/cngx-ui-layout.mjs +89 -0
- package/fesm2022/cngx-ui-layout.mjs.map +1 -0
- package/fesm2022/cngx-ui-mat-stepper.mjs +567 -0
- package/fesm2022/cngx-ui-mat-stepper.mjs.map +1 -0
- package/fesm2022/cngx-ui-mat-tabs.mjs +1405 -0
- package/fesm2022/cngx-ui-mat-tabs.mjs.map +1 -0
- package/fesm2022/cngx-ui-material.mjs +79 -0
- package/fesm2022/cngx-ui-material.mjs.map +1 -0
- package/fesm2022/cngx-ui-overlay.mjs +91 -0
- package/fesm2022/cngx-ui-overlay.mjs.map +1 -0
- package/fesm2022/cngx-ui-sidenav.mjs +521 -0
- package/fesm2022/cngx-ui-sidenav.mjs.map +1 -0
- package/fesm2022/cngx-ui-skeleton.mjs +158 -0
- package/fesm2022/cngx-ui-skeleton.mjs.map +1 -0
- package/fesm2022/cngx-ui-speak.mjs +112 -0
- package/fesm2022/cngx-ui-speak.mjs.map +1 -0
- package/fesm2022/cngx-ui-stepper.mjs +312 -0
- package/fesm2022/cngx-ui-stepper.mjs.map +1 -0
- package/fesm2022/cngx-ui-tabs.mjs +507 -0
- package/fesm2022/cngx-ui-tabs.mjs.map +1 -0
- package/fesm2022/cngx-ui.mjs +45 -0
- package/fesm2022/cngx-ui.mjs.map +1 -0
- package/layout/README.md +133 -0
- package/mat-stepper/README.md +34 -0
- package/mat-tabs/README.md +163 -0
- package/mat-tabs/styles/mat-tabs.css +233 -0
- package/material/README.md +90 -0
- package/overlay/README.md +99 -0
- package/package.json +98 -0
- package/sidenav/README.md +127 -0
- package/skeleton/README.md +98 -0
- package/speak/README.md +93 -0
- package/speak/speak-button-theme.scss +78 -0
- package/stepper/README.md +40 -0
- package/tabs/README.md +28 -0
- package/types/cngx-ui-action-button.d.ts +126 -0
- package/types/cngx-ui-empty-state.d.ts +41 -0
- package/types/cngx-ui-feedback.d.ts +1174 -0
- package/types/cngx-ui-layout.d.ts +56 -0
- package/types/cngx-ui-mat-stepper.d.ts +234 -0
- package/types/cngx-ui-mat-tabs.d.ts +664 -0
- package/types/cngx-ui-material.d.ts +36 -0
- package/types/cngx-ui-overlay.d.ts +57 -0
- package/types/cngx-ui-sidenav.d.ts +209 -0
- package/types/cngx-ui-skeleton.d.ts +97 -0
- package/types/cngx-ui-speak.d.ts +31 -0
- package/types/cngx-ui-stepper.d.ts +129 -0
- package/types/cngx-ui-tabs.d.ts +165 -0
- package/types/cngx-ui.d.ts +18 -0
|
@@ -0,0 +1,1174 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { TemplateRef, InjectionToken, Type, Provider, EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import { CngxAsyncState } from '@cngx/core/utils';
|
|
4
|
+
import { Observable, Subject } from 'rxjs';
|
|
5
|
+
import { AsyncView } from '@cngx/common/data';
|
|
6
|
+
|
|
7
|
+
/** Visual variant for the loading indicator. */
|
|
8
|
+
type LoadingIndicatorVariant = 'spinner' | 'bar';
|
|
9
|
+
/**
|
|
10
|
+
* Loading indicator atom — purely visual, blocks no interaction.
|
|
11
|
+
*
|
|
12
|
+
* Two variants:
|
|
13
|
+
* - `spinner` — rotating circle, inline or centered
|
|
14
|
+
* - `bar` — thin line at the top of the container (YouTube-style)
|
|
15
|
+
*
|
|
16
|
+
* Timing:
|
|
17
|
+
* - `delay` (default 200ms): operations faster than this never show the indicator
|
|
18
|
+
* - `minDuration` (default 500ms): once visible, stays for at least this long
|
|
19
|
+
*
|
|
20
|
+
* For content-blocking overlays, use `cngx-loading-overlay` instead.
|
|
21
|
+
*
|
|
22
|
+
* ### With async state
|
|
23
|
+
* ```html
|
|
24
|
+
* <cngx-loading-indicator [state]="residents" variant="bar" />
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ### Manual boolean
|
|
28
|
+
* ```html
|
|
29
|
+
* <cngx-loading-indicator [loading]="isLoading()" label="Fetching data" />
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
declare class CngxLoadingIndicator {
|
|
33
|
+
private readonly config;
|
|
34
|
+
/** Bind an async state — shows indicator when `isBusy()`. */
|
|
35
|
+
readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
36
|
+
/** Direct boolean control — alternative to `[state]`. */
|
|
37
|
+
readonly loading: _angular_core.InputSignal<boolean>;
|
|
38
|
+
/** Visual variant. */
|
|
39
|
+
readonly variant: _angular_core.InputSignal<LoadingIndicatorVariant>;
|
|
40
|
+
/** Screen reader label. */
|
|
41
|
+
readonly label: _angular_core.InputSignal<string>;
|
|
42
|
+
/** Delay in ms before showing the indicator. Falls back to global config, then 200ms. */
|
|
43
|
+
readonly delay: _angular_core.InputSignal<number>;
|
|
44
|
+
/** Minimum display time in ms once visible. Falls back to global config, then 500ms. */
|
|
45
|
+
readonly minDuration: _angular_core.InputSignal<number>;
|
|
46
|
+
/** @internal — true when the underlying source says "loading". */
|
|
47
|
+
protected readonly isActive: _angular_core.Signal<boolean>;
|
|
48
|
+
/** @internal — custom spinner component from global config. */
|
|
49
|
+
protected readonly customSpinner: _angular_core.Signal<_angular_core.Type<unknown> | null>;
|
|
50
|
+
/** @internal — final visibility after delay + minDuration. */
|
|
51
|
+
readonly visible: _angular_core.Signal<boolean>;
|
|
52
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxLoadingIndicator, never>;
|
|
53
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxLoadingIndicator, "cngx-loading-indicator", never, { "state": { "alias": "state"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "delay": { "alias": "delay"; "required": false; "isSignal": true; }; "minDuration": { "alias": "minDuration"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Loading overlay — content container that blocks interaction while loading.
|
|
58
|
+
*
|
|
59
|
+
* Projects content inside a wrapper that receives `inert` during loading.
|
|
60
|
+
* Renders a centered spinner over a semi-transparent backdrop.
|
|
61
|
+
* Manages focus save/restore across the inert lifecycle.
|
|
62
|
+
*
|
|
63
|
+
* Uses `display: grid` with a shared grid cell — backdrop and content
|
|
64
|
+
* overlap naturally without `position: absolute` or `display: contents`.
|
|
65
|
+
*
|
|
66
|
+
* ### With async state
|
|
67
|
+
* ```html
|
|
68
|
+
* <cngx-loading-overlay [state]="tableData">
|
|
69
|
+
* <table>...</table>
|
|
70
|
+
* </cngx-loading-overlay>
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* ### Manual boolean
|
|
74
|
+
* ```html
|
|
75
|
+
* <cngx-loading-overlay [loading]="isSaving()">
|
|
76
|
+
* <form>...</form>
|
|
77
|
+
* </cngx-loading-overlay>
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* ### First load only (refresh uses the container's built-in bar)
|
|
81
|
+
* ```html
|
|
82
|
+
* <cngx-loading-overlay [state]="query" [firstLoadOnly]="true">
|
|
83
|
+
* <cngx-async-container [state]="query">...</cngx-async-container>
|
|
84
|
+
* </cngx-loading-overlay>
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
declare class CngxLoadingOverlay {
|
|
88
|
+
private readonly doc;
|
|
89
|
+
private readonly config;
|
|
90
|
+
/** Bind an async state — shows overlay when `isBusy()`. */
|
|
91
|
+
readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
92
|
+
/** Direct boolean control — alternative to `[state]`. */
|
|
93
|
+
readonly loading: _angular_core.InputSignal<boolean>;
|
|
94
|
+
/** Screen reader label for the spinner. */
|
|
95
|
+
readonly label: _angular_core.InputSignal<string>;
|
|
96
|
+
/** Delay in ms before showing the overlay. Falls back to global config, then 200ms. */
|
|
97
|
+
readonly delay: _angular_core.InputSignal<number>;
|
|
98
|
+
/** Minimum display time in ms once visible. Falls back to global config, then 500ms. */
|
|
99
|
+
readonly minDuration: _angular_core.InputSignal<number>;
|
|
100
|
+
/**
|
|
101
|
+
* When `true`, the overlay only activates during the first load (`isFirstLoad()`),
|
|
102
|
+
* not during refreshes. Use the async container's built-in refresh bar for
|
|
103
|
+
* subsequent loads to avoid content jumps under the backdrop.
|
|
104
|
+
*/
|
|
105
|
+
readonly firstLoadOnly: _angular_core.InputSignal<boolean>;
|
|
106
|
+
/** @internal */
|
|
107
|
+
protected readonly isActive: _angular_core.Signal<boolean>;
|
|
108
|
+
/** @internal — debounced visibility via shared timer factory. */
|
|
109
|
+
protected readonly visible: _angular_core.Signal<boolean>;
|
|
110
|
+
private readonly savedFocus;
|
|
111
|
+
private readonly contentWrapper;
|
|
112
|
+
private readonly spinnerEl;
|
|
113
|
+
constructor();
|
|
114
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxLoadingOverlay, never>;
|
|
115
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxLoadingOverlay, "cngx-loading-overlay", never, { "state": { "alias": "state"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "delay": { "alias": "delay"; "required": false; "isSignal": true; }; "minDuration": { "alias": "minDuration"; "required": false; "isSignal": true; }; "firstLoadOnly": { "alias": "firstLoadOnly"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Visual variant for the progress indicator. */
|
|
119
|
+
type ProgressVariant = 'linear' | 'circular';
|
|
120
|
+
/**
|
|
121
|
+
* Progress indicator atom — determinate or indeterminate.
|
|
122
|
+
*
|
|
123
|
+
* Automatically switches between modes based on whether `progress` is defined:
|
|
124
|
+
* - **Indeterminate** (`progress === undefined`) — animated line, no value
|
|
125
|
+
* - **Determinate** (`progress` 0–100) — bar with percentage
|
|
126
|
+
*
|
|
127
|
+
* CSS `transition` on bar width (300ms ease-out) smooths jumpy updates.
|
|
128
|
+
* `aria-valuenow` is only present in determinate mode — AT uses its
|
|
129
|
+
* absence to distinguish the two modes.
|
|
130
|
+
*
|
|
131
|
+
* ### With async state
|
|
132
|
+
* ```html
|
|
133
|
+
* <cngx-progress [state]="uploadState" label="File upload" [showLabel]="true" />
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* ### Manual progress
|
|
137
|
+
* ```html
|
|
138
|
+
* <cngx-progress [progress]="percent()" label="Processing" />
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
declare class CngxProgress {
|
|
142
|
+
/** Bind an async state — reads `progress()` for determinate mode. */
|
|
143
|
+
readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
144
|
+
/** Direct progress value (0–100). `undefined` = indeterminate. */
|
|
145
|
+
readonly progress: _angular_core.InputSignal<number | undefined>;
|
|
146
|
+
/** Visual variant. */
|
|
147
|
+
readonly variant: _angular_core.InputSignal<ProgressVariant>;
|
|
148
|
+
/** Show percentage label next to the bar. */
|
|
149
|
+
readonly showLabel: _angular_core.InputSignal<boolean>;
|
|
150
|
+
/** Screen reader label describing *what* is progressing. */
|
|
151
|
+
readonly label: _angular_core.InputSignal<string>;
|
|
152
|
+
/** @internal */
|
|
153
|
+
protected readonly effectiveProgress: _angular_core.Signal<number | undefined>;
|
|
154
|
+
/** @internal */
|
|
155
|
+
protected readonly isDeterminate: _angular_core.Signal<boolean>;
|
|
156
|
+
/** @internal — `null` removes the attribute from the DOM for indeterminate mode. */
|
|
157
|
+
protected readonly ariaValueNow: _angular_core.Signal<number | null>;
|
|
158
|
+
/** @internal */
|
|
159
|
+
protected readonly ariaValueText: _angular_core.Signal<string | null>;
|
|
160
|
+
/** @internal */
|
|
161
|
+
protected readonly circleDashArray: string;
|
|
162
|
+
/** @internal — SVG circle dash offset for determinate circular mode. */
|
|
163
|
+
protected readonly circleDashOffset: _angular_core.Signal<number>;
|
|
164
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxProgress, never>;
|
|
165
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxProgress, "cngx-progress", never, { "state": { "alias": "state"; "required": false; "isSignal": true; }; "progress": { "alias": "progress"; "required": false; "isSignal": true; }; "variant": { "alias": "variant"; "required": false; "isSignal": true; }; "showLabel": { "alias": "showLabel"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Severity level for the alert — determines visual style, icon, and ARIA role. */
|
|
169
|
+
type AlertSeverity = 'info' | 'success' | 'warning' | 'error';
|
|
170
|
+
/** Visibility phase for enter/exit CSS animations. */
|
|
171
|
+
type AlertVisibilityPhase = 'hidden' | 'entering' | 'visible' | 'exiting';
|
|
172
|
+
/** Content slot directive for custom alert icons. */
|
|
173
|
+
declare class CngxAlertIcon {
|
|
174
|
+
readonly templateRef: TemplateRef<any> | null;
|
|
175
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAlertIcon, never>;
|
|
176
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAlertIcon, "[cngxAlertIcon]", never, {}, {}, never, never, true, never>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Action button marker inside an alert. Restricts to button and anchor elements.
|
|
180
|
+
*
|
|
181
|
+
* When present, the alert container uses `aria-atomic="false"` to prevent
|
|
182
|
+
* re-announcing the entire alert on button interaction.
|
|
183
|
+
*
|
|
184
|
+
* ```html
|
|
185
|
+
* <cngx-alert severity="error" title="Save failed" [state]="saveState">
|
|
186
|
+
* Check your connection and try again.
|
|
187
|
+
* <button cngxAlertAction (click)="retry()">Retry</button>
|
|
188
|
+
* </cngx-alert>
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
declare class CngxAlertAction {
|
|
192
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAlertAction, never>;
|
|
193
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAlertAction, "button[cngxAlertAction], a[cngxAlertAction]", never, {}, {}, never, never, true, never>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Inline alert atom with enter/exit animations, state-driven visibility,
|
|
197
|
+
* auto-dismiss with pause-on-hover/focus, and optional auto-collapse.
|
|
198
|
+
*
|
|
199
|
+
* Three visibility modes:
|
|
200
|
+
* - **Static** (no `[state]` or `[when]`): always visible
|
|
201
|
+
* - **State-driven** (`[state]`): auto-shows on error/success/loading, auto-hides on idle
|
|
202
|
+
* - **Boolean-driven** (`[when]`): visible when true, hidden when false
|
|
203
|
+
*
|
|
204
|
+
* `[state]` takes precedence over `[when]`.
|
|
205
|
+
*/
|
|
206
|
+
declare class CngxAlert {
|
|
207
|
+
private readonly config;
|
|
208
|
+
private readonly destroyRef;
|
|
209
|
+
/** Alert severity — determines visual style, default icon, and ARIA role. */
|
|
210
|
+
readonly severity: _angular_core.InputSignal<AlertSeverity>;
|
|
211
|
+
/** Optional title displayed above the content. */
|
|
212
|
+
readonly title: _angular_core.InputSignal<string | undefined>;
|
|
213
|
+
/**
|
|
214
|
+
* Shows a dismiss button.
|
|
215
|
+
* @deprecated Use `closable` instead.
|
|
216
|
+
*/
|
|
217
|
+
readonly dismissible: _angular_core.InputSignal<boolean>;
|
|
218
|
+
/** Shows a dismiss button. Preferred over deprecated `dismissible`. */
|
|
219
|
+
readonly closable: _angular_core.InputSignal<boolean>;
|
|
220
|
+
/** Bind an async state — auto-shows on error/success/loading, auto-hides on idle. */
|
|
221
|
+
readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
|
|
222
|
+
/**
|
|
223
|
+
* Boolean visibility trigger. When set, controls alert visibility directly.
|
|
224
|
+
* `[state]` takes precedence over `[when]`.
|
|
225
|
+
*/
|
|
226
|
+
readonly when: _angular_core.InputSignal<boolean | undefined>;
|
|
227
|
+
/**
|
|
228
|
+
* Auto-dismiss delay in ms for success state or timed alerts.
|
|
229
|
+
* Set to `undefined` to disable auto-dismiss (persistent).
|
|
230
|
+
*/
|
|
231
|
+
readonly autoDismissDelay: _angular_core.InputSignal<number | undefined>;
|
|
232
|
+
/** Enables auto-collapse after `collapseDelay`. Visual only — SR reads full content. */
|
|
233
|
+
readonly collapsible: _angular_core.InputSignal<boolean>;
|
|
234
|
+
/** Delay in ms before auto-collapsing. Defaults to `autoDismissDelay`. */
|
|
235
|
+
readonly collapseDelay: _angular_core.InputSignal<number | undefined>;
|
|
236
|
+
/** Emitted when the dismiss button is clicked. */
|
|
237
|
+
readonly dismissed: _angular_core.OutputEmitterRef<void>;
|
|
238
|
+
/** @internal — detects projected custom icon to hide default/global icon. */
|
|
239
|
+
protected readonly customIcon: _angular_core.Signal<CngxAlertIcon | undefined>;
|
|
240
|
+
/** @internal — detects projected action buttons for aria-atomic strategy. */
|
|
241
|
+
protected readonly hasActions: _angular_core.Signal<CngxAlertAction | undefined>;
|
|
242
|
+
private readonly manualDismissed;
|
|
243
|
+
private readonly autoDismissed;
|
|
244
|
+
private readonly collapsedState;
|
|
245
|
+
private readonly announcementState;
|
|
246
|
+
/** @internal — animation phase, drives host CSS classes. */
|
|
247
|
+
protected readonly visibilityPhase: _angular_core.WritableSignal<AlertVisibilityPhase>;
|
|
248
|
+
private readonly autoDismissTimer;
|
|
249
|
+
private readonly collapseTimer;
|
|
250
|
+
private animationFallbackId;
|
|
251
|
+
/** @internal — global icon component for the current severity (from provideFeedback config). */
|
|
252
|
+
protected readonly globalIcon: _angular_core.Signal<_angular_core.Type<unknown> | null>;
|
|
253
|
+
/** @internal — merged closable from new and deprecated input. */
|
|
254
|
+
protected readonly effectiveClosable: _angular_core.Signal<boolean>;
|
|
255
|
+
/** @internal — ARIA role: 'alert' for error/warning, 'status' for info/success. */
|
|
256
|
+
protected readonly ariaRole: _angular_core.Signal<"alert" | "status">;
|
|
257
|
+
/** @internal — false when actions are projected to prevent full re-announcement. */
|
|
258
|
+
protected readonly ariaAtomic: _angular_core.Signal<"false" | "true">;
|
|
259
|
+
/** @internal — true when bound state is in a busy status. */
|
|
260
|
+
protected readonly isStateBusy: _angular_core.Signal<boolean>;
|
|
261
|
+
/**
|
|
262
|
+
* @internal — whether the alert SHOULD be visible (before animation).
|
|
263
|
+
* Drives the animation effect which manages visibilityPhase.
|
|
264
|
+
*/
|
|
265
|
+
protected readonly shouldBeVisible: _angular_core.Signal<boolean>;
|
|
266
|
+
/** @internal — true when the alert is currently visible (post-animation). */
|
|
267
|
+
protected readonly isVisible: _angular_core.Signal<boolean>;
|
|
268
|
+
/** @internal — collapsed state (read-only public view). */
|
|
269
|
+
protected readonly collapsed: _angular_core.Signal<boolean>;
|
|
270
|
+
/** @internal — SR announcement text for state transitions. */
|
|
271
|
+
protected readonly announcement: _angular_core.Signal<string>;
|
|
272
|
+
private readonly effectiveCollapseDelay;
|
|
273
|
+
constructor();
|
|
274
|
+
private beginEnter;
|
|
275
|
+
private beginExit;
|
|
276
|
+
private onBecameVisible;
|
|
277
|
+
private onBecameHidden;
|
|
278
|
+
private scheduleAnimationFallback;
|
|
279
|
+
private clearAnimationFallback;
|
|
280
|
+
/** @internal */
|
|
281
|
+
protected handleAnimationEnd(event: AnimationEvent): void;
|
|
282
|
+
/** @internal */
|
|
283
|
+
protected handleDismiss(): void;
|
|
284
|
+
/** @internal — WCAG 2.2.1: pause auto-dismiss on hover. */
|
|
285
|
+
protected handlePointerEnter(): void;
|
|
286
|
+
/** @internal — resume timers on pointer leave. */
|
|
287
|
+
protected handlePointerLeave(): void;
|
|
288
|
+
/** @internal — WCAG 2.2.1: pause auto-dismiss on focus. */
|
|
289
|
+
protected handleFocusIn(): void;
|
|
290
|
+
/** @internal — resume timers on focus out. */
|
|
291
|
+
protected handleFocusOut(): void;
|
|
292
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAlert, never>;
|
|
293
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxAlert, "cngx-alert", never, { "severity": { "alias": "severity"; "required": false; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "dismissible": { "alias": "dismissible"; "required": false; "isSignal": true; }; "closable": { "alias": "closable"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "when": { "alias": "when"; "required": false; "isSignal": true; }; "autoDismissDelay": { "alias": "autoDismissDelay"; "required": false; "isSignal": true; }; "collapsible": { "alias": "collapsible"; "required": false; "isSignal": true; }; "collapseDelay": { "alias": "collapseDelay"; "required": false; "isSignal": true; }; }, { "dismissed": "dismissed"; }, ["customIcon", "hasActions"], ["[cngxAlertIcon]", "*", "[cngxAlertAction]"], true, never>;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Global configuration for all feedback components.
|
|
298
|
+
* Provided via `provideFeedback()` with `with*` features.
|
|
299
|
+
*/
|
|
300
|
+
interface FeedbackConfig {
|
|
301
|
+
/** Custom spinner component to replace the built-in SVG spinner. */
|
|
302
|
+
spinnerComponent?: Type<unknown>;
|
|
303
|
+
/** Custom icon components per alert severity. Replaces built-in SVG icons. */
|
|
304
|
+
alertIcons?: Partial<Record<AlertSeverity, Type<unknown>>>;
|
|
305
|
+
/** Default delay in ms before showing loading indicators. */
|
|
306
|
+
loadingDelay?: number;
|
|
307
|
+
/** Default minimum display time in ms for loading indicators. */
|
|
308
|
+
loadingMinDuration?: number;
|
|
309
|
+
/** Custom close/dismiss icon component — replaces default X SVG globally. */
|
|
310
|
+
closeIconComponent?: Type<unknown>;
|
|
311
|
+
/** Default auto-dismiss duration for toasts in ms. */
|
|
312
|
+
toastDefaultDuration?: number;
|
|
313
|
+
/** Dedup window for identical toasts in ms. */
|
|
314
|
+
toastDedupWindow?: number;
|
|
315
|
+
/** Default auto-dismiss duration for scoped alerts in ms. `undefined` = persistent. */
|
|
316
|
+
alertDefaultDuration?: number;
|
|
317
|
+
/** Dedup window for identical alerts in ms. */
|
|
318
|
+
alertDedupWindow?: number;
|
|
319
|
+
/** Default max visible alerts per stack. */
|
|
320
|
+
alertMaxVisible?: number;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Injection token for the global feedback configuration.
|
|
324
|
+
* Components read this with `inject(CNGX_FEEDBACK_CONFIG, { optional: true })`.
|
|
325
|
+
*/
|
|
326
|
+
declare const CNGX_FEEDBACK_CONFIG: InjectionToken<FeedbackConfig>;
|
|
327
|
+
/** A feature configuration function returned by `withXxx()` helpers. */
|
|
328
|
+
interface FeedbackFeature {
|
|
329
|
+
/** @internal */
|
|
330
|
+
readonly _apply: (config: FeedbackConfig) => FeedbackConfig;
|
|
331
|
+
/** @internal — additional providers contributed by this feature. */
|
|
332
|
+
readonly _providers?: Provider[];
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Register global defaults for all feedback components.
|
|
336
|
+
*
|
|
337
|
+
* ```ts
|
|
338
|
+
* bootstrapApplication(AppComponent, {
|
|
339
|
+
* providers: [
|
|
340
|
+
* provideFeedback(
|
|
341
|
+
* withSpinnerTemplate(MyLucideSpinner),
|
|
342
|
+
* withAlertIcons({ error: MyErrorIcon, warning: MyWarningIcon }),
|
|
343
|
+
* withLoadingDefaults({ delay: 300, minDuration: 600 }),
|
|
344
|
+
* ),
|
|
345
|
+
* ],
|
|
346
|
+
* });
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function provideFeedback(...features: FeedbackFeature[]): EnvironmentProviders;
|
|
350
|
+
/**
|
|
351
|
+
* Replace the built-in SVG spinner in `CngxLoadingIndicator` and `CngxLoadingOverlay`.
|
|
352
|
+
*
|
|
353
|
+
* The component receives no inputs — it should be a self-contained spinner
|
|
354
|
+
* (e.g. a Lucide `<loader-2>` with CSS animation, or a Material `<mat-spinner>`).
|
|
355
|
+
*
|
|
356
|
+
* ```ts
|
|
357
|
+
* provideFeedback(withSpinnerTemplate(MatProgressSpinner))
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
declare function withSpinnerTemplate(component: Type<unknown>): FeedbackFeature;
|
|
361
|
+
/**
|
|
362
|
+
* Replace the built-in SVG icons in `CngxAlert` per severity.
|
|
363
|
+
*
|
|
364
|
+
* Each component receives no inputs — it should render a single icon.
|
|
365
|
+
* Only specified severities are replaced; others keep the built-in SVG.
|
|
366
|
+
*
|
|
367
|
+
* ```ts
|
|
368
|
+
* provideFeedback(withAlertIcons({
|
|
369
|
+
* error: MyErrorIcon,
|
|
370
|
+
* warning: MyWarningIcon,
|
|
371
|
+
* success: MyCheckIcon,
|
|
372
|
+
* info: MyInfoIcon,
|
|
373
|
+
* }))
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
declare function withAlertIcons(icons: Partial<Record<AlertSeverity, Type<unknown>>>): FeedbackFeature;
|
|
377
|
+
/**
|
|
378
|
+
* Set default timing for all loading indicators and overlays.
|
|
379
|
+
*
|
|
380
|
+
* Individual components can still override via their `[delay]` and `[minDuration]` inputs.
|
|
381
|
+
*
|
|
382
|
+
* ```ts
|
|
383
|
+
* provideFeedback(withLoadingDefaults({ delay: 300, minDuration: 600 }))
|
|
384
|
+
* ```
|
|
385
|
+
*/
|
|
386
|
+
declare function withLoadingDefaults(opts: {
|
|
387
|
+
delay?: number;
|
|
388
|
+
minDuration?: number;
|
|
389
|
+
}): FeedbackFeature;
|
|
390
|
+
/**
|
|
391
|
+
* Replace the built-in X SVG in all close/dismiss buttons globally.
|
|
392
|
+
*
|
|
393
|
+
* The component receives no inputs — it should render a single icon.
|
|
394
|
+
* Per-instance override via content projection on `CngxCloseButton` takes precedence.
|
|
395
|
+
*
|
|
396
|
+
* ```ts
|
|
397
|
+
* provideFeedback(withCloseIcon(MyLucideXIcon))
|
|
398
|
+
* ```
|
|
399
|
+
*/
|
|
400
|
+
declare function withCloseIcon(component: Type<unknown>): FeedbackFeature;
|
|
401
|
+
/**
|
|
402
|
+
* Enable the toast system within `provideFeedback()`.
|
|
403
|
+
*
|
|
404
|
+
* Provides `CngxToaster` at the environment level.
|
|
405
|
+
* Without this feature, `CngxToastOn` and `CngxToastOutlet` will throw
|
|
406
|
+
* a `NullInjectorError` at runtime.
|
|
407
|
+
*
|
|
408
|
+
* @param opts Optional toast defaults.
|
|
409
|
+
*
|
|
410
|
+
* ```ts
|
|
411
|
+
* provideFeedback(
|
|
412
|
+
* withToasts(),
|
|
413
|
+
* withAlertIcons({ error: MyErrorIcon }),
|
|
414
|
+
* )
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
declare function withToasts(opts?: {
|
|
418
|
+
/** Default auto-dismiss duration in ms. */
|
|
419
|
+
defaultDuration?: number;
|
|
420
|
+
/** Dedup window in ms. */
|
|
421
|
+
dedupWindow?: number;
|
|
422
|
+
}): FeedbackFeature;
|
|
423
|
+
/**
|
|
424
|
+
* Enable the scoped alert system within `provideFeedback()`.
|
|
425
|
+
*
|
|
426
|
+
* Provides `CngxAlerter` at the environment level for root-level injection.
|
|
427
|
+
* Without this feature, `CngxAlerter` is only available via `CngxAlertStack`'s
|
|
428
|
+
* `viewProviders` (scoped injection).
|
|
429
|
+
*
|
|
430
|
+
* The token is opaque — always use `provideFeedback()` with feature functions,
|
|
431
|
+
* never construct the config object manually.
|
|
432
|
+
*
|
|
433
|
+
* @param opts Optional alert defaults.
|
|
434
|
+
*
|
|
435
|
+
* ```ts
|
|
436
|
+
* provideFeedback(
|
|
437
|
+
* withToasts(),
|
|
438
|
+
* withAlerts(),
|
|
439
|
+
* )
|
|
440
|
+
* ```
|
|
441
|
+
*/
|
|
442
|
+
declare function withAlerts(opts?: {
|
|
443
|
+
/** Default auto-dismiss duration in ms. `undefined` = persistent. */
|
|
444
|
+
defaultDuration?: number;
|
|
445
|
+
/** Dedup window in ms. */
|
|
446
|
+
dedupWindow?: number;
|
|
447
|
+
/** Default max visible alerts per stack. */
|
|
448
|
+
maxVisible?: number;
|
|
449
|
+
}): FeedbackFeature;
|
|
450
|
+
/**
|
|
451
|
+
* Enable the global banner system within `provideFeedback()`.
|
|
452
|
+
*
|
|
453
|
+
* Provides `CngxBanner` at the environment level.
|
|
454
|
+
* Without this feature, `CngxBannerOutlet` will throw a `NullInjectorError`.
|
|
455
|
+
*
|
|
456
|
+
* Banners are always persistent — no `duration`. Dismiss programmatically
|
|
457
|
+
* via `banner.dismiss(id)` when the condition resolves.
|
|
458
|
+
*
|
|
459
|
+
* ```ts
|
|
460
|
+
* provideFeedback(
|
|
461
|
+
* withToasts(),
|
|
462
|
+
* withAlerts(),
|
|
463
|
+
* withBanners(),
|
|
464
|
+
* )
|
|
465
|
+
* ```
|
|
466
|
+
*/
|
|
467
|
+
declare function withBanners(): FeedbackFeature;
|
|
468
|
+
|
|
469
|
+
/** Configuration for a programmatic alert. */
|
|
470
|
+
interface AlertConfig {
|
|
471
|
+
/** Alert message text (required). */
|
|
472
|
+
message: string;
|
|
473
|
+
/** Visual severity — determines icon, color, and ARIA role. */
|
|
474
|
+
severity?: AlertSeverity;
|
|
475
|
+
/** Optional bold title above the message. */
|
|
476
|
+
title?: string;
|
|
477
|
+
/** Whether the alert persists until explicitly dismissed. Default `true`. */
|
|
478
|
+
persistent?: boolean;
|
|
479
|
+
/** Auto-dismiss duration in ms. Only applies when `persistent` is false. */
|
|
480
|
+
duration?: number;
|
|
481
|
+
/** Show a dismiss button. Default `true`. */
|
|
482
|
+
dismissible?: boolean;
|
|
483
|
+
/** Scope key — only shown in stacks with matching scope. */
|
|
484
|
+
scope?: string;
|
|
485
|
+
}
|
|
486
|
+
/** Handle to a displayed alert — allows programmatic dismiss. */
|
|
487
|
+
interface AlertRef {
|
|
488
|
+
/** Programmatically dismiss this alert. */
|
|
489
|
+
dismiss(): void;
|
|
490
|
+
/** Emits after the alert is fully removed. */
|
|
491
|
+
afterDismissed(): Observable<void>;
|
|
492
|
+
}
|
|
493
|
+
/** @internal — tracked state for a single alert in the stack. */
|
|
494
|
+
interface AlertState {
|
|
495
|
+
readonly id: number;
|
|
496
|
+
readonly config: Required<Pick<AlertConfig, 'message' | 'severity' | 'dismissible' | 'persistent'>> & Pick<AlertConfig, 'title' | 'duration' | 'scope'>;
|
|
497
|
+
readonly createdAt: number;
|
|
498
|
+
readonly dismissed$: Subject<void>;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Scoped alert service — manages an alert stack as a signal array.
|
|
502
|
+
*
|
|
503
|
+
* Not `providedIn: 'root'`. Each `CngxAlertStack` provides its own instance
|
|
504
|
+
* via `viewProviders`, scoping alerts to that stack's subtree.
|
|
505
|
+
*
|
|
506
|
+
* For root-level injection, use `provideFeedback(withAlerts())`.
|
|
507
|
+
*/
|
|
508
|
+
declare class CngxAlerter {
|
|
509
|
+
private readonly destroyRef;
|
|
510
|
+
private readonly config;
|
|
511
|
+
private nextId;
|
|
512
|
+
/** Reactive alert stack — read by `CngxAlertStack`. */
|
|
513
|
+
readonly alerts: _angular_core.WritableSignal<readonly AlertState[]>;
|
|
514
|
+
private readonly dedupWindow;
|
|
515
|
+
private readonly defaultDuration;
|
|
516
|
+
constructor();
|
|
517
|
+
/** Show an alert. Returns a ref for programmatic dismiss. */
|
|
518
|
+
show(config: AlertConfig): AlertRef;
|
|
519
|
+
/** Dismiss a single alert by id. */
|
|
520
|
+
dismiss(id: number): void;
|
|
521
|
+
/** Dismiss all alerts (optionally filtered by scope). */
|
|
522
|
+
dismissAll(scope?: string): void;
|
|
523
|
+
private createRef;
|
|
524
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAlerter, never>;
|
|
525
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxAlerter>;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Scoped alert stack — renders alerts from its own `CngxAlerter` instance.
|
|
530
|
+
*
|
|
531
|
+
* Provides `CngxAlerter` via `viewProviders` — child components that
|
|
532
|
+
* `inject(CngxAlerter)` get this stack's instance. Supports nesting
|
|
533
|
+
* (each stack is independent).
|
|
534
|
+
*
|
|
535
|
+
* ### In a dialog
|
|
536
|
+
* ```html
|
|
537
|
+
* <dialog cngxDialog [submitAction]="save">
|
|
538
|
+
* <header cngxDialogTitle>Edit user</header>
|
|
539
|
+
* <cngx-alert-stack scope="user-form" position="top" />
|
|
540
|
+
* <form>...</form>
|
|
541
|
+
* </dialog>
|
|
542
|
+
* ```
|
|
543
|
+
*
|
|
544
|
+
* ### Programmatic usage
|
|
545
|
+
* ```typescript
|
|
546
|
+
* private readonly alerter = inject(CngxAlerter);
|
|
547
|
+
*
|
|
548
|
+
* handleErrors(errors: string[]) {
|
|
549
|
+
* this.alerter.dismissAll();
|
|
550
|
+
* errors.forEach(e => this.alerter.show({ message: e, severity: 'error' }));
|
|
551
|
+
* }
|
|
552
|
+
* ```
|
|
553
|
+
*/
|
|
554
|
+
declare class CngxAlertStack {
|
|
555
|
+
/** The scoped alerter instance — use to add/dismiss alerts programmatically. */
|
|
556
|
+
readonly alerter: CngxAlerter;
|
|
557
|
+
private readonly config;
|
|
558
|
+
/** Scope filter — only shows alerts matching this scope. */
|
|
559
|
+
readonly scope: _angular_core.InputSignal<string | undefined>;
|
|
560
|
+
/** Maximum visible alerts before collapse overflow. */
|
|
561
|
+
readonly maxVisible: _angular_core.InputSignal<number>;
|
|
562
|
+
/** Where new alerts appear. */
|
|
563
|
+
readonly position: _angular_core.InputSignal<"top" | "bottom">;
|
|
564
|
+
/** Reserve min-height for one alert to prevent layout shift. */
|
|
565
|
+
readonly reserveSpace: _angular_core.InputSignal<boolean>;
|
|
566
|
+
/** Auto-scroll stack into view when new alert appears. */
|
|
567
|
+
readonly autoScroll: _angular_core.InputSignal<boolean>;
|
|
568
|
+
/** @internal — expanded state. Resets when alert count drops to maxVisible or below. */
|
|
569
|
+
private readonly expanded;
|
|
570
|
+
/** @internal — alerts filtered by scope. */
|
|
571
|
+
private readonly scopedAlerts;
|
|
572
|
+
/** @internal — alerts visible within maxVisible limit. */
|
|
573
|
+
protected readonly visibleAlerts: _angular_core.Signal<readonly AlertState[]>;
|
|
574
|
+
/** @internal — number of hidden overflow alerts. */
|
|
575
|
+
protected readonly overflowCount: _angular_core.Signal<number>;
|
|
576
|
+
/** @internal — IDs of overflow alerts for aria-controls. */
|
|
577
|
+
protected readonly overflowIds: _angular_core.Signal<string>;
|
|
578
|
+
/** @internal — resolve icon component from global config. */
|
|
579
|
+
protected iconFor(alert: AlertState): _angular_core.Type<unknown> | null;
|
|
580
|
+
/** @internal */
|
|
581
|
+
protected handleExpandOverflow(): void;
|
|
582
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAlertStack, never>;
|
|
583
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxAlertStack, "cngx-alert-stack", never, { "scope": { "alias": "scope"; "required": false; "isSignal": true; }; "maxVisible": { "alias": "maxVisible"; "required": false; "isSignal": true; }; "position": { "alias": "position"; "required": false; "isSignal": true; }; "reserveSpace": { "alias": "reserveSpace"; "required": false; "isSignal": true; }; "autoScroll": { "alias": "autoScroll"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Declarative state-to-alert bridge for scoped alert stacks.
|
|
588
|
+
*
|
|
589
|
+
* Place on any element inside a `CngxAlertStack` subtree — fires an alert
|
|
590
|
+
* when the bound `CngxAsyncState` transitions to `error` (or optionally `success`).
|
|
591
|
+
* Only fires on actual transitions, not on initial `idle` state.
|
|
592
|
+
*
|
|
593
|
+
* ```html
|
|
594
|
+
* <cngx-alert-stack scope="form" />
|
|
595
|
+
*
|
|
596
|
+
* <button [cngxAsyncClick]="save"
|
|
597
|
+
* [cngxAlertOn]="saveState"
|
|
598
|
+
* alertError="Save failed"
|
|
599
|
+
* [alertErrorDetail]="true">
|
|
600
|
+
* Save
|
|
601
|
+
* </button>
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
declare class CngxAlertOn {
|
|
605
|
+
private readonly alerter;
|
|
606
|
+
private readonly statefulFallback;
|
|
607
|
+
/**
|
|
608
|
+
* The async state to watch. Optional — when omitted, falls back to
|
|
609
|
+
* `CNGX_STATEFUL` from an ancestor/self component. A bare `cngxAlertOn`
|
|
610
|
+
* attribute is treated as "no input bound".
|
|
611
|
+
*/
|
|
612
|
+
readonly state: _angular_core.InputSignalWithTransform<CngxAsyncState<unknown> | undefined, "" | CngxAsyncState<unknown> | undefined>;
|
|
613
|
+
/** Effective state — input wins over ancestor `CNGX_STATEFUL`. */
|
|
614
|
+
private readonly effectiveState;
|
|
615
|
+
/** Alert message on success. If not set, no success alert fires. */
|
|
616
|
+
readonly alertSuccess: _angular_core.InputSignal<string | undefined>;
|
|
617
|
+
/** Alert message on error. If not set, no error alert fires. */
|
|
618
|
+
readonly alertError: _angular_core.InputSignal<string | undefined>;
|
|
619
|
+
/** Include the error detail message in the alert body. */
|
|
620
|
+
readonly alertErrorDetail: _angular_core.InputSignal<boolean>;
|
|
621
|
+
/** Scope for the alert — matches against `CngxAlertStack`'s `[scope]` input. */
|
|
622
|
+
readonly alertScope: _angular_core.InputSignal<string | undefined>;
|
|
623
|
+
constructor();
|
|
624
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAlertOn, never>;
|
|
625
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAlertOn, "[cngxAlertOn]", never, { "state": { "alias": "cngxAlertOn"; "required": false; "isSignal": true; }; "alertSuccess": { "alias": "alertSuccess"; "required": false; "isSignal": true; }; "alertError": { "alias": "alertError"; "required": false; "isSignal": true; }; "alertErrorDetail": { "alias": "alertErrorDetail"; "required": false; "isSignal": true; }; "alertScope": { "alias": "alertScope"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
/** Configuration for a system-level banner. */
|
|
629
|
+
interface BannerConfig {
|
|
630
|
+
/** Banner message text (required). */
|
|
631
|
+
message: string;
|
|
632
|
+
/** Required dedup key — only one banner per id. `show()` with existing id calls `update()`. */
|
|
633
|
+
id: string;
|
|
634
|
+
/** Visual severity — determines icon, color, and ARIA role. */
|
|
635
|
+
severity?: AlertSeverity;
|
|
636
|
+
/**
|
|
637
|
+
* Action button. If `handler` returns a Promise, the button shows `aria-busy`
|
|
638
|
+
* and is disabled until resolved. On error, the banner stays open.
|
|
639
|
+
*/
|
|
640
|
+
action?: {
|
|
641
|
+
label: string;
|
|
642
|
+
handler: () => void | Promise<void>;
|
|
643
|
+
};
|
|
644
|
+
/** Show a dismiss button. Default `true`. */
|
|
645
|
+
dismissible?: boolean;
|
|
646
|
+
}
|
|
647
|
+
/** Handle to a displayed banner. */
|
|
648
|
+
interface BannerRef {
|
|
649
|
+
/** Programmatically dismiss this banner. */
|
|
650
|
+
dismiss(): void;
|
|
651
|
+
/** Emits after the banner is fully removed. */
|
|
652
|
+
afterDismissed(): Observable<void>;
|
|
653
|
+
}
|
|
654
|
+
/** @internal — tracked state for a single banner. */
|
|
655
|
+
interface BannerState {
|
|
656
|
+
readonly id: string;
|
|
657
|
+
readonly config: Required<Pick<BannerConfig, 'message' | 'id' | 'severity' | 'dismissible'>> & Pick<BannerConfig, 'action'>;
|
|
658
|
+
/** Whether the action handler is currently executing. */
|
|
659
|
+
readonly actionPending: boolean;
|
|
660
|
+
/** Error from the last action handler execution. */
|
|
661
|
+
readonly actionError: unknown;
|
|
662
|
+
readonly dismissed$: Subject<void>;
|
|
663
|
+
}
|
|
664
|
+
/**
|
|
665
|
+
* Global banner service — manages system-level banners as a signal array.
|
|
666
|
+
*
|
|
667
|
+
* Not `providedIn: 'root'`. Provide via `provideFeedback(withBanners())`.
|
|
668
|
+
*
|
|
669
|
+
* Banners are always persistent — no auto-dismiss. Use `dismiss(id)` to remove
|
|
670
|
+
* programmatically (e.g., on reconnect, on session extend).
|
|
671
|
+
*
|
|
672
|
+
* `id` is required and serves as the dedup key. Calling `show()` with an existing
|
|
673
|
+
* `id` calls `update()` instead (e.g., session timeout countdown).
|
|
674
|
+
*
|
|
675
|
+
* ```typescript
|
|
676
|
+
* private readonly banner = inject(CngxBanner);
|
|
677
|
+
*
|
|
678
|
+
* this.banner.show({
|
|
679
|
+
* message: 'Your session expires in 5 minutes',
|
|
680
|
+
* severity: 'warning',
|
|
681
|
+
* id: 'auth:session-timeout',
|
|
682
|
+
* action: { label: 'Extend', handler: () => this.extendSession() },
|
|
683
|
+
* });
|
|
684
|
+
* ```
|
|
685
|
+
*/
|
|
686
|
+
declare class CngxBanner {
|
|
687
|
+
private readonly destroyRef;
|
|
688
|
+
/** Reactive banner stack — read by `CngxBannerOutlet`. */
|
|
689
|
+
readonly banners: _angular_core.WritableSignal<readonly BannerState[]>;
|
|
690
|
+
constructor();
|
|
691
|
+
/** Show a banner. If `id` already exists, updates it instead. */
|
|
692
|
+
show(config: BannerConfig): BannerRef;
|
|
693
|
+
/** Update an existing banner in-place by id. */
|
|
694
|
+
update(id: string, patch: Partial<BannerConfig>): void;
|
|
695
|
+
/** Dismiss a banner by id. */
|
|
696
|
+
dismiss(id: string): void;
|
|
697
|
+
/** Dismiss all banners. */
|
|
698
|
+
dismissAll(): void;
|
|
699
|
+
/**
|
|
700
|
+
* @internal — execute an action handler with async lifecycle.
|
|
701
|
+
* Sets `actionPending` during execution, `actionError` on failure.
|
|
702
|
+
*/
|
|
703
|
+
executeAction(id: string): Promise<void>;
|
|
704
|
+
private createRef;
|
|
705
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBanner, never>;
|
|
706
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxBanner>;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Banner outlet — renders the global banner stack at the top of the page.
|
|
711
|
+
*
|
|
712
|
+
* Place once in the app shell, above `<router-outlet>`.
|
|
713
|
+
* Requires `provideFeedback(withBanners())`.
|
|
714
|
+
*
|
|
715
|
+
* Banners present at first render appear without animation to avoid
|
|
716
|
+
* layout jump on page load.
|
|
717
|
+
*
|
|
718
|
+
* ```html
|
|
719
|
+
* <cngx-banner-outlet />
|
|
720
|
+
* <router-outlet />
|
|
721
|
+
* ```
|
|
722
|
+
*/
|
|
723
|
+
declare class CngxBannerOutlet {
|
|
724
|
+
protected readonly service: CngxBanner;
|
|
725
|
+
private readonly config;
|
|
726
|
+
/**
|
|
727
|
+
* @internal — skip enter animation for banners present at first render.
|
|
728
|
+
* Prevents layout jump when banners are known before first paint (e.g., offline state).
|
|
729
|
+
*/
|
|
730
|
+
protected readonly pastFirstRender: _angular_core.WritableSignal<boolean>;
|
|
731
|
+
constructor();
|
|
732
|
+
/** @internal — resolve icon from global config. */
|
|
733
|
+
protected iconFor(banner: BannerState): _angular_core.Type<unknown> | null;
|
|
734
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBannerOutlet, never>;
|
|
735
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxBannerOutlet, "cngx-banner-outlet", never, {}, {}, never, never, true, never>;
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/**
|
|
739
|
+
* Declarative state-to-banner bridge.
|
|
740
|
+
*
|
|
741
|
+
* Place on any element — shows a global banner when the bound `CngxAsyncState`
|
|
742
|
+
* transitions to `error`. Dismisses automatically on `success` or `idle`.
|
|
743
|
+
* Only fires on actual transitions, not on initial `idle` state.
|
|
744
|
+
*
|
|
745
|
+
* ```html
|
|
746
|
+
* <div [cngxBannerOn]="connectionState"
|
|
747
|
+
* bannerId="net:offline"
|
|
748
|
+
* bannerError="You are offline. Changes will sync when reconnected.">
|
|
749
|
+
* </div>
|
|
750
|
+
* ```
|
|
751
|
+
*/
|
|
752
|
+
declare class CngxBannerOn {
|
|
753
|
+
private readonly bannerService;
|
|
754
|
+
private readonly statefulFallback;
|
|
755
|
+
/**
|
|
756
|
+
* The async state to watch. Optional — when omitted, falls back to
|
|
757
|
+
* `CNGX_STATEFUL` from an ancestor/self component. A bare `cngxBannerOn`
|
|
758
|
+
* attribute is treated as "no input bound".
|
|
759
|
+
*/
|
|
760
|
+
readonly state: _angular_core.InputSignalWithTransform<CngxAsyncState<unknown> | undefined, "" | CngxAsyncState<unknown> | undefined>;
|
|
761
|
+
/** Effective state — input wins over ancestor `CNGX_STATEFUL`. */
|
|
762
|
+
private readonly effectiveState;
|
|
763
|
+
/** Required banner id — dedup key. */
|
|
764
|
+
readonly bannerId: _angular_core.InputSignal<string>;
|
|
765
|
+
/** Banner message on error. */
|
|
766
|
+
readonly bannerError: _angular_core.InputSignal<string | undefined>;
|
|
767
|
+
/** Banner severity on error. Default `'error'`. */
|
|
768
|
+
readonly bannerSeverity: _angular_core.InputSignal<"warning" | "error">;
|
|
769
|
+
/** Include error detail in the message. */
|
|
770
|
+
readonly bannerErrorDetail: _angular_core.InputSignal<boolean>;
|
|
771
|
+
constructor();
|
|
772
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBannerOn, never>;
|
|
773
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxBannerOn, "[cngxBannerOn]", never, { "state": { "alias": "cngxBannerOn"; "required": false; "isSignal": true; }; "bannerId": { "alias": "bannerId"; "required": true; "isSignal": true; }; "bannerError": { "alias": "bannerError"; "required": false; "isSignal": true; }; "bannerSeverity": { "alias": "bannerSeverity"; "required": false; "isSignal": true; }; "bannerErrorDetail": { "alias": "bannerErrorDetail"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
/**
|
|
777
|
+
* Declarative banner trigger — renders nothing, shows/dismisses a global banner
|
|
778
|
+
* when `[when]` changes.
|
|
779
|
+
*
|
|
780
|
+
* When `[when]` becomes `true`, the banner appears. When `false`, it is dismissed.
|
|
781
|
+
* The banner's lifecycle is tied to the signal — perfect for reactive system state
|
|
782
|
+
* like `isOffline()` or `sessionExpiring()`.
|
|
783
|
+
*
|
|
784
|
+
* Requires `provideFeedback(withBanners())`.
|
|
785
|
+
*
|
|
786
|
+
* ```html
|
|
787
|
+
* <cngx-banner-trigger
|
|
788
|
+
* [when]="isOffline()"
|
|
789
|
+
* message="You are offline. Changes will sync when reconnected."
|
|
790
|
+
* id="net:offline"
|
|
791
|
+
* severity="error" />
|
|
792
|
+
*
|
|
793
|
+
* <cngx-banner-trigger
|
|
794
|
+
* [when]="sessionExpiring()"
|
|
795
|
+
* message="Session expires soon."
|
|
796
|
+
* id="auth:session"
|
|
797
|
+
* severity="warning"
|
|
798
|
+
* actionLabel="Extend"
|
|
799
|
+
* [actionHandler]="extendSession" />
|
|
800
|
+
* ```
|
|
801
|
+
*/
|
|
802
|
+
declare class CngxBannerTrigger {
|
|
803
|
+
private readonly banner;
|
|
804
|
+
private readonly destroyRef;
|
|
805
|
+
/** When `true`, the banner is shown. When `false`, it is dismissed. */
|
|
806
|
+
readonly when: _angular_core.InputSignal<boolean>;
|
|
807
|
+
/** Banner message text. */
|
|
808
|
+
readonly message: _angular_core.InputSignal<string>;
|
|
809
|
+
/** Required unique id — dedup key. */
|
|
810
|
+
readonly id: _angular_core.InputSignal<string>;
|
|
811
|
+
/** Visual severity. */
|
|
812
|
+
readonly severity: _angular_core.InputSignal<AlertSeverity>;
|
|
813
|
+
/** Show dismiss button. */
|
|
814
|
+
readonly dismissible: _angular_core.InputSignal<boolean>;
|
|
815
|
+
/** Action button label. */
|
|
816
|
+
readonly actionLabel: _angular_core.InputSignal<string | undefined>;
|
|
817
|
+
/** Action button handler. */
|
|
818
|
+
readonly actionHandler: _angular_core.InputSignal<(() => void | Promise<void>) | undefined>;
|
|
819
|
+
constructor();
|
|
820
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBannerTrigger, never>;
|
|
821
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxBannerTrigger, "cngx-banner-trigger", never, { "when": { "alias": "when"; "required": true; "isSignal": true; }; "message": { "alias": "message"; "required": true; "isSignal": true; }; "id": { "alias": "id"; "required": true; "isSignal": true; }; "severity": { "alias": "severity"; "required": false; "isSignal": true; }; "dismissible": { "alias": "dismissible"; "required": false; "isSignal": true; }; "actionLabel": { "alias": "actionLabel"; "required": false; "isSignal": true; }; "actionHandler": { "alias": "actionHandler"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/** Configuration for a single toast. */
|
|
825
|
+
interface ToastConfig {
|
|
826
|
+
/** Toast message text. Used as sole text when `title` is not set. */
|
|
827
|
+
message: string;
|
|
828
|
+
/**
|
|
829
|
+
* Bold primary text — renders above `description` or `message`.
|
|
830
|
+
* When set, the toast switches to a two-line layout (title + description).
|
|
831
|
+
* When not set, `message` renders as a single line (backwards-compatible).
|
|
832
|
+
*/
|
|
833
|
+
title?: string;
|
|
834
|
+
/**
|
|
835
|
+
* Secondary description text — renders below `title`.
|
|
836
|
+
* Falls back to `message` when `title` is set but `description` is not.
|
|
837
|
+
* Ignored when `title` is not set.
|
|
838
|
+
*/
|
|
839
|
+
description?: string;
|
|
840
|
+
/** Visual severity — determines icon, color, and ARIA role. */
|
|
841
|
+
severity?: AlertSeverity;
|
|
842
|
+
/** Auto-dismiss duration in ms, or `'persistent'` for manual dismiss only. */
|
|
843
|
+
duration?: number | 'persistent';
|
|
844
|
+
/** Optional action button inside the toast. */
|
|
845
|
+
action?: {
|
|
846
|
+
label: string;
|
|
847
|
+
handler: () => void;
|
|
848
|
+
};
|
|
849
|
+
/** Show dismiss button. */
|
|
850
|
+
dismissible?: boolean;
|
|
851
|
+
/**
|
|
852
|
+
* Custom component rendered as the toast body (Stufe 2).
|
|
853
|
+
* Replaces the default `message`/`description` text.
|
|
854
|
+
* `title` is still rendered above the component if set.
|
|
855
|
+
*
|
|
856
|
+
* A11y: avoid focusable elements (`<a>`, `<button>`, `<input>`) inside
|
|
857
|
+
* the component — they are unreachable inside a `role="status"` live region.
|
|
858
|
+
*/
|
|
859
|
+
content?: Type<unknown>;
|
|
860
|
+
/** Inputs passed to the `content` component via `NgComponentOutlet`. */
|
|
861
|
+
contentInputs?: Record<string, unknown>;
|
|
862
|
+
}
|
|
863
|
+
/** Handle to a displayed toast — allows programmatic dismiss. */
|
|
864
|
+
interface ToastRef {
|
|
865
|
+
/** Programmatically dismiss this toast. */
|
|
866
|
+
dismiss(): void;
|
|
867
|
+
/** Emits after the toast is fully removed (post-animation). */
|
|
868
|
+
afterDismissed(): Observable<void>;
|
|
869
|
+
}
|
|
870
|
+
/** Internal toast state tracked by the service. */
|
|
871
|
+
interface ToastState {
|
|
872
|
+
readonly id: number;
|
|
873
|
+
readonly config: Required<Pick<ToastConfig, 'message' | 'severity' | 'dismissible'>> & Pick<ToastConfig, 'action' | 'title' | 'description' | 'content' | 'contentInputs'> & {
|
|
874
|
+
duration: number | 'persistent';
|
|
875
|
+
};
|
|
876
|
+
readonly createdAt: number;
|
|
877
|
+
/** Timestamp when the current timer started (created or last resumed). */
|
|
878
|
+
readonly timerStartedAt: number;
|
|
879
|
+
/** Dedup counter — incremented when identical toast fires again. */
|
|
880
|
+
readonly count: number;
|
|
881
|
+
/** Remaining ms when timer was paused (hover/focus). `undefined` = not paused. */
|
|
882
|
+
readonly pausedRemaining: number | undefined;
|
|
883
|
+
/** Timer handle for auto-dismiss. */
|
|
884
|
+
readonly timer: ReturnType<typeof setTimeout> | undefined;
|
|
885
|
+
/** Subject that emits on dismiss. */
|
|
886
|
+
readonly dismissed$: Subject<void>;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Feature-scoped toast service — not `providedIn: 'root'`.
|
|
890
|
+
*
|
|
891
|
+
* Provide via `provideFeedback(withToasts())` or `provideToasts()` at the
|
|
892
|
+
* app-shell or route level.
|
|
893
|
+
*
|
|
894
|
+
* Manages the toast stack as a signal array. `CngxToastOutlet` reads it reactively.
|
|
895
|
+
*/
|
|
896
|
+
declare class CngxToaster {
|
|
897
|
+
private readonly destroyRef;
|
|
898
|
+
private readonly config;
|
|
899
|
+
private nextId;
|
|
900
|
+
/** Reactive toast stack — read by `CngxToastOutlet`. */
|
|
901
|
+
readonly toasts: _angular_core.WritableSignal<readonly ToastState[]>;
|
|
902
|
+
/** Default duration for non-error toasts. */
|
|
903
|
+
readonly defaultDuration: _angular_core.WritableSignal<number>;
|
|
904
|
+
/** Dedup window in ms — identical toasts within this window are merged. */
|
|
905
|
+
readonly dedupWindow: _angular_core.WritableSignal<number>;
|
|
906
|
+
constructor();
|
|
907
|
+
/** Show a toast. Returns a ref for programmatic control. */
|
|
908
|
+
show(config: ToastConfig): ToastRef;
|
|
909
|
+
/** @internal — called by toast-outlet on hover/focus. */
|
|
910
|
+
pauseTimer(id: number): void;
|
|
911
|
+
/** @internal — called by toast-outlet on mouse-leave/focus-out. */
|
|
912
|
+
resumeTimer(id: number): void;
|
|
913
|
+
/** Dismiss a toast by id. */
|
|
914
|
+
dismiss(id: number): void;
|
|
915
|
+
/** Dismiss all toasts. */
|
|
916
|
+
dismissAll(): void;
|
|
917
|
+
private startTimer;
|
|
918
|
+
private createRef;
|
|
919
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxToaster, never>;
|
|
920
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxToaster>;
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Standalone provider for the toast system — use when not using `provideFeedback()`.
|
|
924
|
+
*
|
|
925
|
+
* ```ts
|
|
926
|
+
* bootstrapApplication(AppComponent, {
|
|
927
|
+
* providers: [provideToasts()],
|
|
928
|
+
* });
|
|
929
|
+
* ```
|
|
930
|
+
*/
|
|
931
|
+
declare function provideToasts(): EnvironmentProviders;
|
|
932
|
+
|
|
933
|
+
/** Position for the toast stack. */
|
|
934
|
+
type ToastPosition = 'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' | 'bottom-end';
|
|
935
|
+
/**
|
|
936
|
+
* Toast outlet — renders the toast stack at a fixed viewport position.
|
|
937
|
+
*
|
|
938
|
+
* Place once in the app shell. Reads from `CngxToaster` reactively.
|
|
939
|
+
* Requires `provideToasts()` or `provideFeedback(withToasts())`.
|
|
940
|
+
*
|
|
941
|
+
* ```html
|
|
942
|
+
* <cngx-toast-outlet position="bottom-end" [maxVisible]="5" />
|
|
943
|
+
* ```
|
|
944
|
+
*/
|
|
945
|
+
declare class CngxToastOutlet {
|
|
946
|
+
protected readonly service: CngxToaster;
|
|
947
|
+
private readonly config;
|
|
948
|
+
/** Stack position. */
|
|
949
|
+
readonly position: _angular_core.InputSignal<ToastPosition>;
|
|
950
|
+
/** Maximum visible toasts — oldest are evicted. */
|
|
951
|
+
readonly maxVisible: _angular_core.InputSignal<number>;
|
|
952
|
+
/** Insert new toasts at start or end of the stack. */
|
|
953
|
+
readonly insertPosition: _angular_core.InputSignal<"start" | "end">;
|
|
954
|
+
/** @internal */
|
|
955
|
+
protected readonly positionClass: _angular_core.Signal<string>;
|
|
956
|
+
/** @internal — slice to maxVisible, respecting insert position. */
|
|
957
|
+
protected readonly visibleToasts: _angular_core.Signal<readonly ToastState[]>;
|
|
958
|
+
/** @internal — resolve icon component from global config or null. */
|
|
959
|
+
protected iconFor(toast: ToastState): _angular_core.Type<unknown> | null;
|
|
960
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxToastOutlet, never>;
|
|
961
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxToastOutlet, "cngx-toast-outlet", never, { "position": { "alias": "position"; "required": false; "isSignal": true; }; "maxVisible": { "alias": "maxVisible"; "required": false; "isSignal": true; }; "insertPosition": { "alias": "insertPosition"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Declarative state-to-toast bridge.
|
|
966
|
+
*
|
|
967
|
+
* Place on any element — fires a toast when the bound `CngxAsyncState`
|
|
968
|
+
* transitions to `success` or `error`. Only fires on actual transitions,
|
|
969
|
+
* not on initial `idle` state.
|
|
970
|
+
*
|
|
971
|
+
* ### On a button
|
|
972
|
+
* ```html
|
|
973
|
+
* <button [cngxAsyncClick]="save"
|
|
974
|
+
* [cngxToastOn]="saveState"
|
|
975
|
+
* toastSuccess="Saved"
|
|
976
|
+
* toastError="Save failed">
|
|
977
|
+
* Save
|
|
978
|
+
* </button>
|
|
979
|
+
* ```
|
|
980
|
+
*
|
|
981
|
+
* ### On a form
|
|
982
|
+
* ```html
|
|
983
|
+
* <form [cngxToastOn]="submitState"
|
|
984
|
+
* toastSuccess="Form submitted"
|
|
985
|
+
* toastError="Submission failed"
|
|
986
|
+
* [toastErrorDetail]="true">
|
|
987
|
+
* ...
|
|
988
|
+
* </form>
|
|
989
|
+
* ```
|
|
990
|
+
*/
|
|
991
|
+
declare class CngxToastOn {
|
|
992
|
+
private readonly toast;
|
|
993
|
+
private readonly statefulFallback;
|
|
994
|
+
private readonly toastService;
|
|
995
|
+
/**
|
|
996
|
+
* The async state to watch. Optional — when omitted, the bridge falls back
|
|
997
|
+
* to `CNGX_STATEFUL` injected from the host component (for example
|
|
998
|
+
* `CngxSelect.commitState`). A bare `cngxToastOn` attribute (empty string)
|
|
999
|
+
* is treated as "no input bound" so the fallback kicks in.
|
|
1000
|
+
*/
|
|
1001
|
+
readonly state: _angular_core.InputSignalWithTransform<CngxAsyncState<unknown> | undefined, "" | CngxAsyncState<unknown> | undefined>;
|
|
1002
|
+
/** Effective state — input wins over ancestor `CNGX_STATEFUL`. */
|
|
1003
|
+
private readonly effectiveState;
|
|
1004
|
+
/** Toast message on success. If not set, no success toast fires. */
|
|
1005
|
+
readonly toastSuccess: _angular_core.InputSignal<string | undefined>;
|
|
1006
|
+
/** Toast message on error. If not set, no error toast fires. */
|
|
1007
|
+
readonly toastError: _angular_core.InputSignal<string | undefined>;
|
|
1008
|
+
/** Include the error detail message in the toast body. */
|
|
1009
|
+
readonly toastErrorDetail: _angular_core.InputSignal<boolean>;
|
|
1010
|
+
/** Duration for success toasts in ms. */
|
|
1011
|
+
readonly toastSuccessDuration: _angular_core.InputSignal<number>;
|
|
1012
|
+
/** Duration for error toasts — `'persistent'` means manual dismiss only. */
|
|
1013
|
+
readonly toastErrorDuration: _angular_core.InputSignal<number | "persistent">;
|
|
1014
|
+
constructor();
|
|
1015
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxToastOn, never>;
|
|
1016
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxToastOn, "[cngxToastOn]", never, { "state": { "alias": "cngxToastOn"; "required": false; "isSignal": true; }; "toastSuccess": { "alias": "toastSuccess"; "required": false; "isSignal": true; }; "toastError": { "alias": "toastError"; "required": false; "isSignal": true; }; "toastErrorDetail": { "alias": "toastErrorDetail"; "required": false; "isSignal": true; }; "toastSuccessDuration": { "alias": "toastSuccessDuration"; "required": false; "isSignal": true; }; "toastErrorDuration": { "alias": "toastErrorDuration"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
/**
|
|
1020
|
+
* Declarative toast — renders nothing at its position, pushes into the global `CngxToastOutlet`.
|
|
1021
|
+
*
|
|
1022
|
+
* Shows a toast when `[when]` becomes `true`. Dismisses when `[when]` becomes `false`
|
|
1023
|
+
* (unless already auto-dismissed). Supports projected content for custom toast bodies.
|
|
1024
|
+
*
|
|
1025
|
+
* Requires `provideToasts()` or `provideFeedback(withToasts())`.
|
|
1026
|
+
*
|
|
1027
|
+
* ### Simple message
|
|
1028
|
+
* ```html
|
|
1029
|
+
* <cngx-toast severity="success" message="Saved" [when]="saved()" />
|
|
1030
|
+
* ```
|
|
1031
|
+
*
|
|
1032
|
+
* ### With custom content
|
|
1033
|
+
* ```html
|
|
1034
|
+
* <cngx-toast severity="error" [when]="hasError()">
|
|
1035
|
+
* Something went wrong. <button (click)="retry()">Retry</button>
|
|
1036
|
+
* </cngx-toast>
|
|
1037
|
+
* ```
|
|
1038
|
+
*
|
|
1039
|
+
* ### With async state
|
|
1040
|
+
* ```html
|
|
1041
|
+
* <cngx-toast severity="success" message="Item saved" [when]="saveState.status() === 'success'" />
|
|
1042
|
+
* <cngx-toast severity="error" message="Save failed" [when]="saveState.status() === 'error'" />
|
|
1043
|
+
* ```
|
|
1044
|
+
*/
|
|
1045
|
+
declare class CngxToast {
|
|
1046
|
+
private readonly toaster;
|
|
1047
|
+
private readonly destroyRef;
|
|
1048
|
+
/** When `true`, the toast is shown. When `false`, it is dismissed. */
|
|
1049
|
+
readonly when: _angular_core.InputSignal<boolean>;
|
|
1050
|
+
/** Toast message text. Ignored when content is projected. */
|
|
1051
|
+
readonly message: _angular_core.InputSignal<string>;
|
|
1052
|
+
/** Visual severity. */
|
|
1053
|
+
readonly severity: _angular_core.InputSignal<AlertSeverity>;
|
|
1054
|
+
/** Auto-dismiss duration in ms, or `'persistent'`. */
|
|
1055
|
+
readonly duration: _angular_core.InputSignal<number | "persistent" | undefined>;
|
|
1056
|
+
/** Show dismiss button. */
|
|
1057
|
+
readonly dismissible: _angular_core.InputSignal<boolean>;
|
|
1058
|
+
/** Action button config. */
|
|
1059
|
+
readonly actionLabel: _angular_core.InputSignal<string | undefined>;
|
|
1060
|
+
readonly actionHandler: _angular_core.InputSignal<(() => void) | undefined>;
|
|
1061
|
+
/** @internal */
|
|
1062
|
+
private readonly action;
|
|
1063
|
+
private activeRef;
|
|
1064
|
+
constructor();
|
|
1065
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxToast, never>;
|
|
1066
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxToast, "cngx-toast", never, { "when": { "alias": "when"; "required": true; "isSignal": true; }; "message": { "alias": "message"; "required": false; "isSignal": true; }; "severity": { "alias": "severity"; "required": false; "isSignal": true; }; "duration": { "alias": "duration"; "required": false; "isSignal": true; }; "dismissible": { "alias": "dismissible"; "required": false; "isSignal": true; }; "actionLabel": { "alias": "actionLabel"; "required": false; "isSignal": true; }; "actionHandler": { "alias": "actionHandler"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
/** Marks the skeleton template inside `cngx-async-container`. */
|
|
1070
|
+
declare class CngxAsyncSkeletonTpl {
|
|
1071
|
+
readonly templateRef: TemplateRef<any>;
|
|
1072
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsyncSkeletonTpl, never>;
|
|
1073
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAsyncSkeletonTpl, "ng-template[cngxAsyncSkeleton]", never, {}, {}, never, never, true, never>;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Marks the content template inside `cngx-async-container`.
|
|
1077
|
+
* Context: `{ $implicit: T }` — use `let-data` to access.
|
|
1078
|
+
*/
|
|
1079
|
+
declare class CngxAsyncContentTpl<T> {
|
|
1080
|
+
readonly templateRef: TemplateRef<{
|
|
1081
|
+
$implicit: T;
|
|
1082
|
+
}>;
|
|
1083
|
+
static ngTemplateContextGuard<T>(_dir: CngxAsyncContentTpl<T>, _ctx: unknown): _ctx is {
|
|
1084
|
+
$implicit: T;
|
|
1085
|
+
};
|
|
1086
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsyncContentTpl<any>, never>;
|
|
1087
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAsyncContentTpl<any>, "ng-template[cngxAsyncContent]", never, {}, {}, never, never, true, never>;
|
|
1088
|
+
}
|
|
1089
|
+
/** Marks the empty-state template inside `cngx-async-container`. */
|
|
1090
|
+
declare class CngxAsyncEmptyTpl {
|
|
1091
|
+
readonly templateRef: TemplateRef<any>;
|
|
1092
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsyncEmptyTpl, never>;
|
|
1093
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAsyncEmptyTpl, "ng-template[cngxAsyncEmpty]", never, {}, {}, never, never, true, never>;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Marks the error template inside `cngx-async-container`.
|
|
1097
|
+
* Context: `{ $implicit: unknown }` — use `let-err` to access.
|
|
1098
|
+
*/
|
|
1099
|
+
declare class CngxAsyncErrorTpl {
|
|
1100
|
+
readonly templateRef: TemplateRef<{
|
|
1101
|
+
$implicit: unknown;
|
|
1102
|
+
}>;
|
|
1103
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsyncErrorTpl, never>;
|
|
1104
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxAsyncErrorTpl, "ng-template[cngxAsyncError]", never, {}, {}, never, never, true, never>;
|
|
1105
|
+
}
|
|
1106
|
+
/**
|
|
1107
|
+
* Async container molecule — coordinates all feedback states for data loading.
|
|
1108
|
+
*
|
|
1109
|
+
* Projects four named templates and switches between them based on the
|
|
1110
|
+
* `CngxAsyncState` lifecycle. Includes a built-in refresh indicator (bar)
|
|
1111
|
+
* and ARIA state announcements.
|
|
1112
|
+
*
|
|
1113
|
+
* ```html
|
|
1114
|
+
* <cngx-async-container [state]="residents">
|
|
1115
|
+
* <ng-template cngxAsyncSkeleton>
|
|
1116
|
+
* @for (i of [1,2,3]; track i) { <div class="skeleton-card"></div> }
|
|
1117
|
+
* </ng-template>
|
|
1118
|
+
*
|
|
1119
|
+
* <ng-template cngxAsyncContent let-data>
|
|
1120
|
+
* @for (r of data; track r.id) { <app-card [resident]="r" /> }
|
|
1121
|
+
* </ng-template>
|
|
1122
|
+
*
|
|
1123
|
+
* <ng-template cngxAsyncEmpty>
|
|
1124
|
+
* <cngx-empty-state title="No residents" />
|
|
1125
|
+
* </ng-template>
|
|
1126
|
+
*
|
|
1127
|
+
* <ng-template cngxAsyncError let-err>
|
|
1128
|
+
* <cngx-alert severity="error">{{ err }}</cngx-alert>
|
|
1129
|
+
* </ng-template>
|
|
1130
|
+
* </cngx-async-container>
|
|
1131
|
+
* ```
|
|
1132
|
+
*/
|
|
1133
|
+
declare class CngxAsyncContainer<T> {
|
|
1134
|
+
private readonly toaster;
|
|
1135
|
+
/** The async state to render. */
|
|
1136
|
+
readonly state: _angular_core.InputSignal<CngxAsyncState<T>>;
|
|
1137
|
+
/** Show refresh indicator bar during refresh/re-query. */
|
|
1138
|
+
readonly refreshIndicator: _angular_core.InputSignal<boolean>;
|
|
1139
|
+
/** ARIA label for the region. */
|
|
1140
|
+
readonly ariaLabel: _angular_core.InputSignal<string | undefined>;
|
|
1141
|
+
/** Toast message on success. If set, fires a toast via CngxToaster. */
|
|
1142
|
+
readonly toastSuccess: _angular_core.InputSignal<string | undefined>;
|
|
1143
|
+
/** Toast message on error. If set, fires a toast via CngxToaster. */
|
|
1144
|
+
readonly toastError: _angular_core.InputSignal<string | undefined>;
|
|
1145
|
+
/** @internal */
|
|
1146
|
+
protected readonly skeletonTpl: _angular_core.Signal<CngxAsyncSkeletonTpl | undefined>;
|
|
1147
|
+
/** @internal */
|
|
1148
|
+
protected readonly contentTpl: _angular_core.Signal<CngxAsyncContentTpl<any> | undefined>;
|
|
1149
|
+
/** @internal */
|
|
1150
|
+
protected readonly emptyTpl: _angular_core.Signal<CngxAsyncEmptyTpl | undefined>;
|
|
1151
|
+
/** @internal */
|
|
1152
|
+
protected readonly errorTpl: _angular_core.Signal<CngxAsyncErrorTpl | undefined>;
|
|
1153
|
+
/** @internal */
|
|
1154
|
+
protected readonly activeView: _angular_core.Signal<AsyncView>;
|
|
1155
|
+
/** @internal */
|
|
1156
|
+
protected readonly showRefreshIndicator: _angular_core.Signal<boolean>;
|
|
1157
|
+
/** @internal */
|
|
1158
|
+
protected readonly contentContext: _angular_core.Signal<{
|
|
1159
|
+
$implicit: T;
|
|
1160
|
+
}>;
|
|
1161
|
+
/** @internal */
|
|
1162
|
+
protected readonly errorContext: _angular_core.Signal<{
|
|
1163
|
+
$implicit: unknown;
|
|
1164
|
+
}>;
|
|
1165
|
+
/** @internal */
|
|
1166
|
+
protected readonly announcement: _angular_core.WritableSignal<string>;
|
|
1167
|
+
constructor();
|
|
1168
|
+
private fireToast;
|
|
1169
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxAsyncContainer<any>, never>;
|
|
1170
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxAsyncContainer<any>, "cngx-async-container", never, { "state": { "alias": "state"; "required": true; "isSignal": true; }; "refreshIndicator": { "alias": "refreshIndicator"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "toastSuccess": { "alias": "toastSuccess"; "required": false; "isSignal": true; }; "toastError": { "alias": "toastError"; "required": false; "isSignal": true; }; }, {}, ["skeletonTpl", "contentTpl", "emptyTpl", "errorTpl"], never, true, never>;
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
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 };
|
|
1174
|
+
export type { AlertConfig, AlertRef, AlertSeverity, AlertState, AlertVisibilityPhase, BannerConfig, BannerRef, BannerState, FeedbackConfig, FeedbackFeature, LoadingIndicatorVariant, ProgressVariant, ToastConfig, ToastPosition, ToastRef };
|