sci-pro
Version:
41 lines (40 loc) • 1.31 kB
JavaScript
const x = (e) => typeof Element > "u" ? !1 : e instanceof Element, s = /* @__PURE__ */ new Map();
let l;
const y = typeof window < "u";
y && (document.addEventListener("mousedown", (e) => l = e), document.addEventListener("mouseup", (e) => {
for (const t of s.values())
for (const { documentHandler: n } of t)
n(e, l);
}));
function f(e, t) {
let n = [];
return Array.isArray(t.arg) ? n = t.arg : x(t.arg) && n.push(t.arg), function(a, o) {
const c = t.instance.popperRef, r = a.target, d = o == null ? void 0 : o.target, i = !t || !t.instance, p = !r || !d, h = e.contains(r) || e.contains(d), E = e === r, g = n.length && n.some((u) => u == null ? void 0 : u.contains(r)) || n.length && n.includes(d), v = c && (c.contains(r) || c.contains(d));
i || p || h || E || g || v || t.value(a, o);
};
}
const H = {
beforeMount(e, t) {
s.has(e) || s.set(e, []), s.get(e).push({
documentHandler: f(e, t),
bindingFn: t.value
});
},
updated(e, t) {
s.has(e) || s.set(e, []);
const n = s.get(e), a = n.findIndex(
(c) => c.bindingFn === t.oldValue
), o = {
documentHandler: f(e, t),
bindingFn: t.value
};
a >= 0 ? n.splice(a, 1, o) : n.push(o);
},
unmounted(e) {
s.delete(e);
}
};
export {
H as default,
x as isElement
};