nmrium 0.53.0 → 0.55.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 (178) hide show
  1. package/lib/component/1d/Viewer1D.js +48 -17
  2. package/lib/component/1d/XAxis.js +1 -1
  3. package/lib/component/1d/integral/IntegralsSeries.js +2 -2
  4. package/lib/component/1d/integral/Integration.d.ts +3 -1
  5. package/lib/component/1d/integral/Integration.js +3 -2
  6. package/lib/component/1d/peaks/PeakEditionManager.js +5 -3
  7. package/lib/component/1d/ranges/AssignmentActionsButtons.d.ts +1 -0
  8. package/lib/component/1d/ranges/AssignmentActionsButtons.js +3 -3
  9. package/lib/component/1d/ranges/AssignmentLabel.d.ts +1 -1
  10. package/lib/component/1d/ranges/AssignmentLabel.js +31 -4
  11. package/lib/component/1d/ranges/Atoms.js +4 -5
  12. package/lib/component/1d/ranges/Range.js +62 -12
  13. package/lib/component/1d/ranges/Ranges.js +2 -1
  14. package/lib/component/1d/ranges/RangesIntegrals.js +11 -4
  15. package/lib/component/1d/tool/XLabelPointer.js +4 -12
  16. package/lib/component/1d-2d/FieldEdition.d.ts +13 -0
  17. package/lib/component/1d-2d/FieldEdition.js +42 -0
  18. package/lib/component/2d/Chart2D.js +5 -3
  19. package/lib/component/2d/tools/XYLabelPointer.js +3 -9
  20. package/lib/component/2d/zones/Zone.js +18 -2
  21. package/lib/component/2d/zones/ZonesAssignmentsLabels.d.ts +7 -0
  22. package/lib/component/2d/zones/ZonesAssignmentsLabels.js +286 -0
  23. package/lib/component/EventsTrackers/KeysListenerTracker.js +14 -1
  24. package/lib/component/context/LoggerContext.js +11 -4
  25. package/lib/component/context/ShareDataContext.d.ts +10 -0
  26. package/lib/component/context/ShareDataContext.js +22 -0
  27. package/lib/component/elements/ActionsButtonsPopover.d.ts +10 -0
  28. package/lib/component/elements/ActionsButtonsPopover.js +22 -0
  29. package/lib/component/elements/CloseButton.d.ts +1 -1
  30. package/lib/component/elements/CustomToolTip.d.ts +8 -0
  31. package/lib/component/elements/CustomToolTip.js +107 -0
  32. package/lib/component/elements/EditableColumn.js +3 -2
  33. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +7 -5
  34. package/lib/component/elements/ReactTable/ReactTable.d.ts +2 -2
  35. package/lib/component/elements/SVGButton.d.ts +14 -0
  36. package/lib/component/elements/SVGButton.js +6 -0
  37. package/lib/component/elements/SVGGroup.js +15 -13
  38. package/lib/component/elements/SVGText.d.ts +8 -0
  39. package/lib/component/elements/SVGText.js +24 -0
  40. package/lib/component/elements/SaveButton.d.ts +1 -1
  41. package/lib/component/elements/draggable/SVGDraggable.d.ts +2 -2
  42. package/lib/component/elements/formik/FormikError.js +2 -4
  43. package/lib/component/elements/formik/FormikInput.d.ts +2 -1
  44. package/lib/component/elements/formik/FormikInput.js +5 -4
  45. package/lib/component/header/Header.js +8 -11
  46. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
  47. package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
  48. package/lib/component/hooks/useCheckPointsNumberInWindowArea.d.ts +1 -1
  49. package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
  50. package/lib/component/hooks/useFormatNumberByNucleus.js +8 -7
  51. package/lib/component/hooks/useIntegralPath.d.ts +2 -0
  52. package/lib/component/hooks/useIntegralPath.js +3 -1
  53. package/lib/component/hooks/usePanelPreferences.js +1 -2
  54. package/lib/component/hooks/useSaveSettings.js +7 -14
  55. package/lib/component/hooks/useTriggerNewAssignmentLabel.d.ts +4 -0
  56. package/lib/component/hooks/useTriggerNewAssignmentLabel.js +8 -0
  57. package/lib/component/hooks/useWorkspaceAction.d.ts +7 -0
  58. package/lib/component/hooks/useWorkspaceAction.js +89 -0
  59. package/lib/component/loader/DropZone.js +0 -3
  60. package/lib/component/main/InnerNMRium.js +3 -1
  61. package/lib/component/main/InnerNMRiumContents.js +14 -2
  62. package/lib/component/main/NMRiumStateProvider.js +15 -3
  63. package/lib/component/modal/AboutPredictionModal.js +1 -1
  64. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  65. package/lib/component/modal/CopyClipboardModal.js +1 -1
  66. package/lib/component/modal/EditPeakShapeModal.js +1 -1
  67. package/lib/component/modal/ImportPublicationStringModal.js +11 -5
  68. package/lib/component/modal/PredictSpectraModal.js +1 -1
  69. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
  70. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  71. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  72. package/lib/component/modal/editRange/forms/components/DeltaInput.js +3 -3
  73. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +17 -12
  74. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +30 -13
  75. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +26 -16
  76. package/lib/component/modal/editZone/EditZoneModal.js +1 -1
  77. package/lib/component/modal/setting/GeneralSettings.js +18 -39
  78. package/lib/component/modal/setting/WorkspaceItem.js +1 -1
  79. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.d.ts +2 -0
  80. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +99 -0
  81. package/lib/component/modal/setting/settingsValidation.js +36 -40
  82. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
  83. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
  84. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
  85. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  86. package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
  87. package/lib/component/panels/RangesPanel/RangesHeader.js +11 -11
  88. package/lib/component/panels/RangesPanel/RangesPreferences.js +16 -16
  89. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  90. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
  91. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
  92. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +13 -1
  93. package/lib/component/panels/SpectraPanel/base/setting/PlotChart.js +1 -1
  94. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.js +1 -1
  95. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  96. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
  97. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
  98. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
  99. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
  100. package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
  101. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.d.ts +6 -0
  102. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentLabelColumn.js +16 -0
  103. package/lib/component/panels/ZonesPanel/ZonesPanel.js +22 -6
  104. package/lib/component/panels/ZonesPanel/ZonesPreferences.js +15 -9
  105. package/lib/component/panels/ZonesPanel/ZonesTable.js +2 -2
  106. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +3 -2
  107. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
  108. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  109. package/lib/component/panels/header/PreferencesHeader.js +1 -1
  110. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
  111. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
  112. package/lib/component/panels/multipleAnalysisPanel/preferences/index.js +1 -1
  113. package/lib/component/reducer/IgnoreActions.js +1 -0
  114. package/lib/component/reducer/Reducer.js +8 -0
  115. package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
  116. package/lib/component/reducer/actions/DomainActions.js +29 -1
  117. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
  118. package/lib/component/reducer/actions/FiltersActions.js +27 -1
  119. package/lib/component/reducer/actions/MoleculeActions.js +1 -1
  120. package/lib/component/reducer/actions/RangesActions.d.ts +2 -3
  121. package/lib/component/reducer/actions/RangesActions.js +28 -26
  122. package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
  123. package/lib/component/reducer/actions/SpectraActions.js +5 -1
  124. package/lib/component/reducer/actions/ZonesActions.d.ts +15 -2
  125. package/lib/component/reducer/actions/ZonesActions.js +47 -13
  126. package/lib/component/reducer/helper/setRangesViewProperty.d.ts +1 -0
  127. package/lib/component/reducer/helper/setRangesViewProperty.js +11 -11
  128. package/lib/component/reducer/preferences/actions/addWorkspace.js +4 -23
  129. package/lib/component/reducer/preferences/actions/analyzeSpectra.js +4 -4
  130. package/lib/component/reducer/preferences/actions/initPreferences.js +2 -4
  131. package/lib/component/reducer/preferences/actions/matrixGeneration.js +3 -3
  132. package/lib/component/reducer/preferences/actions/removeWorkspace.js +0 -5
  133. package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +0 -4
  134. package/lib/component/reducer/preferences/actions/setPanelsPreferences.js +1 -1
  135. package/lib/component/reducer/preferences/actions/setPreferences.js +2 -16
  136. package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
  137. package/lib/component/reducer/preferences/preferencesReducer.d.ts +7 -0
  138. package/lib/component/reducer/preferences/preferencesReducer.js +21 -18
  139. package/lib/component/toolbar/ToolBar.js +115 -25
  140. package/lib/component/utility/PreferencesHelper.js +5 -4
  141. package/lib/component/utility/export.js +4 -0
  142. package/lib/component/workspaces/assignment.js +0 -1
  143. package/lib/component/workspaces/basic.js +0 -1
  144. package/lib/component/workspaces/embedded.js +0 -1
  145. package/lib/component/workspaces/exercise.js +26 -29
  146. package/lib/component/workspaces/prediction.js +171 -174
  147. package/lib/component/workspaces/process1D.js +0 -1
  148. package/lib/component/workspaces/simulation.js +35 -38
  149. package/lib/component/workspaces/workspaceDefaultProperties.js +16 -23
  150. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
  151. package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
  152. package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
  153. package/lib/data/data1d/Spectrum1D/index.js +2 -2
  154. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
  155. package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
  156. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
  157. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
  158. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
  159. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
  160. package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
  161. package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
  162. package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
  163. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
  164. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
  165. package/lib/data/utilities/generateColor.d.ts +7 -3
  166. package/lib/data/utilities/generateColor.js +5 -17
  167. package/lib/versionInfo.js +1 -1
  168. package/package.json +35 -35
  169. package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
  170. package/lib/component/elements/MolecularFormulaInput.js +0 -63
  171. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.d.ts +0 -2
  172. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +0 -80
  173. package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.d.ts +0 -2
  174. package/lib/component/reducer/preferences/utilities/mapNucleiFormatting.js +0 -10
  175. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
  176. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
  177. package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
  178. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
