material-react-table 0.5.7 → 0.6.0
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/dist/MaterialReactTable.d.ts +8 -2
- package/dist/body/MRT_TableBodyCell.d.ts +1 -1
- package/dist/body/MRT_TableBodyRow.d.ts +1 -1
- package/dist/body/MRT_TableDetailPanel.d.ts +1 -1
- package/dist/buttons/MRT_EditActionButtons.d.ts +1 -1
- package/dist/buttons/MRT_ExpandButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +1 -1
- package/dist/enums.d.ts +12 -0
- package/dist/filtersFNs.d.ts +20 -0
- package/dist/footer/MRT_TableFooterCell.d.ts +1 -1
- package/dist/footer/MRT_TableFooterRow.d.ts +1 -1
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHeadRow.d.ts +1 -1
- package/dist/inputs/MRT_EditCellTextField.d.ts +1 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
- package/dist/inputs/MRT_SelectCheckbox.d.ts +1 -1
- package/dist/localization.d.ts +44 -44
- package/dist/material-react-table.cjs.development.js +569 -360
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +570 -361
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +9 -2
- package/dist/menus/MRT_FilterTypeMenu.d.ts +1 -1
- package/dist/menus/MRT_RowActionMenu.d.ts +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +3 -2
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -0
- package/dist/useMRT.d.ts +1 -1
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +5 -9
- package/src/body/MRT_TableBody.tsx +1 -1
- package/src/body/MRT_TableBodyCell.tsx +1 -1
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +5 -8
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -2
- package/src/buttons/MRT_ExpandButton.tsx +3 -3
- package/src/buttons/MRT_FullScreenToggleButton.tsx +2 -2
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +4 -55
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +4 -3
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -2
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +4 -8
- package/src/buttons/MRT_ToggleSearchButton.tsx +1 -1
- package/src/enums.ts +12 -0
- package/src/filtersFNs.ts +42 -0
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHead.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +22 -18
- package/src/head/MRT_TableHeadCellActions.tsx +1 -1
- package/src/head/MRT_TableHeadRow.tsx +1 -1
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +99 -21
- package/src/inputs/MRT_SearchTextField.tsx +3 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +5 -5
- package/src/localization.ts +89 -88
- package/src/menus/MRT_ColumnActionMenu.tsx +109 -56
- package/src/menus/MRT_FilterTypeMenu.tsx +63 -26
- package/src/menus/MRT_RowActionMenu.tsx +4 -10
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +54 -33
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +57 -0
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -3
- package/src/useMRT.tsx +36 -14
|
@@ -3,14 +3,16 @@ import {
|
|
|
3
3
|
Chip,
|
|
4
4
|
IconButton,
|
|
5
5
|
InputAdornment,
|
|
6
|
+
MenuItem,
|
|
6
7
|
TextField,
|
|
7
8
|
TextFieldProps,
|
|
8
9
|
Tooltip,
|
|
9
10
|
} from '@mui/material';
|
|
10
11
|
import { useAsyncDebounce } from 'react-table';
|
|
11
12
|
import { useMRT } from '../useMRT';
|
|
12
|
-
import { MRT_HeaderGroup } from '..';
|
|
13
|
+
import type { MRT_HeaderGroup } from '..';
|
|
13
14
|
import { MRT_FilterTypeMenu } from '../menus/MRT_FilterTypeMenu';
|
|
15
|
+
import { MRT_FILTER_TYPE } from '../enums';
|
|
14
16
|
|
|
15
17
|
interface Props {
|
|
16
18
|
column: MRT_HeaderGroup;
|
|
@@ -65,7 +67,10 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
65
67
|
const handleClearFilterChip = () => {
|
|
66
68
|
setFilterValue('');
|
|
67
69
|
column.setFilter(undefined);
|
|
68
|
-
setCurrentFilterTypes((prev) => ({
|
|
70
|
+
setCurrentFilterTypes((prev) => ({
|
|
71
|
+
...prev,
|
|
72
|
+
[column.id]: MRT_FILTER_TYPE.FUZZY,
|
|
73
|
+
}));
|
|
69
74
|
};
|
|
70
75
|
|
|
71
76
|
if (column.Filter) {
|
|
@@ -73,8 +78,18 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
73
78
|
}
|
|
74
79
|
|
|
75
80
|
const filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
76
|
-
const
|
|
77
|
-
const
|
|
81
|
+
const isSelectFilter = !!column.filterSelectOptions;
|
|
82
|
+
const filterChipLabel =
|
|
83
|
+
!(filterType instanceof Function) &&
|
|
84
|
+
[MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(
|
|
85
|
+
filterType as MRT_FILTER_TYPE,
|
|
86
|
+
)
|
|
87
|
+
? //@ts-ignore
|
|
88
|
+
localization[
|
|
89
|
+
`filter${filterType.charAt(0).toUpperCase() + filterType.slice(1)}`
|
|
90
|
+
]
|
|
91
|
+
: '';
|
|
92
|
+
const filterPlaceholder = localization.filterByColumn?.replace(
|
|
78
93
|
'{column}',
|
|
79
94
|
String(column.Header),
|
|
80
95
|
);
|
|
@@ -92,29 +107,61 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
92
107
|
},
|
|
93
108
|
title: filterPlaceholder,
|
|
94
109
|
}}
|
|
110
|
+
helperText={
|
|
111
|
+
filterType instanceof Function
|
|
112
|
+
? ''
|
|
113
|
+
: localization.filterMode.replace(
|
|
114
|
+
'{filterType}',
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
localization[
|
|
117
|
+
`filter${
|
|
118
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
119
|
+
}`
|
|
120
|
+
],
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
FormHelperTextProps={{
|
|
124
|
+
sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
|
|
125
|
+
}}
|
|
126
|
+
label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
|
|
127
|
+
InputLabelProps={{
|
|
128
|
+
shrink: false,
|
|
129
|
+
sx: {
|
|
130
|
+
maxWidth: 'calc(100% - 2.5rem)',
|
|
131
|
+
},
|
|
132
|
+
title: filterPlaceholder,
|
|
133
|
+
}}
|
|
95
134
|
margin="none"
|
|
96
|
-
placeholder={
|
|
135
|
+
placeholder={
|
|
136
|
+
filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
|
|
137
|
+
}
|
|
97
138
|
onChange={(e: ChangeEvent<HTMLInputElement>) => {
|
|
98
139
|
setFilterValue(e.target.value);
|
|
99
140
|
handleChange(e.target.value);
|
|
100
141
|
}}
|
|
101
142
|
onClick={(e) => e.stopPropagation()}
|
|
143
|
+
select={isSelectFilter}
|
|
102
144
|
value={filterValue ?? ''}
|
|
103
145
|
variant="standard"
|
|
104
146
|
InputProps={{
|
|
105
|
-
startAdornment: (
|
|
147
|
+
startAdornment: !isSelectFilter && (
|
|
106
148
|
<InputAdornment position="start">
|
|
107
|
-
<Tooltip arrow title=
|
|
108
|
-
<
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
149
|
+
<Tooltip arrow title={localization.changeFilterMode}>
|
|
150
|
+
<span>
|
|
151
|
+
<IconButton
|
|
152
|
+
onClick={handleFilterMenuOpen}
|
|
153
|
+
size="small"
|
|
154
|
+
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
155
|
+
>
|
|
156
|
+
<FilterListIcon />
|
|
157
|
+
</IconButton>
|
|
158
|
+
</span>
|
|
115
159
|
</Tooltip>
|
|
116
160
|
{filterChipLabel && (
|
|
117
|
-
<Chip
|
|
161
|
+
<Chip
|
|
162
|
+
onDelete={handleClearFilterChip}
|
|
163
|
+
label={filterChipLabel}
|
|
164
|
+
/>
|
|
118
165
|
)}
|
|
119
166
|
</InputAdornment>
|
|
120
167
|
),
|
|
@@ -122,16 +169,20 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
122
169
|
<InputAdornment position="end">
|
|
123
170
|
<Tooltip
|
|
124
171
|
arrow
|
|
172
|
+
disableHoverListener={isSelectFilter}
|
|
125
173
|
placement="right"
|
|
126
|
-
title={localization.
|
|
174
|
+
title={localization.clearFilter ?? ''}
|
|
127
175
|
>
|
|
128
176
|
<span>
|
|
129
177
|
<IconButton
|
|
130
|
-
aria-label={localization.
|
|
131
|
-
disabled={filterValue?.length
|
|
178
|
+
aria-label={localization.clearFilter}
|
|
179
|
+
disabled={!filterValue?.length}
|
|
132
180
|
onClick={handleClear}
|
|
133
181
|
size="small"
|
|
134
|
-
sx={{
|
|
182
|
+
sx={{
|
|
183
|
+
height: '1.75rem',
|
|
184
|
+
width: '1.75rem',
|
|
185
|
+
}}
|
|
135
186
|
>
|
|
136
187
|
<CloseIcon fontSize="small" />
|
|
137
188
|
</IconButton>
|
|
@@ -142,12 +193,39 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
142
193
|
}}
|
|
143
194
|
{...textFieldProps}
|
|
144
195
|
sx={{
|
|
145
|
-
m: '
|
|
196
|
+
m: '-0.25rem',
|
|
197
|
+
p: 0,
|
|
146
198
|
minWidth: !filterChipLabel ? '5rem' : 'auto',
|
|
147
199
|
width: 'calc(100% + 0.5rem)',
|
|
200
|
+
mt: isSelectFilter && !filterValue ? '-1rem' : undefined,
|
|
201
|
+
'& .MuiSelect-icon': {
|
|
202
|
+
mr: '1.5rem',
|
|
203
|
+
},
|
|
148
204
|
...textFieldProps?.sx,
|
|
149
205
|
}}
|
|
150
|
-
|
|
206
|
+
>
|
|
207
|
+
{isSelectFilter && (
|
|
208
|
+
<MenuItem divider disabled={!filterValue} value="">
|
|
209
|
+
{localization.clearFilter}
|
|
210
|
+
</MenuItem>
|
|
211
|
+
)}
|
|
212
|
+
{column?.filterSelectOptions?.map((option) => {
|
|
213
|
+
let value;
|
|
214
|
+
let text;
|
|
215
|
+
if (typeof option === 'string') {
|
|
216
|
+
value = option;
|
|
217
|
+
text = option;
|
|
218
|
+
} else if (typeof option === 'object') {
|
|
219
|
+
value = option.value;
|
|
220
|
+
text = option.text;
|
|
221
|
+
}
|
|
222
|
+
return (
|
|
223
|
+
<MenuItem key={value} value={value}>
|
|
224
|
+
{text}
|
|
225
|
+
</MenuItem>
|
|
226
|
+
);
|
|
227
|
+
})}
|
|
228
|
+
</TextField>
|
|
151
229
|
<MRT_FilterTypeMenu
|
|
152
230
|
anchorEl={anchorEl}
|
|
153
231
|
column={column}
|
|
@@ -34,7 +34,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
34
34
|
<Collapse in={tableInstance.state.showSearch} orientation="horizontal">
|
|
35
35
|
<TextField
|
|
36
36
|
id={`mrt-${idPrefix}-search-text-field`}
|
|
37
|
-
placeholder={localization.
|
|
37
|
+
placeholder={localization.search}
|
|
38
38
|
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
39
39
|
setSearchValue(event.target.value);
|
|
40
40
|
handleChange(event);
|
|
@@ -50,11 +50,11 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
50
50
|
endAdornment: (
|
|
51
51
|
<InputAdornment position="end">
|
|
52
52
|
<IconButton
|
|
53
|
-
aria-label={localization.
|
|
53
|
+
aria-label={localization.clearSearch}
|
|
54
54
|
disabled={searchValue?.length === 0}
|
|
55
55
|
onClick={handleClear}
|
|
56
56
|
size="small"
|
|
57
|
-
title={localization.
|
|
57
|
+
title={localization.clearSearch}
|
|
58
58
|
>
|
|
59
59
|
<CloseIcon fontSize="small" />
|
|
60
60
|
</IconButton>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC } from 'react';
|
|
2
2
|
import { Checkbox, TableCell, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_Row } from '..';
|
|
4
|
+
import type { MRT_Row } from '..';
|
|
5
5
|
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
@@ -37,15 +37,15 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll }) => {
|
|
|
37
37
|
enterNextDelay={1000}
|
|
38
38
|
title={
|
|
39
39
|
selectAll
|
|
40
|
-
? localization.
|
|
41
|
-
: localization.
|
|
40
|
+
? localization.toggleSelectAll
|
|
41
|
+
: localization.toggleSelectRow
|
|
42
42
|
}
|
|
43
43
|
>
|
|
44
44
|
<Checkbox
|
|
45
45
|
inputProps={{
|
|
46
46
|
'aria-label': selectAll
|
|
47
|
-
? localization.
|
|
48
|
-
: localization.
|
|
47
|
+
? localization.toggleSelectAll
|
|
48
|
+
: localization.toggleSelectRow,
|
|
49
49
|
}}
|
|
50
50
|
onChange={onSelectChange}
|
|
51
51
|
{...checkboxProps}
|
package/src/localization.ts
CHANGED
|
@@ -1,93 +1,94 @@
|
|
|
1
1
|
export interface MRT_Localization {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
actions: string;
|
|
3
|
+
cancel: string;
|
|
4
|
+
changeFilterMode: string;
|
|
5
|
+
clearFilter: string;
|
|
6
|
+
clearSearch: string;
|
|
7
|
+
clearSort: string;
|
|
8
|
+
columnActions: string;
|
|
9
|
+
edit: string;
|
|
10
|
+
expand: string;
|
|
11
|
+
expandAll: string;
|
|
12
|
+
filterByColumn: string;
|
|
13
|
+
filterContains: string;
|
|
14
|
+
filterEmpty: string;
|
|
15
|
+
filterEndsWith: string;
|
|
16
|
+
filterEquals: string;
|
|
17
|
+
filterFuzzy: string;
|
|
18
|
+
filterGreaterThan: string;
|
|
19
|
+
filterLessThan: string;
|
|
20
|
+
filterMode: string;
|
|
21
|
+
filterNotEmpty: string;
|
|
22
|
+
filterNotEquals: string;
|
|
23
|
+
filterStartsWith: string;
|
|
24
|
+
filteringByColumn: string;
|
|
25
|
+
groupByColumn: string;
|
|
26
|
+
groupedBy: string;
|
|
27
|
+
hideAll: string;
|
|
28
|
+
hideColumn: string;
|
|
29
|
+
rowActions: string;
|
|
30
|
+
save: string;
|
|
31
|
+
search: string;
|
|
32
|
+
selectedCountOfRowCountRowsSelected: string;
|
|
33
|
+
showAll: string;
|
|
34
|
+
showHideColumns: string;
|
|
35
|
+
showAllColumns: string;
|
|
36
|
+
showHideFilters: string;
|
|
37
|
+
showHideSearch: string;
|
|
38
|
+
sortByColumnAsc: string;
|
|
39
|
+
sortByColumnDesc: string;
|
|
40
|
+
thenBy: string;
|
|
41
|
+
toggleDensePadding: string;
|
|
42
|
+
toggleFullScreen: string;
|
|
43
|
+
toggleSelectAll: string;
|
|
44
|
+
toggleSelectRow: string;
|
|
45
|
+
ungroupByColumn: string;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
49
|
+
actions: 'Actions',
|
|
50
|
+
cancel: 'Cancel',
|
|
51
|
+
changeFilterMode: 'Change filter mode',
|
|
52
|
+
clearFilter: 'Clear filter',
|
|
53
|
+
clearSearch: 'Clear search',
|
|
54
|
+
clearSort: 'Clear sort',
|
|
55
|
+
columnActions: 'Column Actions',
|
|
56
|
+
edit: 'Edit',
|
|
57
|
+
expand: 'Expand',
|
|
58
|
+
expandAll: 'Expand all',
|
|
59
|
+
filterByColumn: 'Filter by {column}',
|
|
60
|
+
filterContains: 'Contains Exact',
|
|
61
|
+
filterEmpty: 'Empty',
|
|
62
|
+
filterEndsWith: 'Ends With',
|
|
63
|
+
filterEquals: 'Equals',
|
|
64
|
+
filterFuzzy: 'Fuzzy Match',
|
|
65
|
+
filterGreaterThan: 'Greater Than',
|
|
66
|
+
filterLessThan: 'Less Than',
|
|
67
|
+
filterMode: 'Filter Mode: {filterType}',
|
|
68
|
+
filterNotEmpty: 'Not Empty',
|
|
69
|
+
filterNotEquals: 'Not Equals',
|
|
70
|
+
filterStartsWith: 'Starts With',
|
|
71
|
+
filteringByColumn: 'Filtering by {column} - {filterType} "{filterValue}"',
|
|
72
|
+
groupByColumn: 'Group by {column}',
|
|
73
|
+
groupedBy: 'Grouped by ',
|
|
74
|
+
hideAll: 'Hide all',
|
|
75
|
+
hideColumn: 'Hide {column} column',
|
|
76
|
+
rowActions: 'Row Actions',
|
|
77
|
+
save: 'Save',
|
|
78
|
+
search: 'Search',
|
|
79
|
+
selectedCountOfRowCountRowsSelected:
|
|
80
|
+
'{selectedCount} of {rowCount} row(s) selected',
|
|
81
|
+
showAll: 'Show all',
|
|
82
|
+
showAllColumns: 'Show all columns',
|
|
83
|
+
showHideColumns: 'Show/Hide columns',
|
|
84
|
+
showHideFilters: 'Show/Hide filters',
|
|
85
|
+
showHideSearch: 'Show/Hide search',
|
|
86
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
|
87
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
|
88
|
+
thenBy: ', then by ',
|
|
89
|
+
toggleDensePadding: 'Toggle dense padding',
|
|
90
|
+
toggleFullScreen: 'Toggle full screen',
|
|
91
|
+
toggleSelectAll: 'Toggle select all',
|
|
92
|
+
toggleSelectRow: 'Toggle select row',
|
|
93
|
+
ungroupByColumn: 'Ungroup by {column}',
|
|
93
94
|
};
|