@jbrowse/plugin-dotplot-view 3.6.5 → 3.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 (97) hide show
  1. package/dist/DiagonalizeDotplotRpc.d.ts +30 -0
  2. package/dist/DiagonalizeDotplotRpc.js +156 -0
  3. package/dist/DotplotDisplay/renderDotplotBlock.js +3 -0
  4. package/dist/DotplotDisplay/stateModelFactory.d.ts +6 -0
  5. package/dist/DotplotDisplay/stateModelFactory.js +15 -0
  6. package/dist/DotplotRenderer/DotplotRenderer.d.ts +3 -12
  7. package/dist/DotplotRenderer/clamp.d.ts +7 -0
  8. package/dist/DotplotRenderer/clamp.js +62 -0
  9. package/dist/DotplotRenderer/drawDotplot.d.ts +5 -4
  10. package/dist/DotplotRenderer/drawDotplot.js +92 -96
  11. package/dist/DotplotView/1dview.js +5 -3
  12. package/dist/DotplotView/components/ColorBySelector.d.ts +5 -0
  13. package/dist/DotplotView/components/ColorBySelector.js +79 -0
  14. package/dist/DotplotView/components/DiagonalizationProgressDialog.d.ts +6 -0
  15. package/dist/DotplotView/components/DiagonalizationProgressDialog.js +125 -0
  16. package/dist/DotplotView/components/DotplotControls.js +84 -12
  17. package/dist/DotplotView/components/DotplotTooltips.d.ts +15 -0
  18. package/dist/DotplotView/components/DotplotTooltips.js +43 -0
  19. package/dist/DotplotView/components/DotplotView.js +16 -191
  20. package/dist/DotplotView/components/DotplotWarnings.js +3 -3
  21. package/dist/DotplotView/components/ImportForm/index.js +0 -1
  22. package/dist/DotplotView/components/MinLengthSlider.d.ts +5 -0
  23. package/dist/DotplotView/components/MinLengthSlider.js +44 -0
  24. package/dist/DotplotView/components/MouseInteractionLayer.d.ts +17 -0
  25. package/dist/DotplotView/components/MouseInteractionLayer.js +18 -0
  26. package/dist/DotplotView/components/OpacitySlider.d.ts +5 -0
  27. package/dist/DotplotView/components/OpacitySlider.js +43 -0
  28. package/dist/DotplotView/components/SelectionContextMenu.d.ts +13 -0
  29. package/dist/DotplotView/components/SelectionContextMenu.js +42 -0
  30. package/dist/DotplotView/components/SliderTooltip.d.ts +2 -0
  31. package/dist/DotplotView/components/SliderTooltip.js +9 -0
  32. package/dist/DotplotView/components/hooks/useCtrlKeyTracking.d.ts +1 -0
  33. package/dist/DotplotView/components/hooks/useCtrlKeyTracking.js +24 -0
  34. package/dist/DotplotView/components/hooks/useCursorMode.d.ts +7 -0
  35. package/dist/DotplotView/components/hooks/useCursorMode.js +19 -0
  36. package/dist/DotplotView/components/hooks/useMouseCoordinates.d.ts +29 -0
  37. package/dist/DotplotView/components/hooks/useMouseCoordinates.js +52 -0
  38. package/dist/DotplotView/components/hooks/useMouseMoveHandler.d.ts +6 -0
  39. package/dist/DotplotView/components/hooks/useMouseMoveHandler.js +27 -0
  40. package/dist/DotplotView/components/hooks/useMouseUpHandler.d.ts +3 -0
  41. package/dist/DotplotView/components/hooks/useMouseUpHandler.js +31 -0
  42. package/dist/DotplotView/components/hooks/useWheelHandler.d.ts +8 -0
  43. package/dist/DotplotView/components/hooks/useWheelHandler.js +47 -0
  44. package/dist/DotplotView/components/util.js +1 -3
  45. package/dist/DotplotView/model.d.ts +5 -0
  46. package/dist/DotplotView/model.js +35 -20
  47. package/dist/ServerSideRenderedBlockContent.js +3 -20
  48. package/dist/index.js +2 -0
  49. package/esm/DiagonalizeDotplotRpc.d.ts +30 -0
  50. package/esm/DiagonalizeDotplotRpc.js +150 -0
  51. package/esm/DotplotDisplay/renderDotplotBlock.js +3 -0
  52. package/esm/DotplotDisplay/stateModelFactory.d.ts +6 -0
  53. package/esm/DotplotDisplay/stateModelFactory.js +15 -0
  54. package/esm/DotplotRenderer/DotplotRenderer.d.ts +3 -12
  55. package/esm/DotplotRenderer/clamp.d.ts +7 -0
  56. package/esm/DotplotRenderer/clamp.js +58 -0
  57. package/esm/DotplotRenderer/drawDotplot.d.ts +5 -4
  58. package/esm/DotplotRenderer/drawDotplot.js +92 -96
  59. package/esm/DotplotView/1dview.js +5 -3
  60. package/esm/DotplotView/components/ColorBySelector.d.ts +5 -0
  61. package/esm/DotplotView/components/ColorBySelector.js +74 -0
  62. package/esm/DotplotView/components/DiagonalizationProgressDialog.d.ts +6 -0
  63. package/esm/DotplotView/components/DiagonalizationProgressDialog.js +123 -0
  64. package/esm/DotplotView/components/DotplotControls.js +52 -13
  65. package/esm/DotplotView/components/DotplotTooltips.d.ts +15 -0
  66. package/esm/DotplotView/components/DotplotTooltips.js +7 -0
  67. package/esm/DotplotView/components/DotplotView.js +17 -159
  68. package/esm/DotplotView/components/DotplotWarnings.js +4 -4
  69. package/esm/DotplotView/components/ImportForm/index.js +0 -1
  70. package/esm/DotplotView/components/MinLengthSlider.d.ts +5 -0
  71. package/esm/DotplotView/components/MinLengthSlider.js +39 -0
  72. package/esm/DotplotView/components/MouseInteractionLayer.d.ts +17 -0
  73. package/esm/DotplotView/components/MouseInteractionLayer.js +12 -0
  74. package/esm/DotplotView/components/OpacitySlider.d.ts +5 -0
  75. package/esm/DotplotView/components/OpacitySlider.js +38 -0
  76. package/esm/DotplotView/components/SelectionContextMenu.d.ts +13 -0
  77. package/esm/DotplotView/components/SelectionContextMenu.js +39 -0
  78. package/esm/DotplotView/components/SliderTooltip.d.ts +2 -0
  79. package/esm/DotplotView/components/SliderTooltip.js +6 -0
  80. package/esm/DotplotView/components/hooks/useCtrlKeyTracking.d.ts +1 -0
  81. package/esm/DotplotView/components/hooks/useCtrlKeyTracking.js +21 -0
  82. package/esm/DotplotView/components/hooks/useCursorMode.d.ts +7 -0
  83. package/esm/DotplotView/components/hooks/useCursorMode.js +16 -0
  84. package/esm/DotplotView/components/hooks/useMouseCoordinates.d.ts +29 -0
  85. package/esm/DotplotView/components/hooks/useMouseCoordinates.js +49 -0
  86. package/esm/DotplotView/components/hooks/useMouseMoveHandler.d.ts +6 -0
  87. package/esm/DotplotView/components/hooks/useMouseMoveHandler.js +24 -0
  88. package/esm/DotplotView/components/hooks/useMouseUpHandler.d.ts +3 -0
  89. package/esm/DotplotView/components/hooks/useMouseUpHandler.js +28 -0
  90. package/esm/DotplotView/components/hooks/useWheelHandler.d.ts +8 -0
  91. package/esm/DotplotView/components/hooks/useWheelHandler.js +44 -0
  92. package/esm/DotplotView/components/util.js +1 -3
  93. package/esm/DotplotView/model.d.ts +5 -0
  94. package/esm/DotplotView/model.js +35 -20
  95. package/esm/ServerSideRenderedBlockContent.js +4 -21
  96. package/esm/index.js +2 -0
  97. package/package.json +4 -4
