material-react-table 0.7.6 → 0.8.0-alpha.1

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 (53) hide show
  1. package/dist/MaterialReactTable.d.ts +13 -15
  2. package/dist/body/MRT_TableBody.d.ts +0 -1
  3. package/dist/body/MRT_TableBodyCell.d.ts +1 -0
  4. package/dist/body/MRT_TableBodyRow.d.ts +0 -1
  5. package/dist/buttons/MRT_CopyButton.d.ts +2 -1
  6. package/dist/enums.d.ts +2 -2
  7. package/dist/filtersFNs.d.ts +31 -30
  8. package/dist/footer/MRT_TableFooter.d.ts +0 -1
  9. package/dist/head/MRT_TableHead.d.ts +0 -1
  10. package/dist/inputs/MRT_FilterRangeFields.d.ts +8 -0
  11. package/dist/inputs/MRT_FilterTextField.d.ts +1 -0
  12. package/dist/localization.d.ts +6 -2
  13. package/dist/material-react-table.cjs.development.js +372 -402
  14. package/dist/material-react-table.cjs.development.js.map +1 -1
  15. package/dist/material-react-table.cjs.production.min.js +1 -1
  16. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  17. package/dist/material-react-table.esm.js +375 -405
  18. package/dist/material-react-table.esm.js.map +1 -1
  19. package/dist/table/MRT_Table.d.ts +0 -1
  20. package/dist/toolbar/MRT_ToolbarTop.d.ts +1 -0
  21. package/dist/utils.d.ts +1 -1
  22. package/package.json +24 -24
  23. package/src/MaterialReactTable.tsx +17 -24
  24. package/src/body/MRT_TableBody.tsx +3 -11
  25. package/src/body/MRT_TableBodyCell.tsx +102 -51
  26. package/src/body/MRT_TableBodyRow.tsx +21 -30
  27. package/src/buttons/MRT_ColumnPinningButtons.tsx +28 -40
  28. package/src/buttons/MRT_CopyButton.tsx +3 -2
  29. package/src/buttons/MRT_EditActionButtons.tsx +1 -2
  30. package/src/buttons/MRT_ExpandAllButton.tsx +1 -2
  31. package/src/enums.ts +2 -2
  32. package/src/filtersFNs.ts +71 -81
  33. package/src/footer/MRT_TableFooter.tsx +6 -16
  34. package/src/footer/MRT_TableFooterCell.tsx +5 -7
  35. package/src/footer/MRT_TableFooterRow.tsx +5 -8
  36. package/src/head/MRT_TableHead.tsx +5 -16
  37. package/src/head/MRT_TableHeadCell.tsx +98 -39
  38. package/src/head/MRT_TableHeadRow.tsx +8 -15
  39. package/src/inputs/MRT_EditCellTextField.tsx +2 -2
  40. package/src/inputs/MRT_FilterRangeFields.tsx +41 -0
  41. package/src/inputs/MRT_FilterTextField.tsx +73 -41
  42. package/src/inputs/MRT_SelectCheckbox.tsx +16 -17
  43. package/src/localization.ts +13 -5
  44. package/src/menus/MRT_ColumnActionMenu.tsx +7 -6
  45. package/src/menus/MRT_FilterOptionMenu.tsx +36 -33
  46. package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
  47. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +3 -5
  48. package/src/table/MRT_Table.tsx +5 -16
  49. package/src/table/MRT_TableContainer.tsx +7 -78
  50. package/src/table/MRT_TableRoot.tsx +51 -51
  51. package/src/toolbar/MRT_LinearProgressBar.tsx +5 -2
  52. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -2
  53. package/src/toolbar/MRT_ToolbarTop.tsx +4 -6
@@ -1,7 +1,6 @@
1
1
  import { FC } from 'react';
2
2
  import { MRT_TableInstance } from '..';
3
3
  interface Props {
4
- pinned: 'left' | 'center' | 'right' | 'none';
5
4
  tableInstance: MRT_TableInstance;
6
5
  }
7
6
  export declare const MRT_Table: FC<Props>;
