@cngx/common 0.1.0-rc.7 → 0.1.0-rc.9

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 (69) hide show
  1. package/card/README.md +2 -1
  2. package/command/README.md +29 -0
  3. package/data/README.md +15 -3
  4. package/dialog/README.md +23 -1
  5. package/fesm2022/cngx-common-a11y.mjs +517 -184
  6. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  7. package/fesm2022/cngx-common-audio.mjs +62 -17
  8. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  9. package/fesm2022/cngx-common-card.mjs +301 -46
  10. package/fesm2022/cngx-common-card.mjs.map +1 -1
  11. package/fesm2022/cngx-common-chart.mjs +1221 -479
  12. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  13. package/fesm2022/cngx-common-command.mjs +97 -16
  14. package/fesm2022/cngx-common-command.mjs.map +1 -1
  15. package/fesm2022/cngx-common-data.mjs +1496 -499
  16. package/fesm2022/cngx-common-data.mjs.map +1 -1
  17. package/fesm2022/cngx-common-dialog.mjs +236 -61
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  19. package/fesm2022/cngx-common-display.mjs +364 -93
  20. package/fesm2022/cngx-common-display.mjs.map +1 -1
  21. package/fesm2022/cngx-common-interactive.mjs +2040 -1046
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  23. package/fesm2022/cngx-common-layout.mjs +955 -125
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  25. package/fesm2022/cngx-common-popover.mjs +1293 -89
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  27. package/fesm2022/cngx-common-stepper.mjs +997 -453
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  29. package/fesm2022/cngx-common-tabs.mjs +1794 -1265
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  31. package/fesm2022/cngx-common-timeline.mjs +151 -61
  32. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  33. package/fesm2022/cngx-common.mjs +1 -1
  34. package/interactive/README.md +15 -4
  35. package/layout/README.md +37 -1
  36. package/package.json +20 -7
  37. package/popover/README.md +58 -2
  38. package/schematics/collection.json +9 -0
  39. package/schematics/ng-add/index.js +9 -0
  40. package/schematics/ng-add/schema.json +91 -0
  41. package/schematics/package.json +3 -0
  42. package/stepper/README.md +11 -8
  43. package/theming/components/cngx-accordion.css +1 -1
  44. package/theming/components/cngx-backdrop.css +12 -0
  45. package/theming/components/cngx-button-toggle.css +29 -3
  46. package/theming/components/cngx-data-grid.css +168 -1
  47. package/theming/components/cngx-dialog.css +13 -0
  48. package/theming/components/cngx-listbox.css +21 -12
  49. package/theming/components/cngx-menu.css +56 -16
  50. package/theming/components/cngx-popover-sheet.css +402 -0
  51. package/theming/components/cngx-popover.css +28 -0
  52. package/theming/components/cngx-recycler-placeholder.css +196 -0
  53. package/theming/components/cngx-ripple.css +1 -1
  54. package/theming/components/cngx-slider.css +32 -1
  55. package/theming/components/cngx-tooltip.css +12 -0
  56. package/timeline/README.md +155 -0
  57. package/types/cngx-common-a11y.d.ts +205 -28
  58. package/types/cngx-common-card.d.ts +201 -17
  59. package/types/cngx-common-chart.d.ts +345 -48
  60. package/types/cngx-common-command.d.ts +50 -10
  61. package/types/cngx-common-data.d.ts +743 -92
  62. package/types/cngx-common-dialog.d.ts +161 -10
  63. package/types/cngx-common-display.d.ts +356 -142
  64. package/types/cngx-common-interactive.d.ts +910 -226
  65. package/types/cngx-common-layout.d.ts +603 -32
  66. package/types/cngx-common-popover.d.ts +612 -49
  67. package/types/cngx-common-stepper.d.ts +526 -237
  68. package/types/cngx-common-tabs.d.ts +358 -75
  69. package/types/cngx-common-timeline.d.ts +108 -22
@@ -1,9 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, signal, computed, Injectable, inject, 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
- import { nextUid, buildAsyncStateView, hasTransition, onTransitionDone } from '@cngx/core/utils';
4
+ import { createOverrideMerge, nextUid, coerceSignal, buildAsyncStateView, hasTransition, onTransitionDone } from '@cngx/core/utils';
5
5
  import { createScrollLock } from '@cngx/common/layout';
