@jbrowse/plugin-grid-bookmark 2.10.3 → 2.11.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.
@@ -118,7 +118,7 @@ const BookmarkGrid = (0, mobx_react_1.observer)(function ({ model, }) {
118
118
  const target = rows[row.id];
119
119
  model.updateBookmarkLabel(target, row.label);
120
120
  return row;
121
- }, onProcessRowUpdateError: e => session.notify(e.message, 'error'), checkboxSelection: true, onRowSelectionModelChange: newRowSelectionModel => {
121
+ }, onProcessRowUpdateError: e => session.notifyError(`${e}`, e), checkboxSelection: true, onRowSelectionModelChange: newRowSelectionModel => {
122
122
  if (bookmarksWithValidAssemblies.length > 0) {
123
123
  model.setSelectedBookmarks(newRowSelectionModel.map(value => ({
124
124
  ...rows[value],
@@ -3,5 +3,5 @@ import { IExtendedLGV } from '../../model';
3
3
  type LGV = IExtendedLGV;
4
4
  declare const Highlight: ({ model }: {
5
5
  model: LGV;
6
- }) => React.JSX.Element;
6
+ }) => React.JSX.Element[] | null;
7
7
  export default Highlight;
@@ -38,10 +38,7 @@ const useStyles = (0, mui_1.makeStyles)()({
38
38
  highlight: {
39
39
  height: '100%',
40
40
  position: 'absolute',
41
- textAlign: 'center',
42
41
  overflow: 'hidden',
43
- display: 'flex',
44
- alignItems: 'start',
45
42
  },
46
43
  });
47
44
  const Highlight = (0, mobx_react_1.observer)(function Highlight({ model }) {
@@ -49,6 +46,7 @@ const Highlight = (0, mobx_react_1.observer)(function Highlight({ model }) {
49
46
  const { classes } = useStyles();
50
47
  const session = (0, util_1.getSession)(model);
51
48
  const { showBookmarkHighlights, showBookmarkLabels } = model;
49
+ const { assemblyManager } = session;
52
50
  const assemblyNames = new Set(session.assemblyNames);
53
51
  const bookmarkWidget = session.widgets.get('GridBookmark');
54
52
  const bookmarks = (0, react_1.useRef)((_a = bookmarkWidget === null || bookmarkWidget === void 0 ? void 0 : bookmarkWidget.bookmarks) !== null && _a !== void 0 ? _a : []);
@@ -58,16 +56,19 @@ const Highlight = (0, mobx_react_1.observer)(function Highlight({ model }) {
58
56
  bookmarks.current = newBookmarkWidget.bookmarks;
59
57
  }
60
58
  }, [session, bookmarkWidget]);
61
- return (react_1.default.createElement(react_1.default.Fragment, null, showBookmarkHighlights && bookmarks.current
59
+ return showBookmarkHighlights && bookmarks.current
62
60
  ? bookmarks.current
63
61
  .filter(value => assemblyNames.has(value.assemblyName))
64
62
  .map(r => {
63
+ var _a;
64
+ const asm = assemblyManager.get(r.assemblyName);
65
+ const refName = (_a = asm === null || asm === void 0 ? void 0 : asm.getCanonicalRefName(r.refName)) !== null && _a !== void 0 ? _a : r.refName;
65
66
  const s = model.bpToPx({
66
- refName: r.refName,
67
+ refName: refName,
67
68
  coord: r.start,
68
69
  });
69
70
  const e = model.bpToPx({
70
- refName: r.refName,
71
+ refName: refName,
71
72
  coord: r.end,
72
73
  });
73
74
  return s && e
@@ -80,12 +81,16 @@ const Highlight = (0, mobx_react_1.observer)(function Highlight({ model }) {
80
81
  : undefined;
81
82
  })
82
83
  .filter(util_1.notEmpty)
83
- .map(({ left, width, highlight, label }, idx) => (react_1.default.createElement("div", { key: `${left}_${width}_${idx}`, className: classes.highlight, style: { left, width, background: highlight } }, showBookmarkLabels ? (react_1.default.createElement(material_1.Tooltip, { title: label, arrow: true },
84
+ .map(({ left, width, highlight, label }, idx) => (react_1.default.createElement("div", { key: `${left}_${width}_${idx}`, className: classes.highlight, style: {
85
+ left,
86
+ width,
87
+ background: highlight,
88
+ } }, showBookmarkLabels ? (react_1.default.createElement(material_1.Tooltip, { title: label, arrow: true },
84
89
  react_1.default.createElement(Bookmark_1.default, { fontSize: "small", sx: {
85
90
  color: `${(0, colord_1.colord)(highlight).alpha() !== 0
86
91
  ? (0, colord_1.colord)(highlight).alpha(0.8).toRgbString()
87
92
  : (0, colord_1.colord)(highlight).alpha(0).toRgbString()}`,
88
93
  } }))) : null)))
89
- : null));
94
+ : null;
90
95
  });
91
96
  exports.default = Highlight;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { Base1DViewModel } from '@jbrowse/core/util/Base1DViewModel';
3
+ import { IExtendedLGV } from '../../model';
4
+ type LGV = IExtendedLGV;
5
+ declare const OverviewHighlight: ({ model, overview, }: {
6
+ model: LGV;
7
+ overview: Base1DViewModel;
8
+ }) => React.JSX.Element[] | null;
9
+ export default OverviewHighlight;
@@ -0,0 +1,82 @@
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 mobx_react_1 = require("mobx-react");
28
+ const mui_1 = require("tss-react/mui");
29
+ const util_1 = require("@jbrowse/core/util");
30
+ const material_1 = require("@mui/material");
31
+ const useStyles = (0, mui_1.makeStyles)()({
32
+ highlight: {
33
+ height: '100%',
34
+ position: 'absolute',
35
+ },
36
+ });
37
+ const OverviewHighlight = (0, mobx_react_1.observer)(function OverviewHighlight({ model, overview, }) {
38
+ var _a;
39
+ const { cytobandOffset } = model;
40
+ const session = (0, util_1.getSession)(model);
41
+ const { classes } = useStyles();
42
+ const { showBookmarkHighlights, showBookmarkLabels } = model;
43
+ const assemblyNames = new Set(session.assemblyNames);
44
+ const bookmarkWidget = session.widgets.get('GridBookmark');
45
+ const bookmarks = (0, react_1.useRef)((_a = bookmarkWidget === null || bookmarkWidget === void 0 ? void 0 : bookmarkWidget.bookmarks) !== null && _a !== void 0 ? _a : []);
46
+ (0, react_1.useEffect)(() => {
47
+ if (!bookmarkWidget) {
48
+ const newBookmarkWidget = session.addWidget('GridBookmarkWidget', 'GridBookmark');
49
+ bookmarks.current = newBookmarkWidget.bookmarks;
50
+ }
51
+ }, [session, bookmarkWidget]);
52
+ return showBookmarkHighlights && bookmarks.current
53
+ ? bookmarks.current
54
+ .filter(value => assemblyNames.has(value.assemblyName))
55
+ .map(r => {
56
+ const rev = r.reversed;
57
+ const s = overview.bpToPx({ ...r, coord: rev ? r.end : r.start });
58
+ const e = overview.bpToPx({ ...r, coord: rev ? r.start : r.end });
59
+ return s !== undefined && e !== undefined
60
+ ? {
61
+ width: Math.abs(e - s),
62
+ left: s + cytobandOffset,
63
+ highlight: r.highlight,
64
+ label: r.label,
65
+ }
66
+ : undefined;
67
+ })
68
+ .filter(util_1.notEmpty)
69
+ .map((obj, idx) => {
70
+ const { left, width, highlight, label } = obj;
71
+ return (react_1.default.createElement(material_1.Tooltip, { key: JSON.stringify(obj) + '-' + idx, title: showBookmarkLabels ? label : '', arrow: true },
72
+ react_1.default.createElement("div", { className: classes.highlight, style: {
73
+ left,
74
+ width,
75
+ background: highlight,
76
+ borderLeft: `1px solid ${highlight}`,
77
+ borderRight: `1px solid ${highlight}`,
78
+ } })));
79
+ })
80
+ : null;
81
+ });
82
+ exports.default = OverviewHighlight;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
7
  // locals
8
8
  const Highlight_1 = __importDefault(require("./Highlight"));
9
+ const OverviewHighlight_1 = __importDefault(require("./OverviewHighlight"));
9
10
  function AddHighlightModelF(pluginManager) {
10
11
  pluginManager.addToExtensionPoint('LinearGenomeView-TracksContainerComponent',
11
12
  // @ts-expect-error
@@ -15,5 +16,13 @@ function AddHighlightModelF(pluginManager) {
15
16
  react_1.default.createElement(Highlight_1.default, { key: `highlight_grid_bookmark`, model: model }),
16
17
  ];
17
18
  });
19
+ pluginManager.addToExtensionPoint('LinearGenomeView-OverviewScalebarComponent',
20
+ // @ts-expect-error
21
+ (rest = [], { model, overview }) => {
22
+ return [
23
+ ...rest,
24
+ react_1.default.createElement(OverviewHighlight_1.default, { key: `overview_highlight_grid_bookmark`, model: model, overview: overview }),
25
+ ];
26
+ });
18
27
  }
19
28
  exports.default = AddHighlightModelF;
@@ -20,7 +20,7 @@ const LabeledRegionModel = mobx_state_tree_1.types
20
20
  const SharedBookmarksModel = mobx_state_tree_1.types.model('SharedBookmarksModel', {
21
21
  sharedBookmarks: mobx_state_tree_1.types.maybe(mobx_state_tree_1.types.array(LabeledRegionModel)),
22
22
  });
23
- const localStorageKeyF = () => typeof window !== undefined
23
+ const localStorageKeyF = () => typeof window !== 'undefined'
24
24
  ? `bookmarks-${[window.location.host + window.location.pathname].join('-')}`
25
25
  : 'empty';
26
26
  /**
@@ -49,7 +49,7 @@ async function navToBookmark(locString, assembly, views, model) {
49
49
  }
50
50
  catch (e) {
51
51
  console.error(e);
52
- session.notify(`${e}`, 'error');
52
+ session.notifyError(`${e}`, e);
53
53
  }
54
54
  }
55
55
  exports.navToBookmark = navToBookmark;
@@ -90,7 +90,7 @@ const BookmarkGrid = observer(function ({ model, }) {
90
90
  const target = rows[row.id];
91
91
  model.updateBookmarkLabel(target, row.label);
92
92
  return row;
93
- }, onProcessRowUpdateError: e => session.notify(e.message, 'error'), checkboxSelection: true, onRowSelectionModelChange: newRowSelectionModel => {
93
+ }, onProcessRowUpdateError: e => session.notifyError(`${e}`, e), checkboxSelection: true, onRowSelectionModelChange: newRowSelectionModel => {
94
94
  if (bookmarksWithValidAssemblies.length > 0) {
95
95
  model.setSelectedBookmarks(newRowSelectionModel.map(value => ({
96
96
  ...rows[value],
@@ -3,5 +3,5 @@ import { IExtendedLGV } from '../../model';
3
3
  type LGV = IExtendedLGV;
4
4
  declare const Highlight: ({ model }: {
5
5
  model: LGV;
6
- }) => React.JSX.Element;
6
+ }) => React.JSX.Element[] | null;
7
7
  export default Highlight;
@@ -10,10 +10,7 @@ const useStyles = makeStyles()({
10
10
  highlight: {
11
11
  height: '100%',
12
12
  position: 'absolute',
13
- textAlign: 'center',
14
13
  overflow: 'hidden',
15
- display: 'flex',
16
- alignItems: 'start',
17
14
  },
18
15
  });
19
16
  const Highlight = observer(function Highlight({ model }) {
@@ -21,6 +18,7 @@ const Highlight = observer(function Highlight({ model }) {
21
18
  const { classes } = useStyles();
22
19
  const session = getSession(model);
23
20
  const { showBookmarkHighlights, showBookmarkLabels } = model;
21
+ const { assemblyManager } = session;
24
22
  const assemblyNames = new Set(session.assemblyNames);
25
23
  const bookmarkWidget = session.widgets.get('GridBookmark');
26
24
  const bookmarks = useRef((_a = bookmarkWidget === null || bookmarkWidget === void 0 ? void 0 : bookmarkWidget.bookmarks) !== null && _a !== void 0 ? _a : []);
@@ -30,16 +28,19 @@ const Highlight = observer(function Highlight({ model }) {
30
28
  bookmarks.current = newBookmarkWidget.bookmarks;
31
29
  }
32
30
  }, [session, bookmarkWidget]);
33
- return (React.createElement(React.Fragment, null, showBookmarkHighlights && bookmarks.current
31
+ return showBookmarkHighlights && bookmarks.current
34
32
  ? bookmarks.current
35
33
  .filter(value => assemblyNames.has(value.assemblyName))
36
34
  .map(r => {
35
+ var _a;
36
+ const asm = assemblyManager.get(r.assemblyName);
37
+ const refName = (_a = asm === null || asm === void 0 ? void 0 : asm.getCanonicalRefName(r.refName)) !== null && _a !== void 0 ? _a : r.refName;
37
38
  const s = model.bpToPx({
38
- refName: r.refName,
39
+ refName: refName,
39
40
  coord: r.start,
40
41
  });
41
42
  const e = model.bpToPx({
42
- refName: r.refName,
43
+ refName: refName,
43
44
  coord: r.end,
44
45
  });
45
46
  return s && e
@@ -52,12 +53,16 @@ const Highlight = observer(function Highlight({ model }) {
52
53
  : undefined;
53
54
  })
54
55
  .filter(notEmpty)
55
- .map(({ left, width, highlight, label }, idx) => (React.createElement("div", { key: `${left}_${width}_${idx}`, className: classes.highlight, style: { left, width, background: highlight } }, showBookmarkLabels ? (React.createElement(Tooltip, { title: label, arrow: true },
56
+ .map(({ left, width, highlight, label }, idx) => (React.createElement("div", { key: `${left}_${width}_${idx}`, className: classes.highlight, style: {
57
+ left,
58
+ width,
59
+ background: highlight,
60
+ } }, showBookmarkLabels ? (React.createElement(Tooltip, { title: label, arrow: true },
56
61
  React.createElement(BookmarkIcon, { fontSize: "small", sx: {
57
62
  color: `${colord(highlight).alpha() !== 0
58
63
  ? colord(highlight).alpha(0.8).toRgbString()
59
64
  : colord(highlight).alpha(0).toRgbString()}`,
60
65
  } }))) : null)))
61
- : null));
66
+ : null;
62
67
  });
63
68
  export default Highlight;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { Base1DViewModel } from '@jbrowse/core/util/Base1DViewModel';
3
+ import { IExtendedLGV } from '../../model';
4
+ type LGV = IExtendedLGV;
5
+ declare const OverviewHighlight: ({ model, overview, }: {
6
+ model: LGV;
7
+ overview: Base1DViewModel;
8
+ }) => React.JSX.Element[] | null;
9
+ export default OverviewHighlight;
@@ -0,0 +1,57 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { observer } from 'mobx-react';
3
+ import { makeStyles } from 'tss-react/mui';
4
+ import { getSession, notEmpty } from '@jbrowse/core/util';
5
+ import { Tooltip } from '@mui/material';
6
+ const useStyles = makeStyles()({
7
+ highlight: {
8
+ height: '100%',
9
+ position: 'absolute',
10
+ },
11
+ });
12
+ const OverviewHighlight = observer(function OverviewHighlight({ model, overview, }) {
13
+ var _a;
14
+ const { cytobandOffset } = model;
15
+ const session = getSession(model);
16
+ const { classes } = useStyles();
17
+ const { showBookmarkHighlights, showBookmarkLabels } = model;
18
+ const assemblyNames = new Set(session.assemblyNames);
19
+ const bookmarkWidget = session.widgets.get('GridBookmark');
20
+ const bookmarks = useRef((_a = bookmarkWidget === null || bookmarkWidget === void 0 ? void 0 : bookmarkWidget.bookmarks) !== null && _a !== void 0 ? _a : []);
21
+ useEffect(() => {
22
+ if (!bookmarkWidget) {
23
+ const newBookmarkWidget = session.addWidget('GridBookmarkWidget', 'GridBookmark');
24
+ bookmarks.current = newBookmarkWidget.bookmarks;
25
+ }
26
+ }, [session, bookmarkWidget]);
27
+ return showBookmarkHighlights && bookmarks.current
28
+ ? bookmarks.current
29
+ .filter(value => assemblyNames.has(value.assemblyName))
30
+ .map(r => {
31
+ const rev = r.reversed;
32
+ const s = overview.bpToPx({ ...r, coord: rev ? r.end : r.start });
33
+ const e = overview.bpToPx({ ...r, coord: rev ? r.start : r.end });
34
+ return s !== undefined && e !== undefined
35
+ ? {
36
+ width: Math.abs(e - s),
37
+ left: s + cytobandOffset,
38
+ highlight: r.highlight,
39
+ label: r.label,
40
+ }
41
+ : undefined;
42
+ })
43
+ .filter(notEmpty)
44
+ .map((obj, idx) => {
45
+ const { left, width, highlight, label } = obj;
46
+ return (React.createElement(Tooltip, { key: JSON.stringify(obj) + '-' + idx, title: showBookmarkLabels ? label : '', arrow: true },
47
+ React.createElement("div", { className: classes.highlight, style: {
48
+ left,
49
+ width,
50
+ background: highlight,
51
+ borderLeft: `1px solid ${highlight}`,
52
+ borderRight: `1px solid ${highlight}`,
53
+ } })));
54
+ })
55
+ : null;
56
+ });
57
+ export default OverviewHighlight;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  // locals
3
3
  import Highlight from './Highlight';
4
+ import OverviewHighlight from './OverviewHighlight';
4
5
  export default function AddHighlightModelF(pluginManager) {
5
6
  pluginManager.addToExtensionPoint('LinearGenomeView-TracksContainerComponent',
6
7
  // @ts-expect-error
@@ -10,4 +11,12 @@ export default function AddHighlightModelF(pluginManager) {
10
11
  React.createElement(Highlight, { key: `highlight_grid_bookmark`, model: model }),
11
12
  ];
12
13
  });
14
+ pluginManager.addToExtensionPoint('LinearGenomeView-OverviewScalebarComponent',
15
+ // @ts-expect-error
16
+ (rest = [], { model, overview }) => {
17
+ return [
18
+ ...rest,
19
+ React.createElement(OverviewHighlight, { key: `overview_highlight_grid_bookmark`, model: model, overview: overview }),
20
+ ];
21
+ });
13
22
  }
@@ -18,7 +18,7 @@ const LabeledRegionModel = types
18
18
  const SharedBookmarksModel = types.model('SharedBookmarksModel', {
19
19
  sharedBookmarks: types.maybe(types.array(LabeledRegionModel)),
20
20
  });
21
- const localStorageKeyF = () => typeof window !== undefined
21
+ const localStorageKeyF = () => typeof window !== 'undefined'
22
22
  ? `bookmarks-${[window.location.host + window.location.pathname].join('-')}`
23
23
  : 'empty';
24
24
  /**
@@ -23,7 +23,7 @@ export async function navToBookmark(locString, assembly, views, model) {
23
23
  }
24
24
  catch (e) {
25
25
  console.error(e);
26
- session.notify(`${e}`, 'error');
26
+ session.notifyError(`${e}`, e);
27
27
  }
28
28
  }
29
29
  export function downloadBookmarkFile(fileFormat, model) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-grid-bookmark",
3
- "version": "2.10.3",
3
+ "version": "2.11.0",
4
4
  "description": "JBrowse 2 grid bookmark widget",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -46,7 +46,7 @@
46
46
  "@jbrowse/plugin-config": "^2.0.0",
47
47
  "@jbrowse/plugin-linear-genome-view": "^2.0.0",
48
48
  "@mui/material": "^5.0.0",
49
- "@mui/x-data-grid": "^6.0.1",
49
+ "@mui/x-data-grid": "^7.0.0",
50
50
  "mobx": "^6.0.0",
51
51
  "mobx-react": "^9.0.0",
52
52
  "mobx-state-tree": "^5.0.0",
@@ -59,5 +59,5 @@
59
59
  "distModule": "esm/index.js",
60
60
  "srcModule": "src/index.ts",
61
61
  "module": "esm/index.js",
62
- "gitHead": "c8fc800cd17decd72b2e971c7a6add3b95214e72"
62
+ "gitHead": "3d43a820b9274a6160aa4dc15616147f390d9094"
63
63
  }