import * as React from "react"; import { MmuiDefaultSortedTableProps, MmuiDefaultSortedTableState, MmuiDefaultTableSorted, } from "../../mmui-react-component"; export interface MmuiBlueDefaultTableSortedProps extends MmuiDefaultSortedTableProps { updateTransform: (t) => void; } export interface MmuiBlueDefaultTableSortedState extends MmuiDefaultSortedTableState { order?: any; } export class MmuiBlueDefaultTableSorted < P extends MmuiBlueDefaultTableSortedProps, S extends MmuiBlueDefaultTableSortedState > extends MmuiDefaultTableSorted { constructor(props) { super(props); this.tableClassNameList = ['mm-table']; } getOrderDirection(col) { if (col !== this.state.order.column) return null; let sortSymbol; if (this.state.order.direction == 'ASC') { sortSymbol = ; } else { sortSymbol = ; } return sortSymbol; } getColumnHeaderRender(colKey, index) { const records = this.props.records, classList: Array = [], column = this.state.order.column; let aria = this.state.order.direction === 'ASC' ? 'ascending' : 'descending'; if (colKey !== column) { aria = 'none' } if (records.length > 0) { let value; for (let i = 0; i < records.length; i++) { value = records[i][colKey]; if (value !== undefined && value !== null) { if (typeof value === 'number') { classList.push('col--right'); } break; } } } return ( // @ts-ignore this.handleSortOrderChange(e, colKey)}> {this.props.columns[colKey]} {this.getOrderDirection(colKey)} ); } }