nmrium 0.41.0 → 0.43.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 (247) hide show
  1. package/lib/component/1d/ApodizationLine.js +1 -1
  2. package/lib/component/1d/Chart1D.js +3 -2
  3. package/lib/component/1d/Line.js +1 -1
  4. package/lib/component/1d/Viewer1D.js +15 -3
  5. package/lib/component/1d/integral/IntegralResizable.js +4 -3
  6. package/lib/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  7. package/lib/component/1d/peaks/PeakAnnotations.js +20 -25
  8. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +2 -0
  9. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +59 -0
  10. package/lib/component/1d/peaks/PeakEditionManager.d.ts +18 -0
  11. package/lib/component/1d/peaks/PeakEditionManager.js +98 -0
  12. package/lib/component/1d/peaks/Peaks.d.ts +1 -0
  13. package/lib/component/1d/peaks/Peaks.js +22 -0
  14. package/lib/component/1d/ranges/Range.js +3 -1
  15. package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
  16. package/lib/component/1d/tool/BaseLineZones.js +11 -31
  17. package/lib/component/1d/utilities/intersectionResolver.d.ts +25 -0
  18. package/lib/component/1d/utilities/intersectionResolver.js +71 -0
  19. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  20. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  21. package/lib/component/2d/SlicingView.js +1 -1
  22. package/lib/component/2d/ft/Contours.js +1 -1
  23. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +5 -1
  24. package/lib/component/EventsTrackers/KeysListenerTracker.js +47 -6
  25. package/lib/component/assignment/index.d.ts +6 -1
  26. package/lib/component/assignment/index.js +5 -1
  27. package/lib/component/context/DispatchContext.d.ts +1 -2
  28. package/lib/component/context/KeyModifierContext.d.ts +13 -0
  29. package/lib/component/context/KeyModifierContext.js +39 -0
  30. package/lib/component/context/PreferencesContext.d.ts +39 -39
  31. package/lib/component/elements/Button.js +2 -0
  32. package/lib/component/elements/Input.js +1 -0
  33. package/lib/component/elements/NumberInput.d.ts +1 -0
  34. package/lib/component/elements/NumberInput.js +10 -3
  35. package/lib/component/elements/Scroller.d.ts +15 -0
  36. package/lib/component/elements/Scroller.js +31 -0
  37. package/lib/component/elements/formik/FormikOnChange.js +1 -1
  38. package/lib/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  39. package/lib/component/header/ApodizationOptionsPanel.js +23 -14
  40. package/lib/component/header/BaseLineCorrectionPanel.js +31 -10
  41. package/lib/component/header/Header.d.ts +10 -3
  42. package/lib/component/header/Header.js +5 -5
  43. package/lib/component/header/ZeroFillingOptionsPanel.js +37 -31
  44. package/lib/component/highlight/index.d.ts +1 -0
  45. package/lib/component/highlight/index.js +1 -0
  46. package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  47. package/lib/component/hooks/useCheckToolsVisibility.js +7 -3
  48. package/lib/component/hooks/useResizerStatus.d.ts +2 -0
  49. package/lib/component/hooks/useResizerStatus.js +7 -0
  50. package/lib/component/hooks/useSaveSettings.js +9 -11
  51. package/lib/component/hooks/useSpectrum.js +1 -1
  52. package/lib/component/main/ErrorOverlay.js +20 -0
  53. package/lib/component/main/InnerNMRium.d.ts +7 -0
  54. package/lib/component/main/InnerNMRium.js +52 -0
  55. package/lib/component/main/InnerNMRiumContents.d.ts +14 -0
  56. package/lib/component/main/InnerNMRiumContents.js +89 -0
  57. package/lib/component/main/NMRium.d.ts +23 -0
  58. package/lib/component/main/NMRium.js +13 -0
  59. package/lib/component/main/NMRiumStateProvider.d.ts +9 -0
  60. package/lib/component/main/NMRiumStateProvider.js +74 -0
  61. package/lib/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  62. package/lib/component/main/StateError.d.ts +4 -0
  63. package/lib/component/main/StateError.js +16 -0
  64. package/lib/component/main/index.d.ts +3 -0
  65. package/lib/component/main/index.js +3 -0
  66. package/lib/component/main/types.d.ts +18 -0
  67. package/lib/component/main/types.js +2 -0
  68. package/lib/component/modal/AboutPredictionModal.js +1 -1
  69. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  70. package/lib/component/modal/PredictSpectraModal.js +1 -1
  71. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +5 -16
  72. package/lib/component/modal/changeSum/ChangeSumModal.js +6 -115
  73. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +18 -0
  74. package/lib/component/modal/changeSum/ChangeSumModalContents.js +94 -0
  75. package/lib/component/modal/setting/GeneralSettings.js +2 -2
  76. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  77. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  78. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
  79. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  80. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +3 -9
  81. package/lib/component/panels/MoleculesPanel/Utilities.js +14 -10
  82. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +3 -3
  83. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  84. package/lib/component/panels/PeaksPanel/PeaksPanel.js +11 -5
  85. package/lib/component/panels/RangesPanel/RangesHeader.js +6 -10
  86. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +4 -3
  87. package/lib/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  88. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  89. package/lib/component/panels/ZonesPanel/ZonesPanel.js +3 -2
  90. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  91. package/lib/component/panels/databasePanel/DatabasePanel.js +33 -26
  92. package/lib/component/panels/header/DefaultPanelHeader.d.ts +3 -4
  93. package/lib/component/panels/header/DefaultPanelHeader.js +9 -5
  94. package/lib/component/panels/predictionPanel/PredictionPanel.js +1 -1
  95. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  96. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  97. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  98. package/lib/component/reducer/IgnoreActions.js +0 -1
  99. package/lib/component/reducer/Reducer.d.ts +1 -6
  100. package/lib/component/reducer/Reducer.js +32 -6
  101. package/lib/component/reducer/actions/FiltersActions.d.ts +32 -11
  102. package/lib/component/reducer/actions/FiltersActions.js +96 -28
  103. package/lib/component/reducer/actions/IntegralsActions.d.ts +6 -2
  104. package/lib/component/reducer/actions/IntegralsActions.js +44 -20
  105. package/lib/component/reducer/actions/MoleculeActions.d.ts +6 -2
  106. package/lib/component/reducer/actions/MoleculeActions.js +8 -2
  107. package/lib/component/reducer/actions/PeaksActions.d.ts +6 -4
  108. package/lib/component/reducer/actions/PeaksActions.js +19 -1
  109. package/lib/component/reducer/actions/RangesActions.d.ts +6 -2
  110. package/lib/component/reducer/actions/RangesActions.js +31 -3
  111. package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -15
  112. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  113. package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.d.ts +1 -1
  114. package/lib/component/toolbar/FunctionToolBar.js +13 -3
  115. package/lib/component/toolbar/ToolTypes.d.ts +1 -0
  116. package/lib/component/toolbar/ToolTypes.js +36 -0
  117. package/lib/component/utility/PathBuilder.js +11 -0
  118. package/lib/component/utility/export.js +7 -4
  119. package/lib/component/utility/filterType.d.ts +3 -0
  120. package/lib/component/utility/filterType.js +1 -0
  121. package/lib/component/workspaces/basic.js +2 -0
  122. package/lib/component/workspaces/embedded.js +2 -0
  123. package/lib/component/workspaces/exercise.js +2 -0
  124. package/lib/component/workspaces/prediction.js +9 -0
  125. package/lib/component/workspaces/process1D.js +2 -0
  126. package/lib/component/workspaces/workspaceDefaultProperties.js +10 -5
  127. package/lib/data/PredictionManager.d.ts +3 -3
  128. package/lib/data/PredictionManager.js +10 -10
  129. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -2
  130. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +2 -8
  131. package/lib/data/data1d/database.d.ts +4 -2
  132. package/lib/data/data1d/database.js +10 -3
  133. package/lib/data/molecules/Molecule.js +2 -2
  134. package/lib/data/molecules/MoleculeManager.d.ts +1 -0
  135. package/lib/data/molecules/MoleculeManager.js +14 -0
  136. package/lib/data/utilities/checkModifierKeyActivated.d.ts +1 -1
  137. package/lib/data/utilities/checkModifierKeyActivated.js +8 -13
  138. package/lib/versionInfo.js +1 -1
  139. package/lib-cjs/component/1d/ApodizationLine.js +1 -1
  140. package/lib-cjs/component/1d/Chart1D.js +3 -2
  141. package/lib-cjs/component/1d/Line.js +1 -1
  142. package/lib-cjs/component/1d/Viewer1D.js +15 -3
  143. package/lib-cjs/component/1d/integral/IntegralResizable.js +4 -3
  144. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  145. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +19 -24
  146. package/lib-cjs/component/1d/peaks/PeakAnnotationsSpreadMode.js +64 -0
  147. package/lib-cjs/component/1d/peaks/PeakEditionManager.js +129 -0
  148. package/lib-cjs/component/1d/peaks/Peaks.js +29 -0
  149. package/lib-cjs/component/1d/ranges/Range.js +3 -1
  150. package/lib-cjs/component/1d/tool/BaseLineZones.js +11 -34
  151. package/lib-cjs/component/1d/utilities/intersectionResolver.js +75 -0
  152. package/lib-cjs/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  153. package/lib-cjs/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  154. package/lib-cjs/component/2d/SlicingView.js +1 -1
  155. package/lib-cjs/component/2d/ft/Contours.js +1 -1
  156. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +46 -5
  157. package/lib-cjs/component/assignment/index.js +5 -1
  158. package/lib-cjs/component/context/KeyModifierContext.js +44 -0
  159. package/lib-cjs/component/elements/Button.js +2 -0
  160. package/lib-cjs/component/elements/Input.js +1 -0
  161. package/lib-cjs/component/elements/NumberInput.js +12 -2
  162. package/lib-cjs/component/elements/Scroller.js +35 -0
  163. package/lib-cjs/component/elements/formik/FormikOnChange.js +1 -1
  164. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  165. package/lib-cjs/component/header/ApodizationOptionsPanel.js +23 -14
  166. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +30 -9
  167. package/lib-cjs/component/header/Header.js +5 -5
  168. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +35 -29
  169. package/lib-cjs/component/highlight/index.js +1 -0
  170. package/lib-cjs/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  171. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +7 -3
  172. package/lib-cjs/component/hooks/useResizerStatus.js +11 -0
  173. package/lib-cjs/component/hooks/useSaveSettings.js +9 -11
  174. package/lib-cjs/component/hooks/useSpectrum.js +1 -1
  175. package/lib-cjs/component/main/ErrorOverlay.js +26 -0
  176. package/lib-cjs/component/main/InnerNMRium.js +82 -0
  177. package/lib-cjs/component/main/InnerNMRiumContents.js +96 -0
  178. package/lib-cjs/component/main/NMRium.js +19 -0
  179. package/lib-cjs/component/main/NMRiumStateProvider.js +80 -0
  180. package/lib-cjs/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  181. package/lib-cjs/component/main/StateError.js +20 -0
  182. package/lib-cjs/component/main/index.js +21 -0
  183. package/lib-cjs/component/main/types.js +3 -0
  184. package/lib-cjs/component/modal/AboutPredictionModal.js +1 -1
  185. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +1 -1
  186. package/lib-cjs/component/modal/PredictSpectraModal.js +1 -1
  187. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +6 -141
  188. package/lib-cjs/component/modal/changeSum/ChangeSumModalContents.js +124 -0
  189. package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -2
  190. package/lib-cjs/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  191. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
  192. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  193. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +14 -10
  194. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  195. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +32 -3
  196. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +29 -10
  197. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +3 -2
  198. package/lib-cjs/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  199. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +27 -3
  200. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +26 -2
  201. package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  202. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +33 -26
  203. package/lib-cjs/component/panels/header/DefaultPanelHeader.js +11 -5
  204. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +1 -1
  205. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  206. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  207. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  208. package/lib-cjs/component/reducer/IgnoreActions.js +0 -1
  209. package/lib-cjs/component/reducer/Reducer.js +31 -5
  210. package/lib-cjs/component/reducer/actions/FiltersActions.js +98 -28
  211. package/lib-cjs/component/reducer/actions/IntegralsActions.js +45 -20
  212. package/lib-cjs/component/reducer/actions/MoleculeActions.js +9 -2
  213. package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
  214. package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
  215. package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
  216. package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
  217. package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
  218. package/lib-cjs/component/utility/PathBuilder.js +11 -0
  219. package/lib-cjs/component/utility/export.js +7 -4
  220. package/lib-cjs/component/utility/filterType.js +2 -0
  221. package/lib-cjs/component/workspaces/basic.js +2 -0
  222. package/lib-cjs/component/workspaces/embedded.js +2 -0
  223. package/lib-cjs/component/workspaces/exercise.js +2 -0
  224. package/lib-cjs/component/workspaces/prediction.js +9 -0
  225. package/lib-cjs/component/workspaces/process1D.js +2 -0
  226. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +10 -5
  227. package/lib-cjs/data/PredictionManager.js +9 -9
  228. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
  229. package/lib-cjs/data/data1d/database.js +10 -3
  230. package/lib-cjs/data/molecules/Molecule.js +2 -2
  231. package/lib-cjs/data/molecules/MoleculeManager.js +16 -1
  232. package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
  233. package/lib-cjs/versionInfo.js +1 -1
  234. package/package.json +26 -25
  235. package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
  236. package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
  237. package/lib/component/ErrorOverlay.js +0 -27
  238. package/lib/component/NMRium.d.ts +0 -42
  239. package/lib/component/NMRium.js +0 -237
  240. package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
  241. package/lib/component/reducer/actions/GlobalActions.js +0 -4
  242. package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
  243. package/lib-cjs/component/ErrorOverlay.js +0 -30
  244. package/lib-cjs/component/NMRium.js +0 -267
  245. package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
  246. /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
  247. /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
