nmrium 2.4.0 → 2.5.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 (277) hide show
  1. package/lib/component/1d/HorizontalAxis1D.d.ts.map +1 -1
  2. package/lib/component/1d/HorizontalAxis1D.js +4 -1
  3. package/lib/component/1d/HorizontalAxis1D.js.map +1 -1
  4. package/lib/component/1d/SVGContent1D.d.ts.map +1 -1
  5. package/lib/component/1d/SVGContent1D.js +2 -1
  6. package/lib/component/1d/SVGContent1D.js.map +1 -1
  7. package/lib/component/1d/Viewer1D.d.ts.map +1 -1
  8. package/lib/component/1d/Viewer1D.js +2 -1
  9. package/lib/component/1d/Viewer1D.js.map +1 -1
  10. package/lib/component/1d/integral/IntegralResizable.d.ts.map +1 -1
  11. package/lib/component/1d/integral/IntegralResizable.js +4 -4
  12. package/lib/component/1d/integral/IntegralResizable.js.map +1 -1
  13. package/lib/component/1d/ranges/Range.d.ts.map +1 -1
  14. package/lib/component/1d/ranges/Range.js +3 -3
  15. package/lib/component/1d/ranges/Range.js.map +1 -1
  16. package/lib/component/1d/ranges/Signals.d.ts +2 -0
  17. package/lib/component/1d/ranges/Signals.d.ts.map +1 -0
  18. package/lib/component/1d/ranges/Signals.js +16 -0
  19. package/lib/component/1d/ranges/Signals.js.map +1 -0
  20. package/lib/component/1d-2d/components/RangeIndicator.d.ts +13 -0
  21. package/lib/component/1d-2d/components/RangeIndicator.d.ts.map +1 -0
  22. package/lib/component/1d-2d/components/RangeIndicator.js +52 -0
  23. package/lib/component/1d-2d/components/RangeIndicator.js.map +1 -0
  24. package/lib/component/1d-2d/components/Signals1D.d.ts +19 -0
  25. package/lib/component/1d-2d/components/Signals1D.d.ts.map +1 -0
  26. package/lib/component/1d-2d/components/Signals1D.js +155 -0
  27. package/lib/component/1d-2d/components/Signals1D.js.map +1 -0
  28. package/lib/component/1d-2d/tools/CrossLinePointer.d.ts +16 -1
  29. package/lib/component/1d-2d/tools/CrossLinePointer.d.ts.map +1 -1
  30. package/lib/component/1d-2d/tools/CrossLinePointer.js +25 -15
  31. package/lib/component/1d-2d/tools/CrossLinePointer.js.map +1 -1
  32. package/lib/component/1d-2d/tools/CursorToolIcon.d.ts +9 -0
  33. package/lib/component/1d-2d/tools/CursorToolIcon.d.ts.map +1 -0
  34. package/lib/component/1d-2d/tools/CursorToolIcon.js +58 -0
  35. package/lib/component/1d-2d/tools/CursorToolIcon.js.map +1 -0
  36. package/lib/component/2d/1d-tracer/Left1DChart.d.ts.map +1 -1
  37. package/lib/component/2d/1d-tracer/Left1DChart.js +3 -2
  38. package/lib/component/2d/1d-tracer/Left1DChart.js.map +1 -1
  39. package/lib/component/2d/1d-tracer/Ranges1D.d.ts.map +1 -1
  40. package/lib/component/2d/1d-tracer/Ranges1D.js +4 -60
  41. package/lib/component/2d/1d-tracer/Ranges1D.js.map +1 -1
  42. package/lib/component/2d/1d-tracer/Top1DChart.d.ts.map +1 -1
  43. package/lib/component/2d/1d-tracer/Top1DChart.js +3 -2
  44. package/lib/component/2d/1d-tracer/Top1DChart.js.map +1 -1
  45. package/lib/component/2d/DirectAxis2D.d.ts.map +1 -1
  46. package/lib/component/2d/DirectAxis2D.js +4 -1
  47. package/lib/component/2d/DirectAxis2D.js.map +1 -1
  48. package/lib/component/2d/IndirectAxis2D.d.ts.map +1 -1
  49. package/lib/component/2d/IndirectAxis2D.js +5 -2
  50. package/lib/component/2d/IndirectAxis2D.js.map +1 -1
  51. package/lib/component/2d/Viewer2D.d.ts.map +1 -1
  52. package/lib/component/2d/Viewer2D.js +2 -1
  53. package/lib/component/2d/Viewer2D.js.map +1 -1
  54. package/lib/component/AnchorSVG.d.ts +5 -6
  55. package/lib/component/AnchorSVG.d.ts.map +1 -1
  56. package/lib/component/AnchorSVG.js +9 -6
  57. package/lib/component/AnchorSVG.js.map +1 -1
  58. package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
  59. package/lib/component/EventsTrackers/BrushTracker.js +14 -4
  60. package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
  61. package/lib/component/EventsTrackers/MouseTracker.d.ts +3 -0
  62. package/lib/component/EventsTrackers/MouseTracker.d.ts.map +1 -1
  63. package/lib/component/EventsTrackers/MouseTracker.js +15 -0
  64. package/lib/component/EventsTrackers/MouseTracker.js.map +1 -1
  65. package/lib/component/context/KeyModifierContext.d.ts +1 -0
  66. package/lib/component/context/KeyModifierContext.d.ts.map +1 -1
  67. package/lib/component/context/KeyModifierContext.js +22 -6
  68. package/lib/component/context/KeyModifierContext.js.map +1 -1
  69. package/lib/component/elements/D3Axis.d.ts.map +1 -1
  70. package/lib/component/elements/D3Axis.js +4 -3
  71. package/lib/component/elements/D3Axis.js.map +1 -1
  72. package/lib/component/header/AutoPeakPickingOptionPanel.d.ts.map +1 -1
  73. package/lib/component/header/AutoPeakPickingOptionPanel.js +59 -31
  74. package/lib/component/header/AutoPeakPickingOptionPanel.js.map +1 -1
  75. package/lib/component/header/RangesPickingOptionPanel.d.ts.map +1 -1
  76. package/lib/component/header/RangesPickingOptionPanel.js +34 -19
  77. package/lib/component/header/RangesPickingOptionPanel.js.map +1 -1
  78. package/lib/component/hooks/useAddMultipletSignal.d.ts +7 -0
  79. package/lib/component/hooks/useAddMultipletSignal.d.ts.map +1 -0
  80. package/lib/component/hooks/useAddMultipletSignal.js +28 -0
  81. package/lib/component/hooks/useAddMultipletSignal.js.map +1 -0
  82. package/lib/component/hooks/useFilter.d.ts.map +1 -1
  83. package/lib/component/hooks/useFilter.js.map +1 -1
  84. package/lib/component/hooks/useSpectrum.d.ts +3 -1
  85. package/lib/component/hooks/useSpectrum.d.ts.map +1 -1
  86. package/lib/component/hooks/useSpectrum.js +1 -1
  87. package/lib/component/hooks/useSpectrum.js.map +1 -1
  88. package/lib/component/hooks/useSpectrumWithDataSource.d.ts +1 -1
  89. package/lib/component/hooks/useSpectrumWithDataSource.d.ts.map +1 -1
  90. package/lib/component/hooks/useSpectrumWithDataSource.js.map +1 -1
  91. package/lib/component/hooks/useTempSpectrum.d.ts +1 -1
  92. package/lib/component/hooks/useTempSpectrum.d.ts.map +1 -1
  93. package/lib/component/hooks/use_ticks_config.d.ts +1 -4
  94. package/lib/component/hooks/use_ticks_config.d.ts.map +1 -1
  95. package/lib/component/hooks/use_ticks_config.js +1 -6
  96. package/lib/component/hooks/use_ticks_config.js.map +1 -1
  97. package/lib/component/modal/PublicationStringModal.d.ts +1 -1
  98. package/lib/component/modal/PublicationStringModal.d.ts.map +1 -1
  99. package/lib/component/modal/PublicationStringModal.js +2 -2
  100. package/lib/component/modal/PublicationStringModal.js.map +1 -1
  101. package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts +118 -0
  102. package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts.map +1 -1
  103. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts +118 -0
  104. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts.map +1 -1
  105. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts +118 -0
  106. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts.map +1 -1
  107. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts +96 -0
  108. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts.map +1 -1
  109. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts +96 -0
  110. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts.map +1 -1
  111. package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts +16 -0
  112. package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts.map +1 -1
  113. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts +96 -0
  114. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts.map +1 -1
  115. package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts +96 -0
  116. package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts.map +1 -1
  117. package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.js +12 -1
  118. package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.js.map +1 -1
  119. package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts +96 -0
  120. package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts.map +1 -1
  121. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts +96 -0
  122. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts.map +1 -1
  123. package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts +96 -0
  124. package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts.map +1 -1
  125. package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts +96 -0
  126. package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts.map +1 -1
  127. package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts +96 -0
  128. package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts.map +1 -1
  129. package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts +96 -0
  130. package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts.map +1 -1
  131. package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts +96 -0
  132. package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts.map +1 -1
  133. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts +96 -0
  134. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts.map +1 -1
  135. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts +96 -0
  136. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts.map +1 -1
  137. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts +96 -0
  138. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts.map +1 -1
  139. package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts +96 -0
  140. package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts.map +1 -1
  141. package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.d.ts +22 -0
  142. package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.d.ts.map +1 -1
  143. package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.js +15 -2
  144. package/lib/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.js.map +1 -1
  145. package/lib/component/modal/setting/tanstack_general_settings/validation.d.ts +22 -0
  146. package/lib/component/modal/setting/tanstack_general_settings/validation.d.ts.map +1 -1
  147. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js +1 -1
  148. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -1
  149. package/lib/component/panels/RangesPanel/RangesPanel.d.ts.map +1 -1
  150. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -3
  151. package/lib/component/panels/RangesPanel/RangesPanel.js.map +1 -1
  152. package/lib/component/panels/RangesPanel/RangesTableRow.d.ts.map +1 -1
  153. package/lib/component/panels/RangesPanel/RangesTableRow.js +10 -12
  154. package/lib/component/panels/RangesPanel/RangesTableRow.js.map +1 -1
  155. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +1 -1
  156. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts.map +1 -1
  157. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.js +1 -1
  158. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.js.map +1 -1
  159. package/lib/component/panels/filtersPanel/processings_sections_panel.d.ts.map +1 -1
  160. package/lib/component/panels/filtersPanel/processings_sections_panel.js +13 -23
  161. package/lib/component/panels/filtersPanel/processings_sections_panel.js.map +1 -1
  162. package/lib/component/panels/hooks/use_processings_mutation.d.ts +10 -0
  163. package/lib/component/panels/hooks/use_processings_mutation.d.ts.map +1 -0
  164. package/lib/component/panels/hooks/use_processings_mutation.js +130 -0
  165. package/lib/component/panels/hooks/use_processings_mutation.js.map +1 -0
  166. package/lib/component/panels/informationPanel/InformationPanel.js +1 -1
  167. package/lib/component/panels/informationPanel/InformationPanel.js.map +1 -1
  168. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  169. package/lib/component/reducer/Reducer.js +2 -0
  170. package/lib/component/reducer/Reducer.js.map +1 -1
  171. package/lib/component/reducer/actions/CorrelationsActions.js +1 -1
  172. package/lib/component/reducer/actions/CorrelationsActions.js.map +1 -1
  173. package/lib/component/reducer/actions/FiltersActions.d.ts +2 -0
  174. package/lib/component/reducer/actions/FiltersActions.d.ts.map +1 -1
  175. package/lib/component/reducer/actions/FiltersActions.js +1 -1
  176. package/lib/component/reducer/actions/FiltersActions.js.map +1 -1
  177. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  178. package/lib/component/reducer/actions/RangesActions.js +13 -24
  179. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  180. package/lib/component/reducer/actions/SpectraActions.d.ts +8 -2
  181. package/lib/component/reducer/actions/SpectraActions.d.ts.map +1 -1
  182. package/lib/component/reducer/actions/SpectraActions.js +6 -1
  183. package/lib/component/reducer/actions/SpectraActions.js.map +1 -1
  184. package/lib/component/reducer/preferences/actions/setPreferences.d.ts +2 -2
  185. package/lib/component/reducer/preferences/actions/setPreferences.d.ts.map +1 -1
  186. package/lib/component/reducer/preferences/actions/setPreferences.js +8 -5
  187. package/lib/component/reducer/preferences/actions/setPreferences.js.map +1 -1
  188. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  189. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  190. package/lib/component/toolbar/ToolTypes.d.ts +21 -1
  191. package/lib/component/toolbar/ToolTypes.d.ts.map +1 -1
  192. package/lib/component/toolbar/ToolTypes.js +40 -0
  193. package/lib/component/toolbar/ToolTypes.js.map +1 -1
  194. package/lib/component/toolbar/nmr_toolbar.d.ts.map +1 -1
  195. package/lib/component/toolbar/nmr_toolbar.js +9 -35
  196. package/lib/component/toolbar/nmr_toolbar.js.map +1 -1
  197. package/lib/component/workspaces/workspaceDefaultProperties.d.ts.map +1 -1
  198. package/lib/component/workspaces/workspaceDefaultProperties.js +19 -2
  199. package/lib/component/workspaces/workspaceDefaultProperties.js.map +1 -1
  200. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
  201. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +13 -5
  202. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
  203. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  204. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +12 -4
  205. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  206. package/lib/data/data2d/Spectrum2D/isSpectrum2D.d.ts +1 -1
  207. package/lib/data/data2d/Spectrum2D/isSpectrum2D.d.ts.map +1 -1
  208. package/lib/data/data2d/Spectrum2D/isSpectrum2D.js.map +1 -1
  209. package/lib/data/utilities/RangeUtilities.d.ts +1 -6
  210. package/lib/data/utilities/RangeUtilities.d.ts.map +1 -1
  211. package/lib/data/utilities/RangeUtilities.js +10 -27
  212. package/lib/data/utilities/RangeUtilities.js.map +1 -1
  213. package/lib/versionInfo.js +1 -1
  214. package/package.json +15 -14
  215. package/src/component/1d/HorizontalAxis1D.tsx +12 -2
  216. package/src/component/1d/SVGContent1D.tsx +2 -0
  217. package/src/component/1d/Viewer1D.tsx +2 -0
  218. package/src/component/1d/integral/IntegralResizable.tsx +6 -6
  219. package/src/component/1d/ranges/Range.tsx +6 -6
  220. package/src/component/1d/ranges/Signals.tsx +28 -0
  221. package/src/component/1d-2d/components/RangeIndicator.tsx +106 -0
  222. package/src/component/1d-2d/components/Signals1D.tsx +306 -0
  223. package/src/component/1d-2d/tools/CrossLinePointer.tsx +75 -32
  224. package/src/component/1d-2d/tools/CursorToolIcon.tsx +110 -0
  225. package/src/component/2d/1d-tracer/Left1DChart.tsx +4 -2
  226. package/src/component/2d/1d-tracer/Ranges1D.tsx +4 -100
  227. package/src/component/2d/1d-tracer/Top1DChart.tsx +4 -2
  228. package/src/component/2d/DirectAxis2D.tsx +12 -3
  229. package/src/component/2d/IndirectAxis2D.tsx +9 -5
  230. package/src/component/2d/Viewer2D.tsx +5 -2
  231. package/src/component/AnchorSVG.tsx +27 -28
  232. package/src/component/EventsTrackers/BrushTracker.tsx +21 -7
  233. package/src/component/EventsTrackers/MouseTracker.tsx +21 -0
  234. package/src/component/context/KeyModifierContext.tsx +27 -8
  235. package/src/component/elements/D3Axis.tsx +31 -9
  236. package/src/component/header/AutoPeakPickingOptionPanel.tsx +173 -102
  237. package/src/component/header/RangesPickingOptionPanel.tsx +72 -59
  238. package/src/component/hooks/useAddMultipletSignal.tsx +32 -0
  239. package/src/component/hooks/useFilter.ts +2 -1
  240. package/src/component/hooks/useSpectrum.ts +7 -1
  241. package/src/component/hooks/useSpectrumWithDataSource.ts +16 -8
  242. package/src/component/hooks/use_ticks_config.ts +1 -7
  243. package/src/component/modal/PublicationStringModal.tsx +3 -3
  244. package/src/component/modal/setting/tanstack_general_settings/tabs/axis_tab.tsx +76 -12
  245. package/src/component/modal/setting/tanstack_general_settings/validation/axis_tab_validation.ts +16 -2
  246. package/src/component/panels/MoleculesPanel/hooks/useAtomAssignment.tsx +1 -1
  247. package/src/component/panels/RangesPanel/RangesPanel.tsx +1 -3
  248. package/src/component/panels/RangesPanel/RangesTableRow.tsx +10 -12
  249. package/src/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.tsx +2 -2
  250. package/src/component/panels/filtersPanel/processings_sections_panel.tsx +27 -44
  251. package/src/component/panels/hooks/use_processings_mutation.ts +171 -0
  252. package/src/component/panels/informationPanel/InformationPanel.tsx +1 -1
  253. package/src/component/reducer/Reducer.ts +2 -0
  254. package/src/component/reducer/actions/CorrelationsActions.ts +1 -1
  255. package/src/component/reducer/actions/FiltersActions.ts +1 -1
  256. package/src/component/reducer/actions/RangesActions.ts +14 -25
  257. package/src/component/reducer/actions/SpectraActions.ts +20 -1
  258. package/src/component/reducer/preferences/actions/setPreferences.ts +18 -10
  259. package/src/component/reducer/preferences/preferencesReducer.ts +1 -1
  260. package/src/component/toolbar/ToolTypes.ts +92 -1
  261. package/src/component/toolbar/nmr_toolbar.tsx +12 -69
  262. package/src/component/workspaces/workspaceDefaultProperties.ts +19 -2
  263. package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +14 -8
  264. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +12 -4
  265. package/src/data/data2d/Spectrum2D/isSpectrum2D.ts +1 -1
  266. package/src/data/utilities/RangeUtilities.ts +12 -36
  267. package/src/versionInfo.ts +1 -1
  268. package/lib/component/1d/integral/IntegralIndicator.d.ts +0 -9
  269. package/lib/component/1d/integral/IntegralIndicator.d.ts.map +0 -1
  270. package/lib/component/1d/integral/IntegralIndicator.js +0 -22
  271. package/lib/component/1d/integral/IntegralIndicator.js.map +0 -1
  272. package/lib/component/2d/1d-tracer/Signals1D.d.ts +0 -11
  273. package/lib/component/2d/1d-tracer/Signals1D.d.ts.map +0 -1
  274. package/lib/component/2d/1d-tracer/Signals1D.js +0 -90
  275. package/lib/component/2d/1d-tracer/Signals1D.js.map +0 -1
  276. package/src/component/1d/integral/IntegralIndicator.tsx +0 -43
  277. package/src/component/2d/1d-tracer/Signals1D.tsx +0 -145
