nmrium 1.7.0 → 1.9.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 (258) hide show
  1. package/lib/component/1d/ranges/Atoms.d.ts.map +1 -1
  2. package/lib/component/1d/ranges/Atoms.js +24 -9
  3. package/lib/component/1d/ranges/Atoms.js.map +1 -1
  4. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts +2 -1
  5. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
  6. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +32 -42
  7. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
  8. package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.d.ts.map +1 -1
  9. package/lib/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.js.map +1 -1
  10. package/lib/component/2d/useTracesSpectra.d.ts.map +1 -1
  11. package/lib/component/2d/useTracesSpectra.js +2 -0
  12. package/lib/component/2d/useTracesSpectra.js.map +1 -1
  13. package/lib/component/2d/zones/SignalsGuideLines.js +1 -1
  14. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  15. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts.map +1 -1
  16. package/lib/component/EventsTrackers/KeysListenerTracker.js +6 -0
  17. package/lib/component/EventsTrackers/KeysListenerTracker.js.map +1 -1
  18. package/lib/component/hooks/useExport.js +1 -1
  19. package/lib/component/hooks/useExport.js.map +1 -1
  20. package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
  21. package/lib/component/loader/useLoadFiles.js +17 -7
  22. package/lib/component/loader/useLoadFiles.js.map +1 -1
  23. package/lib/component/main/NMRiumStateProvider.d.ts.map +1 -1
  24. package/lib/component/main/NMRiumStateProvider.js +2 -3
  25. package/lib/component/main/NMRiumStateProvider.js.map +1 -1
  26. package/lib/component/modal/LoadJCAMPModal.js +7 -2
  27. package/lib/component/modal/LoadJCAMPModal.js.map +1 -1
  28. package/lib/component/modal/MoleculeStructureEditorModal.d.ts.map +1 -1
  29. package/lib/component/modal/MoleculeStructureEditorModal.js +7 -3
  30. package/lib/component/modal/MoleculeStructureEditorModal.js.map +1 -1
  31. package/lib/component/modal/MultipletAnalysisModal.js +1 -1
  32. package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
  33. package/lib/component/modal/SaveAsModal.js +6 -2
  34. package/lib/component/modal/SaveAsModal.js.map +1 -1
  35. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.d.ts.map +1 -1
  36. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +17 -1
  37. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js.map +1 -1
  38. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts +6 -0
  39. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.d.ts.map +1 -0
  40. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js +87 -0
  41. package/lib/component/panels/MoleculesPanel/MoleculeOptionsPanel.js.map +1 -0
  42. package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts.map +1 -1
  43. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +18 -26
  44. package/lib/component/panels/MoleculesPanel/MoleculePanel.js.map +1 -1
  45. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  46. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +36 -31
  47. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  48. package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts +13 -0
  49. package/lib/component/panels/MoleculesPanel/MoleculeStructure.d.ts.map +1 -0
  50. package/lib/component/panels/MoleculesPanel/MoleculeStructure.js +66 -0
  51. package/lib/component/panels/MoleculesPanel/MoleculeStructure.js.map +1 -0
  52. package/lib/component/panels/MoleculesPanel/{useAtomAssignment.d.ts → hooks/useAtomAssignment.d.ts} +1 -1
  53. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.d.ts.map +1 -0
  54. package/lib/component/panels/MoleculesPanel/{useAtomAssignment.js → hooks/useAtomAssignment.js} +32 -16
  55. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -0
  56. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts +12 -0
  57. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts.map +1 -0
  58. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js +58 -0
  59. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js.map +1 -0
  60. package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts +5 -0
  61. package/lib/component/panels/MoleculesPanel/utilities/AtomData.d.ts.map +1 -0
  62. package/lib/component/panels/MoleculesPanel/utilities/AtomData.js +2 -0
  63. package/lib/component/panels/MoleculesPanel/utilities/AtomData.js.map +1 -0
  64. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts +16 -0
  65. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.d.ts.map +1 -0
  66. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js +47 -0
  67. package/lib/component/panels/MoleculesPanel/utilities/extractFromAtom.js.map +1 -0
  68. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts +18 -0
  69. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.d.ts.map +1 -0
  70. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js +31 -0
  71. package/lib/component/panels/MoleculesPanel/utilities/getAssignIds.js.map +1 -0
  72. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts +3 -0
  73. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.d.ts.map +1 -0
  74. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js +12 -0
  75. package/lib/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.js.map +1 -0
  76. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts +4 -0
  77. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.d.ts.map +1 -0
  78. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js +25 -0
  79. package/lib/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.js.map +1 -0
  80. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts +6 -0
  81. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.d.ts.map +1 -0
  82. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js +18 -0
  83. package/lib/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.js.map +1 -0
  84. package/lib/component/panels/databasePanel/DatabaseInfo.d.ts +5 -0
  85. package/lib/component/panels/databasePanel/DatabaseInfo.d.ts.map +1 -0
  86. package/lib/component/panels/databasePanel/DatabaseInfo.js +29 -0
  87. package/lib/component/panels/databasePanel/DatabaseInfo.js.map +1 -0
  88. package/lib/component/panels/databasePanel/DatabaseTable.d.ts.map +1 -1
  89. package/lib/component/panels/databasePanel/DatabaseTable.js +21 -3
  90. package/lib/component/panels/databasePanel/DatabaseTable.js.map +1 -1
  91. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts +9 -0
  92. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts.map +1 -0
  93. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js +27 -0
  94. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js.map +1 -0
  95. package/lib/component/panels/informationPanel/InformationEditionModal.js +1 -1
  96. package/lib/component/panels/informationPanel/InformationEditionModal.js.map +1 -1
  97. package/lib/component/reducer/IgnoreActions.d.ts.map +1 -1
  98. package/lib/component/reducer/IgnoreActions.js +2 -1
  99. package/lib/component/reducer/IgnoreActions.js.map +1 -1
  100. package/lib/component/reducer/Reducer.d.ts +11 -5
  101. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  102. package/lib/component/reducer/Reducer.js +8 -3
  103. package/lib/component/reducer/Reducer.js.map +1 -1
  104. package/lib/component/reducer/actions/DatabaseActions.d.ts.map +1 -1
  105. package/lib/component/reducer/actions/DatabaseActions.js +4 -2
  106. package/lib/component/reducer/actions/DatabaseActions.js.map +1 -1
  107. package/lib/component/reducer/actions/LoadAction.d.ts +7 -4
  108. package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
  109. package/lib/component/reducer/actions/LoadAction.js +35 -26
  110. package/lib/component/reducer/actions/LoadAction.js.map +1 -1
  111. package/lib/component/reducer/actions/MoleculeActions.d.ts +20 -5
  112. package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
  113. package/lib/component/reducer/actions/MoleculeActions.js +42 -28
  114. package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
  115. package/lib/component/reducer/actions/RangesActions.d.ts +10 -4
  116. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  117. package/lib/component/reducer/actions/RangesActions.js +24 -3
  118. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  119. package/lib/component/reducer/actions/ZonesActions.d.ts +1 -1
  120. package/lib/component/reducer/actions/ZonesActions.d.ts.map +1 -1
  121. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts +4 -0
  122. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.d.ts.map +1 -0
  123. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js +7 -0
  124. package/lib/component/reducer/preferences/actions/changeDefaultMoleculeSettings.js.map +1 -0
  125. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -1
  126. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js.map +1 -1
  127. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
  128. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  129. package/lib/component/reducer/preferences/preferencesReducer.js +3 -0
  130. package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
  131. package/lib/component/toolbar/ToolBar.d.ts.map +1 -1
  132. package/lib/component/toolbar/ToolBar.js +5 -1
  133. package/lib/component/toolbar/ToolBar.js.map +1 -1
  134. package/lib/component/toolbar/ToolTypes.d.ts.map +1 -1
  135. package/lib/component/toolbar/ToolTypes.js +2 -1
  136. package/lib/component/toolbar/ToolTypes.js.map +1 -1
  137. package/lib/component/utility/filterDatabaseInfoEntry.d.ts +3 -0
  138. package/lib/component/utility/filterDatabaseInfoEntry.d.ts.map +1 -0
  139. package/lib/component/utility/filterDatabaseInfoEntry.js +9 -0
  140. package/lib/component/utility/filterDatabaseInfoEntry.js.map +1 -0
  141. package/lib/component/workspaces/assignment.d.ts.map +1 -1
  142. package/lib/component/workspaces/assignment.js +7 -0
  143. package/lib/component/workspaces/assignment.js.map +1 -1
  144. package/lib/component/workspaces/basic.d.ts.map +1 -1
  145. package/lib/component/workspaces/basic.js +5 -0
  146. package/lib/component/workspaces/basic.js.map +1 -1
  147. package/lib/component/workspaces/embedded.d.ts.map +1 -1
  148. package/lib/component/workspaces/embedded.js +5 -0
  149. package/lib/component/workspaces/embedded.js.map +1 -1
  150. package/lib/component/workspaces/exercise.d.ts.map +1 -1
  151. package/lib/component/workspaces/exercise.js +5 -0
  152. package/lib/component/workspaces/exercise.js.map +1 -1
  153. package/lib/component/workspaces/prediction.d.ts.map +1 -1
  154. package/lib/component/workspaces/prediction.js +6 -1
  155. package/lib/component/workspaces/prediction.js.map +1 -1
  156. package/lib/component/workspaces/process1D.d.ts.map +1 -1
  157. package/lib/component/workspaces/process1D.js +6 -0
  158. package/lib/component/workspaces/process1D.js.map +1 -1
  159. package/lib/component/workspaces/simulation.js +1 -1
  160. package/lib/component/workspaces/simulation.js.map +1 -1
  161. package/lib/component/workspaces/workspaceDefaultProperties.d.ts.map +1 -1
  162. package/lib/component/workspaces/workspaceDefaultProperties.js +19 -1
  163. package/lib/component/workspaces/workspaceDefaultProperties.js.map +1 -1
  164. package/lib/data/SpectraManager.d.ts +1 -1
  165. package/lib/data/SpectraManager.d.ts.map +1 -1
  166. package/lib/data/SpectraManager.js.map +1 -1
  167. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +0 -1
  168. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
  169. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +17 -16
  170. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
  171. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts.map +1 -1
  172. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +2 -1
  173. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js.map +1 -1
  174. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +0 -1
  175. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  176. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +7 -6
  177. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  178. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts.map +1 -1
  179. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts.map +1 -1
  180. package/lib/data/molecules/Molecule.d.ts +1 -17
  181. package/lib/data/molecules/Molecule.d.ts.map +1 -1
  182. package/lib/data/molecules/Molecule.js +3 -7
  183. package/lib/data/molecules/Molecule.js.map +1 -1
  184. package/lib/data/molecules/MoleculeManager.d.ts +3 -2
  185. package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
  186. package/lib/data/molecules/MoleculeManager.js +31 -7
  187. package/lib/data/molecules/MoleculeManager.js.map +1 -1
  188. package/lib/utils/clipboard/clipboardHooks.js +4 -4
  189. package/lib/utils/clipboard/clipboardHooks.js.map +1 -1
  190. package/lib/versionInfo.js +1 -1
  191. package/package.json +30 -29
  192. package/src/component/1d/ranges/Atoms.tsx +36 -13
  193. package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +38 -79
  194. package/src/component/1d-2d/components/FloatMoleculeStructures/FloatMolecules.tsx +5 -2
  195. package/src/component/2d/useTracesSpectra.ts +2 -0
  196. package/src/component/2d/zones/SignalsGuideLines.tsx +1 -1
  197. package/src/component/EventsTrackers/KeysListenerTracker.tsx +6 -0
  198. package/src/component/hooks/useExport.tsx +1 -1
  199. package/src/component/loader/useLoadFiles.ts +19 -7
  200. package/src/component/main/NMRiumStateProvider.tsx +2 -3
  201. package/src/component/modal/LoadJCAMPModal.tsx +10 -4
  202. package/src/component/modal/MoleculeStructureEditorModal.tsx +10 -3
  203. package/src/component/modal/MultipletAnalysisModal.tsx +1 -1
  204. package/src/component/modal/SaveAsModal.tsx +8 -2
  205. package/src/component/modal/setting/settings-tabs/ToolsTabContent.tsx +17 -1
  206. package/src/component/panels/MoleculesPanel/MoleculeOptionsPanel.tsx +160 -0
  207. package/src/component/panels/MoleculesPanel/MoleculePanel.tsx +77 -101
  208. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +63 -42
  209. package/src/component/panels/MoleculesPanel/MoleculeStructure.tsx +117 -0
  210. package/src/component/panels/MoleculesPanel/{useAtomAssignment.tsx → hooks/useAtomAssignment.tsx} +47 -25
  211. package/src/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.ts +74 -0
  212. package/src/component/panels/MoleculesPanel/utilities/AtomData.ts +4 -0
  213. package/src/component/panels/MoleculesPanel/utilities/extractFromAtom.ts +63 -0
  214. package/src/component/panels/MoleculesPanel/utilities/getAssignIds.ts +59 -0
  215. package/src/component/panels/MoleculesPanel/utilities/getCurrentDiaIDsToHighlight.ts +12 -0
  216. package/src/component/panels/MoleculesPanel/utilities/getHighlightsOnHover.ts +36 -0
  217. package/src/component/panels/MoleculesPanel/utilities/getUniqueDiaIDs.ts +20 -0
  218. package/src/component/panels/databasePanel/DatabaseInfo.tsx +43 -0
  219. package/src/component/panels/databasePanel/DatabaseTable.tsx +33 -1
  220. package/src/component/panels/hooks/useMoleculeAnnotationCore.ts +36 -0
  221. package/src/component/panels/informationPanel/InformationEditionModal.tsx +2 -0
  222. package/src/component/reducer/IgnoreActions.ts +2 -1
  223. package/src/component/reducer/Reducer.ts +21 -8
  224. package/src/component/reducer/actions/DatabaseActions.ts +4 -2
  225. package/src/component/reducer/actions/LoadAction.ts +51 -38
  226. package/src/component/reducer/actions/MoleculeActions.ts +85 -37
  227. package/src/component/reducer/actions/RangesActions.ts +50 -5
  228. package/src/component/reducer/actions/ZonesActions.ts +1 -1
  229. package/src/component/reducer/preferences/actions/changeDefaultMoleculeSettings.ts +16 -0
  230. package/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts +1 -1
  231. package/src/component/reducer/preferences/preferencesReducer.ts +11 -1
  232. package/src/component/toolbar/ToolBar.tsx +6 -1
  233. package/src/component/toolbar/ToolTypes.ts +2 -1
  234. package/src/component/utility/filterDatabaseInfoEntry.ts +10 -0
  235. package/src/component/workspaces/assignment.ts +7 -0
  236. package/src/component/workspaces/basic.ts +5 -0
  237. package/src/component/workspaces/embedded.ts +5 -0
  238. package/src/component/workspaces/exercise.ts +5 -0
  239. package/src/component/workspaces/prediction.ts +6 -1
  240. package/src/component/workspaces/process1D.ts +6 -0
  241. package/src/component/workspaces/simulation.ts +1 -1
  242. package/src/component/workspaces/workspaceDefaultProperties.ts +19 -1
  243. package/src/data/SpectraManager.ts +1 -7
  244. package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +17 -19
  245. package/src/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.ts +2 -1
  246. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +7 -10
  247. package/src/data/molecules/Molecule.ts +5 -25
  248. package/src/data/molecules/MoleculeManager.ts +40 -8
  249. package/src/index.tsx +0 -3
  250. package/src/utils/clipboard/clipboardHooks.ts +6 -6
  251. package/src/versionInfo.ts +1 -1
  252. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +0 -43
  253. package/lib/component/panels/MoleculesPanel/Utilities.d.ts.map +0 -1
  254. package/lib/component/panels/MoleculesPanel/Utilities.js +0 -129
  255. package/lib/component/panels/MoleculesPanel/Utilities.js.map +0 -1
  256. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts.map +0 -1
  257. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js.map +0 -1
  258. package/src/component/panels/MoleculesPanel/Utilities.ts +0 -188
