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

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

/**
 * 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);

  var _super = _createSuper(TableHeader);

  function TableHeader() {
    var _this;

    _classCallCheck(this, TableHeader);

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

    _this = _super.call.apply(_super, [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 /*#__PURE__*/React.createElement("div", {
        style: {
          width: warpWidth
        },
        className: tableHeaderRowPrefixCls,
        onScroll: handleBodyScrollLeft,
        ref: this.getTableHeader
      }, /*#__PURE__*/React.createElement("table", {
        style: {
          width: width
        }
      }, /*#__PURE__*/React.createElement(ColGroup, {
        renderColumns: renderColumns
      }), /*#__PURE__*/React.createElement(TableHeaderRow, tableHeaderRowProps)));
    }
  }]);

  return TableHeader;
}(React.Component);

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

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

export default TableHeader;