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,4 +1,4 @@
1
- import React, { CSSProperties, FC } from 'react';
1
+ import React, { FC, MouseEvent } from 'react';
2
2
  import {
3
3
  TableCell,
4
4
  TableSortLabel,
@@ -7,47 +7,36 @@ import {
7
7
  Tooltip,
8
8
  Box,
9
9
  IconButton,
10
+ alpha,
11
+ Theme,
10
12
  } from '@mui/material';
11
- import { useMRT } from '../useMRT';
12
13
  import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
13
14
  import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
14
- import type { MRT_HeaderGroup } from '..';
15
-
16
- export const commonTableHeadCellStyles = (
17
- densePadding: boolean,
18
- enableColumnResizing?: boolean,
19
- widths?: {
20
- maxWidth?: CSSProperties['maxWidth'];
21
- minWidth?: CSSProperties['minWidth'];
22
- width?: CSSProperties['width'];
23
- },
24
- ) => ({
25
- fontWeight: 'bold',
26
- height: '100%',
27
- p: densePadding ? '0.5rem' : '1rem',
28
- pt: densePadding ? '0.75rem' : '1.25rem',
29
- transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
30
- verticalAlign: 'text-top',
31
- ...widths,
32
- });
15
+ import type { MRT_Header, MRT_TableInstance } from '..';
16
+ import { ColumnResizerProps } from '@tanstack/react-table';
33
17
 
34
18
  interface Props {
35
- column: MRT_HeaderGroup;
19
+ header: MRT_Header;
20
+ tableInstance: MRT_TableInstance;
36
21
  }
37
22
 
38
- export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
23
+ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
39
24
  const {
40
- disableColumnActions,
41
- disableFilters,
42
- enableColumnResizing,
43
- icons: { FilterAltIcon, FilterAltOff },
44
- localization,
45
- muiTableHeadCellProps,
46
- setShowFilters,
47
- tableInstance,
48
- } = useMRT();
25
+ getState,
26
+ options: {
27
+ enableColumnActions,
28
+ enableColumnFilters,
29
+ enableColumnResizing,
30
+ icons: { FilterAltIcon, FilterAltOff },
31
+ localization,
32
+ muiTableHeadCellProps,
33
+ setShowFilters,
34
+ },
35
+ } = tableInstance;
36
+
37
+ const { isDensePadding, showFilters } = getState();
49
38
 
50
- const isParentHeader = !!column?.columns?.length;
39
+ const { column } = header;
51
40
 
52
41
  const mTableHeadCellProps =
53
42
  muiTableHeadCellProps instanceof Function
@@ -60,150 +49,210 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
60
49
  : column.muiTableHeadCellProps;
61
50
 
62
51
  const tableCellProps = {
52
+ ...header.getHeaderProps(),
63
53
  ...mTableHeadCellProps,
64
54
  ...mcTableHeadCellProps,
65
- ...column.getHeaderProps(),
66
- style: {
67
- ...column.getHeaderProps().style,
68
- ...mTableHeadCellProps?.style,
69
- ...mcTableHeadCellProps?.style,
70
- },
71
55
  };
72
56
 
73
- const sortTooltip = column.isSorted
74
- ? column.isSortedDesc
57
+ const sortTooltip = !!column.getIsSorted()
58
+ ? column.getIsSorted() === 'desc'
75
59
  ? localization.clearSort
