import type { ReactNode } from "react"; /** * The ordered stack of open **backdrop** modals, and the one shared * scrim that stands behind all of them. * * ### Why a stack at all * * A modal must know two things it cannot see for itself: whether it is * the **top** of the stack (only the top traps focus and answers * Escape / an outside press; everything under it is `inert`), and how * **deep** the stack is (the scrim shows while at least one modal is * open and hides when the last closes). An `OverlayPanel` registers on * open and unregisters on close, and reads `topId`/`depth` back. * * ### The provider is optional * * `useOverlayStack()` has a self-hosting default — `isProvided: * false`, a no-op register, `depth: 0` — so a lone `Modal` needs no * setup: it sees it is unprovided and renders its own scrim, treating * itself as the top. Only *stacking* needs `OverlayStackProvider` at * the app root, where a single shared scrim and real top-of-stack * bookkeeping replace N self-hosted scrims fighting for the same * corner. */ export type OverlayStackEntry = { id: string; onClose: () => void; }; export type OverlayStackValue = { depth: number; /** * The open ids, oldest first. A panel reads its own index out of * this to cascade its z-index above the one below it. */ orderedIds: string[]; /** * `false` in the context default. An `OverlayPanel` reads this to * decide whether to render its own scrim (unprovided) or defer to * the provider's shared one. */ isProvided: boolean; register: (entry: OverlayStackEntry) => void; /** Closes the top entry — the imperative twin of an outside press. */ requestCloseTop: () => void; topId: null | string; unregister: (id: string) => void; }; export declare const useOverlayStack: () => OverlayStackValue; export declare const OverlayStackProvider: ({ children, }: { children: ReactNode; }) => ReactNode; //# sourceMappingURL=OverlayStack.d.ts.map