import { S as DialogStyle, a as DialogTheme, b as DialogShowOptions, d as BaseChoiceOptions, f as BaseConfirmOptions, g as DialogContainerOptions, m as BasePromptOptions, p as BaseDialogActions, s as themes, u as BaseAlertOptions, v as DialogId, x as DialogSize } from "./themes-CS3n3Ng8.mjs"; import { a as PromptContext, i as DialogState, n as ChoiceContext, r as ConfirmContext, t as AlertContext } from "./index-D_zQGKOE.mjs"; import { KeyEvent } from "@opentui/core"; import { ReactNode } from "react"; //#region src/react.d.ts /** * Content factory that returns React elements. * Must be a function to ensure consistent behavior with Solid adapter * and prevent timing issues with JSX evaluation. */ type ContentFactory = () => ReactNode; interface ShowOptions extends Omit { /** Must be a function returning JSX: `() => ` */ content: ContentFactory; } /** Content factory for prompt dialogs. */ type PromptContent = (ctx: PromptContext) => ReactNode; /** Content factory for confirm dialogs. */ type ConfirmContent = (ctx: ConfirmContext) => ReactNode; /** Content factory for alert dialogs. */ type AlertContent = (ctx: AlertContext) => ReactNode; /** Content factory for choice dialogs. */ type ChoiceContent = (ctx: ChoiceContext) => ReactNode; /** * Options for a generic prompt dialog. * @template T The type of value the prompt resolves to. */ interface PromptOptions extends BasePromptOptions> {} /** * Options for a confirm dialog. */ interface ConfirmOptions extends BaseConfirmOptions {} /** * Options for an alert dialog. */ interface AlertOptions extends BaseAlertOptions {} /** * Options for a choice dialog. * @template K The type of keys for the available choices. */ interface ChoiceOptions extends BaseChoiceOptions, K> {} /** * Dialog actions for showing, closing, and managing dialogs. * Extends BaseDialogActions with async prompt methods. */ interface DialogActions extends BaseDialogActions { /** Show a generic prompt dialog and wait for a response. */ prompt: (options: PromptOptions) => Promise; /** Show a confirmation dialog and wait for the user to confirm or cancel. */ confirm: (options: ConfirmOptions) => Promise; /** Show an alert dialog and wait for the user to dismiss it. */ alert: (options: AlertOptions) => Promise; /** Show a choice dialog and wait for the user to select an option. */ choice: (options: ChoiceOptions) => Promise; } /** * Access dialog actions within a DialogProvider. * * For reactive state, use `useDialogState()` instead. * * @example * ```tsx * const dialog = useDialog(); * * // Show a dialog (content must be a function) * dialog.show({ content: () => Hello }); * * // Close the top dialog * dialog.close(); * * // Close a specific dialog * dialog.close(dialogId); * * // Close all dialogs * dialog.closeAll(); * ``` */ declare function useDialog(): DialogActions; /** * Subscribe to reactive dialog state with a selector. * * Only re-renders when the selected value changes (using reference equality). * * @example * ```tsx * // Subscribe to specific state * const isOpen = useDialogState(s => s.isOpen); * const count = useDialogState(s => s.count); * const topDialog = useDialogState(s => s.topDialog); * const dialogs = useDialogState(s => s.dialogs); * * // Use in your component * if (isOpen) { * console.log(`${count} dialog(s) open`); * } * ``` */ declare function useDialogState(selector: (state: DialogState) => T): T; /** * A keyboard hook for dialog content that only fires when the dialog is topmost. * * This prevents keyboard events from affecting stacked dialogs that are not focused. * Use this instead of `useKeyboard` inside dialog content components. * * @param handler - Keyboard event handler (only called when dialog is topmost) * @param dialogId - The dialog's ID from context (e.g., `ctx.dialogId`) * * @example * ```tsx * function DeleteConfirmDialog({ resolve, dialogId }: ConfirmContext) { * useDialogKeyboard((key) => { * if (key.name === "return") resolve(true); * if (key.name === "escape") resolve(false); * }, dialogId); * * return Press Enter to confirm; * } * ``` */ declare function useDialogKeyboard(handler: (key: KeyEvent) => void | Promise, dialogId: DialogId): void; interface DialogProviderProps extends DialogContainerOptions { children: ReactNode; } /** * Provides dialog functionality to children via useDialog() and useDialogState() hooks. * * @example * ```tsx * * * * ``` */ declare function DialogProvider(props: DialogProviderProps): ReactNode; //#endregion export { type AlertContext, AlertOptions, type ChoiceContext, ChoiceOptions, type ConfirmContext, ConfirmOptions, ContentFactory, DialogActions, type DialogContainerOptions, type DialogId, DialogProvider, DialogProviderProps, type DialogSize, type DialogState, type DialogStyle, type DialogTheme, type PromptContext, PromptOptions, ShowOptions, themes, useDialog, useDialogKeyboard, useDialogState }; //# sourceMappingURL=react.d.mts.map