@jbrowse/embedded-core 2.6.1

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.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [2020] [Evolutionary Software Foundation]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,2 @@
1
+ export { default as ModalWidget } from './ui/ModalWidget';
2
+ export { default as EmbeddedViewContainer } from './ui/EmbeddedViewContainer';
package/dist/index.js ADDED
@@ -0,0 +1,10 @@
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
+ exports.EmbeddedViewContainer = exports.ModalWidget = void 0;
7
+ var ModalWidget_1 = require("./ui/ModalWidget");
8
+ Object.defineProperty(exports, "ModalWidget", { enumerable: true, get: function () { return __importDefault(ModalWidget_1).default; } });
9
+ var EmbeddedViewContainer_1 = require("./ui/EmbeddedViewContainer");
10
+ Object.defineProperty(exports, "EmbeddedViewContainer", { enumerable: true, get: function () { return __importDefault(EmbeddedViewContainer_1).default; } });
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
3
+ declare const ViewContainerWrapper: ({ view, children, }: {
4
+ view: IBaseViewModel;
5
+ children: React.ReactNode;
6
+ }) => React.JSX.Element;
7
+ export default ViewContainerWrapper;
@@ -0,0 +1,65 @@
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
+ const ViewTitle_1 = __importDefault(require("./ViewTitle"));
35
+ const useStyles = (0, mui_1.makeStyles)()(theme => ({
36
+ // avoid parent styles getting into this div
37
+ // https://css-tricks.com/almanac/properties/a/all/
38
+ avoidParentStyle: {
39
+ all: 'initial',
40
+ },
41
+ viewContainer: {
42
+ overflow: 'hidden',
43
+ background: theme.palette.secondary.main,
44
+ margin: theme.spacing(0.5),
45
+ padding: `0 ${theme.spacing(1)} ${theme.spacing(1)}`,
46
+ },
47
+ }));
48
+ const ViewContainer = (0, mobx_react_1.observer)(function ({ view, children, }) {
49
+ const { classes } = useStyles();
50
+ const session = (0, util_1.getSession)(view);
51
+ const theme = (0, material_1.useTheme)();
52
+ const ref = (0, util_1.useWidthSetter)(view, theme.spacing(1));
53
+ return (react_1.default.createElement(material_1.Paper, { elevation: 12, ref: ref, className: classes.viewContainer },
54
+ session.DialogComponent ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement("div", null) },
55
+ react_1.default.createElement(session.DialogComponent, { ...session.DialogProps }))) : null,
56
+ react_1.default.createElement(ViewTitle_1.default, { view: view }),
57
+ react_1.default.createElement(material_1.Paper, null, children)));
58
+ });
59
+ const ViewContainerWrapper = (0, mobx_react_1.observer)(function ({ view, children, }) {
60
+ const { classes } = useStyles();
61
+ return (react_1.default.createElement("div", { className: classes.avoidParentStyle },
62
+ react_1.default.createElement(material_1.ScopedCssBaseline, null,
63
+ react_1.default.createElement(ViewContainer, { view: view }, children))));
64
+ });
65
+ exports.default = ViewContainerWrapper;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { SessionWithWidgets } from '@jbrowse/core/util';
3
+ declare const _default: ({ session, }: {
4
+ session: SessionWithWidgets;
5
+ }) => React.JSX.Element | null;
6
+ export default _default;
@@ -0,0 +1,58 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ const react_1 = __importStar(require("react"));
27
+ const material_1 = require("@mui/material");
28
+ const ui_1 = require("@jbrowse/core/ui");
29
+ const mui_1 = require("tss-react/mui");
30
+ const mobx_react_1 = require("mobx-react");
31
+ const mobx_state_tree_1 = require("mobx-state-tree");
32
+ const useStyles = (0, mui_1.makeStyles)()({
33
+ paper: {
34
+ overflow: 'auto',
35
+ },
36
+ });
37
+ exports.default = (0, mobx_react_1.observer)(function ({ session, }) {
38
+ const { classes } = useStyles();
39
+ const { visibleWidget } = session;
40
+ const { pluginManager } = (0, mobx_state_tree_1.getEnv)(session);
41
+ if (!visibleWidget) {
42
+ return null;
43
+ }
44
+ const { ReactComponent, HeadingComponent, heading } = pluginManager.getWidgetType(visibleWidget.type);
45
+ const Component = visibleWidget
46
+ ? pluginManager.evaluateExtensionPoint('Core-replaceWidget', ReactComponent, {
47
+ session,
48
+ model: visibleWidget,
49
+ })
50
+ : null;
51
+ return (react_1.default.createElement(ui_1.Dialog, { open: true, onClose: () => session.hideAllWidgets(), maxWidth: "xl", header: react_1.default.createElement(material_1.AppBar, { position: "static" },
52
+ react_1.default.createElement(material_1.Toolbar, null, HeadingComponent ? (react_1.default.createElement(HeadingComponent, { model: visibleWidget })) : (react_1.default.createElement(material_1.Typography, { variant: "h6" }, heading)))) }, Component ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement("div", null, "Loading...") },
53
+ react_1.default.createElement(material_1.Paper, { className: classes.paper },
54
+ react_1.default.createElement(Component, { model: visibleWidget, session: session, overrideDimensions: {
55
+ height: (window.innerHeight * 5) / 8,
56
+ width: 800,
57
+ } })))) : null));
58
+ });
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export default function AboutDialog({ open, version, onClose, }: {
3
+ open: boolean;
4
+ version: string;
5
+ onClose: () => void;
6
+ }): React.JSX.Element;
@@ -0,0 +1,31 @@
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 ui_1 = require("@jbrowse/core/ui");
9
+ const mui_1 = require("tss-react/mui");
10
+ const useStyles = (0, mui_1.makeStyles)()({
11
+ content: {
12
+ minWidth: 800,
13
+ },
14
+ });
15
+ function AboutDialog({ open, version, onClose, }) {
16
+ const { classes } = useStyles();
17
+ return (react_1.default.createElement(ui_1.Dialog, { open: open, onClose: onClose, maxWidth: "xl", title: `JBrowse v${version}` },
18
+ react_1.default.createElement(material_1.DialogContent, { className: classes.content },
19
+ react_1.default.createElement(material_1.Typography, null, "JBrowse is a GMOD project \u00A9 2019-2021, The Evolutionary Software Foundation"),
20
+ react_1.default.createElement(material_1.Typography, null, "Here are some resources and documentation. Please report the version number above when asking questions. Thanks!"),
21
+ react_1.default.createElement("ul", null,
22
+ react_1.default.createElement("li", null,
23
+ react_1.default.createElement(material_1.Link, { href: "https://github.com/GMOD/jbrowse-components/discussions", target: "_blank", rel: "noopener noreferrer" }, "Question & answer forum")),
24
+ react_1.default.createElement("li", null,
25
+ react_1.default.createElement(material_1.Link, { href: "https://github.com/GMOD/jbrowse-components/issues/new/choose", target: "_blank", rel: "noopener noreferrer" }, "Report a bug")),
26
+ react_1.default.createElement("li", null,
27
+ react_1.default.createElement(material_1.Link, { href: "https://jbrowse.org/jb2/docs/user_guide", target: "_blank", rel: "noopener noreferrer" }, "User guide")),
28
+ react_1.default.createElement("li", null,
29
+ react_1.default.createElement(material_1.Link, { href: "https://jbrowse.org/jb2/docs/", target: "_blank", rel: "noopener noreferrer" }, "Documentation"))))));
30
+ }
31
+ exports.default = AboutDialog;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { IconButtonProps as IconButtonPropsType, SvgIconProps } from '@mui/material';
3
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
4
+ declare const ViewMenu: ({ model, IconButtonProps, IconProps, }: {
5
+ model: IBaseViewModel;
6
+ IconButtonProps: IconButtonPropsType;
7
+ IconProps: SvgIconProps;
8
+ }) => React.JSX.Element | null;
9
+ export default ViewMenu;
@@ -0,0 +1,16 @@
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 CascadingMenuButton_1 = __importDefault(require("@jbrowse/core/ui/CascadingMenuButton"));
8
+ const mobx_react_1 = require("mobx-react");
9
+ // icons
10
+ const Menu_1 = __importDefault(require("@mui/icons-material/Menu"));
11
+ const ViewMenu = (0, mobx_react_1.observer)(function ({ model, IconButtonProps, IconProps, }) {
12
+ const items = model.menuItems();
13
+ return items.length ? (react_1.default.createElement(CascadingMenuButton_1.default, { menuItems: items, "data-testid": "view_menu_icon" },
14
+ react_1.default.createElement(Menu_1.default, { ...IconProps }))) : null;
15
+ });
16
+ exports.default = ViewMenu;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
3
+ declare const _default: ({ view }: {
4
+ view: IBaseViewModel;
5
+ }) => React.JSX.Element;
6
+ export default _default;
@@ -0,0 +1,76 @@
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 mobx_react_1 = require("mobx-react");
32
+ const ui_1 = require("@jbrowse/core/ui");
33
+ const mui_1 = require("tss-react/mui");
34
+ const util_1 = require("@jbrowse/core/util");
35
+ // locals
36
+ const ViewMenu_1 = __importDefault(require("./ViewMenu"));
37
+ const VersionAboutDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./VersionAboutDialog'))));
38
+ const useStyles = (0, mui_1.makeStyles)()(theme => ({
39
+ icon: {
40
+ color: theme.palette.secondary.contrastText,
41
+ },
42
+ displayName: {
43
+ marginTop: 2,
44
+ color: theme.palette.secondary.contrastText,
45
+ },
46
+ grow: {
47
+ flexGrow: 1,
48
+ },
49
+ iconRoot: {
50
+ '&:hover': {
51
+ backgroundColor: (0, material_1.alpha)(theme.palette.secondary.contrastText, theme.palette.action.hoverOpacity),
52
+ '@media (hover: none)': {
53
+ backgroundColor: 'transparent',
54
+ },
55
+ },
56
+ },
57
+ }));
58
+ exports.default = (0, mobx_react_1.observer)(({ view }) => {
59
+ const { classes } = useStyles();
60
+ const { displayName } = view;
61
+ const [dlgOpen, setDlgOpen] = (0, react_1.useState)(false);
62
+ const session = (0, util_1.getSession)(view);
63
+ return (react_1.default.createElement("div", { style: { display: 'flex' } },
64
+ react_1.default.createElement(ViewMenu_1.default, { model: view, IconButtonProps: {
65
+ classes: { root: classes.iconRoot },
66
+ edge: 'start',
67
+ }, IconProps: { className: classes.icon } }),
68
+ react_1.default.createElement("div", { className: classes.grow }),
69
+ displayName ? (react_1.default.createElement(material_1.Typography, { variant: "body2", className: classes.displayName }, displayName)) : null,
70
+ react_1.default.createElement("div", { className: classes.grow }),
71
+ react_1.default.createElement(material_1.IconButton, { onClick: () => setDlgOpen(true) },
72
+ react_1.default.createElement("div", { style: { width: 22, height: 22 } },
73
+ react_1.default.createElement(ui_1.Logomark, { variant: "white" }))),
74
+ dlgOpen ? (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement("div", null) },
75
+ react_1.default.createElement(VersionAboutDialog, { open: true, onClose: () => setDlgOpen(false), version: session.version }))) : null));
76
+ });
package/esm/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as ModalWidget } from './ui/ModalWidget';
2
+ export { default as EmbeddedViewContainer } from './ui/EmbeddedViewContainer';
package/esm/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { default as ModalWidget } from './ui/ModalWidget';
2
+ export { default as EmbeddedViewContainer } from './ui/EmbeddedViewContainer';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
3
+ declare const ViewContainerWrapper: ({ view, children, }: {
4
+ view: IBaseViewModel;
5
+ children: React.ReactNode;
6
+ }) => React.JSX.Element;
7
+ export default ViewContainerWrapper;
@@ -0,0 +1,37 @@
1
+ import React, { Suspense } from 'react';
2
+ import { Paper, ScopedCssBaseline, useTheme } from '@mui/material';
3
+ import { makeStyles } from 'tss-react/mui';
4
+ import { observer } from 'mobx-react';
5
+ import { getSession, useWidthSetter } from '@jbrowse/core/util';
6
+ import ViewTitle from './ViewTitle';
7
+ const useStyles = makeStyles()(theme => ({
8
+ // avoid parent styles getting into this div
9
+ // https://css-tricks.com/almanac/properties/a/all/
10
+ avoidParentStyle: {
11
+ all: 'initial',
12
+ },
13
+ viewContainer: {
14
+ overflow: 'hidden',
15
+ background: theme.palette.secondary.main,
16
+ margin: theme.spacing(0.5),
17
+ padding: `0 ${theme.spacing(1)} ${theme.spacing(1)}`,
18
+ },
19
+ }));
20
+ const ViewContainer = observer(function ({ view, children, }) {
21
+ const { classes } = useStyles();
22
+ const session = getSession(view);
23
+ const theme = useTheme();
24
+ const ref = useWidthSetter(view, theme.spacing(1));
25
+ return (React.createElement(Paper, { elevation: 12, ref: ref, className: classes.viewContainer },
26
+ session.DialogComponent ? (React.createElement(Suspense, { fallback: React.createElement("div", null) },
27
+ React.createElement(session.DialogComponent, { ...session.DialogProps }))) : null,
28
+ React.createElement(ViewTitle, { view: view }),
29
+ React.createElement(Paper, null, children)));
30
+ });
31
+ const ViewContainerWrapper = observer(function ({ view, children, }) {
32
+ const { classes } = useStyles();
33
+ return (React.createElement("div", { className: classes.avoidParentStyle },
34
+ React.createElement(ScopedCssBaseline, null,
35
+ React.createElement(ViewContainer, { view: view }, children))));
36
+ });
37
+ export default ViewContainerWrapper;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { SessionWithWidgets } from '@jbrowse/core/util';
3
+ declare const _default: ({ session, }: {
4
+ session: SessionWithWidgets;
5
+ }) => React.JSX.Element | null;
6
+ export default _default;
@@ -0,0 +1,33 @@
1
+ import React, { Suspense } from 'react';
2
+ import { AppBar, Paper, Toolbar, Typography } from '@mui/material';
3
+ import { Dialog } from '@jbrowse/core/ui';
4
+ import { makeStyles } from 'tss-react/mui';
5
+ import { observer } from 'mobx-react';
6
+ import { getEnv } from 'mobx-state-tree';
7
+ const useStyles = makeStyles()({
8
+ paper: {
9
+ overflow: 'auto',
10
+ },
11
+ });
12
+ export default observer(function ({ session, }) {
13
+ const { classes } = useStyles();
14
+ const { visibleWidget } = session;
15
+ const { pluginManager } = getEnv(session);
16
+ if (!visibleWidget) {
17
+ return null;
18
+ }
19
+ const { ReactComponent, HeadingComponent, heading } = pluginManager.getWidgetType(visibleWidget.type);
20
+ const Component = visibleWidget
21
+ ? pluginManager.evaluateExtensionPoint('Core-replaceWidget', ReactComponent, {
22
+ session,
23
+ model: visibleWidget,
24
+ })
25
+ : null;
26
+ return (React.createElement(Dialog, { open: true, onClose: () => session.hideAllWidgets(), maxWidth: "xl", header: React.createElement(AppBar, { position: "static" },
27
+ React.createElement(Toolbar, null, HeadingComponent ? (React.createElement(HeadingComponent, { model: visibleWidget })) : (React.createElement(Typography, { variant: "h6" }, heading)))) }, Component ? (React.createElement(Suspense, { fallback: React.createElement("div", null, "Loading...") },
28
+ React.createElement(Paper, { className: classes.paper },
29
+ React.createElement(Component, { model: visibleWidget, session: session, overrideDimensions: {
30
+ height: (window.innerHeight * 5) / 8,
31
+ width: 800,
32
+ } })))) : null));
33
+ });
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ export default function AboutDialog({ open, version, onClose, }: {
3
+ open: boolean;
4
+ version: string;
5
+ onClose: () => void;
6
+ }): React.JSX.Element;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { DialogContent, Link, Typography } from '@mui/material';
3
+ import { Dialog } from '@jbrowse/core/ui';
4
+ import { makeStyles } from 'tss-react/mui';
5
+ const useStyles = makeStyles()({
6
+ content: {
7
+ minWidth: 800,
8
+ },
9
+ });
10
+ export default function AboutDialog({ open, version, onClose, }) {
11
+ const { classes } = useStyles();
12
+ return (React.createElement(Dialog, { open: open, onClose: onClose, maxWidth: "xl", title: `JBrowse v${version}` },
13
+ React.createElement(DialogContent, { className: classes.content },
14
+ React.createElement(Typography, null, "JBrowse is a GMOD project \u00A9 2019-2021, The Evolutionary Software Foundation"),
15
+ React.createElement(Typography, null, "Here are some resources and documentation. Please report the version number above when asking questions. Thanks!"),
16
+ React.createElement("ul", null,
17
+ React.createElement("li", null,
18
+ React.createElement(Link, { href: "https://github.com/GMOD/jbrowse-components/discussions", target: "_blank", rel: "noopener noreferrer" }, "Question & answer forum")),
19
+ React.createElement("li", null,
20
+ React.createElement(Link, { href: "https://github.com/GMOD/jbrowse-components/issues/new/choose", target: "_blank", rel: "noopener noreferrer" }, "Report a bug")),
21
+ React.createElement("li", null,
22
+ React.createElement(Link, { href: "https://jbrowse.org/jb2/docs/user_guide", target: "_blank", rel: "noopener noreferrer" }, "User guide")),
23
+ React.createElement("li", null,
24
+ React.createElement(Link, { href: "https://jbrowse.org/jb2/docs/", target: "_blank", rel: "noopener noreferrer" }, "Documentation"))))));
25
+ }
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { IconButtonProps as IconButtonPropsType, SvgIconProps } from '@mui/material';
3
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
4
+ declare const ViewMenu: ({ model, IconButtonProps, IconProps, }: {
5
+ model: IBaseViewModel;
6
+ IconButtonProps: IconButtonPropsType;
7
+ IconProps: SvgIconProps;
8
+ }) => React.JSX.Element | null;
9
+ export default ViewMenu;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import CascadingMenuButton from '@jbrowse/core/ui/CascadingMenuButton';
3
+ import { observer } from 'mobx-react';
4
+ // icons
5
+ import MenuIcon from '@mui/icons-material/Menu';
6
+ const ViewMenu = observer(function ({ model, IconButtonProps, IconProps, }) {
7
+ const items = model.menuItems();
8
+ return items.length ? (React.createElement(CascadingMenuButton, { menuItems: items, "data-testid": "view_menu_icon" },
9
+ React.createElement(MenuIcon, { ...IconProps }))) : null;
10
+ });
11
+ export default ViewMenu;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel';
3
+ declare const _default: ({ view }: {
4
+ view: IBaseViewModel;
5
+ }) => React.JSX.Element;
6
+ export default _default;
@@ -0,0 +1,48 @@
1
+ import React, { Suspense, lazy, useState } from 'react';
2
+ import { IconButton, Typography, alpha } from '@mui/material';
3
+ import { observer } from 'mobx-react';
4
+ import { Logomark } from '@jbrowse/core/ui';
5
+ import { makeStyles } from 'tss-react/mui';
6
+ import { getSession } from '@jbrowse/core/util';
7
+ // locals
8
+ import ViewMenu from './ViewMenu';
9
+ const VersionAboutDialog = lazy(() => import('./VersionAboutDialog'));
10
+ const useStyles = makeStyles()(theme => ({
11
+ icon: {
12
+ color: theme.palette.secondary.contrastText,
13
+ },
14
+ displayName: {
15
+ marginTop: 2,
16
+ color: theme.palette.secondary.contrastText,
17
+ },
18
+ grow: {
19
+ flexGrow: 1,
20
+ },
21
+ iconRoot: {
22
+ '&:hover': {
23
+ backgroundColor: alpha(theme.palette.secondary.contrastText, theme.palette.action.hoverOpacity),
24
+ '@media (hover: none)': {
25
+ backgroundColor: 'transparent',
26
+ },
27
+ },
28
+ },
29
+ }));
30
+ export default observer(({ view }) => {
31
+ const { classes } = useStyles();
32
+ const { displayName } = view;
33
+ const [dlgOpen, setDlgOpen] = useState(false);
34
+ const session = getSession(view);
35
+ return (React.createElement("div", { style: { display: 'flex' } },
36
+ React.createElement(ViewMenu, { model: view, IconButtonProps: {
37
+ classes: { root: classes.iconRoot },
38
+ edge: 'start',
39
+ }, IconProps: { className: classes.icon } }),
40
+ React.createElement("div", { className: classes.grow }),
41
+ displayName ? (React.createElement(Typography, { variant: "body2", className: classes.displayName }, displayName)) : null,
42
+ React.createElement("div", { className: classes.grow }),
43
+ React.createElement(IconButton, { onClick: () => setDlgOpen(true) },
44
+ React.createElement("div", { style: { width: 22, height: 22 } },
45
+ React.createElement(Logomark, { variant: "white" }))),
46
+ dlgOpen ? (React.createElement(Suspense, { fallback: React.createElement("div", null) },
47
+ React.createElement(VersionAboutDialog, { open: true, onClose: () => setDlgOpen(false), version: session.version }))) : null));
48
+ });
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@jbrowse/embedded-core",
3
+ "version": "2.6.1",
4
+ "description": "JBrowse 2 code shared between embedded products",
5
+ "keywords": [
6
+ "jbrowse",
7
+ "jbrowse2",
8
+ "bionode",
9
+ "biojs",
10
+ "genomics"
11
+ ],
12
+ "license": "Apache-2.0",
13
+ "homepage": "https://jbrowse.org",
14
+ "bugs": "https://github.com/GMOD/jbrowse-components/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/GMOD/jbrowse-components.git",
18
+ "directory": "packages/embedded-core"
19
+ },
20
+ "author": "JBrowse Team",
21
+ "distMain": "dist/index.js",
22
+ "distModule": "esm/index.js",
23
+ "srcMain": "src/index.ts",
24
+ "srcModule": "src/index.ts",
25
+ "main": "dist/index.js",
26
+ "module": "esm/index.js",
27
+ "files": [
28
+ "dist",
29
+ "esm",
30
+ "src"
31
+ ],
32
+ "scripts": {
33
+ "build:esm": "tsc --build tsconfig.build.esm.json",
34
+ "build:es5": "tsc --build tsconfig.build.es5.json",
35
+ "build": "npm run build:esm && npm run build:es5",
36
+ "test": "cd ../..; jest packages/embedded-core",
37
+ "clean": "rimraf dist esm *.tsbuildinfo",
38
+ "prebuild": "yarn clean",
39
+ "prepack": "yarn build && yarn useDist",
40
+ "postpack": "yarn useSrc",
41
+ "useDist": "node ../../scripts/useDist.js",
42
+ "useSrc": "node ../../scripts/useSrc.js"
43
+ },
44
+ "dependencies": {
45
+ "@babel/runtime": "^7.16.3",
46
+ "@jbrowse/product-core": "^2.6.1",
47
+ "@mui/icons-material": "^5.0.0",
48
+ "@mui/material": "^5.10.17",
49
+ "copy-to-clipboard": "^3.3.1",
50
+ "react-error-boundary": "^4.0.3",
51
+ "shortid": "^2.2.15"
52
+ },
53
+ "peerDependencies": {
54
+ "mobx": "^6.0.0",
55
+ "mobx-react": "^7.0.0",
56
+ "mobx-state-tree": "^5.0.0",
57
+ "react": "^17.0.0",
58
+ "react-dom": "^17.0.0",
59
+ "rxjs": "^7.0.0",
60
+ "tss-react": "^4.0.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ },
65
+ "gitHead": "1cbe7ba097fb2d2763c776e5e429e4670cdd583c"
66
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { default as ModalWidget } from './ui/ModalWidget'
2
+ export { default as EmbeddedViewContainer } from './ui/EmbeddedViewContainer'
@@ -0,0 +1,64 @@
1
+ import React, { Suspense } from 'react'
2
+ import { Paper, ScopedCssBaseline, useTheme } from '@mui/material'
3
+ import { makeStyles } from 'tss-react/mui'
4
+ import { observer } from 'mobx-react'
5
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel'
6
+ import { getSession, useWidthSetter } from '@jbrowse/core/util'
7
+ import ViewTitle from './ViewTitle'
8
+
9
+ const useStyles = makeStyles()(theme => ({
10
+ // avoid parent styles getting into this div
11
+ // https://css-tricks.com/almanac/properties/a/all/
12
+ avoidParentStyle: {
13
+ all: 'initial',
14
+ },
15
+ viewContainer: {
16
+ overflow: 'hidden',
17
+ background: theme.palette.secondary.main,
18
+ margin: theme.spacing(0.5),
19
+ padding: `0 ${theme.spacing(1)} ${theme.spacing(1)}`,
20
+ },
21
+ }))
22
+
23
+ const ViewContainer = observer(function ({
24
+ view,
25
+ children,
26
+ }: {
27
+ view: IBaseViewModel
28
+ children: React.ReactNode
29
+ }) {
30
+ const { classes } = useStyles()
31
+ const session = getSession(view)
32
+ const theme = useTheme()
33
+ const ref = useWidthSetter(view, theme.spacing(1))
34
+
35
+ return (
36
+ <Paper elevation={12} ref={ref} className={classes.viewContainer}>
37
+ {session.DialogComponent ? (
38
+ <Suspense fallback={<div />}>
39
+ <session.DialogComponent {...session.DialogProps} />
40
+ </Suspense>
41
+ ) : null}
42
+ <ViewTitle view={view} />
43
+ <Paper>{children}</Paper>
44
+ </Paper>
45
+ )
46
+ })
47
+
48
+ const ViewContainerWrapper = observer(function ({
49
+ view,
50
+ children,
51
+ }: {
52
+ view: IBaseViewModel
53
+ children: React.ReactNode
54
+ }) {
55
+ const { classes } = useStyles()
56
+ return (
57
+ <div className={classes.avoidParentStyle}>
58
+ <ScopedCssBaseline>
59
+ <ViewContainer view={view}>{children}</ViewContainer>
60
+ </ScopedCssBaseline>
61
+ </div>
62
+ )
63
+ })
64
+ export default ViewContainerWrapper
@@ -0,0 +1,74 @@
1
+ import React, { Suspense } from 'react'
2
+ import { AppBar, Paper, Toolbar, Typography } from '@mui/material'
3
+ import { Dialog } from '@jbrowse/core/ui'
4
+ import { makeStyles } from 'tss-react/mui'
5
+ import { observer } from 'mobx-react'
6
+ import { getEnv } from 'mobx-state-tree'
7
+ import { SessionWithWidgets } from '@jbrowse/core/util'
8
+
9
+ const useStyles = makeStyles()({
10
+ paper: {
11
+ overflow: 'auto',
12
+ },
13
+ })
14
+
15
+ export default observer(function ({
16
+ session,
17
+ }: {
18
+ session: SessionWithWidgets
19
+ }) {
20
+ const { classes } = useStyles()
21
+ const { visibleWidget } = session
22
+ const { pluginManager } = getEnv(session)
23
+
24
+ if (!visibleWidget) {
25
+ return null
26
+ }
27
+ const { ReactComponent, HeadingComponent, heading } =
28
+ pluginManager.getWidgetType(visibleWidget.type)
29
+
30
+ const Component = visibleWidget
31
+ ? (pluginManager.evaluateExtensionPoint(
32
+ 'Core-replaceWidget',
33
+ ReactComponent,
34
+ {
35
+ session,
36
+ model: visibleWidget,
37
+ },
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ ) as React.FC<any>)
40
+ : null
41
+ return (
42
+ <Dialog
43
+ open
44
+ onClose={() => session.hideAllWidgets()}
45
+ maxWidth="xl"
46
+ header={
47
+ <AppBar position="static">
48
+ <Toolbar>
49
+ {HeadingComponent ? (
50
+ <HeadingComponent model={visibleWidget} />
51
+ ) : (
52
+ <Typography variant="h6">{heading}</Typography>
53
+ )}
54
+ </Toolbar>
55
+ </AppBar>
56
+ }
57
+ >
58
+ {Component ? (
59
+ <Suspense fallback={<div>Loading...</div>}>
60
+ <Paper className={classes.paper}>
61
+ <Component
62
+ model={visibleWidget}
63
+ session={session}
64
+ overrideDimensions={{
65
+ height: (window.innerHeight * 5) / 8,
66
+ width: 800,
67
+ }}
68
+ />
69
+ </Paper>
70
+ </Suspense>
71
+ ) : null}
72
+ </Dialog>
73
+ )
74
+ })
@@ -0,0 +1,79 @@
1
+ import React from 'react'
2
+ import { DialogContent, Link, Typography } from '@mui/material'
3
+ import { Dialog } from '@jbrowse/core/ui'
4
+ import { makeStyles } from 'tss-react/mui'
5
+
6
+ const useStyles = makeStyles()({
7
+ content: {
8
+ minWidth: 800,
9
+ },
10
+ })
11
+
12
+ export default function AboutDialog({
13
+ open,
14
+ version,
15
+ onClose,
16
+ }: {
17
+ open: boolean
18
+ version: string
19
+ onClose: () => void
20
+ }) {
21
+ const { classes } = useStyles()
22
+ return (
23
+ <Dialog
24
+ open={open}
25
+ onClose={onClose}
26
+ maxWidth="xl"
27
+ title={`JBrowse v${version}`}
28
+ >
29
+ <DialogContent className={classes.content}>
30
+ <Typography>
31
+ JBrowse is a GMOD project © 2019-2021, The Evolutionary Software
32
+ Foundation
33
+ </Typography>
34
+ <Typography>
35
+ Here are some resources and documentation. Please report the version
36
+ number above when asking questions. Thanks!
37
+ </Typography>
38
+ <ul>
39
+ <li>
40
+ <Link
41
+ href="https://github.com/GMOD/jbrowse-components/discussions"
42
+ target="_blank"
43
+ rel="noopener noreferrer"
44
+ >
45
+ Question & answer forum
46
+ </Link>
47
+ </li>
48
+ <li>
49
+ <Link
50
+ href="https://github.com/GMOD/jbrowse-components/issues/new/choose"
51
+ target="_blank"
52
+ rel="noopener noreferrer"
53
+ >
54
+ Report a bug
55
+ </Link>
56
+ </li>
57
+ <li>
58
+ <Link
59
+ href="https://jbrowse.org/jb2/docs/user_guide"
60
+ target="_blank"
61
+ rel="noopener noreferrer"
62
+ >
63
+ User guide
64
+ </Link>
65
+ </li>
66
+ <li>
67
+ <Link
68
+ href="https://jbrowse.org/jb2/docs/"
69
+ target="_blank"
70
+ rel="noopener noreferrer"
71
+ >
72
+ Documentation
73
+ </Link>
74
+ </li>
75
+ </ul>
76
+ </DialogContent>
77
+ </Dialog>
78
+ )
79
+ }
@@ -0,0 +1,30 @@
1
+ import React from 'react'
2
+ import {
3
+ IconButtonProps as IconButtonPropsType,
4
+ SvgIconProps,
5
+ } from '@mui/material'
6
+ import CascadingMenuButton from '@jbrowse/core/ui/CascadingMenuButton'
7
+ import { observer } from 'mobx-react'
8
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel'
9
+
10
+ // icons
11
+ import MenuIcon from '@mui/icons-material/Menu'
12
+
13
+ const ViewMenu = observer(function ({
14
+ model,
15
+ IconButtonProps,
16
+ IconProps,
17
+ }: {
18
+ model: IBaseViewModel
19
+ IconButtonProps: IconButtonPropsType
20
+ IconProps: SvgIconProps
21
+ }) {
22
+ const items = model.menuItems()
23
+ return items.length ? (
24
+ <CascadingMenuButton menuItems={items} data-testid="view_menu_icon">
25
+ <MenuIcon {...IconProps} />
26
+ </CascadingMenuButton>
27
+ ) : null
28
+ })
29
+
30
+ export default ViewMenu
@@ -0,0 +1,76 @@
1
+ import React, { Suspense, lazy, useState } from 'react'
2
+ import { IconButton, Typography, alpha } from '@mui/material'
3
+ import { observer } from 'mobx-react'
4
+ import { IBaseViewModel } from '@jbrowse/core/pluggableElementTypes/models/BaseViewModel'
5
+ import { Logomark } from '@jbrowse/core/ui'
6
+ import { makeStyles } from 'tss-react/mui'
7
+ import { getSession } from '@jbrowse/core/util'
8
+
9
+ // locals
10
+ import ViewMenu from './ViewMenu'
11
+
12
+ const VersionAboutDialog = lazy(() => import('./VersionAboutDialog'))
13
+
14
+ const useStyles = makeStyles()(theme => ({
15
+ icon: {
16
+ color: theme.palette.secondary.contrastText,
17
+ },
18
+ displayName: {
19
+ marginTop: 2,
20
+ color: theme.palette.secondary.contrastText,
21
+ },
22
+ grow: {
23
+ flexGrow: 1,
24
+ },
25
+ iconRoot: {
26
+ '&:hover': {
27
+ backgroundColor: alpha(
28
+ theme.palette.secondary.contrastText,
29
+ theme.palette.action.hoverOpacity,
30
+ ),
31
+ '@media (hover: none)': {
32
+ backgroundColor: 'transparent',
33
+ },
34
+ },
35
+ },
36
+ }))
37
+
38
+ export default observer(({ view }: { view: IBaseViewModel }) => {
39
+ const { classes } = useStyles()
40
+ const { displayName } = view
41
+ const [dlgOpen, setDlgOpen] = useState(false)
42
+ const session = getSession(view)
43
+ return (
44
+ <div style={{ display: 'flex' }}>
45
+ <ViewMenu
46
+ model={view}
47
+ IconButtonProps={{
48
+ classes: { root: classes.iconRoot },
49
+ edge: 'start',
50
+ }}
51
+ IconProps={{ className: classes.icon }}
52
+ />
53
+ <div className={classes.grow} />
54
+ {displayName ? (
55
+ <Typography variant="body2" className={classes.displayName}>
56
+ {displayName}
57
+ </Typography>
58
+ ) : null}
59
+ <div className={classes.grow} />
60
+ <IconButton onClick={() => setDlgOpen(true)}>
61
+ <div style={{ width: 22, height: 22 }}>
62
+ <Logomark variant="white" />
63
+ </div>
64
+ </IconButton>
65
+ {dlgOpen ? (
66
+ <Suspense fallback={<div />}>
67
+ <VersionAboutDialog
68
+ open
69
+ onClose={() => setDlgOpen(false)}
70
+ version={session.version}
71
+ />
72
+ </Suspense>
73
+ ) : null}
74
+ </div>
75
+ )
76
+ })