@jbrowse/plugin-variants 2.7.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/StructuralVariantChordRenderer/Chord.js +29 -10
- package/dist/StructuralVariantChordRenderer/ReactComponent.js +13 -11
- package/dist/VariantFeatureWidget/VariantSampleGrid.d.ts +2 -2
- package/dist/VariantFeatureWidget/VariantSampleGrid.js +1 -1
- package/esm/StructuralVariantChordRenderer/Chord.js +7 -8
- package/esm/StructuralVariantChordRenderer/ReactComponent.js +13 -11
- package/esm/VariantFeatureWidget/VariantSampleGrid.d.ts +2 -2
- package/esm/VariantFeatureWidget/VariantSampleGrid.js +1 -1
- package/package.json +2 -2
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const react_1 =
|
|
26
|
+
const react_1 = __importStar(require("react"));
|
|
7
27
|
const mobx_react_1 = require("mobx-react");
|
|
8
28
|
const util_1 = require("@jbrowse/core/util");
|
|
9
29
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
@@ -16,6 +36,7 @@ function bpToRadians(block, pos) {
|
|
|
16
36
|
}
|
|
17
37
|
const Chord = (0, mobx_react_1.observer)(function Chord({ feature, blocksForRefs, radius, config, bezierRadius, selected, onClick, }) {
|
|
18
38
|
var _a, _b, _c, _d, _e;
|
|
39
|
+
const [hovered, setHovered] = (0, react_1.useState)(false);
|
|
19
40
|
// find the blocks that our start and end points belong to
|
|
20
41
|
const startBlock = blocksForRefs[feature.get('refName')];
|
|
21
42
|
if (!startBlock) {
|
|
@@ -66,19 +87,17 @@ const Chord = (0, mobx_react_1.observer)(function Chord({ feature, blocksForRefs
|
|
|
66
87
|
const hoverStrokeColor = (0, configuration_1.readConfObject)(config, 'strokeColorHover', {
|
|
67
88
|
feature,
|
|
68
89
|
});
|
|
69
|
-
return (react_1.default.createElement("path", { "data-testid": `chord-${feature.id()}`, d: ['M', ...startXY, 'Q', ...controlXY, ...endXY].join(' '),
|
|
90
|
+
return (react_1.default.createElement("path", { "data-testid": `chord-${feature.id()}`, d: ['M', ...startXY, 'Q', ...controlXY, ...endXY].join(' '), stroke: hovered ? hoverStrokeColor : strokeColor, strokeWidth: hovered ? 3 : 1, onClick: evt => {
|
|
70
91
|
if (endBlock && startBlock) {
|
|
71
92
|
onClick(feature, startBlock.region, endBlock.region, evt);
|
|
72
93
|
}
|
|
73
|
-
}, onMouseOver:
|
|
94
|
+
}, onMouseOver: () => {
|
|
74
95
|
if (!selected) {
|
|
75
|
-
|
|
76
|
-
evt.currentTarget.style.strokeWidth = '3px';
|
|
96
|
+
setHovered(true);
|
|
77
97
|
}
|
|
78
|
-
}, onMouseOut:
|
|
98
|
+
}, onMouseOut: () => {
|
|
79
99
|
if (!selected) {
|
|
80
|
-
|
|
81
|
-
evt.currentTarget.style.strokeWidth = '1px';
|
|
100
|
+
setHovered(false);
|
|
82
101
|
}
|
|
83
102
|
} }));
|
|
84
103
|
}
|
|
@@ -34,18 +34,16 @@ const StructuralVariantChordsReactComponent = (0, mobx_react_1.observer)(functio
|
|
|
34
34
|
// make a map of refName -> blockDefinition
|
|
35
35
|
const blocksForRefsMemo = (0, react_1.useMemo)(() => {
|
|
36
36
|
const blocksForRefs = {};
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
for (const block of blockDefinitions) {
|
|
38
|
+
const regions = block.region.elided
|
|
39
|
+
? block.region.regions
|
|
40
|
+
: [block.region];
|
|
41
|
+
for (const region of regions) {
|
|
42
|
+
blocksForRefs[region.refName] = block;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
41
45
|
return blocksForRefs;
|
|
42
46
|
}, [blockDefinitions]);
|
|
43
|
-
const chords = [];
|
|
44
|
-
for (const feature of features.values()) {
|
|
45
|
-
const id = feature.id();
|
|
46
|
-
const selected = String(selectedFeatureId) === String(id);
|
|
47
|
-
chords.push(react_1.default.createElement(Chord_1.default, { key: id, feature: feature, config: config, radius: radius, bezierRadius: bezierRadius, blocksForRefs: blocksForRefsMemo, selected: selected, onClick: onChordClick }));
|
|
48
|
-
}
|
|
49
47
|
const trackStyleId = `chords-${typeof jest !== 'undefined' ? 'test' : displayModel.id}`;
|
|
50
48
|
return (react_1.default.createElement("g", { id: trackStyleId, "data-testid": "structuralVariantChordRenderer" },
|
|
51
49
|
react_1.default.createElement("style", {
|
|
@@ -58,6 +56,10 @@ const StructuralVariantChordsReactComponent = (0, mobx_react_1.observer)(functio
|
|
|
58
56
|
}
|
|
59
57
|
`,
|
|
60
58
|
} }),
|
|
61
|
-
|
|
59
|
+
[...features.values()].map(feature => {
|
|
60
|
+
const id = feature.id();
|
|
61
|
+
const selected = String(selectedFeatureId) === String(id);
|
|
62
|
+
return (react_1.default.createElement(Chord_1.default, { key: id, feature: feature, config: config, radius: radius, bezierRadius: bezierRadius, blocksForRefs: blocksForRefsMemo, selected: selected, onClick: onChordClick }));
|
|
63
|
+
})));
|
|
62
64
|
});
|
|
63
65
|
exports.default = StructuralVariantChordsReactComponent;
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
3
3
|
export default function VariantSamples(props: {
|
|
4
4
|
feature: SimpleFeatureSerialized;
|
|
5
|
-
descriptions
|
|
5
|
+
descriptions?: {
|
|
6
6
|
FORMAT?: Record<string, {
|
|
7
7
|
Description?: string;
|
|
8
8
|
}>;
|
|
9
|
-
};
|
|
9
|
+
} | null;
|
|
10
10
|
}): React.JSX.Element | null;
|
|
@@ -79,7 +79,7 @@ function VariantSamples(props) {
|
|
|
79
79
|
var _a, _b;
|
|
80
80
|
return ({
|
|
81
81
|
field,
|
|
82
|
-
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
82
|
+
description: (_b = (_a = descriptions === null || descriptions === void 0 ? void 0 : descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
83
83
|
width: widths[index],
|
|
84
84
|
});
|
|
85
85
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { observer } from 'mobx-react';
|
|
3
3
|
import { polarToCartesian } from '@jbrowse/core/util';
|
|
4
4
|
import { readConfObject, } from '@jbrowse/core/configuration';
|
|
@@ -11,6 +11,7 @@ function bpToRadians(block, pos) {
|
|
|
11
11
|
}
|
|
12
12
|
const Chord = observer(function Chord({ feature, blocksForRefs, radius, config, bezierRadius, selected, onClick, }) {
|
|
13
13
|
var _a, _b, _c, _d, _e;
|
|
14
|
+
const [hovered, setHovered] = useState(false);
|
|
14
15
|
// find the blocks that our start and end points belong to
|
|
15
16
|
const startBlock = blocksForRefs[feature.get('refName')];
|
|
16
17
|
if (!startBlock) {
|
|
@@ -61,19 +62,17 @@ const Chord = observer(function Chord({ feature, blocksForRefs, radius, config,
|
|
|
61
62
|
const hoverStrokeColor = readConfObject(config, 'strokeColorHover', {
|
|
62
63
|
feature,
|
|
63
64
|
});
|
|
64
|
-
return (React.createElement("path", { "data-testid": `chord-${feature.id()}`, d: ['M', ...startXY, 'Q', ...controlXY, ...endXY].join(' '),
|
|
65
|
+
return (React.createElement("path", { "data-testid": `chord-${feature.id()}`, d: ['M', ...startXY, 'Q', ...controlXY, ...endXY].join(' '), stroke: hovered ? hoverStrokeColor : strokeColor, strokeWidth: hovered ? 3 : 1, onClick: evt => {
|
|
65
66
|
if (endBlock && startBlock) {
|
|
66
67
|
onClick(feature, startBlock.region, endBlock.region, evt);
|
|
67
68
|
}
|
|
68
|
-
}, onMouseOver:
|
|
69
|
+
}, onMouseOver: () => {
|
|
69
70
|
if (!selected) {
|
|
70
|
-
|
|
71
|
-
evt.currentTarget.style.strokeWidth = '3px';
|
|
71
|
+
setHovered(true);
|
|
72
72
|
}
|
|
73
|
-
}, onMouseOut:
|
|
73
|
+
}, onMouseOut: () => {
|
|
74
74
|
if (!selected) {
|
|
75
|
-
|
|
76
|
-
evt.currentTarget.style.strokeWidth = '1px';
|
|
75
|
+
setHovered(false);
|
|
77
76
|
}
|
|
78
77
|
} }));
|
|
79
78
|
}
|
|
@@ -6,18 +6,16 @@ const StructuralVariantChordsReactComponent = observer(function ({ features, con
|
|
|
6
6
|
// make a map of refName -> blockDefinition
|
|
7
7
|
const blocksForRefsMemo = useMemo(() => {
|
|
8
8
|
const blocksForRefs = {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
for (const block of blockDefinitions) {
|
|
10
|
+
const regions = block.region.elided
|
|
11
|
+
? block.region.regions
|
|
12
|
+
: [block.region];
|
|
13
|
+
for (const region of regions) {
|
|
14
|
+
blocksForRefs[region.refName] = block;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
13
17
|
return blocksForRefs;
|
|
14
18
|
}, [blockDefinitions]);
|
|
15
|
-
const chords = [];
|
|
16
|
-
for (const feature of features.values()) {
|
|
17
|
-
const id = feature.id();
|
|
18
|
-
const selected = String(selectedFeatureId) === String(id);
|
|
19
|
-
chords.push(React.createElement(Chord, { key: id, feature: feature, config: config, radius: radius, bezierRadius: bezierRadius, blocksForRefs: blocksForRefsMemo, selected: selected, onClick: onChordClick }));
|
|
20
|
-
}
|
|
21
19
|
const trackStyleId = `chords-${typeof jest !== 'undefined' ? 'test' : displayModel.id}`;
|
|
22
20
|
return (React.createElement("g", { id: trackStyleId, "data-testid": "structuralVariantChordRenderer" },
|
|
23
21
|
React.createElement("style", {
|
|
@@ -30,6 +28,10 @@ const StructuralVariantChordsReactComponent = observer(function ({ features, con
|
|
|
30
28
|
}
|
|
31
29
|
`,
|
|
32
30
|
} }),
|
|
33
|
-
|
|
31
|
+
[...features.values()].map(feature => {
|
|
32
|
+
const id = feature.id();
|
|
33
|
+
const selected = String(selectedFeatureId) === String(id);
|
|
34
|
+
return (React.createElement(Chord, { key: id, feature: feature, config: config, radius: radius, bezierRadius: bezierRadius, blocksForRefs: blocksForRefsMemo, selected: selected, onClick: onChordClick }));
|
|
35
|
+
})));
|
|
34
36
|
});
|
|
35
37
|
export default StructuralVariantChordsReactComponent;
|
|
@@ -2,9 +2,9 @@ import React from 'react';
|
|
|
2
2
|
import { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
3
3
|
export default function VariantSamples(props: {
|
|
4
4
|
feature: SimpleFeatureSerialized;
|
|
5
|
-
descriptions
|
|
5
|
+
descriptions?: {
|
|
6
6
|
FORMAT?: Record<string, {
|
|
7
7
|
Description?: string;
|
|
8
8
|
}>;
|
|
9
|
-
};
|
|
9
|
+
} | null;
|
|
10
10
|
}): React.JSX.Element | null;
|
|
@@ -51,7 +51,7 @@ export default function VariantSamples(props) {
|
|
|
51
51
|
var _a, _b;
|
|
52
52
|
return ({
|
|
53
53
|
field,
|
|
54
|
-
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
54
|
+
description: (_b = (_a = descriptions === null || descriptions === void 0 ? void 0 : descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
55
55
|
width: widths[index],
|
|
56
56
|
});
|
|
57
57
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"distModule": "esm/index.js",
|
|
64
64
|
"srcModule": "src/index.ts",
|
|
65
65
|
"module": "esm/index.js",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ee8c2bdc8bd4f1a70b1eefda984f04a2830d9ca0"
|
|
67
67
|
}
|