material-react-table 0.14.2 → 0.14.5
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 +1 -1
- package/dist/head/MRT_TableHeadCell.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +26 -29
- 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 +27 -30
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/MaterialReactTable.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +14 -14
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +55 -57
- package/src/toolbar/MRT_ToolbarBottom.tsx +2 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.14.
|
|
2
|
+
"version": "0.14.5",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"@babel/core": "^7.18.5",
|
|
60
60
|
"@emotion/react": "^11.9.3",
|
|
61
61
|
"@emotion/styled": "^11.9.3",
|
|
62
|
-
"@faker-js/faker": "^
|
|
62
|
+
"@faker-js/faker": "^7.3.0",
|
|
63
63
|
"@mui/icons-material": "^5.8.4",
|
|
64
|
-
"@mui/material": "^5.8.
|
|
64
|
+
"@mui/material": "^5.8.5",
|
|
65
65
|
"@size-limit/preset-small-lib": "^7.0.8",
|
|
66
66
|
"@storybook/addon-a11y": "^6.5.9",
|
|
67
67
|
"@storybook/addon-actions": "^6.5.9",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@types/react": "^18.0.14",
|
|
74
74
|
"@types/react-dom": "^18.0.5",
|
|
75
75
|
"babel-loader": "^8.2.5",
|
|
76
|
-
"eslint": "^8.
|
|
76
|
+
"eslint": "^8.18.0",
|
|
77
77
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
78
78
|
"husky": "^8.0.1",
|
|
79
79
|
"prettier": "^2.7.1",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"storybook-dark-mode": "^1.1.0",
|
|
88
88
|
"tsdx": "^0.14.1",
|
|
89
89
|
"tslib": "^2.4.0",
|
|
90
|
-
"typescript": "^4.7.
|
|
90
|
+
"typescript": "^4.7.4"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"@emotion/react": ">=11",
|
|
@@ -824,7 +824,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
824
824
|
rowNumberMode?: 'original' | 'static';
|
|
825
825
|
selectAllMode?: 'all' | 'page';
|
|
826
826
|
tableId?: string;
|
|
827
|
-
virtualizerProps?: VirtualizerOptions<HTMLDivElement
|
|
827
|
+
virtualizerProps?: Partial<VirtualizerOptions<HTMLDivElement>>;
|
|
828
828
|
};
|
|
829
829
|
|
|
830
830
|
export default <D extends Record<string, any> = {}>({
|
|
@@ -12,32 +12,32 @@ interface Props {
|
|
|
12
12
|
dragRef?: Ref<HTMLButtonElement>;
|
|
13
13
|
dropRef?: Ref<HTMLDivElement>;
|
|
14
14
|
header: MRT_Header;
|
|
15
|
+
instance: MRT_TableInstance;
|
|
15
16
|
isDragging?: boolean;
|
|
16
17
|
previewRef?: Ref<HTMLTableCellElement>;
|
|
17
|
-
instance: MRT_TableInstance;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export const MRT_TableHeadCell: FC<Props> = ({
|
|
21
21
|
dragRef,
|
|
22
22
|
dropRef,
|
|
23
23
|
header,
|
|
24
|
+
instance,
|
|
24
25
|
isDragging,
|
|
25
26
|
previewRef,
|
|
26
|
-
instance,
|
|
27
27
|
}) => {
|
|
28
28
|
const {
|
|
29
29
|
getState,
|
|
30
30
|
options: {
|
|
31
31
|
enableColumnActions,
|
|
32
|
-
enableColumnFilters,
|
|
33
32
|
enableColumnOrdering,
|
|
34
33
|
enableColumnResizing,
|
|
35
34
|
enableGrouping,
|
|
35
|
+
enableMultiSort,
|
|
36
36
|
muiTableHeadCellProps,
|
|
37
37
|
},
|
|
38
38
|
} = instance;
|
|
39
39
|
|
|
40
|
-
const { density } = getState();
|
|
40
|
+
const { density, showFilters } = getState();
|
|
41
41
|
|
|
42
42
|
const { column } = header;
|
|
43
43
|
|
|
@@ -139,7 +139,9 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
139
139
|
right:
|
|
140
140
|
column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
|
|
141
141
|
transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
|
|
142
|
-
|
|
142
|
+
userSelect: enableMultiSort ? 'none' : undefined,
|
|
143
|
+
verticalAlign:
|
|
144
|
+
columnDefType === 'display' && showFilters ? 'center' : 'text-top',
|
|
143
145
|
zIndex: column.getIsResizing()
|
|
144
146
|
? 3
|
|
145
147
|
: column.getIsPinned() && columnDefType !== 'group'
|
|
@@ -167,7 +169,7 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
167
169
|
}}
|
|
168
170
|
>
|
|
169
171
|
<Box
|
|
170
|
-
onClick={
|
|
172
|
+
onClick={column.getToggleSortingHandler()}
|
|
171
173
|
sx={{
|
|
172
174
|
alignItems: 'center',
|
|
173
175
|
cursor:
|
|
@@ -184,14 +186,12 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
184
186
|
{columnDefType === 'data' && column.getCanSort() && (
|
|
185
187
|
<MRT_TableHeadCellSortLabel header={header} instance={instance} />
|
|
186
188
|
)}
|
|
187
|
-
{columnDefType === 'data' &&
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
/>
|
|
194
|
-
)}
|
|
189
|
+
{columnDefType === 'data' && column.getCanFilter() && (
|
|
190
|
+
<MRT_TableHeadCellFilterLabel
|
|
191
|
+
header={header}
|
|
192
|
+
instance={instance}
|
|
193
|
+
/>
|
|
194
|
+
)}
|
|
195
195
|
</Box>
|
|
196
196
|
<Box sx={{ whiteSpace: 'nowrap' }}>
|
|
197
197
|
{columnDefType === 'data' &&
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { FC, MouseEvent } from 'react';
|
|
2
|
-
import { IconButton, Tooltip } from '@mui/material';
|
|
2
|
+
import { Grow, IconButton, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_Header, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
@@ -14,73 +14,71 @@ export const MRT_TableHeadCellFilterLabel: FC<Props> = ({
|
|
|
14
14
|
const {
|
|
15
15
|
getState,
|
|
16
16
|
options: {
|
|
17
|
-
icons: { FilterAltIcon
|
|
17
|
+
icons: { FilterAltIcon },
|
|
18
18
|
localization,
|
|
19
19
|
},
|
|
20
|
-
setShowFilters,
|
|
21
20
|
} = instance;
|
|
22
21
|
|
|
23
|
-
const {
|
|
22
|
+
const { currentFilterFns } = getState();
|
|
24
23
|
|
|
25
24
|
const { column } = header;
|
|
26
25
|
|
|
27
26
|
const { columnDef } = column;
|
|
28
27
|
|
|
29
|
-
const filterFn =
|
|
28
|
+
const filterFn = currentFilterFns?.[header.id];
|
|
30
29
|
|
|
31
|
-
const filterTooltip =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.replace('" "', '')
|
|
54
|
-
: localization.showHideFilters;
|
|
30
|
+
const filterTooltip = localization.filteringByColumn
|
|
31
|
+
.replace('{column}', String(columnDef.header))
|
|
32
|
+
.replace(
|
|
33
|
+
'{filterType}',
|
|
34
|
+
filterFn instanceof Function
|
|
35
|
+
? ''
|
|
36
|
+
: // @ts-ignore
|
|
37
|
+
localization[
|
|
38
|
+
`filter${filterFn.charAt(0).toUpperCase() + filterFn.slice(1)}`
|
|
39
|
+
],
|
|
40
|
+
)
|
|
41
|
+
.replace(
|
|
42
|
+
'{filterValue}',
|
|
43
|
+
`"${
|
|
44
|
+
Array.isArray(column.getFilterValue())
|
|
45
|
+
? (column.getFilterValue() as [string, string]).join(
|
|
46
|
+
`" ${localization.and} "`,
|
|
47
|
+
)
|
|
48
|
+
: (column.getFilterValue() as string)
|
|
49
|
+
}"`,
|
|
50
|
+
)
|
|
51
|
+
.replace('" "', '');
|
|
55
52
|
|
|
56
53
|
return (
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
54
|
+
<Grow
|
|
55
|
+
unmountOnExit
|
|
56
|
+
in={
|
|
57
|
+
(!!column.getFilterValue() && filterFn !== 'between') ||
|
|
58
|
+
(filterFn === 'between' && // @ts-ignore
|
|
59
|
+
(!!column.getFilterValue()?.[0] || !!column.getFilterValue()?.[1]))
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
<span>
|
|
63
|
+
<Tooltip arrow placement="top" title={filterTooltip}>
|
|
64
|
+
<IconButton
|
|
65
|
+
disableRipple
|
|
66
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => {
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
}}
|
|
69
|
+
size="small"
|
|
70
|
+
sx={{
|
|
71
|
+
m: 0,
|
|
72
|
+
opacity: 0.8,
|
|
73
|
+
p: '2px',
|
|
74
|
+
transform: 'scale(0.66)',
|
|
75
|
+
width: '1.5ch',
|
|
76
|
+
}}
|
|
77
|
+
>
|
|
78
|
+
<FilterAltIcon />
|
|
79
|
+
</IconButton>
|
|
80
|
+
</Tooltip>
|
|
81
|
+
</span>
|
|
82
|
+
</Grow>
|
|
85
83
|
);
|
|
86
84
|
};
|
|
@@ -47,7 +47,9 @@ export const MRT_ToolbarBottom: FC<Props> = ({ instance }) => {
|
|
|
47
47
|
...commonToolbarStyles({ theme }),
|
|
48
48
|
bottom: isFullScreen ? '0' : undefined,
|
|
49
49
|
boxShadow: `-3px 0 6px ${alpha(theme.palette.common.black, 0.1)}`,
|
|
50
|
+
left: 0,
|
|
50
51
|
position: isFullScreen ? 'fixed' : 'relative',
|
|
52
|
+
right: 0,
|
|
51
53
|
...toolbarProps?.sx,
|
|
52
54
|
} as any)
|
|
53
55
|
}
|