UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

106 lines (105 loc) 5.16 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef, lazy, useState } from 'react'; import MoreVert from '@mui/icons-material/MoreVert'; import Settings from '@mui/icons-material/Settings'; import { observer } from 'mobx-react'; import CascadingMenuButton from "../../../ui/CascadingMenuButton.js"; const SequenceFeatureSettingsDialog = lazy(() => import("./SettingsDialog.js")); const SequenceFeatureMenu = observer(forwardRef(function SequenceFeatureMenu2({ model, extraItems = [] }, ref) { if (typeof ref === 'function') { throw new Error('needs a non function ref'); } const [showSettings, setShowSettings] = useState(false); const { showCoordinatesSetting, showGenomicCoordsOption } = model; return (_jsxs(_Fragment, { children: [_jsx(CascadingMenuButton, { menuItems: [ { label: 'Copy plaintext', onClick: async () => { const { default: copy } = await import('copy-to-clipboard'); const r = ref?.current; if (r) { copy(r.textContent || '', { format: 'text/plain' }); } }, }, { label: 'Copy HTML', onClick: async () => { const { default: copy } = await import('copy-to-clipboard'); const r = ref?.current; if (r) { copy(r.outerHTML, { format: 'text/html' }); } }, }, { label: 'Download plaintext', onClick: async () => { const { saveAs } = await import('file-saver-es'); const r = ref?.current; if (r) { saveAs(new Blob([r.textContent || ''], { type: 'text/plain;charset=utf-8', }), 'sequence.txt'); } }, }, { label: 'Download HTML', onClick: async () => { const { saveAs } = await import('file-saver-es'); const r = ref?.current; if (r) { saveAs(new Blob([r.outerHTML || ''], { type: 'text/html;charset=utf-8', }), 'sequence.html'); } }, }, ...extraItems, { label: 'Show coordinates?', type: 'subMenu', subMenu: [ { label: 'No coordinates', type: 'radio', checked: showCoordinatesSetting === 'none', onClick: () => { model.setShowCoordinates('none'); }, }, { label: 'Coordinates relative to feature start', type: 'radio', checked: showCoordinatesSetting === 'relative', onClick: () => { model.setShowCoordinates('relative'); }, }, ...(showGenomicCoordsOption ? [ { label: 'Coordinates relative to genome (only available for continuous genome based sequence types)', type: 'radio', checked: showCoordinatesSetting === 'genomic', onClick: () => { model.setShowCoordinates('genomic'); }, }, ] : []), ], }, { label: 'Settings', icon: Settings, onClick: () => { setShowSettings(true); }, }, ], children: _jsx(MoreVert, {}) }), showSettings ? (_jsx(SequenceFeatureSettingsDialog, { model: model, handleClose: () => { setShowSettings(false); } })) : null] })); })); export default SequenceFeatureMenu;