import React from "react";
export function useClickAway(refs, onClickAway) {
    React.useLayoutEffect(() => {
        const onClick = (event) => {
            const isOutsideClick = !refs.some((ref) => ref.current?.contains(event.target));
            if (isOutsideClick) {
                onClickAway();
            }
        };
        document.addEventListener("click", onClick);
        return () => document.addEventListener("click", onClick);
    }, [refs, onClickAway]);
}
