material-react-table 0.7.0-alpha.1 → 0.7.0-alpha.10
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 +29 -19
- package/dist/MaterialReactTable.d.ts +203 -61
- package/dist/buttons/MRT_CopyButton.d.ts +1 -2
- package/dist/localization.d.ts +1 -0
- package/dist/material-react-table.cjs.development.js +303 -956
- 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 +303 -956
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +380 -128
- package/src/body/MRT_TableBody.tsx +1 -1
- package/src/body/MRT_TableBodyCell.tsx +9 -6
- package/src/body/MRT_TableBodyRow.tsx +2 -2
- package/src/body/MRT_TableDetailPanel.tsx +6 -4
- package/src/buttons/MRT_CopyButton.tsx +3 -4
- package/src/buttons/MRT_EditActionButtons.tsx +5 -3
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +5 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +6 -6
- 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 +30 -14
- 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/localization.ts +2 -1
- package/src/menus/MRT_RowActionMenu.tsx +7 -5
- 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/table/MRT_TableRoot.tsx +11 -8
- package/src/toolbar/MRT_LinearProgressBar.tsx +1 -1
- package/src/toolbar/MRT_TablePagination.tsx +6 -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
|
@@ -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} />}
|
|
@@ -55,7 +55,6 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
55
55
|
const [showSearch, setShowSearch] = useState(
|
|
56
56
|
props.initialState?.showSearch ?? false,
|
|
57
57
|
);
|
|
58
|
-
|
|
59
58
|
const [pagination, setPagination] = useState<PaginationState>({
|
|
60
59
|
pageIndex: props.initialState?.pagination?.pageIndex ?? 0,
|
|
61
60
|
pageSize: props.initialState?.pagination?.pageSize ?? 10,
|
|
@@ -92,7 +91,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
92
91
|
const displayColumns = useMemo(
|
|
93
92
|
() =>
|
|
94
93
|
[
|
|
95
|
-
(props.enableRowActions || props.
|
|
94
|
+
(props.enableRowActions || props.enableEditing) &&
|
|
96
95
|
createDisplayColumn(table, {
|
|
97
96
|
Cell: ({ cell }) => (
|
|
98
97
|
<MRT_ToggleRowActionMenuButton
|
|
@@ -142,7 +141,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
142
141
|
props.enableRowNumbers &&
|
|
143
142
|
createDisplayColumn(table, {
|
|
144
143
|
Cell: ({ cell }) => cell.row.index + 1,
|
|
145
|
-
Header: () =>
|
|
144
|
+
Header: () => props.localization?.rowNumber,
|
|
146
145
|
header: props.localization?.rowNumbers,
|
|
147
146
|
id: 'mrt-row-numbers',
|
|
148
147
|
maxWidth: 40,
|
|
@@ -151,10 +150,12 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
151
150
|
}),
|
|
152
151
|
].filter(Boolean),
|
|
153
152
|
[
|
|
153
|
+
table,
|
|
154
154
|
props.enableExpandAll,
|
|
155
155
|
props.enableExpanded,
|
|
156
156
|
props.enableRowActions,
|
|
157
|
-
props.
|
|
157
|
+
props.enableGrouping,
|
|
158
|
+
props.enableEditing,
|
|
158
159
|
props.enableRowNumbers,
|
|
159
160
|
props.enableRowSelection,
|
|
160
161
|
props.enableSelectAll,
|
|
@@ -195,17 +196,20 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
195
196
|
//@ts-ignore
|
|
196
197
|
const tableInstance: MRT_TableInstance<{}> = useTable(table, {
|
|
197
198
|
...props,
|
|
198
|
-
//@ts-ignore
|
|
199
|
-
filterTypes: defaultFilterFNs,
|
|
200
|
-
globalFilterType: currentGlobalFilterType,
|
|
201
199
|
columnFilterRowsFn: columnFilterRowsFn,
|
|
202
200
|
columns,
|
|
203
201
|
data,
|
|
202
|
+
debugAll: false,
|
|
204
203
|
expandRowsFn: expandRowsFn,
|
|
204
|
+
//@ts-ignore
|
|
205
|
+
filterTypes: defaultFilterFNs,
|
|
205
206
|
getSubRows: props.getSubRows ?? ((originalRow: D) => originalRow.subRows),
|
|
206
207
|
globalFilterRowsFn: globalFilterRowsFn,
|
|
208
|
+
globalFilterType: currentGlobalFilterType,
|
|
207
209
|
groupRowsFn: groupRowsFn,
|
|
208
210
|
idPrefix,
|
|
211
|
+
//@ts-ignore
|
|
212
|
+
initialState: props.initialState,
|
|
209
213
|
onPaginationChange: (updater: any) =>
|
|
210
214
|
setPagination((old) => functionalUpdate(updater, old)),
|
|
211
215
|
paginateRowsFn: paginateRowsFn,
|
|
@@ -218,7 +222,6 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
218
222
|
setShowSearch,
|
|
219
223
|
sortRowsFn,
|
|
220
224
|
state: {
|
|
221
|
-
...props.initialState,
|
|
222
225
|
currentEditingRow,
|
|
223
226
|
currentFilterTypes,
|
|
224
227
|
currentGlobalFilterType,
|
|
@@ -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,17 @@ export const MRT_TablePagination: FC<Props> = ({ tableInstance }) => {
|
|
|
33
33
|
|
|
34
34
|
return (
|
|
35
35
|
<TablePagination
|
|
36
|
+
SelectProps={{
|
|
37
|
+
sx: { m: '0 1rem 0 1ch' },
|
|
38
|
+
MenuProps: { MenuListProps: { disablePadding: true } },
|
|
39
|
+
}}
|
|
36
40
|
component="div"
|
|
37
41
|
count={getPrePaginationRowModel().rows.length}
|
|
38
42
|
onPageChange={(_: any, newPage: number) => setPageIndex(newPage)}
|
|
39
43
|
onRowsPerPageChange={handleChangeRowsPerPage}
|
|
40
44
|
page={pageIndex}
|
|
41
45
|
rowsPerPage={pageSize}
|
|
42
|
-
|
|
46
|
+
rowsPerPageOptions={[5, 10, 15, 20, 25, 30, 50, 100]}
|
|
43
47
|
showFirstButton={showFirstLastPageButtons}
|
|
44
48
|
showLastButton={showFirstLastPageButtons}
|
|
45
49
|
{...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',
|