import * as React from 'react' import { Dialog as BaseDialog } from '@base-ui/react/dialog' import { cn } from '../../internal/utils' import { type ModalContentProps, splitModalProps } from '../../internal/modal' import { buttonVariants } from '../button/button-variants' type DialogProps = React.ComponentProps const Dialog = Object.assign( function Dialog(props: DialogProps) { return }, { createHandle: BaseDialog.createHandle }, ) type DialogTriggerProps = React.ComponentProps function DialogTrigger({ className, ...props }: DialogTriggerProps) { return } type DialogContentProps = ModalContentProps< React.ComponentProps, React.ComponentProps, React.ComponentProps, React.ComponentProps > & { /** * Render the × button in the corner. * @default true */ closeButton?: boolean /** * Accessible label for the close button. * @default 'Close' */ closeLabel?: string /** * Render the dimmed, blurred backdrop behind the popup. * @default true */ backdrop?: boolean /** * Wrap the popup in a translucent glass frame. Needs `backdrop`: without one the popup * is always a plain solid card. * @default true */ frame?: boolean } function DialogContent({ className, children, closeButton = true, closeLabel = 'Close', backdrop = true, frame = true, backdropProps, viewportProps, ...props }: DialogContentProps) { // The frame is a rim of blurred page around the popup, so it only reads against the // backdrop. Without one it collapses to a plain solid card. const showFrame = frame && backdrop const { portal, popup } = splitModalProps(props) return ( {backdrop && ( )}
[data-slot=dialog-footer]]:pb-6 not-has-[>[data-slot=dialog-header]]:pt-6 [&>[data-slot=dialog-header]+[data-slot=dialog-footer]]:pt-0', showFrame && 'bg-background rounded-[calc(var(--radius-2xl)*5/6)]', )} > {children} {closeButton && ( )}
) } type DialogHeaderProps = React.ComponentPropsWithoutRef<'div'> function DialogHeader({ className, ...props }: DialogHeaderProps) { return
} type DialogTitleProps = React.ComponentProps function DialogTitle({ className, ...props }: DialogTitleProps) { return ( ) } type DialogDescriptionProps = React.ComponentProps function DialogDescription({ className, ...props }: DialogDescriptionProps) { return ( ) } type DialogBodyProps = React.ComponentPropsWithoutRef<'div'> function DialogBody({ className, ...props }: DialogBodyProps) { return
} type DialogFooterProps = React.ComponentPropsWithoutRef<'div'> function DialogFooter({ className, ...props }: DialogFooterProps) { return (
) } type DialogCloseProps = React.ComponentProps function DialogClose({ className, ...props }: DialogCloseProps) { return } function CloseIcon(props: React.SVGProps) { return ( ) } export { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogBody, DialogFooter, DialogClose, } export type { DialogProps, DialogTriggerProps, DialogContentProps, DialogHeaderProps, DialogTitleProps, DialogDescriptionProps, DialogBodyProps, DialogFooterProps, DialogCloseProps, }