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-11-03 08:35:51 +00:00
|
|
|
import ContextMenuItem, { IProps as ItemProps } from './ContextMenuItem';
|
2022-01-07 10:54:42 +00:00
|
|
|
|
2021-10-22 13:23:52 +00:00
|
|
|
|
2022-11-03 08:35:51 +00:00
|
|
|
interface IProps {
|
2021-10-22 13:23:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
2022-11-03 08:35:51 +00:00
|
|
|
}
|
2021-10-22 13:23:52 +00:00
|
|
|
|
2022-11-15 07:50:22 +00:00
|
|
|
const useStyles = makeStyles()(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}`
|
2022-10-06 10:09:40 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
'&:first-of-type': {
|
|
|
|
paddingTop: 0
|
|
|
|
},
|
|
|
|
|
|
|
|
'&:last-of-type': {
|
|
|
|
paddingBottom: 0
|
2021-10-22 13:23:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
const ContextMenuItemGroup = ({
|
|
|
|
actions,
|
|
|
|
children
|
2022-11-03 08:35:51 +00:00
|
|
|
}: IProps) => {
|
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;
|