nmrium 0.42.0 → 0.43.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/ApodizationLine.js +1 -1
- package/lib/component/1d/Chart1D.js +3 -2
- package/lib/component/1d/Line.js +1 -1
- package/lib/component/1d/Viewer1D.js +15 -3
- package/lib/component/1d/integral/IntegralResizable.js +4 -3
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +3 -1
- package/lib/component/1d/peaks/PeakAnnotations.js +20 -25
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +2 -0
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +59 -0
- package/lib/component/1d/peaks/PeakEditionManager.d.ts +18 -0
- package/lib/component/1d/peaks/PeakEditionManager.js +98 -0
- package/lib/component/1d/peaks/Peaks.d.ts +1 -0
- package/lib/component/1d/peaks/Peaks.js +22 -0
- package/lib/component/1d/ranges/Range.js +3 -1
- package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
- package/lib/component/1d/tool/BaseLineZones.js +11 -31
- package/lib/component/1d/utilities/intersectionResolver.d.ts +25 -0
- package/lib/component/1d/utilities/intersectionResolver.js +71 -0
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
- package/lib/component/2d/SlicingView.js +1 -1
- package/lib/component/2d/ft/Contours.js +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +5 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +47 -6
- package/lib/component/assignment/index.d.ts +6 -1
- package/lib/component/assignment/index.js +5 -1
- package/lib/component/context/DispatchContext.d.ts +1 -2
- package/lib/component/context/KeyModifierContext.d.ts +13 -0
- package/lib/component/context/KeyModifierContext.js +39 -0
- package/lib/component/context/PreferencesContext.d.ts +39 -39
- package/lib/component/elements/Button.js +2 -0
- package/lib/component/elements/NumberInput.d.ts +1 -0
- package/lib/component/elements/NumberInput.js +10 -3
- package/lib/component/elements/formik/FormikOnChange.js +1 -1
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +1 -1
- package/lib/component/header/ApodizationOptionsPanel.js +23 -14
- package/lib/component/header/BaseLineCorrectionPanel.js +31 -10
- package/lib/component/header/Header.d.ts +10 -3
- package/lib/component/header/Header.js +5 -5
- package/lib/component/header/ZeroFillingOptionsPanel.js +37 -31
- package/lib/component/highlight/index.d.ts +1 -0
- package/lib/component/highlight/index.js +1 -0
- package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
- package/lib/component/hooks/useCheckToolsVisibility.js +7 -3
- package/lib/component/hooks/useResizerStatus.d.ts +2 -0
- package/lib/component/hooks/useResizerStatus.js +7 -0
- package/lib/component/hooks/useSpectrum.js +1 -1
- package/lib/component/main/ErrorOverlay.js +20 -0
- package/lib/component/main/InnerNMRium.d.ts +7 -0
- package/lib/component/main/InnerNMRium.js +52 -0
- package/lib/component/main/InnerNMRiumContents.d.ts +14 -0
- package/lib/component/main/InnerNMRiumContents.js +89 -0
- package/lib/component/main/NMRium.d.ts +23 -0
- package/lib/component/main/NMRium.js +13 -0
- package/lib/component/main/NMRiumStateProvider.d.ts +9 -0
- package/lib/component/main/NMRiumStateProvider.js +74 -0
- package/lib/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
- package/lib/component/main/StateError.d.ts +4 -0
- package/lib/component/main/StateError.js +16 -0
- package/lib/component/main/index.d.ts +3 -0
- package/lib/component/main/index.js +3 -0
- package/lib/component/main/types.d.ts +18 -0
- package/lib/component/main/types.js +2 -0
- package/lib/component/modal/PredictSpectraModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.d.ts +5 -16
- package/lib/component/modal/changeSum/ChangeSumModal.js +6 -115
- package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +18 -0
- package/lib/component/modal/changeSum/ChangeSumModalContents.js +94 -0
- package/lib/component/modal/setting/GeneralSettings.js +2 -2
- package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -4
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +3 -9
- package/lib/component/panels/MoleculesPanel/Utilities.js +14 -10
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +3 -3
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +11 -5
- package/lib/component/panels/RangesPanel/RangesHeader.js +6 -10
- package/lib/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +3 -2
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +3 -4
- package/lib/component/panels/header/DefaultPanelHeader.js +9 -5
- package/lib/component/panels/predictionPanel/PredictionPanel.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
- package/lib/component/reducer/IgnoreActions.js +0 -1
- package/lib/component/reducer/Reducer.d.ts +1 -6
- package/lib/component/reducer/Reducer.js +30 -6
- package/lib/component/reducer/actions/FiltersActions.d.ts +32 -11
- package/lib/component/reducer/actions/FiltersActions.js +96 -28
- package/lib/component/reducer/actions/IntegralsActions.d.ts +6 -2
- package/lib/component/reducer/actions/IntegralsActions.js +44 -20
- package/lib/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib/component/reducer/actions/PeaksActions.d.ts +6 -4
- package/lib/component/reducer/actions/PeaksActions.js +19 -1
- package/lib/component/reducer/actions/RangesActions.d.ts +6 -2
- package/lib/component/reducer/actions/RangesActions.js +31 -3
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
- package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.d.ts +1 -1
- package/lib/component/toolbar/FunctionToolBar.js +13 -3
- package/lib/component/toolbar/ToolTypes.d.ts +1 -0
- package/lib/component/toolbar/ToolTypes.js +36 -0
- package/lib/component/utility/export.js +7 -4
- package/lib/component/utility/filterType.d.ts +3 -0
- package/lib/component/utility/filterType.js +1 -0
- package/lib/component/workspaces/basic.js +2 -0
- package/lib/component/workspaces/embedded.js +2 -0
- package/lib/component/workspaces/exercise.js +2 -0
- package/lib/component/workspaces/prediction.js +9 -0
- package/lib/component/workspaces/process1D.js +2 -0
- package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib/data/PredictionManager.d.ts +3 -3
- package/lib/data/PredictionManager.js +10 -10
- package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -2
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +2 -8
- package/lib/data/molecules/Molecule.js +2 -2
- package/lib/data/utilities/checkModifierKeyActivated.d.ts +1 -1
- package/lib/data/utilities/checkModifierKeyActivated.js +8 -13
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/ApodizationLine.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +3 -2
- package/lib-cjs/component/1d/Line.js +1 -1
- package/lib-cjs/component/1d/Viewer1D.js +15 -3
- package/lib-cjs/component/1d/integral/IntegralResizable.js +4 -3
- package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +3 -1
- package/lib-cjs/component/1d/peaks/PeakAnnotations.js +19 -24
- package/lib-cjs/component/1d/peaks/PeakAnnotationsSpreadMode.js +64 -0
- package/lib-cjs/component/1d/peaks/PeakEditionManager.js +129 -0
- package/lib-cjs/component/1d/peaks/Peaks.js +29 -0
- package/lib-cjs/component/1d/ranges/Range.js +3 -1
- package/lib-cjs/component/1d/tool/BaseLineZones.js +11 -34
- package/lib-cjs/component/1d/utilities/intersectionResolver.js +75 -0
- package/lib-cjs/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
- package/lib-cjs/component/2d/SlicingView.js +1 -1
- package/lib-cjs/component/2d/ft/Contours.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +46 -5
- package/lib-cjs/component/assignment/index.js +5 -1
- package/lib-cjs/component/context/KeyModifierContext.js +44 -0
- package/lib-cjs/component/elements/Button.js +2 -0
- package/lib-cjs/component/elements/NumberInput.js +12 -2
- package/lib-cjs/component/elements/formik/FormikOnChange.js +1 -1
- package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +1 -1
- package/lib-cjs/component/header/ApodizationOptionsPanel.js +23 -14
- package/lib-cjs/component/header/BaseLineCorrectionPanel.js +30 -9
- package/lib-cjs/component/header/Header.js +5 -5
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +35 -29
- package/lib-cjs/component/highlight/index.js +1 -0
- package/lib-cjs/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +7 -3
- package/lib-cjs/component/hooks/useResizerStatus.js +11 -0
- package/lib-cjs/component/hooks/useSpectrum.js +1 -1
- package/lib-cjs/component/main/ErrorOverlay.js +26 -0
- package/lib-cjs/component/main/InnerNMRium.js +82 -0
- package/lib-cjs/component/main/InnerNMRiumContents.js +96 -0
- package/lib-cjs/component/main/NMRium.js +19 -0
- package/lib-cjs/component/main/NMRiumStateProvider.js +80 -0
- package/lib-cjs/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
- package/lib-cjs/component/main/StateError.js +20 -0
- package/lib-cjs/component/main/index.js +21 -0
- package/lib-cjs/component/main/types.js +3 -0
- package/lib-cjs/component/modal/PredictSpectraModal.js +1 -1
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +6 -141
- package/lib-cjs/component/modal/changeSum/ChangeSumModalContents.js +124 -0
- package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -2
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -4
- package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +14 -10
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +32 -3
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +29 -10
- package/lib-cjs/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +27 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +26 -2
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
- package/lib-cjs/component/panels/header/DefaultPanelHeader.js +11 -5
- package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +1 -1
- package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
- package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
- package/lib-cjs/component/reducer/IgnoreActions.js +0 -1
- package/lib-cjs/component/reducer/Reducer.js +29 -5
- package/lib-cjs/component/reducer/actions/FiltersActions.js +98 -28
- package/lib-cjs/component/reducer/actions/IntegralsActions.js +45 -20
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +1 -1
- package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
- package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
- package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
- package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
- package/lib-cjs/component/utility/export.js +7 -4
- package/lib-cjs/component/utility/filterType.js +2 -0
- package/lib-cjs/component/workspaces/basic.js +2 -0
- package/lib-cjs/component/workspaces/embedded.js +2 -0
- package/lib-cjs/component/workspaces/exercise.js +2 -0
- package/lib-cjs/component/workspaces/prediction.js +9 -0
- package/lib-cjs/component/workspaces/process1D.js +2 -0
- package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib-cjs/data/PredictionManager.js +9 -9
- package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
- package/lib-cjs/data/molecules/Molecule.js +2 -2
- package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +26 -25
- package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
- package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
- package/lib/component/ErrorOverlay.js +0 -27
- package/lib/component/NMRium.d.ts +0 -42
- package/lib/component/NMRium.js +0 -237
- package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
- package/lib/component/reducer/actions/GlobalActions.js +0 -4
- package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
- package/lib-cjs/component/ErrorOverlay.js +0 -30
- package/lib-cjs/component/NMRium.js +0 -267
- package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
- /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
- /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Filters } from 'nmr-processing';
|
|
3
|
-
import {
|
|
4
|
-
import { Checkbox } from 'react-science/ui';
|
|
3
|
+
import { memo, useRef } from 'react';
|
|
5
4
|
import generateNumbersPowerOfX from '../../data/utilities/generateNumbersPowerOfX';
|
|
6
5
|
import { useDispatch } from '../context/DispatchContext';
|
|
7
6
|
import ActionButtons from '../elements/ActionButtons';
|
|
8
7
|
import Label from '../elements/Label';
|
|
9
|
-
import Select from '../elements/Select';
|
|
10
8
|
import { useFilter } from '../hooks/useFilter';
|
|
11
9
|
import useSpectrum from '../hooks/useSpectrum';
|
|
12
10
|
import { headerLabelStyle } from './Header';
|
|
13
11
|
import { HeaderContainer } from './HeaderContainer';
|
|
12
|
+
import { Formik } from 'formik';
|
|
13
|
+
import FormikSelect from '../elements/formik/FormikSelect';
|
|
14
|
+
import FormikCheckBox from '../elements/formik/FormikCheckBox';
|
|
15
|
+
import FormikOnChange from '../elements/formik/FormikOnChange';
|
|
14
16
|
const Sizes = generateNumbersPowerOfX(8, 21);
|
|
15
17
|
function useInitZeroFillingSize() {
|
|
16
18
|
const filter = useFilter(Filters.zeroFilling.id);
|
|
@@ -24,40 +26,44 @@ function useInitZeroFillingSize() {
|
|
|
24
26
|
return 0;
|
|
25
27
|
}
|
|
26
28
|
function ZeroFillingOptionsInnerPanel(props) {
|
|
29
|
+
const { size } = props;
|
|
27
30
|
const dispatch = useDispatch();
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
const previousPreviewRef = useRef(true);
|
|
32
|
+
function handleApplyFilter(values, triggerSource = 'apply') {
|
|
33
|
+
const { livePreview, ...options } = values;
|
|
34
|
+
switch (triggerSource) {
|
|
35
|
+
case 'onChange': {
|
|
36
|
+
if (livePreview || previousPreviewRef !== livePreview) {
|
|
37
|
+
dispatch({
|
|
38
|
+
type: 'CALCULATE_ZERO_FILLING_FILTER',
|
|
39
|
+
payload: {
|
|
40
|
+
options,
|
|
41
|
+
livePreview,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'apply': {
|
|
48
|
+
dispatch({
|
|
49
|
+
type: 'APPLY_ZERO_FILLING_FILTER',
|
|
50
|
+
payload: {
|
|
51
|
+
options,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
default:
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
previousPreviewRef.current = livePreview;
|
|
37
60
|
}
|
|
38
61
|
function handleCancelFilter() {
|
|
39
62
|
dispatch({
|
|
40
63
|
type: 'RESET_SELECTED_TOOL',
|
|
41
64
|
});
|
|
42
65
|
}
|
|
43
|
-
|
|
44
|
-
dispatch({
|
|
45
|
-
type: 'CALCULATE_ZERO_FILLING_FILTER',
|
|
46
|
-
payload: {
|
|
47
|
-
nbPoints,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function handleChangeSizeHandler(value) {
|
|
52
|
-
setSize(value);
|
|
53
|
-
}
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (livePreview && size) {
|
|
56
|
-
dispatchLiveChanges(size);
|
|
57
|
-
}
|
|
58
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
-
}, [size, livePreview]);
|
|
60
|
-
return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Size: ", style: headerLabelStyle, children: _jsx(Select, { items: Sizes, style: { marginLeft: 10, marginRight: 10 }, value: size, onChange: handleChangeSizeHandler }) }), _jsx(Checkbox, { label: "Live preview", checked: livePreview, onChange: setLivePreview }), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
|
|
66
|
+
return (_jsx(HeaderContainer, { children: _jsx(Formik, { onSubmit: (values) => handleApplyFilter(values), initialValues: { nbPoints: size, livePreview: true }, children: ({ submitForm }) => (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Size: ", style: headerLabelStyle, children: _jsx(FormikSelect, { items: Sizes, style: { marginLeft: 10, marginRight: 10 }, name: "nbPoints" }) }), _jsx(Label, { title: "Live preview ", htmlFor: "livePreview", style: { label: { padding: '0 5px' } }, children: _jsx(FormikCheckBox, { name: "livePreview" }) }), _jsx(FormikOnChange, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true }), _jsx(ActionButtons, { onDone: submitForm, onCancel: handleCancelFilter })] })) }) }));
|
|
61
67
|
}
|
|
62
68
|
const MemoizedZeroFillingOptionsPanel = memo(ZeroFillingOptionsInnerPanel);
|
|
63
69
|
export default function ZeroFillingOptionsPanel() {
|
|
@@ -7,6 +7,7 @@ export declare enum HighlightEventSource {
|
|
|
7
7
|
SIGNAL = "SIGNAL",
|
|
8
8
|
RANGE = "RANGE",
|
|
9
9
|
ZONE = "ZONE",
|
|
10
|
+
BASELINE_ZONE = "BASELINE_ZONE",
|
|
10
11
|
EXCLUSION_ZONE = "EXCLUSION_ZONE",
|
|
11
12
|
MATRIX_GENERATION_EXCLUSION_ZONE = "MATRIX_GENERATION_EXCLUSION_ZONE",
|
|
12
13
|
MULTIPLE_ANALYSIS_ZONE = "MULTIPLE_ANALYSIS_ZONE",
|
|
@@ -7,6 +7,7 @@ export var HighlightEventSource;
|
|
|
7
7
|
HighlightEventSource["SIGNAL"] = "SIGNAL";
|
|
8
8
|
HighlightEventSource["RANGE"] = "RANGE";
|
|
9
9
|
HighlightEventSource["ZONE"] = "ZONE";
|
|
10
|
+
HighlightEventSource["BASELINE_ZONE"] = "BASELINE_ZONE";
|
|
10
11
|
HighlightEventSource["EXCLUSION_ZONE"] = "EXCLUSION_ZONE";
|
|
11
12
|
HighlightEventSource["MATRIX_GENERATION_EXCLUSION_ZONE"] = "MATRIX_GENERATION_EXCLUSION_ZONE";
|
|
12
13
|
HighlightEventSource["MULTIPLE_ANALYSIS_ZONE"] = "MULTIPLE_ANALYSIS_ZONE";
|
|
@@ -3,24 +3,28 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import { useChartData } from '../context/ChartContext';
|
|
4
4
|
import { usePreferences } from '../context/PreferencesContext';
|
|
5
5
|
import { options } from '../toolbar/ToolTypes';
|
|
6
|
+
import useCheckExperimentalFeature from './useCheckExperimentalFeature';
|
|
6
7
|
import useSpectrum from './useSpectrum';
|
|
7
8
|
export function useCheckToolsVisibility() {
|
|
8
9
|
const { displayerMode } = useChartData();
|
|
9
10
|
const preferences = usePreferences();
|
|
10
11
|
const spectrum = useSpectrum(null);
|
|
12
|
+
const isExperimentalFeatureActivated = useCheckExperimentalFeature();
|
|
11
13
|
return useCallback((toolKey, checkOptions = {}) => {
|
|
12
14
|
const { checkMode = true, checkSpectrumType = true, extraInfoCheckParameters, } = checkOptions;
|
|
15
|
+
const { spectraOptions, mode, isExperimental } = options[toolKey];
|
|
13
16
|
const flag = lodashGet(preferences.current, `display.toolBarButtons.${toolKey}`, false);
|
|
14
|
-
const { spectraOptions, mode } = options[toolKey];
|
|
15
17
|
const modeFlag = !checkMode || (checkMode && (!mode || displayerMode === mode));
|
|
16
18
|
const spectrumCheckFlag = !checkSpectrumType ||
|
|
17
19
|
(checkSpectrumType && checkSpectrum(spectrum, spectraOptions));
|
|
18
|
-
|
|
20
|
+
const isToolActivated = (flag && !isExperimental) ||
|
|
21
|
+
(isExperimental && isExperimentalFeatureActivated);
|
|
22
|
+
return (isToolActivated &&
|
|
19
23
|
modeFlag &&
|
|
20
24
|
spectrumCheckFlag &&
|
|
21
25
|
(!extraInfoCheckParameters ||
|
|
22
26
|
checkInfo(extraInfoCheckParameters, spectrum?.info)));
|
|
23
|
-
}, [displayerMode, preferences, spectrum]);
|
|
27
|
+
}, [displayerMode, isExperimentalFeatureActivated, preferences, spectrum]);
|
|
24
28
|
}
|
|
25
29
|
function checkSpectrum(spectrum, options) {
|
|
26
30
|
let outerConditionResult = false;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useChartData } from '../context/ChartContext';
|
|
2
|
+
import { useKeyModifiers } from '../context/KeyModifierContext';
|
|
3
|
+
export function useResizerStatus(toolKey) {
|
|
4
|
+
const { toolOptions: { selectedTool }, } = useChartData();
|
|
5
|
+
const { shiftKey } = useKeyModifiers();
|
|
6
|
+
return !shiftKey && selectedTool === toolKey;
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ export default function useSpectrum(defaultValue = null) {
|
|
|
5
5
|
const { data } = useChartData();
|
|
6
6
|
const activeSpectrum = useActiveSpectrum();
|
|
7
7
|
return useMemo(() => {
|
|
8
|
-
if (data && activeSpectrum
|
|
8
|
+
if (data && activeSpectrum?.id) {
|
|
9
9
|
const datum = data.find((datum) => datum.id === activeSpectrum.id) || defaultValue;
|
|
10
10
|
return datum;
|
|
11
11
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
const WrongP = styled.p `
|
|
4
|
+
background-color: white;
|
|
5
|
+
padding: 20px;
|
|
6
|
+
border-radius: 10px;
|
|
7
|
+
font-size: 30px;
|
|
8
|
+
text-align: center;
|
|
9
|
+
`;
|
|
10
|
+
const Details = styled.details `
|
|
11
|
+
margin-top: 10px;
|
|
12
|
+
white-space: pre-wrap;
|
|
13
|
+
background-color: white;
|
|
14
|
+
padding: 20px;
|
|
15
|
+
border-radius: 10px;
|
|
16
|
+
color: red;
|
|
17
|
+
`;
|
|
18
|
+
export default function ErrorOverlay(props) {
|
|
19
|
+
return (_jsxs("div", { style: { margin: 25 }, children: [_jsx(WrongP, { children: "Something went wrong." }), _jsxs(Details, { children: [_jsx("p", { style: { textDecoration: 'underline' }, children: props.error.message }), props.error.stack] })] }));
|
|
20
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ForwardedRef } from 'react';
|
|
2
|
+
import type { NMRiumProps, NMRiumRef } from './NMRium';
|
|
3
|
+
type InnerNMRiumProps = Omit<NMRiumProps, 'onError'> & {
|
|
4
|
+
innerRef: ForwardedRef<NMRiumRef>;
|
|
5
|
+
};
|
|
6
|
+
export declare function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner, onChange, emptyText, innerRef, }: InnerNMRiumProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useReducer, useRef, useImperativeHandle, } from 'react';
|
|
3
|
+
import { useOnOff } from 'react-science/ui';
|
|
4
|
+
import { useFullscreen } from 'react-use';
|
|
5
|
+
import { AssignmentProvider } from '../assignment';
|
|
6
|
+
import { GlobalProvider } from '../context/GlobalContext';
|
|
7
|
+
import { KeyModifiersProvider } from '../context/KeyModifierContext';
|
|
8
|
+
import { LoggerProvider } from '../context/LoggerContext';
|
|
9
|
+
import { PreferencesProvider } from '../context/PreferencesContext';
|
|
10
|
+
import { AlertProvider } from '../elements/popup/Alert';
|
|
11
|
+
import { ModalProvider } from '../elements/popup/Modal';
|
|
12
|
+
import { HighlightProvider } from '../highlight';
|
|
13
|
+
import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
|
|
14
|
+
import preferencesReducer, { preferencesInitialState, initPreferencesState, } from '../reducer/preferences/preferencesReducer';
|
|
15
|
+
import { getBlob } from '../utility/export';
|
|
16
|
+
import { InnerNMRiumContents } from './InnerNMRiumContents';
|
|
17
|
+
import NMRiumStateProvider from './NMRiumStateProvider';
|
|
18
|
+
export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner = defaultGetSpinner, onChange, emptyText, innerRef, }) {
|
|
19
|
+
const rootRef = useRef(null);
|
|
20
|
+
const elementsWrapperRef = useRef(null);
|
|
21
|
+
const viewerRef = useRef(null);
|
|
22
|
+
const [enableFullscreen, , disableFullscreen, toggleFullscreen] = useOnOff(false);
|
|
23
|
+
const mainDivRef = useRef(null);
|
|
24
|
+
const isFullscreenEnabled = useFullscreen(rootRef, enableFullscreen, {
|
|
25
|
+
onClose: disableFullscreen,
|
|
26
|
+
});
|
|
27
|
+
const [preferencesState, dispatchPreferences] = useReducer(preferencesReducer, preferencesInitialState, initPreferencesState);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
rootRef.current?.focus();
|
|
30
|
+
}, [isFullscreenEnabled]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
dispatchPreferences({
|
|
33
|
+
type: 'INIT_PREFERENCES',
|
|
34
|
+
payload: {
|
|
35
|
+
preferences,
|
|
36
|
+
workspace,
|
|
37
|
+
customWorkspaces,
|
|
38
|
+
dispatch: dispatchPreferences,
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}, [customWorkspaces, preferences, workspace]);
|
|
42
|
+
useImperativeHandle(innerRef, () => ({
|
|
43
|
+
getSpectraViewerAsBlob: () => {
|
|
44
|
+
return rootRef?.current ? getBlob(rootRef.current, 'nmrSVG') : null;
|
|
45
|
+
},
|
|
46
|
+
}), []);
|
|
47
|
+
return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(GlobalProvider, { value: {
|
|
48
|
+
rootRef: rootRef.current,
|
|
49
|
+
elementsWrapperRef: elementsWrapperRef.current,
|
|
50
|
+
viewerRef: viewerRef.current,
|
|
51
|
+
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }));
|
|
52
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
import { NMRiumProps } from '.';
|
|
4
|
+
interface InnerNMRiumContentsProps {
|
|
5
|
+
isFullscreenEnabled: boolean;
|
|
6
|
+
toggleFullscreen: () => void;
|
|
7
|
+
emptyText: NMRiumProps['emptyText'];
|
|
8
|
+
mainDivRef: RefObject<HTMLDivElement>;
|
|
9
|
+
elementsWrapperRef: RefObject<HTMLDivElement>;
|
|
10
|
+
rootRef: RefObject<HTMLDivElement>;
|
|
11
|
+
viewerRef: RefObject<HTMLDivElement>;
|
|
12
|
+
}
|
|
13
|
+
export declare function InnerNMRiumContents(props: InnerNMRiumContentsProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
|
|
6
|
+
import Viewer1D from '../1d/Viewer1D';
|
|
7
|
+
import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures';
|
|
8
|
+
import Viewer2D from '../2d/Viewer2D';
|
|
9
|
+
import KeysListenerTracker from '../EventsTrackers/KeysListenerTracker';
|
|
10
|
+
import { useChartData } from '../context/ChartContext';
|
|
11
|
+
import Header from '../header/Header';
|
|
12
|
+
import DropZone from '../loader/DropZone';
|
|
13
|
+
import Panels from '../panels/Panels';
|
|
14
|
+
import { DISPLAYER_MODE } from '../reducer/core/Constants';
|
|
15
|
+
import ToolBar from '../toolbar/ToolBar';
|
|
16
|
+
import { SplitPaneWrapper } from './SplitPaneWrapper';
|
|
17
|
+
import { StateError } from './StateError';
|
|
18
|
+
const viewerContainerStyle = css `
|
|
19
|
+
border: 0.55px #e6e6e6 solid;
|
|
20
|
+
display: flex;
|
|
21
|
+
flex: 1;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
height: 100%;
|
|
24
|
+
margin-left: -1px;
|
|
25
|
+
`;
|
|
26
|
+
const containerStyles = css `
|
|
27
|
+
background-color: white;
|
|
28
|
+
width: 100%;
|
|
29
|
+
display: block;
|
|
30
|
+
height: 100%;
|
|
31
|
+
|
|
32
|
+
div:focus {
|
|
33
|
+
outline: none !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
button {
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
button,
|
|
41
|
+
button:active,
|
|
42
|
+
button:hover,
|
|
43
|
+
button:focus,
|
|
44
|
+
[type='button']:focus {
|
|
45
|
+
outline: none !important;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
button:disabled {
|
|
49
|
+
cursor: default;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
* {
|
|
53
|
+
-webkit-user-drag: none;
|
|
54
|
+
-moz-user-drag: none;
|
|
55
|
+
-o-user-drag: none;
|
|
56
|
+
user-select: none;
|
|
57
|
+
}
|
|
58
|
+
`;
|
|
59
|
+
export function InnerNMRiumContents(props) {
|
|
60
|
+
const { isFullscreenEnabled, toggleFullscreen, emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef, } = props;
|
|
61
|
+
const { displayerMode } = useChartData();
|
|
62
|
+
const preventContextMenuHandler = useCallback((e) => {
|
|
63
|
+
if (!checkModifierKeyActivated(e)) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
}
|
|
66
|
+
}, []);
|
|
67
|
+
return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
|
|
68
|
+
display: 'flex',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
backgroundColor: 'white',
|
|
71
|
+
width: '100%',
|
|
72
|
+
}, children: [_jsx(Header, { isFullscreenEnabled: isFullscreenEnabled, onEnableFullscreen: toggleFullscreen }), _jsxs("div", { style: {
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'row',
|
|
75
|
+
height: '100%',
|
|
76
|
+
}, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, { mainDivRef: mainDivRef }), _jsxs("div", { id: "nmrium-viewer", "data-testid": "viewer", ref: viewerRef, style: {
|
|
77
|
+
width: '100%',
|
|
78
|
+
height: '100%',
|
|
79
|
+
position: 'relative',
|
|
80
|
+
}, children: [_jsx(FloatMoleculeStructures, {}), displayerMode === DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
|
|
81
|
+
position: 'absolute',
|
|
82
|
+
pointerEvents: 'none',
|
|
83
|
+
zIndex: 2,
|
|
84
|
+
left: 0,
|
|
85
|
+
right: 0,
|
|
86
|
+
top: 0,
|
|
87
|
+
bottom: 0,
|
|
88
|
+
} }, String(isFullscreenEnabled))] })] }) }) })] }));
|
|
89
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CustomWorkspaces, WorkspacePreferences as NMRiumPreferences } from 'nmr-load-save';
|
|
2
|
+
import { ReactElement, ReactNode } from 'react';
|
|
3
|
+
import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
|
|
4
|
+
import { BlobObject } from '../utility/export';
|
|
5
|
+
import { NMRiumChangeCb, NMRiumData, NMRiumWorkspace } from './types';
|
|
6
|
+
export interface NMRiumProps {
|
|
7
|
+
data?: NMRiumData;
|
|
8
|
+
onChange?: NMRiumChangeCb;
|
|
9
|
+
noErrorBoundary?: boolean;
|
|
10
|
+
onError?: ErrorBoundaryPropsWithComponent['onError'];
|
|
11
|
+
workspace?: NMRiumWorkspace;
|
|
12
|
+
customWorkspaces?: CustomWorkspaces;
|
|
13
|
+
preferences?: NMRiumPreferences;
|
|
14
|
+
emptyText?: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Returns a custom spinner that will be rendered while loading data.
|
|
17
|
+
*/
|
|
18
|
+
getSpinner?: () => ReactElement;
|
|
19
|
+
}
|
|
20
|
+
export interface NMRiumRef {
|
|
21
|
+
getSpectraViewerAsBlob: () => BlobObject | null;
|
|
22
|
+
}
|
|
23
|
+
export declare const NMRium: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<NMRiumProps & import("react").RefAttributes<NMRiumRef>>>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, forwardRef } from 'react';
|
|
3
|
+
import { ErrorBoundary, } from 'react-error-boundary';
|
|
4
|
+
import { RootLayout } from 'react-science/ui';
|
|
5
|
+
import ErrorOverlay from './ErrorOverlay';
|
|
6
|
+
import { InnerNMRium } from './InnerNMRium';
|
|
7
|
+
const NMRiumBase = forwardRef(function NMRium(props, ref) {
|
|
8
|
+
const { noErrorBoundary = false, onError, ...otherProps } = props;
|
|
9
|
+
const innerNmrium = _jsx(InnerNMRium, { ...otherProps, innerRef: ref });
|
|
10
|
+
const children = noErrorBoundary ? (innerNmrium) : (_jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, onError: onError, children: innerNmrium }));
|
|
11
|
+
return _jsx(RootLayout, { style: { width: '100%' }, children: children });
|
|
12
|
+
});
|
|
13
|
+
export const NMRium = memo(NMRiumBase);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { NMRiumChangeCb, NMRiumData } from './types';
|
|
3
|
+
interface NMRiumStateProviderProps {
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
onChange: NMRiumChangeCb | undefined;
|
|
6
|
+
nmriumData: NMRiumData | undefined;
|
|
7
|
+
}
|
|
8
|
+
export default function NMRiumStateProvider(props: NMRiumStateProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { readNMRiumObject } from 'nmr-load-save';
|
|
3
|
+
import { useCallback, useEffect, useReducer, useRef } from 'react';
|
|
4
|
+
import { toJSON } from '../../data/SpectraManager';
|
|
5
|
+
import { ChartDataProvider } from '../context/ChartContext';
|
|
6
|
+
import { DispatchProvider } from '../context/DispatchContext';
|
|
7
|
+
import { useLogger } from '../context/LoggerContext';
|
|
8
|
+
import { usePreferences } from '../context/PreferencesContext';
|
|
9
|
+
import checkActionType from '../reducer/IgnoreActions';
|
|
10
|
+
import { spectrumReducer, initialState, initState } from '../reducer/Reducer';
|
|
11
|
+
const defaultData = {
|
|
12
|
+
spectra: [],
|
|
13
|
+
};
|
|
14
|
+
export default function NMRiumStateProvider(props) {
|
|
15
|
+
const { children, onChange, nmriumData = defaultData } = props;
|
|
16
|
+
const { logger } = useLogger();
|
|
17
|
+
const preferencesState = usePreferences();
|
|
18
|
+
const [state, dispatchRaw] = useReducer(spectrumReducer, initialState, initState);
|
|
19
|
+
const dispatch = useCallback((action) => {
|
|
20
|
+
logger.trace({ action }, `Dispatch main reducer action: ${action.type}`);
|
|
21
|
+
dispatchRaw(action);
|
|
22
|
+
}, [logger]);
|
|
23
|
+
const { source, data: spectraData, molecules, correlations, actionType, view, } = state;
|
|
24
|
+
const stateRef = useRef();
|
|
25
|
+
const handleChange = useRef(onChange);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
handleChange.current = onChange;
|
|
28
|
+
}, [onChange]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const { workspace, workspaces = {} } = preferencesState;
|
|
31
|
+
stateRef.current = toJSON({ data: spectraData, molecules, correlations, source, view, actionType }, { current: workspaces[workspace.current] }, { serialize: false, exportTarget: 'onChange' });
|
|
32
|
+
}, [
|
|
33
|
+
actionType,
|
|
34
|
+
correlations,
|
|
35
|
+
molecules,
|
|
36
|
+
preferencesState,
|
|
37
|
+
source,
|
|
38
|
+
spectraData,
|
|
39
|
+
view,
|
|
40
|
+
]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
// trigger onChange callback if data object changed
|
|
43
|
+
if (checkActionType(actionType)) {
|
|
44
|
+
handleChange.current?.(stateRef.current, 'data');
|
|
45
|
+
}
|
|
46
|
+
}, [actionType, correlations, molecules, source, spectraData]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
// trigger onChange callback if view object changed
|
|
49
|
+
handleChange.current?.(stateRef.current, 'view');
|
|
50
|
+
}, [view]);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
// trigger onChange callback if settings changed
|
|
53
|
+
handleChange.current?.(stateRef.current, 'settings');
|
|
54
|
+
}, [preferencesState]);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
dispatch({
|
|
57
|
+
type: 'SET_LOADING_FLAG',
|
|
58
|
+
payload: { isLoading: true },
|
|
59
|
+
});
|
|
60
|
+
if (nmriumData) {
|
|
61
|
+
void readNMRiumObject(nmriumData)
|
|
62
|
+
.then((nmriumState) => {
|
|
63
|
+
dispatch({ type: 'INITIATE', payload: { nmriumState } });
|
|
64
|
+
})
|
|
65
|
+
.catch((error) => {
|
|
66
|
+
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
|
|
67
|
+
// eslint-disable-next-line no-alert
|
|
68
|
+
alert(error.message);
|
|
69
|
+
reportError(error);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, [nmriumData, dispatch]);
|
|
73
|
+
return (_jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: children }) }));
|
|
74
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { SplitPane } from 'react-science/ui';
|
|
3
|
-
import { usePreferences } from '
|
|
3
|
+
import { usePreferences } from '../context/PreferencesContext';
|
|
4
4
|
export function SplitPaneWrapper({ children }) {
|
|
5
5
|
const { current, dispatch } = usePreferences();
|
|
6
6
|
const { general: { verticalSplitterPosition, verticalSplitterCloseThreshold }, display: { general = {} }, } = current;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { useChartData } from '../context/ChartContext';
|
|
3
|
+
import { useLogger } from '../context/LoggerContext';
|
|
4
|
+
/**
|
|
5
|
+
* Alert user in UI when state have errorAction (error from reducer)
|
|
6
|
+
*/
|
|
7
|
+
export function StateError() {
|
|
8
|
+
const { errorAction } = useChartData();
|
|
9
|
+
const { logger } = useLogger();
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (!errorAction)
|
|
12
|
+
return;
|
|
13
|
+
logger.error(errorAction);
|
|
14
|
+
}, [errorAction, logger]);
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { WebSource } from 'filelist-utils';
|
|
2
|
+
import { CorrelationData } from 'nmr-correlation';
|
|
3
|
+
import type { NmriumState as NMRiumState, WorkspacePreferences as NMRiumPreferences, Spectrum } from 'nmr-load-save';
|
|
4
|
+
type DeepPartial<T> = {
|
|
5
|
+
[P in keyof T]?: DeepPartial<T[P]>;
|
|
6
|
+
};
|
|
7
|
+
interface NMRiumData {
|
|
8
|
+
source?: WebSource;
|
|
9
|
+
molecules?: NMRiumMolecules;
|
|
10
|
+
spectra: Array<DeepPartial<Spectrum>>;
|
|
11
|
+
correlations?: CorrelationData;
|
|
12
|
+
}
|
|
13
|
+
type NMRiumWorkspace = 'exercise' | 'process1D' | 'default' | 'prediction' | 'embedded' | 'assignment' | 'simulation' | (string & {});
|
|
14
|
+
type NMRiumChangeCb = (state: NMRiumState, source: 'data' | 'view' | 'settings') => void;
|
|
15
|
+
type NMRiumMolecules = Array<{
|
|
16
|
+
molfile: string;
|
|
17
|
+
}>;
|
|
18
|
+
export type { NMRiumChangeCb, NMRiumData, NMRiumMolecules, NMRiumPreferences, NMRiumState, NMRiumWorkspace, };
|
|
@@ -74,7 +74,7 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
74
74
|
closeDialog();
|
|
75
75
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
76
76
|
try {
|
|
77
|
-
const data = await predictSpectra(molfile);
|
|
77
|
+
const data = await predictSpectra(molfile, values.spectra);
|
|
78
78
|
dispatch({
|
|
79
79
|
type: 'PREDICT_SPECTRA',
|
|
80
80
|
payload: {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} | {
|
|
6
|
-
moleculeId: string;
|
|
7
|
-
mf: string;
|
|
8
|
-
sumAuto: true;
|
|
9
|
-
};
|
|
10
|
-
interface ChangeSumModalProps {
|
|
11
|
-
onSave: (saveInput: SaveInput) => void;
|
|
12
|
-
onClose: () => void;
|
|
13
|
-
header: string;
|
|
14
|
-
sumOptions: SumOptions;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChangeSumModalContentsProps } from './ChangeSumModalContents';
|
|
3
|
+
export interface ChangeSumModalProps extends Omit<ChangeSumModalContentsProps, 'onClose'> {
|
|
4
|
+
renderButton: (onClick: () => void) => ReactNode;
|
|
15
5
|
}
|
|
16
|
-
export default function ChangeSumModal({
|
|
17
|
-
export {};
|
|
6
|
+
export default function ChangeSumModal({ renderButton, ...otherProps }: ChangeSumModalProps): import("react/jsx-runtime").JSX.Element;
|