@@ -41,10 +41,7 @@ const style = css `
41
41
  }
42
42
  `;
43
43
  const containerStyle = css `
44
- border: 0.55px #e6e6e6 solid;
45
44
  display: flex;
46
- flex: 1;
47
- flex-direction: 'column';
48
45
  height: 100%;
49
46
  `;
50
47
  function DropZone(props) {
@@ -11,7 +11,7 @@ import { TopicMoleculeProvider } from '../context/TopicMoleculeContext';
11
11
  import { ModalProvider } from '../elements/popup/Modal';
12
12
  import { HighlightProvider } from '../highlight';
13
13
  import { defaultGetSpinner, SpinnerProvider } from '../loader/SpinnerContext';
14
- import preferencesReducer, { preferencesInitialState, initPreferencesState, } from '../reducer/preferences/preferencesReducer';
14
+ import preferencesReducer, { preferencesInitialState, initPreferencesState, readSettings, } from '../reducer/preferences/preferencesReducer';
15
15
  import { getBlob } from '../utility/export';
16
16
  import { InnerNMRiumContents } from './InnerNMRiumContents';
17
17
  import NMRiumStateProvider from './NMRiumStateProvider';
@@ -26,12 +26,14 @@ export function InnerNMRium({ data: nmriumData, workspace, customWorkspaces, pre
26
26
  rootRef.current?.focus();
27
27
  }, [isFullScreen]);
28
28
  useEffect(() => {
29
+ const settings = readSettings();
29
30
  dispatchPreferences({
30
31
  type: 'INIT_PREFERENCES',
31
32
  payload: {
32
33
  preferences,
33
34
  workspace,
34
35
  customWorkspaces,
36
+ currentWorkspace: settings?.currentWorkspace,
35
37
  dispatch: dispatchPreferences,
36
38
  },
37
39
  });
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
- import { css } from '@emotion/react';
3
+ import { Global, css } from '@emotion/react';
4
4
  import { useCallback } from 'react';
5
5
  import { useFullscreen } from 'react-science/ui';
6
6
  import checkModifierKeyActivated from '../../data/utilities/checkModifierKeyActivated';
@@ -55,6 +55,12 @@ const containerStyles = css `
55
55
  -o-user-drag: none;
56
56
  user-select: none;
57
57
  }
58
+
59
+ .actions-buttons-popover {
60
+ background: transparent;
61
+ padding: 5px;
62
+ box-shadow: none;
63
+ }
58
64
  `;
59
65
  export function InnerNMRiumContents(props) {
60
66
  const { emptyText, mainDivRef, elementsWrapperRef, rootRef, viewerRef } = props;
@@ -65,7 +71,13 @@ export function InnerNMRiumContents(props) {
65
71
  e.preventDefault();
66
72
  }
67
73
  }, []);
68
- return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
74
+ return (_jsxs(_Fragment, { children: [_jsx(StateError, {}), _jsx(Global, { styles: css `
75
+ .actions-buttons-popover {
76
+ border-radius: 10px;
77
+ padding: 5px;
78
+ background-color: white;
79
+ }
80
+ ` }), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
69
81
  display: 'flex',
70
82
  flexDirection: 'column',
71
83
  backgroundColor: 'white',
@@ -15,6 +15,7 @@ export default function NMRiumStateProvider(props) {
15
15
  const { children, onChange, nmriumData = defaultData } = props;
16
16
  const { logger } = useLogger();
17
17
  const preferencesState = usePreferences();
18
+ const { dispatch: dispatchPreferences } = preferencesState;
18
19
  const [state, dispatchRaw] = useReducer(spectrumReducer, initialState, initState);
19
20
  const dispatch = useCallback((action) => {
20
21
  logger.trace({ action }, `Dispatch main reducer action: ${action.type}`);
@@ -60,15 +61,26 @@ export default function NMRiumStateProvider(props) {
60
61
  if (nmriumData) {
61
62
  void readNMRiumObject(nmriumData)
62
63
  .then((nmriumState) => {
64
+ if (nmriumState?.settings) {
65
+ dispatchPreferences({
66
+ type: 'SET_WORKSPACE',
67
+ payload: {
68
+ data: nmriumState.settings,
69
+ workspaceSource: 'nmriumFile',
70
+ },
71
+ });
72
+ }
63
73
  dispatch({ type: 'INITIATE', payload: { nmriumState } });
64
74
  })
65
75
  .catch((error) => {
66
76
  dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
67
- // eslint-disable-next-line no-alert
68
- window.alert(error.message);
77
+ if (error instanceof Error) {
78
+ // eslint-disable-next-line no-alert
79
+ window.alert(error.message);
80
+ }
69
81
  reportError(error);
70
82
  });
71
83
  }
72
- }, [nmriumData, dispatch]);
84
+ }, [nmriumData, dispatch, dispatchPreferences]);
73
85
  return (_jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: children }) }));
74
86
  }
@@ -40,6 +40,6 @@ const styles = css `
40
40
  `;
41
41
  function AboutPredictionModal() {
42
42
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
43
- return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaInfo, {}), onClick: openDialog, title: "About prediction" }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, title: "About prediction", style: { width: '600px' }, children: _jsxs(DialogBody, { css: styles, children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Damiano Banfi and Luc Patiny", ' ', _jsx("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', _jsx("i", { children: "Chimia" }), ", ", _jsx("b", { children: "2008" }), ", 62(4), 280-281."] }), _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "1" }), "H NMR prediction is possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:"] }), _jsxs("ul", { children: [_jsxs("li", { children: ["Yuri Binev, Maria M. B. Marques and Jo\u00E3o Aires-de-Sousa", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR coupling constants with associative neural networks trained for chemical shifts"] }), ' ', _jsx("i", { children: "J. Chem. Inf. Model." }), " ", _jsx("b", { children: "2007" }), ", 47(6), 2089-2097."] }), _jsxs("li", { children: ["Jo\u00E3o Aires-de-Sousa, Markus C. Hemmer and Johann Gasteiger", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR Chemical Shifts Using Neural Networks"] }), ", ", _jsx("i", { children: "Analytical Chemistry" }), ", ", _jsx("b", { children: "2002" }), ", 74(1), 80-90."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "13" }), "C NMR prediction was possible thanks to NMRshiftDB:"] }), _jsx("ul", { children: _jsxs("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components" }), ' ', _jsx("i", { children: "Journal of chemical information and computer sciences" }), ",", ' ', _jsx("b", { children: "2003" }), ", 43(6): 1733-1739."] }) })] }) })] }));
43
+ return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { icon: _jsx(FaInfo, {}), onClick: openDialog, tooltip: "About prediction" }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, title: "About prediction", style: { width: '600px' }, children: _jsxs(DialogBody, { css: styles, children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsxs("ul", { children: [_jsxs("li", { children: ["Damiano Banfi and Luc Patiny", ' ', _jsx("a", { href: "http://dx.doi.org/10.2533/chimia.2008.280", target: "_blank", rel: "noreferrer", children: "www.nmrdb.org: Resurrecting and processing NMR spectra on-line" }), ' ', _jsx("i", { children: "Chimia" }), ", ", _jsx("b", { children: "2008" }), ", 62(4), 280-281."] }), _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "1" }), "H NMR prediction is possible thanks to the tool of the FCT-Universidade NOVA de Lisboa developed by Yuri Binev and Joao Aires-de-Sousa:"] }), _jsxs("ul", { children: [_jsxs("li", { children: ["Yuri Binev, Maria M. B. Marques and Jo\u00E3o Aires-de-Sousa", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ci700172n", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR coupling constants with associative neural networks trained for chemical shifts"] }), ' ', _jsx("i", { children: "J. Chem. Inf. Model." }), " ", _jsx("b", { children: "2007" }), ", 47(6), 2089-2097."] }), _jsxs("li", { children: ["Jo\u00E3o Aires-de-Sousa, Markus C. Hemmer and Johann Gasteiger", ' ', _jsxs("a", { href: "http://dx.doi.org/10.1021/ac010737m", target: "_blank", rel: "noreferrer", children: ["Prediction of ", _jsx("sup", { children: "1" }), "H NMR Chemical Shifts Using Neural Networks"] }), ", ", _jsx("i", { children: "Analytical Chemistry" }), ", ", _jsx("b", { children: "2002" }), ", 74(1), 80-90."] })] }), _jsxs("p", { children: [_jsx("sup", { children: "13" }), "C NMR prediction was possible thanks to NMRshiftDB:"] }), _jsx("ul", { children: _jsxs("li", { children: ["Steinbeck, Christoph, Stefan Krause, and Stefan Kuhn", ' ', _jsx("a", { href: "http://dx.doi.org/10.1021/ci0341363", target: "_blank", rel: "noreferrer", children: "NMRShiftDB Constructing a Free Chemical Information System with Open-Source Components" }), ' ', _jsx("i", { children: "Journal of chemical information and computer sciences" }), ",", ' ', _jsx("b", { children: "2003" }), ", 43(6): 1733-1739."] }) })] }) })] }));
44
44
  }
