@cutting/material-react-table 5.0.0-beta.2 → 5.1.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 +1 -4
- package/dist/index.d.ts +189 -524
- package/dist/index.js +329 -345
- package/dist/index.js.map +1 -1
- package/locales/ar/index.mjs +1 -2
- package/locales/az/index.mjs +1 -2
- package/locales/bg/index.mjs +1 -2
- package/locales/cs/index.mjs +1 -2
- package/locales/da/index.mjs +1 -2
- package/locales/de/index.mjs +1 -2
- package/locales/el/index.mjs +1 -2
- package/locales/en/index.mjs +1 -2
- package/locales/es/index.mjs +1 -2
- package/locales/et/index.mjs +1 -2
- package/locales/fa/index.mjs +1 -2
- package/locales/fi/index.mjs +1 -2
- package/locales/fr/index.mjs +1 -2
- package/locales/he/index.mjs +1 -2
- package/locales/hr/index.mjs +1 -2
- package/locales/hu/index.mjs +1 -2
- package/locales/hy/index.mjs +1 -2
- package/locales/id/index.mjs +1 -2
- package/locales/it/index.mjs +1 -2
- package/locales/ja/index.mjs +1 -2
- package/locales/ko/index.mjs +1 -2
- package/locales/nl/index.mjs +1 -2
- package/locales/no/index.mjs +1 -2
- package/locales/np/index.mjs +1 -2
- package/locales/pl/index.mjs +1 -2
- package/locales/pt/index.mjs +1 -2
- package/locales/pt-BR/index.mjs +1 -2
- package/locales/ro/index.mjs +1 -2
- package/locales/ru/index.mjs +1 -2
- package/locales/sk/index.mjs +1 -2
- package/locales/sr-Cyrl-RS/index.mjs +1 -2
- package/locales/sr-Latn-RS/index.mjs +1 -2
- package/locales/sv/index.mjs +1 -2
- package/locales/tr/index.mjs +1 -2
- package/locales/uk/index.mjs +1 -2
- package/locales/vi/index.mjs +1 -2
- package/locales/zh-Hans/index.mjs +1 -2
- package/locales/zh-Hant/index.mjs +1 -2
- package/package.json +32 -40
- package/src/MaterialReactTable.smoke.test.tsx +3 -9
- package/src/components/MaterialReactTable.tsx +13 -21
- package/src/components/body/MRT_TableBody.tsx +67 -82
- package/src/components/body/MRT_TableBodyCell.tsx +38 -80
- package/src/components/body/MRT_TableBodyCellValue.tsx +5 -14
- package/src/components/body/MRT_TableBodyRow.tsx +55 -102
- package/src/components/body/MRT_TableBodyRowGrabHandle.test.tsx +2 -6
- package/src/components/body/MRT_TableBodyRowGrabHandle.tsx +4 -9
- package/src/components/body/MRT_TableBodyRowPinButton.tsx +8 -14
- package/src/components/body/MRT_TableDetailPanel.test.tsx +3 -9
- package/src/components/body/MRT_TableDetailPanel.tsx +8 -14
- package/src/components/buttons/MRT_ColumnPinningButtons.test.tsx +6 -16
- package/src/components/buttons/MRT_ColumnPinningButtons.tsx +6 -12
- package/src/components/buttons/MRT_CopyButton.tsx +7 -15
- package/src/components/buttons/MRT_EditActionButtons.test.tsx +2 -6
- package/src/components/buttons/MRT_EditActionButtons.tsx +15 -37
- package/src/components/buttons/MRT_ExpandAllButton.tsx +8 -16
- package/src/components/buttons/MRT_ExpandButton.tsx +9 -21
- package/src/components/buttons/MRT_GrabHandleButton.tsx +6 -10
- package/src/components/buttons/MRT_RowPinButton.tsx +8 -23
- package/src/components/buttons/MRT_ShowHideColumnsButton.tsx +5 -18
- package/src/components/buttons/MRT_ToggleDensePaddingButton.test.tsx +4 -12
- package/src/components/buttons/MRT_ToggleDensePaddingButton.tsx +4 -11
- package/src/components/buttons/MRT_ToggleFiltersButton.test.tsx +4 -13
- package/src/components/buttons/MRT_ToggleFiltersButton.tsx +3 -5
- package/src/components/buttons/MRT_ToggleFullScreenButton.test.tsx +3 -11
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +4 -9
- package/src/components/buttons/MRT_ToggleGlobalFilterButton.tsx +3 -5
- package/src/components/buttons/MRT_ToggleRowActionMenuButton.tsx +7 -15
- package/src/components/footer/MRT_TableFooter.tsx +9 -16
- package/src/components/footer/MRT_TableFooterCell.tsx +9 -32
- package/src/components/footer/MRT_TableFooterRow.tsx +18 -32
- package/src/components/head/MRT_TableHead.tsx +8 -18
- package/src/components/head/MRT_TableHeadCell.tsx +46 -100
- package/src/components/head/MRT_TableHeadCellColumnActionsButton.tsx +10 -30
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +4 -15
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +20 -54
- package/src/components/head/MRT_TableHeadCellGrabHandle.test.tsx +5 -19
- package/src/components/head/MRT_TableHeadCellGrabHandle.tsx +9 -38
- package/src/components/head/MRT_TableHeadCellResizeHandle.test.tsx +3 -13
- package/src/components/head/MRT_TableHeadCellResizeHandle.tsx +10 -24
- package/src/components/head/MRT_TableHeadCellSortLabel.tsx +10 -26
- package/src/components/head/MRT_TableHeadRow.tsx +24 -36
- package/src/components/inputs/MRT_EditCellTextField.test.tsx +2 -9
- package/src/components/inputs/MRT_EditCellTextField.tsx +9 -28
- package/src/components/inputs/MRT_FilterCheckbox.tsx +9 -23
- package/src/components/inputs/MRT_FilterRangeFields.tsx +6 -15
- package/src/components/inputs/MRT_FilterRangeSlider.tsx +24 -32
- package/src/components/inputs/MRT_FilterTextField.test.tsx +72 -14
- package/src/components/inputs/MRT_FilterTextField.tsx +77 -138
- package/src/components/inputs/MRT_GlobalFilterTextField.tsx +10 -32
- package/src/components/inputs/MRT_SelectCheckbox.test.tsx +4 -11
- package/src/components/inputs/MRT_SelectCheckbox.tsx +17 -36
- package/src/components/menus/MRT_ActionMenuItem.tsx +6 -15
- package/src/components/menus/MRT_CellActionMenu.tsx +6 -9
- package/src/components/menus/MRT_ColumnActionMenu.tsx +22 -57
- package/src/components/menus/MRT_FilterOptionMenu.tsx +38 -65
- package/src/components/menus/MRT_RowActionMenu.tsx +33 -22
- package/src/components/menus/MRT_ShowHideColumnsMenu.tsx +29 -65
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.test.tsx +43 -0
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +14 -50
- package/src/components/modals/MRT_EditRowModal.test.tsx +5 -21
- package/src/components/modals/MRT_EditRowModal.tsx +8 -26
- package/src/components/table/MRT_Table.tsx +12 -20
- package/src/components/table/MRT_TableContainer.test.tsx +147 -0
- package/src/components/table/MRT_TableContainer.tsx +33 -37
- package/src/components/table/MRT_TableLoadingOverlay.tsx +3 -5
- package/src/components/table/MRT_TablePaper.tsx +7 -14
- package/src/components/toolbar/MRT_BottomToolbar.tsx +11 -23
- package/src/components/toolbar/MRT_LinearProgressBar.tsx +4 -11
- package/src/components/toolbar/MRT_TablePagination.tsx +33 -40
- package/src/components/toolbar/MRT_ToolbarAlertBanner.tsx +21 -50
- package/src/components/toolbar/MRT_ToolbarDropZone.test.tsx +26 -10
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +23 -21
- package/src/components/toolbar/MRT_ToolbarInternalButtons.tsx +11 -21
- package/src/components/toolbar/MRT_TopToolbar.tsx +12 -28
- package/src/fns/aggregationFns.test.tsx +1 -3
- package/src/fns/filterFns.test.tsx +9 -37
- package/src/fns/filterFns.ts +73 -96
- package/src/fns/sortingFns.test.tsx +39 -0
- package/src/fns/sortingFns.ts +15 -15
- package/src/fns/tableFeatures.test.tsx +6 -29
- package/src/fns/tableFeatures.ts +5 -4
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +2 -11
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +2 -10
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +8 -17
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +3 -8
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +2 -8
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +3 -13
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -5
- package/src/hooks/useMRT_ColumnVirtualizer.ts +28 -49
- package/src/hooks/useMRT_Effects.test.tsx +114 -0
- package/src/hooks/useMRT_Effects.ts +26 -27
- package/src/hooks/useMRT_RowVirtualizer.ts +18 -33
- package/src/hooks/useMRT_Rows.ts +3 -42
- package/src/hooks/useMRT_TableInstance.ts +63 -129
- package/src/hooks/useMRT_TableOptions.ts +15 -29
- package/src/hooks/useMaterialReactTable.ts +2 -7
- package/src/icons.ts +38 -1
- package/src/index.ts +0 -4
- package/src/locales/ar.ts +1 -2
- package/src/locales/az.ts +1 -2
- package/src/locales/bg.ts +1 -2
- package/src/locales/cs.ts +2 -4
- package/src/locales/da.ts +1 -2
- package/src/locales/de.ts +1 -2
- package/src/locales/el.ts +1 -2
- package/src/locales/en.ts +1 -2
- package/src/locales/es.ts +1 -2
- package/src/locales/et.ts +2 -4
- package/src/locales/fa.ts +1 -2
- package/src/locales/fi.ts +2 -4
- package/src/locales/fr.ts +1 -2
- package/src/locales/he.ts +1 -2
- package/src/locales/hr.ts +1 -2
- package/src/locales/hu.ts +1 -2
- package/src/locales/hy.ts +1 -2
- package/src/locales/id.ts +2 -4
- package/src/locales/it.ts +1 -2
- package/src/locales/ja.ts +1 -2
- package/src/locales/ko.ts +1 -2
- package/src/locales/nl.ts +1 -2
- package/src/locales/no.ts +2 -4
- package/src/locales/np.ts +2 -4
- package/src/locales/pl.ts +1 -2
- package/src/locales/pt-BR.ts +1 -2
- package/src/locales/pt.ts +1 -2
- package/src/locales/ro.ts +1 -2
- package/src/locales/ru.ts +1 -2
- package/src/locales/sk.ts +2 -4
- package/src/locales/sr-Cyrl-RS.ts +1 -2
- package/src/locales/sr-Latn-RS.ts +1 -2
- package/src/locales/sv.ts +1 -2
- package/src/locales/tr.ts +1 -2
- package/src/locales/uk.ts +1 -2
- package/src/locales/vi.ts +1 -2
- package/src/types.ts +156 -349
- package/src/utils/cell.utils.ts +30 -68
- package/src/utils/column.utils.ts +61 -49
- package/src/utils/displayColumn.utils.ts +16 -38
- package/src/utils/highlight.utils.ts +7 -11
- package/src/utils/row.utils.ts +40 -65
- package/src/utils/slotProps.utils.ts +1 -4
- package/src/utils/style.utils.ts +18 -46
- package/src/utils/tanstack.helpers.ts +10 -17
- package/src/utils/utils.ts +6 -10
- package/src/utils/virtualization.utils.ts +5 -9
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TableContainer, type TableContainerProps } from '@mui/material';
|
|
2
|
+
import { type CSSObject } from '@mui/material/styles';
|
|
2
3
|
import { useEffect, useLayoutEffect, useState } from 'react';
|
|
3
4
|
|
|
4
5
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
@@ -8,39 +9,31 @@ import { MRT_EditRowModal } from '../modals/MRT_EditRowModal';
|
|
|
8
9
|
import { MRT_Table } from './MRT_Table';
|
|
9
10
|
import { MRT_TableLoadingOverlay } from './MRT_TableLoadingOverlay';
|
|
10
11
|
|
|
11
|
-
const useIsomorphicLayoutEffect =
|
|
12
|
-
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
12
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
13
13
|
|
|
14
|
-
export interface MRT_TableContainerProps<TData extends MRT_RowData>
|
|
15
|
-
extends TableContainerProps {
|
|
14
|
+
export interface MRT_TableContainerProps<TData extends MRT_RowData> extends TableContainerProps {
|
|
16
15
|
table: MRT_TableInstance<TData>;
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export const MRT_TableContainer = <TData extends MRT_RowData>({
|
|
20
19
|
table,
|
|
21
20
|
...rest
|
|
22
|
-
}: MRT_TableContainerProps<TData>) => {
|
|
21
|
+
}: MRT_TableContainerProps<TData>): JSX.Element => {
|
|
23
22
|
const {
|
|
24
23
|
options: {
|
|
25
24
|
createDisplayMode,
|
|
26
25
|
editDisplayMode,
|
|
26
|
+
enableBottomToolbar,
|
|
27
27
|
enableCellActions,
|
|
28
28
|
enableStickyHeader,
|
|
29
|
+
enableTopToolbar,
|
|
29
30
|
muiTableContainerProps,
|
|
30
31
|
},
|
|
31
32
|
refs: { bottomToolbarRef, tableContainerRef, topToolbarRef },
|
|
32
33
|
} = table;
|
|
33
|
-
const {
|
|
34
|
-
actionCell,
|
|
35
|
-
creatingRow,
|
|
36
|
-
editingRow,
|
|
37
|
-
isFullScreen,
|
|
38
|
-
isLoading,
|
|
39
|
-
showLoadingOverlay,
|
|
40
|
-
} = table.state;
|
|
34
|
+
const { actionCell, creatingRow, editingRow, isFullScreen, isLoading, showLoadingOverlay } = table.state;
|
|
41
35
|
|
|
42
|
-
const loading =
|
|
43
|
-
showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
|
|
36
|
+
const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
|
|
44
37
|
|
|
45
38
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
46
39
|
|
|
@@ -52,18 +45,28 @@ export const MRT_TableContainer = <TData extends MRT_RowData>({
|
|
|
52
45
|
};
|
|
53
46
|
|
|
54
47
|
useIsomorphicLayoutEffect(() => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
const measureToolbars = () => {
|
|
49
|
+
setTotalToolbarHeight((topToolbarRef.current?.offsetHeight ?? 0) + (bottomToolbarRef.current?.offsetHeight ?? 0));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
measureToolbars();
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
if (typeof ResizeObserver === 'undefined' || !tableContainerRef.current) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
59
|
+
for (const toolbar of [topToolbarRef.current, bottomToolbarRef.current]) {
|
|
60
|
+
if (toolbar) {
|
|
61
|
+
resizeObserver.observe(toolbar);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
measureToolbars();
|
|
65
|
+
});
|
|
66
|
+
resizeObserver.observe(tableContainerRef.current);
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
});
|
|
68
|
+
return () => resizeObserver.disconnect();
|
|
69
|
+
}, [bottomToolbarRef, enableBottomToolbar, enableTopToolbar, isFullScreen, tableContainerRef, topToolbarRef]);
|
|
67
70
|
|
|
68
71
|
const createModalOpen = createDisplayMode === 'modal' && creatingRow;
|
|
69
72
|
const editModalOpen = editDisplayMode === 'modal' && editingRow;
|
|
@@ -76,33 +79,26 @@ export const MRT_TableContainer = <TData extends MRT_RowData>({
|
|
|
76
79
|
ref={(node: HTMLDivElement) => {
|
|
77
80
|
if (node) {
|
|
78
81
|
tableContainerRef.current = node;
|
|
79
|
-
if (tableContainerProps?.ref) {
|
|
80
|
-
//@ts-expect-error
|
|
82
|
+
if (tableContainerProps?.ref && typeof tableContainerProps.ref === 'object') {
|
|
81
83
|
tableContainerProps.ref.current = node;
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
86
|
}}
|
|
85
87
|
style={{
|
|
86
|
-
maxHeight: isFullScreen
|
|
87
|
-
? `calc(100vh - ${totalToolbarHeight}px)`
|
|
88
|
-
: undefined,
|
|
88
|
+
maxHeight: isFullScreen ? `calc(100vh - ${totalToolbarHeight}px)` : undefined,
|
|
89
89
|
...tableContainerProps?.style,
|
|
90
90
|
}}
|
|
91
91
|
sx={(theme) => ({
|
|
92
|
-
maxHeight: enableStickyHeader
|
|
93
|
-
? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
|
|
94
|
-
: undefined,
|
|
92
|
+
maxHeight: enableStickyHeader ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)` : undefined,
|
|
95
93
|
maxWidth: '100%',
|
|
96
94
|
overflow: 'auto',
|
|
97
95
|
position: 'relative',
|
|
98
|
-
...(parseFromValuesOrFunc(tableContainerProps?.sx, theme) as
|
|
96
|
+
...(parseFromValuesOrFunc(tableContainerProps?.sx, theme) as CSSObject),
|
|
99
97
|
})}
|
|
100
98
|
>
|
|
101
99
|
{loading ? <MRT_TableLoadingOverlay table={table} /> : null}
|
|
102
100
|
<MRT_Table table={table} />
|
|
103
|
-
{(createModalOpen || editModalOpen) &&
|
|
104
|
-
<MRT_EditRowModal open table={table} />
|
|
105
|
-
)}
|
|
101
|
+
{(createModalOpen || editModalOpen) && <MRT_EditRowModal open table={table} />}
|
|
106
102
|
{enableCellActions && actionCell && <MRT_CellActionMenu table={table} />}
|
|
107
103
|
</TableContainer>
|
|
108
104
|
);
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import { Box } from '@mui/material';
|
|
2
|
-
import { CircularProgress, type CircularProgressProps } from '@mui/material';
|
|
1
|
+
import { Box, CircularProgress, type CircularProgressProps } from '@mui/material';
|
|
3
2
|
import { alpha } from '@mui/material/styles';
|
|
4
3
|
|
|
5
4
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
6
5
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
7
6
|
|
|
8
|
-
export interface MRT_TableLoadingOverlayProps<TData extends MRT_RowData>
|
|
9
|
-
extends CircularProgressProps {
|
|
7
|
+
export interface MRT_TableLoadingOverlayProps<TData extends MRT_RowData> extends CircularProgressProps {
|
|
10
8
|
table: MRT_TableInstance<TData>;
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
|
|
14
12
|
table,
|
|
15
13
|
...rest
|
|
16
|
-
}: MRT_TableLoadingOverlayProps<TData>) => {
|
|
14
|
+
}: MRT_TableLoadingOverlayProps<TData>): JSX.Element => {
|
|
17
15
|
const {
|
|
18
16
|
options: {
|
|
19
17
|
id,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Paper, type PaperProps } from '@mui/material';
|
|
2
|
-
import { useTheme } from '@mui/material/styles';
|
|
2
|
+
import { type CSSObject, useTheme } from '@mui/material/styles';
|
|
3
3
|
|
|
4
4
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
5
5
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
@@ -7,15 +7,14 @@ import { MRT_BottomToolbar } from '../toolbar/MRT_BottomToolbar';
|
|
|
7
7
|
import { MRT_TopToolbar } from '../toolbar/MRT_TopToolbar';
|
|
8
8
|
import { MRT_TableContainer } from './MRT_TableContainer';
|
|
9
9
|
|
|
10
|
-
export interface MRT_TablePaperProps<TData extends MRT_RowData>
|
|
11
|
-
extends PaperProps {
|
|
10
|
+
export interface MRT_TablePaperProps<TData extends MRT_RowData> extends PaperProps {
|
|
12
11
|
table: MRT_TableInstance<TData>;
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
16
15
|
table,
|
|
17
16
|
...rest
|
|
18
|
-
}: MRT_TablePaperProps<TData>) => {
|
|
17
|
+
}: MRT_TablePaperProps<TData>): JSX.Element => {
|
|
19
18
|
const {
|
|
20
19
|
options: {
|
|
21
20
|
enableBottomToolbar,
|
|
@@ -43,8 +42,7 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
|
43
42
|
{...paperProps}
|
|
44
43
|
ref={(ref: HTMLDivElement) => {
|
|
45
44
|
tablePaperRef.current = ref;
|
|
46
|
-
if (paperProps?.ref) {
|
|
47
|
-
//@ts-expect-error
|
|
45
|
+
if (paperProps?.ref && typeof paperProps.ref === 'object') {
|
|
48
46
|
paperProps.ref.current = ref;
|
|
49
47
|
}
|
|
50
48
|
}}
|
|
@@ -72,18 +70,13 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
|
|
72
70
|
backgroundImage: 'unset',
|
|
73
71
|
overflow: 'hidden',
|
|
74
72
|
transition: 'all 100ms ease-in-out',
|
|
75
|
-
...(parseFromValuesOrFunc(paperProps?.sx, theme) as
|
|
73
|
+
...(parseFromValuesOrFunc(paperProps?.sx, theme) as CSSObject),
|
|
76
74
|
})}
|
|
77
75
|
>
|
|
78
|
-
{enableTopToolbar &&
|
|
79
|
-
(parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (
|
|
80
|
-
<MRT_TopToolbar table={table} />
|
|
81
|
-
))}
|
|
76
|
+
{enableTopToolbar && (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? <MRT_TopToolbar table={table} />)}
|
|
82
77
|
<MRT_TableContainer table={table} />
|
|
83
78
|
{enableBottomToolbar &&
|
|
84
|
-
(parseFromValuesOrFunc(renderBottomToolbar, { table }) ??
|
|
85
|
-
<MRT_BottomToolbar table={table} />
|
|
86
|
-
))}
|
|
79
|
+
(parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? <MRT_BottomToolbar table={table} />)}
|
|
87
80
|
</Paper>
|
|
88
81
|
);
|
|
89
82
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Box, type BoxProps, useMediaQuery } from '@mui/material';
|
|
2
|
-
import { alpha } from '@mui/material/styles';
|
|
2
|
+
import { alpha, type CSSObject } from '@mui/material/styles';
|
|
3
3
|
|
|
4
4
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
5
5
|
import { getCommonToolbarStyles } from '../../utils/style.utils';
|
|
@@ -9,15 +9,14 @@ import { MRT_TablePagination } from './MRT_TablePagination';
|
|
|
9
9
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
10
10
|
import { MRT_ToolbarDropZone } from './MRT_ToolbarDropZone';
|
|
11
11
|
|
|
12
|
-
export interface MRT_BottomToolbarProps<TData extends MRT_RowData>
|
|
13
|
-
extends BoxProps {
|
|
12
|
+
export interface MRT_BottomToolbarProps<TData extends MRT_RowData> extends BoxProps {
|
|
14
13
|
table: MRT_TableInstance<TData>;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export const MRT_BottomToolbar = <TData extends MRT_RowData>({
|
|
18
17
|
table,
|
|
19
18
|
...rest
|
|
20
|
-
}: MRT_BottomToolbarProps<TData>) => {
|
|
19
|
+
}: MRT_BottomToolbarProps<TData>): JSX.Element => {
|
|
21
20
|
const {
|
|
22
21
|
options: {
|
|
23
22
|
enablePagination,
|
|
@@ -46,8 +45,7 @@ export const MRT_BottomToolbar = <TData extends MRT_RowData>({
|
|
|
46
45
|
ref={(node: HTMLDivElement) => {
|
|
47
46
|
if (node) {
|
|
48
47
|
bottomToolbarRef.current = node;
|
|
49
|
-
if (toolbarProps?.ref) {
|
|
50
|
-
// @ts-expect-error
|
|
48
|
+
if (toolbarProps?.ref && typeof toolbarProps.ref === 'object') {
|
|
51
49
|
toolbarProps.ref.current = node;
|
|
52
50
|
}
|
|
53
51
|
}
|
|
@@ -59,19 +57,14 @@ export const MRT_BottomToolbar = <TData extends MRT_RowData>({
|
|
|
59
57
|
left: 0,
|
|
60
58
|
position: isFullScreen ? 'fixed' : 'relative',
|
|
61
59
|
right: 0,
|
|
62
|
-
...(parseFromValuesOrFunc(toolbarProps?.sx, theme) as
|
|
60
|
+
...(parseFromValuesOrFunc(toolbarProps?.sx, theme) as CSSObject),
|
|
63
61
|
})}
|
|
64
62
|
>
|
|
65
63
|
<MRT_LinearProgressBar isTopToolbar={false} table={table} />
|
|
66
64
|
{positionToolbarAlertBanner === 'bottom' && (
|
|
67
|
-
<MRT_ToolbarAlertBanner
|
|
68
|
-
stackAlertBanner={stackAlertBanner}
|
|
69
|
-
table={table}
|
|
70
|
-
/>
|
|
71
|
-
)}
|
|
72
|
-
{['both', 'bottom'].includes(positionToolbarDropZone ?? '') && (
|
|
73
|
-
<MRT_ToolbarDropZone table={table} />
|
|
65
|
+
<MRT_ToolbarAlertBanner stackAlertBanner={stackAlertBanner} table={table} />
|
|
74
66
|
)}
|
|
67
|
+
{['both', 'bottom'].includes(positionToolbarDropZone ?? '') && <MRT_ToolbarDropZone table={table} />}
|
|
75
68
|
<Box
|
|
76
69
|
sx={{
|
|
77
70
|
alignItems: 'center',
|
|
@@ -82,11 +75,7 @@ export const MRT_BottomToolbar = <TData extends MRT_RowData>({
|
|
|
82
75
|
width: '100%',
|
|
83
76
|
}}
|
|
84
77
|
>
|
|
85
|
-
{renderBottomToolbarCustomActions ? (
|
|
86
|
-
renderBottomToolbarCustomActions({ table })
|
|
87
|
-
) : (
|
|
88
|
-
<span />
|
|
89
|
-
)}
|
|
78
|
+
{renderBottomToolbarCustomActions ? renderBottomToolbarCustomActions({ table }) : <span />}
|
|
90
79
|
<Box
|
|
91
80
|
sx={{
|
|
92
81
|
display: 'flex',
|
|
@@ -96,10 +85,9 @@ export const MRT_BottomToolbar = <TData extends MRT_RowData>({
|
|
|
96
85
|
top: 0,
|
|
97
86
|
}}
|
|
98
87
|
>
|
|
99
|
-
{enablePagination &&
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
)}
|
|
88
|
+
{enablePagination && ['both', 'bottom'].includes(positionPagination ?? '') && (
|
|
89
|
+
<MRT_TablePagination position="bottom" table={table} />
|
|
90
|
+
)}
|
|
103
91
|
</Box>
|
|
104
92
|
</Box>
|
|
105
93
|
</Box>
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { Collapse } from '@mui/material';
|
|
2
|
-
import { LinearProgress, type LinearProgressProps } from '@mui/material';
|
|
1
|
+
import { Collapse, LinearProgress, type LinearProgressProps } from '@mui/material';
|
|
3
2
|
|
|
4
3
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
5
4
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
6
5
|
|
|
7
|
-
export interface MRT_LinearProgressBarProps<TData extends MRT_RowData>
|
|
8
|
-
extends LinearProgressProps {
|
|
6
|
+
export interface MRT_LinearProgressBarProps<TData extends MRT_RowData> extends LinearProgressProps {
|
|
9
7
|
isTopToolbar: boolean;
|
|
10
8
|
table: MRT_TableInstance<TData>;
|
|
11
9
|
}
|
|
@@ -14,7 +12,7 @@ export const MRT_LinearProgressBar = <TData extends MRT_RowData>({
|
|
|
14
12
|
isTopToolbar,
|
|
15
13
|
table,
|
|
16
14
|
...rest
|
|
17
|
-
}: MRT_LinearProgressBarProps<TData>) => {
|
|
15
|
+
}: MRT_LinearProgressBarProps<TData>): JSX.Element => {
|
|
18
16
|
const {
|
|
19
17
|
options: { muiLinearProgressProps },
|
|
20
18
|
} = table;
|
|
@@ -40,12 +38,7 @@ export const MRT_LinearProgressBar = <TData extends MRT_RowData>({
|
|
|
40
38
|
}}
|
|
41
39
|
unmountOnExit
|
|
42
40
|
>
|
|
43
|
-
<LinearProgress
|
|
44
|
-
aria-busy="true"
|
|
45
|
-
aria-label="Loading"
|
|
46
|
-
sx={{ position: 'relative' }}
|
|
47
|
-
{...linearProgressProps}
|
|
48
|
-
/>
|
|
41
|
+
<LinearProgress aria-busy="true" aria-label="Loading" sx={{ position: 'relative' }} {...linearProgressProps} />
|
|
49
42
|
</Collapse>
|
|
50
43
|
);
|
|
51
44
|
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import {
|
|
2
|
+
Box,
|
|
3
|
+
IconButton,
|
|
4
|
+
InputLabel,
|
|
5
|
+
MenuItem,
|
|
6
|
+
Pagination,
|
|
7
|
+
PaginationItem,
|
|
8
|
+
type PaginationProps,
|
|
9
|
+
Select,
|
|
10
|
+
type SelectProps,
|
|
11
|
+
Tooltip,
|
|
12
|
+
Typography,
|
|
13
|
+
useMediaQuery,
|
|
14
|
+
} from '@mui/material';
|
|
10
15
|
import { useTheme } from '@mui/material/styles';
|
|
11
16
|
|
|
12
17
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
@@ -15,15 +20,14 @@ import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
|
15
20
|
|
|
16
21
|
const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
|
|
17
22
|
|
|
18
|
-
export interface MRT_TablePaginationProps<TData extends MRT_RowData>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
> {
|
|
23
|
+
export interface MRT_TablePaginationProps<TData extends MRT_RowData> extends Partial<
|
|
24
|
+
PaginationProps & {
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
rowsPerPageOptions?: number[] | { label: string; value: number }[];
|
|
27
|
+
SelectProps?: Partial<SelectProps>;
|
|
28
|
+
showRowsPerPage?: boolean;
|
|
29
|
+
}
|
|
30
|
+
> {
|
|
27
31
|
position?: 'bottom' | 'top';
|
|
28
32
|
table: MRT_TableInstance<TData>;
|
|
29
33
|
}
|
|
@@ -32,7 +36,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
|
32
36
|
position = 'bottom',
|
|
33
37
|
table,
|
|
34
38
|
...rest
|
|
35
|
-
}: MRT_TablePaginationProps<TData>) => {
|
|
39
|
+
}: MRT_TablePaginationProps<TData>): JSX.Element => {
|
|
36
40
|
const theme = useTheme();
|
|
37
41
|
const isMobile = useMediaQuery('(max-width: 720px)');
|
|
38
42
|
|
|
@@ -92,10 +96,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
|
92
96
|
gap: '8px',
|
|
93
97
|
justifyContent: { md: 'space-between', sm: 'center' },
|
|
94
98
|
justifySelf: 'flex-end',
|
|
95
|
-
mt:
|
|
96
|
-
position === 'top' && enableToolbarInternalActions
|
|
97
|
-
? '3rem'
|
|
98
|
-
: undefined,
|
|
99
|
+
mt: position === 'top' && enableToolbarInternalActions ? '3rem' : undefined,
|
|
99
100
|
position: 'relative',
|
|
100
101
|
px: '8px',
|
|
101
102
|
py: '12px',
|
|
@@ -116,9 +117,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
|
116
117
|
}}
|
|
117
118
|
label={localization.rowsPerPage}
|
|
118
119
|
MenuProps={{ disableScrollLock: true }}
|
|
119
|
-
onChange={(event) =>
|
|
120
|
-
table.setPageSize(+(event.target.value as any))
|
|
121
|
-
}
|
|
120
|
+
onChange={(event) => table.setPageSize(Number(event.target.value))}
|
|
122
121
|
sx={{ mb: 0 }}
|
|
123
122
|
value={pageSize}
|
|
124
123
|
variant="standard"
|
|
@@ -126,8 +125,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
|
126
125
|
>
|
|
127
126
|
{rowsPerPageOptions.map((option) => {
|
|
128
127
|
const value = typeof option !== 'number' ? option.value : option;
|
|
129
|
-
const label =
|
|
130
|
-
typeof option !== 'number' ? option.label : `${option}`;
|
|
128
|
+
const label = typeof option !== 'number' ? option.label : `${option}`;
|
|
131
129
|
return (
|
|
132
130
|
SelectProps?.children ??
|
|
133
131
|
(SelectProps?.native ? (
|
|
@@ -167,21 +165,16 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
|
|
|
167
165
|
/>
|
|
168
166
|
) : paginationDisplayMode === 'default' ? (
|
|
169
167
|
<>
|
|
170
|
-
<Typography
|
|
171
|
-
|
|
172
|
-
component="span"
|
|
173
|
-
sx={{ m: '0 4px', minWidth: '8ch' }}
|
|
174
|
-
variant="body2"
|
|
175
|
-
>{`${
|
|
176
|
-
lastRowIndex === 0
|
|
177
|
-
? 0
|
|
178
|
-
: (firstRowIndex + 1).toLocaleString(localization.language)
|
|
168
|
+
<Typography align="center" component="span" sx={{ m: '0 4px', minWidth: '8ch' }} variant="body2">{`${
|
|
169
|
+
lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString(localization.language)
|
|
179
170
|
}-${lastRowIndex.toLocaleString(localization.language)} ${
|
|
180
171
|
localization.of
|
|
181
172
|
} ${totalRowCount.toLocaleString(localization.language)}`}</Typography>
|
|
182
|
-
<Box
|
|
183
|
-
|
|
184
|
-
|
|
173
|
+
<Box
|
|
174
|
+
sx={{
|
|
175
|
+
gap: 'xs',
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
185
178
|
{showFirstButton && (
|
|
186
179
|
<Tooltip {...tooltipProps} title={localization.goToFirstPage}>
|
|
187
180
|
<span>
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { Alert, type AlertProps } from '@mui/material';
|
|
2
|
-
import {
|
|
3
|
-
import { Box } from '@mui/material';
|
|
4
|
-
import { Button } from '@mui/material';
|
|
5
|
-
import { Chip } from '@mui/material';
|
|
6
|
-
import { Collapse } from '@mui/material';
|
|
7
|
-
import { Stack } from '@mui/material';
|
|
1
|
+
import { Alert, type AlertProps, AlertTitle, Box, Button, Chip, Collapse, Stack } from '@mui/material';
|
|
2
|
+
import { type CSSObject } from '@mui/material/styles';
|
|
8
3
|
import { Fragment, useMemo } from 'react';
|
|
9
4
|
|
|
10
5
|
import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
|
@@ -12,8 +7,7 @@ import { getMRT_SelectAllHandler } from '../../utils/row.utils';
|
|
|
12
7
|
import { parseFromValuesOrFunc } from '../../utils/utils';
|
|
13
8
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
14
9
|
|
|
15
|
-
export interface MRT_ToolbarAlertBannerProps<TData extends MRT_RowData>
|
|
16
|
-
extends AlertProps {
|
|
10
|
+
export interface MRT_ToolbarAlertBannerProps<TData extends MRT_RowData> extends AlertProps {
|
|
17
11
|
stackAlertBanner?: boolean;
|
|
18
12
|
table: MRT_TableInstance<TData>;
|
|
19
13
|
}
|
|
@@ -22,7 +16,7 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
|
22
16
|
stackAlertBanner,
|
|
23
17
|
table,
|
|
24
18
|
...rest
|
|
25
|
-
}: MRT_ToolbarAlertBannerProps<TData>) => {
|
|
19
|
+
}: MRT_ToolbarAlertBannerProps<TData>): JSX.Element => {
|
|
26
20
|
const {
|
|
27
21
|
getCoreRowModel,
|
|
28
22
|
getFilteredSelectedRowModel,
|
|
@@ -56,33 +50,23 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
|
56
50
|
const filteredRowCount = getFilteredSelectedRowModel().rows.length;
|
|
57
51
|
|
|
58
52
|
const selectedRowCount = useMemo(
|
|
59
|
-
() =>
|
|
60
|
-
|
|
61
|
-
? Object.values(rowSelection).filter(Boolean).length
|
|
62
|
-
: filteredRowCount,
|
|
63
|
-
[rowSelection, totalRowCount, manualPagination, filteredRowCount],
|
|
53
|
+
() => (manualPagination ? Object.values(rowSelection).filter(Boolean).length : filteredRowCount),
|
|
54
|
+
[rowSelection, manualPagination, filteredRowCount],
|
|
64
55
|
);
|
|
65
56
|
const selectedAlert =
|
|
66
57
|
selectedRowCount > 0 ? (
|
|
67
58
|
<Stack
|
|
68
59
|
direction="row"
|
|
69
60
|
sx={{
|
|
70
|
-
alignItems:
|
|
71
|
-
gap:
|
|
72
|
-
}}
|
|
61
|
+
alignItems: 'center',
|
|
62
|
+
gap: '16px',
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
73
65
|
{localization.selectedCountOfRowCountRowsSelected
|
|
74
|
-
?.replace(
|
|
75
|
-
|
|
76
|
-
selectedRowCount.toLocaleString(localization.language),
|
|
77
|
-
)
|
|
78
|
-
?.replace(
|
|
79
|
-
'{rowCount}',
|
|
80
|
-
totalRowCount.toLocaleString(localization.language),
|
|
81
|
-
)}
|
|
66
|
+
?.replace('{selectedCount}', selectedRowCount.toLocaleString(localization.language))
|
|
67
|
+
?.replace('{rowCount}', totalRowCount.toLocaleString(localization.language))}
|
|
82
68
|
<Button
|
|
83
|
-
onClick={(event) =>
|
|
84
|
-
getMRT_SelectAllHandler({ table })(event, false, true)
|
|
85
|
-
}
|
|
69
|
+
onClick={(event) => getMRT_SelectAllHandler({ table })(event, false, true)}
|
|
86
70
|
size="small"
|
|
87
71
|
sx={{ p: '2px' }}
|
|
88
72
|
>
|
|
@@ -109,36 +93,27 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
|
109
93
|
) : null;
|
|
110
94
|
|
|
111
95
|
return (
|
|
112
|
-
<Collapse
|
|
113
|
-
in={showAlertBanner || !!selectedAlert || !!groupedAlert}
|
|
114
|
-
timeout={stackAlertBanner ? 200 : 0}
|
|
115
|
-
>
|
|
96
|
+
<Collapse in={showAlertBanner || !!selectedAlert || !!groupedAlert} timeout={stackAlertBanner ? 200 : 0}>
|
|
116
97
|
<Alert
|
|
117
98
|
color="info"
|
|
118
99
|
icon={false}
|
|
119
100
|
{...alertProps}
|
|
120
101
|
sx={(theme) => ({
|
|
121
102
|
'& .MuiAlert-message': {
|
|
122
|
-
maxWidth: `calc(${
|
|
123
|
-
tablePaperRef.current?.clientWidth ?? 360
|
|
124
|
-
}px - 1rem)`,
|
|
103
|
+
maxWidth: `calc(${tablePaperRef.current?.clientWidth ?? 360}px - 1rem)`,
|
|
125
104
|
width: '100%',
|
|
126
105
|
},
|
|
127
106
|
borderRadius: 0,
|
|
128
107
|
fontSize: '1rem',
|
|
129
108
|
left: 0,
|
|
130
|
-
mb: stackAlertBanner
|
|
131
|
-
? 0
|
|
132
|
-
: positionToolbarAlertBanner === 'bottom'
|
|
133
|
-
? '-1rem'
|
|
134
|
-
: undefined,
|
|
109
|
+
mb: stackAlertBanner ? 0 : positionToolbarAlertBanner === 'bottom' ? '-1rem' : undefined,
|
|
135
110
|
p: 0,
|
|
136
111
|
position: 'relative',
|
|
137
112
|
right: 0,
|
|
138
113
|
top: 0,
|
|
139
114
|
width: '100%',
|
|
140
115
|
zIndex: 2,
|
|
141
|
-
...(parseFromValuesOrFunc(alertProps?.sx, theme) as
|
|
116
|
+
...(parseFromValuesOrFunc(alertProps?.sx, theme) as CSSObject),
|
|
142
117
|
})}
|
|
143
118
|
>
|
|
144
119
|
{renderToolbarAlertBannerContent?.({
|
|
@@ -161,15 +136,11 @@ export const MRT_ToolbarAlertBanner = <TData extends MRT_RowData>({
|
|
|
161
136
|
}}
|
|
162
137
|
>
|
|
163
138
|
{alertProps?.children}
|
|
164
|
-
{alertProps?.children && (selectedAlert || groupedAlert) &&
|
|
165
|
-
<br />
|
|
166
|
-
)}
|
|
139
|
+
{alertProps?.children && (selectedAlert || groupedAlert) && <br />}
|
|
167
140
|
<Box sx={{ display: 'flex' }}>
|
|
168
|
-
{enableRowSelection &&
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
<MRT_SelectCheckbox table={table} />
|
|
172
|
-
)}{' '}
|
|
141
|
+
{enableRowSelection && enableSelectAll && positionToolbarAlertBanner === 'head-overlay' && (
|
|
142
|
+
<MRT_SelectCheckbox table={table} />
|
|
143
|
+
)}{' '}
|
|
173
144
|
{selectedAlert}
|
|
174
145
|
</Box>
|
|
175
146
|
{selectedAlert && groupedAlert && <br />}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fireEvent, render } from '@testing-library/react';
|
|
2
|
-
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { describe, expect, test, vi } from 'vitest';
|
|
3
3
|
|
|
4
4
|
import { type MRT_ColumnDef } from '../../types';
|
|
5
5
|
import { MaterialReactTable } from '../MaterialReactTable';
|
|
@@ -21,22 +21,38 @@ const columns = (): MRT_ColumnDef<Person>[] => [
|
|
|
21
21
|
|
|
22
22
|
describe('grouping drop zone', () => {
|
|
23
23
|
test('dropping a column on it groups by that column', () => {
|
|
24
|
-
const { container } = render(
|
|
25
|
-
<MaterialReactTable columns={columns()} data={data} enableGrouping />,
|
|
26
|
-
);
|
|
24
|
+
const { container } = render(<MaterialReactTable columns={columns()} data={data} enableGrouping />);
|
|
27
25
|
|
|
28
|
-
const handle = container.querySelector(
|
|
29
|
-
'thead button[aria-label="Move"]',
|
|
30
|
-
) as HTMLElement;
|
|
26
|
+
const handle = container.querySelector('thead button[aria-label="Move"]') as HTMLElement;
|
|
31
27
|
|
|
32
28
|
fireEvent.dragStart(handle, {
|
|
33
29
|
dataTransfer: { setDragImage: () => {} },
|
|
34
30
|
});
|
|
35
|
-
fireEvent.dragEnter(
|
|
36
|
-
container.querySelector('[class*="ToolbarDropZone"]') as HTMLElement,
|
|
37
|
-
);
|
|
31
|
+
fireEvent.dragEnter(container.querySelector('[class*="ToolbarDropZone"]') as HTMLElement);
|
|
38
32
|
fireEvent.dragEnd(handle);
|
|
39
33
|
|
|
40
34
|
expect(container.textContent).toContain('Grouped by');
|
|
41
35
|
});
|
|
42
36
|
});
|
|
37
|
+
|
|
38
|
+
describe('controlled drop zone', () => {
|
|
39
|
+
test('does not call onShowToolbarDropZoneChange when the table re-renders', () => {
|
|
40
|
+
const onShowToolbarDropZoneChange = vi.fn();
|
|
41
|
+
const table = (isLoading: boolean) => (
|
|
42
|
+
<MaterialReactTable
|
|
43
|
+
columns={columns()}
|
|
44
|
+
data={data}
|
|
45
|
+
enableGrouping
|
|
46
|
+
onShowToolbarDropZoneChange={(showToolbarDropZone) => onShowToolbarDropZoneChange(showToolbarDropZone)}
|
|
47
|
+
state={{ isLoading, showToolbarDropZone: false }}
|
|
48
|
+
/>
|
|
49
|
+
);
|
|
50
|
+
const { rerender } = render(table(false));
|
|
51
|
+
onShowToolbarDropZoneChange.mockClear();
|
|
52
|
+
|
|
53
|
+
rerender(table(true));
|
|
54
|
+
rerender(table(false));
|
|
55
|
+
|
|
56
|
+
expect(onShowToolbarDropZoneChange).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
});
|