nmrium 0.24.1 → 0.25.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 (83) hide show
  1. package/lib/component/1d/IntegralResizable.js +13 -13
  2. package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
  3. package/lib/component/1d/ranges/Range.js +18 -28
  4. package/lib/component/NMRium.js +22 -29
  5. package/lib/component/context/GlobalContext.d.ts +12 -3
  6. package/lib/component/context/GlobalContext.js +1 -1
  7. package/lib/component/elements/ActionButtons.d.ts +10 -0
  8. package/lib/component/elements/ActionButtons.js +14 -0
  9. package/lib/component/elements/Button.d.ts +30 -5
  10. package/lib/component/elements/Button.js +150 -4
  11. package/lib/component/elements/ContextMenu.js +6 -6
  12. package/lib/component/elements/ToolTip/ToolTip.js +3 -2
  13. package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
  14. package/lib/component/elements/resizer/DivResizer.js +107 -0
  15. package/lib/component/elements/resizer/Resizer.d.ts +18 -0
  16. package/lib/component/elements/resizer/Resizer.js +12 -0
  17. package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
  18. package/lib/component/elements/resizer/SVGResizer.js +71 -0
  19. package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
  20. package/lib/component/elements/resizer/useDraggable.js +52 -0
  21. package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
  22. package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
  23. package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
  24. package/lib/component/header/RangesPickingOptionPanel.js +3 -16
  25. package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
  26. package/lib/component/header/Zones2DOptionPanel.js +3 -14
  27. package/lib/component/hooks/useExport.js +11 -9
  28. package/lib/component/loader/DropZone.js +1 -0
  29. package/lib/component/modal/AlignSpectraModal.js +2 -1
  30. package/lib/component/modal/ExportAsMatrixModal.js +2 -1
  31. package/lib/component/modal/ImportPublicationStringModal.js +2 -1
  32. package/lib/component/modal/LoadJCAMPModal.js +7 -6
  33. package/lib/component/modal/ModalStyle.js +4 -26
  34. package/lib/component/modal/MoleculeStructureEditorModal.js +2 -1
  35. package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
  36. package/lib/component/modal/PredictSpectraModal.js +2 -7
  37. package/lib/component/modal/SaveAsModal.d.ts +1 -1
  38. package/lib/component/modal/SaveAsModal.js +2 -1
  39. package/lib/component/modal/setting/GeneralSettings.js +2 -1
  40. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +10 -4
  41. package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
  42. package/lib/component/utility/Export.d.ts +3 -3
  43. package/lib/component/utility/Export.js +10 -9
  44. package/lib/versionInfo.js +1 -1
  45. package/lib-cjs/component/1d/IntegralResizable.js +12 -12
  46. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
  47. package/lib-cjs/component/1d/ranges/Range.js +18 -28
  48. package/lib-cjs/component/NMRium.js +22 -29
  49. package/lib-cjs/component/context/GlobalContext.js +1 -1
  50. package/lib-cjs/component/elements/ActionButtons.js +20 -0
  51. package/lib-cjs/component/elements/Button.js +149 -4
  52. package/lib-cjs/component/elements/ContextMenu.js +6 -6
  53. package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
  54. package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
  55. package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
  56. package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
  57. package/lib-cjs/component/elements/resizer/useDraggable.js +55 -0
  58. package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
  59. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
  60. package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
  61. package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
  62. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
  63. package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
  64. package/lib-cjs/component/hooks/useExport.js +11 -9
  65. package/lib-cjs/component/loader/DropZone.js +1 -0
  66. package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
  67. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
  68. package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
  69. package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
  70. package/lib-cjs/component/modal/ModalStyle.js +4 -26
  71. package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +5 -1
  72. package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
  73. package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
  74. package/lib-cjs/component/modal/SaveAsModal.js +2 -1
  75. package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -1
  76. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +10 -4
  77. package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
  78. package/lib-cjs/component/utility/Export.js +10 -9
  79. package/lib-cjs/versionInfo.js +1 -1
  80. package/package.json +16 -17
  81. package/lib/component/1d/Resizable.d.ts +0 -12
  82. package/lib/component/1d/Resizable.js +0 -105
  83. package/lib-cjs/component/1d/Resizable.js +0 -110
@@ -4,6 +4,7 @@ import { css } from '@emotion/react';
4
4
  import { useCallback, useRef } from 'react';
5
5
  import * as yup from 'yup';
6
6
  import { useDispatch } from '../context/DispatchContext';
7
+ import Button from '../elements/Button';
7
8
  import CloseButton from '../elements/CloseButton';
8
9
  import FormikForm from '../elements/formik/FormikForm';
9
10
  import FormikTextarea from '../elements/formik/FormikTextarea';
@@ -51,6 +52,6 @@ function ImportPublicationStringModal({ onClose, }) {
51
52
  }, [alert, dispatch, onClose]);
52
53
  return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Import from publication string" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsx(FormikForm, { ref: formRef, initialValues: {
53
54
  publicationText: '1H NMR (CDCl3, 400MHz) δ 10.58 (b, 1H), 7.40 (d, 1H, J = 8.0 Hz), 6.19 (d, 1H, J = 7.6 Hz), 4.88 (s, 1H), 2.17 (s, 3H), 1.02 (s, 9H), 1.01 (s, 9H), 0.89 (s, 9H)',
54
- }, validationSchema: validationSchema, onSubmit: publicationStringHandler, children: _jsx(FormikTextarea, { name: "publicationText", className: "text-area", placeholder: "Enter publication string" }) }) }), _jsx("div", { className: "footer-container", children: _jsx("button", { type: "button", onClick: () => formRef.current.submitForm(), className: "btn primary", children: "Import" }) })] }));
55
+ }, validationSchema: validationSchema, onSubmit: publicationStringHandler, children: _jsx(FormikTextarea, { name: "publicationText", className: "text-area", placeholder: "Enter publication string" }) }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), children: "Import" }) })] }));
55
56
  }