@@ -8,6 +8,7 @@ export declare const commonToolbarStyles: ({ theme }: {
8
8
  backgroundImage: string;
9
9
  display: string;
10
10
  p: string;
11
+ transition: string;
11
12
  width: string;
12
13
  zIndex: number;
13
14
  };
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" | "defaultCanHide" | "defaultIsVisible" | "enablePinning" | "defaultCanPin" | "enableAllFilters" | "enableColumnFilter" | "enableGlobalFilter" | "defaultCanFilter" | "defaultCanColumnFilter" | "defaultCanGlobalFilter" | "sortingFn" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "defaultCanSort" | "invertSorting" | "sortUndefined" | "aggregationFn" | "aggregateValue" | "aggregatedCell" | "enableGrouping" | "defaultCanGroup" | "enableResizing" | "defaultCanResize" | "width" | "minWidth" | "maxWidth" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "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>, "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" | "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.7.6",
2
+ "version": "0.8.0-alpha.1",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI implementation of react-table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
@@ -55,39 +55,39 @@
55
55
  }
56
56
  ],
57
57
  "devDependencies": {
58
- "@babel/core": "^7.17.9",
58
+ "@babel/core": "^7.18.2",
59
59
  "@emotion/react": "^11.9.0",
60
60
  "@emotion/styled": "^11.8.1",
61
61
  "@etchteam/storybook-addon-status": "^4.2.1",
62
- "@faker-js/faker": "^6.2.0",
63
- "@mui/icons-material": "^5.6.2",
64
- "@mui/material": "^5.6.3",
62
+ "@faker-js/faker": "^7.1.0",
63
+ "@mui/icons-material": "^5.8.0",
64
+ "@mui/material": "^5.8.1",
65
65
  "@size-limit/preset-small-lib": "^7.0.8",
66
- "@storybook/addon-a11y": "^6.4.22",
67
- "@storybook/addon-actions": "^6.4.22",
66
+ "@storybook/addon-a11y": "^6.5.5",
67
+ "@storybook/addon-actions": "^6.5.5",
68
68
  "@storybook/addon-console": "^1.2.3",
69
- "@storybook/addon-essentials": "^6.4.22",
69
+ "@storybook/addon-essentials": "^6.5.5",
70
70
  "@storybook/addon-info": "^5.3.21",
71
- "@storybook/addon-links": "^6.4.22",
72
- "@storybook/addon-storysource": "^6.4.22",
73
- "@storybook/addons": "^6.4.22",
74
- "@storybook/react": "^6.4.22",
75
- "@types/react": "^17.0.41",
76
- "@types/react-dom": "^17.0.14",
71
+ "@storybook/addon-links": "^6.5.5",
72
+ "@storybook/addon-storysource": "^6.5.5",
73
+ "@storybook/addons": "^6.5.5",
74
+ "@storybook/react": "^6.5.5",
75
+ "@types/react": "^18.0.9",
76
+ "@types/react-dom": "^18.0.5",
77
77
  "babel-loader": "^8.2.5",
78
- "eslint": "^8.14.0",
79
- "eslint-plugin-react-hooks": "^4.4.0",
80
- "husky": "^7.0.4",
78
+ "eslint": "^8.16.0",
79
+ "eslint-plugin-react-hooks": "^4.5.0",
80
+ "husky": "^8.0.1",
81
81
  "prettier": "^2.6.2",
82
- "react": "^17.0.2",
83
- "react-dom": "^17.0.2",
84
- "react-is": "^17.0.2",
82
+ "react": "^18.1.0",
83
+ "react-dom": "^18.1.0",
84
+ "react-is": "^18.1.0",
85
85
  "size-limit": "^7.0.8",
86
86
  "storybook-addon-paddings": "^4.3.0",
87
- "storybook-dark-mode": "^1.0.9",
87
+ "storybook-dark-mode": "^1.1.0",
88
88
  "tsdx": "^0.14.1",
89
89
  "tslib": "^2.4.0",
90
- "typescript": "^4.6.3"
90
+ "typescript": "^4.7.2"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@emotion/react": ">=11",
@@ -97,7 +97,7 @@
97
97
  "react": ">=16.8"
98
98
  },
99
99
  "dependencies": {
100
- "@tanstack/react-table": "^8.0.0-alpha.48",
101
- "match-sorter": "^6.3.1"
100
+ "@tanstack/match-sorter-utils": "^8.0.0-alpha.83",
101
+ "@tanstack/react-table": "^8.0.0-alpha.87"
102
102
  }
