@cngx/common 0.1.0-rc.8 → 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 (52) hide show
  1. package/command/README.md +29 -0
  2. package/data/README.md +5 -2
  3. package/fesm2022/cngx-common-a11y.mjs +403 -84
  4. package/fesm2022/cngx-common-a11y.mjs.map +1 -1
  5. package/fesm2022/cngx-common-audio.mjs +16 -13
  6. package/fesm2022/cngx-common-audio.mjs.map +1 -1
  7. package/fesm2022/cngx-common-card.mjs +4 -3
  8. package/fesm2022/cngx-common-card.mjs.map +1 -1
  9. package/fesm2022/cngx-common-chart.mjs +55 -36
  10. package/fesm2022/cngx-common-chart.mjs.map +1 -1
  11. package/fesm2022/cngx-common-command.mjs +60 -6
  12. package/fesm2022/cngx-common-command.mjs.map +1 -1
  13. package/fesm2022/cngx-common-data.mjs +185 -37
  14. package/fesm2022/cngx-common-data.mjs.map +1 -1
  15. package/fesm2022/cngx-common-dialog.mjs +86 -48
  16. package/fesm2022/cngx-common-dialog.mjs.map +1 -1
  17. package/fesm2022/cngx-common-display.mjs +27 -23
  18. package/fesm2022/cngx-common-display.mjs.map +1 -1
  19. package/fesm2022/cngx-common-interactive.mjs +324 -122
  20. package/fesm2022/cngx-common-interactive.mjs.map +1 -1
  21. package/fesm2022/cngx-common-layout.mjs +129 -26
  22. package/fesm2022/cngx-common-layout.mjs.map +1 -1
  23. package/fesm2022/cngx-common-popover.mjs +947 -33
  24. package/fesm2022/cngx-common-popover.mjs.map +1 -1
  25. package/fesm2022/cngx-common-stepper.mjs +300 -166
  26. package/fesm2022/cngx-common-stepper.mjs.map +1 -1
  27. package/fesm2022/cngx-common-tabs.mjs +251 -80
  28. package/fesm2022/cngx-common-tabs.mjs.map +1 -1
  29. package/fesm2022/cngx-common-timeline.mjs +16 -10
  30. package/fesm2022/cngx-common-timeline.mjs.map +1 -1
  31. package/fesm2022/cngx-common.mjs +1 -1
  32. package/layout/README.md +16 -0
  33. package/package.json +20 -7
  34. package/popover/README.md +40 -0
  35. package/schematics/collection.json +9 -0
  36. package/schematics/ng-add/index.js +9 -0
  37. package/schematics/ng-add/schema.json +91 -0
  38. package/schematics/package.json +3 -0
  39. package/stepper/README.md +5 -4
  40. package/theming/components/cngx-popover-sheet.css +402 -0
  41. package/theming/components/cngx-popover.css +10 -6
  42. package/types/cngx-common-a11y.d.ts +167 -14
  43. package/types/cngx-common-chart.d.ts +8 -7
  44. package/types/cngx-common-command.d.ts +19 -2
  45. package/types/cngx-common-data.d.ts +164 -26
  46. package/types/cngx-common-dialog.d.ts +3 -7
  47. package/types/cngx-common-interactive.d.ts +52 -17
  48. package/types/cngx-common-layout.d.ts +37 -5
  49. package/types/cngx-common-popover.d.ts +353 -13
  50. package/types/cngx-common-stepper.d.ts +168 -129
  51. package/types/cngx-common-tabs.d.ts +149 -30
  52. package/types/cngx-common-timeline.d.ts +27 -7
@@ -1,13 +1,16 @@
1
1
  import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { InjectionToken, isDevMode, inject, ElementRef, DestroyRef, Injector, input, signal, computed, effect, untracked, Directive, Renderer2, TemplateRef, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component, viewChild, afterNextRender } from '@angular/core';
3
+ import { InjectionToken, inject, ElementRef, DestroyRef, Injector, computed, input, signal, effect, untracked, Directive, Renderer2, output, afterNextRender, TemplateRef, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component, viewChild } from '@angular/core';
4
4
  import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
5
  import { fromEvent } from 'rxjs';
6
6
  import { injectDirection } from '@cngx/core';
7
- import { nextUid, createSlotRegistry, hasTransition, onTransitionDone, createOverrideMerge } from '@cngx/core/utils';
7
+ import { nextUid, createSlotRegistry, hasTransition, onTransitionDone, createKeyedRegistry, createTransitionTracker, createOverrideMerge } from '@cngx/core/utils';
8
+ import { cngxDevWarn, CngxRuntimeError } from '@cngx/utils';
8
9
  import * as i1 from '@cngx/common/a11y';
9
- import { CngxReducedMotion } from '@cngx/common/a11y';
10
- import { CngxCloseButton, CngxPending, CngxSucceeded, CngxFailed, CngxAsyncClick } from '@cngx/common/interactive';
10
+ import { CngxReducedMotion, CngxFocusTrap, CngxLiveAnnouncer, injectScopedLiveRegion, CNGX_FOCUS_TRAP_DRIVER } from '@cngx/common/a11y';
11
+ import { createContainerSize, createPinnedScrollLock } from '@cngx/common/layout';
12
+ import { injectWindow } from '@cngx/core/tokens';
13
+ import { CngxSwipeDismiss, CngxCloseButton, CngxPending, CngxSucceeded, CngxFailed, CngxAsyncClick } from '@cngx/common/interactive';
11
14
  import { createLanguageSection } from '@cngx/core/i18n';
12
15
  import * as i1$1 from '@cngx/common/display';
13
16
  import { CngxDivider } from '@cngx/common/display';
