import { useEffect, useRef, useState, } from "react";
const useComponentOutsideClick = (isVisible) => {
    const [isComponentVisible, setIsComponentVisible] = useState(isVisible);
    const ref = useRef(null);
    const handleClickOutside = (event) => {
        if (ref.current && !ref.current.contains(event.target)) {
            setIsComponentVisible(false);
        }
    };
    useEffect(() => {
        document.addEventListener("click", handleClickOutside, true);
        return () => {
            document.removeEventListener("click", handleClickOutside, true);
        };
    }, []);
    return { ref, isComponentVisible, setIsComponentVisible };
};
export default useComponentOutsideClick;
//# sourceMappingURL=UseComponentOutsideClick.js.map