nmrium 0.49.0 → 0.50.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 (104) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/LinesSeries.js +1 -1
  3. package/lib/component/1d/SimilarityTree.d.ts +1 -0
  4. package/lib/component/1d/SimilarityTree.js +60 -0
  5. package/lib/component/1d/Viewer1D.js +9 -11
  6. package/lib/component/1d/multiplicityTree/MultiplicityTree.d.ts +1 -7
  7. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +114 -125
  8. package/lib/component/1d/multiplicityTree/MultiplicityTrees.d.ts +1 -0
  9. package/lib/component/1d/multiplicityTree/MultiplicityTrees.js +23 -0
  10. package/lib/component/1d/multiplicityTree/generateTreeNodes.d.ts +18 -0
  11. package/lib/component/1d/multiplicityTree/generateTreeNodes.js +66 -0
  12. package/lib/component/1d/ranges/Range.d.ts +1 -1
  13. package/lib/component/1d/ranges/Range.js +8 -9
  14. package/lib/component/elements/CloseButton.d.ts +2 -10
  15. package/lib/component/elements/CloseButton.js +3 -20
  16. package/lib/component/elements/CounterLabel.js +0 -1
  17. package/lib/component/elements/DeleteButton.d.ts +5 -7
  18. package/lib/component/elements/DeleteButton.js +7 -5
  19. package/lib/component/elements/FilterButton.d.ts +6 -0
  20. package/lib/component/elements/FilterButton.js +8 -0
  21. package/lib/component/elements/PreferencesButton.d.ts +2 -4
  22. package/lib/component/elements/PreferencesButton.js +5 -3
  23. package/lib/component/elements/ReactTable/ReactTable.js +5 -2
  24. package/lib/component/elements/SaveButton.d.ts +2 -11
  25. package/lib/component/elements/SaveButton.js +4 -19
  26. package/lib/component/elements/ToolBarButton.d.ts +9 -0
  27. package/lib/component/elements/ToolBarButton.js +14 -0
  28. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +2 -1
  29. package/lib/component/elements/popup/Modal/ConfirmDialog.js +11 -8
  30. package/lib/component/hooks/useSaveSettings.js +3 -2
  31. package/lib/component/main/InnerNMRiumContents.js +1 -1
  32. package/lib/component/modal/AboutPredictionModal.js +4 -8
  33. package/lib/component/modal/AboutSpectrumSimulationModal.js +4 -8
  34. package/lib/component/modal/CopyClipboardModal.js +1 -1
  35. package/lib/component/modal/EditPeakShapeModal.js +2 -2
  36. package/lib/component/modal/ExportAsJcampModal.d.ts +1 -1
  37. package/lib/component/modal/ExportAsJcampModal.js +7 -3
  38. package/lib/component/modal/ImportPublicationStringModal.js +15 -11
  39. package/lib/component/modal/LoadJCAMPModal.js +12 -9
  40. package/lib/component/modal/LogsHistoryModal.d.ts +1 -1
  41. package/lib/component/modal/LogsHistoryModal.js +9 -4
  42. package/lib/component/modal/MoleculeStructureEditorModal.js +10 -3
  43. package/lib/component/modal/MultipletAnalysisModal.js +8 -8
  44. package/lib/component/modal/PredictSpectraModal.js +6 -5
  45. package/lib/component/modal/SaveAsModal.js +2 -2
  46. package/lib/component/modal/aboutUs/AboutUsModal.js +11 -26
  47. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +4 -3
  48. package/lib/component/modal/changeSum/ChangeSumModal.js +10 -3
  49. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +1 -3
  50. package/lib/component/modal/changeSum/ChangeSumModalContents.js +9 -6
  51. package/lib/component/modal/editRange/EditRangeModal.js +8 -6
  52. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +1 -0
  53. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +13 -10
  54. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +1 -1
  55. package/lib/component/modal/editRange/forms/components/SignalsForm.js +1 -0
  56. package/lib/component/modal/editZone/EditZoneModal.js +3 -3
  57. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  58. package/lib/component/modal/setting/GeneralSettings.js +17 -38
  59. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +2 -4
  60. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
  61. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -23
  62. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +3 -3
  63. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -4
  64. package/lib/component/panels/PeaksPanel/PeaksPanel.js +7 -8
  65. package/lib/component/panels/PeaksPanel/PeaksToggleActions.d.ts +8 -6
  66. package/lib/component/panels/PeaksPanel/PeaksToggleActions.js +3 -6
  67. package/lib/component/panels/RangesPanel/RangesHeader.d.ts +1 -1
  68. package/lib/component/panels/RangesPanel/RangesHeader.js +8 -31
  69. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +2 -2
  70. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +40 -9
  71. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  72. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +1 -1
  73. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +1 -1
  74. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  75. package/lib/component/panels/ZonesPanel/ZonesPanel.js +2 -26
  76. package/lib/component/panels/databasePanel/DatabasePanel.js +6 -6
  77. package/lib/component/panels/databasePanel/DatabaseSearchOptions.d.ts +4 -6
  78. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +12 -13
  79. package/lib/component/panels/databasePanel/DatabaseStructureSearchModal.js +7 -8
  80. package/lib/component/panels/filtersPanel/FiltersTable.js +1 -1
  81. package/lib/component/panels/header/DefaultPanelHeader.js +9 -4
  82. package/lib/component/panels/header/PanelHeader.js +0 -1
  83. package/lib/component/panels/header/PreferencesHeader.d.ts +2 -4
  84. package/lib/component/panels/header/PreferencesHeader.js +9 -23
  85. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +2 -2
  86. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -9
  87. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +3 -3
  88. package/lib/component/reducer/Reducer.js +3 -0
  89. package/lib/component/reducer/actions/DatabaseActions.d.ts +3 -2
  90. package/lib/component/reducer/actions/DatabaseActions.js +5 -1
  91. package/lib/utils/clipboard/clipboardComponents.d.ts +2 -2
  92. package/lib/utils/clipboard/clipboardComponents.js +8 -3
  93. package/lib/versionInfo.js +1 -1
  94. package/package.json +17 -16
  95. package/lib/component/1d/multiplicityTree/LevelNode.d.ts +0 -8
  96. package/lib/component/1d/multiplicityTree/LevelNode.js +0 -8
  97. package/lib/component/1d/multiplicityTree/StringNode.d.ts +0 -11
  98. package/lib/component/1d/multiplicityTree/StringNode.js +0 -7
  99. package/lib/component/1d/multiplicityTree/TreeColors.d.ts +0 -1
  100. package/lib/component/1d/multiplicityTree/TreeColors.js +0 -1
  101. package/lib/component/1d/multiplicityTree/TreeNodes.d.ts +0 -21
  102. package/lib/component/1d/multiplicityTree/TreeNodes.js +0 -23
  103. package/lib/component/1d/multiplicityTree/buildTreeNode.d.ts +0 -11
  104. package/lib/component/1d/multiplicityTree/buildTreeNode.js +0 -57
