material-react-table 0.6.10 → 0.7.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 (103) hide show
  1. package/dist/MaterialReactTable.d.ts +142 -82
  2. package/dist/body/MRT_TableBody.d.ts +3 -0
  3. package/dist/body/MRT_TableBodyCell.d.ts +2 -11
  4. package/dist/body/MRT_TableBodyRow.d.ts +3 -1
  5. package/dist/body/MRT_TableDetailPanel.d.ts +2 -1
  6. package/dist/buttons/MRT_CopyButton.d.ts +4 -2
  7. package/dist/buttons/MRT_EditActionButtons.d.ts +2 -1
  8. package/dist/buttons/MRT_ExpandAllButton.d.ts +2 -0
  9. package/dist/buttons/MRT_ExpandButton.d.ts +2 -1
  10. package/dist/buttons/MRT_FullScreenToggleButton.d.ts +2 -0
  11. package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +2 -0
  12. package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +3 -2
  13. package/dist/buttons/MRT_ToggleDensePaddingButton.d.ts +2 -0
  14. package/dist/buttons/MRT_ToggleFiltersButton.d.ts +2 -0
  15. package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +2 -1
  16. package/dist/buttons/MRT_ToggleSearchButton.d.ts +2 -0
  17. package/dist/footer/MRT_TableFooter.d.ts +3 -0
  18. package/dist/footer/MRT_TableFooterCell.d.ts +3 -2
  19. package/dist/footer/MRT_TableFooterRow.d.ts +2 -1
  20. package/dist/head/MRT_TableHead.d.ts +3 -0
  21. package/dist/head/MRT_TableHeadCell.d.ts +4 -18
  22. package/dist/head/MRT_TableHeadRow.d.ts +2 -1
  23. package/dist/icons.d.ts +1 -1
  24. package/dist/inputs/MRT_EditCellTextField.d.ts +2 -1
  25. package/dist/inputs/MRT_FilterTextField.d.ts +3 -2
  26. package/dist/inputs/MRT_SearchTextField.d.ts +2 -0
  27. package/dist/inputs/MRT_SelectCheckbox.d.ts +2 -1
  28. package/dist/localization.d.ts +7 -2
  29. package/dist/material-react-table.cjs.development.js +2142 -1729
  30. package/dist/material-react-table.cjs.development.js.map +1 -1
  31. package/dist/material-react-table.cjs.production.min.js +1 -1
  32. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  33. package/dist/material-react-table.esm.js +2143 -1730
  34. package/dist/material-react-table.esm.js.map +1 -1
  35. package/dist/menus/MRT_ColumnActionMenu.d.ts +3 -2
  36. package/dist/menus/MRT_FilterTypeMenu.d.ts +4 -3
  37. package/dist/menus/MRT_RowActionMenu.d.ts +3 -2
  38. package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +2 -0
  39. package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +2 -1
  40. package/dist/table/MRT_Table.d.ts +3 -0
  41. package/dist/table/MRT_TableContainer.d.ts +2 -0
  42. package/dist/table/MRT_TablePaper.d.ts +7 -0
  43. package/dist/table/MRT_TableRoot.d.ts +3 -0
  44. package/dist/toolbar/MRT_LinearProgressBar.d.ts +2 -0
  45. package/dist/toolbar/MRT_TablePagination.d.ts +2 -0
  46. package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +2 -0
  47. package/dist/toolbar/MRT_ToolbarBottom.d.ts +2 -0
  48. package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +2 -0
  49. package/dist/toolbar/MRT_ToolbarTop.d.ts +4 -2
  50. package/dist/utils.d.ts +12 -2
  51. package/package.json +27 -28
  52. package/src/MaterialReactTable.tsx +298 -242
  53. package/src/body/MRT_TableBody.tsx +25 -21
  54. package/src/body/MRT_TableBodyCell.tsx +73 -58
  55. package/src/body/MRT_TableBodyRow.tsx +35 -74
  56. package/src/body/MRT_TableDetailPanel.tsx +16 -14
  57. package/src/buttons/MRT_CopyButton.tsx +14 -7
  58. package/src/buttons/MRT_EditActionButtons.tsx +13 -12
  59. package/src/buttons/MRT_ExpandAllButton.tsx +24 -9
  60. package/src/buttons/MRT_ExpandButton.tsx +21 -14
  61. package/src/buttons/MRT_FullScreenToggleButton.tsx +18 -11
  62. package/src/buttons/MRT_ShowHideColumnsButton.tsx +18 -7
  63. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +17 -9
  64. package/src/buttons/MRT_ToggleDensePaddingButton.tsx +18 -11
  65. package/src/buttons/MRT_ToggleFiltersButton.tsx +16 -9
  66. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +26 -21
  67. package/src/buttons/MRT_ToggleSearchButton.tsx +18 -11
  68. package/src/footer/MRT_TableFooter.tsx +23 -7
  69. package/src/footer/MRT_TableFooterCell.tsx +32 -24
  70. package/src/footer/MRT_TableFooterRow.tsx +20 -38
  71. package/src/head/MRT_TableHead.tsx +23 -7
  72. package/src/head/MRT_TableHeadCell.tsx +201 -152
  73. package/src/head/MRT_TableHeadRow.tsx +15 -103
  74. package/src/icons.ts +3 -3
  75. package/src/inputs/MRT_EditCellTextField.tsx +23 -24
  76. package/src/inputs/MRT_FilterTextField.tsx +51 -30
  77. package/src/inputs/MRT_SearchTextField.tsx +38 -21
  78. package/src/inputs/MRT_SelectCheckbox.tsx +34 -24
  79. package/src/localization.ts +13 -2
  80. package/src/menus/MRT_ColumnActionMenu.tsx +129 -69
  81. package/src/menus/MRT_FilterTypeMenu.tsx +28 -22
  82. package/src/menus/MRT_RowActionMenu.tsx +16 -11
  83. package/src/menus/MRT_ShowHideColumnsMenu.tsx +52 -20
  84. package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +28 -17
  85. package/src/table/MRT_Table.tsx +24 -14
  86. package/src/table/MRT_TableContainer.tsx +109 -44
  87. package/src/table/MRT_TablePaper.tsx +61 -0
  88. package/src/table/MRT_TableRoot.tsx +236 -0
  89. package/src/toolbar/MRT_LinearProgressBar.tsx +9 -6
  90. package/src/toolbar/MRT_TablePagination.tsx +28 -18
  91. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +31 -19
  92. package/src/toolbar/MRT_ToolbarBottom.tsx +31 -20
  93. package/src/toolbar/MRT_ToolbarInternalButtons.tsx +29 -16
  94. package/src/toolbar/MRT_ToolbarTop.tsx +34 -27
  95. package/src/utils.ts +37 -8
  96. package/dist/head/MRT_TableHeadCellActions.d.ts +0 -5
  97. package/dist/table/MRT_TableSpacerCell.d.ts +0 -6
  98. package/dist/useMRT.d.ts +0 -28
  99. package/src/@types/faker.d.ts +0 -4
  100. package/src/@types/react-table-config.d.ts +0 -53
  101. package/src/head/MRT_TableHeadCellActions.tsx +0 -29
  102. package/src/table/MRT_TableSpacerCell.tsx +0 -20
  103. package/src/useMRT.tsx +0 -226
