@jbrowse/plugin-config 1.6.4 → 1.6.7

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.
@@ -11,17 +11,15 @@ import SimpleFeature from '@jbrowse/core/util/simpleFeature';
11
11
  import { ObservableCreate } from '@jbrowse/core/util/rxjs';
12
12
  import { toArray } from 'rxjs/operators';
13
13
  import { openLocation } from '@jbrowse/core/util/io';
14
- import { useDebounce, iterMap } from '@jbrowse/core/util';
15
- import { FormControl, InputLabel, FormHelperText, makeStyles, useTheme, Tooltip, IconButton, Paper, TextField as TextField$1, SvgIcon, List, ListItem, InputAdornment, Card, CardHeader, CardContent, FormControlLabel, Checkbox, MenuItem } from '@material-ui/core';
14
+ import { useDebounce } from '@jbrowse/core/util';
15
+ import { FormControl, InputLabel, FormHelperText, makeStyles, useTheme, Tooltip, IconButton, Paper, TextField as TextField$1, SvgIcon, List, ListItem, InputAdornment, Card, CardHeader, CardContent, FormControlLabel, Checkbox, MenuItem, Accordion, AccordionSummary, Typography, AccordionDetails, FormGroup } from '@material-ui/core';
16
16
  import Editor from 'react-simple-code-editor';
17
17
  import { Light } from 'react-syntax-highlighter';
18
18
  import json from 'react-syntax-highlighter/dist/cjs/languages/hljs/json';
19
19
  import a11yDark from 'react-syntax-highlighter/dist/cjs/styles/hljs/a11y-dark';
20
20
  import a11yLight from 'react-syntax-highlighter/dist/cjs/styles/hljs/a11y-light';
21
- import FormGroup from '@material-ui/core/FormGroup';
22
- import FormLabel from '@material-ui/core/FormLabel';
23
- import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
24
21
  import { singular } from 'pluralize';
22
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
25
23
  import { FileSelector } from '@jbrowse/core/ui';
26
24
  import { getSubType, getUnionSubTypes, getPropertyType } from '@jbrowse/core/util/mst-reflection';
27
25
  import DeleteIcon from '@material-ui/icons/Delete';
@@ -33,6 +31,7 @@ import ReactPropTypes from 'prop-types';
33
31
  import TextField from '@material-ui/core/TextField';
34
32
  import MenuItem$1 from '@material-ui/core/MenuItem';
35
33
  import Paper$1 from '@material-ui/core/Paper';
34
+ import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
36
35
  import { ChromePicker } from 'react-color';
37
36
 