6
+ import { cngxDevWarn } from '@cngx/utils';
6
7
  import { isObservable, firstValueFrom, filter, take, map } from 'rxjs';
8
+ import { createLanguageSection } from '@cngx/core/i18n';
7
9
  import { toObservable } from '@angular/core/rxjs-interop';
8
10
  import { CngxSwipeDismiss } from '@cngx/common/interactive';
9
11
 
@@ -16,6 +18,103 @@ import { CngxSwipeDismiss } from '@cngx/common/interactive';
16
18
  */
17
19
  const DIALOG_REF = new InjectionToken('CngxDialogRef');
18
20
 
21
+ /**
22
+ * The English dialog section: the single source of the dialog family's
23
+ * English copy. The `CNGX_DIALOG_DEFAULTS` labels default to it.
24
+ *
25
+ * @category common/dialog/i18n
26
+ * @since 0.1.0
27
+ * @relatedTo CNGX_DIALOG_DEFAULTS
28
+ */
29
+ const CNGX_DIALOG_LANGUAGE_EN = {
30
+ close: 'Close dialog',
31
+ errorFallback: 'An error occurred',
32
+ dragHandle: 'Move dialog',
33
+ dragHandleRoleDescription: 'draggable',
34
+ dragInstructions: 'Use arrow keys to move the dialog; Shift for larger steps',
35
+ };
36
+
37
+ /** @internal The dialog section of the active pack over the English labels. */
38
+ const dialogLabelsFromPack = createLanguageSection('dialog', CNGX_DIALOG_LANGUAGE_EN);
39
+ /**
40
+ * DI token carrying the merged {@link CngxDialogDefaults}. `providedIn: 'root'`:
41
+ * `labels` is the dialog section of the active language pack over the English
42
+ * defaults, so a consumer who provides nothing keeps today's behaviour
43
+ * exactly.
44
+ *
45
+ * @category common/dialog/config
46
+ * @wcag AA
47
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
48
+ * @since 0.1.0
49
+ * @relatedTo CngxDialog, CngxDialogClose, CngxDialogDraggable
50
+ */
51
+ const CNGX_DIALOG_DEFAULTS = new InjectionToken('CngxDialogDefaults', {
52
+ providedIn: 'root',
53
+ factory: () => ({ labels: dialogLabelsFromPack() }),
54
+ });
55
+ /**
56
+ * Override dialog interaction strings. Unset keys keep the language pack's
57
+ * text, or the English default, and two calls merge rather than replace.
58
+ * Pass a `Signal` to switch the language at runtime.
59
+ *
60
+ * ```ts
61
+ * bootstrapApplication(AppComponent, {
62
+ * providers: [
63
+ * provideDialogConfig(
64
+ * withDialogLabels({ close: 'Dialog schließen', dragHandle: 'Dialog verschieben' }),
65
+ * ),
66
+ * ],
67
+ * });
68
+ * ```
69
+ *
70
+ * @category common/dialog/config
71
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
72
+ * @since 0.1.0
73
+ */
74
+ function withDialogLabels(overrides) {
75
+ return { labels: overrides };
76
+ }
77
+ /**
78
+ * Register app-wide dialog defaults composed from `with*` features, applied
79
+ * on top of the active language pack.
80
+ *
81
+ * @category common/dialog/config
82
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
83
+ * @since 0.1.0
84
+ */
85
+ function provideDialogConfig(...features) {
86
+ return [
87
+ {
88
+ provide: CNGX_DIALOG_DEFAULTS,
89
+ useFactory: () => ({
90
+ labels: features.reduce((acc, feature) => createOverrideMerge(acc, feature.labels), dialogLabelsFromPack()),
91
+ }),
92
+ },
93
+ ];
94
+ }
95
+ /**
96
+ * Sub-tree variant - use in `viewProviders` so the defaults only apply to
97
+ * dialogs opened from descendants of this component.
98
+ *
99
+ * @category common/dialog/config
100
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
101
+ * @since 0.1.0
102
+ */
103
+ function provideDialogConfigAt(...features) {
104
+ return provideDialogConfig(...features);
105
+ }
106
+ /**
107
+ * Inject the currently-resolved dialog defaults. Safe in any injection
108
+ * context; falls back to the English bundle when nothing is provided.
109
+ *
110
+ * @category common/dialog/config
111
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/dialog/config/dialog-config.ts
112
+ * @since 0.1.0
113
+ */
114
+ function injectDialogConfig() {
115
+ return inject(CNGX_DIALOG_DEFAULTS);
116
+ }
117
+
19
118
  /**
20
119
  * Injection token for the dialog ARIA registry.
21
120
  *
@@ -260,6 +359,42 @@ function applySrOnly(el) {
260
359
  el.style.border = '0';
261
360
  }
262
361
 
362
+ /**
363
+ * The registry is single-slot per kind, so a second live registration
364
+ * silently wins - surface the authoring error instead of letting the
365
+ * two open paths resolve different labelling. A module function, not a
366
+ * method: a class keeps its methods in the bundle, and an emptied method
367
+ * still pulls `cngxDevWarn` into the production build.
368
+ */
369
+ function warnDoubleRegistration(id, kind, current, next) {
370
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
371
+ return;
372
+ }
373
+ if (current === null || current === next) {
374
+ return;
375
+ }
376
+ cngxDevWarn('CNGX1014', `[cngxDialog] dialog "${id}" has a second ${kind} registered while another ` +
377
+ `is live. The dialog references one ${kind} id, and both elements render it; a ` +
378
+ `template-declared ${kind} wins over a registered one. Remove the extra ` +
379
+ `cngxDialog${kind === 'title' ? 'Title' : 'Description'} element.`);
380
+ }
381
+ /**
382
+ * A non-modal dialog keeps focus on the page, so the only announcement is
383
+ * the title text the dialog writes into its own live region on open. Warn
384
+ * when there is no title text to announce. A module function for the same
385
+ * reason as `warnDoubleRegistration`.
386
+ */
387
+ function warnNonModalA11y(id, titleText) {
388
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
389
+ return;
390
+ }
391
+ if (titleText === '') {
392
+ cngxDevWarn('CNGX1015', `[cngxDialog] non-modal dialog "${id}" opened without a title. ` +
393
+ 'A non-modal dialog leaves focus on the page and is announced only by ' +
394
+ 'reading its title into its live region; with no title text, screen reader ' +
395
+ 'users are not told it appeared. Add a [cngxDialogTitle] element with text.');
396
+ }
397
+ }
263
398
  /**
264
399
  * Signal-driven state machine for native `<dialog>`.
265
400
  *
@@ -339,6 +474,10 @@ class CngxDialog {
339
474
  renderer = inject(Renderer2);
340
475
  destroyRef = inject(DestroyRef);
341
476
  dialogStack = inject(CngxDialogStack);
477
+ labels = coerceSignal(injectDialogConfig().labels);
478
+ // Armed while a close transition runs; cancelled on destroy so the
479
+ // transitionend listener and fallback timer never outlive the directive.
480
+ pendingClose = null;
342
481
  titleDirective = contentChild(CngxDialogTitle, ...(ngDevMode ? [{ debugName: "titleDirective" }] : /* istanbul ignore next */ []));
