UNPKG

tdesign-vue

Version:
155 lines (151 loc) 6.4 kB
/** * tdesign v1.15.0 * (c) 2026 tdesign * @license MIT */ import { h as helper } from '../_chunks/dep-53490f85.js'; import _defineProperty from '@babel/runtime/helpers/defineProperty'; import { defineComponent, toRefs, h } from '@vue/composition-api'; import { isFunction, isString, get } from 'lodash-es'; import { formatRowAttributes, formatRowClassNames } from './utils.js'; import { getColumnFixedStyles } from './hooks/useFixed.js'; import { useTNodeJSX } from '../hooks/tnode.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 '../_common/js/log/log.js'; import '../_common/js/utils/getScrollbarWidth.js'; import '../_common/js/utils/helper.js'; import '@babel/runtime/helpers/toConsumableArray'; import '@babel/runtime/helpers/objectWithoutProperties'; import '../utils/dom.js'; import 'vue'; import 'raf'; import '../utils/easing.js'; import '../hooks/render-tnode.js'; import '../config-provider/useConfig.js'; import '../config-provider/context.js'; import '../_common/js/global-config/default-config.js'; import '../_common/js/global-config/locale/zh_CN.js'; import '../_chunks/dep-e5d497fb.js'; import '../_chunks/dep-1618e1d6.js'; import 'dayjs'; import '../_common/js/global-config/t.js'; 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 }, 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); } 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; var h = arguments[0]; 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 h("tr", helper([{ "key": rowIndex }, { "attrs": trAttributes }, { "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 h("td", helper([{}, { "attrs": _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 h("tfoot", { "ref": "tFooterRef", "class": theadClasses }, [footerSummary && h("tr", { "class": this.tableFullRowClasses.base }, [h("td", { "attrs": { "colspan": this.columns.length } }, [h("div", { "class": this.tableFullRowClasses.innerFullElement }, [footerSummary])])]), footerDomList]); } }); export { TFoot as default }; //# sourceMappingURL=tfoot.js.map