import { type RefObject } from "react"; type EventType = "mousedown" | "mouseup" | "touchstart" | "touchend" | "pointerdown" | "pointerup" | "click"; export interface UseClickOutsideOptions { enabled?: boolean; events?: EventType[]; } /** * Detects clicks outside of a specified element. * Perfect for closing dropdowns, modals, and tooltips when a user clicks away. * Uses ref-forwarded handlers to avoid re-subscribing on each render. * * @param ref - The React ref attached to the element you want to detect clicks outside of. * @param handler - The callback function to fire when an outside click is detected. * @param options - Additional options including enabled flag and custom DOM events. * * @example * ```tsx * const ref = useRef(null); * useClickOutside(ref, () => setIsOpen(false)); * return