343
482
  descriptionDirective = contentChild(CngxDialogDescription, ...(ngDevMode ? [{ debugName: "descriptionDirective" }] : /* istanbul ignore next */ []));
344
483
  // Push-registered counterparts of the content queries above. Programmatic
@@ -514,6 +653,10 @@ class CngxDialog {
514
653
  }, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
515
654
  backdropOpacity = computed(() => this.dialogStack.topmost() === this.idSignal() ? '1' : '0', ...(ngDevMode ? [{ debugName: "backdropOpacity" }] : /* istanbul ignore next */ []));
516
655
  liveRegion = null;
656
+ /** The title text the open announcement reads; `''` when there is none. */
657
+ currentTitleText() {
658
+ return (this.titleDirective() ?? this.registeredTitle())?.textContent?.() ?? '';
659
+ }
517
660
  /**
518
661
  * The modal mode latched at `open()`. Everything that depends on how the
519
662
  * dialog actually opened derives from this - scroll-lock release, stack
@@ -526,7 +669,12 @@ class CngxDialog {
526
669
  this.createLiveRegion();
527
670
  effect(() => {
528
671
  if (this.lifecycleSignal() === 'open') {
529
- 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
+ }
530
678
  if (titleText && this.liveRegion) {
531
679
  this.liveRegion.textContent = titleText;
532
680
  // Clear after one frame so subsequent opens re-announce
@@ -544,7 +692,10 @@ class CngxDialog {
544
692
  // so a retried identical failure would never re-fire this effect.
545
693
  if (this.effectiveError() && this.liveRegion) {
546
694
  const errMsg = this.state()?.error() ?? this.submitErrorState();
547
- this.liveRegion.textContent = typeof errMsg === 'string' ? errMsg : 'An error occurred';
695
+ // The fallback copy is read untracked: a language switch must not
696
+ // re-fire the announcement; the next error speaks the new language.
697
+ this.liveRegion.textContent =
698
+ typeof errMsg === 'string' ? errMsg : untracked(() => this.labels().errorFallback);
548
699
  // Clear after one frame (same pattern as the title announce) so a
549
700
  // repeated identical error is a fresh mutation the SR re-announces.
550
701
  requestAnimationFrame(() => {
@@ -555,6 +706,8 @@ class CngxDialog {
555
706
  }
556
707
  });
557
708
  this.destroyRef.onDestroy(() => {
709
+ // finalize() disarms pendingClose; a 'closed' lifecycle means it
710
+ // already ran and the handle is gone.
558
711
  if (this.lifecycleSignal() !== 'closed') {
559
712
  this.finalize();
560
713
  }
@@ -569,7 +722,9 @@ class CngxDialog {
569
722
  * @internal CNGX_DIALOG_ARIA_REGISTRY implementation - not public API.
570
723
  */
