@cngx/common 0.0.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +18 -0
  3. package/a11y/README.md +77 -0
  4. package/card/README.md +79 -0
  5. package/chart/README.md +31 -0
  6. package/data/README.md +883 -0
  7. package/dialog/README.md +84 -0
  8. package/display/README.md +30 -0
  9. package/fesm2022/cngx-common-a11y.mjs +1260 -0
  10. package/fesm2022/cngx-common-a11y.mjs.map +1 -0
  11. package/fesm2022/cngx-common-card.mjs +765 -0
  12. package/fesm2022/cngx-common-card.mjs.map +1 -0
  13. package/fesm2022/cngx-common-chart.mjs +2943 -0
  14. package/fesm2022/cngx-common-chart.mjs.map +1 -0
  15. package/fesm2022/cngx-common-data.mjs +2886 -0
  16. package/fesm2022/cngx-common-data.mjs.map +1 -0
  17. package/fesm2022/cngx-common-dialog.mjs +1366 -0
  18. package/fesm2022/cngx-common-dialog.mjs.map +1 -0
  19. package/fesm2022/cngx-common-display.mjs +1603 -0
  20. package/fesm2022/cngx-common-display.mjs.map +1 -0
  21. package/fesm2022/cngx-common-interactive.mjs +8185 -0
  22. package/fesm2022/cngx-common-interactive.mjs.map +1 -0
  23. package/fesm2022/cngx-common-layout.mjs +1335 -0
  24. package/fesm2022/cngx-common-layout.mjs.map +1 -0
  25. package/fesm2022/cngx-common-popover.mjs +1200 -0
  26. package/fesm2022/cngx-common-popover.mjs.map +1 -0
  27. package/fesm2022/cngx-common-stepper.mjs +1350 -0
  28. package/fesm2022/cngx-common-stepper.mjs.map +1 -0
  29. package/fesm2022/cngx-common-tabs.mjs +1551 -0
  30. package/fesm2022/cngx-common-tabs.mjs.map +1 -0
  31. package/fesm2022/cngx-common.mjs +34 -0
  32. package/fesm2022/cngx-common.mjs.map +1 -0
  33. package/interactive/README.md +211 -0
  34. package/layout/README.md +117 -0
  35. package/package.json +100 -0
  36. package/popover/README.md +218 -0
  37. package/stepper/README.md +102 -0
  38. package/tabs/README.md +32 -0
  39. package/types/cngx-common-a11y.d.ts +616 -0
  40. package/types/cngx-common-card.d.ts +413 -0
  41. package/types/cngx-common-chart.d.ts +1081 -0
  42. package/types/cngx-common-data.d.ts +1460 -0
  43. package/types/cngx-common-dialog.d.ts +772 -0
  44. package/types/cngx-common-display.d.ts +1136 -0
  45. package/types/cngx-common-interactive.d.ts +5013 -0
  46. package/types/cngx-common-layout.d.ts +737 -0
  47. package/types/cngx-common-popover.d.ts +520 -0
  48. package/types/cngx-common-stepper.d.ts +982 -0
  49. package/types/cngx-common-tabs.d.ts +1237 -0
  50. package/types/cngx-common.d.ts +13 -0
