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

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

import TableHeader from '../_TableHeader';

export default class Thead extends Component {

    static 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

    };
    static defaultProps = {

        className: null,
        style: null,

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

    };

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

    render() {

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

        return (
            <thead className={'thead' + (hidden ? ' hidden' : '') + (className ? ' ' + className : '')}
                   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>
        );

    }
};
@@ -204,23 +204,8 @@
 ';%0A%0A
-export default 
 clas
@@ -237,476 +237,8 @@
  %7B%0A%0A
-    static propTypes = %7B%0A%0A        className: PropTypes.string,%0A        style: PropTypes.object,%0A%0A        columns: PropTypes.array,%0A        sort: PropTypes.object,%0A        sortAscIconCls: PropTypes.string,%0A        sortDescIconCls: PropTypes.string,%0A        hidden: PropTypes.bool,%0A%0A        onSort: PropTypes.func%0A%0A    %7D;%0A    static defaultProps = %7B%0A%0A        className: null,%0A        style: null,%0A%0A        columns: %5B%5D,%0A        sort: null,%0A        hidden: false%0A%0A    %7D;%0A%0A
     
@@ -1972,8 +1972,430 @@
     %7D%0A%7D;
+%0A%0AThead.propTypes = %7B%0A%0A    className: PropTypes.string,%0A    style: PropTypes.object,%0A%0A    columns: PropTypes.array,%0A    sort: PropTypes.object,%0A    sortAscIconCls: PropTypes.string,%0A    sortDescIconCls: PropTypes.string,%0A    hidden: PropTypes.bool,%0A%0A    onSort: PropTypes.func%0A%0A%7D;%0A%0AThead.defaultProps = %7B%0A%0A    className: null,%0A    style: null,%0A%0A    columns: %5B%5D,%0A    sort: null,%0A    hidden: false%0A%0A%7D;%0A%0Aexport default Thead;

update Thead