"use client"; import type * as React from "react"; import { useState } from "react"; import { cn } from "@/lib/utils"; import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { Maximize2Icon, Minimize2Icon, XIcon } from "lucide-react"; import { useI18n } from "@/i18n/provider"; const dialogSizeClassName = { sm: "max-w-md sm:max-w-md", md: "max-w-xl sm:max-w-xl", lg: "max-w-2xl sm:max-w-2xl", xl: "max-w-4xl sm:max-w-4xl", xxl: "max-w-5xl sm:max-w-5xl", } as const; type ProjectDialogSize = keyof typeof dialogSizeClassName; type ProjectDialogProps = React.ComponentProps & { title: React.ReactNode; description?: React.ReactNode; size?: ProjectDialogSize; children: React.ReactNode; footer?: React.ReactNode; contentClassName?: string; headerClassName?: string; bodyClassName?: string; footerClassName?: string; showCloseButton?: boolean; closeOnEsc?: boolean; allowFullscreen?: boolean; defaultFullscreen?: boolean; bodyScrollable?: boolean; }; function ProjectDialog({ open, onOpenChange, title, description, size = "md", children, footer, contentClassName, headerClassName, bodyClassName, footerClassName, showCloseButton = true, closeOnEsc = true, allowFullscreen = false, defaultFullscreen = false, bodyScrollable = true, }: ProjectDialogProps) { const t = useI18n(); const [fullscreen, setFullscreen] = useState(defaultFullscreen); function handleOpenChange(nextOpen: boolean, eventDetails: unknown) { const reason = (eventDetails as { reason?: string } | undefined)?.reason; if (!nextOpen && !closeOnEsc && reason === "escape-key") { return; } if (!nextOpen) { setFullscreen(defaultFullscreen); } onOpenChange?.(nextOpen, eventDetails as never); } return ( {(allowFullscreen || showCloseButton) && (
{allowFullscreen ? ( ) : null} {showCloseButton ? ( } > {t("common.close")} ) : null}
)} {title} {description ? ( {description} ) : null} {bodyScrollable ? (
{children}
) : (
{children}
)} {footer ? ( {footer} ) : null}
); } export { ProjectDialog };