@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
27 lines (26 loc) • 2.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = SetMinMaxDialog;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const ui_1 = require("@jbrowse/core/ui");
const material_1 = require("@mui/material");
function SetMinMaxDialog(props) {
const { model, handleClose } = props;
const { minScore, maxScore, scaleType } = model;
const [min, setMin] = (0, react_1.useState)(`${minScore !== Number.MIN_VALUE ? minScore : ''}`);
const [max, setMax] = (0, react_1.useState)(`${maxScore !== Number.MAX_VALUE ? maxScore : ''}`);
const ok = min !== '' && max !== '' && !Number.isNaN(+min) && !Number.isNaN(+max)
? +max > +min
: true;
const logOk = scaleType === 'log' && min !== '' && !Number.isNaN(+min) ? +min > 0 : true;
return ((0, jsx_runtime_1.jsxs)(ui_1.Dialog, { open: true, onClose: handleClose, title: "Set min/max score for track", children: [(0, jsx_runtime_1.jsxs)(material_1.DialogContent, { children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { children: "Enter min/max score: " }), !ok ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", children: "Max is greater than or equal to min" })) : null, !logOk ? ((0, jsx_runtime_1.jsx)(material_1.Typography, { color: "error", children: "Min score should be greater than 0 for log scale" })) : null, (0, jsx_runtime_1.jsx)(material_1.TextField, { value: min, onChange: event => {
setMin(event.target.value);
}, placeholder: "Enter min score" }), (0, jsx_runtime_1.jsx)(material_1.TextField, { value: max, onChange: event => {
setMax(event.target.value);
}, placeholder: "Enter max score" })] }), (0, jsx_runtime_1.jsx)(material_1.DialogActions, { children: (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", type: "submit", style: { marginLeft: 20 }, disabled: !ok, onClick: () => {
model.setMinScore(min !== '' && !Number.isNaN(+min) ? +min : undefined);
model.setMaxScore(max !== '' && !Number.isNaN(+max) ? +max : undefined);
handleClose();
}, children: "Submit" }) })] }));
}