45
45
  export default AboutPredictionModal;
@@ -40,6 +40,6 @@ const styles = css `
40
40
  `;
41
41
  function AboutSpectrumSimulationModal() {
42
42
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
43
- return (_jsxs(_Fragment, { children: [_jsx(Toolbar, { children: _jsx(Toolbar.Item, { onClick: openDialog, title: "About prediction", icon: _jsx(FaInfo, {}) }) }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, title: "About spectrum simulation", style: { width: '600px' }, children: _jsxs(DialogBody, { css: styles, children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsx("ul", { children: _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] }) })] }) })] }));
43
+ return (_jsxs(_Fragment, { children: [_jsx(Toolbar, { children: _jsx(Toolbar.Item, { onClick: openDialog, tooltip: "About prediction", icon: _jsx(FaInfo, {}) }) }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, title: "About spectrum simulation", style: { width: '600px' }, children: _jsxs(DialogBody, { css: styles, children: [_jsx("p", { children: "If you are using our tools please cite us:" }), _jsx("ul", { children: _jsxs("li", { children: ["Andr\u00E9s M. Castillo, Luc Patiny and Julien Wist", ' ', _jsx("a", { href: "http://dx.doi.org/10.1016/j.jmr.2010.12.008", target: "_blank", rel: "noreferrer", children: "Fast and Accurate Algorithm for the Simulation of NMR spectra of Large Spin Systems" }), ' ', _jsx("i", { children: "Journal of Magnetic Resonance" }), " ", _jsx("b", { children: "2011" }), ", 209(2), 123-130."] }) })] }) })] }));
44
44
  }
