@jbrowse/core 2.4.0 → 2.4.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 (101) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +1 -3
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +13 -9
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +3 -10
  4. package/BaseFeatureWidget/SequencePanel.js +1 -1
  5. package/BaseFeatureWidget/index.d.ts +1 -1
  6. package/BaseFeatureWidget/index.js +8 -11
  7. package/PluginLoader.js +8 -8
  8. package/PluginManager.d.ts +2 -4
  9. package/PluginManager.js +2 -3
  10. package/ReExports/Attributes.d.ts +1 -2
  11. package/ReExports/Attributes.js +4 -3
  12. package/ReExports/BaseCard.d.ts +1 -2
  13. package/ReExports/BaseCard.js +4 -3
  14. package/ReExports/DataGrid.d.ts +1 -2
  15. package/ReExports/DataGrid.js +2 -2
  16. package/ReExports/FeatureDetails.d.ts +1 -2
  17. package/ReExports/FeatureDetails.js +4 -3
  18. package/ReExports/index.d.ts +1 -2
  19. package/ReExports/index.js +3 -2
  20. package/ReExports/modules.d.ts +2 -4
  21. package/ReExports/modules.js +2 -2
  22. package/assemblyManager/assembly.js +5 -5
  23. package/assemblyManager/assemblyConfigSchema.js +2 -2
  24. package/configuration/configurationSchema.d.ts +3 -1
  25. package/configuration/configurationSchema.js +1 -1
  26. package/configuration/configurationSlot.d.ts +1 -0
  27. package/configuration/util.js +1 -1
  28. package/data_adapters/BaseAdapter.js +1 -1
  29. package/data_adapters/CytobandAdapter/CytobandAdapter.js +1 -1
  30. package/data_adapters/dataAdapterCache.d.ts +3 -2
  31. package/data_adapters/dataAdapterCache.js +2 -3
  32. package/package.json +2 -3
  33. package/pluggableElementTypes/RpcMethodType.js +1 -1
  34. package/pluggableElementTypes/index.d.ts +11 -1
  35. package/pluggableElementTypes/index.js +23 -23
  36. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +2 -2
  37. package/pluggableElementTypes/models/BaseTrackModel.js +8 -13
  38. package/pluggableElementTypes/models/baseTrackConfig.js +1 -1
  39. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.d.ts +2 -2
  40. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +1 -3
  41. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +1 -1
  42. package/pluggableElementTypes/renderers/index.d.ts +7 -9
  43. package/pluggableElementTypes/renderers/index.js +15 -15
  44. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +1 -1
  45. package/rpc/BaseRpcDriver.js +7 -8
  46. package/rpc/WebWorkerRpcDriver.js +18 -12
  47. package/rpc/coreRpcMethods.d.ts +9 -11
  48. package/rpc/coreRpcMethods.js +17 -17
  49. package/rpc/methods/CoreGetFeatureDetails.js +1 -1
  50. package/rpc/methods/util.d.ts +2 -2
  51. package/rpc/methods/util.js +2 -2
  52. package/rpc/remoteAbortSignals.js +0 -1
  53. package/tsconfig.build.tsbuildinfo +1 -1
  54. package/ui/App.js +1 -1
  55. package/ui/AppLogo.js +1 -6
  56. package/ui/ColorPicker.js +1 -1
  57. package/ui/Dialog.js +1 -1
  58. package/ui/DrawerWidget.js +4 -4
  59. package/ui/EditableTypography.js +1 -1
  60. package/ui/FileSelector/FileSelector.d.ts +2 -2
  61. package/ui/FileSelector/FileSelector.js +24 -35
  62. package/ui/FileSelector/index.d.ts +1 -2
  63. package/ui/FileSelector/index.js +3 -2
  64. package/ui/LoadingEllipses.js +4 -4
  65. package/ui/Menu.js +45 -32
  66. package/ui/ResizeBar.js +6 -1
  67. package/ui/ResizeHandle.js +3 -6
  68. package/ui/ViewContainer.d.ts +2 -3
  69. package/ui/ViewContainer.js +7 -41
  70. package/ui/ViewContainerTitle.d.ts +6 -0
  71. package/ui/ViewContainerTitle.js +42 -0
  72. package/ui/theme.js +7 -7
  73. package/util/Base1DUtils.js +16 -14
  74. package/util/Base1DViewModel.d.ts +1 -1
  75. package/util/Base1DViewModel.js +9 -8
  76. package/util/aborting.js +1 -1
  77. package/util/analytics.js +1 -1
  78. package/util/blockTypes.js +10 -10
  79. package/util/color/index.d.ts +1 -2
  80. package/util/color/index.js +4 -3
  81. package/util/idMaker.js +5 -8
  82. package/util/index.d.ts +11 -9
  83. package/util/index.js +42 -50
  84. package/util/io/RemoteFileWithRangeCache.js +2 -2
  85. package/util/io/index.d.ts +4 -3
  86. package/util/io/index.js +14 -9
  87. package/util/jexl.js +3 -1
  88. package/util/layouts/GranularRectLayout.js +10 -4
  89. package/util/layouts/MultiLayout.js +1 -1
  90. package/util/layouts/SceneGraph.js +3 -7
  91. package/util/mst-reflection.d.ts +12 -17
  92. package/util/mst-reflection.js +13 -12
  93. package/util/offscreenCanvasPonyfill.js +4 -3
  94. package/util/offscreenCanvasUtils.js +1 -0
  95. package/util/tracks.d.ts +1 -1
  96. package/util/tracks.js +0 -1
  97. package/util/types/index.d.ts +2 -1
  98. package/util/types/index.js +3 -3
  99. package/util/types/mst.js +3 -3
  100. package/util/useMeasure.d.ts +5 -0
  101. package/util/useMeasure.js +34 -0
