UNPKG

@huyuchen/visual

Version:

## 组件环境

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