UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

40 lines (39 loc) 3.32 kB
import { jsx as o, jsxs as f, Fragment as x } from "react/jsx-runtime"; import { u, o as d, Y as y } from "./JBrowsePanel-uJIA-L6s.js"; import { g as W } from "./util-BUvuuJah.js"; const S = (t) => { const { color: e = "rgb(255,255,255,0.8)" } = t; return o("rect", { ...t, ...u.getFillProps(e) }); }, $ = function({ source: t, idx: e, rowHeight: n, labelWidth: r, model: s, exportSVG: i }) { const c = Math.min(20, n), { needsCustomLegend: l, graphType: h, needsFullHeightScalebar: g, rowHeightTooSmallForScalebar: m, renderColorBoxes: b } = s, w = Math.min(n, 12), p = n > 11, a = b ? 15 : 0, F = r + a + 5, v = (i ? 10 : 0) || (h && !m ? 50 : 0); return f(x, { children: [g ? null : o(S, { y: e * n + 1, x: v, width: F, height: c }), t.color ? o(S, { y: e * n + 1, x: v, width: a, height: l ? n : c, color: t.color }) : null, p ? o("text", { y: e * n + 13, x: v + a + 2, fontSize: w, children: t.name }) : null] }); }, B = d(function({ model: t, rowHeight: e, exportSVG: n }) { const { graphType: r, needsFullHeightScalebar: s, rowHeightTooSmallForScalebar: i, renderColorBoxes: c, sources: l, labelWidth: h } = t, m = h + (c ? 15 : 0) + 5; return l ? f(x, { children: [s ? o(S, { y: 0, x: (n ? 10 : 0) || (r && !i ? 50 : 0), width: m, height: (l.length + 0.25) * e }) : null, l.map((p, a) => o($, { source: p, idx: a, model: t, rowHeight: e, exportSVG: n, labelWidth: h }, `${p.name}-${a}`))] }) : null; }), O = d(function({ model: t, orientation: e, exportSVG: n }) { const { labelWidth: r } = t, { width: s } = u.getContainingView(t); return f(x, { children: [o("g", { transform: `translate(${n ? 0 : W(t)},0)`, children: o(y, { model: t, orientation: e }) }), o("g", { transform: `translate(${s - r - 100},0)`, children: o(B, { exportSVG: n, model: t, rowHeight: 12 }) })] }); }), C = d(({ model: t }) => { const { ticks: e, scaleType: n } = t, { width: r } = u.getContainingView(t), s = `[${e == null ? void 0 : e.values[0]}-${e == null ? void 0 : e.values[1]}]${n === "log" ? " (log scale)" : ""}`, i = u.measureText(s, 14), l = r - i - 25; return f(x, { children: [o(S, { y: 0, x: l, width: i + 6, height: 16 }), o("text", { y: 13, x: l, children: s })] }); }), T = d(function({ model: t, orientation: e, exportSVG: n }) { const { sources: r, rowHeight: s, rowHeightTooSmallForScalebar: i, needsCustomLegend: c, ticks: l } = t; return r != null && r.length ? f(x, { children: [o(B, { exportSVG: n, model: t, rowHeight: t.rowHeight }), i || c ? o(C, { model: t }) : r.map((h, g) => o("g", { transform: `translate(0 ${s * g})`, children: o(y, { model: t, orientation: e }) }, `${JSON.stringify(l)}-${g}`))] }) : null; }), V = d(function({ children: t, model: e, exportSVG: n }) { const { height: r } = e; return n ? t : o("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none", height: r, width: u.getContainingView(e).width }, children: t }); }), j = d(function(t) { const { model: e, orientation: n, exportSVG: r } = t, { showSidebar: s, stats: i, needsFullHeightScalebar: c, sources: l } = e; return i && l ? o(V, { ...t, children: s ? c ? o(O, { model: e, orientation: n, exportSVG: r }) : o(T, { model: e, orientation: n, exportSVG: r }) : null }) : null; }); export { j as Y }; //# sourceMappingURL=YScaleBars-Bq0UZpom.js.map