@jbrowse/plugin-config 2.6.1 → 2.6.3

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.
Files changed (147) hide show
  1. package/dist/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
  2. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
  3. package/dist/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
  4. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
  5. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -2
  6. package/dist/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
  7. package/dist/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
  8. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
  9. package/dist/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
  10. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
  11. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
  12. package/dist/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
  13. package/dist/ConfigurationEditorWidget/index.js +0 -1
  14. package/dist/ConfigurationEditorWidget/model.js +0 -1
  15. package/dist/FromConfigAdapter/FromConfigAdapter.js +0 -1
  16. package/dist/FromConfigAdapter/configSchema.js +0 -1
  17. package/dist/FromConfigAdapter/index.js +0 -1
  18. package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
  19. package/dist/FromConfigRegionsAdapter/configSchema.js +0 -1
  20. package/dist/FromConfigRegionsAdapter/index.js +0 -1
  21. package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
  22. package/dist/FromConfigSequenceAdapter/configSchema.js +0 -1
  23. package/dist/FromConfigSequenceAdapter/index.js +0 -1
  24. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
  25. package/dist/RefNameAliasAdapter/configSchema.js +0 -1
  26. package/dist/RefNameAliasAdapter/index.js +0 -1
  27. package/dist/index.js +0 -1
  28. package/esm/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
  29. package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
  30. package/esm/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
  31. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
  32. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -2
  33. package/esm/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
  34. package/esm/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
  35. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
  36. package/esm/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
  37. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
  38. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
  39. package/esm/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
  40. package/esm/ConfigurationEditorWidget/index.js +0 -1
  41. package/esm/ConfigurationEditorWidget/model.js +0 -1
  42. package/esm/FromConfigAdapter/FromConfigAdapter.js +0 -1
  43. package/esm/FromConfigAdapter/configSchema.js +0 -1
  44. package/esm/FromConfigAdapter/index.js +0 -1
  45. package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
  46. package/esm/FromConfigRegionsAdapter/configSchema.js +0 -1
  47. package/esm/FromConfigRegionsAdapter/index.js +0 -1
  48. package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
  49. package/esm/FromConfigSequenceAdapter/configSchema.js +0 -1
  50. package/esm/FromConfigSequenceAdapter/index.js +0 -1
  51. package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
  52. package/esm/RefNameAliasAdapter/configSchema.js +0 -1
  53. package/esm/RefNameAliasAdapter/index.js +0 -1
  54. package/esm/index.js +0 -1
  55. package/package.json +3 -4
  56. package/dist/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
  57. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
  58. package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
  59. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
  60. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
  61. package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
  62. package/dist/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
  63. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
  64. package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
  65. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
  66. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
  67. package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
  68. package/dist/ConfigurationEditorWidget/index.js.map +0 -1
  69. package/dist/ConfigurationEditorWidget/model.js.map +0 -1
  70. package/dist/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
  71. package/dist/FromConfigAdapter/configSchema.js.map +0 -1
  72. package/dist/FromConfigAdapter/index.js.map +0 -1
  73. package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
  74. package/dist/FromConfigRegionsAdapter/configSchema.js.map +0 -1
  75. package/dist/FromConfigRegionsAdapter/index.js.map +0 -1
  76. package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
  77. package/dist/FromConfigSequenceAdapter/configSchema.js.map +0 -1
  78. package/dist/FromConfigSequenceAdapter/index.js.map +0 -1
  79. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
  80. package/dist/RefNameAliasAdapter/configSchema.js.map +0 -1
  81. package/dist/RefNameAliasAdapter/index.js.map +0 -1
  82. package/dist/index.js.map +0 -1
  83. package/esm/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
  84. package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
  85. package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
  86. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
  87. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
  88. package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
  89. package/esm/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
  90. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
  91. package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
  92. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
  93. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
  94. package/esm/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
  95. package/esm/ConfigurationEditorWidget/index.js.map +0 -1
  96. package/esm/ConfigurationEditorWidget/model.js.map +0 -1
  97. package/esm/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
  98. package/esm/FromConfigAdapter/configSchema.js.map +0 -1
  99. package/esm/FromConfigAdapter/index.js.map +0 -1
  100. package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
  101. package/esm/FromConfigRegionsAdapter/configSchema.js.map +0 -1
  102. package/esm/FromConfigRegionsAdapter/index.js.map +0 -1
  103. package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
  104. package/esm/FromConfigSequenceAdapter/configSchema.js.map +0 -1
  105. package/esm/FromConfigSequenceAdapter/index.js.map +0 -1
  106. package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
  107. package/esm/RefNameAliasAdapter/configSchema.js.map +0 -1
  108. package/esm/RefNameAliasAdapter/index.js.map +0 -1
  109. package/esm/index.js.map +0 -1
  110. package/src/ConfigurationEditorWidget/components/BooleanEditor.tsx +0 -35
  111. package/src/ConfigurationEditorWidget/components/CallbackEditor.tsx +0 -126
  112. package/src/ConfigurationEditorWidget/components/ColorEditor.test.tsx +0 -14
  113. package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +0 -59
  114. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.test.tsx +0 -95
  115. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +0 -167
  116. package/src/ConfigurationEditorWidget/components/ConfigurationTextField.tsx +0 -22
  117. package/src/ConfigurationEditorWidget/components/JsonEditor.tsx +0 -84
  118. package/src/ConfigurationEditorWidget/components/NumberEditor.tsx +0 -34
  119. package/src/ConfigurationEditorWidget/components/NumberMapEditor.tsx +0 -94
  120. package/src/ConfigurationEditorWidget/components/SlotEditor.tsx +0 -236
  121. package/src/ConfigurationEditorWidget/components/StringArrayEditor.tsx +0 -112
  122. package/src/ConfigurationEditorWidget/components/StringArrayMapEditor.tsx +0 -104
  123. package/src/ConfigurationEditorWidget/components/TypeSelector.tsx +0 -43
  124. package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.tsx.snap +0 -2079
  125. package/src/ConfigurationEditorWidget/index.tsx +0 -25
  126. package/src/ConfigurationEditorWidget/model.ts +0 -21
  127. package/src/FromConfigAdapter/FromConfigAdapter.test.ts +0 -56
  128. package/src/FromConfigAdapter/FromConfigAdapter.ts +0 -90
  129. package/src/FromConfigAdapter/configSchema.ts +0 -22
  130. package/src/FromConfigAdapter/index.ts +0 -18
  131. package/src/FromConfigAdapter/test_data/volvox.2bit +0 -0
  132. package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.test.ts +0 -58
  133. package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.ts +0 -81
  134. package/src/FromConfigRegionsAdapter/configSchema.ts +0 -24
  135. package/src/FromConfigRegionsAdapter/index.ts +0 -18
  136. package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.test.ts +0 -64
  137. package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.ts +0 -86
  138. package/src/FromConfigSequenceAdapter/configSchema.ts +0 -21
  139. package/src/FromConfigSequenceAdapter/index.ts +0 -19
  140. package/src/RefNameAliasAdapter/RefNameAliasAdapter.test.ts +0 -18
  141. package/src/RefNameAliasAdapter/RefNameAliasAdapter.ts +0 -30
  142. package/src/RefNameAliasAdapter/configSchema.ts +0 -36
  143. package/src/RefNameAliasAdapter/index.ts +0 -19
  144. package/src/RefNameAliasAdapter/test_data/simple_alias.txt +0 -2
  145. package/src/__snapshots__/index.test.ts.snap +0 -10
  146. package/src/index.test.ts +0 -38
  147. package/src/index.ts +0 -42
