@teselagen/ove 0.8.26 → 0.8.28
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/RowItem/StackedAnnotations/PointedAnnotation.d.ts +56 -1
- package/helperComponents/withHover.d.ts +62 -2
- package/index.cjs.js +108 -108
- package/index.es.js +108 -108
- package/index.umd.js +108 -108
- package/ove.css +4 -2
- package/package.json +1 -1
- package/src/Editor/darkmode.css +4 -2
- package/src/RowItem/Translations/AASliver.js +3 -3
- package/src/createVectorEditor/makeStore.js +1 -1
- package/src/helperComponents/withHover.js +93 -69
- package/src/redux/index.js +0 -2
- package/redux/hoveredAnnotation.d.ts +0 -4
- package/src/redux/hoveredAnnotation.js +0 -24
|
@@ -168,11 +168,11 @@ function AASliver(props) {
|
|
|
168
168
|
{showAminoAcidNumbers && (aminoAcidIndex + 1) % 5 === 0 && (
|
|
169
169
|
<text
|
|
170
170
|
fontSize={25}
|
|
171
|
-
|
|
171
|
+
className={"aminoAcidNumber"}
|
|
172
172
|
strokeWidth={2}
|
|
173
|
-
transform={`scale(${(3 / width) * 10}
|
|
173
|
+
transform={`scale(${(3 / width) * 10},${37.5 / height}) translate(${
|
|
174
174
|
((forward ? 45 : 55) * width) / 10
|
|
175
|
-
}
|
|
175
|
+
},${4.4 * height - 4})`}
|
|
176
176
|
x="0"
|
|
177
177
|
y="4"
|
|
178
178
|
style={{ textAnchor: "middle" }}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import classnames from "classnames";
|
|
2
|
-
import { compose } from "redux";
|
|
3
|
-
import { connect } from "react-redux";
|
|
4
2
|
import React from "react";
|
|
5
|
-
import { store } from "@risingstack/react-easy-state";
|
|
6
|
-
import * as hoveredAnnotationActions from "../redux/hoveredAnnotation";
|
|
7
|
-
import { withHandlers, branch } from "recompose";
|
|
3
|
+
import { store, view } from "@risingstack/react-easy-state";
|
|
8
4
|
import { modifiableTypes } from "@teselagen/sequence-utils";
|
|
9
5
|
|
|
10
6
|
export const HoveredIdContext = React.createContext({
|
|
@@ -20,57 +16,37 @@ export function withHoveredIdFromContext(Component) {
|
|
|
20
16
|
);
|
|
21
17
|
};
|
|
22
18
|
}
|
|
19
|
+
|
|
20
|
+
// Easy state store for hover state management (replaces Redux)
|
|
23
21
|
export const hoveredAnnEasyStore = store({
|
|
24
22
|
hoveredAnn: undefined,
|
|
25
|
-
selectedAnn: undefined
|
|
23
|
+
selectedAnn: undefined,
|
|
24
|
+
// Per-editor hovered annotation IDs
|
|
25
|
+
hoveredIds: {}
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const hovered = !!(isIdHashmap ? id[hoveredId] : hoveredId === id);
|
|
52
|
-
const newClassName = classnames(className, "hoverHelper", {
|
|
53
|
-
veAnnotationHovered: hovered
|
|
54
|
-
});
|
|
55
|
-
const toReturn = {
|
|
56
|
-
hovered,
|
|
57
|
-
className: newClassName
|
|
58
|
-
};
|
|
59
|
-
if (hovered && passHoveredId) {
|
|
60
|
-
//only pass hoveredId if it is hovered
|
|
61
|
-
toReturn.hoveredId = hoveredId;
|
|
62
|
-
}
|
|
63
|
-
return toReturn;
|
|
64
|
-
}, hoveredAnnotationActions)
|
|
65
|
-
),
|
|
66
|
-
withHandlers({
|
|
67
|
-
onMouseOver: props =>
|
|
68
|
-
function (e) {
|
|
69
|
-
// loop through the target element and the parents and see if any of them have the hoverHelper class
|
|
70
|
-
// if they do, then we don't want to trigger the hover event
|
|
71
|
-
// if they don't, then we do want to trigger the hover event
|
|
72
|
-
// we should stop the loop if the target element is implementing this onMouseOver event
|
|
73
|
-
// e.stopPropagation(); //this is important otherwise hovering labels inside circular view label groups won't work
|
|
28
|
+
// Helper functions to update/clear hovered annotation (replaces Redux actions)
|
|
29
|
+
export function hoveredAnnotationUpdate(
|
|
30
|
+
id,
|
|
31
|
+
{ editorName = "StandaloneEditor" } = {}
|
|
32
|
+
) {
|
|
33
|
+
hoveredAnnEasyStore.hoveredIds[editorName] = id;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function hoveredAnnotationClear(
|
|
37
|
+
clear,
|
|
38
|
+
{ editorName = "StandaloneEditor" } = {}
|
|
39
|
+
) {
|
|
40
|
+
hoveredAnnEasyStore.hoveredIds[editorName] = "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// HOC that provides hover functionality using react-easy-state
|
|
44
|
+
export default function withHover(WrappedComponent) {
|
|
45
|
+
const HoverComponent = view(
|
|
46
|
+
class extends React.Component {
|
|
47
|
+
static contextType = HoveredIdContext;
|
|
48
|
+
|
|
49
|
+
handleMouseOver = e => {
|
|
74
50
|
const target = e.target;
|
|
75
51
|
let alreadyHandled = false;
|
|
76
52
|
let currentElement = target;
|
|
@@ -78,8 +54,6 @@ export default compose(
|
|
|
78
54
|
if (currentElement === e.currentTarget) {
|
|
79
55
|
break;
|
|
80
56
|
}
|
|
81
|
-
// console.log(`currentElement:`, currentElement)
|
|
82
|
-
|
|
83
57
|
if (currentElement.classList.contains("hoverHelper")) {
|
|
84
58
|
alreadyHandled = true;
|
|
85
59
|
break;
|
|
@@ -88,26 +62,76 @@ export default compose(
|
|
|
88
62
|
}
|
|
89
63
|
if (alreadyHandled) return;
|
|
90
64
|
|
|
91
|
-
|
|
92
|
-
|
|
65
|
+
const {
|
|
66
|
+
editorName = "StandaloneEditor",
|
|
67
|
+
id,
|
|
68
|
+
annotation,
|
|
69
|
+
label
|
|
70
|
+
} = this.props;
|
|
93
71
|
const isIdHashmap = typeof id === "object";
|
|
94
72
|
const idToPass = isIdHashmap ? Object.keys(id)[0] : id;
|
|
95
|
-
const annot =
|
|
73
|
+
const annot = annotation || label?.annotation;
|
|
96
74
|
if (modifiableTypes.includes(annot?.annotationTypePlural)) {
|
|
97
75
|
hoveredAnnEasyStore.hoveredAnn = annot;
|
|
98
76
|
}
|
|
99
|
-
//
|
|
77
|
+
// Disable hover during dragging or scrolling
|
|
100
78
|
if (window.__veDragging || window.__veScrolling) return;
|
|
101
79
|
|
|
102
|
-
hoveredAnnotationUpdate
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
80
|
+
hoveredAnnotationUpdate(idToPass, { editorName });
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
handleMouseLeave = e => {
|
|
84
|
+
hoveredAnnEasyStore.hoveredAnn = undefined;
|
|
85
|
+
const { editorName = "StandaloneEditor" } = this.props;
|
|
86
|
+
e.stopPropagation();
|
|
87
|
+
if (window.__veDragging || window.__veScrolling) return;
|
|
88
|
+
hoveredAnnotationClear(true, { editorName });
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
render() {
|
|
92
|
+
const {
|
|
93
|
+
id,
|
|
94
|
+
editorName = "StandaloneEditor",
|
|
95
|
+
className,
|
|
96
|
+
passHoveredId,
|
|
97
|
+
noRedux, // eslint-disable-line no-unused-vars
|
|
98
|
+
...restProps
|
|
99
|
+
} = this.props;
|
|
100
|
+
|
|
101
|
+
const hoveredIdFromContext = this.context?.hoveredId;
|
|
102
|
+
const hoveredId =
|
|
103
|
+
hoveredAnnEasyStore.hoveredIds[editorName] ||
|
|
104
|
+
hoveredIdFromContext ||
|
|
105
|
+
"";
|
|
106
|
+
const isIdHashmap = typeof id === "object";
|
|
107
|
+
const hovered = !!(isIdHashmap ? id[hoveredId] : hoveredId === id);
|
|
108
|
+
|
|
109
|
+
const newClassName = classnames(className, "hoverHelper", {
|
|
110
|
+
veAnnotationHovered: hovered
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const passedProps = {
|
|
114
|
+
...restProps,
|
|
115
|
+
id,
|
|
116
|
+
editorName,
|
|
117
|
+
hovered,
|
|
118
|
+
className: newClassName,
|
|
119
|
+
onMouseOver: this.handleMouseOver,
|
|
120
|
+
onMouseLeave: this.handleMouseLeave
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
if (hovered && passHoveredId) {
|
|
124
|
+
passedProps.hoveredId = hoveredId;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return <WrappedComponent {...passedProps} />;
|
|
128
|
+
}
|
|
111
129
|
}
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
HoverComponent.displayName = `withHover(${
|
|
133
|
+
WrappedComponent.displayName || WrappedComponent.name || "Component"
|
|
134
|
+
})`;
|
|
135
|
+
|
|
136
|
+
return HoverComponent;
|
|
137
|
+
}
|
package/src/redux/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import * as digestTool from "./digestTool";
|
|
|
11
11
|
import * as findTool from "./findTool";
|
|
12
12
|
import * as toolBar from "./toolBar";
|
|
13
13
|
import * as frameTranslations from "./frameTranslations";
|
|
14
|
-
import * as hoveredAnnotation from "./hoveredAnnotation";
|
|
15
14
|
import * as minimumOrfSize from "./minimumOrfSize";
|
|
16
15
|
import * as alignments from "./alignments";
|
|
17
16
|
import * as panelsShown from "./panelsShown";
|
|
@@ -51,7 +50,6 @@ const subReducers = {
|
|
|
51
50
|
toolBar,
|
|
52
51
|
findTool,
|
|
53
52
|
frameTranslations,
|
|
54
|
-
hoveredAnnotation,
|
|
55
53
|
minimumOrfSize,
|
|
56
54
|
panelsShown,
|
|
57
55
|
propertiesTool,
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export const hoveredAnnotationUpdate: import('redux-act').ComplexActionCreator1<any, any, any>;
|
|
2
|
-
export const hoveredAnnotationClear: import('redux-act').ComplexActionCreator1<any, any, any>;
|
|
3
|
-
declare const _default: import('redux-act').Reducer<string, import('../../../../node_modules/redux').AnyAction>;
|
|
4
|
-
export default _default;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//./caretPosition.js
|
|
2
|
-
import { createReducer } from "redux-act";
|
|
3
|
-
import createAction from "./utils/createMetaAction";
|
|
4
|
-
|
|
5
|
-
// ------------------------------------
|
|
6
|
-
// Actions
|
|
7
|
-
// ------------------------------------
|
|
8
|
-
export const hoveredAnnotationUpdate = createAction("HOVEREDANNOTATIONUPDATE");
|
|
9
|
-
export const hoveredAnnotationClear = createAction("HOVEREDANNOTATIONCLEAR");
|
|
10
|
-
|
|
11
|
-
// ------------------------------------
|
|
12
|
-
// Reducer
|
|
13
|
-
// ------------------------------------
|
|
14
|
-
export default createReducer(
|
|
15
|
-
{
|
|
16
|
-
[hoveredAnnotationUpdate]: (state, payload) => {
|
|
17
|
-
return payload || null;
|
|
18
|
-
},
|
|
19
|
-
[hoveredAnnotationClear]: () => {
|
|
20
|
-
return "";
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
""
|
|
24
|
-
);
|