@complat/react-spectra-editor 1.7.0 → 1.8.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 (111) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/LICENSE +21 -662
  3. package/README.md +5 -0
  4. package/dist/__tests__/fixtures/lc_ms_jcamp.js +2329 -0
  5. package/dist/__tests__/fixtures/lc_ms_jcamp_2.js +2874 -0
  6. package/dist/__tests__/fixtures/lc_ms_jcamp_mz_chemstation.js +3242 -0
  7. package/dist/__tests__/fixtures/lc_ms_jcamp_tic_chemstation.js +854 -0
  8. package/dist/__tests__/fixtures/lc_ms_jcamp_tic_neg.js +1233 -0
  9. package/dist/__tests__/fixtures/lc_ms_jcamp_tic_pos.js +1233 -0
  10. package/dist/__tests__/fixtures/lc_ms_jcamp_uvvis.js +48908 -0
  11. package/dist/__tests__/fixtures/lc_ms_jcamp_uvvis_chemstation.js +15424 -0
  12. package/dist/__tests__/units/components/cmd_bar/r05_submit_btn.test.js +158 -3
  13. package/dist/__tests__/units/components/d3_line_rect.test.js +85 -0
  14. package/dist/__tests__/units/components/d3_multi/multi_focus.test.js +43 -0
  15. package/dist/__tests__/units/components/hplc_viewer.test.js +123 -0
  16. package/dist/__tests__/units/components/panel/info.test.js +55 -15
  17. package/dist/__tests__/units/features/lc-ms/parsing/lcmsCategory.test.js +73 -0
  18. package/dist/__tests__/units/features/lc-ms/submit/peaks.test.js +310 -0
  19. package/dist/actions/curve.js +5 -2
  20. package/dist/actions/hplc_ms.js +66 -0
  21. package/dist/actions/integration.js +17 -2
  22. package/dist/actions/ui.js +39 -11
  23. package/dist/app.js +21 -8
  24. package/dist/components/cmd_bar/01_viewer.js +15 -11
  25. package/dist/components/cmd_bar/03_peak.js +25 -16
  26. package/dist/components/cmd_bar/04_integration.js +116 -17
  27. package/dist/components/cmd_bar/08_peak_group.js +83 -0
  28. package/dist/components/cmd_bar/collapsible_toolbar_group.js +101 -0
  29. package/dist/components/cmd_bar/common.js +4 -3
  30. package/dist/components/cmd_bar/index.js +76 -18
  31. package/dist/components/cmd_bar/r01_layout.js +6 -0
  32. package/dist/components/cmd_bar/r02_scan.js +15 -11
  33. package/dist/components/cmd_bar/r03_threshold.js +19 -3
  34. package/dist/components/cmd_bar/r04_submit.js +61 -6
  35. package/dist/components/cmd_bar/r05_submit_btn.js +60 -13
  36. package/dist/components/cmd_bar/r06_predict_btn.js +4 -4
  37. package/dist/components/cmd_bar/r07_wavelength_btn.js +10 -9
  38. package/dist/components/cmd_bar/r09_detector.js +2 -2
  39. package/dist/components/cmd_bar/tri_btn.js +4 -1
  40. package/dist/components/common/draw.js +6 -5
  41. package/dist/components/d3_line/index.js +70 -15
  42. package/dist/components/d3_line/line_focus.js +104 -67
  43. package/dist/components/d3_line_rect/index.js +836 -0
  44. package/dist/components/d3_line_rect/line_focus.js +526 -0
  45. package/dist/components/d3_line_rect/multi_focus.js +433 -0
  46. package/dist/components/d3_line_rect/rect_focus.js +247 -0
  47. package/dist/components/d3_multi/index.js +154 -163
  48. package/dist/components/d3_multi/multi_focus.js +117 -68
  49. package/dist/components/d3_rect/index.js +6 -0
  50. package/dist/components/d3_rect/rect_focus.js +17 -5
  51. package/dist/components/hplc_viewer.js +169 -0
  52. package/dist/components/lc_ms_uv_tools_bar.js +175 -0
  53. package/dist/components/multi_jcamps_viewer.js +17 -5
  54. package/dist/components/panel/compare.js +84 -62
  55. package/dist/components/panel/cyclic_voltamery_data.js +15 -14
  56. package/dist/components/panel/graph_selection.js +32 -30
  57. package/dist/components/panel/index.js +28 -22
  58. package/dist/components/panel/info.js +90 -31
  59. package/dist/constants/action_type.js +23 -2
  60. package/dist/constants/list_graph.js +16 -0
  61. package/dist/constants/list_layout.js +2 -1
  62. package/dist/constants/list_ui.js +5 -2
  63. package/dist/features/lc-ms/entities/extractEntityLCMS.js +187 -0
  64. package/dist/features/lc-ms/parsing/chemstation.js +108 -0
  65. package/dist/features/lc-ms/parsing/index.js +46 -0
  66. package/dist/features/lc-ms/parsing/lcmsCategory.js +44 -0
  67. package/dist/features/lc-ms/parsing/lcmsJcampInfo.js +18 -0
  68. package/dist/features/lc-ms/parsing/lcmsMsPage.js +241 -0
  69. package/dist/features/lc-ms/parsing/pageValue.js +27 -0
  70. package/dist/features/lc-ms/submit/index.js +24 -0
  71. package/dist/features/lc-ms/submit/peaks.js +66 -0
  72. package/dist/features/lc-ms/ui/wavelengthSelect.js +54 -0
  73. package/dist/fn.js +4 -1
  74. package/dist/helpers/brush.js +74 -19
  75. package/dist/helpers/calc.js +4 -2
  76. package/dist/helpers/cfg.js +5 -4
  77. package/dist/helpers/chem.js +449 -71
  78. package/dist/helpers/compass.js +181 -17
  79. package/dist/helpers/extractEntityLCMS.js +24 -0
  80. package/dist/helpers/extractParams.js +118 -33
  81. package/dist/helpers/extractPeaksEdit.js +29 -9
  82. package/dist/helpers/format.js +189 -4
  83. package/dist/helpers/init.js +25 -5
  84. package/dist/helpers/integration.js +130 -17
  85. package/dist/helpers/integration_draft.js +43 -0
  86. package/dist/helpers/integration_focus.js +155 -0
  87. package/dist/helpers/integration_jcamp.js +68 -0
  88. package/dist/helpers/integration_split.js +202 -0
  89. package/dist/helpers/mount.js +8 -1
  90. package/dist/helpers/sweep.js +39 -0
  91. package/dist/index.js +284 -26
  92. package/dist/layer_content.js +17 -3
  93. package/dist/layer_init.js +124 -14
  94. package/dist/layer_prism.js +31 -5
  95. package/dist/reducers/index.js +3 -1
  96. package/dist/reducers/reducer_curve.js +54 -36
  97. package/dist/reducers/reducer_hplc_ms/hydrate.js +289 -0
  98. package/dist/reducers/reducer_hplc_ms/index.js +122 -0
  99. package/dist/reducers/reducer_hplc_ms/persistence.js +74 -0
  100. package/dist/reducers/reducer_hplc_ms/tic.js +70 -0
  101. package/dist/reducers/reducer_hplc_ms/utils.js +70 -0
  102. package/dist/reducers/reducer_hplc_ms/uvvis.js +377 -0
  103. package/dist/reducers/reducer_integration.js +265 -7
  104. package/dist/reducers/reducer_layout.js +1 -1
  105. package/dist/reducers/reducer_submit.js +2 -1
  106. package/dist/reducers/reducer_ui.js +149 -13
  107. package/dist/reducers/undo_redo_config.js +2 -2
  108. package/dist/sagas/saga_lcms_ui.js +85 -0
  109. package/dist/sagas/saga_ui.js +177 -74
  110. package/dist/setupTests.js +5 -5
  111. package/package.json +10 -7
