material-react-table 1.7.2 → 1.7.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/index.js +33 -42
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +6 -0
- package/dist/cjs/types/column.utils.d.ts +4 -2
- package/dist/cjs/types/icons.d.ts +0 -1
- package/dist/esm/material-react-table.esm.js +33 -41
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +6 -0
- package/dist/esm/types/column.utils.d.ts +4 -2
- package/dist/esm/types/icons.d.ts +0 -1
- package/dist/index.d.ts +6 -1
- package/package.json +12 -13
- package/src/MaterialReactTable.tsx +6 -0
- package/src/body/MRT_TableBodyCell.tsx +3 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +10 -8
- package/src/buttons/MRT_ExpandButton.tsx +10 -8
- package/src/column.utils.ts +16 -13
- package/src/head/MRT_TableHeadCell.tsx +1 -0
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +1 -1
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +2 -5
- package/src/icons.ts +0 -3
- package/src/table/MRT_Table.tsx +5 -4
@@ -243,6 +243,12 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<ColumnD
|
|
243
243
|
header: MRT_Header<TData>;
|
244
244
|
table: MRT_TableInstance<TData>;
|
245
245
|
}) => ReactNode);
|
246
|
+
PlaceholderCell?: (props: {
|
247
|
+
cell: MRT_Cell<TData>;
|
248
|
+
column: MRT_Column<TData>;
|
249
|
+
row: MRT_Row<TData>;
|
250
|
+
table: MRT_TableInstance<TData>;
|
251
|
+
}) => ReactNode;
|
246
252
|
/**
|
247
253
|
* Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
|
248
254
|
* Specify a function here to point to the correct property in the data object.
|
@@ -4,7 +4,7 @@ import { MRT_FilterFns } from './filterFns';
|
|
4
4
|
import { MRT_SortingFns } from './sortingFns';
|
5
5
|
import type { TableCellProps } from '@mui/material/TableCell';
|
6
6
|
import type { Theme } from '@mui/material/styles';
|
7
|
-
import type { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption, MRT_TableInstance } from '.';
|
7
|
+
import type { MaterialReactTableProps, MRT_Column, MRT_ColumnDef, MRT_DefinedColumnDef, MRT_DisplayColumnIds, MRT_FilterOption, MRT_Header, MRT_TableInstance } from '.';
|
8
8
|
export declare const getColumnId: <TData extends Record<string, any> = {}>(columnDef: MRT_ColumnDef<TData>) => string;
|
9
9
|
export declare const getAllLeafColumnDefs: <TData extends Record<string, any> = {}>(columns: MRT_ColumnDef<TData>[]) => MRT_ColumnDef<TData>[];
|
10
10
|
export declare const prepareColumns: <TData extends Record<string, any> = {}>({ aggregationFns, columnDefs, columnFilterFns, defaultDisplayColumn, filterFns, sortingFns, }: {
|
@@ -111,8 +111,9 @@ export declare const getIsLastColumn: (column: MRT_Column, table: MRT_TableInsta
|
|
111
111
|
export declare const getIsLastLeftPinnedColumn: (table: MRT_TableInstance, column: MRT_Column) => boolean;
|
112
112
|
export declare const getIsFirstRightPinnedColumn: (column: MRT_Column) => boolean;
|
113
113
|
export declare const getTotalRight: (table: MRT_TableInstance, column: MRT_Column) => number;
|
114
|
-
export declare const getCommonCellStyles: ({ column, table, tableCellProps, theme, }: {
|
114
|
+
export declare const getCommonCellStyles: ({ column, header, table, tableCellProps, theme, }: {
|
115
115
|
column: MRT_Column;
|
116
|
+
header?: MRT_Header<{}> | undefined;
|
116
117
|
table: MRT_TableInstance;
|
117
118
|
tableCellProps: TableCellProps;
|
118
119
|
theme: Theme;
|
@@ -137,3 +138,4 @@ export declare const MRT_DefaultDisplayColumn: {
|
|
137
138
|
readonly enableResizing: false;
|
138
139
|
readonly enableSorting: false;
|
139
140
|
};
|
141
|
+
export declare const parseCSSVarId: (id: string) => string;
|
package/dist/index.d.ts
CHANGED
@@ -116,7 +116,6 @@ interface MRT_Icons {
|
|
116
116
|
DragHandleIcon: any;
|
117
117
|
DynamicFeedIcon: any;
|
118
118
|
EditIcon: any;
|
119
|
-
ExpandLessIcon: any;
|
120
119
|
ExpandMoreIcon: any;
|
121
120
|
FilterAltIcon: any;
|
122
121
|
FilterListIcon: any;
|
@@ -364,6 +363,12 @@ type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<ColumnDef<TDat
|
|
364
363
|
header: MRT_Header<TData>;
|
365
364
|
table: MRT_TableInstance<TData>;
|
366
365
|
}) => ReactNode);
|
366
|
+
PlaceholderCell?: (props: {
|
367
|
+
cell: MRT_Cell<TData>;
|
368
|
+
column: MRT_Column<TData>;
|
369
|
+
row: MRT_Row<TData>;
|
370
|
+
table: MRT_TableInstance<TData>;
|
371
|
+
}) => ReactNode;
|
367
372
|
/**
|
368
373
|
* Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
|
369
374
|
* Specify a function here to point to the correct property in the data object.
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "1.7.
|
2
|
+
"version": "1.7.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.",
|
@@ -46,7 +46,6 @@
|
|
46
46
|
},
|
47
47
|
"scripts": {
|
48
48
|
"build": "rm -rf dist && rollup -c && size-limit",
|
49
|
-
"dev": "rm -rf dist && rollup -c -w",
|
50
49
|
"lib:build": "rm -rf dist && rollup -c && size-limit",
|
51
50
|
"lib:dev": "rm -rf dist && rollup -c -w",
|
52
51
|
"lint": "eslint .",
|
@@ -58,17 +57,17 @@
|
|
58
57
|
"@emotion/react": "^11.10.5",
|
59
58
|
"@emotion/styled": "^11.10.5",
|
60
59
|
"@mui/icons-material": "^5.11.0",
|
61
|
-
"@mui/material": "^5.11.
|
60
|
+
"@mui/material": "^5.11.8",
|
62
61
|
"@rollup/plugin-babel": "^6.0.3",
|
63
62
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
64
63
|
"@rollup/plugin-typescript": "^11.0.0",
|
65
|
-
"@size-limit/preset-small-lib": "^8.1.
|
66
|
-
"@types/node": "^18.
|
67
|
-
"@types/react": "^18.0.
|
64
|
+
"@size-limit/preset-small-lib": "^8.1.2",
|
65
|
+
"@types/node": "^18.13.0",
|
66
|
+
"@types/react": "^18.0.28",
|
68
67
|
"@types/react-dom": "^18.0.10",
|
69
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
70
|
-
"@typescript-eslint/parser": "^5.
|
71
|
-
"eslint": "^8.
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.51.0",
|
69
|
+
"@typescript-eslint/parser": "^5.51.0",
|
70
|
+
"eslint": "^8.34.0",
|
72
71
|
"eslint-plugin-mui-path-imports": "^0.0.9",
|
73
72
|
"react": "^18.2.0",
|
74
73
|
"react-dom": "^18.2.0",
|
@@ -77,9 +76,9 @@
|
|
77
76
|
"rollup-plugin-copy": "^3.4.0",
|
78
77
|
"rollup-plugin-dts": "^5.1.1",
|
79
78
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
80
|
-
"size-limit": "^8.1.
|
81
|
-
"tslib": "^2.
|
82
|
-
"typescript": "^4.9.
|
79
|
+
"size-limit": "^8.1.2",
|
80
|
+
"tslib": "^2.5.0",
|
81
|
+
"typescript": "^4.9.5"
|
83
82
|
},
|
84
83
|
"peerDependencies": {
|
85
84
|
"@emotion/react": ">=11",
|
@@ -92,7 +91,7 @@
|
|
92
91
|
"dependencies": {
|
93
92
|
"@tanstack/match-sorter-utils": "8.7.6",
|
94
93
|
"@tanstack/react-table": "8.7.9",
|
95
|
-
"@tanstack/react-virtual": "3.0.0-beta.
|
94
|
+
"@tanstack/react-virtual": "3.0.0-beta.47",
|
96
95
|
"highlight-words": "1.2.1"
|
97
96
|
}
|
98
97
|
}
|
@@ -304,6 +304,12 @@ export type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit<
|
|
304
304
|
header: MRT_Header<TData>;
|
305
305
|
table: MRT_TableInstance<TData>;
|
306
306
|
}) => ReactNode);
|
307
|
+
PlaceholderCell?: (props: {
|
308
|
+
cell: MRT_Cell<TData>;
|
309
|
+
column: MRT_Column<TData>;
|
310
|
+
row: MRT_Row<TData>;
|
311
|
+
table: MRT_TableInstance<TData>;
|
312
|
+
}) => ReactNode;
|
307
313
|
/**
|
308
314
|
* Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
|
309
315
|
* Specify a function here to point to the correct property in the data object.
|
@@ -259,7 +259,9 @@ export const MRT_TableBodyCell = ({
|
|
259
259
|
})}
|
260
260
|
>
|
261
261
|
<>
|
262
|
-
{cell.getIsPlaceholder() ?
|
262
|
+
{cell.getIsPlaceholder() ? (
|
263
|
+
columnDef.PlaceholderCell?.({ cell, column, row, table }) ?? null
|
264
|
+
) : isLoading || showSkeletons ? (
|
263
265
|
<Skeleton
|
264
266
|
animation="wave"
|
265
267
|
height={20}
|
@@ -59,14 +59,16 @@ export const MRT_ExpandAllButton = ({ table }: Props) => {
|
|
59
59
|
})}
|
60
60
|
title={undefined}
|
61
61
|
>
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
{iconButtonProps?.children ?? (
|
63
|
+
<KeyboardDoubleArrowDownIcon
|
64
|
+
style={{
|
65
|
+
transform: `rotate(${
|
66
|
+
isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
|
67
|
+
}deg)`,
|
68
|
+
transition: 'transform 150ms',
|
69
|
+
}}
|
70
|
+
/>
|
71
|
+
)}
|
70
72
|
</IconButton>
|
71
73
|
</span>
|
72
74
|
</Tooltip>
|
@@ -61,14 +61,16 @@ export const MRT_ExpandButton = ({ row, table }: Props) => {
|
|
61
61
|
})}
|
62
62
|
title={undefined}
|
63
63
|
>
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
64
|
+
{iconButtonProps?.children ?? (
|
65
|
+
<ExpandMoreIcon
|
66
|
+
style={{
|
67
|
+
transform: `rotate(${
|
68
|
+
!canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0
|
69
|
+
}deg)`,
|
70
|
+
transition: 'transform 150ms',
|
71
|
+
}}
|
72
|
+
/>
|
73
|
+
)}
|
72
74
|
</IconButton>
|
73
75
|
</span>
|
74
76
|
</Tooltip>
|
package/src/column.utils.ts
CHANGED
@@ -16,6 +16,7 @@ import type {
|
|
16
16
|
MRT_DefinedColumnDef,
|
17
17
|
MRT_DisplayColumnIds,
|
18
18
|
MRT_FilterOption,
|
19
|
+
MRT_Header,
|
19
20
|
MRT_TableInstance,
|
20
21
|
} from '.';
|
21
22
|
|
@@ -241,11 +242,13 @@ export const getTotalRight = (table: MRT_TableInstance, column: MRT_Column) => {
|
|
241
242
|
|
242
243
|
export const getCommonCellStyles = ({
|
243
244
|
column,
|
245
|
+
header,
|
244
246
|
table,
|
245
247
|
tableCellProps,
|
246
248
|
theme,
|
247
249
|
}: {
|
248
250
|
column: MRT_Column;
|
251
|
+
header?: MRT_Header;
|
249
252
|
table: MRT_TableInstance;
|
250
253
|
tableCellProps: TableCellProps;
|
251
254
|
theme: Theme;
|
@@ -263,9 +266,7 @@ export const getCommonCellStyles = ({
|
|
263
266
|
display: table.options.layoutMode === 'grid' ? 'flex' : 'table-cell',
|
264
267
|
flex:
|
265
268
|
table.options.layoutMode === 'grid'
|
266
|
-
? `var(--col-${column.id
|
267
|
-
.replaceAll('.', '_')
|
268
|
-
.replaceAll(' ', '_')}-size) 0 auto`
|
269
|
+
? `var(--col-${parseCSSVarId(header?.id ?? column.id)}-size) 0 auto`
|
269
270
|
: undefined,
|
270
271
|
left:
|
271
272
|
column.getIsPinned() === 'left'
|
@@ -302,19 +303,18 @@ export const getCommonCellStyles = ({
|
|
302
303
|
column.getIsPinned() === 'right'
|
303
304
|
? `${getTotalRight(table, column)}px`
|
304
305
|
: undefined,
|
305
|
-
transition:
|
306
|
-
|
307
|
-
|
308
|
-
: `padding 150ms ease-in-out`,
|
306
|
+
transition: table.options.enableColumnVirtualization
|
307
|
+
? 'none'
|
308
|
+
: `padding 150ms ease-in-out`,
|
309
309
|
...(tableCellProps?.sx instanceof Function
|
310
310
|
? tableCellProps.sx(theme)
|
311
311
|
: (tableCellProps?.sx as any)),
|
312
|
-
minWidth: `max(calc(var(--col-${
|
313
|
-
.
|
314
|
-
|
315
|
-
width: `calc(var(--col-${
|
316
|
-
.
|
317
|
-
|
312
|
+
minWidth: `max(calc(var(--col-${parseCSSVarId(
|
313
|
+
header?.id ?? column.id,
|
314
|
+
)}-size) * 1px), ${column.columnDef.minSize ?? 30}px)`,
|
315
|
+
width: `calc(var(--col-${parseCSSVarId(
|
316
|
+
header?.id ?? column.id,
|
317
|
+
)}-size) * 1px)`,
|
318
318
|
});
|
319
319
|
|
320
320
|
export const MRT_DefaultColumn = {
|
@@ -338,3 +338,6 @@ export const MRT_DefaultDisplayColumn = {
|
|
338
338
|
enableResizing: false,
|
339
339
|
enableSorting: false,
|
340
340
|
} as const;
|
341
|
+
|
342
|
+
export const parseCSSVarId = (id: string) =>
|
343
|
+
id.replaceAll('.', '_').replaceAll(' ', '_').replaceAll('+', '_');
|
@@ -14,10 +14,8 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
|
|
14
14
|
options: { columnResizeMode },
|
15
15
|
setColumnSizingInfo,
|
16
16
|
} = table;
|
17
|
-
const { density
|
17
|
+
const { density } = getState();
|
18
18
|
const { column } = header;
|
19
|
-
const { columnDef } = column;
|
20
|
-
const { columnDefType } = columnDef;
|
21
19
|
|
22
20
|
return (
|
23
21
|
<Box
|
@@ -54,8 +52,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
|
|
54
52
|
sx={{
|
55
53
|
borderRadius: '2px',
|
56
54
|
borderWidth: '2px',
|
57
|
-
height:
|
58
|
-
showColumnFilters && columnDefType === 'data' ? '3.5rem' : '1.5rem',
|
55
|
+
height: '24px',
|
59
56
|
touchAction: 'none',
|
60
57
|
transition: column.getIsResizing()
|
61
58
|
? undefined
|
package/src/icons.ts
CHANGED
@@ -9,7 +9,6 @@ import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
9
9
|
import DragHandleIcon from '@mui/icons-material/DragHandle';
|
10
10
|
import DynamicFeedIcon from '@mui/icons-material/DynamicFeed';
|
11
11
|
import EditIcon from '@mui/icons-material/Edit';
|
12
|
-
import ExpandLessIcon from '@mui/icons-material/ExpandLess';
|
13
12
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
14
13
|
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
15
14
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
@@ -41,7 +40,6 @@ export interface MRT_Icons {
|
|
41
40
|
DragHandleIcon: any;
|
42
41
|
DynamicFeedIcon: any;
|
43
42
|
EditIcon: any;
|
44
|
-
ExpandLessIcon: any;
|
45
43
|
ExpandMoreIcon: any;
|
46
44
|
FilterAltIcon: any;
|
47
45
|
FilterListIcon: any;
|
@@ -72,7 +70,6 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
72
70
|
DragHandleIcon,
|
73
71
|
DynamicFeedIcon,
|
74
72
|
EditIcon,
|
75
|
-
ExpandLessIcon,
|
76
73
|
ExpandMoreIcon,
|
77
74
|
FilterAltIcon,
|
78
75
|
FilterListIcon,
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -9,6 +9,7 @@ import Table from '@mui/material/Table';
|
|
9
9
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|
10
10
|
import { Memo_MRT_TableBody, MRT_TableBody } from '../body/MRT_TableBody';
|
11
11
|
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
12
|
+
import { parseCSSVarId } from '../column.utils';
|
12
13
|
import type { MRT_TableInstance } from '..';
|
13
14
|
|
14
15
|
interface Props {
|
@@ -57,10 +58,10 @@ export const MRT_Table = ({ table }: Props) => {
|
|
57
58
|
const headers = getFlatHeaders();
|
58
59
|
const colSizes: { [key: string]: number } = {};
|
59
60
|
for (let i = 0; i < headers.length; i++) {
|
60
|
-
const
|
61
|
-
|
62
|
-
|
63
|
-
] =
|
61
|
+
const header = headers[i];
|
62
|
+
const colSize = header.getSize();
|
63
|
+
colSizes[`--header-${parseCSSVarId(header.id)}-size`] = colSize;
|
64
|
+
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
64
65
|
}
|
65
66
|
return colSizes;
|
66
67
|
}, [columns, columnSizing, columnSizingInfo]);
|