nmrium 0.30.0 → 0.32.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 (273) hide show
  1. package/lib/component/1d/ApodizationLine.js +3 -1
  2. package/lib/component/1d/FooterBanner.js +20 -11
  3. package/lib/component/1d/IntegralsSeries.js +3 -1
  4. package/lib/component/1d/LinesSeries.js +3 -1
  5. package/lib/component/1d/SpectraTracker.js +1 -1
  6. package/lib/component/1d/Viewer1D.js +3 -1
  7. package/lib/component/1d/jCouplingGraph/JGraph.js +5 -1
  8. package/lib/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  9. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  10. package/lib/component/1d/peaks/PeakAnnotations.js +3 -1
  11. package/lib/component/1d/peaks/PeaksShapes.js +4 -2
  12. package/lib/component/1d/peaks/usePeakShapesPath.js +7 -3
  13. package/lib/component/1d/ranges/Ranges.js +8 -2
  14. package/lib/component/1d/tool/PeakPointer.js +3 -1
  15. package/lib/component/1d/tool/XLabelPointer.js +3 -1
  16. package/lib/component/2d/Contours.js +4 -2
  17. package/lib/component/2d/FooterBanner.js +3 -1
  18. package/lib/component/2d/Left1DChart.js +1 -1
  19. package/lib/component/2d/Top1DChart.js +1 -1
  20. package/lib/component/2d/Viewer2D.js +4 -4
  21. package/lib/component/2d/XAxis.js +2 -2
  22. package/lib/component/2d/YAxis.js +2 -2
  23. package/lib/component/2d/tools/XYLabelPointer.js +3 -1
  24. package/lib/component/2d/tools/slicing/SlicingView.js +3 -1
  25. package/lib/component/2d/zones/IndicationLines.js +1 -1
  26. package/lib/component/2d/zones/Zones.js +14 -19
  27. package/lib/component/EventsTrackers/BrushTracker.js +30 -21
  28. package/lib/component/NMRium.d.ts +2 -0
  29. package/lib/component/NMRium.js +14 -3
  30. package/lib/component/SplitPaneWrapper.js +1 -1
  31. package/lib/component/elements/EditableColumn.d.ts +3 -1
  32. package/lib/component/elements/EditableColumn.js +18 -3
  33. package/lib/component/elements/popup/Modal/Provider.d.ts +3 -3
  34. package/lib/component/elements/popup/Modal/Provider.js +8 -11
  35. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -1
  36. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +3 -3
  37. package/lib/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  38. package/lib/component/hooks/useExport.d.ts +0 -1
  39. package/lib/component/hooks/useExport.js +1 -17
  40. package/lib/component/hooks/useIntegralPath.js +5 -2
  41. package/lib/component/hooks/useNucleus.js +4 -4
  42. package/lib/component/hooks/useSpectraPerNucleus.js +1 -1
  43. package/lib/component/hooks/useSpectrum.js +3 -1
  44. package/lib/component/loader/DropZone.js +15 -147
  45. package/lib/component/modal/changeSum/SelectMolecule.js +1 -1
  46. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  47. package/lib/component/modal/setting/GeneralTabContent.js +1 -1
  48. package/lib/component/modal/setting/ToolsTabContent.js +4 -0
  49. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  50. package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  51. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  52. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  53. package/lib/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  54. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  55. package/lib/component/panels/RangesPanel/RangesHeader.d.ts +2 -1
  56. package/lib/component/panels/RangesPanel/RangesHeader.js +10 -9
  57. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -3
  58. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  59. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  60. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
  61. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  62. package/lib/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  63. package/lib/component/panels/ZonesPanel/ZonesPanel.js +19 -10
  64. package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
  65. package/lib/component/reducer/IgnoreActions.js +1 -0
  66. package/lib/component/reducer/Reducer.d.ts +110 -96
  67. package/lib/component/reducer/Reducer.js +45 -41
  68. package/lib/component/reducer/actions/DomainActions.d.ts +1 -1
  69. package/lib/component/reducer/actions/DomainActions.js +12 -9
  70. package/lib/component/reducer/actions/FiltersActions.d.ts +1 -1
  71. package/lib/component/reducer/actions/FiltersActions.js +227 -232
  72. package/lib/component/reducer/actions/IntegralsActions.js +14 -8
  73. package/lib/component/reducer/actions/LoadActions.d.ts +2 -5
  74. package/lib/component/reducer/actions/LoadActions.js +19 -34
  75. package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -1
  76. package/lib/component/reducer/actions/MoleculeActions.js +22 -6
  77. package/lib/component/reducer/actions/PeaksActions.js +19 -12
  78. package/lib/component/reducer/actions/PreferencesActions.js +9 -10
  79. package/lib/component/reducer/actions/RangesActions.d.ts +4 -4
  80. package/lib/component/reducer/actions/RangesActions.js +89 -29
  81. package/lib/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  82. package/lib/component/reducer/actions/SpectrumsActions.js +14 -10
  83. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
  84. package/lib/component/reducer/actions/ToolsActions.js +44 -27
  85. package/lib/component/reducer/actions/ZonesActions.d.ts +4 -1
  86. package/lib/component/reducer/actions/ZonesActions.js +69 -17
  87. package/lib/component/reducer/helper/Zoom1DManager.js +2 -1
  88. package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
  89. package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
  90. package/lib/component/reducer/helper/getActiveSpectrumOrFail.d.ts +3 -0
  91. package/lib/component/reducer/helper/getActiveSpectrumOrFail.js +6 -0
  92. package/lib/component/reducer/helper/getSpectrum.js +3 -2
  93. package/lib/component/reducer/helper/getStrongestPeak.js +2 -1
  94. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  95. package/lib/component/reducer/types/Types.d.ts +5 -0
  96. package/lib/component/reducer/types/Types.js +5 -0
  97. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.d.ts +6 -0
  98. package/lib/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  99. package/lib/component/tool/FloatMoleculeStructures/index.js +14 -8
  100. package/lib/component/toolbar/BasicToolBar.js +12 -13
  101. package/lib/component/toolbar/FunctionToolBar.js +3 -1
  102. package/lib/component/utility/Export.js +7 -1
  103. package/lib/component/utility/assert.d.ts +1 -0
  104. package/lib/component/utility/assert.js +5 -0
  105. package/lib/component/workspaces/Workspace.d.ts +1 -1
  106. package/lib/component/workspaces/exercise.js +9 -3
  107. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  108. package/lib/data/Filters.d.ts +1 -2
  109. package/lib/data/Filters.js +1 -2
  110. package/lib/data/SpectraManager.d.ts +0 -4
  111. package/lib/data/SpectraManager.js +2 -87
  112. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  113. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  114. package/lib/data/data1d/filter1d/fft.js +11 -0
  115. package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
  116. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.d.ts +2 -0
  117. package/lib/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +35 -0
  118. package/lib/data/data2d/Processing2D.js +3 -2
  119. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.d.ts +1 -1
  120. package/lib/data/molecules/Molecule.d.ts +5 -0
  121. package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
  122. package/lib/data/utilities/calculateSanPlot.js +31 -0
  123. package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
  124. package/lib/versionInfo.js +1 -1
  125. package/lib-cjs/component/1d/ApodizationLine.js +3 -1
  126. package/lib-cjs/component/1d/FooterBanner.js +19 -10
  127. package/lib-cjs/component/1d/IntegralsSeries.js +3 -1
  128. package/lib-cjs/component/1d/LinesSeries.js +3 -1
  129. package/lib-cjs/component/1d/SpectraTracker.js +1 -1
  130. package/lib-cjs/component/1d/Viewer1D.js +3 -1
  131. package/lib-cjs/component/1d/jCouplingGraph/JGraph.js +5 -1
  132. package/lib-cjs/component/1d/multiAnalysis/MultiAnalysisRanges.js +1 -1
  133. package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +3 -1
  134. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +3 -1
  135. package/lib-cjs/component/1d/peaks/PeaksShapes.js +4 -2
  136. package/lib-cjs/component/1d/peaks/usePeakShapesPath.js +7 -3
  137. package/lib-cjs/component/1d/ranges/Ranges.js +7 -1
  138. package/lib-cjs/component/1d/tool/PeakPointer.js +3 -1
  139. package/lib-cjs/component/1d/tool/XLabelPointer.js +3 -1
  140. package/lib-cjs/component/2d/Contours.js +4 -2
  141. package/lib-cjs/component/2d/FooterBanner.js +3 -1
  142. package/lib-cjs/component/2d/Left1DChart.js +1 -1
  143. package/lib-cjs/component/2d/Top1DChart.js +1 -1
  144. package/lib-cjs/component/2d/Viewer2D.js +4 -4
  145. package/lib-cjs/component/2d/XAxis.js +2 -2
  146. package/lib-cjs/component/2d/YAxis.js +2 -2
  147. package/lib-cjs/component/2d/tools/XYLabelPointer.js +3 -1
  148. package/lib-cjs/component/2d/tools/slicing/SlicingView.js +3 -1
  149. package/lib-cjs/component/2d/zones/IndicationLines.js +1 -1
  150. package/lib-cjs/component/2d/zones/Zones.js +13 -18
  151. package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
  152. package/lib-cjs/component/NMRium.js +14 -3
  153. package/lib-cjs/component/SplitPaneWrapper.js +1 -1
  154. package/lib-cjs/component/elements/EditableColumn.js +18 -3
  155. package/lib-cjs/component/elements/popup/Modal/Provider.js +8 -11
  156. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -1
  157. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +3 -3
  158. package/lib-cjs/component/hooks/useDatumWithSpectraStatistics.js +3 -1
  159. package/lib-cjs/component/hooks/useExport.js +0 -16
  160. package/lib-cjs/component/hooks/useIntegralPath.js +5 -2
  161. package/lib-cjs/component/hooks/useNucleus.js +4 -4
  162. package/lib-cjs/component/hooks/useSpectraPerNucleus.js +1 -1
  163. package/lib-cjs/component/hooks/useSpectrum.js +3 -1
  164. package/lib-cjs/component/loader/DropZone.js +14 -149
  165. package/lib-cjs/component/modal/changeSum/SelectMolecule.js +1 -1
  166. package/lib-cjs/component/modal/editRange/EditRangeModal.js +1 -1
  167. package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
  168. package/lib-cjs/component/modal/setting/ToolsTabContent.js +4 -0
  169. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +1 -1
  170. package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  171. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
  172. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  173. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +1 -1
  174. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  175. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +10 -9
  176. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -3
  177. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -1
  178. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -1
  179. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
  180. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  181. package/lib-cjs/component/panels/SummaryPanel/utilities/useInView.js +3 -1
  182. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +18 -9
  183. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
  184. package/lib-cjs/component/reducer/IgnoreActions.js +1 -0
  185. package/lib-cjs/component/reducer/Reducer.js +48 -43
  186. package/lib-cjs/component/reducer/actions/DomainActions.js +12 -9
  187. package/lib-cjs/component/reducer/actions/FiltersActions.js +228 -233
  188. package/lib-cjs/component/reducer/actions/IntegralsActions.js +14 -8
  189. package/lib-cjs/component/reducer/actions/LoadActions.js +18 -36
  190. package/lib-cjs/component/reducer/actions/MoleculeActions.js +23 -6
  191. package/lib-cjs/component/reducer/actions/PeaksActions.js +19 -12
  192. package/lib-cjs/component/reducer/actions/PreferencesActions.js +9 -10
  193. package/lib-cjs/component/reducer/actions/RangesActions.js +89 -29
  194. package/lib-cjs/component/reducer/actions/SpectraAnalysisAction.js +5 -5
  195. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +14 -10
  196. package/lib-cjs/component/reducer/actions/ToolsActions.js +44 -27
  197. package/lib-cjs/component/reducer/actions/ZonesActions.js +72 -17
  198. package/lib-cjs/component/reducer/helper/Zoom1DManager.js +2 -1
  199. package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
  200. package/lib-cjs/component/reducer/helper/getActiveSpectrumOrFail.js +10 -0
  201. package/lib-cjs/component/reducer/helper/getSpectrum.js +3 -2
  202. package/lib-cjs/component/reducer/helper/getStrongestPeak.js +2 -1
  203. package/lib-cjs/component/reducer/types/Types.js +8 -3
  204. package/lib-cjs/component/tool/FloatMoleculeStructures/DraggableStructure.js +10 -3
  205. package/lib-cjs/component/tool/FloatMoleculeStructures/index.js +14 -8
  206. package/lib-cjs/component/toolbar/BasicToolBar.js +11 -12
  207. package/lib-cjs/component/toolbar/FunctionToolBar.js +3 -1
  208. package/lib-cjs/component/utility/Export.js +7 -1
  209. package/lib-cjs/component/utility/assert.js +9 -0
  210. package/lib-cjs/component/workspaces/exercise.js +9 -3
  211. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
  212. package/lib-cjs/data/Filters.js +1 -3
  213. package/lib-cjs/data/SpectraManager.js +3 -92
  214. package/lib-cjs/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -0
  215. package/lib-cjs/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +1 -0
  216. package/lib-cjs/data/data1d/filter1d/fft.js +11 -0
  217. package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
  218. package/lib-cjs/data/data1d/filter1d/utils/padDataToNextPowerOfTwo.js +39 -0
  219. package/lib-cjs/data/data2d/Processing2D.js +3 -2
  220. package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
  221. package/lib-cjs/versionInfo.js +1 -1
  222. package/package.json +26 -25
  223. package/lib/component/utility/nmredataToNmrium.d.ts +0 -4
  224. package/lib/component/utility/nmredataToNmrium.js +0 -66
  225. package/lib/component/utility/nmriumToNmredata.d.ts +0 -2
  226. package/lib/component/utility/nmriumToNmredata.js +0 -80
  227. package/lib/component/utility/util/nmredata/addRanges.d.ts +0 -1
  228. package/lib/component/utility/util/nmredata/addRanges.js +0 -52
  229. package/lib/component/utility/util/nmredata/addSource.d.ts +0 -6
  230. package/lib/component/utility/util/nmredata/addSource.js +0 -54
  231. package/lib/component/utility/util/nmredata/addZones.d.ts +0 -1
  232. package/lib/component/utility/util/nmredata/addZones.js +0 -41
  233. package/lib/component/utility/util/nmredata/flat2DSignals.d.ts +0 -1
  234. package/lib/component/utility/util/nmredata/flat2DSignals.js +0 -7
  235. package/lib/component/utility/util/nmredata/get1DSignals.d.ts +0 -10
  236. package/lib/component/utility/util/nmredata/get1DSignals.js +0 -96
  237. package/lib/component/utility/util/nmredata/get2DSignals.d.ts +0 -8
  238. package/lib/component/utility/util/nmredata/get2DSignals.js +0 -59
  239. package/lib/component/utility/util/nmredata/getCouplingObserved.d.ts +0 -1
  240. package/lib/component/utility/util/nmredata/getCouplingObserved.js +0 -11
  241. package/lib/component/utility/util/nmredata/getLabels.d.ts +0 -9
  242. package/lib/component/utility/util/nmredata/getLabels.js +0 -66
  243. package/lib/component/utility/util/nmredata/getToFix.d.ts +0 -1
  244. package/lib/component/utility/util/nmredata/getToFix.js +0 -19
  245. package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
  246. package/lib/data/data1d/filter1d/absolute.js +0 -26
  247. package/lib/data/migration/MigrationManager.d.ts +0 -2
  248. package/lib/data/migration/MigrationManager.js +0 -19
  249. package/lib/data/migration/changeKeys.d.ts +0 -1
  250. package/lib/data/migration/changeKeys.js +0 -9
  251. package/lib/data/migration/migrateToVersion1.d.ts +0 -11
  252. package/lib/data/migration/migrateToVersion1.js +0 -32
  253. package/lib/data/migration/migrateToVersion2.d.ts +0 -1
  254. package/lib/data/migration/migrateToVersion2.js +0 -111
  255. package/lib/data/migration/migrateToVersion3.d.ts +0 -1
  256. package/lib/data/migration/migrateToVersion3.js +0 -55
  257. package/lib-cjs/component/utility/nmredataToNmrium.js +0 -73
  258. package/lib-cjs/component/utility/nmriumToNmredata.js +0 -87
  259. package/lib-cjs/component/utility/util/nmredata/addRanges.js +0 -56
  260. package/lib-cjs/component/utility/util/nmredata/addSource.js +0 -61
  261. package/lib-cjs/component/utility/util/nmredata/addZones.js +0 -45
  262. package/lib-cjs/component/utility/util/nmredata/flat2DSignals.js +0 -11
  263. package/lib-cjs/component/utility/util/nmredata/get1DSignals.js +0 -100
  264. package/lib-cjs/component/utility/util/nmredata/get2DSignals.js +0 -63
  265. package/lib-cjs/component/utility/util/nmredata/getCouplingObserved.js +0 -15
  266. package/lib-cjs/component/utility/util/nmredata/getLabels.js +0 -70
  267. package/lib-cjs/component/utility/util/nmredata/getToFix.js +0 -23
  268. package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
  269. package/lib-cjs/data/migration/MigrationManager.js +0 -26
  270. package/lib-cjs/data/migration/changeKeys.js +0 -13
  271. package/lib-cjs/data/migration/migrateToVersion1.js +0 -35
  272. package/lib-cjs/data/migration/migrateToVersion2.js +0 -114
  273. package/lib-cjs/data/migration/migrateToVersion3.js +0 -58
