@antdv/pro-utils
Version:
@antdv/pro-utils
72 lines (71 loc) • 2.33 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
genCopyable: () => genCopyable
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_ant_design_vue = require("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 ? (0, import_vue.createVNode)("div", {
"class": "pro-table-tooltip-text"
}, [dom]) : text
)
} : false;
return (0, import_vue.createVNode)(import_ant_design_vue.Typography.Text, {
"style": {
width: "100%",
margin: 0,
padding: 0
},
"title": "",
"copyable": copyable,
"ellipsis": ellipsis
}, {
default: () => [dom]
});
}
return dom;
}