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
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
|
2
2
|
import { Menu, MenuItem } from '@mui/material';
|
|
3
|
-
import type {
|
|
4
|
-
MRT_FilterFn,
|
|
5
|
-
MRT_FILTER_OPTION,
|
|
6
|
-
MRT_Header,
|
|
7
|
-
MRT_TableInstance,
|
|
8
|
-
} from '..';
|
|
9
|
-
import {
|
|
10
|
-
between,
|
|
11
|
-
contains,
|
|
12
|
-
empty,
|
|
13
|
-
endsWith,
|
|
14
|
-
equals,
|
|
15
|
-
fuzzy,
|
|
16
|
-
greaterThan,
|
|
17
|
-
lessThan,
|
|
18
|
-
notEmpty,
|
|
19
|
-
notEquals,
|
|
20
|
-
startsWith,
|
|
21
|
-
} from '../filtersFns';
|
|
3
|
+
import type { MRT_FilterOption, MRT_Header, MRT_TableInstance } from '..';
|
|
22
4
|
|
|
23
5
|
const commonMenuItemStyles = {
|
|
24
6
|
py: '6px',
|
|
@@ -31,7 +13,7 @@ interface Props {
|
|
|
31
13
|
header?: MRT_Header;
|
|
32
14
|
onSelect?: () => void;
|
|
33
15
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
34
|
-
|
|
16
|
+
table: MRT_TableInstance;
|
|
35
17
|
}
|
|
36
18
|
|
|
37
19
|
export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
@@ -39,7 +21,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
39
21
|
header,
|
|
40
22
|
onSelect,
|
|
41
23
|
setAnchorEl,
|
|
42
|
-
|
|
24
|
+
table,
|
|
43
25
|
}) => {
|
|
44
26
|
const {
|
|
45
27
|
getState,
|
|
@@ -50,12 +32,9 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
50
32
|
},
|
|
51
33
|
setCurrentFilterFns,
|
|
52
34
|
setCurrentGlobalFilterFn,
|
|
53
|
-
} =
|
|
54
|
-
|
|
55
|
-
const { density, currentFilterFns, currentGlobalFilterFn } = getState();
|
|
56
|
-
|
|
35
|
+
} = table;
|
|
36
|
+
const { currentFilterFns, currentGlobalFilterFn, density } = getState();
|
|
57
37
|
const { column } = header ?? {};
|
|
58
|
-
|
|
59
38
|
const { columnDef } = column ?? {};
|
|
60
39
|
|
|
61
40
|
const allowedColumnFilterOptions =
|
|
@@ -68,67 +47,56 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
68
47
|
option: 'fuzzy',
|
|
69
48
|
label: localization.filterFuzzy,
|
|
70
49
|
divider: false,
|
|
71
|
-
fn: fuzzy,
|
|
72
50
|
},
|
|
73
51
|
{
|
|
74
52
|
option: 'contains',
|
|
75
53
|
label: localization.filterContains,
|
|
76
54
|
divider: false,
|
|
77
|
-
fn: contains,
|
|
78
55
|
},
|
|
79
56
|
{
|
|
80
57
|
option: 'startsWith',
|
|
81
58
|
label: localization.filterStartsWith,
|
|
82
59
|
divider: false,
|
|
83
|
-
fn: startsWith,
|
|
84
60
|
},
|
|
85
61
|
{
|
|
86
62
|
option: 'endsWith',
|
|
87
63
|
label: localization.filterEndsWith,
|
|
88
64
|
divider: true,
|
|
89
|
-
fn: endsWith,
|
|
90
65
|
},
|
|
91
66
|
{
|
|
92
67
|
option: 'equals',
|
|
93
68
|
label: localization.filterEquals,
|
|
94
69
|
divider: false,
|
|
95
|
-
fn: equals,
|
|
96
70
|
},
|
|
97
71
|
{
|
|
98
72
|
option: 'notEquals',
|
|
99
73
|
label: localization.filterNotEquals,
|
|
100
74
|
divider: true,
|
|
101
|
-
fn: notEquals,
|
|
102
75
|
},
|
|
103
76
|
{
|
|
104
77
|
option: 'between',
|
|
105
78
|
label: localization.filterBetween,
|
|
106
79
|
divider: false,
|
|
107
|
-
fn: between,
|
|
108
80
|
},
|
|
109
81
|
{
|
|
110
82
|
option: 'greaterThan',
|
|
111
83
|
label: localization.filterGreaterThan,
|
|
112
84
|
divider: false,
|
|
113
|
-
fn: greaterThan,
|
|
114
85
|
},
|
|
115
86
|
{
|
|
116
87
|
option: 'lessThan',
|
|
117
88
|
label: localization.filterLessThan,
|
|
118
89
|
divider: true,
|
|
119
|
-
fn: lessThan,
|
|
120
90
|
},
|
|
121
91
|
{
|
|
122
92
|
option: 'empty',
|
|
123
93
|
label: localization.filterEmpty,
|
|
124
94
|
divider: false,
|
|
125
|
-
fn: empty,
|
|
126
95
|
},
|
|
127
96
|
{
|
|
128
97
|
option: 'notEmpty',
|
|
129
98
|
label: localization.filterNotEmpty,
|
|
130
99
|
divider: false,
|
|
131
|
-
fn: notEmpty,
|
|
132
100
|
},
|
|
133
101
|
].filter((filterType) =>
|
|
134
102
|
columnDef
|
|
@@ -138,7 +106,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
138
106
|
enabledGlobalFilterOptions.includes(filterType.option)) &&
|
|
139
107
|
['fuzzy', 'contains'].includes(filterType.option),
|
|
140
108
|
) as Array<{
|
|
141
|
-
option:
|
|
109
|
+
option: MRT_FilterOption;
|
|
142
110
|
label: string;
|
|
143
111
|
divider: boolean;
|
|
144
112
|
fn: Function;
|
|
@@ -146,21 +114,21 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
146
114
|
[],
|
|
147
115
|
);
|
|
148
116
|
|
|
149
|
-
const handleSelectFilterType = (
|
|
117
|
+
const handleSelectFilterType = (option: MRT_FilterOption) => {
|
|
150
118
|
if (header && column) {
|
|
151
|
-
setCurrentFilterFns((prev: { [key: string]:
|
|
119
|
+
setCurrentFilterFns((prev: { [key: string]: any }) => ({
|
|
152
120
|
...prev,
|
|
153
|
-
[header.id]:
|
|
121
|
+
[header.id]: option,
|
|
154
122
|
}));
|
|
155
|
-
if (['empty', 'notEmpty'].includes(
|
|
123
|
+
if (['empty', 'notEmpty'].includes(option)) {
|
|
156
124
|
column.setFilterValue(' ');
|
|
157
|
-
} else if (
|
|
125
|
+
} else if (option === 'between') {
|
|
158
126
|
column.setFilterValue(['', '']);
|
|
159
127
|
} else {
|
|
160
128
|
column.setFilterValue('');
|
|
161
129
|
}
|
|
162
130
|
} else {
|
|
163
|
-
setCurrentGlobalFilterFn(
|
|
131
|
+
setCurrentGlobalFilterFn(option);
|
|
164
132
|
}
|
|
165
133
|
setAnchorEl(null);
|
|
166
134
|
onSelect?.();
|
|
@@ -180,14 +148,14 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
180
148
|
dense: density === 'compact',
|
|
181
149
|
}}
|
|
182
150
|
>
|
|
183
|
-
{filterOptions.map(({ option, label, divider
|
|
151
|
+
{filterOptions.map(({ option, label, divider }, index) => (
|
|
184
152
|
<MenuItem
|
|
185
153
|
divider={divider}
|
|
186
154
|
key={index}
|
|
187
|
-
onClick={() => handleSelectFilterType(option
|
|
188
|
-
selected={option === filterOption
|
|
155
|
+
onClick={() => handleSelectFilterType(option)}
|
|
156
|
+
selected={option === filterOption}
|
|
189
157
|
sx={commonMenuItemStyles}
|
|
190
|
-
value={option
|
|
158
|
+
value={option}
|
|
191
159
|
>
|
|
192
160
|
{label}
|
|
193
161
|
</MenuItem>
|
|
@@ -11,7 +11,7 @@ interface Props {
|
|
|
11
11
|
handleEdit: () => void;
|
|
12
12
|
row: MRT_Row;
|
|
13
13
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
14
|
-
|
|
14
|
+
table: MRT_TableInstance;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const MRT_RowActionMenu: FC<Props> = ({
|
|
@@ -19,7 +19,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
19
19
|
handleEdit,
|
|
20
20
|
row,
|
|
21
21
|
setAnchorEl,
|
|
22
|
-
|
|
22
|
+
table,
|
|
23
23
|
}) => {
|
|
24
24
|
const {
|
|
25
25
|
getState,
|
|
@@ -29,8 +29,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
29
29
|
localization,
|
|
30
30
|
renderRowActionMenuItems,
|
|
31
31
|
},
|
|
32
|
-
} =
|
|
33
|
-
|
|
32
|
+
} = table;
|
|
34
33
|
const { density } = getState();
|
|
35
34
|
|
|
36
35
|
return (
|
|
@@ -54,7 +53,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
54
53
|
)}
|
|
55
54
|
{renderRowActionMenuItems?.({
|
|
56
55
|
row,
|
|
57
|
-
|
|
56
|
+
table,
|
|
58
57
|
closeMenu: () => setAnchorEl(null),
|
|
59
58
|
})}
|
|
60
59
|
</Menu>
|
|
@@ -8,14 +8,14 @@ interface Props {
|
|
|
8
8
|
anchorEl: HTMLElement | null;
|
|
9
9
|
isSubMenu?: boolean;
|
|
10
10
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
11
|
-
|
|
11
|
+
table: MRT_TableInstance;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
15
15
|
anchorEl,
|
|
16
16
|
isSubMenu,
|
|
17
17
|
setAnchorEl,
|
|
18
|
-
|
|
18
|
+
table,
|
|
19
19
|
}) => {
|
|
20
20
|
const {
|
|
21
21
|
getAllColumns,
|
|
@@ -29,8 +29,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
29
29
|
getState,
|
|
30
30
|
toggleAllColumnsVisible,
|
|
31
31
|
options: { localization, enablePinning, enableColumnOrdering },
|
|
32
|
-
} =
|
|
33
|
-
|
|
32
|
+
} = table;
|
|
34
33
|
const { density, columnOrder, columnPinning } = getState();
|
|
35
34
|
|
|
36
35
|
const hideAllColumns = () => {
|
|
@@ -43,7 +42,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
43
42
|
const columns = getAllColumns();
|
|
44
43
|
if (
|
|
45
44
|
columnOrder.length > 0 &&
|
|
46
|
-
!columns.some((col) => col.columnDefType === 'group')
|
|
45
|
+
!columns.some((col) => col.columnDef.columnDefType === 'group')
|
|
47
46
|
) {
|
|
48
47
|
return [
|
|
49
48
|
...getLeftLeafColumns(),
|
|
@@ -91,8 +90,8 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
91
90
|
{!isSubMenu && enableColumnOrdering && (
|
|
92
91
|
<Button
|
|
93
92
|
onClick={() =>
|
|
94
|
-
|
|
95
|
-
getDefaultColumnOrderIds(
|
|
93
|
+
table.setColumnOrder(
|
|
94
|
+
getDefaultColumnOrderIds(table.options as any),
|
|
96
95
|
)
|
|
97
96
|
}
|
|
98
97
|
>
|
|
@@ -102,7 +101,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
102
101
|
{!isSubMenu && enablePinning && (
|
|
103
102
|
<Button
|
|
104
103
|
disabled={!getIsSomeColumnsPinned()}
|
|
105
|
-
onClick={() =>
|
|
104
|
+
onClick={() => table.resetColumnPinning(true)}
|
|
106
105
|
>
|
|
107
106
|
{localization.unpinAll}
|
|
108
107
|
</Button>
|
|
@@ -121,7 +120,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
121
120
|
column={column}
|
|
122
121
|
isSubMenu={isSubMenu}
|
|
123
122
|
key={`${index}-${column.id}`}
|
|
124
|
-
|
|
123
|
+
table={table}
|
|
125
124
|
/>
|
|
126
125
|
))}
|
|
127
126
|
</Menu>
|
|
@@ -17,14 +17,14 @@ interface Props {
|
|
|
17
17
|
allColumns: MRT_Column[];
|
|
18
18
|
column: MRT_Column;
|
|
19
19
|
isSubMenu?: boolean;
|
|
20
|
-
|
|
20
|
+
table: MRT_TableInstance;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
24
24
|
allColumns,
|
|
25
25
|
column,
|
|
26
26
|
isSubMenu,
|
|
27
|
-
|
|
27
|
+
table,
|
|
28
28
|
}) => {
|
|
29
29
|
const {
|
|
30
30
|
getState,
|
|
@@ -35,11 +35,10 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
35
35
|
localization,
|
|
36
36
|
},
|
|
37
37
|
setColumnOrder,
|
|
38
|
-
} =
|
|
39
|
-
|
|
38
|
+
} = table;
|
|
40
39
|
const { columnOrder } = getState();
|
|
41
|
-
|
|
42
|
-
const {
|
|
40
|
+
const { columnDef } = column;
|
|
41
|
+
const { columnDefType } = columnDef;
|
|
43
42
|
|
|
44
43
|
const [, dropRef] = useDrop({
|
|
45
44
|
accept: 'column',
|
|
@@ -94,11 +93,13 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
94
93
|
>
|
|
95
94
|
{columnDefType !== 'group' &&
|
|
96
95
|
enableColumnOrdering &&
|
|
97
|
-
!allColumns.some(
|
|
96
|
+
!allColumns.some(
|
|
97
|
+
(col) => col.columnDef.columnDefType === 'group',
|
|
98
|
+
) &&
|
|
98
99
|
(columnDef.enableColumnOrdering !== false ? (
|
|
99
100
|
<MRT_GrabHandleButton
|
|
100
101
|
ref={dragRef as Ref<HTMLButtonElement>}
|
|
101
|
-
|
|
102
|
+
table={table}
|
|
102
103
|
/>
|
|
103
104
|
) : (
|
|
104
105
|
<Box sx={{ width: '28px' }} />
|
|
@@ -106,7 +107,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
106
107
|
{enablePinning &&
|
|
107
108
|
!isSubMenu &&
|
|
108
109
|
(column.getCanPin() ? (
|
|
109
|
-
<MRT_ColumnPinningButtons column={column}
|
|
110
|
+
<MRT_ColumnPinningButtons column={column} table={table} />
|
|
110
111
|
) : (
|
|
111
112
|
<Box sx={{ width: '70px' }} />
|
|
112
113
|
))}
|
|
@@ -152,7 +153,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
|
|
|
152
153
|
key={`${i}-${c.id}`}
|
|
153
154
|
column={c}
|
|
154
155
|
isSubMenu={isSubMenu}
|
|
155
|
-
|
|
156
|
+
table={table}
|
|
156
157
|
/>
|
|
157
158
|
))}
|
|
158
159
|
</>
|
package/src/sortingFns.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { compareItems, RankingInfo } from '@tanstack/match-sorter-utils';
|
|
2
2
|
import { Row, sortingFns } from '@tanstack/react-table';
|
|
3
|
-
import
|
|
3
|
+
import { MRT_Row } from '.';
|
|
4
4
|
|
|
5
|
-
const fuzzy =
|
|
5
|
+
const fuzzy = <D extends Record<string, any> = {}>(
|
|
6
|
+
rowA: Row<D>,
|
|
7
|
+
rowB: Row<D>,
|
|
8
|
+
columnId: string,
|
|
9
|
+
) => {
|
|
6
10
|
let dir = 0;
|
|
7
11
|
if (rowA.columnFiltersMeta[columnId]) {
|
|
8
12
|
dir = compareItems(
|
|
@@ -17,9 +21,13 @@ const fuzzy = (rowA: MRT_Row, rowB: MRT_Row, columnId: string) => {
|
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
export const MRT_SortingFns = {
|
|
24
|
+
...sortingFns,
|
|
20
25
|
fuzzy,
|
|
21
26
|
};
|
|
22
27
|
|
|
23
|
-
export const rankGlobalFuzzy =
|
|
28
|
+
export const rankGlobalFuzzy = <D extends Record<string, any> = {}>(
|
|
29
|
+
rowA: MRT_Row<D>,
|
|
30
|
+
rowB: MRT_Row<D>,
|
|
31
|
+
) =>
|
|
24
32
|
Math.max(...Object.values(rowB.columnFiltersMeta).map((v: any) => v.rank)) -
|
|
25
33
|
Math.max(...Object.values(rowA.columnFiltersMeta).map((v: any) => v.rank));
|
package/src/table/MRT_Table.tsx
CHANGED
|
@@ -7,10 +7,10 @@ import { MRT_TableInstance } from '..';
|
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
tableContainerRef: RefObject<HTMLDivElement>;
|
|
10
|
-
|
|
10
|
+
table: MRT_TableInstance;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const MRT_Table: FC<Props> = ({ tableContainerRef,
|
|
13
|
+
export const MRT_Table: FC<Props> = ({ tableContainerRef, table }) => {
|
|
14
14
|
const {
|
|
15
15
|
getState,
|
|
16
16
|
options: {
|
|
@@ -21,13 +21,12 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, instance }) => {
|
|
|
21
21
|
enableTableHead,
|
|
22
22
|
muiTableProps,
|
|
23
23
|
},
|
|
24
|
-
} =
|
|
25
|
-
|
|
24
|
+
} = table;
|
|
26
25
|
const { isFullScreen } = getState();
|
|
27
26
|
|
|
28
27
|
const tableProps =
|
|
29
28
|
muiTableProps instanceof Function
|
|
30
|
-
? muiTableProps({
|
|
29
|
+
? muiTableProps({ table })
|
|
31
30
|
: muiTableProps;
|
|
32
31
|
|
|
33
32
|
return (
|
|
@@ -42,12 +41,9 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, instance }) => {
|
|
|
42
41
|
...tableProps?.sx,
|
|
43
42
|
}}
|
|
44
43
|
>
|
|
45
|
-
{enableTableHead && <MRT_TableHead
|
|
46
|
-
<MRT_TableBody
|
|
47
|
-
|
|
48
|
-
instance={instance}
|
|
49
|
-
/>
|
|
50
|
-
{enableTableFooter && <MRT_TableFooter instance={instance} />}
|
|
44
|
+
{enableTableHead && <MRT_TableHead table={table} />}
|
|
45
|
+
<MRT_TableBody tableContainerRef={tableContainerRef} table={table} />
|
|
46
|
+
{enableTableFooter && <MRT_TableFooter table={table} />}
|
|
51
47
|
</Table>
|
|
52
48
|
);
|
|
53
49
|
};
|
|
@@ -7,10 +7,10 @@ const useIsomorphicLayoutEffect =
|
|
|
7
7
|
typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
|
-
|
|
10
|
+
table: MRT_TableInstance;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export const MRT_TableContainer: FC<Props> = ({
|
|
13
|
+
export const MRT_TableContainer: FC<Props> = ({ table }) => {
|
|
14
14
|
const {
|
|
15
15
|
getState,
|
|
16
16
|
options: {
|
|
@@ -19,15 +19,14 @@ export const MRT_TableContainer: FC<Props> = ({ instance }) => {
|
|
|
19
19
|
muiTableContainerProps,
|
|
20
20
|
tableId,
|
|
21
21
|
},
|
|
22
|
-
} =
|
|
23
|
-
|
|
22
|
+
} = table;
|
|
24
23
|
const { isFullScreen } = getState();
|
|
25
24
|
|
|
26
25
|
const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
|
|
27
26
|
|
|
28
27
|
const tableContainerProps =
|
|
29
28
|
muiTableContainerProps instanceof Function
|
|
30
|
-
? muiTableContainerProps({
|
|
29
|
+
? muiTableContainerProps({ table })
|
|
31
30
|
: muiTableContainerProps;
|
|
32
31
|
|
|
33
32
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -68,7 +67,7 @@ export const MRT_TableContainer: FC<Props> = ({ instance }) => {
|
|
|
68
67
|
...tableContainerProps?.style,
|
|
69
68
|
}}
|
|
70
69
|
>
|
|
71
|
-
<MRT_Table tableContainerRef={tableContainerRef}
|
|
70
|
+
<MRT_Table tableContainerRef={tableContainerRef} table={table} />
|
|
72
71
|
</TableContainer>
|
|
73
72
|
);
|
|
74
73
|
};
|
|
@@ -8,15 +8,14 @@ import { MRT_TableContainer } from './MRT_TableContainer';
|
|
|
8
8
|
import type { MRT_TableInstance } from '..';
|
|
9
9
|
|
|
10
10
|
interface Props {
|
|
11
|
-
|
|
11
|
+
table: MRT_TableInstance;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const MRT_TablePaper: FC<Props> = ({
|
|
14
|
+
export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
15
15
|
const {
|
|
16
16
|
getState,
|
|
17
17
|
options: { enableToolbarBottom, enableToolbarTop, muiTablePaperProps },
|
|
18
|
-
} =
|
|
19
|
-
|
|
18
|
+
} = table;
|
|
20
19
|
const { isFullScreen } = getState();
|
|
21
20
|
|
|
22
21
|
useEffect(() => {
|
|
@@ -31,7 +30,7 @@ export const MRT_TablePaper: FC<Props> = ({ instance }) => {
|
|
|
31
30
|
|
|
32
31
|
const tablePaperProps =
|
|
33
32
|
muiTablePaperProps instanceof Function
|
|
34
|
-
? muiTablePaperProps({
|
|
33
|
+
? muiTablePaperProps({ table })
|
|
35
34
|
: muiTablePaperProps;
|
|
36
35
|
|
|
37
36
|
return (
|
|
@@ -53,9 +52,9 @@ export const MRT_TablePaper: FC<Props> = ({ instance }) => {
|
|
|
53
52
|
width: isFullScreen ? '100vw' : undefined,
|
|
54
53
|
}}
|
|
55
54
|
>
|
|
56
|
-
{enableToolbarTop && <MRT_ToolbarTop
|
|
57
|
-
<MRT_TableContainer
|
|
58
|
-
{enableToolbarBottom && <MRT_ToolbarBottom
|
|
55
|
+
{enableToolbarTop && <MRT_ToolbarTop table={table} />}
|
|
56
|
+
<MRT_TableContainer table={table} />
|
|
57
|
+
{enableToolbarBottom && <MRT_ToolbarBottom table={table} />}
|
|
59
58
|
</Paper>
|
|
60
59
|
</DndProvider>
|
|
61
60
|
);
|