nmrium 0.50.0 → 0.51.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 (196) hide show
  1. package/README.md +7 -7
  2. package/lib/component/1d/Chart1D.js +1 -1
  3. package/lib/component/1d/LinesSeries.js +2 -2
  4. package/lib/component/1d/Viewer1D.js +6 -11
  5. package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
  6. package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
  7. package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
  8. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
  9. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
  10. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
  11. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
  12. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
  13. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
  14. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
  15. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
  16. package/lib/component/2d/Viewer2D.js +16 -15
  17. package/lib/component/2d/ft/Contours.js +6 -3
  18. package/lib/component/2d/utilities/scale.d.ts +2 -1
  19. package/lib/component/2d/utilities/scale.js +12 -2
  20. package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
  21. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  22. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
  23. package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
  24. package/lib/component/context/ToasterContext.d.ts +13 -0
  25. package/lib/component/context/ToasterContext.js +34 -0
  26. package/lib/component/elements/CloseButton.d.ts +2 -2
  27. package/lib/component/elements/CloseButton.js +1 -1
  28. package/lib/component/elements/CounterLabel.d.ts +3 -3
  29. package/lib/component/elements/CounterLabel.js +3 -3
  30. package/lib/component/elements/PreferencesButton.d.ts +2 -2
  31. package/lib/component/elements/PreferencesButton.js +2 -4
  32. package/lib/component/elements/SaveButton.d.ts +2 -2
  33. package/lib/component/elements/SaveButton.js +1 -1
  34. package/lib/component/elements/Select.js +2 -2
  35. package/lib/component/elements/ToolBarButton.d.ts +1 -8
  36. package/lib/component/elements/ToolBarButton.js +2 -11
  37. package/lib/component/elements/ToolbarPopoverItem.d.ts +11 -0
  38. package/lib/component/elements/ToolbarPopoverItem.js +10 -0
  39. package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
  40. package/lib/component/header/Header.d.ts +1 -11
  41. package/lib/component/header/Header.js +5 -6
  42. package/lib/component/header/PhaseCorrectionPanel.js +24 -33
  43. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
  44. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
  45. package/lib/component/header/RangesPickingOptionPanel.js +6 -3
  46. package/lib/component/hooks/useDialogToggle.d.ts +5 -0
  47. package/lib/component/hooks/useDialogToggle.js +16 -0
  48. package/lib/component/hooks/useExport.d.ts +9 -1
  49. package/lib/component/hooks/useExport.js +34 -36
  50. package/lib/component/hooks/useSaveSettings.js +6 -3
  51. package/lib/component/hooks/useToolsFunctions.js +6 -4
  52. package/lib/component/loader/DropZone.js +14 -14
  53. package/lib/component/main/InnerNMRium.js +5 -9
  54. package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
  55. package/lib/component/main/InnerNMRiumContents.js +5 -3
  56. package/lib/component/main/NMRium.js +2 -2
  57. package/lib/component/modal/AboutPredictionModal.js +1 -1
  58. package/lib/component/modal/CopyClipboardModal.js +1 -1
  59. package/lib/component/modal/EditPeakShapeModal.js +1 -1
  60. package/lib/component/modal/ExportAsJcampModal.js +15 -15
  61. package/lib/component/modal/ImportPublicationStringModal.js +5 -3
  62. package/lib/component/modal/LoadJCAMPModal.js +6 -4
  63. package/lib/component/modal/PredictSpectraModal.js +11 -9
  64. package/lib/component/modal/SaveAsModal.d.ts +3 -4
  65. package/lib/component/modal/SaveAsModal.js +27 -27
  66. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
  67. package/lib/component/modal/editRange/EditRangeModal.js +2 -2
  68. package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
  69. package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
  70. package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
  71. package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
  72. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
  73. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
  74. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
  75. package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
  76. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
  77. package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
  78. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
  79. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
  80. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
  81. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
  82. package/lib/component/modal/editZone/EditZoneModal.js +1 -1
  83. package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
  84. package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
  85. package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
  86. package/lib/component/modal/setting/GeneralSettings.js +7 -4
  87. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +16 -2
  88. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
  89. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +20 -6
  90. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +16 -3
  91. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +14 -10
  92. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
  93. package/lib/component/panels/PeaksPanel/PeaksPanel.js +48 -14
  94. package/lib/component/panels/RangesPanel/RangesHeader.js +73 -13
  95. package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
  96. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +49 -8
  97. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
  98. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  99. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +1 -1
  100. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +1 -1
  101. package/lib/component/panels/SummaryPanel/SummaryPanel.js +28 -18
  102. package/lib/component/panels/ZonesPanel/ZonesPanel.js +28 -4
  103. package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
  104. package/lib/component/panels/databasePanel/DatabaseSearchOptions.d.ts +3 -3
  105. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +4 -4
  106. package/lib/component/panels/filtersPanel/FilterPanel.js +6 -4
  107. package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
  108. package/lib/component/panels/header/DefaultPanelHeader.d.ts +10 -6
  109. package/lib/component/panels/header/DefaultPanelHeader.js +26 -10
  110. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
  111. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
  112. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
  113. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +36 -7
  114. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
  115. package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
  116. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
  117. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +5 -1
  118. package/lib/component/reducer/Reducer.d.ts +2 -2
  119. package/lib/component/reducer/Reducer.js +23 -16
  120. package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
  121. package/lib/component/reducer/actions/FiltersActions.js +243 -91
  122. package/lib/component/reducer/actions/IntegralsActions.d.ts +1 -1
  123. package/lib/component/reducer/actions/IntegralsActions.js +2 -2
  124. package/lib/component/reducer/actions/MoleculeActions.js +0 -1
  125. package/lib/component/reducer/actions/RangesActions.js +16 -6
  126. package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
  127. package/lib/component/reducer/actions/ToolsActions.js +75 -14
  128. package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
  129. package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
  130. package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
  131. package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
  132. package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
  133. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
  134. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
  135. package/lib/component/toolbar/ToolBar.js +241 -8
  136. package/lib/component/toolbar/toolbarMenu.d.ts +4 -0
  137. package/lib/component/toolbar/toolbarMenu.js +77 -0
  138. package/lib/component/utility/Events.d.ts +11 -0
  139. package/lib/component/utility/Events.js +22 -0
  140. package/lib/component/utility/booleanToString.d.ts +6 -0
  141. package/lib/component/utility/booleanToString.js +4 -0
  142. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
  143. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
  144. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
  145. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
  146. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  147. package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
  148. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
  149. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
  150. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
  151. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
  152. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
  153. package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
  154. package/lib/data/data2d/Spectrum2D/contours.js +3 -3
  155. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  156. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  157. package/lib/data/getDefaultMatrixFilters.js +2 -2
  158. package/lib/data/matrixGeneration.js +1 -1
  159. package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
  160. package/lib/versionInfo.js +1 -1
  161. package/package.json +31 -30
  162. package/lib/component/elements/DeleteButton.d.ts +0 -6
  163. package/lib/component/elements/DeleteButton.js +0 -8
  164. package/lib/component/elements/DropdownMenu.d.ts +0 -9
  165. package/lib/component/elements/DropdownMenu.js +0 -7
  166. package/lib/component/elements/FilterButton.d.ts +0 -6
  167. package/lib/component/elements/FilterButton.js +0 -8
  168. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
  169. package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
  170. package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
  171. package/lib/component/elements/popup/Alert/Context.js +0 -10
  172. package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
  173. package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
  174. package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
  175. package/lib/component/elements/popup/Alert/Provider.js +0 -127
  176. package/lib/component/elements/popup/Alert/index.d.ts +0 -3
  177. package/lib/component/elements/popup/Alert/index.js +0 -3
  178. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
  179. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
  180. package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
  181. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
  182. package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
  183. package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
  184. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
  185. package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
  186. package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
  187. package/lib/component/modal/metaImportation/index.d.ts +0 -2
  188. package/lib/component/modal/metaImportation/index.js +0 -17
  189. package/lib/component/panels/PeaksPanel/PeaksToggleActions.d.ts +0 -12
  190. package/lib/component/panels/PeaksPanel/PeaksToggleActions.js +0 -7
  191. package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
  192. package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
  193. package/lib/component/toolbar/BasicToolBar.d.ts +0 -1
  194. package/lib/component/toolbar/BasicToolBar.js +0 -165
  195. package/lib/component/toolbar/FunctionToolBar.d.ts +0 -3
  196. package/lib/component/toolbar/FunctionToolBar.js +0 -148
