@cngx/common 0.1.0-rc.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/a11y/README.md +15 -2
  2. package/button/README.md +258 -0
  3. package/command/README.md +42 -2
  4. package/data/README.md +15 -12
  5. package/fesm2022/cngx-common-a11y.mjs +1076 -319
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +99 -77
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-button.mjs +1084 -0
  10. package/fesm2022/cngx-common-button.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +138 -78
  12. package/fesm2022/cngx-common-card.mjs.map +1 -1
  13. package/fesm2022/cngx-common-chart.mjs +799 -327
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  15. package/fesm2022/cngx-common-command.mjs +101 -25
  16. package/fesm2022/cngx-common-command.mjs.map +1 -1
  17. package/fesm2022/cngx-common-data.mjs +861 -423
  18. package/fesm2022/cngx-common-data.mjs.map +1 -1
  19. package/fesm2022/cngx-common-dialog.mjs +198 -160
  20. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  21. package/fesm2022/cngx-common-display.mjs +693 -329
  22. package/fesm2022/cngx-common-display.mjs.map +1 -1
  23. package/fesm2022/cngx-common-interactive.mjs +7303 -2774
  24. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  25. package/fesm2022/cngx-common-layout.mjs +2174 -442
  26. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  27. package/fesm2022/cngx-common-menu-button.mjs +557 -0
  28. package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
  29. package/fesm2022/cngx-common-popover.mjs +2109 -557
  30. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  31. package/fesm2022/cngx-common-stepper.mjs +548 -419
  32. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  33. package/fesm2022/cngx-common-tabs.mjs +442 -331
  34. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  35. package/fesm2022/cngx-common-timeline.mjs +44 -71
  36. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  37. package/fesm2022/cngx-common.mjs +10 -10
  38. package/fesm2022/cngx-common.mjs.map +1 -1
  39. package/interactive/README.md +30 -19
  40. package/layout/README.md +17 -1
  41. package/menu-button/README.md +234 -0
  42. package/package.json +31 -8
  43. package/popover/README.md +81 -4
  44. package/popover/tooltip-indicator.scss +52 -0
  45. package/schematics/collection.json +9 -0
  46. package/schematics/ng-add/index.js +9 -0
  47. package/schematics/ng-add/schema.json +96 -0
  48. package/schematics/package.json +3 -0
  49. package/stepper/README.md +5 -5
  50. package/theming/components/cngx-accordion.css +36 -7
  51. package/theming/components/cngx-async.css +185 -37
  52. package/theming/components/cngx-backdrop.css +3 -1
  53. package/theming/components/cngx-badge.css +20 -5
  54. package/theming/components/cngx-bottom-sheet.css +2 -0
  55. package/theming/components/cngx-breadcrumb.css +3 -1
  56. package/theming/components/cngx-button-group.css +325 -0
  57. package/theming/components/cngx-button-toggle.css +55 -23
  58. package/theming/components/cngx-button.css +975 -0
  59. package/theming/components/cngx-data-grid.css +2 -0
  60. package/theming/components/cngx-dialog.css +3 -1
  61. package/theming/components/cngx-divider.css +24 -9
  62. package/theming/components/cngx-drawer.css +153 -0
  63. package/theming/components/cngx-icon-glyph.css +76 -0
  64. package/theming/components/cngx-listbox.css +79 -25
  65. package/theming/components/cngx-menu.css +112 -52
  66. package/theming/components/cngx-nav.css +1220 -0
  67. package/theming/components/cngx-popover-sheet.css +434 -0
  68. package/theming/components/cngx-popover.css +37 -9
  69. package/theming/components/cngx-recycler-placeholder.css +2 -0
  70. package/theming/components/cngx-ripple.css +74 -16
  71. package/theming/components/cngx-sidebar.css +71 -0
  72. package/theming/components/cngx-slider.css +3 -1
  73. package/theming/components/cngx-tooltip.css +2 -0
  74. package/timeline/README.md +2 -2
  75. package/types/cngx-common-a11y.d.ts +488 -112
  76. package/types/cngx-common-audio.d.ts +60 -88
  77. package/types/cngx-common-button.d.ts +698 -0
  78. package/types/cngx-common-card.d.ts +104 -78
  79. package/types/cngx-common-chart.d.ts +677 -389
  80. package/types/cngx-common-command.d.ts +55 -41
  81. package/types/cngx-common-data.d.ts +506 -360
  82. package/types/cngx-common-dialog.d.ts +94 -127
  83. package/types/cngx-common-display.d.ts +475 -300
  84. package/types/cngx-common-interactive.d.ts +4383 -1721
  85. package/types/cngx-common-layout.d.ts +1399 -288
  86. package/types/cngx-common-menu-button.d.ts +382 -0
  87. package/types/cngx-common-popover.d.ts +990 -268
  88. package/types/cngx-common-stepper.d.ts +374 -465
  89. package/types/cngx-common-tabs.d.ts +309 -403
  90. package/types/cngx-common-timeline.d.ts +50 -109
