@wetspace/pro-components
Version:
::: tip 基本介绍
60 lines (59 loc) • 1.93 kB
JavaScript
import { defineComponent as y, shallowRef as a, computed as T, openBlock as b, createBlock as g, unref as p, mergeProps as k, withCtx as f, createElementVNode as u, normalizeClass as m, normalizeStyle as d, renderSlot as h } from "vue";
import { textEllipsisProps as C } from "./types.mjs";
import { useNamespace as E, ElTooltip as W } from "element-plus";
const z = /* @__PURE__ */ y({
name: "TextEllipsis",
__name: "index",
props: C,
setup(v) {
const i = E("text-ellipsis"), t = v, l = a(null), o = a(), s = a(!1), x = () => {
var e;
o.value && o.value.scrollHeight > o.value.offsetHeight * 1.5 && (s.value = !0, (e = l.value) == null || e.onOpen());
}, w = () => {
var e;
(e = l.value) == null || e.onClose(), s.value = !1;
}, _ = T(() => {
var n;
return (n = t.tooltip) != null && n.maxWidth ? `${t.tooltip.maxWidth}px` : "240px";
});
return (e, n) => {
var r, c;
return b(), g(p(W), k({
ref_key: "toolTipIns",
ref: l,
"append-to": "body"
}, t.tooltip, {
effect: ((r = t.tooltip) == null ? void 0 : r.effect) ?? "light",
disabled: !s.value,
placement: ((c = t.tooltip) == null ? void 0 : c.placement) ?? "top"
}), {
content: f(() => [
u("div", {
class: m([p(i).e("content")]),
style: d({ maxWidth: _.value })
}, [
h(e.$slots, "default")
], 6)
]),
default: f(() => [
u("span", {
ref_key: "spanRef",
ref: o,
class: m([p(i).b()]),
style: d({
"--wet-pro-line-clamp": t.rows
}),
onMouseenter: x,
onMouseleave: w
}, [
h(e.$slots, "default")
], 38)
]),
_: 3
}, 16, ["effect", "disabled", "placement"]);
};
}
});
export {
z as default
};