ng-primitives 0.112.3 → 0.114.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/dialog/index.d.ts +85 -28
- package/fesm2022/ng-primitives-dialog.mjs +164 -78
- package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/ng-primitives-portal.mjs +340 -62
- package/fesm2022/ng-primitives-portal.mjs.map +1 -1
- package/package.json +1 -1
- package/portal/index.d.ts +159 -4
package/portal/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _angular_core from '@angular/core';
|
|
|
4
4
|
import { WritableSignal, TemplateRef, Type, Injector, ViewContainerRef, Signal, Provider, ValueProvider, ApplicationRef } from '@angular/core';
|
|
5
5
|
import { FocusOrigin } from '@angular/cdk/a11y';
|
|
6
6
|
import { Subject } from 'rxjs';
|
|
7
|
-
import { ViewportRuler } from '@angular/cdk/
|
|
7
|
+
import { ViewportRuler } from '@angular/cdk/scrolling';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Options for configuring flip behavior to keep the floating element in view.
|
|
@@ -278,11 +278,12 @@ declare class NgpOverlay<T = unknown> implements CooldownOverlay {
|
|
|
278
278
|
private config;
|
|
279
279
|
private readonly disposables;
|
|
280
280
|
private readonly document;
|
|
281
|
+
private readonly viewportRuler;
|
|
281
282
|
private readonly destroyRef;
|
|
282
283
|
private readonly viewContainerRef;
|
|
283
|
-
private readonly viewportRuler;
|
|
284
284
|
private readonly focusMonitor;
|
|
285
285
|
private readonly cooldownManager;
|
|
286
|
+
private readonly registry;
|
|
286
287
|
/** Access any parent overlays */
|
|
287
288
|
private readonly parentOverlay;
|
|
288
289
|
/** Track child overlays for outside click detection */
|
|
@@ -506,6 +507,160 @@ interface OverlayTriggerOptions {
|
|
|
506
507
|
origin?: FocusOrigin;
|
|
507
508
|
}
|
|
508
509
|
|
|
510
|
+
/**
|
|
511
|
+
* A dismiss guard can be a boolean or a callback that returns a boolean (sync or async).
|
|
512
|
+
* - `true` → always dismiss
|
|
513
|
+
* - `false` → never dismiss
|
|
514
|
+
* - `(target) => boolean | Promise<boolean>` → custom logic per interaction
|
|
515
|
+
*/
|
|
516
|
+
type NgpDismissGuard<T = Element> = boolean | ((target: T) => boolean | Promise<boolean>);
|
|
517
|
+
/**
|
|
518
|
+
* Dismiss policy for an overlay entry.
|
|
519
|
+
* Determines how the overlay responds to outside clicks and escape key presses.
|
|
520
|
+
* @internal
|
|
521
|
+
*/
|
|
522
|
+
interface NgpDismissPolicy {
|
|
523
|
+
/** Whether clicking outside should close this overlay, or a guard function */
|
|
524
|
+
outsidePress: NgpDismissGuard<Element>;
|
|
525
|
+
/** Whether pressing Escape should close this overlay, or a guard function */
|
|
526
|
+
escapeKey: NgpDismissGuard<KeyboardEvent>;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* An entry in the overlay registry representing a single visible overlay.
|
|
530
|
+
* @internal
|
|
531
|
+
*/
|
|
532
|
+
interface NgpOverlayEntry {
|
|
533
|
+
/** Unique overlay ID */
|
|
534
|
+
id: string;
|
|
535
|
+
/** Parent overlay ID, null for root overlays */
|
|
536
|
+
parentId: string | null;
|
|
537
|
+
/** Reference to the overlay instance for calling hide()/hideImmediate() */
|
|
538
|
+
overlay: NgpOverlayRef;
|
|
539
|
+
/** Function that returns the portal DOM elements */
|
|
540
|
+
getElements: () => HTMLElement[];
|
|
541
|
+
/** The trigger element */
|
|
542
|
+
triggerElement: HTMLElement;
|
|
543
|
+
/** Optional anchor element */
|
|
544
|
+
anchorElement?: HTMLElement | null;
|
|
545
|
+
/** Per-instance dismiss configuration */
|
|
546
|
+
dismissPolicy: NgpDismissPolicy;
|
|
547
|
+
/** Optional subject that receives pointer events that occur outside the overlay */
|
|
548
|
+
outsidePointerEvents$?: Subject<MouseEvent>;
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Minimal overlay reference needed by the registry.
|
|
552
|
+
* This avoids a circular dependency with NgpOverlay.
|
|
553
|
+
* @internal
|
|
554
|
+
*/
|
|
555
|
+
interface NgpOverlayRef {
|
|
556
|
+
hide(options?: {
|
|
557
|
+
immediate?: boolean;
|
|
558
|
+
origin?: FocusOrigin;
|
|
559
|
+
}): void;
|
|
560
|
+
hideImmediate(): void;
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Singleton registry that tracks all visible overlays in open order and
|
|
564
|
+
* provides centralized dismiss routing (outside-click and escape-key).
|
|
565
|
+
*
|
|
566
|
+
* Document listeners are attached when the first overlay registers and
|
|
567
|
+
* detached when the last deregisters, avoiding permanent global listeners.
|
|
568
|
+
* @internal
|
|
569
|
+
*/
|
|
570
|
+
declare class NgpOverlayRegistry {
|
|
571
|
+
private readonly document;
|
|
572
|
+
private readonly ngZone;
|
|
573
|
+
/** Ordered list of visible overlay entries (oldest first, newest/topmost last) */
|
|
574
|
+
private readonly entries;
|
|
575
|
+
/** Set of overlay IDs currently evaluating an async dismiss guard */
|
|
576
|
+
private readonly pendingGuardIds;
|
|
577
|
+
/** Cleanup functions for the centralized document listeners */
|
|
578
|
+
private removeOutsideClickListener?;
|
|
579
|
+
private removeEscapeKeyListener?;
|
|
580
|
+
private removeOutsidePointerListeners?;
|
|
581
|
+
/** Tracks the pointerdown target for CDK-compatible outside pointer event dispatch */
|
|
582
|
+
private pointerDownTarget;
|
|
583
|
+
/**
|
|
584
|
+
* Register an overlay as visible. The entry is appended to the end of the list
|
|
585
|
+
* (making it the topmost overlay). Attaches document listeners if this is the
|
|
586
|
+
* first entry.
|
|
587
|
+
*/
|
|
588
|
+
register(entry: NgpOverlayEntry): void;
|
|
589
|
+
/**
|
|
590
|
+
* Remove an overlay from the registry.
|
|
591
|
+
* Detaches document listeners if no entries remain.
|
|
592
|
+
*/
|
|
593
|
+
deregister(id: string): void;
|
|
594
|
+
/**
|
|
595
|
+
* Close all descendants of the given overlay.
|
|
596
|
+
* Called by NgpOverlay when it hides to cascade the close to children.
|
|
597
|
+
*/
|
|
598
|
+
closeDescendants(id: string): void;
|
|
599
|
+
/**
|
|
600
|
+
* Get all registered entries.
|
|
601
|
+
*/
|
|
602
|
+
getEntries(): readonly NgpOverlayEntry[];
|
|
603
|
+
/**
|
|
604
|
+
* Get the topmost (most recently opened) overlay entry, or null if none.
|
|
605
|
+
*/
|
|
606
|
+
getTopmost(): NgpOverlayEntry | null;
|
|
607
|
+
/**
|
|
608
|
+
* Find the overlay whose elements contain the given DOM element.
|
|
609
|
+
* Returns the ID of the most recently opened (topmost) containing overlay, or null.
|
|
610
|
+
*/
|
|
611
|
+
findContainingOverlay(element: HTMLElement): string | null;
|
|
612
|
+
/**
|
|
613
|
+
* Check whether overlay `ancestorId` is an ancestor of overlay `descendantId`
|
|
614
|
+
* by walking the parentId chain.
|
|
615
|
+
*/
|
|
616
|
+
isAncestorOf(ancestorId: string, descendantId: string): boolean;
|
|
617
|
+
/**
|
|
618
|
+
* Get all descendants of the given overlay (children, grandchildren, etc.)
|
|
619
|
+
* by walking parentId chains of all entries.
|
|
620
|
+
*/
|
|
621
|
+
getDescendants(id: string): NgpOverlayEntry[];
|
|
622
|
+
/**
|
|
623
|
+
* Attach centralized document listeners for outside-click and escape-key.
|
|
624
|
+
* Runs outside Angular zone to avoid unnecessary change detection on every
|
|
625
|
+
* mouse/keyboard event.
|
|
626
|
+
*/
|
|
627
|
+
private attachListeners;
|
|
628
|
+
/**
|
|
629
|
+
* Detach centralized document listeners.
|
|
630
|
+
*/
|
|
631
|
+
private detachListeners;
|
|
632
|
+
/**
|
|
633
|
+
* Outside-click dismiss: only the topmost overlay responds.
|
|
634
|
+
*/
|
|
635
|
+
private handleOutsideClick;
|
|
636
|
+
/**
|
|
637
|
+
* Escape-key dismiss: only the topmost overlay responds.
|
|
638
|
+
*/
|
|
639
|
+
private handleEscapeKey;
|
|
640
|
+
/**
|
|
641
|
+
* CDK-compatible outside pointer event dispatch.
|
|
642
|
+
* Iterates overlays from topmost to oldest (like CDK's OverlayOutsideClickDispatcher).
|
|
643
|
+
* For each overlay with an outsidePointerEvents$ subject, emits the event if the
|
|
644
|
+
* click was outside its elements. Stops iterating when an overlay contains the click.
|
|
645
|
+
*/
|
|
646
|
+
private handleOutsidePointerEvent;
|
|
647
|
+
/**
|
|
648
|
+
* Get the composed event target, piercing shadow DOM boundaries.
|
|
649
|
+
*/
|
|
650
|
+
private getComposedTarget;
|
|
651
|
+
/**
|
|
652
|
+
* Check whether any of the given elements contain the target, piercing shadow DOM.
|
|
653
|
+
*/
|
|
654
|
+
private containsElement;
|
|
655
|
+
/**
|
|
656
|
+
* Evaluate a dismiss guard and call the dismiss function if allowed.
|
|
657
|
+
* Supports boolean values and sync/async guard functions.
|
|
658
|
+
*/
|
|
659
|
+
private evaluateGuardAndDismiss;
|
|
660
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgpOverlayRegistry, never>;
|
|
661
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NgpOverlayRegistry>;
|
|
662
|
+
}
|
|
663
|
+
|
|
509
664
|
/**
|
|
510
665
|
* The state interface for the overlay arrow.
|
|
511
666
|
*/
|
|
@@ -759,5 +914,5 @@ declare class NoopScrollStrategy implements ScrollStrategy {
|
|
|
759
914
|
disable(): void;
|
|
760
915
|
}
|
|
761
916
|
|
|
762
|
-
export { BlockScrollStrategy, CloseScrollStrategy, NgpComponentPortal, NgpOverlay, NgpOverlayArrowStateToken, NgpOverlayCooldownManager, NgpPortal, NgpTemplatePortal, NoopScrollStrategy, coerceFlip, coerceOffset, coerceShift, createOverlay, createPortal, injectOverlay, injectOverlayArrowState, injectOverlayContext, ngpOverlayArrow, provideOverlayArrowState, provideOverlayContext };
|
|
763
|
-
export type { NgpFlip, NgpFlipInput, NgpFlipOptions, NgpOffset, NgpOffsetInput, NgpOffsetOptions, NgpOverlayArrowProps, NgpOverlayArrowState, NgpOverlayConfig, NgpOverlayContent, NgpOverlayTemplateContext, NgpPosition, NgpShift, NgpShiftInput, NgpShiftOptions, ScrollStrategy };
|
|
917
|
+
export { BlockScrollStrategy, CloseScrollStrategy, NgpComponentPortal, NgpOverlay, NgpOverlayArrowStateToken, NgpOverlayCooldownManager, NgpOverlayRegistry, NgpPortal, NgpTemplatePortal, NoopScrollStrategy, coerceFlip, coerceOffset, coerceShift, createOverlay, createPortal, injectOverlay, injectOverlayArrowState, injectOverlayContext, ngpOverlayArrow, provideOverlayArrowState, provideOverlayContext };
|
|
918
|
+
export type { NgpDismissGuard, NgpDismissPolicy, NgpFlip, NgpFlipInput, NgpFlipOptions, NgpOffset, NgpOffsetInput, NgpOffsetOptions, NgpOverlayArrowProps, NgpOverlayArrowState, NgpOverlayConfig, NgpOverlayContent, NgpOverlayEntry, NgpOverlayRef, NgpOverlayTemplateContext, NgpPosition, NgpShift, NgpShiftInput, NgpShiftOptions, ScrollStrategy };
|