nmrium 0.45.0 → 0.46.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 (95) hide show
  1. package/lib/component/1d/tool/PeakPointer.js +6 -16
  2. package/lib/component/1d/utilities/scale.js +13 -8
  3. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +15 -4
  4. package/lib/component/elements/ContextMenuBluePrint.d.ts +16 -0
  5. package/lib/component/elements/ContextMenuBluePrint.js +20 -0
  6. package/lib/component/elements/DropdownMenu.d.ts +9 -0
  7. package/lib/component/elements/DropdownMenu.js +7 -0
  8. package/lib/component/elements/Header.d.ts +1 -1
  9. package/lib/component/elements/Header.js +4 -6
  10. package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +2 -2
  11. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +2 -2
  12. package/lib/component/elements/ReactTable/ReactTable.d.ts +5 -5
  13. package/lib/component/elements/Select.js +11 -4
  14. package/lib/component/header/Header.js +3 -4
  15. package/lib/component/hooks/useActiveSpectrumIntegralsViewState.js +3 -1
  16. package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +3 -1
  17. package/lib/component/hooks/useActiveSpectrumRangesViewState.js +3 -1
  18. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +6 -2
  19. package/lib/component/hooks/useActiveSpectrumZonesViewState.js +3 -1
  20. package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -1
  21. package/lib/component/hooks/useSaveSettings.js +1 -1
  22. package/lib/component/hooks/useSpectrum.js +1 -1
  23. package/lib/component/hooks/useToolsFunctions.js +2 -2
  24. package/lib/component/modal/MoleculeStructureEditorModal.d.ts +0 -8
  25. package/lib/component/modal/MoleculeStructureEditorModal.js +31 -8
  26. package/lib/component/modal/MultipletAnalysisModal.d.ts +1 -2
  27. package/lib/component/modal/PredictSpectraModal.js +3 -2
  28. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -5
  29. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +1 -0
  30. package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +4 -1
  31. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  32. package/lib/component/modal/setting/GeneralSettings.js +1 -1
  33. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +1 -1
  34. package/lib/component/modal/setting/settingsValidation.js +3 -1
  35. package/lib/component/panels/MatrixGenerationPanel/FiltersOptions.js +7 -2
  36. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +7 -14
  37. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  38. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -2
  39. package/lib/component/panels/RangesPanel/RangesTable.d.ts +2 -2
  40. package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +2 -2
  41. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
  42. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
  43. package/lib/component/panels/SpectrumsPanel/SpectraTable.d.ts +1 -2
  44. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +15 -18
  45. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -2
  46. package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -2
  47. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +2 -2
  48. package/lib/component/panels/extra/preferences/ColumnsHelper.js +1 -2
  49. package/lib/component/panels/filtersPanel/FiltersTable.js +1 -1
  50. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +6 -2
  51. package/lib/component/reducer/Reducer.d.ts +0 -4
  52. package/lib/component/reducer/actions/FiltersActions.d.ts +2 -1
  53. package/lib/component/reducer/actions/FiltersActions.js +1 -1
  54. package/lib/component/reducer/actions/MoleculeActions.d.ts +4 -1
  55. package/lib/component/reducer/actions/MoleculeActions.js +6 -2
  56. package/lib/component/reducer/actions/PeaksActions.js +4 -3
  57. package/lib/component/reducer/actions/SpectrumsActions.js +1 -0
  58. package/lib/component/reducer/actions/ToolsActions.js +8 -6
  59. package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.d.ts +3 -0
  60. package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.js +24 -0
  61. package/lib/component/reducer/helper/Zoom1DManager.js +1 -1
  62. package/lib/component/reducer/helper/getActiveSpectra.js +2 -1
  63. package/lib/component/reducer/helper/getActiveSpectrum.js +1 -1
  64. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -1
  65. package/lib/component/toolbar/BasicToolBar.js +53 -34
  66. package/lib/component/toolbar/FunctionToolBar.js +102 -9
  67. package/lib/component/toolbar/ToolBar.js +1 -1
  68. package/lib/component/utility/getClosePeak.d.ts +10 -0
  69. package/lib/component/utility/getClosePeak.js +15 -0
  70. package/lib/component/utility/maxAbsoluteValue.d.ts +3 -0
  71. package/lib/component/utility/maxAbsoluteValue.js +21 -0
  72. package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
  73. package/lib/data/data1d/Spectrum1D/index.js +0 -1
  74. package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
  75. package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -1
  76. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +1 -1
  77. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  78. package/lib/data/data2d/Spectrum2D/contours.js +2 -2
  79. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  80. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  81. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  82. package/lib/data/parseMeta/mapErrors.js +3 -1
  83. package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
  84. package/lib/versionInfo.js +1 -1
  85. package/package.json +39 -38
  86. package/lib/component/elements/ToolbarMenu.d.ts +0 -18
  87. package/lib/component/elements/ToolbarMenu.js +0 -102
  88. package/lib/component/elements/toggle/ToggleButton.d.ts +0 -13
  89. package/lib/component/elements/toggle/ToggleButton.js +0 -24
  90. package/lib/component/elements/toggle/ToggleButtonGroup.d.ts +0 -8
  91. package/lib/component/elements/toggle/ToggleButtonGroup.js +0 -48
  92. package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.d.ts +0 -17
  93. package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.js +0 -18
  94. package/lib/data/data2d/Processing2D.d.ts +0 -32
  95. package/lib/data/data2d/Processing2D.js +0 -130
