@jbrowse/app-core 2.6.2 → 2.7.0

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 (53) hide show
  1. package/dist/AppFocus/index.d.ts +13 -0
  2. package/dist/AppFocus/index.js +24 -0
  3. package/dist/HistoryManagement/index.js +5 -2
  4. package/dist/JBrowseConfig/index.d.ts +29 -18
  5. package/dist/JBrowseConfig/index.js +8 -47
  6. package/dist/JBrowseModel/index.d.ts +34 -7
  7. package/dist/JBrowseModel/index.js +15 -0
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +1 -0
  10. package/dist/ui/App/App.d.ts +4 -4
  11. package/dist/ui/App/AppFab.d.ts +2 -2
  12. package/dist/ui/App/AppFab.js +2 -1
  13. package/dist/ui/App/DialogQueue.d.ts +2 -2
  14. package/dist/ui/App/DialogQueue.js +2 -1
  15. package/dist/ui/App/Drawer.d.ts +5 -6
  16. package/dist/ui/App/Drawer.js +49 -5
  17. package/dist/ui/App/DrawerHeader.d.ts +7 -0
  18. package/dist/ui/App/DrawerHeader.js +124 -0
  19. package/dist/ui/App/DrawerWidget.d.ts +2 -2
  20. package/dist/ui/App/DrawerWidget.js +2 -76
  21. package/dist/ui/App/ViewContainer.d.ts +2 -2
  22. package/dist/ui/App/ViewContainer.js +28 -3
  23. package/dist/ui/App/ViewContainerTitle.d.ts +2 -2
  24. package/dist/ui/App/ViewContainerTitle.js +2 -1
  25. package/dist/ui/App/ViewMenu.d.ts +1 -1
  26. package/dist/ui/App/ViewMenu.js +1 -1
  27. package/esm/AppFocus/index.d.ts +13 -0
  28. package/esm/AppFocus/index.js +20 -0
  29. package/esm/HistoryManagement/index.js +5 -2
  30. package/esm/JBrowseConfig/index.d.ts +29 -18
  31. package/esm/JBrowseConfig/index.js +8 -47
  32. package/esm/JBrowseModel/index.d.ts +34 -7
  33. package/esm/JBrowseModel/index.js +16 -1
  34. package/esm/index.d.ts +1 -0
  35. package/esm/index.js +1 -0
  36. package/esm/ui/App/App.d.ts +4 -4
  37. package/esm/ui/App/AppFab.d.ts +2 -2
  38. package/esm/ui/App/AppFab.js +2 -1
  39. package/esm/ui/App/DialogQueue.d.ts +2 -2
  40. package/esm/ui/App/DialogQueue.js +2 -1
  41. package/esm/ui/App/Drawer.d.ts +5 -6
  42. package/esm/ui/App/Drawer.js +26 -5
  43. package/esm/ui/App/DrawerHeader.d.ts +7 -0
  44. package/esm/ui/App/DrawerHeader.js +96 -0
  45. package/esm/ui/App/DrawerWidget.d.ts +2 -2
  46. package/esm/ui/App/DrawerWidget.js +1 -75
  47. package/esm/ui/App/ViewContainer.d.ts +2 -2
  48. package/esm/ui/App/ViewContainer.js +29 -4
  49. package/esm/ui/App/ViewContainerTitle.d.ts +2 -2
  50. package/esm/ui/App/ViewContainerTitle.js +2 -1
  51. package/esm/ui/App/ViewMenu.d.ts +1 -1
  52. package/esm/ui/App/ViewMenu.js +1 -1
  53. package/package.json +8 -8
