nmrium 0.48.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/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/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/2d/Chart2D.js +6 -4
- package/lib/component/2d/Viewer2D.js +35 -26
- package/lib/component/context/KeyModifierContext.d.ts +13 -2
- 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/useToolsFunctions.js +4 -2
- package/lib/component/main/InnerNMRium.js +2 -1
- 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/setting/settings-tabs/GeneralTabContent.js +9 -11
- 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 +3 -3
- package/lib/component/panels/SpectrumsPanel/SpectrumListPanel.js +4 -2
- package/lib/component/panels/SpectrumsPanel/base/SpectraColumnsManager.js +19 -16
- package/lib/component/reducer/Reducer.js +2 -0
- package/lib/component/reducer/actions/FiltersActions.d.ts +3 -4
- package/lib/component/reducer/actions/FiltersActions.js +92 -55
- 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 +3 -3
- package/lib/component/reducer/actions/ToolsActions.d.ts +8 -5
- package/lib/component/reducer/actions/ToolsActions.js +51 -44
- package/lib/component/toolbar/BasicToolBar.js +11 -29
- package/lib/component/utility/export.js +3 -0
- 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/versionInfo.js +1 -1
- package/package.json +18 -17
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.d.ts +0 -2
- package/lib/data/data1d/Spectrum1D/generateSpectrumFromPublicationString.js +0 -6
|
@@ -1,11 +1,16 @@
|
|
|
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
|
}
|
|
@@ -14,5 +19,11 @@ export declare function getModifiers(event: KeyboardEvent | MouseEvent): {
|
|
|
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 ||
|
|
@@ -3,6 +3,7 @@ import lodashMap from 'lodash/map';
|
|
|
3
3
|
import { useCallback, useRef, useState } from 'react';
|
|
4
4
|
import { useToggleAccordion } from 'react-science/ui';
|
|
5
5
|
import { useDispatch } from '../context/DispatchContext';
|
|
6
|
+
import { usePreferences } from '../context/PreferencesContext';
|
|
6
7
|
import { useAlert } from '../elements/popup/Alert';
|
|
7
8
|
import { TOOLS_PANELS_ACCORDION } from '../panels/Panels';
|
|
8
9
|
import { options } from '../toolbar/ToolTypes';
|
|
@@ -12,6 +13,7 @@ export default function useToolsFunctions() {
|
|
|
12
13
|
const { open: openPanel } = useToggleAccordion();
|
|
13
14
|
const [isRealSpectrumShown, setIsRealSpectrumShown] = useState(false);
|
|
14
15
|
const debounceClickEventsRef = useRef({ clicks: [] });
|
|
16
|
+
const { current: { general: { invert }, }, } = usePreferences();
|
|
15
17
|
const handleChangeOption = useCallback((selectedTool) => {
|
|
16
18
|
if ([
|
|
17
19
|
options.peakPicking.id,
|
|
@@ -20,7 +22,7 @@ export default function useToolsFunctions() {
|
|
|
20
22
|
options.exclusionZones.id,
|
|
21
23
|
options.rangePicking.id,
|
|
22
24
|
].includes(selectedTool)) {
|
|
23
|
-
alert.show(
|
|
25
|
+
alert.show(`Press ${!invert ? 'Shift +' : ''} Left Mouse button to select zone`);
|
|
24
26
|
}
|
|
25
27
|
if (Object.keys(TOOLS_PANELS_ACCORDION).includes(selectedTool)) {
|
|
26
28
|
openPanel(TOOLS_PANELS_ACCORDION[selectedTool]);
|
|
@@ -29,7 +31,7 @@ export default function useToolsFunctions() {
|
|
|
29
31
|
type: 'SET_SELECTED_TOOL',
|
|
30
32
|
payload: { selectedTool: selectedTool || options.zoom.id },
|
|
31
33
|
});
|
|
32
|
-
}, [alert, dispatch, openPanel]);
|
|
34
|
+
}, [alert, dispatch, invert, openPanel]);
|
|
33
35
|
const handleFullZoomOut = useCallback(() => {
|
|
34
36
|
if (debounceClickEventsRef.current.clicks.length === 0) {
|
|
35
37
|
dispatch({
|
|
@@ -7,6 +7,7 @@ import { GlobalProvider } from '../context/GlobalContext';
|
|
|
7
7
|
import { KeyModifiersProvider } from '../context/KeyModifierContext';
|
|
8
8
|
import { LoggerProvider } from '../context/LoggerContext';
|
|
9
9
|
import { PreferencesProvider } from '../context/PreferencesContext';
|
|
10
|
+
import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
|
|
10
11
|
import { AlertProvider } from '../elements/popup/Alert';
|
|
11
12
|
import { ModalProvider } from '../elements/popup/Modal';
|
|
12
13
|
import { HighlightProvider } from '../highlight';
|
|
@@ -48,5 +49,5 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
|
|
|
48
49
|
rootRef: rootRef.current,
|
|
49
50
|
elementsWrapperRef: elementsWrapperRef.current,
|
|
50
51
|
viewerRef: viewerRef.current,
|
|
51
|
-
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }));
|
|
52
|
+
}, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(TopicMoleculeProvider, { children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
52
53
|
}
|
|
@@ -42,7 +42,7 @@ function ExportAsJcampModal(props) {
|
|
|
42
42
|
const alert = useAlert();
|
|
43
43
|
function submitHandler(options) {
|
|
44
44
|
void (async () => {
|
|
45
|
-
const hideLoading = await alert.showLoading('export as JCAMP in progress');
|
|
45
|
+
const hideLoading = await alert.showLoading('export as JCAMP-DX in progress');
|
|
46
46
|
try {
|
|
47
47
|
exportAsJcamp(spectrum, options);
|
|
48
48
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
interface ImportPublicationStringModalProps {
|
|
2
2
|
onClose: () => void;
|
|
3
|
+
isOpen: boolean;
|
|
3
4
|
}
|
|
4
|
-
declare function ImportPublicationStringModal(
|
|
5
|
+
declare function ImportPublicationStringModal(props: ImportPublicationStringModalProps): import("react/jsx-runtime").JSX.Element | undefined;
|
|
5
6
|
export default ImportPublicationStringModal;
|