tdesign-vue-next
Version:
TDesign Component for vue-next
264 lines (256 loc) • 12.2 kB
JavaScript
/**
* tdesign v1.11.5
* (c) 2025 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
var Vue = require('vue');
var table_tr = require('./tr.js');
var configProvider_hooks_useConfig = require('../config-provider/hooks/useConfig.js');
var hooks_tnode = require('../_chunks/dep-a69ce597.js');
var table_hooks_useClassName = require('./hooks/useClassName.js');
var table_baseTableProps = require('./base-table-props.js');
var table_hooks_useRowspanAndColspan = require('./hooks/useRowspanAndColspan.js');
var pick = require('../_chunks/dep-ba971aad.js');
var get = require('../_chunks/dep-56c837c8.js');
var camelCase = require('../_chunks/dep-db023c41.js');
require('@babel/runtime/helpers/typeof');
require('./utils.js');
require('../_chunks/dep-047617bf.js');
require('../_chunks/dep-bbe343d7.js');
require('../_chunks/dep-0a510359.js');
require('./hooks/useFixed.js');
require('@babel/runtime/helpers/slicedToArray');
require('../_chunks/dep-cef23b69.js');
require('../_chunks/dep-31c4c452.js');
require('../_chunks/dep-25acc189.js');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../_chunks/dep-93cf0a54.js');
require('../_chunks/dep-8afe2bf0.js');
require('../_chunks/dep-b8b9c2a3.js');
require('../_chunks/dep-5ad8a2ab.js');
require('../_chunks/dep-0c2ad01b.js');
require('../_chunks/dep-cea0dc9b.js');
require('../utils/dom.js');
require('../_chunks/dep-30fb1b25.js');
require('../_chunks/dep-6f8a66a3.js');
require('../_chunks/dep-feae46a3.js');
require('../_chunks/dep-abf21389.js');
require('../_chunks/dep-b27d3215.js');
require('../_chunks/dep-ed572eb3.js');
require('../_chunks/dep-b0b4fff1.js');
require('../_chunks/dep-9780143c.js');
require('../_chunks/dep-62aae11c.js');
require('../_chunks/dep-02ebb419.js');
require('../_chunks/dep-50a41d31.js');
require('../_chunks/dep-732925e8.js');
require('../_chunks/dep-e495f218.js');
require('../_chunks/dep-bafc1f63.js');
require('../_chunks/dep-7a21da5b.js');
require('../_chunks/dep-43bc982b.js');
require('../_chunks/dep-be3c3d53.js');
require('../_chunks/dep-9de7d250.js');
require('../_chunks/dep-7c08b9a8.js');
require('../_chunks/dep-beb9de0a.js');
require('../_chunks/dep-31140ae7.js');
require('../_chunks/dep-533159e9.js');
require('../_chunks/dep-55d8c3ed.js');
require('../_chunks/dep-8ba18d4f.js');
require('../_chunks/dep-ba2090c8.js');
require('../_chunks/dep-49fa220e.js');
require('../_chunks/dep-fd1ddb6b.js');
require('./ellipsis.js');
require('../utils/render-tnode.js');
require('../_chunks/dep-76218bd8.js');
require('../_chunks/dep-acb090bf.js');
require('../_chunks/dep-9a321a91.js');
require('../_chunks/dep-ecbaedee.js');
require('../_chunks/dep-8b98fa07.js');
require('../_chunks/dep-c07d6878.js');
require('../_chunks/dep-a957c564.js');
require('../tooltip/index.js');
require('../tooltip/tooltip.js');
require('../tooltip/props.js');
require('../popup/props.js');
require('../popup/index.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../hooks/useConfig.js');
require('../_chunks/dep-b4c4a54b.js');
require('../_chunks/dep-f8ff548f.js');
require('dayjs');
require('../_chunks/dep-b6c192db.js');
require('../_chunks/dep-7f32423d.js');
require('../_chunks/dep-7c9e3d93.js');
require('../_chunks/dep-61a7e281.js');
require('../hooks/useKeepAnimation.js');
require('../_chunks/dep-b1b8272b.js');
require('../hooks/useVModel.js');
require('../popup/container.js');
require('../hooks/useResizeObserver.js');
require('../utils/withInstall.js');
require('../tooltip/utils/index.js');
require('../_chunks/dep-d67d6b6f.js');
require('./hooks/useLazyLoad.js');
require('../_chunks/dep-9da21bcd.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumableArray);
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default["default"](e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var ROW_AND_TD_LISTENERS = [].concat(_toConsumableArray__default["default"](table_tr.ROW_LISTENERS), ["cell-click"]);
var extendTableProps = ["bordered", "rowKey", "rowClassName", "rowAttributes", "loading", "empty", "fixedRows", "firstFullRow", "lastFullRow", "rowspanAndColspan", "scroll", "cellEmptyContent", "pagination", "attach", "onCellClick", "onPageChange", "onRowClick", "onRowDblclick", "onRowMouseover", "onRowMousedown", "onRowMouseenter", "onRowMouseleave", "onRowMouseup", "onScroll", "onScrollX", "onScrollY"];
var TBody = Vue.defineComponent({
name: "TBody",
props: _objectSpread({
classPrefix: String,
data: Array,
columns: Array,
ellipsisOverlayClassName: String,
rowAndColFixedPosition: Map,
showColumnShadow: Object,
tableElm: {},
tableWidth: Number,
isWidthOverflow: Boolean,
virtualConfig: Object,
tableContentElm: {},
handleRowMounted: Function,
renderExpandedRow: Function,
firstFullRow: [String, Function],
lastFullRow: [String, Function],
activeRow: [Array],
hoverRow: [String, Number]
}, pick.pick(table_baseTableProps["default"], extendTableProps)),
setup: function setup(props) {
var renderTNode = hooks_tnode.useTNodeJSX();
var _toRefs = Vue.toRefs(props),
data = _toRefs.data,
columns = _toRefs.columns,
rowKey = _toRefs.rowKey,
rowspanAndColspan = _toRefs.rowspanAndColspan;
var _useConfig = configProvider_hooks_useConfig.useConfig("table", props.locale),
t = _useConfig.t,
globalConfig = _useConfig.globalConfig;
var _useClassName = table_hooks_useClassName["default"](),
tableFullRowClasses = _useClassName.tableFullRowClasses,
tableBaseClass = _useClassName.tableBaseClass;
var _useRowspanAndColspan = table_hooks_useRowspanAndColspan["default"](data, columns, rowKey, rowspanAndColspan),
skipSpansMap = _useRowspanAndColspan.skipSpansMap;
var tbodyClasses = Vue.computed(function () {
return [tableBaseClass.body];
});
return {
t: t,
globalConfig: globalConfig,
renderTNode: renderTNode,
tableFullRowClasses: tableFullRowClasses,
tbodyClasses: tbodyClasses,
tableBaseClass: tableBaseClass,
skipSpansMap: skipSpansMap
};
},
render: function render() {
var _this = this,
_this$data,
_this$data2,
_this$virtualConfig,
_this$virtualConfig2;
var renderEmpty = function renderEmpty(columns) {
var tableWidth = _this.bordered ? _this.tableWidth - 2 : _this.tableWidth;
return Vue.createVNode("tr", {
"class": [_this.tableBaseClass.emptyRow, _defineProperty__default["default"]({}, _this.tableFullRowClasses.base, _this.isWidthOverflow)]
}, [Vue.createVNode("td", {
"colspan": columns.length
}, [Vue.createVNode("div", {
"class": [_this.tableBaseClass.empty, _defineProperty__default["default"]({}, _this.tableFullRowClasses.innerFullRow, _this.isWidthOverflow)],
"style": _this.isWidthOverflow ? {
width: "".concat(tableWidth, "px")
} : {}
}, [_this.renderTNode("empty") || _this.t(_this.globalConfig.empty)])])]);
};
var getFullRow = function getFullRow(columnLength2, type) {
var tType = camelCase.camelCase(type);
var fullRowNode = _this.renderTNode(tType);
if (["", null, void 0, false].includes(fullRowNode)) return null;
var isFixedToLeft = _this.isWidthOverflow && _this.columns.find(function (col) {
return col.fixed === "left";
});
var classes = [_this.tableFullRowClasses.base, _this.tableFullRowClasses[tType]];
var tableWidth = _this.bordered ? _this.tableWidth - 2 : _this.tableWidth;
return Vue.createVNode("tr", {
"class": classes,
"key": "key-full-row-".concat(type)
}, [Vue.createVNode("td", {
"colspan": columnLength2
}, [Vue.createVNode("div", {
"class": _defineProperty__default["default"]({}, _this.tableFullRowClasses.innerFullRow, isFixedToLeft),
"style": isFixedToLeft ? {
width: "".concat(tableWidth, "px")
} : {}
}, [Vue.createVNode("div", {
"class": _this.tableFullRowClasses.innerFullElement
}, [fullRowNode])])])]);
};
var columnLength = this.columns.length;
var dataLength = (_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.length;
var trNodeList = [];
var properties = ["classPrefix", "ellipsisOverlayClassName", "rowAndColFixedPosition", "scroll", "tableElm", "tableContentElm", "pagination", "attach"];
var renderData = this.virtualConfig.isVirtualScroll.value ? this.virtualConfig.visibleData.value : this.data;
renderData === null || renderData === void 0 || renderData.forEach(function (row, rowIndex) {
var _this$activeRow;
var rowKey = _this.rowKey || "id";
var rowValue = get.get(row, rowKey);
var trProps = _objectSpread(_objectSpread({}, pick.pick(_this.$props, table_tr.TABLE_PROPS)), {}, {
rowKey: rowKey,
row: row,
columns: _this.columns,
rowIndex: row.VIRTUAL_SCROLL_INDEX || rowIndex,
dataLength: dataLength,
skipSpansMap: _this.skipSpansMap,
virtualConfig: _this.virtualConfig,
active: (_this$activeRow = _this.activeRow) === null || _this$activeRow === void 0 ? void 0 : _this$activeRow.includes(rowValue),
isHover: _this.hoverRow === rowValue
}, pick.pick(_this.$props, properties));
if (_this.onCellClick) {
trProps.onCellClick = _this.onCellClick;
}
var trNode = Vue.createVNode(table_tr["default"], Vue.mergeProps({
"key": get.get(row, _this.rowKey || "id") || rowIndex
}, trProps, {
"onRowMounted": _this.handleRowMounted
}), _this.$slots);
trNodeList.push(trNode);
if (_this.renderExpandedRow) {
var p = {
row: row,
index: rowIndex,
columns: _this.columns,
tableWidth: _this.tableWidth,
isWidthOverflow: _this.isWidthOverflow
};
var expandedContent = _this.renderExpandedRow(p);
expandedContent && trNodeList.push(expandedContent);
}
});
var list = [getFullRow(columnLength, "first-full-row")].concat(trNodeList, [getFullRow(columnLength, "last-full-row")]);
var isEmpty = !((_this$data2 = this.data) !== null && _this$data2 !== void 0 && _this$data2.length) && !this.loading && !this.firstFullRow && !this.lastFullRow;
var translate = "translateY(".concat((_this$virtualConfig = this.virtualConfig) === null || _this$virtualConfig === void 0 ? void 0 : _this$virtualConfig.translateY.value, "px)");
var posStyle = (_this$virtualConfig2 = this.virtualConfig) !== null && _this$virtualConfig2 !== void 0 && _this$virtualConfig2.isVirtualScroll.value ? {
transform: translate,
"-ms-transform": translate,
"-moz-transform": translate,
"-webkit-transform": translate
} : void 0;
return Vue.createVNode("tbody", {
"class": this.tbodyClasses,
"style": _objectSpread({}, posStyle)
}, [isEmpty ? renderEmpty(this.columns) : list]);
}
});
exports.ROW_AND_TD_LISTENERS = ROW_AND_TD_LISTENERS;
exports["default"] = TBody;
exports.extendTableProps = extendTableProps;
//# sourceMappingURL=tbody.js.map