@complat/react-spectra-editor 1.5.3 → 1.6.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.
@@ -45,22 +45,23 @@ const tpStyle = () => {
45
45
  const style = stBorder + stBorderRadius + stBackground + stColor + stPadding + stOpacity + stPadding + stZindex + stFontFamily;
46
46
  return style;
47
47
  };
48
- const tpDiv = (d, digits) => `
48
+ const tpDiv = (d, digits, yFactor = 1) => `
49
49
  <div
50
50
  class="peak-tp"
51
51
  style="${tpStyle()}"
52
52
  >
53
53
  <span> x: ${_format.default.fixDigit(d.x, digits)}</span>
54
54
  <br/>
55
- <span> y: ${d3.format('.2~e')(d.y)}</span>
55
+ <span> y: ${d3.format('.2~e')(d.y * (yFactor || 1))}</span>
56
56
  <div>
57
57
  `;
58
58
  const InitTip = () => {
59
59
  d3.select('.peak-tp').remove();
60
60
  const tip = (0, _d3Tip.default)().attr('class', 'd3-tip').html(({
61
61
  d,
62
- layout
63
- }) => tpDiv(d, _format.default.spectraDigit(layout)));
62
+ layout,
63
+ yFactor
64
+ }) => tpDiv(d, _format.default.spectraDigit(layout), yFactor || 1));
64
65
  return tip;
65
66
  };
66
67
  exports.InitTip = InitTip;
package/dist/index.js CHANGED
@@ -500,7 +500,7 @@ class DemoWriteIr extends _react.default.Component {
500
500
  console.log(analysis);
501
501
  console.log(integration);
502
502
  console.log(multiplicity);
503
- if (shift.ref.label) {
503
+ if (shift?.ref?.label) {
504
504
  const label = this.rmDollarSign(shift.ref.label);
505
505
  alert(`Peaks: ${body}` + '\n' + '- - - - - - - - - - -' + '\n' + `Shift solvent = ${label}, ${shift.ref.value}ppm` + '\n');
506
506
  } else {
@@ -9,7 +9,10 @@ var _chem = require("../helpers/chem");
9
9
  /* eslint-disable prefer-object-spread, default-param-last */
10
10
 
11
11
  const initialState = {
12
- spectraList: []
12
+ spectraList: [],
13
+ areaValue: 1.0,
14
+ areaUnit: 'cm²',
15
+ useCurrentDensity: false
13
16
  };
14
17
  const initSpectra = {
15
18
  list: [],
@@ -563,6 +566,36 @@ const cyclicVoltaReducer = (state = initialState, action) => {
563
566
  return Object.assign({}, state, {
564
567
  spectraList: []
565
568
  });
569
+ case _action_type.CYCLIC_VOLTA_METRY.SET_AREA_VALUE:
570
+ {
571
+ const {
572
+ value
573
+ } = action.payload;
574
+ if (value === '') {
575
+ return Object.assign({}, state, {
576
+ areaValue: ''
577
+ });
578
+ }
579
+ const areaValue = Number.isFinite(value) ? value : state.areaValue;
580
+ return Object.assign({}, state, {
581
+ areaValue
582
+ });
583
+ }
584
+ case _action_type.CYCLIC_VOLTA_METRY.SET_AREA_UNIT:
585
+ {
586
+ const {
587
+ unit
588
+ } = action.payload;
589
+ return Object.assign({}, state, {
590
+ areaUnit: unit
591
+ });
592
+ }
593
+ case _action_type.CYCLIC_VOLTA_METRY.TOGGLE_DENSITY:
594
+ {
595
+ return Object.assign({}, state, {
596
+ useCurrentDensity: !state.useCurrentDensity
597
+ });
598
+ }
566
599
  default:
567
600
  return state;
568
601
  }
@@ -38,6 +38,66 @@ function* setCyclicVoltametry(action) {
38
38
  if (layout !== _list_layout.LIST_LAYOUT.CYCLIC_VOLTAMMETRY) {
39
39
  return;
40
40
  }
41
+ const cvSt = yield (0, _effects.select)(state => state.cyclicvolta);
42
+ const {
43
+ feature
44
+ } = firstCurve;
45
+ if (feature) {
46
+ const {
47
+ weAreaValue,
48
+ weAreaUnit,
49
+ currentMode
50
+ } = feature;
51
+ if (typeof weAreaUnit === 'string' && weAreaUnit.length > 0) {
52
+ const unit = weAreaUnit.replace('^2', '²');
53
+ yield (0, _effects.put)({
54
+ type: _action_type.CYCLIC_VOLTA_METRY.SET_AREA_UNIT,
55
+ payload: {
56
+ unit
57
+ }
58
+ });
59
+ } else {
60
+ yield (0, _effects.put)({
61
+ type: _action_type.CYCLIC_VOLTA_METRY.SET_AREA_UNIT,
62
+ payload: {
63
+ unit: 'cm²'
64
+ }
65
+ });
66
+ }
67
+ if (weAreaValue !== undefined && weAreaValue !== null) {
68
+ let numeric = null;
69
+ if (typeof weAreaValue === 'string') {
70
+ const parsed = parseFloat(weAreaValue);
71
+ if (!Number.isNaN(parsed)) numeric = parsed;
72
+ } else if (Number.isFinite(weAreaValue)) {
73
+ numeric = weAreaValue;
74
+ }
75
+ if (Number.isFinite(numeric)) {
76
+ yield (0, _effects.put)({
77
+ type: _action_type.CYCLIC_VOLTA_METRY.SET_AREA_VALUE,
78
+ payload: {
79
+ value: numeric
80
+ }
81
+ });
82
+ } else {
83
+ yield (0, _effects.put)({
84
+ type: _action_type.CYCLIC_VOLTA_METRY.SET_AREA_VALUE,
85
+ payload: {
86
+ value: 1.0
87
+ }
88
+ });
89
+ }
90
+ }
91
+ if (typeof currentMode === 'string' && currentMode.length > 0) {
92
+ const wantDensity = currentMode.toUpperCase() === 'DENSITY';
93
+ if (!!cvSt.useCurrentDensity !== wantDensity) {
94
+ yield (0, _effects.put)({
95
+ type: _action_type.CYCLIC_VOLTA_METRY.TOGGLE_DENSITY,
96
+ payload: null
97
+ });
98
+ }
99
+ }
100
+ }
41
101
  for (let index = 0; index < listCurves.length; index++) {
42
102
  const curve = listCurves[index];
43
103
  const maxminPeak = getMaxMinPeak(curve);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@complat/react-spectra-editor",
3
- "version": "1.5.3",
3
+ "version": "1.6.0",
4
4
  "description": "An editor to View and Edit Chemical Spectra data (NMR, IR, MS, CV, UIVIS, XRD, GC, and DSC).",
5
5
  "repository": {
6
6
  "type": "git",