import { Button } from "@repo/shadcn-ui/components/button"; import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader, DialogTitle, } from "@repo/shadcn-ui/components/dialog"; import { type ReactNode, createContext, useContext } from "react"; const FormCancelContext = createContext(undefined); export function FormDialog({ open, onOpenChange, title, cancelLabel, children, wide = false, size, formActions = false, }: { open: boolean; onOpenChange: (open: boolean) => void; title: ReactNode; cancelLabel: string; children: ReactNode; wide?: boolean; size?: "small" | "medium" | "large"; formActions?: boolean; }) { const width = size ?? (wide ? "large" : "small"); const widths = { small: "sm:max-w-xl", medium: "sm:max-w-3xl", large: "sm:w-[90vw] sm:max-w-[1200px]", }; return ( {title}
{children}
{!formActions && ( }> {cancelLabel} )}
); } export function FormActions({ children }: { children: ReactNode }) { const cancelLabel = useContext(FormCancelContext); return ( {cancelLabel && ( }>{cancelLabel} )} {children} ); } /** El cuerpo reserva espacio simétrico para que el scroll no recorte el anillo de foco. */ export function FormBody({ children }: { children: ReactNode }) { return (
{children}
); }