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
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const react_1 = require("react");
8
- const Spectrum1D_1 = require("../../data/data1d/Spectrum1D");
9
- const ChartContext_1 = require("../context/ChartContext");
10
- const Reducer_1 = require("../reducer/Reducer");
8
+ const Spectrum1D_1 = require("../../../data/data1d/Spectrum1D");
9
+ const ChartContext_1 = require("../../context/ChartContext");
10
+ const Reducer_1 = require("../../reducer/Reducer");
11
11
  const Integral_1 = __importDefault(require("./Integral"));
12
12
  function IntegralsSeries() {
13
13
  const { xDomains, data, displayerKey, view: { spectra: { activeTab: nucleus }, }, } = (0, ChartContext_1.useChartData)();
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
7
7
  /** @jsxImportSource @emotion/react */
8
8
  const react_1 = require("@emotion/react");
9
- const react_2 = require("react");
10
9
  const RangeUtilities_1 = require("../../../data/utilities/RangeUtilities");
11
10
  const AssignmentsContext_1 = require("../../assignment/AssignmentsContext");
12
11
  const filterForIDsWithAssignment_1 = require("../../assignment/utilities/filterForIDsWithAssignment");
@@ -17,18 +16,17 @@ const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
17
16
  const highlight_1 = require("../../highlight");
18
17
  const Types_1 = require("../../reducer/types/Types");
19
18
  const ToolTypes_1 = require("../../toolbar/ToolTypes");
20
- const formatNumber_1 = require("../../utility/formatNumber");
19
+ const IntegralIndicator_1 = require("../integral/IntegralIndicator");
21
20
  const MultiplicityTree_1 = __importDefault(require("../multiplicityTree/MultiplicityTree"));
22
21
  const stylesOnHover = (0, react_1.css) `
23
22
  pointer-events: bounding-box;
24
23
  @-moz-document url-prefix() {
25
24
  pointer-events: fill;
26
25
  }
27
- user-select: 'none';
28
- -webkit-user-select: none; /* Chrome all / Safari all */
29
- -moz-user-select: none; /* Firefox all */
30
-
31
- .delete-button {
26
+ .highlight {
27
+ fill: transparent;
28
+ }
29
+ .target {
32
30
  visibility: hidden;
33
31
  }
34
32
  `;
@@ -38,13 +36,10 @@ const stylesHighlighted = (0, react_1.css) `
38
36
  @-moz-document url-prefix() {
39
37
  pointer-events: fill;
40
38
  }
41
- .range-area {
42
- height: 100%;
43
- fill: #ff6f0057;
44
- }
45
- .delete-button {
39
+ fill: #ff6f0057;
40
+
41
+ .target {
46
42
  visibility: visible;
47
- cursor: pointer;
48
43
  }
49
44
  `;
50
45
  function Range({ rangeData, showMultiplicityTrees, selectedTool, relativeFormat, }) {
@@ -55,20 +50,8 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, relativeFormat,
55
50
  const highlightRange = (0, highlight_1.useHighlight)([assignmentRange.id].concat(assignmentRange.assigned?.x || []).concat((0, filterForIDsWithAssignment_1.filterForIDsWithAssignment)(assignmentData, signals.map((_signal) => _signal.id))), { type: highlight_1.HighlightEventSource.RANGE, extra: { id } });
56
51
  const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
57
52
  const dispatch = (0, DispatchContext_1.useDispatch)();
58
- const [reduceOpacity, setReduceOpacity] = (0, react_2.useState)(false);
59
- const [isBlockedByEditing, setIsBlockedByEditing] = (0, react_2.useState)(false);
60
- (0, react_2.useEffect)(() => {
61
- if (selectedTool && selectedTool === ToolTypes_1.options.editRange.id) {
62
- setIsBlockedByEditing(true);
63
- }
64
- else {
65
- setIsBlockedByEditing(false);
66
- }
67
- }, [selectedTool]);
68
- (0, react_2.useEffect)(() => {
69
- setReduceOpacity(!(0, RangeUtilities_1.checkRangeKind)(rangeData));
70
- }, [rangeData]);
71
- const handleOnStopResizing = (0, react_2.useCallback)((position) => {
53
+ const isBlockedByEditing = selectedTool && selectedTool === ToolTypes_1.options.editRange.id;
54
+ function handleOnStopResizing(position) {
72
55
  dispatch({
73
56
  type: Types_1.RESIZE_RANGE,
74
57
  data: {
@@ -77,40 +60,34 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, relativeFormat,
77
60
  to: scaleX().invert(position.x1),
78
61
  },
79
62
  });
80
- }, [dispatch, rangeData, scaleX]);
81
- const mouseEnterHandler = (0, react_2.useCallback)(() => {
63
+ }
64
+ function mouseEnterHandler() {
82
65
  assignmentRange.show('x');
83
66
  highlightRange.show();
84
- }, [assignmentRange, highlightRange]);
85
- const mouseLeaveHandler = (0, react_2.useCallback)(() => {
67
+ }
68
+ function mouseLeaveHandler() {
86
69
  assignmentRange.hide();
87
70
  highlightRange.hide();
88
- }, [assignmentRange, highlightRange]);
89
- const assignHandler = (0, react_2.useCallback)((e) => {
71
+ }
72
+ function assignHandler(e) {
90
73
  if (selectedTool === ToolTypes_1.options.rangePicking.id &&
91
74
  e.shiftKey &&
92
75
  !isBlockedByEditing) {
93
76
  assignmentRange.setActive('x');
94
77
  }
95
- }, [assignmentRange, isBlockedByEditing, selectedTool]);
78
+ }
96
79
  const from = scaleX()(rangeData.from);
97
80
  const to = scaleX()(rangeData.to);
98
- return ((0, jsx_runtime_1.jsxs)("g", { "data-test-id": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, 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.rangePicking.id, children: ({ x1, x2 }, isActive) => ((0, jsx_runtime_1.jsxs)("g", { transform: `translate(0,10)`, css: isBlockedByEditing ||
99
- highlightRange.isActive ||
100
- assignmentRange.isActive ||
101
- isActive
102
- ? stylesHighlighted
103
- : stylesOnHover, children: [(0, jsx_runtime_1.jsx)("rect", { x: "0", width: x2 - x1, height: "6", className: "range-area", fill: "green", fillOpacity: !reduceOpacity ||
104
- highlightRange.isActive ||
105
- assignmentRange.isActive
106
- ? 1
107
- : 0.4 }), (0, jsx_runtime_1.jsx)("text", { textAnchor: "middle", x: (x2 - x1) / 2, y: "20", fontSize: "10", fill: "red", fillOpacity: !reduceOpacity ||
108
- highlightRange.isActive ||
109
- assignmentRange.isActive
110
- ? 1
111
- : 0.6, children: integration !== undefined
112
- ? (0, formatNumber_1.formatNumber)(integration, relativeFormat)
113
- : '' })] })) }, `${id}_${to}_${from}`), showMultiplicityTrees &&
81
+ const isNotSignal = !(0, RangeUtilities_1.checkRangeKind)(rangeData);
82
+ return ((0, jsx_runtime_1.jsxs)("g", { "data-test-id": "range", style: { outline: 'none' }, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, 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.rangePicking.id, children: ({ x1, x2 }, isActive) => {
83
+ const width = x2 - x1;
84
+ return ((0, jsx_runtime_1.jsxs)("g", { css: isBlockedByEditing ||
85
+ highlightRange.isActive ||
86
+ assignmentRange.isActive ||
87
+ isActive
88
+ ? stylesHighlighted
89
+ : stylesOnHover, children: [(0, jsx_runtime_1.jsx)("rect", { width: width, height: "100%", className: "highlight", "data-no-export": "true" }), (0, jsx_runtime_1.jsx)(IntegralIndicator_1.IntegralIndicator, { value: integration, format: relativeFormat, width: width, opacity: isNotSignal ? 0.5 : 1 })] }));
90
+ } }, `${id}_${to}_${from}`), showMultiplicityTrees &&
114
91
  signals &&
115
92
  signals.length > 0 &&
116
93
  signals.map((_signal) => ((0, jsx_runtime_1.jsx)(MultiplicityTree_1.default, { rangeFrom: rangeData.from, rangeTo: rangeData.to, signal: _signal }, _signal.id)))] }, id));
