material-react-table 0.7.5 → 0.8.0-alpha.2
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 +16 -15
- package/dist/body/MRT_TableBody.d.ts +0 -1
- package/dist/body/MRT_TableBodyCell.d.ts +1 -0
- package/dist/body/MRT_TableBodyRow.d.ts +0 -1
- package/dist/buttons/MRT_ColumnPinningButtons.d.ts +8 -0
- package/dist/buttons/MRT_CopyButton.d.ts +2 -1
- package/dist/enums.d.ts +2 -2
- package/dist/filtersFNs.d.ts +31 -30
- package/dist/footer/MRT_TableFooter.d.ts +0 -1
- package/dist/head/MRT_TableHead.d.ts +0 -1
- package/dist/inputs/MRT_FilterRangeFields.d.ts +8 -0
- package/dist/inputs/MRT_FilterTextField.d.ts +1 -0
- package/dist/localization.d.ts +7 -2
- package/dist/material-react-table.cjs.development.js +451 -418
- 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 +454 -421
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_Table.d.ts +0 -1
- package/dist/toolbar/MRT_ToolbarTop.d.ts +1 -0
- package/dist/utils.d.ts +1 -1
- package/package.json +21 -25
- package/src/MaterialReactTable.tsx +20 -24
- package/src/body/MRT_TableBody.tsx +3 -11
- package/src/body/MRT_TableBodyCell.tsx +103 -52
- package/src/body/MRT_TableBodyRow.tsx +21 -30
- package/src/buttons/MRT_ColumnPinningButtons.tsx +57 -0
- package/src/buttons/MRT_CopyButton.tsx +3 -2
- package/src/buttons/MRT_EditActionButtons.tsx +1 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +22 -18
- package/src/buttons/MRT_ExpandButton.tsx +27 -21
- package/src/enums.ts +2 -2
- package/src/filtersFNs.ts +71 -81
- package/src/footer/MRT_TableFooter.tsx +6 -16
- package/src/footer/MRT_TableFooterCell.tsx +15 -15
- package/src/footer/MRT_TableFooterRow.tsx +6 -8
- package/src/head/MRT_TableHead.tsx +5 -16
- package/src/head/MRT_TableHeadCell.tsx +116 -49
- package/src/head/MRT_TableHeadRow.tsx +8 -15
- package/src/inputs/MRT_EditCellTextField.tsx +3 -3
- package/src/inputs/MRT_FilterRangeFields.tsx +41 -0
- package/src/inputs/MRT_FilterTextField.tsx +76 -41
- package/src/inputs/MRT_SelectCheckbox.tsx +15 -17
- package/src/localization.ts +15 -5
- package/src/menus/MRT_ColumnActionMenu.tsx +13 -12
- package/src/menus/MRT_FilterOptionMenu.tsx +36 -33
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +25 -11
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +16 -6
- package/src/table/MRT_Table.tsx +8 -19
- package/src/table/MRT_TableContainer.tsx +8 -69
- package/src/table/MRT_TableRoot.tsx +44 -52
- package/src/toolbar/MRT_LinearProgressBar.tsx +5 -2
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -2
- package/src/toolbar/MRT_ToolbarTop.tsx +4 -6
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { FC, useState } from 'react';
|
|
1
|
+
import React, { FC, ReactNode, useState } from 'react';
|
|
2
2
|
import { Button, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_Cell, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
cell: MRT_Cell;
|
|
7
|
+
children: ReactNode;
|
|
7
8
|
tableInstance: MRT_TableInstance;
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -49,7 +50,7 @@ export const MRT_CopyButton: FC<Props> = ({
|
|
|
49
50
|
>
|
|
50
51
|
<Button
|
|
51
52
|
aria-label={localization.clickToCopy}
|
|
52
|
-
onClick={() => handleCopy(cell.
|
|
53
|
+
onClick={() => handleCopy(cell.getValue())}
|
|
53
54
|
size="small"
|
|
54
55
|
{...buttonProps}
|
|
55
56
|
sx={{
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Box, IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
|
-
import { RowValues } from '@tanstack/react-table';
|
|
5
4
|
|
|
6
5
|
interface Props {
|
|
7
6
|
row: MRT_Row;
|
|
@@ -22,7 +21,7 @@ export const MRT_EditActionButtons: FC<Props> = ({ row, tableInstance }) => {
|
|
|
22
21
|
const { currentEditingRow } = getState();
|
|
23
22
|
|
|
24
23
|
const handleCancel = () => {
|
|
25
|
-
row.
|
|
24
|
+
row._valuesCache = row.original ?? {};
|
|
26
25
|
setCurrentEditingRow(null);
|
|
27
26
|
};
|
|
28
27
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton } from '@mui/material';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -13,7 +13,6 @@ export const MRT_ExpandAllButton: FC<Props> = ({ tableInstance }) => {
|
|
|
13
13
|
getState,
|
|
14
14
|
options: {
|
|
15
15
|
icons: { DoubleArrowDownIcon },
|
|
16
|
-
isLoading,
|
|
17
16
|
localization,
|
|
18
17
|
},
|
|
19
18
|
toggleAllRowsExpanded,
|
|
@@ -22,24 +21,29 @@ export const MRT_ExpandAllButton: FC<Props> = ({ tableInstance }) => {
|
|
|
22
21
|
const { isDensePadding } = getState();
|
|
23
22
|
|
|
24
23
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
<Tooltip
|
|
25
|
+
arrow
|
|
26
|
+
enterDelay={1000}
|
|
27
|
+
enterNextDelay={1000}
|
|
28
28
|
title={localization.expandAll}
|
|
29
|
-
onClick={() => toggleAllRowsExpanded(!getIsAllRowsExpanded())}
|
|
30
|
-
sx={{
|
|
31
|
-
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
32
|
-
width: isDensePadding ? '1.75rem' : '2.25rem',
|
|
33
|
-
}}
|
|
34
29
|
>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
<IconButton
|
|
31
|
+
aria-label={localization.expandAll}
|
|
32
|
+
onClick={() => toggleAllRowsExpanded(!getIsAllRowsExpanded())}
|
|
33
|
+
sx={{
|
|
34
|
+
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
35
|
+
width: isDensePadding ? '1.75rem' : '2.25rem',
|
|
41
36
|
}}
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
>
|
|
38
|
+
<DoubleArrowDownIcon
|
|
39
|
+
style={{
|
|
40
|
+
transform: `rotate(${
|
|
41
|
+
getIsAllRowsExpanded() ? -180 : getIsSomeRowsExpanded() ? -90 : 0
|
|
42
|
+
}deg)`,
|
|
43
|
+
transition: 'transform 0.2s',
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
</IconButton>
|
|
47
|
+
</Tooltip>
|
|
44
48
|
);
|
|
45
49
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { IconButton } from '@mui/material';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import type { MRT_Row, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -26,28 +26,34 @@ export const MRT_ExpandButton: FC<Props> = ({ row, tableInstance }) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
<Tooltip
|
|
30
|
+
arrow
|
|
31
|
+
enterDelay={1000}
|
|
32
|
+
enterNextDelay={1000}
|
|
32
33
|
title={localization.expand}
|
|
33
|
-
onClick={handleToggleExpand}
|
|
34
|
-
sx={{
|
|
35
|
-
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
36
|
-
width: isDensePadding ? '1.75rem' : '2.25rem',
|
|
37
|
-
}}
|
|
38
34
|
>
|
|
39
|
-
<
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
: 0
|
|
47
|
-
}deg)`,
|
|
48
|
-
transition: 'transform 0.2s',
|
|
35
|
+
<IconButton
|
|
36
|
+
aria-label={localization.expand}
|
|
37
|
+
disabled={!row.getCanExpand() && !renderDetailPanel}
|
|
38
|
+
onClick={handleToggleExpand}
|
|
39
|
+
sx={{
|
|
40
|
+
height: isDensePadding ? '1.75rem' : '2.25rem',
|
|
41
|
+
width: isDensePadding ? '1.75rem' : '2.25rem',
|
|
49
42
|
}}
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
>
|
|
44
|
+
<ExpandMoreIcon
|
|
45
|
+
style={{
|
|
46
|
+
transform: `rotate(${
|
|
47
|
+
!row.getCanExpand() && !renderDetailPanel
|
|
48
|
+
? -90
|
|
49
|
+
: row.getIsExpanded()
|
|
50
|
+
? -180
|
|
51
|
+
: 0
|
|
52
|
+
}deg)`,
|
|
53
|
+
transition: 'transform 0.2s',
|
|
54
|
+
}}
|
|
55
|
+
/>
|
|
56
|
+
</IconButton>
|
|
57
|
+
</Tooltip>
|
|
52
58
|
);
|
|
53
59
|
};
|
package/src/enums.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export enum MRT_FILTER_OPTION {
|
|
2
|
-
|
|
3
|
-
BEST_MATCH_FIRST = 'bestMatchFirst',
|
|
2
|
+
BETWEEN = 'between',
|
|
4
3
|
CONTAINS = 'contains',
|
|
5
4
|
EMPTY = 'empty',
|
|
6
5
|
ENDS_WITH = 'endsWith',
|
|
7
6
|
EQUALS = 'equals',
|
|
7
|
+
FUZZY = 'fuzzy',
|
|
8
8
|
GREATER_THAN = 'greaterThan',
|
|
9
9
|
LESS_THAN = 'lessThan',
|
|
10
10
|
NOT_EMPTY = 'notEmpty',
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,155 +1,145 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { rankItem, rankings, RankingInfo } from '@tanstack/match-sorter-utils';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
) =>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
: [`values.${columnIds}`],
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
bestMatchFirst.autoRemove = (val: any) => !val;
|
|
16
|
-
|
|
17
|
-
export const bestMatch = (
|
|
18
|
-
rows: MRT_Row[],
|
|
19
|
-
columnIds: string[] | string,
|
|
20
|
-
filterValue: string | number,
|
|
21
|
-
) =>
|
|
22
|
-
matchSorter(rows, filterValue.toString().trim(), {
|
|
23
|
-
keys: Array.isArray(columnIds)
|
|
24
|
-
? columnIds.map((c) => `values.${c}`)
|
|
25
|
-
: [`values.${columnIds}`],
|
|
26
|
-
sorter: (rankedItems) => rankedItems,
|
|
4
|
+
export const fuzzy = (
|
|
5
|
+
row: MRT_Row,
|
|
6
|
+
columnId: string,
|
|
7
|
+
value: string,
|
|
8
|
+
addMeta: (item: RankingInfo) => void,
|
|
9
|
+
) => {
|
|
10
|
+
const itemRank = rankItem(row.getValue(columnId), value, {
|
|
11
|
+
threshold: rankings.MATCHES,
|
|
27
12
|
});
|
|
13
|
+
addMeta(itemRank);
|
|
14
|
+
return itemRank.passed;
|
|
15
|
+
};
|
|
28
16
|
|
|
29
|
-
|
|
17
|
+
fuzzy.autoRemove = (val: any) => !val;
|
|
30
18
|
|
|
31
19
|
export const contains = (
|
|
32
|
-
|
|
20
|
+
row: MRT_Row,
|
|
33
21
|
id: string,
|
|
34
22
|
filterValue: string | number,
|
|
35
23
|
) =>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
);
|
|
24
|
+
row
|
|
25
|
+
.getValue(id)
|
|
26
|
+
.toString()
|
|
27
|
+
.toLowerCase()
|
|
28
|
+
.trim()
|
|
29
|
+
.includes(filterValue.toString().toLowerCase().trim());
|
|
43
30
|
|
|
44
31
|
contains.autoRemove = (val: any) => !val;
|
|
45
32
|
|
|
46
33
|
export const startsWith = (
|
|
47
|
-
|
|
34
|
+
row: MRT_Row,
|
|
48
35
|
id: string,
|
|
49
36
|
filterValue: string | number,
|
|
50
37
|
) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
38
|
+
row
|
|
39
|
+
.getValue(id)
|
|
40
|
+
.toString()
|
|
41
|
+
.toLowerCase()
|
|
42
|
+
.trim()
|
|
43
|
+
.startsWith(filterValue.toString().toLowerCase().trim());
|
|
58
44
|
|
|
59
45
|
startsWith.autoRemove = (val: any) => !val;
|
|
60
46
|
|
|
61
47
|
export const endsWith = (
|
|
62
|
-
|
|
48
|
+
row: MRT_Row,
|
|
63
49
|
id: string,
|
|
64
50
|
filterValue: string | number,
|
|
65
51
|
) =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
);
|
|
52
|
+
row
|
|
53
|
+
.getValue(id)
|
|
54
|
+
.toString()
|
|
55
|
+
.toLowerCase()
|
|
56
|
+
.trim()
|
|
57
|
+
.endsWith(filterValue.toString().toLowerCase().trim());
|
|
73
58
|
|
|
74
59
|
endsWith.autoRemove = (val: any) => !val;
|
|
75
60
|
|
|
76
61
|
export const equals = (
|
|
77
|
-
|
|
62
|
+
row: MRT_Row,
|
|
78
63
|
id: string,
|
|
79
64
|
filterValue: string | number,
|
|
80
65
|
) =>
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
row.values[id].toString().toLowerCase().trim() ===
|
|
84
|
-
filterValue.toString().toLowerCase().trim(),
|
|
85
|
-
);
|
|
66
|
+
row.getValue(id).toString().toLowerCase().trim() ===
|
|
67
|
+
filterValue.toString().toLowerCase().trim();
|
|
86
68
|
|
|
87
69
|
equals.autoRemove = (val: any) => !val;
|
|
88
70
|
|
|
89
71
|
export const notEquals = (
|
|
90
|
-
|
|
72
|
+
row: MRT_Row,
|
|
91
73
|
id: string,
|
|
92
74
|
filterValue: string | number,
|
|
93
75
|
) =>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
row.values[id].toString().toLowerCase().trim() !==
|
|
97
|
-
filterValue.toString().toLowerCase().trim(),
|
|
98
|
-
);
|
|
76
|
+
row.getValue(id).toString().toLowerCase().trim() !==
|
|
77
|
+
filterValue.toString().toLowerCase().trim();
|
|
99
78
|
|
|
100
79
|
notEquals.autoRemove = (val: any) => !val;
|
|
101
80
|
|
|
102
81
|
export const greaterThan = (
|
|
103
|
-
|
|
82
|
+
row: MRT_Row,
|
|
104
83
|
id: string,
|
|
105
84
|
filterValue: string | number,
|
|
106
85
|
) =>
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
filterValue.toString().toLowerCase().trim(),
|
|
112
|
-
);
|
|
86
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
87
|
+
? +row.getValue(id) >= +filterValue
|
|
88
|
+
: row.getValue(id).toString().toLowerCase().trim() >
|
|
89
|
+
filterValue.toString().toLowerCase().trim();
|
|
113
90
|
|
|
114
91
|
greaterThan.autoRemove = (val: any) => !val;
|
|
115
92
|
|
|
116
93
|
export const lessThan = (
|
|
117
|
-
|
|
94
|
+
row: MRT_Row,
|
|
118
95
|
id: string,
|
|
119
96
|
filterValue: string | number,
|
|
120
97
|
) =>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
filterValue.toString().toLowerCase().trim(),
|
|
126
|
-
);
|
|
98
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
99
|
+
? +row.getValue(id) <= +filterValue
|
|
100
|
+
: row.getValue(id).toString().toLowerCase().trim() <
|
|
101
|
+
filterValue.toString().toLowerCase().trim();
|
|
127
102
|
|
|
128
103
|
lessThan.autoRemove = (val: any) => !val;
|
|
129
104
|
|
|
105
|
+
export const between = (
|
|
106
|
+
row: MRT_Row,
|
|
107
|
+
id: string,
|
|
108
|
+
filterValues: [string | number, string | number],
|
|
109
|
+
) =>
|
|
110
|
+
((['', undefined] as any[]).includes(filterValues[0]) ||
|
|
111
|
+
greaterThan(row, id, filterValues[0])) &&
|
|
112
|
+
((!isNaN(+filterValues[0]) &&
|
|
113
|
+
!isNaN(+filterValues[1]) &&
|
|
114
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
115
|
+
(['', undefined] as any[]).includes(filterValues[1]) ||
|
|
116
|
+
lessThan(row, id, filterValues[1]));
|
|
117
|
+
|
|
118
|
+
between.autoRemove = (val: any) => !val;
|
|
119
|
+
|
|
130
120
|
export const empty = (
|
|
131
|
-
|
|
121
|
+
row: MRT_Row,
|
|
132
122
|
id: string,
|
|
133
123
|
_filterValue: string | number,
|
|
134
|
-
) =>
|
|
124
|
+
) => !row.getValue(id).toString().trim();
|
|
135
125
|
|
|
136
126
|
empty.autoRemove = (val: any) => !val;
|
|
137
127
|
|
|
138
128
|
export const notEmpty = (
|
|
139
|
-
|
|
129
|
+
row: MRT_Row,
|
|
140
130
|
id: string,
|
|
141
131
|
_filterValue: string | number,
|
|
142
|
-
) =>
|
|
132
|
+
) => !!row.getValue(id).toString().trim();
|
|
143
133
|
|
|
144
134
|
notEmpty.autoRemove = (val: any) => !val;
|
|
145
135
|
|
|
146
136
|
export const defaultFilterFNs = {
|
|
147
|
-
|
|
148
|
-
bestMatchFirst,
|
|
137
|
+
between,
|
|
149
138
|
contains,
|
|
150
139
|
empty,
|
|
151
140
|
endsWith,
|
|
152
141
|
equals,
|
|
142
|
+
fuzzy,
|
|
153
143
|
greaterThan,
|
|
154
144
|
lessThan,
|
|
155
145
|
notEmpty,
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableFooter } from '@mui/material';
|
|
3
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
pinned: 'left' | 'center' | 'right' | 'none';
|
|
8
7
|
tableInstance: MRT_TableInstance;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export const MRT_TableFooter: FC<Props> = ({
|
|
10
|
+
export const MRT_TableFooter: FC<Props> = ({ tableInstance }) => {
|
|
12
11
|
const {
|
|
13
|
-
getCenterFooterGroups,
|
|
14
12
|
getFooterGroups,
|
|
15
|
-
|
|
16
|
-
getRightFooterGroups,
|
|
13
|
+
|
|
17
14
|
options: { muiTableFooterProps },
|
|
18
15
|
} = tableInstance;
|
|
19
16
|
|
|
@@ -22,19 +19,12 @@ export const MRT_TableFooter: FC<Props> = ({ pinned, tableInstance }) => {
|
|
|
22
19
|
? muiTableFooterProps({ tableInstance })
|
|
23
20
|
: muiTableFooterProps;
|
|
24
21
|
|
|
25
|
-
const getFooterGroupsMap = {
|
|
26
|
-
center: getCenterFooterGroups,
|
|
27
|
-
left: getLeftFooterGroups,
|
|
28
|
-
none: getFooterGroups,
|
|
29
|
-
right: getRightFooterGroups,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
22
|
return (
|
|
33
23
|
<TableFooter {...tableFooterProps}>
|
|
34
|
-
{
|
|
24
|
+
{getFooterGroups().map((footerGroup) => (
|
|
35
25
|
<MRT_TableFooterRow
|
|
36
|
-
footerGroup={footerGroup as
|
|
37
|
-
key={footerGroup.
|
|
26
|
+
footerGroup={footerGroup as any}
|
|
27
|
+
key={footerGroup.id}
|
|
38
28
|
tableInstance={tableInstance}
|
|
39
29
|
/>
|
|
40
30
|
))}
|
|
@@ -28,7 +28,6 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
|
|
|
28
28
|
: column.muiTableFooterCellProps;
|
|
29
29
|
|
|
30
30
|
const tableCellProps = {
|
|
31
|
-
...footer.getFooterProps(),
|
|
32
31
|
...mTableFooterCellProps,
|
|
33
32
|
...mcTableFooterCellProps,
|
|
34
33
|
};
|
|
@@ -36,9 +35,9 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
|
|
|
36
35
|
return (
|
|
37
36
|
<TableCell
|
|
38
37
|
align={column.columnDefType === 'group' ? 'center' : 'left'}
|
|
38
|
+
colSpan={footer.colSpan}
|
|
39
39
|
variant="head"
|
|
40
40
|
{...tableCellProps}
|
|
41
|
-
//@ts-ignore
|
|
42
41
|
sx={(theme) => ({
|
|
43
42
|
backgroundColor: theme.palette.background.default,
|
|
44
43
|
backgroundImage: `linear-gradient(${alpha(
|
|
@@ -46,24 +45,25 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
|
|
|
46
45
|
0.05,
|
|
47
46
|
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
48
47
|
fontWeight: 'bold',
|
|
49
|
-
maxWidth:
|
|
50
|
-
minWidth:
|
|
48
|
+
maxWidth: `${column.getSize()}px`,
|
|
49
|
+
minWidth: `${column.getSize()}px`,
|
|
51
50
|
p: isDensePadding ? '0.5rem' : '1rem',
|
|
52
51
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
53
|
-
width: column.
|
|
52
|
+
width: column.getSize(),
|
|
54
53
|
verticalAlign: 'text-top',
|
|
55
|
-
|
|
56
|
-
...tableCellProps?.sx,
|
|
54
|
+
...(tableCellProps?.sx as any),
|
|
57
55
|
})}
|
|
58
56
|
>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
<>
|
|
58
|
+
{footer.isPlaceholder
|
|
59
|
+
? null
|
|
60
|
+
: column.columnDef.Footer?.({
|
|
61
|
+
footer,
|
|
62
|
+
tableInstance,
|
|
63
|
+
}) ??
|
|
64
|
+
footer.renderFooter() ??
|
|
65
|
+
null}
|
|
66
|
+
</>
|
|
67
67
|
</TableCell>
|
|
68
68
|
);
|
|
69
69
|
};
|
|
@@ -19,27 +19,25 @@ export const MRT_TableFooterRow: FC<Props> = ({
|
|
|
19
19
|
// if no content in row, skip row
|
|
20
20
|
if (
|
|
21
21
|
!footerGroup.headers?.some(
|
|
22
|
-
(h) =>
|
|
22
|
+
(h) =>
|
|
23
|
+
(typeof h.column.columnDef.footer === 'string' &&
|
|
24
|
+
!!h.column.columnDef.footer) ||
|
|
25
|
+
h.column.columnDef.Footer,
|
|
23
26
|
)
|
|
24
27
|
)
|
|
25
28
|
return null;
|
|
26
29
|
|
|
27
|
-
const
|
|
30
|
+
const tableRowProps =
|
|
28
31
|
muiTableFooterRowProps instanceof Function
|
|
29
32
|
? muiTableFooterRowProps({ footerGroup, tableInstance })
|
|
30
33
|
: muiTableFooterRowProps;
|
|
31
34
|
|
|
32
|
-
const tableRowProps = {
|
|
33
|
-
...footerGroup.getFooterGroupProps(),
|
|
34
|
-
...mTableFooterRowProps,
|
|
35
|
-
};
|
|
36
|
-
|
|
37
35
|
return (
|
|
38
36
|
<TableRow {...tableRowProps}>
|
|
39
37
|
{footerGroup.headers.map((footer: MRT_Header) => (
|
|
40
38
|
<MRT_TableFooterCell
|
|
41
39
|
footer={footer}
|
|
42
|
-
key={footer.
|
|
40
|
+
key={footer.id}
|
|
43
41
|
tableInstance={tableInstance}
|
|
44
42
|
/>
|
|
45
43
|
))}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { TableHead } from '@mui/material';
|
|
3
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MRT_TableInstance } from '..';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
|
-
pinned: 'left' | 'center' | 'right' | 'none';
|
|
8
7
|
tableInstance: MRT_TableInstance;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
export const MRT_TableHead: FC<Props> = ({
|
|
10
|
+
export const MRT_TableHead: FC<Props> = ({ tableInstance }) => {
|
|
12
11
|
const {
|
|
13
|
-
getCenterHeaderGroups,
|
|
14
12
|
getHeaderGroups,
|
|
15
|
-
getLeftHeaderGroups,
|
|
16
|
-
getRightHeaderGroups,
|
|
17
13
|
options: { muiTableHeadProps },
|
|
18
14
|
} = tableInstance;
|
|
19
15
|
|
|
@@ -22,19 +18,12 @@ export const MRT_TableHead: FC<Props> = ({ pinned, tableInstance }) => {
|
|
|
22
18
|
? muiTableHeadProps({ tableInstance })
|
|
23
19
|
: muiTableHeadProps;
|
|
24
20
|
|
|
25
|
-
const getHeaderGroupsMap = {
|
|
26
|
-
center: getCenterHeaderGroups,
|
|
27
|
-
left: getLeftHeaderGroups,
|
|
28
|
-
none: getHeaderGroups,
|
|
29
|
-
right: getRightHeaderGroups,
|
|
30
|
-
};
|
|
31
|
-
|
|
32
21
|
return (
|
|
33
22
|
<TableHead {...tableHeadProps}>
|
|
34
|
-
{
|
|
23
|
+
{getHeaderGroups().map((headerGroup) => (
|
|
35
24
|
<MRT_TableHeadRow
|
|
36
|
-
headerGroup={headerGroup as
|
|
37
|
-
key={headerGroup.
|
|
25
|
+
headerGroup={headerGroup as any}
|
|
26
|
+
key={headerGroup.id}
|
|
38
27
|
tableInstance={tableInstance}
|
|
39
28
|
/>
|
|
40
29
|
))}
|