2022-09-13 07:36:00 +00:00
|
|
|
import { Theme } from '@mui/material';
|
2022-08-26 09:54:03 +00:00
|
|
|
import React, { ReactNode } from 'react';
|
2022-09-13 07:36:00 +00:00
|
|
|
import { makeStyles } from 'tss-react/mui';
|
2021-10-22 13:23:52 +00:00
|
|
|
|
2022-08-26 09:54:03 +00:00
|
|
|
import ContextMenuItem, { Props as ItemProps } from './ContextMenuItem';
|
2022-01-07 10:54:42 +00:00
|
|
|
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* List of actions in this group.
|
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
actions?: Array<ItemProps>;
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
2021-11-04 21:10:43 +00:00
|
|
|
* The children of the component.
|
2021-10-22 13:23:52 +00:00
|
|
|
*/
|
2022-09-08 09:52:36 +00:00
|
|
|
children?: ReactNode;
|
2021-10-22 13:23:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-13 07:36:00 +00:00
|
|
|
const useStyles = makeStyles()((theme: Theme) => {
|
2021-10-22 13:23:52 +00:00
|
|
|
return {
|
|
|
|
contextMenuItemGroup: {
|
|
|
|
'&:not(:empty)': {
|
2022-09-13 07:36:00 +00:00
|
|
|
padding: `${theme.spacing(2)} 0`
|
2021-10-22 13:23:52 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
'& + &:not(:empty)': {
|
|
|
|
borderTop: `1px solid ${theme.palette.ui04}`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const ContextMenuItemGroup = ({
|
|
|
|
actions,
|
|
|
|
children
|
|
|
|
}: Props) => {
|
2022-09-13 07:36:00 +00:00
|
|
|
const { classes: styles } = useStyles();
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className = { styles.contextMenuItemGroup }>
|
|
|
|
{children}
|
2022-09-08 09:52:36 +00:00
|
|
|
{actions?.map(actionProps => (
|
2021-12-15 13:18:41 +00:00
|
|
|
<ContextMenuItem
|
|
|
|
key = { actionProps.text }
|
|
|
|
{ ...actionProps } />
|
2021-10-22 13:23:52 +00:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ContextMenuItemGroup;
|