56
57
  export default ImportPublicationStringModal;
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
4
  import { useRef, useCallback } from 'react';
5
+ import Button from '../elements/Button';
5
6
  import CloseButton from '../elements/CloseButton';
6
7
  import { loadFile, extractFileMetaFromPath } from '../utility/FileUtility';
7
8
  const styles = css `
@@ -33,12 +34,13 @@ const styles = css `
33
34
  .container {
34
35
  display: flex;
35
36
  margin: 30px 5px;
36
- input,
37
- button {
37
+ align-items: center;
38
+ height: 36px;
39
+
40
+ input {
38
41
  padding: 5px;
39
42
  border: 1px solid gray;
40
43
  border-radius: 5px;
41
- height: 36px;
42
44
  margin: 2px;
43
45
  }
44
46
  input {
@@ -46,8 +48,7 @@ const styles = css `
46
48
  }
47
49
  button {
48
50
  flex: 2;
49
- color: white;
50
- background-color: gray;
51
+ height: 100%;
51
52
  }
52
53
  }
53
54
  `;
@@ -73,5 +74,5 @@ export default function LoadJCAMPModal({ onLoadClick, onClose, startLoading, })
73
74
  onLoadClick(null);
74
75
  }
75
76
  }, [onLoadClick, startLoading]);
76
- return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Load JCAMP Dialog" }), _jsx(CloseButton, { onClick: onClose })] }), _jsxs("div", { className: "container", children: [_jsx("input", { ref: pathReft, type: "text", placeholder: "Enter URL to JCAMP-DX file" }), _jsx("button", { type: "button", onClick: loadJCAMPHandler, children: "Load" })] })] }));
77
+ return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Load JCAMP Dialog" }), _jsx(CloseButton, { onClick: onClose })] }), _jsxs("div", { className: "container", children: [_jsx("input", { ref: pathReft, type: "text", placeholder: "Enter URL to JCAMP-DX file" }), _jsx(Button.Done, { onClick: loadJCAMPHandler, children: "Load" })] })] }));
77
78
  }
@@ -28,34 +28,12 @@ export const ModalStyles = css `
28
28
  overflow: auto;
29
29
  }
30
30
 
31
- button:focus {
32
- outline: none;
33
- }
34
- button:not([disabled]):hover {
35
- color: black;
36
- }
37
- .btn:not([disabled]):hover {
38
- background-color: #ffffff;
39
- }
40
- .btn:disabled {
41
- opacity: 0.5;
42
- }
43
- .btn {
44
- border: none;
45
- padding: 0 15px;
46
- background-color: #ffffff5e;
47
- border-radius: 5px;
48
- height: 25px;
49
- }
50
-
51
- .primary {
52
- background-color: #e2e2e2;
53
- }
54
-
55
31
  .footer-container {
56
32
  display: flex;
57
- flex-direction: row-reverse;
58
- align-items: flex-end;
33
+ flex-direction: row;
34
+ align-items: end;
35
+ justify-content: end;
36
+
59
37
  background: rgb(242, 242, 242);
60
38
  background: -moz-linear-gradient(
61
39
  0deg,
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { useState, useEffect, useCallback } from 'react';
4
4
  import { StructureEditor } from 'react-ocl/full';
5
5
  import { useDispatch } from '../context/DispatchContext';
6
+ import ActionButtons from '../elements/ActionButtons';
6
7
  import { SET_MOLECULE, ADD_MOLECULE } from '../reducer/types/Types';
7
8
  import { ModalStyles } from './ModalStyle';
8
9
  function MoleculeStructureEditorModal(props) {
@@ -34,6 +35,6 @@ function MoleculeStructureEditorModal(props) {
34
35
  onClose('new');
35
36
  }
36
37
  }, [dispatch, selectedMolecule, molfile, onClose]);
37
- return (_jsxs("div", { css: ModalStyles, children: [_jsx(StructureEditor, { initialMolfile: selectedMolecule?.molfile, svgMenu: true, fragment: false, onChange: cb }), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", className: "btn", onClick: handleSave, disabled: !molfile, children: "Save" }), _jsx("button", { type: "button", className: "btn", onClick: handleClose, children: "Close" })] })] }));
38
+ return (_jsxs("div", { css: ModalStyles, children: [_jsx(StructureEditor, { initialMolfile: selectedMolecule?.molfile, svgMenu: true, fragment: false, onChange: cb }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleClose }) })] }));
38
39
  }
39
40
  export default MoleculeStructureEditorModal;
@@ -5,6 +5,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import * as Filters from '../../../data/Filters';
6
6
  import { REFERENCES } from '../../../data/constants/References';
7
7
  import { useDispatch } from '../../context/DispatchContext';
8
+ import ActionButtons from '../../elements/ActionButtons';
8
9
  import CloseButton from '../../elements/CloseButton';
9
10
  import Select from '../../elements/Select';
10
11
  import FormikForm from '../../elements/formik/FormikForm';
@@ -114,6 +115,6 @@ function MultipleSpectraFiltersModal({ onClose = () => null, nucleus = '', }) {
114
115
  break;
115
116
  }
116
117
  }, [filter, submitHandler]);
117
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Apply filters" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "inner-content container", children: [_jsx("p", { className: "infoText", children: "This filter will use the exclusions zones defined in the first spectrum." }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Filter :" }), _jsx(Select, { data: List, style: { width: 275, height: 30, margin: 0 }, onChange: filterChangeHandler })] }), filterOptions] }), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", onClick: handleSave, className: "btn primary", children: "Apply" }), _jsx("button", { type: "button", onClick: onClose, className: "btn", children: "Close" })] })] }));
118
+ return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Apply filters" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "inner-content container", children: [_jsx("p", { className: "infoText", children: "This filter will use the exclusions zones defined in the first spectrum." }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Filter :" }), _jsx(Select, { data: List, style: { width: 275, height: 30, margin: 0 }, onChange: filterChangeHandler })] }), filterOptions] }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: onClose, cancelLabel: "Close" }) })] }));
118
119
  }
119
120
  export default MultipleSpectraFiltersModal;
@@ -7,6 +7,7 @@ import { defaultPredictionOptions, FREQUENCIES, } from '../../data/PredictionMan
7
7
  import generateNumbersPowerOfX from '../../data/utilities/generateNumbersPowerOfX';
8
8
  import { useChartData } from '../context/ChartContext';
9
9
  import { useDispatch } from '../context/DispatchContext';
10
+ import Button from '../elements/Button';
10
11
  import CheckBox from '../elements/CheckBox';
11
12
  import CloseButton from '../elements/CloseButton';
12
13
  import IsotopesViewer from '../elements/IsotopesViewer';
@@ -60,12 +61,6 @@ const styles = css `
60
61
  }
