UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

142 lines (141 loc) 6.99 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const react_1 = require("react"); const MoreVert_1 = __importDefault(require("@mui/icons-material/MoreVert")); const Settings_1 = __importDefault(require("@mui/icons-material/Settings")); const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard")); const file_saver_1 = require("file-saver"); const mobx_react_1 = require("mobx-react"); const CascadingMenuButton_1 = __importDefault(require("../../../ui/CascadingMenuButton")); const SequenceFeatureSettingsDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./SettingsDialog')))); const SequenceFeatureMenu = (0, mobx_react_1.observer)((0, react_1.forwardRef)(function SequenceFeatureMenu2({ model, extraItems = [] }, ref) { if (typeof ref === 'function') { throw new Error('needs a non function ref'); } const [showSettings, setShowSettings] = (0, react_1.useState)(false); const { showCoordinatesSetting, showGenomicCoordsOption } = model; return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(CascadingMenuButton_1.default, { menuItems: [ { label: 'Copy plaintext', onClick: () => { const r = ref === null || ref === void 0 ? void 0 : ref.current; if (r) { (0, copy_to_clipboard_1.default)(r.textContent || '', { format: 'text/plain' }); } }, }, { label: 'Copy HTML', onClick: () => { const r = ref === null || ref === void 0 ? void 0 : ref.current; if (r) { (0, copy_to_clipboard_1.default)(r.outerHTML, { format: 'text/html' }); } }, }, { label: 'Download plaintext', onClick: () => { const r = ref === null || ref === void 0 ? void 0 : ref.current; if (r) { (0, file_saver_1.saveAs)(new Blob([r.textContent || ''], { type: 'text/plain;charset=utf-8', }), 'sequence.txt'); } }, }, { label: 'Download HTML', onClick: () => { const r = ref === null || ref === void 0 ? void 0 : ref.current; if (r) { (0, file_saver_1.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_1.default, onClick: () => { setShowSettings(true); }, }, ], children: (0, jsx_runtime_1.jsx)(MoreVert_1.default, {}) }), showSettings ? ((0, jsx_runtime_1.jsx)(SequenceFeatureSettingsDialog, { model: model, handleClose: () => { setShowSettings(false); } })) : null] })); })); exports.default = SequenceFeatureMenu;