tdesign-vue
Version:
300 lines (292 loc) • 13.2 kB
JavaScript
/**
* tdesign v1.15.0
* (c) 2026 tdesign
* @license MIT
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
var helper = require('../_chunks/dep-4009cfe4.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var table_tr = require('./tr.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
var hooks_tnode = require('../hooks/tnode.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-d250e942.js');
var get = require('../_chunks/dep-a7198720.js');
var camelCase = require('../_chunks/dep-9c5b91d3.js');
require('@babel/runtime/helpers/typeof');
require('./utils.js');
require('../_chunks/dep-8d206316.js');
require('../_chunks/dep-3b2292ce.js');
require('../_chunks/dep-2bc87cc8.js');
require('./hooks/useFixed.js');
require('@babel/runtime/helpers/slicedToArray');
require('../_common/js/log/log.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('../_chunks/dep-721fcdf6.js');
require('../_chunks/dep-591b87f1.js');
require('../_chunks/dep-a2217d56.js');
require('../_chunks/dep-10fcb46d.js');
require('../_chunks/dep-ba7f5924.js');
require('../_chunks/dep-268c68b1.js');
require('../utils/dom.js');
require('vue');
require('raf');
require('../utils/easing.js');
require('../_chunks/dep-56f568d3.js');
require('../_chunks/dep-f5b14344.js');
require('../_chunks/dep-36c2788b.js');
require('../_chunks/dep-fa353fbb.js');
require('../_chunks/dep-efe55b82.js');
require('../_chunks/dep-733a2279.js');
require('../_chunks/dep-010db548.js');
require('../_chunks/dep-116aedc3.js');
require('../_chunks/dep-d7516e38.js');
require('../_chunks/dep-7c84d9a0.js');
require('../_chunks/dep-d844c9ed.js');
require('../_chunks/dep-f020448d.js');
require('../_chunks/dep-689d381f.js');
require('../_chunks/dep-803744d9.js');
require('../_chunks/dep-f77d6ad5.js');
require('../_chunks/dep-a96e5563.js');
require('../_chunks/dep-bb0ececf.js');
require('../_chunks/dep-4e96e31a.js');
require('../_chunks/dep-74be1050.js');
require('../_chunks/dep-da2ef9c3.js');
require('../_chunks/dep-ee4e645f.js');
require('../_chunks/dep-0ea9f257.js');
require('../_chunks/dep-1e173c2b.js');
require('../_chunks/dep-518e9c7b.js');
require('../_chunks/dep-c05a9033.js');
require('../_chunks/dep-9dae8101.js');
require('../_chunks/dep-c9ce9427.js');
require('./ellipsis.js');
require('../utils/render-tnode.js');
require('@babel/runtime/helpers/readOnlyError');
require('../_chunks/dep-2c592e99.js');
require('../_chunks/dep-f1081d8e.js');
require('../_chunks/dep-9a74c2be.js');
require('../_chunks/dep-84027b7f.js');
require('../_chunks/dep-49400b00.js');
require('../tooltip/index.js');
require('../tooltip/tooltip.js');
require('../tooltip/props.js');
require('../popup/props.js');
require('../popup/popup.js');
require('@popperjs/core');
require('../utils/helper.js');
require('../_common/js/utils/setStyle.js');
require('../popup/container.js');
require('../config-provider/config-receiver.js');
require('../_chunks/dep-8eddb350.js');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('../_chunks/dep-0c37520c.js');
require('../_chunks/dep-c13dcbfd.js');
require('dayjs');
require('../_chunks/dep-6f4e680e.js');
require('../_chunks/dep-6eba4d23.js');
require('../_chunks/dep-7da70ee1.js');
require('../_chunks/dep-124386d4.js');
require('../_chunks/dep-d66ab3a4.js');
require('../_chunks/dep-d4d8c513.js');
require('../_common/js/global-config/t.js');
require('../utils/mixins.js');
require('../utils/event.js');
require('../popup/utils.js');
require('../utils/map-props.js');
require('../utils/withInstall.js');
require('../hooks/useLazyLoad.js');
require('../_common/js/utils/observe.js');
require('../hooks/render-tnode.js');
require('../_chunks/dep-812bd25d.js');
require('../_chunks/dep-82ce56ef.js');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
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 = table_tr.ROW_LISTENERS.concat("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 = VueCompositionAPI.defineComponent({
name: "TBody",
props: _objectSpread({
classPrefix: String,
ellipsisOverlayClassName: String,
data: Array,
columns: Array,
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, _ref) {
var emit = _ref.emit;
var renderTNode = hooks_tnode.useTNodeJSX();
var _toRefs = VueCompositionAPI.toRefs(props),
data = _toRefs.data,
columns = _toRefs.columns,
rowKey = _toRefs.rowKey,
rowspanAndColspan = _toRefs.rowspanAndColspan;
var _useConfig = configProvider_useConfig.useConfig("table", props.locale),
t = _useConfig.t,
global = _useConfig.global;
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 = VueCompositionAPI.computed(function () {
return [tableBaseClass.body];
});
var isFixedLeftColumn = VueCompositionAPI.computed(function () {
return props.isWidthOverflow && !!props.columns.find(function (col) {
return col.fixed === "left";
});
});
var getTrListeners = function getTrListeners() {
var trListeners = {};
ROW_AND_TD_LISTENERS.forEach(function (eventName) {
var name = ["cell-click"].includes(eventName) ? eventName : "row-".concat(eventName);
trListeners[name] = function (context) {
emit(name, context);
};
});
return trListeners;
};
return {
t: t,
global: global,
tableFullRowClasses: tableFullRowClasses,
tbodyClasses: tbodyClasses,
tableBaseClass: tableBaseClass,
isFixedLeftColumn: isFixedLeftColumn,
skipSpansMap: skipSpansMap,
renderTNode: renderTNode,
getTrListeners: getTrListeners
};
},
render: function render(h) {
var _this = this,
_this$data,
_this$data2,
_this$data3,
_this$virtualConfig,
_this$virtualConfig2;
var renderEmpty = function renderEmpty(h2, columns) {
var showEmptyText = Boolean(_this.tableWidth && _this.tableWidth > 100) || "production" === "test";
var tableWidth = _this.bordered ? _this.tableWidth - 2 : _this.tableWidth;
return h("tr", {
"class": [_this.tableBaseClass.emptyRow, _defineProperty__default["default"]({}, _this.tableFullRowClasses.base, _this.isWidthOverflow)]
}, [h("td", {
"attrs": {
"colspan": columns.length
}
}, [h("div", {
"class": [_this.tableBaseClass.empty, _defineProperty__default["default"]({}, _this.tableFullRowClasses.innerFullRow, _this.isWidthOverflow)],
"style": _this.isWidthOverflow ? {
width: "".concat(tableWidth, "px")
} : {}
}, [showEmptyText ? _this.renderTNode("empty") || _this.t(_this.global.empty) : ""])])]);
};
var getFullRow = function getFullRow(h2, columnLength2, type) {
var tType = camelCase.camelCase(type);
var fullRowNode = _this.renderTNode(tType);
if (["", null, void 0, false].includes(fullRowNode)) return null;
var classes = [_this.tableFullRowClasses.base, _this.tableFullRowClasses[tType]];
var tableWidth = _this.bordered ? _this.tableWidth - 2 : _this.tableWidth;
return h("tr", {
"class": classes
}, [h("td", {
"attrs": {
"colspan": columnLength2
}
}, [h("div", {
"class": _defineProperty__default["default"]({}, _this.tableFullRowClasses.innerFullRow, _this.isFixedToLeft),
"style": _this.isFixedToLeft ? {
width: "".concat(tableWidth, "px")
} : {}
}, [h("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"];
(_this$data2 = this.data) === null || _this$data2 === void 0 || _this$data2.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 === null || row === void 0 ? void 0 : 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 on = _this.getTrListeners();
if (_this.handleRowMounted) {
on["row-mounted"] = _this.handleRowMounted;
}
var trNode = h(table_tr["default"], helper.helper([{
"scopedSlots": _this.$scopedSlots,
"key": get.get(row, _this.rowKey || "id")
}, {
"on": on
}, {}, {
"props": trProps
}]));
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(h, p);
expandedContent && trNodeList.push(expandedContent);
}
});
var list = [getFullRow(h, columnLength, "first-full-row"), trNodeList, getFullRow(h, columnLength, "last-full-row")];
var isEmpty = !((_this$data3 = this.data) !== null && _this$data3 !== void 0 && _this$data3.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 h("tbody", {
"class": this.tbodyClasses,
"style": _objectSpread({}, posStyle)
}, [isEmpty ? renderEmpty(h, this.columns) : list]);
}
});
exports.ROW_AND_TD_LISTENERS = ROW_AND_TD_LISTENERS;
exports["default"] = TBody;
exports.extendTableProps = extendTableProps;
//# sourceMappingURL=tbody.js.map