45
45
  export default AboutSpectrumSimulationModal;
@@ -32,7 +32,7 @@ const styles = css `
32
32
  }
33
33
  `;
34
34
  function CopyClipboardModal({ text, onClose, onCopyClick, }) {
35
- return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "main-buttons-container handle", children: [_jsx("button", { type: "button", onClick: () => onCopyClick(text), children: _jsx(FaCopy, {}) }), _jsx(CloseButton, { title: "Close", onClick: onClose })] }), _jsx("div", { className: "inner-container",
35
+ return (_jsxs("div", { css: styles, children: [_jsxs("div", { className: "main-buttons-container handle", children: [_jsx("button", { type: "button", onClick: () => onCopyClick(text), children: _jsx(FaCopy, {}) }), _jsx(CloseButton, { tooltip: "Close", onClick: onClose })] }), _jsx("div", { className: "inner-container",
36
36
  // eslint-disable-next-line react/no-danger
37
37
  dangerouslySetInnerHTML: { __html: text } })] }));
38
38
  }
@@ -79,6 +79,6 @@ function EditPeakShapeModal({ onClose = () => null, peak, peaksPreferences, }) {
79
79
  }, [dispatch, onClose, peak.id]);
80
80
  const values = getValues(peak, kind);
81
81
  const valuePPM = formatNumber(peak.x, peaksPreferences.deltaPPM.format);
