@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
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+
3
+ var _peaks = require("../../../../../features/lc-ms/submit/peaks");
4
+ describe('lc-ms/submit peaks — backend payload shape', () => {
5
+ describe('formatLcmsPeaksForBackend', () => {
6
+ it('returns empty array when state is missing or has no spectraList', () => {
7
+ expect((0, _peaks.formatLcmsPeaksForBackend)(null)).toEqual([]);
8
+ expect((0, _peaks.formatLcmsPeaksForBackend)({})).toEqual([]);
9
+ expect((0, _peaks.formatLcmsPeaksForBackend)({
10
+ uvvis: {}
11
+ })).toEqual([]);
12
+ expect((0, _peaks.formatLcmsPeaksForBackend)({
13
+ uvvis: {
14
+ spectraList: null
15
+ }
16
+ })).toEqual([]);
17
+ });
18
+ it('adds wavelength from spectrum pageValue to each peak (single channel)', () => {
19
+ const hplcMsSt = {
20
+ uvvis: {
21
+ spectraList: [{
22
+ pageValue: 254,
23
+ peaks: [{
24
+ x: 1.2,
25
+ y: 10,
26
+ _meta: 'a'
27
+ }, {
28
+ x: 3.4,
29
+ y: 20
30
+ }]
31
+ }]
32
+ }
33
+ };
34
+ const out = (0, _peaks.formatLcmsPeaksForBackend)(hplcMsSt);
35
+ expect(out).toEqual([{
36
+ x: 1.2,
37
+ y: 10,
38
+ _meta: 'a',
39
+ wavelength: 254
40
+ }, {
41
+ x: 3.4,
42
+ y: 20,
43
+ wavelength: 254
44
+ }]);
45
+ });
46
+ it('flattens peaks from multiple UV channels with distinct wavelengths', () => {
47
+ const hplcMsSt = {
48
+ uvvis: {
49
+ spectraList: [{
50
+ pageValue: 230,
51
+ peaks: [{
52
+ x: 0.1,
53
+ y: 1
54
+ }]
55
+ }, {
56
+ pageValue: 280,
57
+ peaks: [{
58
+ x: 0.2,
59
+ y: 2
60
+ }, {
61
+ x: 0.3,
62
+ y: 3
63
+ }]
64
+ }, {
65
+ pageValue: 210,
66
+ peaks: []
67
+ }]
68
+ }
69
+ };
70
+ const out = (0, _peaks.formatLcmsPeaksForBackend)(hplcMsSt);
71
+ expect(out).toHaveLength(3);
72
+ expect(out[0]).toMatchObject({
73
+ x: 0.1,
74
+ wavelength: 230
75
+ });
76
+ expect(out[1]).toMatchObject({
77
+ x: 0.2,
78
+ wavelength: 280
79
+ });
80
+ expect(out[2]).toMatchObject({
81
+ x: 0.3,
82
+ wavelength: 280
83
+ });
84
+ });
85
+ it('ignores spectra with no peaks', () => {
86
+ const hplcMsSt = {
87
+ uvvis: {
88
+ spectraList: [{
89
+ pageValue: 254,
90
+ peaks: []
91
+ }, {
92
+ pageValue: 230,
93
+ peaks: [{
94
+ x: 1,
95
+ y: 1
96
+ }]
97
+ }]
98
+ }
99
+ };
100
+ expect((0, _peaks.formatLcmsPeaksForBackend)(hplcMsSt)).toEqual([{
101
+ x: 1,
102
+ y: 1,
103
+ wavelength: 230
104
+ }]);
105
+ });
106
+ });
107
+ describe('formatLcmsIntegralsForBackend', () => {
108
+ it('returns empty when no integrals', () => {
109
+ expect((0, _peaks.formatLcmsIntegralsForBackend)(null)).toEqual([]);
110
+ expect((0, _peaks.formatLcmsIntegralsForBackend)({
111
+ uvvis: {
112
+ spectraList: []
113
+ }
114
+ })).toEqual([]);
115
+ });
116
+ it('maps integration fields to backend keys (from, to, value, integral, wavelength)', () => {
117
+ const hplcMsSt = {
118
+ uvvis: {
119
+ spectraList: [{
120
+ pageValue: 254,
121
+ integrations: [{
122
+ xL: 1,
123
+ xU: 2,
124
+ area: 100,
125
+ absoluteArea: 1000
126
+ }, {
127
+ xL: 3,
128
+ xU: 4,
129
+ area: 50,
130
+ absoluteArea: 500
131
+ }]
132
+ }]
133
+ }
134
+ };
135
+ expect((0, _peaks.formatLcmsIntegralsForBackend)(hplcMsSt)).toEqual([{
136
+ from: 1,
137
+ to: 2,
138
+ value: 100,
139
+ integral: 1000,
140
+ wavelength: 254
141
+ }, {
142
+ from: 3,
143
+ to: 4,
144
+ value: 50,
145
+ integral: 500,
146
+ wavelength: 254
147
+ }]);
148
+ });
149
+ });
150
+ describe('getLcmsMzPageData', () => {
151
+ it('returns null when tic or ms is missing', () => {
152
+ expect((0, _peaks.getLcmsMzPageData)(null)).toBeNull();
153
+ expect((0, _peaks.getLcmsMzPageData)({})).toBeNull();
154
+ expect((0, _peaks.getLcmsMzPageData)({
155
+ tic: {}
156
+ })).toBeNull();
157
+ expect((0, _peaks.getLcmsMzPageData)({
158
+ ms: {}
159
+ })).toBeNull();
160
+ });
161
+ it('returns null when TIC x axis is missing or currentPageValue is not finite', () => {
162
+ const base = {
163
+ tic: {
164
+ polarity: 'positive',
165
+ currentPageValue: 0.5,
166
+ positive: {
167
+ data: {}
168
+ }
169
+ },
170
+ ms: {
171
+ positive: {
172
+ pageValues: [0.5],
173
+ peaks: [[{
174
+ x: 100,
175
+ y: 1
176
+ }]]
177
+ }
178
+ }
179
+ };
180
+ expect((0, _peaks.getLcmsMzPageData)({
181
+ ...base,
182
+ tic: {
183
+ ...base.tic,
184
+ currentPageValue: NaN
185
+ }
186
+ })).toBeNull();
187
+ });
188
+ it('returns null when RT does not match any TIC point or page value', () => {
189
+ const hplcMsSt = {
190
+ tic: {
191
+ polarity: 'positive',
192
+ currentPageValue: 0.99,
193
+ positive: {
194
+ data: {
195
+ x: [0.1, 0.2]
196
+ }
197
+ }
198
+ },
199
+ ms: {
200
+ positive: {
201
+ pageValues: [0.1, 0.2],
202
+ peaks: [[{
203
+ x: 50,
204
+ y: 1
205
+ }], [{
206
+ x: 60,
207
+ y: 2
208
+ }]]
209
+ }
210
+ }
211
+ };
212
+ expect((0, _peaks.getLcmsMzPageData)(hplcMsSt)).toBeNull();
213
+ });
214
+ it('resolves MS peak array for positive polarity via pageValues', () => {
215
+ const peakRow = [{
216
+ x: 120.1,
217
+ y: 999
218
+ }, {
219
+ x: 121,
220
+ y: 1
221
+ }];
222
+ const hplcMsSt = {
223
+ tic: {
224
+ polarity: 'positive',
225
+ currentPageValue: 0.5,
226
+ positive: {
227
+ data: {
228
+ x: [0.4, 0.5, 0.6]
229
+ }
230
+ }
231
+ },
232
+ ms: {
233
+ positive: {
234
+ pageValues: [0.4, 0.5, 0.6],
235
+ peaks: [[], peakRow, []]
236
+ }
237
+ }
238
+ };
239
+ expect((0, _peaks.getLcmsMzPageData)(hplcMsSt)).toEqual(peakRow);
240
+ });
241
+ it('uses negative polarity and matching pageValues', () => {
242
+ const peakRow = [{
243
+ x: 200,
244
+ y: 1
245
+ }];
246
+ const hplcMsSt = {
247
+ tic: {
248
+ polarity: 'negative',
249
+ currentPageValue: 1.0,
250
+ negative: {
251
+ data: {
252
+ x: [1.0]
253
+ }
254
+ }
255
+ },
256
+ ms: {
257
+ negative: {
258
+ pageValues: [1.0],
259
+ peaks: [peakRow]
260
+ }
261
+ }
262
+ };
263
+ expect((0, _peaks.getLcmsMzPageData)(hplcMsSt)).toEqual(peakRow);
264
+ });
265
+ it('falls back to TIC x index when pageValues does not list the RT', () => {
266
+ const peakRow = [{
267
+ x: 300,
268
+ y: 1
269
+ }];
270
+ const hplcMsSt = {
271
+ tic: {
272
+ polarity: 'positive',
273
+ currentPageValue: 0.5,
274
+ positive: {
275
+ data: {
276
+ x: [0.3, 0.5, 0.7]
277
+ }
278
+ }
279
+ },
280
+ ms: {
281
+ positive: {
282
+ pageValues: null,
283
+ peaks: [[], peakRow, []]
284
+ }
285
+ }
286
+ };
287
+ expect((0, _peaks.getLcmsMzPageData)(hplcMsSt)).toEqual(peakRow);
288
+ });
289
+ it('returns null when peaks slot is not an array', () => {
290
+ const hplcMsSt = {
291
+ tic: {
292
+ polarity: 'positive',
293
+ currentPageValue: 0.5,
294
+ positive: {
295
+ data: {
296
+ x: [0.5]
297
+ }
298
+ }
299
+ },
300
+ ms: {
301
+ positive: {
302
+ pageValues: [0.5],
303
+ peaks: [null]
304
+ }
305
+ }
306
+ };
307
+ expect((0, _peaks.getLcmsMzPageData)(hplcMsSt)).toBeNull();
308
+ });
309
+ });
310
+ });
@@ -10,9 +10,12 @@ const selectCurve = payload => ({
10
10
  payload
11
11
  });
