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
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { useEffect } from 'react';
5
+ import useDraggable from './useDraggable';
6
+ const anchorStyle = {
7
+ marginLeft: '5px',
8
+ width: '2px',
9
+ height: '100%',
10
+ pointerEvents: 'none',
11
+ position: 'relative',
12
+ };
13
+ const styles = {
14
+ container: (position) => css `
15
+ position: absolute;
16
+ height: 100%;
17
+ width: 10px;
18
+ left: -5px;
19
+ cursor: e-resize;
20
+ transform: translateX(${position}px);
21
+ user-select: none;
22
+ z-index: 99999999;
23
+
24
+ &:hover {
25
+ div {
26
+ background-color: red;
27
+ }
28
+ }
29
+ `,
30
+ content: (anchorSide, left, right) => {
31
+ const width = right.previousPosition - left.previousPosition;
32
+ const baseCss = css `
33
+ position: absolute;
34
+ width: ${width}px;
35
+ overflow: hidden;
36
+ `;
37
+ if (right.position.action === 'move' || left.position.action === 'move') {
38
+ const scale = (right.position.x - left.position.x) / width;
39
+ if (anchorSide === 'RIGHT') {
40
+ return [
41
+ baseCss,
42
+ css `
43
+ transform: translateX(${left.position.x}px) scaleX(${scale});
44
+ transform-origin: left center;
45
+ `,
46
+ ];
47
+ }
48
+ else if (anchorSide === 'LEFT') {
49
+ return css([
50
+ baseCss,
51
+ css `
52
+ transform: translateX(${left.position.x}px) scaleX(${scale});
53
+ transform-origin: left center;
54
+ `,
55
+ ]);
56
+ }
57
+ }
58
+ else {
59
+ return css([
60
+ baseCss,
61
+ css `
62
+ transform: translateX(${left.position.x}px);
63
+ `,
64
+ ]);
65
+ }
66
+ },
67
+ };
68
+ export default function DivResizer(props) {
69
+ const { children, initialPosition = { x1: 10, x2: 40 }, onStart, onMove, onEnd, } = props;
70
+ const right = useDraggable({
71
+ x: initialPosition.x2,
72
+ anchor: 'RIGHT',
73
+ });
74
+ const left = useDraggable({
75
+ x: initialPosition.x1,
76
+ anchor: 'LEFT',
77
+ });
78
+ const anchor = left.isActive
79
+ ? left.anchor
80
+ : right.isActive
81
+ ? right.anchor
82
+ : '';
83
+ useEffect(() => {
84
+ const position = { x1: left.position.x, x2: right.position.x };
85
+ const status = left.isActive
86
+ ? left.position.action
87
+ : right.isActive
88
+ ? right.position.action
89
+ : '';
90
+ switch (status) {
91
+ case 'start':
92
+ onStart?.(position);
93
+ break;
94
+ case 'move':
95
+ onMove?.(position);
96
+ break;
97
+ case 'end':
98
+ onEnd?.(position);
99
+ break;
100
+ default:
101
+ break;
102
+ }
103
+ }, [left, onEnd, onMove, onStart, right]);
104
+ return (_jsxs(_Fragment, { children: [_jsx("div", { "data-no-export": "true", onMouseDown: right.onMouseDown, css: styles.container(right.position.x), children: _jsx("div", { style: anchorStyle }) }), _jsx("div", { css: styles.content(anchor, left, right), children: typeof children === 'function'
105
+ ? children?.(left.position.x, right.position.x)
106
+ : children }), _jsx("div", { "data-no-export": "true", onMouseDown: left.onMouseDown, css: styles.container(left.position.x), children: _jsx("div", { style: anchorStyle }) })] }));
107
+ }
@@ -0,0 +1,18 @@
1
+ import { ReactFragment } from 'react';
2
+ export interface Position {
3
+ x1: number;
4
+ x2: number;
5
+ }
6
+ declare type ChildType = Array<React.ReactElement> | React.ReactElement | ReactFragment | boolean | null;
7
+ export interface ResizerProps {
8
+ children?: ChildType | ((x1: number, x2: number) => ChildType);
9
+ initialPosition?: Position;
10
+ position?: Position;
11
+ onStart?: PositionChangeHandler;
12
+ onMove?: PositionChangeHandler;
13
+ onEnd?: PositionChangeHandler;
14
+ tag?: 'div' | 'svg';
15
+ }
16
+ declare type PositionChangeHandler = (data: Position) => void;
17
+ export default function Resizer(props: ResizerProps): JSX.Element;
18
+ export {};
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import DivResizer from './DivResizer';
3
+ import SVGResizer from './SVGResizer';
4
+ export default function Resizer(props) {
5
+ const { tag = 'div', ...resProps } = props;
6
+ if (tag === 'div') {
7
+ return _jsx(DivResizer, { ...resProps });
8
+ }
9
+ else {
10
+ return _jsx(SVGResizer, { ...resProps });
11
+ }
12
+ }
@@ -0,0 +1,2 @@
1
+ import { ResizerProps } from './Resizer';
2
+ export default function SVGResizer(props: ResizerProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -0,0 +1,71 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { useEffect } from 'react';
5
+ import useDraggable from './useDraggable';
6
+ const anchorStyle = {
7
+ width: '2px',
8
+ height: '100%',
9
+ pointerEvents: 'none',
10
+ fill: 'transparent',
11
+ };
12
+ const styles = {
13
+ container: (position) => css `
14
+ transform: translateX(${position}px);
15
+
16
+ &:hover {
17
+ rect:last-child {
18
+ fill: red !important;
19
+ }
20
+ }
21
+ `,
22
+ innerContainer: css `
23
+ position: absolute;
24
+ height: 100%;
25
+ fill: transparent;
26
+ width: 10px;
27
+ cursor: e-resize;
28
+ user-select: none;
29
+ z-index: 99999999;
30
+ `,
31
+ };
32
+ export default function SVGResizer(props) {
33
+ const { children, initialPosition = { x1: 10, x2: 40 }, onStart, onMove, onEnd, } = props;
34
+ const right = useDraggable({
35
+ x: initialPosition.x2,
36
+ anchor: 'RIGHT',
37
+ });
38
+ const left = useDraggable({
39
+ x: initialPosition.x1,
40
+ anchor: 'LEFT',
41
+ });
42
+ useEffect(() => {
43
+ const position = { x1: left.position.x, x2: right.position.x };
44
+ const status = left.isActive
45
+ ? left.position.action
46
+ : right.isActive
47
+ ? right.position.action
48
+ : '';
49
+ switch (status) {
50
+ case 'start':
51
+ onStart?.(position);
52
+ break;
53
+ case 'move':
54
+ onMove?.(position);
55
+ break;
56
+ case 'end':
57
+ onEnd?.(position);
58
+ break;
59
+ default:
60
+ break;
61
+ }
62
+ }, [left, onEnd, onMove, onStart, right]);
63
+ return (_jsxs("g", { style: {
64
+ transform: `translateX(${left.position.x}px)`,
65
+ }, children: [typeof children === 'function'
66
+ ? children(left.position.x, right.position.x)
67
+ : children, _jsx(SVGResizerHandle, { onMouseDown: left.onMouseDown, position: 0 }), _jsx(SVGResizerHandle, { onMouseDown: right.onMouseDown, position: right.position.x - left.position.x })] }));
68
+ }
69
+ function SVGResizerHandle(props) {
70
+ return (_jsxs("g", { onMouseDown: props.onMouseDown, css: styles.container(props.position), "data-no-export": "true", children: [_jsx("rect", { x: "-5px", css: styles.innerContainer }), _jsx("rect", { x: "-2.5px", style: anchorStyle })] }));
71
+ }
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ interface UseDraggable {
3
+ x: number;
4
+ anchor: Anchor;
5
+ }
6
+ export interface Draggable {
7
+ onMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGElement, MouseEvent>) => void;
8
+ position: {
9
+ x: number;
10
+ action: Action;
11
+ };
12
+ previousPosition: number;
13
+ isActive: boolean;
14
+ anchor: Anchor;
15
+ }
16
+ declare type Action = 'start' | 'move' | 'end' | null;
17
+ export declare type Anchor = 'RIGHT' | 'LEFT';
18
+ export default function useDraggable(props: UseDraggable): Draggable;
19
+ export {};
@@ -0,0 +1,52 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ export default function useDraggable(props) {
3
+ const { x, anchor } = props;
4
+ const isActive = useRef(false);
5
+ const positionRef = useRef({
6
+ relativeX: x,
7
+ x,
8
+ });
9
+ const [position, setPosition] = useState({
10
+ x,
11
+ action: null,
12
+ });
13
+ useEffect(() => {
14
+ positionRef.current = { relativeX: x, x };
15
+ setPosition({ x, action: null });
16
+ }, [x]);
17
+ const onMouseDown = useCallback((e) => {
18
+ setPosition({ x: positionRef.current.x, action: 'start' });
19
+ positionRef.current.relativeX = e.clientX - positionRef.current.relativeX;
20
+ isActive.current = true;
21
+ e.stopPropagation();
22
+ function onMouseUp(e) {
23
+ e.stopPropagation();
24
+ if (isActive.current) {
25
+ const x = e.clientX - positionRef.current.relativeX;
26
+ positionRef.current = { relativeX: x, x };
27
+ setPosition({ x, action: 'end' });
28
+ isActive.current = false;
29
+ }
30
+ window.removeEventListener('mousemove', onMouseMove);
31
+ window.removeEventListener('mouseup', onMouseUp);
32
+ }
33
+ function onMouseMove(e) {
34
+ e.stopPropagation();
35
+ if (isActive.current) {
36
+ setPosition({
37
+ x: e.clientX - positionRef.current.relativeX,
38
+ action: 'move',
39
+ });
40
+ }
41
+ }
42
+ window.addEventListener('mousemove', onMouseMove);
43
+ window.addEventListener('mouseup', onMouseUp);
44
+ }, []);
45
+ return {
46
+ onMouseDown,
47
+ position,
48
+ previousPosition: positionRef.current.x,
49
+ isActive: isActive.current,
50
+ anchor,
51
+ };
52
+ }
@@ -1,14 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useRef } from 'react';
3
3
  import { useDispatch } from '../context/DispatchContext';
