mui-table-2026 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/index.cjs +148 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.esm.js +124 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -0
- package/package.json +74 -19
- package/src/MUIDataTable.js +213 -217
- package/src/components/TableBody.js +41 -38
- package/src/components/TableFilter.js +98 -90
- package/src/components/TableToolbar.js +134 -126
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import PropTypes from
|
|
3
|
-
import { Typography } from
|
|
4
|
-
import { TableBody as MuiTableBody } from
|
|
5
|
-
import TableBodyCell from
|
|
6
|
-
import TableBodyRow from
|
|
7
|
-
import TableSelectCell from
|
|
8
|
-
import { withStyles } from
|
|
9
|
-
import cloneDeep from
|
|
10
|
-
import { getPageValue } from
|
|
11
|
-
import clsx from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Typography } from "@mui/material";
|
|
4
|
+
import { TableBody as MuiTableBody } from "@mui/material";
|
|
5
|
+
import TableBodyCell from "./TableBodyCell";
|
|
6
|
+
import TableBodyRow from "./TableBodyRow";
|
|
7
|
+
import TableSelectCell from "./TableSelectCell";
|
|
8
|
+
import { withStyles } from "tss-react/mui";
|
|
9
|
+
import { cloneDeep } from "lodash-es";
|
|
10
|
+
import { getPageValue } from "../utils";
|
|
11
|
+
import clsx from "clsx";
|
|
12
12
|
|
|
13
13
|
const defaultBodyStyles = (theme) => ({
|
|
14
14
|
root: {},
|
|
15
15
|
emptyTitle: {
|
|
16
|
-
textAlign:
|
|
16
|
+
textAlign: "center",
|
|
17
17
|
},
|
|
18
18
|
lastStackedCell: {
|
|
19
|
-
[theme.breakpoints.down(
|
|
20
|
-
|
|
21
|
-
borderBottom:
|
|
19
|
+
[theme.breakpoints.down("md")]: {
|
|
20
|
+
"& td:last-child": {
|
|
21
|
+
borderBottom: "none",
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
24
|
},
|
|
25
25
|
lastSimpleCell: {
|
|
26
|
-
[theme.breakpoints.down(
|
|
27
|
-
|
|
28
|
-
borderBottom:
|
|
26
|
+
[theme.breakpoints.down("sm")]: {
|
|
27
|
+
"& td:last-child": {
|
|
28
|
+
borderBottom: "none",
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
},
|
|
@@ -76,7 +76,7 @@ class TableBody extends React.Component {
|
|
|
76
76
|
const toIndex = Math.min(count, (highestPageInRange + 1) * rowsPerPage);
|
|
77
77
|
|
|
78
78
|
if (page > highestPageInRange) {
|
|
79
|
-
console.warn(
|
|
79
|
+
console.warn("Current page is out of range, using the highest page that is in range instead.");
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
for (let rowIndex = fromIndex; rowIndex < count && rowIndex < toIndex; rowIndex++) {
|
|
@@ -170,25 +170,25 @@ class TableBody extends React.Component {
|
|
|
170
170
|
curIndex = data.index > curIndex ? curIndex + 1 : curIndex - 1;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
this.props.selectRowUpdate(
|
|
173
|
+
this.props.selectRowUpdate("cell", data, shiftAdjacentRows);
|
|
174
174
|
};
|
|
175
175
|
|
|
176
176
|
handleRowClick = (row, data, event) => {
|
|
177
177
|
// Don't trigger onRowClick if the event was actually the expandable icon.
|
|
178
178
|
if (
|
|
179
|
-
event.target.id ===
|
|
180
|
-
(event.target.nodeName ===
|
|
179
|
+
event.target.id === "expandable-button" ||
|
|
180
|
+
(event.target.nodeName === "path" && event.target.parentNode.id === "expandable-button")
|
|
181
181
|
) {
|
|
182
182
|
return;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
// Don't trigger onRowClick if the event was actually a row selection via checkbox
|
|
186
|
-
if (event.target.id && event.target.id.startsWith(
|
|
186
|
+
if (event.target.id && event.target.id.startsWith("MUIDataTableSelectCell")) return;
|
|
187
187
|
|
|
188
188
|
// Check if we should toggle row select when row is clicked anywhere
|
|
189
189
|
if (
|
|
190
190
|
this.props.options.selectableRowsOnClick &&
|
|
191
|
-
this.props.options.selectableRows !==
|
|
191
|
+
this.props.options.selectableRows !== "none" &&
|
|
192
192
|
this.isRowSelectable(data.dataIndex, this.props.selectedRows)
|
|
193
193
|
) {
|
|
194
194
|
const selectRow = { index: data.rowIndex, dataIndex: data.dataIndex };
|
|
@@ -232,7 +232,7 @@ class TableBody extends React.Component {
|
|
|
232
232
|
tableId,
|
|
233
233
|
} = this.props;
|
|
234
234
|
const tableRows = this.buildRows();
|
|
235
|
-
const visibleColCnt = columns.filter((c) => c.display ===
|
|
235
|
+
const visibleColCnt = columns.filter((c) => c.display === "true").length;
|
|
236
236
|
|
|
237
237
|
return (
|
|
238
238
|
<MuiTableBody>
|
|
@@ -244,7 +244,7 @@ class TableBody extends React.Component {
|
|
|
244
244
|
return options.customRowRender(row, dataIndex, rowIndex);
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
let isRowSelected = options.selectableRows !==
|
|
247
|
+
let isRowSelected = options.selectableRows !== "none" ? this.isRowSelected(dataIndex) : false;
|
|
248
248
|
let isRowSelectable = this.isRowSelectable(dataIndex);
|
|
249
249
|
let bodyClasses = options.setRowProps ? options.setRowProps(row, dataIndex, rowIndex) || {} : {};
|
|
250
250
|
|
|
@@ -260,14 +260,15 @@ class TableBody extends React.Component {
|
|
|
260
260
|
onClick={this.handleRowClick.bind(null, row, { rowIndex, dataIndex })}
|
|
261
261
|
className={clsx({
|
|
262
262
|
[classes.lastStackedCell]:
|
|
263
|
-
options.responsive ===
|
|
264
|
-
options.responsive ===
|
|
265
|
-
options.responsive ===
|
|
266
|
-
[classes.lastSimpleCell]: options.responsive ===
|
|
263
|
+
options.responsive === "vertical" ||
|
|
264
|
+
options.responsive === "stacked" ||
|
|
265
|
+
options.responsive === "stackedFullWidth",
|
|
266
|
+
[classes.lastSimpleCell]: options.responsive === "simple",
|
|
267
267
|
[bodyClasses.className]: bodyClasses.className,
|
|
268
268
|
})}
|
|
269
|
-
data-testid={
|
|
270
|
-
id={`MUIDataTableBodyRow-${tableId}-${dataIndex}`}
|
|
269
|
+
data-testid={"MUIDataTableBodyRow-" + dataIndex}
|
|
270
|
+
id={`MUIDataTableBodyRow-${tableId}-${dataIndex}`}
|
|
271
|
+
>
|
|
271
272
|
<TableSelectCell
|
|
272
273
|
onChange={this.handleRowSelect.bind(null, {
|
|
273
274
|
index: this.getRowIndex(rowIndex),
|
|
@@ -294,7 +295,7 @@ class TableBody extends React.Component {
|
|
|
294
295
|
/>
|
|
295
296
|
{processedRow.map(
|
|
296
297
|
(column) =>
|
|
297
|
-
columns[column.index].display ===
|
|
298
|
+
columns[column.index].display === "true" && (
|
|
298
299
|
<TableBodyCell
|
|
299
300
|
{...(columns[column.index].setCellProps
|
|
300
301
|
? columns[column.index].setCellProps(column.value, dataIndex, column.index) || {}
|
|
@@ -307,7 +308,8 @@ class TableBody extends React.Component {
|
|
|
307
308
|
print={columns[column.index].print}
|
|
308
309
|
options={options}
|
|
309
310
|
tableId={tableId}
|
|
310
|
-
key={column.index}
|
|
311
|
+
key={column.index}
|
|
312
|
+
>
|
|
311
313
|
{column.value}
|
|
312
314
|
</TableBodyCell>
|
|
313
315
|
),
|
|
@@ -320,11 +322,12 @@ class TableBody extends React.Component {
|
|
|
320
322
|
) : (
|
|
321
323
|
<TableBodyRow options={options}>
|
|
322
324
|
<TableBodyCell
|
|
323
|
-
colSpan={options.selectableRows !==
|
|
325
|
+
colSpan={options.selectableRows !== "none" || options.expandableRows ? visibleColCnt + 1 : visibleColCnt}
|
|
324
326
|
options={options}
|
|
325
327
|
colIndex={0}
|
|
326
|
-
rowIndex={0}
|
|
327
|
-
|
|
328
|
+
rowIndex={0}
|
|
329
|
+
>
|
|
330
|
+
<Typography variant="body1" className={classes.emptyTitle} component={"div"}>
|
|
328
331
|
{options.textLabels.body.noMatch}
|
|
329
332
|
</Typography>
|
|
330
333
|
</TableBodyCell>
|
|
@@ -335,4 +338,4 @@ class TableBody extends React.Component {
|
|
|
335
338
|
}
|
|
336
339
|
}
|
|
337
340
|
|
|
338
|
-
export default withStyles(TableBody, defaultBodyStyles, { name:
|
|
341
|
+
export default withStyles(TableBody, defaultBodyStyles, { name: "MUIDataTableBody" });
|
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { Button } from
|
|
2
|
-
import { Checkbox } from
|
|
3
|
-
import { FormControl } from
|
|
4
|
-
import { FormControlLabel } from
|
|
5
|
-
import { FormGroup } from
|
|
6
|
-
import { Grid } from
|
|
7
|
-
import { Input } from
|
|
8
|
-
import { InputLabel } from
|
|
9
|
-
import { ListItemText } from
|
|
10
|
-
import { MenuItem } from
|
|
11
|
-
import PropTypes from
|
|
12
|
-
import React from
|
|
13
|
-
import { Select } from
|
|
14
|
-
import { TextField } from
|
|
15
|
-
import { Typography } from
|
|
16
|
-
import clsx from
|
|
17
|
-
import { withStyles } from
|
|
18
|
-
import cloneDeep from
|
|
19
|
-
|
|
20
|
-
export const defaultFilterStyles = theme => ({
|
|
1
|
+
import { Button } from "@mui/material";
|
|
2
|
+
import { Checkbox } from "@mui/material";
|
|
3
|
+
import { FormControl } from "@mui/material";
|
|
4
|
+
import { FormControlLabel } from "@mui/material";
|
|
5
|
+
import { FormGroup } from "@mui/material";
|
|
6
|
+
import { Grid } from "@mui/material";
|
|
7
|
+
import { Input } from "@mui/material";
|
|
8
|
+
import { InputLabel } from "@mui/material";
|
|
9
|
+
import { ListItemText } from "@mui/material";
|
|
10
|
+
import { MenuItem } from "@mui/material";
|
|
11
|
+
import PropTypes from "prop-types";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { Select } from "@mui/material";
|
|
14
|
+
import { TextField } from "@mui/material";
|
|
15
|
+
import { Typography } from "@mui/material";
|
|
16
|
+
import clsx from "clsx";
|
|
17
|
+
import { withStyles } from "tss-react/mui";
|
|
18
|
+
import { cloneDeep } from "lodash-es";
|
|
19
|
+
|
|
20
|
+
export const defaultFilterStyles = (theme) => ({
|
|
21
21
|
root: {
|
|
22
22
|
backgroundColor: theme.palette.background.default,
|
|
23
|
-
padding:
|
|
24
|
-
fontFamily:
|
|
23
|
+
padding: "24px 24px 36px 24px",
|
|
24
|
+
fontFamily: "Roboto",
|
|
25
25
|
},
|
|
26
26
|
header: {
|
|
27
|
-
flex:
|
|
28
|
-
marginBottom:
|
|
29
|
-
width:
|
|
30
|
-
display:
|
|
31
|
-
justifyContent:
|
|
27
|
+
flex: "0 0 auto",
|
|
28
|
+
marginBottom: "16px",
|
|
29
|
+
width: "100%",
|
|
30
|
+
display: "flex",
|
|
31
|
+
justifyContent: "space-between",
|
|
32
32
|
},
|
|
33
33
|
title: {
|
|
34
|
-
display:
|
|
35
|
-
marginLeft:
|
|
34
|
+
display: "inline-block",
|
|
35
|
+
marginLeft: "7px",
|
|
36
36
|
color: theme.palette.text.primary,
|
|
37
|
-
fontSize:
|
|
37
|
+
fontSize: "14px",
|
|
38
38
|
fontWeight: 500,
|
|
39
39
|
},
|
|
40
40
|
noMargin: {
|
|
41
|
-
marginLeft:
|
|
41
|
+
marginLeft: "0px",
|
|
42
42
|
},
|
|
43
43
|
reset: {
|
|
44
|
-
alignSelf:
|
|
44
|
+
alignSelf: "left",
|
|
45
45
|
},
|
|
46
46
|
resetLink: {
|
|
47
|
-
marginLeft:
|
|
48
|
-
fontSize:
|
|
49
|
-
cursor:
|
|
47
|
+
marginLeft: "16px",
|
|
48
|
+
fontSize: "12px",
|
|
49
|
+
cursor: "pointer",
|
|
50
50
|
},
|
|
51
51
|
filtersSelected: {
|
|
52
|
-
alignSelf:
|
|
52
|
+
alignSelf: "right",
|
|
53
53
|
},
|
|
54
54
|
/* checkbox */
|
|
55
55
|
checkboxListTitle: {
|
|
56
|
-
marginLeft:
|
|
57
|
-
marginBottom:
|
|
58
|
-
fontSize:
|
|
56
|
+
marginLeft: "7px",
|
|
57
|
+
marginBottom: "8px",
|
|
58
|
+
fontSize: "14px",
|
|
59
59
|
color: theme.palette.text.secondary,
|
|
60
|
-
textAlign:
|
|
60
|
+
textAlign: "left",
|
|
61
61
|
fontWeight: 500,
|
|
62
62
|
},
|
|
63
63
|
checkboxFormGroup: {
|
|
64
|
-
marginTop:
|
|
64
|
+
marginTop: "8px",
|
|
65
65
|
},
|
|
66
66
|
checkboxFormControl: {
|
|
67
|
-
margin:
|
|
67
|
+
margin: "0px",
|
|
68
68
|
},
|
|
69
69
|
checkboxFormControlLabel: {
|
|
70
|
-
fontSize:
|
|
71
|
-
marginLeft:
|
|
70
|
+
fontSize: "15px",
|
|
71
|
+
marginLeft: "8px",
|
|
72
72
|
color: theme.palette.text.primary,
|
|
73
73
|
},
|
|
74
74
|
checkboxIcon: {
|
|
75
|
-
width:
|
|
76
|
-
height:
|
|
75
|
+
width: "32px",
|
|
76
|
+
height: "32px",
|
|
77
77
|
},
|
|
78
78
|
checkbox: {},
|
|
79
79
|
checked: {},
|
|
80
80
|
gridListTile: {
|
|
81
|
-
marginTop:
|
|
81
|
+
marginTop: "16px",
|
|
82
82
|
},
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -115,36 +115,36 @@ class TableFilter extends React.Component {
|
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
handleCheckboxChange = (index, value, column) => {
|
|
118
|
-
this.filterUpdate(index, value, column,
|
|
118
|
+
this.filterUpdate(index, value, column, "checkbox");
|
|
119
119
|
|
|
120
120
|
if (this.props.options.confirmFilters !== true) {
|
|
121
|
-
this.props.onFilterUpdate(index, value, column,
|
|
121
|
+
this.props.onFilterUpdate(index, value, column, "checkbox");
|
|
122
122
|
}
|
|
123
123
|
};
|
|
124
124
|
|
|
125
125
|
handleDropdownChange = (event, index, column) => {
|
|
126
126
|
const labelFilterAll = this.props.options.textLabels.filter.all;
|
|
127
127
|
const value = event.target.value === labelFilterAll ? [] : [event.target.value];
|
|
128
|
-
this.filterUpdate(index, value, column,
|
|
128
|
+
this.filterUpdate(index, value, column, "dropdown");
|
|
129
129
|
|
|
130
130
|
if (this.props.options.confirmFilters !== true) {
|
|
131
|
-
this.props.onFilterUpdate(index, value, column,
|
|
131
|
+
this.props.onFilterUpdate(index, value, column, "dropdown");
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
handleMultiselectChange = (index, value, column) => {
|
|
136
|
-
this.filterUpdate(index, value, column,
|
|
136
|
+
this.filterUpdate(index, value, column, "multiselect");
|
|
137
137
|
|
|
138
138
|
if (this.props.options.confirmFilters !== true) {
|
|
139
|
-
this.props.onFilterUpdate(index, value, column,
|
|
139
|
+
this.props.onFilterUpdate(index, value, column, "multiselect");
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
handleTextFieldChange = (event, index, column) => {
|
|
144
|
-
this.filterUpdate(index, event.target.value, column,
|
|
144
|
+
this.filterUpdate(index, event.target.value, column, "textField");
|
|
145
145
|
|
|
146
146
|
if (this.props.options.confirmFilters !== true) {
|
|
147
|
-
this.props.onFilterUpdate(index, event.target.value, column,
|
|
147
|
+
this.props.onFilterUpdate(index, event.target.value, column, "textField");
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
|
|
@@ -162,7 +162,7 @@ class TableFilter extends React.Component {
|
|
|
162
162
|
const { classes, filterData } = this.props;
|
|
163
163
|
const { filterList } = this.state;
|
|
164
164
|
const renderItem =
|
|
165
|
-
column.filterOptions && column.filterOptions.renderValue ? column.filterOptions.renderValue : v => v;
|
|
165
|
+
column.filterOptions && column.filterOptions.renderValue ? column.filterOptions.renderValue : (v) => v;
|
|
166
166
|
|
|
167
167
|
return (
|
|
168
168
|
<Grid item key={index} xs={6}>
|
|
@@ -192,7 +192,7 @@ class TableFilter extends React.Component {
|
|
|
192
192
|
root: classes.checkbox,
|
|
193
193
|
checked: classes.checked,
|
|
194
194
|
}}
|
|
195
|
-
value={filterValue != null ? filterValue.toString() :
|
|
195
|
+
value={filterValue != null ? filterValue.toString() : ""}
|
|
196
196
|
/>
|
|
197
197
|
}
|
|
198
198
|
label={renderItem(filterValue)}
|
|
@@ -212,7 +212,7 @@ class TableFilter extends React.Component {
|
|
|
212
212
|
const renderItem =
|
|
213
213
|
column.filterOptions && column.filterOptions.renderValue
|
|
214
214
|
? column.filterOptions.renderValue
|
|
215
|
-
: v => (v != null ? v.toString() :
|
|
215
|
+
: (v) => (v != null ? v.toString() : "");
|
|
216
216
|
const width = (column.filterOptions && column.filterOptions.fullWidth) === true ? 12 : 6;
|
|
217
217
|
|
|
218
218
|
return (
|
|
@@ -220,15 +220,17 @@ class TableFilter extends React.Component {
|
|
|
220
220
|
item
|
|
221
221
|
key={index}
|
|
222
222
|
xs={width}
|
|
223
|
-
classes={{
|
|
224
|
-
|
|
223
|
+
classes={{ "grid-xs-12": classes.gridListTile, "grid-xs-6": classes.gridListTile }}
|
|
224
|
+
>
|
|
225
|
+
<FormControl key={index} variant={"standard"} fullWidth>
|
|
225
226
|
<InputLabel htmlFor={column.name}>{column.label}</InputLabel>
|
|
226
227
|
<Select
|
|
227
228
|
fullWidth
|
|
228
229
|
value={filterList[index].length ? filterList[index].toString() : textLabels.all}
|
|
229
230
|
name={column.name}
|
|
230
|
-
onChange={event => this.handleDropdownChange(event, index, column.name)}
|
|
231
|
-
input={<Input name={column.name} id={column.name} />}
|
|
231
|
+
onChange={(event) => this.handleDropdownChange(event, index, column.name)}
|
|
232
|
+
input={<Input name={column.name} id={column.name} />}
|
|
233
|
+
>
|
|
232
234
|
<MenuItem value={textLabels.all} key={0}>
|
|
233
235
|
{textLabels.all}
|
|
234
236
|
</MenuItem>
|
|
@@ -247,7 +249,7 @@ class TableFilter extends React.Component {
|
|
|
247
249
|
const { classes } = this.props;
|
|
248
250
|
const { filterList } = this.state;
|
|
249
251
|
if (column.filterOptions && column.filterOptions.renderValue) {
|
|
250
|
-
console.warn(
|
|
252
|
+
console.warn("Custom renderValue not supported for textField filters");
|
|
251
253
|
}
|
|
252
254
|
const width = (column.filterOptions && column.filterOptions.fullWidth) === true ? 12 : 6;
|
|
253
255
|
|
|
@@ -256,15 +258,16 @@ class TableFilter extends React.Component {
|
|
|
256
258
|
item
|
|
257
259
|
key={index}
|
|
258
260
|
xs={width}
|
|
259
|
-
classes={{
|
|
261
|
+
classes={{ "grid-xs-12": classes.gridListTile, "grid-xs-6": classes.gridListTile }}
|
|
262
|
+
>
|
|
260
263
|
<FormControl key={index} fullWidth>
|
|
261
264
|
<TextField
|
|
262
265
|
fullWidth
|
|
263
|
-
variant={
|
|
266
|
+
variant={"standard"}
|
|
264
267
|
label={column.label}
|
|
265
|
-
value={filterList[index].toString() ||
|
|
266
|
-
data-testid={
|
|
267
|
-
onChange={event => this.handleTextFieldChange(event, index, column.name)}
|
|
268
|
+
value={filterList[index].toString() || ""}
|
|
269
|
+
data-testid={"filtertextfield-" + column.name}
|
|
270
|
+
onChange={(event) => this.handleTextFieldChange(event, index, column.name)}
|
|
268
271
|
/>
|
|
269
272
|
</FormControl>
|
|
270
273
|
</Grid>
|
|
@@ -277,31 +280,33 @@ class TableFilter extends React.Component {
|
|
|
277
280
|
const { classes, filterData } = this.props;
|
|
278
281
|
const { filterList } = this.state;
|
|
279
282
|
const renderItem =
|
|
280
|
-
column.filterOptions && column.filterOptions.renderValue ? column.filterOptions.renderValue : v => v;
|
|
283
|
+
column.filterOptions && column.filterOptions.renderValue ? column.filterOptions.renderValue : (v) => v;
|
|
281
284
|
const width = (column.filterOptions && column.filterOptions.fullWidth) === true ? 12 : 6;
|
|
282
285
|
return (
|
|
283
286
|
<Grid
|
|
284
287
|
item
|
|
285
288
|
key={index}
|
|
286
289
|
xs={width}
|
|
287
|
-
classes={{
|
|
288
|
-
|
|
290
|
+
classes={{ "grid-xs-12": classes.gridListTile, "grid-xs-6": classes.gridListTile }}
|
|
291
|
+
>
|
|
292
|
+
<FormControl key={index} variant={"standard"} fullWidth>
|
|
289
293
|
<InputLabel htmlFor={column.name}>{column.label}</InputLabel>
|
|
290
294
|
<Select
|
|
291
295
|
multiple
|
|
292
296
|
fullWidth
|
|
293
297
|
value={filterList[index] || []}
|
|
294
|
-
renderValue={selected => selected.map(renderItem).join(
|
|
298
|
+
renderValue={(selected) => selected.map(renderItem).join(", ")}
|
|
295
299
|
name={column.name}
|
|
296
|
-
onChange={event => this.handleMultiselectChange(index, event.target.value, column.name)}
|
|
297
|
-
input={<Input name={column.name} id={column.name} />}
|
|
300
|
+
onChange={(event) => this.handleMultiselectChange(index, event.target.value, column.name)}
|
|
301
|
+
input={<Input name={column.name} id={column.name} />}
|
|
302
|
+
>
|
|
298
303
|
{filterData[index].map((filterValue, filterIndex) => (
|
|
299
304
|
<MenuItem value={filterValue} key={filterIndex + 1}>
|
|
300
305
|
<CheckboxComponent
|
|
301
306
|
data-description="table-filter"
|
|
302
307
|
color="primary"
|
|
303
308
|
checked={filterList[index].indexOf(filterValue) >= 0}
|
|
304
|
-
value={filterValue != null ? filterValue.toString() :
|
|
309
|
+
value={filterValue != null ? filterValue.toString() : ""}
|
|
305
310
|
className={classes.checkboxIcon}
|
|
306
311
|
classes={{
|
|
307
312
|
root: classes.checkbox,
|
|
@@ -338,7 +343,8 @@ class TableFilter extends React.Component {
|
|
|
338
343
|
item
|
|
339
344
|
key={index}
|
|
340
345
|
xs={width}
|
|
341
|
-
classes={{
|
|
346
|
+
classes={{ "grid-xs-12": classes.gridListTile, "grid-xs-6": classes.gridListTile }}
|
|
347
|
+
>
|
|
342
348
|
<FormControl key={index} fullWidth>
|
|
343
349
|
{display(filterList, this.handleCustomChange, index, column, filterData)}
|
|
344
350
|
</FormControl>
|
|
@@ -348,7 +354,7 @@ class TableFilter extends React.Component {
|
|
|
348
354
|
|
|
349
355
|
applyFilters = () => {
|
|
350
356
|
this.state.filterList.forEach((filter, index) => {
|
|
351
|
-
this.props.onFilterUpdate(index, filter, this.props.columns[index],
|
|
357
|
+
this.props.onFilterUpdate(index, filter, this.props.columns[index], "custom");
|
|
352
358
|
});
|
|
353
359
|
|
|
354
360
|
this.props.handleClose(); // close filter dialog popover
|
|
@@ -381,7 +387,8 @@ class TableFilter extends React.Component {
|
|
|
381
387
|
variant="body2"
|
|
382
388
|
className={clsx({
|
|
383
389
|
[classes.title]: true,
|
|
384
|
-
})}
|
|
390
|
+
})}
|
|
391
|
+
>
|
|
385
392
|
{textLabels.title}
|
|
386
393
|
</Typography>
|
|
387
394
|
<Button
|
|
@@ -389,8 +396,9 @@ class TableFilter extends React.Component {
|
|
|
389
396
|
className={classes.resetLink}
|
|
390
397
|
tabIndex={0}
|
|
391
398
|
aria-label={textLabels.reset}
|
|
392
|
-
data-testid={
|
|
393
|
-
onClick={this.resetFilters}
|
|
399
|
+
data-testid={"filterReset-button"}
|
|
400
|
+
onClick={this.resetFilters}
|
|
401
|
+
>
|
|
394
402
|
{textLabels.reset}
|
|
395
403
|
</Button>
|
|
396
404
|
</div>
|
|
@@ -400,22 +408,22 @@ class TableFilter extends React.Component {
|
|
|
400
408
|
{columns.map((column, index) => {
|
|
401
409
|
if (column.filter) {
|
|
402
410
|
const filterType = column.filterType || options.filterType;
|
|
403
|
-
return filterType ===
|
|
411
|
+
return filterType === "checkbox"
|
|
404
412
|
? this.renderCheckbox(column, index, components)
|
|
405
|
-
: filterType ===
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
413
|
+
: filterType === "multiselect"
|
|
414
|
+
? this.renderMultiselect(column, index, components)
|
|
415
|
+
: filterType === "textField"
|
|
416
|
+
? this.renderTextField(column, index)
|
|
417
|
+
: filterType === "custom"
|
|
418
|
+
? this.renderCustomField(column, index)
|
|
419
|
+
: this.renderSelect(column, index);
|
|
412
420
|
}
|
|
413
421
|
})}
|
|
414
422
|
</Grid>
|
|
415
|
-
{customFooter ? customFooter(filterList, this.applyFilters) :
|
|
423
|
+
{customFooter ? customFooter(filterList, this.applyFilters) : ""}
|
|
416
424
|
</div>
|
|
417
425
|
);
|
|
418
426
|
}
|
|
419
427
|
}
|
|
420
428
|
|
|
421
|
-
export default withStyles(TableFilter, defaultFilterStyles, { name:
|
|
429
|
+
export default withStyles(TableFilter, defaultFilterStyles, { name: "MUIDataTableFilter" });
|