nmrium 0.58.0 → 0.60.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/LinesSeries.js +17 -5
- package/lib/component/1d/Viewer1D.js +10 -4
- package/lib/component/1d/integral/IntegralResizable.js +2 -2
- package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
- package/lib/component/1d/ranges/Atoms.js +6 -4
- package/lib/component/1d/ranges/Range.js +4 -2
- package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
- package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
- package/lib/component/1d-2d/tools/BrushXY.js +0 -1
- package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
- package/lib/component/2d/Viewer2D.js +7 -3
- package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
- package/lib/component/2d/tools/PivotIndicator.js +2 -3
- package/lib/component/2d/zones/Zone.js +2 -2
- package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
- package/lib/component/context/ChartContext.js +12 -1
- package/lib/component/context/ShareDataContext.d.ts +1 -1
- package/lib/component/context/ShareDataContext.js +2 -4
- package/lib/component/context/ToasterContext.d.ts +1 -0
- package/lib/component/context/ToasterContext.js +12 -3
- package/lib/component/elements/ActionsButtonsPopover.js +1 -3
- package/lib/component/elements/Alert.d.ts +20 -0
- package/lib/component/elements/Alert.js +80 -0
- package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
- package/lib/component/elements/ContextMenuBluePrint.js +9 -3
- package/lib/component/elements/DialogManager.d.ts +34 -0
- package/lib/component/elements/DialogManager.js +96 -0
- package/lib/component/elements/DraggableDialog.d.ts +13 -0
- package/lib/component/elements/DraggableDialog.js +156 -0
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
- package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
- package/lib/component/elements/Select2.d.ts +12 -7
- package/lib/component/elements/Select2.js +5 -4
- package/lib/component/elements/Select2Controller.d.ts +2 -2
- package/lib/component/elements/Select2Controller.js +5 -5
- package/lib/component/elements/TabTitle.d.ts +9 -0
- package/lib/component/elements/TabTitle.js +18 -0
- package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
- package/lib/component/elements/ToolbarPopoverItem.js +13 -5
- package/lib/component/elements/print/PrintContent.d.ts +17 -0
- package/lib/component/elements/print/PrintContent.js +281 -0
- package/lib/component/elements/print/PrintProvider.d.ts +12 -0
- package/lib/component/elements/print/PrintProvider.js +28 -0
- package/lib/component/elements/print/index.d.ts +2 -0
- package/lib/component/elements/print/index.js +2 -0
- package/lib/component/header/ApodizationOptionsPanel.js +2 -2
- package/lib/component/header/BaseLineCorrectionPanel.js +3 -0
- package/lib/component/hooks/useSaveSettings.d.ts +1 -1
- package/lib/component/hooks/useSaveSettings.js +18 -22
- package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
- package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
- package/lib/component/loader/DropZone.js +3 -67
- package/lib/component/loader/useLoadFiles.d.ts +1 -0
- package/lib/component/loader/useLoadFiles.js +78 -0
- package/lib/component/main/InnerNMRium.d.ts +4 -3
- package/lib/component/main/InnerNMRium.js +5 -10
- package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
- package/lib/component/main/InnerNMRiumContents.js +38 -29
- package/lib/component/main/NMRium.d.ts +2 -5
- package/lib/component/main/NMRium.js +1 -1
- package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
- package/lib/component/main/NMRiumRefAPI.js +12 -0
- package/lib/component/main/NMRiumViewer.d.ts +10 -0
- package/lib/component/main/NMRiumViewer.js +35 -0
- package/lib/component/main/index.d.ts +1 -0
- package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
- package/lib/component/modal/CopyClipboardModal.js +18 -32
- package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
- package/lib/component/modal/EditPeakShapeModal.js +45 -33
- package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
- package/lib/component/modal/ExportAsJcampModal.js +69 -35
- package/lib/component/modal/ImportPublicationStringModal.js +1 -1
- package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
- package/lib/component/modal/editRange/EditRangeModal.js +26 -54
- package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
- package/lib/component/modal/editZone/EditZoneModal.js +74 -91
- package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
- package/lib/component/modal/editZone/SignalsForm.js +33 -50
- package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
- package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
- package/lib/component/modal/setting/GeneralSettings.js +4 -2
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
- package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
- package/lib/component/modal/setting/settingsValidation.js +15 -1
- package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
- package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
- package/lib/component/panels/Panels.js +2 -2
- package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
- package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
- package/lib/component/panels/RangesPanel/RangesHeader.js +52 -15
- package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
- package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
- package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
- package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
- package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +68 -53
- package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +70 -58
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
- package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
- package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +8 -1
- package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
- package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
- package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
- package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
- package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
- package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
- package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
- package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
- package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
- package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
- package/lib/component/reducer/IgnoreActions.js +1 -0
- package/lib/component/reducer/Reducer.js +2 -4
- package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
- package/lib/component/reducer/actions/DatabaseActions.js +52 -34
- package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
- package/lib/component/reducer/actions/FiltersActions.js +9 -4
- package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
- package/lib/component/reducer/actions/RangesActions.js +9 -4
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.js +53 -43
- package/lib/component/reducer/actions/ToolsActions.js +0 -17
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
- package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
- package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
- package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
- package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -2
- package/lib/component/reducer/preferences/preferencesReducer.js +4 -1
- package/lib/component/toolbar/ToolBar.js +33 -14
- package/lib/component/toolbar/ToolTypes.d.ts +1 -1
- package/lib/component/toolbar/ToolTypes.js +0 -14
- package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
- package/lib/data/SpectraManager.d.ts +7 -10
- package/lib/data/SpectraManager.js +51 -30
- package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
- package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
- package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
- package/lib/data/data1d/Spectrum1D/index.js +1 -1
- package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
- package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
- package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -16
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
- package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
- package/lib/data/molecules/MoleculeManager.d.ts +1 -1
- package/lib/data/molecules/MoleculeManager.js +21 -49
- package/lib/data/utilities/getCustomColor.d.ts +1 -1
- package/lib/data/utilities/removeByPaths.d.ts +3 -0
- package/lib/data/utilities/removeByPaths.js +33 -0
- package/lib/versionInfo.js +1 -1
- package/package.json +34 -34
- package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
- package/lib/component/elements/ContextMenu.d.ts +0 -9
- package/lib/component/elements/ContextMenu.js +0 -116
- package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
- package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
- package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
- package/lib/component/elements/popup/Modal/Context.js +0 -6
- package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
- package/lib/component/elements/popup/Modal/Modal.js +0 -42
- package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
- package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
- package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
- package/lib/component/elements/popup/Modal/Provider.js +0 -172
- package/lib/component/elements/popup/Modal/index.d.ts +0 -4
- package/lib/component/elements/popup/Modal/index.js +0 -4
- package/lib/component/elements/popup/Transition.d.ts +0 -14
- package/lib/component/elements/popup/Transition.js +0 -35
- package/lib/component/elements/popup/Wrapper.d.ts +0 -8
- package/lib/component/elements/popup/Wrapper.js +0 -83
- package/lib/component/elements/popup/options.d.ts +0 -28
- package/lib/component/elements/popup/options.js +0 -25
- package/lib/component/elements/popup/utility.d.ts +0 -2
- package/lib/component/elements/popup/utility.js +0 -13
- package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
- package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
- package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
- package/lib/component/modal/editZone/SignalFormTab.js +0 -6
- package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
- package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
- package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Dialog, DialogBody, DialogFooter, Radio, RadioGroup, Tag, } from '@blueprintjs/core';
|
|
4
|
+
import { css } from '@emotion/react';
|
|
5
|
+
import { useCallback, useEffect, useRef, useState, } from 'react';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
7
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
8
|
+
import ActionButtons from '../ActionButtons';
|
|
9
|
+
import Label from '../Label';
|
|
10
|
+
import { NumberInput2Controller } from '../NumberInput2Controller';
|
|
11
|
+
import { Select2Controller } from '../Select2Controller';
|
|
12
|
+
import { PrintProvider } from './PrintProvider';
|
|
13
|
+
const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');
|
|
14
|
+
const pageSizes = [
|
|
15
|
+
{
|
|
16
|
+
name: 'Letter',
|
|
17
|
+
portrait: { width: 21.59, height: 27.94 },
|
|
18
|
+
landscape: { width: 27.94, height: 21.59 },
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'Legal',
|
|
22
|
+
portrait: { width: 21.59, height: 35.56 },
|
|
23
|
+
landscape: { width: 35.56, height: 21.59 },
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'Tabloid',
|
|
27
|
+
portrait: { width: 27.94, height: 43.18 },
|
|
28
|
+
landscape: { width: 43.18, height: 27.94 },
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'Executive',
|
|
32
|
+
portrait: { width: 26.67, height: 18.42 },
|
|
33
|
+
landscape: { width: 18.42, height: 26.67 },
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Statement',
|
|
37
|
+
portrait: { width: 21.59, height: 13.97 },
|
|
38
|
+
landscape: { width: 13.97, height: 21.59 },
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'Folio',
|
|
42
|
+
portrait: { width: 33.02, height: 21.59 },
|
|
43
|
+
landscape: { width: 21.59, height: 33.02 },
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: 'A3',
|
|
47
|
+
portrait: { width: 29.7, height: 42 },
|
|
48
|
+
landscape: { width: 42, height: 29.7 },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'A4',
|
|
52
|
+
portrait: { width: 21, height: 29.7 },
|
|
53
|
+
landscape: { width: 29.7, height: 21 },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'A5',
|
|
57
|
+
portrait: { width: 14.8, height: 21 },
|
|
58
|
+
landscape: { width: 21, height: 14.8 },
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'B4',
|
|
62
|
+
portrait: { width: 25.7, height: 36.4 },
|
|
63
|
+
landscape: { width: 36.4, height: 25.7 },
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'B5',
|
|
67
|
+
portrait: { width: 18.2, height: 25.7 },
|
|
68
|
+
landscape: { width: 25.7, height: 18.2 },
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
function getSizesList(layout) {
|
|
72
|
+
const output = [];
|
|
73
|
+
for (const item of pageSizes) {
|
|
74
|
+
const { name, ...otherKeys } = item;
|
|
75
|
+
const { width, height } = otherKeys[layout];
|
|
76
|
+
output.push({ label: `${name} (${width} cm x ${height} cm)`, value: name });
|
|
77
|
+
}
|
|
78
|
+
return output;
|
|
79
|
+
}
|
|
80
|
+
export function PrintContent(props) {
|
|
81
|
+
const [isPageOptionModalOpened, togglePageOptionDialog] = useState(false);
|
|
82
|
+
const [pageOptions, setPageOptions] = useState();
|
|
83
|
+
const { onBeforePrint, onAfterPrint, children, printPageOptions, defaultPrintPageOptions, onPrint, } = props;
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
function handleKeyDow(event) {
|
|
86
|
+
if ((event.ctrlKey || event.metaKey) && event.key === 'p') {
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
if (!printPageOptions) {
|
|
89
|
+
togglePageOptionDialog(true);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
setPageOptions(printPageOptions);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
window.addEventListener('keydown', handleKeyDow);
|
|
97
|
+
return () => {
|
|
98
|
+
window.removeEventListener('keydown', handleKeyDow);
|
|
99
|
+
};
|
|
100
|
+
}, [printPageOptions]);
|
|
101
|
+
if (!pageOptions) {
|
|
102
|
+
return (_jsx(PrintPageOptionsModal, { isOpen: isPageOptionModalOpened, onCloseDialog: () => {
|
|
103
|
+
togglePageOptionDialog(false);
|
|
104
|
+
}, onPrint: (options) => {
|
|
105
|
+
togglePageOptionDialog(false);
|
|
106
|
+
onPrint?.(options);
|
|
107
|
+
setPageOptions(options);
|
|
108
|
+
}, defaultPrintPageOptions: defaultPrintPageOptions || {} }));
|
|
109
|
+
}
|
|
110
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { style: {
|
|
111
|
+
backgroundColor: 'white',
|
|
112
|
+
opacity: 0.5,
|
|
113
|
+
left: 0,
|
|
114
|
+
top: 0,
|
|
115
|
+
position: 'fixed',
|
|
116
|
+
width: '100%',
|
|
117
|
+
height: '100%',
|
|
118
|
+
zIndex: 10,
|
|
119
|
+
} }), _jsx(InnerPrintFrame, { printPageOptions: pageOptions, onAfterPrint: () => {
|
|
120
|
+
setPageOptions(null);
|
|
121
|
+
onAfterPrint?.();
|
|
122
|
+
}, onBeforePrint: () => {
|
|
123
|
+
onBeforePrint?.();
|
|
124
|
+
}, children: children })] }));
|
|
125
|
+
}
|
|
126
|
+
export function InnerPrintFrame(props) {
|
|
127
|
+
const { children, onAfterPrint, onBeforePrint, printPageOptions = {}, } = props;
|
|
128
|
+
const { size = 'A4', margin = 0, layout = 'landscape', } = printPageOptions || {};
|
|
129
|
+
const frameRef = useRef(null);
|
|
130
|
+
const [content, setContent] = useState();
|
|
131
|
+
const { width = 0, height = 0 } = pageSizes.find((pageItem) => pageItem.name === size)?.[layout] || {};
|
|
132
|
+
const handleAfterPrint = useCallback(() => {
|
|
133
|
+
onAfterPrint?.();
|
|
134
|
+
}, [onAfterPrint]);
|
|
135
|
+
const handleBeforePrint = useCallback(() => {
|
|
136
|
+
onBeforePrint?.();
|
|
137
|
+
}, [onBeforePrint]);
|
|
138
|
+
const load = useCallback(() => {
|
|
139
|
+
const contentWindow = frameRef.current?.contentWindow;
|
|
140
|
+
if (!contentWindow)
|
|
141
|
+
return;
|
|
142
|
+
const document = contentWindow.document;
|
|
143
|
+
setContent(document.body);
|
|
144
|
+
transferStyles(document);
|
|
145
|
+
appendPrintPageStyle(document, { size, layout, margin });
|
|
146
|
+
contentWindow.addEventListener('afterprint', handleAfterPrint);
|
|
147
|
+
contentWindow.addEventListener('beforeprint', handleBeforePrint);
|
|
148
|
+
return contentWindow;
|
|
149
|
+
}, [handleAfterPrint, handleBeforePrint, layout, margin, size]);
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
const contentWindow = frameRef.current?.contentWindow;
|
|
152
|
+
if (!isFirefox) {
|
|
153
|
+
load();
|
|
154
|
+
}
|
|
155
|
+
return () => {
|
|
156
|
+
if (!contentWindow)
|
|
157
|
+
return;
|
|
158
|
+
contentWindow.removeEventListener('afterprint', handleAfterPrint);
|
|
159
|
+
contentWindow.removeEventListener('beforeprint', handleBeforePrint);
|
|
160
|
+
};
|
|
161
|
+
}, [
|
|
162
|
+
onBeforePrint,
|
|
163
|
+
onAfterPrint,
|
|
164
|
+
handleBeforePrint,
|
|
165
|
+
handleAfterPrint,
|
|
166
|
+
size,
|
|
167
|
+
layout,
|
|
168
|
+
margin,
|
|
169
|
+
load,
|
|
170
|
+
]);
|
|
171
|
+
return (_jsx(PrintProvider, { width: width, height: height, margin: margin, children: _jsx("iframe", { ref: frameRef, style: {
|
|
172
|
+
width: 0,
|
|
173
|
+
height: 0,
|
|
174
|
+
border: 'none',
|
|
175
|
+
}, onLoad: () => {
|
|
176
|
+
if (isFirefox) {
|
|
177
|
+
load();
|
|
178
|
+
}
|
|
179
|
+
}, children: content &&
|
|
180
|
+
createPortal(_jsx(RenderContainer, { onRenderComplete: () => {
|
|
181
|
+
frameRef.current?.contentWindow?.focus();
|
|
182
|
+
frameRef.current?.contentWindow?.print();
|
|
183
|
+
}, style: {
|
|
184
|
+
width: `${width - margin}cm`,
|
|
185
|
+
height: `${height - margin}cm`,
|
|
186
|
+
margin: `${margin}cm`,
|
|
187
|
+
}, children: children }), content) }) }));
|
|
188
|
+
}
|
|
189
|
+
function RenderContainer(props) {
|
|
190
|
+
const { onRenderComplete, style, children } = props;
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
const handleRenderComplete = () => {
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
onRenderComplete();
|
|
195
|
+
}, 250);
|
|
196
|
+
};
|
|
197
|
+
const animationFrameId = requestAnimationFrame(handleRenderComplete);
|
|
198
|
+
return () => {
|
|
199
|
+
cancelAnimationFrame(animationFrameId);
|
|
200
|
+
};
|
|
201
|
+
}, [onRenderComplete]);
|
|
202
|
+
return _jsx("div", { style: style, children: children });
|
|
203
|
+
}
|
|
204
|
+
function appendPrintPageStyle(document, style = {}) {
|
|
205
|
+
const { layout = 'landscape', size = 'A4' } = style;
|
|
206
|
+
const styleElement = document.createElement('style');
|
|
207
|
+
styleElement.textContent = `
|
|
208
|
+
@media print {
|
|
209
|
+
|
|
210
|
+
@page {
|
|
211
|
+
size: ${size} ${layout};
|
|
212
|
+
padding:0;
|
|
213
|
+
margin:0;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
`;
|
|
217
|
+
document.head.append(styleElement);
|
|
218
|
+
}
|
|
219
|
+
function transferStyles(targetDocument) {
|
|
220
|
+
// Copy the style from the main page and inject it inside the iframe
|
|
221
|
+
const styleSheets = Array.from(document.styleSheets);
|
|
222
|
+
const targetHead = targetDocument.head;
|
|
223
|
+
for (const styleSheet of styleSheets) {
|
|
224
|
+
try {
|
|
225
|
+
if (styleSheet.cssRules) {
|
|
226
|
+
const newStyleEl = document.createElement('style');
|
|
227
|
+
const cssRules = Array.from(styleSheet.cssRules);
|
|
228
|
+
const cssText = cssRules.map((rule) => rule.cssText).join('\n');
|
|
229
|
+
newStyleEl.append(document.createTextNode(cssText));
|
|
230
|
+
targetHead.append(newStyleEl);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
// eslint-disable-next-line no-console
|
|
235
|
+
console.error('Error transferring styles:', error);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function PrintPageOptionsModal(props) {
|
|
240
|
+
const { isOpen, ...otherProps } = props;
|
|
241
|
+
if (!isOpen)
|
|
242
|
+
return;
|
|
243
|
+
return _jsx(InnerPrintOptionsModal, { ...otherProps });
|
|
244
|
+
}
|
|
245
|
+
const labelStyle = {
|
|
246
|
+
label: {
|
|
247
|
+
flex: 4,
|
|
248
|
+
color: '#232323',
|
|
249
|
+
},
|
|
250
|
+
wrapper: {
|
|
251
|
+
flex: 8,
|
|
252
|
+
display: 'flex',
|
|
253
|
+
justifyContent: 'flex-start',
|
|
254
|
+
},
|
|
255
|
+
container: { margin: '5px 0' },
|
|
256
|
+
};
|
|
257
|
+
const INITIAL_VALUE = {
|
|
258
|
+
size: 'A4',
|
|
259
|
+
layout: 'landscape',
|
|
260
|
+
margin: 0,
|
|
261
|
+
};
|
|
262
|
+
function InnerPrintOptionsModal(props) {
|
|
263
|
+
const { onCloseDialog, onPrint, defaultPrintPageOptions } = props;
|
|
264
|
+
function submitHandler(values) {
|
|
265
|
+
onPrint(values);
|
|
266
|
+
onCloseDialog?.();
|
|
267
|
+
}
|
|
268
|
+
const { handleSubmit, control, watch } = useForm({
|
|
269
|
+
defaultValues: { ...INITIAL_VALUE, ...defaultPrintPageOptions },
|
|
270
|
+
});
|
|
271
|
+
const layout = watch('layout');
|
|
272
|
+
const sizesList = getSizesList(layout);
|
|
273
|
+
return (_jsxs(Dialog, { isOpen: true, title: "Print options", onClose: onCloseDialog, style: { width: 600 }, children: [_jsxs(DialogBody, { css: css `
|
|
274
|
+
background-color: white;
|
|
275
|
+
`, children: [_jsx(Label, { style: labelStyle, title: "Size", children: _jsx(Select2Controller, { control: control, name: "size", items: sizesList }) }), _jsx(Label, { style: labelStyle, title: "Layout", children: _jsx(Controller, { name: "layout", control: control, render: ({ field }) => {
|
|
276
|
+
const { value, onChange, ...otherFieldProps } = field;
|
|
277
|
+
return (_jsxs(RadioGroup, { inline: true, onChange: onChange, selectedValue: value, ...otherFieldProps, children: [_jsx(Radio, { label: "Portrait", value: "portrait" }), _jsx(Radio, { label: "Landscape", value: "landscape" })] }));
|
|
278
|
+
} }) }), _jsx(Label, { style: labelStyle, title: "Margin", children: _jsx(NumberInput2Controller, { name: "margin", control: control, min: 0, rightElement: _jsx(Tag, { children: "cm" }) }) })] }), _jsx(DialogFooter, { children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => {
|
|
279
|
+
void handleSubmit(submitHandler)();
|
|
280
|
+
}, doneLabel: "Print", onCancel: () => onCloseDialog?.() }) })] }));
|
|
281
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface PrintPagContextProps {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function usePrintPage(): PrintPagContextProps | null;
|
|
7
|
+
interface PrintProviderProps extends PrintPagContextProps {
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
margin: number;
|
|
10
|
+
}
|
|
11
|
+
export declare function PrintProvider(props: PrintProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
3
|
+
const PrintContext = createContext(null);
|
|
4
|
+
export function usePrintPage() {
|
|
5
|
+
return useContext(PrintContext);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Converts centimetre to pixels.
|
|
9
|
+
* @param cm - The value in centimetre.
|
|
10
|
+
* @param ppi - Pixels per inch (default is 96).
|
|
11
|
+
* @returns The value in pixels.
|
|
12
|
+
*/
|
|
13
|
+
function cmToPx(cm, margin, ppi = 96) {
|
|
14
|
+
const inches = (cm - margin * 2) / 2.54;
|
|
15
|
+
return Math.round(inches * ppi);
|
|
16
|
+
}
|
|
17
|
+
export function PrintProvider(props) {
|
|
18
|
+
const { children, width, height, margin } = props;
|
|
19
|
+
const state = useMemo(() => {
|
|
20
|
+
const w = cmToPx(width, margin);
|
|
21
|
+
const h = cmToPx(height, margin);
|
|
22
|
+
return {
|
|
23
|
+
width: w,
|
|
24
|
+
height: h,
|
|
25
|
+
};
|
|
26
|
+
}, [height, margin, width]);
|
|
27
|
+
return (_jsx(PrintContext.Provider, { value: state, children: children }));
|
|
28
|
+
}
|
|
@@ -75,9 +75,9 @@ function ApodizationOptionsInnerPanel(props) {
|
|
|
75
75
|
useEffect(() => {
|
|
76
76
|
void handleSubmit((values) => onChange(values))();
|
|
77
77
|
}, [handleSubmit, onChange]);
|
|
78
|
-
return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Line broadening:", shortTitle: "LB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadening", debounceTime: 250,
|
|
78
|
+
return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Line broadening:", shortTitle: "LB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadening", debounceTime: 250, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
|
|
79
79
|
submitHandler();
|
|
80
|
-
} }) }), _jsx(Label, { title: "Gauss broadening:", shortTitle: "GB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "gaussBroadening", debounceTime: 250,
|
|
80
|
+
} }) }), _jsx(Label, { title: "Gauss broadening:", shortTitle: "GB:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "gaussBroadening", debounceTime: 250, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
|
|
81
81
|
submitHandler();
|
|
82
82
|
} }) }), _jsx(Label, { title: "Line broadening center [0 - 1]:", shortTitle: "LB center:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "lineBroadeningCenter", debounceTime: 250, min: 0, max: 1, stepSize: 0.1, style: { width: '60px' }, onValueChange: () => {
|
|
83
83
|
submitHandler();
|
|
@@ -127,6 +127,9 @@ function BaseLineCorrectionInnerPanel(props) {
|
|
|
127
127
|
onItemSelect(item);
|
|
128
128
|
const { values } = getData(item.value, props?.filter?.value || {});
|
|
129
129
|
reset(values);
|
|
130
|
+
setTimeout(() => {
|
|
131
|
+
submitHandler();
|
|
132
|
+
}, 0);
|
|
130
133
|
}, ...defaultSelectProps, children: _jsx(Button, { text: algorithm?.label, rightIcon: "double-caret-vertical" }) }) }), algorithm && algorithm?.value === 'airpls' && (_jsxs("div", { style: { display: 'flex' }, children: [_jsx(Label, { title: "Max iterations:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "maxIterations", min: 0, stepSize: 1, style: { width: '60px' }, debounceTime: 250, onValueChange: () => {
|
|
131
134
|
submitHandler();
|
|
132
135
|
} }) }), _jsx(Label, { title: "Tolerance:", style: headerLabelStyle, children: _jsx(NumberInput2Controller, { control: control, name: "tolerance", min: 0, stepSize: 0.001, majorStepSize: 0.001, minorStepSize: 0.001, style: { width: '60px' }, debounceTime: 250, onValueChange: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Workspace } from 'nmr-load-save';
|
|
2
2
|
export declare function useSaveSettings(): {
|
|
3
3
|
saveSettings: (values?: Partial<Workspace>) => void;
|
|
4
|
-
SaveSettingsModal: () => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
SaveSettingsModal: () => import("@emotion/react/jsx-runtime").JSX.Element;
|
|
5
5
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
|
+
/** @jsxImportSource @emotion/react */
|
|
3
|
+
import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
|
|
4
|
+
import styled from '@emotion/styled';
|
|
3
5
|
import { yupResolver } from '@hookform/resolvers/yup';
|
|
4
6
|
import { useRef } from 'react';
|
|
5
7
|
import { useForm } from 'react-hook-form';
|
|
@@ -7,8 +9,8 @@ import { useOnOff } from 'react-science/ui';
|
|
|
7
9
|
import * as Yup from 'yup';
|
|
8
10
|
import { usePreferences } from '../context/PreferencesContext';
|
|
9
11
|
import { useToaster } from '../context/ToasterContext';
|
|
12
|
+
import ActionButtons from '../elements/ActionButtons';
|
|
10
13
|
import { Input2Controller } from '../elements/Input2Controller';
|
|
11
|
-
import ConfirmationDialog from '../elements/popup/Modal/ConfirmDialog';
|
|
12
14
|
import { useWorkspaceAction } from './useWorkspaceAction';
|
|
13
15
|
const schema = Yup.object().shape({
|
|
14
16
|
workspaceName: Yup.string().required(),
|
|
@@ -64,25 +66,19 @@ export function useSaveSettings() {
|
|
|
64
66
|
return {
|
|
65
67
|
saveSettings,
|
|
66
68
|
SaveSettingsModal: () => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
void handleSubmit(handleAddNewWorkspace)();
|
|
71
|
-
}, control: control })),
|
|
72
|
-
buttons: [
|
|
73
|
-
{
|
|
74
|
-
text: 'Save',
|
|
75
|
-
handler: () => {
|
|
76
|
-
void handleSubmit(handleAddNewWorkspace)();
|
|
77
|
-
},
|
|
78
|
-
preventClose: true,
|
|
79
|
-
},
|
|
80
|
-
{ text: 'Cancel' },
|
|
81
|
-
],
|
|
82
|
-
id: 'save-workspace-dialog',
|
|
83
|
-
onClose: closeDialog,
|
|
84
|
-
};
|
|
85
|
-
return (_jsx(Dialog, { onClose: closeDialog, isOpen: isOpenDialog, title: "Save workspace", children: _jsx(ConfirmationDialog, { disableDefaultStyle: true, ...alertConfig }) }));
|
|
69
|
+
return (_jsxs(Dialog, { onClose: closeDialog, isOpen: isOpenDialog, title: "Save workspace", role: "dialog", children: [_jsxs(DialogContent, { children: [_jsx(Title, { children: "Please enter a new user workspace name in order to save your changes locally" }), _jsx(WorkspaceAddForm, { onEnter: () => {
|
|
70
|
+
void handleSubmit(handleAddNewWorkspace)();
|
|
71
|
+
}, control: control })] }), _jsx(DialogFooter, { children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onCancel: closeDialog, doneLabel: "Save workspace", onDone: () => void handleSubmit(handleAddNewWorkspace)() }) })] }));
|
|
86
72
|
},
|
|
87
73
|
};
|
|
88
74
|
}
|
|
75
|
+
const DialogContent = styled(DialogBody) `
|
|
76
|
+
background-color: white;
|
|
77
|
+
text-align: center;
|
|
78
|
+
`;
|
|
79
|
+
const Title = styled.p `
|
|
80
|
+
padding: 0 30px;
|
|
81
|
+
font-weight: bold;
|
|
82
|
+
text-align: left;
|
|
83
|
+
font-size: 1em;
|
|
84
|
+
`;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { ToolbarItemProps } from '../panels/header/DefaultPanelHeader';
|
|
2
|
+
import { SpectraSelectedMode } from '../reducer/actions/SpectraActions';
|
|
3
|
+
interface ToggleSpectraVisibility {
|
|
4
|
+
enableShowAll: boolean;
|
|
5
|
+
enableShowSelected: boolean;
|
|
6
|
+
enableShowSelectedOnly: boolean;
|
|
7
|
+
enableHideSelected: boolean;
|
|
8
|
+
enableHideAll: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function useToggleSpectraVisibility(props?: Partial<ToggleSpectraVisibility>): {
|
|
11
|
+
showSpectraHandler: (mode: SpectraSelectedMode) => void;
|
|
12
|
+
hideSpectraHandler: (mode: SpectraSelectedMode) => void;
|
|
13
|
+
getToggleVisibilityButtons: (disabled?: boolean) => ToolbarItemProps[];
|
|
10
14
|
};
|
|
15
|
+
export {};
|
|
@@ -1,37 +1,66 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { FaEye, FaEyeSlash } from 'react-icons/fa';
|
|
2
|
+
import { FaEye, FaEyeSlash, FaMinus, FaPlus } from 'react-icons/fa';
|
|
3
|
+
import { GrRadialSelected } from 'react-icons/gr';
|
|
4
|
+
import { TooltipHelpContent } from 'react-science/ui';
|
|
3
5
|
import { useChartData } from '../context/ChartContext';
|
|
4
6
|
import { useDispatch } from '../context/DispatchContext';
|
|
5
|
-
export function useToggleSpectraVisibility(
|
|
7
|
+
export function useToggleSpectraVisibility(props = {}) {
|
|
8
|
+
const { enableHideAll = true, enableHideSelected = true, enableShowAll = true, enableShowSelectedOnly = true, enableShowSelected = true, } = props;
|
|
6
9
|
const dispatch = useDispatch();
|
|
7
10
|
const { view: { spectra: { activeTab }, }, } = useChartData();
|
|
8
|
-
function showSpectraHandler() {
|
|
11
|
+
function showSpectraHandler(mode) {
|
|
9
12
|
dispatch({
|
|
10
13
|
type: 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS',
|
|
11
14
|
payload: { nucleus: activeTab, flag: true, mode },
|
|
12
15
|
});
|
|
13
16
|
}
|
|
14
|
-
function hideSpectraHandler() {
|
|
17
|
+
function hideSpectraHandler(mode) {
|
|
15
18
|
dispatch({
|
|
16
19
|
type: 'CHANGE_SPECTRA_VISIBILITY_BY_NUCLEUS',
|
|
17
20
|
payload: { nucleus: activeTab, flag: false, mode },
|
|
18
21
|
});
|
|
19
22
|
}
|
|
20
23
|
function getToggleVisibilityButtons(disabled = false) {
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const output = [];
|
|
25
|
+
if (enableShowAll) {
|
|
26
|
+
output.push({
|
|
27
|
+
icon: _jsx(FaEye, {}),
|
|
28
|
+
tooltip: _jsx(TooltipHelpContent, { title: "Show all spectra" }),
|
|
29
|
+
onClick: () => showSpectraHandler('all'),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (enableShowSelected) {
|
|
33
|
+
output.push({
|
|
23
34
|
disabled,
|
|
24
|
-
icon: _jsx(
|
|
25
|
-
tooltip:
|
|
26
|
-
onClick:
|
|
27
|
-
}
|
|
28
|
-
|
|
35
|
+
icon: _jsx(FaPlus, {}),
|
|
36
|
+
tooltip: _jsx(TooltipHelpContent, { title: "Show selected spectra" }),
|
|
37
|
+
onClick: () => showSpectraHandler('selected'),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (enableShowSelectedOnly) {
|
|
41
|
+
output.push({
|
|
29
42
|
disabled,
|
|
30
|
-
icon: _jsx(
|
|
31
|
-
tooltip:
|
|
32
|
-
onClick: showSpectraHandler,
|
|
33
|
-
}
|
|
34
|
-
|
|
43
|
+
icon: _jsx(GrRadialSelected, {}),
|
|
44
|
+
tooltip: _jsx(TooltipHelpContent, { title: "Focus on selected spectra" }),
|
|
45
|
+
onClick: () => showSpectraHandler('selectedOnly'),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (enableHideSelected) {
|
|
49
|
+
output.push({
|
|
50
|
+
disabled,
|
|
51
|
+
icon: _jsx(FaMinus, {}),
|
|
52
|
+
tooltip: _jsx(TooltipHelpContent, { title: "Hide selected spectra" }),
|
|
53
|
+
onClick: () => hideSpectraHandler('selected'),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (enableHideAll) {
|
|
57
|
+
output.push({
|
|
58
|
+
icon: _jsx(FaEyeSlash, {}),
|
|
59
|
+
tooltip: _jsx(TooltipHelpContent, { title: "Hide all spectra" }),
|
|
60
|
+
onClick: () => hideSpectraHandler('all'),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return output;
|
|
35
64
|
}
|
|
36
65
|
return {
|
|
37
66
|
showSpectraHandler,
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
|
-
import { fileCollectionFromFileList } from 'filelist-utils';
|
|
5
|
-
import { read as readDropFiles } from 'nmr-load-save';
|
|
6
4
|
import { useCallback, useState } from 'react';
|
|
7
5
|
import { useDropzone } from 'react-dropzone';
|
|
8
6
|
import { FaUpload } from 'react-icons/fa';
|
|
9
|
-
import { isMetaFile, parseMetaFile } from '../../data/parseMeta';
|
|
10
7
|
import { useChartData } from '../context/ChartContext';
|
|
11
|
-
import { useDispatch } from '../context/DispatchContext';
|
|
12
8
|
import { LoaderProvider } from '../context/LoaderContext';
|
|
13
|
-
import { useLogger } from '../context/LoggerContext';
|
|
14
|
-
import { usePreferences } from '../context/PreferencesContext';
|
|
15
|
-
import { useToaster } from '../context/ToasterContext';
|
|
16
|
-
import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
|
|
17
9
|
import { useCheckToolsVisibility } from '../hooks/useCheckToolsVisibility';
|
|
18
10
|
import { MetaImportationModal } from '../modal/metaImportation/MetaImportationModal';
|
|
11
|
+
import { useLoadFiles } from './useLoadFiles';
|
|
19
12
|
const style = css `
|
|
20
13
|
height: 100%;
|
|
21
14
|
background-color: #b5b5b599;
|
|
@@ -46,69 +39,12 @@ const containerStyle = css `
|
|
|
46
39
|
`;
|
|
47
40
|
function DropZone(props) {
|
|
48
41
|
const { width, height } = useChartData();
|
|
49
|
-
const dispatch = useDispatch();
|
|
50
|
-
const { dispatch: dispatchPreferences, current: workspacePreferences } = usePreferences();
|
|
51
|
-
const preferences = usePreferences();
|
|
52
42
|
const isToolEnabled = useCheckToolsVisibility();
|
|
53
|
-
const toaster = useToaster();
|
|
54
|
-
const { logger } = useLogger();
|
|
55
|
-
const experimentalFeatures = useCheckExperimentalFeature();
|
|
56
43
|
const [metaInformationFile, openMetaInformationDialog] = useState();
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
if (files.length === 1 && isMetaFile(files[0])) {
|
|
60
|
-
openMetaInformationDialog(files[0]);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
const fileCollection = await fileCollectionFromFileList(files);
|
|
64
|
-
const metaFile = Object.values(fileCollection.files).find((file) => isMetaFile(file));
|
|
65
|
-
let parseMetaFileResult = null;
|
|
66
|
-
if (metaFile) {
|
|
67
|
-
parseMetaFileResult = await parseMetaFile(metaFile);
|
|
68
|
-
}
|
|
69
|
-
const { nmrLoaders: sourceSelector } = preferences.current;
|
|
70
|
-
const { onLoadProcessing, spectraColors } = workspacePreferences;
|
|
71
|
-
const { nmriumState, containsNmrium } = await readDropFiles(fileCollection, {
|
|
72
|
-
sourceSelector,
|
|
73
|
-
logger: logger.child({ context: 'nmr-processing' }),
|
|
74
|
-
onLoadProcessing,
|
|
75
|
-
experimentalFeatures,
|
|
76
|
-
});
|
|
77
|
-
if (nmriumState?.settings) {
|
|
78
|
-
dispatchPreferences({
|
|
79
|
-
type: 'SET_WORKSPACE',
|
|
80
|
-
payload: {
|
|
81
|
-
data: nmriumState.settings,
|
|
82
|
-
workspaceSource: 'nmriumFile',
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
dispatch({
|
|
87
|
-
type: 'LOAD_DROP_FILES',
|
|
88
|
-
payload: {
|
|
89
|
-
nmriumState,
|
|
90
|
-
containsNmrium,
|
|
91
|
-
parseMetaFileResult,
|
|
92
|
-
spectraColors,
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
toaster.show({ message: error.message, intent: 'danger' });
|
|
99
|
-
logger.error(error);
|
|
100
|
-
}
|
|
101
|
-
finally {
|
|
102
|
-
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
function onDrop(droppedFiles) {
|
|
106
|
-
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: true } });
|
|
107
|
-
void loadFilesHandler(droppedFiles);
|
|
108
|
-
}
|
|
44
|
+
const loadFiles = useLoadFiles(openMetaInformationDialog);
|
|
109
45
|
const isImportEnabled = isToolEnabled('import');
|
|
110
46
|
const { getRootProps, getInputProps, isDragActive, open: openImportDialog, } = useDropzone({
|
|
111
|
-
onDrop,
|
|
47
|
+
onDrop: loadFiles,
|
|
112
48
|
noClick: true,
|
|
113
49
|
noKeyboard: true,
|
|
114
50
|
noDrag: !isImportEnabled,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useLoadFiles(onOpenMetaInformation?: (file: File) => void): (files: File[]) => void;
|