nmrium 0.32.0 → 0.33.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 (116) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/{Integral.d.ts → integral/Integral.d.ts} +0 -0
  3. package/lib/component/1d/{Integral.js → integral/Integral.js} +2 -2
  4. package/lib/component/1d/integral/IntegralIndicator.d.ts +9 -0
  5. package/lib/component/1d/integral/IntegralIndicator.js +27 -0
  6. package/lib/component/1d/{IntegralResizable.d.ts → integral/IntegralResizable.d.ts} +0 -0
  7. package/lib/component/1d/integral/IntegralResizable.js +69 -0
  8. package/lib/component/1d/{IntegralsSeries.d.ts → integral/IntegralsSeries.d.ts} +0 -0
  9. package/lib/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  10. package/lib/component/1d/ranges/Range.js +27 -50
  11. package/lib/component/1d/utilities/scale.js +2 -2
  12. package/lib/component/2d/Contours.js +61 -42
  13. package/lib/component/NMRium.d.ts +1 -1
  14. package/lib/component/NMRium.js +1 -1
  15. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  16. package/lib/component/elements/formik/FormikColorPicker.js +5 -8
  17. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  18. package/lib/component/elements/formik/FormikInput.js +8 -19
  19. package/lib/component/elements/formik/FormikOnChange.d.ts +1 -1
  20. package/lib/component/elements/formik/FormikOnChange.js +13 -10
  21. package/lib/component/elements/formik/FormikSlider.d.ts +2 -4
  22. package/lib/component/elements/formik/FormikSlider.js +8 -11
  23. package/lib/component/hooks/useExport.js +1 -1
  24. package/lib/component/modal/ExportAsMatrixModal.js +1 -1
  25. package/lib/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  26. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  27. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +1 -1
  28. package/lib/component/panels/RangesPanel/RangesHeader.js +1 -1
  29. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
  30. package/lib/component/panels/RangesPanel/RangesTableRow.js +1 -3
  31. package/lib/component/panels/SpectrumsPanel/SpectrumsTabs.js +1 -1
  32. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.d.ts +1 -1
  33. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  34. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.d.ts +1 -1
  35. package/lib/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  36. package/lib/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  37. package/lib/component/reducer/Reducer.d.ts +18 -12
  38. package/lib/component/reducer/Reducer.js +23 -9
  39. package/lib/component/reducer/actions/PreferencesActions.js +16 -35
  40. package/lib/component/reducer/actions/RangesActions.js +6 -4
  41. package/lib/component/reducer/actions/SpectrumsActions.js +10 -4
  42. package/lib/component/reducer/actions/ToolsActions.js +7 -22
  43. package/lib/component/reducer/core/Constants.js +1 -1
  44. package/lib/component/utility/FileUtility.d.ts +1 -8
  45. package/lib/component/utility/FileUtility.js +2 -17
  46. package/lib/component/utility/{Export.d.ts → export.d.ts} +0 -0
  47. package/lib/component/utility/{Export.js → export.js} +26 -49
  48. package/lib/component/utility/formatNumber.d.ts +6 -1
  49. package/lib/component/utility/formatNumber.js +4 -3
  50. package/lib/data/SpectraManager.d.ts +1 -2
  51. package/lib/data/SpectraManager.js +22 -55
  52. package/lib/data/data1d/filter1d/fft.js +21 -4
  53. package/lib/data/data2d/Spectrum2D/contours.d.ts +40 -0
  54. package/lib/data/data2d/Spectrum2D/contours.js +132 -0
  55. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  56. package/lib/data/types/common/Source.d.ts +1 -0
  57. package/lib/data/types/data2d/Data2D.d.ts +2 -0
  58. package/lib/data/types/data2d/Datum2D.d.ts +0 -1
  59. package/lib/versionInfo.js +1 -1
  60. package/lib-cjs/component/1d/Chart1D.js +1 -1
  61. package/lib-cjs/component/1d/{Integral.js → integral/Integral.js} +2 -2
  62. package/lib-cjs/component/1d/integral/IntegralIndicator.js +31 -0
  63. package/lib-cjs/component/1d/integral/IntegralResizable.js +74 -0
  64. package/lib-cjs/component/1d/{IntegralsSeries.js → integral/IntegralsSeries.js} +3 -3
  65. package/lib-cjs/component/1d/ranges/Range.js +27 -50
  66. package/lib-cjs/component/1d/utilities/scale.js +2 -2
  67. package/lib-cjs/component/2d/Contours.js +60 -41
  68. package/lib-cjs/component/NMRium.js +2 -2
  69. package/lib-cjs/component/elements/formik/FormikColorPicker.js +4 -7
  70. package/lib-cjs/component/elements/formik/FormikInput.js +8 -19
  71. package/lib-cjs/component/elements/formik/FormikOnChange.js +13 -10
  72. package/lib-cjs/component/elements/formik/FormikSlider.js +7 -10
  73. package/lib-cjs/component/hooks/useExport.js +6 -6
  74. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -2
  75. package/lib-cjs/component/modal/editRange/forms/components/SignalFormInfo.js +1 -1
  76. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +4 -4
  77. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +2 -2
  78. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +2 -2
  79. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
  80. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +1 -3
  81. package/lib-cjs/component/panels/SpectrumsPanel/SpectrumsTabs.js +2 -2
  82. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum1DSetting.js +2 -1
  83. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/Spectrum2DSetting.js +2 -1
  84. package/lib-cjs/component/panels/extra/preferences/ColumnsHelper.js +5 -2
  85. package/lib-cjs/component/reducer/Reducer.js +22 -8
  86. package/lib-cjs/component/reducer/actions/PreferencesActions.js +16 -35
  87. package/lib-cjs/component/reducer/actions/RangesActions.js +6 -4
  88. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +9 -3
  89. package/lib-cjs/component/reducer/actions/ToolsActions.js +7 -22
  90. package/lib-cjs/component/reducer/core/Constants.js +1 -1
  91. package/lib-cjs/component/utility/FileUtility.js +2 -18
  92. package/lib-cjs/component/utility/{Export.js → export.js} +50 -50
  93. package/lib-cjs/component/utility/formatNumber.js +4 -3
  94. package/lib-cjs/data/SpectraManager.js +23 -57
  95. package/lib-cjs/data/data1d/filter1d/fft.js +20 -3
  96. package/lib-cjs/data/data2d/Spectrum2D/contours.js +138 -0
  97. package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +2 -3
  98. package/lib-cjs/versionInfo.js +1 -1
  99. package/package.json +6 -6
  100. package/lib/component/1d/IntegralResizable.js +0 -72
  101. package/lib/component/panels/RangesPanel/TableColumns/format.d.ts +0 -1
  102. package/lib/component/panels/RangesPanel/TableColumns/format.js +0 -8
  103. package/lib/data/data1d/Data1DManager.d.ts +0 -3
  104. package/lib/data/data1d/Data1DManager.js +0 -98
  105. package/lib/data/data2d/Data2DManager.d.ts +0 -3
  106. package/lib/data/data2d/Data2DManager.js +0 -34
  107. package/lib/data/types/data2d/Contour.d.ts +0 -4
  108. package/lib/data/types/data2d/Contour.js +0 -1
  109. package/lib/data/types/data2d/Contours.d.ts +0 -2
  110. package/lib/data/types/data2d/Contours.js +0 -1
  111. package/lib-cjs/component/1d/IntegralResizable.js +0 -77
  112. package/lib-cjs/component/panels/RangesPanel/TableColumns/format.js +0 -14
  113. package/lib-cjs/data/data1d/Data1DManager.js +0 -104
  114. package/lib-cjs/data/data2d/Data2DManager.js +0 -40
  115. package/lib-cjs/data/types/data2d/Contour.js +0 -2
  116. package/lib-cjs/data/types/data2d/Contours.js +0 -2
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
7
- /** @jsxImportSource @emotion/react */
8
- const react_1 = require("@emotion/react");
9
- const react_2 = require("react");
10
- const ChartContext_1 = require("../context/ChartContext");
11
- const DispatchContext_1 = require("../context/DispatchContext");
12
- const GlobalContext_1 = require("../context/GlobalContext");
13
- const ScaleContext_1 = require("../context/ScaleContext");
14
- const Resizer_1 = __importDefault(require("../elements/resizer/Resizer"));
15
- const index_1 = require("../highlight/index");
16
- const Types_1 = require("../reducer/types/Types");
17
- const ToolTypes_1 = require("../toolbar/ToolTypes");
18
- const formatNumber_1 = require("../utility/formatNumber");
19
- const stylesOnHover = (0, react_1.css) `
20
- pointer-events: bounding-box;
21
- @-moz-document url-prefix() {
22
- pointer-events: fill;
23
- }
24
- .highlight {
25
- fill: transparent;
26
- }
27
- .target {
28
- visibility: hidden;
29
- }
30
- `;
31
- const stylesHighlighted = (0, react_1.css) `
32
- pointer-events: bounding-box;
33
-
34
- @-moz-document url-prefix() {
35
- pointer-events: fill;
36
- }
37
- fill: #ff6f0057;
38
-
39
- .target {
40
- visibility: visible;
41
- }
42
- `;
43
- function IntegralResizable({ integralData, integralFormat, }) {
44
- const { height, margin, toolOptions: { selectedTool }, } = (0, ChartContext_1.useChartData)();
45
- const { viewerRef } = (0, GlobalContext_1.useGlobal)();
46
- const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
47
- const dispatch = (0, DispatchContext_1.useDispatch)();
48
- const { id, integral } = integralData;
49
- const highlight = (0, index_1.useHighlight)([id], {
50
- type: index_1.HighlightEventSource.INTEGRAL,
51
- extra: { id },
52
- });
53
- const handleOnStopResizing = (0, react_2.useCallback)((position) => {
54
- dispatch({
55
- type: Types_1.RESIZE_INTEGRAL,
56
- payload: {
57
- data: {
58
- ...integralData,
59
- from: scaleX().invert(position.x2),
60
- to: scaleX().invert(position.x1),
61
- },
62
- },
63
- });
64
- }, [dispatch, integralData, scaleX]);
65
- const handleOnEnterNotation = (0, react_2.useCallback)(() => {
66
- highlight.show();
67
- }, [highlight]);
68
- const handleOnMouseLeaveNotation = (0, react_2.useCallback)(() => {
69
- highlight.hide();
70
- }, [highlight]);
71
- const from = integralData.from ? scaleX()(integralData.from) : 0;
72
- const to = integralData.to ? scaleX()(integralData.to) : 0;
73
- return ((0, jsx_runtime_1.jsx)("g", { onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: to, x2: from }, onEnd: handleOnStopResizing, parentElement: viewerRef, disabled: selectedTool !== ToolTypes_1.options.integral.id, children: ({ x1, x2 }, isActive) => ((0, jsx_runtime_1.jsxs)("g", { css: highlight.isActive || isActive ? stylesHighlighted : stylesOnHover, children: [(0, jsx_runtime_1.jsx)("rect", { x: "0", y: "0", width: x2 - x1, height: height - margin.bottom, className: "highlight", "data-no-export": "true" }), (0, jsx_runtime_1.jsx)("text", { x: 0, y: height - margin.bottom + 30, fill: "black", style: { fontSize: '12px', fontWeight: 'bold' }, children: integral !== undefined
74
- ? (0, formatNumber_1.formatNumber)(integral, integralFormat)
75
- : '' })] })) }, `${id}_${to}_${from}`) }));
76
- }
77
- exports.default = IntegralResizable;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const get_1 = __importDefault(require("lodash/get"));
7
- const formatNumber_1 = require("../../../utility/formatNumber");
8
- function useFormat(preferences) {
9
- return (value, keysPath, prefix = '', suffix = '') => {
10
- const format = (0, get_1.default)(preferences, keysPath, '0.000');
11
- return (0, formatNumber_1.formatNumber)(value, format, prefix, suffix);
12
- };
13
- }
14
- exports.default = useFormat;
@@ -1,104 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromParsedJcamp = exports.fromCSD = exports.fromBruker = void 0;
4
- const Spectrum1D_1 = require("./Spectrum1D");
5
- function fromBruker(result, options = {}, usedColors = {}) {
6
- const { dependentVariables, info, meta, source } = result;
7
- let { data } = dependentVariables[0].components[0];
8
- const { x, re, im } = data;
9
- if (x[0] > x[1]) {
10
- x.reverse();
11
- re.reverse();
12
- if (im)
13
- im.reverse();
14
- }
15
- if (data.im)
16
- info.isComplex = true;
17
- if (Array.isArray(info.nucleus))
18
- info.nucleus = info.nucleus[0];
19
- const datum1D = (0, Spectrum1D_1.initiateDatum1D)({
20
- ...options,
21
- source,
22
- info,
23
- meta,
24
- data,
25
- }, usedColors);
26
- return datum1D;
27
- }
28
- exports.fromBruker = fromBruker;
29
- function fromCSD(result, options = {}, usedColors = {}) {
30
- let dimension = result.dimensions[0];
31
- let dependentVariables = result.dependentVariables;
32
- let quantityName = dimension.quantityName;
33
- let n = dimension.count;
34
- let incr = dimension.increment.magnitude;
35
- let origin = dimension.originOffset.magnitude;
36
- let offset = dimension.coordinatesOffset.magnitude;
37
- let buffer = dependentVariables[0].components[0];
38
- const re = new Float64Array(n);
39
- const im = new Float64Array(n);
40
- for (let i = buffer.length - 1, index = 0; i > 0; i -= 2) {
41
- re[index] = buffer[i - 1];
42
- im[index++] = buffer[i];
43
- }
44
- let data = {};
45
- let i, x0;
46
- switch (quantityName) {
47
- case 'frequency':
48
- x0 = 0 + (offset / origin) * 1000000;
49
- i = (incr / origin) * 1000000;
50
- data.re = re;
51
- data.im = im;
52
- break;
53
- case 'time':
54
- x0 = origin;
55
- i = incr;
56
- data.re = re.reverse();
57
- data.im = im.reverse().map((z) => -z);
58
- break;
59
- default:
60
- break;
61
- }
62
- let scale = [];
63
- for (let x = 0; x < n; x++) {
64
- scale.push(x0 + x * i);
65
- }
66
- data.x = scale;
67
- const datum1D = (0, Spectrum1D_1.initiateDatum1D)({
68
- ...options,
69
- data,
70
- }, usedColors);
71
- return datum1D;
72
- }
73
- exports.fromCSD = fromCSD;
74
- function fromParsedJcamp(parsedJcamp, options, usedColors, jcampSpectrumIndex) {
75
- const { dependentVariables, info, meta } = parsedJcamp;
76
- let data = getData(dependentVariables[0].components);
77
- if (Array.isArray(info.nucleus))
78
- info.nucleus = info.nucleus[0];
79
- const datum1D = (0, Spectrum1D_1.initiateDatum1D)({
80
- ...options,
81
- source: { ...options.source, jcampSpectrumIndex },
82
- display: {
83
- ...options.display,
84
- name: options?.display?.name ? options.display.name : info?.title,
85
- },
86
- info,
87
- meta,
88
- data,
89
- }, usedColors);
90
- return datum1D;
91
- }
92
- exports.fromParsedJcamp = fromParsedJcamp;
93
- function getData(spectra) {
94
- let x = spectra[0]?.data?.x ? spectra[0].data.x : [];
95
- let re = spectra[0]?.data?.y ? spectra[0].data.y : [];
96
- let im = spectra[1]?.data?.y ? spectra[1].data.y : null;
97
- if (x[0] > x[1]) {
98
- x.reverse();
99
- re.reverse();
100
- if (im)
101
- im.reverse();
102
- }
103
- return { x, re, im };
104
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromCSD = exports.fromBruker = exports.fromParsedJcamp = void 0;
4
- const Spectrum2D_1 = require("./Spectrum2D");
5
- function fromParsedJcamp(parsedJcamp, options, usedColors, jcampSpectrumIndex) {
6
- const { dependentVariables, info, meta } = parsedJcamp;
7
- let data = dependentVariables[0].components;
8
- const ob = (0, Spectrum2D_1.initiateDatum2D)({
9
- ...options,
10
- source: { ...options?.source, jcampSpectrumIndex },
11
- display: {
12
- ...options.display,
13
- name: options?.display?.name ? options.display.name : info?.title,
14
- },
15
- info,
16
- meta,
17
- data,
18
- }, usedColors);
19
- return ob;
20
- }
21
- exports.fromParsedJcamp = fromParsedJcamp;
22
- function fromBruker(result, options = {}, usedColors = {}) {
23
- const { dependentVariables, meta, source } = result;
24
- let data = dependentVariables[0].components;
25
- const datum2D = (0, Spectrum2D_1.initiateDatum2D)({
26
- ...options,
27
- source,
28
- meta,
29
- data,
30
- }, usedColors);
31
- return datum2D;
32
- }
33
- exports.fromBruker = fromBruker;
34
- // TODO: implement this.
35
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
- function fromCSD(result, options = {}, usedColors = {}) {
37
- const datum2D = (0, Spectrum2D_1.initiateDatum2D)({}, usedColors);
38
- return datum2D;
39
- }
40
- exports.fromCSD = fromCSD;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });