@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
36 lines (35 loc) • 2.78 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tooltip = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const mobx_react_1 = require("mobx-react");
const Tooltip_1 = __importDefault(require("../../Tooltip"));
const util_1 = require("../../util");
const en = (n) => n.toLocaleString('en-US');
const TooltipContents = (0, react_1.forwardRef)(function TooltipContents2({ model, feature }, ref) {
const start = feature.get('start');
const end = feature.get('end');
const refName = feature.get('refName');
const coord = start === end ? en(start) : `${en(start)}..${en(end)}`;
const sources = feature.get('sources');
const source = feature.get('source');
const summary = feature.get('summary');
const obj = Object.fromEntries(model.sources.map(ent => [ent.name, ent]));
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, children: [[refName, coord].filter(f => !!f).join(':'), (0, jsx_runtime_1.jsx)("br", {}), sources ? ((0, jsx_runtime_1.jsxs)("table", { children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "color" }), (0, jsx_runtime_1.jsx)("th", { children: "source" }), (0, jsx_runtime_1.jsx)("th", { children: "score" })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: Object.entries(sources).map(([source, data]) => ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("div", { style: {
width: 16,
height: 16,
background: obj[source].color,
} }) }), (0, jsx_runtime_1.jsx)("td", { children: source }), (0, jsx_runtime_1.jsx)("td", { children: (0, util_1.toP)(data.score) })] }, source))) })] })) : ((0, jsx_runtime_1.jsxs)("span", { children: [source, ' ', summary
? `min:${(0, util_1.toP)(feature.get('minScore'))} avg:${(0, util_1.toP)(feature.get('score'))} max:${(0, util_1.toP)(feature.get('maxScore'))}`
: (0, util_1.toP)(feature.get('score'))] }))] }));
});
const WiggleTooltip = (0, mobx_react_1.observer)((props) => {
return (0, jsx_runtime_1.jsx)(Tooltip_1.default, { useClientY: true, TooltipContents: TooltipContents, ...props });
});
exports.default = WiggleTooltip;
var Tooltip_2 = require("../../Tooltip");
Object.defineProperty(exports, "Tooltip", { enumerable: true, get: function () { return __importDefault(Tooltip_2).default; } });