@@ -0,0 +1,24 @@
1
+ export function deepReplaceDiaIDs(data, mappings) {
2
+ for (const key in data) {
3
+ if (key !== 'diaIDs') {
4
+ if (typeof data[key] === 'object' && !ArrayBuffer.isView(data[key])) {
5
+ deepReplaceDiaIDs(data[key], mappings);
6
+ }
7
+ continue;
8
+ }
9
+ if (!Array.isArray(data[key])) {
10
+ throw new Error('diaIDs must be an array');
11
+ }
12
+ const diaIDs = data[key];
13
+ for (let i = 0; i < diaIDs.length; i++) {
14
+ const diaID = diaIDs[i];
15
+ if (typeof diaID !== 'string') {
16
+ throw new Error('diaID must be a string');
17
+ }
18
+ const newDiaID = mappings[diaID];
19
+ if (newDiaID) {
20
+ diaIDs[i] = newDiaID;
21
+ }
22
+ }
23
+ }
24
+ }
@@ -31,7 +31,7 @@ function setZoom(draft, options = {}) {
31
31
  ]);
32
32
  const [min, max] = shareYDomain ? yDomain : yDomains[id];
33
33
  const maxPoint = Math.max(Math.abs(max), Math.abs(min));
34
- const scalePoint = maxPoint === max ? 0 : min;
34
+ const scalePoint = maxPoint === Math.abs(max) ? 0 : min;
35
35
  const t = zoomIdentity