103
103
  }
@@ -30,17 +30,18 @@ import {
30
30
  Cell,
31
31
  Column,
32
32
  ColumnDef,
33
- DefaultGenerics,
34
33
  FilterFn,
35
34
  FilterFnOption,
36
35
  Header,
37
36
  HeaderGroup,
38
- Options,
39
37
  Overwrite,
40
38
  PaginationState,
39
+ ReactTableGenerics,
41
40
  Row,
41
+ TableGenerics,
42
42
  TableInstance,
43
43
  TableState,
44
+ UseTableInstanceOptions,
44
45
  VisibilityState,
45
46
  } from '@tanstack/react-table';
46
47
  import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
@@ -50,7 +51,7 @@ import { MRT_TableRoot } from './table/MRT_TableRoot';
50
51
 
51
52
  export type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<
52
53
  Omit<
53
- Options<D>,
54
+ UseTableInstanceOptions<ReactTableGenerics>,
54
55
  'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn' | 'filterFns'
55
56
  >
56
57
  > & {
@@ -71,7 +72,7 @@ export interface MRT_RowModel<D extends Record<string, any> = {}> {
71
72
  export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
72
73
  TableInstance<
73
74
  Overwrite<
74
- Partial<DefaultGenerics>,
75
+ Partial<TableGenerics>,
75
76
  {
76
77
  Row: D;
77
78
  }
@@ -100,11 +101,11 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
100
101
  idPrefix: string;
101
102
  localization: MRT_Localization;
102
103
  };
103
- setCurrentEditingCell: Dispatch<SetStateAction<MRT_Cell<D> | null>>;
104
- setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
104
+ setCurrentEditingCell: Dispatch<SetStateAction<MRT_Cell | null>>;
105
+ setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row | null>>;
105
106
  setCurrentFilterFns: Dispatch<
106
107
  SetStateAction<{
107
- [key: string]: MRT_FilterFn<D>;
108
+ [key: string]: MRT_FilterFn;
108
109
  }>
109
110
  >;
110
111
  setCurrentGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterFn<D>>>;
@@ -123,10 +124,13 @@ export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
123
124
  currentFilterFns: Record<string, string | Function>;
124
125
  currentGlobalFilterFn: Record<string, string | Function>;
125
126
  isDensePadding: boolean;
127
+ isLoading: boolean;
126
128
  isFullScreen: boolean;
129
+ pagination: Partial<PaginationState>;
127
130
  showFilters: boolean;
128
131
  showGlobalFilter: boolean;
129
- pagination: Partial<PaginationState>;
132
+ showProgressBars: boolean;
133
+ showSkeletons: boolean;
130
134
  };
131
135
 
132
136
  export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
@@ -294,18 +298,9 @@ export type MRT_HeaderGroup<D extends Record<string, any> = {}> = Omit<
294
298
 
295
299
  export type MRT_Row<D extends Record<string, any> = {}> = Omit<
296
300
  Row<D>,
297
- | 'getVisibleCells'
298
- | 'getAllCells'
299
- | 'subRows'
300
- | 'original'
301
- | 'getLeftVisibleCells'
302
- | 'getRightVisibleCells'
303
- | 'getCenterVisibleCells'
301
+ 'getVisibleCells' | 'getAllCells' | 'subRows' | 'original'
304
302
  > & {
305
303
  getAllCells: () => MRT_Cell<D>[];
306
- getCenterVisibleCells: () => MRT_Cell<D>[];
307
- getLeftVisibleCells: () => MRT_Cell<D>[];
308
- getRightVisibleCells: () => MRT_Cell<D>[];
309
304
  getVisibleCells: () => MRT_Cell<D>[];
310
305
  subRows?: MRT_Row<D>[];
311
306
  original: D;
@@ -320,7 +315,7 @@ export type MRT_Cell<D extends Record<string, any> = {}> = Omit<
320
315
  };
321
316
 
322
317
  export type MRT_FilterFn<D extends Record<string, any> = {}> =
323
- | FilterFn<D>
318
+ | FilterFn<TableGenerics>
324
319
  | FilterFnOption<D>
