@jbrowse/plugin-linear-genome-view 5.0.0-beta.1 → 5.0.0-beta.11

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 (148) hide show
  1. package/esm/FeatureTrack/configSchema.d.ts +142 -50
  2. package/esm/LaunchLinearGenomeView/index.js +2 -13
  3. package/esm/LinearGenomeView/afterAttach.d.ts +5 -5
  4. package/esm/LinearGenomeView/afterAttach.js +75 -62
  5. package/esm/LinearGenomeView/components/CenterLine.js +5 -3
  6. package/esm/LinearGenomeView/components/CrisprGuidePanel.js +3 -5
  7. package/esm/LinearGenomeView/components/ExportSvgDialog.d.ts +3 -2
  8. package/esm/LinearGenomeView/components/ExportSvgDialog.js +6 -2
  9. package/esm/LinearGenomeView/components/GetSequenceDialog.js +2 -2
  10. package/esm/LinearGenomeView/components/Header.js +11 -1
  11. package/esm/LinearGenomeView/components/HeaderClearHighlightButton.js +2 -2
  12. package/esm/LinearGenomeView/components/HeaderPanControls.js +2 -1
  13. package/esm/LinearGenomeView/components/HeaderZoomControls.js +4 -34
  14. package/esm/LinearGenomeView/components/Highlight.js +7 -7
  15. package/esm/LinearGenomeView/components/HighlightBand.d.ts +9 -1
  16. package/esm/LinearGenomeView/components/HighlightBand.js +15 -3
  17. package/esm/LinearGenomeView/components/HighlightChip.d.ts +1 -2
  18. package/esm/LinearGenomeView/components/HighlightChip.js +5 -7
  19. package/esm/LinearGenomeView/components/HoverPositionHighlight.js +3 -3
  20. package/esm/LinearGenomeView/components/ImportForm.js +2 -2
  21. package/esm/LinearGenomeView/components/LinearGenomeView.js +3 -3
  22. package/esm/LinearGenomeView/components/LinearGenomeViewContainer.js +3 -4
  23. package/esm/LinearGenomeView/components/MiniControls.js +3 -2
  24. package/esm/LinearGenomeView/components/OverviewHighlight.js +3 -3
  25. package/esm/LinearGenomeView/components/OverviewHighlightBand.js +2 -3
  26. package/esm/LinearGenomeView/components/OverviewRubberband.js +20 -45
  27. package/esm/LinearGenomeView/components/OverviewScalebar.js +4 -5
  28. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.js +5 -3
  29. package/esm/LinearGenomeView/components/PaddingBlocks.d.ts +1 -1
  30. package/esm/LinearGenomeView/components/PaddingBlocks.js +14 -9
  31. package/esm/LinearGenomeView/components/RangeSelectOverlay.js +5 -6
  32. package/esm/LinearGenomeView/components/ResizeAllTracksHandle.d.ts +5 -0
  33. package/esm/LinearGenomeView/components/ResizeAllTracksHandle.js +71 -0
  34. package/esm/LinearGenomeView/components/Rubberband.d.ts +1 -2
  35. package/esm/LinearGenomeView/components/Rubberband.js +3 -2
  36. package/esm/LinearGenomeView/components/SVGHighlightBand.js +2 -3
  37. package/esm/LinearGenomeView/components/Scalebar.d.ts +2 -6
  38. package/esm/LinearGenomeView/components/Scalebar.js +8 -5
  39. package/esm/LinearGenomeView/components/ScalebarRefNameLabels.js +49 -34
  40. package/esm/LinearGenomeView/components/SearchBox.js +8 -7
  41. package/esm/LinearGenomeView/components/SearchResultsDialog.d.ts +2 -1
  42. package/esm/LinearGenomeView/components/SearchResultsDialog.js +2 -2
  43. package/esm/LinearGenomeView/components/SearchResultsTable.d.ts +2 -1
  44. package/esm/LinearGenomeView/components/SearchResultsTable.js +12 -29
  45. package/esm/LinearGenomeView/components/SequenceSearchDialog.d.ts +2 -4
  46. package/esm/LinearGenomeView/components/TrackContainer.js +63 -9
  47. package/esm/LinearGenomeView/components/TrackLabel.js +10 -3
  48. package/esm/LinearGenomeView/components/TrackLabelButtons.js +2 -2
  49. package/esm/LinearGenomeView/components/TrackLabelDragHandle.js +2 -2
  50. package/esm/LinearGenomeView/components/TrackLabelMenu.js +3 -2
  51. package/esm/LinearGenomeView/components/TrackRenderingContainer.d.ts +4 -1
  52. package/esm/LinearGenomeView/components/TrackRenderingContainer.js +11 -23
  53. package/esm/LinearGenomeView/components/TracksContainer.js +10 -22
  54. package/esm/LinearGenomeView/components/VerticalGuide.d.ts +1 -2
  55. package/esm/LinearGenomeView/components/VerticalGuide.js +3 -16
  56. package/esm/LinearGenomeView/components/ZoomButton.js +6 -1
  57. package/esm/LinearGenomeView/components/ZoomTransform.js +4 -0
  58. package/esm/LinearGenomeView/components/fetchSequence.d.ts +1 -2
  59. package/esm/LinearGenomeView/components/recentLocationsMenu.js +10 -0
  60. package/esm/LinearGenomeView/components/searchModes.d.ts +1 -1
  61. package/esm/LinearGenomeView/components/searchModes.js +1 -1
  62. package/esm/LinearGenomeView/components/useRangeSelect.d.ts +0 -3
  63. package/esm/LinearGenomeView/components/useRangeSelect.js +20 -59
  64. package/esm/LinearGenomeView/components/useSideScroll.d.ts +16 -2
  65. package/esm/LinearGenomeView/components/useSideScroll.js +153 -103
  66. package/esm/LinearGenomeView/components/util.d.ts +4 -0
  67. package/esm/LinearGenomeView/components/util.js +4 -2
  68. package/esm/LinearGenomeView/consts.d.ts +2 -0
  69. package/esm/LinearGenomeView/consts.js +3 -1
  70. package/esm/LinearGenomeView/containingLgv.d.ts +21 -0
  71. package/esm/LinearGenomeView/containingLgv.js +23 -0
  72. package/esm/LinearGenomeView/headerFit.d.ts +4 -2
  73. package/esm/LinearGenomeView/headerFit.js +20 -7
  74. package/esm/LinearGenomeView/index.d.ts +1 -5
  75. package/esm/LinearGenomeView/index.js +10 -7
  76. package/esm/LinearGenomeView/keyboardHandler.d.ts +2 -0
  77. package/esm/LinearGenomeView/keyboardHandler.js +15 -1
  78. package/esm/LinearGenomeView/launchKeys.d.ts +2 -0
  79. package/esm/LinearGenomeView/launchKeys.js +27 -0
  80. package/esm/LinearGenomeView/lazyDialogs.d.ts +2 -4
  81. package/esm/LinearGenomeView/lazyDialogs.js +1 -0
  82. package/esm/LinearGenomeView/linkedViewSync.d.ts +3 -11
  83. package/esm/LinearGenomeView/linkedViewSync.js +27 -43
  84. package/esm/LinearGenomeView/menuItems.d.ts +16 -18
  85. package/esm/LinearGenomeView/menuItems.js +242 -151
  86. package/esm/LinearGenomeView/model.d.ts +2027 -200
  87. package/esm/LinearGenomeView/model.js +560 -395
  88. package/esm/LinearGenomeView/sharedScaleContainer.d.ts +1 -1
  89. package/esm/LinearGenomeView/showRegionsWithUndo.js +7 -1
  90. package/esm/LinearGenomeView/stickyChrome.d.ts +5 -9
  91. package/esm/LinearGenomeView/stickyChrome.js +5 -9
  92. package/esm/LinearGenomeView/svgcomponents/SVGGridlines.js +4 -4
  93. package/esm/LinearGenomeView/svgcomponents/SVGHeader.d.ts +4 -1
  94. package/esm/LinearGenomeView/svgcomponents/SVGHeader.js +8 -21
  95. package/esm/LinearGenomeView/svgcomponents/SVGHighlights.js +8 -8
  96. package/esm/LinearGenomeView/svgcomponents/SVGHighlightsOverlay.js +3 -3
  97. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +7 -11
  98. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.js +2 -5
  99. package/esm/LinearGenomeView/svgcomponents/SVGRowHeader.js +5 -6
  100. package/esm/LinearGenomeView/svgcomponents/SVGRuler.js +9 -10
  101. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.js +3 -3
  102. package/esm/LinearGenomeView/svgcomponents/SVGStackedRow.d.ts +27 -0
  103. package/esm/LinearGenomeView/svgcomponents/SVGStackedRow.js +12 -0
  104. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.d.ts +2 -1
  105. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js +29 -16
  106. package/esm/LinearGenomeView/svgcomponents/SVGTracks.d.ts +4 -4
  107. package/esm/LinearGenomeView/svgcomponents/SVGTracks.js +6 -5
  108. package/esm/LinearGenomeView/svgcomponents/SVGView.d.ts +1 -1
  109. package/esm/LinearGenomeView/svgcomponents/SVGView.js +1 -1
  110. package/esm/LinearGenomeView/svgcomponents/figureContract.js +14 -14
  111. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.d.ts +1 -0
  112. package/esm/LinearGenomeView/svgcomponents/renderViewTracks.js +1 -1
  113. package/esm/LinearGenomeView/svgcomponents/useViewSvgFigure.js +50 -68
  114. package/esm/LinearGenomeView/svgcomponents/util.d.ts +20 -8
  115. package/esm/LinearGenomeView/svgcomponents/util.js +50 -29
  116. package/esm/LinearGenomeView/types.d.ts +8 -11
  117. package/esm/LinearGenomeView/util.d.ts +60 -45
  118. package/esm/LinearGenomeView/util.js +131 -160
  119. package/esm/MultiLevelRubberband/MultiLevelRubberband.js +7 -4
  120. package/esm/MultiLevelRubberband/index.d.ts +2 -0
  121. package/esm/MultiLevelRubberband/index.js +2 -0
  122. package/esm/MultiLevelRubberband/menuItems.d.ts +34 -0
  123. package/esm/MultiLevelRubberband/menuItems.js +52 -0
  124. package/esm/MultiLevelRubberband/rowLabel.d.ts +22 -0
  125. package/esm/MultiLevelRubberband/rowLabel.js +27 -0
  126. package/esm/MultiLevelRubberband/types.d.ts +1 -0
  127. package/esm/MultiLevelRubberband/useRangeSelect.d.ts +2 -1
  128. package/esm/MultiLevelRubberband/useRangeSelect.js +31 -47
  129. package/esm/displayKitTests/perRegionTestEnv.d.ts +244 -86
  130. package/esm/displayKitTests/perRegionTestEnv.js +30 -29
  131. package/esm/index.d.ts +15 -85
  132. package/esm/index.js +13 -36
  133. package/esm/searchUtils.d.ts +18 -9
  134. package/esm/searchUtils.js +85 -69
  135. package/esm/shared/RubberbandSpan.js +2 -1
  136. package/esm/shared/coordLabels.d.ts +7 -0
  137. package/esm/shared/coordLabels.js +15 -1
  138. package/esm/shared/useWindowDrag.d.ts +18 -0
  139. package/esm/shared/useWindowDrag.js +45 -0
  140. package/package.json +10 -10
  141. package/esm/LinearGenomeView/FloatingSvgOverlay.d.ts +0 -5
  142. package/esm/LinearGenomeView/FloatingSvgOverlay.js +0 -25
  143. package/esm/LinearGenomeView/initKeys.d.ts +0 -13
  144. package/esm/LinearGenomeView/initKeys.js +0 -104
  145. package/esm/MultiLevelRubberband/VerticalGuide.d.ts +0 -6
  146. package/esm/MultiLevelRubberband/VerticalGuide.js +0 -21
  147. package/esm/lazyPluginExports.d.ts +0 -23
  148. package/esm/lazyPluginExports.js +0 -36
