43 lines
904 B
TypeScript
43 lines
904 B
TypeScript
|
|
import type { ReactNode } from "react";
|
||
|
|
|
||
|
|
import { Button } from "./button";
|
||
|
|
import {
|
||
|
|
Dialog,
|
||
|
|
DialogClose,
|
||
|
|
DialogContent,
|
||
|
|
DialogFooter,
|
||
|
|
DialogHeader,
|
||
|
|
DialogTitle,
|
||
|
|
} from "./dialog";
|
||
|
|
|
||
|
|
export function FormDialog({
|
||
|
|
open,
|
||
|
|
onOpenChange,
|
||
|
|
title,
|
||
|
|
cancelLabel,
|
||
|
|
children,
|
||
|
|
}: {
|
||
|
|
open: boolean;
|
||
|
|
onOpenChange: (open: boolean) => void;
|
||
|
|
title: string;
|
||
|
|
cancelLabel: string;
|
||
|
|
children: ReactNode;
|
||
|
|
}) {
|
||
|
|
return (
|
||
|
|
<Dialog onOpenChange={onOpenChange} open={open}>
|
||
|
|
<DialogContent
|
||
|
|
className="max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-xl"
|
||
|
|
showCloseButton={false}
|
||
|
|
>
|
||
|
|
<DialogHeader>
|
||
|
|
<DialogTitle>{title}</DialogTitle>
|
||
|
|
</DialogHeader>
|
||
|
|
{children}
|
||
|
|
<DialogFooter>
|
||
|
|
<DialogClose render={<Button variant="outline" />}>{cancelLabel}</DialogClose>
|
||
|
|
</DialogFooter>
|
||
|
|
</DialogContent>
|
||
|
|
</Dialog>
|
||
|
|
);
|
||
|
|
}
|