@@ -0,0 +1,1200 @@
1
+ import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
2
+ import * as i0 from '@angular/core';
3
+ import { InjectionToken, isDevMode, inject, ElementRef, DestroyRef, input, signal, computed, effect, untracked, Directive, Renderer2, TemplateRef, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
+ import { nextUid, hasTransition, onTransitionDone } from '@cngx/core/utils';
5
+ import * as i1 from '@cngx/common/a11y';
6
+ import { CngxReducedMotion } from '@cngx/common/a11y';
7
+ import { CngxCloseButton, CngxPending, CngxSucceeded, CngxFailed, CngxAsyncClick } from '@cngx/common/interactive';
8
+
9
+ /**
10
+ * Detect CSS Anchor Positioning support.
11
+ *
12
+ * The spec renamed `inset-area` to `position-area` (Chrome 129+, Safari 18.4+).
13
+ * Chrome 125-128 only supports the old `inset-area` name.
14
+ * We detect whichever is available and use it consistently.
15
+ */
16
+ function detectAnchorSupport() {
17
+ if (typeof CSS === 'undefined') {
18
+ return { supported: false, propertyName: 'position-area' };
19
+ }
20
+ if (CSS.supports('position-area', 'bottom')) {
21
+ return { supported: true, propertyName: 'position-area' };
22
+ }
23
+ if (CSS.supports('inset-area', 'bottom')) {
24
+ return { supported: true, propertyName: 'inset-area' };
25
+ }
26
+ return { supported: false, propertyName: 'position-area' };
27
+ }
28
+ const ANCHOR_SUPPORT = detectAnchorSupport();
29
+ /** `true` when the browser supports CSS Anchor Positioning. */
30
+ const SUPPORTS_ANCHOR = ANCHOR_SUPPORT.supported;
31
+ /** The CSS property name for anchor area positioning (`position-area` or `inset-area`). */
32
+ const ANCHOR_AREA_PROPERTY = ANCHOR_SUPPORT.propertyName;
33
+ /**
34
+ * CSS anchor area values mapped from logical placement tokens.
35
+ *
36
+ * Uses physical keywords only — Chrome does not support logical keywords
37
+ * (`start`/`end`/`span-inline-*`) in `position-area` as of Chrome 140.
38
+ * Supported: `top`, `bottom`, `left`, `right`, `span-all`,
39
+ * `top left`, `top right`, `bottom left`, `bottom right`.
40
+ */
41
+ const POSITION_AREA = {
42
+ top: 'top',
43
+ 'top-start': 'top left',
44
+ 'top-end': 'top right',
45
+ bottom: 'bottom',
46
+ 'bottom-start': 'bottom left',
47
+ 'bottom-end': 'bottom right',
48
+ left: 'left',
49
+ 'left-start': 'top left',
50
+ 'left-end': 'bottom left',
51
+ right: 'right',
52
+ 'right-start': 'top right',
53
+ 'right-end': 'bottom right',
54
+ };
55
+
56
+ /**
57
+ * Injection token for the Floating UI fallback.
58
+ * `null` when not provided — CSS Anchor Positioning is used instead.
59
+ */
60
+ const CNGX_FLOATING_FALLBACK = new InjectionToken('CngxFloatingFallback', { factory: () => null });
61
+ /**
62
+ * Provides the Floating UI positioning fallback for browsers without
63
+ * CSS Anchor Positioning support.
64
+ *
65
+ * The consumer must install `@floating-ui/dom` themselves — this library
66
+ * never imports it directly, keeping the bundle at zero cost for modern browsers.
67
+ *
68
+ * ```typescript
69
+ * import { computePosition, flip, offset, shift } from '@floating-ui/dom';
70
+ *
71
+ * // In app.config.ts or component providers:
72
+ * providers: [
73
+ * provideFloatingFallback(computePosition, [offset(8), flip(), shift()]),
74
+ * ]
75
+ * ```
76
+ */
77
+ function provideFloatingFallback(computePosition, middleware) {
78
+ return {
79
+ provide: CNGX_FLOATING_FALLBACK,
80
+ useValue: { computePosition, middleware },
81
+ };
82
+ }
83
+ /** Maps cngx placement tokens to Floating UI placement strings. */
84
+ const FLOATING_PLACEMENT = {
85
+ top: 'top',
86
+ 'top-start': 'top-start',
87
+ 'top-end': 'top-end',
88
+ bottom: 'bottom',
89
+ 'bottom-start': 'bottom-start',
90
+ 'bottom-end': 'bottom-end',
91
+ left: 'left',
92
+ 'left-start': 'left-start',
93
+ 'left-end': 'left-end',
94
+ right: 'right',
95
+ 'right-start': 'right-start',
96
+ 'right-end': 'right-end',
97
+ };
98
+
99
+ /** Module-level registry of open popovers (insertion-ordered). */
100
+ const openPopovers = new Set();
101
+ /** Tracks which Documents already have the global Escape listener. */
102
+ const escapeListenerDocs = new WeakSet();
103
+ function installGlobalEscapeListener(doc) {
104
+ if (escapeListenerDocs.has(doc)) {
105
+ return;
106
+ }
107
+ escapeListenerDocs.add(doc);
108
+ doc.addEventListener('keydown', (e) => {
109
+ if (e.key !== 'Escape' || openPopovers.size === 0) {
110
+ return;
111
+ }
112
+ // Route to the most recently opened (last in Set iteration order)
113
+ const last = [...openPopovers].at(-1);
114
+ if (last?.closeOnEscape()) {
115
+ e.stopPropagation();
116
+ last.hide();
117
+ }
118
+ });
119
+ }
120
+ /** Tracks which Documents have already warned about missing Popover API. */
121
+ const popoverApiWarnedDocs = new WeakSet();
122
+ function warnMissingPopoverApi(el) {
123
+ const doc = el.ownerDocument;
124
+ if (popoverApiWarnedDocs.has(doc) || !isDevMode()) {
125
+ return;
126
+ }
127
+ if (typeof el.showPopover !== 'function') {
128
+ popoverApiWarnedDocs.add(doc);
129
+ console.warn('CngxPopover: The native Popover API is not supported in this browser. ' +
130
+ 'Install @oddbird/popover-polyfill and import it in your polyfills:\n\n' +
131
+ ' npm install @oddbird/popover-polyfill\n' +
132
+ ' // polyfills.ts\n' +
133
+ " import '@oddbird/popover-polyfill';\n");
134
+ }
135
+ }
136
+ /**
137
+ * Signal-driven state machine for the native Popover API.
138
+ *
139
+ * Wraps the browser's `popover` attribute with reactive state,
140
+ * CSS-transition-aware lifecycle, and CSS Anchor Positioning.
141
+ * Pure state machine — contains no trigger logic, no delays.
142
+ *
143
+ * State lifecycle: `closed` → `opening` → `open` → `closing` → `closed`.
144
+ * CSS classes `cngx-popover--opening`, `cngx-popover--open`, and
145
+ * `cngx-popover--closing` are applied to the host for transition hooks.
146
+ *
147
+ * ### Declarative click popover
148
+ * ```html
149
+ * <button [cngxPopoverTrigger]="pop" (click)="pop.toggle()">Menu</button>
150
+ * <div cngxPopover #pop="cngxPopover" placement="bottom-start">
151
+ * <menu><li>Edit</li><li>Delete</li></menu>
152
+ * </div>
153
+ * ```
154
+ *
155
+ * ### Controlled open state
156
+ * ```html
157
+ * <div cngxPopover [cngxPopoverOpen]="showErrors()" role="alert">
158
+ * {{ errorSummary() }}
159
+ * </div>
160
+ * ```
161
+ */
162
+ class CngxPopover {
163
+ /**
164
+ * Host ElementRef. Public for consumers that need to pass the
165
+ * popover's native element to APIs expecting an `ElementRef`
166
+ * (scroll observers, intersection observers, focus managers, …).
167
+ * Notable consumer: `injectRecycler({ scrollElement: pop.elementRef })`
168
+ * for `@cngx/forms/select` virtualisation — the popover IS the
169
+ * scroll container when `select-base.css`'s `max-height + overflow-y`
170
+ * rules apply.
171
+ */
172
+ elementRef = inject(ElementRef);
173
+ elRef = this.elementRef;
174
+ destroyRef = inject(DestroyRef);
175
+ doc = inject(DOCUMENT);
176
+ floatingFallback = inject(CNGX_FLOATING_FALLBACK, { optional: true });
177
+ /** Anchor-relative placement. */
178
+ placement = input('bottom', ...(ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []));
179
+ /** Gap between anchor and popover in px. */
180
+ offset = input(8, ...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []));
181
+ /** Whether Escape key dismisses the popover. */
182
+ closeOnEscape = input(true, ...(ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []));
183
+ /** Native popover mode. `'manual'` for full control, `'auto'` for browser light dismiss. */
184
+ mode = input('manual', ...(ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []));
185
+ /**
186
+ * Controlled open state. When set, drives the popover reactively.
187
+ * `undefined` = uncontrolled (default).
188
+ */
189
+ controlledOpen = input(undefined, { ...(ngDevMode ? { debugName: "controlledOpen" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverOpen' });
190
+ /**
191
+ * When `true` (default), opening this popover closes any other open
192
+ * `CngxPopover` instance. Set to `false` to allow multiple popovers
193
+ * open simultaneously.
194
+ */
195
+ exclusive = input(true, ...(ngDevMode ? [{ debugName: "exclusive" }] : /* istanbul ignore next */ []));
196
+ stateSignal = signal('closed', ...(ngDevMode ? [{ debugName: "stateSignal" }] : /* istanbul ignore next */ []));
197
+ idSignal = signal(nextUid('cngx-popover'), ...(ngDevMode ? [{ debugName: "idSignal" }] : /* istanbul ignore next */ []));
198
+ /** Current lifecycle state. */
199
+ state = this.stateSignal.asReadonly();
200
+ /** Unique auto-generated ID for this popover instance. */
201
+ id = this.idSignal.asReadonly();
202
+ /**
203
+ * The anchor element for Floating UI fallback positioning.
204
+ * Set by `CngxPopoverTrigger` or `CngxTooltip`.
205
+ */
206
+ anchorElement = signal(null, ...(ngDevMode ? [{ debugName: "anchorElement" }] : /* istanbul ignore next */ []));
207
+ isOpening = computed(() => this.stateSignal() === 'opening', ...(ngDevMode ? [{ debugName: "isOpening" }] : /* istanbul ignore next */ []));
208
+ isOpen = computed(() => this.stateSignal() === 'open', ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
209
+ isClosing = computed(() => this.stateSignal() === 'closing', ...(ngDevMode ? [{ debugName: "isClosing" }] : /* istanbul ignore next */ []));
210
+ isVisible = computed(() => this.stateSignal() !== 'closed', ...(ngDevMode ? [{ debugName: "isVisible" }] : /* istanbul ignore next */ []));
211
+ cssAnchorRef = computed(() => SUPPORTS_ANCHOR ? `--cngx-pop-${this.idSignal()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorRef" }] : /* istanbul ignore next */ []));
212
+ cssMargin = computed(() => (SUPPORTS_ANCHOR ? `${this.offset()}px` : null), ...(ngDevMode ? [{ debugName: "cssMargin" }] : /* istanbul ignore next */ []));
213
+ constructor() {
214
+ // Host binding needs a static property name; position-area/inset-area name flips per browser.
215
+ if (SUPPORTS_ANCHOR) {
216
+ effect(() => {
217
+ this.elRef.nativeElement.style.setProperty(ANCHOR_AREA_PROPERTY, POSITION_AREA[this.placement()]);
218
+ });
219
+ }
220
+ effect(() => {
221
+ const desired = this.controlledOpen();
222
+ if (desired === undefined) {
223
+ return;
224
+ }
225
+ const current = untracked(() => this.stateSignal());
226
+ if (desired && current === 'closed') {
227
+ this.show();
228
+ }
229
+ if (!desired && (current === 'open' || current === 'opening')) {
230
+ this.hide();
231
+ }
232
+ });
233
+ this.destroyRef.onDestroy(() => {
234
+ if (this.stateSignal() !== 'closed') {
235
+ this.finalize();
236
+ }
237
+ });
238
+ }
239
+ /** Open the popover. No-op if not `closed`. */
240
+ show() {
241
+ warnMissingPopoverApi(this.elRef.nativeElement);
242
+ if (this.stateSignal() !== 'closed') {
243
+ return;
244
+ }
245
+ if (this.exclusive()) {
246
+ for (const other of openPopovers) {
247
+ if (other !== this) {
248
+ other.hide();
249
+ }
250
+ }
251
+ }
252
+ openPopovers.add(this);
253
+ this.stateSignal.set('opening');
254
+ this.elRef.nativeElement.showPopover();
255
+ installGlobalEscapeListener(this.doc);
256
+ this.applyFloatingPosition();
257
+ requestAnimationFrame(() => {
258
+ if (this.stateSignal() === 'opening') {
259
+ this.stateSignal.set('open');
260
+ }
261
+ });
262
+ }
263
+ /** Close the popover. No-op if already `closed` or `closing`. */
264
+ hide() {
265
+ if (this.stateSignal() === 'closed' || this.stateSignal() === 'closing') {
266
+ return;
267
+ }
268
+ this.startClosing();
269
+ }
270
+ /** Toggle between open and closed. */
271
+ toggle() {
272
+ if (this.stateSignal() === 'closed') {
273
+ this.show();
274
+ }
275
+ else {
276
+ this.hide();
277
+ }
278
+ }
279
+ handleToggle(e) {
280
+ // Sync with browser when it closes the popover (e.g. popover="auto" light dismiss)
281
+ if (e.newState === 'closed' && this.stateSignal() !== 'closed') {
282
+ this.stateSignal.set('closed');
283
+ }
284
+ }
285
+ /**
286
+ * Apply Floating UI positioning when CSS Anchor is not supported
287
+ * and the consumer has provided the fallback via `provideFloatingFallback()`.
288
+ */
289
+ applyFloatingPosition() {
290
+ if (SUPPORTS_ANCHOR || !this.floatingFallback) {
291
+ return;
292
+ }
293
+ const anchor = this.anchorElement();
294
+ if (!anchor) {
295
+ return;
296
+ }
297
+ const fb = this.floatingFallback;
298
+ const el = this.popoverElement;
299
+ const placement = FLOATING_PLACEMENT[this.placement()];
300
+ const offsetVal = this.offset();
301
+ const middleware = fb.middleware ?? [];
302
+ void fb.computePosition(anchor, el, { placement, middleware }).then(({ x, y }) => {
303
+ el.style.left = `${x}px`;
304
+ el.style.top = `${y}px`;
305
+ el.style.margin = `${offsetVal}px`;
306
+ });
307
+ }
308
+ get popoverElement() {
309
+ return this.elRef.nativeElement;
310
+ }
311
+ startClosing() {
312
+ if (hasTransition(this.popoverElement)) {
313
+ this.stateSignal.set('closing');
314
+ onTransitionDone(this.popoverElement, () => this.finalize());
315
+ }
316
+ else {
317
+ this.finalize();
318
+ }
319
+ }
320
+ finalize() {
321
+ openPopovers.delete(this);
322
+ const el = this.popoverElement;
323
+ try {
324
+ el.hidePopover();
325
+ }
326
+ catch {
327
+ // Element may already be hidden or disconnected
328
+ }
329
+ this.stateSignal.set('closed');
330
+ }
331
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopover, deps: [], target: i0.ɵɵFactoryTarget.Directive });
332
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxPopover, isStandalone: true, selector: "[cngxPopover]", inputs: { placement: { classPropertyName: "placement", publicName: "placement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, mode: { classPropertyName: "mode", publicName: "mode", isSignal: true, isRequired: false, transformFunction: null }, controlledOpen: { classPropertyName: "controlledOpen", publicName: "cngxPopoverOpen", isSignal: true, isRequired: false, transformFunction: null }, exclusive: { classPropertyName: "exclusive", publicName: "exclusive", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "toggle": "handleToggle($event)" }, properties: { "attr.popover": "mode()", "id": "id()", "attr.aria-hidden": "!isVisible()", "class.cngx-popover--opening": "isOpening()", "class.cngx-popover--open": "isOpen()", "class.cngx-popover--closing": "isClosing()", "style.position-anchor": "cssAnchorRef()", "style.margin": "cssMargin()" } }, exportAs: ["cngxPopover"], ngImport: i0 });
333
+ }
334
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopover, decorators: [{
335
+ type: Directive,
336
+ args: [{
337
+ selector: '[cngxPopover]',
338
+ exportAs: 'cngxPopover',
339
+ standalone: true,
340
+ host: {
341
+ '[attr.popover]': 'mode()',
342
+ '[id]': 'id()',
343
+ '[attr.aria-hidden]': '!isVisible()',
344
+ '[class.cngx-popover--opening]': 'isOpening()',
345
+ '[class.cngx-popover--open]': 'isOpen()',
346
+ '[class.cngx-popover--closing]': 'isClosing()',
347
+ '[style.position-anchor]': 'cssAnchorRef()',
348
+ '[style.margin]': 'cssMargin()',
349
+ '(toggle)': 'handleToggle($event)',
350
+ },
351
+ }]
352
+ }], ctorParameters: () => [], propDecorators: { placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], mode: [{ type: i0.Input, args: [{ isSignal: true, alias: "mode", required: false }] }], controlledOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverOpen", required: false }] }], exclusive: [{ type: i0.Input, args: [{ isSignal: true, alias: "exclusive", required: false }] }] } });
353
+
354
+ /**
355
+ * ARIA wiring atom for elements that trigger a `CngxPopover`.
356
+ *
357
+ * Sets `aria-expanded`, `aria-controls`, and `aria-haspopup` based on the
358
+ * referenced popover's state. Also sets `anchor-name` for CSS Anchor
359
+ * Positioning and registers the anchor element on the popover for fallback
360
+ * positioning.
361
+ *
362
+ * Contains **no event handlers** — the consumer binds interactions directly:
363
+ *
364
+ * ```html
365
+ * <button [cngxPopoverTrigger]="pop" (click)="pop.toggle()">Menu</button>
366
+ * <div cngxPopover #pop="cngxPopover" placement="bottom-start">…</div>
367
+ * ```
368
+ */
369
+ class CngxPopoverTrigger {
370
+ elRef = inject(ElementRef);
371
+ /** Explicit reference to the popover this trigger controls. */
372
+ popoverRef = input.required({ ...(ngDevMode ? { debugName: "popoverRef" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverTrigger' });
373
+ /**
374
+ * ARIA haspopup value. Adjust to match the popover's role. Accepts
375
+ * the W3C-spec values for all supported popup-container roles:
376
+ * `'dialog'` for dialog popups, `'listbox'` for single/multi select
377
+ * panels, `'menu'` for menu surfaces, `'tree'` for treeview popups
378
+ * (CngxTreeSelect), or `'true'` when the role isn't meaningful.
379
+ */
380
+ haspopup = input('true', ...(ngDevMode ? [{ debugName: "haspopup" }] : /* istanbul ignore next */ []));
381
+ cssAnchorName = computed(() => SUPPORTS_ANCHOR ? `--cngx-pop-${this.popoverRef().id()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorName" }] : /* istanbul ignore next */ []));
382
+ constructor() {
383
+ // Register this element as the anchor for fallback positioning.
384
+ effect(() => {
385
+ const pop = this.popoverRef();
386
+ untracked(() => pop.anchorElement.set(this.elRef.nativeElement));
387
+ });
388
+ }
389
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive });
390
+ 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 }, haspopup: { classPropertyName: "haspopup", publicName: "haspopup", 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 });
391
+ }
392
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverTrigger, decorators: [{
393
+ type: Directive,
394
+ args: [{
395
+ selector: '[cngxPopoverTrigger]',
396
+ exportAs: 'cngxPopoverTrigger',
397
+ standalone: true,
398
+ host: {
399
+ '[attr.aria-expanded]': 'popoverRef().isVisible()',
400
+ '[attr.aria-controls]': 'popoverRef().id()',
401
+ '[attr.aria-haspopup]': 'haspopup()',
402
+ '[style.anchor-name]': 'cssAnchorName()',
403
+ },
404
+ }]
405
+ }], ctorParameters: () => [], propDecorators: { popoverRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverTrigger", required: true }] }], haspopup: [{ type: i0.Input, args: [{ isSignal: true, alias: "haspopup", required: false }] }] } });
406
+
407
+ /** Small debounce to prevent SR announcement storms during rapid Tab navigation. */
408
+ const FOCUS_DEBOUNCE_MS = 50;
409
+ /**
410
+ * String-input tooltip directive applied to the trigger element.
411
+ *
412
+ * Creates the tooltip popover element internally via `Renderer2` and manages
413
+ * the full lifecycle: hover/focus triggers, open/close delays, Escape dismiss,
414
+ * CSS Anchor Positioning, and ARIA wiring (`aria-describedby` + `role="tooltip"`).
415
+ *
416
+ * The consumer sees only the attribute — no extra elements in the template.
417
+ *
418
+ * ### Basic
419
+ * ```html
420
+ * <button cngxTooltip="Ctrl+S">Save</button>
421
+ * ```
422
+ *
423
+ * ### With configuration
424
+ * ```html
425
+ * <button cngxTooltip="Ctrl+S" tooltipPlacement="top" [tooltipDelay]="500">
426
+ * Save
427
+ * </button>
428
+ * ```
429
+ */
430
+ class CngxTooltip {
431
+ renderer = inject(Renderer2);
432
+ elRef = inject(ElementRef);
433
+ destroyRef = inject(DestroyRef);
434
+ floatingFallback = inject(CNGX_FLOATING_FALLBACK, { optional: true });
435
+ /** Tooltip text content. */
436
+ text = input.required({ ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'cngxTooltip' });
437
+ /** Anchor-relative placement. */
438
+ placement = input('top', { ...(ngDevMode ? { debugName: "placement" } : /* istanbul ignore next */ {}), alias: 'tooltipPlacement' });
439
+ /** Gap between trigger and tooltip in px. */
440
+ offset = input(8, { ...(ngDevMode ? { debugName: "offset" } : /* istanbul ignore next */ {}), alias: 'tooltipOffset' });
441
+ /** Delay in ms before opening on mouseenter. */
442
+ openDelay = input(300, { ...(ngDevMode ? { debugName: "openDelay" } : /* istanbul ignore next */ {}), alias: 'tooltipDelay' });
443
+ /** Delay in ms before closing on mouseleave. */
444
+ closeDelay = input(100, ...(ngDevMode ? [{ debugName: "closeDelay" }] : /* istanbul ignore next */ []));
445
+ /** Whether the tooltip is active. When `false`, no tooltip appears and ARIA is cleared. */
446
+ enabled = input(true, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
447
+ stateSignal = signal('closed', ...(ngDevMode ? [{ debugName: "stateSignal" }] : /* istanbul ignore next */ []));
448
+ idSignal = signal(nextUid('cngx-tooltip'), ...(ngDevMode ? [{ debugName: "idSignal" }] : /* istanbul ignore next */ []));
449
+ /** Current lifecycle state. */
450
+ state = this.stateSignal.asReadonly();
451
+ tooltipEl = null;
452
+ openTimer = null;
453
+ closeTimer = null;
454
+ ariaDescribedBy = computed(() => (this.enabled() ? this.idSignal() : null), ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
455
+ cssAnchorName = computed(() => SUPPORTS_ANCHOR ? `--cngx-tip-${this.idSignal()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorName" }] : /* istanbul ignore next */ []));
456
+ constructor() {
457
+ this.createTooltipElement();
458
+ effect(() => {
459
+ const text = this.text();
460
+ const el = untracked(() => this.tooltipEl);
461
+ if (el) {
462
+ el.textContent = text;
463
+ }
464
+ });
465
+ effect(() => {
466
+ const placement = this.placement();
467
+ const offset = this.offset();
468
+ const el = untracked(() => this.tooltipEl);
469
+ if (!el) {
470
+ return;
471
+ }
472
+ if (SUPPORTS_ANCHOR) {
473
+ el.style.setProperty('position-anchor', `--cngx-tip-${this.idSignal()}`);
474
+ el.style.setProperty(ANCHOR_AREA_PROPERTY, POSITION_AREA[placement]);
475
+ el.style.setProperty('margin', `${offset}px`);
476
+ }
477
+ });
478
+ effect(() => {
479
+ const enabled = this.enabled();
480
+ if (!enabled) {
481
+ const current = untracked(() => this.stateSignal());
482
+ if (current !== 'closed') {
483
+ this.hide();
484
+ }
485
+ }
486
+ });
487
+ this.destroyRef.onDestroy(() => {
488
+ this.clearTimers();
489
+ this.tooltipEl?.remove();
490
+ });
491
+ }
492
+ /** Show the tooltip immediately (bypassing delay). */
493
+ show() {
494
+ if (!this.enabled() || this.stateSignal() !== 'closed') {
495
+ return;
496
+ }
497
+ this.stateSignal.set('opening');
498
+ this.tooltipEl.showPopover();
499
+ this.applyFloatingPosition();
500
+ requestAnimationFrame(() => {
501
+ if (this.stateSignal() === 'opening') {
502
+ this.stateSignal.set('open');
503
+ }
504
+ });
505
+ }
506
+ /** Hide the tooltip immediately (bypassing delay). */
507
+ hide() {
508
+ if (this.stateSignal() === 'closed' || this.stateSignal() === 'closing') {
509
+ return;
510
+ }
511
+ this.clearTimers();
512
+ this.finalize();
513
+ }
514
+ handleMouseEnter() {
515
+ if (!this.enabled()) {
516
+ return;
517
+ }
518
+ this.clearCloseTimer();
519
+ const delay = this.openDelay();
520
+ if (delay > 0) {
521
+ this.openTimer = setTimeout(() => this.show(), delay);
522
+ }
523
+ else {
524
+ this.show();
525
+ }
526
+ }
527
+ handleMouseLeave() {
528
+ this.clearOpenTimer();
529
+ const delay = this.closeDelay();
530
+ if (delay > 0) {
531
+ this.closeTimer = setTimeout(() => this.hide(), delay);
532
+ }
533
+ else {
534
+ this.hide();
535
+ }
536
+ }
537
+ handleFocus() {
538
+ if (!this.enabled()) {
539
+ return;
540
+ }
541
+ // Debounce prevents SR announcement storm when user rapidly Tabs
542
+ // through a toolbar of tooltipped buttons.
543
+ this.clearTimers();
544
+ this.openTimer = setTimeout(() => this.show(), FOCUS_DEBOUNCE_MS);
545
+ }
546
+ handleBlur() {
547
+ this.clearTimers();
548
+ this.hide();
549
+ }
550
+ handleEscape(event) {
551
+ if (this.stateSignal() !== 'closed') {
552
+ // Prevent Escape from bubbling to parent overlays (e.g. dialog)
553
+ event.stopPropagation();
554
+ this.hide();
555
+ }
556
+ }
557
+ applyFloatingPosition() {
558
+ if (SUPPORTS_ANCHOR || !this.floatingFallback || !this.tooltipEl) {
559
+ return;
560
+ }
561
+ const fb = this.floatingFallback;
562
+ const trigger = this.elRef.nativeElement;
563
+ const tooltip = this.tooltipEl;
564
+ const placement = FLOATING_PLACEMENT[this.placement()];
565
+ const middleware = fb.middleware ?? [];
566
+ void fb.computePosition(trigger, tooltip, { placement, middleware }).then(({ x, y }) => {
567
+ tooltip.style.left = `${x}px`;
568
+ tooltip.style.top = `${y}px`;
569
+ });
570
+ }
571
+ createTooltipElement() {
572
+ const el = this.renderer.createElement('div');
573
+ el.setAttribute('popover', 'manual');
574
+ el.setAttribute('role', 'tooltip');
575
+ el.id = this.idSignal();
576
+ el.setAttribute('aria-hidden', 'true');
577
+ el.classList.add('cngx-tooltip');
578
+ // Insert as next sibling of the trigger for DOM proximity
579
+ const trigger = this.elRef.nativeElement;
580
+ if (trigger.parentElement) {
581
+ this.renderer.insertBefore(trigger.parentElement, el, trigger.nextSibling);
582
+ }
583
+ else {
584
+ this.renderer.appendChild(trigger, el);
585
+ }
586
+ this.tooltipEl = el;
587
+ }
588
+ finalize() {
589
+ if (this.tooltipEl) {
590
+ try {
591
+ this.tooltipEl.hidePopover();
592
+ }
593
+ catch {
594
+ // May already be hidden or disconnected
595
+ }
596
+ this.tooltipEl.setAttribute('aria-hidden', 'true');
597
+ }
598
+ this.stateSignal.set('closed');
599
+ }
600
+ clearTimers() {
601
+ this.clearOpenTimer();
602
+ this.clearCloseTimer();
603
+ }
604
+ clearOpenTimer() {
605
+ if (this.openTimer) {
606
+ clearTimeout(this.openTimer);
607
+ this.openTimer = null;
608
+ }
609
+ }
610
+ clearCloseTimer() {
611
+ if (this.closeTimer) {
612
+ clearTimeout(this.closeTimer);
613
+ this.closeTimer = null;
614
+ }
615
+ }
616
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive });
617
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxTooltip, isStandalone: true, selector: "[cngxTooltip]", inputs: { text: { classPropertyName: "text", publicName: "cngxTooltip", isSignal: true, isRequired: true, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "tooltipPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "tooltipOffset", isSignal: true, isRequired: false, transformFunction: null }, openDelay: { classPropertyName: "openDelay", publicName: "tooltipDelay", isSignal: true, isRequired: false, transformFunction: null }, closeDelay: { classPropertyName: "closeDelay", publicName: "closeDelay", isSignal: true, isRequired: false, transformFunction: null }, enabled: { classPropertyName: "enabled", publicName: "enabled", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "handleMouseEnter()", "mouseleave": "handleMouseLeave()", "focus": "handleFocus()", "blur": "handleBlur()", "keydown.escape": "handleEscape($event)" }, properties: { "attr.aria-describedby": "ariaDescribedBy()", "style.anchor-name": "cssAnchorName()" } }, exportAs: ["cngxTooltip"], hostDirectives: [{ directive: i1.CngxReducedMotion }], ngImport: i0 });
618
+ }
619
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTooltip, decorators: [{
620
+ type: Directive,
621
+ args: [{
622
+ selector: '[cngxTooltip]',
623
+ exportAs: 'cngxTooltip',
624
+ standalone: true,
625
+ hostDirectives: [CngxReducedMotion],
626
+ host: {
627
+ '[attr.aria-describedby]': 'ariaDescribedBy()',
628
+ '[style.anchor-name]': 'cssAnchorName()',
629
+ '(mouseenter)': 'handleMouseEnter()',
630
+ '(mouseleave)': 'handleMouseLeave()',
631
+ '(focus)': 'handleFocus()',
632
+ '(blur)': 'handleBlur()',
633
+ '(keydown.escape)': 'handleEscape($event)',
634
+ },
635
+ }]
636
+ }], 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 }] }] } });
637
+
638
+ /** Default configuration — no auto-dismiss, no close-on-success, variant='default'. */
639
+ const DEFAULT_CONFIG = {
640
+ defaultVariant: 'default',
641
+ };
642
+ /** Injection token for popover panel configuration. */
643
+ const CNGX_POPOVER_PANEL_CONFIG = new InjectionToken('CngxPopoverPanelConfig', { factory: () => DEFAULT_CONFIG });
644
+ /**
645
+ * Provides configuration for `CngxPopoverPanel` instances.
646
+ *
647
+ * ```typescript
648
+ * providers: [
649
+ * providePopoverPanel(
650
+ * withAutoDismiss({ info: 5000, success: 3000 }),
651
+ * withCloseOnSuccess(300),
652
+ * ),
653
+ * ]
654
+ * ```
655
+ */
656
+ function providePopoverPanel(...features) {
657
+ const config = features.reduce((acc, f) => f(acc), { ...DEFAULT_CONFIG });
658
+ return { provide: CNGX_POPOVER_PANEL_CONFIG, useValue: config };
659
+ }
660
+ /**
661
+ * Auto-dismiss the panel after a timeout, per variant.
662
+ *
663
+ * @param timing - Map of variant name to dismiss duration in ms.
664
+ * ```typescript
665
+ * withAutoDismiss({ info: 5000, success: 3000 })
666
+ * ```
667
+ */
668
+ function withAutoDismiss(timing) {
669
+ return (config) => ({ ...config, autoDismiss: { ...config.autoDismiss, ...timing } });
670
+ }
671
+ /**
672
+ * Auto-close the panel after an async action in the footer succeeds.
673
+ *
674
+ * @param delay - Delay in ms before closing. Defaults to `300`.
675
+ */
676
+ function withCloseOnSuccess(delay = 300) {
677
+ return (config) => ({ ...config, closeOnSuccessDelay: delay });
678
+ }
679
+ /**
680
+ * Set the default variant applied when no `variant` input is set.
681
+ */
682
+ function withDefaultVariant(variant) {
683
+ return (config) => ({ ...config, defaultVariant: variant });
684
+ }
685
+ /**
686
+ * Show the close button on all panels by default.
687
+ */
688
+ function withCloseButton(show = true) {
689
+ return (config) => ({ ...config, showClose: show });
690
+ }
691
+ /**
692
+ * Show the arrow on all panels by default.
693
+ */
694
+ function withArrow(show = true) {
695
+ return (config) => ({ ...config, showArrow: show });
696
+ }
697
+
698
+ /** Marks the header content inside `cngx-popover-panel`. */
699
+ class CngxPopoverHeader {
700
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
701
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverHeader, isStandalone: true, selector: "[cngxPopoverHeader]", ngImport: i0 });
702
+ }
703
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverHeader, decorators: [{
704
+ type: Directive,
705
+ args: [{ selector: '[cngxPopoverHeader]', standalone: true }]
706
+ }] });
707
+ /** Marks the body content inside `cngx-popover-panel`. */
708
+ class CngxPopoverBody {
709
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverBody, deps: [], target: i0.ɵɵFactoryTarget.Directive });
710
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverBody, isStandalone: true, selector: "[cngxPopoverBody]", ngImport: i0 });
711
+ }
712
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverBody, decorators: [{
713
+ type: Directive,
714
+ args: [{ selector: '[cngxPopoverBody]', standalone: true }]
715
+ }] });
716
+ /** Marks the footer content inside `cngx-popover-panel`. */
717
+ class CngxPopoverFooter {
718
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverFooter, deps: [], target: i0.ɵɵFactoryTarget.Directive });
719
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverFooter, isStandalone: true, selector: "[cngxPopoverFooter]", ngImport: i0 });
720
+ }
721
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverFooter, decorators: [{
722
+ type: Directive,
723
+ args: [{ selector: '[cngxPopoverFooter]', standalone: true }]
724
+ }] });
725
+ /**
726
+ * Custom close button template. Overrides the default close button.
727
+ *
728
+ * ```html
729
+ * <ng-template cngxPopoverClose>
730
+ * <button mat-icon-button (click)="panel.popover.hide()">
731
+ * <mat-icon>close</mat-icon>
732
+ * </button>
733
+ * </ng-template>
734
+ * ```
735
+ */
736
+ class CngxPopoverClose {
737
+ templateRef = inject(TemplateRef);
738
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverClose, deps: [], target: i0.ɵɵFactoryTarget.Directive });
739
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverClose, isStandalone: true, selector: "ng-template[cngxPopoverClose]", ngImport: i0 });
740
+ }
741
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverClose, decorators: [{
742
+ type: Directive,
743
+ args: [{ selector: 'ng-template[cngxPopoverClose]', standalone: true }]
744
+ }] });
745
+ /** Template shown while panel content is loading. */
746
+ class CngxPopoverLoading {
747
+ templateRef = inject(TemplateRef);
748
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverLoading, deps: [], target: i0.ɵɵFactoryTarget.Directive });
749
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverLoading, isStandalone: true, selector: "ng-template[cngxPopoverLoading]", ngImport: i0 });
750
+ }
751
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverLoading, decorators: [{
752
+ type: Directive,
753
+ args: [{ selector: 'ng-template[cngxPopoverLoading]', standalone: true }]
754
+ }] });
755
+ /** Template shown when panel content is empty. */
756
+ class CngxPopoverEmpty {
757
+ templateRef = inject(TemplateRef);
758
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
759
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverEmpty, isStandalone: true, selector: "ng-template[cngxPopoverEmpty]", ngImport: i0 });
760
+ }
761
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverEmpty, decorators: [{
762
+ type: Directive,
763
+ args: [{ selector: 'ng-template[cngxPopoverEmpty]', standalone: true }]
764
+ }] });
765
+ /** Template shown when panel content failed to load. Context: `$implicit` = error. */
766
+ class CngxPopoverError {
767
+ templateRef = inject(TemplateRef);
768
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
769
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverError, isStandalone: true, selector: "ng-template[cngxPopoverError]", ngImport: i0 });
770
+ }
771
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverError, decorators: [{
772
+ type: Directive,
773
+ args: [{ selector: 'ng-template[cngxPopoverError]', standalone: true }]
774
+ }] });
775
+
776
+ /**
777
+ * Rich popover panel molecule with header/body/footer slots, variant
778
+ * styling, arrow, close button, and content state templates.
779
+ *
780
+ * Composes `CngxPopover` via `hostDirectives` — all popover inputs
781
+ * (`placement`, `offset`, `closeOnEscape`, `mode`, `exclusive`,
782
+ * `cngxPopoverOpen`) are forwarded.
783
+ *
784
+ * The `variant` input is a free-form string mapped to a CSS class
785
+ * (`cngx-popover-panel--{variant}`). Five variants are pre-themed
786
+ * in `popover-panel-theme.scss`: `default`, `info`, `warning`,
787
+ * `danger`, `success`. Add custom variants via CSS.
788
+ *
789
+ * ### Basic with header/body/footer
790
+ * ```html
791
+ * <button [cngxPopoverTrigger]="panel" (click)="panel.popover.toggle()">Menu</button>
792
+ * <cngx-popover-panel #panel variant="danger" [showClose]="true" [showArrow]="true">
793
+ * <span cngxPopoverHeader>Delete Item?</span>
794
+ * <p cngxPopoverBody>This action cannot be undone.</p>
795
+ * <div cngxPopoverFooter>
796
+ * <cngx-popover-action role="dismiss">Cancel</cngx-popover-action>
797
+ * <cngx-popover-action role="confirm" [action]="delete" variant="danger">
798
+ * Delete
799
+ * </cngx-popover-action>
800
+ * </div>
801
+ * </cngx-popover-panel>
802
+ * ```
803
+ *
804
+ * ### With loading state
805
+ * ```html
806
+ * <cngx-popover-panel [loading]="isLoading()" [error]="loadError()">
807
+ * <p cngxPopoverBody>Loaded content here</p>
808
+ * <ng-template cngxPopoverLoading>Loading...</ng-template>
809
+ * <ng-template cngxPopoverError let-err>Failed: {{ err }}</ng-template>
810
+ * </cngx-popover-panel>
811
+ * ```
812
+ */
813
+ class CngxPopoverPanel {
814
+ /** The underlying popover state machine. */
815
+ popover = inject(CngxPopover, { self: true });
816
+ config = inject(CNGX_POPOVER_PANEL_CONFIG);
817
+ destroyRef = inject(DestroyRef);
818
+ /**
819
+ * Variant string — mapped to CSS class `cngx-popover-panel--{variant}`.
820
+ * Pre-themed: `default`, `info`, `warning`, `danger`, `success`.
821
+ * Add custom variants via CSS.
822
+ */
823
+ variant = input(undefined, ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
824
+ /** Show a close button. Falls back to global config from `providePopoverPanel(withCloseButton())`. */
825
+ showCloseInput = input(undefined, { ...(ngDevMode ? { debugName: "showCloseInput" } : /* istanbul ignore next */ {}), alias: 'showClose' });
826
+ /** Show an arrow. Falls back to global config from `providePopoverPanel(withArrow())`. */
827
+ showArrowInput = input(undefined, { ...(ngDevMode ? { debugName: "showArrowInput" } : /* istanbul ignore next */ {}), alias: 'showArrow' });
828
+ /** Resolved showClose — input takes precedence over config. */
829
+ showClose = computed(() => this.showCloseInput() ?? this.config.showClose ?? false, ...(ngDevMode ? [{ debugName: "showClose" }] : /* istanbul ignore next */ []));
830
+ /** Resolved showArrow — input takes precedence over config. */
831
+ showArrow = computed(() => this.showArrowInput() ?? this.config.showArrow ?? false, ...(ngDevMode ? [{ debugName: "showArrow" }] : /* istanbul ignore next */ []));
832
+ /**
833
+ * Bind an async state — drives loading, error, and empty slots from a single source.
834
+ * When set, takes precedence over individual `[loading]`, `[error]`, `[empty]` inputs.
835
+ */
836
+ state = input(undefined, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
837
+ /** Whether the panel content is in a loading state. Fallback when `[state]` is not set. */
838
+ loading = input(false, ...(ngDevMode ? [{ debugName: "loading" }] : /* istanbul ignore next */ []));
839
+ /** Error value when content loading failed. Fallback when `[state]` is not set. */
840
+ error = input(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
841
+ /** Whether the panel content is empty. Fallback when `[state]` is not set. */
842
+ empty = input(false, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
843
+ /** @internal Resolved loading — state takes precedence over boolean input. */
844
+ effectiveLoading = computed(() => this.state()?.isFirstLoad() ?? this.loading(), ...(ngDevMode ? [{ debugName: "effectiveLoading" }] : /* istanbul ignore next */ []));
845
+ /** @internal Resolved error — state takes precedence over direct input. */
846
+ effectiveError = computed(() => this.state()?.error() ?? this.error(), ...(ngDevMode ? [{ debugName: "effectiveError" }] : /* istanbul ignore next */ []));
847
+ /** @internal Resolved empty — state takes precedence over boolean input. */
848
+ effectiveEmpty = computed(() => this.state()?.isEmpty() ?? this.empty(), ...(ngDevMode ? [{ debugName: "effectiveEmpty" }] : /* istanbul ignore next */ []));
849
+ /** Whether the header slot has projected content. */
850
+ hasHeader = input(true, ...(ngDevMode ? [{ debugName: "hasHeader" }] : /* istanbul ignore next */ []));
851
+ /** Whether the footer slot has projected content. */
852
+ hasFooter = input(false, ...(ngDevMode ? [{ debugName: "hasFooter" }] : /* istanbul ignore next */ []));
853
+ closeTpl = contentChild(CngxPopoverClose, ...(ngDevMode ? [{ debugName: "closeTpl" }] : /* istanbul ignore next */ []));
854
+ loadingTpl = contentChild(CngxPopoverLoading, ...(ngDevMode ? [{ debugName: "loadingTpl" }] : /* istanbul ignore next */ []));
855
+ emptyTpl = contentChild(CngxPopoverEmpty, ...(ngDevMode ? [{ debugName: "emptyTpl" }] : /* istanbul ignore next */ []));
856
+ errorTpl = contentChild(CngxPopoverError, ...(ngDevMode ? [{ debugName: "errorTpl" }] : /* istanbul ignore next */ []));
857
+ uid = nextUid('cngx-pp');
858
+ headerId = `${this.uid}-header`;
859
+ bodyId = `${this.uid}-body`;
860
+ /** Only point to body when default content is showing (not loading/error/empty). */
861
+ ariaDescribedBy = computed(() => this.effectiveLoading() || this.effectiveError() || this.effectiveEmpty() ? null : this.bodyId, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
862
+ hostClass = computed(() => {
863
+ const v = this.variant() ?? this.config.defaultVariant ?? 'default';
864
+ let cls = `cngx-popover-panel cngx-popover-panel--${v}`;
865
+ if (this.showArrow()) {
866
+ cls += ' cngx-popover-panel--arrow';
867
+ }
868
+ return cls;
869
+ }, ...(ngDevMode ? [{ debugName: "hostClass" }] : /* istanbul ignore next */ []));
870
+ autoDismissTimer = null;
871
+ constructor() {
872
+ effect(() => {
873
+ const isVisible = this.popover.isVisible();
874
+ const v = this.variant() ?? untracked(() => this.config.defaultVariant) ?? 'default';
875
+ const timing = untracked(() => this.config.autoDismiss);
876
+ if (this.autoDismissTimer) {
877
+ clearTimeout(this.autoDismissTimer);
878
+ this.autoDismissTimer = null;
879
+ }
880
+ if (isVisible && timing?.[v]) {
881
+ this.autoDismissTimer = setTimeout(() => this.popover.hide(), timing[v]);
882
+ }
883
+ else if (!isVisible && this.autoDismissTimer) {
884
+ clearTimeout(this.autoDismissTimer);
885
+ this.autoDismissTimer = null;
886
+ }
887
+ });
888
+ this.destroyRef.onDestroy(() => {
889
+ if (this.autoDismissTimer) {
890
+ clearTimeout(this.autoDismissTimer);
891
+ }
892
+ });
893
+ }
894
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverPanel, deps: [], target: i0.ɵɵFactoryTarget.Component });
895
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxPopoverPanel, isStandalone: true, selector: "cngx-popover-panel", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, showCloseInput: { classPropertyName: "showCloseInput", publicName: "showClose", isSignal: true, isRequired: false, transformFunction: null }, showArrowInput: { classPropertyName: "showArrowInput", publicName: "showArrow", isSignal: true, isRequired: false, transformFunction: null }, state: { classPropertyName: "state", publicName: "state", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, error: { classPropertyName: "error", publicName: "error", isSignal: true, isRequired: false, transformFunction: null }, empty: { classPropertyName: "empty", publicName: "empty", isSignal: true, isRequired: false, transformFunction: null }, hasHeader: { classPropertyName: "hasHeader", publicName: "hasHeader", isSignal: true, isRequired: false, transformFunction: null }, hasFooter: { classPropertyName: "hasFooter", publicName: "hasFooter", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClass()", "attr.aria-labelledby": "headerId", "attr.aria-describedby": "ariaDescribedBy()", "attr.aria-busy": "effectiveLoading() || null" } }, queries: [{ propertyName: "closeTpl", first: true, predicate: CngxPopoverClose, descendants: true, isSignal: true }, { propertyName: "loadingTpl", first: true, predicate: CngxPopoverLoading, descendants: true, isSignal: true }, { propertyName: "emptyTpl", first: true, predicate: CngxPopoverEmpty, descendants: true, isSignal: true }, { propertyName: "errorTpl", first: true, predicate: CngxPopoverError, descendants: true, isSignal: true }], exportAs: ["cngxPopoverPanel"], hostDirectives: [{ directive: CngxPopover, inputs: ["placement", "placement", "offset", "offset", "closeOnEscape", "closeOnEscape", "mode", "mode", "exclusive", "exclusive", "cngxPopoverOpen", "cngxPopoverOpen"] }], ngImport: i0, template: `
896
+ @if (showArrow()) {
897
+ <div class="cngx-popover-panel__arrow"></div>
898
+ }
899
+
900
+ @if (effectiveLoading()) {
901
+ @if (loadingTpl(); as tpl) {
902
+ <div class="cngx-popover-panel__loading">
903
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
904
+ </div>
905
+ }
906
+ } @else if (effectiveError(); as err) {
907
+ @if (errorTpl(); as tpl) {
908
+ <div class="cngx-popover-panel__error">
909
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: { $implicit: err }" />
910
+ </div>
911
+ }
912
+ } @else if (effectiveEmpty()) {
913
+ @if (emptyTpl(); as tpl) {
914
+ <div class="cngx-popover-panel__empty">
915
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
916
+ </div>
917
+ }
918
+ } @else {
919
+ @if (hasHeader() || showClose()) {
920
+ <div class="cngx-popover-panel__header-row">
921
+ <div class="cngx-popover-panel__header" [id]="headerId">
922
+ <ng-content select="[cngxPopoverHeader]" />
923
+ </div>
924
+ @if (showClose()) {
925
+ @if (closeTpl(); as tpl) {
926
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
927
+ } @else {
928
+ <cngx-close-button
929
+ label="Close"
930
+ class="cngx-popover-panel__close"
931
+ (click)="popover.hide()"
932
+ />
933
+ }
934
+ }
935
+ </div>
936
+ }
937
+ <div class="cngx-popover-panel__body" [id]="bodyId">
938
+ <ng-content select="[cngxPopoverBody]" />
939
+ <ng-content />
940
+ </div>
941
+ @if (hasFooter()) {
942
+ <div class="cngx-popover-panel__footer">
943
+ <ng-content select="[cngxPopoverFooter]" />
944
+ </div>
945
+ }
946
+ }
947
+ `, isInline: true, dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CngxCloseButton, selector: "cngx-close-button", inputs: ["label"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
948
+ }
949
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverPanel, decorators: [{
950
+ type: Component,
951
+ args: [{
952
+ selector: 'cngx-popover-panel',
953
+ standalone: true,
954
+ imports: [NgTemplateOutlet, CngxCloseButton],
955
+ changeDetection: ChangeDetectionStrategy.OnPush,
956
+ encapsulation: ViewEncapsulation.None,
957
+ exportAs: 'cngxPopoverPanel',
958
+ hostDirectives: [
959
+ {
960
+ directive: CngxPopover,
961
+ inputs: ['placement', 'offset', 'closeOnEscape', 'mode', 'exclusive', 'cngxPopoverOpen'],
962
+ },
963
+ ],
964
+ host: {
965
+ '[class]': 'hostClass()',
966
+ '[attr.aria-labelledby]': 'headerId',
967
+ '[attr.aria-describedby]': 'ariaDescribedBy()',
968
+ '[attr.aria-busy]': 'effectiveLoading() || null',
969
+ },
970
+ template: `
971
+ @if (showArrow()) {
972
+ <div class="cngx-popover-panel__arrow"></div>
973
+ }
974
+
975
+ @if (effectiveLoading()) {
976
+ @if (loadingTpl(); as tpl) {
977
+ <div class="cngx-popover-panel__loading">
978
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
979
+ </div>
980
+ }
981
+ } @else if (effectiveError(); as err) {
982
+ @if (errorTpl(); as tpl) {
983
+ <div class="cngx-popover-panel__error">
984
+ <ng-container *ngTemplateOutlet="tpl.templateRef; context: { $implicit: err }" />
985
+ </div>
986
+ }
987
+ } @else if (effectiveEmpty()) {
988
+ @if (emptyTpl(); as tpl) {
989
+ <div class="cngx-popover-panel__empty">
990
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
991
+ </div>
992
+ }
993
+ } @else {
994
+ @if (hasHeader() || showClose()) {
995
+ <div class="cngx-popover-panel__header-row">
996
+ <div class="cngx-popover-panel__header" [id]="headerId">
997
+ <ng-content select="[cngxPopoverHeader]" />
998
+ </div>
999
+ @if (showClose()) {
1000
+ @if (closeTpl(); as tpl) {
1001
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
1002
+ } @else {
1003
+ <cngx-close-button
1004
+ label="Close"
1005
+ class="cngx-popover-panel__close"
1006
+ (click)="popover.hide()"
1007
+ />
1008
+ }
1009
+ }
1010
+ </div>
1011
+ }
1012
+ <div class="cngx-popover-panel__body" [id]="bodyId">
1013
+ <ng-content select="[cngxPopoverBody]" />
1014
+ <ng-content />
1015
+ </div>
1016
+ @if (hasFooter()) {
1017
+ <div class="cngx-popover-panel__footer">
1018
+ <ng-content select="[cngxPopoverFooter]" />
1019
+ </div>
1020
+ }
1021
+ }
1022
+ `,
1023
+ }]
1024
+ }], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], showCloseInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "showClose", required: false }] }], showArrowInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "showArrow", required: false }] }], state: [{ type: i0.Input, args: [{ isSignal: true, alias: "state", required: false }] }], loading: [{ type: i0.Input, args: [{ isSignal: true, alias: "loading", required: false }] }], error: [{ type: i0.Input, args: [{ isSignal: true, alias: "error", required: false }] }], empty: [{ type: i0.Input, args: [{ isSignal: true, alias: "empty", required: false }] }], hasHeader: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasHeader", required: false }] }], hasFooter: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasFooter", required: false }] }], closeTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverClose), { isSignal: true }] }], loadingTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverLoading), { isSignal: true }] }], emptyTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverEmpty), { isSignal: true }] }], errorTpl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverError), { isSignal: true }] }] } });
1025
+
1026
+ /**
1027
+ * Action button for use inside `cngx-popover-panel` footer.
1028
+ *
1029
+ * Two roles:
1030
+ * - `'dismiss'` — closes the panel on click (no async action).
1031
+ * - `'confirm'` — executes an async action, shows status templates,
1032
+ * optionally auto-closes the panel on success.
1033
+ *
1034
+ * Supports the same `cngxPending`/`cngxSucceeded`/`cngxFailed` templates
1035
+ * as `CngxActionButton`, or use `status()` + `@switch` for full control.
1036
+ *
1037
+ * ### Dismiss button
1038
+ * ```html
1039
+ * <cngx-popover-action role="dismiss">Cancel</cngx-popover-action>
1040
+ * ```
1041
+ *
1042
+ * ### Confirm with templates
1043
+ * ```html
1044
+ * <cngx-popover-action role="confirm" [action]="save" variant="primary">
1045
+ * Save
1046
+ * <ng-template cngxPending>Saving...</ng-template>
1047
+ * <ng-template cngxSucceeded>Saved!</ng-template>
1048
+ * <ng-template cngxFailed let-err>{{ err }}</ng-template>
1049
+ * </cngx-popover-action>
1050
+ * ```
1051
+ *
1052
+ * ### With @switch
1053
+ * ```html
1054
+ * <cngx-popover-action role="confirm" [action]="save" #act="cngxPopoverAction">
1055
+ * @switch (act.status()) {
1056
+ * @case ('pending') { Saving... }
1057
+ * @case ('success') { Done }
1058
+ * @default { Save }
1059
+ * }
1060
+ * </cngx-popover-action>
1061
+ * ```
1062
+ */
1063
+ class CngxPopoverAction {
1064
+ popover = inject(CngxPopover, { optional: true });
1065
+ /** Button role: `'dismiss'` closes immediately, `'confirm'` runs an async action. */
1066
+ role = input('confirm', ...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
1067
+ /** The async action to execute (only for `role="confirm"`). */
1068
+ action = input(undefined, ...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
1069
+ /** Visual variant for the button. */
1070
+ variant = input('secondary', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
1071
+ /** Duration in ms to show success/error feedback. */
1072
+ feedbackDuration = input(2000, ...(ngDevMode ? [{ debugName: "feedbackDuration" }] : /* istanbul ignore next */ []));
1073
+ pendingTpl = contentChild(CngxPending, ...(ngDevMode ? [{ debugName: "pendingTpl" }] : /* istanbul ignore next */ []));
1074
+ succeededTpl = contentChild(CngxSucceeded, ...(ngDevMode ? [{ debugName: "succeededTpl" }] : /* istanbul ignore next */ []));
1075
+ failedTpl = contentChild(CngxFailed, ...(ngDevMode ? [{ debugName: "failedTpl" }] : /* istanbul ignore next */ []));
1076
+ handleDismiss() {
1077
+ this.popover?.hide();
1078
+ }
1079
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverAction, deps: [], target: i0.ɵɵFactoryTarget.Component });
1080
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.4", type: CngxPopoverAction, isStandalone: true, selector: "cngx-popover-action", inputs: { role: { classPropertyName: "role", publicName: "role", isSignal: true, isRequired: false, transformFunction: null }, action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: false, transformFunction: null }, variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, feedbackDuration: { classPropertyName: "feedbackDuration", publicName: "feedbackDuration", isSignal: true, isRequired: false, transformFunction: null } }, host: { styleAttribute: "display: contents" }, queries: [{ propertyName: "pendingTpl", first: true, predicate: CngxPending, descendants: true, isSignal: true }, { propertyName: "succeededTpl", first: true, predicate: CngxSucceeded, descendants: true, isSignal: true }, { propertyName: "failedTpl", first: true, predicate: CngxFailed, descendants: true, isSignal: true }], exportAs: ["cngxPopoverAction"], ngImport: i0, template: `
1081
+ <ng-template #idle><ng-content /></ng-template>
1082
+
1083
+ @if (role() === 'dismiss') {
1084
+ <button
1085
+ type="button"
1086
+ [class]="'cngx-popover-action cngx-popover-action--' + variant()"
1087
+ (click)="handleDismiss()"
1088
+ >
1089
+ <ng-container *ngTemplateOutlet="idle" />
1090
+ </button>
1091
+ } @else {
1092
+ <button
1093
+ type="button"
1094
+ [cngxAsyncClick]="action()!"
1095
+ #btn="cngxAsyncClick"
1096
+ [feedbackDuration]="feedbackDuration()"
1097
+ [class]="'cngx-popover-action cngx-popover-action--' + variant()"
1098
+ >
1099
+ @switch (btn.status()) {
1100
+ @case ('pending') {
1101
+ @if (pendingTpl(); as tpl) {
1102
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
1103
+ } @else {
1104
+ <ng-container *ngTemplateOutlet="idle" />
1105
+ }
1106
+ }
1107
+ @case ('success') {
1108
+ @if (succeededTpl(); as tpl) {
1109
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
1110
+ } @else {
1111
+ <ng-container *ngTemplateOutlet="idle" />
1112
+ }
1113
+ }
1114
+ @case ('error') {
1115
+ @if (failedTpl(); as tpl) {
1116
+ <ng-container
1117
+ *ngTemplateOutlet="tpl.templateRef; context: { $implicit: btn.error() }"
1118
+ />
1119
+ } @else {
1120
+ <ng-container *ngTemplateOutlet="idle" />
1121
+ }
1122
+ }
1123
+ @default {
1124
+ <ng-container *ngTemplateOutlet="idle" />
1125
+ }
1126
+ }
1127
+ </button>
1128
+ <span aria-live="polite" aria-atomic="true" class="cngx-popover-action__sr-only">
1129
+ {{ btn.announcement() }}
1130
+ </span>
1131
+ }
1132
+ `, isInline: true, styles: [".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}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: CngxAsyncClick, selector: "[cngxAsyncClick]", inputs: ["cngxAsyncClick", "feedbackDuration", "enabled", "succeededAnnouncement", "failedAnnouncement"], exportAs: ["cngxAsyncClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
1133
+ }
1134
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverAction, decorators: [{
1135
+ type: Component,
1136
+ args: [{ selector: 'cngx-popover-action', standalone: true, imports: [NgTemplateOutlet, CngxAsyncClick], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxPopoverAction', host: { style: 'display: contents' }, template: `
1137
+ <ng-template #idle><ng-content /></ng-template>
1138
+
1139
+ @if (role() === 'dismiss') {
1140
+ <button
1141
+ type="button"
1142
+ [class]="'cngx-popover-action cngx-popover-action--' + variant()"
1143
+ (click)="handleDismiss()"
1144
+ >
1145
+ <ng-container *ngTemplateOutlet="idle" />
1146
+ </button>
1147
+ } @else {
1148
+ <button
1149
+ type="button"
1150
+ [cngxAsyncClick]="action()!"
1151
+ #btn="cngxAsyncClick"
1152
+ [feedbackDuration]="feedbackDuration()"
1153
+ [class]="'cngx-popover-action cngx-popover-action--' + variant()"
1154
+ >
1155
+ @switch (btn.status()) {
1156
+ @case ('pending') {
1157
+ @if (pendingTpl(); as tpl) {
1158
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
1159
+ } @else {
1160
+ <ng-container *ngTemplateOutlet="idle" />
1161
+ }
1162
+ }
1163
+ @case ('success') {
1164
+ @if (succeededTpl(); as tpl) {
1165
+ <ng-container *ngTemplateOutlet="tpl.templateRef" />
1166
+ } @else {
1167
+ <ng-container *ngTemplateOutlet="idle" />
1168
+ }
1169
+ }
1170
+ @case ('error') {
1171
+ @if (failedTpl(); as tpl) {
1172
+ <ng-container
1173
+ *ngTemplateOutlet="tpl.templateRef; context: { $implicit: btn.error() }"
1174
+ />
1175
+ } @else {
1176
+ <ng-container *ngTemplateOutlet="idle" />
1177
+ }
1178
+ }
1179
+ @default {
1180
+ <ng-container *ngTemplateOutlet="idle" />
1181
+ }
1182
+ }
1183
+ </button>
1184
+ <span aria-live="polite" aria-atomic="true" class="cngx-popover-action__sr-only">
1185
+ {{ btn.announcement() }}
1186
+ </span>
1187
+ }
1188
+ `, styles: [".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}\n"] }]
1189
+ }], 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 }] }] } });
1190
+
1191
+ /**
1192
+ * @module @cngx/common/popover
1193
+ */
1194
+
1195
+ /**
1196
+ * Generated bundle index. Do not edit.
1197
+ */
1198
+
1199
+ export { CNGX_FLOATING_FALLBACK, CNGX_POPOVER_PANEL_CONFIG, CngxPopover, CngxPopoverAction, CngxPopoverBody, CngxPopoverClose, CngxPopoverEmpty, CngxPopoverError, CngxPopoverFooter, CngxPopoverHeader, CngxPopoverLoading, CngxPopoverPanel, CngxPopoverTrigger, CngxTooltip, provideFloatingFallback, providePopoverPanel, withArrow, withAutoDismiss, withCloseButton, withCloseOnSuccess, withDefaultVariant };
1200
+ //# sourceMappingURL=cngx-common-popover.mjs.map