61
62
  }
62
63
 
63
- button[disabled],
64
- button[disabled]:hover {
65
- opacity: 0.5;
66
- color: black;
67
- }
68
-
69
64
  .middle-x {
70
65
  padding: 0 10px;
71
66
  }
@@ -161,6 +156,6 @@ function PredictSpectraModal({ onClose = () => null, molfile, }) {
161
156
  const approveCheckHandler = useCallback((e) => {
162
157
  setApproved(e.target.checked);
163
158
  }, []);
164
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Prediction of NMR spectrum" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "inner-content", children: [_jsxs(FormikForm, { ref: refForm, initialValues: initValues, validationSchema: predictionFormValidation, onSubmit: submitHandler, children: [_jsx(FormikErrorsSummary, {}), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Name :" }), _jsx(FormikInput, { name: "name", style: { input: { width: '200px', textAlign: 'left' } } })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Spectrometer Frequency :" }), _jsx(FormikSelect, { data: FREQUENCIES, style: { width: 290, height: 30, margin: 0 }, name: "frequency" })] }), _jsx("span", { className: "group-label", children: "1D Options " }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx(IsotopesViewer, { value: "1H", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.1H.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.1H.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx(IsotopesViewer, { value: "13C", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.13C.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.13C.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Line Width : " }), _jsx(FormikInput, { name: "1d.lineWidth", type: "number", style: { input: { margin: 0 } } }), _jsx("span", { style: { paddingLeft: '0.4rem' }, children: " Hz " })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Number of Points : " }), _jsx(FormikSelect, { data: NUMBER_OF_POINTS_1D, name: "1d.nbPoints", style: { width: 290, height: 30, margin: 0 } })] }), _jsx("span", { className: "group-label", children: "2D Options " }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Number of Points : " }), _jsx(FormikSelect, { data: NUMBER_OF_POINTS_2D, name: "2d.nbPoints.x", style: { margin: 0, height: 30 } }), _jsx("span", { className: "middle-x", children: " X " }), _jsx(FormikSelect, { data: NUMBER_OF_POINTS_2D, name: "2d.nbPoints.y", style: { margin: 0, height: 30 } })] }), _jsx("div", { className: "row margin-10", children: _jsx("span", { className: "group-label", children: "Spectra " }) }), _jsxs("div", { className: "row margin-10 padding-h-10", style: { justifyContent: 'space-between' }, children: [_jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.proton" }), _jsx(IsotopesViewer, { value: "1H", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.carbon" }), _jsx(IsotopesViewer, { value: "13C", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.cosy" }), _jsx(IsotopesViewer, { value: "COSY", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.hsqc" }), _jsx(IsotopesViewer, { value: "HSQC", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.hmbc" }), _jsx(IsotopesViewer, { value: "HMBC", className: "nucleus-label" })] })] })] }), _jsx("p", { className: "warning", children: "In order to predict spectra we are calling an external service and the chemical structure will leave your browser! You should never predict spectra for confidential molecules." }), _jsxs("div", { className: "warning-container", children: [_jsx(CheckBox, { onChange: approveCheckHandler, checked: isApproved }, String(isApproved)), _jsx("p", { children: "I confirm that the chemical structure is not confidential." })] })] }), _jsx("div", { className: "footer-container", children: _jsx("button", { type: "button", onClick: handleSave, className: "btn", disabled: !isApproved, children: "Predict spectrum" }) })] }));
159
+ return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Prediction of NMR spectrum" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "inner-content", children: [_jsxs(FormikForm, { ref: refForm, initialValues: initValues, validationSchema: predictionFormValidation, onSubmit: submitHandler, children: [_jsx(FormikErrorsSummary, {}), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Name :" }), _jsx(FormikInput, { name: "name", style: { input: { width: '200px', textAlign: 'left' } } })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Spectrometer Frequency :" }), _jsx(FormikSelect, { data: FREQUENCIES, style: { width: 290, height: 30, margin: 0 }, name: "frequency" })] }), _jsx("span", { className: "group-label", children: "1D Options " }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx(IsotopesViewer, { value: "1H", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.1H.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.1H.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx(IsotopesViewer, { value: "13C", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.13C.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.13C.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Line Width : " }), _jsx(FormikInput, { name: "1d.lineWidth", type: "number", style: { input: { margin: 0 } } }), _jsx("span", { style: { paddingLeft: '0.4rem' }, children: " Hz " })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Number of Points : " }), _jsx(FormikSelect, { data: NUMBER_OF_POINTS_1D, name: "1d.nbPoints", style: { width: 290, height: 30, margin: 0 } })] }), _jsx("span", { className: "group-label", children: "2D Options " }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Number of Points : " }), _jsx(FormikSelect, { data: NUMBER_OF_POINTS_2D, name: "2d.nbPoints.x", style: { margin: 0, height: 30 } }), _jsx("span", { className: "middle-x", children: " X " }), _jsx(FormikSelect, { data: NUMBER_OF_POINTS_2D, name: "2d.nbPoints.y", style: { margin: 0, height: 30 } })] }), _jsx("div", { className: "row margin-10", children: _jsx("span", { className: "group-label", children: "Spectra " }) }), _jsxs("div", { className: "row margin-10 padding-h-10", style: { justifyContent: 'space-between' }, children: [_jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.proton" }), _jsx(IsotopesViewer, { value: "1H", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.carbon" }), _jsx(IsotopesViewer, { value: "13C", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.cosy" }), _jsx(IsotopesViewer, { value: "COSY", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.hsqc" }), _jsx(IsotopesViewer, { value: "HSQC", className: "nucleus-label" })] }), _jsxs("div", { className: "row", children: [_jsx(FormikCheckBox, { name: "spectra.hmbc" }), _jsx(IsotopesViewer, { value: "HMBC", className: "nucleus-label" })] })] })] }), _jsx("p", { className: "warning", children: "In order to predict spectra we are calling an external service and the chemical structure will leave your browser! You should never predict spectra for confidential molecules." }), _jsxs("div", { className: "warning-container", children: [_jsx(CheckBox, { onChange: approveCheckHandler, checked: isApproved }, String(isApproved)), _jsx("p", { children: "I confirm that the chemical structure is not confidential." })] })] }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: handleSave, disabled: !isApproved, children: "Predict spectrum" }) })] }));
165
160
  }
