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,116 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
- /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
4
- import { Formik } from 'formik';
5
- import { useEffect, useRef, useState } from 'react';
6
- import * as Yup from 'yup';
7
- import { usePreferences } from '../../context/PreferencesContext';
8
- import Button from '../../elements/Button';
9
- import CloseButton from '../../elements/CloseButton';
10
- import Tab from '../../elements/Tab/Tab';
11
- import Tabs from '../../elements/Tab/Tabs';
12
- import FormikInput from '../../elements/formik/FormikInput';
13
- import { ModalStyles } from '../ModalStyle';
14
- import SelectMolecule from './SelectMolecule';
15
- const styles = css `
16
- width: 450px;
17
- height: 400px;
18
-
19
- .header {
20
- display: flex;
21
- padding: 10px;
22
-
23
- span {
24
- font-size: 14px;
25
- flex: 1;
26
- }
27
- }
28
-
29
- .tab-content {
30
- flex: 1;
31
- }
32
-
33
- .manual-container {
34
- padding: 30px 5px;
35
-
36
- .input {
37
- width: 80% !important;
38
- height: 36px;
39
- margin: 0 auto;
40
- }
41
-
42
- .input input {
43
- padding: 5px;
44
- text-align: center;
45
- }
46
- }
47
- `;
48
- var SumSetOptions;
49
- (function (SumSetOptions) {
50
- SumSetOptions["Auto"] = "auto";
51
- SumSetOptions["Manual"] = "manual";
52
- })(SumSetOptions || (SumSetOptions = {}));
53
- function getValidationSchema(option) {
54
- switch (option) {
55
- case SumSetOptions.Auto: {
56
- return Yup.object({
57
- molecule: Yup.object().required(),
58
- });
59
- }
60
- case SumSetOptions.Manual: {
61
- return Yup.object({
62
- sum: Yup.number().required(),
63
- });
64
- }
65
- default:
66
- return null;
67
- }
68
- }
69
- export default function ChangeSumModal({ onSave, onClose, header, sumOptions, }) {
70
- const { current: { display: { panels }, }, } = usePreferences();
71
- const [setOption, setActiveOption] = useState(SumSetOptions.Auto);
72
- const formRef = useRef(null);
73
- function handleKeyDown(event) {
74
- if (event.key === 'Enter') {
75
- formRef.current.submitForm();
76
- }
77
- }
78
- function onTabChangeHandler(tab) {
79
- setActiveOption(tab.tabid);
80
- }
81
- useEffect(() => {
82
- if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
83
- setActiveOption(SumSetOptions.Auto);
84
- const { mf, moleculeId: id } = sumOptions;
85
- formRef.current.setValues({
86
- sum: null,
87
- molecule: id && mf ? { mf, id } : null,
88
- });
89
- }
90
- else {
91
- setActiveOption(SumSetOptions.Manual);
92
- formRef.current.setValues({ sum: sumOptions?.sum ?? '', molecule: null });
93
- }
94
- }, [panels?.structuresPanel, sumOptions]);
95
- function saveHandler(values) {
96
- switch (setOption) {
97
- case SumSetOptions.Auto: {
98
- const { molecule: { mf, id: moleculeId }, } = values;
99
- onSave({ sumAuto: true, mf, moleculeId });
100
- break;
101
- }
102
- case SumSetOptions.Manual: {
103
- const { sum } = values;
104
- onSave({ sum, sumAuto: false });
105
- break;
106
- }
107
- default:
108
- return;
109
- }
110
- onClose();
111
- }
112
- const isStructurePanelVisible = panels?.structuresPanel?.display || false;
113
- return (
114
- // <div css={modalContainer}>
115
- _jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: header }), _jsx(CloseButton, { onClick: onClose })] }), _jsx("div", { className: "tab-content", children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: _jsxs(Tabs, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && (_jsx(Tab, { title: "Auto", tabid: SumSetOptions.Auto, children: _jsx(SelectMolecule, { name: "molecule" }) })), _jsx(Tab, { title: "Manual", tabid: SumSetOptions.Manual, children: _jsx("div", { className: "manual-container", children: _jsx(FormikInput, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), _jsx("div", { className: "footer-container", children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), style: { width: '80px' }, children: "Set" }) })] }));
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Modal, useOnOff } from 'react-science/ui';
3
+ import { ChangeSumModalContents, } from './ChangeSumModalContents';
4
+ export default function ChangeSumModal({ renderButton, ...otherProps }) {
5
+ const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
6
+ return (_jsxs(_Fragment, { children: [renderButton(openDialog), _jsx(Modal, { isOpen: isOpenDialog, onRequestClose: closeDialog, width: 500, height: 400, children: _jsx(ChangeSumModalContents, { ...otherProps, onClose: closeDialog }) })] }));
116
7
  }
