UNPKG

@jbrowse/plugin-wiggle

Version:

JBrowse 2 wiggle adapters, tracks, etc.

24 lines (23 loc) 1.99 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import { Dialog } from '@jbrowse/core/ui'; import { Button, DialogActions, DialogContent, TextField, Typography, } from '@mui/material'; export default function SetMinMaxDialog(props) { const { model, handleClose } = props; const { minScore, maxScore, scaleType } = model; const [min, setMin] = useState(`${minScore !== Number.MIN_VALUE ? minScore : ''}`); const [max, setMax] = 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 (_jsxs(Dialog, { open: true, onClose: handleClose, title: "Set min/max score for track", children: [_jsxs(DialogContent, { children: [_jsx(Typography, { children: "Enter min/max score: " }), !ok ? (_jsx(Typography, { color: "error", children: "Max is greater than or equal to min" })) : null, !logOk ? (_jsx(Typography, { color: "error", children: "Min score should be greater than 0 for log scale" })) : null, _jsx(TextField, { value: min, onChange: event => { setMin(event.target.value); }, placeholder: "Enter min score" }), _jsx(TextField, { value: max, onChange: event => { setMax(event.target.value); }, placeholder: "Enter max score" })] }), _jsx(DialogActions, { children: _jsx(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" }) })] })); }