material-react-table 0.5.7 → 0.6.0
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 +8 -2
- 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_EditActionButtons.d.ts +1 -1
- package/dist/buttons/MRT_ExpandButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleColumnActionMenuButton.d.ts +1 -1
- package/dist/buttons/MRT_ToggleRowActionMenuButton.d.ts +1 -1
- package/dist/enums.d.ts +12 -0
- package/dist/filtersFNs.d.ts +20 -0
- package/dist/footer/MRT_TableFooterCell.d.ts +1 -1
- package/dist/footer/MRT_TableFooterRow.d.ts +1 -1
- package/dist/head/MRT_TableHeadCell.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_FilterTextField.d.ts +1 -1
- package/dist/inputs/MRT_SelectCheckbox.d.ts +1 -1
- package/dist/localization.d.ts +44 -44
- package/dist/material-react-table.cjs.development.js +569 -360
- 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 +570 -361
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/menus/MRT_ColumnActionMenu.d.ts +9 -2
- package/dist/menus/MRT_FilterTypeMenu.d.ts +1 -1
- package/dist/menus/MRT_RowActionMenu.d.ts +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 +1 -1
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +5 -9
- package/src/body/MRT_TableBody.tsx +1 -1
- package/src/body/MRT_TableBodyCell.tsx +1 -1
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +5 -8
- package/src/buttons/MRT_ExpandAllButton.tsx +2 -2
- package/src/buttons/MRT_ExpandButton.tsx +3 -3
- package/src/buttons/MRT_FullScreenToggleButton.tsx +2 -2
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +4 -55
- package/src/buttons/MRT_ToggleColumnActionMenuButton.tsx +4 -3
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +2 -2
- package/src/buttons/MRT_ToggleFiltersButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +4 -8
- package/src/buttons/MRT_ToggleSearchButton.tsx +1 -1
- package/src/enums.ts +12 -0
- package/src/filtersFNs.ts +42 -0
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHead.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +22 -18
- package/src/head/MRT_TableHeadCellActions.tsx +1 -1
- package/src/head/MRT_TableHeadRow.tsx +1 -1
- package/src/inputs/MRT_EditCellTextField.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +99 -21
- package/src/inputs/MRT_SearchTextField.tsx +3 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +5 -5
- package/src/localization.ts +89 -88
- package/src/menus/MRT_ColumnActionMenu.tsx +109 -56
- package/src/menus/MRT_FilterTypeMenu.tsx +63 -26
- package/src/menus/MRT_RowActionMenu.tsx +4 -10
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +54 -33
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +57 -0
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +3 -3
- package/src/useMRT.tsx +36 -14
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { MRT_HeaderGroup } from '..';
|
|
2
|
+
import type { MRT_HeaderGroup } from '..';
|
|
3
3
|
export declare const commonMenuItemStyles: {
|
|
4
4
|
py: string;
|
|
5
|
-
my:
|
|
5
|
+
my: number;
|
|
6
|
+
justifyContent: string;
|
|
7
|
+
alignItems: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const commonListItemStyles: {
|
|
10
|
+
display: string;
|
|
11
|
+
gap: string;
|
|
12
|
+
alignItems: string;
|
|
6
13
|
};
|
|
7
14
|
interface Props {
|
|
8
15
|
anchorEl: HTMLElement | null;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import { 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,5 @@
|
|
|
1
1
|
import React, { PropsWithChildren, Dispatch, SetStateAction } from 'react';
|
|
2
|
-
import { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
|
|
2
|
+
import type { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
|
|
3
3
|
import { MRT_Icons } from './icons';
|
|
4
4
|
import { MRT_Localization } from './localization';
|
|
5
5
|
import { MaterialReactTableProps } from './MaterialReactTable';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.6.0",
|
|
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.",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"analyze": "size-limit --why",
|
|
31
|
-
"build": "tsdx build && size-limit && cp -r dist material-react-table-docs/node_modules/material-react-table/
|
|
31
|
+
"build": "tsdx build && size-limit && rm -rf material-react-table-docs/node_modules/material-react-table/dist && cp -r dist material-react-table-docs/node_modules/material-react-table/ && cp -r src material-react-table-docs/node_modules/material-react-table/ && cp -r package.json material-react-table-docs/node_modules/material-react-table/package.json",
|
|
32
32
|
"build-storybook": "build-storybook",
|
|
33
33
|
"format": "prettier -w .",
|
|
34
34
|
"lint": "tsdx lint",
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
Cell,
|
|
20
20
|
Column,
|
|
21
21
|
ColumnInstance,
|
|
22
|
+
FilterType,
|
|
22
23
|
// ColumnInterface,
|
|
23
24
|
HeaderGroup,
|
|
24
25
|
Row,
|
|
@@ -76,6 +77,7 @@ import { MaterialReactTableProvider } from './useMRT';
|
|
|
76
77
|
import { MRT_TableContainer } from './table/MRT_TableContainer';
|
|
77
78
|
import { MRT_Localization, MRT_DefaultLocalization_EN } from './localization';
|
|
78
79
|
import { MRT_Default_Icons, MRT_Icons } from './icons';
|
|
80
|
+
import { MRT_FILTER_TYPE } from './enums';
|
|
79
81
|
|
|
80
82
|
export type MRT_TableOptions<D extends {} = {}> = TableOptions<D> &
|
|
81
83
|
UseExpandedOptions<D> &
|
|
@@ -132,6 +134,8 @@ export type MRT_ColumnInterface<D extends {} = {}> =
|
|
|
132
134
|
Header?: string;
|
|
133
135
|
disableFilters?: boolean;
|
|
134
136
|
editable?: boolean;
|
|
137
|
+
filter?: MRT_FilterType | string | FilterType<D>;
|
|
138
|
+
filterSelectOptions?: (string | { text: string; value: string })[];
|
|
135
139
|
muiTableBodyCellEditTextFieldProps?:
|
|
136
140
|
| TextFieldProps
|
|
137
141
|
| ((cell: MRT_Cell<D>) => TextFieldProps);
|
|
@@ -183,15 +187,7 @@ export type MRT_Cell<D extends {} = {}, _V = any> = Cell<D> &
|
|
|
183
187
|
UseGroupByCellProps<D> &
|
|
184
188
|
UseRowStateCellProps<D> & {};
|
|
185
189
|
|
|
186
|
-
export type MRT_FilterType =
|
|
187
|
-
| 'contains'
|
|
188
|
-
| 'empty'
|
|
189
|
-
| 'endsWith'
|
|
190
|
-
| 'equals'
|
|
191
|
-
| 'fuzzy'
|
|
192
|
-
| 'notEmpty'
|
|
193
|
-
| 'notEquals'
|
|
194
|
-
| 'startsWith';
|
|
190
|
+
export type MRT_FilterType = MRT_FILTER_TYPE | Function;
|
|
195
191
|
|
|
196
192
|
export type MRT_TableState<D extends {} = {}> = TableState<D> &
|
|
197
193
|
UseColumnOrderState<D> &
|
|
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { TableBody } from '@mui/material';
|
|
3
3
|
import { MRT_TableBodyRow } from './MRT_TableBodyRow';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
|
-
import { MRT_Row } from '..';
|
|
5
|
+
import type { MRT_Row } from '..';
|
|
6
6
|
|
|
7
7
|
interface Props {}
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@ import React, { FC, MouseEvent } from 'react';
|
|
|
2
2
|
import { Skeleton, TableCell, TableCellProps } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
|
5
|
-
import { MRT_Cell } from '..';
|
|
5
|
+
import type { MRT_Cell } from '..';
|
|
6
6
|
|
|
7
7
|
export const commonTableBodyCellStyles = (densePadding: boolean) => ({
|
|
8
8
|
p: densePadding ? '0.5rem' : '1rem',
|
|
@@ -9,7 +9,7 @@ import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
|
|
9
9
|
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
|
10
10
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
11
11
|
import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
|
|
12
|
-
import { MRT_Cell, MRT_Row } from '..';
|
|
12
|
+
import type { MRT_Cell, MRT_Row } from '..';
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
15
15
|
row: MRT_Row;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { Box, IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_Row } from '..';
|
|
4
|
+
import type { MRT_Row } from '..';
|
|
5
5
|
|
|
6
6
|
interface Props {
|
|
7
7
|
row: MRT_Row;
|
|
@@ -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={{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
2
|
import { IconButton, TableCell } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
|
-
import { MRT_Row } from '..';
|
|
4
|
+
import type { MRT_Row } from '..';
|
|
5
5
|
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
@@ -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,17 +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 { MRT_ColumnInstance } from '..';
|
|
14
|
-
import { commonMenuItemStyles } from '../menus/MRT_ColumnActionMenu';
|
|
15
5
|
|
|
16
6
|
interface Props extends IconButtonProps {}
|
|
17
7
|
|
|
@@ -19,7 +9,6 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
19
9
|
const {
|
|
20
10
|
icons: { ViewColumnIcon },
|
|
21
11
|
localization,
|
|
22
|
-
tableInstance,
|
|
23
12
|
} = useMRT();
|
|
24
13
|
|
|
25
14
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
@@ -30,9 +19,9 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
30
19
|
|
|
31
20
|
return (
|
|
32
21
|
<>
|
|
33
|
-
<Tooltip arrow title={localization.
|
|
22
|
+
<Tooltip arrow title={localization.showHideColumns}>
|
|
34
23
|
<IconButton
|
|
35
|
-
aria-label={localization.
|
|
24
|
+
aria-label={localization.showHideColumns}
|
|
36
25
|
onClick={handleClick}
|
|
37
26
|
size="small"
|
|
38
27
|
{...rest}
|
|
@@ -40,47 +29,7 @@ export const MRT_ShowHideColumnsButton: FC<Props> = ({ ...rest }) => {
|
|
|
40
29
|
<ViewColumnIcon />
|
|
41
30
|
</IconButton>
|
|
42
31
|
</Tooltip>
|
|
43
|
-
<
|
|
44
|
-
anchorEl={anchorEl}
|
|
45
|
-
open={!!anchorEl}
|
|
46
|
-
onClose={() => setAnchorEl(null)}
|
|
47
|
-
MenuListProps={{
|
|
48
|
-
dense: tableInstance.state.densePadding,
|
|
49
|
-
disablePadding: true,
|
|
50
|
-
}}
|
|
51
|
-
sx={commonMenuItemStyles}
|
|
52
|
-
>
|
|
53
|
-
<Box
|
|
54
|
-
sx={{
|
|
55
|
-
display: 'flex',
|
|
56
|
-
justifyContent: 'space-between',
|
|
57
|
-
p: '0.5rem',
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
<Button
|
|
61
|
-
disabled={
|
|
62
|
-
!tableInstance.getToggleHideAllColumnsProps().checked &&
|
|
63
|
-
!tableInstance.getToggleHideAllColumnsProps().indeterminate
|
|
64
|
-
}
|
|
65
|
-
onClick={() => tableInstance.toggleHideAllColumns(true)}
|
|
66
|
-
>
|
|
67
|
-
{localization.columnShowHideMenuHideAll}
|
|
68
|
-
</Button>
|
|
69
|
-
<Button
|
|
70
|
-
disabled={tableInstance.getToggleHideAllColumnsProps().checked}
|
|
71
|
-
onClick={() => tableInstance.toggleHideAllColumns(false)}
|
|
72
|
-
>
|
|
73
|
-
{localization.columnShowHideMenuShowAll}
|
|
74
|
-
</Button>
|
|
75
|
-
</Box>
|
|
76
|
-
<Divider />
|
|
77
|
-
{tableInstance.columns.map((column: MRT_ColumnInstance, index) => (
|
|
78
|
-
<MRT_ShowHideColumnsMenu
|
|
79
|
-
key={`${index}-${column.id}`}
|
|
80
|
-
column={column}
|
|
81
|
-
/>
|
|
82
|
-
))}
|
|
83
|
-
</Menu>
|
|
32
|
+
<MRT_ShowHideColumnsMenu anchorEl={anchorEl} setAnchorEl={setAnchorEl} />
|
|
84
33
|
</>
|
|
85
34
|
);
|
|
86
35
|
};
|
|
@@ -2,7 +2,7 @@ import React, { FC, MouseEvent, useState } from 'react';
|
|
|
2
2
|
import { IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
|
5
|
-
import { MRT_HeaderGroup } from '..';
|
|
5
|
+
import type { MRT_HeaderGroup } from '..';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
column: MRT_HeaderGroup;
|
|
@@ -28,10 +28,11 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({ column }) => {
|
|
|
28
28
|
arrow
|
|
29
29
|
enterDelay={1000}
|
|
30
30
|
enterNextDelay={1000}
|
|
31
|
-
|
|
31
|
+
placement="top"
|
|
32
|
+
title={localization.columnActions}
|
|
32
33
|
>
|
|
33
34
|
<IconButton
|
|
34
|
-
aria-label={localization.
|
|
35
|
+
aria-label={localization.columnActions}
|
|
35
36
|
onClick={handleClick}
|
|
36
37
|
size="small"
|
|
37
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}
|
|
@@ -3,7 +3,7 @@ import { IconButton, TableCell, Tooltip } from '@mui/material';
|
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
|
5
5
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
|
6
|
-
import { MRT_Row } from '..';
|
|
6
|
+
import type { MRT_Row } from '..';
|
|
7
7
|
import { commonTableBodyButtonCellStyles } from '../body/MRT_TableBodyCell';
|
|
8
8
|
|
|
9
9
|
const commonIconButtonStyles = {
|
|
@@ -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/enums.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export enum MRT_FILTER_TYPE {
|
|
2
|
+
CONTAINS = 'contains',
|
|
3
|
+
EMPTY = 'empty',
|
|
4
|
+
ENDS_WITH = 'endsWith',
|
|
5
|
+
EQUALS = 'equals',
|
|
6
|
+
FUZZY = 'fuzzy',
|
|
7
|
+
GREATER_THAN = 'greaterThan',
|
|
8
|
+
LESS_THAN = 'lessThan',
|
|
9
|
+
NOT_EMPTY = 'notEmpty',
|
|
10
|
+
NOT_EQUALS = 'notEquals',
|
|
11
|
+
STARTS_WITH = 'startsWith',
|
|
12
|
+
}
|
package/src/filtersFNs.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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
|
+
|
|
4
16
|
export const fuzzyFilterFN = (
|
|
5
17
|
rows: MRT_Row[],
|
|
6
18
|
id: string,
|
|
@@ -84,6 +96,34 @@ export const notEqualsFilterFN = (
|
|
|
84
96
|
|
|
85
97
|
notEqualsFilterFN.autoRemove = (val: any) => !val;
|
|
86
98
|
|
|
99
|
+
export const greaterThanFilterFN = (
|
|
100
|
+
rows: MRT_Row[],
|
|
101
|
+
id: string,
|
|
102
|
+
filterValue: string | number,
|
|
103
|
+
) =>
|
|
104
|
+
rows.filter((row) =>
|
|
105
|
+
!isNaN(+filterValue) && !isNaN(+row.values[id])
|
|
106
|
+
? +row.values[id] > +filterValue
|
|
107
|
+
: row.values[id].toString().toLowerCase().trim() >
|
|
108
|
+
filterValue.toString().toLowerCase().trim(),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
greaterThanFilterFN.autoRemove = (val: any) => !val;
|
|
112
|
+
|
|
113
|
+
export const lessThanFilterFN = (
|
|
114
|
+
rows: MRT_Row[],
|
|
115
|
+
id: string,
|
|
116
|
+
filterValue: string | number,
|
|
117
|
+
) =>
|
|
118
|
+
rows.filter((row) =>
|
|
119
|
+
!isNaN(+filterValue) && !isNaN(+row.values[id])
|
|
120
|
+
? +row.values[id] < +filterValue
|
|
121
|
+
: row.values[id].toString().toLowerCase().trim() <
|
|
122
|
+
filterValue.toString().toLowerCase().trim(),
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
lessThanFilterFN.autoRemove = (val: any) => !val;
|
|
126
|
+
|
|
87
127
|
export const emptyFilterFN = (
|
|
88
128
|
rows: MRT_Row[],
|
|
89
129
|
id: string,
|
|
@@ -104,6 +144,8 @@ export const defaultFilterFNs = {
|
|
|
104
144
|
contains: containsFilterFN,
|
|
105
145
|
empty: emptyFilterFN,
|
|
106
146
|
endsWith: endsWithFilterFN,
|
|
147
|
+
greaterThan: greaterThanFilterFN,
|
|
148
|
+
lessThan: lessThanFilterFN,
|
|
107
149
|
equals: equalsFilterFN,
|
|
108
150
|
fuzzy: fuzzyFilterFN,
|
|
109
151
|
notEmpty: notEmptyFilterFN,
|
|
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { TableFooter } from '@mui/material';
|
|
3
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
|
-
import { MRT_HeaderGroup } from '..';
|
|
5
|
+
import type { MRT_HeaderGroup } from '..';
|
|
6
6
|
|
|
7
7
|
interface Props {}
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@ import { TableRow } from '@mui/material';
|
|
|
3
3
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
|
4
4
|
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
5
5
|
import { useMRT } from '../useMRT';
|
|
6
|
-
import { MRT_HeaderGroup } from '..';
|
|
6
|
+
import type { MRT_HeaderGroup } from '..';
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
footerGroup: MRT_HeaderGroup;
|
|
@@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|
|
2
2
|
import { TableHead } from '@mui/material';
|
|
3
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
|
-
import { MRT_HeaderGroup } from '..';
|
|
5
|
+
import type { MRT_HeaderGroup } from '..';
|
|
6
6
|
|
|
7
7
|
interface Props {}
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
import { useMRT } from '../useMRT';
|
|
12
12
|
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
13
13
|
import { MRT_ToggleColumnActionMenuButton } from '../buttons/MRT_ToggleColumnActionMenuButton';
|
|
14
|
-
import { MRT_HeaderGroup } from '..';
|
|
14
|
+
import type { MRT_HeaderGroup } from '..';
|
|
15
15
|
|
|
16
16
|
export const commonTableHeadCellStyles = (
|
|
17
17
|
densePadding: boolean,
|
|
@@ -66,32 +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
84
|
.replace(
|
|
83
85
|
'{filterType}',
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
],
|
|
86
|
+
filterType instanceof Function
|
|
87
|
+
? ''
|
|
88
|
+
: // @ts-ignore
|
|
89
|
+
localization[
|
|
90
|
+
`filter${
|
|
91
|
+
filterType.charAt(0).toUpperCase() + filterType.slice(1)
|
|
92
|
+
}`
|
|
93
|
+
],
|
|
93
94
|
)
|
|
94
|
-
|
|
95
|
+
.replace('{filterValue}', column.filterValue)
|
|
96
|
+
: localization.showHideFilters;
|
|
95
97
|
|
|
96
98
|
const columnHeader = column.render('Header') as string;
|
|
97
99
|
|
|
@@ -127,7 +129,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
127
129
|
>
|
|
128
130
|
{column.render('Header')}
|
|
129
131
|
{!isParentHeader && column.canSort && (
|
|
130
|
-
<Tooltip arrow title={sortTooltip}>
|
|
132
|
+
<Tooltip arrow placement="top" title={sortTooltip}>
|
|
131
133
|
<TableSortLabel
|
|
132
134
|
aria-label={sortTooltip}
|
|
133
135
|
active={column.isSorted}
|
|
@@ -136,19 +138,21 @@ export const MRT_TableHeadCell: FC<Props> = ({ column }) => {
|
|
|
136
138
|
</Tooltip>
|
|
137
139
|
)}
|
|
138
140
|
{!isParentHeader && !!column.canFilter && (
|
|
139
|
-
<Tooltip arrow title={filterTooltip}>
|
|
141
|
+
<Tooltip arrow placement="top" title={filterTooltip}>
|
|
140
142
|
<IconButton
|
|
143
|
+
disableRipple
|
|
141
144
|
onClick={(event) => {
|
|
142
145
|
event.stopPropagation();
|
|
143
146
|
setShowFilters(!tableInstance.state.showFilters);
|
|
144
147
|
}}
|
|
145
148
|
size="small"
|
|
146
149
|
sx={{
|
|
150
|
+
m: 0,
|
|
147
151
|
opacity: !!column.filterValue ? 0.8 : 0,
|
|
148
152
|
p: '2px',
|
|
149
|
-
m: 0,
|
|
150
153
|
transition: 'all 0.2s ease-in-out',
|
|
151
154
|
'&:hover': {
|
|
155
|
+
backgroundColor: 'transparent',
|
|
152
156
|
opacity: 0.8,
|
|
153
157
|
},
|
|
154
158
|
}}
|
|
@@ -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
|
};
|
|
@@ -9,7 +9,7 @@ import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
|
|
9
9
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
|
10
10
|
import { MRT_TableSpacerCell } from '../table/MRT_TableSpacerCell';
|
|
11
11
|
import { MRT_TableHeadCellActions } from './MRT_TableHeadCellActions';
|
|
12
|
-
import { MRT_HeaderGroup } from '..';
|
|
12
|
+
import type { MRT_HeaderGroup } from '..';
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
15
15
|
headerGroup: MRT_HeaderGroup;
|