/**
 * tdesign v0.39.1-alpha.1
 * (c) 2022 tdesign
 * @license MIT
 */

import { h as helper } from '../_chunks/dep-1ec74b8b.js';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, h } from '@vue/composition-api';
import isString from 'lodash/isString';
import isFunction from 'lodash/isFunction';
import get from 'lodash/get';
import { formatRowAttributes } from './utils.js';
import { getColumnFixedStyles } from './hooks/useFixed.js';
import useClassName from './hooks/useClassName.js';
import '@babel/runtime/helpers/typeof';
import '@babel/runtime/helpers/slicedToArray';
import '../_common/js/log/index.js';
import '../_common/js/log/log.js';
import '../_common/js/utils/getScrollbarWidth.js';
import '../utils/dom.js';
import 'vue';
import 'raf';
import '../utils/easing.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import 'lodash/merge';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var TFoot = defineComponent({
  name: "TFoot",
  props: {
    isFixedHeader: Boolean,
    rowAndColFixedPosition: Map,
    footData: Array,
    columns: Array,
    rowAttributes: [Array, Object, Function],
    rowClassName: [Array, String, Object, Function]
  },
  setup: function setup(props, context) {
    var classnames = useClassName();

    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({}, classnames), {}, {
      renderTFootCell: renderTFootCell
    });
  },
  render: function render() {
    var _this = this;

    var h = arguments[0];
    if (!this.footData || !this.footData.length || !this.columns) return null;
    var theadClasses = [this.tableFooterClasses.footer, _defineProperty({}, this.tableFooterClasses.fixed, this.isFixedHeader)];
    return h("tfoot", {
      "ref": "tfooterRef",
      "class": theadClasses
    }, [this.footData.map(function (row, rowIndex) {
      var trAttributes = formatRowAttributes(_this.rowAttributes, {
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      });
      var customClasses = isFunction(_this.rowClassName) ? _this.rowClassName({
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      }) : _this.rowClassName;
      return h("tr", helper([{
        "key": rowIndex
      }, {
        "attrs": trAttributes
      }, {
        "class": customClasses
      }]), [_this.columns.map(function (col, colIndex) {
        var tdStyles = getColumnFixedStyles(col, colIndex, _this.rowAndColFixedPosition, _this.tableColFixedClasses);
        return h("td", {
          "key": col.colKey,
          "class": tdStyles.classes,
          "style": tdStyles.style
        }, [_this.renderTFootCell({
          row: row,
          rowIndex: rowIndex,
          col: col,
          colIndex: colIndex
        })]);
      })]);
    })]);
  }
});

export { TFoot as default };
//# sourceMappingURL=tfoot.js.map
