• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

gregnb / mui-datatables / #1880

01 Aug 2019 07:29AM UTC coverage: 74.963% (+3.7%) from 71.311%
#1880

push

gabrielliwerant
2.7.0

444 of 611 branches covered (72.67%)

Branch coverage included in aggregate %.

568 of 739 relevant lines covered (76.86%)

85.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/components/TableFilterList.js
1
import Chip from '@material-ui/core/Chip';
2
import { withStyles } from '@material-ui/core/styles';
3
import PropTypes from 'prop-types';
4
import React from 'react';
5

6
const defaultFilterListStyles = {
1✔
7
  root: {
8
    display: 'flex',
9
    justifyContent: 'left',
10
    flexWrap: 'wrap',
11
    margin: '0px 16px 0px 16px',
12
  },
13
  chip: {
14
    margin: '8px 8px 0px 0px',
15
  },
16
};
17

18
class TableFilterList extends React.Component {
19
  static propTypes = {
20
    /** Data used to filter table against */
21
    filterList: PropTypes.array.isRequired,
22
    /** Filter List value renderers */
23
    filterListRenderers: PropTypes.array.isRequired,
24
    /** Columns used to describe table */
25
    columnNames: PropTypes.PropTypes.arrayOf(
26
      PropTypes.oneOfType([
27
        PropTypes.string,
28
        PropTypes.shape({ name: PropTypes.string.isRequired, filterType: PropTypes.string }),
29
      ]),
30
    ).isRequired,
31
    /** Callback to trigger filter update */
32
    onFilterUpdate: PropTypes.func,
33
    /** Extend the style applied to components */
34
    classes: PropTypes.object,
35
  };
36

37
  render() {
38
    const { classes, filterList, filterUpdate, filterListRenderers, columnNames } = this.props;
19✔
39

40
    return (
19✔
41
      <div className={classes.root}>
42
        {filterList.map((item, index) => {
43
          if (columnNames[index].filterType === 'custom' && filterListRenderers[index](item)) {
95!
44
            return (
×
45
              <Chip
46
                label={filterListRenderers[index](item)}
47
                key={index}
48
                onDelete={filterUpdate.bind(null, index, [], columnNames[index].name, columnNames[index].filterType)}
49
                className={classes.chip}
50
              />
51
            );
52
          }
53

54
          return item.map((data, colIndex) => (
95✔
55
            <Chip
2✔
56
              label={filterListRenderers[index](data)}
57
              key={colIndex}
58
              onDelete={filterUpdate.bind(null, index, data, columnNames[index].name, 'checkbox')}
59
              className={classes.chip}
60
            />
61
          ));
62
        })}
63
      </div>
64
    );
65
  }
66
}
67

68
export default withStyles(defaultFilterListStyles, { name: 'MUIDataTableFilterList' })(TableFilterList);
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc