"use strict";

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

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

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

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

var _measureScrollbar = _interopRequireDefault(require("../../_util/measureScrollbar"));

var _BaseTable = _interopRequireDefault(require("./BaseTable"));

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

function FootTable(props) {
  var table = (0, _react.useContext)(_TableContext["default"]);
  var _table$props = table.props,
      prefixCls = _table$props.prefixCls,
      scroll = _table$props.scroll,
      showHeader = _table$props.showHeader;
  var columns = props.columns,
      fixed = props.fixed,
      tableClassName = props.tableClassName,
      handleBodyScrollLeft = props.handleBodyScrollLeft,
      expander = props.expander;
  var saveRef = table.saveRef,
      columnManager = table.columnManager;
  var useFixedHeader = table.props.useFixedHeader;
  var footStyle = {};

  if (scroll.y) {
    useFixedHeader = true; // Add negative margin bottom for scroll bar overflow bug

    var scrollbarWidth = (0, _measureScrollbar["default"])('horizontal');

    if (scrollbarWidth > 0 && !fixed) {
      footStyle.marginBottom = "-".concat(scrollbarWidth, "px");
      footStyle.paddingBottom = '0px';
    }
  }

  if (!useFixedHeader || !showHeader || !columnManager.hasFooter()) {
    return null;
  }

  return /*#__PURE__*/_react["default"].createElement("div", {
    key: "footTable",
    ref: fixed ? null : saveRef('footTable'),
    className: "".concat(prefixCls, "-column-footer"),
    style: footStyle,
    onScroll: handleBodyScrollLeft
  }, /*#__PURE__*/_react["default"].createElement(_BaseTable["default"], {
    tableClassName: tableClassName,
    hasHead: false,
    hasBody: false,
    hasFoot: true,
    fixed: fixed,
    columns: columns,
    expander: expander
  }));
}
//# sourceMappingURL=FootTable.js.map
