nmrium 0.50.1 → 0.51.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 (151) hide show
  1. package/lib/component/1d/Chart1D.js +1 -1
  2. package/lib/component/1d/LinesSeries.js +2 -2
  3. package/lib/component/1d/Viewer1D.js +6 -11
  4. package/lib/component/1d/database/DatabaseSpectrum.js +3 -3
  5. package/lib/component/2d/1d-tracer/HorizontalSliceChart.js +6 -2
  6. package/lib/component/2d/1d-tracer/VerticalSliceChart.js +8 -1
  7. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraceWithMouse.js +2 -21
  8. package/lib/component/2d/1d-tracer/phase-correction-traces/PhaseTraces.js +1 -1
  9. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.d.ts +1 -1
  10. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectraPhaseTraces.js +6 -17
  11. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.d.ts +6 -10
  12. package/lib/component/2d/1d-tracer/phase-correction-traces/SpectrumPhaseTrace.js +62 -13
  13. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.d.ts +1 -0
  14. package/lib/component/2d/1d-tracer/phase-correction-traces/useActivePhaseTraces.js +2 -1
  15. package/lib/component/2d/Viewer2D.js +16 -15
  16. package/lib/component/2d/ft/Contours.js +6 -3
  17. package/lib/component/2d/utilities/scale.d.ts +2 -1
  18. package/lib/component/2d/utilities/scale.js +12 -2
  19. package/lib/component/EventsTrackers/BrushTracker.d.ts +5 -3
  20. package/lib/component/EventsTrackers/BrushTracker.js +2 -2
  21. package/lib/component/EventsTrackers/KeysListenerTracker.d.ts +1 -1
  22. package/lib/component/EventsTrackers/KeysListenerTracker.js +29 -15
  23. package/lib/component/context/ToasterContext.d.ts +13 -0
  24. package/lib/component/context/ToasterContext.js +34 -0
  25. package/lib/component/elements/Select.js +2 -2
  26. package/lib/component/elements/ToolbarPopoverItem.js +1 -1
  27. package/lib/component/header/AutoPeakPickingOptionPanel.js +6 -3
  28. package/lib/component/header/Header.d.ts +1 -11
  29. package/lib/component/header/Header.js +5 -6
  30. package/lib/component/header/PhaseCorrectionPanel.js +24 -33
  31. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.d.ts +1 -1
  32. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +96 -42
  33. package/lib/component/header/RangesPickingOptionPanel.js +6 -3
  34. package/lib/component/hooks/useDialogToggle.d.ts +5 -0
  35. package/lib/component/hooks/useDialogToggle.js +16 -0
  36. package/lib/component/hooks/useExport.d.ts +9 -1
  37. package/lib/component/hooks/useExport.js +34 -36
  38. package/lib/component/hooks/useSaveSettings.js +6 -3
  39. package/lib/component/hooks/useToolsFunctions.js +6 -4
  40. package/lib/component/loader/DropZone.js +14 -14
  41. package/lib/component/main/InnerNMRium.js +5 -9
  42. package/lib/component/main/InnerNMRiumContents.d.ts +0 -2
  43. package/lib/component/main/InnerNMRiumContents.js +5 -3
  44. package/lib/component/main/NMRium.js +2 -2
  45. package/lib/component/modal/AboutPredictionModal.js +1 -1
  46. package/lib/component/modal/ExportAsJcampModal.js +15 -15
  47. package/lib/component/modal/ImportPublicationStringModal.js +5 -3
  48. package/lib/component/modal/LoadJCAMPModal.js +6 -4
  49. package/lib/component/modal/PredictSpectraModal.js +11 -9
  50. package/lib/component/modal/SaveAsModal.d.ts +3 -4
  51. package/lib/component/modal/SaveAsModal.js +27 -27
  52. package/lib/component/modal/editRange/EditRangeModal.js +2 -2
  53. package/lib/component/modal/editRange/forms/components/DeltaInput.d.ts +2 -3
  54. package/lib/component/modal/editRange/forms/components/DeltaInput.js +2 -3
  55. package/lib/component/modal/editRange/forms/components/InfoBlock.d.ts +1 -0
  56. package/lib/component/modal/editRange/forms/components/{SignalFormInfo.js → InfoBlock.js} +2 -2
  57. package/lib/component/modal/editRange/forms/components/NewSignalTab.d.ts +5 -0
  58. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +85 -0
  59. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +7 -0
  60. package/lib/component/modal/editRange/forms/components/SignalTab.js +24 -0
  61. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +8 -0
  62. package/lib/component/modal/editRange/forms/components/SignalsContent.js +57 -0
  63. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.d.ts +5 -0
  64. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +133 -0
  65. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.d.ts +5 -0
  66. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +141 -0
  67. package/lib/component/modal/metaImportation/MetaImportationModal.d.ts +7 -4
  68. package/lib/component/modal/metaImportation/MetaImportationModal.js +23 -13
  69. package/lib/component/modal/metaImportation/utils/mapColumnToSelectItems.js +1 -1
  70. package/lib/component/modal/setting/GeneralSettings.js +7 -4
  71. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +7 -4
  72. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +13 -7
  73. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +6 -4
  74. package/lib/component/panels/PeaksPanel/PeaksPanel.js +6 -3
  75. package/lib/component/panels/RangesPanel/RangesHeader.js +3 -3
  76. package/lib/component/panels/RangesPanel/RangesPanel.js +4 -4
  77. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -3
  78. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +11 -5
  79. package/lib/component/panels/databasePanel/DatabasePanel.js +37 -19
  80. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +1 -1
  81. package/lib/component/panels/filtersPanel/FilterPanel.js +5 -3
  82. package/lib/component/panels/filtersPanel/FiltersTable.js +27 -23
  83. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +6 -4
  84. package/lib/component/panels/multipleAnalysisPanel/AlignSpectra.js +2 -2
  85. package/lib/component/panels/multipleAnalysisPanel/AnalysisChart.js +3 -3
  86. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +5 -5
  87. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +4 -2
  88. package/lib/component/panels/predictionPanel/PredictionPanel.js +7 -5
  89. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -0
  90. package/lib/component/reducer/Reducer.d.ts +2 -2
  91. package/lib/component/reducer/Reducer.js +23 -16
  92. package/lib/component/reducer/actions/FiltersActions.d.ts +11 -4
  93. package/lib/component/reducer/actions/FiltersActions.js +243 -91
  94. package/lib/component/reducer/actions/IntegralsActions.js +2 -2
  95. package/lib/component/reducer/actions/MoleculeActions.js +0 -1
  96. package/lib/component/reducer/actions/RangesActions.js +16 -6
  97. package/lib/component/reducer/actions/ToolsActions.d.ts +3 -3
  98. package/lib/component/reducer/actions/ToolsActions.js +75 -14
  99. package/lib/component/reducer/helper/Zoom1DManager.d.ts +4 -3
  100. package/lib/component/reducer/helper/Zoom1DManager.js +4 -4
  101. package/lib/component/reducer/helper/ZoomHistoryManager.js +1 -5
  102. package/lib/component/reducer/helper/findStrongestPeak.d.ts +6 -0
  103. package/lib/component/reducer/helper/findStrongestPeak.js +13 -0
  104. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.d.ts +2 -1
  105. package/lib/component/reducer/helper/getTwoDimensionPhaseCorrectionOptions.js +7 -1
  106. package/lib/component/toolbar/ToolBar.js +17 -12
  107. package/lib/component/utility/Events.d.ts +11 -0
  108. package/lib/component/utility/Events.js +22 -0
  109. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -33
  110. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +5 -15
  111. package/lib/data/data1d/Spectrum1D/ranges/autoRangesDetection.js +6 -4
  112. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +1 -1
  113. package/lib/data/data1d/Spectrum1D/ranges/detectRange.js +1 -1
  114. package/lib/data/data1d/Spectrum1D/ranges/detectRanges.d.ts +6 -4
  115. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +13 -3
  116. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +6 -0
  117. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.d.ts +13 -3
  118. package/lib/data/data1d/Spectrum1D/ranges/detectSignalsByMultipletAnalysis.js +78 -18
  119. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +2 -2
  120. package/lib/data/data1d/spectrumSimulation.d.ts +1 -1
  121. package/lib/data/data2d/Spectrum2D/contours.js +3 -3
  122. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +2 -2
  123. package/lib/data/data2d/Spectrum2D/getSlice.js +3 -3
  124. package/lib/data/getDefaultMatrixFilters.js +2 -2
  125. package/lib/data/matrixGeneration.js +1 -1
  126. package/lib/data/utilities/calculateSanPlot.d.ts +1 -6
  127. package/lib/versionInfo.js +1 -1
  128. package/package.json +31 -30
  129. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +0 -8
  130. package/lib/component/elements/popup/Alert/AlertBlock.js +0 -30
  131. package/lib/component/elements/popup/Alert/Context.d.ts +0 -27
  132. package/lib/component/elements/popup/Alert/Context.js +0 -10
  133. package/lib/component/elements/popup/Alert/ProgressIndicator.d.ts +0 -1
  134. package/lib/component/elements/popup/Alert/ProgressIndicator.js +0 -33
  135. package/lib/component/elements/popup/Alert/Provider.d.ts +0 -19
  136. package/lib/component/elements/popup/Alert/Provider.js +0 -127
  137. package/lib/component/elements/popup/Alert/index.d.ts +0 -3
  138. package/lib/component/elements/popup/Alert/index.js +0 -3
  139. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.d.ts +0 -10
  140. package/lib/component/modal/editRange/forms/components/AddSignalFormTab.js +0 -81
  141. package/lib/component/modal/editRange/forms/components/CouplingsTable.d.ts +0 -13
  142. package/lib/component/modal/editRange/forms/components/CouplingsTable.js +0 -63
  143. package/lib/component/modal/editRange/forms/components/SignalFormInfo.d.ts +0 -1
  144. package/lib/component/modal/editRange/forms/components/SignalFormTab.d.ts +0 -8
  145. package/lib/component/modal/editRange/forms/components/SignalFormTab.js +0 -18
  146. package/lib/component/modal/editRange/forms/components/SignalsForm.d.ts +0 -10
  147. package/lib/component/modal/editRange/forms/components/SignalsForm.js +0 -114
  148. package/lib/component/modal/metaImportation/index.d.ts +0 -2
  149. package/lib/component/modal/metaImportation/index.js +0 -17
  150. package/lib/component/reducer/helper/getStrongestPeak.d.ts +0 -7
  151. package/lib/component/reducer/helper/getStrongestPeak.js +0 -15