@@ -207,6 +210,9 @@ function resolveFloatingPlacement(placement, direction) {
207
210
  */
208
211
  const CNGX_POPOVER_ARROW_BOUNDS = new InjectionToken('CngxPopoverArrowBounds');
209
212
 
213
+ /** @internal Resolved by `CngxPopover` on its own element only (`self: true`). */
214
+ const CNGX_POPOVER_PRESENTATION = new InjectionToken('CngxPopoverPresentation');
215
+
210
216
  /**
211
217
  * Injection token for the Floating UI fallback.
212
218
  * `null` when not provided - CSS Anchor Positioning is used instead.
@@ -424,15 +430,26 @@ function installGlobalOutsideClickListener(doc) {
424
430
  }
425
431
  /** @internal Tracks which Documents have already warned about missing Popover API. */
426
432
  const popoverApiWarnedDocs = new WeakSet();
427
- /** @internal */
428
- function warnMissingPopoverApi(el) {
433
+ /**
434
+ * @internal - test hook. Resets the per-Document warning suppression so
435
+ * specs can exercise the warning path against a shared jsdom Document.
436
+ * Do not call from production code.
437
+ */
438
+ function __resetPopoverApiWarnings(doc) {
439
+ popoverApiWarnedDocs.delete(doc);
440
+ }
441
+ /** @internal Shared with `CngxTooltip`, which opens its own popover element. */
442
+ function warnMissingPopoverApi(el, owner) {
443
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
444
+ return;
445
+ }
429
446
  const doc = el.ownerDocument;
430
- if (popoverApiWarnedDocs.has(doc) || !isDevMode()) {
447
+ if (popoverApiWarnedDocs.has(doc)) {
431
448
  return;
432
449
  }
433
450
  if (typeof el.showPopover !== 'function') {
434
451
  popoverApiWarnedDocs.add(doc);
435
- console.warn('CngxPopover: The native Popover API is not supported in this browser. ' +
452
+ cngxDevWarn('CNGX1036', `[${owner}] the native Popover API is not supported in this browser. ` +
436
453
  'Install @oddbird/popover-polyfill and import it in your polyfills:\n\n' +
437
454
  ' npm install @oddbird/popover-polyfill\n' +
438
455
  ' // polyfills.ts\n' +
@@ -451,11 +468,14 @@ function __resetFloatingMiddlewareWarnings(doc) {
451
468
  }
452
469
  /** @internal */
453
470
  function warnMissingFloatingMiddleware(doc) {
454
- if (floatingMiddlewareWarnedDocs.has(doc) || !isDevMode()) {
471
+ if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
472
+ return;
473
+ }
474
+ if (floatingMiddlewareWarnedDocs.has(doc)) {
455
475
  return;
456
476
  }
457
477
  floatingMiddlewareWarnedDocs.add(doc);
458
- console.warn('CngxPopover: provideFloatingFallback(computePosition) was registered without middleware. ' +
478
+ cngxDevWarn('CNGX1037', '[cngxPopover] provideFloatingFallback(computePosition) was registered without middleware. ' +
459
479
  'Popovers in browsers without CSS Anchor Positioning will clip against the viewport edge ' +
460
480
  'because no flip/shift recovery is configured. Pass middleware on registration:\n\n' +
461
481
  " import { computePosition, flip, shift } from '@floating-ui/dom';\n\n" +
@@ -553,6 +573,31 @@ class CngxPopover {
553
573
  }
554
574
  return this._arrowBounds;
555
575
  }
576
+ /**
577
+ * Presentation seam resolved lazily on first use, same reason as
578
+ * {@link getArrowBounds}: the modifier providing it constructs after this
579
+ * directive. `self: true` keeps a popover nested inside a sheet's host from
580
+ * picking up the outer sheet's seam.
581
+ */
582
+ _presentationSeam = undefined;
583
+ presentationSeam() {
584
+ if (this._presentationSeam === undefined) {
585
+ this._presentationSeam = this._injector.get(CNGX_POPOVER_PRESENTATION, null, {
586
+ self: true,
587
+ });
588
+ }
589
+ return this._presentationSeam;
590
+ }
591
+ /**
592
+ * `false` while a presentation modifier lays the panel out as a sheet or
593
+ * fullscreen. Gates every anchor, margin, fallback and floating write:
594
+ * inline styles beat author CSS, so the sheet stylesheet cannot win
595
+ * against them.
596
+ */
597
+ anchored = computed(() => (this.presentationSeam()?.presentation() ?? 'anchored') === 'anchored', ...(ngDevMode ? [{ debugName: "anchored" }] : /* istanbul ignore next */ []));
598
+ // Re-entrancy guard for hide(): a hide() / toggle() from inside the
599
+ // seam's onHide() must not start a second close.
600
+ hiding = false;
556
601
  /** Anchor-relative placement. */
557
602
  placement = input('bottom', ...(ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []));
558
603
  /**
@@ -717,7 +762,7 @@ class CngxPopover {
717
762
  * `cngxPopoverArrow` template use this to render their own glyph at
718
763
  * the same coordinate the default arrow ornament would.
719
764
  */
720
- arrowOffset = this._arrowOffset.asReadonly();
765
+ arrowOffset = computed(() => (this.anchored() ? this._arrowOffset() : null), ...(ngDevMode ? [{ debugName: "arrowOffset" }] : /* istanbul ignore next */ []));
721
766
  /** Backing state for {@link haspopup}. */
722
767
  haspopupState = signal(undefined, ...(ngDevMode ? [{ debugName: "haspopupState" }] : /* istanbul ignore next */ []));
723
768
  /**
@@ -727,12 +772,15 @@ class CngxPopover {
727
772
  * the consumer having to set `haspopup` on every trigger element.
728
773
  * Consumer-supplied `haspopup` on the trigger still wins.
729
774
  */
730
- haspopup = this.haspopupState.asReadonly();
775
+ haspopup = computed(() =>
776
+ // A sheet or fullscreen presentation is a modal dialog, whatever a
777
+ // composer installed for the anchored layout.
778
+ this.anchored() ? this.haspopupState() : 'dialog', ...(ngDevMode ? [{ debugName: "haspopup" }] : /* istanbul ignore next */ []));
731
779
  isOpening = computed(() => this.stateSignal() === 'opening', ...(ngDevMode ? [{ debugName: "isOpening" }] : /* istanbul ignore next */ []));
732
780
  isOpen = computed(() => this.stateSignal() === 'open', ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
733
781
  isClosing = computed(() => this.stateSignal() === 'closing', ...(ngDevMode ? [{ debugName: "isClosing" }] : /* istanbul ignore next */ []));
734
782
  isVisible = computed(() => this.stateSignal() !== 'closed', ...(ngDevMode ? [{ debugName: "isVisible" }] : /* istanbul ignore next */ []));
735
- cssAnchorRef = computed(() => SUPPORTS_ANCHOR ? `--cngx-pop-${this.idSignal()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorRef" }] : /* istanbul ignore next */ []));
783
+ cssAnchorRef = computed(() => SUPPORTS_ANCHOR && this.anchored() ? `--cngx-pop-${this.idSignal()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorRef" }] : /* istanbul ignore next */ []));
736
784
  /**
737
785
  * Primary edge of the placement, written from the live trigger and panel
738
786
  * rects so the arrow lands on the side that actually faces the trigger.
@@ -749,8 +797,11 @@ class CngxPopover {
749
797
  * so consumers projecting a `cngxPopoverArrow` template can rotate
750
798
  * their own glyph to match the rendered placement.
751
799
  */
752
- resolvedEdge = computed(() => this.resolvedEdgeSignal() ?? this.effectivePlacement().split('-')[0], ...(ngDevMode ? [{ debugName: "resolvedEdge" }] : /* istanbul ignore next */ []));
753
- cssMargin = computed(() => SUPPORTS_ANCHOR ? resolveAnchorMargin(this.effectivePlacement(), this.offset()) : null, ...(ngDevMode ? [{ debugName: "cssMargin" }] : /* istanbul ignore next */ []));
800
+ resolvedEdge = computed(() => (this.anchored() ? this.resolvedEdgeSignal() : null) ??
801
+ this.effectivePlacement().split('-')[0], ...(ngDevMode ? [{ debugName: "resolvedEdge" }] : /* istanbul ignore next */ []));
802
+ cssMargin = computed(() => SUPPORTS_ANCHOR && this.anchored()
803
+ ? resolveAnchorMargin(this.effectivePlacement(), this.offset())
804
+ : null, ...(ngDevMode ? [{ debugName: "cssMargin" }] : /* istanbul ignore next */ []));
754
805
  /**
755
806
  * Comma-joined `position-try-fallbacks` value, or `null` to skip the
756
807
  * style write. Bound via host binding so empty / cleared lists drop the
@@ -758,6 +809,9 @@ class CngxPopover {
758
809
  * gating on `SUPPORTS_ANCHOR` would only suppress a harmless write.
759
810
  */
760
811
  cssPositionTryFallbacks = computed(() => {
812
+ if (!this.anchored()) {
813
+ return null;
814
+ }
761
815
  const list = this.effectivePositionTryFallbacks();
762
816
  return list.length > 0 ? list.join(', ') : null;
763
817
  }, ...(ngDevMode ? [{ debugName: "cssPositionTryFallbacks" }] : /* istanbul ignore next */ []));
@@ -765,9 +819,38 @@ class CngxPopover {
765
819
  // Host binding needs a static property name; position-area/inset-area name flips per browser.
766
820
  if (SUPPORTS_ANCHOR) {
767
821
  effect(() => {
768
- this.elRef.nativeElement.style.setProperty(ANCHOR_AREA_PROPERTY, POSITION_AREA[this.effectivePlacement()]);
822
+ const style = this.elRef.nativeElement.style;
823
+ if (!this.anchored()) {
824
+ style.removeProperty(ANCHOR_AREA_PROPERTY);
825
+ return;
826
+ }
827
+ style.setProperty(ANCHOR_AREA_PROPERTY, POSITION_AREA[this.effectivePlacement()]);
769
828
  });
770
829
  }
830
+ // A presentation flip while open: leaving the anchored layout stops the
831
+ // floating engine (the arrow geometry is gated in its computeds); coming
832
+ // back re-positions right away instead of waiting for the next scroll or
833
+ // resize.
834
+ effect(() => {
835
+ const anchored = this.anchored();
836
+ untracked(() => {
837
+ if (this.stateSignal() === 'closed') {
838
+ return;
839
+ }
840
+ if (!anchored) {
841
+ this.floatingPositioner?.stop();
842
+ this.clearFloatingPosition();
843
+ return;
844
+ }
845
+ this.applyFloatingPosition();
846
+ this.cancelArrowFrame();
847
+ this.arrowFrame = requestAnimationFrame(() => {
848
+ this.arrowFrame = null;
849
+ this.updateArrowOffset();
850
+ });
851
+ });
852
+ });
853
+ this.destroyRef.onDestroy(() => this.cancelArrowFrame());
771
854
  effect(() => {
772
855
  const desired = this.controlledOpen();
773
856
  if (desired === undefined) {
@@ -804,10 +887,18 @@ class CngxPopover {
804
887
  }
805
888
  /** Open the popover. No-op if not `closed`. */
806
889
  show() {
807
- warnMissingPopoverApi(this.elRef.nativeElement);
890
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
891
+ warnMissingPopoverApi(this.elRef.nativeElement, 'cngxPopover');
892
+ }
808
893
  if (this.stateSignal() !== 'closed') {
809
894
  return;
810
895
  }
896
+ // Without the native Popover API (no polyfill) the open cannot happen.
897
+ // Bail before any state change, so the popover stays closed and can open
898
+ // once a polyfill lands instead of latching in 'opening'.
899
+ if (typeof this.elRef.nativeElement.showPopover !== 'function') {
900
+ return;
901
+ }
811
902
  // Snapshot the pre-open focus target before showPopover() runs -
812
903
  // autofocus content inside the panel lands right after that call,
813
904
  // and a post-CD capture (the trigger's effect) would store the
@@ -825,7 +916,15 @@ class CngxPopover {
825
916
  }
826
917
  openPopovers.add(this);
827
918
  this.stateSignal.set('opening');
919
+ if (!this.anchored()) {
920
+ this.clearFloatingPosition();
921
+ }
828
922
  this.elRef.nativeElement.showPopover();
923
+ // The host binding writes aria-hidden on the next change detection; the
924
+ // seam may move focus into the panel right now, which must not land
925
+ // under a stale aria-hidden="true".
926
+ this.elRef.nativeElement.setAttribute('aria-hidden', 'false');
927
+ this.presentationSeam()?.onShown();
829
928
  installGlobalEscapeListener(this.doc);
830
929
  installGlobalOutsideClickListener(this.doc);
831
930
  this.applyFloatingPosition();
@@ -846,7 +945,17 @@ class CngxPopover {
846
945
  if (this.stateSignal() === 'closed' || this.stateSignal() === 'closing') {
847
946
  return;
848
947
  }
849
- this.startClosing();
948
+ if (this.hiding) {
949
+ return;
950
+ }
951
+ this.hiding = true;
952
+ try {
953
+ this.presentationSeam()?.onHide();
954
+ this.startClosing();
955
+ }
956
+ finally {
957
+ this.hiding = false;
958
+ }
850
959
  }
851
960
  /** Toggle between open and closed. */
852
961
  toggle() {
@@ -938,7 +1047,9 @@ class CngxPopover {
938
1047
  * `CngxPopoverAnchor` holds the popover).
939
1048
  */
940
1049
  closeIfOutsidePointerDown(target) {
941
- if (!this.closeOnOutsideClick()) {
1050
+ // Outside a sheet the presentation modifier owns the tap and routes it
1051
+ // through its close request; hiding here would bypass that policy.
1052
+ if (!this.closeOnOutsideClick() || !this.anchored()) {
942
1053
  return;
943
1054
  }
944
1055
  const node = target;
@@ -961,7 +1072,9 @@ class CngxPopover {
961
1072
  getElement: () => this.popoverElement,
962
1073
  getPlacement: () => FLOATING_PLACEMENT[this.floatingPlacement()],
963
1074
  getOffset: () => this.offset(),
964
- isOpen: () => this.stateSignal() !== 'closed',
1075
+ // A position request in flight when the panel leaves the anchored
1076
+ // layout must not land on the sheet.
1077
+ isOpen: () => this.stateSignal() !== 'closed' && this.anchored(),
965
1078
  onPositioned: () => this.updateArrowOffset(),
966
1079
  })
967
1080
  : null;
@@ -970,13 +1083,15 @@ class CngxPopover {
970
1083
  * and the consumer has provided the fallback via `provideFloatingFallback()`.
971
1084
  */
972
1085
  applyFloatingPosition() {
973
- if (SUPPORTS_ANCHOR || !this.floatingPositioner) {
1086
+ if (SUPPORTS_ANCHOR || !this.floatingPositioner || !this.anchored()) {
974
1087
  return;
975
1088
  }
976
1089
  if (!this.anchorElement()) {
977
1090
  return;
978
1091
  }
979
- if ((this.floatingFallback?.middleware ?? []).length === 0) {
1092
+ if (typeof ngDevMode !== 'undefined' &&
1093
+ ngDevMode &&
1094
+ (this.floatingFallback?.middleware ?? []).length === 0) {
980
1095
  warnMissingFloatingMiddleware(this.popoverElement.ownerDocument);
981
1096
  }
982
1097
  this.floatingPositioner.start();
@@ -989,6 +1104,9 @@ class CngxPopover {
989
1104
  * anchor sits outside the panel's inline extent.
990
1105
  */
991
1106
  updateArrowOffset() {
1107
+ if (!this.anchored()) {
1108
+ return;
1109
+ }
992
1110
  const anchor = this.anchorElement();
993
1111
  if (!anchor) {
994
1112
  this._arrowOffset.set(null);
@@ -1016,6 +1134,22 @@ class CngxPopover {
1016
1134
  const clamped = Math.max(radius, Math.min(raw, panelDim - radius));
1017
1135
  this._arrowOffset.set(`${clamped}px`);
1018
1136
  }
1137
+ arrowFrame = null;
1138
+ // The floating fallback writes inline left/top, which beat any stylesheet;
1139
+ // a sheet opened after an anchored open must not inherit them.
1140
+ clearFloatingPosition() {
1141
+ if (!this.floatingPositioner) {
1142
+ return;
1143
+ }
1144
+ this.popoverElement.style.removeProperty('left');
1145
+ this.popoverElement.style.removeProperty('top');
1146
+ }
1147
+ cancelArrowFrame() {
1148
+ if (this.arrowFrame !== null) {
1149
+ cancelAnimationFrame(this.arrowFrame);
1150
+ this.arrowFrame = null;
1151
+ }
1152
+ }
1019
1153
  get popoverElement() {
1020
1154
  return this.elRef.nativeElement;
1021
1155
  }
@@ -1151,6 +1285,13 @@ class CngxPopoverTrigger {
1151
1285
  * `CngxPopoverPanel`'s `'dialog'` default.
1152
1286
  */
1153
1287
  haspopupInput = input(undefined, { ...(ngDevMode ? { debugName: "haspopupInput" } : /* istanbul ignore next */ {}), alias: 'haspopup' });
1288
+ /**
1289
+ * ARIA controls override. When set, `aria-controls` names this id instead
1290
+ * of the popover element - correct when the popup role sits on an element
1291
+ * inside the popover (a `role="listbox"` or `role="tree"` panel). `null`
1292
+ * or unset falls back to `popoverRef().id()`.
1293
+ */
1294
+ controlsInput = input(undefined, { ...(ngDevMode ? { debugName: "controlsInput" } : /* istanbul ignore next */ {}), alias: 'controls' });
1154
1295
  /**
1155
1296
  * When `true`, remembers the popover's pre-open focus target (the
1156
1297
  * popover snapshots `document.activeElement` synchronously inside
@@ -1171,6 +1312,8 @@ class CngxPopoverTrigger {
1171
1312
  const resolved = this.haspopupInput() ?? this.popoverRef().haspopup() ?? 'true';
1172
1313
  return resolved === 'none' ? null : resolved;
1173
1314
  }, ...(ngDevMode ? [{ debugName: "haspopup" }] : /* istanbul ignore next */ []));
1315
+ /** Resolved `aria-controls`: the consumer override, else the popover id. */
1316
+ controls = computed(() => this.controlsInput() ?? this.popoverRef().id(), ...(ngDevMode ? [{ debugName: "controls" }] : /* istanbul ignore next */ []));
1174
1317
  /**
1175
1318
  * CSS anchor name, yielded (`null`) while a `CngxPopoverAnchor` holds
1176
1319
  * the popover's explicit anchor slot.
@@ -1214,7 +1357,7 @@ class CngxPopoverTrigger {
1214
1357
  });
1215
1358
  }
1216
1359
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1217
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxPopoverTrigger, isStandalone: true, selector: "[cngxPopoverTrigger]", inputs: { popoverRef: { classPropertyName: "popoverRef", publicName: "cngxPopoverTrigger", isSignal: true, isRequired: true, transformFunction: null }, haspopupInput: { classPropertyName: "haspopupInput", publicName: "haspopup", isSignal: true, isRequired: false, transformFunction: null }, restoreFocus: { classPropertyName: "restoreFocus", publicName: "restoreFocus", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-expanded": "popoverRef().isVisible()", "attr.aria-controls": "popoverRef().id()", "attr.aria-haspopup": "haspopup()", "style.anchor-name": "cssAnchorName()" } }, exportAs: ["cngxPopoverTrigger"], ngImport: i0 });
1360
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxPopoverTrigger, isStandalone: true, selector: "[cngxPopoverTrigger]", inputs: { popoverRef: { classPropertyName: "popoverRef", publicName: "cngxPopoverTrigger", isSignal: true, isRequired: true, transformFunction: null }, haspopupInput: { classPropertyName: "haspopupInput", publicName: "haspopup", isSignal: true, isRequired: false, transformFunction: null }, controlsInput: { classPropertyName: "controlsInput", publicName: "controls", isSignal: true, isRequired: false, transformFunction: null }, restoreFocus: { classPropertyName: "restoreFocus", publicName: "restoreFocus", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-expanded": "popoverRef().isVisible()", "attr.aria-controls": "controls()", "attr.aria-haspopup": "haspopup()", "style.anchor-name": "cssAnchorName()" } }, exportAs: ["cngxPopoverTrigger"], ngImport: i0 });
1218
1361
  }
1219
1362
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverTrigger, decorators: [{
1220
1363
  type: Directive,
@@ -1224,12 +1367,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1224
1367
  standalone: true,
1225
1368
  host: {
1226
1369
  '[attr.aria-expanded]': 'popoverRef().isVisible()',
1227
- '[attr.aria-controls]': 'popoverRef().id()',
1370
+ '[attr.aria-controls]': 'controls()',
1228
1371
  '[attr.aria-haspopup]': 'haspopup()',
1229
1372
  '[style.anchor-name]': 'cssAnchorName()',
1230
1373
  },
1231
1374
  }]
1232
- }], ctorParameters: () => [], propDecorators: { popoverRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverTrigger", required: true }] }], haspopupInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "haspopup", required: false }] }], restoreFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreFocus", required: false }] }] } });
1375
+ }], ctorParameters: () => [], propDecorators: { popoverRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverTrigger", required: true }] }], haspopupInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "haspopup", required: false }] }], controlsInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "controls", required: false }] }], restoreFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreFocus", required: false }] }] } });
1233
1376
 
1234
1377
  /**
1235
1378
  * Geometry anchor atom: positions a `CngxPopover` against its host
@@ -1444,9 +1587,17 @@ class CngxTooltip {
1444
1587
  }
1445
1588
  /** Show the tooltip immediately (bypassing delay). */
1446
1589
  show() {
1590
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
1591
+ warnMissingPopoverApi(this.tooltipEl, 'cngxTooltip');
1592
+ }
1447
1593
  if (!this.enabled() || this.stateSignal() !== 'closed') {
1448
1594
  return;
1449
1595
  }
1596
+ // Without the Popover API the open cannot happen; stay closed instead of
1597
+ // latching in 'opening', so the tooltip opens once a polyfill lands.
1598
+ if (typeof this.tooltipEl.showPopover !== 'function') {
1599
+ return;
1600
+ }
1450
1601
  this.stateSignal.set('opening');
1451
1602
  // The element ships aria-hidden while closed; an open tooltip must be
1452
1603
  // exposed - it is the live target of the trigger's aria-describedby.
@@ -1616,6 +1767,751 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
1616
1767
  }]
1617
1768
  }], ctorParameters: () => [], propDecorators: { text: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxTooltip", required: true }] }], placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPlacement", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipOffset", required: false }] }], openDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipDelay", required: false }] }], closeDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeDelay", required: false }] }], enabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "enabled", required: false }] }], triggers: [{ type: i0.Input, args: [{ isSignal: true, alias: "triggers", required: false }] }], positionTryFallbacks: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltipPositionTryFallbacks", required: false }] }] } });
1618
1769
 
1770
+ const BREAKPOINT_PROPERTY = '--cngx-popover-sheet-breakpoint';
1771
+ /**
1772
+ * @internal The `--cngx-popover-sheet-breakpoint` value `cngx-popover-sheet.css`
1773
+ * writes on the root: `'1'` on coarse, narrow viewports, `'0'` otherwise, `''`
1774
+ * before the first resize entry or without the stylesheet. One observer per
1775
+ * application, shared by every sheet.
1776
+ */
1777
+ const CNGX_POPOVER_SHEET_BREAKPOINT = new InjectionToken('CngxPopoverSheetBreakpoint', {
1778
+ providedIn: 'root',
1779
+ factory: () => createContainerSize(inject(DOCUMENT).documentElement, inject(DestroyRef), injectWindow()).property(BREAKPOINT_PROPERTY),
1780
+ });
1781
+
1782
+ /** @internal Provided by `CngxPopoverSheet` for its parts. */
1783
+ const CNGX_POPOVER_SHEET_HOST = new InjectionToken('CngxPopoverSheetHost');
1784
+ /**
1785
+ * @internal The sheet a part belongs to. A part outside a sheet would render
1786
+ * nothing useful (an unnamed dialog, a dead swipe), so it throws instead.
1787
+ */
1788
+ function injectPopoverSheetHost(part) {
1789
+ const host = inject(CNGX_POPOVER_SHEET_HOST, { optional: true });
1790
+ if (!host) {
1791
+ throw new CngxRuntimeError('CNGX1066', typeof ngDevMode !== 'undefined' &&
1792
+ ngDevMode &&
1793
+ `[${part}] must be placed inside an element with [cngxPopoverSheet].`);
1794
+ }
1795
+ return host;
1796
+ }
1797
+
1798
+ const SETTLING_ATTRIBUTE = 'data-cngx-sheet-settling';
1799
+ const SETTLING_FRAME_CAP = 4;
1800
+ const LIVE_REGION_SELECTOR = '[aria-live], [role="status"], [role="alert"], [role="log"]';
1801
+ const FOCUS_TRAP_ANCHOR_CLASS = 'cdk-focus-trap-anchor';
1802
+ // Longer than a tap's pointerdown-to-click gap, shorter than a second tap.
1803
+ const CLICK_SWALLOW_MS = 600;
1804
+ // Engaged modal sheets, oldest first. Only the topmost answers an outside
1805
+ // tap: a tap on a later sheet is outside an earlier one that is not its
1806
+ // DOM ancestor, and must not close both.
1807
+ const engagedSheets = [];
1808
+ // How many engaged sheets want each element inert. Several sheets can be
1809
+ // open at once (`[exclusive]="false"`), so an element stays inert until the
1810
+ // last sheet that claimed it lets go, and one sheet's release never makes
1811
+ // the page live under another. Elements inert before any sheet are never
1812
+ // claimed and never touched.
1813
+ const inertClaims = new WeakMap();
1814
+ // The sheet is a presentation of the popover on its own element; without
1815
+ // one there is nothing to present.
1816
+ function injectSheetPopover() {
1817
+ const popover = inject(CngxPopover, { self: true, optional: true });
1818
+ if (!popover) {
1819
+ throw new CngxRuntimeError('CNGX1067', typeof ngDevMode !== 'undefined' &&
1820
+ ngDevMode &&
1821
+ '[cngxPopoverSheet] must be placed on an element with [cngxPopover].');
1822
+ }
1823
+ return popover;
1824
+ }
1825
+ /**
1826
+ * Turns a `CngxPopover` into a modal bottom sheet or fullscreen panel on
1827
+ * coarse, narrow viewports, and leaves it anchored everywhere else.
1828
+ *
1829
+ * Place it on the `[cngxPopover]` element. With the default `'auto'` request,
1830
+ * the breakpoint written once in `cngx-popover-sheet.css`
1831
+ * (`(pointer: coarse) and (max-width: 48rem)`) picks between the anchored
1832
+ * panel and `autoPresentation` (`'sheet'` or `'fullscreen'`). Pass a fixed
1833
+ * presentation to override it.
1834
+ *
1835
+ * Both non-anchored presentations are modal: the host becomes
1836
+ * `role="dialog"` + `aria-modal="true"`, named by its
1837
+ * `CngxPopoverSheetTitle`; focus moves into the panel inside `show()`, onto
1838
+ * the first enabled `CngxPopoverSheetInitialFocus` (a marked search input
1839
+ * focused there keeps the iOS keyboard of a tap open), Tab is trapped, every page
1840
+ * sibling is `inert`, the page is pinned, and announcements go through
1841
+ * {@link announce} into a live region inside the panel, the only region
1842
+ * VoiceOver speaks under `aria-modal`. On close the page is live again and
1843
+ * focus is back on the opener before the close transition starts.
1844
+ *
1845
+ * The sheet never closes itself. Header swipes, outside taps and the Android
1846
+ * back gesture arrive as `closeRequested` with a reason; the popover hides
1847
+ * unless `closeOnRequest` is `false`, which lets a consumer apply its own
1848
+ * dismiss policy. Escape stays with `CngxPopover`'s `closeOnEscape`.
1849
+ *
1850
+ * Requires `mode="manual"` on the popover (the default): native light dismiss
1851
+ * would bypass `closeRequested`.
1852
+ *
1853
+ * ```html
1854
+ * <button type="button" (click)="pop.show()">Choose city</button>
1855
+ * <div cngxPopover #pop="cngxPopover" cngxPopoverSheet #sheet="cngxPopoverSheet">
1856
+ * <header cngxPopoverSheetHeader cngxSwipeDismiss="down">
1857
+ * <span cngxPopoverSheetHandle></span>
1858
+ * <h2 cngxPopoverSheetTitle>City</h2>
1859
+ * <button type="button" (click)="sheet.requestClose('close')">Close</button>
1860
+ * </header>
1861
+ * <ul>...</ul>
1862
+ * </div>
1863
+ * ```
1864
+ *
1865
+ * @category common/popover
1866
+ * @docsKind primary
1867
+ * @wcag AA
1868
+ * @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-sheet.directive.ts
1869
+ * @since 0.1.0
1870
+ * @relatedTo CngxPopover, CngxSwipeDismiss, CngxFocusTrap, createPinnedScrollLock, injectScopedLiveRegion
1871
+ * <example-url>http://localhost:4200/#/common/popover/sheet/bottom-sheet</example-url>
1872
+ * <example-url>http://localhost:4200/#/common/popover/sheet/fullscreen-search</example-url>
1873
+ */
1874
+ class CngxPopoverSheet {
1875
+ popover = injectSheetPopover();
1876
+ trap = inject(CngxFocusTrap, { self: true });
1877
+ announcer = inject(CngxLiveAnnouncer);
1878
+ doc = inject(DOCUMENT);
1879
+ injector = inject(Injector);
1880
+ win = injectWindow();
1881
+ host = inject(ElementRef).nativeElement;
1882
+ // Static attributes the consumer wrote are what the anchored presentation
1883
+ // keeps; the bindings below only take over while the sheet is modal.
1884
+ staticRole = this.host.getAttribute('role');
1885
+ staticLabelledBy = this.host.getAttribute('aria-labelledby');
1886
+ staticTabindex = this.host.getAttribute('tabindex');
1887
+ /**
1888
+ * Requested presentation. `'auto'` (default, also the bare attribute)
1889
+ * resolves through the stylesheet breakpoint.
1890
+ */
1891
+ request = input('auto', { ...(ngDevMode ? { debugName: "request" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverSheet', transform: (v) => (v === '' ? 'auto' : v) });
1892
+ /**
1893
+ * What `'auto'` resolves to below the breakpoint: a content-sized `'sheet'`
1894
+ * or a `'fullscreen'` panel (for panels led by a text input).
1895
+ */
1896
+ autoPresentation = input('sheet', ...(ngDevMode ? [{ debugName: "autoPresentation" }] : /* istanbul ignore next */ []));
1897
+ /** Id of the element naming the dialog. Wins over a registered `CngxPopoverSheetTitle`. */
1898
+ labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
1899
+ /**
1900
+ * Whether the sheet returns focus on close (to `restoreTarget`, else to the
1901
+ * element focused before it opened). Turn it off when a `closing` handler
1902
+ * moves focus itself.
1903
+ */
1904
+ restoreFocus = input(true, ...(ngDevMode ? [{ debugName: "restoreFocus" }] : /* istanbul ignore next */ []));
1905
+ /** Element to return focus to on close. Defaults to the element focused before open. */
1906
+ restoreTarget = input(undefined, ...(ngDevMode ? [{ debugName: "restoreTarget" }] : /* istanbul ignore next */ []));
1907
+ /**
1908
+ * Whether a close request hides the popover. `false` only emits
1909
+ * `closeRequested`, so the consumer decides.
1910
+ */
1911
+ closeOnRequest = input(true, ...(ngDevMode ? [{ debugName: "closeOnRequest" }] : /* istanbul ignore next */ []));
1912
+ /** A swipe, outside tap, back gesture or close control asked the sheet to close. */
1913
+ closeRequested = output();
1914
+ /**
1915
+ * Emits synchronously inside `hide()` while the page is already live again,
1916
+ * before the close transition. The place to move focus out of the panel.
1917
+ * Fires only for a modal close.
1918
+ */
1919
+ closing = output();
1920
+ breakpoint = inject(CNGX_POPOVER_SHEET_BREAKPOINT);
1921
+ /** Resolved presentation, reflected as `data-cngx-presentation`. */
1922
+ presentation = computed(() => {
1923
+ const request = this.request();
1924
+ if (request !== 'auto') {
1925
+ return request;
1926
+ }
1927
+ return this.breakpoint() === '1' ? this.autoPresentation() : 'anchored';
1928
+ }, ...(ngDevMode ? [{ debugName: "presentation" }] : /* istanbul ignore next */ []));
1929
+ /** `true` in the sheet and fullscreen presentations. */
1930
+ modal = computed(() => this.presentation() !== 'anchored', ...(ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []));
1931
+ /** @internal Drives the composed `CngxFocusTrap`: Tab stays inside while modal and visible. */
1932
+ focusTrapEnabled = computed(() => this.modal() && this.popover.isVisible(), ...(ngDevMode ? [{ debugName: "focusTrapEnabled" }] : /* istanbul ignore next */ []));
1933
+ /** @internal The sheet moves focus itself, inside `show()`. */
1934
+ focusTrapAutoFocus = false;
1935
+ /** @internal */
1936
+ titleRegistry = createSlotRegistry();
1937
+ /** @internal */
1938
+ initialFocusRegistry = createKeyedRegistry({
1939
+ name: 'CngxPopoverSheet',
1940
+ });
1941
+ roleAttr = computed(() => (this.modal() ? 'dialog' : this.staticRole), ...(ngDevMode ? [{ debugName: "roleAttr" }] : /* istanbul ignore next */ []));
1942
+ ariaModal = computed(() => (this.modal() ? 'true' : null), ...(ngDevMode ? [{ debugName: "ariaModal" }] : /* istanbul ignore next */ []));
1943
+ ariaLabelledBy = computed(() => this.modal()
1944
+ ? (this.labelledBy() ?? this.titleRegistry.current()?.id() ?? null)
1945
+ : this.staticLabelledBy, ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
1946
+ // Last-resort focus target: a modal sheet with nothing tabbable inside
1947
+ // still takes focus on its host.
1948
+ tabindexAttr = computed(() => this.modal() ? (this.staticTabindex ?? '-1') : this.staticTabindex, ...(ngDevMode ? [{ debugName: "tabindexAttr" }] : /* istanbul ignore next */ []));
1949
+ region = injectScopedLiveRegion(this.host);
1950
+ engaged = false;
1951
+ savedFocus = null;
1952
+ inerted = [];
1953
+ // Own host and ancestors an earlier sheet made inert, lifted while this
1954
+ // sheet is engaged so it stays reachable.
1955
+ lifted = [];
1956
+ releaseLock = null;
1957
+ settlingFrame = null;
1958
+ warnedTitle = false;
1959
+ warnedMode = false;
1960
+ closeWatcher = null;
1961
+ // Capture phase: the tap must be seen before anything under it reacts.
1962
+ // The page siblings are inert, so a tap outside the panel lands on a
1963
+ // non-inert ancestor; the popover ::backdrop does not catch taps on iOS
1964
+ // or Android.
1965
+ outsidePointerDown = (event) => {
1966
+ this.disarmClickSwallow();
1967
+ if (engagedSheets.at(-1) !== this) {
1968
+ return;
1969
+ }
1970
+ const target = event.target;
1971
+ if (target instanceof Node && this.host.contains(target)) {
1972
+ return;
1973
+ }
1974
+ this.armClickSwallow();
1975
+ this.requestClose('backdrop');
1976
+ };
1977
+ // Closing on pointerdown releases inert before the gesture's click lands,
1978
+ // so that click would hit the page element under the tap. Swallow the
1979
+ // one click that belongs to this gesture; the next pointerdown or a short
1980
+ // timeout disarms it, so a later tap is never eaten.
1981
+ clickSwallowTimer = null;
1982
+ // Chromium also turns an unhandled Escape keydown into a CloseWatcher close
1983
+ // request. Escape belongs to CngxPopover (gated by closeOnEscape, topmost
1984
+ // popover only), so a watcher close that comes from the same keypress is
1985
+ // not a back gesture. The flag lives for the keydown task only.
1986
+ escapeKeyTimer = null;
1987
+ escapeKeydown = (event) => {
1988
+ if (event.key !== 'Escape') {
1989
+ return;
1990
+ }
1991
+ if (this.escapeKeyTimer !== null) {
1992
+ clearTimeout(this.escapeKeyTimer);
1993
+ }
1994
+ this.escapeKeyTimer = setTimeout(() => {
1995
+ this.escapeKeyTimer = null;
1996
+ });
1997
+ };
1998
+ swallowClick = (event) => {
1999
+ event.preventDefault();
2000
+ event.stopPropagation();
2001
+ this.disarmClickSwallow();
2002
+ };
2003
+ constructor() {
2004
+ // A breakpoint crossing or request flip while open. Open and close
2005
+ // themselves run through onShown() / onHide(), which engage first, so
2006
+ // this effect only sees edges nobody handled yet.
2007
+ const active = createTransitionTracker(() => this.modal() && this.popover.isVisible());
2008
+ effect(() => {
2009
+ const now = active.current();
2010
+ const previous = active.previous();
2011
+ untracked(() => {
2012
+ if (now && !previous && !this.engaged) {
2013
+ this.engage(!this.host.contains(this.doc.activeElement));
2014
+ }
2015
+ if (!now && previous && this.engaged) {
2016
+ const opener = this.savedFocus;
2017
+ this.release();
2018
+ if (this.popover.isVisible()) {
2019
+ this.rehomeFocusAfterFlip(opener);
2020
+ }
2021
+ }
2022
+ });
2023
+ });
2024
+ // Destroyed while open: the host leaves the DOM, so focus would drop to
2025
+ // body. Restore it like a close, without emitting from a dying directive.
2026
+ inject(DestroyRef).onDestroy(() => {
2027
+ this.disengage(false);
2028
+ this.release();
2029
+ this.disarmClickSwallow();
2030
+ });
2031
+ }
2032
+ /** @internal Seam call from `CngxPopover.show()`, after `showPopover()`. */
2033
+ onShown() {
2034
+ if (!this.modal()) {
2035
+ return;
2036
+ }
2037
+ this.engage(true);
2038
+ }
2039
+ /** @internal Seam call from `CngxPopover.hide()`, before the close transition. */
2040
+ onHide() {
2041
+ this.disengage(true);
2042
+ }
2043
+ /**
2044
+ * Ask the sheet to close. Emits `closeRequested` once per open (no-op
2045
+ * unless the popover is opening or open) and hides when `closeOnRequest`
2046
+ * is on.
2047
+ */
2048
+ requestClose(reason) {
2049
+ const state = this.popover.state();
2050
+ if (state !== 'open' && state !== 'opening') {
2051
+ return;
2052
+ }
2053
+ this.closeRequested.emit(reason);
2054
+ if (this.closeOnRequest()) {
2055
+ this.popover.hide();
2056
+ }
2057
+ }
2058
+ /**
2059
+ * Speak `message` from the live region inside the panel. Use it for
2060
+ * every announcement while the sheet is modal: VoiceOver drops body-level
2061
+ * regions under `aria-modal`.
2062
+ */
2063
+ announce(message, politeness = 'polite') {
2064
+ this.region.announce(message, politeness);
2065
+ }
2066
+ /**
2067
+ * Move focus to the first enabled `CngxPopoverSheetInitialFocus` in
2068
+ * document order, else the first tabbable element, else the host. Runs on
2069
+ * every modal open.
2070
+ */
2071
+ focusInitial() {
2072
+ const target = this.initialFocusTarget();
2073
+ if (target) {
2074
+ target.focus();
2075
+ return;
2076
+ }
2077
+ if (!this.trap.focusFirstNow()) {
2078
+ this.host.focus();
2079
+ }
2080
+ }
2081
+ initialFocusTarget() {
2082
+ let first = null;
2083
+ for (const handle of this.initialFocusRegistry.values()) {
2084
+ const enabled = handle.enabled?.() ?? true;
2085
+ const precedes = first === null ||
2086
+ (first.compareDocumentPosition(handle.element) & first.DOCUMENT_POSITION_PRECEDING) !== 0;
2087
+ if (enabled && precedes) {
2088
+ first = handle.element;
2089
+ }
2090
+ }
2091
+ return first;
2092
+ }
2093
+ handleBeforeToggle(event) {
2094
+ // Native close paths (light dismiss, a direct hidePopover()) skip hide()
2095
+ // but owe the same page release and focus return.
2096
+ if (event.newState === 'closed') {
2097
+ this.disengage(true);
2098
+ }
2099
+ }
2100
+ // Close order: page live again, pending messages handed over, consumers
2101
+ // told, focus back on the opener, lock released. Idempotent through
2102
+ // `engaged`.
2103
+ disengage(emitClosing) {
2104
+ if (!this.engaged) {
2105
+ return;
2106
+ }
2107
+ this.restoreInert();
2108
+ this.handOffPendingAnnouncements();
2109
+ if (emitClosing) {
2110
+ this.closing.emit();
2111
+ }
2112
+ // On body counts as lost: CngxPopover's own teardown blurs the panel
2113
+ // before this one runs when both are destroyed together.
2114
+ const active = this.doc.activeElement;
2115
+ const focusLost = !active || active === this.doc.body || this.host.contains(active);
2116
+ if (this.restoreFocus() && focusLost) {
2117
+ this.focusFirstTaker([this.restoreTarget(), this.savedFocus, this.focusableAnchor()]);
2118
+ }
2119
+ this.release();
2120
+ }
2121
+ // Open order: focus, then inert, then lock. Focus first so the move
2122
+ // happens while the trigger is still focusable and inside the opening
2123
+ // gesture; inert after so the page never holds focus under inert.
2124
+ engage(moveFocus) {
2125
+ if (this.engaged) {
2126
+ return;
2127
+ }
2128
+ this.engaged = true;
2129
+ engagedSheets.push(this);
2130
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2131
+ this.warnOnMisconfiguration();
2132
+ }
2133
+ this.savedFocus = this.openerToRestore();
2134
+ this.region.ensure();
2135
+ this.liftOwnInert();
2136
+ if (moveFocus) {
2137
+ this.focusInitial();
2138
+ }
2139
+ this.applyInert();
2140
+ this.releaseLock = createPinnedScrollLock(this.doc.documentElement);
2141
+ this.startSettling();
2142
+ this.doc.addEventListener('pointerdown', this.outsidePointerDown, true);
2143
+ this.doc.addEventListener('keydown', this.escapeKeydown, true);
2144
+ this.armCloseWatcher();
2145
+ }
2146
+ // A flip back to anchored while open strips the modal focus targets (the
2147
+ // listbox loses its tabindex), so focus would drop to body. Independent of
2148
+ // `restoreFocus`, which governs a close, not a flip.
2149
+ rehomeFocusAfterFlip(opener) {
2150
+ afterNextRender(() => {
2151
+ const active = this.doc.activeElement;
2152
+ const lost = !active || active === this.doc.body || this.host.contains(active);
2153
+ if (lost) {
2154
+ this.focusFirstTaker([this.focusableAnchor(), opener]);
2155
+ }
2156
+ }, { injector: this.injector });
2157
+ }
2158
+ // A target can refuse focus: the opener of a sheet chain sits inside the
2159
+ // sheet the exclusive eviction just hid. Take the first one that holds it.
2160
+ focusFirstTaker(candidates) {
2161
+ for (const target of candidates) {
2162
+ if (!target?.isConnected) {
2163
+ continue;
2164
+ }
2165
+ target.focus();
2166
+ if (this.doc.activeElement === target) {
2167
+ return;
2168
+ }
2169
+ }
2170
+ }
2171
+ focusableAnchor() {
2172
+ const anchor = this.popover.anchorElement();
2173
+ return anchor && anchor.tabIndex >= 0 ? anchor : null;
2174
+ }
2175
+ // iOS Safari does not focus a button on tap (with or without VoiceOver),
2176
+ // so the pre-open snapshot is often body. Fall back to the popover's
2177
+ // anchor when it can take focus, so the close lands back on the opener.
2178
+ openerToRestore() {
2179
+ const origin = this.popover.focusOrigin();
2180
+ if (origin && origin !== this.doc.body) {
2181
+ return origin;
2182
+ }
2183
+ return this.focusableAnchor();
2184
+ }
2185
+ // Idempotent: hide(), the native toggle, a flip back to anchored and
2186
+ // destroy can all reach it.
2187
+ release() {
2188
+ this.doc.removeEventListener('pointerdown', this.outsidePointerDown, true);
2189
+ this.doc.removeEventListener('keydown', this.escapeKeydown, true);
2190
+ if (this.escapeKeyTimer !== null) {
2191
+ clearTimeout(this.escapeKeyTimer);
2192
+ this.escapeKeyTimer = null;
2193
+ }
2194
+ this.disarmCloseWatcher();
2195
+ this.restoreInert();
2196
+ this.releaseLock?.();
2197
+ this.releaseLock = null;
2198
+ this.stopSettling();
2199
+ this.engaged = false;
2200
+ this.savedFocus = null;
2201
+ const index = engagedSheets.indexOf(this);
2202
+ if (index !== -1) {
2203
+ engagedSheets.splice(index, 1);
2204
+ }
2205
+ }
2206
+ // Created inside the opening call, so a tap-opened sheet creates it under
2207
+ // the tap's user activation (Chrome groups watchers created without one).
2208
+ // Without CloseWatcher (iOS Safari) the back gesture leaves the page.
2209
+ armCloseWatcher() {
2210
+ const Watcher = this.win?.CloseWatcher;
2211
+ if (typeof Watcher !== 'function') {
2212
+ return;
2213
+ }
2214
+ const watcher = new Watcher();
2215
+ watcher.onclose = () => {
2216
+ if (this.closeWatcher === watcher) {
2217
+ this.closeWatcher = null;
2218
+ }
2219
+ if (this.escapeKeyTimer !== null) {
2220
+ if (this.engaged) {
2221
+ this.armCloseWatcher();
2222
+ }
2223
+ return;
2224
+ }
2225
+ this.requestClose('back');
2226
+ // A blocked request leaves the sheet open; the spent watcher would let
2227
+ // the next back gesture navigate away.
2228
+ if (this.engaged && this.closeWatcher === null) {
2229
+ this.armCloseWatcher();
2230
+ }
2231
+ };
2232
+ this.closeWatcher = watcher;
2233
+ }
2234
+ armClickSwallow() {
2235
+ this.doc.addEventListener('click', this.swallowClick, true);
2236
+ this.clickSwallowTimer = setTimeout(() => this.disarmClickSwallow(), CLICK_SWALLOW_MS);
2237
+ }
2238
+ disarmClickSwallow() {
2239
+ this.doc.removeEventListener('click', this.swallowClick, true);
2240
+ if (this.clickSwallowTimer !== null) {
2241
+ clearTimeout(this.clickSwallowTimer);
2242
+ this.clickSwallowTimer = null;
2243
+ }
2244
+ }
2245
+ disarmCloseWatcher() {
2246
+ const watcher = this.closeWatcher;
2247
+ this.closeWatcher = null;
2248
+ watcher?.destroy();
2249
+ }
2250
+ liftOwnInert() {
2251
+ let node = this.host;
2252
+ while (node && node !== this.doc.body) {
2253
+ if ((inertClaims.get(node) ?? 0) > 0 && node.hasAttribute('inert')) {
2254
+ node.removeAttribute('inert');
2255
+ this.lifted.push(node);
2256
+ }
2257
+ node = node.parentElement;
2258
+ }
2259
+ }
2260
+ applyInert() {
2261
+ const body = this.doc.body;
2262
+ let node = this.host;
2263
+ while (node !== body && node.parentElement) {
2264
+ const parent = node.parentElement;
2265
+ for (const sibling of Array.from(parent.children)) {
2266
+ if (sibling === node || !(sibling instanceof HTMLElement) || this.skipsInert(sibling)) {
2267
+ continue;
2268
+ }
2269
+ inertClaims.set(sibling, (inertClaims.get(sibling) ?? 0) + 1);
2270
+ sibling.setAttribute('inert', '');
2271
+ this.inerted.push(sibling);
2272
+ }
2273
+ node = parent;
2274
+ }
2275
+ }
2276
+ skipsInert(el) {
2277
+ const preExisting = el.hasAttribute('inert') && !inertClaims.get(el);
2278
+ return (preExisting ||
2279
+ el.classList.contains(FOCUS_TRAP_ANCHOR_CLASS) ||
2280
+ el.matches(LIVE_REGION_SELECTOR));
2281
+ }
2282
+ restoreInert() {
2283
+ for (const el of this.inerted) {
2284
+ const claims = (inertClaims.get(el) ?? 1) - 1;
2285
+ if (claims > 0) {
2286
+ inertClaims.set(el, claims);
2287
+ continue;
2288
+ }
2289
+ inertClaims.delete(el);
2290
+ el.removeAttribute('inert');
2291
+ }
2292
+ this.inerted = [];
2293
+ for (const el of this.lifted) {
2294
+ if ((inertClaims.get(el) ?? 0) > 0) {
2295
+ el.setAttribute('inert', '');
2296
+ }
2297
+ }
2298
+ this.lifted = [];
2299
+ }
2300
+ // A message announced right before close would land in a region that is
2301
+ // about to hide; the root announcer speaks it after the close instead.
2302
+ handOffPendingAnnouncements() {
2303
+ for (const pending of this.region.takePending()) {
2304
+ this.announcer.announce(pending.message, pending.politeness);
2305
+ }
2306
+ }
2307
+ // The pinned lock shifts the page for one frame on iOS. Keep the panel
2308
+ // invisible until two consecutive frames report the same rect.
2309
+ startSettling() {
2310
+ const raf = this.win?.requestAnimationFrame?.bind(this.win);
2311
+ if (!raf) {
2312
+ return;
2313
+ }
2314
+ this.host.setAttribute(SETTLING_ATTRIBUTE, '');
2315
+ let previous = null;
2316
+ let frames = 0;
2317
+ const check = () => {
2318
+ frames += 1;
2319
+ const rect = this.host.getBoundingClientRect();
2320
+ const stable = previous !== null &&
2321
+ previous.top === rect.top &&
2322
+ previous.left === rect.left &&
2323
+ previous.width === rect.width &&
2324
+ previous.height === rect.height;
2325
+ if (stable || frames >= SETTLING_FRAME_CAP) {
2326
+ this.stopSettling();
2327
+ return;
2328
+ }
2329
+ previous = rect;
2330
+ this.settlingFrame = raf(check);
2331
+ };
2332
+ this.settlingFrame = raf(check);
2333
+ }
2334
+ stopSettling() {
2335
+ if (this.settlingFrame !== null) {
2336
+ this.win?.cancelAnimationFrame?.(this.settlingFrame);
2337
+ this.settlingFrame = null;
2338
+ }
2339
+ this.host.removeAttribute(SETTLING_ATTRIBUTE);
2340
+ }
2341
+ warnOnMisconfiguration() {
2342
+ const unnamed = !this.labelledBy() && !this.titleRegistry.current();
2343
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !this.warnedTitle && unnamed) {
2344
+ this.warnedTitle = true;
2345
+ cngxDevWarn('CNGX1064', '[cngxPopoverSheet] opened as a modal sheet without a name. Add a ' +
2346
+ 'cngxPopoverSheetTitle inside the panel or bind [labelledBy].', this.host);
2347
+ }
2348
+ const mode = this.popover.mode();
2349
+ if (typeof ngDevMode !== 'undefined' && ngDevMode && !this.warnedMode && mode !== 'manual') {
2350
+ this.warnedMode = true;
2351
+ cngxDevWarn('CNGX1065', `[cngxPopoverSheet] needs mode="manual" on the popover, got "${mode}". ` +
2352
+ 'Native light dismiss and Escape bypass closeRequested in that mode.', this.host);
2353
+ }
2354
+ }
2355
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheet, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2356
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxPopoverSheet, isStandalone: true, selector: "[cngxPopoverSheet]", inputs: { request: { classPropertyName: "request", publicName: "cngxPopoverSheet", isSignal: true, isRequired: false, transformFunction: null }, autoPresentation: { classPropertyName: "autoPresentation", publicName: "autoPresentation", isSignal: true, isRequired: false, transformFunction: null }, labelledBy: { classPropertyName: "labelledBy", publicName: "labelledBy", isSignal: true, isRequired: false, transformFunction: null }, restoreFocus: { classPropertyName: "restoreFocus", publicName: "restoreFocus", isSignal: true, isRequired: false, transformFunction: null }, restoreTarget: { classPropertyName: "restoreTarget", publicName: "restoreTarget", isSignal: true, isRequired: false, transformFunction: null }, closeOnRequest: { classPropertyName: "closeOnRequest", publicName: "closeOnRequest", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closeRequested: "closeRequested", closing: "closing" }, host: { listeners: { "beforetoggle": "handleBeforeToggle($event)" }, properties: { "attr.data-cngx-sheet": "request()", "attr.data-cngx-presentation": "presentation()", "attr.role": "roleAttr()", "attr.aria-modal": "ariaModal()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.tabindex": "tabindexAttr()" }, classAttribute: "cngx-popover-sheet" }, providers: [
2357
+ { provide: CNGX_POPOVER_PRESENTATION, useExisting: CngxPopoverSheet },
2358
+ { provide: CNGX_POPOVER_SHEET_HOST, useExisting: CngxPopoverSheet },
2359
+ { provide: CNGX_FOCUS_TRAP_DRIVER, useExisting: CngxPopoverSheet },
2360
+ ], exportAs: ["cngxPopoverSheet"], hostDirectives: [{ directive: i1.CngxFocusTrap }], ngImport: i0 });
2361
+ }
2362
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheet, decorators: [{
2363
+ type: Directive,
2364
+ args: [{
2365
+ selector: '[cngxPopoverSheet]',
2366
+ exportAs: 'cngxPopoverSheet',
2367
+ standalone: true,
2368
+ hostDirectives: [{ directive: CngxFocusTrap, inputs: [], outputs: [] }],
2369
+ providers: [
2370
+ { provide: CNGX_POPOVER_PRESENTATION, useExisting: CngxPopoverSheet },
2371
+ { provide: CNGX_POPOVER_SHEET_HOST, useExisting: CngxPopoverSheet },
2372
+ { provide: CNGX_FOCUS_TRAP_DRIVER, useExisting: CngxPopoverSheet },
2373
+ ],
2374
+ host: {
2375
+ class: 'cngx-popover-sheet',
2376
+ '[attr.data-cngx-sheet]': 'request()',
2377
+ '[attr.data-cngx-presentation]': 'presentation()',
2378
+ '[attr.role]': 'roleAttr()',
2379
+ '[attr.aria-modal]': 'ariaModal()',
2380
+ '[attr.aria-labelledby]': 'ariaLabelledBy()',
2381
+ '[attr.tabindex]': 'tabindexAttr()',
2382
+ '(beforetoggle)': 'handleBeforeToggle($event)',
2383
+ },
2384
+ }]
2385
+ }], ctorParameters: () => [], propDecorators: { request: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverSheet", required: false }] }], autoPresentation: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoPresentation", required: false }] }], labelledBy: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelledBy", required: false }] }], restoreFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreFocus", required: false }] }], restoreTarget: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreTarget", required: false }] }], closeOnRequest: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnRequest", required: false }] }], closeRequested: [{ type: i0.Output, args: ["closeRequested"] }], closing: [{ type: i0.Output, args: ["closing"] }] } });
2386
+
2387
+ // Header and handle share the swipe wiring: a CngxSwipeDismiss on the same
2388
+ // element closes the sheet through closeRequested (CngxBottomSheet precedent).
2389
+ function routeSwipeToSheet(part) {
2390
+ const sheet = injectPopoverSheetHost(part);
2391
+ const swipe = inject(CngxSwipeDismiss, { self: true, optional: true });
2392
+ if (!swipe) {
2393
+ return;
2394
+ }
2395
+ const sub = swipe.swiped.subscribe(() => sheet.requestClose('swipe'));
2396
+ inject(DestroyRef).onDestroy(() => sub.unsubscribe());
2397
+ }
2398
+ /**
2399
+ * Header row of a `CngxPopoverSheet`. Stays put while the content below it
2400
+ * scrolls; add `cngxSwipeDismiss="down"` to close the sheet by swiping it.
2401
+ *
2402
+ * @category common/popover
2403
+ * @since 0.1.0
2404
+ * @relatedTo CngxPopoverSheet, CngxSwipeDismiss
2405
+ */
2406
+ class CngxPopoverSheetHeader {
2407
+ constructor() {
2408
+ routeSwipeToSheet('cngxPopoverSheetHeader');
2409
+ }
2410
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2411
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverSheetHeader, isStandalone: true, selector: "[cngxPopoverSheetHeader]", host: { classAttribute: "cngx-popover-sheet-header" }, ngImport: i0 });
2412
+ }
2413
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHeader, decorators: [{
2414
+ type: Directive,
2415
+ args: [{
2416
+ selector: '[cngxPopoverSheetHeader]',
2417
+ standalone: true,
2418
+ host: { class: 'cngx-popover-sheet-header' },
2419
+ }]
2420
+ }], ctorParameters: () => [] });
2421
+ /**
2422
+ * The element that names a modal `CngxPopoverSheet`. The sheet points its
2423
+ * `aria-labelledby` here, never at the header that also holds buttons.
2424
+ *
2425
+ * @category common/popover
2426
+ * @since 0.1.0
2427
+ * @relatedTo CngxPopoverSheet
2428
+ */
2429
+ class CngxPopoverSheetTitle {
2430
+ /** Generated id the sheet references. */
2431
+ id = signal(nextUid('cngx-popover-sheet-title')).asReadonly();
2432
+ constructor() {
2433
+ const sheet = injectPopoverSheetHost('cngxPopoverSheetTitle');
2434
+ sheet.titleRegistry.register(this);
2435
+ inject(DestroyRef).onDestroy(() => sheet.titleRegistry.unregister(this));
2436
+ }
2437
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetTitle, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2438
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverSheetTitle, isStandalone: true, selector: "[cngxPopoverSheetTitle]", host: { properties: { "id": "id()" } }, ngImport: i0 });
2439
+ }
2440
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetTitle, decorators: [{
2441
+ type: Directive,
2442
+ args: [{
2443
+ selector: '[cngxPopoverSheetTitle]',
2444
+ standalone: true,
2445
+ host: { '[id]': 'id()' },
2446
+ }]
2447
+ }], ctorParameters: () => [] });
2448
+ /**
2449
+ * Decorative drag handle. Always `aria-hidden`: screen-reader users close
2450
+ * the sheet through its close control, since their swipe is consumed by
2451
+ * navigation.
2452
+ *
2453
+ * @category common/popover
2454
+ * @since 0.1.0
2455
+ * @relatedTo CngxPopoverSheet
2456
+ */
2457
+ class CngxPopoverSheetHandle {
2458
+ constructor() {
2459
+ routeSwipeToSheet('cngxPopoverSheetHandle');
2460
+ }
2461
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHandle, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2462
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverSheetHandle, isStandalone: true, selector: "[cngxPopoverSheetHandle]", host: { attributes: { "aria-hidden": "true" }, classAttribute: "cngx-popover-sheet-handle" }, ngImport: i0 });
2463
+ }
2464
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHandle, decorators: [{
2465
+ type: Directive,
2466
+ args: [{
2467
+ selector: '[cngxPopoverSheetHandle]',
2468
+ standalone: true,
2469
+ host: { class: 'cngx-popover-sheet-handle', 'aria-hidden': 'true' },
2470
+ }]
2471
+ }], ctorParameters: () => [] });
2472
+ /**
2473
+ * Marks the element that receives focus when a modal `CngxPopoverSheet`
2474
+ * opens, e.g. the search input of a fullscreen panel. Without one the first
2475
+ * tabbable element is focused.
2476
+ *
2477
+ * A panel can mark several elements. The first enabled one in document order
2478
+ * takes focus, so a search field that should lead only some opens binds
2479
+ * `[cngxPopoverSheetInitialFocus]="condition"` and the list below it carries
2480
+ * the bare attribute as the default target. The condition is read when the
2481
+ * sheet opens.
2482
+ *
2483
+ * @category common/popover
2484
+ * @since 0.1.0
2485
+ * @relatedTo CngxPopoverSheet
2486
+ */
2487
+ class CngxPopoverSheetInitialFocus {
2488
+ /** The element focused on open. */
2489
+ element = inject(ElementRef).nativeElement;
2490
+ /**
2491
+ * `false` keeps this element out of the next open's focus choice. The bare
2492
+ * attribute, or no binding, leaves it enabled.
2493
+ */
2494
+ enabledInput = input(undefined, { ...(ngDevMode ? { debugName: "enabledInput" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverSheetInitialFocus',
2495
+ transform: (v) => (typeof v === 'string' ? undefined : v) });
2496
+ /** @internal Read by the sheet on open. */
2497
+ enabled = computed(() => this.enabledInput() !== false, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
2498
+ key = nextUid('cngx-popover-sheet-initial-focus');
2499
+ constructor() {
2500
+ const sheet = injectPopoverSheetHost('cngxPopoverSheetInitialFocus');
2501
+ sheet.initialFocusRegistry.register(this.key, this);
2502
+ inject(DestroyRef).onDestroy(() => sheet.initialFocusRegistry.unregister(this.key, this));
2503
+ }
2504
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetInitialFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2505
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxPopoverSheetInitialFocus, isStandalone: true, selector: "[cngxPopoverSheetInitialFocus]", inputs: { enabledInput: { classPropertyName: "enabledInput", publicName: "cngxPopoverSheetInitialFocus", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0 });
2506
+ }
2507
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetInitialFocus, decorators: [{
2508
+ type: Directive,
2509
+ args: [{
2510
+ selector: '[cngxPopoverSheetInitialFocus]',
2511
+ standalone: true,
2512
+ }]
2513
+ }], ctorParameters: () => [], propDecorators: { enabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverSheetInitialFocus", required: false }] }] } });
2514
+
1619
2515
  /** @internal Default configuration - no auto-dismiss, no close-on-success, variant='default'. */
1620
2516
  const DEFAULT_CONFIG = {
1621
2517
  defaultVariant: 'default',
@@ -2339,11 +3235,11 @@ class CngxPopoverAction {
2339
3235
  }
2340
3236
  });
2341
3237
  this.destroyRef.onDestroy(() => this.clearCloseOnSuccessTimer());
2342
- if (isDevMode()) {
3238
+ if (typeof ngDevMode !== 'undefined' && ngDevMode) {
2343
3239
  afterNextRender(() => {
2344
3240
  if (this.role() === 'confirm' && !this.action()) {
2345
- console.warn('CngxPopoverAction: role="confirm" without an [action] renders a button whose ' +
2346
- 'click does nothing. Bind [action] or use role="dismiss".');
3241
+ cngxDevWarn('CNGX1035', '[cngx-popover-action] role="confirm" without an [action] renders a button whose ' +
3242
+ 'click runs nothing and leaves the popover open. Bind [action] or use role="dismiss".');
2347
3243
  }
2348
3244
  });
2349
3245
  }
@@ -2369,10 +3265,10 @@ class CngxPopoverAction {
2369
3265
  >
2370
3266
  <ng-container *ngTemplateOutlet="idle" />
2371
3267
  </button>
2372
- } @else {
3268
+ } @else if (action(); as act) {
2373
3269
  <button
2374
3270
  type="button"
2375
- [cngxAsyncClick]="action()!"
3271
+ [cngxAsyncClick]="act"
2376
3272
  #btn="cngxAsyncClick"
2377
3273
  [feedbackDuration]="feedbackDuration()"
2378
3274
  [autoAnnounce]="false"
@@ -2410,6 +3306,15 @@ class CngxPopoverAction {
2410
3306
  <span aria-live="polite" aria-atomic="true" class="cngx-popover-action__sr-only">
2411
3307
  {{ btn.announcement() }}
2412
3308
  </span>
3309
+ } @else {
3310
+ <!-- confirm without [action]: CNGX1035; the click runs nothing -->
3311
+ <button
3312
+ type="button"
3313
+ aria-disabled="true"
3314
+ [class]="'cngx-popover-action cngx-popover-action--' + variant()"
3315
+ >
3316
+ <ng-container *ngTemplateOutlet="idle" />
3317
+ </button>
2413
3318
  }
2414
3319
  `, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-popover-action-padding-block{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-popover-action-padding-inline{syntax: \"<length>\"; inherits: false; initial-value: 14px;}@property --cngx-popover-action-gap{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-popover-action-radius{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-popover-action-font-size{syntax: \"*\"; inherits: false; initial-value: .8125rem;}@property --cngx-popover-action-font-weight{syntax: \"<number>\"; inherits: false; initial-value: 500;}@property --cngx-popover-action-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}:where(.cngx-popover-action){--cngx-popover-action-transition: var(--cngx-duration-fast)}@property --cngx-popover-action-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .04);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-popover-action-hover-bg: oklch(1 0 0 / .06)}}[data-color-scheme=dark],.dark{--cngx-popover-action-hover-bg: oklch(1 0 0 / .06)}[data-color-scheme=light],.light{--cngx-popover-action-hover-bg: oklch(0 0 0 / .04)}}@layer cngx.components{@scope(.cngx-popover-action){:scope{--cngx-popover-action-gap: var(--cngx-space-xs);--cngx-popover-action-padding-block: var(--cngx-space-xs);--cngx-popover-action-padding-inline: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-popover-action-gap, 6px);padding:var(--cngx-popover-action-padding-block, 6px) var(--cngx-popover-action-padding-inline, 14px);min-block-size:var(--cngx-target-min, 0px);border:1px solid var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));border-radius:var(--cngx-popover-action-radius, 6px);background:transparent;color:inherit;font:inherit;font-size:var(--cngx-popover-action-font-size, .8125rem);font-weight:var(--cngx-popover-action-font-weight, 500);cursor:pointer;transition:background var(--cngx-popover-action-transition, .15s),border-color var(--cngx-popover-action-transition, .15s),color var(--cngx-popover-action-transition, .15s)}:scope:hover{background:var(--cngx-popover-action-hover-bg, oklch(0 0 0 / .04))}:scope:focus-visible{outline:2px solid var(--cngx-popover-panel-accent-text, currentColor);outline-offset:2px}:scope:disabled,:scope[aria-disabled=true]{cursor:not-allowed}:scope.cngx-popover-action--primary{background:var(--cngx-popover-panel-accent, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-popover-panel-accent-text, oklch(1 0 0));border-color:transparent}:scope.cngx-popover-action--primary:hover{filter:brightness(.95);background:var(--cngx-popover-panel-accent, var(--cngx-color-primary, oklch(.66 .19 50)))}:scope.cngx-popover-action--danger{background:var(--cngx-color-danger, oklch(.6 .22 25));color:#fff;border-color:transparent}:scope.cngx-popover-action--danger:hover{filter:brightness(.95)}:scope.cngx-popover-action--ghost{border-color:transparent}:scope.cngx-popover-action--ghost:hover{background:var(--cngx-popover-action-hover-bg, oklch(0 0 0 / .04))}:scope:is(:disabled,[aria-disabled=true]){color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:is(.cngx-popover-action--primary,.cngx-popover-action--danger):is(:disabled,[aria-disabled=true]){background:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent);color:var(--cngx-color-surface, oklch(1 0 0));filter:none}}.cngx-popover-action__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}@media(forced-colors:active){.cngx-popover-action:is(:disabled,[aria-disabled=true]){color:GrayText;border-color:GrayText}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxAsyncClick, selector: "[cngxAsyncClick]", inputs: ["cngxAsyncClick", "feedbackDuration", "enabled", "busy", "succeededAnnouncement", "failedAnnouncement", "autoAnnounce"], exportAs: ["cngxAsyncClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
2415
3320
  }
@@ -2426,10 +3331,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2426
3331
  >
2427
3332
  <ng-container *ngTemplateOutlet="idle" />
2428
3333
  </button>
2429
- } @else {
3334
+ } @else if (action(); as act) {
2430
3335
  <button
2431
3336
  type="button"
2432
- [cngxAsyncClick]="action()!"
3337
+ [cngxAsyncClick]="act"
2433
3338
  #btn="cngxAsyncClick"
2434
3339
  [feedbackDuration]="feedbackDuration()"
2435
3340
  [autoAnnounce]="false"
@@ -2467,6 +3372,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2467
3372
  <span aria-live="polite" aria-atomic="true" class="cngx-popover-action__sr-only">
2468
3373
  {{ btn.announcement() }}
2469
3374
  </span>
3375
+ } @else {
3376
+ <!-- confirm without [action]: CNGX1035; the click runs nothing -->
3377
+ <button
3378
+ type="button"
3379
+ aria-disabled="true"
3380
+ [class]="'cngx-popover-action cngx-popover-action--' + variant()"
3381
+ >
3382
+ <ng-container *ngTemplateOutlet="idle" />
3383
+ </button>
2470
3384
  }
2471
3385
  `, styles: ["@layer cngx.tokens{@property --cngx-popover-action-padding-block{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-popover-action-padding-inline{syntax: \"<length>\"; inherits: false; initial-value: 14px;}@property --cngx-popover-action-gap{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-popover-action-radius{syntax: \"<length>\"; inherits: false; initial-value: 6px;}@property --cngx-popover-action-font-size{syntax: \"*\"; inherits: false; initial-value: .8125rem;}@property --cngx-popover-action-font-weight{syntax: \"<number>\"; inherits: false; initial-value: 500;}@property --cngx-popover-action-transition{syntax: \"<time>\"; inherits: false; initial-value: .15s;}:where(.cngx-popover-action){--cngx-popover-action-transition: var(--cngx-duration-fast)}@property --cngx-popover-action-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .04);}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-popover-action-hover-bg: oklch(1 0 0 / .06)}}[data-color-scheme=dark],.dark{--cngx-popover-action-hover-bg: oklch(1 0 0 / .06)}[data-color-scheme=light],.light{--cngx-popover-action-hover-bg: oklch(0 0 0 / .04)}}@layer cngx.components{@scope(.cngx-popover-action){:scope{--cngx-popover-action-gap: var(--cngx-space-xs);--cngx-popover-action-padding-block: var(--cngx-space-xs);--cngx-popover-action-padding-inline: var(--cngx-space-md);display:inline-flex;align-items:center;gap:var(--cngx-popover-action-gap, 6px);padding:var(--cngx-popover-action-padding-block, 6px) var(--cngx-popover-action-padding-inline, 14px);min-block-size:var(--cngx-target-min, 0px);border:1px solid var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));border-radius:var(--cngx-popover-action-radius, 6px);background:transparent;color:inherit;font:inherit;font-size:var(--cngx-popover-action-font-size, .8125rem);font-weight:var(--cngx-popover-action-font-weight, 500);cursor:pointer;transition:background var(--cngx-popover-action-transition, .15s),border-color var(--cngx-popover-action-transition, .15s),color var(--cngx-popover-action-transition, .15s)}:scope:hover{background:var(--cngx-popover-action-hover-bg, oklch(0 0 0 / .04))}:scope:focus-visible{outline:2px solid var(--cngx-popover-panel-accent-text, currentColor);outline-offset:2px}:scope:disabled,:scope[aria-disabled=true]{cursor:not-allowed}:scope.cngx-popover-action--primary{background:var(--cngx-popover-panel-accent, var(--cngx-color-primary, oklch(.66 .19 50)));color:var(--cngx-popover-panel-accent-text, oklch(1 0 0));border-color:transparent}:scope.cngx-popover-action--primary:hover{filter:brightness(.95);background:var(--cngx-popover-panel-accent, var(--cngx-color-primary, oklch(.66 .19 50)))}:scope.cngx-popover-action--danger{background:var(--cngx-color-danger, oklch(.6 .22 25));color:#fff;border-color:transparent}:scope.cngx-popover-action--danger:hover{filter:brightness(.95)}:scope.cngx-popover-action--ghost{border-color:transparent}:scope.cngx-popover-action--ghost:hover{background:var(--cngx-popover-action-hover-bg, oklch(0 0 0 / .04))}:scope:is(:disabled,[aria-disabled=true]){color:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent)}:scope:is(.cngx-popover-action--primary,.cngx-popover-action--danger):is(:disabled,[aria-disabled=true]){background:color-mix(in oklab,var(--cngx-color-text, oklch(.2 .01 250)) 38%,transparent);color:var(--cngx-color-surface, oklch(1 0 0));filter:none}}.cngx-popover-action__sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}}@media(forced-colors:active){.cngx-popover-action:is(:disabled,[aria-disabled=true]){color:GrayText;border-color:GrayText}}\n"] }]
2472
3386
  }], ctorParameters: () => [], propDecorators: { role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", required: false }] }], action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: false }] }], variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], feedbackDuration: [{ type: i0.Input, args: [{ isSignal: true, alias: "feedbackDuration", required: false }] }], pendingTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPending), { isSignal: true }] }], succeededTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxSucceeded), { isSignal: true }] }], failedTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxFailed), { isSignal: true }] }], asyncClick: [{ type: i0.ViewChild, args: [i0.forwardRef(() => CngxAsyncClick), { isSignal: true }] }] } });
@@ -2538,5 +3452,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
2538
3452
  * Generated bundle index. Do not edit.
2539
3453
  */
2540
3454
 
2541
- export { CNGX_FLOATING_FALLBACK, CNGX_POPOVER_ARROW_BOUNDS, CNGX_POPOVER_LANGUAGE_EN, CNGX_POPOVER_PANEL_CONFIG, CngxPopover, CngxPopoverAction, CngxPopoverAnchor, CngxPopoverArrow, CngxPopoverBody, CngxPopoverClose, CngxPopoverDivider, CngxPopoverEmpty, CngxPopoverError, CngxPopoverFooter, CngxPopoverHeader, CngxPopoverLoading, CngxPopoverPanel, CngxPopoverTrigger, CngxTooltip, provideFloatingFallback, providePopoverPanel, withArrow, withArrowTemplate, withAutoDismiss, withCloseButton, withCloseOnSuccess, withDefaultVariant, withPopoverPanelLabels };
3455
+ export { CNGX_FLOATING_FALLBACK, CNGX_POPOVER_ARROW_BOUNDS, CNGX_POPOVER_LANGUAGE_EN, CNGX_POPOVER_PANEL_CONFIG, CngxPopover, CngxPopoverAction, CngxPopoverAnchor, CngxPopoverArrow, CngxPopoverBody, CngxPopoverClose, CngxPopoverDivider, CngxPopoverEmpty, CngxPopoverError, CngxPopoverFooter, CngxPopoverHeader, CngxPopoverLoading, CngxPopoverPanel, CngxPopoverSheet, CngxPopoverSheetHandle, CngxPopoverSheetHeader, CngxPopoverSheetInitialFocus, CngxPopoverSheetTitle, CngxPopoverTrigger, CngxTooltip, provideFloatingFallback, providePopoverPanel, withArrow, withArrowTemplate, withAutoDismiss, withCloseButton, withCloseOnSuccess, withDefaultVariant, withPopoverPanelLabels };
2542
3456
  //# sourceMappingURL=cngx-common-popover.mjs.map