82
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsxs("span", { children: [`Peak Shape Edition ( ${valuePPM} PPM)`, " "] }), _jsx(CloseButton, { title: "Close", onClick: () => onClose?.(), className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsx(Formik, { enableReinitialize: true, innerRef: refForm, initialValues: values, validationSchema: validation(kind), onSubmit: changePeakShapeHandler, children: _jsxs(_Fragment, { children: [_jsx(Label, { title: "Kind:", style: labelStyle, children: _jsx(Select, { items: KINDS, style: { margin: 0, height: 30 }, value: kind, onChange: (kind) => setKind(kind) }) }), _jsx(Label, { title: "FWHM:", style: labelStyle, children: _jsx(FormikInput, { name: "fwhm", style: inputStyle }) }), kind === 'pseudoVoigt' && (_jsx(Label, { title: "Mu:", style: labelStyle, children: _jsx(FormikInput, { name: "mu", style: inputStyle }) }))] }) }) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current.submitForm(), doneLabel: "Save", onCancel: () => onClose?.() }) })] }));
82
+ return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsxs("span", { children: [`Peak Shape Edition ( ${valuePPM} PPM)`, " "] }), _jsx(CloseButton, { tooltip: "Close", onClick: () => onClose?.(), className: "close-bt" })] }), _jsx("div", { className: "inner-content", children: _jsx(Formik, { enableReinitialize: true, innerRef: refForm, initialValues: values, validationSchema: validation(kind), onSubmit: changePeakShapeHandler, children: _jsxs(_Fragment, { children: [_jsx(Label, { title: "Kind:", style: labelStyle, children: _jsx(Select, { items: KINDS, style: { margin: 0, height: 30 }, value: kind, onChange: (kind) => setKind(kind) }) }), _jsx(Label, { title: "FWHM:", style: labelStyle, children: _jsx(FormikInput, { name: "fwhm", style: inputStyle }) }), kind === 'pseudoVoigt' && (_jsx(Label, { title: "Mu:", style: labelStyle, children: _jsx(FormikInput, { name: "mu", style: inputStyle }) }))] }) }) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: () => refForm.current.submitForm(), doneLabel: "Save", onCancel: () => onClose?.() }) })] }));
83
83
  }
84
84
  export default EditPeakShapeModal;
@@ -4,7 +4,7 @@ import { FifoLogger } from 'fifo-logger';
4
4
  import { Formik } from 'formik';
5
5
  import debounce from 'lodash/debounce';
6
6
  import { resurrect } from 'nmr-processing';
7
- import { useMemo, useRef, useState } from 'react';
7
+ import { useEffect, useMemo, useRef, useState } from 'react';
8
8
  import * as yup from 'yup';
9
9
  import { useDispatch } from '../context/DispatchContext';
10
10
  import { useToaster } from '../context/ToasterContext';
