/** * dismissable-layer - a global stack of dismissable overlays (dropdowns, * popovers, dialogs). Escape and outside-pointer dismiss only the TOP layer, so * a menu opened inside a dialog closes the menu first and the dialog second - * the ordering users expect from nested overlays. One set of document listeners * is shared by every layer instead of each component wiring its own. */ type Reason = 'escape' | 'outside'; /** One element, several elements, or a getter of either. A pointerdown counts * as "inside" when it lands in ANY of them (e.g. a popover's panel AND its * trigger, so clicking the trigger doesn't immediately re-dismiss). */ export type DismissTarget = HTMLElement | null | ReadonlyArray; export type DismissableOptions = { /** The panel element(s); a pointerdown outside ALL of them dismisses the layer. * Pass multiple (e.g. panel + trigger) so clicking the trigger doesn't * immediately re-dismiss what it just opened. */ element: () => DismissTarget; onDismiss: (reason: Reason) => void; /** Dismiss on Escape when topmost. Default true. */ closeOnEscape?: boolean; /** Dismiss on outside pointerdown when topmost. Default true. */ closeOnOutside?: boolean; }; export type DismissableLayer = { activate: () => void; release: () => void; }; /** Register a dismissable layer. Inert until `activate()`. */ export declare function createDismissableLayer(options: DismissableOptions): DismissableLayer; /** Test/introspection helper: current number of active layers. */ export declare function dismissableDepth(): number; /** * Close-on-scroll for popovers that are position:fixed and anchored by a * one-time measurement taken when they open. Scrolling an ancestor slides the * anchor out from under them, so they have to close - but scrolling INSIDE * them (a long menu, a facet list) must not, which is what a bare capture-phase * window listener gets wrong: inner scroll containers don't bubble, so the * capture listener sees them and dismisses the panel the user is scrolling. * * Returns the unsubscribe function. */ export declare function onScrollOutside(element: () => DismissTarget, onOutside: () => void): () => void; export {};