nmrium 0.45.1-pre.1701344673 → 0.46.1

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 (91) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/Viewer1D.js +4 -21
  3. package/lib/component/1d/tool/PeakPointer.js +6 -16
  4. package/lib/component/1d/utilities/scale.js +13 -8
  5. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +15 -4
  6. package/lib/component/2d/1d-tracer/Top1DChart.js +1 -1
  7. package/lib/component/2d/zones/Signal.js +1 -1
  8. package/lib/component/2d/zones/Zone.js +1 -1
  9. package/lib/component/elements/ContextMenuBluePrint.d.ts +16 -0
  10. package/lib/component/elements/ContextMenuBluePrint.js +20 -0
  11. package/lib/component/elements/DropdownMenu.d.ts +9 -0
  12. package/lib/component/elements/DropdownMenu.js +7 -0
  13. package/lib/component/elements/Header.d.ts +1 -1
  14. package/lib/component/elements/Header.js +5 -7
  15. package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +2 -2
  16. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +2 -2
  17. package/lib/component/elements/ReactTable/ReactTable.d.ts +5 -5
  18. package/lib/component/header/Header.js +3 -4
  19. package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -1
  20. package/lib/component/hooks/useToolsFunctions.js +2 -2
  21. package/lib/component/modal/MoleculeStructureEditorModal.d.ts +0 -8
  22. package/lib/component/modal/MoleculeStructureEditorModal.js +31 -8
  23. package/lib/component/modal/MultipletAnalysisModal.js +1 -1
  24. package/lib/component/modal/PredictSpectraModal.js +3 -2
  25. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -5
  26. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +1 -0
  27. package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +4 -1
  28. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  29. package/lib/component/modal/setting/GeneralSettings.js +1 -1
  30. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  31. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +1 -1
  32. package/lib/component/modal/setting/settingsValidation.js +3 -1
  33. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +1 -1
  34. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +7 -14
  35. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  36. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -2
  37. package/lib/component/panels/RangesPanel/RangesTable.d.ts +2 -2
  38. package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +2 -2
  39. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
  40. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +12 -17
  41. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/MoveLink.js +1 -1
  42. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  43. package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -2
  44. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +2 -2
  45. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  46. package/lib/component/panels/extra/preferences/ColumnsHelper.js +1 -2
  47. package/lib/component/panels/filtersPanel/FiltersTable.js +1 -1
  48. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +6 -2
  49. package/lib/component/reducer/actions/MoleculeActions.d.ts +4 -1
  50. package/lib/component/reducer/actions/MoleculeActions.js +6 -2
  51. package/lib/component/reducer/actions/PeaksActions.js +4 -3
  52. package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.d.ts +3 -0
  53. package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.js +24 -0
  54. package/lib/component/reducer/helper/Zoom1DManager.js +1 -1
  55. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -1
  56. package/lib/component/toolbar/BasicToolBar.js +54 -35
  57. package/lib/component/toolbar/FunctionToolBar.js +102 -9
  58. package/lib/component/toolbar/ToolBar.js +1 -1
  59. package/lib/component/utility/getClosePeak.d.ts +10 -0
  60. package/lib/component/utility/getClosePeak.js +15 -0
  61. package/lib/component/utility/maxAbsoluteValue.d.ts +3 -0
  62. package/lib/component/utility/maxAbsoluteValue.js +21 -0
  63. package/lib/data/constants/Multiplets.js +1 -1
  64. package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
  65. package/lib/data/data1d/Spectrum1D/index.js +0 -1
  66. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
  67. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -1
  68. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -1
  69. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +1 -1
  70. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +6 -3
  71. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  72. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +6 -1
  73. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +106 -19
  74. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +1 -0
  75. package/lib/data/data2d/Spectrum2D/contours.js +2 -2
  76. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  77. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  78. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  79. package/lib/data/parseMeta/mapErrors.js +3 -1
  80. package/lib/versionInfo.js +1 -1
  81. package/package.json +41 -40
  82. package/lib/component/elements/ToolbarMenu.d.ts +0 -18
  83. package/lib/component/elements/ToolbarMenu.js +0 -102
  84. package/lib/component/elements/toggle/ToggleButton.d.ts +0 -13
  85. package/lib/component/elements/toggle/ToggleButton.js +0 -24
  86. package/lib/component/elements/toggle/ToggleButtonGroup.d.ts +0 -8
  87. package/lib/component/elements/toggle/ToggleButtonGroup.js +0 -48
  88. package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.d.ts +0 -17
  89. package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.js +0 -18
  90. package/lib/data/data2d/Processing2D.d.ts +0 -32
  91. package/lib/data/data2d/Processing2D.js +0 -130
@@ -1,11 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { SvgNmrRealImag, SvgNmrOverlay3, SvgNmrOverlay3Aligned, SvgNmrAlignBottom, SvgNmrAlignCenter, } from 'cheminfo-font';
3
3
  import { Fragment, useCallback, memo } from 'react';
4
4
  import { FaDownload, FaFileDownload, FaFileImage, FaCopy, FaFileExport, FaFile, FaFileImport, } from 'react-icons/fa';
