material-react-table 0.6.7 → 0.6.10
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 +12 -3
- package/dist/enums.d.ts +2 -1
- package/dist/filtersFNs.d.ts +13 -5
- package/dist/localization.d.ts +3 -1
- package/dist/material-react-table.cjs.development.js +339 -248
- 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 +340 -249
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_FilterTypeMenu.d.ts +1 -1
- package/dist/useMRT.d.ts +1 -0
- package/dist/utils.d.ts +2 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +29 -4
- package/src/body/MRT_TableBodyCell.tsx +8 -2
- package/src/body/MRT_TableBodyRow.tsx +30 -7
- package/src/buttons/MRT_CopyButton.tsx +24 -6
- package/src/buttons/MRT_ExpandAllButton.tsx +13 -20
- package/src/buttons/MRT_ExpandButton.tsx +20 -33
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +19 -1
- package/src/enums.ts +2 -1
- package/src/filtersFNs.ts +17 -3
- package/src/head/MRT_TableHeadCell.tsx +6 -3
- package/src/head/MRT_TableHeadRow.tsx +38 -15
- package/src/inputs/MRT_EditCellTextField.tsx +0 -6
- package/src/inputs/MRT_FilterTextField.tsx +1 -12
- package/src/inputs/MRT_SearchTextField.tsx +27 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +58 -31
- package/src/localization.ts +7 -3
- package/src/menus/MRT_ColumnActionMenu.tsx +6 -1
- package/src/menus/MRT_FilterTypeMenu.tsx +44 -18
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +12 -1
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -1
- package/src/table/MRT_TableSpacerCell.tsx +1 -8
- package/src/useMRT.tsx +12 -1
- package/src/utils.ts +8 -4
package/dist/useMRT.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
17
17
|
setCurrentFilterTypes: Dispatch<SetStateAction<{
|
|
18
18
|
[key: string]: MRT_FilterType;
|
|
19
19
|
}>>;
|
|
20
|
+
setCurrentGlobalFilterType: Dispatch<SetStateAction<MRT_FILTER_TYPE>>;
|
|
20
21
|
setDensePadding: Dispatch<SetStateAction<boolean>>;
|
|
21
22
|
setFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
22
23
|
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { MRT_ColumnInterface } from '.';
|
|
2
|
-
export declare const findLowestLevelCols: (columns: MRT_ColumnInterface[]) => MRT_ColumnInterface<{}>[];
|
|
1
|
+
import { MRT_ColumnInstance, MRT_ColumnInterface } from '.';
|
|
2
|
+
export declare const findLowestLevelCols: (columns: MRT_ColumnInterface[] | MRT_ColumnInstance[]) => MRT_ColumnInterface<{}>[];
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.6.
|
|
2
|
+
"version": "0.6.10",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React, { ChangeEvent, FC, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
AlertProps,
|
|
4
|
+
ButtonProps,
|
|
5
|
+
CheckboxProps,
|
|
4
6
|
IconButtonProps,
|
|
5
7
|
LinearProgressProps,
|
|
6
8
|
SkeletonProps,
|
|
@@ -135,11 +137,16 @@ export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
|
135
137
|
accessor?: string;
|
|
136
138
|
columns?: MRT_ColumnInterface<D>[];
|
|
137
139
|
disableClickToCopy?: boolean;
|
|
140
|
+
disableColumnActions?: boolean;
|
|
141
|
+
disableColumnHiding?: boolean;
|
|
138
142
|
disableEditing?: boolean;
|
|
139
143
|
disableFilters?: boolean;
|
|
144
|
+
enabledFilterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
140
145
|
filter?: MRT_FilterType | string | FilterType<D>;
|
|
141
146
|
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
142
|
-
|
|
147
|
+
muiTableBodyCellCopyButtonProps?:
|
|
148
|
+
| ButtonProps
|
|
149
|
+
| ((cell?: MRT_Cell<D>) => ButtonProps);
|
|
143
150
|
muiTableBodyCellEditTextFieldProps?:
|
|
144
151
|
| TextFieldProps
|
|
145
152
|
| ((cell: MRT_Cell<D>) => TextFieldProps);
|
|
@@ -149,6 +156,9 @@ export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
|
149
156
|
muiTableFooterCellProps?:
|
|
150
157
|
| TableCellProps
|
|
151
158
|
| ((column: Column<D>) => TableCellProps);
|
|
159
|
+
muiTableHeadCellColumnActionsButtonProps?:
|
|
160
|
+
| IconButtonProps
|
|
161
|
+
| ((column: Column<D>) => IconButtonProps);
|
|
152
162
|
muiTableHeadCellFilterTextFieldProps?:
|
|
153
163
|
| TextFieldProps
|
|
154
164
|
| ((column: Column<D>) => TextFieldProps);
|
|
@@ -209,6 +219,7 @@ export type MRT_TableState<D extends {} = {}> = TableState<D> &
|
|
|
209
219
|
UseSortByState<D> & {
|
|
210
220
|
currentEditingRow: MRT_Row<D> | null;
|
|
211
221
|
currentFilterTypes: { [key: string]: MRT_FilterType };
|
|
222
|
+
currentGlobalFilterType: MRT_FilterType;
|
|
212
223
|
densePadding: boolean;
|
|
213
224
|
fullScreen: boolean;
|
|
214
225
|
showFilters: boolean;
|
|
@@ -240,6 +251,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
240
251
|
enableRowEditing?: boolean;
|
|
241
252
|
enableRowNumbers?: boolean;
|
|
242
253
|
enableSelection?: boolean;
|
|
254
|
+
enabledGlobalFilterTypes?: (MRT_FILTER_TYPE | string)[];
|
|
243
255
|
filterTypes?: { [key in MRT_FILTER_TYPE]: any };
|
|
244
256
|
hideTableFooter?: boolean;
|
|
245
257
|
hideTableHead?: boolean;
|
|
@@ -255,6 +267,16 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
255
267
|
| LinearProgressProps
|
|
256
268
|
| ((tableInstance: MRT_TableInstance) => LinearProgressProps);
|
|
257
269
|
muiSearchTextFieldProps?: TextFieldProps;
|
|
270
|
+
muiSelectCheckboxProps?:
|
|
271
|
+
| CheckboxProps
|
|
272
|
+
| ((
|
|
273
|
+
isSelectAll?: boolean,
|
|
274
|
+
row?: MRT_Row<D>,
|
|
275
|
+
tableInstance?: MRT_TableInstance<D>,
|
|
276
|
+
) => CheckboxProps);
|
|
277
|
+
muiTableBodyCellCopyButtonProps?:
|
|
278
|
+
| ButtonProps
|
|
279
|
+
| ((cell?: MRT_Cell<D>) => ButtonProps);
|
|
258
280
|
muiTableBodyCellEditTextFieldProps?:
|
|
259
281
|
| TextFieldProps
|
|
260
282
|
| ((cell?: MRT_Cell<D>) => TextFieldProps);
|
|
@@ -283,6 +305,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
283
305
|
muiTableFooterRowProps?:
|
|
284
306
|
| TableRowProps
|
|
285
307
|
| ((footerGroup: MRT_HeaderGroup<D>) => TableRowProps);
|
|
308
|
+
muiTableHeadCellColumnActionsButtonProps?:
|
|
309
|
+
| IconButtonProps
|
|
310
|
+
| ((column: Column<D>) => IconButtonProps);
|
|
286
311
|
muiTableHeadCellFilterTextFieldProps?:
|
|
287
312
|
| TextFieldProps
|
|
288
313
|
| ((column: Column<D>) => TextFieldProps);
|
|
@@ -328,12 +353,12 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
328
353
|
event: MouseEvent<HTMLButtonElement>,
|
|
329
354
|
row: Row<D>,
|
|
330
355
|
) => void;
|
|
331
|
-
|
|
356
|
+
onSelectAllChange?: (event: ChangeEvent, selectedRows: Row<D>[]) => void;
|
|
357
|
+
onSelectChange?: (
|
|
332
358
|
event: ChangeEvent,
|
|
333
359
|
row: Row<D>,
|
|
334
360
|
selectedRows: Row<D>[],
|
|
335
361
|
) => void;
|
|
336
|
-
onSelectAllChange?: (event: ChangeEvent, selectedRows: Row<D>[]) => void;
|
|
337
362
|
positionActionsColumn?: 'first' | 'last';
|
|
338
363
|
positionPagination?: 'bottom' | 'top' | 'both';
|
|
339
364
|
positionToolbarActions?: 'bottom' | 'top';
|
|
@@ -372,7 +397,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
372
397
|
export default <D extends {} = {}>({
|
|
373
398
|
defaultColumn = { minWidth: 50, maxWidth: 1000 },
|
|
374
399
|
filterTypes,
|
|
375
|
-
globalFilter =
|
|
400
|
+
globalFilter = MRT_FILTER_TYPE.BEST_MATCH_FIRST,
|
|
376
401
|
icons,
|
|
377
402
|
localization,
|
|
378
403
|
positionActionsColumn = 'first',
|
|
@@ -78,13 +78,19 @@ export const MRT_TableBodyCell: FC<Props> = ({ cell }) => {
|
|
|
78
78
|
currentEditingRow?.id === cell.row.id ? (
|
|
79
79
|
<MRT_EditCellTextField cell={cell} />
|
|
80
80
|
) : cell.isPlaceholder ? null : cell.isAggregated ? (
|
|
81
|
-
cell.
|
|
81
|
+
enableClickToCopy && !cell.column.disableClickToCopy ? (
|
|
82
|
+
<MRT_CopyButton cell={cell}>
|
|
83
|
+
{cell.render('Aggregated')}
|
|
84
|
+
</MRT_CopyButton>
|
|
85
|
+
) : (
|
|
86
|
+
cell.render('Aggregated')
|
|
87
|
+
)
|
|
82
88
|
) : cell.isGrouped ? (
|
|
83
89
|
<span>
|
|
84
90
|
{cell.render('Cell')} ({cell.row.subRows.length})
|
|
85
91
|
</span>
|
|
86
92
|
) : enableClickToCopy && !cell.column.disableClickToCopy ? (
|
|
87
|
-
<MRT_CopyButton cell={cell}
|
|
93
|
+
<MRT_CopyButton cell={cell}>{cell.render('Cell')}</MRT_CopyButton>
|
|
88
94
|
) : (
|
|
89
95
|
cell.render('Cell')
|
|
90
96
|
)}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
2
|
import { TableCell, TableRow } from '@mui/material';
|
|
3
3
|
import {
|
|
4
|
+
commonTableBodyButtonCellStyles,
|
|
4
5
|
commonTableBodyCellStyles,
|
|
5
6
|
MRT_TableBodyCell,
|
|
6
7
|
} from './MRT_TableBodyCell';
|
|
@@ -26,6 +27,7 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
26
27
|
onRowClick,
|
|
27
28
|
positionActionsColumn,
|
|
28
29
|
renderDetailPanel,
|
|
30
|
+
tableInstance,
|
|
29
31
|
tableInstance: {
|
|
30
32
|
state: { densePadding },
|
|
31
33
|
},
|
|
@@ -55,19 +57,40 @@ export const MRT_TableBodyRow: FC<Props> = ({ row }) => {
|
|
|
55
57
|
selected={row.isSelected}
|
|
56
58
|
{...tableRowProps}
|
|
57
59
|
>
|
|
58
|
-
{enableRowNumbers && (
|
|
59
|
-
<TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
|
|
60
|
-
{row.index + 1}
|
|
61
|
-
</TableCell>
|
|
62
|
-
)}
|
|
63
60
|
{(enableRowActions || enableRowEditing) &&
|
|
64
61
|
positionActionsColumn === 'first' && (
|
|
65
62
|
<MRT_ToggleRowActionMenuButton row={row} />
|
|
66
63
|
)}
|
|
67
64
|
{(anyRowsCanExpand || renderDetailPanel) && (
|
|
68
|
-
<
|
|
65
|
+
<TableCell
|
|
66
|
+
size="small"
|
|
67
|
+
sx={{
|
|
68
|
+
...commonTableBodyButtonCellStyles(densePadding),
|
|
69
|
+
pl: `${row.depth + 0.5}rem`,
|
|
70
|
+
textAlign: 'left',
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<MRT_ExpandButton row={row} />
|
|
74
|
+
</TableCell>
|
|
75
|
+
)}
|
|
76
|
+
{enableSelection && (
|
|
77
|
+
<TableCell
|
|
78
|
+
sx={{
|
|
79
|
+
...commonTableBodyButtonCellStyles(
|
|
80
|
+
tableInstance.state.densePadding,
|
|
81
|
+
),
|
|
82
|
+
maxWidth: '3rem',
|
|
83
|
+
width: '3rem',
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<MRT_SelectCheckbox row={row} />
|
|
87
|
+
</TableCell>
|
|
88
|
+
)}
|
|
89
|
+
{enableRowNumbers && (
|
|
90
|
+
<TableCell sx={{ ...commonTableBodyCellStyles(densePadding) }}>
|
|
91
|
+
{row.index + 1}
|
|
92
|
+
</TableCell>
|
|
69
93
|
)}
|
|
70
|
-
{enableSelection && <MRT_SelectCheckbox row={row} />}
|
|
71
94
|
{row.cells.map((cell: MRT_Cell) => (
|
|
72
95
|
<MRT_TableBodyCell key={cell.getCellProps().key} cell={cell} />
|
|
73
96
|
))}
|
|
@@ -7,8 +7,8 @@ interface Props {
|
|
|
7
7
|
cell: MRT_Cell;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
export const MRT_CopyButton: FC<Props> = ({ cell }) => {
|
|
11
|
-
const { localization } = useMRT();
|
|
10
|
+
export const MRT_CopyButton: FC<Props> = ({ cell, children }) => {
|
|
11
|
+
const { localization, muiTableBodyCellCopyButtonProps } = useMRT();
|
|
12
12
|
|
|
13
13
|
const [copied, setCopied] = useState(false);
|
|
14
14
|
|
|
@@ -18,6 +18,21 @@ export const MRT_CopyButton: FC<Props> = ({ cell }) => {
|
|
|
18
18
|
setTimeout(() => setCopied(false), 4000);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const mTableBodyCellCopyButtonProps =
|
|
22
|
+
muiTableBodyCellCopyButtonProps instanceof Function
|
|
23
|
+
? muiTableBodyCellCopyButtonProps(cell)
|
|
24
|
+
: muiTableBodyCellCopyButtonProps;
|
|
25
|
+
|
|
26
|
+
const mcTableBodyCellCopyButtonProps =
|
|
27
|
+
cell.column.muiTableBodyCellCopyButtonProps instanceof Function
|
|
28
|
+
? cell.column.muiTableBodyCellCopyButtonProps(cell)
|
|
29
|
+
: cell.column.muiTableBodyCellCopyButtonProps;
|
|
30
|
+
|
|
31
|
+
const buttonProps = {
|
|
32
|
+
...mTableBodyCellCopyButtonProps,
|
|
33
|
+
...mcTableBodyCellCopyButtonProps,
|
|
34
|
+
};
|
|
35
|
+
|
|
21
36
|
return (
|
|
22
37
|
<Tooltip
|
|
23
38
|
arrow
|
|
@@ -30,20 +45,23 @@ export const MRT_CopyButton: FC<Props> = ({ cell }) => {
|
|
|
30
45
|
aria-label={localization.clickToCopy}
|
|
31
46
|
onClick={() => handleCopy(cell.value)}
|
|
32
47
|
size="small"
|
|
48
|
+
{...buttonProps}
|
|
33
49
|
sx={{
|
|
34
50
|
backgroundColor: 'transparent',
|
|
51
|
+
border: 'none',
|
|
35
52
|
color: 'inherit',
|
|
36
|
-
letterSpacing: 'inherit',
|
|
37
53
|
fontFamily: 'inherit',
|
|
38
54
|
fontSize: 'inherit',
|
|
55
|
+
letterSpacing: 'inherit',
|
|
39
56
|
m: '-0.25rem',
|
|
40
|
-
textTransform: 'inherit',
|
|
41
|
-
textAlign: 'inherit',
|
|
42
57
|
minWidth: 'unset',
|
|
58
|
+
textAlign: 'inherit',
|
|
59
|
+
textTransform: 'inherit',
|
|
60
|
+
...buttonProps?.sx,
|
|
43
61
|
}}
|
|
44
62
|
variant="text"
|
|
45
63
|
>
|
|
46
|
-
{
|
|
64
|
+
{children}
|
|
47
65
|
</Button>
|
|
48
66
|
</Tooltip>
|
|
49
67
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { IconButton
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
5
4
|
|
|
6
5
|
interface Props {}
|
|
7
6
|
|
|
@@ -14,24 +13,18 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
14
13
|
} = useMRT();
|
|
15
14
|
|
|
16
15
|
return (
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
16
|
+
<IconButton
|
|
17
|
+
aria-label={localization.expandAll}
|
|
18
|
+
title={localization.expandAll}
|
|
21
19
|
>
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
transition: 'transform 0.2s',
|
|
32
|
-
}}
|
|
33
|
-
/>
|
|
34
|
-
</IconButton>
|
|
35
|
-
</TableCell>
|
|
20
|
+
<DoubleArrowDownIcon
|
|
21
|
+
style={{
|
|
22
|
+
transform: `rotate(${
|
|
23
|
+
tableInstance.isAllRowsExpanded ? -180 : anyRowsExpanded ? -90 : 0
|
|
24
|
+
}deg)`,
|
|
25
|
+
transition: 'transform 0.2s',
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
</IconButton>
|
|
36
29
|
);
|
|
37
30
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { IconButton
|
|
2
|
+
import { IconButton } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import type { MRT_Row } from '..';
|
|
5
|
-
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
6
5
|
|
|
7
6
|
interface Props {
|
|
8
7
|
row: MRT_Row;
|
|
@@ -14,9 +13,6 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
14
13
|
localization,
|
|
15
14
|
onRowExpandChange,
|
|
16
15
|
renderDetailPanel,
|
|
17
|
-
tableInstance: {
|
|
18
|
-
state: { densePadding },
|
|
19
|
-
},
|
|
20
16
|
} = useMRT();
|
|
21
17
|
|
|
22
18
|
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
@@ -26,34 +22,25 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
return (
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}}
|
|
25
|
+
<IconButton
|
|
26
|
+
aria-label={localization.expand}
|
|
27
|
+
disabled={!row.canExpand && !renderDetailPanel}
|
|
28
|
+
title={localization.expand}
|
|
29
|
+
{...row.getToggleRowExpandedProps()}
|
|
30
|
+
onClick={handleToggleExpand}
|
|
36
31
|
>
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
? -180
|
|
51
|
-
: 0
|
|
52
|
-
}deg)`,
|
|
53
|
-
transition: 'transform 0.2s',
|
|
54
|
-
}}
|
|
55
|
-
/>
|
|
56
|
-
</IconButton>
|
|
57
|
-
</TableCell>
|
|
32
|
+
<ExpandMoreIcon
|
|
33
|
+
style={{
|
|
34
|
+
transform: `rotate(${
|
|
35
|
+
!row.canExpand && !renderDetailPanel
|
|
36
|
+
? -90
|
|
37
|
+
: row.isExpanded
|
|
38
|
+
? -180
|
|
39
|
+
: 0
|
|
40
|
+
}deg)`,
|
|
41
|
+
transition: 'transform 0.2s',
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
</IconButton>
|
|
58
45
|
);
|
|
59
46
|
};
|
|
@@ -10,8 +10,9 @@ interface Props {
|
|
|
10
10
|
|
|
11
11
|
export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
12
12
|
const {
|
|
13
|
-
localization,
|
|
14
13
|
icons: { MoreVertIcon },
|
|
14
|
+
localization,
|
|
15
|
+
muiTableHeadCellColumnActionsButtonProps,
|
|
15
16
|
} = useMRT();
|
|
16
17
|
|
|
17
18
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -22,6 +23,21 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
22
23
|
setAnchorEl(event.currentTarget);
|
|
23
24
|
};
|
|
24
25
|
|
|
26
|
+
const mTableHeadCellColumnActionsButtonProps =
|
|
27
|
+
muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
28
|
+
? muiTableHeadCellColumnActionsButtonProps(column)
|
|
29
|
+
: muiTableHeadCellColumnActionsButtonProps;
|
|
30
|
+
|
|
31
|
+
const mcTableHeadCellColumnActionsButtonProps =
|
|
32
|
+
column.muiTableHeadCellColumnActionsButtonProps instanceof Function
|
|
33
|
+
? column.muiTableHeadCellColumnActionsButtonProps(column)
|
|
34
|
+
: column.muiTableHeadCellColumnActionsButtonProps;
|
|
35
|
+
|
|
36
|
+
const iconButtonProps = {
|
|
37
|
+
...mTableHeadCellColumnActionsButtonProps,
|
|
38
|
+
...mcTableHeadCellColumnActionsButtonProps,
|
|
39
|
+
};
|
|
40
|
+
|
|
25
41
|
return (
|
|
26
42
|
<>
|
|
27
43
|
<Tooltip
|
|
@@ -35,6 +51,7 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
35
51
|
aria-label={localization.columnActions}
|
|
36
52
|
onClick={handleClick}
|
|
37
53
|
size="small"
|
|
54
|
+
{...iconButtonProps}
|
|
38
55
|
sx={{
|
|
39
56
|
height: '2rem',
|
|
40
57
|
mr: '2px',
|
|
@@ -45,6 +62,7 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
45
62
|
'&:hover': {
|
|
46
63
|
opacity: 1,
|
|
47
64
|
},
|
|
65
|
+
...iconButtonProps.sx,
|
|
48
66
|
}}
|
|
49
67
|
>
|
|
50
68
|
<MoreVertIcon />
|
package/src/enums.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export enum MRT_FILTER_TYPE {
|
|
2
|
+
BEST_MATCH = 'bestMatch',
|
|
3
|
+
BEST_MATCH_FIRST = 'bestMatchFirst',
|
|
2
4
|
CONTAINS = 'contains',
|
|
3
5
|
EMPTY = 'empty',
|
|
4
6
|
ENDS_WITH = 'endsWith',
|
|
5
7
|
EQUALS = 'equals',
|
|
6
|
-
FUZZY = 'fuzzy',
|
|
7
8
|
GREATER_THAN = 'greaterThan',
|
|
8
9
|
LESS_THAN = 'lessThan',
|
|
9
10
|
NOT_EMPTY = 'notEmpty',
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { matchSorter } from 'match-sorter';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const bestMatchFirst = (
|
|
5
|
+
rows: MRT_Row[],
|
|
6
|
+
columnIds: string[] | string,
|
|
7
|
+
filterValue: string | number,
|
|
8
|
+
) =>
|
|
9
|
+
matchSorter(rows, filterValue.toString().trim(), {
|
|
10
|
+
keys: Array.isArray(columnIds)
|
|
11
|
+
? columnIds.map((c) => `values.${c}`)
|
|
12
|
+
: [`values.${columnIds}`],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
bestMatchFirst.autoRemove = (val: any) => !val;
|
|
16
|
+
|
|
17
|
+
export const bestMatch = (
|
|
5
18
|
rows: MRT_Row[],
|
|
6
19
|
columnIds: string[] | string,
|
|
7
20
|
filterValue: string | number,
|
|
@@ -13,7 +26,7 @@ export const fuzzy = (
|
|
|
13
26
|
sorter: (rankedItems) => rankedItems,
|
|
14
27
|
});
|
|
15
28
|
|
|
16
|
-
|
|
29
|
+
bestMatch.autoRemove = (val: any) => !val;
|
|
17
30
|
|
|
18
31
|
export const contains = (
|
|
19
32
|
rows: MRT_Row[],
|
|
@@ -131,11 +144,12 @@ export const notEmpty = (
|
|
|
131
144
|
notEmpty.autoRemove = (val: any) => !val;
|
|
132
145
|
|
|
133
146
|
export const defaultFilterFNs = {
|
|
147
|
+
bestMatch,
|
|
148
|
+
bestMatchFirst,
|
|
134
149
|
contains,
|
|
135
150
|
empty,
|
|
136
151
|
endsWith,
|
|
137
152
|
equals,
|
|
138
|
-
fuzzy,
|
|
139
153
|
greaterThan,
|
|
140
154
|
lessThan,
|
|
141
155
|
notEmpty,
|
|
@@ -99,6 +99,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
99
99
|
],
|
|
100
100
|
)
|
|
101
101
|
.replace('{filterValue}', column.filterValue)
|
|
102
|
+
.replace('" "', '')
|
|
102
103
|
: localization.showHideFilters;
|
|
103
104
|
|
|
104
105
|
const columnHeader = column.render('Header') as string;
|
|
@@ -178,9 +179,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
178
179
|
)}
|
|
179
180
|
</Box>
|
|
180
181
|
<Box sx={{ alignItems: 'center', display: 'flex', flexWrap: 'nowrap' }}>
|
|
181
|
-
{!disableColumnActions &&
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
{!disableColumnActions &&
|
|
183
|
+
!column.disableColumnActions &&
|
|
184
|
+
!isParentHeader && (
|
|
185
|
+
<MRT_ToggleColumnActionMenuButton column={column} />
|
|
186
|
+
)}
|
|
184
187
|
{enableColumnResizing && !isParentHeader && (
|
|
185
188
|
<Divider
|
|
186
189
|
flexItem
|
|
@@ -19,6 +19,7 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
19
19
|
const {
|
|
20
20
|
anyRowsCanExpand,
|
|
21
21
|
disableExpandAll,
|
|
22
|
+
disableSelectAll,
|
|
22
23
|
enableRowActions,
|
|
23
24
|
enableRowEditing,
|
|
24
25
|
enableRowNumbers,
|
|
@@ -50,18 +51,6 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
50
51
|
|
|
51
52
|
return (
|
|
52
53
|
<TableRow {...tableRowProps}>
|
|
53
|
-
{enableRowNumbers &&
|
|
54
|
-
(isParentHeader ? (
|
|
55
|
-
<MRT_TableSpacerCell />
|
|
56
|
-
) : (
|
|
57
|
-
<TableCell
|
|
58
|
-
sx={{
|
|
59
|
-
...commonTableHeadCellStyles(tableInstance.state.densePadding),
|
|
60
|
-
}}
|
|
61
|
-
>
|
|
62
|
-
#
|
|
63
|
-
</TableCell>
|
|
64
|
-
))}
|
|
65
54
|
{(enableRowActions || enableRowEditing) &&
|
|
66
55
|
positionActionsColumn === 'first' &&
|
|
67
56
|
(isParentHeader ? (
|
|
@@ -71,7 +60,18 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
71
60
|
))}
|
|
72
61
|
{anyRowsCanExpand || renderDetailPanel ? (
|
|
73
62
|
!disableExpandAll && !isParentHeader ? (
|
|
74
|
-
<
|
|
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
75
|
) : (
|
|
76
76
|
<MRT_TableSpacerCell
|
|
77
77
|
width={`${
|
|
@@ -81,12 +81,35 @@ export const MRT_TableHeadRow: FC<Props> = ({ headerGroup }) => {
|
|
|
81
81
|
)
|
|
82
82
|
) : null}
|
|
83
83
|
{enableSelection ? (
|
|
84
|
-
!isParentHeader ? (
|
|
85
|
-
<
|
|
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>
|
|
86
95
|
) : (
|
|
87
96
|
<MRT_TableSpacerCell width="1rem" />
|
|
88
97
|
)
|
|
89
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
|
+
))}
|
|
90
113
|
{headerGroup.headers.map((column: MRT_HeaderGroup) => (
|
|
91
114
|
<MRT_TableHeadCell key={column.getHeaderProps().key} column={column} />
|
|
92
115
|
))}
|
|
@@ -39,12 +39,6 @@ export const MRT_EditCellTextField: FC<Props> = ({ cell }) => {
|
|
|
39
39
|
const textFieldProps = {
|
|
40
40
|
...mTableBodyCellEditTextFieldProps,
|
|
41
41
|
...mcTableBodyCellEditTextFieldProps,
|
|
42
|
-
style: {
|
|
43
|
-
//@ts-ignore
|
|
44
|
-
...muiTableBodyCellEditTextFieldProps?.style,
|
|
45
|
-
//@ts-ignore
|
|
46
|
-
...cell.column.muiTableBodyCellEditTextFieldProps?.style,
|
|
47
|
-
},
|
|
48
42
|
};
|
|
49
43
|
|
|
50
44
|
if (!cell.column.disableEditing && cell.column.Edit) {
|
|
@@ -43,10 +43,6 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
43
43
|
const textFieldProps = {
|
|
44
44
|
...mTableHeadCellFilterTextFieldProps,
|
|
45
45
|
...mcTableHeadCellFilterTextFieldProps,
|
|
46
|
-
style: {
|
|
47
|
-
...mTableHeadCellFilterTextFieldProps?.style,
|
|
48
|
-
...mcTableHeadCellFilterTextFieldProps?.style,
|
|
49
|
-
},
|
|
50
46
|
} as TextFieldProps;
|
|
51
47
|
|
|
52
48
|
const [filterValue, setFilterValue] = useState('');
|
|
@@ -69,7 +65,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
69
65
|
column.setFilter(undefined);
|
|
70
66
|
setCurrentFilterTypes((prev) => ({
|
|
71
67
|
...prev,
|
|
72
|
-
[column.id]: MRT_FILTER_TYPE.
|
|
68
|
+
[column.id]: MRT_FILTER_TYPE.BEST_MATCH,
|
|
73
69
|
}));
|
|
74
70
|
};
|
|
75
71
|
|
|
@@ -136,13 +132,6 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
136
132
|
sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
|
|
137
133
|
}}
|
|
138
134
|
label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
|
|
139
|
-
InputLabelProps={{
|
|
140
|
-
shrink: false,
|
|
141
|
-
sx: {
|
|
142
|
-
maxWidth: 'calc(100% - 2.5rem)',
|
|
143
|
-
},
|
|
144
|
-
title: filterPlaceholder,
|
|
145
|
-
}}
|
|
146
135
|
margin="none"
|
|
147
136
|
placeholder={
|
|
148
137
|
filterChipLabel || isSelectFilter ? undefined : filterPlaceholder
|