material-react-table 2.9.2 → 2.11.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/README.md +3 -2
- package/dist/index.d.ts +222 -152
- package/dist/index.esm.js +906 -769
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +910 -768
- package/dist/index.js.map +1 -1
- package/locales/ar/index.esm.js +2 -0
- package/locales/ar/index.js +2 -0
- package/locales/az/index.esm.js +2 -0
- package/locales/az/index.js +2 -0
- package/locales/bg/index.esm.js +2 -0
- package/locales/bg/index.js +2 -0
- package/locales/cs/index.esm.js +2 -0
- package/locales/cs/index.js +2 -0
- package/locales/da/index.esm.js +2 -0
- package/locales/da/index.js +2 -0
- package/locales/de/index.esm.js +2 -0
- package/locales/de/index.js +2 -0
- package/locales/en/index.esm.js +2 -0
- package/locales/en/index.js +2 -0
- package/locales/es/index.esm.js +2 -0
- package/locales/es/index.js +2 -0
- package/locales/et/index.esm.js +2 -0
- package/locales/et/index.js +2 -0
- package/locales/fa/index.esm.js +2 -0
- package/locales/fa/index.js +2 -0
- package/locales/fi/index.esm.js +2 -0
- package/locales/fi/index.js +2 -0
- package/locales/fr/index.esm.js +2 -0
- package/locales/fr/index.js +2 -0
- package/locales/he/index.esm.js +2 -0
- package/locales/he/index.js +2 -0
- package/locales/hu/index.esm.js +2 -0
- package/locales/hu/index.js +2 -0
- package/locales/hy/index.esm.js +2 -0
- package/locales/hy/index.js +2 -0
- package/locales/id/index.esm.js +2 -0
- package/locales/id/index.js +2 -0
- package/locales/it/index.esm.js +2 -0
- package/locales/it/index.js +2 -0
- package/locales/ja/index.esm.js +2 -0
- package/locales/ja/index.js +2 -0
- package/locales/ko/index.esm.js +2 -0
- package/locales/ko/index.js +2 -0
- package/locales/nl/index.esm.js +2 -0
- package/locales/nl/index.js +2 -0
- package/locales/no/index.esm.js +2 -0
- package/locales/no/index.js +2 -0
- package/locales/np/index.esm.js +2 -0
- package/locales/np/index.js +2 -0
- package/locales/pl/index.esm.js +2 -0
- package/locales/pl/index.js +2 -0
- package/locales/pt/index.esm.js +2 -0
- package/locales/pt/index.js +2 -0
- package/locales/pt-BR/index.esm.js +2 -0
- package/locales/pt-BR/index.js +2 -0
- package/locales/ro/index.esm.js +2 -0
- package/locales/ro/index.js +2 -0
- package/locales/ru/index.esm.js +2 -0
- package/locales/ru/index.js +2 -0
- package/locales/sk/index.esm.js +2 -0
- package/locales/sk/index.js +2 -0
- package/locales/sr-Cyrl-RS/index.esm.js +2 -0
- package/locales/sr-Cyrl-RS/index.js +2 -0
- package/locales/sr-Latn-RS/index.esm.js +2 -0
- package/locales/sr-Latn-RS/index.js +2 -0
- package/locales/sv/index.esm.js +2 -0
- package/locales/sv/index.js +2 -0
- package/locales/tr/index.esm.js +2 -0
- package/locales/tr/index.js +2 -0
- package/locales/uk/index.esm.js +2 -0
- package/locales/uk/index.js +2 -0
- package/locales/vi/index.esm.js +2 -0
- package/locales/vi/index.js +2 -0
- package/locales/zh-Hans/index.esm.js +2 -0
- package/locales/zh-Hans/index.js +2 -0
- package/locales/zh-Hant/index.esm.js +2 -0
- package/locales/zh-Hant/index.js +2 -0
- package/package.json +20 -20
- package/src/components/MaterialReactTable.tsx +3 -3
- package/src/components/body/MRT_TableBody.tsx +3 -2
- package/src/components/body/MRT_TableBodyCell.tsx +45 -34
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -2
- package/src/components/body/MRT_TableBodyRow.tsx +13 -12
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -3
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +3 -2
- package/src/components/body/MRT_TableDetailPanel.tsx +3 -2
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +3 -2
- package/src/components/buttons/MRT_CopyButton.tsx +4 -2
- package/src/components/buttons/MRT_EditActionButtons.tsx +3 -2
- package/src/components/buttons/MRT_ExpandAllButton.tsx +3 -2
- package/src/components/buttons/MRT_ExpandButton.tsx +3 -2
- package/src/components/buttons/MRT_GrabHandleButton.tsx +9 -15
- package/src/components/buttons/MRT_RowPinButton.tsx +3 -2
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -2
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +3 -2
- package/src/components/footer/MRT_TableFooter.tsx +3 -2
- package/src/components/footer/MRT_TableFooterCell.tsx +3 -2
- package/src/components/footer/MRT_TableFooterRow.tsx +5 -3
- package/src/components/head/MRT_TableHead.tsx +3 -2
- package/src/components/head/MRT_TableHeadCell.tsx +9 -5
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +4 -2
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +4 -3
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +3 -2
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +3 -2
- package/src/components/head/MRT_TableHeadRow.tsx +4 -2
- package/src/components/inputs/MRT_EditCellTextField.tsx +3 -2
- package/src/components/inputs/MRT_FilterCheckbox.tsx +3 -2
- package/src/components/inputs/MRT_FilterRangeFields.tsx +3 -2
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +3 -2
- package/src/components/inputs/MRT_FilterTextField.tsx +15 -6
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +3 -2
- package/src/components/inputs/MRT_SelectCheckbox.tsx +26 -33
- package/src/components/menus/MRT_ActionMenuItem.tsx +61 -0
- package/src/components/menus/MRT_CellActionMenu.tsx +109 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +92 -172
- package/src/components/menus/MRT_FilterOptionMenu.tsx +9 -16
- package/src/components/menus/MRT_RowActionMenu.tsx +10 -17
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +11 -3
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +7 -5
- package/src/components/modals/MRT_EditRowModal.tsx +3 -2
- package/src/components/table/MRT_Table.tsx +2 -2
- package/src/components/table/MRT_TableContainer.tsx +7 -2
- package/src/components/table/MRT_TableLoadingOverlay.tsx +11 -8
- package/src/components/table/MRT_TablePaper.tsx +3 -2
- package/src/components/toolbar/MRT_BottomToolbar.tsx +3 -2
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +3 -2
- package/src/components/toolbar/MRT_TablePagination.tsx +2 -2
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +30 -13
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +3 -2
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +3 -2
- package/src/components/toolbar/MRT_TopToolbar.tsx +2 -2
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +1 -8
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -8
- package/src/hooks/useMRT_Effects.ts +14 -4
- package/src/hooks/useMRT_Rows.ts +11 -79
- package/src/hooks/useMRT_TableInstance.ts +114 -59
- package/src/hooks/useMRT_TableOptions.ts +2 -0
- package/src/icons.ts +2 -0
- package/src/index.ts +2 -0
- package/src/locales/ar.ts +2 -0
- package/src/locales/az.ts +2 -0
- package/src/locales/bg.ts +2 -0
- package/src/locales/cs.ts +2 -0
- package/src/locales/da.ts +2 -0
- package/src/locales/de.ts +2 -0
- package/src/locales/en.ts +2 -0
- package/src/locales/es.ts +2 -0
- package/src/locales/et.ts +2 -0
- package/src/locales/fa.ts +2 -0
- package/src/locales/fi.ts +2 -0
- package/src/locales/fr.ts +2 -0
- package/src/locales/he.ts +2 -0
- package/src/locales/hu.ts +2 -0
- package/src/locales/hy.ts +2 -0
- package/src/locales/id.ts +2 -0
- package/src/locales/it.ts +2 -0
- package/src/locales/ja.ts +2 -0
- package/src/locales/ko.ts +2 -0
- package/src/locales/nl.ts +2 -0
- package/src/locales/no.ts +2 -0
- package/src/locales/np.ts +2 -0
- package/src/locales/pl.ts +2 -0
- package/src/locales/pt-BR.ts +2 -0
- package/src/locales/pt.ts +2 -0
- package/src/locales/ro.ts +2 -0
- package/src/locales/ru.ts +2 -0
- package/src/locales/sk.ts +2 -0
- package/src/locales/sr-Cyrl-RS.ts +2 -0
- package/src/locales/sr-Latn-RS.ts +2 -0
- package/src/locales/sv.ts +2 -0
- package/src/locales/tr.ts +2 -0
- package/src/locales/uk.ts +2 -0
- package/src/locales/vi.ts +2 -0
- package/src/locales/zh-Hans.ts +2 -0
- package/src/locales/zh-Hant.ts +2 -0
- package/src/types.ts +51 -13
- package/src/utils/cell.utils.ts +50 -0
- package/src/utils/column.utils.ts +4 -6
- package/src/utils/displayColumn.utils.ts +39 -21
- package/src/utils/row.utils.ts +179 -21
- package/locales/am/index.d.ts +0 -3
- package/locales/am/index.esm.d.ts +0 -3
- package/locales/am/index.esm.js +0 -93
- package/locales/am/index.js +0 -97
- package/locales/am/package.json +0 -6
- package/src/hooks/display-columns/getMRT_DisplayColumns.tsx +0 -26
- package/src/locales/am.ts +0 -94
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import Box from '@mui/material/Box';
|
|
4
|
-
import IconButton from '@mui/material/IconButton';
|
|
5
|
-
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
1
|
+
import { type MouseEvent, useState } from 'react';
|
|
6
2
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
|
7
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
8
3
|
import { useTheme } from '@mui/material/styles';
|
|
4
|
+
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
|
9
5
|
import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu';
|
|
10
6
|
import {
|
|
11
7
|
type MRT_Header,
|
|
@@ -14,19 +10,8 @@ import {
|
|
|
14
10
|
} from '../../types';
|
|
15
11
|
import { getMRTTheme } from '../../utils/style.utils';
|
|
16
12
|
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
justifyContent: 'space-between',
|
|
20
|
-
my: 0,
|
|
21
|
-
py: '6px',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const commonListItemStyles = {
|
|
25
|
-
alignItems: 'center',
|
|
26
|
-
display: 'flex',
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
interface Props<TData extends MRT_RowData> extends Partial<MenuProps> {
|
|
13
|
+
export interface MRT_ColumnActionMenuProps<TData extends MRT_RowData>
|
|
14
|
+
extends Partial<MenuProps> {
|
|
30
15
|
anchorEl: HTMLElement | null;
|
|
31
16
|
header: MRT_Header<TData>;
|
|
32
17
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
@@ -39,8 +24,9 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
|
39
24
|
setAnchorEl,
|
|
40
25
|
table,
|
|
41
26
|
...rest
|
|
42
|
-
}:
|
|
27
|
+
}: MRT_ColumnActionMenuProps<TData>) => {
|
|
43
28
|
const {
|
|
29
|
+
getAllLeafColumns,
|
|
44
30
|
getState,
|
|
45
31
|
options: {
|
|
46
32
|
columnFilterDisplayMode,
|
|
@@ -54,7 +40,6 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
|
54
40
|
enableSorting,
|
|
55
41
|
enableSortingRemoval,
|
|
56
42
|
icons: {
|
|
57
|
-
ArrowRightIcon,
|
|
58
43
|
ClearAllIcon,
|
|
59
44
|
DynamicFeedIcon,
|
|
60
45
|
FilterListIcon,
|
|
@@ -73,7 +58,6 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
|
73
58
|
setColumnOrder,
|
|
74
59
|
setColumnSizingInfo,
|
|
75
60
|
setShowColumnFilters,
|
|
76
|
-
toggleAllColumnsVisible,
|
|
77
61
|
} = table;
|
|
78
62
|
const { column } = header;
|
|
79
63
|
const { columnDef } = column;
|
|
@@ -139,11 +123,13 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
|
139
123
|
};
|
|
140
124
|
|
|
141
125
|
const handleShowAllColumns = () => {
|
|
142
|
-
|
|
126
|
+
getAllLeafColumns()
|
|
127
|
+
.filter((col) => col.columnDef.enableHiding !== false)
|
|
128
|
+
.forEach((col) => col.toggleVisibility(true));
|
|
143
129
|
setAnchorEl(null);
|
|
144
130
|
};
|
|
145
131
|
|
|
146
|
-
const handleOpenFilterModeMenu = (event:
|
|
132
|
+
const handleOpenFilterModeMenu = (event: MouseEvent<HTMLElement>) => {
|
|
147
133
|
event.stopPropagation();
|
|
148
134
|
setFilterMenuAnchorEl(event.currentTarget);
|
|
149
135
|
};
|
|
@@ -164,106 +150,75 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
|
164
150
|
...(enableSorting && column.getCanSort()
|
|
165
151
|
? [
|
|
166
152
|
enableSortingRemoval !== false && (
|
|
167
|
-
<
|
|
168
|
-
|
|
153
|
+
<MRT_ActionMenuItem
|
|
154
|
+
icon={<ClearAllIcon />}
|
|
169
155
|
key={0}
|
|
156
|
+
label={localization.clearSort}
|
|
170
157
|
onClick={handleClearSort}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
<Box sx={commonListItemStyles}>
|
|
174
|
-
<ListItemIcon>
|
|
175
|
-
<ClearAllIcon />
|
|
176
|
-
</ListItemIcon>
|
|
177
|
-
{localization.clearSort}
|
|
178
|
-
</Box>
|
|
179
|
-
</MenuItem>
|
|
158
|
+
table={table}
|
|
159
|
+
/>
|
|
180
160
|
),
|
|
181
|
-
<
|
|
161
|
+
<MRT_ActionMenuItem
|
|
182
162
|
disabled={column.getIsSorted() === 'asc'}
|
|
163
|
+
icon={
|
|
164
|
+
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
|
|
165
|
+
}
|
|
183
166
|
key={1}
|
|
167
|
+
label={localization.sortByColumnAsc?.replace(
|
|
168
|
+
'{column}',
|
|
169
|
+
String(columnDef.header),
|
|
170
|
+
)}
|
|
184
171
|
onClick={handleSortAsc}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
<ListItemIcon>
|
|
189
|
-
<SortIcon style={{ transform: 'rotate(180deg) scaleX(-1)' }} />
|
|
190
|
-
</ListItemIcon>
|
|
191
|
-
{localization.sortByColumnAsc?.replace(
|
|
192
|
-
'{column}',
|
|
193
|
-
String(columnDef.header),
|
|
194
|
-
)}
|
|
195
|
-
</Box>
|
|
196
|
-
</MenuItem>,
|
|
197
|
-
<MenuItem
|
|
172
|
+
table={table}
|
|
173
|
+
/>,
|
|
174
|
+
<MRT_ActionMenuItem
|
|
198
175
|
disabled={column.getIsSorted() === 'desc'}
|
|
199
176
|
divider={enableColumnFilters || enableGrouping || enableHiding}
|
|
177
|
+
icon={<SortIcon />}
|
|
200
178
|
key={2}
|
|
179
|
+
label={localization.sortByColumnDesc?.replace(
|
|
180
|
+
'{column}',
|
|
181
|
+
String(columnDef.header),
|
|
182
|
+
)}
|
|
201
183
|
onClick={handleSortDesc}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<Box sx={commonListItemStyles}>
|
|
205
|
-
<ListItemIcon>
|
|
206
|
-
<SortIcon />
|
|
207
|
-
</ListItemIcon>
|
|
208
|
-
{localization.sortByColumnDesc?.replace(
|
|
209
|
-
'{column}',
|
|
210
|
-
String(columnDef.header),
|
|
211
|
-
)}
|
|
212
|
-
</Box>
|
|
213
|
-
</MenuItem>,
|
|
184
|
+
table={table}
|
|
185
|
+
/>,
|
|
214
186
|
]
|
|
215
187
|
: []),
|
|
216
188
|
...(enableColumnFilters && column.getCanFilter()
|
|
217
189
|
? [
|
|
218
|
-
<
|
|
190
|
+
<MRT_ActionMenuItem
|
|
219
191
|
disabled={
|
|
220
192
|
!columnFilterValue ||
|
|
221
193
|
(Array.isArray(columnFilterValue) &&
|
|
222
194
|
!columnFilterValue.filter((value) => value).length)
|
|
223
195
|
}
|
|
196
|
+
icon={<FilterListOffIcon />}
|
|
224
197
|
key={3}
|
|
198
|
+
label={localization.clearFilter}
|
|
225
199
|
onClick={handleClearFilter}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
<Box sx={commonListItemStyles}>
|
|
229
|
-
<ListItemIcon>
|
|
230
|
-
<FilterListOffIcon />
|
|
231
|
-
</ListItemIcon>
|
|
232
|
-
{localization.clearFilter}
|
|
233
|
-
</Box>
|
|
234
|
-
</MenuItem>,
|
|
200
|
+
table={table}
|
|
201
|
+
/>,
|
|
235
202
|
columnFilterDisplayMode === 'subheader' && (
|
|
236
|
-
<
|
|
203
|
+
<MRT_ActionMenuItem
|
|
237
204
|
disabled={showColumnFilters && !enableColumnFilterModes}
|
|
238
205
|
divider={enableGrouping || enableHiding}
|
|
206
|
+
icon={<FilterListIcon />}
|
|
239
207
|
key={4}
|
|
208
|
+
label={localization.filterByColumn?.replace(
|
|
209
|
+
'{column}',
|
|
210
|
+
String(columnDef.header),
|
|
211
|
+
)}
|
|
240
212
|
onClick={
|
|
241
213
|
showColumnFilters
|
|
242
214
|
? handleOpenFilterModeMenu
|
|
243
215
|
: handleFilterByColumn
|
|
244
216
|
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
</ListItemIcon>
|
|
251
|
-
{localization.filterByColumn?.replace(
|
|
252
|
-
'{column}',
|
|
253
|
-
String(columnDef.header),
|
|
254
|
-
)}
|
|
255
|
-
</Box>
|
|
256
|
-
{showFilterModeSubMenu && (
|
|
257
|
-
<IconButton
|
|
258
|
-
onClick={handleOpenFilterModeMenu}
|
|
259
|
-
onMouseEnter={handleOpenFilterModeMenu}
|
|
260
|
-
size="small"
|
|
261
|
-
sx={{ p: 0 }}
|
|
262
|
-
>
|
|
263
|
-
<ArrowRightIcon />
|
|
264
|
-
</IconButton>
|
|
265
|
-
)}
|
|
266
|
-
</MenuItem>
|
|
217
|
+
onOpenSubMenu={
|
|
218
|
+
showFilterModeSubMenu ? handleOpenFilterModeMenu : undefined
|
|
219
|
+
}
|
|
220
|
+
table={table}
|
|
221
|
+
/>
|
|
267
222
|
),
|
|
268
223
|
showFilterModeSubMenu && (
|
|
269
224
|
<MRT_FilterOptionMenu
|
|
@@ -279,121 +234,86 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
|
279
234
|
: []),
|
|
280
235
|
...(enableGrouping && column.getCanGroup()
|
|
281
236
|
? [
|
|
282
|
-
<
|
|
237
|
+
<MRT_ActionMenuItem
|
|
283
238
|
divider={enableColumnPinning}
|
|
239
|
+
icon={<DynamicFeedIcon />}
|
|
284
240
|
key={6}
|
|
241
|
+
label={localization[
|
|
242
|
+
column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn'
|
|
243
|
+
]?.replace('{column}', String(columnDef.header))}
|
|
285
244
|
onClick={handleGroupByColumn}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
<Box sx={commonListItemStyles}>
|
|
289
|
-
<ListItemIcon>
|
|
290
|
-
<DynamicFeedIcon />
|
|
291
|
-
</ListItemIcon>
|
|
292
|
-
{localization[
|
|
293
|
-
column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn'
|
|
294
|
-
]?.replace('{column}', String(columnDef.header))}
|
|
295
|
-
</Box>
|
|
296
|
-
</MenuItem>,
|
|
245
|
+
table={table}
|
|
246
|
+
/>,
|
|
297
247
|
]
|
|
298
248
|
: []),
|
|
299
249
|
...(enableColumnPinning && column.getCanPin()
|
|
300
250
|
? [
|
|
301
|
-
<
|
|
251
|
+
<MRT_ActionMenuItem
|
|
302
252
|
disabled={column.getIsPinned() === 'left' || !column.getCanPin()}
|
|
253
|
+
icon={<PushPinIcon style={{ transform: 'rotate(90deg)' }} />}
|
|
303
254
|
key={7}
|
|
255
|
+
label={localization.pinToLeft}
|
|
304
256
|
onClick={() => handlePinColumn('left')}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
<ListItemIcon>
|
|
309
|
-
<PushPinIcon style={{ transform: 'rotate(90deg)' }} />
|
|
310
|
-
</ListItemIcon>
|
|
311
|
-
{localization.pinToLeft}
|
|
312
|
-
</Box>
|
|
313
|
-
</MenuItem>,
|
|
314
|
-
<MenuItem
|
|
257
|
+
table={table}
|
|
258
|
+
/>,
|
|
259
|
+
<MRT_ActionMenuItem
|
|
315
260
|
disabled={column.getIsPinned() === 'right' || !column.getCanPin()}
|
|
261
|
+
icon={<PushPinIcon style={{ transform: 'rotate(-90deg)' }} />}
|
|
316
262
|
key={8}
|
|
263
|
+
label={localization.pinToRight}
|
|
317
264
|
onClick={() => handlePinColumn('right')}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
<ListItemIcon>
|
|
322
|
-
<PushPinIcon style={{ transform: 'rotate(-90deg)' }} />
|
|
323
|
-
</ListItemIcon>
|
|
324
|
-
{localization.pinToRight}
|
|
325
|
-
</Box>
|
|
326
|
-
</MenuItem>,
|
|
327
|
-
<MenuItem
|
|
265
|
+
table={table}
|
|
266
|
+
/>,
|
|
267
|
+
<MRT_ActionMenuItem
|
|
328
268
|
disabled={!column.getIsPinned()}
|
|
329
269
|
divider={enableHiding}
|
|
270
|
+
icon={<PushPinIcon />}
|
|
330
271
|
key={9}
|
|
272
|
+
label={localization.unpin}
|
|
331
273
|
onClick={() => handlePinColumn(false)}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
<Box sx={commonListItemStyles}>
|
|
335
|
-
<ListItemIcon>
|
|
336
|
-
<PushPinIcon />
|
|
337
|
-
</ListItemIcon>
|
|
338
|
-
{localization.unpin}
|
|
339
|
-
</Box>
|
|
340
|
-
</MenuItem>,
|
|
274
|
+
table={table}
|
|
275
|
+
/>,
|
|
341
276
|
]
|
|
342
277
|
: []),
|
|
343
278
|
...(enableColumnResizing && column.getCanResize()
|
|
344
279
|
? [
|
|
345
|
-
<
|
|
280
|
+
<MRT_ActionMenuItem
|
|
346
281
|
disabled={!columnSizing[column.id]}
|
|
282
|
+
icon={<RestartAltIcon />}
|
|
347
283
|
key={10}
|
|
284
|
+
label={localization.resetColumnSize}
|
|
348
285
|
onClick={handleResetColumnSize}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
<Box sx={commonListItemStyles}>
|
|
352
|
-
<ListItemIcon>
|
|
353
|
-
<RestartAltIcon />
|
|
354
|
-
</ListItemIcon>
|
|
355
|
-
{localization.resetColumnSize}
|
|
356
|
-
</Box>
|
|
357
|
-
</MenuItem>,
|
|
286
|
+
table={table}
|
|
287
|
+
/>,
|
|
358
288
|
]
|
|
359
289
|
: []),
|
|
360
290
|
...(enableHiding
|
|
361
291
|
? [
|
|
362
|
-
<
|
|
292
|
+
<MRT_ActionMenuItem
|
|
363
293
|
disabled={!column.getCanHide()}
|
|
294
|
+
icon={<VisibilityOffIcon />}
|
|
364
295
|
key={11}
|
|
296
|
+
label={localization.hideColumn?.replace(
|
|
297
|
+
'{column}',
|
|
298
|
+
String(columnDef.header),
|
|
299
|
+
)}
|
|
365
300
|
onClick={handleHideColumn}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
<ListItemIcon>
|
|
370
|
-
<VisibilityOffIcon />
|
|
371
|
-
</ListItemIcon>
|
|
372
|
-
{localization.hideColumn?.replace(
|
|
373
|
-
'{column}',
|
|
374
|
-
String(columnDef.header),
|
|
375
|
-
)}
|
|
376
|
-
</Box>
|
|
377
|
-
</MenuItem>,
|
|
378
|
-
<MenuItem
|
|
301
|
+
table={table}
|
|
302
|
+
/>,
|
|
303
|
+
<MRT_ActionMenuItem
|
|
379
304
|
disabled={
|
|
380
305
|
!Object.values(columnVisibility).filter((visible) => !visible)
|
|
381
306
|
.length
|
|
382
307
|
}
|
|
308
|
+
icon={<ViewColumnIcon />}
|
|
383
309
|
key={12}
|
|
310
|
+
label={localization.showAllColumns?.replace(
|
|
311
|
+
'{column}',
|
|
312
|
+
String(columnDef.header),
|
|
313
|
+
)}
|
|
384
314
|
onClick={handleShowAllColumns}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
<Box sx={commonListItemStyles}>
|
|
388
|
-
<ListItemIcon>
|
|
389
|
-
<ViewColumnIcon />
|
|
390
|
-
</ListItemIcon>
|
|
391
|
-
{localization.showAllColumns?.replace(
|
|
392
|
-
'{column}',
|
|
393
|
-
String(columnDef.header),
|
|
394
|
-
)}
|
|
395
|
-
</Box>
|
|
396
|
-
</MenuItem>,
|
|
315
|
+
table={table}
|
|
316
|
+
/>,
|
|
397
317
|
]
|
|
398
318
|
: []),
|
|
399
319
|
].filter(Boolean);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
|
-
import Box from '@mui/material/Box';
|
|
3
2
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
|
4
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
5
3
|
import { useTheme } from '@mui/material/styles';
|
|
4
|
+
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
|
6
5
|
import {
|
|
7
6
|
type MRT_FilterOption,
|
|
8
7
|
type MRT_Header,
|
|
@@ -107,7 +106,8 @@ const emptyModes = ['empty', 'notEmpty'];
|
|
|
107
106
|
const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
|
|
108
107
|
const rangeVariants = ['range-slider', 'date-range', 'datetime-range', 'range'];
|
|
109
108
|
|
|
110
|
-
interface
|
|
109
|
+
export interface MRT_FilterOptionMenuProps<TData extends MRT_RowData>
|
|
110
|
+
extends Partial<MenuProps> {
|
|
111
111
|
anchorEl: HTMLElement | null;
|
|
112
112
|
header?: MRT_Header<TData>;
|
|
113
113
|
onSelect?: () => void;
|
|
@@ -124,7 +124,7 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
|
|
|
124
124
|
setFilterValue,
|
|
125
125
|
table,
|
|
126
126
|
...rest
|
|
127
|
-
}:
|
|
127
|
+
}: MRT_FilterOptionMenuProps<TData>) => {
|
|
128
128
|
const {
|
|
129
129
|
getState,
|
|
130
130
|
options: {
|
|
@@ -277,23 +277,16 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
|
|
|
277
277
|
})) ??
|
|
278
278
|
internalFilterOptions.map(
|
|
279
279
|
({ divider, label, option, symbol }, index) => (
|
|
280
|
-
<
|
|
280
|
+
<MRT_ActionMenuItem
|
|
281
281
|
divider={divider}
|
|
282
|
+
icon={symbol}
|
|
282
283
|
key={index}
|
|
284
|
+
label={label}
|
|
283
285
|
onClick={() => handleSelectFilterMode(option as MRT_FilterOption)}
|
|
284
286
|
selected={option === filterOption}
|
|
285
|
-
|
|
286
|
-
alignItems: 'center',
|
|
287
|
-
display: 'flex',
|
|
288
|
-
gap: '2ch',
|
|
289
|
-
my: 0,
|
|
290
|
-
py: '6px',
|
|
291
|
-
}}
|
|
287
|
+
table={table}
|
|
292
288
|
value={option}
|
|
293
|
-
|
|
294
|
-
<Box sx={{ fontSize: '1.25rem', width: '2ch' }}>{symbol}</Box>
|
|
295
|
-
{label}
|
|
296
|
-
</MenuItem>
|
|
289
|
+
/>
|
|
297
290
|
),
|
|
298
291
|
)}
|
|
299
292
|
</Menu>
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
import { type MouseEvent } from 'react';
|
|
2
|
-
import Box from '@mui/material/Box';
|
|
3
|
-
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
4
2
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
|
5
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
6
3
|
import { useTheme } from '@mui/material/styles';
|
|
7
|
-
import {
|
|
8
|
-
commonListItemStyles,
|
|
9
|
-
commonMenuItemStyles,
|
|
10
|
-
} from './MRT_ColumnActionMenu';
|
|
4
|
+
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
|
11
5
|
import {
|
|
12
6
|
type MRT_Row,
|
|
13
7
|
type MRT_RowData,
|
|
@@ -16,7 +10,8 @@ import {
|
|
|
16
10
|
import { getMRTTheme } from '../../utils/style.utils';
|
|
17
11
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
18
12
|
|
|
19
|
-
interface
|
|
13
|
+
export interface MRT_RowActionMenuProps<TData extends MRT_RowData>
|
|
14
|
+
extends Partial<MenuProps> {
|
|
20
15
|
anchorEl: HTMLElement | null;
|
|
21
16
|
handleEdit: (event: MouseEvent) => void;
|
|
22
17
|
row: MRT_Row<TData>;
|
|
@@ -33,7 +28,7 @@ export const MRT_RowActionMenu = <TData extends MRT_RowData>({
|
|
|
33
28
|
staticRowIndex,
|
|
34
29
|
table,
|
|
35
30
|
...rest
|
|
36
|
-
}:
|
|
31
|
+
}: MRT_RowActionMenuProps<TData>) => {
|
|
37
32
|
const {
|
|
38
33
|
getState,
|
|
39
34
|
options: {
|
|
@@ -66,14 +61,12 @@ export const MRT_RowActionMenu = <TData extends MRT_RowData>({
|
|
|
66
61
|
>
|
|
67
62
|
{parseFromValuesOrFunc(enableEditing, row) &&
|
|
68
63
|
['modal', 'row'].includes(editDisplayMode!) && (
|
|
69
|
-
<
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</Box>
|
|
76
|
-
</MenuItem>
|
|
64
|
+
<MRT_ActionMenuItem
|
|
65
|
+
icon={<EditIcon />}
|
|
66
|
+
label={localization.edit}
|
|
67
|
+
onClick={handleEdit}
|
|
68
|
+
table={table}
|
|
69
|
+
/>
|
|
77
70
|
)}
|
|
78
71
|
{renderRowActionMenuItems?.({
|
|
79
72
|
closeMenu: () => setAnchorEl(null),
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
import { getDefaultColumnOrderIds } from '../../utils/displayColumn.utils';
|
|
14
14
|
import { getMRTTheme } from '../../utils/style.utils';
|
|
15
15
|
|
|
16
|
-
interface
|
|
16
|
+
export interface MRT_ShowHideColumnsMenuProps<TData extends MRT_RowData>
|
|
17
|
+
extends Partial<MenuProps> {
|
|
17
18
|
anchorEl: HTMLElement | null;
|
|
18
19
|
isSubMenu?: boolean;
|
|
19
20
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
@@ -25,7 +26,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
|
25
26
|
setAnchorEl,
|
|
26
27
|
table,
|
|
27
28
|
...rest
|
|
28
|
-
}:
|
|
29
|
+
}: MRT_ShowHideColumnsMenuProps<TData>) => {
|
|
29
30
|
const {
|
|
30
31
|
getAllColumns,
|
|
31
32
|
getAllLeafColumns,
|
|
@@ -75,6 +76,10 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
|
75
76
|
getRightLeafColumns(),
|
|
76
77
|
]) as MRT_Column<TData>[];
|
|
77
78
|
|
|
79
|
+
const isNestedColumns = allColumns.some(
|
|
80
|
+
(col) => col.columnDef.columnDefType === 'group',
|
|
81
|
+
);
|
|
82
|
+
|
|
78
83
|
const [hoveredColumn, setHoveredColumn] = useState<MRT_Column<TData> | null>(
|
|
79
84
|
null,
|
|
80
85
|
);
|
|
@@ -115,7 +120,9 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
|
115
120
|
{enableColumnOrdering && (
|
|
116
121
|
<Button
|
|
117
122
|
onClick={() =>
|
|
118
|
-
table.setColumnOrder(
|
|
123
|
+
table.setColumnOrder(
|
|
124
|
+
getDefaultColumnOrderIds(table.options, true),
|
|
125
|
+
)
|
|
119
126
|
}
|
|
120
127
|
>
|
|
121
128
|
{localization.resetOrder}
|
|
@@ -144,6 +151,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
|
144
151
|
allColumns={allColumns}
|
|
145
152
|
column={column}
|
|
146
153
|
hoveredColumn={hoveredColumn}
|
|
154
|
+
isNestedColumns={isNestedColumns}
|
|
147
155
|
key={`${index}-${column.id}`}
|
|
148
156
|
setHoveredColumn={setHoveredColumn}
|
|
149
157
|
table={table}
|
|
@@ -22,10 +22,12 @@ import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
|
22
22
|
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
|
23
23
|
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
24
24
|
|
|
25
|
-
interface
|
|
25
|
+
export interface MRT_ShowHideColumnsMenuItemsProps<TData extends MRT_RowData>
|
|
26
|
+
extends MenuItemProps {
|
|
26
27
|
allColumns: MRT_Column<TData>[];
|
|
27
28
|
column: MRT_Column<TData>;
|
|
28
29
|
hoveredColumn: MRT_Column<TData> | null;
|
|
30
|
+
isNestedColumns: boolean;
|
|
29
31
|
setHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
30
32
|
table: MRT_TableInstance<TData>;
|
|
31
33
|
}
|
|
@@ -34,10 +36,11 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
|
34
36
|
allColumns,
|
|
35
37
|
column,
|
|
36
38
|
hoveredColumn,
|
|
39
|
+
isNestedColumns,
|
|
37
40
|
setHoveredColumn,
|
|
38
41
|
table,
|
|
39
42
|
...rest
|
|
40
|
-
}:
|
|
43
|
+
}: MRT_ShowHideColumnsMenuItemsProps<TData>) => {
|
|
41
44
|
const {
|
|
42
45
|
getState,
|
|
43
46
|
options: {
|
|
@@ -130,9 +133,7 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
|
130
133
|
>
|
|
131
134
|
{columnDefType !== 'group' &&
|
|
132
135
|
enableColumnOrdering &&
|
|
133
|
-
!
|
|
134
|
-
(col) => col.columnDef.columnDefType === 'group',
|
|
135
|
-
) &&
|
|
136
|
+
!isNestedColumns &&
|
|
136
137
|
(columnDef.enableColumnOrdering !== false ? (
|
|
137
138
|
<MRT_GrabHandleButton
|
|
138
139
|
onDragEnd={handleDragEnd}
|
|
@@ -183,6 +184,7 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
|
183
184
|
allColumns={allColumns}
|
|
184
185
|
column={c}
|
|
185
186
|
hoveredColumn={hoveredColumn}
|
|
187
|
+
isNestedColumns={isNestedColumns}
|
|
186
188
|
key={`${i}-${c.id}`}
|
|
187
189
|
setHoveredColumn={setHoveredColumn}
|
|
188
190
|
table={table}
|
|
@@ -12,7 +12,8 @@ import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
|
12
12
|
import { MRT_EditActionButtons } from '../buttons/MRT_EditActionButtons';
|
|
13
13
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
14
14
|
|
|
15
|
-
interface
|
|
15
|
+
export interface MRT_EditRowModalProps<TData extends MRT_RowData>
|
|
16
|
+
extends Partial<DialogProps> {
|
|
16
17
|
open: boolean;
|
|
17
18
|
table: MRT_TableInstance<TData>;
|
|
18
19
|
}
|
|
@@ -21,7 +22,7 @@ export const MRT_EditRowModal = <TData extends MRT_RowData>({
|
|
|
21
22
|
open,
|
|
22
23
|
table,
|
|
23
24
|
...rest
|
|
24
|
-
}:
|
|
25
|
+
}: MRT_EditRowModalProps<TData>) => {
|
|
25
26
|
const {
|
|
26
27
|
getState,
|
|
27
28
|
options: {
|
|
@@ -8,14 +8,14 @@ import { MRT_TableBody, Memo_MRT_TableBody } from '../body/MRT_TableBody';
|
|
|
8
8
|
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
|
9
9
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|
|
10
10
|
|
|
11
|
-
interface
|
|
11
|
+
export interface MRT_TableProps<TData extends MRT_RowData> extends TableProps {
|
|
12
12
|
table: MRT_TableInstance<TData>;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export const MRT_Table = <TData extends MRT_RowData>({
|
|
16
16
|
table,
|
|
17
17
|
...rest
|
|
18
|
-
}:
|
|
18
|
+
}: MRT_TableProps<TData>) => {
|
|
19
19
|
const {
|
|
20
20
|
getFlatHeaders,
|
|
21
21
|
getState,
|
|
@@ -6,30 +6,34 @@ import { MRT_Table } from './MRT_Table';
|
|
|
6
6
|
import { MRT_TableLoadingOverlay } from './MRT_TableLoadingOverlay';
|
|
7
7
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
8
8
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
9
|
+
import { MRT_CellActionMenu } from '../menus/MRT_CellActionMenu';
|
|
9
10
|
import { MRT_EditRowModal } from '../modals/MRT_EditRowModal';
|
|
10
11
|
|
|
11
12
|
const useIsomorphicLayoutEffect =
|
|
12
13
|
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
13
14
|
|
|
14
|
-
interface
|
|
15
|
+
export interface MRT_TableContainerProps<TData extends MRT_RowData>
|
|
16
|
+
extends TableContainerProps {
|
|
15
17
|
table: MRT_TableInstance<TData>;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
20
|
export const MRT_TableContainer = <TData extends MRT_RowData>({
|
|
19
21
|
table,
|
|
20
22
|
...rest
|
|
21
|
-
}:
|
|
23
|
+
}: MRT_TableContainerProps<TData>) => {
|
|
22
24
|
const {
|
|
23
25
|
getState,
|
|
24
26
|
options: {
|
|
25
27
|
createDisplayMode,
|
|
26
28
|
editDisplayMode,
|
|
29
|
+
enableCellActions,
|
|
27
30
|
enableStickyHeader,
|
|
28
31
|
muiTableContainerProps,
|
|
29
32
|
},
|
|
30
33
|
refs: { bottomToolbarRef, tableContainerRef, topToolbarRef },
|
|
31
34
|
} = table;
|
|
32
35
|
const {
|
|
36
|
+
actionCell,
|
|
33
37
|
creatingRow,
|
|
34
38
|
editingRow,
|
|
35
39
|
isFullScreen,
|
|
@@ -101,6 +105,7 @@ export const MRT_TableContainer = <TData extends MRT_RowData>({
|
|
|
101
105
|
{(createModalOpen || editModalOpen) && (
|
|
102
106
|
<MRT_EditRowModal open table={table} />
|
|
103
107
|
)}
|
|
108
|
+
{enableCellActions && actionCell && <MRT_CellActionMenu table={table} />}
|
|
104
109
|
</TableContainer>
|
|
105
110
|
);
|
|
106
111
|
};
|