@@ -1,18 +1,16 @@
1
- /// <reference types="react" />
1
+ import { ToolBarButtonProps } from '../../elements/ToolBarButton';
2
2
  import { DataBaseSearchResultEntry, DatabaseSearchKeywords, Databases } from './DatabasePanel';
3
- type OnClick = React.ButtonHTMLAttributes<HTMLButtonElement>['onClick'];
4
3
  interface DatabaseSearchOptionsProps {
5
4
  databases: Databases;
6
5
  defaultDatabase: string;
7
6
  keywords: DatabaseSearchKeywords;
8
7
  result: DataBaseSearchResultEntry;
9
- selectedTool: string;
10
8
  idCode?: string;
11
9
  total: number;
12
10
  onKeywordsChange: (k: Partial<DatabaseSearchKeywords>) => void;
13
- onSettingClick: OnClick;
14
- onStructureClick: OnClick;
11
+ onSettingClick: ToolBarButtonProps['onClick'];
12
+ onStructureClick: ToolBarButtonProps['onClick'];
15
13
  onDatabaseChange: (databaseKey: string) => void;
16
14
  }
17
- export declare function DatabaseSearchOptions({ databases, defaultDatabase, keywords, result, selectedTool, idCode, total, onKeywordsChange, onSettingClick, onStructureClick, onDatabaseChange, }: DatabaseSearchOptionsProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function DatabaseSearchOptions({ databases, defaultDatabase, keywords, result, idCode, total, onKeywordsChange, onSettingClick, onStructureClick, onDatabaseChange, }: DatabaseSearchOptionsProps): import("react/jsx-runtime").JSX.Element;
18
16
  export {};
@@ -2,18 +2,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { BsHexagon, BsHexagonFill } from 'react-icons/bs';
3
3
  import { FaICursor } from 'react-icons/fa';
4
4
  import { IoSearchOutline } from 'react-icons/io5';
5
- import Button from '../../elements/Button';
5
+ import { TbBinaryTree } from 'react-icons/tb';
6
+ import { useChartData } from '../../context/ChartContext';
7
+ import { useDispatch } from '../../context/DispatchContext';
6
8
  import { CounterLabel } from '../../elements/CounterLabel';
7
9
  import Input from '../../elements/Input';
8
10
  import { PreferencesButton } from '../../elements/PreferencesButton';
9
11
  import Select from '../../elements/Select';
10
- import ToggleButton from '../../elements/ToggleButton';
12
+ import { ToolBarButton, } from '../../elements/ToolBarButton';
11
13
  import useToolsFunctions from '../../hooks/useToolsFunctions';
12
14
  import { options } from '../../toolbar/ToolTypes';
13
15
  import { createFilterLabel } from '../header/DefaultPanelHeader';
14
16
  import PanelHeader from '../header/PanelHeader';
15
- export function DatabaseSearchOptions({ databases, defaultDatabase, keywords, result, selectedTool, idCode, total, onKeywordsChange, onSettingClick, onStructureClick, onDatabaseChange, }) {
17
+ export function DatabaseSearchOptions({ databases, defaultDatabase, keywords, result, idCode, total, onKeywordsChange, onSettingClick, onStructureClick, onDatabaseChange, }) {
16
18
  const { handleChangeOption } = useToolsFunctions();
19
+ const { view: { spectra: { showSimilarityTree }, }, toolOptions: { selectedTool }, } = useChartData();
20
+ const dispatch = useDispatch();
17
21
  function enableFilterHandler(flag) {
18
22
  const tool = !flag ? options.zoom.id : options.databaseRangesSelection.id;
19
23
  handleChangeOption(tool);
@@ -32,22 +36,17 @@ export function DatabaseSearchOptions({ databases, defaultDatabase, keywords, re
32
36
  function clearHandler() {
33
37
  onKeywordsChange({ searchKeywords: '' });
34
38
  }
39
+ function handleShowSimilarityTree() {
40
+ dispatch({ type: 'TOGGLE_SIMILARITY_TREE' });
41
+ }
35
42
  return (_jsxs(PanelHeader, { style: { flexDirection: 'column', alignItems: 'normal' }, children: [_jsxs("div", { style: {
36
43
  display: 'flex',
37
44
  justifyContent: 'space-between',
38
45
  paddingBottom: '2px',
39
- }, children: [_jsx(Select, { style: { flex: 6 }, items: databases, itemTextField: "label", itemValueField: "key", onChange: onDatabaseChange, placeholder: "Select database", defaultValue: defaultDatabase }), _jsx(Select, { style: { flex: 4, margin: '0px 5px' }, items: result.solvents, placeholder: "Solvent", onChange: handleSearch, value: keywords.solvent }), _jsxs("div", { style: {
46
+ }, children: [_jsx(ToolBarButton, { title: `${showSimilarityTree ? 'Hide' : 'Show'} similarity tree`, icon: _jsx(TbBinaryTree, {}), active: showSimilarityTree, onClick: handleShowSimilarityTree, style: { marginRight: '5px' } }), _jsx(Select, { style: { flex: 6 }, items: databases, itemTextField: "label", itemValueField: "key", onChange: onDatabaseChange, placeholder: "Select database", defaultValue: defaultDatabase }), _jsx(Select, { style: { flex: 4, margin: '0px 5px' }, items: result.solvents, placeholder: "Solvent", onChange: handleSearch, value: keywords.solvent }), _jsxs("div", { style: {
40
47
  display: 'flex',
41
48
  alignItems: 'center',
42
49
  flex: 2,
43
50
  justifyContent: 'flex-end',
44
- }, children: [_jsx(CounterLabel, { children: createFilterLabel(total || 0, result.data.length) }), _jsx(PreferencesButton, { onClick: onSettingClick })] })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(ToggleButton, { defaultValue: selectedTool === options.databaseRangesSelection.id, popupTitle: "Filter by select ranges", popupPlacement: "right", onClick: enableFilterHandler, children: _jsx(FaICursor, { style: {
45
- pointerEvents: 'none',
46
- fontSize: '12px',
47
- transform: 'rotate(90deg)',
48
- } }) }, selectedTool), _jsx(Input, { value: keywords.searchKeywords, renderIcon: () => _jsx(IoSearchOutline, {}), style: { inputWrapper: { flex: 3 } }, className: "search-input", type: "text", debounceTime: 250, placeholder: "Search for parameter...", onChange: handleSearch, onClear: clearHandler, canClear: true }), _jsx(Button.Done, { fill: "clear", onClick: onStructureClick, style: { padding: '5px' }, children: !idCode ? (_jsx(BsHexagon, { style: {
49
- fontSize: '12px',
50
- } })) : (_jsx(BsHexagonFill, { style: {
51
- fontSize: '12px',
52
- } })) })] })] }));
51
+ }, children: [_jsx(CounterLabel, { children: createFilterLabel(total || 0, result.data.length) }), _jsx(PreferencesButton, { onClick: onSettingClick })] })] }), _jsxs("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: [_jsx(ToolBarButton, { title: "Filter by select ranges", icon: _jsx(FaICursor, {}), active: selectedTool === options.databaseRangesSelection.id, onClick: enableFilterHandler, style: { marginRight: '5px' } }), _jsx(Input, { value: keywords.searchKeywords, renderIcon: () => _jsx(IoSearchOutline, {}), style: { inputWrapper: { flex: 3 } }, className: "search-input", type: "text", debounceTime: 250, placeholder: "Search for parameter...", onChange: handleSearch, onClear: clearHandler, canClear: true }), _jsx(ToolBarButton, { title: "Search by stricture", icon: !idCode ? _jsx(BsHexagon, {}) : _jsx(BsHexagonFill, {}), intent: "success", active: !!idCode, onClick: onStructureClick, style: { marginLeft: '5px' } })] })] }));
53
52
  }
@@ -1,13 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
+ import { Dialog, DialogBody } from '@blueprintjs/core';
4
+ import { css } from '@emotion/react';
3
5
  import { StructureEditor } from 'react-ocl/full';
4
- import { Modal } from 'react-science/ui';
5
6
  export function DatabaseStructureSearchModal({ onChange, isOpen, idCode, onClose, }) {
6
- return (_jsxs(Modal, { hasCloseButton: true, isOpen: isOpen, onRequestClose: () => {
7
+ return (_jsx(Dialog, { isOpen: isOpen, onClose: () => {
7
8
  onClose?.();
8
- }, maxWidth: 1000, children: [_jsx(Modal.Header, { children: _jsx("div", { style: {
9
- color: 'rgb(0, 93, 158)',
10
- width: '100%',
11
- textAlign: 'center',
12
- }, children: _jsx("span", { children: "Search by structure" }) }) }), _jsx(Modal.Body, { children: _jsx(StructureEditor, { initialIDCode: idCode, svgMenu: true, fragment: true, onChange: (molFile, molecule, idCode) => onChange(idCode) }) })] }));
9
+ }, style: { width: 720 }, title: "Search by structure", children: _jsx(DialogBody, { css: css `
10
+ background-color: white;
11
+ `, children: _jsx(StructureEditor, { initialIDCode: idCode, svgMenu: true, fragment: true, onChange: (molFile, molecule, idCode) => onChange(idCode) }) }) }));
13
12
  }
@@ -71,7 +71,7 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
71
71
  modal.showConfirmDialog({
72
72
  message: (_jsxs("span", { children: ["You are about to delete this processing step", _jsxs("span", { style: { color: 'black' }, children: [" ", label, " "] }), " , Are you sure?"] })),
73
73
  buttons,
74
- });
74
+ }, { height: 'auto', width: 'auto' });
75
75
  }, [alert, dispatch, modal, spectraCounter]);