4
+ import Button from '../elements/Button';
4
5
  import CheckBox from '../elements/CheckBox';
5
6
  import NumberInput from '../elements/NumberInput';
6
- import { AUTO_PEAK_PICKING, RESET_SELECTED_TOOL } from '../reducer/types/Types';
7
+ import { AUTO_PEAK_PICKING } from '../reducer/types/Types';
7
8
  const styles = {
8
9
  container: {
9
10
  height: '100%',
10
11
  display: 'flex',
11
12
  fontSize: '12px',
13
+ alignItems: 'center',
12
14
  },
13
15
  input: {
14
16
  width: '50px',
@@ -19,14 +21,6 @@ const styles = {
19
21
  label: {
20
22
  flex: '5',
21
23
  },
22
- actionButton: {
23
- height: '100%',
24
- width: '60px',
25
- borderRadius: '5px',
26
- border: '0.55px solid #c7c7c7',
27
- margin: '0px 5px',
28
- userSelect: 'none',
29
- },
30
24
  };
31
25
  function AutoPeakPickingOptionPanel() {
32
26
  const dispatch = useDispatch();
@@ -45,11 +39,6 @@ function AutoPeakPickingOptionPanel() {
45
39
  },
46
40
  });
47
41
  }, [dispatch]);
48
- const handleCancelFilter = useCallback(() => {
49
- dispatch({
50
- type: RESET_SELECTED_TOOL,
51
- });
52
- }, [dispatch]);
53
42
  return (_jsxs("div", { style: styles.container, children: [_jsx(NumberInput, { ref: maxNumberOfPeaksRef, label: "Max Number Of Peaks:", name: "maxNumberOfPeaks", style: {
54
43
  input: styles.input,
55
44
  inputContainer: styles.inputContainer,
@@ -62,6 +51,6 @@ function AutoPeakPickingOptionPanel() {
62
51
  input: styles.input,
63
52
  inputContainer: styles.inputContainer,
64
53
  label: styles.label,
65
- }, defaultValue: 0.1, step: "0.01" }), _jsxs("div", { style: { justifyItems: 'baseline', marginRight: '3px' }, children: [_jsx("label", { style: { marginRight: '2px', lineHeight: 2, userSelect: 'none' }, htmlFor: "lookNegative", children: "Detect Negative:" }), _jsx(CheckBox, { name: "lookNegative", ref: lookNegativeRef })] }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleApplyFilter, children: "Apply" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleCancelFilter, children: "Cancel" })] }));
54
+ }, defaultValue: 0.1, step: "0.01" }), _jsxs("div", { style: { justifyItems: 'baseline', marginRight: '3px' }, children: [_jsx("label", { style: { marginRight: '2px', lineHeight: 2, userSelect: 'none' }, htmlFor: "lookNegative", children: "Detect Negative:" }), _jsx(CheckBox, { name: "lookNegative", ref: lookNegativeRef })] }), _jsx(Button.Done, { onClick: handleApplyFilter, style: { margin: '0 10px' }, children: "Apply" })] }));
66
55
  }
