@complat/react-spectra-editor 0.11.3 → 0.11.4-beta.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.
@@ -0,0 +1,488 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _effects = require('redux-saga/effects');
8
+
9
+ var _action_type = require('../constants/action_type');
10
+
11
+ var _list_ui = require('../constants/list_ui');
12
+
13
+ var _list_layout = require('../constants/list_layout');
14
+
15
+ var _marked = /*#__PURE__*/regeneratorRuntime.mark(selectUiSweep),
16
+ _marked2 = /*#__PURE__*/regeneratorRuntime.mark(scrollUiWheel),
17
+ _marked3 = /*#__PURE__*/regeneratorRuntime.mark(clickUiTarget);
18
+
19
+ var getUiSt = function getUiSt(state) {
20
+ return state.ui;
21
+ };
22
+
23
+ var calcPeaks = function calcPeaks(payload) {
24
+ var xExtent = payload.xExtent,
25
+ yExtent = payload.yExtent,
26
+ dataPks = payload.dataPks;
27
+
28
+ if (!dataPks) return [];
29
+ var xL = xExtent.xL,
30
+ xU = xExtent.xU;
31
+ var yL = yExtent.yL,
32
+ yU = yExtent.yU;
33
+
34
+ var peaks = dataPks.filter(function (p) {
35
+ return xL <= p.x && p.x <= xU && yL <= p.y && p.y <= yU;
36
+ });
37
+ return peaks;
38
+ };
39
+
40
+ function selectUiSweep(action) {
41
+ var uiSt, payload, peaks, newPayload;
42
+ return regeneratorRuntime.wrap(function selectUiSweep$(_context) {
43
+ while (1) {
44
+ switch (_context.prev = _context.next) {
45
+ case 0:
46
+ _context.next = 2;
47
+ return (0, _effects.select)(getUiSt);
48
+
49
+ case 2:
50
+ uiSt = _context.sent;
51
+ payload = action.payload;
52
+ _context.t0 = uiSt.sweepType;
53
+ _context.next = _context.t0 === _list_ui.LIST_UI_SWEEP_TYPE.ZOOMIN ? 7 : _context.t0 === _list_ui.LIST_UI_SWEEP_TYPE.ZOOMRESET ? 10 : _context.t0 === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_ADD ? 13 : _context.t0 === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_SWEEP_ADD ? 16 : 25;
54
+ break;
55
+
56
+ case 7:
57
+ _context.next = 9;
58
+ return (0, _effects.put)({
59
+ type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
60
+ payload: payload
61
+ });
62
+
63
+ case 9:
64
+ return _context.abrupt('break', 26);
65
+
66
+ case 10:
67
+ _context.next = 12;
68
+ return (0, _effects.put)({
69
+ type: _action_type.UI.SWEEP.SELECT_ZOOMRESET,
70
+ payload: payload
71
+ });
72
+
73
+ case 12:
74
+ return _context.abrupt('break', 26);
75
+
76
+ case 13:
77
+ _context.next = 15;
78
+ return (0, _effects.put)({
79
+ type: _action_type.UI.SWEEP.SELECT_INTEGRATION,
80
+ payload: payload
81
+ });
82
+
83
+ case 15:
84
+ return _context.abrupt('break', 26);
85
+
86
+ case 16:
87
+ peaks = calcPeaks(payload); // eslint-disable-line
88
+
89
+ if (!(peaks.length === 0)) {
90
+ _context.next = 19;
91
+ break;
92
+ }
93
+
94
+ return _context.abrupt('break', 26);
95
+
96
+ case 19:
97
+ newPayload = Object.assign({}, payload, { peaks: peaks }); // eslint-disable-line
98
+
99
+ _context.next = 22;
100
+ return (0, _effects.put)({
101
+ type: _action_type.UI.SWEEP.SELECT_INTEGRATION,
102
+ payload: newPayload
103
+ });
104
+
105
+ case 22:
106
+ _context.next = 24;
107
+ return (0, _effects.put)({
108
+ type: _action_type.UI.SWEEP.SELECT_MULTIPLICITY,
109
+ payload: newPayload
110
+ });
111
+
112
+ case 24:
113
+ return _context.abrupt('break', 26);
114
+
115
+ case 25:
116
+ return _context.abrupt('break', 26);
117
+
118
+ case 26:
119
+ return _context.abrupt('return', null);
120
+
121
+ case 27:
122
+ case 'end':
123
+ return _context.stop();
124
+ }
125
+ }
126
+ }, _marked);
127
+ }
128
+
129
+ var getLayoutSt = function getLayoutSt(state) {
130
+ return state.layout;
131
+ };
132
+
133
+ function scrollUiWheel(action) {
134
+ var layoutSt, payload, xExtent, yExtent, direction, yL, yU, yeL, yeU, scale, nextExtent, nyeL, nyeU, h, nytL, nytU;
135
+ return regeneratorRuntime.wrap(function scrollUiWheel$(_context2) {
136
+ while (1) {
137
+ switch (_context2.prev = _context2.next) {
138
+ case 0:
139
+ _context2.next = 2;
140
+ return (0, _effects.select)(getLayoutSt);
141
+
142
+ case 2:
143
+ layoutSt = _context2.sent;
144
+ payload = action.payload;
145
+ xExtent = payload.xExtent, yExtent = payload.yExtent, direction = payload.direction;
146
+ yL = yExtent.yL, yU = yExtent.yU;
147
+ yeL = yL + (yU - yL) * 0.1, yeU = yU - (yU - yL) * 0.1;
148
+ scale = direction ? 0.8 : 1.25;
149
+ nextExtent = { xExtent: false, yExtent: false };
150
+ nyeL = 0, nyeU = 1, h = 1, nytL = 0, nytU = 1;
151
+ _context2.t0 = layoutSt;
152
+ _context2.next = _context2.t0 === _list_layout.LIST_LAYOUT.IR ? 13 : _context2.t0 === _list_layout.LIST_LAYOUT.RAMAN ? 13 : _context2.t0 === _list_layout.LIST_LAYOUT.MS ? 20 : _context2.t0 === _list_layout.LIST_LAYOUT.UVVIS ? 27 : _context2.t0 === _list_layout.LIST_LAYOUT.HPLC_UVVIS ? 27 : _context2.t0 === _list_layout.LIST_LAYOUT.TGA ? 27 : _context2.t0 === _list_layout.LIST_LAYOUT.XRD ? 27 : 27;
153
+ break;
154
+
155
+ case 13:
156
+ nyeL = yeL + (yeU - yeL) * (1 - scale);
157
+ nyeU = yeU;
158
+
159
+ h = nyeU - nyeL;
160
+ nytL = nyeL - 0.125 * h;
161
+ nytU = nyeU + 0.125 * h;
162
+
163
+ nextExtent = { xExtent: xExtent, yExtent: { yL: nytL, yU: nytU } };
164
+ return _context2.abrupt('break', 34);
165
+
166
+ case 20:
167
+ nyeL = 0;
168
+ nyeU = yeL + (yeU - yeL) * scale;
169
+
170
+ h = nyeU - nyeL;
171
+ nytL = nyeL - 0.125 * h;
172
+ nytU = nyeU + 0.125 * h;
173
+
174
+ nextExtent = { xExtent: xExtent, yExtent: { yL: nytL, yU: nytU } };
175
+ return _context2.abrupt('break', 34);
176
+
177
+ case 27:
178
+ nyeL = yeL;
179
+ nyeU = yeL + (yeU - yeL) * scale;
180
+
181
+ h = nyeU - nyeL;
182
+ nytL = nyeL - 0.125 * h;
183
+ nytU = nyeU + 0.125 * h;
184
+
185
+ nextExtent = { xExtent: xExtent, yExtent: { yL: nytL, yU: nytU } };
186
+ return _context2.abrupt('break', 34);
187
+
188
+ case 34:
189
+ _context2.next = 36;
190
+ return (0, _effects.put)({
191
+ type: _action_type.UI.SWEEP.SELECT_ZOOMIN,
192
+ payload: nextExtent
193
+ });
194
+
195
+ case 36:
196
+ case 'end':
197
+ return _context2.stop();
198
+ }
199
+ }
200
+ }, _marked2);
201
+ }
202
+
203
+ var getUiSweepType = function getUiSweepType(state) {
204
+ return state.ui.sweepType;
205
+ };
206
+
207
+ function clickUiTarget(action) {
208
+ var payload, onPeak, voltammetryPeakIdx, onPecker, jcampIdx, uiSweepType, xExtent, xL, xU;
209
+ return regeneratorRuntime.wrap(function clickUiTarget$(_context3) {
210
+ while (1) {
211
+ switch (_context3.prev = _context3.next) {
212
+ case 0:
213
+ payload = action.payload, onPeak = action.onPeak, voltammetryPeakIdx = action.voltammetryPeakIdx, onPecker = action.onPecker, jcampIdx = action.jcampIdx;
214
+ _context3.next = 3;
215
+ return (0, _effects.select)(getUiSweepType);
216
+
217
+ case 3:
218
+ uiSweepType = _context3.sent;
219
+
220
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_ADD && !onPeak)) {
221
+ _context3.next = 9;
222
+ break;
223
+ }
224
+
225
+ _context3.next = 7;
226
+ return (0, _effects.put)({
227
+ type: _action_type.EDITPEAK.ADD_POSITIVE,
228
+ payload: payload
229
+ });
230
+
231
+ case 7:
232
+ _context3.next = 84;
233
+ break;
234
+
235
+ case 9:
236
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.PEAK_DELETE && onPeak)) {
237
+ _context3.next = 14;
238
+ break;
239
+ }
240
+
241
+ _context3.next = 12;
242
+ return (0, _effects.put)({
243
+ type: _action_type.EDITPEAK.ADD_NEGATIVE,
244
+ payload: payload
245
+ });
246
+
247
+ case 12:
248
+ _context3.next = 84;
249
+ break;
250
+
251
+ case 14:
252
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.ANCHOR_SHIFT && onPeak)) {
253
+ _context3.next = 19;
254
+ break;
255
+ }
256
+
257
+ _context3.next = 17;
258
+ return (0, _effects.put)({
259
+ type: _action_type.SHIFT.SET_PEAK,
260
+ payload: payload
261
+ });
262
+
263
+ case 17:
264
+ _context3.next = 84;
265
+ break;
266
+
267
+ case 19:
268
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_RM && onPeak)) {
269
+ _context3.next = 24;
270
+ break;
271
+ }
272
+
273
+ _context3.next = 22;
274
+ return (0, _effects.put)({
275
+ type: _action_type.INTEGRATION.RM_ONE,
276
+ payload: payload
277
+ });
278
+
279
+ case 22:
280
+ _context3.next = 84;
281
+ break;
282
+
283
+ case 24:
284
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_ONE_RM && onPeak)) {
285
+ _context3.next = 29;
286
+ break;
287
+ }
288
+
289
+ _context3.next = 27;
290
+ return (0, _effects.put)({
291
+ type: _action_type.INTEGRATION.RM_ONE,
292
+ payload: payload
293
+ });
294
+
295
+ case 27:
296
+ _context3.next = 84;
297
+ break;
298
+
299
+ case 29:
300
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.INTEGRATION_SET_REF && onPeak)) {
301
+ _context3.next = 34;
302
+ break;
303
+ }
304
+
305
+ _context3.next = 32;
306
+ return (0, _effects.put)({
307
+ type: _action_type.INTEGRATION.SET_REF,
308
+ payload: payload
309
+ });
310
+
311
+ case 32:
312
+ _context3.next = 84;
313
+ break;
314
+
315
+ case 34:
316
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_ONE_CLICK && onPeak)) {
317
+ _context3.next = 46;
318
+ break;
319
+ }
320
+
321
+ xExtent = payload.xExtent, xL = payload.xL, xU = payload.xU;
322
+
323
+ if (!xExtent) {
324
+ _context3.next = 41;
325
+ break;
326
+ }
327
+
328
+ _context3.next = 39;
329
+ return (0, _effects.put)({
330
+ type: _action_type.MULTIPLICITY.ONE_CLICK_BY_UI,
331
+ payload: xExtent
332
+ });
333
+
334
+ case 39:
335
+ _context3.next = 44;
336
+ break;
337
+
338
+ case 41:
339
+ if (!(xL && xU)) {
340
+ _context3.next = 44;
341
+ break;
342
+ }
343
+
344
+ _context3.next = 44;
345
+ return (0, _effects.put)({
346
+ type: _action_type.MULTIPLICITY.ONE_CLICK_BY_UI,
347
+ payload: { xL: xL, xU: xU }
348
+ });
349
+
350
+ case 44:
351
+ _context3.next = 84;
352
+ break;
353
+
354
+ case 46:
355
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_PEAK_ADD)) {
356
+ _context3.next = 51;
357
+ break;
358
+ }
359
+
360
+ _context3.next = 49;
361
+ return (0, _effects.put)({
362
+ type: _action_type.MULTIPLICITY.PEAK_ADD_BY_UI_SAG,
363
+ payload: payload
364
+ });
365
+
366
+ case 49:
367
+ _context3.next = 84;
368
+ break;
369
+
370
+ case 51:
371
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.MULTIPLICITY_PEAK_RM && onPeak)) {
372
+ _context3.next = 56;
373
+ break;
374
+ }
375
+
376
+ _context3.next = 54;
377
+ return (0, _effects.put)({
378
+ type: _action_type.MULTIPLICITY.PEAK_RM_BY_UI,
379
+ payload: payload
380
+ });
381
+
382
+ case 54:
383
+ _context3.next = 84;
384
+ break;
385
+
386
+ case 56:
387
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.CYCLIC_VOLTA_ADD_MAX_PEAK && !onPeak)) {
388
+ _context3.next = 61;
389
+ break;
390
+ }
391
+
392
+ _context3.next = 59;
393
+ return (0, _effects.put)({
394
+ type: _action_type.CYCLIC_VOLTA_METRY.ADD_MAX_PEAK,
395
+ payload: { peak: payload, index: voltammetryPeakIdx, jcampIdx: jcampIdx }
396
+ });
397
+
398
+ case 59:
399
+ _context3.next = 84;
400
+ break;
401
+
402
+ case 61:
403
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.CYCLIC_VOLTA_RM_MAX_PEAK && onPeak)) {
404
+ _context3.next = 66;
405
+ break;
406
+ }
407
+
408
+ _context3.next = 64;
409
+ return (0, _effects.put)({
410
+ type: _action_type.CYCLIC_VOLTA_METRY.REMOVE_MAX_PEAK,
411
+ payload: { index: voltammetryPeakIdx, jcampIdx: jcampIdx }
412
+ });
413
+
414
+ case 64:
415
+ _context3.next = 84;
416
+ break;
417
+
418
+ case 66:
419
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.CYCLIC_VOLTA_ADD_MIN_PEAK && !onPeak)) {
420
+ _context3.next = 71;
421
+ break;
422
+ }
423
+
424
+ _context3.next = 69;
425
+ return (0, _effects.put)({
426
+ type: _action_type.CYCLIC_VOLTA_METRY.ADD_MIN_PEAK,
427
+ payload: { peak: payload, index: voltammetryPeakIdx, jcampIdx: jcampIdx }
428
+ });
429
+
430
+ case 69:
431
+ _context3.next = 84;
432
+ break;
433
+
434
+ case 71:
435
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.CYCLIC_VOLTA_RM_MIN_PEAK && onPeak)) {
436
+ _context3.next = 76;
437
+ break;
438
+ }
439
+
440
+ _context3.next = 74;
441
+ return (0, _effects.put)({
442
+ type: _action_type.CYCLIC_VOLTA_METRY.REMOVE_MIN_PEAK,
443
+ payload: { index: voltammetryPeakIdx, jcampIdx: jcampIdx }
444
+ });
445
+
446
+ case 74:
447
+ _context3.next = 84;
448
+ break;
449
+
450
+ case 76:
451
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.CYCLIC_VOLTA_ADD_PECKER && !onPecker)) {
452
+ _context3.next = 81;
453
+ break;
454
+ }
455
+
456
+ _context3.next = 79;
457
+ return (0, _effects.put)({
458
+ type: _action_type.CYCLIC_VOLTA_METRY.ADD_PECKER,
459
+ payload: { peak: payload, index: voltammetryPeakIdx, jcampIdx: jcampIdx }
460
+ });
461
+
462
+ case 79:
463
+ _context3.next = 84;
464
+ break;
465
+
466
+ case 81:
467
+ if (!(uiSweepType === _list_ui.LIST_UI_SWEEP_TYPE.CYCLIC_VOLTA_RM_PECKER && onPecker)) {
468
+ _context3.next = 84;
469
+ break;
470
+ }
471
+
472
+ _context3.next = 84;
473
+ return (0, _effects.put)({
474
+ type: _action_type.CYCLIC_VOLTA_METRY.REMOVE_PECKER,
475
+ payload: { index: voltammetryPeakIdx, jcampIdx: jcampIdx }
476
+ });
477
+
478
+ case 84:
479
+ case 'end':
480
+ return _context3.stop();
481
+ }
482
+ }
483
+ }, _marked3);
484
+ }
485
+
486
+ var 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)];
487
+
488
+ exports.default = managerSagas;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@complat/react-spectra-editor",
3
- "version": "0.11.3",
3
+ "version": "0.11.4-beta.0",
4
4
  "description": "An editor to View and Edit Chemical Spectra data (NMR, IR and MS).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,7 +8,7 @@
8
8
  },
9
9
  "license": "AGPL-3.0",
10
10
  "dependencies": {
11
- "@complat/react-svg-file-zoom-pan": "^1.0.11",
11
+ "@complat/react-svg-file-zoom-pan": "1.0.15-alpha.1",
12
12
  "@material-ui/core": "^4.10.0",
13
13
  "@material-ui/icons": "^4.10.0",
14
14
  "@mdi/js": "^4.7.95",
@@ -22,6 +22,7 @@
22
22
  "d3-brush": "2.1.0",
23
23
  "d3-selection": "^2.0.0",
24
24
  "d3-tip": "^0.9.1",
25
+ "d3-zoom": "^3.0.0",
25
26
  "jcampconverter": "4.1.0",
26
27
  "ml-savitzky-golay-generalized": "1.1.1",
27
28
  "prop-types": "^15.7.2",