5
5
  import { Toolbar, useOnOff } from 'react-science/ui';
6
6
  import { useChartData } from '../context/ChartContext';
7
7
  import { useLoader } from '../context/LoaderContext';
8
- import ToolbarMenu from '../elements/ToolbarMenu';
8
+ import { DropdownMenu } from '../elements/DropdownMenu';
9
9
  import { useModal } from '../elements/popup/Modal';
10
10
  import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
11
11
  import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
@@ -15,59 +15,80 @@ import useToolsFunctions from '../hooks/useToolsFunctions';
15
15
  import { useVerticalAlign } from '../hooks/useVerticalAlign';
16
16
  import ImportPublicationStringModal from '../modal/ImportPublicationStringModal';
17
17
  import { LoadJCAMPModal } from '../modal/LoadJCAMPModal';
18
- import { useMetaInformationImportationModal } from '../modal/metaImportation/index';
18
+ import { useMetaInformationImportationModal } from '../modal/metaImportation';
19
+ import { options } from './ToolTypes';
19
20
  const IMPORT_MENU = [
20
21
  {
21
- id: 'importFile',
22
22
  icon: _jsx(FaFile, {}),
23
- label: 'Import from file system (Press Ctrl + O)',
23
+ text: 'Import from file system (Press Ctrl + O)',
24
+ data: {
25
+ id: 'importFile',
26
+ },
24
27
  },
25
28
  {
26
- id: 'importJDX',
27
29
  icon: _jsx(FaFile, {}),
28
- label: 'Add JCAMP-DX from URL',
30
+ text: 'Add JCAMP-DX from URL',
31
+ data: {
32
+ id: 'importJDX',
33
+ },
29
34
  },
30
35
  {
31
- id: 'importPublicationString',
32
36
  icon: _jsx(FaFile, {}),
33
- label: 'Import from publication string',
37
+ text: 'Import from publication string',
38
+ data: {
39
+ id: 'importPublicationString',
40
+ },
34
41
  },
35
42
  {
36
- id: 'importMetaInformation',
37
43
  icon: _jsx(FaFile, {}),
38
- label: 'Import meta information',
44
+ text: 'Import meta information',
45
+ data: {
46
+ id: 'importMetaInformation',
47
+ },
39
48
  },
40
49
  ];
41
50
  const EXPORT_MENU = [
42
51
  {
43
- id: 'svg',
44
52
  icon: _jsx(FaDownload, {}),
45
- label: 'Export as SVG',
53
+ text: 'Export as SVG',
54
+ data: {
55
+ id: 'svg',
56
+ },
46
57
  },
47
58
  {
48
- id: 'png',
49
59
  icon: _jsx(FaFileImage, {}),
50
- label: 'Export as PNG',
60
+ text: 'Export as PNG',
61
+ data: {
62
+ id: 'png',
63
+ },
51
64
  },
52
65
  {
53
- id: 'json',
54
66
  icon: _jsx(FaFileDownload, {}),
55
- label: 'Save data ( Press Ctrl + S )',
67
+ text: 'Save data ( Press Ctrl + S )',
68
+ data: {
69
+ id: 'json',
70
+ },
56
71
  },
57
72
  {
58
- id: 'advance_save',
59
73
  icon: _jsx(FaFileDownload, {}),
60
- label: 'Save data as ( Press Ctrl + Shift + S )',
74
+ text: 'Save data as ( Press Ctrl + Shift + S )',
75
+ data: {
76
+ id: 'advance_save',
77
+ },
61
78
  },
62
79
  {
63
- id: 'nmre',
64
80
  icon: _jsx(FaFileDownload, {}),
65
- label: 'Save NMRE data',
81
+ text: 'Save NMRE data',
82
+ data: {
83
+ id: 'nmre',
84
+ },
66
85
  },
67
86
  {
68
- id: 'copy',
69
87
  icon: _jsx(FaCopy, {}),
70
- label: 'Copy image to Clipboard ( Press Ctrl + C )',
88
+ text: 'Copy image to Clipboard ( Press Ctrl + C )',
89
+ data: {
90
+ id: 'copy',
91
+ },
71
92
  },
72
93
  ];
73
94
  function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
@@ -91,8 +112,8 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
91
112
  const openImportPublicationStringModal = useCallback(() => {
92
113
  modal.show(_jsx(ImportPublicationStringModal, { onClose: () => modal.close() }), {});
93
114
  }, [modal]);