67
56
  export default AutoPeakPickingOptionPanel;
@@ -8,6 +8,7 @@ import Select from '../elements/Select';
8
8
  import FormikForm from '../elements/formik/FormikForm';
9
9
  import FormikInput from '../elements/formik/FormikInput';
10
10
  import { RESET_SELECTED_TOOL, APPLY_BASE_LINE_CORRECTION_FILTER, } from '../reducer/types/Types';
11
+ import ActionButtons from '../elements/ActionButtons';
11
12
  const styles = {
12
13
  container: {
13
14
  padding: '5px',
@@ -19,14 +20,6 @@ const styles = {
19
20
  lineHeight: 2,
20
21
  userSelect: 'none',
21
22
  },
22
- actionButton: {
23
- height: '100%',
24
- width: '60px',
25
- borderRadius: '5px',
26
- border: '0.55px solid #c7c7c7',
27
- margin: '0px 5px',
28
- userSelect: 'none',
29
- },
30
23
  };
31
24
  function BaseLineCorrectionPanel() {
32
25
  const dispatch = useDispatch();
@@ -92,6 +85,6 @@ function BaseLineCorrectionPanel() {
92
85
  return { validation: {}, initialValue: {} };
93
86
  }
94
87
  }, [algorithm]);
95
- return (_jsxs("div", { style: styles.container, children: [_jsx("span", { style: styles.label, children: "Algorithm: " }), _jsx(Select, { ref: algorithmRef, data: getAlgorithmsList(), style: { marginLeft: 10, marginRight: 10 }, onChange: changeAlgorithmHandler, defaultValue: "polynomial" }), _jsxs(FormikForm, { ref: formRef, onSubmit: handleApplyFilter, initialValues: formData.initialValue, validationSchema: formData.validation, children: [algorithm && algorithm === 'airpls' && (_jsxs("div", { style: { display: 'flex' }, children: [_jsx(Label, { title: "maxIterations:", children: _jsx(FormikInput, { type: "number", name: "maxIterations" }) }), _jsx(Label, { title: "tolerance:", style: { label: { padding: '0 5px' } }, children: _jsx(FormikInput, { type: "number", name: "tolerance" }) })] })), algorithm && ['autoPolynomial', 'polynomial'].includes(algorithm) && (_jsx(Label, { title: "degree [ 1 - 6 ]:", children: _jsx(FormikInput, { type: "number", name: "degree", min: 1, max: 6, style: { inputWrapper: { height: '100%' } } }) }))] }, JSON.stringify(formData.initialValue)), _jsx("button", { type: "button", style: styles.actionButton, onClick: () => formRef.current.submitForm(), children: "Apply" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleCancelFilter, children: "Cancel" })] }));
88
+ return (_jsxs("div", { style: styles.container, children: [_jsx("span", { style: styles.label, children: "Algorithm: " }), _jsx(Select, { ref: algorithmRef, data: getAlgorithmsList(), style: { marginLeft: 10, marginRight: 10 }, onChange: changeAlgorithmHandler, defaultValue: "polynomial" }), _jsxs(FormikForm, { ref: formRef, onSubmit: handleApplyFilter, initialValues: formData.initialValue, validationSchema: formData.validation, children: [algorithm && algorithm === 'airpls' && (_jsxs("div", { style: { display: 'flex' }, children: [_jsx(Label, { title: "maxIterations:", children: _jsx(FormikInput, { type: "number", name: "maxIterations" }) }), _jsx(Label, { title: "tolerance:", style: { label: { padding: '0 5px' } }, children: _jsx(FormikInput, { type: "number", name: "tolerance" }) })] })), algorithm && ['autoPolynomial', 'polynomial'].includes(algorithm) && (_jsx(Label, { title: "degree [ 1 - 6 ]:", children: _jsx(FormikInput, { type: "number", name: "degree", min: 1, max: 6, style: { inputWrapper: { height: '100%' } } }) }))] }, JSON.stringify(formData.initialValue)), _jsx(ActionButtons, { onDone: () => formRef.current.submitForm(), onCancel: handleCancelFilter })] }));
96
89
  }