@@ -1,15 +1,22 @@
1
1
  import React, { FC, MouseEvent, useState } from 'react';
2
2
  import { IconButton, Tooltip, IconButtonProps } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
3
  import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
4
+ import { MRT_TableInstance } from '..';
5
5
 
6
- interface Props extends IconButtonProps {}
6
+ interface Props extends IconButtonProps {
7
+ tableInstance: MRT_TableInstance;
8
+ }
7
9
 
8
- export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
10
+ export const MRT_ShowHideColumnsButton: FC<Props> = ({
11
+ tableInstance,
12
+ ...rest
13
+ }) => {
9
14
  const {
10
- icons: { ViewColumnIcon },
11
- localization,
12
- } = useMRT();
15
+ options: {
16
+ icons: { ViewColumnIcon },
17
+ localization,
18
+ },
19
+ } = tableInstance;
13
20
 
14
21
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
15
22
 
@@ -29,7 +36,11 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
29
36
  <ViewColumnIcon />
30
37
  </IconButton>
31
38
  </Tooltip>
32
- <MRT_ShowHideColumnsMenu anchorEl={anchorEl} setAnchorEl={setAnchorEl} />
39
+ <MRT_ShowHideColumnsMenu
40
+ anchorEl={anchorEl}
41
+ setAnchorEl={setAnchorEl}
42
+ tableInstance={tableInstance}
43
+ />
33
44
  </>
