nmrium 0.59.0 → 0.60.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/lib/component/1d/LinesSeries.js +17 -5
  2. package/lib/component/1d/Viewer1D.js +10 -4
  3. package/lib/component/1d/ranges/Range.js +4 -2
  4. package/lib/component/1d/tool/PivotIndicator.d.ts +1 -0
  5. package/lib/component/1d/tool/{VerticalIndicator.js → PivotIndicator.js} +8 -4
  6. package/lib/component/1d-2d/tools/BrushXY.js +0 -1
  7. package/lib/component/1d-2d/tools/CrossLinePointer.js +0 -1
  8. package/lib/component/2d/Viewer2D.js +1 -1
  9. package/lib/component/2d/tools/PivotIndicator.d.ts +1 -2
  10. package/lib/component/2d/tools/PivotIndicator.js +2 -3
  11. package/lib/component/elements/DialogManager.d.ts +34 -0
  12. package/lib/component/elements/DialogManager.js +96 -0
  13. package/lib/component/elements/DraggableDialog.d.ts +13 -0
  14. package/lib/component/elements/DraggableDialog.js +156 -0
  15. package/lib/component/elements/TabTitle.d.ts +9 -0
  16. package/lib/component/elements/TabTitle.js +18 -0
  17. package/lib/component/header/ApodizationOptionsPanel.js +2 -2
  18. package/lib/component/hooks/useSaveSettings.d.ts +1 -1
  19. package/lib/component/hooks/useSaveSettings.js +18 -22
  20. package/lib/component/main/InnerNMRium.js +2 -2
  21. package/lib/component/main/InnerNMRiumContents.js +5 -0
  22. package/lib/component/modal/EditPeakShapeModal.d.ts +4 -6
  23. package/lib/component/modal/EditPeakShapeModal.js +45 -33
  24. package/lib/component/modal/editRange/EditRangeModal.d.ts +2 -10
  25. package/lib/component/modal/editRange/EditRangeModal.js +26 -54
  26. package/lib/component/modal/editZone/EditZoneModal.d.ts +3 -8
  27. package/lib/component/modal/editZone/EditZoneModal.js +74 -91
  28. package/lib/component/modal/editZone/SignalsForm.d.ts +1 -2
  29. package/lib/component/modal/editZone/SignalsForm.js +33 -50
  30. package/lib/component/modal/editZone/validation/isDefaultPathLength.d.ts +1 -2
  31. package/lib/component/modal/editZone/validation/isDefaultPathLength.js +3 -5
  32. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -3
  33. package/lib/component/panels/PeaksPanel/PeaksTable.js +7 -13
  34. package/lib/component/panels/RangesPanel/RangesHeader.js +0 -3
  35. package/lib/component/panels/RangesPanel/RangesTable.js +6 -3
  36. package/lib/component/panels/RangesPanel/TableColumns/ActionsColumn.js +21 -3
  37. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.d.ts +6 -5
  38. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +41 -64
  39. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.d.ts +1 -2
  40. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnField.js +33 -41
  41. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +66 -55
  42. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +68 -60
  43. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.d.ts +13 -8
  44. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +17 -81
  45. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +3 -0
  46. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -1
  47. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  48. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +62 -43
  49. package/lib/component/panels/ZonesPanel/ZonesTable.js +4 -1
  50. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.d.ts +5 -0
  51. package/lib/component/panels/ZonesPanel/hooks/useZoneActions.js +40 -0
  52. package/lib/component/reducer/actions/RangesActions.d.ts +1 -0
  53. package/lib/component/reducer/actions/RangesActions.js +9 -4
  54. package/lib/component/reducer/actions/ToolsActions.js +0 -17
  55. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +0 -4
  56. package/lib/component/reducer/preferences/actions/matrixGeneration.js +1 -2
  57. package/lib/component/toolbar/ToolTypes.d.ts +1 -1
  58. package/lib/component/toolbar/ToolTypes.js +0 -14
  59. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +1 -7
  60. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +1 -7
  61. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +1 -7
  62. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +1 -7
  63. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  64. package/lib/data/molecules/MoleculeManager.js +5 -11
  65. package/lib/versionInfo.js +1 -1
  66. package/package.json +2 -2
  67. package/lib/component/1d/tool/VerticalIndicator.d.ts +0 -2
  68. package/lib/component/elements/ContextMenu.d.ts +0 -9
  69. package/lib/component/elements/ContextMenu.js +0 -116
  70. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +0 -21
  71. package/lib/component/elements/popup/Modal/ConfirmDialog.js +0 -68
  72. package/lib/component/elements/popup/Modal/Context.d.ts +0 -2
  73. package/lib/component/elements/popup/Modal/Context.js +0 -6
  74. package/lib/component/elements/popup/Modal/Modal.d.ts +0 -9
  75. package/lib/component/elements/popup/Modal/Modal.js +0 -42
  76. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -6
  77. package/lib/component/elements/popup/Modal/ModalContent.js +0 -27
  78. package/lib/component/elements/popup/Modal/Provider.d.ts +0 -11
  79. package/lib/component/elements/popup/Modal/Provider.js +0 -172
  80. package/lib/component/elements/popup/Modal/index.d.ts +0 -4
  81. package/lib/component/elements/popup/Modal/index.js +0 -4
  82. package/lib/component/elements/popup/Transition.d.ts +0 -14
  83. package/lib/component/elements/popup/Transition.js +0 -35
  84. package/lib/component/elements/popup/Wrapper.d.ts +0 -8
  85. package/lib/component/elements/popup/Wrapper.js +0 -83
  86. package/lib/component/elements/popup/options.d.ts +0 -28
  87. package/lib/component/elements/popup/options.js +0 -25
  88. package/lib/component/elements/popup/utility.d.ts +0 -2
  89. package/lib/component/elements/popup/utility.js +0 -13
  90. package/lib/component/modal/editZone/EditPathLengthFormik.d.ts +0 -5
  91. package/lib/component/modal/editZone/EditPathLengthFormik.js +0 -67
  92. package/lib/component/modal/editZone/SignalFormTab.d.ts +0 -5
  93. package/lib/component/modal/editZone/SignalFormTab.js +0 -6
  94. package/lib/component/modal/editZone/validation/EditZoneValidation.d.ts +0 -14
  95. package/lib/component/modal/editZone/validation/EditZoneValidation.js +0 -14
