@jbrowse/plugin-linear-genome-view 4.1.15 → 4.2.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.
@@ -1,5 +1,4 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { memo } from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
3
2
  import { getContainingView } from '@jbrowse/core/util';
4
3
  import { makeStyles } from '@jbrowse/core/util/tss-react';
5
4
  import { observer } from 'mobx-react';
@@ -25,12 +24,6 @@ const useStyles = makeStyles()({
25
24
  lineHeight: 1,
26
25
  },
27
26
  });
28
- const FixedLabel = memo(function FixedLabel({ text, color, isOverlay, featureLeftPx, featureId, subfeatureId, y, tooltip, labelClass, overlayClass, }) {
29
- return (_jsx("div", { "data-feature-id": featureId, "data-subfeature-id": subfeatureId, "data-tooltip": tooltip, className: isOverlay ? `${labelClass} ${overlayClass}` : labelClass, style: {
30
- color,
31
- transform: `translate(calc(${featureLeftPx}px - var(--offset-px)), ${y}px)`,
32
- }, children: text }));
33
- });
34
27
  function FloatingLabel({ text, color, isOverlay, featureLeftPx, featureRightPx, featureId, subfeatureId, labelWidth, y, offsetPx, tooltip, labelClass, overlayClass, }) {
35
28
  const x = calculateFloatingLabelPosition(featureLeftPx, featureRightPx, labelWidth, offsetPx);
36
29
  return (_jsx("div", { "data-feature-id": featureId, "data-subfeature-id": subfeatureId, "data-tooltip": tooltip, className: isOverlay ? `${labelClass} ${overlayClass}` : labelClass, style: { color, transform: `translate(${x}px,${y}px)` }, children: text }));
@@ -41,8 +34,7 @@ const FloatingLabels = observer(function FloatingLabels({ model, }) {
41
34
  const { offsetPx } = view;
42
35
  const featureLabels = model.floatingLabelData;
43
36
  const { onFeatureClick, onFeatureContextMenu, onMouseMove } = model.renderingProps();
44
- const fixedLabels = [];
45
- const floatingLabels = [];
37
+ const labels = [];
46
38
  for (const [key, { leftPx, topPx, totalFeatureHeight, floatingLabels: labelData, featureWidth, },] of featureLabels.entries()) {
47
39
  const featureVisualBottom = topPx + totalFeatureHeight;
48
40
  const featureRightPx = leftPx + featureWidth;
@@ -52,15 +44,10 @@ const FloatingLabels = observer(function FloatingLabels({ model, }) {
52
44
  const y = featureVisualBottom + relativeY;
53
45
  const labelKey = `${key}-${i}`;
54
46
  const featureId = parentFeatureId ?? key;
55
- if (labelWidth > featureWidth) {
56
- fixedLabels.push(_jsx(FixedLabel, { text: text, color: color, isOverlay: isOverlay ?? false, featureLeftPx: leftPx, featureId: featureId, subfeatureId: subfeatureId, y: y, tooltip: tooltip, labelClass: classes.label, overlayClass: classes.overlay }, labelKey));
57
- }
58
- else {
59
- floatingLabels.push(_jsx(FloatingLabel, { text: text, color: color, isOverlay: isOverlay ?? false, featureLeftPx: leftPx, featureRightPx: featureRightPx, featureId: featureId, subfeatureId: subfeatureId, labelWidth: labelWidth, y: y, offsetPx: offsetPx, tooltip: tooltip, labelClass: classes.label, overlayClass: classes.overlay }, labelKey));
60
- }
47
+ labels.push(_jsx(FloatingLabel, { text: text, color: color, isOverlay: isOverlay ?? false, featureLeftPx: leftPx, featureRightPx: featureRightPx, featureId: featureId, subfeatureId: subfeatureId, labelWidth: labelWidth, y: y, offsetPx: offsetPx, tooltip: tooltip, labelClass: classes.label, overlayClass: classes.overlay }, labelKey));
61
48
  }
62
49
  }
63
- return (_jsxs("div", { className: classes.container, style: { '--offset-px': `${offsetPx}px` }, onClick: e => {
50
+ return (_jsx("div", { className: classes.container, onClick: e => {
64
51
  const target = e.target;
65
52
  const subfeatureId = target.dataset.subfeatureId;
66
53
  const featureId = subfeatureId ?? target.dataset.featureId;
@@ -83,6 +70,6 @@ const FloatingLabels = observer(function FloatingLabels({ model, }) {
83
70
  onMouseMove?.(e, featureId, tooltip);
84
71
  model.setSubfeatureIdUnderMouse(subfeatureId);
85
72
  }
86
- }, children: [fixedLabels, floatingLabels] }));
73
+ }, children: labels }));
87
74
  });
88
75
  export default FloatingLabels;
@@ -80,10 +80,11 @@ export function deduplicateFeatureLabels(layoutFeatures, view, assembly, bpPerPx
80
80
  if (leftPx === undefined) {
81
81
  continue;
82
82
  }
83
+ const floorLeftPx = Math.floor(leftPx);
83
84
  const existing = featureLabels.get(key);
84
- if (!existing || leftPx < existing.leftPx) {
85
+ if (!existing || floorLeftPx < existing.leftPx) {
85
86
  featureLabels.set(key, {
86
- leftPx,
87
+ leftPx: floorLeftPx,
87
88
  topPx: effectiveTopPx,
88
89
  totalFeatureHeight,
89
90
  floatingLabels,
@@ -96,11 +97,11 @@ export function deduplicateFeatureLabels(layoutFeatures, view, assembly, bpPerPx
96
97
  export function calculateFloatingLabelPosition(featureLeftPx, featureRightPx, labelWidth, offsetPx) {
97
98
  const featureWidth = featureRightPx - featureLeftPx;
98
99
  if (labelWidth > featureWidth) {
99
- return featureLeftPx - offsetPx;
100
+ return Math.round(featureLeftPx - offsetPx);
100
101
  }
101
102
  const viewportLeft = Math.max(0, offsetPx);
102
103
  const leftPx = Math.max(featureLeftPx, viewportLeft);
103
104
  const naturalX = leftPx - offsetPx;
104
105
  const maxX = featureRightPx - offsetPx - labelWidth;
105
- return clamp(naturalX, 0, maxX);
106
+ return Math.round(clamp(naturalX, 0, maxX));
106
107
  }
@@ -20,7 +20,14 @@ export function setupInitAutorun(self) {
20
20
  }
21
21
  try {
22
22
  if (init.loc) {
23
- await self.navToLocString(init.loc, init.assembly);
23
+ const asm = await assemblyManager.waitForAssembly(init.assembly);
24
+ if (!asm) {
25
+ throw new Error('Assembly not found');
26
+ }
27
+ await self.navToSearchString({
28
+ input: init.loc,
29
+ assembly: asm,
30
+ });
24
31
  }
25
32
  else {
26
33
  self.showAllRegionsInAssembly(init.assembly);
@@ -23,7 +23,7 @@ const LinearGenomeViewImportForm = observer(function LinearGenomeViewImportForm(
23
23
  const { classes } = useStyles();
24
24
  const session = getSession(model);
25
25
  const { assemblyNames, assemblyManager } = session;
26
- const { error } = model;
26
+ const { initialized, error } = model;
27
27
  const [selectedAsm, setSelectedAsm] = useState(assemblyNames[0]);
28
28
  const [option, setOption] = useState();
29
29
  const assembly = assemblyManager.get(selectedAsm);
@@ -38,7 +38,7 @@ const LinearGenomeViewImportForm = observer(function LinearGenomeViewImportForm(
38
38
  useEffect(() => {
39
39
  setValue(r0);
40
40
  }, [r0, selectedAsm]);
41
- return (_jsxs("div", { className: classes.container, children: [displayError ? _jsx(ErrorMessage, { error: displayError }) : null, _jsx(Container, { className: classes.importFormContainer, children: _jsx("form", { onSubmit: async (event) => {
41
+ return (_jsxs("div", { className: classes.container, children: [displayError ? _jsx(ErrorMessage, { error: displayError }) : null, initialized ? (_jsx(Container, { className: classes.importFormContainer, children: _jsx("form", { onSubmit: async (event) => {
42
42
  event.preventDefault();
43
43
  model.setError(undefined);
44
44
  if (value) {
@@ -72,6 +72,6 @@ const LinearGenomeViewImportForm = observer(function LinearGenomeViewImportForm(
72
72
  }, localStorageKey: "lgv", session: session, selected: selectedAsm }) }), selectedAsm ? (assemblyError ? (_jsx(CloseIcon, { style: { color: 'red' } })) : assemblyLoaded ? (_jsx(FormControl, { children: _jsx(ImportFormRefNameAutocomplete, { value: value, setValue: setValue, selectedAsm: selectedAsm, setOption: setOption, model: model }) })) : (_jsx(CircularProgress, { size: 20, disableShrink: true }))) : null, _jsx(FormControl, { children: _jsx(Button, { type: "submit", disabled: !value, className: classes.button, variant: "contained", color: "primary", children: "Open" }) }), _jsx(FormControl, { children: _jsx(Button, { disabled: !value, className: classes.button, onClick: () => {
73
73
  model.setError(undefined);
74
74
  model.showAllRegionsInAssembly(selectedAsm);
75
- }, variant: "contained", color: "secondary", children: "Show all regions in assembly" }) })] }) }) })] }));
75
+ }, variant: "contained", color: "secondary", children: "Show all regions in assembly" }) })] }) }) })) : null] }));
76
76
  });
77
77
  export default LinearGenomeViewImportForm;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-linear-genome-view",
3
- "version": "4.1.15",
3
+ "version": "4.2.1",
4
4
  "type": "module",
5
5
  "description": "JBrowse 2 linear genome view",
6
6
  "keywords": [
@@ -22,15 +22,15 @@
22
22
  ],
23
23
  "dependencies": {
24
24
  "@jbrowse/mobx-state-tree": "^5.6.0",
25
- "@mui/icons-material": "^7.3.9",
26
- "@mui/material": "^7.3.9",
25
+ "@mui/icons-material": "^7.3.10",
26
+ "@mui/material": "^7.3.10",
27
27
  "@types/file-saver-es": "^2.0.3",
28
28
  "copy-to-clipboard": "^3.3.3",
29
29
  "file-saver-es": "^2.0.5",
30
30
  "mobx": "^6.15.0",
31
31
  "mobx-react": "^9.2.1",
32
- "@jbrowse/core": "^4.1.15",
33
- "@jbrowse/product-core": "^4.1.15"
32
+ "@jbrowse/core": "^4.2.1",
33
+ "@jbrowse/product-core": "^4.2.1"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=18.0.0",