material-react-table 0.17.1 → 0.19.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.
- package/dist/MaterialReactTable.d.ts +170 -230
- package/dist/body/MRT_TableBody.d.ts +1 -1
- package/dist/body/MRT_TableBodyCell.d.ts +1 -1
- package/dist/body/MRT_TableBodyRow.d.ts +1 -1
- package/dist/body/MRT_TableDetailPanel.d.ts +1 -1
- package/dist/buttons/MRT_ColumnPinningButtons.d.ts +1 -1
- package/dist/buttons/MRT_CopyButton.d.ts +1 -1
- package/dist/buttons/MRT_EditActionButtons.d.ts +1 -1
- package/dist/buttons/MRT_ExpandAllButton.d.ts +1 -1
- package/dist/buttons/MRT_ExpandButton.d.ts +1 -1
- package/dist/buttons/MRT_FullScreenToggleButton.d.ts +1 -1
- package/dist/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/buttons/MRT_ShowHideColumnsButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleDensePaddingButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleFiltersButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleGlobalFilterButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +1 -1
- package/dist/filtersFns.d.ts +31 -23
- package/dist/footer/MRT_TableFooter.d.ts +1 -1
- package/dist/footer/MRT_TableFooterCell.d.ts +1 -1
- package/dist/footer/MRT_TableFooterRow.d.ts +1 -1
- package/dist/head/MRT_DraggableTableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHead.d.ts +1 -1
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellColumnActionsButton.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellFilterContainer.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellResizeHandle.d.ts +1 -1
- package/dist/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/head/MRT_TableHeadRow.d.ts +1 -1
- package/dist/inputs/MRT_EditCellTextField.d.ts +1 -1
- package/dist/inputs/MRT_FilterRangeFields.d.ts +1 -1
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -1
- package/dist/inputs/MRT_GlobalFilterTextField.d.ts +1 -1
- package/dist/inputs/MRT_SelectCheckbox.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +791 -915
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +793 -917
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +1 -1
- package/dist/menus/MRT_FilterOptionMenu.d.ts +1 -1
- package/dist/menus/MRT_RowActionMenu.d.ts +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/sortingFns.d.ts +10 -3
- package/dist/table/MRT_Table.d.ts +1 -1
- package/dist/table/MRT_TableContainer.d.ts +1 -1
- package/dist/table/MRT_TablePaper.d.ts +1 -1
- package/dist/toolbar/MRT_LinearProgressBar.d.ts +1 -1
- package/dist/toolbar/MRT_TablePagination.d.ts +1 -1
- package/dist/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/toolbar/MRT_ToolbarBottom.d.ts +1 -1
- package/dist/toolbar/MRT_ToolbarInternalButtons.d.ts +1 -1
- package/dist/toolbar/MRT_ToolbarTop.d.ts +1 -1
- package/dist/utils.d.ts +10 -16
- package/package.json +4 -4
- package/src/MaterialReactTable.tsx +168 -334
- package/src/body/MRT_TableBody.tsx +5 -6
- package/src/body/MRT_TableBodyCell.tsx +19 -36
- package/src/body/MRT_TableBodyRow.tsx +9 -12
- package/src/body/MRT_TableDetailPanel.tsx +8 -12
- package/src/buttons/MRT_ColumnPinningButtons.tsx +3 -3
- package/src/buttons/MRT_CopyButton.tsx +5 -7
- package/src/buttons/MRT_EditActionButtons.tsx +4 -5
- package/src/buttons/MRT_ExpandAllButton.tsx +4 -5
- package/src/buttons/MRT_ExpandButton.tsx +6 -9
- package/src/buttons/MRT_FullScreenToggleButton.tsx +5 -15
- package/src/buttons/MRT_GrabHandleButton.tsx +39 -41
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +4 -4
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +5 -15
- package/src/buttons/MRT_ToggleFiltersButton.tsx +5 -12
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +6 -16
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +6 -6
- package/src/filtersFns.ts +24 -23
- package/src/footer/MRT_TableFooter.tsx +5 -6
- package/src/footer/MRT_TableFooterCell.tsx +8 -11
- package/src/footer/MRT_TableFooterRow.tsx +5 -9
- package/src/head/MRT_DraggableTableHeadCell.tsx +4 -6
- package/src/head/MRT_TableHead.tsx +5 -5
- package/src/head/MRT_TableHeadCell.tsx +18 -29
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +6 -8
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +5 -7
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +13 -19
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +12 -11
- package/src/head/MRT_TableHeadCellSortLabel.tsx +3 -5
- package/src/head/MRT_TableHeadRow.tsx +6 -6
- package/src/inputs/MRT_EditCellTextField.tsx +13 -15
- package/src/inputs/MRT_FilterRangeFields.tsx +4 -4
- package/src/inputs/MRT_FilterTextField.tsx +27 -64
- package/src/inputs/MRT_GlobalFilterTextField.tsx +5 -10
- package/src/inputs/MRT_SelectCheckbox.tsx +9 -36
- package/src/menus/MRT_ColumnActionMenu.tsx +5 -9
- package/src/menus/MRT_FilterOptionMenu.tsx +16 -48
- package/src/menus/MRT_RowActionMenu.tsx +4 -5
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +8 -9
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +11 -10
- package/src/sortingFns.ts +11 -3
- package/src/table/MRT_Table.tsx +7 -11
- package/src/table/MRT_TableContainer.tsx +5 -6
- package/src/table/MRT_TablePaper.tsx +7 -8
- package/src/table/MRT_TableRoot.tsx +123 -156
- package/src/toolbar/MRT_LinearProgressBar.tsx +4 -5
- package/src/toolbar/MRT_TablePagination.tsx +7 -9
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +15 -11
- package/src/toolbar/MRT_ToolbarBottom.tsx +8 -9
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +10 -10
- package/src/toolbar/MRT_ToolbarTop.tsx +11 -11
- package/src/utils.ts +56 -50
|
@@ -6,11 +6,11 @@ import type { MRT_Row, MRT_TableInstance } from '..';
|
|
|
6
6
|
import { rankGlobalFuzzy } from '../sortingFns';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
|
-
|
|
9
|
+
table: MRT_TableInstance;
|
|
10
10
|
tableContainerRef: RefObject<HTMLDivElement>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const MRT_TableBody: FC<Props> = ({
|
|
13
|
+
export const MRT_TableBody: FC<Props> = ({ table, tableContainerRef }) => {
|
|
14
14
|
const {
|
|
15
15
|
getRowModel,
|
|
16
16
|
getPrePaginationRowModel,
|
|
@@ -22,13 +22,12 @@ export const MRT_TableBody: FC<Props> = ({ instance, tableContainerRef }) => {
|
|
|
22
22
|
muiTableBodyProps,
|
|
23
23
|
virtualizerProps,
|
|
24
24
|
},
|
|
25
|
-
} =
|
|
26
|
-
|
|
25
|
+
} = table;
|
|
27
26
|
const { density, globalFilter, pagination, sorting } = getState();
|
|
28
27
|
|
|
29
28
|
const tableBodyProps =
|
|
30
29
|
muiTableBodyProps instanceof Function
|
|
31
|
-
? muiTableBodyProps({
|
|
30
|
+
? muiTableBodyProps({ table })
|
|
32
31
|
: muiTableBodyProps;
|
|
33
32
|
|
|
34
33
|
const getIsSomeColumnsSorted = () => {
|
|
@@ -97,7 +96,7 @@ export const MRT_TableBody: FC<Props> = ({ instance, tableContainerRef }) => {
|
|
|
97
96
|
rowIndex={
|
|
98
97
|
enableRowVirtualization ? rowOrVirtualRow.index : rowIndex
|
|
99
98
|
}
|
|
100
|
-
|
|
99
|
+
table={table}
|
|
101
100
|
/>
|
|
102
101
|
);
|
|
103
102
|
},
|
|
@@ -10,14 +10,14 @@ interface Props {
|
|
|
10
10
|
cell: MRT_Cell;
|
|
11
11
|
enableHover?: boolean;
|
|
12
12
|
rowIndex: number;
|
|
13
|
-
|
|
13
|
+
table: MRT_TableInstance;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const MRT_TableBodyCell: FC<Props> = ({
|
|
17
17
|
cell,
|
|
18
18
|
enableHover,
|
|
19
19
|
rowIndex,
|
|
20
|
-
|
|
20
|
+
table,
|
|
21
21
|
}) => {
|
|
22
22
|
const {
|
|
23
23
|
getState,
|
|
@@ -29,15 +29,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
29
29
|
enableRowNumbers,
|
|
30
30
|
muiTableBodyCellProps,
|
|
31
31
|
muiTableBodyCellSkeletonProps,
|
|
32
|
-
onCellClick,
|
|
33
|
-
onRowClick,
|
|
34
32
|
rowNumberMode,
|
|
35
33
|
tableId,
|
|
36
34
|
},
|
|
37
35
|
setColumnOrder,
|
|
38
36
|
setCurrentEditingCell,
|
|
39
|
-
} =
|
|
40
|
-
|
|
37
|
+
} = table;
|
|
41
38
|
const {
|
|
42
39
|
columnOrder,
|
|
43
40
|
currentEditingCell,
|
|
@@ -46,10 +43,9 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
46
43
|
isLoading,
|
|
47
44
|
showSkeletons,
|
|
48
45
|
} = getState();
|
|
49
|
-
|
|
50
46
|
const { column, row } = cell;
|
|
51
|
-
|
|
52
|
-
const {
|
|
47
|
+
const { columnDef } = column;
|
|
48
|
+
const { columnDefType } = columnDef;
|
|
53
49
|
|
|
54
50
|
const [, dropRef] = useDrop({
|
|
55
51
|
accept: 'column',
|
|
@@ -61,12 +57,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
61
57
|
|
|
62
58
|
const mTableCellBodyProps =
|
|
63
59
|
muiTableBodyCellProps instanceof Function
|
|
64
|
-
? muiTableBodyCellProps({ cell,
|
|
60
|
+
? muiTableBodyCellProps({ cell, table })
|
|
65
61
|
: muiTableBodyCellProps;
|
|
66
62
|
|
|
67
63
|
const mcTableCellBodyProps =
|
|
68
64
|
columnDef.muiTableBodyCellProps instanceof Function
|
|
69
|
-
? columnDef.muiTableBodyCellProps({ cell,
|
|
65
|
+
? columnDef.muiTableBodyCellProps({ cell, table })
|
|
70
66
|
: columnDef.muiTableBodyCellProps;
|
|
71
67
|
|
|
72
68
|
const tableCellProps = {
|
|
@@ -80,7 +76,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
80
76
|
? column.getSize() / 2
|
|
81
77
|
: Math.random() * (column.getSize() - column.getSize() / 3) +
|
|
82
78
|
column.getSize() / 3,
|
|
83
|
-
[
|
|
79
|
+
[],
|
|
84
80
|
);
|
|
85
81
|
|
|
86
82
|
const isEditable =
|
|
@@ -115,7 +111,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
115
111
|
const getIsLastLeftPinnedColumn = () => {
|
|
116
112
|
return (
|
|
117
113
|
column.getIsPinned() === 'left' &&
|
|
118
|
-
|
|
114
|
+
table.getLeftLeafHeaders().length - 1 === column.getPinnedIndex()
|
|
119
115
|
);
|
|
120
116
|
};
|
|
121
117
|
|
|
@@ -125,16 +121,12 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
125
121
|
|
|
126
122
|
const getTotalRight = () => {
|
|
127
123
|
return (
|
|
128
|
-
(
|
|
129
|
-
150
|
|
124
|
+
(table.getRightLeafHeaders().length - 1 - column.getPinnedIndex()) * 150
|
|
130
125
|
);
|
|
131
126
|
};
|
|
132
127
|
|
|
133
128
|
return (
|
|
134
129
|
<TableCell
|
|
135
|
-
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
136
|
-
onCellClick?.({ event, cell, instance })
|
|
137
|
-
}
|
|
138
130
|
onDoubleClick={handleDoubleClick}
|
|
139
131
|
{...tableCellProps}
|
|
140
132
|
ref={
|
|
@@ -149,10 +141,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
149
141
|
: getIsFirstRightPinnedColumn()
|
|
150
142
|
? `-4px 0 4px -2px ${alpha(theme.palette.common.black, 0.1)}`
|
|
151
143
|
: undefined,
|
|
152
|
-
cursor:
|
|
153
|
-
(isEditable && editingMode === 'cell') || onRowClick || onCellClick
|
|
154
|
-
? 'pointer'
|
|
155
|
-
: 'text',
|
|
144
|
+
cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'text',
|
|
156
145
|
left:
|
|
157
146
|
column.getIsPinned() === 'left'
|
|
158
147
|
? `${column.getStart('left')}px`
|
|
@@ -206,7 +195,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
206
195
|
})}
|
|
207
196
|
>
|
|
208
197
|
<>
|
|
209
|
-
{isLoading || showSkeletons ? (
|
|
198
|
+
{cell.getIsPlaceholder() ? null : isLoading || showSkeletons ? (
|
|
210
199
|
<Skeleton
|
|
211
200
|
animation="wave"
|
|
212
201
|
height={20}
|
|
@@ -218,27 +207,21 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
218
207
|
column.id === 'mrt-row-numbers' ? (
|
|
219
208
|
rowIndex + 1
|
|
220
209
|
) : columnDefType === 'display' ? (
|
|
221
|
-
columnDef.Cell?.({ cell,
|
|
222
|
-
) : cell.getIsPlaceholder() ||
|
|
223
|
-
(row.getIsGrouped() &&
|
|
224
|
-
column.id !==
|
|
225
|
-
row.groupingColumnId) ? null : cell.getIsAggregated() ? (
|
|
226
|
-
columnDef.AggregatedCell?.({ cell, instance }) ??
|
|
227
|
-
cell.renderAggregatedCell()
|
|
210
|
+
columnDef.Cell?.({ cell, table })
|
|
228
211
|
) : isEditing ? (
|
|
229
|
-
<MRT_EditCellTextField cell={cell}
|
|
212
|
+
<MRT_EditCellTextField cell={cell} table={table} />
|
|
230
213
|
) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
231
214
|
columnDef.enableClickToCopy !== false ? (
|
|
232
215
|
<>
|
|
233
|
-
<MRT_CopyButton cell={cell}
|
|
234
|
-
<>{columnDef?.Cell?.({ cell,
|
|
216
|
+
<MRT_CopyButton cell={cell} table={table}>
|
|
217
|
+
<>{columnDef?.Cell?.({ cell, table }) ?? cell.renderValue()}</>
|
|
235
218
|
</MRT_CopyButton>
|
|
236
|
-
{
|
|
219
|
+
{cell.getIsGrouped() && <> ({row.subRows?.length})</>}
|
|
237
220
|
</>
|
|
238
221
|
) : (
|
|
239
222
|
<>
|
|
240
|
-
{columnDef?.Cell?.({ cell,
|
|
241
|
-
{
|
|
223
|
+
{columnDef?.Cell?.({ cell, table }) ?? cell.renderValue()}
|
|
224
|
+
{cell.getIsGrouped() && <> ({row.subRows?.length ?? ''})</>}
|
|
242
225
|
</>
|
|
243
226
|
)}
|
|
244
227
|
</>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { darken, lighten, TableRow } from '@mui/material';
|
|
3
3
|
import { MRT_TableBodyCell } from './MRT_TableBodyCell';
|
|
4
4
|
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
@@ -7,27 +7,24 @@ import type { MRT_Row, MRT_TableInstance } from '..';
|
|
|
7
7
|
interface Props {
|
|
8
8
|
row: MRT_Row;
|
|
9
9
|
rowIndex: number;
|
|
10
|
-
|
|
10
|
+
table: MRT_TableInstance;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex,
|
|
13
|
+
export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, table }) => {
|
|
14
14
|
const {
|
|
15
15
|
getIsSomeColumnsPinned,
|
|
16
|
-
options: { muiTableBodyRowProps,
|
|
17
|
-
} =
|
|
16
|
+
options: { muiTableBodyRowProps, renderDetailPanel },
|
|
17
|
+
} = table;
|
|
18
18
|
|
|
19
19
|
const tableRowProps =
|
|
20
20
|
muiTableBodyRowProps instanceof Function
|
|
21
|
-
? muiTableBodyRowProps({ row,
|
|
21
|
+
? muiTableBodyRowProps({ row, table })
|
|
22
22
|
: muiTableBodyRowProps;
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<>
|
|
26
26
|
<TableRow
|
|
27
27
|
hover
|
|
28
|
-
onClick={(event: MouseEvent<HTMLTableRowElement>) =>
|
|
29
|
-
onRowClick?.({ event, row, instance })
|
|
30
|
-
}
|
|
31
28
|
selected={row.getIsSelected()}
|
|
32
29
|
{...tableRowProps}
|
|
33
30
|
sx={(theme) => ({
|
|
@@ -44,18 +41,18 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, instance }) => {
|
|
|
44
41
|
...(tableRowProps?.sx as any),
|
|
45
42
|
})}
|
|
46
43
|
>
|
|
47
|
-
{row
|
|
44
|
+
{row?.getVisibleCells()?.map?.((cell) => (
|
|
48
45
|
<MRT_TableBodyCell
|
|
49
46
|
cell={cell}
|
|
50
47
|
key={cell.id}
|
|
51
48
|
enableHover={tableRowProps?.hover !== false}
|
|
52
49
|
rowIndex={rowIndex}
|
|
53
|
-
|
|
50
|
+
table={table}
|
|
54
51
|
/>
|
|
55
52
|
))}
|
|
56
53
|
</TableRow>
|
|
57
54
|
{renderDetailPanel && !row.getIsGrouped() && (
|
|
58
|
-
<MRT_TableDetailPanel row={row}
|
|
55
|
+
<MRT_TableDetailPanel row={row} table={table} />
|
|
59
56
|
)}
|
|
60
57
|
</>
|
|
61
58
|
);
|
|
@@ -1,53 +1,49 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { Collapse, TableCell, TableRow } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
row: MRT_Row;
|
|
7
|
-
|
|
7
|
+
table: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_TableDetailPanel: FC<Props> = ({ row,
|
|
10
|
+
export const MRT_TableDetailPanel: FC<Props> = ({ row, table }) => {
|
|
11
11
|
const {
|
|
12
12
|
getVisibleLeafColumns,
|
|
13
13
|
options: {
|
|
14
14
|
muiTableBodyRowProps,
|
|
15
15
|
muiTableDetailPanelProps,
|
|
16
|
-
onDetailPanelClick,
|
|
17
16
|
renderDetailPanel,
|
|
18
17
|
},
|
|
19
|
-
} =
|
|
18
|
+
} = table;
|
|
20
19
|
|
|
21
20
|
const tableRowProps =
|
|
22
21
|
muiTableBodyRowProps instanceof Function
|
|
23
|
-
? muiTableBodyRowProps({ row,
|
|
22
|
+
? muiTableBodyRowProps({ row, table })
|
|
24
23
|
: muiTableBodyRowProps;
|
|
25
24
|
|
|
26
25
|
const tableCellProps =
|
|
27
26
|
muiTableDetailPanelProps instanceof Function
|
|
28
|
-
? muiTableDetailPanelProps({ row,
|
|
27
|
+
? muiTableDetailPanelProps({ row, table })
|
|
29
28
|
: muiTableDetailPanelProps;
|
|
30
29
|
|
|
31
30
|
return (
|
|
32
31
|
<TableRow {...tableRowProps}>
|
|
33
32
|
<TableCell
|
|
34
33
|
colSpan={getVisibleLeafColumns().length}
|
|
35
|
-
onClick={(event: MouseEvent<HTMLTableCellElement>) =>
|
|
36
|
-
onDetailPanelClick?.({ event, row, instance })
|
|
37
|
-
}
|
|
38
34
|
{...tableCellProps}
|
|
39
35
|
sx={{
|
|
40
36
|
borderBottom: !row.getIsExpanded() ? 'none' : undefined,
|
|
41
37
|
pb: row.getIsExpanded() ? '1rem' : 0,
|
|
42
38
|
pt: row.getIsExpanded() ? '1rem' : 0,
|
|
43
39
|
transition: 'all 0.2s ease-in-out',
|
|
44
|
-
width: `${
|
|
40
|
+
width: `${table.getTotalSize()}px`,
|
|
45
41
|
...tableCellProps?.sx,
|
|
46
42
|
}}
|
|
47
43
|
>
|
|
48
44
|
{renderDetailPanel && (
|
|
49
45
|
<Collapse in={row.getIsExpanded()}>
|
|
50
|
-
{renderDetailPanel({ row,
|
|
46
|
+
{renderDetailPanel({ row, table })}
|
|
51
47
|
</Collapse>
|
|
52
48
|
)}
|
|
53
49
|
</TableCell>
|
|
@@ -4,16 +4,16 @@ import type { MRT_Column, MRT_TableInstance } from '..';
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
column: MRT_Column;
|
|
7
|
-
|
|
7
|
+
table: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_ColumnPinningButtons: FC<Props> = ({ column,
|
|
10
|
+
export const MRT_ColumnPinningButtons: FC<Props> = ({ column, table }) => {
|
|
11
11
|
const {
|
|
12
12
|
options: {
|
|
13
13
|
icons: { PushPinIcon },
|
|
14
14
|
localization,
|
|
15
15
|
},
|
|
16
|
-
} =
|
|
16
|
+
} = table;
|
|
17
17
|
|
|
18
18
|
const handlePinColumn = (pinDirection: 'left' | 'right' | false) => {
|
|
19
19
|
column.pin(pinDirection);
|
|
@@ -5,16 +5,14 @@ import { MRT_Cell, MRT_TableInstance } from '..';
|
|
|
5
5
|
interface Props {
|
|
6
6
|
cell: MRT_Cell;
|
|
7
7
|
children: ReactNode;
|
|
8
|
-
|
|
8
|
+
table: MRT_TableInstance;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const MRT_CopyButton: FC<Props> = ({ cell, children,
|
|
11
|
+
export const MRT_CopyButton: FC<Props> = ({ cell, children, table }) => {
|
|
12
12
|
const {
|
|
13
13
|
options: { localization, muiTableBodyCellCopyButtonProps },
|
|
14
|
-
} =
|
|
15
|
-
|
|
14
|
+
} = table;
|
|
16
15
|
const { column } = cell;
|
|
17
|
-
|
|
18
16
|
const { columnDef } = column;
|
|
19
17
|
|
|
20
18
|
const [copied, setCopied] = useState(false);
|
|
@@ -27,14 +25,14 @@ export const MRT_CopyButton: FC<Props> = ({ cell, children, instance }) => {
|
|
|
27
25
|
|
|
28
26
|
const mTableBodyCellCopyButtonProps =
|
|
29
27
|
muiTableBodyCellCopyButtonProps instanceof Function
|
|
30
|
-
? muiTableBodyCellCopyButtonProps({ cell,
|
|
28
|
+
? muiTableBodyCellCopyButtonProps({ cell, table })
|
|
31
29
|
: muiTableBodyCellCopyButtonProps;
|
|
32
30
|
|
|
33
31
|
const mcTableBodyCellCopyButtonProps =
|
|
34
32
|
columnDef.muiTableBodyCellCopyButtonProps instanceof Function
|
|
35
33
|
? columnDef.muiTableBodyCellCopyButtonProps({
|
|
36
34
|
cell,
|
|
37
|
-
|
|
35
|
+
table,
|
|
38
36
|
})
|
|
39
37
|
: columnDef.muiTableBodyCellCopyButtonProps;
|
|
40
38
|
|
|
@@ -4,10 +4,10 @@ import type { MRT_Row, MRT_TableInstance } from '..';
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
row: MRT_Row;
|
|
7
|
-
|
|
7
|
+
table: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_EditActionButtons: FC<Props> = ({ row,
|
|
10
|
+
export const MRT_EditActionButtons: FC<Props> = ({ row, table }) => {
|
|
11
11
|
const {
|
|
12
12
|
getState,
|
|
13
13
|
options: {
|
|
@@ -16,8 +16,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, instance }) => {
|
|
|
16
16
|
onEditRowSubmit,
|
|
17
17
|
},
|
|
18
18
|
setCurrentEditingRow,
|
|
19
|
-
} =
|
|
20
|
-
|
|
19
|
+
} = table;
|
|
21
20
|
const { currentEditingRow } = getState();
|
|
22
21
|
|
|
23
22
|
const handleCancel = () => {
|
|
@@ -26,7 +25,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, instance }) => {
|
|
|
26
25
|
};
|
|
27
26
|
|
|
28
27
|
const handleSave = () => {
|
|
29
|
-
onEditRowSubmit?.({ row: currentEditingRow ?? row,
|
|
28
|
+
onEditRowSubmit?.({ row: currentEditingRow ?? row, table });
|
|
30
29
|
setCurrentEditingRow(null);
|
|
31
30
|
};
|
|
32
31
|
|
|
@@ -3,10 +3,10 @@ import { IconButton, Tooltip } from '@mui/material';
|
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
|
-
|
|
6
|
+
table: MRT_TableInstance;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const MRT_ExpandAllButton: FC<Props> = ({
|
|
9
|
+
export const MRT_ExpandAllButton: FC<Props> = ({ table }) => {
|
|
10
10
|
const {
|
|
11
11
|
getIsAllRowsExpanded,
|
|
12
12
|
getIsSomeRowsExpanded,
|
|
@@ -19,13 +19,12 @@ export const MRT_ExpandAllButton: FC<Props> = ({ instance }) => {
|
|
|
19
19
|
renderDetailPanel,
|
|
20
20
|
},
|
|
21
21
|
toggleAllRowsExpanded,
|
|
22
|
-
} =
|
|
23
|
-
|
|
22
|
+
} = table;
|
|
24
23
|
const { density } = getState();
|
|
25
24
|
|
|
26
25
|
const iconButtonProps =
|
|
27
26
|
muiExpandAllButtonProps instanceof Function
|
|
28
|
-
? muiExpandAllButtonProps({
|
|
27
|
+
? muiExpandAllButtonProps({ table })
|
|
29
28
|
: muiExpandAllButtonProps;
|
|
30
29
|
|
|
31
30
|
return (
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
row: MRT_Row;
|
|
7
|
-
|
|
7
|
+
table: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_ExpandButton: FC<Props> = ({ row,
|
|
10
|
+
export const MRT_ExpandButton: FC<Props> = ({ row, table }) => {
|
|
11
11
|
const {
|
|
12
12
|
getState,
|
|
13
13
|
options: {
|
|
14
14
|
icons: { ExpandMoreIcon },
|
|
15
15
|
localization,
|
|
16
16
|
muiExpandButtonProps,
|
|
17
|
-
onExpandChanged,
|
|
18
17
|
renderDetailPanel,
|
|
19
18
|
},
|
|
20
|
-
} =
|
|
21
|
-
|
|
19
|
+
} = table;
|
|
22
20
|
const { density } = getState();
|
|
23
21
|
|
|
24
22
|
const iconButtonProps =
|
|
25
23
|
muiExpandButtonProps instanceof Function
|
|
26
|
-
? muiExpandButtonProps({
|
|
24
|
+
? muiExpandButtonProps({ table, row })
|
|
27
25
|
: muiExpandButtonProps;
|
|
28
26
|
|
|
29
|
-
const handleToggleExpand = (
|
|
27
|
+
const handleToggleExpand = () => {
|
|
30
28
|
row.toggleExpanded();
|
|
31
|
-
onExpandChanged?.({ event, row, instance });
|
|
32
29
|
};
|
|
33
30
|
|
|
34
31
|
return (
|
|
@@ -1,33 +1,23 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props extends IconButtonProps {
|
|
6
|
-
|
|
6
|
+
table: MRT_TableInstance;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const MRT_FullScreenToggleButton: FC<Props> = ({
|
|
10
|
-
instance,
|
|
11
|
-
...rest
|
|
12
|
-
}) => {
|
|
9
|
+
export const MRT_FullScreenToggleButton: FC<Props> = ({ table, ...rest }) => {
|
|
13
10
|
const {
|
|
14
11
|
getState,
|
|
15
12
|
options: {
|
|
16
13
|
icons: { FullscreenExitIcon, FullscreenIcon },
|
|
17
14
|
localization,
|
|
18
|
-
onIsFullScreenChanged,
|
|
19
15
|
},
|
|
20
16
|
setIsFullScreen,
|
|
21
|
-
} =
|
|
22
|
-
|
|
17
|
+
} = table;
|
|
23
18
|
const { isFullScreen } = getState();
|
|
24
19
|
|
|
25
|
-
const handleToggleFullScreen = (
|
|
26
|
-
onIsFullScreenChanged?.({
|
|
27
|
-
event,
|
|
28
|
-
isFullScreen: !isFullScreen,
|
|
29
|
-
instance,
|
|
30
|
-
});
|
|
20
|
+
const handleToggleFullScreen = () => {
|
|
31
21
|
setIsFullScreen(!isFullScreen);
|
|
32
22
|
};
|
|
33
23
|
|
|
@@ -4,48 +4,46 @@ import { MRT_TableInstance } from '..';
|
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
ref: Ref<HTMLButtonElement>;
|
|
7
|
-
|
|
7
|
+
table: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_GrabHandleButton: FC<Props> = forwardRef(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} = instance;
|
|
10
|
+
export const MRT_GrabHandleButton: FC<Props> = forwardRef(({ table }, ref) => {
|
|
11
|
+
const {
|
|
12
|
+
options: {
|
|
13
|
+
icons: { DragHandleIcon },
|
|
14
|
+
localization,
|
|
15
|
+
},
|
|
16
|
+
} = table;
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
return (
|
|
19
|
+
<Tooltip
|
|
20
|
+
arrow
|
|
21
|
+
enterDelay={1000}
|
|
22
|
+
enterNextDelay={1000}
|
|
23
|
+
placement="top"
|
|
24
|
+
title={localization.grab}
|
|
25
|
+
>
|
|
26
|
+
<IconButton
|
|
27
|
+
disableRipple
|
|
28
|
+
ref={ref}
|
|
29
|
+
size="small"
|
|
30
|
+
sx={{
|
|
31
|
+
cursor: 'grab',
|
|
32
|
+
m: 0,
|
|
33
|
+
opacity: 0.5,
|
|
34
|
+
p: '2px',
|
|
35
|
+
transition: 'all 0.2s ease-in-out',
|
|
36
|
+
'&:hover': {
|
|
37
|
+
backgroundColor: 'transparent',
|
|
38
|
+
opacity: 1,
|
|
39
|
+
},
|
|
40
|
+
'&:active': {
|
|
41
|
+
cursor: 'grabbing',
|
|
42
|
+
},
|
|
43
|
+
}}
|
|
26
44
|
>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
cursor: 'grab',
|
|
33
|
-
m: 0,
|
|
34
|
-
opacity: 0.5,
|
|
35
|
-
p: '2px',
|
|
36
|
-
transition: 'all 0.2s ease-in-out',
|
|
37
|
-
'&:hover': {
|
|
38
|
-
backgroundColor: 'transparent',
|
|
39
|
-
opacity: 1,
|
|
40
|
-
},
|
|
41
|
-
'&:active': {
|
|
42
|
-
cursor: 'grabbing',
|
|
43
|
-
},
|
|
44
|
-
}}
|
|
45
|
-
>
|
|
46
|
-
<DragHandleIcon />
|
|
47
|
-
</IconButton>
|
|
48
|
-
</Tooltip>
|
|
49
|
-
);
|
|
50
|
-
},
|
|
51
|
-
);
|
|
45
|
+
<DragHandleIcon />
|
|
46
|
+
</IconButton>
|
|
47
|
+
</Tooltip>
|
|
48
|
+
);
|
|
49
|
+
});
|
|
@@ -4,16 +4,16 @@ import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
|
4
4
|
import { MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
6
|
interface Props extends IconButtonProps {
|
|
7
|
-
|
|
7
|
+
table: MRT_TableInstance;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_ShowHideColumnsButton: FC<Props> = ({
|
|
10
|
+
export const MRT_ShowHideColumnsButton: FC<Props> = ({ table, ...rest }) => {
|
|
11
11
|
const {
|
|
12
12
|
options: {
|
|
13
13
|
icons: { ViewColumnIcon },
|
|
14
14
|
localization,
|
|
15
15
|
},
|
|
16
|
-
} =
|
|
16
|
+
} = table;
|
|
17
17
|
|
|
18
18
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
19
19
|
|
|
@@ -35,7 +35,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ instance, ...rest }) => {
|
|
|
35
35
|
<MRT_ShowHideColumnsMenu
|
|
36
36
|
anchorEl={anchorEl}
|
|
37
37
|
setAnchorEl={setAnchorEl}
|
|
38
|
-
|
|
38
|
+
table={table}
|
|
39
39
|
/>
|
|
40
40
|
</>
|
|
41
41
|
);
|
|
@@ -1,39 +1,29 @@
|
|
|
1
|
-
import React, { FC
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, IconButtonProps, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props extends IconButtonProps {
|
|
6
|
-
|
|
6
|
+
table: MRT_TableInstance;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
10
|
-
instance,
|
|
11
|
-
...rest
|
|
12
|
-
}) => {
|
|
9
|
+
export const MRT_ToggleDensePaddingButton: FC<Props> = ({ table, ...rest }) => {
|
|
13
10
|
const {
|
|
14
11
|
getState,
|
|
15
12
|
options: {
|
|
16
13
|
icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon },
|
|
17
14
|
localization,
|
|
18
|
-
onDensityChanged,
|
|
19
15
|
},
|
|
20
16
|
setDensity,
|
|
21
|
-
} =
|
|
22
|
-
|
|
17
|
+
} = table;
|
|
23
18
|
const { density } = getState();
|
|
24
19
|
|
|
25
|
-
const handleToggleDensePadding = (
|
|
20
|
+
const handleToggleDensePadding = () => {
|
|
26
21
|
const nextDensity =
|
|
27
22
|
density === 'comfortable'
|
|
28
23
|
? 'compact'
|
|
29
24
|
: density === 'compact'
|
|
30
25
|
? 'spacious'
|
|
31
26
|
: 'comfortable';
|
|
32
|
-
onDensityChanged?.({
|
|
33
|
-
event,
|
|
34
|
-
density: nextDensity,
|
|
35
|
-
instance,
|
|
36
|
-
});
|
|
37
27
|
setDensity(nextDensity);
|
|
38
28
|
};
|
|
39
29
|
|