@@ -1,20 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { buildLink, getCorrelationDelta, getLabel, getLinkDim, } from 'nmr-correlation';
3
- import { useCallback, useMemo, useRef } from 'react';
3
+ import { useCallback, useMemo } from 'react';
4
4
  import { buildID } from '../../../../data/utilities/Concatenation';
5
5
  import { findRangeOrZoneID } from '../../../../data/utilities/FindUtilities';
6
6
  import { useAlert } from '../../../elements/Alert';
7
- import ContextMenu from '../../../elements/ContextMenu';
7
+ import { ContextMenu, } from '../../../elements/ContextMenuBluePrint';
8
+ import { useDialog } from '../../../elements/DialogManager';
8
9
  import EditableColumn from '../../../elements/EditableColumn';
9
- import { positions, useModal } from '../../../elements/popup/Modal';
10
10
  import { useHighlight } from '../../../highlight';
11
11
  import { convertValuesString } from '../utilities/Utilities';
12
12
  import useInView from '../utilities/useInView';
13
13
  import AdditionalColumnField from './AdditionalColumnField';
14
- import EditLinkModal from './editLink/EditLinkModal';
14
+ import { EditLinkModal } from './editLink/EditLinkModal';
15
15
  function CorrelationTableRow({ additionalColumnData, correlations, correlation, styleRow, styleLabel, onSaveEditEquivalences, onSaveEditNumericValues, onEditCorrelationTableCellHandler, spectraData, }) {
16
- const contextRef = useRef();
17
- const modal = useModal();
16
+ const { openDialog } = useDialog();
18
17
  const alert = useAlert();
19
18
  const highlightIDsRow = useMemo(() => {
20
19
  if (correlation.pseudo === true) {
@@ -65,12 +64,11 @@ function CorrelationTableRow({ additionalColumnData, correlations, correlation,
65
64
  }
66
65
  }
67
66
  }
68
- return (_jsx(AdditionalColumnField, { rowCorrelation: correlation, columnCorrelation: _correlation, commonLinks: commonLinks, correlations: correlations, spectraData: spectraData, onEdit: onEditCorrelationTableCellHandler }, `addColData_${correlation.id}_${_correlation.id}`));
67
+ return (_jsx(AdditionalColumnField, { rowCorrelation: correlation, columnCorrelation: _correlation, commonLinks: commonLinks, spectraData: spectraData, onEdit: onEditCorrelationTableCellHandler }, `addColData_${correlation.id}_${_correlation.id}`));
69
68
  });
70
69
  }, [
71
70
  additionalColumnData,
72
71
  correlation,
73
- correlations,
74
72
  onEditCorrelationTableCellHandler,
75
73
  spectraData,
76
74
  ]);
@@ -123,64 +121,74 @@ function CorrelationTableRow({ additionalColumnData, correlations, correlation,
123
121
  mouseLeaveHandler,
124
122
  styleRow,
125
123
  ]);
126
- const contextMenu = useMemo(() => {
127
- return correlation.pseudo === false
128
- ? correlation.link
129
- .filter((link) => getLinkDim(link) === 1 && link.pseudo === false)
130
- .map((link) => {
131
- return {
132
- label: `edit 1D (${link.signal.delta.toFixed(3)})${link.edited?.moved === true ? '[MOVED]' : ''}`,
133
- onClick: () => {
134
- highlightRow.hide();
135
- modal.show(_jsx(EditLinkModal, { onClose: () => modal.close(), onEdit: onEditCorrelationTableCellHandler, link: link, correlationDim1: correlation, correlationDim2: undefined, correlations: correlations }), {
136
- position: positions.MIDDLE_RIGHT,
137
- isBackgroundBlur: false,
138
- });
139
- },
140
- };
141
- })
142
- .concat([
124
+ const deleteCorrelationLink = useCallback(() => {
125
+ const message = `All signals of ${correlation.label.origin} (${getCorrelationDelta(correlation).toFixed(2)}) will be deleted. Are you sure?`;
126
+ alert.showAlert({
127
+ message,
128
+ buttons: [
143
129
  {
144
- label: `delete ${correlation.label.origin}`,
130
+ text: 'Yes',
145
131
  onClick: () => {
146
- alert.showAlert({
147
- message: `All signals of ${correlation.label.origin} (${getCorrelationDelta(correlation).toFixed(2)}) will be deleted. Are you sure?`,
148
- buttons: [
149
- {
150
- text: 'Yes',
151
- onClick: () => {
152
- onEditCorrelationTableCellHandler([correlation], 'removeAll');
153
- },
154
- intent: 'danger',
155
- },
156
- { text: 'No' },
157
- ],
158
- });
159
- highlightRow.hide();
132
+ onEditCorrelationTableCellHandler([correlation], 'removeAll');
160
133
  },
134
+ intent: 'danger',
161
135
  },
162
- ])
163
- : [];
164
- }, [
165
- correlation,
166
- highlightRow,
167
- modal,
168
- onEditCorrelationTableCellHandler,
169
- correlations,
170
- alert,
171
- ]);
172
- const contextMenuHandler = useCallback((e) => {
173
- e.preventDefault();
174
- contextRef.current.handleContextMenu(e);
175
- }, [contextRef]);
136
+ { text: 'No' },
137
+ ],
138
+ });
139
+ highlightRow.hide();
140
+ }, [alert, correlation, highlightRow, onEditCorrelationTableCellHandler]);
141
+ const contextMenus = useMemo(() => {
142
+ if (correlation.pseudo !== false) {
143
+ return [];
144
+ }
145
+ const contextMenus = [
146
+ {
147
+ text: `Delete ${correlation.label.origin}`,
148
+ icon: 'trash',
149
+ data: { action: 'delete' },
150
+ },
151
+ ];
152
+ for (const link of correlation?.link || []) {
153
+ const isValidLink = getLinkDim(link) === 1 && link.pseudo === false;
154
+ if (isValidLink) {
155
+ const contextMenu = {
156
+ text: `Edit 1D (${link.signal.delta.toFixed(3)})${link.edited?.moved === true ? '[MOVED]' : ''}`,
157
+ icon: 'edit',
158
+ data: {
159
+ action: 'edit',
160
+ data: {
161
+ link,
162
+ correlationDim1: correlation,
163
+ correlationDim2: null,
164
+ },
165
+ },
166
+ };
167
+ contextMenus.push(contextMenu);
168
+ }
169
+ }
170
+ return contextMenus;
171
+ }, [correlation]);
172
+ function contextMenuHandler(selectedItem) {
173
+ const { action, data } = selectedItem;
174
+ switch (action) {
175
+ case 'delete': {
176
+ deleteCorrelationLink();
177
+ break;
178
+ }
179
+ case 'edit': {
180
+ highlightRow.hide();
181
+ openDialog(EditLinkModal, data);
182
+ break;
183
+ }
184
+ default:
185
+ break;
186
+ }
187
+ }
176
188
  const { title, ...otherTableDataProps } = tableDataProps;
