UNPKG

@artmate/chat

Version:

**开箱即用的AI组件库(基于 Vue3 + ElementPlus)**

123 lines (122 loc) 3.76 kB
import { noop as m, isIOS as C, isClient as L, toArray as P, watchImmediate as S, tryOnScopeDispose as $, isObject as R } from "./node_modules/@vueuse/shared/index.js"; import { computed as W, toValue as f, unref as F } from "vue"; const M = L ? window : void 0; function v(l) { var s; const c = f(l); return (s = c == null ? void 0 : c.$el) != null ? s : c; } function h(...l) { const s = [], c = () => { s.forEach((o) => o()), s.length = 0; }, i = (o, n, r, a) => (o.addEventListener(n, r, a), () => o.removeEventListener(n, r, a)), d = W(() => { const o = P(f(l[0])).filter((n) => n != null); return o.every((n) => typeof n != "string") ? o : void 0; }), y = S( () => { var o, n; return [ (n = (o = d.value) == null ? void 0 : o.map((r) => v(r))) != null ? n : [M].filter((r) => r != null), P(f(d.value ? l[1] : l[0])), P(F(d.value ? l[2] : l[1])), // @ts-expect-error - TypeScript gets the correct types, but somehow still complains f(d.value ? l[3] : l[2]) ]; }, ([o, n, r, a]) => { if (c(), !(o != null && o.length) || !(n != null && n.length) || !(r != null && r.length)) return; const b = R(a) ? { ...a } : a; s.push( ...o.flatMap( (E) => n.flatMap( (p) => r.map((k) => i(E, p, k, b)) ) ) ); }, { flush: "post" } ), g = () => { y(), c(); }; return $(c), g; } let I = !1; function x(l, s, c = {}) { const { window: i = M, ignore: d = [], capture: y = !0, detectIframe: g = !1, controls: o = !1 } = c; if (!i) return o ? { stop: m, cancel: m, trigger: m } : m; if (C && !I) { I = !0; const e = { passive: !0 }; Array.from(i.document.body.children).forEach((t) => h(t, "click", m, e)), h(i.document.documentElement, "click", m, e); } let n = !0; const r = (e) => f(d).some((t) => { if (typeof t == "string") return Array.from(i.document.querySelectorAll(t)).some((u) => u === e.target || e.composedPath().includes(u)); { const u = v(t); return u && (e.target === u || e.composedPath().includes(u)); } }); function a(e) { const t = f(e); return t && t.$.subTree.shapeFlag === 16; } function b(e, t) { const u = f(e), A = u.$.subTree && u.$.subTree.children; return A == null || !Array.isArray(A) ? !1 : A.some((T) => T.el === t.target || t.composedPath().includes(T.el)); } const E = (e) => { const t = v(l); if (e.target != null && !(!(t instanceof Element) && a(l) && b(l, e)) && !(!t || t === e.target || e.composedPath().includes(t))) { if ("detail" in e && e.detail === 0 && (n = !r(e)), !n) { n = !0; return; } s(e); } }; let p = !1; const k = [ h(i, "click", (e) => { p || (p = !0, setTimeout(() => { p = !1; }, 0), E(e)); }, { passive: !0, capture: y }), h(i, "pointerdown", (e) => { const t = v(l); n = !r(e) && !!(t && !e.composedPath().includes(t)); }, { passive: !0 }), g && h(i, "blur", (e) => { setTimeout(() => { var t; const u = v(l); ((t = i.document.activeElement) == null ? void 0 : t.tagName) === "IFRAME" && !(u != null && u.contains(i.document.activeElement)) && s(e); }, 0); }, { passive: !0 }) ].filter(Boolean), O = () => k.forEach((e) => e()); return o ? { stop: O, cancel: () => { n = !1; }, trigger: (e) => { n = !0, E(e), n = !1; } } : O; } export { M as defaultWindow, L as isClient, C as isIOS, R as isObject, m as noop, x as onClickOutside, P as toArray, $ as tryOnScopeDispose, v as unrefElement, h as useEventListener, S as watchImmediate };