166
161
  export default PredictSpectraModal;
@@ -1,5 +1,5 @@
1
1
  interface SaveAsModalProps {
2
- onClose?: (element?: any) => void;
2
+ onClose?: (event?: MouseEvent) => void;
3
3
  onSave: (element: any) => void;
4
4
  name: string;
5
5
  }
@@ -4,6 +4,7 @@ import { css } from '@emotion/react';
4
4
  import { Field } from 'formik';
5
5
  import { useCallback, useRef } from 'react';
6
6
  import { DataExportOptions } from '../../data/SpectraManager';
7
+ import ActionButtons from '../elements/ActionButtons';
7
8
  import CloseButton from '../elements/CloseButton';
8
9
  import FormikCheckBox from '../elements/formik/FormikCheckBox';
9
10
  import FormikForm from '../elements/formik/FormikForm';
@@ -56,6 +57,6 @@ function SaveAsModal({ onClose, onSave, name }) {
56
57
  }, [onClose, onSave]);
57
58
  return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Save as ... " }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsxs(FormikForm, { ref: refForm, initialValues: { ...INITIAL_VALUE, name }, onSubmit: submitHandler, children: [_jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Name" }), _jsx(FormikInput, { name: "name", className: "name", style: {
58
59
  inputWrapper: { width: '100%' },
59
- } })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Compressed" }), _jsx(FormikCheckBox, { name: "compressed" })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Pretty Format" }), _jsx(FormikCheckBox, { name: "pretty" })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: " Include " }), _jsxs("div", { className: "data-export-group", children: [_jsxs("label", { children: [_jsx(Field, { type: "radio", name: "dataExportOption", value: DataExportOptions.ROW_DATA }), "Raw Data"] }), _jsxs("label", { children: [_jsx(Field, { type: "radio", name: "dataExportOption", value: DataExportOptions.DATA_SOURCE }), "Data Source"] })] })] })] }) }), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", onClick: handleSave, className: "btn primary", children: "Save" }), _jsx("button", { type: "button", onClick: onClose, className: "btn", children: "Close" })] })] }));
60
+ } })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Compressed" }), _jsx(FormikCheckBox, { name: "compressed" })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Pretty Format" }), _jsx(FormikCheckBox, { name: "pretty" })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: " Include " }), _jsxs("div", { className: "data-export-group", children: [_jsxs("label", { children: [_jsx(Field, { type: "radio", name: "dataExportOption", value: DataExportOptions.ROW_DATA }), "Raw Data"] }), _jsxs("label", { children: [_jsx(Field, { type: "radio", name: "dataExportOption", value: DataExportOptions.DATA_SOURCE }), "Data Source"] })] })] })] }) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: () => onClose?.() }) })] }));
60
61
  }
61
62
  export default SaveAsModal;
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { css } from '@emotion/react';
4
4
  import { useCallback, useMemo, useRef, useState } from 'react';
5
5
  import { usePreferences, useWorkspacesList, } from '../../context/PreferencesContext';
6
+ import ActionButtons from '../../elements/ActionButtons';
6
7
  import CloseButton from '../../elements/CloseButton';
7
8
  import Tab from '../../elements/Tab/Tab';
8
9
  import Tabs, { PositionsEnum } from '../../elements/Tab/Tabs';