36
36
  .translate(0, Math.sign(scalePoint) >= 0
37
37
  ? _scale(scalePoint)
@@ -1,4 +1,5 @@
1
1
  export function getActiveSpectra(state) {
2
2
  const { activeSpectra, activeTab } = state.view.spectra;
3
- return activeSpectra?.[activeTab] || null;
3
+ const spectra = activeSpectra?.[activeTab]?.filter((spectrum) => spectrum?.selected);
4
+ return Array.isArray(spectra) && spectra.length > 0 ? spectra : null;
4
5
  }
@@ -1,7 +1,7 @@
1
1
  export function getActiveSpectrum(state) {
2
2
  const { activeSpectra, activeTab } = state.view.spectra;
3
3
  const spectra = activeSpectra[activeTab];
4
- if (spectra?.length === 1) {
4
+ if (spectra?.length === 1 && spectra[0]?.selected) {
5
5
  return spectra[0];
6
6
  }
7
7
  return null;
@@ -95,7 +95,7 @@ const getRangeDefaultValues = (nucleus) => {
95
95
  deltaPPM: { show: true, format: '0.00' },
96
96
  deltaHz: { show: false, format: '0.00' },
97
97
  coupling: { show: true, format: '0.00' },
98
- jGraphTolerance: nucleus === '1H' ? 0.2 : nucleus === '13C' ? 2 : 0,
98
+ jGraphTolerance: nucleus === '1H' ? 0.2 : nucleus === '13C' ? 2 : 0, //J Graph tolerance for: 1H: 0.2Hz 13C: 2Hz
99
99
  showKind: true,
100
100
  showMultiplicity: true,
101
101
  showAssignment: true,
@@ -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';
@@ -16,58 +16,79 @@ import { useVerticalAlign } from '../hooks/useVerticalAlign';
16
16
  import ImportPublicationStringModal from '../modal/ImportPublicationStringModal';
17
17
  import { LoadJCAMPModal } from '../modal/LoadJCAMPModal';
18
18
  import { useMetaInformationImportationModal } from '../modal/metaImportation/index';
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", onSelect: (data) => {
165
+ importHandler(data);
166
+ }, options: importMenu, renderTarget: (targetProps) => (_jsx("div", { ...targetProps, style: { flex: 'none' }, 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", options: exportMenu, renderTarget: (targetProps) => (_jsx("div", { ...targetProps, style: { flex: 'none' }, children: _jsx(Toolbar.Item, { id: options.exportAs.id, title: options.import.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
+ }
@@ -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
  });
@@ -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 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
  };
@@ -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
  }
@@ -33,9 +33,9 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
33
33
  if (index === -1)
34
34
  index = 0;
35
35
  const info = {
36
- nucleus: datumInfo.nucleus[index],
36
+ nucleus: datumInfo.nucleus[index], // 1H, 13C, 19F, ...
37
37
  isFid: false,
38
- isComplex: false,
38
+ isComplex: false, // if isComplex is true that mean it contains real/ imaginary x set, if not hid re/im button .
39
39
  dimension: 1,
40
40
  };
41
41
  const data = getProjection(datum, index);
@@ -2,7 +2,7 @@ import { zoneToX } from 'ml-spectra-processing';
2
2
  import { initiateDatum1D } from '../../data1d/Spectrum1D';
3
3
  const BASE_INFO = {
4
4
  isFid: false,
5
- isComplex: false,
5
+ isComplex: false, // if isComplex is true that mean it contains real/ imaginary x set, if not hid re/im button .
6
6
  dimension: 1,
7
7
  };
8
8
  export function getSlice(spectrum, position, options = {}) {
@@ -21,11 +21,11 @@ export function getSlice(spectrum, position, options = {}) {
21
21
  if (yIndex < 0 || yIndex >= real.z.length)
22
22
  return;
23
23
  const infoX = {
24
- nucleus: info.nucleus[0],
24
+ nucleus: info.nucleus[0], // 1H, 13C, 19F, ...
25
25
  ...BASE_INFO,
26
26
  };
27
27
  const infoY = {
28
- nucleus: info.nucleus[1],
28
+ nucleus: info.nucleus[1], // 1H, 13C, 19F, ...
29
29
  ...BASE_INFO,
30
30
  };
31
31
  const dataX = initiateData(real.minX, real.maxX, xLength);
@@ -21,7 +21,7 @@ export function initiateDatum2D(spectrum, usedColors = {}) {
21
21
  nucleus: ['1H', '1H'],
22
22
  isFt: true,
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: 2,
26
26
  ...spectrum.info,
27
27
  };
@@ -1,7 +1,9 @@
1
1
  export function mapErrors(errors) {
2
2
  const result = {};
3
3
  for (const error of errors) {
4
- result[error.row] = error.message;
4
+ if (error?.row) {
5
+ result[error.row] = error.message;
6
+ }
5
7
  }
6
8
  return result;
7
9
  }
@@ -18,6 +18,6 @@ function formatNumber(number) {
18
18
  return `${number / 1024}K`;
19
19
  }
20
20
  else {
21
- return number;
21
+ return `${number}`;
22
22
  }
23
23
  }
@@ -1 +1 @@
1
- export default { version: 'v0.45.0' };
1
+ export default { version: 'v0.46.0' };