nmrium 1.10.1 → 1.11.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/BrushTracker1D.d.ts.map +1 -1
- package/lib/component/1d/BrushTracker1D.js +7 -0
- package/lib/component/1d/BrushTracker1D.js.map +1 -1
- package/lib/component/1d/FloatPublicationString.d.ts.map +1 -1
- package/lib/component/1d/FloatPublicationString.js +1 -1
- package/lib/component/1d/FloatPublicationString.js.map +1 -1
- package/lib/component/1d/FloatingRanges.d.ts.map +1 -1
- package/lib/component/1d/FloatingRanges.js +1 -1
- package/lib/component/1d/FloatingRanges.js.map +1 -1
- package/lib/component/1d/inset/DraggableInset.d.ts.map +1 -1
- package/lib/component/1d/inset/DraggableInset.js +1 -1
- package/lib/component/1d/inset/DraggableInset.js.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +11 -2
- package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
- package/lib/component/EventsTrackers/KeysListenerTracker.js +3 -3
- package/lib/component/EventsTrackers/KeysListenerTracker.js.map +1 -1
- package/lib/component/elements/NextPrev.d.ts.map +1 -1
- package/lib/component/elements/NextPrev.js +23 -4
- package/lib/component/elements/NextPrev.js.map +1 -1
- package/lib/component/elements/export/utilities/exportOptionValidationSchema.d.ts +1 -1
- package/lib/component/hooks/useExport.d.ts +7 -7
- package/lib/component/hooks/useExport.d.ts.map +1 -1
- package/lib/component/hooks/useExport.js +22 -42
- package/lib/component/hooks/useExport.js.map +1 -1
- package/lib/component/hooks/useSetActiveSpectrumAction.d.ts.map +1 -1
- package/lib/component/hooks/useSetActiveSpectrumAction.js +3 -1
- package/lib/component/hooks/useSetActiveSpectrumAction.js.map +1 -1
- package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
- package/lib/component/loader/useLoadFiles.js +81 -86
- package/lib/component/loader/useLoadFiles.js.map +1 -1
- package/lib/component/main/ErrorOverlay.d.ts.map +1 -1
- package/lib/component/main/ErrorOverlay.js +6 -1
- package/lib/component/main/ErrorOverlay.js.map +1 -1
- package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
- package/lib/component/main/InnerNMRiumContents.js +1 -2
- package/lib/component/main/InnerNMRiumContents.js.map +1 -1
- package/lib/component/main/NMRiumViewer.js +1 -1
- package/lib/component/main/NMRiumViewer.js.map +1 -1
- package/lib/component/main/NMRiumViewerWrapper.d.ts.map +1 -1
- package/lib/component/main/NMRiumViewerWrapper.js +11 -3
- package/lib/component/main/NMRiumViewerWrapper.js.map +1 -1
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.d.ts +6 -0
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.d.ts.map +1 -0
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.js +127 -0
- package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.js.map +1 -0
- package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
- package/lib/component/modal/SaveAsModal.js +4 -8
- package/lib/component/modal/SaveAsModal.js.map +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
- package/lib/component/modal/changeSum/ChangeSumModal.js.map +1 -1
- package/lib/component/modal/changeSum/SelectMolecule.js +4 -1
- package/lib/component/modal/changeSum/SelectMolecule.js.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +71 -16
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
- package/lib/component/panels/Panels.d.ts +0 -9
- package/lib/component/panels/Panels.d.ts.map +1 -1
- package/lib/component/panels/Panels.js +1 -29
- package/lib/component/panels/Panels.js.map +1 -1
- package/lib/component/panels/hooks/useTogglePanel.d.ts.map +1 -1
- package/lib/component/panels/hooks/useTogglePanel.js +4 -3
- package/lib/component/panels/hooks/useTogglePanel.js.map +1 -1
- package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
- package/lib/component/reducer/actions/LoadAction.js +6 -0
- package/lib/component/reducer/actions/LoadAction.js.map +1 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts +23 -1
- package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/MoleculeActions.js +2 -2
- package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
- package/lib/component/reducer/actions/RangesActions.js +1 -1
- package/lib/component/reducer/actions/RangesActions.js.map +1 -1
- package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
- package/lib/component/reducer/actions/SpectraActions.d.ts.map +1 -1
- package/lib/component/reducer/actions/SpectraActions.js +2 -2
- package/lib/component/reducer/actions/SpectraActions.js.map +1 -1
- package/lib/component/reducer/preferences/actions/analyzeSpectra.d.ts +2 -1
- package/lib/component/reducer/preferences/actions/analyzeSpectra.d.ts.map +1 -1
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js +10 -0
- package/lib/component/reducer/preferences/actions/analyzeSpectra.js.map +1 -1
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.d.ts +4 -0
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.d.ts.map +1 -0
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.js +9 -0
- package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.js.map +1 -0
- package/lib/component/reducer/preferences/preferencesReducer.d.ts +8 -1
- package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
- package/lib/component/reducer/preferences/preferencesReducer.js +6 -1
- package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
- package/lib/component/toolbar/ToolBar.d.ts.map +1 -1
- package/lib/component/toolbar/ToolBar.js +6 -7
- package/lib/component/toolbar/ToolBar.js.map +1 -1
- package/lib/component/toolbar/toolbarMenu.d.ts +5 -1
- package/lib/component/toolbar/toolbarMenu.d.ts.map +1 -1
- package/lib/component/toolbar/toolbarMenu.js +1 -1
- package/lib/component/toolbar/toolbarMenu.js.map +1 -1
- package/lib/component/utility/export.d.ts +2 -1
- package/lib/component/utility/export.d.ts.map +1 -1
- package/lib/component/utility/export.js +5 -1
- package/lib/component/utility/export.js.map +1 -1
- package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -0
- package/lib/data/data1d/multipleSpectraAnalysis.d.ts.map +1 -1
- package/lib/data/data1d/multipleSpectraAnalysis.js +14 -0
- package/lib/data/data1d/multipleSpectraAnalysis.js.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
- package/lib/data/data2d/Spectrum2D/contours.js +13 -6
- package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
- package/lib/data/molecules/MoleculeManager.d.ts +6 -1
- package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
- package/lib/data/molecules/MoleculeManager.js +3 -2
- package/lib/data/molecules/MoleculeManager.js.map +1 -1
- package/lib/versionInfo.js +1 -1
- package/package.json +36 -36
- package/src/component/1d/BrushTracker1D.tsx +8 -0
- package/src/component/1d/FloatPublicationString.tsx +0 -1
- package/src/component/1d/FloatingRanges.tsx +0 -1
- package/src/component/1d/inset/DraggableInset.tsx +0 -1
- package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +11 -2
- package/src/component/EventsTrackers/KeysListenerTracker.tsx +3 -3
- package/src/component/elements/NextPrev.tsx +28 -4
- package/src/component/hooks/useExport.tsx +34 -64
- package/src/component/hooks/useSetActiveSpectrumAction.ts +3 -2
- package/src/component/loader/useLoadFiles.ts +134 -111
- package/src/component/main/ErrorOverlay.tsx +11 -2
- package/src/component/main/InnerNMRiumContents.tsx +6 -9
- package/src/component/main/NMRiumViewer.tsx +2 -2
- package/src/component/main/NMRiumViewerWrapper.tsx +14 -6
- package/src/component/modal/MoleculeAutoLabelsDatabaseModal.tsx +219 -0
- package/src/component/modal/SaveAsModal.tsx +14 -41
- package/src/component/modal/changeSum/ChangeSumModal.tsx +1 -1
- package/src/component/modal/changeSum/SelectMolecule.tsx +23 -23
- package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +94 -15
- package/src/component/panels/Panels.tsx +1 -53
- package/src/component/panels/hooks/useTogglePanel.ts +4 -3
- package/src/component/reducer/actions/LoadAction.ts +15 -1
- package/src/component/reducer/actions/MoleculeActions.ts +4 -2
- package/src/component/reducer/actions/RangesActions.ts +1 -1
- package/src/component/reducer/actions/SpectraActions.ts +6 -2
- package/src/component/reducer/preferences/actions/analyzeSpectra.ts +16 -0
- package/src/component/reducer/preferences/actions/toggleOpenSplitPanel.ts +18 -0
- package/src/component/reducer/preferences/preferencesReducer.ts +22 -1
- package/src/component/toolbar/ToolBar.tsx +9 -9
- package/src/component/toolbar/toolbarMenu.tsx +13 -2
- package/src/component/utility/export.ts +6 -0
- package/src/data/data1d/multipleSpectraAnalysis.ts +20 -0
- package/src/data/data2d/Spectrum2D/contours.ts +16 -6
- package/src/data/molecules/MoleculeManager.ts +7 -2
- package/src/versionInfo.ts +1 -1
|
@@ -3,7 +3,7 @@ import type { SplitPaneSize } from 'react-science/ui';
|
|
|
3
3
|
import { SplitPane } from 'react-science/ui';
|
|
4
4
|
|
|
5
5
|
import { usePreferences } from '../context/PreferencesContext.js';
|
|
6
|
-
import { Panels
|
|
6
|
+
import { Panels } from '../panels/Panels.js';
|
|
7
7
|
import { useAccordionItems } from '../panels/hooks/useAccordionItems.js';
|
|
8
8
|
import { useGetPanelOptions } from '../panels/hooks/useGetPanelOptions.js';
|
|
9
9
|
|
|
@@ -19,8 +19,6 @@ export function NMRiumViewerWrapper(props: NMRiumViewerWrapperProps) {
|
|
|
19
19
|
const { emptyText, viewerRef } = props;
|
|
20
20
|
const { current, dispatch } = usePreferences();
|
|
21
21
|
const getPanelPreferences = useGetPanelOptions();
|
|
22
|
-
const { closeSplitPane, openSplitPane, isSplitPaneOpen } =
|
|
23
|
-
usePanelOpenState();
|
|
24
22
|
|
|
25
23
|
const {
|
|
26
24
|
general: { verticalSplitterPosition, verticalSplitterCloseThreshold },
|
|
@@ -36,6 +34,14 @@ export function NMRiumViewerWrapper(props: NMRiumViewerWrapperProps) {
|
|
|
36
34
|
},
|
|
37
35
|
});
|
|
38
36
|
}
|
|
37
|
+
function handleToggleSplitPanel(isOpen: boolean) {
|
|
38
|
+
dispatch({
|
|
39
|
+
type: 'TOGGLE_SPLIT_PANEL',
|
|
40
|
+
payload: {
|
|
41
|
+
isOpen,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
39
45
|
|
|
40
46
|
const displayedPanels = items.filter((item) => {
|
|
41
47
|
const panelOptions = getPanelPreferences(item);
|
|
@@ -47,16 +53,18 @@ export function NMRiumViewerWrapper(props: NMRiumViewerWrapperProps) {
|
|
|
47
53
|
return <NMRiumViewer emptyText={emptyText} viewerRef={viewerRef} />;
|
|
48
54
|
}
|
|
49
55
|
|
|
56
|
+
const isOpen = !general?.hidePanelOnLoad;
|
|
57
|
+
|
|
50
58
|
return (
|
|
51
59
|
<SplitPane
|
|
52
60
|
size={verticalSplitterPosition}
|
|
53
61
|
direction="horizontal"
|
|
54
62
|
controlledSide="end"
|
|
55
|
-
open={
|
|
56
|
-
defaultOpen={
|
|
63
|
+
open={isOpen}
|
|
64
|
+
defaultOpen={isOpen}
|
|
57
65
|
closeThreshold={verticalSplitterCloseThreshold}
|
|
58
66
|
onSizeChange={resizeHandler}
|
|
59
|
-
onOpenChange={(isOpen) => (isOpen
|
|
67
|
+
onOpenChange={(isOpen) => handleToggleSplitPanel(isOpen)}
|
|
60
68
|
>
|
|
61
69
|
<NMRiumViewer emptyText={emptyText} viewerRef={viewerRef} />
|
|
62
70
|
<Panels />
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { Dialog, InputGroup } from '@blueprintjs/core';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import { Molecule } from 'openchemlib';
|
|
4
|
+
import { autoLabelDatabase } from 'openchemlib-utils';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { MF } from 'react-mf';
|
|
7
|
+
import { IdcodeSvgRenderer } from 'react-ocl';
|
|
8
|
+
import { Button } from 'react-science/ui';
|
|
9
|
+
import { filter } from 'smart-array-filter';
|
|
10
|
+
|
|
11
|
+
import { useDispatch } from '../context/DispatchContext.tsx';
|
|
12
|
+
import { StyledDialogBody } from '../elements/StyledDialogBody.js';
|
|
13
|
+
|
|
14
|
+
interface LabelDatabaseItem {
|
|
15
|
+
idCode: string;
|
|
16
|
+
coordinates: string;
|
|
17
|
+
mf: string;
|
|
18
|
+
mw: number;
|
|
19
|
+
label: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ChemicalGrid = styled.div`
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-wrap: wrap;
|
|
25
|
+
gap: 1.25rem;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
padding: 0.5rem 1rem;
|
|
28
|
+
flex: 1;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const AddButton = styled(Button)`
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0;
|
|
34
|
+
left: 0;
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const ChemicalCard = styled.div`
|
|
38
|
+
position: relative;
|
|
39
|
+
flex: 0 0 calc((100% - 2.5rem) / 3);
|
|
40
|
+
min-width: 200px;
|
|
41
|
+
border-radius: 8px;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
background: #fff;
|
|
44
|
+
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
|
|
45
|
+
transition: all 0.25s ease;
|
|
46
|
+
/* stylelint-disable nesting-selector-no-missing-scoping-root */
|
|
47
|
+
&:hover {
|
|
48
|
+
box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
|
|
49
|
+
transform: translateY(-2px);
|
|
50
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
const CardLabel = styled.div`
|
|
54
|
+
padding: 0.75rem 1rem;
|
|
55
|
+
background: linear-gradient(180deg, #fff 0%, #f0f2f5 40%, #e2e6eb 100%);
|
|
56
|
+
border-bottom: 1px solid #d1d5db;
|
|
57
|
+
box-shadow: inset 0 1px 0 rgb(255 255 255 / 80%);
|
|
58
|
+
|
|
59
|
+
h3 {
|
|
60
|
+
margin: 0;
|
|
61
|
+
font-size: 0.95rem;
|
|
62
|
+
font-weight: 600;
|
|
63
|
+
color: #374151;
|
|
64
|
+
text-align: center;
|
|
65
|
+
text-transform: capitalize;
|
|
66
|
+
letter-spacing: 0.02em;
|
|
67
|
+
text-shadow: 0 1px 0 rgb(255 255 255 / 50%);
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
const StructureContainer = styled.div`
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: center;
|
|
75
|
+
padding: 0.5rem;
|
|
76
|
+
background: #fafafa;
|
|
77
|
+
border-bottom: 1px solid #eee;
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
const CardInfo = styled.div`
|
|
81
|
+
padding: 0.75rem 1rem;
|
|
82
|
+
display: flex;
|
|
83
|
+
justify-content: center;
|
|
84
|
+
align-items: center;
|
|
85
|
+
background: #fff;
|
|
86
|
+
`;
|
|
87
|
+
|
|
88
|
+
const MolecularFormula = styled.div<{ color?: string }>`
|
|
89
|
+
font-size: 0.9rem;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
color: ${({ color }) => color ?? '#374151'};
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
const SearchContainer = styled.div`
|
|
95
|
+
padding: 1.2rem;
|
|
96
|
+
margin-bottom: 1.5rem;
|
|
97
|
+
background-color: white;
|
|
98
|
+
border-bottom: 1px solid #e0e0e0;
|
|
99
|
+
position: sticky;
|
|
100
|
+
top: 0;
|
|
101
|
+
z-index: 1;
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
const SearchInput = styled(InputGroup)`
|
|
105
|
+
input {
|
|
106
|
+
background: #eceff7;
|
|
107
|
+
|
|
108
|
+
&:focus {
|
|
109
|
+
background: #fff;
|
|
110
|
+
box-shadow: 0 1px 4px rgb(0 0 0 / 15%);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
const NoResults = styled.p`
|
|
116
|
+
text-align: center;
|
|
117
|
+
color: #6b7280;
|
|
118
|
+
font-size: 1rem;
|
|
119
|
+
padding: 3rem;
|
|
120
|
+
`;
|
|
121
|
+
interface MoleculeAutoLabelsDatabaseModalProps {
|
|
122
|
+
onClose?: (element?: string) => void;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function MoleculeAutoLabelsDatabaseModal({
|
|
126
|
+
onClose = () => null,
|
|
127
|
+
}: MoleculeAutoLabelsDatabaseModalProps) {
|
|
128
|
+
const dispatch = useDispatch();
|
|
129
|
+
const [keywords, setSearch] = useState('');
|
|
130
|
+
|
|
131
|
+
function handleAddMolecule(options: LabelDatabaseItem) {
|
|
132
|
+
const { idCode, coordinates, label } = options;
|
|
133
|
+
const molecule = Molecule.fromIDCode(idCode, coordinates);
|
|
134
|
+
|
|
135
|
+
if (molecule.getAllAtoms() <= 0) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
dispatch({
|
|
140
|
+
type: 'ADD_MOLECULE',
|
|
141
|
+
payload: { molfile: molecule.toMolfileV3(), label },
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
onClose();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const filteredLabelDatabase = filter(autoLabelDatabase, { keywords });
|
|
148
|
+
|
|
149
|
+
return (
|
|
150
|
+
<Dialog
|
|
151
|
+
isOpen
|
|
152
|
+
onClose={() => onClose()}
|
|
153
|
+
style={{ width: '90vw', maxWidth: 1000, height: '80vh' }}
|
|
154
|
+
title="Template database"
|
|
155
|
+
>
|
|
156
|
+
<StyledDialogBody style={{ padding: 0 }}>
|
|
157
|
+
<SearchContainer>
|
|
158
|
+
<SearchInput
|
|
159
|
+
size="large"
|
|
160
|
+
placeholder="Search ..."
|
|
161
|
+
value={keywords}
|
|
162
|
+
onChange={({ target }) => {
|
|
163
|
+
if (target.value !== undefined) {
|
|
164
|
+
setSearch(target.value);
|
|
165
|
+
}
|
|
166
|
+
}}
|
|
167
|
+
leftIcon="search"
|
|
168
|
+
type="search"
|
|
169
|
+
/>
|
|
170
|
+
</SearchContainer>
|
|
171
|
+
{filteredLabelDatabase.length === 0 ? (
|
|
172
|
+
<NoResults>No results found for "{keywords}"</NoResults>
|
|
173
|
+
) : (
|
|
174
|
+
<ChemicalGrid>
|
|
175
|
+
{filteredLabelDatabase.map((compound) => (
|
|
176
|
+
<ChemicalCard key={compound.label}>
|
|
177
|
+
<AddButton
|
|
178
|
+
size="large"
|
|
179
|
+
icon="plus"
|
|
180
|
+
minimal
|
|
181
|
+
tooltipProps={{
|
|
182
|
+
content: (
|
|
183
|
+
<MolecularFormula color="white">
|
|
184
|
+
<span>Add </span>
|
|
185
|
+
<MF mf={compound.mf} /> -
|
|
186
|
+
<span> {compound.mw.toFixed(2)}</span>
|
|
187
|
+
<span> molecule </span>
|
|
188
|
+
</MolecularFormula>
|
|
189
|
+
),
|
|
190
|
+
}}
|
|
191
|
+
onClick={() => handleAddMolecule(compound)}
|
|
192
|
+
/>
|
|
193
|
+
<CardLabel>
|
|
194
|
+
<h3>{compound.label}</h3>
|
|
195
|
+
</CardLabel>
|
|
196
|
+
|
|
197
|
+
<StructureContainer>
|
|
198
|
+
<IdcodeSvgRenderer
|
|
199
|
+
idcode={compound.idCode}
|
|
200
|
+
coordinates={compound.coordinates}
|
|
201
|
+
width={300}
|
|
202
|
+
height={200}
|
|
203
|
+
/>
|
|
204
|
+
</StructureContainer>
|
|
205
|
+
|
|
206
|
+
<CardInfo>
|
|
207
|
+
<MolecularFormula>
|
|
208
|
+
<MF mf={compound.mf} /> -
|
|
209
|
+
<span> {compound.mw.toFixed(2)}</span>
|
|
210
|
+
</MolecularFormula>
|
|
211
|
+
</CardInfo>
|
|
212
|
+
</ChemicalCard>
|
|
213
|
+
))}
|
|
214
|
+
</ChemicalGrid>
|
|
215
|
+
)}
|
|
216
|
+
</StyledDialogBody>
|
|
217
|
+
</Dialog>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
import { useMemo } from 'react';
|
|
9
9
|
import { Controller, useForm } from 'react-hook-form';
|
|
10
10
|
|
|
11
|
-
import type { ExportOptions } from '../../data/SpectraManager.js';
|
|
12
11
|
import { DataExportOptions } from '../../data/SpectraManager.js';
|
|
13
12
|
import { useChartData } from '../context/ChartContext.js';
|
|
14
13
|
import ActionButtons from '../elements/ActionButtons.js';
|
|
@@ -16,18 +15,16 @@ import { Input2Controller } from '../elements/Input2Controller.js';
|
|
|
16
15
|
import type { LabelStyle } from '../elements/Label.js';
|
|
17
16
|
import Label from '../elements/Label.js';
|
|
18
17
|
import { StyledDialogBody } from '../elements/StyledDialogBody.js';
|
|
19
|
-
import
|
|
18
|
+
import type { SaveOptions } from '../hooks/useExport.js';
|
|
20
19
|
import { useExport } from '../hooks/useExport.js';
|
|
21
20
|
|
|
22
|
-
const INITIAL_VALUE = {
|
|
21
|
+
const INITIAL_VALUE: SaveOptions = {
|
|
23
22
|
name: '',
|
|
24
|
-
compressed: false,
|
|
25
|
-
pretty: false,
|
|
26
23
|
include: {
|
|
27
|
-
dataType: DataExportOptions.
|
|
24
|
+
dataType: DataExportOptions.SELF_CONTAINED,
|
|
28
25
|
view: false,
|
|
29
26
|
settings: false,
|
|
30
|
-
}
|
|
27
|
+
},
|
|
31
28
|
};
|
|
32
29
|
|
|
33
30
|
export const labelStyle: LabelStyle = {
|
|
@@ -57,15 +54,14 @@ function SaveAsModal(props: SaveAsModalProps) {
|
|
|
57
54
|
|
|
58
55
|
return <InnerSaveAsModal onCloseDialog={onCloseDialog} />;
|
|
59
56
|
}
|
|
57
|
+
|
|
60
58
|
function InnerSaveAsModal(props: InnerSaveAsModalProps) {
|
|
61
59
|
const { onCloseDialog } = props;
|
|
62
|
-
const {
|
|
60
|
+
const { data, aggregator } = useChartData();
|
|
63
61
|
const { saveHandler } = useExport();
|
|
64
|
-
const experimentalFlagEnabled = useCheckExperimentalFeature();
|
|
65
|
-
|
|
66
62
|
const fileName = data[0]?.info?.name;
|
|
67
63
|
|
|
68
|
-
function submitHandler(values:
|
|
64
|
+
function submitHandler(values: SaveOptions) {
|
|
69
65
|
saveHandler(values);
|
|
70
66
|
onCloseDialog?.();
|
|
71
67
|
}
|
|
@@ -94,12 +90,6 @@ function InnerSaveAsModal(props: InnerSaveAsModalProps) {
|
|
|
94
90
|
controllerProps={{ rules: { required: true } }}
|
|
95
91
|
/>
|
|
96
92
|
</Label>
|
|
97
|
-
<Label style={labelStyle} title="Compressed">
|
|
98
|
-
<Checkbox style={{ margin: 0 }} {...register(`compressed`)} />
|
|
99
|
-
</Label>
|
|
100
|
-
<Label style={labelStyle} title="Pretty format">
|
|
101
|
-
<Checkbox style={{ margin: 0 }} {...register(`pretty`)} />
|
|
102
|
-
</Label>
|
|
103
93
|
<Label style={labelStyle} title="Include view">
|
|
104
94
|
<Checkbox style={{ margin: 0 }} {...register(`include.view`)} />
|
|
105
95
|
</Label>
|
|
@@ -114,33 +104,16 @@ function InnerSaveAsModal(props: InnerSaveAsModalProps) {
|
|
|
114
104
|
const { value, ref, ...otherFieldProps } = field;
|
|
115
105
|
return (
|
|
116
106
|
<RadioGroup inline selectedValue={value} {...otherFieldProps}>
|
|
117
|
-
<Radio label="Raw data" value={DataExportOptions.RAW_DATA} />
|
|
118
107
|
<Radio
|
|
119
|
-
label="
|
|
120
|
-
value={DataExportOptions.
|
|
121
|
-
|
|
108
|
+
label="External data embed"
|
|
109
|
+
value={DataExportOptions.SELF_CONTAINED}
|
|
110
|
+
/>
|
|
111
|
+
<Radio
|
|
112
|
+
label="External data linked"
|
|
113
|
+
disabled={!containsLinkedFiles}
|
|
114
|
+
value={DataExportOptions.SELF_CONTAINED_EXTERNAL_DATASOURCE}
|
|
122
115
|
/>
|
|
123
116
|
<Radio label="No data" value={DataExportOptions.NO_DATA} />
|
|
124
|
-
|
|
125
|
-
{/*
|
|
126
|
-
* Radio group works with Children.map.
|
|
127
|
-
* So Radio must be direct children of RadioGroup.
|
|
128
|
-
*/}
|
|
129
|
-
{experimentalFlagEnabled && (
|
|
130
|
-
<Radio
|
|
131
|
-
label="Full data (external data embed, experimental)"
|
|
132
|
-
value={DataExportOptions.SELF_CONTAINED}
|
|
133
|
-
/>
|
|
134
|
-
)}
|
|
135
|
-
{experimentalFlagEnabled && (
|
|
136
|
-
<Radio
|
|
137
|
-
label="Full data (external data linked, experimental)"
|
|
138
|
-
disabled={!containsLinkedFiles}
|
|
139
|
-
value={
|
|
140
|
-
DataExportOptions.SELF_CONTAINED_EXTERNAL_DATASOURCE
|
|
141
|
-
}
|
|
142
|
-
/>
|
|
143
|
-
)}
|
|
144
117
|
</RadioGroup>
|
|
145
118
|
);
|
|
146
119
|
}}
|
|
@@ -35,7 +35,7 @@ export default function ChangeSumModal(props: ChangeSumModalProps) {
|
|
|
35
35
|
<Dialog
|
|
36
36
|
isOpen
|
|
37
37
|
onClose={closeDialog}
|
|
38
|
-
style={{ width: 500 }}
|
|
38
|
+
style={{ width: 500, minHeight: 450 }}
|
|
39
39
|
title={
|
|
40
40
|
currentSum
|
|
41
41
|
? `Set new ${sumType} sum (Current: ${currentSum.toFixed(2)})`
|
|
@@ -87,29 +87,29 @@ export default function SelectMolecule<
|
|
|
87
87
|
[setValue],
|
|
88
88
|
);
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<
|
|
94
|
-
|
|
90
|
+
if (element && molecules && molecules.length > 0) {
|
|
91
|
+
return (
|
|
92
|
+
<Container>
|
|
93
|
+
<Title>Select a molecule as reference!</Title>
|
|
94
|
+
|
|
95
|
+
<SelectionContainer>
|
|
96
|
+
<MoleculeSelection
|
|
97
|
+
index={currentIndex}
|
|
98
|
+
molecules={molecules}
|
|
99
|
+
onChange={onChangeMoleculeSelectionHandler}
|
|
100
|
+
/>
|
|
101
|
+
<SumValue>
|
|
102
|
+
New sum for {element} will be {newSum}!
|
|
103
|
+
</SumValue>
|
|
104
|
+
</SelectionContainer>
|
|
105
|
+
</Container>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
95
108
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/>
|
|
102
|
-
<SumValue>
|
|
103
|
-
New sum for {element} will be {newSum}!
|
|
104
|
-
</SumValue>
|
|
105
|
-
</SelectionContainer>
|
|
106
|
-
</Container>
|
|
107
|
-
) : (
|
|
108
|
-
<EmptyText color={invalid ? 'red' : 'black'}>
|
|
109
|
-
You have to Select a spectrum and Add a molecule from the Structure
|
|
110
|
-
panel to select as a reference!
|
|
111
|
-
</EmptyText>
|
|
112
|
-
)}
|
|
113
|
-
</div>
|
|
109
|
+
return (
|
|
110
|
+
<EmptyText color={invalid ? 'red' : 'black'}>
|
|
111
|
+
You have to Select a spectrum and Add a molecule from the Structure panel
|
|
112
|
+
to select as a reference!
|
|
113
|
+
</EmptyText>
|
|
114
114
|
);
|
|
115
115
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { Molecule } from 'openchemlib';
|
|
2
|
+
import { autoLabel } from 'openchemlib-utils';
|
|
2
3
|
import type { ReactNode } from 'react';
|
|
3
4
|
import { useCallback } from 'react';
|
|
4
5
|
import {
|
|
5
6
|
FaCopy,
|
|
7
|
+
FaDatabase,
|
|
6
8
|
FaDownload,
|
|
7
9
|
FaFileExport,
|
|
8
10
|
FaFileImage,
|
|
@@ -13,7 +15,7 @@ import {
|
|
|
13
15
|
} from 'react-icons/fa';
|
|
14
16
|
import { FaMaximize, FaMinimize } from 'react-icons/fa6';
|
|
15
17
|
import { IoOpenOutline } from 'react-icons/io5';
|
|
16
|
-
import { MdNumbers, MdOutlineLabelOff } from 'react-icons/md';
|
|
18
|
+
import { MdFlashAuto, MdNumbers, MdOutlineLabelOff } from 'react-icons/md';
|
|
17
19
|
import { PanelHeader, Toolbar } from 'react-science/ui';
|
|
18
20
|
|
|
19
21
|
import type {
|
|
@@ -33,50 +35,80 @@ import { useToaster } from '../../context/ToasterContext.js';
|
|
|
33
35
|
import { useTopicMolecule } from '../../context/TopicMoleculeContext.js';
|
|
34
36
|
import type { ToolbarPopoverMenuItem } from '../../elements/ToolbarPopoverItem.js';
|
|
35
37
|
import { ToolbarPopoverItem } from '../../elements/ToolbarPopoverItem.js';
|
|
38
|
+
import { useDialogToggle } from '../../hooks/useDialogToggle.ts';
|
|
36
39
|
import AboutPredictionModal from '../../modal/AboutPredictionModal.js';
|
|
40
|
+
import { MoleculeAutoLabelsDatabaseModal } from '../../modal/MoleculeAutoLabelsDatabaseModal.tsx';
|
|
37
41
|
import PredictSpectraModal from '../../modal/PredictSpectraModal.js';
|
|
38
42
|
import { booleanToString } from '../../utility/booleanToString.ts';
|
|
39
43
|
import {
|
|
40
44
|
browserNotSupportedErrorToast,
|
|
41
45
|
copyPNGToClipboard,
|
|
46
|
+
exportAsMolfile,
|
|
42
47
|
exportAsSVG,
|
|
43
48
|
} from '../../utility/export.js';
|
|
44
49
|
import { useMoleculeAnnotationCore } from '../hooks/useMoleculeAnnotationCore.ts';
|
|
45
50
|
|
|
46
|
-
|
|
51
|
+
type ExportOperation =
|
|
52
|
+
| 'CopyAsSmiles'
|
|
53
|
+
| 'CopyAsMolfileV3'
|
|
54
|
+
| 'SaveAsMolfileV3'
|
|
55
|
+
| 'CopyAsMolfileV2'
|
|
56
|
+
| 'SaveAsMolfileV2'
|
|
57
|
+
| 'CopyAsPng'
|
|
58
|
+
| 'SaveAsSvg';
|
|
59
|
+
|
|
60
|
+
interface ExportDataItem {
|
|
61
|
+
id: ExportOperation;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const MOL_EXPORT_MENU: Array<ToolbarPopoverMenuItem<ExportDataItem>> = [
|
|
47
65
|
{
|
|
48
66
|
icon: <FaCopy />,
|
|
49
67
|
text: 'Copy as SMILES',
|
|
50
68
|
data: {
|
|
51
|
-
id: '
|
|
69
|
+
id: 'CopyAsSmiles',
|
|
52
70
|
},
|
|
53
71
|
},
|
|
54
72
|
{
|
|
55
73
|
icon: <FaCopy />,
|
|
56
|
-
text: 'Copy as molfile
|
|
74
|
+
text: 'Copy as molfile V2',
|
|
57
75
|
data: {
|
|
58
|
-
id: '
|
|
76
|
+
id: 'CopyAsMolfileV2',
|
|
59
77
|
},
|
|
60
78
|
},
|
|
61
79
|
{
|
|
62
80
|
icon: <FaCopy />,
|
|
63
|
-
text: 'Copy as molfile
|
|
81
|
+
text: 'Copy as molfile V3',
|
|
64
82
|
data: {
|
|
65
|
-
id: '
|
|
83
|
+
id: 'CopyAsMolfileV3',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
icon: <FaDownload />,
|
|
88
|
+
text: 'Save as molfile V2',
|
|
89
|
+
data: {
|
|
90
|
+
id: 'SaveAsMolfileV2',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
icon: <FaDownload />,
|
|
95
|
+
text: 'Save as molfile V3',
|
|
96
|
+
data: {
|
|
97
|
+
id: 'SaveAsMolfileV3',
|
|
66
98
|
},
|
|
67
99
|
},
|
|
68
100
|
{
|
|
69
101
|
icon: <FaFileImage />,
|
|
70
102
|
text: 'Copy as PNG',
|
|
71
103
|
data: {
|
|
72
|
-
id: '
|
|
104
|
+
id: 'CopyAsPng',
|
|
73
105
|
},
|
|
74
106
|
},
|
|
75
107
|
{
|
|
76
108
|
icon: <FaDownload />,
|
|
77
109
|
text: 'Export as SVG',
|
|
78
110
|
data: {
|
|
79
|
-
id: '
|
|
111
|
+
id: 'SaveAsSvg',
|
|
80
112
|
},
|
|
81
113
|
},
|
|
82
114
|
];
|
|
@@ -111,6 +143,9 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
|
|
|
111
143
|
current: { defaultMoleculeSettings },
|
|
112
144
|
} = usePreferences();
|
|
113
145
|
const moleculeKey = molecules?.[currentIndex]?.id;
|
|
146
|
+
const { dialog, openDialog, closeDialog } = useDialogToggle({
|
|
147
|
+
autoLabelDatabaseDialog: false,
|
|
148
|
+
});
|
|
114
149
|
const saveAsSVGHandler = useCallback(() => {
|
|
115
150
|
if (!rootRef) return;
|
|
116
151
|
exportAsSVG(`molSVG${currentIndex}`, {
|
|
@@ -161,29 +196,39 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
|
|
|
161
196
|
);
|
|
162
197
|
|
|
163
198
|
const exportHandler = useCallback(
|
|
164
|
-
(selected
|
|
199
|
+
(selected?: ExportDataItem) => {
|
|
165
200
|
const m = molecules?.[currentIndex];
|
|
166
201
|
const molecule = Molecule.fromMolfile(m.molfile);
|
|
167
202
|
if (molecule) {
|
|
168
203
|
switch (selected?.id) {
|
|
169
|
-
case '
|
|
204
|
+
case 'CopyAsSmiles':
|
|
170
205
|
copyHandler(molecule.toIsomericSmiles(), 'SMILES');
|
|
171
206
|
|
|
172
207
|
break;
|
|
173
|
-
case '
|
|
208
|
+
case 'CopyAsMolfileV3':
|
|
174
209
|
copyHandler(m.molfile, 'MOLFile');
|
|
175
210
|
break;
|
|
176
|
-
case '
|
|
211
|
+
case 'SaveAsMolfileV3':
|
|
212
|
+
exportAsMolfile(m.molfile, m.label);
|
|
213
|
+
break;
|
|
214
|
+
case 'CopyAsMolfileV2': {
|
|
177
215
|
copyHandler(
|
|
178
216
|
molecule.toMolfile({ customLabelPosition: 'normal' }),
|
|
179
217
|
'MOLFile',
|
|
180
218
|
);
|
|
181
219
|
break;
|
|
182
220
|
}
|
|
183
|
-
case '
|
|
221
|
+
case 'SaveAsMolfileV2': {
|
|
222
|
+
exportAsMolfile(
|
|
223
|
+
molecule.toMolfile({ customLabelPosition: 'normal' }),
|
|
224
|
+
m.label,
|
|
225
|
+
);
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
case 'CopyAsPng':
|
|
184
229
|
void saveAsPNGHandler();
|
|
185
230
|
break;
|
|
186
|
-
case '
|
|
231
|
+
case 'SaveAsSvg':
|
|
187
232
|
saveAsSVGHandler();
|
|
188
233
|
break;
|
|
189
234
|
default:
|
|
@@ -274,6 +319,20 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
|
|
|
274
319
|
});
|
|
275
320
|
}
|
|
276
321
|
|
|
322
|
+
function autoLabels() {
|
|
323
|
+
const currentMolecule = molecules[currentIndex];
|
|
324
|
+
|
|
325
|
+
if (!currentMolecule) return;
|
|
326
|
+
const { id, label, molfile } = currentMolecule;
|
|
327
|
+
|
|
328
|
+
const molecule = Molecule.fromMolfile(molfile);
|
|
329
|
+
autoLabel(molecule);
|
|
330
|
+
dispatch({
|
|
331
|
+
type: 'SET_MOLECULE',
|
|
332
|
+
payload: { id, label, molfile: molecule.toMolfileV3() },
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
277
336
|
const hasMolecules = molecules && molecules.length > 0;
|
|
278
337
|
const showCounter = hasMolecules && renderSource !== 'predictionPanel';
|
|
279
338
|
const moreMenu: ToolbarPopoverMenuItem[] = [
|
|
@@ -295,6 +354,23 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
|
|
|
295
354
|
disabled: !hasMolecules,
|
|
296
355
|
onClick: () => clearCustomAtomLabels(),
|
|
297
356
|
},
|
|
357
|
+
{
|
|
358
|
+
icon: <MdFlashAuto />,
|
|
359
|
+
text: 'Auto label atoms',
|
|
360
|
+
disabled: !hasMolecules,
|
|
361
|
+
tooltip: {
|
|
362
|
+
title: 'Auto label atoms',
|
|
363
|
+
description:
|
|
364
|
+
'Atoms are automatically labeled according to a predefined template database',
|
|
365
|
+
link: 'https://docs.nmrium.org/help/structure-labelling',
|
|
366
|
+
},
|
|
367
|
+
onClick: () => autoLabels(),
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
icon: <FaDatabase />,
|
|
371
|
+
text: 'Template database',
|
|
372
|
+
onClick: () => openDialog('autoLabelDatabaseDialog'),
|
|
373
|
+
},
|
|
298
374
|
];
|
|
299
375
|
|
|
300
376
|
const { handleChangeAtomAnnotation, isAnnotation } =
|
|
@@ -305,6 +381,9 @@ export default function MoleculePanelHeader(props: MoleculePanelHeaderProps) {
|
|
|
305
381
|
current={showCounter ? currentIndex + 1 : undefined}
|
|
306
382
|
total={showCounter ? molecules.length : undefined}
|
|
307
383
|
>
|
|
384
|
+
{dialog.autoLabelDatabaseDialog && (
|
|
385
|
+
<MoleculeAutoLabelsDatabaseModal onClose={closeDialog} />
|
|
386
|
+
)}
|
|
308
387
|
<Toolbar>
|
|
309
388
|
{renderSource === 'predictionPanel' && <AboutPredictionModal />}
|
|
310
389
|
{renderSource === 'moleculePanel' && (
|