@@ -13,8 +13,8 @@ exports.getXScale = getXScale;
13
13
  function getYScale(state, spectrumId = null) {
14
14
  const { height, margin, verticalAlign, yDomain, yDomains } = state;
15
15
  const _height = verticalAlign.align === 'center'
16
- ? (height - 30) / 2
17
- : height - margin.bottom - 30;
16
+ ? (height - 40) / 2
17
+ : height - margin.bottom - 40;
18
18
  let domainY = [];
19
19
  if (spectrumId === null || yDomains[spectrumId] === undefined) {
20
20
  domainY = [0, yDomain[1]];
@@ -4,67 +4,86 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const debounce_1 = __importDefault(require("lodash/debounce"));
7
8
  const get_1 = __importDefault(require("lodash/get"));
8
9
  const react_1 = require("react");
9
10
  const Spectrum2D_1 = require("../../data/data2d/Spectrum2D");
11
+ const contours_1 = require("../../data/data2d/Spectrum2D/contours");
10
12
  const ChartContext_1 = require("../context/ChartContext");
11
13
  const PreferencesContext_1 = require("../context/PreferencesContext");
14
+ const Alert_1 = require("../elements/popup/Alert");
12
15
  const Reducer_1 = require("../reducer/Reducer");
13
16
  const PathBuilder_1 = require("../utility/PathBuilder");
17
+ const nucleusToString_1 = __importDefault(require("../utility/nucleusToString"));
14
18
  const scale_1 = require("./utilities/scale");
15
- function ContoursPaths({ id: spectrumID, sign, color, datum, }) {
16
- const { margin, width, height, xDomain, yDomain, contours } = (0, ChartContext_1.useChartData)();
17
- const activeSpectrum = (0, Reducer_1.useActiveSpectrum)();
18
- const preferences = (0, PreferencesContext_1.usePreferences)();
19
+ function usePath(datum, contours) {
20
+ const { margin, width, height, xDomain, yDomain } = (0, ChartContext_1.useChartData)();
19
21
  const { xShift, yShift } = (0, Spectrum2D_1.getShift)(datum);
20
- const isActive = (0, react_1.useMemo)(() => {
21
- return activeSpectrum === null ? true : spectrumID === activeSpectrum.id;
22
- }, [activeSpectrum, spectrumID]);
23
- function buildContourPath(data) {
24
- const _scaleX = (0, scale_1.get2DXScale)({ margin, width, xDomain });
25
- const _scaleY = (0, scale_1.get2DYScale)({ margin, height, yDomain });
26
- const pathBuilder = new PathBuilder_1.PathBuilder();
27
- for (const element of data) {
28
- if (element.lines) {
29
- const lines = element.lines;
30
- if (lines.length < 1e6) {
31
- for (let i = 0; i < lines.length; i += 4) {
32
- pathBuilder.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
33
- pathBuilder.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
34
- }
22
+ const _scaleX = (0, scale_1.get2DXScale)({ margin, width, xDomain });
23
+ const _scaleY = (0, scale_1.get2DYScale)({ margin, height, yDomain });
24
+ const pathBuilder = new PathBuilder_1.PathBuilder();
25
+ for (const element of contours) {
26
+ if (element.lines) {
27
+ const lines = element.lines;
28
+ if (lines.length < 1e6) {
29
+ for (let i = 0; i < lines.length; i += 4) {
30
+ pathBuilder.moveTo(_scaleX(lines[i] + xShift), _scaleY(lines[i + 1] + yShift));
31
+ pathBuilder.lineTo(_scaleX(lines[i + 2] + xShift), _scaleY(lines[i + 3] + yShift));
35
32
  }
36
33
  }
37
- else {
38
- pathBuilder.moveTo(_scaleX(element[0].x + xShift), _scaleY(element[0].y + yShift));
39
- for (let j = 1; j < element.length; j++) {
40
- pathBuilder.lineTo(_scaleX(element[j].x + xShift), _scaleY(element[j].y + yShift));
41
- }
34
+ }
35
+ else {
36
+ pathBuilder.moveTo(_scaleX(element[0].x + xShift), _scaleY(element[0].y + yShift));
37
+ for (let j = 1; j < element.length; j++) {
38
+ pathBuilder.lineTo(_scaleX(element[j].x + xShift), _scaleY(element[j].y + yShift));
42
39
  }
43
40
  }
44
- pathBuilder.closePath();
45
- return pathBuilder.toString();
46
41
  }
47
- const data = (0, react_1.useMemo)(() => {
48
- return (0, get_1.default)(contours, `${spectrumID}.${sign}`, []);
49
- }, [contours, sign, spectrumID]);
50
- const path = buildContourPath(data);
51
- if (!path)
52
- return null;
53
- return ((0, jsx_runtime_1.jsx)("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", style: {
54
- opacity: isActive
55
- ? 1
56
- : (0, get_1.default)(preferences.current, 'general.dimmedSpectraOpacity', 0.1),
57
- }, d: path }));
42
+ pathBuilder.closePath();
43
+ return pathBuilder.toString();
44
+ }
45
+ const useContoursLevel = (datum, sign) => {
46
+ const { view: { zoom: { levels }, }, } = (0, ChartContext_1.useChartData)();
47
+ const { id, display: { contourOptions }, } = datum;
48
+ const defaultLevel = (0, contours_1.getDefaultContoursLevel)(contourOptions);
49
+ const level = levels?.[id]?.[sign];
50
+ return isNaN(level) ? defaultLevel[sign] : level;
51
+ };
52
+ function ContoursPaths({ id: spectrumID, sign, color, datum, onTimeout, }) {
53
+ const activeSpectrum = (0, Reducer_1.useActiveSpectrum)();
54
+ const preferences = (0, PreferencesContext_1.usePreferences)();
55
+ const level = useContoursLevel(datum, sign);
56
+ const contours = (0, react_1.useMemo)(() => {
57
+ const { contours, timeout } = (0, contours_1.drawContours)(level, datum, sign === 'negative');
58
+ if (timeout) {
59
+ onTimeout();
60
+ }
61
+ return contours;
62
+ }, [datum, level, onTimeout, sign]);
63
+ const path = usePath(datum, contours);
64
+ const opacity = activeSpectrum === null || spectrumID === activeSpectrum.id
65
+ ? '1'
66
+ : (0, get_1.default)(preferences.current, 'general.dimmedSpectraOpacity', 0.1);
67
+ return ((0, jsx_runtime_1.jsx)("path", { fill: "none", "data-test-id": "spectrum-line", stroke: color, strokeWidth: "1", opacity: opacity, d: path }));
58
68
  }
59
69
  function ContoursInner({ data, displayerKey }) {
60
- return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum, index) => ((0, jsx_runtime_1.jsxs)("g", { children: [datum.display.isPositiveVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "positive", datum: datum, color: datum.display.positiveColor })), datum.display.isNegativeVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "negative", datum: datum, color: datum.display.negativeColor }))] }, `${datum.id + index}`))) }));
70
+ const alert = (0, Alert_1.useAlert)();
71
+ const debounceAlert = (0, react_1.useRef)((0, debounce_1.default)(() => {
72
+ alert.error('Too many contour lines, only showing the first ones');
73
+ }, 2000));
74
+ function timeoutHandler() {
75
+ debounceAlert.current();
76
+ }
77
+ return ((0, jsx_runtime_1.jsx)("g", { clipPath: `url(#${displayerKey}clip-chart-2d)`, className: "contours", children: data?.map((datum) => ((0, jsx_runtime_1.jsxs)("g", { children: [datum.display.isPositiveVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "positive", datum: datum, color: datum.display.positiveColor, onTimeout: timeoutHandler })), datum.display.isNegativeVisible && ((0, jsx_runtime_1.jsx)(ContoursPaths, { id: datum.id, sign: "negative", datum: datum, color: datum.display.negativeColor, onTimeout: timeoutHandler }))] }, datum.id))) }));
61
78
  }
