material-react-table 3.0.0-beta.2 → 3.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +36 -35
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +36 -34
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/buttons/MRT_RowPinButton.tsx +2 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +2 -0
- package/src/components/table/MRT_TableLoadingOverlay.tsx +2 -1
- package/src/components/table/MRT_TablePaper.tsx +52 -48
- package/src/components/toolbar/MRT_TablePagination.tsx +3 -2
- package/src/hooks/useMRT_TableOptions.ts +3 -1
- package/src/types.ts +4 -0
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "3.0.0-
|
2
|
+
"version": "3.0.0-rc.0",
|
3
3
|
"license": "MIT",
|
4
4
|
"name": "material-react-table",
|
5
5
|
"description": "A fully featured Material UI V6 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
@@ -110,8 +110,8 @@
|
|
110
110
|
"@mui/icons-material": ">=6",
|
111
111
|
"@mui/material": ">=6",
|
112
112
|
"@mui/x-date-pickers": ">=7.15",
|
113
|
-
"react": ">=
|
114
|
-
"react-dom": ">=
|
113
|
+
"react": ">=18.0",
|
114
|
+
"react-dom": ">=18.0"
|
115
115
|
},
|
116
116
|
"dependencies": {
|
117
117
|
"@tanstack/match-sorter-utils": "8.19.4",
|
@@ -49,7 +49,9 @@ export const MRT_RowPinButton = <TData extends MRT_RowData>({
|
|
49
49
|
>
|
50
50
|
<IconButton
|
51
51
|
aria-label={localization.pin}
|
52
|
+
onBlur={() => setTooltipOpened(false)}
|
52
53
|
onClick={handleTogglePin}
|
54
|
+
onFocus={() => setTooltipOpened(true)}
|
53
55
|
onMouseEnter={() => setTooltipOpened(true)}
|
54
56
|
onMouseLeave={() => setTooltipOpened(false)}
|
55
57
|
size="small"
|
@@ -36,7 +36,9 @@ export const MRT_ToggleFullScreenButton = <TData extends MRT_RowData>({
|
|
36
36
|
>
|
37
37
|
<IconButton
|
38
38
|
aria-label={localization.toggleFullScreen}
|
39
|
+
onBlur={() => setTooltipOpened(false)}
|
39
40
|
onClick={handleToggleFullScreen}
|
41
|
+
onFocus={() => setTooltipOpened(true)}
|
40
42
|
onMouseEnter={() => setTooltipOpened(true)}
|
41
43
|
onMouseLeave={() => setTooltipOpened(false)}
|
42
44
|
{...rest}
|
@@ -17,6 +17,7 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
|
|
17
17
|
}: MRT_TableLoadingOverlayProps<TData>) => {
|
18
18
|
const {
|
19
19
|
options: {
|
20
|
+
id,
|
20
21
|
localization,
|
21
22
|
mrtTheme: { baseBackgroundColor },
|
22
23
|
muiCircularProgressProps,
|
@@ -48,7 +49,7 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
|
|
48
49
|
{circularProgressProps?.Component ?? (
|
49
50
|
<CircularProgress
|
50
51
|
aria-label={localization.noRecordsToDisplay}
|
51
|
-
id=
|
52
|
+
id={`mrt-progress-${id}`}
|
52
53
|
{...circularProgressProps}
|
53
54
|
/>
|
54
55
|
)}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import Paper, { type PaperProps } from '@mui/material/Paper';
|
2
|
-
import
|
2
|
+
import FocusTrap from '@mui/material/Unstable_TrapFocus/FocusTrap';
|
3
|
+
import { useTheme } from '@mui/material/styles';
|
3
4
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
4
5
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
5
6
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
@@ -37,52 +38,55 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
37
38
|
const theme = useTheme();
|
38
39
|
|
39
40
|
return (
|
40
|
-
<
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
paperProps
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
41
|
+
<FocusTrap open={isFullScreen}>
|
42
|
+
<Paper
|
43
|
+
elevation={2}
|
44
|
+
onKeyDown={(e) => e.key === 'Escape' && table.setIsFullScreen(false)}
|
45
|
+
{...paperProps}
|
46
|
+
ref={(ref: HTMLDivElement) => {
|
47
|
+
tablePaperRef.current = ref;
|
48
|
+
if (paperProps?.ref) {
|
49
|
+
//@ts-ignore
|
50
|
+
paperProps.ref.current = ref;
|
51
|
+
}
|
52
|
+
}}
|
53
|
+
style={{
|
54
|
+
...(isFullScreen
|
55
|
+
? {
|
56
|
+
bottom: 0,
|
57
|
+
height: '100dvh',
|
58
|
+
left: 0,
|
59
|
+
margin: 0,
|
60
|
+
maxHeight: '100dvh',
|
61
|
+
maxWidth: '100dvw',
|
62
|
+
padding: 0,
|
63
|
+
position: 'fixed',
|
64
|
+
right: 0,
|
65
|
+
top: 0,
|
66
|
+
width: '100dvw',
|
67
|
+
zIndex: theme.zIndex.modal,
|
68
|
+
}
|
69
|
+
: {}),
|
70
|
+
...paperProps?.style,
|
71
|
+
}}
|
72
|
+
sx={(theme) => ({
|
73
|
+
backgroundColor: baseBackgroundColor,
|
74
|
+
backgroundImage: 'unset',
|
75
|
+
overflow: 'hidden',
|
76
|
+
transition: 'all 100ms ease-in-out',
|
77
|
+
...(parseFromValuesOrFunc(paperProps?.sx, theme) as any),
|
78
|
+
})}
|
79
|
+
>
|
80
|
+
{enableTopToolbar &&
|
81
|
+
(parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (
|
82
|
+
<MRT_TopToolbar table={table} />
|
83
|
+
))}
|
84
|
+
<MRT_TableContainer table={table} />
|
85
|
+
{enableBottomToolbar &&
|
86
|
+
(parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? (
|
87
|
+
<MRT_BottomToolbar table={table} />
|
88
|
+
))}
|
89
|
+
</Paper>
|
90
|
+
</FocusTrap>
|
87
91
|
);
|
88
92
|
};
|
@@ -41,6 +41,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
41
41
|
options: {
|
42
42
|
enableToolbarInternalActions,
|
43
43
|
icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon },
|
44
|
+
id,
|
44
45
|
localization,
|
45
46
|
muiPaginationProps,
|
46
47
|
paginationDisplayMode,
|
@@ -107,7 +108,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
107
108
|
>
|
108
109
|
{showRowsPerPage && (
|
109
110
|
<Box sx={{ alignItems: 'center', display: 'flex', gap: '8px' }}>
|
110
|
-
<InputLabel htmlFor=
|
111
|
+
<InputLabel htmlFor={`mrt-rows-per-page-${id}`} sx={{ mb: 0 }}>
|
111
112
|
{localization.rowsPerPage}
|
112
113
|
</InputLabel>
|
113
114
|
<Select
|
@@ -116,7 +117,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
116
117
|
disabled={disabled}
|
117
118
|
inputProps={{
|
118
119
|
'aria-label': localization.rowsPerPage,
|
119
|
-
id:
|
120
|
+
id: `mrt-rows-per-page-${id}`,
|
120
121
|
}}
|
121
122
|
label={localization.rowsPerPage}
|
122
123
|
onChange={(event) =>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useMemo } from 'react';
|
1
|
+
import { useId, useMemo } from 'react';
|
2
2
|
import {
|
3
3
|
getCoreRowModel,
|
4
4
|
getExpandedRowModel,
|
@@ -92,6 +92,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
92
92
|
enableTopToolbar = true,
|
93
93
|
filterFns,
|
94
94
|
icons,
|
95
|
+
id = useId(),
|
95
96
|
layoutMode,
|
96
97
|
localization,
|
97
98
|
manualFiltering,
|
@@ -244,6 +245,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
244
245
|
enableSorting && !manualSorting ? getSortedRowModel() : undefined,
|
245
246
|
getSubRows: (row) => row?.subRows,
|
246
247
|
icons,
|
248
|
+
id,
|
247
249
|
layoutMode,
|
248
250
|
localization,
|
249
251
|
manualFiltering,
|
package/src/types.ts
CHANGED
@@ -894,6 +894,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
894
894
|
globalFilterFn?: MRT_FilterOption;
|
895
895
|
globalFilterModeOptions?: MRT_FilterOption[] | null;
|
896
896
|
icons?: Partial<MRT_Icons>;
|
897
|
+
id?: string;
|
897
898
|
initialState?: Partial<MRT_TableState<TData>>;
|
898
899
|
/**
|
899
900
|
* Changes which kind of CSS layout is used to render the table. `semantic` uses default semantic HTML elements, while `grid` adds CSS grid and flexbox styles
|
@@ -1132,6 +1133,9 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
|
|
1132
1133
|
muiTableContainerProps?:
|
1133
1134
|
| ((props: { table: MRT_TableInstance<TData> }) => TableContainerProps)
|
1134
1135
|
| TableContainerProps;
|
1136
|
+
/**
|
1137
|
+
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1138
|
+
*/
|
1135
1139
|
muiTableFooterCellProps?:
|
1136
1140
|
| ((props: {
|
1137
1141
|
column: MRT_Column<TData>;
|