nmrium 0.57.1 → 0.59.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 (139) hide show
  1. package/lib/component/1d/integral/IntegralResizable.js +2 -2
  2. package/lib/component/1d/matrix/useMatrix.d.ts +1 -1
  3. package/lib/component/1d/multiAnalysis/AnalysisRange.js +1 -1
  4. package/lib/component/1d/ranges/Atoms.js +6 -4
  5. package/lib/component/1d-2d/components/SpectrumInfoBlock.d.ts +1 -1
  6. package/lib/component/1d-2d/components/SpectrumInfoBlock.js +114 -7
  7. package/lib/component/2d/Viewer2D.js +6 -2
  8. package/lib/component/2d/zones/Zone.js +2 -2
  9. package/lib/component/EventsTrackers/KeysListenerTracker.js +8 -8
  10. package/lib/component/context/ChartContext.js +12 -1
  11. package/lib/component/context/ShareDataContext.d.ts +1 -1
  12. package/lib/component/context/ShareDataContext.js +2 -4
  13. package/lib/component/context/ToasterContext.d.ts +1 -0
  14. package/lib/component/context/ToasterContext.js +12 -3
  15. package/lib/component/elements/ActionsButtonsPopover.d.ts +7 -1
  16. package/lib/component/elements/ActionsButtonsPopover.js +7 -6
  17. package/lib/component/elements/Alert.d.ts +20 -0
  18. package/lib/component/elements/Alert.js +80 -0
  19. package/lib/component/elements/ContextMenuBluePrint.d.ts +7 -2
  20. package/lib/component/elements/ContextMenuBluePrint.js +9 -3
  21. package/lib/component/elements/Input2.js +2 -2
  22. package/lib/component/elements/Input2Controller.d.ts +4 -2
  23. package/lib/component/elements/Input2Controller.js +22 -6
  24. package/lib/component/elements/MoleculeSelection.js +2 -2
  25. package/lib/component/elements/NextPrev.d.ts +4 -5
  26. package/lib/component/elements/NextPrev.js +76 -79
  27. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +1 -1
  28. package/lib/component/elements/ReactTable/ReactTableFlexLayout.d.ts +0 -3
  29. package/lib/component/elements/ReactTable/ReactTableFlexLayout.js +1 -1
  30. package/lib/component/elements/Select2.d.ts +12 -7
  31. package/lib/component/elements/Select2.js +5 -4
  32. package/lib/component/elements/Select2Controller.d.ts +2 -2
  33. package/lib/component/elements/Select2Controller.js +5 -5
  34. package/lib/component/elements/ToolbarPopoverItem.d.ts +7 -6
  35. package/lib/component/elements/ToolbarPopoverItem.js +13 -5
  36. package/lib/component/elements/print/PrintContent.d.ts +17 -0
  37. package/lib/component/elements/print/PrintContent.js +281 -0
  38. package/lib/component/elements/print/PrintProvider.d.ts +12 -0
  39. package/lib/component/elements/print/PrintProvider.js +28 -0
  40. package/lib/component/elements/print/index.d.ts +2 -0
  41. package/lib/component/elements/print/index.js +2 -0
  42. package/lib/component/header/ApodizationOptionsPanel.js +14 -7
  43. package/lib/component/header/BaseLineCorrectionPanel.js +20 -10
  44. package/lib/component/header/ZeroFillingOptionsPanel.js +17 -10
  45. package/lib/component/hooks/useSaveSettings.js +43 -26
  46. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +14 -9
  47. package/lib/component/hooks/useToggleSpectraVisibility.js +45 -16
  48. package/lib/component/hooks/useWorkspaceAction.js +12 -14
  49. package/lib/component/loader/DropZone.js +3 -67
  50. package/lib/component/loader/useLoadFiles.d.ts +1 -0
  51. package/lib/component/loader/useLoadFiles.js +78 -0
  52. package/lib/component/main/InnerNMRium.d.ts +4 -3
  53. package/lib/component/main/InnerNMRium.js +4 -9
  54. package/lib/component/main/InnerNMRiumContents.d.ts +3 -2
  55. package/lib/component/main/InnerNMRiumContents.js +33 -29
  56. package/lib/component/main/NMRium.d.ts +2 -5
  57. package/lib/component/main/NMRium.js +1 -1
  58. package/lib/component/main/NMRiumRefAPI.d.ts +7 -0
  59. package/lib/component/main/NMRiumRefAPI.js +12 -0
  60. package/lib/component/main/NMRiumViewer.d.ts +10 -0
  61. package/lib/component/main/NMRiumViewer.js +35 -0
  62. package/lib/component/main/index.d.ts +1 -0
  63. package/lib/component/modal/CopyClipboardModal.d.ts +3 -2
  64. package/lib/component/modal/CopyClipboardModal.js +18 -32
  65. package/lib/component/modal/ExportAsJcampModal.d.ts +6 -3
  66. package/lib/component/modal/ExportAsJcampModal.js +69 -35
  67. package/lib/component/modal/ImportPublicationStringModal.js +1 -1
  68. package/lib/component/modal/LoadJCAMPModal.d.ts +3 -1
  69. package/lib/component/modal/LoadJCAMPModal.js +17 -18
  70. package/lib/component/modal/SaveAsModal.d.ts +3 -1
  71. package/lib/component/modal/SaveAsModal.js +20 -30
  72. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  73. package/lib/component/modal/changeSum/ChangeSumModalContents.js +35 -47
  74. package/lib/component/modal/changeSum/SelectMolecule.d.ts +2 -5
  75. package/lib/component/modal/changeSum/SelectMolecule.js +9 -8
  76. package/lib/component/modal/setting/GeneralSettings.js +4 -2
  77. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.d.ts +1 -0
  78. package/lib/component/modal/setting/settings-tabs/ExternalAPIsTabContent.js +89 -0
  79. package/lib/component/modal/setting/settingsValidation.js +15 -1
  80. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +8 -5
  81. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +5 -1
  82. package/lib/component/panels/MoleculesPanel/MoleculePanel.js +5 -3
  83. package/lib/component/panels/Panels.js +15 -15
  84. package/lib/component/panels/PeaksPanel/PeaksPanel.js +8 -5
  85. package/lib/component/panels/RangesPanel/RangesHeader.js +52 -12
  86. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +13 -6
  87. package/lib/component/panels/SpectraPanel/SpectraTable.js +63 -21
  88. package/lib/component/panels/SummaryPanel/CorrelationTable/AdditionalColumnHeader.js +6 -2
  89. package/lib/component/panels/SummaryPanel/CorrelationTable/CorrelationTableRow.js +6 -2
  90. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -0
  91. package/lib/component/panels/ZonesPanel/ZonesPanel.js +16 -8
  92. package/lib/component/panels/databasePanel/DatabasePanel.js +7 -8
  93. package/lib/component/panels/filtersPanel/FilterPanel.js +9 -6
  94. package/lib/component/panels/filtersPanel/FiltersTable.js +12 -10
  95. package/lib/component/panels/header/DefaultPanelHeader.d.ts +1 -0
  96. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  97. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +10 -12
  98. package/lib/component/panels/predictionPanel/PredictionPanel.js +2 -2
  99. package/lib/component/reducer/IgnoreActions.js +1 -0
  100. package/lib/component/reducer/Reducer.js +2 -4
  101. package/lib/component/reducer/actions/DatabaseActions.d.ts +15 -13
  102. package/lib/component/reducer/actions/DatabaseActions.js +52 -34
  103. package/lib/component/reducer/actions/DomainActions.d.ts +2 -2
  104. package/lib/component/reducer/actions/FiltersActions.js +9 -4
  105. package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
  106. package/lib/component/reducer/actions/SpectraActions.js +53 -43
  107. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.d.ts +3 -0
  108. package/lib/component/reducer/helper/removeSpectrumRelatedObjectsById.js +16 -0
  109. package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.d.ts +3 -0
  110. package/lib/component/reducer/preferences/actions/changeInformationBlockPosition.js +5 -0
  111. package/lib/component/reducer/preferences/actions/changePrintPageSettings.d.ts +3 -0
  112. package/lib/component/reducer/preferences/actions/changePrintPageSettings.js +6 -0
  113. package/lib/component/reducer/preferences/actions/toggleInformationBlock.d.ts +3 -0
  114. package/lib/component/reducer/preferences/actions/toggleInformationBlock.js +7 -0
  115. package/lib/component/reducer/preferences/preferencesReducer.d.ts +12 -2
  116. package/lib/component/reducer/preferences/preferencesReducer.js +9 -0
  117. package/lib/component/toolbar/ToolBar.js +33 -14
  118. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  119. package/lib/data/SpectraManager.d.ts +7 -10
  120. package/lib/data/SpectraManager.js +51 -30
  121. package/lib/data/data1d/Spectrum1D/SumManager.d.ts +0 -1
  122. package/lib/data/data1d/Spectrum1D/SumManager.js +2 -10
  123. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +1 -1
  124. package/lib/data/data1d/Spectrum1D/index.d.ts +1 -1
  125. package/lib/data/data1d/Spectrum1D/index.js +1 -1
  126. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +10 -10
  127. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +2 -1
  128. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +10 -10
  129. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +10 -10
  130. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.d.ts +13 -0
  131. package/lib/data/data1d/Spectrum1D/ranges/resurrectSpectrum.js +65 -0
  132. package/lib/data/molecules/MoleculeManager.js +16 -38
  133. package/lib/data/utilities/getCustomColor.d.ts +1 -1
  134. package/lib/data/utilities/removeByPaths.d.ts +3 -0
  135. package/lib/data/utilities/removeByPaths.js +33 -0
  136. package/lib/versionInfo.js +1 -1
  137. package/package.json +36 -36
  138. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.d.ts +0 -11
  139. package/lib/data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges.js +0 -29
