import * as React from 'react'; import { ColumnModel, ColumnType } from './columnModel'; import { withStyles, WithStyles, createStyles, Theme } from '@material-ui/core/styles'; import TableCell from '@material-ui/core/TableCell'; import TableRow from '@material-ui/core/TableRow'; import Input from '@material-ui/core/Input'; import { Select, FormControl, InputLabel, MenuItem } from '@material-ui/core'; const styles = (theme: Theme) => createStyles({ container: { display: 'flex', flexWrap: 'wrap', }, input: { margin: theme.spacing.unit, }, }); interface IEnhancedTableFilterComponentProps extends WithStyles { onFilterChanged: (property: string, filterTerm: string) => void; filter: { [property: string]: string }; columns: ColumnModel<{}>[]; enableSelection?: boolean; } class EnhancedTableFilterComponent extends React.Component { createFilterHandler = (property: string) => (event: React.ChangeEvent) => { this.props.onFilterChanged && this.props.onFilterChanged(property, event.target.value); }; render() { const { columns, filter, classes } = this.props; return ( { this.props.enableSelection ? : null } { columns.map(col => { const style = col.width ? { width: col.width } : {}; return ( { col.disableFilter || (col.type === ColumnType.custom) ? null : (col.type === ColumnType.boolean) ? : } ); }, this) } ); } } export const EnhancedTableFilter = withStyles(styles)(EnhancedTableFilterComponent);