571
724
  registerTitle(handle) {
572
- this.warnDoubleRegistration('title', untracked(this.registeredTitle), handle);
725
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
726
+ warnDoubleRegistration(untracked(this.idSignal), 'title', untracked(this.registeredTitle), handle);
727
+ }
573
728
  this.registeredTitle.set(handle);
574
729
  return () => this.registeredTitle.update((current) => (current === handle ? null : current));
575
730
  }
@@ -579,7 +734,9 @@ class CngxDialog {
579
734
  * @internal CNGX_DIALOG_ARIA_REGISTRY implementation - not public API.
580
735
  */
581
736
  registerDescription(handle) {
582
- this.warnDoubleRegistration('description', untracked(this.registeredDescription), handle);
737
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
738
+ warnDoubleRegistration(untracked(this.idSignal), 'description', untracked(this.registeredDescription), handle);
739
+ }
583
740
  this.registeredDescription.set(handle);
584
741
  return () => this.registeredDescription.update((current) => (current === handle ? null : current));
585
742
  }
@@ -620,7 +777,6 @@ class CngxDialog {
620
777
  }
621
778
  else {
622
779
  dialog.show();
623
- this.warnNonModalA11y();
624
780
  }
625
781
  // Transition to open after browser paints the opening class
626
782
  requestAnimationFrame(() => {
@@ -752,13 +908,17 @@ class CngxDialog {
752
908
  startClosing() {
753
909
  if (hasTransition(this.dialogElement)) {
754
910
  this.lifecycleSignal.set('closing');
755
- onTransitionDone(this.dialogElement, () => this.finalize());
911
+ this.pendingClose = onTransitionDone(this.dialogElement, () => this.finalize());
756
912
  }
757
913
  else {
758
914
  this.finalize();
759
915
  }
760
916
  }
761
917
  finalize() {
918
+ // Disarm any pending close wait no matter which path got here, so the
919
+ // settled handle never lingers as a stale armed field.
920
+ this.pendingClose?.cancel();
921
+ this.pendingClose = null;
762
922
  const dialog = this.dialogElement;
763
923
  if (dialog.open) {
764
924
  dialog.close();
@@ -829,35 +989,6 @@ class CngxDialog {
829
989
  this.scrollLockRelease?.();
830
990
  this.scrollLockRelease = null;
831
991
  }
832
- /**
833
- * The registry is single-slot per kind, so a second live registration
834
- * silently wins - surface the authoring error instead of letting the
835
- * two open paths resolve different labelling.
836
- */
837
- warnDoubleRegistration(kind, current, next) {
838
- if (!isDevMode() || current === null || current === next) {
839
- return;
840
- }
841
- console.warn(`CngxDialog [${this.idSignal()}]: a second ${kind} registered while another ` +
842
- `is live. The dialog references one ${kind} id - the newest registration ` +
843
- `wins. Remove the extra cngxDialog${kind === 'title' ? 'Title' : 'Description'} element.`);
844
- }
845
- warnNonModalA11y() {
846
- if (!isDevMode()) {
847
- return;
848
- }
849
- // Non-modal dialogs are silent to SR. Warn if no aria-live sibling found.
850
- const trigger = this.triggerElement();
851
- if (trigger) {
852
- const parent = trigger.parentElement;
853
- if (parent && !parent.querySelector('[aria-live]')) {
854
- console.warn(`CngxDialog [${this.idSignal()}]: Non-modal dialog opened without an ` +
855
- '`aria-live` region near the trigger. Screen reader users will not ' +
856
- 'be notified that the dialog appeared. Add `aria-live="polite"` to a ' +
857
- 'sibling element that announces the dialog presence.');
858
- }
859
- }
860
- }
861
992
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialog, deps: [], target: i0.ɵɵFactoryTarget.Directive });
862
993
  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: [
863
994
  { provide: DIALOG_REF, useExisting: CngxDialog },
@@ -930,10 +1061,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
930
1061
  class CngxDialogClose {
931
1062
  dialogRef = inject(DIALOG_REF);
932
1063
  elRef = inject((ElementRef));
1064
+ labels = coerceSignal(injectDialogConfig().labels);
933
1065
  /** Value to pass to `close()`. When `undefined`, calls `dismiss()` instead. */
934
1066
  value = input(undefined, { ...(ngDevMode ? { debugName: "value" } : /* istanbul ignore next */ {}), alias: 'cngxDialogClose' });
935
1067
  /**
936
- * Explicit `aria-label` override.
1068
+ * Explicit `aria-label` override. Bind a dynamic accessible name here,
1069
+ * not through `[attr.aria-label]`: the directive owns the host's
1070
+ * `aria-label` binding, so a second binding on the same attribute races it.
1071
+ * A static `aria-label="..."` attribute on the host is kept as is.
937
1072
  *
938
1073
  * When not set, the directive auto-detects whether the host element
939
1074
  * has descriptive text content. If it does (e.g. "Cancel", "Confirm"),
@@ -941,11 +1076,17 @@ class CngxDialogClose {
941
1076
  * empty, or visually an icon, `aria-label` defaults to `"Close dialog"`.
942
1077
  */
943
1078
  label = input(undefined, { ...(ngDevMode ? { debugName: "label" } : /* istanbul ignore next */ {}), alias: 'cngxDialogCloseLabel' });
1079
+ // The value is read once at construction and written back through the host
1080
+ // binding: returning null would remove the consumer's attribute, and after
1081
+ // the first render the binding owns aria-label, so a recompute must not
1082
+ // mistake the directive's own value for a consumer-authored one.
1083
+ consumerAriaLabel = this.elRef.nativeElement.getAttribute('aria-label');
944
1084
  /** Set type="button" on <button> hosts to prevent form submit. */
945
1085
  hostType = this.elRef.nativeElement.tagName === 'BUTTON' ? 'button' : null;
946
1086
  /**
947
1087
  * Computed `aria-label`. Returns:
948
1088
  * - explicit `label()` input if set
1089
+ * - the consumer's static `aria-label` attribute, kept as is
949
1090
  * - `null` if host text is descriptive (> 1 char, not whitespace-only)
950
1091
  * - `'Close dialog'` for icon-only / single-char content
951
1092
  */
@@ -954,16 +1095,15 @@ class CngxDialogClose {
954
1095
  if (explicit !== undefined) {
955
1096
  return explicit || null;
956
1097
  }
957
- // If host already has aria-label attribute set by the consumer, don't override
958
- const el = this.elRef.nativeElement;
959
- if (el.hasAttribute('aria-label')) {
960
- return null;
1098
+ if (this.consumerAriaLabel !== null) {
1099
+ return this.consumerAriaLabel;
961
1100
  }
1101
+ const el = this.elRef.nativeElement;
962
1102
  const text = el.textContent?.trim() ?? '';
963
1103
  if (text.length > 1) {
964
1104
  return null;
965
1105
  }
966
- return 'Close dialog';
1106
+ return this.labels().close;
967
1107
  }, ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
968
1108
  handleClick() {
969
1109
  const v = this.value();
@@ -1267,19 +1407,32 @@ class CngxDialogOpener {
1267
1407
  { provide: CNGX_DIALOG_DATA, useValue: config.data ?? null },
1268
1408
  ],
1269
1409
  });
1270
- if (outletVcr) {
1271
- if (typeof content === 'function') {
1272
- contentRef = outletVcr.createComponent(content, {
1273
- injector: childInjector,
1274
- });
1275
- }
1276
- else {
1277
- outletVcr.createEmbeddedView(content, { $implicit: innerDialog }, { injector: childInjector });
1410
+ // Creating the content and its first render run consumer code. A throw
1411
+ // there must leave no outlet in the body and no ref in openDialogs, so
1412
+ // the ref is registered only after open() succeeded.
1413
+ try {
1414
+ if (outletVcr) {
1415
+ if (typeof content === 'function') {
1416
+ contentRef = outletVcr.createComponent(content, {
1417
+ injector: childInjector,
1418
+ });
1419
+ }
1420
+ else {
1421
+ outletVcr.createEmbeddedView(content, { $implicit: innerDialog }, { injector: childInjector });
1422
+ }
1278
1423
  }
1424
+ // The outlet's inputs reach the inner cngxDialog through template
1425
+ // bindings, and open() latches [modal]. Without this pass the dialog
1426
+ // would still see its input defaults and always open modal.
1427
+ outletRef.changeDetectorRef.detectChanges();
1428
+ dialogInstance.open();
1429
+ }
1430
+ catch (error) {
1431
+ this.discardOutlet(outletRef);
1432
+ throw error;
1279
1433
  }
1280
1434
  const dialogRef = new CngxDialogRef(innerDialog, outletRef, contentRef, this.injector);
1281
1435
  this.openDialogs.push(dialogRef);
1282
- dialogInstance.open();
1283
1436
  this.cleanupEffects.set(dialogRef, effect(() => {
1284
1437
  if (innerDialog.lifecycle() === 'closed' &&
1285
1438
  outletRef.hostView &&
@@ -1310,13 +1463,18 @@ class CngxDialogOpener {
1310
1463
  if (ref.componentRef && !ref.componentRef.hostView.destroyed) {
1311
1464
  ref.componentRef.destroy();
1312
1465
  }
1313
- const outletRef = ref._outletRef;
1314
- if (outletRef && !outletRef.hostView.destroyed) {
1315
- this.appRef.detachView(outletRef.hostView);
1316
- outletRef.location.nativeElement.remove();
1317
- outletRef.destroy();
1466
+ if (ref._outletRef) {
1467
+ this.discardOutlet(ref._outletRef);
1318
1468
  }
1319
1469
  }
1470
+ discardOutlet(outletRef) {
1471
+ if (outletRef.hostView.destroyed) {
1472
+ return;
1473
+ }
1474
+ this.appRef.detachView(outletRef.hostView);
1475
+ outletRef.location.nativeElement.remove();
1476
+ outletRef.destroy();
1477
+ }
1320
1478
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialogOpener, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1321
1479
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxDialogOpener });
1322
1480
  }
@@ -1461,6 +1619,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1461
1619
  class CngxDialogDraggable {
1462
1620
  elRef = inject(ElementRef);
1463
1621
  doc = inject(DOCUMENT);
1622
+ labels = coerceSignal(injectDialogConfig().labels);
1464
1623
  destroyRef = inject(DestroyRef);
1465
1624
  ariaRegistry = inject(CNGX_DIALOG_ARIA_REGISTRY, { optional: true });
1466
1625
  /** Handle element for initiating drag. If not set, entire dialog is the handle. */
@@ -1510,6 +1669,12 @@ class CngxDialogDraggable {
1510
1669
  // a signal write that must not become a tracked dependency.
1511
1670
  untracked(() => this.setupHandle(handleEl));
1512
1671
  });
1672
+ // A language switch relabels the promoted handle and the instruction in
1673
+ // place, without re-running the handle setup.
1674
+ effect(() => {
1675
+ const labels = this.labels();
1676
+ untracked(() => this.applyLabels(labels));
1677
+ });
1513
1678
  this.destroyRef.onDestroy(() => this.cleanup());
1514
1679
  }
1515
1680
  currentHandle = null;
@@ -1532,8 +1697,8 @@ class CngxDialogDraggable {
1532
1697
  // on the dialog element itself would clobber its accessible name (the
1533
1698
  // title) and its role text.
1534
1699
  if (!el.hasAttribute('aria-roledescription') && el !== this.elRef.nativeElement) {
1535
- el.setAttribute('aria-roledescription', 'draggable');
1536
- el.setAttribute('aria-label', 'Move dialog');
1700
+ el.setAttribute('aria-roledescription', this.labels().dragHandleRoleDescription);
1701
+ el.setAttribute('aria-label', this.labels().dragHandle);
1537
1702
  this.handleAddedAria = true;
1538
1703
  }
1539
1704
  // The keyboard path is live on every handle, so the instruction is too.
@@ -1671,6 +1836,16 @@ class CngxDialogDraggable {
1671
1836
  y: Math.round(y / grid) * grid,
1672
1837
  };
1673
1838
  }
1839
+ /** Re-apply the handle labels and the instruction text this directive owns. */
1840
+ applyLabels(labels) {
1841
+ if (this.currentHandle && this.handleAddedAria) {
1842
+ this.currentHandle.setAttribute('aria-roledescription', labels.dragHandleRoleDescription);
1843
+ this.currentHandle.setAttribute('aria-label', labels.dragHandle);
1844
+ }
1845
+ if (this.instructionNode) {
1846
+ this.instructionNode.textContent = labels.dragInstructions;
1847
+ }
1848
+ }
1674
1849
  instructionNode = null;
1675
1850
  releaseInstruction = null;
1676
1851
  handleAddedDescribedBy = false;
@@ -1683,7 +1858,7 @@ class CngxDialogDraggable {
1683
1858
  createInstructionNode() {
1684
1859
  const node = this.doc.createElement('span');
1685
1860
  node.id = nextUid('cngx-dialog-drag-hint');
1686
- node.textContent = 'Use arrow keys to move the dialog; Shift for larger steps';
1861
+ node.textContent = this.labels().dragInstructions;
1687
1862
  applySrOnly(node);
1688
1863
  this.elRef.nativeElement.appendChild(node);
1689
1864
  this.instructionNode = node;
@@ -1769,5 +1944,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1769
1944
  * Generated bundle index. Do not edit.
1770
1945
  */
1771
1946
 
1772
- export { CNGX_DIALOG_DATA, CngxBottomSheet, CngxDialog, CngxDialogClose, CngxDialogDescription, CngxDialogDraggable, CngxDialogOpener, CngxDialogRef, CngxDialogStack, CngxDialogTitle, DIALOG_REF, provideDialog, provideDialogStack };
1947
+ export { CNGX_DIALOG_DATA, CNGX_DIALOG_DEFAULTS, CNGX_DIALOG_LANGUAGE_EN, CngxBottomSheet, CngxDialog, CngxDialogClose, CngxDialogDescription, CngxDialogDraggable, CngxDialogOpener, CngxDialogRef, CngxDialogStack, CngxDialogTitle, DIALOG_REF, injectDialogConfig, provideDialog, provideDialogConfig, provideDialogConfigAt, provideDialogStack, withDialogLabels };
1773
1948
  //# sourceMappingURL=cngx-common-dialog.mjs.map