vxe-table
Version:
A PC-end table component based on Vxe UI, supporting copy-paste, data pivot table, and high-performance virtual list table solution.
274 lines (273 loc) • 13.5 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var panel_exports = {};
__export(panel_exports, {
default: () => panel_default
});
module.exports = __toCommonJS(panel_exports);
var import_vue = require("vue");
var import_comp = require("../../../ui/src/comp");
var import_xe_utils = __toESM(require("xe-utils"));
var import_core = require("@vxe-ui/core");
var import_utils = require("../../../ui/src/utils");
var import_vn = require("../../../ui/src/vn");
const { getIcon, getI18n, renderEmptyElement } = import_core.VxeUI;
var panel_default = (
/* define-vxe-component start */
(0, import_comp.defineVxeComponent)({
name: "VxeTableMenuPanel",
setup(props, context) {
const xID = import_xe_utils.default.uniqueId();
const $xeTable = (0, import_vue.inject)("$xeTable", {});
const { reactData: tableReactData } = $xeTable;
const refElem = (0, import_vue.ref)();
const refMaps = {
refElem
};
const $xeMenuPanel = {
xID,
props,
context,
getRefMaps: () => refMaps
};
const renderVN = () => {
const { ctxMenuStore } = tableReactData;
const { computeMenuOpts } = $xeTable.getComputeMaps();
const menuOpts = computeMenuOpts.value;
const { transfer, destroyOnClose, className } = menuOpts;
const { visible, list } = ctxMenuStore;
return (0, import_vue.h)(
import_vue.Teleport,
{
to: "body",
disabled: !transfer
},
[
(0, import_vue.h)(
"div",
{
ref: refElem,
class: [
"vxe-table--context-menu-wrapper",
className,
{
"is--visible": visible
}
],
style: ctxMenuStore.style
},
(destroyOnClose ? visible : true) ? list.map((options, gIndex) => {
return options.every((item) => item.visible === false) ? renderEmptyElement($xeTable) : (0, import_vue.h)(
"ul",
{
class: "vxe-table--context-menu-group-wrapper",
key: gIndex
},
options.map((item, index) => {
const { children, loading } = item;
const hasChildMenus = children && children.some((child) => child.visible !== false);
const prefixOpts = Object.assign({}, item.prefixConfig);
const prefixIcon = prefixOpts.icon || item.prefixIcon;
const suffixOpts = Object.assign({}, item.suffixConfig);
const suffixIcon = suffixOpts.icon || item.suffixIcon;
const menuContent = (0, import_utils.getFuncText)(item.name);
return item.visible === false ? renderEmptyElement($xeTable) : (0, import_vue.h)(
"li",
{
class: [
"vxe-table--context-menu--option",
item.className,
{
"link--loading": loading,
"link--disabled": item.disabled,
"link--active": item === ctxMenuStore.selected
}
],
key: `${gIndex}_${index}`
},
[
(0, import_vue.h)(
"a",
{
class: "vxe-context-menu--link",
onClick(evnt) {
$xeTable.ctxMenuLinkEvent(evnt, item);
},
onMouseover(evnt) {
$xeTable.ctxMenuMouseoverEvent(evnt, item);
},
onMouseout(evnt) {
$xeTable.ctxMenuMouseoutEvent(evnt, item);
}
},
[
(0, import_vue.h)(
"div",
{
class: ["vxe-context-menu--link-prefix", prefixOpts.className || ""]
},
[
loading ? (0, import_vue.h)("span", {
class: getIcon("TABLE_MENU_OPTION_LOADING")
}) : prefixIcon && import_xe_utils.default.isFunction(prefixIcon) ? (0, import_vue.h)("span", {}, (0, import_vn.getSlotVNs)(prefixIcon({}))) : (0, import_vue.h)("span", {}, [
(0, import_vue.h)("i", {
class: prefixIcon
})
]),
prefixOpts.content ? (0, import_vue.h)("span", {}, `${prefixOpts.content}`) : renderEmptyElement($xeTable)
]
),
(0, import_vue.h)(
"div",
{
class: "vxe-context-menu--link-content",
title: menuContent
},
loading ? getI18n("vxe.table.menuLoading") : menuContent
),
(0, import_vue.h)(
"div",
{
class: ["vxe-context-menu--link-suffix", suffixOpts.className || ""]
},
[
suffixIcon && import_xe_utils.default.isFunction(suffixIcon) ? (0, import_vue.h)("span", {}, (0, import_vn.getSlotVNs)(suffixIcon({}))) : (0, import_vue.h)("i", {
class: suffixIcon || (hasChildMenus ? getIcon().TABLE_MENU_OPTIONS : "")
}),
suffixOpts.content ? (0, import_vue.h)("span", `${suffixOpts.content}`) : renderEmptyElement($xeTable)
]
)
]
),
hasChildMenus && children ? (0, import_vue.h)(
"ul",
{
class: [
"vxe-table--context-menu-clild-wrapper",
{
"is--show": item === ctxMenuStore.selected && ctxMenuStore.showChild
}
]
},
children.map((child, cIndex) => {
const { loading: childLoading } = child;
const childPrefixOpts = Object.assign({}, child.prefixConfig);
const childPrefixIcon = childPrefixOpts.icon || child.prefixIcon;
const childSuffixOpts = Object.assign({}, child.suffixConfig);
const childSuffixIcon = childSuffixOpts.icon || child.suffixIcon;
const childMenuContent = (0, import_utils.getFuncText)(child.name);
return child.visible === false ? null : (0, import_vue.h)(
"li",
{
class: [
"vxe-table--context-menu--option",
child.className,
{
"link--loading": childLoading,
"link--disabled": child.disabled,
"link--active": child === ctxMenuStore.selectChild
}
],
key: `${gIndex}_${index}_${cIndex}`
},
[
(0, import_vue.h)(
"a",
{
class: "vxe-context-menu--link",
onClick(evnt) {
$xeTable.ctxMenuLinkEvent(evnt, child);
},
onMouseover(evnt) {
$xeTable.ctxMenuMouseoverEvent(evnt, item, child);
},
onMouseout(evnt) {
$xeTable.ctxMenuMouseoutEvent(evnt, item);
}
},
[
(0, import_vue.h)(
"div",
{
class: ["vxe-context-menu--link-prefix", childPrefixOpts.className || ""]
},
[
child.loading ? (0, import_vue.h)("span", {
class: getIcon("TABLE_MENU_OPTION_LOADING")
}) : childPrefixIcon && import_xe_utils.default.isFunction(childPrefixIcon) ? (0, import_vue.h)("span", {}, (0, import_vn.getSlotVNs)(childPrefixIcon({}))) : (0, import_vue.h)("span", {}, [
(0, import_vue.h)("i", {
class: childPrefixIcon
})
]),
childPrefixOpts.content ? (0, import_vue.h)("span", `${childPrefixOpts.content}`) : renderEmptyElement($xeTable)
]
),
(0, import_vue.h)(
"div",
{
class: "vxe-context-menu--link-content",
title: childMenuContent
},
childLoading ? getI18n("vxe.table.menuLoading") : childMenuContent
),
(0, import_vue.h)(
"div",
{
class: ["vxe-context-menu--link-suffix", childSuffixOpts.className || ""]
},
[
childSuffixIcon && import_xe_utils.default.isFunction(childSuffixIcon) ? (0, import_vue.h)("span", {}, (0, import_vn.getSlotVNs)(childSuffixIcon({}))) : (0, import_vue.h)("i", {
class: childSuffixIcon
}),
childSuffixOpts.content ? (0, import_vue.h)("span", `${childSuffixOpts.content}`) : renderEmptyElement($xeTable)
]
)
]
)
]
);
})
) : null
]
);
})
);
}) : []
)
]
);
};
$xeMenuPanel.renderVN = renderVN;
return $xeMenuPanel;
},
render() {
return this.renderVN();
}
})
);