@antdv/pro-utils
Version:
@antdv/pro-utils
53 lines (52 loc) • 1.39 kB
JavaScript
import { createVNode as _createVNode } from "vue";
import { Typography } from "ant-design-vue";
function isNeedTranText(item) {
var _a;
if ((_a = item == null ? void 0 : item.valueType) == null ? void 0 : _a.toString().startsWith("date")) {
return true;
}
if ((item == null ? void 0 : item.valueType) === "select" || (item == null ? void 0 : item.valueEnum)) {
return true;
}
return false;
}
function getEllipsis(item) {
var _a;
if (((_a = item.ellipsis) == null ? void 0 : _a.showTitle) === false) {
return false;
}
return item.ellipsis;
}
function genCopyable(dom, item, text) {
if (item.copyable || item.ellipsis) {
const copyable = item.copyable && text ? {
text,
tooltips: ["", ""]
} : void 0;
const needTranText = isNeedTranText(item);
const ellipsis = getEllipsis(item) && text ? {
tooltip: (
// 支持一下 tooltip 的关闭
(item == null ? void 0 : item.tooltip) !== false && needTranText ? _createVNode("div", {
"class": "pro-table-tooltip-text"
}, [dom]) : text
)
} : false;
return _createVNode(Typography.Text, {
"style": {
width: "100%",
margin: 0,
padding: 0
},
"title": "",
"copyable": copyable,
"ellipsis": ellipsis
}, {
default: () => [dom]
});
}
return dom;
}
export {
genCopyable
};