nmrium 0.31.0 → 0.32.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/FooterBanner.js +17 -10
- package/lib/component/2d/Contours.js +1 -1
- package/lib/component/2d/Left1DChart.js +1 -1
- package/lib/component/2d/Top1DChart.js +1 -1
- package/lib/component/EventsTrackers/BrushTracker.js +30 -21
- package/lib/component/SplitPaneWrapper.js +1 -1
- package/lib/component/elements/EditableColumn.d.ts +3 -1
- package/lib/component/elements/EditableColumn.js +18 -3
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
- package/lib/component/loader/DropZone.js +9 -1
- package/lib/component/modal/setting/GeneralTabContent.js +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
- package/lib/component/reducer/Reducer.d.ts +2 -47
- package/lib/component/reducer/Reducer.js +2 -2
- package/lib/component/reducer/actions/DomainActions.js +3 -2
- package/lib/component/reducer/actions/FiltersActions.js +12 -3
- package/lib/component/reducer/actions/IntegralsActions.js +6 -5
- package/lib/component/reducer/actions/PeaksActions.js +7 -6
- package/lib/component/reducer/actions/PreferencesActions.js +2 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +1 -1
- package/lib/component/reducer/actions/RangesActions.js +14 -12
- package/lib/component/reducer/actions/SpectrumsActions.js +3 -2
- package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
- package/lib/component/reducer/actions/ToolsActions.js +9 -7
- package/lib/component/reducer/actions/ZonesActions.js +9 -8
- package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
- package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
- package/lib/component/toolbar/BasicToolBar.js +8 -7
- package/lib/component/utility/Export.js +7 -1
- package/lib/component/workspaces/Workspace.d.ts +1 -1
- package/lib/component/workspaces/exercise.js +4 -4
- package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
- package/lib/data/Filters.d.ts +1 -2
- package/lib/data/Filters.js +1 -2
- package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
- package/lib/data/data2d/Processing2D.js +3 -2
- package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
- package/lib/data/utilities/calculateSanPlot.js +31 -0
- package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/FooterBanner.js +16 -9
- package/lib-cjs/component/2d/Contours.js +1 -1
- package/lib-cjs/component/2d/Left1DChart.js +1 -1
- package/lib-cjs/component/2d/Top1DChart.js +1 -1
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
- package/lib-cjs/component/SplitPaneWrapper.js +1 -1
- package/lib-cjs/component/elements/EditableColumn.js +18 -3
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
- package/lib-cjs/component/loader/DropZone.js +9 -1
- package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
- package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
- package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
- package/lib-cjs/component/reducer/Reducer.js +2 -2
- package/lib-cjs/component/reducer/actions/DomainActions.js +3 -2
- package/lib-cjs/component/reducer/actions/FiltersActions.js +12 -3
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +6 -5
- package/lib-cjs/component/reducer/actions/PeaksActions.js +7 -6
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +2 -1
- package/lib-cjs/component/reducer/actions/RangesActions.js +14 -12
- package/lib-cjs/component/reducer/actions/SpectrumsActions.js +3 -2
- package/lib-cjs/component/reducer/actions/ToolsActions.js +9 -7
- package/lib-cjs/component/reducer/actions/ZonesActions.js +9 -8
- package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
- package/lib-cjs/component/toolbar/BasicToolBar.js +7 -6
- package/lib-cjs/component/utility/Export.js +7 -1
- package/lib-cjs/component/workspaces/exercise.js +4 -4
- package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
- package/lib-cjs/data/Filters.js +1 -3
- package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
- package/lib-cjs/data/data2d/Processing2D.js +3 -2
- package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +18 -17
- package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
- package/lib/data/data1d/filter1d/absolute.js +0 -26
- package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
5
|
-
import { useContext,
|
|
5
|
+
import { useContext, Fragment, memo } from 'react';
|
|
6
6
|
import { BsCursor } from 'react-icons/bs';
|
|
7
7
|
import { IoPulseSharp } from 'react-icons/io5';
|
|
8
8
|
import { get1DDataXY } from '../../data/data1d/Spectrum1D/get1DDataXY';
|
|
@@ -67,14 +67,6 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
|
|
|
67
67
|
const { startX, endX, step } = useContext(BrushContext);
|
|
68
68
|
const { scaleX } = useScaleChecked();
|
|
69
69
|
const format = useFormatNumberByNucleus(activeTab);
|
|
70
|
-
const getYValue = useCallback((xPosition) => {
|
|
71
|
-
if (spectrum) {
|
|
72
|
-
const data = get1DDataXY(spectrum);
|
|
73
|
-
const xIndex = xFindClosestIndex(data.x, scaleX().invert(xPosition));
|
|
74
|
-
return data.y[xIndex];
|
|
75
|
-
}
|
|
76
|
-
return 1;
|
|
77
|
-
}, [spectrum, scaleX]);
|
|
78
70
|
if (!position ||
|
|
79
71
|
position.y < margin.top ||
|
|
80
72
|
position.x < margin.left ||
|
|
@@ -82,7 +74,22 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
|
|
|
82
74
|
position.y > height - margin.bottom) {
|
|
83
75
|
return _jsx("div", { css: styles });
|
|
84
76
|
}
|
|
85
|
-
|
|
77
|
+
function getXIndex(xPosition) {
|
|
78
|
+
if (spectrum) {
|
|
79
|
+
const data = get1DDataXY(spectrum);
|
|
80
|
+
return xFindClosestIndex(data.x, scaleX().invert(xPosition));
|
|
81
|
+
}
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
function getYValue(xPosition) {
|
|
85
|
+
if (spectrum) {
|
|
86
|
+
const data = get1DDataXY(spectrum);
|
|
87
|
+
const xIndex = getXIndex(xPosition);
|
|
88
|
+
return data.y[xIndex];
|
|
89
|
+
}
|
|
90
|
+
return 1;
|
|
91
|
+
}
|
|
92
|
+
return (_jsxs("div", { css: styles, children: [_jsx(BsCursor, {}), _jsxs("div", { children: [_jsx("span", { className: "label", children: " \uD835\uDEC5: " }), _jsx("span", { className: "value", children: format(scaleX().invert(position.x)) }), _jsx("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && (_jsxs(_Fragment, { children: [_jsxs("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), _jsx("span", { className: "unit", children: "Hz" }), _jsx("span", { className: "value", children: ") " }), _jsx("span", { children: "," }), _jsx("span", { className: "label", children: " Index: " }), _jsx("span", { className: "value", children: getXIndex(position.x) })] }))] }), step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " \u0394ppm: " }), _jsx("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && (_jsxs(Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " \u0394Hz: " }), _jsx("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
|
|
86
93
|
spectrum?.info?.originFrequency).toPrecision(5) })] })), step === 'brushing' && (_jsxs("div", { children: [_jsx("span", { className: "label", children: " ratio :" }), _jsxs("span", { className: "value", children: [((getYValue(startX) / (getYValue(endX) || Number.MIN_VALUE)) *
|
|
87
94
|
100).toFixed(2), "%"] })] }))] })), activeSpectrum && (_jsxs(Fragment, { children: [_jsx("div", { className: "separator" }), _jsx(IoPulseSharp, {}), _jsxs("div", { children: [_jsx("span", { className: "label", children: "Intensity: " }), _jsx("span", { className: "value yvalue", children: format(getYValue(position.x)) })] })] }))] }));
|
|
88
95
|
}
|
|
@@ -48,7 +48,7 @@ function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
|
|
|
48
48
|
return (_jsx("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", style: {
|
|
49
49
|
opacity: isActive
|
|
50
50
|
? 1
|
|
51
|
-
: get(preferences.current, 'general.
|
|
51
|
+
: get(preferences.current, 'general.dimmedSpectraOpacity', 0.1),
|
|
52
52
|
}, d: path }));
|
|
53
53
|
}
|
|
54
54
|
function ContoursInner({ data, displayerKey }) {
|
|
@@ -41,6 +41,6 @@ function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
|
|
|
41
41
|
const mainHeight = originHeight - margin.bottom - margin.top;
|
|
42
42
|
if (!mainHeight || !height)
|
|
43
43
|
return null;
|
|
44
|
-
return (_jsxs("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-left`, children: _jsx("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-left)`, children: _jsx("path", { className: "line", stroke:
|
|
44
|
+
return (_jsxs("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-left`, children: _jsx("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-left)`, children: _jsx("path", { className: "line", stroke: spectrum.display.color, fill: "none", d: paths }) })] }));
|
|
45
45
|
}
|
|
46
46
|
export default memo(Left1DChart);
|
|
@@ -37,6 +37,6 @@ function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
|
|
|
37
37
|
if (!width || !height) {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-top`, children: _jsx("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-top)`, children: _jsx("path", { className: "line", stroke:
|
|
40
|
+
return (_jsxs("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-top`, children: _jsx("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), _jsx("g", { clipPath: `url(#${displayerKey}clip-top)`, children: _jsx("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: paths }) })] }));
|
|
41
41
|
}
|
|
42
42
|
export default memo(Top1DChart);
|
|
@@ -13,6 +13,9 @@ const initialState = {
|
|
|
13
13
|
startY: 0,
|
|
14
14
|
endY: 0,
|
|
15
15
|
};
|
|
16
|
+
function stopPageScrolling(event) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
}
|
|
16
19
|
export const BrushContext = createContext(initialState);
|
|
17
20
|
export function BrushTracker({ children, className, style, onBrush = () => null, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
|
|
18
21
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
@@ -35,6 +38,24 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
|
|
|
35
38
|
});
|
|
36
39
|
setMouseDownTime(event.timeStamp);
|
|
37
40
|
}
|
|
41
|
+
function moveCallback(event) {
|
|
42
|
+
dispatch({
|
|
43
|
+
type: 'MOVE',
|
|
44
|
+
screenX: event.screenX,
|
|
45
|
+
screenY: event.screenY,
|
|
46
|
+
clientX: event.clientX,
|
|
47
|
+
clientY: event.clientY,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function mouseUpCallback() {
|
|
51
|
+
dispatch({
|
|
52
|
+
type: 'UP',
|
|
53
|
+
});
|
|
54
|
+
window.removeEventListener('mousemove', moveCallback);
|
|
55
|
+
window.removeEventListener('mouseup', mouseUpCallback);
|
|
56
|
+
}
|
|
57
|
+
window.addEventListener('mousemove', moveCallback);
|
|
58
|
+
window.addEventListener('mouseup', mouseUpCallback);
|
|
38
59
|
return false;
|
|
39
60
|
}, [noPropagation]);
|
|
40
61
|
const clickHandler = useCallback((e) => {
|
|
@@ -74,34 +95,22 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
|
|
|
74
95
|
});
|
|
75
96
|
}
|
|
76
97
|
}, [onBrush, state]);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const upCallback = useCallback((event) => {
|
|
87
|
-
dispatch({
|
|
88
|
-
type: 'UP',
|
|
89
|
-
clientX: event.clientX,
|
|
90
|
-
clientY: event.clientY,
|
|
91
|
-
});
|
|
92
|
-
return false;
|
|
93
|
-
}, []);
|
|
94
|
-
return (_jsx(BrushContext.Provider, { value: state, children: _jsx("div", { className: className, style: style, onMouseDown: mouseDownHandler, onMouseUp: upCallback, onMouseMove: moveCallback, onClick: clickHandler, onWheel: handleMouseWheel, children: children }) }));
|
|
98
|
+
return (_jsx(BrushContext.Provider, { value: state, children: _jsx("div", { className: className, style: style, onMouseDown: mouseDownHandler, onClick: clickHandler, onWheel: handleMouseWheel, onMouseEnter: () => {
|
|
99
|
+
// disable page scrolling once the mouse over the Displayer
|
|
100
|
+
window.addEventListener('wheel', stopPageScrolling, {
|
|
101
|
+
passive: false,
|
|
102
|
+
});
|
|
103
|
+
}, onMouseLeave: () => {
|
|
104
|
+
// disable page scrolling once the mouse over the Displayer
|
|
105
|
+
window.removeEventListener('wheel', stopPageScrolling);
|
|
106
|
+
}, children: children }) }));
|
|
95
107
|
}
|
|
96
108
|
function reducer(state, action) {
|
|
97
109
|
switch (action.type) {
|
|
98
110
|
case 'UP':
|
|
99
111
|
if (state.step === 'brushing' || state.step === 'start') {
|
|
100
|
-
const { clientX, clientY } = action;
|
|
101
112
|
return {
|
|
102
113
|
...state,
|
|
103
|
-
endX: clientX - state.boundingRect.x,
|
|
104
|
-
endY: clientY - state.boundingRect.y,
|
|
105
114
|
step: state.step === 'start' ? 'initial' : 'end',
|
|
106
115
|
};
|
|
107
116
|
}
|
|
@@ -4,5 +4,5 @@ import { usePreferences } from './context/PreferencesContext';
|
|
|
4
4
|
export function SplitPaneWrapper({ children }) {
|
|
5
5
|
const { current } = usePreferences();
|
|
6
6
|
const { hidePanelOnLoad = false, initialPanelWidth = '560px' } = current?.display?.general || {};
|
|
7
|
-
return (_jsx(SplitPane, {
|
|
7
|
+
return (_jsx(SplitPane, { initialSize: initialPanelWidth, direction: "horizontal", controlledSide: "end", initialClosed: hidePanelOnLoad ? true : 600, children: children }, hidePanelOnLoad ? 'true' : 'false'));
|
|
8
8
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
|
|
2
|
+
import { InputProps } from './Input';
|
|
3
|
+
interface EditableColumnProps extends Omit<InputProps, 'style' | 'value' | 'type'> {
|
|
3
4
|
onSave?: (element: any) => void;
|
|
4
5
|
onEditStart?: (element: any) => void;
|
|
5
6
|
type?: 'number' | 'text';
|
|
@@ -7,6 +8,7 @@ interface EditableColumnProps {
|
|
|
7
8
|
value: string | number;
|
|
8
9
|
style?: CSSProperties;
|
|
9
10
|
validate?: (value?: any) => boolean;
|
|
11
|
+
textOverFlowEllipses?: boolean;
|
|
10
12
|
}
|
|
11
13
|
declare const EditableColumn: import("react").ForwardRefExoticComponent<EditableColumnProps & import("react").RefAttributes<unknown>>;
|
|
12
14
|
export default EditableColumn;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState, } from 'react';
|
|
3
3
|
import Input from './Input';
|
|
4
4
|
const EditableColumn = forwardRef(function EditableColumn(props, ref) {
|
|
5
|
-
const { onSave = () => null, value, type = 'text', style, onEditStart = () => null, editStatus = false, validate = () => true, } = props;
|
|
5
|
+
const { onSave = () => null, value, type = 'text', style, onEditStart = () => null, editStatus = false, validate = () => true, textOverFlowEllipses = false, ...InputProps } = props;
|
|
6
6
|
const [enabled, enableEdit] = useState();
|
|
7
7
|
const [isValid, setValid] = useState(true);
|
|
8
8
|
useEffect(() => {
|
|
@@ -43,11 +43,26 @@ const EditableColumn = forwardRef(function EditableColumn(props, ref) {
|
|
|
43
43
|
window.removeEventListener('mousedown', mouseClickCallback);
|
|
44
44
|
}
|
|
45
45
|
}, [mouseClickCallback, onSave, validate]);
|
|
46
|
-
return (_jsxs("div", { style: {
|
|
46
|
+
return (_jsxs("div", { style: {
|
|
47
|
+
display: 'table',
|
|
48
|
+
width: '100%',
|
|
49
|
+
height: '100%',
|
|
50
|
+
...(textOverFlowEllipses
|
|
51
|
+
? { whiteSpace: 'nowrap', overflow: 'hidden', display: 'inline-flex' }
|
|
52
|
+
: {}),
|
|
53
|
+
...style,
|
|
54
|
+
}, className: "editable-column-input", onDoubleClick: startEditHandler, children: [!enabled && (_jsx("span", { style: {
|
|
55
|
+
display: 'table-cell',
|
|
56
|
+
verticalAlign: 'middle',
|
|
57
|
+
width: 'inherit',
|
|
58
|
+
...(textOverFlowEllipses
|
|
59
|
+
? { textOverflow: 'ellipsis', overflow: 'hidden' }
|
|
60
|
+
: {}),
|
|
61
|
+
}, children: value })), enabled && (_jsx("div", { style: { display: 'table-cell', verticalAlign: 'middle' }, children: _jsx(Input, { style: {
|
|
47
62
|
inputWrapper: {
|
|
48
63
|
width: '100%',
|
|
49
64
|
...(!isValid && { borderColor: 'red' }),
|
|
50
65
|
},
|
|
51
|
-
}, enableAutoSelect: true, className: "editable-column", value: value, type: type, onKeyUp: editHandler }) }))] }));
|
|
66
|
+
}, enableAutoSelect: true, className: "editable-column", value: value, type: type, onKeyUp: editHandler, ...InputProps }) }))] }));
|
|
52
67
|
});
|
|
53
68
|
export default EditableColumn;
|
|
@@ -9,7 +9,7 @@ export default function useActiveSpectrumStyleOptions(id) {
|
|
|
9
9
|
const isActive = activeSpectrum === null ? true : id === activeSpectrum.id;
|
|
10
10
|
const opacity = isActive
|
|
11
11
|
? 1
|
|
12
|
-
: get(preferences.current, 'general.
|
|
12
|
+
: get(preferences.current, 'general.dimmedSpectraOpacity', 0.1);
|
|
13
13
|
return { isActive, opacity };
|
|
14
14
|
}, [activeSpectrum, id, preferences]);
|
|
15
15
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
+
import { fileCollectionFromFileList } from 'filelist-utils';
|
|
4
5
|
import { useCallback } from 'react';
|
|
5
6
|
import { useDropzone } from 'react-dropzone';
|
|
6
7
|
import { FaUpload } from 'react-icons/fa';
|
|
@@ -48,7 +49,14 @@ function DropZone(props) {
|
|
|
48
49
|
files.forEach((file) => {
|
|
49
50
|
Object.defineProperty(file, 'webkitRelativePath', { value: file.path });
|
|
50
51
|
});
|
|
51
|
-
|
|
52
|
+
fileCollectionFromFileList(files)
|
|
53
|
+
.then((fileCollection) => {
|
|
54
|
+
dispatch({ type: LOAD_DROP_FILES, fileCollection });
|
|
55
|
+
})
|
|
56
|
+
.catch((e) => {
|
|
57
|
+
dispatch({ type: SET_LOADING_FLAG, isLoading: false });
|
|
58
|
+
reportError(e);
|
|
59
|
+
});
|
|
52
60
|
}, [dispatch]);
|
|
53
61
|
const onDrop = useCallback((droppedFiles) => {
|
|
54
62
|
dispatch({ type: SET_LOADING_FLAG, isLoading: true });
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import Label from '../../elements/Label';
|
|
3
3
|
import FormikInput from '../../elements/formik/FormikInput';
|
|
4
4
|
function GeneralTabContent() {
|
|
5
|
-
return (_jsxs(_Fragment, { children: [_jsx("p", { className: "section-header", children: "Spectra" }), _jsx(Label, { title: "
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsx("p", { className: "section-header", children: "Spectra" }), _jsx(Label, { title: "Opacity of dimmed spectra [ 0 - 1 ]", children: _jsx(FormikInput, { name: "general.dimmedSpectraOpacity", checkValue: (value) => value >= 0 && value <= 1, type: "number" }) })] }));
|
|
6
6
|
}
|
|
7
7
|
export default GeneralTabContent;
|
|
@@ -34,5 +34,5 @@ export default function MoleculeHeader(props) {
|
|
|
34
34
|
const label = event.target.value;
|
|
35
35
|
dispatch({ type: CHANGE_MOLECULE_LABEL, payload: { label, id } });
|
|
36
36
|
}, [dispatch]);
|
|
37
|
-
return (_jsxs("div", { style: styles.toolbar, children: [_jsxs("div", { style: { display: 'flex' }, children: [_jsx("span", { children: "Label" }), _jsx(EditableColumn, { value: currentMolecule.label, style: styles.labelInput, validate: validateLabel, onSave: (event) => saveLabelHandler(currentMolecule.id, event) })] }), _jsxs("span", { children: [_jsx(MF, { mf: currentMolecule.mf }), " - ", currentMolecule.mw?.toFixed(2)] })] }));
|
|
37
|
+
return (_jsxs("div", { style: styles.toolbar, children: [_jsxs("div", { style: { display: 'flex' }, children: [_jsx("span", { children: "Label" }), _jsx(EditableColumn, { value: currentMolecule.label, style: styles.labelInput, validate: validateLabel, onSave: (event) => saveLabelHandler(currentMolecule.id, event), textOverFlowEllipses: true })] }), _jsxs("span", { children: [_jsx(MF, { mf: currentMolecule.mf }), " - ", currentMolecule.mw?.toFixed(2)] })] }));
|
|
38
38
|
}
|
|
@@ -36,7 +36,7 @@ function PeaksTable({ activeTab, data }) {
|
|
|
36
36
|
});
|
|
37
37
|
}, [modal, peaksPreferences]);
|
|
38
38
|
const saveDeltaPPMRefsHandler = useCallback((event, row) => {
|
|
39
|
-
const shiftValue = parseFloat(event.target.value) - parseFloat(row.
|
|
39
|
+
const shiftValue = parseFloat(event.target.value) - parseFloat(row.x);
|
|
40
40
|
dispatch({ type: SHIFT_SPECTRUM, shiftValue });
|
|
41
41
|
}, [dispatch]);
|
|
42
42
|
const COLUMNS = useMemo(() => [
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { xyReduce } from 'ml-spectra-processing';
|
|
2
|
+
import { calculateSanPlot } from '../../../../../data/utilities/calculateSanPlot';
|
|
2
3
|
export function processSnapPlot(dimension, data, yLogBase) {
|
|
3
|
-
const
|
|
4
|
-
? prepare1DData(data)
|
|
5
|
-
: prepare2DData(data);
|
|
6
|
-
const sanResult = xNoiseSanPlot(input);
|
|
4
|
+
const sanResult = calculateSanPlot(dimension, data);
|
|
7
5
|
const sanPlot = {};
|
|
8
6
|
const lines = {};
|
|
9
7
|
for (let plotKey in sanResult.sanplot) {
|
|
@@ -17,27 +15,6 @@ export function processSnapPlot(dimension, data, yLogBase) {
|
|
|
17
15
|
}
|
|
18
16
|
return { sanPlot, lines };
|
|
19
17
|
}
|
|
20
|
-
function prepare1DData(data) {
|
|
21
|
-
const length = data.re.length;
|
|
22
|
-
const jump = Math.floor(length / 307200) || 1;
|
|
23
|
-
const array = new Float64Array((length / jump) >> 0);
|
|
24
|
-
let index = 0;
|
|
25
|
-
for (let i = 0; i < array.length; i += jump) {
|
|
26
|
-
array[index++] = data.re[i];
|
|
27
|
-
}
|
|
28
|
-
return array;
|
|
29
|
-
}
|
|
30
|
-
function prepare2DData(data) {
|
|
31
|
-
let cols = data.z[0].length;
|
|
32
|
-
let rows = data.z.length;
|
|
33
|
-
let jump = Math.floor((cols * rows) / 204800) || 1;
|
|
34
|
-
const array = new Float64Array(((cols * rows) / jump) >> 0);
|
|
35
|
-
let index = 0;
|
|
36
|
-
for (let i = 0; i < array.length; i += jump) {
|
|
37
|
-
array[index++] = data.z[(i / rows) >> 0][i % rows];
|
|
38
|
-
}
|
|
39
|
-
return array;
|
|
40
|
-
}
|
|
41
18
|
function getLine(value, data, options) {
|
|
42
19
|
const { log10, abs } = Math;
|
|
43
20
|
const { yLogBase } = options;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { CorrelationData } from 'nmr-correlation';
|
|
3
2
|
import { SpectraAnalysis } from '../../data/data1d/MultipleAnalysis';
|
|
4
3
|
import { ApodizationOptions } from '../../data/data1d/filter1d/apodization';
|
|
@@ -309,29 +308,7 @@ export declare const spectrumReducer: (base: {
|
|
|
309
308
|
readonly source: {
|
|
310
309
|
readonly jcampURL: string;
|
|
311
310
|
readonly jcampSpectrumIndex: number;
|
|
312
|
-
readonly file:
|
|
313
|
-
readonly lastModified: number;
|
|
314
|
-
readonly name: string;
|
|
315
|
-
readonly webkitRelativePath: string;
|
|
316
|
-
readonly size: number;
|
|
317
|
-
readonly type: string;
|
|
318
|
-
readonly arrayBuffer: {
|
|
319
|
-
(): Promise<ArrayBuffer>;
|
|
320
|
-
(): Promise<ArrayBuffer>;
|
|
321
|
-
};
|
|
322
|
-
readonly slice: {
|
|
323
|
-
(start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
|
|
324
|
-
(start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
|
|
325
|
-
};
|
|
326
|
-
readonly stream: {
|
|
327
|
-
(): ReadableStream<Uint8Array>;
|
|
328
|
-
(): NodeJS.ReadableStream;
|
|
329
|
-
};
|
|
330
|
-
readonly text: {
|
|
331
|
-
(): Promise<string>;
|
|
332
|
-
(): Promise<string>;
|
|
333
|
-
};
|
|
334
|
-
};
|
|
311
|
+
readonly file: File;
|
|
335
312
|
};
|
|
336
313
|
readonly display: {
|
|
337
314
|
readonly name: string;
|
|
@@ -809,29 +786,7 @@ export declare const spectrumReducer: (base: {
|
|
|
809
786
|
readonly source: {
|
|
810
787
|
readonly jcampURL: string;
|
|
811
788
|
readonly jcampSpectrumIndex: number;
|
|
812
|
-
readonly file:
|
|
813
|
-
readonly lastModified: number;
|
|
814
|
-
readonly name: string;
|
|
815
|
-
readonly webkitRelativePath: string;
|
|
816
|
-
readonly size: number;
|
|
817
|
-
readonly type: string;
|
|
818
|
-
readonly arrayBuffer: {
|
|
819
|
-
(): Promise<ArrayBuffer>;
|
|
820
|
-
(): Promise<ArrayBuffer>;
|
|
821
|
-
};
|
|
822
|
-
readonly slice: {
|
|
823
|
-
(start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
|
|
824
|
-
(start?: number | undefined, end?: number | undefined, contentType?: string | undefined): Blob;
|
|
825
|
-
};
|
|
826
|
-
readonly stream: {
|
|
827
|
-
(): ReadableStream<Uint8Array>;
|
|
828
|
-
(): NodeJS.ReadableStream;
|
|
829
|
-
};
|
|
830
|
-
readonly text: {
|
|
831
|
-
(): Promise<string>;
|
|
832
|
-
(): Promise<string>;
|
|
833
|
-
};
|
|
834
|
-
};
|
|
789
|
+
readonly file: File;
|
|
835
790
|
};
|
|
836
791
|
readonly display: {
|
|
837
792
|
readonly name: string;
|
|
@@ -145,9 +145,9 @@ export function dispatchMiddleware(dispatch) {
|
|
|
145
145
|
break;
|
|
146
146
|
}
|
|
147
147
|
case types.LOAD_DROP_FILES: {
|
|
148
|
-
const {
|
|
148
|
+
const { fileCollection } = action;
|
|
149
149
|
action.usedColors = usedColors;
|
|
150
|
-
readDropFiles(
|
|
150
|
+
readDropFiles(fileCollection, usedColors)
|
|
151
151
|
.then((data) => {
|
|
152
152
|
action.data = data;
|
|
153
153
|
dispatch(action);
|
|
@@ -3,12 +3,13 @@ import { get1DDataXY } from '../../../data/data1d/Spectrum1D/get1DDataXY';
|
|
|
3
3
|
import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
|
|
4
4
|
import nucleusToString from '../../utility/nucleusToString';
|
|
5
5
|
import { DISPLAYER_MODE } from '../core/Constants';
|
|
6
|
+
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
6
7
|
function getActiveData(draft) {
|
|
7
8
|
let data = draft.data.filter((datum) => nucleusToString(datum.info.nucleus) === draft.view.spectra.activeTab &&
|
|
8
9
|
datum.info.dimension === 1);
|
|
9
10
|
// todo: refactor this
|
|
10
|
-
const activeSpectrum = draft
|
|
11
|
-
if (activeSpectrum) {
|
|
11
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
12
|
+
if (activeSpectrum?.id) {
|
|
12
13
|
const activeSpectrumIndex = data.findIndex((datum) => datum.id === activeSpectrum?.id);
|
|
13
14
|
if (activeSpectrumIndex !== -1) {
|
|
14
15
|
const isFid = data[activeSpectrumIndex].info.isFid || false;
|
|
@@ -102,7 +102,10 @@ function applyManualPhaseCorrectionFilter(draft, filterOptions) {
|
|
|
102
102
|
const { index } = activeSpectrum;
|
|
103
103
|
const { ph0, ph1 } = filterOptions;
|
|
104
104
|
FiltersManager.applyFilter(draft.data[index], [
|
|
105
|
-
{
|
|
105
|
+
{
|
|
106
|
+
name: Filters.phaseCorrection.id,
|
|
107
|
+
options: { ph0, ph1, absolute: false },
|
|
108
|
+
},
|
|
106
109
|
]);
|
|
107
110
|
resetSelectedTool(draft);
|
|
108
111
|
draft.tempData = null;
|
|
@@ -112,7 +115,10 @@ function applyAbsoluteFilter(draft) {
|
|
|
112
115
|
const activeSpectrum = getActiveSpectrumOrFail(draft);
|
|
113
116
|
const { index } = activeSpectrum;
|
|
114
117
|
FiltersManager.applyFilter(draft.data[index], [
|
|
115
|
-
{
|
|
118
|
+
{
|
|
119
|
+
name: Filters.phaseCorrection.id,
|
|
120
|
+
options: { absolute: true, ph0: 0, ph1: 0 },
|
|
121
|
+
},
|
|
116
122
|
]);
|
|
117
123
|
resetSelectedTool(draft);
|
|
118
124
|
draft.tempData = null;
|
|
@@ -123,7 +129,10 @@ function applyAutoPhaseCorrectionFilter(draft) {
|
|
|
123
129
|
const { index } = activeSpectrum;
|
|
124
130
|
const { ph0, ph1 } = autoPhaseCorrection(draft.data[index]);
|
|
125
131
|
FiltersManager.applyFilter(draft.data[index], [
|
|
126
|
-
{
|
|
132
|
+
{
|
|
133
|
+
name: Filters.phaseCorrection.id,
|
|
134
|
+
options: { ph0, ph1, absolute: false },
|
|
135
|
+
},
|
|
127
136
|
]);
|
|
128
137
|
resetSelectedTool(draft);
|
|
129
138
|
draft.tempData = null;
|
|
@@ -3,11 +3,12 @@ import { original } from 'immer';
|
|
|
3
3
|
import { xyIntegration } from 'ml-spectra-processing';
|
|
4
4
|
import { updateIntegralsRelativeValues, changeIntegralsRelative, getShiftX, } from '../../../data/data1d/Spectrum1D';
|
|
5
5
|
import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
|
|
6
|
+
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
6
7
|
import getRange from '../helper/getRange';
|
|
7
8
|
import { setIntegralsYDomain } from './DomainActions';
|
|
8
9
|
function handleChangeIntegralSum(draft, options) {
|
|
9
10
|
const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
|
|
10
|
-
const activeSpectrum = draft
|
|
11
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
11
12
|
if (activeSpectrum?.id) {
|
|
12
13
|
const { index } = activeSpectrum;
|
|
13
14
|
const datum = data[index];
|
|
@@ -18,7 +19,7 @@ function handleChangeIntegralSum(draft, options) {
|
|
|
18
19
|
function addIntegral(draft, action) {
|
|
19
20
|
const { startX, endX } = action;
|
|
20
21
|
const { data, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
|
|
21
|
-
const activeSpectrum = draft
|
|
22
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
22
23
|
const [from, to] = getRange(draft, { startX, endX });
|
|
23
24
|
if (activeSpectrum?.id) {
|
|
24
25
|
const datum = data[activeSpectrum.index];
|
|
@@ -43,7 +44,7 @@ function addIntegral(draft, action) {
|
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
function deleteIntegral(draft, action) {
|
|
46
|
-
const activeSpectrum = draft
|
|
47
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
47
48
|
if (activeSpectrum) {
|
|
48
49
|
const state = original(draft);
|
|
49
50
|
const { index } = activeSpectrum;
|
|
@@ -60,7 +61,7 @@ function deleteIntegral(draft, action) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
function changeIntegral(draft, action) {
|
|
63
|
-
const activeSpectrum = draft
|
|
64
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
64
65
|
const state = original(draft);
|
|
65
66
|
const integral = action.payload.data;
|
|
66
67
|
if (activeSpectrum?.id) {
|
|
@@ -81,7 +82,7 @@ function changeIntegral(draft, action) {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
function handleChangeIntegralsRelativeValue(draft, action) {
|
|
84
|
-
const activeSpectrum = draft
|
|
85
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
85
86
|
const data = action.payload.data;
|
|
86
87
|
if (activeSpectrum?.id) {
|
|
87
88
|
const { index } = activeSpectrum;
|
|
@@ -3,9 +3,10 @@ import { original } from 'immer';
|
|
|
3
3
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
4
4
|
import { getShiftX, lookupPeak, autoPeakPicking, optimizePeaks, } from '../../../data/data1d/Spectrum1D';
|
|
5
5
|
import { options } from '../../toolbar/ToolTypes';
|
|
6
|
+
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
6
7
|
import getRange from '../helper/getRange';
|
|
7
8
|
function addPeak(draft, mouseCoordinates) {
|
|
8
|
-
const activeSpectrum = draft
|
|
9
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
9
10
|
const state = original(draft);
|
|
10
11
|
if (activeSpectrum?.id && state) {
|
|
11
12
|
const { index } = activeSpectrum;
|
|
@@ -32,7 +33,7 @@ function addPeak(draft, mouseCoordinates) {
|
|
|
32
33
|
}
|
|
33
34
|
function addPeaks(draft, action) {
|
|
34
35
|
const state = original(draft);
|
|
35
|
-
const activeSpectrum = draft
|
|
36
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
36
37
|
if (activeSpectrum) {
|
|
37
38
|
const { index } = activeSpectrum;
|
|
38
39
|
const datumOriginal = state.data[index];
|
|
@@ -55,7 +56,7 @@ function addPeaks(draft, action) {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
function deletePeak(draft, peakData) {
|
|
58
|
-
const activeSpectrum = draft
|
|
59
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
59
60
|
if (activeSpectrum) {
|
|
60
61
|
const { index } = activeSpectrum;
|
|
61
62
|
const state = original(draft);
|
|
@@ -70,7 +71,7 @@ function deletePeak(draft, peakData) {
|
|
|
70
71
|
}
|
|
71
72
|
function handleOptimizePeaks(draft, action) {
|
|
72
73
|
const { peaks } = action.payload;
|
|
73
|
-
const activeSpectrum = draft
|
|
74
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
74
75
|
if (activeSpectrum?.id) {
|
|
75
76
|
const { index } = activeSpectrum;
|
|
76
77
|
const datum = draft.data[index];
|
|
@@ -84,7 +85,7 @@ function handleOptimizePeaks(draft, action) {
|
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
function handleAutoPeakPicking(draft, autOptions) {
|
|
87
|
-
const activeSpectrum = draft
|
|
88
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
88
89
|
if (activeSpectrum?.id) {
|
|
89
90
|
draft.toolOptions.selectedTool = options.zoom.id;
|
|
90
91
|
draft.toolOptions.selectedOptionPanel = null;
|
|
@@ -103,7 +104,7 @@ function handleAutoPeakPicking(draft, autOptions) {
|
|
|
103
104
|
}
|
|
104
105
|
function changePeakShapeHandler(draft, action) {
|
|
105
106
|
const { shape, id } = action.payload;
|
|
106
|
-
const activeSpectrum = draft
|
|
107
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
107
108
|
if (activeSpectrum?.id) {
|
|
108
109
|
const { index } = activeSpectrum;
|
|
109
110
|
const datum = draft.data[index];
|
|
@@ -2,6 +2,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
2
2
|
import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
3
3
|
import nucleusToString from '../../utility/nucleusToString';
|
|
4
4
|
import { DEFAULT_YAXIS_SHIFT_VALUE, DISPLAYER_MODE } from '../core/Constants';
|
|
5
|
+
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
5
6
|
import { setDomain } from './DomainActions';
|
|
6
7
|
function changeSpectrumVerticalAlignment(draft, options) {
|
|
7
8
|
function stack(spectra = []) {
|
|
@@ -54,7 +55,7 @@ function changeSpectrumVerticalAlignment(draft, options) {
|
|
|
54
55
|
}
|
|
55
56
|
function setKeyPreferencesHandler(draft, keyCode) {
|
|
56
57
|
const { data, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, view, } = draft;
|
|
57
|
-
const activeSpectrum = draft
|
|
58
|
+
const activeSpectrum = getActiveSpectrum(draft);
|
|
58
59
|
if (view.spectra.activeTab) {
|
|
59
60
|
const groupByNucleus = groupByInfoKey('nucleus');
|
|
60
61
|
const spectrumsGroupsList = groupByNucleus(data);
|
|
@@ -13,7 +13,7 @@ declare function handleChangeRangeSum(draft: Draft<State>, options: any): void;
|
|
|
13
13
|
declare function handleAddRange(draft: Draft<State>, action: any): void;
|
|
14
14
|
declare function handleChangeRangeRelativeValue(draft: any, action: any): void;
|
|
15
15
|
declare function handleChangeRangeSignalValue(draft: any, action: any): void;
|
|
16
|
-
declare function handleChangeRangesSumFlag(draft:
|
|
16
|
+
declare function handleChangeRangesSumFlag(draft: Draft<State>, action: any): void;
|
|
17
17
|
declare function handleUpdateRange(draft: Draft<State>, action: any): void;
|
|
18
18
|
declare function handleShowMultiplicityTrees(draft: Draft<State>, action: any): void;
|
|
19
19
|
declare function handleShowRangesIntegrals(draft: Draft<State>, action: any): void;
|