@complat/react-spectra-editor 1.3.4 → 1.4.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 (95) hide show
  1. package/dist/__tests__/fixtures/nmr1h_2_jcamp.js +3199 -1944
  2. package/dist/__tests__/units/components/cmd_bar/01_viewer.test.js +21 -18
  3. package/dist/__tests__/units/components/cmd_bar/02_zoom.test.js +15 -13
  4. package/dist/__tests__/units/components/cmd_bar/03_peak.test.js +35 -26
  5. package/dist/__tests__/units/components/cmd_bar/07_pecker.test.js +17 -14
  6. package/dist/__tests__/units/components/cmd_bar/r08_change_axes.test.js +15 -13
  7. package/dist/__tests__/units/components/common/comps.test.js +9 -8
  8. package/dist/__tests__/units/components/common/draw.test.js +26 -34
  9. package/dist/__tests__/units/components/panel/graph_selection.test.js +25 -22
  10. package/dist/__tests__/units/components/panel/info.test.js +30 -25
  11. package/dist/__tests__/units/components/panel/peaks.test.js +29 -24
  12. package/dist/actions/manager.js +6 -2
  13. package/dist/actions/ui.js +13 -21
  14. package/dist/app.js +47 -47
  15. package/dist/components/cmd_bar/01_viewer.js +38 -31
  16. package/dist/components/cmd_bar/02_zoom.js +34 -27
  17. package/dist/components/cmd_bar/03_peak.js +85 -64
  18. package/dist/components/cmd_bar/04_integration.js +97 -76
  19. package/dist/components/cmd_bar/05_multiplicity.js +94 -67
  20. package/dist/components/cmd_bar/06_undo_redo.js +41 -32
  21. package/dist/components/cmd_bar/07_pecker.js +70 -47
  22. package/dist/components/cmd_bar/common.js +8 -8
  23. package/dist/components/cmd_bar/index.js +20 -21
  24. package/dist/components/cmd_bar/r01_layout.js +201 -137
  25. package/dist/components/cmd_bar/r02_scan.js +63 -51
  26. package/dist/components/cmd_bar/r03_threshold.js +95 -69
  27. package/dist/components/cmd_bar/r04_submit.js +155 -133
  28. package/dist/components/cmd_bar/r05_submit_btn.js +39 -36
  29. package/dist/components/cmd_bar/r06_predict_btn.js +66 -52
  30. package/dist/components/cmd_bar/r07_wavelength_btn.js +35 -31
  31. package/dist/components/cmd_bar/r08_change_axes.js +65 -56
  32. package/dist/components/cmd_bar/r09_detector.js +38 -33
  33. package/dist/components/cmd_bar/tri_btn.js +37 -25
  34. package/dist/components/common/comps.js +5 -6
  35. package/dist/components/d3_line/index.js +2 -1
  36. package/dist/components/d3_line/line_focus.js +32 -34
  37. package/dist/components/d3_multi/index.js +2 -1
  38. package/dist/components/d3_multi/multi_focus.js +60 -37
  39. package/dist/components/d3_rect/index.js +2 -1
  40. package/dist/components/d3_rect/rect_focus.js +18 -20
  41. package/dist/components/forecast/comps.js +169 -132
  42. package/dist/components/forecast/ir_comps.js +88 -69
  43. package/dist/components/forecast/ir_viewer.js +35 -28
  44. package/dist/components/forecast/nmr_comps.js +105 -76
  45. package/dist/components/forecast/nmr_viewer.js +36 -29
  46. package/dist/components/forecast/section_loading.js +22 -17
  47. package/dist/components/forecast_viewer.js +19 -17
  48. package/dist/components/multi_jcamps_viewer.js +46 -40
  49. package/dist/components/panel/compare.js +92 -76
  50. package/dist/components/panel/cyclic_voltamery_data.js +171 -122
  51. package/dist/components/panel/graph_selection.js +113 -90
  52. package/dist/components/panel/index.js +45 -41
  53. package/dist/components/panel/info.js +204 -157
  54. package/dist/components/panel/multiplicity.js +85 -63
  55. package/dist/components/panel/multiplicity_coupling.js +36 -29
  56. package/dist/components/panel/multiplicity_select.js +20 -19
  57. package/dist/components/panel/peaks.js +78 -56
  58. package/dist/constants/action_type.js +2 -1
  59. package/dist/helpers/cfg.js +1 -2
  60. package/dist/helpers/chem.js +5 -13
  61. package/dist/helpers/converter.js +1 -2
  62. package/dist/helpers/extractParams.js +1 -2
  63. package/dist/helpers/extractPeaksEdit.js +3 -6
  64. package/dist/helpers/format.js +27 -62
  65. package/dist/helpers/init.js +5 -9
  66. package/dist/helpers/integration.js +1 -2
  67. package/dist/helpers/mount.js +1 -2
  68. package/dist/index.js +306 -276
  69. package/dist/layer_content.js +14 -14
  70. package/dist/layer_init.js +17 -16
  71. package/dist/layer_prism.js +84 -73
  72. package/dist/reducers/reducer_axes.js +2 -5
  73. package/dist/reducers/reducer_curve.js +8 -6
  74. package/dist/reducers/reducer_detector.js +1 -3
  75. package/dist/reducers/reducer_edit_peak.js +1 -3
  76. package/dist/reducers/reducer_forecast.js +1 -3
  77. package/dist/reducers/reducer_integration.js +1 -3
  78. package/dist/reducers/reducer_jcamp.js +5 -8
  79. package/dist/reducers/reducer_layout.js +1 -3
  80. package/dist/reducers/reducer_manager.js +1 -3
  81. package/dist/reducers/reducer_meta.js +1 -3
  82. package/dist/reducers/reducer_multiplicity.js +3 -3
  83. package/dist/reducers/reducer_scan.js +1 -3
  84. package/dist/reducers/reducer_shift.js +1 -3
  85. package/dist/reducers/reducer_simulation.js +1 -3
  86. package/dist/reducers/reducer_status.js +1 -3
  87. package/dist/reducers/reducer_submit.js +1 -3
  88. package/dist/reducers/reducer_threshold.js +199 -29
  89. package/dist/reducers/reducer_ui.js +1 -3
  90. package/dist/reducers/reducer_voltammetry.js +3 -7
  91. package/dist/reducers/reducer_wavelength.js +1 -3
  92. package/dist/sagas/saga_multi_entities.js +35 -14
  93. package/dist/sagas/saga_multiplicity.js +1 -2
  94. package/dist/third_party/jAnalyzer.js +1 -1
  95. package/package.json +18 -1