@@ -0,0 +1,52 @@
1
+ import { rowLabels } from './rowLabel.js';
2
+ /**
3
+ * One row per genome row, each holding that row's own rubberband menu — Get
4
+ * sequence, Copy range, Highlight region, and whatever a plugin contributes
5
+ * under Launch.
6
+ *
7
+ * A drag on the multi-level strip commits offsets on EVERY row (see
8
+ * `useRangeSelect`), so each row's `rubberBandMenuItems()` already describes a
9
+ * real selection and was simply never offered: the stacked views' menu held
10
+ * "Zoom to region(s)" and nothing else, while the same drag in a plain linear
11
+ * genome view offered five actions. Per row rather than applied across rows
12
+ * because each row is its own assembly — one sequence to fetch, one range to
13
+ * copy, one highlight to place — so there is no "all rows" answer to give.
14
+ *
15
+ * Zoom is the exception and stays where each view already has it: zooming every
16
+ * row at once is what the gesture means, and the synteny view holds its follow
17
+ * anchor across the loop.
18
+ */
19
+ export function multiLevelRowMenuItems(views) {
20
+ return rowLabels(views).map((label, idx) => ({
21
+ label,
22
+ subMenu: views[idx].rubberBandMenuItems(),
23
+ }));
24
+ }
25
+ /**
26
+ * The same per-row rows for a bare CLICK on the strip rather than a drag — each
27
+ * row's Center view here, Zoom to base level and Copy coordinate, at the base
28
+ * that row paints under `px`.
29
+ *
30
+ * No all-rows row above them, unlike the drag's "Zoom to region(s)". A drag
31
+ * names a span in pixels and every row can act on it; a click names a
32
+ * COORDINATE, and the rows are different assemblies, so which genome's base the
33
+ * pointer is over is the question the menu has to ask rather than answer.
34
+ *
35
+ * `px` rather than a resolved offset: each row maps the pixel through its own
36
+ * `pxToBp`, so there is no one offset to pass.
37
+ */
38
+ export function multiLevelRowClickMenuItems(views, px) {
39
+ return rowLabels(views).flatMap((label, idx) => {
40
+ const view = views[idx];
41
+ // A row with no regions is dropped, because `pxToBp` THROWS on one rather
42
+ // than answering an offset that names no base — so gating on the built
43
+ // submenu being empty, which is what this did, was a guard that could never
44
+ // fire in front of a call that had already thrown. Reachable: a row's
45
+ // `initialized` is assembly readiness, and the stack mounts this strip once
46
+ // ANY row is ready.
47
+ if (!view.displayedRegions.length) {
48
+ return [];
49
+ }
50
+ return [{ label, subMenu: view.rubberbandClickMenuItems(view.pxToBp(px)) }];
51
+ });
52
+ }
@@ -0,0 +1,22 @@
1
+ /**
2
+ * What to call each genome row, one label per row. The assembly name where
3
+ * there is one, and the row's position where a row is still loading, so a label
4
+ * stays true whatever the assemblies turn out to be called.
5
+ *
6
+ * A NAME THAT REPEATS PICKS UP ITS ROW NUMBER, because a stack can hold one
7
+ * assembly twice — two loci of the same genome, a read against its own
8
+ * reference — and there the bare name gives two menu rows that open different
9
+ * things under identical text. Only the repeats pay for it: the ordinary
10
+ * pairwise view still reads "hg38" and "mm39".
11
+ *
12
+ * One function over the whole list rather than one row at a time, since
13
+ * uniqueness is a property of the list. Shared by every menu that names the
14
+ * rows — the track selectors, the row menus, the follow anchors, the
15
+ * rubberband — so they cannot drift into calling the same row two different
16
+ * things one click apart. Here rather than in the synteny view because the
17
+ * breakpoint split view is the same stack of rows and had been numbering them
18
+ * itself.
19
+ */
20
+ export declare function rowLabels(views: {
21
+ assemblyNames: string[];
22
+ }[]): string[];
@@ -0,0 +1,27 @@
1
+ /**
2
+ * What to call each genome row, one label per row. The assembly name where
3
+ * there is one, and the row's position where a row is still loading, so a label
4
+ * stays true whatever the assemblies turn out to be called.
5
+ *
6
+ * A NAME THAT REPEATS PICKS UP ITS ROW NUMBER, because a stack can hold one
7
+ * assembly twice — two loci of the same genome, a read against its own
8
+ * reference — and there the bare name gives two menu rows that open different
9
+ * things under identical text. Only the repeats pay for it: the ordinary
10
+ * pairwise view still reads "hg38" and "mm39".
11
+ *
12
+ * One function over the whole list rather than one row at a time, since
13
+ * uniqueness is a property of the list. Shared by every menu that names the
14
+ * rows — the track selectors, the row menus, the follow anchors, the
15
+ * rubberband — so they cannot drift into calling the same row two different
16
+ * things one click apart. Here rather than in the synteny view because the
17
+ * breakpoint split view is the same stack of rows and had been numbering them
18
+ * itself.
19
+ */
20
+ export function rowLabels(views) {
21
+ const names = views.map((view, idx) => view.assemblyNames[0] ?? `Row ${idx + 1}`);
22
+ const counts = new Map();
23
+ for (const name of names) {
24
+ counts.set(name, (counts.get(name) ?? 0) + 1);
25
+ }
26
+ return names.map((name, idx) => counts.get(name) > 1 ? `${name} (row ${idx + 1})` : name);
27
+ }
@@ -3,4 +3,5 @@ import type { MenuItem } from '@jbrowse/core/ui';
3
3
  export interface MultiLevelRubberbandModel {
4
4
  views: LinearGenomeViewModel[];
5
5
  rubberBandMenuItems: () => MenuItem[];
6
+ rubberbandClickMenuItemsAtPx: (px: number) => MenuItem[];
6
7
  }
