2023-04-17 02:27:22 +00:00
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import Box from '@mui/material/Box';
|
|
|
|
|
import Drawer from '@mui/material/Drawer';
|
|
|
|
|
import Button from '@mui/material/Button';
|
|
|
|
|
import {SxProps, Theme} from "@mui/material";
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
outerContainerSx?: SxProps<Theme>;
|
|
|
|
|
children?: React.ReactNode;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-17 02:27:22 +00:00
|
|
|
|
export default function DrawerNewField({outerContainerSx: sx, children }: Props) {
|
|
|
|
|
const [state, setState] = React.useState({
|
|
|
|
|
right: false,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const toggleDrawer =
|
|
|
|
|
(anchor: 'right', open: boolean) =>
|
|
|
|
|
() => {
|
|
|
|
|
setState({ ...state, 'right' : open });
|
|
|
|
|
};
|
|
|
|
|
|
2023-04-17 02:27:22 +00:00
|
|
|
|
return (
|
|
|
|
|
<>
|
2023-04-17 02:27:22 +00:00
|
|
|
|
<Button onClick={toggleDrawer("right", true)} variant='contained' sx={{maxWidth: 'fit-content', padding: '10px 20px'}}>
|
|
|
|
|
Добавить поле +
|
|
|
|
|
</Button>
|
2023-04-17 02:27:22 +00:00
|
|
|
|
<Drawer
|
|
|
|
|
anchor='right'
|
2023-04-17 02:27:22 +00:00
|
|
|
|
open={state['right']}
|
|
|
|
|
onClose={toggleDrawer("right", false)}
|
2023-04-17 02:27:22 +00:00
|
|
|
|
>
|
|
|
|
|
<Box
|
|
|
|
|
sx={{ width: 450 }}
|
|
|
|
|
role="presentation"
|
|
|
|
|
>
|
|
|
|
|
|
|
|
|
|
{children}
|
|
|
|
|
</Box>
|
|
|
|
|
</Drawer>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|