@@ -41,11 +41,17 @@ function InnerImportPublicationStringModal(props) {
41
41
  const dispatch = useDispatch();
42
42
  const toaster = useToaster();
43
43
  const [logs, setLogs] = useState([]);
44
- const loggerRef = useRef(new FifoLogger({
45
- onChange: (log, logs) => {
44
+ const loggerRef = useRef(new FifoLogger());
45
+ useEffect(() => {
46
+ function handleLogs({ detail: { logs } }) {
46
47
  setLogs(logs.slice());
47
- },
48
- }));
48
+ }
49
+ const loggerInstance = loggerRef.current;
50
+ loggerInstance.addEventListener('change', handleLogs);
51
+ return () => {
52
+ loggerInstance.removeEventListener('change', handleLogs);
53
+ };
54
+ }, []);
49
55
  const COLUMNS = useMemo(() => [
50
56
  {
51
57
  Header: '#',
@@ -107,7 +107,7 @@ export function PredictSpectraModal({ onClose = () => null, molecule, }) {
107
107
  dispatch,
108
108
  logger,
109
109
  ]);
110
- return (_jsxs(_Fragment, { children: [_jsx(Toolbar, { children: _jsx(Toolbar.Item, { icon: _jsx(SvgNmrFt, {}), title: "Predict spectra", onClick: openDialog }) }), _jsxs(Dialog, { isOpen: isOpenDialog, onClose: () => {
110
+ return (_jsxs(_Fragment, { children: [_jsx(Toolbar, { children: _jsx(Toolbar.Item, { icon: _jsx(SvgNmrFt, {}), tooltip: "Predict spectra", onClick: openDialog }) }), _jsxs(Dialog, { isOpen: isOpenDialog, onClose: () => {
111
111
  onClose();
112
112
  closeDialog();
113
113
  }, style: { width: 600, maxWidth: 1000 }, title: "Prediction of NMR spectrum", children: [_jsxs(DialogBody, { css: styles, children: [_jsx(PredictionPreferences, { onSubmit: submitHandler, options: initValues, ref: refForm }), _jsx("p", { className: "warning", children: "In order to predict spectra we are calling an external service and the chemical structure will leave your browser! You should never predict spectra for confidential molecules." }), _jsx("div", { className: "warning-container", children: _jsx(Checkbox, { onChange: (value) => setApproved(value.target.checked), checked: isApproved, label: "I confirm that the chemical structure is not confidential." }) })] }), _jsx(DialogFooter, { className: "footer-container", children: _jsx(Button.Done, { onClick: handleSave, disabled: !isApproved, children: "Predict spectrum" }) })] })] }));
@@ -70,7 +70,7 @@ const styles = css `
70
70
  `;
71
71
  function AboutUsModal() {
72
72
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
73
- return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { onClick: openDialog, id: "logo", title: "About NMRium", icon: _jsx(SvgLogoNmrium, {}) }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, style: {
73
+ return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { onClick: openDialog, id: "logo", tooltip: "About NMRium", icon: _jsx(SvgLogoNmrium, {}) }), _jsx(Dialog, { isOpen: isOpenDialog, onClose: closeDialog, style: {
74
74
  maxWidth: 1000,
75
75
  width: '40vw',
76
76
  minWidth: '500px',
@@ -6,7 +6,7 @@ import { ChangeSumModalContents, } from './ChangeSumModalContents';
6
6
  export default function ChangeSumModal(props) {
7
7
  const { disabled = false, currentSum, sumType, ...otherProps } = props;
8
8
  const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
9
- return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { disabled: disabled, icon: _jsx(SvgNmrSum, {}), title: currentSum
9
+ return (_jsxs(_Fragment, { children: [_jsx(Toolbar.Item, { disabled: disabled, icon: _jsx(SvgNmrSum, {}), tooltip: currentSum
10
10
  ? `Change ${sumType} sum (${currentSum.toFixed(2)})`
11
11
  : `Change ${sumType} sum`, onClick: openDialog }), isOpenDialog && (_jsx(Dialog, { isOpen: true, onClose: closeDialog, style: { width: 500, height: 400 }, title: currentSum
12
12
  ? `Set new ${sumType} sum (Current: ${currentSum.toFixed(2)})`
@@ -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(SignalsContent, { range: range }), _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(), tooltip: "Save and Exit" }), _jsx(CloseButton, { tooltip: "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({
@@ -3,8 +3,8 @@ import { translateMultiplet } from 'nmr-processing';
3
3
  import FormikInput from '../../../../elements/formik/FormikInput';
4
4
  const style = {
5
5
  input: {
6
- width: '50px',
7
- height: '26px',
6
+ width: '60px',
7
+ height: '30px',
8
8
  },
9
9
  inputWrapper: {
10
10
  borderWidth: 0,
@@ -12,7 +12,7 @@ const style = {
12
12
  },
13
13
  };
14
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
15
+ return (_jsxs("div", { style: { display: 'flex', alignItems: 'center' }, children: [_jsx("span", { children: "\uD835\uDEC5: " }), _jsx(FormikInput, { name: `signals.${index}.delta`, type: "number", placeholder: 'Delta (PPM)', style: style, checkErrorAfterInputTouched: false }), _jsx("span", { children: signal.js
16
16
  .map((_coupling) => translateMultiplet(_coupling.multiplicity))
17
17
  .join('') })] }));
18
18
  }
@@ -1,7 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Formik, useFormikContext } from 'formik';
3
3
  import { translateMultiplet } from 'nmr-processing';
4
- import { useRef } from 'react';
4
+ import { useEffect, useRef, useState } from 'react';
5
5
  import * as Yup from 'yup';
6
6
  import { useChartData } from '../../../../context/ChartContext';
7
7
  import Button from '../../../../elements/Button';
@@ -27,7 +27,9 @@ const styles = {
27
27
  export function NewSignalTab(props) {
28
28
  const { range } = props;
29
29
  const { values, setFieldValue } = useFormikContext();
30
+ const [signalValue, setSignalValue] = useState((range.from + range.to) / 2);
30
31
  const newSignalFormRef = useRef();
32
+ const inputRef = useRef(null);
31
33
  const { view: { spectra: { activeTab }, }, } = useChartData();
32
34
  const rangesPreferences = usePanelPreferences('ranges', activeTab);
33
35
  function saveHandler(val) {
@@ -42,28 +44,31 @@ export function NewSignalTab(props) {
42
44
  void setFieldValue('signalIndex', String(_signals.length - 1));
43
45
  }
44
46
  useEvent({
45
- onClick: (options) => {
46
- if (values.signalIndex === '-1') {
47
- newSignalFormRef.current.setValues({ newSignalDelta: options.xPPM });
47
+ onClick: ({ xPPM, shiftKey }) => {
48
+ if (values.signalIndex === '-1' && shiftKey) {
49
+ setSignalValue(xPPM);
48
50
  }
49
51
  },
50
52
  onBrushEnd: (options) => {
51
- const { range: [from, to], } = options;
52
- if (values.signalIndex === '-1') {
53
- newSignalFormRef.current.setValues({
54
- newSignalDelta: (to - from) / 2 + from,
55
- });
53
+ const { range: [from, to], shiftKey, } = options;
54
+ if (values.signalIndex === '-1' && shiftKey) {
55
+ setSignalValue((to - from) / 2 + from);
56
56
  }
57
57
  },
58
58
  });
59
+ useEffect(() => {
60
+ setTimeout(() => {
61
+ inputRef.current?.select();
62
+ }, 50);
63
+ }, [signalValue]);
59
64
  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: {
65
+ newSignalDelta: signalValue,
66
+ }, enableReinitialize: true, 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, { ref: inputRef, name: "newSignalDelta", type: "number", placeholder: `𝛅(ppm)`, style: {
62
67
  input: {
63
68
  height: '30px',
64
69
  padding: '0.25rem 0.5rem',
65
70
  },
66
- }, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
71
+ }, autoSelect: true, checkErrorAfterInputTouched: false }), _jsx(Button.Done, { style: {
67
72
  marginTop: '20px',
68
73
  height: '30px',
69
74
  }, onClick: () => newSignalFormRef.current.submitForm(), children: "Add a signal" })] }) }) }));
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useFormikContext } from 'formik';
3
3
  import { translateMultiplet } from 'nmr-processing';
4
- import { useCallback, useMemo, useState } from 'react';
4
+ import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
5
5
  import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
6
6
  import { Toolbar } from 'react-science/ui';
7
7
  import { Multiplets } from '../../../../../../data/constants/Multiplets';
@@ -35,23 +35,25 @@ function getJCouplingKey(signalIndex, jIndex, jCouplingKey) {
35
35
  export function SignalJCouplingsTable(props) {
36
36
  const { values, setFieldValue } = useFormikContext();
37
37
  const signal = values?.signals?.[values?.signalIndex] || {};
38
- const jCouplings = signal?.js || [];
39
38
  const [lastSelectedCouplingIndex, setLastSelectedCouplingIndex] = useState(null);
40
39
  const spectrum = useSpectrum();
41
40
  const { view: { spectra: { activeTab }, }, } = useChartData();
42
41
  const rangesPreferences = usePanelPreferences('ranges', activeTab);
42
+ const inputRef = useRef([]);
43
43
  useEvent({
44
- onClick: (options) => {
44
+ onClick: ({ xPPM, shiftKey }) => {
45
45
  if (`${props.index}` === values.signalIndex &&
46
- typeof lastSelectedCouplingIndex === 'number') {
47
- const x = formatNumber(options.xPPM, rangesPreferences.deltaHz.format);
46
+ typeof lastSelectedCouplingIndex === 'number' &&
47
+ shiftKey) {
48
+ const x = formatNumber(xPPM, rangesPreferences.deltaHz.format);
48
49
  void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), x);
49
50
  }
50
51
  },
51
52
  onBrushEnd: (options) => {
52
- const { range: [from, to], } = options;
53
+ const { range: [from, to], shiftKey, } = options;
53
54
  if (`${props.index}` === values.signalIndex &&
54
55
  typeof lastSelectedCouplingIndex === 'number' &&
56
+ shiftKey &&
55
57
  isSpectrum1D(spectrum)) {
56
58
  const value = Number(formatNumber(Math.abs(to - from) * spectrum.info.originFrequency, rangesPreferences.deltaHz.format));
57
59
  void setFieldValue(getJCouplingKey(values.signalIndex, lastSelectedCouplingIndex, 'coupling'), value);
@@ -97,6 +99,10 @@ export function SignalJCouplingsTable(props) {
97
99
  Cell: ({ row }) => {
98
100
  return (_jsx(FormikSelect, { className: "select-box", name: getJCouplingKey(values.signalIndex, row.index, 'multiplicity'), items: Multiplets, itemValueField: "label", onChange: (value) => {
99
101
  multiplicityChangeHandler(value, getJCouplingKey(values.signalIndex, row.index, 'coupling'));
102
+ if (hasCouplingConstant(row.original?.multiplicity) &&
103
+ typeof lastSelectedCouplingIndex === 'number') {
104
+ inputRef.current[lastSelectedCouplingIndex].focus();
105
+ }
100
106
  }, style: styles.select, onClick: (e) => e.stopPropagation() }));
101
107
  },
102
108
  },
@@ -104,7 +110,11 @@ export function SignalJCouplingsTable(props) {
104
110
  Header: 'J (Hz)',
105
111
  style: { padding: 0, ...styles.column },
106
112
  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() }));
113
+ return (_jsx(FormikInput, { ref: (ref) => {
114
+ if (ref) {
115
+ inputRef.current[row.index] = ref;
116
+ }
117
+ }, name: getJCouplingKey(values.signalIndex, row.index, 'coupling'), type: "number", placeholder: 'J (Hz)', style: { input: styles.input }, disabled: !hasCouplingConstant(row.original?.multiplicity) }));
108
118
  },
109
119
  },
110
120
  {
@@ -119,15 +129,22 @@ export function SignalJCouplingsTable(props) {
119
129
  }, children: _jsx(FaRegTrashAlt, {}) })) }));
120
130
  },
121
131
  },
122
- ], [deleteHandler, multiplicityChangeHandler, values.signalIndex]);
132
+ ], [
133
+ deleteHandler,
134
+ lastSelectedCouplingIndex,
135
+ multiplicityChangeHandler,
136
+ values.signalIndex,
137
+ ]);
123
138
  function selectRowHandler(index) {
124
139
  setLastSelectedCouplingIndex((prevIndex) => prevIndex === index ? null : index);
125
140
  }
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: {
141
+ useEffect(() => {
142
+ if (typeof lastSelectedCouplingIndex === 'number') {
143
+ inputRef.current[lastSelectedCouplingIndex].focus();
144
+ }
145
+ }, [lastSelectedCouplingIndex, signal?.js]);
146
+ 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, {}), tooltip: "Add a new J coupling", intent: "success", onClick: () => addHandler(signal?.js || []) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), tooltip: "Delete all J couplings", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
130
147
  maxHeight: '300px',
131
148
  overflow: 'auto',
132
- }, children: _jsx(ReactTable, { data: jCouplings, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No J Couplings" }) })] }));
149
+ }, children: _jsx(ReactTable, { data: signal?.js || [], columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), emptyDataRowText: "No J Couplings" }) })] }));
133
150
  }