62
79
  const MemoizedContours = (0, react_1.memo)(ContoursInner);
63
80
  function Contours() {
64
- const { data: spectra, displayerKey } = (0, ChartContext_1.useChartData)();
81
+ const { data: spectra, displayerKey, view: { spectra: { activeTab }, }, } = (0, ChartContext_1.useChartData)();
65
82
  const data = (0, react_1.useMemo)(() => {
66
- return spectra.filter((datum) => datum.info.dimension === 2 && datum.info.isFt);
67
- }, [spectra]);
83
+ return spectra.filter((datum) => datum.info.dimension === 2 &&
84
+ datum.info.isFt &&
85
+ activeTab === (0, nucleusToString_1.default)(datum.info.nucleus));
86
+ }, [activeTab, spectra]);
68
87
  return (0, jsx_runtime_1.jsx)(MemoizedContours, { ...{ data, displayerKey } });
69
88
  }
70
89
  exports.default = Contours;
@@ -58,7 +58,7 @@ const Constants_1 = require("./reducer/core/Constants");
58
58
  const preferencesReducer_1 = __importStar(require("./reducer/preferences/preferencesReducer"));
59
59
  const Types_1 = require("./reducer/types/Types");
60
60
  const ToolBar_1 = __importDefault(require("./toolbar/ToolBar"));
