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
@@ -19,6 +19,9 @@ const initialState = {
19
19
  startY: 0,
20
20
  endY: 0,
21
21
  };
22
+ function stopPageScrolling(event) {
23
+ event.preventDefault();
24
+ }
22
25
  exports.BrushContext = (0, react_1.createContext)(initialState);
23
26
  function BrushTracker({ children, className, style, onBrush = () => null, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
24
27
  const [state, dispatch] = (0, react_1.useReducer)(reducer, initialState);
@@ -41,6 +44,24 @@ function BrushTracker({ children, className, style, onBrush = () => null, onZoom
41
44
  });
42
45
  setMouseDownTime(event.timeStamp);
43
46
  }
47
+ function moveCallback(event) {
48
+ dispatch({
49
+ type: 'MOVE',
50
+ screenX: event.screenX,
51
+ screenY: event.screenY,
52
+ clientX: event.clientX,
53
+ clientY: event.clientY,
54
+ });
55
+ }
56
+ function mouseUpCallback() {
57
+ dispatch({
58
+ type: 'UP',
59
+ });
60
+ window.removeEventListener('mousemove', moveCallback);
61
+ window.removeEventListener('mouseup', mouseUpCallback);
62
+ }
63
+ window.addEventListener('mousemove', moveCallback);
64
+ window.addEventListener('mouseup', mouseUpCallback);
44
65
  return false;
45
66
  }, [noPropagation]);
46
67
  const clickHandler = (0, react_1.useCallback)((e) => {
@@ -80,35 +101,23 @@ function BrushTracker({ children, className, style, onBrush = () => null, onZoom
80
101
  });
81
102
  }
82
103
  }, [onBrush, state]);
83
- const moveCallback = (0, react_1.useCallback)((event) => {
84
- dispatch({
85
- type: 'MOVE',
86
- screenX: event.screenX,
87
- screenY: event.screenY,
88
- clientX: event.clientX,
89
- clientY: event.clientY,
90
- });
91
- }, []);
92
- const upCallback = (0, react_1.useCallback)((event) => {
93
- dispatch({
94
- type: 'UP',
95
- clientX: event.clientX,
96
- clientY: event.clientY,
97
- });
98
- return false;
99
- }, []);
100
- return ((0, jsx_runtime_1.jsx)(exports.BrushContext.Provider, { value: state, children: (0, jsx_runtime_1.jsx)("div", { className: className, style: style, onMouseDown: mouseDownHandler, onMouseUp: upCallback, onMouseMove: moveCallback, onClick: clickHandler, onWheel: handleMouseWheel, children: children }) }));
104
+ return ((0, jsx_runtime_1.jsx)(exports.BrushContext.Provider, { value: state, children: (0, jsx_runtime_1.jsx)("div", { className: className, style: style, onMouseDown: mouseDownHandler, onClick: clickHandler, onWheel: handleMouseWheel, onMouseEnter: () => {
105
+ // disable page scrolling once the mouse over the Displayer
106
+ window.addEventListener('wheel', stopPageScrolling, {
107
+ passive: false,
108
+ });
109
+ }, onMouseLeave: () => {
110
+ // disable page scrolling once the mouse over the Displayer
111
+ window.removeEventListener('wheel', stopPageScrolling);
112
+ }, children: children }) }));
101
113
  }
102
114
  exports.BrushTracker = BrushTracker;
103
115
  function reducer(state, action) {
104
116
  switch (action.type) {
105
117
  case 'UP':
106
118
  if (state.step === 'brushing' || state.step === 'start') {
107
- const { clientX, clientY } = action;
108
119
  return {
109
120
  ...state,
110
- endX: clientX - state.boundingRect.x,
111
- endY: clientY - state.boundingRect.y,
112
121
  step: state.step === 'start' ? 'initial' : 'end',
113
122
  };
114
123
  }
@@ -7,6 +7,6 @@ const PreferencesContext_1 = require("./context/PreferencesContext");
7
7
  function SplitPaneWrapper({ children }) {
8
8
  const { current } = (0, PreferencesContext_1.usePreferences)();
9
9
  const { hidePanelOnLoad = false, initialPanelWidth = '560px' } = current?.display?.general || {};
10
- return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.SplitPane, { initialSeparation: initialPanelWidth, orientation: "horizontal", sideSeparation: "end", ...(hidePanelOnLoad ? { initialClosed: true } : { minimumSize: 600 }), children: children }, hidePanelOnLoad ? 'true' : 'false'));
10
+ return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.SplitPane, { initialSize: initialPanelWidth, direction: "horizontal", controlledSide: "end", initialClosed: hidePanelOnLoad ? true : 600, children: children }, hidePanelOnLoad ? 'true' : 'false'));
11
11
  }
