UNPKG

@opensig/opendesign

Version:

19 lines (18 loc) 464 B
import { toValue } from "vue"; import { useEventListener } from "@vueuse/core"; function useClickOutside(opts) { const { targets, onOutside, disabled } = opts; useEventListener("mousedown", (e) => { if (toValue(disabled)) return; const path = e.composedPath(); if (toValue(targets).some((el) => { const node = toValue(el); return node && path.includes(node); })) return; onOutside(); }); } export { useClickOutside };