97
90
  export default BaseLineCorrectionPanel;
@@ -3,6 +3,7 @@ import { useMemo, memo, useCallback, useEffect, useRef, useState, } from 'react'
3
3
  import * as Filters from '../../data/Filters';
4
4
  import { useChartData } from '../context/ChartContext';
5
5
  import { useDispatch } from '../context/DispatchContext';
6
+ import ActionButtons from '../elements/ActionButtons';
6
7
  import Input from '../elements/Input';
7
8
  import InputRange from '../elements/InputRange';
8
9
  import Label from '../elements/Label';
@@ -18,14 +19,6 @@ const styles = {
18
19
  input: {
19
20
  width: '100px',
20
21
  },
21
- actionButton: {
22
- height: '100%',
23
- width: '60px',
24
- borderRadius: '5px',
25
- border: '0.55px solid #c7c7c7',
26
- margin: '0px 5px',
27
- userSelect: 'none',
28
- },
29
22
  select: {
30
23
  marginLeft: '5px',
31
24
  marginRight: '10px',
@@ -135,7 +128,7 @@ function ManualPhaseCorrectionPanelInner({ data, pivot, filter, }) {
135
128
  const onChangeHandler = useCallback((val) => {
136
129
  setPhaseCorrectionType(val);
137
130
  }, []);
138
- return (_jsxs("div", { style: styles.container, children: [_jsx(Select, { onChange: onChangeHandler, data: algorithms, defaultValue: phaseCorrectionTypes.manual, style: styles.select }), phaseCorrectionType === phaseCorrectionTypes.manual && (_jsxs(_Fragment, { children: [_jsx(Label, { title: "PH0 :", style: { wrapper: { marginRight: '5px' } }, children: _jsx(Input, { name: "ph0", style: { input: styles.input }, onChange: handleInput, value: value.ph0, type: "number", debounceTime: 250 }) }), _jsx(Label, { title: "PH1 :", children: _jsx(Input, { name: "ph1", style: { input: styles.input }, onChange: handleInput, value: value.ph1, type: "number", debounceTime: 250 }) }), _jsx(InputRange, { ref: ph0Ref, name: "ph0", label: "Change Ph0 By mouse click and drag", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(InputRange, { ref: ph1Ref, name: "ph1", label: "Change Ph1 By mouse click and drag", style: { width: '20%' }, onChange: handleRangeChange })] })), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleApplyFilter, children: "Apply" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleCancelFilter, children: "Cancel" })] }));
131
+ return (_jsxs("div", { style: styles.container, children: [_jsx(Select, { onChange: onChangeHandler, data: algorithms, defaultValue: phaseCorrectionTypes.manual, style: styles.select }), phaseCorrectionType === phaseCorrectionTypes.manual && (_jsxs(_Fragment, { children: [_jsx(Label, { title: "PH0 :", style: { wrapper: { marginRight: '5px' } }, children: _jsx(Input, { name: "ph0", style: { input: styles.input }, onChange: handleInput, value: value.ph0, type: "number", debounceTime: 250 }) }), _jsx(Label, { title: "PH1 :", children: _jsx(Input, { name: "ph1", style: { input: styles.input }, onChange: handleInput, value: value.ph1, type: "number", debounceTime: 250 }) }), _jsx(InputRange, { ref: ph0Ref, name: "ph0", label: "Change Ph0 By mouse click and drag", style: { width: '20%' }, onChange: handleRangeChange }), _jsx(InputRange, { ref: ph1Ref, name: "ph1", label: "Change Ph1 By mouse click and drag", style: { width: '20%' }, onChange: handleRangeChange })] })), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
139
132
  }
140
133
  const MemoizedManualPhaseCorrectionPanel = memo(ManualPhaseCorrectionPanelInner);
141
134
  const emptyData = { datum: {}, filter: null };
@@ -1,9 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useRef } from 'react';
3
3
  import { useDispatch } from '../context/DispatchContext';
4
+ import Button from '../elements/Button';
4
5
  import CheckBox from '../elements/CheckBox';
5
6
  import NumberInput from '../elements/NumberInput';
6
- import { AUTO_RANGES_DETECTION, RESET_SELECTED_TOOL, } from '../reducer/types/Types';
7
+ import { AUTO_RANGES_DETECTION } from '../reducer/types/Types';
7
8
  const styles = {
8
9
  container: {
9
10
  padding: '5px',
@@ -26,15 +27,6 @@ const styles = {
26
27
  label: {
27
28
  flex: 5,
28
29
  },
29
- actionButton: {
30
- height: '100%',
31
- minWidth: '60px',
32
- borderRadius: '5px',
33
- border: '0.55px solid #c7c7c7',
34
- margin: '0px 5px',
35
- userSelect: 'none',
36
- padding: '3px',
37
- },
38
30
  hint: {
39
31
  lineHeight: 2,
40
32
  userSelect: 'none',
@@ -56,15 +48,10 @@ function RangesPickingOptionPanel() {
56
48
  },
57
49
  });
58
50
  }, [dispatch]);
59
- const handleCancelFilter = useCallback(() => {
60
- dispatch({
61
- type: RESET_SELECTED_TOOL,
62
- });
63
- }, [dispatch]);
64
51
  return (_jsxs("div", { style: styles.container, children: [_jsxs("div", { style: { justifyItems: 'baseline', margin: '0 10px' }, children: [_jsx("label", { style: { marginRight: '2px', lineHeight: 2, userSelect: 'none' }, htmlFor: "lookNegative", children: "Detect negative:" }), _jsx(CheckBox, { name: "lookNegative", ref: lookNegativeRef })] }), _jsx(NumberInput, { ref: minMaxRatioRef, label: "Min Max Ratio:", name: "minMaxRatio", style: {
65
52
  input: styles.input,
66
53
  inputContainer: styles.inputContainer,
67
54
  label: styles.label,
68
- }, defaultValue: 0.05, step: "0.01" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleApplyFilter, "data-test-id": "auto-ranges-detection-btn", children: "Auto ranges picking" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleCancelFilter, children: "Cancel" }), _jsx("span", { style: styles.hint, children: "Manual selection using SHIFT + select zone or click on Auto peak picking" })] }));
55
+ }, defaultValue: 0.05, step: "0.01" }), _jsx(Button.Done, { onClick: handleApplyFilter, style: { margin: '0 10px' }, children: "Auto ranges picking" }), _jsx("span", { style: styles.hint, children: "Manual selection using SHIFT + select zone or click on Auto peak picking" })] }));
69
56
  }
