material-react-table 0.4.8 → 0.5.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 (42) hide show
  1. package/dist/MaterialReactTable.d.ts +6 -5
  2. package/dist/body/MRT_TableBodyCell.d.ts +10 -3
  3. package/dist/body/MRT_TableBodyRow.d.ts +1 -16
  4. package/dist/head/MRT_TableHeadCell.d.ts +8 -4
  5. package/dist/material-react-table.cjs.development.js +400 -471
  6. package/dist/material-react-table.cjs.development.js.map +1 -1
  7. package/dist/material-react-table.cjs.production.min.js +1 -1
  8. package/dist/material-react-table.cjs.production.min.js.map +1 -1
  9. package/dist/material-react-table.esm.js +404 -475
  10. package/dist/material-react-table.esm.js.map +1 -1
  11. package/package.json +4 -4
  12. package/src/MaterialReactTable.tsx +8 -7
  13. package/src/body/MRT_TableBody.tsx +6 -7
  14. package/src/body/MRT_TableBodyCell.tsx +20 -11
  15. package/src/body/MRT_TableBodyRow.tsx +17 -14
  16. package/src/body/MRT_TableDetailPanel.tsx +9 -26
  17. package/src/buttons/MRT_EditActionButtons.tsx +3 -8
  18. package/src/buttons/MRT_ExpandAllButton.tsx +5 -5
  19. package/src/buttons/MRT_ExpandButton.tsx +10 -10
  20. package/src/buttons/MRT_ShowHideColumnsButton.tsx +9 -9
  21. package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +11 -12
  22. package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +9 -8
  23. package/src/footer/MRT_TableFooterCell.tsx +10 -17
  24. package/src/footer/MRT_TableFooterRow.tsx +1 -1
  25. package/src/head/MRT_TableHeadCell.tsx +47 -54
  26. package/src/head/MRT_TableHeadCellActions.tsx +5 -4
  27. package/src/head/MRT_TableHeadRow.tsx +5 -4
  28. package/src/inputs/MRT_SearchTextField.tsx +2 -11
  29. package/src/inputs/MRT_SelectCheckbox.tsx +4 -4
  30. package/src/menus/MRT_ColumnActionMenu.tsx +17 -6
  31. package/src/menus/MRT_RowActionMenu.tsx +2 -7
  32. package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
  33. package/src/table/MRT_Table.tsx +1 -1
  34. package/src/table/MRT_TableContainer.tsx +17 -41
  35. package/src/table/MRT_TableSpacerCell.tsx +4 -3
  36. package/src/toolbar/MRT_TablePagination.tsx +6 -1
  37. package/src/toolbar/MRT_ToolbarAlertBanner.tsx +19 -29
  38. package/src/toolbar/MRT_ToolbarBottom.tsx +23 -20
  39. package/src/toolbar/MRT_ToolbarInternalButtons.tsx +13 -12
  40. package/src/toolbar/MRT_ToolbarTop.tsx +38 -35
  41. package/dist/table/MRT_TableButtonCell.d.ts +0 -3
  42. package/src/table/MRT_TableButtonCell.tsx +0 -9
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.4.8",
2
+ "version": "0.5.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 DataGrid, written from the ground up in TypeScript.",
@@ -61,8 +61,8 @@
61
61
  "@emotion/styled": "^11.8.1",
62
62
  "@etchteam/storybook-addon-status": "^4.2.0",
63
63
  "@faker-js/faker": "^6.0.0-alpha.7",
64
- "@mui/icons-material": "^5.4.2",
65
- "@mui/material": "^5.4.3",
64
+ "@mui/icons-material": "^5.4.4",
65
+ "@mui/material": "^5.4.4",
66
66
  "@size-limit/preset-small-lib": "^7.0.8",
67
67
  "@storybook/addon-a11y": "^6.4.19",
68
68
  "@storybook/addon-actions": "^6.4.19",
@@ -89,7 +89,7 @@
89
89
  "storybook-dark-mode": "^1.0.9",
