nmrium 0.19.1 → 0.21.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/Chart1D.js +3 -3
- package/lib/component/1d/ExclusionZoneAnnotation.d.ts +11 -0
- package/lib/component/1d/ExclusionZoneAnnotation.js +18 -0
- package/lib/component/1d/ExclusionZonesAnnotations.d.ts +3 -0
- package/lib/component/1d/ExclusionZonesAnnotations.js +28 -0
- package/lib/component/1d/Line.js +11 -23
- package/lib/component/1d/Viewer1D.js +36 -5
- package/lib/component/1d/ranges/Ranges.js +3 -3
- package/lib/component/1d/{BaseLineZones.d.ts → tool/BaseLineZones.d.ts} +0 -0
- package/lib/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib/component/2d/Contours.js +12 -11
- package/lib/component/2d/Left1DChart.js +7 -9
- package/lib/component/2d/Top1DChart.js +7 -7
- package/lib/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +106 -80
- package/lib/component/NMRium.d.ts +8 -3
- package/lib/component/NMRium.js +36 -33
- package/lib/component/elements/NumberInput.d.ts +1 -2
- package/lib/component/elements/Tab/Tab.js +1 -0
- package/lib/component/header/Header.js +10 -3
- package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
- package/lib/component/hooks/useCheckExperimentalFeature.js +2 -1
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -0
- package/lib/component/hooks/useCheckToolsVisibility.js +6 -0
- package/lib/component/hooks/useToolsFunctions.js +2 -1
- package/lib/component/hooks/useXYReduce.d.ts +2 -1
- package/lib/component/loader/DropZone.js +88 -88
- package/lib/component/modal/ModalStyle.js +5 -2
- package/lib/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +1 -5
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +4 -17
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -0
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +35 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +49 -67
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -23
- package/lib/component/panels/Panels.js +10 -0
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib/component/panels/PeaksPanel/PeaksPreferences.js +5 -14
- package/lib/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib/component/panels/RangesPanel/RangesPreferences.js +5 -18
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.d.ts +5 -5
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib/component/panels/SummaryPanel/Utilities.d.ts +7 -7
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +5 -18
- package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
- package/lib/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.js +4 -17
- package/lib/component/reducer/Reducer.d.ts +11 -27
- package/lib/component/reducer/Reducer.js +4 -5
- package/lib/component/reducer/actions/CorrelationsActions.d.ts +7 -7
- package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -1
- package/lib/component/reducer/actions/FiltersActions.js +60 -18
- package/lib/component/reducer/actions/LoadActions.js +2 -3
- package/lib/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib/component/reducer/actions/RangesActions.js +1 -1
- package/lib/component/reducer/actions/ToolsActions.d.ts +1 -3
- package/lib/component/reducer/actions/ToolsActions.js +13 -59
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib/component/reducer/helper/getRange.d.ts +6 -1
- package/lib/component/reducer/helper/getRange.js +1 -1
- package/lib/component/reducer/preferencesReducer.d.ts +2 -0
- package/lib/component/reducer/preferencesReducer.js +76 -36
- package/lib/component/toolbar/FunctionToolBar.js +9 -15
- package/lib/component/toolbar/ToolTypes.js +3 -3
- package/lib/component/utility/PathBuilder.d.ts +7 -0
- package/lib/component/utility/PathBuilder.js +17 -0
- package/lib/component/utility/getSpectraByNucleus.d.ts +3 -0
- package/lib/component/utility/getSpectraByNucleus.js +4 -0
- package/lib/component/workspaces/Workspace.d.ts +6 -0
- package/lib/component/workspaces/Workspace.js +1 -0
- package/lib/component/workspaces/basic.d.ts +2 -0
- package/lib/component/workspaces/basic.js +45 -0
- package/lib/component/workspaces/exercise1D.d.ts +2 -0
- package/lib/component/workspaces/exercise1D.js +45 -0
- package/lib/component/workspaces/index.d.ts +6 -0
- package/lib/component/workspaces/index.js +4 -0
- package/lib/component/workspaces/process1D.d.ts +2 -0
- package/lib/component/workspaces/process1D.js +43 -0
- package/lib/data/Filters.d.ts +2 -1
- package/lib/data/Filters.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +3 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +23 -15
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +16 -0
- package/lib/data/data1d/filter1d/exclusionZones.js +28 -0
- package/lib/data/migration/MigrationManager.js +3 -0
- package/lib/data/types/data1d/ExclusionZone.d.ts +5 -0
- package/lib/data/types/data1d/ExclusionZone.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/Chart1D.js +3 -3
- package/lib-cjs/component/1d/ExclusionZoneAnnotation.js +23 -0
- package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +52 -0
- package/lib-cjs/component/1d/Line.js +11 -23
- package/lib-cjs/component/1d/Viewer1D.js +36 -5
- package/lib-cjs/component/1d/ranges/Ranges.js +1 -1
- package/lib-cjs/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
- package/lib-cjs/component/1d/utilities/useIntegralPath.js +9 -10
- package/lib-cjs/component/2d/Contours.js +12 -11
- package/lib-cjs/component/2d/Left1DChart.js +7 -9
- package/lib-cjs/component/2d/Top1DChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
- package/lib-cjs/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
- package/lib-cjs/component/EventsTrackers/BrushTracker.js +2 -2
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +106 -80
- package/lib-cjs/component/NMRium.js +37 -34
- package/lib-cjs/component/elements/Tab/Tab.js +1 -0
- package/lib-cjs/component/header/Header.js +10 -3
- package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
- package/lib-cjs/component/hooks/useCheckExperimentalFeature.js +5 -1
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +13 -0
- package/lib-cjs/component/hooks/useToolsFunctions.js +2 -1
- package/lib-cjs/component/loader/DropZone.js +88 -88
- package/lib-cjs/component/modal/ModalStyle.js +5 -2
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +3 -2
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +1 -5
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +3 -16
- package/lib-cjs/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +40 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +48 -66
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
- package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -22
- package/lib-cjs/component/panels/Panels.js +10 -0
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +4 -13
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +4 -17
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +4 -17
- package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +3 -16
- package/lib-cjs/component/reducer/Reducer.js +4 -5
- package/lib-cjs/component/reducer/actions/FiltersActions.js +62 -18
- package/lib-cjs/component/reducer/actions/LoadActions.js +2 -3
- package/lib-cjs/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib-cjs/component/reducer/actions/PreferencesActions.js +4 -7
- package/lib-cjs/component/reducer/actions/RangesActions.js +1 -1
- package/lib-cjs/component/reducer/actions/ToolsActions.js +13 -61
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib-cjs/component/reducer/helper/getRange.js +1 -1
- package/lib-cjs/component/reducer/preferencesReducer.js +75 -35
- package/lib-cjs/component/toolbar/FunctionToolBar.js +9 -15
- package/lib-cjs/component/toolbar/ToolTypes.js +3 -3
- package/lib-cjs/component/utility/PathBuilder.js +21 -0
- package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
- package/lib-cjs/component/workspaces/Workspace.js +2 -0
- package/lib-cjs/component/workspaces/basic.js +48 -0
- package/lib-cjs/component/workspaces/exercise1D.js +48 -0
- package/lib-cjs/component/workspaces/index.js +6 -0
- package/lib-cjs/component/workspaces/process1D.js +46 -0
- package/lib-cjs/data/Filters.js +3 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
- package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
- package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +24 -15
- package/lib-cjs/data/data1d/filter1d/exclusionZones.js +34 -0
- package/lib-cjs/data/migration/MigrationManager.js +3 -0
- package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +28 -29
- package/lib/component/1d/ExclusionZone.d.ts +0 -8
- package/lib/component/1d/ExclusionZone.js +0 -30
- package/lib/component/1d/ExclusionZones.d.ts +0 -2
- package/lib/component/1d/ExclusionZones.js +0 -10
- package/lib/component/nmriumMode/basic.d.ts +0 -38
- package/lib/component/nmriumMode/basic.js +0 -37
- package/lib/component/nmriumMode/exercise1D.d.ts +0 -38
- package/lib/component/nmriumMode/exercise1D.js +0 -37
- package/lib/component/nmriumMode/process1D.d.ts +0 -38
- package/lib/component/nmriumMode/process1D.js +0 -37
- package/lib-cjs/component/1d/ExclusionZone.js +0 -32
- package/lib-cjs/component/1d/ExclusionZones.js +0 -16
- package/lib-cjs/component/nmriumMode/basic.js +0 -39
- package/lib-cjs/component/nmriumMode/exercise1D.js +0 -39
- package/lib-cjs/component/nmriumMode/process1D.js +0 -39
|
@@ -8,6 +8,7 @@ import { FaUpload } from 'react-icons/fa';
|
|
|
8
8
|
import { useChartData } from '../context/ChartContext';
|
|
9
9
|
import { useDispatch } from '../context/DispatchContext';
|
|
10
10
|
import { LoaderProvider } from '../context/LoaderContext';
|
|
11
|
+
import { useAlert } from '../elements/popup/Alert';
|
|
11
12
|
import { LOAD_MOL_FILE, LOAD_JSON_FILE, LOAD_JCAMP_FILE, SET_LOADING_FLAG, LOAD_ZIP_FILE, LOAD_JDF_FILE, LOAD_NMREDATA_FILE, } from '../reducer/types/Types';
|
|
12
13
|
import { FILES_TYPES, FILES_SIGNATURES, getFileExtension, getFileSignature, loadFiles, loadFilesFromZip, } from '../utility/FileUtility';
|
|
13
14
|
const style = css `
|
|
@@ -44,72 +45,75 @@ const containerStyle = css `
|
|
|
44
45
|
function DropZone(props) {
|
|
45
46
|
const { width, height } = useChartData();
|
|
46
47
|
const dispatch = useDispatch();
|
|
47
|
-
const
|
|
48
|
+
const alert = useAlert();
|
|
49
|
+
const loadSubFilesFromZip = useCallback(async (extractedfiles, uniqueFileExtensions) => {
|
|
48
50
|
for (let extension of uniqueFileExtensions) {
|
|
49
51
|
const selectedFilesByExtensions = extractedfiles.filter((file) => getFileExtension(file.name) === extension);
|
|
50
52
|
switch (extension) {
|
|
51
|
-
case FILES_TYPES.MOL:
|
|
52
|
-
|
|
53
|
+
case FILES_TYPES.MOL: {
|
|
54
|
+
const files = await loadFilesFromZip(selectedFilesByExtensions);
|
|
55
|
+
dispatch({ type: LOAD_MOL_FILE, files });
|
|
53
56
|
break;
|
|
57
|
+
}
|
|
54
58
|
case FILES_TYPES.NMRIUM:
|
|
55
|
-
case FILES_TYPES.JSON:
|
|
56
|
-
|
|
59
|
+
case FILES_TYPES.JSON: {
|
|
60
|
+
const files = await loadFilesFromZip(selectedFilesByExtensions, {
|
|
57
61
|
asBuffer: true,
|
|
58
|
-
}).then((files) => {
|
|
59
|
-
if (selectedFilesByExtensions.length === 1) {
|
|
60
|
-
const decoder = new TextDecoder('utf8');
|
|
61
|
-
files[0].binary = decoder.decode(files[0].binary);
|
|
62
|
-
dispatch({ type: LOAD_JSON_FILE, files });
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
dispatch({ type: SET_LOADING_FLAG, isLoading: false });
|
|
66
|
-
// eslint-disable-next-line no-alert
|
|
67
|
-
alert('You can add only one json file');
|
|
68
|
-
}
|
|
69
62
|
});
|
|
63
|
+
if (selectedFilesByExtensions.length === 1) {
|
|
64
|
+
const decoder = new TextDecoder('utf8');
|
|
65
|
+
files[0].binary = decoder.decode(files[0].binary);
|
|
66
|
+
dispatch({ type: LOAD_JSON_FILE, files });
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
throw new Error('You can add only one json file');
|
|
70
|
+
}
|
|
70
71
|
break;
|
|
72
|
+
}
|
|
71
73
|
case FILES_TYPES.JDX:
|
|
72
|
-
case FILES_TYPES.DX:
|
|
73
|
-
|
|
74
|
+
case FILES_TYPES.DX: {
|
|
75
|
+
const files = await loadFilesFromZip(selectedFilesByExtensions, {
|
|
74
76
|
asBuffer: true,
|
|
75
|
-
})
|
|
77
|
+
});
|
|
78
|
+
dispatch({ type: LOAD_JCAMP_FILE, files });
|
|
76
79
|
break;
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
}
|
|
81
|
+
case FILES_TYPES.JDF: {
|
|
82
|
+
const files = await loadFilesFromZip(selectedFilesByExtensions, {
|
|
79
83
|
asBuffer: true,
|
|
80
|
-
})
|
|
84
|
+
});
|
|
85
|
+
dispatch({ type: LOAD_JDF_FILE, files });
|
|
81
86
|
break;
|
|
87
|
+
}
|
|
82
88
|
default:
|
|
83
89
|
break;
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
}, [dispatch]);
|
|
87
|
-
const loadFilesHandler = useCallback((files) => {
|
|
93
|
+
const loadFilesHandler = useCallback(async (files) => {
|
|
88
94
|
const uniqueFileExtensions = [
|
|
89
95
|
...new Set(files.map((file) => getFileExtension(file.name))),
|
|
90
96
|
];
|
|
91
97
|
for (let extension of uniqueFileExtensions) {
|
|
92
98
|
const selectedFilesByExtensions = files.filter((file) => getFileExtension(file.name) === extension);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
try {
|
|
100
|
+
switch (extension) {
|
|
101
|
+
case FILES_TYPES.MOL: {
|
|
102
|
+
const files = await loadFiles(selectedFilesByExtensions);
|
|
96
103
|
dispatch({ type: LOAD_MOL_FILE, files });
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
loadFiles(selectedFilesByExtensions, {
|
|
106
|
-
asBuffer: true,
|
|
107
|
-
}).then(async (files) => {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case FILES_TYPES.NMRIUM:
|
|
107
|
+
case FILES_TYPES.JSON:
|
|
108
|
+
if (selectedFilesByExtensions.length === 1) {
|
|
109
|
+
const files = await loadFiles(selectedFilesByExtensions, {
|
|
110
|
+
asBuffer: true,
|
|
111
|
+
});
|
|
108
112
|
// InputFileFormat
|
|
109
113
|
const fileSignature = getFileSignature(files[0].binary);
|
|
110
114
|
if (fileSignature === FILES_SIGNATURES.ZIP) {
|
|
111
115
|
const unzipResult = await Zip.loadAsync(files[0].binary);
|
|
112
|
-
|
|
116
|
+
await loadSubFilesFromZip(Object.values(unzipResult.files), [
|
|
113
117
|
FILES_TYPES.NMRIUM,
|
|
114
118
|
]);
|
|
115
119
|
}
|
|
@@ -118,35 +122,30 @@ function DropZone(props) {
|
|
|
118
122
|
files[0].binary = decoder.decode(files[0].binary);
|
|
119
123
|
dispatch({ type: LOAD_JSON_FILE, files });
|
|
120
124
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
throw new Error('You can add only one json file');
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
case FILES_TYPES.JDX:
|
|
131
|
+
case FILES_TYPES.DX: {
|
|
132
|
+
const files = await loadFiles(selectedFilesByExtensions, {
|
|
133
|
+
asBuffer: true,
|
|
124
134
|
});
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// eslint-disable-next-line no-alert
|
|
128
|
-
alert('You can add only one json file');
|
|
129
|
-
}
|
|
130
|
-
break;
|
|
131
|
-
case FILES_TYPES.JDX:
|
|
132
|
-
case FILES_TYPES.DX:
|
|
133
|
-
loadFiles(selectedFilesByExtensions, { asBuffer: true }).then((files) => {
|
|
134
135
|
dispatch({ type: LOAD_JCAMP_FILE, files });
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
loadFiles(selectedFilesByExtensions, { asBuffer: true }).then((files) => {
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case FILES_TYPES.JDF: {
|
|
139
|
+
const files = await loadFiles(selectedFilesByExtensions, {
|
|
140
|
+
asBuffer: true,
|
|
141
|
+
});
|
|
142
142
|
dispatch({ type: LOAD_JDF_FILE, files });
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
loadFiles(selectedFilesByExtensions, { asBuffer: true }).then(async (files) => {
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case FILES_TYPES.ZIP: {
|
|
146
|
+
const files = await loadFiles(selectedFilesByExtensions, {
|
|
147
|
+
asBuffer: true,
|
|
148
|
+
});
|
|
150
149
|
for (const zipFile of files) {
|
|
151
150
|
const unzipResult = await Zip.loadAsync(zipFile.binary);
|
|
152
151
|
const uniqueFileExtensions = [
|
|
@@ -159,38 +158,39 @@ function DropZone(props) {
|
|
|
159
158
|
});
|
|
160
159
|
if (hasBruker)
|
|
161
160
|
dispatch({ type: LOAD_ZIP_FILE, files });
|
|
162
|
-
|
|
161
|
+
await loadSubFilesFromZip(Object.values(unzipResult.files), uniqueFileExtensions);
|
|
163
162
|
}
|
|
164
163
|
else {
|
|
165
164
|
dispatch({ type: LOAD_ZIP_FILE, files });
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
167
|
+
break;
|
|
168
|
+
}
|
|
169
|
+
case FILES_TYPES.NMREDATA:
|
|
170
|
+
void loadFiles(selectedFilesByExtensions, {
|
|
171
|
+
asBuffer: true,
|
|
172
|
+
}).then(async (files) => {
|
|
173
|
+
for (const zipFile of files) {
|
|
174
|
+
dispatch({
|
|
175
|
+
type: LOAD_NMREDATA_FILE,
|
|
176
|
+
file: zipFile,
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
break;
|
|
181
|
+
default:
|
|
182
|
+
throw new Error('The file extension must be zip, dx, jdx, json, mol, nmredata or nmrium.');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
catch (e) {
|
|
186
|
+
dispatch({ type: SET_LOADING_FLAG, isLoading: false });
|
|
187
|
+
alert.error(e.message);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
}, [dispatch,
|
|
190
|
+
}, [alert, dispatch, loadSubFilesFromZip]);
|
|
191
191
|
const onDrop = useCallback((droppedFiles) => {
|
|
192
192
|
dispatch({ type: SET_LOADING_FLAG, isLoading: true });
|
|
193
|
-
loadFilesHandler(droppedFiles);
|
|
193
|
+
void loadFilesHandler(droppedFiles);
|
|
194
194
|
}, [dispatch, loadFilesHandler]);
|
|
195
195
|
const { getRootProps, getInputProps, isDragActive, open: openImportDialog, } = useDropzone({
|
|
196
196
|
onDrop,
|
|
@@ -199,7 +199,7 @@ function DropZone(props) {
|
|
|
199
199
|
const open = useCallback(() => {
|
|
200
200
|
openImportDialog();
|
|
201
201
|
}, [openImportDialog]);
|
|
202
|
-
return (_jsx(LoaderProvider, { value: open, children: _jsxs("div", { ...getRootProps(), css: containerStyle, children: [_jsx("input", { ...getInputProps() }, void 0), isDragActive && (_jsxs("div", { css: style, style: {
|
|
202
|
+
return (_jsx(LoaderProvider, { value: open, children: _jsxs("div", { ...getRootProps(), role: "none", css: containerStyle, children: [_jsx("input", { "data-test-id": "dropzone-input", ...getInputProps() }, void 0), isDragActive && (_jsxs("div", { css: style, style: {
|
|
203
203
|
width: `${width}px`,
|
|
204
204
|
height: `${height}px`,
|
|
205
205
|
marginTop: '30px',
|
|
@@ -31,12 +31,15 @@ export const ModalStyles = css `
|
|
|
31
31
|
button:focus {
|
|
32
32
|
outline: none;
|
|
33
33
|
}
|
|
34
|
-
button:hover {
|
|
34
|
+
button:not([disabled]):hover {
|
|
35
35
|
color: #007bff;
|
|
36
36
|
}
|
|
37
|
-
.btn:hover {
|
|
37
|
+
.btn:not([disabled]):hover {
|
|
38
38
|
background-color: #ffffff;
|
|
39
39
|
}
|
|
40
|
+
.btn:disabled {
|
|
41
|
+
opacity: 0.5;
|
|
42
|
+
}
|
|
40
43
|
.btn {
|
|
41
44
|
border: none;
|
|
42
45
|
padding: 0 15px;
|
|
@@ -18,7 +18,8 @@ function MoleculeStructureEditorModal(props) {
|
|
|
18
18
|
}
|
|
19
19
|
}, [selectedMolecule]);
|
|
20
20
|
const cb = useCallback((newMolfile) => {
|
|
21
|
-
|
|
21
|
+
const molText = /(?<s>M {2}V30 BEGIN BOND)(?<mol>.*?)(?<e>M {2}V30 END BOND)/gs.exec(newMolfile)?.groups?.mol;
|
|
22
|
+
setMolfile(molText?.trim() ? newMolfile : null);
|
|
22
23
|
}, [setMolfile]);
|
|
23
24
|
const handleClose = useCallback(() => {
|
|
24
25
|
onClose();
|
|
@@ -33,6 +34,6 @@ function MoleculeStructureEditorModal(props) {
|
|
|
33
34
|
onClose('new');
|
|
34
35
|
}
|
|
35
36
|
}, [dispatch, selectedMolecule, molfile, onClose]);
|
|
36
|
-
return (_jsxs("div", { css: ModalStyles, children: [_jsx(StructureEditor, { initialMolfile: selectedMolecule?.molfile, svgMenu: true, fragment: false, onChange: cb }, void 0), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", className: "btn", onClick: handleSave, children: "Save" }, void 0), _jsx("button", { type: "button", className: "btn", onClick: handleClose, children: "Close" }, void 0)] }, void 0)] }, void 0));
|
|
37
|
+
return (_jsxs("div", { css: ModalStyles, children: [_jsx(StructureEditor, { initialMolfile: selectedMolecule?.molfile, svgMenu: true, fragment: false, onChange: cb }, void 0), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", className: "btn", onClick: handleSave, disabled: !molfile, children: "Save" }, void 0), _jsx("button", { type: "button", className: "btn", onClick: handleClose, children: "Close" }, void 0)] }, void 0)] }, void 0));
|
|
37
38
|
}
|
|
38
39
|
export default MoleculeStructureEditorModal;
|
|
@@ -49,6 +49,15 @@ const styles = css `
|
|
|
49
49
|
.container {
|
|
50
50
|
flex: 1;
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
.infoText {
|
|
54
|
+
padding: 10px;
|
|
55
|
+
font-size: 12px;
|
|
56
|
+
text-align: left;
|
|
57
|
+
color: white;
|
|
58
|
+
background-color: #5f5f5f;
|
|
59
|
+
border-radius: 5px;
|
|
60
|
+
}
|
|
52
61
|
`;
|
|
53
62
|
function MultipleSpectraFiltersModal({ onClose = () => null, nucleus = '', }) {
|
|
54
63
|
const refForm = useRef();
|
|
@@ -105,6 +114,6 @@ function MultipleSpectraFiltersModal({ onClose = () => null, nucleus = '', }) {
|
|
|
105
114
|
break;
|
|
106
115
|
}
|
|
107
116
|
}, [filter, submitHandler]);
|
|
108
|
-
return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Apply filters" }, void 0), _jsx(CloseButton, { onClick: onClose, className: "close-bt" }, void 0)] }, void 0), _jsxs("div", { className: "inner-content container", children: [_jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Filter :" }, void 0), _jsx(Select, { data: List, style: { width: 275, height: 30, margin: 0 }, onChange: filterChangeHandler }, void 0)] }, void 0), filterOptions] }, void 0), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", onClick: handleSave, className: "btn primary", children: "Apply" }, void 0), _jsx("button", { type: "button", onClick: onClose, className: "btn", children: "Close" }, void 0)] }, void 0)] }, void 0));
|
|
117
|
+
return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Apply filters" }, void 0), _jsx(CloseButton, { onClick: onClose, className: "close-bt" }, void 0)] }, void 0), _jsxs("div", { className: "inner-content container", children: [_jsx("p", { className: "infoText", children: "This filter will use the exclusions zones defined in the first spectrum." }, void 0), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Filter :" }, void 0), _jsx(Select, { data: List, style: { width: 275, height: 30, margin: 0 }, onChange: filterChangeHandler }, void 0)] }, void 0), filterOptions] }, void 0), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", onClick: handleSave, className: "btn primary", children: "Apply" }, void 0), _jsx("button", { type: "button", onClick: onClose, className: "btn", children: "Close" }, void 0)] }, void 0)] }, void 0));
|
|
109
118
|
}
|
|
110
119
|
export default MultipleSpectraFiltersModal;
|
|
@@ -72,7 +72,9 @@ export default function ChangeSumModal({ onSave, onClose, header, sumOptions, })
|
|
|
72
72
|
setActiveOption(tab.tabid);
|
|
73
73
|
}, []);
|
|
74
74
|
useEffect(() => {
|
|
75
|
-
if (sumOptions.sumAuto
|
|
75
|
+
if (sumOptions.sumAuto &&
|
|
76
|
+
!general.hideSetSumFromMolecule &&
|
|
77
|
+
!panels.hideStructuresPanel) {
|
|
76
78
|
setActiveOption(SumSetOptions.Auto);
|
|
77
79
|
const { mf, moleculeKey: key } = sumOptions;
|
|
78
80
|
formRef.current.setValues({
|
|
@@ -84,7 +86,7 @@ export default function ChangeSumModal({ onSave, onClose, header, sumOptions, })
|
|
|
84
86
|
setActiveOption(SumSetOptions.Manual);
|
|
85
87
|
formRef.current.setValues({ sum: sumOptions.sum, molecule: null });
|
|
86
88
|
}
|
|
87
|
-
}, [sumOptions]);
|
|
89
|
+
}, [general.hideSetSumFromMolecule, panels.hideStructuresPanel, sumOptions]);
|
|
88
90
|
const saveHandler = useCallback((values) => {
|
|
89
91
|
switch (setOption) {
|
|
90
92
|
case SumSetOptions.Auto: {
|
|
@@ -8,7 +8,6 @@ import Tab from '../../elements/Tab/Tab';
|
|
|
8
8
|
import Tabs, { PositionsEnum } from '../../elements/Tab/Tabs';
|
|
9
9
|
import FormikForm from '../../elements/formik/FormikForm';
|
|
10
10
|
import { SET_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
11
|
-
import { useStateWithLocalStorage } from '../../utility/LocalStorage';
|
|
12
11
|
import ControllersTabContent from './ControllersTabContent';
|
|
13
12
|
import DisplayTabContent from './DisplayTabContent';
|
|
14
13
|
import FormattingTabContent from './FormattingTabContent';
|
|
@@ -142,17 +141,14 @@ const styles = css `
|
|
|
142
141
|
function GeneralSettings({ onClose, onSave }) {
|
|
143
142
|
const [activeTab, setActiveTab] = useState('controllers');
|
|
144
143
|
const preferences = usePreferences();
|
|
145
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
146
144
|
const refForm = useRef();
|
|
147
145
|
const handleSave = useCallback(() => {
|
|
148
146
|
refForm.current.submitForm();
|
|
149
147
|
}, []);
|
|
150
148
|
const submitHandler = useCallback((values) => {
|
|
151
|
-
const { dispatch, basePreferences, ...resValues } = values;
|
|
152
|
-
setSettingsData(resValues);
|
|
153
149
|
preferences.dispatch({ type: SET_PREFERENCES, payload: values });
|
|
154
150
|
onSave?.();
|
|
155
|
-
}, [onSave, preferences
|
|
151
|
+
}, [onSave, preferences]);
|
|
156
152
|
const tabChangeHandler = useCallback((tab) => {
|
|
157
153
|
setActiveTab(tab.tabid);
|
|
158
154
|
}, []);
|
|
@@ -63,9 +63,6 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, preferences,
|
|
|
63
63
|
}, [changeIntegralSumHandler, currentSum, integrals?.options, modal]);
|
|
64
64
|
const settingsPanelHandler = useCallback(() => {
|
|
65
65
|
setFlipStatus(!isFlipped);
|
|
66
|
-
if (!isFlipped) {
|
|
67
|
-
settingRef.current.cancelSetting();
|
|
68
|
-
}
|
|
69
66
|
}, [isFlipped]);
|
|
70
67
|
const saveSettingHandler = useCallback(() => {
|
|
71
68
|
settingRef.current.saveSetting();
|
|
@@ -9,7 +9,7 @@ import FormikNumberInput from '../../elements/formik/FormikNumberInput';
|
|
|
9
9
|
import { useAlert } from '../../elements/popup/Alert';
|
|
10
10
|
import useNucleus from '../../hooks/useNucleus';
|
|
11
11
|
import { SET_PANELS_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
12
|
-
import {
|
|
12
|
+
import { getValue as getValueByKeyPath } from '../../utility/LocalStorage';
|
|
13
13
|
import { integralDefaultValues } from '../extra/preferences/defaultValues';
|
|
14
14
|
const styles = {
|
|
15
15
|
container: {
|
|
@@ -61,7 +61,6 @@ const formatFields = [
|
|
|
61
61
|
];
|
|
62
62
|
function IntegralsPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
63
63
|
const alert = useAlert();
|
|
64
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
65
64
|
const formRef = useRef();
|
|
66
65
|
const updateValues = useCallback(() => {
|
|
67
66
|
if (nucleus) {
|
|
@@ -78,31 +77,19 @@ function IntegralsPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
78
77
|
useEffect(() => {
|
|
79
78
|
updateValues();
|
|
80
79
|
}, [updateValues]);
|
|
81
|
-
const
|
|
82
|
-
setSettingsData(values, 'formatting.panels.integrals');
|
|
83
|
-
};
|
|
84
|
-
const saveHandler = useCallback((values, showMessage = false) => {
|
|
80
|
+
const saveHandler = useCallback((values) => {
|
|
85
81
|
preferences.dispatch({
|
|
86
82
|
type: SET_PANELS_PREFERENCES,
|
|
87
83
|
payload: { key: 'integrals', value: values },
|
|
88
84
|
});
|
|
89
|
-
|
|
90
|
-
alert.success('Integrals preferences saved successfully');
|
|
91
|
-
}
|
|
85
|
+
alert.success('Integrals preferences saved successfully');
|
|
92
86
|
}, [alert, preferences]);
|
|
93
87
|
useImperativeHandle(innerRef, () => ({
|
|
94
88
|
saveSetting: () => {
|
|
95
89
|
formRef.current.submitForm();
|
|
96
90
|
},
|
|
97
|
-
cancelSetting: () => {
|
|
98
|
-
updateValues();
|
|
99
|
-
},
|
|
100
91
|
}));
|
|
101
|
-
|
|
102
|
-
saveHandler(values, true);
|
|
103
|
-
saveToLocalStorgate(values);
|
|
104
|
-
};
|
|
105
|
-
return (_jsx("div", { style: styles.container, children: _jsxs(FormikForm, { onSubmit: handleSubmit, ref: formRef, children: [_jsxs("div", { style: styles.groupContainer, children: [_jsx("p", { style: styles.header, children: "General" }, void 0), _jsx(FormikColorInput, { name: "color" }, void 0), _jsx(FormikNumberInput, { name: "strokeWidth", label: "stroke width :", style: {
|
|
92
|
+
return (_jsx("div", { style: styles.container, children: _jsxs(FormikForm, { onSubmit: saveHandler, ref: formRef, children: [_jsxs("div", { style: styles.groupContainer, children: [_jsx("p", { style: styles.header, children: "General" }, void 0), _jsx(FormikColorInput, { name: "color" }, void 0), _jsx(FormikNumberInput, { name: "strokeWidth", label: "stroke width :", style: {
|
|
106
93
|
label: { fontSize: '11px', fontWeight: 'bold', color: '#232323' },
|
|
107
94
|
input: {
|
|
108
95
|
width: '60%',
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { SvgNmrAddFilter, SvgNmrExportAsMatrix } from 'cheminfo-font';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
6
|
+
import Button from '../../elements/ButtonToolTip';
|
|
7
|
+
import { positions, useModal } from '../../elements/popup/Modal';
|
|
8
|
+
import ExportAsMatrixModal from '../../modal/ExportAsMatrixModal';
|
|
9
|
+
import MultipleSpectraFiltersModal from '../../modal/MultipleSpectraFiltersModal';
|
|
10
|
+
import { RESET_SELECTED_TOOL } from '../../reducer/types/Types';
|
|
11
|
+
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
12
|
+
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
13
|
+
function MatrixGenerationPanel() {
|
|
14
|
+
const modal = useModal();
|
|
15
|
+
const dispatch = useDispatch();
|
|
16
|
+
const openFiltersModal = useCallback(() => {
|
|
17
|
+
dispatch({ type: RESET_SELECTED_TOOL });
|
|
18
|
+
modal.show(_jsx(MultipleSpectraFiltersModal, {}, void 0), {
|
|
19
|
+
isBackgroundBlur: false,
|
|
20
|
+
position: positions.TOP_CENTER,
|
|
21
|
+
width: 550,
|
|
22
|
+
height: 250,
|
|
23
|
+
});
|
|
24
|
+
}, [modal, dispatch]);
|
|
25
|
+
const openExportAsMatrixModal = useCallback(() => {
|
|
26
|
+
dispatch({ type: RESET_SELECTED_TOOL });
|
|
27
|
+
modal.show(_jsx(ExportAsMatrixModal, {}, void 0), {
|
|
28
|
+
isBackgroundBlur: false,
|
|
29
|
+
position: positions.TOP_CENTER,
|
|
30
|
+
width: 500,
|
|
31
|
+
});
|
|
32
|
+
}, [modal, dispatch]);
|
|
33
|
+
return (_jsxs("div", { css: tablePanelStyle, children: [_jsxs(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, children: [_jsx(Button, { popupTitle: "Add Filter", onClick: openFiltersModal, children: _jsx(SvgNmrAddFilter, { style: { fontSize: '18px' } }, void 0) }, void 0), _jsx(Button, { popupTitle: "Export spectra as a Matrix", onClick: openExportAsMatrixModal, children: _jsx(SvgNmrExportAsMatrix, {}, void 0) }, void 0)] }, void 0), _jsx("div", { className: "inner-container" }, void 0)] }, void 0));
|
|
34
|
+
}
|
|
35
|
+
export default MatrixGenerationPanel;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import OCL from 'openchemlib/full';
|
|
@@ -15,61 +15,43 @@ import MoleculeStructureEditorModal from '../../modal/MoleculeStructureEditorMod
|
|
|
15
15
|
import { SET_MOLECULE } from '../../reducer/types/Types';
|
|
16
16
|
import MoleculePanelHeader from './MoleculePanelHeader';
|
|
17
17
|
import useAtomAssignment from './useAtomAssignment';
|
|
18
|
-
const styles =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
display:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
`;
|
|
59
|
-
const toolbarStyle = css `
|
|
60
|
-
display: flex;
|
|
61
|
-
flex-direction: row;
|
|
62
|
-
border-bottom: 0.55px solid rgb(240, 240, 240);
|
|
63
|
-
padding: 0px 5px;
|
|
64
|
-
|
|
65
|
-
p {
|
|
66
|
-
margin: 0;
|
|
67
|
-
text-align: right;
|
|
68
|
-
width: 100%;
|
|
69
|
-
line-height: 22px;
|
|
70
|
-
padding: 0px 10px;
|
|
71
|
-
}
|
|
72
|
-
`;
|
|
18
|
+
const styles = {
|
|
19
|
+
panel: css({
|
|
20
|
+
display: 'flex',
|
|
21
|
+
flexGrow: 1,
|
|
22
|
+
width: '100%',
|
|
23
|
+
height: '100%',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
}),
|
|
26
|
+
molecule: css({
|
|
27
|
+
display: 'flex',
|
|
28
|
+
flex: '1 1 0%',
|
|
29
|
+
flexDirection: 'column',
|
|
30
|
+
minHeight: 0,
|
|
31
|
+
}),
|
|
32
|
+
toolbar: css({
|
|
33
|
+
display: 'flex',
|
|
34
|
+
borderBottom: '0.55px solid rgb(240, 240, 240)',
|
|
35
|
+
padding: '0px 10px',
|
|
36
|
+
justifyContent: 'end',
|
|
37
|
+
height: 22,
|
|
38
|
+
}),
|
|
39
|
+
slider: css({
|
|
40
|
+
display: 'flex',
|
|
41
|
+
flexDirection: 'column',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
flexGrow: 1,
|
|
45
|
+
minHeight: 0,
|
|
46
|
+
}),
|
|
47
|
+
items: css({
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexDirection: 'column',
|
|
50
|
+
flex: '1 1 0%',
|
|
51
|
+
height: '100%',
|
|
52
|
+
minHeight: 0,
|
|
53
|
+
}),
|
|
54
|
+
};
|
|
73
55
|
function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab, displayerMode, }) {
|
|
74
56
|
const [currentIndex, setCurrentIndex] = useState(0);
|
|
75
57
|
const [molecules, setMolecules] = useState([]);
|
|
@@ -99,17 +81,17 @@ function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab
|
|
|
99
81
|
const moleculeIndexHandler = useCallback((index) => {
|
|
100
82
|
setCurrentIndex(index);
|
|
101
83
|
}, []);
|
|
102
|
-
return (_jsxs("div", { css: styles, children: [_jsx(MoleculePanelHeader, { currentIndex: currentIndex, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditorHandler(), onMoleculeIndexChange: moleculeIndexHandler }, void 0), _jsx("div", {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
84
|
+
return (_jsxs("div", { css: styles.panel, children: [_jsx(MoleculePanelHeader, { currentIndex: currentIndex, molecules: molecules, onOpenMoleculeEditor: () => openMoleculeEditorHandler(), onMoleculeIndexChange: moleculeIndexHandler }, void 0), _jsx("div", { css: styles.molecule, children: _jsx(NextPrev, { onChange: (slideIndex) => setCurrentIndex(slideIndex), defaultIndex: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => (_jsxs("div", { css: styles.items, children: [_jsxs("span", { css: styles.toolbar, children: [_jsx(MF, { mf: mol.mf }, void 0), " - ", mol.mw?.toFixed(2)] }, void 0), _jsx("div", { css: styles.slider, className: "mol-svg-container", onDoubleClick: () => openMoleculeEditorHandler(mol), style: {
|
|
85
|
+
backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
|
|
86
|
+
}, children: _jsx(ResponsiveChart, { children: ({ height, width }) => {
|
|
87
|
+
return (_jsx(OCLnmr, { OCL: OCL, id: `molSVG${index}`, width: width, height: height, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol.key, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
|
|
88
|
+
currentDiaIDsToHighlight.length > 0
|
|
89
|
+
? 'red'
|
|
90
|
+
: '#FFD700', atomHighlightOpacity: 0.35, highlights: currentDiaIDsToHighlight &&
|
|
91
|
+
currentDiaIDsToHighlight.length > 0
|
|
92
|
+
? currentDiaIDsToHighlight
|
|
93
|
+
: assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0));
|
|
94
|
+
} }, void 0) }, void 0)] }, mol.key)))) : (_jsx("div", { css: styles.slider, style: { height: '100%' }, onClick: () => openMoleculeEditorHandler(), children: _jsx("span", { children: "Click to draw molecule" }, void 0) }, void 0)) }, void 0) }, void 0)] }, void 0));
|
|
113
95
|
}
|
|
114
96
|
const MemoizedMoleculePanel = memo(MoleculePanelInner);
|
|
115
97
|
const emptyData = { ranges: {}, zones: {} };
|
|
@@ -98,15 +98,10 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
98
98
|
return getCurrentDiaIDsToHighlight(assignmentData, displayerMode).concat(highlights);
|
|
99
99
|
}, [assignmentData, data, displayerMode, highlightData.highlight]);
|
|
100
100
|
const toggleAssignment = useCallback((diaID, atomInformation) => {
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
if (assignedDiaIDsMerged.some((_oclID) => atomInformation.oclIDs.includes(_oclID)) &&
|
|
104
|
-
!diaID.some((_oclID) => atomInformation.oclIDs.includes(_oclID))) {
|
|
105
|
-
alert.info('Atom is already assigned to another signal!');
|
|
106
|
-
return diaID;
|
|
107
|
-
}
|
|
101
|
+
// a previous version of the code prevented to assign many time the same atom
|
|
102
|
+
// see revision cc13abc18f77b6787b923e3c4edaef51750d9e90
|
|
108
103
|
return toggleDiaIDs(diaID, atomInformation);
|
|
109
|
-
}, [
|
|
104
|
+
}, []);
|
|
110
105
|
const handleOnClickAtom = useCallback((atom, event) => {
|
|
111
106
|
if (!checkModifierKeyActivated(event)) {
|
|
112
107
|
if (activeAssignment.isActive) {
|