70
57
  export default RangesPickingOptionPanel;
@@ -3,6 +3,7 @@ import { useCallback, useRef, useState } from 'react';
3
3
  import generateNumbersPowerOfX from '../../data/utilities/generateNumbersPowerOfX';
4
4
  import { useChartData } from '../context/ChartContext';
5
5
  import { useDispatch } from '../context/DispatchContext';
6
+ import ActionButtons from '../elements/ActionButtons';
6
7
  import Select from '../elements/Select';
7
8
  import { APPLY_ZERO_FILLING_FILTER, RESET_SELECTED_TOOL, } from '../reducer/types/Types';
8
9
  const styles = {
@@ -19,14 +20,6 @@ const styles = {
19
20
  margin: '0px 5px 0px 5px',
20
21
  textAlign: 'center',
21
22
  },
22
- actionButton: {
23
- height: '100%',
24
- width: '60px',
25
- borderRadius: '5px',
26
- border: '0.55px solid #c7c7c7',
27
- margin: '0px 5px',
28
- userSelect: 'none',
29
- },
30
23
  label: {
31
24
  lineHeight: 2,
32
25
  userSelect: 'none',
@@ -67,6 +60,6 @@ function ZeroFillingOptionsPanel() {
67
60
  type: RESET_SELECTED_TOOL,
68
61
  });
69
62
  }, [dispatch]);