@@ -8,43 +8,213 @@ var _action_type = require("../constants/action_type");
8
8
  /* eslint-disable prefer-object-spread, default-param-last */
9
9
 
10
10
  const initialState = {
11
- isEdit: true,
12
- value: false,
13
- upper: false,
14
- lower: false
15
- };
16
- const thresholdReducer = function () {
17
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
18
- let action = arguments.length > 1 ? arguments[1] : undefined;
11
+ selectedIdx: 0,
12
+ list: [{
13
+ isEdit: true,
14
+ value: false,
15
+ upper: false,
16
+ lower: false
17
+ }]
18
+ };
19
+
20
+ // const defaultThresHold = {
21
+ // isEdit: true,
22
+ // value: false,
23
+ // upper: false,
24
+ // lower: false,
25
+ // };
26
+
27
+ const setThresHoldValue = (state, action) => {
28
+ const {
29
+ payload
30
+ } = action;
31
+ const {
32
+ list,
33
+ selectedIdx
34
+ } = state;
35
+ if (payload) {
36
+ const {
37
+ value,
38
+ curveIdx
39
+ } = payload;
40
+ const selectedThres = list[curveIdx];
41
+ const newSelectedThres = Object.assign({}, selectedThres, {
42
+ value
43
+ });
44
+ const newListThres = [...list];
45
+ newListThres[curveIdx] = newSelectedThres;
46
+ return Object.assign({}, state, {
47
+ list: newListThres,
48
+ selectedIdx: curveIdx
49
+ });
50
+ }
51
+ const selectedThres = list[selectedIdx];
52
+ const newSelectedThres = Object.assign({}, selectedThres, {
53
+ value: payload
54
+ });
55
+ const newListThres = [...list];
56
+ newListThres[selectedIdx] = newSelectedThres;
57
+ return Object.assign({}, state, {
58
+ list: newListThres
59
+ });
60
+ };
61
+ const setThresHoldUpper = (state, action) => {
62
+ const {
63
+ payload
64
+ } = action;
65
+ const {
66
+ list,
67
+ selectedIdx
68
+ } = state;
69
+ if (payload) {
70
+ const {
71
+ value,
72
+ curveIdx
73
+ } = payload;
74
+ const selectedThres = list[curveIdx];
75
+ const newSelectedThres = Object.assign({}, selectedThres, {
76
+ upper: value
77
+ });
78
+ const newListThres = [...list];
79
+ newListThres[curveIdx] = newSelectedThres;
80
+ return Object.assign({}, state, {
81
+ list: newListThres,
82
+ selectedIdx: curveIdx
83
+ });
84
+ }
85
+ const selectedThres = list[selectedIdx];
86
+ const newSelectedThres = Object.assign({}, selectedThres, {
87
+ upper: payload
88
+ });
89
+ const newListThres = [...list];
90
+ newListThres[selectedIdx] = newSelectedThres;
91
+ return Object.assign({}, state, {
92
+ list: newListThres
93
+ });
94
+ };
95
+ const setThresHoldLower = (state, action) => {
96
+ const {
97
+ payload
98
+ } = action;
99
+ const {
100
+ list,
101
+ selectedIdx
102
+ } = state;
103
+ if (payload) {
104
+ const {
105
+ value,
106
+ curveIdx
107
+ } = payload;
108
+ const selectedThres = list[curveIdx];
109
+ const newSelectedThres = Object.assign({}, selectedThres, {
110
+ lower: value
111
+ });
112
+ const newListThres = [...list];
113
+ newListThres[curveIdx] = newSelectedThres;
114
+ return Object.assign({}, state, {
115
+ list: newListThres,
116
+ selectedIdx: curveIdx
117
+ });
118
+ }
119
+ const selectedThres = list[selectedIdx];
120
+ const newSelectedThres = Object.assign({}, selectedThres, {
121
+ lower: payload
122
+ });
123
+ const newListThres = [...list];
124
+ newListThres[selectedIdx] = newSelectedThres;
125
+ return Object.assign({}, state, {
126
+ list: newListThres
127
+ });
128
+ };
129
+ const setThresHoldIsEdit = state => {
130
+ const {
131
+ list,
132
+ selectedIdx
133
+ } = state;
134
+ const selectedThres = list[selectedIdx];
135
+ const {
136
+ isEdit
137
+ } = selectedThres;
138
+ const newSelectedThres = Object.assign({}, selectedThres, {
139
+ isEdit: !isEdit
140
+ });
141
+ const newListThres = [...list];
142
+ newListThres[selectedIdx] = newSelectedThres;
143
+ return Object.assign({}, state, {
144
+ list: newListThres
145
+ });
146
+ };
147
+ const resetAll = (state, action) => {
148
+ const {
149
+ payload
150
+ } = action;
151
+ const {
152
+ list
153
+ } = state;
154
+ const newList = list.map(item => ({
155
+ isEdit: item.isEdit,
156
+ value: payload && payload.thresRef,
157
+ upper: item.upper,
158
+ lower: item.lower
159
+ }));
160
+ return Object.assign({}, state, {
161
+ selectedIdx: 0,
162
+ list: newList
163
+ });
164
+ };
165
+ const setListThreshold = (state, action) => {
166
+ const {
167
+ payload
168
+ } = action;
169
+ const {
170
+ list
171
+ } = state;
172
+ if (payload && payload.length > list.length) {
173
+ const newList = payload.map(() => ({
174
+ isEdit: true,
175
+ value: false,
176
+ upper: false,
177
+ lower: false
178
+ }));
179
+ return Object.assign({}, state, {
180
+ list: newList
181
+ });
182
+ }
183
+ return state;
184
+ };
185
+ const resetInitCommon = state => {
186
+ const {
187
+ list
188
+ } = state;
189
+ const newList = list.map(item => ({
190
+ isEdit: true,
191
+ value: item.value,
192
+ upper: item.upper,
193
+ lower: item.lower
194
+ }));
195
+ return Object.assign({}, state, {
196
+ selectedIdx: 0,
197
+ list: newList
198
+ });
199
+ };
200
+ const thresholdReducer = (state = initialState, action) => {
19
201
  switch (action.type) {
202
+ case _action_type.CURVE.SET_ALL_CURVES:
203
+ return setListThreshold(state, action);
20
204
  case _action_type.THRESHOLD.UPDATE_VALUE:
21
- return Object.assign({}, state, {
22
- value: action.payload
23
- });
205
+ return setThresHoldValue(state, action);
24
206
  case _action_type.THRESHOLD.UPDATE_UPPER_VALUE:
25
- return Object.assign({}, state, {
26
- upper: action.payload
27
- });
207
+ return setThresHoldUpper(state, action);
28
208
  case _action_type.THRESHOLD.UPDATE_LOWER_VALUE:
29
- return Object.assign({}, state, {
30
- lower: action.payload
31
- });
209
+ return setThresHoldLower(state, action);
32
210
  case _action_type.THRESHOLD.RESET_VALUE:
33
- return Object.assign({}, state, {
34
- value: action.payload
35
- });
211
+ return setThresHoldValue(state, action);
36
212
  case _action_type.THRESHOLD.TOGGLE_ISEDIT:
37
- return Object.assign({}, state, {
38
- isEdit: !state.isEdit
39
- });
213
+ return setThresHoldIsEdit(state);
40
214
  case _action_type.MANAGER.RESET_INIT_COMMON:
41
- return Object.assign({}, state, {
42
- isEdit: true
43
- });
215
+ return resetInitCommon(state);
44
216
  case _action_type.MANAGER.RESETALL:
45
- return Object.assign({}, state, {
46
- value: action.payload && action.payload.thresRef
47
- });
217
+ return resetAll(state, action);
48
218
  default:
49
219
  return state;
50
220
  }
@@ -17,9 +17,7 @@ const initialState = {
17
17
  },
18
18
  jcampIdx: 0
19
19
  };
