@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.
Files changed (175) hide show
  1. package/dist/ConfigurationEditorWidget/components/BooleanEditor.d.ts +2 -1
  2. package/dist/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
  3. package/dist/ConfigurationEditorWidget/components/CallbackEditor.d.ts +2 -1
  4. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
  5. package/dist/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -2
  6. package/dist/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
  7. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -1
  8. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
  9. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +2 -1
  10. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -1
  11. package/dist/ConfigurationEditorWidget/components/JsonEditor.d.ts +2 -1
  12. package/dist/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
  13. package/dist/ConfigurationEditorWidget/components/NumberEditor.d.ts +2 -1
  14. package/dist/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
  15. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +2 -1
  16. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
  17. package/dist/ConfigurationEditorWidget/components/SlotEditor.d.ts +2 -1
  18. package/dist/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
  19. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +2 -1
  20. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
  21. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +2 -1
  22. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
  23. package/dist/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
  24. package/dist/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
  25. package/dist/ConfigurationEditorWidget/index.d.ts +2 -1
  26. package/dist/ConfigurationEditorWidget/index.js +0 -1
  27. package/dist/ConfigurationEditorWidget/model.js +0 -1
  28. package/dist/FromConfigAdapter/FromConfigAdapter.js +0 -1
  29. package/dist/FromConfigAdapter/configSchema.js +0 -1
  30. package/dist/FromConfigAdapter/index.js +0 -1
  31. package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
  32. package/dist/FromConfigRegionsAdapter/configSchema.js +0 -1
  33. package/dist/FromConfigRegionsAdapter/index.js +0 -1
  34. package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
  35. package/dist/FromConfigSequenceAdapter/configSchema.js +0 -1
  36. package/dist/FromConfigSequenceAdapter/index.js +0 -1
  37. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
  38. package/dist/RefNameAliasAdapter/configSchema.js +0 -1
  39. package/dist/RefNameAliasAdapter/index.js +0 -1
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +0 -1
  42. package/esm/ConfigurationEditorWidget/components/BooleanEditor.d.ts +2 -1
  43. package/esm/ConfigurationEditorWidget/components/BooleanEditor.js +0 -1
  44. package/esm/ConfigurationEditorWidget/components/CallbackEditor.d.ts +2 -1
  45. package/esm/ConfigurationEditorWidget/components/CallbackEditor.js +0 -1
  46. package/esm/ConfigurationEditorWidget/components/ColorEditor.d.ts +3 -2
  47. package/esm/ConfigurationEditorWidget/components/ColorEditor.js +0 -1
  48. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.d.ts +2 -1
  49. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js +0 -1
  50. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.d.ts +2 -1
  51. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js +0 -1
  52. package/esm/ConfigurationEditorWidget/components/JsonEditor.d.ts +2 -1
  53. package/esm/ConfigurationEditorWidget/components/JsonEditor.js +0 -1
  54. package/esm/ConfigurationEditorWidget/components/NumberEditor.d.ts +2 -1
  55. package/esm/ConfigurationEditorWidget/components/NumberEditor.js +0 -1
  56. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.d.ts +2 -1
  57. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js +0 -1
  58. package/esm/ConfigurationEditorWidget/components/SlotEditor.d.ts +2 -1
  59. package/esm/ConfigurationEditorWidget/components/SlotEditor.js +0 -1
  60. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.d.ts +2 -1
  61. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js +0 -1
  62. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.d.ts +2 -1
  63. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js +0 -1
  64. package/esm/ConfigurationEditorWidget/components/TypeSelector.d.ts +1 -1
  65. package/esm/ConfigurationEditorWidget/components/TypeSelector.js +0 -1
  66. package/esm/ConfigurationEditorWidget/index.d.ts +2 -1
  67. package/esm/ConfigurationEditorWidget/index.js +0 -1
  68. package/esm/ConfigurationEditorWidget/model.js +0 -1
  69. package/esm/FromConfigAdapter/FromConfigAdapter.js +0 -1
  70. package/esm/FromConfigAdapter/configSchema.js +0 -1
  71. package/esm/FromConfigAdapter/index.js +0 -1
  72. package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js +0 -1
  73. package/esm/FromConfigRegionsAdapter/configSchema.js +0 -1
  74. package/esm/FromConfigRegionsAdapter/index.js +0 -1
  75. package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js +0 -1
  76. package/esm/FromConfigSequenceAdapter/configSchema.js +0 -1
  77. package/esm/FromConfigSequenceAdapter/index.js +0 -1
  78. package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js +0 -1
  79. package/esm/RefNameAliasAdapter/configSchema.js +0 -1
  80. package/esm/RefNameAliasAdapter/index.js +0 -1
  81. package/esm/index.d.ts +1 -1
  82. package/esm/index.js +0 -1
  83. package/package.json +3 -4
  84. package/dist/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
  85. package/dist/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
  86. package/dist/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
  87. package/dist/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
  88. package/dist/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
  89. package/dist/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
  90. package/dist/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
  91. package/dist/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
  92. package/dist/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
  93. package/dist/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
  94. package/dist/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
  95. package/dist/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
  96. package/dist/ConfigurationEditorWidget/index.js.map +0 -1
  97. package/dist/ConfigurationEditorWidget/model.js.map +0 -1
  98. package/dist/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
  99. package/dist/FromConfigAdapter/configSchema.js.map +0 -1
  100. package/dist/FromConfigAdapter/index.js.map +0 -1
  101. package/dist/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
  102. package/dist/FromConfigRegionsAdapter/configSchema.js.map +0 -1
  103. package/dist/FromConfigRegionsAdapter/index.js.map +0 -1
  104. package/dist/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
  105. package/dist/FromConfigSequenceAdapter/configSchema.js.map +0 -1
  106. package/dist/FromConfigSequenceAdapter/index.js.map +0 -1
  107. package/dist/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
  108. package/dist/RefNameAliasAdapter/configSchema.js.map +0 -1
  109. package/dist/RefNameAliasAdapter/index.js.map +0 -1
  110. package/dist/index.js.map +0 -1
  111. package/esm/ConfigurationEditorWidget/components/BooleanEditor.js.map +0 -1
  112. package/esm/ConfigurationEditorWidget/components/CallbackEditor.js.map +0 -1
  113. package/esm/ConfigurationEditorWidget/components/ColorEditor.js.map +0 -1
  114. package/esm/ConfigurationEditorWidget/components/ConfigurationEditor.js.map +0 -1
  115. package/esm/ConfigurationEditorWidget/components/ConfigurationTextField.js.map +0 -1
  116. package/esm/ConfigurationEditorWidget/components/JsonEditor.js.map +0 -1
  117. package/esm/ConfigurationEditorWidget/components/NumberEditor.js.map +0 -1
  118. package/esm/ConfigurationEditorWidget/components/NumberMapEditor.js.map +0 -1
  119. package/esm/ConfigurationEditorWidget/components/SlotEditor.js.map +0 -1
  120. package/esm/ConfigurationEditorWidget/components/StringArrayEditor.js.map +0 -1
  121. package/esm/ConfigurationEditorWidget/components/StringArrayMapEditor.js.map +0 -1
  122. package/esm/ConfigurationEditorWidget/components/TypeSelector.js.map +0 -1
  123. package/esm/ConfigurationEditorWidget/index.js.map +0 -1
  124. package/esm/ConfigurationEditorWidget/model.js.map +0 -1
  125. package/esm/FromConfigAdapter/FromConfigAdapter.js.map +0 -1
  126. package/esm/FromConfigAdapter/configSchema.js.map +0 -1
  127. package/esm/FromConfigAdapter/index.js.map +0 -1
  128. package/esm/FromConfigRegionsAdapter/FromConfigRegionsAdapter.js.map +0 -1
  129. package/esm/FromConfigRegionsAdapter/configSchema.js.map +0 -1
  130. package/esm/FromConfigRegionsAdapter/index.js.map +0 -1
  131. package/esm/FromConfigSequenceAdapter/FromConfigSequenceAdapter.js.map +0 -1
  132. package/esm/FromConfigSequenceAdapter/configSchema.js.map +0 -1
  133. package/esm/FromConfigSequenceAdapter/index.js.map +0 -1
  134. package/esm/RefNameAliasAdapter/RefNameAliasAdapter.js.map +0 -1
  135. package/esm/RefNameAliasAdapter/configSchema.js.map +0 -1
  136. package/esm/RefNameAliasAdapter/index.js.map +0 -1
  137. package/esm/index.js.map +0 -1
  138. package/src/ConfigurationEditorWidget/components/BooleanEditor.tsx +0 -35
  139. package/src/ConfigurationEditorWidget/components/CallbackEditor.tsx +0 -126
  140. package/src/ConfigurationEditorWidget/components/ColorEditor.test.tsx +0 -14
  141. package/src/ConfigurationEditorWidget/components/ColorEditor.tsx +0 -59
  142. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.test.tsx +0 -95
  143. package/src/ConfigurationEditorWidget/components/ConfigurationEditor.tsx +0 -167
  144. package/src/ConfigurationEditorWidget/components/ConfigurationTextField.tsx +0 -22
  145. package/src/ConfigurationEditorWidget/components/JsonEditor.tsx +0 -84
  146. package/src/ConfigurationEditorWidget/components/NumberEditor.tsx +0 -34
  147. package/src/ConfigurationEditorWidget/components/NumberMapEditor.tsx +0 -94
  148. package/src/ConfigurationEditorWidget/components/SlotEditor.tsx +0 -236
  149. package/src/ConfigurationEditorWidget/components/StringArrayEditor.tsx +0 -112
  150. package/src/ConfigurationEditorWidget/components/StringArrayMapEditor.tsx +0 -104
  151. package/src/ConfigurationEditorWidget/components/TypeSelector.tsx +0 -43
  152. package/src/ConfigurationEditorWidget/components/__snapshots__/ConfigurationEditor.test.tsx.snap +0 -2079
  153. package/src/ConfigurationEditorWidget/index.tsx +0 -25
  154. package/src/ConfigurationEditorWidget/model.ts +0 -21
  155. package/src/FromConfigAdapter/FromConfigAdapter.test.ts +0 -56
  156. package/src/FromConfigAdapter/FromConfigAdapter.ts +0 -90
  157. package/src/FromConfigAdapter/configSchema.ts +0 -22
  158. package/src/FromConfigAdapter/index.ts +0 -18
  159. package/src/FromConfigAdapter/test_data/volvox.2bit +0 -0
  160. package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.test.ts +0 -58
  161. package/src/FromConfigRegionsAdapter/FromConfigRegionsAdapter.ts +0 -81
  162. package/src/FromConfigRegionsAdapter/configSchema.ts +0 -24
  163. package/src/FromConfigRegionsAdapter/index.ts +0 -18
  164. package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.test.ts +0 -64
  165. package/src/FromConfigSequenceAdapter/FromConfigSequenceAdapter.ts +0 -86
  166. package/src/FromConfigSequenceAdapter/configSchema.ts +0 -21
  167. package/src/FromConfigSequenceAdapter/index.ts +0 -19
  168. package/src/RefNameAliasAdapter/RefNameAliasAdapter.test.ts +0 -18
  169. package/src/RefNameAliasAdapter/RefNameAliasAdapter.ts +0 -30
  170. package/src/RefNameAliasAdapter/configSchema.ts +0 -36
  171. package/src/RefNameAliasAdapter/index.ts +0 -19
  172. package/src/RefNameAliasAdapter/test_data/simple_alias.txt +0 -2
  173. package/src/__snapshots__/index.test.ts.snap +0 -10
  174. package/src/index.test.ts +0 -38
  175. package/src/index.ts +0 -42
