@jbrowse/core
Version:
JBrowse 2 core libraries used by plugins
60 lines (59 loc) • 2.29 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
import CheckBoxIcon from '@mui/icons-material/CheckBox';
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
import RadioButtonCheckedIcon from '@mui/icons-material/RadioButtonChecked';
import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked';
import { CircularProgress, ListItemIcon, ListItemText, MenuItem, } from '@mui/material';
import { makeStyles } from "../util/tss-react/index.js";
const useStyles = makeStyles()({
menuItemEndDecoration: {
padding: 0,
margin: 0,
height: 16,
},
});
export function MenuItemEndDecoration(props) {
const { classes } = useStyles();
const { type } = props;
let checked;
let disabled;
if ('checked' in props) {
;
({ checked, disabled } = props);
}
let icon;
switch (type) {
case 'subMenu': {
icon = _jsx(ArrowRightIcon, { color: "action" });
break;
}
case 'checkbox': {
if (checked) {
const color = disabled ? 'inherit' : undefined;
icon = _jsx(CheckBoxIcon, { color: color });
}
else {
icon = _jsx(CheckBoxOutlineBlankIcon, { color: "action" });
}
break;
}
case 'radio': {
if (checked) {
const color = disabled ? 'inherit' : undefined;
icon = _jsx(RadioButtonCheckedIcon, { color: color });
}
else {
icon = _jsx(RadioButtonUncheckedIcon, { color: "action" });
}
break;
}
}
return _jsx("div", { className: classes.menuItemEndDecoration, children: icon });
}
export function LoadingMenuItem() {
return (_jsxs(MenuItem, { disabled: true, children: [_jsx(ListItemIcon, { children: _jsx(CircularProgress, { size: 20 }) }), _jsx(ListItemText, { primary: "Loading..." })] }));
}
export function ErrorMenuItem({ error }) {
return (_jsx(MenuItem, { disabled: true, children: _jsx(ListItemText, { primary: "Error loading menu", secondary: error instanceof Error ? error.message : String(error) }) }));
}