nmrium 1.4.0 → 1.5.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/FloatPublicationString.d.ts.map +1 -1
- package/lib/component/1d/FloatPublicationString.js +4 -9
- package/lib/component/1d/FloatPublicationString.js.map +1 -1
- package/lib/component/1d/peaks/PeakAnnotations.d.ts.map +1 -1
- package/lib/component/1d/peaks/PeakAnnotations.js +99 -3
- package/lib/component/1d/peaks/PeakAnnotations.js.map +1 -1
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +3 -3
- package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js.map +1 -1
- package/lib/component/1d/peaks/Peaks.d.ts +4 -2
- package/lib/component/1d/peaks/Peaks.d.ts.map +1 -1
- package/lib/component/1d/peaks/Peaks.js +23 -19
- package/lib/component/1d/peaks/Peaks.js.map +1 -1
- package/lib/component/1d/ranges/Ranges.js +4 -4
- package/lib/component/1d/ranges/Ranges.js.map +1 -1
- package/lib/component/2d/zones/SignalsGuideLines.d.ts.map +1 -1
- package/lib/component/2d/zones/SignalsGuideLines.js +10 -6
- package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
- package/lib/component/elements/DraggableDialog.js +0 -2
- package/lib/component/elements/DraggableDialog.js.map +1 -1
- package/lib/component/elements/EditableColumn.d.ts.map +1 -1
- package/lib/component/elements/EditableColumn.js +2 -0
- package/lib/component/elements/EditableColumn.js.map +1 -1
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts.map +1 -1
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +0 -1
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js.map +1 -1
- package/lib/component/elements/ReactTable/ReactTable.d.ts.map +1 -1
- package/lib/component/elements/ReactTable/ReactTable.js +1 -4
- package/lib/component/elements/ReactTable/ReactTable.js.map +1 -1
- package/lib/component/elements/Tab/Tabs.js +1 -1
- package/lib/component/elements/Tab/Tabs.js.map +1 -1
- package/lib/component/hooks/useActiveSpectrumRangesViewState.d.ts +1 -1
- package/lib/component/hooks/useActiveSpectrumRangesViewState.d.ts.map +1 -1
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +20 -16
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js.map +1 -1
- package/lib/component/hooks/useCombinedRefs.js +1 -1
- package/lib/component/hooks/useCombinedRefs.js.map +1 -1
- package/lib/component/hooks/useTextMetrics.d.ts +4 -0
- package/lib/component/hooks/useTextMetrics.d.ts.map +1 -0
- package/lib/component/hooks/useTextMetrics.js +21 -0
- package/lib/component/hooks/useTextMetrics.js.map +1 -0
- package/lib/component/modal/MultipletAnalysisModal.js +2 -0
- package/lib/component/modal/MultipletAnalysisModal.js.map +1 -1
- package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts.map +1 -1
- package/lib/component/modal/changeSum/ChangeSumModalContents.js +2 -0
- package/lib/component/modal/changeSum/ChangeSumModalContents.js.map +1 -1
- package/lib/component/modal/changeSum/SelectMolecule.d.ts.map +1 -1
- package/lib/component/modal/changeSum/SelectMolecule.js +2 -0
- package/lib/component/modal/changeSum/SelectMolecule.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanel.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +2 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js.map +1 -1
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.d.ts.map +1 -1
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js +2 -5
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.js.map +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts.map +1 -1
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -9
- package/lib/component/panels/SummaryPanel/SummaryPanel.js.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.js +10 -10
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.js.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.d.ts.map +1 -1
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js +7 -5
- package/lib/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.js.map +1 -1
- package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts.map +1 -1
- package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.js +2 -0
- package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.js.map +1 -1
- package/lib/component/reducer/actions/InsetActions.js +6 -6
- package/lib/component/reducer/actions/InsetActions.js.map +1 -1
- package/lib/component/reducer/actions/PeaksActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/PeaksActions.js +3 -2
- package/lib/component/reducer/actions/PeaksActions.js.map +1 -1
- package/lib/component/reducer/helper/setRangesViewProperty.d.ts.map +1 -1
- package/lib/component/reducer/helper/setRangesViewProperty.js +5 -5
- package/lib/component/reducer/helper/setRangesViewProperty.js.map +1 -1
- package/lib/component/utility/isHomoNuclear.d.ts +2 -0
- package/lib/component/utility/isHomoNuclear.d.ts.map +1 -0
- package/lib/component/utility/isHomoNuclear.js +11 -0
- package/lib/component/utility/isHomoNuclear.js.map +1 -0
- package/lib/utils/clipboard/clipboardComponents.d.ts.map +1 -1
- package/lib/utils/clipboard/clipboardComponents.js +12 -4
- package/lib/utils/clipboard/clipboardComponents.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +17 -17
- package/src/component/1d/FloatPublicationString.tsx +4 -9
- package/src/component/1d/peaks/PeakAnnotations.tsx +147 -22
- package/src/component/1d/peaks/PeakAnnotationsSpreadMode.tsx +3 -3
- package/src/component/1d/peaks/Peaks.tsx +37 -31
- package/src/component/1d/ranges/Ranges.tsx +4 -4
- package/src/component/2d/zones/SignalsGuideLines.tsx +11 -6
- package/src/component/elements/DraggableDialog.tsx +0 -2
- package/src/component/elements/EditableColumn.tsx +2 -0
- package/src/component/elements/ReactTable/Elements/ReactTableRow.tsx +0 -1
- package/src/component/elements/ReactTable/ReactTable.tsx +0 -3
- package/src/component/elements/Tab/Tabs.tsx +1 -1
- package/src/component/hooks/useActiveSpectrumRangesViewState.ts +24 -16
- package/src/component/hooks/useCombinedRefs.ts +1 -1
- package/src/component/hooks/useTextMetrics.ts +27 -0
- package/src/component/modal/MultipletAnalysisModal.tsx +2 -0
- package/src/component/modal/changeSum/ChangeSumModalContents.tsx +2 -0
- package/src/component/modal/changeSum/SelectMolecule.tsx +2 -0
- package/src/component/panels/MoleculesPanel/MoleculePanel.tsx +2 -0
- package/src/component/panels/SpectraPanel/SpectraPanelHeader.tsx +1 -1
- package/src/component/panels/SummaryPanel/CorrelationTable/editLink/EditPathLength.tsx +3 -6
- package/src/component/panels/SummaryPanel/SummaryPanel.tsx +10 -16
- package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrection.tsx +14 -14
- package/src/component/panels/filtersPanel/Filters/hooks/usePhaseCorrectionTwoDimensions.tsx +10 -8
- package/src/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.tsx +2 -0
- package/src/component/reducer/actions/InsetActions.ts +6 -6
- package/src/component/reducer/actions/PeaksActions.ts +7 -2
- package/src/component/reducer/helper/setRangesViewProperty.ts +8 -5
- package/src/component/utility/isHomoNuclear.ts +11 -0
- package/src/utils/clipboard/clipboardComponents.tsx +15 -5
- package/src/versionInfo.ts +1 -1
- package/lib/component/hooks/useCanvasContext.d.ts +0 -2
- package/lib/component/hooks/useCanvasContext.d.ts.map +0 -1
- package/lib/component/hooks/useCanvasContext.js +0 -13
- package/lib/component/hooks/useCanvasContext.js.map +0 -1
- package/src/component/hooks/useCanvasContext.ts +0 -15
|
@@ -5,25 +5,33 @@ import { useChartData } from '../context/ChartContext.js';
|
|
|
5
5
|
|
|
6
6
|
import { useActiveSpectrum } from './useActiveSpectrum.js';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
export function getDefaultRangesViewState(nucleus: string): RangesViewState {
|
|
9
|
+
const isProton = nucleus === '1H';
|
|
10
|
+
const isCarbon = nucleus === '13C';
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
showPeaks: isCarbon,
|
|
14
|
+
showMultiplicityTrees: false,
|
|
15
|
+
showIntegrals: false,
|
|
16
|
+
showIntegralsValues: isProton,
|
|
17
|
+
showJGraph: false,
|
|
18
|
+
displayingMode: 'spread',
|
|
19
|
+
integralsScaleRatio: 1,
|
|
20
|
+
showAssignmentsLabels: false,
|
|
21
|
+
showPublicationString: false,
|
|
22
|
+
showRanges: false,
|
|
23
|
+
publicationStringBounding: { x: 0, y: 0, width: 400, height: 0 },
|
|
24
|
+
rangesBounding: { x: 0, y: 0, width: 200, height: 150 },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
22
27
|
|
|
23
28
|
export function useActiveSpectrumRangesViewState() {
|
|
24
29
|
const activeSpectrum = useActiveSpectrum();
|
|
25
30
|
const {
|
|
26
|
-
view: {
|
|
31
|
+
view: {
|
|
32
|
+
ranges,
|
|
33
|
+
spectra: { activeTab: nucleus },
|
|
34
|
+
},
|
|
27
35
|
} = useChartData();
|
|
28
36
|
|
|
29
37
|
const inset = useInsetOptions();
|
|
@@ -39,6 +47,6 @@ export function useActiveSpectrumRangesViewState() {
|
|
|
39
47
|
) {
|
|
40
48
|
return ranges[activeSpectrum?.id];
|
|
41
49
|
} else {
|
|
42
|
-
return
|
|
50
|
+
return getDefaultRangesViewState(nucleus);
|
|
43
51
|
}
|
|
44
52
|
}
|
|
@@ -13,7 +13,7 @@ export default function useCombinedRefs<T>(
|
|
|
13
13
|
ref(targetRef.current);
|
|
14
14
|
} else {
|
|
15
15
|
// Mutating a ref.
|
|
16
|
-
// eslint-disable-next-line react-hooks/
|
|
16
|
+
// eslint-disable-next-line react-hooks/immutability
|
|
17
17
|
ref.current = targetRef.current;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
function measureTextWidth(
|
|
4
|
+
context: CanvasRenderingContext2D | null,
|
|
5
|
+
text: string,
|
|
6
|
+
) {
|
|
7
|
+
if (!context) return 0;
|
|
8
|
+
return Math.round(context.measureText(text).width);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useTextMetrics(labelSize = 12) {
|
|
12
|
+
const contextRef = useRef<CanvasRenderingContext2D | null>(null);
|
|
13
|
+
|
|
14
|
+
if (!contextRef.current) {
|
|
15
|
+
const canvas = document.createElement('canvas');
|
|
16
|
+
contextRef.current = canvas.getContext('2d');
|
|
17
|
+
if (contextRef.current) {
|
|
18
|
+
contextRef.current.font = `${labelSize}px Arial`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getTextWidth(text: string): number {
|
|
23
|
+
return measureTextWidth(contextRef.current, text);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return { getTextWidth };
|
|
27
|
+
}
|
|
@@ -162,6 +162,8 @@ function InnerMultipleAnalysis(props: InnerMultipleAnalysisProps) {
|
|
|
162
162
|
debug: true,
|
|
163
163
|
},
|
|
164
164
|
});
|
|
165
|
+
// TODO: refactor to not use an effect
|
|
166
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
165
167
|
setCalcFinished(true);
|
|
166
168
|
setAnalysisData(result);
|
|
167
169
|
} catch (error) {
|
|
@@ -80,6 +80,8 @@ export function ChangeSumModalContents(props: ChangeSumModalContentsProps) {
|
|
|
80
80
|
|
|
81
81
|
useEffect(() => {
|
|
82
82
|
if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
|
|
83
|
+
// TODO: refactor to not use an effect
|
|
84
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
83
85
|
setActiveOption('auto');
|
|
84
86
|
const { mf, moleculeId: id } = sumOptions;
|
|
85
87
|
reset({
|
|
@@ -76,6 +76,8 @@ export default function SelectMolecule<
|
|
|
76
76
|
const index = value
|
|
77
77
|
? molecules.findIndex((molecule) => molecule.id === value.id)
|
|
78
78
|
: -1;
|
|
79
|
+
// TODO: refactor to not use an effect
|
|
80
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
79
81
|
setValue(index !== -1 ? index : 0);
|
|
80
82
|
}
|
|
81
83
|
}, [molecules, setValue, value]);
|
|
@@ -75,6 +75,8 @@ function MoleculePanelInner(props: MoleculePanelInnerProps) {
|
|
|
75
75
|
|
|
76
76
|
useEffect(() => {
|
|
77
77
|
if (moleculesProp) {
|
|
78
|
+
// TODO: refactor to not use an effect
|
|
79
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
78
80
|
setMolecules((prevMolecules) => {
|
|
79
81
|
if (moleculesProp.length > prevMolecules.length) {
|
|
80
82
|
setCurrentIndex(molecules.length);
|
|
@@ -119,7 +119,7 @@ function SpectraPanelHeaderInner({
|
|
|
119
119
|
const hasActiveSpectra = activeSpectra && activeSpectra?.length > 0;
|
|
120
120
|
const spectraLengthPerTab = getSpectraByNucleus(activeTab, data)?.length;
|
|
121
121
|
const { getToggleVisibilityButtons } = useToggleSpectraVisibility(
|
|
122
|
-
spectraLengthPerTab <
|
|
122
|
+
spectraLengthPerTab < 3
|
|
123
123
|
? {
|
|
124
124
|
enableHideSelected: false,
|
|
125
125
|
enableShowSelected: false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled from '@emotion/styled';
|
|
2
2
|
import type { Signal2D } from '@zakodium/nmr-types';
|
|
3
3
|
import type { FromTo } from 'cheminfo-types';
|
|
4
|
-
import { useCallback,
|
|
4
|
+
import { useCallback, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
import DefaultPathLengths from '../../../../../data/constants/DefaultPathLengths.js';
|
|
7
7
|
import Button from '../../../../elements/Button.js';
|
|
@@ -60,7 +60,8 @@ function EditPathLength({ signal, experimentType, onEdit }: InputProps) {
|
|
|
60
60
|
? (signal.j.pathLength as FromTo).to
|
|
61
61
|
: DefaultPathLengths[experimentType]?.to || 0,
|
|
62
62
|
);
|
|
63
|
-
|
|
63
|
+
|
|
64
|
+
const isError = from <= 0 || from > to;
|
|
64
65
|
|
|
65
66
|
const handleOnEdit = useCallback(() => {
|
|
66
67
|
const pathLength: FromTo = {
|
|
@@ -78,10 +79,6 @@ function EditPathLength({ signal, experimentType, onEdit }: InputProps) {
|
|
|
78
79
|
onEdit(editedSignal);
|
|
79
80
|
}, [to, from, onEdit, signal]);
|
|
80
81
|
|
|
81
|
-
useEffect(() => {
|
|
82
|
-
setIsError(from <= 0 || from > to);
|
|
83
|
-
}, [to, from]);
|
|
84
|
-
|
|
85
82
|
return (
|
|
86
83
|
<Container>
|
|
87
84
|
<p>Setting of the minimum and maximum path length (J coupling).</p>
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
Values as CorrelationValues,
|
|
8
8
|
} from 'nmr-correlation';
|
|
9
9
|
import { getLinkDelta, getLinkDim } from 'nmr-correlation';
|
|
10
|
-
import { memo, useCallback,
|
|
10
|
+
import { memo, useCallback, useMemo, useState } from 'react';
|
|
11
11
|
import { FaFlask, FaSlidersH } from 'react-icons/fa';
|
|
12
12
|
|
|
13
13
|
import {
|
|
@@ -102,9 +102,6 @@ function SummaryPanel() {
|
|
|
102
102
|
molecularFormula: false,
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
const [additionalColumnData, setAdditionalColumnData] = useState<
|
|
106
|
-
Correlation[]
|
|
107
|
-
>([]);
|
|
108
105
|
const [
|
|
109
106
|
selectedAdditionalColumnsAtomType,
|
|
110
107
|
setSelectedAdditionalColumnsAtomType,
|
|
@@ -265,21 +262,18 @@ function SummaryPanel() {
|
|
|
265
262
|
});
|
|
266
263
|
}, [correlationsData]);
|
|
267
264
|
|
|
268
|
-
|
|
265
|
+
const additionalColumnData = useMemo<Correlation[]>(() => {
|
|
269
266
|
const _selectedAdditionalColumnsAtomType =
|
|
270
267
|
selectedAdditionalColumnsAtomType.split('-')[0];
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
correlation.atomType === _selectedAdditionalColumnsAtomType,
|
|
278
|
-
)
|
|
279
|
-
// eslint-disable-next-line unicorn/no-array-reverse
|
|
280
|
-
.reverse()
|
|
281
|
-
: [],
|
|
268
|
+
if (!filteredCorrelationsData) {
|
|
269
|
+
return [];
|
|
270
|
+
}
|
|
271
|
+
const result = filteredCorrelationsData.values.filter(
|
|
272
|
+
(correlation: any) =>
|
|
273
|
+
correlation.atomType === _selectedAdditionalColumnsAtomType,
|
|
282
274
|
);
|
|
275
|
+
result.reverse();
|
|
276
|
+
return result;
|
|
283
277
|
}, [filteredCorrelationsData, selectedAdditionalColumnsAtomType]);
|
|
284
278
|
|
|
285
279
|
const editEquivalencesSaveHandler = useCallback(
|
|
@@ -55,14 +55,6 @@ export function usePhaseCorrection(
|
|
|
55
55
|
itemTextKey: 'label',
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
function syncWatch(sharedFilterOptions: any) {
|
|
59
|
-
updateInputRangeInitialValue(sharedFilterOptions);
|
|
60
|
-
setValue(sharedFilterOptions);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const { syncFilterOptions, clearSyncFilterOptions } =
|
|
64
|
-
useSyncedFilterOptions(syncWatch);
|
|
65
|
-
|
|
66
58
|
useEffect(() => {
|
|
67
59
|
if (filter && phaseCorrectionTypeItem?.value === 'manual') {
|
|
68
60
|
const { ph0 = 0, ph1 = 0 } = filter?.value || {};
|
|
@@ -79,6 +71,20 @@ export function usePhaseCorrection(
|
|
|
79
71
|
}
|
|
80
72
|
}, [filter, phaseCorrectionTypeItem]);
|
|
81
73
|
|
|
74
|
+
const updateInputRangeInitialValue = useCallback((value: any) => {
|
|
75
|
+
// update InputRange initial value
|
|
76
|
+
ph0Ref.current?.setValue(value.ph0);
|
|
77
|
+
ph1Ref.current?.setValue(value.ph1);
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
function syncWatch(sharedFilterOptions: any) {
|
|
81
|
+
updateInputRangeInitialValue(sharedFilterOptions);
|
|
82
|
+
setValue(sharedFilterOptions);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const { syncFilterOptions, clearSyncFilterOptions } =
|
|
86
|
+
useSyncedFilterOptions(syncWatch);
|
|
87
|
+
|
|
82
88
|
function handleApplyFilter() {
|
|
83
89
|
switch (phaseCorrectionTypeItem?.value) {
|
|
84
90
|
case 'automatic': {
|
|
@@ -123,12 +129,6 @@ export function usePhaseCorrection(
|
|
|
123
129
|
[data.re, dispatch, pivot?.index],
|
|
124
130
|
);
|
|
125
131
|
|
|
126
|
-
const updateInputRangeInitialValue = useCallback((value: any) => {
|
|
127
|
-
// update InputRange initial value
|
|
128
|
-
ph0Ref.current?.setValue(value.ph0);
|
|
129
|
-
ph1Ref.current?.setValue(value.ph1);
|
|
130
|
-
}, []);
|
|
131
|
-
|
|
132
132
|
const handleInput = useCallback(
|
|
133
133
|
(valueAsNumber: any, valueAsString: any, element: any) => {
|
|
134
134
|
const { name } = element;
|
|
@@ -59,14 +59,6 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
|
|
|
59
59
|
}, 250),
|
|
60
60
|
);
|
|
61
61
|
|
|
62
|
-
function syncWatch(sharedFilterOptions: any) {
|
|
63
|
-
updateInputRangeInitialValue(sharedFilterOptions);
|
|
64
|
-
setValue(sharedFilterOptions);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const { syncFilterOptions, clearSyncFilterOptions } =
|
|
68
|
-
useSyncedFilterOptions(syncWatch);
|
|
69
|
-
|
|
70
62
|
const {
|
|
71
63
|
value: phaseCorrectionSelectItem,
|
|
72
64
|
...defaultPhaseCorrectionSelectProps
|
|
@@ -85,6 +77,8 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
|
|
|
85
77
|
(phaseOptions as any)[direction] = { ph0, ph1 };
|
|
86
78
|
}
|
|
87
79
|
|
|
80
|
+
// TODO: change this to not use an effect
|
|
81
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
88
82
|
setValue(phaseOptions);
|
|
89
83
|
valueRef.current = phaseOptions;
|
|
90
84
|
}
|
|
@@ -135,6 +129,14 @@ export function usePhaseCorrectionTwoDimensions(filter: Filter2DEntry | null) {
|
|
|
135
129
|
[activeTraceDirection],
|
|
136
130
|
);
|
|
137
131
|
|
|
132
|
+
function syncWatch(sharedFilterOptions: any) {
|
|
133
|
+
updateInputRangeInitialValue(sharedFilterOptions);
|
|
134
|
+
setValue(sharedFilterOptions);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const { syncFilterOptions, clearSyncFilterOptions } =
|
|
138
|
+
useSyncedFilterOptions(syncWatch);
|
|
139
|
+
|
|
138
140
|
const handleInputValueChange = useCallback(
|
|
139
141
|
(valueAsNumber: any, valueAsString: any, inputElement: any) => {
|
|
140
142
|
const { name } = inputElement;
|
package/src/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.tsx
CHANGED
|
@@ -23,6 +23,8 @@ function MultipleAnalysisCodeEditor({ data }: MultipleAnalysisCodeEditorProps) {
|
|
|
23
23
|
useEffect(() => {
|
|
24
24
|
const evalResult = evaluate(code, data);
|
|
25
25
|
if (evalResult instanceof Error) {
|
|
26
|
+
// TODO: change this to not use an effect.
|
|
27
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
26
28
|
setResult(evalResult.message);
|
|
27
29
|
} else {
|
|
28
30
|
setValue('code', code);
|
|
@@ -18,7 +18,7 @@ import { getInsetXScale } from '../../1d/utilities/scale.js';
|
|
|
18
18
|
import type { ZoomOptions } from '../../EventsTrackers/BrushTracker.js';
|
|
19
19
|
import { defaultIntegralsViewState } from '../../hooks/useActiveSpectrumIntegralsViewState.js';
|
|
20
20
|
import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState.js';
|
|
21
|
-
import {
|
|
21
|
+
import { getDefaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
|
|
22
22
|
import {
|
|
23
23
|
convertPercentToPixel,
|
|
24
24
|
convertPixelToPercent,
|
|
@@ -116,7 +116,7 @@ function handleAddInset(draft: Draft<State>, action: AddInsetAction) {
|
|
|
116
116
|
const {
|
|
117
117
|
yDomain,
|
|
118
118
|
view: {
|
|
119
|
-
spectra: { activeTab },
|
|
119
|
+
spectra: { activeTab: nucleus },
|
|
120
120
|
},
|
|
121
121
|
width: baseWidth,
|
|
122
122
|
height: baseHeight,
|
|
@@ -142,16 +142,16 @@ function handleAddInset(draft: Draft<State>, action: AddInsetAction) {
|
|
|
142
142
|
yDomain,
|
|
143
143
|
zoomHistory: [{ xDomain, yDomain }],
|
|
144
144
|
view: {
|
|
145
|
-
ranges:
|
|
145
|
+
ranges: getDefaultRangesViewState(nucleus),
|
|
146
146
|
peaks: { ...defaultPeaksViewState },
|
|
147
147
|
integrals: { ...defaultIntegralsViewState },
|
|
148
148
|
},
|
|
149
149
|
};
|
|
150
150
|
|
|
151
|
-
if (draft.insets?.[
|
|
152
|
-
draft.insets[
|
|
151
|
+
if (draft.insets?.[nucleus]) {
|
|
152
|
+
draft.insets[nucleus].push(inset);
|
|
153
153
|
} else {
|
|
154
|
-
draft.insets[
|
|
154
|
+
draft.insets[nucleus] = [inset];
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
function handleDeleteInset(draft: Draft<State>, action: DeleteInsetAction) {
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
optimizePeaks,
|
|
19
19
|
} from '../../../data/data1d/Spectrum1D/index.js';
|
|
20
20
|
import { defaultPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState.js';
|
|
21
|
-
import {
|
|
21
|
+
import { getDefaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
|
|
22
22
|
import type { FilterType } from '../../utility/filterType.js';
|
|
23
23
|
import { getClosePeak } from '../../utility/getClosePeak.js';
|
|
24
24
|
import type { State } from '../Reducer.js';
|
|
@@ -264,6 +264,11 @@ function toggleDisplayingPeaks(
|
|
|
264
264
|
draft: Draft<State>,
|
|
265
265
|
key: keyof Pick<ViewState, 'peaks' | 'ranges'>,
|
|
266
266
|
) {
|
|
267
|
+
const {
|
|
268
|
+
view: {
|
|
269
|
+
spectra: { activeTab: nucleus },
|
|
270
|
+
},
|
|
271
|
+
} = draft;
|
|
267
272
|
const activeSpectrum = getActiveSpectrum(draft);
|
|
268
273
|
|
|
269
274
|
if (activeSpectrum?.id) {
|
|
@@ -281,7 +286,7 @@ function toggleDisplayingPeaks(
|
|
|
281
286
|
|
|
282
287
|
break;
|
|
283
288
|
case 'ranges':
|
|
284
|
-
defaultsViewOptions =
|
|
289
|
+
defaultsViewOptions = getDefaultRangesViewState(nucleus);
|
|
285
290
|
break;
|
|
286
291
|
default:
|
|
287
292
|
break;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { RangesViewState } from '@zakodium/nmrium-core';
|
|
2
2
|
import type { Draft } from 'immer';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getDefaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState.js';
|
|
5
5
|
import type { State } from '../Reducer.js';
|
|
6
6
|
|
|
7
7
|
import { getActiveSpectrum } from './getActiveSpectrum.js';
|
|
@@ -56,10 +56,13 @@ export function initializeRangeViewObject(
|
|
|
56
56
|
draft: Draft<State>,
|
|
57
57
|
spectrumID: string,
|
|
58
58
|
) {
|
|
59
|
-
const
|
|
59
|
+
const {
|
|
60
|
+
ranges,
|
|
61
|
+
spectra: { activeTab: nucleus },
|
|
62
|
+
} = draft.view;
|
|
60
63
|
|
|
61
|
-
if (spectrumID in
|
|
64
|
+
if (spectrumID in ranges) return;
|
|
62
65
|
|
|
63
|
-
const defaultRangesView =
|
|
64
|
-
|
|
66
|
+
const defaultRangesView = getDefaultRangesViewState(nucleus);
|
|
67
|
+
ranges[spectrumID] = defaultRangesView;
|
|
65
68
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function isHomoNuclear(nuclei: string | string[], splitSeparator = ',') {
|
|
2
|
+
let parts: string[] = [];
|
|
3
|
+
|
|
4
|
+
if (typeof nuclei === 'string') {
|
|
5
|
+
parts = nuclei.split(splitSeparator).map((s) => s.trim());
|
|
6
|
+
} else {
|
|
7
|
+
parts = nuclei;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return parts.length === 1 || parts.every((p) => p === parts[0]);
|
|
11
|
+
}
|
|
@@ -139,7 +139,9 @@ interface ClipboardFallbackReadProps extends CFBP {
|
|
|
139
139
|
}
|
|
140
140
|
function ClipboardFallbackRead(props: ClipboardFallbackReadProps) {
|
|
141
141
|
const onFileRef = useRef(props.onRead);
|
|
142
|
-
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
onFileRef.current = props.onRead;
|
|
144
|
+
});
|
|
143
145
|
|
|
144
146
|
const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
|
|
145
147
|
event.preventDefault();
|
|
@@ -178,9 +180,12 @@ interface ClipboardFallbackReadTextProps extends CFBP {
|
|
|
178
180
|
onReadText: (text: string) => void;
|
|
179
181
|
mode: 'readText';
|
|
180
182
|
}
|
|
183
|
+
|
|
181
184
|
function ClipboardFallbackReadText(props: ClipboardFallbackReadTextProps) {
|
|
182
185
|
const onTextRef = useRef(props.onReadText);
|
|
183
|
-
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
onTextRef.current = props.onReadText;
|
|
188
|
+
});
|
|
184
189
|
|
|
185
190
|
const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
|
|
186
191
|
event.preventDefault();
|
|
@@ -219,9 +224,12 @@ interface ClipboardFallbackWriteProps extends CFBP {
|
|
|
219
224
|
file: File;
|
|
220
225
|
mode: 'write';
|
|
221
226
|
}
|
|
227
|
+
|
|
222
228
|
function ClipboardFallbackWrite(props: ClipboardFallbackWriteProps) {
|
|
223
229
|
const onDismissRef = useRef(props.onDismiss);
|
|
224
|
-
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
onDismissRef.current = props.onDismiss;
|
|
232
|
+
});
|
|
225
233
|
|
|
226
234
|
const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
|
|
227
235
|
event.preventDefault();
|
|
@@ -259,13 +267,15 @@ interface ClipboardFallbackWriteTextProps extends CFBP {
|
|
|
259
267
|
text: string;
|
|
260
268
|
mode: 'writeText';
|
|
261
269
|
}
|
|
270
|
+
|
|
262
271
|
function ClipboardFallbackWriteText(props: ClipboardFallbackWriteTextProps) {
|
|
263
272
|
const onDismissRef = useRef(props.onDismiss);
|
|
264
|
-
|
|
273
|
+
useEffect(() => {
|
|
274
|
+
onDismissRef.current = props.onDismiss;
|
|
275
|
+
});
|
|
265
276
|
|
|
266
277
|
const onSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
|
|
267
278
|
event.preventDefault();
|
|
268
|
-
|
|
269
279
|
onDismissRef.current();
|
|
270
280
|
}, []);
|
|
271
281
|
|
package/src/versionInfo.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v1.
|
|
1
|
+
export default { version: 'v1.5.0' };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasContext.d.ts","sourceRoot":"","sources":["../../../src/component/hooks/useCanvasContext.ts"],"names":[],"mappings":"AAEA,wBAAgB,gBAAgB,CAAC,SAAS,SAAK,mCAY9C"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
export function useCanvasContext(labelSize = 12) {
|
|
3
|
-
const contextRef = useRef(null);
|
|
4
|
-
if (!contextRef.current) {
|
|
5
|
-
const canvas = document.createElement('canvas');
|
|
6
|
-
contextRef.current = canvas.getContext('2d');
|
|
7
|
-
if (contextRef.current) {
|
|
8
|
-
contextRef.current.font = `${labelSize}px Arial`;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
return contextRef.current;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=useCanvasContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCanvasContext.js","sourceRoot":"","sources":["../../../src/component/hooks/useCanvasContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,MAAM,UAAU,gBAAgB,CAAC,SAAS,GAAG,EAAE;IAC7C,MAAM,UAAU,GAAG,MAAM,CAAkC,IAAI,CAAC,CAAC;IAEjE,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC;YACvB,UAAU,CAAC,OAAO,CAAC,IAAI,GAAG,GAAG,SAAS,UAAU,CAAC;QACnD,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC,OAAO,CAAC;AAC5B,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useRef } from 'react';
|
|
2
|
-
|
|
3
|
-
export function useCanvasContext(labelSize = 12) {
|
|
4
|
-
const contextRef = useRef<CanvasRenderingContext2D | null>(null);
|
|
5
|
-
|
|
6
|
-
if (!contextRef.current) {
|
|
7
|
-
const canvas = document.createElement('canvas');
|
|
8
|
-
contextRef.current = canvas.getContext('2d');
|
|
9
|
-
if (contextRef.current) {
|
|
10
|
-
contextRef.current.font = `${labelSize}px Arial`;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return contextRef.current;
|
|
15
|
-
}
|