@@ -1,12 +1,12 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import { produce } from 'immer';
3
3
  import { buildCorrelationData } from 'nmr-correlation';
4
+ import { read as readDropFiles, migrate } from 'nmr-load-save';
4
5
  import { predictSpectra } from '../../data/PredictionManager';
5
6
  import * as SpectraManager from '../../data/SpectraManager';
6
- import { migrate } from '../../data/migration/MigrationManager';
7
+ import { useChartData } from '../context/ChartContext';
7
8
  import { DefaultTolerance } from '../panels/SummaryPanel/CorrelationTable/Constants';
8
9
  import { options } from '../toolbar/ToolTypes';
9
- import { nmredataToNmrium } from '../utility/nmredataToNmrium';
10
10
  import * as AssignmentsActions from './actions/AssignmentsActions';
11
11
  import * as CorrelationsActions from './actions/CorrelationsActions';
12
12
  import * as DatabaseActions from './actions/DatabaseActions';
@@ -28,6 +28,16 @@ import * as ZonesActions from './actions/ZonesActions';
28
28
  import { DEFAULT_YAXIS_SHIFT_VALUE, DISPLAYER_MODE } from './core/Constants';
29
29
  import { UNDO, REDO, RESET } from './types/HistoryTypes';
30
30
  import * as types from './types/Types';
