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
|
@@ -0,0 +1,82 @@
|
|
|
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.InnerNMRium = void 0;
|
|
30
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
const react_1 = require("react");
|
|
32
|
+
const ui_1 = require("react-science/ui");
|
|
33
|
+
const react_use_1 = require("react-use");
|
|
34
|
+
const assignment_1 = require("../assignment");
|
|
35
|
+
const GlobalContext_1 = require("../context/GlobalContext");
|
|
36
|
+
const KeyModifierContext_1 = require("../context/KeyModifierContext");
|
|
37
|
+
const LoggerContext_1 = require("../context/LoggerContext");
|
|
38
|
+
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
39
|
+
const Alert_1 = require("../elements/popup/Alert");
|
|
40
|
+
const Modal_1 = require("../elements/popup/Modal");
|
|
41
|
+
const highlight_1 = require("../highlight");
|
|
42
|
+
const SpinnerContext_1 = require("../loader/SpinnerContext");
|
|
43
|
+
const preferencesReducer_1 = __importStar(require("../reducer/preferences/preferencesReducer"));
|
|
44
|
+
const export_1 = require("../utility/export");
|
|
45
|
+
const InnerNMRiumContents_1 = require("./InnerNMRiumContents");
|
|
46
|
+
const NMRiumStateProvider_1 = __importDefault(require("./NMRiumStateProvider"));
|
|
47
|
+
function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner = SpinnerContext_1.defaultGetSpinner, onChange, emptyText, innerRef, }) {
|
|
48
|
+
const rootRef = (0, react_1.useRef)(null);
|
|
49
|
+
const elementsWrapperRef = (0, react_1.useRef)(null);
|
|
50
|
+
const viewerRef = (0, react_1.useRef)(null);
|
|
51
|
+
const [enableFullscreen, , disableFullscreen, toggleFullscreen] = (0, ui_1.useOnOff)(false);
|
|
52
|
+
const mainDivRef = (0, react_1.useRef)(null);
|
|
53
|
+
const isFullscreenEnabled = (0, react_use_1.useFullscreen)(rootRef, enableFullscreen, {
|
|
54
|
+
onClose: disableFullscreen,
|
|
55
|
+
});
|
|
56
|
+
const [preferencesState, dispatchPreferences] = (0, react_1.useReducer)(preferencesReducer_1.default, preferencesReducer_1.preferencesInitialState, preferencesReducer_1.initPreferencesState);
|
|
57
|
+
(0, react_1.useEffect)(() => {
|
|
58
|
+
rootRef.current?.focus();
|
|
59
|
+
}, [isFullscreenEnabled]);
|
|
60
|
+
(0, react_1.useEffect)(() => {
|
|
61
|
+
dispatchPreferences({
|
|
62
|
+
type: 'INIT_PREFERENCES',
|
|
63
|
+
payload: {
|
|
64
|
+
preferences,
|
|
65
|
+
workspace,
|
|
66
|
+
customWorkspaces,
|
|
67
|
+
dispatch: dispatchPreferences,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}, [customWorkspaces, preferences, workspace]);
|
|
71
|
+
(0, react_1.useImperativeHandle)(innerRef, () => ({
|
|
72
|
+
getSpectraViewerAsBlob: () => {
|
|
73
|
+
return rootRef?.current ? (0, export_1.getBlob)(rootRef.current, 'nmrSVG') : null;
|
|
74
|
+
},
|
|
75
|
+
}), []);
|
|
76
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: (0, jsx_runtime_1.jsx)(GlobalContext_1.GlobalProvider, { value: {
|
|
77
|
+
rootRef: rootRef.current,
|
|
78
|
+
elementsWrapperRef: elementsWrapperRef.current,
|
|
79
|
+
viewerRef: viewerRef.current,
|
|
80
|
+
}, children: (0, jsx_runtime_1.jsx)(PreferencesContext_1.PreferencesProvider, { value: preferencesState, children: (0, jsx_runtime_1.jsx)(LoggerContext_1.LoggerProvider, { children: (0, jsx_runtime_1.jsx)(KeyModifierContext_1.KeyModifiersProvider, { children: (0, jsx_runtime_1.jsx)(Alert_1.AlertProvider, { wrapperRef: elementsWrapperRef.current, children: (0, jsx_runtime_1.jsx)(NMRiumStateProvider_1.default, { onChange: onChange, nmriumData: nmriumData, 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, { children: (0, jsx_runtime_1.jsx)(SpinnerContext_1.SpinnerProvider, { value: getSpinner, children: (0, jsx_runtime_1.jsx)(InnerNMRiumContents_1.InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }));
|
|
81
|
+
}
|
|
82
|
+
exports.InnerNMRium = InnerNMRium;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.InnerNMRiumContents = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
8
|
+
/** @jsxImportSource @emotion/react */
|
|
9
|
+
const react_1 = require("@emotion/react");
|
|
10
|
+
const react_2 = require("react");
|
|
11
|
+
const checkModifierKeyActivated_1 = __importDefault(require("../../data/utilities/checkModifierKeyActivated"));
|
|
12
|
+
const Viewer1D_1 = __importDefault(require("../1d/Viewer1D"));
|
|
13
|
+
const FloatMoleculeStructures_1 = __importDefault(require("../1d-2d/components/FloatMoleculeStructures"));
|
|
14
|
+
const Viewer2D_1 = __importDefault(require("../2d/Viewer2D"));
|
|
15
|
+
const KeysListenerTracker_1 = __importDefault(require("../EventsTrackers/KeysListenerTracker"));
|
|
16
|
+
const ChartContext_1 = require("../context/ChartContext");
|
|
17
|
+
const Header_1 = __importDefault(require("../header/Header"));
|
|
18
|
+
const DropZone_1 = __importDefault(require("../loader/DropZone"));
|
|
19
|
+
const Panels_1 = __importDefault(require("../panels/Panels"));
|
|
20
|
+
const Constants_1 = require("../reducer/core/Constants");
|
|
21
|
+
const ToolBar_1 = __importDefault(require("../toolbar/ToolBar"));
|
|
22
|
+
const SplitPaneWrapper_1 = require("./SplitPaneWrapper");
|
|
23
|
+
const StateError_1 = require("./StateError");
|
|
24
|
+
const viewerContainerStyle = (0, react_1.css) `
|
|
25
|
+
border: 0.55px #e6e6e6 solid;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex: 1;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
height: 100%;
|
|
30
|
+
margin-left: -1px;
|
|
31
|
+
`;
|
|
32
|
+
const containerStyles = (0, react_1.css) `
|
|
33
|
+
background-color: white;
|
|
34
|
+
width: 100%;
|
|
35
|
+
display: block;
|
|
36
|
+
height: 100%;
|
|
37
|
+
|
|
38
|
+
div:focus {
|
|
39
|
+
outline: none !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
button {
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
button,
|
|
47
|
+
button:active,
|
|
48
|
+
button:hover,
|
|
49
|
+
button:focus,
|
|
50
|
+
[type='button']:focus {
|
|
51
|
+
outline: none !important;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
button:disabled {
|
|
55
|
+
cursor: default;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
* {
|
|
59
|
+
-webkit-user-drag: none;
|
|
60
|
+
-moz-user-drag: none;
|
|
61
|
+
-o-user-drag: none;
|
|
62
|
+
user-select: none;
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
function InnerNMRiumContents(props) {
|
|
66
|
+
const { isFullscreenEnabled, toggleFullscreen, emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef, } = props;
|
|
67
|
+
const { displayerMode } = (0, ChartContext_1.useChartData)();
|
|
68
|
+
const preventContextMenuHandler = (0, react_2.useCallback)((e) => {
|
|
69
|
+
if (!(0, checkModifierKeyActivated_1.default)(e)) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
}
|
|
72
|
+
}, []);
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StateError_1.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: {
|
|
74
|
+
display: 'flex',
|
|
75
|
+
flexDirection: 'column',
|
|
76
|
+
backgroundColor: 'white',
|
|
77
|
+
width: '100%',
|
|
78
|
+
}, children: [(0, jsx_runtime_1.jsx)(Header_1.default, { isFullscreenEnabled: isFullscreenEnabled, onEnableFullscreen: toggleFullscreen }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
79
|
+
display: 'flex',
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
height: '100%',
|
|
82
|
+
}, 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, { mainDivRef: mainDivRef }), (0, jsx_runtime_1.jsxs)("div", { id: "nmrium-viewer", "data-testid": "viewer", ref: viewerRef, style: {
|
|
83
|
+
width: '100%',
|
|
84
|
+
height: '100%',
|
|
85
|
+
position: 'relative',
|
|
86
|
+
}, children: [(0, jsx_runtime_1.jsx)(FloatMoleculeStructures_1.default, {}), displayerMode === 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: {
|
|
87
|
+
position: 'absolute',
|
|
88
|
+
pointerEvents: 'none',
|
|
89
|
+
zIndex: 2,
|
|
90
|
+
left: 0,
|
|
91
|
+
right: 0,
|
|
92
|
+
top: 0,
|
|
93
|
+
bottom: 0,
|
|
94
|
+
} }, String(isFullscreenEnabled))] })] }) }) })] }));
|
|
95
|
+
}
|
|
96
|
+
exports.InnerNMRiumContents = InnerNMRiumContents;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NMRium = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const react_error_boundary_1 = require("react-error-boundary");
|
|
10
|
+
const ui_1 = require("react-science/ui");
|
|
11
|
+
const ErrorOverlay_1 = __importDefault(require("./ErrorOverlay"));
|
|
12
|
+
const InnerNMRium_1 = require("./InnerNMRium");
|
|
13
|
+
const NMRiumBase = (0, react_1.forwardRef)(function NMRium(props, ref) {
|
|
14
|
+
const { noErrorBoundary = false, onError, ...otherProps } = props;
|
|
15
|
+
const innerNmrium = (0, jsx_runtime_1.jsx)(InnerNMRium_1.InnerNMRium, { ...otherProps, innerRef: ref });
|
|
16
|
+
const children = noErrorBoundary ? (innerNmrium) : ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorOverlay_1.default, onError: onError, children: innerNmrium }));
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(ui_1.RootLayout, { style: { width: '100%' }, children: children });
|
|
18
|
+
});
|
|
19
|
+
exports.NMRium = (0, react_1.memo)(NMRiumBase);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const nmr_load_save_1 = require("nmr-load-save");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const SpectraManager_1 = require("../../data/SpectraManager");
|
|
10
|
+
const ChartContext_1 = require("../context/ChartContext");
|
|
11
|
+
const DispatchContext_1 = require("../context/DispatchContext");
|
|
12
|
+
const LoggerContext_1 = require("../context/LoggerContext");
|
|
13
|
+
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
14
|
+
const IgnoreActions_1 = __importDefault(require("../reducer/IgnoreActions"));
|
|
15
|
+
const Reducer_1 = require("../reducer/Reducer");
|
|
16
|
+
const defaultData = {
|
|
17
|
+
spectra: [],
|
|
18
|
+
};
|
|
19
|
+
function NMRiumStateProvider(props) {
|
|
20
|
+
const { children, onChange, nmriumData = defaultData } = props;
|
|
21
|
+
const { logger } = (0, LoggerContext_1.useLogger)();
|
|
22
|
+
const preferencesState = (0, PreferencesContext_1.usePreferences)();
|
|
23
|
+
const [state, dispatchRaw] = (0, react_1.useReducer)(Reducer_1.spectrumReducer, Reducer_1.initialState, Reducer_1.initState);
|
|
24
|
+
const dispatch = (0, react_1.useCallback)((action) => {
|
|
25
|
+
logger.trace({ action }, `Dispatch main reducer action: ${action.type}`);
|
|
26
|
+
dispatchRaw(action);
|
|
27
|
+
}, [logger]);
|
|
28
|
+
const { source, data: spectraData, molecules, correlations, actionType, view, } = state;
|
|
29
|
+
const stateRef = (0, react_1.useRef)();
|
|
30
|
+
const handleChange = (0, react_1.useRef)(onChange);
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
handleChange.current = onChange;
|
|
33
|
+
}, [onChange]);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
const { workspace, workspaces = {} } = preferencesState;
|
|
36
|
+
stateRef.current = (0, SpectraManager_1.toJSON)({ data: spectraData, molecules, correlations, source, view, actionType }, { current: workspaces[workspace.current] }, { serialize: false, exportTarget: 'onChange' });
|
|
37
|
+
}, [
|
|
38
|
+
actionType,
|
|
39
|
+
correlations,
|
|
40
|
+
molecules,
|
|
41
|
+
preferencesState,
|
|
42
|
+
source,
|
|
43
|
+
spectraData,
|
|
44
|
+
view,
|
|
45
|
+
]);
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
// trigger onChange callback if data object changed
|
|
48
|
+
if ((0, IgnoreActions_1.default)(actionType)) {
|
|
49
|
+
handleChange.current?.(stateRef.current, 'data');
|
|
50
|
+
}
|
|
51
|
+
}, [actionType, correlations, molecules, source, spectraData]);
|
|
52
|
+
(0, react_1.useEffect)(() => {
|
|
53
|
+
// trigger onChange callback if view object changed
|
|
54
|
+
handleChange.current?.(stateRef.current, 'view');
|
|
55
|
+
}, [view]);
|
|
56
|
+
(0, react_1.useEffect)(() => {
|
|
57
|
+
// trigger onChange callback if settings changed
|
|
58
|
+
handleChange.current?.(stateRef.current, 'settings');
|
|
59
|
+
}, [preferencesState]);
|
|
60
|
+
(0, react_1.useEffect)(() => {
|
|
61
|
+
dispatch({
|
|
62
|
+
type: 'SET_LOADING_FLAG',
|
|
63
|
+
payload: { isLoading: true },
|
|
64
|
+
});
|
|
65
|
+
if (nmriumData) {
|
|
66
|
+
void (0, nmr_load_save_1.readNMRiumObject)(nmriumData)
|
|
67
|
+
.then((nmriumState) => {
|
|
68
|
+
dispatch({ type: 'INITIATE', payload: { nmriumState } });
|
|
69
|
+
})
|
|
70
|
+
.catch((error) => {
|
|
71
|
+
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
|
|
72
|
+
// eslint-disable-next-line no-alert
|
|
73
|
+
alert(error.message);
|
|
74
|
+
reportError(error);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}, [nmriumData, dispatch]);
|
|
78
|
+
return ((0, jsx_runtime_1.jsx)(DispatchContext_1.DispatchProvider, { value: dispatch, children: (0, jsx_runtime_1.jsx)(ChartContext_1.ChartDataProvider, { value: state, children: children }) }));
|
|
79
|
+
}
|
|
80
|
+
exports.default = NMRiumStateProvider;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SplitPaneWrapper = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const ui_1 = require("react-science/ui");
|
|
6
|
-
const PreferencesContext_1 = require("
|
|
6
|
+
const PreferencesContext_1 = require("../context/PreferencesContext");
|
|
7
7
|
function SplitPaneWrapper({ children }) {
|
|
8
8
|
const { current, dispatch } = (0, PreferencesContext_1.usePreferences)();
|
|
9
9
|
const { general: { verticalSplitterPosition, verticalSplitterCloseThreshold }, display: { general = {} }, } = current;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StateError = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ChartContext_1 = require("../context/ChartContext");
|
|
6
|
+
const LoggerContext_1 = require("../context/LoggerContext");
|
|
7
|
+
/**
|
|
8
|
+
* Alert user in UI when state have errorAction (error from reducer)
|
|
9
|
+
*/
|
|
10
|
+
function StateError() {
|
|
11
|
+
const { errorAction } = (0, ChartContext_1.useChartData)();
|
|
12
|
+
const { logger } = (0, LoggerContext_1.useLogger)();
|
|
13
|
+
(0, react_1.useEffect)(() => {
|
|
14
|
+
if (!errorAction)
|
|
15
|
+
return;
|
|
16
|
+
logger.error(errorAction);
|
|
17
|
+
}, [errorAction, logger]);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
exports.StateError = StateError;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.serializeNMRiumState = void 0;
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
var nmr_load_save_1 = require("nmr-load-save");
|
|
20
|
+
Object.defineProperty(exports, "serializeNMRiumState", { enumerable: true, get: function () { return nmr_load_save_1.serializeNmriumState; } });
|
|
21
|
+
__exportStar(require("./NMRium"), exports);
|
|
@@ -80,7 +80,7 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
|
|
|
80
80
|
closeDialog();
|
|
81
81
|
const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
|
|
82
82
|
try {
|
|
83
|
-
const data = await (0, PredictionManager_1.predictSpectra)(molfile);
|
|
83
|
+
const data = await (0, PredictionManager_1.predictSpectra)(molfile, values.spectra);
|
|
84
84
|
dispatch({
|
|
85
85
|
type: 'PREDICT_SPECTRA',
|
|
86
86
|
payload: {
|
|
@@ -1,145 +1,10 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const jsx_runtime_1 = require("
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
const PreferencesContext_1 = require("../../context/PreferencesContext");
|
|
36
|
-
const Button_1 = __importDefault(require("../../elements/Button"));
|
|
37
|
-
const CloseButton_1 = __importDefault(require("../../elements/CloseButton"));
|
|
38
|
-
const Tab_1 = __importDefault(require("../../elements/Tab/Tab"));
|
|
39
|
-
const Tabs_1 = __importDefault(require("../../elements/Tab/Tabs"));
|
|
40
|
-
const FormikInput_1 = __importDefault(require("../../elements/formik/FormikInput"));
|
|
41
|
-
const ModalStyle_1 = require("../ModalStyle");
|
|
42
|
-
const SelectMolecule_1 = __importDefault(require("./SelectMolecule"));
|
|
43
|
-
const styles = (0, react_1.css) `
|
|
44
|
-
width: 450px;
|
|
45
|
-
height: 400px;
|
|
46
|
-
|
|
47
|
-
.header {
|
|
48
|
-
display: flex;
|
|
49
|
-
padding: 10px;
|
|
50
|
-
|
|
51
|
-
span {
|
|
52
|
-
font-size: 14px;
|
|
53
|
-
flex: 1;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.tab-content {
|
|
58
|
-
flex: 1;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.manual-container {
|
|
62
|
-
padding: 30px 5px;
|
|
63
|
-
|
|
64
|
-
.input {
|
|
65
|
-
width: 80% !important;
|
|
66
|
-
height: 36px;
|
|
67
|
-
margin: 0 auto;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.input input {
|
|
71
|
-
padding: 5px;
|
|
72
|
-
text-align: center;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
`;
|
|
76
|
-
var SumSetOptions;
|
|
77
|
-
(function (SumSetOptions) {
|
|
78
|
-
SumSetOptions["Auto"] = "auto";
|
|
79
|
-
SumSetOptions["Manual"] = "manual";
|
|
80
|
-
})(SumSetOptions || (SumSetOptions = {}));
|
|
81
|
-
function getValidationSchema(option) {
|
|
82
|
-
switch (option) {
|
|
83
|
-
case SumSetOptions.Auto: {
|
|
84
|
-
return Yup.object({
|
|
85
|
-
molecule: Yup.object().required(),
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
case SumSetOptions.Manual: {
|
|
89
|
-
return Yup.object({
|
|
90
|
-
sum: Yup.number().required(),
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
default:
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function ChangeSumModal({ onSave, onClose, header, sumOptions, }) {
|
|
98
|
-
const { current: { display: { panels }, }, } = (0, PreferencesContext_1.usePreferences)();
|
|
99
|
-
const [setOption, setActiveOption] = (0, react_2.useState)(SumSetOptions.Auto);
|
|
100
|
-
const formRef = (0, react_2.useRef)(null);
|
|
101
|
-
function handleKeyDown(event) {
|
|
102
|
-
if (event.key === 'Enter') {
|
|
103
|
-
formRef.current.submitForm();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function onTabChangeHandler(tab) {
|
|
107
|
-
setActiveOption(tab.tabid);
|
|
108
|
-
}
|
|
109
|
-
(0, react_2.useEffect)(() => {
|
|
110
|
-
if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
|
|
111
|
-
setActiveOption(SumSetOptions.Auto);
|
|
112
|
-
const { mf, moleculeId: id } = sumOptions;
|
|
113
|
-
formRef.current.setValues({
|
|
114
|
-
sum: null,
|
|
115
|
-
molecule: id && mf ? { mf, id } : null,
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
setActiveOption(SumSetOptions.Manual);
|
|
120
|
-
formRef.current.setValues({ sum: sumOptions?.sum ?? '', molecule: null });
|
|
121
|
-
}
|
|
122
|
-
}, [panels?.structuresPanel, sumOptions]);
|
|
123
|
-
function saveHandler(values) {
|
|
124
|
-
switch (setOption) {
|
|
125
|
-
case SumSetOptions.Auto: {
|
|
126
|
-
const { molecule: { mf, id: moleculeId }, } = values;
|
|
127
|
-
onSave({ sumAuto: true, mf, moleculeId });
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
case SumSetOptions.Manual: {
|
|
131
|
-
const { sum } = values;
|
|
132
|
-
onSave({ sum, sumAuto: false });
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
default:
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
onClose();
|
|
139
|
-
}
|
|
140
|
-
const isStructurePanelVisible = panels?.structuresPanel?.display || false;
|
|
141
|
-
return (
|
|
142
|
-
// <div css={modalContainer}>
|
|
143
|
-
(0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: header }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose })] }), (0, jsx_runtime_1.jsx)("div", { className: "tab-content", children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && ((0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Auto", tabid: SumSetOptions.Auto, children: (0, jsx_runtime_1.jsx)(SelectMolecule_1.default, { name: "molecule" }) })), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Manual", tabid: SumSetOptions.Manual, children: (0, jsx_runtime_1.jsx)("div", { className: "manual-container", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "footer-container", children: (0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: () => formRef.current.submitForm(), style: { width: '80px' }, children: "Set" }) })] }));
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const ui_1 = require("react-science/ui");
|
|
5
|
+
const ChangeSumModalContents_1 = require("./ChangeSumModalContents");
|
|
6
|
+
function ChangeSumModal({ renderButton, ...otherProps }) {
|
|
7
|
+
const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
|
|
8
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [renderButton(openDialog), (0, jsx_runtime_1.jsx)(ui_1.Modal, { isOpen: isOpenDialog, onRequestClose: closeDialog, width: 500, height: 400, children: (0, jsx_runtime_1.jsx)(ChangeSumModalContents_1.ChangeSumModalContents, { ...otherProps, onClose: closeDialog }) })] }));
|
|
144
9
|
}
|
|
145
10
|
exports.default = ChangeSumModal;
|
|
@@ -0,0 +1,124 @@
|
|
|
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.ChangeSumModalContents = void 0;
|
|
30
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
32
|
+
const formik_1 = require("formik");
|
|
33
|
+
const react_1 = require("react");
|
|
34
|
+
const ui_1 = require("react-science/ui");
|
|
35
|
+
const Yup = __importStar(require("yup"));
|
|
36
|
+
const PreferencesContext_1 = require("../../context/PreferencesContext");
|
|
37
|
+
const Button_1 = __importDefault(require("../../elements/Button"));
|
|
38
|
+
const Tab_1 = __importDefault(require("../../elements/Tab/Tab"));
|
|
39
|
+
const Tabs_1 = __importDefault(require("../../elements/Tab/Tabs"));
|
|
40
|
+
const FormikInput_1 = __importDefault(require("../../elements/formik/FormikInput"));
|
|
41
|
+
const SelectMolecule_1 = __importDefault(require("./SelectMolecule"));
|
|
42
|
+
function getValidationSchema(option) {
|
|
43
|
+
switch (option) {
|
|
44
|
+
case 'auto': {
|
|
45
|
+
return Yup.object({
|
|
46
|
+
molecule: Yup.object().required(),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
case 'manual': {
|
|
50
|
+
return Yup.object({
|
|
51
|
+
sum: Yup.number().required(),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
default:
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const ManualContainer = styled_1.default.div `
|
|
59
|
+
padding: 30px 5px;
|
|
60
|
+
|
|
61
|
+
.input {
|
|
62
|
+
width: 80% !important;
|
|
63
|
+
height: 36px;
|
|
64
|
+
margin: 0 auto;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.input input {
|
|
68
|
+
padding: 5px;
|
|
69
|
+
text-align: center;
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
function ChangeSumModalContents(props) {
|
|
73
|
+
const { currentSum, sumType, sumOptions, onSave, onClose } = props;
|
|
74
|
+
const { current: { display: { panels }, }, } = (0, PreferencesContext_1.usePreferences)();
|
|
75
|
+
const [setOption, setActiveOption] = (0, react_1.useState)('auto');
|
|
76
|
+
const formRef = (0, react_1.useRef)(null);
|
|
77
|
+
(0, react_1.useEffect)(() => {
|
|
78
|
+
if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
|
|
79
|
+
setActiveOption('auto');
|
|
80
|
+
const { mf, moleculeId: id } = sumOptions;
|
|
81
|
+
formRef.current.setValues({
|
|
82
|
+
sum: null,
|
|
83
|
+
molecule: id && mf ? { mf, id } : null,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
setActiveOption('manual');
|
|
88
|
+
formRef.current.setValues({
|
|
89
|
+
sum: sumOptions?.sum ?? '',
|
|
90
|
+
molecule: null,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}, [panels?.structuresPanel, sumOptions]);
|
|
94
|
+
function handleKeyDown(event) {
|
|
95
|
+
if (event.key === 'Enter') {
|
|
96
|
+
formRef.current.submitForm();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function onTabChangeHandler(tab) {
|
|
100
|
+
setActiveOption(tab.tabid);
|
|
101
|
+
}
|
|
102
|
+
function saveHandler(values) {
|
|
103
|
+
switch (setOption) {
|
|
104
|
+
case 'auto': {
|
|
105
|
+
const { molecule: { mf, id: moleculeId }, } = values;
|
|
106
|
+
onSave({ sumAuto: true, mf, moleculeId });
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'manual': {
|
|
110
|
+
const { sum } = values;
|
|
111
|
+
onSave({ sum, sumAuto: false });
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
default:
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
onClose();
|
|
118
|
+
}
|
|
119
|
+
const isStructurePanelVisible = panels?.structuresPanel?.display || false;
|
|
120
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: currentSum
|
|
121
|
+
? `Set new ${sumType} sum (Current: ${currentSum.toFixed(2)})`
|
|
122
|
+
: `Set new ${sumType} Sum` }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && ((0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Auto", tabid: "auto", children: (0, jsx_runtime_1.jsx)(SelectMolecule_1.default, { name: "molecule" }) })), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Manual", tabid: "manual", children: (0, jsx_runtime_1.jsx)(ManualContainer, { children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Footer, { children: (0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: () => formRef.current.submitForm(), style: { width: 80 }, children: "Set" }) })] }));
|
|
123
|
+
}
|
|
124
|
+
exports.ChangeSumModalContents = ChangeSumModalContents;
|
|
@@ -150,7 +150,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
150
150
|
}, [workspaces]);
|
|
151
151
|
const handleReset = () => {
|
|
152
152
|
const workSpaceDisplayPreferences = (0, getPreferencesByWorkspace_1.getPreferencesByWorkspace)(workspaceName, originalWorkspaces);
|
|
153
|
-
refForm.current?.setValues(workSpaceDisplayPreferences);
|
|
153
|
+
void refForm.current?.setValues(workSpaceDisplayPreferences);
|
|
154
154
|
};
|
|
155
155
|
function submitHandler(values) {
|
|
156
156
|
saveSettings(values);
|
|
@@ -215,7 +215,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
215
215
|
const setWorkspaceSetting = (0, react_2.useCallback)((inputWorkspace) => {
|
|
216
216
|
const parseWorkspaceName = Object.keys(inputWorkspace)[0];
|
|
217
217
|
if (preferences.workspace.current === parseWorkspaceName) {
|
|
218
|
-
refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
|
|
218
|
+
void refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
|
|
219
219
|
}
|
|
220
220
|
else if (preferences.workspaces[parseWorkspaceName]) {
|
|
221
221
|
pastRef.current = inputWorkspace;
|