import type { CSSProperties, ComponentPropsWithRef, ComponentPropsWithoutRef, ReactElement, ReactNode } from "react"; import type { Dialog as BaseDialog } from "../unstyledPrimitives"; import type { ButtonProps } from "../Button"; type BaseUIPropsToExclude = "render" | "className" | "style" | "ref" | "children"; /** Width of the dialog; `fullScreen` fills the viewport. */ export type DialogSize = "small" | "base" | "large" | "fullScreen"; /** `alertdialog` blocks outside/backdrop dismissal; `dialog` allows it. */ export type DialogType = "dialog" | "alertdialog"; /** * Shared `className`/`style` contract for the composable Dialog parts. */ export interface DialogBaseProps { /** Class name applied to the part's root element. */ readonly className?: string; /** Inline styles applied to the part's root element. */ readonly style?: CSSProperties; } export type DialogHandle = BaseDialog.Handle; export interface DialogRootProps extends Pick, "open" | "onOpenChange" | "handle" | "triggerId" | "defaultTriggerId" | "onOpenChangeComplete"> { /** * Called when the user asks to close (escape, backdrop, dismiss button). * Receives BaseUI's change-event details (reason + originating event), * matching how BaseUI types its open/close callbacks. */ readonly onRequestClose?: (eventDetails: BaseDialog.Root.ChangeEventDetails) => void; /** * Width of the dialog. * On mobile when this is set to "fullScreen" the bottom sheet will be full screen (100% height). * @default "base" */ readonly size?: DialogSize; /** * Type of the dialog. An `alertdialog` requires the user to choose an action * before it can be closed (no outside/backdrop dismissal). * @default "dialog" */ readonly type?: DialogType; /** * @see {@link https://base-ui.com/react/components/dialog#DialogPopup-finalFocus} * */ readonly finalFocus?: BaseDialog.Popup.Props["finalFocus"]; /** * The content of the dialog. This can be a regular React node or a render function that receives the payload of the active trigger. */ readonly children?: ReactNode | ((state: { payload: Payload | undefined; }) => ReactNode); } /** Props BaseUI passes to a `Dialog.Trigger` `render` callback. */ export type DialogTriggerRenderProps = ComponentPropsWithRef<"button">; /** A custom trigger element, or a function that renders one from BaseUI props. */ export type DialogTriggerRender = ReactElement | ((props: DialogTriggerRenderProps) => ReactElement); interface DialogTriggerSharedProps extends DialogBaseProps, Omit { /** * Links a detached trigger to a `Dialog` with the matching `handle`, when the * trigger can't be nested inside the `Dialog`. */ readonly handle?: DialogHandle; /** * Data passed to the dialog when this trigger opens it (used with `handle`). */ readonly payload?: Payload; } interface DialogTriggerDefaultProps extends DialogTriggerSharedProps { /** Trigger content; an Atlantis `