nmrium 0.54.0 → 0.55.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/XAxis.js +1 -1
- package/lib/component/1d/integral/IntegralsSeries.js +2 -2
- package/lib/component/1d/integral/Integration.d.ts +3 -1
- package/lib/component/1d/integral/Integration.js +3 -2
- package/lib/component/1d/peaks/PeakEditionManager.js +5 -3
- package/lib/component/1d/ranges/AssignmentActionsButtons.d.ts +1 -0
- package/lib/component/1d/ranges/AssignmentActionsButtons.js +3 -3
- package/lib/component/1d/ranges/AssignmentLabel.d.ts +1 -1
- package/lib/component/1d/ranges/AssignmentLabel.js +31 -4
- package/lib/component/1d/ranges/Atoms.js +4 -5
- package/lib/component/1d/ranges/Range.js +48 -6
- package/lib/component/1d/ranges/Ranges.js +2 -1
- package/lib/component/1d/ranges/RangesIntegrals.js +11 -4
- package/lib/component/1d-2d/FieldEdition.d.ts +13 -0
- package/lib/component/1d-2d/FieldEdition.js +42 -0
- package/lib/component/2d/Chart2D.js +5 -3
- package/lib/component/2d/zones/Zone.js +18 -2
- package/lib/component/2d/zones/ZonesAssignmentsLabels.d.ts +7 -0
- package/lib/component/2d/zones/ZonesAssignmentsLabels.js +286 -0
- package/lib/component/EventsTrackers/KeysListenerTracker.js +14 -1
- package/lib/component/context/ShareDataContext.d.ts +10 -0
- package/lib/component/context/ShareDataContext.js +22 -0
- package/lib/component/elements/ActionsButtonsPopover.d.ts +10 -0
- package/lib/component/elements/ActionsButtonsPopover.js +22 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +7 -5
- package/lib/component/elements/ReactTable/ReactTable.d.ts +2 -2
- package/lib/component/elements/SVGButton.d.ts +14 -0
- package/lib/component/elements/SVGButton.js +6 -0
- package/lib/component/elements/SVGGroup.js +15 -13
- package/lib/component/elements/SVGText.d.ts +8 -0
- package/lib/component/elements/SVGText.js +24 -0
- package/lib/component/elements/draggable/SVGDraggable.d.ts +2 -2
- package/lib/component/elements/formik/FormikInput.d.ts +2 -1
- package/lib/component/elements/formik/FormikInput.js +4 -3
- package/lib/component/header/Header.js +7 -10
- package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
- package/lib/component/hooks/useCheckPointsNumberInWindowArea.d.ts +1 -1
- package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
- package/lib/component/hooks/useFormatNumberByNucleus.js +8 -7
- package/lib/component/hooks/useIntegralPath.d.ts +2 -0
- package/lib/component/hooks/useIntegralPath.js +3 -1
- package/lib/component/hooks/usePanelPreferences.js +1 -2
- package/lib/component/hooks/useSaveSettings.js +7 -14
- package/lib/component/hooks/useTriggerNewAssignmentLabel.d.ts +4 -0
- package/lib/component/hooks/useTriggerNewAssignmentLabel.js +8 -0
- package/lib/component/hooks/useWorkspaceAction.d.ts +7 -0
- package/lib/component/hooks/useWorkspaceAction.js +89 -0
- package/lib/component/loader/DropZone.js +0 -3
- package/lib/component/main/InnerNMRium.js +3 -1
- package/lib/component/main/InnerNMRiumContents.js +14 -2
- package/lib/component/main/NMRiumStateProvider.js +4 -2
- package/lib/component/modal/editRange/forms/components/DeltaInput.js +3 -3
- package/lib/component/modal/editRange/forms/components/NewSignalTab.js +17 -12
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +30 -13
- package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +26 -16
- package/lib/component/modal/setting/GeneralSettings.js +7 -21
- package/lib/component/modal/setting/WorkspaceItem.js +1 -1
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.d.ts +2 -0
- package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +99 -0
- package/lib/component/modal/setting/settingsValidation.js +36 -40
- package/lib/component/panels/SpectraPanel/SpectraPreferences.js +13 -1
- package/lib/component/panels/SpectraPanel/base/setting/PlotChart.js +1 -1
- package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.d.ts +6 -0
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.js +16 -0
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +18 -2
- package/lib/component/panels/ZonesPanel/ZonesPreferences.js +15 -9
- package/lib/component/panels/ZonesPanel/ZonesTable.js +2 -2
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +3 -2
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +6 -0
- package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
- package/lib/component/reducer/actions/DomainActions.js +29 -1
- package/lib/component/reducer/actions/RangesActions.js +12 -6
- package/lib/component/reducer/actions/ZonesActions.d.ts +15 -2
- package/lib/component/reducer/actions/ZonesActions.js +47 -13
- package/lib/component/reducer/helper/setRangesViewProperty.d.ts +1 -0
- package/lib/component/reducer/helper/setRangesViewProperty.js +11 -11
- package/lib/component/reducer/preferences/actions/addWorkspace.js +4 -23
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js +4 -4
- package/lib/component/reducer/preferences/actions/initPreferences.js +2 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +3 -3
- package/lib/component/reducer/preferences/actions/removeWorkspace.js +0 -5
- package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +0 -4
- package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
- package/lib/component/reducer/preferences/actions/setPreferences.js +2 -16
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +7 -0
- package/lib/component/reducer/preferences/preferencesReducer.js +21 -18
- package/lib/component/toolbar/ToolBar.js +18 -14
- package/lib/component/utility/PreferencesHelper.js +5 -4
- package/lib/component/utility/export.js +4 -0
- package/lib/component/workspaces/assignment.js +0 -1
- package/lib/component/workspaces/basic.js +0 -1
- package/lib/component/workspaces/embedded.js +0 -1
- package/lib/component/workspaces/exercise.js +26 -29
- package/lib/component/workspaces/prediction.js +171 -174
- package/lib/component/workspaces/process1D.js +0 -1
- package/lib/component/workspaces/simulation.js +35 -38
- package/lib/component/workspaces/workspaceDefaultProperties.js +9 -11
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -31
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.d.ts +0 -2
- package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +0 -80
- package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.d.ts +0 -2
- package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.js +0 -10
|
@@ -4,14 +4,15 @@ import { usePreferences } from '../context/PreferencesContext';
|
|
|
4
4
|
import { formatNumber } from '../utility/formatNumber';
|
|
5
5
|
export function useFormatNumberByNucleus(nucleus) {
|
|
6
6
|
const preferences = usePreferences();
|
|
7
|
-
const
|
|
8
|
-
ppm: '0.0',
|
|
9
|
-
hz: '0.0',
|
|
10
|
-
});
|
|
7
|
+
const nucleiPreferences = lodashGet(preferences.current, `nuclei`, []);
|
|
11
8
|
return useMemo(() => {
|
|
12
9
|
function formatFun(n) {
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const preferences = nucleiPreferences?.find(({ nucleus }) => nucleus.toLowerCase() === n.toLowerCase()) || {
|
|
11
|
+
ppmFormat: '0.0',
|
|
12
|
+
hzFormat: '0.0',
|
|
13
|
+
};
|
|
14
|
+
return (value, formatKey = 'ppmFormat', prefix = '', suffix = '') => {
|
|
15
|
+
return formatNumber(value, preferences[formatKey], {
|
|
15
16
|
prefix,
|
|
16
17
|
suffix,
|
|
17
18
|
});
|
|
@@ -29,5 +30,5 @@ export function useFormatNumberByNucleus(nucleus) {
|
|
|
29
30
|
else {
|
|
30
31
|
throw new Error('nuclus must be string or array of string');
|
|
31
32
|
}
|
|
32
|
-
}, [
|
|
33
|
+
}, [nucleiPreferences, nucleus]);
|
|
33
34
|
}
|
|
@@ -13,12 +13,14 @@ function useIntegralYDomain(max, scaleRatio = 1) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
export default function useIntegralPath(options) {
|
|
16
|
-
const { x, y, max, scaleRatio } = options;
|
|
16
|
+
const { x, y, max, scaleRatio, from, to } = options;
|
|
17
17
|
const scaleX = useXScale();
|
|
18
18
|
const scaleY = useIntegralYDomain(max, scaleRatio);
|
|
19
19
|
const xySeries = xyReduce({ x, y }, {
|
|
20
20
|
nbPoints: 200,
|
|
21
21
|
optimize: true,
|
|
22
|
+
from,
|
|
23
|
+
to,
|
|
22
24
|
});
|
|
23
25
|
const pathBuilder = new PathBuilder();
|
|
24
26
|
pathBuilder.moveTo(scaleX(xySeries.x[0]), scaleY(xySeries.y[0]));
|
|
@@ -4,7 +4,6 @@ import { getDefaultPredictionOptions } from '../../data/PredictionManager';
|
|
|
4
4
|
import { usePreferences } from '../context/PreferencesContext';
|
|
5
5
|
import { getIntegralDefaultValues, getPeaksDefaultValues, getZoneDefaultValues, getRangeDefaultValues, databaseDefaultValues, getMultipleSpectraAnalysisDefaultValues, getSpectraDefaultValues, } from '../reducer/preferences/panelsPreferencesDefaultValues';
|
|
6
6
|
import { getValue } from '../utility/LocalStorage';
|
|
7
|
-
const basePath = 'formatting.panels';
|
|
8
7
|
function getDefaultPreferences(panelKey, nucleus) {
|
|
9
8
|
switch (panelKey) {
|
|
10
9
|
case 'spectra':
|
|
@@ -35,7 +34,7 @@ function joinWithNucleusPreferences(data, nucleus, returnOnlyNucleusPreferences
|
|
|
35
34
|
return { ...nuclei[nucleus], ...rest };
|
|
36
35
|
}
|
|
37
36
|
function getPanelPreferences(preferences, panelKey, nucleus, returnOnlyNucleusPreferences = false) {
|
|
38
|
-
const panelPath =
|
|
37
|
+
const panelPath = `panels.${panelKey}`;
|
|
39
38
|
let path = panelPath;
|
|
40
39
|
if (nucleus) {
|
|
41
40
|
switch (panelKey) {
|
|
@@ -8,6 +8,7 @@ import { usePreferences } from '../context/PreferencesContext';
|
|
|
8
8
|
import { useToaster } from '../context/ToasterContext';
|
|
9
9
|
import FormikInput from '../elements/formik/FormikInput';
|
|
10
10
|
import ConfirmationDialog from '../elements/popup/Modal/ConfirmDialog';
|
|
11
|
+
import { useWorkspaceAction } from './useWorkspaceAction';
|
|
11
12
|
const schema = Yup.object().shape({
|
|
12
13
|
workspaceName: Yup.string().required(),
|
|
13
14
|
});
|
|
@@ -25,16 +26,11 @@ export function useSaveSettings() {
|
|
|
25
26
|
const toaster = useToaster();
|
|
26
27
|
const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
|
|
27
28
|
const settingsRef = useRef();
|
|
28
|
-
const {
|
|
29
|
+
const { current } = usePreferences();
|
|
29
30
|
const formRef = useRef(null);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
payload: {
|
|
34
|
-
workspaceKey: workspaceName,
|
|
35
|
-
data: settingsRef.current,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
31
|
+
const { saveWorkspace, addNewWorkspace } = useWorkspaceAction();
|
|
32
|
+
function handleAddNewWorkspace({ workspaceName }) {
|
|
33
|
+
addNewWorkspace(workspaceName, settingsRef.current);
|
|
38
34
|
closeDialog();
|
|
39
35
|
toaster.show({
|
|
40
36
|
message: 'Preferences saved successfully',
|
|
@@ -48,17 +44,14 @@ export function useSaveSettings() {
|
|
|
48
44
|
openDialog();
|
|
49
45
|
}
|
|
50
46
|
else {
|
|
51
|
-
|
|
52
|
-
type: 'SET_PREFERENCES',
|
|
53
|
-
...(values && { payload: values }),
|
|
54
|
-
});
|
|
47
|
+
saveWorkspace(values);
|
|
55
48
|
closeDialog();
|
|
56
49
|
}
|
|
57
50
|
},
|
|
58
51
|
SaveSettingsModal: () => {
|
|
59
52
|
const alertConfig = {
|
|
60
53
|
message: 'Please enter a new user workspace name in order to save your changes locally',
|
|
61
|
-
render: (props) => (_jsx(WorkspaceAddForm, { ...props, onSave:
|
|
54
|
+
render: (props) => (_jsx(WorkspaceAddForm, { ...props, onSave: handleAddNewWorkspace, ref: formRef })),
|
|
62
55
|
buttons: [
|
|
63
56
|
{
|
|
64
57
|
text: 'Save',
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useShareData } from '../context/ShareDataContext';
|
|
2
|
+
export function useTriggerNewAssignmentLabel(id) {
|
|
3
|
+
const { data: rangeKey, setData } = useShareData();
|
|
4
|
+
function dismissNewLabel() {
|
|
5
|
+
setData(null);
|
|
6
|
+
}
|
|
7
|
+
return { isNewAssignment: rangeKey === id, dismissNewLabel };
|
|
8
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Workspace } from 'nmr-load-save';
|
|
2
|
+
export declare function useWorkspaceAction(): {
|
|
3
|
+
addNewWorkspace: (workspaceName: string, data?: Omit<Workspace, 'version' | 'label'>) => void;
|
|
4
|
+
removeWorkspace: (key: string) => void;
|
|
5
|
+
saveWorkspace: (data?: Partial<Workspace>) => void;
|
|
6
|
+
setActiveWorkspace: (workspace: string) => void;
|
|
7
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { v4 } from '@lukeed/uuid';
|
|
2
|
+
import lodashMerge from 'lodash/merge';
|
|
3
|
+
import { usePreferences } from '../context/PreferencesContext';
|
|
4
|
+
import { readSettings, updateSettings, } from '../reducer/preferences/preferencesReducer';
|
|
5
|
+
import { workspaceDefaultProperties } from '../workspaces/workspaceDefaultProperties';
|
|
6
|
+
export function useWorkspaceAction() {
|
|
7
|
+
const { dispatch, current, workspace } = usePreferences();
|
|
8
|
+
function setActiveWorkspace(workspace) {
|
|
9
|
+
const settings = readSettings() || {
|
|
10
|
+
currentWorkspace: null,
|
|
11
|
+
version: 0,
|
|
12
|
+
workspaces: {},
|
|
13
|
+
};
|
|
14
|
+
settings.currentWorkspace = workspace;
|
|
15
|
+
updateSettings(settings);
|
|
16
|
+
dispatch({
|
|
17
|
+
type: 'SET_ACTIVE_WORKSPACE',
|
|
18
|
+
payload: {
|
|
19
|
+
workspace,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function addNewWorkspace(workspaceName, data) {
|
|
24
|
+
const workSpaceData = data ?? current;
|
|
25
|
+
const newWorkSpace = lodashMerge({}, workspaceDefaultProperties, workSpaceData, {
|
|
26
|
+
version: 1,
|
|
27
|
+
label: workspaceName,
|
|
28
|
+
source: 'user',
|
|
29
|
+
});
|
|
30
|
+
const workspaceKey = v4();
|
|
31
|
+
const localData = readSettings() || { workspaces: {} };
|
|
32
|
+
const settings = {
|
|
33
|
+
...localData,
|
|
34
|
+
currentWorkspace: workspaceKey,
|
|
35
|
+
workspaces: { ...localData?.workspaces, [workspaceKey]: newWorkSpace },
|
|
36
|
+
};
|
|
37
|
+
updateSettings(settings);
|
|
38
|
+
dispatch({
|
|
39
|
+
type: 'ADD_WORKSPACE',
|
|
40
|
+
payload: {
|
|
41
|
+
workspaceKey,
|
|
42
|
+
data: newWorkSpace,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function removeWorkspace(key) {
|
|
47
|
+
const settings = readSettings();
|
|
48
|
+
if (settings) {
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
50
|
+
delete settings.workspaces[key];
|
|
51
|
+
if (key === settings.currentWorkspace) {
|
|
52
|
+
settings.currentWorkspace = 'default';
|
|
53
|
+
}
|
|
54
|
+
updateSettings(settings);
|
|
55
|
+
}
|
|
56
|
+
dispatch({
|
|
57
|
+
type: 'REMOVE_WORKSPACE',
|
|
58
|
+
payload: {
|
|
59
|
+
workspace: key,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
function saveWorkspace(data) {
|
|
64
|
+
if (data) {
|
|
65
|
+
const settings = readSettings() || {
|
|
66
|
+
version: 0,
|
|
67
|
+
currentWorkspace: null,
|
|
68
|
+
workspaces: {},
|
|
69
|
+
};
|
|
70
|
+
updateSettings({
|
|
71
|
+
...settings,
|
|
72
|
+
workspaces: {
|
|
73
|
+
...settings.workspaces,
|
|
74
|
+
[workspace.current]: data,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
dispatch({
|
|
79
|
+
type: 'SET_PREFERENCES',
|
|
80
|
+
...(data && { payload: data }),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
addNewWorkspace,
|
|
85
|
+
removeWorkspace,
|
|
86
|
+
saveWorkspace,
|
|
87
|
+
setActiveWorkspace,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
@@ -11,7 +11,7 @@ import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
|
|
|
11
11
|
import { ModalProvider } from '../elements/popup/Modal';
|
|
12
12
|
import { HighlightProvider } from '../highlight';
|
|
13
13
|
import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
|
|
14
|
-
import preferencesReducer, { preferencesInitialState, initPreferencesState, } from '../reducer/preferences/preferencesReducer';
|
|
14
|
+
import preferencesReducer, { preferencesInitialState, initPreferencesState, readSettings, } from '../reducer/preferences/preferencesReducer';
|
|
15
15
|
import { getBlob } from '../utility/export';
|
|
16
16
|
import { InnerNMRiumContents } from './InnerNMRiumContents';
|
|
17
17
|
import NMRiumStateProvider from './NMRiumStateProvider';
|
|
@@ -26,12 +26,14 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
|
|
|
26
26
|
rootRef.current?.focus();
|
|
27
27
|
}, [isFullScreen]);
|
|
28
28
|
useEffect(() => {
|
|
29
|
+
const settings = readSettings();
|
|
29
30
|
dispatchPreferences({
|
|
30
31
|
type: 'INIT_PREFERENCES',
|
|
31
32
|
payload: {
|
|
32
33
|
preferences,
|
|
33
34
|
workspace,
|
|
34
35
|
customWorkspaces,
|
|
36
|
+
currentWorkspace: settings?.currentWorkspace,
|
|
35
37
|
dispatch: dispatchPreferences,
|
|
36
38
|
},
|
|
37
39
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
|
-
import { css } from '@emotion/react';
|
|
3
|
+
import { Global, css } from '@emotion/react';
|
|
4
4
|
import { useCallback } from 'react';
|
|
5
5
|
import { useFullscreen } from 'react-science/ui';
|
|
6
6
|
import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
|
|
@@ -55,6 +55,12 @@ const containerStyles = css `
|
|
|
55
55
|
-o-user-drag: none;
|
|
56
56
|
user-select: none;
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
.actions-buttons-popover {
|
|
60
|
+
background: transparent;
|
|
61
|
+
padding: 5px;
|
|
62
|
+
box-shadow: none;
|
|
63
|
+
}
|
|
58
64
|
`;
|
|
59
65
|
export function InnerNMRiumContents(props) {
|
|
60
66
|
const { emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef } = props;
|
|
@@ -65,7 +71,13 @@ export function InnerNMRiumContents(props) {
|
|
|
65
71
|
e.preventDefault();
|
|
66
72
|
}
|
|
67
73
|
}, []);
|
|
68
|
-
return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx(
|
|
74
|
+
return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx(Global, { styles: css `
|
|
75
|
+
.actions-buttons-popover {
|
|
76
|
+
border-radius: 10px;
|
|
77
|
+
padding: 5px;
|
|
78
|
+
background-color: white;
|
|
79
|
+
}
|
|
80
|
+
` }), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
|
|
69
81
|
display: 'flex',
|
|
70
82
|
flexDirection: 'column',
|
|
71
83
|
backgroundColor: 'white',
|
|
@@ -74,8 +74,10 @@ export default function NMRiumStateProvider(props) {
|
|
|
74
74
|
})
|
|
75
75
|
.catch((error) => {
|
|
76
76
|
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if (error instanceof Error) {
|
|
78
|
+
// eslint-disable-next-line no-alert
|
|
79
|
+
window.alert(error.message);
|
|
80
|
+
}
|
|
79
81
|
reportError(error);
|
|
80
82
|
});
|
|
81
83
|
}
|
|
@@ -3,8 +3,8 @@ import { translateMultiplet } from 'nmr-processing';
|
|
|
3
3
|
import FormikInput from '../../../../elements/formik/FormikInput';
|
|
4
4
|
const style = {
|
|
5
5
|
input: {
|
|
6
|
-
width: '
|
|
7
|
-
height: '
|
|
6
|
+
width: '60px',
|
|
7
|
+
height: '30px',
|
|
8
8
|
},
|
|
9
9
|
inputWrapper: {
|
|
10
10
|
borderWidth: 0,
|
|
@@ -12,7 +12,7 @@ const style = {
|
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
14
|
export function DeltaInput({ signal, index }) {
|
|
15
|
-
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { children: "\uD835\uDEC5: " }), _jsx(FormikInput, { name: `signals.${index}.delta`, type: "number", placeholder: '
|
|
15
|
+
return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { children: "\uD835\uDEC5: " }), _jsx(FormikInput, { name: `signals.${index}.delta`, type: "number", placeholder: 'Delta (PPM)', style: style, checkErrorAfterInputTouched: false }), _jsx("span", { children: signal.js
|
|
16
16
|
.map((_coupling) => translateMultiplet(_coupling.multiplicity))
|
|
17
17
|
.join('') })] }));
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Formik, useFormikContext } from 'formik';
|
|
3
3
|
import { translateMultiplet } from 'nmr-processing';
|
|
4
|
-
import { useRef } from 'react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import * as Yup from 'yup';
|
|
6
6
|
import { useChartData } from '../../../../context/ChartContext';
|
|
7
7
|
import Button from '../../../../elements/Button';
|
|
@@ -27,7 +27,9 @@ const styles = {
|
|
|
27
27
|
export function NewSignalTab(props) {
|
|
28
28
|
const { range } = props;
|
|
29
29
|
const { values, setFieldValue } = useFormikContext();
|
|
30
|
+
const [signalValue, setSignalValue] = useState((range.from + range.to) / 2);
|
|
30
31
|
const newSignalFormRef = useRef();
|
|
32
|
+
const inputRef = useRef(null);
|
|
31
33
|
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
32
34
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
33
35
|
function saveHandler(val) {
|
|
@@ -42,28 +44,31 @@ export function NewSignalTab(props) {
|
|
|
42
44
|
void setFieldValue('signalIndex', String(_signals.length - 1));
|
|
43
45
|
}
|
|
44
46
|
useEvent({
|
|
45
|
-
onClick: (
|
|
46
|
-
if (values.signalIndex === '-1') {
|
|
47
|
-
|
|
47
|
+
onClick: ({ xPPM, shiftKey }) => {
|
|
48
|
+
if (values.signalIndex === '-1' && shiftKey) {
|
|
49
|
+
setSignalValue(xPPM);
|
|
48
50
|
}
|
|
49
51
|
},
|
|
50
52
|
onBrushEnd: (options) => {
|
|
51
|
-
const { range: [from, to], } = options;
|
|
52
|
-
if (values.signalIndex === '-1') {
|
|
53
|
-
|
|
54
|
-
newSignalDelta: (to - from) / 2 + from,
|
|
55
|
-
});
|
|
53
|
+
const { range: [from, to], shiftKey, } = options;
|
|
54
|
+
if (values.signalIndex === '-1' && shiftKey) {
|
|
55
|
+
setSignalValue((to - from) / 2 + from);
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
});
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
setTimeout(() => {
|
|
61
|
+
inputRef.current?.select();
|
|
62
|
+
}, 50);
|
|
63
|
+
}, [signalValue]);
|
|
59
64
|
return (_jsx("div", { style: styles.container, children: _jsx(Formik, { innerRef: newSignalFormRef, validationSchema: getSignalValidationSchema(range), initialValues: {
|
|
60
|
-
newSignalDelta:
|
|
61
|
-
}, onSubmit: saveHandler, children: _jsxs("div", { style: styles.innerContainer, children: [_jsxs("p", { style: styles.infoText, children: ["Edit or select a delta value of new signal in range [", `${formatNumber(range.from, rangesPreferences.from.format)} ppm - ${formatNumber(range.to, rangesPreferences.to.format)} ppm`, "]:"] }), _jsx(FormikInput, { name: "newSignalDelta", type: "number", placeholder: `𝛅(ppm)`, style: {
|
|
65
|
+
newSignalDelta: signalValue,
|
|
66
|
+
}, enableReinitialize: true, onSubmit: saveHandler, children: _jsxs("div", { style: styles.innerContainer, children: [_jsxs("p", { style: styles.infoText, children: ["Edit or select a delta value of new signal in range [", `${formatNumber(range.from, rangesPreferences.from.format)} ppm - ${formatNumber(range.to, rangesPreferences.to.format)} ppm`, "]:"] }), _jsx(FormikInput, { ref: inputRef, name: "newSignalDelta", type: "number", placeholder: `𝛅(ppm)`, style: {
|
|
62
67
|
input: {
|
|
63
68
|
height: '30px',
|
|
64
69
|
padding: '0.25rem 0.5rem',
|
|
65
70
|
},
|
|
66
|
-
}, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
|
|
71
|
+
}, autoSelect: true, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
|
|
67
72
|
marginTop: '20px',
|
|
68
73
|
height: '30px',
|
|
69
74
|
}, onClick: () => newSignalFormRef.current.submitForm(), children: "Add a signal" })] }) }) }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useFormikContext } from 'formik';
|
|
3
3
|
import { translateMultiplet } from 'nmr-processing';
|
|
4
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
5
5
|
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
6
6
|
import { Toolbar } from 'react-science/ui';
|
|
7
7
|
import { Multiplets } from '../../../../../../data/constants/Multiplets';
|
|
@@ -35,23 +35,25 @@ function getJCouplingKey(signalIndex, jIndex, jCouplingKey) {
|
|
|
35
35
|
export function SignalJCouplingsTable(props) {
|
|
36
36
|
const { values, setFieldValue } = useFormikContext();
|
|
37
37
|
const signal = values?.signals?.[values?.signalIndex] || {};
|
|
38
|
-
const jCouplings = signal?.js || [];
|
|
39
38
|
const [lastSelectedCouplingIndex, setLastSelectedCouplingIndex] = useState(null);
|
|
40
39
|
const spectrum = useSpectrum();
|
|
41
40
|
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
42
41
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
42
|
+
const inputRef = useRef([]);
|
|
43
43
|
useEvent({
|
|
44
|
-
onClick: (
|
|
44
|
+
onClick: ({ xPPM, shiftKey }) => {
|
|
45
45
|
if (`${props.index}` === values.signalIndex &&
|
|
46
|
-
typeof lastSelectedCouplingIndex === 'number'
|
|
47
|
-
|
|
46
|
+
typeof lastSelectedCouplingIndex === 'number' &&
|
|
47
|
+
shiftKey) {
|
|
48
|
+
const x = formatNumber(xPPM, rangesPreferences.deltaHz.format);
|
|
48
49
|
void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), x);
|
|
49
50
|
}
|
|
50
51
|
},
|
|
51
52
|
onBrushEnd: (options) => {
|
|
52
|
-
const { range: [from, to], } = options;
|
|
53
|
+
const { range: [from, to], shiftKey, } = options;
|
|
53
54
|
if (`${props.index}` === values.signalIndex &&
|
|
54
55
|
typeof lastSelectedCouplingIndex === 'number' &&
|
|
56
|
+
shiftKey &&
|
|
55
57
|
isSpectrum1D(spectrum)) {
|
|
56
58
|
const value = Number(formatNumber(Math.abs(to - from) * spectrum.info.originFrequency, rangesPreferences.deltaHz.format));
|
|
57
59
|
void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), value);
|
|
@@ -97,6 +99,10 @@ export function SignalJCouplingsTable(props) {
|
|
|
97
99
|
Cell: ({ row }) => {
|
|
98
100
|
return (_jsx(FormikSelect, { className: "select-box", name: getJCouplingKey(values.signalIndex, row.index, 'multiplicity'), items: Multiplets, itemValueField: "label", onChange: (value) => {
|
|
99
101
|
multiplicityChangeHandler(value, getJCouplingKey(values.signalIndex, row.index, 'coupling'));
|
|
102
|
+
if (hasCouplingConstant(row.original?.multiplicity) &&
|
|
103
|
+
typeof lastSelectedCouplingIndex === 'number') {
|
|
104
|
+
inputRef.current[lastSelectedCouplingIndex].focus();
|
|
105
|
+
}
|
|
100
106
|
}, style: styles.select, onClick: (e) => e.stopPropagation() }));
|
|
101
107
|
},
|
|
102
108
|
},
|
|
@@ -104,7 +110,11 @@ export function SignalJCouplingsTable(props) {
|
|
|
104
110
|
Header: 'J (Hz)',
|
|
105
111
|
style: { padding: 0, ...styles.column },
|
|
106
112
|
Cell: ({ row }) => {
|
|
107
|
-
return (_jsx(FormikInput, {
|
|
113
|
+
return (_jsx(FormikInput, { ref: (ref) => {
|
|
114
|
+
if (ref) {
|
|
115
|
+
inputRef.current[row.index] = ref;
|
|
116
|
+
}
|
|
117
|
+
}, name: getJCouplingKey(values.signalIndex, row.index, 'coupling'), type: "number", placeholder: 'J (Hz)', style: { input: styles.input }, disabled: !hasCouplingConstant(row.original?.multiplicity) }));
|
|
108
118
|
},
|
|
109
119
|
},
|
|
110
120
|
{
|
|
@@ -119,15 +129,22 @@ export function SignalJCouplingsTable(props) {
|
|
|
119
129
|
}, children: _jsx(FaRegTrashAlt, {}) })) }));
|
|
120
130
|
},
|
|
121
131
|
},
|
|
122
|
-
], [
|
|
132
|
+
], [
|
|
133
|
+
deleteHandler,
|
|
134
|
+
lastSelectedCouplingIndex,
|
|
135
|
+
multiplicityChangeHandler,
|
|
136
|
+
values.signalIndex,
|
|
137
|
+
]);
|
|
123
138
|
function selectRowHandler(index) {
|
|
124
139
|
setLastSelectedCouplingIndex((prevIndex) => prevIndex === index ? null : index);
|
|
125
140
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (typeof lastSelectedCouplingIndex === 'number') {
|
|
143
|
+
inputRef.current[lastSelectedCouplingIndex].focus();
|
|
144
|
+
}
|
|
145
|
+
}, [lastSelectedCouplingIndex, signal?.js]);
|
|
146
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), tooltip: "Add a new J coupling", intent: "success", onClick: () => addHandler(signal?.js || []) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), tooltip: "Delete all J couplings", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
|
|
130
147
|
maxHeight: '300px',
|
|
131
148
|
overflow: 'auto',
|
|
132
|
-
}, children: _jsx(ReactTable, { data:
|
|
149
|
+
}, children: _jsx(ReactTable, { data: signal?.js || [], columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), emptyDataRowText: "No J Couplings" }) })] }));
|
|
133
150
|
}
|
|
@@ -3,7 +3,7 @@ import { v4 } from '@lukeed/uuid';
|
|
|
3
3
|
import { useFormikContext } from 'formik';
|
|
4
4
|
import { xFindClosestIndex } from 'ml-spectra-processing';
|
|
5
5
|
import { getShiftX } from 'nmr-processing';
|
|
6
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
7
7
|
import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
|
|
8
8
|
import { Toolbar } from 'react-science/ui';
|
|
9
9
|
import { useChartData } from '../../../../../context/ChartContext';
|
|
@@ -33,7 +33,6 @@ function getPeakKey(signalIndex, peakIndex, key) {
|
|
|
33
33
|
export function SignalPeaksTable(props) {
|
|
34
34
|
const { values, setFieldValue } = useFormikContext();
|
|
35
35
|
const signal = values?.signals?.[values?.signalIndex] || {};
|
|
36
|
-
const peaks = signal?.peaks || [];
|
|
37
36
|
const delta = signal?.delta || 0;
|
|
38
37
|
const spectrum = useSpectrum();
|
|
39
38
|
const { data: { x: xArray, re }, } = spectrum;
|
|
@@ -41,24 +40,27 @@ export function SignalPeaksTable(props) {
|
|
|
41
40
|
const [lastSelectedPeakIndex, setLastSelectedPeakIndex] = useState(null);
|
|
42
41
|
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
43
42
|
const rangesPreferences = usePanelPreferences('ranges', activeTab);
|
|
43
|
+
const inputRef = useRef([]);
|
|
44
44
|
useEvent({
|
|
45
|
-
onClick: (
|
|
45
|
+
onClick: ({ xPPM, shiftKey }) => {
|
|
46
46
|
if (`${props.index}` === values.signalIndex &&
|
|
47
|
-
typeof lastSelectedPeakIndex === 'number'
|
|
48
|
-
|
|
47
|
+
typeof lastSelectedPeakIndex === 'number' &&
|
|
48
|
+
shiftKey) {
|
|
49
|
+
const delta = formatNumber(xPPM, rangesPreferences.deltaPPM.format);
|
|
49
50
|
const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
|
|
50
51
|
const intensity = formatNumber(re[xIndex], rangesPreferences.deltaPPM.format);
|
|
51
52
|
void setFieldValue(getPeakKey(values?.signalIndex, lastSelectedPeakIndex), {
|
|
52
|
-
...peaks[lastSelectedPeakIndex],
|
|
53
|
+
...signal?.peaks?.[lastSelectedPeakIndex],
|
|
53
54
|
x: delta,
|
|
54
55
|
y: intensity,
|
|
55
56
|
});
|
|
56
57
|
}
|
|
57
58
|
},
|
|
58
59
|
onBrushEnd: (options) => {
|
|
59
|
-
const { range: [from, to], } = options;
|
|
60
|
+
const { range: [from, to], shiftKey, } = options;
|
|
60
61
|
if (`${props.index}` === values.signalIndex &&
|
|
61
|
-
typeof lastSelectedPeakIndex === 'number'
|
|
62
|
+
typeof lastSelectedPeakIndex === 'number' &&
|
|
63
|
+
shiftKey) {
|
|
62
64
|
const value = Number(formatNumber((to - from) / 2 + from, rangesPreferences.deltaPPM.format));
|
|
63
65
|
void setFieldValue(getPeakKey(values.signalIndex, lastSelectedPeakIndex, 'x'), value);
|
|
64
66
|
}
|
|
@@ -77,7 +79,8 @@ export function SignalPeaksTable(props) {
|
|
|
77
79
|
...data,
|
|
78
80
|
peak,
|
|
79
81
|
]);
|
|
80
|
-
|
|
82
|
+
const rowIndex = data?.length || 0;
|
|
83
|
+
setLastSelectedPeakIndex(rowIndex);
|
|
81
84
|
}, [delta, re, setFieldValue, shiftX, values?.signalIndex, xArray]);
|
|
82
85
|
const deleteHandler = useCallback((data, index) => {
|
|
83
86
|
const peaks = data.filter((_, columnIndex) => columnIndex !== index);
|
|
@@ -105,7 +108,11 @@ export function SignalPeaksTable(props) {
|
|
|
105
108
|
Header: 'delta',
|
|
106
109
|
style: { padding: 0, ...styles.column },
|
|
107
110
|
Cell: ({ row }) => {
|
|
108
|
-
return (_jsx(FormikInput, {
|
|
111
|
+
return (_jsx(FormikInput, { ref: (ref) => {
|
|
112
|
+
if (ref) {
|
|
113
|
+
inputRef.current[row.index] = ref;
|
|
114
|
+
}
|
|
115
|
+
}, name: `signals.${values?.signalIndex}.peaks.${row.index}.x`, style: { input: styles.input }, onChange: (event) => changeDeltaHandler(event, row.index), type: "number" }));
|
|
109
116
|
},
|
|
110
117
|
},
|
|
111
118
|
{
|
|
@@ -129,13 +136,16 @@ export function SignalPeaksTable(props) {
|
|
|
129
136
|
},
|
|
130
137
|
], [changeDeltaHandler, deleteHandler, values?.signalIndex]);
|
|
131
138
|
function selectRowHandler(index) {
|
|
132
|
-
setLastSelectedPeakIndex(
|
|
139
|
+
setLastSelectedPeakIndex(index);
|
|
140
|
+
inputRef.current[index].select();
|
|
133
141
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
if (typeof lastSelectedPeakIndex === 'number') {
|
|
144
|
+
inputRef.current[lastSelectedPeakIndex].focus();
|
|
145
|
+
}
|
|
146
|
+
}, [lastSelectedPeakIndex, signal?.peaks]);
|
|
147
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), tooltip: "Add a new peak", intent: "success", onClick: () => addHandler(signal?.peaks || []) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), tooltip: "Delete all peaks", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
|
|
138
148
|
maxHeight: '300px',
|
|
139
149
|
overflow: 'auto',
|
|
140
|
-
}, children: _jsx(ReactTable, { data: peaks, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index),
|
|
150
|
+
}, children: _jsx(ReactTable, { data: signal?.peaks || [], columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), emptyDataRowText: "No peaks" }) })] }));
|
|
141
151
|
}
|