@@ -9,8 +9,8 @@ import { getDefaultPredictionOptions, predictSpectra, } from '../../data/Predict
9
9
  import { useChartData } from '../context/ChartContext';
10
10
  import { useDispatch } from '../context/DispatchContext';
11
11
  import { useLogger } from '../context/LoggerContext';
12
+ import { useToaster } from '../context/ToasterContext';
12
13
  import Button from '../elements/Button';
13
- import { useAlert } from '../elements/popup/Alert';
14
14
  import PredictionPreferences from '../panels/predictionPanel/PredictionOptionsPanel';
15
15
  import { useStateWithLocalStorage } from '../utility/LocalStorage';
16
16
  const styles = css `
@@ -47,7 +47,7 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
47
47
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
48
48
  const refForm = useRef();
49
49
  const dispatch = useDispatch();
50
- const alert = useAlert();
50
+ const toaster = useToaster();
51
51
  const [predictionPreferences, setPredictionPreferences] = useStateWithLocalStorage('nmrium-prediction-preferences');
52
52
  const { isApproved: isAgree = false, ...options } = predictionPreferences;
53
53
  const [isApproved, setApproved] = useState(isAgree);
@@ -74,7 +74,9 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
74
74
  }
75
75
  onClose();
76
76
  closeDialog();
77
- const hideLoading = await alert.showLoading(`Predict ${predictedSpectra.join(',')} in progress`);
77
+ const hideLoading = toaster.showLoading({
78
+ message: `Predict ${predictedSpectra.join(',')} in progress`,
79
+ });
78
80
  try {
79
81
  const data = await predictSpectra(molfile, values.spectra);
80
82
  dispatch({
@@ -88,7 +90,7 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
88
90
  });
89
91
  }
90
92
  catch (error) {
91
- alert.error(error?.message);
93
+ toaster.show({ message: error?.message, intent: 'danger' });
92
94
  }
93
95
  finally {
94
96
  hideLoading();
@@ -96,14 +98,14 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
96
98
  }
97
99
  })();
98
100
  }, [
99
- alert,
100
- dispatch,
101
- isApproved,
102
101
  molecule,
103
- onClose,
104
- logger,
105
102
  setPredictionPreferences,
103
+ isApproved,
104
+ onClose,
106
105
  closeDialog,
106
+ toaster,
107
+ dispatch,
108
+ logger,
107
109
  ]);
108
110
  return (_jsxs(_Fragment, { children: [_jsx(Toolbar, { children: _jsx(Toolbar.Item, { icon: _jsx(SvgNmrFt, {}), title: "Predict spectra", onClick: openDialog }) }), _jsxs(Dialog, { isOpen: isOpenDialog, onClose: () => {
109
111
  onClose();
@@ -1,9 +1,8 @@
1
1
  import { LabelStyle } from '../elements/Label';
2
2
  export declare const labelStyle: LabelStyle;
3
3
  interface SaveAsModalProps {
4
- onClose?: (event?: MouseEvent) => void;
5
- onSave: (element: any) => void;
6
- name: string;
4
+ onCloseDialog: () => void;
5
+ isOpen: boolean;
7
6
  }
8
- declare function SaveAsModal({ onClose, onSave, name }: SaveAsModalProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ declare function SaveAsModal(props: SaveAsModalProps): import("@emotion/react/jsx-runtime").JSX.Element | undefined;
9
8
  export default SaveAsModal;
@@ -1,30 +1,27 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
+ import { Dialog, DialogBody, DialogFooter } from '@blueprintjs/core';
3
4
  import { css } from '@emotion/react';
4
5
  import { Field, Formik } from 'formik';
5
- import { useCallback, useRef } from 'react';
6
+ import { useRef } from 'react';
6
7
  import { DataExportOptions } from '../../data/SpectraManager';
7
8
  import { useChartData } from '../context/ChartContext';
8
9
  import ActionButtons from '../elements/ActionButtons';
9
- import { CloseButton } from '../elements/CloseButton';
10
10
  import Label from '../elements/Label';
11
11
  import FormikCheckBox from '../elements/formik/FormikCheckBox';
12
12
  import FormikInput from '../elements/formik/FormikInput';
13
- import { ModalStyles } from './ModalStyle';
13
+ import useExport from '../hooks/useExport';
14
14
  const styles = css `