76
76
  const filterSnapShotHandler = useCallback((filter, index) => {
77
77
  selectedFilterIndex.current =
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { FaRegTrashAlt, FaFilter } from 'react-icons/fa';
3
- import Button from '../../elements/Button';
2
+ import { useState } from 'react';
4
3
  import { CounterLabel } from '../../elements/CounterLabel';
4
+ import { DeleteButton } from '../../elements/DeleteButton';
5
+ import { FilterButton } from '../../elements/FilterButton';
5
6
  import { PreferencesButton } from '../../elements/PreferencesButton';
6
- import ToggleButton from '../../elements/ToggleButton';
7
7
  import PanelHeader from './PanelHeader';
8
8
  const styles = {
9
9
  leftContainer: {
@@ -19,6 +19,11 @@ export function createFilterLabel(total, counter) {
19
19
  return `[ ${counter}/${total} ]`;
20
20
  }
21
21
  function DefaultPanelHeader({ counter, counterLabel, onDelete = () => null, deleteToolTip = 'Delete', onFilter = () => null, filterToolTip = '', children, onSettingClick = () => null, showSettingButton = false, canDelete = true, disableDelete = false, style = {}, className = '', renderRightButtons, }) {
22
- return (_jsxs(PanelHeader, { style, className, children: [_jsxs("div", { style: styles.leftContainer, children: [canDelete && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'red' }, onClick: onDelete, disabled: counter === 0 || disableDelete, toolTip: deleteToolTip, tooltipOrientation: "horizontal", children: _jsx(FaRegTrashAlt, {}) })), filterToolTip ? (_jsx(ToggleButton, { popupTitle: filterToolTip, popupPlacement: "right", onClick: onFilter, children: _jsx(FaFilter, { style: { pointerEvents: 'none', fontSize: '12px' } }) })) : null, children] }), renderRightButtons?.(), counterLabel && _jsx(CounterLabel, { children: counterLabel }), showSettingButton && _jsx(PreferencesButton, { onClick: onSettingClick })] }));
22
+ const [isFiltered, setFilterStatus] = useState(false);
23
+ function handleFilter() {
24
+ setFilterStatus((previousValue) => !previousValue);
25
+ onFilter();
26
+ }
27
+ return (_jsxs(PanelHeader, { style, className, children: [_jsxs("div", { style: styles.leftContainer, children: [canDelete && (_jsx(DeleteButton, { disabled: counter === 0 || disableDelete, title: deleteToolTip, onClick: onDelete })), filterToolTip && (_jsx(FilterButton, { onClick: handleFilter, active: isFiltered, title: filterToolTip })), children] }), renderRightButtons?.(), counterLabel && _jsx(CounterLabel, { children: counterLabel }), showSettingButton && _jsx(PreferencesButton, { onClick: onSettingClick })] }));
23
28
  }
