nmrium 0.20.2 → 0.21.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/EventsTrackers/KeysListenerTracker.js +98 -81
- package/lib/component/NMRium.d.ts +7 -2
- package/lib/component/NMRium.js +9 -9
- package/lib/component/header/Header.js +10 -3
- package/lib/component/hooks/useCheckExperimentalFeature.js +2 -1
- package/lib/component/hooks/useCheckToolsVisibility.d.ts +1 -0
- package/lib/component/hooks/useCheckToolsVisibility.js +6 -0
- package/lib/component/hooks/useToolsFunctions.js +2 -1
- package/lib/component/loader/DropZone.js +87 -87
- package/lib/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib/component/modal/setting/GeneralSettings.js +1 -5
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib/component/panels/IntegralsPanel/IntegralsPreferences.js +4 -17
- package/lib/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib/component/panels/PeaksPanel/PeaksPreferences.js +5 -14
- package/lib/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib/component/panels/RangesPanel/RangesPreferences.js +5 -18
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +5 -18
- package/lib/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib/component/panels/databasePanel/DatabasePreferences.js +4 -17
- package/lib/component/reducer/actions/ToolsActions.js +12 -29
- package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +1 -0
- package/lib/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib/component/reducer/preferencesReducer.d.ts +2 -0
- package/lib/component/reducer/preferencesReducer.js +76 -36
- package/lib/component/toolbar/FunctionToolBar.js +7 -10
- package/lib/component/toolbar/ToolTypes.js +3 -3
- package/lib/component/workspaces/Workspace.d.ts +6 -0
- package/lib/component/workspaces/Workspace.js +1 -0
- package/lib/component/workspaces/basic.d.ts +2 -0
- package/lib/component/workspaces/basic.js +45 -0
- package/lib/component/workspaces/exercise1D.d.ts +2 -0
- package/lib/component/workspaces/exercise1D.js +45 -0
- package/lib/component/workspaces/index.d.ts +6 -0
- package/lib/component/workspaces/index.js +4 -0
- package/lib/component/workspaces/process1D.d.ts +2 -0
- package/lib/component/workspaces/process1D.js +43 -0
- package/lib/data/migration/MigrationManager.js +3 -0
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +98 -81
- package/lib-cjs/component/NMRium.js +10 -10
- package/lib-cjs/component/header/Header.js +10 -3
- package/lib-cjs/component/hooks/useCheckExperimentalFeature.js +5 -1
- package/lib-cjs/component/hooks/useCheckToolsVisibility.js +13 -0
- package/lib-cjs/component/hooks/useToolsFunctions.js +2 -1
- package/lib-cjs/component/loader/DropZone.js +87 -87
- package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +4 -2
- package/lib-cjs/component/modal/setting/DisplayTabContent.js +1 -1
- package/lib-cjs/component/modal/setting/GeneralSettings.js +1 -5
- package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +0 -3
- package/lib-cjs/component/panels/IntegralsPanel/IntegralsPreferences.js +3 -16
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanel.js +1 -1
- package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +0 -3
- package/lib-cjs/component/panels/PeaksPanel/PeaksPreferences.js +4 -13
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +0 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPreferences.js +4 -17
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +13 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +0 -3
- package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +4 -17
- package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +0 -3
- package/lib-cjs/component/panels/databasePanel/DatabasePreferences.js +3 -16
- package/lib-cjs/component/reducer/actions/ToolsActions.js +12 -29
- package/lib-cjs/component/reducer/helper/ZoomHistoryManager.js +2 -1
- package/lib-cjs/component/reducer/preferencesReducer.js +75 -35
- package/lib-cjs/component/toolbar/FunctionToolBar.js +7 -10
- package/lib-cjs/component/toolbar/ToolTypes.js +3 -3
- package/lib-cjs/component/workspaces/Workspace.js +2 -0
- package/lib-cjs/component/workspaces/basic.js +48 -0
- package/lib-cjs/component/workspaces/exercise1D.js +48 -0
- package/lib-cjs/component/workspaces/index.js +6 -0
- package/lib-cjs/component/workspaces/process1D.js +46 -0
- package/lib-cjs/data/migration/MigrationManager.js +3 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +1 -1
- package/lib/component/nmriumMode/basic.d.ts +0 -38
- package/lib/component/nmriumMode/basic.js +0 -37
- package/lib/component/nmriumMode/exercise1D.d.ts +0 -38
- package/lib/component/nmriumMode/exercise1D.js +0 -37
- package/lib/component/nmriumMode/process1D.d.ts +0 -38
- package/lib/component/nmriumMode/process1D.js +0 -37
- package/lib-cjs/component/nmriumMode/basic.js +0 -39
- package/lib-cjs/component/nmriumMode/exercise1D.js +0 -39
- package/lib-cjs/component/nmriumMode/process1D.js +0 -39
|
@@ -8,7 +8,6 @@ import Tab from '../../elements/Tab/Tab';
|
|
|
8
8
|
import Tabs, { PositionsEnum } from '../../elements/Tab/Tabs';
|
|
9
9
|
import FormikForm from '../../elements/formik/FormikForm';
|
|
10
10
|
import { SET_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
11
|
-
import { useStateWithLocalStorage } from '../../utility/LocalStorage';
|
|
12
11
|
import ControllersTabContent from './ControllersTabContent';
|
|
13
12
|
import DisplayTabContent from './DisplayTabContent';
|
|
14
13
|
import FormattingTabContent from './FormattingTabContent';
|
|
@@ -142,17 +141,14 @@ const styles = css `
|
|
|
142
141
|
function GeneralSettings({ onClose, onSave }) {
|
|
143
142
|
const [activeTab, setActiveTab] = useState('controllers');
|
|
144
143
|
const preferences = usePreferences();
|
|
145
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
146
144
|
const refForm = useRef();
|
|
147
145
|
const handleSave = useCallback(() => {
|
|
148
146
|
refForm.current.submitForm();
|
|
149
147
|
}, []);
|
|
150
148
|
const submitHandler = useCallback((values) => {
|
|
151
|
-
const { dispatch, basePreferences, ...resValues } = values;
|
|
152
|
-
setSettingsData(resValues);
|
|
153
149
|
preferences.dispatch({ type: SET_PREFERENCES, payload: values });
|
|
154
150
|
onSave?.();
|
|
155
|
-
}, [onSave, preferences
|
|
151
|
+
}, [onSave, preferences]);
|
|
156
152
|
const tabChangeHandler = useCallback((tab) => {
|
|
157
153
|
setActiveTab(tab.tabid);
|
|
158
154
|
}, []);
|
|
@@ -63,9 +63,6 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, preferences,
|
|
|
63
63
|
}, [changeIntegralSumHandler, currentSum, integrals?.options, modal]);
|
|
64
64
|
const settingsPanelHandler = useCallback(() => {
|
|
65
65
|
setFlipStatus(!isFlipped);
|
|
66
|
-
if (!isFlipped) {
|
|
67
|
-
settingRef.current.cancelSetting();
|
|
68
|
-
}
|
|
69
66
|
}, [isFlipped]);
|
|
70
67
|
const saveSettingHandler = useCallback(() => {
|
|
71
68
|
settingRef.current.saveSetting();
|
|
@@ -9,7 +9,7 @@ import FormikNumberInput from '../../elements/formik/FormikNumberInput';
|
|
|
9
9
|
import { useAlert } from '../../elements/popup/Alert';
|
|
10
10
|
import useNucleus from '../../hooks/useNucleus';
|
|
11
11
|
import { SET_PANELS_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
12
|
-
import {
|
|
12
|
+
import { getValue as getValueByKeyPath } from '../../utility/LocalStorage';
|
|
13
13
|
import { integralDefaultValues } from '../extra/preferences/defaultValues';
|
|
14
14
|
const styles = {
|
|
15
15
|
container: {
|
|
@@ -61,7 +61,6 @@ const formatFields = [
|
|
|
61
61
|
];
|
|
62
62
|
function IntegralsPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
63
63
|
const alert = useAlert();
|
|
64
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
65
64
|
const formRef = useRef();
|
|
66
65
|
const updateValues = useCallback(() => {
|
|
67
66
|
if (nucleus) {
|
|
@@ -78,31 +77,19 @@ function IntegralsPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
78
77
|
useEffect(() => {
|
|
79
78
|
updateValues();
|
|
80
79
|
}, [updateValues]);
|
|
81
|
-
const
|
|
82
|
-
setSettingsData(values, 'formatting.panels.integrals');
|
|
83
|
-
};
|
|
84
|
-
const saveHandler = useCallback((values, showMessage = false) => {
|
|
80
|
+
const saveHandler = useCallback((values) => {
|
|
85
81
|
preferences.dispatch({
|
|
86
82
|
type: SET_PANELS_PREFERENCES,
|
|
87
83
|
payload: { key: 'integrals', value: values },
|
|
88
84
|
});
|
|
89
|
-
|
|
90
|
-
alert.success('Integrals preferences saved successfully');
|
|
91
|
-
}
|
|
85
|
+
alert.success('Integrals preferences saved successfully');
|
|
92
86
|
}, [alert, preferences]);
|
|
93
87
|
useImperativeHandle(innerRef, () => ({
|
|
94
88
|
saveSetting: () => {
|
|
95
89
|
formRef.current.submitForm();
|
|
96
90
|
},
|
|
97
|
-
cancelSetting: () => {
|
|
98
|
-
updateValues();
|
|
99
|
-
},
|
|
100
91
|
}));
|
|
101
|
-
|
|
102
|
-
saveHandler(values, true);
|
|
103
|
-
saveToLocalStorgate(values);
|
|
104
|
-
};
|
|
105
|
-
return (_jsx("div", { style: styles.container, children: _jsxs(FormikForm, { onSubmit: handleSubmit, ref: formRef, children: [_jsxs("div", { style: styles.groupContainer, children: [_jsx("p", { style: styles.header, children: "General" }, void 0), _jsx(FormikColorInput, { name: "color" }, void 0), _jsx(FormikNumberInput, { name: "strokeWidth", label: "stroke width :", style: {
|
|
92
|
+
return (_jsx("div", { style: styles.container, children: _jsxs(FormikForm, { onSubmit: saveHandler, ref: formRef, children: [_jsxs("div", { style: styles.groupContainer, children: [_jsx("p", { style: styles.header, children: "General" }, void 0), _jsx(FormikColorInput, { name: "color" }, void 0), _jsx(FormikNumberInput, { name: "strokeWidth", label: "stroke width :", style: {
|
|
106
93
|
label: { fontSize: '11px', fontWeight: 'bold', color: '#232323' },
|
|
107
94
|
input: {
|
|
108
95
|
width: '60%',
|
|
@@ -91,7 +91,7 @@ function MoleculePanelInner({ zones, ranges, molecules: moleculesProp, activeTab
|
|
|
91
91
|
currentDiaIDsToHighlight.length > 0
|
|
92
92
|
? currentDiaIDsToHighlight
|
|
93
93
|
: assignedDiaIDsMerged, setHoverAtom: handleOnAtomHover }, void 0));
|
|
94
|
-
} }, void 0) }, void 0)] }, mol.key)))) : (_jsx("div", {
|
|
94
|
+
} }, void 0) }, void 0)] }, mol.key)))) : (_jsx("div", { css: styles.slider, style: { height: '100%' }, onClick: () => openMoleculeEditorHandler(), children: _jsx("span", { children: "Click to draw molecule" }, void 0) }, void 0)) }, void 0) }, void 0)] }, void 0));
|
|
95
95
|
}
|
|
96
96
|
const MemoizedMoleculePanel = memo(MoleculePanelInner);
|
|
97
97
|
const emptyData = { ranges: {}, zones: {} };
|
|
@@ -32,9 +32,6 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, preferences, }) {
|
|
|
32
32
|
}, [modal, yesHandler]);
|
|
33
33
|
const settingsPanelHandler = useCallback(() => {
|
|
34
34
|
setFlipStatus(!isFlipped);
|
|
35
|
-
if (!isFlipped) {
|
|
36
|
-
settingRef.current.cancelSetting();
|
|
37
|
-
}
|
|
38
35
|
}, [isFlipped]);
|
|
39
36
|
const saveSettingHandler = useCallback(() => {
|
|
40
37
|
settingRef.current.saveSetting();
|
|
@@ -7,7 +7,7 @@ import FormikForm from '../../elements/formik/FormikForm';
|
|
|
7
7
|
import { useAlert } from '../../elements/popup/Alert';
|
|
8
8
|
import useNucleus from '../../hooks/useNucleus';
|
|
9
9
|
import { SET_PANELS_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
10
|
-
import {
|
|
10
|
+
import { getValue as getValueByKeyPath } from '../../utility/LocalStorage';
|
|
11
11
|
import { peaksDefaultValues } from '../extra/preferences/defaultValues';
|
|
12
12
|
const styles = {
|
|
13
13
|
container: {
|
|
@@ -83,7 +83,6 @@ const formatFields = [
|
|
|
83
83
|
];
|
|
84
84
|
function PeaksPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
85
85
|
const alert = useAlert();
|
|
86
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
87
86
|
const formRef = useRef(null);
|
|
88
87
|
const updateValues = useCallback(() => {
|
|
89
88
|
if (nucleus) {
|
|
@@ -98,27 +97,19 @@ function PeaksPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
98
97
|
useEffect(() => {
|
|
99
98
|
updateValues();
|
|
100
99
|
}, [updateValues]);
|
|
101
|
-
const saveHandler = useCallback((values
|
|
100
|
+
const saveHandler = useCallback((values) => {
|
|
102
101
|
preferences.dispatch({
|
|
103
102
|
type: SET_PANELS_PREFERENCES,
|
|
104
103
|
payload: { key: 'peaks', value: values },
|
|
105
104
|
});
|
|
106
|
-
|
|
107
|
-
alert.success('Peaks preferences saved successfully');
|
|
105
|
+
alert.success('Peaks preferences saved successfully');
|
|
108
106
|
}, [alert, preferences]);
|
|
109
107
|
useImperativeHandle(innerRef, () => ({
|
|
110
108
|
saveSetting: () => {
|
|
111
109
|
formRef.current.submitForm();
|
|
112
110
|
},
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
}), [updateValues]);
|
|
117
|
-
const handleSubmit = useCallback((values) => {
|
|
118
|
-
saveHandler(values, true);
|
|
119
|
-
setSettingsData(values, 'formatting.panels.peaks');
|
|
120
|
-
}, [saveHandler, setSettingsData]);
|
|
121
|
-
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: handleSubmit, ref: formRef, children: nucleus?.map((nucleusLabel) => (_jsxs("div", { style: styles.groupContainer, children: [_jsx(IsotopesViewer, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => (_jsx(FormikColumnFormatField, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}`, hideFormat: field.formatController === 'deltaPPMFormat' }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
111
|
+
}), []);
|
|
112
|
+
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: saveHandler, ref: formRef, children: nucleus?.map((nucleusLabel) => (_jsxs("div", { style: styles.groupContainer, children: [_jsx(IsotopesViewer, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => (_jsx(FormikColumnFormatField, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}`, hideFormat: field.formatController === 'deltaPPMFormat' }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
122
113
|
}
|
|
123
114
|
const MemoizedPeaksPreferences = memo(PeaksPreferencesInner);
|
|
124
115
|
// TODO: remove this hacky use of ref.
|
|
@@ -100,9 +100,6 @@ function RangesTablePanelInner({ ranges, data, info, xDomain, preferences, activ
|
|
|
100
100
|
}, [isFilterActive]);
|
|
101
101
|
const settingsPanelHandler = useCallback(() => {
|
|
102
102
|
setFlipStatus(!isFlipped);
|
|
103
|
-
if (!isFlipped) {
|
|
104
|
-
settingRef.current.cancelSetting();
|
|
105
|
-
}
|
|
106
103
|
}, [isFlipped]);
|
|
107
104
|
const saveSettingHandler = useCallback(() => {
|
|
108
105
|
settingRef.current.saveSetting();
|
|
@@ -9,7 +9,7 @@ import FormikInput from '../../elements/formik/FormikInput';
|
|
|
9
9
|
import { useAlert } from '../../elements/popup/Alert';
|
|
10
10
|
import useNucleus from '../../hooks/useNucleus';
|
|
11
11
|
import { SET_PANELS_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
12
|
-
import {
|
|
12
|
+
import { getValue as getValueByKeyPath } from '../../utility/LocalStorage';
|
|
13
13
|
import { getRangeDefaultValues } from '../extra/preferences/defaultValues';
|
|
14
14
|
const styles = {
|
|
15
15
|
container: {
|
|
@@ -71,7 +71,6 @@ const formatFields = [
|
|
|
71
71
|
];
|
|
72
72
|
function RangesPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
73
73
|
const alert = useAlert();
|
|
74
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
75
74
|
const formRef = useRef();
|
|
76
75
|
const updateValues = useCallback(() => {
|
|
77
76
|
if (nucleus) {
|
|
@@ -86,31 +85,19 @@ function RangesPreferencesInner({ nucleus, preferences, innerRef, }) {
|
|
|
86
85
|
useEffect(() => {
|
|
87
86
|
updateValues();
|
|
88
87
|
}, [updateValues]);
|
|
89
|
-
const
|
|
90
|
-
setSettingsData(values, 'formatting.panels.ranges');
|
|
91
|
-
};
|
|
92
|
-
const saveHandler = useCallback((values, showMessage = false) => {
|
|
88
|
+
const saveHandler = useCallback((values) => {
|
|
93
89
|
preferences.dispatch({
|
|
94
90
|
type: SET_PANELS_PREFERENCES,
|
|
95
91
|
payload: { key: 'ranges', value: values },
|
|
96
92
|
});
|
|
97
|
-
|
|
98
|
-
alert.success('ranges preferences saved successfully');
|
|
99
|
-
}
|
|
93
|
+
alert.success('ranges preferences saved successfully');
|
|
100
94
|
}, [alert, preferences]);
|
|
101
95
|
useImperativeHandle(innerRef, () => ({
|
|
102
96
|
saveSetting: () => {
|
|
103
97
|
formRef.current.submitForm();
|
|
104
98
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
},
|
|
108
|
-
}), [updateValues]);
|
|
109
|
-
const handleSubmit = (values) => {
|
|
110
|
-
saveHandler(values, true);
|
|
111
|
-
saveToLocalStorgate(values);
|
|
112
|
-
};
|
|
113
|
-
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: handleSubmit, ref: formRef, children: nucleus?.map((nucleusLabel) => (_jsxs("div", { style: styles.groupContainer, children: [_jsx(IsotopesViewer, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => (_jsx(FormikColumnFormatField, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id))), _jsx(Label, { title: "J Graph tolerance (Hz) :", style: { label: styles.inputLabel, wrapper: styles.inputWrapper }, children: _jsx(FormikInput, { name: `${nucleusLabel}.jGraphTolerance`, type: "number" }, void 0) }, void 0)] }, nucleusLabel))) }, void 0) }, void 0));
|
|
99
|
+
}), []);
|
|
100
|
+
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: saveHandler, ref: formRef, children: nucleus?.map((nucleusLabel) => (_jsxs("div", { style: styles.groupContainer, children: [_jsx(IsotopesViewer, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => (_jsx(FormikColumnFormatField, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id))), _jsx(Label, { title: "J Graph tolerance (Hz) :", style: { label: styles.inputLabel, wrapper: styles.inputWrapper }, children: _jsx(FormikInput, { name: `${nucleusLabel}.jGraphTolerance`, type: "number" }, void 0) }, void 0)] }, nucleusLabel))) }, void 0) }, void 0));
|
|
114
101
|
}
|
|
115
102
|
const MemoizedRangesPreferences = memo(RangesPreferencesInner);
|
|
116
103
|
// TODO: remove this hacky use of ref.
|
|
@@ -7,10 +7,11 @@ import { useDispatch } from '../../context/DispatchContext';
|
|
|
7
7
|
import Button from '../../elements/ButtonToolTip';
|
|
8
8
|
import { useAlert } from '../../elements/popup/Alert';
|
|
9
9
|
import { useModal } from '../../elements/popup/Modal';
|
|
10
|
+
import { useCheckToolsVisibility } from '../../hooks/useCheckToolsVisibility';
|
|
10
11
|
import { DISPLAYER_MODE } from '../../reducer/core/Constants';
|
|
11
12
|
import { ADD_MISSING_PROJECTION, CHANGE_VISIBILITY, DELETE_SPECTRA, RESET_SPECTRA_SCALE, SET_SPECTRA_SAME_TOP, AUTO_RANGES_SPECTRA_PICKING, AUTO_ZONES_SPECTRA_PICKING, } from '../../reducer/types/Types';
|
|
12
13
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
13
|
-
function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMode, spectrums, }) {
|
|
14
|
+
function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMode, spectrums, isAutomaticPickingVisible, }) {
|
|
14
15
|
const modal = useModal();
|
|
15
16
|
const alert = useAlert();
|
|
16
17
|
const dispatch = useDispatch();
|
|
@@ -72,10 +73,19 @@ function SpectraPanelHeaderInner({ data, activeSpectrum, activeTab, displayerMod
|
|
|
72
73
|
hideLoading();
|
|
73
74
|
}, 0);
|
|
74
75
|
}, [dispatch, alert]);
|
|
75
|
-
return (_jsxs(DefaultPanelHeader, { onDelete: handleDelete, counter: spectrums?.length, deleteToolTip: "Delete all spectra", children: [_jsx(Button, { popupTitle: "Hide all spectra", onClick: hideAllSpectrumsHandler, children: _jsx(FaEyeSlash, {}, void 0) }, void 0), _jsx(Button, { popupTitle: "Show all spectra", onClick: showAllSpectrumsHandler, children: _jsx(FaEye, {}, void 0) }, void 0), activeSpectrum && activeTab && activeTab.split(',').length > 1 && (_jsx(Button, { popupTitle: "Add missing projection", onClick: addMissingProjectionHandler, children: _jsx(FaCreativeCommonsSamplingPlus, {}, void 0) }, void 0)), displayerMode === DISPLAYER_MODE.DM_1D && spectrums.length > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { popupTitle: "Reset Scale", onClick: resetScaleHandler, children: _jsx(SvgNmrResetScale, {}, void 0) }, void 0), _jsx(Button, { popupTitle: "Same Top", onClick: setSameTopHandler, children: _jsx(SvgNmrSameTop, {}, void 0) }, void 0)] }, void 0)), data && data.length > 0 && (_jsx(Button, { popupTitle: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: _jsx(SvgNmrRangePicking, {}, void 0) }, void 0))] }, void 0));
|
|
76
|
+
return (_jsxs(DefaultPanelHeader, { onDelete: handleDelete, counter: spectrums?.length, deleteToolTip: "Delete all spectra", children: [_jsx(Button, { popupTitle: "Hide all spectra", onClick: hideAllSpectrumsHandler, children: _jsx(FaEyeSlash, {}, void 0) }, void 0), _jsx(Button, { popupTitle: "Show all spectra", onClick: showAllSpectrumsHandler, children: _jsx(FaEye, {}, void 0) }, void 0), activeSpectrum && activeTab && activeTab.split(',').length > 1 && (_jsx(Button, { popupTitle: "Add missing projection", onClick: addMissingProjectionHandler, children: _jsx(FaCreativeCommonsSamplingPlus, {}, void 0) }, void 0)), displayerMode === DISPLAYER_MODE.DM_1D && spectrums.length > 1 && (_jsxs(_Fragment, { children: [_jsx(Button, { popupTitle: "Reset Scale", onClick: resetScaleHandler, children: _jsx(SvgNmrResetScale, {}, void 0) }, void 0), _jsx(Button, { popupTitle: "Same Top", onClick: setSameTopHandler, children: _jsx(SvgNmrSameTop, {}, void 0) }, void 0)] }, void 0)), data && data.length > 0 && isAutomaticPickingVisible && (_jsx(Button, { popupTitle: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: _jsx(SvgNmrRangePicking, {}, void 0) }, void 0))] }, void 0));
|
|
76
77
|
}
|
|
77
78
|
const MemoizedSpectraPanelHeader = memo(SpectraPanelHeaderInner);
|
|
78
79
|
export default function SpectrumsTabs({ spectrums }) {
|
|
79
80
|
const { data, activeSpectrum, activeTab, displayerMode } = useChartData();
|
|
80
|
-
|
|
81
|
+
const isToolVisible = useCheckToolsVisibility();
|
|
82
|
+
const isAutomaticPickingVisible = isToolVisible('hideAutoRangesTool');
|
|
83
|
+
return (_jsx(MemoizedSpectraPanelHeader, { ...{
|
|
84
|
+
data,
|
|
85
|
+
activeSpectrum,
|
|
86
|
+
activeTab,
|
|
87
|
+
displayerMode,
|
|
88
|
+
spectrums,
|
|
89
|
+
isAutomaticPickingVisible,
|
|
90
|
+
} }, void 0));
|
|
81
91
|
}
|
|
@@ -118,9 +118,6 @@ function ZonesPanelInner({ zones, activeTab, xDomain, yDomain }) {
|
|
|
118
118
|
}, [assignmentData, dispatch, modal]);
|
|
119
119
|
const settingsPanelHandler = useCallback(() => {
|
|
120
120
|
setFlipStatus(!isFlipped);
|
|
121
|
-
if (!isFlipped) {
|
|
122
|
-
settingRef.current.cancelSetting();
|
|
123
|
-
}
|
|
124
121
|
}, [isFlipped]);
|
|
125
122
|
const saveSettingHandler = useCallback(() => {
|
|
126
123
|
settingRef.current.saveSetting();
|
|
@@ -7,7 +7,7 @@ import FormikForm from '../../elements/formik/FormikForm';
|
|
|
7
7
|
import { useAlert } from '../../elements/popup/Alert';
|
|
8
8
|
import useNucleus from '../../hooks/useNucleus';
|
|
9
9
|
import { SET_PANELS_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
10
|
-
import {
|
|
10
|
+
import { getValue as getValueByKeyPath } from '../../utility/LocalStorage';
|
|
11
11
|
import { zoneDefaultValues } from '../extra/preferences/defaultValues';
|
|
12
12
|
const styles = {
|
|
13
13
|
container: {
|
|
@@ -71,7 +71,6 @@ const formatFields = [
|
|
|
71
71
|
];
|
|
72
72
|
function ZonesPreferencesInner({ nucleus, innerRef, }) {
|
|
73
73
|
const alert = useAlert();
|
|
74
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
75
74
|
const preferences = usePreferences();
|
|
76
75
|
const formRef = useRef();
|
|
77
76
|
const updateValues = useCallback(() => {
|
|
@@ -87,31 +86,19 @@ function ZonesPreferencesInner({ nucleus, innerRef, }) {
|
|
|
87
86
|
useEffect(() => {
|
|
88
87
|
updateValues();
|
|
89
88
|
}, [updateValues]);
|
|
90
|
-
const
|
|
91
|
-
setSettingsData(values, 'formatting.panels.ranges');
|
|
92
|
-
};
|
|
93
|
-
const saveHandler = useCallback((values, showMessage = false) => {
|
|
89
|
+
const saveHandler = useCallback((values) => {
|
|
94
90
|
preferences.dispatch({
|
|
95
91
|
type: SET_PANELS_PREFERENCES,
|
|
96
92
|
payload: { key: 'zones', value: values },
|
|
97
93
|
});
|
|
98
|
-
|
|
99
|
-
alert.success('zones preferences saved successfully');
|
|
100
|
-
}
|
|
94
|
+
alert.success('zones preferences saved successfully');
|
|
101
95
|
}, [alert, preferences]);
|
|
102
96
|
useImperativeHandle(innerRef, () => ({
|
|
103
97
|
saveSetting: () => {
|
|
104
98
|
formRef.current.submitForm();
|
|
105
99
|
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
}), [updateValues]);
|
|
110
|
-
const handleSubmit = (values) => {
|
|
111
|
-
saveHandler(values, true);
|
|
112
|
-
saveToLocalStorgate(values);
|
|
113
|
-
};
|
|
114
|
-
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: handleSubmit, ref: formRef, children: nucleus?.map((nucleusLabel) => (_jsxs("div", { style: styles.groupContainer, children: [_jsx(IsotopesViewer, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => (_jsx(FormikColumnFormatField, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
100
|
+
}), []);
|
|
101
|
+
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: saveHandler, ref: formRef, children: nucleus?.map((nucleusLabel) => (_jsxs("div", { style: styles.groupContainer, children: [_jsx(IsotopesViewer, { style: styles.header, value: nucleusLabel }, void 0), formatFields.map((field) => (_jsx(FormikColumnFormatField, { label: field.label, checkControllerName: `${nucleusLabel}.${field.checkController}`, formatControllerName: `${nucleusLabel}.${field.formatController}` }, field.id)))] }, nucleusLabel))) }, void 0) }, void 0));
|
|
115
102
|
}
|
|
116
103
|
const MemoizedZonesPreferences = memo(ZonesPreferencesInner);
|
|
117
104
|
// TODO: remove this hacky use of ref.
|
|
@@ -61,9 +61,6 @@ function DatabasePanelInner({ nucleus, selectedTool }) {
|
|
|
61
61
|
const { item } = useAccordionContext('Database');
|
|
62
62
|
const settingsPanelHandler = useCallback(() => {
|
|
63
63
|
setFlipStatus(!isFlipped);
|
|
64
|
-
if (!isFlipped) {
|
|
65
|
-
settingRef.current.cancelSetting();
|
|
66
|
-
}
|
|
67
64
|
}, [isFlipped]);
|
|
68
65
|
const saveSettingHandler = useCallback(() => {
|
|
69
66
|
settingRef.current.saveSetting();
|
|
@@ -5,7 +5,7 @@ import FormikColumnFormatField from '../../elements/formik/FormikColumnFormatFie
|
|
|
5
5
|
import FormikForm from '../../elements/formik/FormikForm';
|
|
6
6
|
import { useAlert } from '../../elements/popup/Alert';
|
|
7
7
|
import { SET_PANELS_PREFERENCES } from '../../reducer/preferencesReducer';
|
|
8
|
-
import {
|
|
8
|
+
import { getValue as getValueByKeyPath } from '../../utility/LocalStorage';
|
|
9
9
|
import { databaseDefaultValues } from '../extra/preferences/defaultValues';
|
|
10
10
|
const styles = {
|
|
11
11
|
container: {
|
|
@@ -43,7 +43,6 @@ const styles = {
|
|
|
43
43
|
function DatabasePreferences(props, ref) {
|
|
44
44
|
const preferences = usePreferences();
|
|
45
45
|
const alert = useAlert();
|
|
46
|
-
const [, setSettingsData] = useStateWithLocalStorage('nmr-general-settings');
|
|
47
46
|
const formRef = useRef();
|
|
48
47
|
const updateValues = useCallback(() => {
|
|
49
48
|
const databasePreferences = getValueByKeyPath(preferences, `formatting.panels.database`);
|
|
@@ -52,30 +51,18 @@ function DatabasePreferences(props, ref) {
|
|
|
52
51
|
useEffect(() => {
|
|
53
52
|
updateValues();
|
|
54
53
|
}, [updateValues]);
|
|
55
|
-
const
|
|
56
|
-
setSettingsData(values, 'formatting.panels.database');
|
|
57
|
-
};
|
|
58
|
-
const saveHandler = useCallback((values, showMessage = false) => {
|
|
54
|
+
const saveHandler = useCallback((values) => {
|
|
59
55
|
preferences.dispatch({
|
|
60
56
|
type: SET_PANELS_PREFERENCES,
|
|
61
57
|
payload: { key: 'database', value: values },
|
|
62
58
|
});
|
|
63
|
-
|
|
64
|
-
alert.success('database preferences saved successfully');
|
|
65
|
-
}
|
|
59
|
+
alert.success('database preferences saved successfully');
|
|
66
60
|
}, [alert, preferences]);
|
|
67
61
|
useImperativeHandle(ref, () => ({
|
|
68
62
|
saveSetting: () => {
|
|
69
63
|
formRef.current.submitForm();
|
|
70
64
|
},
|
|
71
|
-
cancelSetting: () => {
|
|
72
|
-
updateValues();
|
|
73
|
-
},
|
|
74
65
|
}));
|
|
75
|
-
|
|
76
|
-
saveHandler(values, true);
|
|
77
|
-
saveToLocalStorage(values);
|
|
78
|
-
};
|
|
79
|
-
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: handleSubmit, ref: formRef, children: _jsxs("div", { style: styles.groupContainer, children: [_jsx(FormikColumnFormatField, { label: "Smiles", checkControllerName: "showSmiles", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Solvent", checkControllerName: "showSolvent", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Names", checkControllerName: "showNames", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Range", checkControllerName: "showRange", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "\u03B4 (ppm)", checkControllerName: "showDelta", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Assignment", checkControllerName: "showAssignment", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "J (Hz)", checkControllerName: "showCoupling", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Multiplicity", checkControllerName: "showMultiplicity", hideFormat: true }, void 0)] }, void 0) }, void 0) }, void 0));
|
|
66
|
+
return (_jsx("div", { style: styles.container, children: _jsx(FormikForm, { onSubmit: saveHandler, ref: formRef, children: _jsxs("div", { style: styles.groupContainer, children: [_jsx(FormikColumnFormatField, { label: "Smiles", checkControllerName: "showSmiles", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Solvent", checkControllerName: "showSolvent", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Names", checkControllerName: "showNames", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Range", checkControllerName: "showRange", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "\u03B4 (ppm)", checkControllerName: "showDelta", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Assignment", checkControllerName: "showAssignment", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "J (Hz)", checkControllerName: "showCoupling", hideFormat: true }, void 0), _jsx(FormikColumnFormatField, { label: "Multiplicity", checkControllerName: "showMultiplicity", hideFormat: true }, void 0)] }, void 0) }, void 0) }, void 0));
|
|
80
67
|
}
|
|
81
68
|
export default forwardRef(DatabasePreferences);
|
|
@@ -180,7 +180,7 @@ function handleBrushEnd(draft, action) {
|
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
if (brushHistory) {
|
|
183
|
-
brushHistory.push({ xDomain:
|
|
183
|
+
brushHistory.push({ xDomain: draft.xDomain, yDomain: draft.yDomain });
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
else {
|
|
@@ -242,6 +242,7 @@ function zoomOut(draft, action) {
|
|
|
242
242
|
switch (zoomType) {
|
|
243
243
|
case ZoomType.HORIZONTAL: {
|
|
244
244
|
draft.xDomain = draft.originDomain.xDomain;
|
|
245
|
+
zoomHistory.clear();
|
|
245
246
|
break;
|
|
246
247
|
}
|
|
247
248
|
case ZoomType.VERTICAL:
|
|
@@ -264,34 +265,16 @@ function zoomOut(draft, action) {
|
|
|
264
265
|
}
|
|
265
266
|
else {
|
|
266
267
|
const { xDomain, yDomain, yDomains } = draft.originDomain;
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
const activeSpectrum = draft.tabActiveSpectrum[draft.activeTab.split(',')[1]];
|
|
278
|
-
draft.yDomain = yDomain;
|
|
279
|
-
if (activeSpectrum?.id) {
|
|
280
|
-
draft.yDomains[activeSpectrum.id] = yDomains[activeSpectrum.id];
|
|
281
|
-
}
|
|
282
|
-
break;
|
|
283
|
-
}
|
|
284
|
-
case LAYOUT.CENTER_2D: {
|
|
285
|
-
const zoomValue = zoomHistory.pop();
|
|
286
|
-
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
287
|
-
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
default:
|
|
291
|
-
draft.xDomain = xDomain;
|
|
292
|
-
draft.yDomain = yDomain;
|
|
293
|
-
draft.yDomains = yDomains;
|
|
294
|
-
break;
|
|
268
|
+
if ([LAYOUT.TOP_1D, LAYOUT.LEFT_1D, LAYOUT.CENTER_2D].includes(trackID)) {
|
|
269
|
+
const zoomValue = zoomHistory.pop();
|
|
270
|
+
draft.xDomain = zoomValue ? zoomValue.xDomain : xDomain;
|
|
271
|
+
draft.yDomain = zoomValue ? zoomValue.yDomain : yDomain;
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
zoomHistory.clear();
|
|
275
|
+
draft.xDomain = xDomain;
|
|
276
|
+
draft.yDomain = yDomain;
|
|
277
|
+
draft.yDomains = yDomains;
|
|
295
278
|
}
|
|
296
279
|
}
|
|
297
280
|
}
|
|
@@ -10,6 +10,7 @@ interface ZoomHistoryManager {
|
|
|
10
10
|
push: (value: HistoryItem) => void;
|
|
11
11
|
pop: () => HistoryItem;
|
|
12
12
|
getLast: () => HistoryItem;
|
|
13
|
+
clear: () => void;
|
|
13
14
|
}
|
|
14
15
|
export default function zoomHistoryManager(zoomHistory: ZoomHistory, nucleus: string): ZoomHistoryManager;
|
|
15
16
|
export {};
|
|
@@ -5,7 +5,8 @@ export default function zoomHistoryManager(zoomHistory, nucleus) {
|
|
|
5
5
|
const push = preparePush(zoomHistory[nucleus]);
|
|
6
6
|
const pop = preparePop(zoomHistory[nucleus]);
|
|
7
7
|
const getLast = prepareGetLast(zoomHistory[nucleus]);
|
|
8
|
-
|
|
8
|
+
const clear = () => (zoomHistory[nucleus] = []);
|
|
9
|
+
return { historyStack: zoomHistory[nucleus], push, pop, getLast, clear };
|
|
9
10
|
}
|
|
10
11
|
function preparePush(historyStack) {
|
|
11
12
|
return (val) => {
|
|
@@ -22,6 +22,7 @@ export interface PreferencesState {
|
|
|
22
22
|
panels: any;
|
|
23
23
|
};
|
|
24
24
|
dispatch: any;
|
|
25
|
+
workspace: string;
|
|
25
26
|
}
|
|
26
27
|
export declare const preferencesInitialState: PreferencesState;
|
|
27
28
|
declare const preferencesReducer: (base: {
|
|
@@ -45,5 +46,6 @@ declare const preferencesReducer: (base: {
|
|
|
45
46
|
readonly panels: any;
|
|
46
47
|
};
|
|
47
48
|
readonly dispatch: any;
|
|
49
|
+
readonly workspace: string;
|
|
48
50
|
}, action: any) => import("immer/dist/internal").WritableDraft<PreferencesState>;
|
|
49
51
|
export default preferencesReducer;
|