@@ -45,7 +45,8 @@ const submitReducer = (state = initialState, action) => {
45
45
  }
46
46
  case _action_type.MANAGER.RESETALL:
47
47
  {
48
- const decimal = _format.default.spectraDigit(action.payload.operation.layout);
48
+ const layout = action.payload?.operation?.layout;
49
+ const decimal = layout ? _format.default.spectraDigit(layout) : state.decimal;
49
50
  return Object.assign({}, state, {
50
51
  decimal,
51
52
  isIntensity: true,
@@ -15,7 +15,137 @@ const initialState = {
15
15
  xExtent: false,
16
16
  yExtent: false
17
17
  },
18
- jcampIdx: 0
18
+ jcampIdx: 0,
19
+ subViewerAt: {
20
+ x: null,
21
+ y: null
22
+ },
23
+ zoom: {
24
+ graphIndex: 0,
25
+ sweepExtent: [{
26
+ xExtent: false,
27
+ yExtent: false
28
+ }, {
29
+ xExtent: false,
30
+ yExtent: false
31
+ }, {
32
+ xExtent: false,
33
+ yExtent: false
34
+ }],
35
+ sweepTypes: [_list_ui.LIST_UI_SWEEP_TYPE.ZOOMIN, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET]
36
+ }
37
+ };
38
+ const updateSweepType = (state, action) => {
39
+ const {
40
+ payload
41
+ } = action;
42
+ const {
43
+ graphIndex,
44
+ sweepType
45
+ } = payload;
46
+ if (!sweepType) {
47
+ return Object.assign({}, state, {
48
+ sweepType: action.payload,
49
+ jcampIdx: action.jcampIdx,
50
+ zoom: {
51
+ ...state.zoom,
52
+ sweepTypes: [_list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET]
53
+ }
54
+ });
55
+ }
56
+ const {
57
+ zoom
58
+ } = state;
59
+ let newSweepTypes = zoom.sweepTypes.slice();
60
+ if (sweepType === _list_ui.LIST_UI_SWEEP_TYPE.ZOOMIN) {
61
+ newSweepTypes = newSweepTypes.map((val, idx) => idx === graphIndex ? _list_ui.LIST_UI_SWEEP_TYPE.ZOOMIN : _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET);
62
+ } else {
63
+ newSweepTypes = newSweepTypes.map(() => _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET);
64
+ if (graphIndex !== undefined) {
65
+ newSweepTypes[graphIndex] = sweepType;
66
+ }
67
+ }
68
+ const newZoom = Object.assign({}, zoom, {
69
+ sweepTypes: newSweepTypes,
70
+ graphIndex
71
+ });
72
+ return Object.assign({}, state, {
73
+ zoom: newZoom,
74
+ sweepType
75
+ });
76
+ };
77
+ const updateZoom = (state, action) => {
78
+ const {
79
+ payload
80
+ } = action;
81
+ const {
82
+ graphIndex,
83
+ zoomValue,
84
+ lcmsSyncX
85
+ } = payload;
86
+ if (!zoomValue) {
87
+ return Object.assign({}, state, {
88
+ sweepExtent: payload
89
+ });
90
+ }
91
+ const {
92
+ zoom
93
+ } = state;
94
+ const sweepExtent = Array.isArray(zoom.sweepExtent) ? [...zoom.sweepExtent] : [];
95
+ const selectedGraph = sweepExtent[graphIndex];
96
+ const newSweepExtent = Object.assign({}, selectedGraph, zoomValue);
97
+ sweepExtent[graphIndex] = newSweepExtent;
98
+ if (lcmsSyncX != null && zoomValue && zoomValue.xExtent) {
99
+ const otherIdx = lcmsSyncX;
100
+ const otherGraph = sweepExtent[otherIdx] || {};
101
+ sweepExtent[otherIdx] = Object.assign({}, otherGraph, {
102
+ xExtent: zoomValue.xExtent,
103
+ yExtent: false
104
+ });
105
+ }
106
+ const newZoom = Object.assign({}, zoom, {
107
+ sweepExtent,
108
+ graphIndex
109
+ });
110
+ return Object.assign({}, state, {
111
+ zoom: newZoom
112
+ });
113
+ };
114
+ const resetZoom = (state, action) => {
115
+ const {
116
+ payload
117
+ } = action;
118
+ const {
119
+ graphIndex
120
+ } = payload || {};
121
+ if (graphIndex === undefined) {
122
+ return Object.assign({}, state, {
123
+ sweepExtent: {
124
+ xExtent: false,
125
+ yExtent: false
126
+ }
127
+ });
128
+ }
129
+ const {
130
+ zoom
131
+ } = state;
132
+ const sweepExtent = Array.isArray(zoom.sweepExtent) ? [...zoom.sweepExtent] : [];
133
+ const indicesToReset = graphIndex === 0 || graphIndex === 1 ? [0, 1] : [graphIndex];
134
+ indicesToReset.forEach(idx => {
135
+ const selectedGraph = sweepExtent[idx] || {};
136
+ sweepExtent[idx] = Object.assign({}, selectedGraph, {
137
+ xExtent: false,
138
+ yExtent: false
139
+ });
140
+ });
141
+ return Object.assign({}, state, {
142
+ zoom: {
143
+ sweepExtent,
144
+ graphIndex,
145
+ sweepTypes: [_list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET]
146
+ },
147
+ sweepType: _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET
148
+ });
19
149
  };
20
150
  const uiReducer = (state = initialState, action) => {
21
151
  switch (action.type) {
@@ -24,21 +154,27 @@ const uiReducer = (state = initialState, action) => {
24
154
  viewer: action.payload
25
155
  });
26
156
  case _action_type.UI.SWEEP.SET_TYPE:
27
- if (action.payload === _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET) {
28
- return Object.assign({}, state, {
29
- sweepExtent: {
30
- xExtent: false,
31
- yExtent: false
32
- }
33
- });
157
+ if (action.payload.sweepType === _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET || action.payload === _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET) {
158
+ // return Object.assign({}, state, {
159
+ // sweepExtent: { xExtent: false, yExtent: false },
160
+ // });
161
+ return resetZoom(state, action);
34
162
  }
35
- return Object.assign({}, state, {
36
- sweepType: action.payload,
37
- jcampIdx: action.jcampIdx
38
- });
163
+ // return Object.assign({}, state, {
164
+ // sweepType: action.payload,
165
+ // jcampIdx: action.jcampIdx,
166
+ // });
167
+ return updateSweepType(state, action);
39
168
  case _action_type.UI.SWEEP.SELECT_ZOOMIN:
169
+ {
170
+ // return Object.assign({}, state, {
171
+ // sweepExtent: action.payload,
172
+ // });
173
+ return updateZoom(state, action);
174
+ }
175
+ case _action_type.UI.SUB_VIEWER.DISPLAY_VIEWER_AT:
40
176
  return Object.assign({}, state, {
41
- sweepExtent: action.payload
177
+ subViewerAt: action.payload
42
178
  });
43
179
  case _action_type.MANAGER.RESETALL:
44
180
  return initialState;
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.undoRedoConfig = exports.undoRedoActions = void 0;
7
7
  var _reduxUndo = require("redux-undo");
8
8
  var _action_type = require("../constants/action_type");
9
- const undoRedoActions = exports.undoRedoActions = [_action_type.EDITPEAK.ADD_POSITIVE, _action_type.EDITPEAK.ADD_NEGATIVE, _action_type.EDITPEAK.RM_POSITIVE, _action_type.EDITPEAK.RM_NEGATIVE, _action_type.EDITPEAK.SHIFT, _action_type.EDITPEAK.CLEAR_ALL, _action_type.MANAGER.RESETALL, _action_type.MANAGER.RESETSHIFT, _action_type.MANAGER.RESET_INIT_COMMON, _action_type.MANAGER.RESET_INIT_NMR, _action_type.MANAGER.RESET_INIT_MS, _action_type.MANAGER.RESET_INIT_COMMON_WITH_INTERGATION, _action_type.UI.SWEEP.SELECT_INTEGRATION, _action_type.UI.SWEEP.SELECT_MULTIPLICITY_RDC, _action_type.INTEGRATION.RM_ONE, _action_type.INTEGRATION.SET_REF, _action_type.INTEGRATION.SET_FKR, _action_type.INTEGRATION.RESET_ALL, _action_type.INTEGRATION.CLEAR_ALL, _action_type.MULTIPLICITY.PEAK_RM_BY_PANEL_RDC, _action_type.MULTIPLICITY.PEAK_RM_BY_UI_RDC, _action_type.MULTIPLICITY.PEAK_ADD_BY_UI_RDC, _action_type.MULTIPLICITY.RESET_ONE_RDC, _action_type.MULTIPLICITY.UPDATE_J, _action_type.MULTIPLICITY.TYPE_SELECT_RDC, _action_type.MULTIPLICITY.ONE_CLICK, _action_type.MULTIPLICITY.ONE_CLICK_BY_UI, _action_type.MULTIPLICITY.RESET_ALL_RDC, _action_type.MULTIPLICITY.CLEAR_ALL];
9
+ const undoRedoActions = exports.undoRedoActions = [_action_type.EDITPEAK.ADD_POSITIVE, _action_type.EDITPEAK.ADD_NEGATIVE, _action_type.EDITPEAK.RM_POSITIVE, _action_type.EDITPEAK.RM_NEGATIVE, _action_type.EDITPEAK.SHIFT, _action_type.EDITPEAK.CLEAR_ALL, _action_type.MANAGER.RESETALL, _action_type.MANAGER.RESETSHIFT, _action_type.MANAGER.RESET_INIT_COMMON, _action_type.MANAGER.RESET_INIT_NMR, _action_type.MANAGER.RESET_INIT_MS, _action_type.MANAGER.RESET_INIT_COMMON_WITH_INTERGATION, _action_type.UI.SWEEP.SELECT_INTEGRATION, _action_type.UI.SWEEP.SELECT_MULTIPLICITY_RDC, _action_type.INTEGRATION.RM_ONE, _action_type.INTEGRATION.SET_REF, _action_type.INTEGRATION.SET_FKR, _action_type.INTEGRATION.SPLIT, _action_type.INTEGRATION.ADD_VISUAL_SPLIT, _action_type.INTEGRATION.RM_VISUAL_SPLIT, _action_type.INTEGRATION.RESET_ALL, _action_type.INTEGRATION.CLEAR_ALL, _action_type.MULTIPLICITY.PEAK_RM_BY_PANEL_RDC, _action_type.MULTIPLICITY.PEAK_RM_BY_UI_RDC, _action_type.MULTIPLICITY.PEAK_ADD_BY_UI_RDC, _action_type.MULTIPLICITY.RESET_ONE_RDC, _action_type.MULTIPLICITY.UPDATE_J, _action_type.MULTIPLICITY.TYPE_SELECT_RDC, _action_type.MULTIPLICITY.ONE_CLICK, _action_type.MULTIPLICITY.ONE_CLICK_BY_UI, _action_type.MULTIPLICITY.RESET_ALL_RDC, _action_type.MULTIPLICITY.CLEAR_ALL];
10
10
  const undoRedoConfig = exports.undoRedoConfig = {
11
11
  debug: false,
12
12
  limit: 10,
13
- ignoreInitialState: true,
13
+ ignoreInitialState: false,
14
14
  filter: (0, _reduxUndo.includeAction)(undoRedoActions),
15
15
  clearHistoryType: [_action_type.EDITPEAK.SHIFT, _action_type.EDITPEAK.CLEAR_ALL, _action_type.MANAGER.RESETALL, _action_type.MANAGER.RESETSHIFT, _action_type.MANAGER.RESET_INIT_COMMON, _action_type.MANAGER.RESET_INIT_NMR, _action_type.MANAGER.RESET_INIT_MS, _action_type.MANAGER.RESET_INIT_COMMON_WITH_INTERGATION],
16
16
  neverSkipReducer: [_action_type.EDITPEAK.SHIFT, _action_type.EDITPEAK.CLEAR_ALL, _action_type.MANAGER.RESETALL, _action_type.MANAGER.RESETSHIFT, _action_type.MANAGER.RESET_INIT_COMMON, _action_type.MANAGER.RESET_INIT_NMR, _action_type.MANAGER.RESET_INIT_MS, _action_type.MANAGER.RESET_INIT_COMMON_WITH_INTERGATION]
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.lcmsHandleIntegrationAdd = lcmsHandleIntegrationAdd;
7
+ exports.lcmsHandleIntegrationRm = lcmsHandleIntegrationRm;
8
+ exports.lcmsHandlePeakDelete = lcmsHandlePeakDelete;
9
+ exports.lcmsHandleSelectZoomIn = lcmsHandleSelectZoomIn;
10
+ exports.lcmsHandleSelectZoomReset = lcmsHandleSelectZoomReset;
11
+ var _effects = require("redux-saga/effects");
12
+ var _action_type = require("../constants/action_type");
13
+ function* lcmsHandleSelectZoomIn({
14
+ payload,
15
+ zoom
16
+ }) {
17
+ const {
18
+ graphIndex
19
+ } = zoom;
20
+ let lcmsSyncX;
21
+ if ((graphIndex === 0 || graphIndex === 1) && payload?.xExtent) {
22
+ lcmsSyncX = graphIndex === 0 ? 1 : 0;
23
+ }
24
+ yield (0, _effects.put)({
25
+ type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
26
+ payload: {
27
+ graphIndex,
28
+ zoomValue: payload,
29
+ ...(lcmsSyncX != null ? {
30
+ lcmsSyncX
31
+ } : {})
32
+ }
33
+ });
34
+ }
35
+ function* lcmsHandleSelectZoomReset() {
36
+ yield (0, _effects.put)({
37
+ type: _action_type.UI.SWEEP.SELECT_ZOOMRESET,
38
+ payload: {
39
+ graphIndex: 0
40
+ }
41
+ });
42
+ yield (0, _effects.put)({
43
+ type: _action_type.UI.SWEEP.SELECT_ZOOMRESET,
44
+ payload: {
45
+ graphIndex: 1
46
+ }
47
+ });
48
+ }
49
+ function* lcmsHandleIntegrationAdd({
50
+ uvvis,
51
+ payload
52
+ }) {
53
+ yield (0, _effects.put)({
54
+ type: _action_type.HPLC_MS.UPDATE_HPLCMS_INTEGRATIONS,
55
+ payload: {
56
+ spectrumId: uvvis.selectedWaveLength,
57
+ integration: payload
58
+ }
59
+ });
60
+ }
61
+ function* lcmsHandlePeakDelete({
62
+ uvvis,
63
+ payload
64
+ }) {
65
+ yield (0, _effects.put)({
66
+ type: _action_type.HPLC_MS.REMOVE_HPLCMS_PEAK,
67
+ payload: {
68
+ spectrumId: uvvis.selectedWaveLength,
69
+ peak: payload
70
+ }
71
+ });
72
+ }
73
+ function* lcmsHandleIntegrationRm({
74
+ uvvis,
75
+ payload
76
+ }) {
77
+ yield (0, _effects.put)({
78
+ type: _action_type.HPLC_MS.UPDATE_HPLCMS_INTEGRATIONS,
79
+ payload: {
80
+ spectrumId: uvvis.selectedWaveLength,
81
+ integration: payload,
82
+ remove: true
83
+ }
84
+ });
85
+ }
@@ -3,13 +3,17 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.shouldDisplayLcmsSubViewerAt = exports.default = void 0;
7
7
  var _effects = require("redux-saga/effects");
8
8
  var _action_type = require("../constants/action_type");
9
9
  var _list_ui = require("../constants/list_ui");
10
10
  var _list_layout = require("../constants/list_layout");
11
- const getUiSt = state => state.ui;
12
- const getCurveSt = state => state.curve;
11
+ var _list_graph = require("../constants/list_graph");
12
+ var _saga_lcms_ui = require("./saga_lcms_ui");
13
+ const getUiState = state => state.ui;
14
+ const getCurveState = state => state.curve;
15
+ const getHplcMsState = state => state.hplcMs;
16
+ const getSubViewZoomActionType = () => _action_type.UI.SWEEP.SELECT_ZOOMIN_SUBVIEW || _action_type.UI.SWEEP.SELECT_ZOOMIN;
13
17
  const calcPeaks = payload => {
14
18
  const {
15
19
  xExtent,
@@ -28,76 +32,110 @@ const calcPeaks = payload => {
28
32
  const peaks = dataPks.filter(p => xL <= p.x && p.x <= xU && yL <= p.y && p.y <= yU);
29
33
  return peaks;
30
34
  };
35
+ const getLayoutState = state => state.layout;
31
36
  function* selectUiSweep(action) {
32
- const uiSt = yield (0, _effects.select)(getUiSt);
37
+ const uiState = yield (0, _effects.select)(getUiState);
38
+ const {
39
+ sweepType,
40
+ zoom
41
+ } = uiState;
33
42
  const {
34
43
  payload
35
44
  } = action;
36
- const curveSt = yield (0, _effects.select)(getCurveSt);
45
+ const curveState = yield (0, _effects.select)(getCurveState);
37
46
  const {
38
47
  curveIdx
39
- } = curveSt;
40
- switch (uiSt.sweepType) {
48
+ } = curveState;
49
+ const hplcMsState = yield (0, _effects.select)(getHplcMsState);
50
+ const {
51
+ uvvis
52
+ } = hplcMsState;
53
+ const layoutState = yield (0, _effects.select)(getLayoutState);
54
+ switch (sweepType) {
41
55
  case _list_ui.LIST_UI_SWEEP_TYPE.ZOOMIN:
42
- yield (0, _effects.put)({
43
- type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
44
- payload
45
- });
56
+ if (layoutState === _list_layout.LIST_LAYOUT.LC_MS && uvvis.listWaveLength) {
57
+ yield* (0, _saga_lcms_ui.lcmsHandleSelectZoomIn)({
58
+ payload,
59
+ zoom
60
+ });
61
+ } else {
62
+ yield (0, _effects.put)({
63
+ type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
64
+ payload
65
+ });
66
+ }
46
67
  break;
47
68
  case _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET:
48
- yield (0, _effects.put)({
49
- type: _action_type.UI.SWEEP.SELECT_ZOOMRESET,
50
- payload
51
- });
69
+ if (layoutState === _list_layout.LIST_LAYOUT.LC_MS && (payload?.graphIndex === 0 || payload?.graphIndex === 1)) {
70
+ yield* (0, _saga_lcms_ui.lcmsHandleSelectZoomReset)();
71
+ } else {
72
+ yield (0, _effects.put)({
73
+ type: _action_type.UI.SWEEP.SELECT_ZOOMRESET,
74
+ payload
75
+ });
76
+ }
52
77
  break;
53
78
  case _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_ADD:
54
- yield (0, _effects.put)({
55
- type: _action_type.UI.SWEEP.SELECT_INTEGRATION,
56
- payload: {
57
- newData: payload,
58
- curveIdx
79
+ {
80
+ if (uvvis.selectedWaveLength && layoutState === _list_layout.LIST_LAYOUT.LC_MS) {
81
+ yield* (0, _saga_lcms_ui.lcmsHandleIntegrationAdd)({
82
+ uvvis,
83
+ payload
84
+ });
85
+ } else {
86
+ yield (0, _effects.put)({
87
+ type: _action_type.UI.SWEEP.SELECT_INTEGRATION,
88
+ payload: {
89
+ newData: payload,
90
+ curveIdx
91
+ }
92
+ });
59
93
  }
60
- });
61
- break;
62
- case _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_SWEEP_ADD:
63
- const peaks = calcPeaks(payload); // eslint-disable-line
64
- if (peaks.length === 0) {
65
94
  break;
66
95
  }
67
- const newPayload = Object.assign({}, payload, {
68
- peaks
69
- }); // eslint-disable-line
70
-
71
- yield (0, _effects.put)({
72
- type: _action_type.UI.SWEEP.SELECT_INTEGRATION,
73
- payload: {
74
- newData: newPayload,
75
- curveIdx
76
- }
77
- });
78
- yield (0, _effects.put)({
79
- type: _action_type.UI.SWEEP.SELECT_MULTIPLICITY,
80
- payload: {
81
- newData: newPayload,
82
- curveIdx
96
+ case _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_SWEEP_ADD:
97
+ {
98
+ const peaks = calcPeaks(payload); // eslint-disable-line
99
+ if (peaks.length === 0) {
100
+ break;
83
101
  }
84
- });
85
- break;
102
+ const newPayload = {
103
+ ...payload,
104
+ peaks
105
+ }; // eslint-disable-line
106
+
107
+ yield (0, _effects.put)({
108
+ type: _action_type.UI.SWEEP.SELECT_INTEGRATION,
109
+ payload: {
110
+ newData: newPayload,
111
+ curveIdx
112
+ }
113
+ });
114
+ yield (0, _effects.put)({
115
+ type: _action_type.UI.SWEEP.SELECT_MULTIPLICITY,
116
+ payload: {
117
+ newData: newPayload,
118
+ curveIdx
119
+ }
120
+ });
121
+ break;
122
+ }
86
123
  default:
87
124
  break;
88
125
  }
89
126
  return null;
90
127
  }
91
- const getLayoutSt = state => state.layout;
92
128
  function* scrollUiWheel(action) {
93
- const layoutSt = yield (0, _effects.select)(getLayoutSt);
129
+ const layoutState = yield (0, _effects.select)(getLayoutState);
94
130
  const {
95
131
  payload
96
132
  } = action;
133
+ if (!payload?.xExtent || !payload?.yExtent) return;
97
134
  const {
98
135
  xExtent,
99
136
  yExtent,
100
- direction
137
+ direction,
138
+ brushClass
101
139
  } = payload;
102
140
  const {
103
141
  yL,
@@ -110,7 +148,7 @@ function* scrollUiWheel(action) {
110
148
  yExtent: false
111
149
  };
112
150
  let [nyeL, nyeU, h, nytL, nytU] = [0, 1, 1, 0, 1];
113
- switch (layoutSt) {
151
+ switch (layoutState) {
114
152
  case _list_layout.LIST_LAYOUT.IR:
115
153
  case _list_layout.LIST_LAYOUT.RAMAN:
116
154
  [nyeL, nyeU] = [yeL + (yeU - yeL) * (1 - scale), yeU];
@@ -154,40 +192,93 @@ function* scrollUiWheel(action) {
154
192
  };
155
193
  break;
156
194
  }
157
- yield (0, _effects.put)({
158
- type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
159
- payload: nextExtent
160
- });
195
+ if (brushClass === `.${_list_graph.LIST_BRUSH_SVG_GRAPH.RECT}`) {
196
+ yield (0, _effects.put)({
197
+ type: getSubViewZoomActionType(),
198
+ payload: nextExtent
199
+ });
200
+ } else {
201
+ yield (0, _effects.put)({
202
+ type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
203
+ payload: nextExtent
204
+ });
205
+ }
161
206
  }
162
207
  const getUiSweepType = state => state.ui.sweepType;
208
+ const shouldDisplayLcmsSubViewerAt = ({
209
+ isLcmsLayout,
210
+ payload,
211
+ sourceHint,
212
+ uiSweepType
213
+ }) => isLcmsLayout && sourceHint === 'lcms_tic' && Number.isFinite(payload?.x) && [_list_ui.LIST_UI_SWEEP_TYPE.ZOOMIN, _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET, _list_ui.LIST_UI_SWEEP_TYPE.PEAK_GROUP_SELECT].includes(uiSweepType);
214
+ exports.shouldDisplayLcmsSubViewerAt = shouldDisplayLcmsSubViewerAt;
163
215
  function* clickUiTarget(action) {
164
216
  const {
165
217
  payload,
166
218
  onPeak,
167
219
  voltammetryPeakIdx,
168
- onPecker
220
+ onPecker,
221
+ sourceHint
169
222
  } = action;
170
223
  const uiSweepType = yield (0, _effects.select)(getUiSweepType);
171
- const curveSt = yield (0, _effects.select)(getCurveSt);
224
+ const curveState = yield (0, _effects.select)(getCurveState);
172
225
  const {
173
226
  curveIdx
174
- } = curveSt;
175
- if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_ADD && !onPeak) {
227
+ } = curveState;
228
+ const hplcMsState = yield (0, _effects.select)(getHplcMsState);
229
+ const {
230
+ uvvis
231
+ } = hplcMsState;
232
+ const isLcmsLayout = (yield (0, _effects.select)(getLayoutState)) === _list_layout.LIST_LAYOUT.LC_MS;
233
+ if (shouldDisplayLcmsSubViewerAt({
234
+ isLcmsLayout,
235
+ payload,
236
+ sourceHint,
237
+ uiSweepType
238
+ })) {
176
239
  yield (0, _effects.put)({
177
- type: _action_type.EDITPEAK.ADD_POSITIVE,
178
- payload: {
179
- dataToAdd: payload,
180
- curveIdx
181
- }
240
+ type: _action_type.UI.SUB_VIEWER.DISPLAY_VIEWER_AT,
241
+ payload
182
242
  });
243
+ return;
244
+ }
245
+ if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_ADD && !onPeak) {
246
+ if (isLcmsLayout) {
247
+ const spectrumId = hplcMsState?.uvvis?.selectedWaveLength;
248
+ if (spectrumId == null) return;
249
+ const currentPeaks = hplcMsState?.uvvis?.currentSpectrum?.peaks || [];
250
+ const updatedPeaks = [...currentPeaks, payload];
251
+ yield (0, _effects.put)({
252
+ type: _action_type.HPLC_MS.UPDATE_HPLCMS_PEAKS,
253
+ payload: {
254
+ spectrumId,
255
+ peaks: updatedPeaks
256
+ }
257
+ });
258
+ } else {
259
+ yield (0, _effects.put)({
260
+ type: _action_type.EDITPEAK.ADD_POSITIVE,
261
+ payload: {
262
+ dataToAdd: payload,
263
+ curveIdx
264
+ }
265
+ });
266
+ }
183
267
  } else if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_DELETE && onPeak) {
184
- yield (0, _effects.put)({
185
- type: _action_type.EDITPEAK.ADD_NEGATIVE,
186
- payload: {
187
- dataToAdd: payload,
188
- curveIdx
189
- }
190
- });
268
+ if (isLcmsLayout && uvvis.selectedWaveLength) {
269
+ yield* (0, _saga_lcms_ui.lcmsHandlePeakDelete)({
270
+ uvvis,
271
+ payload
272
+ });
273
+ } else {
274
+ yield (0, _effects.put)({
275
+ type: _action_type.EDITPEAK.ADD_NEGATIVE,
276
+ payload: {
277
+ dataToAdd: payload,
278
+ curveIdx
279
+ }
280
+ });
281
+ }
191
282
  } else if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.ANCHOR_SHIFT && onPeak) {
192
283
  yield (0, _effects.put)({
193
284
  type: _action_type.SHIFT.SET_PEAK,
@@ -197,13 +288,20 @@ function* clickUiTarget(action) {
197
288
  }
198
289
  });
199
290
  } else if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_RM && onPeak) {
200
- yield (0, _effects.put)({
201
- type: _action_type.INTEGRATION.RM_ONE,
202
- payload: {
203
- dataToRemove: payload,
204
- curveIdx
205
- }
206
- });
291
+ if (uvvis.selectedWaveLength && isLcmsLayout) {
292
+ yield* (0, _saga_lcms_ui.lcmsHandleIntegrationRm)({
293
+ uvvis,
294
+ payload
295
+ });
296
+ } else {
297
+ yield (0, _effects.put)({
298
+ type: _action_type.INTEGRATION.RM_ONE,
299
+ payload: {
300
+ dataToRemove: payload,
301
+ curveIdx
302
+ }
303
+ });
304
+ }
207
305
  } else if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_ONE_RM && onPeak) {
208
306
  yield (0, _effects.put)({
209
307
  type: _action_type.INTEGRATION.RM_ONE,
@@ -315,6 +413,11 @@ function* clickUiTarget(action) {
315
413
  jcampIdx: curveIdx
316
414
  }
317
415
  });
416
+ } else if (uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_GROUP_SELECT) {
417
+ yield (0, _effects.put)({
418
+ type: _action_type.UI.SUB_VIEWER.DISPLAY_VIEWER_AT,
419
+ payload
420
+ });
318
421
  }
319
422
  }
320
423
  const managerSagas = [(0, _effects.takeEvery)(_action_type.UI.CLICK_TARGET, clickUiTarget), (0, _effects.takeEvery)(_action_type.UI.SWEEP.SELECT, selectUiSweep), (0, _effects.takeEvery)(_action_type.UI.WHEEL.SCROLL, scrollUiWheel)];
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _enzyme = _interopRequireDefault(require("enzyme"));
5
- var _enzymeAdapterReact = _interopRequireDefault(require("@wojtekmaj/enzyme-adapter-react-17"));
6
- _enzyme.default.configure({
7
- adapter: new _enzymeAdapterReact.default()
3
+ const Enzyme = require('enzyme');
4
+ const AdapterModule = require('@wojtekmaj/enzyme-adapter-react-17');
5
+ const Adapter = AdapterModule.default || AdapterModule;
6
+ Enzyme.configure({
7
+ adapter: new Adapter()
8
8
  });