nmrium 0.41.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 (247) 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/1d-2d/components/SpectrumInfoBlock.js +4 -1
  21. package/lib/component/2d/SlicingView.js +1 -1
  22. package/lib/component/2d/ft/Contours.js +1 -1
  23. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +5 -1
  24. package/lib/component/EventsTrackers/KeysListenerTracker.js +47 -6
  25. package/lib/component/assignment/index.d.ts +6 -1
  26. package/lib/component/assignment/index.js +5 -1
  27. package/lib/component/context/DispatchContext.d.ts +1 -2
  28. package/lib/component/context/KeyModifierContext.d.ts +13 -0
  29. package/lib/component/context/KeyModifierContext.js +39 -0
  30. package/lib/component/context/PreferencesContext.d.ts +39 -39
  31. package/lib/component/elements/Button.js +2 -0
  32. package/lib/component/elements/Input.js +1 -0
  33. package/lib/component/elements/NumberInput.d.ts +1 -0
  34. package/lib/component/elements/NumberInput.js +10 -3
  35. package/lib/component/elements/Scroller.d.ts +15 -0
  36. package/lib/component/elements/Scroller.js +31 -0
  37. package/lib/component/elements/formik/FormikOnChange.js +1 -1
  38. package/lib/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  39. package/lib/component/header/ApodizationOptionsPanel.js +23 -14
  40. package/lib/component/header/BaseLineCorrectionPanel.js +31 -10
  41. package/lib/component/header/Header.d.ts +10 -3
  42. package/lib/component/header/Header.js +5 -5
  43. package/lib/component/header/ZeroFillingOptionsPanel.js +37 -31
  44. package/lib/component/highlight/index.d.ts +1 -0
  45. package/lib/component/highlight/index.js +1 -0
  46. package/lib/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  47. package/lib/component/hooks/useCheckToolsVisibility.js +7 -3
  48. package/lib/component/hooks/useResizerStatus.d.ts +2 -0
  49. package/lib/component/hooks/useResizerStatus.js +7 -0
  50. package/lib/component/hooks/useSaveSettings.js +9 -11
  51. package/lib/component/hooks/useSpectrum.js +1 -1
  52. package/lib/component/main/ErrorOverlay.js +20 -0
  53. package/lib/component/main/InnerNMRium.d.ts +7 -0
  54. package/lib/component/main/InnerNMRium.js +52 -0
  55. package/lib/component/main/InnerNMRiumContents.d.ts +14 -0
  56. package/lib/component/main/InnerNMRiumContents.js +89 -0
  57. package/lib/component/main/NMRium.d.ts +23 -0
  58. package/lib/component/main/NMRium.js +13 -0
  59. package/lib/component/main/NMRiumStateProvider.d.ts +9 -0
  60. package/lib/component/main/NMRiumStateProvider.js +74 -0
  61. package/lib/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  62. package/lib/component/main/StateError.d.ts +4 -0
  63. package/lib/component/main/StateError.js +16 -0
  64. package/lib/component/main/index.d.ts +3 -0
  65. package/lib/component/main/index.js +3 -0
  66. package/lib/component/main/types.d.ts +18 -0
  67. package/lib/component/main/types.js +2 -0
  68. package/lib/component/modal/AboutPredictionModal.js +1 -1
  69. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  70. package/lib/component/modal/PredictSpectraModal.js +1 -1
  71. package/lib/component/modal/changeSum/ChangeSumModal.d.ts +5 -16
  72. package/lib/component/modal/changeSum/ChangeSumModal.js +6 -115
  73. package/lib/component/modal/changeSum/ChangeSumModalContents.d.ts +18 -0
  74. package/lib/component/modal/changeSum/ChangeSumModalContents.js +94 -0
  75. package/lib/component/modal/setting/GeneralSettings.js +2 -2
  76. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  77. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  78. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +6 -11
  79. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  80. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +3 -9
  81. package/lib/component/panels/MoleculesPanel/Utilities.js +14 -10
  82. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +3 -3
  83. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  84. package/lib/component/panels/PeaksPanel/PeaksPanel.js +11 -5
  85. package/lib/component/panels/RangesPanel/RangesHeader.js +6 -10
  86. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +4 -3
  87. package/lib/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  88. package/lib/component/panels/SummaryPanel/SummaryPanel.js +4 -3
  89. package/lib/component/panels/ZonesPanel/ZonesPanel.js +3 -2
  90. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  91. package/lib/component/panels/databasePanel/DatabasePanel.js +33 -26
  92. package/lib/component/panels/header/DefaultPanelHeader.d.ts +3 -4
  93. package/lib/component/panels/header/DefaultPanelHeader.js +9 -5
  94. package/lib/component/panels/predictionPanel/PredictionPanel.js +1 -1
  95. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  96. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  97. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  98. package/lib/component/reducer/IgnoreActions.js +0 -1
  99. package/lib/component/reducer/Reducer.d.ts +1 -6
  100. package/lib/component/reducer/Reducer.js +32 -6
  101. package/lib/component/reducer/actions/FiltersActions.d.ts +32 -11
  102. package/lib/component/reducer/actions/FiltersActions.js +96 -28
  103. package/lib/component/reducer/actions/IntegralsActions.d.ts +6 -2
  104. package/lib/component/reducer/actions/IntegralsActions.js +44 -20
  105. package/lib/component/reducer/actions/MoleculeActions.d.ts +6 -2
  106. package/lib/component/reducer/actions/MoleculeActions.js +8 -2
  107. package/lib/component/reducer/actions/PeaksActions.d.ts +6 -4
  108. package/lib/component/reducer/actions/PeaksActions.js +19 -1
  109. package/lib/component/reducer/actions/RangesActions.d.ts +6 -2
  110. package/lib/component/reducer/actions/RangesActions.js +31 -3
  111. package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -15
  112. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  113. package/lib/component/reducer/preferences/utilities/getPreferencesByWorkspace.d.ts +1 -1
  114. package/lib/component/toolbar/FunctionToolBar.js +13 -3
  115. package/lib/component/toolbar/ToolTypes.d.ts +1 -0
  116. package/lib/component/toolbar/ToolTypes.js +36 -0
  117. package/lib/component/utility/PathBuilder.js +11 -0
  118. package/lib/component/utility/export.js +7 -4
  119. package/lib/component/utility/filterType.d.ts +3 -0
  120. package/lib/component/utility/filterType.js +1 -0
  121. package/lib/component/workspaces/basic.js +2 -0
  122. package/lib/component/workspaces/embedded.js +2 -0
  123. package/lib/component/workspaces/exercise.js +2 -0
  124. package/lib/component/workspaces/prediction.js +9 -0
  125. package/lib/component/workspaces/process1D.js +2 -0
  126. package/lib/component/workspaces/workspaceDefaultProperties.js +10 -5
  127. package/lib/data/PredictionManager.d.ts +3 -3
  128. package/lib/data/PredictionManager.js +10 -10
  129. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +1 -2
  130. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +2 -8
  131. package/lib/data/data1d/database.d.ts +4 -2
  132. package/lib/data/data1d/database.js +10 -3
  133. package/lib/data/molecules/Molecule.js +2 -2
  134. package/lib/data/molecules/MoleculeManager.d.ts +1 -0
  135. package/lib/data/molecules/MoleculeManager.js +14 -0
  136. package/lib/data/utilities/checkModifierKeyActivated.d.ts +1 -1
  137. package/lib/data/utilities/checkModifierKeyActivated.js +8 -13
  138. package/lib/versionInfo.js +1 -1
  139. package/lib-cjs/component/1d/ApodizationLine.js +1 -1
  140. package/lib-cjs/component/1d/Chart1D.js +3 -2
  141. package/lib-cjs/component/1d/Line.js +1 -1
  142. package/lib-cjs/component/1d/Viewer1D.js +15 -3
  143. package/lib-cjs/component/1d/integral/IntegralResizable.js +4 -3
  144. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +3 -1
  145. package/lib-cjs/component/1d/peaks/PeakAnnotations.js +19 -24
  146. package/lib-cjs/component/1d/peaks/PeakAnnotationsSpreadMode.js +64 -0
  147. package/lib-cjs/component/1d/peaks/PeakEditionManager.js +129 -0
  148. package/lib-cjs/component/1d/peaks/Peaks.js +29 -0
  149. package/lib-cjs/component/1d/ranges/Range.js +3 -1
  150. package/lib-cjs/component/1d/tool/BaseLineZones.js +11 -34
  151. package/lib-cjs/component/1d/utilities/intersectionResolver.js +75 -0
  152. package/lib-cjs/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +3 -2
  153. package/lib-cjs/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  154. package/lib-cjs/component/2d/SlicingView.js +1 -1
  155. package/lib-cjs/component/2d/ft/Contours.js +1 -1
  156. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +46 -5
  157. package/lib-cjs/component/assignment/index.js +5 -1
  158. package/lib-cjs/component/context/KeyModifierContext.js +44 -0
  159. package/lib-cjs/component/elements/Button.js +2 -0
  160. package/lib-cjs/component/elements/Input.js +1 -0
  161. package/lib-cjs/component/elements/NumberInput.js +12 -2
  162. package/lib-cjs/component/elements/Scroller.js +35 -0
  163. package/lib-cjs/component/elements/formik/FormikOnChange.js +1 -1
  164. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +1 -1
  165. package/lib-cjs/component/header/ApodizationOptionsPanel.js +23 -14
  166. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +30 -9
  167. package/lib-cjs/component/header/Header.js +5 -5
  168. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +35 -29
  169. package/lib-cjs/component/highlight/index.js +1 -0
  170. package/lib-cjs/component/hooks/useActiveSpectrumPeaksViewState.js +1 -0
  171. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +7 -3
  172. package/lib-cjs/component/hooks/useResizerStatus.js +11 -0
  173. package/lib-cjs/component/hooks/useSaveSettings.js +9 -11
  174. package/lib-cjs/component/hooks/useSpectrum.js +1 -1
  175. package/lib-cjs/component/main/ErrorOverlay.js +26 -0
  176. package/lib-cjs/component/main/InnerNMRium.js +82 -0
  177. package/lib-cjs/component/main/InnerNMRiumContents.js +96 -0
  178. package/lib-cjs/component/main/NMRium.js +19 -0
  179. package/lib-cjs/component/main/NMRiumStateProvider.js +80 -0
  180. package/lib-cjs/component/{SplitPaneWrapper.js → main/SplitPaneWrapper.js} +1 -1
  181. package/lib-cjs/component/main/StateError.js +20 -0
  182. package/lib-cjs/component/main/index.js +21 -0
  183. package/lib-cjs/component/main/types.js +3 -0
  184. package/lib-cjs/component/modal/AboutPredictionModal.js +1 -1
  185. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +1 -1
  186. package/lib-cjs/component/modal/PredictSpectraModal.js +1 -1
  187. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +6 -141
  188. package/lib-cjs/component/modal/changeSum/ChangeSumModalContents.js +124 -0
  189. package/lib-cjs/component/modal/setting/GeneralSettings.js +2 -2
  190. package/lib-cjs/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  191. package/lib-cjs/component/panels/IntegralsPanel/IntegralPanel.js +29 -11
  192. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  193. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +14 -10
  194. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +4 -4
  195. package/lib-cjs/component/panels/PeaksPanel/PeaksPanel.js +32 -3
  196. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +29 -10
  197. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +3 -2
  198. package/lib-cjs/component/panels/SpectrumsPanel/base/ShowHideSpectrumButton.js +1 -1
  199. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +27 -3
  200. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +26 -2
  201. package/lib-cjs/component/panels/ZonesPanel/ZonesPreferences.js +1 -1
  202. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +33 -26
  203. package/lib-cjs/component/panels/header/DefaultPanelHeader.js +11 -5
  204. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +1 -1
  205. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +0 -1
  206. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +1 -1
  207. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -2
  208. package/lib-cjs/component/reducer/IgnoreActions.js +0 -1
  209. package/lib-cjs/component/reducer/Reducer.js +31 -5
  210. package/lib-cjs/component/reducer/actions/FiltersActions.js +98 -28
  211. package/lib-cjs/component/reducer/actions/IntegralsActions.js +45 -20
  212. package/lib-cjs/component/reducer/actions/MoleculeActions.js +9 -2
  213. package/lib-cjs/component/reducer/actions/PeaksActions.js +20 -1
  214. package/lib-cjs/component/reducer/actions/RangesActions.js +31 -2
  215. package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
  216. package/lib-cjs/component/toolbar/FunctionToolBar.js +13 -3
  217. package/lib-cjs/component/toolbar/ToolTypes.js +36 -0
  218. package/lib-cjs/component/utility/PathBuilder.js +11 -0
  219. package/lib-cjs/component/utility/export.js +7 -4
  220. package/lib-cjs/component/utility/filterType.js +2 -0
  221. package/lib-cjs/component/workspaces/basic.js +2 -0
  222. package/lib-cjs/component/workspaces/embedded.js +2 -0
  223. package/lib-cjs/component/workspaces/exercise.js +2 -0
  224. package/lib-cjs/component/workspaces/prediction.js +9 -0
  225. package/lib-cjs/component/workspaces/process1D.js +2 -0
  226. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +10 -5
  227. package/lib-cjs/data/PredictionManager.js +9 -9
  228. package/lib-cjs/data/data1d/Spectrum1D/ranges/addRange.js +1 -7
  229. package/lib-cjs/data/data1d/database.js +10 -3
  230. package/lib-cjs/data/molecules/Molecule.js +2 -2
  231. package/lib-cjs/data/molecules/MoleculeManager.js +16 -1
  232. package/lib-cjs/data/utilities/checkModifierKeyActivated.js +8 -13
  233. package/lib-cjs/versionInfo.js +1 -1
  234. package/package.json +26 -25
  235. package/lib/component/1d/peaks/PeakAnnotation.d.ts +0 -12
  236. package/lib/component/1d/peaks/PeakAnnotation.js +0 -116
  237. package/lib/component/ErrorOverlay.js +0 -27
  238. package/lib/component/NMRium.d.ts +0 -42
  239. package/lib/component/NMRium.js +0 -237
  240. package/lib/component/reducer/actions/GlobalActions.d.ts +0 -9
  241. package/lib/component/reducer/actions/GlobalActions.js +0 -4
  242. package/lib-cjs/component/1d/peaks/PeakAnnotation.js +0 -118
  243. package/lib-cjs/component/ErrorOverlay.js +0 -30
  244. package/lib-cjs/component/NMRium.js +0 -267
  245. package/lib-cjs/component/reducer/actions/GlobalActions.js +0 -7
  246. /package/lib/component/{ErrorOverlay.d.ts → main/ErrorOverlay.d.ts} +0 -0
  247. /package/lib/component/{SplitPaneWrapper.d.ts → main/SplitPaneWrapper.d.ts} +0 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.InnerNMRiumContents = void 0;