12
12
  exports.selectCurve = selectCurve;
13
- const setAllCurves = payload => ({
13
+ const setAllCurves = (payload, meta) => ({
14
14
  type: _action_type.CURVE.SET_ALL_CURVES,
15
- payload
15
+ payload,
16
+ ...(meta && typeof meta === 'object' ? {
17
+ meta
18
+ } : {})
16
19
  });
17
20
  exports.setAllCurves = setAllCurves;
18
21
  const toggleShowAllCurves = payload => ({
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.uvvisUndo = exports.uvvisRedo = exports.updateCurrentPageValue = exports.setLcmsIntegrationsExport = exports.selectWavelength = exports.clearIntegrationAllHplcMs = exports.clearHplcMsState = exports.clearAllPeaksHplcMs = exports.changeTic = void 0;
7
+ var _action_type = require("../constants/action_type");
8
+ const normalizeTicPolarity = value => {
9
+ if (value === 0 || value === '0') return 'positive';
10
+ if (value === 1 || value === '1') return 'negative';
11
+ if (value === 2 || value === '2') return 'neutral';
12
+ if (value === 'positive' || value === 'negative' || value === 'neutral') return value;
13
+ return 'positive';
14
+ };
15
+ const setLcmsIntegrationsExport = lcmsIntegrationsExport => ({
16
+ type: _action_type.HPLC_MS.SET_LCMS_INTEGRATIONS_EXPORT,
17
+ payload: {
18
+ lcmsIntegrationsExport
19
+ }
20
+ });
21
+ exports.setLcmsIntegrationsExport = setLcmsIntegrationsExport;
22
+ const selectWavelength = payload => ({
23
+ type: _action_type.HPLC_MS.UPDATE_UVVIS_WAVE_LENGTH,
24
+ payload
25
+ });
26
+ exports.selectWavelength = selectWavelength;
27
+ const changeTic = payload => {
28
+ const rawValue = payload?.target?.value ?? payload?.polarity ?? 'positive';
29
+ const polarity = normalizeTicPolarity(rawValue);
30
+ return {
31
+ type: _action_type.HPLC_MS.SELECT_TIC_CURVE,
32
+ payload: {
33
+ polarity
34
+ }
35
+ };
36
+ };
37
+ exports.changeTic = changeTic;
38
+ const updateCurrentPageValue = currentPageValue => ({
39
+ type: _action_type.HPLC_MS.UPDATE_CURRENT_PAGE_VALUE,
40
+ payload: {
41
+ currentPageValue
42
+ }
43
+ });
44
+ exports.updateCurrentPageValue = updateCurrentPageValue;
45
+ const uvvisUndo = () => ({
46
+ type: _action_type.HPLC_MS.UVVIS_UNDO
47
+ });
48
+ exports.uvvisUndo = uvvisUndo;
49
+ const uvvisRedo = () => ({
50
+ type: _action_type.HPLC_MS.UVVIS_REDO
51
+ });
52
+ exports.uvvisRedo = uvvisRedo;
53
+ const clearIntegrationAllHplcMs = payload => ({
54
+ type: _action_type.HPLC_MS.CLEAR_INTEGRATION_ALL_HPLCMS,
55
+ payload
56
+ });
57
+ exports.clearIntegrationAllHplcMs = clearIntegrationAllHplcMs;
58
+ const clearAllPeaksHplcMs = payload => ({
59
+ type: _action_type.HPLC_MS.CLEAR_ALL_PEAKS_HPLCMS,
60
+ payload
61
+ });
62
+ exports.clearAllPeaksHplcMs = clearAllPeaksHplcMs;
63
+ const clearHplcMsState = () => ({
64
+ type: _action_type.HPLC_MS.CLEAR_STATE
65
+ });
66
+ exports.clearHplcMsState = clearHplcMsState;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.sweepIntegration = exports.setIntegrationFkr = exports.clearIntegrationAll = void 0;
6
+ exports.sweepIntegration = exports.splitIntegration = exports.setIntegrationFkr = exports.removeVisualSplitLine = exports.clearIntegrationAll = exports.addVisualSplitLine = void 0;
7
7
  var _action_type = require("../constants/action_type");
8
8
  const sweepIntegration = payload => ({
9
9
  type: _action_type.INTEGRATION.SWEEP,
@@ -19,6 +19,21 @@ const clearIntegrationAll = payload => ({
19
19
  type: _action_type.INTEGRATION.CLEAR_ALL,
20
20
  payload
21
21
  });
22
+ exports.clearIntegrationAll = clearIntegrationAll;
23
+ const splitIntegration = payload => ({
24
+ type: _action_type.INTEGRATION.SPLIT,
25
+ payload
26
+ });
27
+ exports.splitIntegration = splitIntegration;
28
+ const addVisualSplitLine = payload => ({
29
+ type: _action_type.INTEGRATION.ADD_VISUAL_SPLIT,
30
+ payload
31
+ });
32
+ exports.addVisualSplitLine = addVisualSplitLine;
33
+ const removeVisualSplitLine = payload => ({
34
+ type: _action_type.INTEGRATION.RM_VISUAL_SPLIT,
35
+ payload
36
+ });
22
37
 
23
38
  // eslint-disable-line
24
- exports.clearIntegrationAll = clearIntegrationAll;
39
+ exports.removeVisualSplitLine = removeVisualSplitLine;
@@ -3,18 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setUiViewerType = exports.setUiSweepType = exports.selectUiSweep = exports.scrollUiWheel = exports.clickUiTarget = void 0;
6
+ exports.setUiViewerType = exports.setUiSweepType = exports.selectUiSweep = exports.scrollUiWheel = exports.displaySubViewerAt = exports.clickUiTarget = void 0;
7
7
  var _action_type = require("../constants/action_type");
8
- const setUiViewerType = payload => ({
9
- type: _action_type.UI.VIEWER.SET_TYPE,
10
- payload
11
- });
12
- exports.setUiViewerType = setUiViewerType;
13
- const setUiSweepType = (payload, jcampIdx = 0) => ({
8
+ var _list_ui = require("../constants/list_ui");
9
+ var _integration_draft = require("../helpers/integration_draft.js");
10
+ // eslint-disable-line import/extensions
11
+
12
+ const keepIntegrationMode = (jcampIdx = 0) => ({
14
13
  type: _action_type.UI.SWEEP.SET_TYPE,
15
- payload,
14
+ payload: _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_ADD,
16
15
  jcampIdx
17
16
  });
17
+ const setUiViewerType = payload => {
18
+ if (!(0, _integration_draft.confirmCancelPendingIntegration)()) {
19
+ return keepIntegrationMode();
20
+ }
21
+ return {
22
+ type: _action_type.UI.VIEWER.SET_TYPE,
23
+ payload
24
+ };
25
+ };
26
+ exports.setUiViewerType = setUiViewerType;
27
+ const setUiSweepType = (payload, jcampIdx = 0) => {
28
+ if (payload !== _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_ADD && !(0, _integration_draft.confirmCancelPendingIntegration)()) {
29
+ return keepIntegrationMode(jcampIdx);
30
+ }
31
+ return {
32
+ type: _action_type.UI.SWEEP.SET_TYPE,
33
+ payload,
34
+ jcampIdx
35
+ };
36
+ };
18
37
  exports.setUiSweepType = setUiSweepType;
19
38
  const selectUiSweep = payload => ({
20
39
  type: _action_type.UI.SWEEP.SELECT,
@@ -26,12 +45,21 @@ const scrollUiWheel = payload => ({
26
45
  payload
27
46
  });
28
47
  exports.scrollUiWheel = scrollUiWheel;
29
- const clickUiTarget = (payload, onPeak, voltammetryPeakIdx = 0, jcampIdx = 0, onPecker = false) => ({
48
+ const clickUiTarget = (payload, onPeak, voltammetryPeakIdx = 0, jcampIdx = 0, onPecker = false, sourceHint = null) => ({
30
49
  type: _action_type.UI.CLICK_TARGET,
31
50
  payload,
32
51
  onPeak,
33
52
  voltammetryPeakIdx,
34
53
  jcampIdx,
35
- onPecker
54
+ onPecker,
55
+ sourceHint
56
+ });
57
+ exports.clickUiTarget = clickUiTarget;
58
+ const displaySubViewerAt = payload => ({
59
+ type: _action_type.UI.SUB_VIEWER.DISPLAY_VIEWER_AT,
60
+ payload: payload == null ? {
61
+ x: null,
62
+ y: null
63
+ } : payload
36
64
  });
37
- exports.clickUiTarget = clickUiTarget;
65
+ exports.displaySubViewerAt = displaySubViewerAt;
package/dist/app.js CHANGED
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "FN", {
10
10
  return _fn.default;
11
11
  }
12
12
  });
13
- exports.SpectraEditor = void 0;
13
+ exports.store = exports.SpectraEditor = void 0;
14
14
  var _react = _interopRequireDefault(require("react"));
15
15
  var _reactRedux = require("react-redux");
16
16
  var _redux = require("redux");
@@ -33,8 +33,13 @@ var _jsxRuntime = require("react/jsx-runtime");
33
33
  const sagaMiddleware = (0, _reduxSaga.default)();
34
34
  const middlewares = [sagaMiddleware]; // logger
35
35
 
36
- const store = (0, _redux.compose)((0, _redux.applyMiddleware)(...middlewares))(_redux.createStore)(_index.default);
37
- sagaMiddleware.run(_index2.default);
36
+ const store = exports.store = (0, _redux.compose)((0, _redux.applyMiddleware)(...middlewares))(_redux.createStore)(_index.default);
37
+ try {
38
+ sagaMiddleware.run(_index2.default);
39
+ } catch (error) {
40
+ // Keep startup failure visible without crashing silently.
41
+ console.error('[SpectraEditor] Failed to start sagas', error); // eslint-disable-line no-console
42
+ }
38
43
 
39
44
  // - - - helper - - -
40
45
  const ensureQuillDelta = descs => {
@@ -45,6 +50,10 @@ const ensureQuillDelta = descs => {
45
50
  };
46
51
 
47
52
  // - - - React - - -
53
+ // LC/MS: when `onLcmsPageRequest` is set, the host (e.g. ELN) must reload `multiEntities`
54
+ // with MS data for the requested RT/polarity. Triggers include `user_click`, `initial`,
55
+ // and `tic_polarity` (TIC polarity dropdown). The standalone demo in `src/index.js`
56
+ // implements a local mock via `buildLcmsStandaloneMultiEntities`.
48
57
  const SpectraEditor = ({
49
58
  entity,
50
59
  others,
@@ -62,7 +71,8 @@ const SpectraEditor = ({
62
71
  multiEntities,
63
72
  multiMolSvgs,
64
73
  entityFileNames,
65
- userManualLink
74
+ userManualLink,
75
+ onLcmsPageRequest
66
76
  }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactRedux.Provider, {
67
77
  store: store,
68
78
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.StyledEngineProvider, {
@@ -84,7 +94,8 @@ const SpectraEditor = ({
84
94
  editorOnly: editorOnly,
85
95
  exactMass: exactMass,
86
96
  canChangeDescription: canChangeDescription,
87
- onDescriptionChanged: onDescriptionChanged
97
+ onDescriptionChanged: onDescriptionChanged,
98
+ onLcmsPageRequest: onLcmsPageRequest
88
99
  })
89
100
  })
90
101
  });
@@ -105,6 +116,7 @@ SpectraEditor.propTypes = {
105
116
  editorOnly: _propTypes.default.bool,
106
117
  canChangeDescription: _propTypes.default.bool,
107
118
  onDescriptionChanged: _propTypes.default.func,
119
+ onLcmsPageRequest: _propTypes.default.func,
108
120
  userManualLink: _propTypes.default.object,
109
121
  exactMass: _propTypes.default.string
110
122
  };
@@ -113,8 +125,8 @@ SpectraEditor.defaultProps = {
113
125
  others: [],
114
126
  addOthersCb: false
115
127
  },
116
- multiEntities: false,
117
- entityFileNames: false,
128
+ multiEntities: [],
129
+ entityFileNames: [],
118
130
  cLabel: '',
119
131
  xLabel: '',
120
132
  yLabel: '',
@@ -126,5 +138,6 @@ SpectraEditor.defaultProps = {
126
138
  multiMolSvgs: [],
127
139
  editorOnly: false,
128
140
  canChangeDescription: false,
129
- userManualLink: {}
141
+ userManualLink: {},
142
+ onLcmsPageRequest: null
130
143
  };
@@ -40,11 +40,13 @@ const Viewer = ({
40
40
  className: "txt-sv-tp",
41
41
  children: "Spectrum Viewer"
42
42
  }),
43
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.MuButton, {
44
- className: (0, _classnames.default)((0, _common.focusStyle)(isfocusSpectrumSt, classes), 'btn-sv-bar-spctrum'),
45
- onClick: onViewSpectrum,
46
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TimelineOutlined.default, {
47
- className: classes.icon
43
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
44
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.MuButton, {
45
+ className: (0, _classnames.default)((0, _common.focusStyle)(isfocusSpectrumSt, classes), 'btn-sv-bar-spctrum'),
46
+ onClick: onViewSpectrum,
47
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_TimelineOutlined.default, {
48
+ className: classes.icon
49
+ })
48
50
  })
49
51
  })
50
52
  }), hideCmdAnaViewerSt ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, {
@@ -52,12 +54,14 @@ const Viewer = ({
52
54
  className: "txt-sv-tp",
53
55
  children: "Analysis Viewer"
54
56
  }),
55
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.MuButton, {
56
- className: (0, _classnames.default)((0, _common.focusStyle)(isfocusAnalysisSt, classes), 'btn-sv-bar-analysis'),
57
- disabled: disableCmdAnaViewerSt,
58
- onClick: onViewAnalysis,
59
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpellcheckOutlined.default, {
60
- className: classes.icon
57
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
58
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_common.MuButton, {
59
+ className: (0, _classnames.default)((0, _common.focusStyle)(isfocusAnalysisSt, classes), 'btn-sv-bar-analysis'),
60
+ disabled: disableCmdAnaViewerSt,
61
+ onClick: onViewAnalysis,
62
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_SpellcheckOutlined.default, {
63
+ className: classes.icon
64
+ })
61
65
  })
62
66
  })
63
67
  })]