@complat/react-spectra-editor 0.10.13-alpha.5

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 (109) hide show
  1. package/LICENSE +662 -0
  2. package/README.md +37 -0
  3. package/dist/actions/edit_peak.js +25 -0
  4. package/dist/actions/forecast.js +41 -0
  5. package/dist/actions/integration.js +33 -0
  6. package/dist/actions/jcamp.js +41 -0
  7. package/dist/actions/layout.js +17 -0
  8. package/dist/actions/manager.js +49 -0
  9. package/dist/actions/meta.js +17 -0
  10. package/dist/actions/multiplicity.js +57 -0
  11. package/dist/actions/scan.js +33 -0
  12. package/dist/actions/shift.js +25 -0
  13. package/dist/actions/status.js +33 -0
  14. package/dist/actions/submit.js +41 -0
  15. package/dist/actions/threshold.js +33 -0
  16. package/dist/actions/ui.js +50 -0
  17. package/dist/app.js +125 -0
  18. package/dist/components/cmd_bar/01_viewer.js +133 -0
  19. package/dist/components/cmd_bar/02_zoom.js +119 -0
  20. package/dist/components/cmd_bar/03_peak.js +176 -0
  21. package/dist/components/cmd_bar/04_integration.js +273 -0
  22. package/dist/components/cmd_bar/05_multiplicity.js +228 -0
  23. package/dist/components/cmd_bar/06_undo_redo.js +137 -0
  24. package/dist/components/cmd_bar/common.js +104 -0
  25. package/dist/components/cmd_bar/index.js +113 -0
  26. package/dist/components/cmd_bar/r01_layout.js +351 -0
  27. package/dist/components/cmd_bar/r02_scan.js +226 -0
  28. package/dist/components/cmd_bar/r03_threshold.js +209 -0
  29. package/dist/components/cmd_bar/r04_submit.js +349 -0
  30. package/dist/components/cmd_bar/r05_submit_btn.js +147 -0
  31. package/dist/components/cmd_bar/r06_predict_btn.js +307 -0
  32. package/dist/components/cmd_bar/tri_btn.js +202 -0
  33. package/dist/components/common/chem.js +115 -0
  34. package/dist/components/common/comps.js +29 -0
  35. package/dist/components/common/draw.js +41 -0
  36. package/dist/components/d3_line/index.js +236 -0
  37. package/dist/components/d3_line/line_focus.js +765 -0
  38. package/dist/components/d3_rect/index.js +200 -0
  39. package/dist/components/d3_rect/rect_focus.js +301 -0
  40. package/dist/components/forecast/comps.js +337 -0
  41. package/dist/components/forecast/ir_comps.js +224 -0
  42. package/dist/components/forecast/ir_viewer.js +172 -0
  43. package/dist/components/forecast/nmr_comps.js +253 -0
  44. package/dist/components/forecast/nmr_viewer.js +170 -0
  45. package/dist/components/forecast/section_loading.js +95 -0
  46. package/dist/components/forecast_viewer.js +190 -0
  47. package/dist/components/panel/compare.js +370 -0
  48. package/dist/components/panel/index.js +191 -0
  49. package/dist/components/panel/info.js +335 -0
  50. package/dist/components/panel/multiplicity.js +405 -0
  51. package/dist/components/panel/multiplicity_coupling.js +195 -0
  52. package/dist/components/panel/multiplicity_select.js +114 -0
  53. package/dist/components/panel/peaks.js +296 -0
  54. package/dist/constants/action_type.js +140 -0
  55. package/dist/constants/list_layout.js +23 -0
  56. package/dist/constants/list_shift.js +480 -0
  57. package/dist/constants/list_ui.js +33 -0
  58. package/dist/fn.js +31 -0
  59. package/dist/helpers/brush.js +109 -0
  60. package/dist/helpers/calc.js +10 -0
  61. package/dist/helpers/carbonFeatures.js +47 -0
  62. package/dist/helpers/cfg.js +89 -0
  63. package/dist/helpers/chem.js +594 -0
  64. package/dist/helpers/compass.js +91 -0
  65. package/dist/helpers/converter.js +74 -0
  66. package/dist/helpers/extractParams.js +77 -0
  67. package/dist/helpers/extractPeaksEdit.js +69 -0
  68. package/dist/helpers/focus.js +15 -0
  69. package/dist/helpers/format.js +403 -0
  70. package/dist/helpers/init.js +80 -0
  71. package/dist/helpers/integration.js +30 -0
  72. package/dist/helpers/mount.js +112 -0
  73. package/dist/helpers/multiplicity.js +44 -0
  74. package/dist/helpers/multiplicity_calc.js +117 -0
  75. package/dist/helpers/multiplicity_complat.js +126 -0
  76. package/dist/helpers/multiplicity_manual.js +94 -0
  77. package/dist/helpers/multiplicity_verify_basic.js +196 -0
  78. package/dist/helpers/shift.js +48 -0
  79. package/dist/helpers/zoom.js +32 -0
  80. package/dist/index.js +705 -0
  81. package/dist/layer_content.js +125 -0
  82. package/dist/layer_init.js +231 -0
  83. package/dist/layer_prism.js +186 -0
  84. package/dist/reducers/index.js +89 -0
  85. package/dist/reducers/reducer_edit_peak.js +111 -0
  86. package/dist/reducers/reducer_forecast.js +113 -0
  87. package/dist/reducers/reducer_integration.js +136 -0
  88. package/dist/reducers/reducer_jcamp.js +74 -0
  89. package/dist/reducers/reducer_layout.js +27 -0
  90. package/dist/reducers/reducer_manager.js +20 -0
  91. package/dist/reducers/reducer_meta.js +30 -0
  92. package/dist/reducers/reducer_multiplicity.js +131 -0
  93. package/dist/reducers/reducer_scan.js +55 -0
  94. package/dist/reducers/reducer_shift.js +99 -0
  95. package/dist/reducers/reducer_simulation.js +30 -0
  96. package/dist/reducers/reducer_status.js +41 -0
  97. package/dist/reducers/reducer_submit.js +54 -0
  98. package/dist/reducers/reducer_threshold.js +34 -0
  99. package/dist/reducers/reducer_ui.js +46 -0
  100. package/dist/reducers/undo_redo_config.js +24 -0
  101. package/dist/sagas/index.js +50 -0
  102. package/dist/sagas/saga_edit_peak.js +84 -0
  103. package/dist/sagas/saga_manager.js +116 -0
  104. package/dist/sagas/saga_meta.js +46 -0
  105. package/dist/sagas/saga_multiplicity.js +387 -0
  106. package/dist/sagas/saga_ui.js +392 -0
  107. package/dist/third_party/jAnalyzer.js +596 -0
  108. package/dist/third_party/peakInterval.js +107 -0
  109. package/package.json +77 -0
