UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

141 lines (140 loc) 7.53 kB
import { jsxs as l, Fragment as p, jsx as e } from "react/jsx-runtime"; import { useState as r } from "react"; import { o as m, D as v, c as F, d as C, B as y, a as d, bo as N, m as U, aV as j, U as E, a4 as z, s as A, bp as M } from "./JBrowsePanel-BNE3gNW1.js"; import { M as O } from "./MenuItem-DAMdxuDJ.js"; import { D as H } from "./DataGridFlexContainer-fD_l1wuy.js"; import { D as G } from "./Delete-CRntlDho.js"; import { D as $ } from "./DataGrid-cokHFdGI.js"; const q = m(function({ adapterSelection: n, setAdapterSelection: i, adapterTypes: o }) { return e(F, { value: n, variant: "outlined", select: !0, helperText: "Type of adapter to use", fullWidth: !0, onChange: (t) => { i(t.target.value); }, children: o.map((t) => e(O, { value: t, children: t }, t)) }); }), P = m(function({ fastaLocation: n, setFastaLocation: i }) { return l(p, { children: [e(N, { severity: "warning", style: { margin: 30 }, children: "Note: use only relatively small files for this type, it is loaded into memory" }), e("div", { children: e(d.FileSelector, { inline: !0, name: "fastaLocation", location: n, setLocation: (o) => { i(o); } }) })] }); }), V = m(function({ fastaLocation: n, faiLocation: i, setFaiLocation: o, setFastaLocation: t }) { return l(p, { children: [e("div", { children: e(d.FileSelector, { inline: !0, name: "fastaLocation", location: n, setLocation: (a) => { t(a); } }) }), e("div", { children: e(d.FileSelector, { inline: !0, name: "faiLocation", location: i, setLocation: (a) => { o(a); } }) })] }); }), R = m(function({ fastaLocation: n, faiLocation: i, gziLocation: o, setFaiLocation: t, setGziLocation: a, setFastaLocation: c }) { return l(p, { children: [e("div", { children: e(d.FileSelector, { inline: !0, name: "fastaLocation", location: n, setLocation: (s) => { c(s); } }) }), e("div", { children: e(d.FileSelector, { inline: !0, name: "faiLocation", location: i, setLocation: (s) => { t(s); } }) }), e("div", { children: e(d.FileSelector, { inline: !0, name: "gziLocation", location: o, setLocation: (s) => { a(s); } }) })] }); }), W = m(function({ twoBitLocation: n, chromSizesLocation: i, setTwoBitLocation: o, setChromSizesLocation: t }) { return l(p, { children: [e("div", { children: e(d.FileSelector, { inline: !0, name: "twoBitLocation", location: n, setLocation: (a) => { o(a); } }) }), e("div", { children: e(d.FileSelector, { inline: !0, name: "chromSizesLocation (optional, can be added to speed up loading 2bit files with many contigs)", location: i, setLocation: (a) => { t(a); } }) })] }); }), f = { uri: "" }, B = [ "IndexedFastaAdapter", "BgzipFastaAdapter", "UnindexedFastaAdapter", "TwoBitAdapter" ], J = m(function({ session: n, onClose: i }) { const [o, t] = r(""), [a, c] = r(""), [s, h] = r(B[0]), [u, L] = r(f), [b, S] = r(f), [x, T] = r(f), [I, k] = r(f), [w, D] = r(f); return l(p, { children: [l(v, { children: [e(F, { id: "assembly-name", label: "Assembly name", helperText: "The assembly name e.g. hg38", variant: "outlined", value: o, onChange: (g) => { t(g.target.value); }, slotProps: { htmlInput: { "data-testid": "assembly-name" } } }), e(F, { id: "assembly-name", label: "Assembly display name", helperText: '(optional) A human readable display name for the assembly e.g. "Homo sapiens (hg38)"', variant: "outlined", value: a, onChange: (g) => { c(g.target.value); }, slotProps: { htmlInput: { "data-testid": "assembly-display-name" } } }), e(q, { adapterSelection: s, adapterTypes: B, setAdapterSelection: h }), s === "IndexedFastaAdapter" ? e(V, { fastaLocation: u, faiLocation: b, setFaiLocation: S, setFastaLocation: L }) : s === "UnindexedFastaAdapter" ? e(P, { fastaLocation: u, setFastaLocation: L }) : s === "TwoBitAdapter" ? e(W, { twoBitLocation: I, chromSizesLocation: w, setTwoBitLocation: k, setChromSizesLocation: D }) : e(R, { fastaLocation: u, gziLocation: x, faiLocation: b, setFaiLocation: S, setGziLocation: T, setFastaLocation: L })] }), l(C, { children: [e(y, { variant: "contained", color: "primary", onClick: () => { o === "" ? n.notify("Can't create an assembly without a name") : (i(), n.addAssembly({ name: o, displayName: a, sequence: { type: "ReferenceSequenceTrack", trackId: `${o}-${performance.now()}`, adapter: s === "IndexedFastaAdapter" ? { type: "IndexedFastaAdapter", fastaLocation: u, faiLocation: b } : s === "BgzipFastaAdapter" ? { type: "BgzipFastaAdapter", fastaLocation: u, faiLocation: b, gziLocation: x } : s === "UnindexedFastaAdapter" ? { type: "UnindexedFastaAdapter", fastaLocation: u } : { type: "TwoBitAdapter", twoBitLocation: I, chromSizesLocation: w } } }), n.notify(`Added "${o}"`, "success")); }, children: "Submit" }), e(y, { variant: "contained", color: "secondary", onClick: () => { i(); }, children: "Cancel" })] })] }); }), K = U()({ container: { overflow: "auto", maxHeight: 600 } }), Q = m(function({ assembly: n, onClose: i }) { const { classes: o } = K(); return l(p, { children: [e(v, { children: e("div", { className: o.container, children: n ? e(j, { model: { target: n } }) : e("div", { children: "No assembly" }) }) }), e(C, { children: e(y, { variant: "contained", onClick: () => { i(); }, children: "Back" }) })] }); }), X = E(/* @__PURE__ */ e("path", { d: "M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z" }), "Create"), Y = m(function({ onEditAssembly: n, onAddAssembly: i, onClose: o, session: t }) { return l(p, { children: [e(v, { children: e(H, { children: e($, { rowHeight: 25, columnHeaderHeight: 35, hideFooter: t.assemblies.length < 25, rows: t.assemblies.map((a) => ({ id: A.readConfObject(a, "name"), name: A.readConfObject(a, "name"), displayName: A.readConfObject(a, "displayName"), aliases: A.readConfObject(a, "aliases"), assembly: a })), columns: [ { field: "name" }, { field: "displayName" }, { field: "aliases" }, { field: "actions", renderCell: ({ row: a }) => { const { assembly: c, name: s } = a, h = t.sessionAssemblies.includes(c) ? !0 : t.adminMode; return l(p, { children: [e(z, { disabled: !h, onClick: () => { n(c); }, children: e(X, {}) }), e(z, { "data-testid": `${s}-delete`, disabled: !h, onClick: () => { h && (t.removeAssembly ? t.removeAssembly(s) : t.notify("Unable to find removeAssembly function")); }, children: e(G, {}) })] }); } } ] }) }) }), l(C, { children: [e(y, { color: "secondary", variant: "contained", onClick: () => { o(); }, children: "Close" }), e(y, { variant: "contained", startIcon: e(M, {}), onClick: () => { i(); }, children: "Add new assembly" })] })] }); }), ie = m(function({ session: n, onClose: i }) { const [o, t] = r(!1), [a, c] = r(); return e(d.Dialog, { open: !0, title: "Assembly manager", onClose: () => { i(); }, children: a ? e(Q, { assembly: a, onClose: () => { c(void 0); } }) : o ? e(J, { session: n, onClose: () => { t(!1); } }) : e(Y, { session: n, onClose: () => { i(); }, onAddAssembly: () => { t(!0); }, onEditAssembly: (s) => { c(s); } }) }); }); export { ie as default }; //# sourceMappingURL=index-BwsTbrGS.js.map