@@ -145,6 +146,6 @@ function GeneralSettings({ onClose }) {
145
146
  const renderItem = useCallback((item) => {
146
147
  return (_jsx(WorkspaceItem, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
147
148
  }, [addWorkSpaceHandler, deleteWorkSpaceHandler]);
148
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", onClick: handleSave, className: "btn", children: "Save" }), _jsx("button", { type: "button", onClick: handleReset, className: "btn", children: "Reset" })] })] }));
149
+ return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
149
150
  }
150
151
  export default GeneralSettings;
@@ -6,6 +6,7 @@ import { useCallback } from 'react';
6
6
  import { FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
7
7
  import { useAssignmentData } from '../../assignment';
8
8
  import { useDispatch } from '../../context/DispatchContext';
9
+ import { useGlobal } from '../../context/GlobalContext';
9
10
  import ButtonToolTip from '../../elements/ButtonToolTip';
10
11
  import MenuButton from '../../elements/MenuButton';
11
12
  import ToolTip from '../../elements/ToolTip/ToolTip';
@@ -56,17 +57,22 @@ const MOL_EXPORT_MENU = [
56
57
  },
57
58
  ];
58
59
  export default function MoleculePanelHeader({ currentIndex, molecules, onMoleculeIndexChange = () => null, onOpenMoleculeEditor = () => null, actionsOptions = {}, }) {
60
+ const { rootRef } = useGlobal();
59
61
  const alert = useAlert();
60
62
  const dispatch = useDispatch();
61
63
  const modal = useModal();
62
64
  const assignmentData = useAssignmentData();
63
65
  const saveAsSVGHandler = useCallback(() => {
64
- exportAsSVG(`molSVG${currentIndex}`, 'molFile');
65
- }, [currentIndex]);
66
+ if (!rootRef)
67
+ return;
68
+ exportAsSVG(rootRef, `molSVG${currentIndex}`, 'molFile');
69
+ }, [rootRef, currentIndex]);
66
70
  const saveAsPNGHandler = useCallback(() => {
67
- copyPNGToClipboard(`molSVG${currentIndex}`);
71
+ if (!rootRef)
72
+ return;
73
+ copyPNGToClipboard(rootRef, `molSVG${currentIndex}`);
68
74
  alert.success('MOL copied as PNG to clipboard');
69
- }, [alert, currentIndex]);
75
+ }, [rootRef, alert, currentIndex]);
70
76
  const saveAsMolHandler = useCallback(() => {
71
77
  if (molecules[currentIndex]) {
72
78
  void copyTextToClipboard(molecules[currentIndex].molfile).then((flag) => {
@@ -4,6 +4,7 @@ import { css } from '@emotion/react';
4
4
  import { useCallback, useRef } from 'react';
5
5
  import * as Yup from 'yup';
6
6
  import { defaultPredictionOptions, FREQUENCIES, } from '../../../data/PredictionManager';
7
+ import Button from '../../elements/Button';
7
8
  import IsotopesViewer from '../../elements/IsotopesViewer';
8
9
  import Label from '../../elements/Label';
9
10
  import FormikErrorsSummary from '../../elements/formik/FormikErrorsSummary';
@@ -34,23 +35,6 @@ const styles = css `
34
35
  align-items: flex-end;
35
36
  }
36
37
 
37
- .btn:not([disabled]):hover {
38
- background-color: #ffffff;
39
- }
40
- .btn:hover {
41
- background-color: #f2f2f2 !important;
42
- }
43
- .btn:disabled {
44
- opacity: 0.5;
45
- }
46
- .btn {
47
- border: none;
48
- padding: 0 15px;
49
- background-color: #ffffff;
50
- border-radius: 5px;
51
- height: 25px;
52
- }
53
-
54
38
  .input {
55
39
  font-size: 14px;
56
40
  border-radius: 5px;
@@ -85,6 +69,6 @@ function PredictionOptions({ onPredict = () => null }) {
85
69
  onPredict(values);
86
70
  })();
87
71
  }, [onPredict]);
88
- return (_jsxs("div", { css: styles, children: [_jsx("div", { children: _jsxs(FormikForm, { ref: refForm, initialValues: defaultPredictionOptions, validationSchema: predictionFormValidation, onSubmit: submitHandler, children: [_jsx(FormikErrorsSummary, {}), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Frequency : " }), _jsx(FormikSelect, { data: FREQUENCIES, style: { width: 290, height: 30, margin: 0 }, name: "frequency" })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "1H", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.1H.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.1H.to", type: "number" }) })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "13C", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.13C.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.13C.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Line Width : " }), _jsx(FormikInput, { name: "1d.lineWidth", type: "number", style: { input: { margin: 0 } } }), _jsx("span", { style: { paddingLeft: '0.4rem' }, children: " Hz " })] })] }) }), _jsx("div", { children: _jsx("button", { type: "button", onClick: handleSave, className: "btn", children: "Predict spectrum" }) })] }));
72
+ return (_jsxs("div", { css: styles, children: [_jsx("div", { children: _jsxs(FormikForm, { ref: refForm, initialValues: defaultPredictionOptions, validationSchema: predictionFormValidation, onSubmit: submitHandler, children: [_jsx(FormikErrorsSummary, {}), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Frequency : " }), _jsx(FormikSelect, { data: FREQUENCIES, style: { width: 290, height: 30, margin: 0 }, name: "frequency" })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "1H", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.1H.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.1H.to", type: "number" }) })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "13C", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.13C.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.13C.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Line Width : " }), _jsx(FormikInput, { name: "1d.lineWidth", type: "number", style: { input: { margin: 0 } } }), _jsx("span", { style: { paddingLeft: '0.4rem' }, children: " Hz " })] })] }) }), _jsx("div", { children: _jsx(Button.Done, { onClick: handleSave, children: "Predict spectrum" }) })] }));
89
73
  }
90
74
  export default PredictionOptions;
@@ -11,7 +11,7 @@ declare function exportAsMol(data: any, fileName?: string): void;
11
11
  /**
12
12
  * export the vitalization result as SVG, if you need to remove some content during exportation process enclose the the content with <!-- export-remove --> ${content} <!-- export-remove -->
13
13
  */
14
- declare function exportAsSVG(elementID: any, fileName?: string): void;
15
- declare function exportAsPng(elementID: any, fileName?: string): void;
16
- declare function copyPNGToClipboard(elementID: any): void;
14
+ declare function exportAsSVG(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
15
+ declare function exportAsPng(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
16
+ declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string): void;
17
17
  export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, copyTextToClipboard, copyHTMLToClipboard, exportAsMol, exportAsMatrix, };
@@ -109,12 +109,12 @@ function exportAsMol(data, fileName = 'mol') {
109
109
  /**
110
110
  * export the vitalization result as SVG, if you need to remove some content during exportation process enclose the the content with <!-- export-remove --> ${content} <!-- export-remove -->
111
111
  */
112
- function exportAsSVG(elementID, fileName = 'experiment') {
113
- const { blob } = getBlob(elementID);
112
+ function exportAsSVG(rootRef, elementID, fileName = 'experiment') {
113
+ const { blob } = getBlob(rootRef, elementID);
114
114
  saveAs(blob, `${fileName}.svg`);
115
115
  }
116
- function exportAsPng(elementID, fileName = 'experiment') {
117
- const { blob, width, height } = getBlob(elementID);
116
+ function exportAsPng(rootRef, elementID, fileName = 'experiment') {
117
+ const { blob, width, height } = getBlob(rootRef, elementID);
118
118
  try {
119
119
  let canvas = document.createElement('canvas');
120
120
  canvas.width = width;
@@ -166,8 +166,8 @@ function copyBlobToCliboard(canvas) {
166
166
  });
167
167
  });
168
168
  }
169
- function copyPNGToClipboard(elementID) {
170
- const { blob, width, height } = getBlob(elementID);
169
+ function copyPNGToClipboard(rootRef, elementID) {
170
+ const { blob, width, height } = getBlob(rootRef, elementID);
171
171
  try {
172
172
  let canvas = document.createElement('canvas');
173
173
  canvas.width = width;
@@ -202,9 +202,10 @@ function copyPNGToClipboard(elementID) {
202
202
  console.log(e);
203
203
  }
204
204
  }
205
- function getBlob(elementID) {
206
- // nmrSVG
207
- let _svg = document.getElementById(elementID)?.cloneNode(true);
205
+ function getBlob(rootRef, elementID) {
206
+ let _svg = rootRef.getRootNode()
207
+ .getElementById(elementID)
208
+ ?.cloneNode(true);
208
209
  const width = _svg?.getAttribute('width').replace('px', '');
209
210
  const height = _svg?.getAttribute('height').replace('px', '');
210
211
  _svg
@@ -1 +1 @@
1
- export default { version: 'v0.24.1' };
1
+ export default { version: 'v0.25.0' };
@@ -10,9 +10,9 @@ const react_2 = require("react");
10
10
  const ChartContext_1 = require("../context/ChartContext");
11
11
  const DispatchContext_1 = require("../context/DispatchContext");
12
12
  const ScaleContext_1 = require("../context/ScaleContext");
13
+ const Resizer_1 = __importDefault(require("../elements/resizer/Resizer"));
13
14
  const index_1 = require("../highlight/index");
14
15
  const Types_1 = require("../reducer/types/Types");
15
- const Resizable_1 = __importDefault(require("./Resizable"));
16
16
  const stylesOnHover = (0, react_1.css) `
17
17
  pointer-events: bounding-box;
18
18
  @-moz-document url-prefix() {
@@ -41,31 +41,31 @@ function IntegralResizable({ integralData }) {
41
41
  const { height, margin } = (0, ChartContext_1.useChartData)();
42
42
  const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
43
43
  const dispatch = (0, DispatchContext_1.useDispatch)();
44
- const [{ id, integral, from, to }, setIntegral] = (0, react_2.useState)(integralData);
44
+ const { id, from, to, integral } = integralData;
45
45
  const highlight = (0, index_1.useHighlight)([id], {
46
46
  type: index_1.HighlightedSource.INTEGRAL,
47
47
  extra: { id },
48
48
  });
49
- (0, react_2.useEffect)(() => {
50
- setIntegral(integralData);
51
- }, [integralData]);
52
- const handleOnStopResizing = (0, react_2.useCallback)((resized) => {
49
+ const handleOnStopResizing = (0, react_2.useCallback)((position) => {
53
50
  dispatch({
54
51
  type: Types_1.RESIZE_INTEGRAL,
55
- payload: { data: { ...integralData, ...resized } },
52
+ payload: {
53
+ data: {
54
+ ...integralData,
55
+ from: scaleX().invert(position.x2),
56
+ to: scaleX().invert(position.x1),
57
+ },
58
+ },
56
59
  });
57
- }, [dispatch, integralData]);
60
+ }, [dispatch, integralData, scaleX]);
58
61
  const handleOnEnterNotation = (0, react_2.useCallback)(() => {
59
62
  highlight.show();
60
63
  }, [highlight]);
61
64
  const handleOnMouseLeaveNotation = (0, react_2.useCallback)(() => {
62
65
  highlight.hide();
63
66
  }, [highlight]);
64
- const dragHandler = (0, react_2.useCallback)((boundary) => {
65
- setIntegral((integral) => ({ ...integral, ...boundary }));
66
- }, []);
67
67
  const x0 = from ? scaleX()(from) : 0;
68
68
  const x1 = to ? scaleX()(to) : 0;
69
- return ((0, jsx_runtime_1.jsxs)("g", { css: highlight.isActive ? stylesHighlighted : stylesOnHover, onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: [(0, jsx_runtime_1.jsx)("rect", { "data-no-export": "true", x: `${x1}`, y: "0", width: `${x0 - x1}`, height: height - margin.bottom, className: "highlight" }), (0, jsx_runtime_1.jsx)("text", { x: x1, y: height - margin.bottom + 30, fill: "black", style: { fontSize: '12px', fontWeight: 'bold' }, children: integral !== undefined ? integral.toFixed(2) : '' }), (0, jsx_runtime_1.jsx)(Resizable_1.default, { from: integralData.from, to: integralData.to, onDrag: dragHandler, onDrop: handleOnStopResizing, "data-no-export": "true" })] }));
69
+ return ((0, jsx_runtime_1.jsx)("g", { css: highlight.isActive ? stylesHighlighted : stylesOnHover, onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: x1, x2: x0 }, onEnd: handleOnStopResizing, children: (x1, x2) => ((0, jsx_runtime_1.jsxs)("g", { 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 ? integral.toFixed(2) : '' })] })) }) }));
70
70
  }