94
- const importHandler = useCallback(({ id }) => {
95
- switch (id) {
115
+ const importHandler = useCallback((data) => {
116
+ switch (data?.id) {
96
117
  case 'importFile':
97
118
  openLoader();
98
119
  break;
@@ -113,8 +134,8 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
113
134
  openImportPublicationStringModal,
114
135
  openMetaInformationModal,
115
136
  ]);
116
- const exportHandler = useCallback(({ id }) => {
117
- switch (id) {
137
+ const exportHandler = useCallback((data) => {
138
+ switch (data?.id) {
118
139
  case 'svg':
119
140
  void saveAsSVGHandler();
120
141
  break;
@@ -140,16 +161,14 @@ function BasicToolBarInner({ verticalAlign, ftCounter, fidCounter, }) {
140
161
  saveAsHandler,
141
162
  saveToClipboardHandler,
142
163
  ]);
143
- return (_jsxs(Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadModalOpened, onCloseDialog: closeLoadModal }), isButtonVisible('import') && (_jsx(ToolbarMenu, { component: _jsx(FaFileImport, {}), toolTip: "Import", onClick: (element) => {
144
- importHandler(element);
145
- return null;
146
- }, items: importMenu })), isButtonVisible('exportAs') && (_jsx(ToolbarMenu, { component: _jsx(FaFileExport, {}), toolTip: "Export As", onClick: (element) => {
147
- exportHandler(element);
148
- return null;
149
- }, items: exportMenu })), isButtonVisible('spectraStackAlignments') && ftCounter > 1 && (_jsx(Toolbar.Item, { id: "spectra-alignment", className: "cheminfo", title: "Spectra alignment ( Press s )", onClick: changeDisplayViewModeHandler, children: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})) })), isButtonVisible('realImaginary') && (_jsx(Toolbar.Item, { id: "display", title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary', onClick: changeSpectrumViewHandler, className: "cheminfo", children: _jsx(SvgNmrRealImag, {}) })), isButtonVisible('spectraCenterAlignments') &&
164
+ return (_jsxs(Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: isLoadModalOpened, onCloseDialog: closeLoadModal }), isButtonVisible('import') && (_jsx(DropdownMenu, { placement: "right-start", onSelect: (data) => {
165
+ importHandler(data);
166
+ }, targetTagName: "div", targetProps: { style: { flex: 'none' } }, options: importMenu, children: _jsx(Toolbar.Item, { id: options.import.id, title: options.import.label, icon: _jsx(FaFileImport, {}) }) })), isButtonVisible('exportAs') && (_jsx(DropdownMenu, { onSelect: (data) => {
167
+ exportHandler(data);
168
+ }, placement: "right-start", targetTagName: "div", targetProps: { style: { flex: 'none' } }, options: exportMenu, children: _jsx(Toolbar.Item, { id: options.exportAs.id, title: options.exportAs.label, icon: _jsx(FaFileExport, {}) }) })), isButtonVisible('spectraStackAlignments') && ftCounter > 1 && (_jsx(Toolbar.Item, { id: "spectra-alignment", className: "cheminfo", title: "Spectra alignment ( Press s )", onClick: changeDisplayViewModeHandler, icon: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})) })), isButtonVisible('realImaginary') && (_jsx(Toolbar.Item, { id: "display", title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary', onClick: changeSpectrumViewHandler, className: "cheminfo", icon: _jsx(SvgNmrRealImag, {}) })), isButtonVisible('spectraCenterAlignments') &&
150
169
  (ftCounter > 0 || fidCounter > 0) && (_jsx(Toolbar.Item, { id: "baseline-position", title: verticalAlign === 'bottom'
151
170
  ? 'Baseline center ( Press c )'
152
- : 'Baseline bottom ( Press c )', onClick: alignSpectrumsVerticallyHandler, className: "cheminfo", children: _jsx("div", { style: { fontSize: 24 }, children: verticalAlign === 'bottom' ? (_jsx(SvgNmrAlignCenter, {})) : (_jsx(SvgNmrAlignBottom, {})) }) }))] }));
171
+ : 'Baseline bottom ( Press c )', onClick: alignSpectrumsVerticallyHandler, className: "cheminfo", icon: _jsx(_Fragment, { children: verticalAlign === 'bottom' ? (_jsx(SvgNmrAlignCenter, {})) : (_jsx(SvgNmrAlignBottom, {})) }) }))] }));
153
172
  }
154
173
  const MemoizedBasicToolBar = memo(BasicToolBarInner);
155
174
  export default function BasicToolBar() {
@@ -1,13 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { SvgNmrApodization, SvgNmrBaselineCorrection, SvgNmrFourierTransform, SvgNmrIntegrate, SvgNmrMultipleAnalysis, SvgNmrPeakPicking, SvgNmrPhaseCorrection, SvgNmrRangePicking, SvgNmrZeroFilling, } from 'cheminfo-font';
3
3
  import { useState, useEffect, useCallback, memo } from 'react';
4
4
  import { FaSearchPlus, FaExpand, FaDiceFour } from 'react-icons/fa';
5
5
  import { Toolbar } from 'react-science/ui';
6
6
  import { useChartData } from '../context/ChartContext';
7
7
  import { useDispatch } from '../context/DispatchContext';
8
- import ToggleButton from '../elements/toggle/ToggleButton';
9
- import ToggleButtonGroup from '../elements/toggle/ToggleButtonGroup';
10
- import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
8
+ import { useCheckToolsVisibility, } from '../hooks/useCheckToolsVisibility';
11
9
  import useDatumWithSpectraStatistics from '../hooks/useDatumWithSpectraStatistics';
12
10
  import useToolsFunctions from '../hooks/useToolsFunctions';
13
11
  import { options } from './ToolTypes';
@@ -38,11 +36,106 @@ function FunctionToolBarInner({ defaultValue, ftCounter, }) {
38
36
  type: 'APPLY_FFT_DIMENSION_2_FILTER',
39
37
  });