package/README.md CHANGED
@@ -92,13 +92,13 @@ npm start
92
92
 
93
93
  ## Funding
94
94
 
95
- | | |
96
- | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
97
- | <img src="images/zakodium.svg" width="200"> | [Zakodium sàrl](https://www.zakodium.com) |
98
- | <img src="images/idnmr.png" height="80"> | [Initiative zur Verbesserung der NMR-Datenqualität (IDNMR)](https://idnmr.uni-koeln.de/) |
99
- | <img src="images/nfdi4chem.png" width="200"> | [NFDI4Chem Chemistry Consortium in the NFDI](https://www.nfdi4chem.de/) |
100
- | <img src="images/univalle.svg" height="100"> | [Universidad del Valle / Cali, Colombia](https://darmn.correounivalle.edu.co/) |
101
- | <img src="images/bigmap.jpg" height="100"> | [Union’s Horizon 2020 research and innovation programme under grant agreement No 957189](https://www.big-map.eu/European) |
95
+ | | |
96
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
97
+ | <img src="images/zakodium.svg" width="200"> | [Zakodium sàrl](https://www.zakodium.com) |
98
+ | <img src="images/idnmr.png" height="80"> | [Initiative zur Verbesserung der NMR-Datenqualität (IDNMR)](https://idnmr.uni-koeln.de/) |
99
+ | <img src="images/nfdi4chem.png" width="200"> | [NFDI4Chem Chemistry Consortium in the NFDI](https://www.nfdi4chem.de/) |
100
+ | <img src="images/univalle.svg" height="100"> | [Universidad del Valle / Cali, Colombia](https://darmn.correounivalle.edu.co/) |
101
+ | <img src="images/bigmap.jpg" height="100"> | This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 957189. The project is part of BATTERY 2030+, the large-scale European research initiative for inventing the sustainable batteries of the future. |
102
102
 
103
103
  ## License
104
104
 
@@ -22,6 +22,6 @@ function Chart1D({ mode, width, height, margin, displayerKey }) {
22
22
  const { current: { general: { spectraRendering }, }, } = usePreferences();
23
23
  const innerWidth = width - margin.left - margin.right;
24
24
  const innerHeight = height - margin.bottom;
25
- return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { id: "nmrSVG", width: width, height: height, viewBox: `0 0 ${width} ${height}`, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(Ranges, {}), _jsx(MultiplicityTrees, {}), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx(SimilarityTree, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
25
+ return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { id: "nmrSVG", width: width, height: height, viewBox: `0 0 ${width} ${height}`, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Ranges, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(MultiplicityTrees, {}), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx(SimilarityTree, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
26
26
  }
27
27
  export default Chart1D;
@@ -19,7 +19,7 @@ const style = css `
19
19
  }
20
20
  `;
21
21
  function LinesSeries() {
22
- const { data, displayerKey, xDomains, width, margin, height } = useChartData();
22
+ const { data, displayerKey, xDomains, width, margin, height, toolOptions: { selectedTool }, } = useChartData();
23
23
  const activeSpectra = useActiveSpectra();
24
24
  const { shiftY } = useScaleChecked();
25
25
  const verticalAlign = useVerticalAlign();
@@ -27,7 +27,7 @@ function LinesSeries() {
27
27
  const innerHeight = height - margin.bottom - SPECTRA_BOTTOM_MARGIN;
28
28
  const spectra = (data?.filter((d) => isSpectrum1D(d) && d.display.isVisible && xDomains[d.id]) || []);
29
29
  const { setActiveSpectrum } = useSetActiveSpectrumAction();
30
- return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), verticalAlign === 'stack' && (_jsx("rect", { css: style, y: innerHeight - shiftY * i - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
30
+ return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), verticalAlign === 'stack' && selectedTool === 'zoom' && (_jsx("rect", { css: style, y: innerHeight - shiftY * i - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
31
31
  setActiveSpectrum(e, d.id);
32
32
  }, "data-no-export": "true" }))] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
33
33
  }
@@ -219,19 +219,17 @@ function Viewer1D({ emptyText = undefined }) {
219
219
  payload: { zoomType: ZOOM_TYPES.STEP_HORIZONTAL },
220
220
  });
221
221
  }, [dispatch]);
222
- const handleZoom = useCallback((event) => {
223
- dispatch({ type: 'SET_ZOOM', payload: { event } });
222
+ const handleZoom = useCallback((options) => {
223
+ dispatch({ type: 'SET_ZOOM', payload: { options } });
224
224
  }, [dispatch]);
225
225
  const mouseClick = useCallback((event) => {
226
226
  if (!scaleState.scaleX)
227
227
  return;
228
228
  const xPPM = scaleState.scaleX().invert(event.x);
229
- const propagateEvent = () => {
230
- Events.emit('mouseClick', {
231
- ...event,
232
- xPPM,
233
- });
234
- };
229
+ Events.emit('mouseClick', {
230
+ ...event,
231
+ xPPM,
232
+ });
235
233
  const keyModifiers = getModifiersKey(event);
236
234
  switch (keyModifiers) {
237
235
  case primaryKeyIdentifier: {
@@ -242,9 +240,6 @@ function Viewer1D({ emptyText = undefined }) {
242
240
  payload: event,
243
241
  });
244
242
  break;
245
- case options.editRange.id:
246
- propagateEvent();
247
- break;
248
243
  case options.integral.id:
249
244
  dispatch({
250
245
  type: 'CUT_INTEGRAL',
@@ -4,7 +4,7 @@ import { readFromWebSource } from 'nmr-load-save';
4
4
  import { useCallback, useContext, useEffect, useRef, useState } from 'react';
5
5
  import { useChartData } from '../../context/ChartContext';
6
6
  import { useScaleChecked } from '../../context/ScaleContext';
7
- import { useAlert } from '../../elements/popup/Alert';
7
+ import { useToaster } from '../../context/ToasterContext';
8
8
  import { HighlightEventSource, useHighlightData } from '../../highlight';
9
9
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
10
10
  import { useVerticalAlign } from '../../hooks/useVerticalAlign';
@@ -18,7 +18,7 @@ function DatabaseSpectrum() {
18
18
  const [isLoading, setLoading] = useState(false);
19
19
  const { highlight } = useHighlightData();
20
20
  const { scaleX } = useScaleChecked();
21
- const alert = useAlert();
21
+ const toaster = useToaster();
22
22
  const { color, marginBottom } = usePanelPreferences('database');
23
23
  const { jcampURL: jcampRelativeURL = '', baseURL } = highlight?.sourceData?.extra || {};
24
24
  const getSpinner = useContext(spinnerContext);
@@ -60,7 +60,7 @@ function DatabaseSpectrum() {
60
60
  }
61
61
  catch (error) {
62
62
  reportError(error);
63
- alert.error('Failed to Load spectrum');
63
+ toaster.show({ message: 'Failed to Load spectrum', intent: 'danger' });
64
64
  }
65
65
  }, 250));
66
66
  useEffect(() => {
@@ -1,15 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useChartData } from '../../context/ChartContext';
3
+ import useSpectrum from '../../hooks/useSpectrum';
3
4
  import { PathBuilder } from '../../utility/PathBuilder';
4
5
  import { useScale2DX, getSliceYScale } from '../utilities/scale';
5
6
  function usePath(data, options) {
6
7
  const { height = 100, vericalMargin = 10 } = options;
7
8
  const { mode } = useChartData();
8
9
  const scaleX = useScale2DX();
9
- if (!data)
10
+ const spectrum = useSpectrum();
11
+ if (!data || !spectrum)
10
12
  return '';
11
13
  const { x, re: y } = data;
12
- const scaleY = getSliceYScale(y, height, mode, { margin: vericalMargin });
14
+ const scaleY = getSliceYScale(spectrum.data, height, mode, {
15
+ margin: vericalMargin,
16
+ });
13
17
  const pathBuilder = new PathBuilder();
14
18
  pathBuilder.moveTo(scaleX(x[0]), scaleY(y[0]));
15
19
  for (let i = 1; i < x.length; i++) {
@@ -1,13 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useChartData } from '../../context/ChartContext';
3
+ import useSpectrum from '../../hooks/useSpectrum';
3
4
  import { PathBuilder } from '../../utility/PathBuilder';
4
5
  import { getSliceYScale, useScale2DY } from '../utilities/scale';
5
6
  function usePath(data, props) {
6
7
  const { reverse, width = 100, horizontalMargin = 10 } = props;
7
8
  const { mode } = useChartData();
8
9
  const scaleX = useScale2DY(reverse);
10
+ const spectrum = useSpectrum();
11
+ if (!data || !spectrum) {
12
+ return '';
13
+ }
9
14
  const { x, re: y } = data;
10
- const scaleY = getSliceYScale(y, width, mode, { margin: horizontalMargin });
15
+ const scaleY = getSliceYScale(spectrum.data, width, mode, {
16
+ margin: horizontalMargin,
17
+ });
11
18
  const pathBuilder = new PathBuilder();
12
19
  pathBuilder.moveTo(scaleY(y.at(-1)), scaleX(x.at(-1)));
13
20
  for (let i = x.length - 2; i >= 0; i--) {
@@ -1,29 +1,10 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { getSlice } from '../../../../data/data2d/Spectrum2D';
3
2
  import { useMouseTracker } from '../../../EventsTrackers/MouseTracker';
4
- import { useChartData } from '../../../context/ChartContext';
5
- import { useActiveSpectrum } from '../../../hooks/useActiveSpectrum';
6
- import { useScale2DX, useScale2DY } from '../../utilities/scale';
7
3
  import { SpectrumPhaseTrace } from './SpectrumPhaseTrace';
8
- import { useActivePhaseTraces } from './useActivePhaseTraces';
9
4
  export function PhaseTraceWithMouse() {
10
- const { width, height, data: spectra } = useChartData();
11
- const activeSpectrum = useActiveSpectrum();
12
- const { activeTraceDirection, color } = useActivePhaseTraces();
13
5
  const position = useMouseTracker();
14
- const scale2dX = useScale2DX();
15
- const scale2dY = useScale2DY();
16
- if (!position || !width || !height || !activeSpectrum?.id) {
6
+ if (!position) {
17
7
  return null;
18
8
  }
19
- const spectrum = spectra[activeSpectrum.index];
20
- const sliceData = getSlice(spectrum, {
21
- x: scale2dX.invert(position.x),
22
- y: scale2dY.invert(position.y),
23
- });
24
- const data = sliceData?.[activeTraceDirection]?.data;
25
- if (!data) {
26
- return null;
27
- }
28
- return (_jsx(SpectrumPhaseTrace, { data: data, position: position, color: color, direction: activeTraceDirection }));
9
+ return _jsx(SpectrumPhaseTrace, { positionUnit: "Pixel", position: position });
29
10
  }
@@ -6,7 +6,7 @@ import { SpectraPhaseTraces } from './SpectraPhaseTraces';
6
6
  export function PhaseTraces() {
7
7
  const { width, height, margin, displayerKey } = useChartData();
8
8
  const activeSpectrum = useActiveSpectrum();
9
- if (!activeSpectrum?.id)
9
+ if (!activeSpectrum?.id || !width || !height)
10
10
  return null;
11
11
  const clipWidth = width - margin.left - margin.right;
12
12
  const clipHeight = height - margin.top - margin.bottom;
@@ -1 +1 @@
1
- export declare function SpectraPhaseTraces(): import("@emotion/react/jsx-runtime").JSX.Element[] | null;
1
+ export declare function SpectraPhaseTraces(): import("@emotion/react/jsx-runtime").JSX.Element[];
@@ -3,43 +3,32 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { css } from '@emotion/react';
4
4
  import { useChartData } from '../../../context/ChartContext';
5
5
  import { HighlightEventSource, useHighlight } from '../../../highlight';
6
- import { useScale2DX, useScale2DY } from '../../utilities/scale';
7
6
  import { SpectrumPhaseTrace } from './SpectrumPhaseTrace';
8
7
  import { useActivePhaseTraces } from './useActivePhaseTraces';
9
8
  const BOX_SIZE = 20;
10
9
  const style = css `
11
- .target {
12
- fill: transparent;
13
- }
10
+ fill: transparent;
14
11
 
15
12
  &:hover {
16
- .target {
17
- fill: #ff6f0057;
18
- }
13
+ fill: #ff6f0057;
19
14
  }
20
15
  `;
21
16
  export function SpectraPhaseTraces() {
22
- const { width, height } = useChartData();
23
17
  const { spectra = [], color, activeTraceDirection } = useActivePhaseTraces();
24
- if (!width || !height || spectra.length === 0) {
25
- return null;
26
- }
27
18
  return spectra.map((spectrumTrace) => {
28
19
  return (_jsx(PhaseTrace, { spectrum: spectrumTrace, color: color, direction: activeTraceDirection }, spectrumTrace.id));
29
20
  });
30
21
  }
31
22
  function PhaseTrace(props) {
32
23
  const { width, height, margin } = useChartData();
33
- const { spectrum: { data, x, y, id }, color, direction, } = props;
24
+ const { spectrum: { x, y, id }, direction, } = props;
34
25
  const highligh = useHighlight([id], {
35
26
  type: HighlightEventSource.PHASE_CORRECTION_TRACE,
36
27
  extra: { id },
37
28
  });
38
- const scale2dX = useScale2DX();
39
- const scale2dY = useScale2DY();
40
- const innerheight = height - margin.top - margin.bottom;
29
+ const innerHeight = height - margin.top - margin.bottom;
41
30
  const innerWidth = width - margin.left - margin.right;
42
- const transformY = innerheight - BOX_SIZE / 2;
31
+ const transformY = innerHeight - BOX_SIZE / 2;
43
32
  const transformX = innerWidth - BOX_SIZE / 2;
44
- return (_jsxs(SpectrumPhaseTrace, { data: data, position: { x: scale2dX(x), y: scale2dY(y) }, color: color, direction: direction, ...highligh.onHover, css: style, children: [direction === 'horizontal' && (_jsx("rect", { className: "target", y: transformY, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px` })), direction === 'vertical' && (_jsx("rect", { className: "target", y: margin.top, x: transformX, width: `${BOX_SIZE}px`, height: innerheight }))] }));
33
+ return (_jsxs(SpectrumPhaseTrace, { positionUnit: "PPM", position: { x, y }, ...highligh.onHover, children: [direction === 'horizontal' && (_jsx("rect", { css: style, y: transformY, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px` })), direction === 'vertical' && (_jsx("rect", { css: style, y: margin.top, x: transformX, width: `${BOX_SIZE}px`, height: innerHeight }))] }));
45
34
  }
@@ -1,17 +1,13 @@
1
1
  import { ReactNode } from 'react';
2
- import { TraceDirection } from '../../../reducer/Reducer';
3
- interface SpectrumPhaseTraceProps extends React.SVGAttributes<SVGGElement> {
4
- data: {
5
- x: Float64Array;
6
- re: Float64Array;
7
- };
2
+ interface BaseComponentProps extends React.SVGAttributes<SVGGElement> {
3
+ children?: ReactNode;
4
+ }
5
+ interface SpectrumPhaseTraceProps extends BaseComponentProps {
6
+ positionUnit: 'PPM' | 'Pixel';
8
7
  position: {
9
8
  x: number;
10
9
  y: number;
11
10
  };
12
- color: string;
13
- direction: TraceDirection;
14
- children?: ReactNode;
15
11
  }
16
- export declare function SpectrumPhaseTrace(props: SpectrumPhaseTraceProps): import("react/jsx-runtime").JSX.Element;
12
+ export declare function SpectrumPhaseTrace(props: SpectrumPhaseTraceProps): import("react/jsx-runtime").JSX.Element | null;
17
13
  export {};
@@ -1,14 +1,21 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Filters } from 'nmr-processing';
3
+ import { getSlice } from '../../../../data/data2d/Spectrum2D';
2
4
  import { useChartData } from '../../../context/ChartContext';
5
+ import { useActiveSpectrum } from '../../../hooks/useActiveSpectrum';
6
+ import useSpectrum from '../../../hooks/useSpectrum';
3
7
  import { PathBuilder } from '../../../utility/PathBuilder';
4
- import { get2DXScale, get2DYScale, getSliceYScale, } from '../../utilities/scale';
8
+ import { get2DXScale, get2DYScale, getSliceYScale, useScale2DX, useScale2DY, } from '../../utilities/scale';
5
9
  import { useActivePhaseTraces } from './useActivePhaseTraces';
6
10
  function usePath(x, y, direction) {
7
11
  const { width, margin, height, xDomain, yDomain, mode } = useChartData();
8
12
  const { scaleRatio } = useActivePhaseTraces();
13
+ const spectrum = useSpectrum();
14
+ if (!spectrum)
15
+ return '';
9
16
  if (direction === 'horizontal') {
10
17
  const scaleX = get2DXScale({ margin, width, xDomain, mode });
11
- const scaleY = getSliceYScale(y, height, 'RTL', {
18
+ const scaleY = getSliceYScale(spectrum.data, height, 'RTL', {
12
19
  margin: margin.top + margin.bottom,
13
20
  scaleRatio,
14
21
  });
@@ -20,7 +27,7 @@ function usePath(x, y, direction) {
20
27
  return pathBuilder.toString();
21
28
  }
22
29
  const scaleX = get2DYScale({ margin, height, yDomain });
23
- const scaleY = getSliceYScale(y, width, 'RTL', {
30
+ const scaleY = getSliceYScale(spectrum.data, width, 'RTL', {
24
31
  margin: margin.left + margin.right,
25
32
  scaleRatio,
26
33
  });
@@ -32,15 +39,57 @@ function usePath(x, y, direction) {
32
39
  return pathBuilder.toString();
33
40
  }
34
41
  export function SpectrumPhaseTrace(props) {
35
- const { data, position, color, direction, children, ...othersProps } = props;
36
- const { width, margin, height } = useChartData();
37
- const { x, re } = data;
38
- const path = usePath(x, re, direction);
39
- const innerheight = height - margin.top - margin.bottom;
42
+ const { positionUnit, position, children, ...otherProps } = props;
43
+ const { tempData, width, margin, height } = useChartData();
44
+ const { activeTraceDirection: direction } = useActivePhaseTraces();
45
+ const scale2dX = useScale2DX();
46
+ const scale2dY = useScale2DY();
47
+ const activeSpectrum = useActiveSpectrum();
48
+ if (!activeSpectrum?.id) {
49
+ return null;
50
+ }
51
+ const spectrumBeforePhasing = tempData[activeSpectrum.index];
52
+ let positionInPixel;
53
+ let positionInPPM;
54
+ if (positionUnit === 'Pixel') {
55
+ positionInPixel = position;
56
+ positionInPPM = {
57
+ x: scale2dX.invert(position.x),
58
+ y: scale2dY.invert(position.y),
59
+ };
60
+ }
61
+ else {
62
+ positionInPixel = {
63
+ x: scale2dX(position.x),
64
+ y: scale2dY(position.y),
65
+ };
66
+ positionInPPM = position;
67
+ }
68
+ const sliceData = getSlice(spectrumBeforePhasing, positionInPPM, {
69
+ sliceType: 'both',
70
+ });
71
+ const data = sliceData?.[direction]?.data;
72
+ if (!data) {
73
+ return null;
74
+ }
75
+ const innerHeight = height - margin.top - margin.bottom;
40
76
  const innerWidth = width - margin.left - margin.right;
41
- const translateY = direction === 'horizontal' ? position.y - innerheight : 0;
42
- const translateX = direction === 'vertical' ? position.x - innerWidth : 0;
43
- return (_jsxs("g", { style: {
44
- transform: `translate(${translateX}px,${translateY}px) `,
45
- }, ...othersProps, children: [_jsx("path", { className: "line", stroke: color, strokeWidth: "1", fill: "transparent", d: path, pointerEvents: "none" }), children] }));
77
+ const translateY = direction === 'horizontal' ? positionInPixel.y - innerHeight : 0;
78
+ const translateX = direction === 'vertical' ? positionInPixel.x - innerWidth : 0;
79
+ return (_jsx(InnerSpectrumPhaseTrace, { transform: `translate(${translateX} ${translateY})`, ...otherProps, data: data, children: children }));
80
+ }
81
+ function InnerSpectrumPhaseTrace(props) {
82
+ const { data: dataBeforePhasing, children, ...othersProps } = props;
83
+ const { color, activeTraceDirection: direction, ph0, ph1, } = useActivePhaseTraces();
84
+ const spectrum = {
85
+ data: dataBeforePhasing,
86
+ info: { isComplex: true, isFid: false },
87
+ };
88
+ Filters.phaseCorrection.apply(spectrum, {
89
+ ph0,
90
+ ph1,
91
+ });
92
+ const { x, re } = spectrum.data;
93
+ const path = usePath(x, re, direction);
94
+ return (_jsxs("g", { ...othersProps, children: [_jsx("path", { className: "line", stroke: color, strokeWidth: "1", fill: "transparent", d: path, pointerEvents: "none" }), children] }));
46
95
  }
@@ -1,6 +1,7 @@
1
1
  export declare function useActivePhaseTraces(): {
2
2
  activeTraceDirection: import("../../../reducer/Reducer").TraceDirection;
3
3
  color: string;
4
+ addTracesToBothDirections: boolean;
4
5
  spectra: import("../../../reducer/Reducer").SpectrumTrace[];
5
6
  ph0: number;
6
7
  ph1: number;
@@ -1,11 +1,12 @@
1
1
  import { COLORS } from '../../../../data/utilities/generateColor';
2
2
  import { useChartData } from '../../../context/ChartContext';
3
3
  export function useActivePhaseTraces() {
4
- const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces, activeTraceDirection }, }, }, } = useChartData();
4
+ const { toolOptions: { data: { twoDimensionPhaseCorrection: { traces, activeTraceDirection, addTracesToBothDirections, }, }, }, } = useChartData();
5
5
  const color = activeTraceDirection === 'horizontal' ? COLORS[0] : COLORS[1];
6
6
  return {
7
7
  ...traces[activeTraceDirection],
8
8
  activeTraceDirection,
9
9
  color,
10
+ addTracesToBothDirections,
10
11
  };
11
12
  }
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect, useMemo, useRef } from 'react';
3
3
  import { ResponsiveChart } from 'react-d3-utils';
4
- import { assert } from 'react-science/ui';
5
4
  import BrushXY, { BRUSH_TYPE } from '../1d-2d/tools/BrushXY';
6
5
  import CrossLinePointer from '../1d-2d/tools/CrossLinePointer';
7
6
  import { BrushTracker, } from '../EventsTrackers/BrushTracker';
@@ -27,18 +26,18 @@ function Viewer2D({ emptyText = undefined }) {
27
26
  const { getModifiersKey, primaryKeyIdentifier } = useMapKeyModifiers();
28
27
  const spectrumData = useMemo(() => {
29
28
  const nuclei = activeTab.split(',');
30
- return nuclei
31
- .map((nucleus) => {
29
+ const traces = [];
30
+ for (const nucleus of nuclei) {
32
31
  const spectra = activeSpectra[nucleus];
33
32
  if (spectra?.length === 1) {
34
33
  const id = spectra[0].id;
35
- const spectrum = data.find((datum) => datum.id === id && !datum.info.isFid);
36
- assert(spectrum, `Spectrum with id ${id} not found`);
37
- return spectrum;
34
+ const spectrum = data.find((datum) => datum.id === id && !datum.info.isFid && datum.info.dimension === 1);
35
+ if (spectrum) {
36
+ traces.push(spectrum);
37
+ }
38
38
  }
39
- return null;
40
- })
41
- .filter((d) => d !== null);
39
+ }
40
+ return traces;
42
41
  }, [activeTab, data, activeSpectra]);
43
42
  const DIMENSION = get2DDimensionLayout(state);
44
43
  function handelBrush(brushData) {
@@ -109,16 +108,18 @@ function Viewer2D({ emptyText = undefined }) {
109
108
  dispatch({ type: 'FULL_ZOOM_OUT', payload: { trackID } });
110
109
  }
111
110
  }, [DIMENSION, dispatch]);
112
- const handleZoom = (event) => {
113
- const { x: startX, y: startY, shiftKey } = event;
111
+ const handleZoom = (options) => {
112
+ const { x: startX, y: startY, shiftKey } = options;
114
113
  const trackID = getLayoutID(DIMENSION, { startX, startY });
115
114
  if (trackID) {
116
- if (trackID !== 'CENTER_2D' ||
117
- (selectedTool === 'phaseCorrectionTwoDimensions' && !shiftKey)) {
118
- dispatch({ type: 'SET_ZOOM', payload: { event, trackID } });
115
+ const isZoomWithScroll = trackID === 'CENTER_2D' && shiftKey && selectedTool === 'zoom';
116
+ const isMouseOver1DTrace = trackID !== 'CENTER_2D';
117
+ const isTraceZoomActive = selectedTool === 'phaseCorrectionTwoDimensions' && !shiftKey;
118
+ if (isZoomWithScroll || isMouseOver1DTrace || isTraceZoomActive) {
119
+ dispatch({ type: 'SET_ZOOM', payload: { options, trackID } });
119
120
  }
120
121
  else {
121
- dispatch({ type: 'SET_2D_LEVEL', payload: event });
122
+ dispatch({ type: 'SET_2D_LEVEL', payload: { options } });
122
123
  }
123
124
  }
124
125
  };
@@ -5,7 +5,7 @@ import { memo, useMemo, useRef } from 'react';
5
5
  import { drawContours, getDefaultContoursLevel, } from '../../../data/data2d/Spectrum2D/contours';
6
6
  import { useChartData } from '../../context/ChartContext';
7
7
  import { usePreferences } from '../../context/PreferencesContext';
8
- import { useAlert } from '../../elements/popup/Alert';
8
+ import { useToaster } from '../../context/ToasterContext';
9
9
  import { useActiveSpectrum } from '../../hooks/useActiveSpectrum';
10
10
  import { PathBuilder } from '../../utility/PathBuilder';
11
11
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
@@ -53,9 +53,12 @@ function ContoursPaths({ id: spectrumID, sign, color, spectrum, onTimeout, }) {
53
53
  return (_jsx("path", { fill: "none", "data-testid": "spectrum-line", stroke: color, strokeWidth: "1", opacity: opacity, d: path }));
54
54
  }
55
55
  function ContoursInner({ spectra, displayerKey }) {
56
- const alert = useAlert();
56
+ const toaster = useToaster();
57
57
  const debounceAlert = useRef(debounce(() => {
58
- alert.error('Too many contour lines, only showing the first ones');
58
+ toaster.show({
59
+ message: 'Too many contour lines, only showing the first ones',
60
+ intent: 'danger',
61
+ });
59
62
  }, 2000));
60
63
  function timeoutHandler() {
61
64
  debounceAlert.current();
@@ -1,3 +1,4 @@
1
+ import { NmrData2D } from 'cheminfo-types';
1
2
  import { Margin, SpectraDirection } from '../../reducer/Reducer';
2
3
  import { Layout } from './DimensionLayout';
3
4
  interface Scale2DXOptions {
@@ -38,5 +39,5 @@ interface SliceYScaleOptions {
38
39
  margin?: number;
39
40
  scaleRatio?: number;
40
41
  }
41
- declare function getSliceYScale(data: Float64Array, size: number, mode: SpectraDirection, options?: SliceYScaleOptions): import("d3-scale").ScaleLinear<number, number, never>;
42
+ declare function getSliceYScale(data: NmrData2D, size: number, mode: SpectraDirection, options?: SliceYScaleOptions): import("d3-scale").ScaleLinear<number, number, never>;
42
43
  export { get2DXScale, getSliceYScale, get2DYScale, get1DXScale, get1DYScale, useScale2DX, useScale2DY, use1DTraceYScale, };
@@ -1,5 +1,4 @@
1
1
  import { scaleLinear } from 'd3';
2
- import { xMaxValue } from 'ml-spectra-processing';
3
2
  import { useChartData } from '../../context/ChartContext';
4
3
  import { LAYOUT } from './DimensionLayout';
5
4
  function get2DXScale(options, reverse) {
@@ -48,9 +47,20 @@ function use1DTraceYScale(SpectrumId, height, verticalMargin) {
48
47
  const { yDomains } = useChartData();
49
48
  return get1DYScale(yDomains[SpectrumId], height, verticalMargin);
50
49
  }
50
+ function getMax(data) {
51
+ let max;
52
+ for (const key in data) {
53
+ const { minZ, maxZ } = data[key];
54
+ const innerMax = Math.max(Math.abs(minZ), Math.max(maxZ));
55
+ if (max === undefined || max > innerMax) {
56
+ max = innerMax;
57
+ }
58
+ }
59
+ return max;
60
+ }
51
61
  function getSliceYScale(data, size, mode, options = {}) {
52
62
  const { margin = 10, scaleRatio = 1 } = options;
53
- const max = xMaxValue(data);
63
+ const max = getMax(data);
54
64
  size = mode === 'RTL' ? size : size / 2;
55
65
  return scaleLinear([0, max * scaleRatio], [
56
66
  size - margin,
@@ -13,13 +13,15 @@ export interface BrushTrackerContext {
13
13
  type MouseButton = 'main' | 'secondary' | 'unknown';
14
14
  export declare const BrushContext: import("react").Context<BrushTrackerContext>;
15
15
  export declare function useBrushTracker(): BrushTrackerContext;
16
- interface Position {
16
+ export interface Position {
17
17
  x: number;
18
18
  y: number;
19
19
  }
20
- export type OnClick = (element: React.MouseEvent & Position) => void;
20
+ export type ClickOptions = React.MouseEvent & Position;
21
+ export type OnClick = (element: ClickOptions) => void;
21
22
  export type { OnClick as OnDoubleClick };
22
- export type OnZoom = (event: Pick<React.WheelEvent, 'deltaY' | 'shiftKey' | 'deltaMode'> & Position) => void;
23
+ export type ZoomOptions = Pick<React.WheelEvent, 'deltaY' | 'shiftKey' | 'deltaMode' | 'altKey'> & Position;
24
+ export type OnZoom = (options: ZoomOptions) => void;
23
25
  export type OnBrush = (state: BrushTrackerContext) => void;
24
26
  interface BrushTrackerProps {
25
27
  children: ReactNode;
@@ -104,8 +104,8 @@ export function BrushTracker({ children, className, style, onBrushEnd, onBrush,
104
104
  const boundingRect = event.currentTarget.getBoundingClientRect();
105
105
  const x = event.clientX - boundingRect.x;
106
106
  const y = event.clientY - boundingRect.y;
107
- const { deltaY, deltaX, shiftKey, deltaMode } = event;
108
- onZoom({ deltaY: deltaY || deltaX, shiftKey, deltaMode, x, y });
107
+ const { deltaY, deltaX, shiftKey, altKey, deltaMode } = event;
108
+ onZoom({ deltaY: deltaY || deltaX, shiftKey, altKey, deltaMode, x, y });
109
109
  }, [onZoom]);
110
110
  useEffect(() => {
111
111
  const { step, startX, endX, startY, endY } = state;
@@ -2,5 +2,5 @@ import { RefObject } from 'react';
2
2
  interface KeysListenerTrackerProps {
3
3
  mainDivRef: RefObject<HTMLDivElement>;
4
4
  }
5
- declare function KeysListenerTracker(props: KeysListenerTrackerProps): null;
5
+ declare function KeysListenerTracker(props: KeysListenerTrackerProps): import("react/jsx-runtime").JSX.Element;
6
6
  export default KeysListenerTracker;