import { useEffect } from 'react';
export function useOutsideFocus(ref, callback) {
    useEffect(() => {
        function handleFocus(event) {
            // Check if the focus is outside the ref
            if (ref.current && !ref.current.contains(event.target)) {
                callback();
            }
        }
        // Bind the focus and blur handlers
        document.addEventListener('focus', handleFocus, true);
        document.addEventListener('blur', handleFocus, true);
        document.addEventListener('mousedown', handleFocus, true);
        return () => {
            // Unbind the focus and blur handlers when the component unmounts
            document.removeEventListener('focus', handleFocus, true);
            document.removeEventListener('blur', handleFocus, true);
            document.removeEventListener('mousedown', handleFocus, true);
        };
    }, [ref, callback]); // Re-run if ref or callback changes
}
//# sourceMappingURL=outside-focus.js.map