import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
import _inherits from 'babel-runtime/helpers/inherits';
var _jsxFileName = 'src/table/TableHeader.jsx';
/**
 * 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 = function (_React$Component) {
    _inherits(TableHeader, _React$Component);

    function TableHeader(props, context) {
        _classCallCheck(this, TableHeader);

        var _this = _possibleConstructorReturn(this, (TableHeader.__proto__ || Object.getPrototypeOf(TableHeader)).call(this, props, context));

        _this.getTableHeader = function (el) {
            var tableHeaderRef = _this.props.tableHeaderRef;

            tableHeaderRef && tableHeaderRef(el);
        };

        return _this;
    }

    _createClass(TableHeader, [{
        key: 'render',
        value: function render() {
            var _props = this.props,
                theadClassName = _props.theadClassName,
                renderColumns = _props.renderColumns,
                handleSetSort = _props.handleSetSort,
                sortState = _props.sortState,
                onClickTh = _props.onClickTh,
                textCenter = _props.textCenter,
                tdWidthArray = _props.tdWidthArray,
                position = _props.position,
                prefixCls = _props.prefixCls,
                expandRow = _props.expandRow,
                handleBodyScrollLeft = _props.handleBodyScrollLeft,
                tableHeaderRef = _props.tableHeaderRef,
                tableHeaderRowRef = _props.tableHeaderRowRef,
                width = _props.width,
                height = _props.height,
                warpWidth = _props.warpWidth;


            var tableHeaderRowPrefixCls = 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, __source: {
                        fileName: _jsxFileName,
                        lineNumber: 66
                    },
                    __self: this
                },
                React.createElement(
                    'table',
                    { style: { width: width }, __source: {
                            fileName: _jsxFileName,
                            lineNumber: 71
                        },
                        __self: this
                    },
                    React.createElement(ColGroup, { renderColumns: renderColumns, __source: {
                            fileName: _jsxFileName,
                            lineNumber: 72
                        },
                        __self: this
                    }),
                    React.createElement(TableHeaderRow, Object.assign({}, tableHeaderRowProps, {
                        __source: {
                            fileName: _jsxFileName,
                            lineNumber: 73
                        },
                        __self: this
                    }))
                )
            );
        }
    }]);

    return TableHeader;
}(React.Component);

TableHeader.propTypes = {};
TableHeader.defaultProps = {};


export default TableHeader;