@@ -4,9 +4,10 @@ interface AnchorPosition {
4
4
  offsetX: number;
5
5
  clientX: number;
6
6
  clientY: number;
7
+ isClick: boolean;
7
8
  }
8
9
  export declare function useRangeSelect(ref: React.RefObject<HTMLDivElement | null>, model: MultiLevelRubberbandModel): {
9
- open: boolean;
10
+ isClick: boolean | undefined;
10
11
  rubberbandOn: boolean;
11
12
  guideX: number | undefined;
12
13
  anchorPosition: AnchorPosition | undefined;
@@ -1,6 +1,7 @@
1
- import { useCallback, useEffect, useState } from 'react';
1
+ import { useCallback, useState } from 'react';
2
2
  import { getRelativeX } from '@jbrowse/core/util/getRelativeX';
3
3
  import { transaction } from 'mobx';
4
+ import { useWindowDrag } from '../shared/useWindowDrag.js';
4
5
  export function useRangeSelect(ref, model) {
5
6
  const [startX, setStartX] = useState();
6
7
  const [currentX, setCurrentX] = useState(0);
@@ -18,8 +19,15 @@ export function useRangeSelect(ref, model) {
18
19
  });
19
20
  }, [model]);
20
21
  // releases the committed offsets too, since mouseOut no longer does while the
