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,15 +1,13 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import lodashGet from 'lodash/get';
3
- import { useCallback, useMemo, memo } from 'react';
3
+ import { useCallback, useMemo, memo, useState } from 'react';
4
4
  import { FaEdit, FaRegTrashAlt } from 'react-icons/fa';
5
5
  import { useDispatch } from '../../context/DispatchContext';
6
6
  import EditableColumn from '../../elements/EditableColumn';
7
7
  import ReactTable from '../../elements/ReactTable/ReactTable';
8
8
  import addCustomColumn, { createActionColumn, } from '../../elements/ReactTable/utility/addCustomColumn';
9
- import { useModal } from '../../elements/popup/Modal';
10
- import { positions, transitions } from '../../elements/popup/options';
11
9
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
12
- import EditPeakShapeModal from '../../modal/EditPeakShapeModal';
10
+ import { EditPeakShapeModal } from '../../modal/EditPeakShapeModal';
13
11
  import { formatNumber } from '../../utility/formatNumber';
14
12
  import NoDataForFid from '../extra/placeholder/NoDataForFid';
15
13
  import NoTableData from '../extra/placeholder/NoTableData';
@@ -18,8 +16,8 @@ function handleActiveRow(row) {
18
16
  }
19
17
  function PeaksTable({ activeTab, data, info }) {
20
18
  const dispatch = useDispatch();
21
- const modal = useModal();
22
19
  const peaksPreferences = usePanelPreferences('peaks', activeTab);
20
+ const [peak, setEditedPeak] = useState();
23
21
  const deletePeakHandler = useCallback((row) => {
24
22
  const params = row.original;
25
23
  dispatch({
@@ -28,12 +26,8 @@ function PeaksTable({ activeTab, data, info }) {
28
26
  });
29
27
  }, [dispatch]);
30
28
  const editPeakHandler = useCallback((row) => {
31
- modal.show(_jsx(EditPeakShapeModal, { peak: row.original, peaksPreferences: peaksPreferences }), {
32
- position: positions.MIDDLE_RIGHT,
33
- transition: transitions.SCALE,
34
- isBackgroundBlur: false,
35
- });
36
- }, [modal, peaksPreferences]);
29
+ setEditedPeak(row.original);
30
+ }, []);
37
31
  const saveDeltaPPMRefsHandler = useCallback((event, row) => {
38
32
  const shift = Number.parseFloat(event.target.value) - Number.parseFloat(row.x);
39
33
  dispatch({ type: 'SHIFT_SPECTRUM', payload: { shift } });
@@ -149,6 +143,6 @@ function PeaksTable({ activeTab, data, info }) {
149
143
  if (!data || data.length === 0) {
150
144
  return _jsx(NoTableData, {});
151
145
  }
152
- return (_jsx(ReactTable, { activeRow: handleActiveRow, rowStyle: { activated: { backgroundColor: '#f5f5dc' } }, data: data, columns: tableColumns, approxItemHeight: 24, enableVirtualScroll: true }));
146
+ return (_jsxs(_Fragment, { children: [_jsx(EditPeakShapeModal, { peak: peak, onCloseDialog: () => setEditedPeak(undefined) }), _jsx(ReactTable, { activeRow: handleActiveRow, rowStyle: { activated: { backgroundColor: '#f5f5dc' } }, data: data, columns: tableColumns, approxItemHeight: 24, enableVirtualScroll: true })] }));
153
147
  }
154
148
  export default memo(PeaksTable);
@@ -14,7 +14,6 @@ import { useDispatch } from '../../context/DispatchContext';
14
14
  import { useToaster } from '../../context/ToasterContext';
15
15
  import { useAlert } from '../../elements/Alert';
16
16
  import { ToolbarPopoverItem, } from '../../elements/ToolbarPopoverItem';
17
- import { useModal } from '../../elements/popup/Modal';
18
17
  import { useActiveSpectrumRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
19
18
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
20
19
  import CopyClipboardModal from '../../modal/CopyClipboardModal';
@@ -39,7 +38,6 @@ const EXPORT_MENU = [
39
38
  ];
40
39
  function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClick, isFilterActive, filterCounter, activeTab, }) {
41
40
  const dispatch = useDispatch();
42
- const modal = useModal();
43
41
  const alert = useAlert();
44
42
  const toaster = useToaster();
45
43
  const assignmentData = useAssignmentData();
@@ -49,7 +47,6 @@ function RangesHeader({ ranges, info, onUnlink, onFilterActivated, onSettingClic
49
47
  const { showMultiplicityTrees, showJGraph, showIntegrals, showIntegralsValues, showPeaks, displayingMode, showAssignmentsLabels, } = useActiveSpectrumRangesViewState();
50
48
  function changeRangesSumHandler(options) {
51
49
  dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
52
- modal.close();
53
50
  }
54
51
  function removeAssignments() {
55
52
  onUnlink();
@@ -2,7 +2,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
4
  import { FaLink } from 'react-icons/fa';
5
+ import { withDialog } from '../../elements/DialogManager';
5
6
  import useTableSortBy from '../../hooks/useTableSortBy';
7
+ import { EditRangeModal } from '../../modal/editRange/EditRangeModal';
6
8
  import NoDataForFid from '../extra/placeholder/NoDataForFid';
7
9
  import NoTableData from '../extra/placeholder/NoTableData';
8
10
  import RangesTableRow from './RangesTableRow';
@@ -51,6 +53,7 @@ const tableStyle = css `
51
53
  }
52
54
  }
53
55
  `;
56
+ const EditRangeDialog = withDialog(EditRangeModal, { force: true });
54
57
  function RangesTable({ tableData, onUnlink, contextMenu = [], onContextMenuSelect, activeTab, preferences, info, }) {
55
58
  const element = activeTab?.replace(/\d/g, '');
56
59
  const { items: sortedData, isSortedDesc, onSort } = useTableSortBy(tableData);
@@ -64,8 +67,8 @@ function RangesTable({ tableData, onUnlink, contextMenu = [], onContextMenuSelec
64
67
  const showActions = preferences.showDeleteAction ||
65
68
  preferences.showEditAction ||
66
69
  preferences.showZoomAction;
67
- return (_jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.showAssignmentLabel && (_jsx("th", { title: "Assignment", children: "Assignment" })), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
68
- return (_jsx(RangesTableRow, { rowData: range, onUnlink: onUnlink, preferences: preferences, info: info, contextMenu: contextMenu, onContextMenuSelect: onContextMenuSelect }, range.rowKey));
69
- }) })] }));
70
+ return (_jsxs(_Fragment, { children: [_jsx(EditRangeDialog, {}), _jsxs("table", { css: tableStyle, children: [_jsx("thead", { children: _jsxs("tr", { children: [preferences.showSerialNumber && _jsx("th", { children: "#" }), preferences.showAssignmentLabel && (_jsx("th", { title: "Assignment", children: "Assignment" })), preferences.from.show && (_jsxs("th", { id: "from", ...onSort, children: ["From", isSortedDesc('from').content] })), preferences.to.show && (_jsxs("th", { id: "to", ...onSort, children: ["To ", isSortedDesc('to').content] })), preferences.deltaPPM.show && (_jsxs("th", { id: "from", ...onSort, children: ["\u03B4 (ppm) ", isSortedDesc('from').content] })), preferences.deltaHz.show && _jsx("th", { children: "\u03B4 (Hz) " }), preferences.relative.show && (_jsxs("th", { id: "integration", ...onSort, children: ["Rel. ", element, " ", isSortedDesc('integration').content] })), preferences.absolute.show && _jsx("th", { children: "Absolute" }), preferences.showMultiplicity && _jsx("th", { children: "Mult." }), preferences.coupling.show && _jsx("th", { children: "J (Hz)" }), preferences.showAssignment && (_jsxs(_Fragment, { children: [_jsx("th", { title: "Assign multiplets", children: _jsx(FaLink, { style: { fontSize: 10, margin: 'auto' } }) }), _jsx("th", { title: "Assign ranges", style: { minWidth: '50px' }, children: "\u03A3" })] })), preferences.showKind && _jsx("th", { children: "Kind" }), showActions && _jsx("th", { children: '' })] }) }), _jsx("tbody", { children: data?.map((range) => {
71
+ return (_jsx(RangesTableRow, { rowData: range, onUnlink: onUnlink, preferences: preferences, info: info, contextMenu: contextMenu, onContextMenuSelect: onContextMenuSelect }, range.rowKey));
72
+ }) })] })] }));
70
73
  }