70
- return (_jsxs("div", { style: styles.container, children: [_jsx("span", { style: styles.label, children: "Size: " }), _jsx(Select, { ref: sizeTextInputRef, data: Sizes, style: { marginLeft: 10, marginRight: 10 }, defaultValue: getDefaultValue() }), _jsx("span", { style: styles.label, children: "Line Broadening: " }), _jsx("input", { name: "line-broadening", style: styles.input, type: "number", defaultValue: lineBroadeningValue, onInput: handleInput, pattern: "^\\d*(\\.\\d{0,2})?$", step: "any" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleApplyFilter, children: "Apply" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleCancelFilter, children: "Cancel" })] }));
63
+ return (_jsxs("div", { style: styles.container, children: [_jsx("span", { style: styles.label, children: "Size: " }), _jsx(Select, { ref: sizeTextInputRef, data: Sizes, style: { marginLeft: 10, marginRight: 10 }, defaultValue: getDefaultValue() }), _jsx("span", { style: styles.label, children: "Line Broadening: " }), _jsx("input", { name: "line-broadening", style: styles.input, type: "number", defaultValue: lineBroadeningValue, onInput: handleInput, pattern: "^\\d*(\\.\\d{0,2})?$", step: "any" }), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
71
64
  }
72
65
  export default ZeroFillingOptionsPanel;
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useRef } from 'react';
3
3
  import { useDispatch } from '../context/DispatchContext';
4
+ import Button from '../elements/Button';
4
5
  import NumberInput from '../elements/NumberInput';
5
- import { RESET_SELECTED_TOOL, AUTO_ZONES_DETECTION, CHANGE_ZONES_NOISE_FACTOR, } from '../reducer/types/Types';
6
+ import { AUTO_ZONES_DETECTION, CHANGE_ZONES_NOISE_FACTOR, } from '../reducer/types/Types';
6
7
  const styles = {
7
8
  container: {
8
9
  padding: '5px',
@@ -19,13 +20,6 @@ const styles = {
19
20
  label: {
20
21
  flex: '5',
21
22
  },
22
- actionButton: {
23
- height: '100%',
24
- borderRadius: '5px',
25
- border: '0.55px solid #c7c7c7',
26
- margin: '0px 5px',
27
- userSelect: 'none',
28
- },
29
23
  };
30
24
  function Zones2DOptionPanel() {
31
25
  const dispatch = useDispatch();
@@ -38,11 +32,6 @@ function Zones2DOptionPanel() {
38
32
  },
39
33
  });
40
34
  }, [dispatch]);
41
- const handleCancelFilter = useCallback(() => {
42
- dispatch({
43
- type: RESET_SELECTED_TOOL,
44
- });
45
- }, [dispatch]);
46
35
  const handleInput = useCallback((e) => {
47
36
  if (e.target) {
48
37
  dispatch({ type: CHANGE_ZONES_NOISE_FACTOR, payload: e.target.value });
@@ -52,6 +41,6 @@ function Zones2DOptionPanel() {
52
41
  input: styles.input,
53
42
  inputContainer: styles.inputContainer,
54
43
  label: styles.label,
55
- }, defaultValue: 1, onChange: handleInput }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleApplyFilter, children: "Auto Zones Picking" }), _jsx("button", { type: "button", style: styles.actionButton, onClick: handleCancelFilter, children: "Cancel" })] }));
44
+ }, defaultValue: 1, onChange: handleInput }), _jsx(Button.Done, { onClick: handleApplyFilter, style: { margin: '0 10px' }, children: "Auto Zones Picking" })] }));
56
45
  }