61
- const Export_1 = require("./utility/Export");
61
+ const export_1 = require("./utility/export");
62
62
  const viewerContainerStyle = (0, react_1.css) `
63
63
  border: 0.55px #e6e6e6 solid;
64
64
  display: flex;
@@ -162,7 +162,7 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = de
162
162
  }, [preferences, workspace]);
163
163
  (0, react_2.useImperativeHandle)(innerRef, () => ({
164
164
  getSpectraViewerAsBlob: () => {
165
- return rootRef?.current ? (0, Export_1.getBlob)(rootRef.current, 'nmrSVG') : null;
165
+ return rootRef?.current ? (0, export_1.getBlob)(rootRef.current, 'nmrSVG') : null;
166
166
  },
167
167
  }), []);
168
168
  (0, react_2.useEffect)(() => {
@@ -10,15 +10,12 @@ const get_1 = __importDefault(require("lodash/get"));
10
10
  const react_1 = require("react");
11
11
  const getColor_1 = require("../../../data/utilities/getColor");
12
12
  function FormikColorPicker(props) {
13
- const { onColorChange = () => null, name, triggerSubmit = false } = props;
14
- const { values, setFieldValue, submitForm } = (0, formik_1.useFormikContext)();
15
- const colorChangeHandler = (0, react_1.useCallback)((color) => {
13
+ const { onColorChange = () => null, name } = props;
14
+ const { values, setFieldValue } = (0, formik_1.useFormikContext)();
15
+ function colorChangeHandler(color) {
16
16
  setFieldValue(name, `${color.hex}${Math.round(color.rgb.a * 255).toString(16)}`, false);
17
17
  onColorChange(color);
18
- if (triggerSubmit) {
19
- setTimeout(submitForm, 1);
20
- }
21
- }, [name, onColorChange, setFieldValue, submitForm, triggerSubmit]);
18
+ }
22
19
  return ((0, jsx_runtime_1.jsx)(analysis_ui_components_1.ColorPicker, { color: { hex: (0, get_1.default)(values, name, '#000') }, presetColors: getColor_1.COLORS, onChangeComplete: colorChangeHandler, style: { boxShadow: 'none' } }));
23
20
  }
24
21
  exports.default = (0, react_1.memo)(FormikColorPicker);
@@ -6,29 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const formik_1 = require("formik");
8
8
  const get_1 = __importDefault(require("lodash/get"));
9
- const react_1 = require("react");
10
9
  const Input_1 = __importDefault(require("../Input"));
11
10
  function FormikInput(props) {
12
- const { name, style = { label: {}, input: {} }, onChange = () => null, checkValue = () => true, type = 'text', className = '', value = null, format = () => (value) => value, checkErrorAfterInputTouched = true, triggerSubmit = false, ...resProps } = props;
13
- const { values, handleChange, setFieldValue, errors, touched, submitForm } = (0, formik_1.useFormikContext)();
14
- const changeHandler = (0, react_1.useCallback)((e) => {
11
+ const { name, style = { label: {}, input: {} }, onChange = () => null, checkValue = () => true, type = 'text', className = '', value = null, format = () => (value) => value, checkErrorAfterInputTouched = true, ...resProps } = props;
12
+ const { values, handleChange, errors, touched } = (0, formik_1.useFormikContext)();
13
+ function changeHandler(e) {
15
14
  onChange(e);
16
15
  handleChange(e);
17
- }, [handleChange, onChange]);
18
- (0, react_1.useEffect)(() => {
19
- if (value) {
20
- setFieldValue(name, value);
21
- if (triggerSubmit) {
22
- setTimeout(submitForm, 1);
23
- }
24
- }
25
- }, [name, setFieldValue, submitForm, triggerSubmit, value]);
26
- const isInvalid = (0, react_1.useMemo)(() => {
27
- if (checkErrorAfterInputTouched) {
28
- return (0, get_1.default)(errors, name) && (0, get_1.default)(touched, name);
29
- }
30
- return (0, get_1.default)(errors, name);
31
- }, [checkErrorAfterInputTouched, errors, name, touched]);
16
+ }
17
+ let isInvalid = (0, get_1.default)(errors, name);
18
+ if (checkErrorAfterInputTouched) {
19
+ isInvalid = (0, get_1.default)(errors, name) && (0, get_1.default)(touched, name);
20
+ }
32
21
  return ((0, jsx_runtime_1.jsx)(Input_1.default, { name: name, value: value ? value : (0, get_1.default)(values, name), onChange: changeHandler, type: type, style: {
33
22
  ...style,
34
23
  inputWrapper: {
@@ -5,22 +5,25 @@ const react_1 = require("react");
5
5
  const FormikOnChange = (props) => {
6
6
  const { onChange = () => null, enableValidation = true } = props;
7
7
  const oldValuesRef = (0, react_1.useRef)({});
8
- const { values, errors, submitForm, setTouched } = (0, formik_1.useFormikContext)();
8
+ const { values, errors, setTouched, initialValues } = (0, formik_1.useFormikContext)();
9
9
  (0, react_1.useEffect)(() => {
10
- if (enableValidation) {
11
- if (Object.keys(errors).length === 0 &&
12
- JSON.stringify(oldValuesRef.current) !== JSON.stringify(values)) {
13
- onChange(values);
10
+ const isNewValue = JSON.stringify(values) !== JSON.stringify(initialValues);
11
+ if (isNewValue) {
12
+ if (enableValidation) {
13
+ if (Object.keys(errors).length === 0 &&
14
+ JSON.stringify(oldValuesRef.current) !== JSON.stringify(values)) {
15
+ onChange(values);
16
+ }
17
+ else {
18
+ setTouched(errors);
19
+ }
14
20
  }
15
21
  else {
16
- setTouched(errors);
22
+ onChange(values);
17
23
  }
18
24
  }
19
- else {
20
- onChange(values);
21
- }
22
25
  oldValuesRef.current = values;
23
- }, [values, enableValidation, errors, onChange, submitForm, setTouched]);
26
+ }, [values, enableValidation, errors, onChange, setTouched, initialValues]);
24
27
  return null;
25
28
  };
26
29
  exports.default = (0, react_1.memo)(FormikOnChange);
@@ -5,19 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsx_runtime_1 = require("react/jsx-runtime");
7
7
  const formik_1 = require("formik");
8
+ const debounce_1 = __importDefault(require("lodash/debounce"));
8
9
  const get_1 = __importDefault(require("lodash/get"));
9
10
  const react_1 = require("react");
10
11
  const react_slider_1 = __importDefault(require("react-slider"));
11
12
  function FormikSlider(props) {
12
- const { onAfterChange = () => null, name, triggerSubmit = false, ...sliderProps } = props;
13
- const { values, setFieldValue, submitForm } = (0, formik_1.useFormikContext)();
14
- const changeHandler = (0, react_1.useCallback)((value) => {
15
- onAfterChange(value);
13
+ const { name, debounceTime = 0 } = props;
14
+ const { values, setFieldValue } = (0, formik_1.useFormikContext)();
15
+ const debounceOnChange = (0, react_1.useRef)((0, debounce_1.default)((value) => {
16
16
  setFieldValue(name, value);
17
- if (triggerSubmit) {
18
- setTimeout(submitForm, 1);
19
- }
20
- }, [name, onAfterChange, setFieldValue, submitForm, triggerSubmit]);
21
- return ((0, jsx_runtime_1.jsx)(react_slider_1.default, { className: "horizontal-slider", thumbClassName: "thumb", trackClassName: "track", defaultValue: (0, get_1.default)(values, name, [0, 100]), onAfterChange: changeHandler, renderThumb: (props, state) => ((0, jsx_runtime_1.jsx)("div", { ...props, children: (0, jsx_runtime_1.jsx)("span", { children: state.valueNow }) })), pearling: true, minDistance: 10, ...sliderProps }));
17
+ }, debounceTime)).current;
18
+ return ((0, jsx_runtime_1.jsx)(react_slider_1.default, { className: "horizontal-slider", thumbClassName: "thumb", trackClassName: "track", defaultValue: (0, get_1.default)(values, name, [0, 100]), onAfterChange: (value) => debounceOnChange(value), renderThumb: (props, state) => ((0, jsx_runtime_1.jsx)("div", { ...props, children: (0, jsx_runtime_1.jsx)("span", { children: state.valueNow }) })), pearling: true, minDistance: 10 }));
22
19
  }
23
- exports.default = (0, react_1.memo)(FormikSlider);
20
+ exports.default = FormikSlider;
@@ -11,7 +11,7 @@ const GlobalContext_1 = require("../context/GlobalContext");
11
11
  const Alert_1 = require("../elements/popup/Alert");
12
12
  const Modal_1 = require("../elements/popup/Modal");
13
13
  const SaveAsModal_1 = __importDefault(require("../modal/SaveAsModal"));
14
- const Export_1 = require("../utility/Export");
14
+ const export_1 = require("../utility/export");
15
15
  function useExport() {
16
16
  const { rootRef } = (0, GlobalContext_1.useGlobal)();
17
17
  const modal = (0, Modal_1.useModal)();
@@ -21,7 +21,7 @@ function useExport() {
21
21
  if (state.data.length > 0 && rootRef) {
22
22
  const hideLoading = await alert.showLoading('Exporting as NMRium process in progress');
23
23
  setTimeout(() => {
24
- (0, Export_1.copyPNGToClipboard)(rootRef, 'nmrSVG');
24
+ (0, export_1.copyPNGToClipboard)(rootRef, 'nmrSVG');
25
25
  hideLoading();
26
26
  alert.success('Image copied to clipboard');
27
27
  }, 0);
@@ -35,7 +35,7 @@ function useExport() {
35
35
  //exported file name by default will be the first spectrum name
36
36
  const fileName = state.data[0]?.display?.name;
37
37
  const exportedData = (0, SpectraManager_1.toJSON)(state, 'nmrium');
38
- await (0, Export_1.exportAsJSON)(exportedData, fileName, spaceIndent, isCompressed);
38
+ await (0, export_1.exportAsJSON)(exportedData, fileName, spaceIndent, isCompressed);
39
39
  hideLoading();
40
40
  }
41
41
  void handle();
@@ -47,7 +47,7 @@ function useExport() {
47
47
  const hideLoading = await alert.showLoading('Exporting as SVG process in progress');
48
48
  setTimeout(() => {
49
49
  const fileName = state.data[0]?.display?.name;
50
- (0, Export_1.exportAsSVG)(rootRef, 'nmrSVG', fileName);
50
+ (0, export_1.exportAsSVG)(rootRef, 'nmrSVG', fileName);
51
51
  hideLoading();
52
52
  }, 0);
53
53
  }
@@ -57,7 +57,7 @@ function useExport() {
57
57
  const hideLoading = await alert.showLoading('Exporting as PNG process in progress');
58
58
  setTimeout(() => {
59
59
  const fileName = state.data[0]?.display?.name;
60
- (0, Export_1.exportAsPng)(rootRef, 'nmrSVG', fileName);
60
+ (0, export_1.exportAsPng)(rootRef, 'nmrSVG', fileName);
61
61
  hideLoading();
62
62
  }, 0);
63
63
  }
@@ -70,7 +70,7 @@ function useExport() {
70
70
  void (async () => {
71
71
  const exportedData = (0, SpectraManager_1.toJSON)(state, 'nmrium', dataExportOption);
72
72
  const spaceIndent = pretty ? 2 : 0;
73
- await (0, Export_1.exportAsJSON)(exportedData, name, spaceIndent, compressed);
73
+ await (0, export_1.exportAsJSON)(exportedData, name, spaceIndent, compressed);
74
74
  hideLoading();
75
75
  })();
76
76
  }, 0);
@@ -13,7 +13,7 @@ const Label_1 = __importDefault(require("../elements/Label"));
13
13
  const FormikForm_1 = __importDefault(require("../elements/formik/FormikForm"));
14
14
  const FormikInput_1 = __importDefault(require("../elements/formik/FormikInput"));
15
15
  const Events_1 = __importDefault(require("../utility/Events"));
16
- const Export_1 = require("../utility/Export");
16
+ const export_1 = require("../utility/export");
17
17
  const ModalStyle_1 = require("./ModalStyle");
18
18
  const INITIAL_VALUE = { from: -1, to: 1, nbPoints: 1024 };
19
19
  function ExportAsMatrixModal({ onClose = () => null, }) {
@@ -23,7 +23,7 @@ function ExportAsMatrixModal({ onClose = () => null, }) {
23
23
  refForm.current.submitForm();
24
24
  }, []);
25
25
  const submitHandler = (0, react_1.useCallback)((options) => {
26
- (0, Export_1.exportAsMatrix)(data, options, 'fileName');
26
+ (0, export_1.exportAsMatrix)(data, options, 'fileName');
27
27
  onClose();
28
28
  }, [data, onClose]);
29
29
  (0, react_1.useEffect)(() => {
@@ -21,7 +21,7 @@ const styles = {
21
21
  color: 'red',
22
22
  },
23
23
  };
24
- const EDIT_SIGNAL_INFO_TEXT = `Focus on an input field and press Shift + Drag &#38; Drop to draw a coupling constant in spectrum view.`;
24
+ const EDIT_SIGNAL_INFO_TEXT = `Focus on an input field and press Shift + Drag and Drop to draw a coupling constant in spectrum view.`;
25
25
  const ADD_SIGNAL_INFO_TEXT = `Focus on the input field and press Shift + Left mouse click to select new signal delta value in spectrum view.`;
