@plteam/chat-ui
Version:
CUI Kit is a free and open-source library for creating AI assistant chat interfaces, built with React, Material UI, and TypeScript
28 lines (27 loc) • 1.21 kB
JavaScript
import * as React from 'react';
import MenuItem from '@mui/material/MenuItem';
import { styled } from '@mui/material/styles';
import ListItemIcon from '@mui/material/ListItemIcon';
import CircularProgress from '@mui/material/CircularProgress';
const MenuItemStyled = styled(MenuItem)(({ theme }) => ({
minWidth: 180,
paddingLeft: theme.spacing(1.5),
paddingRight: theme.spacing(1),
minHeight: '48px !important',
'& .MuiSvgIcon-root': {
color: 'inherit',
fontSize: '1.5rem',
}
}));
const MdMenuItem = ({ children, startIcon, disabled, loading, ...otherProps }) => {
const icon = startIcon ? React.createElement(startIcon, { fontSize: 'small' }) : undefined;
return (React.createElement(MenuItemStyled, { ...otherProps, disabled: disabled || loading },
!!icon && (
// eslint-disable-next-line react/jsx-no-useless-fragment
React.createElement(React.Fragment, null, loading
? (React.createElement(ListItemIcon, null,
React.createElement(CircularProgress, { size: 24 })))
: (React.createElement(ListItemIcon, null, icon)))),
children));
};
export default MdMenuItem;