@@ -1,84 +0,0 @@
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)
@@ -1,34 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { observer } from 'mobx-react'
3
- import ConfigurationTextField from './ConfigurationTextField'
4
-
5
- export default observer(function ({
6
- slot,
7
- }: {
8
- slot: {
9
- name?: string
10
- value: string
11
- description?: string
12
- set: (val: number) => void
13
- reset?: () => void
14
- }
15
- }) {
16
- const [val, setVal] = useState(slot.value)
17
- useEffect(() => {
18
- const num = Number.parseFloat(val)
19
- if (Number.isNaN(num)) {
20
- slot.reset?.()
21
- } else {
22
- slot.set(num)
23
- }
24
- }, [slot, val])
25
- return (
26
- <ConfigurationTextField
27
- label={slot.name}
28
- helperText={slot.description}
29
- value={val}
30
- type="number"
31
- onChange={evt => setVal(evt.target.value)}
32
- />
33
- )
34
- })
@@ -1,94 +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
- import NumberEditor from './NumberEditor'
20
-
21
- const useStyles = makeStyles()(theme => ({
22
- card: {
23
- marginTop: theme.spacing(1),
24
- },
25
- }))
26
-
27
- export default observer(function ({
28
- slot,
29
- }: {
30
- slot: {
31
- name: string
32
- value: Map<string, string>
33
- remove: (key: string) => void
34
- add: (key: string, val: number) => void
35
- description: string
36
- }
37
- }) {
38
- const { classes } = useStyles()
39
- const [value, setValue] = useState('')
40
- return (
41
- <>
42
- <InputLabel>{slot.name}</InputLabel>
43
- {[...slot.value].map(([key, val]) => (
44
- <Card raised key={key} className={classes.card}>
45
- <CardHeader
46
- title={key}
47
- action={
48
- <IconButton onClick={() => slot.remove(key)}>
49
- <DeleteIcon />
50
- </IconButton>
51
- }
52
- />
53
- <CardContent>
54
- <NumberEditor
55
- slot={{
56
- value: val,
57
- set: (val: number) => slot.add(key, val),
58
- }}
59
- />
60
- </CardContent>
61
- </Card>
62
- ))}
63
- <Card raised className={classes.card}>
64
- <CardHeader
65
- disableTypography
66
- title={
67
- <TextField
68
- fullWidth
69
- value={value}
70
- placeholder="add new"
71
- onChange={event => setValue(event.target.value)}
72
- InputProps={{
73
- endAdornment: (
74
- <InputAdornment position="end">
75
- <IconButton
76
- disabled={value === ''}
77
- onClick={() => {
78
- slot.add(value, 0)
79
- setValue('')
80
- }}
81
- >
82
- <AddIcon />
83
- </IconButton>
84
- </InputAdornment>
85
- ),
86
- }}
87
- />
88
- }
89
- />
90
- </Card>
91
- <FormHelperText>{slot.description}</FormHelperText>
92
- </>
93
- )
94
- })
@@ -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