nmrium 0.54.0 → 0.56.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 +3 -1
- package/lib/component/1d/Viewer1D.js +36 -11
- 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/matrix/Boxplot.d.ts +6 -0
- package/lib/component/1d/matrix/Boxplot.js +97 -0
- package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
- package/lib/component/1d/matrix/Stocsy.js +101 -0
- package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
- package/lib/component/1d/matrix/useMatrix.js +93 -0
- 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/utilities/scale.d.ts +2 -1
- package/lib/component/1d/utilities/scale.js +6 -1
- 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/PrepareExportContext.d.ts +21 -0
- package/lib/component/context/PrepareExportContext.js +124 -0
- 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/useExport.d.ts +1 -1
- package/lib/component/hooks/useExport.js +4 -4
- 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.d.ts +2 -3
- package/lib/component/hooks/usePanelPreferences.js +4 -3
- package/lib/component/hooks/useSaveSettings.js +7 -14
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
- package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
- 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/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
- package/lib/component/panels/Panels.js +1 -1
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
- 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/databasePanel/DatabaseTable.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.d.ts +6 -0
- package/lib/component/reducer/Reducer.js +6 -0
- package/lib/component/reducer/actions/DomainActions.d.ts +12 -4
- package/lib/component/reducer/actions/DomainActions.js +35 -5
- package/lib/component/reducer/actions/FiltersActions.js +2 -2
- package/lib/component/reducer/actions/LoadActions.js +5 -2
- package/lib/component/reducer/actions/RangesActions.js +12 -6
- package/lib/component/reducer/actions/SpectraActions.d.ts +1 -0
- package/lib/component/reducer/actions/SpectraActions.js +7 -2
- 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.d.ts +47 -2
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +63 -26
- 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/panelsPreferencesDefaultValues.d.ts +5 -2
- package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +17 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +9 -25
- package/lib/component/reducer/preferences/preferencesReducer.js +28 -19
- package/lib/component/toolbar/ToolBar.js +23 -20
- package/lib/component/utility/PathBuilder.d.ts +1 -0
- package/lib/component/utility/PathBuilder.js +8 -1
- 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/data/types/common/DeepPartial.d.ts +3 -0
- package/lib/data/types/common/DeepPartial.js +1 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +39 -39
- package/lib/component/elements/CustomToolTip.d.ts +0 -8
- package/lib/component/elements/CustomToolTip.js +0 -107
- 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
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';
|
|
3
|
+
const PrepareExportContext = createContext(null);
|
|
4
|
+
export function usePrepareExport() {
|
|
5
|
+
const context = useContext(PrepareExportContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('Export prepare context was not found');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
11
|
+
export function useRegisterExportComponents(componentId) {
|
|
12
|
+
const { registerComponent, unRegisterComponent } = usePrepareExport();
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
registerComponent(componentId);
|
|
15
|
+
return () => {
|
|
16
|
+
unRegisterComponent(componentId);
|
|
17
|
+
};
|
|
18
|
+
}, [componentId, registerComponent, unRegisterComponent]);
|
|
19
|
+
}
|
|
20
|
+
export function useNotifyComponentLoaded(componentId) {
|
|
21
|
+
const { notifyComponentLoaded } = usePrepareExport();
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
notifyComponentLoaded(componentId);
|
|
24
|
+
}, [componentId, notifyComponentLoaded]);
|
|
25
|
+
}
|
|
26
|
+
export function PrepareExportProvider(props) {
|
|
27
|
+
const { children, timeout = 10000 } = props;
|
|
28
|
+
const [isExporting, setIsExporting] = useState(false);
|
|
29
|
+
const componentRefs = useRef(new Map());
|
|
30
|
+
const registerComponent = useCallback((componentId) => {
|
|
31
|
+
componentRefs.current.set(componentId, false);
|
|
32
|
+
}, []);
|
|
33
|
+
const unRegisterComponent = useCallback((componentId) => {
|
|
34
|
+
componentRefs.current.delete(componentId);
|
|
35
|
+
}, []);
|
|
36
|
+
const notifyComponentLoaded = useCallback((componentId) => {
|
|
37
|
+
componentRefs.current.set(componentId, true);
|
|
38
|
+
}, []);
|
|
39
|
+
const prepareExportStart = useCallback(() => {
|
|
40
|
+
setIsExporting(true);
|
|
41
|
+
}, []);
|
|
42
|
+
const prepareExportEnd = useCallback(() => {
|
|
43
|
+
for (const key of componentRefs.current.keys()) {
|
|
44
|
+
componentRefs.current.set(key, false);
|
|
45
|
+
}
|
|
46
|
+
setIsExporting(false);
|
|
47
|
+
}, []);
|
|
48
|
+
const waitForAllComponentsRendered = useCallback(() => {
|
|
49
|
+
return new Promise((resolve, reject) => {
|
|
50
|
+
const loadPromise = checkComponents(componentRefs.current);
|
|
51
|
+
const timeoutPromise = createTimeoutPromise(timeout);
|
|
52
|
+
Promise.race([loadPromise, timeoutPromise])
|
|
53
|
+
.then(resolve)
|
|
54
|
+
.catch((error) => {
|
|
55
|
+
if (error instanceof Error) {
|
|
56
|
+
reject(error);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
reject(new Error('Unknown error occurred'));
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}, [timeout]);
|
|
64
|
+
const state = useMemo(() => {
|
|
65
|
+
return {
|
|
66
|
+
prepareExportStart,
|
|
67
|
+
prepareExportEnd,
|
|
68
|
+
registerComponent,
|
|
69
|
+
notifyComponentLoaded,
|
|
70
|
+
waitForAllComponentsRendered,
|
|
71
|
+
unRegisterComponent,
|
|
72
|
+
isExporting,
|
|
73
|
+
};
|
|
74
|
+
}, [
|
|
75
|
+
prepareExportStart,
|
|
76
|
+
prepareExportEnd,
|
|
77
|
+
registerComponent,
|
|
78
|
+
notifyComponentLoaded,
|
|
79
|
+
waitForAllComponentsRendered,
|
|
80
|
+
unRegisterComponent,
|
|
81
|
+
isExporting,
|
|
82
|
+
]);
|
|
83
|
+
return (_jsx(PrepareExportContext.Provider, { value: state, children: children }));
|
|
84
|
+
}
|
|
85
|
+
const interval = 100;
|
|
86
|
+
function checkComponents(componentsStatus) {
|
|
87
|
+
if (componentsStatus.size === 0)
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
const checkInterval = setInterval(() => {
|
|
91
|
+
const allLoaded = Array.from(componentsStatus.values()).every(Boolean);
|
|
92
|
+
if (allLoaded) {
|
|
93
|
+
clearInterval(checkInterval);
|
|
94
|
+
resolve();
|
|
95
|
+
}
|
|
96
|
+
}, interval);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function createTimeoutPromise(timeout) {
|
|
100
|
+
return new Promise((_, reject) => {
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
reject(new Error('Load svg component timeout'));
|
|
103
|
+
}, timeout);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function withExportRegister(Component, componentId) {
|
|
107
|
+
return (props) => {
|
|
108
|
+
const { isExporting } = usePrepareExport();
|
|
109
|
+
useRegisterExportComponents(componentId);
|
|
110
|
+
if (isExporting)
|
|
111
|
+
return null;
|
|
112
|
+
return _jsx(Component, { ...props });
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function withExport(Component, componentId) {
|
|
116
|
+
return (props) => {
|
|
117
|
+
const { isExporting } = usePrepareExport();
|
|
118
|
+
useNotifyComponentLoaded(componentId);
|
|
119
|
+
if (!isExporting) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
return _jsx(Component, { ...props });
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ShareDataState<T> {
|
|
3
|
+
data: T | null;
|
|
4
|
+
setData: (data: T) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function useShareData<T>(): ShareDataState<T>;
|
|
7
|
+
export declare function ShareDataProvider<T>({ children, }: {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo, useState } from 'react';
|
|
3
|
+
const ShareDataContext = createContext(null);
|
|
4
|
+
export function useShareData() {
|
|
5
|
+
const context = useContext(ShareDataContext);
|
|
6
|
+
if (!context) {
|
|
7
|
+
throw new Error('useShareData must be used within an ShareDataProvider');
|
|
8
|
+
}
|
|
9
|
+
return context;
|
|
10
|
+
}
|
|
11
|
+
export function ShareDataProvider({ children, }) {
|
|
12
|
+
const [data, setData] = useState(null);
|
|
13
|
+
const state = useMemo(() => {
|
|
14
|
+
return {
|
|
15
|
+
data,
|
|
16
|
+
setData: (newData) => {
|
|
17
|
+
setData(newData);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
}, [data]);
|
|
21
|
+
return (_jsx(ShareDataContext.Provider, { value: state, children: children }));
|
|
22
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { PopoverProps } from '@blueprintjs/core';
|
|
3
|
+
import { ButtonProps } from 'react-science/ui';
|
|
4
|
+
export interface ActionsButtonsPopoverProps extends Omit<PopoverProps, 'interactionKind' | 'content'> {
|
|
5
|
+
buttons: Array<Pick<ButtonProps, 'icon' | 'onClick' | 'intent' | 'disabled'> & {
|
|
6
|
+
title?: string;
|
|
7
|
+
visible?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
export declare function ActionsButtonsPopover(props: ActionsButtonsPopoverProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Popover } from '@blueprintjs/core';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { Button } from 'react-science/ui';
|
|
6
|
+
export function ActionsButtonsPopover(props) {
|
|
7
|
+
const { buttons, children, ...otherProps } = props;
|
|
8
|
+
return (_jsx(Popover, { minimal: true, position: "auto-start", popoverClassName: "actions-buttons-popover", interactionKind: "hover", enforceFocus: false, content: _jsx("div", { style: { display: 'flex', flexDirection: 'column' }, css: css `
|
|
9
|
+
button,
|
|
10
|
+
a[role='button'] {
|
|
11
|
+
border-radius: 50%;
|
|
12
|
+
min-width: 16px;
|
|
13
|
+
min-height: 16px;
|
|
14
|
+
font-size: 10px;
|
|
15
|
+
padding: 5px;
|
|
16
|
+
}
|
|
17
|
+
`, children: buttons
|
|
18
|
+
.filter((button) => button?.visible !== false)
|
|
19
|
+
.map(({ icon, onClick, intent, title, disabled }, index) => {
|
|
20
|
+
return (_jsx(Button, { disabled: disabled, icon: icon, onClick: onClick, tooltipProps: { content: title || '', compact: true }, intent: intent }, title || index));
|
|
21
|
+
}) }), ...otherProps, children: children }));
|
|
22
|
+
}
|
|
@@ -51,17 +51,19 @@ function ReactTableRow(props) {
|
|
|
51
51
|
const clickHandler = useCallback((event) => {
|
|
52
52
|
onClick?.(event, row);
|
|
53
53
|
}, [onClick, row]);
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
const { key: rowKey, ...otherKeyProps } = row.getRowProps();
|
|
55
|
+
return (_jsx(ContextMenu, { options: contextMenu, onSelect: (selected) => onContextMenuSelect?.(selected, row.original), as: "tr", style: { position: 'static' }, css: getRowStyle(highlight.isActive || isRowActive, rowStyle, disableDefaultRowStyle), ...otherKeyProps, ...highlight.onHover, children: row.cells.map((cell) => {
|
|
56
|
+
const { style, padding } = cell;
|
|
56
57
|
if (cell.isRowSpanned) {
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
59
60
|
else {
|
|
60
|
-
|
|
61
|
+
const { key: columnKey, ...otherColumnProps } = cell.getCellProps();
|
|
62
|
+
return (_jsx("td", { rowSpan: cell.rowSpan, ...otherColumnProps, onContextMenu: (e) => {
|
|
61
63
|
e.preventDefault();
|
|
62
64
|
return false;
|
|
63
|
-
}, style: { padding, ...style }, onClick: clickHandler, children: cell.render('Cell') },
|
|
65
|
+
}, style: { padding, ...style }, onClick: clickHandler, children: cell.render('Cell') }, columnKey));
|
|
64
66
|
}
|
|
65
|
-
}) },
|
|
67
|
+
}) }, rowKey));
|
|
66
68
|
}
|
|
67
69
|
export default ReactTableRow;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
2
|
import { CSSObject, SerializedStyles } from '@emotion/react';
|
|
3
|
-
import { CSSProperties } from 'react';
|
|
3
|
+
import { CSSProperties, ReactElement } from 'react';
|
|
4
4
|
import { CellProps, Column as ReactColumn, UseSortByColumnOptions } from 'react-table';
|
|
5
5
|
import { HighlightEventSource } from '../../highlight';
|
|
6
6
|
import { BaseContextMenuProps } from '../ContextMenuBluePrint';
|
|
@@ -8,7 +8,7 @@ import { ClickEvent } from './Elements/ReactTableRow';
|
|
|
8
8
|
interface ExtraColumn<T extends object> {
|
|
9
9
|
enableRowSpan?: boolean;
|
|
10
10
|
style?: CSSProperties;
|
|
11
|
-
Cell?: (cell: CellProps<T>) =>
|
|
11
|
+
Cell?: (cell: CellProps<T>) => ReactElement | string;
|
|
12
12
|
}
|
|
13
13
|
export type Column<T extends object> = ReactColumn<T> & ExtraColumn<T> & UseSortByColumnOptions<T>;
|
|
14
14
|
interface SortEvent {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { IconName, TooltipProps } from '@blueprintjs/core';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
interface IconButtonProps extends React.SVGAttributes<SVGElement> {
|
|
4
|
+
size?: number;
|
|
5
|
+
padding?: number;
|
|
6
|
+
icon?: IconName;
|
|
7
|
+
backgroundColor?: CSSProperties['backgroundColor'];
|
|
8
|
+
color?: CSSProperties['color'];
|
|
9
|
+
title?: string;
|
|
10
|
+
tooltipProps?: TooltipProps;
|
|
11
|
+
renderIcon?: (props: Pick<IconButtonProps, 'color' | 'size'>) => ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function SVGButton(props: IconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon, Tooltip } from '@blueprintjs/core';
|
|
3
|
+
export function SVGButton(props) {
|
|
4
|
+
const { size = 16, padding = 5, className, icon, renderIcon, backgroundColor = 'gray', color = 'white', title, tooltipProps, ...otherProps } = props;
|
|
5
|
+
return (_jsx(Tooltip, { content: title, compact: true, targetTagName: "g", placement: "auto-end", ...tooltipProps, children: _jsxs("svg", { width: size, height: size, viewBox: `0 0 ${size} ${size}`, ...otherProps, children: [_jsx("circle", { cx: size / 2, cy: size / 2, r: size / 2, fill: backgroundColor }), _jsx("g", { transform: `translate(${padding / 2} ${padding / 2})`, children: typeof renderIcon === 'function' ? (renderIcon({ size: size - padding, color })) : (_jsx(Icon, { tagName: "g", icon: icon, size: size - padding, color: color })) })] }) }));
|
|
6
|
+
}
|
|
@@ -5,18 +5,20 @@ export function SVGGroup(props) {
|
|
|
5
5
|
const { children, direction = 'row', space = 0, ...resProps } = props;
|
|
6
6
|
useLayoutEffect(() => {
|
|
7
7
|
let shift = 0;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const elements = elementsRefs.current;
|
|
9
|
+
if (!elements) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
for (const element of elements) {
|
|
13
|
+
if (element) {
|
|
14
|
+
const boundary = element.getBoundingClientRect();
|
|
15
|
+
if (direction === 'row') {
|
|
16
|
+
element.setAttribute('transform', `translate(${shift} 0)`);
|
|
17
|
+
shift += boundary.width + space;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
element.setAttribute('transform', `translate(0 ${shift})`);
|
|
21
|
+
shift += boundary.height + space;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
@@ -27,6 +29,6 @@ export function SVGGroup(props) {
|
|
|
27
29
|
if (ref) {
|
|
28
30
|
elementsRefs.current[index] = ref;
|
|
29
31
|
}
|
|
30
|
-
}, children: child },
|
|
32
|
+
}, children: child }, `${index}`));
|
|
31
33
|
}) }));
|
|
32
34
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SVGAttributes } from 'react';
|
|
2
|
+
interface SVGTextProps extends SVGAttributes<SVGTextElement> {
|
|
3
|
+
rectProps?: SVGAttributes<SVGRectElement>;
|
|
4
|
+
padding?: number;
|
|
5
|
+
borderRadius?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function SVGText(props: SVGTextProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
3
|
+
const defaultTextBBox = {
|
|
4
|
+
width: 0,
|
|
5
|
+
height: 0,
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0,
|
|
8
|
+
};
|
|
9
|
+
export function SVGText(props) {
|
|
10
|
+
const textRef = useRef(null);
|
|
11
|
+
const [boxSize, setBoxSize] = useState(defaultTextBBox);
|
|
12
|
+
const { rectProps = {}, padding = 0, borderRadius = 0, children, ...otherProps } = props;
|
|
13
|
+
const { ...otherRectProps } = rectProps;
|
|
14
|
+
useLayoutEffect(() => {
|
|
15
|
+
const boundary = textRef?.current?.getBBox();
|
|
16
|
+
if (boundary) {
|
|
17
|
+
setBoxSize(boundary);
|
|
18
|
+
}
|
|
19
|
+
}, []);
|
|
20
|
+
const { width: textWidth, height: textHeight, x, y } = boxSize;
|
|
21
|
+
const width = textWidth + padding * 2;
|
|
22
|
+
const height = textHeight + padding * 2;
|
|
23
|
+
return (_jsxs("g", { children: [_jsx("rect", { width: width, height: height, x: x - padding, y: y - padding, fill: "transparent", ...(borderRadius && { rx: borderRadius, ry: borderRadius }), ...otherRectProps }), _jsx("text", { ref: textRef, fill: "black", textAnchor: "middle", ...otherProps, children: children })] }));
|
|
24
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
2
|
import { Position } from './useDraggable';
|
|
3
|
-
type ChildType =
|
|
3
|
+
type ChildType = ReactElement[] | ReactElement | boolean | null;
|
|
4
4
|
type PositionChangeHandler = (data: Position) => void;
|
|
5
5
|
export interface DraggableProps {
|
|
6
6
|
children?: ChildType | ((x1: number, x2: number) => ChildType);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { InputProps } from '../Input';
|
|
2
3
|
export interface InputMapValueFunctions {
|
|
3
4
|
mapOnChangeValue?: (value: string | number) => any;
|
|
@@ -7,5 +8,5 @@ interface FormikInputProps extends InputMapValueFunctions {
|
|
|
7
8
|
name: string;
|
|
8
9
|
checkErrorAfterInputTouched?: boolean;
|
|
9
10
|
}
|
|
10
|
-
declare
|
|
11
|
+
declare const FormikInput: import("react").ForwardRefExoticComponent<FormikInputProps & InputProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
11
12
|
export default FormikInput;
|
|
@@ -1,8 +1,9 @@
|
|
|
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 { forwardRef } from 'react';
|
|
4
5
|
import Input from '../Input';
|
|
5
|
-
function FormikInput(props) {
|
|
6
|
+
const FormikInput = forwardRef(function FormikInput(props, ref) {
|
|
6
7
|
const { name, style = { label: {}, input: {}, inputWrapper: {} }, onChange, type = 'text', className = '', value = null, checkErrorAfterInputTouched = true, mapOnChangeValue, mapValue, ...resProps } = props;
|
|
7
8
|
const { values, handleChange, errors, touched, setFieldValue, handleBlur } = useFormikContext();
|
|
8
9
|
function changeHandler(e) {
|
|
@@ -20,7 +21,7 @@ function FormikInput(props) {
|
|
|
20
21
|
}
|
|
21
22
|
let val = value || lodashGet(values, name);
|
|
22
23
|
val = mapValue ? mapValue(val) : val;
|
|
23
|
-
return (_jsx(Input, { name: name, value: val, onChange: changeHandler, onBlur: handleBlur, type: type, style: {
|
|
24
|
+
return (_jsx(Input, { ref: ref, name: name, value: val, onChange: changeHandler, onBlur: handleBlur, type: type, style: {
|
|
24
25
|
...style,
|
|
25
26
|
inputWrapper: {
|
|
26
27
|
...style.inputWrapper,
|
|
@@ -34,5 +35,5 @@ function FormikInput(props) {
|
|
|
34
35
|
: {}),
|
|
35
36
|
},
|
|
36
37
|
}, className: className, ...resProps }));
|
|
37
|
-
}
|
|
38
|
+
});
|
|
38
39
|
export default FormikInput;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { useMemo,
|
|
4
|
+
import { useMemo, memo } from 'react';
|
|
5
5
|
import { FaRegWindowMaximize, FaQuestionCircle, FaRegSave, FaFilm, } from 'react-icons/fa';
|
|
6
6
|
import { Toolbar, useFullscreen } from 'react-science/ui';
|
|
7
7
|
import { docsBaseUrl } from '../../constants';
|
|
@@ -11,6 +11,7 @@ import Button from '../elements/Button';
|
|
|
11
11
|
import { Header } from '../elements/Header';
|
|
12
12
|
import DropDownButton from '../elements/dropDownButton/DropDownButton';
|
|
13
13
|
import { useSaveSettings } from '../hooks/useSaveSettings';
|
|
14
|
+
import { useWorkspaceAction } from '../hooks/useWorkspaceAction';
|
|
14
15
|
import { LogsHistoryModal } from '../modal/LogsHistoryModal';
|
|
15
16
|
import AboutUsModal from '../modal/aboutUs/AboutUsModal';
|
|
16
17
|
import GeneralSettingsModal from '../modal/setting/GeneralSettings';
|
|
@@ -63,7 +64,8 @@ const styles = css `
|
|
|
63
64
|
`;
|
|
64
65
|
function HeaderInner(props) {
|
|
65
66
|
const { selectedOptionPanel, height } = props;
|
|
66
|
-
const { current: { display: { general }, }, workspace,
|
|
67
|
+
const { current: { display: { general }, }, workspace, } = usePreferences();
|
|
68
|
+
const { setActiveWorkspace } = useWorkspaceAction();
|
|
67
69
|
const fullscreen = useFullscreen();
|
|
68
70
|
const workspacesList = useWorkspacesList();
|
|
69
71
|
const hideGeneralSettings = !!(general?.hideGeneralSettings && workspace.base);
|
|
@@ -90,14 +92,9 @@ function HeaderInner(props) {
|
|
|
90
92
|
return null;
|
|
91
93
|
}
|
|
92
94
|
}, [selectedOptionPanel]);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
payload: {
|
|
97
|
-
workspace: option.key,
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
}, [dispatch]);
|
|
95
|
+
function changeWorkspaceHandler(option) {
|
|
96
|
+
setActiveWorkspace(option.key);
|
|
97
|
+
}
|
|
101
98
|
function renderItem(item) {
|
|
102
99
|
return _jsx(WorkspaceItem, { item: item });
|
|
103
100
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MIN_AREA_POINTS
|
|
1
|
+
export declare const MIN_AREA_POINTS = 5;
|
|
2
2
|
export declare function useCheckPointsNumberInWindowArea(): number;
|
|
@@ -8,7 +8,7 @@ interface SaveOptions {
|
|
|
8
8
|
export default function useExport(): {
|
|
9
9
|
saveToClipboardHandler: () => Promise<void>;
|
|
10
10
|
saveAsJSONHandler: (spaceIndent?: number, isCompressed?: boolean) => void;
|
|
11
|
-
saveAsSVGHandler: () =>
|
|
11
|
+
saveAsSVGHandler: () => void;
|
|
12
12
|
saveAsPNGHandler: () => Promise<void>;
|
|
13
13
|
saveHandler: (options: SaveOptions) => void;
|
|
14
14
|
};
|
|
@@ -17,11 +17,11 @@ export default function useExport() {
|
|
|
17
17
|
});
|
|
18
18
|
setTimeout(async () => {
|
|
19
19
|
await copyPNGToClipboard(rootRef, 'nmrSVG');
|
|
20
|
-
hideLoading();
|
|
21
20
|
toaster.show({
|
|
22
21
|
message: 'Image copied to clipboard',
|
|
23
22
|
intent: 'success',
|
|
24
23
|
});
|
|
24
|
+
hideLoading();
|
|
25
25
|
}, 0);
|
|
26
26
|
}
|
|
27
27
|
}, [state.data.length, rootRef, toaster]);
|
|
@@ -44,12 +44,12 @@ export default function useExport() {
|
|
|
44
44
|
reportError(error);
|
|
45
45
|
}
|
|
46
46
|
}, [preferencesState, state, toaster]);
|
|
47
|
-
const saveAsSVGHandler = useCallback(
|
|
47
|
+
const saveAsSVGHandler = useCallback(() => {
|
|
48
48
|
if (state.data.length > 0 && rootRef) {
|
|
49
49
|
const hideLoading = toaster.showLoading({
|
|
50
50
|
message: 'Exporting as SVG process in progress',
|
|
51
51
|
});
|
|
52
|
-
setTimeout(() => {
|
|
52
|
+
void setTimeout(async () => {
|
|
53
53
|
const fileName = state.data[0]?.info?.name;
|
|
54
54
|
exportAsSVG(rootRef, 'nmrSVG', fileName);
|
|
55
55
|
hideLoading();
|
|
@@ -61,7 +61,7 @@ export default function useExport() {
|
|
|
61
61
|
const hideLoading = toaster.showLoading({
|
|
62
62
|
message: 'Exporting as PNG process in progress',
|
|
63
63
|
});
|
|
64
|
-
setTimeout(() => {
|
|
64
|
+
void setTimeout(async () => {
|
|
65
65
|
const fileName = state.data[0]?.info?.name;
|
|
66
66
|
exportAsPng(rootRef, 'nmrSVG', fileName);
|
|
67
67
|
hideLoading();
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type ReturnFunction = (value?: number | string, formatKey?: string, prefix?: string, suffix?: string) => string;
|
|
1
|
+
export type ReturnFunction = (value?: number | string, formatKey?: 'ppmFormat' | 'hzFormat' | (string & {}), prefix?: string, suffix?: string) => string;
|
|
2
2
|
export declare function useFormatNumberByNucleus(nucleus?: string[]): ReturnFunction[];
|
|
3
3
|
export declare function useFormatNumberByNucleus(nucleus?: string): ReturnFunction;
|
|
@@ -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]));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { MultipleSpectraAnalysisPreferences, PanelsPreferences, WorkSpacePanelPreferences } from 'nmr-load-save';
|
|
2
|
-
import { MatrixOptions } from '../../data/types/data1d/MatrixOptions';
|
|
1
|
+
import { MatrixGenerationOptions, MultipleSpectraAnalysisPreferences, PanelsPreferences, WorkSpacePanelPreferences } from 'nmr-load-save';
|
|
3
2
|
type Panel = 'spectra' | 'peaks' | 'integrals' | 'zones' | 'ranges' | 'database' | 'multipleSpectraAnalysis' | 'matrixGeneration' | 'prediction';
|
|
4
|
-
export declare function usePanelPreferences<T extends Panel>(panelKey: T, nucleus: string): T extends 'matrixGeneration' ?
|
|
3
|
+
export declare function usePanelPreferences<T extends Panel>(panelKey: T, nucleus: string): T extends 'matrixGeneration' ? MatrixGenerationOptions : T extends 'multipleSpectraAnalysis' ? MultipleSpectraAnalysisPreferences : WorkSpacePanelPreferences[T];
|
|
5
4
|
export declare function usePanelPreferences<T extends 'database' | 'prediction'>(panelKey: T): WorkSpacePanelPreferences[T];
|
|
6
5
|
export type UsePanelPreferencesByNucleiResult<T extends Panel> = T extends 'spectra' ? PanelsPreferences['spectra'] : T extends 'peaks' ? PanelsPreferences['peaks'] : T extends 'integrals' ? PanelsPreferences['integrals'] : T extends 'zones' ? PanelsPreferences['zones'] : T extends 'ranges' ? PanelsPreferences['ranges'] : T extends 'multipleSpectraAnalysis' ? PanelsPreferences['multipleSpectraAnalysis'] : T extends 'matrixGeneration' ? PanelsPreferences['matrixGeneration'] : void;
|
|
7
6
|
export declare function usePanelPreferencesByNuclei<T extends Panel>(panelKey: T, nuclei: string[]): UsePanelPreferencesByNucleiResult<T>;
|
|
@@ -2,9 +2,8 @@ import has from 'lodash/has';
|
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { getDefaultPredictionOptions } from '../../data/PredictionManager';
|
|
4
4
|
import { usePreferences } from '../context/PreferencesContext';
|
|
5
|
-
import { getIntegralDefaultValues, getPeaksDefaultValues, getZoneDefaultValues, getRangeDefaultValues, databaseDefaultValues, getMultipleSpectraAnalysisDefaultValues, getSpectraDefaultValues, } from '../reducer/preferences/panelsPreferencesDefaultValues';
|
|
5
|
+
import { getIntegralDefaultValues, getPeaksDefaultValues, getZoneDefaultValues, getRangeDefaultValues, databaseDefaultValues, getMultipleSpectraAnalysisDefaultValues, getSpectraDefaultValues, getMatrixGenerationDefaultValues, } 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':
|
|
@@ -23,6 +22,8 @@ function getDefaultPreferences(panelKey, nucleus) {
|
|
|
23
22
|
return getMultipleSpectraAnalysisDefaultValues(nucleus);
|
|
24
23
|
case 'prediction':
|
|
25
24
|
return getDefaultPredictionOptions();
|
|
25
|
+
case 'matrixGeneration':
|
|
26
|
+
return getMatrixGenerationDefaultValues(nucleus);
|
|
26
27
|
default:
|
|
27
28
|
return {};
|
|
28
29
|
}
|
|
@@ -35,7 +36,7 @@ function joinWithNucleusPreferences(data, nucleus, returnOnlyNucleusPreferences
|
|
|
35
36
|
return { ...nuclei[nucleus], ...rest };
|
|
36
37
|
}
|
|
37
38
|
function getPanelPreferences(preferences, panelKey, nucleus, returnOnlyNucleusPreferences = false) {
|
|
38
|
-
const panelPath =
|
|
39
|
+
const panelPath = `panels.${panelKey}`;
|
|
39
40
|
let path = panelPath;
|
|
40
41
|
if (nucleus) {
|
|
41
42
|
switch (panelKey) {
|