taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
59 lines (58 loc) • 3.18 kB
JavaScript
import { jsx as n, jsxs as E } from "react/jsx-runtime";
import { useState as y, useEffect as k } from "react";
import { o as A, u as F, aP as L, aQ as M, m as O, a as R, aR as u, ax as T, C as j, B as w, aS as G, aT as P } from "./JBrowsePanel-uJIA-L6s.js";
import { C as V } from "./Container-CcXKrUXg.js";
import { G as B } from "./Grid-IFK_B2cC.js";
const D = A(function({ model: e, selectedAsm: a, value: r, setValue: l, setOption: c }) {
const m = F.getSession(e), { assemblyManager: d, textSearchManager: t } = m, { rankSearchResults: p } = e, o = e.searchScope(a), g = d.get(a);
return n(L, { fetchResults: (s) => M({
queryString: s,
assembly: g,
textSearchManager: t,
rankSearchResults: p,
searchScope: o
}), model: e, assemblyName: a, value: r, minWidth: 270, onChange: (s) => {
l(s);
}, onSelect: (s) => {
c(s);
}, TextFieldProps: {
variant: "outlined",
helperText: "Enter sequence name, feature name, or location"
} });
}), _ = O()((e) => ({
importFormContainer: {
padding: e.spacing(2)
},
button: {
margin: e.spacing(2)
},
container: {
padding: e.spacing(4)
}
})), $ = A(function({ model: e }) {
var a;
const { classes: r } = _(), l = F.getSession(e), { assemblyNames: c, assemblyManager: m } = l, { error: d } = e, [t, p] = y(c[0]), [o, g] = y(), s = m.get(t), b = c.length ? s == null ? void 0 : s.error : "No configured assemblies", S = b || d, [i, C] = y(""), f = s == null ? void 0 : s.regions, I = !!f, N = f && ((a = f[0]) === null || a === void 0 ? void 0 : a.refName) || "";
return k(() => {
C(N);
}, [N, t]), E("div", { className: r.container, children: [S ? n(R.ErrorMessage, { error: S }) : null, n(V, { className: r.importFormContainer, children: n("form", { onSubmit: async (h) => {
var v;
if (h.preventDefault(), e.setError(void 0), i)
try {
(o == null ? void 0 : o.getDisplayString()) === i && o.hasLocation() ? await G({
option: o,
model: e,
assemblyName: t
}) : !((v = o == null ? void 0 : o.results) === null || v === void 0) && v.length ? e.setSearchResults(o.results, o.getLabel(), t) : s && await P({ input: i, assembly: s, model: e });
} catch (x) {
console.error(x), l.notify(`${x}`, "warning");
}
}, children: E(B, { container: !0, spacing: 1, justifyContent: "center", alignItems: "center", children: [n(u, { children: n(R.AssemblySelector, { onChange: (h) => {
p(h);
}, localStorageKey: "lgv", session: l, selected: t }) }), t ? b ? n(T, { style: { color: "red" } }) : I ? n(u, { children: n(D, { value: i, setValue: C, selectedAsm: t, setOption: g, model: e }) }) : n(j, { size: 20, disableShrink: !0 }) : null, n(u, { children: n(w, { type: "submit", disabled: !i, className: r.button, variant: "contained", color: "primary", children: "Open" }) }), n(u, { children: n(w, { disabled: !i, className: r.button, onClick: () => {
e.setError(void 0), e.showAllRegionsInAssembly(t);
}, variant: "contained", color: "secondary", children: "Show all regions in assembly" }) })] }) }) })] });
});
export {
$ as default
};
//# sourceMappingURL=ImportForm-DiVfOLBd.js.map