12
12
  exports.SplitPaneWrapper = SplitPaneWrapper;
@@ -7,7 +7,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
8
  const Input_1 = __importDefault(require("./Input"));
9
9
  const EditableColumn = (0, react_1.forwardRef)(function EditableColumn(props, ref) {
10
- const { onSave = () => null, value, type = 'text', style, onEditStart = () => null, editStatus = false, validate = () => true, } = props;
10
+ const { onSave = () => null, value, type = 'text', style, onEditStart = () => null, editStatus = false, validate = () => true, textOverFlowEllipses = false, ...InputProps } = props;
11
11
  const [enabled, enableEdit] = (0, react_1.useState)();
12
12
  const [isValid, setValid] = (0, react_1.useState)(true);
13
13
  (0, react_1.useEffect)(() => {
@@ -48,11 +48,26 @@ const EditableColumn = (0, react_1.forwardRef)(function EditableColumn(props, re
48
48
  window.removeEventListener('mousedown', mouseClickCallback);
49
49
  }
50
50
  }, [mouseClickCallback, onSave, validate]);
51
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'table', width: '100%', height: '100%', ...style }, onDoubleClick: startEditHandler, children: [!enabled && ((0, jsx_runtime_1.jsx)("span", { style: { display: 'table-cell', verticalAlign: 'middle' }, children: value })), enabled && ((0, jsx_runtime_1.jsx)("div", { style: { display: 'table-cell', verticalAlign: 'middle' }, children: (0, jsx_runtime_1.jsx)(Input_1.default, { style: {
51
+ return ((0, jsx_runtime_1.jsxs)("div", { style: {
52
+ display: 'table',
53
+ width: '100%',
54
+ height: '100%',
55
+ ...(textOverFlowEllipses
56
+ ? { whiteSpace: 'nowrap', overflow: 'hidden', display: 'inline-flex' }
57
+ : {}),
58
+ ...style,
59
+ }, className: "editable-column-input", onDoubleClick: startEditHandler, children: [!enabled && ((0, jsx_runtime_1.jsx)("span", { style: {
60
+ display: 'table-cell',
61
+ verticalAlign: 'middle',
62
+ width: 'inherit',
63
+ ...(textOverFlowEllipses
64
+ ? { textOverflow: 'ellipsis', overflow: 'hidden' }
65
+ : {}),
66
+ }, children: value })), enabled && ((0, jsx_runtime_1.jsx)("div", { style: { display: 'table-cell', verticalAlign: 'middle' }, children: (0, jsx_runtime_1.jsx)(Input_1.default, { style: {
52
67
  inputWrapper: {
53
68
  width: '100%',
54
69
  ...(!isValid && { borderColor: 'red' }),
55
70
  },
56
- }, enableAutoSelect: true, className: "editable-column", value: value, type: type, onKeyUp: editHandler }) }))] }));
71
+ }, enableAutoSelect: true, className: "editable-column", value: value, type: type, onKeyUp: editHandler, ...InputProps }) }))] }));
57
72
  });
58
73
  exports.default = EditableColumn;
@@ -14,7 +14,7 @@ function useActiveSpectrumStyleOptions(id) {
14
14
  const isActive = activeSpectrum === null ? true : id === activeSpectrum.id;
15
15
  const opacity = isActive
16
16
  ? 1
17
- : (0, get_1.default)(preferences.current, 'general.dimmedSpectraTransparency', 0.1);
17
+ : (0, get_1.default)(preferences.current, 'general.dimmedSpectraOpacity', 0.1);
18
18
  return { isActive, opacity };
19
19
  }, [activeSpectrum, id, preferences]);
20
20
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
4
4
  /** @jsxImportSource @emotion/react */
5
5
  const react_1 = require("@emotion/react");
6
+ const filelist_utils_1 = require("filelist-utils");
6
7
  const react_2 = require("react");
7
8
  const react_dropzone_1 = require("react-dropzone");