@@ -288,6 +288,42 @@ export const options = {
288
288
  ],
289
289
  isToggle: false,
290
290
  },
291
+ fftDimension1: {
292
+ id: 'fftDimension1',
293
+ label: 'Fourier transform dimension 1',
294
+ hasOptionPanel: false,
295
+ isFilter: true,
296
+ mode: DISPLAYER_MODE.DM_2D,
297
+ spectraOptions: [
298
+ {
299
+ info: [
300
+ { key: 'isFid', value: true },
301
+ { key: 'isComplex', value: true },
302
+ ],
303
+ active: true,
304
+ },
305
+ ],
306
+ isToggle: false,
307
+ isExperimental: true,
308
+ },
309
+ fftDimension2: {
310
+ id: 'fftDimension2',
311
+ label: 'Fourier transform dimension 2',
312
+ hasOptionPanel: false,
313
+ isFilter: true,
314
+ mode: DISPLAYER_MODE.DM_2D,
315
+ spectraOptions: [
316
+ {
317
+ info: [
318
+ { key: 'isFid', value: true },
319
+ { key: 'isComplex', value: true },
320
+ ],
321
+ active: true,
322
+ },
323
+ ],
324
+ isToggle: false,
325
+ isExperimental: true,
326
+ },
291
327
  import: {
292
328
  id: 'import',
293
329
  label: 'Import',
@@ -3,9 +3,13 @@ export class PathBuilder {
3
3
  this.array = [];
4
4
  }
5
5
  moveTo(x, y) {
6
+ x = clamp(x);
7
+ y = clamp(y);
6
8
  this.array.push(`M ${x} ${y}`);
7
9
  }
8
10
  lineTo(x, y) {
11
+ x = clamp(x);
12
+ y = clamp(y);
9
13
  this.array.push(`L ${x} ${y}`);
10
14
  }
11
15
  closePath() {
@@ -16,3 +20,10 @@ export class PathBuilder {
16
20
  return this.array.join(' ');
17
21
  }
18
22
  }
23
+ /**
24
+ * Clamp values to avoid rendering issues of the SVG.
25
+ * This assumes that the viewport has pixel coordinates (so the max values are outside of the visible area)
26
+ */
27
+ function clamp(value) {
28
+ return Math.max(-1e5, Math.min(1e5, value));
29
+ }
@@ -187,14 +187,17 @@ function getBlob(rootRef, elementID) {
187
187
  const blob = new Blob([svg], { type: 'image/svg+xml' });
188
188
  return { blob, width, height };
189
189
  }
190
+ function getMatrix(element) {
191
+ const transform = window
192
+ .getComputedStyle(element)
193
+ .getPropertyValue('transform');
194
+ return new DOMMatrix(transform);
195
+ }
190
196
  function getMoleculesElement(rootRef) {
191
197
  const nmriumViewer = rootRef.getRootNode().querySelector(`#nmrium-viewer`);
192
198
  const floatingMoleculesGroup = document.createElement('g');
193
199
  for (const element of nmriumViewer.querySelectorAll('.draggable-molecule')) {
194
- const transform = window
195
- .getComputedStyle(element)
196
- .getPropertyValue('transform');
197
- const matrix = new DOMMatrix(transform);
200
+ const matrix = getMatrix(element);
198
201
  const actionHeaderElement = element.querySelector('.float-molecule-actions');
199
202
  const molElement = element
200
203
  .cloneNode(true)
@@ -0,0 +1,3 @@
1
+ export type FilterType<SourceType, Type> = Pick<SourceType, {
2
+ [K in keyof SourceType]: SourceType[K] extends Type ? K : never;
3
+ }[keyof SourceType]>;
@@ -0,0 +1 @@
1
+ export {};
@@ -32,6 +32,8 @@ export const basic = {
32
32
  phaseCorrection: true,
33
33
  baselineCorrection: true,
34
34
  autoRangeAndZonePicking: true,
35
+ fftDimension1: true,
36
+ fftDimension2: true,
35
37
  },
36
38
  },
37
39
  };
@@ -36,6 +36,8 @@ export const embedded = {
36
36
  zoomOut: true,
37
37
  zoom: true,
38
38
  autoRangeAndZonePicking: true,
39
+ fftDimension1: true,
40
+ fftDimension2: true,
39
41
  },
40
42
  },