7
+ const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
8
+ /** @jsxImportSource @emotion/react */
9
+ const react_1 = require("@emotion/react");
10
+ const react_2 = require("react");
11
+ const checkModifierKeyActivated_1 = __importDefault(require("../../data/utilities/checkModifierKeyActivated"));
12
+ const Viewer1D_1 = __importDefault(require("../1d/Viewer1D"));
13
+ const FloatMoleculeStructures_1 = __importDefault(require("../1d-2d/components/FloatMoleculeStructures"));
14
+ const Viewer2D_1 = __importDefault(require("../2d/Viewer2D"));
15
+ const KeysListenerTracker_1 = __importDefault(require("../EventsTrackers/KeysListenerTracker"));
16
+ const ChartContext_1 = require("../context/ChartContext");
17
+ const Header_1 = __importDefault(require("../header/Header"));
18
+ const DropZone_1 = __importDefault(require("../loader/DropZone"));
19
+ const Panels_1 = __importDefault(require("../panels/Panels"));
20
+ const Constants_1 = require("../reducer/core/Constants");
21
+ const ToolBar_1 = __importDefault(require("../toolbar/ToolBar"));
22
+ const SplitPaneWrapper_1 = require("./SplitPaneWrapper");
23
+ const StateError_1 = require("./StateError");
24
+ const viewerContainerStyle = (0, react_1.css) `
25
+ border: 0.55px #e6e6e6 solid;
26
+ display: flex;
27
+ flex: 1;
28
+ flex-direction: column;
29
+ height: 100%;
30
+ margin-left: -1px;
31
+ `;
32
+ const containerStyles = (0, react_1.css) `
33
+ background-color: white;
34
+ width: 100%;
35
+ display: block;
36
+ height: 100%;
37
+
38
+ div:focus {
39
+ outline: none !important;
40
+ }
41
+
42
+ button {
43
+ cursor: pointer;
44
+ }
45
+
46
+ button,
47
+ button:active,
48
+ button:hover,
49
+ button:focus,
50
+ [type='button']:focus {
51
+ outline: none !important;
52
+ }
53
+
54
+ button:disabled {
55
+ cursor: default;
56
+ }
57
+
58
+ * {
59
+ -webkit-user-drag: none;
60
+ -moz-user-drag: none;
61
+ -o-user-drag: none;
62
+ user-select: none;
63
+ }
64
+ `;
65
+ function InnerNMRiumContents(props) {
66
+ const { isFullscreenEnabled, toggleFullscreen, emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef, } = props;
67
+ const { displayerMode } = (0, ChartContext_1.useChartData)();
68
+ const preventContextMenuHandler = (0, react_2.useCallback)((e) => {
69
+ if (!(0, checkModifierKeyActivated_1.default)(e)) {
70
+ e.preventDefault();
71
+ }
72
+ }, []);
73
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(StateError_1.StateError, {}), (0, jsx_runtime_1.jsx)("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: (0, jsx_runtime_1.jsx)(DropZone_1.default, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
74
+ display: 'flex',
75
+ flexDirection: 'column',
76
+ backgroundColor: 'white',
77
+ width: '100%',
78
+ }, children: [(0, jsx_runtime_1.jsx)(Header_1.default, { isFullscreenEnabled: isFullscreenEnabled, onEnableFullscreen: toggleFullscreen }), (0, jsx_runtime_1.jsxs)("div", { style: {
79
+ display: 'flex',
80
+ flexDirection: 'row',
81
+ height: '100%',
82
+ }, children: [(0, jsx_runtime_1.jsx)(ToolBar_1.default, {}), (0, jsx_runtime_1.jsxs)(SplitPaneWrapper_1.SplitPaneWrapper, { children: [(0, jsx_runtime_1.jsxs)("div", { css: viewerContainerStyle, children: [(0, jsx_runtime_1.jsx)(KeysListenerTracker_1.default, { mainDivRef: mainDivRef }), (0, jsx_runtime_1.jsxs)("div", { id: "nmrium-viewer", "data-testid": "viewer", ref: viewerRef, style: {
83
+ width: '100%',
84
+ height: '100%',
85
+ position: 'relative',
86
+ }, children: [(0, jsx_runtime_1.jsx)(FloatMoleculeStructures_1.default, {}), displayerMode === Constants_1.DISPLAYER_MODE.DM_1D ? ((0, jsx_runtime_1.jsx)(Viewer1D_1.default, { emptyText: emptyText })) : ((0, jsx_runtime_1.jsx)(Viewer2D_1.default, { emptyText: emptyText }))] })] }), (0, jsx_runtime_1.jsx)(Panels_1.default, {})] }), (0, jsx_runtime_1.jsx)("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
87
+ position: 'absolute',
88
+ pointerEvents: 'none',
89
+ zIndex: 2,
90
+ left: 0,
91
+ right: 0,
92
+ top: 0,
93
+ bottom: 0,
94
+ } }, String(isFullscreenEnabled))] })] }) }) })] }));
95
+ }
96
+ exports.InnerNMRiumContents = InnerNMRiumContents;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NMRium = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = require("react");
9
+ const react_error_boundary_1 = require("react-error-boundary");
10
+ const ui_1 = require("react-science/ui");
11
+ const ErrorOverlay_1 = __importDefault(require("./ErrorOverlay"));
12
+ const InnerNMRium_1 = require("./InnerNMRium");
13
+ const NMRiumBase = (0, react_1.forwardRef)(function NMRium(props, ref) {
14
+ const { noErrorBoundary = false, onError, ...otherProps } = props;
15
+ const innerNmrium = (0, jsx_runtime_1.jsx)(InnerNMRium_1.InnerNMRium, { ...otherProps, innerRef: ref });
16
+ const children = noErrorBoundary ? (innerNmrium) : ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { FallbackComponent: ErrorOverlay_1.default, onError: onError, children: innerNmrium }));
17
+ return (0, jsx_runtime_1.jsx)(ui_1.RootLayout, { style: { width: '100%' }, children: children });
18
+ });
19
+ exports.NMRium = (0, react_1.memo)(NMRiumBase);
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const nmr_load_save_1 = require("nmr-load-save");
8
+ const react_1 = require("react");
9
+ const SpectraManager_1 = require("../../data/SpectraManager");
10
+ const ChartContext_1 = require("../context/ChartContext");
11
+ const DispatchContext_1 = require("../context/DispatchContext");
12
+ const LoggerContext_1 = require("../context/LoggerContext");
13
+ const PreferencesContext_1 = require("../context/PreferencesContext");
14
+ const IgnoreActions_1 = __importDefault(require("../reducer/IgnoreActions"));
15
+ const Reducer_1 = require("../reducer/Reducer");
16
+ const defaultData = {
17
+ spectra: [],
18
+ };
19
+ function NMRiumStateProvider(props) {
20
+ const { children, onChange, nmriumData = defaultData } = props;
21
+ const { logger } = (0, LoggerContext_1.useLogger)();
22
+ const preferencesState = (0, PreferencesContext_1.usePreferences)();
23
+ const [state, dispatchRaw] = (0, react_1.useReducer)(Reducer_1.spectrumReducer, Reducer_1.initialState, Reducer_1.initState);
24
+ const dispatch = (0, react_1.useCallback)((action) => {
25
+ logger.trace({ action }, `Dispatch main reducer action: ${action.type}`);
26
+ dispatchRaw(action);
27
+ }, [logger]);
28
+ const { source, data: spectraData, molecules, correlations, actionType, view, } = state;
29
+ const stateRef = (0, react_1.useRef)();
30
+ const handleChange = (0, react_1.useRef)(onChange);
31
+ (0, react_1.useEffect)(() => {
32
+ handleChange.current = onChange;
33
+ }, [onChange]);
34
+ (0, react_1.useEffect)(() => {
35
+ const { workspace, workspaces = {} } = preferencesState;
36
+ stateRef.current = (0, SpectraManager_1.toJSON)({ data: spectraData, molecules, correlations, source, view, actionType }, { current: workspaces[workspace.current] }, { serialize: false, exportTarget: 'onChange' });
37
+ }, [
38
+ actionType,
39
+ correlations,
40
+ molecules,
41
+ preferencesState,
42
+ source,
43
+ spectraData,
44
+ view,
45
+ ]);
46
+ (0, react_1.useEffect)(() => {
47
+ // trigger onChange callback if data object changed
48
+ if ((0, IgnoreActions_1.default)(actionType)) {
49
+ handleChange.current?.(stateRef.current, 'data');
50
+ }
51
+ }, [actionType, correlations, molecules, source, spectraData]);
52
+ (0, react_1.useEffect)(() => {
53
+ // trigger onChange callback if view object changed
54
+ handleChange.current?.(stateRef.current, 'view');
55
+ }, [view]);
56
+ (0, react_1.useEffect)(() => {
57
+ // trigger onChange callback if settings changed
58
+ handleChange.current?.(stateRef.current, 'settings');
59
+ }, [preferencesState]);
60
+ (0, react_1.useEffect)(() => {
61
+ dispatch({
62
+ type: 'SET_LOADING_FLAG',
63
+ payload: { isLoading: true },
64
+ });
65
+ if (nmriumData) {
66
+ void (0, nmr_load_save_1.readNMRiumObject)(nmriumData)
67
+ .then((nmriumState) => {
68
+ dispatch({ type: 'INITIATE', payload: { nmriumState } });
69
+ })
70
+ .catch((error) => {
71
+ dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
72
+ // eslint-disable-next-line no-alert
73
+ alert(error.message);
74
+ reportError(error);
75
+ });
76
+ }
77
+ }, [nmriumData, dispatch]);
78
+ return ((0, jsx_runtime_1.jsx)(DispatchContext_1.DispatchProvider, { value: dispatch, children: (0, jsx_runtime_1.jsx)(ChartContext_1.ChartDataProvider, { value: state, children: children }) }));
79
+ }
80
+ exports.default = NMRiumStateProvider;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SplitPaneWrapper = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const ui_1 = require("react-science/ui");
6
- const PreferencesContext_1 = require("./context/PreferencesContext");
6
+ const PreferencesContext_1 = require("../context/PreferencesContext");
7
7
  function SplitPaneWrapper({ children }) {
8
8
  const { current, dispatch } = (0, PreferencesContext_1.usePreferences)();
9
9
  const { general: { verticalSplitterPosition, verticalSplitterCloseThreshold }, display: { general = {} }, } = current;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StateError = void 0;
4
+ const react_1 = require("react");
5
+ const ChartContext_1 = require("../context/ChartContext");
6
+ const LoggerContext_1 = require("../context/LoggerContext");
7
+ /**
8
+ * Alert user in UI when state have errorAction (error from reducer)
9
+ */
10
+ function StateError() {
11
+ const { errorAction } = (0, ChartContext_1.useChartData)();
12
+ const { logger } = (0, LoggerContext_1.useLogger)();
13
+ (0, react_1.useEffect)(() => {
14
+ if (!errorAction)
15
+ return;
16
+ logger.error(errorAction);
17
+ }, [errorAction, logger]);
18
+ return null;
19
+ }
20
+ exports.StateError = StateError;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.serializeNMRiumState = void 0;
18
+ __exportStar(require("./types"), exports);
19
+ var nmr_load_save_1 = require("nmr-load-save");
20
+ Object.defineProperty(exports, "serializeNMRiumState", { enumerable: true, get: function () { return nmr_load_save_1.serializeNmriumState; } });
21
+ __exportStar(require("./NMRium"), exports);
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-enable unicorn/prefer-export-from */
@@ -49,6 +49,6 @@ const styles = (0, react_1.css) `
49
49
  `;
50
50
  function AboutPredictionModal() {
51
51
  const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
52
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About Prediction" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Banfi, D.; Patiny, L.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', "Chimia, 2008, 62(4), 280-281."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ". Journal of Magnetic Resonance 2011."] })] }), (0, jsx_runtime_1.jsx)("p", { children: "1H NMR prediction was possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Y. Binev, M.M. Marques, J. Aires-de-Sousa,", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: "Prediction of 1H NMR coupling constants with associative neural networks trained for chemical shifts" }), ' ', "J. Chem. Inf. Model. 2007, 47/(6), 2089-2097."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Aires-de-Sousa, M. Hemmer, J. Gasteiger,", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: "\u201C Prediction of 1H NMR Chemical Shifts Using Neural Networks\u201D" }), ", Analytical Chemistry, 2002, 74(1), 80-90."] })] }), (0, jsx_runtime_1.jsx)("p", { children: "13 NMR prediction was possible thanks to NMRshiftDB:" }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn.", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components." }), ' ', "Journal of chemical information and computer sciences, 2003, 43(6): 1733-1739."] }) })] }) })] }) })] }));
52
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About Prediction" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Damiano Banfi and Luc Patiny", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Chimia" }), ", ", (0, jsx_runtime_1.jsx)("b", { children: "2008" }), ", 62(4), 280-281."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Journal of Magnetic Resonance" }), " ", (0, jsx_runtime_1.jsx)("b", { children: "2011" }), ", 209(2), 123-130."] })] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("sup", { children: "1" }), "H NMR prediction is possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:"] }), (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Yuri Binev, Maria M. B. Marques and Jo\u00E3o Aires-de-Sousa", ' ', (0, jsx_runtime_1.jsxs)("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: ["Prediction of ", (0, jsx_runtime_1.jsx)("sup", { children: "1" }), "H NMR coupling constants with associative neural networks trained for chemical shifts"] }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "J. Chem. Inf. Model." }), " ", (0, jsx_runtime_1.jsx)("b", { children: "2007" }), ", 47(6), 2089-2097."] }), (0, jsx_runtime_1.jsxs)("li", { children: ["Jo\u00E3o Aires-de-Sousa, Markus C. Hemmer and Johann Gasteiger", ' ', (0, jsx_runtime_1.jsxs)("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: ["Prediction of ", (0, jsx_runtime_1.jsx)("sup", { children: "1" }), "H NMR Chemical Shifts Using Neural Networks"] }), ", ", (0, jsx_runtime_1.jsx)("i", { children: "Analytical Chemistry" }), ", ", (0, jsx_runtime_1.jsx)("b", { children: "2002" }), ", 74(1), 80-90."] })] }), (0, jsx_runtime_1.jsxs)("p", { children: [(0, jsx_runtime_1.jsx)("sup", { children: "13" }), "C NMR prediction was possible thanks to NMRshiftDB:"] }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Journal of chemical information and computer sciences" }), ",", ' ', (0, jsx_runtime_1.jsx)("b", { children: "2003" }), ", 43(6): 1733-1739."] }) })] }) })] }) })] }));
53
53
  }