@@ -1,54 +1,24 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
4
  };
38
5
  Object.defineProperty(exports, "__esModule", { value: true });
39
6
  const jsx_runtime_1 = require("react/jsx-runtime");
40
- const react_1 = require("react");
41
7
  const ui_1 = require("@jbrowse/core/ui");
42
- const mobx_1 = require("mobx");
43
8
  const mobx_react_1 = require("mobx-react");
44
9
  const mui_1 = require("tss-react/mui");
45
10
  const Axes_1 = require("./Axes");
46
- const Grid_1 = __importDefault(require("./Grid"));
11
+ const DotplotTooltips_1 = __importDefault(require("./DotplotTooltips"));
47
12
  const Header_1 = __importDefault(require("./Header"));
48
13
  const ImportForm_1 = __importDefault(require("./ImportForm"));
49
- const TooltipWhereClicked = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./DotplotTooltipClick'))));
50
- const TooltipWhereMouseovered = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./DotplotTooltipMouseover'))));
51
- const blank = { left: 0, top: 0, width: 0, height: 0 };
14
+ const MouseInteractionLayer_1 = __importDefault(require("./MouseInteractionLayer"));
15
+ const SelectionContextMenu_1 = __importDefault(require("./SelectionContextMenu"));
16
+ const useCtrlKeyTracking_1 = require("./hooks/useCtrlKeyTracking");
17
+ const useCursorMode_1 = require("./hooks/useCursorMode");
18
+ const useMouseCoordinates_1 = require("./hooks/useMouseCoordinates");
19
+ const useMouseMoveHandler_1 = require("./hooks/useMouseMoveHandler");
20
+ const useMouseUpHandler_1 = require("./hooks/useMouseUpHandler");
21
+ const useWheelHandler_1 = require("./hooks/useWheelHandler");
52
22
  const useStyles = (0, mui_1.makeStyles)()(theme => ({
53
23
  spacer: {
54
24
  gridColumn: '1/2',
@@ -89,9 +59,6 @@ const useStyles = (0, mui_1.makeStyles)()(theme => ({
89
59
  borderTop: '1px solid #fafafa',
90
60
  },
91
61
  }));
92
- function getOffset(coord, rect) {
93
- return coord && [coord[0] - rect.left, coord[1] - rect.top];
94
- }
95
62
  const RenderedComponent = (0, mobx_react_1.observer)(({ model }) => {
96
63
  const { classes } = useStyles();
97
64
  return ((0, jsx_runtime_1.jsx)("div", { className: classes.overlay, children: model.tracks.map(track => {
@@ -101,118 +68,14 @@ const RenderedComponent = (0, mobx_react_1.observer)(({ model }) => {
101
68
  }) }));
102
69
  });
103
70
  const DotplotViewInternal = (0, mobx_react_1.observer)(function ({ model, }) {
104
- var _a, _b;
105
71
  const { classes } = useStyles();
106
- const [mousecurrClient, setMouseCurrClient] = (0, react_1.useState)();
107
- const [mousedownClient, setMouseDownClient] = (0, react_1.useState)();
108
- const [mouseOvered, setMouseOvered] = (0, react_1.useState)(false);
109
- const [mouseupClient, setMouseUpClient] = (0, react_1.useState)();
110
- const ref = (0, react_1.useRef)(null);
111
- const root = (0, react_1.useRef)(null);
112
- const distanceX = (0, react_1.useRef)(0);
113
- const distanceY = (0, react_1.useRef)(0);
114
- const scheduled = (0, react_1.useRef)(false);
115
- const [ctrlKeyWasUsed, setCtrlKeyWasUsed] = (0, react_1.useState)(false);
116
- const [ctrlKeyDown, setCtrlKeyDown] = (0, react_1.useState)(false);
117
- const svg = ((_a = ref.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || blank;
118
- const rootRect = ((_b = ref.current) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect()) || blank;
119
- const mousedown = getOffset(mousedownClient, svg);
120
- const mousecurr = getOffset(mousecurrClient, svg);
121
- const mouseup = getOffset(mouseupClient, svg);
122
- const mouserect = mouseup || mousecurr;
123
- const mouserectClient = mouseupClient || mousecurrClient;
124
- const xdistance = mousedown && mouserect ? mouserect[0] - mousedown[0] : 0;
125
- const ydistance = mousedown && mouserect ? mouserect[1] - mousedown[1] : 0;
126
72
  const { hview, vview, wheelMode, cursorMode } = model;
127
- const validPan = (cursorMode === 'move' && !ctrlKeyWasUsed) ||
128
- (cursorMode === 'crosshair' && ctrlKeyWasUsed);
129
- const validSelect = (cursorMode === 'move' && ctrlKeyWasUsed) ||
130
- (cursorMode === 'crosshair' && !ctrlKeyWasUsed);
131
- (0, react_1.useEffect)(() => {
132
- function onWheel(event) {
133
- event.preventDefault();
134
- distanceX.current += event.deltaX;
135
- distanceY.current -= event.deltaY;
136
- if (!scheduled.current) {
137
- scheduled.current = true;
138
- window.requestAnimationFrame(() => {
139
- (0, mobx_1.transaction)(() => {
140
- if (wheelMode === 'pan') {
141
- hview.scroll(distanceX.current / 3);
142
- vview.scroll(distanceY.current / 10);
143
- }
144
- else if (wheelMode === 'zoom') {
145
- if (Math.abs(distanceY.current) > Math.abs(distanceX.current) * 2 &&
146
- mousecurr) {
147
- const val = distanceY.current < 0 ? 1.1 : 0.9;
148
- hview.zoomTo(hview.bpPerPx * val, mousecurr[0]);
149
- vview.zoomTo(vview.bpPerPx * val, rootRect.height - mousecurr[1]);
150
- }
151
- }
152
- });
153
- scheduled.current = false;
154
- distanceX.current = 0;
155
- distanceY.current = 0;
156
- });
157
- }
158
- }
159
- if (ref.current) {
160
- const curr = ref.current;
161
- curr.addEventListener('wheel', onWheel);
162
- return () => {
163
- curr.removeEventListener('wheel', onWheel);
164
- };
165
- }
166
- return () => { };
167
- }, [hview, vview, wheelMode, mousecurr, rootRect.height]);
168
- (0, react_1.useEffect)(() => {
169
- function globalMouseMove(event) {
170
- setMouseCurrClient([event.clientX, event.clientY]);
171
- if (mousecurrClient && mousedownClient && validPan && !mouseupClient) {
172
- hview.scroll(-event.clientX + mousecurrClient[0]);
173
- vview.scroll(event.clientY - mousecurrClient[1]);
174
- }
175
- }
176
- window.addEventListener('mousemove', globalMouseMove);
177
- return () => {
178
- window.removeEventListener('mousemove', globalMouseMove);
179
- };
180
- }, [validPan, mousecurrClient, mousedownClient, mouseupClient, hview, vview]);
181
- (0, react_1.useEffect)(() => {
182
- function globalCtrlKeyDown(event) {
183
- if (event.metaKey || event.ctrlKey) {
184
- setCtrlKeyDown(true);
185
- }
186
- }
187
- function globalCtrlKeyUp(event) {
188
- if (!event.metaKey && !event.ctrlKey) {
189
- setCtrlKeyDown(false);
190
- }
191
- }
192
- window.addEventListener('keydown', globalCtrlKeyDown);
193
- window.addEventListener('keyup', globalCtrlKeyUp);
194
- return () => {
195
- window.removeEventListener('keydown', globalCtrlKeyDown);
196
- window.removeEventListener('keyup', globalCtrlKeyUp);
197
- };
198
- }, []);
199
- (0, react_1.useEffect)(() => {
200
- function globalMouseUp(event) {
201
- if (Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 && validSelect) {
202
- setMouseUpClient([event.clientX, event.clientY]);
203
- }
204
- else {
205
- setMouseDownClient(undefined);
206
- }
207
- }
208
- if (mousedown && !mouseup) {
209
- window.addEventListener('mouseup', globalMouseUp, true);
210
- return () => {
211
- window.removeEventListener('mouseup', globalMouseUp, true);
212
- };
213
- }
214
- return () => { };
215
- }, [validSelect, mousedown, mouseup, xdistance, ydistance]);
73
+ const { mousecurrClient, mousedownClient, mouseupClient, mouseOvered, setMouseCurrClient, setMouseDownClient, setMouseUpClient, setMouseOvered, ref, root, rootRect, mousedown, mousecurr, mouseup, mouserect, mouserectClient, xdistance, ydistance, } = (0, useMouseCoordinates_1.useMouseCoordinates)();
74
+ const { ctrlKeyDown, validPan, validSelect, setCtrlKeyWasUsed, setCtrlKeyDown, } = (0, useCursorMode_1.useCursorMode)(cursorMode);
75
+ (0, useWheelHandler_1.useWheelHandler)(ref, wheelMode, hview, vview, mousecurr, rootRect.height);
76
+ (0, useMouseMoveHandler_1.useMouseMoveHandler)(mousecurrClient, mousedownClient, mouseupClient, validPan, hview, vview, setMouseCurrClient);
77
+ (0, useCtrlKeyTracking_1.useCtrlKeyTracking)(setCtrlKeyDown);
78
+ (0, useMouseUpHandler_1.useMouseUpHandler)(mousedown, mouseup, xdistance, ydistance, validSelect, setMouseUpClient, setMouseDownClient);
216
79
  return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(Header_1.default, { model: model, selection: !validSelect || !(mousedown && mouserect)
217
80
  ? undefined
218
81
  : {
@@ -222,45 +85,7 @@ const DotplotViewInternal = (0, mobx_react_1.observer)(function ({ model, }) {
222
85
  setMouseOvered(false);
223
86
  }, onMouseEnter: () => {
224
87
  setMouseOvered(true);
225
- }, children: [(0, jsx_runtime_1.jsxs)("div", { className: classes.container, children: [(0, jsx_runtime_1.jsx)(Axes_1.VerticalAxis, { model: model }), (0, jsx_runtime_1.jsx)(Axes_1.HorizontalAxis, { model: model }), (0, jsx_runtime_1.jsxs)("div", { ref: ref, className: classes.content, children: [mouseOvered && validSelect ? ((0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: null, children: (0, jsx_runtime_1.jsx)(TooltipWhereMouseovered, { model: model, mouserect: mouserect, mouserectClient: mouserectClient, xdistance: xdistance }) })) : null, validSelect ? ((0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: null, children: (0, jsx_runtime_1.jsx)(TooltipWhereClicked, { model: model, mousedown: mousedown, mousedownClient: mousedownClient, xdistance: xdistance, ydistance: ydistance }) })) : null, (0, jsx_runtime_1.jsx)("div", { style: { cursor: ctrlKeyDown ? 'pointer' : cursorMode }, onMouseDown: event => {
226
- if (event.button === 0) {
227
- const { clientX, clientY } = event;
228
- setMouseDownClient([clientX, clientY]);
229
- setMouseCurrClient([clientX, clientY]);
230
- setCtrlKeyWasUsed(ctrlKeyDown);
231
- }
232
- }, children: (0, jsx_runtime_1.jsx)(Grid_1.default, { model: model, children: validSelect && mousedown && mouserect ? ((0, jsx_runtime_1.jsx)("rect", { fill: "rgba(255,0,0,0.3)", x: Math.min(mouserect[0], mousedown[0]), y: Math.min(mouserect[1], mousedown[1]), width: Math.abs(xdistance), height: Math.abs(ydistance) })) : null }) }), (0, jsx_runtime_1.jsx)("div", { className: classes.spacer })] }), (0, jsx_runtime_1.jsx)(RenderedComponent, { model: model }), (0, jsx_runtime_1.jsx)(ui_1.Menu, { open: Boolean(mouseup), onMenuItemClick: (_, callback) => {
233
- callback();
234
- setMouseUpClient(undefined);
235
- setMouseDownClient(undefined);
236
- }, onClose: () => {
237
- setMouseUpClient(undefined);
238
- setMouseDownClient(undefined);
239
- }, anchorReference: "anchorPosition", anchorPosition: mouseupClient
240
- ? {
241
- top: mouseupClient[1] + 50,
242
- left: mouseupClient[0] + 50,
243
- }
244
- : undefined, style: { zIndex: 800 }, menuItems: [
245
- {
246
- label: 'Zoom in',
247
- onClick: () => {
248
- if (mousedown && mouseup) {
249
- model.zoomInToMouseCoords(mousedown, mouseup);
250
- }
251
- setMouseOvered(false);
252
- },
253
- },
254
- {
255
- label: 'Open linear synteny view',
256
- onClick: () => {
257
- if (mousedown && mouseup) {
258
- model.onDotplotView(mousedown, mouseup);
259
- }
260
- setMouseOvered(false);
261
- },
262
- },
263
- ] })] }), (0, jsx_runtime_1.jsx)(ui_1.ResizeHandle, { onDrag: n => model.setHeight(model.height + n), className: classes.resizeHandle })] })] }));
88
+ }, children: [(0, jsx_runtime_1.jsxs)("div", { className: classes.container, children: [(0, jsx_runtime_1.jsx)(Axes_1.VerticalAxis, { model: model }), (0, jsx_runtime_1.jsx)(Axes_1.HorizontalAxis, { model: model }), (0, jsx_runtime_1.jsxs)("div", { ref: ref, className: classes.content, children: [(0, jsx_runtime_1.jsx)(DotplotTooltips_1.default, { model: model, mouseOvered: mouseOvered, validSelect: validSelect, mouserect: mouserect, mouserectClient: mouserectClient, xdistance: xdistance, mousedown: mousedown, mousedownClient: mousedownClient, ydistance: ydistance }), (0, jsx_runtime_1.jsx)(MouseInteractionLayer_1.default, { model: model, ctrlKeyDown: ctrlKeyDown, cursorMode: cursorMode, validSelect: validSelect, mousedown: mousedown, mouserect: mouserect, xdistance: xdistance, ydistance: ydistance, setMouseDownClient: setMouseDownClient, setMouseCurrClient: setMouseCurrClient, setCtrlKeyWasUsed: setCtrlKeyWasUsed }), (0, jsx_runtime_1.jsx)("div", { className: classes.spacer })] }), (0, jsx_runtime_1.jsx)(RenderedComponent, { model: model }), (0, jsx_runtime_1.jsx)(SelectionContextMenu_1.default, { model: model, mouseup: mouseup, mouseupClient: mouseupClient, mousedown: mousedown, setMouseUpClient: setMouseUpClient, setMouseDownClient: setMouseDownClient, setMouseOvered: setMouseOvered })] }), (0, jsx_runtime_1.jsx)(ui_1.ResizeHandle, { onDrag: n => model.setHeight(model.height + n), className: classes.resizeHandle })] })] }));
264
89
  });