@@ -3,7 +3,7 @@ import { v4 } from '@lukeed/uuid';
3
3
  import { useFormikContext } from 'formik';
4
4
  import { xFindClosestIndex } from 'ml-spectra-processing';
5
5
  import { getShiftX } from 'nmr-processing';
6
- import { useCallback, useMemo, useState } from 'react';
6
+ import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
7
7
  import { FaPlus, FaRegTrashAlt } from 'react-icons/fa';
8
8
  import { Toolbar } from 'react-science/ui';
9
9
  import { useChartData } from '../../../../../context/ChartContext';
@@ -33,7 +33,6 @@ function getPeakKey(signalIndex, peakIndex, key) {
33
33
  export function SignalPeaksTable(props) {
34
34
  const { values, setFieldValue } = useFormikContext();
35
35
  const signal = values?.signals?.[values?.signalIndex] || {};
36
- const peaks = signal?.peaks || [];
37
36
  const delta = signal?.delta || 0;
38
37
  const spectrum = useSpectrum();
39
38
  const { data: { x: xArray, re }, } = spectrum;
@@ -41,24 +40,27 @@ export function SignalPeaksTable(props) {
41
40
  const [lastSelectedPeakIndex, setLastSelectedPeakIndex] = useState(null);
42
41
  const { view: { spectra: { activeTab }, }, } = useChartData();
43
42
  const rangesPreferences = usePanelPreferences('ranges', activeTab);
43
+ const inputRef = useRef([]);
44
44
  useEvent({
45
- onClick: (options) => {
45
+ onClick: ({ xPPM, shiftKey }) => {
46
46
  if (`${props.index}` === values.signalIndex &&
47
- typeof lastSelectedPeakIndex === 'number') {
48
- const delta = formatNumber(options.xPPM, rangesPreferences.deltaPPM.format);
47
+ typeof lastSelectedPeakIndex === 'number' &&
48
+ shiftKey) {
49
+ const delta = formatNumber(xPPM, rangesPreferences.deltaPPM.format);
49
50
  const xIndex = xFindClosestIndex(xArray, delta, { sorted: false });
50
51
  const intensity = formatNumber(re[xIndex], rangesPreferences.deltaPPM.format);
51
52
  void setFieldValue(getPeakKey(values?.signalIndex, lastSelectedPeakIndex), {
52
- ...peaks[lastSelectedPeakIndex],
53
+ ...signal?.peaks?.[lastSelectedPeakIndex],
53
54
  x: delta,
54
55
  y: intensity,
55
56
  });
56
57
  }
57
58
  },
58
59
  onBrushEnd: (options) => {
59
- const { range: [from, to], } = options;
60
+ const { range: [from, to], shiftKey, } = options;
60
61
  if (`${props.index}` === values.signalIndex &&
61
- typeof lastSelectedPeakIndex === 'number') {
62
+ typeof lastSelectedPeakIndex === 'number' &&
63
+ shiftKey) {
62
64
  const value = Number(formatNumber((to - from) / 2 + from, rangesPreferences.deltaPPM.format));
63
65
  void setFieldValue(getPeakKey(values.signalIndex, lastSelectedPeakIndex, 'x'), value);
64
66
  }
@@ -77,7 +79,8 @@ export function SignalPeaksTable(props) {
77
79
  ...data,
78
80
  peak,
79
81
  ]);
80
- setLastSelectedPeakIndex(data?.length || 0);
82
+ const rowIndex = data?.length || 0;
83
+ setLastSelectedPeakIndex(rowIndex);
81
84
  }, [delta, re, setFieldValue, shiftX, values?.signalIndex, xArray]);
82
85
  const deleteHandler = useCallback((data, index) => {
83
86
  const peaks = data.filter((_, columnIndex) => columnIndex !== index);
@@ -105,7 +108,11 @@ export function SignalPeaksTable(props) {
105
108
  Header: 'delta',
106
109
  style: { padding: 0, ...styles.column },
107
110
  Cell: ({ row }) => {
108
- return (_jsx(FormikInput, { name: `signals.${values?.signalIndex}.peaks.${row.index}.x`, style: { input: styles.input }, onChange: (event) => changeDeltaHandler(event, row.index), type: "number", onClick: (e) => e.stopPropagation() }));
111
+ return (_jsx(FormikInput, { ref: (ref) => {
112
+ if (ref) {
113
+ inputRef.current[row.index] = ref;
114
+ }
115
+ }, name: `signals.${values?.signalIndex}.peaks.${row.index}.x`, style: { input: styles.input }, onChange: (event) => changeDeltaHandler(event, row.index), type: "number" }));
109
116
  },
110
117
  },
111
118
  {
@@ -129,13 +136,16 @@ export function SignalPeaksTable(props) {
129
136
  },
130
137
  ], [changeDeltaHandler, deleteHandler, values?.signalIndex]);
131
138
  function selectRowHandler(index) {
132
- setLastSelectedPeakIndex((prevIndex) => prevIndex === index ? null : index);
139
+ setLastSelectedPeakIndex(index);
140
+ inputRef.current[index].select();
133
141
  }
134
- function handleActiveRow(row) {
135
- return row?.index === lastSelectedPeakIndex;
136
- }
137
- 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 peak", intent: "success", onClick: () => addHandler(peaks) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), title: "Delete all peaks", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
142
+ useEffect(() => {
143
+ if (typeof lastSelectedPeakIndex === 'number') {
144
+ inputRef.current[lastSelectedPeakIndex].focus();
145
+ }
146
+ }, [lastSelectedPeakIndex, signal?.peaks]);
147
+ 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, {}), tooltip: "Add a new peak", intent: "success", onClick: () => addHandler(signal?.peaks || []) }), _jsx(Toolbar.Item, { icon: _jsx(FaRegTrashAlt, {}), tooltip: "Delete all peaks", intent: "danger", onClick: deleteAllHandler })] }) }), _jsx("div", { style: {
138
148
  maxHeight: '300px',
139
149
  overflow: 'auto',
140
- }, children: _jsx(ReactTable, { data: peaks, columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), activeRow: handleActiveRow, emptyDataRowText: "No peaks" }) })] }));
150
+ }, children: _jsx(ReactTable, { data: signal?.peaks || [], columns: COLUMNS, onClick: (e, rowData) => selectRowHandler(rowData.index), emptyDataRowText: "No peaks" }) })] }));
141
151
  }
