material-react-table 1.7.3 → 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.
@@ -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;
@@ -11,7 +11,6 @@ export interface MRT_Icons {
11
11
  DragHandleIcon: any;
12
12
  DynamicFeedIcon: any;
13
13
  EditIcon: any;
14
- ExpandLessIcon: any;
15
14
  ExpandMoreIcon: any;
16
15
  FilterAltIcon: any;
17
16
  FilterListIcon: any;
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.3",
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.4",
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.0",
66
- "@types/node": "^18.11.18",
67
- "@types/react": "^18.0.26",
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.48.1",
70
- "@typescript-eslint/parser": "^5.48.1",
71
- "eslint": "^8.31.0",
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.0",
81
- "tslib": "^2.4.1",
82
- "typescript": "^4.9.4"
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.30",
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() ? null : isLoading || showSkeletons ? (
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
- <KeyboardDoubleArrowDownIcon
63
- style={{
64
- transform: `rotate(${
65
- isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0
66
- }deg)`,
67
- transition: 'transform 150ms',
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
- <ExpandMoreIcon
65
- style={{
66
- transform: `rotate(${
67
- !canExpand && !renderDetailPanel ? -90 : isExpanded ? -180 : 0
68
- }deg)`,
69
- transition: 'transform 150ms',
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>
@@ -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,7 +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-${parseCSSVarId(column.id)}-size) 0 auto`
269
+ ? `var(--col-${parseCSSVarId(header?.id ?? column.id)}-size) 0 auto`
267
270
  : undefined,
268
271
  left:
269
272
  column.getIsPinned() === 'left'
@@ -306,10 +309,12 @@ export const getCommonCellStyles = ({
306
309
  ...(tableCellProps?.sx instanceof Function
307
310
  ? tableCellProps.sx(theme)
308
311
  : (tableCellProps?.sx as any)),
309
- minWidth: `max(calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px), ${
310
- column.columnDef.minSize ?? 30
311
- }px)`,
312
- width: `calc(var(--col-${parseCSSVarId(column.id)}-size) * 1px)`,
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)`,
313
318
  });
314
319
 
315
320
  export const MRT_DefaultColumn = {
@@ -165,6 +165,7 @@ export const MRT_TableHeadCell = ({ header, table }: Props) => {
165
165
  : 1,
166
166
  ...getCommonCellStyles({
167
167
  column,
168
+ header,
168
169
  table,
169
170
  tableCellProps,
170
171
  theme,
@@ -67,7 +67,7 @@ export const MRT_TableHeadCellColumnActionsButton = ({
67
67
  height: '2rem',
68
68
  m: '-8px -4px',
69
69
  opacity: 0.5,
70
- transform: 'scale(0.85)',
70
+ transform: 'scale(0.85) translateX(-4px)',
71
71
  transition: 'opacity 150ms',
72
72
  width: '2rem',
73
73
  '&:hover': {
@@ -14,10 +14,8 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
14
14
  options: { columnResizeMode },
15
15
  setColumnSizingInfo,
16
16
  } = table;
17
- const { density, showColumnFilters } = getState();
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,
@@ -58,8 +58,10 @@ export const MRT_Table = ({ table }: Props) => {
58
58
  const headers = getFlatHeaders();
59
59
  const colSizes: { [key: string]: number } = {};
60
60
  for (let i = 0; i < headers.length; i++) {
61
- const h = headers[i];
62
- colSizes[`--col-${parseCSSVarId(h.column.id)}-size`] = h.getSize();
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;
63
65
  }
64
66
  return colSizes;
65
67
  }, [columns, columnSizing, columnSizingInfo]);