76
- : localization.sortByColumnDesc?.replace(
60
+ : localization.sortByColumnDesc.replace(
77
61
  '{column}',
78
- column.Header as string,
62
+ column.header as string,
79
63
  )
80
- : localization.sortByColumnAsc?.replace(
81
- '{column}',
82
- column.Header as string,
83
- );
64
+ : localization.sortByColumnAsc.replace('{column}', column.header as string);
84
65
 
85
- const filterType = tableInstance.state.currentFilterTypes[column.id];
66
+ // const filterType = getState()?.currentFilterTypes?.[id];
86
67
 
87
- const filterTooltip = !!column.filterValue
88
- ? localization.filteringByColumn
89
- .replace('{column}', String(column.Header))
90
- .replace(
91
- '{filterType}',
92
- filterType instanceof Function
93
- ? ''
94
- : // @ts-ignore
95
- localization[
96
- `filter${
97
- filterType.charAt(0).toUpperCase() + filterType.slice(1)
98
- }`
99
- ],
100
- )
101
- .replace('{filterValue}', column.filterValue)
102
- .replace('" "', '')
103
- : localization.showHideFilters;
68
+ const filterTooltip = '';
69
+ // !!getColumnFilterValue()
70
+ // ? localization.filteringByColumn
71
+ // .replace('{column}', String(headerString))
72
+ // .replace(
73
+ // '{filterType}',
74
+ // filterType instanceof Function
75
+ // ? ''
76
+ // : // @ts-ignore
77
+ // localization[
78
+ // `filter${
79
+ // filterType.charAt(0).toUpperCase() + filterType.slice(1)
80
+ // }`
81
+ // ],
82
+ // )
83
+ // .replace(
84
+ // '{filterValue}',
85
+ // getColumnFilterValue() as string,
86
+ // )
87
+ // .replace('" "', '')
88
+ // : localization.showHideFilters;
104
89
 
105
- const columnHeader = column.render('Header') as string;
90
+ const headerElement =
91
+ column?.Header?.({
92
+ header,
93
+ tableInstance,
94
+ }) ?? column.header;
106
95
 
107
96
  return (
108
97
  <TableCell
109
- align={isParentHeader ? 'center' : 'left'}
98
+ align={column.columnDefType === 'group' ? 'center' : 'left'}
110
99
  {...tableCellProps}
111
- sx={{
112
- ...commonTableHeadCellStyles(
113
- tableInstance.state.densePadding,
114
- enableColumnResizing,
115
- {
116
- maxWidth: column.maxWidth,
117
- minWidth: column.minWidth,
118
- width: column.width,
119
- },
120
- ),
100
+ //@ts-ignore
101
+ sx={(theme: Theme) => ({
102
+ backgroundColor: theme.palette.background.default,
103
+ backgroundImage: `linear-gradient(${alpha(
104
+ theme.palette.common.white,
105
+ 0.05,
106
+ )},${alpha(theme.palette.common.white, 0.05)})`,
107
+ boxShadow: `3px 0 6px ${alpha(theme.palette.common.black, 0.1)}`,
108
+ fontWeight: 'bold',
109
+ height: '100%',
110
+ minWidth: `max(${header.getWidth()}, 100px)`,
111
+ p: isDensePadding
112
+ ? column.columnDefType === 'display'
113
+ ? '0 0.5rem'
114
+ : '0.5rem'
115
+ : column.columnDefType === 'display'
116
+ ? '0.5rem 0.75rem'
117
+ : '1rem',
118
+ pt:
119
+ column.columnDefType === 'display'
120
+ ? 0
121
+ : isDensePadding
122
+ ? '0.75rem'
123
+ : '1.25rem',
124
+ pb: column.columnDefType === 'display' ? 0 : undefined,
125
+ transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
126
+ verticalAlign: 'text-top',
127
+ width: header.getWidth(),
128
+ //@ts-ignore
121
129
  ...tableCellProps?.sx,
122
- }}
130
+ })}
123
131
  >
124
- <Box
125
- sx={{
126
- alignItems: 'flex-start',
127
- display: 'flex',
128
- justifyContent: isParentHeader ? 'center' : 'space-between',
129
- width: '100%',
130
- }}
131
- >
132
+ {header.isPlaceholder ? null : column.columnDefType === 'display' ? (
133
+ headerElement
134
+ ) : (
132
135
  <Box
133
- {...column.getSortByToggleProps()}
134
136
  sx={{
135
- alignItems: 'center',
137
+ alignItems: 'flex-start',
136
138
  display: 'flex',
137
- flexWrap: 'nowrap',
138
- whiteSpace: columnHeader.length < 15 ? 'nowrap' : 'normal',
139
+ justifyContent:
140
+ column.columnDefType === 'group' ? 'center' : 'space-between',
141
+ width: '100%',
139
142
  }}
140
- title={undefined}
141
143
  >
142
- {column.render('Header')}
143
- {!isParentHeader && column.canSort && (
144
- <Tooltip arrow placement="top" title={sortTooltip}>
145
- <TableSortLabel
146
- aria-label={sortTooltip}
147
- active={column.isSorted}
148
- direction={column.isSortedDesc ? 'desc' : 'asc'}
149
- />
150
- </Tooltip>
151
- )}
152
- {!isParentHeader && !!column.canFilter && (
153
- <Tooltip arrow placement="top" title={filterTooltip}>
154
- <IconButton
155
- disableRipple
156
- onClick={(event) => {
157
- event.stopPropagation();
158
- setShowFilters(!tableInstance.state.showFilters);
159
- }}
160
- size="small"
161
- sx={{
162
- m: 0,
163
- opacity: !!column.filterValue ? 0.8 : 0,
164
- p: '2px',
165
- transition: 'all 0.2s ease-in-out',
166
- '&:hover': {
167
- backgroundColor: 'transparent',
168
- opacity: 0.8,
144
+ <Box
145
+ {...column.getToggleSortingProps()}
146
+ sx={{
147
+ alignItems: 'center',
148
+ cursor:
149
+ column.getCanSort() && column.columnDefType !== 'group'
150
+ ? 'pointer'
151
+ : undefined,
152
+ display: 'flex',
153
+ flexWrap: 'nowrap',
154
+ whiteSpace: column.header.length < 15 ? 'nowrap' : 'normal',
155
+ }}
156
+ title={undefined}
157
+ >
158
+ {headerElement}
159
+ {column.columnDefType !== 'group' && column.getCanSort() && (
160
+ <Tooltip arrow placement="top" title={sortTooltip}>
161
+ <TableSortLabel
162
+ aria-label={sortTooltip}
163
+ active={!!column.getIsSorted()}
164
+ direction={
165
+ column.getIsSorted()
166
+ ? (column.getIsSorted() as 'asc' | 'desc')
167
+ : undefined
168
+ }
169
+ />
170
+ </Tooltip>
171
+ )}
172
+ {column.columnDefType !== 'group' &&
173
+ enableColumnFilters &&
174
+ !!column.getCanColumnFilter() && (
175
+ <Tooltip arrow placement="top" title={filterTooltip}>
176
+ <IconButton
177
+ disableRipple
178
+ onClick={(event: MouseEvent<HTMLButtonElement>) => {
179
+ event.stopPropagation();
180
+ setShowFilters(!showFilters);
181
+ }}
182
+ size="small"
183
+ sx={{
184
+ m: 0,
185
+ opacity: !!column.getColumnFilterValue() ? 0.8 : 0,
186
+ p: '2px',
187
+ transition: 'all 0.2s ease-in-out',
188
+ '&:hover': {
189
+ backgroundColor: 'transparent',
190
+ opacity: 0.8,
191
+ },
192
+ }}
193
+ >
194
+ {showFilters && !column.getColumnFilterValue() ? (
195
+ <FilterAltOff fontSize="small" />
196
+ ) : (
197
+ <FilterAltIcon fontSize="small" />
198
+ )}
199
+ </IconButton>
200
+ </Tooltip>
201
+ )}
202
+ </Box>
203
+ <Box
204
+ sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}
205
+ >
206
+ {(enableColumnActions || column.enableColumnActions) &&
207
+ column.enableColumnActions !== false &&
208
+ column.columnDefType !== 'group' && (
209
+ <MRT_ToggleColumnActionMenuButton
210
+ header={header}
211
+ tableInstance={tableInstance}
212
+ />
213
+ )}
214
+ {enableColumnResizing && column.columnDefType !== 'group' && (
215
+ <Divider
216
+ flexItem
217
+ orientation="vertical"
218
+ onDoubleClick={() => header.resetSize()}
219
+ sx={(theme: Theme) => ({
220
+ borderRightWidth: '2px',
221
+ borderRadius: '2px',
222
+ maxHeight: '2rem',
223
+ cursor: 'col-resize',
224
+ userSelect: 'none',
225
+ touchAction: 'none',
226
+ '&:active': {
227
+ backgroundColor: theme.palette.secondary.dark,
228
+ opacity: 1,
169
229
  },
170
- }}
171
- >
172
- {tableInstance.state.showFilters && !column.filterValue ? (
173
- <FilterAltOff fontSize="small" />
174
- ) : (
175
- <FilterAltIcon fontSize="small" />
176
- )}
177
- </IconButton>
178
- </Tooltip>
179
- )}
180
- </Box>
181
- <Box sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}>
182
- {!disableColumnActions &&
183
- !column.disableColumnActions &&
184
- !isParentHeader && (
185
- <MRT_ToggleColumnActionMenuButton column={column} />
230
+ })}
231
+ {...(header.getResizerProps((props: ColumnResizerProps) => ({
232
+ ...props,
233
+ style: {
234
+ transform: column.getIsResizing()
235
+ ? `translateX(${
236
+ getState().columnSizingInfo.deltaOffset
237
+ }px)`
238
+ : '',
239
+ },
240
+ })) as any)}
241
+ />
186
242
  )}
187
- {enableColumnResizing && !isParentHeader && (
188
- <Divider
189
- flexItem
190
- orientation="vertical"
191
- onDoubleClick={() => tableInstance.resetResizing()}
192
- {...column.getResizerProps()}
193
- sx={{
194
- borderRightWidth: '2px',
195
- borderRadius: '2px',
196
- maxHeight: '2rem',
197
- }}
198
- />
199
- )}
243
+ </Box>
200
244
  </Box>
201
- </Box>
202
- {!disableFilters && column.canFilter && (
203
- <Collapse in={tableInstance.state.showFilters}>
204
- <MRT_FilterTextField column={column} />
205
- </Collapse>
206
245
  )}
246
+ {column.columnDefType === 'data' &&
247
+ enableColumnFilters &&
248
+ column.getCanColumnFilter() && (
249
+ <Collapse in={showFilters}>
250
+ <MRT_FilterTextField
251
+ header={header}
252
+ tableInstance={tableInstance}
253
+ />
254
+ </Collapse>
255
+ )}
207
256
  </TableCell>
208
257
  );
209
258
  };
@@ -1,39 +1,17 @@
1
- import React, { FC, useMemo } from 'react';
2
- import { TableCell, TableRow } from '@mui/material';
3
- import {
4
- commonTableHeadCellStyles,
5
- MRT_TableHeadCell,
6
- } from './MRT_TableHeadCell';
7
- import { useMRT } from '../useMRT';
8
- import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
9
- import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
10
- import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
11
- import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
12
- import type { MRT_HeaderGroup } from '..';
1
+ import React, { FC } from 'react';
2
+ import { TableRow } from '@mui/material';
3
+ import { MRT_TableHeadCell } from './MRT_TableHeadCell';
4
+ import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
13
5
 
14
6
  interface Props {
15
7
  headerGroup: MRT_HeaderGroup;
8
+ tableInstance: MRT_TableInstance;
16
9
  }
17
10
 
18
- export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
11
+ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup, tableInstance }) => {
19
12
  const {
20
- anyRowsCanExpand,
21
- disableExpandAll,
22
- disableSelectAll,
23
- enableRowActions,
24
- enableRowEditing,
25
- enableRowNumbers,
26
- enableSelection,
27
- muiTableHeadRowProps,
28
- positionActionsColumn,
29
- renderDetailPanel,
30
- tableInstance,
31
- } = useMRT();
32
-
33
- const isParentHeader = useMemo(
34
- () => headerGroup.headers.some((h) => (h.columns?.length ?? 0) > 0),
35
- [headerGroup.headers],
36
- );
13
+ options: { muiTableHeadRowProps },
14
+ } = tableInstance;
37
15
 
38
16
  const mTableHeadRowProps =
39
17
  muiTableHeadRowProps instanceof Function
@@ -41,85 +19,19 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
41
19
  : muiTableHeadRowProps;
42
20
 
43
21
  const tableRowProps = {
22
+ ...headerGroup?.getHeaderGroupProps(),
44
23
  ...mTableHeadRowProps,
45
- ...headerGroup.getHeaderGroupProps(),
46
- style: {
47
- ...headerGroup.getHeaderGroupProps().style,
48
- ...mTableHeadRowProps?.style,
49
- },
50
24
  };
51
25
 
52
26
  return (
53
27
  <TableRow {...tableRowProps}>
54
- {(enableRowActions || enableRowEditing) &&
55
- positionActionsColumn === 'first' &&
56
- (isParentHeader ? (
57
- <MRT_TableSpacerCell />
58
- ) : (
59
- <MRT_TableHeadCellActions />
60
- ))}
61
- {anyRowsCanExpand || renderDetailPanel ? (
62
- !disableExpandAll && !isParentHeader ? (
63
- <TableCell
64
- size="small"
65
- {...tableInstance.getToggleAllRowsExpandedProps()}
66
- sx={{
67
- ...commonTableHeadCellStyles(tableInstance.state.densePadding),
68
- width: '3rem',
69
- maxWidth: '3rem',
70
- textAlign: 'center',
71
- }}
72
- >
73
- <MRT_ExpandAllButton />
74
- </TableCell>
75
- ) : (
76
- <MRT_TableSpacerCell
77
- width={`${
78
- renderDetailPanel ? 2 : tableInstance.expandedDepth + 0.5
79
- }rem`}
80
- />
81
- )
82
- ) : null}
83
- {enableSelection ? (
84
- !isParentHeader && !disableSelectAll ? (
85
- <TableCell
86
- sx={{
87
- ...commonTableHeadCellStyles(tableInstance.state.densePadding),
88
- maxWidth: '3rem',
89
- width: '3rem',
90
- textAlign: 'center',
91
- }}
92
- >
93
- <MRT_SelectCheckbox selectAll />
94
- </TableCell>
95
- ) : (
96
- <MRT_TableSpacerCell width="1rem" />
97
- )
98
- ) : null}
99
- {enableRowNumbers &&
100
- (isParentHeader ? (
101
- <MRT_TableSpacerCell />
102
- ) : (
103
- <TableCell
104
- sx={{
105
- ...commonTableHeadCellStyles(tableInstance.state.densePadding),
106
- width: '2rem',
107
- maxWidth: '2rem',
108
- }}
109
- >
110
- #
111
- </TableCell>
112
- ))}
113
- {headerGroup.headers.map((column: MRT_HeaderGroup) => (
114
- <MRT_TableHeadCell key={column.getHeaderProps().key} column={column} />
28
+ {headerGroup.headers.map((header: MRT_Header, index) => (
29
+ <MRT_TableHeadCell
30
+ header={header}
31
+ key={header.id || index}
32
+ tableInstance={tableInstance}
33
+ />
115
34
  ))}
116
- {(enableRowActions || enableRowEditing) &&
117
- positionActionsColumn === 'last' &&
118
- (isParentHeader ? (
119
- <MRT_TableSpacerCell />
120
- ) : (
121
- <MRT_TableHeadCellActions />
122
- ))}
123
35
  </TableRow>
124
36
  );
125
37
  };
package/src/icons.ts CHANGED
@@ -3,7 +3,6 @@ import CancelIcon from '@mui/icons-material/Cancel';
3
3
  import CheckBoxIcon from '@mui/icons-material/CheckBox';
4
4
  import ClearAllIcon from '@mui/icons-material/ClearAll';
5
5
  import CloseIcon from '@mui/icons-material/Close';
6
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
7
6
  import DensityMediumIcon from '@mui/icons-material/DensityMedium';
8
7
  import DensitySmallIcon from '@mui/icons-material/DensitySmall';
9
8
  import DoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
@@ -19,6 +18,7 @@ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
19
18
  import FullscreenIcon from '@mui/icons-material/Fullscreen';
20
19
  import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
21
20
  import MoreVertIcon from '@mui/icons-material/MoreVert';
21
+ import PushPinIcon from '@mui/icons-material/PushPin';
22
22
  import SaveIcon from '@mui/icons-material/Save';
23
23
  import SearchIcon from '@mui/icons-material/Search';
24
24
  import SearchOffIcon from '@mui/icons-material/SearchOff';
@@ -32,7 +32,6 @@ export interface MRT_Icons {
32
32
  CheckBoxIcon: any;
33
33
  ClearAllIcon: any;
34
34
  CloseIcon: any;
35
- ContentCopyIcon: any;
36
35
  DensityMediumIcon: any;
37
36
  DensitySmallIcon: any;
38
37
  DoubleArrowDownIcon: any;
@@ -48,6 +47,7 @@ export interface MRT_Icons {
48
47
  FullscreenIcon: any;
49
48
  MoreHorizIcon: any;
50
49
  MoreVertIcon: any;
50
+ PushPinIcon: any;
51
51
  SaveIcon: any;
52
52
  SearchIcon: any;
53
53
  SearchOffIcon: any;
@@ -62,7 +62,6 @@ export const MRT_Default_Icons: MRT_Icons = {
62
62
  CheckBoxIcon,
63
63
  ClearAllIcon,
64
64
  CloseIcon,
65
- ContentCopyIcon,
66
65
  DensityMediumIcon,
67
66
  DensitySmallIcon,
68
67
  DoubleArrowDownIcon,
@@ -78,6 +77,7 @@ export const MRT_Default_Icons: MRT_Icons = {
78
77
  FullscreenIcon,
79
78
  MoreHorizIcon,
80
79
  MoreVertIcon,
80
+ PushPinIcon,
81
81
  SaveIcon,
82
82
  SearchIcon,
83
83
  SearchOffIcon,
@@ -1,29 +1,28 @@
1
- import React, { ChangeEvent, FC } from 'react';
1
+ import React, { ChangeEvent, FC, MouseEvent } from 'react';
2
2
  import { TextField } from '@mui/material';
3
- import { useMRT } from '../useMRT';
4
- import type { MRT_Cell } from '..';
3
+ import type { MRT_Cell, MRT_TableInstance } from '..';
5
4
 
6
5
  interface Props {
7
6
  cell: MRT_Cell;
7
+ tableInstance: MRT_TableInstance;
8
8
  }
9
9
 
10
- export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
10
+ export const MRT_EditCellTextField: FC<Props> = ({ cell, tableInstance }) => {
11
11
  const {
12
- muiTableBodyCellEditTextFieldProps,
13
- setCurrentEditingRow,
14
- tableInstance: {
15
- state: { currentEditingRow },
16
- },
17
- } = useMRT();
12
+ getState,
13
+ options: { muiTableBodyCellEditTextFieldProps },
14
+ } = tableInstance;
15
+
16
+ const { column, row } = cell;
18
17
 
19
18
  const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
20
- if (currentEditingRow) {
21
- cell.row.values[cell.column.id] = event.target.value;
22
- setCurrentEditingRow({
23
- ...currentEditingRow,
24
- });
19
+ if (getState().currentEditingRow) {
20
+ row.values[column.id] = event.target.value;
21
+ // setCurrentEditingRow({
22
+ // ...getState().currentEditingRow,
23
+ // });
25
24
  }
26
- cell.column.onCellEditChange?.(event, cell);
25
+ column.onCellEditChange?.(event, cell);
27
26
  };
28
27
 
29
28
  const mTableBodyCellEditTextFieldProps =
@@ -32,25 +31,25 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
32
31
  : muiTableBodyCellEditTextFieldProps;
33
32
 
34
33
  const mcTableBodyCellEditTextFieldProps =
35
- cell.column.muiTableBodyCellEditTextFieldProps instanceof Function
36
- ? cell.column.muiTableBodyCellEditTextFieldProps(cell)
37
- : cell.column.muiTableBodyCellEditTextFieldProps;
34
+ column.muiTableBodyCellEditTextFieldProps instanceof Function
35
+ ? column.muiTableBodyCellEditTextFieldProps(cell)
36
+ : column.muiTableBodyCellEditTextFieldProps;
38
37
 
39
38
  const textFieldProps = {
40
39
  ...mTableBodyCellEditTextFieldProps,
41
40
  ...mcTableBodyCellEditTextFieldProps,
42
41
  };
43
42
 
44
- if (!cell.column.disableEditing && cell.column.Edit) {
45
- return <>{cell.column.Edit({ ...textFieldProps, cell })}</>;
46
- }
43
+ // if (enableEditing && Edit) {
44
+ // return <>{Edit({ ...textFieldProps, cell })}</>;
45
+ // }
47
46
 
48
47
  return (
49
48
  <TextField
50
49
  margin="dense"
51
50
  onChange={handleChange}
52
- onClick={(e) => e.stopPropagation()}
53
- placeholder={cell.column.Header as string}
51
+ onClick={(e: MouseEvent<HTMLInputElement>) => e.stopPropagation()}
52
+ placeholder={column.header}
54
53
  value={cell.value}
55
54
  variant="standard"
56
55
  {...textFieldProps}