26
26
  const InfoText = (props) => {
27
27
  const { value, type = 'info' } = props;
@@ -21,7 +21,7 @@ const Alert_1 = require("../../elements/popup/Alert");
21
21
  const Modal_1 = require("../../elements/popup/Modal");
22
22
  const PredictSpectraModal_1 = __importDefault(require("../../modal/PredictSpectraModal"));
23
23
  const Types_1 = require("../../reducer/types/Types");
24
- const Export_1 = require("../../utility/Export");
24
+ const export_1 = require("../../utility/export");
25
25
  const toolbarStyle = (0, react_1.css) `
26
26
  display: flex;
27
27
  flex-direction: row;
@@ -72,17 +72,17 @@ function MoleculePanelHeader({ currentIndex, molecules, floatingMolecules, onMol
72
72
  const saveAsSVGHandler = (0, react_2.useCallback)(() => {
73
73
  if (!rootRef)
74
74
  return;
75
- (0, Export_1.exportAsSVG)(rootRef, `molSVG${currentIndex}`, 'molFile');
75
+ (0, export_1.exportAsSVG)(rootRef, `molSVG${currentIndex}`, 'molFile');
76
76
  }, [rootRef, currentIndex]);
77
77
  const saveAsPNGHandler = (0, react_2.useCallback)(() => {
78
78
  if (!rootRef)
79
79
  return;
80
- (0, Export_1.copyPNGToClipboard)(rootRef, `molSVG${currentIndex}`);
80
+ (0, export_1.copyPNGToClipboard)(rootRef, `molSVG${currentIndex}`);
81
81
  alert.success('MOL copied as PNG to clipboard');
82
82
  }, [rootRef, alert, currentIndex]);
83
83
  const saveAsMolHandler = (0, react_2.useCallback)(() => {
84
84
  if (molecules[currentIndex]) {
85
- void (0, Export_1.copyTextToClipboard)(molecules[currentIndex].molfile).then((flag) => {
85
+ void (0, export_1.copyTextToClipboard)(molecules[currentIndex].molfile).then((flag) => {
86
86
  if (flag) {
87
87
  alert.success('MOLFile copied to clipboard');
88
88
  }
@@ -20,7 +20,7 @@ const Modal_1 = require("../../elements/popup/Modal");
20
20
  const AlignSpectraModal_1 = __importDefault(require("../../modal/AlignSpectraModal"));
21
21
  const Types_1 = require("../../reducer/types/Types");
22
22
  const Events_1 = __importDefault(require("../../utility/Events"));
23
- const Export_1 = require("../../utility/Export");
23
+ const export_1 = require("../../utility/export");
24
24
  const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
25
25
  const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
26
26
  const PreferencesHeader_1 = __importDefault(require("../header/PreferencesHeader"));
@@ -62,7 +62,7 @@ function MultipleSpectraAnalysisPanelInner({ activeTab, spectraAnalysis, }) {
62
62
  const copyToClipboardHandler = (0, react_2.useCallback)(() => {
63
63
  void (async () => {
64
64
  const data = (0, MultipleAnalysis_1.getDataAsString)(spectraAnalysis, activeTab);
65
- const success = await (0, Export_1.copyTextToClipboard)(data);
65
+ const success = await (0, export_1.copyTextToClipboard)(data);
66
66
  if (success) {
67
67
  alert.success('Data copied to clipboard');
68
68
  }
@@ -23,7 +23,7 @@ const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
23
23
  const CopyClipboardModal_1 = __importDefault(require("../../modal/CopyClipboardModal"));
24
24
  const ChangeSumModal_1 = __importDefault(require("../../modal/changeSum/ChangeSumModal"));
25
25
  const Types_1 = require("../../reducer/types/Types");
26
- const Export_1 = require("../../utility/Export");
26
+ const export_1 = require("../../utility/export");
27
27
  const formatNumber_1 = require("../../utility/formatNumber");
28
28
  const DefaultPanelHeader_1 = __importDefault(require("../header/DefaultPanelHeader"));
29
29
  const useEditRangeModal_1 = __importDefault(require("./hooks/useEditRangeModal"));
@@ -98,7 +98,7 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
98
98
  }, [dispatch, id]);
99
99
  const saveToClipboardHandler = (0, react_2.useCallback)((value) => {
100
100
  void (async () => {
101
- const success = await (0, Export_1.copyHTMLToClipboard)(value);
101
+ const success = await (0, export_1.copyHTMLToClipboard)(value);
102
102
  if (success) {
103
103
  alert.success('Data copied to clipboard');
104
104
  }
@@ -16,7 +16,7 @@ const usePanelPreferences_1 = require("../../hooks/usePanelPreferences");
16
16
  const useSpectrum_1 = __importDefault(require("../../hooks/useSpectrum"));
17
17
  const Reducer_1 = require("../../reducer/Reducer");
18
18
  const Types_1 = require("../../reducer/types/Types");
19
- const Export_1 = require("../../utility/Export");
19
+ const export_1 = require("../../utility/export");
20
20
  const BasicPanelStyle_1 = require("../extra/BasicPanelStyle");
21
21
  const NoTableData_1 = __importDefault(require("../extra/placeholder/NoTableData"));
22
22
  const PreferencesHeader_1 = __importDefault(require("../header/PreferencesHeader"));
@@ -79,7 +79,7 @@ function RangesTablePanelInner({ id, ranges, data, info, xDomain, preferences, a
79
79
  y: Array.from(re.slice(fromIndex, toIndex)),
80
80
  ...value,
81
81
  };
82
- const success = await (0, Export_1.copyTextToClipboard)(JSON.stringify(dataToClipboard, undefined, 2));
82
+ const success = await (0, export_1.copyTextToClipboard)(JSON.stringify(dataToClipboard, undefined, 2));
83
83
  if (success) {
84
84
  alert.show('Data copied to clipboard');
85
85
  }