UNPKG

tdesign-vue-next

Version:
145 lines (141 loc) 6.25 kB
/** * tdesign v1.11.5 * (c) 2025 tdesign * @license MIT */ import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, toRefs, createVNode, mergeProps, h } from 'vue'; import { isFunction, isString, get } from 'lodash-es'; import { formatRowAttributes, formatRowClassNames } from './utils.js'; import { getColumnFixedStyles } from './hooks/useFixed.js'; import { u as useTNodeJSX } from '../_chunks/dep-7c56a7f5.js'; import useRowspanAndColspan, { getCellKey } from './hooks/useRowspanAndColspan.js'; import useClassName from './hooks/useClassName.js'; import '@babel/runtime/helpers/typeof'; import '@babel/runtime/helpers/slicedToArray'; import '../_chunks/dep-92106726.js'; import '../_chunks/dep-3bde6c25.js'; import '../_chunks/dep-56c3d46e.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../utils/dom.js'; import '../_chunks/dep-caecb55d.js'; import '../utils/render-tnode.js'; import '../hooks/useConfig.js'; import '../config-provider/hooks/useConfig.js'; import '../config-provider/utils/context.js'; import '../_chunks/dep-c75b9b8e.js'; import 'dayjs'; 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(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 TFoot = defineComponent({ name: "TFoot", props: { rowKey: String, isFixedHeader: Boolean, rowAndColFixedPosition: Map, footData: Array, columns: Array, rowAttributes: [Array, Object, Function], rowClassName: [Array, String, Object, Function], thWidthList: [Object], footerSummary: [String, Function], rowspanAndColspanInFooter: Function, virtualScroll: Boolean }, setup: function setup(props, context) { var renderTNode = useTNodeJSX(); var classnames = useClassName(); var _toRefs = toRefs(props), footData = _toRefs.footData, columns = _toRefs.columns, rowKey = _toRefs.rowKey, rowspanAndColspanInFooter = _toRefs.rowspanAndColspanInFooter; var _useRowspanAndColspan = useRowspanAndColspan(footData, columns, rowKey, rowspanAndColspanInFooter), skipSpansMap = _useRowspanAndColspan.skipSpansMap; var renderTFootCell = function renderTFootCell(p) { var col = p.col, row = p.row; if (isFunction(col.foot)) { return col.foot(h, p); } if (isString(col.foot) && context.slots[col.foot]) { return context.slots[col.foot](p) || col.foot; } return col.foot || get(row, col.colKey); }; return _objectSpread(_objectSpread({ skipSpansMap: skipSpansMap }, classnames), {}, { renderTFootCell: renderTFootCell, renderTNode: renderTNode }); }, render: function render() { var _this$footData, _this = this; if (!this.columns) return null; var theadClasses = [this.tableFooterClasses.footer, _defineProperty({}, this.tableFooterClasses.fixed, this.isFixedHeader)]; var footerDomList = (_this$footData = this.footData) === null || _this$footData === void 0 ? void 0 : _this$footData.map(function (row, rowIndex) { var trAttributes = formatRowAttributes(_this.rowAttributes, { row: row, rowIndex: rowIndex, type: "foot" }); var customClasses = formatRowClassNames(_this.rowClassName, { row: row, rowIndex: rowIndex, type: "foot" }, _this.rowKey || "id"); return createVNode("tr", mergeProps(trAttributes, { "key": rowIndex, "class": customClasses }), [_this.columns.map(function (col, colIndex) { var _this$thWidthList; var cellSpans = {}; var spanState = null; if (_this.skipSpansMap.size) { var _spanState, _spanState2; var cellKey = getCellKey(row, _this.rowKey, col.colKey, colIndex); spanState = _this.skipSpansMap.get(cellKey) || {}; ((_spanState = spanState) === null || _spanState === void 0 ? void 0 : _spanState.rowspan) > 1 && (cellSpans.rowspan = spanState.rowspan); ((_spanState2 = spanState) === null || _spanState2 === void 0 ? void 0 : _spanState2.colspan) > 1 && (cellSpans.colspan = spanState.colspan); if (spanState.skipped) return null; } var tdStyles = getColumnFixedStyles(col, colIndex, _this.rowAndColFixedPosition, _this.tableColFixedClasses); var style = _objectSpread({}, tdStyles.style); if ((_this$thWidthList = _this.thWidthList) !== null && _this$thWidthList !== void 0 && _this$thWidthList[col.colKey]) { style.width = "".concat(_this.thWidthList[col.colKey], "px"); } return createVNode("td", mergeProps(_objectSpread({ key: col.colKey }, cellSpans), { "class": tdStyles.classes, "style": style }), [_this.renderTFootCell({ row: row, rowIndex: rowIndex, col: col, colIndex: colIndex })]); })]); }); var footerSummary = this.renderTNode("footerSummary"); if (!footerSummary && (!this.footData || !this.footData.length)) return null; return createVNode("tfoot", { "ref": "tFooterRef", "class": theadClasses, "style": { visibility: this.virtualScroll ? "hidden" : "visible" } }, [footerSummary && createVNode("tr", { "class": this.tableFullRowClasses.base }, [createVNode("td", { "colspan": this.columns.length }, [createVNode("div", { "class": this.tableFullRowClasses.innerFullElement }, [footerSummary])])]), footerDomList]); } }); export { TFoot as default }; //# sourceMappingURL=tfoot.js.map