40
38
  }, [dispatch]);
41
- return (_jsxs(_Fragment, { children: [_jsxs(ToggleButtonGroup, { value: option, onChange: handleChange, children: [isButtonVisible('zoom') && (_jsx(ToggleButton, { value: options.zoom.id, id: options.zoom.id, title: `${options.zoom.label}`, children: _jsx(FaSearchPlus, {}) }, options.zoom.id)), isButtonVisible('zoomOut') && (_jsx(Toolbar.Item, { id: "zoom-out", onClick: handleFullZoomOut, title: "Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )", children: _jsx(FaExpand, {}) })), isButtonVisible('peakPicking') && (_jsx(ToggleButton, { value: options.peakPicking.id, title: `${options.peakPicking.label} ( Press p )`, id: options.peakPicking.id, children: _jsx(SvgNmrPeakPicking, {}) }, options.peakPicking.id)), isButtonVisible('integral') && (_jsx(ToggleButton, { value: options.integral.id, id: options.integral.id, title: `${options.integral.label} ( Press i )`, children: _jsx(SvgNmrIntegrate, {}) }, options.integral.id)), isButtonVisible('zonePicking') && (_jsx(ToggleButton, { value: options.zonePicking.id, id: options.zonePicking.id, title: `${options.zonePicking.label} ( Press r )`, children: _jsx(FaDiceFour, {}) }, options.zonePicking.id)), isButtonVisible('slicing') && (_jsx(ToggleButton, { value: options.slicing.id, id: options.slicing.id, title: `${options.slicing.label}`, children: _jsx("p", { children: "Slic" }) }, options.slicing.id)), isButtonVisible('rangePicking') && (_jsx(ToggleButton, { value: options.rangePicking.id, title: `${options.rangePicking.label} ( Press r )`, id: options.rangePicking.id, children: _jsx(SvgNmrRangePicking, {}) }, options.rangePicking.id)), isButtonVisible('multipleSpectraAnalysis', {
42
- checkSpectrumType: false,
43
- }) &&
44
- ftCounter > 1 && (_jsx(ToggleButton, { value: options.multipleSpectraAnalysis.id, id: options.multipleSpectraAnalysis.id, title: options.multipleSpectraAnalysis.label, children: _jsx(SvgNmrMultipleAnalysis, {}) }, options.multipleSpectraAnalysis.id)), isButtonVisible('apodization') && (_jsx(ToggleButton, { value: options.apodization.id, id: options.apodization.id, title: `${options.apodization.label} (Press a)`, children: _jsx(SvgNmrApodization, {}) }, options.apodization.id)), isButtonVisible('zeroFilling') && (_jsx(ToggleButton, { value: options.zeroFilling.id, id: options.zeroFilling.id, title: `${options.zeroFilling.label} ( Press z )`, children: _jsx(SvgNmrZeroFilling, {}) }, options.zeroFilling.id)), isButtonVisible('phaseCorrection') && (_jsx(ToggleButton, { value: options.phaseCorrection.id, id: options.phaseCorrection.id, title: `${options.phaseCorrection.label} ( Press a )`, children: _jsx(SvgNmrPhaseCorrection, {}) }, options.phaseCorrection.id)), isButtonVisible('phaseCorrectionTwoDimensions') && (_jsx(ToggleButton, { value: options.phaseCorrectionTwoDimensions.id, id: options.phaseCorrectionTwoDimensions.id, title: `${options.phaseCorrectionTwoDimensions.label} ( Press a )`, children: _jsx(SvgNmrPhaseCorrection, {}) }, options.phaseCorrectionTwoDimensions.id)), isButtonVisible('baselineCorrection') && (_jsx(ToggleButton, { value: options.baselineCorrection.id, id: options.baselineCorrection.id, title: `${options.baselineCorrection.label} ( Press b )`, children: _jsx(SvgNmrBaselineCorrection, {}) }, options.baselineCorrection.id)), isButtonVisible('exclusionZones', { checkSpectrumType: false }) &&
45
- ftCounter > 0 && (_jsx(ToggleButton, { value: options.exclusionZones.id, title: `${options.exclusionZones.label} ( Press e )`, id: options.exclusionZones.id, children: _jsx("div", { style: { fontSize: 18 }, children: _jsx(SvgNmrMultipleAnalysis, {}) }) }, options.exclusionZones.id))] }), isButtonVisible('fft') && (_jsx(Toolbar.Item, { id: options.fft.id, className: "cheminfo", title: `${options.fft.label} ( Press t )`, onClick: handleOnFFTFilter, children: _jsx(SvgNmrFourierTransform, {}) })), isButtonVisible('fftDimension1') && (_jsx(Toolbar.Item, { id: options.fftDimension1.id, className: "cheminfo", title: options.fftDimension1.label, onClick: handleFFtDimension1Filter, children: _jsx(SvgNmrFourierTransform, {}) })), isButtonVisible('fftDimension2') && (_jsx(Toolbar.Item, { id: options.fftDimension2.id, className: "cheminfo", title: options.fftDimension2.label, onClick: handleFFtDimension2Filter, children: _jsx(SvgNmrFourierTransform, {}) }))] }));
39
+ const toolItems = [
40
+ {
41
+ id: 'zoom',
42
+ label: options.zoom.label,
43
+ icon: _jsx(FaSearchPlus, {}),
44
+ },
45
+ {
46
+ id: 'zoomOut',
47
+ label: 'Horizontal zoom out ( Press f ), Horizontal and Vertical zoom out, double click ( Press ff )',
48
+ onClick: handleFullZoomOut,
49
+ icon: _jsx(FaExpand, {}),
50
+ },
51
+ {
52
+ id: 'peakPicking',
53
+ label: `${options.peakPicking.label} ( Press p )`,
54
+ icon: _jsx(SvgNmrPeakPicking, {}),
55
+ },
56
+ {
57
+ id: 'integral',
58
+ label: `${options.integral.label} ( Press i )`,
59
+ icon: _jsx(SvgNmrIntegrate, {}),
60
+ },
61
+ {
62
+ id: 'zonePicking',
63
+ label: `${options.zonePicking.label} ( Press r )`,
64
+ icon: _jsx(FaDiceFour, {}),
65
+ },
66
+ {
67
+ id: 'slicing',
68
+ label: options.slicing.label,
69
+ icon: _jsx("p", { children: "Slic" }),
70
+ },
71
+ {
72
+ id: 'rangePicking',
73
+ label: `${options.rangePicking.label} ( Press r )`,
74
+ icon: _jsx(SvgNmrRangePicking, {}),
75
+ },
76
+ {
77
+ id: 'multipleSpectraAnalysis',
78
+ label: options.multipleSpectraAnalysis.label,
79
+ icon: _jsx(SvgNmrMultipleAnalysis, {}),
80
+ checkOptions: { checkSpectrumType: false },
81
+ condition: ftCounter > 1,
82
+ },
83
+ {
84
+ id: 'apodization',
85
+ label: `${options.apodization.label} (Press a)`,
86
+ icon: _jsx(SvgNmrApodization, {}),
87
+ },
88
+ {
89
+ id: 'zeroFilling',
90
+ label: `${options.zeroFilling.label} ( Press z )`,
91
+ icon: _jsx(SvgNmrZeroFilling, {}),
92
+ },
93
+ {
94
+ id: 'phaseCorrection',
95
+ label: `${options.phaseCorrection.label} ( Press a )`,
96
+ icon: _jsx(SvgNmrPhaseCorrection, {}),
97
+ },
98
+ {
99
+ id: 'phaseCorrectionTwoDimensions',
100
+ label: `${options.phaseCorrectionTwoDimensions.label} ( Press a )`,
101
+ icon: _jsx(SvgNmrPhaseCorrection, {}),
102
+ },
103
+ {
104
+ id: 'baselineCorrection',
105
+ label: `${options.baselineCorrection.label} ( Press b )`,
106
+ icon: _jsx(SvgNmrBaselineCorrection, {}),
107
+ },
108
+ {
109
+ id: 'exclusionZones',
110
+ label: `${options.exclusionZones.label} ( Press e )`,
111
+ icon: _jsx(SvgNmrMultipleAnalysis, {}),
112
+ checkOptions: { checkSpectrumType: false },
113
+ condition: ftCounter > 0,
114
+ },
115
+ {
116
+ id: 'fft',
117
+ label: `${options.fft.label} ( Press t )`,
118
+ onClick: handleOnFFTFilter,
119
+ icon: _jsx(SvgNmrFourierTransform, {}),
120
+ },
121
+ {
122
+ id: 'fftDimension1',
123
+ label: options.fftDimension1.label,
124
+ onClick: handleFFtDimension1Filter,
125
+ icon: _jsx(SvgNmrFourierTransform, {}),
126
+ },
127
+ {
128
+ id: 'fftDimension2',
129
+ label: options.fftDimension2.label,
130
+ onClick: handleFFtDimension2Filter,
131
+ icon: _jsx(SvgNmrFourierTransform, {}),
132
+ },
133
+ ];
134
+ return (_jsx(_Fragment, { children: toolItems.map((item) => {
135
+ const { id, icon, label, checkOptions, onClick, condition } = item;
136
+ return (isButtonVisible(id, checkOptions) &&
137
+ (condition === undefined || condition) && (_jsx(Toolbar.Item, { onClick: onClick || (() => handleChange(id)), title: label, id: id, active: option === id, icon: icon }, id)));
138
+ }) }));
46
139
  }
