@cngx/common 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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/a11y/README.md +77 -0
  4. package/card/README.md +79 -0
  5. package/chart/README.md +31 -0
  6. package/data/README.md +883 -0
  7. package/dialog/README.md +84 -0
  8. package/display/README.md +30 -0
  9. package/fesm2022/cngx-common-a11y.mjs +1260 -0
  10. package/fesm2022/cngx-common-a11y.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +765 -0
  12. package/fesm2022/cngx-common-card.mjs.map +1 -0
  13. package/fesm2022/cngx-common-chart.mjs +2943 -0
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -0
  15. package/fesm2022/cngx-common-data.mjs +2886 -0
  16. package/fesm2022/cngx-common-data.mjs.map +1 -0
  17. package/fesm2022/cngx-common-dialog.mjs +1366 -0
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -0
  19. package/fesm2022/cngx-common-display.mjs +1603 -0
  20. package/fesm2022/cngx-common-display.mjs.map +1 -0
  21. package/fesm2022/cngx-common-interactive.mjs +8185 -0
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -0
  23. package/fesm2022/cngx-common-layout.mjs +1335 -0
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -0
  25. package/fesm2022/cngx-common-popover.mjs +1200 -0
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -0
  27. package/fesm2022/cngx-common-stepper.mjs +1350 -0
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -0
  29. package/fesm2022/cngx-common-tabs.mjs +1551 -0
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -0
  31. package/fesm2022/cngx-common.mjs +34 -0
  32. package/fesm2022/cngx-common.mjs.map +1 -0
  33. package/interactive/README.md +211 -0
  34. package/layout/README.md +117 -0
  35. package/package.json +100 -0
  36. package/popover/README.md +218 -0
  37. package/stepper/README.md +102 -0
  38. package/tabs/README.md +32 -0
  39. package/types/cngx-common-a11y.d.ts +616 -0
  40. package/types/cngx-common-card.d.ts +413 -0
  41. package/types/cngx-common-chart.d.ts +1081 -0
  42. package/types/cngx-common-data.d.ts +1460 -0
  43. package/types/cngx-common-dialog.d.ts +772 -0
  44. package/types/cngx-common-display.d.ts +1136 -0
  45. package/types/cngx-common-interactive.d.ts +5013 -0
  46. package/types/cngx-common-layout.d.ts +737 -0
  47. package/types/cngx-common-popover.d.ts +520 -0
  48. package/types/cngx-common-stepper.d.ts +982 -0
  49. package/types/cngx-common-tabs.d.ts +1237 -0
  50. package/types/cngx-common.d.ts +13 -0
