material-react-table 0.4.3 → 0.4.4
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 +9 -2
- package/dist/inputs/MRT_DensePaddingSwitch.d.ts +5 -0
- package/dist/material-react-table.cjs.development.js +18 -6
- 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 +18 -6
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +18 -2
- package/src/inputs/MRT_DensePaddingSwitch.tsx +23 -0
- package/src/table/MRT_TableContainer.tsx +3 -3
- package/src/toolbar/MRT_ToolbarBottom.tsx +2 -2
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +16 -0
- package/src/toolbar/MRT_ToolbarTop.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.4.
|
|
2
|
+
"version": "0.4.4",
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import React, { ChangeEvent, MouseEvent, ReactNode } from 'react';
|
|
1
|
+
import React, { ChangeEvent, FC, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
AlertProps,
|
|
4
4
|
TableBodyProps,
|
|
@@ -66,7 +66,7 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
66
66
|
enableSelection?: boolean;
|
|
67
67
|
hideTableFooter?: boolean;
|
|
68
68
|
hideTableHead?: boolean;
|
|
69
|
-
|
|
69
|
+
hideToolbarInternalActions?: boolean;
|
|
70
70
|
hideToolbarBottom?: boolean;
|
|
71
71
|
hideToolbarTop?: boolean;
|
|
72
72
|
isFetching?: boolean;
|
|
@@ -153,6 +153,22 @@ export type MaterialReactTableProps<D extends {} = {}> = TableOptions<D> &
|
|
|
153
153
|
tableInstance: TableInstance<D>,
|
|
154
154
|
) => ReactNode;
|
|
155
155
|
renderToolbarCustomActions?: (tableInstance: TableInstance<D>) => ReactNode;
|
|
156
|
+
renderToolbarInternalActions?: (
|
|
157
|
+
tableInstance: TableInstance<D>,
|
|
158
|
+
{
|
|
159
|
+
MRT_ToggleSearchButton,
|
|
160
|
+
MRT_ToggleFiltersButton,
|
|
161
|
+
MRT_ShowHideColumnsButton,
|
|
162
|
+
MRT_ToggleDensePaddingButton,
|
|
163
|
+
MRT_FullScreenToggleButton,
|
|
164
|
+
}: {
|
|
165
|
+
MRT_ToggleSearchButton: FC;
|
|
166
|
+
MRT_ToggleFiltersButton: FC;
|
|
167
|
+
MRT_ShowHideColumnsButton: FC;
|
|
168
|
+
MRT_ToggleDensePaddingButton: FC;
|
|
169
|
+
MRT_FullScreenToggleButton: FC;
|
|
170
|
+
},
|
|
171
|
+
) => ReactNode;
|
|
156
172
|
};
|
|
157
173
|
|
|
158
174
|
export default <D extends {}>({
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { Switch, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
|
|
5
|
+
interface Props {}
|
|
6
|
+
|
|
7
|
+
export const MRT_DensePaddingSwitch: FC<Props> = () => {
|
|
8
|
+
const { densePadding, setDensePadding, localization } = useMRT();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
|
|
12
|
+
<Switch
|
|
13
|
+
inputProps={{
|
|
14
|
+
'aria-label': localization?.toggleDensePaddingSwitchTitle ?? '',
|
|
15
|
+
}}
|
|
16
|
+
color="default"
|
|
17
|
+
checked={densePadding}
|
|
18
|
+
size="small"
|
|
19
|
+
onChange={() => setDensePadding(!densePadding)}
|
|
20
|
+
/>
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -14,12 +14,12 @@ import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
|
|
|
14
14
|
|
|
15
15
|
const TableContainer = styled(MuiTableContainer, {
|
|
16
16
|
shouldForwardProp: (prop) => prop !== 'fullScreen',
|
|
17
|
-
})<{ fullScreen?: boolean
|
|
17
|
+
})<{ fullScreen?: boolean; component: any }>(({ fullScreen }) => ({
|
|
18
18
|
bottom: fullScreen ? '0' : undefined,
|
|
19
19
|
height: fullScreen ? '100%' : undefined,
|
|
20
20
|
left: fullScreen ? '0' : undefined,
|
|
21
21
|
margin: fullScreen ? '0' : undefined,
|
|
22
|
-
position: fullScreen ? '
|
|
22
|
+
position: fullScreen ? 'fixed' : undefined,
|
|
23
23
|
right: fullScreen ? '0' : undefined,
|
|
24
24
|
top: fullScreen ? '0' : undefined,
|
|
25
25
|
transition: 'all 0.2s ease-in-out',
|
|
@@ -52,7 +52,7 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
52
52
|
} = useMRT();
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
55
|
-
if(fullScreen) {
|
|
55
|
+
if (fullScreen) {
|
|
56
56
|
document.body.style.overflow = 'hidden';
|
|
57
57
|
} else {
|
|
58
58
|
document.body.style.overflow = 'auto';
|
|
@@ -27,7 +27,7 @@ interface Props {}
|
|
|
27
27
|
|
|
28
28
|
export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
29
29
|
const {
|
|
30
|
-
|
|
30
|
+
hideToolbarInternalActions,
|
|
31
31
|
manualPagination,
|
|
32
32
|
muiTableToolbarBottomProps,
|
|
33
33
|
positionPagination,
|
|
@@ -44,7 +44,7 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
46
|
<Toolbar fullScreen={fullScreen} variant="dense" {...toolbarProps}>
|
|
47
|
-
{!
|
|
47
|
+
{!hideToolbarInternalActions && positionToolbarActions === 'bottom' ? (
|
|
48
48
|
<MRT_ToolbarInternalButtons />
|
|
49
49
|
) : (
|
|
50
50
|
<span />
|
|
@@ -22,8 +22,24 @@ export const MRT_ToolbarInternalButtons: FC<Props> = () => {
|
|
|
22
22
|
disableDensePaddingToggle,
|
|
23
23
|
disableGlobalFilter,
|
|
24
24
|
disableFullScreenToggle,
|
|
25
|
+
renderToolbarInternalActions,
|
|
26
|
+
tableInstance,
|
|
25
27
|
} = useMRT();
|
|
26
28
|
|
|
29
|
+
if (renderToolbarInternalActions) {
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
{renderToolbarInternalActions(tableInstance, {
|
|
33
|
+
MRT_ToggleSearchButton,
|
|
34
|
+
MRT_ToggleFiltersButton,
|
|
35
|
+
MRT_ShowHideColumnsButton,
|
|
36
|
+
MRT_ToggleDensePaddingButton,
|
|
37
|
+
MRT_FullScreenToggleButton,
|
|
38
|
+
})}
|
|
39
|
+
</>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
return (
|
|
28
44
|
<ToolbarButtonsContainer>
|
|
29
45
|
{!disableGlobalFilter && <MRT_ToggleSearchButton />}
|
|
@@ -40,7 +40,7 @@ interface Props {}
|
|
|
40
40
|
export const MRT_ToolbarTop: FC<Props> = () => {
|
|
41
41
|
const {
|
|
42
42
|
disableGlobalFilter,
|
|
43
|
-
|
|
43
|
+
hideToolbarInternalActions,
|
|
44
44
|
manualPagination,
|
|
45
45
|
muiTableToolbarTopProps,
|
|
46
46
|
positionPagination,
|
|
@@ -63,7 +63,7 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
63
63
|
{renderToolbarCustomActions?.(tableInstance) ?? <span />}
|
|
64
64
|
<ToolbarActionsContainer>
|
|
65
65
|
{!disableGlobalFilter && <MRT_SearchTextField />}
|
|
66
|
-
{!
|
|
66
|
+
{!hideToolbarInternalActions && positionToolbarActions === 'top' && (
|
|
67
67
|
<MRT_ToolbarInternalButtons />
|
|
68
68
|
)}
|
|
69
69
|
</ToolbarActionsContainer>
|