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.
- 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/elements/Select.js +11 -4
- package/lib/component/header/Header.js +3 -4
- package/lib/component/hooks/useActiveSpectrumIntegralsViewState.js +3 -1
- package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +3 -1
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +3 -1
- package/lib/component/hooks/useActiveSpectrumStyleOptions.js +6 -2
- package/lib/component/hooks/useActiveSpectrumZonesViewState.js +3 -1
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -1
- package/lib/component/hooks/useSaveSettings.js +1 -1
- package/lib/component/hooks/useSpectrum.js +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/MultipletAnalysisModal.d.ts +1 -2
- 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/MatrixGenerationPanel/FiltersOptions.js +7 -2
- 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/SpectraPanelHeader.js +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectraTable.d.ts +1 -2
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +15 -18
- package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -2
- 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/Reducer.d.ts +0 -4
- package/lib/component/reducer/actions/FiltersActions.d.ts +2 -1
- package/lib/component/reducer/actions/FiltersActions.js +1 -1
- 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/SpectrumsActions.js +1 -0
- package/lib/component/reducer/actions/ToolsActions.js +8 -6
- 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/helper/getActiveSpectra.js +2 -1
- package/lib/component/reducer/helper/getActiveSpectrum.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/data/utilities/generateNumbersPowerOfX.js +1 -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
|
@@ -221,7 +221,7 @@ function GeneralSettingsModal({ height }) {
|
|
|
221
221
|
function handlePastWorkspaceAction() {
|
|
222
222
|
void readText().then(handlePastWorkspace);
|
|
223
223
|
}
|
|
224
|
-
return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { id: "general-settings", onClick: openDialog, title: "General settings",
|
|
224
|
+
return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { id: "general-settings", onClick: openDialog, title: "General settings", icon: _jsx(FaWrench, {}) }), _jsxs(Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, maxWidth: 1000, children: [_jsx(Modal.Header, { children: _jsxs("div", { style: {
|
|
225
225
|
display: 'flex',
|
|
226
226
|
flexDirection: 'column',
|
|
227
227
|
}, children: [_jsx("span", { children: "General Settings" }), _jsxs("div", { style: {
|
|
@@ -61,7 +61,7 @@ function InfoBlockTabContent() {
|
|
|
61
61
|
Header: 'Field',
|
|
62
62
|
style: { padding: 0, ...styles.column },
|
|
63
63
|
Cell: ({ row }) => {
|
|
64
|
-
return (_jsx(FormikInput, { name: `infoBlock.fields.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => paths?.[key] ||
|
|
64
|
+
return (_jsx(FormikInput, { name: `infoBlock.fields.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => paths?.[key] || key, mapValue: (paths) => convertPathArrayToString(paths), datalist: datalist }));
|
|
65
65
|
},
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -31,7 +31,9 @@ const formattingValidation = (obj) => object().shape({
|
|
|
31
31
|
const { value, fields } = nucleusFrequencies[key];
|
|
32
32
|
if (value > 1) {
|
|
33
33
|
for (const field of fields) {
|
|
34
|
-
errors.push(new ValidationError(`${key} nucleus must te be unique`, nuclei[key].name,
|
|
34
|
+
errors.push(new ValidationError(`${key} nucleus must te be unique`, nuclei[key].name,
|
|
35
|
+
// eslint-disable-next-line no-invalid-this
|
|
36
|
+
`${this.path}.${field}.name`));
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -12,7 +12,7 @@ import FormikInput from '../../elements/formik/FormikInput';
|
|
|
12
12
|
import FormikSelect from '../../elements/formik/FormikSelect';
|
|
13
13
|
import { DEFAULT_MATRIX_FILTERS, GroupPanelStyle, } from './MatrixGenerationPanel';
|
|
14
14
|
const inputStyle = {
|
|
15
|
-
input: { padding: '0.
|
|
15
|
+
input: { padding: '0.4em', width: '100%' },
|
|
16
16
|
};
|
|
17
17
|
export function FiltersOptions() {
|
|
18
18
|
const { values } = useFormikContext();
|
|
@@ -96,7 +96,12 @@ function FiltersPanelGroupHeader({ index, name }) {
|
|
|
96
96
|
function handleDelete(index) {
|
|
97
97
|
void setFieldValue('filters', values.filters.filter((_, i) => i !== index));
|
|
98
98
|
}
|
|
99
|
-
return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsxs("p", { style: {
|
|
99
|
+
return (_jsxs("div", { className: "section-header", style: { display: 'flex', padding: '5px 0px' }, children: [_jsxs("p", { style: {
|
|
100
|
+
flex: 1,
|
|
101
|
+
margin: 0,
|
|
102
|
+
paddingRight: '5px',
|
|
103
|
+
...GroupPanelStyle.header,
|
|
104
|
+
}, children: [index + 1, "-"] }), _jsx(Select, { value: name, items: DEFAULT_MATRIX_FILTERS, onChange: (value) => handelSelectFilter(value, index), style: { width: '100%' }, returnValue: false, itemTextField: "name", itemValueField: "name", textRender: (text) => normalCase(text) }), _jsxs("div", { style: { display: 'flex' }, children: [_jsx(Button.Danger, { fill: "outline", onClick: () => handleDelete(index), style: { marginLeft: '5px' }, children: _jsx(FaTimes, {}) }), _jsx(Button.Done, { fill: "outline", onClick: () => handleAdd(index + 1), style: { marginLeft: '5px' }, children: _jsx(FaPlus, {}) })] })] }));
|
|
100
105
|
}
|
|
101
106
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
102
107
|
function FieldInfo(props) {
|
|
@@ -3,7 +3,6 @@ import { Molecule as OCLMolecule } from 'openchemlib/full';
|
|
|
3
3
|
import { useCallback } from 'react';
|
|
4
4
|
import { FaCog, FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
|
|
5
5
|
import { IoOpenOutline } from 'react-icons/io5';
|
|
6
|
-
import { DropdownMenu } from 'react-science/ui';
|
|
7
6
|
import { getMolecules } from '../../../data/molecules/MoleculeManager';
|
|
8
7
|
import { ClipboardFallbackModal } from '../../../utils/clipboard/clipboardComponents';
|
|
9
8
|
import { useClipboard } from '../../../utils/clipboard/clipboardHooks';
|
|
@@ -12,6 +11,7 @@ import { useDispatch } from '../../context/DispatchContext';
|
|
|
12
11
|
import { useGlobal } from '../../context/GlobalContext';
|
|
13
12
|
import ActiveButton from '../../elements/ActiveButton';
|
|
14
13
|
import Button from '../../elements/Button';
|
|
14
|
+
import { DropdownMenu } from '../../elements/DropdownMenu';
|
|
15
15
|
import { useAlert } from '../../elements/popup/Alert';
|
|
16
16
|
import AboutPredictionModal from '../../modal/AboutPredictionModal';
|
|
17
17
|
import PredictSpectraModal from '../../modal/PredictSpectraModal';
|
|
@@ -34,38 +34,31 @@ const styles = {
|
|
|
34
34
|
lineHeight: 1,
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
-
const LabelWrapper = ({ children }) => {
|
|
38
|
-
return _jsx("p", { style: { padding: '0.4em' }, children: children });
|
|
39
|
-
};
|
|
40
37
|
const MOL_EXPORT_MENU = [
|
|
41
38
|
{
|
|
42
|
-
type: 'option',
|
|
43
39
|
icon: _jsx(FaCopy, {}),
|
|
44
|
-
|
|
40
|
+
text: 'Copy as molfile V3',
|
|
45
41
|
data: {
|
|
46
42
|
id: 'molfileV3',
|
|
47
43
|
},
|
|
48
44
|
},
|
|
49
45
|
{
|
|
50
|
-
type: 'option',
|
|
51
46
|
icon: _jsx(FaCopy, {}),
|
|
52
|
-
|
|
47
|
+
text: 'Copy as molfile V2',
|
|
53
48
|
data: {
|
|
54
49
|
id: 'molfileV2',
|
|
55
50
|
},
|
|
56
51
|
},
|
|
57
52
|
{
|
|
58
|
-
type: 'option',
|
|
59
53
|
icon: _jsx(FaFileImage, {}),
|
|
60
|
-
|
|
54
|
+
text: 'Copy as PNG',
|
|
61
55
|
data: {
|
|
62
56
|
id: 'png',
|
|
63
57
|
},
|
|
64
58
|
},
|
|
65
59
|
{
|
|
66
|
-
type: 'option',
|
|
67
60
|
icon: _jsx(FaDownload, {}),
|
|
68
|
-
|
|
61
|
+
text: 'Export as SVG',
|
|
69
62
|
data: {
|
|
70
63
|
id: 'svg',
|
|
71
64
|
},
|
|
@@ -97,7 +90,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
97
90
|
const exportHandler = useCallback((selected) => {
|
|
98
91
|
const molecule = molecules?.[currentIndex];
|
|
99
92
|
if (molecule) {
|
|
100
|
-
switch (selected?.
|
|
93
|
+
switch (selected?.id) {
|
|
101
94
|
case 'molfileV3':
|
|
102
95
|
saveAsMolHandler(molecule.molfile);
|
|
103
96
|
break;
|
|
@@ -160,5 +153,5 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
160
153
|
});
|
|
161
154
|
}
|
|
162
155
|
const hasMolecules = molecules && molecules.length > 0;
|
|
163
|
-
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, {
|
|
156
|
+
return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), molecules && molecules.length > 0 && (_jsx("p", { style: styles.counter, children: `${+(currentIndex + 1)} / ${molecules.length}` })), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
|
|
164
157
|
}
|
|
@@ -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
|
}
|
|
@@ -11,7 +11,7 @@ import { useModal } from '../../elements/popup/Modal';
|
|
|
11
11
|
import { useActiveSpectra } from '../../hooks/useActiveSpectra';
|
|
12
12
|
import useSpectrum from '../../hooks/useSpectrum';
|
|
13
13
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
14
|
-
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
14
|
+
import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
|
|
15
15
|
import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
|
|
16
16
|
function getMissingProjection(SpectrumsData, activeTab) {
|
|
17
17
|
let nucleus = activeTab.split(',');
|
|
@@ -29,7 +29,6 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
|
|
|
29
29
|
const modal = useModal();
|
|
30
30
|
const alert = useAlert();
|
|
31
31
|
const dispatch = useDispatch();
|
|
32
|
-
const spectra = getSpectraByNucleus(activeTab, data);
|
|
33
32
|
const handleDelete = useCallback(() => {
|
|
34
33
|
modal.showConfirmDialog({
|
|
35
34
|
message: (_jsxs("span", { children: ["You are about to delete", _jsxs("span", { style: { color: 'black' }, children: [" ", activeSpectra?.length, " "] }), "spectra, Are you sure?"] })),
|
|
@@ -81,7 +80,8 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeSpectra, activeTa
|
|
|
81
80
|
});
|
|
82
81
|
}
|
|
83
82
|
const hasActiveSpectra = activeSpectra && activeSpectra?.length > 0;
|
|
84
|
-
|
|
83
|
+
const spectraLengthPerTab = getSpectraByNucleus(activeTab, data)?.length;
|
|
84
|
+
return (_jsxs(DefaultPanelHeader, { onDelete: handleDelete, counter: data?.length, counterLabel: createFilterLabel(data?.length, spectraLengthPerTab), deleteToolTip: "Delete selected spectra", disableDelete: !hasActiveSpectra, showSettingButton: true, onSettingClick: onSettingClick, children: [_jsx(Button.BarButton, { toolTip: "Hide selected spectra", onClick: hideAllSpectrumsHandler, tooltipOrientation: "horizontal", disabled: !hasActiveSpectra, children: _jsx(FaEyeSlash, {}) }), _jsx(Button.BarButton, { onClick: showAllSpectrumsHandler, toolTip: "Show selected spectra", tooltipOrientation: "horizontal", disabled: !hasActiveSpectra, children: _jsx(FaEye, {}) }), displayerMode === '2D' && activeSpectrum?.info.isFt && (_jsx(Button.BarButton, { toolTip: "Add missing projection", tooltipOrientation: "horizontal", onClick: addMissingProjectionHandler, children: _jsx(FaCreativeCommonsSamplingPlus, {}) })), displayerMode === '1D' && spectraLengthPerTab > 1 && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Reset scale", onClick: resetScaleHandler, children: _jsx(SvgNmrResetScale, {}) }), _jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Same top", onClick: setSameTopHandler, children: _jsx(SvgNmrSameTop, {}) })] })), _jsx(SpectraAutomaticPickingButton, {}), _jsx(Button.BarButton, { tooltipOrientation: "horizontal", toolTip: "Recolor spectra", onClick: recolorSpectraHandler, children: _jsx(IoColorPaletteOutline, {}) })] }));
|
|
85
85
|
}
|
|
86
86
|
const MemoizedSpectraPanelHeader = memo(SpectraPanelHeaderInner);
|
|
87
87
|
export default function SpectrumsTabs({ onSettingClick, }) {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Spectrum } from 'nmr-load-save';
|
|
2
|
-
import { ActiveSpectrum } from '../../reducer/Reducer';
|
|
1
|
+
import { ActiveSpectrum, Spectrum } from 'nmr-load-save';
|
|
3
2
|
import { OnChangeVisibilityEvent } from './base/ShowHideSpectrumButton';
|
|
4
3
|
interface SpectraTableProps extends OnChangeVisibilityEvent {
|
|
5
4
|
data: any;
|
|
@@ -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';
|
|
@@ -24,7 +24,9 @@ function getActiveSpectraAsObject(activeSpectra) {
|
|
|
24
24
|
const result = {};
|
|
25
25
|
if (activeSpectra) {
|
|
26
26
|
for (const activeSpectrum of activeSpectra) {
|
|
27
|
-
|
|
27
|
+
if (activeSpectrum?.selected) {
|
|
28
|
+
result[activeSpectrum.id] = true;
|
|
29
|
+
}
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
return result;
|
|
@@ -35,8 +37,7 @@ const columnStyle = {
|
|
|
35
37
|
};
|
|
36
38
|
const options = [
|
|
37
39
|
{
|
|
38
|
-
|
|
39
|
-
type: 'option',
|
|
40
|
+
text: 'Recolor based on distinct value',
|
|
40
41
|
icon: _jsx(IoColorPaletteOutline, {}),
|
|
41
42
|
},
|
|
42
43
|
];
|
|
@@ -48,20 +49,17 @@ var SpectraContextMenuOptionsKeys;
|
|
|
48
49
|
})(SpectraContextMenuOptionsKeys || (SpectraContextMenuOptionsKeys = {}));
|
|
49
50
|
const Spectra2DContextMenuOptions = [
|
|
50
51
|
{
|
|
51
|
-
|
|
52
|
-
type: 'option',
|
|
52
|
+
text: 'Copy to Clipboard',
|
|
53
53
|
icon: _jsx(FaCopy, {}),
|
|
54
54
|
data: { id: SpectraContextMenuOptionsKeys.CopyToClipboard },
|
|
55
55
|
},
|
|
56
56
|
{
|
|
57
|
-
|
|
58
|
-
type: 'option',
|
|
57
|
+
text: 'Delete',
|
|
59
58
|
icon: _jsx(FaRegTrashAlt, {}),
|
|
60
59
|
data: { id: SpectraContextMenuOptionsKeys.Delete },
|
|
61
60
|
},
|
|
62
61
|
{
|
|
63
|
-
|
|
64
|
-
type: 'option',
|
|
62
|
+
text: 'Export as jcamp',
|
|
65
63
|
icon: _jsx(FaFileExport, {}),
|
|
66
64
|
data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
|
|
67
65
|
},
|
|
@@ -69,8 +67,7 @@ const Spectra2DContextMenuOptions = [
|
|
|
69
67
|
const Spectra1DContextMenuOptions = [
|
|
70
68
|
...Spectra2DContextMenuOptions,
|
|
71
69
|
{
|
|
72
|
-
|
|
73
|
-
type: 'option',
|
|
70
|
+
text: 'Export as jcamp',
|
|
74
71
|
icon: _jsx(FaFileExport, {}),
|
|
75
72
|
data: { id: SpectraContextMenuOptionsKeys.ExportAsJcamp },
|
|
76
73
|
},
|
|
@@ -133,7 +130,7 @@ export function SpectraTable(props) {
|
|
|
133
130
|
}), [onChangeVisibility, onOpenSettingModal]);
|
|
134
131
|
const { rawWriteWithType, cleanShouldFallback, shouldFallback, text } = useClipboard();
|
|
135
132
|
const selectContextMenuHandler = useCallback((option, spectrum) => {
|
|
136
|
-
const { id } = option
|
|
133
|
+
const { id } = option;
|
|
137
134
|
switch (id) {
|
|
138
135
|
case SpectraContextMenuOptionsKeys.CopyToClipboard: {
|
|
139
136
|
void (async () => {
|
|
@@ -223,9 +220,9 @@ const ColumnHeader = ({ label, col, }) => {
|
|
|
223
220
|
});
|
|
224
221
|
}
|
|
225
222
|
}
|
|
226
|
-
return (_jsx(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
223
|
+
return (_jsx(ContextMenu, { options: options, onSelect: selectHandler, style: {
|
|
224
|
+
whiteSpace: 'nowrap',
|
|
225
|
+
overflow: 'hidden',
|
|
226
|
+
textOverflow: 'ellipsis',
|
|
227
|
+
}, children: label }));
|
|
231
228
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Correlation, Link } from 'nmr-correlation';
|
|
2
|
-
import { Spectrum2D, Spectrum } from 'nmr-load-save';
|
|
3
|
-
import {
|
|
2
|
+
import { Spectrum2D, Spectrum, ActiveSpectrum } from 'nmr-load-save';
|
|
3
|
+
import { DisplayerMode } from '../../../reducer/Reducer';
|
|
4
4
|
declare function getAtomType(nucleus: string): string;
|
|
5
5
|
declare function getLabelColor(correlationData: any, correlation: any): string | null;
|
|
6
6
|
declare function findSignalMatch1D(spectrum: Spectrum2D, link: Link, factor: number, xDomain0: number, xDomain1: number): boolean;
|
|
@@ -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);
|
|
@@ -9,10 +9,6 @@ import { UsedColors } from '../../types/UsedColors';
|
|
|
9
9
|
import { Action } from '../context/DispatchContext';
|
|
10
10
|
import { Tool } from '../toolbar/ToolTypes';
|
|
11
11
|
import { ZoomHistory } from './helper/ZoomHistoryManager';
|
|
12
|
-
export interface ActiveSpectrum {
|
|
13
|
-
id: string;
|
|
14
|
-
index: number;
|
|
15
|
-
}
|
|
16
12
|
export type DisplayerMode = '1D' | '2D';
|
|
17
13
|
export interface Pivot {
|
|
18
14
|
value: number;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { ActiveSpectrum } from 'nmr-load-save';
|
|
2
3
|
import { BaselineCorrectionOptions, ApodizationOptions } from 'nmr-processing';
|
|
3
4
|
import { ExclusionZone } from '../../../data/types/data1d/ExclusionZone';
|
|
4
5
|
import { MatrixOptions } from '../../../data/types/data1d/MatrixOptions';
|
|
5
|
-
import {
|
|
6
|
+
import { State, TraceDirection } from '../Reducer';
|
|
6
7
|
import { ActionType } from '../types/ActionType';
|
|
7
8
|
type ShiftSpectrumAlongXAxisAction = ActionType<'SHIFT_SPECTRUM', {
|
|
8
9
|
shift: number;
|
|
@@ -10,7 +10,7 @@ import { get2DXScale, get2DYScale } from '../../2d/utilities/scale';
|
|
|
10
10
|
import { options as Tools } from '../../toolbar/ToolTypes';
|
|
11
11
|
import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
|
|
12
12
|
import nucleusToString from '../../utility/nucleusToString';
|
|
13
|
-
import { getInitialState
|
|
13
|
+
import { getInitialState } from '../Reducer';
|
|
14
14
|
import zoomHistoryManager from '../helper/ZoomHistoryManager';
|
|
15
15
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
16
16
|
import getRange from '../helper/getRange';
|
|
@@ -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 = {
|
|
@@ -327,23 +327,25 @@ function setTabActiveSpectrum(draft, dataGroupByTab) {
|
|
|
327
327
|
}
|
|
328
328
|
if (data.length === 1) {
|
|
329
329
|
const index = draft.data.findIndex((datum) => datum.id === data[0].id);
|
|
330
|
-
tabActiveSpectrum[tabKey] = [{ id: data[0].id, index }];
|
|
330
|
+
tabActiveSpectrum[tabKey] = [{ id: data[0].id, index, selected: true }];
|
|
331
331
|
}
|
|
332
332
|
else {
|
|
333
333
|
const tabSpectra = dataGroupByTab[tabKey];
|
|
334
334
|
const tabSpectraLength = tabSpectra.length;
|
|
335
335
|
if (tabSpectraLength >= 2) {
|
|
336
336
|
const FTSpectrums = tabSpectra.filter((d) => !d.info.isFid);
|
|
337
|
-
if (FTSpectrums.length > 0
|
|
338
|
-
|
|
339
|
-
(nucleusLength === 1 && tabSpectraLength !== FTSpectrums.length)
|
|
337
|
+
if (FTSpectrums.length > 0) {
|
|
338
|
+
const selected = nucleusLength === 2 ||
|
|
339
|
+
(nucleusLength === 1 && tabSpectraLength !== FTSpectrums.length);
|
|
340
340
|
const index = draft.data.findIndex((datum) => datum.id === FTSpectrums[0].id);
|
|
341
|
-
tabActiveSpectrum[tabKey] = [
|
|
341
|
+
tabActiveSpectrum[tabKey] = [
|
|
342
|
+
{ id: FTSpectrums[0].id, index, selected },
|
|
343
|
+
];
|
|
342
344
|
}
|
|
343
345
|
else if (tabSpectraLength - FTSpectrums > 0) {
|
|
344
346
|
const id = tabSpectra[0].id;
|
|
345
347
|
const index = draft.data.findIndex((datum) => datum.id === id);
|
|
346
|
-
tabActiveSpectrum[tabKey] = [{ id, index }];
|
|
348
|
+
tabActiveSpectrum[tabKey] = [{ id, index, selected: true }];
|
|
347
349
|
}
|
|
348
350
|
else {
|
|
349
351
|
tabActiveSpectrum[tabKey] = null;
|