15
- .inner-content {
16
- flex: 1;
17
- }
15
+ display: flex;
16
+ flex-direction: column;
18
17
 
19
- .data-export-group {
20
- label {
21
- margin-right: 10px;
22
- display: inline-block;
23
- }
18
+ label {
19
+ margin-right: 20px;
20
+ display: inline-block;
21
+ }
24
22
 
25
- input[type='radio'] {
26
- margin-right: 5px;
27
- }
23
+ input[type='radio'] {
24
+ margin-right: 5px;
28
25
  }
29
26
  `;
30
27
  const INITIAL_VALUE = {
@@ -41,7 +38,6 @@ export const labelStyle = {
41
38
  label: {
42
39
  flex: 4,
43
40
  fontSize: '12px',
44
- fontWeight: 'bold',
45
41
  color: '#232323',
46
42
  },
47
43
  wrapper: {
@@ -51,21 +47,25 @@ export const labelStyle = {
51
47
  },
52
48
  container: { padding: '5px 0' },
53
49
  };
54
- function SaveAsModal({ onClose, onSave, name }) {
50
+ function SaveAsModal(props) {
51
+ const { onCloseDialog, isOpen } = props;
55
52
  const refForm = useRef();
56
- const { source } = useChartData();
57
- const handleSave = useCallback(() => {
58
- refForm.current.submitForm();
59
- }, []);
60
- const submitHandler = useCallback((values) => {
61
- onSave(values);
62
- onClose?.();
63
- }, [onClose, onSave]);
64
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "Save as ... " }), _jsx(CloseButton, { title: "Close", onClick: () => onClose?.(), className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsx(Formik, { innerRef: refForm, initialValues: { ...INITIAL_VALUE, name }, onSubmit: submitHandler, children: _jsxs(_Fragment, { children: [_jsx(Label, { style: labelStyle, title: "Name", children: _jsx(FormikInput, { name: "name", className: "name", style: {
53
+ const { source, data } = useChartData();
54
+ const { saveHandler } = useExport();
55
+ const fileName = data[0]?.info?.name;
56
+ function submitHandler(values) {
57
+ saveHandler(values);
58
+ onCloseDialog?.();
59
+ }
60
+ if (!isOpen)
61
+ return;
62
+ return (_jsxs(Dialog, { isOpen: true, title: "Save as ... ", onClose: onCloseDialog, style: { width: 500 }, children: [_jsx(DialogBody, { css: css `
63
+ background-color: white;
64
+ `, children: _jsx(Formik, { innerRef: refForm, initialValues: { ...INITIAL_VALUE, name: fileName }, onSubmit: submitHandler, children: _jsxs(_Fragment, { children: [_jsx(Label, { style: labelStyle, title: "Name", children: _jsx(FormikInput, { name: "name", className: "name", style: {
65
65
  inputWrapper: { width: '100%' },
66
66
  input: { padding: '5px', textAlign: 'left' },
67
- } }) }), _jsx(Label, { style: labelStyle, title: "Compressed", children: _jsx(FormikCheckBox, { name: "compressed" }) }), _jsx(Label, { style: labelStyle, title: "Pretty Format", children: _jsx(FormikCheckBox, { name: "pretty" }) }), _jsx(Label, { style: labelStyle, title: "Include view", children: _jsx(FormikCheckBox, { name: "include.view" }) }), _jsx(Label, { style: labelStyle, title: "Include settings", children: _jsx(FormikCheckBox, { name: "include.settings" }) }), _jsx(Label, { style: labelStyle, title: "Include Data", children: _jsx("div", { style: { display: 'flex', flexDirection: 'column' }, children: _jsxs("div", { className: "data-export-group", children: [_jsxs("label", { children: [_jsx(Field, { type: "radio", name: "include.dataType", value: DataExportOptions.ROW_DATA }), "Raw Data"] }), _jsxs("label", { style: {
67
+ } }) }), _jsx(Label, { style: labelStyle, title: "Compressed", htmlFor: "compressed", children: _jsx(FormikCheckBox, { name: "compressed" }) }), _jsx(Label, { style: labelStyle, title: "Pretty Format", htmlFor: "pretty", children: _jsx(FormikCheckBox, { name: "pretty" }) }), _jsx(Label, { style: labelStyle, title: "Include view", htmlFor: "include.view", children: _jsx(FormikCheckBox, { name: "include.view" }) }), _jsx(Label, { style: labelStyle, title: "Include settings", htmlFor: "include.settings", children: _jsx(FormikCheckBox, { name: "include.settings" }) }), _jsx(Label, { style: labelStyle, title: "Include Data", children: _jsx("div", { css: styles, children: _jsxs("div", { children: [_jsxs("label", { children: [_jsx(Field, { type: "radio", name: "include.dataType", value: DataExportOptions.ROW_DATA }), "Raw Data"] }), _jsxs("label", { style: {
68
68
  color: source ? 'black' : 'lightgray',
69
- }, children: [_jsx(Field, { type: "radio", name: "include.dataType", value: DataExportOptions.DATA_SOURCE, disabled: !source }), "Data Source"] }), _jsxs("label", { children: [_jsx(Field, { type: "radio", name: "include.dataType", value: DataExportOptions.NO_DATA }), "No Data"] })] }) }) })] }) }) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: () => onClose?.() }) })] }));
69
+ }, children: [_jsx(Field, { type: "radio", name: "include.dataType", value: DataExportOptions.DATA_SOURCE, disabled: !source }), "Data Source"] }), _jsxs("label", { children: [_jsx(Field, { type: "radio", name: "include.dataType", value: DataExportOptions.NO_DATA }), "No Data"] })] }) }) })] }) }) }), _jsx(DialogFooter, { children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current.submitForm(), doneLabel: "Save", onCancel: () => onCloseDialog?.() }) })] }));
70
70
  }
71
71
  export default SaveAsModal;
@@ -16,7 +16,7 @@ import { usePanelPreferences } from '../../hooks/usePanelPreferences';
16
16
  import useSpectrum from '../../hooks/useSpectrum';
17
17
  import { hasCouplingConstant } from '../../panels/extra/utilities/MultiplicityUtilities';
18
18
  import { formatNumber } from '../../utility/formatNumber';
19
- import SignalsForm from './forms/components/SignalsForm';
19
+ import SignalsContent from './forms/components/SignalsContent';
20
20
  import editRangeFormValidation from './forms/validation/EditRangeValidation';
21
21
  const styles = css `
22
22
  min-height: 500px;
@@ -154,7 +154,7 @@ function EditRangeModal({ onSave, onClose, onZoom, onRest, rangeId, }) {
154
154
  if (!rangesPreferences || !range) {
155
155
  return;
156
156
  }
157
- return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "header handle", children: [_jsx(Button.Action, { onClick: handleOnZoom, fill: "outline", style: { fontSize: '14' }, color: { base: '#5f5f5f', hover: 'white' }, children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { className: "title", children: ` Range and Signal edition: ${formatNumber(range?.from, rangesPreferences.from.format)} ppm to ${formatNumber(range?.to, rangesPreferences.to.format)} ppm` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and Exit" }), _jsx(CloseButton, { title: "Close", onClick: handleOnClose })] }), _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: editRangeFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsx(SignalsForm, { range: range, preferences: rangesPreferences }), _jsx(FormikOnChange, { onChange: changeHandler })] }) })] }));
157
+ return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "header handle", children: [_jsx(Button.Action, { onClick: handleOnZoom, fill: "outline", style: { fontSize: '14' }, color: { base: '#5f5f5f', hover: 'white' }, children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { className: "title", children: ` Range and Signal edition: ${formatNumber(range?.from, rangesPreferences.from.format)} ppm to ${formatNumber(range?.to, rangesPreferences.to.format)} ppm` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and Exit" }), _jsx(CloseButton, { title: "Close", onClick: handleOnClose })] }), _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: editRangeFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsx(SignalsContent, { range: range }), _jsx(FormikOnChange, { onChange: changeHandler })] }) })] }));
158
158
  }
159
159
  function useRange(rangeId) {
160
160
  const { ranges } = useSpectrum({
@@ -1,7 +1,6 @@
1
1
  interface DeltaInputProps {
2
2
  signal: any;
3
3
  index: number;
4
- onFocus: (element: any) => void;
5
4
  }
6
- declare function DeltaInput({ signal, index, onFocus }: DeltaInputProps): import("react/jsx-runtime").JSX.Element;
7
- export default DeltaInput;
5
+ export declare function DeltaInput({ signal, index }: DeltaInputProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -11,9 +11,8 @@ const style = {
11
11
  margin: '0 5px',
12
12
  },
13
13
  };
14
- function DeltaInput({ signal, index, onFocus }) {
15
- return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { children: "\uD835\uDEC5: " }), _jsx(FormikInput, { name: `signals.${index}.delta`, type: "number", placeholder: 'J (Hz)', onFocus: onFocus, style: style, checkErrorAfterInputTouched: false }), _jsx("span", { children: signal.js
14
+ export function DeltaInput({ signal, index }) {
15
+ return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { children: "\uD835\uDEC5: " }), _jsx(FormikInput, { name: `signals.${index}.delta`, type: "number", placeholder: 'J (Hz)', style: style, checkErrorAfterInputTouched: false }), _jsx("span", { children: signal.js
16
16
  .map((_coupling) => translateMultiplet(_coupling.multiplicity))
17
17
  .join('') })] }));
18
18
  }
19
- export default DeltaInput;
@@ -0,0 +1 @@
1
+ export declare function InfoBlock(): import("react/jsx-runtime").JSX.Element;
@@ -24,11 +24,11 @@ const InfoText = (props) => {
24
24
  const { value, type = 'info' } = props;
25
25
  return (_jsx("p", { style: { ...styles.infoText, ...(type === 'error' && styles.errorText) }, children: value }));
26
26
  };
27
- export function SignalFormInfo() {
27
+ export function InfoBlock() {
28
28
  const { values, errors, } = useFormikContext();
29
29
  return (_jsx("div", { style: {
30
30
  textAlign: 'center',
31
31
  width: '100%',
32
32
  }, children: errors.signals &&
33
- (errors.signals.noSignals || errors.signals.noCouplings) ? (_jsxs("div", { children: [_jsx("p", { className: "error-text", children: errors.signals.noSignals || errors.signals.noCouplings[0].message }), errors.signals.noSignals && (_jsx(InfoText, { value: ADD_SIGNAL_INFO_TEXT }))] })) : values.activeTab === 'addSignalTab' ? (_jsx(InfoText, { value: ADD_SIGNAL_INFO_TEXT })) : (_jsx(InfoText, { value: EDIT_SIGNAL_INFO_TEXT })) }));
33
+ (errors.signals.noSignals || errors.signals.noCouplings) ? (_jsxs("div", { children: [_jsx("p", { className: "error-text", children: errors.signals.noSignals || errors.signals.noCouplings[0].message }), errors.signals.noSignals && (_jsx(InfoText, { value: ADD_SIGNAL_INFO_TEXT }))] })) : values.signalIndex === '-1' ? (_jsx(InfoText, { value: ADD_SIGNAL_INFO_TEXT })) : (_jsx(InfoText, { value: EDIT_SIGNAL_INFO_TEXT })) }));
34
34
  }
@@ -0,0 +1,5 @@
1
+ interface NewSignalTabProps {
2
+ range: any;
3
+ }
4
+ export declare function NewSignalTab(props: NewSignalTabProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,85 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Formik, useFormikContext } from 'formik';
3
+ import { translateMultiplet } from 'nmr-processing';
4
+ import { useRef } from 'react';
5
+ import * as Yup from 'yup';
6
+ import { useChartData } from '../../../../context/ChartContext';
7
+ import Button from '../../../../elements/Button';
8
+ import FormikInput from '../../../../elements/formik/FormikInput';
9
+ import { usePanelPreferences } from '../../../../hooks/usePanelPreferences';
10
+ import { useEvent } from '../../../../utility/Events';
11
+ import { formatNumber } from '../../../../utility/formatNumber';
12
+ const styles = {
13
+ container: {
14
+ padding: '0.4rem',
15
+ },
16
+ innerContainer: {
17
+ width: '70%',
18
+ display: 'block',
19
+ margin: 'auto',
20
+ },
21
+ infoText: {
22
+ padding: '10px 0',
23
+ fontSize: '13px',
24
+ textAlign: 'left',
25
+ },
26
+ };
27
+ export function NewSignalTab(props) {
28
+ const { range } = props;
29
+ const { values, setFieldValue } = useFormikContext();
30
+ const newSignalFormRef = useRef();
31
+ const { view: { spectra: { activeTab }, }, } = useChartData();
32
+ const rangesPreferences = usePanelPreferences('ranges', activeTab);
33
+ function saveHandler(val) {
34
+ const newSignal = {
35
+ multiplicity: 'm',
36
+ kind: 'signal',
37
+ delta: Number(val.newSignalDelta),
38
+ js: [{ multiplicity: translateMultiplet('m'), coupling: '' }],
39
+ };
40
+ const _signals = values.signals.slice().concat(newSignal);
41
+ void setFieldValue('signals', _signals);
42
+ void setFieldValue('signalIndex', String(_signals.length - 1));
43
+ }
44
+ useEvent({
45
+ onClick: (options) => {
46
+ if (values.signalIndex === '-1') {
47
+ newSignalFormRef.current.setValues({ newSignalDelta: options.xPPM });
48
+ }
49
+ },
50
+ onBrushEnd: (options) => {
51
+ const { range: [from, to], } = options;
52
+ if (values.signalIndex === '-1') {
53
+ newSignalFormRef.current.setValues({
54
+ newSignalDelta: (to - from) / 2 + from,
55
+ });
56
+ }
57
+ },
58
+ });
59
+ return (_jsx("div", { style: styles.container, children: _jsx(Formik, { innerRef: newSignalFormRef, validationSchema: getSignalValidationSchema(range), initialValues: {
60
+ newSignalDelta: (range.from + range.to) / 2,
61
+ }, onSubmit: saveHandler, children: _jsxs("div", { style: styles.innerContainer, children: [_jsxs("p", { style: styles.infoText, children: ["Edit or select a delta value of new signal in range [", `${formatNumber(range.from, rangesPreferences.from.format)} ppm - ${formatNumber(range.to, rangesPreferences.to.format)} ppm`, "]:"] }), _jsx(FormikInput, { name: "newSignalDelta", type: "number", placeholder: `𝛅(ppm)`, style: {
62
+ input: {
63
+ height: '30px',
64
+ padding: '0.25rem 0.5rem',
65
+ },
66
+ }, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
67
+ marginTop: '20px',
68
+ height: '30px',
69
+ }, onClick: () => newSignalFormRef.current.submitForm(), children: "Add a signal" })] }) }) }));
70
+ }
71
+ function getSignalValidationSchema(range) {
72
+ return Yup.object().shape({
73
+ newSignalDelta: Yup.number()
74
+ .test(`test-range`, '', function testNewSignalDelta(value) {
75
+ // eslint-disable-next-line no-invalid-this
76
+ const { path, createError } = this;
77
+ if (value && value >= range.from && value <= range.to) {
78
+ return true;
79
+ }
80
+ const errorMessage = ` ${value ? value.toFixed(5) : 0} ppm out of the range`;
81
+ return createError({ path, message: errorMessage });
82
+ })
83
+ .required(),
84
+ });
85
+ }
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ interface SignalTabProps {
3
+ index: number;
4
+ }
5
+ declare function SignalTab({ index }: SignalTabProps): import("@emotion/react/jsx-runtime").JSX.Element;
6
+ declare const _default: import("react").MemoExoticComponent<typeof SignalTab>;
7
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { Tab, Tabs } from '@blueprintjs/core';
4
+ import { css } from '@emotion/react';
5
+ import { memo } from 'react';
6
+ import { SignalJCouplingsTable } from './signal-tabs/SignalJCouplingsTable';
7
+ import { SignalPeaksTable } from './signal-tabs/SignalPeaksTable';
8
+ const style = {
9
+ borderSpacing: '0',
10
+ width: '100%',
11
+ fontSize: '12px',
12
+ height: '100%',
13
+ margin: '0',
14
+ padding: '0.4rem',
15
+ textAlign: 'center',
16
+ };
17
+ function SignalTab({ index }) {
18
+ return (_jsx("div", { style: style, css: css `
19
+ div[role='tabpanel'] {
20
+ width: 100%;
21
+ }
22
+ `, children: _jsxs(Tabs, { vertical: true, fill: true, renderActiveTabPanelOnly: true, children: [_jsx(Tab, { id: "couplings", title: "Couplings", panel: _jsx(SignalJCouplingsTable, { index: index }) }), _jsx(Tab, { id: "peaks", title: "Peaks", panel: _jsx(SignalPeaksTable, { index: index }) })] }) }));
23
+ }
24
+ export default memo(SignalTab);
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { Range } from 'nmr-processing';
3
+ interface SignalsFormProps {
4
+ range: Range;
5
+ }
6
+ declare function SignalsContent({ range }: SignalsFormProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
+ declare const _default: import("react").MemoExoticComponent<typeof SignalsContent>;
8
+ export default _default;
@@ -0,0 +1,57 @@
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 { useFormikContext } from 'formik';
5
+ import { useCallback, useMemo, memo, useEffect } from 'react';
6
+ import { FaPlus } from 'react-icons/fa';
7
+ import Tab from '../../../../elements/Tab/Tab';
8
+ import Tabs from '../../../../elements/Tab/Tabs';
9
+ import { DeltaInput } from './DeltaInput';
10
+ import { InfoBlock } from './InfoBlock';
11
+ import { NewSignalTab } from './NewSignalTab';
12
+ import SignalTab from './SignalTab';
13
+ const tabStylesAddition = css `
14
+ color: red;
15
+ `;
16
+ const tabStyles = css `
17
+ padding: 0 1.5rem !important;
18
+ height: 40px;
19
+ `;
20
+ const newTabStyles = css `
21
+ padding: 0 !important;
22
+ height: 40px;
23
+ `;
24
+ function SignalsContent({ range }) {
25
+ const { values, setFieldValue, errors, } = useFormikContext();
26
+ const tapClickHandler = useCallback(({ tabid }) => {
27
+ setFieldValue('signalIndex', tabid);
28
+ }, [setFieldValue]);
29
+ const handleDeleteSignal = useCallback(({ tabid }) => {
30
+ const _signals = values.signals.filter((_signal, i) => i !== Number(tabid));
31
+ setFieldValue('signals', _signals);
32
+ }, [setFieldValue, values.signals]);
33
+ useEffect(() => {
34
+ setFieldValue('signalIndex', values.signals.length > 0 ? (values.signals.length - 1).toString() : '-1');
35
+ }, [setFieldValue, values.signals.length]);
36
+ const tabContainsErrors = useCallback((i) => {
37
+ return !!errors?.signals?.[i];
38
+ }, [errors]);
39
+ const signalFormTabs = useMemo(() => {
40
+ const signalTabs = values.signals.length > 0
41
+ ? values.signals.map((signal, i) => (_jsx(Tab
42
+ // eslint-disable-next-line react/no-array-index-key
43
+ , { tabid: `${i}`, tabstyles: tabContainsErrors(i) ? tabStylesAddition : tabStyles, canDelete: true, render: () => _jsx(DeltaInput, { signal: signal, index: i }), children: _jsx(SignalTab, { index: i }) }, `signalForm${i}`)))
44
+ : [];
45
+ const addSignalTab = (_jsx(Tab, { tabid: "-1", canDelete: false, tabstyles: newTabStyles, render: () => (_jsxs("div", { style: {
46
+ display: 'flex',
47
+ alignItems: 'center',
48
+ padding: '0 1.5rem',
49
+ fontSize: '12px',
50
+ color: '#28ba62',
51
+ textWrap: 'nowrap',
52
+ }, children: [_jsx(FaPlus, { style: { display: 'inline-block' } }), _jsx("span", { style: { display: 'inline-block' }, children: "New Signal" })] })), children: _jsx(NewSignalTab, { range: range }) }, "addSignalTab"));
53
+ return [...signalTabs, addSignalTab];
54
+ }, [range, tabContainsErrors, values.signals]);
55
+ return (_jsxs("div", { children: [_jsx(InfoBlock, {}), _jsx(Tabs, { activeTab: values.signalIndex, onClick: tapClickHandler, onDelete: handleDeleteSignal, children: signalFormTabs })] }));
56
+ }
57
+ export default memo(SignalsContent);
@@ -0,0 +1,5 @@
1
+ interface SignalJCouplingsTableProps {
2
+ index: number;
3
+ }
4
+ export declare function SignalJCouplingsTable(props: SignalJCouplingsTableProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
@@ -0,0 +1,133 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useFormikContext } from 'formik';
3
+ import { translateMultiplet } from 'nmr-processing';
4
+ import { useCallback, useMemo, useState } from 'react';
5
+ import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
6
+ import { Toolbar } from 'react-science/ui';
7
+ import { Multiplets } from '../../../../../../data/constants/Multiplets';
8
+ import { isSpectrum1D } from '../../../../../../data/data1d/Spectrum1D';
9
+ import { useChartData } from '../../../../../context/ChartContext';
10
+ import Button from '../../../../../elements/Button';
11
+ import ReactTable from '../../../../../elements/ReactTable/ReactTable';
12
+ import FormikInput from '../../../../../elements/formik/FormikInput';
13
+ import FormikSelect from '../../../../../elements/formik/FormikSelect';
14
+ import { usePanelPreferences } from '../../../../../hooks/usePanelPreferences';
15
+ import useSpectrum from '../../../../../hooks/useSpectrum';
16
+ import { hasCouplingConstant } from '../../../../../panels/extra/utilities/MultiplicityUtilities';
17
+ import { useEvent } from '../../../../../utility/Events';
18
+ import { formatNumber } from '../../../../../utility/formatNumber';
19
+ const styles = {
20
+ input: {
21
+ width: '100%',
22
+ padding: '0.25rem 0.5rem',
23
+ },
24
+ select: {
25
+ height: '26px',
26
+ width: '100%',
27
+ },
28
+ column: {
29
+ padding: '2px',
30
+ },
31
+ };
32
+ function getJCouplingKey(signalIndex, jIndex, jCouplingKey) {
33
+ return `signals[${signalIndex}].js.${jIndex}.${jCouplingKey}`;
34
+ }
35
+ export function SignalJCouplingsTable(props) {
36
+ const { values, setFieldValue } = useFormikContext();
37
+ const signal = values?.signals?.[values?.signalIndex] || {};
38
+ const jCouplings = signal?.js || [];
39
+ const [lastSelectedCouplingIndex, setLastSelectedCouplingIndex] = useState(null);
40
+ const spectrum = useSpectrum();
41
+ const { view: { spectra: { activeTab }, }, } = useChartData();
42
+ const rangesPreferences = usePanelPreferences('ranges', activeTab);
43
+ useEvent({
44
+ onClick: (options) => {
45
+ if (`${props.index}` === values.signalIndex &&
46
+ typeof lastSelectedCouplingIndex === 'number') {
47
+ const x = formatNumber(options.xPPM, rangesPreferences.deltaHz.format);
48
+ void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), x);
49
+ }
50
+ },
51
+ onBrushEnd: (options) => {
52
+ const { range: [from, to], } = options;
53
+ if (`${props.index}` === values.signalIndex &&
54
+ typeof lastSelectedCouplingIndex === 'number' &&
55
+ isSpectrum1D(spectrum)) {
56
+ const value = Number(formatNumber(Math.abs(to - from) * spectrum.info.originFrequency, rangesPreferences.deltaHz.format));
57
+ void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), value);
58
+ }
59
+ },
60
+ });
61
+ const addHandler = useCallback((data) => {
62
+ const coupling = {
63
+ multiplicity: translateMultiplet('m'),
64
+ coupling: '',
65
+ };
66
+ void setFieldValue(`signals[${values?.signalIndex}].js`, [
67
+ ...data,
68
+ coupling,
69
+ ]);
70
+ setLastSelectedCouplingIndex(data.length);
71
+ }, [setFieldValue, values?.signalIndex]);
72
+ const deleteHandler = useCallback((data, index) => {
73
+ const jCouplings = data.filter((_, columnIndex) => columnIndex !== index);
74
+ void setFieldValue(`signals[${values?.signalIndex}].js`, jCouplings);
75
+ if (lastSelectedCouplingIndex === index) {
76
+ setLastSelectedCouplingIndex(null);
77
+ }
78
+ }, [lastSelectedCouplingIndex, setFieldValue, values?.signalIndex]);
79
+ function deleteAllHandler() {
80
+ void setFieldValue(`signals[${values?.signalIndex}].js`, []);
81
+ setLastSelectedCouplingIndex(null);
82
+ }
83
+ const multiplicityChangeHandler = useCallback((value, name) => {
84
+ if (!hasCouplingConstant(value)) {
85
+ void setFieldValue(name, '');
86
+ }
87
+ }, [setFieldValue]);
88
+ const COLUMNS = useMemo(() => [
89
+ {
90
+ Header: '#',
91
+ style: { width: '25px', ...styles.column },
92
+ accessor: (_, index) => index + 1,
93
+ },
94
+ {
95
+ Header: 'Multiplicity',
96
+ style: { padding: 0, ...styles.column },
97
+ Cell: ({ row }) => {
98
+ return (_jsx(FormikSelect, { className: "select-box", name: getJCouplingKey(values.signalIndex, row.index, 'multiplicity'), items: Multiplets, itemValueField: "label", onChange: (value) => {
99
+ multiplicityChangeHandler(value, getJCouplingKey(values.signalIndex, row.index, 'coupling'));
100
+ }, style: styles.select, onClick: (e) => e.stopPropagation() }));
101
+ },
102
+ },
103
+ {
104
+ Header: 'J (Hz)',
105
+ style: { padding: 0, ...styles.column },
106
+ Cell: ({ row }) => {
107
+ return (_jsx(FormikInput, { name: getJCouplingKey(values.signalIndex, row.index, 'coupling'), type: "number", placeholder: 'J (Hz)', style: { input: styles.input }, disabled: !hasCouplingConstant(row.original?.multiplicity), onClick: (e) => e.stopPropagation() }));
108
+ },
109
+ },
110
+ {
111
+ Header: '',
112
+ style: { width: '70px', ...styles.column },
113
+ id: 'action-button',
114
+ Cell: ({ data, row }) => {
115
+ const record = row.original;
116
+ return (_jsx("div", { style: { display: 'flex', justifyContent: 'space-around' }, children: !record?.name && (_jsx(Button.Danger, { fill: "outline", onClick: (e) => {
117
+ e.stopPropagation();
118
+ deleteHandler(data, row.index);
119
+ }, children: _jsx(FaRegTrashAlt, {}) })) }));
120
+ },
121
+ },
122
+ ], [deleteHandler, multiplicityChangeHandler, values.signalIndex]);
123
+ function selectRowHandler(index) {
124
+ setLastSelectedCouplingIndex((prevIndex) => prevIndex === index ? null : index);
125
+ }
126
+ function handleActiveRow(row) {
127
+ return row?.index === lastSelectedCouplingIndex;
128
+ }
129
+ return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("div", { style: { padding: '5px 0', display: 'flex' }, children: _jsxs(Toolbar, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaPlus, {}), title: "Add a new J coupling", intent: "success", onClick: () => addHandler(jCouplings) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), title: "Delete all J couplings", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
130
+ maxHeight: '300px',
131
+ overflow: 'auto',
132
+ }, children: _jsx(ReactTable, { data: jCouplings, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No J Couplings" }) })] }));
133
+ }
@@ -0,0 +1,5 @@
1
+ interface SignalPeaksTableProps {
2
+ index: number;
3
+ }
4
+ export declare function SignalPeaksTable(props: SignalPeaksTableProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};