325
320
  | MRT_FILTER_OPTION
326
321
  | number
@@ -351,8 +346,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
351
346
  enabledGlobalFilterOptions?: (MRT_FILTER_OPTION | string)[];
352
347
  icons?: Partial<MRT_Icons>;
353
348
  idPrefix?: string;
354
- isLoading?: boolean;
355
- isReloading?: boolean;
356
349
  localization?: Partial<MRT_Localization>;
357
350
  muiLinearProgressProps?:
358
351
  | LinearProgressProps
@@ -760,7 +753,6 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
760
753
 
761
754
  export default <D extends Record<string, any> = {}>({
762
755
  autoResetExpanded = false,
763
- autoResetSorting = false,
764
756
  columnResizeMode = 'onEnd',
765
757
  editingMode = 'row',
766
758
  enableColumnActions = true,
@@ -774,6 +766,7 @@ export default <D extends Record<string, any> = {}>({
774
766
  enableHiding = true,
775
767
  enableMultiRowSelection = true,
776
768
  enablePagination = true,
769
+ enablePinning = false,
777
770
  enableSelectAll = true,
778
771
  enableSorting = true,
779
772
  enableStickyHeader = true,
@@ -793,12 +786,11 @@ export default <D extends Record<string, any> = {}>({
793
786
  }: MaterialReactTableProps<D>) => (
794
787
  <MRT_TableRoot
795
788
  autoResetExpanded={autoResetExpanded}
796
- autoResetSorting={autoResetSorting}
797
789
  columnResizeMode={columnResizeMode}
798
790
  editingMode={editingMode}
799
791
  enableColumnActions={enableColumnActions}
800
- enableColumnResizing={enableColumnResizing}
801
792
  enableColumnFilters={enableColumnFilters}
793
+ enableColumnResizing={enableColumnResizing}
802
794
  enableDensePaddingToggle={enableDensePaddingToggle}
803
795
  enableExpandAll={enableExpandAll}
804
796
  enableFilters={enableFilters}
@@ -807,6 +799,7 @@ export default <D extends Record<string, any> = {}>({
807
799
  enableHiding={enableHiding}
808
800
  enableMultiRowSelection={enableMultiRowSelection}
809
801
  enablePagination={enablePagination}
802
+ enablePinning={enablePinning}
810
803
  enableSelectAll={enableSelectAll}
811
804
  enableSorting={enableSorting}
812
805
  enableStickyHeader={enableStickyHeader}
@@ -4,15 +4,13 @@ import { MRT_TableBodyRow } from './MRT_TableBodyRow';
4
4
  import { MRT_TableInstance } from '..';
5
5
 
6
6
  interface Props {
7
- pinned: 'left' | 'center' | 'right' | 'none';
8
7
  tableInstance: MRT_TableInstance;
9
8
  }
10
9
 
11
- export const MRT_TableBody: FC<Props> = ({ pinned, tableInstance }) => {
10
+ export const MRT_TableBody: FC<Props> = ({ tableInstance }) => {
12
11
  const {
13
12
  getPaginationRowModel,
14
13
  getPrePaginationRowModel,
15
- getTableBodyProps,
16
14
  options: { enablePagination, muiTableBodyProps },
17
15
  } = tableInstance;
18
16
 
@@ -20,22 +18,16 @@ export const MRT_TableBody: FC<Props> = ({ pinned, tableInstance }) => {
20
18
  ? getPaginationRowModel().rows
21
19
  : getPrePaginationRowModel().rows;
22
20
 
23
- const mTableBodyProps =
21
+ const tableBodyProps =
24
22
  muiTableBodyProps instanceof Function
25
23
  ? muiTableBodyProps({ tableInstance })
26
24
  : muiTableBodyProps;
27
25
 
28
- const tableBodyProps = {
29
- ...getTableBodyProps(),
30
- ...mTableBodyProps,
31
- };
32
-
33
26
  return (
34
27
  <TableBody {...tableBodyProps}>
35
28
  {rows.map((row) => (
36
29
  <MRT_TableBodyRow
37
- key={row.getRowProps().key}
38
- pinned={pinned}
30
+ key={row.id}
39
31
  row={row}
40
32
  tableInstance={tableInstance}
41
33
  />
@@ -1,25 +1,27 @@
1
1
  import React, { FC, MouseEvent, useMemo } from 'react';
2
- import { Skeleton, TableCell } from '@mui/material';
2
+ import { alpha, darken, lighten, Skeleton, TableCell } from '@mui/material';
3
3
  import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
4
4
  import type { MRT_Cell, MRT_TableInstance } from '..';
5
5
  import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
6
6
 
7
7
  interface Props {
8
8
  cell: MRT_Cell;
9
+ enableHover?: boolean;
9
10
  tableInstance: MRT_TableInstance;
10
11
  }
11
12
 
12
- export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
13
+ export const MRT_TableBodyCell: FC<Props> = ({
14
+ cell,
15
+ enableHover,
16
+ tableInstance,
17
+ }) => {
13
18
  const {
14
- getIsSomeColumnsPinned,
15
19
  getState,
16
20
  options: {
17
21
  editingMode,
18
22
  enableClickToCopy,
19
23
  enableEditing,
20
- enablePinning,
21
24
  idPrefix,
22
- isLoading,
23
25
  muiTableBodyCellProps,
24
26
  muiTableBodyCellSkeletonProps,
25
27
  onCellClick,
@@ -27,7 +29,13 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
27
29
  setCurrentEditingCell,
28
30
  } = tableInstance;
29
31
 
30
- const { currentEditingCell, currentEditingRow, isDensePadding } = getState();
32
+ const {
33
+ currentEditingCell,
34
+ currentEditingRow,
35
+ isDensePadding,
36
+ isLoading,
37
+ showSkeletons,
38
+ } = getState();
31
39
 
32
40
  const { column, row } = cell;
33
41
 
@@ -42,7 +50,6 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
42
50
  : column.muiTableBodyCellProps;
43
51
 
44
52
  const tableCellProps = {
45
- ...cell.getCellProps(),
46
53
  ...mTableCellBodyProps,
47
54
  ...mcTableCellBodyProps,
48
55
  };
@@ -50,10 +57,10 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
50
57
  const skeletonWidth = useMemo(
51
58
  () =>
52
59
  column.columnDefType === 'display'
53
- ? column.getWidth() / 2
54
- : Math.random() * (column.getWidth() - column.getWidth() / 3) +
55
- column.getWidth() / 3,
56
- [column.columnDefType, column.getWidth()],
60
+ ? column.getSize() / 2
61
+ : Math.random() * (column.getSize() - column.getSize() / 3) +
62
+ column.getSize() / 3,
63
+ [column.columnDefType, column.getSize()],
57
64
  );
58
65
 
59
66
  const isEditable =
@@ -84,6 +91,26 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
84
91
  }
85
92
  };
86
93
 
94
+ const getIsLastLeftPinnedColumn = () => {
95
+ return (
96
+ column.getIsPinned() === 'left' &&
97
+ tableInstance.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
98
+ );
99
+ };
100
+
101
+ const getIsFirstRightPinnedColumn = () => {
102
+ return column.getIsPinned() === 'right' && column.getPinnedIndex() === 0;
103
+ };
104
+
105
+ const getTotalRight = () => {
106
+ return (
107
+ (tableInstance.getRightLeafHeaders().length -
108
+ 1 -
109
+ column.getPinnedIndex()) *
110
+ 150
111
+ );
112
+ };
113
+
87
114
  return (
88
115
  <TableCell
89
116
  onClick={(event: MouseEvent<HTMLTableCellElement>) =>
@@ -91,10 +118,22 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
91
118
  }
92
119
  onDoubleClick={handleDoubleClick}
93
120
  {...tableCellProps}
94
- sx={{
121
+ sx={(theme) => ({
122
+ backgroundColor: column.getIsPinned()
123
+ ? alpha(lighten(theme.palette.background.default, 0.04), 0.95)
124
+ : undefined,
125
+ boxShadow: getIsLastLeftPinnedColumn()
126
+ ? `4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
127
+ : getIsFirstRightPinnedColumn()
128
+ ? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
129
+ : undefined,
95
130
  cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text',
96
- maxWidth: `min(${column.getWidth()}px, fit-content)`,
97
- minWidth: `max(${column.getWidth()}px, ${column.minWidth}px)`,
131
+ left:
132
+ column.getIsPinned() === 'left'
133
+ ? `${column.getStart('left')}px`
134
+ : undefined,
135
+ maxWidth: `min(${column.getSize()}px, fit-content)`,
136
+ minWidth: `max${column.getSize()}px, ${column.minSize}px`,
98
137
  p: isDensePadding
99
138
  ? column.columnDefType === 'display'
100
139
  ? '0 0.5rem'
@@ -106,46 +145,58 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell, tableInstance }) => {
106
145
  column.id === 'mrt-expand'
107
146
  ? `${row.depth + (isDensePadding ? 0.5 : 0.75)}rem`
108
147
  : undefined,
148
+ position: column.getIsPinned() ? 'sticky' : 'relative',
149
+ right:
150
+ column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
109
151
  transition: 'all 0.2s ease-in-out',
110
- whiteSpace:
111
- isDensePadding || (enablePinning && getIsSomeColumnsPinned())
112
- ? 'nowrap'
113
- : 'normal',
114
- width: column.getWidth(),
115
- //@ts-ignore
116
- ...tableCellProps?.sx,
117
- }}
152
+ whiteSpace: isDensePadding ? 'nowrap' : 'normal',
153
+ width: column.getSize(),
154
+ zIndex: column.getIsPinned() ? 1 : undefined,
155
+ '&:hover': {
156
+ backgroundColor: enableHover
157
+ ? theme.palette.mode === 'dark'
158
+ ? `${lighten(theme.palette.background.default, 0.13)} !important`
159
+ : `${darken(theme.palette.background.default, 0.07)} !important`
160
+ : undefined,
161
+ },
162
+ ...(tableCellProps?.sx as any),
163
+ })}
118
164
  >
119
- {isLoading ? (
120
- <Skeleton
121
- animation="wave"
122
- height={20}
123
- width={skeletonWidth}
124
- {...muiTableBodyCellSkeletonProps}
125
- />
126
- ) : column.columnDefType === 'display' ? (
127
- column.Cell?.({ cell, tableInstance })
128
- ) : cell.getIsPlaceholder() ||
129
- (row.getIsGrouped() &&
130
- column.id !==
131
- row.groupingColumnId) ? null : cell.getIsAggregated() ? (
132
- cell.renderAggregatedCell()
133
- ) : isEditing ? (
134
- <MRT_EditCellTextField cell={cell} tableInstance={tableInstance} />
135
- ) : (enableClickToCopy || column.enableClickToCopy) &&
136
- column.enableClickToCopy !== false ? (
137
- <>
138
- <MRT_CopyButton cell={cell} tableInstance={tableInstance}>
165
+ <>
166
+ {isLoading || showSkeletons ? (
167
+ <Skeleton
168
+ animation="wave"
169
+ height={20}
170
+ width={skeletonWidth}
171
+ {...muiTableBodyCellSkeletonProps}
172
+ />
173
+ ) : column.columnDefType === 'display' ? (
174
+ column.Cell?.({ cell, tableInstance })
175
+ ) : cell.getIsPlaceholder() ||
176
+ (row.getIsGrouped() &&
177
+ column.id !==
178
+ row.groupingColumnId) ? null : cell.getIsAggregated() ? (
179
+ cell.renderAggregatedCell()
180
+ ) : isEditing ? (
181
+ <MRT_EditCellTextField cell={cell} tableInstance={tableInstance} />
182
+ ) : (enableClickToCopy || column.enableClickToCopy) &&
183
+ column.enableClickToCopy !== false ? (
184
+ <>
185
+ <MRT_CopyButton cell={cell} tableInstance={tableInstance}>
186
+ <>
187
+ {cell.column?.Cell?.({ cell, tableInstance }) ??
188
+ cell.renderCell()}
189
+ </>
190
+ </MRT_CopyButton>
191
+ {row.getIsGrouped() && <> ({row.subRows?.length})</>}
192
+ </>
193
+ ) : (
194
+ <>
139
195
  {cell.column?.Cell?.({ cell, tableInstance }) ?? cell.renderCell()}
140
- </MRT_CopyButton>
141
- {row.getIsGrouped() && <> ({row.subRows?.length})</>}
142
- </>
143
- ) : (
144
- <>
145
- {cell.column?.Cell?.({ cell, tableInstance }) ?? cell.renderCell()}
146
- {row.getIsGrouped() && <> ({row.subRows?.length})</>}
147
- </>
148
- )}
196
+ {row.getIsGrouped() && <> ({row.subRows?.length})</>}
197
+ </>
198
+ )}
199
+ </>
149
200
  </TableCell>
150
201
  );
151
202
  };
@@ -1,47 +1,24 @@
1
1
  import React, { FC, MouseEvent } from 'react';
2
- import { TableRow } from '@mui/material';
2
+ import { darken, lighten, TableRow } from '@mui/material';
3
3
  import { MRT_TableBodyCell } from './MRT_TableBodyCell';
4
4
  import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
5
5
  import type { MRT_Row, MRT_TableInstance } from '..';
6
6
 
7
7
  interface Props {
8
- pinned: 'left' | 'center' | 'right' | 'none';
9
8
  row: MRT_Row;
10
9
  tableInstance: MRT_TableInstance;
11
10
  }
12
11
 
13
- export const MRT_TableBodyRow: FC<Props> = ({ pinned, row, tableInstance }) => {
12
+ export const MRT_TableBodyRow: FC<Props> = ({ row, tableInstance }) => {
14
13
  const {
15
14
  options: { muiTableBodyRowProps, onRowClick, renderDetailPanel },
16
15
  } = tableInstance;
17
16
 
18
- const {
19
- getCenterVisibleCells,
20
- getIsGrouped,
21
- getIsSelected,
22
- getLeftVisibleCells,
23
- getRightVisibleCells,
24
- getRowProps,
25
- getVisibleCells,
26
- } = row;
27
-
28
- const mTableBodyRowProps =
17
+ const tableRowProps =
29
18
  muiTableBodyRowProps instanceof Function
30
19
  ? muiTableBodyRowProps({ row, tableInstance })
31
20
  : muiTableBodyRowProps;
32
21
 
33
- const tableRowProps = {
34
- ...getRowProps(),
35
- ...mTableBodyRowProps,
36
- };
37
-
38
- const getVisibleCellsMap = {
39
- center: getCenterVisibleCells,
40
- left: getLeftVisibleCells,
41
- none: getVisibleCells,
42
- right: getRightVisibleCells,
43
- };
44
-
45
22
  return (
46
23
  <>
47
24
  <TableRow
@@ -49,18 +26,32 @@ export const MRT_TableBodyRow: FC<Props> = ({ pinned, row, tableInstance }) => {
49
26
  onClick={(event: MouseEvent<HTMLTableRowElement>) =>
50
27
  onRowClick?.({ event, row, tableInstance })
51
28
  }
52
- selected={getIsSelected()}
29
+ selected={row.getIsSelected()}
53
30
  {...tableRowProps}
31
+ sx={(theme) => ({
32
+ backgroundColor: lighten(theme.palette.background.default, 0.06),
33
+ transition: 'all 0.2s ease-in-out',
34
+ '&:hover td': {
35
+ backgroundColor:
36
+ tableRowProps?.hover !== false
37
+ ? theme.palette.mode === 'dark'
38
+ ? `${lighten(theme.palette.background.default, 0.12)}`
39
+ : `${darken(theme.palette.background.default, 0.05)}`
40
+ : undefined,
41
+ },
42
+ ...(tableRowProps?.sx as any),
43
+ })}
54
44
  >
55
- {getVisibleCellsMap[pinned]().map((cell) => (
45
+ {row.getVisibleCells().map((cell) => (
56
46
  <MRT_TableBodyCell
57
47
  cell={cell}
58
- key={cell.getCellProps().key}
48
+ key={cell.id}
49
+ enableHover={tableRowProps?.hover !== false}
59
50
  tableInstance={tableInstance}
60
51
  />
61
52
  ))}
62
53
  </TableRow>
63
- {renderDetailPanel && !getIsGrouped() && (
54
+ {renderDetailPanel && !row.getIsGrouped() && (
64
55
  <MRT_TableDetailPanel row={row} tableInstance={tableInstance} />
65
56
  )}
66
57
  </>