import { useEffect } from "react";
/**
 * Hook that detects clicks outside of the passed ref and executes a function
 */
export const useOutsideClickDetector = (ref, fn) => {
    useEffect(() => {
        function handleClickOutside(event) {
            if (ref.current && !ref.current.contains(event.target)) {
                fn();
            }
        }
        document.addEventListener("mousedown", handleClickOutside);
        return () => {
            document.removeEventListener("mousedown", handleClickOutside);
        };
    }, [ref]);
};
//# sourceMappingURL=useOutsideClickDetector.js.map