@@ -1,126 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import { Tooltip, IconButton, TextField } from '@mui/material'
3
- import { useDebounce } from '@jbrowse/core/util'
4
- import { stringToJexlExpression } from '@jbrowse/core/util/jexlStrings'
5
- import { getEnv } from 'mobx-state-tree'
6
- import { observer } from 'mobx-react'
7
- import { makeStyles } from 'tss-react/mui'
8
-
9
- // icons
10
- import HelpIcon from '@mui/icons-material/Help'
11
-
12
- // Optimize by using system default fonts:
13
- // https://css-tricks.com/snippets/css/font-stacks/
14
- const fontFamily =
15
- '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'
16
-
17
- const useStyles = makeStyles()(theme => ({
18
- callbackEditor: {
19
- marginTop: '16px',
20
- borderBottom: `1px solid ${theme.palette.divider}`,
21
- width: '100%',
22
- fontFamily,
23
- },
24
- textAreaFont: {
25
- fontFamily,
26
- },
27
- callbackContainer: {
28
- width: '100%',
29
- overflowX: 'auto',
30
- },
31
-
32
- error: {
33
- color: 'red',
34
- fontSize: '0.8em',
35
- },
36
- }))
37
-
38
- function CallbackEditor({
39
- slot,
40
- }: {
41
- slot: {
42
- set: (arg: string) => void
43
- description: string
44
- name: string
45
- value: string
46
- contextVariable: string
47
- }
48
- }) {
49
- const { classes } = useStyles()
50
-
51
- const [code, setCode] = useState(slot.value)
52
- const [error, setCodeError] = useState<unknown>()
53
- const debouncedCode = useDebounce(code, 400)
54
-
55
- useEffect(() => {
56
- try {
57
- const jexlDebouncedCode = debouncedCode.startsWith('jexl:')
58
- ? debouncedCode
59
- : `jexl:${debouncedCode}`
60
-
61
- if (jexlDebouncedCode === 'jexl:') {
62
- throw new Error('Empty jexl expression is not valid')
63
- }
64
- stringToJexlExpression(
65
- jexlDebouncedCode,
66
- getEnv(slot).pluginManager?.jexl,
67
- )
68
- slot.set(jexlDebouncedCode)
69
- setCodeError(undefined)
70
- } catch (e) {
71
- console.error({ e })
72
- setCodeError(e)
73
- }
74
- }, [debouncedCode, slot])
75
-
76
- // if default value is a callback, will have to remove jexl:
77
- // do this last
78
- return (
79
- <>
80
- {error ? <p className={classes.error}>{`${error}`}</p> : null}
81
- <div className={classes.callbackContainer}>
82
- <TextField
83
- multiline
84
- className={classes.callbackEditor}
85
- value={code.startsWith('jexl:') ? code.split('jexl:')[1] : code}
86
- onChange={event => setCode(event.target.value)}
87
- style={{ background: error ? '#fdd' : undefined }}
88
- InputProps={{
89
- classes: {
90
- input: classes.textAreaFont,
91
- },
92
- }}
93
- />
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
104
- >
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>
122
- </>
123
- )
124
- }
125
-
126
- export default observer(CallbackEditor)
@@ -1,14 +0,0 @@
1
- import React from 'react'
2
- import { render, fireEvent } from '@testing-library/react'
3
-
4
- import { ColorSlot } from './ColorEditor'
5
-
6
- test('can change value via the text field', () => {
7
- const myfn = jest.fn()
8
- const { getByDisplayValue } = render(
9
- <ColorSlot value="green" onChange={myfn} />,
10
- )
11
- const ret = getByDisplayValue('green')
12
- fireEvent.change(ret, { target: { value: 'red' } })
13
- expect(myfn).toHaveBeenCalledWith('red')
14
- })
@@ -1,59 +0,0 @@
1
- import React, { lazy, useState } from 'react'
2
- import { observer } from 'mobx-react'
3
- import { TextField } from '@mui/material'
4
-
5
- const ColorPicker = lazy(() => import('@jbrowse/core/ui/ColorPicker'))
6
-
7
- export const ColorSlot = (props: {
8
- value: string
9
- label?: string
10
- TextFieldProps?: {
11
- helperText: string
12
- fullWidth: boolean
13
- }
14
- onChange: (arg: string) => void
15
- }) => {
16
- const { value = '#000', label = '', TextFieldProps = {}, onChange } = props
17
- const [displayed, setDisplayed] = useState(false)
18
-
19
- return (
20
- <div style={{ display: 'flex' }}>
21
- <TextField
22
- value={value}
23
- label={label}
24
- onClick={() => setDisplayed(!displayed)}
25
- onChange={event => onChange(event.target.value)}
26
- {...TextFieldProps}
27
- />
28
- <div style={{ marginTop: 10 }}>
29
- <React.Suspense fallback={<div />}>
30
- <ColorPicker color={value} onChange={event => onChange(event)} />
31
- </React.Suspense>
32
- </div>
33
- </div>
34
- )
35
- }
36
-
37
- function ColorEditorSlot(props: {
38
- slot: {
39
- name: string
40
- value: string
41
- description: string
42
- set: (arg: string) => void
43
- }
44
- }) {
45
- const { slot } = props
46
- return (
47
- <ColorSlot
48
- label={slot.name}
49
- value={slot.value}
50
- onChange={color => slot.set(color)}
51
- TextFieldProps={{
52
- helperText: slot.description,
53
- fullWidth: true,
54
- }}
55
- />
56
- )
57
- }
58
-
59
- export default observer(ColorEditorSlot)
@@ -1,95 +0,0 @@
1
- import React from 'react'
2
- import { render } from '@testing-library/react'
3
-
4
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
5
- import PluginManager from '@jbrowse/core/PluginManager'
6
- import Alignments from '@jbrowse/plugin-alignments'
7
- import SVG from '@jbrowse/plugin-svg'
8
- import { linearBasicDisplayConfigSchemaFactory } from '@jbrowse/plugin-linear-genome-view'
9
- import ConfigurationEditor from './ConfigurationEditor'
10
-
11
- describe('ConfigurationEditor widget', () => {
12
- it('renders with just the required model elements', () => {
13
- const TestSchema = ConfigurationSchema('TestThing', {
14
- foo: {
15
- type: 'string',
16
- defaultValue: 'bar',
17
- },
18
- })
19
-
20
- const { container } = render(
21
- <ConfigurationEditor model={{ target: TestSchema.create() }} />,
22
- )
23
- expect(container.firstChild).toMatchSnapshot()
24
- })
25
-
26
- it('renders all the different types of built-in slots', () => {
27
- const TestSchema = ConfigurationSchema('TestThing', {
28
- stringTest: {
29
- name: 'stringTest',
30
- description: 'stringTest',
31
- type: 'string',
32
- defaultValue: 'string1',
33
- },
34
- fileLocationTest: {
35
- name: 'fileLocationTest',
36
- description: 'fileLocationTest',
37
- type: 'fileLocation',
38
- defaultValue: { uri: '/path/to/my.file', locationType: 'UriLocation' },
39
- },
40
- stringArrayTest: {
41
- name: 'stringArrayTest',
42
- description: 'stringArrayTest',
43
- type: 'stringArray',
44
- defaultValue: ['string1', 'string2'],
45
- },
46
- stringArrayMapTest: {
47
- name: 'stringArrayMapTest',
48
- description: 'stringArrayMapTest',
49
- type: 'stringArrayMap',
50
- defaultValue: { key1: ['string1', 'string2'] },
51
- },
52
- numberTest: {
53
- name: 'numberTest',
54
- description: 'numberTest',
55
- type: 'number',
56
- defaultValue: 88.5,
57
- },
58
- integerTest: {
59
- name: 'integerTest',
60
- description: 'integerTest',
61
- type: 'integer',
62
- defaultValue: 42,
63
- },
64
- colorTest: {
65
- name: 'colorTest',
66
- description: 'colorTest',
67
- type: 'color',
68
- defaultValue: '#396494',
69
- },
70
- booleanTest: {
71
- name: 'booleanTest',
72
- description: 'booleanTest',
73
- type: 'boolean',
74
- defaultValue: true,
75
- },
76
- })
77
-
78
- const { container } = render(
79
- <ConfigurationEditor model={{ target: TestSchema.create() }} />,
80
- )
81
- expect(container.firstChild).toMatchSnapshot()
82
- })
83
-
84
- it('renders with defaults of the PileupTrack schema', () => {
85
- const pluginManager = new PluginManager([new Alignments(), new SVG()])
86
- pluginManager.createPluggableElements()
87
- pluginManager.configure()
88
- const PileupDisplaySchema =
89
- linearBasicDisplayConfigSchemaFactory(pluginManager)
90
- const { container } = render(
91
- <ConfigurationEditor model={{ target: PileupDisplaySchema.create() }} />,
92
- )
93
- expect(container.firstChild).toMatchSnapshot()
94
- })
95
- })
@@ -1,167 +0,0 @@
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
- import { AbstractSessionModel } from '@jbrowse/core/util'
28
-
29
- const useStyles = makeStyles()(theme => ({
30
- expandIcon: {
31
- color: theme.palette.tertiary?.contrastText || '#fff',
32
- },
33
- root: {
34
- padding: theme.spacing(1, 3, 1, 1),
35
- },
36
- expansionPanelDetails: {
37
- display: 'block',
38
- padding: theme.spacing(1),
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(function (props: {
50
- slotName: string
51
- slotSchema: IAnyType
52
- schema: AnyConfigurationModel
53
- slot?: AnyConfigurationModel | AnyConfigurationModel[]
54
- path?: string[]
55
- }) {
56
- const { classes } = useStyles()
57
- const {
58
- slotName,
59
- slotSchema,
60
- schema,
61
- slot = schema[slotName],
62
- path = [],
63
- } = props
64
- let typeSelector
65
- if (isConfigurationSchemaType(slotSchema)) {
66
- if (slot.length) {
67
- return slot.map((subslot: AnyConfigurationModel, slotIndex: number) => {
68
- const key = `${singular(slotName)} ${slotIndex + 1}`
69
- return <Member {...props} key={key} slot={subslot} slotName={key} />
70
- })
71
- }
72
- // if this is an explicitly typed schema, make a type-selecting dropdown
73
- // that can be used to change its type
74
- const typeNameChoices = getTypeNamesFromExplicitlyTypedUnion(slotSchema)
75
- if (typeNameChoices.length) {
76
- typeSelector = (
77
- <TypeSelector
78
- typeNameChoices={typeNameChoices}
79
- slotName={slotName}
80
- slot={slot}
81
- onChange={evt => {
82
- if (evt.target.value !== slot.type) {
83
- schema.setSubschema(slotName, { type: evt.target.value })
84
- }
85
- }}
86
- />
87
- )
88
- }
89
- return (
90
- <Accordion defaultExpanded className={classes.accordion}>
91
- <AccordionSummary
92
- expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
93
- >
94
- <Typography>{[...path, slotName].join('➔')}</Typography>
95
- </AccordionSummary>
96
- <AccordionDetails className={classes.expansionPanelDetails}>
97
- {typeSelector}
98
- <FormGroup className={classes.noOverflow}>
99
- <Schema schema={slot} path={[...path, slotName]} />
100
- </FormGroup>
101
- </AccordionDetails>
102
- </Accordion>
103
- )
104
- }
105
-
106
- if (isConfigurationSlotType(slotSchema)) {
107
- // this is a regular config slot
108
- return <SlotEditor key={slotName} slot={slot} slotSchema={slotSchema} />
109
- }
110
-
111
- return null
112
- })
113
-
114
- const Schema = observer(function ({
115
- schema,
116
- path = [],
117
- }: {
118
- schema: AnyConfigurationModel
119
- path?: string[]
120
- }) {
121
- const properties = getMembers(schema).properties
122
- return (
123
- <>
124
- {Object.entries(properties).map(([slotName, slotSchema]) => (
125
- <Member
126
- key={slotName}
127
- slotName={slotName}
128
- slotSchema={slotSchema}
129
- path={path}
130
- schema={schema}
131
- />
132
- ))}
133
- </>
134
- )
135
- })
136
-
137
- const ConfigurationEditor = observer(function ({
138
- model,
139
- }: {
140
- model: { target: AnyConfigurationModel }
141
- session?: AbstractSessionModel
142
- }) {
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
- <Accordion key={key} defaultExpanded className={classes.accordion}>
152
- <AccordionSummary
153
- expandIcon={<ExpandMoreIcon className={classes.expandIcon} />}
154
- >
155
- <Typography>{name ?? 'Configuration'}</Typography>
156
- </AccordionSummary>
157
- <AccordionDetails
158
- className={classes.expansionPanelDetails}
159
- data-testid="configEditor"
160
- >
161
- {!target ? 'no target set' : <Schema schema={target} />}
162
- </AccordionDetails>
163
- </Accordion>
164
- )
165
- })
166
-
167
- export default ConfigurationEditor
@@ -1,22 +0,0 @@
1
- import React from 'react'
2
- import { TextField, TextFieldProps } from '@mui/material'
3
- import { SanitizedHTML } from '@jbrowse/core/ui'
4
-
5
- // adds ability to have html in helperText. note that FormHelperTextProps is
6
- // div because the default is p which does not like div children
7
- export default function ConfigurationTextField(
8
- props: { helperText?: string } & TextFieldProps,
9
- ) {
10
- const { helperText } = props
11
- return (
12
- <TextField
13
- {...props}
14
- helperText={<SanitizedHTML html={helperText || ''} />}
15
- FormHelperTextProps={{
16
- // @ts-expect-error
17
- component: 'div',
18
- }}
19
- fullWidth
20
- />
21
- )
22
- }
@@ -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
- })