@@ -0,0 +1,772 @@
1
+ import * as _angular_core from '@angular/core';
2
+ import { Signal, InjectionToken, Provider, ViewContainerRef, Type, ComponentRef, Injector, TemplateRef } from '@angular/core';
3
+ import { CngxAsyncState } from '@cngx/core/utils';
4
+ import { Observable } from 'rxjs';
5
+ import * as _cngx_common_dialog from '@cngx/common/dialog';
6
+
7
+ /**
8
+ * Lifecycle states of a `CngxDialog`.
9
+ */
10
+ type DialogState = 'closed' | 'opening' | 'open' | 'closing';
11
+ /**
12
+ * Signal-based dialog reference.
13
+ *
14
+ * - **Outside** (parent template): access via `exportAs` — `#dlg="cngxDialog"`
15
+ * - **Inside** (dialog content): access via DI — `inject(DIALOG_REF)`
16
+ */
17
+ interface DialogRef<T = unknown> {
18
+ /** Current lifecycle state of the dialog. */
19
+ readonly lifecycle: Signal<DialogState>;
20
+ /**
21
+ * The typed result of the dialog.
22
+ *
23
+ * - `undefined` before the dialog closes (reset on each `open()`)
24
+ * - `'dismissed'` when dismissed via Escape or backdrop click
25
+ * - `T` when closed with an explicit value
26
+ */
27
+ readonly result: Signal<T | 'dismissed' | undefined>;
28
+ /** Unique ID of this dialog instance. */
29
+ readonly id: Signal<string>;
30
+ /**
31
+ * Async state of the submit channel.
32
+ *
33
+ * Populated when `[submitAction]` is set — tracks the submit lifecycle
34
+ * (`idle` -> `pending` -> `success`/`error`). When `submitAction` is not set,
35
+ * this is a static idle state.
36
+ *
37
+ * Bind to any state consumer: `<cngx-alert [state]="dlg.submitState" />`.
38
+ */
39
+ readonly submitState: CngxAsyncState<unknown>;
40
+ /** Close the dialog with a typed result value. */
41
+ close(value: T): void;
42
+ /** Dismiss the dialog without a result (Escape / backdrop). */
43
+ dismiss(): void;
44
+ }
45
+ /** Injection token to access the nearest `DialogRef` from inside a dialog. */
46
+ declare const DIALOG_REF: InjectionToken<DialogRef<unknown>>;
47
+
48
+ /**
49
+ * Signal-driven state machine for native `<dialog>`.
50
+ *
51
+ * Wraps the browser's `<dialog>` element with reactive state, typed results,
52
+ * deterministic focus management, and full ARIA communication. Supports both
53
+ * modal and non-modal modes, CSS transition-aware open/close lifecycle, and
54
+ * ref-counted scroll locking for stacked modals.
55
+ *
56
+ * The directive implements `DialogRef<T>` and provides itself via `DIALOG_REF`,
57
+ * so child directives (`CngxDialogTitle`, `CngxDialogClose`, etc.) can inject
58
+ * the reference without explicit wiring.
59
+ *
60
+ * State lifecycle: `closed` -> `opening` -> `open` -> `closing` -> `closed`.
61
+ * CSS classes `cngx-dialog--opening`, `cngx-dialog--open`, and
62
+ * `cngx-dialog--closing` are applied to the host for transition hooks.
63
+ *
64
+ * ### Declarative (template-driven)
65
+ * ```html
66
+ * <dialog cngxDialog #dlg="cngxDialog">
67
+ * <h2 cngxDialogTitle>Delete item?</h2>
68
+ * <p cngxDialogDescription>This cannot be undone.</p>
69
+ * <button [cngxDialogClose]="false">Cancel</button>
70
+ * <button [cngxDialogClose]="true">Delete</button>
71
+ * </dialog>
72
+ * <button (click)="dlg.open()">Delete</button>
73
+ *
74
+ * @if (dlg.lifecycle() === 'closed' && dlg.result() === true) {
75
+ * <p>Item deleted.</p>
76
+ * }
77
+ * ```
78
+ *
79
+ * ### Programmatic (via CngxDialogOpener)
80
+ * ```typescript
81
+ * const ref = this.dialogService.open<boolean>(ConfirmDialog, {
82
+ * data: { message: 'Delete item?' },
83
+ * });
84
+ *
85
+ * ref.afterClosed().subscribe(result => {
86
+ * if (result === true) this.delete();
87
+ * });
88
+ * ```
89
+ *
90
+ * ### Non-modal dialog
91
+ * ```html
92
+ * <dialog cngxDialog [modal]="false" #tooltip="cngxDialog">
93
+ * <p>Inline tooltip content</p>
94
+ * </dialog>
95
+ * ```
96
+ *
97
+ * ### Custom focus target
98
+ * ```html
99
+ * <dialog cngxDialog [autoFocus]="'#name-input'">
100
+ * <input id="name-input" />
101
+ * </dialog>
102
+ * ```
103
+ */
104
+ declare class CngxDialog<T = unknown> implements DialogRef<T> {
105
+ private readonly elRef;
106
+ private readonly doc;
107
+ private readonly renderer;
108
+ private readonly destroyRef;
109
+ private readonly dialogStack;
110
+ private readonly titleDirective;
111
+ private readonly descriptionDirective;
112
+ /**
113
+ * Whether the dialog opens as modal (`showModal()`) or non-modal (`show()`).
114
+ *
115
+ * Modal dialogs block interaction with the rest of the page, acquire a
116
+ * scroll lock, and participate in the `CngxDialogStack` for backdrop
117
+ * management. Non-modal dialogs do not.
118
+ *
119
+ * @defaultValue `true`
120
+ */
121
+ readonly modal: _angular_core.InputSignal<boolean>;
122
+ /**
123
+ * Whether clicking the backdrop dismisses the dialog.
124
+ *
125
+ * Only applies to modal dialogs. When `true`, a click on the
126
+ * `::backdrop` pseudo-element calls `dismiss()`.
127
+ *
128
+ * @defaultValue `true`
129
+ */
130
+ readonly closeOnBackdropClick: _angular_core.InputSignal<boolean>;
131
+ /**
132
+ * Whether pressing Escape dismisses the dialog.
133
+ *
134
+ * Only applies to modal dialogs. The native `cancel` event is always
135
+ * prevented; this input controls whether `dismiss()` is called in response.
136
+ *
137
+ * @defaultValue `true`
138
+ */
139
+ readonly closeOnEscape: _angular_core.InputSignal<boolean>;
140
+ /**
141
+ * Focus strategy applied after the dialog transitions to `'open'`.
142
+ *
143
+ * Only applies to modal dialogs.
144
+ *
145
+ * - `'first-focusable'` -- focus the first `[autofocus]` element, or the
146
+ * first focusable element in DOM order (default)
147
+ * - `'none'` -- do not move focus
148
+ * - Any CSS selector string -- focus the first element matching the selector
149
+ *
150
+ * @defaultValue `'first-focusable'`
151
+ */
152
+ readonly autoFocus: _angular_core.InputSignal<(string & {}) | "first-focusable" | "none">;
153
+ /**
154
+ * Fallback element to focus when the original trigger element has been
155
+ * removed from the DOM by the time the dialog closes.
156
+ *
157
+ * When not set and the trigger is gone, no focus return occurs.
158
+ */
159
+ readonly focusFallback: _angular_core.InputSignal<HTMLElement | undefined>;
160
+ /**
161
+ * Bind an async state — drives pending (aria-busy, prevents close) and
162
+ * error from a single source. When set, takes precedence over the
163
+ * `[error]` boolean input and `[submitAction]`.
164
+ *
165
+ * When `state.status()` is `'pending'`, the dialog prevents close/dismiss
166
+ * and applies `aria-busy`. When `state.status()` is `'error'`, the dialog
167
+ * applies `cngx-dialog--error` and announces the error via the SR live region.
168
+ */
169
+ readonly state: _angular_core.InputSignal<CngxAsyncState<unknown> | undefined>;
170
+ /**
171
+ * Async action to execute when `close(value)` is called.
172
+ *
173
+ * Receives the close value as parameter. On success, the dialog auto-closes.
174
+ * On error, the dialog stays open with `cngx-dialog--error` and the error
175
+ * is announced to screen readers.
176
+ *
177
+ * When set, `close(value)` no longer closes immediately — it enters a
178
+ * `submitting` phase (`isPending() = true`, `aria-busy`, close blocked).
179
+ *
180
+ * The submit lifecycle is exposed via `submitState: CngxAsyncState<unknown>`.
181
+ * Ignored when `[state]` input is also set (external state takes precedence).
182
+ */
183
+ readonly submitAction: _angular_core.InputSignal<((value: T) => Promise<unknown> | Observable<unknown>) | undefined>;
184
+ /**
185
+ * Whether the dialog is in an error state. Fallback when neither `[state]`
186
+ * nor `[submitAction]` is set.
187
+ *
188
+ * When `true`, applies the `cngx-dialog--error` CSS class on the host.
189
+ * Use this to communicate form submission failures or other error
190
+ * conditions visually.
191
+ *
192
+ * Pair with `cngx-form-errors` (`role="alert"`) inside the dialog for
193
+ * WCAG-compliant error announcements.
194
+ *
195
+ * @defaultValue `false`
196
+ */
197
+ readonly error: _angular_core.InputSignal<boolean>;
198
+ private readonly lifecycleSignal;
199
+ private readonly resultSignal;
200
+ private readonly idSignal;
201
+ private readonly triggerElement;
202
+ /**
203
+ * Current lifecycle state of the dialog.
204
+ *
205
+ * Possible values: `'closed'`, `'opening'`, `'open'`, `'closing'`.
206
+ */
207
+ readonly lifecycle: _angular_core.Signal<DialogState>;
208
+ /**
209
+ * The typed result of the dialog.
210
+ *
211
+ * - `undefined` before close (reset on each `open()` call)
212
+ * - `'dismissed'` when dismissed via Escape or backdrop click
213
+ * - `T` when closed with an explicit value via `close(value)`
214
+ */
215
+ readonly result: _angular_core.Signal<"dismissed" | T | undefined>;
216
+ /** Unique auto-generated ID for this dialog instance. Used for ARIA and stack tracking. */
217
+ readonly id: _angular_core.Signal<string>;
218
+ private readonly submitStatusState;
219
+ private readonly submitErrorState;
220
+ /**
221
+ * Async state of the submit channel.
222
+ *
223
+ * Populated when `[submitAction]` is set. Tracks `idle` -> `pending` ->
224
+ * `success`/`error`. When `submitAction` is not set, remains at `'idle'`.
225
+ *
226
+ * Bind to any state consumer: `<cngx-alert [state]="dlg.submitState" />`.
227
+ */
228
+ readonly submitState: CngxAsyncState<unknown>;
229
+ /**
230
+ * `true` when any async operation is pending. Blocks close/dismiss and sets `aria-busy`.
231
+ *
232
+ * External `[state]` short-circuits — when set, `submitAction` is ignored by the
233
+ * `close()` guard (`action && !this.state()`), so `submitStatusState` stays `'idle'`.
234
+ */
235
+ readonly isPending: _angular_core.Signal<boolean>;
236
+ /**
237
+ * Resolved error — external `[state]` takes precedence over submit state,
238
+ * which takes precedence over the boolean `[error]` input.
239
+ */
240
+ protected readonly effectiveError: _angular_core.Signal<boolean>;
241
+ protected readonly isOpening: _angular_core.Signal<boolean>;
242
+ protected readonly isOpen: _angular_core.Signal<boolean>;
243
+ protected readonly isClosing: _angular_core.Signal<boolean>;
244
+ protected readonly ariaModal: _angular_core.Signal<"true" | null>;
245
+ protected readonly ariaLabelledBy: _angular_core.Signal<string | null>;
246
+ protected readonly ariaDescribedBy: _angular_core.Signal<string | null>;
247
+ protected readonly backdropOpacity: _angular_core.Signal<"0" | null>;
248
+ private liveRegion;
249
+ constructor();
250
+ /**
251
+ * Open the dialog.
252
+ *
253
+ * Resets the result from any previous open/close cycle, stores the
254
+ * currently focused element for focus return, and calls the native
255
+ * `showModal()` or `show()` depending on the `modal` input.
256
+ *
257
+ * No-op if the dialog is already open or in a transition state.
258
+ */
259
+ open(): void;
260
+ /**
261
+ * Close the dialog with a typed result.
262
+ *
263
+ * When `[submitAction]` is set and `[state]` is not set, executes the action
264
+ * with `value` before closing. The dialog enters a submitting phase
265
+ * (`isPending() = true`) — on success it auto-closes, on error it stays open.
266
+ *
267
+ * When `[submitAction]` is not set (or `[state]` overrides), closes immediately.
268
+ *
269
+ * No-op if the dialog is not in the `'open'` or `'opening'` state, or if
270
+ * already pending.
271
+ *
272
+ * @param value - The typed result to deliver to consumers.
273
+ */
274
+ close(value: T): void;
275
+ /**
276
+ * Dismiss the dialog without a typed result.
277
+ *
278
+ * Sets `result` to `'dismissed'`, then initiates the closing transition.
279
+ * Typically triggered by Escape key or backdrop click, but can be called
280
+ * directly. No-op if the dialog is not in the `'open'` or `'opening'` state.
281
+ */
282
+ dismiss(): void;
283
+ private executeSubmit;
284
+ protected handleCancel(event: Event): void;
285
+ protected handleClick(event: MouseEvent): void;
286
+ private get dialogElement();
287
+ private startClosing;
288
+ private finalize;
289
+ private moveFocus;
290
+ private returnFocus;
291
+ private createLiveRegion;
292
+ private acquireScrollLock;
293
+ private releaseScrollLock;
294
+ private warnNonModalA11y;
295
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialog<any>, never>;
296
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxDialog<any>, "dialog[cngxDialog]", ["cngxDialog"], { "modal": { "alias": "modal"; "required": false; "isSignal": true; }; "closeOnBackdropClick": { "alias": "closeOnBackdropClick"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; "autoFocus": { "alias": "autoFocus"; "required": false; "isSignal": true; }; "focusFallback": { "alias": "focusFallback"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "submitAction": { "alias": "submitAction"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; }, {}, ["titleDirective", "descriptionDirective"], never, true, never>;
297
+ }
298
+
299
+ /**
300
+ * Marks an element as the dialog's title for ARIA labelling.
301
+ *
302
+ * Automatically generates a deterministic ID and registers with the
303
+ * parent `CngxDialog` for `aria-labelledby`. The title text is also
304
+ * announced via `aria-live` when the dialog transitions to `'open'`.
305
+ *
306
+ * ```html
307
+ * <dialog cngxDialog>
308
+ * <h2 cngxDialogTitle>Confirm Delete</h2>
309
+ * …
310
+ * </dialog>
311
+ * ```
312
+ */
313
+ declare class CngxDialogTitle {
314
+ private readonly elRef;
315
+ private readonly dialogRef;
316
+ /**
317
+ * Auto-generated unique ID bound to the host `[id]` attribute.
318
+ *
319
+ * Used by `CngxDialog` for `aria-labelledby`. When a parent `CngxDialog`
320
+ * is present, the ID is derived from the dialog's ID (e.g. `cngx-dialog-0-title`).
321
+ */
322
+ readonly id: _angular_core.WritableSignal<string>;
323
+ /**
324
+ * Text content of the title element.
325
+ *
326
+ * Read by `CngxDialog` on open to announce the dialog title via
327
+ * an `aria-live` region for screen readers.
328
+ */
329
+ readonly textContent: _angular_core.Signal<string>;
330
+ constructor();
331
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogTitle, never>;
332
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxDialogTitle, "[cngxDialogTitle]", ["cngxDialogTitle"], {}, {}, never, never, true, never>;
333
+ }
334
+
335
+ /**
336
+ * Marks an element as the dialog's description for ARIA.
337
+ *
338
+ * Automatically generates a deterministic ID and registers with the
339
+ * parent `CngxDialog` for `aria-describedby`.
340
+ *
341
+ * ```html
342
+ * <dialog cngxDialog>
343
+ * <h2 cngxDialogTitle>Delete item?</h2>
344
+ * <p cngxDialogDescription>This action cannot be undone.</p>
345
+ * …
346
+ * </dialog>
347
+ * ```
348
+ */
349
+ declare class CngxDialogDescription {
350
+ private readonly dialogRef;
351
+ /**
352
+ * Auto-generated unique ID bound to the host `[id]` attribute.
353
+ *
354
+ * Used by `CngxDialog` for `aria-describedby`. When a parent `CngxDialog`
355
+ * is present, the ID is derived from the dialog's ID (e.g. `cngx-dialog-0-desc`).
356
+ */
357
+ readonly id: _angular_core.WritableSignal<string>;
358
+ constructor();
359
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogDescription, never>;
360
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxDialogDescription, "[cngxDialogDescription]", ["cngxDialogDescription"], {}, {}, never, never, true, never>;
361
+ }
362
+
363
+ /**
364
+ * Close trigger for a dialog. Place on any clickable element inside a dialog.
365
+ *
366
+ * - With a value: `[cngxDialogClose]="'confirm'"` calls `dialogRef.close(value)`
367
+ * - Without a value: `cngxDialogClose` calls `dialogRef.dismiss()`
368
+ *
369
+ * Automatically sets `type="button"` on `<button>` hosts to prevent
370
+ * accidental form submission. Sets a default `aria-label="Close dialog"`
371
+ * when the host has no descriptive text content (icon-only buttons).
372
+ *
373
+ * ```html
374
+ * <dialog cngxDialog>
375
+ * <button [cngxDialogClose]="false">Cancel</button>
376
+ * <button [cngxDialogClose]="true">Confirm</button>
377
+ * </dialog>
378
+ * ```
379
+ */
380
+ declare class CngxDialogClose {
381
+ private readonly dialogRef;
382
+ private readonly elRef;
383
+ /** Value to pass to `close()`. When `undefined`, calls `dismiss()` instead. */
384
+ readonly value: _angular_core.InputSignal<unknown>;
385
+ /**
386
+ * Explicit `aria-label` override.
387
+ *
388
+ * When not set, the directive auto-detects whether the host element
389
+ * has descriptive text content. If it does (e.g. "Cancel", "Confirm"),
390
+ * no `aria-label` is added. If the content is a single character,
391
+ * empty, or visually an icon, `aria-label` defaults to `"Close dialog"`.
392
+ */
393
+ readonly label: _angular_core.InputSignal<string | undefined>;
394
+ /** Set type="button" on <button> hosts to prevent form submit. */
395
+ protected readonly hostType: string | null;
396
+ /**
397
+ * Computed `aria-label`. Returns:
398
+ * - explicit `label()` input if set
399
+ * - `null` if host text is descriptive (> 1 char, not whitespace-only)
400
+ * - `'Close dialog'` for icon-only / single-char content
401
+ */
402
+ protected readonly ariaLabel: _angular_core.Signal<string | null>;
403
+ protected handleClick(): void;
404
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogClose, never>;
405
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxDialogClose, "[cngxDialogClose]", ["cngxDialogClose"], { "value": { "alias": "cngxDialogClose"; "required": false; "isSignal": true; }; "label": { "alias": "cngxDialogCloseLabel"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
406
+ }
407
+
408
+ /**
409
+ * Tracks open dialog instances as a stack for backdrop management.
410
+ *
411
+ * Provided in root — always available, no manual provider setup needed.
412
+ * When multiple modal dialogs are stacked, only the topmost shows
413
+ * its `::backdrop`. Each `CngxDialog` reads `isTopmost` from this service
414
+ * to control `--cngx-dialog-backdrop-opacity`.
415
+ */
416
+ declare class CngxDialogStack {
417
+ private readonly stackState;
418
+ /** Readonly snapshot of the current stack (bottom → top). */
419
+ readonly stack: _angular_core.Signal<readonly string[]>;
420
+ /** ID of the topmost (most recently opened) dialog, or `null`. */
421
+ readonly topmost: _angular_core.Signal<string | null>;
422
+ /** Push a dialog ID onto the stack (called on open). */
423
+ push(id: string): void;
424
+ /** Remove a dialog ID from the stack (called on close). */
425
+ pop(id: string): void;
426
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogStack, never>;
427
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxDialogStack>;
428
+ }
429
+ /**
430
+ * Provide a scoped `CngxDialogStack` instance for nested dialog backdrop management.
431
+ *
432
+ * By default, `CngxDialogStack` is `providedIn: 'root'`, so all dialogs share
433
+ * one stack. Call `provideDialogStack()` in a component's `providers` array to
434
+ * create an isolated stack scope (e.g., for a sub-application or dialog group).
435
+ *
436
+ * ```typescript
437
+ * @Component({
438
+ * providers: [provideDialogStack()],
439
+ * })
440
+ * export class NestedDialogHost { }
441
+ * ```
442
+ */
443
+ declare function provideDialogStack(): Provider;
444
+
445
+ /** Injection token for data passed to a programmatically opened dialog via `CngxDialogOpener.open()`. */
446
+ declare const CNGX_DIALOG_DATA: InjectionToken<unknown>;
447
+ /**
448
+ * Configuration for programmatically opened dialogs.
449
+ */
450
+ interface CngxDialogConfig<D = unknown> {
451
+ /** Data to inject via `CNGX_DIALOG_DATA` inside the dialog component. */
452
+ data?: D;
453
+ /** Whether the dialog opens as modal (`showModal()`) or non-modal (`show()`). Default: `true`. */
454
+ modal?: boolean;
455
+ /** Whether clicking the backdrop dismisses the dialog. Default: `true`. */
456
+ closeOnBackdropClick?: boolean;
457
+ /** Whether pressing Escape dismisses the dialog. Default: `true`. */
458
+ closeOnEscape?: boolean;
459
+ /** Focus strategy on open. Default: `'first-focusable'`. */
460
+ autoFocus?: 'first-focusable' | 'none' | (string & {});
461
+ }
462
+
463
+ /**
464
+ * Internal container component for programmatically opened dialogs.
465
+ *
466
+ * Not part of the public API — instantiated exclusively by `CngxDialogOpener`.
467
+ * Renders the native `<dialog>` shell and exposes a `<ng-container>` outlet
468
+ * where the content component or template is inserted.
469
+ *
470
+ * @internal
471
+ */
472
+ declare class CngxDialogOutlet {
473
+ readonly modal: _angular_core.InputSignal<boolean>;
474
+ readonly closeOnBackdropClick: _angular_core.InputSignal<boolean>;
475
+ readonly closeOnEscape: _angular_core.InputSignal<boolean>;
476
+ readonly autoFocus: _angular_core.InputSignal<string>;
477
+ readonly dialog: _angular_core.Signal<CngxDialog<any>>;
478
+ readonly contentOutlet: _angular_core.Signal<ViewContainerRef | undefined>;
479
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogOutlet, never>;
480
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<CngxDialogOutlet, "cngx-dialog-outlet", never, { "modal": { "alias": "modal"; "required": false; "isSignal": true; }; "closeOnBackdropClick": { "alias": "closeOnBackdropClick"; "required": false; "isSignal": true; }; "closeOnEscape": { "alias": "closeOnEscape"; "required": false; "isSignal": true; }; "autoFocus": { "alias": "autoFocus"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
481
+ }
482
+
483
+ /**
484
+ * Reference to a programmatically opened dialog.
485
+ *
486
+ * Returned by `CngxDialogOpener.open()`. Provides both Signal-based access
487
+ * (`state`, `result`) and Observable convenience methods (`afterClosed()`,
488
+ * `afterOpened()`) for migration compatibility with `MatDialogRef`.
489
+ *
490
+ * ### Signal-based result reading
491
+ * ```typescript
492
+ * const ref = dialog.open<boolean>(ConfirmDialog);
493
+ *
494
+ * // In a computed or effect:
495
+ * const wasCancelled = ref.result() === 'dismissed';
496
+ * ```
497
+ *
498
+ * ### Observable-based result reading
499
+ * ```typescript
500
+ * ref.afterClosed().subscribe(result => {
501
+ * if (result !== 'dismissed') console.log('Confirmed:', result);
502
+ * });
503
+ * ```
504
+ */
505
+ declare class CngxDialogRef<T = unknown> {
506
+ private readonly inner;
507
+ private readonly contentRef;
508
+ private readonly injector;
509
+ /** @internal */
510
+ readonly _outletRef: ComponentRef<CngxDialogOutlet>;
511
+ /** @internal */
512
+ constructor(inner: DialogRef<T>, outletRef: ComponentRef<CngxDialogOutlet>, contentRef: ComponentRef<unknown> | null, injector: Injector);
513
+ /**
514
+ * Current lifecycle state of the dialog.
515
+ *
516
+ * Possible values: `'closed'`, `'opening'`, `'open'`, `'closing'`.
517
+ */
518
+ get lifecycle(): _angular_core.Signal<_cngx_common_dialog.DialogState>;
519
+ /**
520
+ * The typed result signal.
521
+ *
522
+ * - `undefined` before the dialog closes (reset on each open cycle)
523
+ * - `'dismissed'` when dismissed via Escape or backdrop click
524
+ * - `T` when closed with an explicit value
525
+ */
526
+ get result(): _angular_core.Signal<"dismissed" | T | undefined>;
527
+ /** Unique auto-generated ID for this dialog instance. */
528
+ get id(): _angular_core.Signal<string>;
529
+ /**
530
+ * Close the dialog with a typed result value.
531
+ *
532
+ * @param value - The result to deliver to consumers.
533
+ */
534
+ close(value: T): void;
535
+ /**
536
+ * Dismiss the dialog without a typed result.
537
+ *
538
+ * Sets the result to `'dismissed'`. Use for cancellation actions.
539
+ */
540
+ dismiss(): void;
541
+ /**
542
+ * Observable that emits the result when the dialog closes.
543
+ *
544
+ * Emits exactly once with `T | 'dismissed'`, then completes.
545
+ * Compatible with `MatDialogRef.afterClosed()` usage patterns.
546
+ */
547
+ afterClosed(): Observable<T | 'dismissed'>;
548
+ /**
549
+ * Observable that emits when the dialog finishes opening.
550
+ *
551
+ * Emits exactly once with `void` when the state transitions to `'open'`,
552
+ * then completes. Useful for post-open logic (e.g., focusing a specific
553
+ * element after animation completes).
554
+ */
555
+ afterOpened(): Observable<void>;
556
+ /**
557
+ * Reference to the content component instance.
558
+ *
559
+ * Returns `null` when the dialog was opened with a `TemplateRef` instead
560
+ * of a component type.
561
+ */
562
+ get componentRef(): ComponentRef<unknown> | null;
563
+ }
564
+ /**
565
+ * Service for opening dialogs programmatically.
566
+ *
567
+ * Works like `MatDialog.open()` — pass a component type and config,
568
+ * get back a typed `CngxDialogRef<T>`.
569
+ *
570
+ * Must be provided via `provideDialog()`.
571
+ *
572
+ * ### Open a component dialog
573
+ * ```typescript
574
+ * const ref = this.dialog.open<User>(EditUserDialog, {
575
+ * data: { userId: 123 },
576
+ * });
577
+ *
578
+ * ref.afterClosed().subscribe(result => {
579
+ * if (result !== 'dismissed') saveUser(result);
580
+ * });
581
+ * ```
582
+ *
583
+ * ### Inside the dialog component
584
+ * ```typescript
585
+ * class EditUserDialog {
586
+ * private readonly data = inject(CNGX_DIALOG_DATA) as { userId: number };
587
+ * private readonly dialogRef = inject(DIALOG_REF) as DialogRef<User>;
588
+ *
589
+ * save(user: User) { this.dialogRef.close(user); }
590
+ * }
591
+ * ```
592
+ */
593
+ declare class CngxDialogOpener {
594
+ private readonly appRef;
595
+ private readonly envInjector;
596
+ private readonly injector;
597
+ private readonly doc;
598
+ private readonly openDialogs;
599
+ /**
600
+ * Open a dialog with the given component.
601
+ *
602
+ * @param component — The component type to render inside the dialog.
603
+ * @param config — Optional dialog configuration.
604
+ * @returns A typed `CngxDialogRef<T>` for reading the result and controlling the dialog.
605
+ */
606
+ open<T = unknown, D = unknown>(component: Type<unknown>, config?: CngxDialogConfig<D>): CngxDialogRef<T>;
607
+ /**
608
+ * Open a dialog with the given template.
609
+ *
610
+ * @param templateRef — The template to render inside the dialog.
611
+ * @param config — Optional dialog configuration.
612
+ * @returns A typed `CngxDialogRef<T>`.
613
+ */
614
+ open<T = unknown, D = unknown>(templateRef: TemplateRef<unknown>, config?: CngxDialogConfig<D>): CngxDialogRef<T>;
615
+ /**
616
+ * Dismiss all programmatically opened dialogs.
617
+ *
618
+ * Calls `dismiss()` on each open dialog in reverse order (most recent first).
619
+ * Useful for route guards or global teardown.
620
+ */
621
+ closeAll(): void;
622
+ private cleanup;
623
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogOpener, never>;
624
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<CngxDialogOpener>;
625
+ }
626
+ /**
627
+ * Provide `CngxDialogOpener` for programmatic dialog opening.
628
+ *
629
+ * Must be called in the application's `providers` array or a route's
630
+ * `providers` for `CngxDialogOpener` to be injectable.
631
+ *
632
+ * ```typescript
633
+ * bootstrapApplication(AppComponent, {
634
+ * providers: [provideDialog()],
635
+ * });
636
+ * ```
637
+ */
638
+ declare function provideDialog(): Provider[];
639
+
640
+ /**
641
+ * Bottom sheet molecule — a `CngxDialog` positioned at the viewport bottom
642
+ * with swipe-to-dismiss support.
643
+ *
644
+ * Place on the same `<dialog>` element alongside `cngxDialog`. Adds the
645
+ * `cngx-bottom-sheet` CSS class (styled by `bottom-sheet-theme.scss`).
646
+ * When `CngxSwipeDismiss` is also present, auto-wires the swipe output
647
+ * to `dialogRef.dismiss()` — no manual `(swiped)` binding needed.
648
+ *
649
+ * ### Basic bottom sheet
650
+ * ```html
651
+ * <dialog cngxDialog cngxBottomSheet [cngxSwipeDismiss]="'down'"
652
+ * #sheet="cngxDialog">
653
+ * <h2 cngxDialogTitle>Share</h2>
654
+ * <button [cngxDialogClose]="'copy'">Copy Link</button>
655
+ * <button [cngxDialogClose]="'email'">Email</button>
656
+ * <button cngxDialogClose>Cancel</button>
657
+ * </dialog>
658
+ * <button (click)="sheet.open()">Share</button>
659
+ * ```
660
+ *
661
+ * ### Without swipe (static bottom sheet)
662
+ * ```html
663
+ * <dialog cngxDialog cngxBottomSheet #sheet="cngxDialog">
664
+ * <p>Content positioned at the bottom.</p>
665
+ * </dialog>
666
+ * ```
667
+ */
668
+ declare class CngxBottomSheet {
669
+ private readonly dialogRef;
670
+ private readonly swipe;
671
+ /**
672
+ * Whether the drag handle bar is visible.
673
+ *
674
+ * The handle itself is rendered via CSS (`::before` pseudo-element on the host).
675
+ * Set to `false` to hide it.
676
+ *
677
+ * @defaultValue `true`
678
+ */
679
+ readonly showHandle: _angular_core.InputSignal<boolean>;
680
+ constructor();
681
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxBottomSheet, never>;
682
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxBottomSheet, "dialog[cngxBottomSheet]", ["cngxBottomSheet"], { "showHandle": { "alias": "showHandle"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
683
+ }
684
+
685
+ /**
686
+ * Opt-in drag behavior for `CngxDialog`.
687
+ *
688
+ * Uses Pointer Events for unified mouse/touch handling. Position is exposed
689
+ * as CSS custom properties `--cngx-dialog-x` and `--cngx-dialog-y` — the
690
+ * consumer applies the transform via CSS.
691
+ *
692
+ * Keyboard-based moving is mandatory for accessibility:
693
+ * - Arrow keys move 10px
694
+ * - Shift + Arrow moves 50px
695
+ * - Home resets to origin
696
+ *
697
+ * ```html
698
+ * <dialog cngxDialog cngxDialogDraggable>
699
+ * <div class="dialog-header" #handle>Title</div>
700
+ * …
701
+ * </dialog>
702
+ * ```
703
+ *
704
+ * ```css
705
+ * dialog[cngxDialogDraggable] {
706
+ * transform: translate(var(--cngx-dialog-x, 0px), var(--cngx-dialog-y, 0px));
707
+ * }
708
+ * ```
709
+ */
710
+ declare class CngxDialogDraggable {
711
+ private readonly elRef;
712
+ private readonly doc;
713
+ private readonly destroyRef;
714
+ /** Handle element for initiating drag. If not set, entire dialog is the handle. */
715
+ readonly handle: _angular_core.InputSignal<HTMLElement | undefined>;
716
+ /** Clamp position to viewport bounds. */
717
+ readonly constrainToViewport: _angular_core.InputSignal<boolean>;
718
+ /**
719
+ * Snap position to a grid in pixels.
720
+ *
721
+ * When set to a positive number, the dialog position snaps to the nearest
722
+ * grid increment. When `snapMode` is `'live'`, snapping happens during drag.
723
+ * When `'release'`, position is free during drag and snaps on pointer up.
724
+ *
725
+ * @defaultValue `0` (no grid)
726
+ */
727
+ readonly gridSize: _angular_core.InputSignal<number>;
728
+ /**
729
+ * When to apply grid snapping.
730
+ *
731
+ * - `'live'` — position snaps continuously during drag (default)
732
+ * - `'release'` — position is free during drag, snaps on pointer up
733
+ *
734
+ * @defaultValue `'live'`
735
+ */
736
+ readonly snapMode: _angular_core.InputSignal<"live" | "release">;
737
+ private readonly positionState;
738
+ private readonly draggingState;
739
+ /** Current offset position. */
740
+ readonly position: _angular_core.Signal<{
741
+ x: number;
742
+ y: number;
743
+ }>;
744
+ /** Whether a drag operation is in progress. */
745
+ readonly isDragging: _angular_core.Signal<boolean>;
746
+ protected readonly cssX: _angular_core.Signal<string>;
747
+ protected readonly cssY: _angular_core.Signal<string>;
748
+ private dragStartX;
749
+ private dragStartY;
750
+ private posStartX;
751
+ private posStartY;
752
+ private boundMove;
753
+ private boundUp;
754
+ constructor();
755
+ private currentHandle;
756
+ private boundPointerDown;
757
+ private boundKeyDown;
758
+ /** Attach pointer and keyboard listeners to `el`, cleaning up the previous handle first. */
759
+ private setupHandle;
760
+ private handlePointerDown;
761
+ private handlePointerMove;
762
+ private handlePointerUp;
763
+ private handleKeyDown;
764
+ /** Snap `x`/`y` to the nearest `gridSize` increment. Pass-through when grid is disabled. */
765
+ private snap;
766
+ private cleanup;
767
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<CngxDialogDraggable, never>;
768
+ static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CngxDialogDraggable, "[cngxDialogDraggable]", ["cngxDialogDraggable"], { "handle": { "alias": "handle"; "required": false; "isSignal": true; }; "constrainToViewport": { "alias": "constrainToViewport"; "required": false; "isSignal": true; }; "gridSize": { "alias": "gridSize"; "required": false; "isSignal": true; }; "snapMode": { "alias": "snapMode"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
769
+ }
770
+
771
+ export { CNGX_DIALOG_DATA, CngxBottomSheet, CngxDialog, CngxDialogClose, CngxDialogDescription, CngxDialogDraggable, CngxDialogOpener, CngxDialogRef, CngxDialogStack, CngxDialogTitle, DIALOG_REF, provideDialog, provideDialogStack };
772
+ export type { CngxDialogConfig, DialogRef, DialogState };