nmrium 0.24.1 → 0.25.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.
- package/lib/component/1d/IntegralResizable.js +13 -13
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
- package/lib/component/1d/ranges/Range.js +18 -28
- package/lib/component/NMRium.js +22 -29
- package/lib/component/context/GlobalContext.d.ts +12 -3
- package/lib/component/context/GlobalContext.js +1 -1
- package/lib/component/elements/ActionButtons.d.ts +10 -0
- package/lib/component/elements/ActionButtons.js +14 -0
- package/lib/component/elements/Button.d.ts +30 -5
- package/lib/component/elements/Button.js +150 -4
- package/lib/component/elements/ContextMenu.js +6 -6
- package/lib/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
- package/lib/component/elements/resizer/DivResizer.js +107 -0
- package/lib/component/elements/resizer/Resizer.d.ts +18 -0
- package/lib/component/elements/resizer/Resizer.js +12 -0
- package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
- package/lib/component/elements/resizer/SVGResizer.js +71 -0
- package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
- package/lib/component/elements/resizer/useDraggable.js +52 -0
- package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
- package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib/component/header/RangesPickingOptionPanel.js +3 -16
- package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib/component/header/Zones2DOptionPanel.js +3 -14
- package/lib/component/hooks/useExport.js +11 -9
- package/lib/component/loader/DropZone.js +1 -0
- package/lib/component/modal/AlignSpectraModal.js +2 -1
- package/lib/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib/component/modal/LoadJCAMPModal.js +7 -6
- package/lib/component/modal/ModalStyle.js +4 -26
- package/lib/component/modal/MoleculeStructureEditorModal.js +2 -1
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib/component/modal/PredictSpectraModal.js +2 -7
- package/lib/component/modal/SaveAsModal.d.ts +1 -1
- package/lib/component/modal/SaveAsModal.js +2 -1
- package/lib/component/modal/setting/GeneralSettings.js +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +10 -4
- package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib/component/utility/Export.d.ts +3 -3
- package/lib/component/utility/Export.js +10 -9
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/IntegralResizable.js +12 -12
- package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
- package/lib-cjs/component/1d/ranges/Range.js +18 -28
- package/lib-cjs/component/NMRium.js +22 -29
- package/lib-cjs/component/context/GlobalContext.js +1 -1
- package/lib-cjs/component/elements/ActionButtons.js +20 -0
- package/lib-cjs/component/elements/Button.js +149 -4
- package/lib-cjs/component/elements/ContextMenu.js +6 -6
- package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
- package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
- package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
- package/lib-cjs/component/elements/resizer/useDraggable.js +55 -0
- package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
- package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
- package/lib-cjs/component/hooks/useExport.js +11 -9
- package/lib-cjs/component/loader/DropZone.js +1 -0
- package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
- package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
- package/lib-cjs/component/modal/ModalStyle.js +4 -26
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +5 -1
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
- package/lib-cjs/component/modal/SaveAsModal.js +2 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -1
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +10 -4
- package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib-cjs/component/utility/Export.js +10 -9
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +16 -17
- package/lib/component/1d/Resizable.d.ts +0 -12
- package/lib/component/1d/Resizable.js +0 -105
- package/lib-cjs/component/1d/Resizable.js +0 -110
|
@@ -77,7 +77,6 @@ const containerStyles = (0, react_1.css) `
|
|
|
77
77
|
|
|
78
78
|
button {
|
|
79
79
|
cursor: pointer;
|
|
80
|
-
color: black;
|
|
81
80
|
&:disabled {
|
|
82
81
|
cursor: default;
|
|
83
82
|
}
|
|
@@ -104,25 +103,6 @@ const containerStyles = (0, react_1.css) `
|
|
|
104
103
|
.SplitPane {
|
|
105
104
|
height: 100%;
|
|
106
105
|
}
|
|
107
|
-
|
|
108
|
-
.Resizer.vertical:after {
|
|
109
|
-
content: '\\22EE';
|
|
110
|
-
top: 50%;
|
|
111
|
-
color: black;
|
|
112
|
-
position: absolute;
|
|
113
|
-
font-size: 14px;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.Resizer.vertical {
|
|
117
|
-
padding: 2px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.Resizer.vertical:hover {
|
|
121
|
-
background-color: #dfdfdf !important;
|
|
122
|
-
border-left: 0.55px #bbbbbb;
|
|
123
|
-
solid;
|
|
124
|
-
border-right: 0.55px #bbbbbb solid;
|
|
125
|
-
}
|
|
126
106
|
`;
|
|
127
107
|
const defaultPreferences = {};
|
|
128
108
|
const defaultData = {
|
|
@@ -133,7 +113,7 @@ function NMRium(props) {
|
|
|
133
113
|
}
|
|
134
114
|
function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = defaultPreferences, getSpinner = SpinnerContext_1.defaultGetSpinner, onDataChange, emptyText, }) {
|
|
135
115
|
const rootRef = (0, react_2.useRef)(null);
|
|
136
|
-
const
|
|
116
|
+
const elementsWrapperRef = (0, react_2.useRef)(null);
|
|
137
117
|
const [show, toggle] = (0, react_use_1.useToggle)(false);
|
|
138
118
|
const isFullscreen = (0, react_use_1.useFullscreen)(rootRef, show, {
|
|
139
119
|
onClose: () => {
|
|
@@ -175,16 +155,29 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = de
|
|
|
175
155
|
e.preventDefault();
|
|
176
156
|
}
|
|
177
157
|
}, []);
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
158
|
+
const mainDivRef = (0, react_2.useRef)(null);
|
|
159
|
+
(0, react_2.useEffect)(() => {
|
|
160
|
+
const div = mainDivRef.current;
|
|
161
|
+
if (!div) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
function mouseEnterHandler() {
|
|
165
|
+
dispatchMiddleWare({ type: Types_1.SET_MOUSE_OVER_DISPLAYER, payload: true });
|
|
166
|
+
}
|
|
167
|
+
function mouseLeaveHandler() {
|
|
168
|
+
dispatchMiddleWare({ type: Types_1.SET_MOUSE_OVER_DISPLAYER, payload: false });
|
|
169
|
+
}
|
|
170
|
+
div.addEventListener('mouseenter', mouseEnterHandler);
|
|
171
|
+
div.addEventListener('mouseleave', mouseLeaveHandler);
|
|
172
|
+
return () => {
|
|
173
|
+
div.removeEventListener('mouseenter', mouseEnterHandler);
|
|
174
|
+
div.removeEventListener('mouseleave', mouseLeaveHandler);
|
|
175
|
+
};
|
|
183
176
|
}, [dispatchMiddleWare]);
|
|
184
177
|
return ((0, jsx_runtime_1.jsx)(GlobalContext_1.GlobalProvider, { value: {
|
|
185
178
|
rootRef: rootRef.current,
|
|
186
|
-
|
|
187
|
-
}, children: (0, jsx_runtime_1.jsx)(PreferencesContext_1.PreferencesProvider, { value: preferencesState, children: (0, jsx_runtime_1.jsx)("div", {
|
|
179
|
+
elementsWrapperRef: elementsWrapperRef.current,
|
|
180
|
+
}, children: (0, jsx_runtime_1.jsx)(PreferencesContext_1.PreferencesProvider, { value: preferencesState, children: (0, jsx_runtime_1.jsx)("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: (0, jsx_runtime_1.jsx)(Alert_1.AlertProvider, { wrapperRef: elementsWrapperRef.current, children: (0, jsx_runtime_1.jsx)(DispatchContext_1.DispatchProvider, { value: dispatchMiddleWare, children: (0, jsx_runtime_1.jsx)(ChartContext_1.ChartDataProvider, { value: state, children: (0, jsx_runtime_1.jsx)(Modal_1.ModalProvider, { wrapperRef: elementsWrapperRef.current, children: (0, jsx_runtime_1.jsx)(highlight_1.HighlightProvider, { children: (0, jsx_runtime_1.jsx)(assignment_1.AssignmentProvider, { spectraData: spectraData, children: (0, jsx_runtime_1.jsx)(SpinnerContext_1.SpinnerProvider, { value: getSpinner, children: (0, jsx_runtime_1.jsx)("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: (0, jsx_runtime_1.jsx)(DropZone_1.default, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
188
181
|
display: 'flex',
|
|
189
182
|
flexDirection: 'column',
|
|
190
183
|
backgroundColor: 'white',
|
|
@@ -197,7 +190,7 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = de
|
|
|
197
190
|
width: '100%',
|
|
198
191
|
height: '100%',
|
|
199
192
|
}, children: displayerMode ===
|
|
200
|
-
Constants_1.DISPLAYER_MODE.DM_1D ? ((0, jsx_runtime_1.jsx)(Viewer1D_1.default, { emptyText: emptyText })) : ((0, jsx_runtime_1.jsx)(Viewer2D_1.default, { emptyText: emptyText })) })] }), (0, jsx_runtime_1.jsx)(Panels_1.default, {})] }), (0, jsx_runtime_1.jsx)("div", { ref:
|
|
193
|
+
Constants_1.DISPLAYER_MODE.DM_1D ? ((0, jsx_runtime_1.jsx)(Viewer1D_1.default, { emptyText: emptyText })) : ((0, jsx_runtime_1.jsx)(Viewer2D_1.default, { emptyText: emptyText })) })] }), (0, jsx_runtime_1.jsx)(Panels_1.default, {})] }), (0, jsx_runtime_1.jsx)("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
|
|
201
194
|
position: 'absolute',
|
|
202
195
|
pointerEvents: 'none',
|
|
203
196
|
zIndex: 0,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useGlobal = exports.GlobalProvider = exports.GlobalConetxt = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
-
exports.GlobalConetxt = (0, react_1.createContext)({});
|
|
5
|
+
exports.GlobalConetxt = (0, react_1.createContext)({ rootRef: null, elementsWrapperRef: null });
|
|
6
6
|
exports.GlobalProvider = exports.GlobalConetxt.Provider;
|
|
7
7
|
function useGlobal() {
|
|
8
8
|
return (0, react_1.useContext)(exports.GlobalConetxt);
|
|
@@ -0,0 +1,20 @@
|
|
|
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 Button_1 = __importDefault(require("./Button"));
|
|
8
|
+
function ActionButtons(props) {
|
|
9
|
+
const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, } = props;
|
|
10
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: onDone, style: style?.flexDirection === 'row-reverse'
|
|
11
|
+
? {
|
|
12
|
+
marginLeft: '10px',
|
|
13
|
+
}
|
|
14
|
+
: {}, children: doneLabel }), (0, jsx_runtime_1.jsx)(Button_1.default.Danger, { fill: "outline", onClick: onCancel, style: !style.flexDirection || style.flexDirection === 'row'
|
|
15
|
+
? {
|
|
16
|
+
marginLeft: '10px',
|
|
17
|
+
}
|
|
18
|
+
: {}, children: cancelLabel })] }));
|
|
19
|
+
}
|
|
20
|
+
exports.default = ActionButtons;
|
|
@@ -1,8 +1,153 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
4
|
+
/** @jsxImportSource @emotion/react */
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
6
|
+
const colorPalettes = {
|
|
7
|
+
success: {
|
|
8
|
+
base: '#2dd36f',
|
|
9
|
+
shade: '#28ba62',
|
|
10
|
+
tint: '#42d77d',
|
|
11
|
+
},
|
|
12
|
+
danger: {
|
|
13
|
+
base: '#eb445a',
|
|
14
|
+
shade: '#cf3c4f',
|
|
15
|
+
tint: '#ed576b',
|
|
16
|
+
},
|
|
17
|
+
warning: {
|
|
18
|
+
base: '#ffc409',
|
|
19
|
+
shade: '#e0ac08',
|
|
20
|
+
tint: '#ffca22',
|
|
21
|
+
},
|
|
22
|
+
medium: {
|
|
23
|
+
base: '#92949c',
|
|
24
|
+
shade: '#808289',
|
|
25
|
+
tint: '#9d9fa6',
|
|
26
|
+
},
|
|
27
|
+
light: {
|
|
28
|
+
base: '#f4f5f8',
|
|
29
|
+
shade: '#d7d8da',
|
|
30
|
+
tint: '#f5f6f9',
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const sizeConfig = {
|
|
34
|
+
xSmall: {
|
|
35
|
+
fontSize: '0.75rem',
|
|
36
|
+
padding: '0.15rem 0.3rem',
|
|
37
|
+
borderRadius: '0.15rem',
|
|
38
|
+
},
|
|
39
|
+
small: {
|
|
40
|
+
fontSize: '0.8rem',
|
|
41
|
+
padding: '0.25rem 0.5rem',
|
|
42
|
+
borderRadius: '0.2rem',
|
|
43
|
+
},
|
|
44
|
+
medium: {
|
|
45
|
+
fontSize: '1rem',
|
|
46
|
+
padding: '0.375rem 0.75rem',
|
|
47
|
+
borderRadius: '0.25rem',
|
|
48
|
+
},
|
|
49
|
+
large: {
|
|
50
|
+
fontSize: '1.25rem',
|
|
51
|
+
padding: '0.5rem 1rem',
|
|
52
|
+
borderRadius: '0.3rem',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
function getFillStyle(props) {
|
|
56
|
+
const { borderColor, fill, backgroundColor, color } = props;
|
|
57
|
+
switch (fill) {
|
|
58
|
+
case 'solid': {
|
|
59
|
+
return (0, react_1.css) `
|
|
60
|
+
border-color: transparent;
|
|
61
|
+
background-color: ${backgroundColor.base};
|
|
62
|
+
color: ${color.hover};
|
|
63
|
+
`;
|
|
64
|
+
}
|
|
65
|
+
case 'outline': {
|
|
66
|
+
return (0, react_1.css) `
|
|
67
|
+
border-style: solid;
|
|
68
|
+
border-color: ${backgroundColor.base};
|
|
69
|
+
background-color: transparent;
|
|
70
|
+
color: ${color.base};
|
|
71
|
+
`;
|
|
72
|
+
}
|
|
73
|
+
case 'clear': {
|
|
74
|
+
return (0, react_1.css) `
|
|
75
|
+
border-color: transparent;
|
|
76
|
+
background-color: transparent;
|
|
77
|
+
color: ${color.base};
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
default:
|
|
81
|
+
return (0, react_1.css) `
|
|
82
|
+
background-color: ${backgroundColor.base};
|
|
83
|
+
color: ${color.base};
|
|
84
|
+
border-color: ${borderColor};
|
|
85
|
+
`;
|
|
86
|
+
}
|
|
7
87
|
}
|
|
88
|
+
const styles = {
|
|
89
|
+
button: (props) => {
|
|
90
|
+
const { size, backgroundColor, color, borderRadius } = props;
|
|
91
|
+
const basic = (0, react_1.css) `
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: row;
|
|
94
|
+
border-width: 1px;
|
|
95
|
+
align-items: center;
|
|
96
|
+
`;
|
|
97
|
+
const fillStyle = getFillStyle(props);
|
|
98
|
+
const colorStyle = (0, react_1.css) `
|
|
99
|
+
&:not([disabled]):hover {
|
|
100
|
+
background-color: ${backgroundColor.hover};
|
|
101
|
+
color: ${color.hover};
|
|
102
|
+
}
|
|
103
|
+
&:not([disabled]):active {
|
|
104
|
+
background-color: ${backgroundColor?.active || backgroundColor.hover};
|
|
105
|
+
color: ${color?.active || color.hover};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&:disabled {
|
|
109
|
+
opacity: 0.25;
|
|
110
|
+
}
|
|
111
|
+
`;
|
|
112
|
+
return (0, react_1.css)([
|
|
113
|
+
basic,
|
|
114
|
+
sizeConfig[size],
|
|
115
|
+
fillStyle,
|
|
116
|
+
colorStyle,
|
|
117
|
+
{ borderRadius },
|
|
118
|
+
]);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
const Button = (props) => {
|
|
122
|
+
const { onClick, size = 'small', color = { base: 'black', hover: 'white' }, backgroundColor = { base: 'white', hover: 'black', active: 'black' }, borderColor = 'transparent', fill, borderRadius, style = {}, ...restProps } = props;
|
|
123
|
+
return ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: onClick, css: [
|
|
124
|
+
styles.button({
|
|
125
|
+
size,
|
|
126
|
+
backgroundColor,
|
|
127
|
+
color,
|
|
128
|
+
borderColor,
|
|
129
|
+
fill,
|
|
130
|
+
borderRadius,
|
|
131
|
+
}),
|
|
132
|
+
style,
|
|
133
|
+
], ...restProps, children: (0, jsx_runtime_1.jsxs)("span", { style: { flex: 1 }, children: [" ", props.children] }) }));
|
|
134
|
+
};
|
|
135
|
+
function ThemeButton(props) {
|
|
136
|
+
const { base, shade, tint } = colorPalettes[props.colorTheme];
|
|
137
|
+
const { color = { base: shade, hover: 'white' }, backgroundColor = {
|
|
138
|
+
base: base,
|
|
139
|
+
hover: shade,
|
|
140
|
+
active: tint,
|
|
141
|
+
}, fill = 'solid', ...restProps } = props;
|
|
142
|
+
return (0, jsx_runtime_1.jsx)(Button, { ...{ fill, ...restProps, backgroundColor, color } });
|
|
143
|
+
}
|
|
144
|
+
Button.Done = (props) => {
|
|
145
|
+
return (0, jsx_runtime_1.jsx)(ThemeButton, { ...props, colorTheme: "success" });
|
|
146
|
+
};
|
|
147
|
+
Button.Danger = (props) => {
|
|
148
|
+
return (0, jsx_runtime_1.jsx)(ThemeButton, { ...props, colorTheme: "danger" });
|
|
149
|
+
};
|
|
150
|
+
Button.Action = (props) => {
|
|
151
|
+
return (0, jsx_runtime_1.jsx)(ThemeButton, { ...props, colorTheme: "medium" });
|
|
152
|
+
};
|
|
8
153
|
exports.default = Button;
|
|
@@ -49,22 +49,22 @@ function ContextMenu({ context }, ref) {
|
|
|
49
49
|
left: 0,
|
|
50
50
|
top: 0,
|
|
51
51
|
});
|
|
52
|
-
const { rootRef,
|
|
52
|
+
const { rootRef, elementsWrapperRef } = (0, GlobalContext_1.useGlobal)();
|
|
53
53
|
const [data, setData] = (0, react_2.useState)();
|
|
54
54
|
const [isVisible, show] = (0, react_2.useState)();
|
|
55
55
|
const [sourceElement, setSourceElement] = (0, react_2.useState)(null);
|
|
56
56
|
const root = (0, react_2.useRef)();
|
|
57
57
|
(0, react_2.useEffect)(() => {
|
|
58
58
|
root.current = document.createElement('div');
|
|
59
|
-
if (
|
|
60
|
-
|
|
59
|
+
if (elementsWrapperRef) {
|
|
60
|
+
elementsWrapperRef.appendChild(root.current);
|
|
61
61
|
}
|
|
62
62
|
return () => {
|
|
63
|
-
if (root.current &&
|
|
64
|
-
|
|
63
|
+
if (root.current && elementsWrapperRef) {
|
|
64
|
+
elementsWrapperRef.removeChild(root.current);
|
|
65
65
|
}
|
|
66
66
|
};
|
|
67
|
-
}, [
|
|
67
|
+
}, [elementsWrapperRef]);
|
|
68
68
|
const contextMenuHandler = (event) => {
|
|
69
69
|
event.preventDefault();
|
|
70
70
|
setSourceElement(event.target.parentElement);
|
|
@@ -25,7 +25,7 @@ function ToolTip({ style = { popup: {}, mainContainer: {} }, className = '', pop
|
|
|
25
25
|
const refContent = (0, react_1.useRef)(null);
|
|
26
26
|
const [placement, setPlacement] = (0, react_1.useState)({ x: 0, y: 0 });
|
|
27
27
|
const [show, showToolTip] = (0, react_1.useState)(false);
|
|
28
|
-
const {
|
|
28
|
+
const { elementsWrapperRef } = (0, GlobalContext_1.useGlobal)();
|
|
29
29
|
(0, react_1.useLayoutEffect)(() => {
|
|
30
30
|
const getPopupPlacement = () => {
|
|
31
31
|
let x;
|
|
@@ -92,11 +92,12 @@ function ToolTip({ style = { popup: {}, mainContainer: {} }, className = '', pop
|
|
|
92
92
|
alignItems: 'center',
|
|
93
93
|
...style.mainContainer,
|
|
94
94
|
}, ref: refChild, onMouseOver: mouseOverHandler, onMouseOut: mouseLeaveHandler, children: children }), show &&
|
|
95
|
+
elementsWrapperRef &&
|
|
95
96
|
(0, react_dom_1.createPortal)((0, jsx_runtime_1.jsx)("div", { ref: refContent, style: {
|
|
96
97
|
...styles.popup,
|
|
97
98
|
transform: `translate(${placement.x + offset.x}px,${placement.y + offset.y}px)`,
|
|
98
99
|
zIndex: 999999999,
|
|
99
100
|
...style.popup,
|
|
100
|
-
}, className: className, children: (0, jsx_runtime_1.jsx)("span", { style: { pointerEvents: 'none' }, children: title }) }),
|
|
101
|
+
}, className: className, children: (0, jsx_runtime_1.jsx)("span", { style: { pointerEvents: 'none' }, children: title }) }), elementsWrapperRef)] }));
|
|
101
102
|
}
|
|
102
103
|
exports.default = (0, react_1.memo)(ToolTip);
|
|
@@ -0,0 +1,113 @@
|
|
|
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("@emotion/react/jsx-runtime");
|
|
7
|
+
/** @jsxImportSource @emotion/react */
|
|
8
|
+
const react_1 = require("@emotion/react");
|
|
9
|
+
const react_2 = require("react");
|
|
10
|
+
const useDraggable_1 = __importDefault(require("./useDraggable"));
|
|
11
|
+
const anchorStyle = {
|
|
12
|
+
marginLeft: '5px',
|
|
13
|
+
width: '2px',
|
|
14
|
+
height: '100%',
|
|
15
|
+
pointerEvents: 'none',
|
|
16
|
+
position: 'relative',
|
|
17
|
+
};
|
|
18
|
+
const styles = {
|
|
19
|
+
container: (position) => (0, react_1.css) `
|
|
20
|
+
position: absolute;
|
|
21
|
+
height: 100%;
|
|
22
|
+
width: 10px;
|
|
23
|
+
left: -5px;
|
|
24
|
+
cursor: e-resize;
|
|
25
|
+
transform: translateX(${position}px);
|
|
26
|
+
user-select: none;
|
|
27
|
+
z-index: 99999999;
|
|
28
|
+
|
|
29
|
+
&:hover {
|
|
30
|
+
div {
|
|
31
|
+
background-color: red;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
`,
|
|
35
|
+
content: (anchorSide, left, right) => {
|
|
36
|
+
const width = right.previousPosition - left.previousPosition;
|
|
37
|
+
const baseCss = (0, react_1.css) `
|
|
38
|
+
position: absolute;
|
|
39
|
+
width: ${width}px;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
`;
|
|
42
|
+
if (right.position.action === 'move' || left.position.action === 'move') {
|
|
43
|
+
const scale = (right.position.x - left.position.x) / width;
|
|
44
|
+
if (anchorSide === 'RIGHT') {
|
|
45
|
+
return [
|
|
46
|
+
baseCss,
|
|
47
|
+
(0, react_1.css) `
|
|
48
|
+
transform: translateX(${left.position.x}px) scaleX(${scale});
|
|
49
|
+
transform-origin: left center;
|
|
50
|
+
`,
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
else if (anchorSide === 'LEFT') {
|
|
54
|
+
return (0, react_1.css)([
|
|
55
|
+
baseCss,
|
|
56
|
+
(0, react_1.css) `
|
|
57
|
+
transform: translateX(${left.position.x}px) scaleX(${scale});
|
|
58
|
+
transform-origin: left center;
|
|
59
|
+
`,
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
return (0, react_1.css)([
|
|
65
|
+
baseCss,
|
|
66
|
+
(0, react_1.css) `
|
|
67
|
+
transform: translateX(${left.position.x}px);
|
|
68
|
+
`,
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
function DivResizer(props) {
|
|
74
|
+
const { children, initialPosition = { x1: 10, x2: 40 }, onStart, onMove, onEnd, } = props;
|
|
75
|
+
const right = (0, useDraggable_1.default)({
|
|
76
|
+
x: initialPosition.x2,
|
|
77
|
+
anchor: 'RIGHT',
|
|
78
|
+
});
|
|
79
|
+
const left = (0, useDraggable_1.default)({
|
|
80
|
+
x: initialPosition.x1,
|
|
81
|
+
anchor: 'LEFT',
|
|
82
|
+
});
|
|
83
|
+
const anchor = left.isActive
|
|
84
|
+
? left.anchor
|
|
85
|
+
: right.isActive
|
|
86
|
+
? right.anchor
|
|
87
|
+
: '';
|
|
88
|
+
(0, react_2.useEffect)(() => {
|
|
89
|
+
const position = { x1: left.position.x, x2: right.position.x };
|
|
90
|
+
const status = left.isActive
|
|
91
|
+
? left.position.action
|
|
92
|
+
: right.isActive
|
|
93
|
+
? right.position.action
|
|
94
|
+
: '';
|
|
95
|
+
switch (status) {
|
|
96
|
+
case 'start':
|
|
97
|
+
onStart?.(position);
|
|
98
|
+
break;
|
|
99
|
+
case 'move':
|
|
100
|
+
onMove?.(position);
|
|
101
|
+
break;
|
|
102
|
+
case 'end':
|
|
103
|
+
onEnd?.(position);
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}, [left, onEnd, onMove, onStart, right]);
|
|
109
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { "data-no-export": "true", onMouseDown: right.onMouseDown, css: styles.container(right.position.x), children: (0, jsx_runtime_1.jsx)("div", { style: anchorStyle }) }), (0, jsx_runtime_1.jsx)("div", { css: styles.content(anchor, left, right), children: typeof children === 'function'
|
|
110
|
+
? children?.(left.position.x, right.position.x)
|
|
111
|
+
: children }), (0, jsx_runtime_1.jsx)("div", { "data-no-export": "true", onMouseDown: left.onMouseDown, css: styles.container(left.position.x), children: (0, jsx_runtime_1.jsx)("div", { style: anchorStyle }) })] }));
|
|
112
|
+
}
|
|
113
|
+
exports.default = DivResizer;
|
|
@@ -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
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const DivResizer_1 = __importDefault(require("./DivResizer"));
|
|
8
|
+
const SVGResizer_1 = __importDefault(require("./SVGResizer"));
|
|
9
|
+
function Resizer(props) {
|
|
10
|
+
const { tag = 'div', ...resProps } = props;
|
|
11
|
+
if (tag === 'div') {
|
|
12
|
+
return (0, jsx_runtime_1.jsx)(DivResizer_1.default, { ...resProps });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return (0, jsx_runtime_1.jsx)(SVGResizer_1.default, { ...resProps });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = Resizer;
|
|
@@ -0,0 +1,77 @@
|
|
|
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("@emotion/react/jsx-runtime");
|
|
7
|
+
/** @jsxImportSource @emotion/react */
|
|
8
|
+
const react_1 = require("@emotion/react");
|
|
9
|
+
const react_2 = require("react");
|
|
10
|
+
const useDraggable_1 = __importDefault(require("./useDraggable"));
|
|
11
|
+
const anchorStyle = {
|
|
12
|
+
width: '2px',
|
|
13
|
+
height: '100%',
|
|
14
|
+
pointerEvents: 'none',
|
|
15
|
+
fill: 'transparent',
|
|
16
|
+
};
|
|
17
|
+
const styles = {
|
|
18
|
+
container: (position) => (0, react_1.css) `
|
|
19
|
+
transform: translateX(${position}px);
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
rect:last-child {
|
|
23
|
+
fill: red !important;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`,
|
|
27
|
+
innerContainer: (0, react_1.css) `
|
|
28
|
+
position: absolute;
|
|
29
|
+
height: 100%;
|
|
30
|
+
fill: transparent;
|
|
31
|
+
width: 10px;
|
|
32
|
+
cursor: e-resize;
|
|
33
|
+
user-select: none;
|
|
34
|
+
z-index: 99999999;
|
|
35
|
+
`,
|
|
36
|
+
};
|
|
37
|
+
function SVGResizer(props) {
|
|
38
|
+
const { children, initialPosition = { x1: 10, x2: 40 }, onStart, onMove, onEnd, } = props;
|
|
39
|
+
const right = (0, useDraggable_1.default)({
|
|
40
|
+
x: initialPosition.x2,
|
|
41
|
+
anchor: 'RIGHT',
|
|
42
|
+
});
|
|
43
|
+
const left = (0, useDraggable_1.default)({
|
|
44
|
+
x: initialPosition.x1,
|
|
45
|
+
anchor: 'LEFT',
|
|
46
|
+
});
|
|
47
|
+
(0, react_2.useEffect)(() => {
|
|
48
|
+
const position = { x1: left.position.x, x2: right.position.x };
|
|
49
|
+
const status = left.isActive
|
|
50
|
+
? left.position.action
|
|
51
|
+
: right.isActive
|
|
52
|
+
? right.position.action
|
|
53
|
+
: '';
|
|
54
|
+
switch (status) {
|
|
55
|
+
case 'start':
|
|
56
|
+
onStart?.(position);
|
|
57
|
+
break;
|
|
58
|
+
case 'move':
|
|
59
|
+
onMove?.(position);
|
|
60
|
+
break;
|
|
61
|
+
case 'end':
|
|
62
|
+
onEnd?.(position);
|
|
63
|
+
break;
|
|
64
|
+
default:
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}, [left, onEnd, onMove, onStart, right]);
|
|
68
|
+
return ((0, jsx_runtime_1.jsxs)("g", { style: {
|
|
69
|
+
transform: `translateX(${left.position.x}px)`,
|
|
70
|
+
}, children: [typeof children === 'function'
|
|
71
|
+
? children(left.position.x, right.position.x)
|
|
72
|
+
: children, (0, jsx_runtime_1.jsx)(SVGResizerHandle, { onMouseDown: left.onMouseDown, position: 0 }), (0, jsx_runtime_1.jsx)(SVGResizerHandle, { onMouseDown: right.onMouseDown, position: right.position.x - left.position.x })] }));
|
|
73
|
+
}
|
|
74
|
+
exports.default = SVGResizer;
|
|
75
|
+
function SVGResizerHandle(props) {
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)("g", { onMouseDown: props.onMouseDown, css: styles.container(props.position), "data-no-export": "true", children: [(0, jsx_runtime_1.jsx)("rect", { x: "-5px", css: styles.innerContainer }), (0, jsx_runtime_1.jsx)("rect", { x: "-2.5px", style: anchorStyle })] }));
|
|
77
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const react_1 = require("react");
|
|
4
|
+
function useDraggable(props) {
|
|
5
|
+
const { x, anchor } = props;
|
|
6
|
+
const isActive = (0, react_1.useRef)(false);
|
|
7
|
+
const positionRef = (0, react_1.useRef)({
|
|
8
|
+
relativeX: x,
|
|
9
|
+
x,
|
|
10
|
+
});
|
|
11
|
+
const [position, setPosition] = (0, react_1.useState)({
|
|
12
|
+
x,
|
|
13
|
+
action: null,
|
|
14
|
+
});
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
positionRef.current = { relativeX: x, x };
|
|
17
|
+
setPosition({ x, action: null });
|
|
18
|
+
}, [x]);
|
|
19
|
+
const onMouseDown = (0, react_1.useCallback)((e) => {
|
|
20
|
+
setPosition({ x: positionRef.current.x, action: 'start' });
|
|
21
|
+
positionRef.current.relativeX = e.clientX - positionRef.current.relativeX;
|
|
22
|
+
isActive.current = true;
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
function onMouseUp(e) {
|
|
25
|
+
e.stopPropagation();
|
|
26
|
+
if (isActive.current) {
|
|
27
|
+
const x = e.clientX - positionRef.current.relativeX;
|
|
28
|
+
positionRef.current = { relativeX: x, x };
|
|
29
|
+
setPosition({ x, action: 'end' });
|
|
30
|
+
isActive.current = false;
|
|
31
|
+
}
|
|
32
|
+
window.removeEventListener('mousemove', onMouseMove);
|
|
33
|
+
window.removeEventListener('mouseup', onMouseUp);
|
|
34
|
+
}
|
|
35
|
+
function onMouseMove(e) {
|
|
36
|
+
e.stopPropagation();
|
|
37
|
+
if (isActive.current) {
|
|
38
|
+
setPosition({
|
|
39
|
+
x: e.clientX - positionRef.current.relativeX,
|
|
40
|
+
action: 'move',
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
window.addEventListener('mousemove', onMouseMove);
|
|
45
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
46
|
+
}, []);
|
|
47
|
+
return {
|
|
48
|
+
onMouseDown,
|
|
49
|
+
position,
|
|
50
|
+
previousPosition: positionRef.current.x,
|
|
51
|
+
isActive: isActive.current,
|
|
52
|
+
anchor,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.default = useDraggable;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const DispatchContext_1 = require("../context/DispatchContext");
|
|
9
|
+
const Button_1 = __importDefault(require("../elements/Button"));
|
|
9
10
|
const CheckBox_1 = __importDefault(require("../elements/CheckBox"));
|
|
10
11
|
const NumberInput_1 = __importDefault(require("../elements/NumberInput"));
|
|
11
12
|
const Types_1 = require("../reducer/types/Types");
|
|
@@ -14,6 +15,7 @@ const styles = {
|
|
|
14
15
|
height: '100%',
|
|
15
16
|
display: 'flex',
|
|
16
17
|
fontSize: '12px',
|
|
18
|
+
alignItems: 'center',
|
|
17
19
|
},
|
|
18
20
|
input: {
|
|
19
21
|
width: '50px',
|
|
@@ -24,14 +26,6 @@ const styles = {
|
|
|
24
26
|
label: {
|
|
25
27
|
flex: '5',
|
|
26
28
|
},
|
|
27
|
-
actionButton: {
|
|
28
|
-
height: '100%',
|
|
29
|
-
width: '60px',
|
|
30
|
-
borderRadius: '5px',
|
|
31
|
-
border: '0.55px solid #c7c7c7',
|
|
32
|
-
margin: '0px 5px',
|
|
33
|
-
userSelect: 'none',
|
|
34
|
-
},
|
|
35
29
|
};
|
|
36
30
|
function AutoPeakPickingOptionPanel() {
|
|
37
31
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
@@ -50,11 +44,6 @@ function AutoPeakPickingOptionPanel() {
|
|
|
50
44
|
},
|
|
51
45
|
});
|
|
52
46
|
}, [dispatch]);
|
|
53
|
-
const handleCancelFilter = (0, react_1.useCallback)(() => {
|
|
54
|
-
dispatch({
|
|
55
|
-
type: Types_1.RESET_SELECTED_TOOL,
|
|
56
|
-
});
|
|
57
|
-
}, [dispatch]);
|
|
58
47
|
return ((0, jsx_runtime_1.jsxs)("div", { style: styles.container, children: [(0, jsx_runtime_1.jsx)(NumberInput_1.default, { ref: maxNumberOfPeaksRef, label: "Max Number Of Peaks:", name: "maxNumberOfPeaks", style: {
|
|
59
48
|
input: styles.input,
|
|
60
49
|
inputContainer: styles.inputContainer,
|
|
@@ -67,6 +56,6 @@ function AutoPeakPickingOptionPanel() {
|
|
|
67
56
|
input: styles.input,
|
|
68
57
|
inputContainer: styles.inputContainer,
|
|
69
58
|
label: styles.label,
|
|
70
|
-
}, defaultValue: 0.1, step: "0.01" }), (0, jsx_runtime_1.jsxs)("div", { style: { justifyItems: 'baseline', marginRight: '3px' }, children: [(0, jsx_runtime_1.jsx)("label", { style: { marginRight: '2px', lineHeight: 2, userSelect: 'none' }, htmlFor: "lookNegative", children: "Detect Negative:" }), (0, jsx_runtime_1.jsx)(CheckBox_1.default, { name: "lookNegative", ref: lookNegativeRef })] }), (0, jsx_runtime_1.jsx)(
|
|
59
|
+
}, defaultValue: 0.1, step: "0.01" }), (0, jsx_runtime_1.jsxs)("div", { style: { justifyItems: 'baseline', marginRight: '3px' }, children: [(0, jsx_runtime_1.jsx)("label", { style: { marginRight: '2px', lineHeight: 2, userSelect: 'none' }, htmlFor: "lookNegative", children: "Detect Negative:" }), (0, jsx_runtime_1.jsx)(CheckBox_1.default, { name: "lookNegative", ref: lookNegativeRef })] }), (0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: handleApplyFilter, style: { margin: '0 10px' }, children: "Apply" })] }));
|
|
71
60
|
}
|
|
72
61
|
exports.default = AutoPeakPickingOptionPanel;
|