31
+ export const rangeStateInit = {
32
+ showMultiplicityTrees: false,
33
+ showRangesIntegrals: true,
34
+ showJGraph: false,
35
+ };
36
+ export const zoneStateInit = {
37
+ showZones: true,
38
+ showSignals: true,
39
+ showPeaks: true,
40
+ };
31
41
  export const getInitialState = () => ({
32
42
  actionType: '',
33
43
  data: [],
@@ -45,7 +55,6 @@ export const getInitialState = () => ({
45
55
  shareYDomain: false,
46
56
  },
47
57
  integralsYDomains: {},
48
- activeTab: '',
49
58
  width: 0,
50
59
  height: 0,
51
60
  margin: {
@@ -54,10 +63,14 @@ export const getInitialState = () => ({
54
63
  bottom: 70,
55
64
  left: 0,
56
65
  },
57
- activeSpectrum: null,
58
66
  mode: 'RTL',
59
67
  molecules: [],
60
- view: { floatingMolecules: [] },
68
+ view: {
69
+ floatingMolecules: [],
70
+ ranges: [],
71
+ zones: [],
72
+ spectra: { activeSpectra: {}, activeTab: '' },
73
+ },
61
74
  verticalAlign: {
62
75
  align: 'bottom',
63
76
  verticalShift: DEFAULT_YAXIS_SHIFT_VALUE,
@@ -72,7 +85,6 @@ export const getInitialState = () => ({
72
85
  isLoading: false,
73
86
  keysPreferences: {},
74
87
  displayerMode: DISPLAYER_MODE.DM_1D,
75
- tabActiveSpectrum: {},
76
88
  spectraAnalysis: {},
77
89
  correlations: {},
78
90
  displayerKey: '',
@@ -92,9 +104,6 @@ export const getInitialState = () => ({
92
104
  pivot: { value: 0, index: 0 },
93
105
  zonesNoiseFactor: 1,
94
106
  activeFilterID: null,
95
- showMultiplicityTrees: false,
96
- showRangesIntegrals: true,
97
- showJGraph: false,
98
107
  predictionIndex: 0,
99
108
  peaksOptions: {
100
109
  showPeaksShapes: false,
@@ -105,6 +114,10 @@ export const getInitialState = () => ({
105
114
  usedColors: { '1d': [], '2d': [] },
106
115
  });
107
116
  export const initialState = getInitialState();
117
+ export function useActiveSpectrum() {
118
+ const { view: { spectra: { activeSpectra, activeTab }, }, } = useChartData();
119
+ return activeSpectra[activeTab] || null;
120
+ }
108
121
  export function initState(state) {
109
122
  const displayerKey = v4();
110
123
  const correlations = buildCorrelationData([], {
@@ -131,28 +144,17 @@ export function dispatchMiddleware(dispatch) {
131
144
  }
132
145
  break;
133
146
  }
134
- case types.LOAD_JSON_FILE: {
135
- const parsedData = JSON.parse(action.files[0].binary.toString());
136
- const data = migrate(parsedData);
137
- void SpectraManager.fromJSON(data.spectra, usedColors).then((spectra) => {
138
- action.payload = Object.assign(data, { spectra, usedColors });
139
- dispatch(action);
140
- });
141
- break;
142
- }
143
- case types.LOAD_ZIP_FILE: {
144
- for (let zipFile of action.files) {
145
- void SpectraManager.addBruker({ display: { name: zipFile.name } }, zipFile.binary, usedColors).then((data) => {
146
- action.payload = { data, usedColors };
147
- dispatch(action);
148
- });
149
- }
150
- break;
151
- }
152
- case types.LOAD_NMREDATA_FILE: {
153
- void nmredataToNmrium(action.file, usedColors).then((data) => {
154
- action.payload = Object.assign(data, { usedColors });
147
+ case types.LOAD_DROP_FILES: {
148
+ const { fileCollection } = action;
149
+ action.usedColors = usedColors;
150
+ readDropFiles(fileCollection, usedColors)
151
+ .then((data) => {
152
+ action.data = data;
155
153
  dispatch(action);
154
+ })
155
+ .catch((e) => {
156
+ dispatch({ type: types.SET_LOADING_FLAG, isLoading: false });
157
+ reportError(e);
156
158
  });
157
159
  break;
158
160
  }
@@ -180,20 +182,14 @@ function innerSpectrumReducer(draft, action) {
180
182
  switch (action.type) {
181
183
  case types.INITIATE:
182
184
  return LoadActions.initiate(draft, action);
185
+ case types.LOAD_DROP_FILES:
186
+ return LoadActions.loadDropFiles(draft, action);
183
187
  case types.SET_LOADING_FLAG:
184
188
  return LoadActions.setIsLoading(draft, action.isLoading);
185
189
  case types.LOAD_JSON_FILE:
186
190
  return LoadActions.handleLoadJsonFile(draft, action);
187
191
  case types.LOAD_JCAMP_FILE:
188
192
  return LoadActions.loadJcampFile(draft, action);
189
- case types.LOAD_JDF_FILE:
190
- return LoadActions.loadJDFFile(draft, action);
191
- case types.LOAD_MOL_FILE:
192
- return LoadActions.handleLoadMOLFile(draft, action);
193
- case types.LOAD_ZIP_FILE:
194
- return LoadActions.handleLoadZIPFile(draft, action);
195
- case types.LOAD_NMREDATA_FILE:
196
- return LoadActions.handleLoadNmredata(draft, action);
197
193
  case types.ADD_PEAK:
198
194
  return PeaksActions.addPeak(draft, action.mouseCoordinates);
199
195
  case types.ADD_PEAKS:
@@ -320,6 +316,8 @@ function innerSpectrumReducer(draft, action) {
320
316
  return MoleculeActions.predictSpectraFromMoleculeHandler(draft, action);
321
317
  case types.FLOAT_MOLECULE_OVER_SPECTRUM:
322
318
  return MoleculeActions.floatMoleculeOverSpectrum(draft, action);
319
+ case types.CHANGE_FLOAT_MOLECULE_POSITION:
320
+ return MoleculeActions.changeFloatMoleculePosition(draft, action);
323
321
  case types.SET_CORRELATIONS_MF:
324
322
  return CorrelationsActions.handleSetMF(draft, action.payload);
325
323
  case types.SET_CORRELATIONS_TOLERANCE:
@@ -369,13 +367,13 @@ function innerSpectrumReducer(draft, action) {
369
367
  case types.UPDATE_RANGE:
370
368
  return RangesActions.handleUpdateRange(draft, action);
371
369
  case types.SHOW_MULTIPLICTY_TREES:
372
- return RangesActions.handleShowMultiplicityTrees(draft);
370
+ return RangesActions.handleShowMultiplicityTrees(draft, action);
373
371
  case types.SHOW_RANGES_INTEGRALS:
374
- return RangesActions.handleShowRangesIntegrals(draft);
372
+ return RangesActions.handleShowRangesIntegrals(draft, action);
375
373
  case types.AUTO_RANGES_SPECTRA_PICKING:
376
374
  return RangesActions.handleAutoSpectraRangesDetection(draft);
377
375
  case types.SHOW_J_GRAPH:
378
- return RangesActions.handleShowJGraph(draft);
376
+ return RangesActions.handleShowJGraph(draft, action);
379
377
  case types.SET_ACTIVE_TAB:
380
378
  return ToolsActions.handelSetActiveTab(draft, action.tab);
381
379
  case types.ADD_BASE_LINE_ZONE:
@@ -408,6 +406,12 @@ function innerSpectrumReducer(draft, action) {
408
406
  return ZonesActions.handleSetDiaIDZone(draft, action);
409
407
  case types.AUTO_ZONES_SPECTRA_PICKING:
410
408
  return ZonesActions.handleAutoSpectraZonesDetection(draft);
409
+ case types.SHOW_ZONES:
410
+ return ZonesActions.handleShowZones(draft, action);
411
+ case types.SHOW_ZONES_SIGNALS:
412
+ return ZonesActions.handleShowSignals(draft, action);
413
+ case types.SHOW_ZONES_PEAKS:
414
+ return ZonesActions.handleShowPeaks(draft, action);
411
415
  case types.SAVE_EDITED_ZONE:
412
416
  return ZonesActions.handleSaveEditedZone(draft, action);
413
417
  case types.ANALYZE_SPECTRA:
@@ -1,7 +1,7 @@
1
1
  import { Draft } from 'immer';
2
2
  import { Datum1D } from '../../../data/types/data1d';
3
3
  import { State } from '../Reducer';
4
- declare function getDomain(drfat: Draft<State>): {
4
+ declare function getDomain(draft: Draft<State>): {
5
5
  xDomain: [number, number] | [undefined, undefined];
6
6
  yDomain: [number, number] | [undefined, undefined];
7
7
  yDomains: {};
@@ -3,11 +3,14 @@ import { get1DDataXY } from '../../../data/data1d/Spectrum1D/get1DDataXY';
3
3
  import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
4
4
  import nucleusToString from '../../utility/nucleusToString';
5
5
  import { DISPLAYER_MODE } from '../core/Constants';
6
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
6
7
  function getActiveData(draft) {
7
- let data = draft.data.filter((datum) => nucleusToString(datum.info.nucleus) === draft.activeTab &&
8
+ let data = draft.data.filter((datum) => nucleusToString(datum.info.nucleus) === draft.view.spectra.activeTab &&
8
9
  datum.info.dimension === 1);
9
- if (draft.activeSpectrum) {
10
- const activeSpectrumIndex = data.findIndex((datum) => datum.id === draft.activeSpectrum?.id);
10
+ // todo: refactor this
11
+ const activeSpectrum = getActiveSpectrum(draft);
12
+ if (activeSpectrum?.id) {
13
+ const activeSpectrumIndex = data.findIndex((datum) => datum.id === activeSpectrum?.id);
11
14
  if (activeSpectrumIndex !== -1) {
12
15
  const isFid = data[activeSpectrumIndex].info.isFid || false;
13
16
  data = data.filter((datum) => datum.info.isFid === isFid);
@@ -18,12 +21,12 @@ function getActiveData(draft) {
18
21
  }
19
22
  return data;
20
23
  }
21
- function getDomain(drfat) {
24
+ function getDomain(draft) {
22
25
  let xArray = [];
23
26
  let yArray = [];
24
27
  let yDomains = {};
25
28
  let xDomains = {};
26
- const data = getActiveData(drfat);
29
+ const data = getActiveData(draft);
27
30
  try {
28
31
  xArray = data.reduce((acc, d) => {
29
32
  const { display, data } = d;
@@ -61,7 +64,7 @@ function get2DDomain(state) {
61
64
  let yArray = [];
62
65
  let yDomains = {};
63
66
  let xDomains = {};
64
- const { activeTab, tabActiveSpectrum, data } = state;
67
+ const { view: { spectra: { activeSpectra, activeTab }, }, data, } = state;
65
68
  const nucleus = activeTab.split(',');
66
69
  try {
67
70
  xArray = data.reduce((acc, datum) => {
@@ -85,7 +88,7 @@ function get2DDomain(state) {
85
88
  // eslint-disable-next-line no-console
86
89
  console.log(e);
87
90
  }
88
- const spectrumsIDs = nucleus.map((n) => tabActiveSpectrum[n]?.id);
91
+ const spectrumsIDs = nucleus.map((n) => activeSpectra[n]?.id);
89
92
  const filteredData = data.reduce((acc, datum) => {
90
93
  return spectrumsIDs.includes(datum.id) && datum.info.dimension === 1
91
94
  ? acc.concat(datum)
@@ -118,7 +121,7 @@ function get2DDomain(state) {
118
121
  function setDomain(draft, options) {
119
122
  const { yDomain = { isChanged: true, isShared: true } } = options || {};
120
123
  let domain;
121
- if (draft.activeTab) {
124
+ if (draft.view.spectra.activeTab) {
122
125
  if (draft.displayerMode === DISPLAYER_MODE.DM_1D) {
123
126
  domain = getDomain(draft);
124
127
  }
@@ -186,7 +189,7 @@ function handelResetDomain(draft) {
186
189
  }
187
190
  function setMode(draft) {
188
191
  const data = draft.data.filter((datum) => draft.xDomains[datum.id] &&
189
- nucleusToString(datum.info.nucleus) === draft.activeTab);
192
+ nucleusToString(datum.info.nucleus) === draft.view.spectra.activeTab);
190
193
  draft.mode = data[0]?.info.isFid ? 'LTR' : 'RTL';
191
194
  }
192
195
  export { getDomain, setOriginalDomain, setXDomain, setYDomain, handelResetDomain, setDomain, setMode, setIntegralsYDomain, };
@@ -24,7 +24,7 @@ declare function handleBaseLineCorrectionFilter(draft: Draft<State>, action: any
24
24
  * @param {boolean=} options.updateDomain
25
25
  * @param {boolean=} options.rollback
26
26
  */
27
- declare function resetSpectrumByFilter(draft: any, options?: {
27
+ declare function resetSpectrumByFilter(draft: Draft<State>, options?: {
28
28
  rollback?: boolean;
29
29
  resetTool?: boolean;
30
30
  updateDomain?: boolean;