/**
 * @file Thead component
 * @author liangxiaojun(liangxiaojun@derbysoft.com)
 */

import React, {Component} from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

import TableHeader from '../_TableHeader';

class Thead extends Component {

    constructor(props, ...restArgs) {
        super(props, ...restArgs);
    }

    render() {

        const {className, style, columns, sort, sortAscIconCls, sortDescIconCls, hidden, onSort} = this.props,

            theadClassName = classNames('thead', {
                hidden: hidden,
                [className]: className
            });

        return (
            <thead className={theadClassName}
                   style={style}>
                <tr>
                    {
                        columns.map((item, index) => {

                            const headerClassName = (item.sortable ? 'sortable ' : '')
                                + (item.headerClassName ? ' ' + item.headerClassName : '');

                            return (
                                <TableHeader key={index}
                                             className={headerClassName}
                                             style={item.headerStyle}
                                             header={item.header}
                                             colIndex={index}
                                             sortable={item.sortable}
                                             sortProp={item.sortProp}
                                             sort={sort}
                                             sortAscIconCls={sortAscIconCls}
                                             sortDescIconCls={sortDescIconCls}
                                             hidden={hidden}
                                             onSort={() => {
                                                 onSort(item);
                                             }}/>
                            );

                        })
                    }
                </tr>
            </thead>
        );

    }
};

Thead.propTypes = {

    className: PropTypes.string,
    style: PropTypes.object,

    columns: PropTypes.array,
    sort: PropTypes.object,
    sortAscIconCls: PropTypes.string,
    sortDescIconCls: PropTypes.string,
    hidden: PropTypes.bool,

    onSort: PropTypes.func

};

Thead.defaultProps = {

    className: null,
    style: null,

    columns: [],
    sort: null,
    hidden: false

};

export default Thead;
@@ -237,16 +237,78 @@
 ader';%0A%0A
+import PureRender from '../_vendors/PureRender';%0A%0A@PureRender%0A
 class Th
@@ -2150,24 +2150,66 @@
 %0A%0A    %7D%0A%7D;%0A%0A
+process.env.NODE_ENV !== 'production' && (
 Thead.propTy
@@ -2473,16 +2473,17 @@
 .func%0A%0A%7D
+)
 ;%0A%0AThead
@@ -2504,48 +2504,8 @@
 = %7B%0A
-%0A    className: null,%0A    style: null,%0A%0A
     
@@ -2521,24 +2521,8 @@
 %5B%5D,%0A
-    sort: null,%0A
     
@@ -2535,17 +2535,16 @@
 : false%0A
-%0A
 %7D;%0A%0Aexpo

update Thead