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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var helper = require('../_chunks/dep-33ee4bce.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var VueCompositionAPI = require('@vue/composition-api');
var isString = require('lodash/isString');
var isFunction = require('lodash/isFunction');
var get = require('lodash/get');
var table_utils = require('./utils.js');
var table_hooks_useFixed = require('./hooks/useFixed.js');
var table_hooks_useClassName = require('./hooks/useClassName.js');
require('@babel/runtime/helpers/typeof');
require('@babel/runtime/helpers/slicedToArray');
require('../_common/js/log/log.js');
require('../_common/js/utils/getScrollbarWidth.js');
require('../utils/dom.js');
require('vue');
require('raf');
require('../utils/easing.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('lodash/merge');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);
var get__default = /*#__PURE__*/_interopDefaultLegacy(get);

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__default["default"](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 = VueCompositionAPI.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 = table_hooks_useClassName["default"]();

    var renderTFootCell = function renderTFootCell(p) {
      var col = p.col,
          row = p.row;

      if (isFunction__default["default"](col.foot)) {
        return col.foot(VueCompositionAPI.h, p);
      }

      if (isString__default["default"](col.foot) && context.slots[col.foot]) {
        return context.slots[col.foot](p);
      }

      return col.foot || get__default["default"](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__default["default"]({}, this.tableFooterClasses.fixed, this.isFixedHeader)];
    return h("tfoot", {
      "ref": "tfooterRef",
      "class": theadClasses
    }, [this.footData.map(function (row, rowIndex) {
      var trAttributes = table_utils.formatRowAttributes(_this.rowAttributes, {
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      });
      var customClasses = isFunction__default["default"](_this.rowClassName) ? _this.rowClassName({
        row: row,
        rowIndex: rowIndex,
        type: "foot"
      }) : _this.rowClassName;
      return h("tr", helper.helper([{
        "key": rowIndex
      }, {
        "attrs": trAttributes
      }, {
        "class": customClasses
      }]), [_this.columns.map(function (col, colIndex) {
        var tdStyles = table_hooks_useFixed.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
        })]);
      })]);
    })]);
  }
});

exports["default"] = TFoot;
//# sourceMappingURL=tfoot.js.map
