import * as i0 from '@angular/core'; import { OnDestroy, ClassProvider, Signal, EffectCleanupRegisterFn, CreateEffectOptions, EffectRef, ElementRef, Injector, ViewContainerRef, TemplateRef, Provider } from '@angular/core'; import { Observable } from 'rxjs'; declare class NgpExitAnimation implements OnDestroy { /** The animation manager. */ private readonly animationManager; /** Access the element reference. */ protected readonly elementRef: i0.ElementRef; /** Exist animation reference. */ protected readonly ref: NgpExitAnimationRef; constructor(); ngOnDestroy(): void; /** Mark the element as exiting. */ exit(): Promise; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵdir: i0.ɵɵDirectiveDeclaration; } interface NgpExitAnimationOptions { /** The element to animate. */ element: HTMLElement; /** If true, skip requestAnimationFrame delay and set enter state immediately. */ immediate?: boolean; } interface NgpExitAnimationRef { /** Mark the element as exiting and wait for the animation to finish. */ exit: () => Promise; /** Cancel an in-progress exit animation and transition back to enter state. */ cancel: () => void; /** End an in-progress exit animation now, leaving the element on its way out. */ finish: () => void; } declare function setupExitAnimation({ element, immediate, }: NgpExitAnimationOptions): NgpExitAnimationRef; declare class NgpExitAnimationManager { /** Store the instances of the exit animation directive. */ private readonly instances; /** Add an instance to the manager. */ add(instance: NgpExitAnimation): void; /** Remove an instance from the manager. */ remove(instance: NgpExitAnimation): void; /** Exit all instances. */ exit(): Promise; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare function provideExitAnimationManager(): ClassProvider; declare function injectExitAnimationManager(): NgpExitAnimationManager; /** * Fallback timeout (ms) after which an idle hover bridge closes the overlay. * Shared so tooltip, menu and submenu hover-intent behaviour stay in sync. */ declare const HOVER_BRIDGE_TIMEOUT_MS = 150; /** * Pointer movement below this magnitude (px) on the intent axis is treated as * jitter, not a reversal, so a tiny backward twitch doesn't collapse the bridge. */ declare const HOVER_BRIDGE_DIRECTION_TOLERANCE_PX = 2; /** * Idle timeout (ms) applied while the pointer is resting over one of the * trigger's siblings instead of the open gap. The corridor holds the sibling * container inert for its whole lifetime, so a pointer that has stopped there * is waiting on the corridor to end, and gets a much shorter benefit of the * doubt than the gap does. Movement still resets the timer either way - only a * pointer that has genuinely settled over a sibling closes early. */ declare const HOVER_BRIDGE_SIBLING_TIMEOUT_MS = 80; interface HoverBridgePoint { x: number; y: number; } /** * The dominant axis and sign pointing from the trigger toward the target. Used * to reject pointer movement heading away from the target while inside the corridor. */ interface HoverBridgeDirection { axis: 'x' | 'y'; sign: 1 | -1; } interface CreateHoverBridgePolygonOptions { triggerRect: DOMRect | null; targetRect: DOMRect | null; exitPoint: HoverBridgePoint; corridorHalfSize?: number; } /** * Computes the dominant axis and sign from the trigger toward the target - i.e. * which way the pointer must travel to reach the panel. Returns null if either * rect is missing. */ declare function getHoverBridgeDirection(triggerRect: DOMRect | null, targetRect: DOMRect | null): HoverBridgeDirection | null; /** * Builds a pointer grace polygon between the trigger exit point and the target overlay. * The polygon is intentionally directional so moving away from the target exits quickly. */ declare function createHoverBridgePolygon({ triggerRect, targetRect, exitPoint, corridorHalfSize, }: CreateHoverBridgePolygonOptions): HoverBridgePoint[] | null; /** * Returns true when the point lies inside the provided polygon. */ declare function isPointInHoverBridgePolygon(point: HoverBridgePoint, polygon: HoverBridgePoint[]): boolean; interface HoverTransitTracker { /** @internal */ setTransitSource(trigger: HTMLElement): void; /** @internal */ clearTransitSource(trigger: HTMLElement): void; /** @internal */ isTransitBlocked(trigger: HTMLElement): boolean; } /** * Tracks which sibling currently owns a hover corridor so the others can * decline an enter the browser had already resolved before the corridor's * pointer-events suppression applied. Lives on whichever element holds the * siblings - a trigger group for root triggers, the panel itself for submenus. */ declare function createHoverTransitTracker(): HoverTransitTracker; interface HoverTransitDeclineOptions { /** Whether a sibling's corridor currently owns the transit. */ isBlocked: () => boolean; /** Whether the pointer is still over this trigger when the retry fires. */ isPointerOverTrigger: Signal; /** Open this trigger's overlay. */ show: () => void; } /** * Builds the hover-decline check a trigger runs before opening. Call it from * the state factory; the returned function goes in the pointerenter handler and * reports whether the hover was declined. * * A hover that arrives while a sibling's corridor is in flight is declined and * retried once that corridor has had time to end - the pointer may have * genuinely landed here rather than passing through, and a declined enter is * never re-delivered on its own. */ declare function createHoverTransitDecline({ isBlocked, isPointerOverTrigger, show, }: HoverTransitDeclineOptions): () => boolean; interface HoverBridgeOptions { /** Whether the pointer is currently over the trigger or the panel (the "safe" area). */ isPointerInAnchor: () => boolean; /** Close the overlay - called when the pointer leaves the corridor or the idle timer fires. */ close: () => void; /** * Require the pointer to keep heading toward the panel. When true, reversing * away along the corridor's dominant axis closes the overlay (menu/submenu). * Tooltips leave this off. Defaults to false. */ requireForwardMovement?: boolean; /** * Reset the idle-fallback timer on valid in-corridor movement, so it only * fires after the pointer genuinely stops. When false the timer is a fixed cap * from the moment the corridor is built (tooltip's original semantics). * Defaults to true. */ resetFallbackOnMove?: boolean; /** Idle-fallback timeout in ms. Defaults to HOVER_BRIDGE_TIMEOUT_MS. */ timeoutMs?: number; /** * Element containing this trigger's siblings. While the bridge is active, * pointer-events are suppressed on it so a sibling can't receive its own * pointerenter mid-transit toward the open panel - the browser's hit-testing * withholds the event entirely rather than the sibling needing to know * anything about this bridge. The trigger itself is exempted. Omit for * triggers with no siblings to protect. */ siblingContainer?: () => HTMLElement | null; /** * Notified when sibling suppression engages or releases. Siblings must ignore * their own hover while it is active as well: the browser resolves a * movement's hit-test before dispatching its boundary events, so a fast * sample that jumps straight onto a sibling still delivers that sibling an * enter, whatever pointer-events says by the time it arrives. */ onSuppressionChange?: (active: boolean) => void; } interface HoverBridgeTrackOptions { triggerRect: DOMRect | null; targetRect: DOMRect | null; exitPoint: HoverBridgePoint; } interface HoverBridgeController { /** The active corridor polygon, or null when no bridge is in progress. */ readonly polygon: Signal; /** Whether a corridor is currently active. */ isActive(): boolean; /** * Build a corridor from the exit point toward the panel and start tracking the * pointer. Returns false (and does nothing) when a polygon can't be built, so * the caller can apply its own fallback. */ track(options: HoverBridgeTrackOptions): boolean; /** Tear down the corridor and its global listener/timer. */ clear(): void; } /** * Shared safe-polygon hover-intent state machine used by the menu, submenu and * tooltip triggers. While the pointer travels inside the corridor toward the * panel the overlay stays open; it closes when the pointer leaves the corridor, * reverses away (when requireForwardMovement is set) or idles past the timeout. */ declare function createHoverBridge({ isPointerInAnchor, close, requireForwardMovement, resetFallbackOnMove, timeoutMs, siblingContainer, onSuppressionChange, }: HoverBridgeOptions): HoverBridgeController; /** * This implementation is heavily inspired by the great work on ngextension! * https://github.com/ngxtension/ngxtension-platform/blob/main/libs/ngxtension/explicit-effect/src/explicit-effect.ts */ /** * We want to have the Tuple in order to use the types in the function signature */ type ExplicitEffectValues = { [K in keyof T]: () => T[K]; }; /** * This explicit effect function will take the dependencies and the function to run when the dependencies change. * @param deps - The dependencies that the effect will run on * @param fn - The function to run when the dependencies change * @param options - The options for the effect with the addition of defer (it allows the computation to run on first change, not immediately) */ declare function explicitEffect(deps: readonly [...ExplicitEffectValues], fn: (deps: Params, onCleanup: EffectCleanupRegisterFn) => void, options?: CreateEffectOptions): EffectRef; /** * A utility service for injecting styles into the document. * Angular doesn't allow directives to specify styles, only components. * As we ship directives, occasionally we need to associate styles with them. * This service allows us to programmatically inject styles into the document. */ declare class StyleInjector { /** * Access the CSP nonce */ private readonly cspNonce; /** * Access the document. */ private readonly document; /** * Detect the platform. */ private readonly platformId; /** * Store the map of style elements with their unique identifiers. */ private readonly styleElements; constructor(); /** * Inject a style into the document. * @param id The unique identifier for the style. * @param style The style to inject. */ add(id: string, style: string): void; /** * Remove a style from the document. * @param id The unique identifier for the style. */ remove(id: string): void; /** * Collect any styles that were rendered by the server. */ private collectServerStyles; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } declare function injectStyleInjector(): StyleInjector; /** * Whenever an element is removed from the DOM, we call the callback. * @param element The element to watch for removal. * @param callback The callback to call when the element is removed. */ declare function onDomRemoval(element: HTMLElement, callback: () => void): void; /** * This function sorts DOM elements based on their position in the document. * However items can also explitly define their index in which case it will be used * to sort the elements first. This allows for both natural DOM order sorting as well * as custom order for cases like virtual scrolling where items might be rendered * out of order. */ declare function domSort(items: T[], getElement: (item: T) => HTMLElement, getIndex?: (item: T) => number | undefined): T[]; /** * A simple utility function to inject an element reference with less boilerplate. * @returns The element reference. */ declare function injectElementRef(): ElementRef; type NgpEscapeKeyClaim = (event: KeyboardEvent) => boolean; /** * Escape keys that a control will handle itself, so overlays leave them alone. * Overlays listen in the capture phase, before the control sees the key, so they * ask here rather than relying on the control to stop the event. */ declare class NgpEscapeKeyClaims { private readonly claims; add(claim: NgpEscapeKeyClaim): () => void; isClaimed(event: KeyboardEvent): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } /** * Claim the Escape keys `claim` returns true for, for the lifetime of the current injection context. */ declare function claimEscapeKey(claim: NgpEscapeKeyClaim): void; interface NgpMutationObserverOptions { /** * Whether to listen for events. */ disabled?: Signal; /** * The injector to use when called from outside of the injector context. */ injector?: Injector; /** * Whether the childList should be observed. */ childList?: boolean; /** * Whether the subtree should be observed. */ subtree?: boolean; /** * Whether the attributes should be observed. */ attributes?: boolean; /** * Whether the characterData should be observed. */ characterData?: boolean; /** * Whether the attributeFilter should be observed. */ attributeFilter?: string[]; } /** * This function sets up a mutation observer to listen for changes in the DOM. * It will stop listening when the `disabled` signal is true, and re-enable when it is false. * @param options - Options for the mutation observer */ declare function fromMutationObserver(element: HTMLElement, { childList, subtree, attributes, characterData, disabled, injector, }?: NgpMutationObserverOptions): Observable; /** * Options for {@link renderList}. */ interface NgpRenderListOptions { /** The view container the items are rendered into. */ readonly viewContainer: ViewContainerRef; /** The template instantiated once per item. */ readonly template: TemplateRef; /** * A reactive source of items. Read inside an effect, so the list re-renders * whenever any signal it touches changes. */ readonly items: () => readonly T[]; /** * Build the template context for an item. Defaults to `{ $implicit: item }`. */ readonly context?: (item: T, index: number) => object; /** * Providers made available to each rendered view's injector (e.g. per-item * injection tokens). */ readonly providers?: (item: T, index: number) => Provider[]; /** * The per-item state function, invoked once per rendered element inside an * injection context scoped to that item. The rendered element is provided as * `ElementRef`, so the function can call `injectElementRef()` like any other * `-state.ts` factory. Anything it registers (`dataBinding`, `listener`, * effects, `inject(DestroyRef).onDestroy`, ...) is cleaned up automatically * when the item is removed or the list is destroyed. * * If it returns a value (e.g. the state from a `createPrimitive` factory) that * value becomes the template context's `$implicit`, so `let item` exposes it. */ readonly setup?: (item: T, index: number) => unknown; /** The injector to bind the render effect to. Defaults to the current one. */ readonly injector?: Injector; } /** * Render a reactive list of items from a template into a view container, * managing the embedded-view lifecycle and per-item state wiring. * * The list re-renders whenever the reactive `items` source changes. Each item * runs its `setup` in its own injector, so effects registered there are torn * down when the item is removed or the host is destroyed - callers never manage * view refs or cleanup by hand. * * Must be called from an injection context (e.g. a directive constructor). */ declare function renderList(options: NgpRenderListOptions): void; interface NgpResizeObserverOptions { /** * Whether to listen for events. */ disabled?: Signal; /** * The injector to use when called from outside of the injector context. */ injector?: Injector; } /** * A simple helper function to create a resize observer as an RxJS Observable. * @param element The element to observe for resize events. * @returns The resize event as an Observable. */ declare function fromResizeEvent(element: HTMLElement, { disabled, injector }?: NgpResizeObserverOptions): Observable; /** * A utility function to observe any element for resize events and return the dimensions as a signal. */ declare function observeResize(elementFn: () => HTMLElement | undefined): Signal; interface Dimensions { width: number; height: number; } /** * A simple utility to get the dimensions of an element as a signal. */ declare function injectDimensions(): Signal; declare function scrollIntoViewIfNeeded(element: HTMLElement): void; export { HOVER_BRIDGE_DIRECTION_TOLERANCE_PX, HOVER_BRIDGE_SIBLING_TIMEOUT_MS, HOVER_BRIDGE_TIMEOUT_MS, NgpEscapeKeyClaims, NgpExitAnimation, NgpExitAnimationManager, StyleInjector, claimEscapeKey, createHoverBridge, createHoverBridgePolygon, createHoverTransitDecline, createHoverTransitTracker, domSort, explicitEffect, fromMutationObserver, fromResizeEvent, getHoverBridgeDirection, injectDimensions, injectElementRef, injectExitAnimationManager, injectStyleInjector, isPointInHoverBridgePolygon, observeResize, onDomRemoval, provideExitAnimationManager, renderList, scrollIntoViewIfNeeded, setupExitAnimation }; export type { Dimensions, HoverBridgeController, HoverBridgeDirection, HoverBridgeOptions, HoverBridgePoint, HoverBridgeTrackOptions, HoverTransitDeclineOptions, HoverTransitTracker, NgpEscapeKeyClaim, NgpExitAnimationRef, NgpRenderListOptions };