()
| 38 | class TableHeader extends Component { |
| 39 | |
| 40 | render() { |
| 41 | const { sortIndicator, sortList, onSort, reset, version, condensed, bordered, |
| 42 | expandedColumnHeaderComponent, noAnyExpand, toggleExpandAllChilds, expandAll |
| 43 | } = this.props; |
| 44 | const containerClasses = classSet( |
| 45 | 'react-bs-container-header', |
| 46 | 'table-header-wrapper', |
| 47 | this.props.headerContainerClass); |
| 48 | const customTableClasses = { |
| 49 | 'table-bordered': bordered |
| 50 | }; |
| 51 | if (condensed) { |
| 52 | if (Utils.isBootstrap4(version)) customTableClasses['table-sm'] = true; |
| 53 | else customTableClasses['table-condensed'] = true; |
| 54 | } |
| 55 | const tableClasses = classSet( |
| 56 | 'table', 'table-hover', customTableClasses, this.props.tableHeaderClass); |
| 57 | |
| 58 | const rowCount = Math.max(...React.Children.map(this.props.children, elm => |
| 59 | (elm && elm.props.row) ? Number(elm.props.row) : 0 |
| 60 | )); |
| 61 | |
| 62 | const rows = []; |
| 63 | let rowKey = 0; |
| 64 | |
| 65 | rows[0] = []; |
| 66 | rows[0].push( [ |
| 67 | this.props.expandColumnVisible && |
| 68 | this.props.expandColumnBeforeSelectColumn && |
| 69 | <ExpandRowHeaderColumn key='expandCol' rowCount={ rowCount + 1 } |
| 70 | expandedColumnHeaderComponent={ expandedColumnHeaderComponent } |
| 71 | noAnyExpand={ noAnyExpand } |
| 72 | expandAll={ expandAll } |
| 73 | toggleExpandAllChilds={ toggleExpandAllChilds }/> |
| 74 | ], [ |
| 75 | this.renderSelectRowHeader(rowCount + 1, rowKey++) |
| 76 | ], [ |
| 77 | this.props.expandColumnVisible && |
| 78 | !this.props.expandColumnBeforeSelectColumn && |
| 79 | <ExpandRowHeaderColumn key='expandCol' rowCount={ rowCount + 1 } |
| 80 | expandedColumnHeaderComponent={ expandedColumnHeaderComponent } |
| 81 | noAnyExpand={ noAnyExpand } |
| 82 | expandAll={ expandAll } |
| 83 | toggleExpandAllChilds={ toggleExpandAllChilds }/> |
| 84 | ]); |
| 85 | |
| 86 | React.Children.forEach(this.props.children, (elm) => { |
| 87 | if (elm === null || elm === undefined) { |
| 88 | // Skip null or undefined elements. |
| 89 | return; |
| 90 | } |
| 91 | const { dataField, dataSort } = elm.props; |
| 92 | const sort = getSortOrder(sortList, dataField, dataSort); |
| 93 | const rowIndex = elm.props.row ? Number(elm.props.row) : 0; |
| 94 | const rowSpan = elm.props.rowSpan ? Number(elm.props.rowSpan) : 1; |
| 95 | if (rows[rowIndex] === undefined) { |
| 96 | rows[rowIndex] = []; |
| 97 | } |
nothing calls this directly
no test coverage detected