"use client"; import { Divider } from "@tremor/react"; import { FiX } from "react-icons/fi"; import { IconProps } from "./icons/icons"; import { useRef } from "react"; import { isEventWithinRef } from "@/lib/contains"; interface ModalProps { icon?: ({ size, className }: IconProps) => JSX.Element; children: JSX.Element | string; title?: JSX.Element | string; onOutsideClick?: () => void; className?: string; width?: string; titleSize?: string; hideDividerForTitle?: boolean; noPadding?: boolean; } export function Modal({ icon, children, title, onOutsideClick, className, width, titleSize, hideDividerForTitle, noPadding, }: ModalProps) { const modalRef = useRef(null); const handleMouseDown = (e: React.MouseEvent) => { if ( onOutsideClick && modalRef.current && !modalRef.current.contains(e.target as Node) && !isEventWithinRef(e.nativeEvent, modalRef) ) { onOutsideClick(); } }; return (
event.stopPropagation()} > {title && ( <>

{title} {icon && icon({ size: 30 })}

{onOutsideClick && (
)}
{!hideDividerForTitle && } )} {children}
); }