material-react-table 1.0.0-beta.1 → 1.0.0-beta.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.
Files changed (58) hide show
  1. package/dist/cjs/MaterialReactTable.d.ts +5 -3
  2. package/dist/cjs/body/MRT_EditRowModal.d.ts +0 -1
  3. package/dist/cjs/body/MRT_TableBody.d.ts +1 -2
  4. package/dist/cjs/body/MRT_TableBodyCellValue.d.ts +2 -2
  5. package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
  6. package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +0 -1
  7. package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
  8. package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
  9. package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
  10. package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
  11. package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
  12. package/dist/cjs/column.utils.d.ts +12 -1
  13. package/dist/cjs/index.js +115 -124
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +0 -1
  16. package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
  17. package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +0 -1
  18. package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
  19. package/dist/cjs/table/MRT_Table.d.ts +1 -2
  20. package/dist/cjs/table/MRT_TableRoot.d.ts +0 -1
  21. package/dist/cjs/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  22. package/dist/esm/MaterialReactTable.d.ts +5 -3
  23. package/dist/esm/body/MRT_EditRowModal.d.ts +0 -1
  24. package/dist/esm/body/MRT_TableBody.d.ts +1 -2
  25. package/dist/esm/body/MRT_TableBodyCellValue.d.ts +2 -2
  26. package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +0 -1
  27. package/dist/esm/buttons/MRT_EditActionButtons.d.ts +0 -1
  28. package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +0 -1
  29. package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +0 -1
  30. package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +0 -1
  31. package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +0 -1
  32. package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +0 -1
  33. package/dist/esm/column.utils.d.ts +12 -1
  34. package/dist/esm/inputs/MRT_EditCellTextField.d.ts +0 -1
  35. package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +0 -1
  36. package/dist/esm/material-react-table.esm.js +117 -126
  37. package/dist/esm/material-react-table.esm.js.map +1 -1
  38. package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +0 -1
  39. package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +0 -1
  40. package/dist/esm/table/MRT_Table.d.ts +1 -2
  41. package/dist/esm/table/MRT_TableRoot.d.ts +0 -1
  42. package/dist/esm/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
  43. package/dist/index.d.ts +5 -4
  44. package/package.json +6 -6
  45. package/src/MaterialReactTable.tsx +7 -2
  46. package/src/body/MRT_TableBody.tsx +3 -3
  47. package/src/body/MRT_TableBodyCell.tsx +11 -58
  48. package/src/body/MRT_TableBodyCellValue.tsx +7 -2
  49. package/src/column.utils.ts +72 -0
  50. package/src/footer/MRT_TableFooterCell.tsx +5 -15
  51. package/src/head/MRT_TableHeadCell.tsx +9 -50
  52. package/src/inputs/MRT_FilterTextField.tsx +6 -1
  53. package/src/table/MRT_Table.tsx +3 -4
  54. package/src/table/MRT_TableContainer.tsx +2 -11
  55. package/src/table/MRT_TableRoot.tsx +5 -3
  56. package/src/toolbar/MRT_BottomToolbar.tsx +5 -2
  57. package/src/toolbar/MRT_TablePagination.tsx +1 -1
  58. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +7 -1
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MRT_Header, MRT_InternalFilterOption, MRT_TableInstance } from '..';
3
2
  import { MRT_Localization } from '../localization';