57
46
  export default Zones2DOptionPanel;
@@ -2,25 +2,27 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useCallback } from 'react';
3
3
  import { toJSON } from '../../data/SpectraManager';
4
4
  import { useChartData } from '../context/ChartContext';
5
+ import { useGlobal } from '../context/GlobalContext';
5
6
  import { useAlert } from '../elements/popup/Alert';
6
7
  import { positions, useModal } from '../elements/popup/Modal';
7
8
  import SaveAsModal from '../modal/SaveAsModal';
8
9
  import { copyPNGToClipboard, exportAsJSON, exportAsNMRE, exportAsPng, exportAsSVG, } from '../utility/Export';
9
10
  import { nmriumToNmredata } from '../utility/nmriumToNmredata';
10
11
  export default function useExport() {
12
+ const { rootRef } = useGlobal();
11
13
  const modal = useModal();
12
14
  const alert = useAlert();
13
15
  const state = useChartData();
14
16
  const saveToClipboardHandler = useCallback(async () => {
15
- if (state.data.length > 0) {
17
+ if (state.data.length > 0 && rootRef) {
16
18
  const hideLoading = await alert.showLoading('Exporting as NMRium process in progress');
17
19
  setTimeout(() => {
18
- copyPNGToClipboard('nmrSVG');
20
+ copyPNGToClipboard(rootRef, 'nmrSVG');
19
21
  hideLoading();
20
22
  alert.success('Image copied to clipboard');
21
23
  }, 0);
22
24
  }
23
- }, [alert, state]);
25
+ }, [rootRef, alert, state]);
24
26
  const saveAsJSONHandler = useCallback(async (spaceIndent = 0, isCompressed = true) => {
25
27
  if (state.data.length > 0) {
26
28
  const hideLoading = await alert.showLoading('Exporting as NMRium process in progress');
@@ -51,25 +53,25 @@ export default function useExport() {
51
53
  }
52
54
  }, [alert, state]);
53
55
  const saveAsSVGHandler = useCallback(async () => {
54
- if (state.data.length > 0) {
56
+ if (state.data.length > 0 && rootRef) {
55
57
  const hideLoading = await alert.showLoading('Exporting as SVG process in progress');
56
58
  setTimeout(() => {
57
59
  const fileName = state.data[0]?.display?.name;
58
- exportAsSVG('nmrSVG', fileName);
60
+ exportAsSVG(rootRef, 'nmrSVG', fileName);
59
61
  hideLoading();
60
62
  }, 0);
61
63
  }
62
- }, [alert, state.data]);
64
+ }, [rootRef, alert, state.data]);
63
65
  const saveAsPNGHandler = useCallback(async () => {
64
- if (state.data.length > 0) {
66
+ if (state.data.length > 0 && rootRef) {
65
67
  const hideLoading = await alert.showLoading('Exporting as PNG process in progress');
66
68
  setTimeout(() => {
67
69
  const fileName = state.data[0]?.display?.name;
68
- exportAsPng('nmrSVG', fileName);
70
+ exportAsPng(rootRef, 'nmrSVG', fileName);
69
71
  hideLoading();
70
72
  }, 0);
71
73
  }
72
- }, [alert, state.data]);
74
+ }, [rootRef, alert, state.data]);
73
75
  const saveHandler = useCallback((options) => {
74
76
  async function handler() {
75
77
  const { name, pretty, compressed, dataExportOption } = options;
@@ -195,6 +195,7 @@ function DropZone(props) {
195
195
  const { getRootProps, getInputProps, isDragActive, open: openImportDialog, } = useDropzone({
196
196
  onDrop,
197
197
  noClick: true,
198
+ noKeyboard: true,
198
199
  });
199
200
  const open = useCallback(() => {
200
201
  openImportDialog();
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { useCallback, useEffect, useMemo, useRef } from 'react';
4
4
  import { REFERENCES } from '../../data/constants/References';
5
5
  import { useDispatch } from '../context/DispatchContext';
6
+ import Button from '../elements/Button';
6
7
  import CloseButton from '../elements/CloseButton';
7
8
  import Label from '../elements/Label';
8
9
  import Select from '../elements/Select';
@@ -51,6 +52,6 @@ function AlignSpectraModal({ onClose = () => null, nucleus, }) {
51
52
  ...resValues,
52
53
  });
53
54
  }, [nucleus]);
54
- return (_jsxs("div", { css: ModalStyles, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Spectra calibration" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", style: { flex: 1 }, children: _jsxs(FormikForm, { ref: refForm, initialValues: { from: -1, to: 1, nbPeaks: 1, targetX: 0 }, onSubmit: submitHandler, children: [_jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Options :" }), _jsx(Select, { data: List, style: { width: 270, height: 30, marginBottom: '20px' }, onChange: optionChangeHandler })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Range :" }), _jsx(Label, { title: "From : ", children: _jsx(FormikInput, { name: "from", type: "number" }) }), _jsx(Label, { title: "To : ", children: _jsx(FormikInput, { name: "to", type: "number" }) })] }), _jsx("div", { className: " margin-10", children: _jsx(Label, { className: "custom-label", title: "Number of Peaks : ", children: _jsx(FormikInput, { name: "nbPeaks", type: "number" }) }) }), _jsx("div", { className: " margin-10", children: _jsx(Label, { className: "custom-label", title: "Target PPM :", children: _jsx(FormikInput, { name: "targetX", type: "number" }) }) })] }) }), _jsx("div", { className: "footer-container", children: _jsx("button", { type: "button", onClick: handleSave, className: "btn", children: "Done" }) })] }));
55
+ return (_jsxs("div", { css: ModalStyles, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Spectra calibration" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", style: { flex: 1 }, children: _jsxs(FormikForm, { ref: refForm, initialValues: { from: -1, to: 1, nbPeaks: 1, targetX: 0 }, onSubmit: submitHandler, children: [_jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Options :" }), _jsx(Select, { data: List, style: { width: 270, height: 30, marginBottom: '20px' }, onChange: optionChangeHandler })] }), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Range :" }), _jsx(Label, { title: "From : ", children: _jsx(FormikInput, { name: "from", type: "number" }) }), _jsx(Label, { title: "To : ", children: _jsx(FormikInput, { name: "to", type: "number" }) })] }), _jsx("div", { className: " margin-10", children: _jsx(Label, { className: "custom-label", title: "Number of Peaks : ", children: _jsx(FormikInput, { name: "nbPeaks", type: "number" }) }) }), _jsx("div", { className: " margin-10", children: _jsx(Label, { className: "custom-label", title: "Target PPM :", children: _jsx(FormikInput, { name: "targetX", type: "number" }) }) })] }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: handleSave, children: "Done" }) })] }));
55
56
  }
