@jbrowse/plugin-variants 2.3.3 → 2.3.4
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/VariantFeatureWidget/VariantSampleGrid.d.ts +1 -1
- package/dist/VariantFeatureWidget/VariantSampleGrid.js +28 -21
- package/dist/VariantFeatureWidget/VariantSampleGrid.js.map +1 -1
- package/esm/VariantFeatureWidget/VariantSampleGrid.d.ts +1 -1
- package/esm/VariantFeatureWidget/VariantSampleGrid.js +28 -21
- package/esm/VariantFeatureWidget/VariantSampleGrid.js.map +1 -1
- package/package.json +2 -2
- package/src/VariantFeatureWidget/VariantSampleGrid.tsx +47 -36
- package/src/VariantFeatureWidget/__snapshots__/VariantFeatureWidget.test.tsx.snap +12 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SimpleFeatureSerialized } from '@jbrowse/core/util
|
|
2
|
+
import { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
3
3
|
export default function VariantSamples(props: {
|
|
4
4
|
feature: SimpleFeatureSerialized;
|
|
5
5
|
descriptions: any;
|
|
@@ -23,27 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
27
26
|
const react_1 = __importStar(require("react"));
|
|
28
27
|
const material_1 = require("@mui/material");
|
|
29
28
|
const x_data_grid_1 = require("@mui/x-data-grid");
|
|
30
29
|
const BaseFeatureDetail_1 = require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail");
|
|
30
|
+
const util_1 = require("@jbrowse/core/util");
|
|
31
|
+
const ResizeBar_1 = __importStar(require("@jbrowse/core/ui/ResizeBar"));
|
|
31
32
|
function VariantSamples(props) {
|
|
32
|
-
|
|
33
|
+
var _a;
|
|
34
|
+
const { feature, descriptions = {} } = props;
|
|
35
|
+
const { ref, scrollLeft } = (0, ResizeBar_1.useResizeBar)();
|
|
33
36
|
const [filter, setFilter] = (0, react_1.useState)({});
|
|
34
37
|
const [showFilters, setShowFilters] = (0, react_1.useState)(false);
|
|
35
|
-
const
|
|
38
|
+
const samples = (feature.samples || {});
|
|
36
39
|
const preFilteredRows = Object.entries(samples);
|
|
37
|
-
if (!preFilteredRows.length) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const infoFields = ['sample', ...Object.keys(preFilteredRows[0][1])].map(field => {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
return ({
|
|
43
|
-
field,
|
|
44
|
-
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
40
|
let error;
|
|
48
41
|
let rows = [];
|
|
49
42
|
const filters = Object.keys(filter);
|
|
@@ -52,11 +45,13 @@ function VariantSamples(props) {
|
|
|
52
45
|
// sortable by the data-grid
|
|
53
46
|
try {
|
|
54
47
|
rows = preFilteredRows
|
|
55
|
-
.map(row =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
.map(row => {
|
|
49
|
+
return {
|
|
50
|
+
...Object.fromEntries(Object.entries(row[1]).map(e => [e[0], `${e[1]}`])),
|
|
51
|
+
sample: row[0],
|
|
52
|
+
id: row[0],
|
|
53
|
+
};
|
|
54
|
+
})
|
|
60
55
|
.filter(row => filters.length
|
|
61
56
|
? filters.every(key => {
|
|
62
57
|
const val = row[key];
|
|
@@ -68,16 +63,28 @@ function VariantSamples(props) {
|
|
|
68
63
|
catch (e) {
|
|
69
64
|
error = e;
|
|
70
65
|
}
|
|
66
|
+
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
67
|
+
const [widths, setWidths] = (0, react_1.useState)(keys.map(e => (0, util_1.measureGridWidth)(rows.map(r => r[e]))));
|
|
68
|
+
const infoFields = keys.map((field, index) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return ({
|
|
71
|
+
field,
|
|
72
|
+
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
73
|
+
width: widths[index],
|
|
74
|
+
});
|
|
75
|
+
});
|
|
71
76
|
// disableSelectionOnClick helps avoid
|
|
72
77
|
// https://github.com/mui-org/material-ui-x/issues/1197
|
|
73
|
-
return (react_1.default.createElement(BaseFeatureDetail_1.BaseCard, { ...props, title: "Samples" },
|
|
78
|
+
return !preFilteredRows.length ? null : (react_1.default.createElement(BaseFeatureDetail_1.BaseCard, { ...props, title: "Samples" },
|
|
74
79
|
error ? react_1.default.createElement(material_1.Typography, { color: "error" }, `${error}`) : null,
|
|
75
80
|
react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Checkbox, { checked: showFilters, onChange: () => setShowFilters(f => !f) }), label: "Show sample filters" }),
|
|
76
81
|
showFilters ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
77
82
|
react_1.default.createElement(material_1.Typography, null, "These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"),
|
|
78
83
|
infoFields.map(({ field }) => (react_1.default.createElement(material_1.TextField, { key: `filter-${field}`, placeholder: `Filter ${field}`, value: filter[field] || '', onChange: event => setFilter({ ...filter, [field]: event.target.value }) }))))) : null,
|
|
79
|
-
react_1.default.createElement("div", {
|
|
80
|
-
react_1.default.createElement(
|
|
84
|
+
react_1.default.createElement("div", { ref: ref },
|
|
85
|
+
react_1.default.createElement(ResizeBar_1.default, { widths: widths, setWidths: setWidths, scrollLeft: scrollLeft }),
|
|
86
|
+
react_1.default.createElement("div", { ref: ref, style: { height: 600, width: '100%', overflow: 'auto' } },
|
|
87
|
+
react_1.default.createElement(x_data_grid_1.DataGrid, { rows: rows, columns: infoFields, disableSelectionOnClick: true, rowHeight: 25, headerHeight: 35, disableColumnMenu: true })))));
|
|
81
88
|
}
|
|
82
89
|
exports.default = VariantSamples;
|
|
83
90
|
//# sourceMappingURL=VariantSampleGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AAEvC,4CAKsB;AAEtB,kDAA2C;AAC3C,yFAA4E;AAC5E,6CAA8E;AAC9E,wEAAoE;AAWpE,SAAwB,cAAc,CAAC,KAItC;;IACC,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,KAAK,CAAA;IAC5C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAA,wBAAY,GAAE,CAAA;IAC1C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAU,EAAE,CAAC,CAAA;IACjD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAA;IACrD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA+B,CAAA;IACrE,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/C,IAAI,KAAK,CAAA;IACT,IAAI,IAAI,GAAG,EAAa,CAAA;IACxB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEnC,qCAA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AE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAEvD,CACH,CAAC,CACD,CACJ,CAAC,CAAC,CAAC,IAAI;QACR,uCAAK,GAAG,EAAE,GAAG;YACX,8BAAC,mBAAS,IACR,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GACtB;YACF,uCAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;gBACpE,8BAAC,sBAAQ,IACP,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,UAAU,EACnB,uBAAuB,QACvB,SAAS,EAAE,EAAE,EACb,YAAY,EAAE,EAAE,EAChB,iBAAiB,SACjB,CACE,CACF,CACG,CACZ,CAAA;AACH,CAAC;AA5GD,iCA4GC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SimpleFeatureSerialized } from '@jbrowse/core/util
|
|
2
|
+
import { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
3
3
|
export default function VariantSamples(props: {
|
|
4
4
|
feature: SimpleFeatureSerialized;
|
|
5
5
|
descriptions: any;
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import React, { useState } from 'react';
|
|
3
2
|
import { FormControlLabel, Checkbox, TextField, Typography, } from '@mui/material';
|
|
4
3
|
import { DataGrid } from '@mui/x-data-grid';
|
|
5
4
|
import { BaseCard } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
|
|
5
|
+
import { measureGridWidth } from '@jbrowse/core/util';
|
|
6
|
+
import ResizeBar, { useResizeBar } from '@jbrowse/core/ui/ResizeBar';
|
|
6
7
|
export default function VariantSamples(props) {
|
|
7
|
-
|
|
8
|
+
var _a;
|
|
9
|
+
const { feature, descriptions = {} } = props;
|
|
10
|
+
const { ref, scrollLeft } = useResizeBar();
|
|
8
11
|
const [filter, setFilter] = useState({});
|
|
9
12
|
const [showFilters, setShowFilters] = useState(false);
|
|
10
|
-
const
|
|
13
|
+
const samples = (feature.samples || {});
|
|
11
14
|
const preFilteredRows = Object.entries(samples);
|
|
12
|
-
if (!preFilteredRows.length) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const infoFields = ['sample', ...Object.keys(preFilteredRows[0][1])].map(field => {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
return ({
|
|
18
|
-
field,
|
|
19
|
-
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
15
|
let error;
|
|
23
16
|
let rows = [];
|
|
24
17
|
const filters = Object.keys(filter);
|
|
@@ -27,11 +20,13 @@ export default function VariantSamples(props) {
|
|
|
27
20
|
// sortable by the data-grid
|
|
28
21
|
try {
|
|
29
22
|
rows = preFilteredRows
|
|
30
|
-
.map(row =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
.map(row => {
|
|
24
|
+
return {
|
|
25
|
+
...Object.fromEntries(Object.entries(row[1]).map(e => [e[0], `${e[1]}`])),
|
|
26
|
+
sample: row[0],
|
|
27
|
+
id: row[0],
|
|
28
|
+
};
|
|
29
|
+
})
|
|
35
30
|
.filter(row => filters.length
|
|
36
31
|
? filters.every(key => {
|
|
37
32
|
const val = row[key];
|
|
@@ -43,15 +38,27 @@ export default function VariantSamples(props) {
|
|
|
43
38
|
catch (e) {
|
|
44
39
|
error = e;
|
|
45
40
|
}
|
|
41
|
+
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
42
|
+
const [widths, setWidths] = useState(keys.map(e => measureGridWidth(rows.map(r => r[e]))));
|
|
43
|
+
const infoFields = keys.map((field, index) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return ({
|
|
46
|
+
field,
|
|
47
|
+
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
48
|
+
width: widths[index],
|
|
49
|
+
});
|
|
50
|
+
});
|
|
46
51
|
// disableSelectionOnClick helps avoid
|
|
47
52
|
// https://github.com/mui-org/material-ui-x/issues/1197
|
|
48
|
-
return (React.createElement(BaseCard, { ...props, title: "Samples" },
|
|
53
|
+
return !preFilteredRows.length ? null : (React.createElement(BaseCard, { ...props, title: "Samples" },
|
|
49
54
|
error ? React.createElement(Typography, { color: "error" }, `${error}`) : null,
|
|
50
55
|
React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { checked: showFilters, onChange: () => setShowFilters(f => !f) }), label: "Show sample filters" }),
|
|
51
56
|
showFilters ? (React.createElement(React.Fragment, null,
|
|
52
57
|
React.createElement(Typography, null, "These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"),
|
|
53
58
|
infoFields.map(({ field }) => (React.createElement(TextField, { key: `filter-${field}`, placeholder: `Filter ${field}`, value: filter[field] || '', onChange: event => setFilter({ ...filter, [field]: event.target.value }) }))))) : null,
|
|
54
|
-
React.createElement("div", {
|
|
55
|
-
React.createElement(
|
|
59
|
+
React.createElement("div", { ref: ref },
|
|
60
|
+
React.createElement(ResizeBar, { widths: widths, setWidths: setWidths, scrollLeft: scrollLeft }),
|
|
61
|
+
React.createElement("div", { ref: ref, style: { height: 600, width: '100%', overflow: 'auto' } },
|
|
62
|
+
React.createElement(DataGrid, { rows: rows, columns: infoFields, disableSelectionOnClick: true, rowHeight: 25, headerHeight: 35, disableColumnMenu: true })))));
|
|
56
63
|
}
|
|
57
64
|
//# sourceMappingURL=VariantSampleGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAA2B,MAAM,oBAAoB,CAAA;AAC9E,OAAO,SAAS,EAAE,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAWpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAItC;;IACC,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,KAAK,CAAA;IAC5C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,YAAY,EAAE,CAAA;IAC1C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAU,EAAE,CAAC,CAAA;IACjD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACrD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA+B,CAAA;IACrE,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAE/C,IAAI,KAAK,CAAA;IACT,IAAI,IAAI,GAAG,EAAa,CAAA;IACxB,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEnC,qC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AAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAEvD,CACH,CAAC,CACD,CACJ,CAAC,CAAC,CAAC,IAAI;QACR,6BAAK,GAAG,EAAE,GAAG;YACX,oBAAC,SAAS,IACR,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GACtB;YACF,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;gBACpE,oBAAC,QAAQ,IACP,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,UAAU,EACnB,uBAAuB,QACvB,SAAS,EAAE,EAAE,EACb,YAAY,EAAE,EAAE,EAChB,iBAAiB,SACjB,CACE,CACF,CACG,CACZ,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"distModule": "esm/index.js",
|
|
65
65
|
"srcModule": "src/index.ts",
|
|
66
66
|
"module": "esm/index.js",
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "98ae48be91ee2371e1b2768a907b4997995e9915"
|
|
68
68
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import React, { useState } from 'react'
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -10,7 +9,8 @@ import {
|
|
|
10
9
|
|
|
11
10
|
import { DataGrid } from '@mui/x-data-grid'
|
|
12
11
|
import { BaseCard } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail'
|
|
13
|
-
import { SimpleFeatureSerialized } from '@jbrowse/core/util
|
|
12
|
+
import { measureGridWidth, SimpleFeatureSerialized } from '@jbrowse/core/util'
|
|
13
|
+
import ResizeBar, { useResizeBar } from '@jbrowse/core/ui/ResizeBar'
|
|
14
14
|
|
|
15
15
|
interface Entry {
|
|
16
16
|
sample: string
|
|
@@ -18,28 +18,20 @@ interface Entry {
|
|
|
18
18
|
[key: string]: string
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
type InfoFields = Record<string, unknown>
|
|
22
|
+
type Filters = Record<string, string>
|
|
23
|
+
|
|
21
24
|
export default function VariantSamples(props: {
|
|
22
25
|
feature: SimpleFeatureSerialized
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
27
|
descriptions: any
|
|
24
28
|
}) {
|
|
25
|
-
const { feature, descriptions } = props
|
|
26
|
-
const
|
|
29
|
+
const { feature, descriptions = {} } = props
|
|
30
|
+
const { ref, scrollLeft } = useResizeBar()
|
|
31
|
+
const [filter, setFilter] = useState<Filters>({})
|
|
27
32
|
const [showFilters, setShowFilters] = useState(false)
|
|
28
|
-
const
|
|
29
|
-
string,
|
|
30
|
-
Record<string, Record<string, unknown>>
|
|
31
|
-
>
|
|
33
|
+
const samples = (feature.samples || {}) as Record<string, InfoFields>
|
|
32
34
|
const preFilteredRows = Object.entries(samples)
|
|
33
|
-
if (!preFilteredRows.length) {
|
|
34
|
-
return null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const infoFields = ['sample', ...Object.keys(preFilteredRows[0][1])].map(
|
|
38
|
-
field => ({
|
|
39
|
-
field,
|
|
40
|
-
description: descriptions.FORMAT?.[field]?.Description,
|
|
41
|
-
}),
|
|
42
|
-
)
|
|
43
35
|
|
|
44
36
|
let error
|
|
45
37
|
let rows = [] as Entry[]
|
|
@@ -50,16 +42,15 @@ export default function VariantSamples(props: {
|
|
|
50
42
|
// sortable by the data-grid
|
|
51
43
|
try {
|
|
52
44
|
rows = preFilteredRows
|
|
53
|
-
.map(
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
45
|
+
.map(row => {
|
|
46
|
+
return {
|
|
47
|
+
...Object.fromEntries(
|
|
48
|
+
Object.entries(row[1]).map(e => [e[0], `${e[1]}`]),
|
|
49
|
+
),
|
|
50
|
+
sample: row[0],
|
|
51
|
+
id: row[0],
|
|
52
|
+
} as Entry
|
|
53
|
+
})
|
|
63
54
|
.filter(row =>
|
|
64
55
|
filters.length
|
|
65
56
|
? filters.every(key => {
|
|
@@ -72,9 +63,21 @@ export default function VariantSamples(props: {
|
|
|
72
63
|
} catch (e) {
|
|
73
64
|
error = e
|
|
74
65
|
}
|
|
66
|
+
|
|
67
|
+
const keys = ['sample', ...Object.keys(preFilteredRows[0]?.[1] || {})]
|
|
68
|
+
|
|
69
|
+
const [widths, setWidths] = useState(
|
|
70
|
+
keys.map(e => measureGridWidth(rows.map(r => r[e]))),
|
|
71
|
+
)
|
|
72
|
+
const infoFields = keys.map((field, index) => ({
|
|
73
|
+
field,
|
|
74
|
+
description: descriptions.FORMAT?.[field]?.Description,
|
|
75
|
+
width: widths[index],
|
|
76
|
+
}))
|
|
77
|
+
|
|
75
78
|
// disableSelectionOnClick helps avoid
|
|
76
79
|
// https://github.com/mui-org/material-ui-x/issues/1197
|
|
77
|
-
return (
|
|
80
|
+
return !preFilteredRows.length ? null : (
|
|
78
81
|
<BaseCard {...props} title="Samples">
|
|
79
82
|
{error ? <Typography color="error">{`${error}`}</Typography> : null}
|
|
80
83
|
|
|
@@ -107,14 +110,22 @@ export default function VariantSamples(props: {
|
|
|
107
110
|
))}
|
|
108
111
|
</>
|
|
109
112
|
) : null}
|
|
110
|
-
<div
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
rowHeight={25}
|
|
116
|
-
disableColumnMenu
|
|
113
|
+
<div ref={ref}>
|
|
114
|
+
<ResizeBar
|
|
115
|
+
widths={widths}
|
|
116
|
+
setWidths={setWidths}
|
|
117
|
+
scrollLeft={scrollLeft}
|
|
117
118
|
/>
|
|
119
|
+
<div ref={ref} style={{ height: 600, width: '100%', overflow: 'auto' }}>
|
|
120
|
+
<DataGrid
|
|
121
|
+
rows={rows}
|
|
122
|
+
columns={infoFields}
|
|
123
|
+
disableSelectionOnClick
|
|
124
|
+
rowHeight={25}
|
|
125
|
+
headerHeight={35}
|
|
126
|
+
disableColumnMenu
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
118
129
|
</div>
|
|
119
130
|
</BaseCard>
|
|
120
131
|
)
|
|
@@ -87,9 +87,9 @@ exports[`renders with just the required model elements 1`] = `
|
|
|
87
87
|
<div
|
|
88
88
|
class="css-1omt041-fieldValue"
|
|
89
89
|
>
|
|
90
|
-
<
|
|
90
|
+
<span>
|
|
91
91
|
rs123
|
|
92
|
-
</
|
|
92
|
+
</span>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
<div
|
|
@@ -103,9 +103,9 @@ exports[`renders with just the required model elements 1`] = `
|
|
|
103
103
|
<div
|
|
104
104
|
class="css-1omt041-fieldValue"
|
|
105
105
|
>
|
|
106
|
-
<
|
|
106
|
+
<span>
|
|
107
107
|
1
|
|
108
|
-
</
|
|
108
|
+
</span>
|
|
109
109
|
</div>
|
|
110
110
|
</div>
|
|
111
111
|
<hr
|
|
@@ -129,9 +129,9 @@ exports[`renders with just the required model elements 1`] = `
|
|
|
129
129
|
<div
|
|
130
130
|
class="css-1omt041-fieldValue"
|
|
131
131
|
>
|
|
132
|
-
<
|
|
132
|
+
<span>
|
|
133
133
|
A
|
|
134
|
-
</
|
|
134
|
+
</span>
|
|
135
135
|
</div>
|
|
136
136
|
</div>
|
|
137
137
|
<div
|
|
@@ -147,9 +147,9 @@ exports[`renders with just the required model elements 1`] = `
|
|
|
147
147
|
<div
|
|
148
148
|
class="css-1omt041-fieldValue"
|
|
149
149
|
>
|
|
150
|
-
<
|
|
150
|
+
<span>
|
|
151
151
|
<TRA>
|
|
152
|
-
</
|
|
152
|
+
</span>
|
|
153
153
|
</div>
|
|
154
154
|
</div>
|
|
155
155
|
<div
|
|
@@ -165,9 +165,9 @@ exports[`renders with just the required model elements 1`] = `
|
|
|
165
165
|
<div
|
|
166
166
|
class="css-1omt041-fieldValue"
|
|
167
167
|
>
|
|
168
|
-
<
|
|
168
|
+
<span>
|
|
169
169
|
10.4
|
|
170
|
-
</
|
|
170
|
+
</span>
|
|
171
171
|
</div>
|
|
172
172
|
</div>
|
|
173
173
|
<div
|
|
@@ -182,9 +182,9 @@ exports[`renders with just the required model elements 1`] = `
|
|
|
182
182
|
<div
|
|
183
183
|
class="css-1omt041-fieldValue"
|
|
184
184
|
>
|
|
185
|
-
<
|
|
185
|
+
<span>
|
|
186
186
|
5
|
|
187
|
-
</
|
|
187
|
+
</span>
|
|
188
188
|
</div>
|
|
189
189
|
</div>
|
|
190
190
|
<div
|