4
3
  export declare const mrtFilterOptions: (localization: MRT_Localization) => MRT_InternalFilterOption[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import type { MRT_TableInstance } from '..';
3
2
  interface Props<TData extends Record<string, any> = {}> {
4
3
  anchorEl: HTMLElement | null;
@@ -1,7 +1,6 @@
1
- import { FC, RefObject } from 'react';
1
+ import { FC } from 'react';
2
2
  import { MRT_TableInstance } from '..';
3
3
  interface Props {
4
- tableContainerRef: RefObject<HTMLDivElement>;
5
4
  table: MRT_TableInstance;
6
5
  }
7
6
  export declare const MRT_Table: FC<Props>;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { MaterialReactTableProps } from '..';
3
2
  export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { FC } from 'react';
2
2
  import { MRT_TableInstance } from '..';
3
3
  interface Props {
4
- stackAlertBanner?: boolean;
4
+ stackAlertBanner: boolean;
5
5
  table: MRT_TableInstance;
6
6
  }
7
7
  export declare const MRT_ToolbarAlertBanner: FC<Props>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { MutableRefObject, Dispatch, SetStateAction, ReactNode, DragEvent } from 'react';
3
2
  import { ButtonProps, TextFieldProps, TableCellProps, IconButtonProps, ToolbarProps, LinearProgressProps, CheckboxProps, SkeletonProps, TableBodyProps, TableRowProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, PaperProps, TableProps, ChipProps, AlertProps } from '@mui/material';
4
3
  import { Row, Table, TableState, ColumnDef, DeepKeys, Column, Header, HeaderGroup, Cell, SortingFn, FilterFn, TableOptions, OnChangeFn } from '@tanstack/react-table';
@@ -518,7 +517,7 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
518
517
  muiExpandAllButtonProps?: IconButtonProps | (({ table }: {
519
518
  table: MRT_TableInstance<TData>;
520
519
  }) => IconButtonProps);
521
- muiExpandButtonProps?: IconButtonProps | (({ table, }: {
520
+ muiExpandButtonProps?: IconButtonProps | (({ row, table, }: {
522
521
  table: MRT_TableInstance<TData>;
523
522
  row: MRT_Row<TData>;
524
523
  }) => IconButtonProps);
@@ -554,9 +553,11 @@ declare type MaterialReactTableProps<TData extends Record<string, any> = {}> = O
554
553
  row: MRT_Row<TData>;
555
554
  table: MRT_TableInstance<TData>;
556
555
  }) => TableCellProps);
557
- muiTableBodyCellSkeletonProps?: SkeletonProps | (({ table, cell, }: {
558
- table: MRT_TableInstance<TData>;
556
+ muiTableBodyCellSkeletonProps?: SkeletonProps | (({ cell, column, row, table, }: {
559
557
  cell: MRT_Cell<TData>;
558
+ column: MRT_Column<TData>;
559
+ row: MRT_Row<TData>;
560
+ table: MRT_TableInstance<TData>;
560
561
  }) => SkeletonProps);
561
562
  muiTableBodyProps?: TableBodyProps | (({ table }: {
562
563
  table: MRT_TableInstance<TData>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-beta.1",
2
+ "version": "1.0.0-beta.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.",
@@ -51,8 +51,8 @@
51
51
  "devDependencies": {
52
52
  "@babel/core": "^7.18.13",
53
53
  "@babel/preset-react": "^7.18.6",
54
- "@emotion/react": "^11.10.0",
55
- "@emotion/styled": "^11.10.0",
54
+ "@emotion/react": "^11.10.4",
55
+ "@emotion/styled": "^11.10.4",
56
56
  "@faker-js/faker": "^7.5.0",
57
57
  "@mui/icons-material": "^5.10.3",
58
58
  "@mui/material": "^5.10.3",
@@ -68,7 +68,7 @@
68
68
  "@storybook/addon-storysource": "^6.5.10",
69
69
  "@storybook/addons": "^6.5.10",
70
70
  "@storybook/react": "^6.5.10",
71
- "@types/react": "^18.0.17",
71
+ "@types/react": "^18.0.18",
72
72
  "@types/react-dom": "^18.0.6",
73
73
  "babel-loader": "^8.2.5",
74
74
  "eslint": "^8.23.0",
@@ -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.1",
81
+ "rollup": "^2.79.0",
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",
@@ -95,7 +95,7 @@
95
95
  },
96
96
  "dependencies": {
97
97
  "@tanstack/match-sorter-utils": "8.1.1",
98
- "@tanstack/react-table": "8.5.11",
98
+ "@tanstack/react-table": "8.5.13",
99
99
  "react-virtual": "^2.10.4"
100
100
  }
101
101
  }
@@ -541,6 +541,7 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
541
541
  muiExpandButtonProps?:
542
542
  | IconButtonProps
543
543
  | (({
544
+ row,
544
545
  table,
545
546
  }: {
546
547
  table: MRT_TableInstance<TData>;
@@ -612,11 +613,15 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> =
612
613
  muiTableBodyCellSkeletonProps?:
613
614
  | SkeletonProps
614
615
  | (({
615
- table,
616
616
  cell,
617
+ column,
618
+ row,
619
+ table,
617
620
  }: {
618
- table: MRT_TableInstance<TData>;
619
621
  cell: MRT_Cell<TData>;
622
+ column: MRT_Column<TData>;
623
+ row: MRT_Row<TData>;
624
+ table: MRT_TableInstance<TData>;
620
625
  }) => SkeletonProps);
621
626
  muiTableBodyProps?:
622
627
  | TableBodyProps
@@ -1,4 +1,4 @@
1
- import React, { FC, RefObject, useMemo } from 'react';
1
+ import React, { FC, useMemo } from 'react';
2
2
  import { useVirtual } from 'react-virtual'; //stuck on v2 for now
3
3
  // import { useVirtualizer, Virtualizer } from '@tanstack/react-virtual';
4
4
  import { TableBody } from '@mui/material';
@@ -8,10 +8,9 @@ import type { MRT_Row, MRT_TableInstance } from '..';
8
8
 
9
9
  interface Props {
10
10
  table: MRT_TableInstance;
11
- tableContainerRef: RefObject<HTMLDivElement>;
12
11
  }
13
12
 
14
- export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
13
+ export const MRT_TableBody: FC<Props> = ({ table }) => {
15
14
  const {
16
15
  getRowModel,
17
16
  getPrePaginationRowModel,
@@ -26,6 +25,7 @@ export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
26
25
  virtualizerInstanceRef,
27
26
  virtualizerProps,
28
27
  },
28
+ refs: { tableContainerRef },
29
29
  } = table;
30
30
  const { globalFilter, pagination, sorting } = getState();
31
31
 
@@ -6,19 +6,13 @@ import React, {
6
6
  useEffect,
7
7
  useState,
8
8
  } from 'react';
9
- import {
10
- alpha,
11
- darken,
12
- lighten,
13
- Skeleton,
14
- TableCell,
15
- useTheme,
16
- } from '@mui/material';
9
+ import { darken, lighten, Skeleton, TableCell, useTheme } from '@mui/material';
17
10
  import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
18
11
  import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
19
- import type { MRT_Cell, MRT_TableInstance } from '..';
20
12
  import { MRT_TableBodyRowGrabHandle } from './MRT_TableBodyRowGrabHandle';
21
13
  import { MRT_TableBodyCellValue } from './MRT_TableBodyCellValue';
14
+ import { getCommonCellStyles } from '../column.utils';
15
+ import type { MRT_Cell, MRT_TableInstance } from '..';
22
16
 
23
17
  interface Props {
24
18
  cell: MRT_Cell;
@@ -82,6 +76,11 @@ export const MRT_TableBodyCell: FC<Props> = ({
82
76
  ...mcTableCellBodyProps,
83
77
  };
84
78
 
79
+ const skeletonProps =
80
+ muiTableBodyCellSkeletonProps instanceof Function
81
+ ? muiTableBodyCellSkeletonProps({ cell, column, row, table })
82
+ : muiTableBodyCellSkeletonProps;
83
+
85
84
  const isEditable =
86
85
  (enableEditing || columnDef.enableEditing) &&
87
86
  columnDef.enableEditing !== false;
@@ -127,23 +126,6 @@ export const MRT_TableBodyCell: FC<Props> = ({
127
126
  }
128
127
  };
129
128
 
130
- const getIsLastLeftPinnedColumn = () => {
131
- return (
132
- column.getIsPinned() === 'left' &&
133
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
134
- );
135
- };
136
-
137
- const getIsFirstRightPinnedColumn = () => {
138
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
139
- };
140
-
141
- const getTotalRight = () => {
142
- return (
143
- (table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150
144
- );
145
- };
146
-
147
129
  const handleDragEnter = (e: DragEvent<HTMLTableCellElement>) => {
148
130
  tableCellProps?.onDragEnter?.(e);
149
131
  if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
@@ -185,23 +167,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
185
167
  onDragEnter={handleDragEnter}
186
168
  onDoubleClick={handleDoubleClick}
187
169
  sx={(theme) => ({
188
- backgroundColor: column.getIsPinned()
189
- ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
190
- : undefined,
191
- boxShadow: getIsLastLeftPinnedColumn()
192
- ? `4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
193
- : getIsFirstRightPinnedColumn()
194
- ? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
195
- : undefined,
196
170
  cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text',
197
- left:
198
- column.getIsPinned() === 'left'
199
- ? `${column.getStart('left')}px`
200
- : undefined,
201
- opacity:
202
- draggingColumn?.id === column.id || hoveredColumn?.id === column.id
203
- ? 0.5
204
- : 1,
205
171
  overflow: 'hidden',
206
172
  p:
207
173
  density === 'compact'
@@ -226,18 +192,10 @@ export const MRT_TableBodyCell: FC<Props> = ({
226
192
  : 1.25)
227
193
  }rem`
228
194
  : undefined,
229
- position: column.getIsPinned() ? 'sticky' : 'relative',
230
- right:
231
- column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
232
195
  textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined,
233
- transition: 'all 0.2s ease-in-out',
234
196
  whiteSpace: density === 'compact' ? 'nowrap' : 'normal',
235
197
  zIndex:
236
- draggingColumn?.id === column.id
237
- ? 2
238
- : column.getIsPinned()
239
- ? 1
240
- : undefined,
198
+ draggingColumn?.id === column.id ? 2 : column.getIsPinned() ? 1 : 0,
241
199
  '&:hover': {
242
200
  backgroundColor:
243
201
  enableHover &&
@@ -249,13 +207,8 @@ export const MRT_TableBodyCell: FC<Props> = ({
249
207
  : `${darken(theme.palette.background.default, 0.1)} !important`
250
208
  : undefined,
251
209
  },
252
- ...(tableCellProps?.sx instanceof Function
253
- ? tableCellProps.sx(theme)
254
- : (tableCellProps?.sx as any)),
210
+ ...getCommonCellStyles({ column, table, theme, tableCellProps }),
255
211
  ...draggingBorders,
256
- maxWidth: `min(${column.getSize()}px, fit-content)`,
257
- minWidth: `max(${column.getSize()}px, ${columnDef.minSize ?? 30}px)`,
258
- width: column.getSize(),
259
212
  })}
260
213
  >
261
214
  <>
@@ -264,7 +217,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
264
217
  animation="wave"
265
218
  height={20}
266
219
  width={skeletonWidth}
267
- {...muiTableBodyCellSkeletonProps}
220
+ {...skeletonProps}
268
221
  />
269
222
  ) : enableRowNumbers &&
270
223
  rowNumberMode === 'static' &&
@@ -1,4 +1,4 @@
1
- import React, { FC } from 'react';
1
+ import React, { FC, memo } from 'react';
2
2
  import { MRT_Cell, MRT_TableInstance } from '..';
3
3
 
4
4
  interface Props {
@@ -6,7 +6,7 @@ interface Props {
6
6
  table: MRT_TableInstance;
7
7
  }
8
8
 
9
- export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
9
+ const _MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
10
10
  const { column, row } = cell;
11
11
  const { columnDef } = column;
12
12
 
@@ -32,3 +32,8 @@ export const MRT_TableBodyCellValue: FC<Props> = ({ cell, table }) => {
32
32
  </>
33
33
  );
34
34
  };
35
+
36
+ export const MRT_TableBodyCellValue = memo(
37
+ _MRT_TableBodyCellValue,
38
+ (prev, next) => prev.cell.getValue() === next.cell.getValue(),
39
+ );
@@ -1,4 +1,5 @@
1
1
  import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
2
+ import { alpha, lighten, TableCellProps, Theme } from '@mui/material';
2
3
  import {
3
4
  MaterialReactTableProps,
4
5
  MRT_Column,
@@ -6,6 +7,8 @@ import {
6
7
  MRT_DefinedColumnDef,
7
8
  MRT_DisplayColumnIds,
8
9
  MRT_FilterOption,
10
+ MRT_Header,
11
+ MRT_TableInstance,
9
12
  } from '.';
10
13
  import { MRT_FilterFns } from './filterFns';
11
14
  import { MRT_SortingFns } from './sortingFns';
@@ -165,3 +168,72 @@ export const getDefaultColumnFilterFn = <
165
168
  if (columnDef.filterVariant === 'range') return 'betweenInclusive';
166
169
  return 'fuzzy';
167
170
  };
171
+
172
+ export const getIsLastLeftPinnedColumn = (
173
+ table: MRT_TableInstance,
174
+ column: MRT_Column,
175
+ ) => {
176
+ return (
177
+ column.getIsPinned() === 'left' &&
178
+ table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
179
+ );
180
+ };
181
+
182
+ export const getIsFirstRightPinnedColumn = (column: MRT_Column) => {
183
+ return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
184
+ };
185
+
186
+ export const getTotalRight = (table: MRT_TableInstance, column: MRT_Column) => {
187
+ return (
188
+ (table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 160
189
+ );
190
+ };
191
+
192
+ export const getCommonCellStyles = ({
193
+ column,
194
+ header,
195
+ table,
196
+ tableCellProps,
197
+ theme,
198
+ }: {
199
+ column: MRT_Column;
200
+ header?: MRT_Header;
201
+ table: MRT_TableInstance;
202
+ tableCellProps: TableCellProps;
203
+ theme: Theme;
204
+ }) => ({
205
+ backgroundColor:
206
+ column.getIsPinned() && column.columnDef.columnDefType !== 'group'
207
+ ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
208
+ : 'inherit',
209
+ backgroundImage: 'inherit',
210
+ boxShadow: getIsLastLeftPinnedColumn(table, column)
211
+ ? `-4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
212
+ : getIsFirstRightPinnedColumn(column)
213
+ ? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
214
+ : undefined,
215
+ left:
216
+ column.getIsPinned() === 'left'
217
+ ? `${column.getStart('left')}px`
218
+ : undefined,
219
+ opacity:
220
+ table.getState().draggingColumn?.id === column.id ||
221
+ table.getState().hoveredColumn?.id === column.id
222
+ ? 0.5
223
+ : 1,
224
+ position:
225
+ column.getIsPinned() && column.columnDef.columnDefType !== 'group'
226
+ ? 'sticky'
227
+ : undefined,
228
+ right:
229
+ column.getIsPinned() === 'right'
230
+ ? `${getTotalRight(table, column)}px`
231
+ : undefined,
232
+ transition: `all ${column.getIsResizing() ? 0 : '0.2s'} ease-in-out`,
233
+ ...(tableCellProps?.sx instanceof Function
234
+ ? tableCellProps.sx(theme)
235
+ : (tableCellProps?.sx as any)),
236
+ maxWidth: `min(${column.getSize()}px, fit-content)`,
237
+ minWidth: `max(${column.getSize()}px, ${column.columnDef.minSize ?? 30}px)`,
238
+ width: header?.getSize() ?? column.getSize(),
239
+ });
@@ -1,5 +1,6 @@
1
1
  import React, { FC } from 'react';
2
- import { alpha, TableCell } from '@mui/material';
2
+ import { TableCell } from '@mui/material';
3
+ import { getCommonCellStyles } from '../column.utils';
3
4
  import type { MRT_Header, MRT_TableInstance } from '..';
4
5
 
5
6
  interface Props {
@@ -10,7 +11,7 @@ interface Props {
10
11
  export const MRT_TableFooterCell: FC<Props> = ({ footer, table }) => {
11
12
  const {
12
13
  getState,
13
- options: { muiTableFooterCellProps, enableColumnResizing },
14
+ options: { muiTableFooterCellProps },
14
15
  } = table;
15
16
  const { density } = getState();
16
17
  const { column } = footer;
@@ -39,26 +40,15 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, table }) => {
39
40
  variant="head"
40
41
  {...tableCellProps}
41
42
  sx={(theme) => ({
42
- backgroundColor: theme.palette.background.default,
43
- backgroundImage: `linear-gradient(${alpha(
44
- theme.palette.common.white,
45
- 0.05,
46
- )},${alpha(theme.palette.common.white, 0.05)})`,
47
43
  fontWeight: 'bold',
48
- maxWidth: `${column.getSize()}px`,
49
- minWidth: `${column.getSize()}px`,
50
44
  p:
51
45
  density === 'compact'
52
46
  ? '0.5rem'
53
47
  : density === 'comfortable'
54
48
  ? '1rem'
55
49
  : '1.5rem',
56
- transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
57
- width: column.getSize(),
58
- verticalAlign: 'text-top',
59
- ...(tableCellProps?.sx instanceof Function
60
- ? tableCellProps.sx(theme)
61
- : (tableCellProps?.sx as any)),
50
+ verticalAlign: 'top',
51
+ ...getCommonCellStyles({ column, table, theme, tableCellProps }),
62
52
  })}
63
53
  >
64
54
  <>
@@ -1,11 +1,12 @@
1
1
  import React, { DragEvent, FC, ReactNode } from 'react';
2
- import { Box, TableCell, Theme, alpha, lighten, useTheme } from '@mui/material';
2
+ import { Box, TableCell, Theme, useTheme } from '@mui/material';
3
3
  import { MRT_TableHeadCellColumnActionsButton } from './MRT_TableHeadCellColumnActionsButton';
4
4
  import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer';
5
5
  import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel';
6
6
  import { MRT_TableHeadCellGrabHandle } from './MRT_TableHeadCellGrabHandle';
7
7
  import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle';
8
8
  import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel';
9
+ import { getCommonCellStyles } from '../column.utils';
9
10
  import type { MRT_Header, MRT_TableInstance } from '..';
10
11
 
11
12
  interface Props {
@@ -21,7 +22,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
21
22
  enableColumnActions,
22
23
  enableColumnDragging,
23
24
  enableColumnOrdering,
24
- enableColumnResizing,
25
25
  enableGrouping,
26
26
  enableMultiSort,
27
27
  muiTableHeadCellProps,
@@ -54,23 +54,6 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
54
54
  ...mcTableHeadCellProps,
55
55
  };
56
56
 
57
- const getIsLastLeftPinnedColumn = () => {
58
- return (
59
- column.getIsPinned() === 'left' &&
60
- table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
61
- );
62
- };
63
-
64
- const getIsFirstRightPinnedColumn = () => {
65
- return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
66
- };
67
-
68
- const getTotalRight = () => {
69
- return (
70
- (table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150
71
- );
72
- };
73
-
74
57
  const handleDragEnter = (_e: DragEvent) => {
75
58
  if (enableGrouping && hoveredColumn?.id === 'drop-zone') {
76
59
  setHoveredColumn(null);
@@ -115,26 +98,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
115
98
  ref={tableHeadCellRef}
116
99
  {...tableCellProps}
117
100
  sx={(theme: Theme) => ({
118
- backgroundColor:
119
- column.getIsPinned() && columnDefType !== 'group'
120
- ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
121
- : 'inherit',
122
- backgroundImage: 'inherit',
123
- boxShadow: getIsLastLeftPinnedColumn()
124
- ? `4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
125
- : getIsFirstRightPinnedColumn()
126
- ? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
127
- : undefined,
128
101
  fontWeight: 'bold',
129
- left:
130
- column.getIsPinned() === 'left'
131
- ? `${column.getStart('left')}px`
132
- : undefined,
133
102
  overflow: 'visible',
134
- opacity:
135
- draggingColumn?.id === column.id || hoveredColumn?.id === column.id
136
- ? 0.5
137
- : 1,
138
103
  p:
139
104
  density === 'compact'
140
105
  ? '0.5rem'
@@ -151,19 +116,12 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
151
116
  : showColumnFilters || density === 'compact'
152
117
  ? '0.4rem'
153
118
  : '0.6rem',
154
- position:
155
- column.getIsPinned() && columnDefType !== 'group'
156
- ? 'sticky'
157
- : undefined,
158
119
  pt:
159
120
  columnDefType === 'group' || density === 'compact'
160
121
  ? '0.25rem'
161
122
  : density === 'comfortable'
162
123
  ? '.75rem'
163
124
  : '1.25rem',
164
- right:
165
- column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
166
- transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
167
125
  userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined,
168
126
  verticalAlign: 'top',
169
127
  zIndex:
@@ -172,13 +130,14 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
172
130
  : column.getIsPinned() && columnDefType !== 'group'
173
131
  ? 2
174
132
  : 1,
175
- ...(tableCellProps?.sx instanceof Function
176
- ? tableCellProps.sx(theme)
177
- : (tableCellProps?.sx as any)),
133
+ ...getCommonCellStyles({
134
+ column,
135
+ header,
136
+ table,
137
+ tableCellProps,
138
+ theme,
139
+ }),
178
140
  ...draggingBorders,
179
- maxWidth: `min(${column.getSize()}px, fit-content)`,
180
- minWidth: `max(${column.getSize()}px, ${columnDef.minSize ?? 30}px)`,
181
- width: header.getSize(),
182
141
  })}
183
142
  >
184
143
  {header.isPlaceholder ? null : (
@@ -313,7 +313,12 @@ export const MRT_FilterTextField: FC<Props> = ({
313
313
  }}
314
314
  sx={(theme) => ({
315
315
  p: 0,
316
- minWidth: !filterChipLabel ? '120px' : 'auto',
316
+ minWidth:
317
+ columnDef.filterVariant === 'range'
318
+ ? '90px'
319
+ : !filterChipLabel
320
+ ? '120px'
321
+ : 'auto',
317
322
  width: '100%',
318
323
  '& .MuiSelect-icon': {
319
324
  mr: '1.5rem',
@@ -1,4 +1,4 @@
1
- import React, { FC, RefObject } from 'react';
1
+ import React, { FC } from 'react';
2
2
  import { Table } from '@mui/material';
3
3
  import { MRT_TableHead } from '../head/MRT_TableHead';
4
4
  import { MRT_TableBody } from '../body/MRT_TableBody';
@@ -6,11 +6,10 @@ import { MRT_TableFooter } from '../footer/MRT_TableFooter';
6
6
  import { MRT_TableInstance } from '..';
7
7
 
8
8
  interface Props {
9
- tableContainerRef: RefObject<HTMLDivElement>;
10
9
  table: MRT_TableInstance;
11
10
  }
12
11
 
13
- export const MRT_Table: FC<Props> = ({ tableContainerRef, table }) => {
12
+ export const MRT_Table: FC<Props> = ({ table }) => {
14
13
  const {
15
14
  getState,
16
15
  options: {
@@ -44,7 +43,7 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, table }) => {
44
43
  })}
45
44
  >
46
45
  {enableTableHead && <MRT_TableHead table={table} />}
47
- <MRT_TableBody tableContainerRef={tableContainerRef} table={table} />
46
+ <MRT_TableBody table={table} />
48
47
  {enableTableFooter && <MRT_TableFooter table={table} />}
49
48
  </Table>
50
49
  );
@@ -1,10 +1,4 @@
1
- import React, {
2
- FC,
3
- RefObject,
4
- useEffect,
5
- useLayoutEffect,
6
- useState,
7
- } from 'react';
1
+ import React, { FC, useEffect, useLayoutEffect, useState } from 'react';
8
2
  import { TableContainer } from '@mui/material';
9
3
  import { MRT_Table } from './MRT_Table';
10
4
  import type { MRT_TableInstance } from '..';
@@ -77,10 +71,7 @@ export const MRT_TableContainer: FC<Props> = ({ table }) => {
77
71
  ...tableContainerProps?.style,
78
72
  }}
79
73
  >
80
- <MRT_Table
81
- tableContainerRef={tableContainerRef as RefObject<HTMLDivElement>}
82
- table={table}
83
- />
74
+ <MRT_Table table={table} />
84
75
  </TableContainer>
85
76
  );
86
77
  };
@@ -321,13 +321,15 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
321
321
  disablePortal
322
322
  fullScreen
323
323
  keepMounted={false}
324
- onClose={() => setIsFullScreen(false)}
325
- open={isFullScreen}
324
+ onClose={() => table.setIsFullScreen(false)}
325
+ open={table.getState().isFullScreen}
326
326
  transitionDuration={400}
327
327
  >
328
328
  <MRT_TablePaper table={table as any} />
329
329
  </Dialog>
330
- {!isFullScreen && <MRT_TablePaper table={table as any} />}
330
+ {!table.getState().isFullScreen && (
331
+ <MRT_TablePaper table={table as any} />
332
+ )}
331
333
  {editingRow && props.editingMode === 'modal' && (
332
334
  <MRT_EditRowModal row={editingRow as any} table={table} open />
333
335
  )}
@@ -62,14 +62,17 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
62
62
  >
63
63
  <MRT_LinearProgressBar isTopToolbar={false} table={table} />
64
64
  {positionToolbarAlertBanner === 'bottom' && (
65
- <MRT_ToolbarAlertBanner table={table} />
65
+ <MRT_ToolbarAlertBanner
66
+ stackAlertBanner={stackAlertBanner}
67
+ table={table}
68
+ />
66
69
  )}
67
70
  {['both', 'bottom'].includes(positionToolbarDropZone ?? '') && (
68
71
  <MRT_ToolbarDropZone table={table} />
69
72
  )}
70
73
  <Box
71
74
  sx={{
72
- alignItems: 'flex-start',
75
+ alignItems: 'center',
73
76
  boxSizing: 'border-box',
74
77
  display: 'flex',
75
78
  justifyContent: 'space-between',