nmrium 0.25.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/multiplicityTree/MultiplicityTree.js +5 -5
- package/lib/component/1d/ranges/Range.js +6 -5
- 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/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/elements/Button.js +2 -1
- 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/header/BaseLineCorrectionPanel.js +1 -1
- package/lib/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib/component/modal/setting/GeneralSettings.js +2 -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 +1 -1
- 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/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 +10 -13
- package/lib/component/reducer/types/Types.d.ts +1 -0
- package/lib/component/reducer/types/Types.js +1 -0
- 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/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/multiplicityTree/MultiplicityTree.js +6 -6
- package/lib-cjs/component/1d/ranges/Range.js +8 -7
- 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/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/elements/Button.js +2 -1
- 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/header/BaseLineCorrectionPanel.js +1 -1
- package/lib-cjs/component/modal/setting/FormattingTabContent.js +17 -11
- package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -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 +2 -2
- 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/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 +10 -13
- package/lib-cjs/component/reducer/types/Types.js +2 -1
- 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/toJSON.js +1 -0
- package/lib-cjs/versionInfo.js +1 -1
- package/package.json +19 -19
|
@@ -2,9 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
4
4
|
/** @jsxImportSource @emotion/react */
|
|
5
|
-
const react_1 = require("react");
|
|
5
|
+
const react_1 = require("@emotion/react");
|
|
6
|
+
const react_2 = require("react");
|
|
6
7
|
const index_1 = require("../../../highlight/index");
|
|
7
|
-
|
|
8
|
+
function highlightStyle(isActive, row) {
|
|
9
|
+
if (isActive) {
|
|
10
|
+
return { backgroundColor: '#ff6f0057' };
|
|
11
|
+
}
|
|
12
|
+
else if (row.original?.isConstantlyHighlighted === true) {
|
|
13
|
+
return { backgroundColor: '#f5f5dc' };
|
|
14
|
+
}
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
const rowCss = (0, react_1.css) `
|
|
18
|
+
&:hover {
|
|
19
|
+
background-color: #ff6f0091 !important;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&:active {
|
|
23
|
+
background-color: #ff6f0070 !important;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
8
26
|
function getIDs(row) {
|
|
9
27
|
const id = row.original.id;
|
|
10
28
|
if (id) {
|
|
@@ -18,24 +36,26 @@ function getIDs(row) {
|
|
|
18
36
|
return [''];
|
|
19
37
|
}
|
|
20
38
|
function ReactTableRow(props, ref) {
|
|
21
|
-
const { row, highlightedSource = index_1.HighlightedSource.UNKNOWN, onContextMenu, } = props;
|
|
22
|
-
const data = (0,
|
|
39
|
+
const { row, highlightedSource = index_1.HighlightedSource.UNKNOWN, onContextMenu, onClick, isRowActive = false, } = props;
|
|
40
|
+
const data = (0, react_2.useMemo)(() => ({
|
|
23
41
|
type: highlightedSource,
|
|
24
42
|
extra: row.original,
|
|
25
43
|
}), [highlightedSource, row]);
|
|
26
44
|
const highlight = (0, index_1.useHighlight)(getIDs(row), data);
|
|
27
|
-
(0,
|
|
45
|
+
(0, react_2.useEffect)(() => {
|
|
28
46
|
return () => {
|
|
29
47
|
highlight.hide();
|
|
30
48
|
};
|
|
31
49
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
50
|
}, []);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
const clickHandler = (0, react_2.useCallback)((event) => {
|
|
52
|
+
onClick?.(event, row);
|
|
53
|
+
}, [onClick, row]);
|
|
54
|
+
return (0, react_2.useMemo)(() => {
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)("tr", { ref: ref, onContextMenu: onContextMenu, css: [
|
|
56
|
+
highlightStyle(highlight.isActive || isRowActive, row),
|
|
57
|
+
onClick && rowCss,
|
|
58
|
+
], ...row.getRowProps(), ...highlight.onHover, children: row.cells.map((cell) => {
|
|
39
59
|
const { style, padding } = cell.column;
|
|
40
60
|
if (cell.isRowSpanned) {
|
|
41
61
|
return null;
|
|
@@ -44,9 +64,17 @@ function ReactTableRow(props, ref) {
|
|
|
44
64
|
return ((0, jsx_runtime_1.jsx)("td", { rowSpan: cell.rowSpan, ...cell.getCellProps(), onContextMenu: (e) => {
|
|
45
65
|
e.preventDefault();
|
|
46
66
|
return false;
|
|
47
|
-
}, style: { padding, ...style }, children: cell.render('Cell') }, cell.key));
|
|
67
|
+
}, style: { padding, ...style }, onClick: clickHandler, children: cell.render('Cell') }, cell.key));
|
|
48
68
|
}
|
|
49
69
|
}) }, row.getRowProps().key));
|
|
50
|
-
}, [
|
|
70
|
+
}, [
|
|
71
|
+
clickHandler,
|
|
72
|
+
highlight.isActive,
|
|
73
|
+
highlight.onHover,
|
|
74
|
+
onClick,
|
|
75
|
+
onContextMenu,
|
|
76
|
+
ref,
|
|
77
|
+
row,
|
|
78
|
+
]);
|
|
51
79
|
}
|
|
52
|
-
exports.default = (0,
|
|
80
|
+
exports.default = (0, react_2.forwardRef)(ReactTableRow);
|
|
@@ -47,9 +47,10 @@ const styles = {
|
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
const ReactTableInner = (0, react_1.forwardRef)(function ReactTableInner(props, ref) {
|
|
50
|
-
const { data, columns, highlightedSource, context = null, onScroll, approxItemHeight = 40, enableVirtualScroll = false, groupKey, } = props;
|
|
50
|
+
const { data, columns, highlightedSource, context = null, onScroll, approxItemHeight = 40, enableVirtualScroll = false, groupKey, onClick, highlightActiveRow = false, } = props;
|
|
51
51
|
const contextRef = (0, react_1.useRef)(null);
|
|
52
52
|
const { index: indexBoundary } = (0, ReactTableContext_1.useReactTableContext)();
|
|
53
|
+
const [rowIndex, setRowIndex] = (0, react_1.useState)();
|
|
53
54
|
const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow, rowSpanHeaders, } = (0, react_table_1.useTable)({
|
|
54
55
|
columns,
|
|
55
56
|
data,
|
|
@@ -63,6 +64,10 @@ const ReactTableInner = (0, react_1.forwardRef)(function ReactTableInner(props,
|
|
|
63
64
|
const rowsData = enableVirtualScroll
|
|
64
65
|
? rows.slice(indexBoundary.start, indexBoundary.end)
|
|
65
66
|
: rows;
|
|
67
|
+
const clickHandler = (0, react_1.useCallback)((event, row) => {
|
|
68
|
+
setRowIndex(row.index);
|
|
69
|
+
onClick?.(event, row);
|
|
70
|
+
}, [onClick]);
|
|
66
71
|
return ((0, jsx_runtime_1.jsxs)("div", { ref: ref, className: "table-container", style: {
|
|
67
72
|
overflowY: 'auto',
|
|
68
73
|
position: 'relative',
|
|
@@ -75,7 +80,7 @@ const ReactTableInner = (0, react_1.forwardRef)(function ReactTableInner(props,
|
|
|
75
80
|
} })), (0, jsx_runtime_1.jsxs)("table", { ...getTableProps(), css: Style_1.ReactTableStyle, style: styles.table(enableVirtualScroll), children: [(0, jsx_runtime_1.jsx)(ReactTableHeader_1.default, { headerGroups: headerGroups }), (0, jsx_runtime_1.jsx)("tbody", { ...getTableBodyProps(), children: rowsData.map((row, index) => {
|
|
76
81
|
prepareRow(row);
|
|
77
82
|
(0, useRowSpan_1.prepareRowSpan)(rows, enableVirtualScroll ? index + indexBoundary.start : index, rowSpanHeaders, groupKey);
|
|
78
|
-
return ((0, jsx_runtime_1.jsx)(ReactTableRow_1.default, { row: row, ...row.getRowProps(), onContextMenu: (e) => contextMenuHandler(e, row), highlightedSource: highlightedSource }, row.key));
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(ReactTableRow_1.default, { row: row, ...row.getRowProps(), onContextMenu: (e) => contextMenuHandler(e, row), onClick: highlightActiveRow ? clickHandler : onClick, highlightedSource: highlightedSource, isRowActive: rowIndex === index }, row.key));
|
|
79
84
|
}) })] }), (0, jsx_runtime_1.jsx)(ContextMenu_1.default, { ref: contextRef, context: context })] }));
|
|
80
85
|
});
|
|
81
86
|
function ReactTable(props) {
|
|
@@ -1,15 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ReactTableStyle = void 0;
|
|
4
4
|
const react_1 = require("@emotion/react");
|
|
5
|
-
const HighlightedRowStyle = (0, react_1.css) `
|
|
6
|
-
background-color: #ff6f0057;
|
|
7
|
-
`;
|
|
8
|
-
exports.HighlightedRowStyle = HighlightedRowStyle;
|
|
9
|
-
const ConstantlyHighlightedRowStyle = (0, react_1.css) `
|
|
10
|
-
background-color: #f5f5dc;
|
|
11
|
-
`;
|
|
12
|
-
exports.ConstantlyHighlightedRowStyle = ConstantlyHighlightedRowStyle;
|
|
13
5
|
const ReactTableStyle = (0, react_1.css) `
|
|
14
6
|
border-spacing: 0;
|
|
15
7
|
border: 1px solid #dedede;
|
|
@@ -31,12 +31,12 @@ const react_1 = require("react");
|
|
|
31
31
|
const Yup = __importStar(require("yup"));
|
|
32
32
|
const baselineCorrection_1 = require("../../data/data1d/filter1d/baselineCorrection");
|
|
33
33
|
const DispatchContext_1 = require("../context/DispatchContext");
|
|
34
|
+
const ActionButtons_1 = __importDefault(require("../elements/ActionButtons"));
|
|
34
35
|
const Label_1 = __importDefault(require("../elements/Label"));
|
|
35
36
|
const Select_1 = __importDefault(require("../elements/Select"));
|
|
36
37
|
const FormikForm_1 = __importDefault(require("../elements/formik/FormikForm"));
|
|
37
38
|
const FormikInput_1 = __importDefault(require("../elements/formik/FormikInput"));
|
|
38
39
|
const Types_1 = require("../reducer/types/Types");
|
|
39
|
-
const ActionButtons_1 = __importDefault(require("../elements/ActionButtons"));
|
|
40
40
|
const styles = {
|
|
41
41
|
container: {
|
|
42
42
|
padding: '5px',
|
|
@@ -52,24 +52,30 @@ const styles = (0, react_1.css) `
|
|
|
52
52
|
`;
|
|
53
53
|
function FormattingTabContent() {
|
|
54
54
|
const { values, setFieldValue } = (0, formik_1.useFormikContext)();
|
|
55
|
-
const
|
|
56
|
-
const deleteHandler = (0, react_2.useCallback)((
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const nuclei = (0, react_2.useMemo)(() => (0, get_1.default)(values, 'formatting.nuclei', {}), [values]);
|
|
56
|
+
const deleteHandler = (0, react_2.useCallback)((key) => {
|
|
57
|
+
let _nuclei = {};
|
|
58
|
+
for (const nucleus in nuclei) {
|
|
59
|
+
if (nucleus !== key) {
|
|
60
|
+
_nuclei[nucleus] = nuclei[nucleus];
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
setFieldValue('formatting.nuclei', _nuclei);
|
|
64
|
+
}, [nuclei, setFieldValue]);
|
|
60
65
|
const addNewNucleusFormatHandler = (0, react_2.useCallback)(() => {
|
|
61
66
|
const newFormat = {
|
|
62
|
-
key: (0, generateID_1.default)(),
|
|
63
67
|
name: '',
|
|
64
68
|
ppm: '0.00',
|
|
65
69
|
hz: '0.00',
|
|
66
70
|
};
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
const key = (0, generateID_1.default)();
|
|
72
|
+
const newNuclei = { ...nuclei, [key]: newFormat };
|
|
73
|
+
setFieldValue('formatting.nuclei', newNuclei);
|
|
74
|
+
}, [nuclei, setFieldValue]);
|
|
75
|
+
const nucleiList = Object.keys(nuclei);
|
|
76
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { className: "section-header", children: "Nuclei Formatting" }), (0, jsx_runtime_1.jsx)("div", { css: styles, children: (0, jsx_runtime_1.jsxs)("table", { children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { className: "counter-col", children: "#" }), (0, jsx_runtime_1.jsx)("th", { className: "nucleus-label-col", children: "Nucleus " }), (0, jsx_runtime_1.jsx)("th", { className: "nucleus-format-input-col", children: "\u03B4 (ppm)" }), (0, jsx_runtime_1.jsx)("th", { className: "nucleus-format-input-col", children: "Coupling (Hz)" }), (0, jsx_runtime_1.jsx)("th", { className: "nucleus-format-input-col" })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: nucleiList?.map((key, index) => {
|
|
71
77
|
const num = index + 1;
|
|
72
|
-
return ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsxs)("td", { className: "counter-col", children: [(0, jsx_runtime_1.jsxs)("span", { children: [num, " - "] }), ' '] }), (0, jsx_runtime_1.jsx)("td", { className: "nucleus-label-col", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `formatting.
|
|
78
|
+
return ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsxs)("td", { className: "counter-col", children: [(0, jsx_runtime_1.jsxs)("span", { children: [num, " - "] }), ' '] }), (0, jsx_runtime_1.jsx)("td", { className: "nucleus-label-col", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `formatting.nuclei.${key}.name`, className: "width-100", checkErrorAfterInputTouched: false }) }), (0, jsx_runtime_1.jsx)("td", { className: "nucleus-format-input-col", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `formatting.nuclei.${key}.ppm`, className: "width-100" }) }), (0, jsx_runtime_1.jsx)("td", { className: "nucleus-format-input-col", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `formatting.nuclei.${key}.hz`, className: "width-100" }) }), (0, jsx_runtime_1.jsxs)("td", { className: "operation-container", children: [(0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: () => deleteHandler(key), popupTitle: `remove ${nuclei[key].name}`, popupPlacement: "right" }), nucleiList.length === index + 1 && ((0, jsx_runtime_1.jsx)("button", { className: "add", type: "button", onClick: addNewNucleusFormatHandler, children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }))] })] }, `${key}`));
|
|
73
79
|
}) })] }) })] }));
|
|
74
80
|
}
|
|
75
81
|
exports.default = FormattingTabContent;
|
|
@@ -43,6 +43,7 @@ const ControllersTabContent_1 = __importDefault(require("./ControllersTabContent
|
|
|
43
43
|
const DisplayTabContent_1 = __importDefault(require("./DisplayTabContent"));
|
|
44
44
|
const FormattingTabContent_1 = __importDefault(require("./FormattingTabContent"));
|
|
45
45
|
const WorkspaceItem_1 = __importDefault(require("./WorkspaceItem"));
|
|
46
|
+
const settingsValidation_1 = require("./settingsValidation");
|
|
46
47
|
const styles = (0, react_1.css) `
|
|
47
48
|
.main-content {
|
|
48
49
|
width: 100%;
|
|
@@ -174,6 +175,6 @@ function GeneralSettings({ onClose }) {
|
|
|
174
175
|
const renderItem = (0, react_2.useCallback)((item) => {
|
|
175
176
|
return ((0, jsx_runtime_1.jsx)(WorkspaceItem_1.default, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
|
|
176
177
|
}, [addWorkSpaceHandler, deleteWorkSpaceHandler]);
|
|
177
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: "General Settings" }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose, className: "close-bt" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "workspace-container", children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "Workspace : " }), (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), (0, jsx_runtime_1.jsx)("div", { className: "main-content", children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { ref: refForm, initialValues: preferences.current, onSubmit: submitHandler, children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { position: Tabs_1.PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [(0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Controllers", tabid: "controllers", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(ControllersTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Formatting", tabid: "formatting", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(FormattingTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Display", tabid: "display", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DisplayTabContent_1.default, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), (0, jsx_runtime_1.jsx)("div", { className: "footer-container", children: (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
|
|
178
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: "General Settings" }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose, className: "close-bt" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "workspace-container", children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "Workspace : " }), (0, jsx_runtime_1.jsx)(DropDownButton_1.default, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), (0, jsx_runtime_1.jsx)("div", { className: "main-content", children: (0, jsx_runtime_1.jsx)(FormikForm_1.default, { ref: refForm, initialValues: preferences.current, validationSchema: settingsValidation_1.validation, onSubmit: submitHandler, children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { position: Tabs_1.PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [(0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Controllers", tabid: "controllers", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(ControllersTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Formatting", tabid: "formatting", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(FormattingTabContent_1.default, {}) }) }), (0, jsx_runtime_1.jsx)(Tab_1.default, { tablabel: "Display", tabid: "display", children: (0, jsx_runtime_1.jsx)("div", { className: "inner-content", children: (0, jsx_runtime_1.jsx)(DisplayTabContent_1.default, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), (0, jsx_runtime_1.jsx)("div", { className: "footer-container", children: (0, jsx_runtime_1.jsx)(ActionButtons_1.default, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
|
|
178
179
|
}
|
|
179
180
|
exports.default = GeneralSettings;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.validation = void 0;
|
|
27
|
+
const Yup = __importStar(require("yup"));
|
|
28
|
+
const formattingValidation = (obj) => Object.keys(obj.formatting.nuclei).reduce((validate, key) => {
|
|
29
|
+
validate[key] = Yup.object().shape({
|
|
30
|
+
name: Yup.string().trim().required('Nucleus is a required field'),
|
|
31
|
+
ppm: Yup.string().trim().required('PPM format is a required field'),
|
|
32
|
+
hz: Yup.string().trim().required('Hz format is a required field'),
|
|
33
|
+
});
|
|
34
|
+
return validate;
|
|
35
|
+
}, {});
|
|
36
|
+
exports.validation = Yup.lazy((obj) => Yup.object().shape({
|
|
37
|
+
formatting: Yup.object().shape({
|
|
38
|
+
nuclei: Yup.object()
|
|
39
|
+
.shape(formattingValidation(obj))
|
|
40
|
+
.test('Unique', 'Nuclei need te be unique', function check(nuclei) {
|
|
41
|
+
let nucleusFrequencies = {};
|
|
42
|
+
for (const key of Object.keys(nuclei)) {
|
|
43
|
+
const _key = nuclei[key].name?.toLowerCase() || '';
|
|
44
|
+
if (_key) {
|
|
45
|
+
if (nucleusFrequencies[_key]) {
|
|
46
|
+
++nucleusFrequencies[_key].value;
|
|
47
|
+
nucleusFrequencies[_key].fields.push(key);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
nucleusFrequencies[_key] = { value: 1, fields: [key] };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const errors = Object.keys(nucleusFrequencies).reduce((errorList, key) => {
|
|
55
|
+
const { value, fields } = nucleusFrequencies[key];
|
|
56
|
+
if (value > 1) {
|
|
57
|
+
for (let field of fields) {
|
|
58
|
+
errorList.push(new Yup.ValidationError(`${key} nucleus must te be unique`, nuclei[key].name, `${this.path}.${field}.name`));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return errorList;
|
|
62
|
+
}, []);
|
|
63
|
+
return new Yup.ValidationError(errors);
|
|
64
|
+
}),
|
|
65
|
+
}),
|
|
66
|
+
}));
|
|
@@ -6,13 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
|
|
7
7
|
/** @jsxImportSource @emotion/react */
|
|
8
8
|
const cheminfo_font_1 = require("cheminfo-font");
|
|
9
|
-
const
|
|
9
|
+
const fa_1 = require("react-icons/fa");
|
|
10
10
|
const ButtonToolTip_1 = __importDefault(require("../../elements/ButtonToolTip"));
|
|
11
11
|
const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
|
|
12
12
|
const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
|
|
13
|
+
const SpectraAutomaticPickingButton_1 = require("../header/SpectraAutomaticPickingButton");
|
|
14
|
+
const AutomaticAssignmentTable_1 = __importDefault(require("./AutomaticAssignmentTable"));
|
|
15
|
+
const useAutoAssignments_1 = require("./useAutoAssignments");
|
|
13
16
|
function AutomaticAssignment() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)("div", { css: BasicPanelStyle_1.tablePanelStyle, children: [(0, jsx_runtime_1.jsx)(DefaultPanelHeader_1.default, { showSettingButton: false, canDelete: false, children: (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "automatic assignment", onClick: automaticAssignmentHandler, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrAssignment2, { style: { fontSize: '18px' } }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "inner-container" })] }));
|
|
17
|
+
const { getAssignments, assignments, restAssignments } = (0, useAutoAssignments_1.useAutoAssignments)();
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)("div", { css: BasicPanelStyle_1.tablePanelStyle, children: [(0, jsx_runtime_1.jsxs)(DefaultPanelHeader_1.default, { showSettingButton: false, canDelete: false, children: [(0, jsx_runtime_1.jsx)(SpectraAutomaticPickingButton_1.SpectraAutomaticPickingButton, {}), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "automatic assignment", onClick: getAssignments, children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrAssignment2, { style: { fontSize: '18px' } }) }), (0, jsx_runtime_1.jsx)(ButtonToolTip_1.default, { popupTitle: "reset assignment", onClick: restAssignments, children: (0, jsx_runtime_1.jsx)(fa_1.FaBolt, {}) })] }), (0, jsx_runtime_1.jsx)("div", { className: "inner-container", children: (0, jsx_runtime_1.jsx)(AutomaticAssignmentTable_1.default, { data: assignments }) })] }));
|
|
17
19
|
}
|
|
18
20
|
exports.default = AutomaticAssignment;
|
|
@@ -6,15 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const cheminfo_font_1 = require("cheminfo-font");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
+
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
9
10
|
const ReactTable_1 = __importDefault(require("../../elements/ReactTable/ReactTable"));
|
|
11
|
+
const Types_1 = require("../../reducer/types/Types");
|
|
10
12
|
const NoTableData_1 = __importDefault(require("../extra/placeholder/NoTableData"));
|
|
11
|
-
function
|
|
13
|
+
function AutomaticAssignmentTable({ data }) {
|
|
14
|
+
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
12
15
|
const assignHandler = (0, react_1.useCallback)((e, row) => {
|
|
13
16
|
e.preventDefault();
|
|
14
17
|
e.stopPropagation();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const assignments = row.original.assignment;
|
|
19
|
+
dispatch({
|
|
20
|
+
type: Types_1.SET_AUTOMATIC_ASSIGNMENTS,
|
|
21
|
+
payload: { assignments },
|
|
22
|
+
});
|
|
23
|
+
}, [dispatch]);
|
|
18
24
|
const COLUMNS = (0, react_1.useMemo)(() => [
|
|
19
25
|
{
|
|
20
26
|
index: 1,
|
|
@@ -25,6 +31,7 @@ function PeaksTable({ data }) {
|
|
|
25
31
|
{
|
|
26
32
|
index: 2,
|
|
27
33
|
Header: 'Score',
|
|
34
|
+
accessor: 'score',
|
|
28
35
|
},
|
|
29
36
|
{
|
|
30
37
|
index: 3,
|
|
@@ -38,6 +45,6 @@ function PeaksTable({ data }) {
|
|
|
38
45
|
Cell: ({ row }) => ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "assign-button", onClick: (e) => assignHandler(e, row), children: (0, jsx_runtime_1.jsx)(cheminfo_font_1.SvgNmrAssignment, {}) })),
|
|
39
46
|
},
|
|
40
47
|
], [assignHandler]);
|
|
41
|
-
return data && data.length > 0 ? ((0, jsx_runtime_1.jsx)(ReactTable_1.default, { data: data, columns: COLUMNS })) : ((0, jsx_runtime_1.jsx)(NoTableData_1.default, {}));
|
|
48
|
+
return data && data.length > 0 ? ((0, jsx_runtime_1.jsx)(ReactTable_1.default, { data: data, columns: COLUMNS, onClick: assignHandler, highlightActiveRow: true })) : ((0, jsx_runtime_1.jsx)(NoTableData_1.default, {}));
|
|
42
49
|
}
|
|
43
|
-
exports.default = (0, react_1.memo)(
|
|
50
|
+
exports.default = (0, react_1.memo)(AutomaticAssignmentTable);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useAutoAssignments = void 0;
|
|
7
|
+
const nmr_processing_1 = require("nmr-processing");
|
|
8
|
+
const full_1 = __importDefault(require("openchemlib/full"));
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const ChartContext_1 = require("../../context/ChartContext");
|
|
11
|
+
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
12
|
+
const Alert_1 = require("../../elements/popup/Alert");
|
|
13
|
+
const Types_1 = require("../../reducer/types/Types");
|
|
14
|
+
function mapSpectra(data) {
|
|
15
|
+
return data.reduce((acc, spectrum) => {
|
|
16
|
+
const { id, info } = spectrum;
|
|
17
|
+
const dimension = spectrum.info.dimension;
|
|
18
|
+
if (dimension === 1) {
|
|
19
|
+
const ranges = spectrum.ranges.values;
|
|
20
|
+
acc.push({ id, info, ranges });
|
|
21
|
+
}
|
|
22
|
+
else if (dimension === 2) {
|
|
23
|
+
const zones = spectrum.zones.values;
|
|
24
|
+
acc.push({ id, info, zones });
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
function useAutoAssignments() {
|
|
30
|
+
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
31
|
+
const { data, molecules } = (0, ChartContext_1.useChartData)();
|
|
32
|
+
const originData = (0, react_1.useRef)();
|
|
33
|
+
const alert = (0, Alert_1.useAlert)();
|
|
34
|
+
const [assignments, setAssignments] = (0, react_1.useState)([]);
|
|
35
|
+
const restAssignments = (0, react_1.useCallback)(() => {
|
|
36
|
+
dispatch({
|
|
37
|
+
type: Types_1.SET_AUTOMATIC_ASSIGNMENTS,
|
|
38
|
+
payload: { assignments: originData.current },
|
|
39
|
+
});
|
|
40
|
+
}, [dispatch]);
|
|
41
|
+
const getAssignments = (0, react_1.useCallback)(() => {
|
|
42
|
+
void (async () => {
|
|
43
|
+
const hideLoading = await alert.showLoading('Auto Assignments');
|
|
44
|
+
const molecule = full_1.default.Molecule.fromMolfile(molecules[0]?.molfile || '');
|
|
45
|
+
const spectra = mapSpectra(data);
|
|
46
|
+
if (!originData.current) {
|
|
47
|
+
originData.current = spectra;
|
|
48
|
+
}
|
|
49
|
+
const result = await (0, nmr_processing_1.getAssignments)({
|
|
50
|
+
spectra,
|
|
51
|
+
molecule,
|
|
52
|
+
}, { minScore: 0 });
|
|
53
|
+
dispatch({
|
|
54
|
+
type: Types_1.SET_AUTOMATIC_ASSIGNMENTS,
|
|
55
|
+
payload: { assignments: result[0].assignment },
|
|
56
|
+
});
|
|
57
|
+
hideLoading();
|
|
58
|
+
setAssignments(result);
|
|
59
|
+
})();
|
|
60
|
+
}, [alert, data, dispatch, molecules]);
|
|
61
|
+
return (0, react_1.useMemo)(() => ({
|
|
62
|
+
getAssignments,
|
|
63
|
+
assignments,
|
|
64
|
+
restAssignments,
|
|
65
|
+
}), [assignments, getAssignments, restAssignments]);
|
|
66
|
+
}
|
|
67
|
+
exports.useAutoAssignments = useAutoAssignments;
|
|
@@ -9,7 +9,7 @@ const react_1 = require("@emotion/react");
|
|
|
9
9
|
const cheminfo_font_1 = require("cheminfo-font");
|
|
10
10
|
const react_2 = require("react");
|
|
11
11
|
const fa_1 = require("react-icons/fa");
|
|
12
|
-
const
|
|
12
|
+
const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
|
|
13
13
|
const DispatchContext_1 = require("../../context/DispatchContext");
|
|
14
14
|
const GlobalContext_1 = require("../../context/GlobalContext");
|
|
15
15
|
const ButtonToolTip_1 = __importDefault(require("../../elements/ButtonToolTip"));
|
|
@@ -66,7 +66,7 @@ function MoleculePanelHeader({ currentIndex, molecules, onMoleculeIndexChange =
|
|
|
66
66
|
const alert = (0, Alert_1.useAlert)();
|
|
67
67
|
const dispatch = (0, DispatchContext_1.useDispatch)();
|
|
68
68
|
const modal = (0, Modal_1.useModal)();
|
|
69
|
-
const assignmentData = (0,
|
|
69
|
+
const assignmentData = (0, AssignmentsContext_1.useAssignmentData)();
|
|
70
70
|
const saveAsSVGHandler = (0, react_2.useCallback)(() => {
|
|
71
71
|
if (!rootRef)
|
|
72
72
|
return;
|
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.toggleDiaIDs = exports.getCurrentDiaIDsToHighlight = exports.getHighlightsOnHover = exports.findDatumAndSignalIndex = exports.extractFromAtom = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
function getElements(activeTab) {
|
|
5
|
+
const nuclei = activeTab.split(',');
|
|
6
|
+
return nuclei.map((nucleus) => nucleus.replace(/[0-9]/g, ''));
|
|
7
|
+
}
|
|
8
|
+
function extractFromAtom(atom, activeTab, axis) {
|
|
9
|
+
const elements = getElements(activeTab);
|
|
6
10
|
if (elements.length > 0 && Object.keys(atom).length > 0) {
|
|
7
|
-
const dim =
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
|
|
12
|
+
switch (dim !== null && elements[dim]) {
|
|
13
|
+
case atom.atomLabel: {
|
|
10
14
|
// take always oclID if atom type is same as element of activeTab)
|
|
11
15
|
return { oclIDs: [atom.oclID], nbAtoms: atom.nbAtoms };
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
case 'H': {
|
|
14
18
|
// if we are in proton spectrum and use then the IDs of attached hydrogens of an atom
|
|
15
19
|
return {
|
|
16
20
|
oclIDs: atom.hydrogenOCLIDs,
|
|
17
21
|
nbAtoms: atom.nbAtoms * atom.nbHydrogens,
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
24
|
+
default:
|
|
25
|
+
return {
|
|
26
|
+
oclIDs: [atom.oclID].concat(atom.hydrogenOCLIDs),
|
|
27
|
+
nbAtoms: atom.nbAtoms + atom.nbAtoms * atom.nbHydrogens,
|
|
28
|
+
};
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
return { oclIDs: [], nbAtoms: 0 };
|
|
29
32
|
}
|
|
30
33
|
exports.extractFromAtom = extractFromAtom;
|
|
31
|
-
function findDatumAndSignalIndex(
|
|
34
|
+
function findDatumAndSignalIndex(data, id) {
|
|
32
35
|
// if datum could be found then the id is on range/zone level
|
|
33
|
-
let datum =
|
|
36
|
+
let datum = data.find((_datum) => _datum.id === id);
|
|
34
37
|
let signalIndex;
|
|
35
38
|
if (!datum) {
|
|
36
39
|
// figure out the datum via id
|
|
37
|
-
for (const
|
|
38
|
-
signalIndex =
|
|
40
|
+
for (const record of data) {
|
|
41
|
+
signalIndex = record.signals.findIndex((signal) => signal.id === id);
|
|
39
42
|
if (signalIndex >= 0) {
|
|
40
|
-
datum =
|
|
43
|
+
datum = record;
|
|
41
44
|
break;
|
|
42
45
|
}
|
|
43
46
|
}
|
|
@@ -45,74 +48,53 @@ function findDatumAndSignalIndex(spectraData, id) {
|
|
|
45
48
|
return { datum, signalIndex };
|
|
46
49
|
}
|
|
47
50
|
exports.findDatumAndSignalIndex = findDatumAndSignalIndex;
|
|
48
|
-
function getHighlightsOnHover(
|
|
51
|
+
function getHighlightsOnHover(assignments, oclIDs, data) {
|
|
49
52
|
// set all IDs to highlight when hovering over an atom from assignment data
|
|
50
53
|
let highlights = [];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
datum = result.datum;
|
|
65
|
-
signalIndex = result.signalIndex;
|
|
66
|
-
stop = true;
|
|
67
|
-
}
|
|
68
|
-
if (datum) {
|
|
69
|
-
highlights.push(datum.id);
|
|
70
|
-
if (signalIndex !== undefined) {
|
|
71
|
-
highlights.push(datum.signals[signalIndex].id);
|
|
54
|
+
const assignmentsByKey = assignments.data.assignments;
|
|
55
|
+
for (const key in assignmentsByKey) {
|
|
56
|
+
const assignments = assignmentsByKey[key];
|
|
57
|
+
for (const axis in assignments) {
|
|
58
|
+
if (assignments[axis]?.some((oclKey) => oclIDs.includes(oclKey))) {
|
|
59
|
+
highlights = highlights.concat(assignments[axis]);
|
|
60
|
+
const { datum, signalIndex } = findDatumAndSignalIndex(data, key);
|
|
61
|
+
if (datum) {
|
|
62
|
+
highlights.push(datum.id);
|
|
63
|
+
if (signalIndex !== undefined) {
|
|
64
|
+
highlights.push(datum.signals[signalIndex].id);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
72
67
|
}
|
|
73
68
|
}
|
|
74
|
-
if (stop) {
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
69
|
}
|
|
78
70
|
return highlights;
|
|
79
71
|
}
|
|
80
72
|
exports.getHighlightsOnHover = getHighlightsOnHover;
|
|
81
|
-
function getCurrentDiaIDsToHighlight(assignmentData
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
: displayerMode === Constants_1.DISPLAYER_MODE.DM_2D
|
|
92
|
-
? axisOnHover
|
|
93
|
-
? axisOnHover === 'x'
|
|
94
|
-
? assignmentOnHover.x || []
|
|
95
|
-
: axisOnHover === 'y'
|
|
96
|
-
? assignmentOnHover.y || []
|
|
97
|
-
: (assignmentOnHover.x || []).concat(assignmentOnHover.y || [])
|
|
98
|
-
: (assignmentOnHover.x || []).concat(assignmentOnHover.y || [])
|
|
99
|
-
: []
|
|
100
|
-
: [];
|
|
73
|
+
function getCurrentDiaIDsToHighlight(assignmentData) {
|
|
74
|
+
const { highlighted, assignments } = assignmentData.data;
|
|
75
|
+
const assignment = highlighted ? assignments[highlighted.id] : null;
|
|
76
|
+
const axisHover = highlighted ? highlighted.axis : null;
|
|
77
|
+
if (axisHover && assignment && assignment[axisHover]) {
|
|
78
|
+
return assignment[axisHover];
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return (assignment?.x || []).concat(assignment?.y || []);
|
|
82
|
+
}
|
|
101
83
|
}
|
|
102
84
|
exports.getCurrentDiaIDsToHighlight = getCurrentDiaIDsToHighlight;
|
|
103
|
-
function toggleDiaIDs(
|
|
104
|
-
let
|
|
85
|
+
function toggleDiaIDs(diaIDs, atomInformation) {
|
|
86
|
+
let _diaIDs = diaIDs ? diaIDs.slice() : [];
|
|
105
87
|
const { nbAtoms, oclIDs } = atomInformation;
|
|
106
88
|
let tempNbAtoms = nbAtoms;
|
|
107
89
|
oclIDs.forEach((_oclID) => {
|
|
108
|
-
if (
|
|
90
|
+
if (_diaIDs.includes(_oclID)) {
|
|
109
91
|
tempNbAtoms *= -1;
|
|
110
|
-
|
|
92
|
+
_diaIDs = _diaIDs.filter((_id) => _id !== _oclID);
|
|
111
93
|
}
|
|
112
94
|
else {
|
|
113
|
-
|
|
95
|
+
_diaIDs.push(_oclID);
|
|
114
96
|
}
|
|
115
97
|
});
|
|
116
|
-
return [
|
|
98
|
+
return [_diaIDs, tempNbAtoms];
|
|
117
99
|
}
|
|
118
100
|
exports.toggleDiaIDs = toggleDiaIDs;
|