import { RefObject } from 'react'; /** * Detects clicks outside of a specified element and triggers a callback. * Useful for closing dropdowns, modals, and popovers when clicking outside. * * @template T - The HTML element type (extends HTMLElement) * @param callback - Function to call when a click outside is detected * @returns A ref to attach to the element * * @example * ```tsx * function Dropdown() { * const [isOpen, setIsOpen] = useState(false); * const dropdownRef = useOnClickOutside(() => setIsOpen(false)); * * return ( *
* * {isOpen && ( *
*

Dropdown content

*
* )} *
* ); * } * ``` * * @example * ```tsx * function Modal({ onClose }: { onClose: () => void }) { * const modalRef = useOnClickOutside(onClose); * * return ( *
*
*

Modal Title

*

Modal content

*
*
* ); * } * ``` */ export declare function useOnClickOutside(callback: (event: MouseEvent | TouchEvent) => void): RefObject; /** * Alternative version that accepts an existing ref instead of creating one. * Useful when you need to attach the ref to multiple elements or use it elsewhere. * * @template T - The HTML element type (extends HTMLElement) * @param ref - The ref object to monitor * @param callback - Function to call when a click outside is detected * * @example * ```tsx * function Popover() { * const [isOpen, setIsOpen] = useState(false); * const popoverRef = useRef(null); * * useOnClickOutsideWithRef(popoverRef, () => setIsOpen(false)); * * return ( *
* * {isOpen && ( *
* Content *
* )} *
* ); * } * ``` */ export declare function useOnClickOutsideWithRef(ref: RefObject, callback: (event: MouseEvent | TouchEvent) => void): void; //# sourceMappingURL=useOnClickOutside.d.ts.map