material-react-table 0.4.2 → 0.4.3
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/buttons/MRT_ToggleDensePaddingButton.d.ts +5 -0
- package/dist/material-react-table.cjs.development.js +59 -22
- 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 +60 -23
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +23 -0
- package/src/table/MRT_TableContainer.tsx +10 -2
- package/src/toolbar/MRT_ToolbarBottom.tsx +17 -5
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +2 -2
- package/src/toolbar/MRT_ToolbarTop.tsx +17 -5
- package/dist/inputs/MRT_DensePaddingSwitch.d.ts +0 -5
- package/src/inputs/MRT_DensePaddingSwitch.tsx +0 -23
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.4.
|
|
2
|
+
"version": "0.4.3",
|
|
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,9 +56,9 @@
|
|
|
56
56
|
}
|
|
57
57
|
],
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@babel/core": "^7.17.
|
|
60
|
-
"@emotion/react": "^11.
|
|
61
|
-
"@emotion/styled": "^11.
|
|
59
|
+
"@babel/core": "^7.17.5",
|
|
60
|
+
"@emotion/react": "^11.8.0",
|
|
61
|
+
"@emotion/styled": "^11.8.0",
|
|
62
62
|
"@etchteam/storybook-addon-status": "^4.2.0",
|
|
63
63
|
"@faker-js/faker": "^6.0.0-alpha.6",
|
|
64
64
|
"@mui/icons-material": "^5.4.2",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"size-limit": "^7.0.8",
|
|
88
88
|
"storybook-addon-paddings": "^4.2.1",
|
|
89
89
|
"storybook-addon-performance": "^0.16.1",
|
|
90
|
-
"storybook-dark-mode": "^1.0.
|
|
90
|
+
"storybook-dark-mode": "^1.0.9",
|
|
91
91
|
"tsdx": "^0.14.1",
|
|
92
92
|
"tslib": "^2.3.1",
|
|
93
93
|
"typescript": "^4.5.5"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { IconButton, Tooltip } from '@mui/material';
|
|
3
|
+
import { useMRT } from '../useMRT';
|
|
4
|
+
import DensityMediumIcon from '@mui/icons-material/DensityMedium';
|
|
5
|
+
import DensitySmallIcon from '@mui/icons-material/DensitySmall';
|
|
6
|
+
|
|
7
|
+
interface Props {}
|
|
8
|
+
|
|
9
|
+
export const MRT_ToggleDensePaddingButton: FC<Props> = () => {
|
|
10
|
+
const { densePadding, setDensePadding, localization } = useMRT();
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<Tooltip arrow title={localization?.toggleDensePaddingSwitchTitle ?? ''}>
|
|
14
|
+
<IconButton
|
|
15
|
+
aria-label={localization?.toggleDensePaddingSwitchTitle}
|
|
16
|
+
onClick={() => setDensePadding(!densePadding)}
|
|
17
|
+
size="small"
|
|
18
|
+
>
|
|
19
|
+
{densePadding ? <DensitySmallIcon /> : <DensityMediumIcon />}
|
|
20
|
+
</IconButton>
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, useEffect } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
CircularProgress,
|
|
4
4
|
LinearProgress,
|
|
@@ -14,7 +14,7 @@ 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,
|
|
@@ -51,6 +51,14 @@ export const MRT_TableContainer: FC<Props> = () => {
|
|
|
51
51
|
tableInstance,
|
|
52
52
|
} = useMRT();
|
|
53
53
|
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if(fullScreen) {
|
|
56
|
+
document.body.style.overflow = 'hidden';
|
|
57
|
+
} else {
|
|
58
|
+
document.body.style.overflow = 'auto';
|
|
59
|
+
}
|
|
60
|
+
}, [fullScreen]);
|
|
61
|
+
|
|
54
62
|
const tableContainerProps =
|
|
55
63
|
muiTableContainerProps instanceof Function
|
|
56
64
|
? muiTableContainerProps(tableInstance)
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { styled, Toolbar as MuiToolbar } from '@mui/material';
|
|
2
|
+
import { alpha, styled, Toolbar as MuiToolbar } from '@mui/material';
|
|
3
3
|
import { useMRT } from '../useMRT';
|
|
4
4
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
5
5
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
6
6
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
7
7
|
|
|
8
|
-
const Toolbar = styled(MuiToolbar
|
|
8
|
+
const Toolbar = styled(MuiToolbar, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== 'fullScreen',
|
|
10
|
+
})<{ fullScreen?: boolean }>(({ fullScreen, theme }) => ({
|
|
11
|
+
backgroundColor: theme.palette.background.default,
|
|
12
|
+
backgroundImage: `linear-gradient(${alpha(
|
|
13
|
+
theme.palette.common.white,
|
|
14
|
+
0.05,
|
|
15
|
+
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
16
|
+
bottom: fullScreen ? '0' : undefined,
|
|
9
17
|
display: 'flex',
|
|
10
18
|
justifyContent: 'space-between',
|
|
11
|
-
padding: '0 0.5rem !important',
|
|
12
19
|
overflowY: 'hidden',
|
|
13
|
-
|
|
20
|
+
padding: '0 0.5rem !important',
|
|
21
|
+
position: fullScreen ? 'fixed' : undefined,
|
|
22
|
+
width: 'calc(100% - 1rem)',
|
|
23
|
+
zIndex: 1,
|
|
24
|
+
}));
|
|
14
25
|
|
|
15
26
|
interface Props {}
|
|
16
27
|
|
|
@@ -20,6 +31,7 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
20
31
|
manualPagination,
|
|
21
32
|
muiTableToolbarBottomProps,
|
|
22
33
|
positionPagination,
|
|
34
|
+
fullScreen,
|
|
23
35
|
positionToolbarActions,
|
|
24
36
|
positionToolbarAlertBanner,
|
|
25
37
|
tableInstance,
|
|
@@ -31,7 +43,7 @@ export const MRT_ToolbarBottom: FC<Props> = () => {
|
|
|
31
43
|
: muiTableToolbarBottomProps;
|
|
32
44
|
|
|
33
45
|
return (
|
|
34
|
-
<Toolbar variant="dense" {...toolbarProps}>
|
|
46
|
+
<Toolbar fullScreen={fullScreen} variant="dense" {...toolbarProps}>
|
|
35
47
|
{!hideToolbarActions && positionToolbarActions === 'bottom' ? (
|
|
36
48
|
<MRT_ToolbarInternalButtons />
|
|
37
49
|
) : (
|
|
@@ -3,7 +3,7 @@ import { styled } from '@mui/material';
|
|
|
3
3
|
import { MRT_ToggleFiltersButton } from '../buttons/MRT_ToggleFiltersButton';
|
|
4
4
|
import { MRT_ShowHideColumnsButton } from '../buttons/MRT_ShowHideColumnsButton';
|
|
5
5
|
import { useMRT } from '../useMRT';
|
|
6
|
-
import {
|
|
6
|
+
import { MRT_ToggleDensePaddingButton } from '../buttons/MRT_ToggleDensePaddingButton';
|
|
7
7
|
import { MRT_ToggleSearchButton } from '../buttons/MRT_ToggleSearchButton';
|
|
8
8
|
import { MRT_FullScreenToggleButton } from '../buttons/MRT_FullScreenToggleButton';
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ export const MRT_ToolbarInternalButtons: FC<Props> = () => {
|
|
|
29
29
|
{!disableGlobalFilter && <MRT_ToggleSearchButton />}
|
|
30
30
|
{!disableFilters && <MRT_ToggleFiltersButton />}
|
|
31
31
|
{!disableColumnHiding && <MRT_ShowHideColumnsButton />}
|
|
32
|
-
{!disableDensePaddingToggle && <
|
|
32
|
+
{!disableDensePaddingToggle && <MRT_ToggleDensePaddingButton />}
|
|
33
33
|
{!disableFullScreenToggle && <MRT_FullScreenToggleButton />}
|
|
34
34
|
</ToolbarButtonsContainer>
|
|
35
35
|
);
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { styled, Toolbar as MuiToolbar } from '@mui/material';
|
|
2
|
+
import { alpha, styled, Toolbar as MuiToolbar } from '@mui/material';
|
|
3
3
|
import { MRT_SearchTextField } from '../inputs/MRT_SearchTextField';
|
|
4
4
|
import { useMRT } from '../useMRT';
|
|
5
5
|
import { MRT_ToolbarInternalButtons } from './MRT_ToolbarInternalButtons';
|
|
6
6
|
import { MRT_TablePagination } from './MRT_TablePagination';
|
|
7
7
|
import { MRT_ToolbarAlertBanner } from './MRT_ToolbarAlertBanner';
|
|
8
8
|
|
|
9
|
-
const Toolbar = styled(MuiToolbar
|
|
9
|
+
const Toolbar = styled(MuiToolbar, {
|
|
10
|
+
shouldForwardProp: (prop) => prop !== 'fullScreen',
|
|
11
|
+
})<{ fullScreen?: boolean }>(({ fullScreen, theme }) => ({
|
|
12
|
+
backgroundColor: theme.palette.background.default,
|
|
13
|
+
backgroundImage: `linear-gradient(${alpha(
|
|
14
|
+
theme.palette.common.white,
|
|
15
|
+
0.05,
|
|
16
|
+
)},${alpha(theme.palette.common.white, 0.05)})`,
|
|
10
17
|
display: 'grid',
|
|
11
18
|
padding: '0 0.5rem !important',
|
|
12
|
-
|
|
19
|
+
position: fullScreen ? 'sticky' : undefined,
|
|
20
|
+
top: fullScreen ? '0' : undefined,
|
|
21
|
+
width: 'calc(100% - 1rem)',
|
|
22
|
+
zIndex: 1,
|
|
23
|
+
}));
|
|
13
24
|
|
|
14
25
|
const ToolbarTopRow = styled('div')({
|
|
15
|
-
padding: '
|
|
26
|
+
padding: '0.5rem',
|
|
16
27
|
display: 'flex',
|
|
17
28
|
justifyContent: 'space-between',
|
|
18
29
|
});
|
|
@@ -34,6 +45,7 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
34
45
|
muiTableToolbarTopProps,
|
|
35
46
|
positionPagination,
|
|
36
47
|
positionToolbarActions,
|
|
48
|
+
fullScreen,
|
|
37
49
|
positionToolbarAlertBanner,
|
|
38
50
|
renderToolbarCustomActions,
|
|
39
51
|
tableInstance,
|
|
@@ -45,7 +57,7 @@ export const MRT_ToolbarTop: FC<Props> = () => {
|
|
|
45
57
|
: muiTableToolbarTopProps;
|
|
46
58
|
|
|
47
59
|
return (
|
|
48
|
-
<Toolbar variant="dense" {...toolbarProps}>
|
|
60
|
+
<Toolbar fullScreen={fullScreen} variant="dense" {...toolbarProps}>
|
|
49
61
|
{positionToolbarAlertBanner === 'top' && <MRT_ToolbarAlertBanner />}
|
|
50
62
|
<ToolbarTopRow>
|
|
51
63
|
{renderToolbarCustomActions?.(tableInstance) ?? <span />}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
};
|