nmrium 0.53.0 → 0.54.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/Viewer1D.js +48 -17
- package/lib/component/1d/ranges/Range.js +14 -6
- package/lib/component/1d/tool/XLabelPointer.js +4 -12
- package/lib/component/2d/tools/XYLabelPointer.js +3 -9
- package/lib/component/context/LoggerContext.js +11 -4
- package/lib/component/elements/CloseButton.d.ts +1 -1
- package/lib/component/elements/CustomToolTip.d.ts +8 -0
- package/lib/component/elements/CustomToolTip.js +107 -0
- package/lib/component/elements/EditableColumn.js +3 -2
- package/lib/component/elements/SaveButton.d.ts +1 -1
- package/lib/component/elements/formik/FormikError.js +2 -4
- package/lib/component/elements/formik/FormikInput.js +2 -2
- package/lib/component/header/Header.js +1 -1
- package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
- package/lib/component/main/NMRiumStateProvider.js +11 -1
- package/lib/component/modal/AboutPredictionModal.js +1 -1
- package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
- package/lib/component/modal/CopyClipboardModal.js +1 -1
- package/lib/component/modal/EditPeakShapeModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.js +11 -5
- package/lib/component/modal/PredictSpectraModal.js +1 -1
- package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.js +1 -1
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +1 -1
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +1 -1
- package/lib/component/modal/editZone/EditZoneModal.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +12 -19
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +11 -11
- package/lib/component/panels/RangesPanel/RangesPreferences.js +16 -16
- package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
- package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
- package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +4 -4
- package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/header/PreferencesHeader.js +1 -1
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
- package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
- package/lib/component/reducer/actions/FiltersActions.js +27 -1
- package/lib/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +2 -3
- package/lib/component/reducer/actions/RangesActions.js +16 -20
- package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
- package/lib/component/reducer/actions/SpectraActions.js +5 -1
- package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
- package/lib/component/toolbar/ToolBar.js +111 -25
- package/lib/component/workspaces/workspaceDefaultProperties.js +7 -12
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
- package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
- package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
- package/lib/data/data1d/Spectrum1D/index.js +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
- package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
- package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
- package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
- package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
- package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
- package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
- package/lib/data/utilities/generateColor.d.ts +7 -3
- package/lib/data/utilities/generateColor.js +5 -17
- package/lib/versionInfo.js +1 -1
- package/package.json +20 -20
- package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
- package/lib/component/elements/MolecularFormulaInput.js +0 -63
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
- package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
|
@@ -2,6 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback, useEffect, useReducer, useRef, useState, } from 'react';
|
|
3
3
|
import { ResponsiveChart } from 'react-d3-utils';
|
|
4
4
|
import { useOnOff } from 'react-science/ui';
|
|
5
|
+
import { createRange, isSpectrum1D } from '../../data/data1d/Spectrum1D';
|
|
6
|
+
import { cutRange } from '../../data/data1d/Spectrum1D/ranges/createRange';
|
|
5
7
|
import BrushXY, { BRUSH_TYPE } from '../1d-2d/tools/BrushXY';
|
|
6
8
|
import CrossLinePointer from '../1d-2d/tools/CrossLinePointer';
|
|
7
9
|
import { ViewerResponsiveWrapper } from '../2d/Viewer2D';
|
|
@@ -10,9 +12,11 @@ import { MouseTracker } from '../EventsTrackers/MouseTracker';
|
|
|
10
12
|
import { useChartData } from '../context/ChartContext';
|
|
11
13
|
import { useDispatch } from '../context/DispatchContext';
|
|
12
14
|
import { useMapKeyModifiers } from '../context/KeyModifierContext';
|
|
15
|
+
import { useLogger } from '../context/LoggerContext';
|
|
13
16
|
import { usePreferences } from '../context/PreferencesContext';
|
|
14
17
|
import { ScaleProvider } from '../context/ScaleContext';
|
|
15
18
|
import { useActiveSpectrum } from '../hooks/useActiveSpectrum';
|
|
19
|
+
import useSpectrum from '../hooks/useSpectrum';
|
|
16
20
|
import { useVerticalAlign } from '../hooks/useVerticalAlign';
|
|
17
21
|
import Spinner from '../loader/Spinner';
|
|
18
22
|
import MultipletAnalysisModal from '../modal/MultipletAnalysisModal';
|
|
@@ -34,8 +38,10 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
34
38
|
const brushStartRef = useRef(null);
|
|
35
39
|
const verticalAlign = useVerticalAlign();
|
|
36
40
|
const activeSpectrum = useActiveSpectrum();
|
|
41
|
+
const spectrum = useSpectrum();
|
|
37
42
|
const dispatch = useDispatch();
|
|
38
43
|
const { dispatch: dispatchPreferences } = usePreferences();
|
|
44
|
+
const { logger } = useLogger();
|
|
39
45
|
const [scaleState, dispatchScale] = useReducer(scaleReducer, scaleInitialState);
|
|
40
46
|
useEffect(() => {
|
|
41
47
|
if (xDomain.length > 0 && yDomain.length > 0 && widthProp && heightProp) {
|
|
@@ -84,6 +90,10 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
84
90
|
brushStartRef.current = null;
|
|
85
91
|
setBrushData(brushData);
|
|
86
92
|
const keyModifiers = getModifiersKey(brushData);
|
|
93
|
+
const selectRange = getRange(state, {
|
|
94
|
+
startX: brushData.startX,
|
|
95
|
+
endX: brushData.endX,
|
|
96
|
+
});
|
|
87
97
|
if (brushData.mouseButton === 'main') {
|
|
88
98
|
const propagateEvent = () => {
|
|
89
99
|
if (!scaleState.scaleX || !scaleState.scaleY)
|
|
@@ -108,12 +118,22 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
108
118
|
});
|
|
109
119
|
break;
|
|
110
120
|
case options.rangePicking.id: {
|
|
111
|
-
if (!
|
|
121
|
+
if (!spectrum)
|
|
112
122
|
break;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
if (isSpectrum1D(spectrum)) {
|
|
124
|
+
const [from, to] = selectRange;
|
|
125
|
+
const range = createRange(spectrum, {
|
|
126
|
+
from,
|
|
127
|
+
to,
|
|
128
|
+
logger,
|
|
129
|
+
});
|
|
130
|
+
if (!range)
|
|
131
|
+
break;
|
|
132
|
+
dispatch({
|
|
133
|
+
type: 'ADD_RANGE',
|
|
134
|
+
payload: { range },
|
|
135
|
+
});
|
|
136
|
+
}
|
|
117
137
|
break;
|
|
118
138
|
}
|
|
119
139
|
case options.multipleSpectraAnalysis.id:
|
|
@@ -153,10 +173,7 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
153
173
|
});
|
|
154
174
|
break;
|
|
155
175
|
case options.matrixGenerationExclusionZones.id: {
|
|
156
|
-
const [from, to] =
|
|
157
|
-
startX: brushData.startX,
|
|
158
|
-
endX: brushData.endX,
|
|
159
|
-
});
|
|
176
|
+
const [from, to] = selectRange;
|
|
160
177
|
dispatchPreferences({
|
|
161
178
|
type: 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE',
|
|
162
179
|
payload: {
|
|
@@ -202,14 +219,15 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
202
219
|
}
|
|
203
220
|
}, [
|
|
204
221
|
getModifiersKey,
|
|
222
|
+
state,
|
|
205
223
|
selectedTool,
|
|
206
224
|
scaleState,
|
|
207
225
|
primaryKeyIdentifier,
|
|
208
226
|
dispatch,
|
|
209
|
-
|
|
227
|
+
spectrum,
|
|
228
|
+
logger,
|
|
210
229
|
dispatchPreferences,
|
|
211
230
|
activeTab,
|
|
212
|
-
state,
|
|
213
231
|
xDomain,
|
|
214
232
|
openAnalysisModal,
|
|
215
233
|
]);
|
|
@@ -246,12 +264,18 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
246
264
|
payload: { cutValue: xPPM },
|
|
247
265
|
});
|
|
248
266
|
break;
|
|
249
|
-
case options.rangePicking.id:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
267
|
+
case options.rangePicking.id: {
|
|
268
|
+
if (!spectrum)
|
|
269
|
+
break;
|
|
270
|
+
if (isSpectrum1D(spectrum)) {
|
|
271
|
+
const cutRanges = cutRange(spectrum, xPPM);
|
|
272
|
+
dispatch({
|
|
273
|
+
type: 'CUT_RANGE',
|
|
274
|
+
payload: { ranges: cutRanges },
|
|
275
|
+
});
|
|
276
|
+
}
|
|
254
277
|
break;
|
|
278
|
+
}
|
|
255
279
|
case options.phaseCorrection.id:
|
|
256
280
|
dispatch({
|
|
257
281
|
type: 'SET_ONE_DIMENSION_PIVOT_POINT',
|
|
@@ -268,7 +292,14 @@ function Viewer1D({ emptyText = undefined }) {
|
|
|
268
292
|
default:
|
|
269
293
|
break;
|
|
270
294
|
}
|
|
271
|
-
}, [
|
|
295
|
+
}, [
|
|
296
|
+
dispatch,
|
|
297
|
+
getModifiersKey,
|
|
298
|
+
primaryKeyIdentifier,
|
|
299
|
+
scaleState,
|
|
300
|
+
selectedTool,
|
|
301
|
+
spectrum,
|
|
302
|
+
]);
|
|
272
303
|
return (_jsxs(ScaleProvider, { value: scaleState, children: [_jsx(ResponsiveChart, { children: ({ height, width }) => (_jsx(ViewerResponsiveWrapper, { height: height, width: width, children: _jsxs("div", { style: { height: '100%', position: 'relative' }, children: [_jsx(Spinner, { isLoading: isLoading, emptyText: emptyText }), scaleState.scaleX &&
|
|
273
304
|
scaleState.scaleY &&
|
|
274
305
|
data &&
|
|
@@ -1,21 +1,24 @@
|
|
|
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 { isSpectrum1D, resizeRange } from '../../../data/data1d/Spectrum1D';
|
|
4
5
|
import { isRangeAssigned } from '../../../data/data1d/Spectrum1D/isRangeAssigned';
|
|
5
6
|
import { checkRangeKind } from '../../../data/utilities/RangeUtilities';
|
|
6
7
|
import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsContext';
|
|
7
8
|
import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
|
|
8
9
|
import { useDispatch } from '../../context/DispatchContext';
|
|
10
|
+
import { useLogger } from '../../context/LoggerContext';
|
|
9
11
|
import { ResizerWithScale } from '../../elements/ResizerWithScale';
|
|
10
12
|
import { HighlightEventSource, useHighlight } from '../../highlight';
|
|
11
13
|
import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
12
14
|
import { useResizerStatus } from '../../hooks/useResizerStatus';
|
|
15
|
+
import useSpectrum from '../../hooks/useSpectrum';
|
|
13
16
|
import { options } from '../../toolbar/ToolTypes';
|
|
14
17
|
import { IntegralIndicator } from '../integral/IntegralIndicator';
|
|
15
18
|
import { useScaleX } from '../utilities/scale';
|
|
16
19
|
import { AssignmentActionsButtons } from './AssignmentActionsButtons';
|
|
17
|
-
import { Atoms } from './Atoms';
|
|
18
20
|
import { AssignmentLabel } from './AssignmentLabel';
|
|
21
|
+
import { Atoms } from './Atoms';
|
|
19
22
|
const style = css `
|
|
20
23
|
.target {
|
|
21
24
|
visibility: hidden;
|
|
@@ -34,17 +37,22 @@ function Range({ range, selectedTool, relativeFormat }) {
|
|
|
34
37
|
const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat(filterForIDsWithAssignment(assignmentData, signals.map((_signal) => _signal.id))), { type: HighlightEventSource.RANGE, extra: { id } });
|
|
35
38
|
const scaleX = useScaleX();
|
|
36
39
|
const dispatch = useDispatch();
|
|
40
|
+
const { logger } = useLogger();
|
|
41
|
+
const spectrum = useSpectrum();
|
|
37
42
|
const { showIntegralsValues } = useActiveSpectrumRangesViewState();
|
|
38
43
|
const isBlockedByEditing = selectedTool && selectedTool === options.editRange.id;
|
|
39
44
|
function handleOnStopResizing(position) {
|
|
45
|
+
if (!spectrum || !isSpectrum1D(spectrum))
|
|
46
|
+
return;
|
|
47
|
+
const from = scaleX().invert(position.x2);
|
|
48
|
+
const to = scaleX().invert(position.x1);
|
|
49
|
+
const newRange = resizeRange(spectrum, { from, to, range, logger });
|
|
50
|
+
if (!newRange)
|
|
51
|
+
return;
|
|
40
52
|
dispatch({
|
|
41
53
|
type: 'RESIZE_RANGE',
|
|
42
54
|
payload: {
|
|
43
|
-
range:
|
|
44
|
-
...range,
|
|
45
|
-
from: scaleX().invert(position.x2),
|
|
46
|
-
to: scaleX().invert(position.x1),
|
|
47
|
-
},
|
|
55
|
+
range: newRange,
|
|
48
56
|
},
|
|
49
57
|
});
|
|
50
58
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
2
|
import { useBrushTracker } from '../../EventsTrackers/BrushTracker';
|
|
4
3
|
import { useMouseTracker } from '../../EventsTrackers/MouseTracker';
|
|
5
4
|
import { useChartData } from '../../context/ChartContext';
|
|
@@ -8,10 +7,8 @@ import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus';
|
|
|
8
7
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
9
8
|
const style = {
|
|
10
9
|
cursor: 'crosshair',
|
|
11
|
-
transformOrigin: 'bottom right',
|
|
12
10
|
position: 'absolute',
|
|
13
|
-
|
|
14
|
-
left: '-30px',
|
|
11
|
+
paddingRight: '5px',
|
|
15
12
|
pointerEvents: 'none',
|
|
16
13
|
overflow: 'visible',
|
|
17
14
|
userSelect: 'none',
|
|
@@ -23,12 +20,6 @@ function XLabelPointer() {
|
|
|
23
20
|
const position = useMouseTracker();
|
|
24
21
|
const brushState = useBrushTracker();
|
|
25
22
|
const format = useFormatNumberByNucleus(activeSpectrum?.info.nucleus);
|
|
26
|
-
const getXValue = useCallback((xVal) => {
|
|
27
|
-
if (activeSpectrum) {
|
|
28
|
-
const xInvert = scaleX().invert(xVal);
|
|
29
|
-
return format(xInvert);
|
|
30
|
-
}
|
|
31
|
-
}, [activeSpectrum, format, scaleX]);
|
|
32
23
|
if (!activeSpectrum ||
|
|
33
24
|
brushState.step === 'brushing' ||
|
|
34
25
|
!position ||
|
|
@@ -38,9 +29,10 @@ function XLabelPointer() {
|
|
|
38
29
|
position.y > height - margin.bottom) {
|
|
39
30
|
return null;
|
|
40
31
|
}
|
|
32
|
+
const x = scaleX().invert(position.x);
|
|
41
33
|
return (_jsx("div", { style: {
|
|
42
34
|
...style,
|
|
43
|
-
transform: `translate(${position.x}px, ${position.y}px)`,
|
|
44
|
-
}, children: _jsx("span", { children:
|
|
35
|
+
transform: `translate(${position.x}px, ${position.y}px) translate(-100%,-100%)`,
|
|
36
|
+
}, children: _jsx("span", { children: format(x) }) }));
|
|
45
37
|
}
|
|
46
38
|
export default XLabelPointer;
|
|
@@ -9,17 +9,12 @@ import { getLayoutID, LAYOUT } from '../utilities/DimensionLayout';
|
|
|
9
9
|
import { get1DYScale, useScale2DX, useScale2DY } from '../utilities/scale';
|
|
10
10
|
const style = {
|
|
11
11
|
cursor: 'crosshair',
|
|
12
|
-
transformOrigin: 'bottom right',
|
|
13
12
|
position: 'absolute',
|
|
14
|
-
|
|
15
|
-
left: '-88px',
|
|
13
|
+
paddingRight: '5px',
|
|
16
14
|
fontWeight: 'bold',
|
|
17
15
|
pointerEvents: 'none',
|
|
18
16
|
overflow: 'visible',
|
|
19
17
|
userSelect: 'none',
|
|
20
|
-
width: '85px',
|
|
21
|
-
textAlign: 'right',
|
|
22
|
-
zIndex: 9,
|
|
23
18
|
};
|
|
24
19
|
function XYLabelPointer({ layout, data1D }) {
|
|
25
20
|
const position = useMouseTracker();
|
|
@@ -33,7 +28,6 @@ function XYLabelPointer({ layout, data1D }) {
|
|
|
33
28
|
});
|
|
34
29
|
const nuclei = activeTab.split(',');
|
|
35
30
|
const [formatX, formatY] = useFormatNumberByNucleus(nuclei);
|
|
36
|
-
// const spectrum = useSpectrum();
|
|
37
31
|
const scale2DX = useScale2DX();
|
|
38
32
|
const scale2DY = useScale2DY();
|
|
39
33
|
const scaleX = useMemo(() => {
|
|
@@ -118,7 +112,7 @@ function XYLabelPointer({ layout, data1D }) {
|
|
|
118
112
|
};
|
|
119
113
|
return (_jsxs("div", { style: {
|
|
120
114
|
...style,
|
|
121
|
-
transform: `translate(${position.x}px, ${position.y}px)`,
|
|
122
|
-
}, children: [_jsx("span", { children: formatY(getYValue()) }), _jsx("span", { style: { color: 'gray' }, children: ',' }), _jsx("span", { style: { color: 'red' }, children: formatX(getXValue()) })] }
|
|
115
|
+
transform: `translate(${position.x}px, ${position.y}px) translate(-100%,-100%)`,
|
|
116
|
+
}, children: [_jsx("span", { children: formatY(getYValue()) }), _jsx("span", { style: { color: 'gray' }, children: ',' }), _jsx("span", { style: { color: 'red' }, children: formatX(getXValue()) })] }));
|
|
123
117
|
}
|
|
124
118
|
export default XYLabelPointer;
|
|
@@ -26,8 +26,10 @@ export function LoggerProvider({ children }) {
|
|
|
26
26
|
const [logsHistory, setLogsHistory] = useState([]);
|
|
27
27
|
const [isLogHistoryOpened, openLogHistory] = useState(false);
|
|
28
28
|
const popupLoggingLevelRef = useRef();
|
|
29
|
-
const loggerRef = useRef(new FifoLogger(
|
|
30
|
-
|
|
29
|
+
const loggerRef = useRef(new FifoLogger());
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
function handleLogger({ detail: { logs } }) {
|
|
32
|
+
const log = logs.at(-1);
|
|
31
33
|
if (log &&
|
|
32
34
|
popupLoggingLevelRef.current &&
|
|
33
35
|
log.level === LOGGER_LEVELS[popupLoggingLevelRef.current]) {
|
|
@@ -38,8 +40,13 @@ export function LoggerProvider({ children }) {
|
|
|
38
40
|
console.error(log.error);
|
|
39
41
|
}
|
|
40
42
|
setLogsHistory(logs.slice());
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
+
}
|
|
44
|
+
const loggerInstance = loggerRef.current;
|
|
45
|
+
loggerInstance.addEventListener('change', handleLogger);
|
|
46
|
+
return () => {
|
|
47
|
+
loggerInstance.removeEventListener('change', handleLogger);
|
|
48
|
+
};
|
|
49
|
+
}, []);
|
|
43
50
|
useEffect(() => {
|
|
44
51
|
if (loggingLevel) {
|
|
45
52
|
loggerRef.current.setLevel(loggingLevel);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ToolbarItemProps } from 'react-science/ui';
|
|
2
|
-
export declare function CloseButton(props: Pick<ToolbarItemProps, 'onClick' | '
|
|
2
|
+
export declare function CloseButton(props: Pick<ToolbarItemProps, 'onClick' | 'tooltip' | 'className'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
const styles = {
|
|
5
|
+
titleContainer: {
|
|
6
|
+
display: 'flex',
|
|
7
|
+
justifyContent: 'space-between',
|
|
8
|
+
flexWrap: 'wrap',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
},
|
|
11
|
+
title: {
|
|
12
|
+
fontSize: '0.9rem',
|
|
13
|
+
flex: 1,
|
|
14
|
+
padding: '5px 0',
|
|
15
|
+
textAlign: 'left',
|
|
16
|
+
color: 'white',
|
|
17
|
+
},
|
|
18
|
+
description: {
|
|
19
|
+
paddingTop: '1rem',
|
|
20
|
+
fontSize: '0.7rem',
|
|
21
|
+
textAlign: 'left',
|
|
22
|
+
color: 'white',
|
|
23
|
+
},
|
|
24
|
+
shortcutContainer: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
textWrap: 'nowrap',
|
|
27
|
+
color: 'white',
|
|
28
|
+
},
|
|
29
|
+
shortcutItem: {
|
|
30
|
+
display: 'flex',
|
|
31
|
+
justifyContent: 'center',
|
|
32
|
+
alignItems: 'center',
|
|
33
|
+
padding: '0.2rem',
|
|
34
|
+
border: '1px solid #ccc',
|
|
35
|
+
borderRadius: '4px',
|
|
36
|
+
height: 'calc(0.2rem + 20px)',
|
|
37
|
+
minWidth: 'calc(0.2rem + 20px)' /* Adjust padding and border width */,
|
|
38
|
+
marginLeft: '5px',
|
|
39
|
+
fontSize: '0.75rem',
|
|
40
|
+
fontWeight: 'bold',
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export function CustomToolTip(props) {
|
|
44
|
+
const { title, shortcuts = [], subTitles = [], description = '', link, } = props;
|
|
45
|
+
return (_jsxs("div", { style: {
|
|
46
|
+
width: 250,
|
|
47
|
+
padding: '0.5rem',
|
|
48
|
+
}, children: [_jsxs("div", { style: styles.titleContainer, children: [_jsx("span", { style: styles.title, children: title }), _jsx(ShortCuts, { shortcuts: shortcuts })] }), _jsx(SubTitles, { items: subTitles }), (description || link) && (_jsxs("p", { style: styles.description, children: [description, link && (_jsx("a", { style: description ? { paddingLeft: '5px' } : {}, target: "_blank", href: link, rel: "noreferrer", children: "Learn more" }))] }))] }));
|
|
49
|
+
}
|
|
50
|
+
function ShortCuts({ shortcuts, style = {}, }) {
|
|
51
|
+
return (_jsx("div", { style: styles.shortcutContainer, children: shortcuts.map((key, index) => {
|
|
52
|
+
return (_jsx("div", { style: {
|
|
53
|
+
...styles.shortcutItem,
|
|
54
|
+
...(index === 0 && { margin: 0 }),
|
|
55
|
+
...style,
|
|
56
|
+
}, children: _jsx("span", { children: key }) }, key));
|
|
57
|
+
}) }));
|
|
58
|
+
}
|
|
59
|
+
const subTitleStyle = css `
|
|
60
|
+
padding-left: 5px;
|
|
61
|
+
list-style: none;
|
|
62
|
+
|
|
63
|
+
li {
|
|
64
|
+
position: relative;
|
|
65
|
+
padding-left: 15px;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
|
|
68
|
+
&::before {
|
|
69
|
+
position: absolute;
|
|
70
|
+
top: 15px;
|
|
71
|
+
left: 0;
|
|
72
|
+
width: 10px;
|
|
73
|
+
height: 1px;
|
|
74
|
+
margin: auto;
|
|
75
|
+
content: '';
|
|
76
|
+
background-color: white;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
&::after {
|
|
80
|
+
position: absolute;
|
|
81
|
+
top: 0;
|
|
82
|
+
bottom: 0;
|
|
83
|
+
left: 0;
|
|
84
|
+
width: 1px;
|
|
85
|
+
height: 100%;
|
|
86
|
+
content: '';
|
|
87
|
+
background-color: white;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:last-child::after {
|
|
91
|
+
height: 15px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
li:first-child {
|
|
96
|
+
padding-top: 5px;
|
|
97
|
+
|
|
98
|
+
&::before {
|
|
99
|
+
top: 20px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
`;
|
|
103
|
+
function SubTitles({ items }) {
|
|
104
|
+
if (!items || items.length === 0)
|
|
105
|
+
return null;
|
|
106
|
+
return (_jsx("ul", { css: subTitleStyle, children: items.map(({ shortcuts = [], title }) => (_jsx("li", { children: _jsxs("div", { style: styles.titleContainer, children: [_jsx("span", { style: { ...styles.title, fontSize: '0.7rem' }, children: title }), _jsx(ShortCuts, { style: { padding: '0.1rem' }, shortcuts: shortcuts })] }) }, title))) }));
|
|
107
|
+
}
|
|
@@ -34,13 +34,14 @@ const EditableColumn = forwardRef(function EditableColumn(props, ref) {
|
|
|
34
34
|
onEditStart(true);
|
|
35
35
|
enableEdit(true);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function saveHandler(event) {
|
|
38
38
|
const valid = validate(val);
|
|
39
39
|
setValid(valid);
|
|
40
40
|
// when press Enter or Tab
|
|
41
41
|
if (valid && ['Enter', 'Tab'].includes(event.key)) {
|
|
42
42
|
onSave(event);
|
|
43
43
|
enableEdit(false);
|
|
44
|
+
window.removeEventListener('mousedown', mouseClickCallback);
|
|
44
45
|
}
|
|
45
46
|
// close edit mode if press Enter, Tab or Escape
|
|
46
47
|
if (['Escape'].includes(event.key)) {
|
|
@@ -76,6 +77,6 @@ const EditableColumn = forwardRef(function EditableColumn(props, ref) {
|
|
|
76
77
|
width: '100%',
|
|
77
78
|
minWidth: '60px',
|
|
78
79
|
},
|
|
79
|
-
}, autoSelect: true, className: "editable-column", value: val, type: type, onChange: handleChange,
|
|
80
|
+
}, autoSelect: true, className: "editable-column", value: val, type: type, onChange: handleChange, onKeyDown: saveHandler, onMouseDown: (e) => e.stopPropagation(), ...InputProps }) }))] }));
|
|
80
81
|
});
|
|
81
82
|
export default EditableColumn;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ToolbarItemProps } from 'react-science/ui';
|
|
2
|
-
export declare function SaveButton(props: Pick<ToolbarItemProps, 'onClick' | '
|
|
2
|
+
export declare function SaveButton(props: Pick<ToolbarItemProps, 'onClick' | 'tooltip'>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -3,7 +3,6 @@ import { useFormikContext } from 'formik';
|
|
|
3
3
|
import lodashGet from 'lodash/get';
|
|
4
4
|
const styles = {
|
|
5
5
|
container: {
|
|
6
|
-
padding: '0.4rem',
|
|
7
6
|
display: 'flex',
|
|
8
7
|
flexDirection: 'column',
|
|
9
8
|
},
|
|
@@ -14,9 +13,8 @@ const styles = {
|
|
|
14
13
|
},
|
|
15
14
|
};
|
|
16
15
|
function FormikError({ style, name, children }) {
|
|
17
|
-
const { errors, isValid, dirty
|
|
16
|
+
const { errors, isValid, dirty } = useFormikContext();
|
|
18
17
|
const errorText = lodashGet(errors, name);
|
|
19
|
-
|
|
20
|
-
return (_jsxs("div", { style: { ...styles.container, ...style?.container }, children: [children, !isValid && dirty && isTouched && (_jsx("span", { style: { ...styles.text, ...style?.text }, children: errorText }))] }));
|
|
18
|
+
return (_jsxs("div", { style: { ...styles.container, ...style?.container }, children: [children, !isValid && dirty && (_jsx("span", { style: { ...styles.text, ...style?.text }, children: errorText }))] }));
|
|
21
19
|
}
|
|
22
20
|
export default FormikError;
|
|
@@ -4,7 +4,7 @@ import lodashGet from 'lodash/get';
|
|
|
4
4
|
import Input from '../Input';
|
|
5
5
|
function FormikInput(props) {
|
|
6
6
|
const { name, style = { label: {}, input: {}, inputWrapper: {} }, onChange, type = 'text', className = '', value = null, checkErrorAfterInputTouched = true, mapOnChangeValue, mapValue, ...resProps } = props;
|
|
7
|
-
const { values, handleChange, errors, touched, setFieldValue } = useFormikContext();
|
|
7
|
+
const { values, handleChange, errors, touched, setFieldValue, handleBlur } = useFormikContext();
|
|
8
8
|
function changeHandler(e) {
|
|
9
9
|
onChange?.(e);
|
|
10
10
|
if (mapOnChangeValue) {
|
|
@@ -20,7 +20,7 @@ function FormikInput(props) {
|
|
|
20
20
|
}
|
|
21
21
|
let val = value || lodashGet(values, name);
|
|
22
22
|
val = mapValue ? mapValue(val) : val;
|
|
23
|
-
return (_jsx(Input, { name: name, value: val, onChange: changeHandler, type: type, style: {
|
|
23
|
+
return (_jsx(Input, { name: name, value: val, onChange: changeHandler, onBlur: handleBlur, type: type, style: {
|
|
24
24
|
...style,
|
|
25
25
|
inputWrapper: {
|
|
26
26
|
...style.inputWrapper,
|
|
@@ -105,7 +105,7 @@ function HeaderInner(props) {
|
|
|
105
105
|
alignItems: 'center',
|
|
106
106
|
}, children: [_jsx("div", { children: _jsx(Toolbar, { children: _jsx(AboutUsModal, {}) }) }), _jsx("div", { className: "toolOptionsPanel", style: { flex: 1 }, children: selectedPanel })] }), _jsxs(HeaderContainer, { style: {
|
|
107
107
|
alignItems: 'center',
|
|
108
|
-
}, children: [!hideWorkspaces && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), !hideGeneralSettings && _jsx(SaveButton, {}), !general?.hideLogs && _jsx(LogsHistoryModal, {}), _jsx("div", { children: _jsxs(Toolbar, { children: [!general?.hideHelp && (_jsx(Toolbar.Item, { id: "user-manual",
|
|
108
|
+
}, children: [!hideWorkspaces && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), !hideGeneralSettings && _jsx(SaveButton, {}), !general?.hideLogs && _jsx(LogsHistoryModal, {}), _jsx("div", { children: _jsxs(Toolbar, { children: [!general?.hideHelp && (_jsx(Toolbar.Item, { id: "user-manual", tooltip: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), icon: _jsx(FaQuestionCircle, {}) })), _jsx(Toolbar.Item, { id: "user-manual", tooltip: "NMRium channel", onClick: () => window.open('https://www.youtube.com/@nmrium', '_blank'), icon: _jsx(FaFilm, {}) }), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !fullscreen.isFullScreen && !general?.hideMaximize && (_jsx(Toolbar.Item, { id: "full-screen", onClick: fullscreen.toggle, tooltip: "Full screen", className: "windowButton", icon: _jsx(FaRegWindowMaximize, {}) }))] }) })] })] }) }));
|
|
109
109
|
}
|
|
110
110
|
function SaveButton() {
|
|
111
111
|
const { workspace, workspaces, originalWorkspaces } = usePreferences();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Select } from '@blueprintjs/select';
|
|
3
4
|
import { css } from '@emotion/react';
|
|
4
5
|
import debounce from 'lodash/debounce';
|
|
5
6
|
import { Filters } from 'nmr-processing';
|
|
6
7
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
7
8
|
import { FaRulerHorizontal, FaRulerVertical } from 'react-icons/fa';
|
|
8
9
|
import { MdLooksTwo } from 'react-icons/md';
|
|
9
|
-
import { Toolbar } from 'react-science/ui';
|
|
10
|
+
import { Button, Toolbar, useSelect } from 'react-science/ui';
|
|
10
11
|
import { useActivePhaseTraces } from '../2d/1d-tracer/phase-correction-traces/useActivePhaseTraces';
|
|
11
12
|
import { useDispatch } from '../context/DispatchContext';
|
|
12
13
|
import ActionButtons from '../elements/ActionButtons';
|
|
@@ -17,6 +18,17 @@ import { useFilter } from '../hooks/useFilter';
|
|
|
17
18
|
import useSpectrum from '../hooks/useSpectrum';
|
|
18
19
|
import { headerLabelStyle } from './Header';
|
|
19
20
|
import { HeaderContainer } from './HeaderContainer';
|
|
21
|
+
const defaultPhasingTypeItem = {
|
|
22
|
+
label: 'Manual',
|
|
23
|
+
value: 'manual',
|
|
24
|
+
};
|
|
25
|
+
const algorithms = [
|
|
26
|
+
defaultPhasingTypeItem,
|
|
27
|
+
{
|
|
28
|
+
label: 'Automatic',
|
|
29
|
+
value: 'automatic',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
20
32
|
const inputStyle = {
|
|
21
33
|
input: {
|
|
22
34
|
width: '70px',
|
|
@@ -46,8 +58,12 @@ export default function PhaseCorrectionTwoDimensionsPanel() {
|
|
|
46
58
|
const valueRef = useRef(defaultPhaseOptions);
|
|
47
59
|
const ph0Ref = useRef();
|
|
48
60
|
const ph1Ref = useRef();
|
|
61
|
+
const { value: phaseCorrectionTypeItem, ...defaultSelectProps } = useSelect({
|
|
62
|
+
defaultSelectedItem: defaultPhasingTypeItem,
|
|
63
|
+
itemTextKey: 'label',
|
|
64
|
+
});
|
|
49
65
|
useEffect(() => {
|
|
50
|
-
if (filter) {
|
|
66
|
+
if (filter && phaseCorrectionTypeItem?.value === 'manual') {
|
|
51
67
|
const { value } = filter;
|
|
52
68
|
const phaseOptions = defaultPhaseOptions;
|
|
53
69
|
for (const direction of Object.keys(value)) {
|
|
@@ -57,7 +73,7 @@ export default function PhaseCorrectionTwoDimensionsPanel() {
|
|
|
57
73
|
setValue(phaseOptions);
|
|
58
74
|
valueRef.current = phaseOptions;
|
|
59
75
|
}
|
|
60
|
-
}, [filter]);
|
|
76
|
+
}, [filter, phaseCorrectionTypeItem?.value]);
|
|
61
77
|
useEffect(() => {
|
|
62
78
|
if (ph0Ref.current && ph1Ref.current) {
|
|
63
79
|
const { ph0, ph1 } = valueRef.current[activeTraceDirection];
|
|
@@ -142,14 +158,29 @@ export default function PhaseCorrectionTwoDimensionsPanel() {
|
|
|
142
158
|
});
|
|
143
159
|
}
|
|
144
160
|
function handleApplyFilter() {
|
|
145
|
-
|
|
161
|
+
switch (phaseCorrectionTypeItem?.value) {
|
|
162
|
+
case 'automatic': {
|
|
163
|
+
dispatch({
|
|
164
|
+
type: 'APPLY_AUTO_PHASE_CORRECTION_TOW_DIMENSION_FILTER',
|
|
165
|
+
});
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
case 'manual': {
|
|
169
|
+
dispatch({
|
|
170
|
+
type: 'APPLY_MANUAL_PHASE_CORRECTION_TOW_DIMENSION_FILTER',
|
|
171
|
+
});
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
default:
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
146
177
|
}
|
|
147
178
|
function handleToggleAddTraceToBothDirections() {
|
|
148
179
|
dispatch({ type: 'TOGGLE_ADD_PHASE_CORRECTION_TRACE_TO_BOTH_DIRECTIONS' });
|
|
149
180
|
}
|
|
150
|
-
return (_jsxs(HeaderContainer, { style: { padding: '0 5px' }, children: [_jsx(Label, { title: "Direction:", style: headerLabelStyle, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { css: css `
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
181
|
+
return (_jsxs(HeaderContainer, { style: { padding: '0 5px' }, children: [_jsx("div", { style: { padding: '0 5px' }, children: _jsx(Select, { items: algorithms, filterable: false, itemsEqual: "value", ...defaultSelectProps, children: _jsx(Button, { text: phaseCorrectionTypeItem?.label, rightIcon: "double-caret-vertical" }) }) }), phaseCorrectionTypeItem?.value === 'manual' && (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Direction:", style: headerLabelStyle, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { css: css `
|
|
182
|
+
border: 1px solid #f7f7f7;
|
|
183
|
+
`, tooltip: "Horizontal", icon: _jsx(FaRulerHorizontal, {}), active: activeTraceDirection === 'horizontal', onClick: () => onChangeHandler('horizontal') }), _jsx(Toolbar.Item, { css: css `
|
|
184
|
+
border: 1px solid #f7f7f7;
|
|
185
|
+
`, tooltip: "Vertical", icon: _jsx(FaRulerVertical, {}), active: activeTraceDirection === 'vertical', onClick: () => onChangeHandler('vertical') })] }) }), _jsx("div", { style: { paddingRight: '5px' }, children: _jsx(Toolbar, { children: _jsx(Toolbar.Item, { tooltip: "Add the trace in both directions", icon: _jsx(MdLooksTwo, {}), active: addTracesToBothDirections, onClick: handleToggleAddTraceToBothDirections }) }) }), _jsx(Label, { title: "PH0:", style: headerLabelStyle, children: _jsx(Input, { name: "ph0", style: inputStyle, onChange: handleInput, value: value[activeTraceDirection].ph0, type: "number", debounceTime: 250 }) }), _jsx(Label, { title: "PH1:", style: headerLabelStyle, children: _jsx(Input, { name: "ph1", style: inputStyle, onChange: handleInput, value: value[activeTraceDirection].ph1, type: "number", debounceTime: 250 }) }), _jsx(InputRange, { ref: ph0Ref, name: "ph0", label: "Change PH0 (click and drag)", shortLabel: "Ph0", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(InputRange, { ref: ph1Ref, name: "ph1", label: "Change PH1 (click and drag)", shortLabel: "Ph1", style: { width: '20%' }, onChange: handleRangeChange })] })), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
|
|
155
186
|
}
|
|
@@ -15,6 +15,7 @@ export default function NMRiumStateProvider(props) {
|
|
|
15
15
|
const { children, onChange, nmriumData = defaultData } = props;
|
|
16
16
|
const { logger } = useLogger();
|
|
17
17
|
const preferencesState = usePreferences();
|
|
18
|
+
const { dispatch: dispatchPreferences } = preferencesState;
|
|
18
19
|
const [state, dispatchRaw] = useReducer(spectrumReducer, initialState, initState);
|
|
19
20
|
const dispatch = useCallback((action) => {
|
|
20
21
|
logger.trace({ action }, `Dispatch main reducer action: ${action.type}`);
|
|
@@ -60,6 +61,15 @@ export default function NMRiumStateProvider(props) {
|
|
|
60
61
|
if (nmriumData) {
|
|
61
62
|
void readNMRiumObject(nmriumData)
|
|
62
63
|
.then((nmriumState) => {
|
|
64
|
+
if (nmriumState?.settings) {
|
|
65
|
+
dispatchPreferences({
|
|
66
|
+
type: 'SET_WORKSPACE',
|
|
67
|
+
payload: {
|
|
68
|
+
data: nmriumState.settings,
|
|
69
|
+
workspaceSource: 'nmriumFile',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
}
|
|
63
73
|
dispatch({ type: 'INITIATE', payload: { nmriumState } });
|
|
64
74
|
})
|
|
65
75
|
.catch((error) => {
|
|
@@ -69,6 +79,6 @@ export default function NMRiumStateProvider(props) {
|
|
|
69
79
|
reportError(error);
|
|
70
80
|
});
|
|
71
81
|
}
|
|
72
|
-
}, [nmriumData, dispatch]);
|
|
82
|
+
}, [nmriumData, dispatch, dispatchPreferences]);
|
|
73
83
|
return (_jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: children }) }));
|
|
74
84
|
}
|