@@ -0,0 +1,18 @@
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
+ export interface ChangeSumModalContentsProps {
11
+ currentSum: number | null;
12
+ sumType: string;
13
+ sumOptions: SumOptions;
14
+ onSave: (saveInput: SaveInput) => void;
15
+ onClose: () => void;
16
+ }
17
+ export declare function ChangeSumModalContents(props: ChangeSumModalContentsProps): import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -0,0 +1,94 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import styled from '@emotion/styled';
3
+ import { Formik } from 'formik';
4
+ import { useEffect, useRef, useState } from 'react';
5
+ import { Modal } from 'react-science/ui';
6
+ import * as Yup from 'yup';
7
+ import { usePreferences } from '../../context/PreferencesContext';
8
+ import Button from '../../elements/Button';
9
+ import Tab from '../../elements/Tab/Tab';
10
+ import Tabs from '../../elements/Tab/Tabs';
11
+ import FormikInput from '../../elements/formik/FormikInput';
12
+ import SelectMolecule from './SelectMolecule';
13
+ function getValidationSchema(option) {
14
+ switch (option) {
15
+ case 'auto': {
16
+ return Yup.object({
17
+ molecule: Yup.object().required(),
18
+ });
19
+ }
20
+ case 'manual': {
21
+ return Yup.object({
22
+ sum: Yup.number().required(),
23
+ });
24
+ }
25
+ default:
26
+ return null;
27
+ }
28
+ }
29
+ const ManualContainer = styled.div `
30
+ padding: 30px 5px;
31
+
32
+ .input {
33
+ width: 80% !important;
34
+ height: 36px;
35
+ margin: 0 auto;
36
+ }
37
+
38
+ .input input {
39
+ padding: 5px;
40
+ text-align: center;
41
+ }
42
+ `;
43
+ export function ChangeSumModalContents(props) {
44
+ const { currentSum, sumType, sumOptions, onSave, onClose } = props;
45
+ const { current: { display: { panels }, }, } = usePreferences();
46
+ const [setOption, setActiveOption] = useState('auto');
47
+ const formRef = useRef(null);
48
+ useEffect(() => {
49
+ if (sumOptions?.sumAuto && panels?.structuresPanel?.display) {
50
+ setActiveOption('auto');
51
+ const { mf, moleculeId: id } = sumOptions;
52
+ formRef.current.setValues({
53
+ sum: null,
54
+ molecule: id && mf ? { mf, id } : null,
55
+ });
56
+ }
57
+ else {
58
+ setActiveOption('manual');
59
+ formRef.current.setValues({
60
+ sum: sumOptions?.sum ?? '',
61
+ molecule: null,
62
+ });
63
+ }
64
+ }, [panels?.structuresPanel, sumOptions]);
65
+ function handleKeyDown(event) {
66
+ if (event.key === 'Enter') {
67
+ formRef.current.submitForm();
68
+ }
69
+ }
70
+ function onTabChangeHandler(tab) {
71
+ setActiveOption(tab.tabid);
72
+ }
73
+ function saveHandler(values) {
74
+ switch (setOption) {
75
+ case 'auto': {
76
+ const { molecule: { mf, id: moleculeId }, } = values;
77
+ onSave({ sumAuto: true, mf, moleculeId });
78
+ break;
79
+ }
80
+ case 'manual': {
81
+ const { sum } = values;
82
+ onSave({ sum, sumAuto: false });
83
+ break;
84
+ }
85
+ default:
86
+ return;
87
+ }
88
+ onClose();
89
+ }
90
+ const isStructurePanelVisible = panels?.structuresPanel?.display || false;
91
+ return (_jsxs(_Fragment, { children: [_jsx(Modal.Header, { children: currentSum
92
+ ? `Set new ${sumType} sum (Current: ${currentSum.toFixed(2)})`
93
+ : `Set new ${sumType} Sum` }), _jsx(Modal.Body, { children: _jsx(Formik, { innerRef: formRef, onSubmit: saveHandler, initialValues: { sum: '', molecule: null }, validationSchema: getValidationSchema(setOption), children: _jsxs(Tabs, { activeTab: setOption, onClick: onTabChangeHandler, children: [isStructurePanelVisible && (_jsx(Tab, { title: "Auto", tabid: "auto", children: _jsx(SelectMolecule, { name: "molecule" }) })), _jsx(Tab, { title: "Manual", tabid: "manual", children: _jsx(ManualContainer, { children: _jsx(FormikInput, { name: "sum", type: "number", nullable: true, placeholder: "Enter the new value", onKeyDown: handleKeyDown }) }) })] }) }) }), _jsx(Modal.Footer, { children: _jsx(Button.Done, { onClick: () => formRef.current.submitForm(), style: { width: 80 }, children: "Set" }) })] }));
94
+ }
@@ -122,7 +122,7 @@ function GeneralSettingsModal({ height }) {
122
122
  }, [workspaces]);
123
123
  const handleReset = () => {
124
124
  const workSpaceDisplayPreferences = getPreferencesByWorkspace(workspaceName, originalWorkspaces);
125
- refForm.current?.setValues(workSpaceDisplayPreferences);
125
+ void refForm.current?.setValues(workSpaceDisplayPreferences);
126
126
  };
