@lunit/oui
Version:
Lunit Oncology UI components
20 lines (19 loc) • 1.04 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext } from 'react';
import ListItemCaption from '../List/ListItemCaption';
import { MenuContext } from '../Menu/Menu';
import { StyledMenuItem, StyledMenuItemStartIcon, StyledMenuItemText, StyledMenuItemEndIcon, CheckIcon, EmptyIcon, } from './MenuItem.styled';
const MenuItem = ({ icon: iconProp, caption, label, selected, ...props }) => {
const { size, showCheck } = useContext(MenuContext);
const icon = (() => {
if (showCheck) {
if (selected) {
return _jsx(CheckIcon, {});
}
return iconProp || _jsx(EmptyIcon, {});
}
return iconProp;
})();
return (_jsxs(StyledMenuItem, { ...props, size: size, disableRipple: true, children: [icon && _jsx(StyledMenuItemStartIcon, { children: icon }), _jsx(StyledMenuItemText, { primary: label }), caption && (_jsx(StyledMenuItemEndIcon, { children: _jsx(ListItemCaption, { children: caption }) }))] }));
};
export default MenuItem;