nmrium 0.24.0 → 0.26.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/IntegralResizable.js +13 -13
- package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
- package/lib/component/1d/multiplicityTree/MultiplicityTree.js +5 -5
- package/lib/component/1d/ranges/Range.js +24 -33
- package/lib/component/2d/zones/Signal.js +8 -8
- package/lib/component/2d/zones/Zone.js +3 -3
- package/lib/component/EventsTrackers/KeysListenerTracker.js +1 -1
- package/lib/component/NMRium.js +22 -29
- package/lib/component/assignment/AssignmentsContext.d.ts +35 -0
- package/lib/component/assignment/AssignmentsContext.js +83 -0
- package/lib/component/assignment/AssignmentsReducer.d.ts +32 -0
- package/lib/component/assignment/AssignmentsReducer.js +39 -0
- package/lib/component/assignment/actions/initAssignment.d.ts +5 -0
- package/lib/component/assignment/actions/initAssignment.js +62 -0
- package/lib/component/assignment/actions/removeAssignment.d.ts +16 -0
- package/lib/component/assignment/actions/removeAssignment.js +24 -0
- package/lib/component/assignment/actions/setActiveAssignment.d.ts +10 -0
- package/lib/component/assignment/actions/setActiveAssignment.js +8 -0
- package/lib/component/assignment/actions/toggleAssignment.d.ts +7 -0
- package/lib/component/assignment/actions/toggleAssignment.js +44 -0
- package/lib/component/assignment/index.d.ts +0 -18
- package/lib/component/assignment/index.js +12 -266
- package/lib/component/assignment/utilities/filterForIDsWithAssignment.d.ts +2 -0
- package/lib/component/assignment/utilities/filterForIDsWithAssignment.js +3 -0
- package/lib/component/context/GlobalContext.d.ts +12 -3
- package/lib/component/context/GlobalContext.js +1 -1
- package/lib/component/elements/ActionButtons.d.ts +10 -0
- package/lib/component/elements/ActionButtons.js +14 -0
- package/lib/component/elements/Button.d.ts +30 -5
- package/lib/component/elements/Button.js +151 -4
- package/lib/component/elements/ContextMenu.js +6 -6
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +5 -1
- package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +38 -10
- package/lib/component/elements/ReactTable/ReactTable.d.ts +3 -1
- package/lib/component/elements/ReactTable/ReactTable.js +7 -2
- package/lib/component/elements/ReactTable/Style.d.ts +1 -3
- package/lib/component/elements/ReactTable/Style.js +1 -7
- package/lib/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
- package/lib/component/elements/resizer/DivResizer.js +107 -0
- package/lib/component/elements/resizer/Resizer.d.ts +18 -0
- package/lib/component/elements/resizer/Resizer.js +12 -0
- package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
- package/lib/component/elements/resizer/SVGResizer.js +71 -0
- package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
- package/lib/component/elements/resizer/useDraggable.js +52 -0
- package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
- package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib/component/header/RangesPickingOptionPanel.js +3 -16
- package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib/component/header/Zones2DOptionPanel.js +3 -14
- package/lib/component/hooks/useExport.js +11 -9
- package/lib/component/loader/DropZone.js +1 -0
- package/lib/component/modal/AlignSpectraModal.js +2 -1
- package/lib/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib/component/modal/LoadJCAMPModal.js +7 -6
- package/lib/component/modal/ModalStyle.js +4 -26
- package/lib/component/modal/MoleculeStructureEditorModal.js +2 -1
- package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib/component/modal/PredictSpectraModal.js +2 -7
- package/lib/component/modal/SaveAsModal.d.ts +1 -1
- package/lib/component/modal/SaveAsModal.js +2 -1
- package/lib/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib/component/modal/setting/GeneralSettings.js +3 -1
- package/lib/component/modal/setting/settingsValidation.d.ts +8 -0
- package/lib/component/modal/setting/settingsValidation.js +40 -0
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +4 -3
- package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.d.ts +10 -0
- package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +60 -0
- package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +11 -5
- package/lib/component/panels/MoleculesPanel/Utilities.d.ts +20 -11
- package/lib/component/panels/MoleculesPanel/Utilities.js +50 -68
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +2 -2
- package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib/component/panels/RangesPanel/RangesHeader.js +2 -2
- package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
- package/lib/component/panels/RangesPanel/RangesTableRow.js +12 -11
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +16 -9
- package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
- package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +2 -3
- package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +1 -1
- package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +5 -18
- package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.d.ts +5 -7
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.d.ts +4 -8
- package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.d.ts +5 -9
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
- package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.d.ts +4 -8
- package/lib/component/panels/ZonesPanel/ZonesPanel.js +1 -1
- package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -1
- package/lib/component/panels/ZonesPanel/ZonesTableRow.js +20 -20
- package/lib/component/panels/header/SpectraAutomaticPickingButton.d.ts +2 -0
- package/lib/component/panels/header/SpectraAutomaticPickingButton.js +30 -0
- package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib/component/reducer/Reducer.d.ts +2 -0
- package/lib/component/reducer/Reducer.js +4 -1
- package/lib/component/reducer/actions/AssignmentsActions.d.ts +9 -0
- package/lib/component/reducer/actions/AssignmentsActions.js +18 -0
- package/lib/component/reducer/actions/LoadActions.d.ts +1 -1
- package/lib/component/reducer/actions/LoadActions.js +10 -5
- package/lib/component/reducer/preferencesReducer.d.ts +1 -8
- package/lib/component/reducer/preferencesReducer.js +16 -16
- package/lib/component/reducer/types/Types.d.ts +1 -0
- package/lib/component/reducer/types/Types.js +1 -0
- package/lib/component/utility/Export.d.ts +3 -3
- package/lib/component/utility/Export.js +10 -9
- package/lib/component/utility/FormatNumber.js +1 -1
- package/lib/component/workspaces/Workspace.d.ts +2 -4
- package/lib/component/workspaces/basic.js +8 -9
- package/lib/data/SpectraManager.js +23 -15
- package/lib/data/data1d/Data1DManager.d.ts +1 -1
- package/lib/data/data1d/Data1DManager.js +2 -1
- package/lib/data/data1d/Spectrum1D/toJSON.d.ts +2 -0
- package/lib/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib/data/data1d/database.d.ts +1 -2
- package/lib/data/data1d/database.js +1 -1
- package/lib/data/data1d/filter1d/exclusionZones.d.ts +1 -4
- package/lib/data/data2d/Data2DManager.d.ts +1 -1
- package/lib/data/data2d/Data2DManager.js +2 -1
- package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib/data/data2d/Spectrum2D/toJSON.d.ts +2 -0
- package/lib/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib/data/types/common/Source.d.ts +1 -0
- package/lib/data/types/data2d/Signal2DAxisData.d.ts +1 -1
- package/lib/versionInfo.js +1 -1
- package/lib-cjs/component/1d/IntegralResizable.js +12 -12
- package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
- package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +6 -6
- package/lib-cjs/component/1d/ranges/Range.js +26 -35
- package/lib-cjs/component/2d/zones/Signal.js +9 -9
- package/lib-cjs/component/2d/zones/Zone.js +4 -4
- package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +2 -2
- package/lib-cjs/component/NMRium.js +22 -29
- package/lib-cjs/component/assignment/AssignmentsContext.js +88 -0
- package/lib-cjs/component/assignment/AssignmentsReducer.js +45 -0
- package/lib-cjs/component/assignment/actions/initAssignment.js +65 -0
- package/lib-cjs/component/assignment/actions/removeAssignment.js +29 -0
- package/lib-cjs/component/assignment/actions/setActiveAssignment.js +11 -0
- package/lib-cjs/component/assignment/actions/toggleAssignment.js +47 -0
- package/lib-cjs/component/assignment/index.js +15 -269
- package/lib-cjs/component/assignment/utilities/filterForIDsWithAssignment.js +7 -0
- package/lib-cjs/component/context/GlobalContext.js +1 -1
- package/lib-cjs/component/elements/ActionButtons.js +20 -0
- package/lib-cjs/component/elements/Button.js +150 -4
- package/lib-cjs/component/elements/ContextMenu.js +6 -6
- package/lib-cjs/component/elements/ReactTable/Elements/ReactTableRow.js +42 -14
- package/lib-cjs/component/elements/ReactTable/ReactTable.js +7 -2
- package/lib-cjs/component/elements/ReactTable/Style.js +1 -9
- package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
- package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
- package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
- package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
- package/lib-cjs/component/elements/resizer/useDraggable.js +55 -0
- package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
- package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
- package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
- package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
- package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
- package/lib-cjs/component/hooks/useExport.js +11 -9
- package/lib-cjs/component/loader/DropZone.js +1 -0
- package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
- package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
- package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
- package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
- package/lib-cjs/component/modal/ModalStyle.js +4 -26
- package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +5 -1
- package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
- package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
- package/lib-cjs/component/modal/SaveAsModal.js +2 -1
- package/lib-cjs/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib-cjs/component/modal/setting/GeneralSettings.js +3 -1
- package/lib-cjs/component/modal/setting/settingsValidation.js +66 -0
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
- package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
- package/lib-cjs/component/panels/AutomaticAssignment/useAutoAssignments.js +67 -0
- package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +12 -6
- package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +50 -68
- package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
- package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +3 -3
- package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +15 -14
- package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
- package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +2 -2
- package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -16
- package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
- package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
- package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +2 -2
- package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +21 -21
- package/lib-cjs/component/panels/header/SpectraAutomaticPickingButton.js +37 -0
- package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
- package/lib-cjs/component/reducer/Reducer.js +4 -1
- package/lib-cjs/component/reducer/actions/AssignmentsActions.js +21 -0
- package/lib-cjs/component/reducer/actions/LoadActions.js +9 -4
- package/lib-cjs/component/reducer/preferencesReducer.js +16 -16
- package/lib-cjs/component/reducer/types/Types.js +2 -1
- package/lib-cjs/component/utility/Export.js +10 -9
- package/lib-cjs/component/utility/FormatNumber.js +1 -1
- package/lib-cjs/component/workspaces/basic.js +8 -9
- package/lib-cjs/data/SpectraManager.js +23 -15
- package/lib-cjs/data/data1d/Data1DManager.js +2 -1
- package/lib-cjs/data/data1d/Spectrum1D/toJSON.js +1 -0
- package/lib-cjs/data/data2d/Data2DManager.js +2 -1
- package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
- package/lib-cjs/data/data2d/Spectrum2D/toJSON.js +1 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +25 -26
- package/lib/component/1d/Resizable.d.ts +0 -12
- package/lib/component/1d/Resizable.js +0 -105
- package/lib-cjs/component/1d/Resizable.js +0 -110
|
@@ -47,24 +47,30 @@ const styles = css `
|
|
|
47
47
|
`;
|
|
48
48
|
function FormattingTabContent() {
|
|
49
49
|
const { values, setFieldValue } = useFormikContext();
|
|
50
|
-
const
|
|
51
|
-
const deleteHandler = useCallback((
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const nuclei = useMemo(() => lodashGet(values, 'formatting.nuclei', {}), [values]);
|
|
51
|
+
const deleteHandler = useCallback((key) => {
|
|
52
|
+
let _nuclei = {};
|
|
53
|
+
for (const nucleus in nuclei) {
|
|
54
|
+
if (nucleus !== key) {
|
|
55
|
+
_nuclei[nucleus] = nuclei[nucleus];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
setFieldValue('formatting.nuclei', _nuclei);
|
|
59
|
+
}, [nuclei, setFieldValue]);
|
|
55
60
|
const addNewNucleusFormatHandler = useCallback(() => {
|
|
56
61
|
const newFormat = {
|
|
57
|
-
key: generateID(),
|
|
58
62
|
name: '',
|
|
59
63
|
ppm: '0.00',
|
|
60
64
|
hz: '0.00',
|
|
61
65
|
};
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
const key = generateID();
|
|
67
|
+
const newNuclei = { ...nuclei, [key]: newFormat };
|
|
68
|
+
setFieldValue('formatting.nuclei', newNuclei);
|
|
69
|
+
}, [nuclei, setFieldValue]);
|
|
70
|
+
const nucleiList = Object.keys(nuclei);
|
|
71
|
+
return (_jsxs(Fragment, { children: [_jsx("p", { className: "section-header", children: "Nuclei Formatting" }), _jsx("div", { css: styles, children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "counter-col", children: "#" }), _jsx("th", { className: "nucleus-label-col", children: "Nucleus " }), _jsx("th", { className: "nucleus-format-input-col", children: "\u03B4 (ppm)" }), _jsx("th", { className: "nucleus-format-input-col", children: "Coupling (Hz)" }), _jsx("th", { className: "nucleus-format-input-col" })] }) }), _jsx("tbody", { children: nucleiList?.map((key, index) => {
|
|
66
72
|
const num = index + 1;
|
|
67
|
-
return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.
|
|
73
|
+
return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.name`, className: "width-100", checkErrorAfterInputTouched: false }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.ppm`, className: "width-100" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.hz`, className: "width-100" }) }), _jsxs("td", { className: "operation-container", children: [_jsx(CloseButton, { onClick: () => deleteHandler(key), popupTitle: `remove ${nuclei[key].name}`, popupPlacement: "right" }), nucleiList.length === index + 1 && (_jsx("button", { className: "add", type: "button", onClick: addNewNucleusFormatHandler, children: _jsx(FaPlus, {}) }))] })] }, `${key}`));
|
|
68
74
|
}) })] }) })] }));
|
|
69
75
|
}
|
|
70
76
|
export default FormattingTabContent;
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { usePreferences, useWorkspacesList, } from '../../context/PreferencesContext';
|
|
6
|
+
import ActionButtons from '../../elements/ActionButtons';
|
|
6
7
|
import CloseButton from '../../elements/CloseButton';
|
|
7
8
|
import Tab from '../../elements/Tab/Tab';
|
|
8
9
|
import Tabs, { PositionsEnum } from '../../elements/Tab/Tabs';
|
|
@@ -14,6 +15,7 @@ import ControllersTabContent from './ControllersTabContent';
|
|
|
14
15
|
import DisplayTabContent from './DisplayTabContent';
|
|
15
16
|
import FormattingTabContent from './FormattingTabContent';
|
|
16
17
|
import WorkspaceItem from './WorkspaceItem';
|
|
18
|
+
import { validation } from './settingsValidation';
|
|
17
19
|
const styles = css `
|
|
18
20
|
.main-content {
|
|
19
21
|
width: 100%;
|
|
@@ -145,6 +147,6 @@ function GeneralSettings({ onClose }) {
|
|
|
145
147
|
const renderItem = useCallback((item) => {
|
|
146
148
|
return (_jsx(WorkspaceItem, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
|
|
147
149
|
}, [addWorkSpaceHandler, deleteWorkSpaceHandler]);
|
|
148
|
-
return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }),
|
|
150
|
+
return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, validationSchema: validation, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
|
|
149
151
|
}
|
|
150
152
|
export default GeneralSettings;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Yup from 'yup';
|
|
2
|
+
export declare const validation: import("yup/lib/Lazy").default<Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
3
|
+
formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
|
|
4
|
+
}>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
5
|
+
formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
|
|
6
|
+
}>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
|
|
7
|
+
formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
|
|
8
|
+
}>>>, import("yup/lib/object").AnyObject>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Yup from 'yup';
|
|
2
|
+
const formattingValidation = (obj) => Object.keys(obj.formatting.nuclei).reduce((validate, key) => {
|
|
3
|
+
validate[key] = Yup.object().shape({
|
|
4
|
+
name: Yup.string().trim().required('Nucleus is a required field'),
|
|
5
|
+
ppm: Yup.string().trim().required('PPM format is a required field'),
|
|
6
|
+
hz: Yup.string().trim().required('Hz format is a required field'),
|
|
7
|
+
});
|
|
8
|
+
return validate;
|
|
9
|
+
}, {});
|
|
10
|
+
export const validation = Yup.lazy((obj) => Yup.object().shape({
|
|
11
|
+
formatting: Yup.object().shape({
|
|
12
|
+
nuclei: Yup.object()
|
|
13
|
+
.shape(formattingValidation(obj))
|
|
14
|
+
.test('Unique', 'Nuclei need te be unique', function check(nuclei) {
|
|
15
|
+
let nucleusFrequencies = {};
|
|
16
|
+
for (const key of Object.keys(nuclei)) {
|
|
17
|
+
const _key = nuclei[key].name?.toLowerCase() || '';
|
|
18
|
+
if (_key) {
|
|
19
|
+
if (nucleusFrequencies[_key]) {
|
|
20
|
+
++nucleusFrequencies[_key].value;
|
|
21
|
+
nucleusFrequencies[_key].fields.push(key);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
nucleusFrequencies[_key] = { value: 1, fields: [key] };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const errors = Object.keys(nucleusFrequencies).reduce((errorList, key) => {
|
|
29
|
+
const { value, fields } = nucleusFrequencies[key];
|
|
30
|
+
if (value > 1) {
|
|
31
|
+
for (let field of fields) {
|
|
32
|
+
errorList.push(new Yup.ValidationError(`${key} nucleus must te be unique`, nuclei[key].name, `${this.path}.${field}.name`));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return errorList;
|
|
36
|
+
}, []);
|
|
37
|
+
return new Yup.ValidationError(errors);
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { SvgNmrAssignment2 } from 'cheminfo-font';
|
|
4
|
-
import {
|
|
4
|
+
import { FaBolt } from 'react-icons/fa';
|
|
5
5
|
import Button from '../../elements/ButtonToolTip';
|
|
6
6
|
import { tablePanelStyle } from '../extra/BasicPanelStyle';
|
|
7
7
|
import DefaultPanelHeader from '../header/DefaultPanelHeader';
|
|
8
|
+
import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
|
|
9
|
+
import AutomaticAssignmentTable from './AutomaticAssignmentTable';
|
|
10
|
+
import { useAutoAssignments } from './useAutoAssignments';
|
|
8
11
|
function AutomaticAssignment() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { showSettingButton: false, canDelete: false, children: _jsx(Button, { popupTitle: "automatic assignment", onClick: automaticAssignmentHandler, children: _jsx(SvgNmrAssignment2, { style: { fontSize: '18px' } }) }) }), _jsx("div", { className: "inner-container" })] }));
|
|
12
|
+
const { getAssignments, assignments, restAssignments } = useAutoAssignments();
|
|
13
|
+
return (_jsxs("div", { css: tablePanelStyle, children: [_jsxs(DefaultPanelHeader, { showSettingButton: false, canDelete: false, children: [_jsx(SpectraAutomaticPickingButton, {}), _jsx(Button, { popupTitle: "automatic assignment", onClick: getAssignments, children: _jsx(SvgNmrAssignment2, { style: { fontSize: '18px' } }) }), _jsx(Button, { popupTitle: "reset assignment", onClick: restAssignments, children: _jsx(FaBolt, {}) })] }), _jsx("div", { className: "inner-container", children: _jsx(AutomaticAssignmentTable, { data: assignments }) })] }));
|
|
12
14
|
}
|
|
13
15
|
export default AutomaticAssignment;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { AutoAssignmentsData } from './useAutoAssignments';
|
|
2
3
|
interface AutomaticAssignmentTableProps {
|
|
3
|
-
data:
|
|
4
|
+
data: AutoAssignmentsData[];
|
|
4
5
|
}
|
|
5
|
-
declare function
|
|
6
|
-
declare const _default: import("react").MemoExoticComponent<typeof
|
|
6
|
+
declare function AutomaticAssignmentTable({ data }: AutomaticAssignmentTableProps): JSX.Element;
|
|
7
|
+
declare const _default: import("react").MemoExoticComponent<typeof AutomaticAssignmentTable>;
|
|
7
8
|
export default _default;
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { SvgNmrAssignment } from 'cheminfo-font';
|
|
3
3
|
import { useCallback, useMemo, memo } from 'react';
|
|
4
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
4
5
|
import ReactTable from '../../elements/ReactTable/ReactTable';
|
|
6
|
+
import { SET_AUTOMATIC_ASSIGNMENTS } from '../../reducer/types/Types';
|
|
5
7
|
import NoTableData from '../extra/placeholder/NoTableData';
|
|
6
|
-
function
|
|
8
|
+
function AutomaticAssignmentTable({ data }) {
|
|
9
|
+
const dispatch = useDispatch();
|
|
7
10
|
const assignHandler = useCallback((e, row) => {
|
|
8
11
|
e.preventDefault();
|
|
9
12
|
e.stopPropagation();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
const assignments = row.original.assignment;
|
|
14
|
+
dispatch({
|
|
15
|
+
type: SET_AUTOMATIC_ASSIGNMENTS,
|
|
16
|
+
payload: { assignments },
|
|
17
|
+
});
|
|
18
|
+
}, [dispatch]);
|
|
13
19
|
const COLUMNS = useMemo(() => [
|
|
14
20
|
{
|
|
15
21
|
index: 1,
|
|
@@ -20,6 +26,7 @@ function PeaksTable({ data }) {
|
|
|
20
26
|
{
|
|
21
27
|
index: 2,
|
|
22
28
|
Header: 'Score',
|
|
29
|
+
accessor: 'score',
|
|
23
30
|
},
|
|
24
31
|
{
|
|
25
32
|
index: 3,
|
|
@@ -33,6 +40,6 @@ function PeaksTable({ data }) {
|
|
|
33
40
|
Cell: ({ row }) => (_jsx("button", { type: "button", className: "assign-button", onClick: (e) => assignHandler(e, row), children: _jsx(SvgNmrAssignment, {}) })),
|
|
34
41
|
},
|
|
35
42
|
], [assignHandler]);
|
|
36
|
-
return data && data.length > 0 ? (_jsx(ReactTable, { data: data, columns: COLUMNS })) : (_jsx(NoTableData, {}));
|
|
43
|
+
return data && data.length > 0 ? (_jsx(ReactTable, { data: data, columns: COLUMNS, onClick: assignHandler, highlightActiveRow: true })) : (_jsx(NoTableData, {}));
|
|
37
44
|
}
|
|
38
|
-
export default memo(
|
|
45
|
+
export default memo(AutomaticAssignmentTable);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SpectraData1D, SpectraData2D } from 'nmr-processing';
|
|
2
|
+
export interface AutoAssignmentsData {
|
|
3
|
+
score: number;
|
|
4
|
+
assignment: (SpectraData1D | SpectraData2D)[];
|
|
5
|
+
}
|
|
6
|
+
export declare function useAutoAssignments(): {
|
|
7
|
+
getAssignments: () => void;
|
|
8
|
+
assignments: AutoAssignmentsData[];
|
|
9
|
+
restAssignments: () => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getAssignments as getAssignmentsData, } from 'nmr-processing';
|
|
2
|
+
import OCL from 'openchemlib/full';
|
|
3
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { useChartData } from '../../context/ChartContext';
|
|
5
|
+
import { useDispatch } from '../../context/DispatchContext';
|
|
6
|
+
import { useAlert } from '../../elements/popup/Alert';
|
|
7
|
+
import { SET_AUTOMATIC_ASSIGNMENTS } from '../../reducer/types/Types';
|
|
8
|
+
function mapSpectra(data) {
|
|
9
|
+
return data.reduce((acc, spectrum) => {
|
|
10
|
+
const { id, info } = spectrum;
|
|
11
|
+
const dimension = spectrum.info.dimension;
|
|
12
|
+
if (dimension === 1) {
|
|
13
|
+
const ranges = spectrum.ranges.values;
|
|
14
|
+
acc.push({ id, info, ranges });
|
|
15
|
+
}
|
|
16
|
+
else if (dimension === 2) {
|
|
17
|
+
const zones = spectrum.zones.values;
|
|
18
|
+
acc.push({ id, info, zones });
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, []);
|
|
22
|
+
}
|
|
23
|
+
export function useAutoAssignments() {
|
|
24
|
+
const dispatch = useDispatch();
|
|
25
|
+
const { data, molecules } = useChartData();
|
|
26
|
+
const originData = useRef();
|
|
27
|
+
const alert = useAlert();
|
|
28
|
+
const [assignments, setAssignments] = useState([]);
|
|
29
|
+
const restAssignments = useCallback(() => {
|
|
30
|
+
dispatch({
|
|
31
|
+
type: SET_AUTOMATIC_ASSIGNMENTS,
|
|
32
|
+
payload: { assignments: originData.current },
|
|
33
|
+
});
|
|
34
|
+
}, [dispatch]);
|
|
35
|
+
const getAssignments = useCallback(() => {
|
|
36
|
+
void (async () => {
|
|
37
|
+
const hideLoading = await alert.showLoading('Auto Assignments');
|
|
38
|
+
const molecule = OCL.Molecule.fromMolfile(molecules[0]?.molfile || '');
|
|
39
|
+
const spectra = mapSpectra(data);
|
|
40
|
+
if (!originData.current) {
|
|
41
|
+
originData.current = spectra;
|
|
42
|
+
}
|
|
43
|
+
const result = await getAssignmentsData({
|
|
44
|
+
spectra,
|
|
45
|
+
molecule,
|
|
46
|
+
}, { minScore: 0 });
|
|
47
|
+
dispatch({
|
|
48
|
+
type: SET_AUTOMATIC_ASSIGNMENTS,
|
|
49
|
+
payload: { assignments: result[0].assignment },
|
|
50
|
+
});
|
|
51
|
+
hideLoading();
|
|
52
|
+
setAssignments(result);
|
|
53
|
+
})();
|
|
54
|
+
}, [alert, data, dispatch, molecules]);
|
|
55
|
+
return useMemo(() => ({
|
|
56
|
+
getAssignments,
|
|
57
|
+
assignments,
|
|
58
|
+
restAssignments,
|
|
59
|
+
}), [assignments, getAssignments, restAssignments]);
|
|
60
|
+
}
|
|
@@ -4,8 +4,9 @@ import { css } from '@emotion/react';
|
|
|
4
4
|
import { SvgNmrFt } from 'cheminfo-font';
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
6
|
import { FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
|
|
7
|
-
import { useAssignmentData } from '../../assignment';
|
|
7
|
+
import { useAssignmentData } from '../../assignment/AssignmentsContext';
|
|
8
8
|
import { useDispatch } from '../../context/DispatchContext';
|
|
9
|
+
import { useGlobal } from '../../context/GlobalContext';
|
|
9
10
|
import ButtonToolTip from '../../elements/ButtonToolTip';
|
|
10
11
|
import MenuButton from '../../elements/MenuButton';
|
|
11
12
|
import ToolTip from '../../elements/ToolTip/ToolTip';
|
|
@@ -56,17 +57,22 @@ const MOL_EXPORT_MENU = [
|
|
|
56
57
|
},
|
|
57
58
|
];
|
|
58
59
|
export default function MoleculePanelHeader({ currentIndex, molecules, onMoleculeIndexChange = () => null, onOpenMoleculeEditor = () => null, actionsOptions = {}, }) {
|
|
60
|
+
const { rootRef } = useGlobal();
|
|
59
61
|
const alert = useAlert();
|
|
60
62
|
const dispatch = useDispatch();
|
|
61
63
|
const modal = useModal();
|
|
62
64
|
const assignmentData = useAssignmentData();
|
|
63
65
|
const saveAsSVGHandler = useCallback(() => {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
if (!rootRef)
|
|
67
|
+
return;
|
|
68
|
+
exportAsSVG(rootRef, `molSVG${currentIndex}`, 'molFile');
|
|
69
|
+
}, [rootRef, currentIndex]);
|
|
66
70
|
const saveAsPNGHandler = useCallback(() => {
|
|
67
|
-
|
|
71
|
+
if (!rootRef)
|
|
72
|
+
return;
|
|
73
|
+
copyPNGToClipboard(rootRef, `molSVG${currentIndex}`);
|
|
68
74
|
alert.success('MOL copied as PNG to clipboard');
|
|
69
|
-
}, [alert, currentIndex]);
|
|
75
|
+
}, [rootRef, alert, currentIndex]);
|
|
70
76
|
const saveAsMolHandler = useCallback(() => {
|
|
71
77
|
if (molecules[currentIndex]) {
|
|
72
78
|
void copyTextToClipboard(molecules[currentIndex].molfile).then((flag) => {
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { Range } from '../../../data/types/data1d';
|
|
2
|
+
import { Zone } from '../../../data/types/data2d';
|
|
3
|
+
import { AssignmentContext, Axis } from '../../assignment/AssignmentsContext';
|
|
4
|
+
interface Atom {
|
|
5
|
+
oclID: string;
|
|
6
|
+
atomLabel: string;
|
|
6
7
|
nbAtoms: number;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
nbHydrogens: number;
|
|
9
|
+
hydrogenOCLIDs: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface AtomData {
|
|
12
|
+
oclIDs: string[];
|
|
13
|
+
nbAtoms: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function extractFromAtom(atom: Atom, activeTab: string, axis?: Axis | null): AtomData;
|
|
16
|
+
export declare function findDatumAndSignalIndex(data: (Range | Zone)[], id: string): {
|
|
17
|
+
datum: Range | Zone | undefined;
|
|
10
18
|
signalIndex: any;
|
|
11
19
|
};
|
|
12
|
-
export declare function getHighlightsOnHover(
|
|
13
|
-
export declare function getCurrentDiaIDsToHighlight(assignmentData:
|
|
14
|
-
export declare function toggleDiaIDs(
|
|
20
|
+
export declare function getHighlightsOnHover(assignments: AssignmentContext, oclIDs: any, data: any): string[];
|
|
21
|
+
export declare function getCurrentDiaIDsToHighlight(assignmentData: AssignmentContext): string[];
|
|
22
|
+
export declare function toggleDiaIDs(diaIDs: string[], atomInformation: AtomData): (number | string[])[];
|
|
23
|
+
export {};
|
|
@@ -1,110 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
function getElements(activeTab) {
|
|
2
|
+
const nuclei = activeTab.split(',');
|
|
3
|
+
return nuclei.map((nucleus) => nucleus.replace(/[0-9]/g, ''));
|
|
4
|
+
}
|
|
5
|
+
export function extractFromAtom(atom, activeTab, axis) {
|
|
6
|
+
const elements = getElements(activeTab);
|
|
3
7
|
if (elements.length > 0 && Object.keys(atom).length > 0) {
|
|
4
|
-
const dim =
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
|
|
9
|
+
switch (dim !== null && elements[dim]) {
|
|
10
|
+
case atom.atomLabel: {
|
|
7
11
|
// take always oclID if atom type is same as element of activeTab)
|
|
8
12
|
return { oclIDs: [atom.oclID], nbAtoms: atom.nbAtoms };
|
|
9
13
|
}
|
|
10
|
-
|
|
14
|
+
case 'H': {
|
|
11
15
|
// if we are in proton spectrum and use then the IDs of attached hydrogens of an atom
|
|
12
16
|
return {
|
|
13
17
|
oclIDs: atom.hydrogenOCLIDs,
|
|
14
18
|
nbAtoms: atom.nbAtoms * atom.nbHydrogens,
|
|
15
19
|
};
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
};
|
|
21
|
+
default:
|
|
22
|
+
return {
|
|
23
|
+
oclIDs: [atom.oclID].concat(atom.hydrogenOCLIDs),
|
|
24
|
+
nbAtoms: atom.nbAtoms + atom.nbAtoms * atom.nbHydrogens,
|
|
25
|
+
};
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
return { oclIDs: [], nbAtoms: 0 };
|
|
26
29
|
}
|
|
27
|
-
export function findDatumAndSignalIndex(
|
|
30
|
+
export function findDatumAndSignalIndex(data, id) {
|
|
28
31
|
// if datum could be found then the id is on range/zone level
|
|
29
|
-
let datum =
|
|
32
|
+
let datum = data.find((_datum) => _datum.id === id);
|
|
30
33
|
let signalIndex;
|
|
31
34
|
if (!datum) {
|
|
32
35
|
// figure out the datum via id
|
|
33
|
-
for (const
|
|
34
|
-
signalIndex =
|
|
36
|
+
for (const record of data) {
|
|
37
|
+
signalIndex = record.signals.findIndex((signal) => signal.id === id);
|
|
35
38
|
if (signalIndex >= 0) {
|
|
36
|
-
datum =
|
|
39
|
+
datum = record;
|
|
37
40
|
break;
|
|
38
41
|
}
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
return { datum, signalIndex };
|
|
42
45
|
}
|
|
43
|
-
export function getHighlightsOnHover(
|
|
46
|
+
export function getHighlightsOnHover(assignments, oclIDs, data) {
|
|
44
47
|
// set all IDs to highlight when hovering over an atom from assignment data
|
|
45
48
|
let highlights = [];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
datum = result.datum;
|
|
60
|
-
signalIndex = result.signalIndex;
|
|
61
|
-
stop = true;
|
|
62
|
-
}
|
|
63
|
-
if (datum) {
|
|
64
|
-
highlights.push(datum.id);
|
|
65
|
-
if (signalIndex !== undefined) {
|
|
66
|
-
highlights.push(datum.signals[signalIndex].id);
|
|
49
|
+
const assignmentsByKey = assignments.data.assignments;
|
|
50
|
+
for (const key in assignmentsByKey) {
|
|
51
|
+
const assignments = assignmentsByKey[key];
|
|
52
|
+
for (const axis in assignments) {
|
|
53
|
+
if (assignments[axis]?.some((oclKey) => oclIDs.includes(oclKey))) {
|
|
54
|
+
highlights = highlights.concat(assignments[axis]);
|
|
55
|
+
const { datum, signalIndex } = findDatumAndSignalIndex(data, key);
|
|
56
|
+
if (datum) {
|
|
57
|
+
highlights.push(datum.id);
|
|
58
|
+
if (signalIndex !== undefined) {
|
|
59
|
+
highlights.push(datum.signals[signalIndex].id);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
67
62
|
}
|
|
68
63
|
}
|
|
69
|
-
if (stop) {
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
64
|
}
|
|
73
65
|
return highlights;
|
|
74
66
|
}
|
|
75
|
-
export function getCurrentDiaIDsToHighlight(assignmentData
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
: displayerMode === DISPLAYER_MODE.DM_2D
|
|
86
|
-
? axisOnHover
|
|
87
|
-
? axisOnHover === 'x'
|
|
88
|
-
? assignmentOnHover.x || []
|
|
89
|
-
: axisOnHover === 'y'
|
|
90
|
-
? assignmentOnHover.y || []
|
|
91
|
-
: (assignmentOnHover.x || []).concat(assignmentOnHover.y || [])
|
|
92
|
-
: (assignmentOnHover.x || []).concat(assignmentOnHover.y || [])
|
|
93
|
-
: []
|
|
94
|
-
: [];
|
|
67
|
+
export function getCurrentDiaIDsToHighlight(assignmentData) {
|
|
68
|
+
const { highlighted, assignments } = assignmentData.data;
|
|
69
|
+
const assignment = highlighted ? assignments[highlighted.id] : null;
|
|
70
|
+
const axisHover = highlighted ? highlighted.axis : null;
|
|
71
|
+
if (axisHover && assignment && assignment[axisHover]) {
|
|
72
|
+
return assignment[axisHover];
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
return (assignment?.x || []).concat(assignment?.y || []);
|
|
76
|
+
}
|
|
95
77
|
}
|
|
96
|
-
export function toggleDiaIDs(
|
|
97
|
-
let
|
|
78
|
+
export function toggleDiaIDs(diaIDs, atomInformation) {
|
|
79
|
+
let _diaIDs = diaIDs ? diaIDs.slice() : [];
|
|
98
80
|
const { nbAtoms, oclIDs } = atomInformation;
|
|
99
81
|
let tempNbAtoms = nbAtoms;
|
|
100
82
|
oclIDs.forEach((_oclID) => {
|
|
101
|
-
if (
|
|
83
|
+
if (_diaIDs.includes(_oclID)) {
|
|
102
84
|
tempNbAtoms *= -1;
|
|
103
|
-
|
|
85
|
+
_diaIDs = _diaIDs.filter((_id) => _id !== _oclID);
|
|
104
86
|
}
|
|
105
87
|
else {
|
|
106
|
-
|
|
88
|
+
_diaIDs.push(_oclID);
|
|
107
89
|
}
|
|
108
90
|
});
|
|
109
|
-
return [
|
|
91
|
+
return [_diaIDs, tempNbAtoms];
|
|
110
92
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default function useAtomAssignment({ displayerMode, activeTab, zones, ranges, }: {
|
|
1
|
+
export default function useAtomAssignment({ displayerMode, activeTab: nucleus, zones, ranges, }: {
|
|
2
2
|
displayerMode: any;
|
|
3
3
|
activeTab: any;
|
|
4
4
|
zones: any;
|
|
@@ -6,6 +6,6 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
|
|
|
6
6
|
}): {
|
|
7
7
|
handleOnAtomHover: (atom: any) => void;
|
|
8
8
|
handleOnClickAtom: (atom: any, event: any) => void;
|
|
9
|
-
currentDiaIDsToHighlight:
|
|
9
|
+
currentDiaIDsToHighlight: string[];
|
|
10
10
|
assignedDiaIDsMerged: any[];
|
|
11
11
|
};
|