/** * A layer registered on the dismiss stack. */ export interface DismissLayer { /** * Unique id of the layer, used to keep the stack free of duplicates. */ id: string; /** * Called when Escape is pressed while this layer is the topmost one. */ onEscape: (event: KeyboardEvent) => void; /** * Whether Escape should dismiss this layer. When false the key is swallowed rather than passed down. */ closeOnEscape?: boolean; } /** * Adds a layer to the dismiss stack. * * @param layer The layer to add. * @returns A function that removes the layer from the stack. */ export declare function pushDismissLayer(layer: DismissLayer): () => void; /** * Whether the given layer is the topmost one on the dismiss stack. * * @param id The id of the layer to check. */ export declare function isTopDismissLayer(id: string): boolean; /** * The options for the `useEscapeListener` hook. */ export interface UseEscapeListenerOptions { /** * Unique id of the layer, used to keep the dismiss stack free of duplicates. */ id?: string; /** * Whether the layer is currently open. The layer joins the stack only while this is true. */ open?: boolean; /** * Whether Escape should dismiss this layer. When false the key is swallowed rather than passed down. */ closeOnEscape?: boolean; /** * Called when Escape is pressed while this layer is the topmost one. */ onEscape: (event: KeyboardEvent) => void; } /** * Registers an overlay layer that closes on Escape, so nested overlays dismiss one level at a time. * * Layers share a single document listener through the dismiss stack: only the topmost open layer * reacts and the event stops there, instead of every open overlay binding its own listener and * collapsing together on a single keypress. * * @param options The options for the escape listener. * * @example * ```tsx * useEscapeListener({ * id, * open: openState, * closeOnEscape: props.closeOnEscape, * onEscape: () => close() * }); * ``` */ export declare function useEscapeListener({ id, open, closeOnEscape, onEscape }: UseEscapeListenerOptions): void;