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
@@ -1,13 +1,13 @@
1
1
  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
- import { useCallback, useState, useEffect } from 'react';
4
+ import { useCallback } from 'react';
5
5
  import { useChartData } from '../context/ChartContext';
6
6
  import { useDispatch } from '../context/DispatchContext';
7
7
  import { useScaleChecked } from '../context/ScaleContext';
8
+ import Resizer from '../elements/resizer/Resizer';
8
9
  import { HighlightedSource, useHighlight } from '../highlight/index';
9
10
  import { RESIZE_INTEGRAL } from '../reducer/types/Types';
10
- import Resizable from './Resizable';
11
11
  const stylesOnHover = css `
12
12
  pointer-events: bounding-box;
13
13
  @-moz-document url-prefix() {
@@ -36,31 +36,31 @@ function IntegralResizable({ integralData }) {
36
36
  const { height, margin } = useChartData();
37
37
  const { scaleX } = useScaleChecked();
38
38
  const dispatch = useDispatch();
39
- const [{ id, integral, from, to }, setIntegral] = useState(integralData);
39
+ const { id, from, to, integral } = integralData;
40
40
  const highlight = useHighlight([id], {
41
41
  type: HighlightedSource.INTEGRAL,
42
42
  extra: { id },
43
43
  });
44
- useEffect(() => {
45
- setIntegral(integralData);
46
- }, [integralData]);
47
- const handleOnStopResizing = useCallback((resized) => {
44
+ const handleOnStopResizing = useCallback((position) => {
48
45
  dispatch({
49
46
  type: RESIZE_INTEGRAL,
50
- payload: { data: { ...integralData, ...resized } },
47
+ payload: {
48
+ data: {
49
+ ...integralData,
50
+ from: scaleX().invert(position.x2),
51
+ to: scaleX().invert(position.x1),
52
+ },
53
+ },
51
54
  });
52
- }, [dispatch, integralData]);
55
+ }, [dispatch, integralData, scaleX]);
53
56
  const handleOnEnterNotation = useCallback(() => {
54
57
  highlight.show();
55
58
  }, [highlight]);
56
59
  const handleOnMouseLeaveNotation = useCallback(() => {
57
60
  highlight.hide();
58
61
  }, [highlight]);
59
- const dragHandler = useCallback((boundary) => {
60
- setIntegral((integral) => ({ ...integral, ...boundary }));
61
- }, []);
62
62
  const x0 = from ? scaleX()(from) : 0;
63
63
  const x1 = to ? scaleX()(to) : 0;
64
- return (_jsxs("g", { css: highlight.isActive ? stylesHighlighted : stylesOnHover, onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: [_jsx("rect", { "data-no-export": "true", x: `${x1}`, y: "0", width: `${x0 - x1}`, height: height - margin.bottom, className: "highlight" }), _jsx("text", { x: x1, y: height - margin.bottom + 30, fill: "black", style: { fontSize: '12px', fontWeight: 'bold' }, children: integral !== undefined ? integral.toFixed(2) : '' }), _jsx(Resizable, { from: integralData.from, to: integralData.to, onDrag: dragHandler, onDrop: handleOnStopResizing, "data-no-export": "true" })] }));
64
+ return (_jsx("g", { css: highlight.isActive ? stylesHighlighted : stylesOnHover, onMouseEnter: handleOnEnterNotation, onMouseLeave: handleOnMouseLeaveNotation, children: _jsx(Resizer, { tag: "svg", initialPosition: { x1: x1, x2: x0 }, onEnd: handleOnStopResizing, children: (x1, x2) => (_jsxs("g", { children: [_jsx("rect", { x: "0", y: "0", width: x2 - x1, height: height - margin.bottom, className: "highlight", "data-no-export": "true" }), _jsx("text", { x: 0, y: height - margin.bottom + 30, fill: "black", style: { fontSize: '12px', fontWeight: 'bold' }, children: integral !== undefined ? integral.toFixed(2) : '' })] })) }) }));
65
65
  }
66
66
  export default IntegralResizable;
@@ -1,41 +1,37 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
4
  import { useCallback } from 'react';
5
5
  import { useDispatch } from '../../context/DispatchContext';
6
6
  import { useScaleChecked } from '../../context/ScaleContext';
7
7
  import DeleteButton from '../../elements/DeleteButton';
8
+ import Resizer from '../../elements/resizer/Resizer';
8
9
  import { useHighlight } from '../../highlight';
9
10
  import { DELETE_ANALYZE_SPECTRA_RANGE, RESIZE_ANALYZE_SPECTRA_RANGE, } from '../../reducer/types/Types';
10
- import Resizable from '../Resizable';
11
- const stylesOnHover = css `
12
- pointer-events: bounding-box;
13
- @-moz-document url-prefix() {
14
- pointer-events: fill;
15
- }
16
- user-select: 'none';
17
- -webkit-user-select: none; /* Chrome all / Safari all */
18
- -moz-user-select: none; /* Firefox all */
11
+ const styles = {
12
+ common: css `
13
+ pointer-events: bounding-box;
19
14
 
20
- .delete-button {
21
- visibility: hidden;
22
- }
23
- `;
24
- const stylesHighlighted = css `
25
- pointer-events: bounding-box;
26
-
27
- @-moz-document url-prefix() {
28
- pointer-events: fill;
29
- }
30
- .range-area {
31
- height: 100%;
32
- fill: #ff6f0057;
33
- }
34
- .delete-button {
35
- visibility: visible;
36
- cursor: pointer;
37
- }
38
- `;
15
+ @-moz-document url-prefix() {
16
+ pointer-events: fill;
17
+ }
18
+ `,
19
+ hover: css `
20
+ .delete-button {
21
+ visibility: hidden;
22
+ }
23
+ `,
24
+ Highlighted: css `
25
+ .range-area {
26
+ height: 100%;
27
+ fill: #ff6f0057;
28
+ }
29
+ .delete-button {
30
+ visibility: visible;
31
+ cursor: pointer;
32
+ }
33
+ `,
34
+ };
39
35
  function AnalysisRange({ rangeData, columnKey }) {
40
36
  const { from, to } = rangeData;
41
37
  const highlight = useHighlight([columnKey]);
@@ -44,12 +40,15 @@ function AnalysisRange({ rangeData, columnKey }) {
44
40
  const deleteHandler = useCallback(() => {
45
41
  dispatch({ type: DELETE_ANALYZE_SPECTRA_RANGE, colKey: columnKey });
46
42
  }, [columnKey, dispatch]);
47
- const handleOnStopResizing = useCallback((resized) => {
43
+ const resizeEndHandler = useCallback((resized) => {
48
44
  dispatch({
49
45
  type: RESIZE_ANALYZE_SPECTRA_RANGE,
50
46
  payload: { ...rangeData, ...resized, columnKey },
51
47
  });
52
48
  }, [columnKey, dispatch, rangeData]);
53
- return (_jsxs("g", { ...highlight.onHover, css: highlight.isActive ? stylesHighlighted : stylesOnHover, children: [_jsxs("g", { transform: `translate(${scaleX()(to)},25)`, children: [_jsx("rect", { x: "0", width: scaleX()(from) - scaleX()(to), height: "6", className: "range-area", fill: "green" }), _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 })] }), _jsx(Resizable, { from: rangeData.from, to: rangeData.to, onDrop: handleOnStopResizing }), _jsx(DeleteButton, { x: scaleX()(to) - 20, y: 10, onDelete: deleteHandler })] }));
49
+ return (_jsx("g", { ...highlight.onHover, css: [
50
+ styles.common,
51
+ highlight.isActive ? styles.Highlighted : styles.hover,
52
+ ], children: _jsx(Resizer, { tag: "svg", onEnd: resizeEndHandler, initialPosition: { x2: scaleX()(from), x1: scaleX()(to) }, children: (x1, x2) => (_jsxs(_Fragment, { children: [_jsxs("g", { transform: `translate(0,25)`, children: [_jsx("rect", { x: "0", width: x2 - x1, height: "6", className: "range-area", fill: "green" }), _jsx("text", { textAnchor: "middle", x: (x2 - x1) / 2, y: "-5", fontSize: "12", fill: "red", fontWeight: "bolder", fillOpacity: highlight.isActive ? 1 : 0.6, children: columnKey })] }), _jsx(DeleteButton, { x: -20, y: 10, onDelete: deleteHandler })] })) }) }));
54
53
  }
55
54
  export default AnalysisRange;
@@ -6,10 +6,10 @@ import { checkRangeKind } from '../../../data/utilities/RangeUtilities';
6
6
  import { filterForIDsWithAssignment, useAssignment, useAssignmentData, } from '../../assignment';
7
7
  import { useDispatch } from '../../context/DispatchContext';
8
8
  import { useScaleChecked } from '../../context/ScaleContext';
9
+ import Resizer from '../../elements/resizer/Resizer';
9
10
  import { HighlightedSource, useHighlight } from '../../highlight';
10
11
  import { RESIZE_RANGE } from '../../reducer/types/Types';
11
12
  import { options } from '../../toolbar/ToolTypes';
12
- import Resizable from '../Resizable';
13
13
  import MultiplicityTree from '../multiplicityTree/MultiplicityTree';
14
14
  import TempMultiplicityTree from '../multiplicityTree/TempMultiplicityTree';
15
15
  const stylesOnHover = css `
@@ -41,24 +41,14 @@ const stylesHighlighted = css `
41
41
  }
42
42
  `;
43
43
  function Range({ rangeData, showMultiplicityTrees, selectedTool, startEditMode, }) {
44
- const { id, from: rangeFrom, to: rangeTo, integration, signals } = rangeData;
44
+ const { id, from, to, integration, signals } = rangeData;
45
45
  const assignmentData = useAssignmentData();
46
46
  const assignmentRange = useAssignment(id);
47
47
  const highlightRange = useHighlight([assignmentRange.id].concat(assignmentRange.assigned.x || []).concat(filterForIDsWithAssignment(assignmentData, signals.map((_signal) => _signal.id))), { type: HighlightedSource.RANGE, extra: { id } });
48
- const [rangeBoundary, setRangeBoundary] = useState({
49
- from: rangeFrom,
50
- to: rangeTo,
51
- });
52
48
  const { scaleX } = useScaleChecked();
53
49
  const dispatch = useDispatch();
54
50
  const [reduceOpacity, setReduceOpacity] = useState(false);
55
51
  const [isBlockedByEditing, setIsBlockedByEditing] = useState(false);
56
- useEffect(() => {
57
- setRangeBoundary({
58
- from: rangeFrom,
59
- to: rangeTo,
60
- });
61
- }, [rangeFrom, rangeTo]);
62
52
  useEffect(() => {
63
53
  if (selectedTool && selectedTool === options.editRange.id) {
64
54
  setIsBlockedByEditing(true);
@@ -70,12 +60,16 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, startEditMode,
70
60
  useEffect(() => {
71
61
  setReduceOpacity(!checkRangeKind(rangeData));
72
62
  }, [rangeData]);
73
- const handleOnStopResizing = useCallback((resized) => {
63
+ const handleOnStopResizing = useCallback((position) => {
74
64
  dispatch({
75
65
  type: RESIZE_RANGE,
76
- data: { ...rangeData, ...resized },
66
+ data: {
67
+ ...rangeData,
68
+ from: scaleX().invert(position.x2),
69
+ to: scaleX().invert(position.x1),
70
+ },
77
71
  });
78
- }, [dispatch, rangeData]);
72
+ }, [dispatch, rangeData, scaleX]);
79
73
  const mouseEnterHandler = useCallback(() => {
80
74
  assignmentRange.onMouseEnter('x');
81
75
  highlightRange.show();
@@ -91,23 +85,19 @@ function Range({ rangeData, showMultiplicityTrees, selectedTool, startEditMode,
91
85
  assignmentRange.onClick('x');
92
86
  }
93
87
  }, [assignmentRange, isBlockedByEditing, selectedTool]);
94
- const dragHandler = useCallback((boundary) => {
95
- setRangeBoundary((range) => ({ ...range, ...boundary }));
96
- }, []);
97
- const { from, to } = rangeBoundary;
98
88
  return (_jsxs("g", { "data-test-id": "range", style: { outline: 'none' }, css: isBlockedByEditing ||
99
89
  highlightRange.isActive ||
100
90
  assignmentRange.isActive
101
91
  ? stylesHighlighted
102
- : stylesOnHover, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, children: [_jsxs("g", { transform: `translate(${scaleX()(to)},10)`, children: [_jsx("rect", { x: "0", width: Math.abs(scaleX()(from) - scaleX()(to)), height: "6", className: "range-area", fill: "green", fillOpacity: !reduceOpacity ||
103
- highlightRange.isActive ||
104
- assignmentRange.isActive
105
- ? 1
106
- : 0.4 }), _jsx("text", { textAnchor: "middle", x: Math.abs(scaleX()(from) - scaleX()(to)) / 2, y: "20", fontSize: "10", fill: "red", fillOpacity: !reduceOpacity ||
107
- highlightRange.isActive ||
108
- assignmentRange.isActive
109
- ? 1
110
- : 0.6, children: integration !== undefined ? integration.toFixed(2) : '' })] }), _jsx(Resizable, { from: rangeData.from, to: rangeData.to, onDrop: handleOnStopResizing, onDrag: dragHandler }), startEditMode ? (_jsx(TempMultiplicityTree, {})) : (showMultiplicityTrees &&
92
+ : stylesOnHover, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, onClick: assignHandler, children: [_jsx(Resizer, { tag: "svg", initialPosition: { x1: scaleX()(to), x2: scaleX()(from) }, onEnd: handleOnStopResizing, children: (x1, x2) => (_jsxs("g", { transform: `translate(0,10)`, children: [_jsx("rect", { "data-no-export": "true", x: "0", width: x2 - x1, height: "6", className: "range-area", fill: "green", fillOpacity: !reduceOpacity ||
93
+ highlightRange.isActive ||
94
+ assignmentRange.isActive
95
+ ? 1
96
+ : 0.4 }), _jsx("text", { textAnchor: "middle", x: (x2 - x1) / 2, y: "20", fontSize: "10", fill: "red", fillOpacity: !reduceOpacity ||
97
+ highlightRange.isActive ||
98
+ assignmentRange.isActive
99
+ ? 1
100
+ : 0.6, children: integration !== undefined ? integration.toFixed(2) : '' })] })) }), startEditMode ? (_jsx(TempMultiplicityTree, {})) : (showMultiplicityTrees &&
111
101
  signals &&
112
102
  signals.length > 0 &&
113
103
  signals.map((_signal) => (_jsx(MultiplicityTree, { rangeFrom: from, rangeTo: to, signal: _signal }, _signal.id))))] }, id));
@@ -49,7 +49,6 @@ const containerStyles = css `
49
49
 
50
50
  button {
51
51
  cursor: pointer;
52
- color: black;
53
52
  &:disabled {
54
53
  cursor: default;
55
54
  }
@@ -76,25 +75,6 @@ const containerStyles = css `
76
75
  .SplitPane {
77
76
  height: 100%;
78
77
  }
79
-
80
- .Resizer.vertical:after {
81
- content: '\\22EE';
82
- top: 50%;
83
- color: black;
84
- position: absolute;
85
- font-size: 14px;
86
- }
87
-
88
- .Resizer.vertical {
89
- padding: 2px;
90
- }
91
-
92
- .Resizer.vertical:hover {
93
- background-color: #dfdfdf !important;
94
- border-left: 0.55px #bbbbbb;
95
- solid;
96
- border-right: 0.55px #bbbbbb solid;
97
- }
98
78
  `;
99
79
  const defaultPreferences = {};
100
80
  const defaultData = {
@@ -105,7 +85,7 @@ function NMRium(props) {
105
85
  }
106
86
  function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = defaultPreferences, getSpinner = defaultGetSpinner, onDataChange, emptyText, }) {
107
87
  const rootRef = useRef(null);
108
- const elementsWraperRef = useRef(null);
88
+ const elementsWrapperRef = useRef(null);
109
89
  const [show, toggle] = useToggle(false);
110
90
  const isFullscreen = useFullscreen(rootRef, show, {
111
91
  onClose: () => {
@@ -147,16 +127,29 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = de
147
127
  e.preventDefault();
148
128
  }
149
129
  }, []);
150
- const mouseEnterHandler = useCallback(() => {
151
- dispatchMiddleWare({ type: SET_MOUSE_OVER_DISPLAYER, payload: true });
152
- }, [dispatchMiddleWare]);
153
- const mouseLeaveHandler = useCallback(() => {
154
- dispatchMiddleWare({ type: SET_MOUSE_OVER_DISPLAYER, payload: false });
130
+ const mainDivRef = useRef(null);
131
+ useEffect(() => {
132
+ const div = mainDivRef.current;
133
+ if (!div) {
134
+ return;
135
+ }
136
+ function mouseEnterHandler() {
137
+ dispatchMiddleWare({ type: SET_MOUSE_OVER_DISPLAYER, payload: true });
138
+ }
139
+ function mouseLeaveHandler() {
140
+ dispatchMiddleWare({ type: SET_MOUSE_OVER_DISPLAYER, payload: false });
141
+ }
142
+ div.addEventListener('mouseenter', mouseEnterHandler);
143
+ div.addEventListener('mouseleave', mouseLeaveHandler);
144
+ return () => {
145
+ div.removeEventListener('mouseenter', mouseEnterHandler);
146
+ div.removeEventListener('mouseleave', mouseLeaveHandler);
147
+ };
155
148
  }, [dispatchMiddleWare]);
156
149
  return (_jsx(GlobalProvider, { value: {
157
150
  rootRef: rootRef.current,
158
- elementsWraperRef: elementsWraperRef.current,
159
- }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler, style: { height: '100%', position: 'relative' }, children: _jsx(AlertProvider, { wrapperRef: elementsWraperRef.current, children: _jsx(DispatchProvider, { value: dispatchMiddleWare, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWraperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
151
+ elementsWrapperRef: elementsWrapperRef.current,
152
+ }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(DispatchProvider, { value: dispatchMiddleWare, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
160
153
  display: 'flex',
161
154
  flexDirection: 'column',
162
155
  backgroundColor: 'white',
@@ -169,7 +162,7 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, preferences = de
169
162
  width: '100%',
170
163
  height: '100%',
171
164
  }, children: displayerMode ===
172
- DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText })) })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWraperRef, id: "main-wrapper", style: {
165
+ DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText })) })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
173
166
  position: 'absolute',
174
167
  pointerEvents: 'none',
175
168
  zIndex: 0,
@@ -1,4 +1,13 @@
1
1
  /// <reference types="react" />
2
- export declare const GlobalConetxt: import("react").Context<any>;
3
- export declare const GlobalProvider: import("react").Provider<any>;
4
- export declare function useGlobal(): any;
2
+ export declare const GlobalConetxt: import("react").Context<{
3
+ rootRef: HTMLDivElement | null;
4
+ elementsWrapperRef: HTMLDivElement | null;
5
+ }>;
6
+ export declare const GlobalProvider: import("react").Provider<{
7
+ rootRef: HTMLDivElement | null;
8
+ elementsWrapperRef: HTMLDivElement | null;
9
+ }>;
10
+ export declare function useGlobal(): {
11
+ rootRef: HTMLDivElement | null;
12
+ elementsWrapperRef: HTMLDivElement | null;
13
+ };
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from 'react';
2
- export const GlobalConetxt = createContext({});
2
+ export const GlobalConetxt = createContext({ rootRef: null, elementsWrapperRef: null });
3
3
  export const GlobalProvider = GlobalConetxt.Provider;
4
4
  export function useGlobal() {
5
5
  return useContext(GlobalConetxt);
@@ -0,0 +1,10 @@
1
+ import { CSSProperties, MouseEvent } from 'react';
2
+ interface ActionButtonsProps {
3
+ onDone: (event?: MouseEvent) => void;
4
+ onCancel: (event?: MouseEvent) => void;
5
+ doneLabel?: string;
6
+ cancelLabel?: string;
7
+ style?: CSSProperties;
8
+ }
9
+ export default function ActionButtons(props: ActionButtonsProps): JSX.Element;
10
+ export {};
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Button from './Button';
3
+ export default function ActionButtons(props) {
4
+ const { onDone, onCancel, doneLabel = 'Apply', cancelLabel = 'Cancel', style = {}, } = props;
5
+ return (_jsxs("div", { style: { margin: '0 10px', display: 'flex', ...style }, children: [_jsx(Button.Done, { onClick: onDone, style: style?.flexDirection === 'row-reverse'
6
+ ? {
7
+ marginLeft: '10px',
8
+ }
9
+ : {}, children: doneLabel }), _jsx(Button.Danger, { fill: "outline", onClick: onCancel, style: !style.flexDirection || style.flexDirection === 'row'
10
+ ? {
11
+ marginLeft: '10px',
12
+ }
13
+ : {}, children: cancelLabel })] }));
14
+ }
@@ -1,6 +1,31 @@
1
- import { ButtonHTMLAttributes } from 'react';
2
- interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
3
- onClick: () => void;
1
+ /** @jsxImportSource @emotion/react */
2
+ import { CSSObject } from '@emotion/react';
3
+ import { ReactNode, ButtonHTMLAttributes, CSSProperties, MouseEvent } from 'react';
4
+ declare type Size = 'xSmall' | 'small' | 'medium' | 'large';
5
+ declare type Color = CSSProperties['color'];
6
+ interface BaseColor {
7
+ base: Color;
8
+ hover: Color;
9
+ active?: Color;
4
10
  }
5
- export default function Button({ onClick, ...props }: ButtonProps): JSX.Element;
6
- export {};
11
+ declare type Fill = 'clear' | 'outline' | 'solid';
12
+ interface ButtonStyle {
13
+ color: BaseColor;
14
+ size: Size;
15
+ borderColor: Color;
16
+ backgroundColor: BaseColor;
17
+ borderRadius?: CSSProperties['borderRadius'];
18
+ fill?: Fill;
19
+ style?: CSSObject;
20
+ }
21
+ interface ButtonProps extends Partial<ButtonStyle>, Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'style'> {
22
+ onClick?: (event?: MouseEvent<HTMLButtonElement>) => void;
23
+ children: ReactNode;
24
+ }
25
+ declare const Button: {
26
+ (props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
27
+ Done(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
28
+ Danger(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
29
+ Action(props: ButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
30
+ };
31
+ export default Button;
@@ -1,5 +1,151 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Fragment } from 'react';
3
- export default function Button({ onClick, ...props }) {
4
- return (_jsx(Fragment, { children: _jsx("button", { type: "button", onClick: onClick, ...props }) }));
1
+ import { jsxs as _jsxs, jsx as _jsx } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ const colorPalettes = {
5
+ success: {
6
+ base: '#2dd36f',
7
+ shade: '#28ba62',
8
+ tint: '#42d77d',
9
+ },
10
+ danger: {
11
+ base: '#eb445a',
12
+ shade: '#cf3c4f',
13
+ tint: '#ed576b',
14
+ },
15
+ warning: {
16
+ base: '#ffc409',
17
+ shade: '#e0ac08',
18
+ tint: '#ffca22',
19
+ },
20
+ medium: {
21
+ base: '#92949c',
22
+ shade: '#808289',
23
+ tint: '#9d9fa6',
24
+ },
25
+ light: {
26
+ base: '#f4f5f8',
27
+ shade: '#d7d8da',
28
+ tint: '#f5f6f9',
29
+ },
30
+ };
31
+ const sizeConfig = {
32
+ xSmall: {
33
+ fontSize: '0.75rem',
34
+ padding: '0.15rem 0.3rem',
35
+ borderRadius: '0.15rem',
36
+ },
37
+ small: {
38
+ fontSize: '0.8rem',
39
+ padding: '0.25rem 0.5rem',
40
+ borderRadius: '0.2rem',
41
+ },
42
+ medium: {
43
+ fontSize: '1rem',
44
+ padding: '0.375rem 0.75rem',
45
+ borderRadius: '0.25rem',
46
+ },
47
+ large: {
48
+ fontSize: '1.25rem',
49
+ padding: '0.5rem 1rem',
50
+ borderRadius: '0.3rem',
51
+ },
52
+ };
53
+ function getFillStyle(props) {
54
+ const { borderColor, fill, backgroundColor, color } = props;
55
+ switch (fill) {
56
+ case 'solid': {
57
+ return css `
58
+ border-color: transparent;
59
+ background-color: ${backgroundColor.base};
60
+ color: ${color.hover};
61
+ `;
62
+ }
63
+ case 'outline': {
64
+ return css `
65
+ border-style: solid;
66
+ border-color: ${backgroundColor.base};
67
+ background-color: transparent;
68
+ color: ${color.base};
69
+ `;
70
+ }
71
+ case 'clear': {
72
+ return css `
73
+ border-color: transparent;
74
+ background-color: transparent;
75
+ color: ${color.base};
76
+ `;
77
+ }
78
+ default:
79
+ return css `
80
+ background-color: ${backgroundColor.base};
81
+ color: ${color.base};
82
+ border-color: ${borderColor};
83
+ `;
84
+ }
5
85
  }
86
+ const styles = {
87
+ button: (props) => {
88
+ const { size, backgroundColor, color, borderRadius } = props;
89
+ const basic = css `
90
+ display: flex;
91
+ flex-direction: row;
92
+ border-width: 1px;
93
+ align-items: center;
94
+ `;
95
+ const fillStyle = getFillStyle(props);
96
+ const colorStyle = css `
97
+ &:not([disabled]):hover {
98
+ background-color: ${backgroundColor.hover};
99
+ color: ${color.hover};
100
+ }
101
+ &:not([disabled]):active {
102
+ background-color: ${backgroundColor?.active || backgroundColor.hover};
103
+ color: ${color?.active || color.hover};
104
+ }
105
+
106
+ &:disabled {
107
+ opacity: 0.25;
108
+ }
109
+ `;
110
+ return css([
111
+ basic,
112
+ sizeConfig[size],
113
+ fillStyle,
114
+ colorStyle,
115
+ { borderRadius },
116
+ ]);
117
+ },
118
+ };
119
+ const Button = (props) => {
120
+ const { onClick, size = 'small', color = { base: 'black', hover: 'white' }, backgroundColor = { base: 'white', hover: 'black', active: 'black' }, borderColor = 'transparent', fill, borderRadius, style = {}, ...restProps } = props;
121
+ return (_jsx("button", { type: "button", onClick: onClick, css: [
122
+ styles.button({
123
+ size,
124
+ backgroundColor,
125
+ color,
126
+ borderColor,
127
+ fill,
128
+ borderRadius,
129
+ }),
130
+ style,
131
+ ], ...restProps, children: _jsxs("span", { style: { flex: 1 }, children: [" ", props.children] }) }));
132
+ };
133
+ function ThemeButton(props) {
134
+ const { base, shade, tint } = colorPalettes[props.colorTheme];
135
+ const { color = { base: shade, hover: 'white' }, backgroundColor = {
136
+ base: base,
137
+ hover: shade,
138
+ active: tint,
139
+ }, fill = 'solid', ...restProps } = props;
140
+ return _jsx(Button, { ...{ fill, ...restProps, backgroundColor, color } });
141
+ }
142
+ Button.Done = (props) => {
143
+ return _jsx(ThemeButton, { ...props, colorTheme: "success" });
144
+ };
145
+ Button.Danger = (props) => {
146
+ return _jsx(ThemeButton, { ...props, colorTheme: "danger" });
147
+ };
148
+ Button.Action = (props) => {
149
+ return _jsx(ThemeButton, { ...props, colorTheme: "medium" });
150
+ };
151
+ export default Button;
@@ -47,22 +47,22 @@ function ContextMenu({ context }, ref) {
47
47
  left: 0,
48
48
  top: 0,
49
49
  });
50
- const { rootRef, elementsWraperRef } = useGlobal();
50
+ const { rootRef, elementsWrapperRef } = useGlobal();
51
51
  const [data, setData] = useState();
52
52
  const [isVisible, show] = useState();
53
53
  const [sourceElement, setSourceElement] = useState(null);
54
54
  const root = useRef();
55
55
  useEffect(() => {
56
56
  root.current = document.createElement('div');
57
- if (elementsWraperRef) {
58
- elementsWraperRef.appendChild(root.current);
57
+ if (elementsWrapperRef) {
58
+ elementsWrapperRef.appendChild(root.current);
59
59
  }
60
60
  return () => {
61
- if (root.current && elementsWraperRef) {
62
- elementsWraperRef.removeChild(root.current);
61
+ if (root.current && elementsWrapperRef) {
62
+ elementsWrapperRef.removeChild(root.current);
63
63
  }
64
64
  };
65
- }, [elementsWraperRef]);
65
+ }, [elementsWrapperRef]);
66
66
  const contextMenuHandler = (event) => {
67
67
  event.preventDefault();
68
68
  setSourceElement(event.target.parentElement);
@@ -23,7 +23,7 @@ function ToolTip({ style = { popup: {}, mainContainer: {} }, className = '', pop
23
23
  const refContent = useRef(null);
24
24
  const [placement, setPlacement] = useState({ x: 0, y: 0 });
25
25
  const [show, showToolTip] = useState(false);
26
- const { elementsWraperRef } = useGlobal();
26
+ const { elementsWrapperRef } = useGlobal();
27
27
  useLayoutEffect(() => {
28
28
  const getPopupPlacement = () => {
29
29
  let x;
@@ -90,11 +90,12 @@ function ToolTip({ style = { popup: {}, mainContainer: {} }, className = '', pop
90
90
  alignItems: 'center',
91
91
  ...style.mainContainer,
92
92
  }, ref: refChild, onMouseOver: mouseOverHandler, onMouseOut: mouseLeaveHandler, children: children }), show &&
93
+ elementsWrapperRef &&
93
94
  createPortal(_jsx("div", { ref: refContent, style: {
94
95
  ...styles.popup,
95
96
  transform: `translate(${placement.x + offset.x}px,${placement.y + offset.y}px)`,
96
97
  zIndex: 999999999,
97
98
  ...style.popup,
98
- }, className: className, children: _jsx("span", { style: { pointerEvents: 'none' }, children: title }) }), elementsWraperRef)] }));
99
+ }, className: className, children: _jsx("span", { style: { pointerEvents: 'none' }, children: title }) }), elementsWrapperRef)] }));
99
100
  }
100
101
  export default memo(ToolTip);
@@ -0,0 +1,2 @@
1
+ import { ResizerProps } from './Resizer';
2
+ export default function DivResizer(props: ResizerProps): import("@emotion/react/jsx-runtime").JSX.Element;