material-react-table 2.11.2 → 2.11.3
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 +12 -16
- package/dist/index.esm.js +50 -87
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -91
- package/dist/index.js.map +1 -1
- package/package.json +21 -21
- package/src/components/body/MRT_TableBodyCell.tsx +4 -6
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -4
- package/src/components/body/MRT_TableBodyRow.tsx +5 -7
- package/src/components/body/MRT_TableDetailPanel.tsx +2 -4
- package/src/components/footer/MRT_TableFooterRow.tsx +6 -3
- package/src/components/head/MRT_TableHeadCell.tsx +2 -3
- package/src/components/head/MRT_TableHeadRow.tsx +7 -3
- package/src/components/inputs/MRT_SelectCheckbox.tsx +2 -1
- package/src/components/menus/MRT_CellActionMenu.tsx +1 -5
- package/src/components/menus/MRT_ColumnActionMenu.tsx +1 -5
- package/src/components/menus/MRT_FilterOptionMenu.tsx +1 -5
- package/src/components/menus/MRT_RowActionMenu.tsx +1 -5
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +1 -5
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -2
- package/src/components/table/MRT_TableLoadingOverlay.tsx +8 -8
- package/src/components/table/MRT_TablePaper.tsx +2 -2
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +3 -1
- package/src/hooks/useMRT_TableOptions.ts +4 -0
- package/src/types.ts +15 -13
- package/src/utils/column.utils.ts +0 -48
- package/src/utils/row.utils.ts +2 -1
- package/src/utils/style.utils.ts +24 -26
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "2.11.
|
2
|
+
"version": "2.11.3",
|
3
3
|
"license": "MIT",
|
4
4
|
"name": "material-react-table",
|
5
5
|
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
@@ -65,26 +65,26 @@
|
|
65
65
|
"@babel/preset-react": "^7.23.3",
|
66
66
|
"@emotion/react": "^11.11.3",
|
67
67
|
"@emotion/styled": "^11.11.0",
|
68
|
-
"@faker-js/faker": "^8.4.
|
69
|
-
"@mui/icons-material": "^5.15.
|
70
|
-
"@mui/material": "^5.15.
|
71
|
-
"@mui/x-date-pickers": "^6.19.
|
68
|
+
"@faker-js/faker": "^8.4.1",
|
69
|
+
"@mui/icons-material": "^5.15.10",
|
70
|
+
"@mui/material": "^5.15.10",
|
71
|
+
"@mui/x-date-pickers": "^6.19.4",
|
72
72
|
"@rollup/plugin-typescript": "^11.1.6",
|
73
73
|
"@size-limit/preset-small-lib": "^11.0.2",
|
74
|
-
"@storybook/addon-a11y": "^7.6.
|
75
|
-
"@storybook/addon-essentials": "^7.6.
|
76
|
-
"@storybook/addon-interactions": "^7.6.
|
77
|
-
"@storybook/addon-links": "^7.6.
|
78
|
-
"@storybook/addon-storysource": "^7.6.
|
79
|
-
"@storybook/blocks": "^7.6.
|
80
|
-
"@storybook/react": "^7.6.
|
81
|
-
"@storybook/react-vite": "^7.6.
|
74
|
+
"@storybook/addon-a11y": "^7.6.15",
|
75
|
+
"@storybook/addon-essentials": "^7.6.15",
|
76
|
+
"@storybook/addon-interactions": "^7.6.15",
|
77
|
+
"@storybook/addon-links": "^7.6.15",
|
78
|
+
"@storybook/addon-storysource": "^7.6.15",
|
79
|
+
"@storybook/blocks": "^7.6.15",
|
80
|
+
"@storybook/react": "^7.6.15",
|
81
|
+
"@storybook/react-vite": "^7.6.15",
|
82
82
|
"@storybook/testing-library": "^0.2.2",
|
83
|
-
"@types/node": "^20.11.
|
84
|
-
"@types/react": "^18.2.
|
85
|
-
"@types/react-dom": "^18.2.
|
86
|
-
"@typescript-eslint/eslint-plugin": "^
|
87
|
-
"@typescript-eslint/parser": "^
|
83
|
+
"@types/node": "^20.11.17",
|
84
|
+
"@types/react": "^18.2.55",
|
85
|
+
"@types/react-dom": "^18.2.19",
|
86
|
+
"@typescript-eslint/eslint-plugin": "^7.0.1",
|
87
|
+
"@typescript-eslint/parser": "^7.0.1",
|
88
88
|
"@vitejs/plugin-react": "^4.2.1",
|
89
89
|
"eslint": "^8.56.0",
|
90
90
|
"eslint-plugin-mui-path-imports": "^0.0.15",
|
@@ -99,11 +99,11 @@
|
|
99
99
|
"rollup-plugin-dts": "^6.1.0",
|
100
100
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
101
101
|
"size-limit": "^11.0.2",
|
102
|
-
"storybook": "^7.6.
|
102
|
+
"storybook": "^7.6.15",
|
103
103
|
"storybook-dark-mode": "^3.0.3",
|
104
104
|
"tslib": "^2.6.2",
|
105
105
|
"typescript": "^5.3.3",
|
106
|
-
"vite": "^5.
|
106
|
+
"vite": "^5.1.1"
|
107
107
|
},
|
108
108
|
"peerDependencies": {
|
109
109
|
"@emotion/react": ">=11.11",
|
@@ -116,7 +116,7 @@
|
|
116
116
|
},
|
117
117
|
"dependencies": {
|
118
118
|
"@tanstack/match-sorter-utils": "8.11.8",
|
119
|
-
"@tanstack/react-table": "8.
|
119
|
+
"@tanstack/react-table": "8.12.0",
|
120
120
|
"@tanstack/react-virtual": "3.0.4",
|
121
121
|
"highlight-words": "1.2.2"
|
122
122
|
}
|
@@ -17,8 +17,7 @@ import {
|
|
17
17
|
type MRT_TableInstance,
|
18
18
|
} from '../../types';
|
19
19
|
import { isCellEditable, openEditingCell } from '../../utils/cell.utils';
|
20
|
-
import {
|
21
|
-
import { getCommonMRTCellStyles, getMRTTheme } from '../../utils/style.utils';
|
20
|
+
import { getCommonMRTCellStyles } from '../../utils/style.utils';
|
22
21
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
23
22
|
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
24
23
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
@@ -56,6 +55,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
56
55
|
enableColumnPinning,
|
57
56
|
enableGrouping,
|
58
57
|
layoutMode,
|
58
|
+
mrtTheme: { draggingBorderColor },
|
59
59
|
muiSkeletonProps,
|
60
60
|
muiTableBodyCellProps,
|
61
61
|
},
|
@@ -93,8 +93,6 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
93
93
|
table,
|
94
94
|
});
|
95
95
|
|
96
|
-
const { draggingBorderColor } = getMRTTheme(table, theme);
|
97
|
-
|
98
96
|
const [skeletonWidth, setSkeletonWidth] = useState(100);
|
99
97
|
useEffect(() => {
|
100
98
|
if ((!isLoading && !showSkeletons) || skeletonWidth !== 100) return;
|
@@ -111,8 +109,8 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
111
109
|
const isHoveredColumn = hoveredColumn?.id === column.id;
|
112
110
|
const isDraggingRow = draggingRow?.id === row.id;
|
113
111
|
const isHoveredRow = hoveredRow?.id === row.id;
|
114
|
-
const isFirstColumn = getIsFirstColumn(
|
115
|
-
const isLastColumn = getIsLastColumn(
|
112
|
+
const isFirstColumn = column.getIsFirstColumn();
|
113
|
+
const isLastColumn = column.getIsLastColumn();
|
116
114
|
const isLastRow = numRows && staticRowIndex === numRows - 1;
|
117
115
|
const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
|
118
116
|
const showResizeBorder =
|
@@ -5,7 +5,6 @@ import {
|
|
5
5
|
type MRT_RowData,
|
6
6
|
type MRT_TableInstance,
|
7
7
|
} from '../../types';
|
8
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
9
8
|
import highlightWords from 'highlight-words';
|
10
9
|
|
11
10
|
const allowedTypes = ['string', 'number'];
|
@@ -27,7 +26,10 @@ export const MRT_TableBodyCellValue = <TData extends MRT_RowData>({
|
|
27
26
|
}: MRT_TableBodyCellValueProps<TData>) => {
|
28
27
|
const {
|
29
28
|
getState,
|
30
|
-
options: {
|
29
|
+
options: {
|
30
|
+
enableFilterMatchHighlighting,
|
31
|
+
mrtTheme: { matchHighlightColor },
|
32
|
+
},
|
31
33
|
} = table;
|
32
34
|
const { column, row } = cell;
|
33
35
|
const { columnDef } = column;
|
@@ -88,8 +90,7 @@ export const MRT_TableBodyCellValue = <TData extends MRT_RowData>({
|
|
88
90
|
sx={
|
89
91
|
match
|
90
92
|
? {
|
91
|
-
backgroundColor:
|
92
|
-
getMRTTheme(table, theme).matchHighlightColor,
|
93
|
+
backgroundColor: matchHighlightColor,
|
93
94
|
borderRadius: '2px',
|
94
95
|
color: (theme) =>
|
95
96
|
theme.palette.mode === 'dark'
|
@@ -23,7 +23,6 @@ import { getIsRowSelected } from '../../utils/row.utils';
|
|
23
23
|
import {
|
24
24
|
commonCellBeforeAfterStyles,
|
25
25
|
getCommonPinnedCellStyles,
|
26
|
-
getMRTTheme,
|
27
26
|
} from '../../utils/style.utils';
|
28
27
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
29
28
|
|
@@ -61,6 +60,11 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
61
60
|
enableStickyHeader,
|
62
61
|
layoutMode,
|
63
62
|
memoMode,
|
63
|
+
mrtTheme: {
|
64
|
+
baseBackgroundColor,
|
65
|
+
pinnedRowBackgroundColor,
|
66
|
+
selectedRowBackgroundColor,
|
67
|
+
},
|
64
68
|
muiTableBodyRowProps,
|
65
69
|
renderDetailPanel,
|
66
70
|
rowPinningDisplayMode,
|
@@ -138,12 +142,6 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
138
142
|
|
139
143
|
const rowRef = useRef<HTMLTableRowElement | null>(null);
|
140
144
|
|
141
|
-
const {
|
142
|
-
baseBackgroundColor,
|
143
|
-
pinnedRowBackgroundColor,
|
144
|
-
selectedRowBackgroundColor,
|
145
|
-
} = getMRTTheme(table, theme);
|
146
|
-
|
147
145
|
const cellHighlightColor = isRowSelected
|
148
146
|
? selectedRowBackgroundColor
|
149
147
|
: isRowPinned
|
@@ -9,7 +9,6 @@ import {
|
|
9
9
|
type MRT_TableInstance,
|
10
10
|
type MRT_VirtualItem,
|
11
11
|
} from '../../types';
|
12
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
13
12
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
14
13
|
|
15
14
|
export interface MRT_TableDetailPanelProps<TData extends MRT_RowData>
|
@@ -37,6 +36,7 @@ export const MRT_TableDetailPanel = <TData extends MRT_RowData>({
|
|
37
36
|
options: {
|
38
37
|
enableRowVirtualization,
|
39
38
|
layoutMode,
|
39
|
+
mrtTheme: { baseBackgroundColor },
|
40
40
|
muiDetailPanelProps,
|
41
41
|
muiTableBodyRowProps,
|
42
42
|
renderDetailPanel,
|
@@ -89,9 +89,7 @@ export const MRT_TableDetailPanel = <TData extends MRT_RowData>({
|
|
89
89
|
colSpan={getVisibleLeafColumns().length}
|
90
90
|
{...tableCellProps}
|
91
91
|
sx={(theme) => ({
|
92
|
-
backgroundColor: virtualRow
|
93
|
-
? getMRTTheme(table, theme).baseBackgroundColor
|
94
|
-
: undefined,
|
92
|
+
backgroundColor: virtualRow ? baseBackgroundColor : undefined,
|
95
93
|
borderBottom: !row.getIsExpanded() ? 'none' : undefined,
|
96
94
|
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
97
95
|
py: !!DetailPanel && row.getIsExpanded() ? '1rem' : 0,
|
@@ -8,7 +8,6 @@ import {
|
|
8
8
|
type MRT_TableInstance,
|
9
9
|
type MRT_VirtualItem,
|
10
10
|
} from '../../types';
|
11
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
12
11
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
13
12
|
|
14
13
|
export interface MRT_TableFooterRowProps<TData extends MRT_RowData>
|
@@ -25,7 +24,11 @@ export const MRT_TableFooterRow = <TData extends MRT_RowData>({
|
|
25
24
|
...rest
|
26
25
|
}: MRT_TableFooterRowProps<TData>) => {
|
27
26
|
const {
|
28
|
-
options: {
|
27
|
+
options: {
|
28
|
+
layoutMode,
|
29
|
+
mrtTheme: { baseBackgroundColor },
|
30
|
+
muiTableFooterRowProps,
|
31
|
+
},
|
29
32
|
} = table;
|
30
33
|
|
31
34
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } =
|
@@ -55,7 +58,7 @@ export const MRT_TableFooterRow = <TData extends MRT_RowData>({
|
|
55
58
|
<TableRow
|
56
59
|
{...tableRowProps}
|
57
60
|
sx={(theme) => ({
|
58
|
-
backgroundColor:
|
61
|
+
backgroundColor: baseBackgroundColor,
|
59
62
|
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
60
63
|
position: 'relative',
|
61
64
|
width: '100%',
|
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
type MRT_RowData,
|
16
16
|
type MRT_TableInstance,
|
17
17
|
} from '../../types';
|
18
|
-
import { getCommonMRTCellStyles
|
18
|
+
import { getCommonMRTCellStyles } from '../../utils/style.utils';
|
19
19
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
20
20
|
|
21
21
|
export interface MRT_TableHeadCellProps<TData extends MRT_RowData>
|
@@ -47,6 +47,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
47
47
|
enableGrouping,
|
48
48
|
enableMultiSort,
|
49
49
|
layoutMode,
|
50
|
+
mrtTheme: { draggingBorderColor },
|
50
51
|
muiTableHeadCellProps,
|
51
52
|
},
|
52
53
|
refs: { tableHeadCellRefs },
|
@@ -73,8 +74,6 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
73
74
|
...rest,
|
74
75
|
};
|
75
76
|
|
76
|
-
const { draggingBorderColor } = getMRTTheme(table, theme);
|
77
|
-
|
78
77
|
const isColumnPinned =
|
79
78
|
enableColumnPinning &&
|
80
79
|
columnDef.columnDefType !== 'group' &&
|
@@ -9,7 +9,6 @@ import {
|
|
9
9
|
type MRT_TableInstance,
|
10
10
|
type MRT_VirtualItem,
|
11
11
|
} from '../../types';
|
12
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
13
12
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
14
13
|
|
15
14
|
export interface MRT_TableHeadRowProps<TData extends MRT_RowData>
|
@@ -26,7 +25,12 @@ export const MRT_TableHeadRow = <TData extends MRT_RowData>({
|
|
26
25
|
...rest
|
27
26
|
}: MRT_TableHeadRowProps<TData>) => {
|
28
27
|
const {
|
29
|
-
options: {
|
28
|
+
options: {
|
29
|
+
enableStickyHeader,
|
30
|
+
layoutMode,
|
31
|
+
mrtTheme: { baseBackgroundColor },
|
32
|
+
muiTableHeadRowProps,
|
33
|
+
},
|
30
34
|
} = table;
|
31
35
|
|
32
36
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } =
|
@@ -44,7 +48,7 @@ export const MRT_TableHeadRow = <TData extends MRT_RowData>({
|
|
44
48
|
<TableRow
|
45
49
|
{...tableRowProps}
|
46
50
|
sx={(theme) => ({
|
47
|
-
backgroundColor:
|
51
|
+
backgroundColor: baseBackgroundColor,
|
48
52
|
boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`,
|
49
53
|
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
50
54
|
position:
|
@@ -58,6 +58,7 @@ export const MRT_SelectCheckbox = <TData extends MRT_RowData>({
|
|
58
58
|
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
59
59
|
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
60
60
|
row,
|
61
|
+
staticRowIndex,
|
61
62
|
table,
|
62
63
|
})),
|
63
64
|
...rest,
|
@@ -87,7 +88,7 @@ export const MRT_SelectCheckbox = <TData extends MRT_RowData>({
|
|
87
88
|
},
|
88
89
|
onChange: (event) => {
|
89
90
|
event.stopPropagation();
|
90
|
-
|
91
|
+
selectAll ? onSelectAllChange(event) : onSelectionChange!(event);
|
91
92
|
},
|
92
93
|
size: (density === 'compact' ? 'small' : 'medium') as 'medium' | 'small',
|
93
94
|
...checkboxProps,
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
2
|
-
import { useTheme } from '@mui/material/styles';
|
3
2
|
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
4
3
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
5
4
|
import { openEditingCell } from '../../utils/cell.utils';
|
6
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
7
5
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
8
6
|
|
9
7
|
export interface MRT_CellActionMenuProps<TData extends MRT_RowData>
|
@@ -23,6 +21,7 @@ export const MRT_CellActionMenu = <TData extends MRT_RowData>({
|
|
23
21
|
enableEditing,
|
24
22
|
icons: { ContentCopy, EditIcon },
|
25
23
|
localization,
|
24
|
+
mrtTheme: { menuBackgroundColor },
|
26
25
|
renderCellActionMenuItems,
|
27
26
|
},
|
28
27
|
refs: { actionCellRef },
|
@@ -33,9 +32,6 @@ export const MRT_CellActionMenu = <TData extends MRT_RowData>({
|
|
33
32
|
const { column } = cell;
|
34
33
|
const { columnDef } = column;
|
35
34
|
|
36
|
-
const theme = useTheme();
|
37
|
-
const { menuBackgroundColor } = getMRTTheme(table, theme);
|
38
|
-
|
39
35
|
const handleClose = (event?: any) => {
|
40
36
|
event?.stopPropagation();
|
41
37
|
table.setActionCell(null);
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { type MouseEvent, useState } from 'react';
|
2
2
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
3
|
-
import { useTheme } from '@mui/material/styles';
|
4
3
|
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
5
4
|
import { MRT_FilterOptionMenu } from './MRT_FilterOptionMenu';
|
6
5
|
import {
|
@@ -8,7 +7,6 @@ import {
|
|
8
7
|
type MRT_RowData,
|
9
8
|
type MRT_TableInstance,
|
10
9
|
} from '../../types';
|
11
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
12
10
|
|
13
11
|
export interface MRT_ColumnActionMenuProps<TData extends MRT_RowData>
|
14
12
|
extends Partial<MenuProps> {
|
@@ -51,6 +49,7 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
51
49
|
VisibilityOffIcon,
|
52
50
|
},
|
53
51
|
localization,
|
52
|
+
mrtTheme: { menuBackgroundColor },
|
54
53
|
renderColumnActionsMenuItems,
|
55
54
|
},
|
56
55
|
refs: { filterInputRefs },
|
@@ -318,9 +317,6 @@ export const MRT_ColumnActionMenu = <TData extends MRT_RowData>({
|
|
318
317
|
: []),
|
319
318
|
].filter(Boolean);
|
320
319
|
|
321
|
-
const theme = useTheme();
|
322
|
-
const { menuBackgroundColor } = getMRTTheme(table, theme);
|
323
|
-
|
324
320
|
return (
|
325
321
|
<Menu
|
326
322
|
MenuListProps={{
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
3
|
-
import { useTheme } from '@mui/material/styles';
|
4
3
|
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
5
4
|
import {
|
6
5
|
type MRT_FilterOption,
|
@@ -10,7 +9,6 @@ import {
|
|
10
9
|
type MRT_RowData,
|
11
10
|
type MRT_TableInstance,
|
12
11
|
} from '../../types';
|
13
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
14
12
|
|
15
13
|
export const mrtFilterOptions = (
|
16
14
|
localization: MRT_Localization,
|
@@ -131,6 +129,7 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
|
|
131
129
|
columnFilterModeOptions,
|
132
130
|
globalFilterModeOptions,
|
133
131
|
localization,
|
132
|
+
mrtTheme: { menuBackgroundColor },
|
134
133
|
renderColumnFilterModeMenuItems,
|
135
134
|
renderGlobalFilterModeMenuItems,
|
136
135
|
},
|
@@ -239,9 +238,6 @@ export const MRT_FilterOptionMenu = <TData extends MRT_RowData>({
|
|
239
238
|
const filterOption =
|
240
239
|
!!header && columnDef ? columnDef._filterFn : globalFilterFn;
|
241
240
|
|
242
|
-
const theme = useTheme();
|
243
|
-
const { menuBackgroundColor } = getMRTTheme(table, theme);
|
244
|
-
|
245
241
|
return (
|
246
242
|
<Menu
|
247
243
|
MenuListProps={{
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import { type MouseEvent } from 'react';
|
2
2
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
3
|
-
import { useTheme } from '@mui/material/styles';
|
4
3
|
import { MRT_ActionMenuItem } from './MRT_ActionMenuItem';
|
5
4
|
import {
|
6
5
|
type MRT_Row,
|
7
6
|
type MRT_RowData,
|
8
7
|
type MRT_TableInstance,
|
9
8
|
} from '../../types';
|
10
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
11
9
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
12
10
|
|
13
11
|
export interface MRT_RowActionMenuProps<TData extends MRT_RowData>
|
@@ -36,14 +34,12 @@ export const MRT_RowActionMenu = <TData extends MRT_RowData>({
|
|
36
34
|
enableEditing,
|
37
35
|
icons: { EditIcon },
|
38
36
|
localization,
|
37
|
+
mrtTheme: { menuBackgroundColor },
|
39
38
|
renderRowActionMenuItems,
|
40
39
|
},
|
41
40
|
} = table;
|
42
41
|
const { density } = getState();
|
43
42
|
|
44
|
-
const theme = useTheme();
|
45
|
-
const { menuBackgroundColor } = getMRTTheme(table, theme);
|
46
|
-
|
47
43
|
return (
|
48
44
|
<Menu
|
49
45
|
MenuListProps={{
|
@@ -3,7 +3,6 @@ import Box from '@mui/material/Box';
|
|
3
3
|
import Button from '@mui/material/Button';
|
4
4
|
import Divider from '@mui/material/Divider';
|
5
5
|
import Menu, { type MenuProps } from '@mui/material/Menu';
|
6
|
-
import { useTheme } from '@mui/material/styles';
|
7
6
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
8
7
|
import {
|
9
8
|
type MRT_Column,
|
@@ -11,7 +10,6 @@ import {
|
|
11
10
|
type MRT_TableInstance,
|
12
11
|
} from '../../types';
|
13
12
|
import { getDefaultColumnOrderIds } from '../../utils/displayColumn.utils';
|
14
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
15
13
|
|
16
14
|
export interface MRT_ShowHideColumnsMenuProps<TData extends MRT_RowData>
|
17
15
|
extends Partial<MenuProps> {
|
@@ -42,6 +40,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
42
40
|
enableColumnPinning,
|
43
41
|
enableHiding,
|
44
42
|
localization,
|
43
|
+
mrtTheme: { menuBackgroundColor },
|
45
44
|
},
|
46
45
|
} = table;
|
47
46
|
const { columnOrder, columnPinning, density } = getState();
|
@@ -84,9 +83,6 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
|
|
84
83
|
null,
|
85
84
|
);
|
86
85
|
|
87
|
-
const theme = useTheme();
|
88
|
-
const { menuBackgroundColor } = getMRTTheme(table, theme);
|
89
|
-
|
90
86
|
return (
|
91
87
|
<Menu
|
92
88
|
MenuListProps={{
|
@@ -17,7 +17,7 @@ import {
|
|
17
17
|
type MRT_TableInstance,
|
18
18
|
} from '../../types';
|
19
19
|
import { reorderColumn } from '../../utils/column.utils';
|
20
|
-
import { getCommonTooltipProps
|
20
|
+
import { getCommonTooltipProps } from '../../utils/style.utils';
|
21
21
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
22
22
|
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
23
23
|
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
@@ -48,6 +48,7 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
48
48
|
enableColumnPinning,
|
49
49
|
enableHiding,
|
50
50
|
localization,
|
51
|
+
mrtTheme: { draggingBorderColor },
|
51
52
|
},
|
52
53
|
setColumnOrder,
|
53
54
|
} = table;
|
@@ -116,7 +117,7 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
|
|
116
117
|
outline: isDragging
|
117
118
|
? `2px dashed ${theme.palette.grey[500]}`
|
118
119
|
: hoveredColumn?.id === column.id
|
119
|
-
? `2px dashed ${
|
120
|
+
? `2px dashed ${draggingBorderColor}`
|
120
121
|
: 'none',
|
121
122
|
outlineOffset: '-2px',
|
122
123
|
pl: `${(column.depth + 0.5) * 2}rem`,
|
@@ -4,7 +4,6 @@ import CircularProgress, {
|
|
4
4
|
} from '@mui/material/CircularProgress';
|
5
5
|
import { alpha } from '@mui/material/styles';
|
6
6
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
7
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
8
7
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
9
8
|
|
10
9
|
export interface MRT_TableLoadingOverlayProps<TData extends MRT_RowData>
|
@@ -17,7 +16,11 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
|
|
17
16
|
...rest
|
18
17
|
}: MRT_TableLoadingOverlayProps<TData>) => {
|
19
18
|
const {
|
20
|
-
options: {
|
19
|
+
options: {
|
20
|
+
localization,
|
21
|
+
mrtTheme: { baseBackgroundColor },
|
22
|
+
muiCircularProgressProps,
|
23
|
+
},
|
21
24
|
} = table;
|
22
25
|
|
23
26
|
const circularProgressProps = {
|
@@ -27,12 +30,9 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
|
|
27
30
|
|
28
31
|
return (
|
29
32
|
<Box
|
30
|
-
sx={
|
33
|
+
sx={{
|
31
34
|
alignItems: 'center',
|
32
|
-
backgroundColor: alpha(
|
33
|
-
getMRTTheme(table, theme).baseBackgroundColor,
|
34
|
-
0.5,
|
35
|
-
),
|
35
|
+
backgroundColor: alpha(baseBackgroundColor, 0.5),
|
36
36
|
bottom: 0,
|
37
37
|
display: 'flex',
|
38
38
|
justifyContent: 'center',
|
@@ -43,7 +43,7 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
|
|
43
43
|
top: 0,
|
44
44
|
width: '100%',
|
45
45
|
zIndex: 3,
|
46
|
-
}
|
46
|
+
}}
|
47
47
|
>
|
48
48
|
{circularProgressProps?.Component ?? (
|
49
49
|
<CircularProgress
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import Paper, { type PaperProps } from '@mui/material/Paper';
|
2
2
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
3
3
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
4
|
-
import { getMRTTheme } from '../../utils/style.utils';
|
5
4
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
6
5
|
import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
|
7
6
|
import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
|
@@ -20,6 +19,7 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
20
19
|
options: {
|
21
20
|
enableBottomToolbar,
|
22
21
|
enableTopToolbar,
|
22
|
+
mrtTheme: { baseBackgroundColor },
|
23
23
|
muiTablePaperProps,
|
24
24
|
renderBottomToolbar,
|
25
25
|
renderTopToolbar,
|
@@ -64,7 +64,7 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
64
64
|
...paperProps?.style,
|
65
65
|
}}
|
66
66
|
sx={(theme) => ({
|
67
|
-
backgroundColor:
|
67
|
+
backgroundColor: baseBackgroundColor,
|
68
68
|
backgroundImage: 'unset',
|
69
69
|
overflow: 'hidden',
|
70
70
|
transition: 'all 100ms ease-in-out',
|
@@ -68,7 +68,9 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
68
68
|
?.replace('{selectedCount}', selectedRowCount.toLocaleString())
|
69
69
|
?.replace('{rowCount}', totalRowCount.toString())}
|
70
70
|
<Button
|
71
|
-
onClick={(event) =>
|
71
|
+
onClick={(event) =>
|
72
|
+
getMRT_SelectAllHandler({ table })(event, false, true)
|
73
|
+
}
|
72
74
|
size="small"
|
73
75
|
sx={{ p: '2px' }}
|
74
76
|
>
|
@@ -21,6 +21,7 @@ import {
|
|
21
21
|
type MRT_RowData,
|
22
22
|
type MRT_TableOptions,
|
23
23
|
} from '../types';
|
24
|
+
import { getMRTTheme } from '../utils/style.utils';
|
24
25
|
|
25
26
|
export const MRT_DefaultColumn = {
|
26
27
|
filterVariant: 'text',
|
@@ -96,6 +97,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
96
97
|
manualGrouping,
|
97
98
|
manualPagination,
|
98
99
|
manualSorting,
|
100
|
+
mrtTheme,
|
99
101
|
paginationDisplayMode = 'default',
|
100
102
|
positionActionsColumn = 'first',
|
101
103
|
positionCreatingRow = 'top',
|
@@ -120,6 +122,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
120
122
|
}),
|
121
123
|
[localization],
|
122
124
|
);
|
125
|
+
mrtTheme = useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
|
123
126
|
aggregationFns = useMemo(
|
124
127
|
() => ({ ...MRT_AggregationFns, ...aggregationFns }),
|
125
128
|
[],
|
@@ -241,6 +244,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
|
|
241
244
|
manualGrouping,
|
242
245
|
manualPagination,
|
243
246
|
manualSorting,
|
247
|
+
mrtTheme,
|
244
248
|
paginationDisplayMode,
|
245
249
|
positionActionsColumn,
|
246
250
|
positionCreatingRow,
|
package/src/types.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import {
|
2
|
-
type CSSProperties,
|
3
2
|
type Dispatch,
|
4
3
|
type MutableRefObject,
|
5
4
|
type ReactNode,
|
@@ -257,12 +256,12 @@ export interface MRT_Localization {
|
|
257
256
|
}
|
258
257
|
|
259
258
|
export interface MRT_Theme {
|
260
|
-
baseBackgroundColor
|
261
|
-
draggingBorderColor
|
262
|
-
matchHighlightColor
|
263
|
-
menuBackgroundColor
|
264
|
-
pinnedRowBackgroundColor
|
265
|
-
selectedRowBackgroundColor
|
259
|
+
baseBackgroundColor: string;
|
260
|
+
draggingBorderColor: string;
|
261
|
+
matchHighlightColor: string;
|
262
|
+
menuBackgroundColor: string;
|
263
|
+
pinnedRowBackgroundColor: string;
|
264
|
+
selectedRowBackgroundColor: string;
|
266
265
|
}
|
267
266
|
|
268
267
|
export interface MRT_RowModel<TData extends MRT_RowData> {
|
@@ -348,11 +347,14 @@ export type MRT_TableInstance<TData extends MRT_RowData> = Omit<
|
|
348
347
|
setShowToolbarDropZone: Dispatch<SetStateAction<boolean>>;
|
349
348
|
};
|
350
349
|
|
351
|
-
export type MRT_DefinedTableOptions<TData extends MRT_RowData> =
|
352
|
-
MRT_TableOptions<TData
|
353
|
-
|
354
|
-
|
355
|
-
|
350
|
+
export type MRT_DefinedTableOptions<TData extends MRT_RowData> = Omit<
|
351
|
+
MRT_TableOptions<TData>,
|
352
|
+
'icons' | 'localization' | 'mrtTheme'
|
353
|
+
> & {
|
354
|
+
icons: MRT_Icons;
|
355
|
+
localization: MRT_Localization;
|
356
|
+
mrtTheme: Required<MRT_Theme>;
|
357
|
+
};
|
356
358
|
|
357
359
|
export type MRT_StatefulTableOptions<TData extends MRT_RowData> =
|
358
360
|
MRT_DefinedTableOptions<TData> & {
|
@@ -914,7 +916,7 @@ export type MRT_TableOptions<TData extends MRT_RowData> = Omit<
|
|
914
916
|
* @link https://www.material-react-table.com/docs/guides/memoize-components
|
915
917
|
*/
|
916
918
|
memoMode?: 'cells' | 'rows' | 'table-body';
|
917
|
-
mrtTheme?: ((theme: Theme) => MRT_Theme) | MRT_Theme
|
919
|
+
mrtTheme?: ((theme: Theme) => Partial<MRT_Theme>) | Partial<MRT_Theme>;
|
918
920
|
muiBottomToolbarProps?:
|
919
921
|
| ((props: { table: MRT_TableInstance<TData> }) => BoxProps)
|
920
922
|
| BoxProps;
|