material-react-table 0.5.9 → 0.6.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 +13 -5
- package/dist/filtersFNs.d.ts +6 -10
- package/dist/localization.d.ts +43 -46
- package/dist/material-react-table.cjs.development.js +404 -331
- 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 +405 -332
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ShowHideColumnsMenu.d.ts +3 -2
- package/dist/menus/MRT_ShowHideColumnsMenuItems.d.ts +8 -0
- package/dist/useMRT.d.ts +4 -0
- package/package.json +3 -3
- package/src/MaterialReactTable.tsx +59 -47
- package/src/buttons/MRT_EditActionButtons.tsx +4 -7
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -2
- package/src/buttons/MRT_ExpandButton.tsx +2 -2
- package/src/buttons/MRT_FullScreenToggleButton.tsx +2 -2
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +4 -52
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +2 -2
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -2
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +3 -7
- package/src/buttons/MRT_ToggleSearchButton.tsx +1 -1
- package/src/filtersFNs.ts +6 -16
- package/src/head/MRT_TableHeadCell.tsx +19 -6
- package/src/head/MRT_TableHeadCellActions.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +34 -9
- package/src/inputs/MRT_SearchTextField.tsx +3 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -4
- package/src/localization.ts +87 -92
- package/src/menus/MRT_ColumnActionMenu.tsx +59 -14
- package/src/menus/MRT_FilterTypeMenu.tsx +10 -10
- package/src/menus/MRT_RowActionMenu.tsx +1 -1
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +52 -35
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +57 -0
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -3
- package/src/useMRT.tsx +38 -34
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import type { MRT_ColumnInstance } from '..';
|
|
3
2
|
interface Props {
|
|
4
|
-
|
|
3
|
+
anchorEl: HTMLElement | null;
|
|
4
|
+
isSubMenu?: boolean;
|
|
5
|
+
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
5
6
|
}
|
|
6
7
|
export declare const MRT_ShowHideColumnsMenu: FC<Props>;
|
|
7
8
|
export {};
|
package/dist/useMRT.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { PropsWithChildren, Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import type { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
|
|
3
|
+
import { MRT_FILTER_TYPE } from './enums';
|
|
3
4
|
import { MRT_Icons } from './icons';
|
|
4
5
|
import { MRT_Localization } from './localization';
|
|
5
6
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
|
@@ -8,6 +9,9 @@ export declare type UseMRT<D extends {} = {}> = MaterialReactTableProps<D> & {
|
|
|
8
9
|
anyRowsExpanded: boolean;
|
|
9
10
|
icons: MRT_Icons;
|
|
10
11
|
idPrefix: string;
|
|
12
|
+
filterTypes: {
|
|
13
|
+
[key in MRT_FILTER_TYPE]: any;
|
|
14
|
+
};
|
|
11
15
|
localization: MRT_Localization;
|
|
12
16
|
setCurrentEditingRow: Dispatch<SetStateAction<MRT_Row<D> | null>>;
|
|
13
17
|
setCurrentFilterTypes: Dispatch<SetStateAction<{
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.2",
|
|
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.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
],
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@babel/core": "^7.17.5",
|
|
59
|
-
"@emotion/react": "^11.8.
|
|
59
|
+
"@emotion/react": "^11.8.2",
|
|
60
60
|
"@emotion/styled": "^11.8.1",
|
|
61
61
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
62
62
|
"@faker-js/faker": "^6.0.0-beta.0",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@storybook/addons": "^6.4.19",
|
|
74
74
|
"@storybook/react": "^6.4.19",
|
|
75
75
|
"@types/faker": "^6.6.8",
|
|
76
|
-
"@types/react": "^17.0.
|
|
76
|
+
"@types/react": "^17.0.40",
|
|
77
77
|
"@types/react-dom": "^17.0.13",
|
|
78
78
|
"@types/react-table": "^7.7.9",
|
|
79
79
|
"babel-loader": "^8.2.3",
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Column,
|
|
21
21
|
ColumnInstance,
|
|
22
22
|
FilterType,
|
|
23
|
-
|
|
23
|
+
ColumnInterface,
|
|
24
24
|
HeaderGroup,
|
|
25
25
|
Row,
|
|
26
26
|
TableInstance,
|
|
@@ -78,6 +78,7 @@ import { MRT_TableContainer } from './table/MRT_TableContainer';
|
|
|
78
78
|
import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
|
|
79
79
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
80
80
|
import { MRT_FILTER_TYPE } from './enums';
|
|
81
|
+
import { defaultFilterFNs } from './filtersFNs';
|
|
81
82
|
|
|
82
83
|
export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
|
|
83
84
|
UseExpandedOptions<D> &
|
|
@@ -115,57 +116,60 @@ export type MRT_TableInstance<D extends {} = {}> = TableInstance<D> &
|
|
|
115
116
|
getToggleAllRowsExpandedProps: () => void;
|
|
116
117
|
};
|
|
117
118
|
|
|
118
|
-
export type MRT_ColumnInterface<D extends {} = {}> =
|
|
119
|
-
// ColumnInterface<D> &
|
|
119
|
+
export type MRT_ColumnInterface<D extends {} = {}> = ColumnInterface<D> &
|
|
120
120
|
UseFiltersColumnOptions<D> &
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
121
|
+
UseGlobalFiltersColumnOptions<D> &
|
|
122
|
+
UseGroupByColumnOptions<D> &
|
|
123
|
+
UseResizeColumnsColumnOptions<D> &
|
|
124
|
+
UseSortByColumnOptions<D> & {
|
|
125
|
+
Edit?: ({
|
|
126
|
+
cell,
|
|
127
|
+
onChange,
|
|
128
|
+
}: {
|
|
129
|
+
cell: MRT_Cell<D>;
|
|
130
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
131
|
+
}) => ReactNode;
|
|
132
|
+
Filter?: ({ column }: { column: MRT_HeaderGroup<D> }) => ReactNode;
|
|
133
|
+
Footer?: string;
|
|
134
|
+
Header?: string;
|
|
135
|
+
accessor: string;
|
|
136
|
+
columns?: (Column<D> & MRT_ColumnInterface<D>)[];
|
|
137
|
+
disableFilters?: boolean;
|
|
138
|
+
editable?: boolean;
|
|
139
|
+
filter?: MRT_FilterType | string | FilterType<D>;
|
|
140
|
+
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
141
|
+
filterTypes: MRT_FILTER_TYPE[];
|
|
142
|
+
muiTableBodyCellEditTextFieldProps?:
|
|
143
|
+
| TextFieldProps
|
|
144
|
+
| ((cell: MRT_Cell<D>) => TextFieldProps);
|
|
145
|
+
muiTableBodyCellProps?:
|
|
146
|
+
| TableCellProps
|
|
147
|
+
| ((cell: MRT_Cell<D>) => TableCellProps);
|
|
148
|
+
muiTableFooterCellProps?:
|
|
149
|
+
| TableCellProps
|
|
150
|
+
| ((column: Column<D>) => TableCellProps);
|
|
151
|
+
muiTableHeadCellFilterTextFieldProps?:
|
|
152
|
+
| TextFieldProps
|
|
153
|
+
| ((column: Column<D>) => TextFieldProps);
|
|
154
|
+
muiTableHeadCellProps?:
|
|
155
|
+
| TableCellProps
|
|
156
|
+
| ((column: Column<D>) => TableCellProps);
|
|
157
|
+
onCellEditChange?: (
|
|
158
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
159
|
+
cell: MRT_Cell<D>,
|
|
160
|
+
) => void;
|
|
161
|
+
onFilterChange?: (
|
|
162
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
163
|
+
filterValue: any,
|
|
164
|
+
) => void;
|
|
165
|
+
};
|
|
163
166
|
|
|
164
167
|
export type MRT_ColumnInstance<D extends {} = {}> = ColumnInstance<D> &
|
|
165
168
|
UseFiltersColumnProps<D> &
|
|
166
169
|
UseGroupByColumnProps<D> &
|
|
167
170
|
UseResizeColumnsColumnProps<D> &
|
|
168
|
-
UseSortByColumnProps<D> &
|
|
171
|
+
UseSortByColumnProps<D> &
|
|
172
|
+
MRT_ColumnInterface<D> & {
|
|
169
173
|
columns?: MRT_ColumnInstance<D>[];
|
|
170
174
|
};
|
|
171
175
|
|
|
@@ -185,7 +189,9 @@ export type MRT_Row<D extends {} = {}> = Row<D> &
|
|
|
185
189
|
|
|
186
190
|
export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
|
|
187
191
|
UseGroupByCellProps<D> &
|
|
188
|
-
UseRowStateCellProps<D> & {
|
|
192
|
+
UseRowStateCellProps<D> & {
|
|
193
|
+
column: MRT_ColumnInstance<D>;
|
|
194
|
+
};
|
|
189
195
|
|
|
190
196
|
export type MRT_FilterType = MRT_FILTER_TYPE | Function;
|
|
191
197
|
|
|
@@ -232,6 +238,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
232
238
|
enableRowEditing?: boolean;
|
|
233
239
|
enableRowNumbers?: boolean;
|
|
234
240
|
enableSelection?: boolean;
|
|
241
|
+
filterTypes?: { [key in MRT_FILTER_TYPE]: any };
|
|
235
242
|
hideTableFooter?: boolean;
|
|
236
243
|
hideTableHead?: boolean;
|
|
237
244
|
hideToolbarBottom?: boolean;
|
|
@@ -362,6 +369,8 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
|
|
|
362
369
|
|
|
363
370
|
export default <D extends {}>({
|
|
364
371
|
defaultColumn = { minWidth: 50, maxWidth: 1000 },
|
|
372
|
+
filterTypes,
|
|
373
|
+
globalFilter = 'fuzzy',
|
|
365
374
|
icons,
|
|
366
375
|
localization,
|
|
367
376
|
positionActionsColumn = 'first',
|
|
@@ -372,6 +381,9 @@ export default <D extends {}>({
|
|
|
372
381
|
}: MaterialReactTableProps<D>) => (
|
|
373
382
|
<MaterialReactTableProvider
|
|
374
383
|
defaultColumn={defaultColumn}
|
|
384
|
+
// @ts-ignore
|
|
385
|
+
filterTypes={{ ...defaultFilterFNs, ...filterTypes }}
|
|
386
|
+
globalFilter={globalFilter}
|
|
375
387
|
icons={{ ...MRT_Default_Icons, ...icons }}
|
|
376
388
|
localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
|
|
377
389
|
positionActionsColumn={positionActionsColumn}
|
|
@@ -30,17 +30,14 @@ export const MRT_EditActionButtons: FC<Props> = ({ row }) => {
|
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
32
|
<Box sx={{ display: 'flex', gap: '0.75rem' }}>
|
|
33
|
-
<Tooltip arrow title={localization.
|
|
34
|
-
<IconButton
|
|
35
|
-
aria-label={localization.rowActionButtonCancel}
|
|
36
|
-
onClick={handleCancel}
|
|
37
|
-
>
|
|
33
|
+
<Tooltip arrow title={localization.cancel}>
|
|
34
|
+
<IconButton aria-label={localization.cancel} onClick={handleCancel}>
|
|
38
35
|
<CancelIcon />
|
|
39
36
|
</IconButton>
|
|
40
37
|
</Tooltip>
|
|
41
|
-
<Tooltip arrow title={localization.
|
|
38
|
+
<Tooltip arrow title={localization.save}>
|
|
42
39
|
<IconButton
|
|
43
|
-
aria-label={localization.
|
|
40
|
+
aria-label={localization.save}
|
|
44
41
|
color="info"
|
|
45
42
|
onClick={handleSave}
|
|
46
43
|
>
|
|
@@ -20,8 +20,8 @@ export const MRT_ExpandAllButton: FC<Props> = () => {
|
|
|
20
20
|
sx={commonTableBodyButtonCellStyles(tableInstance.state.densePadding)}
|
|
21
21
|
>
|
|
22
22
|
<IconButton
|
|
23
|
-
aria-label={localization.
|
|
24
|
-
title={localization.
|
|
23
|
+
aria-label={localization.expandAll}
|
|
24
|
+
title={localization.expandAll}
|
|
25
25
|
>
|
|
26
26
|
<DoubleArrowDownIcon
|
|
27
27
|
style={{
|
|
@@ -28,9 +28,9 @@ export const MRT_ExpandButton: FC<Props> = ({ row }) => {
|
|
|
28
28
|
}}
|
|
29
29
|
>
|
|
30
30
|
<IconButton
|
|
31
|
-
aria-label={localization.
|
|
31
|
+
aria-label={localization.expand}
|
|
32
32
|
disabled={!row.canExpand && !renderDetailPanel}
|
|
33
|
-
title={localization.
|
|
33
|
+
title={localization.expand}
|
|
34
34
|
{...row.getToggleRowExpandedProps()}
|
|
35
35
|
>
|
|
36
36
|
<ExpandMoreIcon
|
|
@@ -15,9 +15,9 @@ export const MRT_FullScreenToggleButton: FC<Props> = ({ ...rest }) => {
|
|
|
15
15
|
} = useMRT();
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<Tooltip arrow title={localization.
|
|
18
|
+
<Tooltip arrow title={localization.toggleFullScreen}>
|
|
19
19
|
<IconButton
|
|
20
|
-
aria-label={localization.
|
|
20
|
+
aria-label={localization.showHideFilters}
|
|
21
21
|
onClick={() => setFullScreen(!fullScreen)}
|
|
22
22
|
size="small"
|
|
23
23
|
{...rest}
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import React, { FC, MouseEvent, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
IconButton,
|
|
5
|
-
Menu,
|
|
6
|
-
Tooltip,
|
|
7
|
-
Divider,
|
|
8
|
-
IconButtonProps,
|
|
9
|
-
Box,
|
|
10
|
-
} from '@mui/material';
|
|
2
|
+
import { IconButton, Tooltip, IconButtonProps } from '@mui/material';
|
|
11
3
|
import { useMRT } from '../useMRT';
|
|
12
4
|
import { MRT_ShowHideColumnsMenu } from '../menus/MRT_ShowHideColumnsMenu';
|
|
13
|
-
import type { MRT_ColumnInstance } from '..';
|
|
14
5
|
|
|
15
6
|
interface Props extends IconButtonProps {}
|
|
16
7
|
|
|
@@ -18,7 +9,6 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
18
9
|
const {
|
|
19
10
|
icons: { ViewColumnIcon },
|
|
20
11
|
localization,
|
|
21
|
-
tableInstance,
|
|
22
12
|
} = useMRT();
|
|
23
13
|
|
|
24
14
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -29,9 +19,9 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
29
19
|
|
|
30
20
|
return (
|
|
31
21
|
<>
|
|
32
|
-
<Tooltip arrow title={localization.
|
|
22
|
+
<Tooltip arrow title={localization.showHideColumns}>
|
|
33
23
|
<IconButton
|
|
34
|
-
aria-label={localization.
|
|
24
|
+
aria-label={localization.showHideColumns}
|
|
35
25
|
onClick={handleClick}
|
|
36
26
|
size="small"
|
|
37
27
|
{...rest}
|
|
@@ -39,45 +29,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
39
29
|
<ViewColumnIcon />
|
|
40
30
|
</IconButton>
|
|
41
31
|
</Tooltip>
|
|
42
|
-
<
|
|
43
|
-
anchorEl={anchorEl}
|
|
44
|
-
open={!!anchorEl}
|
|
45
|
-
onClose={() => setAnchorEl(null)}
|
|
46
|
-
MenuListProps={{
|
|
47
|
-
dense: tableInstance.state.densePadding,
|
|
48
|
-
}}
|
|
49
|
-
>
|
|
50
|
-
<Box
|
|
51
|
-
sx={{
|
|
52
|
-
display: 'flex',
|
|
53
|
-
justifyContent: 'space-between',
|
|
54
|
-
p: '0.5rem',
|
|
55
|
-
}}
|
|
56
|
-
>
|
|
57
|
-
<Button
|
|
58
|
-
disabled={
|
|
59
|
-
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
60
|
-
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
61
|
-
}
|
|
62
|
-
onClick={() => tableInstance.toggleHideAllColumns(true)}
|
|
63
|
-
>
|
|
64
|
-
{localization.columnShowHideMenuHideAll}
|
|
65
|
-
</Button>
|
|
66
|
-
<Button
|
|
67
|
-
disabled={tableInstance.getToggleHideAllColumnsProps().checked}
|
|
68
|
-
onClick={() => tableInstance.toggleHideAllColumns(false)}
|
|
69
|
-
>
|
|
70
|
-
{localization.columnShowHideMenuShowAll}
|
|
71
|
-
</Button>
|
|
72
|
-
</Box>
|
|
73
|
-
<Divider />
|
|
74
|
-
{tableInstance.columns.map((column: MRT_ColumnInstance, index) => (
|
|
75
|
-
<MRT_ShowHideColumnsMenu
|
|
76
|
-
key={`${index}-${column.id}`}
|
|
77
|
-
column={column}
|
|
78
|
-
/>
|
|
79
|
-
))}
|
|
80
|
-
</Menu>
|
|
32
|
+
<MRT_ShowHideColumnsMenu anchorEl={anchorEl} setAnchorEl={setAnchorEl} />
|
|
81
33
|
</>
|
|
82
34
|
);
|
|
83
35
|
};
|
|
@@ -29,10 +29,10 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
29
29
|
enterDelay={1000}
|
|
30
30
|
enterNextDelay={1000}
|
|
31
31
|
placement="top"
|
|
32
|
-
title={localization.
|
|
32
|
+
title={localization.columnActions}
|
|
33
33
|
>
|
|
34
34
|
<IconButton
|
|
35
|
-
aria-label={localization.
|
|
35
|
+
aria-label={localization.columnActions}
|
|
36
36
|
onClick={handleClick}
|
|
37
37
|
size="small"
|
|
38
38
|
sx={{
|
|
@@ -15,9 +15,9 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = ({ ...rest }) => {
|
|
|
15
15
|
} = useMRT();
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<Tooltip arrow title={localization.
|
|
18
|
+
<Tooltip arrow title={localization.toggleDensePadding}>
|
|
19
19
|
<IconButton
|
|
20
|
-
aria-label={localization.
|
|
20
|
+
aria-label={localization.toggleDensePadding}
|
|
21
21
|
onClick={() => setDensePadding(!densePadding)}
|
|
22
22
|
size="small"
|
|
23
23
|
{...rest}
|
|
@@ -15,9 +15,9 @@ export const MRT_ToggleFiltersButton: FC<Props> = ({ ...rest }) => {
|
|
|
15
15
|
} = useMRT();
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<Tooltip arrow title={localization.
|
|
18
|
+
<Tooltip arrow title={localization.showHideFilters}>
|
|
19
19
|
<IconButton
|
|
20
|
-
aria-label={localization.
|
|
20
|
+
aria-label={localization.showHideFilters}
|
|
21
21
|
onClick={() => setShowFilters(!showFilters)}
|
|
22
22
|
size="small"
|
|
23
23
|
{...rest}
|
|
@@ -54,11 +54,7 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
54
54
|
) : row.id === tableInstance.state.currentEditingRow?.id ? (
|
|
55
55
|
<MRT_EditActionButtons row={row} />
|
|
56
56
|
) : !renderRowActionMenuItems && enableRowEditing ? (
|
|
57
|
-
<Tooltip
|
|
58
|
-
placement="right"
|
|
59
|
-
arrow
|
|
60
|
-
title={localization.rowActionMenuItemEdit}
|
|
61
|
-
>
|
|
57
|
+
<Tooltip placement="right" arrow title={localization.edit}>
|
|
62
58
|
<IconButton sx={commonIconButtonStyles} onClick={handleEdit}>
|
|
63
59
|
<EditIcon />
|
|
64
60
|
</IconButton>
|
|
@@ -69,10 +65,10 @@ export const MRT_ToggleRowActionMenuButton: FC<Props> = ({ row }) => {
|
|
|
69
65
|
arrow
|
|
70
66
|
enterDelay={1000}
|
|
71
67
|
enterNextDelay={1000}
|
|
72
|
-
title={localization.
|
|
68
|
+
title={localization.rowActions}
|
|
73
69
|
>
|
|
74
70
|
<IconButton
|
|
75
|
-
aria-label={localization.
|
|
71
|
+
aria-label={localization.rowActions}
|
|
76
72
|
onClick={handleOpenRowActionMenu}
|
|
77
73
|
size="small"
|
|
78
74
|
sx={commonIconButtonStyles}
|
|
@@ -30,7 +30,7 @@ export const MRT_ToggleSearchButton: FC<Props> = ({ ...rest }) => {
|
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<Tooltip arrow title={localization.
|
|
33
|
+
<Tooltip arrow title={localization.showHideSearch}>
|
|
34
34
|
<IconButton size="small" onClick={handleToggleSearch} {...rest}>
|
|
35
35
|
{showSearch ? <SearchOffIcon /> : <SearchIcon />}
|
|
36
36
|
</IconButton>
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
1
|
import { matchSorter } from 'match-sorter';
|
|
2
2
|
import { MRT_Row } from '.';
|
|
3
3
|
|
|
4
|
-
export const fuzzySearchFN = (
|
|
5
|
-
rows: MRT_Row[],
|
|
6
|
-
columnIds: string[],
|
|
7
|
-
filterValue: string | number,
|
|
8
|
-
) =>
|
|
9
|
-
matchSorter(rows, filterValue.toString().trim(), {
|
|
10
|
-
keys: columnIds.map((c) => `values.${c}`),
|
|
11
|
-
sorter: (rankedItems) => rankedItems,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
fuzzySearchFN.autoRemove = (val: any) => !val;
|
|
15
|
-
|
|
16
4
|
export const fuzzyFilterFN = (
|
|
17
5
|
rows: MRT_Row[],
|
|
18
|
-
|
|
6
|
+
columnIds: string[] | string,
|
|
19
7
|
filterValue: string | number,
|
|
20
8
|
) =>
|
|
21
9
|
matchSorter(rows, filterValue.toString().trim(), {
|
|
22
|
-
keys:
|
|
10
|
+
keys: Array.isArray(columnIds)
|
|
11
|
+
? columnIds.map((c) => `values.${c}`)
|
|
12
|
+
: [`values.${columnIds}`],
|
|
23
13
|
sorter: (rankedItems) => rankedItems,
|
|
24
14
|
});
|
|
25
15
|
|
|
@@ -144,10 +134,10 @@ export const defaultFilterFNs = {
|
|
|
144
134
|
contains: containsFilterFN,
|
|
145
135
|
empty: emptyFilterFN,
|
|
146
136
|
endsWith: endsWithFilterFN,
|
|
147
|
-
greaterThan: greaterThanFilterFN,
|
|
148
|
-
lessThan: lessThanFilterFN,
|
|
149
137
|
equals: equalsFilterFN,
|
|
150
138
|
fuzzy: fuzzyFilterFN,
|
|
139
|
+
greaterThan: greaterThanFilterFN,
|
|
140
|
+
lessThan: lessThanFilterFN,
|
|
151
141
|
notEmpty: notEmptyFilterFN,
|
|
152
142
|
notEquals: notEqualsFilterFN,
|
|
153
143
|
startsWith: startsWithFilterFN,
|
|
@@ -66,21 +66,34 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
66
66
|
|
|
67
67
|
const sortTooltip = column.isSorted
|
|
68
68
|
? column.isSortedDesc
|
|
69
|
-
? localization.
|
|
70
|
-
: localization.
|
|
69
|
+
? localization.clearSort
|
|
70
|
+
: localization.sortByColumnDesc?.replace(
|
|
71
71
|
'{column}',
|
|
72
72
|
column.Header as string,
|
|
73
73
|
)
|
|
74
|
-
: localization.
|
|
74
|
+
: localization.sortByColumnAsc?.replace(
|
|
75
75
|
'{column}',
|
|
76
76
|
column.Header as string,
|
|
77
77
|
);
|
|
78
78
|
|
|
79
|
+
const filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
80
|
+
|
|
79
81
|
const filterTooltip = !!column.filterValue
|
|
80
|
-
? localization.
|
|
82
|
+
? localization.filteringByColumn
|
|
81
83
|
.replace('{column}', String(column.Header))
|
|
82
|
-
.replace(
|
|
83
|
-
|
|
84
|
+
.replace(
|
|
85
|
+
'{filterType}',
|
|
86
|
+
filterType instanceof Function
|
|
87
|
+
? ''
|
|
88
|
+
: // @ts-ignore
|
|
89
|
+
localization[
|
|
90
|
+
`filter${
|
|
91
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
92
|
+
}`
|
|
93
|
+
],
|
|
94
|
+
)
|
|
95
|
+
.replace('{filterValue}', column.filterValue)
|
|
96
|
+
: localization.showHideFilters;
|
|
84
97
|
|
|
85
98
|
const columnHeader = column.render('Header') as string;
|
|
86
99
|
|
|
@@ -18,7 +18,7 @@ export const MRT_TableHeadCellActions: FC<Props> = () => {
|
|
|
18
18
|
style={{ textAlign: 'center' }}
|
|
19
19
|
sx={{ ...commonTableHeadCellStyles(densePadding), textAlign: 'center' }}
|
|
20
20
|
>
|
|
21
|
-
{localization.
|
|
21
|
+
{localization.actions}
|
|
22
22
|
</TableCell>
|
|
23
23
|
);
|
|
24
24
|
};
|
|
@@ -78,14 +78,18 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const filterType = tableInstance.state.currentFilterTypes[column.id];
|
|
81
|
-
const isCustomFilterType = filterType instanceof Function;
|
|
82
81
|
const isSelectFilter = !!column.filterSelectOptions;
|
|
83
82
|
const filterChipLabel =
|
|
84
|
-
!
|
|
83
|
+
!(filterType instanceof Function) &&
|
|
85
84
|
[MRT_FILTER_TYPE.EMPTY, MRT_FILTER_TYPE.NOT_EMPTY].includes(
|
|
86
85
|
filterType as MRT_FILTER_TYPE,
|
|
87
|
-
)
|
|
88
|
-
|
|
86
|
+
)
|
|
87
|
+
? //@ts-ignore
|
|
88
|
+
localization[
|
|
89
|
+
`filter${filterType.charAt(0).toUpperCase() + filterType.slice(1)}`
|
|
90
|
+
]
|
|
91
|
+
: '';
|
|
92
|
+
const filterPlaceholder = localization.filterByColumn?.replace(
|
|
89
93
|
'{column}',
|
|
90
94
|
String(column.Header),
|
|
91
95
|
);
|
|
@@ -103,6 +107,22 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
103
107
|
},
|
|
104
108
|
title: filterPlaceholder,
|
|
105
109
|
}}
|
|
110
|
+
helperText={
|
|
111
|
+
filterType instanceof Function
|
|
112
|
+
? ''
|
|
113
|
+
: localization.filterMode.replace(
|
|
114
|
+
'{filterType}',
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
localization[
|
|
117
|
+
`filter${
|
|
118
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
119
|
+
}`
|
|
120
|
+
],
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
FormHelperTextProps={{
|
|
124
|
+
sx: { fontSize: '0.6rem', lineHeight: '0.8rem' },
|
|
125
|
+
}}
|
|
106
126
|
label={isSelectFilter && !filterValue ? filterPlaceholder : undefined}
|
|
107
127
|
InputLabelProps={{
|
|
108
128
|
shrink: false,
|
|
@@ -129,6 +149,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
129
149
|
<Tooltip arrow title={localization.changeFilterMode}>
|
|
130
150
|
<span>
|
|
131
151
|
<IconButton
|
|
152
|
+
aria-label={localization.changeFilterMode}
|
|
132
153
|
onClick={handleFilterMenuOpen}
|
|
133
154
|
size="small"
|
|
134
155
|
sx={{ height: '1.75rem', width: '1.75rem' }}
|
|
@@ -138,7 +159,10 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
138
159
|
</span>
|
|
139
160
|
</Tooltip>
|
|
140
161
|
{filterChipLabel && (
|
|
141
|
-
<Chip
|
|
162
|
+
<Chip
|
|
163
|
+
onDelete={handleClearFilterChip}
|
|
164
|
+
label={filterChipLabel}
|
|
165
|
+
/>
|
|
142
166
|
)}
|
|
143
167
|
</InputAdornment>
|
|
144
168
|
),
|
|
@@ -148,11 +172,11 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
148
172
|
arrow
|
|
149
173
|
disableHoverListener={isSelectFilter}
|
|
150
174
|
placement="right"
|
|
151
|
-
title={localization.
|
|
175
|
+
title={localization.clearFilter ?? ''}
|
|
152
176
|
>
|
|
153
177
|
<span>
|
|
154
178
|
<IconButton
|
|
155
|
-
aria-label={localization.
|
|
179
|
+
aria-label={localization.clearFilter}
|
|
156
180
|
disabled={!filterValue?.length}
|
|
157
181
|
onClick={handleClear}
|
|
158
182
|
size="small"
|
|
@@ -170,7 +194,8 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
170
194
|
}}
|
|
171
195
|
{...textFieldProps}
|
|
172
196
|
sx={{
|
|
173
|
-
m: '
|
|
197
|
+
m: '-0.25rem',
|
|
198
|
+
p: 0,
|
|
174
199
|
minWidth: !filterChipLabel ? '5rem' : 'auto',
|
|
175
200
|
width: 'calc(100% + 0.5rem)',
|
|
176
201
|
mt: isSelectFilter && !filterValue ? '-1rem' : undefined,
|
|
@@ -182,7 +207,7 @@ export const MRT_FilterTextField: FC<Props> = ({ column }) => {
|
|
|
182
207
|
>
|
|
183
208
|
{isSelectFilter && (
|
|
184
209
|
<MenuItem divider disabled={!filterValue} value="">
|
|
185
|
-
{localization.
|
|
210
|
+
{localization.clearFilter}
|
|
186
211
|
</MenuItem>
|
|
187
212
|
)}
|
|
188
213
|
{column?.filterSelectOptions?.map((option) => {
|
|
@@ -34,7 +34,7 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
34
34
|
<Collapse in={tableInstance.state.showSearch} orientation="horizontal">
|
|
35
35
|
<TextField
|
|
36
36
|
id={`mrt-${idPrefix}-search-text-field`}
|
|
37
|
-
placeholder={localization.
|
|
37
|
+
placeholder={localization.search}
|
|
38
38
|
onChange={(event: ChangeEvent<HTMLInputElement>) => {
|
|
39
39
|
setSearchValue(event.target.value);
|
|
40
40
|
handleChange(event);
|
|
@@ -50,11 +50,11 @@ export const MRT_SearchTextField: FC<Props> = () => {
|
|
|
50
50
|
endAdornment: (
|
|
51
51
|
<InputAdornment position="end">
|
|
52
52
|
<IconButton
|
|
53
|
-
aria-label={localization.
|
|
53
|
+
aria-label={localization.clearSearch}
|
|
54
54
|
disabled={searchValue?.length === 0}
|
|
55
55
|
onClick={handleClear}
|
|
56
56
|
size="small"
|
|
57
|
-
title={localization.
|
|
57
|
+
title={localization.clearSearch}
|
|
58
58
|
>
|
|
59
59
|
<CloseIcon fontSize="small" />
|
|
60
60
|
</IconButton>
|