nmrium 0.31.0 → 0.32.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 (80) hide show
  1. package/lib/component/1d/FooterBanner.js +17 -10
  2. package/lib/component/2d/Contours.js +1 -1
  3. package/lib/component/2d/Left1DChart.js +1 -1
  4. package/lib/component/2d/Top1DChart.js +1 -1
  5. package/lib/component/EventsTrackers/BrushTracker.js +30 -21
  6. package/lib/component/SplitPaneWrapper.js +1 -1
  7. package/lib/component/elements/EditableColumn.d.ts +3 -1
  8. package/lib/component/elements/EditableColumn.js +18 -3
  9. package/lib/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
  10. package/lib/component/loader/DropZone.js +9 -1
  11. package/lib/component/modal/setting/GeneralTabContent.js +1 -1
  12. package/lib/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  13. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  14. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +3 -26
  15. package/lib/component/reducer/Reducer.d.ts +2 -47
  16. package/lib/component/reducer/Reducer.js +2 -2
  17. package/lib/component/reducer/actions/DomainActions.js +3 -2
  18. package/lib/component/reducer/actions/FiltersActions.js +12 -3
  19. package/lib/component/reducer/actions/IntegralsActions.js +6 -5
  20. package/lib/component/reducer/actions/PeaksActions.js +7 -6
  21. package/lib/component/reducer/actions/PreferencesActions.js +2 -1
  22. package/lib/component/reducer/actions/RangesActions.d.ts +1 -1
  23. package/lib/component/reducer/actions/RangesActions.js +14 -12
  24. package/lib/component/reducer/actions/SpectrumsActions.js +3 -2
  25. package/lib/component/reducer/actions/ToolsActions.d.ts +1 -1
  26. package/lib/component/reducer/actions/ToolsActions.js +9 -7
  27. package/lib/component/reducer/actions/ZonesActions.js +9 -8
  28. package/lib/component/reducer/helper/getActiveSpectrum.d.ts +3 -0
  29. package/lib/component/reducer/helper/getActiveSpectrum.js +4 -0
  30. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  31. package/lib/component/toolbar/BasicToolBar.js +8 -7
  32. package/lib/component/utility/Export.js +7 -1
  33. package/lib/component/workspaces/Workspace.d.ts +1 -1
  34. package/lib/component/workspaces/exercise.js +4 -4
  35. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -1
  36. package/lib/data/Filters.d.ts +1 -2
  37. package/lib/data/Filters.js +1 -2
  38. package/lib/data/data1d/filter1d/phaseCorrection.js +11 -5
  39. package/lib/data/data2d/Processing2D.js +3 -2
  40. package/lib/data/utilities/calculateSanPlot.d.ts +8 -0
  41. package/lib/data/utilities/calculateSanPlot.js +31 -0
  42. package/lib/types/NMRiumGeneralPreferences.d.ts +2 -2
  43. package/lib/versionInfo.js +1 -1
  44. package/lib-cjs/component/1d/FooterBanner.js +16 -9
  45. package/lib-cjs/component/2d/Contours.js +1 -1
  46. package/lib-cjs/component/2d/Left1DChart.js +1 -1
  47. package/lib-cjs/component/2d/Top1DChart.js +1 -1
  48. package/lib-cjs/component/EventsTrackers/BrushTracker.js +30 -21
  49. package/lib-cjs/component/SplitPaneWrapper.js +1 -1
  50. package/lib-cjs/component/elements/EditableColumn.js +18 -3
  51. package/lib-cjs/component/hooks/useActiveSpectrumStyleOptions.js +1 -1
  52. package/lib-cjs/component/loader/DropZone.js +9 -1
  53. package/lib-cjs/component/modal/setting/GeneralTabContent.js +1 -1
  54. package/lib-cjs/component/panels/MoleculesPanel/MoleculeHeader.js +1 -1
  55. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  56. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -25
  57. package/lib-cjs/component/reducer/Reducer.js +2 -2
  58. package/lib-cjs/component/reducer/actions/DomainActions.js +3 -2
  59. package/lib-cjs/component/reducer/actions/FiltersActions.js +12 -3
  60. package/lib-cjs/component/reducer/actions/IntegralsActions.js +6 -5
  61. package/lib-cjs/component/reducer/actions/PeaksActions.js +7 -6
  62. package/lib-cjs/component/reducer/actions/PreferencesActions.js +2 -1
  63. package/lib-cjs/component/reducer/actions/RangesActions.js +14 -12
  64. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +3 -2
  65. package/lib-cjs/component/reducer/actions/ToolsActions.js +9 -7
  66. package/lib-cjs/component/reducer/actions/ZonesActions.js +9 -8
  67. package/lib-cjs/component/reducer/helper/getActiveSpectrum.js +8 -0
  68. package/lib-cjs/component/toolbar/BasicToolBar.js +7 -6
  69. package/lib-cjs/component/utility/Export.js +7 -1
  70. package/lib-cjs/component/workspaces/exercise.js +4 -4
  71. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -1
  72. package/lib-cjs/data/Filters.js +1 -3
  73. package/lib-cjs/data/data1d/filter1d/phaseCorrection.js +10 -4
  74. package/lib-cjs/data/data2d/Processing2D.js +3 -2
  75. package/lib-cjs/data/utilities/calculateSanPlot.js +35 -0
  76. package/lib-cjs/versionInfo.js +1 -1
  77. package/package.json +18 -17
  78. package/lib/data/data1d/filter1d/absolute.d.ts +0 -13
  79. package/lib/data/data1d/filter1d/absolute.js +0 -26
  80. package/lib-cjs/data/data1d/filter1d/absolute.js +0 -32
