UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

118 lines (117 loc) 4.83 kB
import { jsxs as r, jsx as t, Fragment as F } from "react/jsx-runtime"; import { useState as c, useEffect as G } from "react"; import { o as N, u as p, f as j, a as m, D as q, T as L, c as T, d as M, B as C, e as V, h as z, n as I, p as w } from "./JBrowsePanel-uJIA-L6s.js"; import { M as A } from "./MenuItem-D4Mw907e.js"; const U = N(function(P) { const { model: l, handleClose: y } = P, [e, S] = c(""), [o, b] = c(), [x, D] = c(!1), [k, v] = c(), B = /^[A-Za-z][A-Za-z0-9]$/.exec(e), d = e.length === 2 && !B, $ = p.useDebounce(e, 1e3), [g, E] = c(""); return G(() => { (async () => { try { if (!d) { v(void 0), D(!0); const a = await j({ self: l, tag: $, blocks: p.getContainingView(l).staticBlocks }); b(a); } } catch (a) { console.error(a), v(a); } finally { D(!1); } })(); }, [l, d, $]), r(m.Dialog, { open: !0, onClose: y, title: "Group by", children: [r(q, { children: [t(L, { children: 'NOTE: this will create new session tracks with the "filter by" set to the values chosen here rather than affecting the current track state' }), r(T, { fullWidth: !0, value: g, onChange: (a) => { E(a.target.value); }, label: "Group by...", select: !0, children: [t(A, { value: "strand", children: "Strand" }), t(A, { value: "tag", children: "Tag" })] }), g === "tag" ? r(F, { children: [t(L, { color: "textSecondary", children: "Examples: HP for haplotype, RG for read group, etc." }), t(T, { value: e, onChange: (a) => { S(a.target.value); }, placeholder: "Enter tag name", error: d, helperText: d ? "Not a valid tag" : "", autoComplete: "off", "data-testid": "group-tag-name", slotProps: { htmlInput: { maxLength: 2, "data-testid": "group-tag-name-input" } } }), k ? t(m.ErrorMessage, { error: k }) : x ? t(m.LoadingEllipses, { title: "Loading unique tags" }) : o ? r("div", { children: [r("div", { children: ["Found unique ", e, " values:"] }), t("div", { children: o.join(", ") })] }) : null] }) : null] }), r(M, { children: [t(C, { variant: "contained", color: "primary", type: "submit", disabled: !o, autoFocus: !0, onClick: () => { const a = p.getContainingTrack(l), n = structuredClone(V(a.configuration)), f = p.getSession(l), h = p.getContainingView(l); if (g === "tag") { if (o) { const s = [...o, void 0]; for (const i of s) { const u = `${n.trackId}-${e}:${i}-${+Date.now()}-sessionTrack`; f.addTrackConf({ ...n, trackId: u, name: `${n.name} (${e}:${i})`, displays: [ { displayId: `${u}-LinearAlignmentsDisplay`, type: "LinearAlignmentsDisplay", pileupDisplay: { displayId: `${u}-LinearAlignmentsDisplay-LinearPileupDisplay`, type: "LinearPileupDisplay", filterBy: { ...z, tagFilter: { tag: e, value: i } } } } ] }), h.showTrack(u); } } } else if (g === "strand") { const s = `${n.trackId}-${e}:(-)-${+Date.now()}-sessionTrack`, i = `${n.trackId}-${e}:(+)-${+Date.now()}-sessionTrack`; f.addTrackConf({ ...n, trackId: s, name: `${n.name} (-)`, displays: [ { displayId: `${s}-LinearAlignmentsDisplay`, type: "LinearAlignmentsDisplay", pileupDisplay: { displayId: `${s}-LinearAlignmentsDisplay-LinearPileupDisplay`, type: "LinearPileupDisplay", filterBy: I } }, { displayId: `${s}-LinearSNPCoverageDisplay`, type: "LinearSNPCoverageDisplay", filterBy: I } ] }), f.addTrackConf({ ...n, trackId: i, name: `${n.name} (+)`, displays: [ { displayId: `${i}-LinearAlignmentsDisplay`, type: "LinearAlignmentsDisplay", pileupDisplay: { displayId: `${i}-LinearAlignmentsDisplay-LinearPileupDisplay`, type: "LinearPileupDisplay", filterBy: w } }, { displayId: `${i}-LinearSNPCoverageDisplay`, type: "LinearSNPCoverageDisplay", filterBy: w } ] }), h.showTrack(s), h.showTrack(i); } y(); }, children: "Submit" }), t(C, { variant: "contained", color: "secondary", onClick: () => { y(); }, children: "Cancel" })] })] }); }); export { U as default }; //# sourceMappingURL=GroupByDialog-DRwW8kCB.js.map