47
140
  const MemoizedFunctionToolBar = memo(FunctionToolBarInner);
48
141
  export default function FunctionToolBar({ defaultValue = options.zoom.id, }) {
@@ -5,7 +5,7 @@ import { useChartData } from '../context/ChartContext';
5
5
  import BasicToolBar from './BasicToolBar';
6
6
  import FunctionToolBar from './FunctionToolBar';
7
7
  function ToolBarInner({ selectedTool }) {
8
- return (_jsxs(Toolbar, { orientation: "vertical", children: [_jsx(FunctionToolBar, { defaultValue: selectedTool }), _jsx(BasicToolBar, {})] }));
8
+ return (_jsxs(Toolbar, { vertical: true, children: [_jsx(FunctionToolBar, { defaultValue: selectedTool }), _jsx(BasicToolBar, {})] }));
9
9
  }
10
10
  const MemoizedToolBar = memo(ToolBarInner);
11
11
  export default function ToolBar() {
@@ -0,0 +1,10 @@
1
+ import { Spectrum1D } from 'nmr-load-save';
2
+ interface PeakPosition {
3
+ x: number;
4
+ y: number;
5
+ }
6
+ export declare function getClosePeak(spectrum: Spectrum1D, lookRange: {
7
+ from: number;
8
+ to: number;
9
+ }): PeakPosition | null;
10
+ export {};
@@ -0,0 +1,15 @@
1
+ import { get1DDataXY } from '../../data/data1d/Spectrum1D';
2
+ import { maxAbsoluteValue } from './maxAbsoluteValue';
3
+ export function getClosePeak(spectrum, lookRange) {
4
+ const { from, to } = lookRange;
5
+ const datum = get1DDataXY(spectrum);
6
+ const maxIndex = datum.x.findIndex((number) => number >= to) - 1;
7
+ const minIndex = datum.x.findIndex((number) => number >= from);
8
+ const yDataRange = datum.y.slice(minIndex, maxIndex);
9
+ if (!yDataRange || yDataRange.length === 0)
10
+ return null;
11
+ const y = maxAbsoluteValue(yDataRange);
12
+ const xIndex = minIndex + yDataRange.indexOf(y);
13
+ const x = datum.x[xIndex];
14
+ return { x, y };
15
+ }
@@ -0,0 +1,3 @@
1
+ import { NumberArray } from 'cheminfo-types';
2
+ import { XGetFromToIndexOptions } from 'ml-spectra-processing';
3
+ export declare function maxAbsoluteValue(array: NumberArray, options?: XGetFromToIndexOptions): number;
@@ -0,0 +1,21 @@
1
+ import { xCheck, xGetFromToIndex, } from 'ml-spectra-processing';
2
+ //This function is an adapted version of the xMaxAbsoluteValue function from ml-spectra-processing. It identifies the maximum absolute value and returns the corresponding maximum value along with its sign
3
+ export function maxAbsoluteValue(array, options = {}) {
4
+ xCheck(array);
5
+ const { fromIndex, toIndex } = xGetFromToIndex(array, options);
6
+ let maxValue = array[fromIndex];
7
+ let sign = 1;
8
+ for (let i = fromIndex + 1; i <= toIndex; i++) {
9
+ if (array[i] >= 0) {
10
+ if (array[i] > maxValue) {
11
+ maxValue = array[i];
12
+ sign = 1;
13
+ }
14
+ }
15
+ else if (-array[i] > maxValue) {
16
+ maxValue = -array[i];
17
+ sign = Math.sign(array[i]);
18
+ }
19
+ }
20
+ return maxValue * sign;
21
+ }
@@ -1,6 +1,6 @@
1
1
  import { MultiplicityPatterns } from 'nmr-processing';
2
2
  export const Multiplets = MultiplicityPatterns.map(({ label, value, acs, multiplicity }) => ({
3
- label: `${label}`,
3
+ label,
4
4
  value: acs || value,
5
5
  multiplicity,
6
6
  }));
@@ -5,7 +5,6 @@ export { initiateDatum1D } from './initiateDatum1D';
5
5
  export { changeIntegralsRelative } from './integrals/changeIntegralsRelative';
6
6
  export { isSpectrum1D } from './isSpectrum1D';
7
7
  export { autoPeakPicking } from './peaks/autoPeakPicking';
8
- export { lookupPeak } from './peaks/lookupPeak';
9
8
  export { optimizePeaks } from './peaks/optimizePeaks';
10
9
  export { addRange } from './ranges/addRange';
11
10
  export { changeRange } from './ranges/changeRange';
@@ -5,7 +5,6 @@ export { initiateDatum1D } from './initiateDatum1D';
5
5
  export { changeIntegralsRelative } from './integrals/changeIntegralsRelative';
6
6
  export { isSpectrum1D } from './isSpectrum1D';
7
7
  export { autoPeakPicking } from './peaks/autoPeakPicking';
8
- export { lookupPeak } from './peaks/lookupPeak';
9
8
  export { optimizePeaks } from './peaks/optimizePeaks';
10
9
  export { addRange } from './ranges/addRange';
11
10
  export { changeRange } from './ranges/changeRange';
@@ -19,9 +19,9 @@ export function initiateDatum1D(spectrum, options = {}) {
19
19
  ...get1DColor(spectrum, usedColors),
20
20
  };
21
21
  spectrumObj.info = {
22
- nucleus: '1H',
22
+ nucleus: '1H', // 1H, 13C, 19F, ...
23
23
  isFid: false,
24
- isComplex: false,
24
+ isComplex: false, // if isComplex is true that mean it contains real/ imaginary x set, if not hid re/im button .
25
25
  dimension: 1,
26
26
  ...spectrum.info,
27
27
  };
@@ -15,7 +15,7 @@ export function autoPeakPicking(spectrum, options) {
15
15
  direction,
16
16
  shape: { kind: 'lorentzian' },
17
17
  noiseLevel: noise * noiseFactor,
18
- minMaxRatio,
18
+ minMaxRatio, // Threshold to determine if a given peak should be considered as a noise
19
19
  realTopDetection: true,
20
20
  smoothY: false,
21
21
  });
@@ -15,6 +15,7 @@ export declare function createRangeObj({ from, to, absolute, signals, }: RangeOp
15
15
  signals: {
16
16
  peaks?: import("nmr-processing").NMRPeak1D[] | undefined;
17
17
  kind?: string | undefined;
18
+ assignment?: string | undefined;
18
19
  diaIDs?: string[] | undefined;
19
20
  integration?: number | undefined;
20
21
  multiplicity: string;
@@ -22,7 +23,6 @@ export declare function createRangeObj({ from, to, absolute, signals, }: RangeOp
22
23
  js: import("nmr-processing").Jcoupling[];
23
24
  delta: number;
24
25
  atoms?: number[] | undefined;
25
- assignment?: string | undefined;
26
26
  statistic?: {
27
27
  mean: number;
28
28
  sd: number;
@@ -8,7 +8,7 @@ export function createRangeObj({ from, to, absolute, signals, }) {
8
8
  id: v4(),
9
9
  from,
10
10
  to,
11
- absolute,
11
+ absolute, // the real value,
12
12
  signals: signals.map((signal) => ({ id: v4(), ...signal })),
13
13
  kind: DATUM_KIND.signal,
14
14
  integration: 0,
@@ -14,7 +14,7 @@ export function changeRange(spectrum, range) {
14
14
  frequency,
15
15
  });
16
16
  if (index !== -1) {
17
- spectrum.ranges.values[index] = mapRanges([
17
+ const [newRange] = mapRanges([
18
18
  {
19
19
  ...spectrum.ranges.values[index],
20
20
  originalFrom: from,
@@ -23,7 +23,10 @@ export function changeRange(spectrum, range) {
23
23
  absolute,
24
24
  signals,
25
25
  },
26
- ], spectrum)[0];
27
- updateRangesRelativeValues(spectrum);
26
+ ], spectrum);
27
+ if (newRange) {
28
+ spectrum.ranges.values[index] = newRange;
29
+ updateRangesRelativeValues(spectrum);
30
+ }
28
31
  }
29
32
  }
@@ -14,7 +14,7 @@ export function detectRange(spectrum, options) {
14
14
  originalTo: to - shiftX,
15
15
  from,
16
16
  to,
17
- absolute,
17
+ absolute, // the real value,
18
18
  min,
19
19
  max,
20
20
  };
@@ -1,5 +1,4 @@
1
1
  import { DataXY } from 'cheminfo-types';
2
- export declare const MAX_LENGTH = 4092;
3
2
  export default function detectSignals(data: DataXY, options: {
4
3
  from: number;
5
4
  to: number;
@@ -24,4 +23,10 @@ export default function detectSignals(data: DataXY, options: {
24
23
  max: number;
25
24
  nb: number;
26
25
  } | undefined;
26
+ }[] | {
27
+ multiplicity: any;
28
+ kind: string;
29
+ delta: number;
30
+ js: any;
31
+ diaIDs: never[];
27
32
  }[];
@@ -1,23 +1,110 @@
1
- import { xyAutoRangesPicking } from 'nmr-processing';
2
- export const MAX_LENGTH = 4092;
1
+ import { xGetFromToIndex } from 'ml-spectra-processing';
2
+ import { analyseMultiplet } from 'multiplet-analysis';
3
+ import { signalJoinCouplings, xyAutoPeaksPicking, xyAutoRangesPicking, } from 'nmr-processing';
4
+ const MAX_LENGTH = 4092;
3
5
  export default function detectSignals(data, options) {
4
6
  const { from, to, frequency, nucleus } = options;
5
- const ranges = xyAutoRangesPicking(data, {
6
- peakPicking: {
7
- to,
8
- from,
9
- frequency,
10
- },
11
- ranges: {
12
- frequency,
13
- nucleus,
14
- compile: true,
15
- frequencyCluster: 16,
16
- keepPeaks: true,
17
- clean: 0.3,
18
- },
7
+ const { fromIndex, toIndex } = xGetFromToIndex(data.x, { from, to });
8
+ if (toIndex - fromIndex >= MAX_LENGTH) {
9
+ const ranges = xyAutoRangesPicking(data, {
10
+ peakPicking: {
11
+ to,
12
+ from,
13
+ frequency,
14
+ },
15
+ ranges: {
16
+ symRatio: 2.5,
17
+ frequency,
18
+ nucleus,
19
+ compile: true,
20
+ frequencyCluster: 16,
21
+ keepPeaks: true,
22
+ clean: 0.3,
23
+ },
24
+ });
25
+ return ranges
26
+ .flatMap((r) => r.signals || [])
27
+ .map((s) => ({ multiplicity: '', js: [], ...s }));
28
+ }
29
+ else {
30
+ return detectSignalsByMultipletAnalysis(data, {
31
+ ...options,
32
+ fromIndex,
33
+ toIndex,
34
+ });
35
+ }
36
+ }
37
+ function detectSignalsByMultipletAnalysis(data, options) {
38
+ const { fromIndex, toIndex, frequency } = options;
39
+ const dataRoi = {
40
+ x: data.x.slice(fromIndex, toIndex),
41
+ y: data.y.slice(fromIndex, toIndex),
42
+ };
43
+ const result = analyseMultiplet(dataRoi, {
44
+ frequency,
45
+ minimalResolution: 0.1,
46
+ maxTestedJ: 17,
47
+ checkSymmetryFirst: true,
48
+ takeBestPartMultiplet: true,
49
+ correctVerticalOffset: true,
50
+ symmetrizeEachStep: false,
51
+ decreasingJvalues: true,
52
+ makeShortCutForSpeed: true,
19
53
  });
20
- return ranges
21
- .flatMap((r) => r.signals || [])
22
- .map((s) => ({ multiplicity: '', js: [], ...s }));
54
+ if (result && result.chemShift === undefined)
55
+ return [];
56
+ const { delta, js } = joinCouplings(result);
57
+ let cs = 0;
58
+ let area = 0;
59
+ for (let i = 0; i < dataRoi.x.length; i++) {
60
+ cs += dataRoi.x[i] * dataRoi.y[i];
61
+ area += dataRoi.y[i];
62
+ }
63
+ cs /= area;
64
+ const multiplicity = getMultiplicity(js, { cs, data, delta, frequency });
65
+ return [
66
+ {
67
+ multiplicity,
68
+ kind: 'signal',
69
+ delta: cs,
70
+ js,
71
+ diaIDs: [],
72
+ },
73
+ ];
74
+ }
75
+ function getMultiplicity(js, options) {
76
+ const { cs, delta, frequency, data } = options;
77
+ if (js?.length > 0) {
78
+ return js.map((j) => j.multiplicity).join('');
79
+ }
80
+ //check if the massive center is closer to the shift from multiplet-analysis,
81
+ //if true, is it possibly a singlet.
82
+ if (Math.abs(cs - delta) / cs < 1e-3) {
83
+ let peaks = [];
84
+ if (js?.length === 0) {
85
+ peaks = xyAutoPeaksPicking(data, { frequency });
86
+ }
87
+ if (peaks.length === 1)
88
+ return 's';
89
+ }
90
+ return 'm';
91
+ }
92
+ function joinCouplings(result) {
93
+ const { chemShift: delta, js } = result;
94
+ let jCouplings = js;
95
+ if (js.length > 1) {
96
+ try {
97
+ jCouplings = signalJoinCouplings({
98
+ delta,
99
+ js,
100
+ }, { tolerance: 0.6, ignoreDiaIDs: true }).js;
101
+ }
102
+ catch (error) {
103
+ reportError(error);
104
+ }
105
+ }
106
+ return {
107
+ delta,
108
+ js: jCouplings,
109
+ };
23
110
  }
@@ -45,6 +45,7 @@ export declare function initiateRanges(inputSpectrum: Partial<Spectrum1D>, spect
45
45
  nbAtoms?: number | undefined;
46
46
  multiplicity?: string | undefined;
47
47
  diaIDs?: string[] | undefined;
48
+ assignment?: string | undefined;
48
49
  pubIntegral?: number | undefined;
49
50
  }[];
50
51
  };
@@ -75,7 +75,7 @@ function getRange(min, max, length, exp) {
75
75
  const factors = [];
76
76
  factors[0] = 0;
77
77
  for (let i = 1; i <= length; i++) {
78
- factors[i] = factors[i - 1] + (exp - 1) / Math.pow(exp, i);
78
+ factors[i] = factors[i - 1] + (exp - 1) / exp ** i;
79
79
  }
80
80
  const lastFactor = factors[length];
81
81
  const result = new Array(length);
@@ -119,7 +119,7 @@ function getContours(zoomLevel, options) {
119
119
  const sanResult = calculateSanPlot('2D', data);
120
120
  const median = sanResult.positive;
121
121
  const max = Math.max(Math.abs(data.maxZ), Math.abs(data.minZ));
122
- let _range = getRange(median * 1 * Math.pow(2, zoomLevel), max, nbLevels, 2);
122
+ let _range = getRange(median * 1 * 2 ** zoomLevel, max, nbLevels, 2);
123
123
  if (negative) {
124
124
  _range = _range.map((value) => -value);
125
125
  }