|
1 | 1 | import Paper, { type PaperProps } from '@mui/material/Paper';
|
2 |
| -import { useTheme } from '@mui/material'; |
| 2 | +import FocusTrap from '@mui/material/Unstable_TrapFocus/FocusTrap'; |
| 3 | +import { useTheme } from '@mui/material/styles'; |
3 | 4 | import { MRT_TableContainer } from './MRT_TableContainer';
|
4 | 5 | import { type MRT_RowData, type MRT_TableInstance } from '../../types';
|
5 | 6 | import { parseFromValuesOrFunc } from '../../utils/utils';
|
@@ -37,52 +38,55 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
|
37 | 38 | const theme = useTheme();
|
38 | 39 |
|
39 | 40 | return (
|
40 |
| - <Paper |
41 |
| - elevation={2} |
42 |
| - {...paperProps} |
43 |
| - ref={(ref: HTMLDivElement) => { |
44 |
| - tablePaperRef.current = ref; |
45 |
| - if (paperProps?.ref) { |
46 |
| - //@ts-ignore |
47 |
| - paperProps.ref.current = ref; |
48 |
| - } |
49 |
| - }} |
50 |
| - style={{ |
51 |
| - ...(isFullScreen |
52 |
| - ? { |
53 |
| - bottom: 0, |
54 |
| - height: '100dvh', |
55 |
| - left: 0, |
56 |
| - margin: 0, |
57 |
| - maxHeight: '100dvh', |
58 |
| - maxWidth: '100dvw', |
59 |
| - padding: 0, |
60 |
| - position: 'fixed', |
61 |
| - right: 0, |
62 |
| - top: 0, |
63 |
| - width: '100dvw', |
64 |
| - zIndex: theme.zIndex.modal, |
65 |
| - } |
66 |
| - : {}), |
67 |
| - ...paperProps?.style, |
68 |
| - }} |
69 |
| - sx={(theme) => ({ |
70 |
| - backgroundColor: baseBackgroundColor, |
71 |
| - backgroundImage: 'unset', |
72 |
| - overflow: 'hidden', |
73 |
| - transition: 'all 100ms ease-in-out', |
74 |
| - ...(parseFromValuesOrFunc(paperProps?.sx, theme) as any), |
75 |
| - })} |
76 |
| - > |
77 |
| - {enableTopToolbar && |
78 |
| - (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? ( |
79 |
| - <MRT_TopToolbar table={table} /> |
80 |
| - ))} |
81 |
| - <MRT_TableContainer table={table} /> |
82 |
| - {enableBottomToolbar && |
83 |
| - (parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? ( |
84 |
| - <MRT_BottomToolbar table={table} /> |
85 |
| - ))} |
86 |
| - </Paper> |
| 41 | + <FocusTrap open={isFullScreen}> |
| 42 | + <Paper |
| 43 | + elevation={2} |
| 44 | + onKeyDown={(e) => e.key === 'Escape' && table.setIsFullScreen(false)} |
| 45 | + {...paperProps} |
| 46 | + ref={(ref: HTMLDivElement) => { |
| 47 | + tablePaperRef.current = ref; |
| 48 | + if (paperProps?.ref) { |
| 49 | + //@ts-ignore |
| 50 | + paperProps.ref.current = ref; |
| 51 | + } |
| 52 | + }} |
| 53 | + style={{ |
| 54 | + ...(isFullScreen |
| 55 | + ? { |
| 56 | + bottom: 0, |
| 57 | + height: '100dvh', |
| 58 | + left: 0, |
| 59 | + margin: 0, |
| 60 | + maxHeight: '100dvh', |
| 61 | + maxWidth: '100dvw', |
| 62 | + padding: 0, |
| 63 | + position: 'fixed', |
| 64 | + right: 0, |
| 65 | + top: 0, |
| 66 | + width: '100dvw', |
| 67 | + zIndex: theme.zIndex.modal, |
| 68 | + } |
| 69 | + : {}), |
| 70 | + ...paperProps?.style, |
| 71 | + }} |
| 72 | + sx={(theme) => ({ |
| 73 | + backgroundColor: baseBackgroundColor, |
| 74 | + backgroundImage: 'unset', |
| 75 | + overflow: 'hidden', |
| 76 | + transition: 'all 100ms ease-in-out', |
| 77 | + ...(parseFromValuesOrFunc(paperProps?.sx, theme) as any), |
| 78 | + })} |
| 79 | + > |
| 80 | + {enableTopToolbar && |
| 81 | + (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? ( |
| 82 | + <MRT_TopToolbar table={table} /> |
| 83 | + ))} |
| 84 | + <MRT_TableContainer table={table} /> |
| 85 | + {enableBottomToolbar && |
| 86 | + (parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? ( |
| 87 | + <MRT_BottomToolbar table={table} /> |
| 88 | + ))} |
| 89 | + </Paper> |
| 90 | + </FocusTrap> |
87 | 91 | );
|
88 | 92 | };
|
0 commit comments