127
127
  function submitHandler(values) {
128
128
  saveSettings(values);
@@ -187,7 +187,7 @@ function GeneralSettingsModal({ height }) {
187
187
  const setWorkspaceSetting = useCallback((inputWorkspace) => {
188
188
  const parseWorkspaceName = Object.keys(inputWorkspace)[0];
189
189
  if (preferences.workspace.current === parseWorkspaceName) {
190
- refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
190
+ void refForm.current?.setValues(inputWorkspace[parseWorkspaceName]);
191
191
  }
192
192
  else if (preferences.workspaces[parseWorkspaceName]) {
193
193
  pastRef.current = inputWorkspace;
@@ -1,5 +1,5 @@
1
1
  import { CustomWorkspaces } from 'nmr-load-save';
2
- import { NMRiumWorkspace } from '../../../NMRium';
2
+ import type { NMRiumWorkspace } from '../../../main';
3
3
  interface DatabasesTabContentProps {
4
4
  currentWorkspace: NMRiumWorkspace;
5
5
  originalWorkspaces: CustomWorkspaces;
@@ -13,7 +13,7 @@ import { useModal } from '../../elements/popup/Modal';
13
13
  import useSpectrum from '../../hooks/useSpectrum';
14
14
  import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
15
15
  import { tablePanelStyle } from '../extra/BasicPanelStyle';
16
- import DefaultPanelHeader from '../header/DefaultPanelHeader';
16
+ import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
17
17
  import PreferencesHeader from '../header/PreferencesHeader';
18
18
  import IntegralTable from './IntegralTable';
19
19
  import IntegralsPreferences from './IntegralsPreferences';
@@ -43,16 +43,10 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
43
43
  }, [modal, yesHandler]);
44
44
  const changeIntegralSumHandler = useCallback((options) => {
45
45
  dispatch({ type: 'CHANGE_INTEGRAL_SUM', payload: { options } });
46
- modal.close();
47
- }, [dispatch, modal]);
46
+ }, [dispatch]);
48
47
  const currentSum = useMemo(() => {
49
48
  return lodashGet(integrals, 'options.sum', null);
50
49
  }, [integrals]);
51
- const showChangeIntegralSumModal = useCallback(() => {
52
- modal.show(_jsx(ChangeSumModal, { onClose: () => modal.close(), onSave: changeIntegralSumHandler, header: currentSum
53
- ? `Set new integrals Sum (Current: ${Number(currentSum).toFixed(2)})`
54
- : 'Set new integrals Sum', sumOptions: integrals?.options }));
55
- }, [changeIntegralSumHandler, currentSum, integrals?.options, modal]);
56
50
  const settingsPanelHandler = useCallback(() => {
57
51
  setFlipStatus(!isFlipped);
58
52
  }, [isFlipped]);
@@ -87,6 +81,7 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
87
81
  }
88
82
  return [];
89
83
  }, [filterIsActive, info.dimension, integrals, xDomain]);