90
90
  "tsdx": "^0.14.1",
91
91
  "tslib": "^2.3.1",
92
- "typescript": "^4.5.5"
92
+ "typescript": "^4.6.2"
93
93
  },
94
94
  "peerDependencies": {
95
95
  "@emotion/react": ">=11",
@@ -84,7 +84,11 @@ export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
84
84
  UseResizeColumnsOptions<D> &
85
85
  UseRowSelectOptions<D> &
86
86
  UseRowStateOptions<D> &
87
- UseSortByOptions<D> & {};
87
+ UseSortByOptions<D> & {
88
+ columns: (Column<D> & MRT_ColumnInterface)[];
89
+ data: D[];
90
+ initialState?: Partial<MRT_TableState>;
91
+ };
88
92
 
89
93
  export type MRT_TableInstance<D extends {} = {}> = TableInstance<D> &
90
94
  UseTableInstanceProps<D> &
@@ -194,8 +198,7 @@ export type MRT_TableState<D extends {} = {}> = TableState<D> &
194
198
  showSearchTextField?: boolean;
195
199
  };
196
200
 
197
- export type MaterialReactTableProps<D extends {} = {}> = MRT_TableOptions<D> &
198
- UseTableOptions<D> &
201
+ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
199
202
  UseExpandedOptions<D> &
200
203
  UseFiltersOptions<D> &
201
204
  UseGlobalFiltersOptions<D> &
@@ -204,9 +207,8 @@ export type MaterialReactTableProps<D extends {} = {}> = MRT_TableOptions<D> &
204
207
  UseResizeColumnsOptions<D> &
205
208
  UseRowSelectOptions<D> &
206
209
  UseRowStateOptions<D> &