8
9
  const fa_1 = require("react-icons/fa");
@@ -50,7 +51,14 @@ function DropZone(props) {
50
51
  files.forEach((file) => {
51
52
  Object.defineProperty(file, 'webkitRelativePath', { value: file.path });
52
53
  });
53
- dispatch({ type: Types_1.LOAD_DROP_FILES, files });
54
+ (0, filelist_utils_1.fileCollectionFromFileList)(files)
55
+ .then((fileCollection) => {
56
+ dispatch({ type: Types_1.LOAD_DROP_FILES, fileCollection });
57
+ })
58
+ .catch((e) => {
59
+ dispatch({ type: Types_1.SET_LOADING_FLAG, isLoading: false });
60
+ reportError(e);
61
+ });
54
62
  }, [dispatch]);
55
63
  const onDrop = (0, react_2.useCallback)((droppedFiles) => {
56
64
  dispatch({ type: Types_1.SET_LOADING_FLAG, isLoading: true });
@@ -7,6 +7,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const Label_1 = __importDefault(require("../../elements/Label"));
8
8
  const FormikInput_1 = __importDefault(require("../../elements/formik/FormikInput"));
9
9
  function GeneralTabContent() {
10
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { className: "section-header", children: "Spectra" }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Transparency of Dimmed Spectra [ 0 - 1 ]", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "general.dimmedSpectraTransparency", checkValue: (value) => value >= 0 && value <= 1, type: "number" }) })] }));
10
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("p", { className: "section-header", children: "Spectra" }), (0, jsx_runtime_1.jsx)(Label_1.default, { title: "Opacity of dimmed spectra [ 0 - 1 ]", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "general.dimmedSpectraOpacity", checkValue: (value) => value >= 0 && value <= 1, type: "number" }) })] }));
11
11
  }
12
12
  exports.default = GeneralTabContent;
@@ -39,6 +39,6 @@ function MoleculeHeader(props) {
39
39
  const label = event.target.value;
40
40
  dispatch({ type: Types_1.CHANGE_MOLECULE_LABEL, payload: { label, id } });
41
41
  }, [dispatch]);
42
- return ((0, jsx_runtime_1.jsxs)("div", { style: styles.toolbar, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)("span", { children: "Label" }), (0, jsx_runtime_1.jsx)(EditableColumn_1.default, { value: currentMolecule.label, style: styles.labelInput, validate: validateLabel, onSave: (event) => saveLabelHandler(currentMolecule.id, event) })] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)(react_mf_1.MF, { mf: currentMolecule.mf }), " - ", currentMolecule.mw?.toFixed(2)] })] }));
42
+ return ((0, jsx_runtime_1.jsxs)("div", { style: styles.toolbar, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)("span", { children: "Label" }), (0, jsx_runtime_1.jsx)(EditableColumn_1.default, { value: currentMolecule.label, style: styles.labelInput, validate: validateLabel, onSave: (event) => saveLabelHandler(currentMolecule.id, event), textOverFlowEllipses: true })] }), (0, jsx_runtime_1.jsxs)("span", { children: [(0, jsx_runtime_1.jsx)(react_mf_1.MF, { mf: currentMolecule.mf }), " - ", currentMolecule.mw?.toFixed(2)] })] }));
43
43
  }
44
44
  exports.default = MoleculeHeader;
@@ -41,7 +41,7 @@ function PeaksTable({ activeTab, data }) {
41
41
  });
42
42
  }, [modal, peaksPreferences]);
43
43
  const saveDeltaPPMRefsHandler = (0, react_1.useCallback)((event, row) => {
44
- const shiftValue = parseFloat(event.target.value) - parseFloat(row.value);
44
+ const shiftValue = parseFloat(event.target.value) - parseFloat(row.x);
45
45
  dispatch({ type: Types_1.SHIFT_SPECTRUM, shiftValue });
46
46
  }, [dispatch]);