@@ -4,6 +4,7 @@ import { getCorrelationDelta, getLinkDim } from 'nmr-correlation';
4
4
  import { useCallback, useMemo, useRef } from 'react';
5
5
  import { buildID } from '../../../../data/utilities/Concatenation';
6
6
  import { findRangeOrZoneID } from '../../../../data/utilities/FindUtilities';
7
+ import { useAlert } from '../../../elements/Alert';
7
8
  import ContextMenu from '../../../elements/ContextMenu';
8
9
  import { positions, useModal } from '../../../elements/popup/Modal';
9
10
  import { useHighlight } from '../../../highlight';
@@ -13,6 +14,7 @@ import EditLinkModal from './editLink/EditLinkModal';
13
14
  function AdditionalColumnHeader({ spectraData, correlationsData, correlation, onEdit, }) {
14
15
  const contextRef = useRef();
15
16
  const modal = useModal();
17
+ const alert = useAlert();
16
18
  const highlightIDsAdditionalColumn = useMemo(() => {
17
19
  if (correlation.pseudo === true) {
18
20
  return [];
@@ -99,14 +101,15 @@ function AdditionalColumnHeader({ spectraData, correlationsData, correlation, on
99
101
  {
100
102
  label: `delete all (${correlation.label.origin})`,
101
103
  onClick: () => {
102
- modal.showConfirmDialog({
104
+ alert.showAlert({
103
105
  message: `All signals of ${correlation.label.origin} (${getCorrelationDelta(correlation).toFixed(2)}) will be deleted. Are you sure?`,
104
106
  buttons: [
105
107
  {
106
108
  text: 'Yes',
107
- handler: () => {
109
+ onClick: () => {
108
110
  onEdit([correlation], 'removeAll');
109
111
  },
112
+ intent: 'danger',
110
113
  },
111
114
  { text: 'No' },
112
115
  ],
@@ -117,6 +120,7 @@ function AdditionalColumnHeader({ spectraData, correlationsData, correlation, on
117
120
  ])
118
121
  : [];
119
122
  }, [
123
+ alert,
120
124
  correlation,
121
125
  correlationsData.values,
122
126
  highlightAdditionalColumn,
@@ -3,6 +3,7 @@ import { buildLink, getCorrelationDelta, getLabel, getLinkDim, } from 'nmr-corre
3
3
  import { useCallback, useMemo, useRef } from 'react';
4
4
  import { buildID } from '../../../../data/utilities/Concatenation';
5
5
  import { findRangeOrZoneID } from '../../../../data/utilities/FindUtilities';
6
+ import { useAlert } from '../../../elements/Alert';
6
7
  import ContextMenu from '../../../elements/ContextMenu';
7
8
  import EditableColumn from '../../../elements/EditableColumn';
8
9
  import { positions, useModal } from '../../../elements/popup/Modal';
@@ -14,6 +15,7 @@ import EditLinkModal from './editLink/EditLinkModal';
14
15
  function CorrelationTableRow({ additionalColumnData, correlations, correlation, styleRow, styleLabel, onSaveEditEquivalences, onSaveEditNumericValues, onEditCorrelationTableCellHandler, spectraData, }) {
15
16
  const contextRef = useRef();
16
17
  const modal = useModal();
18
+ const alert = useAlert();
17
19
  const highlightIDsRow = useMemo(() => {
18
20
  if (correlation.pseudo === true) {
19
21
  return [];
@@ -141,14 +143,15 @@ function CorrelationTableRow({ additionalColumnData, correlations, correlation,
141
143
  {
142
144
  label: `delete ${correlation.label.origin}`,
143
145
  onClick: () => {
144
- modal.showConfirmDialog({
146
+ alert.showAlert({
145
147
  message: `All signals of ${correlation.label.origin} (${getCorrelationDelta(correlation).toFixed(2)}) will be deleted. Are you sure?`,
146
148
  buttons: [
147
149
  {
148
150
  text: 'Yes',
149
- handler: () => {
151
+ onClick: () => {
150
152
  onEditCorrelationTableCellHandler([correlation], 'removeAll');
151
153
  },
154
+ intent: 'danger',
152
155
  },
153
156
  { text: 'No' },
154
157
  ],
@@ -164,6 +167,7 @@ function CorrelationTableRow({ additionalColumnData, correlations, correlation,
164
167
  modal,
165
168
  onEditCorrelationTableCellHandler,
166
169
  correlations,
170
+ alert,
167
171
  ]);
168
172
  const contextMenuHandler = useCallback((e) => {
169
173
  e.preventDefault();
@@ -198,6 +198,10 @@ function SummaryPanel() {
198
198
  });
199
199
  }, [dispatch]);
200
200
  const deleteCorrelationHandler = useCallback((correlation) => {
201
+ const correlationLinks = correlation?.links;
202
+ if (!(Array.isArray(correlationLinks) && correlationLinks.length > 0)) {
203
+ return;
204
+ }
201
205
  dispatch({
202
206
  type: 'DELETE_CORRELATION',
203
207
  payload: {
@@ -7,7 +7,7 @@ import { LuSubtitles } from 'react-icons/lu';
7
7
  import { useAssignmentData } from '../../assignment/AssignmentsContext';
8
8
  import { useChartData } from '../../context/ChartContext';
9
9
  import { useDispatch } from '../../context/DispatchContext';
10
- import { useModal } from '../../elements/popup/Modal';
10
+ import { useAlert } from '../../elements/Alert';
11
11
  import { useActiveSpectrumZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
12
12
  import useSpectrum from '../../hooks/useSpectrum';
13
13
  import { booleanToString } from '../../utility/booleanToString';
@@ -20,7 +20,7 @@ function ZonesPanelInner({ zones, activeTab, xDomain, yDomain, info, showZones,
20
20
  const [filterIsActive, setFilterIsActive] = useState(false);
21
21
  const assignmentData = useAssignmentData();
22
22
  const dispatch = useDispatch();
23
- const modal = useModal();
23
+ const alert = useAlert();
24
24
  const [isFlipped, setFlipStatus] = useState(false);
25
25
  const settingRef = useRef();
26
26
  const tableData = useMemo(() => {
@@ -73,25 +73,33 @@ function ZonesPanelInner({ zones, activeTab, xDomain, yDomain, info, showZones,
73
73
  unlinkZoneHandler();
74
74
  }, [unlinkZoneHandler]);
75
75
  const handleOnRemoveAssignments = useCallback(() => {
76
- modal.showConfirmDialog({
76
+ alert.showAlert({
77
77
  message: 'All assignments will be removed. Are you sure?',
78
- buttons: [{ text: 'Yes', handler: removeAssignments }, { text: 'No' }],
78
+ buttons: [
79
+ {
80
+ text: 'Yes',
81
+ onClick: removeAssignments,
82
+ intent: 'danger',
83
+ },
84
+ { text: 'No' },
85
+ ],
79
86
  });
80
- }, [removeAssignments, modal]);
87
+ }, [removeAssignments, alert]);
81
88
  const handleDeleteAll = useCallback(() => {
82
- modal.showConfirmDialog({
89
+ alert.showAlert({
83
90
  message: 'All zones will be deleted. Are You sure?',
84
91
  buttons: [
85
92
  {
86
93
  text: 'Yes',
87
- handler: () => {
94
+ onClick: () => {
88
95
  dispatch({ type: 'DELETE_2D_ZONE', payload: { assignmentData } });
89
96
  },
97
+ intent: 'danger',
90
98
  },
91
99
  { text: 'No' },
92
100
  ],
93
101
  });
94
- }, [assignmentData, dispatch, modal]);
102
+ }, [assignmentData, dispatch, alert]);
95
103
  const settingsPanelHandler = useCallback(() => {
96
104
  setFlipStatus(!isFlipped);
97
105
  }, [isFlipped]);
@@ -177,7 +177,7 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
177
177
  }, [result.data]);
178
178
  const resurrectHandler = useCallback((rowData) => {
179
179
  const { index, baseURL, jcampURL: jcampRelativeURL } = rowData;
180
- const { ranges, solvent, names = [], id: spectrumID, } = result.data[index];
180
+ const databaseEntry = result.data[index];
181
181
  if (jcampRelativeURL) {
182
182
  const url = new URL(jcampRelativeURL, baseURL);
183
183
  setTimeout(async () => {
@@ -189,11 +189,10 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
189
189
  entries: [{ baseURL: url.origin, relativePath: url.pathname }],
190
190
  });
191
191
  const spectrum = data?.spectra?.[0] || null;
192
- if (spectrum && isSpectrum1D(spectrum) && spectrumID) {
193
- spectrum.id = spectrumID;
192
+ if (spectrum && isSpectrum1D(spectrum)) {
194
193
  dispatch({
195
- type: 'RESURRECTING_SPECTRUM_FROM_JCAMP',
196
- payload: { ranges, spectrum },
194
+ type: 'RESURRECTING_SPECTRUM',
195
+ payload: { source: 'jcamp', databaseEntry, spectrum },
197
196
  });
198
197
  }
199
198
  }
@@ -207,11 +206,11 @@ function DatabasePanelInner({ nucleus, selectedTool, databases, defaultDatabase,
207
206
  }
208
207
  else {
209
208
  dispatch({
210
- type: 'RESURRECTING_SPECTRUM_FROM_RANGES',
211
- payload: { ranges, info: { solvent, nucleus, name: names[0] } },
209
+ type: 'RESURRECTING_SPECTRUM',
210
+ payload: { source: 'rangesOrSignals', databaseEntry },
212
211
  });
213
212
  }
214
- }, [dispatch, nucleus, result.data, toaster]);
213
+ }, [dispatch, result.data, toaster]);
215
214
  const saveHandler = useCallback((row) => {
216
215
  if (row?.jcampURL) {
217
216
  setTimeout(async () => {
@@ -1,32 +1,35 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  import { useDispatch } from '../../context/DispatchContext';
3
3
  import { useToaster } from '../../context/ToasterContext';
4
- import { useModal } from '../../elements/popup/Modal/Context';
4
+ import { useAlert } from '../../elements/Alert';
5
+ import useSpectrum from '../../hooks/useSpectrum';
5
6
  import { tablePanelStyle } from '../extra/BasicPanelStyle';
6
7
  import DefaultPanelHeader from '../header/DefaultPanelHeader';
7
8
  import FiltersTable from './FiltersTable';
8
9
  export default function FiltersPanel() {
9
10
  const dispatch = useDispatch();
10
- const modal = useModal();
11
11
  const toaster = useToaster();
12
+ const { showAlert } = useAlert();
13
+ const { filters } = useSpectrum({ filters: [] });
12
14
  function handelDeleteFilter() {
13
15
  const buttons = [
14
16
  {
15
17
  text: 'Yes',
16
- handler: async () => {
17
- const hideLoading = toaster.showLoading({
18
+ onClick: async () => {
19
+ const hideLoading = await toaster.showAsyncLoading({
18
20
  message: 'Delete filters process in progress',
19
21
  });
20
22
  dispatch({ type: 'DELETE_FILTER', payload: {} });
21
23
  hideLoading();
22
24
  },
25
+ intent: 'danger',
23
26
  },
24
27
  { text: 'No' },
25
28
  ];
26
- modal.showConfirmDialog({
29
+ showAlert({
27
30
  message: 'You are about to delete all processing steps, Are you sure?',
28
31
  buttons,
29
32
  });
30
33
  }
31
- return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { deleteToolTip: "Delete all filters", onDelete: handelDeleteFilter }), _jsx("div", { className: "inner-container", children: _jsx(FiltersTable, {}) })] }));
34
+ return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { deleteToolTip: "Delete all filters", onDelete: handelDeleteFilter, total: filters?.length, hideCounter: true }), _jsx("div", { className: "inner-container", children: _jsx(FiltersTable, {}) })] }));
32
35
  }
@@ -6,10 +6,10 @@ import { ObjectInspector } from 'react-inspector';
6
6
  import { useChartData } from '../../context/ChartContext';
7
7
  import { useDispatch } from '../../context/DispatchContext';
8
8
  import { useToaster } from '../../context/ToasterContext';
9
+ import { useAlert } from '../../elements/Alert';
9
10
  import Button from '../../elements/Button';
10
11
  import { ColumnWrapper } from '../../elements/ColumnWrapper';
11
12
  import ReactTable from '../../elements/ReactTable/ReactTable';
12
- import { useModal } from '../../elements/popup/Modal';
13
13
  import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
14
14
  import useSpectrum from '../../hooks/useSpectrum';
15
15
  const rowColors = {
@@ -30,7 +30,7 @@ const rowColors = {
30
30
  };
31
31
  function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
32
32
  const dispatch = useDispatch();
33
- const modal = useModal();
33
+ const alert = useAlert();
34
34
  const toaster = useToaster();
35
35
  const selectedFilterIndex = useRef();
36
36
  const handelFilterCheck = useCallback((id, event) => {
@@ -47,21 +47,22 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
47
47
  const buttons = [
48
48
  {
49
49
  text: 'Yes',
50
- handler: () => {
51
- const hideLoading = toaster.showLoading({
50
+ onClick: async () => {
51
+ const hideLoading = await toaster.showAsyncLoading({
52
52
  message: 'Delete filter process in progress',
53
53
  });
54
54
  dispatch({ type: 'DELETE_FILTER', payload: { id } });
55
55
  hideLoading();
56
56
  },
57
+ intent: 'danger',
57
58
  },
58
59
  { text: 'No' },
59
60
  ];
60
61
  if (spectraCounter > 1) {
61
62
  buttons.unshift({
62
63
  text: 'Yes, for all spectra',
63
- handler: () => {
64
- const hideLoading = toaster.showLoading({
64
+ onClick: async () => {
65
+ const hideLoading = await toaster.showAsyncLoading({
65
66
  message: 'Delete all spectra filter process in progress',
66
67
  });
67
68
  dispatch({
@@ -70,13 +71,14 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
70
71
  });
71
72
  hideLoading();
72
73
  },
74
+ intent: spectraCounter ? 'danger' : 'none',
73
75
  });
74
76
  }
75
- modal.showConfirmDialog({
77
+ alert.showAlert({
76
78
  message: (_jsxs("span", { children: ["You are about to delete this processing step", _jsxs("span", { style: { color: 'black' }, children: [" ", label, " "] }), " , Are you sure?"] })),
77
79
  buttons,
78
- }, { height: 'auto', width: 'auto' });
79
- }, [dispatch, modal, spectraCounter, toaster]);
80
+ });
81
+ }, [alert, dispatch, spectraCounter, toaster]);
80
82
  const filterSnapShotHandler = useCallback((filter, index) => {
81
83
  selectedFilterIndex.current =
82
84
  selectedFilterIndex.current && index === selectedFilterIndex.current
@@ -134,7 +136,7 @@ function FiltersTableInner({ filters, spectraCounter, activeFilterID, }) {
134
136
  if (activeFilterID === id) {
135
137
  return rowColors.active;
136
138
  }
137
- else if (selectedFilterIndex.current &&
139
+ else if (selectedFilterIndex.current != null &&
138
140
  index > selectedFilterIndex.current) {
139
141
  return rowColors.deActive;
140
142
  }
@@ -18,6 +18,7 @@ interface DefaultPanelHeaderProps {
18
18
  className?: string;
19
19
  leftButtons?: ToolbarItemProps[];
20
20
  rightButtons?: ToolbarItemProps[];
21
+ hideCounter?: boolean;
21
22
  }
22
23
  export declare function formatCounterLabel(counter?: number, total?: number): string;
23
24
  declare function DefaultPanelHeader(props: DefaultPanelHeaderProps): import("react/jsx-runtime").JSX.Element;
@@ -29,13 +29,13 @@ export function formatCounterLabel(counter, total) {
29
29
  return '';
30
30
  }
31
31
  function DefaultPanelHeader(props) {
32
- const { total, counter, onDelete, deleteToolTip = 'Delete', onFilter, filterToolTip = '', children, onSettingClick, disableDelete = false, style = {}, className = '', rightButtons = [], leftButtons = [], } = props;
32
+ const { total, counter, onDelete, deleteToolTip = 'Delete', onFilter, filterToolTip = '', children, onSettingClick, disableDelete = false, style = {}, className = '', rightButtons = [], leftButtons = [], hideCounter = false, } = props;
33
33
  const [isFiltered, setFilterStatus] = useState(false);
34
34
  function handleFilter() {
35
35
  setFilterStatus((previousValue) => !previousValue);
36
36
  onFilter?.();
37
37
  }
38
- return (_jsxs(PanelHeader, { style, className, children: [_jsxs("div", { style: styles.leftContainer, children: [_jsxs(Toolbar, { children: [onDelete && (_jsx(Toolbar.Item, { id: "delete-button", onClick: onDelete, tooltip: deleteToolTip, icon: _jsx(FaRegTrashAlt, {}), intent: "danger", disabled: !total || disableDelete })), onFilter && (_jsx(Toolbar.Item, { id: "filter-button", onClick: handleFilter, tooltip: filterToolTip, active: isFiltered, icon: _jsx(FaFilter, {}) })), mapToolbarButtons(leftButtons)] }), children] }), _jsx(Toolbar, { children: mapToolbarButtons(rightButtons) }), _jsx(CounterLabel, { value: formatCounterLabel(counter, total) }), onSettingClick && (_jsx(PreferencesButton, { tooltip: "Preferences", onClick: onSettingClick }))] }));
38
+ return (_jsxs(PanelHeader, { style, className, children: [_jsxs("div", { style: styles.leftContainer, children: [_jsxs(Toolbar, { children: [onDelete && (_jsx(Toolbar.Item, { id: "delete-button", onClick: onDelete, tooltip: deleteToolTip, icon: _jsx(FaRegTrashAlt, {}), intent: "danger", disabled: !total || disableDelete })), onFilter && (_jsx(Toolbar.Item, { id: "filter-button", onClick: handleFilter, tooltip: filterToolTip, active: isFiltered, icon: _jsx(FaFilter, {}) })), mapToolbarButtons(leftButtons)] }), children] }), _jsx(Toolbar, { children: mapToolbarButtons(rightButtons) }), !hideCounter && (_jsx(CounterLabel, { value: formatCounterLabel(counter, total) })), onSettingClick && (_jsx(PreferencesButton, { tooltip: "Preferences", onClick: onSettingClick }))] }));
39
39
  }
40
40
  function mapToolbarButtons(buttons) {
41
41
  return buttons.map((props, index) => isCustomToolbarItem(props) ? (
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
3
3
  import { css } from '@emotion/react';
4
4
  import { Formik } from 'formik';
5
5
  import { xFindClosestIndex } from 'ml-spectra-processing';
6
- import { useEffect, useState } from 'react';
6
+ import { useState } from 'react';
7
7
  import * as Yup from 'yup';
8
8
  import { REFERENCES } from '../../../data/constants/References';
9
9
  import { useDispatch } from '../../context/DispatchContext';
@@ -13,7 +13,7 @@ import Message from '../../elements/Message';
13
13
  import Select from '../../elements/Select';
14
14
  import FormikInput from '../../elements/formik/FormikInput';
15
15
  import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
16
- import Events from '../../utility/Events';
16
+ import { useEvent } from '../../utility/Events';
17
17
  const labelStyle = {
18
18
  label: { flex: 4, fontWeight: '500' },
19
19
  wrapper: { flex: 8, display: 'flex', alignItems: 'center' },
@@ -87,16 +87,14 @@ function AlignSpectra({ onClose = () => null, nucleus }) {
87
87
  setError(message);
88
88
  }
89
89
  }
90
- useEffect(() => {
91
- function handler(event) {
92
- const [from, to] = event.range;
93
- setOptions((prevOptions) => ({ ...prevOptions, from, to }));
94
- }
95
- Events.on('brushEnd', handler);
96
- return () => {
97
- Events.off('brushEnd', handler);
98
- };
99
- }, []);
90
+ useEvent({
91
+ onBrushEnd: (options) => {
92
+ const { range: [from, to], shiftKey, } = options;
93
+ if (shiftKey) {
94
+ setOptions((prevOptions) => ({ ...prevOptions, from, to }));
95
+ }
96
+ },
97
+ });
100
98
  function optionChangeHandler(key) {
101
99
  const { delta: targetX = 0, ...otherOptions } = REFERENCES?.[nucleus]?.[key] || {};
102
100
  const value = {
@@ -9,7 +9,7 @@ import { useDispatch } from '../../context/DispatchContext';
9
9
  import { useLogger } from '../../context/LoggerContext';
10
10
  import { useToaster } from '../../context/ToasterContext';
11
11
  import Button from '../../elements/Button';
12
- import NextPrev from '../../elements/NextPrev';
12
+ import { NextPrev } from '../../elements/NextPrev';
13
13
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
14
14
  import { useMoleculeEditor } from '../../modal/MoleculeStructureEditorModal';
15
15
  import MoleculeHeader from '../MoleculesPanel/MoleculeHeader';
@@ -115,7 +115,7 @@ export default function PredictionPanel() {
115
115
  return (_jsx(NextPrev, { onChange: (slideIndex) => {
116
116
  setCurrentIndex(slideIndex);
117
117
  setMolfile(molecules[slideIndex].molfile);
118
- }, defaultIndex: currentIndex, style: {
118
+ }, index: currentIndex, style: {
119
119
  arrowContainer: {
120
120
  top: '40px',
121
121
  padding: '0 10px 0 55px',
@@ -28,6 +28,7 @@ const ignoreActions = new Set([
28
28
  'FLOAT_MOLECULE_OVER_SPECTRUM',
29
29
  'TOGGLE_SPECTRA_LEGEND',
30
30
  'TOGGLE_MOLECULE_ATOM_NUMBER',
31
+ 'SET_2D_LEVEL',
31
32
  ]);
32
33
  function checkActionType(type) {
33
34
  if (!ignoreActions?.has(type))
@@ -412,10 +412,8 @@ function innerSpectrumReducer(draft, action) {
412
412
  return ZonesActions.handleSetZoneAssignmentLabelCoordination(draft, action);
413
413
  case 'ORDER_MULTIPLE_SPECTRA_ANALYSIS':
414
414
  return SpectraAnalysisActions.handleOrderSpectra(draft, action);
415
- case 'RESURRECTING_SPECTRUM_FROM_RANGES':
416
- return DatabaseActions.handleResurrectSpectrumFromRanges(draft, action);
417
- case 'RESURRECTING_SPECTRUM_FROM_JCAMP':
418
- return DatabaseActions.handleResurrectSpectrumFromJcamp(draft, action);
415
+ case 'RESURRECTING_SPECTRUM':
416
+ return DatabaseActions.handleResurrectSpectrum(draft, action);
419
417
  case 'TOGGLE_SIMILARITY_TREE':
420
418
  return DatabaseActions.handleToggleSimilarityTree(draft);
421
419
  case 'SET_AUTOMATIC_ASSIGNMENTS':
@@ -1,19 +1,21 @@
1
1
  import { Draft } from 'immer';
2
2
  import { Spectrum1D } from 'nmr-load-save';
3
- import { NMRRange } from 'nmr-processing';
4
- import { ResurrectSpectrumInfo } from '../../../data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges';
3
+ import { DatabaseNMREntry } from 'nmr-processing';
5
4
  import { State } from '../Reducer';
6
5
  import { ActionType } from '../types/ActionType';
7
- type ResurrectSpectrumFromJcampAction = ActionType<'RESURRECTING_SPECTRUM_FROM_JCAMP', {
8
- ranges: NMRRange[];
6
+ interface BaseResurrectSpectrum {
7
+ databaseEntry: DatabaseNMREntry;
8
+ }
9
+ interface ResurrectSpectrumFromJCAMP extends BaseResurrectSpectrum {
10
+ source: 'jcamp';
9
11
  spectrum: Spectrum1D;
10
- }>;
11
- type ResurrectSpectrumFromRangesAction = ActionType<'RESURRECTING_SPECTRUM_FROM_RANGES', {
12
- ranges: NMRRange[];
13
- info: ResurrectSpectrumInfo;
14
- }>;
15
- export type DatabaseActions = ActionType<'TOGGLE_SIMILARITY_TREE'> | ResurrectSpectrumFromJcampAction | ResurrectSpectrumFromRangesAction;
16
- declare function handleResurrectSpectrumFromJcamp(draft: Draft<State>, action: ResurrectSpectrumFromJcampAction): void;
17
- declare function handleResurrectSpectrumFromRanges(draft: Draft<State>, action: ResurrectSpectrumFromRangesAction): void;
12
+ }
13
+ interface ResurrectSpectrumFromRangesOrSignals extends BaseResurrectSpectrum {
14
+ source: 'rangesOrSignals';
15
+ }
16
+ type ResurrectSpectrum = ResurrectSpectrumFromJCAMP | ResurrectSpectrumFromRangesOrSignals;
17
+ type ResurrectSpectrumAction = ActionType<'RESURRECTING_SPECTRUM', ResurrectSpectrum>;
18
+ export type DatabaseActions = ActionType<'TOGGLE_SIMILARITY_TREE'> | ResurrectSpectrumAction;
19
+ declare function handleResurrectSpectrum(draft: Draft<State>, action: ResurrectSpectrumAction): void;
18
20
  declare function handleToggleSimilarityTree(draft: Draft<State>): void;
19
- export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp, handleToggleSimilarityTree, };
21
+ export { handleResurrectSpectrum, handleToggleSimilarityTree };
@@ -1,43 +1,61 @@
1
- import { get1DColor, mapRanges } from '../../../data/data1d/Spectrum1D';
2
- import { generateSpectrumFromRanges, } from '../../../data/data1d/Spectrum1D/ranges/generateSpectrumFromRanges';
1
+ import { get1DColor, isSpectrum1D, mapRanges, } from '../../../data/data1d/Spectrum1D';
2
+ import { resurrectSpectrumFromRanges, resurrectSpectrumFromSignals, } from '../../../data/data1d/Spectrum1D/ranges/resurrectSpectrum';
3
3
  import { setZoom } from '../helper/Zoom1DManager';
4
4
  import zoomHistoryManager from '../helper/ZoomHistoryManager';
5
+ import { getSpectrum } from '../helper/getSpectrum';
5
6
  import { setDomain } from './DomainActions';
6
- function handleResurrectSpectrumFromJcamp(draft, action) {
7
- const { ranges } = action.payload;
8
- let { spectrum } = action.payload;
9
- spectrum = {
10
- ...spectrum,
11
- ranges: {
12
- ...spectrum.ranges,
13
- values: mapRanges(ranges, spectrum),
14
- },
15
- display: {
16
- ...spectrum.display,
17
- ...get1DColor(spectrum.display, { usedColors: draft.usedColors }),
18
- },
19
- };
20
- draft.data.push(spectrum);
21
- setDomain(draft, { isYDomainShared: false });
22
- //rescale the vertical zoom
23
- setZoom(draft, { scale: 0.8, spectrumID: spectrum.id });
24
- //keep the last horizontal zoom
25
- const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
26
- const zoomValue = zoomHistory.getLast();
27
- if (zoomValue) {
28
- draft.xDomain = zoomValue.xDomain;
29
- draft.yDomain = zoomValue.yDomain;
7
+ function handleResurrectSpectrum(draft, action) {
8
+ const { spectra: { activeTab: nucleus }, } = draft.view;
9
+ const { databaseEntry, source } = action.payload;
10
+ const { ranges, signals, solvent, names = [], id: spectrumID, } = databaseEntry;
11
+ let resurrectedSpectrum = null;
12
+ if (source === 'jcamp') {
13
+ const { spectrum } = action.payload;
14
+ resurrectedSpectrum = {
15
+ ...spectrum,
16
+ id: spectrumID,
17
+ ranges: {
18
+ ...spectrum.ranges,
19
+ values: mapRanges(ranges, spectrum),
20
+ },
21
+ display: {
22
+ ...spectrum.display,
23
+ ...get1DColor(spectrum.display, { usedColors: draft.usedColors }),
24
+ },
25
+ };
30
26
  }
31
- }
32
- function handleResurrectSpectrumFromRanges(draft, action) {
33
- const { ranges, info } = action.payload;
34
- const datum = generateSpectrumFromRanges(ranges, info, draft.usedColors);
35
- if (!datum)
27
+ if (source === 'rangesOrSignals') {
28
+ const activeSpectrum = getSpectrum(draft) || draft.data[0];
29
+ let options = {};
30
+ let info = { solvent, name: names[0], nucleus };
31
+ if (activeSpectrum && isSpectrum1D(activeSpectrum)) {
32
+ const { data: { x }, info: spectrumInfo, } = activeSpectrum;
33
+ options = { from: x[0], to: x.at(-1) };
34
+ info = { ...spectrumInfo, ...info };
35
+ }
36
+ if (signals) {
37
+ resurrectedSpectrum = resurrectSpectrumFromSignals(signals, {
38
+ spectrumID,
39
+ info,
40
+ usedColors: draft.usedColors,
41
+ ...options,
42
+ });
43
+ }
44
+ else if (ranges) {
45
+ resurrectedSpectrum = resurrectSpectrumFromRanges(ranges, {
46
+ spectrumID,
47
+ info,
48
+ usedColors: draft.usedColors,
49
+ ...options,
50
+ });
51
+ }
52
+ }
53
+ if (!resurrectedSpectrum)
36
54
  return;
37
- draft.data.push(datum);
55
+ draft.data.push(resurrectedSpectrum);
38
56
  setDomain(draft, { isYDomainShared: false });
39
57
  //rescale the vertical zoom
40
- setZoom(draft, { scale: 0.8, spectrumID: datum.id });
58
+ setZoom(draft, { scale: 0.8, spectrumID: resurrectedSpectrum.id });
41
59
  //keep the last horizontal zoom
42
60
  const zoomHistory = zoomHistoryManager(draft.zoom.history, draft.view.spectra.activeTab);
43
61
  const zoomValue = zoomHistory.getLast();
@@ -50,4 +68,4 @@ function handleToggleSimilarityTree(draft) {
50
68
  draft.view.spectra.showSimilarityTree =
51
69
  !draft.view.spectra.showSimilarityTree;
52
70
  }
53
- export { handleResurrectSpectrumFromRanges, handleResurrectSpectrumFromJcamp, handleToggleSimilarityTree, };
71
+ export { handleResurrectSpectrum, handleToggleSimilarityTree };
@@ -20,8 +20,8 @@ interface GetDomainOptions {
20
20
  domainSpectraScope?: 'visible' | 'all';
21
21
  }
22
22
  declare function getDomain(draft: Draft<State>, options?: GetDomainOptions): {
23
- xDomain: [number, number] | never[] | [undefined, undefined];
24
- yDomain: [number, number] | never[] | [undefined, undefined];
23
+ xDomain: never[] | [number, number] | [undefined, undefined];
24
+ yDomain: never[] | [number, number] | [undefined, undefined];
25
25
  yDomains: Record<string, number[]>;
26
26
  xDomains: Record<string, number[]>;
27
27
  };
@@ -1,7 +1,7 @@
1
1
  import { v4 } from '@lukeed/uuid';
2
2
  import { current } from 'immer';
3
3
  import { xFindClosestIndex } from 'ml-spectra-processing';
4
- import { Filters, FiltersManager, getBaselineZones, } from 'nmr-processing';
4
+ import { Filters, FiltersManager, getBaselineZonesByDietrich, } from 'nmr-processing';
5
5
  import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions';
6
6
  import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
7
7
  import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
@@ -21,7 +21,7 @@ import { getTwoDimensionPhaseCorrectionOptions } from '../helper/getTwoDimension
21
21
  import { setDomain, setMode } from './DomainActions';
22
22
  import { changeSpectrumVerticalAlignment } from './PreferencesActions';
23
23
  import { activateTool, resetSelectedTool } from './ToolsActions';
24
- const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, phaseCorrectionTwoDimensions, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, } = Filters;
24
+ const { fft, fftDimension1, fftDimension2, apodization, baselineCorrection, phaseCorrection, phaseCorrectionTwoDimensions, zeroFilling, shiftX, shift2DX, shift2DY, exclusionZones, signalProcessing, digitalFilter, digitalFilter2D, } = Filters;
25
25
  function getFilterUpdateDomainRules(filterName, defaultRule) {
26
26
  return (Filters[filterName]?.DOMAIN_UPDATE_RULES ||
27
27
  defaultRule || {
@@ -70,7 +70,7 @@ function rollbackSpectrumByFilter(draft, options) {
70
70
  //set active filter
71
71
  draft.toolOptions.data.activeFilterID =
72
72
  datum.filters?.[filterIndex]?.id || null;
73
- const filters = datum.filters.slice(0, filterIndex || 1);
73
+ const filters = datum.filters.slice(0, filterIndex);
74
74
  updateDomainOptions = getFilterDomain(datum, {
75
75
  startIndex: Math.min(activeFilterIndex, filterIndex),
76
76
  lastIndex: Math.max(activeFilterIndex, filterIndex),
@@ -131,6 +131,8 @@ function rollbackSpectrum(draft, options) {
131
131
  shift2DX.id,
132
132
  shift2DY.id,
133
133
  signalProcessing.id,
134
+ digitalFilter.id,
135
+ digitalFilter2D.id,
134
136
  ].includes(filterKey);
135
137
  beforeRollback(draft, filterKey);
136
138
  rollbackSpectrumByFilter(draft, {
@@ -233,7 +235,8 @@ function beforeRollback(draft, filterKey) {
233
235
  if (!baselineCorrectionFilter ||
234
236
  (baselineCorrectionFilter &&
235
237
  baselineCorrectionFilter.value.zones?.length === 0)) {
236
- draft.toolOptions.data.baselineCorrection.zones = getBaselineZones(datum.data);
238
+ draft.toolOptions.data.baselineCorrection.zones =
239
+ getBaselineZonesByDietrich(datum.data);
237
240
  }
238
241
  else {
239
242
  draft.toolOptions.data.baselineCorrection.zones =
@@ -773,6 +776,8 @@ function handleSetFilterSnapshotHandler(draft, action) {
773
776
  activateTool(draft, { toolId: filterKey, reset });
774
777
  }
775
778
  else {
779
+ draft.toolOptions.selectedOptionPanel = null;
780
+ draft.toolOptions.selectedTool = 'zoom';
776
781
  rollbackSpectrum(draft, { filterKey, reset });
777
782
  }
778
783
  }