"use client"; import { XMarkIcon } from "@heroicons/react/24/outline"; import clsx from "clsx"; import type { ComponentProps, ReactNode } from "react"; import { Dialog, Heading, Modal, ModalOverlay } from "react-aria-components"; import { Button } from "../Button"; // This type currently isn't exported by react-aria-components, so we reconstruct it here... type DialogRenderProps = Parameters< Exclude["children"], ReactNode> >[0]; type ModalDialogProps = Omit< ComponentProps, "children" > & { closeDisabled?: boolean | undefined; noClose?: boolean | undefined; closeButtonText?: string; title: ReactNode | ReactNode[]; description?: ReactNode; children?: | ((options: DialogRenderProps) => ReactNode | ReactNode[]) | ReactNode | ReactNode[] | undefined; }; export const ModalDialog = ({ closeDisabled, closeButtonText, noClose, children, title, description, ...props }: ModalDialogProps) => ( {(options) => ( <> {!noClose && (
)} {title} {description && (

{description}

)} {typeof children === "function" ? children(options) : children} {!noClose && closeButtonText !== undefined && (
)} )}
);