nmrium 0.42.0 → 0.43.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 (217) hide show
  1. package/lib/component/1d/ApodizationLine.js +1 -1
  2. package/lib/component/1d/Chart1D.js +3 -2
  3. package/lib/component/1d/Line.js +1 -1
  4. package/lib/component/1d/Viewer1D.js +15 -3
  5. package/lib/component/1d/integral/IntegralResizable.js +4 -3
  6. package/lib/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  7. package/lib/component/1d/peaks/PeakAnnotations.js +20 -25
  8. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +2 -0
  9. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.js +59 -0
  10. package/lib/component/1d/peaks/PeakEditionManager.d.ts +18 -0
  11. package/lib/component/1d/peaks/PeakEditionManager.js +98 -0
  12. package/lib/component/1d/peaks/Peaks.d.ts +1 -0
  13. package/lib/component/1d/peaks/Peaks.js +22 -0
  14. package/lib/component/1d/ranges/Range.js +3 -1
  15. package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
  16. package/lib/component/1d/tool/BaseLineZones.js +11 -31
  17. package/lib/component/1d/utilities/intersectionResolver.d.ts +25 -0
  18. package/lib/component/1d/utilities/intersectionResolver.js +71 -0
  19. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  20. package/lib/component/2d/SlicingView.js +1 -1
  21. package/lib/component/2d/ft/Contours.js +1 -1
  22. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +5 -1
  23. package/lib/component/EventsTrackers/KeysListenerTracker.js +47 -6
  24. package/lib/component/assignment/index.d.ts +6 -1
  25. package/lib/component/assignment/index.js +5 -1
  26. package/lib/component/context/DispatchContext.d.ts +1 -2
  27. package/lib/component/context/KeyModifierContext.d.ts +13 -0
  28. package/lib/component/context/KeyModifierContext.js +39 -0
  29. package/lib/component/context/PreferencesContext.d.ts +39 -39
  30. package/lib/component/elements/Button.js +2 -0
  31. package/lib/component/elements/NumberInput.d.ts +1 -0
  32. package/lib/component/elements/NumberInput.js +10 -3
  33. package/lib/component/elements/formik/FormikOnChange.js +1 -1
  34. package/lib/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  35. package/lib/component/header/ApodizationOptionsPanel.js +23 -14
  36. package/lib/component/header/BaseLineCorrectionPanel.js +31 -10
  37. package/lib/component/header/Header.d.ts +10 -3
  38. package/lib/component/header/Header.js +5 -5
  39. package/lib/component/header/ZeroFillingOptionsPanel.js +37 -31
  40. package/lib/component/highlight/index.d.ts +1 -0
  41. package/lib/component/highlight/index.js +1 -0
  42. package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  43. package/lib/component/hooks/useCheckToolsVisibility.js +7 -3
  44. package/lib/component/hooks/useResizerStatus.d.ts +2 -0
  45. package/lib/component/hooks/useResizerStatus.js +7 -0
  46. package/lib/component/hooks/useSpectrum.js +1 -1
  47. package/lib/component/main/ErrorOverlay.js +20 -0
  48. package/lib/component/main/InnerNMRium.d.ts +7 -0
  49. package/lib/component/main/InnerNMRium.js +52 -0
  50. package/lib/component/main/InnerNMRiumContents.d.ts +14 -0
  51. package/lib/component/main/InnerNMRiumContents.js +89 -0
  52. package/lib/component/main/NMRium.d.ts +23 -0
  53. package/lib/component/main/NMRium.js +13 -0
  54. package/lib/component/main/NMRiumStateProvider.d.ts +9 -0
  55. package/lib/component/main/NMRiumStateProvider.js +74 -0
  56. package/lib/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  57. package/lib/component/main/StateError.d.ts +4 -0
  58. package/lib/component/main/StateError.js +16 -0
  59. package/lib/component/main/index.d.ts +3 -0
  60. package/lib/component/main/index.js +3 -0
  61. package/lib/component/main/types.d.ts +18 -0
  62. package/lib/component/main/types.js +2 -0
  63. package/lib/component/modal/PredictSpectraModal.js +1 -1
  64. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +5 -16
  65. package/lib/component/modal/changeSum/ChangeSumModal.js +6 -115
  66. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +18 -0
  67. package/lib/component/modal/changeSum/ChangeSumModalContents.js +94 -0
  68. package/lib/component/modal/setting/GeneralSettings.js +2 -2
  69. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  70. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
  71. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -4
  72. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +3 -9
  73. package/lib/component/panels/MoleculesPanel/Utilities.js +14 -10
  74. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +3 -3
  75. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  76. package/lib/component/panels/PeaksPanel/PeaksPanel.js +11 -5
  77. package/lib/component/panels/RangesPanel/RangesHeader.js +6 -10
  78. package/lib/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  79. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  80. package/lib/component/panels/ZonesPanel/ZonesPanel.js +3 -2
  81. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  82. package/lib/component/panels/header/DefaultPanelHeader.d.ts +3 -4
  83. package/lib/component/panels/header/DefaultPanelHeader.js +9 -5
  84. package/lib/component/panels/predictionPanel/PredictionPanel.js +1 -1
  85. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  86. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  87. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  88. package/lib/component/reducer/IgnoreActions.js +0 -1
  89. package/lib/component/reducer/Reducer.d.ts +1 -6
  90. package/lib/component/reducer/Reducer.js +30 -6
  91. package/lib/component/reducer/actions/FiltersActions.d.ts +32 -11
  92. package/lib/component/reducer/actions/FiltersActions.js +96 -28
  93. package/lib/component/reducer/actions/IntegralsActions.d.ts +6 -2
  94. package/lib/component/reducer/actions/IntegralsActions.js +44 -20
  95. package/lib/component/reducer/actions/MoleculeActions.js +1 -1
  96. package/lib/component/reducer/actions/PeaksActions.d.ts +6 -4
  97. package/lib/component/reducer/actions/PeaksActions.js +19 -1
  98. package/lib/component/reducer/actions/RangesActions.d.ts +6 -2
  99. package/lib/component/reducer/actions/RangesActions.js +31 -3
  100. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  101. package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.d.ts +1 -1
  102. package/lib/component/toolbar/FunctionToolBar.js +13 -3
  103. package/lib/component/toolbar/ToolTypes.d.ts +1 -0
  104. package/lib/component/toolbar/ToolTypes.js +36 -0
  105. package/lib/component/utility/export.js +7 -4
  106. package/lib/component/utility/filterType.d.ts +3 -0
  107. package/lib/component/utility/filterType.js +1 -0
  108. package/lib/component/workspaces/basic.js +2 -0
  109. package/lib/component/workspaces/embedded.js +2 -0
  110. package/lib/component/workspaces/exercise.js +2 -0
  111. package/lib/component/workspaces/prediction.js +9 -0
  112. package/lib/component/workspaces/process1D.js +2 -0
  113. package/lib/component/workspaces/workspaceDefaultProperties.js +2 -0
  114. package/lib/data/PredictionManager.d.ts +3 -3
  115. package/lib/data/PredictionManager.js +10 -10
  116. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -2
  117. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +2 -8
  118. package/lib/data/molecules/Molecule.js +2 -2
  119. package/lib/data/utilities/checkModifierKeyActivated.d.ts +1 -1
  120. package/lib/data/utilities/checkModifierKeyActivated.js +8 -13
  121. package/lib/versionInfo.js +1 -1
  122. package/lib-cjs/component/1d/ApodizationLine.js +1 -1
  123. package/lib-cjs/component/1d/Chart1D.js +3 -2
  124. package/lib-cjs/component/1d/Line.js +1 -1
  125. package/lib-cjs/component/1d/Viewer1D.js +15 -3
  126. package/lib-cjs/component/1d/integral/IntegralResizable.js +4 -3
  127. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  128. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +19 -24
  129. package/lib-cjs/component/1d/peaks/PeakAnnotationsSpreadMode.js +64 -0
  130. package/lib-cjs/component/1d/peaks/PeakEditionManager.js +129 -0
  131. package/lib-cjs/component/1d/peaks/Peaks.js +29 -0
  132. package/lib-cjs/component/1d/ranges/Range.js +3 -1
  133. package/lib-cjs/component/1d/tool/BaseLineZones.js +11 -34
  134. package/lib-cjs/component/1d/utilities/intersectionResolver.js +75 -0
  135. package/lib-cjs/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  136. package/lib-cjs/component/2d/SlicingView.js +1 -1
  137. package/lib-cjs/component/2d/ft/Contours.js +1 -1
  138. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +46 -5
  139. package/lib-cjs/component/assignment/index.js +5 -1
  140. package/lib-cjs/component/context/KeyModifierContext.js +44 -0
  141. package/lib-cjs/component/elements/Button.js +2 -0
  142. package/lib-cjs/component/elements/NumberInput.js +12 -2
  143. package/lib-cjs/component/elements/formik/FormikOnChange.js +1 -1
  144. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  145. package/lib-cjs/component/header/ApodizationOptionsPanel.js +23 -14
  146. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +30 -9
  147. package/lib-cjs/component/header/Header.js +5 -5
  148. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +35 -29
  149. package/lib-cjs/component/highlight/index.js +1 -0
  150. package/lib-cjs/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  151. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +7 -3
  152. package/lib-cjs/component/hooks/useResizerStatus.js +11 -0
  153. package/lib-cjs/component/hooks/useSpectrum.js +1 -1
  154. package/lib-cjs/component/main/ErrorOverlay.js +26 -0
  155. package/lib-cjs/component/main/InnerNMRium.js +82 -0
  156. package/lib-cjs/component/main/InnerNMRiumContents.js +96 -0
  157. package/lib-cjs/component/main/NMRium.js +19 -0
  158. package/lib-cjs/component/main/NMRiumStateProvider.js +80 -0
  159. package/lib-cjs/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  160. package/lib-cjs/component/main/StateError.js +20 -0
  161. package/lib-cjs/component/main/index.js +21 -0
  162. package/lib-cjs/component/main/types.js +3 -0
  163. package/lib-cjs/component/modal/PredictSpectraModal.js +1 -1
  164. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +6 -141
  165. package/lib-cjs/component/modal/changeSum/ChangeSumModalContents.js +124 -0
  166. package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -2
  167. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
  168. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +2 -4
  169. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +14 -10
  170. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  171. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +32 -3
  172. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +29 -10
  173. package/lib-cjs/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  174. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +27 -3
  175. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +26 -2
  176. package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  177. package/lib-cjs/component/panels/header/DefaultPanelHeader.js +11 -5
  178. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +1 -1
  179. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  180. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  181. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  182. package/lib-cjs/component/reducer/IgnoreActions.js +0 -1
  183. package/lib-cjs/component/reducer/Reducer.js +29 -5
  184. package/lib-cjs/component/reducer/actions/FiltersActions.js +98 -28
  185. package/lib-cjs/component/reducer/actions/IntegralsActions.js +45 -20
  186. package/lib-cjs/component/reducer/actions/MoleculeActions.js +1 -1
  187. package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
  188. package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
  189. package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
  190. package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
  191. package/lib-cjs/component/utility/export.js +7 -4
  192. package/lib-cjs/component/utility/filterType.js +2 -0
  193. package/lib-cjs/component/workspaces/basic.js +2 -0
  194. package/lib-cjs/component/workspaces/embedded.js +2 -0
  195. package/lib-cjs/component/workspaces/exercise.js +2 -0
  196. package/lib-cjs/component/workspaces/prediction.js +9 -0
  197. package/lib-cjs/component/workspaces/process1D.js +2 -0
  198. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +2 -0
  199. package/lib-cjs/data/PredictionManager.js +9 -9
  200. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
  201. package/lib-cjs/data/molecules/Molecule.js +2 -2
  202. package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
  203. package/lib-cjs/versionInfo.js +1 -1
  204. package/package.json +26 -25
  205. package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
  206. package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
  207. package/lib/component/ErrorOverlay.js +0 -27
  208. package/lib/component/NMRium.d.ts +0 -42
  209. package/lib/component/NMRium.js +0 -237
  210. package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
  211. package/lib/component/reducer/actions/GlobalActions.js +0 -4
  212. package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
  213. package/lib-cjs/component/ErrorOverlay.js +0 -30
  214. package/lib-cjs/component/NMRium.js +0 -267
  215. package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
  216. /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
  217. /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
