material-react-table 0.8.12 → 0.8.13
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/buttons/MRT_GrabHandleButton.d.ts +8 -0
- package/dist/material-react-table.cjs.development.js +1717 -1665
- 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 +95 -43
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -0
- package/dist/table/MRT_TableRoot.d.ts +0 -1
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/buttons/MRT_ColumnPinningButtons.tsx +1 -1
- package/src/{head/MRT_TableHeadCellGrabHandle.tsx → buttons/MRT_GrabHandleButton.tsx} +2 -3
- package/src/head/MRT_DraggableTableHeadCell.tsx +1 -2
- package/src/head/MRT_TableHeadCell.tsx +2 -3
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +68 -24
- package/dist/head/MRT_TableHeadCellGrabHandle.d.ts +0 -9
package/dist/utils.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export declare const createGroup: <D extends Record<string, any> = {}>(table: Ta
|
|
|
7
7
|
export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterFns: {
|
|
8
8
|
[key: string]: MRT_FilterFn<{}>;
|
|
9
9
|
}) => ColumnDef<D>;
|
|
10
|
-
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "footer" | "columns" | "filterFn" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "enablePinning" | "enableColumnFilter" | "enableGlobalFilter" | "sortingFn" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "invertSorting" | "sortUndefined" | "aggregationFn" | "aggregatedCell" | "enableGrouping" | "enableResizing" | "size" | "minSize" | "maxSize" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableColumnOrdering" | "enableEditing" | "enabledColumnFilterOptions" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChange" | "onColumnFilterValueChange"> & {
|
|
10
|
+
export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "accessorFN" | "footer" | "columns" | "filterFn" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "enablePinning" | "enableColumnFilter" | "enableGlobalFilter" | "sortingFn" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "invertSorting" | "sortUndefined" | "aggregationFn" | "aggregatedCell" | "enableGrouping" | "enableResizing" | "size" | "minSize" | "maxSize" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableColumnOrdering" | "enableEditing" | "enabledColumnFilterOptions" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChange" | "onColumnFilterValueChange"> & {
|
|
11
11
|
header?: string | undefined;
|
|
12
12
|
}) => ColumnDef<D>;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.8.
|
|
2
|
+
"version": "0.8.13",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -23,7 +23,7 @@ export const MRT_ColumnPinningButtons: FC<Props> = ({
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<Box sx={{ mr: '
|
|
26
|
+
<Box sx={{ mr: '4px' }}>
|
|
27
27
|
{column.getIsPinned() ? (
|
|
28
28
|
<Tooltip arrow title={localization.unpin}>
|
|
29
29
|
<IconButton onClick={() => handlePinColumn(false)} size="small">
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { IconButton, Tooltip } from '@mui/material';
|
|
2
2
|
import React, { FC, forwardRef, Ref } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
|
-
header: MRT_Header;
|
|
7
6
|
ref: Ref<HTMLButtonElement>;
|
|
8
7
|
tableInstance: MRT_TableInstance;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export const
|
|
10
|
+
export const MRT_GrabHandleButton: FC<Props> = forwardRef(
|
|
12
11
|
({ tableInstance }, ref) => {
|
|
13
12
|
const {
|
|
14
13
|
options: {
|
|
@@ -24,11 +24,10 @@ export const MRT_DraggableTableHeadCell: FC<Props> = ({
|
|
|
24
24
|
if (movingHeader.column.getCanPin()) {
|
|
25
25
|
movingHeader.column.pin(receivingHeader.column.getIsPinned());
|
|
26
26
|
}
|
|
27
|
-
const { index: currentIndex } = movingHeader;
|
|
28
27
|
columnOrder.splice(
|
|
29
28
|
receivingHeader.index,
|
|
30
29
|
0,
|
|
31
|
-
columnOrder.splice(
|
|
30
|
+
columnOrder.splice(movingHeader.index, 1)[0],
|
|
32
31
|
);
|
|
33
32
|
setColumnOrder([...columnOrder]);
|
|
34
33
|
};
|
|
@@ -2,7 +2,7 @@ import React, { FC, ReactNode, Ref } from 'react';
|
|
|
2
2
|
import { Box, TableCell, Theme, alpha, lighten } from '@mui/material';
|
|
3
3
|
import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer';
|
|
4
4
|
import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel';
|
|
5
|
-
import {
|
|
5
|
+
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
6
6
|
import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle';
|
|
7
7
|
import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel';
|
|
8
8
|
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
@@ -190,8 +190,7 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
190
190
|
((enableColumnOrdering &&
|
|
191
191
|
columnDef.enableColumnOrdering !== false) ||
|
|
192
192
|
(enableGrouping && columnDef.enableGrouping !== false)) && (
|
|
193
|
-
<
|
|
194
|
-
header={header}
|
|
193
|
+
<MRT_GrabHandleButton
|
|
195
194
|
ref={dragRef as Ref<HTMLButtonElement>}
|
|
196
195
|
tableInstance={tableInstance}
|
|
197
196
|
/>
|
|
@@ -1,28 +1,58 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, { FC, Ref } from 'react';
|
|
2
|
+
import { useDrag, useDrop } from 'react-dnd';
|
|
3
|
+
import { Box, FormControlLabel, MenuItem, Switch } from '@mui/material';
|
|
3
4
|
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
|
5
|
+
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
|
4
6
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
9
|
+
allColumns: MRT_Column[];
|
|
7
10
|
column: MRT_Column;
|
|
8
11
|
isSubMenu?: boolean;
|
|
9
12
|
tableInstance: MRT_TableInstance;
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
16
|
+
allColumns,
|
|
13
17
|
column,
|
|
14
18
|
isSubMenu,
|
|
15
19
|
tableInstance,
|
|
16
20
|
}) => {
|
|
17
21
|
const {
|
|
18
22
|
getState,
|
|
19
|
-
options: { onToggleColumnVisibility },
|
|
23
|
+
options: { enableColumnOrdering, onToggleColumnVisibility },
|
|
24
|
+
setColumnOrder,
|
|
20
25
|
} = tableInstance;
|
|
21
26
|
|
|
22
|
-
const { columnVisibility } = getState();
|
|
27
|
+
const { columnOrder, columnVisibility } = getState();
|
|
23
28
|
|
|
24
29
|
const { columnDef, columnDefType } = column;
|
|
25
30
|
|
|
31
|
+
const reorder = (movingColumn: MRT_Column, receivingColumn: MRT_Column) => {
|
|
32
|
+
if (movingColumn.getCanPin()) {
|
|
33
|
+
movingColumn.pin(receivingColumn.getIsPinned());
|
|
34
|
+
}
|
|
35
|
+
columnOrder.splice(
|
|
36
|
+
columnOrder.indexOf(receivingColumn.id),
|
|
37
|
+
0,
|
|
38
|
+
columnOrder.splice(columnOrder.indexOf(movingColumn.id), 1)[0],
|
|
39
|
+
);
|
|
40
|
+
setColumnOrder([...columnOrder]);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const [, dropRef] = useDrop({
|
|
44
|
+
accept: 'column',
|
|
45
|
+
drop: (movingColumn: MRT_Column) => reorder(movingColumn, column),
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const [, dragRef, previewRef] = useDrag({
|
|
49
|
+
collect: (monitor) => ({
|
|
50
|
+
isDragging: monitor.isDragging(),
|
|
51
|
+
}),
|
|
52
|
+
item: () => column,
|
|
53
|
+
type: 'column',
|
|
54
|
+
});
|
|
55
|
+
|
|
26
56
|
const switchChecked =
|
|
27
57
|
(columnDefType !== 'group' && column.getIsVisible()) ||
|
|
28
58
|
(columnDefType === 'group' &&
|
|
@@ -46,6 +76,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
46
76
|
return (
|
|
47
77
|
<>
|
|
48
78
|
<MenuItem
|
|
79
|
+
ref={columnDefType === 'data' ? dropRef : undefined}
|
|
49
80
|
sx={{
|
|
50
81
|
alignItems: 'center',
|
|
51
82
|
justifyContent: 'flex-start',
|
|
@@ -54,30 +85,43 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
54
85
|
py: '6px',
|
|
55
86
|
}}
|
|
56
87
|
>
|
|
57
|
-
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
88
|
+
<Box ref={previewRef} sx={{ display: 'flex', flexWrap: 'nowrap' }}>
|
|
89
|
+
{columnDefType !== 'group' &&
|
|
90
|
+
enableColumnOrdering &&
|
|
91
|
+
columnDef.enableColumnOrdering !== false &&
|
|
92
|
+
!allColumns.some((col) => col.columnDefType === 'group') && (
|
|
93
|
+
<MRT_GrabHandleButton
|
|
94
|
+
ref={dragRef as Ref<HTMLButtonElement>}
|
|
95
|
+
tableInstance={tableInstance}
|
|
96
|
+
/>
|
|
97
|
+
)}
|
|
98
|
+
{!isSubMenu && column.getCanPin() && (
|
|
99
|
+
<MRT_ColumnPinningButtons
|
|
100
|
+
column={column}
|
|
101
|
+
tableInstance={tableInstance}
|
|
102
|
+
/>
|
|
103
|
+
)}
|
|
104
|
+
<FormControlLabel
|
|
105
|
+
componentsProps={{
|
|
106
|
+
typography: {
|
|
107
|
+
sx: {
|
|
108
|
+
mb: 0,
|
|
109
|
+
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
|
110
|
+
},
|
|
69
111
|
},
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
112
|
+
}}
|
|
113
|
+
checked={switchChecked}
|
|
114
|
+
control={<Switch />}
|
|
115
|
+
disabled={(isSubMenu && switchChecked) || !column.getCanHide()}
|
|
116
|
+
label={columnDef.header}
|
|
117
|
+
onChange={() => handleToggleColumnHidden(column)}
|
|
118
|
+
sx={{ ml: '4px' }}
|
|
119
|
+
/>
|
|
120
|
+
</Box>
|
|
78
121
|
</MenuItem>
|
|
79
122
|
{column.columns?.map((c: MRT_Column, i) => (
|
|
80
123
|
<MRT_ShowHideColumnsMenuItems
|
|
124
|
+
allColumns={allColumns}
|
|
81
125
|
key={`${i}-${c.id}`}
|
|
82
126
|
column={c}
|
|
83
127
|
isSubMenu={isSubMenu}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { FC, Ref } from 'react';
|
|
2
|
-
import { MRT_Header, MRT_TableInstance } from '..';
|
|
3
|
-
interface Props {
|
|
4
|
-
header: MRT_Header;
|
|
5
|
-
ref: Ref<HTMLButtonElement>;
|
|
6
|
-
tableInstance: MRT_TableInstance;
|
|
7
|
-
}
|
|
8
|
-
export declare const MRT_TableHeadCellGrabHandle: FC<Props>;
|
|
9
|
-
export {};
|