84
+ const counter = integrals?.values?.length || 0;
90
85
  return (_jsxs("div", { css: [
91
86
  tablePanelStyle,
92
87
  style,
@@ -96,9 +91,9 @@ function IntegralPanelInner({ integrals, info, activeTab, xDomain, }) {
96
91
  position: relative;
97
92
  }
98
93
  `,
99
- ], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: integrals?.values?.length, onDelete: handleDeleteAll, deleteToolTip: "Delete All Integrals", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all integrals' : 'Hide integrals out of view', filterIsActive: filterIsActive, counterFiltered: filteredData.length, showSettingButton: true, onSettingClick: settingsPanelHandler, children: [_jsx(ToolTip, { title: currentSum
100
- ? `Change Integrals Sum (${Number(currentSum).toFixed(2)})`
101
- : 'Change Integrals Sum', popupPlacement: "right", children: _jsx("button", { className: "sum-button", type: "button", onClick: showChangeIntegralSumModal, children: _jsx(SvgNmrSum, {}) }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fix integral values", popupPlacement: "right", onClick: toggleConstantSumHandler, value: integrals?.options?.isSumConstant || false, children: _jsx(ImLink, {}) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(IntegralTable, { data: filteredData, activeTab: activeTab })) : (_jsx(IntegralsPreferences, { ref: settingRef })) })] }));
94
+ ], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: counter, counterLabel: createFilterLabel(counter, filterIsActive && filteredData?.length), onDelete: handleDeleteAll, deleteToolTip: "Delete All Integrals", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all integrals' : 'Hide integrals out of view', showSettingButton: true, onSettingClick: settingsPanelHandler, children: [_jsx(ToolTip, { title: currentSum
95
+ ? `Change integration sum (${currentSum.toFixed(2)})`
96
+ : 'Change integration sum', popupPlacement: "right", children: _jsx(ChangeSumModal, { onSave: changeIntegralSumHandler, sumType: "integrals", currentSum: currentSum, sumOptions: integrals?.options, renderButton: (onClick) => (_jsx("button", { className: "sum-button", type: "button", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration values", popupPlacement: "right", onClick: toggleConstantSumHandler, value: integrals?.options?.isSumConstant || false, children: _jsx(ImLink, {}) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(IntegralTable, { data: filteredData, activeTab: activeTab })) : (_jsx(IntegralsPreferences, { ref: settingRef })) })] }));
102
97
  }
103
98
  const MemoizedIntegralPanel = memo(IntegralPanelInner);
104
99
  const emptyData = { integrals: {}, info: {} };
@@ -22,7 +22,7 @@ const styles = {
22
22
  margin: 0,
23
23
  textAlign: 'right',
24
24
  lineHeight: '22px',
25
- padding: '0 10px',
25
+ padding: '0 5px',
26
26
  whiteSpace: 'nowrap',
27
27
  },
28
28
  atomLabel: {
@@ -160,7 +160,5 @@ export default function MoleculePanelHeader({ currentIndex, molecules, molecules
160
160
  });
161
161
  }
162
162
  const hasMolecules = molecules && molecules.length > 0;
163
- return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), _jsxs("p", { style: styles.counter, children: [molecules &&
164
- molecules.length > 0 &&
165
- `${+(currentIndex + 1)} / ${molecules.length}`, ' '] }), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
163
+ return (_jsxs(PanelHeader, { children: [renderSource === 'predictionPanel' && _jsx(AboutPredictionModal, {}), renderSource === 'moleculePanel' && (_jsx(DropdownMenu, { trigger: "click", options: MOL_EXPORT_MENU, onSelect: exportHandler, children: _jsx(Button.BarButton, { as: "div", disabled: !hasMolecules, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Export As", tooltipOrientation: "horizontal", children: _jsx(FaFileExport, {}) }) })), _jsx(Button.BarButton, { onClick: handlePasteMolfileAction, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Paste molfile", tooltipOrientation: "horizontal", children: _jsx(FaPaste, {}) }), _jsx(Button.BarButton, { onClick: onOpenMoleculeEditor, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Add molecule", tooltipOrientation: "horizontal", children: _jsx(FaPlus, {}) }), renderSource === 'moleculePanel' && (_jsxs(_Fragment, { children: [_jsx(Button.BarButton, { onClick: handleDelete, color: { base: '#4e4e4e', hover: '#4e4e4e' }, toolTip: "Delete molecule", tooltipOrientation: "horizontal", disabled: !hasMolecules, children: _jsx(FaRegTrashAlt, {}) }), hasMolecules && (_jsx(PredictSpectraModal, { molecule: molecules[currentIndex] }))] })), _jsx(ActiveButton, { value: moleculesView?.[moleculeKey]?.floating.visible || false, popupTitle: "Float molecule", popupPlacement: "left", onClick: floatMoleculeHandler, disabled: !hasMolecules, children: _jsx(IoOpenOutline, {}) }), _jsx(ActiveButton, { style: { marginLeft: '2px' }, value: moleculesView?.[moleculeKey]?.showAtomNumber || false, popupTitle: "Show atom number", popupPlacement: "left", onClick: showAtomNumbersHandler, disabled: !hasMolecules, children: _jsx("p", { style: styles.atomLabel, children: "#" }) }), _jsx("div", { style: { flex: 1 }, children: children }), molecules && molecules.length > 0 && (_jsx("p", { style: styles.counter, children: `${+(currentIndex + 1)} / ${molecules.length}` })), onClickPreferences && (_jsx(Button.BarButton, { color: { base: 'black', hover: 'black' }, onClick: onClickPreferences, toolTip: "Preferences", tooltipOrientation: "vertical", children: _jsx(FaCog, {}) })), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, onReadText: handlePasteMolfile, text: text, label: "Molfile" })] }));
166
164
  }
@@ -1,12 +1,6 @@
1
1
  import { Range, Zone } from 'nmr-processing';
2
+ import { DiaIDAndInfo } from 'openchemlib-utils';
2
3
  import { AssignmentContext, Axis } from '../../assignment/AssignmentsContext';
3
- export interface Atom {
4
- oclID: string;
5
- atomLabel: string;
6
- nbAtoms: number;
7
- nbHydrogens: number;
8
- hydrogenOCLIDs: string[];
9
- }
10
4
  export interface AtomData {
11
5
  oclIDs: string[];
12
6
  nbAtoms: number;
@@ -17,12 +11,12 @@ export interface AtomData {
17
11
  * In case of an heavy atom with bonded hydrogens the OCL id(s)
18
12
  * and number of these hydrogens are added as well.
19
13
  *
20
- * @param {Atom} atom - atom returned by OCLnmr component
14
+ * @param {DiaIDAndInfo} diaIDAndInfo - atom returned by OCLnmr component
21
15
  * @param {string} activeTab - active tab
22
16
  * @param {Axis} axis - current axis
23
17
  *
24
18
  */
25
- export declare function extractFromAtom(atom: Atom, activeTab: string, axis?: Axis | null): AtomData;
19
+ export declare function extractFromAtom(diaIDAndInfo: DiaIDAndInfo | undefined, activeTab: string, axis?: Axis | null): AtomData;
26
20
  export declare function findDatumAndSignalIndex(data: Array<Range | Zone>, id: string): {
27
21
  datum: Range | Zone | undefined;
28
22
  signalIndex: any;
@@ -10,31 +10,35 @@ function getElements(activeTab) {
10
10
  * In case of an heavy atom with bonded hydrogens the OCL id(s)
11
11
  * and number of these hydrogens are added as well.
12
12
  *
13
- * @param {Atom} atom - atom returned by OCLnmr component
13
+ * @param {DiaIDAndInfo} diaIDAndInfo - atom returned by OCLnmr component
14
14
  * @param {string} activeTab - active tab
15
15
  * @param {Axis} axis - current axis
16
16
  *
17
17
  */
18
- export function extractFromAtom(atom, activeTab, axis) {
18
+ export function extractFromAtom(diaIDAndInfo, activeTab, axis) {
19
19
  const elements = getElements(activeTab);
20
- if (elements && elements.length > 0 && Object.keys(atom).length > 0) {
20
+ if (elements && elements.length > 0 && diaIDAndInfo) {
21
21
  const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
22
22
  switch (dim !== null && elements[dim]) {
23
- case atom.atomLabel: {
23
+ case diaIDAndInfo.atomLabel: {
24
24
  // take always oclID if atom type is same as element of activeTab)
25
- return { oclIDs: [atom.oclID], nbAtoms: atom.nbAtoms };
25
+ return {
26
+ oclIDs: [diaIDAndInfo.idCode],
27
+ nbAtoms: diaIDAndInfo.nbEquivalentAtoms,
28
+ };
26
29
  }
27
30
  case 'H': {
28
31
  // if we are in proton spectrum and use then the IDs of attached hydrogens of an atom
29
32
  return {
30
- oclIDs: atom.hydrogenOCLIDs,
31
- nbAtoms: atom.nbAtoms * atom.nbHydrogens,
33
+ oclIDs: diaIDAndInfo.attachedHydrogensIDCodes,
34
+ nbAtoms: diaIDAndInfo.nbEquivalentAtoms * diaIDAndInfo.nbAttachedHydrogens,
32
35
  };
33
36
  }
34
37
  default:
35
38
  return {
36
- oclIDs: [atom.oclID].concat(atom.hydrogenOCLIDs),
37
- nbAtoms: atom.nbAtoms + atom.nbAtoms * atom.nbHydrogens,
39
+ oclIDs: [diaIDAndInfo.idCode].concat(diaIDAndInfo.attachedHydrogensIDCodes),
40
+ nbAtoms: diaIDAndInfo.nbEquivalentAtoms +
41
+ diaIDAndInfo.nbEquivalentAtoms * diaIDAndInfo.nbAttachedHydrogens,
38
42
  };
39
43
  }
40
44
  }
@@ -81,7 +85,7 @@ export function getCurrentDiaIDsToHighlight(assignmentData) {
81
85
  const { highlighted, assignments } = assignmentData.data;
82
86
  const assignment = highlighted ? assignments[highlighted.id] : null;
83
87
  const axisHover = highlighted ? highlighted.axis : null;
84
- if (axisHover && assignment && assignment[axisHover]) {
88
+ if (axisHover && assignment?.[axisHover]) {
85
89
  return assignment[axisHover];
86
90
  }
87
91
  else {
@@ -1,13 +1,13 @@
1
+ import { DiaIDAndInfo } from 'openchemlib-utils';
1
2
  import { MouseEvent } from 'react';
2
- import { Atom } from './Utilities';
3
3
  export default function useAtomAssignment({ displayerMode, activeTab: nucleus, zones, ranges, }: {
4
4
  displayerMode: any;
5
5
  activeTab: any;
6
6
  zones: any;
7
7
  ranges: any;
8
8
  }): {
9
- handleOnAtomHover: (atom: Atom) => void;
10
- handleOnClickAtom: (atom: Atom, event: MouseEvent) => void;
9
+ handleOnAtomHover: (diaIDAndInfo: DiaIDAndInfo | undefined) => void;
10
+ handleOnClickAtom: (diaIDAndInfo: DiaIDAndInfo | undefined, event: MouseEvent) => void;
11
11
  currentDiaIDsToHighlight: string[];
12
12
  assignedDiaIDsMerged: string[];
13
13
  };
@@ -100,11 +100,11 @@ export default function useAtomAssignment({ displayerMode, activeTab: nucleus, z
100
100
  // see revision cc13abc18f77b6787b923e3c4edaef51750d9e90
101
101
  return toggleDiaIDs(diaID, atomInformation);
102
102
  }, []);
103
- const handleOnClickAtom = useCallback((atom, event) => {
103
+ const handleOnClickAtom = useCallback((diaIDAndInfo, event) => {
104
104
  if (!checkModifierKeyActivated(event) && activeAssignment.activated) {
105
105
  const { axis, id } = activeAssignment.activated;
106
106
  if (id && axis) {
107
- const atomInformation = extractFromAtom(atom, nucleus, axis);
107
+ const atomInformation = extractFromAtom(diaIDAndInfo, nucleus, axis);
108
108
  if (atomInformation.nbAtoms > 0) {
109
109
  // save assignment in assignment hook
110
110
  const dimension = displayerMode === DISPLAYER_MODE.DM_1D ? '1D' : '2D';
@@ -173,8 +173,8 @@ export default function useAtomAssignment({ displayerMode, activeTab: nucleus, z
173
173
  nucleus,
174
174
  toggleAssignment,
175
175
  ]);
176
- const handleOnAtomHover = useCallback((atom) => {
177
- const { oclIDs } = extractFromAtom(atom, nucleus);
176
+ const handleOnAtomHover = useCallback((diaIDAndInfo) => {
177
+ const { oclIDs } = extractFromAtom(diaIDAndInfo, nucleus);
178
178
  // on enter the atom
179
179
  if (oclIDs.length > 0) {
180
180
  // set all IDs to highlight when hovering over an atom from assignment data
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { css } from '@emotion/react';
4
- import { SvgNmrFt, SvgNmrPeaks } from 'cheminfo-font';
4
+ import { SvgNmrFt, SvgNmrPeaks, SvgNmrPeaksTopLabels } from 'cheminfo-font';
5
5
  import SvgPeaks from 'cheminfo-font/lib-react-cjs/lib-react-tsx/nmr/Peaks';
6
6
  import { useCallback, useMemo, useState, useRef, memo } from 'react';
7
7
  import { FaThinkPeaks } from 'react-icons/fa';
@@ -13,12 +13,12 @@ import ActiveButton from '../../elements/ActiveButton';
13
13
  import Button from '../../elements/Button';
14
14
  import { useAlert } from '../../elements/popup/Alert';
15
15
  import { useModal } from '../../elements/popup/Modal';
16
- import { useActiveSpectrumPeaksViewState, } from '../../hooks/useActiveSpectrumPeaksViewState';
16
+ import { useActiveSpectrumPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState';
17
17
  import useCheckExperimentalFeature from '../../hooks/useCheckExperimentalFeature';
18
18
  import { useFormatNumberByNucleus } from '../../hooks/useFormatNumberByNucleus';
19
19
  import useSpectrum from '../../hooks/useSpectrum';
20
20
  import { tablePanelStyle } from '../extra/BasicPanelStyle';
21
- import DefaultPanelHeader from '../header/DefaultPanelHeader';
21
+ import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
22
22
  import PreferencesHeader from '../header/PreferencesHeader';
23
23
  import PeaksPreferences from './PeaksPreferences';
24
24
  import PeaksTable from './PeaksTable';
@@ -86,6 +86,10 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
86
86
  function toggleViewProperty(key) {
87
87
  dispatch({ type: 'TOGGLE_PEAKS_VIEW_PROPERTY', payload: { key } });
88
88
  }
89
+ function toggleDisplayingMode() {
90
+ dispatch({ type: 'TOGGLE_PEAKS_DISPLAYING_MODE' });
91
+ }
92
+ const counter = peaks?.values?.length || 0;
89
93
  return (_jsxs("div", { css: [
90
94
  tablePanelStyle,
91
95
  isFlipped &&
@@ -97,11 +101,13 @@ function PeaksPanelInner({ peaks, info, xDomain, activeTab, peaksViewState, }) {
97
101
  }
98
102
  }
99
103
  `,
100
- ], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: peaks?.values?.length, onDelete: handleDeleteAll, deleteToolTip: "Delete All Peaks", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all peaks' : 'Hide peaks out of view', filterIsActive: filterIsActive, counterFiltered: filteredPeaks.length, showSettingButton: true, onSettingClick: settingsPanelHandler, children: [isExperimental && (_jsxs(_Fragment, { children: [_jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.showPeaksShapes
104
+ ], children: [!isFlipped && (_jsxs(DefaultPanelHeader, { counter: counter, counterLabel: createFilterLabel(counter, filterIsActive && filteredPeaks?.length), onDelete: handleDeleteAll, deleteToolTip: "Delete All Peaks", onFilter: handleOnFilter, filterToolTip: filterIsActive ? 'Show all peaks' : 'Hide peaks out of view', showSettingButton: true, onSettingClick: settingsPanelHandler, children: [isExperimental && (_jsxs(_Fragment, { children: [_jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.showPeaksShapes
101
105
  ? 'Hide peaks shapes'
102
106
  : 'Show peaks shapes', popupPlacement: "right", onClick: () => toggleViewProperty('showPeaksShapes'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.showPeaksShapes, children: _jsx(SvgPeaks, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.showPeaksSum
103
107
  ? 'Hide peaks sum'
104
- : 'Show peaks sum', popupPlacement: "right", onClick: () => toggleViewProperty('showPeaksSum'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.showPeaksSum, children: _jsx(SvgNmrFt, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(Button.BarButton, { onClick: optimizePeaksHandler, toolTip: "Optimize peaks", tooltipOrientation: "horizontal", children: _jsx(FaThinkPeaks, {}) })] })), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.isPeaksVisible ? 'Hide peaks' : 'Show peaks', popupPlacement: "right", onClick: () => toggleViewProperty('isPeaksVisible'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.isPeaksVisible, children: _jsx(SvgNmrPeaks, { style: { pointerEvents: 'none', fontSize: '12px' } }) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(PeaksTable, { data: filteredPeaks, activeTab: activeTab })) : (_jsx(PeaksPreferences, { ref: settingRef })) })] }));
108
+ : 'Show peaks sum', popupPlacement: "right", onClick: () => toggleViewProperty('showPeaksSum'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.showPeaksSum, children: _jsx(SvgNmrFt, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(Button.BarButton, { onClick: optimizePeaksHandler, toolTip: "Optimize peaks", tooltipOrientation: "horizontal", children: _jsx(FaThinkPeaks, {}) })] })), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.isPeaksVisible ? 'Hide peaks' : 'Show peaks', popupPlacement: "right", onClick: () => toggleViewProperty('isPeaksVisible'), disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.isPeaksVisible, children: _jsx(SvgNmrPeaks, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { style: { marginLeft: '2px', marginRight: '2px' }, popupTitle: peaksViewState.displayingMode === 'spread'
109
+ ? 'Single Mode'
110
+ : 'Spread mode', popupPlacement: "right", onClick: toggleDisplayingMode, disabled: !peaks?.values || peaks.values.length === 0, value: peaksViewState.displayingMode === 'spread', children: _jsx(SvgNmrPeaksTopLabels, { style: { pointerEvents: 'none', fontSize: '12px' } }) })] })), isFlipped && (_jsx(PreferencesHeader, { onSave: saveSettingHandler, onClose: settingsPanelHandler })), _jsx("div", { className: "inner-container", children: !isFlipped ? (_jsx(PeaksTable, { data: filteredPeaks, activeTab: activeTab })) : (_jsx(PeaksPreferences, { ref: settingRef })) })] }));
105
111
  }
