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

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

import Th from '../_Th';

class Thead extends Component {

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

    render() {

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

        return (
            <thead className={classNames({
                [className]: className
            })}
                   style={style}>
                <tr>
                    {
                        columns && columns.map((item, index) => item ?
                            <Th key={index}
                                className={item.headerClassName}
                                style={item.headerStyle}
                                renderer={item.headerRenderer}
                                colIndex={index}
                                data={data}
                                sortable={item.sortable}
                                sortProp={item.sortProp}
                                sort={sort}
                                sortAscIconCls={sortAscIconCls}
                                sortDescIconCls={sortDescIconCls}
                                onSort={() => onSort && onSort(item)}/>
                            :
                            null
                        )
                    }
                </tr>
            </thead>
        );

    }
}

Thead.propTypes = {

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

    columns: PropTypes.array,
    data: PropTypes.array,
    sort: PropTypes.object,
    sortAscIconCls: PropTypes.string,
    sortDescIconCls: PropTypes.string,

    onSort: PropTypes.func

};

Thead.defaultProps = {
    sortAscIconCls: 'fas fa-angle-up',
    sortDescIconCls: 'fas fa-angle-down'
};

export default Thead;

@@ -217,16 +217,104 @@
 ../_Th';
+%0Aimport Util from '../_vendors/Util';%0Aimport SortingType from '../_statics/SortingType';
 %0A%0Aclass 
@@ -500,19 +500,57 @@
 ata,
- sort
+%0A            sorting, defaultSortingType
 , sort
+ing
 AscI
@@ -557,24 +557,27 @@
 conCls, sort
+ing
 DescIconCls,
@@ -595,16 +595,22 @@
   onSort
+Change
 %0A       
@@ -1252,27 +1252,20 @@
 sort
-able=%7Bitem.sortable
+ing=%7Bsorting
 %7D%0A  
@@ -1298,31 +1298,73 @@
     
-sortProp=%7Bitem.sortProp
+defaultSortingType=%7Bitem.defaultSortingType %7C%7C defaultSortingType
 %7D%0A  
@@ -1397,22 +1397,48 @@
     sort
-=%7Bsort
+ingAscIconCls=%7BsortingAscIconCls
 %7D%0A      
@@ -1459,33 +1459,37 @@
             sort
-A
+ingDe
 scIconCls=%7BsortA
@@ -1483,25 +1483,29 @@
 conCls=%7Bsort
-A
+ingDe
 scIconCls%7D%0A 
@@ -1543,36 +1543,27 @@
 sort
-DescIconCls=%7BsortDescIconCls
+able=%7Bitem.sortable
 %7D%0A  
@@ -1596,44 +1596,97 @@
     
-onSort=%7B() =%3E onSort && onSort(item)
+sortingProp=%7Bitem.sortingProp%7D%0A                                onSortChange=%7BonSortChange
 %7D/%3E%0A
@@ -2005,44 +2005,261 @@
 ay,%0A
+%0A
     
-sort: PropTypes.object,%0A    sort
+/**%0A     * sorting%0A     */%0A    sorting: PropTypes.shape(%7B%0A        prop: PropTypes.string,%0A        type: PropTypes.oneOf(Util.enumerateValue(SortingType))%0A    %7D),%0A    defaultSortingType: PropTypes.oneOf(Util.enumerateValue(SortingType)),%0A    sorting
 AscI
@@ -2284,32 +2284,35 @@
 string,%0A    sort
+ing
 DescIconCls: Pro
@@ -2337,16 +2337,22 @@
   onSort
+Change
 : PropTy
@@ -2388,24 +2388,65 @@
 ops = %7B%0A
+    defaultSortingType: SortingType.ASC,%0A
     sort
 AscIconC
@@ -2437,16 +2437,19 @@
     sort
+ing
 AscIconC
@@ -2479,16 +2479,19 @@
     sort
+ing
 DescIcon

update Thead