import { default as React } from 'react'; import { ModalInstance, ModalStackContextValue } from './types'; /** * Inertia Page object structure for modal context */ export interface ModalPageObject { component: string; props: Record; url: string; version?: string; scrollRegions?: Array<{ top: number; left: number; }>; rememberedState?: Record; clearHistory?: boolean; encryptHistory?: boolean; } /** * Hook to check if we're inside a modal context * @returns true if component is rendered inside a modal */ export declare function useIsInModal(): boolean; /** * Hook to get the modal's page object * Returns null if not in a modal context */ export declare function useModalPageContext(): ModalPageObject | null; /** * Provider component that wraps modal content with page context * This should be used by modal renderers to provide page data to modal content */ export interface ModalPageProviderProps { component: string; props: Record; url: string; children: React.ReactNode; } export declare const ModalPageProvider: React.FC; export type { ModalConfig, ModalInstance, ModalStackContextValue, } from './types'; /** * Hook to access the modal stack * * Must be used within a ModalStackProvider. * * @throws Error if used outside ModalStackProvider * @returns The modal stack context value * * @example * ```tsx * function MyComponent() { * const { pushModal, modals } = useModalStack(); * * const openModal = () => { * pushModal({ * component: UserProfile, * props: { userId: 1 }, * config: { size: 'lg' }, * baseUrl: '/users' * }); * }; * * return ( *
* *

Active modals: {modals.length}

*
* ); * } * ``` */ export declare const useModalStack: () => ModalStackContextValue; /** * Hook to access the current modal instance * * Returns the topmost modal in the stack (the currently focused modal). * Returns null if no modals are open. * * @returns The current modal instance or null * * @example * ```tsx * function ModalContent() { * const modal = useModal(); * * if (!modal) { * return
No modal open
; * } * * return ( *
*

Modal {modal.id}

*

Index in stack: {modal.index}

*
* ); * } * ``` */ export declare const useModal: () => ModalInstance | null; /** * Function type for resolving component names to React components */ export type ResolveComponentFn = (name: string) => Promise>; /** * Props for ModalStackProvider */ export interface ModalStackProviderProps { /** * Child components that can access the modal stack */ children: React.ReactNode; /** * Optional callback when modal stack changes */ onStackChange?: (modals: ModalInstance[]) => void; /** * Function to resolve component names to React components. * When provided, enables ModalLink to prefetch both data AND component modules * for instant modal opening. * * @example * ```tsx * const pages = import.meta.glob('./pages/**\/*.tsx'); * const resolveComponent = (name: string) => * pages[`./pages/${name}.tsx`]().then((m: any) => m.default); * * * * * ``` */ resolveComponent?: ResolveComponentFn; } /** * Provider for the modal stack * * Wraps your application to provide modal stack management to all child components. * Must be placed high in your component tree, typically near the root. * * @param props - Provider props * * @example * ```tsx * import { ModalStackProvider } from './modalStack'; * * function App() { * return ( * * * * * * ); * } * ``` * * @example With stack change callback * ```tsx * function App() { * const handleStackChange = (modals) => { * console.log('Modal stack updated:', modals.length, 'modals'); * }; * * return ( * * * * ); * } * ``` */ export declare const ModalStackProvider: React.FC; export default ModalStackProvider; //# sourceMappingURL=modalStack.d.ts.map