nmrium 0.45.1-pre.1701344673 → 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.
- package/lib/component/1d/tool/PeakPointer.js +6 -16
- package/lib/component/1d/utilities/scale.js +13 -8
- package/lib/component/1d-2d/components/SpectrumInfoBlock.js +15 -4
- package/lib/component/elements/ContextMenuBluePrint.d.ts +16 -0
- package/lib/component/elements/ContextMenuBluePrint.js +20 -0
- package/lib/component/elements/DropdownMenu.d.ts +9 -0
- package/lib/component/elements/DropdownMenu.js +7 -0
- package/lib/component/elements/Header.d.ts +1 -1
- package/lib/component/elements/Header.js +4 -6
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +2 -2
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +2 -2
- package/lib/component/elements/ReactTable/ReactTable.d.ts +5 -5
- package/lib/component/header/Header.js +3 -4
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -1
- package/lib/component/hooks/useToolsFunctions.js +2 -2
- package/lib/component/modal/MoleculeStructureEditorModal.d.ts +0 -8
- package/lib/component/modal/MoleculeStructureEditorModal.js +31 -8
- package/lib/component/modal/PredictSpectraModal.js +3 -2
- package/lib/component/modal/aboutUs/AboutUsModal.js +1 -5
- package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +1 -0
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +4 -1
- package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +1 -1
- package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +1 -1
- package/lib/component/modal/setting/settingsValidation.js +3 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +7 -14
- package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -2
- package/lib/component/panels/RangesPanel/RangesTable.d.ts +2 -2
- package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +2 -2
- package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +12 -17
- package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -2
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +2 -2
- package/lib/component/panels/extra/preferences/ColumnsHelper.js +1 -2
- package/lib/component/panels/filtersPanel/FiltersTable.js +1 -1
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +6 -2
- package/lib/component/reducer/actions/MoleculeActions.d.ts +4 -1
- package/lib/component/reducer/actions/MoleculeActions.js +6 -2
- package/lib/component/reducer/actions/PeaksActions.js +4 -3
- package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.d.ts +3 -0
- package/lib/component/reducer/actions/utilities/deepReplaceDiaIDs.js +24 -0
- package/lib/component/reducer/helper/Zoom1DManager.js +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +1 -1
- package/lib/component/toolbar/BasicToolBar.js +53 -34
- package/lib/component/toolbar/FunctionToolBar.js +102 -9
- package/lib/component/toolbar/ToolBar.js +1 -1
- package/lib/component/utility/getClosePeak.d.ts +10 -0
- package/lib/component/utility/getClosePeak.js +15 -0
- package/lib/component/utility/maxAbsoluteValue.d.ts +3 -0
- package/lib/component/utility/maxAbsoluteValue.js +21 -0
- package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/index.js +0 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
- package/lib/data/data1d/Spectrum1D/peaks/autoPeakPicking.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/addRange.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +2 -2
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
- package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib/data/parseMeta/mapErrors.js +3 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +39 -38
- package/lib/component/elements/ToolbarMenu.d.ts +0 -18
- package/lib/component/elements/ToolbarMenu.js +0 -102
- package/lib/component/elements/toggle/ToggleButton.d.ts +0 -13
- package/lib/component/elements/toggle/ToggleButton.js +0 -24
- package/lib/component/elements/toggle/ToggleButtonGroup.d.ts +0 -8
- package/lib/component/elements/toggle/ToggleButtonGroup.js +0 -48
- package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.d.ts +0 -17
- package/lib/data/data1d/Spectrum1D/peaks/lookupPeak.js +0 -18
- package/lib/data/data2d/Processing2D.d.ts +0 -32
- package/lib/data/data2d/Processing2D.js +0 -130
|
@@ -102,7 +102,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
102
102
|
if (Array.isArray(ranges?.values) && ranges.values.length > 0) {
|
|
103
103
|
const { originFrequency: observedFrequency, nucleus } = info;
|
|
104
104
|
const result = rangesToACS(ranges.values, {
|
|
105
|
-
nucleus,
|
|
105
|
+
nucleus, // '19f'
|
|
106
106
|
deltaFormat: rangesPreferences.deltaPPM.format,
|
|
107
107
|
couplingFormat: rangesPreferences.coupling.format,
|
|
108
108
|
observedFrequency, //400
|
|
@@ -19,8 +19,7 @@ import RangesPreferences from './RangesPreferences';
|
|
|
19
19
|
import RangesTable from './RangesTable';
|
|
20
20
|
const rangesContextMenuOptions = [
|
|
21
21
|
{
|
|
22
|
-
|
|
23
|
-
type: 'option',
|
|
22
|
+
text: 'Copy to Clipboard',
|
|
24
23
|
icon: _jsx(FaCopy, {}),
|
|
25
24
|
},
|
|
26
25
|
];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkSpacePanelPreferences } from 'nmr-load-save';
|
|
2
2
|
import { Info1D } from 'nmr-processing';
|
|
3
|
-
import {
|
|
4
|
-
interface RangesTableProps extends
|
|
3
|
+
import { TableContextMenuProps } from '../../elements/ReactTable/ReactTable';
|
|
4
|
+
interface RangesTableProps extends TableContextMenuProps {
|
|
5
5
|
onUnlink: (a: any, b?: any) => void;
|
|
6
6
|
preferences: WorkSpacePanelPreferences['ranges'];
|
|
7
7
|
tableData: any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WorkSpacePanelPreferences } from 'nmr-load-save';
|
|
2
2
|
import { Info1D } from 'nmr-processing';
|
|
3
3
|
import { CSSProperties } from 'react';
|
|
4
|
-
import {
|
|
4
|
+
import { TableContextMenuProps } from '../../elements/ReactTable/ReactTable';
|
|
5
5
|
import { RangeData } from './hooks/useMapRanges';
|
|
6
|
-
interface RangesTableRowProps extends
|
|
6
|
+
interface RangesTableRowProps extends TableContextMenuProps {
|
|
7
7
|
rowData: any;
|
|
8
8
|
onUnlink: (a: any, b?: any) => void;
|
|
9
9
|
preferences: WorkSpacePanelPreferences['ranges'];
|
|
@@ -3,9 +3,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/reac
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import lodashGet from 'lodash/get';
|
|
5
5
|
import { useMemo, useCallback } from 'react';
|
|
6
|
-
import { DropdownMenu } from 'react-science/ui';
|
|
7
6
|
import { useAssignment, useAssignmentData, } from '../../assignment/AssignmentsContext';
|
|
8
7
|
import { filterForIDsWithAssignment } from '../../assignment/utilities/filterForIDsWithAssignment';
|
|
8
|
+
import { ContextMenu } from '../../elements/ContextMenuBluePrint';
|
|
9
9
|
import { HighlightEventSource, useHighlight, useHighlightData, } from '../../highlight';
|
|
10
10
|
import AbsoluteColumn from './TableColumns/AbsoluteColumn';
|
|
11
11
|
import ActionsColumn from './TableColumns/ActionsColumn';
|
|
@@ -103,7 +103,7 @@ function RangesTableRow({ rowData, onUnlink, onContextMenuSelect, contextMenu =
|
|
|
103
103
|
? ConstantlyHighlightedRowStyle
|
|
104
104
|
: null;
|
|
105
105
|
}, [assignmentRange.isActive, highlightRange.isActive, rowData]);
|
|
106
|
-
return (_jsxs(
|
|
106
|
+
return (_jsxs(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, rowData), as: "tr", css: trCss, children: [preferences.showSerialNumber && (_jsx("td", { ...rowSpanTags, ...onHoverRange, children: rowData.tableMetaInfo.rowIndex + 1 })), preferences.from.show && (_jsx(RangeColumn, { value: rowData.from, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.from.format })), preferences.to.show && (_jsx(RangeColumn, { value: rowData.to, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.to.format })), preferences.deltaPPM.show && (_jsx(SignalDeltaColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaPPM.format })), preferences.deltaHz.show && (_jsx(SignalDeltaHzColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverSignal, format: preferences.deltaHz.format, info: info })), preferences.relative.show && (_jsx(RelativeColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.relative.format })), preferences.absolute.show && (_jsx(AbsoluteColumn, { row: rowData, rowSpanTags: rowSpanTags, onHover: onHoverRange, format: preferences.absolute.format })), preferences.showMultiplicity && (_jsx("td", { ...onHoverSignal, children: !rowData?.tableMetaInfo?.signal
|
|
107
107
|
? 'm'
|
|
108
108
|
: lodashGet(rowData, 'tableMetaInfo.signal.multiplicity', '') })), preferences.coupling.show && (_jsx(CouplingColumn, { row: rowData, onHover: onHoverSignal, format: preferences.coupling.format })), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx(SignalAssignmentsColumn, { row: rowData, assignment: assignmentSignal, highlight: highlightSignal, onHover: onHoverSignal, onLink: linkHandler, onUnlink: unlinkHandler }), _jsx(RangeAssignmentsColumn, { row: rowData, assignment: assignmentRange, highlight: highlightRangeAssignmentsColumn, onHover: onHoverRangeAssignmentsColumn, onLink: linkHandler, onUnlink: unlinkHandler, rowSpanTags: rowSpanTags, highlightData: highlightData })] })), _jsx(ActionsColumn, { row: rowData, onHoverSignal: onHoverSignal, onHoverRange: onHoverRange, rowSpanTags: rowSpanTags, showKind: preferences.showKind, showDeleteAction: preferences.showDeleteAction, showEditAction: preferences.showEditAction, showZoomAction: preferences.showZoomAction })] }));
|
|
109
109
|
}
|
|
@@ -3,10 +3,10 @@ import lodashGet from 'lodash/get';
|
|
|
3
3
|
import { useMemo, useCallback, useState } from 'react';
|
|
4
4
|
import { FaCopy, FaRegTrashAlt, FaFileExport } from 'react-icons/fa';
|
|
5
5
|
import { IoColorPaletteOutline } from 'react-icons/io5';
|
|
6
|
-
import { DropdownMenu } from 'react-science/ui';
|
|
7
6
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
8
7
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
9
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
|
+
import { ContextMenu, } from '../../elements/ContextMenuBluePrint';
|
|
10
10
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
11
11
|
import { useAlert } from '../../elements/popup/Alert';
|
|
12
12
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
@@ -37,8 +37,7 @@ const columnStyle = {
|
|
|
37
37
|
};
|
|
38
38
|
const options = [
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
type: 'option',
|
|
40
|
+
text: 'Recolor based on distinct value',
|
|
42
41
|
icon: _jsx(IoColorPaletteOutline, {}),
|
|
43
42
|
},
|
|
44
43
|
];
|
|
@@ -50,20 +49,17 @@ var SpectraContextMenuOptionsKeys;
|
|
|
50
49
|
})(SpectraContextMenuOptionsKeys || (SpectraContextMenuOptionsKeys = {}));
|
|
51
50
|
const Spectra2DContextMenuOptions = [
|
|
52
51
|
{
|
|
53
|
-
|
|
54
|
-
type: 'option',
|
|
52
|
+
text: 'Copy to Clipboard',
|
|
55
53
|
icon: _jsx(FaCopy, {}),
|
|
56
54
|
data: { id: SpectraContextMenuOptionsKeys.CopyToClipboard },
|
|
57
55
|
},
|
|
58
56
|
{
|
|
59
|
-
|
|
60
|
-
type: 'option',
|
|
57
|
+
text: 'Delete',
|
|
61
58
|
icon: _jsx(FaRegTrashAlt, {}),
|
|
62
59
|
data: { id: SpectraContextMenuOptionsKeys.Delete },
|
|
63
60
|
},
|
|
64
61
|
{
|
|
65
|
-
|
|
66
|
-
type: 'option',
|
|
62
|
+
text: 'Export as jcamp',
|
|
67
63
|
icon: _jsx(FaFileExport, {}),
|
|
68
64
|
data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
|
|
69
65
|
},
|
|
@@ -71,8 +67,7 @@ const Spectra2DContextMenuOptions = [
|
|
|
71
67
|
const Spectra1DContextMenuOptions = [
|
|
72
68
|
...Spectra2DContextMenuOptions,
|
|
73
69
|
{
|
|
74
|
-
|
|
75
|
-
type: 'option',
|
|
70
|
+
text: 'Export as jcamp',
|
|
76
71
|
icon: _jsx(FaFileExport, {}),
|
|
77
72
|
data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
|
|
78
73
|
},
|
|
@@ -135,7 +130,7 @@ export function SpectraTable(props) {
|
|
|
135
130
|
}), [onChangeVisibility, onOpenSettingModal]);
|
|
136
131
|
const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = useClipboard();
|
|
137
132
|
const selectContextMenuHandler = useCallback((option, spectrum) => {
|
|
138
|
-
const { id } = option
|
|
133
|
+
const { id } = option;
|
|
139
134
|
switch (id) {
|
|
140
135
|
case SpectraContextMenuOptionsKeys.CopyToClipboard: {
|
|
141
136
|
void (async () => {
|
|
@@ -225,9 +220,9 @@ const ColumnHeader = ({ label, col, }) => {
|
|
|
225
220
|
});
|
|
226
221
|
}
|
|
227
222
|
}
|
|
228
|
-
return (_jsx(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
223
|
+
return (_jsx(ContextMenu, { options: options, onSelect: selectHandler, style: {
|
|
224
|
+
whiteSpace: 'nowrap',
|
|
225
|
+
overflow: 'hidden',
|
|
226
|
+
textOverflow: 'ellipsis',
|
|
227
|
+
}, children: label }));
|
|
233
228
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
import { Axis } from '../../assignment/AssignmentsContext';
|
|
3
|
-
import {
|
|
3
|
+
import { TableContextMenuProps } from '../../elements/ReactTable/ReactTable';
|
|
4
4
|
import { ZoneData } from './hooks/useMapZones';
|
|
5
|
-
interface ZonesTableRowProps extends
|
|
5
|
+
interface ZonesTableRowProps extends TableContextMenuProps {
|
|
6
6
|
rowData: ZoneData;
|
|
7
7
|
onUnlink: (rowData: ZoneData, isOnZoneLevel: boolean, signalIndex: any, axis: Axis) => void;
|
|
8
8
|
rowIndex: number;
|
|
@@ -2,9 +2,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/reac
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import lodashGet from 'lodash/get';
|
|
4
4
|
import { useMemo, useCallback } from 'react';
|
|
5
|
-
import { DropdownMenu } from 'react-science/ui';
|
|
6
5
|
import { buildID } from '../../../data/utilities/Concatenation';
|
|
7
6
|
import { useAssignment, } from '../../assignment/AssignmentsContext';
|
|
7
|
+
import { ContextMenu } from '../../elements/ContextMenuBluePrint';
|
|
8
8
|
import { useHighlight } from '../../highlight';
|
|
9
9
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
10
10
|
import ActionsColumn from './TableColumns/ActionsColumn';
|
|
@@ -115,7 +115,7 @@ function ZonesTableRow({ rowData, onUnlink, contextMenu = [], onContextMenuSelec
|
|
|
115
115
|
},
|
|
116
116
|
};
|
|
117
117
|
}, [assignmentSignal, highlightSignalY]);
|
|
118
|
-
return (_jsxs(
|
|
118
|
+
return (_jsxs(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, rowData), as: "tr", style: highlightZone.isActive || assignmentZone.isActive
|
|
119
119
|
? HighlightedRowStyle
|
|
120
120
|
: lodashGet(rowData, 'tableMetaInfo.isConstantlyHighlighted', false)
|
|
121
121
|
? ConstantlyHighlightedRowStyle
|
|
@@ -23,8 +23,7 @@ export default class ColumnsHelper {
|
|
|
23
23
|
const preferences = this.preferences || this.defaultPreference;
|
|
24
24
|
if (this.checkPreferences(preferences, flagKey)) {
|
|
25
25
|
this.setCustomColumn(columns, columnIndex, columnLabel, (row) => {
|
|
26
|
-
const format = preferences &&
|
|
27
|
-
Object.prototype.hasOwnProperty.call(preferences, formatKey)
|
|
26
|
+
const format = preferences && Object.hasOwn(preferences, formatKey)
|
|
28
27
|
? preferences[formatKey]
|
|
29
28
|
: this.defaultPreference[formatKey];
|
|
30
29
|
const { formatPrefix = '', formatSuffix = '', showPrefixSuffixCallback = () => true, } = options;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Checkbox } from '@blueprintjs/core';
|
|
2
3
|
import { useMemo, useCallback, memo, useRef } from 'react';
|
|
3
4
|
import { FaRegTrashAlt } from 'react-icons/fa';
|
|
4
5
|
import { ObjectInspector } from 'react-inspector';
|
|
5
|
-
import { Checkbox } from 'react-science/ui';
|
|
6
6
|
import { useChartData } from '../../context/ChartContext';
|
|
7
7
|
import { useDispatch } from '../../context/DispatchContext';
|
|
8
8
|
import Button from '../../elements/Button';
|
|
@@ -85,7 +85,9 @@ function columnSchema(columns) {
|
|
|
85
85
|
for (const key in colsFrequency) {
|
|
86
86
|
const indexes = colsFrequency[key];
|
|
87
87
|
if (indexes.length > 1) {
|
|
88
|
-
errors.push(new Yup.ValidationError(`${key} nucleus must te be unique`, key,
|
|
88
|
+
errors.push(new Yup.ValidationError(`${key} nucleus must te be unique`, key,
|
|
89
|
+
// eslint-disable-next-line no-invalid-this
|
|
90
|
+
this.path));
|
|
89
91
|
}
|
|
90
92
|
}
|
|
91
93
|
return new Yup.ValidationError(errors);
|
|
@@ -95,7 +97,9 @@ function columnSchema(columns) {
|
|
|
95
97
|
for (const column of columns) {
|
|
96
98
|
if (column?.type === AnalysisColumnsTypes.FORMULA &&
|
|
97
99
|
(!column.formula || column.formula === '')) {
|
|
98
|
-
errors.push(new Yup.ValidationError(`${column.tempKey} formula value is required`, column.formula,
|
|
100
|
+
errors.push(new Yup.ValidationError(`${column.tempKey} formula value is required`, column.formula,
|
|
101
|
+
// eslint-disable-next-line no-invalid-this
|
|
102
|
+
this.path));
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
return new Yup.ValidationError(errors);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FifoLogger } from 'fifo-logger';
|
|
2
2
|
import { Draft } from 'immer';
|
|
3
|
+
import { TopicMolecule } from 'openchemlib-utils';
|
|
3
4
|
import { PredictedSpectraResult, PredictionOptions } from '../../../data/PredictionManager';
|
|
4
5
|
import { MoleculeBoundingRect, StateMolecule } from '../../../data/molecules/Molecule';
|
|
5
6
|
import { AssignmentContext } from '../../assignment/AssignmentsContext';
|
|
@@ -13,7 +14,9 @@ type AddMoleculeAction = ActionType<'ADD_MOLECULE', AddMoleculeProps>;
|
|
|
13
14
|
type AddMoleculesAction = ActionType<'ADD_MOLECULES', {
|
|
14
15
|
molecules: StateMolecule[];
|
|
15
16
|
}>;
|
|
16
|
-
type SetMoleculeAction = ActionType<'SET_MOLECULE', Required<StateMolecule
|
|
17
|
+
type SetMoleculeAction = ActionType<'SET_MOLECULE', Required<StateMolecule> & {
|
|
18
|
+
mappings?: ReturnType<TopicMolecule['getDiaIDsMapping']>;
|
|
19
|
+
}>;
|
|
17
20
|
type DeleteMoleculeAction = ActionType<'DELETE_MOLECULE', {
|
|
18
21
|
id: string;
|
|
19
22
|
assignmentData: AssignmentContext;
|
|
@@ -9,6 +9,7 @@ import { MARGIN } from '../core/Constants';
|
|
|
9
9
|
import { unlinkRange } from './RangesActions';
|
|
10
10
|
import { setActiveTab } from './ToolsActions';
|
|
11
11
|
import { unlinkZone } from './ZonesActions';
|
|
12
|
+
import { deepReplaceDiaIDs } from './utilities/deepReplaceDiaIDs';
|
|
12
13
|
function addMolecule(draft, props) {
|
|
13
14
|
const { molfile, floatMoleculeOnSave } = props;
|
|
14
15
|
const isEmpty = draft.molecules.length === 0;
|
|
@@ -38,7 +39,7 @@ function handleAddMolecules(draft, action) {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
function setMolecule(draft, props) {
|
|
41
|
-
const { id, label, molfile } = props;
|
|
42
|
+
const { id, label, molfile, mappings } = props;
|
|
42
43
|
MoleculeManager.setMolfile(draft.molecules, {
|
|
43
44
|
id,
|
|
44
45
|
label,
|
|
@@ -48,6 +49,9 @@ function setMolecule(draft, props) {
|
|
|
48
49
|
* update all spectra that its sum was based on this molecule with the new molecule
|
|
49
50
|
*/
|
|
50
51
|
const index = draft.molecules.findIndex((molecule) => molecule.id === id);
|
|
52
|
+
if (mappings) {
|
|
53
|
+
deepReplaceDiaIDs(draft, mappings);
|
|
54
|
+
}
|
|
51
55
|
changeSpectraRelativeSum(draft, id, index !== -1 ? draft.molecules[index] : draft.molecules[0] || null);
|
|
52
56
|
}
|
|
53
57
|
//action
|
|
@@ -193,7 +197,7 @@ function getFloatingMoleculeInitialPosition(id, draft) {
|
|
|
193
197
|
const columns = Math.floor(width / baseWidth);
|
|
194
198
|
const rows = Math.floor(height / baseHeight);
|
|
195
199
|
const moleculeKeys = Object.keys(molecules);
|
|
196
|
-
let index
|
|
200
|
+
let index;
|
|
197
201
|
if (!molecules[id]) {
|
|
198
202
|
index = moleculeKeys.length - 1;
|
|
199
203
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { v4 } from '@lukeed/uuid';
|
|
2
2
|
import { original } from 'immer';
|
|
3
3
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
4
|
-
import { getShiftX,
|
|
4
|
+
import { getShiftX, autoPeakPicking, optimizePeaks, } from '../../../data/data1d/Spectrum1D';
|
|
5
5
|
import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
|
|
6
6
|
import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
|
|
7
7
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
8
8
|
import getRange from '../helper/getRange';
|
|
9
|
+
import { getClosePeak } from '../../utility/getClosePeak';
|
|
9
10
|
//action
|
|
10
11
|
function handleAddPeak(draft, action) {
|
|
11
12
|
const { x: mouseXPosition } = action.payload;
|
|
@@ -17,7 +18,7 @@ function handleAddPeak(draft, action) {
|
|
|
17
18
|
const startX = mouseXPosition - xShift;
|
|
18
19
|
const endX = mouseXPosition + xShift;
|
|
19
20
|
const [from, to] = getRange(draft, { startX, endX });
|
|
20
|
-
const candidatePeak =
|
|
21
|
+
const candidatePeak = getClosePeak(state.data[index], {
|
|
21
22
|
from,
|
|
22
23
|
to,
|
|
23
24
|
});
|
|
@@ -44,7 +45,7 @@ function handleAddPeaks(draft, action) {
|
|
|
44
45
|
const { startX, endX } = action.payload;
|
|
45
46
|
const [from, to] = getRange(draft, { startX, endX });
|
|
46
47
|
if (from !== to) {
|
|
47
|
-
const peak =
|
|
48
|
+
const peak = getClosePeak(datumOriginal, { from, to });
|
|
48
49
|
const shiftX = getShiftX(draft.data[index]);
|
|
49
50
|
if (peak && !datumOriginal.peaks.values.some((p) => p.x === peak.x)) {
|
|
50
51
|
const newPeak = {
|
|
@@ -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)
|
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
+
text: 'Export as SVG',
|
|
54
|
+
data: {
|
|
55
|
+
id: 'svg',
|
|
56
|
+
},
|
|
46
57
|
},
|
|
47
58
|
{
|
|
48
|
-
id: 'png',
|
|
49
59
|
icon: _jsx(FaFileImage, {}),
|
|
50
|
-
|
|
60
|
+
text: 'Export as PNG',
|
|
61
|
+
data: {
|
|
62
|
+
id: 'png',
|
|
63
|
+
},
|
|
51
64
|
},
|
|
52
65
|
{
|
|
53
|
-
id: 'json',
|
|
54
66
|
icon: _jsx(FaFileDownload, {}),
|
|
55
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
+
text: 'Save NMRE data',
|
|
82
|
+
data: {
|
|
83
|
+
id: 'nmre',
|
|
84
|
+
},
|
|
66
85
|
},
|
|
67
86
|
{
|
|
68
|
-
id: 'copy',
|
|
69
87
|
icon: _jsx(FaCopy, {}),
|
|
70
|
-
|
|
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((
|
|
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((
|
|
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(
|
|
144
|
-
importHandler(
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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",
|
|
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() {
|