265
90
  const DotplotView = (0, mobx_react_1.observer)(function ({ model }) {
266
91
  const { initialized, loading, error } = model;
@@ -44,9 +44,9 @@ const DotplotWarnings = (0, mobx_react_1.observer)(function ({ model, }) {
44
44
  const [hide, setHide] = (0, react_1.useState)(false);
45
45
  return trackWarnings.length && !hide ? ((0, jsx_runtime_1.jsxs)(material_1.Alert, { severity: "warning", children: ["Warnings during render", ' ', (0, jsx_runtime_1.jsx)(material_1.Button, { onClick: () => {
46
46
  setShown(true);
47
- }, children: "More info" }), shown ? ((0, jsx_runtime_1.jsx)(WarningDialog, { trackWarnings: trackWarnings, handleClose: () => {
48
- setShown(false);
49
- } })) : null, (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => {
47
+ }, children: "More info" }), shown ? ((0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: null, children: (0, jsx_runtime_1.jsx)(WarningDialog, { trackWarnings: trackWarnings, handleClose: () => {
48
+ setShown(false);
49
+ } }) })) : null, (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", onClick: () => {
50
50
  setHide(true);
51
51
  }, children: "Dismiss" })] })) : null;
52
52
  });
@@ -39,7 +39,6 @@ function doSubmit({ model, assembly1, assembly2, }) {
39
39
  }
