nmrium 2.8.0 → 3.0.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 (243) hide show
  1. package/lib/component/1d/SVGContent1D.js +3 -3
  2. package/lib/component/1d/SVGContent1D.js.map +1 -1
  3. package/lib/component/1d/inset/DraggableInset.d.ts +1 -1
  4. package/lib/component/1d/inset/DraggableInset.d.ts.map +1 -1
  5. package/lib/component/1d/inset/DraggableInset.js.map +1 -1
  6. package/lib/component/1d/inset/InsetProvider.d.ts +1 -1
  7. package/lib/component/1d/inset/InsetProvider.d.ts.map +1 -1
  8. package/lib/component/1d/inset/InsetProvider.js.map +1 -1
  9. package/lib/component/1d/inset/SpectraInsets.d.ts +0 -23
  10. package/lib/component/1d/inset/SpectraInsets.d.ts.map +1 -1
  11. package/lib/component/1d/inset/SpectraInsets.js +1 -1
  12. package/lib/component/1d/inset/SpectraInsets.js.map +1 -1
  13. package/lib/component/1d/peaks/PeakEditionManager.d.ts +1 -1
  14. package/lib/component/1d/peaks/PeakEditionManager.d.ts.map +1 -1
  15. package/lib/component/1d/peaks/PeaksShapes.d.ts +1 -2
  16. package/lib/component/1d/peaks/PeaksShapes.d.ts.map +1 -1
  17. package/lib/component/1d/peaks/PeaksShapes.js +31 -17
  18. package/lib/component/1d/peaks/PeaksShapes.js.map +1 -1
  19. package/lib/component/1d/peaks/usePeakShapesPath.d.ts +1 -2
  20. package/lib/component/1d/peaks/usePeakShapesPath.d.ts.map +1 -1
  21. package/lib/component/1d/peaks/usePeakShapesPath.js +2 -3
  22. package/lib/component/1d/peaks/usePeakShapesPath.js.map +1 -1
  23. package/lib/component/1d/plugin_chart_brush_tracker.js +1 -1
  24. package/lib/component/1d/plugin_chart_brush_tracker.js.map +1 -1
  25. package/lib/component/1d/plugin_svg_chart.d.ts +1 -1
  26. package/lib/component/1d/plugin_svg_chart.d.ts.map +1 -1
  27. package/lib/component/1d/plugin_svg_chart.js +16 -11
  28. package/lib/component/1d/plugin_svg_chart.js.map +1 -1
  29. package/lib/component/1d-2d/tools/CursorToolIcon.d.ts.map +1 -1
  30. package/lib/component/1d-2d/tools/CursorToolIcon.js +23 -6
  31. package/lib/component/1d-2d/tools/CursorToolIcon.js.map +1 -1
  32. package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
  33. package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
  34. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
  35. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts.map +1 -1
  36. package/lib/component/context/LoggerContext.js +1 -1
  37. package/lib/component/context/LoggerContext.js.map +1 -1
  38. package/lib/component/context/ScaleContext.d.ts +1 -1
  39. package/lib/component/context/ScaleContext.d.ts.map +1 -1
  40. package/lib/component/context/ScaleContext.js.map +1 -1
  41. package/lib/component/context/processings_mutations_context.api.d.ts +3 -2
  42. package/lib/component/context/processings_mutations_context.api.d.ts.map +1 -1
  43. package/lib/component/context/processings_mutations_context.api.js +82 -10
  44. package/lib/component/context/processings_mutations_context.api.js.map +1 -1
  45. package/lib/component/elements/Anchor.d.ts +1 -1
  46. package/lib/component/elements/Anchor.d.ts.map +1 -1
  47. package/lib/component/elements/DraggableDialog.js.map +1 -1
  48. package/lib/component/elements/EditableColumn.d.ts +6 -2
  49. package/lib/component/elements/EditableColumn.d.ts.map +1 -1
  50. package/lib/component/elements/EditableColumn.js +35 -25
  51. package/lib/component/elements/EditableColumn.js.map +1 -1
  52. package/lib/component/elements/ResizerWithScale.js +1 -1
  53. package/lib/component/elements/ResizerWithScale.js.map +1 -1
  54. package/lib/component/elements/export/ExportManager.d.ts +1 -1
  55. package/lib/component/elements/export/ExportManager.d.ts.map +1 -1
  56. package/lib/component/elements/export/ExportManager.js.map +1 -1
  57. package/lib/component/elements/tanstack_table/table.js +1 -1
  58. package/lib/component/elements/tanstack_table/table.js.map +1 -1
  59. package/lib/component/header/Header.js +1 -1
  60. package/lib/component/header/Header.js.map +1 -1
  61. package/lib/component/hooks/reduce2DSpectrum.js +1 -1
  62. package/lib/component/hooks/useCombinedRefs.d.ts +2 -2
  63. package/lib/component/hooks/useCombinedRefs.d.ts.map +1 -1
  64. package/lib/component/hooks/useCombinedRefs.js +1 -1
  65. package/lib/component/hooks/useCombinedRefs.js.map +1 -1
  66. package/lib/component/hooks/useSaveSettings.js +1 -1
  67. package/lib/component/hooks/useSaveSettings.js.map +1 -1
  68. package/lib/component/hooks/use_axis_unit.d.ts +3 -3
  69. package/lib/component/main/InnerNMRiumContents.d.ts +4 -4
  70. package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
  71. package/lib/component/main/NMRium.d.ts +1 -1
  72. package/lib/component/main/NMRium.d.ts.map +1 -1
  73. package/lib/component/main/NMRiumRefAPI.d.ts +1 -1
  74. package/lib/component/main/NMRiumRefAPI.d.ts.map +1 -1
  75. package/lib/component/main/NMRiumRefAPI.js.map +1 -1
  76. package/lib/component/main/NMRiumStateProvider.d.ts.map +1 -1
  77. package/lib/component/main/NMRiumStateProvider.js +4 -2
  78. package/lib/component/main/NMRiumStateProvider.js.map +1 -1
  79. package/lib/component/main/NMRiumViewer.d.ts +1 -1
  80. package/lib/component/main/NMRiumViewer.d.ts.map +1 -1
  81. package/lib/component/main/NMRiumViewerWrapper.d.ts +1 -1
  82. package/lib/component/main/NMRiumViewerWrapper.d.ts.map +1 -1
  83. package/lib/component/main/types.d.ts +2 -2
  84. package/lib/component/main/types.d.ts.map +1 -1
  85. package/lib/component/modal/ImportPublicationStringModal.d.ts.map +1 -1
  86. package/lib/component/modal/ImportPublicationStringModal.js +5 -0
  87. package/lib/component/modal/ImportPublicationStringModal.js.map +1 -1
  88. package/lib/component/modal/changeSum/SelectMolecule.js +2 -2
  89. package/lib/component/modal/changeSum/SelectMolecule.js.map +1 -1
  90. package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts +81 -81
  91. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts +81 -81
  92. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts +81 -81
  93. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_footer.d.ts +54 -54
  94. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts +54 -54
  95. package/lib/component/modal/setting/tanstack_general_settings/hooks/use_safe_workspace.d.ts +9 -9
  96. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts +54 -54
  97. package/lib/component/modal/setting/tanstack_general_settings/tabs/axis_tab.d.ts +54 -54
  98. package/lib/component/modal/setting/tanstack_general_settings/tabs/database_tab.d.ts +54 -54
  99. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.d.ts +54 -54
  100. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.d.ts +2 -2
  101. package/lib/component/modal/setting/tanstack_general_settings/tabs/external_api_tab.d.ts +54 -54
  102. package/lib/component/modal/setting/tanstack_general_settings/tabs/general_tab.d.ts +54 -54
  103. package/lib/component/modal/setting/tanstack_general_settings/tabs/import_filters_tab.d.ts +54 -54
  104. package/lib/component/modal/setting/tanstack_general_settings/tabs/nuclei_tab.d.ts +54 -54
  105. package/lib/component/modal/setting/tanstack_general_settings/tabs/panels_tab.d.ts +54 -54
  106. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_colors_tab.d.ts +54 -54
  107. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts +54 -54
  108. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts +54 -54
  109. package/lib/component/modal/setting/tanstack_general_settings/tabs/tools_tab.d.ts +54 -54
  110. package/lib/component/modal/setting/tanstack_general_settings/validation/auto_processing_tab_validation.d.ts +28 -28
  111. package/lib/component/modal/setting/tanstack_general_settings/validation/export_tab_validation.d.ts +10 -10
  112. package/lib/component/modal/setting/tanstack_general_settings/validation/general_tab_validation.d.ts +6 -6
  113. package/lib/component/modal/setting/tanstack_general_settings/validation/import_filters_tab_validation.d.ts +1 -1
  114. package/lib/component/modal/setting/tanstack_general_settings/validation.d.ts +27 -27
  115. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +1 -1
  116. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js.map +1 -1
  117. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +1 -1
  118. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts +1 -0
  119. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.d.ts.map +1 -1
  120. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js +30 -6
  121. package/lib/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.js.map +1 -1
  122. package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +1 -1
  123. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentColumn.d.ts.map +1 -1
  124. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentColumn.js +33 -2
  125. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentColumn.js.map +1 -1
  126. package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +1 -1
  127. package/lib/component/panels/SpectraPanel/SpectrumListPanel.js +1 -1
  128. package/lib/component/panels/SpectraPanel/SpectrumListPanel.js.map +1 -1
  129. package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +1 -1
  130. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.d.ts +1 -1
  131. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js +1 -1
  132. package/lib/component/panels/filtersPanel/Filters/FiltersSectionsPanel.js.map +1 -1
  133. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.d.ts +2 -2
  134. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.js +2 -2
  135. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.js.map +1 -1
  136. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts +2 -2
  137. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js +2 -2
  138. package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js.map +1 -1
  139. package/lib/component/panels/filtersPanel/processings/processing_item.js +1 -1
  140. package/lib/component/panels/filtersPanel/processings/processing_item.js.map +1 -1
  141. package/lib/component/panels/filtersPanel/processings/use_live_edit.d.ts +2 -6
  142. package/lib/component/panels/filtersPanel/processings/use_live_edit.d.ts.map +1 -1
  143. package/lib/component/panels/filtersPanel/processings/use_live_edit.js +9 -9
  144. package/lib/component/panels/filtersPanel/processings/use_live_edit.js.map +1 -1
  145. package/lib/component/reducer/Reducer.d.ts +5 -6
  146. package/lib/component/reducer/Reducer.d.ts.map +1 -1
  147. package/lib/component/reducer/Reducer.js +1 -1
  148. package/lib/component/reducer/Reducer.js.map +1 -1
  149. package/lib/component/reducer/actions/InsetActions.d.ts +1 -2
  150. package/lib/component/reducer/actions/InsetActions.d.ts.map +1 -1
  151. package/lib/component/reducer/actions/InsetActions.js +4 -5
  152. package/lib/component/reducer/actions/InsetActions.js.map +1 -1
  153. package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
  154. package/lib/component/reducer/actions/RangesActions.d.ts.map +1 -1
  155. package/lib/component/reducer/actions/RangesActions.js +33 -11
  156. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  157. package/lib/component/reducer/actions/processings_actions.d.ts +1 -0
  158. package/lib/component/reducer/actions/processings_actions.d.ts.map +1 -1
  159. package/lib/component/reducer/actions/processings_actions.js +4 -2
  160. package/lib/component/reducer/actions/processings_actions.js.map +1 -1
  161. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -1
  162. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts.map +1 -1
  163. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +1 -1
  164. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js.map +1 -1
  165. package/lib/component/utility/core_slots/core_operator_chart_mouse_icon.d.ts +9 -0
  166. package/lib/component/utility/core_slots/core_operator_chart_mouse_icon.d.ts.map +1 -0
  167. package/lib/component/utility/core_slots/core_operator_chart_mouse_icon.js +14 -0
  168. package/lib/component/utility/core_slots/core_operator_chart_mouse_icon.js.map +1 -0
  169. package/lib/component/utility/core_slots/core_operator_expanded.d.ts +1 -1
  170. package/lib/component/utility/core_slots/core_operator_expanded.d.ts.map +1 -1
  171. package/lib/component/utility/core_slots/core_slot.d.ts +1 -1
  172. package/lib/component/utility/core_slots/core_slot.d.ts.map +1 -1
  173. package/lib/component/utility/filterDatabaseInfoEntry.js +1 -1
  174. package/lib/component/utility/filterDatabaseInfoEntry.js.map +1 -1
  175. package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts.map +1 -1
  176. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -0
  177. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js.map +1 -1
  178. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -0
  179. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts.map +1 -1
  180. package/lib/data/data2d/Spectrum2D/contours.js +2 -2
  181. package/lib/data/data2d/Spectrum2D/get2DColor.js +5 -5
  182. package/lib/data/data2d/Spectrum2D/get2DColor.js.map +1 -1
  183. package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts.map +1 -1
  184. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -0
  185. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js.map +1 -1
  186. package/lib/utils/clipboard/clipboardComponents.js.map +1 -1
  187. package/lib/versionInfo.js +1 -1
  188. package/package.json +34 -35
  189. package/src/component/1d/SVGContent1D.tsx +3 -3
  190. package/src/component/1d/inset/DraggableInset.tsx +2 -1
  191. package/src/component/1d/inset/InsetProvider.tsx +1 -2
  192. package/src/component/1d/inset/SpectraInsets.tsx +1 -32
  193. package/src/component/1d/peaks/PeaksShapes.tsx +62 -40
  194. package/src/component/1d/peaks/usePeakShapesPath.ts +2 -4
  195. package/src/component/1d/plugin_chart_brush_tracker.tsx +1 -1
  196. package/src/component/1d/plugin_svg_chart.tsx +26 -15
  197. package/src/component/1d-2d/tools/CursorToolIcon.tsx +38 -16
  198. package/src/component/EventsTrackers/BrushTracker.tsx +1 -4
  199. package/src/component/EventsTrackers/KeysListenerTracker.tsx +1 -1
  200. package/src/component/context/LoggerContext.tsx +1 -1
  201. package/src/component/context/ScaleContext.tsx +2 -1
  202. package/src/component/context/processings_mutations_context.api.ts +115 -17
  203. package/src/component/elements/Anchor.tsx +1 -1
  204. package/src/component/elements/DraggableDialog.tsx +2 -2
  205. package/src/component/elements/EditableColumn.tsx +93 -63
  206. package/src/component/elements/ResizerWithScale.tsx +1 -1
  207. package/src/component/elements/export/ExportManager.tsx +1 -1
  208. package/src/component/elements/tanstack_table/table.tsx +1 -1
  209. package/src/component/header/Header.tsx +1 -1
  210. package/src/component/hooks/reduce2DSpectrum.ts +1 -1
  211. package/src/component/hooks/useCombinedRefs.ts +3 -3
  212. package/src/component/hooks/useSaveSettings.tsx +1 -1
  213. package/src/component/main/InnerNMRiumContents.tsx +4 -4
  214. package/src/component/main/NMRiumRefAPI.ts +1 -1
  215. package/src/component/main/NMRiumStateProvider.tsx +4 -2
  216. package/src/component/main/NMRiumViewer.tsx +1 -1
  217. package/src/component/main/NMRiumViewerWrapper.tsx +1 -1
  218. package/src/component/main/types.ts +3 -3
  219. package/src/component/modal/ImportPublicationStringModal.tsx +7 -0
  220. package/src/component/modal/changeSum/SelectMolecule.tsx +2 -2
  221. package/src/component/panels/AutomaticAssignment/useAutoAssignments.ts +1 -1
  222. package/src/component/panels/MoleculesPanel/hooks/useExtractAtomAssignmentLabel.ts +40 -8
  223. package/src/component/panels/RangesPanel/TableColumns/SignalAssignmentColumn.tsx +52 -2
  224. package/src/component/panels/SpectraPanel/SpectrumListPanel.tsx +1 -1
  225. package/src/component/panels/filtersPanel/Filters/FiltersSectionsPanel.tsx +1 -1
  226. package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.tsx +2 -2
  227. package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.tsx +2 -2
  228. package/src/component/panels/filtersPanel/processings/processing_item.tsx +1 -1
  229. package/src/component/panels/filtersPanel/processings/use_live_edit.ts +9 -17
  230. package/src/component/reducer/Reducer.ts +7 -4
  231. package/src/component/reducer/actions/InsetActions.ts +7 -9
  232. package/src/component/reducer/actions/RangesActions.ts +78 -20
  233. package/src/component/reducer/actions/processings_actions.ts +5 -2
  234. package/src/component/reducer/helper/ZoomHistoryManager.ts +1 -1
  235. package/src/component/reducer/helper/removeSpectrumRelatedObjectsById.ts +1 -1
  236. package/src/component/utility/core_slots/core_operator_chart_mouse_icon.tsx +32 -0
  237. package/src/component/utility/filterDatabaseInfoEntry.ts +1 -1
  238. package/src/data/data1d/Spectrum1D/initiateDatum1D.ts +3 -0
  239. package/src/data/data2d/Spectrum2D/contours.ts +2 -2
  240. package/src/data/data2d/Spectrum2D/get2DColor.ts +5 -5
  241. package/src/data/data2d/Spectrum2D/initiateDatum2D.ts +4 -0
  242. package/src/utils/clipboard/clipboardComponents.tsx +5 -5
  243. package/src/versionInfo.ts +1 -1
