UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

223 lines (222 loc) 9.31 kB
import { jsx as e, jsxs as u, Fragment as j } from "react/jsx-runtime"; import * as D from "react"; import { lazy as S, useState as v, useEffect as R } from "react"; import { A as F, z as B, G as $, H as z, I as O, X as h, o as f, u as g, bX as y, a7 as w, ax as W, T as m, m as C, a6 as U, aw as H, B as A, by as V, bY as _, c as q, bN as Y, a as X } from "./JBrowsePanel-uJIA-L6s.js"; import { C as G } from "./Clear-Iez73PVU.js"; import { A as b, a as x, E as I } from "./ExpandMore-DnyR9BQr.js"; import { L as J } from "./ListItem-shOX3Ebz.js"; import { C as K, a as Q } from "./CardContent-G_V1s50Q.js"; import { L as Z } from "./Link-CZ78-213.js"; import { c as ee, d as ne } from "./index-dFotuATn.js"; import d from "prop-types"; function se(n) { return F("MuiCardActions", n); } B("MuiCardActions", ["root", "spacing"]); const te = (n) => { const { classes: s, disableSpacing: a } = n; return O({ root: ["root", !a && "spacing"] }, se, s); }, oe = z("div", { name: "MuiCardActions", slot: "Root", overridesResolver: (n, s) => { const { ownerState: a } = n; return [s.root, !a.disableSpacing && s.spacing]; } })({ display: "flex", alignItems: "center", padding: 8, variants: [{ props: { disableSpacing: !1 }, style: { "& > :not(style) ~ :not(style)": { marginLeft: 8 } } }] }), E = /* @__PURE__ */ D.forwardRef(function(s, a) { const t = $({ props: s, name: "MuiCardActions" }), { disableSpacing: o = !1, className: c, ...r } = t, l = { ...t, disableSpacing: o }, i = te(l); return /* @__PURE__ */ e(oe, { className: ee(i.root, c), ownerState: l, ref: a, ...r }); }); ne.process.env.NODE_ENV !== "production" && (E.propTypes = { // ┌────────────────────────────── Warning ──────────────────────────────┐ // │ These PropTypes are generated from the TypeScript type definitions. │ // │ To update them, edit the d.ts file and run `pnpm proptypes`. │ // └─────────────────────────────────────────────────────────────────────┘ /** * The content of the component. */ children: d.node, /** * Override or extend the styles applied to the component. */ classes: d.object, /** * @ignore */ className: d.string, /** * If `true`, the actions do not have additional margin. * @default false */ disableSpacing: d.bool, /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: d.oneOfType([d.arrayOf(d.oneOfType([d.func, d.object, d.bool])), d.func, d.object]) }); const ae = h(/* @__PURE__ */ e("path", { d: "M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8" }), "InfoOutlined"), ie = h(/* @__PURE__ */ e("path", { d: "M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2m-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2m3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1s3.1 1.39 3.1 3.1z" }), "Lock"), re = S(() => import("./DeletePluginDialog-Dfk7EB60.js")), le = C()(() => ({ lockedPluginTooltip: { marginRight: "0.5rem" } })); function ce() { const { classes: n } = le(); return e(U, { className: n.lockedPluginTooltip, title: "This plugin was installed by an administrator, you cannot remove it.", children: e(ie, {}) }); } const de = f(function({ plugin: n, model: s }) { const { pluginManager: a } = g.getEnv(s), t = g.getSession(s), { jbrowse: o, adminMode: c } = t, r = y.isSessionWithSessionPlugins(t) ? t.sessionPlugins.some((l) => { var i; return ((i = a.pluginMetadata[n.name]) === null || i === void 0 ? void 0 : i.url) === l.url; }) : !1; return u(J, { children: [c || r ? e(w, { "data-testid": `removePlugin-${n.name}`, onClick: () => { t.queueDialog((l) => [ re, { plugin: n.name, onClose: (i) => { if (i) { const p = a.pluginMetadata[n.name]; c ? o.removePlugin(p) : y.isSessionWithSessionPlugins(t) && t.removeSessionPlugin(p); } l(); } } ]); }, children: e(W, {}) }) : e(ce, {}), e(m, { children: n.name })] }, n.name); }), ue = f(function({ pluginManager: s, model: a }) { const { plugins: t } = s, { filterText: o } = a, c = t.filter((r) => { var l; return !(!((l = s.pluginMetadata[r.name]) === null || l === void 0) && l.isCore); }); return e(H, { children: c.length > 0 ? c.filter((r) => r.name.toLowerCase().includes(o.toLowerCase())).map((r) => e(de, { plugin: r, model: a }, r.name)) : e(m, { children: "No plugins currently installed" }) }); }), me = h(/* @__PURE__ */ e("path", { d: "M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }), "Check"), ge = h(/* @__PURE__ */ e("path", { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4m0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4" }), "Person"), pe = C()({ card: { margin: "0.5em" }, icon: { marginLeft: "0.5em", marginRight: "0.5em" }, bold: { fontWeight: 600 }, dataField: { display: "flex", alignItems: "center" }, mr: { marginRight: "0.5em" } }), he = f(function({ plugin: s, model: a }) { const { classes: t } = pe(), o = g.getSession(a), { pluginManager: c } = g.getEnv(a), { runtimePluginDefinitions: r } = c, l = r.some((P) => "url" in P && P.url === s.url), [i, p] = v(!1), { adminMode: M, jbrowse: N } = o, { name: T, authors: L, description: k } = s; return u(K, { variant: "outlined", className: t.card, children: [u(Q, { children: [e(m, { variant: "h5", children: e(Z, { href: `${s.location}#readme`, target: "_blank", rel: "noopener", children: s.name }) }), u("div", { className: t.dataField, children: [e(ge, { className: t.mr }), e(m, { children: L.join(", ") })] }), e(m, { className: t.bold, children: "Description:" }), e(m, { children: k })] }), e(E, { children: e(A, { variant: "contained", disabled: l || i, startIcon: l ? e(me, {}) : e(V, {}), onClick: () => { M ? N.addPlugin(s) : y.isSessionWithSessionPlugins(o) ? o.addSessionPlugin(s) : o.notify("No way to install plugin"), p(!0); }, children: l ? "Installed" : "Install" }) })] }, T); }); function fe() { const [n, s] = v(), [a, t] = v(); return R(() => { (async () => { try { const o = await fetch("https://jbrowse.org/plugin-store/plugins.json"); if (!o.ok) { const r = await o.text(); throw new Error(`HTTP ${o.status} fetching plugins: ${r}`); } const c = await o.json(); s(c.plugins); } catch (o) { console.error(o), t(o); } })(); }, []), { plugins: n, error: a }; } const ve = S(() => import("./AddCustomPluginDialog-CkqFwYdd.js")), ye = C()((n) => ({ expandIcon: { color: n.palette.tertiary.contrastText }, adminBadge: { borderRadius: 3, backgroundColor: n.palette.quaternary.main, padding: "1em", display: "flex", alignContent: "center" }, customPluginButton: { margin: "1em auto", display: "flex" }, mr: { marginRight: "0.3em" }, m: { margin: "1em" } })), Ne = f(function({ model: n }) { const { classes: s } = ye(), { plugins: a, error: t } = fe(), { filterText: o } = n, c = g.getSession(n), { adminMode: r } = c, { pluginManager: l } = _(n); return u("div", { children: [r && u(j, { children: [!g.isElectron && u("div", { className: s.adminBadge, children: [e(ae, { className: s.mr }), u(m, { children: ["You are using the ", e("code", { children: "admin-server" }), ". Any changes you make will be saved to your configuration file. You also have the ability to add custom plugins that are not in the store."] })] }), e(A, { className: s.customPluginButton, variant: "contained", onClick: () => { c.queueDialog((i) => [ ve, { model: n, onClose: i } ]); }, children: "Add custom plugin" })] }), e(q, { label: "Filter plugins", value: o, onChange: (i) => { n.setFilterText(i.target.value); }, fullWidth: !0, slotProps: { input: { endAdornment: e(Y, { position: "end", children: e(w, { onClick: () => { n.clearFilterText(); }, children: e(G, {}) }) }) } } }), u(b, { defaultExpanded: !0, children: [e(x, { expandIcon: e(I, { className: s.expandIcon }), children: e(m, { variant: "h5", children: "Installed plugins" }) }), e("div", { className: s.m, children: e(ue, { pluginManager: l, model: n }) })] }), u(b, { defaultExpanded: !0, children: [e(x, { expandIcon: e(I, { className: s.expandIcon }), children: e(m, { variant: "h5", children: "Available plugins" }) }), t ? e(m, { color: "error", children: `${t}` }) : a ? a.filter((i) => !(g.isElectron && i.cjsUrl) && i.name.toLowerCase().includes(o.toLowerCase())).map((i) => e(he, { plugin: i, model: n }, i.name)) : e(X.LoadingEllipses, {})] })] }); }); export { Ne as default }; //# sourceMappingURL=PluginStoreWidget-B7HC9Wrz.js.map