@@ -1,19 +1,20 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, signal, computed, Injectable, ElementRef, DestroyRef, Directive, Renderer2, contentChild, input, effect, untracked, isDevMode, viewChild, ViewContainerRef, ChangeDetectionStrategy, Component, ApplicationRef, EnvironmentInjector, Injector, createComponent } from '@angular/core';
2
+ import { InjectionToken, inject, signal, computed, Injectable, ElementRef, DestroyRef, Directive, Renderer2, contentChild, input, effect, untracked, viewChild, ViewContainerRef, ChangeDetectionStrategy, Component, ApplicationRef, EnvironmentInjector, Injector, createComponent } from '@angular/core';
3
3
  import { DOCUMENT } from '@angular/common';
4
4
  import { createOverrideMerge, nextUid, coerceSignal, buildAsyncStateView, hasTransition, onTransitionDone } from '@cngx/core/utils';
5
+ import { createHotkeyScope, CNGX_HOTKEY_SCOPE, CngxSwipeDismiss } from '@cngx/common/interactive';
6
+ import { CNGX_FOCUSABLE_SELECTOR } from '@cngx/common/a11y';
5
7
  import { createScrollLock } from '@cngx/common/layout';
8
+ import { cngxDevWarn } from '@cngx/utils';
6
9
  import { isObservable, firstValueFrom, filter, take, map } from 'rxjs';
7
10
  import { createLanguageSection } from '@cngx/core/i18n';
8
11
  import { toObservable } from '@angular/core/rxjs-interop';
9
- import { CngxSwipeDismiss } from '@cngx/common/interactive';
10
12
 
11
13
  /**
12
14
  * Injection token to access the nearest `DialogRef` from inside a dialog.
13
15
  *
14
- * @category common/dialog
15
16
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-ref.ts
16
- * @since 0.1.0
17
+ * @since 0.3.0
17
18
  */
18
19
  const DIALOG_REF = new InjectionToken('CngxDialogRef');
19
20
 
@@ -21,8 +22,7 @@ const DIALOG_REF = new InjectionToken('CngxDialogRef');
21
22
  * The English dialog section: the single source of the dialog family's
22
23
  * English copy. The `CNGX_DIALOG_DEFAULTS` labels default to it.
23
24
  *
24
- * @category common/dialog/i18n
25
- * @since 0.1.0
25
+ * @since 0.3.0
26
26
  * @relatedTo CNGX_DIALOG_DEFAULTS
27
27
  */