207
- UseSortByOptions<D> & {
208
- columns: (Column<D> & MRT_ColumnInterface)[];
209
- data: D[];
210
+ UseSortByOptions<D> &
211
+ MRT_TableOptions<D> & {
210
212
  disableColumnActions?: boolean;
211
213
  disableColumnHiding?: boolean;
212
214
  disableDensePaddingToggle?: boolean;
@@ -226,7 +228,6 @@ export type MaterialReactTableProps<D extends {} = {}> = MRT_TableOptions<D> &
226
228
  hideToolbarInternalActions?: boolean;
227
229
  hideToolbarTop?: boolean;
228
230
  icons?: Partial<MRT_Icons>;
229
- initialState?: Partial<MRT_TableState>;
230
231
  isFetching?: boolean;
231
232
  isLoading?: boolean;
232
233
  localization?: Partial<MRT_Localization>;
@@ -1,13 +1,9 @@
1
1
  import React, { FC } from 'react';
2
- import { styled, TableBody as MuiTableBody } from '@mui/material';
2
+ import { TableBody } from '@mui/material';
3
3
  import { MRT_TableBodyRow } from './MRT_TableBodyRow';
4
4
  import { useMRT } from '../useMRT';
5
5
  import { MRT_Row } from '..';
6
6
 
7
- const TableBody = styled(MuiTableBody)({
8
- overflowY: 'hidden',
9
- });
10
-
11
7
  interface Props {}
12
8
 
13
9
  export const MRT_TableBody: FC<Props> = () => {
@@ -20,12 +16,15 @@ export const MRT_TableBody: FC<Props> = () => {
20
16
  ...tableInstance.getTableBodyProps(),
21
17
  style: {
22
18
  ...tableInstance.getTableBodyProps().style,
23
- ...(muiTableBodyProps?.style ?? {}),
19
+ ...muiTableBodyProps?.style,
24
20
  },
25
21
  };
26
22
 
27
23
  return (
28
- <TableBody {...tableBodyProps}>
24
+ <TableBody
25
+ {...tableBodyProps}
26
+ sx={{ overflowY: 'hidden', ...tableBodyProps?.sx }}
27
+ >
29
28
  {rows.map((row: MRT_Row) => {
30
29
  tableInstance.prepareRow(row);
31
30
  return <MRT_TableBodyRow key={row.getRowProps().key} row={row} />;
@@ -1,16 +1,20 @@
1
1
  import React, { FC, MouseEvent } from 'react';
2
- import { styled, TableCell as MuiTableCell } from '@mui/material';
2
+ import { TableCell, TableCellProps } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
5
5
  import { MRT_Cell } from '..';
6
6
 
7
- export const MRT_StyledTableBodyCell = styled(MuiTableCell, {
8
- shouldForwardProp: (prop) => prop !== 'densePadding',
9
- })<{ densePadding?: boolean }>(({ densePadding }) => ({
10
- padding: densePadding ? '0.5rem' : '1rem',
7
+ export const commonTableBodyCellStyles = (densePadding: boolean) => ({
8
+ p: densePadding ? '0.5rem' : '1rem',
11
9
  transition: 'all 0.2s ease-in-out',
12
10
  whiteSpace: densePadding ? 'nowrap' : 'normal',
13
- }));
11
+ });
12
+
13
+ export const commonTableBodyButtonCellStyles = (densePadding: boolean) => ({
14
+ p: densePadding ? '1px' : '0.6rem',
15
+ textAlign: 'center',
16
+ transition: 'all 0.2s ease-in-out',
17
+ });
14
18
 
15
19
  interface Props {
16
20
  cell: MRT_Cell;
@@ -40,18 +44,23 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
40
44
  ...cell.getCellProps(),
41
45
  style: {
42
46
  ...cell.getCellProps().style,
43
- ...(mTableCellBodyProps?.style ?? {}),
44
- ...(mcTableCellBodyProps?.style ?? {}),
47
+ ...mTableCellBodyProps?.style,
48
+ ...mcTableCellBodyProps?.style,
45
49
  },
46
50
  };
47
51
 
48
52
  return (
49
- <MRT_StyledTableBodyCell
50
- densePadding={densePadding}
53
+ <TableCell
51
54
  onClick={(event: MouseEvent<HTMLTableCellElement>) =>
52
55
  onCellClick?.(event, cell)
53
56
  }
54
57
  {...tableCellProps}
58
+ sx={
59
+ {
60
+ ...commonTableBodyCellStyles(densePadding),
61
+ ...tableCellProps?.sx,
62
+ } as TableCellProps['sx']
63
+ }
55
64
  >
56
65
  {currentEditingRow?.id === cell.row.id ? (
57
66
  <MRT_EditCellTextField cell={cell} />
@@ -64,6 +73,6 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
64
73
  ) : (
65
74
  cell.render('Cell')
66
75
  )}
67
- </MRT_StyledTableBodyCell>
76
+ </TableCell>
68
77
  );
69
78
  };
@@ -1,7 +1,7 @@
1
1
  import React, { FC, MouseEvent } from 'react';
2
- import { alpha, styled, TableRow as MuiTableRow } from '@mui/material';
2
+ import { alpha, TableCell, TableRow } from '@mui/material';
3
3
  import {
4
- MRT_StyledTableBodyCell,
4
+ commonTableBodyCellStyles,
5
5
  MRT_TableBodyCell,
6
6
  } from './MRT_TableBodyCell';
7
7
  import { useMRT } from '../useMRT';
@@ -11,14 +11,6 @@ import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
11
11
  import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
12
12
  import { MRT_Cell, MRT_Row } from '..';
13
13
 
14
- export const TableRow = styled(MuiTableRow, {
15
- shouldForwardProp: (prop) => prop !== 'isSelected',
16
- })<{ isSelected?: boolean }>(({ isSelected, theme }) => ({
17
- backgroundColor: isSelected
18
- ? alpha(theme.palette.primary.light, 0.1)
19
- : 'transparent',
20
- }));
21
-
22
14
  interface Props {
23
15
  row: MRT_Row;
24
16
  }
@@ -26,6 +18,7 @@ interface Props {
26
18
  export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
27
19
  const {
28
20
  anyRowsCanExpand,
21
+ densePadding,
29
22
  enableRowActions,
30
23
  enableRowEditing,
31
24
  enableRowNumbers,
@@ -46,22 +39,30 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
46
39
  ...row.getRowProps(),
47
40
  style: {
48
41
  ...row.getRowProps().style,
49
- ...(mTableBodyRowProps?.style ?? {}),
42
+ ...mTableBodyRowProps?.style,
50
43
  },
51
44
  };
52
45
 
53
46
  return (
54
47
  <>
55
48
  <TableRow
56
- isSelected={row.isSelected}
57
49
  hover
58
50
  onClick={(event: MouseEvent<HTMLTableRowElement>) =>
59
51
  onRowClick?.(event, row)
60
52
  }
61
53
  {...tableRowProps}
54
+ //@ts-ignore
55
+ sx={(theme) => ({
56
+ backgroundColor: row.isSelected
57
+ ? alpha(theme.palette.primary.light, 0.1)
58
+ : 'transparent',
59
+ ...tableRowProps?.sx,
60
+ })}
62
61
  >
63
62
  {enableRowNumbers && (
64
- <MRT_StyledTableBodyCell>{row.index + 1}</MRT_StyledTableBodyCell>
63
+ <TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
64
+ {row.index + 1}
65
+ </TableCell>
65
66
  )}
66
67
  {(enableRowActions || enableRowEditing) &&
67
68
  positionActionsColumn === 'first' && (
@@ -79,7 +80,9 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
79
80
  <MRT_ToggleRowActionMenuButton row={row} />
80
81
  )}
81
82
  </TableRow>
82
- {renderDetailPanel && <MRT_TableDetailPanel row={row} />}
83
+ {renderDetailPanel && !row.isGrouped && (
84
+ <MRT_TableDetailPanel row={row} />
85
+ )}
83
86
  </>
84
87
  );
85
88
  };
@@ -1,22 +1,8 @@
1
1
  import React, { FC, MouseEvent } from 'react';
2
- import {
3
- Collapse,
4
- styled,
5
- TableCell as MuiTableCell,
6
- TableRow,
7
- } from '@mui/material';
2
+ import { Collapse, TableCell, TableRow } from '@mui/material';
8
3
  import { useMRT } from '../useMRT';
9
4
  import { MRT_Row } from '..';
10
5
 
11
- const TableCell = styled(MuiTableCell, {
12
- shouldForwardProp: (prop) => prop !== 'isExpanded',
13
- })<{ isExpanded?: boolean }>(({ isExpanded }) => ({
14
- borderBottom: !isExpanded ? 'none' : undefined,
15
- paddingBottom: isExpanded ? '1rem' : 0,
16
- paddingTop: isExpanded ? '1rem' : 0,
17
- transition: 'all 0.2s ease-in-out',
18
- }));
19
-
20
6
  interface Props {
21
7
  row: MRT_Row;
22
8
  }
@@ -30,20 +16,11 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
30
16
  tableInstance,
31
17
  } = useMRT();
32
18
 
33
- const mTableBodyRowProps =
19
+ const tableRowProps =
34
20
  muiTableBodyRowProps instanceof Function
35
21
  ? muiTableBodyRowProps(row)
36
22
  : muiTableBodyRowProps;
37
23
 
38
- const tableRowProps = {
39
- ...mTableBodyRowProps,
40
- ...row.getRowProps(),
41
- style: {
42
- ...row.getRowProps().style,
43
- ...(mTableBodyRowProps?.style ?? {}),
44
- },
45
- };
46
-
47
24
  const tableCellProps =
48
25
  muiTableDetailPanelProps instanceof Function
49
26
  ? muiTableDetailPanelProps(row)
@@ -53,11 +30,17 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row }) => {
53
30
  <TableRow {...tableRowProps}>
54
31
  <TableCell
55
32
  colSpan={tableInstance.visibleColumns.length + 10}
56
- isExpanded={row.isExpanded}
57
33
  onClick={(event: MouseEvent<HTMLTableCellElement>) =>
58
34
  onDetailPanelClick?.(event, row)
59
35
  }
60
36
  {...tableCellProps}
37
+ sx={{
38
+ borderBottom: !row.isExpanded ? 'none' : undefined,
39
+ pb: row.isExpanded ? '1rem' : 0,
40
+ pt: row.isExpanded ? '1rem' : 0,
41
+ transition: 'all 0.2s ease-in-out',
42
+ ...tableCellProps?.sx,
43
+ }}
61
44
  >
62
45
  <Collapse in={row.isExpanded}>{renderDetailPanel?.(row)}</Collapse>
63
46
  </TableCell>
@@ -1,13 +1,8 @@
1
1
  import React, { FC } from 'react';
2
- import { IconButton, styled, Tooltip } from '@mui/material';
2
+ import { Box, IconButton, Tooltip } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_Row } from '..';
5
5
 
6
- const EditActionButtonWrappers = styled('div')({
7
- display: 'flex',
8
- gap: '0.75rem',
9
- });
10
-
11
6
  interface Props {
12
7
  row: MRT_Row;
13
8
  }
@@ -32,7 +27,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
32
27
  };
33
28
 
34
29
  return (
35
- <EditActionButtonWrappers>
30
+ <Box sx={{ display: 'flex', gap: '0.75rem' }}>
36
31
  <Tooltip arrow title={localization.rowActionButtonCancel}>
37
32
  <IconButton
38
33
  aria-label={localization.rowActionButtonCancel}
@@ -50,6 +45,6 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
50
45
  <SaveIcon />
51
46
  </IconButton>
52
47
  </Tooltip>
53
- </EditActionButtonWrappers>
48
+ </Box>
54
49
  );
55
50
  };
@@ -1,7 +1,7 @@
1
1
  import React, { FC } from 'react';
2
- import { IconButton } from '@mui/material';
2
+ import { IconButton, TableCell } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
- import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
4
+ import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
5
5
 
6
6
  interface Props {}
7
7
 
@@ -15,10 +15,10 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
15
15
  } = useMRT();