@@ -1,4 +1,5 @@
1
1
  import type { Spectrum1D } from '@zakodium/nmrium-core';
2
+ import { isSpectrum1D } from '@zakodium/nmrium-core';
2
3
 
3
4
  import { useScale } from '../../context/ScaleContext.js';
4
5
  import { useActiveSpectrum } from '../../hooks/useActiveSpectrum.js';
@@ -7,15 +8,21 @@ import useSpectrum from '../../hooks/useSpectrum.js';
7
8
 
8
9
  import { usePeakShapesPath } from './usePeakShapesPath.js';
9
10
 
10
- const emptyData = { peaks: {}, display: {} };
11
+ type PeaksShapesMode = 'peakShape' | 'peaksSum';
11
12
 
12
- function PeaksShapes() {
13
+ export function PeaksShapes() {
13
14
  const { shiftY } = useScale();
14
15
  const { showPeaksShapes, showPeaksSum } = useActiveSpectrumPeaksViewState();
15
16
  const activeSpectrum = useActiveSpectrum();
16
- const spectrum = useSpectrum(emptyData) as Spectrum1D;
17
+ const spectrum = useSpectrum();
17
18
 
18
- if (!spectrum?.peaks?.values || !spectrum.display.isVisible) {
19
+ if (!isSpectrum1D(spectrum)) {
20
+ return null;
21
+ }
22
+
23
+ const { peaks, display } = spectrum;
24
+
25
+ if (!peaks?.values || !display.isVisible) {
19
26
  return null;
20
27
  }
21
28
 
@@ -23,52 +30,67 @@ function PeaksShapes() {
23
30
 
24
31
  return (
25
32
  <g className="peaks-shapes">
26
- {showPeaksShapes && <PeaksShapesItems vAlign={shift} />}
27
- {showPeaksSum && <PeaksShapesSum vAlign={shift} />}
33
+ {showPeaksShapes && <PeaksShapesItems vAlign={shift} mode="peakShape" />}
34
+ {showPeaksSum && <PeaksShapesItems vAlign={shift} mode="peaksSum" />}
28
35
  </g>
29
36
  );
30
37
  }
31
38
 
32
- function PeaksShapesItems(props: { vAlign: number }) {
33
- const spectrum = useSpectrum(emptyData) as Spectrum1D;
34
- const getPath = usePeakShapesPath(spectrum);
39
+ function PeaksShapesItems(props: { vAlign: number; mode: PeaksShapesMode }) {
40
+ const spectrum = useSpectrum();
35
41
 
36
- return (
37
- <g>
38
- {' '}
39
- {spectrum.peaks.values.map((peak) => {
40
- const { fill, path } = getPath({ target: 'peakShape', peak });
41
- return (
42
- <path
43
- key={peak.id}
44
- fill={fill}
45
- fillOpacity={0.3}
46
- d={path}
47
- transform={`translate(0,-${props.vAlign})`}
48
- />
49
- );
50
- })}
51
- </g>
52
- );
42
+ if (!isSpectrum1D(spectrum)) {
43
+ return null;
44
+ }
45
+
46
+ return <PeaksShapesItemsContent spectrum={spectrum} {...props} />;
53
47
  }
54
48
 
55
- function PeaksShapesSum(props: { vAlign: number }) {
56
- const spectrum = useSpectrum(emptyData) as Spectrum1D;
57
- const getPath = usePeakShapesPath(spectrum);
49
+ function PeaksShapesItemsContent(props: {
50
+ spectrum: Spectrum1D;
51
+ vAlign: number;
52
+ mode: PeaksShapesMode;
53
+ }) {
54
+ const { spectrum, vAlign, mode } = props;
55
+ const {
56
+ id,
57
+ info: { originFrequency },
58
+ } = spectrum;
59
+ const getPath = usePeakShapesPath(id, originFrequency);
60
+
61
+ const {
62
+ peaks: { values: peaksList },
63
+ } = spectrum;
64
+
65
+ if (peaksList.length === 0) {
66
+ return null;
67
+ }
68
+
69
+ const transform = `translate(0,-${vAlign})`;
70
+
71
+ if (mode === 'peakShape') {
72
+ return (
73
+ <g>
74
+ {peaksList.map((peak) => {
75
+ const { fill, path } = getPath({ target: 'peakShape', peak });
76
+ return (
77
+ <path
78
+ key={peak.id}
79
+ fill={fill}
80
+ fillOpacity={0.3}
81
+ d={path}
82
+ transform={transform}
83
+ />
84
+ );
85
+ })}
86
+ </g>
87
+ );
88
+ }
58
89
 
59
90
  const { fill, path } = getPath({
60
91
  target: 'peaksSum',
61
- peaks: spectrum.peaks.values,
92
+ peaks: peaksList,
62
93
  });
63
94
 
64
- return (
65
- <path
66
- stroke={'darkblue'}
67
- fill={fill}
68
- d={path}
69
- transform={`translate(0,-${props.vAlign})`}
70
- />
71
- );
95
+ return <path stroke="darkblue" fill={fill} d={path} transform={transform} />;
72
96
  }
73
-
74
- export default PeaksShapes;
@@ -1,5 +1,4 @@
1
1
  import type { Peak1D } from '@zakodium/nmr-types';
2
- import type { Spectrum1D } from '@zakodium/nmrium-core';
3
2
  import type { DataXY } from 'cheminfo-types';
4
3
  import { peakToXY, peaksToXY } from 'nmr-processing';
5
4
  import { SVGPathBuilder } from 'react-science/ui';
@@ -17,7 +16,7 @@ type PeaksShapesOptions =
17
16
  peaks: Peak1D[];
18
17
  };
19
18
 
20
- export function usePeakShapesPath(spectrum: Spectrum1D) {
19
+ export function usePeakShapesPath(spectrumId: string, frequency: number) {
21
20
  const { scaleX, scaleY } = useScaleChecked();
22
21
  const { width, xDomain } = useChartData();
23
22
 
@@ -27,7 +26,6 @@ export function usePeakShapesPath(spectrum: Spectrum1D) {
27
26
  } {
28
27
  const { target } = options;
29
28
 
30
- const frequency = spectrum.info.originFrequency;
31
29
  let pathSeries: DataXY | null = null;
32
30
  switch (target) {
33
31
  case 'peakShape': {
@@ -54,7 +52,7 @@ export function usePeakShapesPath(spectrum: Spectrum1D) {
54
52
  break;
55
53
  }
56
54
  const _scaleX = scaleX();
57
- const _scaleY = scaleY({ spectrumId: spectrum.id });
55
+ const _scaleY = scaleY({ spectrumId });
58
56
 
59
57
  const pathBuilder = new SVGPathBuilder();
60
58
  let fill = 'transparent';
@@ -20,7 +20,7 @@ export function PluginChartBrushTracker() {
20
20
  const indicatorLineColor = useIndicatorLineColor();
21
21
 
22
22
  const [liveOperation, setLiveOperation] = useLiveOperation();
23
- const liveEdit = useLiveEdit(liveOperation);
23
+ const liveEdit = useLiveEdit(liveOperation?.uid);
24
24
  const processingsMutations = useProcessingsMutations();
25
25
 
26
26
  const scaleX = useMemo(() => scaleXBuilder(), [scaleXBuilder]);
@@ -1,29 +1,32 @@
1
+ import { assertDefined } from '@zakodium/utils';
1
2
  import { useMemo } from 'react';
2
3
 
3
4
  import { useChartData } from '../context/ChartContext.tsx';
4
5
  import { useCore } from '../context/CoreContext.tsx';
6
+ import type { ScaleLinearNumberFunction } from '../context/ScaleContext.tsx';
5
7
  import { useScaleChecked } from '../context/ScaleContext.tsx';
6
8
  import { useIndicatorLineColor } from '../hooks/useIndicatorLineColor.ts';
7
- import { useStableSpectrum } from '../hooks/useSpectrum.ts';
9
+ import useSpectrum from '../hooks/useSpectrum.ts';
8
10
  import { useVerticalAlign } from '../hooks/useVerticalAlign.ts';
9
11
  import { useLiveOperation } from '../panels/filtersPanel/processings/use_live_operation.ts';
10
12
  import { CoreOperatorChartSVG } from '../utility/core_slots/core_operator_chart_svg.tsx';
11
13
 
12
14
  import { getYScale } from './utilities/scale.ts';
13
15
 
14
- export function PluginSVGChart() {
16
+ export function PluginSVGChart1D() {
15
17
  const core = useCore();
16
- const spectrum = useStableSpectrum();
18
+ const spectrum = useSpectrum();
17
19
  const { height, width, margin } = useChartData();
18
20
  const [liveOperation] = useLiveOperation();
19
21
  const { scaleX: scaleXBuilder } = useScaleChecked();
20
22
  const indicatorLineColor = useIndicatorLineColor();
21
23
 
22
- const scaleX = useMemo(() => scaleXBuilder(), [scaleXBuilder]);
23
- const scaleY = useWindowYScale();
24
+ const scaleX = useChartScaleX(scaleXBuilder);
25
+ const scaleY = useChartScaleY();
24
26
 
25
27
  if (!liveOperation) return null;
26
28
  if (!spectrum) return null;
29
+ assertDefined(scaleX);
27
30
 
28
31
  const operatorUI = core.slotOperator(liveOperation.operatorId);
29
32
  if (!operatorUI) return null;
@@ -44,17 +47,25 @@ export function PluginSVGChart() {
44
47
  );
45
48
  }
46
49
 
47
- function useWindowYScale() {
50
+ function useChartScaleX(scaleXBuilder: ScaleLinearNumberFunction) {
51
+ return useMemo(() => scaleXBuilder(), [scaleXBuilder]);
52
+ }
53
+
54
+ function useChartScaleY() {
48
55
  const { spectraBottomMargin } = useScaleChecked();
49
- const { height, margin, yDomains } = useChartData();
56
+ const { height, margin, yDomain } = useChartData();
50
57
  const verticalAlign = useVerticalAlign();
51
58
 
52
- return getYScale({
53
- height,
54
- margin,
55
- verticalAlign,
56
- yDomain: [0, 1],
57
- yDomains,
58
- spectraBottomMargin,
59
- });
59
+ return useMemo(
60
+ () =>
61
+ getYScale({
62
+ height,
63
+ margin,
64
+ verticalAlign,
65
+ yDomain,
66
+ yDomains: {},
67
+ spectraBottomMargin,
68
+ }),
69
+ [height, margin, spectraBottomMargin, verticalAlign, yDomain],
70
+ );
60
71
  }
@@ -1,12 +1,16 @@
1
1
  import styled from '@emotion/styled';
2
2
  import { createElement } from 'react';
3
3
  import { TbRulerMeasure } from 'react-icons/tb';
4
+ import { match } from 'ts-pattern';
4
5
 
5
6
  import { useMouseTracker } from '../../EventsTrackers/MouseTracker.js';
6
7
  import { useChartData } from '../../context/ChartContext.js';
8
+ import { useCore } from '../../context/CoreContext.tsx';
7
9
  import { useKeyModifiers } from '../../context/KeyModifierContext.tsx';
10
+ import useCheckExperimentalFeature from '../../hooks/useCheckExperimentalFeature.ts';
8
11
  import type { IconDataContext, Tool } from '../../toolbar/ToolTypes.ts';
9
12
  import { getToolIcon } from '../../toolbar/ToolTypes.ts';
13
+ import { CoreOperatorChartMouseIcon } from '../../utility/core_slots/core_operator_chart_mouse_icon.tsx';
10
14
 
11
15
  const CursorWrapper = styled.div`
12
16
  position: absolute;
@@ -52,15 +56,14 @@ function getCursorOffset(placement: CursorPlacement, offset: number) {
52
56
  interface ToolIconRendererProps extends IconDataContext {
53
57
  toolId: Tool;
54
58
  size?: number;
55
- strokeWidth?: number;
56
59
  }
57
60
 
58
61
  function ToolIconRenderer(props: ToolIconRendererProps) {
59
- const { toolId, size, strokeWidth, ...idc } = props;
62
+ const { toolId, size, ...idc } = props;
60
63
 
61
64
  const icon = getToolIcon(toolId, idc);
62
65
  if (!icon) return null;
63
- return createElement(icon, { fontSize: size, strokeWidth });
66
+ return createElement(icon, { fontSize: size });
64
67
  }
65
68
  export function CursorToolIcon({
66
69
  placement = 'bottom-right',
@@ -72,7 +75,10 @@ export function CursorToolIcon({
72
75
  height,
73
76
  margin,
74
77
  toolOptions: { selectedTool },
78
+ processingOperators: { selected: selectedProcessingTool },
75
79
  } = useChartData();
80
+ const core = useCore();
81
+ const isExperimental = useCheckExperimentalFeature();
76
82
  const mousePosition = useMouseTracker();
77
83
  const { isPrimary, shiftKey } = useKeyModifiers();
78
84
  if (
@@ -92,19 +98,35 @@ export function CursorToolIcon({
92
98
  const showRulerIcon = selectedTool === 'zoom' && shiftKey;
93
99
 
94
100
  return (
95
- <CursorWrapper
96
- style={{
97
- transform: `translate(${x}px, ${y}px)`,
98
- }}
99
- >
100
- {showRulerIcon ? (
101
- <TbRulerMeasure size={size} />
102
- ) : (
103
- <ToolIconRenderer
104
- toolId={isPrimary ? selectedTool : 'zoom'}
105
- size={size}
106
- />
107
- )}
101
+ <CursorWrapper style={{ transform: `translate(${x}px, ${y}px)` }}>
102
+ {match({ showRulerIcon, selectedProcessingTool, isExperimental })
103
+ .when(
104
+ (input) => {
105
+ const { selectedProcessingTool, isExperimental } = input;
106
+
107
+ if (!isExperimental) return false;
108
+ if (!selectedProcessingTool) return false;
109
+
110
+ const operatorUI = core.slotOperator(selectedProcessingTool);
111
+ if (!operatorUI?.ChartMouseIcon) return false;
112
+
113
+ return true;
114
+ },
115
+ ({ selectedProcessingTool }) => (
116
+ <CoreOperatorChartMouseIcon
117
+ core={core}
118
+ selected={selectedProcessingTool}
119
+ size={size}
120
+ />
121
+ ),
122
+ )
123
+ .with({ showRulerIcon: true }, () => <TbRulerMeasure size={size} />)
124
+ .otherwise(() => (
125
+ <ToolIconRenderer
126
+ toolId={isPrimary ? selectedTool : 'zoom'}
127
+ size={size}
128
+ />
129
+ ))}
108
130
  </CursorWrapper>
109
131
  );
110
132
  }
@@ -3,7 +3,6 @@ import type {
3
3
  KeyboardEvent,
4
4
  MouseEvent,
5
5
  PointerEvent,
6
- Reducer,
7
6
  WheelEvent,
8
7
  } from 'react';
9
8
  import {
@@ -103,9 +102,7 @@ export function BrushTracker(options: BrushTrackerProps) {
103
102
  clickTriggerMode = 'native',
104
103
  } = options;
105
104
 
106
- const [state, dispatch] = useReducer<
107
- Reducer<BrushTrackerState, BrushTrackerAction>
108
- >(reducer, initialState);
105
+ const [state, dispatch] = useReducer(reducer, initialState);
109
106
  const clickCountRef = useRef(0);
110
107
  const timeoutRef = useRef<NodeJS.Timeout | null>(null);
111
108
  const lastPointRef = useRef<number>(0);
@@ -20,7 +20,7 @@ import SaveAsModal from '../modal/SaveAsModal.js';
20
20
  import { options } from '../toolbar/ToolTypes.js';
21
21
 
22
22
  interface KeysListenerTrackerProps {
23
- mainDivRef: RefObject<HTMLDivElement>;
23
+ mainDivRef: RefObject<HTMLDivElement | null>;
24
24
  }
25
25
 
26
26
  function KeysListenerTracker(props: KeysListenerTrackerProps) {
@@ -57,7 +57,7 @@ export function LoggerProvider({ children }: LoggerProviderProps) {
57
57
  const [lastReadLogId, setLastLogId] = useState(0);
58
58
  const [logsHistory, setLogsHistory] = useState<LogEntry[]>([]);
59
59
  const [isLogHistoryOpened, openLogHistory] = useState(false);
60
- const popupLoggingLevelRef = useRef<LogEntry['levelLabel']>();
60
+ const popupLoggingLevelRef = useRef<LogEntry['levelLabel']>(undefined);
61
61
  const [logger] = useState(() => new FifoLogger());
62
62
 
63
63
  useEffect(() => {
@@ -18,7 +18,8 @@ export interface ScaleLinearNumberOptions {
18
18
  spectrumId?: number | null | string;
19
19
  customDomain?: number[];
20
20
  }
21
- type ScaleLinearNumberFunction = (
21
+
22
+ export type ScaleLinearNumberFunction = (
22
23
  options?: ScaleLinearNumberOptions,
23
24
  ) => ScaleLinear<number, number>;
24
25
 
@@ -16,10 +16,11 @@ import {
16
16
  import type { Draft } from 'immer';
17
17
  import { useMemo } from 'react';
18
18
  import { useAccordionControls } from 'react-science/ui';
19
+ import { match } from 'ts-pattern';
19
20
  import { useEventCallback } from 'usehooks-ts';
20
21
 
21
22
  import { initializeContoursLevels } from '../../data/data2d/Spectrum2D/contours.ts';
22
- import type { State } from '../reducer/Reducer.ts';
23
+ import type { LiveEdit, State } from '../reducer/Reducer.ts';
23
24
  import { setDomain, setMode } from '../reducer/actions/DomainActions.ts';
24
25
  import { updateView } from '../reducer/actions/FiltersActions.ts';
25
26
  import { restoreLastZoomDomain } from '../reducer/helper/ZoomHistoryManager.ts';
@@ -33,6 +34,15 @@ export type ProcessingsMutations = ReturnType<
33
34
  typeof useProcessingsMutationsAPI
34
35
  >;
35
36
 
37
+ interface PrepareLiveChangeOptions {
38
+ operationUid: string;
39
+ shouldProcessAll: boolean;
40
+ shouldUpdateView: boolean;
41
+ liveOperation?: SpectrumProcessingOperation<unknown, unknown>;
42
+ preProcessOnly?: boolean;
43
+ enforceSpectrum?: Spectrum;
44
+ }
45
+
36
46
  export function useProcessingsMutationsAPI() {
37
47
  const core = useCore();
38
48
  const state = useChartData();
@@ -90,6 +100,8 @@ export function useProcessingsMutationsAPI() {
90
100
  onProduce: (draft) => onProduce(draft, processedSpectrum),
91
101
  },
92
102
  });
103
+
104
+ return spectrum;
93
105
  }
94
106
 
95
107
  function resetSelectedTool() {
@@ -101,11 +113,14 @@ export function useProcessingsMutationsAPI() {
101
113
 
102
114
  // --- API --- //
103
115
 
104
- const resetLiveChange = useEventCallback(function resetLiveChange() {
116
+ const resetLiveChange = useEventCallback(function resetLiveChange(
117
+ updateView: boolean,
118
+ ) {
105
119
  dispatch({
106
120
  type: 'SET_SPECTRUM_LIVE_PROCESSED',
107
121
  payload: {
108
122
  spectrumLiveProcessed: undefined,
123
+ updateView,
109
124
  },
110
125
  });
111
126
  });
@@ -203,11 +218,19 @@ export function useProcessingsMutationsAPI() {
203
218
  });
204
219
 
205
220
  // Related to live update
206
- const prepareLiveChange = useEventCallback(async function prepareLiveChange(
207
- uid: string,
208
- shouldProcessAll: boolean,
209
- ) {
210
- const { spectrum } = getSpectrum();
221
+ async function prepareLiveChange(options: PrepareLiveChangeOptions) {
222
+ const {
223
+ operationUid: uid,
224
+ shouldProcessAll,
225
+ shouldUpdateView,
226
+ liveOperation,
227
+ preProcessOnly = false,
228
+ enforceSpectrum,
229
+ } = options;
230
+
231
+ const { spectrum } = enforceSpectrum
232
+ ? { spectrum: sliceSpectrum(enforceSpectrum) }
233
+ : getSpectrum();
211
234
  if (!spectrum?.processings) return;
212
235
 
213
236
  const preProcessings: typeof spectrum.processings = [];
@@ -215,7 +238,12 @@ export function useProcessingsMutationsAPI() {
215
238
 
216
239
  let didFindUid = false;
217
240
  for (const operation of spectrum.processings) {
218
- if (uid === operation.uid) didFindUid = true;
241
+ if (uid === operation.uid) {
242
+ didFindUid = true;
243
+ processings.push(structuredClone(liveOperation ?? operation));
244
+ continue;
245
+ }
246
+
219
247
  if (didFindUid) processings.push(structuredClone(operation));
220
248
  else preProcessings.push(structuredClone(operation));
221
249
  }
@@ -229,6 +257,9 @@ export function useProcessingsMutationsAPI() {
229
257
  preProcessedSpectrum.originalInfo = structuredClone(
230
258
  preProcessedSpectrum.info,
231
259
  );
260
+ preProcessedSpectrum.originalProcessingInfo = structuredClone(
261
+ preProcessedSpectrum.processingInfo,
262
+ );
232
263
  if (isSpectrum1D(preProcessedSpectrum)) {
233
264
  preProcessedSpectrum.originalData = sliceData1D(
234
265
  preProcessedSpectrum.data,
@@ -241,6 +272,18 @@ export function useProcessingsMutationsAPI() {
241
272
  assertUnreachable(preProcessedSpectrum);
242
273
  }
243
274
 
275
+ // stop here preProcessOnly
276
+ if (preProcessOnly) {
277
+ dispatch({
278
+ type: 'SET_SPECTRUM_LIVE_PROCESSED',
279
+ payload: {
280
+ spectrumLiveProcessed: preProcessedSpectrum,
281
+ updateView: shouldUpdateView,
282
+ },
283
+ });
284
+ return;
285
+ }
286
+
244
287
  // apply the rest of processings
245
288
  const savedProcessings = structuredClone(preProcessedSpectrum.processings);
246
289
 
@@ -257,9 +300,10 @@ export function useProcessingsMutationsAPI() {
257
300
  type: 'SET_SPECTRUM_LIVE_PROCESSED',
258
301
  payload: {
259
302
  spectrumLiveProcessed: processedSpectrum,
303
+ updateView: shouldUpdateView,
260
304
  },
261
305
  });
262
- });
306
+ }
263
307
 
264
308
  const applyLiveChange = useEventCallback(async function applyLiveChange(
265
309
  operation: SpectrumProcessingOperation<any, any>,
@@ -289,10 +333,61 @@ export function useProcessingsMutationsAPI() {
289
333
  type: 'SET_SPECTRUM_LIVE_PROCESSED',
290
334
  payload: {
291
335
  spectrumLiveProcessed: processedSpectrum,
336
+ updateView: false,
292
337
  },
293
338
  });
294
339
  });
295
340
 
341
+ const handleLiveChange = useEventCallback(async function handleLiveChange(
342
+ liveEdit: LiveEdit,
343
+ operationUid: string,
344
+ ) {
345
+ const ui = core.slotOperator(operationUid);
346
+ const previousLiveEdit = state.processingOperators.liveEdit ?? {
347
+ checked: ui?.isLiveEditable ?? false,
348
+ shouldProcessNext:
349
+ ui?.defaultShouldProcessAll ?? liveEdit.shouldProcessNext,
350
+ };
351
+ const shouldUpdateView =
352
+ previousLiveEdit.shouldProcessNext !== liveEdit.shouldProcessNext;
353
+ const liveOperation = state.processingOperators.liveOperation;
354
+
355
+ await match(liveEdit)
356
+ // spectrum fully processed with live operation
357
+ .with({ checked: true, shouldProcessNext: true }, async () => {
358
+ await prepareLiveChange({
359
+ operationUid,
360
+ shouldProcessAll: true,
361
+ shouldUpdateView,
362
+ liveOperation,
363
+ });
364
+ })
365
+ // spectrum fully processed with original operation
366
+ // ie: no `state.spectrumLiveProcessed`
367
+ .with({ checked: false, shouldProcessNext: true }, async () => {
368
+ resetLiveChange(true);
369
+ })
370
+ // spectrum processed until the operation (stop before) then apply the live operation
371
+ .with({ checked: true, shouldProcessNext: false }, async () => {
372
+ await prepareLiveChange({
373
+ operationUid,
374
+ shouldProcessAll: false,
375
+ shouldUpdateView,
376
+ liveOperation,
377
+ });
378
+ })
379
+ // spectrum processed until the operation (stop before)
380
+ .with({ checked: false, shouldProcessNext: false }, async () => {
381
+ await prepareLiveChange({
382
+ operationUid,
383
+ shouldProcessAll: false,
384
+ shouldUpdateView,
385
+ preProcessOnly: true,
386
+ });
387
+ })
388
+ .exhaustive();
389
+ });
390
+
296
391
  const triggerOperation = useEventCallback(async function triggerOperation(
297
392
  operation: SpectrumProcessingOperation<any, any>,
298
393
  ) {
@@ -319,8 +414,8 @@ export function useProcessingsMutationsAPI() {
319
414
  assertNotNullish(operator);
320
415
 
321
416
  openPanel('processingsPanel');
322
- resetLiveChange();
323
- await submit(spectrum, indexSpectrum, (draft) =>
417
+ resetLiveChange(false);
418
+ const processedSpectrum = await submit(spectrum, indexSpectrum, (draft) =>
324
419
  updateView(draft, operator.domainUpdateRules),
325
420
  );
326
421
 
@@ -337,10 +432,13 @@ export function useProcessingsMutationsAPI() {
337
432
  }
338
433
 
339
434
  if (operatorUI.isLiveEditable) {
340
- await prepareLiveChange(
341
- operation.uid,
342
- operatorUI.defaultShouldProcessAll ?? false,
343
- );
435
+ await prepareLiveChange({
436
+ operationUid: operation.uid,
437
+ liveOperation: operation,
438
+ shouldProcessAll: operatorUI.defaultShouldProcessAll ?? false,
439
+ shouldUpdateView: true,
440
+ enforceSpectrum: processedSpectrum,
441
+ });
344
442
  }
345
443
  });
346
444
 
@@ -351,15 +449,15 @@ export function useProcessingsMutationsAPI() {
351
449
  remove,
352
450
  removeAll,
353
451
  switchEnabled,
354
- prepareLiveChange,
355
452
  resetLiveChange,
356
453
  applyLiveChange,
454
+ handleLiveChange,
357
455
  triggerOperation,
358
456
  }),
359
457
  [
360
458
  apply,
361
459
  applyLiveChange,
362
- prepareLiveChange,
460
+ handleLiveChange,
363
461
  remove,
364
462
  removeAll,
365
463
  reorder,
@@ -39,7 +39,7 @@ interface AnchorPosition {
39
39
  interface AnchorProps {
40
40
  position: AnchorPosition;
41
41
  shape?: AnchorShape;
42
- containerRef: RefObject<HTMLElement>;
42
+ containerRef: RefObject<HTMLElement | null>;
43
43
  anchorStyle?: AnchorStyle;
44
44
  restoreFocusOnLeave?: boolean;
45
45
  onDragMove: (newX: number) => void;
@@ -57,7 +57,7 @@ interface DraggableDialogProps
57
57
  }
58
58
 
59
59
  interface InnerDraggableDialogProps extends DraggableDialogProps {
60
- innerDialogRef: RefObject<HTMLDivElement>;
60
+ innerDialogRef: RefObject<HTMLDivElement | null>;
61
61
  }
62
62
  export function DraggableDialog(props: DraggableDialogProps) {
63
63
  const {
@@ -84,7 +84,7 @@ export function DraggableDialog(props: DraggableDialogProps) {
84
84
  />
85
85
  <Overlay2
86
86
  {...otherProps}
87
- childRef={dialogRef}
87
+ childRef={dialogRef as RefObject<HTMLDivElement>}
88
88
  onClose={onClose}
89
89
  className="draggable-portal"
90
90
  hasBackdrop={hasBackdrop}