material-react-table 0.7.5 → 0.8.0-alpha.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/dist/MaterialReactTable.d.ts +16 -15
- package/dist/body/MRT_TableBody.d.ts +0 -1
- package/dist/body/MRT_TableBodyCell.d.ts +1 -0
- package/dist/body/MRT_TableBodyRow.d.ts +0 -1
- package/dist/buttons/MRT_ColumnPinningButtons.d.ts +8 -0
- package/dist/buttons/MRT_CopyButton.d.ts +2 -1
- package/dist/enums.d.ts +2 -2
- package/dist/filtersFNs.d.ts +31 -30
- package/dist/footer/MRT_TableFooter.d.ts +0 -1
- package/dist/head/MRT_TableHead.d.ts +0 -1
- package/dist/inputs/MRT_FilterRangeFields.d.ts +8 -0
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -0
- package/dist/localization.d.ts +7 -2
- package/dist/material-react-table.cjs.development.js +451 -418
- 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 +454 -421
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_Table.d.ts +0 -1
- package/dist/toolbar/MRT_ToolbarTop.d.ts +1 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +21 -25
- package/src/MaterialReactTable.tsx +20 -24
- package/src/body/MRT_TableBody.tsx +3 -11
- package/src/body/MRT_TableBodyCell.tsx +103 -52
- package/src/body/MRT_TableBodyRow.tsx +21 -30
- package/src/buttons/MRT_ColumnPinningButtons.tsx +57 -0
- package/src/buttons/MRT_CopyButton.tsx +3 -2
- package/src/buttons/MRT_EditActionButtons.tsx +1 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +22 -18
- package/src/buttons/MRT_ExpandButton.tsx +27 -21
- package/src/enums.ts +2 -2
- package/src/filtersFNs.ts +71 -81
- package/src/footer/MRT_TableFooter.tsx +6 -16
- package/src/footer/MRT_TableFooterCell.tsx +15 -15
- package/src/footer/MRT_TableFooterRow.tsx +6 -8
- package/src/head/MRT_TableHead.tsx +5 -16
- package/src/head/MRT_TableHeadCell.tsx +116 -49
- package/src/head/MRT_TableHeadRow.tsx +8 -15
- package/src/inputs/MRT_EditCellTextField.tsx +3 -3
- package/src/inputs/MRT_FilterRangeFields.tsx +41 -0
- package/src/inputs/MRT_FilterTextField.tsx +76 -41
- package/src/inputs/MRT_SelectCheckbox.tsx +15 -17
- package/src/localization.ts +15 -5
- package/src/menus/MRT_ColumnActionMenu.tsx +13 -12
- package/src/menus/MRT_FilterOptionMenu.tsx +36 -33
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +25 -11
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +16 -6
- package/src/table/MRT_Table.tsx +8 -19
- package/src/table/MRT_TableContainer.tsx +8 -69
- package/src/table/MRT_TableRoot.tsx +44 -52
- package/src/toolbar/MRT_LinearProgressBar.tsx +5 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -2
- package/src/toolbar/MRT_ToolbarTop.tsx +4 -6
package/src/localization.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export interface MRT_Localization {
|
|
2
2
|
actions: string;
|
|
3
|
+
and: string;
|
|
3
4
|
cancel: string;
|
|
4
5
|
changeFilterMode: string;
|
|
5
6
|
changeSearchMode: string;
|
|
@@ -12,13 +13,13 @@ export interface MRT_Localization {
|
|
|
12
13
|
edit: string;
|
|
13
14
|
expand: string;
|
|
14
15
|
expandAll: string;
|
|
15
|
-
|
|
16
|
-
filterBestMatchFirst: string;
|
|
16
|
+
filterBetween: string;
|
|
17
17
|
filterByColumn: string;
|
|
18
18
|
filterContains: string;
|
|
19
19
|
filterEmpty: string;
|
|
20
20
|
filterEndsWith: string;
|
|
21
21
|
filterEquals: string;
|
|
22
|
+
filterFuzzy: string;
|
|
22
23
|
filterGreaterThan: string;
|
|
23
24
|
filterLessThan: string;
|
|
24
25
|
filterMode: string;
|
|
@@ -30,6 +31,8 @@ export interface MRT_Localization {
|
|
|
30
31
|
groupedBy: string;
|
|
31
32
|
hideAll: string;
|
|
32
33
|
hideColumn: string;
|
|
34
|
+
max: string;
|
|
35
|
+
min: string;
|
|
33
36
|
pinToLeft: string;
|
|
34
37
|
pinToRight: string;
|
|
35
38
|
resetColumnSize: string;
|
|
@@ -50,17 +53,20 @@ export interface MRT_Localization {
|
|
|
50
53
|
sortedByColumnAsc: string;
|
|
51
54
|
sortedByColumnDesc: string;
|
|
52
55
|
thenBy: string;
|
|
56
|
+
to: string;
|
|
53
57
|
toggleDensePadding: string;
|
|
54
58
|
toggleFullScreen: string;
|
|
55
59
|
toggleSelectAll: string;
|
|
56
60
|
toggleSelectRow: string;
|
|
57
61
|
ungroupByColumn: string;
|
|
58
62
|
unpin: string;
|
|
63
|
+
unpinAll: string;
|
|
59
64
|
unsorted: string;
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
63
68
|
actions: 'Actions',
|
|
69
|
+
and: 'and',
|
|
64
70
|
cancel: 'Cancel',
|
|
65
71
|
changeFilterMode: 'Change filter mode',
|
|
66
72
|
changeSearchMode: 'Change search mode',
|
|
@@ -73,24 +79,26 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
73
79
|
edit: 'Edit',
|
|
74
80
|
expand: 'Expand',
|
|
75
81
|
expandAll: 'Expand all',
|
|
76
|
-
|
|
77
|
-
filterBestMatchFirst: 'Best Match First',
|
|
82
|
+
filterBetween: 'Between',
|
|
78
83
|
filterByColumn: 'Filter by {column}',
|
|
79
84
|
filterContains: 'Contains',
|
|
80
85
|
filterEmpty: 'Empty',
|
|
81
86
|
filterEndsWith: 'Ends With',
|
|
82
87
|
filterEquals: 'Equals',
|
|
88
|
+
filterFuzzy: 'Fuzzy',
|
|
83
89
|
filterGreaterThan: 'Greater Than',
|
|
84
90
|
filterLessThan: 'Less Than',
|
|
85
91
|
filterMode: 'Filter Mode: {filterType}',
|
|
86
92
|
filterNotEmpty: 'Not Empty',
|
|
87
93
|
filterNotEquals: 'Not Equals',
|
|
88
94
|
filterStartsWith: 'Starts With',
|
|
89
|
-
filteringByColumn: 'Filtering by {column} - {filterType}
|
|
95
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
90
96
|
groupByColumn: 'Group by {column}',
|
|
91
97
|
groupedBy: 'Grouped by ',
|
|
92
98
|
hideAll: 'Hide all',
|
|
93
99
|
hideColumn: 'Hide {column} column',
|
|
100
|
+
max: 'Max',
|
|
101
|
+
min: 'Min',
|
|
94
102
|
pinToLeft: 'Pin to left',
|
|
95
103
|
pinToRight: 'Pin to right',
|
|
96
104
|
resetColumnSize: 'Reset column size',
|
|
@@ -112,11 +120,13 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
112
120
|
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
113
121
|
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
114
122
|
thenBy: ', then by ',
|
|
123
|
+
to: 'to',
|
|
115
124
|
toggleDensePadding: 'Toggle dense padding',
|
|
116
125
|
toggleFullScreen: 'Toggle full screen',
|
|
117
126
|
toggleSelectAll: 'Toggle select all',
|
|
118
127
|
toggleSelectRow: 'Toggle select row',
|
|
119
128
|
ungroupByColumn: 'Ungroup by {column}',
|
|
120
129
|
unpin: 'Unpin',
|
|
130
|
+
unpinAll: 'Unpin all',
|
|
121
131
|
unsorted: 'Unsorted',
|
|
122
132
|
};
|
|
@@ -69,7 +69,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
69
69
|
useState<null | HTMLElement>(null);
|
|
70
70
|
|
|
71
71
|
const handleClearSort = () => {
|
|
72
|
-
column.
|
|
72
|
+
column.clearSorting();
|
|
73
73
|
setAnchorEl(null);
|
|
74
74
|
};
|
|
75
75
|
|
|
@@ -95,6 +95,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
95
95
|
|
|
96
96
|
const handlePinColumn = (pinDirection: 'left' | 'right' | false) => {
|
|
97
97
|
column.pin(pinDirection);
|
|
98
|
+
setAnchorEl(null);
|
|
98
99
|
};
|
|
99
100
|
|
|
100
101
|
const handleGroupByColumn = () => {
|
|
@@ -104,7 +105,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
104
105
|
};
|
|
105
106
|
|
|
106
107
|
const handleClearFilter = () => {
|
|
107
|
-
column.
|
|
108
|
+
column.setFilterValue('');
|
|
108
109
|
setAnchorEl(null);
|
|
109
110
|
};
|
|
110
111
|
|
|
@@ -177,7 +178,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
177
178
|
</ListItemIcon>
|
|
178
179
|
{localization.sortByColumnAsc?.replace(
|
|
179
180
|
'{column}',
|
|
180
|
-
String(column.header),
|
|
181
|
+
String(column.columnDef.header),
|
|
181
182
|
)}
|
|
182
183
|
</Box>
|
|
183
184
|
</MenuItem>,
|
|
@@ -194,15 +195,15 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
194
195
|
</ListItemIcon>
|
|
195
196
|
{localization.sortByColumnDesc?.replace(
|
|
196
197
|
'{column}',
|
|
197
|
-
String(column.header),
|
|
198
|
+
String(column.columnDef.header),
|
|
198
199
|
)}
|
|
199
200
|
</Box>
|
|
200
201
|
</MenuItem>,
|
|
201
202
|
]}
|
|
202
203
|
{enableColumnFilters &&
|
|
203
|
-
column.
|
|
204
|
+
column.getCanFilter() && [
|
|
204
205
|
<MenuItem
|
|
205
|
-
disabled={!column.
|
|
206
|
+
disabled={!column.getFilterValue()}
|
|
206
207
|
key={0}
|
|
207
208
|
onClick={handleClearFilter}
|
|
208
209
|
sx={commonMenuItemStyles}
|
|
@@ -226,7 +227,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
226
227
|
</ListItemIcon>
|
|
227
228
|
{localization.filterByColumn?.replace(
|
|
228
229
|
'{column}',
|
|
229
|
-
String(column.header),
|
|
230
|
+
String(column.columnDef.header),
|
|
230
231
|
)}
|
|
231
232
|
</Box>
|
|
232
233
|
{!column.filterSelectOptions && (
|
|
@@ -263,7 +264,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
263
264
|
</ListItemIcon>
|
|
264
265
|
{localization[
|
|
265
266
|
column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn'
|
|
266
|
-
]?.replace('{column}', String(column.header))}
|
|
267
|
+
]?.replace('{column}', String(column.columnDef.header))}
|
|
267
268
|
</Box>
|
|
268
269
|
</MenuItem>,
|
|
269
270
|
]}
|
|
@@ -284,7 +285,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
284
285
|
</MenuItem>,
|
|
285
286
|
<MenuItem
|
|
286
287
|
disabled={column.getIsPinned() === 'right' || !column.getCanPin()}
|
|
287
|
-
key={
|
|
288
|
+
key={1}
|
|
288
289
|
onClick={() => handlePinColumn('right')}
|
|
289
290
|
sx={commonMenuItemStyles}
|
|
290
291
|
>
|
|
@@ -298,7 +299,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
298
299
|
<MenuItem
|
|
299
300
|
disabled={!column.getIsPinned()}
|
|
300
301
|
divider={enableHiding}
|
|
301
|
-
key={
|
|
302
|
+
key={2}
|
|
302
303
|
onClick={() => handlePinColumn(false)}
|
|
303
304
|
sx={commonMenuItemStyles}
|
|
304
305
|
>
|
|
@@ -338,7 +339,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
338
339
|
</ListItemIcon>
|
|
339
340
|
{localization.hideColumn?.replace(
|
|
340
341
|
'{column}',
|
|
341
|
-
String(column.header),
|
|
342
|
+
String(column.columnDef.header),
|
|
342
343
|
)}
|
|
343
344
|
</Box>
|
|
344
345
|
</MenuItem>,
|
|
@@ -357,7 +358,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
357
358
|
</ListItemIcon>
|
|
358
359
|
{localization.showAllColumns?.replace(
|
|
359
360
|
'{column}',
|
|
360
|
-
String(column.header),
|
|
361
|
+
String(column.columnDef.header),
|
|
361
362
|
)}
|
|
362
363
|
</Box>
|
|
363
364
|
<IconButton
|
|
@@ -3,12 +3,12 @@ import { Menu, MenuItem } from '@mui/material';
|
|
|
3
3
|
import type { MRT_FilterFn, MRT_Header, MRT_TableInstance } from '..';
|
|
4
4
|
import { MRT_FILTER_OPTION } from '../enums';
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
bestMatchFirst,
|
|
6
|
+
between,
|
|
8
7
|
contains,
|
|
9
8
|
empty,
|
|
10
9
|
endsWith,
|
|
11
10
|
equals,
|
|
11
|
+
fuzzy,
|
|
12
12
|
greaterThan,
|
|
13
13
|
lessThan,
|
|
14
14
|
notEmpty,
|
|
@@ -48,7 +48,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
48
48
|
getState();
|
|
49
49
|
|
|
50
50
|
const filterOptions: {
|
|
51
|
-
|
|
51
|
+
option: MRT_FILTER_OPTION;
|
|
52
52
|
label: string;
|
|
53
53
|
divider: boolean;
|
|
54
54
|
fn: Function;
|
|
@@ -56,67 +56,67 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
56
56
|
() =>
|
|
57
57
|
[
|
|
58
58
|
{
|
|
59
|
-
|
|
60
|
-
label: localization.
|
|
59
|
+
option: MRT_FILTER_OPTION.FUZZY,
|
|
60
|
+
label: localization.filterFuzzy,
|
|
61
61
|
divider: false,
|
|
62
|
-
fn:
|
|
62
|
+
fn: fuzzy,
|
|
63
63
|
},
|
|
64
64
|
{
|
|
65
|
-
|
|
66
|
-
label: localization.filterBestMatch,
|
|
67
|
-
divider: !!header,
|
|
68
|
-
fn: bestMatch,
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
type: MRT_FILTER_OPTION.CONTAINS,
|
|
65
|
+
option: MRT_FILTER_OPTION.CONTAINS,
|
|
72
66
|
label: localization.filterContains,
|
|
73
67
|
divider: false,
|
|
74
68
|
fn: contains,
|
|
75
69
|
},
|
|
76
70
|
{
|
|
77
|
-
|
|
71
|
+
option: MRT_FILTER_OPTION.STARTS_WITH,
|
|
78
72
|
label: localization.filterStartsWith,
|
|
79
73
|
divider: false,
|
|
80
74
|
fn: startsWith,
|
|
81
75
|
},
|
|
82
76
|
{
|
|
83
|
-
|
|
77
|
+
option: MRT_FILTER_OPTION.ENDS_WITH,
|
|
84
78
|
label: localization.filterEndsWith,
|
|
85
79
|
divider: true,
|
|
86
80
|
fn: endsWith,
|
|
87
81
|
},
|
|
88
82
|
{
|
|
89
|
-
|
|
83
|
+
option: MRT_FILTER_OPTION.EQUALS,
|
|
90
84
|
label: localization.filterEquals,
|
|
91
85
|
divider: false,
|
|
92
86
|
fn: equals,
|
|
93
87
|
},
|
|
94
88
|
{
|
|
95
|
-
|
|
89
|
+
option: MRT_FILTER_OPTION.NOT_EQUALS,
|
|
96
90
|
label: localization.filterNotEquals,
|
|
97
91
|
divider: true,
|
|
98
92
|
fn: notEquals,
|
|
99
93
|
},
|
|
100
94
|
{
|
|
101
|
-
|
|
95
|
+
option: MRT_FILTER_OPTION.BETWEEN,
|
|
96
|
+
label: localization.filterBetween,
|
|
97
|
+
divider: false,
|
|
98
|
+
fn: between,
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
option: MRT_FILTER_OPTION.GREATER_THAN,
|
|
102
102
|
label: localization.filterGreaterThan,
|
|
103
103
|
divider: false,
|
|
104
104
|
fn: greaterThan,
|
|
105
105
|
},
|
|
106
106
|
{
|
|
107
|
-
|
|
107
|
+
option: MRT_FILTER_OPTION.LESS_THAN,
|
|
108
108
|
label: localization.filterLessThan,
|
|
109
109
|
divider: true,
|
|
110
110
|
fn: lessThan,
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
|
-
|
|
113
|
+
option: MRT_FILTER_OPTION.EMPTY,
|
|
114
114
|
label: localization.filterEmpty,
|
|
115
115
|
divider: false,
|
|
116
116
|
fn: empty,
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
|
-
|
|
119
|
+
option: MRT_FILTER_OPTION.NOT_EMPTY,
|
|
120
120
|
label: localization.filterNotEmpty,
|
|
121
121
|
divider: false,
|
|
122
122
|
fn: notEmpty,
|
|
@@ -124,13 +124,12 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
124
124
|
].filter((filterType) =>
|
|
125
125
|
header
|
|
126
126
|
? !header.column.enabledColumnFilterOptions ||
|
|
127
|
-
header.column.enabledColumnFilterOptions.includes(filterType.
|
|
127
|
+
header.column.enabledColumnFilterOptions.includes(filterType.option)
|
|
128
128
|
: (!enabledGlobalFilterOptions ||
|
|
129
|
-
enabledGlobalFilterOptions.includes(filterType.
|
|
130
|
-
[
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
].includes(filterType.type),
|
|
129
|
+
enabledGlobalFilterOptions.includes(filterType.option)) &&
|
|
130
|
+
[MRT_FILTER_OPTION.FUZZY, MRT_FILTER_OPTION.CONTAINS].includes(
|
|
131
|
+
filterType.option,
|
|
132
|
+
),
|
|
134
133
|
),
|
|
135
134
|
[],
|
|
136
135
|
);
|
|
@@ -144,7 +143,11 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
144
143
|
if (
|
|
145
144
|
[MRT_FILTER_OPTION.EMPTY, MRT_FILTER_OPTION.NOT_EMPTY].includes(value)
|
|
146
145
|
) {
|
|
147
|
-
header.column.
|
|
146
|
+
header.column.setFilterValue(' ');
|
|
147
|
+
} else if (value === MRT_FILTER_OPTION.BETWEEN) {
|
|
148
|
+
header.column.setFilterValue(['', '']);
|
|
149
|
+
} else {
|
|
150
|
+
header.column.setFilterValue('');
|
|
148
151
|
}
|
|
149
152
|
} else {
|
|
150
153
|
setCurrentGlobalFilterFn(value);
|
|
@@ -153,7 +156,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
153
156
|
onSelect?.();
|
|
154
157
|
};
|
|
155
158
|
|
|
156
|
-
const
|
|
159
|
+
const filterOption = !!header
|
|
157
160
|
? currentFilterFns[header.id]
|
|
158
161
|
: currentGlobalFilterFn;
|
|
159
162
|
|
|
@@ -167,14 +170,14 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
167
170
|
dense: isDensePadding,
|
|
168
171
|
}}
|
|
169
172
|
>
|
|
170
|
-
{filterOptions.map(({
|
|
173
|
+
{filterOptions.map(({ option, label, divider, fn }, index) => (
|
|
171
174
|
<MenuItem
|
|
172
175
|
divider={divider}
|
|
173
176
|
key={index}
|
|
174
|
-
onClick={() => handleSelectFilterType(
|
|
175
|
-
selected={
|
|
177
|
+
onClick={() => handleSelectFilterType(option)}
|
|
178
|
+
selected={option === filterOption || fn === filterOption}
|
|
176
179
|
sx={commonMenuItemStyles}
|
|
177
|
-
value={
|
|
180
|
+
value={option}
|
|
178
181
|
>
|
|
179
182
|
{label}
|
|
180
183
|
</MenuItem>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
2
|
import { Button, Menu, Divider, Box } from '@mui/material';
|
|
3
3
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
|
4
|
-
import { MRT_TableInstance } from '..';
|
|
4
|
+
import { MRT_Column, MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
anchorEl: HTMLElement | null;
|
|
@@ -24,7 +24,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
24
24
|
getState,
|
|
25
25
|
toggleAllColumnsVisible,
|
|
26
26
|
getAllLeafColumns,
|
|
27
|
-
options: { localization },
|
|
27
|
+
options: { localization, enablePinning },
|
|
28
28
|
} = tableInstance;
|
|
29
29
|
|
|
30
30
|
const { isDensePadding } = getState();
|
|
@@ -40,14 +40,16 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
40
40
|
[getAllColumns()],
|
|
41
41
|
);
|
|
42
42
|
|
|
43
|
-
const allDataColumns = useMemo(() => {
|
|
43
|
+
const allDataColumns: (MRT_Column | null)[] = useMemo(() => {
|
|
44
44
|
const dataColumns = getAllColumns().filter(
|
|
45
45
|
(col) => col.columnDefType !== 'display',
|
|
46
46
|
);
|
|
47
47
|
return getIsSomeColumnsPinned()
|
|
48
48
|
? [
|
|
49
49
|
...dataColumns.filter((c) => c.getIsPinned() === 'left'),
|
|
50
|
+
null,
|
|
50
51
|
...dataColumns.filter((c) => c.getIsPinned() === false),
|
|
52
|
+
null,
|
|
51
53
|
...dataColumns.filter((c) => c.getIsPinned() === 'right'),
|
|
52
54
|
]
|
|
53
55
|
: dataColumns;
|
|
@@ -78,6 +80,14 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
78
80
|
{localization.hideAll}
|
|
79
81
|
</Button>
|
|
80
82
|
)}
|
|
83
|
+
{!isSubMenu && enablePinning && (
|
|
84
|
+
<Button
|
|
85
|
+
disabled={!getIsSomeColumnsPinned()}
|
|
86
|
+
onClick={() => tableInstance.resetColumnPinning(true)}
|
|
87
|
+
>
|
|
88
|
+
{localization.unpinAll}
|
|
89
|
+
</Button>
|
|
90
|
+
)}
|
|
81
91
|
<Button
|
|
82
92
|
disabled={getIsAllColumnsVisible()}
|
|
83
93
|
onClick={() => toggleAllColumnsVisible(true)}
|
|
@@ -95,14 +105,18 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
95
105
|
/>
|
|
96
106
|
))}
|
|
97
107
|
<Divider />
|
|
98
|
-
{allDataColumns.map((column, index) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
108
|
+
{allDataColumns.map((column, index) =>
|
|
109
|
+
column ? (
|
|
110
|
+
<MRT_ShowHideColumnsMenuItems
|
|
111
|
+
column={column}
|
|
112
|
+
isSubMenu={isSubMenu}
|
|
113
|
+
key={`${index}-${column.id}`}
|
|
114
|
+
tableInstance={tableInstance}
|
|
115
|
+
/>
|
|
116
|
+
) : (
|
|
117
|
+
<Divider key={`${index}-divider`} />
|
|
118
|
+
),
|
|
119
|
+
)}
|
|
106
120
|
</Menu>
|
|
107
121
|
);
|
|
108
122
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { FormControlLabel, MenuItem, Switch } from '@mui/material';
|
|
3
3
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
4
|
-
import {
|
|
4
|
+
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
column: MRT_Column;
|
|
@@ -44,16 +44,26 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
44
44
|
return (
|
|
45
45
|
<>
|
|
46
46
|
<MenuItem
|
|
47
|
-
sx={{
|
|
47
|
+
sx={{
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
justifyContent: 'flex-start',
|
|
50
|
+
my: 0,
|
|
51
|
+
pl: `${(column.depth + 0.5) * 2}rem`,
|
|
52
|
+
py: '6px',
|
|
53
|
+
}}
|
|
48
54
|
>
|
|
55
|
+
{!isSubMenu && column.getCanPin() && (
|
|
56
|
+
<MRT_ColumnPinningButtons
|
|
57
|
+
column={column}
|
|
58
|
+
tableInstance={tableInstance}
|
|
59
|
+
/>
|
|
60
|
+
)}
|
|
49
61
|
<FormControlLabel
|
|
50
62
|
componentsProps={{ typography: { sx: { marginBottom: 0 } } }}
|
|
51
63
|
checked={switchChecked}
|
|
52
64
|
control={<Switch />}
|
|
53
|
-
disabled={
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
label={column.header}
|
|
65
|
+
disabled={(isSubMenu && switchChecked) || !column.getCanHide()}
|
|
66
|
+
label={column.columnDef.header}
|
|
57
67
|
onChange={() => handleToggleColumnHidden(column)}
|
|
58
68
|
/>
|
|
59
69
|
</MenuItem>
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -6,40 +6,29 @@ import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
|
|
6
6
|
import { MRT_TableInstance } from '..';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
-
pinned: 'left' | 'center' | 'right' | 'none';
|
|
10
9
|
tableInstance: MRT_TableInstance;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export const MRT_Table: FC<Props> = ({
|
|
12
|
+
export const MRT_Table: FC<Props> = ({ tableInstance }) => {
|
|
14
13
|
const {
|
|
15
|
-
getTableProps,
|
|
16
14
|
options: {
|
|
17
|
-
muiTableProps,
|
|
18
|
-
enableTableHead,
|
|
19
|
-
enableTableFooter,
|
|
20
15
|
enableStickyHeader,
|
|
16
|
+
enableTableFooter,
|
|
17
|
+
enableTableHead,
|
|
18
|
+
muiTableProps,
|
|
21
19
|
},
|
|
22
20
|
} = tableInstance;
|
|
23
21
|
|
|
24
|
-
const
|
|
22
|
+
const tableProps =
|
|
25
23
|
muiTableProps instanceof Function
|
|
26
24
|
? muiTableProps({ tableInstance })
|
|
27
25
|
: muiTableProps;
|
|
28
26
|
|
|
29
|
-
const tableProps = {
|
|
30
|
-
...getTableProps(),
|
|
31
|
-
...mTableProps,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
27
|
return (
|
|
35
28
|
<Table stickyHeader={enableStickyHeader} {...tableProps}>
|
|
36
|
-
{enableTableHead &&
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<MRT_TableBody pinned={pinned} tableInstance={tableInstance} />
|
|
40
|
-
{enableTableFooter && (
|
|
41
|
-
<MRT_TableFooter pinned={pinned} tableInstance={tableInstance} />
|
|
42
|
-
)}
|
|
29
|
+
{enableTableHead && <MRT_TableHead tableInstance={tableInstance} />}
|
|
30
|
+
<MRT_TableBody tableInstance={tableInstance} />
|
|
31
|
+
{enableTableFooter && <MRT_TableFooter tableInstance={tableInstance} />}
|
|
43
32
|
</Table>
|
|
44
33
|
);
|
|
45
34
|
};
|
|
@@ -1,27 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, { FC, useEffect, useLayoutEffect, useState } from 'react';
|
|
2
|
+
import { TableContainer } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
import { MRT_Table } from './MRT_Table';
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
theme,
|
|
9
|
-
visible,
|
|
10
|
-
}: {
|
|
11
|
-
pinned?: 'left' | 'right';
|
|
12
|
-
theme: Theme;
|
|
13
|
-
visible?: boolean;
|
|
14
|
-
}): CSSProperties => ({
|
|
15
|
-
display: 'grid',
|
|
16
|
-
minWidth: visible ? '200px' : 0,
|
|
17
|
-
overflowX: pinned ? 'scroll' : 'auto',
|
|
18
|
-
boxShadow:
|
|
19
|
-
pinned === 'left'
|
|
20
|
-
? `0 1px 12px ${alpha(theme.palette.common.black, 0.5)}`
|
|
21
|
-
: pinned === 'right'
|
|
22
|
-
? `0 -1px 12px ${alpha(theme.palette.common.black, 0.5)}`
|
|
23
|
-
: 'none',
|
|
24
|
-
});
|
|
6
|
+
const useIsomorphicLayoutEffect =
|
|
7
|
+
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
25
8
|
|
|
26
9
|
interface Props {
|
|
27
10
|
tableInstance: MRT_TableInstance;
|
|
@@ -29,20 +12,11 @@ interface Props {
|
|
|
29
12
|
|
|
30
13
|
export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
|
|
31
14
|
const {
|
|
32
|
-
getCenterTableWidth,
|
|
33
|
-
getIsSomeColumnsPinned,
|
|
34
|
-
getLeftTableWidth,
|
|
35
|
-
getRightTableWidth,
|
|
36
15
|
getState,
|
|
37
|
-
options: {
|
|
38
|
-
enablePinning,
|
|
39
|
-
enableStickyHeader,
|
|
40
|
-
idPrefix,
|
|
41
|
-
muiTableContainerProps,
|
|
42
|
-
},
|
|
16
|
+
options: { enableStickyHeader, idPrefix, muiTableContainerProps },
|
|
43
17
|
} = tableInstance;
|
|
44
18
|
|
|
45
|
-
const { isFullScreen
|
|
19
|
+
const { isFullScreen } = getState();
|
|
46
20
|
|
|
47
21
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
48
22
|
|
|
@@ -51,7 +25,7 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
|
|
|
51
25
|
? muiTableContainerProps({ tableInstance })
|
|
52
26
|
: muiTableContainerProps;
|
|
53
27
|
|
|
54
|
-
|
|
28
|
+
useIsomorphicLayoutEffect(() => {
|
|
55
29
|
const topToolbarHeight =
|
|
56
30
|
typeof document !== 'undefined'
|
|
57
31
|
? document?.getElementById(`mrt-${idPrefix}-toolbar-top`)
|
|
@@ -84,42 +58,7 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
|
|
|
84
58
|
: undefined,
|
|
85
59
|
}}
|
|
86
60
|
>
|
|
87
|
-
{
|
|
88
|
-
<Box
|
|
89
|
-
sx={{
|
|
90
|
-
display: 'grid',
|
|
91
|
-
gridTemplateColumns: `${getLeftTableWidth()}fr ${getCenterTableWidth()}fr ${getRightTableWidth()}fr`,
|
|
92
|
-
}}
|
|
93
|
-
>
|
|
94
|
-
<Box
|
|
95
|
-
sx={(theme: Theme) =>
|
|
96
|
-
commonBoxStyles({
|
|
97
|
-
pinned: 'left',
|
|
98
|
-
theme,
|
|
99
|
-
visible: !!columnPinning.left?.length,
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
>
|
|
103
|
-
<MRT_Table pinned="left" tableInstance={tableInstance} />
|
|
104
|
-
</Box>
|
|
105
|
-
<Box sx={(theme: Theme) => commonBoxStyles({ theme })}>
|
|
106
|
-
<MRT_Table pinned="center" tableInstance={tableInstance} />
|
|
107
|
-
</Box>
|
|
108
|
-
<Box
|
|
109
|
-
sx={(theme: Theme) =>
|
|
110
|
-
commonBoxStyles({
|
|
111
|
-
pinned: 'right',
|
|
112
|
-
theme,
|
|
113
|
-
visible: !!columnPinning.right?.length,
|
|
114
|
-
})
|
|
115
|
-
}
|
|
116
|
-
>
|
|
117
|
-
<MRT_Table pinned="right" tableInstance={tableInstance} />
|
|
118
|
-
</Box>
|
|
119
|
-
</Box>
|
|
120
|
-
) : (
|
|
121
|
-
<MRT_Table pinned="none" tableInstance={tableInstance} />
|
|
122
|
-
)}
|
|
61
|
+
<MRT_Table tableInstance={tableInstance} />
|
|
123
62
|
</TableContainer>
|
|
124
63
|
);
|
|
125
64
|
};
|