16
16
 
17
17
  return (
18
- <MRT_TableButtonCell
18
+ <TableCell
19
19
  size="small"
20
- densePadding={densePadding}
21
20
  {...tableInstance.getToggleAllRowsExpandedProps()}
21
+ sx={commonTableBodyButtonCellStyles(densePadding)}
22
22
  >
23
23
  <IconButton
24
24
  aria-label={localization.expandAllButtonTitle}
@@ -33,6 +33,6 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
33
33
  }}
34
34
  />
35
35
  </IconButton>
36
- </MRT_TableButtonCell>
36
+ </TableCell>
37
37
  );
38
38
  };
@@ -1,15 +1,8 @@
1
1
  import React, { FC } from 'react';
2
- import { IconButton, styled } from '@mui/material';
2
+ import { IconButton, TableCell } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
- import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
5
4
  import { MRT_Row } from '..';
6
-
7
- const TableCell = styled(MRT_TableButtonCell, {
8
- shouldForwardProp: (prop) => prop !== 'depth',
9
- })<{ depth: number }>(({ depth }) => ({
10
- paddingLeft: `${depth + 0.5}rem`,
11
- textAlign: 'left',
12
- }));
5
+ import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
13
6
 
14
7
  interface Props {
15
8
  row: MRT_Row;
@@ -24,7 +17,14 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
24
17
  } = useMRT();