38
37
  function ownKeys(object, enumerableOnly) {
@@ -273,10 +272,6 @@ function _slicedToArray(arr, i) {
273
272
  return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
274
273
  }
275
274
 
276
- function _toArray(arr) {
277
- return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
278
- }
279
-
280
275
  function _toConsumableArray(arr) {
281
276
  return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
282
277
  }
@@ -1657,7 +1652,7 @@ var RefNameAliasAdapter = /*#__PURE__*/function (_BaseAdapter) {
1657
1652
  key: "getRefNameAliases",
1658
1653
  value: function () {
1659
1654
  var _getRefNameAliases = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1660
- var loc, results;
1655
+ var loc, results, refColumn;
1661
1656
  return runtime_1.wrap(function _callee$(_context) {
1662
1657
  while (1) {
1663
1658
  switch (_context.prev = _context.next) {
@@ -1677,13 +1672,15 @@ var RefNameAliasAdapter = /*#__PURE__*/function (_BaseAdapter) {
1677
1672
 
1678
1673
  case 5:
1679
1674
  results = _context.sent;
1675
+ refColumn = readConfObject(this.config, 'refNameColumn');
1680
1676
  return _context.abrupt("return", results.trim().split('\n').filter(function (f) {
1681
1677
  return !!f && !f.startsWith('#');
1682
1678
  }).map(function (row) {
1683
- var _row$split = row.split('\t'),
1684
- _row$split2 = _toArray(_row$split),
1685
- refName = _row$split2[0],
1686
- aliases = _row$split2.slice(1);
1679
+ var aliases = row.split('\t');
1680
+
1681
+ var _aliases$splice = aliases.splice(refColumn, 1),
1682
+ _aliases$splice2 = _slicedToArray(_aliases$splice, 1),
1683
+ refName = _aliases$splice2[0];
1687
1684
 
1688
1685
  return {
1689
1686
  refName: refName,
@@ -1691,7 +1688,7 @@ var RefNameAliasAdapter = /*#__PURE__*/function (_BaseAdapter) {
1691
1688
  };
1692
1689
  }));
1693
1690
 
1694
- case 7:
1691
+ case 8:
1695
1692
  case "end":
1696
1693
  return _context.stop();
1697
1694
  }
@@ -1738,6 +1735,10 @@ var refNameAliasAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('RefNameA
1738
1735
  uri: '/path/to/my/aliases.txt',
1739
1736
  locationType: 'UriLocation'
1740
1737
  }
1738
+ },
1739
+ refNameColumn: {
1740
+ type: 'number',
1741
+ defaultValue: 0
1741
1742
  }
1742
1743
  }, {
1743
1744
  explicitlyTyped: true
@@ -1975,10 +1976,12 @@ function CallbackEditor(_ref) {
1975
1976
 
1976
1977
  var jexlDebouncedCode = debouncedCode.startsWith('jexl:') ? debouncedCode : "jexl:".concat(debouncedCode);
1977
1978
  stringToJexlExpression(jexlDebouncedCode, (_getEnv$pluginManager = getEnv(slot).pluginManager) === null || _getEnv$pluginManager === void 0 ? void 0 : _getEnv$pluginManager.jexl);
1978
- slot.set(jexlDebouncedCode); // slot.set `jexl:${debouncedCode}`
1979
-
1979
+ slot.set(jexlDebouncedCode);
1980
1980
  setCodeError(null);
1981
1981
  } catch (e) {
1982
+ console.error({
1983
+ e: e
1984
+ });
1982
1985
  setCodeError(e);
1983
1986
  }
1984
1987
  }, [debouncedCode, slot]); // if default value is a callback, will have to remove jexl:
@@ -1991,7 +1994,7 @@ function CallbackEditor(_ref) {
1991
1994
  className: classes.callbackEditor,
1992
1995
  value: code.startsWith('jexl:') ? code.split('jexl:')[1] : code,
1993
1996
  onValueChange: function onValueChange(newCode) {
1994
- setCode(newCode);
1997
+ return setCode(newCode);
1995
1998
  },
1996
1999
  highlight: function highlight(newCode) {
1997
2000
  return newCode;
@@ -2000,7 +2003,11 @@ function CallbackEditor(_ref) {
2000
2003
  style: {
2001
2004
  background: error ? '#fdd' : undefined
2002
2005
  }
2003
- }), /*#__PURE__*/React.createElement(FormHelperText, null, slot.description)), /*#__PURE__*/React.createElement(Tooltip, {
2006
+ }), error ? /*#__PURE__*/React.createElement(FormHelperText, {
2007
+ style: {
2008
+ color: '#f00'
2009
+ }
2010
+ }, "".concat(error)) : null, /*#__PURE__*/React.createElement(FormHelperText, null, slot.description)), /*#__PURE__*/React.createElement(Tooltip, {
2004
2011
  title: /*#__PURE__*/React.createElement("div", null, "Callbacks are written in Jexl format. Click to learn more.", /*#__PURE__*/React.createElement("br", null), " Names of available context items: ", slot.contextVariable),
2005
2012
  arrow: true
2006
2013
  }, /*#__PURE__*/React.createElement(IconButton, {
@@ -2455,13 +2462,10 @@ var useSlotEditorStyles = /*#__PURE__*/makeStyles(function (theme) {
2455
2462
  paper: {
2456
2463
  display: 'flex',
2457
2464
  marginBottom: theme.spacing(2),
2458
- position: 'relative',
2459
- overflow: 'visible'
2465
+ position: 'relative'
2460
2466
  },
2461
2467
  paperContent: {
2462
- flex: 'auto',
2463
- padding: theme.spacing(1),
2464
- overflow: 'auto'
2468
+ width: '100%'
2465
2469
  },
2466
2470
  slotModeSwitch: {
2467
2471
  width: 24,
@@ -2533,18 +2537,20 @@ var TypeSelector = /*#__PURE__*/observer(function (_ref) {
2533
2537
  }))));
2534
2538
  });
2535
2539
 
2536
- var useStyles$3 = /*#__PURE__*/makeStyles$1(function (theme) {
2540
+ var useStyles$3 = /*#__PURE__*/makeStyles(function (theme) {
2537
2541
  return {
2538
- subSchemaContainer: {
2539
- marginLeft: theme.spacing(1),
2540
- borderLeft: "1px solid ".concat(theme.palette.secondary.main),
2541
- paddingLeft: theme.spacing(1),
2542
- marginBottom: theme.spacing(1)
2542
+ expandIcon: {
2543
+ color: '#fff'
2543
2544
  },
2544
2545
  root: {
2545
- padding: theme.spacing(1, 3, 1, 1),
2546
- background: theme.palette.background["default"],
2547
- overflowX: 'hidden'
2546
+ padding: theme.spacing(1, 3, 1, 1)
2547
+ },
2548
+ expansionPanelDetails: {
2549
+ display: 'block',
2550
+ padding: theme.spacing(1)
2551
+ },
2552
+ accordion: {
2553
+ border: "1px solid ".concat(theme.palette.text.primary)
2548
2554
  }
2549
2555
  };
2550
2556
  });
@@ -2554,19 +2560,21 @@ var Member = /*#__PURE__*/observer(function (props) {
2554
2560
  slotSchema = props.slotSchema,
2555
2561
  schema = props.schema,
2556
2562
  _props$slot = props.slot,
2557
- slot = _props$slot === void 0 ? schema[slotName] : _props$slot;
2563
+ slot = _props$slot === void 0 ? schema[slotName] : _props$slot,
2564
+ _props$path = props.path,
2565
+ path = _props$path === void 0 ? [] : _props$path;
2558
2566
  var typeSelector;
2559
2567
 
2560
2568
  if (isConfigurationSchemaType(slotSchema)) {
2561
2569
  if (slot.length) {
2562
- return /*#__PURE__*/React.createElement(React.Fragment, null, slot.map(function (subslot, slotIndex) {
2570
+ return slot.map(function (subslot, slotIndex) {
2563
2571
  var key = "".concat(singular(slotName), " ").concat(slotIndex + 1);
2564
2572
  return /*#__PURE__*/React.createElement(Member, _extends({}, props, {
2565
2573
  key: key,
2566
2574
  slot: subslot,
2567
2575
  slotName: key
2568
2576
  }));
2569
- }));
2577
+ });
2570
2578
  } // if this is an explicitly typed schema, make a type-selecting dropdown
2571
2579
  // that can be used to change its type
2572
2580
 
@@ -2588,10 +2596,22 @@ var Member = /*#__PURE__*/observer(function (props) {
2588
2596
  });
2589
2597
  }
2590
2598
 
2591
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormLabel, null, slotName), /*#__PURE__*/React.createElement("div", {
2592
- className: classes.subSchemaContainer
2599
+ return /*#__PURE__*/React.createElement(Accordion, {
2600
+ defaultExpanded: true,
2601
+ className: classes.accordion,
2602
+ TransitionProps: {
2603
+ unmountOnExit: true,
2604
+ timeout: 150
2605
+ }
2606
+ }, /*#__PURE__*/React.createElement(AccordionSummary, {
2607
+ expandIcon: /*#__PURE__*/React.createElement(ExpandMoreIcon, {
2608
+ className: classes.expandIcon
2609
+ })
2610
+ }, /*#__PURE__*/React.createElement(Typography, null, [].concat(_toConsumableArray(path), [slotName]).join('🡒'))), /*#__PURE__*/React.createElement(AccordionDetails, {
2611
+ className: classes.expansionPanelDetails
2593
2612
  }, typeSelector, /*#__PURE__*/React.createElement(FormGroup, null, /*#__PURE__*/React.createElement(Schema, {
2594
- schema: slot
2613
+ schema: slot,
2614
+ path: [].concat(_toConsumableArray(path), [slotName])
2595
2615
  }))));
2596
2616
  }
2597
2617
 
@@ -2607,8 +2627,11 @@ var Member = /*#__PURE__*/observer(function (props) {
2607
2627
  return null;
2608
2628
  });
2609
2629
  var Schema = /*#__PURE__*/observer(function (_ref) {
2610
- var schema = _ref.schema;
2611
- return iterMap(Object.entries(getMembers(schema).properties), function (_ref2) {
2630
+ var schema = _ref.schema,
2631
+ _ref$path = _ref.path,
2632
+ path = _ref$path === void 0 ? [] : _ref$path;
2633
+ var properties = getMembers(schema).properties;
2634
+ return Object.entries(properties).map(function (_ref2) {
2612
2635
  var _ref3 = _slicedToArray(_ref2, 2),
2613
2636
  slotName = _ref3[0],
2614
2637
  slotSchema = _ref3[1];
@@ -2617,6 +2640,7 @@ var Schema = /*#__PURE__*/observer(function (_ref) {
2617
2640
  key: slotName,
2618
2641
  slotName: slotName,
2619
2642
  slotSchema: slotSchema,
2643
+ path: path,
2620
2644
  schema: schema
2621
2645
  });
2622
2646
  });
@@ -2628,13 +2652,25 @@ var ConfigurationEditor = /*#__PURE__*/observer(function (_ref4) {
2628
2652
  // see pr #804
2629
2653
 
2630
2654
  var key = model.target && readConfObject(model.target, 'trackId');
2631
- return /*#__PURE__*/React.createElement("div", {
2632
- className: classes.root,
2655
+ var name = model.target && readConfObject(model.target, 'name');
2656
+ return /*#__PURE__*/React.createElement(Accordion, {
2633
2657
  key: key,
2658
+ defaultExpanded: true,
2659
+ className: classes.accordion,
2660
+ TransitionProps: {
2661
+ unmountOnExit: true,
2662
+ timeout: 150
2663
+ }
2664
+ }, /*#__PURE__*/React.createElement(AccordionSummary, {
2665
+ expandIcon: /*#__PURE__*/React.createElement(ExpandMoreIcon, {
2666
+ className: classes.expandIcon
2667
+ })
2668
+ }, /*#__PURE__*/React.createElement(Typography, null, name ? name : 'Configuration')), /*#__PURE__*/React.createElement(AccordionDetails, {
2669
+ className: classes.expansionPanelDetails,
2634
2670
  "data-testid": "configEditor"
2635
2671
  }, !model.target ? 'no target set' : /*#__PURE__*/React.createElement(Schema, {
2636
2672
  schema: model.target
2637
- }));
2673
+ })));
2638
2674
  });
2639
2675
 
2640
2676
  var ConfigurationEditor$1 = {