@jbrowse/plugin-config 2.5.0 → 2.6.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/BooleanEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -2
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -1
- package/dist/ConfigurationEditorWidget/components/JsonEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/NumberEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
- package/dist/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
- package/dist/ConfigurationEditorWidget/index.d.ts +2 -1
- package/dist/ConfigurationEditorWidget/index.js +0 -1
- package/dist/ConfigurationEditorWidget/model.js +0 -1
- package/dist/FromConfigAdapter/FromConfigAdapter.js +0 -1
- package/dist/FromConfigAdapter/configSchema.js +0 -1
- package/dist/FromConfigAdapter/index.js +0 -1
- package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
- package/dist/FromConfigRegionsAdapter/configSchema.js +0 -1
- package/dist/FromConfigRegionsAdapter/index.js +0 -1
- package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
- package/dist/FromConfigSequenceAdapter/configSchema.js +0 -1
- package/dist/FromConfigSequenceAdapter/index.js +0 -1
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
- package/dist/RefNameAliasAdapter/configSchema.js +0 -1
- package/dist/RefNameAliasAdapter/index.js +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -2
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -1
- package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/NumberEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
- package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
- package/esm/ConfigurationEditorWidget/index.d.ts +2 -1
- package/esm/ConfigurationEditorWidget/index.js +0 -1
- package/esm/ConfigurationEditorWidget/model.js +0 -1
- package/esm/FromConfigAdapter/FromConfigAdapter.js +0 -1
- package/esm/FromConfigAdapter/configSchema.js +0 -1
- package/esm/FromConfigAdapter/index.js +0 -1
- package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
- package/esm/FromConfigRegionsAdapter/configSchema.js +0 -1
- package/esm/FromConfigRegionsAdapter/index.js +0 -1
- package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
- package/esm/FromConfigSequenceAdapter/configSchema.js +0 -1
- package/esm/FromConfigSequenceAdapter/index.js +0 -1
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
- package/esm/RefNameAliasAdapter/configSchema.js +0 -1
- package/esm/RefNameAliasAdapter/index.js +0 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +0 -1
- package/package.json +3 -4
- package/dist/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
- package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
- package/dist/ConfigurationEditorWidget/index.js.map +0 -1
- package/dist/ConfigurationEditorWidget/model.js.map +0 -1
- package/dist/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
- package/dist/FromConfigAdapter/configSchema.js.map +0 -1
- package/dist/FromConfigAdapter/index.js.map +0 -1
- package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
- package/dist/FromConfigRegionsAdapter/configSchema.js.map +0 -1
- package/dist/FromConfigRegionsAdapter/index.js.map +0 -1
- package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
- package/dist/FromConfigSequenceAdapter/configSchema.js.map +0 -1
- package/dist/FromConfigSequenceAdapter/index.js.map +0 -1
- package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
- package/dist/RefNameAliasAdapter/configSchema.js.map +0 -1
- package/dist/RefNameAliasAdapter/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
- package/esm/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
- package/esm/ConfigurationEditorWidget/index.js.map +0 -1
- package/esm/ConfigurationEditorWidget/model.js.map +0 -1
- package/esm/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
- package/esm/FromConfigAdapter/configSchema.js.map +0 -1
- package/esm/FromConfigAdapter/index.js.map +0 -1
- package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
- package/esm/FromConfigRegionsAdapter/configSchema.js.map +0 -1
- package/esm/FromConfigRegionsAdapter/index.js.map +0 -1
- package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
- package/esm/FromConfigSequenceAdapter/configSchema.js.map +0 -1
- package/esm/FromConfigSequenceAdapter/index.js.map +0 -1
- package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
- package/esm/RefNameAliasAdapter/configSchema.js.map +0 -1
- package/esm/RefNameAliasAdapter/index.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/src/ConfigurationEditorWidget/components/BooleanEditor.tsx +0 -35
- package/src/ConfigurationEditorWidget/components/CallbackEditor.tsx +0 -126
- package/src/ConfigurationEditorWidget/components/ColorEditor.test.tsx +0 -14
- package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +0 -59
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.test.tsx +0 -95
- package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +0 -167
- package/src/ConfigurationEditorWidget/components/ConfigurationTextField.tsx +0 -22
- package/src/ConfigurationEditorWidget/components/JsonEditor.tsx +0 -84
- package/src/ConfigurationEditorWidget/components/NumberEditor.tsx +0 -34
- package/src/ConfigurationEditorWidget/components/NumberMapEditor.tsx +0 -94
- package/src/ConfigurationEditorWidget/components/SlotEditor.tsx +0 -236
- package/src/ConfigurationEditorWidget/components/StringArrayEditor.tsx +0 -112
- package/src/ConfigurationEditorWidget/components/StringArrayMapEditor.tsx +0 -104
- package/src/ConfigurationEditorWidget/components/TypeSelector.tsx +0 -43
- package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.tsx.snap +0 -2079
- package/src/ConfigurationEditorWidget/index.tsx +0 -25
- package/src/ConfigurationEditorWidget/model.ts +0 -21
- package/src/FromConfigAdapter/FromConfigAdapter.test.ts +0 -56
- package/src/FromConfigAdapter/FromConfigAdapter.ts +0 -90
- package/src/FromConfigAdapter/configSchema.ts +0 -22
- package/src/FromConfigAdapter/index.ts +0 -18
- package/src/FromConfigAdapter/test_data/volvox.2bit +0 -0
- package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.test.ts +0 -58
- package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.ts +0 -81
- package/src/FromConfigRegionsAdapter/configSchema.ts +0 -24
- package/src/FromConfigRegionsAdapter/index.ts +0 -18
- package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.test.ts +0 -64
- package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.ts +0 -86
- package/src/FromConfigSequenceAdapter/configSchema.ts +0 -21
- package/src/FromConfigSequenceAdapter/index.ts +0 -19
- package/src/RefNameAliasAdapter/RefNameAliasAdapter.test.ts +0 -18
- package/src/RefNameAliasAdapter/RefNameAliasAdapter.ts +0 -30
- package/src/RefNameAliasAdapter/configSchema.ts +0 -36
- package/src/RefNameAliasAdapter/index.ts +0 -19
- package/src/RefNameAliasAdapter/test_data/simple_alias.txt +0 -2
- package/src/__snapshots__/index.test.ts.snap +0 -10
- package/src/index.test.ts +0 -38
- package/src/index.ts +0 -42
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
import { getPropertyMembers, IAnyType } from 'mobx-state-tree'
|
|
4
|
-
import { getEnv, FileLocation } from '@jbrowse/core/util'
|
|
5
|
-
import { FileSelector } from '@jbrowse/core/ui'
|
|
6
|
-
import {
|
|
7
|
-
getSubType,
|
|
8
|
-
getUnionSubTypes,
|
|
9
|
-
ILiteralType,
|
|
10
|
-
} from '@jbrowse/core/util/mst-reflection'
|
|
11
|
-
import { IconButton, MenuItem, Paper, SvgIcon, TextField } from '@mui/material'
|
|
12
|
-
import { makeStyles } from 'tss-react/mui'
|
|
13
|
-
|
|
14
|
-
// icons
|
|
15
|
-
import RadioButtonUncheckedIcon from '@mui/icons-material/RadioButtonUnchecked'
|
|
16
|
-
|
|
17
|
-
// locals
|
|
18
|
-
import StringArrayEditor from './StringArrayEditor'
|
|
19
|
-
import CallbackEditor from './CallbackEditor'
|
|
20
|
-
import ColorEditor from './ColorEditor'
|
|
21
|
-
import JsonEditor from './JsonEditor'
|
|
22
|
-
import StringArrayMapEditor from './StringArrayMapEditor'
|
|
23
|
-
import ConfigurationTextField from './ConfigurationTextField'
|
|
24
|
-
import NumberMapEditor from './NumberMapEditor'
|
|
25
|
-
import NumberEditor from './NumberEditor'
|
|
26
|
-
import BooleanEditor from './BooleanEditor'
|
|
27
|
-
import {
|
|
28
|
-
AnyConfigurationSlot,
|
|
29
|
-
AnyConfigurationSlotType,
|
|
30
|
-
} from '@jbrowse/core/configuration'
|
|
31
|
-
|
|
32
|
-
const StringEditor = observer(
|
|
33
|
-
({
|
|
34
|
-
slot,
|
|
35
|
-
}: {
|
|
36
|
-
slot: {
|
|
37
|
-
name: string
|
|
38
|
-
description: string
|
|
39
|
-
value: string
|
|
40
|
-
set: (arg: string) => void
|
|
41
|
-
}
|
|
42
|
-
}) => (
|
|
43
|
-
<ConfigurationTextField
|
|
44
|
-
label={slot.name}
|
|
45
|
-
helperText={slot.description}
|
|
46
|
-
value={slot.value}
|
|
47
|
-
onChange={evt => slot.set(evt.target.value)}
|
|
48
|
-
/>
|
|
49
|
-
),
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
const TextEditor = observer(
|
|
53
|
-
({
|
|
54
|
-
slot,
|
|
55
|
-
}: {
|
|
56
|
-
slot: {
|
|
57
|
-
name: string
|
|
58
|
-
description: string
|
|
59
|
-
value: string
|
|
60
|
-
set: (arg: string) => void
|
|
61
|
-
}
|
|
62
|
-
}) => (
|
|
63
|
-
<TextField
|
|
64
|
-
label={slot.name}
|
|
65
|
-
helperText={slot.description}
|
|
66
|
-
multiline
|
|
67
|
-
value={slot.value}
|
|
68
|
-
onChange={evt => slot.set(evt.target.value)}
|
|
69
|
-
/>
|
|
70
|
-
),
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
// checked checkbox, looks like a styled (x)
|
|
74
|
-
const SvgCheckbox = () => (
|
|
75
|
-
<SvgIcon>
|
|
76
|
-
<path d="M20.41,3C21.8,5.71 22.35,8.84 22,12C21.8,15.16 20.7,18.29 18.83,21L17.3,20C18.91,17.57 19.85,14.8 20,12C20.34,9.2 19.89,6.43 18.7,4L20.41,3M5.17,3L6.7,4C5.09,6.43 4.15,9.2 4,12C3.66,14.8 4.12,17.57 5.3,20L3.61,21C2.21,18.29 1.65,15.17 2,12C2.2,8.84 3.3,5.71 5.17,3M12.08,10.68L14.4,7.45H16.93L13.15,12.45L15.35,17.37H13.09L11.71,14L9.28,17.33H6.76L10.66,12.21L8.53,7.45H10.8L12.08,10.68Z" />
|
|
77
|
-
</SvgIcon>
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
const IntegerEditor = observer(
|
|
81
|
-
({
|
|
82
|
-
slot,
|
|
83
|
-
}: {
|
|
84
|
-
slot: {
|
|
85
|
-
name: string
|
|
86
|
-
value: string
|
|
87
|
-
description: string
|
|
88
|
-
set: (num: number) => void
|
|
89
|
-
}
|
|
90
|
-
}) => {
|
|
91
|
-
const [val, setVal] = useState(slot.value)
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
const num = Number.parseInt(val, 10)
|
|
94
|
-
if (!Number.isNaN(num)) {
|
|
95
|
-
slot.set(num)
|
|
96
|
-
}
|
|
97
|
-
}, [slot, val])
|
|
98
|
-
return (
|
|
99
|
-
<ConfigurationTextField
|
|
100
|
-
label={slot.name}
|
|
101
|
-
helperText={slot.description}
|
|
102
|
-
value={val}
|
|
103
|
-
type="number"
|
|
104
|
-
onChange={evt => setVal(evt.target.value)}
|
|
105
|
-
/>
|
|
106
|
-
)
|
|
107
|
-
},
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
const StringEnumEditor = observer(function ({
|
|
111
|
-
slot,
|
|
112
|
-
slotSchema,
|
|
113
|
-
}: {
|
|
114
|
-
slot: AnyConfigurationSlot
|
|
115
|
-
slotSchema: AnyConfigurationSlotType
|
|
116
|
-
}) {
|
|
117
|
-
const p = getPropertyMembers(getSubType(slotSchema))
|
|
118
|
-
const choices = getUnionSubTypes(
|
|
119
|
-
getUnionSubTypes(getSubType(p.properties.value))[1],
|
|
120
|
-
).map(t => (t as ILiteralType<string>).value)
|
|
121
|
-
|
|
122
|
-
return (
|
|
123
|
-
<ConfigurationTextField
|
|
124
|
-
value={slot.value}
|
|
125
|
-
label={slot.name}
|
|
126
|
-
select
|
|
127
|
-
helperText={slot.description}
|
|
128
|
-
onChange={evt => slot.set(evt.target.value)}
|
|
129
|
-
>
|
|
130
|
-
{choices.map(str => (
|
|
131
|
-
<MenuItem key={str} value={str}>
|
|
132
|
-
{str}
|
|
133
|
-
</MenuItem>
|
|
134
|
-
))}
|
|
135
|
-
</ConfigurationTextField>
|
|
136
|
-
)
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
const FileSelectorWrapper = observer(function ({
|
|
140
|
-
slot,
|
|
141
|
-
}: {
|
|
142
|
-
slot: {
|
|
143
|
-
name: string
|
|
144
|
-
value: FileLocation
|
|
145
|
-
set: (arg: FileLocation) => void
|
|
146
|
-
description: string
|
|
147
|
-
}
|
|
148
|
-
}) {
|
|
149
|
-
return (
|
|
150
|
-
<FileSelector
|
|
151
|
-
location={slot.value}
|
|
152
|
-
setLocation={location => slot.set(location)}
|
|
153
|
-
name={slot.name}
|
|
154
|
-
description={slot.description}
|
|
155
|
-
rootModel={getEnv(slot).pluginManager?.rootModel}
|
|
156
|
-
/>
|
|
157
|
-
)
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
const valueComponents = {
|
|
161
|
-
string: StringEditor,
|
|
162
|
-
text: TextEditor,
|
|
163
|
-
fileLocation: FileSelectorWrapper,
|
|
164
|
-
stringArray: StringArrayEditor,
|
|
165
|
-
stringArrayMap: StringArrayMapEditor,
|
|
166
|
-
numberMap: NumberMapEditor,
|
|
167
|
-
number: NumberEditor,
|
|
168
|
-
integer: IntegerEditor,
|
|
169
|
-
color: ColorEditor,
|
|
170
|
-
stringEnum: StringEnumEditor,
|
|
171
|
-
boolean: BooleanEditor,
|
|
172
|
-
frozen: JsonEditor,
|
|
173
|
-
configRelationships: JsonEditor,
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export const useSlotEditorStyles = makeStyles()(theme => ({
|
|
177
|
-
paper: {
|
|
178
|
-
display: 'flex',
|
|
179
|
-
marginBottom: theme.spacing(2),
|
|
180
|
-
position: 'relative',
|
|
181
|
-
},
|
|
182
|
-
paperContent: {
|
|
183
|
-
width: '100%',
|
|
184
|
-
},
|
|
185
|
-
slotModeSwitch: {
|
|
186
|
-
width: 24,
|
|
187
|
-
background: theme.palette.secondary.light,
|
|
188
|
-
display: 'flex',
|
|
189
|
-
justifyContent: 'center',
|
|
190
|
-
alignItems: 'center',
|
|
191
|
-
},
|
|
192
|
-
}))
|
|
193
|
-
|
|
194
|
-
const SlotEditor = observer(
|
|
195
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
196
|
-
({ slot, slotSchema }: { slot: any; slotSchema: IAnyType }) => {
|
|
197
|
-
const { classes } = useSlotEditorStyles()
|
|
198
|
-
const { type } = slot
|
|
199
|
-
let ValueComponent = slot.isCallback
|
|
200
|
-
? CallbackEditor
|
|
201
|
-
: // @ts-expect-error
|
|
202
|
-
valueComponents[type]
|
|
203
|
-
if (!ValueComponent) {
|
|
204
|
-
console.warn(`no slot editor defined for ${type}, editing as string`)
|
|
205
|
-
ValueComponent = StringEditor
|
|
206
|
-
}
|
|
207
|
-
if (!(type in valueComponents)) {
|
|
208
|
-
console.warn(`SlotEditor needs to implement ${type}`)
|
|
209
|
-
}
|
|
210
|
-
return (
|
|
211
|
-
<Paper className={classes.paper}>
|
|
212
|
-
<div className={classes.paperContent}>
|
|
213
|
-
<ValueComponent slot={slot} slotSchema={slotSchema} />
|
|
214
|
-
</div>
|
|
215
|
-
<div className={classes.slotModeSwitch}>
|
|
216
|
-
{slot.contextVariable.length ? (
|
|
217
|
-
<IconButton
|
|
218
|
-
onClick={() =>
|
|
219
|
-
slot.isCallback
|
|
220
|
-
? slot.convertToValue()
|
|
221
|
-
: slot.convertToCallback()
|
|
222
|
-
}
|
|
223
|
-
title={`convert to ${
|
|
224
|
-
slot.isCallback ? 'regular value' : 'callback'
|
|
225
|
-
}`}
|
|
226
|
-
>
|
|
227
|
-
{slot.isCallback ? <SvgCheckbox /> : <RadioButtonUncheckedIcon />}
|
|
228
|
-
</IconButton>
|
|
229
|
-
) : null}
|
|
230
|
-
</div>
|
|
231
|
-
</Paper>
|
|
232
|
-
)
|
|
233
|
-
},
|
|
234
|
-
)
|
|
235
|
-
|
|
236
|
-
export default SlotEditor
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
Button,
|
|
6
|
-
FormHelperText,
|
|
7
|
-
IconButton,
|
|
8
|
-
InputAdornment,
|
|
9
|
-
InputLabel,
|
|
10
|
-
List,
|
|
11
|
-
ListItem,
|
|
12
|
-
TextField,
|
|
13
|
-
} from '@mui/material'
|
|
14
|
-
|
|
15
|
-
// icons
|
|
16
|
-
import DeleteIcon from '@mui/icons-material/Delete'
|
|
17
|
-
|
|
18
|
-
const StringArrayEditor = observer(
|
|
19
|
-
({
|
|
20
|
-
slot,
|
|
21
|
-
}: {
|
|
22
|
-
slot: {
|
|
23
|
-
name: string
|
|
24
|
-
value: string[]
|
|
25
|
-
setAtIndex: Function
|
|
26
|
-
removeAtIndex: Function
|
|
27
|
-
add: Function
|
|
28
|
-
description: string
|
|
29
|
-
}
|
|
30
|
-
}) => {
|
|
31
|
-
const [value, setValue] = useState('')
|
|
32
|
-
const [addNew, setAddNew] = useState(false)
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
{slot.name ? <InputLabel>{slot.name}</InputLabel> : null}
|
|
36
|
-
<List disablePadding>
|
|
37
|
-
{slot.value.map((val, idx) => (
|
|
38
|
-
<ListItem key={idx} disableGutters>
|
|
39
|
-
<TextField
|
|
40
|
-
value={val}
|
|
41
|
-
onChange={evt => slot.setAtIndex(idx, evt.target.value)}
|
|
42
|
-
InputProps={{
|
|
43
|
-
endAdornment: (
|
|
44
|
-
<InputAdornment position="end">
|
|
45
|
-
<IconButton onClick={() => slot.removeAtIndex(idx)}>
|
|
46
|
-
<DeleteIcon />
|
|
47
|
-
</IconButton>
|
|
48
|
-
</InputAdornment>
|
|
49
|
-
),
|
|
50
|
-
}}
|
|
51
|
-
/>
|
|
52
|
-
</ListItem>
|
|
53
|
-
))}
|
|
54
|
-
|
|
55
|
-
{addNew ? (
|
|
56
|
-
<ListItem disableGutters>
|
|
57
|
-
<TextField
|
|
58
|
-
value={value}
|
|
59
|
-
placeholder="add new"
|
|
60
|
-
onChange={event => setValue(event.target.value)}
|
|
61
|
-
InputProps={{
|
|
62
|
-
endAdornment: (
|
|
63
|
-
<InputAdornment position="end">
|
|
64
|
-
<>
|
|
65
|
-
<Button
|
|
66
|
-
color="primary"
|
|
67
|
-
variant="contained"
|
|
68
|
-
style={{ margin: 2 }}
|
|
69
|
-
data-testid={`stringArrayAdd-${slot.name}`}
|
|
70
|
-
onClick={() => {
|
|
71
|
-
setAddNew(false)
|
|
72
|
-
slot.add(value)
|
|
73
|
-
setValue('')
|
|
74
|
-
}}
|
|
75
|
-
>
|
|
76
|
-
OK
|
|
77
|
-
</Button>
|
|
78
|
-
<Button
|
|
79
|
-
color="primary"
|
|
80
|
-
variant="contained"
|
|
81
|
-
style={{ margin: 2 }}
|
|
82
|
-
onClick={() => {
|
|
83
|
-
setAddNew(false)
|
|
84
|
-
setValue('')
|
|
85
|
-
}}
|
|
86
|
-
>
|
|
87
|
-
Cancel
|
|
88
|
-
</Button>
|
|
89
|
-
</>
|
|
90
|
-
</InputAdornment>
|
|
91
|
-
),
|
|
92
|
-
}}
|
|
93
|
-
/>
|
|
94
|
-
</ListItem>
|
|
95
|
-
) : null}
|
|
96
|
-
<Button
|
|
97
|
-
color="primary"
|
|
98
|
-
variant="contained"
|
|
99
|
-
style={{ margin: 4 }}
|
|
100
|
-
disabled={addNew}
|
|
101
|
-
onClick={() => setAddNew(true)}
|
|
102
|
-
>
|
|
103
|
-
Add item
|
|
104
|
-
</Button>
|
|
105
|
-
</List>
|
|
106
|
-
<FormHelperText>{slot.description}</FormHelperText>
|
|
107
|
-
</>
|
|
108
|
-
)
|
|
109
|
-
},
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
export default StringArrayEditor
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
Card,
|
|
6
|
-
CardContent,
|
|
7
|
-
CardHeader,
|
|
8
|
-
FormHelperText,
|
|
9
|
-
IconButton,
|
|
10
|
-
InputAdornment,
|
|
11
|
-
InputLabel,
|
|
12
|
-
TextField,
|
|
13
|
-
} from '@mui/material'
|
|
14
|
-
import { makeStyles } from 'tss-react/mui'
|
|
15
|
-
|
|
16
|
-
// icons
|
|
17
|
-
import DeleteIcon from '@mui/icons-material/Delete'
|
|
18
|
-
import AddIcon from '@mui/icons-material/Add'
|
|
19
|
-
|
|
20
|
-
// locals
|
|
21
|
-
import StringArrayEditor from './StringArrayEditor'
|
|
22
|
-
|
|
23
|
-
const useStyles = makeStyles()(theme => ({
|
|
24
|
-
card: {
|
|
25
|
-
marginTop: theme.spacing(1),
|
|
26
|
-
},
|
|
27
|
-
}))
|
|
28
|
-
|
|
29
|
-
export default observer(function ({
|
|
30
|
-
slot,
|
|
31
|
-
}: {
|
|
32
|
-
slot: {
|
|
33
|
-
name: string
|
|
34
|
-
value: Map<string, string[]>
|
|
35
|
-
remove: (key: string) => void
|
|
36
|
-
add: (key: string, val: string[]) => void
|
|
37
|
-
description: string
|
|
38
|
-
setAtKeyIndex: (key: string, idx: number, val: string) => void
|
|
39
|
-
removeAtKeyIndex: (key: string, idx: number) => void
|
|
40
|
-
addToKey: (key: string, val: string) => void
|
|
41
|
-
}
|
|
42
|
-
}) {
|
|
43
|
-
const { classes } = useStyles()
|
|
44
|
-
const [value, setValue] = useState('')
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<InputLabel>{slot.name}</InputLabel>
|
|
48
|
-
{[...slot.value].map(([key, val]) => (
|
|
49
|
-
<Card raised key={key} className={classes.card}>
|
|
50
|
-
<CardHeader
|
|
51
|
-
title={key}
|
|
52
|
-
action={
|
|
53
|
-
<IconButton onClick={() => slot.remove(key)}>
|
|
54
|
-
<DeleteIcon />
|
|
55
|
-
</IconButton>
|
|
56
|
-
}
|
|
57
|
-
/>
|
|
58
|
-
<CardContent>
|
|
59
|
-
<StringArrayEditor
|
|
60
|
-
slot={{
|
|
61
|
-
name: slot.name,
|
|
62
|
-
value: val,
|
|
63
|
-
description: `Values associated with entry ${key}`,
|
|
64
|
-
setAtIndex: (idx: number, val: string) =>
|
|
65
|
-
slot.setAtKeyIndex(key, idx, val),
|
|
66
|
-
removeAtIndex: (idx: number) => slot.removeAtKeyIndex(key, idx),
|
|
67
|
-
add: (val: string) => slot.addToKey(key, val),
|
|
68
|
-
}}
|
|
69
|
-
/>
|
|
70
|
-
</CardContent>
|
|
71
|
-
</Card>
|
|
72
|
-
))}
|
|
73
|
-
<Card raised className={classes.card}>
|
|
74
|
-
<CardHeader
|
|
75
|
-
disableTypography
|
|
76
|
-
title={
|
|
77
|
-
<TextField
|
|
78
|
-
fullWidth
|
|
79
|
-
value={value}
|
|
80
|
-
placeholder="add new"
|
|
81
|
-
onChange={event => setValue(event.target.value)}
|
|
82
|
-
InputProps={{
|
|
83
|
-
endAdornment: (
|
|
84
|
-
<InputAdornment position="end">
|
|
85
|
-
<IconButton
|
|
86
|
-
disabled={value === ''}
|
|
87
|
-
onClick={() => {
|
|
88
|
-
slot.add(value, [])
|
|
89
|
-
setValue('')
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
<AddIcon />
|
|
93
|
-
</IconButton>
|
|
94
|
-
</InputAdornment>
|
|
95
|
-
),
|
|
96
|
-
}}
|
|
97
|
-
/>
|
|
98
|
-
}
|
|
99
|
-
/>
|
|
100
|
-
</Card>
|
|
101
|
-
<FormHelperText>{slot.description}</FormHelperText>
|
|
102
|
-
</>
|
|
103
|
-
)
|
|
104
|
-
})
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { MenuItem, Paper, TextField } from '@mui/material'
|
|
3
|
-
import { observer } from 'mobx-react'
|
|
4
|
-
import { useSlotEditorStyles } from './SlotEditor'
|
|
5
|
-
import { AnyConfigurationModel } from '@jbrowse/core/configuration'
|
|
6
|
-
|
|
7
|
-
const TypeSelector = observer(
|
|
8
|
-
({
|
|
9
|
-
typeNameChoices,
|
|
10
|
-
slot,
|
|
11
|
-
slotName,
|
|
12
|
-
onChange,
|
|
13
|
-
}: {
|
|
14
|
-
typeNameChoices: string[]
|
|
15
|
-
slot: AnyConfigurationModel
|
|
16
|
-
slotName: string
|
|
17
|
-
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
|
|
18
|
-
}) => {
|
|
19
|
-
const { classes } = useSlotEditorStyles()
|
|
20
|
-
return (
|
|
21
|
-
<Paper className={classes.paper}>
|
|
22
|
-
<div className={classes.paperContent}>
|
|
23
|
-
<TextField
|
|
24
|
-
value={slot.type}
|
|
25
|
-
label="Type"
|
|
26
|
-
select
|
|
27
|
-
helperText={`Type of ${slotName} to use`}
|
|
28
|
-
fullWidth
|
|
29
|
-
onChange={onChange}
|
|
30
|
-
>
|
|
31
|
-
{typeNameChoices.map(str => (
|
|
32
|
-
<MenuItem key={str} value={str}>
|
|
33
|
-
{str}
|
|
34
|
-
</MenuItem>
|
|
35
|
-
))}
|
|
36
|
-
</TextField>
|
|
37
|
-
</div>
|
|
38
|
-
</Paper>
|
|
39
|
-
)
|
|
40
|
-
},
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
export default TypeSelector
|