import React, { useContext } from 'react';
import BaseTable from './BaseTable';
import TableContext from './TableContext';
export default function HeadTable(props) {
  var table = useContext(TableContext);
  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;
  var useFixedHeader = table.props.useFixedHeader;
  var headStyle = {};

  if (scroll.y) {
    useFixedHeader = true; // Add negative margin bottom for scroll bar overflow bug
    // const scrollbarWidth = measureScrollbar('horizontal');
    // if (scrollbarWidth > 0 && !fixed) {

    if (!fixed) {
      headStyle.marginBottom = 0;
      headStyle.paddingBottom = 0;
      headStyle.overflow = 'hidden';
    }
  }

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

  return /*#__PURE__*/React.createElement("div", {
    key: "headTable",
    ref: fixed ? null : saveRef('headTable'),
    className: "".concat(prefixCls, "-header"),
    style: headStyle,
    onScroll: handleBodyScrollLeft
  }, /*#__PURE__*/React.createElement(BaseTable, {
    tableClassName: tableClassName,
    hasHead: true,
    hasBody: false,
    hasFoot: false,
    fixed: fixed,
    columns: columns,
    expander: expander
  }));
}
HeadTable.displayName = 'RcHeadTable';
//# sourceMappingURL=HeadTable.js.map