@@ -1,3 +1,4 @@
1
+ import styled from '@emotion/styled';
1
2
  import {
2
3
  FieldGroupSVGLineStyleFields,
3
4
  FieldGroupSVGTextStyleFields,
@@ -9,6 +10,18 @@ import type { z } from 'zod';
9
10
  import type { gridlineValidation } from '../validation/axis_tab_validation.ts';
10
11
  import { defaultGeneralSettingsFormValues } from '../validation.ts';
11
12
 
13
+ // TODO: Expose the Fieldset and Legend components in react-science/ui package
14
+ const Fieldset = styled.fieldset`
15
+ display: block;
16
+ border-top: 1px lightgrey groove;
17
+ min-inline-size: min-content;
18
+ `;
19
+
20
+ const Legend = styled.legend`
21
+ display: block;
22
+ padding-inline-end: 5px;
23
+ `;
24
+
12
25
  export const AxisTab = withForm({
13
26
  defaultValues: defaultGeneralSettingsFormValues,
14
27
  render: ({ form }) => {
@@ -28,18 +41,69 @@ const TicksSection = withFieldGroup({
28
41
  const { AppField, Section } = group;
29
42
 
30
43
  return (
31
- <Section title="Ticks">
32
- <FieldGroupSVGTextStyleFields
33
- form={group}
34
- fields="primaryTicks.textStyle"
35
- label="Annotation style"
36
- previewText="0"
37
- />
38
- <hr />
39
- <AppField name="secondaryTicks.enabled">
40
- {({ Checkbox }) => <Checkbox label="Show secondary ticks" />}
41
- </AppField>
42
- </Section>
44
+ <>
45
+ <Section title="Axis label">
46
+ <FieldGroupSVGTextStyleFields
47
+ form={group}
48
+ fields="labelStyle"
49
+ label="Style"
50
+ previewText="0"
51
+ />
52
+ </Section>
53
+ <Section title="Primary ticks">
54
+ <FieldGroupSVGTextStyleFields
55
+ form={group}
56
+ fields="primaryTicks.textStyle"
57
+ label="Label style"
58
+ previewText="0"
59
+ />
60
+ <Fieldset>
61
+ <Legend>Line style</Legend>
62
+ <group.AppField name="primaryTicks.tickStyle.stroke">
63
+ {(field) => <field.ColorPicker label="Color" disableAlpha />}
64
+ </group.AppField>
65
+ <group.AppField name="primaryTicks.tickStyle.strokeOpacity">
66
+ {(field) => (
67
+ <field.NumericInput
68
+ label="Opacity"
69
+ min={0}
70
+ max={1}
71
+ minorStepSize={0.01}
72
+ step={0.05}
73
+ majorStepSize={0.1}
74
+ />
75
+ )}
76
+ </group.AppField>
77
+ <group.AppField name="primaryTicks.tickStyle.strokeWidth">
78
+ {(field) => <field.NumericInput label="Width" />}
79
+ </group.AppField>
80
+ </Fieldset>
81
+ </Section>
82
+
83
+ <Section title="Secondary ticks">
84
+ <AppField name="secondaryTicks.enabled">
85
+ {({ Checkbox }) => <Checkbox label="Show secondary ticks" />}
86
+ </AppField>
87
+ <group.AppField name="secondaryTicks.tickStyle.stroke">
88
+ {(field) => <field.ColorPicker label="Color" disableAlpha />}
89
+ </group.AppField>
90
+ <group.AppField name="secondaryTicks.tickStyle.strokeOpacity">
91
+ {(field) => (
92
+ <field.NumericInput
93
+ label="Opacity"
94
+ min={0}
95
+ max={1}
96
+ minorStepSize={0.01}
97
+ step={0.05}
98
+ majorStepSize={0.1}
99
+ />
100
+ )}
101
+ </group.AppField>
102
+ <group.AppField name="secondaryTicks.tickStyle.strokeWidth">
103
+ {(field) => <field.NumericInput label="Width" />}
104
+ </group.AppField>
105
+ </Section>
106
+ </>
43
107
  );
44
108
  },
45
109
  });
@@ -14,10 +14,24 @@ const gridlinesValidation = z.object({
14
14
  secondary: gridlineValidation,
15
15
  });
16
16
 
17
+ const primaryTicksValidation = z.object({
18
+ textStyle: svgTextStyleFieldsSchema,
19
+ tickStyle: svgLineStyleFieldsSchema.omit({
20
+ strokeDasharray: true,
21
+ }),
22
+ });
23
+ const secondaryTicksValidation = z.object({
24
+ enabled: z.boolean(),
25
+ tickStyle: svgLineStyleFieldsSchema.omit({
26
+ strokeDasharray: true,
27
+ }),
28
+ });
29
+
17
30
  export const axisValidation = z
18
31
  .object({
19
- primaryTicks: z.object({ textStyle: svgTextStyleFieldsSchema }),
20
- secondaryTicks: z.object({ enabled: z.boolean() }),
32
+ labelStyle: svgTextStyleFieldsSchema,
33
+ primaryTicks: primaryTicksValidation,
34
+ secondaryTicks: secondaryTicksValidation,
21
35
  gridlines1D: gridlinesValidation,
22
36
  gridlines2D: gridlinesValidation,
23
37
  })
@@ -273,7 +273,7 @@ export default function useAtomAssignment() {
273
273
  if (oclIDs.length > 0) {
274
274
  // set all IDs to highlight when hovering over an atom from assignment data
275
275
  const highlights = getHighlightsOnHover(assignments, oclIDs, [
276
- spectrum,
276
+ ...(spectrum ? [spectrum] : []),
277
277
  ...tracesSpectra,
278
278
  ]);
279
279
  highlightedIdDsRef.current = highlights;
@@ -92,9 +92,7 @@ function RangesTablePanelInner(props: RangesTablePanelInnerProps) {
92
92
  const unlinkRangeHandler = useCallback(() => {
93
93
  dispatch({
94
94
  type: 'UNASSIGN_1D_SIGNAL',
95
- payload: {
96
- signalIndex: -1,
97
- },
95
+ payload: {},
98
96
  });
99
97
  }, [dispatch]);
100
98
 
@@ -105,25 +105,23 @@ export default function RangesTableRow(props: RangesTableRowProps) {
105
105
  }, [rowData.tableMetaInfo]);
106
106
 
107
107
  const unlinkHandler = useCallback(
108
- (e: MouseEvent, isOnRangeLevel: boolean) => {
108
+ (e: MouseEvent) => {
109
109
  // stop propagation here to prevent enabling/disabling the assignment mode at the same time
110
110
  if (e) {
111
111
  e.stopPropagation();
112
112
  }
113
113
 
114
- if (isOnRangeLevel !== undefined) {
115
- const { id: rangeKey, tableMetaInfo } = rowData;
114
+ const { id: rangeKey, tableMetaInfo } = rowData;
116
115
 
117
- const signalIndex = isOnRangeLevel ? -1 : tableMetaInfo.signalIndex;
116
+ const signalIndex = tableMetaInfo.signalIndex;
118
117
 
119
- dispatch({
120
- type: 'UNASSIGN_1D_SIGNAL',
121
- payload: {
122
- rangeKey,
123
- signalIndex,
124
- },
125
- });
126
- }
118
+ dispatch({
119
+ type: 'UNASSIGN_1D_SIGNAL',
120
+ payload: {
121
+ rangeKey,
122
+ signalIndex,
123
+ },
124
+ });
127
125
  },
128
126
  [dispatch, rowData],
129
127
  );
@@ -12,7 +12,7 @@ interface SignalAssignmentsColumnProps
12
12
  isActive: boolean;
13
13
  };
14
14
  onLink?: (a: MouseEvent, b: AssignmentsData) => void;
15
- onUnlink?: (element: MouseEvent, b: boolean) => void;
15
+ onUnlink?: (element: MouseEvent) => void;
16
16
  }
17
17
 
18
18
  function SignalAssignmentsColumn({
@@ -44,7 +44,7 @@ function SignalAssignmentsColumn({
44
44
  onClick={assignHandler}
45
45
  style={{ padding: '0', ...tdCss }}
46
46
  hideRemoveAssignmentButton={!diaIDs || diaIDs.length === 0}
47
- onRemove={(e) => onUnlink?.(e, false)}
47
+ onRemove={(e) => onUnlink?.(e)}
48
48
  >
49
49
  {(diaIDs?.length > 0 || assignment.isActive) && (
50
50
  <span>{diaIDs?.length || 0}</span>
@@ -2,13 +2,12 @@ import { Classes, Switch } from '@blueprintjs/core';
2
2
  import styled from '@emotion/styled';
3
3
  import type {
4
4
  ProcessingOperatorId,
5
- Spectrum,
6
5
  SpectrumProcessingOperation,
7
6
  } from '@zakodium/nmrium-core';
8
7
  import { cast } from '@zakodium/utils';
9
8
  import type { Filter1D, Filter2D } from 'nmr-processing';
10
9
  import type { Dispatch, SetStateAction } from 'react';
11
- import { useEffect, useMemo, useState } from 'react';
10
+ import { useMemo, useState } from 'react';
12
11
  import { ObjectInspector } from 'react-inspector';
13
12
  import { Button } from 'react-science/ui';
14
13
 
@@ -25,6 +24,8 @@ import {
25
24
  CoreOperatorName,
26
25
  } from '../../utility/CoreSlot.tsx';
27
26
  import DefaultPanelHeader from '../header/DefaultPanelHeader.tsx';
27
+ import type { ProcessingsMutations } from '../hooks/use_processings_mutation.ts';
28
+ import { useProcessingsMutations } from '../hooks/use_processings_mutation.ts';
28
29
 
29
30
  const mapToolsToProcessing: Partial<Record<Tool, ProcessingOperatorId>> = {
30
31
  apodization: '@zakodium/nmrium-core-plugins#apodization1D',
@@ -53,8 +54,9 @@ const unremoveableProcessings = new Set<ProcessingOperatorId>([
53
54
  export function ProcessingsSectionsPanel() {
54
55
  const core = useCore();
55
56
  const { showAlert } = useAlert();
56
- const spectrum: Spectrum | undefined = useSpectrum();
57
+ const spectrum = useSpectrum();
57
58
  const { toolOptions } = useChartData();
59
+ const processingsMutations = useProcessingsMutations();
58
60
 
59
61
  cast<FilterName>(toolOptions.data.activeFilterID);
60
62
  const selectedToolProcessing = mapToolsToProcessing[toolOptions.selectedTool];
@@ -62,12 +64,7 @@ export function ProcessingsSectionsPanel() {
62
64
  mapFiltersToProcessings[toolOptions.data.activeFilterID];
63
65
  const [openedOperation, setOpenedOperation] = useState<string>();
64
66
 
65
- const [processings, setProcessings] = useState(
66
- () => spectrum?.processings ?? [],
67
- );
68
- useEffect(() => {
69
- setProcessings(spectrum?.processings ?? []);
70
- }, [spectrum?.processings]);
67
+ const processings = spectrum?.processings ?? [];
71
68
 
72
69
  const selectedProcessing = useMemo<{
73
70
  operatorId?: ProcessingOperatorId;
@@ -94,7 +91,7 @@ export function ProcessingsSectionsPanel() {
94
91
  {
95
92
  text: 'Yes',
96
93
  intent: 'danger',
97
- onClick: () => setProcessings([]),
94
+ onClick: () => void processingsMutations.removeAll(),
98
95
  },
99
96
  { text: 'No' },
100
97
  ];
@@ -113,12 +110,7 @@ export function ProcessingsSectionsPanel() {
113
110
  }
114
111
 
115
112
  function onReorder(sourceIndex: number, targetIndex: number) {
116
- const newProcessings = [...processings];
117
- [newProcessings[sourceIndex], newProcessings[targetIndex]] = [
118
- newProcessings[targetIndex],
119
- newProcessings[sourceIndex],
120
- ];
121
- setProcessings(newProcessings);
113
+ void processingsMutations.reorder(sourceIndex, targetIndex);
122
114
  }
123
115
 
124
116
  if (!spectrum) return null;
@@ -163,7 +155,7 @@ export function ProcessingsSectionsPanel() {
163
155
  isOpen={isOpen}
164
156
  isEditable={isEditable}
165
157
  setOpenedOperation={setOpenedOperation}
166
- setProcessings={setProcessings}
158
+ processingsMutations={processingsMutations}
167
159
  operation={operation}
168
160
  />
169
161
  }
@@ -175,12 +167,12 @@ export function ProcessingsSectionsPanel() {
175
167
  operation={operation}
176
168
  core={core}
177
169
  onChange={(operation) => {
178
- const newProcessings = processings.map((p) =>
179
- p.uid === operation.uid
180
- ? { ...operation, options: undefined }
181
- : p,
170
+ void processingsMutations.apply(
171
+ // onChange generally change settings
172
+ // so options should be re-computed
173
+ { ...operation, options: undefined },
174
+ index,
182
175
  );
183
- setProcessings(newProcessings);
184
176
  setOpenedOperation(undefined);
185
177
  }}
186
178
  >
@@ -226,21 +218,24 @@ interface ProcessingItemExtraProps {
226
218
  isOpen: boolean;
227
219
  isEditable: boolean | undefined;
228
220
  setOpenedOperation: Dispatch<SetStateAction<string | undefined>>;
229
- setProcessings: Dispatch<
230
- SetStateAction<Array<SpectrumProcessingOperation<unknown, unknown>>>
231
- >;
221
+ processingsMutations: ProcessingsMutations;
232
222
  }
233
223
 
234
224
  function ProcessingItemExtra(props: ProcessingItemExtraProps) {
235
- const { operation, isOpen, isEditable, setOpenedOperation, setProcessings } =
236
- props;
225
+ const {
226
+ operation,
227
+ isOpen,
228
+ isEditable,
229
+ setOpenedOperation,
230
+ processingsMutations,
231
+ } = props;
237
232
 
238
233
  return (
239
234
  <CompactControls>
240
235
  {isEditable && (
241
236
  <Button
242
- intent="success"
243
237
  tooltipProps={{ content: 'Edit filter' }}
238
+ intent="success"
244
239
  variant="minimal"
245
240
  onClick={() => setOpenedOperation(operation.uid)}
246
241
  icon="annotation"
@@ -249,31 +244,19 @@ function ProcessingItemExtra(props: ProcessingItemExtraProps) {
249
244
  )}
250
245
 
251
246
  <Button
252
- intent="danger"
253
247
  tooltipProps={{ content: 'Delete filter' }}
248
+ intent="danger"
254
249
  variant="minimal"
255
- onClick={() =>
256
- setProcessings((processings) =>
257
- processings.filter((p) => p.uid !== operation.uid),
258
- )
259
- }
250
+ onClick={() => processingsMutations.remove(operation.uid)}
260
251
  disabled={unremoveableProcessings.has(operation.operatorId)}
261
252
  icon="trash"
262
253
  />
263
254
 
264
255
  <Switch
256
+ checked={operation.enabled ?? false}
265
257
  innerLabelChecked="On"
266
258
  innerLabel="Off"
267
- checked={operation.enabled || false}
268
- onChange={() => {
269
- setProcessings((processings) =>
270
- processings.map((p) =>
271
- p.uid === operation.uid
272
- ? { ...operation, enabled: !operation.enabled }
273
- : p,
274
- ),
275
- );
276
- }}
259
+ onChange={() => processingsMutations.switchEnabled(operation.uid)}
277
260
  />
278
261
  </CompactControls>
279
262
  );
@@ -0,0 +1,171 @@
1
+ import type {
2
+ Spectrum,
3
+ SpectrumProcessingOperation,
4
+ } from '@zakodium/nmrium-core';
5
+ import { sliceSpectrum } from '@zakodium/nmrium-core';
6
+ import { noop } from '@zakodium/utils';
7
+ import type { Draft } from 'immer';
8
+
9
+ import { initializeContoursLevels } from '../../../data/data2d/Spectrum2D/contours.ts';
10
+ import { isSpectrum2D } from '../../../data/data2d/Spectrum2D/index.ts';
11
+ import { useChartData } from '../../context/ChartContext.tsx';
12
+ import { useCore } from '../../context/CoreContext.tsx';
13
+ import { useDispatch } from '../../context/DispatchContext.tsx';
14
+ import type { State } from '../../reducer/Reducer.ts';
15
+ import { setDomain, setMode } from '../../reducer/actions/DomainActions.ts';
16
+ import { updateView } from '../../reducer/actions/FiltersActions.ts';
17
+ import { resetSelectedTool } from '../../reducer/actions/ToolsActions.ts';
18
+ import zoomHistoryManager from '../../reducer/helper/ZoomHistoryManager.ts';
19
+ import { getActiveSpectrum } from '../../reducer/helper/getActiveSpectrum.ts';
20
+
21
+ export type ProcessingsMutations = ReturnType<typeof useProcessingsMutations>;
22
+
23
+ export function useProcessingsMutations() {
24
+ const core = useCore();
25
+ const state = useChartData();
26
+ const dispatch = useDispatch();
27
+
28
+ function setIsLoading(isLoading: boolean) {
29
+ dispatch({
30
+ type: 'SET_LOADING_FLAG',
31
+ payload: { isLoading },
32
+ });
33
+ }
34
+
35
+ /**
36
+ * Return sliced spectrum allowing free mutations
37
+ */
38
+ function getSpectrum() {
39
+ const activeSpectrum = getActiveSpectrum(state);
40
+ if (!activeSpectrum) return {};
41
+
42
+ const id = activeSpectrum.id;
43
+ const indexSpectrum = state.data.findIndex((s) => s.id === id);
44
+ if (indexSpectrum === -1) return {};
45
+
46
+ const spectrum = sliceSpectrum(state.data[indexSpectrum]);
47
+
48
+ return { spectrum, indexSpectrum };
49
+ }
50
+
51
+ async function submit(
52
+ spectrum: Spectrum,
53
+ index: number,
54
+ onProduce: (draft: Draft<State>, processedSpectrum: Spectrum) => void,
55
+ ) {
56
+ setIsLoading(true);
57
+ const processedSpectrum = await core
58
+ .processSpectrum(spectrum)
59
+ .finally(() => setIsLoading(false));
60
+
61
+ dispatch({
62
+ type: 'SET_SPECTRUM',
63
+ payload: {
64
+ index,
65
+ spectrum: processedSpectrum,
66
+ onProduce,
67
+ },
68
+ });
69
+ }
70
+
71
+ return {
72
+ async apply(
73
+ operation: SpectrumProcessingOperation<any, any>,
74
+ indexOperation: number,
75
+ ) {
76
+ const { spectrum, indexSpectrum } = getSpectrum();
77
+
78
+ if (!spectrum?.processings) return;
79
+ if (indexOperation > spectrum.processings.length) return;
80
+
81
+ spectrum.processings[indexOperation] = operation;
82
+
83
+ await submit(spectrum, indexSpectrum, (draft) => {
84
+ const {
85
+ domainUpdateRules = {
86
+ updateXDomain: false,
87
+ updateYDomain: false,
88
+ },
89
+ } = core.getOperator(operation.operatorId) ?? {};
90
+ updateView(draft, domainUpdateRules);
91
+ });
92
+ },
93
+
94
+ async reorder(sourceIndex: number, targetIndex: number) {
95
+ const { spectrum, indexSpectrum } = getSpectrum();
96
+ if (!spectrum?.processings) return;
97
+
98
+ [spectrum.processings[sourceIndex], spectrum.processings[targetIndex]] = [
99
+ spectrum.processings[targetIndex],
100
+ spectrum.processings[sourceIndex],
101
+ ];
102
+
103
+ await submit(spectrum, indexSpectrum, noop);
104
+ },
105
+
106
+ async remove(uid: string) {
107
+ const { spectrum, indexSpectrum } = getSpectrum();
108
+ if (!spectrum?.processings) return;
109
+
110
+ spectrum.processings = spectrum.processings.filter((p) => p.uid !== uid);
111
+
112
+ await submit(spectrum, indexSpectrum, (draft) => {
113
+ draft.toolOptions.data.activeFilterID = null;
114
+ resetSelectedTool(draft);
115
+ setDomain(draft);
116
+ setMode(draft);
117
+ });
118
+ },
119
+
120
+ async removeAll() {
121
+ const { spectrum, indexSpectrum } = getSpectrum();
122
+
123
+ if (!spectrum?.processings) return;
124
+ if (spectrum.processings.length === 0) return;
125
+
126
+ spectrum.processings = [];
127
+
128
+ await submit(spectrum, indexSpectrum, (draft) => {
129
+ draft.toolOptions.data.activeFilterID = null;
130
+ resetSelectedTool(draft);
131
+ setDomain(draft);
132
+ setMode(draft);
133
+ });
134
+ },
135
+
136
+ async switchEnabled(uid: string) {
137
+ const { spectrum, indexSpectrum } = getSpectrum();
138
+ if (!spectrum?.processings) return;
139
+
140
+ const operationIndex = spectrum.processings.findIndex(
141
+ (p) => p.uid === uid,
142
+ );
143
+ if (operationIndex === -1) return;
144
+
145
+ const operation = spectrum.processings[operationIndex];
146
+ operation.enabled = !operation.enabled;
147
+
148
+ await submit(spectrum, indexSpectrum, (draft, processedSpectrum) => {
149
+ if (isSpectrum2D(processedSpectrum) && processedSpectrum.info.isFt) {
150
+ draft.view.spectraContourLevels[processedSpectrum.id] =
151
+ initializeContoursLevels(processedSpectrum);
152
+ }
153
+
154
+ resetSelectedTool(draft);
155
+ setDomain(draft);
156
+ setMode(draft);
157
+
158
+ const zoomHistory = zoomHistoryManager(
159
+ draft.zoom.history,
160
+ draft.view.spectra.activeTab,
161
+ );
162
+ const zoomValue = zoomHistory.getLast();
163
+
164
+ if (zoomValue) {
165
+ draft.xDomain = zoomValue.xDomain;
166
+ draft.yDomain = zoomValue.yDomain;
167
+ }
168
+ });
169
+ },
170
+ };
171
+ }
@@ -13,7 +13,7 @@ import { booleanToString } from '../../utility/booleanToString.js';
13
13
 
14
14
  import { InformationEditionModal } from './InformationEditionModal.js';
15
15
 
16
- const emptyData = { info: {}, meta: {} };
16
+ const emptyData = { info: {}, meta: {}, customInfo: {} };
17
17
 
18
18
  function getToggleInformationBlock(
19
19
  isVisible: boolean,
@@ -648,6 +648,8 @@ function innerSpectrumReducer(draft: Draft<State>, action: Action) {
648
648
  return ToolsActions.setSpectraSameTopHandler(draft);
649
649
  case 'RESET_SPECTRA_SCALE':
650
650
  return ToolsActions.resetSpectraScale(draft);
651
+ case 'SET_SPECTRUM':
652
+ return SpectraActions.setSpectrum(draft, action);
651
653
 
652
654
  case 'CHANGE_SPECTRUM_DISPLAY_VIEW_MODE':
653
655
  return ToolsActions.handleChangeSpectrumDisplayMode(draft);
@@ -160,7 +160,7 @@ function handleDeleteCorrelation(
160
160
  if (zone && signal) {
161
161
  deleteSignal2D(draft, {
162
162
  spectrumId: spectrum.id,
163
- zone,
163
+ zone: original(zone),
164
164
  signalId: signal.id,
165
165
  });
166
166
  }
@@ -738,7 +738,7 @@ function getActiveFilterIndex(draft: Draft<State>) {
738
738
  return -1;
739
739
  }
740
740
 
741
- function updateView(
741
+ export function updateView(
742
742
  draft: Draft<State>,
743
743
  filterUpdateDomainRules: Readonly<FilterDomainUpdateRules>,
744
744
  ) {
@@ -5,7 +5,6 @@ import type {
5
5
  Spectrum1D,
6
6
  } from '@zakodium/nmrium-core';
7
7
  import type { Draft } from 'immer';
8
- import cloneDeep from 'lodash/cloneDeep.js';
9
8
  import { xFindClosestIndex } from 'ml-spectra-processing';
10
9
  import { Filters1DManager } from 'nmr-processing';
11
10
 
@@ -365,23 +364,19 @@ function handleSaveEditedRange(
365
364
  const spectrum = getSpectrum(draft);
366
365
  if (!isSpectrum1D(spectrum)) return;
367
366
 
368
- // remove assignments in global state
369
- const _editedRowData: any = unlink(range);
370
-
371
- delete _editedRowData.tableMetaInfo;
372
- delete _editedRowData.rowKey;
373
- // remove assignments in assignment hook data
374
- // for now: clear all assignments for this range because signals or levels to store might have changed
375
- const rangeIndex = getRangeIndex(spectrum, _editedRowData.id);
367
+ const rangeIndex = getRangeIndex(spectrum, range.id);
376
368
  if (rangeIndex === -1) {
377
369
  throw new Error('unreachable');
378
370
  }
379
371
 
380
- if (_editedRowData.id === 'new') {
381
- _editedRowData.id = crypto.randomUUID();
372
+ // Remove assignments in global state
373
+ unlink(range, -1);
374
+
375
+ if (range.id === 'new') {
376
+ range.id = crypto.randomUUID();
382
377
  }
383
378
 
384
- spectrum.ranges.values[rangeIndex] = _editedRowData;
379
+ spectrum.ranges.values[rangeIndex] = range;
385
380
  updateRangesRelativeValues(spectrum);
386
381
  handleUpdateCorrelations(draft);
387
382
  resetSelectedTool(draft);
@@ -400,11 +395,10 @@ function deleteSignal1D(draft: Draft<State>, props: DeleteSignalProps) {
400
395
  const signalIndex = range.signals.findIndex(
401
396
  (_signal) => _signal.id === signalId,
402
397
  );
398
+ if (signalIndex === -1) return;
399
+
403
400
  // Remove assignments for the signal range object in the global state.
404
- const _range = unlink(cloneDeep(range), {
405
- unlinkType: 'signal',
406
- signalIndex,
407
- });
401
+ const _range = unlink(range, signalIndex);
408
402
 
409
403
  _range.signals.splice(signalIndex, 1);
410
404
  spectrum.ranges.values[rangeIndex] = _range;
@@ -433,16 +427,11 @@ function clearSignalAssignment(
433
427
  const ranges = spectrum.ranges.values;
434
428
  if (rangeKey) {
435
429
  const rangeIndex = getRangeIndex(spectrum, rangeKey);
436
- const unlinkType = signalIndex === -1 ? 'range' : 'signal';
437
- ranges[rangeIndex] = unlink(ranges[rangeIndex], {
438
- unlinkType,
439
- signalIndex,
440
- });
430
+ ranges[rangeIndex] = unlink(ranges[rangeIndex], signalIndex);
441
431
  } else {
442
- const newRanges = ranges.map((range) => {
443
- return unlink(range);
444
- });
445
- spectrum.ranges.values = newRanges;
432
+ for (const range of ranges) {
433
+ unlink(range, -1);
434
+ }
446
435
  }
447
436
  }
448
437