UNPKG

@artmate/chat

Version:

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

70 lines (69 loc) 2.18 kB
import { defineComponent as g, ref as c, watch as i, computed as v, onUnmounted as D, createBlock as E, createCommentVNode as C, openBlock as L, Teleport as y, createElementVNode as b, normalizeStyle as N, normalizeClass as h, unref as _, renderSlot as k } from "vue"; import { useNamespace as w } from "../hooks/useNamespace.js"; const z = /* @__PURE__ */ g({ __name: "DropArea", props: { className: { default: "" }, getDropContainer: { type: [Function, null], default: null }, disabled: { type: Boolean, default: !1 } }, setup(m) { const n = m, r = w("attachment-drop-area"), t = c(null), a = c(null); i( () => n.getDropContainer, () => { var o; const e = (o = n.getDropContainer) == null ? void 0 : o.call(n); t.value !== e && (t.value = e); }, { immediate: !0 } ); const f = v(() => n.getDropContainer && t.value && !n.disabled), p = v(() => { var e; return [ n.className, { [r.b("on-body")]: t.value && ((e = t.value) == null ? void 0 : e.tagName) === "BODY" } ]; }); function l() { a.value = !0; } function u(e) { e.preventDefault(); } function d(e) { e.relatedTarget || (a.value = !1); } function s(e) { a.value = !1, e.preventDefault(); } return i( () => t.value, () => { t.value && (document.addEventListener("dragenter", l), document.addEventListener("dragover", u), document.addEventListener("dragleave", d), document.addEventListener("drop", s, !0)); }, { immediate: !0 } ), D(() => { t.value && (document.removeEventListener("dragenter", l), document.removeEventListener("dragover", u), document.removeEventListener("dragleave", d), document.removeEventListener("drop", s)); }), (e, o) => f.value ? (L(), E(y, { key: 0, to: t.value }, [ b("div", { class: h([_(r).b(), ...p.value]), style: N({ display: a.value ? "block" : "none" }) }, [ k(e.$slots, "default") ], 6) ], 8, ["to"])) : C("", !0); } }); export { z as default };