@@ -0,0 +1,13 @@
1
+ /**
2
+ * #stateModel AppFocusMixin
3
+ * #category session
4
+ */
5
+ export declare function AppFocusMixin(): import("mobx-state-tree").IModelType<{
6
+ /**
7
+ * #property
8
+ * used to keep track of which view is in focus
9
+ */
10
+ focusedViewId: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
11
+ }, {
12
+ setFocusedViewId(viewId: string): void;
13
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AppFocusMixin = void 0;
4
+ const mobx_state_tree_1 = require("mobx-state-tree");
5
+ /**
6
+ * #stateModel AppFocusMixin
7
+ * #category session
8
+ */
9
+ function AppFocusMixin() {
10
+ return mobx_state_tree_1.types
11
+ .model({
12
+ /**
13
+ * #property
14
+ * used to keep track of which view is in focus
15
+ */
16
+ focusedViewId: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.string),
17
+ })
18
+ .actions(self => ({
19
+ setFocusedViewId(viewId) {
20
+ self.focusedViewId = viewId;
21
+ },
22
+ }));
23
+ }
24
+ exports.AppFocusMixin = AppFocusMixin;
@@ -23,18 +23,21 @@ function HistoryManagementMixin() {
23
23
  .actions(self => ({
24
24
  afterCreate() {
25
25
  document.addEventListener('keydown', e => {
26
+ var _a, _b;
26
27
  if (self.history.canRedo &&
27
28
  // ctrl+shift+z or cmd+shift+z
28
29
  (((e.ctrlKey || e.metaKey) && e.shiftKey && e.code === 'KeyZ') ||
29
30
  // ctrl+y
30
- (e.ctrlKey && !e.shiftKey && e.code === 'KeyY'))) {
31
+ (e.ctrlKey && !e.shiftKey && e.code === 'KeyY')) &&
32
+ ((_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.tagName.toUpperCase()) !== 'INPUT') {
31
33
  self.history.redo();
32
34
  }
33
35
  if (self.history.canUndo &&
34
36
  // ctrl+z or cmd+z
35
37
  (e.ctrlKey || e.metaKey) &&
36
38
  !e.shiftKey &&
37
- e.code === 'KeyZ') {
39
+ e.code === 'KeyZ' &&
40
+ ((_b = document.activeElement) === null || _b === void 0 ? void 0 : _b.tagName.toUpperCase()) !== 'INPUT') {
38
41
  self.history.undo();
39
42
  }
40
43
  });
@@ -17,9 +17,7 @@ export declare function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }:
17
17
  rpc: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
18
18
  defaultDriver: {
19
19
  type: string;
20
- description: string; /**
21
- * #slot configuration.formatDetails.feature
22
- */
20
+ description: string;
23
21
  defaultValue: string;
24
22
  };
25
23
  drivers: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IMapType<import("mobx-state-tree").ITypeUnion<import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<Record<string, any>>> | undefined, import("mobx-state-tree").ModelSnapshotType<Record<string, any>>, (Partial<import("mobx-state-tree/dist/internal").ExtractCFromProps<Record<string, any>>> & import("mobx-state-tree/dist/internal").NonEmptyObject) | undefined>>, [undefined]>;
@@ -32,27 +30,18 @@ export declare function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }:
32
30
  defaultValue: number;
33
31
  };
34
32
  formatDetails: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
35
- /**
36
- * #slot configuration.formatDetails.feature
37
- */
38
33
  feature: {
39
34
  type: string;
40
35
  description: string;
41
36
  defaultValue: {};
42
37
  contextVariable: string[];
43
38
  };
44
- /**
45
- * #slot configuration.formatDetails.subfeatures
46
- */
47
39
  subfeatures: {
48
40
  type: string;
49
41
  description: string;
50
42
  defaultValue: {};
51
43
  contextVariable: string[];
52
44
  };
53
- /**
54
- * #slot configuration.formatDetails.depth
55
- */
56
45
  depth: {
57
46
  type: string;
58
47
  defaultValue: number;
@@ -60,18 +49,12 @@ export declare function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }:
60
49
  };
61
50
  }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
62
51
  formatAbout: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
63
- /**
64
- * #slot configuration.formatAbout.config
65
- */
66
52
  config: {
67
53
  type: string;
68
54
  description: string;
69
55
  defaultValue: {};
70
56
  contextVariable: string[];
71
57
  };
72
- /**
73
- * #slot configuration.formatAbout.hideUris
74
- */
75
58
  hideUris: {
76
59
  type: string;
77
60
  defaultValue: boolean;
@@ -88,6 +71,34 @@ export declare function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }:
88
71
  type: string;
89
72
  defaultValue: boolean;
90
73
  };
74
+ hierarchical: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
75
+ sort: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
76
+ trackNames: {
77
+ type: string;
78
+ defaultValue: boolean;
79
+ };
80
+ categories: {
81
+ type: string;
82
+ defaultValue: boolean;
83
+ };
84
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
85
+ defaultCollapsed: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
86
+ categoryNames: {
87
+ type: string;
88
+ defaultValue: never[]; /**
89
+ * #slot configuration.highResolutionScaling
90
+ */
91
+ };
92
+ topLevelCategories: {
93
+ type: string;
94
+ defaultValue: boolean;
95
+ };
96
+ subCategories: {
97
+ type: string;
98
+ defaultValue: boolean;
99
+ };
100
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
101
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
91
102
  /**
92
103
  * #slot configuration.theme
93
104
  */
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.JBrowseConfigF = void 0;
7
7
  const configuration_1 = require("@jbrowse/core/configuration");
