@opensig/opendesign
Version:
19 lines (18 loc) • 567 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const vue = require("vue");
const core = require("@vueuse/core");
function useClickOutside(opts) {
const { targets, onOutside, disabled } = opts;
core.useEventListener("mousedown", (e) => {
if (vue.toValue(disabled)) return;
const path = e.composedPath();
if (vue.toValue(targets).some((el) => {
const node = vue.toValue(el);
return node && path.includes(node);
}))
return;
onOutside();
});
}
exports.useClickOutside = useClickOutside;