@@ -96,6 +96,6 @@ function EditZoneModal({ onSaveEditZoneModal = () => null, onCloseEditZoneModal
96
96
  }),
97
97
  };
98
98
  }, [rowData.signals, rowData.tableMetaInfo.experiment]);
99
- return (_jsx("div", { css: styles, children: _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: zoneFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "header handle", children: [_jsx(Button, { onClick: handleOnZoom, className: "zoom-button", children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { children: `Zone and Signal edition` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), title: "Save and exit" }), _jsx(CloseButton, { title: "Close", onClick: handleOnClose })] }), _jsx(SignalsForm, {})] }) }) }));
99
+ return (_jsx("div", { css: styles, children: _jsx(Formik, { innerRef: formRef, initialValues: data, validationSchema: zoneFormValidation, onSubmit: handleOnSave, children: _jsxs(_Fragment, { children: [_jsxs("div", { className: "header handle", children: [_jsx(Button, { onClick: handleOnZoom, className: "zoom-button", children: _jsx(FaSearchPlus, { title: "Set to default view on range in spectrum" }) }), _jsx("span", { children: `Zone and Signal edition` }), _jsx(SaveButton, { onClick: () => formRef.current.submitForm(), tooltip: "Save and exit" }), _jsx(CloseButton, { tooltip: "Close", onClick: handleOnClose })] }), _jsx(SignalsForm, {})] }) }) }));
100
100
  }
101
101
  export default EditZoneModal;