package/ui/App.js CHANGED
@@ -103,7 +103,7 @@ const App = (0, mobx_react_1.observer)(function (props) {
103
103
  react_1.default.createElement(material_1.AppBar, { className: classes.appBar, position: "static" },
104
104
  react_1.default.createElement(AppToolbar_1.default, { ...props }))),
105
105
  react_1.default.createElement("div", { className: classes.components },
106
- views.length ? (views.map(view => (react_1.default.createElement(ViewPanel_1.default, { key: `view-${view.id}`, view: view, session: session })))) : (react_1.default.createElement(ViewLauncher_1.default, { ...props })),
106
+ views.length > 0 ? (views.map(view => (react_1.default.createElement(ViewPanel_1.default, { key: `view-${view.id}`, view: view, session: session })))) : (react_1.default.createElement(ViewLauncher_1.default, { ...props })),
107
107
  react_1.default.createElement("div", { style: { height: 300 } }))),
108
108
  activeWidgets.size > 0 && minimized ? (react_1.default.createElement(material_1.Tooltip, { title: "Open drawer widget" },
109
109
  react_1.default.createElement(material_1.Fab, { className: drawerPosition === 'right' ? classes.fabRight : classes.fabLeft, color: "primary", "data-testid": "drawer-maximize", onClick: () => session.showWidgetDrawer() },
package/ui/AppLogo.js CHANGED
@@ -12,11 +12,6 @@ const Logo_1 = require("./Logo");
12
12
  const Logo = (0, mobx_react_1.observer)(function ({ session, }) {
13
13
  const { configuration } = session;
14
14
  const logoPath = (0, configuration_1.readConfObject)(configuration, 'logoPath');
15
- if (!(logoPath === null || logoPath === void 0 ? void 0 : logoPath.uri)) {
16
- return react_1.default.createElement(Logo_1.LogoFull, { variant: "white" });
17
- }
18
- else {
19
- return react_1.default.createElement("img", { src: logoPath.uri, alt: "Custom logo" });
20
- }
15
+ return (logoPath === null || logoPath === void 0 ? void 0 : logoPath.uri) ? (react_1.default.createElement("img", { src: logoPath.uri, alt: "Custom logo" })) : (react_1.default.createElement(Logo_1.LogoFull, { variant: "white" }));
21
16
  });
22
17
  exports.default = Logo;
package/ui/ColorPicker.js CHANGED
@@ -90,7 +90,7 @@ function ColorPicker({ onChange, color, }) {
90
90
  const pal = event.target.value;
91
91
  setVal(pal);
92
92
  } }, palettes.map(p => (react_1.default.createElement(material_1.MenuItem, { value: p, key: p }, p)))),
93
- react_1.default.createElement("div", { className: classes.swatches }, presetColors.map((presetColor, idx) => (react_1.default.createElement("button", { key: presetColor + '-' + idx, className: classes.swatch, style: { background: presetColor }, onClick: () => handleChange(presetColor) })))),
93
+ react_1.default.createElement("div", { className: classes.swatches }, presetColors.map((presetColor, idx) => (react_1.default.createElement("button", { key: `${presetColor}-${idx}`, className: classes.swatch, style: { background: presetColor }, onClick: () => handleChange(presetColor) })))),
94
94
  react_1.default.createElement(material_1.TextField, { helperText: 'Manually set color (hex, rgb, or css color name)', value: text, onChange: event => handleChange(event.target.value) }))));
95
95
  }
96
96
  exports.ColorPicker = ColorPicker;
