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.
Files changed (197) hide show
  1. package/lib/component/1d/Chart1D.js +3 -3
  2. package/lib/component/1d/ExclusionZoneAnnotation.d.ts +11 -0
  3. package/lib/component/1d/ExclusionZoneAnnotation.js +18 -0
  4. package/lib/component/1d/ExclusionZonesAnnotations.d.ts +3 -0
  5. package/lib/component/1d/ExclusionZonesAnnotations.js +28 -0
  6. package/lib/component/1d/Line.js +11 -23
  7. package/lib/component/1d/Viewer1D.js +36 -5
  8. package/lib/component/1d/ranges/Ranges.js +3 -3
  9. package/lib/component/1d/{BaseLineZones.d.ts → tool/BaseLineZones.d.ts} +0 -0
  10. package/lib/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
  11. package/lib/component/1d/utilities/useIntegralPath.js +9 -10
  12. package/lib/component/2d/Contours.js +12 -11
  13. package/lib/component/2d/Left1DChart.js +7 -9
  14. package/lib/component/2d/Top1DChart.js +7 -7
  15. package/lib/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
  16. package/lib/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
  17. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  18. package/lib/component/EventsTrackers/KeysListenerTracker.js +106 -80
  19. package/lib/component/NMRium.d.ts +8 -3
  20. package/lib/component/NMRium.js +36 -33
  21. package/lib/component/elements/NumberInput.d.ts +1 -2
  22. package/lib/component/elements/Tab/Tab.js +1 -0
  23. package/lib/component/header/Header.js +10 -3
  24. package/lib/component/hooks/useActiveSpectrumStyleOptions.d.ts +6 -0
  25. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +15 -0
  26. package/lib/component/hooks/useCheckExperimentalFeature.js +2 -1
  27. package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -0
  28. package/lib/component/hooks/useCheckToolsVisibility.js +6 -0
  29. package/lib/component/hooks/useToolsFunctions.js +2 -1
  30. package/lib/component/hooks/useXYReduce.d.ts +2 -1
  31. package/lib/component/loader/DropZone.js +88 -88
  32. package/lib/component/modal/ModalStyle.js +5 -2
  33. package/lib/component/modal/MoleculeStructureEditorModal.js +3 -2
  34. package/lib/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
  35. package/lib/component/modal/changeSum/ChangeSumModal.js +4 -2
  36. package/lib/component/modal/setting/DisplayTabContent.js +1 -1
  37. package/lib/component/modal/setting/GeneralSettings.js +1 -5
  38. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
  39. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +4 -17
  40. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -0
  41. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +35 -0
  42. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +49 -67
  43. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
  44. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -23
  45. package/lib/component/panels/Panels.js +10 -0
  46. package/lib/component/panels/PeaksPanel/PeaksPanel.js +0 -3
  47. package/lib/component/panels/PeaksPanel/PeaksPreferences.js +5 -14
  48. package/lib/component/panels/RangesPanel/RangesPanel.js +0 -3
  49. package/lib/component/panels/RangesPanel/RangesPreferences.js +5 -18
  50. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
  51. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
  52. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.d.ts +5 -5
  53. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  54. package/lib/component/panels/SummaryPanel/Utilities.d.ts +7 -7
  55. package/lib/component/panels/ZonesPanel/ZonesPanel.js +0 -3
  56. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +5 -18
  57. package/lib/component/panels/ZonesPanel/ZonesTable.js +9 -2
  58. package/lib/component/panels/databasePanel/DatabasePanel.js +0 -3
  59. package/lib/component/panels/databasePanel/DatabasePreferences.js +4 -17
  60. package/lib/component/reducer/Reducer.d.ts +11 -27
  61. package/lib/component/reducer/Reducer.js +4 -5
  62. package/lib/component/reducer/actions/CorrelationsActions.d.ts +7 -7
  63. package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
  64. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -1
  65. package/lib/component/reducer/actions/FiltersActions.js +60 -18
  66. package/lib/component/reducer/actions/LoadActions.js +2 -3
  67. package/lib/component/reducer/actions/MoleculeActions.js +2 -2
  68. package/lib/component/reducer/actions/PreferencesActions.js +4 -7
  69. package/lib/component/reducer/actions/RangesActions.js +1 -1
  70. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -3
  71. package/lib/component/reducer/actions/ToolsActions.js +13 -59
  72. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -0
  73. package/lib/component/reducer/helper/ZoomHistoryManager.js +2 -1
  74. package/lib/component/reducer/helper/getRange.d.ts +6 -1
  75. package/lib/component/reducer/helper/getRange.js +1 -1
  76. package/lib/component/reducer/preferencesReducer.d.ts +2 -0
  77. package/lib/component/reducer/preferencesReducer.js +76 -36
  78. package/lib/component/toolbar/FunctionToolBar.js +9 -15
  79. package/lib/component/toolbar/ToolTypes.js +3 -3
  80. package/lib/component/utility/PathBuilder.d.ts +7 -0
  81. package/lib/component/utility/PathBuilder.js +17 -0
  82. package/lib/component/utility/getSpectraByNucleus.d.ts +3 -0
  83. package/lib/component/utility/getSpectraByNucleus.js +4 -0
  84. package/lib/component/workspaces/Workspace.d.ts +6 -0
  85. package/lib/component/workspaces/Workspace.js +1 -0
  86. package/lib/component/workspaces/basic.d.ts +2 -0
  87. package/lib/component/workspaces/basic.js +45 -0
  88. package/lib/component/workspaces/exercise1D.d.ts +2 -0
  89. package/lib/component/workspaces/exercise1D.js +45 -0
  90. package/lib/component/workspaces/index.d.ts +6 -0
  91. package/lib/component/workspaces/index.js +4 -0
  92. package/lib/component/workspaces/process1D.d.ts +2 -0
  93. package/lib/component/workspaces/process1D.js +43 -0
  94. package/lib/data/Filters.d.ts +2 -1
  95. package/lib/data/Filters.js +2 -1
  96. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
  97. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
  98. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
  99. package/lib/data/data1d/Spectrum1D/ranges/detectSignal.d.ts +3 -2
  100. package/lib/data/data1d/Spectrum1D/ranges/detectSignal.js +23 -15
  101. package/lib/data/data1d/filter1d/exclusionZones.d.ts +16 -0
  102. package/lib/data/data1d/filter1d/exclusionZones.js +28 -0
  103. package/lib/data/migration/MigrationManager.js +3 -0
  104. package/lib/data/types/data1d/ExclusionZone.d.ts +5 -0
  105. package/lib/data/types/data1d/ExclusionZone.js +1 -0
  106. package/lib/versionInfo.js +1 -1
  107. package/lib-cjs/component/1d/Chart1D.js +3 -3
  108. package/lib-cjs/component/1d/ExclusionZoneAnnotation.js +23 -0
  109. package/lib-cjs/component/1d/ExclusionZonesAnnotations.js +52 -0
  110. package/lib-cjs/component/1d/Line.js +11 -23
  111. package/lib-cjs/component/1d/Viewer1D.js +36 -5
  112. package/lib-cjs/component/1d/ranges/Ranges.js +1 -1
  113. package/lib-cjs/component/1d/{BaseLineZones.js → tool/BaseLineZones.js} +5 -5
  114. package/lib-cjs/component/1d/utilities/useIntegralPath.js +9 -10
  115. package/lib-cjs/component/2d/Contours.js +12 -11
  116. package/lib-cjs/component/2d/Left1DChart.js +7 -9
  117. package/lib-cjs/component/2d/Top1DChart.js +7 -7
  118. package/lib-cjs/component/2d/tools/slicing/HorizontalSliceChart.js +7 -7
  119. package/lib-cjs/component/2d/tools/slicing/VerticalSliceChart.js +7 -9
  120. package/lib-cjs/component/EventsTrackers/BrushTracker.js +2 -2
  121. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +106 -80
  122. package/lib-cjs/component/NMRium.js +37 -34
  123. package/lib-cjs/component/elements/Tab/Tab.js +1 -0
  124. package/lib-cjs/component/header/Header.js +10 -3
  125. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +21 -0
  126. package/lib-cjs/component/hooks/useCheckExperimentalFeature.js +5 -1
  127. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +13 -0
  128. package/lib-cjs/component/hooks/useToolsFunctions.js +2 -1
  129. package/lib-cjs/component/loader/DropZone.js +88 -88
  130. package/lib-cjs/component/modal/ModalStyle.js +5 -2
  131. package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +3 -2
  132. package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +10 -1
  133. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +4 -2
  134. package/lib-cjs/component/modal/setting/DisplayTabContent.js +1 -1
  135. package/lib-cjs/component/modal/setting/GeneralSettings.js +1 -5
  136. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
  137. package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +3 -16
  138. package/lib-cjs/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +40 -0
  139. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +48 -66
  140. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -8
  141. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -22
  142. package/lib-cjs/component/panels/Panels.js +10 -0
  143. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +0 -3
  144. package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +4 -13
  145. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +0 -3
  146. package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +4 -17
  147. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
  148. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DHistogram.js +1 -1
  149. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +0 -3
  150. package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +4 -17
  151. package/lib-cjs/component/panels/ZonesPanel/ZonesTable.js +8 -1
  152. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +0 -3
  153. package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +3 -16
  154. package/lib-cjs/component/reducer/Reducer.js +4 -5
  155. package/lib-cjs/component/reducer/actions/FiltersActions.js +62 -18
  156. package/lib-cjs/component/reducer/actions/LoadActions.js +2 -3
  157. package/lib-cjs/component/reducer/actions/MoleculeActions.js +2 -2
  158. package/lib-cjs/component/reducer/actions/PreferencesActions.js +4 -7
  159. package/lib-cjs/component/reducer/actions/RangesActions.js +1 -1
  160. package/lib-cjs/component/reducer/actions/ToolsActions.js +13 -61
  161. package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +2 -1
  162. package/lib-cjs/component/reducer/helper/getRange.js +1 -1
  163. package/lib-cjs/component/reducer/preferencesReducer.js +75 -35
  164. package/lib-cjs/component/toolbar/FunctionToolBar.js +9 -15
  165. package/lib-cjs/component/toolbar/ToolTypes.js +3 -3
  166. package/lib-cjs/component/utility/PathBuilder.js +21 -0
  167. package/lib-cjs/component/utility/getSpectraByNucleus.js +11 -0
  168. package/lib-cjs/component/workspaces/Workspace.js +2 -0
  169. package/lib-cjs/component/workspaces/basic.js +48 -0
  170. package/lib-cjs/component/workspaces/exercise1D.js +48 -0
  171. package/lib-cjs/component/workspaces/index.js +6 -0
  172. package/lib-cjs/component/workspaces/process1D.js +46 -0
  173. package/lib-cjs/data/Filters.js +3 -1
  174. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +5 -2
  175. package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -1
  176. package/lib-cjs/data/data1d/Spectrum1D/ranges/detectRange.js +0 -1
  177. package/lib-cjs/data/data1d/Spectrum1D/ranges/detectSignal.js +24 -15
  178. package/lib-cjs/data/data1d/filter1d/exclusionZones.js +34 -0
  179. package/lib-cjs/data/migration/MigrationManager.js +3 -0
  180. package/lib-cjs/data/types/data1d/ExclusionZone.js +2 -0
  181. package/lib-cjs/versionInfo.js +1 -1
  182. package/package.json +28 -29
  183. package/lib/component/1d/ExclusionZone.d.ts +0 -8
  184. package/lib/component/1d/ExclusionZone.js +0 -30
  185. package/lib/component/1d/ExclusionZones.d.ts +0 -2
  186. package/lib/component/1d/ExclusionZones.js +0 -10
  187. package/lib/component/nmriumMode/basic.d.ts +0 -38
  188. package/lib/component/nmriumMode/basic.js +0 -37
  189. package/lib/component/nmriumMode/exercise1D.d.ts +0 -38
  190. package/lib/component/nmriumMode/exercise1D.js +0 -37
  191. package/lib/component/nmriumMode/process1D.d.ts +0 -38
  192. package/lib/component/nmriumMode/process1D.js +0 -37
  193. package/lib-cjs/component/1d/ExclusionZone.js +0 -32
  194. package/lib-cjs/component/1d/ExclusionZones.js +0 -16
  195. package/lib-cjs/component/nmriumMode/basic.js +0 -39
  196. package/lib-cjs/component/nmriumMode/exercise1D.js +0 -39
  197. 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 loadsubFilesfromZip = useCallback((extractedfiles, uniqueFileExtensions) => {
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
- void loadFilesFromZip(selectedFilesByExtensions).then((files) => dispatch({ type: LOAD_MOL_FILE, files }));
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
- void loadFilesFromZip(selectedFilesByExtensions, {
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
- void loadFilesFromZip(selectedFilesByExtensions, {
74
+ case FILES_TYPES.DX: {
75
+ const files = await loadFilesFromZip(selectedFilesByExtensions, {
74
76
  asBuffer: true,
75
- }).then((files) => dispatch({ type: LOAD_JCAMP_FILE, files }));
77
+ });
78
+ dispatch({ type: LOAD_JCAMP_FILE, files });
76
79
  break;
77
- case FILES_TYPES.JDF:
78
- void loadFilesFromZip(selectedFilesByExtensions, {
80
+ }
81
+ case FILES_TYPES.JDF: {
82
+ const files = await loadFilesFromZip(selectedFilesByExtensions, {
79
83
  asBuffer: true,
80
- }).then((files) => dispatch({ type: LOAD_JDF_FILE, files }));
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
- switch (extension) {
94
- case FILES_TYPES.MOL:
95
- loadFiles(selectedFilesByExtensions).then((files) => {
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
- }, (err) => {
98
- // eslint-disable-next-line no-alert
99
- alert(err);
100
- });
101
- break;
102
- case FILES_TYPES.NMRIUM:
103
- case FILES_TYPES.JSON:
104
- if (selectedFilesByExtensions.length === 1) {
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
- loadsubFilesfromZip(Object.values(unzipResult.files), [
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
- }, (err) => {
122
- // eslint-disable-next-line no-alert
123
- alert(err);
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
- }, (err) => {
136
- // eslint-disable-next-line no-alert
137
- alert(err);
138
- });
139
- break;
140
- case FILES_TYPES.JDF:
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
- }, (err) => {
144
- // eslint-disable-next-line no-alert
145
- alert(err);
146
- });
147
- break;
148
- case FILES_TYPES.ZIP:
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
- loadsubFilesfromZip(Object.values(unzipResult.files), uniqueFileExtensions);
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
- }, (err) => {
169
- // eslint-disable-next-line no-alert
170
- alert(err);
171
- });
172
- break;
173
- case FILES_TYPES.NMREDATA:
174
- void loadFiles(selectedFilesByExtensions, { asBuffer: true }).then(async (files) => {
175
- for (const zipFile of files) {
176
- dispatch({
177
- type: LOAD_NMREDATA_FILE,
178
- file: zipFile,
179
- });
180
- }
181
- });
182
- break;
183
- default:
184
- dispatch({ type: SET_LOADING_FLAG, isLoading: false });
185
- // eslint-disable-next-line no-alert
186
- alert('The file extension must be zip, dx, jdx, json, mol, nmredata or nmrium.');
187
- break;
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, loadsubFilesfromZip]);
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
- setMolfile(newMolfile);
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: {
@@ -48,7 +48,7 @@ const LIST = [
48
48
  },
49
49
  {
50
50
  label: 'Experimental Features',
51
- name: 'display.hideExperimentalFeatures',
51
+ name: 'display.general.hideExperimentalFeatures',
52
52
  },
53
53
  ];
54
54
  function DisplayTabContent({ preferences }) {
@@ -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, setSettingsData]);
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 { useStateWithLocalStorage, getValue as getValueByKeyPath, } from '../../utility/LocalStorage';
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 saveToLocalStorgate = (values) => {
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
- if (showMessage) {
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
- const handleSubmit = (values) => {
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,2 @@
1
+ declare function MatrixGenerationPanel(): import("@emotion/react/jsx-runtime").JSX.Element;
2
+ export default MatrixGenerationPanel;
@@ -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, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
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 = css `
19
- display: flex;
20
- flex-direction: column;
21
- flex-grow: 1;
22
- width: 100%;
23
- height: 100%;
24
-
25
- .molecule-container {
26
- width: 100%;
27
- height: 100%;
28
- max-height: calc(100% - 25px);
29
-
30
- .slider {
31
- display: flex;
32
- flex-direction: column;
33
- justify-content: center;
34
- align-items: center;
35
- height: 100%;
36
- padding: 0px;
37
- .mol-svg-container {
38
- width: 100%;
39
- div {
40
- width: 100%;
41
- height: 100%;
42
- }
43
- }
44
-
45
- p {
46
- width: 100%;
47
- margin: 0 auto;
48
- display: block;
49
- position: relative;
50
- text-align: center;
51
- }
52
-
53
- svg polygon {
54
- fill: gray !important;
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", { className: "molecule-container", children: _jsx(ResponsiveChart, { children: ({ height, width }) => {
103
- return (_jsx(NextPrev, { onChange: (slideIndex) => setCurrentIndex(slideIndex), defaultIndex: currentIndex, children: molecules && molecules.length > 0 ? (molecules.map((mol, index) => (_jsxs(_Fragment, { children: [_jsx("div", { css: toolbarStyle, children: _jsxs("p", { children: [_jsx(MF, { mf: mol.mf }, void 0), " - ", mol.mw?.toFixed(2)] }, void 0) }, void 0), _jsx("div", { className: "slider", onDoubleClick: () => openMoleculeEditorHandler(mol), style: {
104
- backgroundColor: (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
105
- }, children: _jsx("div", { className: "mol-svg-container", children: _jsx(OCLnmr, { OCL: OCL, id: `molSVG${index}`, width: width, height: height, molfile: mol.molfile || '', setMolfile: (molfile) => handleReplaceMolecule(mol.key, molfile), setSelectedAtom: handleOnClickAtom, atomHighlightColor: currentDiaIDsToHighlight &&
106
- currentDiaIDsToHighlight.length > 0
107
- ? 'red'
108
- : '#FFD700', atomHighlightOpacity: 0.35, highlights: currentDiaIDsToHighlight &&
109
- currentDiaIDsToHighlight.length > 0
110
- ? currentDiaIDsToHighlight
111
- : assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0) }, void 0) }, mol.key)] }, void 0)))) : (_jsx("div", { style: { width: '100%', height: '100%' }, onClick: () => openMoleculeEditorHandler() }, void 0)) }, void 0));
112
- } }, void 0) }, void 0)] }, void 0));
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
- // 1. one atom can only be assigned to one range/zone/signal
102
- // 2. check whether an atom is already assigned to a range to allow toggling the assignment
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
- }, [alert, assignedDiaIDsMerged]);
104
+ }, []);
110
105
  const handleOnClickAtom = useCallback((atom, event) => {
111
106
  if (!checkModifierKeyActivated(event)) {
112
107
  if (activeAssignment.isActive) {