nmrium 0.47.0 → 0.48.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/Line.js +1 -1
- package/lib/component/1d/LinesSeries.d.ts +1 -1
- package/lib/component/1d/LinesSeries.js +24 -3
- package/lib/component/1d/peaks/Peaks.js +5 -4
- package/lib/component/1d/utilities/scale.d.ts +1 -0
- package/lib/component/1d/utilities/scale.js +2 -1
- package/lib/component/context/KeyModifierContext.d.ts +1 -1
- package/lib/component/hooks/useExport.js +2 -2
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
- package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
- package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
- package/lib/component/main/InnerNMRium.js +1 -1
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +2 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -5
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +26 -38
- package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +3 -9
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.d.ts +7 -0
- package/lib/component/panels/SpectrumsPanel/base/RenderAsHTML.js +21 -0
- package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/DomainActions.js +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +1 -2
- package/lib/component/reducer/actions/SpectrumsActions.js +5 -1
- package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +42 -26
- package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +23 -23
package/lib/component/1d/Line.js
CHANGED
|
@@ -26,6 +26,6 @@ function Line({ data, id, display, index }) {
|
|
|
26
26
|
}
|
|
27
27
|
}, [scaleX, scaleY, id, data, xyReduce]);
|
|
28
28
|
const { color: stroke, opacity: strokeOpacity } = parseColor(display?.color || 'black');
|
|
29
|
-
return (_jsx("path", { className: "line", "data-testid": "spectrum-line", stroke: stroke, fill: "none", strokeOpacity: opacity === 1 ? strokeOpacity : opacity, d: paths, transform: `translate(0,-${shiftY * index})` }
|
|
29
|
+
return (_jsx("path", { id: id, className: "line", "data-testid": "spectrum-line", stroke: stroke, fill: "none", strokeOpacity: opacity === 1 ? strokeOpacity : opacity, d: paths, transform: `translate(0,-${shiftY * index})` }));
|
|
30
30
|
}
|
|
31
31
|
export default Line;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function LinesSeries(): import("react/jsx-runtime").JSX.Element;
|
|
1
|
+
declare function LinesSeries(): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
2
2
|
export default LinesSeries;
|
|
@@ -1,13 +1,34 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { css } from '@emotion/react';
|
|
2
4
|
import { get1DDataXY } from '../../data/data1d/Spectrum1D/get1DDataXY';
|
|
3
5
|
import { isSpectrum1D } from '../../data/data1d/Spectrum1D/isSpectrum1D';
|
|
4
6
|
import { useChartData } from '../context/ChartContext';
|
|
7
|
+
import { useScaleChecked } from '../context/ScaleContext';
|
|
5
8
|
import { useActiveSpectra } from '../hooks/useActiveSpectra';
|
|
9
|
+
import { useSetActiveSpectrumAction } from '../hooks/useSetActiveSpectrumAction';
|
|
10
|
+
import { useVerticalAlign } from '../hooks/useVerticalAlign';
|
|
6
11
|
import Line from './Line';
|
|
12
|
+
import { SPECTRA_BOTTOM_MARGIN } from './utilities/scale';
|
|
13
|
+
const BOX_SIZE = 10;
|
|
14
|
+
const style = css `
|
|
15
|
+
fill: transparent;
|
|
16
|
+
|
|
17
|
+
&:hover {
|
|
18
|
+
fill: #ff6f0057;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
7
21
|
function LinesSeries() {
|
|
8
|
-
const { data, displayerKey, xDomains } = useChartData();
|
|
22
|
+
const { data, displayerKey, xDomains, width, margin, height } = useChartData();
|
|
9
23
|
const activeSpectra = useActiveSpectra();
|
|
24
|
+
const { shiftY } = useScaleChecked();
|
|
25
|
+
const verticalAlign = useVerticalAlign();
|
|
26
|
+
const innerWidth = width - margin.left - margin.right;
|
|
27
|
+
const innerHeight = height - margin.bottom - SPECTRA_BOTTOM_MARGIN;
|
|
10
28
|
const spectra = (data?.filter((d) => isSpectrum1D(d) && d.display.isVisible && xDomains[d.id]) || []);
|
|
11
|
-
|
|
29
|
+
const { setActiveSpectrum } = useSetActiveSpectrumAction();
|
|
30
|
+
return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, className: "spectrums", children: [spectra.map((d, i) => (_jsxs("g", { children: [_jsx(Line, { display: d.display, id: d.id, data: get1DDataXY(d), index: i }), verticalAlign === 'stack' && (_jsx("rect", { css: style, y: innerHeight - shiftY * i - BOX_SIZE / 2, x: margin.left, width: `${innerWidth}px`, height: `${BOX_SIZE}px`, onClick: (e) => {
|
|
31
|
+
setActiveSpectrum(e, d.id);
|
|
32
|
+
} }))] }, d.id))), activeSpectra?.map((activeSpectrum) => (_jsx("use", { href: `#${activeSpectrum.id}` }, activeSpectrum.id)))] }));
|
|
12
33
|
}
|
|
13
34
|
export default LinesSeries;
|
|
@@ -69,13 +69,14 @@ export default function Peaks(props) {
|
|
|
69
69
|
const { deltaPPM: { format: peakFormat }, } = usePanelPreferences(peaksSource === 'peaks' ? 'peaks' : 'ranges', nucleus);
|
|
70
70
|
const canDisplaySpectrumPeaks = !spectrum.display.isVisible || spectrum.info?.isFid;
|
|
71
71
|
let mode = 'spread';
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (peaksSource === 'peaks' &&
|
|
73
|
+
(spectrum.peaks?.values?.length === 0 ||
|
|
74
|
+
!peaksViewState.showPeaks ||
|
|
75
|
+
canDisplaySpectrumPeaks)) {
|
|
75
76
|
return null;
|
|
76
77
|
}
|
|
77
78
|
if (peaksSource === 'ranges' &&
|
|
78
|
-
(
|
|
79
|
+
(spectrum.ranges?.values?.length === 0 ||
|
|
79
80
|
!rangesViewState.showPeaks ||
|
|
80
81
|
canDisplaySpectrumPeaks)) {
|
|
81
82
|
return null;
|
|
@@ -14,6 +14,7 @@ interface ScaleYOptions {
|
|
|
14
14
|
yDomain: number[];
|
|
15
15
|
verticalAlign: VerticalAlignment;
|
|
16
16
|
}
|
|
17
|
+
export declare const SPECTRA_BOTTOM_MARGIN = 40;
|
|
17
18
|
declare function getYScale(options: ScaleYOptions, spectrumId?: number | null | string): import("d3-scale").ScaleLinear<number, number, never>;
|
|
18
19
|
interface IntegralYScaleOptions {
|
|
19
20
|
height: number;
|
|
@@ -9,6 +9,7 @@ function getXScale(options, spectrumId = null) {
|
|
|
9
9
|
: [margin.left, width - margin.right];
|
|
10
10
|
return scaleLinear(spectrumId ? xDomains[spectrumId] : xDomain, range);
|
|
11
11
|
}
|
|
12
|
+
export const SPECTRA_BOTTOM_MARGIN = 40;
|
|
12
13
|
function getYScale(options, spectrumId = null) {
|
|
13
14
|
const { height, margin, verticalAlign, yDomain, yDomains } = options;
|
|
14
15
|
let domainY = yDomain;
|
|
@@ -16,7 +17,7 @@ function getYScale(options, spectrumId = null) {
|
|
|
16
17
|
domainY = yDomains[spectrumId];
|
|
17
18
|
}
|
|
18
19
|
const [min, max] = domainY;
|
|
19
|
-
let bottomShift =
|
|
20
|
+
let bottomShift = SPECTRA_BOTTOM_MARGIN;
|
|
20
21
|
if (verticalAlign === 'center') {
|
|
21
22
|
bottomShift = 0;
|
|
22
23
|
const maxim = Math.max(Math.abs(max), Math.abs(min));
|
|
@@ -9,7 +9,7 @@ export declare function useKeyModifiers(): KeyModifiers;
|
|
|
9
9
|
interface KeyModifierProviderProps {
|
|
10
10
|
children: ReactNode;
|
|
11
11
|
}
|
|
12
|
-
export declare function getModifiers(event: KeyboardEvent): {
|
|
12
|
+
export declare function getModifiers(event: KeyboardEvent | MouseEvent): {
|
|
13
13
|
ctrlKey: boolean;
|
|
14
14
|
shiftKey: boolean;
|
|
15
15
|
altKey: boolean;
|
|
@@ -17,8 +17,8 @@ export default function useExport() {
|
|
|
17
17
|
const saveToClipboardHandler = useCallback(async () => {
|
|
18
18
|
if (state.data.length > 0 && rootRef) {
|
|
19
19
|
const hideLoading = await alert.showLoading('Exporting as NMRium process in progress');
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
copyPNGToClipboard(rootRef, 'nmrSVG');
|
|
20
|
+
setTimeout(async () => {
|
|
21
|
+
await copyPNGToClipboard(rootRef, 'nmrSVG');
|
|
22
22
|
hideLoading();
|
|
23
23
|
alert.success('Image copied to clipboard');
|
|
24
24
|
}, 0);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useDispatch } from '../context/DispatchContext';
|
|
2
|
+
import { getModifiers } from '../context/KeyModifierContext';
|
|
3
|
+
export function useSetActiveSpectrumAction() {
|
|
4
|
+
const dispatch = useDispatch();
|
|
5
|
+
function setActiveSpectrum(e, id) {
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
const { ctrlKey, shiftKey } = getModifiers(e);
|
|
8
|
+
const modifier = `shift[${shiftKey ? 'true' : 'false'}]_ctrl[${ctrlKey ? 'true' : 'false'}]`;
|
|
9
|
+
dispatch({
|
|
10
|
+
type: 'CHANGE_ACTIVE_SPECTRUM',
|
|
11
|
+
payload: { modifier, id },
|
|
12
|
+
});
|
|
13
|
+
}, 0);
|
|
14
|
+
}
|
|
15
|
+
return { setActiveSpectrum };
|
|
16
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useVerticalAlign():
|
|
1
|
+
export declare function useVerticalAlign(): import("../reducer/Reducer").VerticalAlignment;
|
|
@@ -44,7 +44,7 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
|
|
|
44
44
|
return rootRef?.current ? getBlob(rootRef.current, 'nmrSVG') : null;
|
|
45
45
|
},
|
|
46
46
|
}), []);
|
|
47
|
-
return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(GlobalProvider, { value: {
|
|
47
|
+
return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, translate: "no", children: _jsx(GlobalProvider, { value: {
|
|
48
48
|
rootRef: rootRef.current,
|
|
49
49
|
elementsWrapperRef: elementsWrapperRef.current,
|
|
50
50
|
viewerRef: viewerRef.current,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
2
|
import { hasCouplingConstant } from '../../../../panels/extra/utilities/MultiplicityUtilities';
|
|
3
3
|
const editRangeFormValidation = Yup.object().shape({
|
|
4
|
-
signals: Yup.array()
|
|
5
|
-
.of(Yup.object().shape({
|
|
4
|
+
signals: Yup.array().of(Yup.object().shape({
|
|
6
5
|
js: Yup.array()
|
|
7
6
|
.of(Yup.object().shape({
|
|
8
7
|
multiplicity: Yup.string().required(),
|
|
@@ -22,7 +21,6 @@ const editRangeFormValidation = Yup.object().shape({
|
|
|
22
21
|
}),
|
|
23
22
|
}))
|
|
24
23
|
.min(1, 'There must be at least one coupling in a signal'),
|
|
25
|
-
}))
|
|
26
|
-
.min(1, 'There must be at least one signal in a range!'),
|
|
24
|
+
})),
|
|
27
25
|
});
|
|
28
26
|
export default editRangeFormValidation;
|
|
@@ -58,12 +58,13 @@ function MatrixGenerationPanel() {
|
|
|
58
58
|
const { view: { spectra: { activeTab }, }, xDomain, data, } = useChartData();
|
|
59
59
|
const formRef = useRef(null);
|
|
60
60
|
const nucleusMatrixOptions = usePanelPreferences('matrixGeneration', activeTab);
|
|
61
|
+
const spectraPreferences = usePanelPreferences('spectra', activeTab);
|
|
61
62
|
const matrixOptions = getMatrixOptions(nucleusMatrixOptions, {
|
|
62
63
|
from: xDomain[0],
|
|
63
64
|
to: xDomain[1],
|
|
64
65
|
});
|
|
65
66
|
function handleExportAsMatrix() {
|
|
66
|
-
exportAsMatrix(data, 'Spectra Matrix');
|
|
67
|
+
exportAsMatrix(data, spectraPreferences?.columns || [], 'Spectra Matrix');
|
|
67
68
|
}
|
|
68
69
|
function handleSave(options) {
|
|
69
70
|
dispatch({ type: 'APPLY_SIGNAL_PROCESSING_FILTER', payload: { options } });
|
|
@@ -8,7 +8,8 @@ interface MoleculePanelHeaderProps {
|
|
|
8
8
|
onOpenMoleculeEditor: () => void;
|
|
9
9
|
renderSource?: 'moleculePanel' | 'predictionPanel';
|
|
10
10
|
onClickPreferences?: () => void;
|
|
11
|
+
onClickPastMolecule?: () => void;
|
|
11
12
|
children?: ReactNode;
|
|
12
13
|
}
|
|
13
|
-
export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource, onClickPreferences, children, }: MoleculePanelHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource, onClickPreferences, onClickPastMolecule, children, }: MoleculePanelHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
export {};
|
|
@@ -64,7 +64,7 @@ const MOL_EXPORT_MENU = [
|
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
66
|
];
|
|
67
|
-
export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource = 'moleculePanel', onClickPreferences, children, }) {
|
|
67
|
+
export default function MoleculePanelHeader({ currentIndex, molecules, moleculesView, onMoleculeIndexChange, onOpenMoleculeEditor, renderSource = 'moleculePanel', onClickPreferences, onClickPastMolecule, children, }) {
|
|
68
68
|
const { rootRef } = useGlobal();
|
|
69
69
|
const alert = useAlert();
|
|
70
70
|
const dispatch = useDispatch();
|
|
@@ -75,10 +75,10 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
75
75
|
return;
|
|
76
76
|
exportAsSVG(rootRef, `molSVG${currentIndex} `, 'molFile');
|
|
77
77
|
}, [rootRef, currentIndex]);
|
|
78
|
-
const saveAsPNGHandler = useCallback(() => {
|
|
78
|
+
const saveAsPNGHandler = useCallback(async () => {
|
|
79
79
|
if (!rootRef)
|
|
80
80
|
return;
|
|
81
|
-
copyPNGToClipboard(rootRef, `molSVG${currentIndex} `);
|
|
81
|
+
await copyPNGToClipboard(rootRef, `molSVG${currentIndex} `);
|
|
82
82
|
alert.success('MOL copied as PNG to clipboard');
|
|
83
83
|
}, [rootRef, alert, currentIndex]);
|
|
84
84
|
const { rawWriteWithType, readText, shouldFallback, cleanShouldFallback, text, } = useClipboard();
|
|
@@ -99,7 +99,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
101
|
case 'png':
|
|
102
|
-
saveAsPNGHandler();
|
|
102
|
+
void saveAsPNGHandler();
|
|
103
103
|
break;
|
|
104
104
|
case 'svg':
|
|
105
105
|
saveAsSVGHandler();
|
|
@@ -116,6 +116,7 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
116
116
|
saveAsSVGHandler,
|
|
117
117
|
]);
|
|
118
118
|
function handlePasteMolfileAction() {
|
|
119
|
+
onClickPastMolecule?.();
|
|
119
120
|
void readText().then(handlePasteMolfile);
|
|
120
121
|
}
|
|
121
122
|
async function handlePasteMolfile(molfile) {
|
|
@@ -153,5 +154,5 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
|
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
const hasMolecules = molecules && molecules.length > 0;
|
|
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" })] }));
|
|
157
|
+
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 or SMILES", 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" })] }));
|
|
157
158
|
}
|
|
@@ -12,14 +12,9 @@ import { useAlert } from '../../elements/popup/Alert';
|
|
|
12
12
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
13
13
|
import ExportAsJcampModal from '../../modal/ExportAsJcampModal';
|
|
14
14
|
import ColorIndicator from './base/ColorIndicator';
|
|
15
|
+
import { RenderAsHTML } from './base/RenderAsHTML';
|
|
15
16
|
import ShowHideSpectrumButton from './base/ShowHideSpectrumButton';
|
|
16
17
|
import { SpectrumName } from './base/SpectrumName';
|
|
17
|
-
function formatValueAsHTML(value) {
|
|
18
|
-
if (value) {
|
|
19
|
-
value = value.replaceAll(/(?<value>\d+)/g, '<sub>$<value></sub>');
|
|
20
|
-
}
|
|
21
|
-
return value;
|
|
22
|
-
}
|
|
23
18
|
function getActiveSpectraAsObject(activeSpectra) {
|
|
24
19
|
const result = {};
|
|
25
20
|
if (activeSpectra) {
|
|
@@ -34,6 +29,7 @@ function getActiveSpectraAsObject(activeSpectra) {
|
|
|
34
29
|
const columnStyle = {
|
|
35
30
|
maxWidth: 0,
|
|
36
31
|
overflow: 'hidden',
|
|
32
|
+
height: '24px',
|
|
37
33
|
};
|
|
38
34
|
const options = [
|
|
39
35
|
{
|
|
@@ -86,38 +82,18 @@ export function SpectraTable(props) {
|
|
|
86
82
|
style: {
|
|
87
83
|
width: '35px',
|
|
88
84
|
maxWidth: '55px',
|
|
85
|
+
height: '24px',
|
|
89
86
|
},
|
|
90
87
|
Cell: ({ row }) => {
|
|
91
88
|
return (_jsx(ShowHideSpectrumButton, { data: row.original, onChangeVisibility: onChangeVisibility }));
|
|
92
89
|
},
|
|
93
90
|
},
|
|
94
|
-
name: {
|
|
95
|
-
Header: '',
|
|
96
|
-
style: columnStyle,
|
|
97
|
-
accessor: (row) => row.info.name,
|
|
98
|
-
Cell: ({ row }) => {
|
|
99
|
-
return _jsx(SpectrumName, { data: row.original });
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
solvent: {
|
|
103
|
-
Header: '',
|
|
104
|
-
style: columnStyle,
|
|
105
|
-
accessor: (row) => row.info.solvent,
|
|
106
|
-
Cell: ({ row }) => {
|
|
107
|
-
const info = row.original.info;
|
|
108
|
-
return (info?.solvent && (_jsx("div", {
|
|
109
|
-
// style={styles.info}
|
|
110
|
-
// eslint-disable-next-line react/no-danger
|
|
111
|
-
dangerouslySetInnerHTML: {
|
|
112
|
-
__html: formatValueAsHTML(info.solvent),
|
|
113
|
-
} })));
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
91
|
color: {
|
|
117
92
|
id: 'spectrum-actions',
|
|
118
93
|
style: {
|
|
119
94
|
width: '30px',
|
|
120
95
|
maxWidth: '30px',
|
|
96
|
+
height: '24px',
|
|
121
97
|
},
|
|
122
98
|
Cell: ({ row }) => {
|
|
123
99
|
const { display, info: { dimension, isFid }, } = row.original;
|
|
@@ -170,21 +146,33 @@ export function SpectraTable(props) {
|
|
|
170
146
|
...COLUMNS[name],
|
|
171
147
|
Header: () => _jsx(ColumnHeader, { label: col.label, col: col }),
|
|
172
148
|
id: name,
|
|
173
|
-
style: name === 'name' && visibleColumns.length > 3
|
|
174
|
-
? {
|
|
175
|
-
...COLUMNS[name].style,
|
|
176
|
-
width: '50%',
|
|
177
|
-
}
|
|
178
|
-
: COLUMNS[name].style,
|
|
179
149
|
});
|
|
180
150
|
}
|
|
181
151
|
else {
|
|
182
|
-
|
|
152
|
+
const pathString = path.join('.');
|
|
153
|
+
let style = columnStyle;
|
|
154
|
+
let cellRender = null;
|
|
155
|
+
if (pathString === 'info.name') {
|
|
156
|
+
if (visibleColumns.length > 3) {
|
|
157
|
+
style = { ...columnStyle, width: '50%' };
|
|
158
|
+
}
|
|
159
|
+
cellRender = ({ row }) => {
|
|
160
|
+
return _jsx(SpectrumName, { data: row.original });
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (pathString === 'info.solvent') {
|
|
164
|
+
cellRender = ({ row }) => {
|
|
165
|
+
return _jsx(RenderAsHTML, { data: row.original, jpath: pathString });
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
const cell = {
|
|
183
169
|
Header: () => _jsx(ColumnHeader, { label: col.label, col: col }),
|
|
184
170
|
accessor: (row) => lodashGet(row, path, ''),
|
|
171
|
+
...(cellRender && { Cell: cellRender }),
|
|
185
172
|
id: `${index}`,
|
|
186
|
-
style
|
|
187
|
-
}
|
|
173
|
+
style,
|
|
174
|
+
};
|
|
175
|
+
columns.push(cell);
|
|
188
176
|
}
|
|
189
177
|
index++;
|
|
190
178
|
}
|
|
@@ -204,7 +192,7 @@ export function SpectraTable(props) {
|
|
|
204
192
|
activated: { opacity: 1 },
|
|
205
193
|
};
|
|
206
194
|
}
|
|
207
|
-
return (_jsxs(_Fragment, { children: [_jsx(ReactTable, { rowStyle: handleRowStyle, activeRow: handleActiveRow, data: data, columns: tableColumns, onClick: (e, data) => onChangeActiveSpectrum(e, data.original), enableVirtualScroll: true, approxItemHeight:
|
|
195
|
+
return (_jsxs(_Fragment, { children: [_jsx(ReactTable, { rowStyle: handleRowStyle, activeRow: handleActiveRow, data: data, columns: tableColumns, onClick: (e, data) => onChangeActiveSpectrum(e, data.original), enableVirtualScroll: true, approxItemHeight: 24, contextMenu: data.info && data.info.dimension === 1
|
|
208
196
|
? Spectra1DContextMenuOptions
|
|
209
197
|
: Spectra2DContextMenuOptions, onContextMenuSelect: selectContextMenuHandler, onSortEnd: handleSortEnd, style: { 'table td': { paddingTop: 0, paddingBottom: 0 } } }), exportedSpectrum && (_jsx(ExportAsJcampModal, { spectrum: exportedSpectrum, closeDialog: () => {
|
|
210
198
|
setExportedSpectrum(null);
|
|
@@ -4,10 +4,10 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import { useState, useMemo, memo, useCallback } from 'react';
|
|
5
5
|
import { useChartData } from '../../context/ChartContext';
|
|
6
6
|
import { useDispatch } from '../../context/DispatchContext';
|
|
7
|
-
import { getModifiers } from '../../context/KeyModifierContext';
|
|
8
7
|
import IsotopesViewer from '../../elements/IsotopesViewer';
|
|
9
8
|
import Tab from '../../elements/Tab/Tab';
|
|
10
9
|
import Tabs from '../../elements/Tab/Tabs';
|
|
10
|
+
import { useSetActiveSpectrumAction } from '../../hooks/useSetActiveSpectrumAction';
|
|
11
11
|
import groupByInfoKey from '../../utility/GroupByInfoKey';
|
|
12
12
|
import { SpectraTable } from './SpectraTable';
|
|
13
13
|
import SpectrumSetting from './base/setting/SpectrumSetting';
|
|
@@ -22,6 +22,7 @@ function SpectrumsTabsInner({ data, activeSpectra, activeTab, }) {
|
|
|
22
22
|
const groupByNucleus = groupByInfoKey('nucleus');
|
|
23
23
|
return groupByNucleus(data, true);
|
|
24
24
|
}, [data]);
|
|
25
|
+
const { setActiveSpectrum } = useSetActiveSpectrumAction();
|
|
25
26
|
function onTabChangeHandler(tab) {
|
|
26
27
|
dispatch({ type: 'SET_ACTIVE_TAB', payload: { tab: tab.tabid } });
|
|
27
28
|
}
|
|
@@ -44,14 +45,7 @@ function SpectrumsTabsInner({ data, activeSpectra, activeTab, }) {
|
|
|
44
45
|
});
|
|
45
46
|
}, [dispatch]);
|
|
46
47
|
function handleChangeActiveSpectrum(e, spectrum) {
|
|
47
|
-
|
|
48
|
-
const { ctrlKey, shiftKey } = getModifiers(e);
|
|
49
|
-
const modifier = `shift[${shiftKey ? 'true' : 'false'}]_ctrl[${ctrlKey ? 'true' : 'false'}]`;
|
|
50
|
-
dispatch({
|
|
51
|
-
type: 'CHANGE_ACTIVE_SPECTRUM',
|
|
52
|
-
payload: { modifier, id: spectrum.id },
|
|
53
|
-
});
|
|
54
|
-
}, 0);
|
|
48
|
+
setActiveSpectrum(e, spectrum.id);
|
|
55
49
|
}
|
|
56
50
|
function mouseLeaveHandler() {
|
|
57
51
|
setIsSettingModalDisplayed(false);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import lodashGet from 'lodash/get';
|
|
3
|
+
function formatValueAsHTML(value) {
|
|
4
|
+
if (value) {
|
|
5
|
+
value = value.replaceAll(/(?<value>\d+)/g, '<sub>$<value></sub>');
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
export function RenderAsHTML(props) {
|
|
10
|
+
const { data, jpath } = props;
|
|
11
|
+
const value = lodashGet(data, jpath);
|
|
12
|
+
if (!value) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return (_jsx("div", {
|
|
16
|
+
// style={styles.info}
|
|
17
|
+
// eslint-disable-next-line react/no-danger
|
|
18
|
+
dangerouslySetInnerHTML: {
|
|
19
|
+
__html: formatValueAsHTML(value),
|
|
20
|
+
} }));
|
|
21
|
+
}
|
|
@@ -31,7 +31,12 @@ const emptyKeywords = {
|
|
|
31
31
|
searchKeywords: '',
|
|
32
32
|
};
|
|
33
33
|
function mapKeywordsToArray(searchKeywords, solvent) {
|
|
34
|
-
const values = searchKeywords
|
|
34
|
+
const values = searchKeywords
|
|
35
|
+
? searchKeywords
|
|
36
|
+
.trim()
|
|
37
|
+
.split(' ')
|
|
38
|
+
.filter((value) => value !== '')
|
|
39
|
+
: [];
|
|
35
40
|
if (solvent !== '-1') {
|
|
36
41
|
values.unshift(`solvent:${solvent}`);
|
|
37
42
|
}
|
|
@@ -93,7 +93,7 @@ export default function AnalysisChart(props) {
|
|
|
93
93
|
}
|
|
94
94
|
function handleCopy() {
|
|
95
95
|
if (chartParentRef.current) {
|
|
96
|
-
copyPNGToClipboard(chartParentRef.current, svgId, css({ text: { fill: 'black' } }));
|
|
96
|
+
void copyPNGToClipboard(chartParentRef.current, svgId, css({ text: { fill: 'black' } }));
|
|
97
97
|
alert.success('Chart copied to clipboard');
|
|
98
98
|
}
|
|
99
99
|
}
|
|
@@ -107,7 +107,9 @@ export default function PredictionPanel() {
|
|
|
107
107
|
setFlipStatus(false);
|
|
108
108
|
}
|
|
109
109
|
const isPredictedBefore = !!(molecules[currentIndex]?.id && predictions[molecules[currentIndex].id]);
|
|
110
|
-
return (_jsxs("div", { css: tablePanelStyle, children: [isFlipped && (_jsxs(_Fragment, { children: [_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler }), _jsx("div", { className: "inner-container", children: _jsx(PredictionPreferences, { ref: settingRef }) })] })), !isFlipped && (_jsxs(_Fragment, { children: [_jsx(MoleculePanelHeader, { currentIndex: currentIndex, moleculesView: moleculesView, molecules: molecules, renderSource: "predictionPanel", onClickPreferences: settingsPanelHandler, onOpenMoleculeEditor: () => openMoleculeEditor(),
|
|
110
|
+
return (_jsxs("div", { css: tablePanelStyle, children: [isFlipped && (_jsxs(_Fragment, { children: [_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler }), _jsx("div", { className: "inner-container", children: _jsx(PredictionPreferences, { ref: settingRef }) })] })), !isFlipped && (_jsxs(_Fragment, { children: [_jsx(MoleculePanelHeader, { currentIndex: currentIndex, moleculesView: moleculesView, molecules: molecules, renderSource: "predictionPanel", onClickPreferences: settingsPanelHandler, onOpenMoleculeEditor: () => openMoleculeEditor(), onClickPastMolecule: () => {
|
|
111
|
+
refreshSlider.current = true;
|
|
112
|
+
}, children: _jsx(PredictionSimpleOptions, {}) }), _jsxs("div", { style: styles.flexColumnContainer, children: [_jsx("div", { style: { flex: 1 }, children: _jsx(ResponsiveChart, { children: ({ height, width }) => {
|
|
111
113
|
return (_jsx(NextPrev, { onChange: (slideIndex) => {
|
|
112
114
|
setCurrentIndex(slideIndex);
|
|
113
115
|
setMolfile(molecules[slideIndex].molfile);
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { Formik } from 'formik';
|
|
5
5
|
import { useCallback, useState, useRef, useMemo } from 'react';
|
|
6
|
+
import * as Yup from 'yup';
|
|
6
7
|
import { defaultSimulationOptions, } from '../../../data/data1d/spectrumSimulation';
|
|
7
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
8
9
|
import Button from '../../elements/Button';
|
|
@@ -14,6 +15,14 @@ import PreferencesHeader from '../header/PreferencesHeader';
|
|
|
14
15
|
import SpectrumSimulationPreferences from './SpectrumSimulationPreferences';
|
|
15
16
|
import SpectrumSimulationSimpleOptions from './SpectrumSimulationSimpleOptions';
|
|
16
17
|
import { SpinSystemTable } from './SpinSystemTable';
|
|
18
|
+
const validationSchema = Yup.object({
|
|
19
|
+
data: Yup.array().of(Yup.array().of(Yup.lazy((value) => {
|
|
20
|
+
if (value === null) {
|
|
21
|
+
return Yup.mixed().nullable();
|
|
22
|
+
}
|
|
23
|
+
return Yup.number().required();
|
|
24
|
+
}))),
|
|
25
|
+
});
|
|
17
26
|
export default function SpectrumSimulation() {
|
|
18
27
|
const dispatch = useDispatch();
|
|
19
28
|
const [isFlipped, setFlipStatus] = useState(false);
|
|
@@ -51,10 +60,12 @@ export default function SpectrumSimulation() {
|
|
|
51
60
|
return rows;
|
|
52
61
|
}, [spinSystem]);
|
|
53
62
|
function simulateHandler(values, keepSpectrum = false) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
if (validationSchema.isValidSync(values)) {
|
|
64
|
+
dispatch({
|
|
65
|
+
type: 'SIMULATE_SPECTRUM',
|
|
66
|
+
payload: { ...values, spinSystem: spinSystemRef.current, keepSpectrum },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
58
69
|
}
|
|
59
70
|
function addSpectrumHandler() {
|
|
60
71
|
const values = formRef.current?.values;
|
|
@@ -13,8 +13,8 @@ type MoveXAxisAction = ActionType<'MOVE', {
|
|
|
13
13
|
}>;
|
|
14
14
|
export type DomainActions = SetXDomainAction | SetYDomainAction | MoveXAxisAction;
|
|
15
15
|
declare function getDomain(draft: Draft<State>): {
|
|
16
|
-
xDomain: [number, number] | [undefined, undefined];
|
|
17
|
-
yDomain: [number, number] | [undefined, undefined];
|
|
16
|
+
xDomain: [number, number] | never[] | [undefined, undefined];
|
|
17
|
+
yDomain: [number, number] | never[] | [undefined, undefined];
|
|
18
18
|
yDomains: Record<string, number[]>;
|
|
19
19
|
xDomains: Record<string, number[]>;
|
|
20
20
|
};
|
|
@@ -47,8 +47,8 @@ function getDomain(draft) {
|
|
|
47
47
|
reportError(error);
|
|
48
48
|
}
|
|
49
49
|
return {
|
|
50
|
-
xDomain: extent(xArray),
|
|
51
|
-
yDomain: extent(yArray),
|
|
50
|
+
xDomain: xArray?.length > 0 ? extent(xArray) : [],
|
|
51
|
+
yDomain: yArray?.length > 0 ? extent(yArray) : [],
|
|
52
52
|
yDomains,
|
|
53
53
|
xDomains,
|
|
54
54
|
};
|
|
@@ -612,7 +612,6 @@ function handleSignalProcessingFilter(draft, action) {
|
|
|
612
612
|
const { data, view } = draft;
|
|
613
613
|
const nucleus = view.spectra.activeTab;
|
|
614
614
|
const value = action.payload.options;
|
|
615
|
-
const activeFilterIndex = getActiveFilterIndex(draft);
|
|
616
615
|
const spectra = getSpectraByNucleus(nucleus, data);
|
|
617
616
|
for (const spectrum of spectra) {
|
|
618
617
|
FiltersManager.applyFilter(spectrum, [
|
|
@@ -620,7 +619,7 @@ function handleSignalProcessingFilter(draft, action) {
|
|
|
620
619
|
name: signalProcessing.id,
|
|
621
620
|
value,
|
|
622
621
|
},
|
|
623
|
-
], {
|
|
622
|
+
], { forceReapply: true });
|
|
624
623
|
}
|
|
625
624
|
const { updateXDomain, updateYDomain } = signalProcessing.DOMAIN_UPDATE_RULES;
|
|
626
625
|
setDomain(draft, { updateXDomain, updateYDomain });
|
|
@@ -79,13 +79,17 @@ function setSpectraMetaInfo(draft, spectraMetaInfo) {
|
|
|
79
79
|
//action
|
|
80
80
|
function handleChangeSpectrumVisibilityById(draft, action) {
|
|
81
81
|
const { id, key } = action.payload;
|
|
82
|
-
const
|
|
82
|
+
const { xDomain, data } = draft;
|
|
83
|
+
const spectrum = data.find((d) => d.id === id);
|
|
83
84
|
if (spectrum) {
|
|
84
85
|
spectrum.display[key] = !spectrum.display[key];
|
|
85
86
|
if (spectrum.info.dimension === 2) {
|
|
86
87
|
spectrum.display.isVisible = checkIsVisible2D(spectrum);
|
|
87
88
|
}
|
|
88
89
|
}
|
|
90
|
+
if (xDomain?.length === 0) {
|
|
91
|
+
setDomain(draft);
|
|
92
|
+
}
|
|
89
93
|
}
|
|
90
94
|
//action
|
|
91
95
|
function handleChangeSpectraVisibilityByNucleus(draft, action) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
2
|
import { State, VerticalAlignment } from '../Reducer';
|
|
3
|
-
export declare function getVerticalAlign(state: State | Draft<State>, defaultAlign?: VerticalAlignment):
|
|
3
|
+
export declare function getVerticalAlign(state: State | Draft<State>, defaultAlign?: VerticalAlignment): VerticalAlignment;
|
|
@@ -12,16 +12,12 @@ const getSpectraDefaultValues = (nucleus) => {
|
|
|
12
12
|
visible: true,
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
name: 'name',
|
|
16
15
|
label: 'Spectrum Name',
|
|
17
|
-
description: 'Spectrum Name',
|
|
18
16
|
jpath: ['info', 'name'],
|
|
19
17
|
visible: true,
|
|
20
18
|
},
|
|
21
19
|
{
|
|
22
|
-
name: 'solvent',
|
|
23
20
|
label: 'Solvent',
|
|
24
|
-
description: 'Solvent',
|
|
25
21
|
jpath: ['info', 'solvent'],
|
|
26
22
|
visible: true,
|
|
27
23
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SerializedStyles } from '@emotion/react';
|
|
2
|
+
import { SpectraTableColumn } from 'nmr-load-save';
|
|
2
3
|
/**
|
|
3
4
|
* export the experiments result in JSON format
|
|
4
5
|
* @param data
|
|
@@ -7,7 +8,7 @@ import { SerializedStyles } from '@emotion/react';
|
|
|
7
8
|
* @param isCompressed
|
|
8
9
|
*/
|
|
9
10
|
declare function exportAsJSON(data: any, fileName?: string, spaceIndent?: number, isCompressed?: boolean): Promise<void>;
|
|
10
|
-
declare function exportAsMatrix(data: any, fileName?: string): void;
|
|
11
|
+
declare function exportAsMatrix(data: any, spectraColumns: SpectraTableColumn[], fileName?: string): void;
|
|
11
12
|
declare function exportAsNMRE(data: any, fileName?: string): void;
|
|
12
13
|
declare function exportAsMol(data: any, fileName?: string): void;
|
|
13
14
|
/**
|
|
@@ -15,7 +16,7 @@ declare function exportAsMol(data: any, fileName?: string): void;
|
|
|
15
16
|
*/
|
|
16
17
|
declare function exportAsSVG(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
|
|
17
18
|
declare function exportAsPng(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
|
|
18
|
-
declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string, css?: SerializedStyles): void
|
|
19
|
+
declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string, css?: SerializedStyles): Promise<void>;
|
|
19
20
|
export interface BlobObject {
|
|
20
21
|
blob: Blob;
|
|
21
22
|
width: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { saveAs } from 'file-saver';
|
|
2
2
|
import JSZip from 'jszip';
|
|
3
|
-
import
|
|
3
|
+
import lodashGet from 'lodash/get';
|
|
4
4
|
/**
|
|
5
5
|
* export the experiments result in JSON format
|
|
6
6
|
* @param data
|
|
@@ -33,16 +33,29 @@ async function exportAsJSON(data, fileName = 'experiment', spaceIndent = 0, isCo
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
-
function exportAsMatrix(data, fileName = 'experiment') {
|
|
36
|
+
function exportAsMatrix(data, spectraColumns, fileName = 'experiment') {
|
|
37
37
|
//columns labels
|
|
38
|
-
const
|
|
38
|
+
const columnsLabels = [];
|
|
39
|
+
// listed the spectra panel columns
|
|
40
|
+
for (const col of spectraColumns) {
|
|
41
|
+
if (col.visible && 'jpath' in col) {
|
|
42
|
+
columnsLabels.push(col.label);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
39
45
|
for (const value of data[0].data.x) {
|
|
40
|
-
|
|
46
|
+
columnsLabels.push(value);
|
|
41
47
|
}
|
|
42
|
-
let matrix = `${
|
|
48
|
+
let matrix = `${columnsLabels.join('\t')}\n`;
|
|
43
49
|
for (const spectrum of data) {
|
|
44
|
-
const { data: { re },
|
|
45
|
-
const cellsValues = [
|
|
50
|
+
const { data: { re }, } = spectrum;
|
|
51
|
+
const cellsValues = [];
|
|
52
|
+
// listed the spectra cell values
|
|
53
|
+
for (const col of spectraColumns) {
|
|
54
|
+
if (col.visible && 'jpath' in col) {
|
|
55
|
+
const jpath = col?.jpath;
|
|
56
|
+
cellsValues.push(lodashGet(spectrum, jpath, `null`));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
46
59
|
for (const value of re) {
|
|
47
60
|
cellsValues.push(value);
|
|
48
61
|
}
|
|
@@ -107,29 +120,32 @@ function copyDataURLClipboardFireFox(image) {
|
|
|
107
120
|
document.execCommand('Copy');
|
|
108
121
|
img.remove();
|
|
109
122
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
123
|
+
async function resolveBlob(b) {
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
resolve(b);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async function writeImageToClipboard(image, isSafari = false) {
|
|
129
|
+
await navigator.clipboard.write([
|
|
130
|
+
new ClipboardItem({ [image.type]: isSafari ? resolveBlob(image) : image }),
|
|
131
|
+
]);
|
|
132
|
+
}
|
|
133
|
+
async function copyBlobToClipboard(canvas) {
|
|
134
|
+
canvas.toBlob(async (b) => {
|
|
112
135
|
if (!b)
|
|
113
136
|
return;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
})()
|
|
120
|
-
.catch(() => {
|
|
137
|
+
const isSafari = /^(?<safari>(?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
138
|
+
if (typeof ClipboardItem !== 'undefined') {
|
|
139
|
+
await writeImageToClipboard(b, isSafari).catch(reportError);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
121
142
|
const png = canvas.toDataURL('image/png', 1);
|
|
122
143
|
copyDataURLClipboardFireFox(png);
|
|
123
144
|
URL.revokeObjectURL(png);
|
|
124
|
-
}
|
|
125
|
-
.then(() => {
|
|
126
|
-
// eslint-disable-next-line no-console
|
|
127
|
-
console.log('experiment copied.');
|
|
128
|
-
})
|
|
129
|
-
.catch(reportError);
|
|
145
|
+
}
|
|
130
146
|
});
|
|
131
147
|
}
|
|
132
|
-
function copyPNGToClipboard(rootRef, elementID, css) {
|
|
148
|
+
async function copyPNGToClipboard(rootRef, elementID, css) {
|
|
133
149
|
const { blob, width, height } = getBlob(rootRef, elementID, css);
|
|
134
150
|
try {
|
|
135
151
|
const canvas = document.createElement('canvas');
|
|
@@ -142,16 +158,16 @@ function copyPNGToClipboard(rootRef, elementID, css) {
|
|
|
142
158
|
}
|
|
143
159
|
const img = new Image();
|
|
144
160
|
const url = URL.createObjectURL(blob);
|
|
145
|
-
img.addEventListener('load', () => {
|
|
161
|
+
img.addEventListener('load', async () => {
|
|
146
162
|
context?.drawImage(img, 0, 0);
|
|
147
|
-
copyBlobToClipboard(canvas);
|
|
163
|
+
await copyBlobToClipboard(canvas);
|
|
148
164
|
});
|
|
149
165
|
img.src = url;
|
|
150
166
|
}
|
|
151
167
|
catch (error) {
|
|
152
168
|
if (error instanceof ReferenceError) {
|
|
153
169
|
// eslint-disable-next-line no-alert
|
|
154
|
-
alert('Your browser does not support this feature, please use Google Chrome');
|
|
170
|
+
alert('Your browser does not support this feature, please use Google Chrome or Firefox');
|
|
155
171
|
}
|
|
156
172
|
// TODO: handle error.
|
|
157
173
|
reportError(error);
|
|
@@ -99,15 +99,19 @@ export function generateAnalyzeSpectra(multipleSpectraAnalysis, spectra, nucleus
|
|
|
99
99
|
const newData = Object.fromEntries(Object.entries(data).map((spectra) => {
|
|
100
100
|
const result = Object.fromEntries(Object.keys(columns).map((key) => {
|
|
101
101
|
const isFormula = columns[key].type === AnalysisColumnsTypes.FORMULA;
|
|
102
|
-
|
|
103
|
-
key
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
if (isFormula) {
|
|
103
|
+
const { SID, id } = spectra[1][key];
|
|
104
|
+
return [
|
|
105
|
+
key,
|
|
106
|
+
{
|
|
107
|
+
SID,
|
|
108
|
+
id,
|
|
106
109
|
colKey: key,
|
|
107
110
|
value: calculate(columns, data[spectra[0]], columns[key].formula),
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
return [key, { ...spectra[1][key], colKey: key }];
|
|
111
115
|
}));
|
|
112
116
|
return [spectra[0], result];
|
|
113
117
|
}));
|
|
@@ -147,52 +151,35 @@ export function getDataAsString(spectraAnalysis, spectra, spectraPanelPreference
|
|
|
147
151
|
const spectraData = convertSpectraArrayToObject(spectra);
|
|
148
152
|
if (spectraAnalysis) {
|
|
149
153
|
const { values, options: { columns }, } = spectraAnalysis;
|
|
150
|
-
|
|
154
|
+
//columns labels
|
|
155
|
+
const letters = Object.keys(columns);
|
|
156
|
+
const columnsLabels = letters.slice();
|
|
157
|
+
let index = 0;
|
|
151
158
|
// listed the spectra panel columns
|
|
152
159
|
for (const col of spectraPanelPreferences.columns) {
|
|
153
|
-
if (col.visible) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
result += `${col.label}\t`;
|
|
157
|
-
}
|
|
160
|
+
if (col.visible && 'jpath' in col) {
|
|
161
|
+
columnsLabels.splice(index, 0, col.label);
|
|
162
|
+
index++;
|
|
158
163
|
}
|
|
159
164
|
}
|
|
160
|
-
|
|
161
|
-
// listed the spectra analysis panel columns
|
|
162
|
-
for (const letter of letters) {
|
|
163
|
-
result += `${letter}\t`;
|
|
164
|
-
}
|
|
165
|
-
result += '\n';
|
|
165
|
+
let result = `${columnsLabels.join('\t')}\n`;
|
|
166
166
|
for (const spectrumAnalysis of Object.values(values)) {
|
|
167
167
|
const spectrum = spectraData[spectrumAnalysis[letters[0]].SID];
|
|
168
|
+
const cellsValues = [];
|
|
168
169
|
// listed the spectra cell values
|
|
169
170
|
for (const col of spectraPanelPreferences.columns) {
|
|
170
|
-
if (col.visible) {
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
switch (name) {
|
|
175
|
-
case 'name':
|
|
176
|
-
result += `${spectrum.info.name}\t`;
|
|
177
|
-
break;
|
|
178
|
-
case 'solvent':
|
|
179
|
-
result += `${spectrum.info.solvent || `null`}\t`;
|
|
180
|
-
break;
|
|
181
|
-
default:
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
const path = col?.jpath;
|
|
187
|
-
result += `${lodashGet(spectrum, path, `null`)}\t`;
|
|
188
|
-
}
|
|
171
|
+
if (col.visible && 'jpath' in col) {
|
|
172
|
+
const jpath = col?.jpath;
|
|
173
|
+
const value = lodashGet(spectrum, jpath, `null`);
|
|
174
|
+
cellsValues.push(value);
|
|
189
175
|
}
|
|
190
176
|
}
|
|
191
177
|
// listed the spectra analysis cell values
|
|
192
178
|
for (const letter of letters) {
|
|
193
|
-
|
|
179
|
+
const value = spectrumAnalysis[letter][columns[letter].valueKey];
|
|
180
|
+
cellsValues.push(value);
|
|
194
181
|
}
|
|
195
|
-
result += '\n
|
|
182
|
+
result += `${cellsValues.join('\t')}\n`;
|
|
196
183
|
}
|
|
197
184
|
return result;
|
|
198
185
|
}
|
|
@@ -33,7 +33,9 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
|
|
|
33
33
|
if (index === -1)
|
|
34
34
|
index = 0;
|
|
35
35
|
const info = {
|
|
36
|
-
|
|
36
|
+
...getInfo(datumInfo, index),
|
|
37
|
+
experiment: '1d',
|
|
38
|
+
pulseSequence: 'projection',
|
|
37
39
|
isFid: false,
|
|
38
40
|
isComplex: false, // if isComplex is true that mean it contains real/ imaginary x set, if not hid re/im button .
|
|
39
41
|
dimension: 1,
|
|
@@ -41,3 +43,10 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
|
|
|
41
43
|
const data = getProjection(datum, index);
|
|
42
44
|
return initiateDatum1D({ info, data }, { usedColors });
|
|
43
45
|
}
|
|
46
|
+
function getInfo(info, index) {
|
|
47
|
+
const newInfo = {};
|
|
48
|
+
for (const key in info) {
|
|
49
|
+
newInfo[key] = Array.isArray(info[key]) ? info[key][index] : info[key];
|
|
50
|
+
}
|
|
51
|
+
return newInfo;
|
|
52
|
+
}
|
package/lib/versionInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default { version: 'v0.
|
|
1
|
+
export default { version: 'v0.48.0' };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nmrium",
|
|
3
3
|
"description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.48.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "lib/component/main/index.js",
|
|
7
7
|
"types": "lib/component/main/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"url": "git+https://github.com/cheminfo/nmrium.git"
|
|
46
46
|
},
|
|
47
47
|
"volta": {
|
|
48
|
-
"node": "20.
|
|
48
|
+
"node": "20.11.0"
|
|
49
49
|
},
|
|
50
50
|
"overrides": {
|
|
51
51
|
"react": "$react",
|
|
@@ -56,20 +56,20 @@
|
|
|
56
56
|
"react-dom": ">=18.0.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@blueprintjs/core": "^5.
|
|
60
|
-
"@blueprintjs/icons": "^5.
|
|
61
|
-
"@emotion/react": "^11.11.
|
|
59
|
+
"@blueprintjs/core": "^5.8.2",
|
|
60
|
+
"@blueprintjs/icons": "^5.7.0",
|
|
61
|
+
"@emotion/react": "^11.11.3",
|
|
62
62
|
"@emotion/styled": "^11.11.0",
|
|
63
63
|
"@lukeed/uuid": "^2.0.1",
|
|
64
|
-
"cheminfo-font": "^1.
|
|
64
|
+
"cheminfo-font": "^1.13.0",
|
|
65
65
|
"cheminfo-types": "^1.7.2",
|
|
66
|
-
"clipboard-polyfill": "^4.0.
|
|
66
|
+
"clipboard-polyfill": "^4.0.2",
|
|
67
67
|
"convert-to-jcamp": "^5.4.9",
|
|
68
68
|
"d3": "^7.8.5",
|
|
69
69
|
"eventemitter3": "^5.0.1",
|
|
70
70
|
"fifo-logger": "^0.6.1",
|
|
71
71
|
"file-saver": "^2.0.5",
|
|
72
|
-
"filelist-utils": "^1.
|
|
72
|
+
"filelist-utils": "^1.11.0",
|
|
73
73
|
"formik": "^2.4.5",
|
|
74
74
|
"immer": "^10.0.3",
|
|
75
75
|
"jszip": "^3.10.1",
|
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"react-d3-utils": "^1.0.0",
|
|
98
98
|
"react-dropzone": "^14.2.3",
|
|
99
99
|
"react-error-boundary": "^4.0.12",
|
|
100
|
-
"react-icons": "^
|
|
100
|
+
"react-icons": "^5.0.1",
|
|
101
101
|
"react-inspector": "^6.0.2",
|
|
102
102
|
"react-mf": "^2.0.2",
|
|
103
103
|
"react-ocl": "^6.1.0",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"react-slider": "^2.0.6",
|
|
109
109
|
"react-table": "^7.8.0",
|
|
110
110
|
"react-transition-group": "^4.4.5",
|
|
111
|
-
"react-use": "^17.
|
|
111
|
+
"react-use": "^17.5.0",
|
|
112
112
|
"smart-array-filter": "^4.0.2",
|
|
113
113
|
"yup": "^1.3.3"
|
|
114
114
|
},
|
|
@@ -116,36 +116,36 @@
|
|
|
116
116
|
"@babel/plugin-transform-modules-commonjs": "^7.23.3",
|
|
117
117
|
"@babel/preset-react": "^7.23.3",
|
|
118
118
|
"@babel/preset-typescript": "^7.23.3",
|
|
119
|
-
"@playwright/test": "^1.
|
|
119
|
+
"@playwright/test": "^1.41.1",
|
|
120
120
|
"@simbathesailor/use-what-changed": "^2.0.0",
|
|
121
121
|
"@types/d3": "^7.4.3",
|
|
122
122
|
"@types/lodash": "^4.14.202",
|
|
123
|
-
"@types/node": "^20.
|
|
123
|
+
"@types/node": "^20.11.5",
|
|
124
124
|
"@types/papaparse": "^5.3.14",
|
|
125
|
-
"@types/react": "^18.2.
|
|
125
|
+
"@types/react": "^18.2.48",
|
|
126
126
|
"@types/react-dom": "^18.2.18",
|
|
127
|
-
"@types/react-table": "^7.7.
|
|
127
|
+
"@types/react-table": "^7.7.19",
|
|
128
128
|
"@vitejs/plugin-react-swc": "^3.5.0",
|
|
129
|
-
"@vitest/coverage-v8": "^1.
|
|
129
|
+
"@vitest/coverage-v8": "^1.2.1",
|
|
130
130
|
"cross-env": "^7.0.3",
|
|
131
|
-
"cspell": "^8.
|
|
131
|
+
"cspell": "^8.3.2",
|
|
132
132
|
"eslint": "^8.56.0",
|
|
133
133
|
"eslint-config-cheminfo-react": "^10.1.0",
|
|
134
134
|
"eslint-config-cheminfo-typescript": "^12.1.0",
|
|
135
135
|
"modern-normalize": "^2.0.0",
|
|
136
|
-
"postcss-styled-syntax": "^0.
|
|
137
|
-
"prettier": "^3.
|
|
136
|
+
"postcss-styled-syntax": "^0.6.4",
|
|
137
|
+
"prettier": "^3.2.4",
|
|
138
138
|
"rc-menu": "^9.12.4",
|
|
139
139
|
"react": "^18.2.0",
|
|
140
140
|
"react-dom": "^18.2.0",
|
|
141
|
-
"react-router-dom": "^6.21.
|
|
141
|
+
"react-router-dom": "^6.21.3",
|
|
142
142
|
"rimraf": "^5.0.5",
|
|
143
143
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
144
144
|
"serve": "^14.2.1",
|
|
145
|
-
"stylelint": "^16.0
|
|
146
|
-
"stylelint-config-standard": "^
|
|
145
|
+
"stylelint": "^16.2.0",
|
|
146
|
+
"stylelint-config-standard": "^36.0.0",
|
|
147
147
|
"typescript": "^5.3.3",
|
|
148
|
-
"vite": "^5.0.
|
|
149
|
-
"vitest": "^1.
|
|
148
|
+
"vite": "^5.0.12",
|
|
149
|
+
"vitest": "^1.2.1"
|
|
150
150
|
}
|
|
151
151
|
}
|