package/ui/Dialog.js CHANGED
@@ -32,7 +32,7 @@ function JBrowseDialog(props) {
32
32
  react_1.default.createElement(material_1.DialogTitle, null,
33
33
  title,
34
34
  onClose ? (react_1.default.createElement(material_1.IconButton, { className: classes.closeButton, onClick: () => {
35
- // @ts-ignore
35
+ // @ts-expect-error
36
36
  onClose();
37
37
  } },
38
38
  react_1.default.createElement(Close_1.default, null))) : null),
@@ -77,13 +77,13 @@ const DrawerHeader = (0, mobx_react_1.observer)(({ session, setToolbarHeight, })
77
77
  return HeadingComponent ? (react_1.default.createElement(HeadingComponent, { model: widget })) : (react_1.default.createElement(material_1.Typography, { variant: "h6", color: "inherit" }, heading));
78
78
  }, onChange: e => {
79
79
  const w = session.activeWidgets.get(e.target.value);
80
- if (!w) {
81
- session.notify(`Widget not found ${e.target.value}`, 'warning');
80
+ if (w) {
81
+ session.showWidget(w);
82
82
  }
83
83
  else {
84
- session.showWidget(w);
84
+ session.notify(`Widget not found ${e.target.value}`, 'warning');
85
85
  }
86
- } }, Array.from(activeWidgets.values()).map(widget => {
86
+ } }, [...activeWidgets.values()].map(widget => {
87
87
  const widgetType = pluginManager.getWidgetType(widget.type);
88
88
  const { HeadingComponent, heading } = widgetType;
89
89
  return (react_1.default.createElement(material_1.MenuItem, { "data-testid": `widget-drawer-selects-item-${widget.type}`, key: widget.id, value: widget.id },
@@ -59,7 +59,7 @@ const EditableTypography = react_1.default.forwardRef((props, ref) => {
59
59
  }, [blur, inputNode]);
60
60
  // possibly tss-react does not understand the passing of props to
61
61
  // useStyles, but it appears to work
62
- // @ts-ignore
62
+ // @ts-expect-error
63
63
  const { classes } = useStyles(props, { props });
64
64
  const theme = (0, material_1.useTheme)();
65
65
  const clientWidth = sizerNode === null || sizerNode === void 0 ? void 0 : sizerNode.clientWidth;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { FileLocation, AbstractRootModel } from '../../util/types';
3
- declare const FileSelector: (props: {
3
+ declare const _default: (props: {
4
4
  location?: FileLocation | undefined;
5
5
  setLocation: (param: FileLocation) => void;
6
6
  setName?: ((str: string) => void) | undefined;
@@ -8,4 +8,4 @@ declare const FileSelector: (props: {
8
8
  description?: string | undefined;
9
9
  rootModel?: AbstractRootModel | undefined;
10
10
  }) => JSX.Element;
11
- export default FileSelector;
11
+ export default _default;
@@ -42,46 +42,45 @@ function ToggleButtonWithTooltip(props) {
42
42
  }
43
43
  function shorten(str, len) {
44
44
  if (typeof str === 'string' && str.length > len) {
45
- return `${str.substring(0, len)}…`;
45
+ return `${str.slice(0, Math.max(0, len))}…`;
46
46
  }
47
47
  return str;
48
48
  }
49
- const FileSelector = (0, mobx_react_1.observer)((props) => {
49
+ exports.default = (0, mobx_react_1.observer)(function (props) {
50
50
  const { location, name, description, rootModel, setLocation } = props;
51
51
  const fileOrUrl = !location || (0, types_1.isUriLocation)(location) ? 'url' : 'file';
52
52
  const [toggleButtonValue, setToggleButtonValue] = (0, react_1.useState)(location && 'internetAccountId' in location && location.internetAccountId
53
53
  ? location.internetAccountId
54
54
  : fileOrUrl);
55
- const accts = (0, types_1.isAppRootModel)(rootModel)
56
- ? rootModel.internetAccounts.slice()
57
- : [];
55
+ const accts = (0, types_1.isAppRootModel)(rootModel) ? [...rootModel.internetAccounts] : [];
58
56
  const numShown = 2;
59
57
  const [shownAccts, setShownAccts] = (0, react_1.useState)(accts.slice(0, numShown));
60
58
  const [hiddenAccts, setHiddenAccts] = (0, react_1.useState)(accts.slice(numShown));
61
59
  const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
62
- const selectedAcct = accts.find(ia => ia.internetAccountId === toggleButtonValue);
63
- const setLocationWithAccount = (location) => {
60
+ const selectedAcct = accts.find(i => i.internetAccountId === toggleButtonValue);
61
+ const setLocationWithAcct = (0, react_1.useCallback)((location) => {
64
62
  setLocation({
65
63
  ...location,
66
- internetAccountId: selectedAcct
67
- ? selectedAcct.internetAccountId
68
- : undefined,
64
+ ...((0, types_1.isUriLocation)(location)
65
+ ? { internetAccountId: selectedAcct === null || selectedAcct === void 0 ? void 0 : selectedAcct.internetAccountId }
66
+ : {}),
69
67
  });
70
- };
71
- // if you swap account selection after inputting url
72
- if (location &&
73
- selectedAcct &&
74
- (0, types_1.isUriLocation)(location) &&
75
- location.internetAccountId !== selectedAcct.internetAccountId) {
76
- setLocationWithAccount(location);
77
- }
78
- let locationInput = (react_1.default.createElement(UrlChooser_1.default, { ...props, setLocation: setLocationWithAccount, label: selectedAcct === null || selectedAcct === void 0 ? void 0 : selectedAcct.selectorLabel }));
68
+ }, [setLocation, selectedAcct]);
69
+ (0, react_1.useEffect)(() => {
70
+ // if you swap account selection after inputting url
71
+ if (selectedAcct &&
72
+ (0, types_1.isUriLocation)(location) &&
73
+ location.internetAccountId !== selectedAcct.internetAccountId) {
74
+ setLocationWithAcct(location);
75
+ }
76
+ }, [location, selectedAcct, setLocationWithAcct]);
77
+ let locationInput = (react_1.default.createElement(UrlChooser_1.default, { ...props, setLocation: setLocationWithAcct, label: selectedAcct === null || selectedAcct === void 0 ? void 0 : selectedAcct.selectorLabel }));
79
78
  if (toggleButtonValue === 'file') {
80
79
  locationInput = react_1.default.createElement(LocalFileChooser_1.default, { ...props });
81
80
  }
82
81
  if (selectedAcct === null || selectedAcct === void 0 ? void 0 : selectedAcct.SelectorComponent) {
83
82
  const { SelectorComponent } = selectedAcct;
84
- locationInput = (react_1.default.createElement(SelectorComponent, { ...props, setLocation: setLocationWithAccount }));
83
+ locationInput = (react_1.default.createElement(SelectorComponent, { ...props, setLocation: setLocationWithAcct }));
85
84
  }
86
85
  return (react_1.default.createElement(react_1.default.Fragment, null,
87
86
  react_1.default.createElement(material_1.Box, { display: "flex" },
@@ -93,7 +92,7 @@ const FileSelector = (0, mobx_react_1.observer)((props) => {
93
92
  setToggleButtonValue(newState);
94
93
  }
95
94
  if ((0, types_1.isUriLocation)(location)) {
96
- setLocationWithAccount(location);
95
+ setLocationWithAcct(location);
97
96
  }
98
97
  }, "aria-label": "file, url, or account picker" },
99
98
  new URLSearchParams(window.location.search).get('adminKey') ? null : (react_1.default.createElement(material_1.ToggleButton, { value: "file", "aria-label": "local file" }, "File")),
@@ -101,23 +100,14 @@ const FileSelector = (0, mobx_react_1.observer)((props) => {
101
100
  shownAccts.map(({ internetAccountId, toggleContents, name }) => (react_1.default.createElement(ToggleButtonWithTooltip, { key: internetAccountId, value: internetAccountId, "aria-label": name, title: name }, typeof toggleContents === 'string'
102
101
  ? shorten(toggleContents, 5)
103
102
  : toggleContents || shorten(name, 5)))),
104
- hiddenAccts.length ? (
105
- // @ts-ignore
103
+ hiddenAccts.length > 0 ? (
104
+ // @ts-expect-error
106
105
  react_1.default.createElement(material_1.ToggleButton, { onClick: event => setAnchorEl(event.target), selected: false },
107
106
  "More",
108
107
  react_1.default.createElement(ArrowDropDown_1.default, null))) : null),
109
- react_1.default.createElement(material_1.Menu, { open: Boolean(anchorEl), anchorEl: anchorEl, onClose: () => setAnchorEl(null), anchorOrigin: {
110
- vertical: 'bottom',
111
- horizontal: 'center',
112
- }, transformOrigin: {
113
- vertical: 'top',
114
- horizontal: 'center',
115
- } }, hiddenAccts === null || hiddenAccts === void 0 ? void 0 : hiddenAccts.map((acct, idx) => (react_1.default.createElement(material_1.MenuItem, { key: acct.internetAccountId, value: acct.internetAccountId, onClick: () => {
108
+ react_1.default.createElement(material_1.Menu, { open: Boolean(anchorEl), anchorEl: anchorEl, onClose: () => setAnchorEl(null), anchorOrigin: { vertical: 'bottom', horizontal: 'center' }, transformOrigin: { vertical: 'top', horizontal: 'center' } }, hiddenAccts === null || hiddenAccts === void 0 ? void 0 : hiddenAccts.map((acct, idx) => (react_1.default.createElement(material_1.MenuItem, { key: acct.internetAccountId, value: acct.internetAccountId, onClick: () => {
116
109
  const prev = shownAccts[shownAccts.length - 1];
117
- setShownAccts([
118
- ...shownAccts.slice(0, shownAccts.length - 1),
119
- acct,
120
- ]);
110
+ setShownAccts([...shownAccts.slice(0, -1), acct]);
121
111
  setHiddenAccts([
122
112
  prev,
123
113
  ...hiddenAccts.slice(0, idx),
@@ -129,4 +119,3 @@ const FileSelector = (0, mobx_react_1.observer)((props) => {
129
119
  locationInput,
130
120
  react_1.default.createElement(material_1.FormHelperText, null, description)));
131
121
  });
132
- exports.default = FileSelector;
@@ -1,2 +1 @@
1
- import FileSelector from './FileSelector';
2
- export default FileSelector;
1
+ export { default } from './FileSelector';
@@ -3,5 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const FileSelector_1 = __importDefault(require("./FileSelector"));
7
- exports.default = FileSelector_1.default;
6
+ exports.default = void 0;
7
+ var FileSelector_1 = require("./FileSelector");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(FileSelector_1).default; } });
@@ -16,16 +16,16 @@ const useStyles = (0, mui_1.makeStyles)()({
16
16
  textAlign: 'left',
17
17
  animation: `${(0, tss_react_1.keyframes) `
18
18
  0% {
19
- content: '...';
19
+ content: '';
20
20
  }
21
21
  25% {
22
- content: '';
22
+ content: '.';
23
23
  }
24
24
  50% {
25
- content: '.';
25
+ content: '..';
26
26
  }
27
27
  75% {
28
- content: '..';
28
+ content: '...';
29
29
  }
30
30
  `} 1.2s infinite ease-in-out`,
31
31
  },
package/ui/Menu.js CHANGED
@@ -69,26 +69,32 @@ function MenuItemEndDecoration(props) {
69
69
  ({ checked, disabled } = props);
70
70
  }
71
71
  let icon;
72
- if (type === 'subMenu') {
73
- icon = react_1.default.createElement(ArrowRight_1.default, { color: "action" });
74
- }
75
- else if (type === 'checkbox') {
76
- if (checked) {
77
- const color = disabled ? 'inherit' : undefined;
78
- icon = react_1.default.createElement(CheckBox_1.default, { color: color });
79
- }
80
- else {
81
- icon = react_1.default.createElement(CheckBoxOutlineBlank_1.default, { color: "action" });
72
+ switch (type) {
73
+ case 'subMenu': {
74
+ icon = react_1.default.createElement(ArrowRight_1.default, { color: "action" });
75
+ break;
82
76
  }
83
- }
84
- else if (type === 'radio') {
85
- if (checked) {
86
- const color = disabled ? 'inherit' : undefined;
87
- icon = react_1.default.createElement(RadioButtonChecked_1.default, { color: color });
77
+ case 'checkbox': {
78
+ if (checked) {
79
+ const color = disabled ? 'inherit' : undefined;
80
+ icon = react_1.default.createElement(CheckBox_1.default, { color: color });
81
+ }
82
+ else {
83
+ icon = react_1.default.createElement(CheckBoxOutlineBlank_1.default, { color: "action" });
84
+ }
85
+ break;
88
86
  }
89
- else {
90
- icon = react_1.default.createElement(RadioButtonUnchecked_1.default, { color: "action" });
87
+ case 'radio': {
88
+ if (checked) {
89
+ const color = disabled ? 'inherit' : undefined;
90
+ icon = react_1.default.createElement(RadioButtonChecked_1.default, { color: color });
91
+ }
92
+ else {
93
+ icon = react_1.default.createElement(RadioButtonUnchecked_1.default, { color: "action" });
94
+ }
95
+ break;
91
96
  }
97
+ // No default
92
98
  }
93
99
  return react_1.default.createElement("div", { className: classes.menuItemEndDecoration }, icon);
94
100
  }
@@ -208,21 +214,28 @@ const MenuPage = react_1.default.forwardRef((props, ref) => {
208
214
  setOpenSubMenuIdx(undefined);
209
215
  }
210
216
  }, onKeyDown: e => {
211
- if (e.key === 'ArrowLeft' || e.key === 'Escape') {
212
- onClose && onClose(e, 'escapeKeyDown');
213
- }
214
- else if (e.key === 'ArrowUp') {
215
- setSelectedMenuItemIdx(findPreviousValidIdx(menuItems, idx));
216
- }
217
- else if (e.key === 'ArrowDown') {
218
- const a = findNextValidIdx(menuItems, idx);
219
- setSelectedMenuItemIdx(a);
220
- }
221
- else if ('subMenu' in menuItem) {
222
- if (e.key === 'ArrowRight' || e.key === 'Enter') {
223
- setSubMenuAnchorEl(e.currentTarget);
224
- setOpenSubMenuIdx(idx);
225
- setIsSubMenuOpen(true);
217
+ switch (e.key) {
218
+ case 'ArrowLeft':
219
+ case 'Escape': {
220
+ onClose && onClose(e, 'escapeKeyDown');
221
+ break;
222
+ }
223
+ case 'ArrowUp': {
224
+ setSelectedMenuItemIdx(findPreviousValidIdx(menuItems, idx));
225
+ break;
226
+ }
227
+ case 'ArrowDown': {
228
+ const a = findNextValidIdx(menuItems, idx);
229
+ setSelectedMenuItemIdx(a);
230
+ break;
231
+ }
232
+ default: {
233
+ if ('subMenu' in menuItem &&
234
+ (e.key === 'ArrowRight' || e.key === 'Enter')) {
235
+ setSubMenuAnchorEl(e.currentTarget);
236
+ setOpenSubMenuIdx(idx);
237
+ setIsSubMenuOpen(true);
238
+ }
226
239
  }
227
240
  }
228
241
  }, disabled: Boolean(menuItem.disabled) },
package/ui/ResizeBar.js CHANGED
@@ -82,7 +82,12 @@ function Tick({ left, scrollLeft, idx, onDrag, }) {
82
82
  function ResizeBar({ widths, setWidths, checkbox, scrollLeft = 0, }) {
83
83
  const { classes } = useStyles();
84
84
  const offsets = [];
85
- widths.reduce((a, b, i) => (offsets[i] = a + b), checkbox ? 52 : 0);
85
+ let init = checkbox ? 52 : 0;
86
+ for (let i = 0; i < widths.length; i++) {
87
+ const width = widths[i];
88
+ offsets[i] = width + init;
89
+ init += width;
90
+ }
86
91
  const onDrag = (0, react_1.useCallback)((distance, idx) => {
87
92
  const newWidths = [...widths];
88
93
  // mui doesn't allow columns smaller than 50
@@ -72,12 +72,9 @@ function ResizeHandle({ onDrag, vertical = false, flexbox = false, className: or
72
72
  }, [mouseDragging, onDrag, vertical]);
73
73
  let className;
74
74
  if (flexbox) {
75
- if (vertical) {
76
- className = classes.flexbox_verticalHandle;
77
- }
78
- else {
79
- className = classes.flexbox_horizontalHandle;
80
- }
75
+ className = vertical
76
+ ? classes.flexbox_verticalHandle
77
+ : classes.flexbox_horizontalHandle;
81
78
  }
82
79
  else if (vertical) {
83
80
  className = classes.verticalHandle;
@@ -1,10 +1,9 @@
1
1
  import React from 'react';
2
2
  import { IBaseViewModel } from '../pluggableElementTypes/models';
3
- declare const ViewContainer: ({ view, onClose, onMinimize, style, children, }: {
3
+ declare const _default: ({ view, onClose, onMinimize, children, }: {
4
4
  view: IBaseViewModel;
5
5
  onClose: () => void;
6
6
  onMinimize: () => void;
7
- style?: React.CSSProperties | undefined;
8
7
  children: React.ReactNode;
9
8
  }) => JSX.Element;
10
- export default ViewContainer;
9
+ export default _default;
@@ -30,19 +30,19 @@ const react_1 = __importStar(require("react"));
30
30
  const material_1 = require("@mui/material");
31
31
  const mui_1 = require("tss-react/mui");
32
32
  const mobx_react_1 = require("mobx-react");
33
- const mobx_state_tree_1 = require("mobx-state-tree");
34
- const react_use_measure_1 = __importDefault(require("react-use-measure"));
35
33
  // icons
36
34
  const Close_1 = __importDefault(require("@mui/icons-material/Close"));
37
35
  const Minimize_1 = __importDefault(require("@mui/icons-material/Minimize"));
38
36
  const Add_1 = __importDefault(require("@mui/icons-material/Add"));
39
- const EditableTypography_1 = __importDefault(require("./EditableTypography"));
40
37
  const ViewMenu_1 = __importDefault(require("./ViewMenu"));
38
+ const util_1 = require("../util");
39
+ const ViewContainerTitle_1 = __importDefault(require("./ViewContainerTitle"));
41
40
  const useStyles = (0, mui_1.makeStyles)()(theme => ({
42
41
  viewContainer: {
43
42
  overflow: 'hidden',
44
43
  background: theme.palette.secondary.main,
45
44
  margin: theme.spacing(0.5),
45
+ padding: `0 ${theme.spacing(1)} ${theme.spacing(1)}`,
46
46
  },
47
47
  icon: {
48
48
  color: theme.palette.secondary.contrastText,
@@ -50,34 +50,11 @@ const useStyles = (0, mui_1.makeStyles)()(theme => ({
50
50
  grow: {
51
51
  flexGrow: 1,
52
52
  },
53
- input: {
54
- paddingBottom: 0,
55
- paddingTop: 2,
56
- },
57
- inputBase: {
58
- color: theme.palette.secondary.contrastText,
59
- },
60
- inputRoot: {
61
- '&:hover': {
62
- backgroundColor: theme.palette.secondary.light,
63
- },
64
- },
65
- inputFocused: {
66
- borderColor: theme.palette.primary.main,
67
- backgroundColor: theme.palette.secondary.light,
68
- },
69
53
  }));
70
- const ViewContainer = (0, mobx_react_1.observer)(function ({ view, onClose, onMinimize, style, children, }) {
71
- var _a;
54
+ exports.default = (0, mobx_react_1.observer)(function ({ view, onClose, onMinimize, children, }) {
72
55
  const { classes } = useStyles();
73
56
  const theme = (0, material_1.useTheme)();
74
- const padWidth = theme.spacing(1);
75
- const [ref, { width }] = (0, react_use_measure_1.default)();
76
- (0, react_1.useEffect)(() => {
77
- if (width && (0, mobx_state_tree_1.isAlive)(view)) {
78
- view.setWidth(width - parseInt(padWidth, 10) * 2);
79
- }
80
- }, [padWidth, view, width]);
57
+ const ref = (0, util_1.useWidthSetter)(view, theme.spacing(1));
81
58
  const scrollRef = (0, react_1.useRef)(null);
82
59
  // scroll the view into view when first mounted
83
60
  // note that this effect will run only once, because of
@@ -86,25 +63,14 @@ const ViewContainer = (0, mobx_react_1.observer)(function ({ view, onClose, onMi
86
63
  var _a, _b;
87
64
  (_b = (_a = scrollRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(_a, { block: 'center' });
88
65
  }, []);
89
- return (react_1.default.createElement(material_1.Paper, { ref: ref, elevation: 12, className: classes.viewContainer, style: { ...style, padding: `0px ${padWidth} ${padWidth}` } },
66
+ return (react_1.default.createElement(material_1.Paper, { ref: ref, elevation: 12, className: classes.viewContainer },
90
67
  react_1.default.createElement("div", { ref: scrollRef, style: { display: 'flex' } },
91
68
  react_1.default.createElement(ViewMenu_1.default, { model: view, IconProps: { className: classes.icon } }),
92
69
  react_1.default.createElement("div", { className: classes.grow }),
93
- react_1.default.createElement(material_1.Tooltip, { title: "Rename view", arrow: true },
94
- react_1.default.createElement(EditableTypography_1.default, { value: (view.displayName ||
95
- (
96
- // @ts-ignore
97
- (_a = view.assemblyNames) === null || _a === void 0 ? void 0 : _a.join(',')) ||
98
- 'Untitled view') + (view.minimized ? ' (minimized)' : ''), setValue: val => view.setDisplayName(val), variant: "body2", classes: {
99
- input: classes.input,
100
- inputBase: classes.inputBase,
101
- inputRoot: classes.inputRoot,
102
- inputFocused: classes.inputFocused,
103
- } })),
70
+ react_1.default.createElement(ViewContainerTitle_1.default, { view: view }),
104
71
  react_1.default.createElement("div", { className: classes.grow }),
105
72
  react_1.default.createElement(material_1.IconButton, { "data-testid": "minimize_view", onClick: onMinimize }, view.minimized ? (react_1.default.createElement(Add_1.default, { className: classes.icon, fontSize: "small" })) : (react_1.default.createElement(Minimize_1.default, { className: classes.icon, fontSize: "small" }))),
106
73
  react_1.default.createElement(material_1.IconButton, { "data-testid": "close_view", onClick: onClose },
107
74
  react_1.default.createElement(Close_1.default, { className: classes.icon, fontSize: "small" }))),
108
75
  react_1.default.createElement(material_1.Paper, null, children)));
109
76
  });
110
- exports.default = ViewContainer;
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import { IBaseViewModel } from '../pluggableElementTypes';
3
+ declare const _default: ({ view, }: {
4
+ view: IBaseViewModel;
5
+ }) => JSX.Element;
6
+ export default _default;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const material_1 = require("@mui/material");
8
+ const mui_1 = require("tss-react/mui");
9
+ const mobx_react_1 = require("mobx-react");
10
+ // locals
11
+ const EditableTypography_1 = __importDefault(require("./EditableTypography"));
12
+ const useStyles = (0, mui_1.makeStyles)()(theme => ({
13
+ input: {
14
+ paddingBottom: 0,
15
+ paddingTop: 2,
16
+ },
17
+ inputBase: {
18
+ color: theme.palette.secondary.contrastText,
19
+ },
20
+ inputRoot: {
21
+ '&:hover': {
22
+ backgroundColor: theme.palette.secondary.light,
23
+ },
24
+ },
25
+ inputFocused: {
26
+ borderColor: theme.palette.primary.main,
27
+ backgroundColor: theme.palette.secondary.light,
28
+ },
29
+ }));
30
+ exports.default = (0, mobx_react_1.observer)(function ViewContainerTitle({ view, }) {
31
+ var _a;
32
+ const { classes } = useStyles();
33
+ return (react_1.default.createElement(material_1.Tooltip, { title: "Rename view", arrow: true },
34
+ react_1.default.createElement(EditableTypography_1.default, { value: view.displayName ||
35
+ // @ts-expect-error
36
+ `${((_a = view.assemblyNames) === null || _a === void 0 ? void 0 : _a.join(',')) || 'Untitled view'}${view.minimized ? ' (minimized)' : ''}`, setValue: val => view.setDisplayName(val), variant: "body2", classes: {
37
+ input: classes.input,
38
+ inputBase: classes.inputBase,
39
+ inputRoot: classes.inputRoot,
40
+ inputFocused: classes.inputFocused,
41
+ } })));
42
+ });
package/ui/theme.js CHANGED
@@ -25,7 +25,7 @@ function stockTheme() {
25
25
  bases: {
26
26
  A: refTheme.palette.augmentColor({ color: colors_1.green }),
27
27
  C: refTheme.palette.augmentColor({ color: colors_1.blue }),
28
- G: refTheme.palette.augmentColor({ color: colors_1.amber }),
28
+ G: refTheme.palette.augmentColor({ color: colors_1.orange }),
29
29
  T: refTheme.palette.augmentColor({ color: colors_1.red }),
30
30
  },
31
31
  },
@@ -70,7 +70,7 @@ function getDarkStockTheme() {
70
70
  bases: {
71
71
  A: refTheme.palette.augmentColor({ color: colors_1.green }),
72
72
  C: refTheme.palette.augmentColor({ color: colors_1.blue }),
73
- G: refTheme.palette.augmentColor({ color: colors_1.amber }),
73
+ G: refTheme.palette.augmentColor({ color: colors_1.orange }),
74
74
  T: refTheme.palette.augmentColor({ color: colors_1.red }),
75
75
  },
76
76
  },
@@ -103,7 +103,7 @@ function getDarkMinimalTheme() {
103
103
  bases: {
104
104
  A: refTheme.palette.augmentColor({ color: colors_1.green }),
105
105
  C: refTheme.palette.augmentColor({ color: colors_1.blue }),
106
- G: refTheme.palette.augmentColor({ color: colors_1.amber }),
106
+ G: refTheme.palette.augmentColor({ color: colors_1.orange }),
107
107
  T: refTheme.palette.augmentColor({ color: colors_1.red }),
108
108
  },
109
109
  },
@@ -122,7 +122,7 @@ function getMinimalTheme() {
122
122
  bases: {
123
123
  A: refTheme.palette.augmentColor({ color: colors_1.green }),
124
124
  C: refTheme.palette.augmentColor({ color: colors_1.blue }),
125
- G: refTheme.palette.augmentColor({ color: colors_1.amber }),
125
+ G: refTheme.palette.augmentColor({ color: colors_1.orange }),
126
126
  T: refTheme.palette.augmentColor({ color: colors_1.red }),
127
127
  },
128
128
  },
@@ -226,7 +226,7 @@ function createDefaultProps(theme) {
226
226
  },
227
227
  styleOverrides: {
228
228
  secondary: {
229
- // @ts-ignore
229
+ // @ts-expect-error
230
230
  backgroundColor: (_b = (_a = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _a === void 0 ? void 0 : _a.quaternary) === null || _b === void 0 ? void 0 : _b.main,
231
231
  },
232
232
  },
@@ -348,11 +348,11 @@ function createDefaultProps(theme) {
348
348
  MuiAccordionSummary: {
349
349
  styleOverrides: {
350
350
  root: {
351
- // @ts-ignore
351
+ // @ts-expect-error
352
352
  backgroundColor: (_d = (_c = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _c === void 0 ? void 0 : _c.tertiary) === null || _d === void 0 ? void 0 : _d.main,
353
353
  },
354
354
  content: {
355
- // @ts-ignore
355
+ // @ts-expect-error
356
356
  color: (_f = (_e = theme === null || theme === void 0 ? void 0 : theme.palette) === null || _e === void 0 ? void 0 : _e.tertiary) === null || _f === void 0 ? void 0 : _f.contrastText,
357
357
  },
358
358
  },