nmrium 0.47.0 → 0.49.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/Chart1D.js +1 -1
- 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/SpectraLegends.js +1 -1
- package/lib/component/1d/Viewer1D.js +144 -124
- package/lib/component/1d/jCouplingGraph/JsCoupling.js +1 -1
- package/lib/component/1d/peaks/Peaks.js +5 -4
- package/lib/component/1d/ranges/Atoms.d.ts +7 -0
- package/lib/component/1d/ranges/Atoms.js +43 -0
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/BaseLine.d.ts +2 -0
- package/lib/component/1d/tool/BaseLine.js +26 -0
- package/lib/component/1d/tool/BaseLineZones.js +18 -3
- package/lib/component/1d/utilities/scale.d.ts +1 -0
- package/lib/component/1d/utilities/scale.js +2 -1
- package/lib/component/2d/Chart2D.js +6 -4
- package/lib/component/2d/Viewer2D.js +35 -26
- package/lib/component/context/KeyModifierContext.d.ts +14 -3
- package/lib/component/context/KeyModifierContext.js +35 -4
- package/lib/component/context/LoggerContext.d.ts +9 -0
- package/lib/component/context/LoggerContext.js +21 -7
- package/lib/component/context/PreferencesContext.d.ts +1 -108
- package/lib/component/context/TopicMoleculeContext.d.ts +8 -0
- package/lib/component/context/TopicMoleculeContext.js +30 -0
- package/lib/component/elements/Input.js +4 -1
- package/lib/component/elements/ResizerWithScale.js +19 -2
- package/lib/component/elements/SVGGroup.js +2 -2
- package/lib/component/elements/formik/FormikTextarea.js +8 -9
- package/lib/component/elements/linearAxis/LinearVerticalAxis.js +1 -1
- package/lib/component/elements/resizer/SVGResizer.js +1 -1
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -2
- package/lib/component/header/Header.js +2 -2
- package/lib/component/hooks/useCheckToolsVisibility.js +1 -1
- package/lib/component/hooks/useExport.js +2 -2
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts +3 -0
- package/lib/component/hooks/useSetActiveSpectrumAction.js +16 -0
- package/lib/component/hooks/useToolsFunctions.js +4 -2
- package/lib/component/hooks/useVerticalAlign.d.ts +1 -1
- package/lib/component/main/InnerNMRium.js +3 -2
- package/lib/component/modal/ExportAsJcampModal.js +1 -1
- package/lib/component/modal/ImportPublicationStringModal.d.ts +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +76 -32
- package/lib/component/modal/editRange/forms/validation/EditRangeValidation.js +2 -4
- package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +9 -11
- 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/RangesTable.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +39 -5
- package/lib/component/panels/SpectrumsPanel/SpectraTable.js +28 -40
- package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
- 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/SpectraColumnsManager.js +19 -16
- package/lib/component/panels/SpectrumsPanel/base/SpectrumName.js +0 -1
- package/lib/component/panels/databasePanel/DatabasePanel.js +6 -1
- package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +1 -1
- package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -1
- package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +15 -4
- package/lib/component/reducer/Reducer.js +2 -0
- 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.d.ts +3 -4
- package/lib/component/reducer/actions/FiltersActions.js +93 -57
- package/lib/component/reducer/actions/LoadActions.js +10 -8
- package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -1
- package/lib/component/reducer/actions/SpectrumsActions.js +8 -4
- package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
- package/lib/component/reducer/actions/ToolsActions.js +51 -44
- package/lib/component/reducer/helper/getVerticalAlign.d.ts +1 -1
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +0 -4
- package/lib/component/toolbar/BasicToolBar.js +11 -29
- package/lib/component/utility/export.d.ts +3 -2
- package/lib/component/utility/export.js +45 -26
- package/lib/component/workspaces/exercise.js +1 -0
- package/lib/component/workspaces/prediction.js +1 -16
- package/lib/component/workspaces/simulation.js +1 -2
- package/lib/component/workspaces/workspaceDefaultProperties.js +4 -3
- package/lib/data/data1d/Spectrum1D/index.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/index.js +0 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +27 -40
- package/lib/data/data2d/Spectrum2D/getMissingProjection.js +10 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +31 -30
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
|
@@ -8,6 +8,7 @@ import { BrushTracker, } from '../EventsTrackers/BrushTracker';
|
|
|
8
8
|
import { MouseTracker } from '../EventsTrackers/MouseTracker';
|
|
9
9
|
import { useChartData } from '../context/ChartContext';
|
|
10
10
|
import { useDispatch } from '../context/DispatchContext';
|
|
11
|
+
import { useMapKeyModifiers } from '../context/KeyModifierContext';
|
|
11
12
|
import Spinner from '../loader/Spinner';
|
|
12
13
|
import { options } from '../toolbar/ToolTypes';
|
|
13
14
|
import { PhaseTraces } from './1d-tracer/phase-correction-traces';
|
|
@@ -23,6 +24,7 @@ function Viewer2D({ emptyText = undefined }) {
|
|
|
23
24
|
const { toolOptions: { selectedTool }, isLoading, data, margin, view: { spectra: { activeSpectra, activeTab }, }, } = state;
|
|
24
25
|
const dispatch = useDispatch();
|
|
25
26
|
const brushStartRef = useRef(null);
|
|
27
|
+
const { getModifiersKey, primaryKeyIdentifier } = useMapKeyModifiers();
|
|
26
28
|
const spectrumData = useMemo(() => {
|
|
27
29
|
const nuclei = activeTab.split(',');
|
|
28
30
|
return nuclei
|
|
@@ -58,41 +60,48 @@ function Viewer2D({ emptyText = undefined }) {
|
|
|
58
60
|
const handelBrushEnd = useCallback((brushData) => {
|
|
59
61
|
//reset the brush start
|
|
60
62
|
brushStartRef.current = null;
|
|
63
|
+
const modifierKey = getModifiersKey(brushData);
|
|
64
|
+
let executeDefaultAction = false;
|
|
61
65
|
if (brushData.mouseButton === 'main') {
|
|
62
66
|
const trackID = getLayoutID(DIMENSION, brushData);
|
|
63
67
|
if (trackID) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
switch (modifierKey) {
|
|
69
|
+
case primaryKeyIdentifier: {
|
|
70
|
+
switch (selectedTool) {
|
|
71
|
+
case options.zoom.id: {
|
|
72
|
+
executeDefaultAction = true;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case options.zonePicking.id: {
|
|
76
|
+
dispatch({ type: 'ADD_2D_ZONE', payload: brushData });
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
default:
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
68
83
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
case options.zonePicking.id:
|
|
73
|
-
dispatch({ type: 'ADD_2D_ZONE', payload: brushData });
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
break;
|
|
84
|
+
default: {
|
|
85
|
+
executeDefaultAction = true;
|
|
86
|
+
break;
|
|
77
87
|
}
|
|
78
88
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
89
|
+
const isNotDistanceMeasurementTool = selectedTool !== 'zoom' ||
|
|
90
|
+
(selectedTool === 'zoom' && !brushData.shiftKey);
|
|
91
|
+
if (executeDefaultAction &&
|
|
92
|
+
selectedTool != null &&
|
|
93
|
+
isNotDistanceMeasurementTool) {
|
|
94
|
+
return dispatch({
|
|
95
|
+
type: 'BRUSH_END',
|
|
96
|
+
payload: {
|
|
97
|
+
...brushData,
|
|
98
|
+
trackID: getLayoutID(DIMENSION, brushData),
|
|
99
|
+
},
|
|
100
|
+
});
|
|
92
101
|
}
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
|
-
}, [selectedTool,
|
|
104
|
+
}, [getModifiersKey, DIMENSION, selectedTool, primaryKeyIdentifier, dispatch]);
|
|
96
105
|
const handelOnDoubleClick = useCallback((e) => {
|
|
97
106
|
const { x: startX, y: startY } = e;
|
|
98
107
|
const trackID = getLayoutID(DIMENSION, { startX, startY });
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
type ModifiersKey = `shift[${boolean}]_ctrl[${boolean}]_alt[${boolean}]`;
|
|
3
|
+
type PrimaryKey = 'shift[true]_ctrl[false]_alt[false]' | 'shift[false]_ctrl[false]_alt[false]';
|
|
2
4
|
interface KeyModifiers {
|
|
3
5
|
ctrlKey: boolean;
|
|
4
6
|
shiftKey: boolean;
|
|
5
7
|
altKey: boolean;
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
interface KeyModifiersState extends KeyModifiers {
|
|
10
|
+
modifiersKey: ModifiersKey | null;
|
|
11
|
+
}
|
|
12
|
+
export declare const KeyModifierContext: import("react").Context<KeyModifiersState>;
|
|
13
|
+
export declare function useKeyModifiers(): KeyModifiersState;
|
|
9
14
|
interface KeyModifierProviderProps {
|
|
10
15
|
children: ReactNode;
|
|
11
16
|
}
|
|
12
|
-
export declare function getModifiers(event: KeyboardEvent): {
|
|
17
|
+
export declare function getModifiers(event: KeyboardEvent | MouseEvent): {
|
|
13
18
|
ctrlKey: boolean;
|
|
14
19
|
shiftKey: boolean;
|
|
15
20
|
altKey: boolean;
|
|
16
21
|
};
|
|
22
|
+
export declare function toModifiersKey(keyModifiers: KeyModifiers): ModifiersKey;
|
|
23
|
+
declare function getModifiersKey(event: MouseEvent | KeyboardEvent): "shift[false]_ctrl[false]_alt[false]" | "shift[false]_ctrl[false]_alt[true]" | "shift[false]_ctrl[true]_alt[false]" | "shift[false]_ctrl[true]_alt[true]" | "shift[true]_ctrl[false]_alt[false]" | "shift[true]_ctrl[false]_alt[true]" | "shift[true]_ctrl[true]_alt[false]" | "shift[true]_ctrl[true]_alt[true]";
|
|
24
|
+
export declare function useMapKeyModifiers(): {
|
|
25
|
+
primaryKeyIdentifier: PrimaryKey;
|
|
26
|
+
getModifiersKey: typeof getModifiersKey;
|
|
27
|
+
};
|
|
17
28
|
export declare function KeyModifiersProvider({ children }: KeyModifierProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
29
|
export {};
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useEffect, useState, } from 'react';
|
|
2
|
+
import { createContext, useContext, useEffect, useMemo, useState, } from 'react';
|
|
3
|
+
import { usePreferences } from './PreferencesContext';
|
|
4
|
+
function getPrimaryKey(invert) {
|
|
5
|
+
if (invert) {
|
|
6
|
+
return 'shift[false]_ctrl[false]_alt[false]';
|
|
7
|
+
}
|
|
8
|
+
return 'shift[true]_ctrl[false]_alt[false]';
|
|
9
|
+
}
|
|
3
10
|
const defaultKeyModifiersState = {
|
|
4
11
|
ctrlKey: false,
|
|
5
12
|
shiftKey: false,
|
|
6
13
|
altKey: false,
|
|
14
|
+
modifiersKey: null,
|
|
7
15
|
};
|
|
8
16
|
export const KeyModifierContext = createContext(defaultKeyModifiersState);
|
|
9
17
|
export function useKeyModifiers() {
|
|
@@ -19,14 +27,37 @@ export function getModifiers(event) {
|
|
|
19
27
|
const ctrlKey = isMac ? metaKey : event.ctrlKey;
|
|
20
28
|
return { ctrlKey, shiftKey, altKey };
|
|
21
29
|
}
|
|
30
|
+
export function toModifiersKey(keyModifiers) {
|
|
31
|
+
const { shiftKey, altKey, ctrlKey } = keyModifiers;
|
|
32
|
+
return `shift[${shiftKey ? 'true' : 'false'}]_ctrl[${ctrlKey ? 'true' : 'false'}]_alt[${altKey ? 'true' : 'false'}]`;
|
|
33
|
+
}
|
|
34
|
+
function getModifiersKey(event) {
|
|
35
|
+
const keyModifiers = getModifiers(event);
|
|
36
|
+
return toModifiersKey(keyModifiers);
|
|
37
|
+
}
|
|
38
|
+
export function useMapKeyModifiers() {
|
|
39
|
+
const { current: { general: { invert }, }, } = usePreferences();
|
|
40
|
+
return useMemo(() => {
|
|
41
|
+
const primaryKeyIdentifier = getPrimaryKey(invert);
|
|
42
|
+
return {
|
|
43
|
+
primaryKeyIdentifier,
|
|
44
|
+
getModifiersKey,
|
|
45
|
+
};
|
|
46
|
+
}, [invert]);
|
|
47
|
+
}
|
|
22
48
|
export function KeyModifiersProvider({ children }) {
|
|
23
49
|
const [modifiers, setModifiers] = useState(defaultKeyModifiersState);
|
|
50
|
+
const { current: { general: { invert }, }, } = usePreferences();
|
|
24
51
|
useEffect(() => {
|
|
25
52
|
function handleKeyDown(event) {
|
|
26
|
-
|
|
53
|
+
const keyModifiers = getModifiers(event);
|
|
54
|
+
const modifiersKey = toModifiersKey(keyModifiers);
|
|
55
|
+
setModifiers({ ...keyModifiers, modifiersKey });
|
|
27
56
|
}
|
|
28
57
|
function handleKeyUp(event) {
|
|
29
|
-
|
|
58
|
+
const keyModifiers = getModifiers(event);
|
|
59
|
+
const modifiersKey = toModifiersKey(keyModifiers);
|
|
60
|
+
setModifiers({ ...keyModifiers, modifiersKey });
|
|
30
61
|
}
|
|
31
62
|
document.addEventListener('keydown', handleKeyDown);
|
|
32
63
|
document.addEventListener('keyup', handleKeyUp);
|
|
@@ -34,6 +65,6 @@ export function KeyModifiersProvider({ children }) {
|
|
|
34
65
|
document.removeEventListener('keydown', handleKeyDown);
|
|
35
66
|
document.removeEventListener('keyup', handleKeyUp);
|
|
36
67
|
};
|
|
37
|
-
}, []);
|
|
68
|
+
}, [invert]);
|
|
38
69
|
return (_jsx(KeyModifierContext.Provider, { value: modifiers, children: children }));
|
|
39
70
|
}
|
|
@@ -15,5 +15,14 @@ export declare function useLogger(): {
|
|
|
15
15
|
interface LoggerProviderProps {
|
|
16
16
|
children: ReactNode;
|
|
17
17
|
}
|
|
18
|
+
export declare const LOGGER_LEVELS: {
|
|
19
|
+
readonly fatal: 60;
|
|
20
|
+
readonly error: 50;
|
|
21
|
+
readonly warn: 40;
|
|
22
|
+
readonly info: 30;
|
|
23
|
+
readonly debug: 20;
|
|
24
|
+
readonly trace: 10;
|
|
25
|
+
readonly silent: 0;
|
|
26
|
+
};
|
|
18
27
|
export declare function LoggerProvider({ children }: LoggerProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
28
|
export {};
|
|
@@ -11,20 +11,31 @@ export function useLogger() {
|
|
|
11
11
|
}
|
|
12
12
|
return context;
|
|
13
13
|
}
|
|
14
|
+
export const LOGGER_LEVELS = {
|
|
15
|
+
fatal: 60,
|
|
16
|
+
error: 50,
|
|
17
|
+
warn: 40,
|
|
18
|
+
info: 30,
|
|
19
|
+
debug: 20,
|
|
20
|
+
trace: 10,
|
|
21
|
+
silent: 0,
|
|
22
|
+
};
|
|
14
23
|
export function LoggerProvider({ children }) {
|
|
15
|
-
const { current: { general: { loggingLevel }, }, } = usePreferences();
|
|
24
|
+
const { current: { general: { loggingLevel, popupLoggingLevel }, }, } = usePreferences();
|
|
16
25
|
const [lastReadLogId, setLastLogId] = useState(0);
|
|
17
26
|
const [logsHistory, setLogsHistory] = useState([]);
|
|
18
27
|
const [isLogHistoryOpened, openLogHistory] = useState(false);
|
|
28
|
+
const popupLoggingLevelRef = useRef();
|
|
19
29
|
const loggerRef = useRef(new FifoLogger({
|
|
20
30
|
onChange: (log, logs) => {
|
|
21
|
-
if (log &&
|
|
22
|
-
|
|
31
|
+
if (log &&
|
|
32
|
+
popupLoggingLevelRef.current &&
|
|
33
|
+
log.level === LOGGER_LEVELS[popupLoggingLevelRef.current]) {
|
|
23
34
|
openLogHistory(true);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
}
|
|
36
|
+
if (log?.error) {
|
|
37
|
+
// eslint-disable-next-line no-console
|
|
38
|
+
console.error(log.error);
|
|
28
39
|
}
|
|
29
40
|
setLogsHistory(logs.slice());
|
|
30
41
|
},
|
|
@@ -48,5 +59,8 @@ export function LoggerProvider({ children }) {
|
|
|
48
59
|
lastReadLogId,
|
|
49
60
|
};
|
|
50
61
|
}, [lastReadLogId, logsHistory, markAsRead]);
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
popupLoggingLevelRef.current = popupLoggingLevel;
|
|
64
|
+
}, [logsHistory, popupLoggingLevel]);
|
|
51
65
|
return (_jsxs(LoggerContext.Provider, { value: loggerState, children: [isLogHistoryOpened && (_jsx(LogsHistoryModal, { autoOpen: true, onClose: () => openLogHistory(false) })), children] }));
|
|
52
66
|
}
|
|
@@ -6,112 +6,5 @@ export interface PreferencesContextData extends PreferencesState {
|
|
|
6
6
|
}
|
|
7
7
|
export declare const PreferencesContext: import("react").Context<PreferencesState>;
|
|
8
8
|
export declare const PreferencesProvider: import("react").Provider<PreferencesState>;
|
|
9
|
-
export declare function usePreferences():
|
|
10
|
-
current: any;
|
|
11
|
-
isCurrentWorkspaceReadOnly: boolean;
|
|
12
|
-
version: number;
|
|
13
|
-
workspaces: import("../reducer/preferences/preferencesReducer").WorkspacesWithSource;
|
|
14
|
-
originalWorkspaces: import("../reducer/preferences/preferencesReducer").WorkspacesWithSource;
|
|
15
|
-
dispatch: (action?: ({
|
|
16
|
-
type: "INIT_PREFERENCES";
|
|
17
|
-
payload: {
|
|
18
|
-
display: import("nmr-load-save").WorkspacePreferences;
|
|
19
|
-
workspace: import("../main/types").NMRiumWorkspace;
|
|
20
|
-
customWorkspaces: Record<string, import("nmr-load-save").Workspace>;
|
|
21
|
-
dispatch: any;
|
|
22
|
-
};
|
|
23
|
-
} | ({
|
|
24
|
-
type: "SET_PREFERENCES";
|
|
25
|
-
payload: Partial<import("nmr-load-save").Workspace>;
|
|
26
|
-
} | {
|
|
27
|
-
type: "SET_PREFERENCES";
|
|
28
|
-
}) | {
|
|
29
|
-
type: "SET_PANELS_PREFERENCES";
|
|
30
|
-
payload: {
|
|
31
|
-
key: string;
|
|
32
|
-
value: string;
|
|
33
|
-
};
|
|
34
|
-
} | import("../reducer/preferences/preferencesReducer").SetWorkspaceAction | {
|
|
35
|
-
type: "REMOVE_WORKSPACE" | "SET_ACTIVE_WORKSPACE";
|
|
36
|
-
payload: {
|
|
37
|
-
workspace: string;
|
|
38
|
-
};
|
|
39
|
-
} | {
|
|
40
|
-
type: "ADD_WORKSPACE";
|
|
41
|
-
payload: {
|
|
42
|
-
workspaceKey: string;
|
|
43
|
-
data?: Omit<import("nmr-load-save").Workspace, "label" | "version"> | undefined;
|
|
44
|
-
};
|
|
45
|
-
} | {
|
|
46
|
-
type: "APPLY_General_PREFERENCES";
|
|
47
|
-
payload: {
|
|
48
|
-
data: Omit<import("nmr-load-save").Workspace, "label" | "version">;
|
|
49
|
-
};
|
|
50
|
-
} | {
|
|
51
|
-
type: "ANALYZE_SPECTRA";
|
|
52
|
-
payload: {
|
|
53
|
-
start: number;
|
|
54
|
-
end: number;
|
|
55
|
-
nucleus: string;
|
|
56
|
-
columnKey?: string | undefined;
|
|
57
|
-
};
|
|
58
|
-
} | {
|
|
59
|
-
type: "CHANGE_ANALYSIS_COLUMN_VALUE_KEY";
|
|
60
|
-
payload: {
|
|
61
|
-
columnKey: string;
|
|
62
|
-
valueKey: string;
|
|
63
|
-
nucleus: string;
|
|
64
|
-
};
|
|
65
|
-
} | {
|
|
66
|
-
type: "DELETE_ANALYSIS_COLUMN";
|
|
67
|
-
payload: {
|
|
68
|
-
columnKey: string;
|
|
69
|
-
nucleus: string;
|
|
70
|
-
};
|
|
71
|
-
} | {
|
|
72
|
-
type: "SET_SPECTRA_ANALYSIS_PREFERENCES";
|
|
73
|
-
payload: {
|
|
74
|
-
nucleus: string;
|
|
75
|
-
data: import("nmr-load-save").MultipleSpectraAnalysisPreferences;
|
|
76
|
-
};
|
|
77
|
-
} | {
|
|
78
|
-
type: "SET_MATRIX_GENERATION_OPTIONS";
|
|
79
|
-
payload: {
|
|
80
|
-
nucleus: string;
|
|
81
|
-
options: import("../../data/types/data1d/MatrixOptions").MatrixOptions;
|
|
82
|
-
};
|
|
83
|
-
} | {
|
|
84
|
-
type: "ADD_MATRIX_GENERATION_EXCLUSION_ZONE";
|
|
85
|
-
payload: {
|
|
86
|
-
zone: {
|
|
87
|
-
from: number;
|
|
88
|
-
to: number;
|
|
89
|
-
};
|
|
90
|
-
range: {
|
|
91
|
-
from: number;
|
|
92
|
-
to: number;
|
|
93
|
-
};
|
|
94
|
-
nucleus: string;
|
|
95
|
-
};
|
|
96
|
-
} | {
|
|
97
|
-
type: "DELETE_MATRIX_GENERATION_EXCLUSION_ZONE";
|
|
98
|
-
payload: {
|
|
99
|
-
zone: {
|
|
100
|
-
id: string;
|
|
101
|
-
from: number;
|
|
102
|
-
to: number;
|
|
103
|
-
};
|
|
104
|
-
nucleus: string;
|
|
105
|
-
};
|
|
106
|
-
} | {
|
|
107
|
-
type: "SET_VERTICAL_SPLITTER_POSITION";
|
|
108
|
-
payload: {
|
|
109
|
-
value: import("react-science/ui").SplitPaneSize;
|
|
110
|
-
};
|
|
111
|
-
}) | undefined) => void;
|
|
112
|
-
workspace: {
|
|
113
|
-
current: import("../main/types").NMRiumWorkspace;
|
|
114
|
-
base: import("../main/types").NMRiumWorkspace | null;
|
|
115
|
-
};
|
|
116
|
-
};
|
|
9
|
+
export declare function usePreferences(): PreferencesContextData;
|
|
117
10
|
export declare function useWorkspacesList(): any[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TopicMolecule } from 'openchemlib-utils';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export declare function useTopicMolecule(): Record<string, TopicMolecule>;
|
|
4
|
+
interface TopicMoleculeProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function TopicMoleculeProvider({ children, }: TopicMoleculeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import OCL from 'openchemlib/full';
|
|
3
|
+
import { TopicMolecule } from 'openchemlib-utils';
|
|
4
|
+
import { createContext, useContext, useEffect, useRef } from 'react';
|
|
5
|
+
import { useChartData } from './ChartContext';
|
|
6
|
+
const TopicMoleculeContext = createContext({});
|
|
7
|
+
export function useTopicMolecule() {
|
|
8
|
+
const context = useContext(TopicMoleculeContext);
|
|
9
|
+
if (!context) {
|
|
10
|
+
throw new Error('Topic Molecule context was not found');
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
}
|
|
14
|
+
export function TopicMoleculeProvider({ children, }) {
|
|
15
|
+
const moleculesRef = useRef({});
|
|
16
|
+
const { molecules } = useChartData();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
for (const { id, molfile } of molecules) {
|
|
19
|
+
const topicMolecule = moleculesRef.current?.[id];
|
|
20
|
+
const molecule = OCL.Molecule.fromMolfile(molfile);
|
|
21
|
+
if (topicMolecule) {
|
|
22
|
+
moleculesRef.current[id] = topicMolecule.fromMolecule(molecule);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
moleculesRef.current[id] = new TopicMolecule(molecule);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, [molecules]);
|
|
29
|
+
return (_jsx(TopicMoleculeContext.Provider, { value: moleculesRef.current, children: children }));
|
|
30
|
+
}
|
|
@@ -41,8 +41,10 @@ const Input = forwardRef((props, ref) => {
|
|
|
41
41
|
const value = debounceTime ? internalValue : externalValue;
|
|
42
42
|
const localRef = useRef();
|
|
43
43
|
const combinedRef = useCombinedRefs([ref, localRef]);
|
|
44
|
+
const [isDebounced, setDebouncedStatus] = useState(false);
|
|
44
45
|
const debounceOnChange = useMemo(() => debounce((e) => {
|
|
45
46
|
onChange?.(e);
|
|
47
|
+
setDebouncedStatus(true);
|
|
46
48
|
}, debounceTime), [debounceTime, onChange]);
|
|
47
49
|
useEffect(() => {
|
|
48
50
|
if (autoSelect) {
|
|
@@ -58,6 +60,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
58
60
|
e.stopPropagation();
|
|
59
61
|
e.preventDefault();
|
|
60
62
|
const val = e.target.value;
|
|
63
|
+
setDebouncedStatus(false);
|
|
61
64
|
if (checkValue(val)) {
|
|
62
65
|
if (debounceTime) {
|
|
63
66
|
setInternalValue(val);
|
|
@@ -76,7 +79,7 @@ const Input = forwardRef((props, ref) => {
|
|
|
76
79
|
...((renderIcon || canClear) && { padding: '0 5px' }),
|
|
77
80
|
...styles.inputWrapper,
|
|
78
81
|
...style?.inputWrapper,
|
|
79
|
-
}, className: `input ${className || ''}`, children: [renderIcon?.(), _jsx("input", { ...otherProps, ref: combinedRef, name: name, style: {
|
|
82
|
+
}, className: `input ${className || ''} `, children: [renderIcon?.(), _jsx("input", { ...otherProps, className: isDebounced ? 'debounce-end' : '', ref: combinedRef, name: name, style: {
|
|
80
83
|
...styles.input,
|
|
81
84
|
...style?.input,
|
|
82
85
|
}, type: type, value: mapValue(value), onChange: onChangeHandler, list: `${name || ''}-data-list` }), canClear && value && (_jsx("button", { type: "button", style: styles.clearButton, onClick: clearHandler, children: _jsx("span", { style: { display: 'block', margin: '0 auto' }, children: "\u2715" }) })), _jsx("datalist", { id: `${name || ''}-data-list`, children: datalist.map((value) => (_jsx("option", { value: value }, value))) })] }));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { useScaleX } from '../1d/utilities/scale';
|
|
4
4
|
import { useGlobal } from '../context/GlobalContext';
|
|
5
5
|
import SVGResizer from './resizer/SVGResizer';
|
|
@@ -10,10 +10,27 @@ export function ResizerWithScale(props) {
|
|
|
10
10
|
const x2 = scaleX()(from);
|
|
11
11
|
const x1 = scaleX()(to);
|
|
12
12
|
const [position, setPosition] = useState({ x1, x2 });
|
|
13
|
+
const startPositionRef = useRef();
|
|
13
14
|
useEffect(() => {
|
|
14
15
|
const x2 = scaleX()(from);
|
|
15
16
|
const x1 = scaleX()(to);
|
|
16
17
|
setPosition({ x1, x2 });
|
|
17
18
|
}, [from, scaleX, to]);
|
|
18
|
-
|
|
19
|
+
function handleMove(p) {
|
|
20
|
+
if (p.x2 >= p.x1) {
|
|
21
|
+
setPosition(p);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function handleEndMove(p) {
|
|
25
|
+
if (p.x2 >= p.x1) {
|
|
26
|
+
onEnd?.(p);
|
|
27
|
+
}
|
|
28
|
+
else if (startPositionRef.current) {
|
|
29
|
+
setPosition({ ...startPositionRef.current });
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function handleStartResize(p) {
|
|
33
|
+
startPositionRef.current = p;
|
|
34
|
+
}
|
|
35
|
+
return (_jsx(SVGResizer, { position: position, onStart: handleStartResize, onEnd: handleEndMove, parentElement: viewerRef, disabled: disabled, onMove: handleMove, children: children }));
|
|
19
36
|
}
|
|
@@ -10,11 +10,11 @@ export function SVGGroup(props) {
|
|
|
10
10
|
if (element) {
|
|
11
11
|
const boundary = element.getBoundingClientRect();
|
|
12
12
|
if (direction === 'row') {
|
|
13
|
-
element.
|
|
13
|
+
element.setAttribute('transform', `translate(${shift} 0)`);
|
|
14
14
|
shift += boundary.width + space;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
element.
|
|
17
|
+
element.setAttribute('transform', `translate(0 ${shift})`);
|
|
18
18
|
shift += boundary.height + space;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useFormikContext } from 'formik';
|
|
3
3
|
import lodashGet from 'lodash/get';
|
|
4
|
-
import { useCallback, useEffect
|
|
4
|
+
import { useCallback, useEffect } from 'react';
|
|
5
5
|
function FormikTextarea(props) {
|
|
6
6
|
const { name, style = {}, onChange = () => null, className = '', value, placeholder = '', ...resProps } = props;
|
|
7
7
|
const { values, handleChange, setFieldValue, errors } = useFormikContext();
|
|
@@ -14,16 +14,15 @@ function FormikTextarea(props) {
|
|
|
14
14
|
void setFieldValue(name, value);
|
|
15
15
|
}
|
|
16
16
|
}, [name, setFieldValue, value]);
|
|
17
|
-
const isInvalid =
|
|
18
|
-
return lodashGet(errors, name);
|
|
19
|
-
}, [errors, name]);
|
|
17
|
+
const isInvalid = lodashGet(errors, name);
|
|
20
18
|
return (_jsx("textarea", { name, className, placeholder, value: value || lodashGet(values, name), onChange: changeHandler, style: {
|
|
21
19
|
...style,
|
|
22
|
-
...(isInvalid
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
...(isInvalid
|
|
21
|
+
? {
|
|
22
|
+
borderColor: 'red',
|
|
23
|
+
borderWidth: '1px',
|
|
24
|
+
}
|
|
25
|
+
: {}),
|
|
27
26
|
}, ...resProps }));
|
|
28
27
|
}
|
|
29
28
|
export default FormikTextarea;
|
|
@@ -5,7 +5,7 @@ const VerticalAxis = forwardRef((props, ref) => {
|
|
|
5
5
|
const { x, y, height, width, showGrid, ticks } = props;
|
|
6
6
|
return (_jsxs("g", { ref: ref, transform: `translate(${x}, ${y})`, children: [_jsx("line", { y2: height, x1: 15, x2: 15, stroke: "black" }), ticks.map(({ label, position }, index) => (
|
|
7
7
|
// eslint-disable-next-line react/no-array-index-key
|
|
8
|
-
_jsxs("g", { children: [showGrid && width && (_jsx("line", { y1: position, y2: position, x1: 15, x2: width - x, stroke: "lightgray" })), _jsx("line", { y1: position, y2: position, x1: 15, x2: 10, stroke: "black" }), _jsx("text", { y: position, dominantBaseline: "middle", textAnchor: "end", children: label })] }, index + label + position)))] }));
|
|
8
|
+
_jsxs("g", { children: [showGrid && width && (_jsx("line", { y1: position, y2: position, x1: 15, x2: width - x, stroke: "lightgray" })), _jsx("line", { y1: position, y2: position, x1: 15, x2: 10, stroke: "black" }), _jsx("text", { y: position, dominantBaseline: "middle", textAnchor: "end", fill: "black", children: label })] }, index + label + position)))] }));
|
|
9
9
|
});
|
|
10
10
|
export function LinearVerticalAxis(props) {
|
|
11
11
|
const { scale, ...other } = props;
|
|
@@ -35,5 +35,5 @@ export default function SVGResizer(props) {
|
|
|
35
35
|
return (_jsxs("g", { transform: `translate(${position.x1} 0)`, children: [typeof children === 'function' ? children(position, isActive) : children, !disabled && (_jsxs(_Fragment, { children: [' ', _jsx(SVGResizerHandle, { onPointerDown: left.onPointerDown, position: 0 }), _jsx(SVGResizerHandle, { onPointerDown: right.onPointerDown, position: Math.ceil(position.x2 - position.x1) })] }))] }));
|
|
36
36
|
}
|
|
37
37
|
function SVGResizerHandle(props) {
|
|
38
|
-
return (_jsxs("g", { onPointerDown: props.onPointerDown, css: styles.container,
|
|
38
|
+
return (_jsxs("g", { onPointerDown: props.onPointerDown, css: styles.container, transform: `translate(${props.position})`, "data-no-export": "true", children: [_jsx("rect", { x: "-5px", style: style.innerContainer }), _jsx("rect", { x: "-2.5px", style: style.anchor })] }));
|
|
39
39
|
}
|
|
@@ -24,6 +24,7 @@ const inputStyle = {
|
|
|
24
24
|
inputWrapper: { height: '100%' },
|
|
25
25
|
};
|
|
26
26
|
const formData = (algorithm, filterValues) => {
|
|
27
|
+
const { zones, algorithm: baseAlgorithm, ...other } = filterValues;
|
|
27
28
|
switch (algorithm) {
|
|
28
29
|
case 'airpls': {
|
|
29
30
|
const validation = Yup.object().shape({
|
|
@@ -37,7 +38,7 @@ const formData = (algorithm, filterValues) => {
|
|
|
37
38
|
livePreview: true,
|
|
38
39
|
maxIterations: 100,
|
|
39
40
|
tolerance: 0.001,
|
|
40
|
-
...(
|
|
41
|
+
...(baseAlgorithm === 'airpls' ? other : {}),
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -52,7 +53,7 @@ const formData = (algorithm, filterValues) => {
|
|
|
52
53
|
algorithm,
|
|
53
54
|
livePreview: true,
|
|
54
55
|
degree: 3,
|
|
55
|
-
...(
|
|
56
|
+
...(baseAlgorithm === 'polynomial' ? other : {}),
|
|
56
57
|
},
|
|
57
58
|
};
|
|
58
59
|
}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
|
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useMemo, useCallback, memo } from 'react';
|
|
5
|
-
import { FaRegWindowMaximize, FaQuestionCircle, FaRegSave, } from 'react-icons/fa';
|
|
5
|
+
import { FaRegWindowMaximize, FaQuestionCircle, FaRegSave, FaFilm, } from 'react-icons/fa';
|
|
6
6
|
import { Toolbar } from 'react-science/ui';
|
|
7
7
|
import { docsBaseUrl } from '../../constants';
|
|
8
8
|
import { useChartData } from '../context/ChartContext';
|
|
@@ -104,7 +104,7 @@ function HeaderInner(props) {
|
|
|
104
104
|
alignItems: 'center',
|
|
105
105
|
}, children: [_jsx("div", { children: _jsx(Toolbar, { children: _jsx(AboutUsModal, {}) }) }), _jsx("div", { className: "toolOptionsPanel", style: { flex: 1 }, children: selectedPanel })] }), _jsxs(HeaderContainer, { style: {
|
|
106
106
|
alignItems: 'center',
|
|
107
|
-
}, children: [!hideWorkspaces && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), !hideGeneralSettings && _jsx(SaveButton, {}), !general?.hideLogs && _jsx(LogsHistoryModal, {}), _jsx("div", { children: _jsxs(Toolbar, { children: [!general?.hideHelp && (_jsx(Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), icon: _jsx(FaQuestionCircle, {}) })), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !isFullscreenEnabled && !general?.hideMaximize && (_jsx(Toolbar.Item, { id: "full-screen", onClick: onEnableFullscreen, title: "Full Screen", className: "windowButton", icon: _jsx(FaRegWindowMaximize, {}) }))] }) })] })] }) }));
|
|
107
|
+
}, children: [!hideWorkspaces && (_jsx(DropDownButton, { data: workspacesList, selectedKey: workspace.current, onSelect: changeWorkspaceHandler, renderItem: renderItem })), !hideGeneralSettings && _jsx(SaveButton, {}), !general?.hideLogs && _jsx(LogsHistoryModal, {}), _jsx("div", { children: _jsxs(Toolbar, { children: [!general?.hideHelp && (_jsx(Toolbar.Item, { id: "user-manual", title: "User manual", onClick: () => window.open(docsBaseUrl, '_blank'), icon: _jsx(FaQuestionCircle, {}) })), _jsx(Toolbar.Item, { id: "user-manual", title: "NMRium channel", onClick: () => window.open('https://www.youtube.com/@nmrium', '_blank'), icon: _jsx(FaFilm, {}) }), !hideGeneralSettings && (_jsx(GeneralSettingsModal, { height: height / 2 })), !isFullscreenEnabled && !general?.hideMaximize && (_jsx(Toolbar.Item, { id: "full-screen", onClick: onEnableFullscreen, title: "Full Screen", className: "windowButton", icon: _jsx(FaRegWindowMaximize, {}) }))] }) })] })] }) }));
|
|
108
108
|
}
|
|
109
109
|
function SaveButton() {
|
|
110
110
|
const { workspace, workspaces, originalWorkspaces } = usePreferences();
|
|
@@ -19,7 +19,7 @@ export function useCheckToolsVisibility() {
|
|
|
19
19
|
(checkSpectrumType && checkSpectrum(spectrum, spectraOptions));
|
|
20
20
|
const isToolActivated = (flag && !isExperimental) ||
|
|
21
21
|
(isExperimental && isExperimentalFeatureActivated);
|
|
22
|
-
return (isToolActivated &&
|
|
22
|
+
return !!(isToolActivated &&
|
|
23
23
|
modeFlag &&
|
|
24
24
|
spectrumCheckFlag &&
|
|
25
25
|
(!extraInfoCheckParameters ||
|
|
@@ -17,8 +17,8 @@ export default function useExport() {
|
|
|
17
17
|
const saveToClipboardHandler = useCallback(async () => {
|
|
18
18
|
if (state.data.length > 0 && rootRef) {
|
|
19
19
|
const hideLoading = await alert.showLoading('Exporting as NMRium process in progress');
|
|
20
|
-
setTimeout(() => {
|
|
21
|
-
copyPNGToClipboard(rootRef, 'nmrSVG');
|
|
20
|
+
setTimeout(async () => {
|
|
21
|
+
await copyPNGToClipboard(rootRef, 'nmrSVG');
|
|
22
22
|
hideLoading();
|
|
23
23
|
alert.success('Image copied to clipboard');
|
|
24
24
|
}, 0);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useDispatch } from '../context/DispatchContext';
|
|
2
|
+
import { getModifiers } from '../context/KeyModifierContext';
|
|
3
|
+
export function useSetActiveSpectrumAction() {
|
|
4
|
+
const dispatch = useDispatch();
|
|
5
|
+
function setActiveSpectrum(e, id) {
|
|
6
|
+
setTimeout(() => {
|
|
7
|
+
const { ctrlKey, shiftKey } = getModifiers(e);
|
|
8
|
+
const modifier = `shift[${shiftKey ? 'true' : 'false'}]_ctrl[${ctrlKey ? 'true' : 'false'}]`;
|
|
9
|
+
dispatch({
|
|
10
|
+
type: 'CHANGE_ACTIVE_SPECTRUM',
|
|
11
|
+
payload: { modifier, id },
|
|
12
|
+
});
|
|
13
|
+
}, 0);
|
|
14
|
+
}
|
|
15
|
+
return { setActiveSpectrum };
|
|
16
|
+
}
|