47
47
  const COLUMNS = (0, react_1.useMemo)(() => [
@@ -2,11 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processSnapPlot = void 0;
4
4
  const ml_spectra_processing_1 = require("ml-spectra-processing");
5
+ const calculateSanPlot_1 = require("../../../../../data/utilities/calculateSanPlot");
5
6
  function processSnapPlot(dimension, data, yLogBase) {
6
- const input = dimension === '1D'
7
- ? prepare1DData(data)
8
- : prepare2DData(data);
9
- const sanResult = (0, ml_spectra_processing_1.xNoiseSanPlot)(input);
7
+ const sanResult = (0, calculateSanPlot_1.calculateSanPlot)(dimension, data);
10
8
  const sanPlot = {};
11
9
  const lines = {};
12
10
  for (let plotKey in sanResult.sanplot) {
@@ -21,27 +19,6 @@ function processSnapPlot(dimension, data, yLogBase) {
21
19
  return { sanPlot, lines };
22
20
  }
23
21
  exports.processSnapPlot = processSnapPlot;
24
- function prepare1DData(data) {
25
- const length = data.re.length;
26
- const jump = Math.floor(length / 307200) || 1;
27
- const array = new Float64Array((length / jump) >> 0);
28
- let index = 0;
29
- for (let i = 0; i < array.length; i += jump) {
30
- array[index++] = data.re[i];
31
- }
32
- return array;
33
- }
34
- function prepare2DData(data) {
35
- let cols = data.z[0].length;
36
- let rows = data.z.length;
37
- let jump = Math.floor((cols * rows) / 204800) || 1;
38
- const array = new Float64Array(((cols * rows) / jump) >> 0);
39
- let index = 0;
40
- for (let i = 0; i < array.length; i += jump) {
41
- array[index++] = data.z[(i / rows) >> 0][i % rows];
42
- }
43
- return array;
44
- }
45
22
  function getLine(value, data, options) {
46
23
  const { log10, abs } = Math;
47
24
  const { yLogBase } = options;
@@ -174,9 +174,9 @@ function dispatchMiddleware(dispatch) {
174
174
  break;
175
175
  }
176
176
  case types.LOAD_DROP_FILES: {
177
- const { files } = action;
177
+ const { fileCollection } = action;
178
178
  action.usedColors = usedColors;
179
- (0, nmr_load_save_1.read)(files, usedColors)
179
+ (0, nmr_load_save_1.read)(fileCollection, usedColors)
180
180
  .then((data) => {
181
181
  action.data = data;
182
182
  dispatch(action);
@@ -9,12 +9,13 @@ const get1DDataXY_1 = require("../../../data/data1d/Spectrum1D/get1DDataXY");
9
9
  const Spectrum2D_1 = require("../../../data/data2d/Spectrum2D");
10
10
  const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
11
11
  const Constants_1 = require("../core/Constants");
12
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
12
13
  function getActiveData(draft) {
13
14
  let data = draft.data.filter((datum) => (0, nucleusToString_1.default)(datum.info.nucleus) === draft.view.spectra.activeTab &&
14
15
  datum.info.dimension === 1);
15
16
  // todo: refactor this
16
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
17
- if (activeSpectrum) {
17
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
18
+ if (activeSpectrum?.id) {
18
19
  const activeSpectrumIndex = data.findIndex((datum) => datum.id === activeSpectrum?.id);
19
20
  if (activeSpectrumIndex !== -1) {
20
21
  const isFid = data[activeSpectrumIndex].info.isFid || false;
@@ -137,7 +137,10 @@ function applyManualPhaseCorrectionFilter(draft, filterOptions) {
137
137
  const { index } = activeSpectrum;
138
138
  const { ph0, ph1 } = filterOptions;
139
139
  FiltersManager.applyFilter(draft.data[index], [
140
- { name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
140
+ {
141
+ name: Filters.phaseCorrection.id,
142
+ options: { ph0, ph1, absolute: false },
143
+ },
141
144
  ]);
142
145
  (0, ToolsActions_1.resetSelectedTool)(draft);
143
146
  draft.tempData = null;
@@ -148,7 +151,10 @@ function applyAbsoluteFilter(draft) {
148
151
  const activeSpectrum = (0, getActiveSpectrumOrFail_1.getActiveSpectrumOrFail)(draft);
149
152
  const { index } = activeSpectrum;
150
153
  FiltersManager.applyFilter(draft.data[index], [
151
- { name: Filters.absolute.id, options: {} },
154
+ {
155
+ name: Filters.phaseCorrection.id,
156
+ options: { absolute: true, ph0: 0, ph1: 0 },
157
+ },
152
158
  ]);
153
159
  (0, ToolsActions_1.resetSelectedTool)(draft);
154
160
  draft.tempData = null;
@@ -160,7 +166,10 @@ function applyAutoPhaseCorrectionFilter(draft) {
160
166
  const { index } = activeSpectrum;
161
167
  const { ph0, ph1 } = (0, autoPhaseCorrection_1.apply)(draft.data[index]);
162
168
  FiltersManager.applyFilter(draft.data[index], [
163
- { name: Filters.phaseCorrection.id, options: { ph0, ph1 } },
169
+ {
170
+ name: Filters.phaseCorrection.id,
171
+ options: { ph0, ph1, absolute: false },
172
+ },
164
173
  ]);
165
174
  (0, ToolsActions_1.resetSelectedTool)(draft);
166
175
  draft.tempData = null;
@@ -9,11 +9,12 @@ const immer_1 = require("immer");
9
9
  const ml_spectra_processing_1 = require("ml-spectra-processing");
10
10
  const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
11
11
  const SumManager_1 = require("../../../data/data1d/Spectrum1D/SumManager");
12
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
12
13
  const getRange_1 = __importDefault(require("../helper/getRange"));
13
14
  const DomainActions_1 = require("./DomainActions");
14
15
  function handleChangeIntegralSum(draft, options) {
15
16
  const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
16
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
17
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
17
18
  if (activeSpectrum?.id) {
18
19
  const { index } = activeSpectrum;
19
20
  const datum = data[index];
@@ -25,7 +26,7 @@ exports.handleChangeIntegralSum = handleChangeIntegralSum;
25
26
  function addIntegral(draft, action) {
26
27
  const { startX, endX } = action;
27
28
  const { data, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
28
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
29
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
29
30
  const [from, to] = (0, getRange_1.default)(draft, { startX, endX });
30
31
  if (activeSpectrum?.id) {
31
32
  const datum = data[activeSpectrum.index];
@@ -51,7 +52,7 @@ function addIntegral(draft, action) {
51
52
  }
52
53
  exports.addIntegral = addIntegral;
53
54
  function deleteIntegral(draft, action) {
54
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
55
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
55
56
  if (activeSpectrum) {
56
57
  const state = (0, immer_1.original)(draft);
57
58
  const { index } = activeSpectrum;
@@ -69,7 +70,7 @@ function deleteIntegral(draft, action) {
69
70
  }
70
71
  exports.deleteIntegral = deleteIntegral;
71
72
  function changeIntegral(draft, action) {
72
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
73
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
73
74
  const state = (0, immer_1.original)(draft);
74
75
  const integral = action.payload.data;
75
76
  if (activeSpectrum?.id) {
@@ -91,7 +92,7 @@ function changeIntegral(draft, action) {
91
92
  }
92
93
  exports.changeIntegral = changeIntegral;
93
94
  function handleChangeIntegralsRelativeValue(draft, action) {
94
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
95
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
95
96
  const data = action.payload.data;
96
97
  if (activeSpectrum?.id) {
97
98
  const { index } = activeSpectrum;
@@ -9,9 +9,10 @@ const immer_1 = require("immer");
9
9
  const ml_spectra_processing_1 = require("ml-spectra-processing");
10
10
  const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
11
11
  const ToolTypes_1 = require("../../toolbar/ToolTypes");
12
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
12
13
  const getRange_1 = __importDefault(require("../helper/getRange"));
13
14
  function addPeak(draft, mouseCoordinates) {
14
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
15
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
15
16
  const state = (0, immer_1.original)(draft);
16
17
  if (activeSpectrum?.id && state) {
17
18
  const { index } = activeSpectrum;
@@ -39,7 +40,7 @@ function addPeak(draft, mouseCoordinates) {
39
40
  exports.addPeak = addPeak;
40
41
  function addPeaks(draft, action) {
41
42
  const state = (0, immer_1.original)(draft);
42
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
43
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
43
44
  if (activeSpectrum) {
44
45
  const { index } = activeSpectrum;
45
46
  const datumOriginal = state.data[index];
@@ -63,7 +64,7 @@ function addPeaks(draft, action) {
63
64
  }
64
65
  exports.addPeaks = addPeaks;
65
66
  function deletePeak(draft, peakData) {
66
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
67
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
67
68
  if (activeSpectrum) {
68
69
  const { index } = activeSpectrum;
69
70
  const state = (0, immer_1.original)(draft);
@@ -79,7 +80,7 @@ function deletePeak(draft, peakData) {
79
80
  exports.deletePeak = deletePeak;
80
81
  function handleOptimizePeaks(draft, action) {
81
82
  const { peaks } = action.payload;
82
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
83
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
83
84
  if (activeSpectrum?.id) {
84
85
  const { index } = activeSpectrum;
85
86
  const datum = draft.data[index];
@@ -94,7 +95,7 @@ function handleOptimizePeaks(draft, action) {
94
95
  }
95
96
  exports.handleOptimizePeaks = handleOptimizePeaks;
96
97
  function handleAutoPeakPicking(draft, autOptions) {
97
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
98
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
98
99
  if (activeSpectrum?.id) {
99
100
  draft.toolOptions.selectedTool = ToolTypes_1.options.zoom.id;
100
101
  draft.toolOptions.selectedOptionPanel = null;
@@ -114,7 +115,7 @@ function handleAutoPeakPicking(draft, autOptions) {
114
115
  exports.handleAutoPeakPicking = handleAutoPeakPicking;
115
116
  function changePeakShapeHandler(draft, action) {
116
117
  const { shape, id } = action.payload;
117
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
118
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
118
119
  if (activeSpectrum?.id) {
119
120
  const { index } = activeSpectrum;
120
121
  const datum = draft.data[index];
@@ -8,6 +8,7 @@ const cloneDeep_1 = __importDefault(require("lodash/cloneDeep"));
8
8
  const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
9
9
  const nucleusToString_1 = __importDefault(require("../../utility/nucleusToString"));
10
10
  const Constants_1 = require("../core/Constants");
11
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
11
12
  const DomainActions_1 = require("./DomainActions");
12
13
  function changeSpectrumVerticalAlignment(draft, options) {
13
14
  function stack(spectra = []) {
@@ -61,7 +62,7 @@ function changeSpectrumVerticalAlignment(draft, options) {
61
62
  exports.changeSpectrumVerticalAlignment = changeSpectrumVerticalAlignment;
62
63
  function setKeyPreferencesHandler(draft, keyCode) {
63
64
  const { data, zoom, xDomain, xDomains, yDomain, yDomains, originDomain, margin, displayerMode, view, } = draft;
64
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
65
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
65
66
  if (view.spectra.activeTab) {
66
67
  const groupByNucleus = (0, GroupByInfoKey_1.default)('nucleus');
67
68
  const spectrumsGroupsList = groupByNucleus(data);
@@ -38,13 +38,14 @@ const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
38
38
  const SumManager_1 = require("../../../data/data1d/Spectrum1D/SumManager");
39
39
  const RangeUtilities_1 = require("../../../data/utilities/RangeUtilities");
40
40
  const Reducer_1 = require("../Reducer");
41
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
41
42
  const getRange_1 = __importDefault(require("../helper/getRange"));
42
43
  const CorrelationsActions_1 = require("./CorrelationsActions");
43
44
  const DomainActions_1 = require("./DomainActions");
44
45
  const ToolsActions_1 = require("./ToolsActions");
45
46
  function handleAutoRangesDetection(draft, options) {
46
47
  const { data, xDomain, molecules, view: { spectra: { activeTab: nucleus }, }, } = draft;
47
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
48
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
48
49
  if (activeSpectrum?.id) {
49
50
  const { index, id } = activeSpectrum;
50
51
  const datum = data[index];
@@ -103,7 +104,7 @@ function getRangeIndex(draft, spectrumIndex, rangeID) {
103
104
  return draft.data[spectrumIndex].ranges.values.findIndex((range) => range.id === rangeID);
104
105
  }
105
106
  function handleDeleteRange(draft, action) {
106
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
107
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
107
108
  if (activeSpectrum?.id) {
108
109
  const { index } = activeSpectrum;
109
110
  const { data, resetSelectTool = false } = action.payload;
@@ -128,7 +129,7 @@ function handleDeleteRange(draft, action) {
128
129
  exports.handleDeleteRange = handleDeleteRange;
129
130
  function handleChangeRangeSignalKind(draft, action) {
130
131
  const state = (0, immer_1.original)(draft);
131
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
132
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(state);
132
133
  if (activeSpectrum?.id) {
133
134
  const { index } = activeSpectrum;
134
135
  const { rowData, value } = action.payload.data;
@@ -147,7 +148,7 @@ function handleChangeRangeSignalKind(draft, action) {
147
148
  exports.handleChangeRangeSignalKind = handleChangeRangeSignalKind;
148
149
  function handleSaveEditedRange(draft, action) {
149
150
  const state = (0, immer_1.original)(draft);
150
- const activeSpectrum = state.view.spectra.activeSpectra[state.view.spectra.activeTab];
151
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(state);
151
152
  if (activeSpectrum?.id) {
152
153
  const { index } = activeSpectrum;
153
154
  const { editedRowData, assignmentData } = action.payload;
@@ -192,7 +193,7 @@ function handleDeleteSignal(draft, action) {
192
193
  }
193
194
  exports.handleDeleteSignal = handleDeleteSignal;
194
195
  function handleUnlinkRange(draft, action) {
195
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
196
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
196
197
  if (activeSpectrum?.id) {
197
198
  const { index } = activeSpectrum;
198
199
  const { assignmentData, rangeData = null, signalIndex = -1, } = action.payload;
@@ -228,7 +229,7 @@ function handleUnlinkRange(draft, action) {
228
229
  }
229
230
  exports.handleUnlinkRange = handleUnlinkRange;
230
231
  function handleSetDiaIDRange(draft, action) {
231
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
232
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
232
233
  if (activeSpectrum?.id) {
233
234
  const { index } = activeSpectrum;
234
235
  const { rangeData, diaIDs, signalIndex, nbAtoms } = action.payload;
@@ -248,7 +249,7 @@ function handleSetDiaIDRange(draft, action) {
248
249
  }
249
250
  exports.handleSetDiaIDRange = handleSetDiaIDRange;
250
251
  function handleResizeRange(draft, action) {
251
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
252
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
252
253
  if (activeSpectrum?.id) {
253
254
  const { index } = activeSpectrum;
254
255
  (0, Spectrum1D_1.changeRange)(draft.data[index], action.data);
@@ -257,7 +258,7 @@ function handleResizeRange(draft, action) {
257
258
  exports.handleResizeRange = handleResizeRange;
258
259
  function handleChangeRangeSum(draft, options) {
259
260
  const { data, view: { spectra: { activeTab: nucleus }, }, } = draft;
260
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
261
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
261
262
  if (activeSpectrum?.id) {
262
263
  const { index } = activeSpectrum;
263
264
  const datum = data[index];
@@ -270,7 +271,7 @@ function addNewRange(draft, props) {
270
271
  const { startX, endX, id } = props;
271
272
  const range = (0, getRange_1.default)(draft, { startX, endX });
272
273
  const { view: { spectra: { activeTab: nucleus }, }, molecules, } = draft;
273
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
274
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
274
275
  if (activeSpectrum?.id) {
275
276
  const { index } = activeSpectrum;
276
277
  const [from, to] = range;
@@ -337,15 +338,16 @@ function handleOnChangeRangesData(draft) {
337
338
  }
338
339
  function handleChangeRangesSumFlag(draft, action) {
339
340
  const flag = action.payload;
340
- if (draft.activeSpectrum?.id) {
341
- const { index } = draft.activeSpectrum;
341
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
342
+ if (activeSpectrum?.id) {
343
+ const { index } = activeSpectrum;
342
344
  draft.data[index].ranges.options.isSumConstant = !flag;
343
345
  }
344
346
  }
345
347
  exports.handleChangeRangesSumFlag = handleChangeRangesSumFlag;
346
348
  function handleUpdateRange(draft, action) {
347
349
  const { range, resetSelectTool = false } = action.payload;
348
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
350
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
349
351
  if (activeSpectrum?.id && range.id) {
350
352
  const datum = draft.data[activeSpectrum?.index];
351
353
  const index = datum.ranges.values.findIndex((_range) => _range.id === range.id);
@@ -35,6 +35,7 @@ const Spectrum2D_1 = require("../../../data/data2d/Spectrum2D");
35
35
  const ToolTypes_1 = require("../../toolbar/ToolTypes");
36
36
  const GroupByInfoKey_1 = __importDefault(require("../../utility/GroupByInfoKey"));
37
37
  const Zoom1DManager_1 = require("../helper/Zoom1DManager");
38
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
38
39
  const DomainActions_1 = require("./DomainActions");
39
40
  const FiltersActions_1 = require("./FiltersActions");
40
41
  const ToolsActions_1 = require("./ToolsActions");
@@ -96,7 +97,7 @@ function handleChangePeaksMarkersVisibility(draft, data) {
96
97
  exports.handleChangePeaksMarkersVisibility = handleChangePeaksMarkersVisibility;
97
98
  function handleChangeActiveSpectrum(draft, activeSpectrum) {
98
99
  let refreshDomain = false;
99
- const currentActiveSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
100
+ const currentActiveSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
100
101
  if (activeSpectrum) {
101
102
  const newIndex = draft.data.findIndex((d) => d.id === activeSpectrum.id);
102
103
  const oldIndex = draft.data.findIndex((d) => d.id === currentActiveSpectrum?.id);
@@ -179,7 +180,7 @@ exports.handleDeleteSpectra = handleDeleteSpectra;
179
180
  function addMissingProjectionHandler(draft, action) {
180
181
  const state = (0, immer_1.original)(draft);
181
182
  const { nucleus } = action;
182
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
183
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
183
184
  if (activeSpectrum?.id) {
184
185
  const { index } = activeSpectrum;
185
186
  for (let n of nucleus) {
@@ -16,6 +16,7 @@ const Reducer_1 = require("../Reducer");
16
16
  const Constants_1 = require("../core/Constants");
17
17
  const Zoom1DManager_1 = require("../helper/Zoom1DManager");
18
18
  const ZoomHistoryManager_1 = __importDefault(require("../helper/ZoomHistoryManager"));
19
+ const getActiveSpectrum_1 = require("../helper/getActiveSpectrum");
19
20
  const getActiveSpectrumOrFail_1 = require("../helper/getActiveSpectrumOrFail");
20
21
  const DomainActions_1 = require("./DomainActions");
21
22
  const FiltersActions_1 = require("./FiltersActions");
@@ -125,10 +126,11 @@ function handleDeleteBaseLineZone(draft, id) {
125
126
  }
126
127
  exports.handleDeleteBaseLineZone = handleDeleteBaseLineZone;
127
128
  function handleToggleRealImaginaryVisibility(draft) {
128
- if (draft.activeSpectrum != null) {
129
- const { index } = draft.activeSpectrum;
130
- draft.data[index].display.isRealSpectrumVisible =
131
- !draft.data[index].display.isRealSpectrumVisible;
129
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
130
+ if (activeSpectrum != null) {
131
+ const { index } = activeSpectrum;
132
+ const datum = draft.data[index];
133
+ datum.display.isRealSpectrumVisible = !datum.display.isRealSpectrumVisible;
132
134
  (0, DomainActions_1.setDomain)(draft);
133
135
  }
134
136
  }
@@ -172,7 +174,7 @@ function handleBrushEnd(draft, action) {
172
174
  }
173
175
  exports.handleBrushEnd = handleBrushEnd;
174
176
  function setVerticalIndicatorXPosition(draft, position) {
175
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
177
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
176
178
  if (activeSpectrum?.id) {
177
179
  const scaleX = (0, scale_1.getXScale)(draft);
178
180
  const value = scaleX.invert(position);
@@ -189,7 +191,7 @@ function getSpectrumID(draft, index) {
189
191
  function handleZoom(draft, action) {
190
192
  const { event, trackID, selectedTool } = action;
191
193
  const { view: { ranges: rangeState }, displayerMode, } = draft;
192
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
194
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
193
195
  const { showRangesIntegrals } = rangeState.find((r) => r.spectrumID === activeSpectrum?.id) ||
194
196
  Reducer_1.rangeStateInit;
195
197
  if (displayerMode === Constants_1.DISPLAYER_MODE.DM_2D) {
@@ -390,7 +392,7 @@ function handelSetActiveTab(draft, tab) {
390
392
  }
391
393
  exports.handelSetActiveTab = handelSetActiveTab;
392
394
  function levelChangeHandler(draft, { deltaY, shiftKey }) {
393
- const activeSpectrum = draft.view.spectra.activeSpectra[draft.view.spectra.activeTab];
395
+ const activeSpectrum = (0, getActiveSpectrum_1.getActiveSpectrum)(draft);
394
396
  try {
395
397
  if (activeSpectrum?.id) {
396
398
  const { index, id } = activeSpectrum;