25
18
 
26
19
  return (
27
- <TableCell size="small" densePadding={densePadding} depth={row.depth}>
20
+ <TableCell
21
+ size="small"
22
+ sx={{
23
+ ...commonTableBodyButtonCellStyles(densePadding),
24
+ pl: `${row.depth + 0.5}rem`,
25
+ textAlign: 'left',
26
+ }}
27
+ >
28
28
  <IconButton
29
29
  aria-label={localization.expandButtonTitle}
30
30
  disabled={!row.canExpand && !renderDetailPanel}
@@ -4,20 +4,14 @@ import {
4
4
  IconButton,
5
5
  Menu,
6
6
  Tooltip,
7
- styled,
8
7
  Divider,
9
8
  IconButtonProps,
9
+ Box,
10
10
  } from '@mui/material';
11
11
  import { useMRT } from '../useMRT';
12
12
  import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
13
13
  import { MRT_ColumnInstance } from '..';
14
14
 
15
- const MenuButtons = styled('div')({
16
- display: 'flex',
17
- justifyContent: 'space-between',
18
- padding: '0 0.5rem 0.5rem 0.5rem',
19
- });
20
-
21
15
  interface Props extends IconButtonProps {}
22
16
 
23
17
  export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
@@ -50,7 +44,13 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
50
44
  open={!!anchorEl}
51
45
  onClose={() => setAnchorEl(null)}
52
46
  >
53
- <MenuButtons>
47
+ <Box
48
+ sx={{
49
+ display: 'flex',
50
+ justifyContent: 'space-between',
51
+ p: '0 0.5rem 0.5rem 0.5rem',
52
+ }}
53
+ >
54
54
  <Button
55
55
  disabled={
56
56
  !tableInstance.getToggleHideAllColumnsProps().checked &&
@@ -66,7 +66,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
66
66
  >
67
67
  {localization.columnShowHideMenuShowAll}
68
68
  </Button>
69
- </MenuButtons>
69
+ </Box>
70
70
  <Divider />
71
71
  {tableInstance.columns.map((column: MRT_ColumnInstance, index) => (
72
72
  <MRT_ShowHideColumnsMenu
@@ -1,20 +1,9 @@
1
1
  import React, { FC, MouseEvent, useState } from 'react';
2
- import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
2
+ import { IconButton, Tooltip } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
5
5
  import { MRT_HeaderGroup } from '..';
6
6
 
7
- const IconButton = styled(MuiIconButton)({
8
- opacity: 0.5,
9
- transition: 'opacity 0.2s',
10
- marginRight: '2px',
11
- height: '1.6rem',
12
- width: '1.6rem',
13
- '&:hover': {
14
- opacity: 1,
15
- },
16
- });
17
-
18
7
  interface Props {
19
8
  column: MRT_HeaderGroup;
20
9
  }
@@ -45,6 +34,16 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
45
34
  aria-label={localization.columnActionMenuButtonTitle}
46
35
  onClick={handleClick}
47
36
  size="small"
37
+ sx={{
38
+ opacity: 0.5,
39
+ transition: 'opacity 0.2s',
40
+ marginRight: '2px',
41
+ height: '1.6rem',
42
+ width: '1.6rem',
43
+ '&:hover': {
44
+ opacity: 1,
45
+ },
46
+ }}
48
47
  >
49
48
  <MoreVertIcon />
50
49
  </IconButton>
@@ -1,12 +1,12 @@
1
1
  import React, { FC, MouseEvent, useState } from 'react';
2
- import { IconButton as MuiIconButton, styled, Tooltip } from '@mui/material';
2
+ import { IconButton, TableCell, Tooltip } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
5
5
  import { MRT_EditActionButtons } from './MRT_EditActionButtons';
6
- import { MRT_TableButtonCell } from '../table/MRT_TableButtonCell';
7
6
  import { MRT_Row } from '..';
7
+ import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
8
8
 
9
- const IconButton = styled(MuiIconButton)({
9
+ const commonIconButtonStyles = {
10
10
  opacity: 0.5,
11
11
  transition: 'opacity 0.2s',
12
12
  marginRight: '2px',
@@ -15,7 +15,7 @@ const IconButton = styled(MuiIconButton)({
15
15
  '&:hover': {
16
16
  opacity: 1,
17
17
  },
18
- });
18
+ };
19
19
 
20
20
  interface Props {
21
21
  row: MRT_Row;
@@ -48,7 +48,7 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
48
48
  };
49
49
 
50
50
  return (
51
- <MRT_TableButtonCell densePadding={densePadding}>
51
+ <TableCell sx={commonTableBodyButtonCellStyles(densePadding)}>
52
52
  {renderRowActions ? (
53
53
  <>{renderRowActions(row, tableInstance)}</>
54
54
  ) : row.id === currentEditingRow?.id ? (
@@ -59,7 +59,7 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
59
59
  arrow
60
60
  title={localization.rowActionMenuItemEdit}
61
61
  >
62
- <IconButton onClick={handleEdit}>
62
+ <IconButton sx={commonIconButtonStyles} onClick={handleEdit}>
63
63
  <EditIcon />
64
64
  </IconButton>
65
65
  </Tooltip>
@@ -67,9 +67,10 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
67
67
  <>
68
68
  <IconButton
69
69
  aria-label={localization.rowActionMenuButtonTitle}
70
- title={localization.rowActionMenuButtonTitle}
71
70
  onClick={handleOpenRowActionMenu}
72
71
  size="small"
72
+ sx={commonIconButtonStyles}
73
+ title={localization.rowActionMenuButtonTitle}
73
74
  >
74
75
  <MoreHorizIcon />
75
76
  </IconButton>
@@ -81,6 +82,6 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
81
82
  />
82
83
  </>
83
84
  ) : null}
84
- </MRT_TableButtonCell>
85
+ </TableCell>
85
86
  );
86
87
  };
@@ -1,20 +1,8 @@
1
1
  import React, { FC } from 'react';
2
- import { styled, TableCell as MuiTableCell } from '@mui/material';
2
+ import { TableCell } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import { MRT_HeaderGroup } from '..';
5
5
 
6
- const TableCell = styled(MuiTableCell, {
7
- shouldForwardProp: (prop) =>
8
- prop !== 'densePadding' && prop !== 'enableColumnResizing',
9
- })<{ densePadding?: boolean; enableColumnResizing?: boolean }>(
10
- ({ densePadding, enableColumnResizing }) => ({
11
- fontWeight: 'bold',
12
- verticalAlign: 'text-top',
13
- padding: densePadding ? '0.5rem' : '1rem',
14
- transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
15
- }),
16
- );
17
-
18
6
  interface Props {
19
7
  column: MRT_HeaderGroup;
20
8
  }
@@ -41,18 +29,23 @@ export const MRT_TableFooterCell: FC<Props> = ({ column }) => {
41
29
  ...column.getFooterProps(),
42
30
  style: {
43
31
  ...column.getFooterProps().style,
44
- ...(mTableFooterCellProps?.style ?? {}),
45
- ...(mcTableFooterCellProps?.style ?? {}),
32
+ ...mTableFooterCellProps?.style,
33
+ ...mcTableFooterCellProps?.style,
46
34
  },
47
35
  };
48
36
 
49
37
  return (
50
38
  <TableCell
51
39
  align={isParentHeader ? 'center' : 'left'}
52
- densePadding={densePadding}
53
- enableColumnResizing={enableColumnResizing}
54
40
  variant="head"
55
41
  {...tableCellProps}
42
+ sx={{
43
+ fontWeight: 'bold',
44
+ verticalAlign: 'text-top',
45
+ p: densePadding ? '0.5rem' : '1rem',
46
+ transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
47
+ ...tableCellProps?.sx,
48
+ }}
56
49
  >
57
50
  {column.render('Footer')}
58
51
  </TableCell>
@@ -36,7 +36,7 @@ export const MRT_TableFooterRow: FC<Props> = ({ footerGroup }) => {
36
36
  ...footerGroup.getFooterGroupProps(),
37
37
  style: {
38
38
  ...footerGroup.getFooterGroupProps().style,
39
- ...(mTableFooterRowProps?.style ?? {}),
39
+ ...mTableFooterRowProps?.style,
40
40
  },
41
41
  };
42
42