@jbrowse/plugin-config 1.7.11 → 2.1.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/CallbackEditor.d.ts +10 -7
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +117 -115
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/ColorEditor.d.ts +9 -33
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js +68 -117
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +7 -3
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +117 -160
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/JsonEditor.d.ts +9 -7
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js +92 -77
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +17 -5
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js +240 -374
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +76 -105
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +1 -0
- package/dist/ConfigurationEditorWidget/components/TypeSelector.d.ts +8 -6
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js +16 -46
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +1 -0
- package/dist/ConfigurationEditorWidget/index.d.ts +10 -3
- package/dist/ConfigurationEditorWidget/index.js +26 -42
- package/dist/ConfigurationEditorWidget/index.js.map +1 -0
- package/dist/ConfigurationEditorWidget/model.d.ts +3 -2
- package/dist/ConfigurationEditorWidget/model.js +19 -26
- package/dist/ConfigurationEditorWidget/model.js.map +1 -0
- package/dist/FromConfigAdapter/FromConfigAdapter.js +172 -204
- package/dist/FromConfigAdapter/FromConfigAdapter.js.map +1 -0
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js +151 -142
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.js.map +1 -0
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.d.ts +2 -1
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js +174 -181
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.js.map +1 -0
- package/dist/FromConfigAdapter/configSchema.js +33 -49
- package/dist/FromConfigAdapter/configSchema.js.map +1 -0
- package/dist/FromConfigAdapter/index.js +16 -50
- package/dist/FromConfigAdapter/index.js.map +1 -0
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +111 -125
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +1 -0
- package/dist/RefNameAliasAdapter/configSchema.js +16 -25
- package/dist/RefNameAliasAdapter/configSchema.js.map +1 -0
- package/dist/RefNameAliasAdapter/index.js +10 -22
- package/dist/RefNameAliasAdapter/index.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.js +129 -144
- package/dist/index.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.d.ts +12 -0
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +80 -0
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/ColorEditor.d.ts +20 -0
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js +22 -0
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +8 -0
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +87 -0
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +11 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js +55 -0
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +18 -0
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js +182 -0
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +12 -0
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +36 -0
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js.map +1 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +9 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js +12 -0
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js.map +1 -0
- package/esm/ConfigurationEditorWidget/index.d.ts +10 -0
- package/esm/ConfigurationEditorWidget/index.js +21 -0
- package/esm/ConfigurationEditorWidget/index.js.map +1 -0
- package/esm/ConfigurationEditorWidget/model.d.ts +9 -0
- package/esm/ConfigurationEditorWidget/model.js +17 -0
- package/esm/ConfigurationEditorWidget/model.js.map +1 -0
- package/esm/FromConfigAdapter/FromConfigAdapter.d.ts +24 -0
- package/esm/FromConfigAdapter/FromConfigAdapter.js +63 -0
- package/esm/FromConfigAdapter/FromConfigAdapter.js.map +1 -0
- package/esm/FromConfigAdapter/FromConfigRegionsAdapter.d.ts +23 -0
- package/esm/FromConfigAdapter/FromConfigRegionsAdapter.js +50 -0
- package/esm/FromConfigAdapter/FromConfigRegionsAdapter.js.map +1 -0
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.d.ts +26 -0
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.js +65 -0
- package/esm/FromConfigAdapter/FromConfigSequenceAdapter.js.map +1 -0
- package/esm/FromConfigAdapter/configSchema.d.ts +3 -0
- package/esm/FromConfigAdapter/configSchema.js +32 -0
- package/esm/FromConfigAdapter/configSchema.js.map +1 -0
- package/esm/FromConfigAdapter/index.d.ts +4 -0
- package/esm/FromConfigAdapter/index.js +5 -0
- package/esm/FromConfigAdapter/index.js.map +1 -0
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.d.ts +8 -0
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +24 -0
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js.map +1 -0
- package/esm/RefNameAliasAdapter/configSchema.d.ts +2 -0
- package/esm/RefNameAliasAdapter/configSchema.js +15 -0
- package/esm/RefNameAliasAdapter/configSchema.js.map +1 -0
- package/esm/RefNameAliasAdapter/index.d.ts +2 -0
- package/esm/RefNameAliasAdapter/index.js +3 -0
- package/esm/RefNameAliasAdapter/index.js.map +1 -0
- package/esm/index.d.ts +18 -0
- package/esm/index.js +72 -0
- package/esm/index.js.map +1 -0
- package/package.json +21 -15
- package/src/ConfigurationEditorWidget/components/CallbackEditor.tsx +126 -0
- package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +13 -60
- package/src/ConfigurationEditorWidget/components/{ConfigurationEditor.test.js → ConfigurationEditor.test.tsx} +0 -0
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +173 -0
- package/src/ConfigurationEditorWidget/components/JsonEditor.tsx +84 -0
- package/src/ConfigurationEditorWidget/components/SlotEditor.tsx +484 -0
- package/src/ConfigurationEditorWidget/components/StringArrayEditor.tsx +2 -2
- package/src/ConfigurationEditorWidget/components/{TypeSelector.js → TypeSelector.tsx} +15 -7
- package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.tsx.snap +2024 -0
- package/src/ConfigurationEditorWidget/index.tsx +25 -0
- package/src/ConfigurationEditorWidget/{model.js → model.ts} +4 -2
- package/src/FromConfigAdapter/FromConfigSequenceAdapter.ts +6 -10
- package/src/index.ts +20 -14
- package/dist/ConfigurationEditorWidget/components/CodeEditor.d.ts +0 -4
- package/dist/ConfigurationEditorWidget/components/CodeEditor.js +0 -80
- package/dist/ConfigurationEditorWidget/components/ColorEditor.test.js +0 -31
- package/dist/ConfigurationEditorWidget/components/ColorPicker.d.ts +0 -14
- package/dist/ConfigurationEditorWidget/components/ColorPicker.js +0 -72
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.test.js +0 -121
- package/dist/FromConfigAdapter/FromConfigAdapter.test.js +0 -100
- package/dist/FromConfigAdapter/FromConfigRegionsAdapter.test.js +0 -200
- package/dist/FromConfigAdapter/FromConfigSequenceAdapter.test.js +0 -110
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.test.js +0 -41
- package/dist/index.test.js +0 -41
- package/src/ConfigurationEditorWidget/components/CallbackEditor.js +0 -112
- package/src/ConfigurationEditorWidget/components/CodeEditor.js +0 -60
- package/src/ConfigurationEditorWidget/components/ColorPicker.tsx +0 -52
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -154
- package/src/ConfigurationEditorWidget/components/JsonEditor.js +0 -56
- package/src/ConfigurationEditorWidget/components/SlotEditor.js +0 -377
- package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.js.snap +0 -1753
- package/src/ConfigurationEditorWidget/index.js +0 -20
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import {
|
|
3
|
+
readConfObject,
|
|
4
|
+
getTypeNamesFromExplicitlyTypedUnion,
|
|
5
|
+
isConfigurationSchemaType,
|
|
6
|
+
isConfigurationSlotType,
|
|
7
|
+
AnyConfigurationModel,
|
|
8
|
+
} from '@jbrowse/core/configuration'
|
|
9
|
+
import {
|
|
10
|
+
FormGroup,
|
|
11
|
+
Accordion,
|
|
12
|
+
AccordionDetails,
|
|
13
|
+
AccordionSummary,
|
|
14
|
+
Typography,
|
|
15
|
+
} from '@mui/material'
|
|
16
|
+
import { makeStyles } from 'tss-react/mui'
|
|
17
|
+
import { observer } from 'mobx-react'
|
|
18
|
+
import { getMembers, IAnyType } from 'mobx-state-tree'
|
|
19
|
+
import { singular } from 'pluralize'
|
|
20
|
+
|
|
21
|
+
// icons
|
|
22
|
+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'
|
|
23
|
+
|
|
24
|
+
// locals
|
|
25
|
+
import SlotEditor from './SlotEditor'
|
|
26
|
+
import TypeSelector from './TypeSelector'
|
|
27
|
+
|
|
28
|
+
const useStyles = makeStyles()(theme => ({
|
|
29
|
+
expandIcon: {
|
|
30
|
+
color: '#fff',
|
|
31
|
+
},
|
|
32
|
+
root: {
|
|
33
|
+
padding: theme.spacing(1, 3, 1, 1),
|
|
34
|
+
},
|
|
35
|
+
expansionPanelDetails: {
|
|
36
|
+
display: 'block',
|
|
37
|
+
padding: theme.spacing(1),
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
accordion: {
|
|
41
|
+
border: `1px solid ${theme.palette.text.primary}`,
|
|
42
|
+
},
|
|
43
|
+
noOverflow: {
|
|
44
|
+
width: '100%',
|
|
45
|
+
overflowX: 'auto',
|
|
46
|
+
},
|
|
47
|
+
}))
|
|
48
|
+
|
|
49
|
+
const Member = observer(
|
|
50
|
+
(props: {
|
|
51
|
+
slotName: string
|
|
52
|
+
slotSchema: IAnyType
|
|
53
|
+
schema: AnyConfigurationModel
|
|
54
|
+
slot?: AnyConfigurationModel | AnyConfigurationModel[]
|
|
55
|
+
path?: string[]
|
|
56
|
+
}) => {
|
|
57
|
+
const { classes } = useStyles()
|
|
58
|
+
const {
|
|
59
|
+
slotName,
|
|
60
|
+
slotSchema,
|
|
61
|
+
schema,
|
|
62
|
+
slot = schema[slotName],
|
|
63
|
+
path = [],
|
|
64
|
+
} = props
|
|
65
|
+
let typeSelector
|
|
66
|
+
if (isConfigurationSchemaType(slotSchema)) {
|
|
67
|
+
if (slot.length) {
|
|
68
|
+
return slot.map((subslot: AnyConfigurationModel, slotIndex: number) => {
|
|
69
|
+
const key = `${singular(slotName)} ${slotIndex + 1}`
|
|
70
|
+
return <Member {...props} key={key} slot={subslot} slotName={key} />
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
// if this is an explicitly typed schema, make a type-selecting dropdown
|
|
74
|
+
// that can be used to change its type
|
|
75
|
+
const typeNameChoices = getTypeNamesFromExplicitlyTypedUnion(slotSchema)
|
|
76
|
+
if (typeNameChoices.length) {
|
|
77
|
+
typeSelector = (
|
|
78
|
+
<TypeSelector
|
|
79
|
+
typeNameChoices={typeNameChoices}
|
|
80
|
+
slotName={slotName}
|
|
81
|
+
slot={slot}
|
|
82
|
+
onChange={evt => {
|
|
83
|
+
if (evt.target.value !== slot.type) {
|
|
84
|
+
schema.setSubschema(slotName, { type: evt.target.value })
|
|
85
|
+
}
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
return (
|
|
91
|
+
<Accordion defaultExpanded className={classes.accordion}>
|
|
92
|
+
<AccordionSummary
|
|
93
|
+
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
|
|
94
|
+
>
|
|
95
|
+
<Typography>{[...path, slotName].join('🡒')}</Typography>
|
|
96
|
+
</AccordionSummary>
|
|
97
|
+
<AccordionDetails className={classes.expansionPanelDetails}>
|
|
98
|
+
{typeSelector}
|
|
99
|
+
<FormGroup className={classes.noOverflow}>
|
|
100
|
+
<Schema schema={slot} path={[...path, slotName]} />
|
|
101
|
+
</FormGroup>
|
|
102
|
+
</AccordionDetails>
|
|
103
|
+
</Accordion>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (isConfigurationSlotType(slotSchema)) {
|
|
108
|
+
// this is a regular config slot
|
|
109
|
+
return <SlotEditor key={slotName} slot={slot} slotSchema={slotSchema} />
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return null
|
|
113
|
+
},
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
const Schema = observer(
|
|
117
|
+
({
|
|
118
|
+
schema,
|
|
119
|
+
path = [],
|
|
120
|
+
}: {
|
|
121
|
+
schema: AnyConfigurationModel
|
|
122
|
+
path?: string[]
|
|
123
|
+
}) => {
|
|
124
|
+
const properties = getMembers(schema).properties
|
|
125
|
+
return (
|
|
126
|
+
<>
|
|
127
|
+
{Object.entries(properties).map(([slotName, slotSchema]) => (
|
|
128
|
+
<Member
|
|
129
|
+
key={slotName}
|
|
130
|
+
slotName={slotName}
|
|
131
|
+
slotSchema={slotSchema}
|
|
132
|
+
path={path}
|
|
133
|
+
schema={schema}
|
|
134
|
+
/>
|
|
135
|
+
))}
|
|
136
|
+
</>
|
|
137
|
+
)
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
const ConfigurationEditor = observer(
|
|
142
|
+
({ model }: { model: { target: AnyConfigurationModel } }) => {
|
|
143
|
+
const { classes } = useStyles()
|
|
144
|
+
// key forces a re-render, otherwise the same field can end up being used
|
|
145
|
+
// for different tracks since only the backing model changes for example
|
|
146
|
+
// see pr #804
|
|
147
|
+
const { target } = model
|
|
148
|
+
const key = target && readConfObject(target, 'trackId')
|
|
149
|
+
const name = target && readConfObject(target, 'name')
|
|
150
|
+
return (
|
|
151
|
+
<>
|
|
152
|
+
<Accordion key={key} defaultExpanded className={classes.accordion}>
|
|
153
|
+
<AccordionSummary
|
|
154
|
+
expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
|
|
155
|
+
>
|
|
156
|
+
<Typography>{name ?? 'Configuration'}</Typography>
|
|
157
|
+
</AccordionSummary>
|
|
158
|
+
<AccordionDetails
|
|
159
|
+
className={classes.expansionPanelDetails}
|
|
160
|
+
data-testid="configEditor"
|
|
161
|
+
>
|
|
162
|
+
{!target ? 'no target set' : <Schema schema={target} />}
|
|
163
|
+
</AccordionDetails>
|
|
164
|
+
</Accordion>
|
|
165
|
+
|
|
166
|
+
{/* blank space at the bottom of screen allows scroll */}
|
|
167
|
+
<div style={{ height: 300 }} />
|
|
168
|
+
</>
|
|
169
|
+
)
|
|
170
|
+
},
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
export default ConfigurationEditor
|
|
@@ -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)
|