import {autobind} from "core-decorators"; import i18n from "i18next"; import {values} from "lodash"; import {observer} from "mobx-react"; import * as React from "react"; import {LineProps} from "./line"; import {ListBase, ListBaseProps} from "./list-base"; const TABLE_CSS_CLASS = "mdl-data-table mdl-js-data-table mdl-shadow--2dp "; export const TABLE_CELL_CLASS = "mdl-data-table__cell--non-numeric"; export interface TableProps> extends ListBaseProps { columns: {[field: string]: string}; data?: T[]; } @autobind @observer export class Table, AP> extends ListBase & AP> { protected get data() { return this.props.data || []; } protected renderTableHeader() { return ( {values(this.props.columns).map(col => ( {i18n.t(col)} ))} ); } private renderTableBody() { const {LineComponent, lineProps} = this.props; return ( {this.displayedData.map((item, idx) => ( ))} ); } render() { return ( {this.renderTableHeader()} {this.renderTableBody()} {this.renderManualFetch()}
); } } export function tableFor>(props: TableProps) { const List = Table as any; return ; };