"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = TableFooter;

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _react = _interopRequireWildcard(require("react"));

var _TableFooterRow = _interopRequireDefault(require("./TableFooterRow"));

var _TableContext = _interopRequireDefault(require("./TableContext"));

function appendExpandIconColumn(columns) {
  var expandIconCol = {
    key: 'expand-icon-placeholder',
    render: function render() {
      return null;
    }
  };
  return [expandIconCol].concat((0, _toConsumableArray2["default"])(columns));
}

function TableFooter(props) {
  var table = (0, _react.useContext)(_TableContext["default"]);
  var columnManager = table.columnManager,
      components = table.components;
  var _table$props = table.props,
      prefixCls = _table$props.prefixCls,
      data = _table$props.data,
      expandIconAsCell = _table$props.expandIconAsCell;
  var fixed = props.fixed,
      onHover = props.onHover;
  var leafColumns;

  if (fixed === 'left') {
    leafColumns = columnManager.leftLeafColumns();

    if (expandIconAsCell) {
      leafColumns = appendExpandIconColumn(leafColumns);
    }
  } else if (fixed === 'right') {
    leafColumns = columnManager.rightLeafColumns();
  } else {
    leafColumns = columnManager.leafColumns();

    if (expandIconAsCell) {
      leafColumns = appendExpandIconColumn(leafColumns);
    }
  }

  var FooterWrapper = components.footer.wrapper;
  return /*#__PURE__*/_react["default"].createElement(FooterWrapper, {
    className: "".concat(prefixCls, "-tfoot")
  }, /*#__PURE__*/_react["default"].createElement(_TableFooterRow["default"], {
    prefixCls: prefixCls,
    columns: leafColumns,
    components: components,
    fixed: fixed,
    data: data,
    onHover: columnManager.isAnyColumnsFixed() ? onHover : null
  }));
}

TableFooter.displayName = 'RcTableFooter';
//# sourceMappingURL=TableFooter.js.map