177
189
  const t = title || '';
178
- return (_jsxs("tr", { style: styleRow, children: [_jsxs("td", { title: t, ...otherTableDataProps,
179
- style: { ...tableDataProps.style, styleLabel }, onContextMenu: (e) => {
180
- if (contextMenu.length > 0) {
181
- contextMenuHandler(e);
182
- }
183
- }, children: [getLabel(correlations, correlation), _jsx(ContextMenu, { ref: contextRef, context: contextMenu })] }), _jsx("td", { title: t, ...otherTableDataProps, children: getCorrelationDelta(correlation)
190
+ return (_jsxs("tr", { style: styleRow, children: [_jsx(ContextMenu, { as: "td", options: contextMenus, title: t, ...otherTableDataProps,
191
+ style: { ...tableDataProps.style, styleLabel }, onSelect: contextMenuHandler, children: getLabel(correlations, correlation) }), _jsx("td", { title: t, ...otherTableDataProps, children: getCorrelationDelta(correlation)
184
192
  ? getCorrelationDelta(correlation)?.toFixed(2)
185
193
  : '' }), _jsx("td", { title: t, ...otherTableDataProps, children: correlation.atomType !== 'H' ? (_jsx(EditableColumn, { type: "number", value: correlation.equivalence, style: equivalenceCellStyle, onSave: onSaveEquivalencesHandler, validate: (val) => val !== '' })) : (_jsx("span", { style: equivalenceCellStyle, children: correlation.equivalence })) }), _jsx("td", { title: t, ...otherTableDataProps, children: correlation.atomType !== 'H' ? (_jsx(EditableColumn, { type: "text", value: correlation.protonsCount.join(','), style: correlation.edited.protonsCount ? { color: 'blue' } : {}, onSave: (e) => onSaveEditNumericValuesHandler(e, 'protonsCount'), validate: (val) => val !== '' })) : ('') }), _jsx("td", { title: t, ...otherTableDataProps,
186
194
  style: { ...tableDataProps.style, borderRight: '1px solid' }, children: correlation.atomType !== 'H' ? (_jsx(EditableColumn, { type: "text", value: correlation.hybridization
@@ -1,8 +1,13 @@
1
- export default function EditLinkModal({ correlationDim1, correlationDim2, link, correlations, onClose, onEdit, }: {
2
- correlationDim1: any;
3
- correlationDim2: any;
4
- link: any;
5
- correlations: any;
6
- onClose: any;
7
- onEdit: any;
8
- }): import("@emotion/react/jsx-runtime").JSX.Element;
1
+ import { Link, Correlation } from 'nmr-correlation';
2
+ import { DialogProps } from '../../../../elements/DialogManager';
3
+ import { OnEditCorrelationCallback } from '../../SummaryPanel';
4
+ export interface EditLinkDialogData {
5
+ correlationDim1: Correlation;
6
+ correlationDim2: Correlation;
7
+ link: Link;
8
+ }
9
+ interface EditLinkModalProps extends DialogProps<EditLinkDialogData> {
10
+ onEdit: OnEditCorrelationCallback;
11
+ }
12
+ export declare function EditLinkModal(props: EditLinkModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -1,75 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
3
+ import { DialogBody, Tab, Tabs } from '@blueprintjs/core';
4
4
  import { getLinkDim } from 'nmr-correlation';
5
- import { useCallback, useMemo, useState } from 'react';
6
- import { CloseButton } from '../../../../elements/CloseButton';
7
- import Tab from '../../../../elements/Tab/Tab';
8
- import Tabs, { PositionsEnum } from '../../../../elements/Tab/Tabs';
5
+ import { useChartData } from '../../../../context/ChartContext';
6
+ import { DraggableDialog } from '../../../../elements/DraggableDialog';
9
7
  import { getEditedCorrelations } from '../../utilities/Utilities';
10
8
  import EditLinkConfirmation from './Confirmation';
11
9
  import EditPathLength from './EditPathLength';
12
10
  import MoveLink from './MoveLink';
13
- const modalContainer = css `
14
- width: 490px;
15
- height: 220px;
16
- padding: 5px;
17
-
18
- button {
19
- flex: 2;
20
- padding: 5px;
21
- border: 1px solid gray;
22
- border-radius: 5px;
23
- height: 30px;
24
- margin: 0 auto;
25
- margin-top: 15px;
26
- display: block;
27
- width: 20%;
28
- color: white;
29
- background-color: gray;
30
- }
31
-
32
- button:focus {
33
- outline: none;
34
- }
35
-
36
- .header {
37
- height: 24px;
38
- border-bottom: 1px solid #f0f0f0;
39
- display: flex;
40
- align-items: center;
41
-
42
- button {
43
- height: 36px;
44
- margin: 2px;
45
- background-color: transparent;
46
- border: none;
47
-
48
- svg {
49
- height: 16px;
50
- }
51
- }
52
-
53
- p {
54
- font-weight: bold;
55
- margin-bottom: 5px;
56
- margin-right: 30px;
57
- padding: 0 10px;
58
- width: 100%;
59
- text-align: center;
60
- }
61
- }
62
-
63
- .tabs-container {
64
- width: 100%;
65
- flex: 1;
66
- overflow: auto;
67
- border: none;
68
- }
69
- `;
70
- export default function EditLinkModal({ correlationDim1, correlationDim2, link, correlations, onClose, onEdit, }) {
71
- const [activeTab, setActiveTab] = useState('move');
72
- const getLinkLabel = useCallback(() => {
11
+ export function EditLinkModal(props) {
12
+ const { onCloseDialog, dialogData, onEdit } = props;
13
+ const { correlations: correlationData } = useChartData();
14
+ const correlations = correlationData?.values || [];
15
+ const { correlationDim1, correlationDim2, link } = dialogData;
16
+ function getLinkLabel() {
73
17
  const linkDim = getLinkDim(link);
74
18
  if (linkDim === 1) {
75
19
  return ` 1D (${link.signal.delta.toFixed(3)})`;
@@ -78,8 +22,8 @@ export default function EditLinkModal({ correlationDim1, correlationDim2, link,
78
22
  return `${link.signal.x ? `${link.signal.x.delta.toFixed(2)}` : '?'} (${correlationDim1.label.origin}), ${link.signal.y ? link.signal.y.delta.toFixed(2) : '?'} (${correlationDim2.label.origin})`;
79
23
  }
80
24
  return '';
81
- }, [correlationDim1.label.origin, link, correlationDim2]);
82
- const handleOnEdit = useCallback((action, selectedCorrelationIdDim1, selectedCorrelationIdDim2, editedLink) => {
25
+ }
26
+ function handleOnEdit(action, selectedCorrelationIdDim1, selectedCorrelationIdDim2, editedLink) {
83
27
  const { editedCorrelations, buildCorrelationDataOptions } = getEditedCorrelations({
84
28
  correlationDim1,
85
29
  correlationDim2,
@@ -90,18 +34,10 @@ export default function EditLinkModal({ correlationDim1, correlationDim2, link,
90
34
  correlations,
91
35
  });
92
36
  onEdit(editedCorrelations, action, editedLink || link, buildCorrelationDataOptions);
93
- onClose?.();
94
- }, [correlationDim1, correlationDim2, correlations, link, onClose, onEdit]);
95
- const tabsContainer = useMemo(() => (_jsx("div", { className: "tabs-container", children: _jsxs(Tabs, { position: PositionsEnum.TOP, activeTab: activeTab, onClick: (tab) => setActiveTab(tab.tabid), children: [_jsx(Tab, { title: "Move", tabid: 'move', children: _jsx(MoveLink, { correlationDim1: correlationDim1, correlationDim2: correlationDim2, link: link, correlations: correlations, onEdit: (correlationIdDim1, correlationIdDim2) => handleOnEdit('move', correlationIdDim1, correlationIdDim2) }) }), _jsx(Tab, { title: "Unmove", tabid: "unmove", children: _jsx(EditLinkConfirmation, { description: "Movement of signal to its original place.", onConfirm: () => handleOnEdit('unmove', correlationDim1.id, correlationDim2.id) }) }), _jsx(Tab, { title: "Remove", tabid: 'remove', children: _jsx(EditLinkConfirmation, { description: "Deletion of signal.", onConfirm: () => handleOnEdit('remove', undefined, undefined) }) }), _jsx(Tab, { title: "J Coupling", tabid: 'setPathLength', children: _jsx(EditPathLength, { signal: link.signal, experimentType: link.experimentType, onEdit: (editedSignal) => {
96
- const editedLink = { ...link, signal: editedSignal };
97
- handleOnEdit('setPathLength', correlationDim1, correlationDim2, editedLink);
98
- } }) })] }) })), [
99
- activeTab,
100
- correlationDim1,
101
- correlationDim2,
102
- correlations,
103
- handleOnEdit,
104
- link,
105
- ]);
106
- return (_jsxs("div", { css: modalContainer, children: [_jsxs("div", { className: "header handle", children: [_jsx(CloseButton, { tooltip: "Close", onClick: onClose }), _jsx("p", { className: "header-info", children: `${link.experimentType.toUpperCase()} signal at ${getLinkLabel()}` })] }), tabsContainer] }));
37
+ onCloseDialog?.();
38
+ }
39
+ return (_jsx(DraggableDialog, { hasBackdrop: false, canOutsideClickClose: false, style: { width: 500 }, title: `${link.experimentType.toUpperCase()} signal at ${getLinkLabel()}`, isOpen: true, onClose: onCloseDialog, placement: "center-right", children: _jsx(DialogBody, { children: _jsxs(Tabs, { defaultSelectedTabId: "move", children: [_jsx(Tab, { title: "Move", id: "move", panel: _jsx(MoveLink, { correlationDim1: correlationDim1, correlationDim2: correlationDim2, link: link, correlations: correlations, onEdit: (correlationIdDim1, correlationIdDim2) => handleOnEdit('move', correlationIdDim1, correlationIdDim2) }) }), _jsx(Tab, { title: "Unmove", id: "unmove", panel: _jsx(EditLinkConfirmation, { description: "Movement of signal to its original place.", onConfirm: () => handleOnEdit('unmove', correlationDim1.id, correlationDim2.id) }) }), _jsx(Tab, { title: "Remove", id: "remove", panel: _jsx(EditLinkConfirmation, { description: "Deletion of signal.", onConfirm: () => handleOnEdit('remove', undefined, undefined) }) }), _jsx(Tab, { title: "J Coupling", id: "setPathLength", panel: _jsx(EditPathLength, { signal: link.signal, experimentType: link.experimentType, onEdit: (editedSignal) => {
40
+ const editedLink = { ...link, signal: editedSignal };
41
+ handleOnEdit('setPathLength', correlationDim1, correlationDim2, editedLink);
42
+ } }) })] }) }) }));
107
43
  }
@@ -1,3 +1,6 @@
1
+ import { Correlation, Options as CorrelationOptions, Link } from 'nmr-correlation';
2
+ type EditCorrelationAction = 'add' | 'move' | 'remove' | 'unmove' | 'setPathLength';
3
+ export type OnEditCorrelationCallback = (editedCorrelations: Correlation[], action: EditCorrelationAction, link?: Link, options?: CorrelationOptions) => void;
1
4
  declare function SummaryPanel(): import("@emotion/react/jsx-runtime").JSX.Element;
2
5
  declare const _default: import("react").MemoExoticComponent<typeof SummaryPanel>;
3
6
  export default _default;
@@ -8,10 +8,12 @@ import { findRange, findSignal1D, findSignal2D, findSpectrum, findZone, } from '
8
8
  import { useAssignmentData } from '../../assignment/AssignmentsContext';
9
9
  import { useChartData } from '../../context/ChartContext';
10
10
  import { useDispatch } from '../../context/DispatchContext';
11
+ import { withDialog } from '../../elements/DialogManager';
11
12
  import Select from '../../elements/Select';
12
13
  import { useDialogToggle } from '../../hooks/useDialogToggle';
13
14
  import DefaultPanelHeader from '../header/DefaultPanelHeader';
14
15
  import CorrelationTable from './CorrelationTable/CorrelationTable';
16
+ import { EditLinkModal } from './CorrelationTable/editLink/EditLinkModal';
15
17
  import Overview from './Overview';
16
18
  import { SetMolecularFormulaModal } from './SetMolecularFormulaModal';
17
19
  import { SetShiftToleranceModal } from './SetShiftTolerancesModal';
@@ -49,6 +51,7 @@ const panelStyle = css `
49
51
  }
50
52
  }
51
53
  `;
54
+ const EditLinkDialog = withDialog(EditLinkModal);
52
55
  function SummaryPanel() {
53
56
  const { correlations: correlationsData, data: spectraData, xDomain, yDomain, displayerMode, view: { spectra: { activeTab }, }, } = useChartData();
54
57
  const dispatch = useDispatch();
@@ -294,7 +297,7 @@ function SummaryPanel() {
294
297
  setFilterIsActive(!filterIsActive);
295
298
  }, [filterIsActive]);
296
299
  const total = correlationsData ? correlationsData.values.length : 0;
297
- return (_jsxs("div", { css: panelStyle, children: [_jsx(SetMolecularFormulaModal, { isOpen: dialog.molecularFormula, onClose: closeDialog }), _jsx(SetShiftToleranceModal, { isOpen: dialog.shiftToleranceModal, onClose: closeDialog }), _jsx(DefaultPanelHeader, { total: total, counter: filteredCorrelationsData?.values.length, onFilter: handleOnFilter, filterToolTip: filterIsActive
300
+ return (_jsxs("div", { css: panelStyle, children: [_jsx(EditLinkDialog, { onEdit: editCorrelationTableCellHandler }), _jsx(SetMolecularFormulaModal, { isOpen: dialog.molecularFormula, onClose: closeDialog }), _jsx(SetShiftToleranceModal, { isOpen: dialog.shiftToleranceModal, onClose: closeDialog }), _jsx(DefaultPanelHeader, { total: total, counter: filteredCorrelationsData?.values.length, onFilter: handleOnFilter, filterToolTip: filterIsActive
298
301
  ? 'Show all correlations'
299
302
  : 'Hide correlations out of view', leftButtons: [
300
303
  {
@@ -3,7 +3,7 @@ import lodashGet from 'lodash/get';
3
3
  import { addLink, buildCorrelation, buildLink, getLinkDelta, getLinkDim, removeLink, } from 'nmr-correlation';
4
4
  import DefaultPathLengths from '../../../../data/constants/DefaultPathLengths';
5
5
  import { findSignal2D, findSpectrum, } from '../../../../data/utilities/FindUtilities';
6
- import isDefaultPathLength from '../../../modal/editZone/validation/isDefaultPathLength';
6
+ import { isDefaultPathLength } from '../../../modal/editZone/validation/isDefaultPathLength';
7
7
  import { ErrorColors } from '../CorrelationTable/Constants';
8
8
  function getAtomType(nucleus) {
9
9
  return nucleus.split(/\d+/)[1];
@@ -5,8 +5,9 @@ import { SIGNAL_KINDS } from '../../../../data/constants/signalsKinds';
5
5
  import { useAssignmentData } from '../../../assignment/AssignmentsContext';
6
6
  import { useDispatch } from '../../../context/DispatchContext';
7
7
  import Select from '../../../elements/Select';
8
- import { useModal, positions, transitions, } from '../../../elements/popup/Modal';
9
- import EditZoneModal from '../../../modal/editZone/EditZoneModal';
8
+ import { useZoneActions } from '../hooks/useZoneActions';
9
+ import { useDialog } from '../../../elements/DialogManager';
10
+ import { EditZoneModal } from '../../../modal/editZone/EditZoneModal';
10
11
  const selectBoxStyle = {
11
12
  marginLeft: 2,
12
13
  marginRight: 2,
@@ -16,7 +17,6 @@ const selectBoxStyle = {
16
17
  function ActionsColumn({ rowData, rowSpanTags, showKind, showDeleteAction, showEditAction, showZoomAction, }) {
17
18
  const dispatch = useDispatch();
18
19
  const assignmentData = useAssignmentData();
19
- const modal = useModal();
20
20
  const showActions = showDeleteAction || showEditAction || showZoomAction;
21
21
  const changeSignalKindHandler = useCallback((kind) => {
22
22
  dispatch({
@@ -36,47 +36,66 @@ function ActionsColumn({ rowData, rowSpanTags, showKind, showDeleteAction, showE
36
36
  },
37
37
  });
38
38
  }, [assignmentData, dispatch, rowData]);
39
- const zoomZoneHandler = useCallback(() => {
40
- const xMargin = Math.abs(rowData.x.from - rowData.x.to) * 10;
41
- dispatch({
42
- type: 'SET_X_DOMAIN',
43
- payload: {
44
- xDomain: rowData.x.from <= rowData.x.to
45
- ? [rowData.x.from - xMargin, rowData.x.to + xMargin]
46
- : [rowData.x.to - xMargin, rowData.x.from + xMargin],
47
- },
48
- });
49
- const yMargin = Math.abs(rowData.y.from - rowData.y.to) * 10;
50
- dispatch({
51
- type: 'SET_Y_DOMAIN',
52
- payload: {
53
- yDomain: rowData.y.from <= rowData.y.to
54
- ? [rowData.y.from - yMargin, rowData.y.to + yMargin]
55
- : [rowData.y.to - yMargin, rowData.y.from + yMargin],
56
- },
57
- });
58
- }, [dispatch, rowData.x.from, rowData.x.to, rowData.y.from, rowData.y.to]);
59
- const saveEditZoneHandler = useCallback((zone) => {
60
- dispatch({
61
- type: 'SAVE_EDITED_ZONE',
62
- payload: {
63
- zone,
64
- },
65
- });
66
- }, [dispatch]);
67
- const openEditZoneHandler = useCallback(() => {
68
- dispatch({
69
- type: 'SET_SELECTED_TOOL',
70
- payload: { selectedTool: 'editRange' },
71
- });
72
- modal.show(_jsx(EditZoneModal, { onCloseEditZoneModal: () => modal.close(), onSaveEditZoneModal: saveEditZoneHandler, onZoomEditZoneModal: () => zoomZoneHandler(), rowData: rowData }), {
73
- position: positions.MIDDLE_RIGHT,
74
- transition: transitions.SCALE,
75
- isBackgroundBlur: false,
76
- });
77
- }, [dispatch, modal, rowData, saveEditZoneHandler, zoomZoneHandler]);
39
+ // const zoomZoneHandler = useCallback(() => {
40
+ // const xMargin = Math.abs(rowData.x.from - rowData.x.to) * 10;
41
+ // dispatch({
42
+ // type: 'SET_X_DOMAIN',
43
+ // payload: {
44
+ // xDomain:
45
+ // rowData.x.from <= rowData.x.to
46
+ // ? [rowData.x.from - xMargin, rowData.x.to + xMargin]
47
+ // : [rowData.x.to - xMargin, rowData.x.from + xMargin],
48
+ // },
49
+ // });
50
+ // const yMargin = Math.abs(rowData.y.from - rowData.y.to) * 10;
51
+ // dispatch({
52
+ // type: 'SET_Y_DOMAIN',
53
+ // payload: {
54
+ // yDomain:
55
+ // rowData.y.from <= rowData.y.to
56
+ // ? [rowData.y.from - yMargin, rowData.y.to + yMargin]
57
+ // : [rowData.y.to - yMargin, rowData.y.from + yMargin],
58
+ // },
59
+ // });
60
+ // }, [dispatch, rowData.x.from, rowData.x.to, rowData.y.from, rowData.y.to]);
61
+ // const saveEditZoneHandler = useCallback(
62
+ // (zone) => {
63
+ // dispatch({
64
+ // type: 'SAVE_EDITED_ZONE',
65
+ // payload: {
66
+ // zone,
67
+ // },
68
+ // });
69
+ // },
70
+ // [dispatch],
71
+ // );
72
+ const { zoomToZone } = useZoneActions();
73
+ const { openDialog } = useDialog();
74
+ // const openEditZoneHandler = useCallback(() => {
75
+ // dispatch({
76
+ // type: 'SET_SELECTED_TOOL',
77
+ // payload: { selectedTool: 'zoom' },
78
+ // });
79
+ // modal.show(
80
+ // <EditZoneModal
81
+ // onCloseEditZoneModal={() => modal.close()}
82
+ // // onSaveEditZoneModal={saveEditZoneHandler}
83
+ // onZoomEditZoneModal={() => zoomZoneHandler()}
84
+ // rowData={rowData}
85
+ // />,
86
+ // {
87
+ // position: positions.MIDDLE_RIGHT,
88
+ // transition: transitions.SCALE,
89
+ // isBackgroundBlur: false,
90
+ // },
91
+ // );
92
+ // }, [dispatch, modal, rowData, saveEditZoneHandler, zoomZoneHandler]);
93
+ function handleEditZone() {
94
+ openDialog(EditZoneModal, rowData);
95
+ zoomToZone(rowData);
96
+ }
78
97
  return (_jsxs(Fragment, { children: [showKind && (_jsx("td", { children: _jsx(Select, { onChange: (value) => {
79
98
  changeSignalKindHandler(value);
80
- }, items: SIGNAL_KINDS, defaultValue: rowData.tableMetaInfo.signal.kind, style: selectBoxStyle }) })), showActions && (_jsxs("td", { ...rowSpanTags, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: deleteZoneHandler, children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: zoomZoneHandler, children: _jsx(FaSearchPlus, { title: "Zoom to zone in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: openEditZoneHandler, children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
99
+ }, items: SIGNAL_KINDS, defaultValue: rowData.tableMetaInfo.signal.kind, style: selectBoxStyle }) })), showActions && (_jsxs("td", { ...rowSpanTags, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: deleteZoneHandler, children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: () => zoomToZone(rowData), children: _jsx(FaSearchPlus, { title: "Zoom to zone in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: handleEditZone, children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
81
100
  }
82
101
  export default ActionsColumn;
@@ -8,6 +8,8 @@ import NoDataForFid from '../extra/placeholder/NoDataForFid';
8
8
  import NoTableData from '../extra/placeholder/NoTableData';
9
9
  import ZonesTableRow from './ZonesTableRow';
10
10
  import { useMapZones } from './hooks/useMapZones';
11
+ import { withDialog } from '../../elements/DialogManager';
12
+ import { EditZoneModal } from '../../modal/editZone/EditZoneModal';
11
13
  const tableStyle = css `
12
14
  border-spacing: 0;
13
15
  border: 1px solid #dedede;
@@ -60,6 +62,7 @@ const tableStyle = css `
60
62
  top: 21px;
61
63
  }
62
64
  `;
65
+ const ZoneEditionDialog = withDialog(EditZoneModal, { force: true });
63
66
  function ZonesTable({ tableData, onUnlink, nucleus, info }) {
64
67
  const { experiment, isFid } = info;
65
68
  const nuclei = nucleus.split(',');
@@ -75,7 +78,7 @@ function ZonesTable({ tableData, onUnlink, nucleus, info }) {
75
78
  if (!tableData || tableData.length === 0) {
76
79
  return _jsx(NoTableData, {});
77
80
  }
78
- return (_jsx("div", { children: _jsxs("table", { css: tableStyle, children: [_jsxs("thead", { children: [_jsxs("tr", { children: [showSerialNumber && _jsx("th", { rowSpan: 2, children: "#" }), showAssignmentLabel && _jsx("th", { rowSpan: 2, children: "Assignment" }), (deltaX.show || deltaX.show) && _jsx("th", { colSpan: 2, children: "\u03B4 (ppm)" }), showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { colSpan: 2, children: _jsx(FaLink, {}) }), _jsx("th", { colSpan: 2, children: "\u03A3" })] })), showKind && _jsx("th", { rowSpan: 2, children: "Kind" }), showActions && _jsx("th", { rowSpan: 2, children: '' })] }), _jsxs("tr", { children: [deltaX.show && (_jsx("th", { id: "tableMetaInfo.signal.x.delta", ...onSort, children: _jsxs(SurroundedText, { text: "F2", children: [nuclei[0], ' ', isSortedDesc('tableMetaInfo.signal.x.delta').content] }) })), deltaY.show && (_jsx("th", { id: "tableMetaInfo.signal.y.delta", ...onSort, children: _jsxs(SurroundedText, { text: "F1", children: [nuclei[1], ' ', isSortedDesc('tableMetaInfo.signal.y.delta').content] }) })), showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { children: _jsx(SurroundedText, { text: "F2", children: nuclei[0] }) }), _jsx("th", { children: _jsx(SurroundedText, { text: "F1", children: nuclei[1] }) }), _jsx("th", { children: _jsx(SurroundedText, { text: "F2", children: nuclei[0] }) }), _jsx("th", { children: _jsx(SurroundedText, { text: "F1", children: nuclei[1] }) })] }))] })] }), _jsx("tbody", { children: sortedData.map((rowData, index) => (_jsx(ZonesTableRow, { rowIndex: index, rowData: rowData, onUnlink: onUnlink, nucleus: nucleus }, `${rowData.tableMetaInfo.id}`))) })] }) }));
81
+ return (_jsxs("div", { children: [_jsx(ZoneEditionDialog, {}), _jsxs("table", { css: tableStyle, children: [_jsxs("thead", { children: [_jsxs("tr", { children: [showSerialNumber && _jsx("th", { rowSpan: 2, children: "#" }), showAssignmentLabel && _jsx("th", { rowSpan: 2, children: "Assignment" }), (deltaX.show || deltaX.show) && _jsx("th", { colSpan: 2, children: "\u03B4 (ppm)" }), showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { colSpan: 2, children: _jsx(FaLink, {}) }), _jsx("th", { colSpan: 2, children: "\u03A3" })] })), showKind && _jsx("th", { rowSpan: 2, children: "Kind" }), showActions && _jsx("th", { rowSpan: 2, children: '' })] }), _jsxs("tr", { children: [deltaX.show && (_jsx("th", { id: "tableMetaInfo.signal.x.delta", ...onSort, children: _jsxs(SurroundedText, { text: "F2", children: [nuclei[0], ' ', isSortedDesc('tableMetaInfo.signal.x.delta').content] }) })), deltaY.show && (_jsx("th", { id: "tableMetaInfo.signal.y.delta", ...onSort, children: _jsxs(SurroundedText, { text: "F1", children: [nuclei[1], ' ', isSortedDesc('tableMetaInfo.signal.y.delta').content] }) })), showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { children: _jsx(SurroundedText, { text: "F2", children: nuclei[0] }) }), _jsx("th", { children: _jsx(SurroundedText, { text: "F1", children: nuclei[1] }) }), _jsx("th", { children: _jsx(SurroundedText, { text: "F2", children: nuclei[0] }) }), _jsx("th", { children: _jsx(SurroundedText, { text: "F1", children: nuclei[1] }) })] }))] })] }), _jsx("tbody", { children: sortedData.map((rowData, index) => (_jsx(ZonesTableRow, { rowIndex: index, rowData: rowData, onUnlink: onUnlink, nucleus: nucleus }, `${rowData.tableMetaInfo.id}`))) })] })] }));
79
82
  }
80
83
  function SurroundedText(props) {
81
84
  return (_jsxs(_Fragment, { children: [_jsx("div", { style: {
@@ -0,0 +1,5 @@
1
+ import { ZoneData } from './useMapZones';
2
+ export declare function useZoneActions(): {
3
+ zoomToZone: (zone: ZoneData) => void;
4
+ saveZone: (zone: ZoneData) => void;
5
+ };
@@ -0,0 +1,40 @@
1
+ import { useDispatch } from '../../../context/DispatchContext';
2
+ function getZoomDomain(zone, marginFactor = 10) {
3
+ const { x: { from: xFrom, to: xTo }, y: { from: yFrom, to: yTo }, } = zone;
4
+ const xMargin = Math.abs(xFrom - xTo) * marginFactor;
5
+ const yMargin = Math.abs(yFrom - yTo) * marginFactor;
6
+ const xDomain = xFrom <= xTo
7
+ ? [xFrom - xMargin, xTo + xMargin]
8
+ : [xTo - xMargin, xFrom + xMargin];
9
+ const yDomain = yFrom <= yTo
10
+ ? [yFrom - yMargin, yTo + yMargin]
11
+ : [yTo - yMargin, yFrom + yMargin];
12
+ return { xDomain, yDomain };
13
+ }
14
+ export function useZoneActions() {
15
+ const dispatch = useDispatch();
16
+ function zoomToZone(zone) {
17
+ const { xDomain, yDomain } = getZoomDomain(zone);
18
+ dispatch({
19
+ type: 'SET_X_DOMAIN',
20
+ payload: {
21
+ xDomain,
22
+ },
23
+ });
24
+ dispatch({
25
+ type: 'SET_Y_DOMAIN',
26
+ payload: {
27
+ yDomain,
28
+ },
29
+ });
30
+ }
31
+ function saveZone(zone) {
32
+ dispatch({
33
+ type: 'SAVE_EDITED_ZONE',
34
+ payload: {
35
+ zone,
36
+ },
37
+ });
38
+ }
39
+ return { zoomToZone, saveZone };
40
+ }
@@ -65,6 +65,7 @@ type CutRangAction = ActionType<'CUT_RANGE', {
65
65
  }>;
66
66
  type ToggleRangesViewAction = ActionType<'TOGGLE_RANGES_VIEW_PROPERTY', {
67
67
  key: keyof FilterType<RangesViewState, boolean>;
68
+ value?: boolean;
68
69
  }>;
69
70
  type DeleteRangePeakAction = ActionType<'DELETE_RANGE_PEAK', {
70
71
  id: string;
@@ -323,13 +323,18 @@ function handleUpdateRange(draft, action) {
323
323
  datum.ranges.values[index] = range;
324
324
  }
325
325
  }
326
- function toggleRangesViewProperty(draft, key) {
327
- setRangesViewProperty(draft, key, (flag) => !flag);
326
+ function toggleRangesViewProperty(draft, key, value) {
327
+ if (typeof value === 'boolean') {
328
+ setRangesViewProperty(draft, key, value);
329
+ }
330
+ else {
331
+ setRangesViewProperty(draft, key, (flag) => !flag);
332
+ }
328
333
  }
329
334
  //action
330
335
  function handleToggleRangesViewProperty(draft, action) {
331
- const { key } = action.payload;
332
- toggleRangesViewProperty(draft, key);
336
+ const { key, value } = action.payload;
337
+ toggleRangesViewProperty(draft, key, value);
333
338
  }
334
339
  function handleCutRange(draft, action) {
335
340
  const { ranges: cutRanges } = action.payload;
@@ -4,7 +4,6 @@ import { contoursManager } from '../../../data/data2d/Spectrum2D/contours';
4
4
  import { getYScale, getXScale } from '../../1d/utilities/scale';
5
5
  import { LAYOUT } from '../../2d/utilities/DimensionLayout';
6
6
  import { get2DXScale, get2DYScale } from '../../2d/utilities/scale';
7
- import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
8
7
  import { options as Tools } from '../../toolbar/ToolTypes';
9
8
  import groupByInfoKey from '../../utility/GroupByInfoKey';
10
9
  import { getSpectraByNucleus } from '../../utility/getSpectraByNucleus';
@@ -64,22 +63,6 @@ function activateTool(draft, options) {
64
63
  draft.toolOptions.selectedOptionPanel = toolId;
65
64
  }
66
65
  }
67
- // start Range edit mode
68
- if (toolId === Tools.editRange.id) {
69
- const activeSpectrum = getActiveSpectrum(draft);
70
- if (activeSpectrum) {
71
- const range = draft.view.ranges?.[activeSpectrum?.id];
72
- if (range) {
73
- range.showMultiplicityTrees = true;
74
- }
75
- else {
76
- draft.view.ranges[activeSpectrum.id] = {
77
- ...defaultRangesViewState,
78
- showMultiplicityTrees: true,
79
- };
80
- }
81
- }
82
- }
83
66
  setMargin(draft);
84
67
  }
85
68
  function setSelectedTool(draft, action) {