@frontify/fondue
Version:
Design system of Frontify
20 lines (19 loc) • 565 B
JavaScript
import { useRef as n, useEffect as f } from "react";
const e = (i, t) => {
const o = n(null);
return f(() => {
function r(u) {
var c;
!((c = o.current) != null && c.contains(u.target)) && !(t != null && t.find(
(s) => s && (u.target === s || s.contains(u.target))
)) && i();
}
return document.addEventListener("mousedown", r), () => {
document.removeEventListener("mousedown", r);
};
}, [i, t]), { dismissibleElementRef: o };
};
export {
e as useClickOutside
};
//# sourceMappingURL=useClickOutside.es.js.map