nmrium 0.46.1 → 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/integral/Integration.js +2 -1
- package/lib/component/1d/peaks/Peaks.js +5 -4
- package/lib/component/1d/ranges/Range.js +3 -1
- 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/elements/formik/FormikColorPickerDropdown.d.ts +6 -0
- package/lib/component/elements/formik/FormikColorPickerDropdown.js +14 -0
- package/lib/component/hooks/useActiveSpectrumIntegralsViewState.js +1 -0
- package/lib/component/hooks/useActiveSpectrumRangesViewState.js +1 -0
- 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/loader/DropZone.js +4 -2
- package/lib/component/main/InnerNMRium.js +1 -1
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
- package/lib/component/modal/setting/GeneralSettings.js +2 -1
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.d.ts +2 -0
- package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +131 -0
- package/lib/component/modal/setting/settingsValidation.js +12 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +16 -2
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +2 -2
- 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/RangesPanel/RangesHeader.js +10 -2
- 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/databasePanel/DatabasePreferences.js +2 -2
- package/lib/component/panels/filtersPanel/FiltersTable.js +3 -2
- 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/Reducer.js +2 -0
- package/lib/component/reducer/actions/DatabaseActions.js +1 -1
- 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/IntegralsActions.d.ts +8 -2
- package/lib/component/reducer/actions/IntegralsActions.js +10 -1
- package/lib/component/reducer/actions/LoadActions.d.ts +3 -1
- package/lib/component/reducer/actions/LoadActions.js +9 -4
- package/lib/component/reducer/actions/SpectrumsActions.js +14 -4
- package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
- package/lib/component/toolbar/FunctionToolBar.js +2 -1
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +42 -26
- package/lib/component/workspaces/exercise.js +1 -0
- package/lib/component/workspaces/prediction.js +5 -0
- package/lib/component/workspaces/simulation.js +5 -0
- package/lib/component/workspaces/workspaceDefaultProperties.js +41 -0
- package/lib/data/PredictionManager.js +1 -1
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +9 -1
- package/lib/data/data1d/Spectrum1D/get1DColor.js +12 -4
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.d.ts +2 -1
- package/lib/data/data1d/Spectrum1D/initiateDatum1D.js +2 -2
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +7 -6
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -76
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +10 -0
- package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +70 -0
- package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
- package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +9 -2
- package/lib/data/data2d/Spectrum2D/get2DColor.js +13 -5
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.d.ts +7 -2
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +3 -2
- package/lib/data/utilities/getCustomColor.d.ts +4 -0
- package/lib/data/utilities/getCustomColor.js +38 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +25 -25
- package/lib/component/elements/formik/FormikColorInput.d.ts +0 -8
- package/lib/component/elements/formik/FormikColorInput.js +0 -15
|
@@ -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
|
}
|
|
@@ -45,7 +45,7 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
45
45
|
const assignmentData = useAssignmentData();
|
|
46
46
|
const currentSum = lodashGet(ranges, 'options.sum', null);
|
|
47
47
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
48
|
-
const { showMultiplicityTrees, showJGraph, showIntegrals, showPeaks, displayingMode, } = useActiveSpectrumRangesViewState();
|
|
48
|
+
const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, } = useActiveSpectrumRangesViewState();
|
|
49
49
|
function changeRangesSumHandler(options) {
|
|
50
50
|
dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
|
|
51
51
|
modal.close();
|
|
@@ -82,6 +82,12 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
82
82
|
payload: { key: 'showMultiplicityTrees' },
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
+
function handleShowIntegralsValues() {
|
|
86
|
+
dispatch({
|
|
87
|
+
type: 'TOGGLE_RANGES_VIEW_PROPERTY',
|
|
88
|
+
payload: { key: 'showIntegralsValues' },
|
|
89
|
+
});
|
|
90
|
+
}
|
|
85
91
|
function handleShowIntegrals() {
|
|
86
92
|
dispatch({
|
|
87
93
|
type: 'TOGGLE_RANGES_VIEW_PROPERTY',
|
|
@@ -127,6 +133,8 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
|
|
|
127
133
|
? `Change ranges sum (${currentSum.toFixed(2)})`
|
|
128
134
|
: 'Change ranges sum', popupPlacement: "right", className: "btn icon", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }), _jsx(Button, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(ActiveButton, { popupTitle: showMultiplicityTrees
|
|
129
135
|
? 'Hide multiplicity trees in spectrum'
|
|
130
|
-
: 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, {
|
|
136
|
+
: 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showIntegralsValues
|
|
137
|
+
? 'Hide integrals values'
|
|
138
|
+
: 'Show integrals values', popupPlacement: "right", onClick: handleShowIntegralsValues, value: showIntegralsValues, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration sum", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: _jsx(ImLink, {}) }), _jsx(PeaksToggleActions, { disbale: !hasRanges, showPeaks: showPeaks, onShowToggle: () => toggleViewProperty('showPeaks'), displayingMode: displayingMode, onDisplayingModeToggle: toggleDisplayingMode })] }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
|
|
131
139
|
}
|
|
132
140
|
export default RangesHeader;
|
|
@@ -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
|
}
|
|
@@ -3,7 +3,7 @@ import { Formik } from 'formik';
|
|
|
3
3
|
import { useEffect, useCallback, useImperativeHandle, useRef, forwardRef, } from 'react';
|
|
4
4
|
import { usePreferences } from '../../context/PreferencesContext';
|
|
5
5
|
import Label from '../../elements/Label';
|
|
6
|
-
import
|
|
6
|
+
import FormikColorPickerDropdown from '../../elements/formik/FormikColorPickerDropdown';
|
|
7
7
|
import FormikColumnFormatField, { formatFieldInputStyle, formatFieldLabelStyle, } from '../../elements/formik/FormikColumnFormatField';
|
|
8
8
|
import FormikInput from '../../elements/formik/FormikInput';
|
|
9
9
|
import { usePanelPreferences } from '../../hooks/usePanelPreferences';
|
|
@@ -27,6 +27,6 @@ function DatabasePreferences(props, ref) {
|
|
|
27
27
|
formRef.current.submitForm();
|
|
28
28
|
},
|
|
29
29
|
}));
|
|
30
|
-
return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: {}, onSubmit: saveHandler, innerRef: formRef, children: _jsxs(_Fragment, { children: [_jsxs(PreferencesGroup, { children: [_jsx(FormikColumnFormatField, { label: "Preview jcamp", checkControllerName: "previewJcamp", hideFormatField: true }), _jsx(Label, { title: "Color", style: formatFieldLabelStyle, children: _jsx(
|
|
30
|
+
return (_jsx(PreferencesContainer, { children: _jsx(Formik, { initialValues: {}, onSubmit: saveHandler, innerRef: formRef, children: _jsxs(_Fragment, { children: [_jsxs(PreferencesGroup, { children: [_jsx(FormikColumnFormatField, { label: "Preview jcamp", checkControllerName: "previewJcamp", hideFormatField: true }), _jsx(Label, { title: "Color", style: formatFieldLabelStyle, children: _jsx(FormikColorPickerDropdown, { name: "color" }) }), _jsx(Label, { title: "Margin bottom (px) :", style: formatFieldLabelStyle, children: _jsx(FormikInput, { name: "marginBottom", type: "number", style: formatFieldInputStyle }) })] }), _jsxs(PreferencesGroup, { header: "Table Preferences", children: [_jsx(FormikColumnFormatField, { label: "Structure", checkControllerName: "showSmiles", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Solvent", checkControllerName: "showSolvent", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Names", checkControllerName: "showNames", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Range", checkControllerName: "range.show", formatControllerName: "range.format" }), _jsx(FormikColumnFormatField, { label: "\u03B4 (ppm)", checkControllerName: "delta.show", formatControllerName: "delta.format" }), _jsx(FormikColumnFormatField, { label: "Assignment", checkControllerName: "showAssignment", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "J (Hz)", checkControllerName: "coupling.show", formatControllerName: "coupling.format" }), _jsx(FormikColumnFormatField, { label: "Multiplicity", checkControllerName: "showMultiplicity", hideFormatField: true }), _jsx(FormikColumnFormatField, { label: "Save as nmrium", checkControllerName: "allowSaveAsNMRium", hideFormatField: true })] })] }) }) }));
|
|
31
31
|
}
|
|
32
32
|
export default forwardRef(DatabasePreferences);
|
|
@@ -33,7 +33,8 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
33
33
|
const modal = useModal();
|
|
34
34
|
const alert = useAlert();
|
|
35
35
|
const selectedFilterIndex = useRef();
|
|
36
|
-
const handelFilterCheck = useCallback((id,
|
|
36
|
+
const handelFilterCheck = useCallback((id, event) => {
|
|
37
|
+
const { checked: enabled } = event.target;
|
|
37
38
|
void (async () => {
|
|
38
39
|
const hideLoading = await alert.showLoading(`${enabled ? 'Enable' : 'Disable'} filter in progress`);
|
|
39
40
|
setTimeout(() => {
|
|
@@ -109,7 +110,7 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
|
|
|
109
110
|
style: { width: '30px' },
|
|
110
111
|
Cell: ({ row }) => {
|
|
111
112
|
const { flag, id } = row.original;
|
|
112
|
-
return (_jsx(ColumnWrapper, { children: _jsx(Checkbox, { onChange: (
|
|
113
|
+
return (_jsx(ColumnWrapper, { children: _jsx(Checkbox, { onChange: (event) => handelFilterCheck(id, event), checked: flag }) }));
|
|
113
114
|
},
|
|
114
115
|
},
|
|
115
116
|
{
|
|
@@ -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;
|
|
@@ -173,6 +173,8 @@ function innerSpectrumReducer(draft, action) {
|
|
|
173
173
|
return IntegralsActions.handleChangeIntegralsRelativeValue(draft, action);
|
|
174
174
|
case 'CUT_INTEGRAL':
|
|
175
175
|
return IntegralsActions.handleCutIntegral(draft, action);
|
|
176
|
+
case 'TOGGLE_INTEGRALS_VIEW_PROPERTY':
|
|
177
|
+
return IntegralsActions.handleToggleIntegralsViewProperty(draft, action);
|
|
176
178
|
case 'SET_X_DOMAIN':
|
|
177
179
|
return DomainActions.handleSetXDomain(draft, action);
|
|
178
180
|
case 'SET_Y_DOMAIN':
|
|
@@ -13,7 +13,7 @@ function handleResurrectSpectrumFromJcamp(draft, action) {
|
|
|
13
13
|
},
|
|
14
14
|
display: {
|
|
15
15
|
...spectrum.display,
|
|
16
|
-
...get1DColor(spectrum.display, draft.usedColors),
|
|
16
|
+
...get1DColor(spectrum.display, { usedColors: draft.usedColors }),
|
|
17
17
|
},
|
|
18
18
|
};
|
|
19
19
|
draft.data.push(spectrum);
|
|
@@ -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 });
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
+
import { IntegralsViewState } from 'nmr-load-save';
|
|
2
3
|
import { Integral } from 'nmr-processing';
|
|
3
4
|
import { SetSumOptions } from '../../../data/data1d/Spectrum1D/SumManager';
|
|
4
5
|
import { State } from '../Reducer';
|
|
5
6
|
import { ActionType } from '../types/ActionType';
|
|
7
|
+
import { FilterType } from '../../utility/filterType';
|
|
6
8
|
type ChangeIntegralSumAction = ActionType<'CHANGE_INTEGRAL_SUM', {
|
|
7
9
|
options: SetSumOptions;
|
|
8
10
|
}>;
|
|
@@ -23,7 +25,10 @@ type ChangeIntegralRelativeValueAction = ActionType<'CHANGE_INTEGRAL_RELATIVE',
|
|
|
23
25
|
type CutIntegralAction = ActionType<'CUT_INTEGRAL', {
|
|
24
26
|
cutValue: number;
|
|
25
27
|
}>;
|
|
26
|
-
|
|
28
|
+
type ToggleIntegralsViewAction = ActionType<'TOGGLE_INTEGRALS_VIEW_PROPERTY', {
|
|
29
|
+
key: keyof FilterType<IntegralsViewState, boolean>;
|
|
30
|
+
}>;
|
|
31
|
+
export type IntegralsActions = ChangeIntegralSumAction | AddIntegralAction | DeleteIntegralAction | ChangeIntegralAction | ChangeIntegralRelativeValueAction | CutIntegralAction | ToggleIntegralsViewAction | ActionType<'CHANGE_INTEGRALS_SUM_FLAG'>;
|
|
27
32
|
declare function handleChangeIntegralSum(draft: Draft<State>, action: ChangeIntegralSumAction): void;
|
|
28
33
|
declare function handleAddIntegral(draft: Draft<State>, action: AddIntegralAction): void;
|
|
29
34
|
declare function handleDeleteIntegral(draft: Draft<State>, action: DeleteIntegralAction): void;
|
|
@@ -31,4 +36,5 @@ declare function handleChangeIntegral(draft: Draft<State>, action: ChangeIntegra
|
|
|
31
36
|
declare function handleChangeIntegralsRelativeValue(draft: Draft<State>, action: ChangeIntegralRelativeValueAction): void;
|
|
32
37
|
declare function handleChangeIntegralsSumFlag(draft: any): void;
|
|
33
38
|
declare function handleCutIntegral(draft: Draft<State>, action: CutIntegralAction): void;
|
|
34
|
-
|
|
39
|
+
declare function handleToggleIntegralsViewProperty(draft: Draft<State>, action: ToggleIntegralsViewAction): void;
|
|
40
|
+
export { handleCutIntegral, handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, handleToggleIntegralsViewProperty, };
|
|
@@ -6,6 +6,7 @@ import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/
|
|
|
6
6
|
import { getActiveSpectrum } from '../helper/getActiveSpectrum';
|
|
7
7
|
import getRange from '../helper/getRange';
|
|
8
8
|
import { getSpectrum } from '../helper/getSpectrum';
|
|
9
|
+
import { setIntegralsViewProperty } from '../helper/setIntegralsViewProperty';
|
|
9
10
|
function handleChangeIntegralSum(draft, action) {
|
|
10
11
|
const { options } = action.payload;
|
|
11
12
|
const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
|
|
@@ -121,4 +122,12 @@ function handleCutIntegral(draft, action) {
|
|
|
121
122
|
}
|
|
122
123
|
updateIntegralsRelativeValues(spectrum);
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
+
function toggleIntegralsViewProperty(draft, key) {
|
|
126
|
+
setIntegralsViewProperty(draft, key, (flag) => !flag);
|
|
127
|
+
}
|
|
128
|
+
//action
|
|
129
|
+
function handleToggleIntegralsViewProperty(draft, action) {
|
|
130
|
+
const { key } = action.payload;
|
|
131
|
+
toggleIntegralsViewProperty(draft, key);
|
|
132
|
+
}
|
|
133
|
+
export { handleCutIntegral, handleChangeIntegralSum, handleAddIntegral, handleDeleteIntegral, handleChangeIntegral, handleChangeIntegralsRelativeValue, handleChangeIntegralsSumFlag, handleToggleIntegralsViewProperty, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
-
import { Spectrum, NmriumState } from 'nmr-load-save';
|
|
2
|
+
import { Spectrum, NmriumState, SpectraColors } from 'nmr-load-save';
|
|
3
3
|
import { ParseResult } from 'papaparse';
|
|
4
4
|
import { StateMoleculeExtended } from '../../../data/molecules/Molecule';
|
|
5
5
|
import { UsedColors } from '../../../types/UsedColors';
|
|
@@ -13,6 +13,7 @@ interface InputProps extends InitiateProps {
|
|
|
13
13
|
usedColors?: UsedColors;
|
|
14
14
|
parseMetaFileResult?: ParseResult<any> | null;
|
|
15
15
|
resetSourceObject?: boolean;
|
|
16
|
+
spectraColors?: SpectraColors;
|
|
16
17
|
}
|
|
17
18
|
type SetIsLoadingAction = ActionType<'SET_LOADING_FLAG', {
|
|
18
19
|
isLoading: boolean;
|
|
@@ -23,6 +24,7 @@ export type LoadActions = SetIsLoadingAction | LoadDropFilesAction | InitiateAct
|
|
|
23
24
|
declare function initSpectra(inputSpectra: Spectrum[], options: {
|
|
24
25
|
usedColors: UsedColors;
|
|
25
26
|
molecules: StateMoleculeExtended[];
|
|
27
|
+
spectraColors: SpectraColors;
|
|
26
28
|
}): any;
|
|
27
29
|
declare function handleSetIsLoading(draft: Draft<State>, action: SetIsLoadingAction): void;
|
|
28
30
|
declare function handleInitiate(draft: Draft<State>, action: InitiateAction): State | undefined;
|
|
@@ -42,7 +42,7 @@ function setCorrelation(draft, correlations) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
function setData(draft, input) {
|
|
45
|
-
const { nmriumState: { data, view }, parseMetaFileResult = null, } = input || {
|
|
45
|
+
const { nmriumState: { data, view }, parseMetaFileResult = null, spectraColors = { oneDimension: [], twoDimensions: [] }, } = input || {
|
|
46
46
|
nmriumState: { data: { spectra: [], molecules: [], correlations: {} } },
|
|
47
47
|
multipleAnalysis: {},
|
|
48
48
|
};
|
|
@@ -62,6 +62,7 @@ function setData(draft, input) {
|
|
|
62
62
|
draft.data = draft.data.concat(initSpectra(spectra, {
|
|
63
63
|
usedColors: draft.usedColors,
|
|
64
64
|
molecules: draft.molecules,
|
|
65
|
+
spectraColors,
|
|
65
66
|
}));
|
|
66
67
|
setCorrelation(draft, correlations);
|
|
67
68
|
if (parseMetaFileResult) {
|
|
@@ -75,14 +76,18 @@ function setData(draft, input) {
|
|
|
75
76
|
}
|
|
76
77
|
function initSpectra(inputSpectra, options) {
|
|
77
78
|
const spectra = [];
|
|
78
|
-
const { usedColors, molecules } = options;
|
|
79
|
+
const { usedColors, molecules, spectraColors } = options;
|
|
79
80
|
for (const spectrum of inputSpectra) {
|
|
80
81
|
const { info } = spectrum;
|
|
81
82
|
if (info.dimension === 1) {
|
|
82
|
-
spectra.push(initiateDatum1D(spectrum, {
|
|
83
|
+
spectra.push(initiateDatum1D(spectrum, {
|
|
84
|
+
usedColors,
|
|
85
|
+
molecules,
|
|
86
|
+
colors: spectraColors.oneDimension,
|
|
87
|
+
}));
|
|
83
88
|
}
|
|
84
89
|
else if (info.dimension === 2) {
|
|
85
|
-
spectra.push(initiateDatum2D({ ...spectrum }, { usedColors }));
|
|
90
|
+
spectra.push(initiateDatum2D({ ...spectrum }, { usedColors, colors: spectraColors.twoDimensions }));
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
return spectra;
|
|
@@ -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) {
|
|
@@ -342,13 +346,19 @@ function handleRecolorSpectraBasedOnDistinctValue(draft, action) {
|
|
|
342
346
|
}
|
|
343
347
|
else {
|
|
344
348
|
//reset spectra colors
|
|
345
|
-
const
|
|
349
|
+
const usedColors = { '1d': [], '2d': [] };
|
|
346
350
|
for (const spectrum of spectra) {
|
|
347
351
|
if (isSpectrum1D(spectrum)) {
|
|
348
|
-
spectrum.display.color = get1DColor(spectrum,
|
|
352
|
+
spectrum.display.color = get1DColor(spectrum, {
|
|
353
|
+
usedColors,
|
|
354
|
+
regenerate: true,
|
|
355
|
+
}).color;
|
|
349
356
|
}
|
|
350
357
|
else {
|
|
351
|
-
const { positiveColor, negativeColor } = get2DColor(spectrum,
|
|
358
|
+
const { positiveColor, negativeColor } = get2DColor(spectrum, {
|
|
359
|
+
usedColors,
|
|
360
|
+
regenerate: true,
|
|
361
|
+
});
|
|
352
362
|
spectrum.display.positiveColor = positiveColor;
|
|
353
363
|
spectrum.display.negativeColor = negativeColor;
|
|
354
364
|
}
|
|
@@ -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;
|