28
28
  const CNGX_DIALOG_LANGUAGE_EN = {
@@ -41,10 +41,9 @@ const dialogLabelsFromPack = createLanguageSection('dialog', CNGX_DIALOG_LANGUAG
41
41
  * defaults, so a consumer who provides nothing keeps today's behaviour
42
42
  * exactly.
43
43
  *
44
- * @category common/dialog/config
45
44
  * @wcag AA
46
45
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
47
- * @since 0.1.0
46
+ * @since 0.3.0
48
47
  * @relatedTo CngxDialog, CngxDialogClose, CngxDialogDraggable
49
48
  */
50
49
  const CNGX_DIALOG_DEFAULTS = new InjectionToken('CngxDialogDefaults', {
@@ -66,9 +65,8 @@ const CNGX_DIALOG_DEFAULTS = new InjectionToken('CngxDialogDefaults', {
66
65
  * });
67
66
  * ```
68
67
  *
69
- * @category common/dialog/config
70
68
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
71
- * @since 0.1.0
69
+ * @since 0.3.0
72
70
  */
73
71
  function withDialogLabels(overrides) {
74
72
  return { labels: overrides };
@@ -77,9 +75,8 @@ function withDialogLabels(overrides) {
77
75
  * Register app-wide dialog defaults composed from `with*` features, applied
78
76
  * on top of the active language pack.
79
77
  *
80
- * @category common/dialog/config
81
78
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
82
- * @since 0.1.0
79
+ * @since 0.3.0
83
80
  */
84
81
  function provideDialogConfig(...features) {
85
82
  return [
@@ -95,9 +92,8 @@ function provideDialogConfig(...features) {
95
92
  * Sub-tree variant - use in `viewProviders` so the defaults only apply to
96
93
  * dialogs opened from descendants of this component.
97
94
  *
98
- * @category common/dialog/config
99
95
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
100
- * @since 0.1.0
96
+ * @since 0.3.0
101
97
  */
102
98
  function provideDialogConfigAt(...features) {
103
99
  return provideDialogConfig(...features);
@@ -106,9 +102,8 @@ function provideDialogConfigAt(...features) {
106
102
  * Inject the currently-resolved dialog defaults. Safe in any injection
107
103
  * context; falls back to the English bundle when nothing is provided.
108
104
  *
109
- * @category common/dialog/config
110
105
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
111
- * @since 0.1.0
106
+ * @since 0.3.0
112
107
  */
113
108
  function injectDialogConfig() {
114
109
  return inject(CNGX_DIALOG_DEFAULTS);
@@ -119,6 +114,7 @@ function injectDialogConfig() {
119
114
  *
120
115
  * Provided by `CngxDialog` (`useExisting`) on the dialog element and by
121
116
  * `CngxDialogOpener` on the programmatic content's child injector.
117
+ * @internal
122
118
  */
123
119
  const CNGX_DIALOG_ARIA_REGISTRY = new InjectionToken('CngxDialogAriaRegistry');
124
120
 
@@ -130,20 +126,19 @@ const CNGX_DIALOG_ARIA_REGISTRY = new InjectionToken('CngxDialogAriaRegistry');
130
126
  * its `::backdrop`. Each `CngxDialog` reads `isTopmost` from this service
131
127
  * to control `--cngx-dialog-backdrop-opacity`.
132
128
  *
133
- * @category common/dialog
134
129
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-stack.ts
135
- * @since 0.1.0
130
+ * @since 0.3.0
136
131
  * @relatedTo CngxDialog, CngxDialogOpener
137
- * <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
138
- * <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
139
- * <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
140
- * <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
141
- * <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
142
- * <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
143
- * <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
144
- * <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
145
- * <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
146
- * <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
132
+ * <example-url>/#/common/dialog/alert-dialog</example-url>
133
+ * <example-url>/#/common/dialog/bottom-sheet</example-url>
134
+ * <example-url>/#/common/dialog/cngxdialogopener-programmatic</example-url>
135
+ * <example-url>/#/common/dialog/draggable-dialog</example-url>
136
+ * <example-url>/#/common/dialog/fully-declarative</example-url>
137
+ * <example-url>/#/common/dialog/grid-snap-live-vs-release</example-url>
138
+ * <example-url>/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
139
+ * <example-url>/#/common/dialog/non-modal-panel</example-url>
140
+ * <example-url>/#/common/dialog/programmatic-control</example-url>
141
+ * <example-url>/#/common/dialog/template-directives</example-url>
147
142
  */
148
143
  class CngxDialogStack {
149
144
  stackState = signal([], ...(ngDevMode ? [{ debugName: "stackState" }] : /* istanbul ignore next */ []));
@@ -179,8 +174,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
179
174
  * })
180
175
  * export class NestedDialogHost { }
181
176
  * ```
182
- *
183
- * @category common/dialog
184
177
  */
185
178
  function provideDialogStack() {
186
179
  return CngxDialogStack;
@@ -200,22 +193,20 @@ function provideDialogStack() {
200
193
  * </dialog>
201
194
  * ```
202
195
  *
203
- * @category common/dialog
204
- * @docsKind primary
205
196
  * @wcag AA
206
197
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-title.directive.ts
207
- * @since 0.1.0
198
+ * @since 0.3.0
208
199
  * @relatedTo CngxDialog, CngxDialogDescription, CngxDialogClose
209
- * <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
210
- * <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
211
- * <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
212
- * <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
213
- * <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
214
- * <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
215
- * <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
216
- * <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
217
- * <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
218
- * <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
200
+ * <example-url>/#/common/dialog/alert-dialog</example-url>
201
+ * <example-url>/#/common/dialog/bottom-sheet</example-url>
202
+ * <example-url>/#/common/dialog/cngxdialogopener-programmatic</example-url>
203
+ * <example-url>/#/common/dialog/draggable-dialog</example-url>
204
+ * <example-url>/#/common/dialog/fully-declarative</example-url>
205
+ * <example-url>/#/common/dialog/grid-snap-live-vs-release</example-url>
206
+ * <example-url>/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
207
+ * <example-url>/#/common/dialog/non-modal-panel</example-url>
208
+ * <example-url>/#/common/dialog/programmatic-control</example-url>
209
+ * <example-url>/#/common/dialog/template-directives</example-url>
219
210
  */
220
211
  class CngxDialogTitle {
221
212
  elRef = inject(ElementRef);
@@ -279,22 +270,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
279
270
  * </dialog>
280
271
  * ```
281
272
  *
282
- * @category common/dialog
283
- * @docsKind primary
284
273
  * @wcag AA
285
274
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-description.directive.ts
286
- * @since 0.1.0
275
+ * @since 0.3.0
287
276
  * @relatedTo CngxDialog, CngxDialogTitle, CngxDialogClose
288
- * <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
289
- * <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
290
- * <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
291
- * <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
292
- * <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
293
- * <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
294
- * <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
295
- * <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
296
- * <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
297
- * <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
277
+ * <example-url>/#/common/dialog/alert-dialog</example-url>
278
+ * <example-url>/#/common/dialog/bottom-sheet</example-url>
279
+ * <example-url>/#/common/dialog/cngxdialogopener-programmatic</example-url>
280
+ * <example-url>/#/common/dialog/draggable-dialog</example-url>
281
+ * <example-url>/#/common/dialog/fully-declarative</example-url>
282
+ * <example-url>/#/common/dialog/grid-snap-live-vs-release</example-url>
283
+ * <example-url>/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
284
+ * <example-url>/#/common/dialog/non-modal-panel</example-url>
285
+ * <example-url>/#/common/dialog/programmatic-control</example-url>
286
+ * <example-url>/#/common/dialog/template-directives</example-url>
298
287
  */
299
288
  class CngxDialogDescription {
300
289
  dialogRef = inject(DIALOG_REF, { optional: true });
@@ -344,6 +333,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
344
333
  * targets and live regions must never be `display: none`.
345
334
  *
346
335
  * Internal helper - intentionally not exported from `public-api.ts`.
336
+ * @internal
347
337
  */
348
338
  function applySrOnly(el) {
349
339
  el.className = 'cngx-sr-only';
@@ -358,6 +348,42 @@ function applySrOnly(el) {
358
348
  el.style.border = '0';
359
349
  }
360
350
 
351
+ /**
352
+ * The registry is single-slot per kind, so a second live registration
353
+ * silently wins - surface the authoring error instead of letting the
354
+ * two open paths resolve different labelling. A module function, not a
355
+ * method: a class keeps its methods in the bundle, and an emptied method
356
+ * still pulls `cngxDevWarn` into the production build.
357
+ */
358
+ function warnDoubleRegistration(id, kind, current, next) {
359
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
360
+ return;
361
+ }
362
+ if (current === null || current === next) {
363
+ return;
364
+ }
365
+ cngxDevWarn('CNGX1014', `[cngxDialog] dialog "${id}" has a second ${kind} registered while another ` +
366
+ `is live. The dialog references one ${kind} id, and both elements render it; a ` +
367
+ `template-declared ${kind} wins over a registered one. Remove the extra ` +
368
+ `cngxDialog${kind === 'title' ? 'Title' : 'Description'} element.`);
369
+ }
370
+ /**
371
+ * A non-modal dialog keeps focus on the page, so the only announcement is
372
+ * the title text the dialog writes into its own live region on open. Warn
373
+ * when there is no title text to announce. A module function for the same
374
+ * reason as `warnDoubleRegistration`.
375
+ */
376
+ function warnNonModalA11y(id, titleText) {
377
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
378
+ return;
379
+ }
380
+ if (titleText === '') {
381
+ cngxDevWarn('CNGX1015', `[cngxDialog] non-modal dialog "${id}" opened without a title. ` +
382
+ 'A non-modal dialog leaves focus on the page and is announced only by ' +
383
+ 'reading its title into its live region; with no title text, screen reader ' +
384
+ 'users are not told it appeared. Add a [cngxDialogTitle] element with text.');
385
+ }
386
+ }
361
387
  /**
362
388
  * Signal-driven state machine for native `<dialog>`.
363
389
  *
@@ -414,22 +440,21 @@ function applySrOnly(el) {
414
440
  * </dialog>
415
441
  * ```
416
442
  *
417
- * @category common/dialog
418
- * @docsKind primary
419
443
  * @wcag AA
420
444
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog.directive.ts
421
- * @since 0.1.0
445
+ * @since 0.3.0
422
446
  * @relatedTo CngxBottomSheet, CngxDialogOpener, CngxDialogTitle, CngxDialogClose, CngxDialogDraggable
423
- * <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
424
- * <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
425
- * <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
426
- * <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
427
- * <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
428
- * <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
429
- * <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
430
- * <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
431
- * <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
432
- * <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
447
+ * <example-url>/#/common/dialog/alert-dialog</example-url>
448
+ * <example-url>/#/common/dialog/bottom-sheet</example-url>
449
+ * <example-url>/#/common/dialog/cngxdialogopener-programmatic</example-url>
450
+ * <example-url>/#/common/dialog/draggable-dialog</example-url>
451
+ * <example-url>/#/common/dialog/fully-declarative</example-url>
452
+ * <example-url>/#/common/dialog/grid-snap-live-vs-release</example-url>
453
+ * <example-url>/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
454
+ * <example-url>/#/common/dialog/non-modal-panel</example-url>
455
+ * <example-url>/#/common/dialog/programmatic-control</example-url>
456
+ * <example-url>/#/common/dialog/template-directives</example-url>
457
+ * @axis level organism
433
458
  */
434
459
  class CngxDialog {
435
460
  elRef = inject(ElementRef);
@@ -483,7 +508,7 @@ class CngxDialog {
483
508
  * Only applies to modal dialogs.
484
509
  *
485
510
  * - `'first-focusable'` -- focus the first `[autofocus]` element, or the
486
- * first focusable element in DOM order (default)
511
+ * first element in DOM order matching `CNGX_FOCUSABLE_SELECTOR` (default)
487
512
  * - `'none'` -- do not move focus
488
513
  * - Any CSS selector string -- focus the first element matching the selector
489
514
  *
@@ -616,6 +641,10 @@ class CngxDialog {
616
641
  }, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
617
642
  backdropOpacity = computed(() => this.dialogStack.topmost() === this.idSignal() ? '1' : '0', ...(ngDevMode ? [{ debugName: "backdropOpacity" }] : /* istanbul ignore next */ []));
618
643
  liveRegion = null;
644
+ /** The title text the open announcement reads; `''` when there is none. */
645
+ currentTitleText() {
646
+ return (this.titleDirective() ?? this.registeredTitle())?.textContent?.() ?? '';
647
+ }
619
648
  /**
620
649
  * The modal mode latched at `open()`. Everything that depends on how the
621
650
  * dialog actually opened derives from this - scroll-lock release, stack
@@ -624,11 +653,28 @@ class CngxDialog {
624
653
  * nor strand a rendered backdrop without its dismissal surface.
625
654
  */
626
655
  openedAsModal = signal(false, ...(ngDevMode ? [{ debugName: "openedAsModal" }] : /* istanbul ignore next */ []));
656
+ /**
657
+ * @internal Hotkey scope of the dialog subtree: modal while opened as a
658
+ * modal, so app bindings outside stay quiet while focus is inside, and
659
+ * inactive while closed, so bindings inside never fire from a hidden dialog.
660
+ */
661
+ hotkeyScope = createHotkeyScope({
662
+ element: this.elRef.nativeElement,
663
+ modal: this.openedAsModal.asReadonly(),
664
+ active: computed(() => this.lifecycleSignal() !== 'closed'),
665
+ parent: inject(CNGX_HOTKEY_SCOPE, { optional: true, skipSelf: true }),
666
+ destroyRef: this.destroyRef,
667
+ });
627
668
  constructor() {
628
669
  this.createLiveRegion();
629
670
  effect(() => {
630
671
  if (this.lifecycleSignal() === 'open') {
631
- const titleText = untracked(() => (this.titleDirective() ?? this.registeredTitle())?.textContent?.() ?? '');
672
+ const titleText = untracked(() => this.currentTitleText());
673
+ // Checked where the announcement reads the title: an opener-created
674
+ // dialog's title only exists once its content view has rendered.
675
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !untracked(this.openedAsModal)) {
676
+ warnNonModalA11y(untracked(this.idSignal), titleText);
677
+ }
632
678
  if (titleText && this.liveRegion) {
633
679
  this.liveRegion.textContent = titleText;
634
680
  // Clear after one frame so subsequent opens re-announce
@@ -676,7 +722,9 @@ class CngxDialog {
676
722
  * @internal CNGX_DIALOG_ARIA_REGISTRY implementation - not public API.
677
723
  */
678
724
  registerTitle(handle) {
679
- this.warnDoubleRegistration('title', untracked(this.registeredTitle), handle);
725
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
726
+ warnDoubleRegistration(untracked(this.idSignal), 'title', untracked(this.registeredTitle), handle);
727
+ }
680
728
  this.registeredTitle.set(handle);
681
729
  return () => this.registeredTitle.update((current) => (current === handle ? null : current));
682
730
  }
@@ -686,7 +734,9 @@ class CngxDialog {
686
734
  * @internal CNGX_DIALOG_ARIA_REGISTRY implementation - not public API.
687
735
  */
688
736
  registerDescription(handle) {
689
- this.warnDoubleRegistration('description', untracked(this.registeredDescription), handle);
737
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
738
+ warnDoubleRegistration(untracked(this.idSignal), 'description', untracked(this.registeredDescription), handle);
739
+ }
690
740
  this.registeredDescription.set(handle);
691
741
  return () => this.registeredDescription.update((current) => (current === handle ? null : current));
692
742
  }
@@ -727,7 +777,6 @@ class CngxDialog {
727
777
  }
728
778
  else {
729
779
  dialog.show();
730
- this.warnNonModalA11y();
731
780
  }
732
781
  // Transition to open after browser paints the opening class
733
782
  requestAnimationFrame(() => {
@@ -898,8 +947,7 @@ class CngxDialog {
898
947
  autofocusEl.focus();
899
948
  return;
900
949
  }
901
- const focusable = dialog.querySelector('a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])');
902
- focusable?.focus();
950
+ dialog.querySelector(CNGX_FOCUSABLE_SELECTOR)?.focus();
903
951
  }
904
952
  else {
905
953
  const target = dialog.querySelector(strategy);
@@ -940,39 +988,11 @@ class CngxDialog {
940
988
  this.scrollLockRelease?.();
941
989
  this.scrollLockRelease = null;
942
990
  }
943
- /**
944
- * The registry is single-slot per kind, so a second live registration
945
- * silently wins - surface the authoring error instead of letting the
946
- * two open paths resolve different labelling.
947
- */
948
- warnDoubleRegistration(kind, current, next) {
949
- if (!isDevMode() || current === null || current === next) {
950
- return;
951
- }
952
- console.warn(`CngxDialog [${this.idSignal()}]: a second ${kind} registered while another ` +
953
- `is live. The dialog references one ${kind} id - the newest registration ` +
954
- `wins. Remove the extra cngxDialog${kind === 'title' ? 'Title' : 'Description'} element.`);
955
- }
956
- warnNonModalA11y() {
957
- if (!isDevMode()) {
958
- return;
959
- }
960
- // Non-modal dialogs are silent to SR. Warn if no aria-live sibling found.
961
- const trigger = this.triggerElement();
962
- if (trigger) {
963
- const parent = trigger.parentElement;
964
- if (parent && !parent.querySelector('[aria-live]')) {
965
- console.warn(`CngxDialog [${this.idSignal()}]: Non-modal dialog opened without an ` +
966
- '`aria-live` region near the trigger. Screen reader users will not ' +
967
- 'be notified that the dialog appeared. Add `aria-live="polite"` to a ' +
968
- 'sibling element that announces the dialog presence.');
969
- }
970
- }
971
- }
972
991
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialog, deps: [], target: i0.ɵɵFactoryTarget.Directive });
973
992
  static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.4", type: CngxDialog, isStandalone: true, selector: "dialog[cngxDialog]", inputs: { modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, closeOnBackdropClick: { classPropertyName: "closeOnBackdropClick", publicName: "closeOnBackdropClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, autoFocus: { classPropertyName: "autoFocus", publicName: "autoFocus", isSignal: true, isRequired: false, transformFunction: null }, focusFallback: { classPropertyName: "focusFallback", publicName: "focusFallback", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, submitAction: { classPropertyName: "submitAction", publicName: "submitAction", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "cancel": "handleCancel($event)", "pointerdown": "handlePointerDown($event)", "click": "handleClick($event)" }, properties: { "class.cngx-dialog--opening": "isOpening()", "class.cngx-dialog--open": "isOpen()", "class.cngx-dialog--closing": "isClosing()", "class.cngx-dialog--modal": "modal()", "attr.aria-modal": "ariaModal()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-describedby": "ariaDescribedBy()", "class.cngx-dialog--pending": "isPending()", "attr.aria-busy": "isPending() || null", "class.cngx-dialog--error": "effectiveError()", "style.--cngx-dialog-backdrop-opacity": "backdropOpacity()" } }, providers: [
974
993
  { provide: DIALOG_REF, useExisting: CngxDialog },
975
994
  { provide: CNGX_DIALOG_ARIA_REGISTRY, useExisting: CngxDialog },
995
+ { provide: CNGX_HOTKEY_SCOPE, useFactory: () => inject(CngxDialog).hotkeyScope },
976
996
  ], queries: [{ propertyName: "titleDirective", first: true, predicate: CngxDialogTitle, descendants: true, isSignal: true }, { propertyName: "descriptionDirective", first: true, predicate: CngxDialogDescription, descendants: true, isSignal: true }], exportAs: ["cngxDialog"], ngImport: i0 });
977
997
  }
978
998
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialog, decorators: [{
@@ -984,6 +1004,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
984
1004
  providers: [
985
1005
  { provide: DIALOG_REF, useExisting: CngxDialog },
986
1006
  { provide: CNGX_DIALOG_ARIA_REGISTRY, useExisting: CngxDialog },
1007
+ { provide: CNGX_HOTKEY_SCOPE, useFactory: () => inject(CngxDialog).hotkeyScope },
987
1008
  ],
988
1009
  host: {
989
1010
  '[class.cngx-dialog--opening]': 'isOpening()',
@@ -1021,22 +1042,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1021
1042
  * </dialog>
1022
1043
  * ```
1023
1044
  *
1024
- * @category common/dialog
1025
- * @docsKind primary
1026
1045
  * @wcag AA
1027
1046
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-close.directive.ts
1028
- * @since 0.1.0
1047
+ * @since 0.3.0
1029
1048
  * @relatedTo CngxDialog, CngxDialogTitle, CngxDialogDescription
1030
- * <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
1031
- * <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
1032
- * <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
1033
- * <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
1034
- * <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
1035
- * <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
1036
- * <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
1037
- * <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
1038
- * <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
1039
- * <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
1049
+ * <example-url>/#/common/dialog/alert-dialog</example-url>
1050
+ * <example-url>/#/common/dialog/bottom-sheet</example-url>
1051
+ * <example-url>/#/common/dialog/cngxdialogopener-programmatic</example-url>
1052
+ * <example-url>/#/common/dialog/draggable-dialog</example-url>
1053
+ * <example-url>/#/common/dialog/fully-declarative</example-url>
1054
+ * <example-url>/#/common/dialog/grid-snap-live-vs-release</example-url>
1055
+ * <example-url>/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
1056
+ * <example-url>/#/common/dialog/non-modal-panel</example-url>
1057
+ * <example-url>/#/common/dialog/programmatic-control</example-url>
1058
+ * <example-url>/#/common/dialog/template-directives</example-url>
1040
1059
  */
1041
1060
  class CngxDialogClose {
1042
1061
  dialogRef = inject(DIALOG_REF);
@@ -1116,9 +1135,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1116
1135
  /**
1117
1136
  * Injection token for data passed to a programmatically opened dialog via `CngxDialogOpener.open()`.
1118
1137
  *
1119
- * @category common/dialog
1120
1138
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog-config.ts
1121
- * @since 0.1.0
1139
+ * @since 0.3.0
1122
1140
  */
1123
1141
  const CNGX_DIALOG_DATA = new InjectionToken('CngxDialogData');
1124
1142
 
@@ -1202,9 +1220,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1202
1220
  * });
1203
1221
  * ```
1204
1222
  *
1205
- * @category common/dialog
1206
1223
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog.service.ts
1207
- * @since 0.1.0
1224
+ * @since 0.3.0
1208
1225
  * @relatedTo CngxDialogOpener, CngxDialog, CNGX_DIALOG_DATA
1209
1226
  */
1210
1227
  class CngxDialogRef {
@@ -1326,10 +1343,8 @@ class CngxDialogRef {
1326
1343
  * }
1327
1344
  * ```
1328
1345
  *
1329
- * @category common/dialog
1330
- * @docsKind primary
1331
1346
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/dialog/dialog.service.ts
1332
- * @since 0.1.0
1347
+ * @since 0.3.0
1333
1348
  * @relatedTo CngxDialog, CngxDialogRef, CNGX_DIALOG_DATA, CngxDialogStack
1334
1349
  */
1335
1350
  class CngxDialogOpener {
@@ -1345,6 +1360,14 @@ class CngxDialogOpener {
1345
1360
  * one live effect.
1346
1361
  */
1347
1362
  cleanupEffects = new WeakMap();
1363
+ /**
1364
+ * Opens a dialog whose body is a component type or a template. Creates the
1365
+ * dialog outlet, appends it to `document.body`, applies the `config` flags
1366
+ * (`modal`, `closeOnBackdropClick` and `closeOnEscape` default to `true`) and
1367
+ * returns a `CngxDialogRef` that stays tracked, and is torn down, until the
1368
+ * dialog closes. If creating the content throws, the outlet is removed and the
1369
+ * error is rethrown.
1370
+ */
1348
1371
  open(content, config = {}) {
1349
1372
  const outletRef = createComponent(CngxDialogOutlet, {
1350
1373
  environmentInjector: this.envInjector,
@@ -1385,21 +1408,36 @@ class CngxDialogOpener {
1385
1408
  // queries cannot see - labelling flows through the registry instead.
1386
1409
  { provide: CNGX_DIALOG_ARIA_REGISTRY, useValue: dialogInstance },
1387
1410
  { provide: CNGX_DIALOG_DATA, useValue: config.data ?? null },
1411
+ // Same reason: content injectors hang off the service, not the dialog.
1412
+ { provide: CNGX_HOTKEY_SCOPE, useValue: dialogInstance.hotkeyScope },
1388
1413
  ],
1389
1414
  });
1390
- if (outletVcr) {
1391
- if (typeof content === 'function') {
1392
- contentRef = outletVcr.createComponent(content, {
1393
- injector: childInjector,
1394
- });
1395
- }
1396
- else {
1397
- outletVcr.createEmbeddedView(content, { $implicit: innerDialog }, { injector: childInjector });
1415
+ // Creating the content and its first render run consumer code. A throw
1416
+ // there must leave no outlet in the body and no ref in openDialogs, so
1417
+ // the ref is registered only after open() succeeded.
1418
+ try {
1419
+ if (outletVcr) {
1420
+ if (typeof content === 'function') {
1421
+ contentRef = outletVcr.createComponent(content, {
1422
+ injector: childInjector,
1423
+ });
1424
+ }
1425
+ else {
1426
+ outletVcr.createEmbeddedView(content, { $implicit: innerDialog }, { injector: childInjector });
1427
+ }
1398
1428
  }
1429
+ // The outlet's inputs reach the inner cngxDialog through template
1430
+ // bindings, and open() latches [modal]. Without this pass the dialog
1431
+ // would still see its input defaults and always open modal.
1432
+ outletRef.changeDetectorRef.detectChanges();
1433
+ dialogInstance.open();
1434
+ }
1435
+ catch (error) {
1436
+ this.discardOutlet(outletRef);
1437
+ throw error;
1399
1438
  }
1400
1439
  const dialogRef = new CngxDialogRef(innerDialog, outletRef, contentRef, this.injector);
1401
1440
  this.openDialogs.push(dialogRef);
1402
- dialogInstance.open();
1403
1441
  this.cleanupEffects.set(dialogRef, effect(() => {
1404
1442
  if (innerDialog.lifecycle() === 'closed' &&
1405
1443
  outletRef.hostView &&
@@ -1430,13 +1468,18 @@ class CngxDialogOpener {
1430
1468
  if (ref.componentRef && !ref.componentRef.hostView.destroyed) {
1431
1469
  ref.componentRef.destroy();
1432
1470
  }
1433
- const outletRef = ref._outletRef;
1434
- if (outletRef && !outletRef.hostView.destroyed) {
1435
- this.appRef.detachView(outletRef.hostView);
1436
- outletRef.location.nativeElement.remove();
1437
- outletRef.destroy();
1471
+ if (ref._outletRef) {
1472
+ this.discardOutlet(ref._outletRef);
1438
1473
  }
1439
1474
  }
1475
+ discardOutlet(outletRef) {
1476
+ if (outletRef.hostView.destroyed) {
1477
+ return;
1478
+ }
1479
+ this.appRef.detachView(outletRef.hostView);
1480
+ outletRef.location.nativeElement.remove();
1481
+ outletRef.destroy();
1482
+ }
1440
1483
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialogOpener, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1441
1484
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialogOpener });
1442
1485
  }
@@ -1454,8 +1497,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1454
1497
  * providers: [provideDialog()],
1455
1498
  * });
1456
1499
  * ```
1457
- *
1458
- * @category common/dialog
1459
1500
  */
1460
1501
  function provideDialog() {
1461
1502
  return [CngxDialogOpener];
@@ -1489,12 +1530,11 @@ function provideDialog() {
1489
1530
  * </dialog>
1490
1531
  * ```
1491
1532
  *
1492
- * @category common/dialog
1493
- * @docsKind primary
1494
1533
  * @wcag AA
1495
1534
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/bottom-sheet/bottom-sheet.directive.ts
1496
- * @since 0.1.0
1535
+ * @since 0.3.0
1497
1536
  * @relatedTo CngxDialog, CngxSwipeDismiss, CngxDialogClose
1537
+ * @axis level organism
1498
1538
  */
1499
1539
  class CngxBottomSheet {
1500
1540
  dialogRef = inject(DIALOG_REF);
@@ -1561,22 +1601,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1561
1601
  * }
1562
1602
  * ```
1563
1603
  *
1564
- * @category common/dialog
1565
- * @docsKind primary
1566
1604
  * @wcag AA
1567
1605
  * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/draggable/dialog-draggable.directive.ts
1568
- * @since 0.1.0
1606
+ * @since 0.3.0
1569
1607
  * @relatedTo CngxDialog, CngxBottomSheet
1570
- * <example-url>http://localhost:4200/#/common/dialog/alert-dialog</example-url>
1571
- * <example-url>http://localhost:4200/#/common/dialog/bottom-sheet</example-url>
1572
- * <example-url>http://localhost:4200/#/common/dialog/cngxdialogopener-programmatic</example-url>
1573
- * <example-url>http://localhost:4200/#/common/dialog/draggable-dialog</example-url>
1574
- * <example-url>http://localhost:4200/#/common/dialog/fully-declarative</example-url>
1575
- * <example-url>http://localhost:4200/#/common/dialog/grid-snap-live-vs-release</example-url>
1576
- * <example-url>http://localhost:4200/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
1577
- * <example-url>http://localhost:4200/#/common/dialog/non-modal-panel</example-url>
1578
- * <example-url>http://localhost:4200/#/common/dialog/programmatic-control</example-url>
1579
- * <example-url>http://localhost:4200/#/common/dialog/template-directives</example-url>
1608
+ * <example-url>/#/common/dialog/alert-dialog</example-url>
1609
+ * <example-url>/#/common/dialog/bottom-sheet</example-url>
1610
+ * <example-url>/#/common/dialog/cngxdialogopener-programmatic</example-url>
1611
+ * <example-url>/#/common/dialog/draggable-dialog</example-url>
1612
+ * <example-url>/#/common/dialog/fully-declarative</example-url>
1613
+ * <example-url>/#/common/dialog/grid-snap-live-vs-release</example-url>
1614
+ * <example-url>/#/common/dialog/nested-dialogs-cngxdialogstack</example-url>
1615
+ * <example-url>/#/common/dialog/non-modal-panel</example-url>
1616
+ * <example-url>/#/common/dialog/programmatic-control</example-url>
1617
+ * <example-url>/#/common/dialog/template-directives</example-url>
1580
1618
  */
1581
1619
  class CngxDialogDraggable {
1582
1620
  elRef = inject(ElementRef);
@@ -1690,8 +1728,8 @@ class CngxDialogDraggable {
1690
1728
  }
1691
1729
  // Don't drag if the target is an interactive element inside the handle
1692
1730
  const target = event.target;
1693
- if (target.closest('button, a, input, select, textarea, [tabindex]') &&
1694
- target !== this.currentHandle) {
1731
+ const interactiveTarget = target.closest('button, a, input, select, textarea, [tabindex]');
1732
+ if (interactiveTarget !== null && interactiveTarget !== this.currentHandle) {
1695
1733
  return;
1696
1734
  }
1697
1735
  event.preventDefault();
@@ -1899,7 +1937,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1899
1937
  }], ctorParameters: () => [], propDecorators: { handle: [{ type: i0.Input, args: [{ isSignal: true, alias: "handle", required: false }] }], constrainToViewport: [{ type: i0.Input, args: [{ isSignal: true, alias: "constrainToViewport", required: false }] }], gridSize: [{ type: i0.Input, args: [{ isSignal: true, alias: "gridSize", required: false }] }], snapMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "snapMode", required: false }] }] } });
1900
1938
 
1901
1939
  /**
1902
- * @module @cngx/common/dialog
1940
+ * @module `@cngx/common/dialog`
1903
1941
  */
1904
1942
 
1905
1943
  /**