@cngx/common 0.1.0-rc.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/a11y/README.md +15 -2
- package/button/README.md +258 -0
- package/command/README.md +42 -2
- package/data/README.md +15 -12
- package/fesm2022/cngx-common-a11y.mjs +1076 -319
- package/fesm2022/cngx-common-a11y.mjs.map +1 -1
- package/fesm2022/cngx-common-audio.mjs +99 -77
- package/fesm2022/cngx-common-audio.mjs.map +1 -1
- package/fesm2022/cngx-common-button.mjs +1084 -0
- package/fesm2022/cngx-common-button.mjs.map +1 -0
- package/fesm2022/cngx-common-card.mjs +138 -78
- package/fesm2022/cngx-common-card.mjs.map +1 -1
- package/fesm2022/cngx-common-chart.mjs +799 -327
- package/fesm2022/cngx-common-chart.mjs.map +1 -1
- package/fesm2022/cngx-common-command.mjs +101 -25
- package/fesm2022/cngx-common-command.mjs.map +1 -1
- package/fesm2022/cngx-common-data.mjs +861 -423
- package/fesm2022/cngx-common-data.mjs.map +1 -1
- package/fesm2022/cngx-common-dialog.mjs +198 -160
- package/fesm2022/cngx-common-dialog.mjs.map +1 -1
- package/fesm2022/cngx-common-display.mjs +693 -329
- package/fesm2022/cngx-common-display.mjs.map +1 -1
- package/fesm2022/cngx-common-interactive.mjs +7303 -2774
- package/fesm2022/cngx-common-interactive.mjs.map +1 -1
- package/fesm2022/cngx-common-layout.mjs +2174 -442
- package/fesm2022/cngx-common-layout.mjs.map +1 -1
- package/fesm2022/cngx-common-menu-button.mjs +557 -0
- package/fesm2022/cngx-common-menu-button.mjs.map +1 -0
- package/fesm2022/cngx-common-popover.mjs +2109 -557
- package/fesm2022/cngx-common-popover.mjs.map +1 -1
- package/fesm2022/cngx-common-stepper.mjs +548 -419
- package/fesm2022/cngx-common-stepper.mjs.map +1 -1
- package/fesm2022/cngx-common-tabs.mjs +442 -331
- package/fesm2022/cngx-common-tabs.mjs.map +1 -1
- package/fesm2022/cngx-common-timeline.mjs +44 -71
- package/fesm2022/cngx-common-timeline.mjs.map +1 -1
- package/fesm2022/cngx-common.mjs +10 -10
- package/fesm2022/cngx-common.mjs.map +1 -1
- package/interactive/README.md +30 -19
- package/layout/README.md +17 -1
- package/menu-button/README.md +234 -0
- package/package.json +31 -8
- package/popover/README.md +81 -4
- package/popover/tooltip-indicator.scss +52 -0
- package/schematics/collection.json +9 -0
- package/schematics/ng-add/index.js +9 -0
- package/schematics/ng-add/schema.json +96 -0
- package/schematics/package.json +3 -0
- package/stepper/README.md +5 -5
- package/theming/components/cngx-accordion.css +36 -7
- package/theming/components/cngx-async.css +185 -37
- package/theming/components/cngx-backdrop.css +3 -1
- package/theming/components/cngx-badge.css +20 -5
- package/theming/components/cngx-bottom-sheet.css +2 -0
- package/theming/components/cngx-breadcrumb.css +3 -1
- package/theming/components/cngx-button-group.css +325 -0
- package/theming/components/cngx-button-toggle.css +55 -23
- package/theming/components/cngx-button.css +975 -0
- package/theming/components/cngx-data-grid.css +2 -0
- package/theming/components/cngx-dialog.css +3 -1
- package/theming/components/cngx-divider.css +24 -9
- package/theming/components/cngx-drawer.css +153 -0
- package/theming/components/cngx-icon-glyph.css +76 -0
- package/theming/components/cngx-listbox.css +79 -25
- package/theming/components/cngx-menu.css +112 -52
- package/theming/components/cngx-nav.css +1220 -0
- package/theming/components/cngx-popover-sheet.css +434 -0
- package/theming/components/cngx-popover.css +37 -9
- package/theming/components/cngx-recycler-placeholder.css +2 -0
- package/theming/components/cngx-ripple.css +74 -16
- package/theming/components/cngx-sidebar.css +71 -0
- package/theming/components/cngx-slider.css +3 -1
- package/theming/components/cngx-tooltip.css +2 -0
- package/timeline/README.md +2 -2
- package/types/cngx-common-a11y.d.ts +488 -112
- package/types/cngx-common-audio.d.ts +60 -88
- package/types/cngx-common-button.d.ts +698 -0
- package/types/cngx-common-card.d.ts +104 -78
- package/types/cngx-common-chart.d.ts +677 -389
- package/types/cngx-common-command.d.ts +55 -41
- package/types/cngx-common-data.d.ts +506 -360
- package/types/cngx-common-dialog.d.ts +94 -127
- package/types/cngx-common-display.d.ts +475 -300
- package/types/cngx-common-interactive.d.ts +4383 -1721
- package/types/cngx-common-layout.d.ts +1399 -288
- package/types/cngx-common-menu-button.d.ts +382 -0
- package/types/cngx-common-popover.d.ts +990 -268
- package/types/cngx-common-stepper.d.ts +374 -465
- package/types/cngx-common-tabs.d.ts +309 -403
- package/types/cngx-common-timeline.d.ts +50 -109
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { DOCUMENT, NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken,
|
|
3
|
+
import { InjectionToken, untracked, computed, inject, ElementRef, DestroyRef, Injector, input, output, signal, effect, Directive, Renderer2, HostAttributeToken, afterNextRender, TemplateRef, contentChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
5
|
import { fromEvent } from 'rxjs';
|
|
6
|
-
import { injectDirection } from '@cngx/core';
|
|
7
|
-
import { nextUid, createSlotRegistry, hasTransition, onTransitionDone, createOverrideMerge } from '@cngx/core/utils';
|
|
6
|
+
import { injectDirection, injectEffectiveMotion } from '@cngx/core';
|
|
7
|
+
import { createKeyedRegistry, nextUid, coerceSignal, createSlotRegistry, hasTransition, onTransitionDone, injectDescribedByContribution, createDescribedByRegistry, createCloseWatcher, createTransitionTracker, createOverrideMerge, injectLazySelf } from '@cngx/core/utils';
|
|
8
|
+
import { cngxDevWarn, CngxRuntimeError } from '@cngx/utils';
|
|
8
9
|
import * as i1 from '@cngx/common/a11y';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { 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 * as i2 from '@cngx/common/interactive';
|
|
14
|
+
import { CngxSwipeDismiss, CNGX_ACTION_STATUS, CNGX_ANNOUNCEMENT_COVER, CngxActionStatusStack, CngxAsyncClick, CngxActionStatusBrain } from '@cngx/common/interactive';
|
|
15
|
+
import * as i1$1 from '@cngx/common/button';
|
|
16
|
+
import { CngxCloseButton, CngxButtonBrain, CngxButtonStart, CngxButtonEnd, CngxButtonAdornment, provideButtonHost, provideActionStatusHost } from '@cngx/common/button';
|
|
17
|
+
import { resolveAsyncView } from '@cngx/common/data';
|
|
11
18
|
import { createLanguageSection } from '@cngx/core/i18n';
|
|
12
|
-
import * as i1$
|
|
19
|
+
import * as i1$2 from '@cngx/common/display';
|
|
13
20
|
import { CngxDivider } from '@cngx/common/display';
|
|
14
21
|
|
|
15
22
|
/**
|
|
@@ -201,19 +208,63 @@ function resolveFloatingPlacement(placement, direction) {
|
|
|
201
208
|
/**
|
|
202
209
|
* Injection token for the arrow-bounds contract.
|
|
203
210
|
*
|
|
204
|
-
* @category common/popover
|
|
205
211
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-arrow-bounds.ts
|
|
206
|
-
* @since 0.
|
|
212
|
+
* @since 0.3.0
|
|
207
213
|
*/
|
|
208
214
|
const CNGX_POPOVER_ARROW_BOUNDS = new InjectionToken('CngxPopoverArrowBounds');
|
|
209
215
|
|
|
216
|
+
/**
|
|
217
|
+
* @internal Creates an owner-keyed claim map: several composers can hint the
|
|
218
|
+
* same popover, the last live claim wins, and a release only removes the
|
|
219
|
+
* releasing owner's claim, so a co-composer's hint survives it. Built on
|
|
220
|
+
* `createKeyedRegistry`, so every removal goes through its guarded
|
|
221
|
+
* unregister path.
|
|
222
|
+
*
|
|
223
|
+
* `claim` and `release` run untracked: composers call them from effects, and
|
|
224
|
+
* the registry reads its own state on write. The registry stays unnamed: its
|
|
225
|
+
* name only labels the collision warning, and `claim` releases the owner's
|
|
226
|
+
* previous entry first, so a key never collides.
|
|
227
|
+
*/
|
|
228
|
+
function createPopoverHintClaims() {
|
|
229
|
+
const registry = createKeyedRegistry();
|
|
230
|
+
const keys = new WeakMap();
|
|
231
|
+
const keyFor = (owner) => {
|
|
232
|
+
let key = keys.get(owner);
|
|
233
|
+
if (key === undefined) {
|
|
234
|
+
key = nextUid('cngx-popover-claim');
|
|
235
|
+
keys.set(owner, key);
|
|
236
|
+
}
|
|
237
|
+
return key;
|
|
238
|
+
};
|
|
239
|
+
const release = (owner) => {
|
|
240
|
+
const key = keys.get(owner);
|
|
241
|
+
if (key === undefined) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
untracked(() => {
|
|
245
|
+
const held = registry.get(key);
|
|
246
|
+
if (held) {
|
|
247
|
+
registry.unregister(key, held);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
const claim = (owner, value) => {
|
|
252
|
+
release(owner);
|
|
253
|
+
untracked(() => registry.register(keyFor(owner), { value }));
|
|
254
|
+
};
|
|
255
|
+
const current = computed(() => registry.values().at(-1)?.value, ...(ngDevMode ? [{ debugName: "current" }] : /* istanbul ignore next */ []));
|
|
256
|
+
return { current, claim, release };
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** @internal Resolved by `CngxPopover` on its own element only (`self: true`). */
|
|
260
|
+
const CNGX_POPOVER_PRESENTATION = new InjectionToken('CngxPopoverPresentation');
|
|
261
|
+
|
|
210
262
|
/**
|
|
211
263
|
* Injection token for the Floating UI fallback.
|
|
212
264
|
* `null` when not provided - CSS Anchor Positioning is used instead.
|
|
213
265
|
*
|
|
214
|
-
* @category common/popover
|
|
215
266
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/floating-fallback.ts
|
|
216
|
-
* @since 0.
|
|
267
|
+
* @since 0.3.0
|
|
217
268
|
*/
|
|
218
269
|
const CNGX_FLOATING_FALLBACK = new InjectionToken('CngxFloatingFallback', { factory: () => null });
|
|
219
270
|
/**
|
|
@@ -231,8 +282,6 @@ const CNGX_FLOATING_FALLBACK = new InjectionToken('CngxFloatingFallback', { fact
|
|
|
231
282
|
* provideFloatingFallback(computePosition, [flip(), shift()]),
|
|
232
283
|
* ]
|
|
233
284
|
* ```
|
|
234
|
-
*
|
|
235
|
-
* @category common/popover
|
|
236
285
|
*/
|
|
237
286
|
function provideFloatingFallback(computePosition, middleware) {
|
|
238
287
|
return {
|
|
@@ -356,6 +405,13 @@ const FLOATING_PLACEMENT = {
|
|
|
356
405
|
* @internal Module-level registry of open popovers (insertion-ordered).
|
|
357
406
|
*/
|
|
358
407
|
const openPopovers = new Set();
|
|
408
|
+
function setOrRemoveStyle(style, property, value) {
|
|
409
|
+
if (value === null) {
|
|
410
|
+
style.removeProperty(property);
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
style.setProperty(property, value);
|
|
414
|
+
}
|
|
359
415
|
/**
|
|
360
416
|
* @internal
|
|
361
417
|
* Derive the panel's actual placement relative to the trigger from the live
|
|
@@ -397,7 +453,7 @@ function installGlobalEscapeListener(doc) {
|
|
|
397
453
|
}
|
|
398
454
|
// most-recently-opened wins (relies on Set's insertion-order iteration)
|
|
399
455
|
const last = [...openPopovers].at(-1);
|
|
400
|
-
if (last?.
|
|
456
|
+
if (last?.escapeEnabled()) {
|
|
401
457
|
e.stopPropagation();
|
|
402
458
|
last.hide();
|
|
403
459
|
}
|
|
@@ -424,15 +480,26 @@ function installGlobalOutsideClickListener(doc) {
|
|
|
424
480
|
}
|
|
425
481
|
/** @internal Tracks which Documents have already warned about missing Popover API. */
|
|
426
482
|
const popoverApiWarnedDocs = new WeakSet();
|
|
427
|
-
/**
|
|
428
|
-
|
|
483
|
+
/**
|
|
484
|
+
* @internal - test hook. Resets the per-Document warning suppression so
|
|
485
|
+
* specs can exercise the warning path against a shared jsdom Document.
|
|
486
|
+
* Do not call from production code.
|
|
487
|
+
*/
|
|
488
|
+
function __resetPopoverApiWarnings(doc) {
|
|
489
|
+
popoverApiWarnedDocs.delete(doc);
|
|
490
|
+
}
|
|
491
|
+
/** @internal Shared with `CngxTooltip`, which opens its own popover element. */
|
|
492
|
+
function warnMissingPopoverApi(el, owner) {
|
|
493
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
429
496
|
const doc = el.ownerDocument;
|
|
430
|
-
if (popoverApiWarnedDocs.has(doc)
|
|
497
|
+
if (popoverApiWarnedDocs.has(doc)) {
|
|
431
498
|
return;
|
|
432
499
|
}
|
|
433
500
|
if (typeof el.showPopover !== 'function') {
|
|
434
501
|
popoverApiWarnedDocs.add(doc);
|
|
435
|
-
|
|
502
|
+
cngxDevWarn('CNGX1036', `[${owner}] the native Popover API is not supported in this browser. ` +
|
|
436
503
|
'Install @oddbird/popover-polyfill and import it in your polyfills:\n\n' +
|
|
437
504
|
' npm install @oddbird/popover-polyfill\n' +
|
|
438
505
|
' // polyfills.ts\n' +
|
|
@@ -451,11 +518,14 @@ function __resetFloatingMiddlewareWarnings(doc) {
|
|
|
451
518
|
}
|
|
452
519
|
/** @internal */
|
|
453
520
|
function warnMissingFloatingMiddleware(doc) {
|
|
454
|
-
if (
|
|
521
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
522
|
+
return;
|
|
523
|
+
}
|
|
524
|
+
if (floatingMiddlewareWarnedDocs.has(doc)) {
|
|
455
525
|
return;
|
|
456
526
|
}
|
|
457
527
|
floatingMiddlewareWarnedDocs.add(doc);
|
|
458
|
-
|
|
528
|
+
cngxDevWarn('CNGX1037', '[cngxPopover] provideFloatingFallback(computePosition) was registered without middleware. ' +
|
|
459
529
|
'Popovers in browsers without CSS Anchor Positioning will clip against the viewport edge ' +
|
|
460
530
|
'because no flip/shift recovery is configured. Pass middleware on registration:\n\n' +
|
|
461
531
|
" import { computePosition, flip, shift } from '@floating-ui/dom';\n\n" +
|
|
@@ -473,6 +543,8 @@ function warnMissingFloatingMiddleware(doc) {
|
|
|
473
543
|
* State lifecycle: `closed` → `opening` → `open` → `closing` → `closed`.
|
|
474
544
|
* CSS classes `cngx-popover--opening`, `cngx-popover--open`, and
|
|
475
545
|
* `cngx-popover--closing` are applied to the host for transition hooks.
|
|
546
|
+
* The host is `inert` while `closing`, so a reader and a pointer skip a
|
|
547
|
+
* panel that is fading out.
|
|
476
548
|
*
|
|
477
549
|
* ### Declarative click popover
|
|
478
550
|
* ```html
|
|
@@ -488,11 +560,11 @@ function warnMissingFloatingMiddleware(doc) {
|
|
|
488
560
|
* {{ errorSummary() }}
|
|
489
561
|
* </div>
|
|
490
562
|
* ```
|
|
491
|
-
* <example-url
|
|
492
|
-
* <example-url
|
|
493
|
-
* <example-url
|
|
494
|
-
* <example-url
|
|
495
|
-
* <example-url
|
|
563
|
+
* <example-url>/#/common/interactive/listbox/trigger/select-dropdown</example-url>
|
|
564
|
+
* <example-url>/#/common/popover/click-popover</example-url>
|
|
565
|
+
* <example-url>/#/common/popover/controlled-open</example-url>
|
|
566
|
+
* <example-url>/#/common/popover/escape-mode</example-url>
|
|
567
|
+
* <example-url>/#/common/popover/placement-variants</example-url>
|
|
496
568
|
*
|
|
497
569
|
* ### Collision recovery with `<try-tactic>` fallbacks
|
|
498
570
|
* Apply CSS Anchor Positioning's `position-try-fallbacks` declaratively
|
|
@@ -513,12 +585,11 @@ function warnMissingFloatingMiddleware(doc) {
|
|
|
513
585
|
* `position-try-fallbacks` style - the browser positions the popover at
|
|
514
586
|
* the declared `placement` regardless of viewport clipping.
|
|
515
587
|
*
|
|
516
|
-
* @category common/popover
|
|
517
|
-
* @docsKind primary
|
|
518
588
|
* @wcag AA
|
|
519
589
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover.directive.ts
|
|
520
|
-
* @since 0.
|
|
590
|
+
* @since 0.3.0
|
|
521
591
|
* @relatedTo CngxPopoverTrigger, CngxPopoverPanel, CngxTooltip
|
|
592
|
+
* @axis level molecule
|
|
522
593
|
*/
|
|
523
594
|
class CngxPopover {
|
|
524
595
|
/**
|
|
@@ -540,6 +611,10 @@ class CngxPopover {
|
|
|
540
611
|
// Armed while a close transition runs; cancelled on destroy so the
|
|
541
612
|
// transitionend listener and fallback timer never outlive the directive.
|
|
542
613
|
pendingClose = null;
|
|
614
|
+
// The close fade sets inert on the host only when the host is not inert
|
|
615
|
+
// already: an open modal sheet may hold an inert claim on it as a page
|
|
616
|
+
// sibling, and the end of the fade must not drop that claim.
|
|
617
|
+
ownsFadeInert = false;
|
|
543
618
|
/**
|
|
544
619
|
* Arrow-bounds contract resolved lazily on first use.
|
|
545
620
|
* Eager inject() would loop: CngxPopover (host directive on the panel)
|
|
@@ -553,23 +628,60 @@ class CngxPopover {
|
|
|
553
628
|
}
|
|
554
629
|
return this._arrowBounds;
|
|
555
630
|
}
|
|
631
|
+
/**
|
|
632
|
+
* Presentation seam resolved lazily on first use, same reason as
|
|
633
|
+
* {@link getArrowBounds}: the modifier providing it constructs after this
|
|
634
|
+
* directive. `self: true` keeps a popover nested inside a sheet's host from
|
|
635
|
+
* picking up the outer sheet's seam.
|
|
636
|
+
*/
|
|
637
|
+
_presentationSeam = undefined;
|
|
638
|
+
presentationSeam() {
|
|
639
|
+
if (this._presentationSeam === undefined) {
|
|
640
|
+
this._presentationSeam = this._injector.get(CNGX_POPOVER_PRESENTATION, null, {
|
|
641
|
+
self: true,
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
return this._presentationSeam;
|
|
645
|
+
}
|
|
646
|
+
/**
|
|
647
|
+
* `false` while a presentation modifier lays the panel out as a sheet or
|
|
648
|
+
* fullscreen. Gates every anchor, margin, fallback and floating write:
|
|
649
|
+
* inline styles beat author CSS, so the sheet stylesheet cannot win
|
|
650
|
+
* against them.
|
|
651
|
+
*/
|
|
652
|
+
anchored = computed(() => (this.presentationSeam()?.presentation() ?? 'anchored') === 'anchored', ...(ngDevMode ? [{ debugName: "anchored" }] : /* istanbul ignore next */ []));
|
|
653
|
+
// Re-entrancy guard for hide(): a hide() / toggle() from inside the
|
|
654
|
+
// seam's onHide() must not start a second close.
|
|
655
|
+
hiding = false;
|
|
556
656
|
/** Anchor-relative placement. */
|
|
557
657
|
placement = input('bottom', ...(ngDevMode ? [{ debugName: "placement" }] : /* istanbul ignore next */ []));
|
|
558
658
|
/**
|
|
559
|
-
* CSS `<try-tactic>` fallbacks for `position-try-fallbacks`.
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
659
|
+
* CSS `<try-tactic>` fallbacks for `position-try-fallbacks`. Unbound
|
|
660
|
+
* (default) defers to a composer claim ({@link claimPositionTryFallbacks},
|
|
661
|
+
* a menu trigger claims a flip chain), else writes nothing. A bound
|
|
662
|
+
* empty array writes nothing and opts out of every claim. Non-empty
|
|
663
|
+
* entries are written verbatim, comma-joined, in declaration order.
|
|
664
|
+
* Spec-compatible vocabulary only (no cngx placement tokens).
|
|
563
665
|
*/
|
|
564
|
-
positionTryFallbacks = input(
|
|
666
|
+
positionTryFallbacks = input(undefined, ...(ngDevMode ? [{ debugName: "positionTryFallbacks" }] : /* istanbul ignore next */ []));
|
|
565
667
|
/**
|
|
566
668
|
* Gap between anchor and popover in px, on the placement's main axis
|
|
567
669
|
* (block axis for `top` / `bottom`, inline axis for `left` / `right`);
|
|
568
670
|
* the cross axis stays flush. Same on both positioning engines.
|
|
569
671
|
*/
|
|
570
672
|
offset = input(8, ...(ngDevMode ? [{ debugName: "offset" }] : /* istanbul ignore next */ []));
|
|
571
|
-
/**
|
|
673
|
+
/**
|
|
674
|
+
* Whether Escape key dismisses the popover. Bind a `Signal<boolean>` (not
|
|
675
|
+
* its value) when the gate flips inside an event handler: the popover then
|
|
676
|
+
* reads it at keydown time, so an Escape right after the flip, before the
|
|
677
|
+
* next change detection, already sees the new value.
|
|
678
|
+
*/
|
|
572
679
|
closeOnEscape = input(true, ...(ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []));
|
|
680
|
+
/**
|
|
681
|
+
* Current Escape gate, resolved from {@link closeOnEscape}. Read it instead
|
|
682
|
+
* of the input: a bound signal is read live.
|
|
683
|
+
*/
|
|
684
|
+
escapeEnabled = computed(() => coerceSignal(this.closeOnEscape())(), ...(ngDevMode ? [{ debugName: "escapeEnabled" }] : /* istanbul ignore next */ []));
|
|
573
685
|
/**
|
|
574
686
|
* Whether a `pointerdown` outside both the popover and its anchor (trigger)
|
|
575
687
|
* dismisses it - menu / listbox light-dismiss. Opt-in (default `false`) so
|
|
@@ -596,6 +708,20 @@ class CngxPopover {
|
|
|
596
708
|
* never evicts its ancestor.
|
|
597
709
|
*/
|
|
598
710
|
exclusive = input(true, ...(ngDevMode ? [{ debugName: "exclusive" }] : /* istanbul ignore next */ []));
|
|
711
|
+
/**
|
|
712
|
+
* Emits once each time the popover opens: at the end of `show()`, in the
|
|
713
|
+
* caller's task, after the native `showPopover()` call. A `show()` that
|
|
714
|
+
* returns early (already open, no Popover API) emits nothing. Bind it to
|
|
715
|
+
* react to the open as an event instead of watching `state` in an effect.
|
|
716
|
+
*/
|
|
717
|
+
opened = output();
|
|
718
|
+
/**
|
|
719
|
+
* Emits once each time the popover reaches `closed`: after `hide()` (at
|
|
720
|
+
* the end of the exit transition when there is one) and after the
|
|
721
|
+
* browser's own light dismiss. A no-op `hide()` and the teardown on
|
|
722
|
+
* destroy emit nothing.
|
|
723
|
+
*/
|
|
724
|
+
closed = output();
|
|
599
725
|
/**
|
|
600
726
|
* Programmatic override of {@link exclusive}. `null` (default) defers to the
|
|
601
727
|
* `[exclusive]` input; a boolean wins over it. Lets a composing organism
|
|
@@ -648,7 +774,8 @@ class CngxPopover {
|
|
|
648
774
|
/**
|
|
649
775
|
* Programmatic override of {@link positionTryFallbacks}, paired with
|
|
650
776
|
* {@link placementOverride} so a submenu wiring installs the flip chain too.
|
|
651
|
-
* `null` (default) defers to the `[positionTryFallbacks]` input
|
|
777
|
+
* `null` (default) defers to the `[positionTryFallbacks]` input, then to
|
|
778
|
+
* the last live composer claim ({@link claimPositionTryFallbacks}).
|
|
652
779
|
*/
|
|
653
780
|
positionTryFallbacksOverrideState = signal(null, ...(ngDevMode ? [{ debugName: "positionTryFallbacksOverrideState" }] : /* istanbul ignore next */ []));
|
|
654
781
|
/**
|
|
@@ -656,8 +783,16 @@ class CngxPopover {
|
|
|
656
783
|
* override. Written via {@link setPositionTryFallbacksOverride}.
|
|
657
784
|
*/
|
|
658
785
|
positionTryFallbacksOverride = this.positionTryFallbacksOverrideState.asReadonly();
|
|
659
|
-
/**
|
|
660
|
-
|
|
786
|
+
/** Owner-keyed claims behind the composer default of {@link positionTryFallbacks}. */
|
|
787
|
+
positionTryFallbacksClaims = createPopoverHintClaims();
|
|
788
|
+
/**
|
|
789
|
+
* Effective try-fallbacks: the override, else the `[positionTryFallbacks]`
|
|
790
|
+
* input, else the last live composer claim, else none.
|
|
791
|
+
*/
|
|
792
|
+
effectivePositionTryFallbacks = computed(() => this.positionTryFallbacksOverride() ??
|
|
793
|
+
this.positionTryFallbacks() ??
|
|
794
|
+
this.positionTryFallbacksClaims.current() ??
|
|
795
|
+
[], ...(ngDevMode ? [{ debugName: "effectivePositionTryFallbacks" }] : /* istanbul ignore next */ []));
|
|
661
796
|
stateSignal = signal('closed', ...(ngDevMode ? [{ debugName: "stateSignal" }] : /* istanbul ignore next */ []));
|
|
662
797
|
idSignal = signal(nextUid('cngx-popover'), ...(ngDevMode ? [{ debugName: "idSignal" }] : /* istanbul ignore next */ []));
|
|
663
798
|
/** Current lifecycle state. */
|
|
@@ -674,11 +809,24 @@ class CngxPopover {
|
|
|
674
809
|
* target; cleared on finalize.
|
|
675
810
|
*/
|
|
676
811
|
focusOrigin = this.focusOriginState.asReadonly();
|
|
812
|
+
/**
|
|
813
|
+
* @internal Single close-listener slot, claimed by `CngxPopoverTrigger`
|
|
814
|
+
* through {@link registerCloseListener}. Last registration wins, like the
|
|
815
|
+
* implicit anchor slot: one trigger per popover.
|
|
816
|
+
*/
|
|
817
|
+
closeListenerSlot = createSlotRegistry();
|
|
677
818
|
/**
|
|
678
819
|
* Implicit anchor slot, written by `CngxPopoverTrigger` and composing
|
|
679
820
|
* organisms via {@link setAnchorElement}.
|
|
680
821
|
*/
|
|
681
822
|
anchorElementState = signal(null, ...(ngDevMode ? [{ debugName: "anchorElementState" }] : /* istanbul ignore next */ []));
|
|
823
|
+
/**
|
|
824
|
+
* @internal The implicit anchor ({@link setAnchorElement}) even while an
|
|
825
|
+
* explicit anchor shadows it. Read by `CngxPopoverSheet` only: its focus
|
|
826
|
+
* fallback needs a focusable opener when the explicit anchor is a
|
|
827
|
+
* non-focusable box.
|
|
828
|
+
*/
|
|
829
|
+
implicitAnchorElement = this.anchorElementState.asReadonly();
|
|
682
830
|
/** Explicit anchor slot, claimed by `CngxPopoverAnchor`. */
|
|
683
831
|
explicitAnchorElementSlot = createSlotRegistry();
|
|
684
832
|
/**
|
|
@@ -717,22 +865,49 @@ class CngxPopover {
|
|
|
717
865
|
* `cngxPopoverArrow` template use this to render their own glyph at
|
|
718
866
|
* the same coordinate the default arrow ornament would.
|
|
719
867
|
*/
|
|
720
|
-
arrowOffset = this._arrowOffset
|
|
721
|
-
/**
|
|
722
|
-
|
|
868
|
+
arrowOffset = computed(() => (this.anchored() ? this._arrowOffset() : null), ...(ngDevMode ? [{ debugName: "arrowOffset" }] : /* istanbul ignore next */ []));
|
|
869
|
+
/** Owner-keyed claims behind {@link haspopup}. */
|
|
870
|
+
haspopupClaims = createPopoverHintClaims();
|
|
723
871
|
/**
|
|
724
872
|
* Hint for the `CngxPopoverTrigger`'s `aria-haspopup` value. Composers
|
|
725
|
-
* such as `CngxPopoverPanel`
|
|
873
|
+
* such as `CngxPopoverPanel` claim it via {@link claimHaspopup} so any
|
|
726
874
|
* trigger pointing at the popover defaults to the right role without
|
|
727
|
-
* the consumer having to set `haspopup` on every trigger element.
|
|
728
|
-
*
|
|
875
|
+
* the consumer having to set `haspopup` on every trigger element. With
|
|
876
|
+
* several composers the last live claim wins, and a release keeps the
|
|
877
|
+
* others. Consumer-supplied `haspopup` on the trigger still wins.
|
|
878
|
+
*/
|
|
879
|
+
haspopup = computed(() =>
|
|
880
|
+
// A sheet or fullscreen presentation is a modal dialog, whatever a
|
|
881
|
+
// composer claimed for the anchored layout.
|
|
882
|
+
this.anchored() ? this.haspopupClaims.current() : 'dialog', ...(ngDevMode ? [{ debugName: "haspopup" }] : /* istanbul ignore next */ []));
|
|
883
|
+
/** Owner-keyed claims behind {@link controlsHint}: each holds an id source. */
|
|
884
|
+
controlsClaims = createPopoverHintClaims();
|
|
885
|
+
/**
|
|
886
|
+
* Hint for the `CngxPopoverTrigger`'s `aria-controls` value: the id of the
|
|
887
|
+
* popup element inside the popover (a `role="menu"`), read from the source
|
|
888
|
+
* a composer claims via {@link claimControls}. Derived, so a change of
|
|
889
|
+
* that source id reaches every trigger without another claim. The last
|
|
890
|
+
* live claim wins. `null` in a sheet or fullscreen presentation, where the
|
|
891
|
+
* popup is the dialog itself, so the trigger names the popover. A
|
|
892
|
+
* `controls` bound on the trigger still wins.
|
|
893
|
+
*/
|
|
894
|
+
controlsHint = computed(() => this.anchored() ? (this.controlsClaims.current()?.() ?? null) : null, ...(ngDevMode ? [{ debugName: "controlsHint" }] : /* istanbul ignore next */ []));
|
|
895
|
+
/** Owner-keyed claims behind {@link restoreFocusHint}. */
|
|
896
|
+
restoreFocusClaims = createPopoverHintClaims();
|
|
897
|
+
/**
|
|
898
|
+
* Hint for the `CngxPopoverTrigger`'s focus return on close, used when the
|
|
899
|
+
* trigger binds no `[restoreFocus]`. Composers claim it via
|
|
900
|
+
* {@link claimRestoreFocus}: `CngxPopoverPanel` claims `true` (dialog
|
|
901
|
+
* pattern), a menu trigger claims `false` because its focus stack restores.
|
|
902
|
+
* The last live claim wins. `false` in a sheet or fullscreen presentation,
|
|
903
|
+
* where `CngxPopoverSheet` restores focus itself.
|
|
729
904
|
*/
|
|
730
|
-
|
|
905
|
+
restoreFocusHint = computed(() => this.anchored() ? this.restoreFocusClaims.current() : false, ...(ngDevMode ? [{ debugName: "restoreFocusHint" }] : /* istanbul ignore next */ []));
|
|
731
906
|
isOpening = computed(() => this.stateSignal() === 'opening', ...(ngDevMode ? [{ debugName: "isOpening" }] : /* istanbul ignore next */ []));
|
|
732
907
|
isOpen = computed(() => this.stateSignal() === 'open', ...(ngDevMode ? [{ debugName: "isOpen" }] : /* istanbul ignore next */ []));
|
|
733
908
|
isClosing = computed(() => this.stateSignal() === 'closing', ...(ngDevMode ? [{ debugName: "isClosing" }] : /* istanbul ignore next */ []));
|
|
734
909
|
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 */ []));
|
|
910
|
+
cssAnchorRef = computed(() => SUPPORTS_ANCHOR && this.anchored() ? `--cngx-pop-${this.idSignal()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorRef" }] : /* istanbul ignore next */ []));
|
|
736
911
|
/**
|
|
737
912
|
* Primary edge of the placement, written from the live trigger and panel
|
|
738
913
|
* rects so the arrow lands on the side that actually faces the trigger.
|
|
@@ -749,43 +924,79 @@ class CngxPopover {
|
|
|
749
924
|
* so consumers projecting a `cngxPopoverArrow` template can rotate
|
|
750
925
|
* their own glyph to match the rendered placement.
|
|
751
926
|
*/
|
|
752
|
-
resolvedEdge = computed(() => this.
|
|
753
|
-
|
|
927
|
+
resolvedEdge = computed(() => (this.anchored() ? this.resolvedEdgeSignal() : null) ??
|
|
928
|
+
this.effectivePlacement().split('-')[0], ...(ngDevMode ? [{ debugName: "resolvedEdge" }] : /* istanbul ignore next */ []));
|
|
929
|
+
cssMargin = computed(() => SUPPORTS_ANCHOR && this.anchored()
|
|
930
|
+
? resolveAnchorMargin(this.effectivePlacement(), this.offset())
|
|
931
|
+
: null, ...(ngDevMode ? [{ debugName: "cssMargin" }] : /* istanbul ignore next */ []));
|
|
932
|
+
/**
|
|
933
|
+
* The same offset as one length, for `calc()` consumers: the margin above
|
|
934
|
+
* is a shorthand (`8px 0`) and cannot be multiplied. The sheet skin caps
|
|
935
|
+
* an anchored sheet with it.
|
|
936
|
+
*/
|
|
937
|
+
cssOffset = computed(() => SUPPORTS_ANCHOR && this.anchored() ? `${this.offset()}px` : null, ...(ngDevMode ? [{ debugName: "cssOffset" }] : /* istanbul ignore next */ []));
|
|
754
938
|
/**
|
|
755
939
|
* Comma-joined `position-try-fallbacks` value, or `null` to skip the
|
|
756
|
-
* style write.
|
|
757
|
-
* property cleanly. Unsupported browsers ignore the unknown
|
|
758
|
-
* gating on `SUPPORTS_ANCHOR` would only suppress a harmless write.
|
|
940
|
+
* style write. Written by `writeAnchorPlacement()` so empty / cleared lists
|
|
941
|
+
* drop the property cleanly. Unsupported browsers ignore the unknown
|
|
942
|
+
* property - gating on `SUPPORTS_ANCHOR` would only suppress a harmless write.
|
|
759
943
|
*/
|
|
760
944
|
cssPositionTryFallbacks = computed(() => {
|
|
945
|
+
if (!this.anchored()) {
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
761
948
|
const list = this.effectivePositionTryFallbacks();
|
|
762
949
|
return list.length > 0 ? list.join(', ') : null;
|
|
763
950
|
}, ...(ngDevMode ? [{ debugName: "cssPositionTryFallbacks" }] : /* istanbul ignore next */ []));
|
|
764
951
|
constructor() {
|
|
765
|
-
//
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
952
|
+
// One writer for the placement-derived anchor styles: this effect and
|
|
953
|
+
// show(), which must not wait for change detection before showPopover().
|
|
954
|
+
effect(() => this.writeAnchorPlacement());
|
|
955
|
+
// A presentation flip while open: leaving the anchored layout stops the
|
|
956
|
+
// floating engine (the arrow geometry is gated in its computeds); coming
|
|
957
|
+
// back re-positions right away instead of waiting for the next scroll or
|
|
958
|
+
// resize.
|
|
959
|
+
effect(() => {
|
|
960
|
+
const anchored = this.anchored();
|
|
961
|
+
untracked(() => {
|
|
962
|
+
if (this.stateSignal() === 'closed') {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
if (!anchored) {
|
|
966
|
+
this.floatingPositioner?.stop();
|
|
967
|
+
this.clearFloatingPosition();
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
this.applyFloatingPosition();
|
|
971
|
+
this.cancelArrowFrame();
|
|
972
|
+
this.arrowFrame = requestAnimationFrame(() => {
|
|
973
|
+
this.arrowFrame = null;
|
|
974
|
+
this.updateArrowOffset();
|
|
975
|
+
});
|
|
769
976
|
});
|
|
770
|
-
}
|
|
977
|
+
});
|
|
978
|
+
this.destroyRef.onDestroy(() => this.cancelArrowFrame());
|
|
771
979
|
effect(() => {
|
|
772
980
|
const desired = this.controlledOpen();
|
|
773
981
|
if (desired === undefined) {
|
|
774
982
|
return;
|
|
775
983
|
}
|
|
984
|
+
// show()/hide() read state, exclusivity, anchoring and the seam; none
|
|
985
|
+
// of those may become a dependency - only `controlledOpen` drives this.
|
|
776
986
|
const current = untracked(() => this.stateSignal());
|
|
777
987
|
if (desired && current === 'closed') {
|
|
778
|
-
this.show();
|
|
988
|
+
untracked(() => this.show());
|
|
779
989
|
}
|
|
780
990
|
if (!desired && (current === 'open' || current === 'opening')) {
|
|
781
|
-
this.hide();
|
|
991
|
+
untracked(() => this.hide());
|
|
782
992
|
}
|
|
783
993
|
});
|
|
784
994
|
this.destroyRef.onDestroy(() => {
|
|
785
995
|
// finalize() disarms pendingClose; a 'closed' state means it already
|
|
786
|
-
// ran and the handle is gone.
|
|
996
|
+
// ran and the handle is gone. An output cannot emit on a destroyed
|
|
997
|
+
// directive, so the teardown close stays silent.
|
|
787
998
|
if (this.stateSignal() !== 'closed') {
|
|
788
|
-
this.finalize();
|
|
999
|
+
this.finalize(false);
|
|
789
1000
|
}
|
|
790
1001
|
});
|
|
791
1002
|
// Recompute arrow offset on viewport resize while the popover is open.
|
|
@@ -804,10 +1015,18 @@ class CngxPopover {
|
|
|
804
1015
|
}
|
|
805
1016
|
/** Open the popover. No-op if not `closed`. */
|
|
806
1017
|
show() {
|
|
807
|
-
|
|
1018
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1019
|
+
warnMissingPopoverApi(this.elRef.nativeElement, 'cngxPopover');
|
|
1020
|
+
}
|
|
808
1021
|
if (this.stateSignal() !== 'closed') {
|
|
809
1022
|
return;
|
|
810
1023
|
}
|
|
1024
|
+
// Without the native Popover API (no polyfill) the open cannot happen.
|
|
1025
|
+
// Bail before any state change, so the popover stays closed and can open
|
|
1026
|
+
// once a polyfill lands instead of latching in 'opening'.
|
|
1027
|
+
if (typeof this.elRef.nativeElement.showPopover !== 'function') {
|
|
1028
|
+
return;
|
|
1029
|
+
}
|
|
811
1030
|
// Snapshot the pre-open focus target before showPopover() runs -
|
|
812
1031
|
// autofocus content inside the panel lands right after that call,
|
|
813
1032
|
// and a post-CD capture (the trigger's effect) would store the
|
|
@@ -825,7 +1044,19 @@ class CngxPopover {
|
|
|
825
1044
|
}
|
|
826
1045
|
openPopovers.add(this);
|
|
827
1046
|
this.stateSignal.set('opening');
|
|
1047
|
+
if (!this.anchored()) {
|
|
1048
|
+
this.clearFloatingPosition();
|
|
1049
|
+
}
|
|
1050
|
+
// A placement or try-fallback override set in this turn reaches the
|
|
1051
|
+
// effect only on the next change detection; the first frame must not
|
|
1052
|
+
// paint at the previous placement.
|
|
1053
|
+
untracked(() => this.writeAnchorPlacement());
|
|
828
1054
|
this.elRef.nativeElement.showPopover();
|
|
1055
|
+
// The host binding writes aria-hidden on the next change detection; the
|
|
1056
|
+
// seam may move focus into the panel right now, which must not land
|
|
1057
|
+
// under a stale aria-hidden="true".
|
|
1058
|
+
this.elRef.nativeElement.setAttribute('aria-hidden', 'false');
|
|
1059
|
+
this.presentationSeam()?.onShown();
|
|
829
1060
|
installGlobalEscapeListener(this.doc);
|
|
830
1061
|
installGlobalOutsideClickListener(this.doc);
|
|
831
1062
|
this.applyFloatingPosition();
|
|
@@ -840,13 +1071,37 @@ class CngxPopover {
|
|
|
840
1071
|
// getComputedStyle read on this directive's side.
|
|
841
1072
|
this.updateArrowOffset();
|
|
842
1073
|
});
|
|
1074
|
+
this.opened.emit();
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Writes `position-area`, `position-try-fallbacks` and the anchor margin from
|
|
1078
|
+
* their computeds. `position-area` goes through a style call because its
|
|
1079
|
+
* property name differs per browser (`ANCHOR_AREA_PROPERTY`).
|
|
1080
|
+
*/
|
|
1081
|
+
writeAnchorPlacement() {
|
|
1082
|
+
const style = this.elRef.nativeElement.style;
|
|
1083
|
+
const anchored = this.anchored();
|
|
1084
|
+
const area = SUPPORTS_ANCHOR && anchored ? POSITION_AREA[this.effectivePlacement()] : null;
|
|
1085
|
+
setOrRemoveStyle(style, ANCHOR_AREA_PROPERTY, area);
|
|
1086
|
+
setOrRemoveStyle(style, 'position-try-fallbacks', this.cssPositionTryFallbacks());
|
|
1087
|
+
setOrRemoveStyle(style, '--cngx-popover-anchor-margin', this.cssMargin());
|
|
843
1088
|
}
|
|
844
1089
|
/** Close the popover. No-op if already `closed` or `closing`. */
|
|
845
1090
|
hide() {
|
|
846
1091
|
if (this.stateSignal() === 'closed' || this.stateSignal() === 'closing') {
|
|
847
1092
|
return;
|
|
848
1093
|
}
|
|
849
|
-
this.
|
|
1094
|
+
if (this.hiding) {
|
|
1095
|
+
return;
|
|
1096
|
+
}
|
|
1097
|
+
this.hiding = true;
|
|
1098
|
+
try {
|
|
1099
|
+
this.presentationSeam()?.onHide();
|
|
1100
|
+
this.startClosing();
|
|
1101
|
+
}
|
|
1102
|
+
finally {
|
|
1103
|
+
this.hiding = false;
|
|
1104
|
+
}
|
|
850
1105
|
}
|
|
851
1106
|
/** Toggle between open and closed. */
|
|
852
1107
|
toggle() {
|
|
@@ -893,12 +1148,96 @@ class CngxPopover {
|
|
|
893
1148
|
this.explicitAnchorElementSlot.unregister(element);
|
|
894
1149
|
}
|
|
895
1150
|
/**
|
|
896
|
-
*
|
|
897
|
-
*
|
|
898
|
-
*
|
|
1151
|
+
* Claim the `aria-haspopup` hint triggers fall back to when the consumer
|
|
1152
|
+
* sets none. Composers (`CngxPopoverPanel`, menu wirings) claim with
|
|
1153
|
+
* themselves as `owner` and release on destroy. The last live claim wins;
|
|
1154
|
+
* a re-claim by the same owner replaces its earlier one.
|
|
1155
|
+
*/
|
|
1156
|
+
claimHaspopup(owner, value) {
|
|
1157
|
+
this.haspopupClaims.claim(owner, value);
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Release `owner`'s `aria-haspopup` claim. Release removes only this
|
|
1161
|
+
* owner's claim, so a co-composer's hint survives it.
|
|
1162
|
+
*/
|
|
1163
|
+
releaseHaspopup(owner) {
|
|
1164
|
+
this.haspopupClaims.release(owner);
|
|
1165
|
+
}
|
|
1166
|
+
/**
|
|
1167
|
+
* Claim the id source triggers name in `aria-controls` when the consumer
|
|
1168
|
+
* sets none. Composers (menu wirings) pass the popup element's id Signal,
|
|
1169
|
+
* not its value. The last live claim wins; a re-claim by the same owner
|
|
1170
|
+
* replaces its earlier one.
|
|
1171
|
+
*/
|
|
1172
|
+
claimControls(owner, source) {
|
|
1173
|
+
this.controlsClaims.claim(owner, source);
|
|
1174
|
+
}
|
|
1175
|
+
/**
|
|
1176
|
+
* Release `owner`'s `aria-controls` claim. Release removes only this
|
|
1177
|
+
* owner's claim, so a co-composer's hint survives it.
|
|
1178
|
+
*/
|
|
1179
|
+
releaseControls(owner) {
|
|
1180
|
+
this.controlsClaims.release(owner);
|
|
1181
|
+
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Claim the `position-try-fallbacks` chain the popover falls back to
|
|
1184
|
+
* while the consumer binds no `[positionTryFallbacks]`. Composers (menu
|
|
1185
|
+
* wirings) claim with themselves as `owner` and release on destroy. The
|
|
1186
|
+
* last live claim wins; a re-claim by the same owner replaces its
|
|
1187
|
+
* earlier one. A bound list, including an empty one, wins over every
|
|
1188
|
+
* claim.
|
|
1189
|
+
*/
|
|
1190
|
+
claimPositionTryFallbacks(owner, value) {
|
|
1191
|
+
this.positionTryFallbacksClaims.claim(owner, value);
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* Release `owner`'s `position-try-fallbacks` claim. Release removes only
|
|
1195
|
+
* this owner's claim, so a co-composer's chain survives it.
|
|
1196
|
+
*/
|
|
1197
|
+
releasePositionTryFallbacks(owner) {
|
|
1198
|
+
this.positionTryFallbacksClaims.release(owner);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* Claim the focus-return hint triggers fall back to when the consumer
|
|
1202
|
+
* binds no `[restoreFocus]`. The last live claim wins; a re-claim by the
|
|
1203
|
+
* same owner replaces its earlier one.
|
|
1204
|
+
*/
|
|
1205
|
+
claimRestoreFocus(owner, value) {
|
|
1206
|
+
this.restoreFocusClaims.claim(owner, value);
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Release `owner`'s focus-return claim. Release removes only this owner's
|
|
1210
|
+
* claim, so a co-composer's hint survives it.
|
|
899
1211
|
*/
|
|
900
|
-
|
|
901
|
-
this.
|
|
1212
|
+
releaseRestoreFocus(owner) {
|
|
1213
|
+
this.restoreFocusClaims.release(owner);
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* @internal Install the listener `finalize()` calls synchronously at the
|
|
1217
|
+
* end of every close, with the {@link focusOrigin} captured before it is
|
|
1218
|
+
* cleared. Runs on every close path (`hide()`, light dismiss), so a close
|
|
1219
|
+
* that lands before the next change detection pass still reaches it. A
|
|
1220
|
+
* fading close also calls it once at its start, in the `closing` state and
|
|
1221
|
+
* before the panel turns `inert`, with the same origin.
|
|
1222
|
+
* Replacing a different live listener warns in dev mode (CNGX1081).
|
|
1223
|
+
*/
|
|
1224
|
+
registerCloseListener(fn) {
|
|
1225
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1226
|
+
const current = untracked(() => this.closeListenerSlot.current());
|
|
1227
|
+
if (current && current !== fn) {
|
|
1228
|
+
cngxDevWarn('CNGX1081', '[cngxPopover] a second CngxPopoverTrigger registered on this popover and replaced ' +
|
|
1229
|
+
'the first one. Only the last-registered trigger restores focus on close, so bind ' +
|
|
1230
|
+
'one CngxPopoverTrigger per popover.', this.popoverElement);
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
this.closeListenerSlot.register(fn);
|
|
1234
|
+
}
|
|
1235
|
+
/**
|
|
1236
|
+
* @internal Release `fn`. Clears the slot only while `fn` still holds it,
|
|
1237
|
+
* so a stale trigger's teardown leaves a successor registered.
|
|
1238
|
+
*/
|
|
1239
|
+
releaseCloseListener(fn) {
|
|
1240
|
+
this.closeListenerSlot.unregister(fn);
|
|
902
1241
|
}
|
|
903
1242
|
/**
|
|
904
1243
|
* @internal Install or clear the programmatic {@link exclusive} override.
|
|
@@ -916,7 +1255,8 @@ class CngxPopover {
|
|
|
916
1255
|
}
|
|
917
1256
|
/**
|
|
918
1257
|
* @internal Install or clear the programmatic {@link positionTryFallbacks}
|
|
919
|
-
* override. `null` defers back to the `[positionTryFallbacks]` input
|
|
1258
|
+
* override. `null` defers back to the `[positionTryFallbacks]` input, then
|
|
1259
|
+
* to the last live composer claim.
|
|
920
1260
|
*/
|
|
921
1261
|
setPositionTryFallbacksOverride(value) {
|
|
922
1262
|
this.positionTryFallbacksOverrideState.set(value);
|
|
@@ -938,7 +1278,9 @@ class CngxPopover {
|
|
|
938
1278
|
* `CngxPopoverAnchor` holds the popover).
|
|
939
1279
|
*/
|
|
940
1280
|
closeIfOutsidePointerDown(target) {
|
|
941
|
-
|
|
1281
|
+
// Outside a sheet the presentation modifier owns the tap and routes it
|
|
1282
|
+
// through its close request; hiding here would bypass that policy.
|
|
1283
|
+
if (!this.closeOnOutsideClick() || !this.anchored()) {
|
|
942
1284
|
return;
|
|
943
1285
|
}
|
|
944
1286
|
const node = target;
|
|
@@ -961,7 +1303,9 @@ class CngxPopover {
|
|
|
961
1303
|
getElement: () => this.popoverElement,
|
|
962
1304
|
getPlacement: () => FLOATING_PLACEMENT[this.floatingPlacement()],
|
|
963
1305
|
getOffset: () => this.offset(),
|
|
964
|
-
|
|
1306
|
+
// A position request in flight when the panel leaves the anchored
|
|
1307
|
+
// layout must not land on the sheet.
|
|
1308
|
+
isOpen: () => this.stateSignal() !== 'closed' && this.anchored(),
|
|
965
1309
|
onPositioned: () => this.updateArrowOffset(),
|
|
966
1310
|
})
|
|
967
1311
|
: null;
|
|
@@ -970,13 +1314,15 @@ class CngxPopover {
|
|
|
970
1314
|
* and the consumer has provided the fallback via `provideFloatingFallback()`.
|
|
971
1315
|
*/
|
|
972
1316
|
applyFloatingPosition() {
|
|
973
|
-
if (SUPPORTS_ANCHOR || !this.floatingPositioner) {
|
|
1317
|
+
if (SUPPORTS_ANCHOR || !this.floatingPositioner || !this.anchored()) {
|
|
974
1318
|
return;
|
|
975
1319
|
}
|
|
976
1320
|
if (!this.anchorElement()) {
|
|
977
1321
|
return;
|
|
978
1322
|
}
|
|
979
|
-
if (
|
|
1323
|
+
if (typeof ngDevMode !== 'undefined' &&
|
|
1324
|
+
ngDevMode &&
|
|
1325
|
+
(this.floatingFallback?.middleware ?? []).length === 0) {
|
|
980
1326
|
warnMissingFloatingMiddleware(this.popoverElement.ownerDocument);
|
|
981
1327
|
}
|
|
982
1328
|
this.floatingPositioner.start();
|
|
@@ -989,6 +1335,9 @@ class CngxPopover {
|
|
|
989
1335
|
* anchor sits outside the panel's inline extent.
|
|
990
1336
|
*/
|
|
991
1337
|
updateArrowOffset() {
|
|
1338
|
+
if (!this.anchored()) {
|
|
1339
|
+
return;
|
|
1340
|
+
}
|
|
992
1341
|
const anchor = this.anchorElement();
|
|
993
1342
|
if (!anchor) {
|
|
994
1343
|
this._arrowOffset.set(null);
|
|
@@ -1016,6 +1365,22 @@ class CngxPopover {
|
|
|
1016
1365
|
const clamped = Math.max(radius, Math.min(raw, panelDim - radius));
|
|
1017
1366
|
this._arrowOffset.set(`${clamped}px`);
|
|
1018
1367
|
}
|
|
1368
|
+
arrowFrame = null;
|
|
1369
|
+
// The floating fallback writes inline left/top, which beat any stylesheet;
|
|
1370
|
+
// a sheet opened after an anchored open must not inherit them.
|
|
1371
|
+
clearFloatingPosition() {
|
|
1372
|
+
if (!this.floatingPositioner) {
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
this.popoverElement.style.removeProperty('left');
|
|
1376
|
+
this.popoverElement.style.removeProperty('top');
|
|
1377
|
+
}
|
|
1378
|
+
cancelArrowFrame() {
|
|
1379
|
+
if (this.arrowFrame !== null) {
|
|
1380
|
+
cancelAnimationFrame(this.arrowFrame);
|
|
1381
|
+
this.arrowFrame = null;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1019
1384
|
get popoverElement() {
|
|
1020
1385
|
return this.elRef.nativeElement;
|
|
1021
1386
|
}
|
|
@@ -1031,13 +1396,33 @@ class CngxPopover {
|
|
|
1031
1396
|
}
|
|
1032
1397
|
if (hasTransition(this.popoverElement)) {
|
|
1033
1398
|
this.stateSignal.set('closing');
|
|
1399
|
+
// Restore focus while the panel is still live: the fade inert would
|
|
1400
|
+
// otherwise drop a focused descendant to body until finalize().
|
|
1401
|
+
untracked(() => this.closeListenerSlot.current()?.(this.focusOriginState()));
|
|
1402
|
+
this.claimFadeInert();
|
|
1034
1403
|
this.pendingClose = onTransitionDone(this.popoverElement, () => this.finalize());
|
|
1035
1404
|
}
|
|
1036
1405
|
else {
|
|
1037
1406
|
this.finalize();
|
|
1038
1407
|
}
|
|
1039
1408
|
}
|
|
1040
|
-
|
|
1409
|
+
claimFadeInert() {
|
|
1410
|
+
const el = this.popoverElement;
|
|
1411
|
+
if (el.hasAttribute('inert')) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
el.setAttribute('inert', '');
|
|
1415
|
+
this.ownsFadeInert = true;
|
|
1416
|
+
}
|
|
1417
|
+
releaseFadeInert() {
|
|
1418
|
+
if (!this.ownsFadeInert) {
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
this.ownsFadeInert = false;
|
|
1422
|
+
this.popoverElement.removeAttribute('inert');
|
|
1423
|
+
}
|
|
1424
|
+
finalize(emit = true) {
|
|
1425
|
+
const wasClosed = this.stateSignal() === 'closed';
|
|
1041
1426
|
// Disarm any pending close wait no matter which path got here - the
|
|
1042
1427
|
// browser's own light dismiss routes through handleToggle straight to
|
|
1043
1428
|
// finalize(), and a stale armed handle would force-close a reopened
|
|
@@ -1048,6 +1433,7 @@ class CngxPopover {
|
|
|
1048
1433
|
openPopovers.delete(this);
|
|
1049
1434
|
this._arrowOffset.set(null);
|
|
1050
1435
|
this.resolvedEdgeSignal.set(null);
|
|
1436
|
+
const origin = untracked(() => this.focusOriginState());
|
|
1051
1437
|
this.focusOriginState.set(null);
|
|
1052
1438
|
const el = this.popoverElement;
|
|
1053
1439
|
// Move focus out of the panel BEFORE it flips to aria-hidden (state ->
|
|
@@ -1055,8 +1441,8 @@ class CngxPopover {
|
|
|
1055
1441
|
// control reached by keyboard) still holds focus would trap that focus
|
|
1056
1442
|
// under aria-hidden - the browser blocks it and warns. Blurring here
|
|
1057
1443
|
// relocates to the document synchronously, matching the eventual
|
|
1058
|
-
// display:none end state;
|
|
1059
|
-
//
|
|
1444
|
+
// display:none end state; the trigger's restore, by input or claim,
|
|
1445
|
+
// returns focus afterwards.
|
|
1060
1446
|
const active = this.doc.activeElement;
|
|
1061
1447
|
if (active && el.contains(active) && typeof active.blur === 'function') {
|
|
1062
1448
|
active.blur();
|
|
@@ -1068,9 +1454,14 @@ class CngxPopover {
|
|
|
1068
1454
|
// Element may already be hidden or disconnected
|
|
1069
1455
|
}
|
|
1070
1456
|
this.stateSignal.set('closed');
|
|
1457
|
+
this.releaseFadeInert();
|
|
1458
|
+
untracked(() => this.closeListenerSlot.current()?.(origin));
|
|
1459
|
+
if (emit && !wasClosed) {
|
|
1460
|
+
this.closed.emit();
|
|
1461
|
+
}
|
|
1071
1462
|
}
|
|
1072
1463
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopover, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1073
|
-
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 }, positionTryFallbacks: { classPropertyName: "positionTryFallbacks", publicName: "positionTryFallbacks", 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 }, closeOnOutsideClick: { classPropertyName: "closeOnOutsideClick", publicName: "closeOnOutsideClick", 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()", "attr.data-arrow-placement": "resolvedEdge()", "class.cngx-popover--opening": "isOpening()", "class.cngx-popover--open": "isOpen()", "class.cngx-popover--closing": "isClosing()", "style.position-anchor": "cssAnchorRef()", "style
|
|
1464
|
+
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 }, positionTryFallbacks: { classPropertyName: "positionTryFallbacks", publicName: "positionTryFallbacks", 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 }, closeOnOutsideClick: { classPropertyName: "closeOnOutsideClick", publicName: "closeOnOutsideClick", 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 } }, outputs: { opened: "opened", closed: "closed" }, host: { listeners: { "toggle": "handleToggle($event)" }, properties: { "attr.popover": "mode()", "id": "id()", "attr.aria-hidden": "!isVisible()", "attr.data-arrow-placement": "resolvedEdge()", "class.cngx-popover--opening": "isOpening()", "class.cngx-popover--open": "isOpen()", "class.cngx-popover--closing": "isClosing()", "style.position-anchor": "cssAnchorRef()", "style.--cngx-popover-anchor-offset": "cssOffset()", "style.--cngx-popover-arrow-offset": "arrowOffset()" } }, exportAs: ["cngxPopover"], ngImport: i0 });
|
|
1074
1465
|
}
|
|
1075
1466
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopover, decorators: [{
|
|
1076
1467
|
type: Directive,
|
|
@@ -1087,13 +1478,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1087
1478
|
'[class.cngx-popover--open]': 'isOpen()',
|
|
1088
1479
|
'[class.cngx-popover--closing]': 'isClosing()',
|
|
1089
1480
|
'[style.position-anchor]': 'cssAnchorRef()',
|
|
1090
|
-
'[style
|
|
1091
|
-
'[style.margin]': 'cssMargin()',
|
|
1481
|
+
'[style.--cngx-popover-anchor-offset]': 'cssOffset()',
|
|
1092
1482
|
'[style.--cngx-popover-arrow-offset]': 'arrowOffset()',
|
|
1093
1483
|
'(toggle)': 'handleToggle($event)',
|
|
1094
1484
|
},
|
|
1095
1485
|
}]
|
|
1096
|
-
}], ctorParameters: () => [], propDecorators: { placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], positionTryFallbacks: [{ type: i0.Input, args: [{ isSignal: true, alias: "positionTryFallbacks", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], closeOnOutsideClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnOutsideClick", 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 }] }] } });
|
|
1486
|
+
}], ctorParameters: () => [], propDecorators: { placement: [{ type: i0.Input, args: [{ isSignal: true, alias: "placement", required: false }] }], positionTryFallbacks: [{ type: i0.Input, args: [{ isSignal: true, alias: "positionTryFallbacks", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], closeOnOutsideClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnOutsideClick", 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 }] }], opened: [{ type: i0.Output, args: ["opened"] }], closed: [{ type: i0.Output, args: ["closed"] }] } });
|
|
1097
1487
|
|
|
1098
1488
|
/**
|
|
1099
1489
|
* ARIA wiring atom for elements that trigger a `CngxPopover`.
|
|
@@ -1114,27 +1504,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1114
1504
|
* ```
|
|
1115
1505
|
*
|
|
1116
1506
|
* ### Focus restoration
|
|
1117
|
-
*
|
|
1118
|
-
*
|
|
1119
|
-
*
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1123
|
-
*
|
|
1124
|
-
*
|
|
1507
|
+
* On close, the trigger can return focus to the element that was focused
|
|
1508
|
+
* before the popover opened (the popover snapshots it synchronously in
|
|
1509
|
+
* `show()`, so content autofocus cannot displace the restore target). The
|
|
1510
|
+
* popover calls the trigger synchronously at the end of every close, so the
|
|
1511
|
+
* decision is made at close time and a close that lands before the next
|
|
1512
|
+
* change detection pass (a fast Enter then Escape) still restores. The
|
|
1513
|
+
* decision resolves in this order: the `[restoreFocus]` input, then the
|
|
1514
|
+
* composer claim on the popover (`CngxPopoverPanel` claims `true`, a menu
|
|
1515
|
+
* trigger claims `false` because its focus stack restores), then `false`.
|
|
1516
|
+
* A bare popover therefore stays opt-in, and the restore runs only when
|
|
1517
|
+
* focus is lost at close time. One trigger per popover: a later trigger
|
|
1518
|
+
* takes over the close listener, as it does the implicit anchor slot.
|
|
1519
|
+
*
|
|
1125
1520
|
* @wcag AA
|
|
1126
1521
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-trigger.directive.ts
|
|
1127
|
-
* @since 0.
|
|
1128
|
-
* @relatedTo CngxPopover, CngxPopoverAnchor, CngxPopoverPanel, CngxTooltip
|
|
1129
|
-
* <example-url
|
|
1130
|
-
* <example-url
|
|
1131
|
-
* <example-url
|
|
1132
|
-
* <example-url
|
|
1133
|
-
* <example-url
|
|
1522
|
+
* @since 0.3.0
|
|
1523
|
+
* @relatedTo CngxPopover, CngxPopoverAnchor, CngxPopoverPanel, CngxTooltip, CngxMenuButton, CngxDisclosure
|
|
1524
|
+
* <example-url>/#/common/popover/click-popover</example-url>
|
|
1525
|
+
* <example-url>/#/common/popover/disclosure/link-list</example-url>
|
|
1526
|
+
* <example-url>/#/common/popover/controlled-open</example-url>
|
|
1527
|
+
* <example-url>/#/common/popover/escape-mode</example-url>
|
|
1528
|
+
* <example-url>/#/common/popover/placement-variants</example-url>
|
|
1529
|
+
* <example-url>/#/common/popover/anchor/field-box-anchor</example-url>
|
|
1530
|
+
* <example-url>/#/common/menu-button/menu-button/basic</example-url>
|
|
1134
1531
|
*/
|
|
1135
1532
|
class CngxPopoverTrigger {
|
|
1136
1533
|
elRef = inject(ElementRef);
|
|
1137
1534
|
destroyRef = inject(DestroyRef);
|
|
1535
|
+
doc = inject(DOCUMENT);
|
|
1138
1536
|
/** Explicit reference to the popover this trigger controls. */
|
|
1139
1537
|
popoverRef = input.required({ ...(ngDevMode ? { debugName: "popoverRef" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverTrigger' });
|
|
1140
1538
|
/**
|
|
@@ -1152,14 +1550,35 @@ class CngxPopoverTrigger {
|
|
|
1152
1550
|
*/
|
|
1153
1551
|
haspopupInput = input(undefined, { ...(ngDevMode ? { debugName: "haspopupInput" } : /* istanbul ignore next */ {}), alias: 'haspopup' });
|
|
1154
1552
|
/**
|
|
1155
|
-
*
|
|
1156
|
-
* popover
|
|
1157
|
-
*
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
|
|
1553
|
+
* ARIA controls override. When set, `aria-controls` names this id instead
|
|
1554
|
+
* of the popover element - correct when the popup role sits on an element
|
|
1555
|
+
* inside the popover (a `role="listbox"` or `role="tree"` panel). `null`
|
|
1556
|
+
* or unset falls back to the popover's `controlsHint()` (installed by a
|
|
1557
|
+
* composer such as a menu trigger), then to `popoverRef().id()`.
|
|
1558
|
+
*/
|
|
1559
|
+
controlsInput = input(undefined, { ...(ngDevMode ? { debugName: "controlsInput" } : /* istanbul ignore next */ {}), alias: 'controls' });
|
|
1560
|
+
/**
|
|
1561
|
+
* When `true` at close time, restores focus to the popover's pre-open
|
|
1562
|
+
* focus target (the popover snapshots `document.activeElement`
|
|
1563
|
+
* synchronously inside `show()`, before content autofocus can land in
|
|
1564
|
+
* the panel and hands it to the trigger when it closes). The value is
|
|
1565
|
+
* read when the popover closes, not when it opens. A snapshot of `body`
|
|
1566
|
+
* (a browser that does not focus a clicked button, such as Safari)
|
|
1567
|
+
* falls back to this trigger. The restore runs only when focus is
|
|
1568
|
+
* lost at close time - on `body` or inside the panel - so a close
|
|
1569
|
+
* caused by a click or Escape in another control leaves focus there.
|
|
1570
|
+
* Unbound, the popover's composer claim decides
|
|
1571
|
+
* (`popoverRef().restoreFocusHint()`: `CngxPopoverPanel` claims `true`, a
|
|
1572
|
+
* menu trigger `false`), and without a claim it stays `false`, so a bare
|
|
1573
|
+
* popover trigger is a passive ARIA atom. Bind `true` or `false` to
|
|
1574
|
+
* override the composer.
|
|
1575
|
+
*/
|
|
1576
|
+
restoreFocusInput = input(undefined, { ...(ngDevMode ? { debugName: "restoreFocusInput" } : /* istanbul ignore next */ {}), alias: 'restoreFocus' });
|
|
1577
|
+
/**
|
|
1578
|
+
* @internal Resolved focus return: the `[restoreFocus]` input, then the
|
|
1579
|
+
* popover's composer claim, then `false`.
|
|
1161
1580
|
*/
|
|
1162
|
-
restoreFocus =
|
|
1581
|
+
restoreFocus = computed(() => this.restoreFocusInput() ?? this.popoverRef().restoreFocusHint() ?? false, ...(ngDevMode ? [{ debugName: "restoreFocus" }] : /* istanbul ignore next */ []));
|
|
1163
1582
|
/**
|
|
1164
1583
|
* Resolved `aria-haspopup`. Consumer override (`haspopup` on the
|
|
1165
1584
|
* trigger element) wins; otherwise the popover's `haspopup` signal
|
|
@@ -1171,6 +1590,11 @@ class CngxPopoverTrigger {
|
|
|
1171
1590
|
const resolved = this.haspopupInput() ?? this.popoverRef().haspopup() ?? 'true';
|
|
1172
1591
|
return resolved === 'none' ? null : resolved;
|
|
1173
1592
|
}, ...(ngDevMode ? [{ debugName: "haspopup" }] : /* istanbul ignore next */ []));
|
|
1593
|
+
/**
|
|
1594
|
+
* Resolved `aria-controls`: the consumer override, else the popover's
|
|
1595
|
+
* composer hint, else the popover id.
|
|
1596
|
+
*/
|
|
1597
|
+
controls = computed(() => this.controlsInput() ?? this.popoverRef().controlsHint() ?? this.popoverRef().id(), ...(ngDevMode ? [{ debugName: "controls" }] : /* istanbul ignore next */ []));
|
|
1174
1598
|
/**
|
|
1175
1599
|
* CSS anchor name, yielded (`null`) while a `CngxPopoverAnchor` holds
|
|
1176
1600
|
* the popover's explicit anchor slot.
|
|
@@ -1178,7 +1602,24 @@ class CngxPopoverTrigger {
|
|
|
1178
1602
|
cssAnchorName = computed(() => SUPPORTS_ANCHOR && this.popoverRef().explicitAnchorElement() === null
|
|
1179
1603
|
? `--cngx-pop-${this.popoverRef().id()}`
|
|
1180
1604
|
: null, ...(ngDevMode ? [{ debugName: "cssAnchorName" }] : /* istanbul ignore next */ []));
|
|
1181
|
-
|
|
1605
|
+
/**
|
|
1606
|
+
* Close-time focus return, called synchronously by the popover at the end
|
|
1607
|
+
* of every close with its pre-open focus origin, and once more at the
|
|
1608
|
+
* start of a fading close, before the panel turns `inert`. Whichever call
|
|
1609
|
+
* finds focus lost restores it; the other is a no-op. The decision is read
|
|
1610
|
+
* here, not sampled on open: a close in a sheet presentation resolves
|
|
1611
|
+
* `restoreFocus()` to `false` by itself.
|
|
1612
|
+
*/
|
|
1613
|
+
handleClose = (origin) => {
|
|
1614
|
+
if (!this.restoreFocus()) {
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
const target = origin && origin !== this.doc.body ? origin : this.elRef.nativeElement;
|
|
1618
|
+
if (!this.isFocusLost() || !target.isConnected || typeof target.focus !== 'function') {
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
target.focus();
|
|
1622
|
+
};
|
|
1182
1623
|
constructor() {
|
|
1183
1624
|
// Register this element as the anchor for fallback positioning.
|
|
1184
1625
|
effect(() => {
|
|
@@ -1190,31 +1631,26 @@ class CngxPopoverTrigger {
|
|
|
1190
1631
|
this.destroyRef.onDestroy(() => {
|
|
1191
1632
|
this.popoverRef().releaseAnchorElement(this.elRef.nativeElement);
|
|
1192
1633
|
});
|
|
1193
|
-
//
|
|
1194
|
-
//
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
untracked(() => {
|
|
1202
|
-
this.savedFocus = this.popoverRef().focusOrigin() ?? this.elRef.nativeElement;
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
else if (this.savedFocus) {
|
|
1206
|
-
const target = this.savedFocus;
|
|
1207
|
-
this.savedFocus = null;
|
|
1208
|
-
untracked(() => {
|
|
1209
|
-
if (typeof target.focus === 'function' && target.isConnected) {
|
|
1210
|
-
target.focus();
|
|
1211
|
-
}
|
|
1212
|
-
});
|
|
1213
|
-
}
|
|
1634
|
+
// Close listener per popover: the popover calls it synchronously from
|
|
1635
|
+
// its close, so an open and close inside one tick cannot skip the
|
|
1636
|
+
// restore. onCleanup also runs on destroy; the release is
|
|
1637
|
+
// identity-guarded like the anchor slot.
|
|
1638
|
+
effect((onCleanup) => {
|
|
1639
|
+
const pop = this.popoverRef();
|
|
1640
|
+
untracked(() => pop.registerCloseListener(this.handleClose));
|
|
1641
|
+
onCleanup(() => pop.releaseCloseListener(this.handleClose));
|
|
1214
1642
|
});
|
|
1215
1643
|
}
|
|
1644
|
+
// Same rule as CngxPopoverSheet: `body` counts as lost because the
|
|
1645
|
+
// popover blurs a focused descendant on hide.
|
|
1646
|
+
isFocusLost() {
|
|
1647
|
+
const active = this.doc.activeElement;
|
|
1648
|
+
return (!active ||
|
|
1649
|
+
active === this.doc.body ||
|
|
1650
|
+
this.popoverRef().elementRef.nativeElement.contains(active));
|
|
1651
|
+
}
|
|
1216
1652
|
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 },
|
|
1653
|
+
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 }, restoreFocusInput: { classPropertyName: "restoreFocusInput", 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
1654
|
}
|
|
1219
1655
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverTrigger, decorators: [{
|
|
1220
1656
|
type: Directive,
|
|
@@ -1224,12 +1660,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1224
1660
|
standalone: true,
|
|
1225
1661
|
host: {
|
|
1226
1662
|
'[attr.aria-expanded]': 'popoverRef().isVisible()',
|
|
1227
|
-
'[attr.aria-controls]': '
|
|
1663
|
+
'[attr.aria-controls]': 'controls()',
|
|
1228
1664
|
'[attr.aria-haspopup]': 'haspopup()',
|
|
1229
1665
|
'[style.anchor-name]': 'cssAnchorName()',
|
|
1230
1666
|
},
|
|
1231
1667
|
}]
|
|
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 }] }],
|
|
1668
|
+
}], 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 }] }], restoreFocusInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreFocus", required: false }] }] } });
|
|
1233
1669
|
|
|
1234
1670
|
/**
|
|
1235
1671
|
* Geometry anchor atom: positions a `CngxPopover` against its host
|
|
@@ -1259,11 +1695,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1259
1695
|
* releases the slot identity-guarded and the trigger becomes the anchor
|
|
1260
1696
|
* again.
|
|
1261
1697
|
*
|
|
1262
|
-
* @category common/popover
|
|
1263
1698
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-anchor.directive.ts
|
|
1264
|
-
* @since 0.
|
|
1699
|
+
* @since 0.3.0
|
|
1265
1700
|
* @relatedTo CngxPopover, CngxPopoverTrigger
|
|
1266
|
-
* <example-url
|
|
1701
|
+
* <example-url>/#/common/popover/anchor/field-box-anchor</example-url>
|
|
1702
|
+
* @axis level atom
|
|
1267
1703
|
*/
|
|
1268
1704
|
class CngxPopoverAnchor {
|
|
1269
1705
|
host = inject(ElementRef).nativeElement;
|
|
@@ -1307,6 +1743,13 @@ const FOCUS_DEBOUNCE_MS = 50;
|
|
|
1307
1743
|
*
|
|
1308
1744
|
* The consumer sees only the attribute - no extra elements in the template.
|
|
1309
1745
|
*
|
|
1746
|
+
* The tooltip joins the host's `aria-describedby` instead of replacing it. On
|
|
1747
|
+
* a plain host the static `aria-describedby` ids are kept and the tooltip id
|
|
1748
|
+
* is appended after them. When the host provides `CNGX_DESCRIBED_BY`
|
|
1749
|
+
* (`CngxButton`, `CngxIconButton`), the tooltip contributes its id to that
|
|
1750
|
+
* registry next to the host's own ids. The id is referenced while the
|
|
1751
|
+
* tooltip is `enabled`, whether or not the popup is open.
|
|
1752
|
+
*
|
|
1310
1753
|
* ### Basic
|
|
1311
1754
|
* ```html
|
|
1312
1755
|
* <button cngxTooltip="Ctrl+S">Save</button>
|
|
@@ -1319,18 +1762,17 @@ const FOCUS_DEBOUNCE_MS = 50;
|
|
|
1319
1762
|
* </button>
|
|
1320
1763
|
* ```
|
|
1321
1764
|
*
|
|
1322
|
-
* @category common/popover
|
|
1323
|
-
* @docsKind primary
|
|
1324
1765
|
* @wcag AA
|
|
1325
1766
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/tooltip.directive.ts
|
|
1326
|
-
* @since 0.
|
|
1327
|
-
* @relatedTo CngxPopover, CngxPopoverTrigger
|
|
1328
|
-
* <example-url
|
|
1329
|
-
* <example-url
|
|
1330
|
-
* <example-url
|
|
1331
|
-
* <example-url
|
|
1332
|
-
* <example-url
|
|
1333
|
-
* <example-url
|
|
1767
|
+
* @since 0.3.0
|
|
1768
|
+
* @relatedTo CngxPopover, CngxPopoverTrigger, CNGX_DESCRIBED_BY
|
|
1769
|
+
* <example-url>/#/common/popover/tooltip/basic-tooltip</example-url>
|
|
1770
|
+
* <example-url>/#/common/popover/tooltip/custom-delay</example-url>
|
|
1771
|
+
* <example-url>/#/common/popover/tooltip/disabled-state</example-url>
|
|
1772
|
+
* <example-url>/#/common/popover/tooltip/keyboard-navigation</example-url>
|
|
1773
|
+
* <example-url>/#/common/popover/tooltip/placement</example-url>
|
|
1774
|
+
* <example-url>/#/common/popover/tooltip/programmatic-control</example-url>
|
|
1775
|
+
* @axis level atom
|
|
1334
1776
|
*/
|
|
1335
1777
|
class CngxTooltip {
|
|
1336
1778
|
renderer = inject(Renderer2);
|
|
@@ -1338,6 +1780,13 @@ class CngxTooltip {
|
|
|
1338
1780
|
destroyRef = inject(DestroyRef);
|
|
1339
1781
|
floatingFallback = inject(CNGX_FLOATING_FALLBACK, { optional: true });
|
|
1340
1782
|
direction = injectDirection();
|
|
1783
|
+
motion = injectEffectiveMotion();
|
|
1784
|
+
/**
|
|
1785
|
+
* @internal
|
|
1786
|
+
* Drives the `cngx-reduced-motion` class on the trigger from the app motion
|
|
1787
|
+
* axis (`CNGX_MOTION`), falling back to the OS preference on `auto`.
|
|
1788
|
+
*/
|
|
1789
|
+
reducedMotion = computed(() => this.motion() === 'reduced', ...(ngDevMode ? [{ debugName: "reducedMotion" }] : /* istanbul ignore next */ []));
|
|
1341
1790
|
/** Tooltip text content. */
|
|
1342
1791
|
text = input.required({ ...(ngDevMode ? { debugName: "text" } : /* istanbul ignore next */ {}), alias: 'cngxTooltip' });
|
|
1343
1792
|
/** Anchor-relative placement. */
|
|
@@ -1386,7 +1835,18 @@ class CngxTooltip {
|
|
|
1386
1835
|
tooltipEl = null;
|
|
1387
1836
|
openTimer = null;
|
|
1388
1837
|
closeTimer = null;
|
|
1389
|
-
|
|
1838
|
+
ownDescribedBy = computed(() => (this.enabled() ? this.idSignal() : null), ...(ngDevMode ? [{ debugName: "ownDescribedBy" }] : /* istanbul ignore next */ []));
|
|
1839
|
+
/**
|
|
1840
|
+
* A host that owns `aria-describedby` (`CngxButton`, `CngxIconButton`)
|
|
1841
|
+
* provides `CNGX_DESCRIBED_BY` on its element: the tooltip id joins that
|
|
1842
|
+
* registry and this binding renders the merged value the host renders, so
|
|
1843
|
+
* neither binding drops the other's ids. Without one, the tooltip owns a
|
|
1844
|
+
* local registry seeded with the static `aria-describedby`, so the
|
|
1845
|
+
* consumer's ids stay ahead of the tooltip id instead of being overwritten.
|
|
1846
|
+
*/
|
|
1847
|
+
describedByRegistry = injectDescribedByContribution(this.idSignal(), this.ownDescribedBy) ??
|
|
1848
|
+
this.createLocalDescribedBy();
|
|
1849
|
+
ariaDescribedBy = this.describedByRegistry.value;
|
|
1390
1850
|
cssAnchorName = computed(() => SUPPORTS_ANCHOR ? `--cngx-tip-${this.idSignal()}` : null, ...(ngDevMode ? [{ debugName: "cssAnchorName" }] : /* istanbul ignore next */ []));
|
|
1391
1851
|
constructor() {
|
|
1392
1852
|
this.createTooltipElement();
|
|
@@ -1444,9 +1904,17 @@ class CngxTooltip {
|
|
|
1444
1904
|
}
|
|
1445
1905
|
/** Show the tooltip immediately (bypassing delay). */
|
|
1446
1906
|
show() {
|
|
1907
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
1908
|
+
warnMissingPopoverApi(this.tooltipEl, 'cngxTooltip');
|
|
1909
|
+
}
|
|
1447
1910
|
if (!this.enabled() || this.stateSignal() !== 'closed') {
|
|
1448
1911
|
return;
|
|
1449
1912
|
}
|
|
1913
|
+
// Without the Popover API the open cannot happen; stay closed instead of
|
|
1914
|
+
// latching in 'opening', so the tooltip opens once a polyfill lands.
|
|
1915
|
+
if (typeof this.tooltipEl.showPopover !== 'function') {
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1450
1918
|
this.stateSignal.set('opening');
|
|
1451
1919
|
// The element ships aria-hidden while closed; an open tooltip must be
|
|
1452
1920
|
// exposed - it is the live target of the trigger's aria-describedby.
|
|
@@ -1546,6 +2014,14 @@ class CngxTooltip {
|
|
|
1546
2014
|
}
|
|
1547
2015
|
this.floatingPositioner.start();
|
|
1548
2016
|
}
|
|
2017
|
+
createLocalDescribedBy() {
|
|
2018
|
+
const registry = createDescribedByRegistry({
|
|
2019
|
+
name: 'cngxTooltip aria-describedby',
|
|
2020
|
+
seed: inject(new HostAttributeToken('aria-describedby'), { optional: true }),
|
|
2021
|
+
});
|
|
2022
|
+
registry.contribute(this.idSignal(), this.ownDescribedBy);
|
|
2023
|
+
return registry;
|
|
2024
|
+
}
|
|
1549
2025
|
createTooltipElement() {
|
|
1550
2026
|
const el = this.renderer.createElement('div');
|
|
1551
2027
|
el.setAttribute('popover', 'manual');
|
|
@@ -1596,7 +2072,7 @@ class CngxTooltip {
|
|
|
1596
2072
|
}
|
|
1597
2073
|
}
|
|
1598
2074
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1599
|
-
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 }, triggers: { classPropertyName: "triggers", publicName: "triggers", isSignal: true, isRequired: false, transformFunction: null }, positionTryFallbacks: { classPropertyName: "positionTryFallbacks", publicName: "tooltipPositionTryFallbacks", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "handleMouseEnter()", "mouseleave": "handleMouseLeave()", "focus": "handleFocus()", "blur": "handleBlur()" }, properties: { "attr.aria-describedby": "ariaDescribedBy()", "style.anchor-name": "cssAnchorName()" } }, exportAs: ["cngxTooltip"],
|
|
2075
|
+
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 }, triggers: { classPropertyName: "triggers", publicName: "triggers", isSignal: true, isRequired: false, transformFunction: null }, positionTryFallbacks: { classPropertyName: "positionTryFallbacks", publicName: "tooltipPositionTryFallbacks", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "handleMouseEnter()", "mouseleave": "handleMouseLeave()", "focus": "handleFocus()", "blur": "handleBlur()" }, properties: { "class.cngx-reduced-motion": "reducedMotion()", "attr.aria-describedby": "ariaDescribedBy()", "style.anchor-name": "cssAnchorName()" } }, exportAs: ["cngxTooltip"], ngImport: i0 });
|
|
1600
2076
|
}
|
|
1601
2077
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxTooltip, decorators: [{
|
|
1602
2078
|
type: Directive,
|
|
@@ -1604,8 +2080,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1604
2080
|
selector: '[cngxTooltip]',
|
|
1605
2081
|
exportAs: 'cngxTooltip',
|
|
1606
2082
|
standalone: true,
|
|
1607
|
-
hostDirectives: [CngxReducedMotion],
|
|
1608
2083
|
host: {
|
|
2084
|
+
'[class.cngx-reduced-motion]': 'reducedMotion()',
|
|
1609
2085
|
'[attr.aria-describedby]': 'ariaDescribedBy()',
|
|
1610
2086
|
'[style.anchor-name]': 'cssAnchorName()',
|
|
1611
2087
|
'(mouseenter)': 'handleMouseEnter()',
|
|
@@ -1616,117 +2092,873 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1616
2092
|
}]
|
|
1617
2093
|
}], 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
2094
|
|
|
1619
|
-
|
|
1620
|
-
const DEFAULT_CONFIG = {
|
|
1621
|
-
defaultVariant: 'default',
|
|
1622
|
-
};
|
|
1623
|
-
/**
|
|
1624
|
-
* Injection token for popover panel configuration.
|
|
1625
|
-
*
|
|
1626
|
-
* @category common/popover
|
|
1627
|
-
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel.config.ts
|
|
1628
|
-
* @since 0.1.0
|
|
1629
|
-
*/
|
|
1630
|
-
const CNGX_POPOVER_PANEL_CONFIG = new InjectionToken('CngxPopoverPanelConfig', { factory: () => DEFAULT_CONFIG });
|
|
1631
|
-
/**
|
|
1632
|
-
* Provides configuration for `CngxPopoverPanel` instances.
|
|
1633
|
-
*
|
|
1634
|
-
* ```typescript
|
|
1635
|
-
* providers: [
|
|
1636
|
-
* providePopoverPanel(
|
|
1637
|
-
* withAutoDismiss({ info: 5000, success: 3000 }),
|
|
1638
|
-
* withCloseOnSuccess(300),
|
|
1639
|
-
* ),
|
|
1640
|
-
* ]
|
|
1641
|
-
* ```
|
|
1642
|
-
*
|
|
1643
|
-
* @category common/popover
|
|
1644
|
-
*/
|
|
1645
|
-
function providePopoverPanel(...features) {
|
|
1646
|
-
const config = features.reduce((acc, f) => f(acc), { ...DEFAULT_CONFIG });
|
|
1647
|
-
return { provide: CNGX_POPOVER_PANEL_CONFIG, useValue: config };
|
|
1648
|
-
}
|
|
1649
|
-
/**
|
|
1650
|
-
* Auto-dismiss the panel after a timeout, per variant.
|
|
1651
|
-
*
|
|
1652
|
-
* @param timing - Map of variant name to dismiss duration in ms.
|
|
1653
|
-
* ```typescript
|
|
1654
|
-
* withAutoDismiss({ info: 5000, success: 3000 })
|
|
1655
|
-
* ```
|
|
1656
|
-
*
|
|
1657
|
-
* @category common/popover
|
|
1658
|
-
*/
|
|
1659
|
-
function withAutoDismiss(timing) {
|
|
1660
|
-
return (config) => ({ ...config, autoDismiss: { ...config.autoDismiss, ...timing } });
|
|
1661
|
-
}
|
|
2095
|
+
const BREAKPOINT_PROPERTY = '--cngx-popover-sheet-breakpoint';
|
|
1662
2096
|
/**
|
|
1663
|
-
*
|
|
1664
|
-
*
|
|
1665
|
-
*
|
|
1666
|
-
*
|
|
1667
|
-
* @category common/popover
|
|
2097
|
+
* @internal The `--cngx-popover-sheet-breakpoint` value `cngx-popover-sheet.css`
|
|
2098
|
+
* writes on the root: `'1'` on coarse, narrow viewports, `'0'` otherwise, `''`
|
|
2099
|
+
* before the first resize entry or without the stylesheet. One observer per
|
|
2100
|
+
* application, shared by every sheet.
|
|
1668
2101
|
*/
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
2102
|
+
const CNGX_POPOVER_SHEET_BREAKPOINT = new InjectionToken('CngxPopoverSheetBreakpoint', {
|
|
2103
|
+
providedIn: 'root',
|
|
2104
|
+
factory: () => createContainerSize(inject(DOCUMENT).documentElement, inject(DestroyRef), injectWindow()).property(BREAKPOINT_PROPERTY),
|
|
2105
|
+
});
|
|
2106
|
+
|
|
2107
|
+
/** @internal Provided by `CngxPopoverSheet` for its parts. */
|
|
2108
|
+
const CNGX_POPOVER_SHEET_HOST = new InjectionToken('CngxPopoverSheetHost');
|
|
1672
2109
|
/**
|
|
1673
|
-
*
|
|
1674
|
-
*
|
|
1675
|
-
* @category common/popover
|
|
2110
|
+
* @internal The sheet a part belongs to. A part outside a sheet would render
|
|
2111
|
+
* nothing useful (an unnamed dialog, a dead swipe), so it throws instead.
|
|
1676
2112
|
*/
|
|
1677
|
-
function
|
|
1678
|
-
|
|
2113
|
+
function injectPopoverSheetHost(part) {
|
|
2114
|
+
const host = inject(CNGX_POPOVER_SHEET_HOST, { optional: true });
|
|
2115
|
+
if (!host) {
|
|
2116
|
+
throw new CngxRuntimeError('CNGX1066', typeof ngDevMode !== 'undefined' &&
|
|
2117
|
+
ngDevMode &&
|
|
2118
|
+
`[${part}] must be placed inside an element with [cngxPopoverSheet].`);
|
|
2119
|
+
}
|
|
2120
|
+
return host;
|
|
1679
2121
|
}
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
2122
|
+
|
|
2123
|
+
const SETTLING_ATTRIBUTE = 'data-cngx-sheet-settling';
|
|
2124
|
+
const SETTLING_FRAME_CAP = 4;
|
|
2125
|
+
const LIVE_REGION_SELECTOR = '[aria-live], [role="status"], [role="alert"], [role="log"]';
|
|
2126
|
+
const FOCUS_TRAP_ANCHOR_CLASS = 'cdk-focus-trap-anchor';
|
|
2127
|
+
// Longer than a tap's pointerdown-to-click gap, shorter than a second tap.
|
|
2128
|
+
const CLICK_SWALLOW_MS = 600;
|
|
2129
|
+
// Engaged modal sheets, oldest first. Only the topmost answers an outside
|
|
2130
|
+
// tap: a tap on a later sheet is outside an earlier one that is not its
|
|
2131
|
+
// DOM ancestor, and must not close both.
|
|
2132
|
+
const engagedSheets = [];
|
|
2133
|
+
// How many engaged sheets want each element inert. Several sheets can be
|
|
2134
|
+
// open at once (`[exclusive]="false"`), so an element stays inert until the
|
|
2135
|
+
// last sheet that claimed it lets go, and one sheet's release never makes
|
|
2136
|
+
// the page live under another. Elements inert before any sheet are never
|
|
2137
|
+
// claimed and never touched.
|
|
2138
|
+
const inertClaims = new WeakMap();
|
|
2139
|
+
// The sheet is a presentation of the popover on its own element; without
|
|
2140
|
+
// one there is nothing to present.
|
|
2141
|
+
function injectSheetPopover() {
|
|
2142
|
+
const popover = inject(CngxPopover, { self: true, optional: true });
|
|
2143
|
+
if (!popover) {
|
|
2144
|
+
throw new CngxRuntimeError('CNGX1067', typeof ngDevMode !== 'undefined' &&
|
|
2145
|
+
ngDevMode &&
|
|
2146
|
+
'[cngxPopoverSheet] must be placed on an element with [cngxPopover].');
|
|
2147
|
+
}
|
|
2148
|
+
return popover;
|
|
1687
2149
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
2150
|
+
// Once per sheet instance and per flag: a nameless modal sheet, and a popover
|
|
2151
|
+
// mode that lets native light dismiss and Escape bypass closeRequested.
|
|
2152
|
+
function warnSheetMisconfiguration(host, unnamed, mode, warned) {
|
|
2153
|
+
if (!(typeof ngDevMode !== 'undefined' && ngDevMode)) {
|
|
2154
|
+
return;
|
|
2155
|
+
}
|
|
2156
|
+
if (!warned.title && unnamed) {
|
|
2157
|
+
warned.title = true;
|
|
2158
|
+
cngxDevWarn('CNGX1064', '[cngxPopoverSheet] opened as a modal sheet without a name. Add a ' +
|
|
2159
|
+
'cngxPopoverSheetTitle inside the panel or bind [labelledBy].', host);
|
|
2160
|
+
}
|
|
2161
|
+
if (!warned.mode && mode !== 'manual') {
|
|
2162
|
+
warned.mode = true;
|
|
2163
|
+
cngxDevWarn('CNGX1065', `[cngxPopoverSheet] needs mode="manual" on the popover, got "${mode}". ` +
|
|
2164
|
+
'Native light dismiss and Escape bypass closeRequested in that mode.', host);
|
|
2165
|
+
}
|
|
1695
2166
|
}
|
|
1696
2167
|
/**
|
|
1697
|
-
*
|
|
1698
|
-
*
|
|
1699
|
-
*
|
|
1700
|
-
*
|
|
1701
|
-
*
|
|
1702
|
-
*
|
|
1703
|
-
*
|
|
2168
|
+
* Turns a `CngxPopover` into a modal bottom sheet or fullscreen panel on
|
|
2169
|
+
* coarse, narrow viewports, and leaves it anchored everywhere else.
|
|
2170
|
+
*
|
|
2171
|
+
* Place it on the `[cngxPopover]` element. With the default `'auto'` request,
|
|
2172
|
+
* the breakpoint written once in `cngx-popover-sheet.css`
|
|
2173
|
+
* (`(pointer: coarse) and (max-width: 48rem)`) picks between the anchored
|
|
2174
|
+
* panel and `autoPresentation` (`'sheet'` or `'fullscreen'`). Pass a fixed
|
|
2175
|
+
* presentation to override it.
|
|
2176
|
+
*
|
|
2177
|
+
* Both non-anchored presentations are modal: the host becomes
|
|
2178
|
+
* `role="dialog"` + `aria-modal="true"`, named by its
|
|
2179
|
+
* `CngxPopoverSheetTitle`; focus moves into the panel inside `show()`, onto
|
|
2180
|
+
* the first enabled `CngxPopoverSheetInitialFocus` (a marked search input
|
|
2181
|
+
* focused there keeps the iOS keyboard of a tap open), Tab is trapped, every page
|
|
2182
|
+
* sibling is `inert`, the page is pinned, and announcements go through
|
|
2183
|
+
* {@link announce} into a live region inside the panel, the only region
|
|
2184
|
+
* VoiceOver speaks under `aria-modal`. On close the page is live again and
|
|
2185
|
+
* focus is back on the opener before the close transition starts.
|
|
2186
|
+
*
|
|
2187
|
+
* The sheet never closes itself. Header swipes, outside taps and the Android
|
|
2188
|
+
* back gesture arrive as `closeRequested` with a reason; the popover hides
|
|
2189
|
+
* unless `closeOnRequest` is `false`, which lets a consumer apply its own
|
|
2190
|
+
* dismiss policy. Escape stays with `CngxPopover`'s `closeOnEscape`.
|
|
2191
|
+
*
|
|
2192
|
+
* Requires `mode="manual"` on the popover (the default): native light dismiss
|
|
2193
|
+
* would bypass `closeRequested`.
|
|
1704
2194
|
*
|
|
1705
|
-
* ```
|
|
1706
|
-
*
|
|
1707
|
-
*
|
|
1708
|
-
*
|
|
2195
|
+
* ```html
|
|
2196
|
+
* <button type="button" (click)="pop.show()">Choose city</button>
|
|
2197
|
+
* <div cngxPopover #pop="cngxPopover" cngxPopoverSheet #sheet="cngxPopoverSheet">
|
|
2198
|
+
* <header cngxPopoverSheetHeader cngxSwipeDismiss="down">
|
|
2199
|
+
* <span cngxPopoverSheetHandle></span>
|
|
2200
|
+
* <h2 cngxPopoverSheetTitle>City</h2>
|
|
2201
|
+
* <button type="button" (click)="sheet.requestClose('close')">Close</button>
|
|
2202
|
+
* </header>
|
|
2203
|
+
* <ul>...</ul>
|
|
2204
|
+
* </div>
|
|
1709
2205
|
* ```
|
|
1710
2206
|
*
|
|
1711
|
-
* @
|
|
2207
|
+
* @wcag AA
|
|
2208
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-sheet.directive.ts
|
|
2209
|
+
* @since 0.3.0
|
|
2210
|
+
* @relatedTo CngxPopover, CngxSwipeDismiss, CngxFocusTrap, createPinnedScrollLock, injectScopedLiveRegion
|
|
2211
|
+
* <example-url>/#/common/popover/sheet/bottom-sheet</example-url>
|
|
2212
|
+
* <example-url>/#/common/popover/sheet/fullscreen-search</example-url>
|
|
2213
|
+
* @axis level molecule
|
|
1712
2214
|
*/
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
2215
|
+
class CngxPopoverSheet {
|
|
2216
|
+
popover = injectSheetPopover();
|
|
2217
|
+
trap = inject(CngxFocusTrap, { self: true });
|
|
2218
|
+
announcer = inject(CngxLiveAnnouncer);
|
|
2219
|
+
doc = inject(DOCUMENT);
|
|
2220
|
+
injector = inject(Injector);
|
|
2221
|
+
win = injectWindow();
|
|
2222
|
+
host = inject(ElementRef).nativeElement;
|
|
2223
|
+
// Static attributes the consumer wrote are what the anchored presentation
|
|
2224
|
+
// keeps; the bindings below only take over while the sheet is modal.
|
|
2225
|
+
staticRole = this.host.getAttribute('role');
|
|
2226
|
+
staticLabelledBy = this.host.getAttribute('aria-labelledby');
|
|
2227
|
+
staticTabindex = this.host.getAttribute('tabindex');
|
|
2228
|
+
/**
|
|
2229
|
+
* Requested presentation. `'auto'` (default, also the bare attribute)
|
|
2230
|
+
* resolves through the stylesheet breakpoint.
|
|
2231
|
+
*/
|
|
2232
|
+
request = input('auto', { ...(ngDevMode ? { debugName: "request" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverSheet', transform: (v) => (v === '' ? 'auto' : v) });
|
|
2233
|
+
/**
|
|
2234
|
+
* What `'auto'` resolves to below the breakpoint: a content-sized `'sheet'`
|
|
2235
|
+
* or a `'fullscreen'` panel (for panels led by a text input).
|
|
2236
|
+
*/
|
|
2237
|
+
autoPresentation = input('sheet', ...(ngDevMode ? [{ debugName: "autoPresentation" }] : /* istanbul ignore next */ []));
|
|
2238
|
+
/** Id of the element naming the dialog. Wins over a registered `CngxPopoverSheetTitle`. */
|
|
2239
|
+
labelledBy = input(undefined, ...(ngDevMode ? [{ debugName: "labelledBy" }] : /* istanbul ignore next */ []));
|
|
2240
|
+
/**
|
|
2241
|
+
* Whether the sheet returns focus on close (to `restoreTarget`, else to the
|
|
2242
|
+
* element focused before it opened). Turn it off when a `closing` handler
|
|
2243
|
+
* moves focus itself.
|
|
2244
|
+
*/
|
|
2245
|
+
restoreFocus = input(true, ...(ngDevMode ? [{ debugName: "restoreFocus" }] : /* istanbul ignore next */ []));
|
|
2246
|
+
/** Element to return focus to on close. Defaults to the element focused before open. */
|
|
2247
|
+
restoreTarget = input(undefined, ...(ngDevMode ? [{ debugName: "restoreTarget" }] : /* istanbul ignore next */ []));
|
|
2248
|
+
/**
|
|
2249
|
+
* Whether a close request hides the popover. `false` only emits
|
|
2250
|
+
* `closeRequested`, so the consumer decides.
|
|
2251
|
+
*/
|
|
2252
|
+
closeOnRequest = input(true, ...(ngDevMode ? [{ debugName: "closeOnRequest" }] : /* istanbul ignore next */ []));
|
|
2253
|
+
/** A swipe, outside tap, back gesture or close control asked the sheet to close. */
|
|
2254
|
+
closeRequested = output();
|
|
2255
|
+
/**
|
|
2256
|
+
* Emits synchronously inside `hide()` while the page is already live again,
|
|
2257
|
+
* before the close transition. The place to move focus out of the panel.
|
|
2258
|
+
* Fires only for a modal close.
|
|
2259
|
+
*/
|
|
2260
|
+
closing = output();
|
|
2261
|
+
breakpoint = inject(CNGX_POPOVER_SHEET_BREAKPOINT);
|
|
2262
|
+
/** Resolved presentation, reflected as `data-cngx-presentation`. */
|
|
2263
|
+
presentation = computed(() => {
|
|
2264
|
+
const request = this.request();
|
|
2265
|
+
if (request !== 'auto') {
|
|
2266
|
+
return request;
|
|
2267
|
+
}
|
|
2268
|
+
return this.breakpoint() === '1' ? this.autoPresentation() : 'anchored';
|
|
2269
|
+
}, ...(ngDevMode ? [{ debugName: "presentation" }] : /* istanbul ignore next */ []));
|
|
2270
|
+
/** `true` in the sheet and fullscreen presentations. */
|
|
2271
|
+
modal = computed(() => this.presentation() !== 'anchored', ...(ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []));
|
|
2272
|
+
showing = computed(() => {
|
|
2273
|
+
const state = this.popover.state();
|
|
2274
|
+
return state === 'opening' || state === 'open';
|
|
2275
|
+
}, ...(ngDevMode ? [{ debugName: "showing" }] : /* istanbul ignore next */ []));
|
|
2276
|
+
// A closing sheet has handed focus back and is no longer modal to a
|
|
2277
|
+
// reader or to Tab; the trap and aria-modal both read this one signal.
|
|
2278
|
+
modalShowing = computed(() => this.modal() && this.showing(), ...(ngDevMode ? [{ debugName: "modalShowing" }] : /* istanbul ignore next */ []));
|
|
2279
|
+
/**
|
|
2280
|
+
* @internal Drives the composed `CngxFocusTrap`: Tab stays inside while
|
|
2281
|
+
* modal and opening or open, so the trap anchors leave the Tab order when
|
|
2282
|
+
* the close starts.
|
|
2283
|
+
*/
|
|
2284
|
+
focusTrapEnabled = this.modalShowing;
|
|
2285
|
+
/** @internal The sheet moves focus itself, inside `show()`. */
|
|
2286
|
+
focusTrapAutoFocus = false;
|
|
2287
|
+
/** @internal */
|
|
2288
|
+
titleRegistry = createSlotRegistry();
|
|
2289
|
+
/** @internal */
|
|
2290
|
+
initialFocusRegistry = createKeyedRegistry({
|
|
2291
|
+
name: 'CngxPopoverSheet',
|
|
2292
|
+
});
|
|
2293
|
+
roleAttr = computed(() => (this.modal() ? 'dialog' : this.staticRole), ...(ngDevMode ? [{ debugName: "roleAttr" }] : /* istanbul ignore next */ []));
|
|
2294
|
+
// A closing or closed sheet marked modal would pull CngxLiveAnnouncer's
|
|
2295
|
+
// scoped messages into a hidden panel.
|
|
2296
|
+
ariaModal = computed(() => (this.modalShowing() ? 'true' : null), ...(ngDevMode ? [{ debugName: "ariaModal" }] : /* istanbul ignore next */ []));
|
|
2297
|
+
ariaLabelledBy = computed(() => this.modal()
|
|
2298
|
+
? (this.labelledBy() ?? this.titleRegistry.current()?.id() ?? null)
|
|
2299
|
+
: this.staticLabelledBy, ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
|
|
2300
|
+
// Last-resort focus target: a modal sheet with nothing tabbable inside
|
|
2301
|
+
// still takes focus on its host.
|
|
2302
|
+
tabindexAttr = computed(() => this.modal() ? (this.staticTabindex ?? '-1') : this.staticTabindex, ...(ngDevMode ? [{ debugName: "tabindexAttr" }] : /* istanbul ignore next */ []));
|
|
2303
|
+
region = injectScopedLiveRegion(this.host);
|
|
2304
|
+
engaged = false;
|
|
2305
|
+
savedFocus = null;
|
|
2306
|
+
inerted = [];
|
|
2307
|
+
// Own host and ancestors an earlier sheet made inert, lifted while this
|
|
2308
|
+
// sheet is engaged so it stays reachable.
|
|
2309
|
+
lifted = [];
|
|
2310
|
+
releaseLock = null;
|
|
2311
|
+
settlingFrame = null;
|
|
2312
|
+
devWarned = { title: false, mode: false };
|
|
2313
|
+
// Created inside the opening call, so a tap-opened sheet creates it under
|
|
2314
|
+
// the tap's user activation (Chrome groups watchers created without one).
|
|
2315
|
+
// Without CloseWatcher (iOS Safari) the back gesture leaves the page.
|
|
2316
|
+
closeWatcher = createCloseWatcher(() => this.handleBackGesture(), this.win);
|
|
2317
|
+
// Capture phase: the tap must be seen before anything under it reacts.
|
|
2318
|
+
// The page siblings are inert, so a tap outside the panel lands on a
|
|
2319
|
+
// non-inert ancestor; the popover ::backdrop does not catch taps on iOS
|
|
2320
|
+
// or Android.
|
|
2321
|
+
outsidePointerDown = (event) => {
|
|
2322
|
+
this.disarmClickSwallow();
|
|
2323
|
+
if (engagedSheets.at(-1) !== this) {
|
|
2324
|
+
return;
|
|
2325
|
+
}
|
|
2326
|
+
const target = event.target;
|
|
2327
|
+
if (target instanceof Node && this.host.contains(target)) {
|
|
2328
|
+
return;
|
|
2329
|
+
}
|
|
2330
|
+
this.armClickSwallow();
|
|
2331
|
+
this.requestClose('backdrop');
|
|
2332
|
+
};
|
|
2333
|
+
// Closing on pointerdown releases inert before the gesture's mousedown and
|
|
2334
|
+
// click land, so they would hit the page element under the tap: the
|
|
2335
|
+
// mousedown would take focus from the restored opener, the click would
|
|
2336
|
+
// activate the element. Swallow both for this gesture; the next
|
|
2337
|
+
// pointerdown or a short timeout disarms them, so a later tap is never
|
|
2338
|
+
// eaten.
|
|
2339
|
+
clickSwallowTimer = null;
|
|
2340
|
+
// Chromium also turns an unhandled Escape keydown into a CloseWatcher close
|
|
2341
|
+
// request. Escape belongs to CngxPopover (gated by closeOnEscape, topmost
|
|
2342
|
+
// popover only), so a watcher close that comes from the same keypress is
|
|
2343
|
+
// not a back gesture. The flag lives for the keydown task only.
|
|
2344
|
+
escapeKeyTimer = null;
|
|
2345
|
+
escapeKeydown = (event) => {
|
|
2346
|
+
if (event.key !== 'Escape') {
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
if (this.escapeKeyTimer !== null) {
|
|
2350
|
+
clearTimeout(this.escapeKeyTimer);
|
|
2351
|
+
}
|
|
2352
|
+
this.escapeKeyTimer = setTimeout(() => {
|
|
2353
|
+
this.escapeKeyTimer = null;
|
|
2354
|
+
});
|
|
2355
|
+
};
|
|
2356
|
+
swallowClick = (event) => {
|
|
2357
|
+
event.preventDefault();
|
|
2358
|
+
event.stopPropagation();
|
|
2359
|
+
this.disarmClickSwallow();
|
|
2360
|
+
};
|
|
2361
|
+
// Default only: the mousedown still propagates.
|
|
2362
|
+
swallowMouseDown = (event) => {
|
|
2363
|
+
event.preventDefault();
|
|
2364
|
+
};
|
|
2365
|
+
constructor() {
|
|
2366
|
+
// A breakpoint crossing or request flip while open. Open and close
|
|
2367
|
+
// themselves run through onShown() / onHide(), which engage first, so
|
|
2368
|
+
// this effect only sees edges nobody handled yet.
|
|
2369
|
+
const active = createTransitionTracker(() => this.modal() && this.popover.isVisible());
|
|
2370
|
+
effect(() => {
|
|
2371
|
+
const now = active.current();
|
|
2372
|
+
const previous = active.previous();
|
|
2373
|
+
untracked(() => {
|
|
2374
|
+
if (now && !previous && !this.engaged) {
|
|
2375
|
+
const focusWasOutside = !this.host.contains(this.doc.activeElement);
|
|
2376
|
+
this.engage(false);
|
|
2377
|
+
if (focusWasOutside) {
|
|
2378
|
+
this.rehomeFocusIntoSheet();
|
|
2379
|
+
}
|
|
2380
|
+
}
|
|
2381
|
+
if (!now && previous && this.engaged) {
|
|
2382
|
+
const opener = this.savedFocus;
|
|
2383
|
+
this.release();
|
|
2384
|
+
if (this.popover.isVisible()) {
|
|
2385
|
+
this.rehomeFocusAfterFlip(opener);
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
});
|
|
2389
|
+
});
|
|
2390
|
+
// Destroyed while open: the host leaves the DOM, so focus would drop to
|
|
2391
|
+
// body. Restore it like a close, without emitting from a dying directive.
|
|
2392
|
+
inject(DestroyRef).onDestroy(() => {
|
|
2393
|
+
this.disengage(false);
|
|
2394
|
+
this.release();
|
|
2395
|
+
this.disarmClickSwallow();
|
|
2396
|
+
});
|
|
2397
|
+
}
|
|
2398
|
+
/** @internal Seam call from `CngxPopover.show()`, after `showPopover()`. */
|
|
2399
|
+
onShown() {
|
|
2400
|
+
if (!this.modal()) {
|
|
2401
|
+
return;
|
|
2402
|
+
}
|
|
2403
|
+
this.engage(true);
|
|
2404
|
+
}
|
|
2405
|
+
/** @internal Seam call from `CngxPopover.hide()`, before the close transition. */
|
|
2406
|
+
onHide() {
|
|
2407
|
+
this.disengage(true);
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Ask the sheet to close. Emits `closeRequested` once per open (no-op
|
|
2411
|
+
* unless the popover is opening or open) and hides when `closeOnRequest`
|
|
2412
|
+
* is on.
|
|
2413
|
+
*/
|
|
2414
|
+
requestClose(reason) {
|
|
2415
|
+
if (!untracked(() => this.showing())) {
|
|
2416
|
+
return;
|
|
2417
|
+
}
|
|
2418
|
+
this.closeRequested.emit(reason);
|
|
2419
|
+
if (this.closeOnRequest()) {
|
|
2420
|
+
this.popover.hide();
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
/**
|
|
2424
|
+
* Speak `message` from the live region inside the panel. Use it for
|
|
2425
|
+
* every announcement while the sheet is modal: VoiceOver drops body-level
|
|
2426
|
+
* regions under `aria-modal`.
|
|
2427
|
+
*/
|
|
2428
|
+
announce(message, politeness = 'polite') {
|
|
2429
|
+
this.region.announce(message, politeness);
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Move focus to the first enabled `CngxPopoverSheetInitialFocus` in
|
|
2433
|
+
* document order, else the first tabbable element, else the host. Runs on
|
|
2434
|
+
* every modal open.
|
|
2435
|
+
*/
|
|
2436
|
+
focusInitial() {
|
|
2437
|
+
const target = this.initialFocusTarget();
|
|
2438
|
+
if (target) {
|
|
2439
|
+
target.focus();
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
if (!this.trap.focusFirstNow()) {
|
|
2443
|
+
this.host.focus();
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
initialFocusTarget() {
|
|
2447
|
+
let first = null;
|
|
2448
|
+
for (const handle of this.initialFocusRegistry.values()) {
|
|
2449
|
+
const enabled = handle.enabled?.() ?? true;
|
|
2450
|
+
const precedes = first === null ||
|
|
2451
|
+
(first.compareDocumentPosition(handle.element) & first.DOCUMENT_POSITION_PRECEDING) !== 0;
|
|
2452
|
+
if (enabled && precedes) {
|
|
2453
|
+
first = handle.element;
|
|
2454
|
+
}
|
|
2455
|
+
}
|
|
2456
|
+
return first;
|
|
2457
|
+
}
|
|
2458
|
+
handleBeforeToggle(event) {
|
|
2459
|
+
// Native close paths (light dismiss, a direct hidePopover()) skip hide()
|
|
2460
|
+
// but owe the same page release and focus return.
|
|
2461
|
+
if (event.newState === 'closed') {
|
|
2462
|
+
this.disengage(true);
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
// Close order: page live again, pending messages handed over, consumers
|
|
2466
|
+
// told, focus back on the opener, lock released. Idempotent through
|
|
2467
|
+
// `engaged`.
|
|
2468
|
+
disengage(emitClosing) {
|
|
2469
|
+
if (!this.engaged) {
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
this.restoreInert();
|
|
2473
|
+
this.handOffPendingAnnouncements();
|
|
2474
|
+
if (emitClosing) {
|
|
2475
|
+
this.closing.emit();
|
|
2476
|
+
}
|
|
2477
|
+
// On body counts as lost: CngxPopover's own teardown blurs the panel
|
|
2478
|
+
// before this one runs when both are destroyed together.
|
|
2479
|
+
const active = this.doc.activeElement;
|
|
2480
|
+
const focusLost = !active || active === this.doc.body || this.host.contains(active);
|
|
2481
|
+
if (this.restoreFocus() && focusLost) {
|
|
2482
|
+
this.focusFirstTaker([this.restoreTarget(), this.savedFocus, this.focusableAnchor()]);
|
|
2483
|
+
}
|
|
2484
|
+
this.release();
|
|
2485
|
+
}
|
|
2486
|
+
// Open order: focus, then inert, then lock. Focus first so the move
|
|
2487
|
+
// happens while the trigger is still focusable and inside the opening
|
|
2488
|
+
// gesture; inert after so the page never holds focus under inert.
|
|
2489
|
+
engage(moveFocus) {
|
|
2490
|
+
if (this.engaged) {
|
|
2491
|
+
return;
|
|
2492
|
+
}
|
|
2493
|
+
this.engaged = true;
|
|
2494
|
+
engagedSheets.push(this);
|
|
2495
|
+
if (typeof ngDevMode !== 'undefined' && ngDevMode) {
|
|
2496
|
+
warnSheetMisconfiguration(this.host, !this.labelledBy() && !this.titleRegistry.current(), this.popover.mode(), this.devWarned);
|
|
2497
|
+
}
|
|
2498
|
+
this.savedFocus = this.openerToRestore();
|
|
2499
|
+
this.region.ensure();
|
|
2500
|
+
this.liftOwnInert();
|
|
2501
|
+
if (moveFocus) {
|
|
2502
|
+
this.focusInitial();
|
|
2503
|
+
}
|
|
2504
|
+
this.applyInert();
|
|
2505
|
+
this.releaseLock = createPinnedScrollLock(this.doc.documentElement);
|
|
2506
|
+
this.startSettling();
|
|
2507
|
+
this.doc.addEventListener('pointerdown', this.outsidePointerDown, true);
|
|
2508
|
+
this.doc.addEventListener('keydown', this.escapeKeydown, true);
|
|
2509
|
+
this.closeWatcher.arm();
|
|
2510
|
+
}
|
|
2511
|
+
// The reverse: a flip back to modal while open re-homes focus into the
|
|
2512
|
+
// sheet. Deferred with afterNextRender so the restored modal DOM (host
|
|
2513
|
+
// tabindex, lifted inert, a visible sheet-header input) exists when
|
|
2514
|
+
// focusInitial reads it - a synchronous move inside the flip effect runs
|
|
2515
|
+
// before change detection applies those bindings. Independent of
|
|
2516
|
+
// `restoreFocus`, which governs a close, not a flip.
|
|
2517
|
+
rehomeFocusIntoSheet() {
|
|
2518
|
+
afterNextRender(() => {
|
|
2519
|
+
if (!this.engaged || !this.modal() || !this.popover.isVisible()) {
|
|
2520
|
+
return;
|
|
2521
|
+
}
|
|
2522
|
+
if (!this.host.contains(this.doc.activeElement)) {
|
|
2523
|
+
this.focusInitial();
|
|
2524
|
+
}
|
|
2525
|
+
}, { injector: this.injector });
|
|
2526
|
+
}
|
|
2527
|
+
// A flip back to anchored while open strips the modal focus targets (the
|
|
2528
|
+
// listbox loses its tabindex), so focus would drop to body. Independent of
|
|
2529
|
+
// `restoreFocus`, which governs a close, not a flip.
|
|
2530
|
+
rehomeFocusAfterFlip(opener) {
|
|
2531
|
+
afterNextRender(() => {
|
|
2532
|
+
const active = this.doc.activeElement;
|
|
2533
|
+
const lost = !active || active === this.doc.body || this.host.contains(active);
|
|
2534
|
+
if (lost) {
|
|
2535
|
+
this.focusFirstTaker([this.focusableAnchor(), opener]);
|
|
2536
|
+
}
|
|
2537
|
+
}, { injector: this.injector });
|
|
2538
|
+
}
|
|
2539
|
+
// A target can refuse focus: the opener of a sheet chain sits inside the
|
|
2540
|
+
// sheet the exclusive eviction just hid. Take the first one that holds it.
|
|
2541
|
+
focusFirstTaker(candidates) {
|
|
2542
|
+
for (const target of candidates) {
|
|
2543
|
+
if (!target?.isConnected) {
|
|
2544
|
+
continue;
|
|
2545
|
+
}
|
|
2546
|
+
target.focus();
|
|
2547
|
+
if (this.doc.activeElement === target) {
|
|
2548
|
+
return;
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
// An explicit anchor can be a non-focusable box; the implicit one (the
|
|
2553
|
+
// trigger) then takes the focus fallback.
|
|
2554
|
+
focusableAnchor() {
|
|
2555
|
+
const candidates = [this.popover.anchorElement(), this.popover.implicitAnchorElement()];
|
|
2556
|
+
return candidates.find((el) => !!el && el.tabIndex >= 0) ?? null;
|
|
2557
|
+
}
|
|
2558
|
+
// iOS Safari does not focus a button on tap (with or without VoiceOver),
|
|
2559
|
+
// so the pre-open snapshot is often body. Fall back to the popover's
|
|
2560
|
+
// anchor when it can take focus, so the close lands back on the opener.
|
|
2561
|
+
openerToRestore() {
|
|
2562
|
+
const origin = this.popover.focusOrigin();
|
|
2563
|
+
if (origin && origin !== this.doc.body) {
|
|
2564
|
+
return origin;
|
|
2565
|
+
}
|
|
2566
|
+
return this.focusableAnchor();
|
|
2567
|
+
}
|
|
2568
|
+
// Idempotent: hide(), the native toggle, a flip back to anchored and
|
|
2569
|
+
// destroy can all reach it. A flip back to anchored skips disengage(), so
|
|
2570
|
+
// the pending hand-off runs here too before the scoped regions go; the next
|
|
2571
|
+
// engage() recreates them.
|
|
2572
|
+
release() {
|
|
2573
|
+
this.doc.removeEventListener('pointerdown', this.outsidePointerDown, true);
|
|
2574
|
+
this.doc.removeEventListener('keydown', this.escapeKeydown, true);
|
|
2575
|
+
if (this.escapeKeyTimer !== null) {
|
|
2576
|
+
clearTimeout(this.escapeKeyTimer);
|
|
2577
|
+
this.escapeKeyTimer = null;
|
|
2578
|
+
}
|
|
2579
|
+
this.closeWatcher.disarm();
|
|
2580
|
+
this.restoreInert();
|
|
2581
|
+
this.releaseLock?.();
|
|
2582
|
+
this.releaseLock = null;
|
|
2583
|
+
this.stopSettling();
|
|
2584
|
+
this.handOffPendingAnnouncements();
|
|
2585
|
+
this.region.destroy();
|
|
2586
|
+
this.engaged = false;
|
|
2587
|
+
this.savedFocus = null;
|
|
2588
|
+
const index = engagedSheets.indexOf(this);
|
|
2589
|
+
if (index !== -1) {
|
|
2590
|
+
engagedSheets.splice(index, 1);
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
handleBackGesture() {
|
|
2594
|
+
if (this.escapeKeyTimer !== null) {
|
|
2595
|
+
if (this.engaged) {
|
|
2596
|
+
this.closeWatcher.arm();
|
|
2597
|
+
}
|
|
2598
|
+
return;
|
|
2599
|
+
}
|
|
2600
|
+
this.requestClose('back');
|
|
2601
|
+
// A blocked request leaves the sheet open; the spent watcher would let
|
|
2602
|
+
// the next back gesture navigate away.
|
|
2603
|
+
if (this.engaged) {
|
|
2604
|
+
this.closeWatcher.arm();
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
armClickSwallow() {
|
|
2608
|
+
this.doc.addEventListener('mousedown', this.swallowMouseDown, true);
|
|
2609
|
+
this.doc.addEventListener('click', this.swallowClick, true);
|
|
2610
|
+
this.clickSwallowTimer = setTimeout(() => this.disarmClickSwallow(), CLICK_SWALLOW_MS);
|
|
2611
|
+
}
|
|
2612
|
+
disarmClickSwallow() {
|
|
2613
|
+
this.doc.removeEventListener('mousedown', this.swallowMouseDown, true);
|
|
2614
|
+
this.doc.removeEventListener('click', this.swallowClick, true);
|
|
2615
|
+
if (this.clickSwallowTimer !== null) {
|
|
2616
|
+
clearTimeout(this.clickSwallowTimer);
|
|
2617
|
+
this.clickSwallowTimer = null;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
liftOwnInert() {
|
|
2621
|
+
let node = this.host;
|
|
2622
|
+
while (node && node !== this.doc.body) {
|
|
2623
|
+
if ((inertClaims.get(node) ?? 0) > 0 && node.hasAttribute('inert')) {
|
|
2624
|
+
node.removeAttribute('inert');
|
|
2625
|
+
this.lifted.push(node);
|
|
2626
|
+
}
|
|
2627
|
+
node = node.parentElement;
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
applyInert() {
|
|
2631
|
+
const body = this.doc.body;
|
|
2632
|
+
let node = this.host;
|
|
2633
|
+
while (node !== body && node.parentElement) {
|
|
2634
|
+
const parent = node.parentElement;
|
|
2635
|
+
for (const sibling of Array.from(parent.children)) {
|
|
2636
|
+
if (sibling === node || !(sibling instanceof HTMLElement) || this.skipsInert(sibling)) {
|
|
2637
|
+
continue;
|
|
2638
|
+
}
|
|
2639
|
+
inertClaims.set(sibling, (inertClaims.get(sibling) ?? 0) + 1);
|
|
2640
|
+
sibling.setAttribute('inert', '');
|
|
2641
|
+
this.inerted.push(sibling);
|
|
2642
|
+
}
|
|
2643
|
+
node = parent;
|
|
2644
|
+
}
|
|
2645
|
+
}
|
|
2646
|
+
skipsInert(el) {
|
|
2647
|
+
const preExisting = el.hasAttribute('inert') && !inertClaims.get(el);
|
|
2648
|
+
return (preExisting ||
|
|
2649
|
+
el.classList.contains(FOCUS_TRAP_ANCHOR_CLASS) ||
|
|
2650
|
+
el.matches(LIVE_REGION_SELECTOR));
|
|
2651
|
+
}
|
|
2652
|
+
restoreInert() {
|
|
2653
|
+
for (const el of this.inerted) {
|
|
2654
|
+
const claims = (inertClaims.get(el) ?? 1) - 1;
|
|
2655
|
+
if (claims > 0) {
|
|
2656
|
+
inertClaims.set(el, claims);
|
|
2657
|
+
continue;
|
|
2658
|
+
}
|
|
2659
|
+
inertClaims.delete(el);
|
|
2660
|
+
el.removeAttribute('inert');
|
|
2661
|
+
}
|
|
2662
|
+
this.inerted = [];
|
|
2663
|
+
for (const el of this.lifted) {
|
|
2664
|
+
if ((inertClaims.get(el) ?? 0) > 0) {
|
|
2665
|
+
el.setAttribute('inert', '');
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
this.lifted = [];
|
|
2669
|
+
}
|
|
2670
|
+
// A message announced right before close would land in a region that is
|
|
2671
|
+
// about to hide; the root announcer speaks it after the close instead.
|
|
2672
|
+
handOffPendingAnnouncements() {
|
|
2673
|
+
for (const pending of this.region.takePending()) {
|
|
2674
|
+
this.announcer.announce(pending.message, pending.politeness);
|
|
2675
|
+
}
|
|
2676
|
+
}
|
|
2677
|
+
// The pinned lock shifts the page for one frame on iOS. Keep the panel
|
|
2678
|
+
// invisible until two consecutive frames report the same rect.
|
|
2679
|
+
startSettling() {
|
|
2680
|
+
const raf = this.win?.requestAnimationFrame?.bind(this.win);
|
|
2681
|
+
if (!raf) {
|
|
2682
|
+
return;
|
|
2683
|
+
}
|
|
2684
|
+
this.host.setAttribute(SETTLING_ATTRIBUTE, '');
|
|
2685
|
+
let previous = null;
|
|
2686
|
+
let frames = 0;
|
|
2687
|
+
const check = () => {
|
|
2688
|
+
frames += 1;
|
|
2689
|
+
const rect = this.host.getBoundingClientRect();
|
|
2690
|
+
const stable = previous !== null &&
|
|
2691
|
+
previous.top === rect.top &&
|
|
2692
|
+
previous.left === rect.left &&
|
|
2693
|
+
previous.width === rect.width &&
|
|
2694
|
+
previous.height === rect.height;
|
|
2695
|
+
if (stable || frames >= SETTLING_FRAME_CAP) {
|
|
2696
|
+
this.stopSettling();
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
previous = rect;
|
|
2700
|
+
this.settlingFrame = raf(check);
|
|
2701
|
+
};
|
|
2702
|
+
this.settlingFrame = raf(check);
|
|
2703
|
+
}
|
|
2704
|
+
stopSettling() {
|
|
2705
|
+
if (this.settlingFrame !== null) {
|
|
2706
|
+
this.win?.cancelAnimationFrame?.(this.settlingFrame);
|
|
2707
|
+
this.settlingFrame = null;
|
|
2708
|
+
}
|
|
2709
|
+
this.host.removeAttribute(SETTLING_ATTRIBUTE);
|
|
2710
|
+
}
|
|
2711
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheet, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2712
|
+
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: [
|
|
2713
|
+
{ provide: CNGX_POPOVER_PRESENTATION, useExisting: CngxPopoverSheet },
|
|
2714
|
+
{ provide: CNGX_POPOVER_SHEET_HOST, useExisting: CngxPopoverSheet },
|
|
2715
|
+
{ provide: CNGX_FOCUS_TRAP_DRIVER, useExisting: CngxPopoverSheet },
|
|
2716
|
+
], exportAs: ["cngxPopoverSheet"], hostDirectives: [{ directive: i1.CngxFocusTrap }], ngImport: i0 });
|
|
2717
|
+
}
|
|
2718
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheet, decorators: [{
|
|
2719
|
+
type: Directive,
|
|
2720
|
+
args: [{
|
|
2721
|
+
selector: '[cngxPopoverSheet]',
|
|
2722
|
+
exportAs: 'cngxPopoverSheet',
|
|
2723
|
+
standalone: true,
|
|
2724
|
+
hostDirectives: [{ directive: CngxFocusTrap, inputs: [], outputs: [] }],
|
|
2725
|
+
providers: [
|
|
2726
|
+
{ provide: CNGX_POPOVER_PRESENTATION, useExisting: CngxPopoverSheet },
|
|
2727
|
+
{ provide: CNGX_POPOVER_SHEET_HOST, useExisting: CngxPopoverSheet },
|
|
2728
|
+
{ provide: CNGX_FOCUS_TRAP_DRIVER, useExisting: CngxPopoverSheet },
|
|
2729
|
+
],
|
|
2730
|
+
host: {
|
|
2731
|
+
class: 'cngx-popover-sheet',
|
|
2732
|
+
'[attr.data-cngx-sheet]': 'request()',
|
|
2733
|
+
'[attr.data-cngx-presentation]': 'presentation()',
|
|
2734
|
+
'[attr.role]': 'roleAttr()',
|
|
2735
|
+
'[attr.aria-modal]': 'ariaModal()',
|
|
2736
|
+
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
2737
|
+
'[attr.tabindex]': 'tabindexAttr()',
|
|
2738
|
+
'(beforetoggle)': 'handleBeforeToggle($event)',
|
|
2739
|
+
},
|
|
2740
|
+
}]
|
|
2741
|
+
}], 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"] }] } });
|
|
2742
|
+
|
|
2743
|
+
// Header and handle share the swipe wiring: a CngxSwipeDismiss on the same
|
|
2744
|
+
// element closes the sheet through closeRequested (CngxBottomSheet precedent).
|
|
2745
|
+
function routeSwipeToSheet(part) {
|
|
2746
|
+
const sheet = injectPopoverSheetHost(part);
|
|
2747
|
+
const swipe = inject(CngxSwipeDismiss, { self: true, optional: true });
|
|
2748
|
+
if (!swipe) {
|
|
2749
|
+
return;
|
|
2750
|
+
}
|
|
2751
|
+
const sub = swipe.swiped.subscribe(() => sheet.requestClose('swipe'));
|
|
2752
|
+
inject(DestroyRef).onDestroy(() => sub.unsubscribe());
|
|
2753
|
+
}
|
|
2754
|
+
/**
|
|
2755
|
+
* Header row of a `CngxPopoverSheet`. Stays put while the content below it
|
|
2756
|
+
* scrolls; add `cngxSwipeDismiss="down"` to close the sheet by swiping it.
|
|
2757
|
+
*
|
|
2758
|
+
* @since 0.3.0
|
|
2759
|
+
* @relatedTo CngxPopoverSheet, CngxSwipeDismiss
|
|
2760
|
+
*/
|
|
2761
|
+
class CngxPopoverSheetHeader {
|
|
2762
|
+
constructor() {
|
|
2763
|
+
routeSwipeToSheet('cngxPopoverSheetHeader');
|
|
2764
|
+
}
|
|
2765
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHeader, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2766
|
+
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 });
|
|
2767
|
+
}
|
|
2768
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHeader, decorators: [{
|
|
2769
|
+
type: Directive,
|
|
2770
|
+
args: [{
|
|
2771
|
+
selector: '[cngxPopoverSheetHeader]',
|
|
2772
|
+
standalone: true,
|
|
2773
|
+
host: { class: 'cngx-popover-sheet-header' },
|
|
2774
|
+
}]
|
|
2775
|
+
}], ctorParameters: () => [] });
|
|
2776
|
+
/**
|
|
2777
|
+
* The element that names a modal `CngxPopoverSheet`. The sheet points its
|
|
2778
|
+
* `aria-labelledby` here, never at the header that also holds buttons.
|
|
2779
|
+
*
|
|
2780
|
+
* @since 0.3.0
|
|
2781
|
+
* @relatedTo CngxPopoverSheet
|
|
2782
|
+
*/
|
|
2783
|
+
class CngxPopoverSheetTitle {
|
|
2784
|
+
/** Generated id the sheet references. */
|
|
2785
|
+
id = signal(nextUid('cngx-popover-sheet-title')).asReadonly();
|
|
2786
|
+
constructor() {
|
|
2787
|
+
const sheet = injectPopoverSheetHost('cngxPopoverSheetTitle');
|
|
2788
|
+
sheet.titleRegistry.register(this);
|
|
2789
|
+
inject(DestroyRef).onDestroy(() => sheet.titleRegistry.unregister(this));
|
|
2790
|
+
}
|
|
2791
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetTitle, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2792
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverSheetTitle, isStandalone: true, selector: "[cngxPopoverSheetTitle]", host: { properties: { "id": "id()" } }, ngImport: i0 });
|
|
2793
|
+
}
|
|
2794
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetTitle, decorators: [{
|
|
2795
|
+
type: Directive,
|
|
2796
|
+
args: [{
|
|
2797
|
+
selector: '[cngxPopoverSheetTitle]',
|
|
2798
|
+
standalone: true,
|
|
2799
|
+
host: { '[id]': 'id()' },
|
|
2800
|
+
}]
|
|
2801
|
+
}], ctorParameters: () => [] });
|
|
2802
|
+
/**
|
|
2803
|
+
* Decorative drag handle. Always `aria-hidden`: screen-reader users close
|
|
2804
|
+
* the sheet through its close control, since their swipe is consumed by
|
|
2805
|
+
* navigation.
|
|
2806
|
+
*
|
|
2807
|
+
* @since 0.3.0
|
|
2808
|
+
* @relatedTo CngxPopoverSheet
|
|
2809
|
+
*/
|
|
2810
|
+
class CngxPopoverSheetHandle {
|
|
2811
|
+
constructor() {
|
|
2812
|
+
routeSwipeToSheet('cngxPopoverSheetHandle');
|
|
2813
|
+
}
|
|
2814
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHandle, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2815
|
+
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 });
|
|
2816
|
+
}
|
|
2817
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetHandle, decorators: [{
|
|
2818
|
+
type: Directive,
|
|
2819
|
+
args: [{
|
|
2820
|
+
selector: '[cngxPopoverSheetHandle]',
|
|
2821
|
+
standalone: true,
|
|
2822
|
+
host: { class: 'cngx-popover-sheet-handle', 'aria-hidden': 'true' },
|
|
2823
|
+
}]
|
|
2824
|
+
}], ctorParameters: () => [] });
|
|
2825
|
+
/**
|
|
2826
|
+
* Marks the element that receives focus when a modal `CngxPopoverSheet`
|
|
2827
|
+
* opens, e.g. the search input of a fullscreen panel. Without one the first
|
|
2828
|
+
* tabbable element is focused.
|
|
2829
|
+
*
|
|
2830
|
+
* A panel can mark several elements. The first enabled one in document order
|
|
2831
|
+
* takes focus, so a search field that should lead only some opens binds
|
|
2832
|
+
* `[cngxPopoverSheetInitialFocus]="condition"` and the list below it carries
|
|
2833
|
+
* the bare attribute as the default target. The condition is read when the
|
|
2834
|
+
* sheet opens.
|
|
2835
|
+
*
|
|
2836
|
+
* @since 0.3.0
|
|
2837
|
+
* @relatedTo CngxPopoverSheet
|
|
2838
|
+
*/
|
|
2839
|
+
class CngxPopoverSheetInitialFocus {
|
|
2840
|
+
/** The element focused on open. */
|
|
2841
|
+
element = inject(ElementRef).nativeElement;
|
|
2842
|
+
/**
|
|
2843
|
+
* `false` keeps this element out of the next open's focus choice. The bare
|
|
2844
|
+
* attribute, or no binding, leaves it enabled.
|
|
2845
|
+
*/
|
|
2846
|
+
enabledInput = input(undefined, { ...(ngDevMode ? { debugName: "enabledInput" } : /* istanbul ignore next */ {}), alias: 'cngxPopoverSheetInitialFocus',
|
|
2847
|
+
transform: (v) => (typeof v === 'string' ? undefined : v) });
|
|
2848
|
+
/** @internal Read by the sheet on open. */
|
|
2849
|
+
enabled = computed(() => this.enabledInput() !== false, ...(ngDevMode ? [{ debugName: "enabled" }] : /* istanbul ignore next */ []));
|
|
2850
|
+
key = nextUid('cngx-popover-sheet-initial-focus');
|
|
2851
|
+
constructor() {
|
|
2852
|
+
const sheet = injectPopoverSheetHost('cngxPopoverSheetInitialFocus');
|
|
2853
|
+
sheet.initialFocusRegistry.register(this.key, this);
|
|
2854
|
+
inject(DestroyRef).onDestroy(() => sheet.initialFocusRegistry.unregister(this.key, this));
|
|
2855
|
+
}
|
|
2856
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetInitialFocus, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2857
|
+
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 });
|
|
2858
|
+
}
|
|
2859
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverSheetInitialFocus, decorators: [{
|
|
2860
|
+
type: Directive,
|
|
2861
|
+
args: [{
|
|
2862
|
+
selector: '[cngxPopoverSheetInitialFocus]',
|
|
2863
|
+
standalone: true,
|
|
2864
|
+
}]
|
|
2865
|
+
}], ctorParameters: () => [], propDecorators: { enabledInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "cngxPopoverSheetInitialFocus", required: false }] }] } });
|
|
2866
|
+
|
|
2867
|
+
/** @internal Default configuration - no auto-dismiss, no close-on-success, variant='default'. */
|
|
2868
|
+
const DEFAULT_CONFIG = {
|
|
2869
|
+
defaultVariant: 'default',
|
|
2870
|
+
};
|
|
2871
|
+
/**
|
|
2872
|
+
* Injection token for popover panel configuration.
|
|
2873
|
+
*
|
|
2874
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel.config.ts
|
|
2875
|
+
* @since 0.3.0
|
|
2876
|
+
*/
|
|
2877
|
+
const CNGX_POPOVER_PANEL_CONFIG = new InjectionToken('CngxPopoverPanelConfig', { factory: () => DEFAULT_CONFIG });
|
|
2878
|
+
/**
|
|
2879
|
+
* Provides configuration for `CngxPopoverPanel` instances.
|
|
2880
|
+
*
|
|
2881
|
+
* ```typescript
|
|
2882
|
+
* providers: [
|
|
2883
|
+
* providePopoverPanel(
|
|
2884
|
+
* withAutoDismiss({ info: 5000, success: 3000 }),
|
|
2885
|
+
* withCloseOnSuccess(300),
|
|
2886
|
+
* ),
|
|
2887
|
+
* ]
|
|
2888
|
+
* ```
|
|
2889
|
+
*/
|
|
2890
|
+
function providePopoverPanel(...features) {
|
|
2891
|
+
const config = features.reduce((acc, f) => f(acc), { ...DEFAULT_CONFIG });
|
|
2892
|
+
return { provide: CNGX_POPOVER_PANEL_CONFIG, useValue: config };
|
|
2893
|
+
}
|
|
2894
|
+
/**
|
|
2895
|
+
* Auto-dismiss the panel after a timeout, per variant.
|
|
2896
|
+
*
|
|
2897
|
+
* @param timing - Map of variant name to dismiss duration in ms.
|
|
2898
|
+
* ```typescript
|
|
2899
|
+
* withAutoDismiss({ info: 5000, success: 3000 })
|
|
2900
|
+
* ```
|
|
2901
|
+
*/
|
|
2902
|
+
function withAutoDismiss(timing) {
|
|
2903
|
+
return (config) => ({ ...config, autoDismiss: { ...config.autoDismiss, ...timing } });
|
|
2904
|
+
}
|
|
2905
|
+
/**
|
|
2906
|
+
* Auto-close the panel after an async action in the footer succeeds.
|
|
2907
|
+
*
|
|
2908
|
+
* @param delay - Delay in ms before closing. Defaults to `300`.
|
|
2909
|
+
*/
|
|
2910
|
+
function withCloseOnSuccess(delay = 300) {
|
|
2911
|
+
return (config) => ({ ...config, closeOnSuccessDelay: delay });
|
|
2912
|
+
}
|
|
2913
|
+
/**
|
|
2914
|
+
* Set the default variant applied when no `variant` input is set.
|
|
2915
|
+
*/
|
|
2916
|
+
function withDefaultVariant(variant) {
|
|
2917
|
+
return (config) => ({ ...config, defaultVariant: variant });
|
|
2918
|
+
}
|
|
2919
|
+
/**
|
|
2920
|
+
* Show the close button on all panels by default.
|
|
2921
|
+
*/
|
|
2922
|
+
function withCloseButton(show = true) {
|
|
2923
|
+
return (config) => ({ ...config, showClose: show });
|
|
2924
|
+
}
|
|
2925
|
+
/**
|
|
2926
|
+
* Show the arrow on all panels by default.
|
|
2927
|
+
*/
|
|
2928
|
+
function withArrow(show = true) {
|
|
2929
|
+
return (config) => ({ ...config, showArrow: show });
|
|
2930
|
+
}
|
|
2931
|
+
/**
|
|
2932
|
+
* Register an app-wide default template for the panel's arrow ornament.
|
|
2933
|
+
* The template receives a `CngxPopoverArrowContext` with `edge` and
|
|
2934
|
+
* `offsetPx` so the consumer's glyph can match the resolved placement.
|
|
2935
|
+
*
|
|
2936
|
+
* Per-instance `*cngxPopoverArrow` still wins over this default; the
|
|
2937
|
+
* library's rotated-diamond fallback only renders when neither tier is
|
|
2938
|
+
* set.
|
|
2939
|
+
*
|
|
2940
|
+
* ```typescript
|
|
2941
|
+
* providers: [
|
|
2942
|
+
* providePopoverPanel(withArrowTemplate(brandArrowTpl)),
|
|
2943
|
+
* ]
|
|
2944
|
+
* ```
|
|
2945
|
+
*/
|
|
2946
|
+
function withArrowTemplate(tpl) {
|
|
2947
|
+
return (config) => ({ ...config, templates: { ...config.templates, arrow: tpl } });
|
|
2948
|
+
}
|
|
2949
|
+
/**
|
|
2950
|
+
* Set the app-wide panel copy. Unset keys keep the language pack's copy, or
|
|
2951
|
+
* the English default; pass a
|
|
2952
|
+
* `Signal` of a partial bundle to switch languages at runtime. A later call
|
|
2953
|
+
* replaces the whole bundle. Mirrors `withDialogLabels`.
|
|
2954
|
+
*
|
|
2955
|
+
* ```typescript
|
|
1723
2956
|
* providers: [
|
|
1724
2957
|
* providePopoverPanel(withPopoverPanelLabels({ close: 'Schliessen' })),
|
|
1725
2958
|
* ]
|
|
1726
2959
|
* ```
|
|
1727
2960
|
*
|
|
1728
|
-
* @
|
|
1729
|
-
* @since 0.1.0
|
|
2961
|
+
* @since 0.3.0
|
|
1730
2962
|
*/
|
|
1731
2963
|
function withPopoverPanelLabels(labels) {
|
|
1732
2964
|
return (config) => ({ ...config, labels });
|
|
@@ -1736,20 +2968,21 @@ function withPopoverPanelLabels(labels) {
|
|
|
1736
2968
|
* The English popover section: the single source of the popover panel's
|
|
1737
2969
|
* English copy.
|
|
1738
2970
|
*
|
|
1739
|
-
* @
|
|
1740
|
-
* @since 0.1.0
|
|
2971
|
+
* @since 0.3.0
|
|
1741
2972
|
* @relatedTo CngxPopoverPanel
|
|
1742
2973
|
*/
|
|
1743
2974
|
const CNGX_POPOVER_LANGUAGE_EN = {
|
|
1744
2975
|
close: 'Close',
|
|
2976
|
+
loading: 'Loading',
|
|
2977
|
+
error: 'Could not load',
|
|
2978
|
+
empty: 'Nothing to show',
|
|
1745
2979
|
};
|
|
1746
2980
|
|
|
1747
2981
|
/**
|
|
1748
2982
|
* Marks the header content inside `cngx-popover-panel`.
|
|
1749
2983
|
*
|
|
1750
|
-
* @category common/popover
|
|
1751
2984
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1752
|
-
* @since 0.
|
|
2985
|
+
* @since 0.3.0
|
|
1753
2986
|
* @relatedTo CngxPopoverPanel, CngxPopoverBody, CngxPopoverFooter
|
|
1754
2987
|
*/
|
|
1755
2988
|
class CngxPopoverHeader {
|
|
@@ -1763,9 +2996,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1763
2996
|
/**
|
|
1764
2997
|
* Marks the body content inside `cngx-popover-panel`.
|
|
1765
2998
|
*
|
|
1766
|
-
* @category common/popover
|
|
1767
2999
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1768
|
-
* @since 0.
|
|
3000
|
+
* @since 0.3.0
|
|
1769
3001
|
* @relatedTo CngxPopoverPanel, CngxPopoverHeader, CngxPopoverFooter
|
|
1770
3002
|
*/
|
|
1771
3003
|
class CngxPopoverBody {
|
|
@@ -1779,9 +3011,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1779
3011
|
/**
|
|
1780
3012
|
* Marks the footer content inside `cngx-popover-panel`.
|
|
1781
3013
|
*
|
|
1782
|
-
* @category common/popover
|
|
1783
3014
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1784
|
-
* @since 0.
|
|
3015
|
+
* @since 0.3.0
|
|
1785
3016
|
* @relatedTo CngxPopoverPanel, CngxPopoverHeader, CngxPopoverBody, CngxPopoverAction
|
|
1786
3017
|
*/
|
|
1787
3018
|
class CngxPopoverFooter {
|
|
@@ -1803,9 +3034,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1803
3034
|
* </ng-template>
|
|
1804
3035
|
* ```
|
|
1805
3036
|
*
|
|
1806
|
-
* @category common/popover
|
|
1807
3037
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1808
|
-
* @since 0.
|
|
3038
|
+
* @since 0.3.0
|
|
1809
3039
|
* @relatedTo CngxPopoverPanel
|
|
1810
3040
|
*/
|
|
1811
3041
|
class CngxPopoverClose {
|
|
@@ -1818,15 +3048,24 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1818
3048
|
args: [{ selector: 'ng-template[cngxPopoverClose]', standalone: true }]
|
|
1819
3049
|
}] });
|
|
1820
3050
|
/**
|
|
1821
|
-
* Template shown while panel content is loading.
|
|
3051
|
+
* Template shown while panel content is loading. Context:
|
|
3052
|
+
* `CngxPopoverStateCopyContext` (`$implicit` / `text` = resolved loading copy).
|
|
3053
|
+
*
|
|
3054
|
+
* ```html
|
|
3055
|
+
* <ng-template cngxPopoverLoading let-text>
|
|
3056
|
+
* <span class="brand-spinner" aria-hidden="true"></span> {{ text }}
|
|
3057
|
+
* </ng-template>
|
|
3058
|
+
* ```
|
|
1822
3059
|
*
|
|
1823
|
-
* @category common/popover
|
|
1824
3060
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1825
|
-
* @since 0.
|
|
3061
|
+
* @since 0.3.0
|
|
1826
3062
|
* @relatedTo CngxPopoverPanel, CngxPopoverEmpty, CngxPopoverError
|
|
1827
3063
|
*/
|
|
1828
3064
|
class CngxPopoverLoading {
|
|
1829
3065
|
templateRef = inject(TemplateRef);
|
|
3066
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
3067
|
+
return true;
|
|
3068
|
+
}
|
|
1830
3069
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverLoading, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1831
3070
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverLoading, isStandalone: true, selector: "ng-template[cngxPopoverLoading]", ngImport: i0 });
|
|
1832
3071
|
}
|
|
@@ -1835,15 +3074,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1835
3074
|
args: [{ selector: 'ng-template[cngxPopoverLoading]', standalone: true }]
|
|
1836
3075
|
}] });
|
|
1837
3076
|
/**
|
|
1838
|
-
* Template shown when panel content is empty.
|
|
3077
|
+
* Template shown when panel content is empty. Context:
|
|
3078
|
+
* `CngxPopoverStateCopyContext` (`$implicit` / `text` = resolved empty copy).
|
|
1839
3079
|
*
|
|
1840
|
-
* @category common/popover
|
|
1841
3080
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1842
|
-
* @since 0.
|
|
3081
|
+
* @since 0.3.0
|
|
1843
3082
|
* @relatedTo CngxPopoverPanel, CngxPopoverLoading, CngxPopoverError
|
|
1844
3083
|
*/
|
|
1845
3084
|
class CngxPopoverEmpty {
|
|
1846
3085
|
templateRef = inject(TemplateRef);
|
|
3086
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
3087
|
+
return true;
|
|
3088
|
+
}
|
|
1847
3089
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1848
3090
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverEmpty, isStandalone: true, selector: "ng-template[cngxPopoverEmpty]", ngImport: i0 });
|
|
1849
3091
|
}
|
|
@@ -1852,15 +3094,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1852
3094
|
args: [{ selector: 'ng-template[cngxPopoverEmpty]', standalone: true }]
|
|
1853
3095
|
}] });
|
|
1854
3096
|
/**
|
|
1855
|
-
* Template shown when panel content failed to load. Context:
|
|
3097
|
+
* Template shown when panel content failed to load. Context:
|
|
3098
|
+
* `CngxPopoverErrorContext` (`$implicit` / `error` = the raw error, `text` =
|
|
3099
|
+
* resolved error copy).
|
|
1856
3100
|
*
|
|
1857
|
-
* @category common/popover
|
|
1858
3101
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1859
|
-
* @since 0.
|
|
3102
|
+
* @since 0.3.0
|
|
1860
3103
|
* @relatedTo CngxPopoverPanel, CngxPopoverLoading, CngxPopoverEmpty
|
|
1861
3104
|
*/
|
|
1862
3105
|
class CngxPopoverError {
|
|
1863
3106
|
templateRef = inject(TemplateRef);
|
|
3107
|
+
static ngTemplateContextGuard(_dir, ctx) {
|
|
3108
|
+
return true;
|
|
3109
|
+
}
|
|
1864
3110
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1865
3111
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverError, isStandalone: true, selector: "ng-template[cngxPopoverError]", ngImport: i0 });
|
|
1866
3112
|
}
|
|
@@ -1885,9 +3131,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1885
3131
|
* </cngx-popover-panel>
|
|
1886
3132
|
* ```
|
|
1887
3133
|
*
|
|
1888
|
-
* @category common/popover
|
|
1889
3134
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel-slots.ts
|
|
1890
|
-
* @since 0.
|
|
3135
|
+
* @since 0.3.0
|
|
1891
3136
|
* @relatedTo CngxPopoverPanel, CngxPopover
|
|
1892
3137
|
*/
|
|
1893
3138
|
class CngxPopoverArrow {
|
|
@@ -1915,6 +3160,13 @@ const injectPopoverPanelLanguage = createLanguageSection('popover', CNGX_POPOVER
|
|
|
1915
3160
|
* `closeOnOutsideClick`, `mode`, `exclusive`, `cngxPopoverOpen`) are
|
|
1916
3161
|
* forwarded.
|
|
1917
3162
|
*
|
|
3163
|
+
* ### Focus return
|
|
3164
|
+
* On by default: when the panel closes and focus would otherwise be lost
|
|
3165
|
+
* (on `body` or inside the panel), its `CngxPopoverTrigger` returns focus
|
|
3166
|
+
* to the element focused before open. Opt out with `[restoreFocus]="false"`
|
|
3167
|
+
* on the trigger. A close that moves focus to another control leaves it
|
|
3168
|
+
* there.
|
|
3169
|
+
*
|
|
1918
3170
|
* The `variant` input is a free-form string mapped to a CSS class
|
|
1919
3171
|
* (`cngx-popover-panel--{variant}`). Five variants are pre-themed
|
|
1920
3172
|
* in `popover-panel-theme.scss`: `default`, `info`, `warning`,
|
|
@@ -1927,10 +3179,8 @@ const injectPopoverPanelLanguage = createLanguageSection('popover', CNGX_POPOVER
|
|
|
1927
3179
|
* <span cngxPopoverHeader>Delete Item?</span>
|
|
1928
3180
|
* <p cngxPopoverBody>This action cannot be undone.</p>
|
|
1929
3181
|
* <div cngxPopoverFooter>
|
|
1930
|
-
* <
|
|
1931
|
-
* <
|
|
1932
|
-
* Delete
|
|
1933
|
-
* </cngx-popover-action>
|
|
3182
|
+
* <button cngxPopoverDismiss>Cancel</button>
|
|
3183
|
+
* <button cngxPopoverAction="solid" tone="danger" [action]="delete">Delete</button>
|
|
1934
3184
|
* </div>
|
|
1935
3185
|
* </cngx-popover-panel>
|
|
1936
3186
|
* ```
|
|
@@ -1944,20 +3194,28 @@ const injectPopoverPanelLanguage = createLanguageSection('popover', CNGX_POPOVER
|
|
|
1944
3194
|
* </cngx-popover-panel>
|
|
1945
3195
|
* ```
|
|
1946
3196
|
*
|
|
1947
|
-
*
|
|
1948
|
-
*
|
|
3197
|
+
* ### State copy
|
|
3198
|
+
* The loading, error and empty views never render an empty box. Without a
|
|
3199
|
+
* slot template each shows default copy, resolved in this order: the
|
|
3200
|
+
* projected `*cngxPopoverLoading` / `*cngxPopoverError` / `*cngxPopoverEmpty`
|
|
3201
|
+
* template (replaces the whole node), then `[loadingText]` / `[errorText]` /
|
|
3202
|
+
* `[emptyText]`, then `withPopoverPanelLabels(...)`, then the `popover`
|
|
3203
|
+
* section of the language pack. The header row (title and close button)
|
|
3204
|
+
* stays in every view.
|
|
3205
|
+
*
|
|
1949
3206
|
* @wcag AA
|
|
1950
3207
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-panel.component.ts
|
|
1951
|
-
* @since 0.
|
|
1952
|
-
* @relatedTo CngxPopover, CngxPopoverAction, CngxPopoverHeader, CngxPopoverBody, CngxPopoverFooter
|
|
3208
|
+
* @since 0.3.0
|
|
3209
|
+
* @relatedTo CngxPopover, CngxPopoverAction, CngxPopoverDismiss, CngxPopoverHeader, CngxPopoverBody, CngxPopoverFooter
|
|
1953
3210
|
* @slot cngxPopoverArrow Replaces the pointer that ties the panel to its trigger.
|
|
1954
3211
|
* @slot cngxPopoverClose Replaces the dismiss control.
|
|
1955
3212
|
* @slot cngxPopoverLoading Rendered while the panel's content is loading.
|
|
1956
3213
|
* @slot cngxPopoverEmpty Rendered when the panel has nothing to show.
|
|
1957
3214
|
* @slot cngxPopoverError Rendered when the panel's content failed to load.
|
|
1958
|
-
* <example-url
|
|
1959
|
-
* <example-url
|
|
1960
|
-
* <example-url
|
|
3215
|
+
* <example-url>/#/common/popover/popover-panel/content-states</example-url>
|
|
3216
|
+
* <example-url>/#/common/popover/popover-panel/variants</example-url>
|
|
3217
|
+
* <example-url>/#/common/popover/popover-panel/with-footer-actions</example-url>
|
|
3218
|
+
* @axis level organism
|
|
1961
3219
|
*/
|
|
1962
3220
|
class CngxPopoverPanel {
|
|
1963
3221
|
/** The underlying popover state machine. */
|
|
@@ -2010,6 +3268,15 @@ class CngxPopoverPanel {
|
|
|
2010
3268
|
labels = createOverrideMerge(injectPopoverPanelLanguage(), this.config.labels);
|
|
2011
3269
|
/** Accessible name of the built-in close button. */
|
|
2012
3270
|
closeLabel = computed(() => this.labels().close, ...(ngDevMode ? [{ debugName: "closeLabel" }] : /* istanbul ignore next */ []));
|
|
3271
|
+
/**
|
|
3272
|
+
* Copy of the state views: rendered without a slot template, handed to a
|
|
3273
|
+
* slot template as its `text` context. Input, then config, then pack.
|
|
3274
|
+
* Read tracked on purpose - the panel has no live region, so a language
|
|
3275
|
+
* flip only updates the visible text in place.
|
|
3276
|
+
*/
|
|
3277
|
+
resolvedLoadingText = computed(() => this.loadingText() ?? this.labels().loading, ...(ngDevMode ? [{ debugName: "resolvedLoadingText" }] : /* istanbul ignore next */ []));
|
|
3278
|
+
resolvedErrorText = computed(() => this.errorText() ?? this.labels().error, ...(ngDevMode ? [{ debugName: "resolvedErrorText" }] : /* istanbul ignore next */ []));
|
|
3279
|
+
resolvedEmptyText = computed(() => this.emptyText() ?? this.labels().empty, ...(ngDevMode ? [{ debugName: "resolvedEmptyText" }] : /* istanbul ignore next */ []));
|
|
2013
3280
|
/** Resolved showClose - input takes precedence over config. */
|
|
2014
3281
|
showClose = computed(() => this.showCloseInput() ?? this.config.showClose ?? false, ...(ngDevMode ? [{ debugName: "showClose" }] : /* istanbul ignore next */ []));
|
|
2015
3282
|
/** Resolved showArrow - input takes precedence over config. */
|
|
@@ -2025,12 +3292,52 @@ class CngxPopoverPanel {
|
|
|
2025
3292
|
error = input(undefined, ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
|
|
2026
3293
|
/** Whether the panel content is empty. Fallback when `[state]` is not set. */
|
|
2027
3294
|
empty = input(false, ...(ngDevMode ? [{ debugName: "empty" }] : /* istanbul ignore next */ []));
|
|
2028
|
-
/**
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
3295
|
+
/**
|
|
3296
|
+
* Text shown in the loading view when no `*cngxPopoverLoading` template is
|
|
3297
|
+
* projected. Unbound, it falls back to `withPopoverPanelLabels` and the
|
|
3298
|
+
* `popover` section of the language pack.
|
|
3299
|
+
*/
|
|
3300
|
+
loadingText = input(undefined, ...(ngDevMode ? [{ debugName: "loadingText" }] : /* istanbul ignore next */ []));
|
|
3301
|
+
/**
|
|
3302
|
+
* Text shown in the error view when no `*cngxPopoverError` template is
|
|
3303
|
+
* projected. Unbound, it falls back to `withPopoverPanelLabels` and the
|
|
3304
|
+
* `popover` section of the language pack.
|
|
3305
|
+
*/
|
|
3306
|
+
errorText = input(undefined, ...(ngDevMode ? [{ debugName: "errorText" }] : /* istanbul ignore next */ []));
|
|
3307
|
+
/**
|
|
3308
|
+
* Text shown in the empty view when no `*cngxPopoverEmpty` template is
|
|
3309
|
+
* projected. Unbound, it falls back to `withPopoverPanelLabels` and the
|
|
3310
|
+
* `popover` section of the language pack.
|
|
3311
|
+
*/
|
|
3312
|
+
emptyText = input(undefined, ...(ngDevMode ? [{ debugName: "emptyText" }] : /* istanbul ignore next */ []));
|
|
3313
|
+
/**
|
|
3314
|
+
* @internal The one view the panel body renders. A bound `[state]` goes
|
|
3315
|
+
* through the shared `resolveAsyncView` table (the same derivation the
|
|
3316
|
+
* select panel uses), so a first-load error shows the error slot and an
|
|
3317
|
+
* idle state renders no body (`'none'`). Without `[state]` the manual
|
|
3318
|
+
* inputs resolve in the order loading, error, empty.
|
|
3319
|
+
*/
|
|
3320
|
+
view = computed(() => {
|
|
3321
|
+
const s = this.state();
|
|
3322
|
+
if (s) {
|
|
3323
|
+
return resolveAsyncView(s.status(), s.isFirstLoad(), s.isEmpty());
|
|
3324
|
+
}
|
|
3325
|
+
if (this.loading()) {
|
|
3326
|
+
return 'skeleton';
|
|
3327
|
+
}
|
|
3328
|
+
if (this.error()) {
|
|
3329
|
+
return 'error';
|
|
3330
|
+
}
|
|
3331
|
+
if (this.empty()) {
|
|
3332
|
+
return 'empty';
|
|
3333
|
+
}
|
|
3334
|
+
return 'content';
|
|
3335
|
+
}, ...(ngDevMode ? [{ debugName: "view" }] : /* istanbul ignore next */ []));
|
|
3336
|
+
/** @internal The error handed to the `*cngxPopoverError` template. */
|
|
3337
|
+
viewError = computed(() => {
|
|
3338
|
+
const s = this.state();
|
|
3339
|
+
return s ? s.error() : this.error();
|
|
3340
|
+
}, ...(ngDevMode ? [{ debugName: "viewError" }] : /* istanbul ignore next */ []));
|
|
2034
3341
|
headerSlot = contentChild(CngxPopoverHeader, ...(ngDevMode ? [{ debugName: "headerSlot" }] : /* istanbul ignore next */ []));
|
|
2035
3342
|
footerSlot = contentChild(CngxPopoverFooter, ...(ngDevMode ? [{ debugName: "footerSlot" }] : /* istanbul ignore next */ []));
|
|
2036
3343
|
closeTpl = contentChild(CngxPopoverClose, ...(ngDevMode ? [{ debugName: "closeTpl" }] : /* istanbul ignore next */ []));
|
|
@@ -2067,14 +3374,35 @@ class CngxPopoverPanel {
|
|
|
2067
3374
|
uid = nextUid('cngx-pp');
|
|
2068
3375
|
headerId = `${this.uid}-header`;
|
|
2069
3376
|
bodyId = `${this.uid}-body`;
|
|
3377
|
+
errorId = `${this.uid}-error`;
|
|
3378
|
+
emptyId = `${this.uid}-empty`;
|
|
2070
3379
|
/**
|
|
2071
|
-
* Only point to the header when one is projected
|
|
2072
|
-
*
|
|
2073
|
-
*
|
|
3380
|
+
* Only point to the header when one is projected. The header row renders
|
|
3381
|
+
* in every view (loading, error, empty, content), so `hasHeader()` alone is
|
|
3382
|
+
* the gate: with a header the reference always resolves, and without one a
|
|
3383
|
+
* bare id would leave AT with an empty accessible name.
|
|
2074
3384
|
*/
|
|
2075
3385
|
ariaLabelledBy = computed(() => (this.hasHeader() ? this.headerId : null), ...(ngDevMode ? [{ debugName: "ariaLabelledBy" }] : /* istanbul ignore next */ []));
|
|
2076
|
-
/**
|
|
2077
|
-
|
|
3386
|
+
/**
|
|
3387
|
+
* The surface that describes the current view: the body in `content`, the
|
|
3388
|
+
* error surface in `error` / `content+error`, the empty surface in `empty`.
|
|
3389
|
+
* Loading speaks through `aria-busy` and its visible text, and `none`
|
|
3390
|
+
* renders nothing, so both emit no reference. Every emitted id resolves
|
|
3391
|
+
* because each surface always renders in its view.
|
|
3392
|
+
*/
|
|
3393
|
+
ariaDescribedBy = computed(() => {
|
|
3394
|
+
switch (this.view()) {
|
|
3395
|
+
case 'content':
|
|
3396
|
+
return this.bodyId;
|
|
3397
|
+
case 'error':
|
|
3398
|
+
case 'content+error':
|
|
3399
|
+
return this.errorId;
|
|
3400
|
+
case 'empty':
|
|
3401
|
+
return this.emptyId;
|
|
3402
|
+
default:
|
|
3403
|
+
return null;
|
|
3404
|
+
}
|
|
3405
|
+
}, ...(ngDevMode ? [{ debugName: "ariaDescribedBy" }] : /* istanbul ignore next */ []));
|
|
2078
3406
|
hostClass = computed(() => {
|
|
2079
3407
|
const v = this.variant() ?? this.config.defaultVariant ?? 'default';
|
|
2080
3408
|
let cls = `cngx-popover-panel cngx-popover-panel--${v}`;
|
|
@@ -2086,8 +3414,14 @@ class CngxPopoverPanel {
|
|
|
2086
3414
|
autoDismissTimer = null;
|
|
2087
3415
|
constructor() {
|
|
2088
3416
|
// Hint any CngxPopoverTrigger pointing at this popover to default
|
|
2089
|
-
// `aria-haspopup="dialog"`. Consumer override on the trigger wins
|
|
2090
|
-
|
|
3417
|
+
// `aria-haspopup="dialog"`. Consumer override on the trigger wins, and a
|
|
3418
|
+
// co-composer's later claim (a menu trigger) wins while it lives.
|
|
3419
|
+
this.popover.claimHaspopup(this, 'dialog');
|
|
3420
|
+
// Dialog pattern: focus returns to the opener when the panel closes and
|
|
3421
|
+
// focus would otherwise be lost. `[restoreFocus]="false"` on the trigger
|
|
3422
|
+
// opts out, and a menu trigger inside claims `false` (its focus stack
|
|
3423
|
+
// restores).
|
|
3424
|
+
this.popover.claimRestoreFocus(this, true);
|
|
2091
3425
|
effect(() => {
|
|
2092
3426
|
const isVisible = this.popover.isVisible();
|
|
2093
3427
|
const v = this.variant() ?? untracked(() => this.config.defaultVariant) ?? 'default';
|
|
@@ -2101,13 +3435,15 @@ class CngxPopoverPanel {
|
|
|
2101
3435
|
}
|
|
2102
3436
|
});
|
|
2103
3437
|
this.destroyRef.onDestroy(() => {
|
|
3438
|
+
this.popover.releaseHaspopup(this);
|
|
3439
|
+
this.popover.releaseRestoreFocus(this);
|
|
2104
3440
|
if (this.autoDismissTimer) {
|
|
2105
3441
|
clearTimeout(this.autoDismissTimer);
|
|
2106
3442
|
}
|
|
2107
3443
|
});
|
|
2108
3444
|
}
|
|
2109
3445
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverPanel, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2110
|
-
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 }, role: { classPropertyName: "role", publicName: "role", 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 } }, host: { properties: { "class": "hostClass()", "attr.role": "role()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-describedby": "ariaDescribedBy()", "attr.aria-busy": "
|
|
3446
|
+
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 }, role: { classPropertyName: "role", publicName: "role", 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 }, loadingText: { classPropertyName: "loadingText", publicName: "loadingText", isSignal: true, isRequired: false, transformFunction: null }, errorText: { classPropertyName: "errorText", publicName: "errorText", isSignal: true, isRequired: false, transformFunction: null }, emptyText: { classPropertyName: "emptyText", publicName: "emptyText", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class": "hostClass()", "attr.role": "role()", "attr.aria-labelledby": "ariaLabelledBy()", "attr.aria-describedby": "ariaDescribedBy()", "attr.aria-busy": "view() === 'skeleton' || null" } }, providers: [{ provide: CNGX_POPOVER_ARROW_BOUNDS, useExisting: CngxPopoverPanel }], queries: [{ propertyName: "headerSlot", first: true, predicate: CngxPopoverHeader, descendants: true, isSignal: true }, { propertyName: "footerSlot", first: true, predicate: CngxPopoverFooter, descendants: true, isSignal: true }, { 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 }, { propertyName: "arrowTplDirective", first: true, predicate: CngxPopoverArrow, descendants: true, isSignal: true }], exportAs: ["cngxPopoverPanel"], hostDirectives: [{ directive: CngxPopover, inputs: ["placement", "placement", "positionTryFallbacks", "positionTryFallbacks", "offset", "offset", "closeOnEscape", "closeOnEscape", "closeOnOutsideClick", "closeOnOutsideClick", "mode", "mode", "exclusive", "exclusive", "cngxPopoverOpen", "cngxPopoverOpen"], outputs: ["opened", "opened", "closed", "closed"] }], ngImport: i0, template: `
|
|
2111
3447
|
@if (showArrow()) {
|
|
2112
3448
|
@if (arrowTpl(); as tpl) {
|
|
2113
3449
|
<ng-container *ngTemplateOutlet="tpl; context: arrowContext()" />
|
|
@@ -2116,43 +3452,66 @@ class CngxPopoverPanel {
|
|
|
2116
3452
|
}
|
|
2117
3453
|
}
|
|
2118
3454
|
|
|
2119
|
-
@if (
|
|
2120
|
-
|
|
2121
|
-
<div class="cngx-popover-
|
|
2122
|
-
<ng-
|
|
3455
|
+
@if (hasHeader() || showClose()) {
|
|
3456
|
+
<div class="cngx-popover-panel__header-row">
|
|
3457
|
+
<div class="cngx-popover-panel__header" [id]="headerId">
|
|
3458
|
+
<ng-content select="[cngxPopoverHeader]" />
|
|
2123
3459
|
</div>
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
2135
|
-
</div>
|
|
2136
|
-
}
|
|
2137
|
-
} @else {
|
|
2138
|
-
@if (hasHeader() || showClose()) {
|
|
2139
|
-
<div class="cngx-popover-panel__header-row">
|
|
2140
|
-
<div class="cngx-popover-panel__header" [id]="headerId">
|
|
2141
|
-
<ng-content select="[cngxPopoverHeader]" />
|
|
2142
|
-
</div>
|
|
2143
|
-
@if (showClose()) {
|
|
2144
|
-
@if (closeTpl(); as tpl) {
|
|
2145
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
2146
|
-
} @else {
|
|
2147
|
-
<cngx-close-button
|
|
2148
|
-
[label]="closeLabel()"
|
|
2149
|
-
class="cngx-popover-panel__close"
|
|
2150
|
-
(click)="popover.hide()"
|
|
2151
|
-
/>
|
|
2152
|
-
}
|
|
3460
|
+
@if (showClose()) {
|
|
3461
|
+
@if (closeTpl(); as tpl) {
|
|
3462
|
+
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
3463
|
+
} @else {
|
|
3464
|
+
<button
|
|
3465
|
+
cngxCloseButton
|
|
3466
|
+
[attr.aria-label]="closeLabel()"
|
|
3467
|
+
class="cngx-popover-panel__close"
|
|
3468
|
+
(click)="popover.hide()"
|
|
3469
|
+
></button>
|
|
2153
3470
|
}
|
|
2154
|
-
|
|
2155
|
-
|
|
3471
|
+
}
|
|
3472
|
+
</div>
|
|
3473
|
+
}
|
|
3474
|
+
|
|
3475
|
+
@if (view() === 'skeleton') {
|
|
3476
|
+
<div class="cngx-popover-panel__loading">
|
|
3477
|
+
@if (loadingTpl(); as tpl) {
|
|
3478
|
+
<ng-container
|
|
3479
|
+
*ngTemplateOutlet="
|
|
3480
|
+
tpl.templateRef;
|
|
3481
|
+
context: { $implicit: resolvedLoadingText(), text: resolvedLoadingText() }
|
|
3482
|
+
"
|
|
3483
|
+
/>
|
|
3484
|
+
} @else {
|
|
3485
|
+
{{ resolvedLoadingText() }}
|
|
3486
|
+
}
|
|
3487
|
+
</div>
|
|
3488
|
+
} @else if (view() === 'error' || view() === 'content+error') {
|
|
3489
|
+
<div class="cngx-popover-panel__error" [id]="errorId">
|
|
3490
|
+
@if (errorTpl(); as tpl) {
|
|
3491
|
+
<ng-container
|
|
3492
|
+
*ngTemplateOutlet="
|
|
3493
|
+
tpl.templateRef;
|
|
3494
|
+
context: { $implicit: viewError(), error: viewError(), text: resolvedErrorText() }
|
|
3495
|
+
"
|
|
3496
|
+
/>
|
|
3497
|
+
} @else {
|
|
3498
|
+
{{ resolvedErrorText() }}
|
|
3499
|
+
}
|
|
3500
|
+
</div>
|
|
3501
|
+
} @else if (view() === 'empty') {
|
|
3502
|
+
<div class="cngx-popover-panel__empty" [id]="emptyId">
|
|
3503
|
+
@if (emptyTpl(); as tpl) {
|
|
3504
|
+
<ng-container
|
|
3505
|
+
*ngTemplateOutlet="
|
|
3506
|
+
tpl.templateRef;
|
|
3507
|
+
context: { $implicit: resolvedEmptyText(), text: resolvedEmptyText() }
|
|
3508
|
+
"
|
|
3509
|
+
/>
|
|
3510
|
+
} @else {
|
|
3511
|
+
{{ resolvedEmptyText() }}
|
|
3512
|
+
}
|
|
3513
|
+
</div>
|
|
3514
|
+
} @else if (view() === 'content') {
|
|
2156
3515
|
<div class="cngx-popover-panel__body" [id]="bodyId">
|
|
2157
3516
|
<ng-content select="[cngxPopoverBody]" />
|
|
2158
3517
|
<ng-content />
|
|
@@ -2163,7 +3522,7 @@ class CngxPopoverPanel {
|
|
|
2163
3522
|
</div>
|
|
2164
3523
|
}
|
|
2165
3524
|
}
|
|
2166
|
-
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-popover-panel-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-popover-panel-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.27 .04 250);}@property --cngx-popover-panel-border-radius{syntax: \"<length>\"; inherits: false; initial-value: 12px;}@property --cngx-popover-panel-padding{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@property --cngx-popover-panel-max-width{syntax: \"<length>\"; inherits: false; initial-value: 360px;}@property --cngx-popover-panel-shadow{syntax: \"*\"; inherits: true; initial-value: 0 8px 24px oklch(0 0 0 / .12);}@property --cngx-popover-panel-border{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .08);}@property --cngx-popover-panel-arrow-size{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-close-size{syntax: \"<length>\"; inherits: true; initial-value: 28px;}@property --cngx-popover-panel-close-offset{syntax: \"<length>\"; inherits: true; initial-value: 4px;}@property --cngx-popover-panel-transition-duration{syntax: \"<time>\"; inherits: true; initial-value: .2s;}:where(.cngx-popover-panel){--cngx-popover-panel-transition-duration: var(--cngx-duration-base)}@property --cngx-popover-panel-transition-easing{syntax: \"*\"; inherits: true; initial-value: cubic-bezier(.4,0,.2,1);}@property --cngx-popover-panel-header-font-size{syntax: \"*\"; inherits: true; initial-value: .875rem;}@property --cngx-popover-panel-header-font-weight{syntax: \"<number>\"; inherits: true; initial-value: 600;}@property --cngx-popover-panel-header-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-border-top{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .06);}@property --cngx-popover-panel-footer-padding-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-footer-margin-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-accent{syntax: \"*\"; inherits: true; initial-value: transparent;}@property --cngx-popover-panel-accent-text{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-popover-panel-close-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .06);}:root{--cngx-popover-panel-bg: var(--cngx-color-surface);--cngx-popover-panel-color: var(--cngx-color-text)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}}[data-color-scheme=dark],.dark{--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}[data-color-scheme=light],.light{--cngx-popover-panel-border: 1px solid oklch(0 0 0 / .08);--cngx-popover-panel-footer-border-top: 1px solid oklch(0 0 0 / .06);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .12);--cngx-popover-panel-close-hover-bg: oklch(0 0 0 / .06)}}@layer cngx.components{@scope(.cngx-popover-panel){:scope{--cngx-popover-panel-padding: var(--cngx-space-md);--cngx-popover-panel-header-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-padding-top: var(--cngx-space-sm);--cngx-popover-panel-footer-margin-top: var(--cngx-space-sm);position:fixed;inset:unset;box-sizing:border-box;background:var(--cngx-popover-panel-bg, var(--cngx-color-surface, oklch(1 0 0)));color:var(--cngx-popover-panel-color, var(--cngx-color-text, oklch(.27 .04 250)));border-radius:var(--cngx-popover-panel-border-radius, 12px);border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));box-shadow:var(--cngx-popover-panel-shadow, 0 8px 24px oklch(0 0 0 / .12));padding:var(--cngx-popover-panel-padding, 16px);max-width:var(--cngx-popover-panel-max-width, 360px);width:max-content;overflow:visible;transition:opacity var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1)),transform var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1))}:scope:popover-open{display:block}:scope.cngx-popover--opening{opacity:0;transform:translateY(4px) scale(.98)}:scope.cngx-popover--open{opacity:1;transform:translateY(0) scale(1)}:scope.cngx-popover--closing{opacity:0;transform:translateY(4px) scale(.98)}.cngx-popover-panel__header{font-size:var(--cngx-popover-panel-header-font-size, .875rem);font-weight:var(--cngx-popover-panel-header-font-weight, 600);margin-bottom:var(--cngx-popover-panel-header-gap, 8px);color:var(--cngx-popover-panel-accent-text, inherit)}.cngx-popover-panel__body{font-size:.8125rem;line-height:1.5}.cngx-popover-panel__footer{display:flex;justify-content:flex-end;gap:var(--cngx-popover-panel-footer-gap, 8px);border-top:var(--cngx-popover-panel-footer-border-top, 1px solid oklch(0 0 0 / .06));padding-top:var(--cngx-popover-panel-footer-padding-top, 12px);margin-top:var(--cngx-popover-panel-footer-margin-top, 12px)}.cngx-popover-panel__header-row{display:flex;align-items:center;gap:8px;margin-bottom:var(--cngx-popover-panel-header-gap, 8px)}.cngx-popover-panel__header-row>.cngx-popover-panel__header{flex:1;margin-bottom:0}.cngx-popover-panel__header-row:has(.cngx-popover-panel__close)>.cngx-popover-panel__header{padding-inline-end:calc(var(--cngx-popover-panel-close-size, 28px) + 8px)}.cngx-popover-panel__close{position:absolute;top:var(--cngx-popover-panel-close-offset, 4px);inset-inline-end:var(--cngx-popover-panel-close-offset, 4px);z-index:1;--cngx-close-button-size: var(--cngx-popover-panel-close-size, 28px);--cngx-close-button-radius: 999px;--cngx-close-button-padding: 0;--cngx-close-button-hover-bg: var(--cngx-popover-panel-close-hover-bg, oklch(0 0 0 / .06));--cngx-close-button-focus-outline: 2px solid var(--cngx-popover-panel-accent-text, currentColor)}.cngx-popover-panel__close .cngx-close-button__btn{--cngx-close-button-radius: 999px}.cngx-popover-panel__arrow{position:absolute;width:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);height:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);background:var(--cngx-popover-panel-bg, oklch(1 0 0));border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));transform:rotate(45deg);pointer-events:none}:scope[data-arrow-placement=bottom]>.cngx-popover-panel__arrow{top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-bottom:none}:scope[data-arrow-placement=top]>.cngx-popover-panel__arrow{bottom:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-top:none}:scope[data-arrow-placement=left]>.cngx-popover-panel__arrow{right:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-bottom:none}:scope[data-arrow-placement=right]>.cngx-popover-panel__arrow{left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-top:none}:scope.cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.92 .05 250);--cngx-popover-panel-accent-text: oklch(.38 .16 260);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.94 .07 155);--cngx-popover-panel-accent-text: oklch(.42 .1 155);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.95 .06 75);--cngx-popover-panel-accent-text: oklch(.46 .12 60);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.93 .04 25);--cngx-popover-panel-accent-text: oklch(.42 .18 25);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}.cngx-popover-panel__loading,.cngx-popover-panel__error,.cngx-popover-panel__empty{font-size:.8125rem;line-height:1.5;text-align:center;padding:8px 0}.cngx-popover-panel__error{color:var(--cngx-color-danger, oklch(.6 .22 25))}.cngx-popover-panel__empty{color:var(--cngx-color-text-muted, oklch(.5 .01 250))}@media(prefers-reduced-motion:reduce){:scope{transition:none}}}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}[data-color-scheme=dark] .cngx-popover-panel--info,.dark .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}[data-color-scheme=dark] .cngx-popover-panel--success,.dark .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}[data-color-scheme=dark] .cngx-popover-panel--warning,.dark .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}[data-color-scheme=dark] .cngx-popover-panel--danger,.dark .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}\n"], 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 });
|
|
3525
|
+
`, isInline: true, styles: ["@layer cngx.tokens{@property --cngx-popover-panel-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-popover-panel-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.27 .04 250);}@property --cngx-popover-panel-border-radius{syntax: \"<length>\"; inherits: false; initial-value: 12px;}@property --cngx-popover-panel-padding{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@property --cngx-popover-panel-max-width{syntax: \"<length>\"; inherits: false; initial-value: 360px;}@property --cngx-popover-panel-shadow{syntax: \"*\"; inherits: true; initial-value: 0 8px 24px oklch(0 0 0 / .12);}@property --cngx-popover-panel-border{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .08);}@property --cngx-popover-panel-arrow-size{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-close-size{syntax: \"<length>\"; inherits: true; initial-value: 28px;}@property --cngx-popover-panel-close-offset{syntax: \"<length>\"; inherits: true; initial-value: 4px;}@property --cngx-popover-panel-transition-duration{syntax: \"<time>\"; inherits: true; initial-value: .2s;}:where(.cngx-popover-panel){--cngx-popover-panel-transition-duration: var(--cngx-duration-base)}@property --cngx-popover-panel-transition-easing{syntax: \"*\"; inherits: true; initial-value: cubic-bezier(.4,0,.2,1);}@property --cngx-popover-panel-header-font-size{syntax: \"*\"; inherits: true; initial-value: .875rem;}@property --cngx-popover-panel-header-font-weight{syntax: \"<number>\"; inherits: true; initial-value: 600;}@property --cngx-popover-panel-header-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-border-top{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .06);}@property --cngx-popover-panel-footer-padding-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-footer-margin-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-accent{syntax: \"*\"; inherits: true; initial-value: transparent;}@property --cngx-popover-panel-accent-text{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-popover-panel-close-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .06);}:root{--cngx-popover-panel-bg: var(--cngx-color-surface);--cngx-popover-panel-color: var(--cngx-color-text)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}}[data-color-scheme=dark],.dark{--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}[data-color-scheme=light],.light{--cngx-popover-panel-border: 1px solid oklch(0 0 0 / .08);--cngx-popover-panel-footer-border-top: 1px solid oklch(0 0 0 / .06);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .12);--cngx-popover-panel-close-hover-bg: oklch(0 0 0 / .06)}}@layer cngx.components{@scope(.cngx-popover-panel){:scope{--cngx-popover-panel-padding: var(--cngx-space-md);--cngx-popover-panel-header-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-padding-top: var(--cngx-space-sm);--cngx-popover-panel-footer-margin-top: var(--cngx-space-sm);position:fixed;inset:unset;box-sizing:border-box;background:var(--cngx-popover-panel-bg);color:var(--cngx-popover-panel-color);border-radius:var(--cngx-popover-panel-border-radius, 12px);border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));box-shadow:var(--cngx-popover-panel-shadow, 0 8px 24px oklch(0 0 0 / .12));padding:var(--cngx-popover-panel-padding, 16px);max-width:var(--cngx-popover-panel-max-width, 360px);width:max-content;overflow:visible;transition:opacity var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1)),transform var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1))}:scope:popover-open{display:block}:scope.cngx-popover--opening{opacity:0;transform:translateY(4px) scale(.98)}:scope.cngx-popover--open{opacity:1;transform:translateY(0) scale(1)}:scope.cngx-popover--closing{opacity:0;transform:translateY(4px) scale(.98)}.cngx-popover-panel__header{font-size:var(--cngx-popover-panel-header-font-size, .875rem);font-weight:var(--cngx-popover-panel-header-font-weight, 600);margin-bottom:var(--cngx-popover-panel-header-gap, 8px);color:var(--cngx-popover-panel-accent-text, inherit)}.cngx-popover-panel__body{font-size:.8125rem;line-height:1.5}.cngx-popover-panel__footer{display:flex;justify-content:flex-end;gap:var(--cngx-popover-panel-footer-gap, 8px);border-top:var(--cngx-popover-panel-footer-border-top, 1px solid oklch(0 0 0 / .06));padding-top:var(--cngx-popover-panel-footer-padding-top, 12px);margin-top:var(--cngx-popover-panel-footer-margin-top, 12px)}.cngx-popover-panel__header-row{display:flex;align-items:center;gap:8px;margin-bottom:var(--cngx-popover-panel-header-gap, 8px)}.cngx-popover-panel__header-row>.cngx-popover-panel__header{flex:1;margin-bottom:0}.cngx-popover-panel__header-row:has(.cngx-popover-panel__close)>.cngx-popover-panel__header{padding-inline-end:calc(max(var(--cngx-popover-panel-close-size, 28px),var(--cngx-target-min, 0px)) + 8px)}.cngx-popover-panel__header-row:has(.cngx-popover-panel__close){--cngx-popover-panel-padding: inherit;min-block-size:calc(max(var(--cngx-popover-panel-close-size, 28px),var(--cngx-target-min, 0px)) + var(--cngx-popover-panel-close-offset, 4px) - var(--cngx-popover-panel-padding, 16px))}.cngx-popover-panel__close.cngx-close-button{position:absolute;top:var(--cngx-popover-panel-close-offset, 4px);inset-inline-end:var(--cngx-popover-panel-close-offset, 4px);z-index:1;--cngx-close-button-size: var(--cngx-popover-panel-close-size, 28px);--cngx-close-button-radius: 999px;--cngx-close-button-hover-bg: var(--cngx-popover-panel-close-hover-bg, oklch(0 0 0 / .06))}.cngx-popover-panel__arrow{position:absolute;width:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);height:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);background:var(--cngx-popover-panel-bg);border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));transform:rotate(45deg);pointer-events:none}:scope[data-arrow-placement=bottom]>.cngx-popover-panel__arrow{top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-bottom:none}:scope[data-arrow-placement=top]>.cngx-popover-panel__arrow{bottom:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-top:none}:scope[data-arrow-placement=left]>.cngx-popover-panel__arrow{right:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-bottom:none}:scope[data-arrow-placement=right]>.cngx-popover-panel__arrow{left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-top:none}:scope.cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.92 .05 250);--cngx-popover-panel-accent-text: oklch(.38 .16 260);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.94 .07 155);--cngx-popover-panel-accent-text: oklch(.42 .1 155);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.95 .06 75);--cngx-popover-panel-accent-text: oklch(.46 .12 60);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.93 .04 25);--cngx-popover-panel-accent-text: oklch(.42 .18 25);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}.cngx-popover-panel__loading,.cngx-popover-panel__error,.cngx-popover-panel__empty{font-size:.8125rem;line-height:1.5;text-align:center;padding:8px 0}.cngx-popover-panel__error{color:var( --cngx-color-danger-text, oklch(from var(--cngx-color-danger, oklch(.6 .18 25)) .46 c h) )}.cngx-popover-panel__empty{color:var(--cngx-color-text-muted, oklch(.5 .01 250))}@media(prefers-reduced-motion:reduce){:scope{transition:none}}}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}[data-color-scheme=dark] .cngx-popover-panel--info,.dark .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}[data-color-scheme=dark] .cngx-popover-panel--success,.dark .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}[data-color-scheme=dark] .cngx-popover-panel--warning,.dark .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}[data-color-scheme=dark] .cngx-popover-panel--danger,.dark .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CngxCloseButton, selector: "button[cngxCloseButton]", exportAs: ["cngxCloseButton"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2167
3526
|
}
|
|
2168
3527
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverPanel, decorators: [{
|
|
2169
3528
|
type: Component,
|
|
@@ -2180,13 +3539,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2180
3539
|
'exclusive',
|
|
2181
3540
|
'cngxPopoverOpen',
|
|
2182
3541
|
],
|
|
3542
|
+
outputs: ['opened', 'closed'],
|
|
2183
3543
|
},
|
|
2184
3544
|
], host: {
|
|
2185
3545
|
'[class]': 'hostClass()',
|
|
2186
3546
|
'[attr.role]': 'role()',
|
|
2187
3547
|
'[attr.aria-labelledby]': 'ariaLabelledBy()',
|
|
2188
3548
|
'[attr.aria-describedby]': 'ariaDescribedBy()',
|
|
2189
|
-
'[attr.aria-busy]':
|
|
3549
|
+
'[attr.aria-busy]': "view() === 'skeleton' || null",
|
|
2190
3550
|
}, template: `
|
|
2191
3551
|
@if (showArrow()) {
|
|
2192
3552
|
@if (arrowTpl(); as tpl) {
|
|
@@ -2196,43 +3556,66 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2196
3556
|
}
|
|
2197
3557
|
}
|
|
2198
3558
|
|
|
2199
|
-
@if (
|
|
2200
|
-
|
|
2201
|
-
<div class="cngx-popover-
|
|
2202
|
-
<ng-
|
|
2203
|
-
</div>
|
|
2204
|
-
}
|
|
2205
|
-
} @else if (effectiveError(); as err) {
|
|
2206
|
-
@if (errorTpl(); as tpl) {
|
|
2207
|
-
<div class="cngx-popover-panel__error">
|
|
2208
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef; context: { $implicit: err }" />
|
|
2209
|
-
</div>
|
|
2210
|
-
}
|
|
2211
|
-
} @else if (effectiveEmpty()) {
|
|
2212
|
-
@if (emptyTpl(); as tpl) {
|
|
2213
|
-
<div class="cngx-popover-panel__empty">
|
|
2214
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
3559
|
+
@if (hasHeader() || showClose()) {
|
|
3560
|
+
<div class="cngx-popover-panel__header-row">
|
|
3561
|
+
<div class="cngx-popover-panel__header" [id]="headerId">
|
|
3562
|
+
<ng-content select="[cngxPopoverHeader]" />
|
|
2215
3563
|
</div>
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
} @else {
|
|
2227
|
-
<cngx-close-button
|
|
2228
|
-
[label]="closeLabel()"
|
|
2229
|
-
class="cngx-popover-panel__close"
|
|
2230
|
-
(click)="popover.hide()"
|
|
2231
|
-
/>
|
|
2232
|
-
}
|
|
3564
|
+
@if (showClose()) {
|
|
3565
|
+
@if (closeTpl(); as tpl) {
|
|
3566
|
+
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
3567
|
+
} @else {
|
|
3568
|
+
<button
|
|
3569
|
+
cngxCloseButton
|
|
3570
|
+
[attr.aria-label]="closeLabel()"
|
|
3571
|
+
class="cngx-popover-panel__close"
|
|
3572
|
+
(click)="popover.hide()"
|
|
3573
|
+
></button>
|
|
2233
3574
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
3575
|
+
}
|
|
3576
|
+
</div>
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
@if (view() === 'skeleton') {
|
|
3580
|
+
<div class="cngx-popover-panel__loading">
|
|
3581
|
+
@if (loadingTpl(); as tpl) {
|
|
3582
|
+
<ng-container
|
|
3583
|
+
*ngTemplateOutlet="
|
|
3584
|
+
tpl.templateRef;
|
|
3585
|
+
context: { $implicit: resolvedLoadingText(), text: resolvedLoadingText() }
|
|
3586
|
+
"
|
|
3587
|
+
/>
|
|
3588
|
+
} @else {
|
|
3589
|
+
{{ resolvedLoadingText() }}
|
|
3590
|
+
}
|
|
3591
|
+
</div>
|
|
3592
|
+
} @else if (view() === 'error' || view() === 'content+error') {
|
|
3593
|
+
<div class="cngx-popover-panel__error" [id]="errorId">
|
|
3594
|
+
@if (errorTpl(); as tpl) {
|
|
3595
|
+
<ng-container
|
|
3596
|
+
*ngTemplateOutlet="
|
|
3597
|
+
tpl.templateRef;
|
|
3598
|
+
context: { $implicit: viewError(), error: viewError(), text: resolvedErrorText() }
|
|
3599
|
+
"
|
|
3600
|
+
/>
|
|
3601
|
+
} @else {
|
|
3602
|
+
{{ resolvedErrorText() }}
|
|
3603
|
+
}
|
|
3604
|
+
</div>
|
|
3605
|
+
} @else if (view() === 'empty') {
|
|
3606
|
+
<div class="cngx-popover-panel__empty" [id]="emptyId">
|
|
3607
|
+
@if (emptyTpl(); as tpl) {
|
|
3608
|
+
<ng-container
|
|
3609
|
+
*ngTemplateOutlet="
|
|
3610
|
+
tpl.templateRef;
|
|
3611
|
+
context: { $implicit: resolvedEmptyText(), text: resolvedEmptyText() }
|
|
3612
|
+
"
|
|
3613
|
+
/>
|
|
3614
|
+
} @else {
|
|
3615
|
+
{{ resolvedEmptyText() }}
|
|
3616
|
+
}
|
|
3617
|
+
</div>
|
|
3618
|
+
} @else if (view() === 'content') {
|
|
2236
3619
|
<div class="cngx-popover-panel__body" [id]="bodyId">
|
|
2237
3620
|
<ng-content select="[cngxPopoverBody]" />
|
|
2238
3621
|
<ng-content />
|
|
@@ -2243,233 +3626,403 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2243
3626
|
</div>
|
|
2244
3627
|
}
|
|
2245
3628
|
}
|
|
2246
|
-
`, styles: ["@layer cngx.tokens{@property --cngx-popover-panel-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-popover-panel-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.27 .04 250);}@property --cngx-popover-panel-border-radius{syntax: \"<length>\"; inherits: false; initial-value: 12px;}@property --cngx-popover-panel-padding{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@property --cngx-popover-panel-max-width{syntax: \"<length>\"; inherits: false; initial-value: 360px;}@property --cngx-popover-panel-shadow{syntax: \"*\"; inherits: true; initial-value: 0 8px 24px oklch(0 0 0 / .12);}@property --cngx-popover-panel-border{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .08);}@property --cngx-popover-panel-arrow-size{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-close-size{syntax: \"<length>\"; inherits: true; initial-value: 28px;}@property --cngx-popover-panel-close-offset{syntax: \"<length>\"; inherits: true; initial-value: 4px;}@property --cngx-popover-panel-transition-duration{syntax: \"<time>\"; inherits: true; initial-value: .2s;}:where(.cngx-popover-panel){--cngx-popover-panel-transition-duration: var(--cngx-duration-base)}@property --cngx-popover-panel-transition-easing{syntax: \"*\"; inherits: true; initial-value: cubic-bezier(.4,0,.2,1);}@property --cngx-popover-panel-header-font-size{syntax: \"*\"; inherits: true; initial-value: .875rem;}@property --cngx-popover-panel-header-font-weight{syntax: \"<number>\"; inherits: true; initial-value: 600;}@property --cngx-popover-panel-header-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-border-top{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .06);}@property --cngx-popover-panel-footer-padding-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-footer-margin-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-accent{syntax: \"*\"; inherits: true; initial-value: transparent;}@property --cngx-popover-panel-accent-text{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-popover-panel-close-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .06);}:root{--cngx-popover-panel-bg: var(--cngx-color-surface);--cngx-popover-panel-color: var(--cngx-color-text)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}}[data-color-scheme=dark],.dark{--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}[data-color-scheme=light],.light{--cngx-popover-panel-border: 1px solid oklch(0 0 0 / .08);--cngx-popover-panel-footer-border-top: 1px solid oklch(0 0 0 / .06);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .12);--cngx-popover-panel-close-hover-bg: oklch(0 0 0 / .06)}}@layer cngx.components{@scope(.cngx-popover-panel){:scope{--cngx-popover-panel-padding: var(--cngx-space-md);--cngx-popover-panel-header-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-padding-top: var(--cngx-space-sm);--cngx-popover-panel-footer-margin-top: var(--cngx-space-sm);position:fixed;inset:unset;box-sizing:border-box;background:var(--cngx-popover-panel-bg, var(--cngx-color-surface, oklch(1 0 0)));color:var(--cngx-popover-panel-color, var(--cngx-color-text, oklch(.27 .04 250)));border-radius:var(--cngx-popover-panel-border-radius, 12px);border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));box-shadow:var(--cngx-popover-panel-shadow, 0 8px 24px oklch(0 0 0 / .12));padding:var(--cngx-popover-panel-padding, 16px);max-width:var(--cngx-popover-panel-max-width, 360px);width:max-content;overflow:visible;transition:opacity var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1)),transform var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1))}:scope:popover-open{display:block}:scope.cngx-popover--opening{opacity:0;transform:translateY(4px) scale(.98)}:scope.cngx-popover--open{opacity:1;transform:translateY(0) scale(1)}:scope.cngx-popover--closing{opacity:0;transform:translateY(4px) scale(.98)}.cngx-popover-panel__header{font-size:var(--cngx-popover-panel-header-font-size, .875rem);font-weight:var(--cngx-popover-panel-header-font-weight, 600);margin-bottom:var(--cngx-popover-panel-header-gap, 8px);color:var(--cngx-popover-panel-accent-text, inherit)}.cngx-popover-panel__body{font-size:.8125rem;line-height:1.5}.cngx-popover-panel__footer{display:flex;justify-content:flex-end;gap:var(--cngx-popover-panel-footer-gap, 8px);border-top:var(--cngx-popover-panel-footer-border-top, 1px solid oklch(0 0 0 / .06));padding-top:var(--cngx-popover-panel-footer-padding-top, 12px);margin-top:var(--cngx-popover-panel-footer-margin-top, 12px)}.cngx-popover-panel__header-row{display:flex;align-items:center;gap:8px;margin-bottom:var(--cngx-popover-panel-header-gap, 8px)}.cngx-popover-panel__header-row>.cngx-popover-panel__header{flex:1;margin-bottom:0}.cngx-popover-panel__header-row:has(.cngx-popover-panel__close)>.cngx-popover-panel__header{padding-inline-end:calc(var(--cngx-popover-panel-close-size, 28px) + 8px)}.cngx-popover-panel__close{position:absolute;top:var(--cngx-popover-panel-close-offset, 4px);inset-inline-end:var(--cngx-popover-panel-close-offset, 4px);z-index:1;--cngx-close-button-size: var(--cngx-popover-panel-close-size, 28px);--cngx-close-button-radius: 999px;--cngx-close-button-padding: 0;--cngx-close-button-hover-bg: var(--cngx-popover-panel-close-hover-bg, oklch(0 0 0 / .06));--cngx-close-button-focus-outline: 2px solid var(--cngx-popover-panel-accent-text, currentColor)}.cngx-popover-panel__close .cngx-close-button__btn{--cngx-close-button-radius: 999px}.cngx-popover-panel__arrow{position:absolute;width:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);height:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);background:var(--cngx-popover-panel-bg, oklch(1 0 0));border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));transform:rotate(45deg);pointer-events:none}:scope[data-arrow-placement=bottom]>.cngx-popover-panel__arrow{top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-bottom:none}:scope[data-arrow-placement=top]>.cngx-popover-panel__arrow{bottom:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-top:none}:scope[data-arrow-placement=left]>.cngx-popover-panel__arrow{right:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-bottom:none}:scope[data-arrow-placement=right]>.cngx-popover-panel__arrow{left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-top:none}:scope.cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.92 .05 250);--cngx-popover-panel-accent-text: oklch(.38 .16 260);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.94 .07 155);--cngx-popover-panel-accent-text: oklch(.42 .1 155);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.95 .06 75);--cngx-popover-panel-accent-text: oklch(.46 .12 60);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.93 .04 25);--cngx-popover-panel-accent-text: oklch(.42 .18 25);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}.cngx-popover-panel__loading,.cngx-popover-panel__error,.cngx-popover-panel__empty{font-size:.8125rem;line-height:1.5;text-align:center;padding:8px 0}.cngx-popover-panel__error{color:var(--cngx-color-danger, oklch(.6 .22 25))}.cngx-popover-panel__empty{color:var(--cngx-color-text-muted, oklch(.5 .01 250))}@media(prefers-reduced-motion:reduce){:scope{transition:none}}}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}[data-color-scheme=dark] .cngx-popover-panel--info,.dark .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}[data-color-scheme=dark] .cngx-popover-panel--success,.dark .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}[data-color-scheme=dark] .cngx-popover-panel--warning,.dark .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}[data-color-scheme=dark] .cngx-popover-panel--danger,.dark .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}\n"] }]
|
|
2247
|
-
}], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", 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 }] }], headerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverHeader), { isSignal: true }] }], footerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverFooter), { isSignal: true }] }], 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 }] }], arrowTplDirective: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverArrow), { isSignal: true }] }] } });
|
|
3629
|
+
`, styles: ["@layer cngx.tokens{@property --cngx-popover-panel-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(1 0 0);}@property --cngx-popover-panel-color{syntax: \"<color>\"; inherits: true; initial-value: oklch(.27 .04 250);}@property --cngx-popover-panel-border-radius{syntax: \"<length>\"; inherits: false; initial-value: 12px;}@property --cngx-popover-panel-padding{syntax: \"<length>\"; inherits: false; initial-value: 16px;}@property --cngx-popover-panel-max-width{syntax: \"<length>\"; inherits: false; initial-value: 360px;}@property --cngx-popover-panel-shadow{syntax: \"*\"; inherits: true; initial-value: 0 8px 24px oklch(0 0 0 / .12);}@property --cngx-popover-panel-border{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .08);}@property --cngx-popover-panel-arrow-size{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-close-size{syntax: \"<length>\"; inherits: true; initial-value: 28px;}@property --cngx-popover-panel-close-offset{syntax: \"<length>\"; inherits: true; initial-value: 4px;}@property --cngx-popover-panel-transition-duration{syntax: \"<time>\"; inherits: true; initial-value: .2s;}:where(.cngx-popover-panel){--cngx-popover-panel-transition-duration: var(--cngx-duration-base)}@property --cngx-popover-panel-transition-easing{syntax: \"*\"; inherits: true; initial-value: cubic-bezier(.4,0,.2,1);}@property --cngx-popover-panel-header-font-size{syntax: \"*\"; inherits: true; initial-value: .875rem;}@property --cngx-popover-panel-header-font-weight{syntax: \"<number>\"; inherits: true; initial-value: 600;}@property --cngx-popover-panel-header-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-gap{syntax: \"<length>\"; inherits: true; initial-value: 8px;}@property --cngx-popover-panel-footer-border-top{syntax: \"*\"; inherits: true; initial-value: 1px solid oklch(0 0 0 / .06);}@property --cngx-popover-panel-footer-padding-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-footer-margin-top{syntax: \"<length>\"; inherits: true; initial-value: 12px;}@property --cngx-popover-panel-accent{syntax: \"*\"; inherits: true; initial-value: transparent;}@property --cngx-popover-panel-accent-text{syntax: \"*\"; inherits: true; initial-value: currentColor;}@property --cngx-popover-panel-close-hover-bg{syntax: \"<color>\"; inherits: true; initial-value: oklch(0 0 0 / .06);}:root{--cngx-popover-panel-bg: var(--cngx-color-surface);--cngx-popover-panel-color: var(--cngx-color-text)}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light){--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}}[data-color-scheme=dark],.dark{--cngx-popover-panel-border: 1px solid oklch(1 0 0 / .12);--cngx-popover-panel-footer-border-top: 1px solid oklch(1 0 0 / .08);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .5);--cngx-popover-panel-close-hover-bg: oklch(1 0 0 / .08)}[data-color-scheme=light],.light{--cngx-popover-panel-border: 1px solid oklch(0 0 0 / .08);--cngx-popover-panel-footer-border-top: 1px solid oklch(0 0 0 / .06);--cngx-popover-panel-shadow: 0 8px 24px oklch(0 0 0 / .12);--cngx-popover-panel-close-hover-bg: oklch(0 0 0 / .06)}}@layer cngx.components{@scope(.cngx-popover-panel){:scope{--cngx-popover-panel-padding: var(--cngx-space-md);--cngx-popover-panel-header-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-gap: var(--cngx-space-sm);--cngx-popover-panel-footer-padding-top: var(--cngx-space-sm);--cngx-popover-panel-footer-margin-top: var(--cngx-space-sm);position:fixed;inset:unset;box-sizing:border-box;background:var(--cngx-popover-panel-bg);color:var(--cngx-popover-panel-color);border-radius:var(--cngx-popover-panel-border-radius, 12px);border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));box-shadow:var(--cngx-popover-panel-shadow, 0 8px 24px oklch(0 0 0 / .12));padding:var(--cngx-popover-panel-padding, 16px);max-width:var(--cngx-popover-panel-max-width, 360px);width:max-content;overflow:visible;transition:opacity var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1)),transform var(--cngx-popover-panel-transition-duration, .2s) var(--cngx-popover-panel-transition-easing, cubic-bezier(.4, 0, .2, 1))}:scope:popover-open{display:block}:scope.cngx-popover--opening{opacity:0;transform:translateY(4px) scale(.98)}:scope.cngx-popover--open{opacity:1;transform:translateY(0) scale(1)}:scope.cngx-popover--closing{opacity:0;transform:translateY(4px) scale(.98)}.cngx-popover-panel__header{font-size:var(--cngx-popover-panel-header-font-size, .875rem);font-weight:var(--cngx-popover-panel-header-font-weight, 600);margin-bottom:var(--cngx-popover-panel-header-gap, 8px);color:var(--cngx-popover-panel-accent-text, inherit)}.cngx-popover-panel__body{font-size:.8125rem;line-height:1.5}.cngx-popover-panel__footer{display:flex;justify-content:flex-end;gap:var(--cngx-popover-panel-footer-gap, 8px);border-top:var(--cngx-popover-panel-footer-border-top, 1px solid oklch(0 0 0 / .06));padding-top:var(--cngx-popover-panel-footer-padding-top, 12px);margin-top:var(--cngx-popover-panel-footer-margin-top, 12px)}.cngx-popover-panel__header-row{display:flex;align-items:center;gap:8px;margin-bottom:var(--cngx-popover-panel-header-gap, 8px)}.cngx-popover-panel__header-row>.cngx-popover-panel__header{flex:1;margin-bottom:0}.cngx-popover-panel__header-row:has(.cngx-popover-panel__close)>.cngx-popover-panel__header{padding-inline-end:calc(max(var(--cngx-popover-panel-close-size, 28px),var(--cngx-target-min, 0px)) + 8px)}.cngx-popover-panel__header-row:has(.cngx-popover-panel__close){--cngx-popover-panel-padding: inherit;min-block-size:calc(max(var(--cngx-popover-panel-close-size, 28px),var(--cngx-target-min, 0px)) + var(--cngx-popover-panel-close-offset, 4px) - var(--cngx-popover-panel-padding, 16px))}.cngx-popover-panel__close.cngx-close-button{position:absolute;top:var(--cngx-popover-panel-close-offset, 4px);inset-inline-end:var(--cngx-popover-panel-close-offset, 4px);z-index:1;--cngx-close-button-size: var(--cngx-popover-panel-close-size, 28px);--cngx-close-button-radius: 999px;--cngx-close-button-hover-bg: var(--cngx-popover-panel-close-hover-bg, oklch(0 0 0 / .06))}.cngx-popover-panel__arrow{position:absolute;width:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);height:calc(var(--cngx-popover-panel-arrow-size, 8px) * 2);background:var(--cngx-popover-panel-bg);border:var(--cngx-popover-panel-border, 1px solid oklch(0 0 0 / .08));transform:rotate(45deg);pointer-events:none}:scope[data-arrow-placement=bottom]>.cngx-popover-panel__arrow{top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-bottom:none}:scope[data-arrow-placement=top]>.cngx-popover-panel__arrow{bottom:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);left:var(--cngx-popover-arrow-offset, 50%);margin-left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-top:none}:scope[data-arrow-placement=left]>.cngx-popover-panel__arrow{right:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-left:none;border-bottom:none}:scope[data-arrow-placement=right]>.cngx-popover-panel__arrow{left:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);top:var(--cngx-popover-arrow-offset, 50%);margin-top:calc(var(--cngx-popover-panel-arrow-size, 8px) * -1);border-right:none;border-top:none}:scope.cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.92 .05 250);--cngx-popover-panel-accent-text: oklch(.38 .16 260);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.94 .07 155);--cngx-popover-panel-accent-text: oklch(.42 .1 155);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.95 .06 75);--cngx-popover-panel-accent-text: oklch(.46 .12 60);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}:scope.cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.93 .04 25);--cngx-popover-panel-accent-text: oklch(.42 .18 25);border-inline-start:3px solid var(--cngx-popover-panel-accent-text)}.cngx-popover-panel__loading,.cngx-popover-panel__error,.cngx-popover-panel__empty{font-size:.8125rem;line-height:1.5;text-align:center;padding:8px 0}.cngx-popover-panel__error{color:var( --cngx-color-danger-text, oklch(from var(--cngx-color-danger, oklch(.6 .18 25)) .46 c h) )}.cngx-popover-panel__empty{color:var(--cngx-color-text-muted, oklch(.5 .01 250))}@media(prefers-reduced-motion:reduce){:scope{transition:none}}}@media(prefers-color-scheme:dark){:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}:root:not([data-color-scheme=light]):not(.light) .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}[data-color-scheme=dark] .cngx-popover-panel--info,.dark .cngx-popover-panel--info{--cngx-popover-panel-accent: oklch(.32 .05 250);--cngx-popover-panel-accent-text: oklch(.78 .13 250)}[data-color-scheme=dark] .cngx-popover-panel--success,.dark .cngx-popover-panel--success{--cngx-popover-panel-accent: oklch(.32 .06 145);--cngx-popover-panel-accent-text: oklch(.78 .13 145)}[data-color-scheme=dark] .cngx-popover-panel--warning,.dark .cngx-popover-panel--warning{--cngx-popover-panel-accent: oklch(.32 .06 75);--cngx-popover-panel-accent-text: oklch(.85 .14 75)}[data-color-scheme=dark] .cngx-popover-panel--danger,.dark .cngx-popover-panel--danger{--cngx-popover-panel-accent: oklch(.32 .05 25);--cngx-popover-panel-accent-text: oklch(.75 .15 25)}}\n"] }]
|
|
3630
|
+
}], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], role: [{ type: i0.Input, args: [{ isSignal: true, alias: "role", 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 }] }], loadingText: [{ type: i0.Input, args: [{ isSignal: true, alias: "loadingText", required: false }] }], errorText: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorText", required: false }] }], emptyText: [{ type: i0.Input, args: [{ isSignal: true, alias: "emptyText", required: false }] }], headerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverHeader), { isSignal: true }] }], footerSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverFooter), { isSignal: true }] }], 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 }] }], arrowTplDirective: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxPopoverArrow), { isSignal: true }] }] } });
|
|
2248
3631
|
|
|
2249
3632
|
/**
|
|
2250
|
-
*
|
|
3633
|
+
* Closes the composing `CngxPopover` after each success outcome of the
|
|
3634
|
+
* co-hosted `CngxActionStatusBrain` (an own run, or a `success` edge of a
|
|
3635
|
+
* bound `[externalState]`): `CNGX_POPOVER_PANEL_CONFIG.closeOnSuccessDelay`
|
|
3636
|
+
* (`withCloseOnSuccess()`), or `[closeOnSuccessDelay]` per instance. A
|
|
3637
|
+
* follow-up run cancels a scheduled close. Focus returns to the trigger
|
|
3638
|
+
* through the panel's restore claim; this directive restores nothing.
|
|
3639
|
+
*
|
|
3640
|
+
* The runner's live region sits inside the panel, which hides after the
|
|
3641
|
+
* delay (maybe 0 ms) and can take the text with it before AT reads it. So
|
|
3642
|
+
* a success that arms a close is covered (`CNGX_ANNOUNCEMENT_COVER`, the
|
|
3643
|
+
* region gets `''`) and spoken through `CngxLiveAnnouncer` outside, scoped
|
|
3644
|
+
* to the popover's parent, once, with the text `CNGX_ACTION_STATUS` resolves
|
|
3645
|
+
* for it, unless another co-hosted cover (a toast) voices it already. Only
|
|
3646
|
+
* this arming case is covered here: the runner speaks any other settle in a
|
|
3647
|
+
* closed panel through `CngxLiveAnnouncer` itself. A selector-less host
|
|
3648
|
+
* directive; `CngxPopoverAction` co-hosts it
|
|
3649
|
+
* next to `CngxActionStatusBrain`.
|
|
2251
3650
|
*
|
|
2252
|
-
*
|
|
2253
|
-
*
|
|
2254
|
-
*
|
|
2255
|
-
*
|
|
2256
|
-
*
|
|
2257
|
-
*
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
3651
|
+
* @wcag AA
|
|
3652
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-close-on-success.directive.ts
|
|
3653
|
+
* @since 0.3.0
|
|
3654
|
+
* @relatedTo CngxPopoverAction, CngxActionStatusBrain, CNGX_ANNOUNCEMENT_COVER, CNGX_POPOVER_PANEL_CONFIG
|
|
3655
|
+
* <example-url>/#/common/popover/popover-panel/close-on-success</example-url>
|
|
3656
|
+
* @axis level molecule
|
|
3657
|
+
*/
|
|
3658
|
+
class CngxPopoverCloseOnSuccess {
|
|
3659
|
+
popover = inject(CngxPopover, { optional: true });
|
|
3660
|
+
config = inject(CNGX_POPOVER_PANEL_CONFIG);
|
|
3661
|
+
announcer = inject(CngxLiveAnnouncer);
|
|
3662
|
+
status = inject(CNGX_ACTION_STATUS);
|
|
3663
|
+
injector = inject(Injector);
|
|
3664
|
+
coverUnits = injectLazySelf(CNGX_ANNOUNCEMENT_COVER, { optional: true });
|
|
3665
|
+
/**
|
|
3666
|
+
* Per-instance close-on-success, named after the
|
|
3667
|
+
* `CNGX_POPOVER_PANEL_CONFIG.closeOnSuccessDelay` it overrides. A number
|
|
3668
|
+
* closes the composing popover that many ms after each success, also
|
|
3669
|
+
* without `withCloseOnSuccess()`; `null` keeps this confirm's popover open
|
|
3670
|
+
* although the config closes it; unbound (`undefined`) uses the config.
|
|
3671
|
+
*/
|
|
3672
|
+
closeOnSuccessDelay = input(undefined, ...(ngDevMode ? [{ debugName: "closeOnSuccessDelay" }] : /* istanbul ignore next */ []));
|
|
3673
|
+
closeOnSuccessTimer = null;
|
|
3674
|
+
constructor() {
|
|
3675
|
+
// The status outcome, not the runner's settle: it follows a bound
|
|
3676
|
+
// [externalState] and is silent for the own runs while one is bound.
|
|
3677
|
+
this.status.outcome.subscribe((outcome) => this.handleOutcome(outcome));
|
|
3678
|
+
// A follow-up run cancels a scheduled close, so a re-triggered action
|
|
3679
|
+
// never yanks the panel away mid-interaction.
|
|
3680
|
+
effect(() => {
|
|
3681
|
+
if (this.status.status() === 'pending') {
|
|
3682
|
+
untracked(() => this.clearCloseOnSuccessTimer());
|
|
3683
|
+
}
|
|
3684
|
+
});
|
|
3685
|
+
inject(DestroyRef).onDestroy(() => this.clearCloseOnSuccessTimer());
|
|
3686
|
+
}
|
|
3687
|
+
/** `true` for a success that arms a close: it is spoken outside the panel instead. */
|
|
3688
|
+
covers(status) {
|
|
3689
|
+
return this.closeDelayFor(status) !== undefined;
|
|
3690
|
+
}
|
|
3691
|
+
/** One outcome: re-arms the close and speaks a closing success outside the panel. */
|
|
3692
|
+
handleOutcome(outcome) {
|
|
3693
|
+
this.clearCloseOnSuccessTimer();
|
|
3694
|
+
const delay = this.closeDelayFor(outcome.status);
|
|
3695
|
+
if (delay === undefined) {
|
|
3696
|
+
return;
|
|
3697
|
+
}
|
|
3698
|
+
this.closeOnSuccessTimer = setTimeout(() => {
|
|
3699
|
+
this.closeOnSuccessTimer = null;
|
|
3700
|
+
this.popover?.hide();
|
|
3701
|
+
}, delay);
|
|
3702
|
+
// After render, so the result cell shows this settle before its text is read.
|
|
3703
|
+
afterNextRender({ write: () => this.announceOutside() }, { injector: this.injector });
|
|
3704
|
+
}
|
|
3705
|
+
announceOutside() {
|
|
3706
|
+
const text = this.status.outcomeText('success');
|
|
3707
|
+
if (text === '' || this.coveredElsewhere()) {
|
|
3708
|
+
return;
|
|
3709
|
+
}
|
|
3710
|
+
const scope = this.popover?.elementRef.nativeElement.parentElement ?? null;
|
|
3711
|
+
untracked(() => this.announcer.announce(text, 'polite', scope));
|
|
3712
|
+
}
|
|
3713
|
+
/** `true` when another co-hosted cover (a toast) already voices the success. */
|
|
3714
|
+
coveredElsewhere() {
|
|
3715
|
+
return untracked(() => this.coverUnits()?.some((c) => c !== this && c.covers('success')) ?? false);
|
|
3716
|
+
}
|
|
3717
|
+
/** The close delay an outcome arms, or `undefined` when it closes nothing. */
|
|
3718
|
+
closeDelayFor(status) {
|
|
3719
|
+
if (status !== 'success' || !this.popover) {
|
|
3720
|
+
return undefined;
|
|
3721
|
+
}
|
|
3722
|
+
const delay = untracked(this.closeOnSuccessDelay);
|
|
3723
|
+
if (delay === null) {
|
|
3724
|
+
return undefined;
|
|
3725
|
+
}
|
|
3726
|
+
return delay ?? this.config.closeOnSuccessDelay;
|
|
3727
|
+
}
|
|
3728
|
+
clearCloseOnSuccessTimer() {
|
|
3729
|
+
if (this.closeOnSuccessTimer) {
|
|
3730
|
+
clearTimeout(this.closeOnSuccessTimer);
|
|
3731
|
+
this.closeOnSuccessTimer = null;
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
3734
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverCloseOnSuccess, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
3735
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.4", type: CngxPopoverCloseOnSuccess, isStandalone: true, inputs: { closeOnSuccessDelay: { classPropertyName: "closeOnSuccessDelay", publicName: "closeOnSuccessDelay", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
3736
|
+
{ provide: CNGX_ANNOUNCEMENT_COVER, useExisting: CngxPopoverCloseOnSuccess, multi: true },
|
|
3737
|
+
], exportAs: ["cngxPopoverCloseOnSuccess"], ngImport: i0 });
|
|
3738
|
+
}
|
|
3739
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverCloseOnSuccess, decorators: [{
|
|
3740
|
+
type: Directive,
|
|
3741
|
+
args: [{
|
|
3742
|
+
standalone: true,
|
|
3743
|
+
exportAs: 'cngxPopoverCloseOnSuccess',
|
|
3744
|
+
providers: [
|
|
3745
|
+
{ provide: CNGX_ANNOUNCEMENT_COVER, useExisting: CngxPopoverCloseOnSuccess, multi: true },
|
|
3746
|
+
],
|
|
3747
|
+
}]
|
|
3748
|
+
}], ctorParameters: () => [], propDecorators: { closeOnSuccessDelay: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnSuccessDelay", required: false }] }] } });
|
|
3749
|
+
|
|
3750
|
+
/**
|
|
3751
|
+
* Async confirm button for a `cngx-popover-panel` footer. A
|
|
3752
|
+
* `CngxButtonBrain` host on the native `<button>` with `cngxAsyncClick`
|
|
3753
|
+
* co-hosted: `[action]` (required) runs on click, and the button stylesheet
|
|
3754
|
+
* paints it. The variant is the selector's own value (default `outline`),
|
|
3755
|
+
* `tone` and `size` are inputs, and the size is pinned to `sm` against the
|
|
3756
|
+
* group and the config (the input still wins). Tone comes from the button
|
|
3757
|
+
* family, not from the panel variant. To close without a run, use
|
|
3758
|
+
* `button[cngxPopoverDismiss]`.
|
|
3759
|
+
*
|
|
3760
|
+
* `disabled` renders `aria-disabled="true"`, keeps the button focusable,
|
|
3761
|
+
* refuses the run and references a `disabledReason` through
|
|
3762
|
+
* `aria-describedby`. `aria-busy`, `data-pending` and `data-busy` come from
|
|
3763
|
+
* the brain over the co-hosted run.
|
|
3764
|
+
*
|
|
3765
|
+
* Supports the `cngxPending` / `cngxSucceeded` / `cngxFailed` templates and
|
|
3766
|
+
* the `pendingLabel` / `succeededLabel` / `failedLabel` strings of
|
|
3767
|
+
* `CngxActionButton`, or use `status()` + `@switch` for full control.
|
|
3768
|
+
* `[externalState]` reflects a run started elsewhere, `(outcome)` emits once
|
|
3769
|
+
* per own settle and per external `success` / `error` edge. The
|
|
3770
|
+
* label follows the busy gate (`CNGX_LOADING_CONFIG.showDelay`, held for
|
|
3771
|
+
* `minDwell`; `[showDelay]` / `[minDwell]` per button): while the busy
|
|
3772
|
+
* visual shows, through the run and its dwell after the settle, the pending
|
|
3773
|
+
* template stays visible with no spinner, and without one the spinner covers
|
|
3774
|
+
* the idle label. The result templates show once the busy visual releases, so
|
|
3775
|
+
* a fast run goes from the idle label straight to the result. Every label
|
|
3776
|
+
* cell stays mounted in one grid cell (the inactive ones `visibility: hidden`
|
|
3777
|
+
* and `aria-hidden`), so the button keeps the width of its widest label and a
|
|
3778
|
+
* right-aligned footer never shifts; the active cell alone names it. `status()`
|
|
3779
|
+
* stays immediate; branch a hand-rolled `@switch` on {@link busyVisible} for
|
|
3780
|
+
* the same timing.
|
|
3781
|
+
*
|
|
3782
|
+
* The status layer comes from the `CngxActionStatusBrain` host directive
|
|
3783
|
+
* (read through `CNGX_ACTION_STATUS`) and close-on-success from the
|
|
3784
|
+
* `CngxPopoverCloseOnSuccess` host directive; the component is the skin.
|
|
3785
|
+
* Each settle is spoken once through the `cngxAsyncClick` live region next
|
|
3786
|
+
* to the button: `succeededAnnouncement` / `failedAnnouncement`, else the
|
|
3787
|
+
* text of the rendered result template (`aria-hidden` parts skipped; read
|
|
3788
|
+
* from its cell even while the dwell still hides it), else
|
|
3789
|
+
* `CNGX_INTERACTIVE_I18N.asyncClickSucceeded` / `asyncClickFailed`.
|
|
3790
|
+
* `announce="never"` keeps the region empty. Under
|
|
3791
|
+
* `withCloseOnSuccess()` the panel closes once per success; focus returns
|
|
3792
|
+
* to the trigger through the panel's restore claim; `[closeOnSuccessDelay]`
|
|
3793
|
+
* overrides the config per confirm (`null` turns it off). A success that closes
|
|
3794
|
+
* the panel is spoken through `CngxLiveAnnouncer` outside it instead (the
|
|
3795
|
+
* sibling region hides with the panel), still once.
|
|
3796
|
+
*
|
|
3797
|
+
* Migration from `cngx-popover-action`: `variant="primary"` is
|
|
3798
|
+
* `cngxPopoverAction="solid" tone="primary"`, `variant="danger"` is
|
|
3799
|
+
* `cngxPopoverAction="solid" tone="danger"`, `variant="ghost"` is
|
|
3800
|
+
* `cngxPopoverAction="ghost"`, `variant="secondary"` is the default
|
|
3801
|
+
* `outline`; `role="dismiss"` is `button[cngxPopoverDismiss]`.
|
|
2264
3802
|
*
|
|
2265
3803
|
* ### Confirm with templates
|
|
2266
3804
|
* ```html
|
|
2267
|
-
* <
|
|
3805
|
+
* <button cngxPopoverAction="solid" tone="primary" [action]="save">
|
|
2268
3806
|
* Save
|
|
2269
3807
|
* <ng-template cngxPending>Saving...</ng-template>
|
|
2270
3808
|
* <ng-template cngxSucceeded>Saved!</ng-template>
|
|
2271
3809
|
* <ng-template cngxFailed let-err>{{ err }}</ng-template>
|
|
2272
|
-
* </
|
|
3810
|
+
* </button>
|
|
2273
3811
|
* ```
|
|
2274
3812
|
*
|
|
2275
|
-
* ### With
|
|
3813
|
+
* ### With `@switch`
|
|
2276
3814
|
* ```html
|
|
2277
|
-
* <
|
|
3815
|
+
* <button cngxPopoverAction [action]="save" #act="cngxPopoverAction">
|
|
2278
3816
|
* @switch (act.status()) {
|
|
2279
|
-
* @case ('pending')
|
|
3817
|
+
* @case ('pending') { Saving... }
|
|
2280
3818
|
* @case ('success') { Done }
|
|
2281
|
-
* @default
|
|
3819
|
+
* @default { Save }
|
|
2282
3820
|
* }
|
|
2283
|
-
* </
|
|
3821
|
+
* </button>
|
|
2284
3822
|
* ```
|
|
2285
3823
|
*
|
|
2286
|
-
* @category common/popover
|
|
2287
|
-
* @docsKind primary
|
|
2288
3824
|
* @wcag AA
|
|
2289
3825
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-action.component.ts
|
|
2290
|
-
* @since 0.
|
|
2291
|
-
* @relatedTo CngxPopoverPanel, CngxPopoverFooter
|
|
2292
|
-
* @slot cngxPending
|
|
2293
|
-
* @slot cngxSucceeded
|
|
2294
|
-
* @slot cngxFailed
|
|
2295
|
-
* <example-url
|
|
2296
|
-
* <example-url
|
|
2297
|
-
* <example-url
|
|
3826
|
+
* @since 0.3.0
|
|
3827
|
+
* @relatedTo CngxPopoverDismiss, CngxPopoverPanel, CngxPopoverFooter, CngxButtonBrain, CngxAsyncClick, CngxActionStatusBrain, CngxPopoverCloseOnSuccess
|
|
3828
|
+
* @slot cngxPending Replaces the label while the action runs, once the run outlasts the show delay.
|
|
3829
|
+
* @slot cngxSucceeded Replaces the label after the action succeeds, once the busy visual releases.
|
|
3830
|
+
* @slot cngxFailed Replaces the label when the action fails, once the busy visual releases; gets the error.
|
|
3831
|
+
* <example-url>/#/common/popover/popover-panel/with-footer-actions</example-url>
|
|
3832
|
+
* <example-url>/#/common/popover/popover-panel/with-dividers</example-url>
|
|
3833
|
+
* <example-url>/#/common/popover/popover-panel/footer-actions-plain</example-url>
|
|
3834
|
+
* <example-url>/#/common/popover/popover-panel/close-on-success</example-url>
|
|
3835
|
+
* @axis level organism
|
|
2298
3836
|
*/
|
|
2299
3837
|
class CngxPopoverAction {
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
/**
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
*
|
|
2317
|
-
*
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
status = computed(() => this.asyncClick()?.status() ?? 'idle', ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
|
|
2321
|
-
closeOnSuccessTimer = null;
|
|
2322
|
-
constructor() {
|
|
2323
|
-
// withCloseOnSuccess(): a confirmed footer action hides the composing
|
|
2324
|
-
// popover after the configured delay. A follow-up run cancels the
|
|
2325
|
-
// pending close so a re-triggered action never yanks the panel away
|
|
2326
|
-
// mid-interaction.
|
|
2327
|
-
effect(() => {
|
|
2328
|
-
const status = this.status();
|
|
2329
|
-
const delay = untracked(() => this.config.closeOnSuccessDelay);
|
|
2330
|
-
if (status === 'pending') {
|
|
2331
|
-
this.clearCloseOnSuccessTimer();
|
|
2332
|
-
}
|
|
2333
|
-
if (status === 'success' && delay !== undefined && this.popover) {
|
|
2334
|
-
this.clearCloseOnSuccessTimer();
|
|
2335
|
-
this.closeOnSuccessTimer = setTimeout(() => {
|
|
2336
|
-
this.closeOnSuccessTimer = null;
|
|
2337
|
-
this.popover?.hide();
|
|
2338
|
-
}, delay);
|
|
2339
|
-
}
|
|
2340
|
-
});
|
|
2341
|
-
this.destroyRef.onDestroy(() => this.clearCloseOnSuccessTimer());
|
|
2342
|
-
if (isDevMode()) {
|
|
2343
|
-
afterNextRender(() => {
|
|
2344
|
-
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".');
|
|
2347
|
-
}
|
|
2348
|
-
});
|
|
2349
|
-
}
|
|
2350
|
-
}
|
|
2351
|
-
handleDismiss() {
|
|
2352
|
-
this.popover?.hide();
|
|
2353
|
-
}
|
|
2354
|
-
clearCloseOnSuccessTimer() {
|
|
2355
|
-
if (this.closeOnSuccessTimer) {
|
|
2356
|
-
clearTimeout(this.closeOnSuccessTimer);
|
|
2357
|
-
this.closeOnSuccessTimer = null;
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
3838
|
+
brain = inject(CngxButtonBrain);
|
|
3839
|
+
actionStatus = inject(CNGX_ACTION_STATUS);
|
|
3840
|
+
startSlot = contentChild(CngxButtonStart, ...(ngDevMode ? [{ debugName: "startSlot" }] : /* istanbul ignore next */ []));
|
|
3841
|
+
endSlot = contentChild(CngxButtonEnd, ...(ngDevMode ? [{ debugName: "endSlot" }] : /* istanbul ignore next */ []));
|
|
3842
|
+
/**
|
|
3843
|
+
* Effective status - `'idle' | 'pending' | 'success' | 'error'`:
|
|
3844
|
+
* `[externalState]` when bound, else the run. Immediate, not gated.
|
|
3845
|
+
*/
|
|
3846
|
+
status = this.actionStatus.status;
|
|
3847
|
+
/**
|
|
3848
|
+
* `true` while the busy visual shows: the run after the loading config's
|
|
3849
|
+
* show delay, held for its min-dwell.
|
|
3850
|
+
*/
|
|
3851
|
+
busyVisible = this.brain.busyVisible;
|
|
3852
|
+
/**
|
|
3853
|
+
* `CngxAsyncState` view of the effective lifecycle (`[externalState]` when
|
|
3854
|
+
* bound, else the run). Bind it to a state consumer: `[state]="act.state"`
|
|
3855
|
+
* on `cngxToastOn` or `cngxAlertOn`.
|
|
3856
|
+
*/
|
|
3857
|
+
state = this.actionStatus.state;
|
|
2360
3858
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverAction, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2361
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
#btn="cngxAsyncClick"
|
|
2377
|
-
[feedbackDuration]="feedbackDuration()"
|
|
2378
|
-
[autoAnnounce]="false"
|
|
2379
|
-
[class]="'cngx-popover-action cngx-popover-action--' + variant()"
|
|
2380
|
-
>
|
|
2381
|
-
@switch (btn.status()) {
|
|
2382
|
-
@case ('pending') {
|
|
2383
|
-
@if (pendingTpl(); as tpl) {
|
|
2384
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
2385
|
-
} @else {
|
|
2386
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
2387
|
-
}
|
|
2388
|
-
}
|
|
2389
|
-
@case ('success') {
|
|
2390
|
-
@if (succeededTpl(); as tpl) {
|
|
2391
|
-
<ng-container *ngTemplateOutlet="tpl.templateRef" />
|
|
2392
|
-
} @else {
|
|
2393
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
2394
|
-
}
|
|
2395
|
-
}
|
|
2396
|
-
@case ('error') {
|
|
2397
|
-
@if (failedTpl(); as tpl) {
|
|
2398
|
-
<ng-container
|
|
2399
|
-
*ngTemplateOutlet="tpl.templateRef; context: { $implicit: btn.error() }"
|
|
2400
|
-
/>
|
|
2401
|
-
} @else {
|
|
2402
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
@default {
|
|
2406
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
</button>
|
|
2410
|
-
<span aria-live="polite" aria-atomic="true" class="cngx-popover-action__sr-only">
|
|
2411
|
-
{{ btn.announcement() }}
|
|
2412
|
-
</span>
|
|
2413
|
-
}
|
|
2414
|
-
`, 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 });
|
|
3859
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxPopoverAction, isStandalone: true, selector: "button[cngxPopoverAction]", host: { properties: { "attr.data-start": "startSlot() ? \"\" : null", "attr.data-end": "endSlot() ? \"\" : null" }, classAttribute: "cngx-button cngx-popover-action" }, providers: [
|
|
3860
|
+
provideButtonHost('cngxPopoverAction', { defaultVariant: 'outline', fixed: { size: 'sm' } }),
|
|
3861
|
+
provideActionStatusHost(),
|
|
3862
|
+
], queries: [{ propertyName: "startSlot", first: true, predicate: CngxButtonStart, descendants: true, isSignal: true }, { propertyName: "endSlot", first: true, predicate: CngxButtonEnd, descendants: true, isSignal: true }], exportAs: ["cngxPopoverAction"], hostDirectives: [{ directive: i1$1.CngxButtonBrain, inputs: ["variant", "cngxPopoverAction", "tone", "tone", "size", "size", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "type", "type"] }, { directive: i2.CngxAsyncClick, inputs: ["cngxAsyncClick", "action", "feedbackDuration", "feedbackDuration", "showDelay", "showDelay", "minDwell", "minDwell"], outputs: ["settled", "settled"] }, { directive: i2.CngxActionStatusBrain, inputs: ["succeededAnnouncement", "succeededAnnouncement", "failedAnnouncement", "failedAnnouncement", "announce", "announce", "pendingLabel", "pendingLabel", "succeededLabel", "succeededLabel", "failedLabel", "failedLabel", "externalState", "externalState"], outputs: ["outcome", "outcome"] }, { directive: CngxPopoverCloseOnSuccess, inputs: ["closeOnSuccessDelay", "closeOnSuccessDelay"] }], ngImport: i0, template: `
|
|
3863
|
+
<ng-content select="[cngxButtonStart]" />
|
|
3864
|
+
<span
|
|
3865
|
+
class="cngx-button__label cngx-popover-action__labels"
|
|
3866
|
+
cngxActionStatusStack
|
|
3867
|
+
cellClass="cngx-popover-action__label"
|
|
3868
|
+
>
|
|
3869
|
+
<ng-content />
|
|
3870
|
+
</span>
|
|
3871
|
+
<ng-content select="[cngxButtonEnd]" />
|
|
3872
|
+
<cngx-button-adornment />
|
|
3873
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "component", type: CngxActionStatusStack, selector: "span[cngxActionStatusStack]", inputs: ["cellClass"] }, { kind: "component", type: CngxButtonAdornment, selector: "cngx-button-adornment" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
2415
3874
|
}
|
|
2416
3875
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverAction, decorators: [{
|
|
2417
3876
|
type: Component,
|
|
2418
|
-
args: [{ selector: '
|
|
2419
|
-
|
|
3877
|
+
args: [{ selector: 'button[cngxPopoverAction]', standalone: true, imports: [CngxActionStatusStack, CngxButtonAdornment], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, exportAs: 'cngxPopoverAction', hostDirectives: [
|
|
3878
|
+
{
|
|
3879
|
+
directive: CngxButtonBrain,
|
|
3880
|
+
inputs: [
|
|
3881
|
+
'variant: cngxPopoverAction',
|
|
3882
|
+
'tone',
|
|
3883
|
+
'size',
|
|
3884
|
+
'disabled',
|
|
3885
|
+
'disabledReason',
|
|
3886
|
+
'cngxDescribedBy',
|
|
3887
|
+
'type',
|
|
3888
|
+
],
|
|
3889
|
+
},
|
|
3890
|
+
{
|
|
3891
|
+
directive: CngxAsyncClick,
|
|
3892
|
+
inputs: ['cngxAsyncClick: action', 'feedbackDuration', 'showDelay', 'minDwell'],
|
|
3893
|
+
outputs: ['settled'],
|
|
3894
|
+
},
|
|
3895
|
+
{
|
|
3896
|
+
directive: CngxActionStatusBrain,
|
|
3897
|
+
outputs: ['outcome'],
|
|
3898
|
+
inputs: [
|
|
3899
|
+
'succeededAnnouncement',
|
|
3900
|
+
'failedAnnouncement',
|
|
3901
|
+
'announce',
|
|
3902
|
+
'pendingLabel',
|
|
3903
|
+
'succeededLabel',
|
|
3904
|
+
'failedLabel',
|
|
3905
|
+
'externalState',
|
|
3906
|
+
],
|
|
3907
|
+
},
|
|
3908
|
+
{ directive: CngxPopoverCloseOnSuccess, inputs: ['closeOnSuccessDelay'] },
|
|
3909
|
+
], providers: [
|
|
3910
|
+
provideButtonHost('cngxPopoverAction', { defaultVariant: 'outline', fixed: { size: 'sm' } }),
|
|
3911
|
+
provideActionStatusHost(),
|
|
3912
|
+
], host: {
|
|
3913
|
+
class: 'cngx-button cngx-popover-action',
|
|
3914
|
+
'[attr.data-start]': 'startSlot() ? "" : null',
|
|
3915
|
+
'[attr.data-end]': 'endSlot() ? "" : null',
|
|
3916
|
+
}, template: `
|
|
3917
|
+
<ng-content select="[cngxButtonStart]" />
|
|
3918
|
+
<span
|
|
3919
|
+
class="cngx-button__label cngx-popover-action__labels"
|
|
3920
|
+
cngxActionStatusStack
|
|
3921
|
+
cellClass="cngx-popover-action__label"
|
|
3922
|
+
>
|
|
3923
|
+
<ng-content />
|
|
3924
|
+
</span>
|
|
3925
|
+
<ng-content select="[cngxButtonEnd]" />
|
|
3926
|
+
<cngx-button-adornment />
|
|
3927
|
+
` }]
|
|
3928
|
+
}], propDecorators: { startSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonStart), { isSignal: true }] }], endSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonEnd), { isSignal: true }] }] } });
|
|
2420
3929
|
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
<ng-container *ngTemplateOutlet="idle" />
|
|
2464
|
-
}
|
|
3930
|
+
/**
|
|
3931
|
+
* Footer button that closes the popover it sits in. A `CngxButtonBrain`
|
|
3932
|
+
* host on the native `<button>`, painted by the button stylesheet: the
|
|
3933
|
+
* variant is the selector's own value (default `outline`), `tone` and
|
|
3934
|
+
* `size` are inputs, and the size is pinned to `sm` against the group and
|
|
3935
|
+
* the config (the input still wins).
|
|
3936
|
+
*
|
|
3937
|
+
* `disabled` renders `aria-disabled="true"`, keeps the button focusable,
|
|
3938
|
+
* swallows the click (the popover stays open) and references a
|
|
3939
|
+
* `disabledReason` through `aria-describedby`. Focus returns to the
|
|
3940
|
+
* trigger through the composing `CngxPopoverPanel`, which claims the
|
|
3941
|
+
* restore; the button has no restore of its own. Outside a popover the
|
|
3942
|
+
* click does nothing.
|
|
3943
|
+
*
|
|
3944
|
+
* For an async confirm next to it, use `button[cngxPopoverAction]`.
|
|
3945
|
+
*
|
|
3946
|
+
* ```html
|
|
3947
|
+
* <div cngxPopoverFooter>
|
|
3948
|
+
* <button cngxPopoverDismiss>Cancel</button>
|
|
3949
|
+
* <button cngxPopoverAction="solid" tone="danger" [action]="delete">Delete</button>
|
|
3950
|
+
* </div>
|
|
3951
|
+
* ```
|
|
3952
|
+
*
|
|
3953
|
+
* @wcag AA
|
|
3954
|
+
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-dismiss.component.ts
|
|
3955
|
+
* @since 0.3.0
|
|
3956
|
+
* @relatedTo CngxPopoverAction, CngxPopoverPanel, CngxPopoverFooter, CngxButtonBrain
|
|
3957
|
+
* <example-url>/#/common/popover/popover-panel/with-footer-actions</example-url>
|
|
3958
|
+
* <example-url>/#/common/popover/popover-panel/with-dividers</example-url>
|
|
3959
|
+
* <example-url>/#/common/popover/popover-panel/footer-actions-plain</example-url>
|
|
3960
|
+
* <example-url>/#/common/popover/popover-panel/close-on-success</example-url>
|
|
3961
|
+
* @axis level molecule
|
|
3962
|
+
*/
|
|
3963
|
+
class CngxPopoverDismiss {
|
|
3964
|
+
popover = inject(CngxPopover, { optional: true });
|
|
3965
|
+
/** @internal */
|
|
3966
|
+
brain = inject(CngxButtonBrain);
|
|
3967
|
+
startSlot = contentChild(CngxButtonStart, ...(ngDevMode ? [{ debugName: "startSlot" }] : /* istanbul ignore next */ []));
|
|
3968
|
+
endSlot = contentChild(CngxButtonEnd, ...(ngDevMode ? [{ debugName: "endSlot" }] : /* istanbul ignore next */ []));
|
|
3969
|
+
handleClick() {
|
|
3970
|
+
if (this.brain.blocked()) {
|
|
3971
|
+
return;
|
|
2465
3972
|
}
|
|
2466
|
-
|
|
2467
|
-
<span aria-live="polite" aria-atomic="true" class="cngx-popover-action__sr-only">
|
|
2468
|
-
{{ btn.announcement() }}
|
|
2469
|
-
</span>
|
|
3973
|
+
this.popover?.hide();
|
|
2470
3974
|
}
|
|
2471
|
-
|
|
2472
|
-
|
|
3975
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverDismiss, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3976
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "21.2.4", type: CngxPopoverDismiss, isStandalone: true, selector: "button[cngxPopoverDismiss]", host: { listeners: { "click": "handleClick()" }, properties: { "attr.data-start": "startSlot() ? \"\" : null", "attr.data-end": "endSlot() ? \"\" : null" }, classAttribute: "cngx-button cngx-popover-dismiss" }, providers: [
|
|
3977
|
+
provideButtonHost('cngxPopoverDismiss', { defaultVariant: 'outline', fixed: { size: 'sm' } }),
|
|
3978
|
+
], queries: [{ propertyName: "startSlot", first: true, predicate: CngxButtonStart, descendants: true, isSignal: true }, { propertyName: "endSlot", first: true, predicate: CngxButtonEnd, descendants: true, isSignal: true }], exportAs: ["cngxPopoverDismiss"], hostDirectives: [{ directive: i1$1.CngxButtonBrain, inputs: ["variant", "cngxPopoverDismiss", "tone", "tone", "size", "size", "disabled", "disabled", "disabledReason", "disabledReason", "cngxDescribedBy", "cngxDescribedBy", "type", "type"] }], ngImport: i0, template: `
|
|
3979
|
+
<ng-content select="[cngxButtonStart]" />
|
|
3980
|
+
<span class="cngx-button__label"><ng-content /></span>
|
|
3981
|
+
<ng-content select="[cngxButtonEnd]" />
|
|
3982
|
+
<cngx-button-adornment />
|
|
3983
|
+
`, isInline: true, dependencies: [{ kind: "component", type: CngxButtonAdornment, selector: "cngx-button-adornment" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
3984
|
+
}
|
|
3985
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverDismiss, decorators: [{
|
|
3986
|
+
type: Component,
|
|
3987
|
+
args: [{
|
|
3988
|
+
// eslint-disable-next-line @angular-eslint/component-selector -- attribute selector by design (sits on the native button)
|
|
3989
|
+
selector: 'button[cngxPopoverDismiss]',
|
|
3990
|
+
standalone: true,
|
|
3991
|
+
imports: [CngxButtonAdornment],
|
|
3992
|
+
exportAs: 'cngxPopoverDismiss',
|
|
3993
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3994
|
+
encapsulation: ViewEncapsulation.None,
|
|
3995
|
+
hostDirectives: [
|
|
3996
|
+
{
|
|
3997
|
+
directive: CngxButtonBrain,
|
|
3998
|
+
inputs: [
|
|
3999
|
+
'variant: cngxPopoverDismiss',
|
|
4000
|
+
'tone',
|
|
4001
|
+
'size',
|
|
4002
|
+
'disabled',
|
|
4003
|
+
'disabledReason',
|
|
4004
|
+
'cngxDescribedBy',
|
|
4005
|
+
'type',
|
|
4006
|
+
],
|
|
4007
|
+
},
|
|
4008
|
+
],
|
|
4009
|
+
providers: [
|
|
4010
|
+
provideButtonHost('cngxPopoverDismiss', { defaultVariant: 'outline', fixed: { size: 'sm' } }),
|
|
4011
|
+
],
|
|
4012
|
+
host: {
|
|
4013
|
+
class: 'cngx-button cngx-popover-dismiss',
|
|
4014
|
+
'[attr.data-start]': 'startSlot() ? "" : null',
|
|
4015
|
+
'[attr.data-end]': 'endSlot() ? "" : null',
|
|
4016
|
+
'(click)': 'handleClick()',
|
|
4017
|
+
},
|
|
4018
|
+
template: `
|
|
4019
|
+
<ng-content select="[cngxButtonStart]" />
|
|
4020
|
+
<span class="cngx-button__label"><ng-content /></span>
|
|
4021
|
+
<ng-content select="[cngxButtonEnd]" />
|
|
4022
|
+
<cngx-button-adornment />
|
|
4023
|
+
`,
|
|
4024
|
+
}]
|
|
4025
|
+
}], propDecorators: { startSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonStart), { isSignal: true }] }], endSlot: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CngxButtonEnd), { isSignal: true }] }] } });
|
|
2473
4026
|
|
|
2474
4027
|
/**
|
|
2475
4028
|
* Separator for use inside `cngx-popover-panel` (or a bare `[cngxPopover]`).
|
|
@@ -2497,20 +4050,19 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2497
4050
|
* ### Vertical separator between footer action groups
|
|
2498
4051
|
* ```html
|
|
2499
4052
|
* <div cngxPopoverFooter>
|
|
2500
|
-
* <
|
|
4053
|
+
* <button cngxPopoverDismiss>Cancel</button>
|
|
2501
4054
|
* <span cngxPopoverDivider orientation="vertical"></span>
|
|
2502
|
-
* <
|
|
4055
|
+
* <button cngxPopoverAction [action]="save">Save</button>
|
|
2503
4056
|
* </div>
|
|
2504
4057
|
* ```
|
|
2505
4058
|
*
|
|
2506
|
-
* @category common/popover
|
|
2507
4059
|
* @github https://github.com/cngxjs/cngx/blob/main/projects/common/popover/popover-divider.directive.ts
|
|
2508
|
-
* @since 0.
|
|
4060
|
+
* @since 0.3.0
|
|
2509
4061
|
* @relatedTo CngxPopoverPanel, CngxDivider
|
|
2510
4062
|
*/
|
|
2511
4063
|
class CngxPopoverDivider {
|
|
2512
4064
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverDivider, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
2513
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverDivider, isStandalone: true, selector: "[cngxPopoverDivider]", host: { classAttribute: "cngx-popover-divider" }, exportAs: ["cngxPopoverDivider"], hostDirectives: [{ directive: i1$
|
|
4065
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.4", type: CngxPopoverDivider, isStandalone: true, selector: "[cngxPopoverDivider]", host: { classAttribute: "cngx-popover-divider" }, exportAs: ["cngxPopoverDivider"], hostDirectives: [{ directive: i1$2.CngxDivider, inputs: ["orientation", "orientation", "inset", "inset"] }], ngImport: i0 });
|
|
2514
4066
|
}
|
|
2515
4067
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: CngxPopoverDivider, decorators: [{
|
|
2516
4068
|
type: Directive,
|
|
@@ -2531,12 +4083,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
2531
4083
|
}] });
|
|
2532
4084
|
|
|
2533
4085
|
/**
|
|
2534
|
-
* @module
|
|
4086
|
+
* @module `@cngx/common/popover`
|
|
2535
4087
|
*/
|
|
2536
4088
|
|
|
2537
4089
|
/**
|
|
2538
4090
|
* Generated bundle index. Do not edit.
|
|
2539
4091
|
*/
|
|
2540
4092
|
|
|
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 };
|
|
4093
|
+
export { CNGX_FLOATING_FALLBACK, CNGX_POPOVER_ARROW_BOUNDS, CNGX_POPOVER_LANGUAGE_EN, CNGX_POPOVER_PANEL_CONFIG, CngxPopover, CngxPopoverAction, CngxPopoverAnchor, CngxPopoverArrow, CngxPopoverBody, CngxPopoverClose, CngxPopoverCloseOnSuccess, CngxPopoverDismiss, CngxPopoverDivider, CngxPopoverEmpty, CngxPopoverError, CngxPopoverFooter, CngxPopoverHeader, CngxPopoverLoading, CngxPopoverPanel, CngxPopoverSheet, CngxPopoverSheetHandle, CngxPopoverSheetHeader, CngxPopoverSheetInitialFocus, CngxPopoverSheetTitle, CngxPopoverTrigger, CngxTooltip, provideFloatingFallback, providePopoverPanel, withArrow, withArrowTemplate, withAutoDismiss, withCloseButton, withCloseOnSuccess, withDefaultVariant, withPopoverPanelLabels };
|
|
2542
4094
|
//# sourceMappingURL=cngx-common-popover.mjs.map
|