54
54
  exports.default = AboutPredictionModal;
@@ -49,6 +49,6 @@ const styles = (0, react_1.css) `
49
49
  `;
50
50
  function AboutSpectrumSimulationModal() {
51
51
  const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
52
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About spectrum simulation" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems. Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist Journal of Magnetic Resonance 2011.", (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "10.1016/j.jmr.2010.12.008" })] }) })] }) })] }) })] }));
52
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(Button_1.default.BarButton, { onClick: openDialog, tooltipOrientation: "horizontal", toolTip: "About Prediction", children: (0, jsx_runtime_1.jsx)(fa_1.FaInfo, {}) }), (0, jsx_runtime_1.jsx)(ui_1.Modal, { hasCloseButton: true, isOpen: isOpenDialog, onRequestClose: closeDialog, children: (0, jsx_runtime_1.jsxs)("div", { css: styles, children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: (0, jsx_runtime_1.jsx)("div", { className: "header", children: (0, jsx_runtime_1.jsx)("span", { children: "About spectrum simulation" }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsxs)("div", { className: "content", children: [(0, jsx_runtime_1.jsx)("p", { children: "If you are using our tools please cite us:" }), (0, jsx_runtime_1.jsx)("ul", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', (0, jsx_runtime_1.jsx)("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', (0, jsx_runtime_1.jsx)("i", { children: "Journal of Magnetic Resonance" }), " ", (0, jsx_runtime_1.jsx)("b", { children: "2011" }), ", 209(2), 123-130."] }) })] }) })] }) })] }));
53
53
  }