106
112
  const MemoizedPeaksPanel = memo(PeaksPanelInner);
107
113
  const emptyData = { peaks: null, info: {} };
@@ -18,7 +18,7 @@ import { usePanelPreferences } from '../../hooks/usePanelPreferences';
18
18
  import CopyClipboardModal from '../../modal/CopyClipboardModal';
19
19
  import ChangeSumModal from '../../modal/changeSum/ChangeSumModal';
20
20
  import { getNumberOfDecimals } from '../../utility/formatNumber';
21
- import DefaultPanelHeader from '../header/DefaultPanelHeader';
21
+ import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
22
22
  const style = css `
23
23
  .btn {
24
24
  background-color: transparent;
@@ -48,11 +48,6 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
48
48
  dispatch({ type: 'CHANGE_RANGE_SUM', payload: { options } });
49
49
  modal.close();
50
50
  }
51
- function showChangeRangesSumModal() {
52
- modal.show(_jsx(ChangeSumModal, { onClose: () => modal.close(), onSave: changeRangesSumHandler, header: currentSum
53
- ? `Set new Ranges Sum (Current: ${Number(currentSum).toFixed(2)})`
54
- : 'Set new Ranges Sum', sumOptions: ranges?.options }));
55
- }
56
51
  function removeAssignments() {
57
52
  onUnlink();
58
53
  }
@@ -112,10 +107,11 @@ function RangesHeader({ id, ranges, info, onUnlink, onFilterActivated, onSetting
112
107
  });
113
108
  }
114
109
  const hasRanges = Array.isArray(ranges?.values) && ranges.values.length > 0;
115
- return (_jsxs("div", { css: style, children: [_jsxs(DefaultPanelHeader, { counter: ranges?.values?.length || 0, onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', filterIsActive: isFilterActive, counterFiltered: filterCounter, showSettingButton: true, onSettingClick: onSettingClick, children: [_jsx(Button, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", disabled: !hasRanges, children: _jsx(FaFileExport, {}) }), _jsx(Button, { popupTitle: currentSum
116
- ? `Change ranges sum (${Number(currentSum).toFixed(2)})`
117
- : 'Change ranges sum', popupPlacement: "right", onClick: showChangeRangesSumModal, className: "btn icon", children: _jsx(SvgNmrSum, {}) }), _jsx(Button, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(ActiveButton, { popupTitle: showMultiplicityTrees
110
+ const counter = ranges?.values?.length || 0;
111
+ return (_jsxs("div", { css: style, children: [_jsxs(DefaultPanelHeader, { counter: counter, counterLabel: createFilterLabel(counter, isFilterActive && filterCounter), onDelete: handleDeleteAll, deleteToolTip: "Delete All Ranges", onFilter: onFilterActivated, filterToolTip: isFilterActive ? 'Show all ranges' : 'Hide ranges out of view', showSettingButton: true, onSettingClick: onSettingClick, children: [_jsx(Button, { popupTitle: "Preview publication string", popupPlacement: "right", onClick: saveAsHTMLHandler, className: "btn preview-publication-icon", disabled: !hasRanges, children: _jsx(FaFileExport, {}) }), _jsx(ChangeSumModal, { onSave: changeRangesSumHandler, sumType: "ranges", currentSum: currentSum, sumOptions: ranges?.options, renderButton: (onClick) => (_jsx(Button, { popupTitle: currentSum
112
+ ? `Change ranges sum (${currentSum.toFixed(2)})`
113
+ : 'Change ranges sum', popupPlacement: "right", className: "btn icon", onClick: onClick, children: _jsx(SvgNmrSum, {}) })) }), _jsx(Button, { popupTitle: "Remove all assignments", popupPlacement: "right", onClick: handleOnRemoveAssignments, disabled: !hasRanges, className: "btn icon", children: _jsx(FaUnlink, {}) }), _jsx(ActiveButton, { popupTitle: showMultiplicityTrees
118
114
  ? 'Hide multiplicity trees in spectrum'
119
- : 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fix integral values", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: _jsx(ImLink, {}) })] }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
115
+ : 'Show multiplicity trees in spectrum', popupPlacement: "right", onClick: handleSetShowMultiplicityTrees, value: showMultiplicityTrees, disabled: !hasRanges, children: _jsx(FaSitemap, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showJGraph ? 'Hide J Graph' : 'Show J Graph', popupPlacement: "right", onClick: handleShowJGraph, value: showJGraph, disabled: !hasRanges, children: _jsx(FaChartBar, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { popupTitle: showRangesIntegrals ? 'Hide integrals' : 'Show integrals', popupPlacement: "right", onClick: handleShowIntegrals, value: showRangesIntegrals, disabled: !hasRanges, children: _jsx(SvgNmrIntegrate, { style: { pointerEvents: 'none', fontSize: '12px' } }) }), _jsx(ActiveButton, { className: "icon", popupTitle: "Fixed integration sum", popupPlacement: "right", onClick: changeSumConstantFlagHandler, value: ranges?.options?.isSumConstant, children: _jsx(ImLink, {}) })] }), _jsx(ClipboardFallbackModal, { mode: shouldFallback, onDismiss: cleanShouldFallback, text: text, label: "Preview publication string" })] }));
120
116
  }
121
117
  export default RangesHeader;
@@ -28,7 +28,7 @@ function DisplayButtons1D(props) {
28
28
  return null;
29
29
  }
30
30
  const display = data.display;
31
- return (_jsx("button", { "data-test-id": "hide-show-spectrum-button", style: buttonStyle, type: "button", onClick: (e) => {
31
+ return (_jsx("button", { "data-testid": "hide-show-spectrum-button", style: buttonStyle, type: "button", onClick: (e) => {
32
32
  e.stopPropagation();
33
33
  onChangeVisibility(data, 'isVisible');
34
34
  }, children: _jsx(FaEye, { style: {
@@ -12,7 +12,7 @@ import Select from '../../elements/Select';
12
12
  import ToolTip from '../../elements/ToolTip/ToolTip';
13
13
  import { useModal } from '../../elements/popup/Modal';
14
14
  import { DISPLAYER_MODE } from '../../reducer/core/Constants';
15
- import DefaultPanelHeader from '../header/DefaultPanelHeader';
15
+ import DefaultPanelHeader, { createFilterLabel, } from '../header/DefaultPanelHeader';
16
16
  import CorrelationTable from './CorrelationTable/CorrelationTable';
17
17
  import Overview from './Overview';
18
18
  import SetMolecularFormulaModal from './SetMolecularFormulaModal';
@@ -309,9 +309,10 @@ function SummaryPanel() {
309
309
  const handleOnFilter = useCallback(() => {
310
310
  setFilterIsActive(!filterIsActive);
311
311
  }, [filterIsActive]);
312
- return (_jsxs("div", { css: panelStyle, children: [_jsxs(DefaultPanelHeader, { canDelete: false, counter: correlationsData ? correlationsData.values.length : 0, onFilter: handleOnFilter, filterToolTip: filterIsActive
312
+ const counter = correlationsData ? correlationsData.values.length : 0;
313
+ return (_jsxs("div", { css: panelStyle, children: [_jsxs(DefaultPanelHeader, { canDelete: false, counter: counter, counterLabel: createFilterLabel(counter, filterIsActive && filteredCorrelationsData?.values.length), onFilter: handleOnFilter, filterToolTip: filterIsActive
313
314
  ? 'Show all correlations'
314
- : 'Hide correlations out of view', filterIsActive: filterIsActive, counterFiltered: filteredCorrelationsData?.values.length, children: [_jsx(ToolTip, { title: `Set molecular formula (${correlationsData.options.mf})`, popupPlacement: "right", children: _jsx("button", { type: "button", onClick: showSetMolecularFormulaModal, children: _jsx(FaFlask, {}) }) }), _jsx(ToolTip, { title: `Set shift tolerance`, popupPlacement: "right", children: _jsx("button", { type: "button", onClick: showSetShiftToleranceModal, children: _jsx(FaSlidersH, {}) }) }), _jsxs("div", { className: "extra-header-content", children: [_jsx("div", { className: "overview-container", children: _jsx(Overview, { correlationsData: correlationsData }) }), _jsx("div", { className: "table-view-selection", children: _jsxs("span", { children: [_jsx("label", { children: "View:" }), _jsx(Select, { onChange: (selection) => {
315
+ : 'Hide correlations out of view', children: [_jsx(ToolTip, { title: `Set molecular formula (${correlationsData.options.mf})`, popupPlacement: "right", children: _jsx("button", { type: "button", onClick: showSetMolecularFormulaModal, children: _jsx(FaFlask, {}) }) }), _jsx(ToolTip, { title: `Set shift tolerance`, popupPlacement: "right", children: _jsx("button", { type: "button", onClick: showSetShiftToleranceModal, children: _jsx(FaSlidersH, {}) }) }), _jsxs("div", { className: "extra-header-content", children: [_jsx("div", { className: "overview-container", children: _jsx(Overview, { correlationsData: correlationsData }) }), _jsx("div", { className: "table-view-selection", children: _jsxs("span", { children: [_jsx("label", { children: "View:" }), _jsx(Select, { onChange: (selection) => {
315
316
  setSelectedAdditionalColumnsAtomType(selection);
316
317
  if (selection === 'H-H') {
317
318
  setShowProtonsAsRows(true);