71
71
  exports.default = IntegralResizable;
@@ -10,37 +10,33 @@ const react_2 = require("react");
10
10
  const DispatchContext_1 = require("../../context/DispatchContext");
11
11
  const ScaleContext_1 = require("../../context/ScaleContext");
12
12
  const DeleteButton_1 = __importDefault(require("../../elements/DeleteButton"));
13
+ const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
13
14
  const highlight_1 = require("../../highlight");
14
15
  const Types_1 = require("../../reducer/types/Types");
15
- const Resizable_1 = __importDefault(require("../Resizable"));
16
- const stylesOnHover = (0, react_1.css) `
17
- pointer-events: bounding-box;
18
- @-moz-document url-prefix() {
19
- pointer-events: fill;
20
- }
21
- user-select: 'none';
22
- -webkit-user-select: none; /* Chrome all / Safari all */
23
- -moz-user-select: none; /* Firefox all */
16
+ const styles = {
17
+ common: (0, react_1.css) `
18
+ pointer-events: bounding-box;
24
19
 
25
- .delete-button {
26
- visibility: hidden;
27
- }
28
- `;
29
- const stylesHighlighted = (0, react_1.css) `
30
- pointer-events: bounding-box;
31
-
32
- @-moz-document url-prefix() {
33
- pointer-events: fill;
34
- }
35
- .range-area {
36
- height: 100%;
37
- fill: #ff6f0057;
38
- }
39
- .delete-button {
40
- visibility: visible;
41
- cursor: pointer;
42
- }
43
- `;
20
+ @-moz-document url-prefix() {
21
+ pointer-events: fill;
22
+ }
23
+ `,
24
+ hover: (0, react_1.css) `
25
+ .delete-button {
26
+ visibility: hidden;
27
+ }
28
+ `,
29
+ Highlighted: (0, react_1.css) `
30
+ .range-area {
31
+ height: 100%;
32
+ fill: #ff6f0057;
33
+ }
34
+ .delete-button {
35
+ visibility: visible;
36
+ cursor: pointer;
37
+ }
38
+ `,
39
+ };
44
40
  function AnalysisRange({ rangeData, columnKey }) {
45
41
  const { from, to } = rangeData;
46
42
  const highlight = (0, highlight_1.useHighlight)([columnKey]);
@@ -49,12 +45,15 @@ function AnalysisRange({ rangeData, columnKey }) {
49
45
  const deleteHandler = (0, react_2.useCallback)(() => {
50
46
  dispatch({ type: Types_1.DELETE_ANALYZE_SPECTRA_RANGE, colKey: columnKey });
51
47
  }, [columnKey, dispatch]);
52
- const handleOnStopResizing = (0, react_2.useCallback)((resized) => {
48
+ const resizeEndHandler = (0, react_2.useCallback)((resized) => {
53
49
  dispatch({
54
50
  type: Types_1.RESIZE_ANALYZE_SPECTRA_RANGE,
55
51
  payload: { ...rangeData, ...resized, columnKey },
56
52
  });
57
53
  }, [columnKey, dispatch, rangeData]);
58
- return ((0, jsx_runtime_1.jsxs)("g", { ...highlight.onHover, css: highlight.isActive ? stylesHighlighted : stylesOnHover, children: [(0, jsx_runtime_1.jsxs)("g", { transform: `translate(${scaleX()(to)},25)`, children: [(0, jsx_runtime_1.jsx)("rect", { x: "0", width: scaleX()(from) - scaleX()(to), height: "6", className: "range-area", fill: "green" }), (0, jsx_runtime_1.jsx)("text", { textAnchor: "middle", x: (scaleX()(from) - scaleX()(to)) / 2, y: "-5", fontSize: "12", fill: "red", fontWeight: "bolder", fillOpacity: highlight.isActive ? 1 : 0.6, children: columnKey })] }), (0, jsx_runtime_1.jsx)(Resizable_1.default, { from: rangeData.from, to: rangeData.to, onDrop: handleOnStopResizing }), (0, jsx_runtime_1.jsx)(DeleteButton_1.default, { x: scaleX()(to) - 20, y: 10, onDelete: deleteHandler })] }));
54
+ return ((0, jsx_runtime_1.jsx)("g", { ...highlight.onHover, css: [
55
+ styles.common,
56
+ highlight.isActive ? styles.Highlighted : styles.hover,
57
+ ], children: (0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", onEnd: resizeEndHandler, initialPosition: { x2: scaleX()(from), x1: scaleX()(to) }, children: (x1, x2) => ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("g", { transform: `translate(0,25)`, children: [(0, jsx_runtime_1.jsx)("rect", { x: "0", width: x2 - x1, height: "6", className: "range-area", fill: "green" }), (0, jsx_runtime_1.jsx)("text", { textAnchor: "middle", x: (x2 - x1) / 2, y: "-5", fontSize: "12", fill: "red", fontWeight: "bolder", fillOpacity: highlight.isActive ? 1 : 0.6, children: columnKey })] }), (0, jsx_runtime_1.jsx)(DeleteButton_1.default, { x: -20, y: 10, onDelete: deleteHandler })] })) }) }));
59
58
  }
60
59
  exports.default = AnalysisRange;
@@ -11,10 +11,10 @@ const RangeUtilities_1 = require("../../../data/utilities/RangeUtilities");
11
11
  const assignment_1 = require("../../assignment");
12
12
  const DispatchContext_1 = require("../../context/DispatchContext");
13
13
  const ScaleContext_1 = require("../../context/ScaleContext");
14
+ const Resizer_1 = __importDefault(require("../../elements/resizer/Resizer"));
14
15
  const highlight_1 = require("../../highlight");
15
16
  const Types_1 = require("../../reducer/types/Types");
16
17
  const ToolTypes_1 = require("../../toolbar/ToolTypes");
17
- const Resizable_1 = __importDefault(require("../Resizable"));
18
18
  const MultiplicityTree_1 = __importDefault(require("../multiplicityTree/MultiplicityTree"));
19
19
  const TempMultiplicityTree_1 = __importDefault(require("../multiplicityTree/TempMultiplicityTree"));
20
20
  const stylesOnHover = (0, react_1.css) `
@@ -46,24 +46,14 @@ const stylesHighlighted = (0, react_1.css) `
46
46
  }
47
47
  `;
48
48
  function Range({ rangeData, showMultiplicityTrees, selectedTool, startEditMode, }) {
49
- const { id, from: rangeFrom, to: rangeTo, integration, signals } = rangeData;
49
+ const { id, from, to, integration, signals } = rangeData;
50
50
  const assignmentData = (0, assignment_1.useAssignmentData)();
51
51
  const assignmentRange = (0, assignment_1.useAssignment)(id);
52
52
  const highlightRange = (0, highlight_1.useHighlight)([assignmentRange.id].concat(assignmentRange.assigned.x || []).concat((0, assignment_1.filterForIDsWithAssignment)(assignmentData, signals.map((_signal) => _signal.id))), { type: highlight_1.HighlightedSource.RANGE, extra: { id } });
53
- const [rangeBoundary, setRangeBoundary] = (0, react_2.useState)({
54
- from: rangeFrom,
55
- to: rangeTo,
56
- });
57
53
  const { scaleX } = (0, ScaleContext_1.useScaleChecked)();
58
54
  const dispatch = (0, DispatchContext_1.useDispatch)();
59
55
  const [reduceOpacity, setReduceOpacity] = (0, react_2.useState)(false);
60
56
  const [isBlockedByEditing, setIsBlockedByEditing] = (0, react_2.useState)(false);
61
- (0, react_2.useEffect)(() => {
62
- setRangeBoundary({
63
- from: rangeFrom,
64
- to: rangeTo,
65
- });
66
- }, [rangeFrom, rangeTo]);
67
57
  (0, react_2.useEffect)(() => {
68
58
  if (selectedTool && selectedTool === ToolTypes_1.options.editRange.id) {
69
59
  setIsBlockedByEditing(true);
@@ -75,12 +65,16 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, startEditMode,
75
65
  (0, react_2.useEffect)(() => {
76
66
  setReduceOpacity(!(0, RangeUtilities_1.checkRangeKind)(rangeData));
77
67
  }, [rangeData]);
78
- const handleOnStopResizing = (0, react_2.useCallback)((resized) => {
68
+ const handleOnStopResizing = (0, react_2.useCallback)((position) => {
79
69
  dispatch({
80
70
  type: Types_1.RESIZE_RANGE,
81
- data: { ...rangeData, ...resized },
71
+ data: {
72
+ ...rangeData,
73
+ from: scaleX().invert(position.x2),
74
+ to: scaleX().invert(position.x1),
75
+ },
82
76
  });
83
- }, [dispatch, rangeData]);
77
+ }, [dispatch, rangeData, scaleX]);
84
78
  const mouseEnterHandler = (0, react_2.useCallback)(() => {
85
79
  assignmentRange.onMouseEnter('x');
86
80
  highlightRange.show();
@@ -96,23 +90,19 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, startEditMode,
96
90
  assignmentRange.onClick('x');
97
91
  }
98
92
  }, [assignmentRange, isBlockedByEditing, selectedTool]);
99
- const dragHandler = (0, react_2.useCallback)((boundary) => {
100
- setRangeBoundary((range) => ({ ...range, ...boundary }));
101
- }, []);
102
- const { from, to } = rangeBoundary;
103
93
  return ((0, jsx_runtime_1.jsxs)("g", { "data-test-id": "range", style: { outline: 'none' }, css: isBlockedByEditing ||
104
94
  highlightRange.isActive ||
105
95
  assignmentRange.isActive
106
96
  ? stylesHighlighted
107
- : stylesOnHover, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, children: [(0, jsx_runtime_1.jsxs)("g", { transform: `translate(${scaleX()(to)},10)`, children: [(0, jsx_runtime_1.jsx)("rect", { x: "0", width: Math.abs(scaleX()(from) - scaleX()(to)), height: "6", className: "range-area", fill: "green", fillOpacity: !reduceOpacity ||
108
- highlightRange.isActive ||
109
- assignmentRange.isActive
110
- ? 1
111
- : 0.4 }), (0, jsx_runtime_1.jsx)("text", { textAnchor: "middle", x: Math.abs(scaleX()(from) - scaleX()(to)) / 2, y: "20", fontSize: "10", fill: "red", fillOpacity: !reduceOpacity ||
112
- highlightRange.isActive ||
113
- assignmentRange.isActive
114
- ? 1
115
- : 0.6, children: integration !== undefined ? integration.toFixed(2) : '' })] }), (0, jsx_runtime_1.jsx)(Resizable_1.default, { from: rangeData.from, to: rangeData.to, onDrop: handleOnStopResizing, onDrag: dragHandler }), startEditMode ? ((0, jsx_runtime_1.jsx)(TempMultiplicityTree_1.default, {})) : (showMultiplicityTrees &&
97
+ : stylesOnHover, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, children: [(0, jsx_runtime_1.jsx)(Resizer_1.default, { tag: "svg", initialPosition: { x1: scaleX()(to), x2: scaleX()(from) }, onEnd: handleOnStopResizing, children: (x1, x2) => ((0, jsx_runtime_1.jsxs)("g", { transform: `translate(0,10)`, children: [(0, jsx_runtime_1.jsx)("rect", { "data-no-export": "true", x: "0", width: x2 - x1, height: "6", className: "range-area", fill: "green", fillOpacity: !reduceOpacity ||
98
+ highlightRange.isActive ||
99
+ assignmentRange.isActive
100
+ ? 1
101
+ : 0.4 }), (0, jsx_runtime_1.jsx)("text", { textAnchor: "middle", x: (x2 - x1) / 2, y: "20", fontSize: "10", fill: "red", fillOpacity: !reduceOpacity ||
102
+ highlightRange.isActive ||
103
+ assignmentRange.isActive
104
+ ? 1
105
+ : 0.6, children: integration !== undefined ? integration.toFixed(2) : '' })] })) }), startEditMode ? ((0, jsx_runtime_1.jsx)(TempMultiplicityTree_1.default, {})) : (showMultiplicityTrees &&
116
106
  signals &&
117
107
  signals.length > 0 &&
118
108
  signals.map((_signal) => ((0, jsx_runtime_1.jsx)(MultiplicityTree_1.default, { rangeFrom: from, rangeTo: to, signal: _signal }, _signal.id))))] }, id));