54
54
  exports.default = AboutSpectrumSimulationModal;
@@ -80,7 +80,7 @@ function PredictSpectraModal({ onClose = () => null, molecule, }) {
80
80
  closeDialog();
81
81
  const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
82
82
  try {
83
- const data = await (0, PredictionManager_1.predictSpectra)(molfile);
83
+ const data = await (0, PredictionManager_1.predictSpectra)(molfile, values.spectra);
84
84
  dispatch({
85
85
  type: 'PREDICT_SPECTRA',
86
86
  payload: {
@@ -1,145 +1,10 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
2
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const jsx_runtime_1 = require("@emotion/react/jsx-runtime");
30
- /** @jsxImportSource @emotion/react */
31
- const react_1 = require("@emotion/react");
32
- const formik_1 = require("formik");
33
- const react_2 = require("react");
34
- const Yup = __importStar(require("yup"));
35
- const PreferencesContext_1 = require("../../context/PreferencesContext");
36
- const Button_1 = __importDefault(require("../../elements/Button"));
37
- const CloseButton_1 = __importDefault(require("../../elements/CloseButton"));
38
- const Tab_1 = __importDefault(require("../../elements/Tab/Tab"));
39
- const Tabs_1 = __importDefault(require("../../elements/Tab/Tabs"));
40
- const FormikInput_1 = __importDefault(require("../../elements/formik/FormikInput"));
41
- const ModalStyle_1 = require("../ModalStyle");
42
- const SelectMolecule_1 = __importDefault(require("./SelectMolecule"));
43
- const styles = (0, react_1.css) `
44
- width: 450px;
45
- height: 400px;
46
-
47
- .header {
48
- display: flex;
49
- padding: 10px;
50
-
51
- span {
52
- font-size: 14px;
53
- flex: 1;
54
- }
55
- }
56
-
57
- .tab-content {
58
- flex: 1;
59
- }
60
-
61
- .manual-container {
62
- padding: 30px 5px;
63
-
64
- .input {
65
- width: 80% !important;
66
- height: 36px;
67
- margin: 0 auto;
68
- }
69
-
70
- .input input {
71
- padding: 5px;
72
- text-align: center;
73
- }
74
- }
75
- `;
76
- var SumSetOptions;
77
- (function (SumSetOptions) {
78
- SumSetOptions["Auto"] = "auto";
79
- SumSetOptions["Manual"] = "manual";
80
- })(SumSetOptions || (SumSetOptions = {}));
81
- function getValidationSchema(option) {
82
- switch (option) {
83
- case SumSetOptions.Auto: {
84
- return Yup.object({
85
- molecule: Yup.object().required(),
86
- });
87
- }
88
- case SumSetOptions.Manual: {
89
- return Yup.object({
90
- sum: Yup.number().required(),
91
- });
92
- }
93
- default:
94
- return null;
95
- }
96
- }
97
- function ChangeSumModal({ onSave, onClose, header, sumOptions, }) {
98
- const { current: { display: { panels }, }, } = (0, PreferencesContext_1.usePreferences)();
99
- const [setOption, setActiveOption] = (0, react_2.useState)(SumSetOptions.Auto);
100
- const formRef = (0, react_2.useRef)(null);
101
- function handleKeyDown(event) {
102
- if (event.key === 'Enter') {
103
- formRef.current.submitForm();
104
- }
105
- }
106
- function onTabChangeHandler(tab) {
107
- setActiveOption(tab.tabid);
108
- }
109
- (0, react_2.useEffect)(() => {
110
- if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
111
- setActiveOption(SumSetOptions.Auto);
112
- const { mf, moleculeId: id } = sumOptions;
113
- formRef.current.setValues({
114
- sum: null,
115
- molecule: id && mf ? { mf, id } : null,
116
- });
117
- }
118
- else {
119
- setActiveOption(SumSetOptions.Manual);
120
- formRef.current.setValues({ sum: sumOptions?.sum ?? '', molecule: null });
121
- }
122
- }, [panels?.structuresPanel, sumOptions]);
123
- function saveHandler(values) {
124
- switch (setOption) {
125
- case SumSetOptions.Auto: {
126
- const { molecule: { mf, id: moleculeId }, } = values;
127
- onSave({ sumAuto: true, mf, moleculeId });
128
- break;
129
- }
130
- case SumSetOptions.Manual: {
131
- const { sum } = values;
132
- onSave({ sum, sumAuto: false });
133
- break;
134
- }
135
- default:
136
- return;
137
- }
138
- onClose();
139
- }
140
- const isStructurePanelVisible = panels?.structuresPanel?.display || false;
141
- return (
142
- // <div css={modalContainer}>
143
- (0, jsx_runtime_1.jsxs)("div", { css: [ModalStyle_1.ModalStyles, styles], children: [(0, jsx_runtime_1.jsxs)("div", { className: "header handle", children: [(0, jsx_runtime_1.jsx)("span", { children: header }), (0, jsx_runtime_1.jsx)(CloseButton_1.default, { onClick: onClose })] }), (0, jsx_runtime_1.jsx)("div", { className: "tab-content", children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && ((0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Auto", tabid: SumSetOptions.Auto, children: (0, jsx_runtime_1.jsx)(SelectMolecule_1.default, { name: "molecule" }) })), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Manual", tabid: SumSetOptions.Manual, children: (0, jsx_runtime_1.jsx)("div", { className: "manual-container", children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "footer-container", children: (0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: () => formRef.current.submitForm(), style: { width: '80px' }, children: "Set" }) })] }));
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const ui_1 = require("react-science/ui");
5
+ const ChangeSumModalContents_1 = require("./ChangeSumModalContents");
6
+ function ChangeSumModal({ renderButton, ...otherProps }) {
7
+ const [isOpenDialog, openDialog, closeDialog] = (0, ui_1.useOnOff)(false);
8
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [renderButton(openDialog), (0, jsx_runtime_1.jsx)(ui_1.Modal, { isOpen: isOpenDialog, onRequestClose: closeDialog, width: 500, height: 400, children: (0, jsx_runtime_1.jsx)(ChangeSumModalContents_1.ChangeSumModalContents, { ...otherProps, onClose: closeDialog }) })] }));
144
9
  }
145
10
  exports.default = ChangeSumModal;
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ChangeSumModalContents = void 0;
30
+ const jsx_runtime_1 = require("react/jsx-runtime");
31
+ const styled_1 = __importDefault(require("@emotion/styled"));
32
+ const formik_1 = require("formik");
33
+ const react_1 = require("react");
34
+ const ui_1 = require("react-science/ui");
35
+ const Yup = __importStar(require("yup"));
36
+ const PreferencesContext_1 = require("../../context/PreferencesContext");
37
+ const Button_1 = __importDefault(require("../../elements/Button"));
38
+ const Tab_1 = __importDefault(require("../../elements/Tab/Tab"));
39
+ const Tabs_1 = __importDefault(require("../../elements/Tab/Tabs"));
40
+ const FormikInput_1 = __importDefault(require("../../elements/formik/FormikInput"));
41
+ const SelectMolecule_1 = __importDefault(require("./SelectMolecule"));
42
+ function getValidationSchema(option) {
43
+ switch (option) {
44
+ case 'auto': {
45
+ return Yup.object({
46
+ molecule: Yup.object().required(),
47
+ });
48
+ }
49
+ case 'manual': {
50
+ return Yup.object({
51
+ sum: Yup.number().required(),
52
+ });
53
+ }
54
+ default:
55
+ return null;
56
+ }
57
+ }
58
+ const ManualContainer = styled_1.default.div `
59
+ padding: 30px 5px;
60
+
61
+ .input {
62
+ width: 80% !important;
63
+ height: 36px;
64
+ margin: 0 auto;
65
+ }
66
+
67
+ .input input {
68
+ padding: 5px;
69
+ text-align: center;
70
+ }
71
+ `;
72
+ function ChangeSumModalContents(props) {
73
+ const { currentSum, sumType, sumOptions, onSave, onClose } = props;
74
+ const { current: { display: { panels }, }, } = (0, PreferencesContext_1.usePreferences)();
75
+ const [setOption, setActiveOption] = (0, react_1.useState)('auto');
76
+ const formRef = (0, react_1.useRef)(null);
77
+ (0, react_1.useEffect)(() => {
78
+ if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
79
+ setActiveOption('auto');
80
+ const { mf, moleculeId: id } = sumOptions;
81
+ formRef.current.setValues({
82
+ sum: null,
83
+ molecule: id && mf ? { mf, id } : null,
84
+ });
85
+ }
86
+ else {
87
+ setActiveOption('manual');
88
+ formRef.current.setValues({
89
+ sum: sumOptions?.sum ?? '',
90
+ molecule: null,
91
+ });
92
+ }
93
+ }, [panels?.structuresPanel, sumOptions]);
94
+ function handleKeyDown(event) {
95
+ if (event.key === 'Enter') {
96
+ formRef.current.submitForm();
97
+ }
98
+ }
99
+ function onTabChangeHandler(tab) {
100
+ setActiveOption(tab.tabid);
101
+ }
102
+ function saveHandler(values) {
103
+ switch (setOption) {
104
+ case 'auto': {
105
+ const { molecule: { mf, id: moleculeId }, } = values;
106
+ onSave({ sumAuto: true, mf, moleculeId });
107
+ break;
108
+ }
109
+ case 'manual': {
110
+ const { sum } = values;
111
+ onSave({ sum, sumAuto: false });
112
+ break;
113
+ }
114
+ default:
115
+ return;
116
+ }
117
+ onClose();
118
+ }
119
+ const isStructurePanelVisible = panels?.structuresPanel?.display || false;
120
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(ui_1.Modal.Header, { children: currentSum
121
+ ? `Set new ${sumType} sum (Current: ${currentSum.toFixed(2)})`
122
+ : `Set new ${sumType} Sum` }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Body, { children: (0, jsx_runtime_1.jsx)(formik_1.Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: (0, jsx_runtime_1.jsxs)(Tabs_1.default, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && ((0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Auto", tabid: "auto", children: (0, jsx_runtime_1.jsx)(SelectMolecule_1.default, { name: "molecule" }) })), (0, jsx_runtime_1.jsx)(Tab_1.default, { title: "Manual", tabid: "manual", children: (0, jsx_runtime_1.jsx)(ManualContainer, { children: (0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), (0, jsx_runtime_1.jsx)(ui_1.Modal.Footer, { children: (0, jsx_runtime_1.jsx)(Button_1.default.Done, { onClick: () => formRef.current.submitForm(), style: { width: 80 }, children: "Set" }) })] }));
123
+ }
124
+ exports.ChangeSumModalContents = ChangeSumModalContents;
@@ -150,7 +150,7 @@ function GeneralSettingsModal({ height }) {
150
150
  }, [workspaces]);
151
151
  const handleReset = () => {
152
152
  const workSpaceDisplayPreferences = (0, getPreferencesByWorkspace_1.getPreferencesByWorkspace)(workspaceName, originalWorkspaces);
153
- refForm.current?.setValues(workSpaceDisplayPreferences);
153
+ void refForm.current?.setValues(workSpaceDisplayPreferences);
154
154
  };
155
155
  function submitHandler(values) {
156
156
  saveSettings(values);
@@ -215,7 +215,7 @@ function GeneralSettingsModal({ height }) {
215
215
  const setWorkspaceSetting = (0, react_2.useCallback)((inputWorkspace) => {
216
216
  const parseWorkspaceName = Object.keys(inputWorkspace)[0];
217
217
  if (preferences.workspace.current === parseWorkspaceName) {
218
- refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
218
+ void refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
219
219
  }
220
220
  else if (preferences.workspaces[parseWorkspaceName]) {
221
221
  pastRef.current = inputWorkspace;
@@ -69,6 +69,13 @@ function InfoBlockTabContent() {
69
69
  return ((0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `infoBlock.fields.${row.index}.jpath`, style: { input: styles.input }, mapOnChangeValue: (key) => paths?.[key] || null, mapValue: (paths) => (0, convertPathArrayToString_1.convertPathArrayToString)(paths), datalist: datalist }));
70
70
  },
71
71
  },
72
+ {
73
+ Header: 'Format',
74
+ style: { padding: 0, ...styles.column },
75
+ Cell: ({ row }) => {
76
+ return ((0, jsx_runtime_1.jsx)(FormikInput_1.default, { name: `infoBlock.fields.${row.index}.format`, style: { input: styles.input } }));
77
+ },
78
+ },
72
79
  {
73
80
  Header: 'Visible',
74
81
  style: { width: '30px', ...styles.column },
@@ -76,11 +83,11 @@ function InfoBlockTabContent() {
76
83
  },
77
84
  {
78
85
  Header: '',
79
- style: { width: '30px', ...styles.column },
86
+ style: { width: '70px', ...styles.column },
80
87
  id: 'add-button',
81
88
  Cell: ({ data, row }) => {
82
89
  const record = row.original;
83
- return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), !record?.name && ((0, jsx_runtime_1.jsx)(Button_1.default.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: (0, jsx_runtime_1.jsx)(fa_1.FaTimes, {}) }))] }));
90
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: [(0, jsx_runtime_1.jsx)(Button_1.default.Done, { fill: "outline", onClick: () => addHandler(data, row.index + 1), children: (0, jsx_runtime_1.jsx)(fa_1.FaPlus, {}) }), !record?.name && ((0, jsx_runtime_1.jsx)(Button_1.default.Danger, { fill: "outline", onClick: () => deleteHandler(data, row.index), children: (0, jsx_runtime_1.jsx)(fa_1.FaTimes, {}) }))] }));
84
91
  },
85
92
  },
86
93
  ], [addHandler, datalist, deleteHandler, paths]);