@@ -9,13 +9,14 @@ import { addRange, changeRangeSignal, detectRanges, updateRangesRelativeValues,
9
9
  import { setSumOptions } from '../../../data/data1d/Spectrum1D/SumManager';
10
10
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/RangeUtilities';
11
11
  import { rangeStateInit } from '../Reducer';
12
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
12
13
  import getRange from '../helper/getRange';
13
14
  import { handleUpdateCorrelations } from './CorrelationsActions';
14
15
  import { setDomain, setIntegralsYDomain } from './DomainActions';
15
16
  import { resetSelectedTool } from './ToolsActions';
16
17
  function handleAutoRangesDetection(draft, options) {
17
18
  const { data, xDomain, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
18
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
19
+ const activeSpectrum = getActiveSpectrum(draft);
19
20
  if (activeSpectrum?.id) {
20
21
  const { index, id } = activeSpectrum;
21
22
  const datum = data[index];
@@ -72,7 +73,7 @@ function getRangeIndex(draft, spectrumIndex, rangeID) {
72
73
  return draft.data[spectrumIndex].ranges.values.findIndex((range) => range.id === rangeID);
73
74
  }
74
75
  function handleDeleteRange(draft, action) {
75
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
76
+ const activeSpectrum = getActiveSpectrum(draft);
76
77
  if (activeSpectrum?.id) {
77
78
  const { index } = activeSpectrum;
78
79
  const { data, resetSelectTool = false } = action.payload;
@@ -96,7 +97,7 @@ function handleDeleteRange(draft, action) {
96
97
  }
97
98
  function handleChangeRangeSignalKind(draft, action) {
98
99
  const state = original(draft);
99
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
100
+ const activeSpectrum = getActiveSpectrum(state);
100
101
  if (activeSpectrum?.id) {
101
102
  const { index } = activeSpectrum;
102
103
  const { rowData, value } = action.payload.data;
@@ -114,7 +115,7 @@ function handleChangeRangeSignalKind(draft, action) {
114
115
  }
115
116
  function handleSaveEditedRange(draft, action) {
116
117
  const state = original(draft);
117
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
118
+ const activeSpectrum = getActiveSpectrum(state);
118
119
  if (activeSpectrum?.id) {
119
120
  const { index } = activeSpectrum;
120
121
  const { editedRowData, assignmentData } = action.payload;
@@ -157,7 +158,7 @@ function handleDeleteSignal(draft, action) {
157
158
  }
158
159
  }
159
160
  function handleUnlinkRange(draft, action) {
160
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
161
+ const activeSpectrum = getActiveSpectrum(draft);
161
162
  if (activeSpectrum?.id) {
162
163
  const { index } = activeSpectrum;
163
164
  const { assignmentData, rangeData = null, signalIndex = -1, } = action.payload;
@@ -192,7 +193,7 @@ function handleUnlinkRange(draft, action) {
192
193
  }
193
194
  }
194
195
  function handleSetDiaIDRange(draft, action) {
195
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
196
+ const activeSpectrum = getActiveSpectrum(draft);
196
197
  if (activeSpectrum?.id) {
197
198
  const { index } = activeSpectrum;
198
199
  const { rangeData, diaIDs, signalIndex, nbAtoms } = action.payload;
@@ -211,7 +212,7 @@ function handleSetDiaIDRange(draft, action) {
211
212
  }
212
213
  }
213
214
  function handleResizeRange(draft, action) {
214
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
215
+ const activeSpectrum = getActiveSpectrum(draft);
215
216
  if (activeSpectrum?.id) {
216
217
  const { index } = activeSpectrum;
217
218
  changeRange(draft.data[index], action.data);
@@ -219,7 +220,7 @@ function handleResizeRange(draft, action) {
219
220
  }
220
221
  function handleChangeRangeSum(draft, options) {
221
222
  const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
222
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
223
+ const activeSpectrum = getActiveSpectrum(draft);
223
224
  if (activeSpectrum?.id) {
224
225
  const { index } = activeSpectrum;
225
226
  const datum = data[index];
@@ -231,7 +232,7 @@ function addNewRange(draft, props) {
231
232
  const { startX, endX, id } = props;
232
233
  const range = getRange(draft, { startX, endX });
233
234
  const { view: { spectra: { activeTab: nucleus }, }, molecules, } = draft;
234
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
235
+ const activeSpectrum = getActiveSpectrum(draft);
235
236
  if (activeSpectrum?.id) {
236
237
  const { index } = activeSpectrum;
237
238
  const [from, to] = range;
@@ -295,14 +296,15 @@ function handleOnChangeRangesData(draft) {
295
296
  }
296
297
  function handleChangeRangesSumFlag(draft, action) {
297
298
  const flag = action.payload;
298
- if (draft.activeSpectrum?.id) {
299
- const { index } = draft.activeSpectrum;
299
+ const activeSpectrum = getActiveSpectrum(draft);
300
+ if (activeSpectrum?.id) {
301
+ const { index } = activeSpectrum;
300
302
  draft.data[index].ranges.options.isSumConstant = !flag;
301
303
  }
302
304
  }
303
305
  function handleUpdateRange(draft, action) {
304
306
  const { range, resetSelectTool = false } = action.payload;
305
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
307
+ const activeSpectrum = getActiveSpectrum(draft);
306
308
  if (activeSpectrum?.id && range.id) {
307
309
  const datum = draft.data[activeSpectrum?.index];
308
310
  const index = datum.ranges.values.findIndex((_range) => _range.id === range.id);
@@ -6,6 +6,7 @@ import { getMissingProjection } from '../../../data/data2d/Spectrum2D';
6
6
  import { options } from '../../toolbar/ToolTypes';
7
7
  import groupByInfoKey from '../../utility/GroupByInfoKey';
8
8
  import { setZoom } from '../helper/Zoom1DManager';
9
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
9
10
  import { setDomain, setMode } from './DomainActions';
10
11
  import { resetSpectrumByFilter } from './FiltersActions';
11
12
  import { setTab, setActiveTab } from './ToolsActions';
@@ -65,7 +66,7 @@ function handleChangePeaksMarkersVisibility(draft, data) {
65
66
  }
66
67
  function handleChangeActiveSpectrum(draft, activeSpectrum) {
67
68
  let refreshDomain = false;
68
- const currentActiveSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
69
+ const currentActiveSpectrum = getActiveSpectrum(draft);
69
70
  if (activeSpectrum) {
70
71
  const newIndex = draft.data.findIndex((d) => d.id === activeSpectrum.id);
71
72
  const oldIndex = draft.data.findIndex((d) => d.id === currentActiveSpectrum?.id);
@@ -144,7 +145,7 @@ function handleDeleteSpectra(draft, action) {
144
145
  function addMissingProjectionHandler(draft, action) {
145
146
  const state = original(draft);
146
147
  const { nucleus } = action;
147
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
148
+ const activeSpectrum = getActiveSpectrum(draft);
148
149
  if (activeSpectrum?.id) {
149
150
  const { index } = activeSpectrum;
150
151
  for (let n of nucleus) {
@@ -11,7 +11,7 @@ declare function handleAddBaseLineZone(draft: Draft<State>, { from, to }: {
11
11
  to: any;
12
12
  }): void;
13
13
  declare function handleDeleteBaseLineZone(draft: Draft<State>, id: any): void;
14
- declare function handleToggleRealImaginaryVisibility(draft: any): void;
14
+ declare function handleToggleRealImaginaryVisibility(draft: Draft<State>): void;
15
15
  declare function handleBrushEnd(draft: Draft<State>, action: any): void;
16
16
  declare function setVerticalIndicatorXPosition(draft: Draft<State>, position: any): void;
17
17
  declare function handleZoom(draft: Draft<State>, action: any): void;
@@ -10,6 +10,7 @@ import { rangeStateInit } from '../Reducer';
10
10
  import { DISPLAYER_MODE, MARGIN } from '../core/Constants';
11
11
  import { setZoom, wheelZoom, ZoomType } from '../helper/Zoom1DManager';
12
12
  import zoomHistoryManager from '../helper/ZoomHistoryManager';
13
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
13
14
  import { getActiveSpectrumOrFail } from '../helper/getActiveSpectrumOrFail';
14
15
  import { setDomain, setIntegralsYDomain, setMode, } from './DomainActions';
15
16
  import { calculateBaseLineCorrection, resetSpectrumByFilter, setFilterChanges, } from './FiltersActions';
@@ -112,10 +113,11 @@ function handleDeleteBaseLineZone(draft, id) {
112
113
  calculateBaseLineCorrection(draft);
113
114
  }
114
115
  function handleToggleRealImaginaryVisibility(draft) {
115
- if (draft.activeSpectrum != null) {
116
- const { index } = draft.activeSpectrum;
117
- draft.data[index].display.isRealSpectrumVisible =
118
- !draft.data[index].display.isRealSpectrumVisible;
116
+ const activeSpectrum = getActiveSpectrum(draft);
117
+ if (activeSpectrum != null) {
118
+ const { index } = activeSpectrum;
119
+ const datum = draft.data[index];
120
+ datum.display.isRealSpectrumVisible = !datum.display.isRealSpectrumVisible;
119
121
  setDomain(draft);
120
122
  }
121
123
  }
@@ -157,7 +159,7 @@ function handleBrushEnd(draft, action) {
157
159
  }
158
160
  }
159
161
  function setVerticalIndicatorXPosition(draft, position) {
160
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
162
+ const activeSpectrum = getActiveSpectrum(draft);
161
163
  if (activeSpectrum?.id) {
162
164
  const scaleX = getXScale(draft);
163
165
  const value = scaleX.invert(position);
@@ -173,7 +175,7 @@ function getSpectrumID(draft, index) {
173
175
  function handleZoom(draft, action) {
174
176
  const { event, trackID, selectedTool } = action;
175
177
  const { view: { ranges: rangeState }, displayerMode, } = draft;
176
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
178
+ const activeSpectrum = getActiveSpectrum(draft);
177
179
  const { showRangesIntegrals } = rangeState.find((r) => r.spectrumID === activeSpectrum?.id) ||
178
180
  rangeStateInit;
179
181
  if (displayerMode === DISPLAYER_MODE.DM_2D) {
@@ -369,7 +371,7 @@ function handelSetActiveTab(draft, tab) {
369
371
  }
370
372
  }
371
373
  function levelChangeHandler(draft, { deltaY, shiftKey }) {
372
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
374
+ const activeSpectrum = getActiveSpectrum(draft);
373
375
  try {
374
376
  if (activeSpectrum?.id) {
375
377
  const { index, id } = activeSpectrum;
@@ -8,13 +8,14 @@ import { changeZoneSignal, detectZones, detectZonesManual, updateShift, } from '
8
8
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/ZoneUtilities';
9
9
  import { zoneStateInit } from '../Reducer';
10
10
  import get2DRange from '../helper/get2DRange';
11
+ import { getActiveSpectrum } from '../helper/getActiveSpectrum';
11
12
  import { handleUpdateCorrelations } from './CorrelationsActions';
12
13
  import { setDomain } from './DomainActions';
13
14
  function changeZonesFactorHandler(draft, action) {
14
15
  draft.toolOptions.data.zonesNoiseFactor = action.payload;
15
16
  }
16
17
  function add2dZoneHandler(draft, action) {
17
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
18
+ const activeSpectrum = getActiveSpectrum(draft);
18
19
  if (activeSpectrum?.id) {
19
20
  const { index } = activeSpectrum;
20
21
  const drawnZone = get2DRange(draft, action);
@@ -29,7 +30,7 @@ function add2dZoneHandler(draft, action) {
29
30
  }
30
31
  }
31
32
  function handleAutoZonesDetection(draft, detectionOptions) {
32
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
33
+ const activeSpectrum = getActiveSpectrum(draft);
33
34
  if (activeSpectrum?.id) {
34
35
  const { index } = activeSpectrum;
35
36
  const [fromX, toX] = draft.xDomain;
@@ -57,7 +58,7 @@ function handleAutoSpectraZonesDetection(draft) {
57
58
  }
58
59
  function changeZoneSignalDelta(draft, action) {
59
60
  const { zoneID, signal } = action.payload;
60
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
61
+ const activeSpectrum = getActiveSpectrum(draft);
61
62
  if (activeSpectrum?.id) {
62
63
  const { index } = activeSpectrum;
63
64
  const { xShift, yShift } = changeZoneSignal(draft.data[index], zoneID, signal);
@@ -79,7 +80,7 @@ function getZoneIndex(state, spectrumIndex, zoneID) {
79
80
  }
80
81
  function handleChangeZoneSignalKind(draft, action) {
81
82
  const state = original(draft);
82
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
83
+ const activeSpectrum = getActiveSpectrum(state);
83
84
  if (activeSpectrum?.id) {
84
85
  const { index } = activeSpectrum;
85
86
  const { rowData, value } = action.payload;
@@ -94,7 +95,7 @@ function handleChangeZoneSignalKind(draft, action) {
94
95
  }
95
96
  function handleDeleteZone(draft, action) {
96
97
  const state = original(draft);
97
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
98
+ const activeSpectrum = getActiveSpectrum(state);
98
99
  if (activeSpectrum?.id) {
99
100
  const { index } = activeSpectrum;
100
101
  const { id, assignmentData } = action.payload;
@@ -149,7 +150,7 @@ function handleSetSignalPathLength(draft, action) {
149
150
  }
150
151
  function handleUnlinkZone(draft, action) {
151
152
  const state = original(draft);
152
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
153
+ const activeSpectrum = getActiveSpectrum(state);
153
154
  if (activeSpectrum?.id) {
154
155
  const { index } = activeSpectrum;
155
156
  const { zoneData = null, assignmentData, isOnZoneLevel = undefined, signalIndex = -1, axis = undefined, } = action.payload;
@@ -172,7 +173,7 @@ function handleUnlinkZone(draft, action) {
172
173
  }
173
174
  function handleSetDiaIDZone(draft, action) {
174
175
  const state = original(draft);
175
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
176
+ const activeSpectrum = getActiveSpectrum(state);
176
177
  if (activeSpectrum?.id) {
177
178
  const { index } = activeSpectrum;
178
179
  const { zoneData, diaIDs, axis, signalIndex, nbAtoms } = action.payload;
@@ -191,7 +192,7 @@ function handleSetDiaIDZone(draft, action) {
191
192
  }
192
193
  function handleSaveEditedZone(draft, action) {
193
194
  const state = original(draft);
194
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
195
+ const activeSpectrum = getActiveSpectrum(state);
195
196
  if (activeSpectrum?.id) {
196
197
  const { index } = activeSpectrum;
197
198
  const { editedRowData } = action.payload;
@@ -0,0 +1,3 @@
1
+ import { Draft } from 'immer';
2
+ import { State } from '../Reducer';
3
+ export declare function getActiveSpectrum(state: Draft<State> | State): import("../Reducer").ActiveSpectrum | null;
@@ -0,0 +1,4 @@
1
+ export function getActiveSpectrum(state) {
2
+ const { activeSpectra, activeTab } = state.view.spectra;
3
+ return activeSpectra[activeTab] || null;
4
+ }
@@ -48,7 +48,7 @@ declare const preferencesReducer: (base: {
48
48
  readonly open?: boolean | undefined;
49
49
  } | undefined;
50
50
  readonly hidePanelOnLoad?: boolean | undefined;
51
- readonly initialPanelWidth?: import("analysis-ui-components/lib-esm/components/SplitPane").InitialSeparation | undefined;
51
+ readonly initialPanelWidth?: import("analysis-ui-components").SplitPaneSize | undefined;
52
52
  } | undefined;
53
53
  readonly panels?: {
54
54
  readonly spectraPanel?: {
@@ -127,7 +127,7 @@ declare const preferencesReducer: (base: {
127
127
  } | undefined;
128
128
  };
129
129
  readonly general: {
130
- readonly dimmedSpectraTransparency: number;
130
+ readonly dimmedSpectraOpacity: number;
131
131
  };
132
132
  readonly formatting: {
133
133
  readonly nuclei: {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Toolbar } from 'analysis-ui-components';
3
3
  import { SvgNmrRealImag, SvgNmrOverlay3, SvgNmrOverlay3Aligned, SvgNmrAlignBottom, SvgNmrAlignCenter, } from 'cheminfo-font';
4
- import { Fragment, useCallback, memo, useMemo } from 'react';
4
+ import { Fragment, useCallback, memo } from 'react';
5
5
  import { FaDownload, FaFileDownload, FaFileImage, FaCopy, FaFileExport, FaFile, FaFileImport, } from 'react-icons/fa';
6
6
  import { useChartData } from '../context/ChartContext';
7
7
  import { useDispatch } from '../context/DispatchContext';
@@ -74,11 +74,12 @@ function BasicToolBarInner({ info, verticalAlign, ftCounter, fidCounter, activeS
74
74
  const openLoader = useLoader();
75
75
  const isExperimentalFeature = useCheckExperimentalFeature();
76
76
  const isButtonVisible = useCheckToolsVisibility();
77
- const importMenu = useMemo(() => {
78
- return isExperimentalFeature
79
- ? IMPORT_MENU
80
- : IMPORT_MENU.filter((item) => item.id !== 'importPublicationString');
81
- }, [isExperimentalFeature]);
77
+ const importMenu = isExperimentalFeature
78
+ ? IMPORT_MENU
79
+ : IMPORT_MENU.filter((item) => item.id !== 'importPublicationString');
80
+ const exportMenu = isExperimentalFeature
81
+ ? EXPORT_MENU
82
+ : EXPORT_MENU.filter((item) => item.id !== 'nmre');
82
83
  const { isRealSpectrumShown, changeSpectrumViewHandler, changeDisplayViewModeHandler, alignSpectrumsVerticallyHandler, } = useToolsFunctions();
83
84
  const { saveAsSVGHandler, saveAsPNGHandler, saveAsJSONHandler, saveToClipboardHandler, saveAsHandler, } = useExport();
84
85
  const LoadJacmpHandler = useCallback((file) => {
@@ -147,7 +148,7 @@ function BasicToolBarInner({ info, verticalAlign, ftCounter, fidCounter, activeS
147
148
  }, items: importMenu })), isButtonVisible('exportAs') && (_jsx(ToolbarMenu, { component: _jsx(FaFileExport, {}), toolTip: "Export As", onClick: (element) => {
148
149
  exportHandler(element);
149
150
  return null;
150
- }, items: EXPORT_MENU })), isButtonVisible('spectraStackAlignments') &&
151
+ }, items: exportMenu })), isButtonVisible('spectraStackAlignments') &&
151
152
  ftCounter > 1 &&
152
153
  (info?.isFt || !activeSpectrum) && (_jsx(Toolbar.Item, { id: "spectra-alignment", className: "cheminfo", title: "Spectra alignment ( Press s )", onClick: changeDisplayViewModeHandler, children: verticalAlign.align === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})) })), isButtonVisible('realImaginary') && info.isComplex && (_jsx(Toolbar.Item, { id: "display", title: isRealSpectrumShown ? 'Display Real ' : 'Display Imaginary', onClick: changeSpectrumViewHandler, className: "cheminfo", children: _jsx(SvgNmrRealImag, {}) })), isButtonVisible('spectraCenterAlignments') &&
153
154
  (ftCounter > 0 || fidCounter > 0) && (_jsx(Toolbar.Item, { id: "baseline-position", title: verticalAlign.align === 'bottom'
@@ -43,7 +43,13 @@ async function copyHTMLToClipboard(data) {
43
43
  }
44
44
  async function copyTextToClipboard(data) {
45
45
  try {
46
- await navigator.clipboard.writeText(data);
46
+ void navigator.clipboard.write([
47
+ new ClipboardItem({
48
+ 'text/plain': new Promise((resolve) => {
49
+ resolve(new Blob([data], { type: 'text/plain' }));
50
+ }),
51
+ }),
52
+ ]);
47
53
  return true;
48
54
  }
49
55
  catch (err) {
@@ -5,7 +5,7 @@ interface NucleusFormat {
5
5
  hz: string;
6
6
  }
7
7
  interface GeneralPreferences {
8
- dimmedSpectraTransparency: number;
8
+ dimmedSpectraOpacity: number;
9
9
  }
10
10
  interface ColumnPreferences {
11
11
  show: boolean;
@@ -1,5 +1,5 @@
1
1
  export const exercise = {
2
- version: 1,
2
+ version: 2,
3
3
  label: 'Exercise',
4
4
  display: {
5
5
  general: {
@@ -10,17 +10,17 @@ export const exercise = {
10
10
  integralsPanel: { display: true },
11
11
  },
12
12
  toolBarButtons: {
13
- peakPicking: true,
13
+ zoom: true,
14
+ zoomOut: true,
14
15
  apodization: true,
15
16
  zeroFilling: true,
16
17
  fastFourierTransform: true,
17
18
  phaseCorrection: true,
18
19
  baselineCorrection: true,
20
+ peakPicking: true,
19
21
  integral: true,
20
22
  spectraCenterAlignments: true,
21
23
  spectraStackAlignments: true,
22
- zoomOut: true,
23
- zoom: true,
24
24
  },
25
25
  },
26
26
  };
@@ -43,7 +43,7 @@ export const workspaceDefaultProperties = {
43
43
  },
44
44
  },
45
45
  general: {
46
- dimmedSpectraTransparency: 0.1,
46
+ dimmedSpectraOpacity: 0.1,
47
47
  },
48
48
  formatting: {
49
49
  nuclei: {
@@ -1,4 +1,3 @@
1
- import * as absolute from './data1d/filter1d/absolute';
2
1
  import * as apodization from './data1d/filter1d/apodization';
3
2
  import * as autoPhaseCorrection from './data1d/filter1d/autoPhaseCorrection';
4
3
  import * as baselineCorrection from './data1d/filter1d/baselineCorrection';
@@ -15,4 +14,4 @@ import * as standardDeviation from './data1d/filter1d/standardDeviation';
15
14
  import * as zeroFilling from './data1d/filter1d/zeroFilling';
16
15
  import * as shift2DX from './data2d/filter2d/shiftX';
17
16
  import * as shift2DY from './data2d/filter2d/shiftY';
18
- export { absolute, baselineCorrection, apodization, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, exclusionZones, shift2DX, shift2DY, };
17
+ export { baselineCorrection, apodization, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, exclusionZones, shift2DX, shift2DY, };
@@ -1,4 +1,3 @@
1
- import * as absolute from './data1d/filter1d/absolute';
2
1
  import * as apodization from './data1d/filter1d/apodization';
3
2
  import * as autoPhaseCorrection from './data1d/filter1d/autoPhaseCorrection';
4
3
  import * as baselineCorrection from './data1d/filter1d/baselineCorrection';
@@ -15,4 +14,4 @@ import * as standardDeviation from './data1d/filter1d/standardDeviation';
15
14
  import * as zeroFilling from './data1d/filter1d/zeroFilling';
16
15
  import * as shift2DX from './data2d/filter2d/shiftX';
17
16
  import * as shift2DY from './data2d/filter2d/shiftY';
18
- export { absolute, baselineCorrection, apodization, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, exclusionZones, shift2DX, shift2DY, };
17
+ export { baselineCorrection, apodization, fft, phaseCorrection, autoPhaseCorrection, shiftX, zeroFilling, digitalFilter, fromTo, equallySpaced, standardDeviation, centerMean, pareto, exclusionZones, shift2DX, shift2DY, };
@@ -1,4 +1,4 @@
1
- import { reimPhaseCorrection } from 'ml-spectra-processing';
1
+ import { reimAbsolute, reimPhaseCorrection } from 'ml-spectra-processing';
2
2
  export const id = 'phaseCorrection';
3
3
  export const name = 'Phase correction';
4
4
  /**
@@ -12,10 +12,16 @@ export function apply(datum1D, options = {}) {
12
12
  if (!isApplicable(datum1D)) {
13
13
  throw new Error('phaseCorrection not applicable on this data');
14
14
  }
15
- let { ph0, ph1 } = options;
16
- ph0 *= Math.PI / 180.0;
17
- ph1 *= Math.PI / 180.0;
18
- Object.assign(datum1D.data, reimPhaseCorrection(datum1D.data, ph0, ph1));
15
+ let { ph0, ph1, absolute } = options;
16
+ if (absolute) {
17
+ datum1D.data.re = reimAbsolute(datum1D.data);
18
+ datum1D.data.im = new Float64Array(0);
19
+ }
20
+ else {
21
+ ph0 *= Math.PI / 180.0;
22
+ ph1 *= Math.PI / 180.0;
23
+ Object.assign(datum1D.data, reimPhaseCorrection(datum1D.data, ph0, ph1));
24
+ }
19
25
  }
20
26
  export function isApplicable(datum1D) {
21
27
  if (datum1D.info.isComplex && !datum1D.info.isFid)
@@ -1,5 +1,5 @@
1
1
  import { Conrec } from 'ml-conrec';
2
- import { matrixAbsoluteMedian } from 'ml-spectra-processing';
2
+ import { calculateSanPlot } from '../utilities/calculateSanPlot';
3
3
  export const defaultContourOptions = {
4
4
  positive: {
5
5
  contourLevels: [0, 21],
@@ -22,7 +22,8 @@ export default class Processing2D {
22
22
  const xs = getRange(minMax.minX, minMax.maxX, minMax.z[0].length);
23
23
  const ys = getRange(minMax.minY, minMax.maxY, minMax.z.length);
24
24
  this.conrec = new Conrec(minMax.z, { xs, ys, swapAxes: false });
25
- this.median = matrixAbsoluteMedian(minMax.z);
25
+ const sanResult = calculateSanPlot('2D', minMax);
26
+ this.median = sanResult.positive;
26
27
  this.minMax = minMax;
27
28
  }
28
29
  getLevel() {
@@ -0,0 +1,8 @@
1
+ import { Data1D } from '../types/data1d';
2
+ import { Data2D } from '../types/data2d';
3
+ export declare function calculateSanPlot<T extends '1D' | '2D'>(dimension: T, data: T extends '1D' ? Data1D : Data2D): {
4
+ positive: number;
5
+ negative: number;
6
+ snr: number;
7
+ sanplot: Record<string, import("cheminfo-types").DataXY<import("cheminfo-types").DoubleArray>>;
8
+ };
@@ -0,0 +1,31 @@
1
+ import { xNoiseSanPlot } from 'ml-spectra-processing';
2
+ export function calculateSanPlot(dimension, data) {
3
+ const input = dimension === '1D'
4
+ ? prepare1DData(data)
5
+ : prepare2DData(data);
6
+ return xNoiseSanPlot(input);
7
+ }
8
+ function prepare1DData(data) {
9
+ const length = data.re.length;
10
+ const jump = Math.floor(length / 307200) || 1;
11
+ const array = new Float64Array((length / jump) >> 0);
12
+ let index = 0;
13
+ for (let i = 0; i < array.length; i += jump) {
14
+ array[index++] = data.re[i];
15
+ }
16
+ return array;
17
+ }
18
+ function prepare2DData(data) {
19
+ let cols = data.z[0].length;
20
+ let rows = data.z.length;
21
+ let jump = Math.floor((cols * rows) / 204800) || 1;
22
+ const array = new Float64Array(((cols * rows) / jump) >> 0);
23
+ let index = 0;
24
+ // console.log('jump', jump, cols * rows);
25
+ for (let r = 0; r < rows; r += 1) {
26
+ for (let c = 0; c < cols; c += jump) {
27
+ array[index++] = data.z[r][c];
28
+ }
29
+ }
30
+ return array;
31
+ }
@@ -1,8 +1,8 @@
1
- import { InitialSeparation } from 'analysis-ui-components/lib-esm/components/SplitPane';
1
+ import { SplitPaneSize } from 'analysis-ui-components';
2
2
  import { PanelPreferencesType } from './PanelPreferencesType';
3
3
  export interface NMRiumGeneralPreferences {
4
4
  hideGeneralSettings: boolean;
5
5
  experimentalFeatures: PanelPreferencesType;
6
6
  hidePanelOnLoad: boolean;
7
- initialPanelWidth?: InitialSeparation;
7
+ initialPanelWidth?: SplitPaneSize;
8
8
  }
@@ -1 +1 @@
1
- export default { version: 'v0.31.0' };
1
+ export default { version: 'v0.32.0' };
@@ -72,14 +72,6 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
72
72
  const { startX, endX, step } = (0, react_2.useContext)(BrushTracker_1.BrushContext);
73
73
  const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
74
74
  const format = (0, useFormatNumberByNucleus_1.useFormatNumberByNucleus)(activeTab);
75
- const getYValue = (0, react_2.useCallback)((xPosition) => {
76
- if (spectrum) {
77
- const data = (0, get1DDataXY_1.get1DDataXY)(spectrum);
78
- const xIndex = (0, ml_spectra_processing_1.xFindClosestIndex)(data.x, scaleX().invert(xPosition));
79
- return data.y[xIndex];
80
- }
81
- return 1;
82
- }, [spectrum, scaleX]);
83
75
  if (!position ||
84
76
  position.y < margin.top ||
85
77
  position.x < margin.left ||
@@ -87,7 +79,22 @@ function FooterBannerInner({ margin, width, height, activeSpectrum, spectrum, ac
87
79
  position.y > height - margin.bottom) {
88
80
  return (0, jsx_runtime_1.jsx)("div", { css: styles });
89
81
  }
90
- return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(bs_1.BsCursor, {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \uD835\uDEC5: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: format(scaleX().invert(position.x)) }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "Hz" }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ") " })] }))] }), step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394ppm: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394Hz: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
82
+ function getXIndex(xPosition) {
83
+ if (spectrum) {
84
+ const data = (0, get1DDataXY_1.get1DDataXY)(spectrum);
85
+ return (0, ml_spectra_processing_1.xFindClosestIndex)(data.x, scaleX().invert(xPosition));
86
+ }
87
+ return 0;
88
+ }
89
+ function getYValue(xPosition) {
90
+ if (spectrum) {
91
+ const data = (0, get1DDataXY_1.get1DDataXY)(spectrum);
92
+ const xIndex = getXIndex(xPosition);
93
+ return data.y[xIndex];
94
+ }
95
+ return 1;
96
+ }
97
+ return ((0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(bs_1.BsCursor, {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \uD835\uDEC5: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: format(scaleX().invert(position.x)) }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "ppm" }), activeSpectrum && spectrum?.info?.originFrequency && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("span", { className: "value", children: ["\u00A0(", format(scaleX().invert(position.x) * spectrum?.info?.originFrequency, 'hz')] }), (0, jsx_runtime_1.jsx)("span", { className: "unit", children: "Hz" }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ") " }), (0, jsx_runtime_1.jsx)("span", { children: "," }), (0, jsx_runtime_1.jsx)("span", { className: "label", children: " Index: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: getXIndex(position.x) })] }))] }), step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394ppm: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: (scaleX().invert(startX) - scaleX().invert(endX)).toPrecision(6) })] })), activeSpectrum && ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [spectrum?.info?.originFrequency && step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " \u0394Hz: " }), (0, jsx_runtime_1.jsx)("span", { className: "value", children: ((scaleX().invert(startX) - scaleX().invert(endX)) *
91
98
  spectrum?.info?.originFrequency).toPrecision(5) })] })), step === 'brushing' && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: " ratio :" }), (0, jsx_runtime_1.jsxs)("span", { className: "value", children: [((getYValue(startX) / (getYValue(endX) || Number.MIN_VALUE)) *
92
99
  100).toFixed(2), "%"] })] }))] })), activeSpectrum && ((0, jsx_runtime_1.jsxs)(react_2.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "separator" }), (0, jsx_runtime_1.jsx)(io5_1.IoPulseSharp, {}), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("span", { className: "label", children: "Intensity: " }), (0, jsx_runtime_1.jsx)("span", { className: "value yvalue", children: format(getYValue(position.x)) })] })] }))] }));
93
100
  }
@@ -53,7 +53,7 @@ function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
53
53
  return ((0, jsx_runtime_1.jsx)("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", style: {
54
54
  opacity: isActive
55
55
  ? 1
56
- : (0, get_1.default)(preferences.current, 'general.dimmedSpectraTransparency', 0.1),
56
+ : (0, get_1.default)(preferences.current, 'general.dimmedSpectraOpacity', 0.1),
57
57
  }, d: path }));
58
58
  }
59
59
  function ContoursInner({ data, displayerKey }) {
@@ -66,6 +66,6 @@ function Left1DChart({ margin: marignValue = 10, data: spectrum, }) {
66
66
  const mainHeight = originHeight - margin.bottom - margin.top;
67
67
  if (!mainHeight || !height)
68
68
  return null;
69
- return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: "black", fill: "none", d: paths }) })] }));
69
+ return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${height} ${mainHeight + margin.top}`, width: height, height: mainHeight + margin.top, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-left`, children: (0, jsx_runtime_1.jsx)("rect", { width: height, height: mainHeight, x: "0", y: margin.top }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-left)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: spectrum.display.color, fill: "none", d: paths }) })] }));
70
70
  }
71
71
  exports.default = (0, react_1.memo)(Left1DChart);
@@ -62,6 +62,6 @@ function Top1DChart({ margin: marginProps = 10, data: spectrum, }) {
62
62
  if (!width || !height) {
63
63
  return null;
64
64
  }
65
- return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-top`, children: (0, jsx_runtime_1.jsx)("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-top)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: "red", fill: "none", strokeWidth: "1px", d: paths }) })] }));
65
+ return ((0, jsx_runtime_1.jsxs)("svg", { viewBox: `0 0 ${width} ${height}`, width: width, height: height, children: [(0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsx)("clipPath", { id: `${displayerKey}clip-top`, children: (0, jsx_runtime_1.jsx)("rect", { width: width - originMargin.left - originMargin.right, height: height, x: originMargin.left, y: `${0}` }) }) }), (0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-top)`, children: (0, jsx_runtime_1.jsx)("path", { className: "line", stroke: spectrum.display.color, fill: "none", strokeWidth: "1px", d: paths }) })] }));
66
66
  }
67
67
  exports.default = (0, react_1.memo)(Top1DChart);