8
8
  const RpcManager_1 = __importDefault(require("@jbrowse/core/rpc/RpcManager"));
9
+ const product_core_1 = require("@jbrowse/product-core");
9
10
  const mobx_state_tree_1 = require("mobx-state-tree");
10
11
  /**
11
12
  * #config JBrowseRootConfig
@@ -26,52 +27,8 @@ function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }) {
26
27
  type: 'number',
27
28
  defaultValue: 2,
28
29
  },
29
- formatDetails: (0, configuration_1.ConfigurationSchema)('FormatDetails', {
30
- /**
31
- * #slot configuration.formatDetails.feature
32
- */
33
- feature: {
34
- type: 'frozen',
35
- description: 'adds extra fields to the feature details',
36
- defaultValue: {},
37
- contextVariable: ['feature'],
38
- },
39
- /**
40
- * #slot configuration.formatDetails.subfeatures
41
- */
42
- subfeatures: {
43
- type: 'frozen',
44
- description: 'adds extra fields to the subfeatures of a feature',
45
- defaultValue: {},
46
- contextVariable: ['feature'],
47
- },
48
- /**
49
- * #slot configuration.formatDetails.depth
50
- */
51
- depth: {
52
- type: 'number',
53
- defaultValue: 2,
54
- description: 'depth to iterate on subfeatures',
55
- },
56
- }),
57
- formatAbout: (0, configuration_1.ConfigurationSchema)('FormatAbout', {
58
- /**
59
- * #slot configuration.formatAbout.config
60
- */
61
- config: {
62
- type: 'frozen',
63
- description: 'formats configuration object in about dialog',
64
- defaultValue: {},
65
- contextVariable: ['config'],
66
- },
67
- /**
68
- * #slot configuration.formatAbout.hideUris
69
- */
70
- hideUris: {
71
- type: 'boolean',
72
- defaultValue: false,
73
- },
74
- }),
30
+ formatDetails: (0, product_core_1.FormatDetailsConfigSchemaFactory)(),
31
+ formatAbout: (0, product_core_1.FormatAboutConfigSchemaFactory)(),
75
32
  /*
76
33
  * #slot configuration.shareURL
77
34
  */
@@ -86,6 +43,7 @@ function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }) {
86
43
  type: 'boolean',
87
44
  defaultValue: false,
88
45
  },
46
+ hierarchical: (0, product_core_1.HierarchicalConfigSchemaFactory)(),
89
47
  /**
90
48
  * #slot configuration.theme
91
49
  */