@@ -60,6 +60,10 @@ const LIST: ListItem[] = [
60
60
  label: 'Range picking',
61
61
  name: 'rangePicking',
62
62
  },
63
+ {
64
+ label: 'Inset',
65
+ name: 'inset',
66
+ },
63
67
  {
64
68
  label: 'Slicing',
65
69
  name: 'slicing',
@@ -92,10 +96,22 @@ const LIST: ListItem[] = [
92
96
  label: 'Fourier transform',
93
97
  name: 'fft',
94
98
  },
99
+ {
100
+ label: 'Fourier transform dimension one',
101
+ name: 'fftDimension1',
102
+ },
103
+ {
104
+ label: 'Fourier transform dimension two',
105
+ name: 'fftDimension2',
106
+ },
95
107
  {
96
108
  label: 'Phase correction',
97
109
  name: 'phaseCorrection',
98
110
  },
111
+ {
112
+ label: 'Two-Dimensional phase correction',
113
+ name: 'phaseCorrectionTwoDimensions',
114
+ },
99
115
  {
100
116
  label: 'Baseline correction',
101
117
  name: 'baselineCorrection',
@@ -105,7 +121,7 @@ const LIST: ListItem[] = [
105
121
  name: 'exclusionZones',
106
122
  },
107
123
  {
108
- label: 'Multiple spectra analysis',
124
+ label: 'Multiple spectra integration',
109
125
  name: 'multipleSpectraAnalysis',
110
126
  },
111
127
  {
@@ -0,0 +1,160 @@
1
+ import styled from '@emotion/styled';
2
+ import { yupResolver } from '@hookform/resolvers/yup';
3
+ import type { BoundingBox, MoleculeView } from '@zakodium/nmrium-core';
4
+ import { useForm } from 'react-hook-form';
5
+ import * as Yup from 'yup';
6
+
7
+ import { usePreferences } from '../../context/PreferencesContext.tsx';
8
+ import { CheckController } from '../../elements/CheckController.js';
9
+ import { GroupPane } from '../../elements/GroupPane.js';
10
+ import type { LabelStyle } from '../../elements/Label.js';
11
+ import Label from '../../elements/Label.js';
12
+ import { NumberInput2Controller } from '../../elements/NumberInput2Controller.js';
13
+ import { Select2Controller } from '../../elements/Select2Controller.js';
14
+ import PreferencesHeader from '../header/PreferencesHeader.tsx';
15
+
16
+ const atomAnnotations: Array<{
17
+ value: MoleculeView['atomAnnotation'];
18
+ label: string;
19
+ }> = [
20
+ { value: 'none', label: 'None' },
21
+ { value: 'atom-numbers', label: 'Atoms number' },
22
+ { value: 'custom-labels', label: 'Custom labels' },
23
+ ];
24
+ const Container = styled.div`
25
+ display: flex;
26
+ flex-direction: column;
27
+ height: 100%;
28
+ width: 100%;
29
+ `;
30
+ const InnerContainer = styled.div`
31
+ overflow: auto;
32
+ height: 100%;
33
+ display: block;
34
+ background-color: white;
35
+ `;
36
+ const boundingBoxSchema: Yup.ObjectSchema<BoundingBox> = Yup.object({
37
+ width: Yup.number().required().min(0, 'Width must be positive'),
38
+ height: Yup.number().required().min(0, 'Height must be positive'),
39
+ x: Yup.number().required(),
40
+ y: Yup.number().required(),
41
+ }).defined();
42
+
43
+ const moleculeViewSchema: Yup.ObjectSchema<MoleculeView> = Yup.object({
44
+ floating: Yup.object({
45
+ visible: Yup.boolean().required(),
46
+ bounding: boundingBoxSchema.required(),
47
+ }),
48
+ showLabel: Yup.boolean().required(),
49
+ atomAnnotation: Yup.mixed<'none' | 'atom-numbers' | 'custom-labels'>()
50
+ .oneOf(['none', 'atom-numbers', 'custom-labels'])
51
+ .required()
52
+ .default('none'),
53
+ }).defined();
54
+
55
+ const labelStyle: LabelStyle = {
56
+ label: { flex: 4, fontWeight: '500' },
57
+ wrapper: { flex: 8, display: 'flex', alignItems: 'center' },
58
+ container: { padding: '5px 0' },
59
+ };
60
+
61
+ const styles = {
62
+ select: {
63
+ width: '100%',
64
+ minWidth: '100px',
65
+ maxWidth: '280px',
66
+ height: 30,
67
+ margin: 0,
68
+ },
69
+ groupHeader: {
70
+ borderBottom: '1px solid #efefef',
71
+ paddingBottom: '5px',
72
+ fontWeight: '600',
73
+ color: '#005d9e',
74
+ },
75
+ };
76
+
77
+ interface MoleculeOptionsPanelProps {
78
+ onClose: () => void;
79
+ }
80
+
81
+ export function MoleculeOptionsPanel(props: MoleculeOptionsPanelProps) {
82
+ const { onClose } = props;
83
+ const {
84
+ current: { defaultMoleculeSettings },
85
+ } = usePreferences();
86
+ const { handleSubmit, control } = useForm<MoleculeView>({
87
+ defaultValues: defaultMoleculeSettings,
88
+ resolver: yupResolver(moleculeViewSchema),
89
+ });
90
+ const { dispatch } = usePreferences();
91
+
92
+ function handleSave() {
93
+ void handleSubmit((values) => {
94
+ dispatch({ type: 'CHANGE_DEFAULT_MOLECULE_SETTINGS', payload: values });
95
+ onClose();
96
+ })();
97
+ }
98
+ return (
99
+ <Container>
100
+ <PreferencesHeader onSave={handleSave} onClose={onClose} />
101
+ <InnerContainer>
102
+ <GroupPane
103
+ text="General"
104
+ style={{
105
+ header: styles.groupHeader,
106
+ }}
107
+ >
108
+ <Label title="Show label" style={labelStyle}>
109
+ <CheckController control={control} name="showLabel" />
110
+ </Label>
111
+ <Label title="Atom annotation" style={labelStyle}>
112
+ <Select2Controller
113
+ control={control}
114
+ items={atomAnnotations}
115
+ name="atomAnnotation"
116
+ />
117
+ </Label>
118
+ </GroupPane>
119
+ <GroupPane
120
+ text="Size & position"
121
+ style={{
122
+ header: styles.groupHeader,
123
+ }}
124
+ >
125
+ <Label title="Floating molecule" style={labelStyle}>
126
+ <CheckController control={control} name="floating.visible" />
127
+ </Label>
128
+ <Label title="X (%)" style={labelStyle}>
129
+ <NumberInput2Controller
130
+ control={control}
131
+ name="floating.bounding.x"
132
+ fill
133
+ />
134
+ </Label>
135
+ <Label title="Y (%)" style={labelStyle}>
136
+ <NumberInput2Controller
137
+ control={control}
138
+ name="floating.bounding.y"
139
+ fill
140
+ />
141
+ </Label>
142
+ <Label title="Width" style={labelStyle}>
143
+ <NumberInput2Controller
144
+ control={control}
145
+ name="floating.bounding.width"
146
+ fill
147
+ />
148
+ </Label>
149
+ <Label title="Height" style={labelStyle}>
150
+ <NumberInput2Controller
151
+ control={control}
152
+ name="floating.bounding.height"
153
+ fill
154
+ />
155
+ </Label>
156
+ </GroupPane>
157
+ </InnerContainer>
158
+ </Container>
159
+ );
160
+ }
@@ -1,23 +1,21 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import type { SerializedStyles } from '@emotion/react';
3
3
  import { css } from '@emotion/react';
4
- import { memo, useEffect, useState } from 'react';
4
+ import { memo, useCallback, useEffect, useState } from 'react';
5
5
  import { ResponsiveChart } from 'react-d3-utils';
6
- import OCLnmr from 'react-ocl-nmr';
7
6
 
8
7
  import type {
9
8
  MoleculesView,
10
9
  StateMoleculeExtended,
11
10
  } from '../../../data/molecules/Molecule.js';
12
11
  import { useChartData } from '../../context/ChartContext.js';
13
- import { useDispatch } from '../../context/DispatchContext.js';
14
12
  import { NextPrev } from '../../elements/NextPrev.js';
15
- import { useHighlightColor } from '../../hooks/useHighlightColor.js';
16
13
  import { useMoleculeEditor } from '../../modal/MoleculeStructureEditorModal.js';
17
14
 
18
15
  import MoleculeHeader from './MoleculeHeader.js';
16
+ import { MoleculeOptionsPanel } from './MoleculeOptionsPanel.tsx';
19
17
  import MoleculePanelHeader from './MoleculePanelHeader.js';
20
- import useAtomAssignment from './useAtomAssignment.js';
18
+ import { MoleculeStructure } from './MoleculeStructure.tsx';
21
19
 
22
20
  const styles: Record<
23
21
  'panel' | 'innerPanel' | 'molecule' | 'slider' | 'items',
@@ -61,20 +59,13 @@ function MoleculePanelInner(props: MoleculePanelInnerProps) {
61
59
  const { molecules: moleculesProp, moleculesView } = props;
62
60
  const [currentIndex, setCurrentIndex] = useState(0);
63
61
  const [molecules, setMolecules] = useState<StateMoleculeExtended[]>([]);
62
+ const [isFlipped, setFlipStatus] = useState(false);
64
63
 
65
- const dispatch = useDispatch();
66
64
  const { modal, openMoleculeEditor } = useMoleculeEditor();
67
- const highlightColor = useHighlightColor();
68
-
69
- const {
70
- currentDiaIDsToHighlight,
71
- handleOnAtomHover,
72
- handleOnClickAtom,
73
- assignedDiaIDsMerged,
74
- } = useAtomAssignment();
75
65
 
76
66
  useEffect(() => {
77
67
  if (moleculesProp) {
68
+ // eslint-disable-next-line react-you-might-not-need-an-effect/no-derived-state
78
69
  setMolecules((prevMolecules) => {
79
70
  if (moleculesProp.length > prevMolecules.length) {
80
71
  setCurrentIndex(molecules.length);
@@ -84,14 +75,6 @@ function MoleculePanelInner(props: MoleculePanelInnerProps) {
84
75
  }
85
76
  }, [molecules.length, moleculesProp]);
86
77
 
87
- function handleReplaceMolecule(molecule: any, molfile: any) {
88
- const { id, label } = molecule;
89
- dispatch({
90
- type: 'SET_MOLECULE',
91
- payload: { molfile, id, label },
92
- });
93
- }
94
-
95
78
  function moleculeIndexHandler(index: any) {
96
79
  setCurrentIndex(index);
97
80
  }
@@ -99,89 +82,82 @@ function MoleculePanelInner(props: MoleculePanelInnerProps) {
99
82
  const lastIndex = molecules?.length > 0 ? molecules.length - 1 : 0;
100
83
  const activeIndex = Math.min(currentIndex, lastIndex);
101
84
 
85
+ const settingsPanelHandler = useCallback(() => {
86
+ setFlipStatus(!isFlipped);
87
+ }, [isFlipped]);
88
+
89
+ const onClose = useCallback(() => {
90
+ setFlipStatus(false);
91
+ }, []);
92
+
102
93
  return (
103
94
  <div css={styles.panel}>
104
- <MoleculePanelHeader
105
- currentIndex={activeIndex}
106
- moleculesView={moleculesView}
107
- molecules={molecules}
108
- onOpenMoleculeEditor={() => openMoleculeEditor()}
109
- onMoleculeIndexChange={moleculeIndexHandler}
110
- />
111
-
112
- <div css={styles.innerPanel}>
113
- <div css={styles.molecule}>
114
- <ResponsiveChart>
115
- {({ height, width }) => {
116
- return (
117
- <NextPrev
118
- onChange={(slideIndex) => setCurrentIndex(slideIndex)}
119
- index={currentIndex}
120
- >
121
- {molecules && molecules.length > 0 ? (
122
- molecules.map((mol: StateMoleculeExtended, index) => (
123
- <div key={mol.id} css={styles.items}>
124
- <MoleculeHeader
125
- currentMolecule={mol}
126
- molecules={molecules}
127
- />
128
-
129
- <div
130
- css={styles.slider}
131
- className="mol-svg-container"
132
- onDoubleClick={() => openMoleculeEditor(mol)}
133
- style={{
134
- backgroundColor:
135
- (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
136
- }}
137
- >
138
- <OCLnmr
139
- id={`molSVG${index}`}
140
- width={width}
141
- height={height - 60}
142
- molfile={mol.molfile || ''}
143
- setMolfile={(molfile) =>
144
- handleReplaceMolecule(mol, molfile)
145
- }
146
- setSelectedAtom={handleOnClickAtom}
147
- atomHighlightColor={
148
- currentDiaIDsToHighlight &&
149
- currentDiaIDsToHighlight.length > 0
150
- ? '#ff000080'
151
- : highlightColor
152
- }
153
- atomHighlightOpacity={1}
154
- highlights={
155
- currentDiaIDsToHighlight &&
156
- currentDiaIDsToHighlight.length > 0
157
- ? currentDiaIDsToHighlight
158
- : assignedDiaIDsMerged
159
- }
160
- atomHighlightStrategy="prefer-editor-props"
161
- setHoverAtom={handleOnAtomHover}
162
- showAtomNumber={
163
- moleculesView?.[mol.id]?.showAtomNumber || false
164
- }
165
- noCarbonLabelWithCustomLabel
166
- />
167
- </div>
95
+ {!isFlipped && (
96
+ <MoleculePanelHeader
97
+ currentIndex={activeIndex}
98
+ moleculesView={moleculesView}
99
+ molecules={molecules}
100
+ onOpenMoleculeEditor={() => openMoleculeEditor()}
101
+ onMoleculeIndexChange={moleculeIndexHandler}
102
+ onClickPreferences={settingsPanelHandler}
103
+ />
104
+ )}
105
+ {isFlipped && <MoleculeOptionsPanel onClose={onClose} />}
106
+ {!isFlipped && (
107
+ <div css={styles.innerPanel}>
108
+ <div css={styles.molecule}>
109
+ <ResponsiveChart>
110
+ {({ height, width }) => {
111
+ return (
112
+ <NextPrev
113
+ onChange={(slideIndex) => setCurrentIndex(slideIndex)}
114
+ index={currentIndex}
115
+ >
116
+ {molecules && molecules.length > 0 ? (
117
+ molecules.map((mol: StateMoleculeExtended, index) => {
118
+ return (
119
+ <div key={mol.id} css={styles.items}>
120
+ <MoleculeHeader
121
+ currentMolecule={mol}
122
+ molecules={molecules}
123
+ />
124
+
125
+ <div
126
+ css={styles.slider}
127
+ className="mol-svg-container"
128
+ onDoubleClick={() => openMoleculeEditor(mol)}
129
+ style={{
130
+ backgroundColor:
131
+ (index + 1) % 2 !== 0 ? '#fafafa' : 'white',
132
+ }}
133
+ >
134
+ <MoleculeStructure
135
+ index={index}
136
+ width={width}
137
+ height={height - 60}
138
+ molecule={mol}
139
+ moleculeView={moleculesView?.[mol.id] || {}}
140
+ />
141
+ </div>
142
+ </div>
143
+ );
144
+ })
145
+ ) : (
146
+ <div
147
+ css={styles.slider}
148
+ style={{ height: '100%' }}
149
+ onClick={() => openMoleculeEditor()}
150
+ >
151
+ <span>Click to draw molecule</span>
168
152
  </div>
169
- ))
170
- ) : (
171
- <div
172
- css={styles.slider}
173
- style={{ height: '100%' }}
174
- onClick={() => openMoleculeEditor()}
175
- >
176
- <span>Click to draw molecule</span>
177
- </div>
178
- )}
179
- </NextPrev>
180
- );
181
- }}
182
- </ResponsiveChart>
153
+ )}
154
+ </NextPrev>
155
+ );
156
+ }}
157
+ </ResponsiveChart>
158
+ </div>
183
159
  </div>
184
- </div>
160
+ )}
185
161
  {modal}
186
162
  </div>
187
163
  );
@@ -1,5 +1,5 @@
1
1
  import { Molecule } from 'openchemlib';
2
- import type { CSSProperties, ReactNode } from 'react';
2
+ import type { ReactNode } from 'react';
3
3
  import { useCallback } from 'react';
4
4
  import {
5
5
  FaCopy,
@@ -8,43 +8,40 @@ import {
8
8
  FaFileImage,
9
9
  FaPaste,
10
10
  FaPlus,
11
+ FaRegBookmark,
11
12
  FaRegTrashAlt,
12
13
  } from 'react-icons/fa';
13
14
  import { FaMaximize, FaMinimize } from 'react-icons/fa6';
14
15
  import { IoOpenOutline } from 'react-icons/io5';
16
+ import { MdNumbers, MdOutlineLabelOff } from 'react-icons/md';
15
17
  import { PanelHeader, Toolbar } from 'react-science/ui';
16
18
 
17
19
  import type {
18
20
  MoleculesView,
19
21
  StateMoleculeExtended,
20
22
  } from '../../../data/molecules/Molecule.js';
21
- import { getMolecules } from '../../../data/molecules/MoleculeManager.js';
23
+ import {
24
+ getMolecules,
25
+ parseErrorMessage,
26
+ } from '../../../data/molecules/MoleculeManager.js';
22
27
  import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents.js';
23
28
  import { useClipboard } from '../../../utils/clipboard/clipboardHooks.js';
24
29
  import { useDispatch } from '../../context/DispatchContext.js';
25
30
  import { useGlobal } from '../../context/GlobalContext.js';
31
+ import { usePreferences } from '../../context/PreferencesContext.tsx';
26
32
  import { useToaster } from '../../context/ToasterContext.js';
27
33
  import { useTopicMolecule } from '../../context/TopicMoleculeContext.js';
28
34
  import type { ToolbarPopoverMenuItem } from '../../elements/ToolbarPopoverItem.js';
29
35
  import { ToolbarPopoverItem } from '../../elements/ToolbarPopoverItem.js';
30
36
  import AboutPredictionModal from '../../modal/AboutPredictionModal.js';
31
37
  import PredictSpectraModal from '../../modal/PredictSpectraModal.js';
38
+ import { booleanToString } from '../../utility/booleanToString.ts';
32
39
  import {
33
40
  browserNotSupportedErrorToast,
34
41
  copyPNGToClipboard,
35
42
  exportAsSVG,
36
43
  } from '../../utility/export.js';
37
-
38
- const styles: Record<'atomLabel', CSSProperties> = {
39
- atomLabel: {
40
- width: '14px',
41
- height: '14px',
42
- padding: 0,
43
- margin: 0,
44
- textAlign: 'center',
45
- lineHeight: 1,
46
- },
47
- };
44
+ import { useMoleculeAnnotationCore } from '../hooks/useMoleculeAnnotationCore.ts';
48
45
 
49
46
  const MOL_EXPORT_MENU: ToolbarPopoverMenuItem[] = [
50
47
  {
@@ -110,7 +107,9 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
110
107
  const { rootRef } = useGlobal();
111
108
  const toaster = useToaster();
112
109
  const dispatch = useDispatch();
113
-
110
+ const {
111
+ current: { defaultMoleculeSettings },
112
+ } = usePreferences();
114
113
  const moleculeKey = molecules?.[currentIndex]?.id;
115
114
  const saveAsSVGHandler = useCallback(() => {
116
115
  if (!rootRef) return;
@@ -204,16 +203,18 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
204
203
  * @param text - text from clipboard
205
204
  * @returns
206
205
  */
207
- async function handlePasteMolecule(text: string | undefined) {
208
- if (!text) return;
206
+
207
+ async function handlePasteMolecule(text?: string) {
209
208
  try {
210
209
  const molecules = getMolecules(text);
211
- dispatch({ type: 'ADD_MOLECULES', payload: { molecules } });
212
- } catch {
210
+ dispatch({
211
+ type: 'ADD_MOLECULES',
212
+ payload: { molecules, defaultMoleculeSettings },
213
+ });
214
+ } catch (error: any) {
213
215
  toaster.show({
214
216
  intent: 'danger',
215
- message:
216
- 'Failed to parse SMILES or molfile. Please paste a valid format',
217
+ message: error?.message || parseErrorMessage,
217
218
  });
218
219
  } finally {
219
220
  cleanShouldFallback();
@@ -237,13 +238,6 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
237
238
  });
238
239
  }
239
240
 
240
- function showAtomNumbersHandler() {
241
- dispatch({
242
- type: 'TOGGLE_MOLECULE_ATOM_NUMBER',
243
- payload: { id: moleculeKey },
244
- });
245
- }
246
-
247
241
  const topicMolecule = useTopicMolecule();
248
242
 
249
243
  function expandMoleculeHydrogens(expand?: boolean) {
@@ -258,30 +252,49 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
258
252
  dispatch({ type: 'SET_MOLECULE', payload: { id, label, molfile } });
259
253
  }
260
254
 
255
+ function clearCustomAtomLabels() {
256
+ const currentMolecule = molecules[currentIndex];
257
+
258
+ if (!currentMolecule) return;
259
+ const { id, label, molfile } = currentMolecule;
260
+
261
+ const molecule = Molecule.fromMolfile(molfile);
262
+
263
+ for (let atom = 0; atom < molecule.getAllAtoms(); atom++) {
264
+ molecule.setAtomCustomLabel(atom, null);
265
+ }
266
+
267
+ dispatch({
268
+ type: 'SET_MOLECULE',
269
+ payload: { id, label, molfile: molecule.toMolfileV3() },
270
+ });
271
+ }
272
+
261
273
  const hasMolecules = molecules && molecules.length > 0;
262
274
  const showCounter = hasMolecules && renderSource !== 'predictionPanel';
263
-
264
275
  const moreMenu: ToolbarPopoverMenuItem[] = [
265
276
  {
266
277
  icon: <FaMaximize />,
267
278
  text: 'Expand all hydrogens',
268
- data: {
269
- id: 'expandAllHydrogens',
270
- },
271
279
  disabled: !hasMolecules,
272
280
  onClick: () => expandMoleculeHydrogens(true),
273
281
  },
274
282
  {
275
283
  icon: <FaMinimize />,
276
284
  text: 'Collapse all hydrogens',
277
- data: {
278
- id: 'collapseAllHydrogens',
279
- },
280
285
  disabled: !hasMolecules,
281
286
  onClick: () => expandMoleculeHydrogens(false),
282
287
  },
288
+ {
289
+ icon: <MdOutlineLabelOff />,
290
+ text: 'Clear custom atom labels',
291
+ disabled: !hasMolecules,
292
+ onClick: () => clearCustomAtomLabels(),
293
+ },
283
294
  ];
284
295
 
296
+ const { handleChangeAtomAnnotation, isAnnotation } =
297
+ useMoleculeAnnotationCore(moleculeKey, moleculesView[moleculeKey]);
285
298
  return (
286
299
  <PanelHeader
287
300
  onClickSettings={onClickPreferences}
@@ -324,6 +337,21 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
324
337
  {hasMolecules && (
325
338
  <PredictSpectraModal molecule={molecules[currentIndex]} />
326
339
  )}
340
+
341
+ <Toolbar.Item
342
+ tooltip={`${booleanToString(!isAnnotation('atom-numbers'))} atom number`}
343
+ icon={<MdNumbers />}
344
+ onClick={() => handleChangeAtomAnnotation('atom-numbers')}
345
+ active={isAnnotation('atom-numbers')}
346
+ disabled={!hasMolecules}
347
+ />
348
+ <Toolbar.Item
349
+ tooltip={`${booleanToString(!isAnnotation('custom-labels'))} custom labels`}
350
+ icon={<FaRegBookmark />}
351
+ onClick={() => handleChangeAtomAnnotation('custom-labels')}
352
+ active={isAnnotation('custom-labels')}
353
+ disabled={!hasMolecules}
354
+ />
327
355
  </>
328
356
  )}
329
357
 
@@ -334,13 +362,6 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
334
362
  active={moleculesView?.[moleculeKey]?.floating.visible || false}
335
363
  disabled={!hasMolecules}
336
364
  />
337
- <Toolbar.Item
338
- tooltip="Show atom number"
339
- icon={<p style={styles.atomLabel}>#</p>}
340
- onClick={showAtomNumbersHandler}
341
- active={moleculesView?.[moleculeKey]?.showAtomNumber || false}
342
- disabled={!hasMolecules}
343
- />
344
365
 
345
366
  <ToolbarPopoverItem
346
367
  options={moreMenu}
@@ -359,7 +380,7 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
359
380
  onDismiss={cleanShouldFallback}
360
381
  onReadText={handlePasteMolecule}
361
382
  text={text}
362
- label="Molfile"
383
+ label="Enter here a molfile or SMILES"
363
384
  />
364
385
  </PanelHeader>
365
386
  );