material-react-table 0.38.1 → 0.38.4
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/cjs/MaterialReactTable.d.ts +1 -0
- package/dist/cjs/body/MRT_EditRowModal.d.ts +1 -0
- package/dist/cjs/body/MRT_TableBodyRow.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +1 -0
- package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +1 -0
- package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +1 -0
- package/dist/cjs/index.js +55 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +1 -0
- package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +1 -0
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +1 -0
- package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +1 -0
- package/dist/cjs/table/MRT_TableRoot.d.ts +1 -0
- package/dist/esm/MaterialReactTable.d.ts +1 -0
- package/dist/esm/body/MRT_EditRowModal.d.ts +1 -0
- package/dist/esm/body/MRT_TableBodyRow.d.ts +1 -0
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +1 -0
- package/dist/esm/buttons/MRT_EditActionButtons.d.ts +1 -0
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +1 -0
- package/dist/esm/inputs/MRT_EditCellTextField.d.ts +1 -0
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +1 -0
- package/dist/esm/material-react-table.esm.js +55 -24
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +1 -0
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +1 -0
- package/dist/esm/table/MRT_TableRoot.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +1 -0
- package/src/body/MRT_TableBody.tsx +1 -0
- package/src/body/MRT_TableBodyCellValue.tsx +10 -11
- package/src/body/MRT_TableBodyRow.tsx +14 -3
- package/src/buttons/MRT_ExpandAllButton.tsx +5 -3
- package/src/buttons/MRT_GrabHandleButton.tsx +5 -3
- package/src/footer/MRT_TableFooter.tsx +22 -2
- package/src/head/MRT_TableHeadRow.tsx +3 -1
- package/src/inputs/MRT_EditCellTextField.tsx +35 -23
- package/src/table/MRT_TablePaper.tsx +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { MutableRefObject, Dispatch, SetStateAction, ReactNode, DragEvent } from 'react';
|
|
2
3
|
import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, ToolbarProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, PaperProps, TableProps, ChipProps, AlertProps } from '@mui/material';
|
|
3
4
|
import { Row, Table, TableState, ColumnDef, DeepKeys, Column, Header, HeaderGroup, Cell, SortingFn, FilterFn, TableOptions, OnChangeFn } from '@tanstack/react-table';
|
|
@@ -479,6 +480,7 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
|
|
|
479
480
|
enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
|
|
480
481
|
enableRowVirtualization?: boolean;
|
|
481
482
|
enableSelectAll?: boolean;
|
|
483
|
+
enableStickyFooter?: boolean;
|
|
482
484
|
enableStickyHeader?: boolean;
|
|
483
485
|
enableTableFooter?: boolean;
|
|
484
486
|
enableTableHead?: boolean;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.38.
|
|
2
|
+
"version": "0.38.4",
|
|
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.",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"react": "^18.2.0",
|
|
79
79
|
"react-dom": "^18.2.0",
|
|
80
80
|
"react-is": "^18.2.0",
|
|
81
|
-
"rollup": "^2.78.
|
|
81
|
+
"rollup": "^2.78.1",
|
|
82
82
|
"rollup-plugin-dts": "^4.2.2",
|
|
83
83
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
84
84
|
"size-limit": "^8.0.1",
|
|
@@ -488,6 +488,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
|
|
|
488
488
|
enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
|
|
489
489
|
enableRowVirtualization?: boolean;
|
|
490
490
|
enableSelectAll?: boolean;
|
|
491
|
+
enableStickyFooter?: boolean;
|
|
491
492
|
enableStickyHeader?: boolean;
|
|
492
493
|
enableTableFooter?: boolean;
|
|
493
494
|
enableTableHead?: boolean;
|
|
@@ -12,8 +12,8 @@ export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
|
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<>
|
|
15
|
-
{cell.getIsAggregated() &&
|
|
16
|
-
? columnDef.AggregatedCell
|
|
15
|
+
{cell.getIsAggregated() && columnDef.AggregatedCell
|
|
16
|
+
? columnDef.AggregatedCell({
|
|
17
17
|
cell,
|
|
18
18
|
column,
|
|
19
19
|
row,
|
|
@@ -21,15 +21,14 @@ export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
|
|
|
21
21
|
})
|
|
22
22
|
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
23
23
|
? null
|
|
24
|
-
:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
cell.renderValue())}
|
|
24
|
+
: cell.getIsGrouped() && columnDef.GroupedCell
|
|
25
|
+
? columnDef.GroupedCell({
|
|
26
|
+
cell,
|
|
27
|
+
column,
|
|
28
|
+
row,
|
|
29
|
+
table,
|
|
30
|
+
})
|
|
31
|
+
: columnDef?.Cell?.({ cell, column, row, table }) ?? cell.renderValue()}
|
|
33
32
|
</>
|
|
34
33
|
);
|
|
35
34
|
};
|
|
@@ -8,9 +8,15 @@ interface Props {
|
|
|
8
8
|
row: MRT_Row;
|
|
9
9
|
rowIndex: number;
|
|
10
10
|
table: MRT_TableInstance;
|
|
11
|
+
virtualRow?: any;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export const MRT_TableBodyRow: FC<Props> = ({
|
|
14
|
+
export const MRT_TableBodyRow: FC<Props> = ({
|
|
15
|
+
row,
|
|
16
|
+
rowIndex,
|
|
17
|
+
table,
|
|
18
|
+
virtualRow,
|
|
19
|
+
}) => {
|
|
14
20
|
const theme = useTheme();
|
|
15
21
|
const {
|
|
16
22
|
getIsSomeColumnsPinned,
|
|
@@ -31,7 +37,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, table }) => {
|
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
39
|
|
|
34
|
-
const rowRef = useRef<HTMLTableRowElement>(null);
|
|
40
|
+
const rowRef = useRef<HTMLTableRowElement | null>(null);
|
|
35
41
|
|
|
36
42
|
const draggingBorder =
|
|
37
43
|
draggingRow?.id === row.id
|
|
@@ -52,7 +58,12 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, table }) => {
|
|
|
52
58
|
onDragEnter={handleDragEnter}
|
|
53
59
|
hover
|
|
54
60
|
selected={row.getIsSelected()}
|
|
55
|
-
ref={
|
|
61
|
+
ref={(node) => {
|
|
62
|
+
rowRef.current = node;
|
|
63
|
+
if (virtualRow?.measureRef) {
|
|
64
|
+
virtualRow.measureRef = node;
|
|
65
|
+
}
|
|
66
|
+
}}
|
|
56
67
|
{...tableRowProps}
|
|
57
68
|
sx={(theme) => ({
|
|
58
69
|
backgroundColor: lighten(theme.palette.background.default, 0.06),
|
|
@@ -40,12 +40,14 @@ export const MRT_ExpandAllButton: FC<Props> = ({ table }) => {
|
|
|
40
40
|
disabled={!getCanSomeRowsExpand() && !renderDetailPanel}
|
|
41
41
|
onClick={() => toggleAllRowsExpanded(!getIsAllRowsExpanded())}
|
|
42
42
|
{...iconButtonProps}
|
|
43
|
-
sx={{
|
|
43
|
+
sx={(theme) => ({
|
|
44
44
|
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
45
45
|
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
46
46
|
mt: density !== 'compact' ? '-0.25rem' : undefined,
|
|
47
|
-
...iconButtonProps?.sx
|
|
48
|
-
|
|
47
|
+
...(iconButtonProps?.sx instanceof Function
|
|
48
|
+
? iconButtonProps?.sx(theme)
|
|
49
|
+
: (iconButtonProps?.sx as any)),
|
|
50
|
+
})}
|
|
49
51
|
>
|
|
50
52
|
<KeyboardDoubleArrowDownIcon
|
|
51
53
|
style={{
|
|
@@ -37,7 +37,7 @@ export const MRT_GrabHandleButton = <TData extends Record<string, any> = {}>({
|
|
|
37
37
|
onDragEnd={onDragEnd}
|
|
38
38
|
size="small"
|
|
39
39
|
{...iconButtonProps}
|
|
40
|
-
sx={{
|
|
40
|
+
sx={(theme) => ({
|
|
41
41
|
cursor: 'grab',
|
|
42
42
|
m: 0,
|
|
43
43
|
opacity: 0.5,
|
|
@@ -50,8 +50,10 @@ export const MRT_GrabHandleButton = <TData extends Record<string, any> = {}>({
|
|
|
50
50
|
'&:active': {
|
|
51
51
|
cursor: 'grabbing',
|
|
52
52
|
},
|
|
53
|
-
...iconButtonProps?.sx
|
|
54
|
-
|
|
53
|
+
...(iconButtonProps?.sx instanceof Function
|
|
54
|
+
? iconButtonProps?.sx(theme)
|
|
55
|
+
: (iconButtonProps?.sx as any)),
|
|
56
|
+
})}
|
|
55
57
|
>
|
|
56
58
|
<DragHandleIcon />
|
|
57
59
|
</IconButton>
|
|
@@ -10,16 +10,36 @@ interface Props {
|
|
|
10
10
|
export const MRT_TableFooter: FC<Props> = ({ table }) => {
|
|
11
11
|
const {
|
|
12
12
|
getFooterGroups,
|
|
13
|
-
|
|
13
|
+
getState,
|
|
14
|
+
options: { enableStickyFooter, muiTableFooterProps },
|
|
14
15
|
} = table;
|
|
16
|
+
const { isFullScreen } = getState();
|
|
15
17
|
|
|
16
18
|
const tableFooterProps =
|
|
17
19
|
muiTableFooterProps instanceof Function
|
|
18
20
|
? muiTableFooterProps({ table })
|
|
19
21
|
: muiTableFooterProps;
|
|
20
22
|
|
|
23
|
+
const stickFooter =
|
|
24
|
+
(isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
|
25
|
+
|
|
21
26
|
return (
|
|
22
|
-
<TableFooter
|
|
27
|
+
<TableFooter
|
|
28
|
+
{...tableFooterProps}
|
|
29
|
+
sx={(theme) => ({
|
|
30
|
+
position: stickFooter ? 'sticky' : undefined,
|
|
31
|
+
bottom: stickFooter ? 0 : undefined,
|
|
32
|
+
opacity: stickFooter ? 0.95 : undefined,
|
|
33
|
+
outline: stickFooter
|
|
34
|
+
? theme.palette.mode === 'light'
|
|
35
|
+
? `1px solid ${theme.palette.grey[300]}`
|
|
36
|
+
: `1px solid ${theme.palette.grey[700]}`
|
|
37
|
+
: undefined,
|
|
38
|
+
...(tableFooterProps?.sx instanceof Function
|
|
39
|
+
? tableFooterProps?.sx(theme)
|
|
40
|
+
: (tableFooterProps?.sx as any)),
|
|
41
|
+
})}
|
|
42
|
+
>
|
|
23
43
|
{getFooterGroups().map((footerGroup) => (
|
|
24
44
|
<MRT_TableFooterRow
|
|
25
45
|
footerGroup={footerGroup as any}
|
|
@@ -24,7 +24,9 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup, table }) => {
|
|
|
24
24
|
sx={(theme) => ({
|
|
25
25
|
boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`,
|
|
26
26
|
backgroundColor: lighten(theme.palette.background.default, 0.04),
|
|
27
|
-
...(tableRowProps?.sx
|
|
27
|
+
...(tableRowProps?.sx instanceof Function
|
|
28
|
+
? tableRowProps?.sx(theme)
|
|
29
|
+
: (tableRowProps?.sx as any)),
|
|
28
30
|
})}
|
|
29
31
|
>
|
|
30
32
|
{headerGroup.headers.map((header: MRT_Header, index) => (
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
FocusEvent,
|
|
4
|
+
KeyboardEvent,
|
|
5
|
+
MouseEvent,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import { TextField, TextFieldProps } from '@mui/material';
|
|
3
9
|
import type { MRT_Cell, MRT_TableInstance } from '..';
|
|
4
10
|
|
|
@@ -46,31 +52,36 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
|
|
|
46
52
|
...mcTableBodyCellEditTextFieldProps,
|
|
47
53
|
};
|
|
48
54
|
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
setValue(event.target.value);
|
|
52
|
-
if (textFieldProps?.select && editingRow) {
|
|
55
|
+
const saveRow = (newValue: string) => {
|
|
56
|
+
if (editingRow) {
|
|
53
57
|
setEditingRow({
|
|
54
58
|
...editingRow,
|
|
55
|
-
_valuesCache: {
|
|
56
|
-
...editingRow._valuesCache,
|
|
57
|
-
[column.id]: event.target.value,
|
|
58
|
-
},
|
|
59
|
+
_valuesCache: { ...editingRow._valuesCache, [column.id]: newValue },
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
|
|
64
|
+
const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
65
|
+
textFieldProps.onChange?.(event);
|
|
66
|
+
setValue(event.target.value);
|
|
67
|
+
if (textFieldProps?.select) {
|
|
68
|
+
saveRow(event.target.value);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
63
72
|
const handleBlur = (event: FocusEvent<HTMLInputElement>) => {
|
|
64
73
|
textFieldProps.onBlur?.(event);
|
|
65
|
-
|
|
66
|
-
setEditingRow({
|
|
67
|
-
...editingRow,
|
|
68
|
-
_valuesCache: { ...editingRow._valuesCache, [column.id]: value },
|
|
69
|
-
});
|
|
70
|
-
}
|
|
74
|
+
saveRow(value);
|
|
71
75
|
setEditingCell(null);
|
|
72
76
|
};
|
|
73
77
|
|
|
78
|
+
const handleEnterKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
79
|
+
textFieldProps.onKeyDown?.(event);
|
|
80
|
+
if (event.key === 'Enter') {
|
|
81
|
+
editInputRefs.current[column.id]?.blur();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
74
85
|
if (columnDef.Edit) {
|
|
75
86
|
return <>{columnDef.Edit?.({ cell, column, row, table })}</>;
|
|
76
87
|
}
|
|
@@ -79,14 +90,6 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
|
|
|
79
90
|
<TextField
|
|
80
91
|
disabled={columnDef.enableEditing === false}
|
|
81
92
|
fullWidth
|
|
82
|
-
label={showLabel ? column.columnDef.header : undefined}
|
|
83
|
-
margin="none"
|
|
84
|
-
name={column.id}
|
|
85
|
-
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
|
86
|
-
placeholder={columnDef.header}
|
|
87
|
-
value={value}
|
|
88
|
-
variant="standard"
|
|
89
|
-
{...textFieldProps}
|
|
90
93
|
inputRef={(inputRef) => {
|
|
91
94
|
if (inputRef) {
|
|
92
95
|
editInputRefs.current[column.id] = inputRef;
|
|
@@ -95,8 +98,17 @@ export const MRT_EditCellTextField = <TData extends Record<string, any> = {}>({
|
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
}}
|
|
101
|
+
label={showLabel ? column.columnDef.header : undefined}
|
|
102
|
+
margin="none"
|
|
103
|
+
name={column.id}
|
|
104
|
+
onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
|
|
105
|
+
placeholder={columnDef.header}
|
|
106
|
+
value={value}
|
|
107
|
+
variant="standard"
|
|
108
|
+
{...textFieldProps}
|
|
98
109
|
onBlur={handleBlur}
|
|
99
110
|
onChange={handleChange}
|
|
111
|
+
onKeyDown={handleEnterKeyDown}
|
|
100
112
|
/>
|
|
101
113
|
);
|
|
102
114
|
};
|
|
@@ -35,10 +35,12 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
35
35
|
<Paper
|
|
36
36
|
elevation={2}
|
|
37
37
|
{...tablePaperProps}
|
|
38
|
-
sx={{
|
|
38
|
+
sx={(theme) => ({
|
|
39
39
|
transition: 'all 0.2s ease-in-out',
|
|
40
|
-
...tablePaperProps?.sx
|
|
41
|
-
|
|
40
|
+
...(tablePaperProps?.sx instanceof Function
|
|
41
|
+
? tablePaperProps?.sx(theme)
|
|
42
|
+
: (tablePaperProps?.sx as any)),
|
|
43
|
+
})}
|
|
42
44
|
style={{
|
|
43
45
|
...tablePaperProps?.style,
|
|
44
46
|
height: isFullScreen ? '100vh' : undefined,
|