@@ -96,7 +54,10 @@ function JBrowseConfigF({ pluginManager, assemblyConfigSchema, }) {
96
54
  /**
97
55
  * #slot configuration.extraThemes
98
56
  */
99
- extraThemes: { type: 'frozen', defaultValue: {} },
57
+ extraThemes: {
58
+ type: 'frozen',
59
+ defaultValue: {},
60
+ },
100
61
  /**
101
62
  * #slot configuration.logoPath
102
63
  */
@@ -15,7 +15,9 @@ export declare function JBrowseModelF({ pluginManager, assemblyConfigSchema, }:
15
15
  defaultValue: string;
16
16
  };
17
17
  drivers: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IMapType<import("mobx-state-tree").ITypeUnion<import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<Record<string, any>>> | undefined, import("mobx-state-tree").ModelSnapshotType<Record<string, any>>, (Partial<import("mobx-state-tree/dist/internal").ExtractCFromProps<Record<string, any>>> & import("mobx-state-tree/dist/internal").NonEmptyObject) | undefined>>, [undefined]>;
18
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
18
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>; /**
19
+ * #getter
20
+ */
19
21
  highResolutionScaling: {
20
22
  type: string;
21
23
  defaultValue: number;
@@ -59,11 +61,35 @@ export declare function JBrowseModelF({ pluginManager, assemblyConfigSchema, }:
59
61
  type: string;
60
62
  defaultValue: boolean;
61
63
  };
64
+ hierarchical: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
65
+ sort: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
66
+ trackNames: {
67
+ type: string;
68
+ defaultValue: boolean;
69
+ };
70
+ categories: {
71
+ type: string;
72
+ defaultValue: boolean;
73
+ };
74
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
75
+ defaultCollapsed: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
76
+ categoryNames: {
77
+ type: string;
78
+ defaultValue: never[];
79
+ };
80
+ topLevelCategories: {
81
+ type: string;
82
+ defaultValue: boolean;
83
+ };
84
+ subCategories: {
85
+ type: string;
86
+ defaultValue: boolean;
87
+ };
88
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
89
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
62
90
  theme: {
63
91
  type: string;
64
- defaultValue: {}; /**
65
- * #action
66
- */
92
+ defaultValue: {};
67
93
  };
68
94
  extraThemes: {
69
95
  type: string;
@@ -71,9 +97,6 @@ export declare function JBrowseModelF({ pluginManager, assemblyConfigSchema, }:
71
97
  };
72
98
  logoPath: {
73
99
  type: string;
74
- /**
75
- * #action
76
- */
77
100
  defaultValue: {
78
101
  uri: string;
79
102
  locationType: string;
@@ -133,6 +156,10 @@ export declare function JBrowseModelF({ pluginManager, assemblyConfigSchema, }:
133
156
  * #action
134
157
  */
135
158
  removePlugin(pluginDefinition: PluginDefinition): void;
159
+ /**
160
+ * #action
161
+ */
162
+ setDefaultSessionConf(sessionConf: AnyConfigurationModel): void;
136
163
  /**
137
164
  * #action
138
165
  */
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.JBrowseModelF = void 0;
4
4
  const mobx_state_tree_1 = require("mobx-state-tree");
5
5
  const configuration_1 = require("@jbrowse/core/configuration");
6
+ const mobx_1 = require("mobx");
6
7
  // locals
7
8
  const JBrowseConfig_1 = require("../JBrowseConfig");
8
9
  function JBrowseModelF({ pluginManager, assemblyConfigSchema, }) {
@@ -109,6 +110,20 @@ function JBrowseModelF({ pluginManager, assemblyConfigSchema, }) {
109
110
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
111
  (0, mobx_state_tree_1.getParent)(self).setPluginsUpdated(true);
111
112
  },
113
+ /**
114
+ * #action
115
+ */
116
+ setDefaultSessionConf(sessionConf) {
117
+ const newDefault =
118
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
+ (0, mobx_state_tree_1.getParent)(self).session.name === sessionConf.name
120
+ ? (0, mobx_state_tree_1.getSnapshot)(sessionConf)
121
+ : (0, mobx_1.toJS)(sessionConf);
122
+ if (!newDefault.name) {
123
+ throw new Error(`unable to set default session to ${newDefault.name}`);
124
+ }
125
+ self.defaultSession = (0, mobx_state_tree_1.cast)(newDefault);
126
+ },
112
127
  /**
113
128
  * #action
114
129
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './ui';
2
2
  export * from './HistoryManagement';
3
+ export * from './AppFocus';
3
4
  export * from './JBrowseConfig';
4
5
  export * from './JBrowseModel';
5
6
  export * from './Assemblies';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./ui"), exports);
18
18
  __exportStar(require("./HistoryManagement"), exports);
19
+ __exportStar(require("./AppFocus"), exports);
19
20
  __exportStar(require("./JBrowseConfig"), exports);
20
21
  __exportStar(require("./JBrowseModel"), exports);
21
22
  __exportStar(require("./Assemblies"), exports);
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- import { SessionWithDrawerWidgets } from '@jbrowse/core/util';
2
+ import { SessionWithFocusedViewAndDrawerWidgets } from '@jbrowse/core/util';
3
3
  import { SnackbarMessage } from '@jbrowse/core/ui/SnackbarModel';
4
4
  import { MenuItem as JBMenuItem } from '@jbrowse/core/ui/Menu';
5
- type Props = {
5
+ interface Props {
6
6
  HeaderButtons?: React.ReactElement;
7
- session: SessionWithDrawerWidgets & {
7
+ session: SessionWithFocusedViewAndDrawerWidgets & {
8
8
  savedSessionNames: string[];
9
9
  menus: {
10
10
  label: string;
@@ -14,6 +14,6 @@ type Props = {
14
14
  snackbarMessages: SnackbarMessage[];
15
15
  popSnackbarMessage: () => unknown;
16
16
  };
17
- };
17
+ }
18
18
  declare const App: (props: Props) => React.JSX.Element;
19
19
  export { App };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SessionWithDrawerWidgets } from '@jbrowse/core/util';
3
- declare const _default: ({ session, }: {
3
+ declare const AppFab: ({ session, }: {
4
4
  session: SessionWithDrawerWidgets;
5
5
  }) => React.JSX.Element | null;
6
- export default _default;
6
+ export default AppFab;
@@ -23,10 +23,11 @@ const useStyles = (0, mui_1.makeStyles)()(theme => ({
23
23
  right: theme.spacing(2),
24
24
  },
25
25
  }));
26
- exports.default = (0, mobx_react_1.observer)(function AppFab({ session, }) {
26
+ const AppFab = (0, mobx_react_1.observer)(function ({ session, }) {
27
27
  const { minimized, activeWidgets, drawerPosition } = session;
28
28
  const { classes } = useStyles();
29
29
  return activeWidgets.size > 0 && minimized ? (react_1.default.createElement(material_1.Tooltip, { title: "Open drawer widget" },
30
30
  react_1.default.createElement(material_1.Fab, { className: drawerPosition === 'right' ? classes.right : classes.left, color: "primary", "data-testid": "drawer-maximize", onClick: () => session.showWidgetDrawer() },
31
31
  react_1.default.createElement(Launch_1.default, null)))) : null;
32
32
  });
33
+ exports.default = AppFab;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { SessionWithDrawerWidgets } from '@jbrowse/core/util';
3
- declare const _default: ({ session, }: {
3
+ declare const DialogQueue: ({ session, }: {
4
4
  session: SessionWithDrawerWidgets;
5
5
  }) => React.JSX.Element;
6
- export default _default;
6
+ export default DialogQueue;
@@ -25,8 +25,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const react_1 = __importStar(require("react"));
27
27
  const mobx_react_1 = require("mobx-react");
28
- exports.default = (0, mobx_react_1.observer)(function ({ session, }) {
28
+ const DialogQueue = (0, mobx_react_1.observer)(function ({ session, }) {
29
29
  const { DialogComponent, DialogProps } = session;
30
30
  return (react_1.default.createElement(react_1.default.Fragment, null, DialogComponent ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement(react_1.default.Fragment, null) },
31
31
  react_1.default.createElement(DialogComponent, { ...DialogProps }))) : null));
32
32
  });
33
+ exports.default = DialogQueue;
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
- import { SessionWithDrawerWidgets } from '@jbrowse/core/util/types';
3
- declare function Drawer({ children, session, }: {
2
+ import { SessionWithFocusedViewAndDrawerWidgets } from '@jbrowse/core/util/types';
3
+ declare const Drawer: ({ children, session, }: {
4
4
  children: React.ReactNode;
5
- session: SessionWithDrawerWidgets;
6
- }): React.JSX.Element;
7
- declare const _default: typeof Drawer;
8
- export default _default;
5
+ session: SessionWithFocusedViewAndDrawerWidgets;
6
+ }) => React.JSX.Element;
7
+ export default Drawer;
@@ -1,9 +1,32 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const react_1 = __importDefault(require("react"));
29
+ const react_1 = __importStar(require("react"));
7
30
  const material_1 = require("@mui/material");
8
31
  const mui_1 = require("tss-react/mui");
9
32
  const mobx_react_1 = require("mobx-react");
@@ -23,12 +46,33 @@ const useStyles = (0, mui_1.makeStyles)()(theme => ({
23
46
  zIndex: theme.zIndex.drawer + 1,
24
47
  },
25
48
  }));
26
- function Drawer({ children, session, }) {
49
+ const Drawer = (0, mobx_react_1.observer)(function ({ children, session, }) {
27
50
  const { drawerPosition, drawerWidth } = session;
28
51
  const { classes } = useStyles();
29
- return (react_1.default.createElement(material_1.Paper, { className: classes.paper, elevation: 16, square: true },
52
+ const ref = (0, react_1.useRef)(null);
53
+ (0, react_1.useEffect)(() => {
54
+ function handleSelectView(e) {
55
+ var _a, _b;
56
+ if (e.target instanceof Element) {
57
+ if ((ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(e.target)) {
58
+ // @ts-ignore
59
+ const visibleWidgetId = (_b = (_a = session.visibleWidget) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.id;
60
+ if (visibleWidgetId) {
61
+ session.setFocusedViewId(visibleWidgetId);
62
+ }
63
+ }
64
+ }
65
+ }
66
+ document.addEventListener('mousedown', handleSelectView);
67
+ document.addEventListener('keydown', handleSelectView);
68
+ return () => {
69
+ document.removeEventListener('mousedown', handleSelectView);
70
+ document.removeEventListener('keydown', handleSelectView);
71
+ };
72
+ }, [ref, session]);
73
+ return (react_1.default.createElement(material_1.Paper, { ref: ref, className: classes.paper, elevation: 16, square: true },
30
74
  drawerPosition === 'right' ? (react_1.default.createElement(ResizeHandle_1.default, { onDrag: session.resizeDrawer, className: classes.resizeHandle, vertical: true })) : null,
31
75
  children,
32
76
  drawerPosition === 'left' ? (react_1.default.createElement(ResizeHandle_1.default, { onDrag: session.resizeDrawer, className: classes.resizeHandle, style: { left: drawerWidth }, vertical: true })) : null));
33
- }
34
- exports.default = (0, mobx_react_1.observer)(Drawer);
77
+ });
78
+ exports.default = Drawer;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { SessionWithFocusedViewAndDrawerWidgets } from '@jbrowse/core/util/types';
3
+ declare const DrawerHeader: ({ session, setToolbarHeight, }: {
4
+ session: SessionWithFocusedViewAndDrawerWidgets;
5
+ setToolbarHeight: (arg: number) => void;
6
+ }) => React.JSX.Element;
7
+ export default DrawerHeader;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const react_1 = __importStar(require("react"));
30
+ const material_1 = require("@mui/material");
31
+ const mui_1 = require("tss-react/mui");
32
+ const mobx_react_1 = require("mobx-react");
33
+ const util_1 = require("@jbrowse/core/util");
34
+ // icons
35
+ const Delete_1 = __importDefault(require("@mui/icons-material/Delete"));
36
+ const Close_1 = __importDefault(require("@mui/icons-material/Close"));
37
+ const Minimize_1 = __importDefault(require("@mui/icons-material/Minimize"));
38
+ const MoreVert_1 = __importDefault(require("@mui/icons-material/MoreVert"));
39
+ const useStyles = (0, mui_1.makeStyles)()(theme => ({
40
+ formControl: {
41
+ margin: 0,
42
+ },
43
+ spacer: {
44
+ flexGrow: 1,
45
+ },
46
+ drawerSelect: {
47
+ margin: 0,
48
+ color: theme.palette.secondary.contrastText,
49
+ },
50
+ dropDownIcon: {
51
+ color: theme.palette.secondary.contrastText,
52
+ },
53
+ headerFocused: {
54
+ background: theme.palette.secondary.main,
55
+ },
56
+ headerUnfocused: {
57
+ background: theme.palette.secondary.dark,
58
+ },
59
+ }));
60
+ const DrawerHeader = (0, mobx_react_1.observer)(function ({ session, setToolbarHeight, }) {
61
+ var _a, _b;
62
+ const { classes } = useStyles();
63
+ const focusedViewId = session.focusedViewId;
64
+ // @ts-ignore
65
+ const viewWidgetId = (_b = (_a = session.visibleWidget) === null || _a === void 0 ? void 0 : _a.view) === null || _b === void 0 ? void 0 : _b.id;
66
+ return (react_1.default.createElement(material_1.AppBar, { position: "sticky", className: focusedViewId === viewWidgetId
67
+ ? classes.headerFocused
68
+ : classes.headerUnfocused, ref: ref => setToolbarHeight((ref === null || ref === void 0 ? void 0 : ref.getBoundingClientRect().height) || 0) },
69
+ react_1.default.createElement(material_1.Toolbar, { disableGutters: true },
70
+ react_1.default.createElement(DrawerWidgetSelector, { session: session }),
71
+ react_1.default.createElement("div", { className: classes.spacer }),
72
+ react_1.default.createElement(DrawerControls, { session: session }))));
73
+ });
74
+ const DrawerWidgetSelector = (0, mobx_react_1.observer)(function ({ session, }) {
75
+ const { visibleWidget, activeWidgets } = session;
76
+ const { classes } = useStyles();
77
+ const { pluginManager } = (0, util_1.getEnv)(session);
78
+ return (react_1.default.createElement(material_1.FormControl, { className: classes.formControl },
79
+ react_1.default.createElement(material_1.Select, { value: visibleWidget === null || visibleWidget === void 0 ? void 0 : visibleWidget.id, "data-testid": "widget-drawer-selects", className: classes.drawerSelect, classes: { icon: classes.dropDownIcon }, renderValue: widgetId => {
80
+ const widget = session.activeWidgets.get(widgetId);
81
+ if (!widget) {
82
+ return (react_1.default.createElement(material_1.Typography, { variant: "h6", color: "inherit" }, "Unknown widget"));
83
+ }
84
+ const widgetType = pluginManager.getWidgetType(widget.type);
85
+ const { HeadingComponent, heading } = widgetType;
86
+ return HeadingComponent ? (react_1.default.createElement(HeadingComponent, { model: widget })) : (react_1.default.createElement(material_1.Typography, { variant: "h6", color: "inherit" }, heading));
87
+ }, onChange: e => {
88
+ const w = session.activeWidgets.get(e.target.value);
89
+ if (w) {
90
+ session.showWidget(w);
91
+ }
92
+ else {
93
+ session.notify(`Widget not found ${e.target.value}`, 'warning');
94
+ }
95
+ } }, [...activeWidgets.values()].map(widget => {
96
+ const widgetType = pluginManager.getWidgetType(widget.type);
97
+ const { HeadingComponent, heading } = widgetType;
98
+ return (react_1.default.createElement(material_1.MenuItem, { "data-testid": `widget-drawer-selects-item-${widget.type}`, key: widget.id, value: widget.id },
99
+ HeadingComponent ? (react_1.default.createElement(HeadingComponent, { model: widget })) : (react_1.default.createElement(material_1.Typography, { variant: "h6", color: "inherit" }, heading)),
100
+ react_1.default.createElement(material_1.IconButton, { "data-testid": `${widget.type}-drawer-delete`, color: "inherit", "aria-label": "Delete", onClick: () => session.hideWidget(widget) },
101
+ react_1.default.createElement(Delete_1.default, null))));
102
+ }))));
103
+ });
104
+ const DrawerControls = (0, mobx_react_1.observer)(function ({ session, }) {
105
+ const [anchorEl, setAnchorEl] = (0, react_1.useState)(null);
106
+ const { drawerPosition, visibleWidget } = session;
107
+ return (react_1.default.createElement(react_1.default.Fragment, null,
108
+ react_1.default.createElement(material_1.IconButton, { color: "inherit", onClick: event => setAnchorEl(event.currentTarget) },
109
+ react_1.default.createElement(MoreVert_1.default, null)),
110
+ react_1.default.createElement(material_1.Tooltip, { title: "Minimize drawer" },
111
+ react_1.default.createElement(material_1.IconButton, { "data-testid": "drawer-minimize", color: "inherit", onClick: () => {
112
+ session.notify(`Drawer minimized, click button on ${drawerPosition} side of screen to re-open`, 'info');
113
+ session.minimizeWidgetDrawer();
114
+ } },
115
+ react_1.default.createElement(Minimize_1.default, null))),
116
+ react_1.default.createElement(material_1.Tooltip, { title: "Close drawer" },
117
+ react_1.default.createElement(material_1.IconButton, { color: "inherit", onClick: () => session.hideWidget(visibleWidget) },
118
+ react_1.default.createElement(Close_1.default, null))),
119
+ react_1.default.createElement(material_1.Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: () => setAnchorEl(null) }, ['left', 'right'].map(option => (react_1.default.createElement(material_1.MenuItem, { key: option, selected: drawerPosition === 'option', onClick: () => {
120
+ session.setDrawerPosition(option);
121
+ setAnchorEl(null);
122
+ } }, option))))));
123
+ });
124
+ exports.default = DrawerHeader;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { SessionWithDrawerWidgets } from '@jbrowse/core/util/types';
2
+ import { SessionWithFocusedViewAndDrawerWidgets } from '@jbrowse/core/util/types';
3
3
  declare const DrawerWidget: ({ session, }: {
4
- session: SessionWithDrawerWidgets;
4
+ session: SessionWithFocusedViewAndDrawerWidgets;
5
5
  }) => React.JSX.Element;
6
6
  export default DrawerWidget;