@jbrowse/plugin-config 2.0.0 → 2.1.2
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/CallbackEditor.js +49 -57
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +1 -1
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js +14 -56
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +1 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +37 -74
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +1 -1
- package/dist/ConfigurationEditorWidget/components/JsonEditor.d.ts +9 -7
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js +42 -43
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +1 -1
- package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +7 -5
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js +97 -142
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +1 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +15 -32
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +1 -1
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js +7 -8
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +1 -1
- package/dist/ConfigurationEditorWidget/index.d.ts +10 -3
- package/dist/ConfigurationEditorWidget/index.js +9 -9
- package/dist/ConfigurationEditorWidget/index.js.map +1 -1
- package/dist/ConfigurationEditorWidget/model.d.ts +3 -2
- package/dist/ConfigurationEditorWidget/model.js +16 -17
- package/dist/ConfigurationEditorWidget/model.js.map +1 -1
- package/dist/FromConfigAdapter/FromConfigAdapter.js +44 -158
- package/dist/FromConfigAdapter/FromConfigAdapter.js.map +1 -1
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js +37 -144
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js.map +1 -1
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.d.ts +2 -1
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js +48 -179
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js.map +1 -1
- package/dist/FromConfigAdapter/configSchema.js +1 -1
- package/dist/FromConfigAdapter/configSchema.js.map +1 -1
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +22 -108
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +1 -1
- package/dist/RefNameAliasAdapter/configSchema.js +1 -1
- package/dist/RefNameAliasAdapter/configSchema.js.map +1 -1
- package/dist/index.js +60 -94
- package/dist/index.js.map +1 -1
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +28 -19
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +1 -1
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js +6 -21
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +1 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +6 -2
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +1 -1
- package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +9 -7
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js +38 -22
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +1 -1
- package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +7 -5
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js +33 -27
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +1 -1
- package/esm/ConfigurationEditorWidget/index.d.ts +10 -3
- package/esm/ConfigurationEditorWidget/index.js +4 -3
- package/esm/ConfigurationEditorWidget/index.js.map +1 -1
- package/esm/ConfigurationEditorWidget/model.d.ts +3 -2
- package/esm/ConfigurationEditorWidget/model.js +2 -1
- package/esm/ConfigurationEditorWidget/model.js.map +1 -1
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.d.ts +2 -1
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.js +1 -9
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.js.map +1 -1
- package/package.json +4 -6
- package/src/ConfigurationEditorWidget/components/CallbackEditor.tsx +44 -45
- package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +6 -28
- package/src/ConfigurationEditorWidget/components/{ConfigurationEditor.test.js → ConfigurationEditor.test.tsx} +0 -0
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +6 -2
- package/src/ConfigurationEditorWidget/components/JsonEditor.tsx +84 -0
- package/src/ConfigurationEditorWidget/components/SlotEditor.tsx +484 -0
- package/src/ConfigurationEditorWidget/components/__snapshots__/{ConfigurationEditor.test.js.snap → ConfigurationEditor.test.tsx.snap} +186 -167
- package/src/ConfigurationEditorWidget/index.tsx +25 -0
- package/src/ConfigurationEditorWidget/{model.js → model.ts} +4 -2
- package/src/FromConfigAdapter/FromConfigSequenceAdapter.ts +6 -10
- package/dist/ConfigurationEditorWidget/components/CodeEditor.d.ts +0 -5
- package/dist/ConfigurationEditorWidget/components/CodeEditor.js +0 -85
- package/dist/ConfigurationEditorWidget/components/CodeEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/ColorPicker.d.ts +0 -7
- package/dist/ConfigurationEditorWidget/components/ColorPicker.js +0 -69
- package/dist/ConfigurationEditorWidget/components/ColorPicker.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/CodeEditor.d.ts +0 -5
- package/esm/ConfigurationEditorWidget/components/CodeEditor.js +0 -42
- package/esm/ConfigurationEditorWidget/components/CodeEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/ColorPicker.d.ts +0 -7
- package/esm/ConfigurationEditorWidget/components/ColorPicker.js +0 -26
- package/esm/ConfigurationEditorWidget/components/ColorPicker.js.map +0 -1
- package/src/ConfigurationEditorWidget/components/CodeEditor.tsx +0 -59
- package/src/ConfigurationEditorWidget/components/ColorPicker.tsx +0 -43
- package/src/ConfigurationEditorWidget/components/JsonEditor.js +0 -52
- package/src/ConfigurationEditorWidget/components/SlotEditor.js +0 -376
- package/src/ConfigurationEditorWidget/index.js +0 -20
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { types } from 'mobx-state-tree';
|
|
2
2
|
import { ElementId } from '@jbrowse/core/util/types/mst';
|
|
3
|
-
export default pluginManager => types
|
|
3
|
+
export default (pluginManager) => types
|
|
4
4
|
.model('ConfigurationEditorWidget', {
|
|
5
5
|
id: ElementId,
|
|
6
6
|
type: types.literal('ConfigurationEditorWidget'),
|
|
@@ -9,6 +9,7 @@ export default pluginManager => types
|
|
|
9
9
|
target: types.safeReference(pluginManager.pluggableConfigSchemaType('track')),
|
|
10
10
|
})
|
|
11
11
|
.actions(self => ({
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
13
|
setTarget(newTarget) {
|
|
13
14
|
self.target = newTarget;
|
|
14
15
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/ConfigurationEditorWidget/model.
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/ConfigurationEditorWidget/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAGxD,eAAe,CAAC,aAA4B,EAAE,EAAE,CAC9C,KAAK;KACF,KAAK,CAAC,2BAA2B,EAAE;IAClC,EAAE,EAAE,SAAS;IACb,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,2BAA2B,CAAC;IAChD,0EAA0E;IAC1E,oDAAoD;IACpD,MAAM,EAAE,KAAK,CAAC,aAAa,CACzB,aAAa,CAAC,yBAAyB,CAAC,OAAO,CAAC,CACjD;CACF,CAAC;KACD,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChB,8DAA8D;IAC9D,SAAS,CAAC,SAAc;QACtB,IAAI,CAAC,MAAM,GAAG,SAAS,CAAA;IACzB,CAAC;CACF,CAAC,CAAC,CAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
2
2
|
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
3
|
import FromConfigAdapter from './FromConfigAdapter';
|
|
4
|
-
|
|
4
|
+
import { RegionsAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
5
|
+
export default class FromConfigSequenceAdapter extends FromConfigAdapter implements RegionsAdapter {
|
|
5
6
|
/**
|
|
6
7
|
* Fetch features for a certain region
|
|
7
8
|
* @param region - Region
|
|
@@ -9,16 +9,8 @@ export default class FromConfigSequenceAdapter extends FromConfigAdapter {
|
|
|
9
9
|
* @returns Observable of Feature objects in the region
|
|
10
10
|
*/
|
|
11
11
|
getFeatures(region) {
|
|
12
|
-
// TODO: restore commented version below once TSDX supports Rollup v2
|
|
13
|
-
// xref: https://github.com/rollup/rollup/blob/master/CHANGELOG.md#bug-fixes-45
|
|
14
|
-
// return ObservableCreate<Feature>(async observer => {
|
|
15
|
-
// const feats = await super.getFeatures(region).pipe(toArray()).toPromise()
|
|
16
|
-
const superGetFeatures = super.getFeatures;
|
|
17
12
|
return ObservableCreate(async (observer) => {
|
|
18
|
-
const feats = await
|
|
19
|
-
.call(this, region)
|
|
20
|
-
.pipe(toArray())
|
|
21
|
-
.toPromise();
|
|
13
|
+
const feats = await super.getFeatures(region).pipe(toArray()).toPromise();
|
|
22
14
|
const feat = feats[0];
|
|
23
15
|
observer.next(new SimpleFeature({
|
|
24
16
|
...feat.toJSON(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FromConfigSequenceAdapter.js","sourceRoot":"","sources":["../../src/FromConfigAdapter/FromConfigSequenceAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,aAA0B,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"FromConfigSequenceAdapter.js","sourceRoot":"","sources":["../../src/FromConfigAdapter/FromConfigSequenceAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,aAA0B,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,OAAO,iBAAiB,MAAM,qBAAqB,CAAA;AAGnD,MAAM,CAAC,OAAO,OAAO,yBACnB,SAAQ,iBAAiB;IAGzB;;;;OAIG;IACH,WAAW,CAAC,MAAwB;QAClC,OAAO,gBAAgB,CAAU,KAAK,EAAC,QAAQ,EAAC,EAAE;YAChD,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,SAAS,EAAE,CAAA;YACzE,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;YACrB,QAAQ,CAAC,IAAI,CACX,IAAI,aAAa,CAAC;gBAChB,GAAG,IAAI,CAAC,MAAM,EAAE;gBAChB,QAAQ,EAAE,GAAG,IAAI,CAAC,EAAE,EAAE,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,GAAG,EAAE;gBACtD,GAAG,EAAE,MAAM,CAAC,GAAG;gBACf,KAAK,EAAE,MAAM,CAAC,KAAK;gBACnB,GAAG,EAAE,IAAI;qBACN,GAAG,CAAC,KAAK,CAAC;qBACV,KAAK,CACJ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,EAC7C,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAC5C;aACJ,CAAC,CACH,CAAA;YAED,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,MAAM,OAAO,GAAG,EAAE,CAAA;QAElB,wEAAwE;QACxE,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE;YAC/C,IAAI,aAAa,CAAA;YACjB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;gBAC9B,IACE,aAAa;oBACb,aAAa,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;oBACzC,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EACzC;oBACA,aAAa,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;iBACvC;qBAAM;oBACL,IAAI,aAAa,EAAE;wBACjB,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;qBAC5B;oBACD,aAAa,GAAG;wBACd,OAAO;wBACP,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC;wBAC3B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;qBACxB,CAAA;iBACF;aACF;YACD,IAAI,aAAa,EAAE;gBACjB,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;aAC5B;SACF;QAED,OAAO,OAAO,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,aAAa,EAAC,gBAAgB,IAAS,CAAC;CACzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-config",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "JBrowse 2 config utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -37,13 +37,11 @@
|
|
|
37
37
|
"clean": "rimraf dist esm *.tsbuildinfo"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@babel/runtime": "^7.17.9",
|
|
41
40
|
"@mui/icons-material": "^5.0.1",
|
|
42
|
-
"pluralize": "^8.0.0"
|
|
43
|
-
"react-color": "^2.19.3"
|
|
41
|
+
"pluralize": "^8.0.0"
|
|
44
42
|
},
|
|
45
43
|
"peerDependencies": {
|
|
46
|
-
"@jbrowse/core": "^
|
|
44
|
+
"@jbrowse/core": "^2.0.0",
|
|
47
45
|
"@mui/material": "^5.0.0",
|
|
48
46
|
"mobx": "^6.0.0",
|
|
49
47
|
"mobx-react": "^7.0.0",
|
|
@@ -60,5 +58,5 @@
|
|
|
60
58
|
"distModule": "esm/index.js",
|
|
61
59
|
"srcModule": "src/index.ts",
|
|
62
60
|
"module": "esm/index.js",
|
|
63
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "449b17325c9a4a97181f7ddddf48e80219f03b8d"
|
|
64
62
|
}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Tooltip, IconButton, TextField } from '@mui/material'
|
|
2
3
|
import { useDebounce } from '@jbrowse/core/util'
|
|
3
4
|
import { stringToJexlExpression } from '@jbrowse/core/util/jexlStrings'
|
|
4
|
-
import {
|
|
5
|
-
FormControl,
|
|
6
|
-
FormHelperText,
|
|
7
|
-
InputLabel,
|
|
8
|
-
Tooltip,
|
|
9
|
-
IconButton,
|
|
10
|
-
TextField,
|
|
11
|
-
} from '@mui/material'
|
|
12
|
-
import { makeStyles } from 'tss-react/mui'
|
|
13
|
-
import HelpIcon from '@mui/icons-material/Help'
|
|
14
5
|
import { getEnv } from 'mobx-state-tree'
|
|
15
6
|
import { observer } from 'mobx-react'
|
|
7
|
+
import { makeStyles } from 'tss-react/mui'
|
|
8
|
+
|
|
9
|
+
// icons
|
|
10
|
+
import HelpIcon from '@mui/icons-material/Help'
|
|
16
11
|
|
|
17
12
|
// Optimize by using system default fonts:
|
|
18
13
|
// https://css-tricks.com/snippets/css/font-stacks/
|
|
@@ -23,11 +18,21 @@ const useStyles = makeStyles()(theme => ({
|
|
|
23
18
|
callbackEditor: {
|
|
24
19
|
marginTop: '16px',
|
|
25
20
|
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
21
|
+
width: '100%',
|
|
26
22
|
fontFamily,
|
|
27
23
|
},
|
|
28
24
|
textAreaFont: {
|
|
29
25
|
fontFamily,
|
|
30
26
|
},
|
|
27
|
+
callbackContainer: {
|
|
28
|
+
width: '100%',
|
|
29
|
+
overflowX: 'auto',
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
error: {
|
|
33
|
+
color: 'red',
|
|
34
|
+
fontSize: '0.8em',
|
|
35
|
+
},
|
|
31
36
|
}))
|
|
32
37
|
|
|
33
38
|
function CallbackEditor({
|
|
@@ -72,10 +77,8 @@ function CallbackEditor({
|
|
|
72
77
|
// do this last
|
|
73
78
|
return (
|
|
74
79
|
<>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
{slot.name}
|
|
78
|
-
</InputLabel>
|
|
80
|
+
{error ? <p className={classes.error}>{`${error}`}</p> : null}
|
|
81
|
+
<div className={classes.callbackContainer}>
|
|
79
82
|
<TextField
|
|
80
83
|
multiline
|
|
81
84
|
className={classes.callbackEditor}
|
|
@@ -88,38 +91,34 @@ function CallbackEditor({
|
|
|
88
91
|
},
|
|
89
92
|
}}
|
|
90
93
|
/>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
Callbacks are written in Jexl format. Click to learn more.
|
|
102
|
-
<br /> Names of available context items: {slot.contextVariable}
|
|
103
|
-
</div>
|
|
104
|
-
}
|
|
105
|
-
arrow
|
|
106
|
-
>
|
|
107
|
-
<IconButton
|
|
108
|
-
color="primary"
|
|
109
|
-
onClick={() => {
|
|
110
|
-
const newWindow = window.open(
|
|
111
|
-
'https://github.com/TomFrost/Jexl',
|
|
112
|
-
'_blank',
|
|
113
|
-
'noopener,noreferrer',
|
|
114
|
-
)
|
|
115
|
-
if (newWindow) {
|
|
116
|
-
newWindow.opener = null
|
|
117
|
-
}
|
|
118
|
-
}}
|
|
94
|
+
|
|
95
|
+
<p>{slot.description}</p>
|
|
96
|
+
<Tooltip
|
|
97
|
+
title={
|
|
98
|
+
<div>
|
|
99
|
+
Callbacks are written in Jexl format. Click to learn more.
|
|
100
|
+
<br /> Names of available context items: {slot.contextVariable}
|
|
101
|
+
</div>
|
|
102
|
+
}
|
|
103
|
+
arrow
|
|
119
104
|
>
|
|
120
|
-
<
|
|
121
|
-
|
|
122
|
-
|
|
105
|
+
<IconButton
|
|
106
|
+
color="primary"
|
|
107
|
+
onClick={() => {
|
|
108
|
+
const newWindow = window.open(
|
|
109
|
+
'https://github.com/TomFrost/Jexl',
|
|
110
|
+
'_blank',
|
|
111
|
+
'noopener,noreferrer',
|
|
112
|
+
)
|
|
113
|
+
if (newWindow) {
|
|
114
|
+
newWindow.opener = null
|
|
115
|
+
}
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
<HelpIcon />
|
|
119
|
+
</IconButton>
|
|
120
|
+
</Tooltip>
|
|
121
|
+
</div>
|
|
123
122
|
</>
|
|
124
123
|
)
|
|
125
124
|
}
|
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
import React, { lazy, useState } from 'react'
|
|
2
2
|
import { observer } from 'mobx-react'
|
|
3
3
|
import { TextField } from '@mui/material'
|
|
4
|
-
import { Color, RGBColor } from 'react-color'
|
|
5
4
|
|
|
6
|
-
const ColorPicker = lazy(() => import('
|
|
7
|
-
|
|
8
|
-
// this is needed because passing a entire color object into the react-color
|
|
9
|
-
// for alpha, can't pass in an rgba string for example
|
|
10
|
-
function serializeColor(color: Color) {
|
|
11
|
-
if (color instanceof Object) {
|
|
12
|
-
const { r, g, b, a } = color as RGBColor
|
|
13
|
-
return a === undefined ? `rgb(${r},${g},${b})` : `rgba(${r},${g},${b},${a})`
|
|
14
|
-
}
|
|
15
|
-
return color
|
|
16
|
-
}
|
|
5
|
+
const ColorPicker = lazy(() => import('@jbrowse/core/ui/ColorPicker'))
|
|
17
6
|
|
|
18
7
|
export const ColorSlot = (props: {
|
|
19
8
|
value: string
|
|
@@ -28,31 +17,20 @@ export const ColorSlot = (props: {
|
|
|
28
17
|
const [displayed, setDisplayed] = useState(false)
|
|
29
18
|
|
|
30
19
|
return (
|
|
31
|
-
|
|
20
|
+
<div style={{ display: 'flex' }}>
|
|
32
21
|
<TextField
|
|
33
22
|
value={value}
|
|
34
23
|
label={label}
|
|
35
|
-
InputProps={{
|
|
36
|
-
style: {
|
|
37
|
-
color: value,
|
|
38
|
-
borderRightWidth: '25px',
|
|
39
|
-
borderRightStyle: 'solid',
|
|
40
|
-
borderRightColor: value,
|
|
41
|
-
},
|
|
42
|
-
}}
|
|
43
24
|
onClick={() => setDisplayed(!displayed)}
|
|
44
25
|
onChange={event => onChange(event.target.value)}
|
|
45
26
|
{...TextFieldProps}
|
|
46
27
|
/>
|
|
47
|
-
{
|
|
28
|
+
<div style={{ marginTop: 10 }}>
|
|
48
29
|
<React.Suspense fallback={<div />}>
|
|
49
|
-
<ColorPicker
|
|
50
|
-
color={value}
|
|
51
|
-
onChange={event => onChange(serializeColor(event.rgb))}
|
|
52
|
-
/>
|
|
30
|
+
<ColorPicker color={value} onChange={event => onChange(event)} />
|
|
53
31
|
</React.Suspense>
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
56
34
|
)
|
|
57
35
|
}
|
|
58
36
|
|
|
File without changes
|
|
@@ -40,6 +40,10 @@ const useStyles = makeStyles()(theme => ({
|
|
|
40
40
|
accordion: {
|
|
41
41
|
border: `1px solid ${theme.palette.text.primary}`,
|
|
42
42
|
},
|
|
43
|
+
noOverflow: {
|
|
44
|
+
width: '100%',
|
|
45
|
+
overflowX: 'auto',
|
|
46
|
+
},
|
|
43
47
|
}))
|
|
44
48
|
|
|
45
49
|
const Member = observer(
|
|
@@ -88,11 +92,11 @@ const Member = observer(
|
|
|
88
92
|
<AccordionSummary
|
|
89
93
|
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
|
|
90
94
|
>
|
|
91
|
-
<Typography>{[...path, slotName].join('
|
|
95
|
+
<Typography>{[...path, slotName].join('➔')}</Typography>
|
|
92
96
|
</AccordionSummary>
|
|
93
97
|
<AccordionDetails className={classes.expansionPanelDetails}>
|
|
94
98
|
{typeSelector}
|
|
95
|
-
<FormGroup>
|
|
99
|
+
<FormGroup className={classes.noOverflow}>
|
|
96
100
|
<Schema schema={slot} path={[...path, slotName]} />
|
|
97
101
|
</FormGroup>
|
|
98
102
|
</AccordionDetails>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { InputLabel, TextField } from '@mui/material'
|
|
3
|
+
import { makeStyles } from 'tss-react/mui'
|
|
4
|
+
import { observer } from 'mobx-react'
|
|
5
|
+
|
|
6
|
+
// fontSize and fontFamily have to match between Editor and SyntaxHighlighter
|
|
7
|
+
const fontSize = '12px'
|
|
8
|
+
// Optimize by using system default fonts: https://css-tricks.com/snippets/css/font-stacks/
|
|
9
|
+
const fontFamily =
|
|
10
|
+
'Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace'
|
|
11
|
+
|
|
12
|
+
const useStyles = makeStyles()(theme => ({
|
|
13
|
+
error: {
|
|
14
|
+
color: 'red',
|
|
15
|
+
fontSize: '0.8em',
|
|
16
|
+
},
|
|
17
|
+
callbackEditor: {
|
|
18
|
+
fontFamily,
|
|
19
|
+
fontSize,
|
|
20
|
+
background: theme.palette.background.default,
|
|
21
|
+
width: 800,
|
|
22
|
+
marginTop: '16px',
|
|
23
|
+
border: '1px solid rgba(0,0,0,0.42)',
|
|
24
|
+
},
|
|
25
|
+
callbackContainer: {
|
|
26
|
+
width: '100%',
|
|
27
|
+
overflowX: 'auto',
|
|
28
|
+
},
|
|
29
|
+
textAreaFont: {
|
|
30
|
+
fontFamily,
|
|
31
|
+
},
|
|
32
|
+
}))
|
|
33
|
+
|
|
34
|
+
function JsonEditor({
|
|
35
|
+
slot,
|
|
36
|
+
}: {
|
|
37
|
+
slot: {
|
|
38
|
+
name: string
|
|
39
|
+
description: string
|
|
40
|
+
value: unknown
|
|
41
|
+
set: (arg: unknown) => void
|
|
42
|
+
}
|
|
43
|
+
}) {
|
|
44
|
+
const { classes } = useStyles()
|
|
45
|
+
const [contents, setContents] = useState(JSON.stringify(slot.value, null, 2))
|
|
46
|
+
const [error, setError] = useState<unknown>()
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
try {
|
|
50
|
+
setError(undefined)
|
|
51
|
+
slot.set(JSON.parse(contents))
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error({ e })
|
|
54
|
+
setError(e)
|
|
55
|
+
}
|
|
56
|
+
}, [contents, slot])
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
{error ? <p className={classes.error}>{`${error}`}</p> : null}
|
|
61
|
+
<div className={classes.callbackContainer}>
|
|
62
|
+
<InputLabel shrink htmlFor="json-editor">
|
|
63
|
+
{slot.name}
|
|
64
|
+
</InputLabel>
|
|
65
|
+
<TextField
|
|
66
|
+
id="json-editor"
|
|
67
|
+
className={classes.callbackEditor}
|
|
68
|
+
value={contents}
|
|
69
|
+
helperText={slot.description}
|
|
70
|
+
multiline
|
|
71
|
+
onChange={event => setContents(event.target.value)}
|
|
72
|
+
style={{ background: error ? '#fdd' : undefined }}
|
|
73
|
+
InputProps={{
|
|
74
|
+
classes: {
|
|
75
|
+
input: classes.textAreaFont,
|
|
76
|
+
},
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</>
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default observer(JsonEditor)
|