"use client"; import { cn } from "@/lib/utils"; import { useEffect, useRef, type ReactNode } from "react"; type PopoverShellProps = { onClose: () => void; className?: string; children: ReactNode; }; export function PopoverShell({ onClose, className, children, }: PopoverShellProps) { const ref = useRef(null); useEffect(() => { function handleClick(event: MouseEvent) { if (ref.current && !ref.current.contains(event.target as Node)) onClose(); } document.addEventListener("mousedown", handleClick); return () => document.removeEventListener("mousedown", handleClick); }, [onClose]); return (
{children}
); }