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
package/lib/component/NMRium.js
DELETED
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
-
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { readNMRiumObject, } from 'nmr-load-save';
|
|
5
|
-
import { useEffect, useCallback, useReducer, useRef, memo, forwardRef, useImperativeHandle, } from 'react';
|
|
6
|
-
import { ErrorBoundary, } from 'react-error-boundary';
|
|
7
|
-
import { RootLayout, useOnOff } from 'react-science/ui';
|
|
8
|
-
import { useFullscreen } from 'react-use';
|
|
9
|
-
import { toJSON } from '../data/SpectraManager';
|
|
10
|
-
import checkModifierKeyActivated from '../data/utilities/checkModifierKeyActivated';
|
|
11
|
-
import Viewer1D from './1d/Viewer1D';
|
|
12
|
-
import FloatMoleculeStructures from './1d-2d/components/FloatMoleculeStructures';
|
|
13
|
-
import Viewer2D from './2d/Viewer2D';
|
|
14
|
-
import ErrorOverlay from './ErrorOverlay';
|
|
15
|
-
import KeysListenerTracker from './EventsTrackers/KeysListenerTracker';
|
|
16
|
-
import { SplitPaneWrapper } from './SplitPaneWrapper';
|
|
17
|
-
import { AssignmentProvider } from './assignment';
|
|
18
|
-
import { ChartDataProvider, useChartData } from './context/ChartContext';
|
|
19
|
-
import { DispatchProvider } from './context/DispatchContext';
|
|
20
|
-
import { GlobalProvider } from './context/GlobalContext';
|
|
21
|
-
import { LoggerProvider, useLogger } from './context/LoggerContext';
|
|
22
|
-
import { PreferencesProvider } from './context/PreferencesContext';
|
|
23
|
-
import { AlertProvider } from './elements/popup/Alert';
|
|
24
|
-
import { ModalProvider } from './elements/popup/Modal';
|
|
25
|
-
import Header from './header/Header';
|
|
26
|
-
import { HighlightProvider } from './highlight';
|
|
27
|
-
import DropZone from './loader/DropZone';
|
|
28
|
-
import { defaultGetSpinner, SpinnerProvider } from './loader/SpinnerContext';
|
|
29
|
-
import Panels from './panels/Panels';
|
|
30
|
-
import checkActionType from './reducer/IgnoreActions';
|
|
31
|
-
import { spectrumReducer, initialState, initState } from './reducer/Reducer';
|
|
32
|
-
import { DISPLAYER_MODE } from './reducer/core/Constants';
|
|
33
|
-
import preferencesReducer, { preferencesInitialState, initPreferencesState, } from './reducer/preferences/preferencesReducer';
|
|
34
|
-
import ToolBar from './toolbar/ToolBar';
|
|
35
|
-
import { getBlob } from './utility/export';
|
|
36
|
-
const viewerContainerStyle = css `
|
|
37
|
-
border: 0.55px #e6e6e6 solid;
|
|
38
|
-
display: flex;
|
|
39
|
-
flex: 1;
|
|
40
|
-
flex-direction: column;
|
|
41
|
-
height: 100%;
|
|
42
|
-
margin-left: -1px;
|
|
43
|
-
`;
|
|
44
|
-
const containerStyles = css `
|
|
45
|
-
background-color: white;
|
|
46
|
-
width: 100%;
|
|
47
|
-
display: block;
|
|
48
|
-
height: 100%;
|
|
49
|
-
|
|
50
|
-
div:focus {
|
|
51
|
-
outline: none !important;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
button {
|
|
55
|
-
cursor: pointer;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
button,
|
|
59
|
-
button:active,
|
|
60
|
-
button:hover,
|
|
61
|
-
button:focus,
|
|
62
|
-
[type='button']:focus {
|
|
63
|
-
outline: none !important;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
button:disabled {
|
|
67
|
-
cursor: default;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
* {
|
|
71
|
-
-webkit-user-drag: none;
|
|
72
|
-
-moz-user-drag: none;
|
|
73
|
-
-o-user-drag: none;
|
|
74
|
-
user-select: none;
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
export { serializeNmriumState } from 'nmr-load-save';
|
|
78
|
-
const defaultData = {
|
|
79
|
-
spectra: [],
|
|
80
|
-
};
|
|
81
|
-
const NMRium = forwardRef(function NMRium(props, ref) {
|
|
82
|
-
const { noErrorBoundary = false, onError, ...otherProps } = props;
|
|
83
|
-
const innerNmrium = _jsx(InnerNMRium, { ...otherProps, innerRef: ref });
|
|
84
|
-
const children = noErrorBoundary ? (innerNmrium) : (_jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, onError: onError, children: innerNmrium }));
|
|
85
|
-
return _jsx(RootLayout, { style: { width: '100%' }, children: children });
|
|
86
|
-
});
|
|
87
|
-
function InnerNMRium({ data: dataProp = defaultData, workspace, customWorkspaces, preferences, getSpinner = defaultGetSpinner, onChange, emptyText, innerRef, }) {
|
|
88
|
-
const rootRef = useRef(null);
|
|
89
|
-
const elementsWrapperRef = useRef(null);
|
|
90
|
-
const viewerRef = useRef(null);
|
|
91
|
-
const [show, , setOff, toggle] = useOnOff(false);
|
|
92
|
-
const mainDivRef = useRef(null);
|
|
93
|
-
const handleChange = useRef(onChange);
|
|
94
|
-
useEffect(() => {
|
|
95
|
-
handleChange.current = onChange;
|
|
96
|
-
}, [onChange]);
|
|
97
|
-
const isFullscreen = useFullscreen(rootRef, show, {
|
|
98
|
-
onClose: setOff,
|
|
99
|
-
});
|
|
100
|
-
const [state, dispatch] = useReducer(spectrumReducer, initialState, initState);
|
|
101
|
-
const [preferencesState, dispatchPreferences] = useReducer(preferencesReducer, preferencesInitialState, initPreferencesState);
|
|
102
|
-
const { displayerMode, source, data: spectraData, molecules, correlations, actionType, view, } = state;
|
|
103
|
-
const stateRef = useRef();
|
|
104
|
-
useEffect(() => {
|
|
105
|
-
const { workspace, workspaces = {} } = preferencesState;
|
|
106
|
-
stateRef.current = toJSON({ data: spectraData, molecules, correlations, source, view, actionType }, { current: workspaces[workspace.current] }, { serialize: false, exportTarget: 'onChange' });
|
|
107
|
-
}, [
|
|
108
|
-
actionType,
|
|
109
|
-
correlations,
|
|
110
|
-
molecules,
|
|
111
|
-
preferencesState,
|
|
112
|
-
source,
|
|
113
|
-
spectraData,
|
|
114
|
-
view,
|
|
115
|
-
]);
|
|
116
|
-
useEffect(() => {
|
|
117
|
-
// trigger onChange callback if data object changed
|
|
118
|
-
if (checkActionType(actionType)) {
|
|
119
|
-
handleChange.current?.(stateRef.current, 'data');
|
|
120
|
-
}
|
|
121
|
-
}, [actionType, correlations, molecules, source, spectraData]);
|
|
122
|
-
useEffect(() => {
|
|
123
|
-
// trigger onChange callback if view object changed
|
|
124
|
-
handleChange.current?.(stateRef.current, 'view');
|
|
125
|
-
}, [view]);
|
|
126
|
-
useEffect(() => {
|
|
127
|
-
// trigger onChange callback if settings changed
|
|
128
|
-
handleChange.current?.(stateRef.current, 'settings');
|
|
129
|
-
}, [preferencesState]);
|
|
130
|
-
useEffect(() => {
|
|
131
|
-
rootRef.current?.focus();
|
|
132
|
-
}, [isFullscreen]);
|
|
133
|
-
useEffect(() => {
|
|
134
|
-
dispatchPreferences({
|
|
135
|
-
type: 'INIT_PREFERENCES',
|
|
136
|
-
payload: {
|
|
137
|
-
preferences,
|
|
138
|
-
workspace,
|
|
139
|
-
customWorkspaces,
|
|
140
|
-
dispatch: dispatchPreferences,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
}, [customWorkspaces, preferences, workspace]);
|
|
144
|
-
useImperativeHandle(innerRef, () => ({
|
|
145
|
-
getSpectraViewerAsBlob: () => {
|
|
146
|
-
return rootRef?.current ? getBlob(rootRef.current, 'nmrSVG') : null;
|
|
147
|
-
},
|
|
148
|
-
}), []);
|
|
149
|
-
useEffect(() => {
|
|
150
|
-
dispatch({
|
|
151
|
-
type: 'SET_LOADING_FLAG',
|
|
152
|
-
payload: { isLoading: true },
|
|
153
|
-
});
|
|
154
|
-
if (dataProp) {
|
|
155
|
-
void readNMRiumObject(dataProp)
|
|
156
|
-
.then((nmriumState) => {
|
|
157
|
-
dispatch({ type: 'INITIATE', payload: { nmriumState } });
|
|
158
|
-
})
|
|
159
|
-
.catch((error) => {
|
|
160
|
-
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
|
|
161
|
-
// eslint-disable-next-line no-alert
|
|
162
|
-
alert(error.message);
|
|
163
|
-
reportError(error);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}, [dataProp]);
|
|
167
|
-
const preventContextMenuHandler = useCallback((e) => {
|
|
168
|
-
if (!checkModifierKeyActivated(e)) {
|
|
169
|
-
e.preventDefault();
|
|
170
|
-
}
|
|
171
|
-
}, []);
|
|
172
|
-
useEffect(() => {
|
|
173
|
-
const div = mainDivRef.current;
|
|
174
|
-
if (!div) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
function mouseEnterHandler() {
|
|
178
|
-
dispatch({
|
|
179
|
-
type: 'SET_MOUSE_OVER_DISPLAYER',
|
|
180
|
-
payload: { isMouseOverDisplayer: true },
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
function mouseLeaveHandler() {
|
|
184
|
-
dispatch({
|
|
185
|
-
type: 'SET_MOUSE_OVER_DISPLAYER',
|
|
186
|
-
payload: { isMouseOverDisplayer: false },
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
div.addEventListener('mouseenter', mouseEnterHandler);
|
|
190
|
-
div.addEventListener('mouseleave', mouseLeaveHandler);
|
|
191
|
-
return () => {
|
|
192
|
-
div.removeEventListener('mouseenter', mouseEnterHandler);
|
|
193
|
-
div.removeEventListener('mouseleave', mouseLeaveHandler);
|
|
194
|
-
};
|
|
195
|
-
}, []);
|
|
196
|
-
return (_jsx(GlobalProvider, { value: {
|
|
197
|
-
rootRef: rootRef.current,
|
|
198
|
-
elementsWrapperRef: elementsWrapperRef.current,
|
|
199
|
-
viewerRef: viewerRef.current,
|
|
200
|
-
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(LoggerProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children: _jsxs(SpinnerProvider, { value: getSpinner, 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: {
|
|
201
|
-
display: 'flex',
|
|
202
|
-
flexDirection: 'column',
|
|
203
|
-
backgroundColor: 'white',
|
|
204
|
-
width: '100%',
|
|
205
|
-
}, children: [_jsx(Header, { isFullscreen: isFullscreen, onMaximize: toggle }), _jsxs("div", { style: {
|
|
206
|
-
display: 'flex',
|
|
207
|
-
flexDirection: 'row',
|
|
208
|
-
height: '100%',
|
|
209
|
-
}, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, {}), _jsxs("div", { id: "nmrium-viewer", "data-test-id": "viewer", ref: viewerRef, style: {
|
|
210
|
-
width: '100%',
|
|
211
|
-
height: '100%',
|
|
212
|
-
position: 'relative',
|
|
213
|
-
}, children: [_jsx(FloatMoleculeStructures, {}), displayerMode ===
|
|
214
|
-
DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
|
|
215
|
-
position: 'absolute',
|
|
216
|
-
pointerEvents: 'none',
|
|
217
|
-
zIndex: 2,
|
|
218
|
-
left: 0,
|
|
219
|
-
right: 0,
|
|
220
|
-
top: 0,
|
|
221
|
-
bottom: 0,
|
|
222
|
-
} }, String(isFullscreen))] })] }) }) })] }) }) }) }) }) }) }) }) }) }) }));
|
|
223
|
-
}
|
|
224
|
-
export default memo(NMRium);
|
|
225
|
-
/**
|
|
226
|
-
* Alert user in UI when state have errorAction (error from reducer)
|
|
227
|
-
*/
|
|
228
|
-
function StateError() {
|
|
229
|
-
const { errorAction } = useChartData();
|
|
230
|
-
const { logger } = useLogger();
|
|
231
|
-
useEffect(() => {
|
|
232
|
-
if (!errorAction)
|
|
233
|
-
return;
|
|
234
|
-
logger.error(errorAction);
|
|
235
|
-
}, [errorAction, logger]);
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Draft } from 'immer';
|
|
2
|
-
import { State } from '../Reducer';
|
|
3
|
-
import { ActionType } from '../types/ActionType';
|
|
4
|
-
type SetIsOverDisplayerAction = ActionType<'SET_MOUSE_OVER_DISPLAYER', {
|
|
5
|
-
isMouseOverDisplayer: boolean;
|
|
6
|
-
}>;
|
|
7
|
-
export type GlobalActions = SetIsOverDisplayerAction;
|
|
8
|
-
declare function handleSetIsOverDisplayer(draft: Draft<State>, action: SetIsOverDisplayerAction): void;
|
|
9
|
-
export { handleSetIsOverDisplayer };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
4
|
-
/** @jsxImportSource @emotion/react */
|
|
5
|
-
const react_1 = require("@emotion/react");
|
|
6
|
-
const react_2 = require("react");
|
|
7
|
-
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
8
|
-
const highlight_1 = require("../../highlight");
|
|
9
|
-
const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
|
|
10
|
-
const formatNumber_1 = require("../../utility/formatNumber");
|
|
11
|
-
const styles = (0, react_1.css) `
|
|
12
|
-
input {
|
|
13
|
-
user-select: text;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
input[type='number']::-webkit-outer-spin-button,
|
|
17
|
-
input[type='number']::-webkit-inner-spin-button {
|
|
18
|
-
appearance: none;
|
|
19
|
-
margin: 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
input[type='number'] {
|
|
23
|
-
appearance: textfield;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.notification-input-normal {
|
|
27
|
-
opacity: 1;
|
|
28
|
-
left: 4px;
|
|
29
|
-
position: fixed;
|
|
30
|
-
font-size: 10px;
|
|
31
|
-
outline: none;
|
|
32
|
-
background-color: transparent;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.notification-input-normal input:focus {
|
|
36
|
-
outline: none;
|
|
37
|
-
background-color: white;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.input-over {
|
|
41
|
-
background-color: white;
|
|
42
|
-
outline: none;
|
|
43
|
-
}
|
|
44
|
-
`;
|
|
45
|
-
function PeakAnnotation({ id, x, y, sign, // 1 positive -1 negative
|
|
46
|
-
value, color, nucleus, }) {
|
|
47
|
-
const refText = (0, react_2.useRef)(null);
|
|
48
|
-
const [isSelected, setIsSelected] = (0, react_2.useState)(false);
|
|
49
|
-
const [_value, setValue] = (0, react_2.useState)(value);
|
|
50
|
-
const [containerSize, setContainerSize] = (0, react_2.useState)({ width: 0, height: 0 });
|
|
51
|
-
const { deltaPPM } = (0, usePanelPreferences_1.usePanelPreferences)('peaks', nucleus);
|
|
52
|
-
const highlight = (0, highlight_1.useHighlight)([id], {
|
|
53
|
-
type: highlight_1.HighlightEventSource.PEAK,
|
|
54
|
-
extra: { id },
|
|
55
|
-
});
|
|
56
|
-
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
57
|
-
const handleOnPeakChange = (0, react_2.useCallback)((e) => dispatch({ type: 'SHIFT_SPECTRUM', payload: { shift: e.shiftValue } }), [dispatch]);
|
|
58
|
-
(0, react_2.useLayoutEffect)(() => {
|
|
59
|
-
const textBox = refText.current?.getBBox();
|
|
60
|
-
setContainerSize({
|
|
61
|
-
width: textBox?.width || 0,
|
|
62
|
-
height: textBox?.height || 0,
|
|
63
|
-
});
|
|
64
|
-
}, [isSelected]);
|
|
65
|
-
(0, react_2.useEffect)(() => {
|
|
66
|
-
setValue(value);
|
|
67
|
-
}, [value]);
|
|
68
|
-
const handleKeyDown = (0, react_2.useCallback)((event) => {
|
|
69
|
-
if (event.key === 'Enter') {
|
|
70
|
-
const newValue = event.currentTarget.valueAsNumber;
|
|
71
|
-
if (!Number.isNaN(newValue)) {
|
|
72
|
-
const shiftValue = newValue - value;
|
|
73
|
-
handleOnPeakChange({
|
|
74
|
-
id,
|
|
75
|
-
value: newValue,
|
|
76
|
-
oldValue: value,
|
|
77
|
-
shiftValue,
|
|
78
|
-
});
|
|
79
|
-
event.currentTarget.blur();
|
|
80
|
-
setIsSelected(false);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
else if (event.key === 'Escape') {
|
|
84
|
-
setValue(value);
|
|
85
|
-
event.currentTarget.blur();
|
|
86
|
-
setIsSelected(false);
|
|
87
|
-
}
|
|
88
|
-
}, [value, handleOnPeakChange, id]);
|
|
89
|
-
const handleChange = (0, react_2.useCallback)((event) => {
|
|
90
|
-
setValue(event.target.value);
|
|
91
|
-
}, []);
|
|
92
|
-
const handleSelectPeakAnnotation = (0, react_2.useCallback)((e) => {
|
|
93
|
-
e.stopPropagation();
|
|
94
|
-
setIsSelected(true);
|
|
95
|
-
return false;
|
|
96
|
-
}, []);
|
|
97
|
-
const handleOnEnterNotation = (0, react_2.useCallback)(() => {
|
|
98
|
-
highlight.show();
|
|
99
|
-
}, [highlight]);
|
|
100
|
-
const handleOnMouseLeaveNotation = (0, react_2.useCallback)(() => {
|
|
101
|
-
highlight.hide();
|
|
102
|
-
}, [highlight]);
|
|
103
|
-
const newValue = (0, react_2.useMemo)(() => (isSelected ? value : (0, formatNumber_1.formatNumber)(value, deltaPPM.format)), [deltaPPM.format, isSelected, value]);
|
|
104
|
-
const oldValue = (0, react_2.useMemo)(() => (isSelected ? _value : (0, formatNumber_1.formatNumber)(_value, deltaPPM.format)), [_value, deltaPPM.format, isSelected]);
|
|
105
|
-
return ((0, jsx_runtime_1.jsxs)("g", { css: styles, id: id, style: { outline: 'none' }, transform: `translate(${x}, ${y})`, onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: [(0, jsx_runtime_1.jsx)("line", { x1: "0", x2: "0", y1: sign === -1 ? 10 : 0, y2: sign === -1 ? 28 : -18, stroke: color, strokeWidth: highlight.isActive ? '7px' : '1px' }), (0, jsx_runtime_1.jsx)("text", { ref: refText, className: "peaks-text", x: "0", y: sign === -1 ? 28 : -12, dy: "0", dx: "0.35em", fill: "transparent", fontSize: "10px", fontWeight: "100", style: {
|
|
106
|
-
position: 'absolute',
|
|
107
|
-
}, children: newValue }), (0, jsx_runtime_1.jsx)("foreignObject", { x: "0", y: sign === -1 ? 16 : -22, dy: "0.1em", dx: "0.35em", width: containerSize.width + 20, height: "40px", "data-no-export": "true", children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
108
|
-
width: containerSize.width + 20,
|
|
109
|
-
height: '100%',
|
|
110
|
-
paddingRight: 5,
|
|
111
|
-
}, children: (0, jsx_runtime_1.jsx)("input", { onClick: handleSelectPeakAnnotation, className: isSelected ? 'input-over' : 'notification-input-normal', style: {
|
|
112
|
-
width: 'inherit',
|
|
113
|
-
border: isSelected ? `1px solid ${color}` : `0`,
|
|
114
|
-
userSelect: 'none',
|
|
115
|
-
color,
|
|
116
|
-
}, value: oldValue, onKeyDown: handleKeyDown, onChange: handleChange, type: "number" }) }) })] }));
|
|
117
|
-
}
|
|
118
|
-
exports.default = PeakAnnotation;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
-
const styles = {
|
|
5
|
-
container: {
|
|
6
|
-
margin: '25px',
|
|
7
|
-
},
|
|
8
|
-
header: {
|
|
9
|
-
backgroundColor: '#ffffff',
|
|
10
|
-
padding: '20px',
|
|
11
|
-
borderRadius: '10px',
|
|
12
|
-
fontSize: '30px',
|
|
13
|
-
textAlign: 'center',
|
|
14
|
-
},
|
|
15
|
-
title: {
|
|
16
|
-
textDecoration: 'underline',
|
|
17
|
-
},
|
|
18
|
-
body: {
|
|
19
|
-
marginTop: '10px',
|
|
20
|
-
whiteSpace: 'pre-wrap',
|
|
21
|
-
backgroundColor: 'white',
|
|
22
|
-
padding: '20px',
|
|
23
|
-
borderRadius: '10px',
|
|
24
|
-
color: 'red',
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
function ErrorOverlay(props) {
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: styles.container, children: [(0, jsx_runtime_1.jsx)("p", { style: styles.header, children: "Something went wrong." }), (0, jsx_runtime_1.jsxs)("details", { style: styles.body, children: [(0, jsx_runtime_1.jsx)("p", { style: styles.title, children: props.error.message }), props.error.stack] })] }));
|
|
29
|
-
}
|
|
30
|
-
exports.default = ErrorOverlay;
|
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.serializeNmriumState = void 0;
|
|
30
|
-
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
31
|
-
/** @jsxImportSource @emotion/react */
|
|
32
|
-
const react_1 = require("@emotion/react");
|
|
33
|
-
const nmr_load_save_1 = require("nmr-load-save");
|
|
34
|
-
const react_2 = require("react");
|
|
35
|
-
const react_error_boundary_1 = require("react-error-boundary");
|
|
36
|
-
const ui_1 = require("react-science/ui");
|
|
37
|
-
const react_use_1 = require("react-use");
|
|
38
|
-
const SpectraManager_1 = require("../data/SpectraManager");
|
|
39
|
-
const checkModifierKeyActivated_1 = __importDefault(require("../data/utilities/checkModifierKeyActivated"));
|
|
40
|
-
const Viewer1D_1 = __importDefault(require("./1d/Viewer1D"));
|
|
41
|
-
const FloatMoleculeStructures_1 = __importDefault(require("./1d-2d/components/FloatMoleculeStructures"));
|
|
42
|
-
const Viewer2D_1 = __importDefault(require("./2d/Viewer2D"));
|
|
43
|
-
const ErrorOverlay_1 = __importDefault(require("./ErrorOverlay"));
|
|
44
|
-
const KeysListenerTracker_1 = __importDefault(require("./EventsTrackers/KeysListenerTracker"));
|
|
45
|
-
const SplitPaneWrapper_1 = require("./SplitPaneWrapper");
|
|
46
|
-
const assignment_1 = require("./assignment");
|
|
47
|
-
const ChartContext_1 = require("./context/ChartContext");
|
|
48
|
-
const DispatchContext_1 = require("./context/DispatchContext");
|
|
49
|
-
const GlobalContext_1 = require("./context/GlobalContext");
|
|
50
|
-
const LoggerContext_1 = require("./context/LoggerContext");
|
|
51
|
-
const PreferencesContext_1 = require("./context/PreferencesContext");
|
|
52
|
-
const Alert_1 = require("./elements/popup/Alert");
|
|
53
|
-
const Modal_1 = require("./elements/popup/Modal");
|
|
54
|
-
const Header_1 = __importDefault(require("./header/Header"));
|
|
55
|
-
const highlight_1 = require("./highlight");
|
|
56
|
-
const DropZone_1 = __importDefault(require("./loader/DropZone"));
|
|
57
|
-
const SpinnerContext_1 = require("./loader/SpinnerContext");
|
|
58
|
-
const Panels_1 = __importDefault(require("./panels/Panels"));
|
|
59
|
-
const IgnoreActions_1 = __importDefault(require("./reducer/IgnoreActions"));
|
|
60
|
-
const Reducer_1 = require("./reducer/Reducer");
|
|
61
|
-
const Constants_1 = require("./reducer/core/Constants");
|
|
62
|
-
const preferencesReducer_1 = __importStar(require("./reducer/preferences/preferencesReducer"));
|
|
63
|
-
const ToolBar_1 = __importDefault(require("./toolbar/ToolBar"));
|
|
64
|
-
const export_1 = require("./utility/export");
|
|
65
|
-
const viewerContainerStyle = (0, react_1.css) `
|
|
66
|
-
border: 0.55px #e6e6e6 solid;
|
|
67
|
-
display: flex;
|
|
68
|
-
flex: 1;
|
|
69
|
-
flex-direction: column;
|
|
70
|
-
height: 100%;
|
|
71
|
-
margin-left: -1px;
|
|
72
|
-
`;
|
|
73
|
-
const containerStyles = (0, react_1.css) `
|
|
74
|
-
background-color: white;
|
|
75
|
-
width: 100%;
|
|
76
|
-
display: block;
|
|
77
|
-
height: 100%;
|
|
78
|
-
|
|
79
|
-
div:focus {
|
|
80
|
-
outline: none !important;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
button {
|
|
84
|
-
cursor: pointer;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
button,
|
|
88
|
-
button:active,
|
|
89
|
-
button:hover,
|
|
90
|
-
button:focus,
|
|
91
|
-
[type='button']:focus {
|
|
92
|
-
outline: none !important;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
button:disabled {
|
|
96
|
-
cursor: default;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
* {
|
|
100
|
-
-webkit-user-drag: none;
|
|
101
|
-
-moz-user-drag: none;
|
|
102
|
-
-o-user-drag: none;
|
|
103
|
-
user-select: none;
|
|
104
|
-
}
|
|
105
|
-
`;
|
|
106
|
-
var nmr_load_save_2 = require("nmr-load-save");
|
|
107
|
-
Object.defineProperty(exports, "serializeNmriumState", { enumerable: true, get: function () { return nmr_load_save_2.serializeNmriumState; } });
|
|
108
|
-
const defaultData = {
|
|
109
|
-
spectra: [],
|
|
110
|
-
};
|
|
111
|
-
const NMRium = (0, react_2.forwardRef)(function NMRium(props, ref) {
|
|
112
|
-
const { noErrorBoundary = false, onError, ...otherProps } = props;
|
|
113
|
-
const innerNmrium = (0, jsx_runtime_1.jsx)(InnerNMRium, { ...otherProps, innerRef: ref });
|
|
114
|
-
const children = noErrorBoundary ? (innerNmrium) : ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorOverlay_1.default, onError: onError, children: innerNmrium }));
|
|
115
|
-
return (0, jsx_runtime_1.jsx)(ui_1.RootLayout, { style: { width: '100%' }, children: children });
|
|
116
|
-
});
|
|
117
|
-
function InnerNMRium({ data: dataProp = defaultData, workspace, customWorkspaces, preferences, getSpinner = SpinnerContext_1.defaultGetSpinner, onChange, emptyText, innerRef, }) {
|
|
118
|
-
const rootRef = (0, react_2.useRef)(null);
|
|
119
|
-
const elementsWrapperRef = (0, react_2.useRef)(null);
|
|
120
|
-
const viewerRef = (0, react_2.useRef)(null);
|
|
121
|
-
const [show, , setOff, toggle] = (0, ui_1.useOnOff)(false);
|
|
122
|
-
const mainDivRef = (0, react_2.useRef)(null);
|
|
123
|
-
const handleChange = (0, react_2.useRef)(onChange);
|
|
124
|
-
(0, react_2.useEffect)(() => {
|
|
125
|
-
handleChange.current = onChange;
|
|
126
|
-
}, [onChange]);
|
|
127
|
-
const isFullscreen = (0, react_use_1.useFullscreen)(rootRef, show, {
|
|
128
|
-
onClose: setOff,
|
|
129
|
-
});
|
|
130
|
-
const [state, dispatch] = (0, react_2.useReducer)(Reducer_1.spectrumReducer, Reducer_1.initialState, Reducer_1.initState);
|
|
131
|
-
const [preferencesState, dispatchPreferences] = (0, react_2.useReducer)(preferencesReducer_1.default, preferencesReducer_1.preferencesInitialState, preferencesReducer_1.initPreferencesState);
|
|
132
|
-
const { displayerMode, source, data: spectraData, molecules, correlations, actionType, view, } = state;
|
|
133
|
-
const stateRef = (0, react_2.useRef)();
|
|
134
|
-
(0, react_2.useEffect)(() => {
|
|
135
|
-
const { workspace, workspaces = {} } = preferencesState;
|
|
136
|
-
stateRef.current = (0, SpectraManager_1.toJSON)({ data: spectraData, molecules, correlations, source, view, actionType }, { current: workspaces[workspace.current] }, { serialize: false, exportTarget: 'onChange' });
|
|
137
|
-
}, [
|
|
138
|
-
actionType,
|
|
139
|
-
correlations,
|
|
140
|
-
molecules,
|
|
141
|
-
preferencesState,
|
|
142
|
-
source,
|
|
143
|
-
spectraData,
|
|
144
|
-
view,
|
|
145
|
-
]);
|
|
146
|
-
(0, react_2.useEffect)(() => {
|
|
147
|
-
// trigger onChange callback if data object changed
|
|
148
|
-
if ((0, IgnoreActions_1.default)(actionType)) {
|
|
149
|
-
handleChange.current?.(stateRef.current, 'data');
|
|
150
|
-
}
|
|
151
|
-
}, [actionType, correlations, molecules, source, spectraData]);
|
|
152
|
-
(0, react_2.useEffect)(() => {
|
|
153
|
-
// trigger onChange callback if view object changed
|
|
154
|
-
handleChange.current?.(stateRef.current, 'view');
|
|
155
|
-
}, [view]);
|
|
156
|
-
(0, react_2.useEffect)(() => {
|
|
157
|
-
// trigger onChange callback if settings changed
|
|
158
|
-
handleChange.current?.(stateRef.current, 'settings');
|
|
159
|
-
}, [preferencesState]);
|
|
160
|
-
(0, react_2.useEffect)(() => {
|
|
161
|
-
rootRef.current?.focus();
|
|
162
|
-
}, [isFullscreen]);
|
|
163
|
-
(0, react_2.useEffect)(() => {
|
|
164
|
-
dispatchPreferences({
|
|
165
|
-
type: 'INIT_PREFERENCES',
|
|
166
|
-
payload: {
|
|
167
|
-
preferences,
|
|
168
|
-
workspace,
|
|
169
|
-
customWorkspaces,
|
|
170
|
-
dispatch: dispatchPreferences,
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
}, [customWorkspaces, preferences, workspace]);
|
|
174
|
-
(0, react_2.useImperativeHandle)(innerRef, () => ({
|
|
175
|
-
getSpectraViewerAsBlob: () => {
|
|
176
|
-
return rootRef?.current ? (0, export_1.getBlob)(rootRef.current, 'nmrSVG') : null;
|
|
177
|
-
},
|
|
178
|
-
}), []);
|
|
179
|
-
(0, react_2.useEffect)(() => {
|
|
180
|
-
dispatch({
|
|
181
|
-
type: 'SET_LOADING_FLAG',
|
|
182
|
-
payload: { isLoading: true },
|
|
183
|
-
});
|
|
184
|
-
if (dataProp) {
|
|
185
|
-
void (0, nmr_load_save_1.readNMRiumObject)(dataProp)
|
|
186
|
-
.then((nmriumState) => {
|
|
187
|
-
dispatch({ type: 'INITIATE', payload: { nmriumState } });
|
|
188
|
-
})
|
|
189
|
-
.catch((error) => {
|
|
190
|
-
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
|
|
191
|
-
// eslint-disable-next-line no-alert
|
|
192
|
-
alert(error.message);
|
|
193
|
-
reportError(error);
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}, [dataProp]);
|
|
197
|
-
const preventContextMenuHandler = (0, react_2.useCallback)((e) => {
|
|
198
|
-
if (!(0, checkModifierKeyActivated_1.default)(e)) {
|
|
199
|
-
e.preventDefault();
|
|
200
|
-
}
|
|
201
|
-
}, []);
|
|
202
|
-
(0, react_2.useEffect)(() => {
|
|
203
|
-
const div = mainDivRef.current;
|
|
204
|
-
if (!div) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
function mouseEnterHandler() {
|
|
208
|
-
dispatch({
|
|
209
|
-
type: 'SET_MOUSE_OVER_DISPLAYER',
|
|
210
|
-
payload: { isMouseOverDisplayer: true },
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
function mouseLeaveHandler() {
|
|
214
|
-
dispatch({
|
|
215
|
-
type: 'SET_MOUSE_OVER_DISPLAYER',
|
|
216
|
-
payload: { isMouseOverDisplayer: false },
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
div.addEventListener('mouseenter', mouseEnterHandler);
|
|
220
|
-
div.addEventListener('mouseleave', mouseLeaveHandler);
|
|
221
|
-
return () => {
|
|
222
|
-
div.removeEventListener('mouseenter', mouseEnterHandler);
|
|
223
|
-
div.removeEventListener('mouseleave', mouseLeaveHandler);
|
|
224
|
-
};
|
|
225
|
-
}, []);
|
|
226
|
-
return ((0, jsx_runtime_1.jsx)(GlobalContext_1.GlobalProvider, { value: {
|
|
227
|
-
rootRef: rootRef.current,
|
|
228
|
-
elementsWrapperRef: elementsWrapperRef.current,
|
|
229
|
-
viewerRef: viewerRef.current,
|
|
230
|
-
}, children: (0, jsx_runtime_1.jsx)(PreferencesContext_1.PreferencesProvider, { value: preferencesState, children: (0, jsx_runtime_1.jsx)("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: (0, jsx_runtime_1.jsx)(LoggerContext_1.LoggerProvider, { children: (0, jsx_runtime_1.jsx)(Alert_1.AlertProvider, { wrapperRef: elementsWrapperRef.current, children: (0, jsx_runtime_1.jsx)(DispatchContext_1.DispatchProvider, { value: dispatch, children: (0, jsx_runtime_1.jsx)(ChartContext_1.ChartDataProvider, { value: state, children: (0, jsx_runtime_1.jsx)(Modal_1.ModalProvider, { wrapperRef: elementsWrapperRef.current, children: (0, jsx_runtime_1.jsx)(highlight_1.HighlightProvider, { children: (0, jsx_runtime_1.jsx)(assignment_1.AssignmentProvider, { spectraData: spectraData, children: (0, jsx_runtime_1.jsxs)(SpinnerContext_1.SpinnerProvider, { value: getSpinner, children: [(0, jsx_runtime_1.jsx)(StateError, {}), (0, jsx_runtime_1.jsx)("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: (0, jsx_runtime_1.jsx)(DropZone_1.default, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
231
|
-
display: 'flex',
|
|
232
|
-
flexDirection: 'column',
|
|
233
|
-
backgroundColor: 'white',
|
|
234
|
-
width: '100%',
|
|
235
|
-
}, children: [(0, jsx_runtime_1.jsx)(Header_1.default, { isFullscreen: isFullscreen, onMaximize: toggle }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
236
|
-
display: 'flex',
|
|
237
|
-
flexDirection: 'row',
|
|
238
|
-
height: '100%',
|
|
239
|
-
}, children: [(0, jsx_runtime_1.jsx)(ToolBar_1.default, {}), (0, jsx_runtime_1.jsxs)(SplitPaneWrapper_1.SplitPaneWrapper, { children: [(0, jsx_runtime_1.jsxs)("div", { css: viewerContainerStyle, children: [(0, jsx_runtime_1.jsx)(KeysListenerTracker_1.default, {}), (0, jsx_runtime_1.jsxs)("div", { id: "nmrium-viewer", "data-test-id": "viewer", ref: viewerRef, style: {
|
|
240
|
-
width: '100%',
|
|
241
|
-
height: '100%',
|
|
242
|
-
position: 'relative',
|
|
243
|
-
}, children: [(0, jsx_runtime_1.jsx)(FloatMoleculeStructures_1.default, {}), displayerMode ===
|
|
244
|
-
Constants_1.DISPLAYER_MODE.DM_1D ? ((0, jsx_runtime_1.jsx)(Viewer1D_1.default, { emptyText: emptyText })) : ((0, jsx_runtime_1.jsx)(Viewer2D_1.default, { emptyText: emptyText }))] })] }), (0, jsx_runtime_1.jsx)(Panels_1.default, {})] }), (0, jsx_runtime_1.jsx)("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
|
|
245
|
-
position: 'absolute',
|
|
246
|
-
pointerEvents: 'none',
|
|
247
|
-
zIndex: 2,
|
|
248
|
-
left: 0,
|
|
249
|
-
right: 0,
|
|
250
|
-
top: 0,
|
|
251
|
-
bottom: 0,
|
|
252
|
-
} }, String(isFullscreen))] })] }) }) })] }) }) }) }) }) }) }) }) }) }) }));
|
|
253
|
-
}
|
|
254
|
-
exports.default = (0, react_2.memo)(NMRium);
|
|
255
|
-
/**
|
|
256
|
-
* Alert user in UI when state have errorAction (error from reducer)
|
|
257
|
-
*/
|
|
258
|
-
function StateError() {
|
|
259
|
-
const { errorAction } = (0, ChartContext_1.useChartData)();
|
|
260
|
-
const { logger } = (0, LoggerContext_1.useLogger)();
|
|
261
|
-
(0, react_2.useEffect)(() => {
|
|
262
|
-
if (!errorAction)
|
|
263
|
-
return;
|
|
264
|
-
logger.error(errorAction);
|
|
265
|
-
}, [errorAction, logger]);
|
|
266
|
-
return null;
|
|
267
|
-
}
|