24
29
  export default DefaultPanelHeader;
@@ -3,7 +3,6 @@ const containerStyle = {
3
3
  display: 'flex',
4
4
  flexDirection: 'row',
5
5
  borderBottom: '0.55px solid rgb(240 240 240)',
6
- padding: '2px 5px',
7
6
  alignItems: 'center',
8
7
  };
9
8
  export default function PanelHeader(props) {
@@ -1,8 +1,6 @@
1
- /// <reference types="react" />
2
1
  interface PreferencesHeaderProps {
3
2
  onClose: () => void;
4
3
  onSave: () => void;
5
4
  }
6
- declare function PreferencesHeader({ onClose, onSave }: PreferencesHeaderProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
- declare const _default: import("react").MemoExoticComponent<typeof PreferencesHeader>;
8
- export default _default;
5
+ declare function PreferencesHeader({ onClose, onSave }: PreferencesHeaderProps): import("react/jsx-runtime").JSX.Element;
6
+ export default PreferencesHeader;
@@ -1,25 +1,11 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { memo } from 'react';
5
- import CloseButton from '../../elements/CloseButton';
6
- import SaveButton from '../../elements/SaveButton';
7
- const styles = css `
8
- display: flex;
9
- flex-direction: row-reverse;
10
- border-bottom: 0.55px solid rgb(240 240 240);
11
-
12
- button {
13
- background-color: transparent;
14
- border: none;
15
- padding: 5px;
16
- }
17
-
18
- button:disabled {
19
- opacity: 0.6;
20
- }
21
- `;
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CloseButton } from '../../elements/CloseButton';
3
+ import { SaveButton } from '../../elements/SaveButton';
22
4
  function PreferencesHeader({ onClose, onSave }) {
23
- return (_jsxs("div", { css: styles, children: [_jsx(CloseButton, { onClick: onClose, popupTitle: "Close preferences" }), _jsx(SaveButton, { onClick: onSave, popupTitle: "Save preferences" })] }));
5
+ return (_jsxs("div", { style: {
6
+ display: 'flex',
7
+ flexDirection: 'row-reverse',
8
+ borderBottom: '0.55px solid rgb(240 240 240)',
9
+ }, children: [_jsx(CloseButton, { onClick: onClose, title: "Close preferences" }), _jsx(SaveButton, { onClick: onSave, title: "Save preferences" })] }));
24
10
  }
25
- export default memo(PreferencesHeader);
11
+ export default PreferencesHeader;
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SvgNmrRangePicking } from 'cheminfo-font';
3
3
  import { useCallback } from 'react';
4
+ import { Toolbar } from 'react-science/ui';
4
5
  import { useChartData } from '../../context/ChartContext';
5
6
  import { useDispatch } from '../../context/DispatchContext';
6
- import Button from '../../elements/Button';
7
7
  import { useAlert } from '../../elements/popup/Alert';
8
8
  import { useCheckToolsVisibility } from '../../hooks/useCheckToolsVisibility';
9
9
  export function SpectraAutomaticPickingButton() {
@@ -25,5 +25,5 @@ export function SpectraAutomaticPickingButton() {
25
25
  !isToolVisible('autoRangeAndZonePicking')) {
26
26
  return null;
27
27
  }
28
- return (_jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: _jsx(SvgNmrRangePicking, {}) }));
28
+ return (_jsx(Toolbar.Item, { icon: _jsx(SvgNmrRangePicking, {}), title: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler }));
29
29
  }
@@ -5,14 +5,13 @@ import { SvgNmrOverlay } from 'cheminfo-font';
5
5
  import { useCallback, useState, useRef, memo } from 'react';
