material-react-table 0.7.0-alpha.1 → 0.7.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 +195 -58
- package/dist/material-react-table.cjs.development.js +239 -931
- 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 +239 -931
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +364 -126
- package/src/body/MRT_TableBody.tsx +1 -1
- package/src/body/MRT_TableBodyCell.tsx +3 -3
- package/src/body/MRT_TableBodyRow.tsx +2 -2
- package/src/body/MRT_TableDetailPanel.tsx +6 -4
- package/src/buttons/MRT_CopyButton.tsx +2 -2
- package/src/buttons/MRT_EditActionButtons.tsx +4 -2
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/buttons/MRT_ToggleSearchButton.tsx +6 -1
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +2 -2
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHead.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +22 -29
- package/src/head/MRT_TableHeadRow.tsx +1 -1
- package/src/inputs/MRT_EditCellTextField.tsx +7 -7
- package/src/inputs/MRT_FilterTextField.tsx +2 -2
- package/src/inputs/MRT_SearchTextField.tsx +8 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +9 -7
- package/src/menus/MRT_RowActionMenu.tsx +5 -3
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +4 -5
- package/src/table/MRT_Table.tsx +1 -1
- package/src/table/MRT_TableContainer.tsx +16 -20
- package/src/table/MRT_TablePaper.tsx +9 -5
- package/src/toolbar/MRT_LinearProgressBar.tsx +1 -1
- package/src/toolbar/MRT_TablePagination.tsx +3 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +2 -1
- package/src/toolbar/MRT_ToolbarBottom.tsx +1 -1
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +5 -4
- package/src/toolbar/MRT_ToolbarTop.tsx +2 -2
|
@@ -20,12 +20,12 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, tableInstance }) => {
|
|
|
20
20
|
|
|
21
21
|
const tableRowProps =
|
|
22
22
|
muiTableBodyRowProps instanceof Function
|
|
23
|
-
? muiTableBodyRowProps(row)
|
|
23
|
+
? muiTableBodyRowProps({ row, tableInstance })
|
|
24
24
|
: muiTableBodyRowProps;
|
|
25
25
|
|
|
26
26
|
const tableCellProps =
|
|
27
27
|
muiTableDetailPanelProps instanceof Function
|
|
28
|
-
? muiTableDetailPanelProps(row)
|
|
28
|
+
? muiTableDetailPanelProps({ row, tableInstance })
|
|
29
29
|
: muiTableDetailPanelProps;
|
|
30
30
|
|
|
31
31
|
return (
|
|
@@ -33,7 +33,7 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, tableInstance }) => {
|
|
|
33
33
|
<TableCell
|
|
34
34
|
colSpan={getVisibleFlatColumns().length + 10}
|
|
35
35
|
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
36
|
-
onDetailPanelClick?.(event, row)
|
|
36
|
+
onDetailPanelClick?.({ event, row, tableInstance })
|
|
37
37
|
}
|
|
38
38
|
{...tableCellProps}
|
|
39
39
|
sx={{
|
|
@@ -44,7 +44,9 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, tableInstance }) => {
|
|
|
44
44
|
...tableCellProps?.sx,
|
|
45
45
|
}}
|
|
46
46
|
>
|
|
47
|
-
<Collapse in={row.getIsExpanded()}>
|
|
47
|
+
<Collapse in={row.getIsExpanded()}>
|
|
48
|
+
{renderDetailPanel?.({ row, tableInstance })}
|
|
49
|
+
</Collapse>
|
|
48
50
|
</TableCell>
|
|
49
51
|
</TableRow>
|
|
50
52
|
);
|
|
@@ -27,12 +27,12 @@ export const MRT_CopyButton: FC<Props> = ({
|
|
|
27
27
|
|
|
28
28
|
const mTableBodyCellCopyButtonProps =
|
|
29
29
|
muiTableBodyCellCopyButtonProps instanceof Function
|
|
30
|
-
? muiTableBodyCellCopyButtonProps(cell)
|
|
30
|
+
? muiTableBodyCellCopyButtonProps({ cell, tableInstance })
|
|
31
31
|
: muiTableBodyCellCopyButtonProps;
|
|
32
32
|
|
|
33
33
|
const mcTableBodyCellCopyButtonProps =
|
|
34
34
|
cell.column.muiTableBodyCellCopyButtonProps instanceof Function
|
|
35
|
-
? cell.column.muiTableBodyCellCopyButtonProps(cell)
|
|
35
|
+
? cell.column.muiTableBodyCellCopyButtonProps({ cell, tableInstance })
|
|
36
36
|
: cell.column.muiTableBodyCellCopyButtonProps;
|
|
37
37
|
|
|
38
38
|
const buttonProps = {
|
|
@@ -19,13 +19,15 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, tableInstance }) => {
|
|
|
19
19
|
},
|
|
20
20
|
} = tableInstance;
|
|
21
21
|
|
|
22
|
+
const { currentEditingRow } = getState();
|
|
23
|
+
|
|
22
24
|
const handleCancel = () => {
|
|
23
25
|
row.values = (row.original as RowValues) ?? {};
|
|
24
26
|
setCurrentEditingRow(null);
|
|
25
27
|
};
|
|
26
28
|
|
|
27
|
-
const handleSave =
|
|
28
|
-
|
|
29
|
+
const handleSave = () => {
|
|
30
|
+
onRowEditSubmit?.({ row: currentEditingRow ?? row, tableInstance });
|
|
29
31
|
setCurrentEditingRow(null);
|
|
30
32
|
};
|
|
31
33
|
|
|
@@ -22,7 +22,7 @@ export const MRT_ExpandButton: FC<Props> = ({ row, tableInstance }) => {
|
|
|
22
22
|
|
|
23
23
|
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
24
24
|
row.toggleExpanded();
|
|
25
|
-
onRowExpandChange?.(event, row);
|
|
25
|
+
onRowExpandChange?.({ event, row, tableInstance });
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return (
|
|
@@ -32,12 +32,15 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
|
|
|
32
32
|
|
|
33
33
|
const mTableHeadCellColumnActionsButtonProps =
|
|
34
34
|
muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
35
|
-
? muiTableHeadCellColumnActionsButtonProps(column)
|
|
35
|
+
? muiTableHeadCellColumnActionsButtonProps({ column, tableInstance })
|
|
36
36
|
: muiTableHeadCellColumnActionsButtonProps;
|
|
37
37
|
|
|
38
38
|
const mcTableHeadCellColumnActionsButtonProps =
|
|
39
39
|
column.muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
40
|
-
? column.muiTableHeadCellColumnActionsButtonProps(
|
|
40
|
+
? column.muiTableHeadCellColumnActionsButtonProps({
|
|
41
|
+
column,
|
|
42
|
+
tableInstance,
|
|
43
|
+
})
|
|
41
44
|
: column.muiTableHeadCellColumnActionsButtonProps;
|
|
42
45
|
|
|
43
46
|
const iconButtonProps = {
|
|
@@ -54,7 +54,7 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({
|
|
|
54
54
|
return (
|
|
55
55
|
<>
|
|
56
56
|
{renderRowActions ? (
|
|
57
|
-
<>{renderRowActions(row, tableInstance)}</>
|
|
57
|
+
<>{renderRowActions({ row, tableInstance })}</>
|
|
58
58
|
) : row.id === currentEditingRow?.id ? (
|
|
59
59
|
<MRT_EditActionButtons row={row} tableInstance={tableInstance} />
|
|
60
60
|
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
@@ -23,13 +23,18 @@ export const MRT_ToggleSearchButton: FC<Props> = ({
|
|
|
23
23
|
|
|
24
24
|
const { showSearch } = getState();
|
|
25
25
|
|
|
26
|
+
const textFieldProps =
|
|
27
|
+
muiSearchTextFieldProps instanceof Function
|
|
28
|
+
? muiSearchTextFieldProps({ tableInstance })
|
|
29
|
+
: muiSearchTextFieldProps;
|
|
30
|
+
|
|
26
31
|
const handleToggleSearch = () => {
|
|
27
32
|
setShowSearch(!showSearch);
|
|
28
33
|
setTimeout(
|
|
29
34
|
() =>
|
|
30
35
|
document
|
|
31
36
|
.getElementById(
|
|
32
|
-
|
|
37
|
+
textFieldProps?.id ?? `mrt-${idPrefix}-search-text-field`,
|
|
33
38
|
)
|
|
34
39
|
?.focus(),
|
|
35
40
|
200,
|
|
@@ -19,7 +19,7 @@ export const MRT_TableFooter: FC<Props> = ({ pinned, tableInstance }) => {
|
|
|
19
19
|
|
|
20
20
|
const tableFooterProps =
|
|
21
21
|
muiTableFooterProps instanceof Function
|
|
22
|
-
? muiTableFooterProps(tableInstance)
|
|
22
|
+
? muiTableFooterProps({ tableInstance })
|
|
23
23
|
: muiTableFooterProps;
|
|
24
24
|
|
|
25
25
|
const getFooterGroupsMap = {
|
|
@@ -19,12 +19,12 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
|
|
|
19
19
|
|
|
20
20
|
const mTableFooterCellProps =
|
|
21
21
|
muiTableFooterCellProps instanceof Function
|
|
22
|
-
? muiTableFooterCellProps(column)
|
|
22
|
+
? muiTableFooterCellProps({ column, tableInstance })
|
|
23
23
|
: muiTableFooterCellProps;
|
|
24
24
|
|
|
25
25
|
const mcTableFooterCellProps =
|
|
26
26
|
column.muiTableFooterCellProps instanceof Function
|
|
27
|
-
? column.muiTableFooterCellProps(column)
|
|
27
|
+
? column.muiTableFooterCellProps({ column, tableInstance })
|
|
28
28
|
: column.muiTableFooterCellProps;
|
|
29
29
|
|
|
30
30
|
const tableCellProps = {
|
|
@@ -26,7 +26,7 @@ export const MRT_TableFooterRow: FC<Props> = ({
|
|
|
26
26
|
|
|
27
27
|
const mTableFooterRowProps =
|
|
28
28
|
muiTableFooterRowProps instanceof Function
|
|
29
|
-
? muiTableFooterRowProps(footerGroup)
|
|
29
|
+
? muiTableFooterRowProps({ footerGroup, tableInstance })
|
|
30
30
|
: muiTableFooterRowProps;
|
|
31
31
|
|
|
32
32
|
const tableRowProps = {
|
|
@@ -19,7 +19,7 @@ export const MRT_TableHead: FC<Props> = ({ pinned, tableInstance }) => {
|
|
|
19
19
|
|
|
20
20
|
const tableHeadProps =
|
|
21
21
|
muiTableHeadProps instanceof Function
|
|
22
|
-
? muiTableHeadProps(tableInstance)
|
|
22
|
+
? muiTableHeadProps({ tableInstance })
|
|
23
23
|
: muiTableHeadProps;
|
|
24
24
|
|
|
25
25
|
const getHeaderGroupsMap = {
|
|
@@ -40,12 +40,12 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
40
40
|
|
|
41
41
|
const mTableHeadCellProps =
|
|
42
42
|
muiTableHeadCellProps instanceof Function
|
|
43
|
-
? muiTableHeadCellProps(column)
|
|
43
|
+
? muiTableHeadCellProps({ column, tableInstance })
|
|
44
44
|
: muiTableHeadCellProps;
|
|
45
45
|
|
|
46
46
|
const mcTableHeadCellProps =
|
|
47
47
|
column.muiTableHeadCellProps instanceof Function
|
|
48
|
-
? column.muiTableHeadCellProps(column)
|
|
48
|
+
? column.muiTableHeadCellProps({ column, tableInstance })
|
|
49
49
|
: column.muiTableHeadCellProps;
|
|
50
50
|
|
|
51
51
|
const tableCellProps = {
|
|
@@ -57,35 +57,28 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
|
|
|
57
57
|
const sortTooltip = !!column.getIsSorted()
|
|
58
58
|
? column.getIsSorted() === 'desc'
|
|
59
59
|
? localization.clearSort
|
|
60
|
-
: localization.sortByColumnDesc.replace(
|
|
61
|
-
|
|
62
|
-
column.header as string,
|
|
63
|
-
)
|
|
64
|
-
: localization.sortByColumnAsc.replace('{column}', column.header as string);
|
|
60
|
+
: localization.sortByColumnDesc.replace('{column}', column.header)
|
|
61
|
+
: localization.sortByColumnAsc.replace('{column}', column.header);
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
const filterType = getState()?.currentFilterTypes?.[header.id];
|
|
67
64
|
|
|
68
|
-
const filterTooltip =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// getColumnFilterValue() as string,
|
|
86
|
-
// )
|
|
87
|
-
// .replace('" "', '')
|
|
88
|
-
// : localization.showHideFilters;
|
|
65
|
+
const filterTooltip = !!column.getColumnFilterValue()
|
|
66
|
+
? localization.filteringByColumn
|
|
67
|
+
.replace('{column}', String(column.header))
|
|
68
|
+
.replace(
|
|
69
|
+
'{filterType}',
|
|
70
|
+
filterType instanceof Function
|
|
71
|
+
? ''
|
|
72
|
+
: // @ts-ignore
|
|
73
|
+
localization[
|
|
74
|
+
`filter${
|
|
75
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
76
|
+
}`
|
|
77
|
+
],
|
|
78
|
+
)
|
|
79
|
+
.replace('{filterValue}', column.getColumnFilterValue() as string)
|
|
80
|
+
.replace('" "', '')
|
|
81
|
+
: localization.showHideFilters;
|
|
89
82
|
|
|
90
83
|
const headerElement =
|
|
91
84
|
column?.Header?.({
|
|
@@ -15,7 +15,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup, tableInstance }) => {
|
|
|
15
15
|
|
|
16
16
|
const mTableHeadRowProps =
|
|
17
17
|
muiTableHeadRowProps instanceof Function
|
|
18
|
-
? muiTableHeadRowProps(headerGroup)
|
|
18
|
+
? muiTableHeadRowProps({ headerGroup, tableInstance })
|
|
19
19
|
: muiTableHeadRowProps;
|
|
20
20
|
|
|
21
21
|
const tableRowProps = {
|
|
@@ -10,7 +10,7 @@ interface Props {
|
|
|
10
10
|
export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
|
|
11
11
|
const {
|
|
12
12
|
getState,
|
|
13
|
-
options: { muiTableBodyCellEditTextFieldProps },
|
|
13
|
+
options: { enableRowEditing, muiTableBodyCellEditTextFieldProps },
|
|
14
14
|
} = tableInstance;
|
|
15
15
|
|
|
16
16
|
const { column, row } = cell;
|
|
@@ -22,17 +22,17 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
22
22
|
// ...getState().currentEditingRow,
|
|
23
23
|
// });
|
|
24
24
|
}
|
|
25
|
-
column.onCellEditChange?.(event, cell);
|
|
25
|
+
column.onCellEditChange?.({ event, cell, tableInstance });
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
const mTableBodyCellEditTextFieldProps =
|
|
29
29
|
muiTableBodyCellEditTextFieldProps instanceof Function
|
|
30
|
-
? muiTableBodyCellEditTextFieldProps(cell)
|
|
30
|
+
? muiTableBodyCellEditTextFieldProps({ cell, tableInstance })
|
|
31
31
|
: muiTableBodyCellEditTextFieldProps;
|
|
32
32
|
|
|
33
33
|
const mcTableBodyCellEditTextFieldProps =
|
|
34
34
|
column.muiTableBodyCellEditTextFieldProps instanceof Function
|
|
35
|
-
? column.muiTableBodyCellEditTextFieldProps(cell)
|
|
35
|
+
? column.muiTableBodyCellEditTextFieldProps({ cell, tableInstance })
|
|
36
36
|
: column.muiTableBodyCellEditTextFieldProps;
|
|
37
37
|
|
|
38
38
|
const textFieldProps = {
|
|
@@ -40,9 +40,9 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
|
|
|
40
40
|
...mcTableBodyCellEditTextFieldProps,
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (enableRowEditing && column.enableEditing !== false && column.Edit) {
|
|
44
|
+
return <>{column.Edit?.({ cell, tableInstance })}</>;
|
|
45
|
+
}
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<TextField
|
|
@@ -44,12 +44,12 @@ export const MRT_FilterTextField: FC<Props> = ({ header, tableInstance }) => {
|
|
|
44
44
|
|
|
45
45
|
const mTableHeadCellFilterTextFieldProps =
|
|
46
46
|
muiTableHeadCellFilterTextFieldProps instanceof Function
|
|
47
|
-
? muiTableHeadCellFilterTextFieldProps(column)
|
|
47
|
+
? muiTableHeadCellFilterTextFieldProps({ column, tableInstance })
|
|
48
48
|
: muiTableHeadCellFilterTextFieldProps;
|
|
49
49
|
|
|
50
50
|
const mcTableHeadCellFilterTextFieldProps =
|
|
51
51
|
column.muiTableHeadCellFilterTextFieldProps instanceof Function
|
|
52
|
-
? column.muiTableHeadCellFilterTextFieldProps(column)
|
|
52
|
+
? column.muiTableHeadCellFilterTextFieldProps({ column, tableInstance })
|
|
53
53
|
: column.muiTableHeadCellFilterTextFieldProps;
|
|
54
54
|
|
|
55
55
|
const textFieldProps = {
|
|
@@ -41,7 +41,7 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
41
41
|
const handleChange = useCallback(
|
|
42
42
|
debounce((event: ChangeEvent<HTMLInputElement>) => {
|
|
43
43
|
setGlobalFilter(event.target.value ?? undefined);
|
|
44
|
-
onGlobalFilterChange?.(event);
|
|
44
|
+
onGlobalFilterChange?.({ event, tableInstance });
|
|
45
45
|
}, 200),
|
|
46
46
|
[],
|
|
47
47
|
);
|
|
@@ -55,6 +55,11 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
55
55
|
setGlobalFilter(undefined);
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
const textFieldProps =
|
|
59
|
+
muiSearchTextFieldProps instanceof Function
|
|
60
|
+
? muiSearchTextFieldProps({ tableInstance })
|
|
61
|
+
: muiSearchTextFieldProps;
|
|
62
|
+
|
|
58
63
|
return (
|
|
59
64
|
<Collapse in={showSearch} orientation="horizontal">
|
|
60
65
|
<TextField
|
|
@@ -97,8 +102,8 @@ export const MRT_SearchTextField: FC<Props> = ({ tableInstance }) => {
|
|
|
97
102
|
</InputAdornment>
|
|
98
103
|
),
|
|
99
104
|
}}
|
|
100
|
-
{...
|
|
101
|
-
sx={{ justifySelf: 'end', ...
|
|
105
|
+
{...textFieldProps}
|
|
106
|
+
sx={{ justifySelf: 'end', ...textFieldProps?.sx }}
|
|
102
107
|
/>
|
|
103
108
|
<MRT_FilterTypeMenu
|
|
104
109
|
anchorEl={anchorEl}
|
|
@@ -32,27 +32,29 @@ export const MRT_SelectCheckbox: FC<Props> = ({
|
|
|
32
32
|
const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
33
33
|
if (selectAll) {
|
|
34
34
|
getToggleAllRowsSelectedProps?.()?.onChange?.(event as any);
|
|
35
|
-
onSelectAllChange?.(
|
|
35
|
+
onSelectAllChange?.({
|
|
36
36
|
event,
|
|
37
|
-
event.target.checked ? getRowModel().flatRows : [],
|
|
38
|
-
|
|
37
|
+
selectedRows: event.target.checked ? getRowModel().flatRows : [],
|
|
38
|
+
tableInstance,
|
|
39
|
+
});
|
|
39
40
|
} else if (row) {
|
|
40
41
|
row?.getToggleSelectedProps()?.onChange?.(event as any);
|
|
41
|
-
onSelectChange?.(
|
|
42
|
+
onSelectChange?.({
|
|
42
43
|
event,
|
|
43
44
|
row,
|
|
44
|
-
event.target.checked
|
|
45
|
+
selectedRows: event.target.checked
|
|
45
46
|
? [...getSelectedRowModel().flatRows, row]
|
|
46
47
|
: getSelectedRowModel().flatRows.filter(
|
|
47
48
|
(selectedRow) => selectedRow.id !== row.id,
|
|
48
49
|
),
|
|
49
|
-
|
|
50
|
+
tableInstance,
|
|
51
|
+
});
|
|
50
52
|
}
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
const mTableBodyRowSelectCheckboxProps =
|
|
54
56
|
muiSelectCheckboxProps instanceof Function
|
|
55
|
-
? muiSelectCheckboxProps(selectAll, row, tableInstance)
|
|
57
|
+
? muiSelectCheckboxProps({ isSelectAll: !!selectAll, row, tableInstance })
|
|
56
58
|
: muiSelectCheckboxProps;
|
|
57
59
|
|
|
58
60
|
const rtSelectCheckboxProps = selectAll
|
|
@@ -52,9 +52,11 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
52
52
|
</Box>
|
|
53
53
|
</MenuItem>
|
|
54
54
|
)}
|
|
55
|
-
{renderRowActionMenuItems?.(
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
{renderRowActionMenuItems?.({
|
|
56
|
+
row,
|
|
57
|
+
tableInstance,
|
|
58
|
+
closeMenu: () => setAnchorEl(null),
|
|
59
|
+
})}
|
|
58
60
|
</Menu>
|
|
59
61
|
);
|
|
60
62
|
};
|
|
@@ -34,12 +34,11 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
34
34
|
} else {
|
|
35
35
|
column.toggleVisibility();
|
|
36
36
|
}
|
|
37
|
-
onColumnHide?.(
|
|
37
|
+
onColumnHide?.({
|
|
38
38
|
column,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
39
|
+
columnVisibility,
|
|
40
|
+
tableInstance,
|
|
41
|
+
});
|
|
43
42
|
};
|
|
44
43
|
|
|
45
44
|
return (
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React, { FC, useLayoutEffect, useState } from 'react';
|
|
2
|
-
import { alpha, Box,
|
|
3
|
-
import {
|
|
2
|
+
import { alpha, Box, TableContainer, Theme } from '@mui/material';
|
|
3
|
+
import { SystemStyleObject } from '@mui/material/node_modules/@mui/system';
|
|
4
4
|
import { MRT_TableInstance } from '..';
|
|
5
|
+
import { MRT_Table } from './MRT_Table';
|
|
5
6
|
|
|
6
7
|
const commonBoxStyles = ({
|
|
7
8
|
pinned,
|
|
@@ -11,18 +12,17 @@ const commonBoxStyles = ({
|
|
|
11
12
|
pinned?: 'left' | 'right';
|
|
12
13
|
theme: Theme;
|
|
13
14
|
visible?: boolean;
|
|
14
|
-
}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
} as SxProps<Theme>);
|
|
15
|
+
}): SystemStyleObject<Theme> => ({
|
|
16
|
+
display: 'grid',
|
|
17
|
+
minWidth: visible ? '200px' : 0,
|
|
18
|
+
overflowX: 'auto',
|
|
19
|
+
boxShadow:
|
|
20
|
+
pinned === 'left'
|
|
21
|
+
? `0 1px 12px ${alpha(theme.palette.common.black, 0.5)}`
|
|
22
|
+
: pinned === 'right'
|
|
23
|
+
? `0 -1px 12px ${alpha(theme.palette.common.black, 0.5)}`
|
|
24
|
+
: 'none',
|
|
25
|
+
});
|
|
26
26
|
|
|
27
27
|
interface Props {
|
|
28
28
|
tableInstance: MRT_TableInstance;
|
|
@@ -49,7 +49,7 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
|
|
|
49
49
|
|
|
50
50
|
const tableContainerProps =
|
|
51
51
|
muiTableContainerProps instanceof Function
|
|
52
|
-
? muiTableContainerProps(tableInstance)
|
|
52
|
+
? muiTableContainerProps({ tableInstance })
|
|
53
53
|
: muiTableContainerProps;
|
|
54
54
|
|
|
55
55
|
useLayoutEffect(() => {
|
|
@@ -93,7 +93,6 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
|
|
|
93
93
|
}}
|
|
94
94
|
>
|
|
95
95
|
<Box
|
|
96
|
-
// @ts-ignore
|
|
97
96
|
sx={(theme: Theme) =>
|
|
98
97
|
commonBoxStyles({
|
|
99
98
|
pinned: 'left',
|
|
@@ -104,13 +103,10 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
|
|
|
104
103
|
>
|
|
105
104
|
<MRT_Table pinned="left" tableInstance={tableInstance} />
|
|
106
105
|
</Box>
|
|
107
|
-
<Box
|
|
108
|
-
sx={(theme: Theme) => commonBoxStyles({ theme })}
|
|
109
|
-
>
|
|
106
|
+
<Box sx={(theme: Theme) => commonBoxStyles({ theme })}>
|
|
110
107
|
<MRT_Table pinned="center" tableInstance={tableInstance} />
|
|
111
108
|
</Box>
|
|
112
109
|
<Box
|
|
113
|
-
// @ts-ignore
|
|
114
110
|
sx={(theme: Theme) =>
|
|
115
111
|
commonBoxStyles({
|
|
116
112
|
pinned: 'right',
|
|
@@ -29,7 +29,7 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
|
|
|
29
29
|
|
|
30
30
|
const tablePaperProps =
|
|
31
31
|
muiTablePaperProps instanceof Function
|
|
32
|
-
? muiTablePaperProps(tableInstance)
|
|
32
|
+
? muiTablePaperProps({ tableInstance })
|
|
33
33
|
: muiTablePaperProps;
|
|
34
34
|
|
|
35
35
|
return (
|
|
@@ -37,18 +37,22 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
|
|
|
37
37
|
elevation={2}
|
|
38
38
|
{...tablePaperProps}
|
|
39
39
|
sx={{
|
|
40
|
-
|
|
40
|
+
transition: 'all 0.2s ease-in-out',
|
|
41
|
+
...tablePaperProps?.sx,
|
|
42
|
+
}}
|
|
43
|
+
style={{
|
|
41
44
|
height: isFullScreen ? '100%' : undefined,
|
|
42
45
|
left: isFullScreen ? '0' : undefined,
|
|
43
|
-
|
|
46
|
+
margin: isFullScreen ? '0' : undefined,
|
|
47
|
+
maxHeight: isFullScreen ? '100%' : undefined,
|
|
48
|
+
maxWidth: isFullScreen ? '100%' : undefined,
|
|
44
49
|
overflowY: !isFullScreen ? 'hidden' : undefined,
|
|
45
50
|
position: isFullScreen ? 'fixed' : undefined,
|
|
46
51
|
right: isFullScreen ? '0' : undefined,
|
|
47
52
|
top: isFullScreen ? '0' : undefined,
|
|
48
|
-
transition: 'all 0.2s ease-in-out',
|
|
49
53
|
width: isFullScreen ? '100vw' : undefined,
|
|
50
54
|
zIndex: isFullScreen ? 1200 : 1,
|
|
51
|
-
|
|
55
|
+
bottom: isFullScreen ? '0' : undefined,
|
|
52
56
|
}}
|
|
53
57
|
>
|
|
54
58
|
{!hideToolbarTop && <MRT_ToolbarTop tableInstance={tableInstance} />}
|
|
@@ -13,7 +13,7 @@ export const MRT_LinearProgressBar: FC<Props> = ({ tableInstance }) => {
|
|
|
13
13
|
|
|
14
14
|
const linearProgressProps =
|
|
15
15
|
muiLinearProgressProps instanceof Function
|
|
16
|
-
? muiLinearProgressProps(tableInstance)
|
|
16
|
+
? muiLinearProgressProps({ tableInstance })
|
|
17
17
|
: muiLinearProgressProps;
|
|
18
18
|
|
|
19
19
|
return (
|
|
@@ -21,7 +21,7 @@ export const MRT_TablePagination: FC<Props> = ({ tableInstance }) => {
|
|
|
21
21
|
|
|
22
22
|
const tablePaginationProps =
|
|
23
23
|
muiTablePaginationProps instanceof Function
|
|
24
|
-
? muiTablePaginationProps(tableInstance)
|
|
24
|
+
? muiTablePaginationProps({ tableInstance })
|
|
25
25
|
: muiTablePaginationProps;
|
|
26
26
|
|
|
27
27
|
const handleChangeRowsPerPage = (event: ChangeEvent<HTMLInputElement>) => {
|
|
@@ -33,13 +33,14 @@ export const MRT_TablePagination: FC<Props> = ({ tableInstance }) => {
|
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<TablePagination
|
|
36
|
+
SelectProps={{ sx: { m: '0 1rem 0 1ch' } }}
|
|
36
37
|
component="div"
|
|
37
38
|
count={getPrePaginationRowModel().rows.length}
|
|
38
39
|
onPageChange={(_: any, newPage: number) => setPageIndex(newPage)}
|
|
39
40
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
40
41
|
page={pageIndex}
|
|
41
42
|
rowsPerPage={pageSize}
|
|
42
|
-
|
|
43
|
+
rowsPerPageOptions={[5, 10, 20, 25, 50, 100]}
|
|
43
44
|
showFirstButton={showFirstLastPageButtons}
|
|
44
45
|
showLastButton={showFirstLastPageButtons}
|
|
45
46
|
{...tablePaginationProps}
|
|
@@ -27,7 +27,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
|
|
|
27
27
|
|
|
28
28
|
const alertProps =
|
|
29
29
|
muiTableToolbarAlertBannerProps instanceof Function
|
|
30
|
-
? muiTableToolbarAlertBannerProps(tableInstance)
|
|
30
|
+
? muiTableToolbarAlertBannerProps({ tableInstance })
|
|
31
31
|
: muiTableToolbarAlertBannerProps;
|
|
32
32
|
|
|
33
33
|
const selectMessage =
|
|
@@ -96,6 +96,7 @@ export const MRT_ToolbarAlertBanner: FC<Props> = ({ tableInstance }) => {
|
|
|
96
96
|
>
|
|
97
97
|
<Box sx={{ p: '0.5rem 1rem' }}>
|
|
98
98
|
{selectMessage}
|
|
99
|
+
<br />
|
|
99
100
|
{groupedByMessage}
|
|
100
101
|
</Box>
|
|
101
102
|
</Alert>
|
|
@@ -29,7 +29,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
|
|
|
29
29
|
|
|
30
30
|
const toolbarProps =
|
|
31
31
|
muiTableToolbarBottomProps instanceof Function
|
|
32
|
-
? muiTableToolbarBottomProps(tableInstance)
|
|
32
|
+
? muiTableToolbarBottomProps({ tableInstance })
|
|
33
33
|
: muiTableToolbarBottomProps;
|
|
34
34
|
|
|
35
35
|
return (
|
|
@@ -26,12 +26,13 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ tableInstance }) => {
|
|
|
26
26
|
if (renderToolbarInternalActions) {
|
|
27
27
|
return (
|
|
28
28
|
<>
|
|
29
|
-
{renderToolbarInternalActions(
|
|
30
|
-
|
|
31
|
-
MRT_ToggleFiltersButton,
|
|
29
|
+
{renderToolbarInternalActions({
|
|
30
|
+
MRT_FullScreenToggleButton,
|
|
32
31
|
MRT_ShowHideColumnsButton,
|
|
33
32
|
MRT_ToggleDensePaddingButton,
|
|
34
|
-
|
|
33
|
+
MRT_ToggleFiltersButton,
|
|
34
|
+
MRT_ToggleSearchButton,
|
|
35
|
+
tableInstance,
|
|
35
36
|
})}
|
|
36
37
|
</>
|
|
37
38
|
);
|
|
@@ -43,7 +43,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
43
43
|
|
|
44
44
|
const toolbarProps =
|
|
45
45
|
muiTableToolbarTopProps instanceof Function
|
|
46
|
-
? muiTableToolbarTopProps(tableInstance)
|
|
46
|
+
? muiTableToolbarTopProps({ tableInstance })
|
|
47
47
|
: muiTableToolbarTopProps;
|
|
48
48
|
|
|
49
49
|
return (
|
|
@@ -70,7 +70,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
|
|
|
70
70
|
justifyContent: 'space-between',
|
|
71
71
|
}}
|
|
72
72
|
>
|
|
73
|
-
{renderToolbarCustomActions?.(tableInstance) ?? <span />}
|
|
73
|
+
{renderToolbarCustomActions?.({ tableInstance }) ?? <span />}
|
|
74
74
|
<Box
|
|
75
75
|
sx={{
|
|
76
76
|
display: 'flex',
|