41
43
  };
@@ -22,6 +22,8 @@ export const exercise = {
22
22
  integral: true,
23
23
  spectraCenterAlignments: true,
24
24
  spectraStackAlignments: true,
25
+ fftDimension1: true,
26
+ fftDimension2: true,
25
27
  },
26
28
  },
27
29
  general: {
@@ -1,6 +1,13 @@
1
1
  export const prediction = {
2
2
  version: 1,
3
3
  label: 'Prediction',
4
+ general: {
5
+ dimmedSpectraOpacity: 0.5,
6
+ verticalSplitterPosition: '440px',
7
+ verticalSplitterCloseThreshold: 600,
8
+ spectraRendering: 'auto',
9
+ loggingLevel: 'info',
10
+ },
4
11
  display: {
5
12
  panels: {
6
13
  spectraPanel: { display: true },
@@ -28,6 +35,8 @@ export const prediction = {
28
35
  zoomOut: true,
29
36
  zoom: true,
30
37
  autoRangeAndZonePicking: true,
38
+ fftDimension1: true,
39
+ fftDimension2: true,
31
40
  },
32
41
  },
33
42
  formatting: {
@@ -28,6 +28,8 @@ export const process1D = {
28
28
  exclusionZones: true,
29
29
  multipleSpectraAnalysis: true,
30
30
  autoRangeAndZonePicking: true,
31
+ fftDimension1: true,
32
+ fftDimension2: true,
31
33
  },
32
34
  },
33
35
  };
@@ -44,6 +44,8 @@ export const workspaceDefaultProperties = {
44
44
  zoom: false,
45
45
  peakPicking: false,
46
46
  autoRangeAndZonePicking: false,
47
+ fftDimension1: false,
48
+ fftDimension2: false,
47
49
  },
48
50
  },
49
51
  general: {
@@ -89,21 +91,24 @@ export const workspaceDefaultProperties = {
89
91
  infoBlock: {
90
92
  visible: false,
91
93
  fields: [
92
- { label: 'name', jpath: ['display', 'name'], visible: true },
94
+ { label: 'name', jpath: ['info', 'name'], visible: true, format: '' },
93
95
  {
94
96
  label: 'Number Of Scan',
95
97
  jpath: ['info', 'numberOfScans'],
96
98
  visible: true,
99
+ format: '0',
97
100
  },
98
101
  {
99
- label: 'Acquisition Time',
100
- jpath: ['info', 'acquisitionTime'],
102
+ label: 'Pulse Sequence',
103
+ jpath: ['info', 'pulseSequence'],
101
104
  visible: true,
105
+ format: '',
102
106
  },
103
107
  {
104
- label: 'Pulse Sequence',
105
- jpath: ['info', 'pulseSequence'],
108
+ label: 'Frequency',
109
+ jpath: ['info', 'originFrequency'],
106
110
  visible: true,
111
+ format: '0',
107
112
  },
108
113
  ],
109
114
  },
@@ -1,9 +1,9 @@
1
1
  import { Logger } from 'cheminfo-types';
2
2
  import { Spectrum } from 'nmr-load-save';
3
- import { PredictedAll, Prediction1D, Prediction2D } from 'nmr-processing';
3
+ import { Predicted, PredictionBase1D, PredictionBase2D } from 'nmr-processing';
4
4
  export type Experiment = 'proton' | 'carbon' | 'cosy' | 'hsqc' | 'hmbc';
5
5
  export type SpectraPredictionOptions = Record<Experiment, boolean>;
6
- export type PredictedSpectraResult = Partial<Record<Experiment, Prediction1D | Prediction2D>>;
6
+ export type PredictedSpectraResult = Partial<Record<Experiment, PredictionBase1D | PredictionBase2D>>;
7
7
  export interface PredictionOptions {
8
8
  name: string;
9
9
  frequency: number;
@@ -34,5 +34,5 @@ export declare const FREQUENCIES: Array<{
34
34
  value: number;
35
35
  label: string;
36
36
  }>;
37
- export declare function predictSpectra(molfile: string): Promise<PredictedAll>;
37
+ export declare function predictSpectra(molfile: string, options: any): Promise<Predicted>;
38
38
  export declare function generateSpectra(predictedSpectra: PredictedSpectraResult, inputOptions: PredictionOptions, color: string, logger: Logger): Spectrum[];
@@ -1,6 +1,6 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import { xMinMaxValues } from 'ml-spectra-processing';
3
- import { predictAll, signalsToXY, signals2DToZ, getFrequency, signalsToRanges, } from 'nmr-processing';
3
+ import { predict, signalsToXY, signals2DToZ, getFrequency, signalsToRanges, } from 'nmr-processing';
4
4
  import OCL from 'openchemlib/full';
5
5
  import { DatumKind } from './constants/SignalsKinds';
6
6
  import { initiateDatum1D, mapRanges, updateIntegralsRelativeValues, } from './data1d/Spectrum1D';
@@ -42,16 +42,16 @@ export const FREQUENCIES = [
42
42
  { value: 1000, label: '1000 MHz' },
43
43
  { value: 1200, label: '1200 MHz' },
44
44
  ];
45
- const baseURL = 'https://nmr-prediction.service.zakodium.com';
46
- export async function predictSpectra(molfile) {
45
+ export async function predictSpectra(molfile, options) {
47
46
  const molecule = OCL.Molecule.fromMolfile(molfile);
48
- return predictAll(molecule, {
49
- predictOptions: {
50
- C: {
51
- webserviceURL: `${baseURL}/v1/predict/carbon`,
52
- },
53
- },
54
- });
47
+ const predictOptions = {};
48
+ for (const key in options) {
49
+ if (!options[key])
50
+ continue;
51
+ const experiment = key === 'proton' ? 'H' : key === 'carbon' ? 'C' : key;
52
+ predictOptions[experiment] = {};
53
+ }
54
+ return predict(molecule, { predictOptions });
55
55
  }
56
56
  function generateName(name, options) {
57
57
  const { frequency, experiment } = options;
@@ -1,6 +1,5 @@
1
1
  import { Spectrum1D } from 'nmr-load-save';
2
2
  import { Signal1D } from 'nmr-processing';
3
- import { SumParams } from '../SumManager';
4
3
  interface RangeOptions {
5
4
  from: number;
6
5
  to: number;
@@ -37,5 +36,5 @@ export declare function createRangeObj({ from, to, absolute, signal, }: RangeOpt
37
36
  kind: string;
38
37
  integration: number;
39
38
  };
40
- export declare function addRange(spectrum: Spectrum1D, options: RangeOptions & SumParams): void;
39
+ export declare function addRange(spectrum: Spectrum1D, options: RangeOptions): void;
41
40
  export {};
@@ -1,8 +1,7 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import { xyIntegration } from 'ml-spectra-processing';
3
- import { updateRangesRelativeValues, mapRanges, } from 'nmr-processing';
3
+ import { mapRanges } from 'nmr-processing';
4
4
  import { DatumKind } from '../../../constants/SignalsKinds';
5
- import { initSumOptions } from '../SumManager';
6
5
  import detectSignal from './detectSignal';
7
6
  export function createRangeObj({ from, to, absolute, signal, }) {
8
7
  return {
@@ -16,7 +15,7 @@ export function createRangeObj({ from, to, absolute, signal, }) {
16
15
  };
17
16
  }
18
17
  export function addRange(spectrum, options) {
19
- const { from, to, molecules, nucleus } = options;
18
+ const { from, to } = options;
20
19
  const { x, re } = spectrum.data;
21
20
  const absolute = xyIntegration({ x, y: re }, { from, to, reverse: true });
22
21
  // detectSignal use the advance multiplet-analysis that can crash if too many points
@@ -36,12 +35,7 @@ export function addRange(spectrum, options) {
36
35
  }
37
36
  try {
38
37
  if (range) {
39
- spectrum.ranges.options = initSumOptions(spectrum.ranges.options, {
40
- molecules,
41
- nucleus,
42
- });
43
38
  spectrum.ranges.values = spectrum.ranges.values.concat(mapRanges([range], spectrum));
44
- updateRangesRelativeValues(spectrum);
45
39
  }
46
40
  }
47
41
  catch (error) {
@@ -33,8 +33,10 @@ export type PrepareDataResult = Partial<DataBaseBasic & DataBaseRange & DataBase
33
33
  export interface InitiateDatabaseResult {
34
34
  data: DatabaseNMREntry[];
35
35
  getSolvents: () => string[];
36
- search: (keywords?: string | string[]) => DatabaseNMREntry[];
37
- searchByStructure: (idCode: string) => DatabaseNMREntry[];
36
+ search: (options: {
37
+ keywords?: string | string[];
38
+ idCode?: string;
39
+ }) => DatabaseNMREntry[];
38
40
  }
39
41
  export declare function initiateDatabase(databases: DatabaseNMREntry[], nucleus: string): InitiateDatabaseResult;
40
42
  export declare function prepareData(data: DatabaseNMREntry[]): PrepareDataResult[];
@@ -14,9 +14,16 @@ export function initiateDatabase(databases, nucleus) {
14
14
  const data = databases.filter((datum) => datum.nucleus === nucleus);
15
15
  const moleculesDB = prepareMoleculesDB(data);
16
16
  const getSolvents = () => prepareGetSolvents(data);
17
- const search = (keywords = []) => filter(data, { keywords });
18
- const searchByStructure = (idCode) => processSearchByStructure(moleculesDB, idCode);
19
- return { searchByStructure, data, getSolvents, search };
17
+ const search = ({ idCode = '', keywords = '', }) => prepareSearch({ idCode, keywords, data, moleculesDB });
18
+ return { data, getSolvents, search };
19
+ }
20
+ function prepareSearch(options) {
21
+ const { data, keywords = [], moleculesDB, idCode } = options;
22
+ let searchData = data;
23
+ if (idCode) {
24
+ searchData = processSearchByStructure(moleculesDB, idCode);
25
+ }
26
+ return filter(searchData, { keywords });
20
27
  }
21
28
  function processSearchByStructure(moleculesDB, idCode) {
22
29
  // default format { format: 'idCode' }
@@ -4,8 +4,8 @@ import getAtomsFromMF from '../utilities/getAtomsFromMF';
4
4
  export const DRAGGABLE_STRUCTURE_INITIAL_BOUNDING_REACT = {
5
5
  x: 100,
6
6
  y: 50,
7
- width: 100,
8
- height: 100,
7
+ width: 190,
8
+ height: 200,
9
9
  };
10
10
  export function initMolecule(options = {}) {
11
11
  const id = options.id || v4();
@@ -5,3 +5,4 @@ export declare function setMolfile(molecules: StateMoleculeExtended[], currentMo
5
5
  export declare function extractNumber(value: string): string | null;
6
6
  export declare function extractLabelsNumbers(molecules: Array<Pick<StateMolecule, 'label'>>): number[];
7
7
  export declare function getLabelNumber(reserveNumbers: number[]): number;
8
+ export declare function getMolecules(text: string): Promise<import("nmr-load-save").StateMolecule[]>;
@@ -1,3 +1,5 @@
1
+ import { fileCollectionFromFiles } from 'filelist-utils';
2
+ import { read } from 'nmr-load-save';
1
3
  import { Molecule as OCLMolecule } from 'openchemlib/full';
2
4
  import { initMolecule } from './Molecule';
3
5
  export function fromJSON(mols, reservedMolecules = []) {
@@ -80,3 +82,15 @@ export function getLabelNumber(reserveNumbers) {
80
82
  }
81
83
  return 1;
82
84
  }
85
+ export async function getMolecules(text) {
86
+ let extension = 'smi';
87
+ if (/v[23]000/i.test(text)) {
88
+ extension = 'sdf';
89
+ }
90
+ const file = new File([text], `file.${extension}`, {
91
+ type: 'text/plain',
92
+ });
93
+ const collection = await fileCollectionFromFiles([file]);
94
+ const { nmriumState: { data }, } = await read(collection);
95
+ return data?.molecules || [];
96
+ }
@@ -1,2 +1,2 @@
1
1
  import { KeyboardEvent, MouseEvent } from 'react';
2
- export default function checkModifierKeyActivated(event: KeyboardEvent | MouseEvent): boolean;
2
+ export default function checkModifierKeyActivated<E = HTMLDivElement>(event: KeyboardEvent<E> | MouseEvent<E>): boolean;
@@ -1,15 +1,10 @@
1
+ const modifiersKeys = [
2
+ 'Alt',
3
+ 'AltGraph',
4
+ 'Control',
5
+ 'Meta',
6
+ 'Shift',
7
+ ];
1
8
  export default function checkModifierKeyActivated(event) {
2
- const modifiersKeys = [
3
- 'Alt',
4
- 'AltGraph',
5
- 'Control',
6
- 'Meta',
7
- 'Shift',
8
- ];
9
- for (const key of modifiersKeys) {
10
- if (event.getModifierState(key)) {
11
- return true;
12
- }
13
- }
14
- return false;
9
+ return modifiersKeys.some((key) => event.getModifierState(key));
15
10
  }
@@ -1 +1 @@
1
- export default { version: 'v0.41.0' };
1
+ export default { version: 'v0.43.0' };
@@ -97,6 +97,6 @@ function ApodizationLine() {
97
97
  return '';
98
98
  }
99
99
  };
100
- return ((0, jsx_runtime_1.jsx)("path", { "data-test-id": "apodization-line", stroke: "green", fill: "none", strokeWidth: "2", d: paths() }));
100
+ return ((0, jsx_runtime_1.jsx)("path", { "data-testid": "apodization-line", stroke: "green", fill: "none", strokeWidth: "2", d: paths() }));
101
101
  }
102
102
  exports.default = ApodizationLine;
@@ -15,12 +15,13 @@ const DatabaseElements_1 = __importDefault(require("./database/DatabaseElements"
15
15
  const IntegralsSeries_1 = __importDefault(require("./integral/IntegralsSeries"));
16
16
  const JGraph_1 = __importDefault(require("./jCouplingGraph/JGraph"));
17
17
  const MultiAnalysisRanges_1 = __importDefault(require("./multiAnalysis/MultiAnalysisRanges"));
18
- const PeakAnnotations_1 = __importDefault(require("./peaks/PeakAnnotations"));
18
+ const PeakEditionManager_1 = require("./peaks/PeakEditionManager");
19
+ const Peaks_1 = require("./peaks/Peaks");
19
20
  const PeaksShapes_1 = __importDefault(require("./peaks/PeaksShapes"));
20
21
  const Ranges_1 = __importDefault(require("./ranges/Ranges"));
21
22
  const BaseLineZones_1 = __importDefault(require("./tool/BaseLineZones"));
22
23
  function Chart1D({ mode, width, height, margin, displayerKey }) {
23
24
  const { current: { general: { spectraRendering }, }, } = (0, PreferencesContext_1.usePreferences)();
24
- return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", shapeRendering: spectraRendering, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-chart-1d`, children: (0, jsx_runtime_1.jsx)("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)(LinesSeries_1.default, {}), (0, jsx_runtime_1.jsx)(ApodizationLine_1.default, {}), (0, jsx_runtime_1.jsx)(IntegralsSeries_1.default, {}), (0, jsx_runtime_1.jsx)(PeakAnnotations_1.default, {}), (0, jsx_runtime_1.jsx)(Ranges_1.default, {}), (0, jsx_runtime_1.jsx)(JGraph_1.default, {}), (0, jsx_runtime_1.jsx)(MultiAnalysisRanges_1.default, {}), (0, jsx_runtime_1.jsx)(BaseLineZones_1.default, {}), (0, jsx_runtime_1.jsx)(ExclusionZonesAnnotations_1.default, {}), (0, jsx_runtime_1.jsx)(DatabaseElements_1.default, {}), (0, jsx_runtime_1.jsx)(PeaksShapes_1.default, {}), (0, jsx_runtime_1.jsx)(SpectraLegends_1.default, {}), (0, jsx_runtime_1.jsx)(SpectrumInfoBlock_1.default, {}), (0, jsx_runtime_1.jsx)("g", { className: "container", style: { pointerEvents: 'none' }, children: (0, jsx_runtime_1.jsx)(XAxis_1.default, { showGrid: true, mode: mode }) })] }));
25
+ return ((0, jsx_runtime_1.jsx)(PeakEditionManager_1.PeakEditionProvider, { children: (0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, id: "nmrSVG", shapeRendering: spectraRendering, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-chart-1d`, children: (0, jsx_runtime_1.jsx)("rect", { width: `${width - margin.left - margin.right}`, height: `${height}`, x: `${margin.left}`, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)(LinesSeries_1.default, {}), (0, jsx_runtime_1.jsx)(ApodizationLine_1.default, {}), (0, jsx_runtime_1.jsx)(IntegralsSeries_1.default, {}), (0, jsx_runtime_1.jsx)(Peaks_1.Peaks, {}), (0, jsx_runtime_1.jsx)(Ranges_1.default, {}), (0, jsx_runtime_1.jsx)(JGraph_1.default, {}), (0, jsx_runtime_1.jsx)(MultiAnalysisRanges_1.default, {}), (0, jsx_runtime_1.jsx)(BaseLineZones_1.default, {}), (0, jsx_runtime_1.jsx)(ExclusionZonesAnnotations_1.default, {}), (0, jsx_runtime_1.jsx)(DatabaseElements_1.default, {}), (0, jsx_runtime_1.jsx)(PeaksShapes_1.default, {}), (0, jsx_runtime_1.jsx)(SpectraLegends_1.default, {}), (0, jsx_runtime_1.jsx)(SpectrumInfoBlock_1.default, {}), (0, jsx_runtime_1.jsx)("g", { className: "container", style: { pointerEvents: 'none' }, children: (0, jsx_runtime_1.jsx)(XAxis_1.default, { showGrid: true, mode: mode }) })] }) }));
25
26
  }
26
27
  exports.default = Chart1D;
@@ -54,6 +54,6 @@ function Line({ data, id, display, index }) {
54
54
  }
55
55
  }, [scaleX, scaleY, id, data, xyReduce]);
56
56
  const { color: stroke, opacity: strokeOpacity } = (0, parseColor_1.parseColor)(display?.color || 'black');
57
- return ((0, jsx_runtime_1.jsx)("path", { className: "line", "data-test-id": "spectrum-line", stroke: stroke, fill: "none", strokeOpacity: opacity === 1 ? strokeOpacity : opacity, d: paths, transform: `translate(0,-${shiftY * index})` }, id));
57
+ return ((0, jsx_runtime_1.jsx)("path", { className: "line", "data-testid": "spectrum-line", stroke: stroke, fill: "none", strokeOpacity: opacity === 1 ? strokeOpacity : opacity, d: paths, transform: `translate(0,-${shiftY * index})` }, id));
58
58
  }
59
59
  exports.default = Line;
@@ -253,10 +253,10 @@ function Viewer1D({ emptyText = undefined }) {
253
253
  dispatch({ type: 'SET_ZOOM', payload: { event, selectedTool } });
254
254
  }, [dispatch, selectedTool]);
255
255
  const mouseClick = (0, react_1.useCallback)((position) => {
256
+ if (!scaleState.scaleX)
257
+ return;
258
+ const xPPM = scaleState.scaleX().invert(position.x);
256
259
  const propagateEvent = () => {
257
- if (!scaleState.scaleX)
258
- return;
259
- const xPPM = scaleState.scaleX().invert(position.x);
260
260
  Events_1.default.emit('mouseClick', {
261
261
  ...position,
262
262
  xPPM,
@@ -273,6 +273,18 @@ function Viewer1D({ emptyText = undefined }) {
273
273
  case ToolTypes_1.options.editRange.id:
274
274
  propagateEvent();
275
275
  break;
276
+ case ToolTypes_1.options.integral.id:
277
+ dispatch({
278
+ type: 'CUT_INTEGRAL',
279
+ payload: { cutValue: xPPM },
280
+ });
281
+ break;
282
+ case ToolTypes_1.options.rangePicking.id:
283
+ dispatch({
284
+ type: 'CUT_RANGE',
285
+ payload: { cutValue: xPPM },
286
+ });
287
+ break;
276
288
  default:
277
289
  break;
278
290
  }
@@ -12,7 +12,7 @@ const GlobalContext_1 = require("../../context/GlobalContext");
12
12
  const ScaleContext_1 = require("../../context/ScaleContext");
13
13
  const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
14
14
  const index_1 = require("../../highlight/index");
15
- const ToolTypes_1 = require("../../toolbar/ToolTypes");
15
+ const useResizerStatus_1 = require("../../hooks/useResizerStatus");
16
16
  const IntegralIndicator_1 = require("./IntegralIndicator");
17
17
  const stylesOnHover = (0, react_1.css) `
18
18
  pointer-events: bounding-box;
@@ -43,7 +43,7 @@ const stylesHighlighted = (0, react_1.css) `
43
43
  }
44
44
  `;
45
45
  function IntegralResizable({ integralData, integralFormat, }) {
46
- const { height, margin, toolOptions: { selectedTool }, } = (0, ChartContext_1.useChartData)();
46
+ const { height, margin } = (0, ChartContext_1.useChartData)();
47
47
  const { viewerRef } = (0, GlobalContext_1.useGlobal)();
48
48
  const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
49
49
  const dispatch = (0, DispatchContext_1.useDispatch)();
@@ -67,7 +67,8 @@ function IntegralResizable({ integralData, integralFormat, }) {
67
67
  const from = integralData.from ? scaleX()(integralData.from) : 0;
68
68
  const to = integralData.to ? scaleX()(integralData.to) : 0;
69
69
  const bottom = height - margin.bottom;
70
- return ((0, jsx_runtime_1.jsx)("g", { onMouseEnter: () => highlight.show(), onMouseLeave: () => highlight.hide(), children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: to, x2: from }, onEnd: handleOnStopResizing, parentElement: viewerRef, disabled: selectedTool !== ToolTypes_1.options.integral.id, children: ({ x1, x2 }, isActive) => {
70
+ const isResizeingActive = (0, useResizerStatus_1.useResizerStatus)('integral');
71
+ return ((0, jsx_runtime_1.jsx)("g", { onMouseEnter: () => highlight.show(), onMouseLeave: () => highlight.hide(), children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: to, x2: from }, onEnd: handleOnStopResizing, parentElement: viewerRef, disabled: !isResizeingActive, children: ({ x1, x2 }, isActive) => {
71
72
  const width = x2 - x1;
72
73
  return ((0, jsx_runtime_1.jsxs)("g", { css: highlight.isActive || isActive
73
74
  ? stylesHighlighted
@@ -12,6 +12,7 @@ const PreferencesContext_1 = require("../../context/PreferencesContext");
12
12
  const ScaleContext_1 = require("../../context/ScaleContext");
13
13
  const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
14
14
  const highlight_1 = require("../../highlight");
15
+ const useResizerStatus_1 = require("../../hooks/useResizerStatus");
15
16
  const styles = {
16
17
  common: (0, react_1.css) `
17
18
  pointer-events: bounding-box;
@@ -56,7 +57,8 @@ function AnalysisRange({ rangeData, columnKey, activeTab, }) {
56
57
  }, [activeTab, columnKey, dispatch, scaleX]);
57
58
  const from = scaleX()(rangeData.from);
58
59
  const to = scaleX()(rangeData.to);
59
- return ((0, jsx_runtime_1.jsx)("g", { ...highlight.onHover, ...highlight.onHover, children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", onEnd: resizeEndHandler, initialPosition: { x2: from, x1: to }, parentElement: viewerRef, children: ({ x1, x2 }, isActive) => ((0, jsx_runtime_1.jsxs)("g", { transform: `translate(0,25)`, css: [
60
+ const isResizeingActive = (0, useResizerStatus_1.useResizerStatus)('multipleSpectraAnalysis');
61
+ return ((0, jsx_runtime_1.jsx)("g", { ...highlight.onHover, ...highlight.onHover, children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", onEnd: resizeEndHandler, initialPosition: { x2: from, x1: to }, parentElement: viewerRef, disabled: !isResizeingActive, children: ({ x1, x2 }, isActive) => ((0, jsx_runtime_1.jsxs)("g", { transform: `translate(0,25)`, css: [
60
62
  styles.common,
61
63
  highlight.isActive || isActive
62
64
  ? styles.Highlighted
@@ -4,38 +4,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
- const react_1 = require("react");
8
7
  const ChartContext_1 = require("../../context/ChartContext");
9
8
  const ScaleContext_1 = require("../../context/ScaleContext");
9
+ const highlight_1 = require("../../highlight");
10
10
  const useActiveSpectrum_1 = require("../../hooks/useActiveSpectrum");
11
- const useActiveSpectrumPeaksViewState_1 = require("../../hooks/useActiveSpectrumPeaksViewState");
11
+ const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
12
12
  const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
13
- const PeakAnnotation_1 = __importDefault(require("./PeakAnnotation"));
13
+ const formatNumber_1 = require("../../utility/formatNumber");
14
+ const PeakEditionManager_1 = require("./PeakEditionManager");
14
15
  const emptyData = { peaks: {}, info: {}, display: {} };
15
16
  function PeakAnnotations() {
16
17
  const { displayerKey } = (0, ChartContext_1.useChartData)();
17
18
  const activeSpectrum = (0, useActiveSpectrum_1.useActiveSpectrum)();
18
- const { scaleX, scaleY, shiftY } = (0, ScaleContext_1.useScaleChecked)();
19
+ const { shiftY } = (0, ScaleContext_1.useScaleChecked)();
19
20
  const spectrum = (0, useSpectrum_1.default)(emptyData);
20
- const peaksViewState = (0, useActiveSpectrumPeaksViewState_1.useActiveSpectrumPeaksViewState)();
21
- const Peaks = (0, react_1.useMemo)(() => {
22
- if (!spectrum?.peaks?.values ||
23
- !spectrum.display.isVisible ||
24
- !peaksViewState.isPeaksVisible) {
25
- return null;
26
- }
27
- return ((0, jsx_runtime_1.jsx)("g", { transform: `translate(0,-${(activeSpectrum?.index || 0) * shiftY})`, children: spectrum.peaks.values.map(({ x, y, id }) => ((0, jsx_runtime_1.jsx)(PeakAnnotation_1.default, { x: scaleX()(x), y: scaleY(spectrum.id)(y) - 5, sign: Math.sign(y), id: id, value: x, color: "#730000", nucleus: spectrum.info.nucleus }, id))) }));
28
- }, [
29
- spectrum.peaks.values,
30
- spectrum.display.isVisible,
31
- spectrum.id,
32
- spectrum.info.nucleus,
33
- peaksViewState.isPeaksVisible,
34
- activeSpectrum?.index,
35
- shiftY,
36
- scaleX,
37
- scaleY,
38
- ]);
39
- return ((0, jsx_runtime_1.jsx)("g", { className: "peaks", clipPath: `url(#${displayerKey}clip-chart-1d)`, children: Peaks }));
21
+ return ((0, jsx_runtime_1.jsx)("g", { className: "peaks", clipPath: `url(#${displayerKey}clip-chart-1d)`, children: (0, jsx_runtime_1.jsx)("g", { transform: `translate(0,-${(activeSpectrum?.index || 0) * shiftY})`, children: spectrum.peaks.values.map((peak) => ((0, jsx_runtime_1.jsx)(PeakAnnotation, { spectrumId: spectrum.id, peak: peak, color: "#730000", nucleus: spectrum.info.nucleus }, peak.id))) }) }));
22
+ }
23
+ function PeakAnnotation({ peak, spectrumId, color, nucleus, }) {
24
+ const { id, x, y } = peak;
25
+ const sign = Math.sign(y);
26
+ const { deltaPPM } = (0, usePanelPreferences_1.usePanelPreferences)('peaks', nucleus);
27
+ const highlight = (0, highlight_1.useHighlight)([id], {
28
+ type: highlight_1.HighlightEventSource.PEAK,
29
+ extra: { id },
30
+ });
31
+ const { scaleX, scaleY } = (0, ScaleContext_1.useScaleChecked)();
32
+ const sx = scaleX()(x);
33
+ const sy = scaleY(spectrumId)(y) - 5;
34
+ return ((0, jsx_runtime_1.jsxs)("g", { style: { outline: 'none' }, transform: `translate(${sx}, ${sy})`, onMouseEnter: () => highlight.show(), onMouseLeave: () => highlight.hide(), children: [(0, jsx_runtime_1.jsx)("line", { x1: "0", x2: "0", y1: sign === -1 ? 10 : 0, y2: sign === -1 ? 28 : -18, stroke: color, strokeWidth: highlight.isActive ? '3px' : '1px' }), (0, jsx_runtime_1.jsx)(PeakEditionManager_1.PeakEditionListener, { value: x, x: x, y: y, useScaleX: true, useScaleY: true, id: id, dy: sign === -1 ? 0 : -26, children: (0, jsx_runtime_1.jsx)("text", { x: "0", y: sign === -1 ? 26 : -10, dy: "0", dx: "0.35em", fontSize: "11px", fill: color, children: (0, formatNumber_1.formatNumber)(x, deltaPPM.format) }) })] }));
40
35
  }
41
36
  exports.default = PeakAnnotations;