21
- // menu is open — closing the menu (button, Escape, or a bare click) is the
22
- // point the selection is actually finished with
22
+ // menu is open — dismissing the menu, by its backdrop or Escape, is the point
23
+ // the selection is actually finished with. A bare click on the strip no longer
24
+ // comes through here: it opens the click menu instead.
25
+ //
26
+ // `CascadingMenu` dismisses BEFORE it runs the clicked row's callback, so this
27
+ // clears the offsets out from under it. Every menu built here captures them
28
+ // when the rows are built, which is why that works — the plain linear genome
29
+ // view's host never clears, so a row written to read them live works there
30
+ // and silently no-ops from a stacked row.
23
31
  const handleClose = useCallback(() => {
24
32
  setAnchorPosition(undefined);
25
33
  setStartX(undefined);
@@ -27,54 +35,27 @@ export function useRangeSelect(ref, model) {
27
35
  setGuideX(undefined);
28
36
  clearOffsets();
29
37
  }, [clearOffsets]);
30
- useEffect(() => {
31
- const el = ref.current;
32
- if (!mouseDragging || !el) {
33
- return;
34
- }
35
- // the container's left edge is fixed for the duration of a drag, so measure
36
- // it once here rather than calling getBoundingClientRect on every mousemove
37
- const { left } = el.getBoundingClientRect();
38
- function globalMouseMove(event) {
39
- setCurrentX(event.clientX - left);
40
- }
41
- function globalMouseUp(event) {
42
- if (startX === undefined) {
43
- return;
44
- }
45
- const offsetX = event.clientX - left;
46
- if (Math.abs(offsetX - startX) <= 3) {
47
- handleClose();
38
+ useWindowDrag(ref, mouseDragging ? startX : undefined, {
39
+ onMove: setCurrentX,
40
+ onEnd: ({ startX, endX, isClick, clientX, clientY }) => {
41
+ setAnchorPosition({ offsetX: endX, clientX, clientY, isClick });
42
+ if (isClick) {
43
+ // the click menu names a coordinate, not a span, so nothing is
44
+ // committed; the guide stays at the click so the menu says where
45
+ setGuideX(endX);
48
46
  return;
49
47
  }
50
- setAnchorPosition({
51
- offsetX,
52
- clientX: event.clientX,
53
- clientY: event.clientY,
54
- });
55
- const leftPx = Math.min(startX, offsetX);
56
- const rightPx = Math.max(startX, offsetX);
48
+ const leftPx = Math.min(startX, endX);
49
+ const rightPx = Math.max(startX, endX);
57
50
  transaction(() => {
58
51
  for (const view of model.views) {
59
52
  view.setOffsets(view.pxToBp(leftPx), view.pxToBp(rightPx));
60
53
  }
61
54
  });
62
55
  setGuideX(undefined);
63
- }
64
- function globalKeyDown(event) {
65
- if (event.key === 'Escape') {
66
- handleClose();
67
- }
68
- }
69
- window.addEventListener('mousemove', globalMouseMove);
70
- window.addEventListener('mouseup', globalMouseUp);
71
- window.addEventListener('keydown', globalKeyDown);
72
- return () => {
73
- window.removeEventListener('mousemove', globalMouseMove);
74
- window.removeEventListener('mouseup', globalMouseUp);
75
- window.removeEventListener('keydown', globalKeyDown);
76
- };
77
- }, [startX, mouseDragging, model, ref, handleClose]);
56
+ },
57
+ onCancel: handleClose,
58
+ });
78
59
  function mouseDown(event) {
79
60
  event.preventDefault();
80
61
  event.stopPropagation();
@@ -90,8 +71,10 @@ export function useRangeSelect(ref, model) {
90
71
  setCurrentX(relativeX);
91
72
  }
92
73
  function mouseMove(event) {
93
- // Don't update guideX while the menu is open (rubberband locked) or while a
94
- // drag-selection is in progress (the rubberband should show, not the guide)
74
+ // Don't update guideX while a menu is open — the guide is what the click
75
+ // menu's rows refer to, so it stays at the click rather than following the
76
+ // pointer to the menu — or while a drag-selection is in progress (the
77
+ // rubberband should show, not the guide)
95
78
  if (anchorPosition || mouseDragging) {
96
79
  return;
97
80
  }
@@ -112,13 +95,14 @@ export function useRangeSelect(ref, model) {
112
95
  callback();
113
96
  handleClose();
114
97
  }
115
- const rubberbandOn = startX !== undefined;
98
+ const isClick = anchorPosition?.isClick;
99
+ const rubberbandOn = startX !== undefined && !isClick;
116
100
  const right = anchorPosition?.offsetX ?? currentX;
117
101
  const left = rubberbandOn ? Math.min(right, startX) : 0;
118
102
  const width = rubberbandOn ? Math.abs(right - startX) : 0;
119
103
  const views = rubberbandOn ? model.views : [];
120
104
  return {
121
- open: Boolean(anchorPosition),
105
+ isClick,
122
106
  rubberbandOn,
123
107
  guideX,
124
108
  anchorPosition,