@@ -1,16 +1,18 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Filters } from 'nmr-processing';
3
- import { useEffect, useState, memo } from 'react';
4
- import { Checkbox } from 'react-science/ui';
3
+ import { memo, useRef } from 'react';
5
4
  import generateNumbersPowerOfX from '../../data/utilities/generateNumbersPowerOfX';
6
5
  import { useDispatch } from '../context/DispatchContext';
7
6
  import ActionButtons from '../elements/ActionButtons';
8
7
  import Label from '../elements/Label';
9
- import Select from '../elements/Select';
10
8
  import { useFilter } from '../hooks/useFilter';
11
9
  import useSpectrum from '../hooks/useSpectrum';
12
10
  import { headerLabelStyle } from './Header';
13
11
  import { HeaderContainer } from './HeaderContainer';
12
+ import { Formik } from 'formik';
13
+ import FormikSelect from '../elements/formik/FormikSelect';
14
+ import FormikCheckBox from '../elements/formik/FormikCheckBox';
15
+ import FormikOnChange from '../elements/formik/FormikOnChange';
14
16
  const Sizes = generateNumbersPowerOfX(8, 21);
15
17
  function useInitZeroFillingSize() {
16
18
  const filter = useFilter(Filters.zeroFilling.id);
@@ -24,40 +26,44 @@ function useInitZeroFillingSize() {
24
26
  return 0;
25
27
  }
26
28
  function ZeroFillingOptionsInnerPanel(props) {
29
+ const { size } = props;
27
30
  const dispatch = useDispatch();
28
- const [livePreview, setLivePreview] = useState(true);
29
- const [size, setSize] = useState(props.size);
30
- function handleApplyFilter() {
31
- dispatch({
32
- type: 'APPLY_ZERO_FILLING_FILTER',
33
- payload: {
34
- nbPoints: size,
35
- },
36
- });
31
+ const previousPreviewRef = useRef(true);
32
+ function handleApplyFilter(values, triggerSource = 'apply') {
33
+ const { livePreview, ...options } = values;
34
+ switch (triggerSource) {
35
+ case 'onChange': {
36
+ if (livePreview || previousPreviewRef !== livePreview) {
37
+ dispatch({
38
+ type: 'CALCULATE_ZERO_FILLING_FILTER',
39
+ payload: {
40
+ options,
41
+ livePreview,
42
+ },
43
+ });
44
+ }
45
+ break;
46
+ }
47
+ case 'apply': {
48
+ dispatch({
49
+ type: 'APPLY_ZERO_FILLING_FILTER',
50
+ payload: {
51
+ options,
52
+ },
53
+ });
54
+ break;
55
+ }
56
+ default:
57
+ break;
58
+ }
59
+ previousPreviewRef.current = livePreview;
37
60
  }
38
61
  function handleCancelFilter() {
39
62
  dispatch({
40
63
  type: 'RESET_SELECTED_TOOL',
41
64
  });
42
65
  }
43
- function dispatchLiveChanges(nbPoints) {
44
- dispatch({
45
- type: 'CALCULATE_ZERO_FILLING_FILTER',
46
- payload: {
47
- nbPoints,
48
- },
49
- });
50
- }
51
- function handleChangeSizeHandler(value) {
52
- setSize(value);
53
- }
54
- useEffect(() => {
55
- if (livePreview && size) {
56
- dispatchLiveChanges(size);
57
- }
58
- // eslint-disable-next-line react-hooks/exhaustive-deps
59
- }, [size, livePreview]);
60
- return (_jsxs(HeaderContainer, { children: [_jsx(Label, { title: "Size: ", style: headerLabelStyle, children: _jsx(Select, { items: Sizes, style: { marginLeft: 10, marginRight: 10 }, value: size, onChange: handleChangeSizeHandler }) }), _jsx(Checkbox, { label: "Live preview", checked: livePreview, onChange: setLivePreview }), _jsx(ActionButtons, { onDone: handleApplyFilter, onCancel: handleCancelFilter })] }));
66
+ return (_jsx(HeaderContainer, { children: _jsx(Formik, { onSubmit: (values) => handleApplyFilter(values), initialValues: { nbPoints: size, livePreview: true }, children: ({ submitForm }) => (_jsxs(_Fragment, { children: [_jsx(Label, { title: "Size: ", style: headerLabelStyle, children: _jsx(FormikSelect, { items: Sizes, style: { marginLeft: 10, marginRight: 10 }, name: "nbPoints" }) }), _jsx(Label, { title: "Live preview ", htmlFor: "livePreview", style: { label: { padding: '0 5px' } }, children: _jsx(FormikCheckBox, { name: "livePreview" }) }), _jsx(FormikOnChange, { onChange: (values) => handleApplyFilter(values, 'onChange'), enableOnload: true }), _jsx(ActionButtons, { onDone: submitForm, onCancel: handleCancelFilter })] })) }) }));
61
67
  }
62
68
  const MemoizedZeroFillingOptionsPanel = memo(ZeroFillingOptionsInnerPanel);
63
69
  export default function ZeroFillingOptionsPanel() {
@@ -7,6 +7,7 @@ export declare enum HighlightEventSource {
7
7
  SIGNAL = "SIGNAL",
8
8
  RANGE = "RANGE",
9
9
  ZONE = "ZONE",
10
+ BASELINE_ZONE = "BASELINE_ZONE",
10
11
  EXCLUSION_ZONE = "EXCLUSION_ZONE",
11
12
  MATRIX_GENERATION_EXCLUSION_ZONE = "MATRIX_GENERATION_EXCLUSION_ZONE",
12
13
  MULTIPLE_ANALYSIS_ZONE = "MULTIPLE_ANALYSIS_ZONE",
@@ -7,6 +7,7 @@ export var HighlightEventSource;
7
7
  HighlightEventSource["SIGNAL"] = "SIGNAL";
8
8
  HighlightEventSource["RANGE"] = "RANGE";
9
9
  HighlightEventSource["ZONE"] = "ZONE";
10
+ HighlightEventSource["BASELINE_ZONE"] = "BASELINE_ZONE";
10
11
  HighlightEventSource["EXCLUSION_ZONE"] = "EXCLUSION_ZONE";
11
12
  HighlightEventSource["MATRIX_GENERATION_EXCLUSION_ZONE"] = "MATRIX_GENERATION_EXCLUSION_ZONE";
12
13
  HighlightEventSource["MULTIPLE_ANALYSIS_ZONE"] = "MULTIPLE_ANALYSIS_ZONE";
@@ -4,6 +4,7 @@ export const defaultPeaksViewState = {
4
4
  isPeaksVisible: true,
5
5
  showPeaksShapes: false,
6
6
  showPeaksSum: false,
7
+ displayingMode: 'spread',
7
8
  };
8
9
  export function useActiveSpectrumPeaksViewState() {
9
10
  const activeSpectrum = useActiveSpectrum();
@@ -3,24 +3,28 @@ import { useCallback } from 'react';
3
3
  import { useChartData } from '../context/ChartContext';
4
4
  import { usePreferences } from '../context/PreferencesContext';
5
5
  import { options } from '../toolbar/ToolTypes';
6
+ import useCheckExperimentalFeature from './useCheckExperimentalFeature';
6
7
  import useSpectrum from './useSpectrum';
7
8
  export function useCheckToolsVisibility() {
8
9
  const { displayerMode } = useChartData();
9
10
  const preferences = usePreferences();
10
11
  const spectrum = useSpectrum(null);
12
+ const isExperimentalFeatureActivated = useCheckExperimentalFeature();
11
13
  return useCallback((toolKey, checkOptions = {}) => {
12
14
  const { checkMode = true, checkSpectrumType = true, extraInfoCheckParameters, } = checkOptions;
15
+ const { spectraOptions, mode, isExperimental } = options[toolKey];
13
16
  const flag = lodashGet(preferences.current, `display.toolBarButtons.${toolKey}`, false);
14
- const { spectraOptions, mode } = options[toolKey];
15
17
  const modeFlag = !checkMode || (checkMode && (!mode || displayerMode === mode));
16
18
  const spectrumCheckFlag = !checkSpectrumType ||
17
19
  (checkSpectrumType && checkSpectrum(spectrum, spectraOptions));
18
- return (flag &&
20
+ const isToolActivated = (flag && !isExperimental) ||
21
+ (isExperimental && isExperimentalFeatureActivated);
22
+ return (isToolActivated &&
19
23
  modeFlag &&
20
24
  spectrumCheckFlag &&
21
25
  (!extraInfoCheckParameters ||
22
26
  checkInfo(extraInfoCheckParameters, spectrum?.info)));
23
- }, [displayerMode, preferences, spectrum]);
27
+ }, [displayerMode, isExperimentalFeatureActivated, preferences, spectrum]);
24
28
  }
25
29
  function checkSpectrum(spectrum, options) {
26
30
  let outerConditionResult = false;
@@ -0,0 +1,2 @@
1
+ import { NMRiumToolBarPreferences } from 'nmr-load-save';
2
+ export declare function useResizerStatus(toolKey: keyof NMRiumToolBarPreferences): boolean;
@@ -0,0 +1,7 @@
1
+ import { useChartData } from '../context/ChartContext';
2
+ import { useKeyModifiers } from '../context/KeyModifierContext';
3
+ export function useResizerStatus(toolKey) {
4
+ const { toolOptions: { selectedTool }, } = useChartData();
5
+ const { shiftKey } = useKeyModifiers();
6
+ return !shiftKey && selectedTool === toolKey;
7
+ }
@@ -5,7 +5,7 @@ export default function useSpectrum(defaultValue = null) {
5
5
  const { data } = useChartData();
6
6
  const activeSpectrum = useActiveSpectrum();
7
7
  return useMemo(() => {
8
- if (data && activeSpectrum && activeSpectrum.id) {
8
+ if (data && activeSpectrum?.id) {
9
9
  const datum = data.find((datum) => datum.id === activeSpectrum.id) || defaultValue;
10
10
  return datum;
11
11
  }
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styled from '@emotion/styled';
3
+ const WrongP = styled.p `
4
+ background-color: white;
5
+ padding: 20px;
6
+ border-radius: 10px;
7
+ font-size: 30px;
8
+ text-align: center;
9
+ `;
10
+ const Details = styled.details `
11
+ margin-top: 10px;
12
+ white-space: pre-wrap;
13
+ background-color: white;
14
+ padding: 20px;
15
+ border-radius: 10px;
16
+ color: red;
17
+ `;
18
+ export default function ErrorOverlay(props) {
19
+ return (_jsxs("div", { style: { margin: 25 }, children: [_jsx(WrongP, { children: "Something went wrong." }), _jsxs(Details, { children: [_jsx("p", { style: { textDecoration: 'underline' }, children: props.error.message }), props.error.stack] })] }));
20
+ }
@@ -0,0 +1,7 @@
1
+ import { ForwardedRef } from 'react';
2
+ import type { NMRiumProps, NMRiumRef } from './NMRium';
3
+ type InnerNMRiumProps = Omit<NMRiumProps, 'onError'> & {
4
+ innerRef: ForwardedRef<NMRiumRef>;
5
+ };
6
+ export declare function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner, onChange, emptyText, innerRef, }: InnerNMRiumProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useReducer, useRef, useImperativeHandle, } from 'react';
3
+ import { useOnOff } from 'react-science/ui';
4
+ import { useFullscreen } from 'react-use';
5
+ import { AssignmentProvider } from '../assignment';
6
+ import { GlobalProvider } from '../context/GlobalContext';
7
+ import { KeyModifiersProvider } from '../context/KeyModifierContext';
8
+ import { LoggerProvider } from '../context/LoggerContext';
9
+ import { PreferencesProvider } from '../context/PreferencesContext';
10
+ import { AlertProvider } from '../elements/popup/Alert';
11
+ import { ModalProvider } from '../elements/popup/Modal';
12
+ import { HighlightProvider } from '../highlight';
13
+ import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
14
+ import preferencesReducer, { preferencesInitialState, initPreferencesState, } from '../reducer/preferences/preferencesReducer';
15
+ import { getBlob } from '../utility/export';
16
+ import { InnerNMRiumContents } from './InnerNMRiumContents';
17
+ import NMRiumStateProvider from './NMRiumStateProvider';
18
+ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, preferences, getSpinner = defaultGetSpinner, onChange, emptyText, innerRef, }) {
19
+ const rootRef = useRef(null);
20
+ const elementsWrapperRef = useRef(null);
21
+ const viewerRef = useRef(null);
22
+ const [enableFullscreen, , disableFullscreen, toggleFullscreen] = useOnOff(false);
23
+ const mainDivRef = useRef(null);
24
+ const isFullscreenEnabled = useFullscreen(rootRef, enableFullscreen, {
25
+ onClose: disableFullscreen,
26
+ });
27
+ const [preferencesState, dispatchPreferences] = useReducer(preferencesReducer, preferencesInitialState, initPreferencesState);
28
+ useEffect(() => {
29
+ rootRef.current?.focus();
30
+ }, [isFullscreenEnabled]);
31
+ useEffect(() => {
32
+ dispatchPreferences({
33
+ type: 'INIT_PREFERENCES',
34
+ payload: {
35
+ preferences,
36
+ workspace,
37
+ customWorkspaces,
38
+ dispatch: dispatchPreferences,
39
+ },
40
+ });
41
+ }, [customWorkspaces, preferences, workspace]);
42
+ useImperativeHandle(innerRef, () => ({
43
+ getSpectraViewerAsBlob: () => {
44
+ return rootRef?.current ? getBlob(rootRef.current, 'nmrSVG') : null;
45
+ },
46
+ }), []);
47
+ return (_jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(GlobalProvider, { value: {
48
+ rootRef: rootRef.current,
49
+ elementsWrapperRef: elementsWrapperRef.current,
50
+ viewerRef: viewerRef.current,
51
+ }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx(LoggerProvider, { children: _jsx(KeyModifiersProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(NMRiumStateProvider, { onChange: onChange, nmriumData: nmriumData, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx(InnerNMRiumContents, { isFullscreenEnabled: isFullscreenEnabled, toggleFullscreen: toggleFullscreen, emptyText: emptyText, mainDivRef: mainDivRef, elementsWrapperRef: elementsWrapperRef, rootRef: rootRef, viewerRef: viewerRef }) }) }) }) }) }) }) }) }) }) }) }));
52
+ }
@@ -0,0 +1,14 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { RefObject } from 'react';
3
+ import { NMRiumProps } from '.';
4
+ interface InnerNMRiumContentsProps {
5
+ isFullscreenEnabled: boolean;
6
+ toggleFullscreen: () => void;
7
+ emptyText: NMRiumProps['emptyText'];
8
+ mainDivRef: RefObject<HTMLDivElement>;
9
+ elementsWrapperRef: RefObject<HTMLDivElement>;
10
+ rootRef: RefObject<HTMLDivElement>;
11
+ viewerRef: RefObject<HTMLDivElement>;
12
+ }
13
+ export declare function InnerNMRiumContents(props: InnerNMRiumContentsProps): import("@emotion/react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -0,0 +1,89 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { useCallback } from 'react';
5
+ import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
6
+ import Viewer1D from '../1d/Viewer1D';
7
+ import FloatMoleculeStructures from '../1d-2d/components/FloatMoleculeStructures';
8
+ import Viewer2D from '../2d/Viewer2D';
9
+ import KeysListenerTracker from '../EventsTrackers/KeysListenerTracker';
10
+ import { useChartData } from '../context/ChartContext';
11
+ import Header from '../header/Header';
12
+ import DropZone from '../loader/DropZone';
13
+ import Panels from '../panels/Panels';
14
+ import { DISPLAYER_MODE } from '../reducer/core/Constants';
15
+ import ToolBar from '../toolbar/ToolBar';
16
+ import { SplitPaneWrapper } from './SplitPaneWrapper';
17
+ import { StateError } from './StateError';
18
+ const viewerContainerStyle = css `
19
+ border: 0.55px #e6e6e6 solid;
20
+ display: flex;
21
+ flex: 1;
22
+ flex-direction: column;
23
+ height: 100%;
24
+ margin-left: -1px;
25
+ `;
26
+ const containerStyles = css `
27
+ background-color: white;
28
+ width: 100%;
29
+ display: block;
30
+ height: 100%;
31
+
32
+ div:focus {
33
+ outline: none !important;
34
+ }
35
+
36
+ button {
37
+ cursor: pointer;
38
+ }
39
+
40
+ button,
41
+ button:active,
42
+ button:hover,
43
+ button:focus,
44
+ [type='button']:focus {
45
+ outline: none !important;
46
+ }
47
+
48
+ button:disabled {
49
+ cursor: default;
50
+ }
51
+
52
+ * {
53
+ -webkit-user-drag: none;
54
+ -moz-user-drag: none;
55
+ -o-user-drag: none;
56
+ user-select: none;
57
+ }
58
+ `;
59
+ export function InnerNMRiumContents(props) {
60
+ const { isFullscreenEnabled, toggleFullscreen, emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef, } = props;
61
+ const { displayerMode } = useChartData();
62
+ const preventContextMenuHandler = useCallback((e) => {
63
+ if (!checkModifierKeyActivated(e)) {
64
+ e.preventDefault();
65
+ }
66
+ }, []);
67
+ return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
68
+ display: 'flex',
69
+ flexDirection: 'column',
70
+ backgroundColor: 'white',
71
+ width: '100%',
72
+ }, children: [_jsx(Header, { isFullscreenEnabled: isFullscreenEnabled, onEnableFullscreen: toggleFullscreen }), _jsxs("div", { style: {
73
+ display: 'flex',
74
+ flexDirection: 'row',
75
+ height: '100%',
76
+ }, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, { mainDivRef: mainDivRef }), _jsxs("div", { id: "nmrium-viewer", "data-testid": "viewer", ref: viewerRef, style: {
77
+ width: '100%',
78
+ height: '100%',
79
+ position: 'relative',
80
+ }, children: [_jsx(FloatMoleculeStructures, {}), displayerMode === DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
81
+ position: 'absolute',
82
+ pointerEvents: 'none',
83
+ zIndex: 2,
84
+ left: 0,
85
+ right: 0,
86
+ top: 0,
87
+ bottom: 0,
88
+ } }, String(isFullscreenEnabled))] })] }) }) })] }));
89
+ }
@@ -0,0 +1,23 @@
1
+ import type { CustomWorkspaces, WorkspacePreferences as NMRiumPreferences } from 'nmr-load-save';
2
+ import { ReactElement, ReactNode } from 'react';
3
+ import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
4
+ import { BlobObject } from '../utility/export';
5
+ import { NMRiumChangeCb, NMRiumData, NMRiumWorkspace } from './types';
6
+ export interface NMRiumProps {
7
+ data?: NMRiumData;
8
+ onChange?: NMRiumChangeCb;
9
+ noErrorBoundary?: boolean;
10
+ onError?: ErrorBoundaryPropsWithComponent['onError'];
11
+ workspace?: NMRiumWorkspace;
12
+ customWorkspaces?: CustomWorkspaces;
13
+ preferences?: NMRiumPreferences;
14
+ emptyText?: ReactNode;
15
+ /**
16
+ * Returns a custom spinner that will be rendered while loading data.
17
+ */
18
+ getSpinner?: () => ReactElement;
19
+ }
20
+ export interface NMRiumRef {
21
+ getSpectraViewerAsBlob: () => BlobObject | null;
22
+ }
23
+ export declare const NMRium: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<NMRiumProps & import("react").RefAttributes<NMRiumRef>>>;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { memo, forwardRef } from 'react';
3
+ import { ErrorBoundary, } from 'react-error-boundary';
4
+ import { RootLayout } from 'react-science/ui';
5
+ import ErrorOverlay from './ErrorOverlay';
6
+ import { InnerNMRium } from './InnerNMRium';
7
+ const NMRiumBase = forwardRef(function NMRium(props, ref) {
8
+ const { noErrorBoundary = false, onError, ...otherProps } = props;
9
+ const innerNmrium = _jsx(InnerNMRium, { ...otherProps, innerRef: ref });
10
+ const children = noErrorBoundary ? (innerNmrium) : (_jsx(ErrorBoundary, { FallbackComponent: ErrorOverlay, onError: onError, children: innerNmrium }));
11
+ return _jsx(RootLayout, { style: { width: '100%' }, children: children });
12
+ });
13
+ export const NMRium = memo(NMRiumBase);
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { NMRiumChangeCb, NMRiumData } from './types';
3
+ interface NMRiumStateProviderProps {
4
+ children: ReactNode;
5
+ onChange: NMRiumChangeCb | undefined;
6
+ nmriumData: NMRiumData | undefined;
7
+ }
8
+ export default function NMRiumStateProvider(props: NMRiumStateProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { readNMRiumObject } from 'nmr-load-save';
3
+ import { useCallback, useEffect, useReducer, useRef } from 'react';
4
+ import { toJSON } from '../../data/SpectraManager';
5
+ import { ChartDataProvider } from '../context/ChartContext';
6
+ import { DispatchProvider } from '../context/DispatchContext';
7
+ import { useLogger } from '../context/LoggerContext';
8
+ import { usePreferences } from '../context/PreferencesContext';
9
+ import checkActionType from '../reducer/IgnoreActions';
10
+ import { spectrumReducer, initialState, initState } from '../reducer/Reducer';
11
+ const defaultData = {
12
+ spectra: [],
13
+ };
14
+ export default function NMRiumStateProvider(props) {
15
+ const { children, onChange, nmriumData = defaultData } = props;
16
+ const { logger } = useLogger();
17
+ const preferencesState = usePreferences();
18
+ const [state, dispatchRaw] = useReducer(spectrumReducer, initialState, initState);
19
+ const dispatch = useCallback((action) => {
20
+ logger.trace({ action }, `Dispatch main reducer action: ${action.type}`);
21
+ dispatchRaw(action);
22
+ }, [logger]);
23
+ const { source, data: spectraData, molecules, correlations, actionType, view, } = state;
24
+ const stateRef = useRef();
25
+ const handleChange = useRef(onChange);
26
+ useEffect(() => {
27
+ handleChange.current = onChange;
28
+ }, [onChange]);
29
+ useEffect(() => {
30
+ const { workspace, workspaces = {} } = preferencesState;
31
+ stateRef.current = toJSON({ data: spectraData, molecules, correlations, source, view, actionType }, { current: workspaces[workspace.current] }, { serialize: false, exportTarget: 'onChange' });
32
+ }, [
33
+ actionType,
34
+ correlations,
35
+ molecules,
36
+ preferencesState,
37
+ source,
38
+ spectraData,
39
+ view,
40
+ ]);
41
+ useEffect(() => {
42
+ // trigger onChange callback if data object changed
43
+ if (checkActionType(actionType)) {
44
+ handleChange.current?.(stateRef.current, 'data');
45
+ }
46
+ }, [actionType, correlations, molecules, source, spectraData]);
47
+ useEffect(() => {
48
+ // trigger onChange callback if view object changed
49
+ handleChange.current?.(stateRef.current, 'view');
50
+ }, [view]);
51
+ useEffect(() => {
52
+ // trigger onChange callback if settings changed
53
+ handleChange.current?.(stateRef.current, 'settings');
54
+ }, [preferencesState]);
55
+ useEffect(() => {
56
+ dispatch({
57
+ type: 'SET_LOADING_FLAG',
58
+ payload: { isLoading: true },
59
+ });
60
+ if (nmriumData) {
61
+ void readNMRiumObject(nmriumData)
62
+ .then((nmriumState) => {
63
+ dispatch({ type: 'INITIATE', payload: { nmriumState } });
64
+ })
65
+ .catch((error) => {
66
+ dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
67
+ // eslint-disable-next-line no-alert
68
+ alert(error.message);
69
+ reportError(error);
70
+ });
71
+ }
72
+ }, [nmriumData, dispatch]);
73
+ return (_jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: children }) }));
74
+ }
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SplitPane } from 'react-science/ui';
3
- import { usePreferences } from './context/PreferencesContext';
3
+ import { usePreferences } from '../context/PreferencesContext';
4
4
  export function SplitPaneWrapper({ children }) {
5
5
  const { current, dispatch } = usePreferences();
6
6
  const { general: { verticalSplitterPosition, verticalSplitterCloseThreshold }, display: { general = {} }, } = current;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Alert user in UI when state have errorAction (error from reducer)
3
+ */
4
+ export declare function StateError(): null;
@@ -0,0 +1,16 @@
1
+ import { useEffect } from 'react';
2
+ import { useChartData } from '../context/ChartContext';
3
+ import { useLogger } from '../context/LoggerContext';
4
+ /**
5
+ * Alert user in UI when state have errorAction (error from reducer)
6
+ */
7
+ export function StateError() {
8
+ const { errorAction } = useChartData();
9
+ const { logger } = useLogger();
10
+ useEffect(() => {
11
+ if (!errorAction)
12
+ return;
13
+ logger.error(errorAction);
14
+ }, [errorAction, logger]);
15
+ return null;
16
+ }
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export { serializeNmriumState as serializeNMRiumState } from 'nmr-load-save';
3
+ export * from './NMRium';
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export { serializeNmriumState as serializeNMRiumState } from 'nmr-load-save';
3
+ export * from './NMRium';
@@ -0,0 +1,18 @@
1
+ import { WebSource } from 'filelist-utils';
2
+ import { CorrelationData } from 'nmr-correlation';
3
+ import type { NmriumState as NMRiumState, WorkspacePreferences as NMRiumPreferences, Spectrum } from 'nmr-load-save';
4
+ type DeepPartial<T> = {
5
+ [P in keyof T]?: DeepPartial<T[P]>;
6
+ };
7
+ interface NMRiumData {
8
+ source?: WebSource;
9
+ molecules?: NMRiumMolecules;
10
+ spectra: Array<DeepPartial<Spectrum>>;
11
+ correlations?: CorrelationData;
12
+ }
13
+ type NMRiumWorkspace = 'exercise' | 'process1D' | 'default' | 'prediction' | 'embedded' | 'assignment' | 'simulation' | (string & {});
14
+ type NMRiumChangeCb = (state: NMRiumState, source: 'data' | 'view' | 'settings') => void;
15
+ type NMRiumMolecules = Array<{
16
+ molfile: string;
17
+ }>;
18
+ export type { NMRiumChangeCb, NMRiumData, NMRiumMolecules, NMRiumPreferences, NMRiumState, NMRiumWorkspace, };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ /* eslint-enable unicorn/prefer-export-from */
@@ -74,7 +74,7 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
74
74
  closeDialog();
75
75
  const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
76
76
  try {
77
- const data = await predictSpectra(molfile);
77
+ const data = await predictSpectra(molfile, values.spectra);
78
78
  dispatch({
79
79
  type: 'PREDICT_SPECTRA',
80
80
  payload: {
@@ -1,17 +1,6 @@
1
- import { SumOptions } from 'nmr-load-save';
2
- type SaveInput = {
3
- sum: number;
4
- sumAuto: false;
5
- } | {
6
- moleculeId: string;
7
- mf: string;
8
- sumAuto: true;
9
- };
10
- interface ChangeSumModalProps {
11
- onSave: (saveInput: SaveInput) => void;
12
- onClose: () => void;
13
- header: string;
14
- sumOptions: SumOptions;
1
+ import { ReactNode } from 'react';
2
+ import { ChangeSumModalContentsProps } from './ChangeSumModalContents';
3
+ export interface ChangeSumModalProps extends Omit<ChangeSumModalContentsProps, 'onClose'> {
4
+ renderButton: (onClick: () => void) => ReactNode;
15
5
  }
16
- export default function ChangeSumModal({ onSave, onClose, header, sumOptions, }: ChangeSumModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
17
- export {};
6
+ export default function ChangeSumModal({ renderButton, ...otherProps }: ChangeSumModalProps): import("react/jsx-runtime").JSX.Element;