@jbrowse/plugin-config 2.11.1 → 2.12.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/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +1 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +19 -21
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +1 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +19 -21
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
3
2
|
import { AbstractSessionModel } from '@jbrowse/core/util';
|
|
3
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
4
4
|
declare const ConfigurationEditor: ({ model, }: {
|
|
5
5
|
model: {
|
|
6
6
|
target: AnyConfigurationModel;
|
|
@@ -4,12 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
8
7
|
const material_1 = require("@mui/material");
|
|
9
8
|
const mui_1 = require("tss-react/mui");
|
|
10
9
|
const mobx_react_1 = require("mobx-react");
|
|
11
10
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
12
11
|
const pluralize_1 = require("pluralize");
|
|
12
|
+
const SanitizedHTML_1 = __importDefault(require("@jbrowse/core/ui/SanitizedHTML"));
|
|
13
|
+
const configuration_1 = require("@jbrowse/core/configuration");
|
|
13
14
|
// icons
|
|
14
15
|
const ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
|
|
15
16
|
// locals
|
|
@@ -18,12 +19,9 @@ const TypeSelector_1 = __importDefault(require("./TypeSelector"));
|
|
|
18
19
|
const useStyles = (0, mui_1.makeStyles)()(theme => {
|
|
19
20
|
var _a;
|
|
20
21
|
return ({
|
|
21
|
-
|
|
22
|
+
icon: {
|
|
22
23
|
color: ((_a = theme.palette.tertiary) === null || _a === void 0 ? void 0 : _a.contrastText) || '#fff',
|
|
23
24
|
},
|
|
24
|
-
root: {
|
|
25
|
-
padding: theme.spacing(1, 3, 1, 1),
|
|
26
|
-
},
|
|
27
25
|
expansionPanelDetails: {
|
|
28
26
|
display: 'block',
|
|
29
27
|
padding: theme.spacing(1),
|
|
@@ -40,37 +38,36 @@ const useStyles = (0, mui_1.makeStyles)()(theme => {
|
|
|
40
38
|
const Member = (0, mobx_react_1.observer)(function (props) {
|
|
41
39
|
const { classes } = useStyles();
|
|
42
40
|
const { slotName, slotSchema, schema, slot = schema[slotName], path = [], } = props;
|
|
43
|
-
let typeSelector;
|
|
44
41
|
if ((0, configuration_1.isConfigurationSchemaType)(slotSchema)) {
|
|
45
42
|
if (slot.length) {
|
|
46
43
|
return slot.map((subslot, slotIndex) => {
|
|
47
|
-
const key =
|
|
44
|
+
const key = subslot.type
|
|
45
|
+
? `${(0, pluralize_1.singular)(slotName)} ${subslot.type}`
|
|
46
|
+
: `${(0, pluralize_1.singular)(slotName)} ${slotIndex + 1}`;
|
|
48
47
|
return react_1.default.createElement(Member, { key: key, ...props, slot: subslot, slotName: key });
|
|
49
48
|
});
|
|
50
49
|
}
|
|
51
50
|
// if this is an explicitly typed schema, make a type-selecting dropdown
|
|
52
51
|
// that can be used to change its type
|
|
53
52
|
const typeNameChoices = (0, configuration_1.getTypeNamesFromExplicitlyTypedUnion)(slotSchema);
|
|
54
|
-
if (typeNameChoices.length) {
|
|
55
|
-
typeSelector = (react_1.default.createElement(TypeSelector_1.default, { typeNameChoices: typeNameChoices, slotName: slotName, slot: slot, onChange: evt => {
|
|
56
|
-
if (evt.target.value !== slot.type) {
|
|
57
|
-
schema.setSubschema(slotName, { type: evt.target.value });
|
|
58
|
-
}
|
|
59
|
-
} }));
|
|
60
|
-
}
|
|
61
53
|
return (react_1.default.createElement(material_1.Accordion, { defaultExpanded: true, className: classes.accordion },
|
|
62
|
-
react_1.default.createElement(material_1.AccordionSummary, { expandIcon: react_1.default.createElement(ExpandMore_1.default, { className: classes.
|
|
54
|
+
react_1.default.createElement(material_1.AccordionSummary, { expandIcon: react_1.default.createElement(ExpandMore_1.default, { className: classes.icon }) },
|
|
63
55
|
react_1.default.createElement(material_1.Typography, null, [...path, slotName].join('➔'))),
|
|
64
56
|
react_1.default.createElement(material_1.AccordionDetails, { className: classes.expansionPanelDetails },
|
|
65
|
-
|
|
57
|
+
typeNameChoices.length ? (react_1.default.createElement(TypeSelector_1.default, { typeNameChoices: typeNameChoices, slotName: slotName, slot: slot, onChange: evt => {
|
|
58
|
+
if (evt.target.value !== slot.type) {
|
|
59
|
+
schema.setSubschema(slotName, { type: evt.target.value });
|
|
60
|
+
}
|
|
61
|
+
} })) : null,
|
|
66
62
|
react_1.default.createElement(material_1.FormGroup, { className: classes.noOverflow },
|
|
67
63
|
react_1.default.createElement(Schema, { schema: slot, path: [...path, slotName] })))));
|
|
68
64
|
}
|
|
69
|
-
if ((0, configuration_1.isConfigurationSlotType)(slotSchema)) {
|
|
70
|
-
// this is a regular config slot
|
|
65
|
+
else if ((0, configuration_1.isConfigurationSlotType)(slotSchema)) {
|
|
71
66
|
return react_1.default.createElement(SlotEditor_1.default, { key: slotName, slot: slot, slotSchema: slotSchema });
|
|
72
67
|
}
|
|
73
|
-
|
|
68
|
+
else {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
74
71
|
});
|
|
75
72
|
const Schema = (0, mobx_react_1.observer)(function ({ schema, path = [], }) {
|
|
76
73
|
const properties = (0, mobx_state_tree_1.getMembers)(schema).properties;
|
|
@@ -85,8 +82,9 @@ const ConfigurationEditor = (0, mobx_react_1.observer)(function ({ model, }) {
|
|
|
85
82
|
const key = target && (0, configuration_1.readConfObject)(target, 'trackId');
|
|
86
83
|
const name = target && (0, configuration_1.readConfObject)(target, 'name');
|
|
87
84
|
return (react_1.default.createElement(material_1.Accordion, { key: key, defaultExpanded: true, className: classes.accordion },
|
|
88
|
-
react_1.default.createElement(material_1.AccordionSummary, { expandIcon: react_1.default.createElement(ExpandMore_1.default, { className: classes.
|
|
89
|
-
react_1.default.createElement(material_1.Typography, null,
|
|
85
|
+
react_1.default.createElement(material_1.AccordionSummary, { expandIcon: react_1.default.createElement(ExpandMore_1.default, { className: classes.icon }) },
|
|
86
|
+
react_1.default.createElement(material_1.Typography, null,
|
|
87
|
+
react_1.default.createElement(SanitizedHTML_1.default, { html: name !== null && name !== void 0 ? name : 'Configuration' }))),
|
|
90
88
|
react_1.default.createElement(material_1.AccordionDetails, { className: classes.expansionPanelDetails, "data-testid": "configEditor" }, !target ? 'no target set' : react_1.default.createElement(Schema, { schema: target }))));
|
|
91
89
|
});
|
|
92
90
|
exports.default = ConfigurationEditor;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
3
2
|
import { AbstractSessionModel } from '@jbrowse/core/util';
|
|
3
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
4
4
|
declare const ConfigurationEditor: ({ model, }: {
|
|
5
5
|
model: {
|
|
6
6
|
target: AnyConfigurationModel;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { readConfObject, getTypeNamesFromExplicitlyTypedUnion, isConfigurationSchemaType, isConfigurationSlotType, } from '@jbrowse/core/configuration';
|
|
3
2
|
import { FormGroup, Accordion, AccordionDetails, AccordionSummary, Typography, } from '@mui/material';
|
|
4
3
|
import { makeStyles } from 'tss-react/mui';
|
|
5
4
|
import { observer } from 'mobx-react';
|
|
6
5
|
import { getMembers } from 'mobx-state-tree';
|
|
7
6
|
import { singular } from 'pluralize';
|
|
7
|
+
import SanitizedHTML from '@jbrowse/core/ui/SanitizedHTML';
|
|
8
|
+
import { readConfObject, getTypeNamesFromExplicitlyTypedUnion, isConfigurationSchemaType, isConfigurationSlotType, } from '@jbrowse/core/configuration';
|
|
8
9
|
// icons
|
|
9
10
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
10
11
|
// locals
|
|
@@ -13,12 +14,9 @@ import TypeSelector from './TypeSelector';
|
|
|
13
14
|
const useStyles = makeStyles()(theme => {
|
|
14
15
|
var _a;
|
|
15
16
|
return ({
|
|
16
|
-
|
|
17
|
+
icon: {
|
|
17
18
|
color: ((_a = theme.palette.tertiary) === null || _a === void 0 ? void 0 : _a.contrastText) || '#fff',
|
|
18
19
|
},
|
|
19
|
-
root: {
|
|
20
|
-
padding: theme.spacing(1, 3, 1, 1),
|
|
21
|
-
},
|
|
22
20
|
expansionPanelDetails: {
|
|
23
21
|
display: 'block',
|
|
24
22
|
padding: theme.spacing(1),
|
|
@@ -35,37 +33,36 @@ const useStyles = makeStyles()(theme => {
|
|
|
35
33
|
const Member = observer(function (props) {
|
|
36
34
|
const { classes } = useStyles();
|
|
37
35
|
const { slotName, slotSchema, schema, slot = schema[slotName], path = [], } = props;
|
|
38
|
-
let typeSelector;
|
|
39
36
|
if (isConfigurationSchemaType(slotSchema)) {
|
|
40
37
|
if (slot.length) {
|
|
41
38
|
return slot.map((subslot, slotIndex) => {
|
|
42
|
-
const key =
|
|
39
|
+
const key = subslot.type
|
|
40
|
+
? `${singular(slotName)} ${subslot.type}`
|
|
41
|
+
: `${singular(slotName)} ${slotIndex + 1}`;
|
|
43
42
|
return React.createElement(Member, { key: key, ...props, slot: subslot, slotName: key });
|
|
44
43
|
});
|
|
45
44
|
}
|
|
46
45
|
// if this is an explicitly typed schema, make a type-selecting dropdown
|
|
47
46
|
// that can be used to change its type
|
|
48
47
|
const typeNameChoices = getTypeNamesFromExplicitlyTypedUnion(slotSchema);
|
|
49
|
-
if (typeNameChoices.length) {
|
|
50
|
-
typeSelector = (React.createElement(TypeSelector, { typeNameChoices: typeNameChoices, slotName: slotName, slot: slot, onChange: evt => {
|
|
51
|
-
if (evt.target.value !== slot.type) {
|
|
52
|
-
schema.setSubschema(slotName, { type: evt.target.value });
|
|
53
|
-
}
|
|
54
|
-
} }));
|
|
55
|
-
}
|
|
56
48
|
return (React.createElement(Accordion, { defaultExpanded: true, className: classes.accordion },
|
|
57
|
-
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, { className: classes.
|
|
49
|
+
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, { className: classes.icon }) },
|
|
58
50
|
React.createElement(Typography, null, [...path, slotName].join('➔'))),
|
|
59
51
|
React.createElement(AccordionDetails, { className: classes.expansionPanelDetails },
|
|
60
|
-
|
|
52
|
+
typeNameChoices.length ? (React.createElement(TypeSelector, { typeNameChoices: typeNameChoices, slotName: slotName, slot: slot, onChange: evt => {
|
|
53
|
+
if (evt.target.value !== slot.type) {
|
|
54
|
+
schema.setSubschema(slotName, { type: evt.target.value });
|
|
55
|
+
}
|
|
56
|
+
} })) : null,
|
|
61
57
|
React.createElement(FormGroup, { className: classes.noOverflow },
|
|
62
58
|
React.createElement(Schema, { schema: slot, path: [...path, slotName] })))));
|
|
63
59
|
}
|
|
64
|
-
if (isConfigurationSlotType(slotSchema)) {
|
|
65
|
-
// this is a regular config slot
|
|
60
|
+
else if (isConfigurationSlotType(slotSchema)) {
|
|
66
61
|
return React.createElement(SlotEditor, { key: slotName, slot: slot, slotSchema: slotSchema });
|
|
67
62
|
}
|
|
68
|
-
|
|
63
|
+
else {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
69
66
|
});
|
|
70
67
|
const Schema = observer(function ({ schema, path = [], }) {
|
|
71
68
|
const properties = getMembers(schema).properties;
|
|
@@ -80,8 +77,9 @@ const ConfigurationEditor = observer(function ({ model, }) {
|
|
|
80
77
|
const key = target && readConfObject(target, 'trackId');
|
|
81
78
|
const name = target && readConfObject(target, 'name');
|
|
82
79
|
return (React.createElement(Accordion, { key: key, defaultExpanded: true, className: classes.accordion },
|
|
83
|
-
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, { className: classes.
|
|
84
|
-
React.createElement(Typography, null,
|
|
80
|
+
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, { className: classes.icon }) },
|
|
81
|
+
React.createElement(Typography, null,
|
|
82
|
+
React.createElement(SanitizedHTML, { html: name !== null && name !== void 0 ? name : 'Configuration' }))),
|
|
85
83
|
React.createElement(AccordionDetails, { className: classes.expansionPanelDetails, "data-testid": "configEditor" }, !target ? 'no target set' : React.createElement(Schema, { schema: target }))));
|
|
86
84
|
});
|
|
87
85
|
export default ConfigurationEditor;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "JBrowse 2 config utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"distModule": "esm/index.js",
|
|
57
57
|
"srcModule": "src/index.ts",
|
|
58
58
|
"module": "esm/index.js",
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "935f2602d29abc737bb1f493a922b6218d023ae2"
|
|
60
60
|
}
|