6
6
  import { FaChartBar, FaFileExport } from 'react-icons/fa';
7
7
  import { IoPulseOutline } from 'react-icons/io5';
8
+ import { Toolbar } from 'react-science/ui';
8
9
  import { useToggle } from 'react-use';
9
10
  import { getDataAsString, generateAnalyzeSpectra, } from '../../../data/data1d/multipleSpectraAnalysis';
10
11
  import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
11
12
  import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
12
13
  import { useChartData } from '../../context/ChartContext';
13
14
  import { useDispatch } from '../../context/DispatchContext';
14
- import ActiveButton from '../../elements/ActiveButton';
15
- import Button from '../../elements/ButtonToolTip';
16
15
  import { useAlert } from '../../elements/popup/Alert';
17
16
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
18
17
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
@@ -52,6 +51,13 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, dis
52
51
  return;
53
52
  void rawWriteWithType(data).then(() => alert.success('Data copied to clipboard'));
54
53
  }, [alert, rawWriteWithType, spectra, spectraAnalysis, spectraPreferences]);
54
+ function handleSpectraCalibration() {
55
+ setCalibration((value) => {
56
+ if (value)
57
+ dispatch({ type: 'RESET_SELECTED_TOOL' });
58
+ return !value;
59
+ });
60
+ }
55
61
  return (_jsxs("div", { css: [
56
62
  tablePanelStyle,
57
63
  isFlipped &&
@@ -60,13 +66,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectra, showLegend, dis
60
66
  position: relative;
61
67
  }
62
68
  `,
63
- ], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: [_jsx(Button, { popupTitle: "Copy To Clipboard", onClick: copyToClipboardHandler, children: _jsx(FaFileExport, {}) }), displayerMode === '1D' && (_jsxs(_Fragment, { children: [_jsx(Button, { popupTitle: "Spectra calibration", onClick: () => {
64
- setCalibration((value) => {
65
- if (value)
66
- dispatch({ type: 'RESET_SELECTED_TOOL' });
67
- return !value;
68
- });
69
- }, children: _jsx(SvgNmrOverlay, { style: { fontSize: '16px' } }) }), _jsx(ActiveButton, { popupTitle: "Y spectra tracker", popupPlacement: "right", onClick: showTrackerHandler, value: showLegend, children: _jsx(IoPulseOutline, {}) }, `${showLegend}`), _jsx(ActiveButton, { popupTitle: `${!showAnalysisChart ? 'Show' : 'Hide'} analysis chart`, popupPlacement: "right", onClick: () => toggleAnalysisChart(), value: showAnalysisChart, style: { marginLeft: '5px' }, children: _jsx(FaChartBar, {}) })] }))] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: isFlipped ? (_jsx(MultipleSpectraAnalysisPreferences, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) : calibration ? (_jsx(AlignSpectra, { nucleus: activeTab, onClose: () => setCalibration(false) })) : (_jsxs("div", { style: { overflow: 'auto', maxHeight: '100%' }, children: [showAnalysisChart && (_jsx(AnalysisChart, { spectraAnalysisData: spectraAnalysis })), _jsx(MultipleSpectraAnalysisTable, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })] })) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
69
+ ], children: [!isFlipped && (_jsx(DefaultPanelHeader, { deleteToolTip: "Delete All Peaks", showSettingButton: true, canDelete: false, onSettingClick: settingsPanelHandler, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaFileExport, {}), title: "Copy To Clipboard", onClick: copyToClipboardHandler }), displayerMode === '1D' && (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { icon: _jsx(SvgNmrOverlay, {}), title: "Spectra calibration", onClick: handleSpectraCalibration, active: calibration }), _jsx(Toolbar.Item, { icon: _jsx(IoPulseOutline, {}), title: "Y spectra tracker", onClick: showTrackerHandler, active: showLegend }), _jsx(Toolbar.Item, { icon: _jsx(FaChartBar, {}), title: `${!showAnalysisChart ? 'Show' : 'Hide'} analysis chart`, onClick: toggleAnalysisChart, active: showAnalysisChart })] }))] }) })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: isFlipped ? (_jsx(MultipleSpectraAnalysisPreferences, { data: spectraAnalysis, activeTab: activeTab, onAfterSave: afterSaveHandler, ref: settingRef })) : calibration ? (_jsx(AlignSpectra, { nucleus: activeTab, onClose: () => setCalibration(false) })) : (_jsxs("div", { style: { overflow: 'auto', maxHeight: '100%' }, children: [showAnalysisChart && (_jsx(AnalysisChart, { spectraAnalysisData: spectraAnalysis })), _jsx(MultipleSpectraAnalysisTable, { data: spectraAnalysis, resortSpectra: preferences.analysisOptions.resortSpectra, activeTab: activeTab })] })) }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Spectra Analysis" })] }));
70
70
  }
71
71
  const MemoizedMultipleSpectraAnalysisPanel = memo(MultipleSpectraAnalysisPanelInner);
72
72
  export default function MultipleSpectraAnalysisPanel() {
@@ -11,10 +11,10 @@ const SPIN_SYSTEMS = getSpinSystems().map((key) => ({
11
11
  }));
12
12
  const labelStyle = {
13
13
  label: { fontSize: '10px' },
14
- wrapper: { display: 'flex', alignItems: 'center', height: '100%' },
15
- container: { padding: '0 5px', height: '100%' },
14
+ wrapper: { display: 'flex', alignItems: 'center' },
15
+ container: { padding: '0 5px' },
16
16
  };
17
- const selectStyles = { width: '100%', minWidth: '75px', fontSize: '10px' };
17
+ const selectStyles = { width: '100%', minWidth: '80px', fontSize: '10px' };
18
18
  export default function SpectrumSimulationSimpleOptions({ onSpinSystemChange, spinSystem, }) {
19
19
  return (_jsxs("div", { style: {
20
20
  display: 'flex',
@@ -29,6 +29,7 @@ export function getDefaultViewState() {
29
29
  activeSpectra: {},
30
30
  activeTab: '',
31
31
  showLegend: false,
32
+ showSimilarityTree: false,
32
33
  selectReferences: {},
33
34
  },
34
35
  zoom: {
@@ -395,6 +396,8 @@ function innerSpectrumReducer(draft, action) {
395
396
  return DatabaseActions.handleResurrectSpectrumFromRanges(draft, action);
396
397
  case 'RESURRECTING_SPECTRUM_FROM_JCAMP':
397
398
  return DatabaseActions.handleResurrectSpectrumFromJcamp(draft, action);
399
+ case 'TOGGLE_SIMILARITY_TREE':
400
+ return DatabaseActions.handleToggleSimilarityTree(draft);
398
401
  case 'SET_AUTOMATIC_ASSIGNMENTS':
399
402
  return AssignmentsActions.handleSetAutomaticAssignments(draft, action);
400
403
  case 'SECRET_THROW_ERROR': {
@@ -12,7 +12,8 @@ type ResurrectSpectrumFromRangesAction = ActionType<'RESURRECTING_SPECTRUM_FROM_
12
12
  ranges: NMRRange[];
13
13
  info: ResurrectSpectrumInfo;
14
14
  }>;
15
- export type DatabaseActions = ResurrectSpectrumFromJcampAction | ResurrectSpectrumFromRangesAction;
15
+ export type DatabaseActions = ActionType<'TOGGLE_SIMILARITY_TREE'> | ResurrectSpectrumFromJcampAction | ResurrectSpectrumFromRangesAction;
16
16
  declare function handleResurrectSpectrumFromJcamp(draft: Draft<State>, action: ResurrectSpectrumFromJcampAction): void;
17
17
  declare function handleResurrectSpectrumFromRanges(draft: Draft<State>, action: ResurrectSpectrumFromRangesAction): void;
18
- export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp };
18
+ declare function handleToggleSimilarityTree(draft: Draft<State>): void;
19
+ export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp, handleToggleSimilarityTree, };
@@ -29,4 +29,8 @@ function handleResurrectSpectrumFromRanges(draft, action) {
29
29
  setZoom(draft, { scale: 0.8, spectrumID: datum.id });
30
30
  }
31
31
  }
32
- export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp };
32
+ function handleToggleSimilarityTree(draft) {
33
+ draft.view.spectra.showSimilarityTree =
34
+ !draft.view.spectra.showSimilarityTree;
35
+ }
36
+ export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp, handleToggleSimilarityTree, };
@@ -18,14 +18,14 @@ export interface ClipboardFallbackProps extends CFBP, Partial<Omit<ClipboardFall
18
18
  *
19
19
  * @param props
20
20
  */
21
- export declare function ClipboardFallback(props: ClipboardFallbackProps): import("react/jsx-runtime").JSX.Element | null;
21
+ export declare function ClipboardFallback(props: ClipboardFallbackProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
22
22
  /**
23
23
  * return null if !props.mode
24
24
  *
25
25
  * @param props
26
26
  * @see ClipboardFallback
27
27
  */
28
- export declare function ClipboardFallbackModal(props: ClipboardFallbackProps): import("react/jsx-runtime").JSX.Element | null;
28
+ export declare function ClipboardFallbackModal(props: ClipboardFallbackProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
29
29
  interface ClipboardFallbackReadProps extends CFBP {
30
30
  onRead: (file: File) => void;
31
31
  mode: 'read';
@@ -1,7 +1,9 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Dialog, DialogBody } from '@blueprintjs/core';
4
+ import { css } from '@emotion/react';
2
5
  import styled from '@emotion/styled';
3
6
  import { useCallback, useEffect, useMemo, useRef } from 'react';
4
- import { Modal } from 'react-science/ui';
5
7
  import Button from '../../component/elements/Button';
6
8
  const ClipboardForm = styled.form `
7
9
  padding: 0.5rem;
@@ -90,7 +92,10 @@ export function ClipboardFallbackModal(props) {
90
92
  write: `Export data to file`,
91
93
  writeText: `Copy text from text area`,
92
94
  };
93
- return (_jsxs(Modal, { hasCloseButton: true, isOpen: true, onRequestClose: props.onDismiss, children: [_jsx(Modal.Header, { children: _jsx("h2", { children: titles[props.mode] }) }), _jsx(Modal.Body, { children: _jsx(ClipboardFallback, { ...props }) })] }));
95
+ return (_jsx(Dialog, { isOpen: true, onClose: props.onDismiss, title: titles[props.mode], children: _jsx(DialogBody, { css: css `
96
+ padding: 0;
97
+ background-color: white;
98
+ `, children: _jsx(ClipboardFallback, { ...props }) }) }));
94
99
  }
95
100
  function ClipboardFallbackRead(props) {
96
101
  const onFileRef = useRef(props.onRead);
@@ -1 +1 @@
1
- export default { version: 'v0.49.0' };
1
+ export default { version: 'v0.50.0' };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "0.49.0",
4
+ "version": "0.50.0",
5
5
  "license": "MIT",
6
6
  "module": "lib/component/main/index.js",
7
7
  "types": "lib/component/main/index.d.ts",
@@ -83,16 +83,17 @@
83
83
  "ml-conrec": "^5.0.2",
84
84
  "ml-gsd": "^12.1.3",
85
85
  "ml-matrix": "^6.11.0",
86
- "ml-spectra-processing": "^12.10.1",
86
+ "ml-spectra-processing": "^12.10.2",
87
87
  "ml-stat": "^1.3.3",
88
+ "ml-tree-similarity": "^2.2.0",
88
89
  "multiplet-analysis": "^2.1.2",
89
90
  "nmr-correlation": "^2.3.3",
90
- "nmr-load-save": "^0.26.0",
91
- "nmr-processing": "^11.10.0",
91
+ "nmr-load-save": "^0.27.2",
92
+ "nmr-processing": "^11.10.1",
92
93
  "nmredata": "^0.9.9",
93
94
  "numeral": "^2.0.6",
94
95
  "openchemlib": "^8.8.1",
95
- "openchemlib-utils": "^5.8.0",
96
+ "openchemlib-utils": "^5.9.0",
96
97
  "papaparse": "^5.4.1",
97
98
  "re-resizable": "6.9.11",
98
99
  "react-d3-utils": "^1.0.0",
@@ -105,7 +106,7 @@
105
106
  "react-ocl-nmr": "^3.0.1",
106
107
  "react-plot": "^1.4.2",
107
108
  "react-rnd": "^10.4.1",
108
- "react-science": "^0.32.2",
109
+ "react-science": "^0.35.0",
109
110
  "react-slider": "^2.0.6",
110
111
  "react-table": "^7.8.0",
111
112
  "react-transition-group": "^4.4.5",
@@ -121,32 +122,32 @@
121
122
  "@simbathesailor/use-what-changed": "^2.0.0",
122
123
  "@types/d3": "^7.4.3",
123
124
  "@types/lodash": "^4.14.202",
124
- "@types/node": "^20.11.16",
125
+ "@types/node": "^20.11.19",
125
126
  "@types/papaparse": "^5.3.14",
126
- "@types/react": "^18.2.51",
127
- "@types/react-dom": "^18.2.18",
127
+ "@types/react": "^18.2.57",
128
+ "@types/react-dom": "^18.2.19",
128
129
  "@types/react-table": "^7.7.19",
129
130
  "@vitejs/plugin-react-swc": "^3.6.0",
130
- "@vitest/coverage-v8": "^1.2.2",
131
+ "@vitest/coverage-v8": "^1.3.1",
131
132
  "cross-env": "^7.0.3",
132
- "cspell": "^8.3.2",
133
+ "cspell": "^8.4.1",
133
134
  "eslint": "^8.56.0",
134
135
  "eslint-config-cheminfo-react": "^10.1.0",
135
- "eslint-config-cheminfo-typescript": "^12.1.0",
136
+ "eslint-config-cheminfo-typescript": "^12.2.0",
136
137
  "modern-normalize": "^2.0.0",
137
138
  "postcss-styled-syntax": "^0.6.4",
138
- "prettier": "^3.2.4",
139
+ "prettier": "^3.2.5",
139
140
  "rc-menu": "^9.12.4",
140
141
  "react": "^18.2.0",
141
142
  "react-dom": "^18.2.0",
142
- "react-router-dom": "^6.22.0",
143
+ "react-router-dom": "^6.22.1",
143
144
  "rimraf": "^5.0.5",
144
145
  "rollup-plugin-analyzer": "^4.0.0",
145
146
  "serve": "^14.2.1",
146
147
  "stylelint": "^16.2.1",
147
148
  "stylelint-config-standard": "^36.0.0",
148
149
  "typescript": "^5.3.3",
149
- "vite": "^5.0.12",
150
- "vitest": "^1.2.2"
150
+ "vite": "^5.1.3",
151
+ "vitest": "^1.3.1"
151
152
  }
152
153
  }
@@ -1,8 +0,0 @@
1
- import { Signal1D } from 'nmr-processing';
2
- interface LevelNodeProps {
3
- signal: Signal1D;
4
- startY: number;
5
- levelHeight: number;
6
- }
7
- declare function LevelNode({ signal, startY, levelHeight }: LevelNodeProps): import("react/jsx-runtime").JSX.Element;
8
- export default LevelNode;
@@ -1,8 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useScaleChecked } from '../../context/ScaleContext';
3
- import { TREE_LEVEL_COLORS } from './TreeColors';
4
- function LevelNode({ signal, startY, levelHeight }) {
5
- const { scaleX } = useScaleChecked();
6
- return (_jsx("line", { x1: scaleX()(signal.delta), y1: startY, x2: scaleX()(signal.delta), y2: startY + levelHeight, stroke: TREE_LEVEL_COLORS[0] }, `startLevelNode_${signal.id}`));
7
- }
8
- export default LevelNode;
@@ -1,11 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- import { Signal1D } from 'nmr-processing';
3
- interface StringNodeProps {
4
- signal: Signal1D;
5
- startY: number;
6
- levelHeight: number;
7
- fontSize: CSSProperties['fontSize'];
8
- showLabels: boolean;
9
- }
10
- declare function StringNode({ signal, startY, levelHeight, fontSize, showLabels, }: StringNodeProps): import("react/jsx-runtime").JSX.Element;
11
- export default StringNode;
@@ -1,7 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useScaleChecked } from '../../context/ScaleContext';
3
- function StringNode({ signal, startY, levelHeight, fontSize, showLabels, }) {
4
- const { scaleX } = useScaleChecked();
5
- return (_jsx("text", { textAnchor: "middle", x: scaleX()(signal.delta), y: startY + levelHeight / 2, fontSize: fontSize, lengthAdjust: "spacing", fill: "black", visibility: showLabels ? 'visible' : 'hidden', children: signal.multiplicity }, `multiplicityString_${signal.id}`));
6
- }
7
- export default StringNode;
@@ -1 +0,0 @@
1
- export declare const TREE_LEVEL_COLORS: string[];
@@ -1 +0,0 @@
1
- export const TREE_LEVEL_COLORS = ['red', 'green', 'blue', 'magenta'];
@@ -1,21 +0,0 @@
1
- import { CSSProperties } from 'react';
2
- interface NodeData {
3
- startX: number;
4
- _startX: number;
5
- ratio: number;
6
- multiplicityIndex: number;
7
- color: string;
8
- }
9
- interface TreeNodesProps {
10
- showLabels: boolean;
11
- startY: number;
12
- signalID: string;
13
- levelHeight: number;
14
- nodesData: NodeData[];
15
- labelOptions: {
16
- distance: number;
17
- fontSize: CSSProperties['fontSize'];
18
- };
19
- }
20
- declare function TreeNodes({ nodesData, levelHeight, startY, signalID, labelOptions, showLabels, }: TreeNodesProps): import("react/jsx-runtime").JSX.Element;
21
- export default TreeNodes;
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /* eslint-disable react/no-unused-prop-types */
3
- import { useCallback } from 'react';
4
- import { useScaleChecked } from '../../context/ScaleContext';
5
- function TreeNodes({ nodesData, levelHeight, startY, signalID, labelOptions, showLabels, }) {
6
- const { scaleX } = useScaleChecked();
7
- const buildTreeNodeAndEdge = useCallback(({ startX, _startX, ratio, multiplicityIndex, color }) => {
8
- const edgeLevel = 2 * multiplicityIndex + 2;
9
- const _startYEdge = startY + edgeLevel * levelHeight;
10
- const _startYNode = startY + (edgeLevel + 1) * levelHeight;
11
- return (_jsxs("g", { children: [_jsx("text", { textAnchor: "middle", x: scaleX()(_startX) + labelOptions.distance, y: _startYNode + 2 * (levelHeight / 3), fontSize: labelOptions.fontSize, fill: color, visibility: showLabels ? 'visible' : 'hidden', children: ratio }), _jsx("line", { x1: scaleX()(startX), y1: _startYEdge, x2: scaleX()(_startX), y2: _startYNode, stroke: color }), _jsx("line", { x1: scaleX()(_startX), y1: _startYNode, x2: scaleX()(_startX), y2: _startYNode + levelHeight, stroke: color })] }, `${multiplicityIndex}_${signalID}_${startX}_${_startX}_${ratio}`));
12
- }, [
13
- signalID,
14
- labelOptions.distance,
15
- labelOptions.fontSize,
16
- scaleX,
17
- showLabels,
18
- startY,
19
- levelHeight,
20
- ]);
21
- return _jsx(_Fragment, { children: nodesData?.map((node) => buildTreeNodeAndEdge(node)) });
22
- }
23
- export default TreeNodes;
@@ -1,11 +0,0 @@
1
- import { Spectrum1D } from 'nmr-load-save';
2
- import { Signal1D } from 'nmr-processing';
3
- export interface TreeNodeData {
4
- startX: number;
5
- _startX: number;
6
- ratio: number;
7
- multiplicityIndex: number;
8
- color: string;
9
- }
10
- declare function createTreeNodes(signal: Signal1D, spectrumData: Spectrum1D): (multiplicityIndex: number, jIndices: number[], treeNodesData: TreeNodeData[], startX: number) => TreeNodeData[] | null;
11
- export default createTreeNodes;
@@ -1,57 +0,0 @@
1
- import lodashGet from 'lodash/get';
2
- import { getMultiplicityNumber, getPascal, } from '../../panels/extra/utilities/MultiplicityUtilities';
3
- import { TREE_LEVEL_COLORS } from './TreeColors';
4
- function createTreeNodes(signal, spectrumData) {
5
- function buildTreeNodesData(multiplicityIndex, jIndices, treeNodesData, startX) {
6
- if (!signal.multiplicity) {
7
- return null;
8
- }
9
- if (multiplicityIndex >= signal.multiplicity.length) {
10
- return treeNodesData;
11
- }
12
- // re-use colors if needed
13
- const color = TREE_LEVEL_COLORS[multiplicityIndex % TREE_LEVEL_COLORS.length];
14
- const jIndex = jIndices.indexOf(multiplicityIndex);
15
- const frequency = lodashGet(spectrumData, 'info.originFrequency', 0);
16
- const coupling = jIndex >= 0 && frequency > 0 && signal?.js?.[jIndex]
17
- ? signal.js[jIndex].coupling / frequency // convert to ppm
18
- : null;
19
- // in case of "s": no coupling constant and build one tree node only
20
- if (!coupling) {
21
- treeNodesData.push({
22
- startX,
23
- _startX: startX,
24
- ratio: 1,
25
- multiplicityIndex,
26
- color,
27
- });
28
- // go to next multiplet in multiplicity string
29
- buildTreeNodesData(multiplicityIndex + 1, jIndices, treeNodesData, startX);
30
- }
31
- else {
32
- // in case of other multiplets
33
- const multiplicity = signal.multiplicity || '';
34
- const pascal = getPascal(getMultiplicityNumber(multiplicity.charAt(multiplicityIndex)), 0.5); // @TODO for now we use the default spin of 1 / 2 only
35
- let _startX = pascal.length % 2 === 0
36
- ? startX - (pascal.length / 2) * coupling + coupling / 2 // in case of even number of nodes
37
- : startX - (pascal.length / 2 - 0.5) * coupling; // in case of odd number of nodes
38
- for (const [k, ratio] of pascal.entries()) {
39
- if (k > 0) {
40
- _startX += coupling;
41
- }
42
- treeNodesData.push({
43
- startX,
44
- _startX,
45
- ratio,
46
- multiplicityIndex,
47
- color,
48
- });
49
- // go to next multiplet in multiplicity string
50
- buildTreeNodesData(multiplicityIndex + 1, jIndices, treeNodesData, _startX);
51
- }
52
- }
53
- return treeNodesData;
54
- }
55
- return buildTreeNodesData;
56
- }
57
- export default createTreeNodes;