UNPKG

@hopeio/utils

Version:
50 lines (49 loc) 1.39 kB
import { defineComponent as u, useSlots as f, ref as i, onMounted as m, h as d, resolveComponent as h, createBlock as x, openBlock as v, mergeProps as y, withModifiers as C, withCtx as g, renderSlot as P } from "vue"; import { useTippy as T } from "vue-tippy"; import { withInstall as _ } from "@pureadmin/utils"; const b = /* @__PURE__ */ u({ name: "ReText", __name: "index", props: { // 行数 lineClamp: { type: [String, Number] }, tippyProps: { type: Object, default: () => ({}) } }, setup(n) { const o = n, l = f(), r = i(), t = i(), p = (e) => o.lineClamp ? e.scrollHeight > e.clientHeight : e.scrollWidth > e.clientWidth, s = () => ({ content: d(l.content || l.default), ...o.tippyProps }); function a(e) { p(e.target) ? (t.value.setProps(s()), t.value.enable()) : t.value.disable(); } return m(() => { var e; t.value = T((e = r.value) == null ? void 0 : e.$el, s()); }), (e, R) => { const c = h("el-text"); return v(), x(c, y({ truncated: !n.lineClamp, lineClamp: n.lineClamp, ...e.$attrs }, { ref_key: "textRef", ref: r, onMouseover: C(a, ["self"]) }), { default: g(() => [ P(e.$slots, "default") ]), _: 3 }, 16); }; } }), H = _(b); export { H as ReText };