@complat/react-spectra-editor 1.5.4 → 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.
@@ -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.4",
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",