nmrium 0.41.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/1d-2d/components/SpectrumInfoBlock.js +4 -1
- 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/Input.js +1 -0
- package/lib/component/elements/NumberInput.d.ts +1 -0
- package/lib/component/elements/NumberInput.js +10 -3
- package/lib/component/elements/Scroller.d.ts +15 -0
- package/lib/component/elements/Scroller.js +31 -0
- 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/useSaveSettings.js +9 -11
- 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/AboutPredictionModal.js +1 -1
- package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
- 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/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
- 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/SpectraPreferences.js +4 -3
- 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/databasePanel/DatabasePanel.js +33 -26
- 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 +32 -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.d.ts +6 -2
- package/lib/component/reducer/actions/MoleculeActions.js +8 -2
- 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/actions/addWorkspace.js +19 -15
- 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/PathBuilder.js +11 -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 +10 -5
- 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/data1d/database.d.ts +4 -2
- package/lib/data/data1d/database.js +10 -3
- package/lib/data/molecules/Molecule.js +2 -2
- package/lib/data/molecules/MoleculeManager.d.ts +1 -0
- package/lib/data/molecules/MoleculeManager.js +14 -0
- 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/1d-2d/components/SpectrumInfoBlock.js +4 -1
- 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/Input.js +1 -0
- package/lib-cjs/component/elements/NumberInput.js +12 -2
- package/lib-cjs/component/elements/Scroller.js +35 -0
- 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/useSaveSettings.js +9 -11
- 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/AboutPredictionModal.js +1 -1
- package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +1 -1
- 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/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
- 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/SpectraPreferences.js +3 -2
- 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/databasePanel/DatabasePanel.js +33 -26
- 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 +31 -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 +9 -2
- package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
- package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
- package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
- package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
- package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
- package/lib-cjs/component/utility/PathBuilder.js +11 -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 +10 -5
- package/lib-cjs/data/PredictionManager.js +9 -9
- package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
- package/lib-cjs/data/data1d/database.js +10 -3
- package/lib-cjs/data/molecules/Molecule.js +2 -2
- package/lib-cjs/data/molecules/MoleculeManager.js +16 -1
- package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +26 -25
- package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
- package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
- package/lib/component/ErrorOverlay.js +0 -27
- package/lib/component/NMRium.d.ts +0 -42
- package/lib/component/NMRium.js +0 -237
- package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
- package/lib/component/reducer/actions/GlobalActions.js +0 -4
- package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
- package/lib-cjs/component/ErrorOverlay.js +0 -30
- package/lib-cjs/component/NMRium.js +0 -267
- package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
- /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
- /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} | {
|
|
6
|
-
moleculeId: string;
|
|
7
|
-
mf: string;
|
|
8
|
-
sumAuto: true;
|
|
9
|
-
};
|
|
10
|
-
interface ChangeSumModalProps {
|
|
11
|
-
onSave: (saveInput: SaveInput) => void;
|
|
12
|
-
onClose: () => void;
|
|
13
|
-
header: string;
|
|
14
|
-
sumOptions: SumOptions;
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ChangeSumModalContentsProps } from './ChangeSumModalContents';
|
|
3
|
+
export interface ChangeSumModalProps extends Omit<ChangeSumModalContentsProps, 'onClose'> {
|
|
4
|
+
renderButton: (onClick: () => void) => ReactNode;
|
|
15
5
|
}
|
|
16
|
-
export default function ChangeSumModal({
|
|
17
|
-
export {};
|
|
6
|
+
export default function ChangeSumModal({ renderButton, ...otherProps }: ChangeSumModalProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,116 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { usePreferences } from '../../context/PreferencesContext';
|
|
8
|
-
import Button from '../../elements/Button';
|
|
9
|
-
import CloseButton from '../../elements/CloseButton';
|
|
10
|
-
import Tab from '../../elements/Tab/Tab';
|
|
11
|
-
import Tabs from '../../elements/Tab/Tabs';
|
|
12
|
-
import FormikInput from '../../elements/formik/FormikInput';
|
|
13
|
-
import { ModalStyles } from '../ModalStyle';
|
|
14
|
-
import SelectMolecule from './SelectMolecule';
|
|
15
|
-
const styles = css `
|
|
16
|
-
width: 450px;
|
|
17
|
-
height: 400px;
|
|
18
|
-
|
|
19
|
-
.header {
|
|
20
|
-
display: flex;
|
|
21
|
-
padding: 10px;
|
|
22
|
-
|
|
23
|
-
span {
|
|
24
|
-
font-size: 14px;
|
|
25
|
-
flex: 1;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.tab-content {
|
|
30
|
-
flex: 1;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.manual-container {
|
|
34
|
-
padding: 30px 5px;
|
|
35
|
-
|
|
36
|
-
.input {
|
|
37
|
-
width: 80% !important;
|
|
38
|
-
height: 36px;
|
|
39
|
-
margin: 0 auto;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.input input {
|
|
43
|
-
padding: 5px;
|
|
44
|
-
text-align: center;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`;
|
|
48
|
-
var SumSetOptions;
|
|
49
|
-
(function (SumSetOptions) {
|
|
50
|
-
SumSetOptions["Auto"] = "auto";
|
|
51
|
-
SumSetOptions["Manual"] = "manual";
|
|
52
|
-
})(SumSetOptions || (SumSetOptions = {}));
|
|
53
|
-
function getValidationSchema(option) {
|
|
54
|
-
switch (option) {
|
|
55
|
-
case SumSetOptions.Auto: {
|
|
56
|
-
return Yup.object({
|
|
57
|
-
molecule: Yup.object().required(),
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
case SumSetOptions.Manual: {
|
|
61
|
-
return Yup.object({
|
|
62
|
-
sum: Yup.number().required(),
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
default:
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
export default function ChangeSumModal({ onSave, onClose, header, sumOptions, }) {
|
|
70
|
-
const { current: { display: { panels }, }, } = usePreferences();
|
|
71
|
-
const [setOption, setActiveOption] = useState(SumSetOptions.Auto);
|
|
72
|
-
const formRef = useRef(null);
|
|
73
|
-
function handleKeyDown(event) {
|
|
74
|
-
if (event.key === 'Enter') {
|
|
75
|
-
formRef.current.submitForm();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function onTabChangeHandler(tab) {
|
|
79
|
-
setActiveOption(tab.tabid);
|
|
80
|
-
}
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
|
|
83
|
-
setActiveOption(SumSetOptions.Auto);
|
|
84
|
-
const { mf, moleculeId: id } = sumOptions;
|
|
85
|
-
formRef.current.setValues({
|
|
86
|
-
sum: null,
|
|
87
|
-
molecule: id && mf ? { mf, id } : null,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
setActiveOption(SumSetOptions.Manual);
|
|
92
|
-
formRef.current.setValues({ sum: sumOptions?.sum ?? '', molecule: null });
|
|
93
|
-
}
|
|
94
|
-
}, [panels?.structuresPanel, sumOptions]);
|
|
95
|
-
function saveHandler(values) {
|
|
96
|
-
switch (setOption) {
|
|
97
|
-
case SumSetOptions.Auto: {
|
|
98
|
-
const { molecule: { mf, id: moleculeId }, } = values;
|
|
99
|
-
onSave({ sumAuto: true, mf, moleculeId });
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case SumSetOptions.Manual: {
|
|
103
|
-
const { sum } = values;
|
|
104
|
-
onSave({ sum, sumAuto: false });
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
default:
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
onClose();
|
|
111
|
-
}
|
|
112
|
-
const isStructurePanelVisible = panels?.structuresPanel?.display || false;
|
|
113
|
-
return (
|
|
114
|
-
// <div css={modalContainer}>
|
|
115
|
-
_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: header }), _jsx(CloseButton, { onClick: onClose })] }), _jsx("div", { className: "tab-content", children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: _jsxs(Tabs, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && (_jsx(Tab, { title: "Auto", tabid: SumSetOptions.Auto, children: _jsx(SelectMolecule, { name: "molecule" }) })), _jsx(Tab, { title: "Manual", tabid: SumSetOptions.Manual, children: _jsx("div", { className: "manual-container", children: _jsx(FormikInput, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), style: { width: '80px' }, children: "Set" }) })] }));
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Modal, useOnOff } from 'react-science/ui';
|
|
3
|
+
import { ChangeSumModalContents, } from './ChangeSumModalContents';
|
|
4
|
+
export default function ChangeSumModal({ renderButton, ...otherProps }) {
|
|
5
|
+
const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
|
|
6
|
+
return (_jsxs(_Fragment, { children: [renderButton(openDialog), _jsx(Modal, { isOpen: isOpenDialog, onRequestClose: closeDialog, width: 500, height: 400, children: _jsx(ChangeSumModalContents, { ...otherProps, onClose: closeDialog }) })] }));
|
|
116
7
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SumOptions } from 'nmr-load-save';
|
|
2
|
+
type SaveInput = {
|
|
3
|
+
sum: number;
|
|
4
|
+
sumAuto: false;
|
|
5
|
+
} | {
|
|
6
|
+
moleculeId: string;
|
|
7
|
+
mf: string;
|
|
8
|
+
sumAuto: true;
|
|
9
|
+
};
|
|
10
|
+
export interface ChangeSumModalContentsProps {
|
|
11
|
+
currentSum: number | null;
|
|
12
|
+
sumType: string;
|
|
13
|
+
sumOptions: SumOptions;
|
|
14
|
+
onSave: (saveInput: SaveInput) => void;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
}
|
|
17
|
+
export declare function ChangeSumModalContents(props: ChangeSumModalContentsProps): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { Formik } from 'formik';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Modal } from 'react-science/ui';
|
|
6
|
+
import * as Yup from 'yup';
|
|
7
|
+
import { usePreferences } from '../../context/PreferencesContext';
|
|
8
|
+
import Button from '../../elements/Button';
|
|
9
|
+
import Tab from '../../elements/Tab/Tab';
|
|
10
|
+
import Tabs from '../../elements/Tab/Tabs';
|
|
11
|
+
import FormikInput from '../../elements/formik/FormikInput';
|
|
12
|
+
import SelectMolecule from './SelectMolecule';
|
|
13
|
+
function getValidationSchema(option) {
|
|
14
|
+
switch (option) {
|
|
15
|
+
case 'auto': {
|
|
16
|
+
return Yup.object({
|
|
17
|
+
molecule: Yup.object().required(),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
case 'manual': {
|
|
21
|
+
return Yup.object({
|
|
22
|
+
sum: Yup.number().required(),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
default:
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const ManualContainer = styled.div `
|
|
30
|
+
padding: 30px 5px;
|
|
31
|
+
|
|
32
|
+
.input {
|
|
33
|
+
width: 80% !important;
|
|
34
|
+
height: 36px;
|
|
35
|
+
margin: 0 auto;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.input input {
|
|
39
|
+
padding: 5px;
|
|
40
|
+
text-align: center;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
export function ChangeSumModalContents(props) {
|
|
44
|
+
const { currentSum, sumType, sumOptions, onSave, onClose } = props;
|
|
45
|
+
const { current: { display: { panels }, }, } = usePreferences();
|
|
46
|
+
const [setOption, setActiveOption] = useState('auto');
|
|
47
|
+
const formRef = useRef(null);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
|
|
50
|
+
setActiveOption('auto');
|
|
51
|
+
const { mf, moleculeId: id } = sumOptions;
|
|
52
|
+
formRef.current.setValues({
|
|
53
|
+
sum: null,
|
|
54
|
+
molecule: id && mf ? { mf, id } : null,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
setActiveOption('manual');
|
|
59
|
+
formRef.current.setValues({
|
|
60
|
+
sum: sumOptions?.sum ?? '',
|
|
61
|
+
molecule: null,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}, [panels?.structuresPanel, sumOptions]);
|
|
65
|
+
function handleKeyDown(event) {
|
|
66
|
+
if (event.key === 'Enter') {
|
|
67
|
+
formRef.current.submitForm();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function onTabChangeHandler(tab) {
|
|
71
|
+
setActiveOption(tab.tabid);
|
|
72
|
+
}
|
|
73
|
+
function saveHandler(values) {
|
|
74
|
+
switch (setOption) {
|
|
75
|
+
case 'auto': {
|
|
76
|
+
const { molecule: { mf, id: moleculeId }, } = values;
|
|
77
|
+
onSave({ sumAuto: true, mf, moleculeId });
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case 'manual': {
|
|
81
|
+
const { sum } = values;
|
|
82
|
+
onSave({ sum, sumAuto: false });
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
default:
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
onClose();
|
|
89
|
+
}
|
|
90
|
+
const isStructurePanelVisible = panels?.structuresPanel?.display || false;
|
|
91
|
+
return (_jsxs(_Fragment, { children: [_jsx(Modal.Header, { children: currentSum
|
|
92
|
+
? `Set new ${sumType} sum (Current: ${currentSum.toFixed(2)})`
|
|
93
|
+
: `Set new ${sumType} Sum` }), _jsx(Modal.Body, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: _jsxs(Tabs, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && (_jsx(Tab, { title: "Auto", tabid: "auto", children: _jsx(SelectMolecule, { name: "molecule" }) })), _jsx(Tab, { title: "Manual", tabid: "manual", children: _jsx(ManualContainer, { children: _jsx(FormikInput, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), _jsx(Modal.Footer, { children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), style: { width: 80 }, children: "Set" }) })] }));
|
|
94
|
+
}
|
|
@@ -122,7 +122,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
122
122
|
}, [workspaces]);
|
|
123
123
|
const handleReset = () => {
|
|
124
124
|
const workSpaceDisplayPreferences = getPreferencesByWorkspace(workspaceName, originalWorkspaces);
|
|
125
|
-
refForm.current?.setValues(workSpaceDisplayPreferences);
|
|
125
|
+
void refForm.current?.setValues(workSpaceDisplayPreferences);
|
|
126
126
|
};
|
|
127
127
|
function submitHandler(values) {
|
|
128
128
|
saveSettings(values);
|
|
@@ -187,7 +187,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
187
187
|
const setWorkspaceSetting = useCallback((inputWorkspace) => {
|
|
188
188
|
const parseWorkspaceName = Object.keys(inputWorkspace)[0];
|
|
189
189
|
if (preferences.workspace.current === parseWorkspaceName) {
|
|
190
|
-
refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
|
|
190
|
+
void refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
|
|
191
191
|
}
|
|
192
192
|
else if (preferences.workspaces[parseWorkspaceName]) {
|
|
193
193
|
pastRef.current = inputWorkspace;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CustomWorkspaces } from 'nmr-load-save';
|
|
2
|
-
import { NMRiumWorkspace } from '../../../
|
|
2
|
+
import type { NMRiumWorkspace } from '../../../main';
|
|
3
3
|
interface DatabasesTabContentProps {
|
|
4
4
|
currentWorkspace: NMRiumWorkspace;
|
|
5
5
|
originalWorkspaces: CustomWorkspaces;
|
|
@@ -64,6 +64,13 @@ function InfoBlockTabContent() {
|
|
|
64
64
|
return (_jsx(FormikInput, { name: `infoBlock.fields.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => paths?.[key] || null, mapValue: (paths) => convertPathArrayToString(paths), datalist: datalist }));
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
|
+
{
|
|
68
|
+
Header: 'Format',
|
|
69
|
+
style: { padding: 0, ...styles.column },
|
|
70
|
+
Cell: ({ row }) => {
|
|
71
|
+
return (_jsx(FormikInput, { name: `infoBlock.fields.${row.index}.format`, style: { input: styles.input } }));
|
|
72
|
+
},
|
|
73
|
+
},
|
|
67
74
|
{
|
|
68
75
|
Header: 'Visible',
|
|
69
76
|
style: { width: '30px', ...styles.column },
|
|
@@ -71,11 +78,11 @@ function InfoBlockTabContent() {
|
|
|
71
78
|
},
|
|
72
79
|
{
|
|
73
80
|
Header: '',
|
|
74
|
-
style: { width: '
|
|
81
|
+
style: { width: '70px', ...styles.column },
|
|
75
82
|
id: 'add-button',
|
|
76
83
|
Cell: ({ data, row }) => {
|
|
77
84
|
const record = row.original;
|
|
78
|
-
return (_jsxs("div", { style: { display: 'flex' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, {}) }), !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: _jsx(FaTimes, {}) }))] }));
|
|
85
|
+
return (_jsxs("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: [_jsx(Button.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: _jsx(FaPlus, {}) }), !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: _jsx(FaTimes, {}) }))] }));
|
|
79
86
|
},
|
|
80
87
|
},
|
|
81
88
|
], [addHandler, datalist, deleteHandler, paths]);
|
|
@@ -13,7 +13,7 @@ import { useModal } from '../../elements/popup/Modal';
|
|
|
13
13
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
14
14
|
import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
|
|
15
15
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
16
|
-
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
16
|
+
import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
|
|
17
17
|
import PreferencesHeader from '../header/PreferencesHeader';
|
|
18
18
|
import IntegralTable from './IntegralTable';
|
|
19
19
|
import IntegralsPreferences from './IntegralsPreferences';
|
|
@@ -43,16 +43,10 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
43
43
|
}, [modal, yesHandler]);
|
|
44
44
|
const changeIntegralSumHandler = useCallback((options) => {
|
|
45
45
|
dispatch({ type: 'CHANGE_INTEGRAL_SUM', payload: { options } });
|
|
46
|
-
|
|
47
|
-
}, [dispatch, modal]);
|
|
46
|
+
}, [dispatch]);
|
|
48
47
|
const currentSum = useMemo(() => {
|
|
49
48
|
return lodashGet(integrals, 'options.sum', null);
|
|
50
49
|
}, [integrals]);
|
|
51
|
-
const showChangeIntegralSumModal = useCallback(() => {
|
|
52
|
-
modal.show(_jsx(ChangeSumModal, { onClose: () => modal.close(), onSave: changeIntegralSumHandler, header: currentSum
|
|
53
|
-
? `Set new integrals Sum (Current: ${Number(currentSum).toFixed(2)})`
|
|
54
|
-
: 'Set new integrals Sum', sumOptions: integrals?.options }));
|
|
55
|
-
}, [changeIntegralSumHandler, currentSum, integrals?.options, modal]);
|
|
56
50
|
const settingsPanelHandler = useCallback(() => {
|
|
57
51
|
setFlipStatus(!isFlipped);
|
|
58
52
|
}, [isFlipped]);
|
|
@@ -87,6 +81,7 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
87
81
|
}
|
|
88
82
|
return [];
|
|
89
83
|
}, [filterIsActive, info.dimension, integrals, xDomain]);
|
|
84
|
+
const counter = integrals?.values?.length || 0;
|
|
90
85
|
return (_jsxs("div", { css: [
|
|
91
86
|
tablePanelStyle,
|
|
92
87
|
style,
|
|
@@ -96,9 +91,9 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
|
|
|
96
91
|
position: relative;
|
|
97
92
|
}
|
|
98
93
|
`,
|
|
99
|
-
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter:
|
|
100
|
-
? `Change
|
|
101
|
-
: 'Change
|
|
94
|
+
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: counter, counterLabel: createFilterLabel(counter, filterIsActive && filteredData?.length), onDelete: handleDeleteAll, deleteToolTip: "Delete All Integrals", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all integrals' : 'Hide integrals out of view', showSettingButton: true, onSettingClick: settingsPanelHandler, children: [_jsx(ToolTip, { title: currentSum
|
|
95
|
+
? `Change integration sum (${currentSum.toFixed(2)})`
|
|
96
|
+
: 'Change integration sum', popupPlacement: "right", children: _jsx(ChangeSumModal, { onSave: changeIntegralSumHandler, sumType: "integrals", currentSum: currentSum, sumOptions: integrals?.options, renderButton: (onClick) => (_jsx("button", { className: "sum-button", type: "button", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration values", popupPlacement: "right", onClick: toggleConstantSumHandler, value: integrals?.options?.isSumConstant || false, children: _jsx(ImLink, {}) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(IntegralTable, { data: filteredData, activeTab: activeTab })) : (_jsx(IntegralsPreferences, { ref: settingRef })) })] }));
|
|
102
97
|
}
|
|
103
98
|
const MemoizedIntegralPanel = memo(IntegralPanelInner);
|
|
104
99
|
const emptyData = { integrals: {}, info: {} };
|
|
@@ -4,6 +4,7 @@ import { useCallback } from 'react';
|
|
|
4
4
|
import { FaCog, FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
|
|
5
5
|
import { IoOpenOutline } from 'react-icons/io5';
|
|
6
6
|
import { DropdownMenu } from 'react-science/ui';
|
|
7
|
+
import { getMolecules } from '../../../data/molecules/MoleculeManager';
|
|
7
8
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
8
9
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
9
10
|
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
@@ -21,7 +22,7 @@ const styles = {
|
|
|
21
22
|
margin: 0,
|
|
22
23
|
textAlign: 'right',
|
|
23
24
|
lineHeight: '22px',
|
|
24
|
-
padding: '0
|
|
25
|
+
padding: '0 5px',
|
|
25
26
|
whiteSpace: 'nowrap',
|
|
26
27
|
},
|
|
27
28
|
atomLabel: {
|
|
@@ -124,10 +125,11 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
124
125
|
function handlePasteMolfileAction() {
|
|
125
126
|
void readText().then(handlePasteMolfile);
|
|
126
127
|
}
|
|
127
|
-
function handlePasteMolfile(molfile) {
|
|
128
|
+
async function handlePasteMolfile(molfile) {
|
|
128
129
|
if (!molfile)
|
|
129
130
|
return;
|
|
130
|
-
|
|
131
|
+
const molecules = await getMolecules(molfile);
|
|
132
|
+
dispatch({ type: 'ADD_MOLECULES', payload: { molecules } });
|
|
131
133
|
cleanShouldFallback();
|
|
132
134
|
}
|
|
133
135
|
const handleDelete = useCallback(() => {
|
|
@@ -158,7 +160,5 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
158
160
|
});
|
|
159
161
|
}
|
|
160
162
|
const hasMolecules = molecules && molecules.length > 0;
|
|
161
|
-
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }),
|
|
162
|
-
molecules.length > 0 &&
|
|
163
|
-
`${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
|
|
163
|
+
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), molecules && molecules.length > 0 && (_jsx("p", { style: styles.counter, children: `${+(currentIndex + 1)} / ${molecules.length}` })), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
|
|
164
164
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import { Range, Zone } from 'nmr-processing';
|
|
2
|
+
import { DiaIDAndInfo } from 'openchemlib-utils';
|
|
2
3
|
import { AssignmentContext, Axis } from '../../assignment/AssignmentsContext';
|
|
3
|
-
export interface Atom {
|
|
4
|
-
oclID: string;
|
|
5
|
-
atomLabel: string;
|
|
6
|
-
nbAtoms: number;
|
|
7
|
-
nbHydrogens: number;
|
|
8
|
-
hydrogenOCLIDs: string[];
|
|
9
|
-
}
|
|
10
4
|
export interface AtomData {
|
|
11
5
|
oclIDs: string[];
|
|
12
6
|
nbAtoms: number;
|
|
@@ -17,12 +11,12 @@ export interface AtomData {
|
|
|
17
11
|
* In case of an heavy atom with bonded hydrogens the OCL id(s)
|
|
18
12
|
* and number of these hydrogens are added as well.
|
|
19
13
|
*
|
|
20
|
-
* @param {
|
|
14
|
+
* @param {DiaIDAndInfo} diaIDAndInfo - atom returned by OCLnmr component
|
|
21
15
|
* @param {string} activeTab - active tab
|
|
22
16
|
* @param {Axis} axis - current axis
|
|
23
17
|
*
|
|
24
18
|
*/
|
|
25
|
-
export declare function extractFromAtom(
|
|
19
|
+
export declare function extractFromAtom(diaIDAndInfo: DiaIDAndInfo | undefined, activeTab: string, axis?: Axis | null): AtomData;
|
|
26
20
|
export declare function findDatumAndSignalIndex(data: Array<Range | Zone>, id: string): {
|
|
27
21
|
datum: Range | Zone | undefined;
|
|
28
22
|
signalIndex: any;
|
|
@@ -10,31 +10,35 @@ function getElements(activeTab) {
|
|
|
10
10
|
* In case of an heavy atom with bonded hydrogens the OCL id(s)
|
|
11
11
|
* and number of these hydrogens are added as well.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {DiaIDAndInfo} diaIDAndInfo - atom returned by OCLnmr component
|
|
14
14
|
* @param {string} activeTab - active tab
|
|
15
15
|
* @param {Axis} axis - current axis
|
|
16
16
|
*
|
|
17
17
|
*/
|
|
18
|
-
export function extractFromAtom(
|
|
18
|
+
export function extractFromAtom(diaIDAndInfo, activeTab, axis) {
|
|
19
19
|
const elements = getElements(activeTab);
|
|
20
|
-
if (elements && elements.length > 0 &&
|
|
20
|
+
if (elements && elements.length > 0 && diaIDAndInfo) {
|
|
21
21
|
const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
|
|
22
22
|
switch (dim !== null && elements[dim]) {
|
|
23
|
-
case
|
|
23
|
+
case diaIDAndInfo.atomLabel: {
|
|
24
24
|
// take always oclID if atom type is same as element of activeTab)
|
|
25
|
-
return {
|
|
25
|
+
return {
|
|
26
|
+
oclIDs: [diaIDAndInfo.idCode],
|
|
27
|
+
nbAtoms: diaIDAndInfo.nbEquivalentAtoms,
|
|
28
|
+
};
|
|
26
29
|
}
|
|
27
30
|
case 'H': {
|
|
28
31
|
// if we are in proton spectrum and use then the IDs of attached hydrogens of an atom
|
|
29
32
|
return {
|
|
30
|
-
oclIDs:
|
|
31
|
-
nbAtoms:
|
|
33
|
+
oclIDs: diaIDAndInfo.attachedHydrogensIDCodes,
|
|
34
|
+
nbAtoms: diaIDAndInfo.nbEquivalentAtoms * diaIDAndInfo.nbAttachedHydrogens,
|
|
32
35
|
};
|
|
33
36
|
}
|
|
34
37
|
default:
|
|
35
38
|
return {
|
|
36
|
-
oclIDs: [
|
|
37
|
-
nbAtoms:
|
|
39
|
+
oclIDs: [diaIDAndInfo.idCode].concat(diaIDAndInfo.attachedHydrogensIDCodes),
|
|
40
|
+
nbAtoms: diaIDAndInfo.nbEquivalentAtoms +
|
|
41
|
+
diaIDAndInfo.nbEquivalentAtoms * diaIDAndInfo.nbAttachedHydrogens,
|
|
38
42
|
};
|
|
39
43
|
}
|
|
40
44
|
}
|
|
@@ -81,7 +85,7 @@ export function getCurrentDiaIDsToHighlight(assignmentData) {
|
|
|
81
85
|
const { highlighted, assignments } = assignmentData.data;
|
|
82
86
|
const assignment = highlighted ? assignments[highlighted.id] : null;
|
|
83
87
|
const axisHover = highlighted ? highlighted.axis : null;
|
|
84
|
-
if (axisHover && assignment
|
|
88
|
+
if (axisHover && assignment?.[axisHover]) {
|
|
85
89
|
return assignment[axisHover];
|
|
86
90
|
}
|
|
87
91
|
else {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { DiaIDAndInfo } from 'openchemlib-utils';
|
|
1
2
|
import { MouseEvent } from 'react';
|
|
2
|
-
import { Atom } from './Utilities';
|
|
3
3
|
export default function useAtomAssignment({ displayerMode, activeTab: nucleus, zones, ranges, }: {
|
|
4
4
|
displayerMode: any;
|
|
5
5
|
activeTab: any;
|
|
6
6
|
zones: any;
|
|
7
7
|
ranges: any;
|
|
8
8
|
}): {
|
|
9
|
-
handleOnAtomHover: (
|
|
10
|
-
handleOnClickAtom: (
|
|
9
|
+
handleOnAtomHover: (diaIDAndInfo: DiaIDAndInfo | undefined) => void;
|
|
10
|
+
handleOnClickAtom: (diaIDAndInfo: DiaIDAndInfo | undefined, event: MouseEvent) => void;
|
|
11
11
|
currentDiaIDsToHighlight: string[];
|
|
12
12
|
assignedDiaIDsMerged: string[];
|
|
13
13
|
};
|
|
@@ -100,11 +100,11 @@ export default function useAtomAssignment({ displayerMode, activeTab: nucleus, z
|
|
|
100
100
|
// see revision cc13abc18f77b6787b923e3c4edaef51750d9e90
|
|
101
101
|
return toggleDiaIDs(diaID, atomInformation);
|
|
102
102
|
}, []);
|
|
103
|
-
const handleOnClickAtom = useCallback((
|
|
103
|
+
const handleOnClickAtom = useCallback((diaIDAndInfo, event) => {
|
|
104
104
|
if (!checkModifierKeyActivated(event) && activeAssignment.activated) {
|
|
105
105
|
const { axis, id } = activeAssignment.activated;
|
|
106
106
|
if (id && axis) {
|
|
107
|
-
const atomInformation = extractFromAtom(
|
|
107
|
+
const atomInformation = extractFromAtom(diaIDAndInfo, nucleus, axis);
|
|
108
108
|
if (atomInformation.nbAtoms > 0) {
|
|
109
109
|
// save assignment in assignment hook
|
|
110
110
|
const dimension = displayerMode === DISPLAYER_MODE.DM_1D ? '1D' : '2D';
|
|
@@ -173,8 +173,8 @@ export default function useAtomAssignment({ displayerMode, activeTab: nucleus, z
|
|
|
173
173
|
nucleus,
|
|
174
174
|
toggleAssignment,
|
|
175
175
|
]);
|
|
176
|
-
const handleOnAtomHover = useCallback((
|
|
177
|
-
const { oclIDs } = extractFromAtom(
|
|
176
|
+
const handleOnAtomHover = useCallback((diaIDAndInfo) => {
|
|
177
|
+
const { oclIDs } = extractFromAtom(diaIDAndInfo, nucleus);
|
|
178
178
|
// on enter the atom
|
|
179
179
|
if (oclIDs.length > 0) {
|
|
180
180
|
// set all IDs to highlight when hovering over an atom from assignment data
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { SvgNmrFt, SvgNmrPeaks } from 'cheminfo-font';
|
|
4
|
+
import { SvgNmrFt, SvgNmrPeaks, SvgNmrPeaksTopLabels } from 'cheminfo-font';
|
|
5
5
|
import SvgPeaks from 'cheminfo-font/lib-react-cjs/lib-react-tsx/nmr/Peaks';
|
|
6
6
|
import { useCallback, useMemo, useState, useRef, memo } from 'react';
|
|
7
7
|
import { FaThinkPeaks } from 'react-icons/fa';
|
|
@@ -13,12 +13,12 @@ import ActiveButton from '../../elements/ActiveButton';
|
|
|
13
13
|
import Button from '../../elements/Button';
|
|
14
14
|
import { useAlert } from '../../elements/popup/Alert';
|
|
15
15
|
import { useModal } from '../../elements/popup/Modal';
|
|
16
|
-
import { useActiveSpectrumPeaksViewState
|
|
16
|
+
import { useActiveSpectrumPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
|
|
17
17
|
import useCheckExperimentalFeature from '../../hooks/useCheckExperimentalFeature';
|
|
18
18
|
import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus';
|
|
19
19
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
20
20
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
21
|
-
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
21
|
+
import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
|
|
22
22
|
import PreferencesHeader from '../header/PreferencesHeader';
|
|
23
23
|
import PeaksPreferences from './PeaksPreferences';
|
|
24
24
|
import PeaksTable from './PeaksTable';
|
|
@@ -86,6 +86,10 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
|
|
|
86
86
|
function toggleViewProperty(key) {
|
|
87
87
|
dispatch({ type: 'TOGGLE_PEAKS_VIEW_PROPERTY', payload: { key } });
|
|
88
88
|
}
|
|
89
|
+
function toggleDisplayingMode() {
|
|
90
|
+
dispatch({ type: 'TOGGLE_PEAKS_DISPLAYING_MODE' });
|
|
91
|
+
}
|
|
92
|
+
const counter = peaks?.values?.length || 0;
|
|
89
93
|
return (_jsxs("div", { css: [
|
|
90
94
|
tablePanelStyle,
|
|
91
95
|
isFlipped &&
|
|
@@ -97,11 +101,13 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
|
|
|
97
101
|
}
|
|
98
102
|
}
|
|
99
103
|
`,
|
|
100
|
-
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter:
|
|
104
|
+
], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: counter, counterLabel: createFilterLabel(counter, filterIsActive && filteredPeaks?.length), onDelete: handleDeleteAll, deleteToolTip: "Delete All Peaks", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all peaks' : 'Hide peaks out of view', showSettingButton: true, onSettingClick: settingsPanelHandler, children: [isExperimental && (_jsxs(_Fragment, { children: [_jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.showPeaksShapes
|
|
101
105
|
? 'Hide peaks shapes'
|
|
102
106
|
: 'Show peaks shapes', popupPlacement: "right", onClick: () => toggleViewProperty('showPeaksShapes'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.showPeaksShapes, children: _jsx(SvgPeaks, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.showPeaksSum
|
|
103
107
|
? 'Hide peaks sum'
|
|
104
|
-
: 'Show peaks sum', popupPlacement: "right", onClick: () => toggleViewProperty('showPeaksSum'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.showPeaksSum, children: _jsx(SvgNmrFt, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(Button.BarButton, { onClick: optimizePeaksHandler, toolTip: "Optimize peaks", tooltipOrientation: "horizontal", children: _jsx(FaThinkPeaks, {}) })] })), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.isPeaksVisible ? 'Hide peaks' : 'Show peaks', popupPlacement: "right", onClick: () => toggleViewProperty('isPeaksVisible'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.isPeaksVisible, children: _jsx(SvgNmrPeaks, { style: { pointerEvents: 'none', fontSize: '12px' } }) })
|
|
108
|
+
: 'Show peaks sum', popupPlacement: "right", onClick: () => toggleViewProperty('showPeaksSum'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.showPeaksSum, children: _jsx(SvgNmrFt, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(Button.BarButton, { onClick: optimizePeaksHandler, toolTip: "Optimize peaks", tooltipOrientation: "horizontal", children: _jsx(FaThinkPeaks, {}) })] })), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.isPeaksVisible ? 'Hide peaks' : 'Show peaks', popupPlacement: "right", onClick: () => toggleViewProperty('isPeaksVisible'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.isPeaksVisible, children: _jsx(SvgNmrPeaks, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.displayingMode === 'spread'
|
|
109
|
+
? 'Single Mode'
|
|
110
|
+
: 'Spread mode', popupPlacement: "right", onClick: toggleDisplayingMode, disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.displayingMode === 'spread', children: _jsx(SvgNmrPeaksTopLabels, { style: { pointerEvents: 'none', fontSize: '12px' } }) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(PeaksTable, { data: filteredPeaks, activeTab: activeTab })) : (_jsx(PeaksPreferences, { ref: settingRef })) })] }));
|
|
105
111
|
}
|
|
106
112
|
const MemoizedPeaksPanel = memo(PeaksPanelInner);
|
|
107
113
|
const emptyData = { peaks: null, info: {} };
|