34
45
  );
35
46
  };
@@ -1,19 +1,26 @@
1
1
  import React, { FC, MouseEvent, useState } from 'react';
2
2
  import { IconButton, Tooltip } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
3
  import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
5
- import type { MRT_HeaderGroup } from '..';
4
+ import type { MRT_Header, MRT_TableInstance } from '..';
6
5
 
7
6
  interface Props {
8
- column: MRT_HeaderGroup;
7
+ header: MRT_Header;
8
+ tableInstance: MRT_TableInstance;
9
9
  }
10
10
 
11
- export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
11
+ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
12
+ header,
13
+ tableInstance,
14
+ }) => {
12
15
  const {
13
- icons: { MoreVertIcon },
14
- localization,
15
- muiTableHeadCellColumnActionsButtonProps,
16
- } = useMRT();
16
+ options: {
17
+ icons: { MoreVertIcon },
18
+ localization,
19
+ muiTableHeadCellColumnActionsButtonProps,
20
+ },
21
+ } = tableInstance;
22
+
23
+ const { column } = header;
17
24
 
18
25
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
19
26
 
@@ -70,8 +77,9 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
70
77
  </Tooltip>
71
78
  <MRT_ColumnActionMenu
72
79
  anchorEl={anchorEl}
73
- column={column}
80
+ header={header}
74
81
  setAnchorEl={setAnchorEl}
82
+ tableInstance={tableInstance}
75
83
  />
76
84
  </>
77
85
  );
@@ -1,28 +1,35 @@
1
1
  import React, { FC } from 'react';
2
2
  import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
3
- import { useMRT } from '../useMRT';
3
+ import { MRT_TableInstance } from '..';
4
4
 
5
- interface Props extends IconButtonProps {}
5
+ interface Props extends IconButtonProps {
6
+ tableInstance: MRT_TableInstance;
7
+ }
6
8
 
