"use client"; import { useEffect, useRef } from "react"; import { XIcon } from "@phosphor-icons/react"; import { Button } from "./Button"; interface ModalProps { isOpen: boolean; onClose: () => void; title: string; children: React.ReactNode; size?: "sm" | "md" | "lg" | "xl" | "2xl" | "3xl"; showCloseButton?: boolean; preventCloseOnClickOutside?: boolean; className?: string; } export const Modal = ({ isOpen, onClose, title, children, size = "md", showCloseButton = true, preventCloseOnClickOutside = false, className = "", }: ModalProps) => { const dialogRef = useRef(null); useEffect(() => { const dialog = dialogRef.current; if (!dialog) return; if (isOpen) { dialog.showModal(); document.body.style.overflow = "hidden"; } else { dialog.close(); document.body.style.overflow = "unset"; } }, [isOpen]); const sizeClasses = { sm: "w-[600px]", md: "w-[800px]", lg: "w-[1000px]", xl: "w-[1200px]", "2xl": "w-[1400px]", "3xl": "w-[90vw]", }; return ( { if (e.target === dialogRef.current && !preventCloseOnClickOutside) { onClose(); } }} >

{title}

{showCloseButton && ( )}
{children}
); };