import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

/**
 * TableHeader.jsx
 *
 * @Author: apple
 * @Date: 2018/3/7 14:31
 */
import React from 'react';
import TableHeaderRow from './TableHeaderRow';
import ColGroup from './colGroup';
/**
 * @ignore
 * */

var TableHeader =
/*#__PURE__*/
function (_React$Component) {
  _inherits(TableHeader, _React$Component);

  function TableHeader() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, TableHeader);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(TableHeader)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_this), "getTableHeader", function (el) {
      var tableHeaderRef = _this.props.tableHeaderRef;
      tableHeaderRef && tableHeaderRef(el);
    });

    return _this;
  }

  _createClass(TableHeader, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          theadClassName = _this$props.theadClassName,
          renderColumns = _this$props.renderColumns,
          handleSetSort = _this$props.handleSetSort,
          sortState = _this$props.sortState,
          onClickTh = _this$props.onClickTh,
          textCenter = _this$props.textCenter,
          tdWidthArray = _this$props.tdWidthArray,
          position = _this$props.position,
          prefixCls = _this$props.prefixCls,
          expandRow = _this$props.expandRow,
          handleBodyScrollLeft = _this$props.handleBodyScrollLeft,
          tableHeaderRef = _this$props.tableHeaderRef,
          tableHeaderRowRef = _this$props.tableHeaderRowRef,
          width = _this$props.width,
          height = _this$props.height,
          warpWidth = _this$props.warpWidth;
      var tableHeaderRowPrefixCls = "".concat(prefixCls, "-header");
      var tableHeaderRowProps = {
        theadClassName: theadClassName,
        renderColumns: renderColumns,
        handleSetSort: handleSetSort,
        sortState: sortState,
        onClickTh: onClickTh,
        textCenter: textCenter,
        tdWidthArray: tdWidthArray,
        position: position,
        prefixCls: tableHeaderRowPrefixCls,
        tableHeaderRef: tableHeaderRef,
        tableHeaderRowRef: tableHeaderRowRef,
        expandRow: expandRow,
        height: height
      };
      return React.createElement("div", {
        style: {
          width: warpWidth
        },
        className: tableHeaderRowPrefixCls,
        onScroll: handleBodyScrollLeft,
        ref: this.getTableHeader
      }, React.createElement("table", {
        style: {
          width: width
        }
      }, React.createElement(ColGroup, {
        renderColumns: renderColumns
      }), React.createElement(TableHeaderRow, tableHeaderRowProps)));
    }
  }]);

  return TableHeader;
}(React.Component);

_defineProperty(TableHeader, "propTypes", {});

_defineProperty(TableHeader, "defaultProps", {});

export default TableHeader;