import { RequestPayload, HttpResponse, Method } from '@inertiajs/core'; import { ComponentType, ReactNode } from 'react'; import { ModalTypeConfig } from './config'; export type HttpMethod = Method; export interface ModalResponseData { id?: string; component: string; props: Record; url?: string; version?: string; meta?: { deferredProps?: Record; }; baseUrl?: string; } export type ModalConfig = Partial; export interface ReloadOptions { only?: string[]; except?: string[]; method?: HttpMethod; data?: Record; headers?: Record; onStart?: () => void; onSuccess?: (response: HttpResponse) => void; onError?: (error: unknown) => void; onFinish?: () => void; } export interface VisitOptions { method?: HttpMethod; data?: RequestPayload; headers?: Record; config?: ModalConfig; onClose?: () => void; onAfterLeave?: () => void; queryStringArrayFormat?: 'brackets' | 'indices'; navigate?: boolean; onStart?: () => void; onSuccess?: (response?: HttpResponse) => void; onError?: (...args: unknown[]) => void; listeners?: Record void>; props?: Record; } export type PrefetchOption = boolean | 'hover' | 'click' | 'mount' | Array<'hover' | 'click' | 'mount'>; export interface PrefetchOptions { method?: HttpMethod; data?: RequestPayload; headers?: Record; queryStringArrayFormat?: 'brackets' | 'indices'; cacheFor?: number; onPrefetching?: () => void; onPrefetched?: () => void; } export type EventCallback = (...args: unknown[]) => void; export type ComponentResolver = (name: string) => Promise; export interface Modal { id: string; isOpen: boolean; shouldRender: boolean; listeners: Record; component: ComponentType | null; props: Record; response: ModalResponseData; config: ModalConfig; onCloseCallback: (() => void) | null; afterLeaveCallback: (() => void) | null; index: number; onTopOfStack: boolean; name?: string; show: () => void; close: () => void; setOpen: (open: boolean) => void; afterLeave: () => void; on: (event: string, callback: EventCallback) => void; off: (event: string, callback?: EventCallback) => void; emit: (event: string, ...args: unknown[]) => void; registerEventListenersFromProps: (props: Record) => () => void; reload: (options?: ReloadOptions) => void; updateProps: (props: Record) => void; getParentModal: () => Modal | null; getChildModal: () => Modal | null; } export interface LocalModal { name: string; callback: (modal: Modal) => void; } export interface ModalStackContextValue { stack: Modal[]; localModals: Record; push: (component: ComponentType | null, response: ModalResponseData, config?: ModalConfig | null, onClose?: (() => void) | null, afterLeave?: (() => void) | null) => Modal; pushFromResponseData: (responseData: ModalResponseData, config?: ModalConfig, onClose?: (() => void) | null, onAfterLeave?: (() => void) | null) => Promise; length: () => number; closeAll: (force?: boolean) => void; reset: () => void; visit: (href: string, method: HttpMethod, payload?: RequestPayload, headers?: Record, config?: ModalConfig, onClose?: (() => void) | null, onAfterLeave?: (() => void) | null, queryStringArrayFormat?: 'brackets' | 'indices', useBrowserHistory?: boolean, onStart?: (() => void) | null, onSuccess?: ((response?: HttpResponse) => void) | null, onError?: ((...args: unknown[]) => void) | null) => Promise; visitModal: (url: string, options?: VisitOptions) => Promise; registerLocalModal: (name: string, callback: (modal: Modal) => void) => void; removeLocalModal: (name: string) => void; } export interface PageProps { initialPage?: { version?: string; }; } export interface ModalRootProps { children?: ReactNode; } export interface ModalRendererProps { index: number; }