7
- export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
9
+ export const MRT_ToggleDensePaddingButton: FC<Props> = ({
10
+ tableInstance,
11
+ ...rest
12
+ }) => {
8
13
  const {
9
- setDensePadding,
10
- localization,
11
- icons: { DensityMediumIcon, DensitySmallIcon },
12
- tableInstance: {
13
- state: { densePadding },
14
+ getState,
15
+ options: {
16
+ icons: { DensityMediumIcon, DensitySmallIcon },
17
+ localization,
18
+ setIsDensePadding,
14
19
  },
15
- } = useMRT();
20
+ } = tableInstance;
21
+
22
+ const { isDensePadding } = getState();
16
23
 
17
24
  return (
18
25
  <Tooltip arrow title={localization.toggleDensePadding}>
19
26
  <IconButton
20
27
  aria-label={localization.toggleDensePadding}
21
- onClick={() => setDensePadding(!densePadding)}
28
+ onClick={() => setIsDensePadding(!isDensePadding)}
22
29
  size="small"
23
30
  {...rest}
24
31
  >
25
- {densePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
32
+ {isDensePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
26
33
  </IconButton>
27
34
  </Tooltip>
28
35
  );
@@ -1,18 +1,25 @@
1
1
  import React, { FC } from 'react';
2
2
  import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
3
- import { useMRT } from '../useMRT';
3
+ import { MRT_TableInstance } from '..';
4
4
 
5
- interface Props extends IconButtonProps {}
5
+ interface Props extends IconButtonProps {
6
+ tableInstance: MRT_TableInstance;
7
+ }
6
8
 
7
- export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
9
+ export const MRT_ToggleFiltersButton: FC<Props> = ({
10
+ tableInstance,
11
+ ...rest
12
+ }) => {
8
13
  const {
9
- icons: { FilterListIcon, FilterListOffIcon },
10
- localization,
11
- setShowFilters,
12
- tableInstance: {
13
- state: { showFilters },
14
+ getState,
15
+ options: {
16
+ icons: { FilterListIcon, FilterListOffIcon },
17
+ localization,
18
+ setShowFilters,
14
19
  },
15
- } = useMRT();
20
+ } = tableInstance;
21
+
22
+ const { showFilters } = getState();
16
23
 
17
24
  return (
18
25
  <Tooltip arrow title={localization.showHideFilters}>
@@ -1,16 +1,14 @@
1
1
  import React, { FC, MouseEvent, useState } from 'react';
2
- import { IconButton, TableCell, Tooltip } from '@mui/material';
3
- import { useMRT } from '../useMRT';
2
+ import { IconButton, Tooltip } from '@mui/material';
4
3
  import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
5
4
  import { MRT_EditActionButtons } from './MRT_EditActionButtons';
6
- import type { MRT_Row } from '..';
7
- import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
5
+ import type { MRT_Row, MRT_TableInstance } from '..';
8
6
 
9
7
  const commonIconButtonStyles = {
8
+ height: '2rem',
9
+ ml: '10px',
10
10
  opacity: 0.5,
11
11
  transition: 'opacity 0.2s',
12
- marginRight: '2px',
13
- height: '2rem',
14
12
  width: '2rem',
15
13
  '&:hover': {
16
14
  opacity: 1,
@@ -19,18 +17,26 @@ const commonIconButtonStyles = {
19
17
 
20
18
  interface Props {
21
19
  row: MRT_Row;
20
+ tableInstance: MRT_TableInstance;
22
21
  }
23
22
 
24
- export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
23
+ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({
24
+ row,
25
+ tableInstance,
26
+ }) => {
25
27
  const {
26
- enableRowEditing,
27
- icons: { EditIcon, MoreHorizIcon },
28
- localization,
29
- renderRowActionMenuItems,
30
- renderRowActions,
31
- setCurrentEditingRow,
32
- tableInstance,
33
- } = useMRT();
28
+ getState,
29
+ options: {
30
+ enableRowEditing,
31
+ icons: { EditIcon, MoreHorizIcon },
32
+ localization,
33
+ renderRowActionMenuItems,
34
+ renderRowActions,
35
+ setCurrentEditingRow,
36
+ },
37
+ } = tableInstance;
38
+
39
+ const { currentEditingRow } = getState();
34
40
 
35
41
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
36
42
 
@@ -46,13 +52,11 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
46
52
  };
47
53
 
48
54
  return (
49
- <TableCell
50
- sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
51
- >
55
+ <>
52
56
  {renderRowActions ? (
53
57
  <>{renderRowActions(row, tableInstance)}</>
54
- ) : row.id === tableInstance.state.currentEditingRow?.id ? (
55
- <MRT_EditActionButtons row={row} />
58
+ ) : row.id === currentEditingRow?.id ? (
59
+ <MRT_EditActionButtons row={row} tableInstance={tableInstance} />
56
60
  ) : !renderRowActionMenuItems && enableRowEditing ? (
57
61
  <Tooltip placement="right" arrow title={localization.edit}>
58
62
  <IconButton sx={commonIconButtonStyles} onClick={handleEdit}>
@@ -81,9 +85,10 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
81
85
  handleEdit={handleEdit}
82
86
  row={row}
83
87
  setAnchorEl={setAnchorEl}
88
+ tableInstance={tableInstance}
84
89
  />
85
90
  </>
86
91
  ) : null}
87
- </TableCell>
92
+ </>
88
93
  );
89
94
  };
@@ -1,20 +1,27 @@
1
1
  import React, { FC } from 'react';
2
2
  import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
3
- import { useMRT } from '../useMRT';
3
+ import { MRT_TableInstance } from '..';
4
4
 
5
- interface Props extends IconButtonProps {}
5
+ interface Props extends IconButtonProps {
6
+ tableInstance: MRT_TableInstance;
7
+ }
6
8
 
7
- export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
9
+ export const MRT_ToggleSearchButton: FC<Props> = ({
10
+ tableInstance,
11
+ ...rest
12
+ }) => {
8
13
  const {
9
- icons: { SearchIcon, SearchOffIcon },
10
- idPrefix,
11
- localization,
12
- muiSearchTextFieldProps,
13
- setShowSearch,
14
- tableInstance: {
15
- state: { showSearch },
14
+ getState,
15
+ options: {
16
+ icons: { SearchIcon, SearchOffIcon },
17
+ idPrefix,
18
+ localization,
19
+ muiSearchTextFieldProps,
20
+ setShowSearch,
16
21
  },
17
- } = useMRT();
22
+ } = tableInstance;
23
+
24
+ const { showSearch } = getState();
18
25
 
19
26
  const handleToggleSearch = () => {
20
27
  setShowSearch(!showSearch);
@@ -1,25 +1,41 @@
1
1
  import React, { FC } from 'react';
2
2
  import { TableFooter } from '@mui/material';
3
3
  import { MRT_TableFooterRow } from './MRT_TableFooterRow';
4
- import { useMRT } from '../useMRT';
5
- import type { MRT_HeaderGroup } from '..';
4
+ import type { MRT_HeaderGroup, MRT_TableInstance } from '..';
6
5
 
7
- interface Props {}
6
+ interface Props {
7
+ pinned: 'left' | 'center' | 'right' | 'none';
8
+ tableInstance: MRT_TableInstance;
9
+ }
8
10
 
9
- export const MRT_TableFooter: FC<Props> = () => {
10
- const { muiTableFooterProps, tableInstance } = useMRT();
11
+ export const MRT_TableFooter: FC<Props> = ({ pinned, tableInstance }) => {
12
+ const {
13
+ getCenterFooterGroups,
14
+ getFooterGroups,
15
+ getLeftFooterGroups,
16
+ getRightFooterGroups,
17
+ options: { muiTableFooterProps },
18
+ } = tableInstance;
11
19
 
12
20
  const tableFooterProps =
13
21
  muiTableFooterProps instanceof Function
14
22
  ? muiTableFooterProps(tableInstance)
15
23
  : muiTableFooterProps;
16
24
 
25
+ const getFooterGroupsMap = {
26
+ center: getCenterFooterGroups,
27
+ left: getLeftFooterGroups,
28
+ none: getFooterGroups,
29
+ right: getRightFooterGroups,
30
+ };
31
+
17
32
  return (
18
33
  <TableFooter {...tableFooterProps}>
19
- {tableInstance.footerGroups.map((footerGroup: MRT_HeaderGroup) => (
34
+ {getFooterGroupsMap[pinned]().map((footerGroup) => (
20
35
  <MRT_TableFooterRow
36
+ footerGroup={footerGroup as MRT_HeaderGroup}
21
37
  key={footerGroup.getFooterGroupProps().key}
22
- footerGroup={footerGroup}
38
+ tableInstance={tableInstance}
23
39
  />
24
40
  ))}
25
41
  </TableFooter>
@@ -1,22 +1,21 @@
1
1
  import React, { FC } from 'react';
2
- import { TableCell } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
- import type { MRT_HeaderGroup } from '..';
2
+ import { alpha, TableCell } from '@mui/material';
3
+ import type { MRT_Header, MRT_TableInstance } from '..';
5
4
 
6
5
  interface Props {
7
- column: MRT_HeaderGroup;
6
+ footer: MRT_Header;
7
+ tableInstance: MRT_TableInstance;
8
8
  }
9
9
 
10
- export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
10
+ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
11
11
  const {
12
- muiTableFooterCellProps,
13
- enableColumnResizing,
14
- tableInstance: {
15
- state: { densePadding },
16
- },
17
- } = useMRT();
12
+ getState,
13
+ options: { muiTableFooterCellProps, enableColumnResizing },
14
+ } = tableInstance;
18
15
 
19
- const isParentHeader = !!column?.columns?.length;
16
+ const { isDensePadding } = getState();
17
+
18
+ const { column } = footer;
20
19
 
21
20
  const mTableFooterCellProps =
22
21
  muiTableFooterCellProps instanceof Function
@@ -29,30 +28,39 @@ export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
29
28
  : column.muiTableFooterCellProps;
30
29
 
31
30
  const tableCellProps = {
31
+ ...footer.getFooterProps(),
32
32
  ...mTableFooterCellProps,
33
33
  ...mcTableFooterCellProps,
34
- ...column.getFooterProps(),
35
- style: {
36
- ...column.getFooterProps().style,
37
- ...mTableFooterCellProps?.style,
38
- ...mcTableFooterCellProps?.style,
39
- },
40
34
  };
41
35
 
42
36
  return (
43
37
  <TableCell
44
- align={isParentHeader ? 'center' : 'left'}
38
+ align={column.columnDefType === 'group' ? 'center' : 'left'}
45
39
  variant="head"
46
40
  {...tableCellProps}
47
- sx={{
41
+ //@ts-ignore
42
+ sx={(theme) => ({
43
+ backgroundColor: theme.palette.background.default,
44
+ backgroundImage: `linear-gradient(${alpha(
45
+ theme.palette.common.white,
46
+ 0.05,
47
+ )},${alpha(theme.palette.common.white, 0.05)})`,
48
48
  fontWeight: 'bold',
49
- verticalAlign: 'text-top',
50
- p: densePadding ? '0.5rem' : '1rem',
49
+ p: isDensePadding ? '0.5rem' : '1rem',
51
50
  transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
51
+ verticalAlign: 'text-top',
52
+ //@ts-ignore
52
53
  ...tableCellProps?.sx,
53
- }}
54
+ })}
54
55
  >
55
- {column.render('Footer')}
56
+ {footer.isPlaceholder
57
+ ? null
58
+ : column.Footer?.({
59
+ footer,
60
+ tableInstance,
61
+ }) ??
62
+ column.footer ??
63
+ null}
56
64
  </TableCell>
57
65
  );
58
66
  };
@@ -1,30 +1,28 @@
1
1
  import React, { FC } from 'react';
2
2
  import { TableRow } from '@mui/material';
3
3
  import { MRT_TableFooterCell } from './MRT_TableFooterCell';
4
- import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
5
- import { useMRT } from '../useMRT';
6
- import type { MRT_HeaderGroup } from '..';
4
+ import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
7
5
 
8
6
  interface Props {
9
7
  footerGroup: MRT_HeaderGroup;
8
+ tableInstance: MRT_TableInstance;
10
9
  }
11
10
 
12
- export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
11
+ export const MRT_TableFooterRow: FC<Props> = ({
12
+ footerGroup,
13
+ tableInstance,
14
+ }) => {
13
15
  const {
14
- anyRowsCanExpand,
15
- columns,
16
- enableRowActions,
17
- enableRowEditing,
18
- enableRowNumbers,
19
- enableSelection,
20
- muiTableFooterRowProps,
21
- positionActionsColumn,
22
- renderDetailPanel,
23
- tableInstance,
24
- } = useMRT();
16
+ options: { muiTableFooterRowProps },
17
+ } = tableInstance;
25
18
 
26
- //if no content in row, skip row
27
- if (!columns?.some((c) => c.Footer)) return null;
19
+ // if no content in row, skip row
20
+ if (
21
+ !footerGroup.headers?.some(
22
+ (h) => h.column.columnDef.footer || h.column.Footer,
23
+ )
24
+ )
25
+ return null;
28
26
 
29
27
  const mTableFooterRowProps =
30
28
  muiTableFooterRowProps instanceof Function
@@ -32,35 +30,19 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
32
30
  : muiTableFooterRowProps;
33
31
 
34
32
  const tableRowProps = {
35
- ...mTableFooterRowProps,
36
33
  ...footerGroup.getFooterGroupProps(),
37
- style: {
38
- ...footerGroup.getFooterGroupProps().style,
39
- ...mTableFooterRowProps?.style,
40
- },
34
+ ...mTableFooterRowProps,
41
35
  };
42
36
 
43
37
  return (
44
38
  <TableRow {...tableRowProps}>
45
- {enableRowNumbers && <MRT_TableSpacerCell />}
46
- {(enableRowActions || enableRowEditing) &&
47
- positionActionsColumn === 'first' && <MRT_TableSpacerCell />}
48
- {(anyRowsCanExpand || renderDetailPanel) && (
49
- <MRT_TableSpacerCell
50
- width={`${
51
- renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
52
- }rem`}
53
- />
54
- )}
55
- {enableSelection && <MRT_TableSpacerCell width="1rem" />}
56
- {footerGroup.headers.map((column: MRT_HeaderGroup) => (
39
+ {footerGroup.headers.map((footer: MRT_Header) => (
57
40
  <MRT_TableFooterCell
58
- key={column.getFooterProps().key}
59
- column={column}
41
+ footer={footer}
42
+ key={footer.getFooterProps().key}
43
+ tableInstance={tableInstance}
60
44
  />
61
45
  ))}
62
- {(enableRowActions || enableRowEditing) &&
63
- positionActionsColumn === 'last' && <MRT_TableSpacerCell />}
64
46
  </TableRow>
65
47
  );
66
48
  };
@@ -1,25 +1,41 @@
1
1
  import React, { FC } from 'react';
2
2
  import { TableHead } from '@mui/material';
3
3
  import { MRT_TableHeadRow } from './MRT_TableHeadRow';
4
- import { useMRT } from '../useMRT';
5
- import type { MRT_HeaderGroup } from '..';
4
+ import type { MRT_HeaderGroup, MRT_TableInstance } from '..';
6
5
 
7
- interface Props {}
6
+ interface Props {
7
+ pinned: 'left' | 'center' | 'right' | 'none';
8
+ tableInstance: MRT_TableInstance;
9
+ }
8
10
 
9
- export const MRT_TableHead: FC<Props> = () => {
10
- const { tableInstance, muiTableHeadProps } = useMRT();
11
+ export const MRT_TableHead: FC<Props> = ({ pinned, tableInstance }) => {
12
+ const {
13
+ getCenterHeaderGroups,
14
+ getHeaderGroups,
15
+ getLeftHeaderGroups,
16
+ getRightHeaderGroups,
17
+ options: { muiTableHeadProps },
18
+ } = tableInstance;
11
19
 
12
20
  const tableHeadProps =
13
21
  muiTableHeadProps instanceof Function
14
22
  ? muiTableHeadProps(tableInstance)
15
23
  : muiTableHeadProps;
16
24
 
25
+ const getHeaderGroupsMap = {
26
+ center: getCenterHeaderGroups,
27
+ left: getLeftHeaderGroups,
28
+ none: getHeaderGroups,
29
+ right: getRightHeaderGroups,
30
+ };
31
+
17
32
  return (
18
33
  <TableHead {...tableHeadProps}>
19
- {tableInstance.headerGroups.map((headerGroup: MRT_HeaderGroup) => (
34
+ {getHeaderGroupsMap[pinned]().map((headerGroup) => (
20
35
  <MRT_TableHeadRow
36
+ headerGroup={headerGroup as MRT_HeaderGroup}
21
37
  key={headerGroup.getHeaderGroupProps().key}
22
- headerGroup={headerGroup}
38
+ tableInstance={tableInstance}
23
39
  />
24
40
  ))}
25
41
  </TableHead>