71
74
  export default RangesTable;
@@ -2,9 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
4
  import { Fragment } from 'react';
5
- import { FaRegTrashAlt, FaSearchPlus, FaEdit } from 'react-icons/fa';
5
+ import { FaEdit, FaRegTrashAlt, FaSearchPlus } from 'react-icons/fa';
6
6
  import { SIGNAL_KINDS } from '../../../../data/constants/signalsKinds';
7
+ import { useDispatch } from '../../../context/DispatchContext';
8
+ import { useDialog } from '../../../elements/DialogManager';
7
9
  import Select from '../../../elements/Select';
10
+ import { EditRangeModal } from '../../../modal/editRange/EditRangeModal';
8
11
  import useEditRangeModal from '../hooks/useEditRangeModal';
9
12
  const styles = css `
10
13
  width: 66px;
@@ -27,8 +30,23 @@ const selectBoxStyle = {
27
30
  height: '20px',
28
31
  };
29
32
  function ActionsColumn({ row, onHoverSignal, rowSpanTags, showKind, showDeleteAction, showEditAction, showZoomAction, }) {
30
- const { editRange, deleteRange, changeRangeSignalKind, zoomRange } = useEditRangeModal(row);
33
+ const { deleteRange, changeRangeSignalKind, zoomRange } = useEditRangeModal();
31
34
  const showActions = showDeleteAction || showEditAction || showZoomAction;
32
- return (_jsxs(Fragment, { children: [showKind && (_jsx("td", { ...onHoverSignal, children: !row?.tableMetaInfo?.signal ? ('') : (_jsx(Select, { onChange: changeRangeSignalKind, items: SIGNAL_KINDS, defaultValue: row?.tableMetaInfo?.signal?.kind, style: selectBoxStyle })) })), showActions && (_jsxs("td", { ...rowSpanTags, css: styles, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: () => deleteRange(), children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: () => zoomRange(), children: _jsx(FaSearchPlus, { title: "Zoom to range in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: () => editRange(), children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
35
+ const { openDialog } = useDialog();
36
+ const dispatch = useDispatch();
37
+ return (_jsxs(Fragment, { children: [showKind && (_jsx("td", { ...onHoverSignal, children: !row?.tableMetaInfo?.signal ? ('') : (_jsx(Select, { onChange: (kind) => changeRangeSignalKind(kind, row), items: SIGNAL_KINDS, defaultValue: row?.tableMetaInfo?.signal?.kind, style: selectBoxStyle })) })), showActions && (_jsxs("td", { ...rowSpanTags, css: styles, children: [showDeleteAction && (_jsx("button", { type: "button", className: "delete-button", onClick: () => deleteRange(row?.id), children: _jsx(FaRegTrashAlt, {}) })), showZoomAction && (_jsx("button", { type: "button", className: "zoom-button", onClick: () => zoomRange(row), children: _jsx(FaSearchPlus, { title: "Zoom to range in spectrum" }) })), showEditAction && (_jsx("button", { type: "button", className: "edit-button", onClick: () => {
38
+ dispatch({
39
+ type: 'SET_SELECTED_TOOL',
40
+ payload: {
41
+ selectedTool: 'zoom',
42
+ },
43
+ });
44
+ dispatch({
45
+ type: 'TOGGLE_RANGES_VIEW_PROPERTY',
46
+ payload: { key: 'showMultiplicityTrees', value: true },
47
+ });
48
+ zoomRange(row);
49
+ openDialog(EditRangeModal, row.id);
50
+ }, children: _jsx(FaEdit, { color: "blue" }) }))] }))] }));
33
51
  }
34
52
  export default ActionsColumn;
@@ -1,7 +1,8 @@
1
1
  import { RangeData } from './useMapRanges';
2
- export default function useEditRangeModal(range?: RangeData): {
3
- editRange: () => void;
4
- deleteRange: (id?: string, resetSelectTool?: boolean) => void;
5
- zoomRange: (modalRange?: RangeData) => void;
6
- changeRangeSignalKind: (kind: any) => void;
2
+ export default function useEditRangeModal(): {
3
+ deleteRange: (id: string, resetSelectTool?: boolean) => void;
4
+ zoomRange: (range: RangeData) => void;
5
+ changeRangeSignalKind: (kind: any, range: RangeData) => void;
6
+ saveEditRange: (editedRange: any) => void;
7
+ reset: (originalRange: any) => void;
7
8
  };
@@ -1,41 +1,38 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { useCallback, useMemo } from 'react';
3
2
  import { useAssignmentData } from '../../../assignment/AssignmentsContext';
4
3
  import { useDispatch } from '../../../context/DispatchContext';
5
- import { useModal } from '../../../elements/popup/Modal';
6
- import { positions, transitions } from '../../../elements/popup/options';
7
- import EditRangeModal from '../../../modal/editRange/EditRangeModal';
8
- export default function useEditRangeModal(range) {
4
+ function getZoomRange(range) {
5
+ const { from, to } = range;
6
+ const margin = Math.abs(from - to);
7
+ return [from - margin, to + margin];
8
+ }
9
+ export default function useEditRangeModal() {
9
10
  const dispatch = useDispatch();
10
- const modal = useModal();
11
11
  const assignmentData = useAssignmentData();
12
- const zoomRange = useCallback((modalRange) => {
13
- const _range = modalRange || range;
14
- if (_range) {
15
- const { from, to } = _range;
16
- const margin = Math.abs(from - to);
17
- dispatch({
18
- type: 'SET_X_DOMAIN',
19
- payload: {
20
- xDomain: [from - margin, to + margin],
21
- },
22
- });
12
+ const zoomRange = useCallback((range) => {
13
+ if (!range) {
14
+ return;
23
15
  }
24
- }, [dispatch, range]);
16
+ const xDomain = getZoomRange(range);
17
+ dispatch({
18
+ type: 'SET_X_DOMAIN',
19
+ payload: {
20
+ xDomain,
21
+ },
22
+ });
23
+ }, [dispatch]);
25
24
  const deleteRange = useCallback((id, resetSelectTool = false) => {
26
- if (range || id) {
27
- dispatch({
28
- type: 'DELETE_RANGE',
29
- payload: {
30
- id: id || range?.id,
31
- assignmentData,
32
- resetSelectTool,
33
- },
34
- });
35
- }
36
- }, [assignmentData, dispatch, range]);
37
- const changeRangeSignalKind = useCallback((kind) => {
38
- if (range) {
25
+ dispatch({
26
+ type: 'DELETE_RANGE',
27
+ payload: {
28
+ id,
29
+ assignmentData,
30
+ resetSelectTool,
31
+ },
32
+ });
33
+ }, [assignmentData, dispatch]);
34
+ const changeRangeSignalKind = useCallback((kind, range) => {
35
+ if (!range) {
39
36
  dispatch({
40
37
  type: 'CHANGE_RANGE_SIGNAL_KIND',
41
38
  payload: {
@@ -44,8 +41,8 @@ export default function useEditRangeModal(range) {
44
41
  },
45
42
  });
46
43
  }
47
- }, [dispatch, range]);
48
- const saveEditRangeHandler = useCallback((editedRange, automaticCloseModal = true) => {
44
+ }, [dispatch]);
45
+ const saveEditRange = useCallback((editedRange) => {
49
46
  dispatch({
50
47
  type: 'SAVE_EDITED_RANGE',
51
48
  payload: {
@@ -53,39 +50,19 @@ export default function useEditRangeModal(range) {
53
50
  assignmentData,
54
51
  },
55
52
  });
56
- if (automaticCloseModal) {
57
- modal.close();
58
- }
59
- }, [assignmentData, dispatch, modal]);
60
- const resetHandler = useCallback((originalRange) => {
61
- saveEditRangeHandler(originalRange, false);
62
- modal.close();
63
- }, [modal, saveEditRangeHandler]);
64
- const editRange = useCallback(() => {
65
- if (!range?.id)
66
- return;
67
- dispatch({
68
- type: 'SET_SELECTED_TOOL',
69
- payload: { selectedTool: 'editRange' },
70
- });
71
- modal.show(_jsx(EditRangeModal, { onRest: resetHandler, onSave: saveEditRangeHandler, onZoom: zoomRange, rangeId: range?.id }), {
72
- position: positions.MIDDLE_RIGHT,
73
- transition: transitions.SCALE,
74
- isBackgroundBlur: false,
75
- });
76
- zoomRange();
77
- }, [
78
- dispatch,
79
- modal,
80
- range?.id,
81
- resetHandler,
82
- saveEditRangeHandler,
83
- zoomRange,
84
- ]);
53
+ // if (automaticCloseModal) {
54
+ // modal.close();
55
+ // }
56
+ }, [assignmentData, dispatch]);
57
+ const reset = useCallback((originalRange) => {
58
+ saveEditRange(originalRange);
59
+ // modal.close();
60
+ }, [saveEditRange]);
85
61
  return useMemo(() => ({
86
- editRange,
87
62
  deleteRange,
88
63
  zoomRange,
89
64
  changeRangeSignalKind,
90
- }), [changeRangeSignalKind, deleteRange, editRange, zoomRange]);
65
+ saveEditRange,
66
+ reset,
67
+ }), [changeRangeSignalKind, deleteRange, reset, saveEditRange, zoomRange]);
91
68
  }
@@ -1,8 +1,7 @@
1
- declare function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks, correlations, spectraData, onEdit, }: {
1
+ declare function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks, spectraData, onEdit, }: {
2
2
  rowCorrelation: any;
3
3
  columnCorrelation: any;
4
4
  commonLinks: any;
5
- correlations: any;
6
5
  spectraData: any;
7
6
  onEdit: any;
8
7
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,18 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { v4 } from '@lukeed/uuid';
3
3
  import { buildLink } from 'nmr-correlation';
4
- import { useCallback, useMemo, useRef } from 'react';
4
+ import { useCallback, useMemo } from 'react';
5
5
  import { buildID } from '../../../../data/utilities/Concatenation';
6
6
  import { findRangeOrZoneID } from '../../../../data/utilities/FindUtilities';
7
- import ContextMenu from '../../../elements/ContextMenu';
8
- import { positions, useModal } from '../../../elements/popup/Modal';
7
+ import { ContextMenu } from '../../../elements/ContextMenuBluePrint';
8
+ import { useDialog } from '../../../elements/DialogManager';
9
9
  import { useHighlight } from '../../../highlight';
10
10
  import { cloneCorrelationAndEditLink, getAbbreviation, } from '../utilities/Utilities';
11
11
  import useInView from '../utilities/useInView';
12
- import EditLinkModal from './editLink/EditLinkModal';
13
- function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks, correlations, spectraData, onEdit, }) {
14
- const contextRef = useRef();
15
- const modal = useModal();
12
+ import { EditLinkModal } from './editLink/EditLinkModal';
13
+ function getLinkText(link) {
14
+ const { signal: { x, y }, edited, } = link;
15
+ const deltaX = x?.delta?.toFixed(2) ?? '?';
16
+ const deltaY = y?.delta?.toFixed(2) ?? '?';
17
+ const movedLabel = edited?.moved ? '[MOVED]' : '';
18
+ return `${getAbbreviation(link)} (${deltaX} , ${deltaY}) ${movedLabel}`;
19
+ }
20
+ function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks, spectraData, onEdit, }) {
21
+ const { openDialog } = useDialog();
16
22
  const highlightIDsCommonLinks = useMemo(() => {
17
23
  return commonLinks.flatMap((link) => {
18
24
  const ids = [];
@@ -35,10 +41,10 @@ function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks,
35
41
  event.currentTarget.blur();
36
42
  highlightCommonLinks.hide();
37
43
  }, [highlightCommonLinks]);
38
- const contextMenuHandler = useCallback((e) => {
39
- e.preventDefault();
40
- contextRef.current.handleContextMenu(e);
41
- }, [contextRef]);
44
+ function contextMenuHandler(data) {
45
+ highlightCommonLinks.hide();
46
+ openDialog(EditLinkModal, data);
47
+ }
42
48
  const handleEditPseudoHSQC = useCallback((action, link) => {
43
49
  const pseudoLinkCountHSQC = rowCorrelation.link.filter((_link) => (_link.experimentType === 'hsqc' ||
44
50
  _link.experimentType === 'hmqc') &&
@@ -77,21 +83,20 @@ function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks,
77
83
  const contextMenu = useMemo(() => {
78
84
  // allow the edition of correlations
79
85
  const commonLinksMenu = commonLinks.flatMap((commonLink) => {
80
- const commonLinkContextMenuLabel = `${getAbbreviation(commonLink)} (${commonLink.signal.x?.delta ? commonLink.signal.x.delta.toFixed(2) : '?'}, ${commonLink.signal.y?.delta ? commonLink.signal.y.delta.toFixed(2) : '?'})${commonLink.edited?.moved === true ? '[MOVED]' : ''}`;
81
- return commonLink.pseudo === false
82
- ? [
83
- {
84
- label: `edit ${commonLinkContextMenuLabel}`,
85
- onClick: () => {
86
- highlightCommonLinks.hide();
87
- modal.show(_jsx(EditLinkModal, { onClose: () => modal.close(), onEdit: onEdit, link: commonLink, correlationDim1: columnCorrelation, correlationDim2: rowCorrelation, correlations: correlations }), {
88
- position: positions.MIDDLE_RIGHT,
89
- isBackgroundBlur: false,
90
- });
91
- },
86
+ if (commonLink.pseudo !== false) {
87
+ return [];
88
+ }
89
+ return [
90
+ {
91
+ text: `Edit ${getLinkText(commonLink)}`,
92
+ icon: 'edit',
93
+ data: {
94
+ link: commonLink,
95
+ correlationDim1: columnCorrelation,
96
+ correlationDim2: rowCorrelation,
92
97
  },
93
- ]
94
- : [];
98
+ },
99
+ ];
95
100
  });
96
101
  // allow addition or removal of a pseudo HSQC link between pseudo heavy atom and proton
97
102
  const commonPseudoLinkHSQC = commonLinks.find((commonLink) => commonLink.pseudo === true && commonLink.experimentType === 'hsqc');
@@ -110,16 +115,7 @@ function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks,
110
115
  }
111
116
  }
112
117
  return commonLinksMenu;
113
- }, [
114
- columnCorrelation,
115
- commonLinks,
116
- correlations,
117
- handleEditPseudoHSQC,
118
- highlightCommonLinks,
119
- modal,
120
- onEdit,
121
- rowCorrelation,
122
- ]);
118
+ }, [columnCorrelation, commonLinks, handleEditPseudoHSQC, rowCorrelation]);
123
119
  const contentLabel = useMemo(() => commonLinks.map((commonLink, i) => (_jsxs("label", { children: [_jsx("label", { style: {
124
120
  color: commonLink.pseudo === true || commonLink.edited?.moved === true
125
121
  ? 'blue'
@@ -127,17 +123,13 @@ function AdditionalColumnField({ rowCorrelation, columnCorrelation, commonLinks,
127
123
  }, children: getAbbreviation(commonLink) }), i < commonLinks.length - 1 && _jsx("label", { children: "/" })] }, commonLink.id))), [commonLinks]);
128
124
  const isInViewRow = useInView({ correlation: rowCorrelation });
129
125
  const isInViewColumn = useInView({ correlation: columnCorrelation });
130
- return (_jsxs("td", { onContextMenu: (e) => {
131
- if (contextMenu.length > 0) {
132
- contextMenuHandler(e);
133
- }
134
- }, style: {
126
+ return (_jsx(ContextMenu, { as: "td", options: contextMenu, onSelect: contextMenuHandler, style: {
135
127
  backgroundColor: highlightCommonLinks.isActive
136
128
  ? '#ff6f0057'
137
129
  : isInViewColumn || isInViewRow
138
130
  ? '#f5f5dc'
139
131
  : 'inherit',
140
- }, title: getTitle(commonLinks), onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, children: [contentLabel, _jsx(ContextMenu, { ref: contextRef, context: contextMenu })] }));
132
+ }, title: getTitle(commonLinks), onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, children: contentLabel }));
141
133
  }
142
134
  function getTitle(commonLinks) {
143
135
  if (commonLinks?.length === 0) {
@@ -1,20 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { getCorrelationDelta, getLinkDim } from 'nmr-correlation';
4
- import { useCallback, useMemo, useRef } from 'react';
4
+ import { useCallback, useMemo } from 'react';
5
5
  import { buildID } from '../../../../data/utilities/Concatenation';
6
6
  import { findRangeOrZoneID } from '../../../../data/utilities/FindUtilities';
7
7
  import { useAlert } from '../../../elements/Alert';
8
- import ContextMenu from '../../../elements/ContextMenu';
9
- import { positions, useModal } from '../../../elements/popup/Modal';
8
+ import { ContextMenu, } from '../../../elements/ContextMenuBluePrint';
9
+ import { useDialog } from '../../../elements/DialogManager';
10
10
  import { useHighlight } from '../../../highlight';
11
11
  import { getLabelColor } from '../utilities/Utilities';
12
12
  import useInView from '../utilities/useInView';
13
- import EditLinkModal from './editLink/EditLinkModal';
13
+ import { EditLinkModal } from './editLink/EditLinkModal';
14
14
  function AdditionalColumnHeader({ spectraData, correlationsData, correlation, onEdit, }) {
15
- const contextRef = useRef();
16
- const modal = useModal();
17
15
  const alert = useAlert();
16
+ const { openDialog } = useDialog();
18
17
  const highlightIDsAdditionalColumn = useMemo(() => {
19
18
  if (correlation.pseudo === true) {
20
19
  return [];
@@ -85,61 +84,73 @@ function AdditionalColumnHeader({ spectraData, correlationsData, correlation, on
85
84
  };
86
85
  }, [correlation]);
87
86
  const contextMenu = useMemo(() => {
88
- return correlation.pseudo === false
89
- ? correlation.link
90
- .filter((link) => getLinkDim(link) === 1 && link.pseudo === false)
91
- .map((link) => {
92
- return {
93
- label: `edit 1D (${link.signal.delta.toFixed(3)}${link.edited?.moved === true ? '[MOVED]' : ''})`,
94
- onClick: () => {
95
- highlightAdditionalColumn.hide();
96
- modal.show(_jsx(EditLinkModal, { onClose: () => modal.close(), onEdit: onEdit, link: link, correlationDim1: correlation, correlationDim2: undefined, correlations: correlationsData.values }), { position: positions.MIDDLE_RIGHT, isBackgroundBlur: false });
87
+ if (correlation.pseudo !== false) {
88
+ return [];
89
+ }
90
+ const contextMenus = [
91
+ {
92
+ text: `Delete all (${correlation.label.origin})`,
93
+ icon: 'trash',
94
+ data: { action: 'removeAll' },
95
+ },
96
+ ];
97
+ for (const link of correlation.link) {
98
+ const isValidLink = getLinkDim(link) === 1 && link.pseudo === false;
99
+ if (isValidLink) {
100
+ const contextMenu = {
101
+ text: `Edit 1D (${link.signal.delta.toFixed(3)}${link.edited?.moved === true ? '[MOVED]' : ''})`,
102
+ icon: 'edit',
103
+ data: {
104
+ action: 'edit',
105
+ data: {
106
+ link,
107
+ correlationDim1: correlation,
108
+ correlationDim2: null,
109
+ },
97
110
  },
98
111
  };
99
- })
100
- .concat([
112
+ contextMenus.push(contextMenu);
113
+ }
114
+ }
115
+ return contextMenus;
116
+ }, [correlation]);
117
+ function removeAllLinks() {
118
+ alert.showAlert({
119
+ message: `All signals of ${correlation.label.origin} (${getCorrelationDelta(correlation).toFixed(2)}) will be deleted. Are you sure?`,
120
+ buttons: [
101
121
  {
102
- label: `delete all (${correlation.label.origin})`,
122
+ text: 'Yes',
103
123
  onClick: () => {
104
- alert.showAlert({
105
- message: `All signals of ${correlation.label.origin} (${getCorrelationDelta(correlation).toFixed(2)}) will be deleted. Are you sure?`,
106
- buttons: [
107
- {
108
- text: 'Yes',
109
- onClick: () => {
110
- onEdit([correlation], 'removeAll');
111
- },
112
- intent: 'danger',
113
- },
114
- { text: 'No' },
115
- ],
116
- });
117
- highlightAdditionalColumn.hide();
124
+ onEdit([correlation], 'removeAll');
118
125
  },
126
+ intent: 'danger',
119
127
  },
120
- ])
121
- : [];
122
- }, [
123
- alert,
124
- correlation,
125
- correlationsData.values,
126
- highlightAdditionalColumn,
127
- modal,
128
- onEdit,
129
- ]);
130
- const contextMenuHandler = useCallback((e) => {
131
- e.preventDefault();
132
- contextRef.current.handleContextMenu(e);
133
- }, [contextRef]);
128
+ { text: 'No' },
129
+ ],
130
+ });
131
+ highlightAdditionalColumn.hide();
132
+ }
133
+ function contextMenuHandler(selectedItem) {
134
+ const { action, data } = selectedItem;
135
+ switch (action) {
136
+ case 'removeAll': {
137
+ removeAllLinks();
138
+ break;
139
+ }
140
+ case 'edit': {
141
+ highlightAdditionalColumn.hide();
142
+ openDialog(EditLinkModal, data);
143
+ break;
144
+ }
145
+ default:
146
+ break;
147
+ }
148
+ }
134
149
  const { title, ...thProps } = tableHeaderProps;
135
- return (_jsx("th", { ...thProps, title: title === false ? undefined : title, children: _jsxs("div", { style: { display: 'block' }, onContextMenu: (e) => {
136
- if (contextMenu.length > 0) {
137
- contextMenuHandler(e);
138
- }
139
- }, children: [_jsx("p", { children: correlation.label.origin }), _jsx("p", { children: getCorrelationDelta(correlation)
140
- ? getCorrelationDelta(correlation)?.toFixed(2)
141
- : '' }), _jsx("p", { style: equivalenceTextStyle, children: Number.isInteger(correlation.equivalence)
142
- ? correlation.equivalence
143
- : correlation.equivalence.toFixed(2) }), _jsx(ContextMenu, { ref: contextRef, context: contextMenu })] }) }));
150
+ return (_jsxs(ContextMenu, { onSelect: (selected) => contextMenuHandler(selected), options: contextMenu, as: "th", ...thProps, title: title === false ? undefined : title, children: [_jsx("p", { children: correlation.label.origin }), _jsx("p", { children: getCorrelationDelta(correlation)
151
+ ? getCorrelationDelta(correlation)?.toFixed(2)
152
+ : '' }), _jsx("p", { style: equivalenceTextStyle, children: Number.isInteger(correlation.equivalence)
153
+ ? correlation.equivalence
154
+ : correlation.equivalence.toFixed(2) })] }));
144
155
  }
145
156
  export default AdditionalColumnHeader;