20
- const uiReducer = function () {
21
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
22
- let action = arguments.length > 1 ? arguments[1] : undefined;
20
+ const uiReducer = (state = initialState, action) => {
23
21
  switch (action.type) {
24
22
  case _action_type.UI.VIEWER.SET_TYPE:
25
23
  return Object.assign({}, state, {
@@ -112,8 +112,7 @@ const getE12 = data => {
112
112
  }
113
113
  return null;
114
114
  };
115
- const addPeak = function (state, action) {
116
- let isMax = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
115
+ const addPeak = (state, action, isMax = true) => {
117
116
  const {
118
117
  payload
119
118
  } = action;
@@ -161,8 +160,7 @@ const addPeak = function (state, action) {
161
160
  }
162
161
  return state;
163
162
  };
164
- const removePeak = function (state, action) {
165
- let isMax = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
163
+ const removePeak = (state, action, isMax = true) => {
166
164
  const {
167
165
  payload
168
166
  } = action;
@@ -533,9 +531,7 @@ const selectRefFactor = (state, action) => {
533
531
  }
534
532
  return state;
535
533
  };
536
- const cyclicVoltaReducer = function () {
537
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
538
- let action = arguments.length > 1 ? arguments[1] : undefined;
534
+ const cyclicVoltaReducer = (state = initialState, action) => {
539
535
  switch (action.type) {
540
536
  case _action_type.CYCLIC_VOLTA_METRY.ADD_PAIR_PEAKS:
541
537
  return addPairPeak(state, action);
@@ -9,9 +9,7 @@ var _action_type = require("../constants/action_type");
9
9
  /* eslint-disable default-param-last */
10
10
 
11
11
  const initialState = _list_wavelength.LIST_WAVE_LENGTH[0];
12
- const wavelengthReducer = function () {
13
- let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
14
- let action = arguments.length > 1 ? arguments[1] : undefined;
12
+ const wavelengthReducer = (state = initialState, action) => {
15
13
  switch (action.type) {
16
14
  case _action_type.XRD.UPDATE_WAVE_LENGTH:
17
15
  return action.payload;
@@ -12,6 +12,7 @@ var _list_layout = require("../constants/list_layout");
12
12
  const getLayoutSt = state => state.layout;
13
13
  const getCurveSt = state => state.curve;
14
14
  const getIntegrationSt = state => state.integration.present;
15
+ const getMultiplicitySt = state => state.multiplicity.present;
15
16
  function getMaxMinPeak(curve) {
16
17
  return curve.maxminPeak;
17
18
  }
@@ -115,31 +116,51 @@ function* setInitIntegrations(action) {
115
116
  if (listCurves) {
116
117
  for (let index = 0; index < listCurves.length; index++) {
117
118
  const integationSt = yield (0, _effects.select)(getIntegrationSt);
119
+ const multiplicitySt = yield (0, _effects.select)(getMultiplicitySt);
118
120
  const curve = listCurves[index];
119
121
  const {
120
122
  integration,
123
+ multiplicity,
121
124
  simulation
122
125
  } = curve;
123
- const {
124
- integrations
125
- } = integationSt;
126
- const newArrIntegration = [...integrations];
127
- if (index < newArrIntegration.length) {
128
- newArrIntegration[index] = integration;
129
- } else {
130
- newArrIntegration.push(integration);
131
- }
132
- const payload = Object.assign({}, integationSt, {
133
- integrations: newArrIntegration,
134
- selectedIdx: index
135
- }); // eslint-disable-line
136
-
137
126
  if (integration) {
127
+ const {
128
+ integrations
129
+ } = integationSt;
130
+ const newArrIntegration = [...integrations];
131
+ if (index < newArrIntegration.length) {
132
+ newArrIntegration[index] = integration;
133
+ } else {
134
+ newArrIntegration.push(integration);
135
+ }
136
+ const payload = Object.assign({}, integationSt, {
137
+ integrations: newArrIntegration,
138
+ selectedIdx: index
139
+ }); // eslint-disable-line
138
140
  yield (0, _effects.put)({
139
141
  type: _action_type.INTEGRATION.RESET_ALL_RDC,
140
142
  payload
141
143
  });
142
144
  }
145
+ if (multiplicity) {
146
+ const {
147
+ multiplicities
148
+ } = multiplicitySt;
149
+ const newArrMultiplicities = [...multiplicities];
150
+ if (index < newArrMultiplicities.length) {
151
+ newArrMultiplicities[index] = multiplicity;
152
+ } else {
153
+ newArrMultiplicities.push(multiplicity);
154
+ }
155
+ const payload = Object.assign({}, multiplicitySt, {
156
+ multiplicities: newArrMultiplicities,
157
+ selectedIdx: index
158
+ }); // eslint-disable-line
159
+ yield (0, _effects.put)({
160
+ type: _action_type.MULTIPLICITY.RESET_ALL_RDC,
161
+ payload
162
+ });
163
+ }
143
164
  if (simulation) {
144
165
  yield (0, _effects.put)({
145
166
  type: _action_type.SIMULATION.RESET_ALL_RDC,
@@ -150,8 +150,7 @@ function* addUiPeakToStack(action) {
150
150
  payload
151
151
  });
152
152
  }
153
- const rmPeakFromStack = function (action, metaSt, mpySt) {
154
- let curveIdx = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
153
+ const rmPeakFromStack = (action, metaSt, mpySt, curveIdx = 0) => {
155
154
  const {
156
155
  peak,
157
156
  xExtent
@@ -22,7 +22,7 @@ var _default = exports.default = {
22
22
  * @param {object} signal
23
23
  * @private
24
24
  */
25
- compilePattern: function (signal) {
25
+ compilePattern: function compilePattern(signal) {
26
26
  signal.multiplicity = 'm';
27
27
  // 1.1 symmetrize
28
28
  // It will add a set of peaks(signal.peaksComp) to the signal that will be used during
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@complat/react-spectra-editor",
3
- "version": "1.3.4",
3
+ "version": "1.4.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",
@@ -57,6 +57,7 @@
57
57
  "devDependencies": {
58
58
  "@babel/cli": "^7.21.5",
59
59
  "@babel/core": "^7.21.8",
60
+ "@babel/plugin-transform-runtime": "^7.28.0",
60
61
  "@babel/preset-env": "^7.21.5",
61
62
  "@babel/preset-react": "^7.18.6",
62
63
  "@storybook/react": "7.0.7",
@@ -73,6 +74,7 @@
73
74
  "eslint-plugin-jsx-a11y": "^6.5.1",
74
75
  "eslint-plugin-react": "^7.28.0",
75
76
  "eslint-plugin-react-hooks": "^4.3.0",
77
+ "postcss-normalize": "^13.0.1",
76
78
  "react": "^17.0.2",
77
79
  "react-dom": "^17.0.2",
78
80
  "react-scripts": "5.0.1",
@@ -96,5 +98,20 @@
96
98
  "transformIgnorePatterns": [
97
99
  "/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
98
100
  ]
101
+ },
102
+ "babel": {
103
+ "presets": [
104
+ "@babel/preset-env",
105
+ [
106
+ "@babel/preset-react",
107
+ {
108
+ "runtime": "automatic"
109
+ }
110
+ ]
111
+ ],
112
+ "plugins": [
113
+ "@babel/plugin-transform-runtime",
114
+ "@babel/plugin-transform-function-name"
115
+ ]
99
116
  }
100
117
  }