@@ -0,0 +1,91 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MouseMove = exports.ClickCompass = exports.TfRescale = exports.MountCompass = undefined;
7
+
8
+ var _d = require('d3');
9
+
10
+ var d3 = _interopRequireWildcard(_d);
11
+
12
+ function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
13
+
14
+ var TfRescale = function TfRescale(focus) {
15
+ var xt = focus.scales.x;
16
+ var yt = focus.scales.y;
17
+ return { xt: xt, yt: yt };
18
+ };
19
+
20
+ var fetchPt = function fetchPt(focus, xt) {
21
+ var rawMouseX = focus.isFirefox // WORKAROUND d3.mouse firefox compatibility
22
+ ? d3.event.offsetX : d3.mouse(focus.root.node())[0];
23
+ var mouseX = xt.invert(rawMouseX);
24
+ var bisectDate = d3.bisector(function (d) {
25
+ return +d.x;
26
+ }).left;
27
+ var dt = focus.data;
28
+ var ls = dt.length;
29
+ var sortData = ls > 0 && dt[0].x > dt[ls - 1].x ? dt.reverse() : dt;
30
+ var idx = bisectDate(sortData, +mouseX);
31
+ return sortData[idx];
32
+ };
33
+
34
+ var MouseMove = function MouseMove(focus) {
35
+ var _TfRescale = TfRescale(focus),
36
+ xt = _TfRescale.xt,
37
+ yt = _TfRescale.yt;
38
+
39
+ var pt = fetchPt(focus, xt);
40
+ var freq = focus.freq;
41
+
42
+ if (pt) {
43
+ var tx = xt(pt.x);
44
+ var ty = yt(pt.y);
45
+ focus.root.select('.compass').attr('transform', 'translate(' + tx + ',' + ty + ')');
46
+ focus.root.select('.x-hover-line').attr('y1', 0 - ty).attr('y2', focus.h - ty);
47
+ focus.root.select('.cursor-txt').attr('transform', 'translate(' + tx + ',' + 10 + ')').text(pt.x.toFixed(3));
48
+ if (freq) {
49
+ focus.root.select('.cursor-txt-hz').attr('transform', 'translate(' + tx + ',' + 20 + ')').text((pt.x * freq).toFixed(3) + ' Hz');
50
+ } else {
51
+ focus.root.select('.cursor-txt-hz').text('');
52
+ }
53
+ }
54
+ };
55
+
56
+ var ClickCompass = function ClickCompass(focus) {
57
+ d3.event.stopPropagation();
58
+ d3.event.preventDefault();
59
+
60
+ var _TfRescale2 = TfRescale(focus),
61
+ xt = _TfRescale2.xt;
62
+
63
+ var pt = fetchPt(focus, xt);
64
+ var onPeak = false;
65
+ focus.clickUiTargetAct(pt, onPeak);
66
+ };
67
+
68
+ var MountCompass = function MountCompass(focus) {
69
+ var root = focus.root,
70
+ w = focus.w,
71
+ h = focus.h;
72
+
73
+ var compass = root.append('g').attr('class', 'compass');
74
+ var cursor = root.append('g').attr('class', 'cursor');
75
+ var overlay = root.append('rect').attr('class', 'overlay-focus').attr('width', w).attr('height', h).attr('opacity', 0.0);
76
+ compass.append('line').attr('class', 'x-hover-line hover-line').attr('stroke', '#777').attr('stroke-width', 1).attr('stroke-dasharray', 2, 2);
77
+ compass.append('circle').attr('r', 4).attr('fill', 'none').attr('stroke', '#777').attr('stroke-width', 2);
78
+ cursor.append('text').attr('class', 'cursor-txt').attr('font-family', 'Helvetica').style('font-size', '12px').style('text-anchor', 'middle');
79
+ cursor.append('text').attr('class', 'cursor-txt-hz').attr('font-family', 'Helvetica').style('font-size', '12px').style('text-anchor', 'middle').style('fill', '#D68910');
80
+
81
+ overlay.on('mousemove', function () {
82
+ return MouseMove(focus);
83
+ }).on('click', function () {
84
+ return ClickCompass(focus);
85
+ });
86
+ };
87
+
88
+ exports.MountCompass = MountCompass;
89
+ exports.TfRescale = TfRescale;
90
+ exports.ClickCompass = ClickCompass;
91
+ exports.MouseMove = MouseMove;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
8
+
9
+ var ToXY = function ToXY(data) {
10
+ var length = data ? data.length : 0;
11
+ if (length === 0) return [];
12
+ var peaks = [];
13
+ var i = 0;
14
+ for (i = 0; i < length; i += 1) {
15
+ var _data$i = data[i],
16
+ x = _data$i.x,
17
+ y = _data$i.y;
18
+
19
+ peaks = [].concat(_toConsumableArray(peaks), [[x, y]]);
20
+ }
21
+ return peaks;
22
+ };
23
+
24
+ var IsSame = function IsSame(one, two) {
25
+ return Math.abs((one - two) * 10000000) < 1.0;
26
+ };
27
+
28
+ var pksRmNeg = function pksRmNeg(dataPks, editPeakSt) {
29
+ var neg = editPeakSt.neg;
30
+
31
+ var negXs = neg.map(function (n) {
32
+ return n.x;
33
+ });
34
+ var result = dataPks.map(function (p) {
35
+ var idx = negXs.findIndex(function (nx) {
36
+ return IsSame(nx, p.x);
37
+ });
38
+ return idx >= 0 ? null : p;
39
+ }).filter(function (r) {
40
+ return r != null;
41
+ });
42
+ return result;
43
+ };
44
+
45
+ var pksAddPos = function pksAddPos(dataPks, editPeakSt) {
46
+ var pos = editPeakSt.pos;
47
+
48
+ var posXs = pos.map(function (p) {
49
+ return p.x;
50
+ });
51
+ var posPks = dataPks.map(function (p) {
52
+ var idx = posXs.findIndex(function (px) {
53
+ return px === p.x;
54
+ });
55
+ return idx >= 0 ? null : p;
56
+ }).filter(function (r) {
57
+ return r != null;
58
+ });
59
+ var result = [].concat(_toConsumableArray(posPks), _toConsumableArray(pos));
60
+ return result;
61
+ };
62
+
63
+ var PksEdit = function PksEdit(dataPks, editPeakSt) {
64
+ var modDataPks = pksAddPos(dataPks, editPeakSt);
65
+ modDataPks = pksRmNeg(modDataPks, editPeakSt);
66
+ modDataPks = modDataPks.sort(function (a, b) {
67
+ return a.x - b.x;
68
+ });
69
+ return modDataPks;
70
+ };
71
+
72
+ exports.ToXY = ToXY;
73
+ exports.PksEdit = PksEdit;
74
+ exports.IsSame = IsSame;
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extractParams = undefined;
7
+
8
+ var _format = require('./format');
9
+
10
+ var _format2 = _interopRequireDefault(_format);
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ var getScanIdx = function getScanIdx(entity, scanSt) {
15
+ var target = scanSt.target,
16
+ isAuto = scanSt.isAuto;
17
+ var features = entity.features,
18
+ spectra = entity.spectra;
19
+
20
+ var defaultFeat = features.editPeak || features.autoPeak || features[0];
21
+ var hasEdit = !!defaultFeat.scanEditTarget;
22
+ var defaultIdx = isAuto || !hasEdit ? defaultFeat.scanAutoTarget : defaultFeat.scanEditTarget;
23
+ var defaultCount = +spectra.length;
24
+ var idx = +(target || defaultIdx || 0);
25
+ if (idx > defaultCount) {
26
+ idx = defaultCount;
27
+ }
28
+ return idx - 1;
29
+ };
30
+
31
+ var extrShare = function extrShare(entity, thresSt) {
32
+ var scanIdx = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
33
+ var spectra = entity.spectra,
34
+ features = entity.features;
35
+ // const { autoPeak, editPeak } = features; // TBD
36
+
37
+ var autoPeak = features.autoPeak || features[scanIdx] || features[0];
38
+ var editPeak = features.editPeak || features[scanIdx] || features[0];
39
+ var hasEdit = editPeak && editPeak.data ? editPeak.data[0].x.length > 0 : false;
40
+
41
+ var feature = hasEdit && thresSt.isEdit ? editPeak : autoPeak;
42
+ var integration = features.integration;
43
+ var multiplicity = features.multiplicity;
44
+ return { spectra: spectra, feature: feature, hasEdit: hasEdit, integration: integration, multiplicity: multiplicity };
45
+ };
46
+
47
+ var extrMs = function extrMs(entity, thresSt, scanSt) {
48
+ var scanIdx = getScanIdx(entity, scanSt);
49
+
50
+ var _extrShare = extrShare(entity, thresSt, scanIdx),
51
+ spectra = _extrShare.spectra,
52
+ feature = _extrShare.feature,
53
+ hasEdit = _extrShare.hasEdit;
54
+
55
+ var topic = spectra[scanIdx].data[0];
56
+ return { topic: topic, feature: feature, hasEdit: hasEdit };
57
+ };
58
+
59
+ var extrNi = function extrNi(entity, thresSt) {
60
+ var scanIdx = 0;
61
+
62
+ var _extrShare2 = extrShare(entity, thresSt, scanIdx),
63
+ spectra = _extrShare2.spectra,
64
+ feature = _extrShare2.feature,
65
+ hasEdit = _extrShare2.hasEdit,
66
+ integration = _extrShare2.integration,
67
+ multiplicity = _extrShare2.multiplicity;
68
+
69
+ var topic = spectra[0].data[0];
70
+ return { topic: topic, feature: feature, hasEdit: hasEdit, integration: integration, multiplicity: multiplicity };
71
+ };
72
+
73
+ var extractParams = function extractParams(entity, thresSt, scanSt) {
74
+ return _format2.default.isMsLayout(entity.layout) ? extrMs(entity, thresSt, scanSt) : extrNi(entity, thresSt);
75
+ };
76
+
77
+ exports.extractParams = extractParams; // eslint-disable-line
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.extractAreaUnderCurve = exports.extractPeaksEdit = undefined;
7
+
8
+ var _converter = require('./converter');
9
+
10
+ var _chem = require('./chem');
11
+
12
+ var _shift = require('./shift');
13
+
14
+ var _format = require('./format');
15
+
16
+ var _format2 = _interopRequireDefault(_format);
17
+
18
+ var _integration = require('./integration');
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ var niOffset = function niOffset(shiftSt) {
23
+ var ref = shiftSt.ref,
24
+ peak = shiftSt.peak;
25
+
26
+ var offset = (0, _shift.FromManualToOffset)(ref, peak);
27
+ return offset;
28
+ };
29
+
30
+ var msOffset = function msOffset() {
31
+ return 0;
32
+ };
33
+
34
+ var extractPeaksEdit = function extractPeaksEdit(feature, editPeakSt, thresSt, shiftSt, layoutSt) {
35
+ var offset = _format2.default.isMsLayout(layoutSt) ? msOffset() : niOffset(shiftSt);
36
+ var peaks = (0, _chem.Convert2Peak)(feature, thresSt.value, offset);
37
+ var peaksEdit = (0, _converter.PksEdit)(peaks, editPeakSt);
38
+ return peaksEdit;
39
+ };
40
+
41
+ var getAUCValue = function getAUCValue(integrationSt) {
42
+ var refArea = integrationSt.refArea,
43
+ refFactor = integrationSt.refFactor,
44
+ stack = integrationSt.stack;
45
+
46
+ if (Array.isArray(stack) && stack.length > 0) {
47
+ var data = stack.at(-1);
48
+ return (0, _integration.calcArea)(data, refArea, refFactor);
49
+ }
50
+ return 0;
51
+ };
52
+
53
+ var extractAreaUnderCurve = function extractAreaUnderCurve(allIntegrationSt, presentIntegrationSt, layoutSt) {
54
+ if ((_format2.default.isUvVisLayout(layoutSt) || _format2.default.isHplcUvVisLayout(layoutSt)) && Array.isArray(allIntegrationSt) && presentIntegrationSt) {
55
+ if (!presentIntegrationSt.refArea) {
56
+ return null;
57
+ }
58
+ var results = [];
59
+ allIntegrationSt.forEach(function (inte) {
60
+ var aucVal = getAUCValue(inte);
61
+ results.push(aucVal);
62
+ });
63
+ return results;
64
+ }
65
+ return null;
66
+ };
67
+
68
+ exports.extractPeaksEdit = extractPeaksEdit;
69
+ exports.extractAreaUnderCurve = extractAreaUnderCurve; // eslint-disable-line
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var itgIdTag = function itgIdTag(d) {
7
+ return Math.round(1000 * d.xL) + "-" + Math.round(1000 * d.xU);
8
+ };
9
+
10
+ var mpyIdTag = function mpyIdTag(d) {
11
+ return Math.round(1000 * d.xExtent.xL) + "-" + Math.round(1000 * d.xExtent.xU);
12
+ };
13
+
14
+ exports.itgIdTag = itgIdTag;
15
+ exports.mpyIdTag = mpyIdTag;