40
40
  });
41
41
  }
42
- model.showAllRegions();
43
42
  model.setAssemblyNames(assembly2, assembly1);
44
43
  });
45
44
  }
@@ -0,0 +1,5 @@
1
+ import type { DotplotViewModel } from '../model';
2
+ declare const MinLengthSlider: ({ model, }: {
3
+ model: DotplotViewModel;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default MinLengthSlider;
@@ -0,0 +1,44 @@
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const material_1 = require("@mui/material");
9
+ const mobx_react_1 = require("mobx-react");
10
+ const mui_1 = require("tss-react/mui");
11
+ const SliderTooltip_1 = __importDefault(require("./SliderTooltip"));
12
+ const useStyles = (0, mui_1.makeStyles)()({
13
+ container: {
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ marginLeft: 16,
17
+ marginRight: 16,
18
+ minWidth: 150,
19
+ },
20
+ });
21
+ const MinLengthSlider = (0, mobx_react_1.observer)(function ({ model, }) {
22
+ var _a, _b;
23
+ const { classes } = useStyles();
24
+ const firstDisplay = (_a = model.tracks[0]) === null || _a === void 0 ? void 0 : _a.displays[0];
25
+ const minAlignmentLength = (_b = firstDisplay === null || firstDisplay === void 0 ? void 0 : firstDisplay.minAlignmentLength) !== null && _b !== void 0 ? _b : 0;
26
+ const [minLengthValue, setMinLengthValue] = (0, react_1.useState)(Math.log2(Math.max(1, minAlignmentLength)) * 100);
27
+ (0, react_1.useEffect)(() => {
28
+ setMinLengthValue(Math.log2(Math.max(1, minAlignmentLength)) * 100);
29
+ }, [minAlignmentLength]);
30
+ return ((0, jsx_runtime_1.jsxs)("span", { className: classes.container, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", style: { marginRight: 8 }, children: "Min length:" }), (0, jsx_runtime_1.jsx)(material_1.Slider, { value: minLengthValue, onChange: (_, val) => {
31
+ setMinLengthValue(val);
32
+ }, onChangeCommitted: () => {
33
+ const newMinLength = Math.round(2 ** (minLengthValue / 100));
34
+ for (const track of model.tracks) {
35
+ for (const display of track.displays) {
36
+ ;
37
+ display.setMinAlignmentLength(newMinLength);
38
+ }
39
+ }
40
+ }, min: 0, max: Math.log2(1000000) * 100, valueLabelDisplay: "auto", valueLabelFormat: newValue => Math.round(2 ** (newValue / 100)).toLocaleString(), size: "small", style: { minWidth: 100 }, slots: {
41
+ valueLabel: SliderTooltip_1.default,
42
+ } })] }));
43
+ });
44
+ exports.default = MinLengthSlider;
@@ -0,0 +1,17 @@
1
+ import type { DotplotViewModel } from '../model';
2
+ type Coord = [number, number] | undefined;
3
+ interface MouseInteractionLayerProps {
4
+ model: DotplotViewModel;
5
+ ctrlKeyDown: boolean;
6
+ cursorMode: string;
7
+ validSelect: boolean;
8
+ mousedown: Coord;
9
+ mouserect: Coord;
10
+ xdistance: number;
11
+ ydistance: number;
12
+ setMouseDownClient: (coord: Coord) => void;
13
+ setMouseCurrClient: (coord: Coord) => void;
14
+ setCtrlKeyWasUsed: (wasUsed: boolean) => void;
15
+ }
16
+ export default function MouseInteractionLayer({ model, ctrlKeyDown, cursorMode, validSelect, mousedown, mouserect, xdistance, ydistance, setMouseDownClient, setMouseCurrClient, setCtrlKeyWasUsed, }: MouseInteractionLayerProps): import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1,18 @@
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.default = MouseInteractionLayer;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const Grid_1 = __importDefault(require("./Grid"));
9
+ function MouseInteractionLayer({ model, ctrlKeyDown, cursorMode, validSelect, mousedown, mouserect, xdistance, ydistance, setMouseDownClient, setMouseCurrClient, setCtrlKeyWasUsed, }) {
10
+ return ((0, jsx_runtime_1.jsx)("div", { style: { cursor: ctrlKeyDown ? 'pointer' : cursorMode }, onMouseDown: event => {
11
+ if (event.button === 0) {
12
+ const { clientX, clientY } = event;
13
+ setMouseDownClient([clientX, clientY]);
14
+ setMouseCurrClient([clientX, clientY]);
15
+ setCtrlKeyWasUsed(ctrlKeyDown);
16
+ }
17
+ }, children: (0, jsx_runtime_1.jsx)(Grid_1.default, { model: model, children: validSelect && mousedown && mouserect ? ((0, jsx_runtime_1.jsx)("rect", { fill: "rgba(255,0,0,0.3)", x: Math.min(mouserect[0], mousedown[0]), y: Math.min(mouserect[1], mousedown[1]), width: Math.abs(xdistance), height: Math.abs(ydistance) })) : null }) }));
18
+ }
@@ -0,0 +1,5 @@
1
+ import type { DotplotViewModel } from '../model';
2
+ declare const OpacitySlider: ({ model, }: {
3
+ model: DotplotViewModel;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default OpacitySlider;
@@ -0,0 +1,43 @@
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 jsx_runtime_1 = require("react/jsx-runtime");
7
+ const material_1 = require("@mui/material");
8
+ const mobx_react_1 = require("mobx-react");
9
+ const mui_1 = require("tss-react/mui");
10
+ const SliderTooltip_1 = __importDefault(require("./SliderTooltip"));
11
+ const useStyles = (0, mui_1.makeStyles)()({
12
+ container: {
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ marginLeft: 16,
16
+ marginRight: 16,
17
+ minWidth: 150,
18
+ },
19
+ });
20
+ const OpacitySlider = (0, mobx_react_1.observer)(function ({ model, }) {
21
+ var _a, _b;
22
+ const { classes } = useStyles();
23
+ const firstDisplay = (_a = model.tracks[0]) === null || _a === void 0 ? void 0 : _a.displays[0];
24
+ const alpha = (_b = firstDisplay === null || firstDisplay === void 0 ? void 0 : firstDisplay.alpha) !== null && _b !== void 0 ? _b : 1;
25
+ const exponent = 3;
26
+ const alphaToSlider = (a) => Math.pow(a, 1 / exponent);
27
+ const sliderToAlpha = (s) => Math.pow(s, exponent);
28
+ const sliderValue = alphaToSlider(alpha);
29
+ const handleAlphaChange = (_event, value) => {
30
+ const sliderVal = typeof value === 'number' ? value : value[0];
31
+ const newAlpha = sliderToAlpha(sliderVal);
32
+ for (const track of model.tracks) {
33
+ for (const display of track.displays) {
34
+ ;
35
+ display.setAlpha(newAlpha);
36
+ }
37
+ }
38
+ };
39
+ return ((0, jsx_runtime_1.jsxs)("span", { className: classes.container, children: [(0, jsx_runtime_1.jsx)(material_1.Typography, { variant: "body2", style: { marginRight: 8 }, children: "Opacity:" }), (0, jsx_runtime_1.jsx)(material_1.Slider, { value: sliderValue, onChange: handleAlphaChange, min: 0, max: 1, step: 0.01, valueLabelDisplay: "auto", size: "small", style: { minWidth: 100 }, slots: {
40
+ valueLabel: SliderTooltip_1.default,
41
+ }, valueLabelFormat: value => sliderToAlpha(value).toFixed(3) })] }));
42
+ });
43
+ exports.default = OpacitySlider;
@@ -0,0 +1,13 @@
1
+ import type { DotplotViewModel } from '../model';
2
+ type Coord = [number, number] | undefined;
3
+ interface SelectionContextMenuProps {
4
+ model: DotplotViewModel;
5
+ mouseup: Coord;
6
+ mouseupClient: Coord;
7
+ mousedown: Coord;
8
+ setMouseUpClient: (coord: Coord) => void;
9
+ setMouseDownClient: (coord: Coord) => void;
10
+ setMouseOvered: (isOvered: boolean) => void;
11
+ }
12
+ export default function SelectionContextMenu({ model, mouseup, mouseupClient, mousedown, setMouseUpClient, setMouseDownClient, setMouseOvered, }: SelectionContextMenuProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = SelectionContextMenu;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const ui_1 = require("@jbrowse/core/ui");
6
+ function getSelectionMenuItems(model, mousedown, mouseup, setMouseOvered) {
7
+ return [
8
+ {
9
+ label: 'Zoom in',
10
+ onClick: () => {
11
+ if (mousedown && mouseup) {
12
+ model.zoomInToMouseCoords(mousedown, mouseup);
13
+ }
14
+ setMouseOvered(false);
15
+ },
16
+ },
17
+ {
18
+ label: 'Open linear synteny view',
19
+ onClick: () => {
20
+ if (mousedown && mouseup) {
21
+ model.onDotplotView(mousedown, mouseup);
22
+ }
23
+ setMouseOvered(false);
24
+ },
25
+ },
26
+ ];
27
+ }
28
+ function SelectionContextMenu({ model, mouseup, mouseupClient, mousedown, setMouseUpClient, setMouseDownClient, setMouseOvered, }) {
29
+ return ((0, jsx_runtime_1.jsx)(ui_1.Menu, { open: Boolean(mouseup), onMenuItemClick: (_, callback) => {
30
+ callback();
31
+ setMouseUpClient(undefined);
32
+ setMouseDownClient(undefined);
33
+ }, onClose: () => {
34
+ setMouseUpClient(undefined);
35
+ setMouseDownClient(undefined);
36
+ }, anchorReference: "anchorPosition", anchorPosition: mouseupClient
37
+ ? {
38
+ top: mouseupClient[1] + 50,
39
+ left: mouseupClient[0] + 50,
40
+ }
41
+ : undefined, style: { zIndex: 11000 }, menuItems: getSelectionMenuItems(model, mousedown, mouseup, setMouseOvered) }));
42
+ }
@@ -0,0 +1,2 @@
1
+ import type { SliderValueLabelProps } from '@mui/material';
2
+ export default function SliderTooltip(props: SliderValueLabelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = SliderTooltip;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const material_1 = require("@mui/material");
6
+ function SliderTooltip(props) {
7
+ const { children, open, value } = props;
8
+ return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { open: open, enterTouchDelay: 0, placement: "top", title: value, arrow: true, children: children }));
9
+ }
@@ -0,0 +1 @@
1
+ export declare function useCtrlKeyTracking(setCtrlKeyDown: (isDown: boolean) => void): void;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCtrlKeyTracking = useCtrlKeyTracking;
4
+ const react_1 = require("react");
5
+ function useCtrlKeyTracking(setCtrlKeyDown) {
6
+ (0, react_1.useEffect)(() => {
7
+ function globalCtrlKeyDown(event) {
8
+ if (event.metaKey || event.ctrlKey) {
9
+ setCtrlKeyDown(true);
10
+ }
11
+ }
12
+ function globalCtrlKeyUp(event) {
13
+ if (!event.metaKey && !event.ctrlKey) {
14
+ setCtrlKeyDown(false);
15
+ }
16
+ }
17
+ window.addEventListener('keydown', globalCtrlKeyDown);
18
+ window.addEventListener('keyup', globalCtrlKeyUp);
19
+ return () => {
20
+ window.removeEventListener('keydown', globalCtrlKeyDown);
21
+ window.removeEventListener('keyup', globalCtrlKeyUp);
22
+ };
23
+ }, [setCtrlKeyDown]);
24
+ }
@@ -0,0 +1,7 @@
1
+ export declare function useCursorMode(cursorMode: string): {
2
+ ctrlKeyDown: boolean;
3
+ validPan: boolean;
4
+ validSelect: boolean;
5
+ setCtrlKeyWasUsed: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
+ setCtrlKeyDown: import("react").Dispatch<import("react").SetStateAction<boolean>>;
7
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCursorMode = useCursorMode;
4
+ const react_1 = require("react");
5
+ function useCursorMode(cursorMode) {
6
+ const [ctrlKeyWasUsed, setCtrlKeyWasUsed] = (0, react_1.useState)(false);
7
+ const [ctrlKeyDown, setCtrlKeyDown] = (0, react_1.useState)(false);
8
+ const validPan = (cursorMode === 'move' && !ctrlKeyWasUsed) ||
9
+ (cursorMode === 'crosshair' && ctrlKeyWasUsed);
10
+ const validSelect = (cursorMode === 'move' && ctrlKeyWasUsed) ||
11
+ (cursorMode === 'crosshair' && !ctrlKeyWasUsed);
12
+ return {
13
+ ctrlKeyDown,
14
+ validPan,
15
+ validSelect,
16
+ setCtrlKeyWasUsed,
17
+ setCtrlKeyDown,
18
+ };
19
+ }
@@ -0,0 +1,29 @@
1
+ type Coord = [number, number] | undefined;
2
+ interface Rect {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare function useMouseCoordinates(): {
9
+ mousecurrClient: Coord;
10
+ mousedownClient: Coord;
11
+ mouseupClient: Coord;
12
+ mouseOvered: boolean;
13
+ setMouseCurrClient: import("react").Dispatch<import("react").SetStateAction<Coord>>;
14
+ setMouseDownClient: import("react").Dispatch<import("react").SetStateAction<Coord>>;
15
+ setMouseUpClient: import("react").Dispatch<import("react").SetStateAction<Coord>>;
16
+ setMouseOvered: import("react").Dispatch<import("react").SetStateAction<boolean>>;
17
+ ref: import("react").RefObject<HTMLDivElement | null>;
18
+ root: import("react").RefObject<HTMLDivElement | null>;
19
+ svg: Rect;
20
+ rootRect: Rect;
21
+ mousedown: Coord;
22
+ mousecurr: Coord;
23
+ mouseup: Coord;
24
+ mouserect: Coord;
25
+ mouserectClient: Coord;
26
+ xdistance: number;
27
+ ydistance: number;
28
+ };
29
+ export {};
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMouseCoordinates = useMouseCoordinates;
4
+ const react_1 = require("react");
5
+ const blank = { left: 0, top: 0, width: 0, height: 0 };
6
+ function getOffset(coord, rect) {
7
+ return coord && [coord[0] - rect.left, coord[1] - rect.top];
8
+ }
9
+ function useMouseCoordinates() {
10
+ const [mousecurrClient, setMouseCurrClient] = (0, react_1.useState)();
11
+ const [mousedownClient, setMouseDownClient] = (0, react_1.useState)();
12
+ const [mouseupClient, setMouseUpClient] = (0, react_1.useState)();
13
+ const [mouseOvered, setMouseOvered] = (0, react_1.useState)(false);
14
+ const [rect, setRect] = (0, react_1.useState)(blank);
15
+ const ref = (0, react_1.useRef)(null);
16
+ const root = (0, react_1.useRef)(null);
17
+ (0, react_1.useLayoutEffect)(() => {
18
+ if (ref.current) {
19
+ setRect(ref.current.getBoundingClientRect());
20
+ }
21
+ }, [mousecurrClient, mousedownClient, mouseupClient]);
22
+ const svg = rect;
23
+ const rootRect = rect;
24
+ const mousedown = getOffset(mousedownClient, rect);
25
+ const mousecurr = getOffset(mousecurrClient, rect);
26
+ const mouseup = getOffset(mouseupClient, rect);
27
+ const mouserect = mouseup || mousecurr;
28
+ const mouserectClient = mouseupClient || mousecurrClient;
29
+ const xdistance = mousedown && mouserect ? mouserect[0] - mousedown[0] : 0;
30
+ const ydistance = mousedown && mouserect ? mouserect[1] - mousedown[1] : 0;
31
+ return {
32
+ mousecurrClient,
33
+ mousedownClient,
34
+ mouseupClient,
35
+ mouseOvered,
36
+ setMouseCurrClient,
37
+ setMouseDownClient,
38
+ setMouseUpClient,
39
+ setMouseOvered,
40
+ ref,
41
+ root,
42
+ svg,
43
+ rootRect,
44
+ mousedown,
45
+ mousecurr,
46
+ mouseup,
47
+ mouserect,
48
+ mouserectClient,
49
+ xdistance,
50
+ ydistance,
51
+ };
52
+ }
@@ -0,0 +1,6 @@
1
+ type Coord = [number, number] | undefined;
2
+ interface View {
3
+ scroll: (distance: number) => void;
4
+ }
5
+ export declare function useMouseMoveHandler(mousecurrClient: Coord, mousedownClient: Coord, mouseupClient: Coord, validPan: boolean, hview: View, vview: View, setMouseCurrClient: (coord: Coord) => void): void;
6
+ export {};