56
57
  export default AlignSpectraModal;
@@ -2,6 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { useCallback, useEffect, useRef } from 'react';
4
4
  import { useChartData } from '../context/ChartContext';
5
+ import Button from '../elements/Button';
5
6
  import CloseButton from '../elements/CloseButton';
6
7
  import Label from '../elements/Label';
7
8
  import FormikForm from '../elements/formik/FormikForm';
@@ -30,6 +31,6 @@ function ExportAsMatrixModal({ onClose = () => null, }) {
30
31
  Events.off('brushEnd', handler);
31
32
  };
32
33
  }, []);
33
- return (_jsxs("div", { css: ModalStyles, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Export spectra as a Matrix" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsxs(FormikForm, { ref: refForm, initialValues: INITIAL_VALUE, onSubmit: submitHandler, children: [_jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Range :" }), _jsx(Label, { title: "From : ", children: _jsx(FormikInput, { name: "from", type: "number" }) }), _jsx(Label, { title: "To : ", children: _jsx(FormikInput, { name: "to", type: "number" }) })] }), _jsx("div", { className: "row margin-10", children: _jsx(Label, { title: "Number of Points :", className: "custom-label", children: _jsx(FormikInput, { name: "nbPoints", type: "number" }) }) })] }) }), _jsx("div", { className: "footer-container", children: _jsx("button", { type: "button", onClick: handleSave, className: "btn", children: "Export Now" }) })] }));
34
+ return (_jsxs("div", { css: ModalStyles, children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Export spectra as a Matrix" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsxs(FormikForm, { ref: refForm, initialValues: INITIAL_VALUE, onSubmit: submitHandler, children: [_jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Range :" }), _jsx(Label, { title: "From : ", children: _jsx(FormikInput, { name: "from", type: "number" }) }), _jsx(Label, { title: "To : ", children: _jsx(FormikInput, { name: "to", type: "number" }) })] }), _jsx("div", { className: "row margin-10", children: _jsx(Label, { title: "Number of Points :", className: "custom-label", children: _jsx(FormikInput, { name: "nbPoints", type: "number" }) }) })] }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: handleSave, children: "Export Now" }) })] }));
34
35
  }
35
36
  export default ExportAsMatrixModal;