nmrium 0.24.0 → 0.26.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 (220) hide show
  1. package/lib/component/1d/IntegralResizable.js +13 -13
  2. package/lib/component/1d/multiAnalysis/AnalysisRange.js +30 -31
  3. package/lib/component/1d/multiplicityTree/MultiplicityTree.js +5 -5
  4. package/lib/component/1d/ranges/Range.js +24 -33
  5. package/lib/component/2d/zones/Signal.js +8 -8
  6. package/lib/component/2d/zones/Zone.js +3 -3
  7. package/lib/component/EventsTrackers/KeysListenerTracker.js +1 -1
  8. package/lib/component/NMRium.js +22 -29
  9. package/lib/component/assignment/AssignmentsContext.d.ts +35 -0
  10. package/lib/component/assignment/AssignmentsContext.js +83 -0
  11. package/lib/component/assignment/AssignmentsReducer.d.ts +32 -0
  12. package/lib/component/assignment/AssignmentsReducer.js +39 -0
  13. package/lib/component/assignment/actions/initAssignment.d.ts +5 -0
  14. package/lib/component/assignment/actions/initAssignment.js +62 -0
  15. package/lib/component/assignment/actions/removeAssignment.d.ts +16 -0
  16. package/lib/component/assignment/actions/removeAssignment.js +24 -0
  17. package/lib/component/assignment/actions/setActiveAssignment.d.ts +10 -0
  18. package/lib/component/assignment/actions/setActiveAssignment.js +8 -0
  19. package/lib/component/assignment/actions/toggleAssignment.d.ts +7 -0
  20. package/lib/component/assignment/actions/toggleAssignment.js +44 -0
  21. package/lib/component/assignment/index.d.ts +0 -18
  22. package/lib/component/assignment/index.js +12 -266
  23. package/lib/component/assignment/utilities/filterForIDsWithAssignment.d.ts +2 -0
  24. package/lib/component/assignment/utilities/filterForIDsWithAssignment.js +3 -0
  25. package/lib/component/context/GlobalContext.d.ts +12 -3
  26. package/lib/component/context/GlobalContext.js +1 -1
  27. package/lib/component/elements/ActionButtons.d.ts +10 -0
  28. package/lib/component/elements/ActionButtons.js +14 -0
  29. package/lib/component/elements/Button.d.ts +30 -5
  30. package/lib/component/elements/Button.js +151 -4
  31. package/lib/component/elements/ContextMenu.js +6 -6
  32. package/lib/component/elements/ReactTable/Elements/ReactTableRow.d.ts +5 -1
  33. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +38 -10
  34. package/lib/component/elements/ReactTable/ReactTable.d.ts +3 -1
  35. package/lib/component/elements/ReactTable/ReactTable.js +7 -2
  36. package/lib/component/elements/ReactTable/Style.d.ts +1 -3
  37. package/lib/component/elements/ReactTable/Style.js +1 -7
  38. package/lib/component/elements/ToolTip/ToolTip.js +3 -2
  39. package/lib/component/elements/resizer/DivResizer.d.ts +2 -0
  40. package/lib/component/elements/resizer/DivResizer.js +107 -0
  41. package/lib/component/elements/resizer/Resizer.d.ts +18 -0
  42. package/lib/component/elements/resizer/Resizer.js +12 -0
  43. package/lib/component/elements/resizer/SVGResizer.d.ts +2 -0
  44. package/lib/component/elements/resizer/SVGResizer.js +71 -0
  45. package/lib/component/elements/resizer/useDraggable.d.ts +19 -0
  46. package/lib/component/elements/resizer/useDraggable.js +52 -0
  47. package/lib/component/header/AutoPeakPickingOptionPanel.js +4 -15
  48. package/lib/component/header/BaseLineCorrectionPanel.js +2 -9
  49. package/lib/component/header/ManualPhaseCorrectionPanel.js +2 -9
  50. package/lib/component/header/RangesPickingOptionPanel.js +3 -16
  51. package/lib/component/header/ZeroFillingOptionsPanel.js +2 -9
  52. package/lib/component/header/Zones2DOptionPanel.js +3 -14
  53. package/lib/component/hooks/useExport.js +11 -9
  54. package/lib/component/loader/DropZone.js +1 -0
  55. package/lib/component/modal/AlignSpectraModal.js +2 -1
  56. package/lib/component/modal/ExportAsMatrixModal.js +2 -1
  57. package/lib/component/modal/ImportPublicationStringModal.js +2 -1
  58. package/lib/component/modal/LoadJCAMPModal.js +7 -6
  59. package/lib/component/modal/ModalStyle.js +4 -26
  60. package/lib/component/modal/MoleculeStructureEditorModal.js +2 -1
  61. package/lib/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
  62. package/lib/component/modal/PredictSpectraModal.js +2 -7
  63. package/lib/component/modal/SaveAsModal.d.ts +1 -1
  64. package/lib/component/modal/SaveAsModal.js +2 -1
  65. package/lib/component/modal/setting/FormattingTabContent.js +17 -11
  66. package/lib/component/modal/setting/GeneralSettings.js +3 -1
  67. package/lib/component/modal/setting/settingsValidation.d.ts +8 -0
  68. package/lib/component/modal/setting/settingsValidation.js +40 -0
  69. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
  70. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +4 -3
  71. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
  72. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.d.ts +10 -0
  73. package/lib/component/panels/AutomaticAssignment/useAutoAssignments.js +60 -0
  74. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +11 -5
  75. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +20 -11
  76. package/lib/component/panels/MoleculesPanel/Utilities.js +50 -68
  77. package/lib/component/panels/MoleculesPanel/useAtomAssignment.d.ts +2 -2
  78. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
  79. package/lib/component/panels/RangesPanel/RangesHeader.js +2 -2
  80. package/lib/component/panels/RangesPanel/RangesPanel.js +1 -1
  81. package/lib/component/panels/RangesPanel/RangesTableRow.js +12 -11
  82. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +16 -9
  83. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
  84. package/lib/component/panels/RangesPanel/TableColumns/SignalAssignmentsColumn.d.ts +2 -3
  85. package/lib/component/panels/RangesPanel/hooks/useEditRangeModal.js +1 -1
  86. package/lib/component/panels/SpectrumsPanel/SpectraPanelHeader.js +5 -18
  87. package/lib/component/panels/SummaryPanel/SummaryPanel.js +1 -1
  88. package/lib/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +1 -1
  89. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.d.ts +5 -7
  90. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
  91. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.d.ts +4 -8
  92. package/lib/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
  93. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.d.ts +5 -9
  94. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
  95. package/lib/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumns.d.ts +4 -8
  96. package/lib/component/panels/ZonesPanel/ZonesPanel.js +1 -1
  97. package/lib/component/panels/ZonesPanel/ZonesTableRow.d.ts +2 -1
  98. package/lib/component/panels/ZonesPanel/ZonesTableRow.js +20 -20
  99. package/lib/component/panels/header/SpectraAutomaticPickingButton.d.ts +2 -0
  100. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +30 -0
  101. package/lib/component/panels/predictionPanel/PredictionOptions.js +2 -18
  102. package/lib/component/reducer/Reducer.d.ts +2 -0
  103. package/lib/component/reducer/Reducer.js +4 -1
  104. package/lib/component/reducer/actions/AssignmentsActions.d.ts +9 -0
  105. package/lib/component/reducer/actions/AssignmentsActions.js +18 -0
  106. package/lib/component/reducer/actions/LoadActions.d.ts +1 -1
  107. package/lib/component/reducer/actions/LoadActions.js +10 -5
  108. package/lib/component/reducer/preferencesReducer.d.ts +1 -8
  109. package/lib/component/reducer/preferencesReducer.js +16 -16
  110. package/lib/component/reducer/types/Types.d.ts +1 -0
  111. package/lib/component/reducer/types/Types.js +1 -0
  112. package/lib/component/utility/Export.d.ts +3 -3
  113. package/lib/component/utility/Export.js +10 -9
  114. package/lib/component/utility/FormatNumber.js +1 -1
  115. package/lib/component/workspaces/Workspace.d.ts +2 -4
  116. package/lib/component/workspaces/basic.js +8 -9
  117. package/lib/data/SpectraManager.js +23 -15
  118. package/lib/data/data1d/Data1DManager.d.ts +1 -1
  119. package/lib/data/data1d/Data1DManager.js +2 -1
  120. package/lib/data/data1d/Spectrum1D/toJSON.d.ts +2 -0
  121. package/lib/data/data1d/Spectrum1D/toJSON.js +1 -0
  122. package/lib/data/data1d/database.d.ts +1 -2
  123. package/lib/data/data1d/database.js +1 -1
  124. package/lib/data/data1d/filter1d/exclusionZones.d.ts +1 -4
  125. package/lib/data/data2d/Data2DManager.d.ts +1 -1
  126. package/lib/data/data2d/Data2DManager.js +2 -1
  127. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  128. package/lib/data/data2d/Spectrum2D/toJSON.d.ts +2 -0
  129. package/lib/data/data2d/Spectrum2D/toJSON.js +1 -0
  130. package/lib/data/types/common/Source.d.ts +1 -0
  131. package/lib/data/types/data2d/Signal2DAxisData.d.ts +1 -1
  132. package/lib/versionInfo.js +1 -1
  133. package/lib-cjs/component/1d/IntegralResizable.js +12 -12
  134. package/lib-cjs/component/1d/multiAnalysis/AnalysisRange.js +29 -30
  135. package/lib-cjs/component/1d/multiplicityTree/MultiplicityTree.js +6 -6
  136. package/lib-cjs/component/1d/ranges/Range.js +26 -35
  137. package/lib-cjs/component/2d/zones/Signal.js +9 -9
  138. package/lib-cjs/component/2d/zones/Zone.js +4 -4
  139. package/lib-cjs/component/EventsTrackers/KeysListenerTracker.js +2 -2
  140. package/lib-cjs/component/NMRium.js +22 -29
  141. package/lib-cjs/component/assignment/AssignmentsContext.js +88 -0
  142. package/lib-cjs/component/assignment/AssignmentsReducer.js +45 -0
  143. package/lib-cjs/component/assignment/actions/initAssignment.js +65 -0
  144. package/lib-cjs/component/assignment/actions/removeAssignment.js +29 -0
  145. package/lib-cjs/component/assignment/actions/setActiveAssignment.js +11 -0
  146. package/lib-cjs/component/assignment/actions/toggleAssignment.js +47 -0
  147. package/lib-cjs/component/assignment/index.js +15 -269
  148. package/lib-cjs/component/assignment/utilities/filterForIDsWithAssignment.js +7 -0
  149. package/lib-cjs/component/context/GlobalContext.js +1 -1
  150. package/lib-cjs/component/elements/ActionButtons.js +20 -0
  151. package/lib-cjs/component/elements/Button.js +150 -4
  152. package/lib-cjs/component/elements/ContextMenu.js +6 -6
  153. package/lib-cjs/component/elements/ReactTable/Elements/ReactTableRow.js +42 -14
  154. package/lib-cjs/component/elements/ReactTable/ReactTable.js +7 -2
  155. package/lib-cjs/component/elements/ReactTable/Style.js +1 -9
  156. package/lib-cjs/component/elements/ToolTip/ToolTip.js +3 -2
  157. package/lib-cjs/component/elements/resizer/DivResizer.js +113 -0
  158. package/lib-cjs/component/elements/resizer/Resizer.js +18 -0
  159. package/lib-cjs/component/elements/resizer/SVGResizer.js +77 -0
  160. package/lib-cjs/component/elements/resizer/useDraggable.js +55 -0
  161. package/lib-cjs/component/header/AutoPeakPickingOptionPanel.js +3 -14
  162. package/lib-cjs/component/header/BaseLineCorrectionPanel.js +2 -9
  163. package/lib-cjs/component/header/ManualPhaseCorrectionPanel.js +2 -9
  164. package/lib-cjs/component/header/RangesPickingOptionPanel.js +2 -15
  165. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +2 -9
  166. package/lib-cjs/component/header/Zones2DOptionPanel.js +2 -13
  167. package/lib-cjs/component/hooks/useExport.js +11 -9
  168. package/lib-cjs/component/loader/DropZone.js +1 -0
  169. package/lib-cjs/component/modal/AlignSpectraModal.js +2 -1
  170. package/lib-cjs/component/modal/ExportAsMatrixModal.js +2 -1
  171. package/lib-cjs/component/modal/ImportPublicationStringModal.js +2 -1
  172. package/lib-cjs/component/modal/LoadJCAMPModal.js +7 -6
  173. package/lib-cjs/component/modal/ModalStyle.js +4 -26
  174. package/lib-cjs/component/modal/MoleculeStructureEditorModal.js +5 -1
  175. package/lib-cjs/component/modal/MultipleSpectraFiltersModal/index.js +2 -1
  176. package/lib-cjs/component/modal/PredictSpectraModal.js +2 -7
  177. package/lib-cjs/component/modal/SaveAsModal.js +2 -1
  178. package/lib-cjs/component/modal/setting/FormattingTabContent.js +17 -11
  179. package/lib-cjs/component/modal/setting/GeneralSettings.js +3 -1
  180. package/lib-cjs/component/modal/setting/settingsValidation.js +66 -0
  181. package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignment.js +6 -4
  182. package/lib-cjs/component/panels/AutomaticAssignment/AutomaticAssignmentTable.js +13 -6
  183. package/lib-cjs/component/panels/AutomaticAssignment/useAutoAssignments.js +67 -0
  184. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +12 -6
  185. package/lib-cjs/component/panels/MoleculesPanel/Utilities.js +50 -68
  186. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +55 -60
  187. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +3 -3
  188. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +2 -2
  189. package/lib-cjs/component/panels/RangesPanel/RangesTableRow.js +15 -14
  190. package/lib-cjs/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.js +2 -2
  191. package/lib-cjs/component/panels/RangesPanel/hooks/useEditRangeModal.js +2 -2
  192. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPanelHeader.js +3 -16
  193. package/lib-cjs/component/panels/SummaryPanel/SummaryPanel.js +2 -2
  194. package/lib-cjs/component/panels/ZonesPanel/TableColumns/ActionsColumn.js +2 -2
  195. package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumn.js +2 -2
  196. package/lib-cjs/component/panels/ZonesPanel/TableColumns/SignalAssignmentsColumns.js +1 -1
  197. package/lib-cjs/component/panels/ZonesPanel/TableColumns/ZoneAssignmentsColumn.js +4 -4
  198. package/lib-cjs/component/panels/ZonesPanel/ZonesPanel.js +2 -2
  199. package/lib-cjs/component/panels/ZonesPanel/ZonesTableRow.js +21 -21
  200. package/lib-cjs/component/panels/header/SpectraAutomaticPickingButton.js +37 -0
  201. package/lib-cjs/component/panels/predictionPanel/PredictionOptions.js +2 -18
  202. package/lib-cjs/component/reducer/Reducer.js +4 -1
  203. package/lib-cjs/component/reducer/actions/AssignmentsActions.js +21 -0
  204. package/lib-cjs/component/reducer/actions/LoadActions.js +9 -4
  205. package/lib-cjs/component/reducer/preferencesReducer.js +16 -16
  206. package/lib-cjs/component/reducer/types/Types.js +2 -1
  207. package/lib-cjs/component/utility/Export.js +10 -9
  208. package/lib-cjs/component/utility/FormatNumber.js +1 -1
  209. package/lib-cjs/component/workspaces/basic.js +8 -9
  210. package/lib-cjs/data/SpectraManager.js +23 -15
  211. package/lib-cjs/data/data1d/Data1DManager.js +2 -1
  212. package/lib-cjs/data/data1d/Spectrum1D/toJSON.js +1 -0
  213. package/lib-cjs/data/data2d/Data2DManager.js +2 -1
  214. package/lib-cjs/data/data2d/Spectrum2D/initiateDatum2D.js +1 -1
  215. package/lib-cjs/data/data2d/Spectrum2D/toJSON.js +1 -0
  216. package/lib-cjs/versionInfo.js +1 -1
  217. package/package.json +25 -26
  218. package/lib/component/1d/Resizable.d.ts +0 -12
  219. package/lib/component/1d/Resizable.js +0 -105
  220. package/lib-cjs/component/1d/Resizable.js +0 -110
@@ -1,22 +1,18 @@
1
1
  /// <reference types="react" />
2
+ import { AssignmentsData, Axis } from '../../../assignment/AssignmentsContext';
2
3
  import { RowDataProps } from './ActionsColumn';
3
4
  interface ZoneAssignmentsColumnsProps {
4
5
  rowData: RowDataProps;
5
6
  onHoverZoneX: any;
6
7
  onHoverZoneY: any;
7
- onClick: (a: any, b: any, c: any) => void;
8
- onUnlink: (a: any, b: any, c: any) => void;
8
+ onClick: (event: any, assignment: AssignmentsData, axis: Axis) => void;
9
+ onUnlink: (event: any, flag: boolean, axis: Axis) => void;
9
10
  rowSpanTags: any;
10
11
  showUnlinkButtonZoneX: boolean;
11
12
  showUnlinkButtonZoneY: boolean;
12
13
  setShowUnlinkButtonZoneX: (element: boolean) => void;
13
14
  setShowUnlinkButtonZoneY: (element: boolean) => void;
14
- assignmentZone: {
15
- activeAxis: any;
16
- onHoverAxis: any;
17
- isActive: boolean;
18
- isOnHover: boolean;
19
- };
15
+ assignmentZone: AssignmentsData;
20
16
  highlightZoneX: {
21
17
  isActive: any;
22
18
  };
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/reac
3
3
  import { css } from '@emotion/react';
4
4
  import { useState, useMemo, useCallback, useRef, memo } from 'react';
5
5
  import { FaUnlink } from 'react-icons/fa';
6
- import { useAssignmentData } from '../../assignment';
6
+ import { useAssignmentData } from '../../assignment/AssignmentsContext';
7
7
  import { useChartData } from '../../context/ChartContext';
8
8
  import { useDispatch } from '../../context/DispatchContext';
9
9
  import ToggleButton from '../../elements/ToggleButton';
@@ -1,8 +1,9 @@
1
1
  /** @jsxImportSource @emotion/react */
2
+ import { Axis } from '../../assignment/AssignmentsContext';
2
3
  import { RowDataProps } from './TableColumns/ActionsColumn';
3
4
  interface ZonesTableRowProps {
4
5
  rowData: RowDataProps;
5
- onUnlink: (a: any, b: any, c: any, d: any) => void;
6
+ onUnlink: (rowData: RowDataProps, isOnZoneLevel: boolean, signalIndex: any, axis: Axis) => void;
6
7
  onContextMenu: (a: any, rowData: RowDataProps) => void;
7
8
  rowIndex: number;
8
9
  }
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import lodashGet from 'lodash/get';
4
- import { useMemo, useCallback, useState } from 'react';
4
+ import { useMemo, useCallback, useState, } from 'react';
5
5
  import { buildID } from '../../../data/utilities/Concatenation';
6
- import { useAssignment } from '../../assignment';
6
+ import { useAssignment, } from '../../assignment/AssignmentsContext';
7
7
  import { useHighlight } from '../../highlight';
8
8
  import ActionsColumn from './TableColumns/ActionsColumn';
9
9
  import SignalAssignmentsColumns from './TableColumns/SignalAssignmentsColumns';
@@ -14,11 +14,11 @@ const ConstantlyHighlightedRowStyle = { backgroundColor: '#f5f5dc' };
14
14
  function ZonesTableRow({ rowData, onUnlink, onContextMenu, rowIndex, }) {
15
15
  const assignmentZone = useAssignment(rowData.id);
16
16
  const highlightZone = useHighlight([assignmentZone.id]);
17
- const highlightZoneX = useHighlight([buildID(assignmentZone.id, 'X')].concat(assignmentZone.assigned.x || []));
18
- const highlightZoneY = useHighlight([buildID(assignmentZone.id, 'Y')].concat(assignmentZone.assigned.y || []));
17
+ const highlightZoneX = useHighlight([buildID(assignmentZone.id, 'X')].concat(assignmentZone.assigned?.x || []));
18
+ const highlightZoneY = useHighlight([buildID(assignmentZone.id, 'Y')].concat(assignmentZone.assigned?.y || []));
19
19
  const assignmentSignal = useAssignment(rowData.tableMetaInfo.id);
20
- const highlightSignalX = useHighlight([buildID(assignmentSignal.id, 'X')].concat(assignmentSignal.assigned.x || [], buildID(assignmentSignal.id, 'Crosshair')));
21
- const highlightSignalY = useHighlight([buildID(assignmentSignal.id, 'Y')].concat(assignmentSignal.assigned.y || [], buildID(assignmentSignal.id, 'Crosshair')));
20
+ const highlightSignalX = useHighlight([buildID(assignmentSignal.id, 'X')].concat(assignmentSignal.assigned?.x || [], buildID(assignmentSignal.id, 'Crosshair')));
21
+ const highlightSignalY = useHighlight([buildID(assignmentSignal.id, 'Y')].concat(assignmentSignal.assigned?.y || [], buildID(assignmentSignal.id, 'Crosshair')));
22
22
  const [showUnlinkButtonZoneX, setShowUnlinkButtonZoneX] = useState(false);
23
23
  const [showUnlinkButtonZoneY, setShowUnlinkButtonZoneY] = useState(false);
24
24
  const [showUnlinkButtonSignalX, setShowUnlinkButtonSignalX] = useState(false);
@@ -31,10 +31,10 @@ function ZonesTableRow({ rowData, onUnlink, onContextMenu, rowIndex, }) {
31
31
  : null,
32
32
  };
33
33
  }, [rowData]);
34
- const unlinkHandler = useCallback((e, isOnZoneLevel, axis) => {
34
+ const unlinkHandler = useCallback((event, isOnZoneLevel, axis) => {
35
35
  // event handling here in case of unlink button clicked
36
- if (e) {
37
- e.stopPropagation();
36
+ if (event) {
37
+ event.stopPropagation();
38
38
  }
39
39
  onUnlink(rowData, isOnZoneLevel, rowData.tableMetaInfo.signalIndex, axis);
40
40
  if (axis === 'x') {
@@ -80,18 +80,18 @@ function ZonesTableRow({ rowData, onUnlink, onContextMenu, rowIndex, }) {
80
80
  assignmentSignal.removeAll('y');
81
81
  }
82
82
  }, [assignmentSignal, assignmentZone, onUnlink, rowData]);
83
- const clickHandler = useCallback((e, assignment, axis) => {
84
- e.stopPropagation();
85
- assignment.onClick(axis);
83
+ const clickHandler = useCallback((event, assignment, axis) => {
84
+ event.stopPropagation();
85
+ assignment.setActive(axis);
86
86
  }, []);
87
87
  const onHoverZoneX = useMemo(() => {
88
88
  return {
89
89
  onMouseEnter: () => {
90
- assignmentZone.onMouseEnter('x');
90
+ assignmentZone.show('x');
91
91
  highlightZoneX.show();
92
92
  },
93
93
  onMouseLeave: () => {
94
- assignmentZone.onMouseLeave('x');
94
+ assignmentZone.hide();
95
95
  highlightZoneX.hide();
96
96
  },
97
97
  };
@@ -99,11 +99,11 @@ function ZonesTableRow({ rowData, onUnlink, onContextMenu, rowIndex, }) {
99
99
  const onHoverZoneY = useMemo(() => {
100
100
  return {
101
101
  onMouseEnter: () => {
102
- assignmentZone.onMouseEnter('y');
102
+ assignmentZone.show('y');
103
103
  highlightZoneY.show();
104
104
  },
105
105
  onMouseLeave: () => {
106
- assignmentZone.onMouseLeave('y');
106
+ assignmentZone.hide();
107
107
  highlightZoneY.hide();
108
108
  },
109
109
  };
@@ -111,11 +111,11 @@ function ZonesTableRow({ rowData, onUnlink, onContextMenu, rowIndex, }) {
111
111
  const onHoverSignalX = useMemo(() => {
112
112
  return {
113
113
  onMouseEnter: () => {
114
- assignmentSignal.onMouseEnter('x');
114
+ assignmentSignal.show('x');
115
115
  highlightSignalX.show();
116
116
  },
117
117
  onMouseLeave: () => {
118
- assignmentSignal.onMouseLeave('x');
118
+ assignmentSignal.hide();
119
119
  highlightSignalX.hide();
120
120
  },
121
121
  };
@@ -123,11 +123,11 @@ function ZonesTableRow({ rowData, onUnlink, onContextMenu, rowIndex, }) {
123
123
  const onHoverSignalY = useMemo(() => {
124
124
  return {
125
125
  onMouseEnter: () => {
126
- assignmentSignal.onMouseEnter('y');
126
+ assignmentSignal.show('y');
127
127
  highlightSignalY.show();
128
128
  },
129
129
  onMouseLeave: () => {
130
- assignmentSignal.onMouseLeave('y');
130
+ assignmentSignal.hide();
131
131
  highlightSignalY.hide();
132
132
  },
133
133
  };
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function SpectraAutomaticPickingButton(): JSX.Element | null;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { SvgNmrRangePicking } from 'cheminfo-font';
3
+ import { useCallback } from 'react';
4
+ import { useChartData } from '../../context/ChartContext';
5
+ import { useDispatch } from '../../context/DispatchContext';
6
+ import Button from '../../elements/ButtonToolTip';
7
+ import { useAlert } from '../../elements/popup/Alert';
8
+ import { useCheckToolsVisibility } from '../../hooks/useCheckToolsVisibility';
9
+ import { AUTO_RANGES_SPECTRA_PICKING, AUTO_ZONES_SPECTRA_PICKING, } from '../../reducer/types/Types';
10
+ export function SpectraAutomaticPickingButton() {
11
+ const dispatch = useDispatch();
12
+ const alert = useAlert();
13
+ const { data } = useChartData();
14
+ const isToolVisible = useCheckToolsVisibility();
15
+ const automaticPickingHandler = useCallback(() => {
16
+ void (async () => {
17
+ const hideLoading = await alert.showLoading('Automatic Ranges/Zones detection for all spectra in progress');
18
+ setTimeout(() => {
19
+ dispatch({ type: AUTO_RANGES_SPECTRA_PICKING });
20
+ dispatch({ type: AUTO_ZONES_SPECTRA_PICKING });
21
+ hideLoading();
22
+ }, 0);
23
+ })();
24
+ }, [dispatch, alert]);
25
+ if ((Array.isArray(data) && data.length === 0) ||
26
+ !isToolVisible('autoRangesTool')) {
27
+ return null;
28
+ }
29
+ return (_jsx(Button, { popupTitle: "Automatic Ranges/Zones picking for all spectra", onClick: automaticPickingHandler, children: _jsx(SvgNmrRangePicking, {}) }));
30
+ }
@@ -4,6 +4,7 @@ import { css } from '@emotion/react';
4
4
  import { useCallback, useRef } from 'react';
5
5
  import * as Yup from 'yup';
6
6
  import { defaultPredictionOptions, FREQUENCIES, } from '../../../data/PredictionManager';
7
+ import Button from '../../elements/Button';
7
8
  import IsotopesViewer from '../../elements/IsotopesViewer';
8
9
  import Label from '../../elements/Label';
9
10
  import FormikErrorsSummary from '../../elements/formik/FormikErrorsSummary';
@@ -34,23 +35,6 @@ const styles = css `
34
35
  align-items: flex-end;
35
36
  }
36
37
 
37
- .btn:not([disabled]):hover {
38
- background-color: #ffffff;
39
- }
40
- .btn:hover {
41
- background-color: #f2f2f2 !important;
42
- }
43
- .btn:disabled {
44
- opacity: 0.5;
45
- }
46
- .btn {
47
- border: none;
48
- padding: 0 15px;
49
- background-color: #ffffff;
50
- border-radius: 5px;
51
- height: 25px;
52
- }
53
-
54
38
  .input {
55
39
  font-size: 14px;
56
40
  border-radius: 5px;
@@ -85,6 +69,6 @@ function PredictionOptions({ onPredict = () => null }) {
85
69
  onPredict(values);
86
70
  })();
87
71
  }, [onPredict]);
88
- return (_jsxs("div", { css: styles, children: [_jsx("div", { children: _jsxs(FormikForm, { ref: refForm, initialValues: defaultPredictionOptions, validationSchema: predictionFormValidation, onSubmit: submitHandler, children: [_jsx(FormikErrorsSummary, {}), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Frequency : " }), _jsx(FormikSelect, { data: FREQUENCIES, style: { width: 290, height: 30, margin: 0 }, name: "frequency" })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "1H", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.1H.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.1H.to", type: "number" }) })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "13C", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.13C.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.13C.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Line Width : " }), _jsx(FormikInput, { name: "1d.lineWidth", type: "number", style: { input: { margin: 0 } } }), _jsx("span", { style: { paddingLeft: '0.4rem' }, children: " Hz " })] })] }) }), _jsx("div", { children: _jsx("button", { type: "button", onClick: handleSave, className: "btn", children: "Predict spectrum" }) })] }));
72
+ return (_jsxs("div", { css: styles, children: [_jsx("div", { children: _jsxs(FormikForm, { ref: refForm, initialValues: defaultPredictionOptions, validationSchema: predictionFormValidation, onSubmit: submitHandler, children: [_jsx(FormikErrorsSummary, {}), _jsxs("div", { className: "row margin-10", children: [_jsx("span", { className: "custom-label", children: "Frequency : " }), _jsx(FormikSelect, { data: FREQUENCIES, style: { width: 290, height: 30, margin: 0 }, name: "frequency" })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "1H", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.1H.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.1H.to", type: "number" }) })] }), _jsxs("div", { className: "row", children: [_jsx(IsotopesViewer, { value: "13C", className: "custom-label" }), _jsx(Label, { title: "From", children: _jsx(FormikInput, { name: "1d.13C.from", type: "number" }) }), _jsx(Label, { title: "To", style: { label: { padding: '0 10px' } }, children: _jsx(FormikInput, { name: "1d.13C.to", type: "number" }) })] }), _jsxs("div", { className: "row margin-10 padding-h-10", children: [_jsx("span", { className: "custom-label", children: "Line Width : " }), _jsx(FormikInput, { name: "1d.lineWidth", type: "number", style: { input: { margin: 0 } } }), _jsx("span", { style: { paddingLeft: '0.4rem' }, children: " Hz " })] })] }) }), _jsx("div", { children: _jsx(Button.Done, { onClick: handleSave, children: "Predict spectrum" }) })] }));
89
73
  }
90
74
  export default PredictionOptions;
@@ -256,6 +256,7 @@ export declare const spectrumReducer: (base: {
256
256
  readonly id: string;
257
257
  readonly source: {
258
258
  readonly jcampURL: string;
259
+ readonly jcampSpectrumIndex: number;
259
260
  readonly file: {
260
261
  readonly lastModified: number;
261
262
  readonly name: string;
@@ -442,6 +443,7 @@ export declare const spectrumReducer: (base: {
442
443
  readonly id: string;
443
444
  readonly source: {
444
445
  readonly jcampURL: string;
446
+ readonly jcampSpectrumIndex: number;
445
447
  readonly file: {
446
448
  readonly lastModified: number;
447
449
  readonly name: string;
@@ -7,6 +7,7 @@ import generateID from '../../data/utilities/generateID';
7
7
  import { DefaultTolerance } from '../panels/SummaryPanel/CorrelationTable/Constants';
8
8
  import { options } from '../toolbar/ToolTypes';
9
9
  import { nmredataToNmrium } from '../utility/nmredataToNmrium';
10
+ import * as AssignmentsActions from './actions/AssignmentsActions';
10
11
  import * as CorrelationsActions from './actions/CorrelationsActions';
11
12
  import * as DatabaseActions from './actions/DatabaseActions';
12
13
  import { setWidth, handleSetDimensions } from './actions/DimensionsActions';
@@ -165,7 +166,7 @@ export function dispatchMiddleware(dispatch) {
165
166
  };
166
167
  }
167
168
  function innerSpectrumReducer(draft, action) {
168
- if (![types.LOAD_JSON_FILE, types.LOAD_NMREDATA_FILE].includes(action.type)) {
169
+ if (![types.LOAD_JSON_FILE, types.LOAD_NMREDATA_FILE, types.INITIATE].includes(action.type)) {
169
170
  draft.actionType = action.type;
170
171
  }
171
172
  switch (action.type) {
@@ -393,6 +394,8 @@ function innerSpectrumReducer(draft, action) {
393
394
  return SpectraAnalysisActions.handleFilterColumn(draft, action);
394
395
  case types.RESURRECTING_SPECTRUM_FROM_RANGES:
395
396
  return DatabaseActions.handleRangeResurrecting(draft, action);
397
+ case types.SET_AUTOMATIC_ASSIGNMENTS:
398
+ return AssignmentsActions.setAutomaticAssignmentsHandler(draft, action);
396
399
  case UNDO:
397
400
  return handleHistoryUndo(draft);
398
401
  case REDO:
@@ -0,0 +1,9 @@
1
+ import { Draft } from 'immer';
2
+ import { SpectraData1D, SpectraData2D } from 'nmr-processing';
3
+ import { State } from '../Reducer';
4
+ declare function setAutomaticAssignmentsHandler(draft: Draft<State>, action: {
5
+ payload: {
6
+ assignments: (SpectraData1D | SpectraData2D)[];
7
+ };
8
+ }): void;
9
+ export { setAutomaticAssignmentsHandler };
@@ -0,0 +1,18 @@
1
+ function setAutomaticAssignmentsHandler(draft, action) {
2
+ const assignments = action.payload.assignments;
3
+ for (let datum of assignments) {
4
+ const index = draft.data.findIndex((spectrum) => spectrum.id === datum.id);
5
+ if (index !== -1) {
6
+ const dimension = draft.data[index].info.dimension;
7
+ if (dimension === 1) {
8
+ draft.data[index].ranges.values = datum
9
+ .ranges;
10
+ }
11
+ else if (dimension === 2) {
12
+ draft.data[index].zones.values = datum
13
+ .zones;
14
+ }
15
+ }
16
+ }
17
+ }
18
+ export { setAutomaticAssignmentsHandler };
@@ -1,7 +1,7 @@
1
1
  import { Draft } from 'immer';
2
2
  import { State } from '../Reducer';
3
3
  declare function setIsLoading(draft: Draft<State>, isLoading: boolean): void;
4
- declare function initiate(draft: Draft<State>, action: any): void;
4
+ declare function initiate(draft: Draft<State>, action: any): State;
5
5
  declare function loadJDFFile(draft: Draft<State>, actions: any): void;
6
6
  declare function loadJcampFile(draft: Draft<State>, actions: any): void;
7
7
  declare function handleLoadJsonFile(draft: Draft<State>, action: any): State;
@@ -3,7 +3,7 @@ import { addJcamps, addJDFs } from '../../../data/SpectraManager';
3
3
  import * as MoleculeManager from '../../../data/molecules/MoleculeManager';
4
4
  import { DefaultTolerance } from '../../panels/SummaryPanel/CorrelationTable/Constants';
5
5
  import { getInitialState } from '../Reducer';
6
- import { LOAD_JSON_FILE, LOAD_NMREDATA_FILE } from '../types/Types';
6
+ import { INITIATE, LOAD_JSON_FILE, LOAD_NMREDATA_FILE } from '../types/Types';
7
7
  import { changeSpectrumVerticalAlignment } from './PreferencesActions';
8
8
  import { setActiveTab } from './ToolsActions';
9
9
  function setIsLoading(draft, isLoading) {
@@ -69,11 +69,16 @@ function setPreferences(draft, data) {
69
69
  }
70
70
  }
71
71
  function initiate(draft, action) {
72
- setData(draft, action.payload);
72
+ const state = getInitialState();
73
+ setData(state, action.payload);
73
74
  const preferences = action.payload?.preferences || {};
74
- setActiveTab(draft, { tab: preferences?.activeTab || '' });
75
- setPreferences(draft, action.payload);
76
- draft.isLoading = false;
75
+ setActiveTab(state, { tab: preferences?.activeTab || '' });
76
+ setPreferences(state, action.payload);
77
+ state.width = draft.width;
78
+ state.height = draft.height;
79
+ state.isLoading = false;
80
+ state.actionType = INITIATE;
81
+ return state;
77
82
  }
78
83
  function loadJDFFile(draft, actions) {
79
84
  const { files } = actions;
@@ -164,15 +164,8 @@ declare const preferencesReducer: (base: {
164
164
  readonly dimmedSpectraTransparency: number;
165
165
  };
166
166
  readonly formatting: {
167
- readonly nucleus: readonly {
168
- readonly key: string;
169
- readonly name: string;
170
- readonly ppm: string;
171
- readonly hz: string;
172
- }[];
173
- readonly nucleusByKey: {
167
+ readonly nuclei: {
174
168
  readonly [x: string]: {
175
- readonly key: string;
176
169
  readonly name: string;
177
170
  readonly ppm: string;
178
171
  readonly hz: string;
@@ -3,7 +3,7 @@ import lodashMerge from 'lodash/merge';
3
3
  import generateID from '../../data/utilities/generateID';
4
4
  import { getLocalStorage, removeData, storeData, } from '../utility/LocalStorage';
5
5
  import Workspaces from '../workspaces';
6
- const LOCAL_STORAGE_VERSION = 5;
6
+ const LOCAL_STORAGE_VERSION = 6;
7
7
  export const WORKSPACES = [
8
8
  {
9
9
  key: 'default',
@@ -77,16 +77,13 @@ function checkKeysExists(sourceObject, targetObject) {
77
77
  }
78
78
  return true;
79
79
  }
80
- function mapNucleus(draft) {
81
- const currentWorkspacePreferences = getActiveWorkspace(draft);
82
- if (currentWorkspacePreferences.formatting.nucleus &&
83
- Array.isArray(currentWorkspacePreferences.formatting.nucleus)) {
84
- currentWorkspacePreferences.formatting.nucleusByKey =
85
- currentWorkspacePreferences.formatting.nucleus.reduce((acc, item) => {
86
- acc[item.name.toLowerCase()] = item;
87
- return { ...acc };
88
- }, {});
89
- }
80
+ function mapNucleiFormatting(formatting) {
81
+ const { nuclei, ...res } = formatting;
82
+ const _nuclei = Object.keys(nuclei).reduce((nucleusFormatting, key) => {
83
+ nucleusFormatting[nuclei[key].name.trim().toLowerCase()] = nuclei[key];
84
+ return nucleusFormatting;
85
+ }, {});
86
+ return { nuclei: _nuclei, ...res };
90
87
  }
91
88
  export function initPreferencesState(state) {
92
89
  const nmrLocalStorageVersion = getLocalStorage('nmr-local-storage-version', false);
@@ -133,19 +130,22 @@ function handleInit(draft, action) {
133
130
  currentWorkspacePreferences?.version ||
134
131
  !checkKeysExists(workspacePreferences.display, currentWorkspacePreferences?.display))) ||
135
132
  !localData) {
136
- const { workspaces, version } = draft || {};
133
+ const { workspaces, version, workspace: { current }, } = draft || {};
137
134
  const display = filterObject(workspacePreferences.display);
138
135
  const data = {
139
136
  version,
137
+ ...(localData?.currentWorkspace && {
138
+ currentWorkspace: localData?.currentWorkspace,
139
+ }),
140
140
  workspaces: {
141
141
  ...workspaces,
142
- [draft.workspace.current]: {
142
+ [current]: {
143
143
  ...workspacePreferences,
144
144
  display,
145
145
  },
146
146
  },
147
147
  };
148
- draft.workspaces[draft.workspace.current] = lodashMerge({}, currentWorkspacePreferences, workspacePreferences);
148
+ draft.workspaces[current] = lodashMerge({}, currentWorkspacePreferences, workspacePreferences);
149
149
  storeData('nmr-general-settings', JSON.stringify(data));
150
150
  }
151
151
  else {
@@ -157,7 +157,8 @@ function handleInit(draft, action) {
157
157
  function handleSetPreferences(draft, action) {
158
158
  if (action.payload) {
159
159
  const currentWorkspacePreferences = getActiveWorkspace(draft);
160
- const { controllers, formatting, display } = action.payload;
160
+ let { controllers, formatting, display } = action.payload;
161
+ formatting = mapNucleiFormatting(formatting);
161
162
  let localData = getLocalStorage('nmr-general-settings');
162
163
  localData.currentWorkspace = draft.workspace.current;
163
164
  localData.workspaces = {
@@ -180,7 +181,6 @@ function handleSetPreferences(draft, action) {
180
181
  experimentalFeatures: display.general.experimentalFeatures,
181
182
  },
182
183
  };
183
- mapNucleus(draft);
184
184
  }
185
185
  }
186
186
  function handleSetPanelsPreferences(draft, action) {
@@ -121,3 +121,4 @@ export declare const AUTO_ZONES_SPECTRA_PICKING = "AUTO_ZONES_SPECTRA_PICKING";
121
121
  export declare const GENERATE_SPECTRUM_FROM_PUBLICATION_STRING = "GENERATE_SPECTRUM_FROM_PUBLICATION_STRING";
122
122
  export declare const RESURRECTING_SPECTRUM_FROM_RANGES = "RESURRECTING_SPECTRUM_FROM_RANGES";
123
123
  export declare const SHOW_J_GRAPH = "SHOW_J_GRAPH";
124
+ export declare const SET_AUTOMATIC_ASSIGNMENTS = "SET_AUTOMATIC_ASSIGNMENTS";
@@ -115,3 +115,4 @@ export const AUTO_ZONES_SPECTRA_PICKING = 'AUTO_ZONES_SPECTRA_PICKING';
115
115
  export const GENERATE_SPECTRUM_FROM_PUBLICATION_STRING = 'GENERATE_SPECTRUM_FROM_PUBLICATION_STRING';
116
116
  export const RESURRECTING_SPECTRUM_FROM_RANGES = 'RESURRECTING_SPECTRUM_FROM_RANGES';
117
117
  export const SHOW_J_GRAPH = 'SHOW_J_GRAPH';
118
+ export const SET_AUTOMATIC_ASSIGNMENTS = 'SET_AUTOMATIC_ASSIGNMENTS';
@@ -11,7 +11,7 @@ declare function exportAsMol(data: any, fileName?: string): void;
11
11
  /**
12
12
  * export the vitalization result as SVG, if you need to remove some content during exportation process enclose the the content with <!-- export-remove --> ${content} <!-- export-remove -->
13
13
  */
14
- declare function exportAsSVG(elementID: any, fileName?: string): void;
15
- declare function exportAsPng(elementID: any, fileName?: string): void;
16
- declare function copyPNGToClipboard(elementID: any): void;
14
+ declare function exportAsSVG(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
15
+ declare function exportAsPng(rootRef: HTMLDivElement, elementID: string, fileName?: string): void;
16
+ declare function copyPNGToClipboard(rootRef: HTMLDivElement, elementID: string): void;
17
17
  export { exportAsSVG, exportAsJSON, exportAsNMRE, exportAsPng, copyPNGToClipboard, copyTextToClipboard, copyHTMLToClipboard, exportAsMol, exportAsMatrix, };
@@ -109,12 +109,12 @@ function exportAsMol(data, fileName = 'mol') {
109
109
  /**
110
110
  * export the vitalization result as SVG, if you need to remove some content during exportation process enclose the the content with <!-- export-remove --> ${content} <!-- export-remove -->
111
111
  */
112
- function exportAsSVG(elementID, fileName = 'experiment') {
113
- const { blob } = getBlob(elementID);
112
+ function exportAsSVG(rootRef, elementID, fileName = 'experiment') {
113
+ const { blob } = getBlob(rootRef, elementID);
114
114
  saveAs(blob, `${fileName}.svg`);
115
115
  }
116
- function exportAsPng(elementID, fileName = 'experiment') {
117
- const { blob, width, height } = getBlob(elementID);
116
+ function exportAsPng(rootRef, elementID, fileName = 'experiment') {
117
+ const { blob, width, height } = getBlob(rootRef, elementID);
118
118
  try {
119
119
  let canvas = document.createElement('canvas');
120
120
  canvas.width = width;
@@ -166,8 +166,8 @@ function copyBlobToCliboard(canvas) {
166
166
  });
167
167
  });
168
168
  }
169
- function copyPNGToClipboard(elementID) {
170
- const { blob, width, height } = getBlob(elementID);
169
+ function copyPNGToClipboard(rootRef, elementID) {
170
+ const { blob, width, height } = getBlob(rootRef, elementID);
171
171
  try {
172
172
  let canvas = document.createElement('canvas');
173
173
  canvas.width = width;
@@ -202,9 +202,10 @@ function copyPNGToClipboard(elementID) {
202
202
  console.log(e);
203
203
  }
204
204
  }
205
- function getBlob(elementID) {
206
- // nmrSVG
207
- let _svg = document.getElementById(elementID)?.cloneNode(true);
205
+ function getBlob(rootRef, elementID) {
206
+ let _svg = rootRef.getRootNode()
207
+ .getElementById(elementID)
208
+ ?.cloneNode(true);
208
209
  const width = _svg?.getAttribute('width').replace('px', '');
209
210
  const height = _svg?.getAttribute('height').replace('px', '');
210
211
  _svg
@@ -7,7 +7,7 @@ function FormatNumber(value, format, prefix = '', suffix = '') {
7
7
  }
8
8
  export function useFormatNumberByNucleus(nucleus) {
9
9
  const preferences = usePreferences();
10
- const nucleusByKey = lodashGet(preferences.current, `formatting.nucleusByKey`, {
10
+ const nucleusByKey = lodashGet(preferences.current, `formatting.nuclei`, {
11
11
  ppm: '0.0',
12
12
  hz: '0.0',
13
13
  });
@@ -1,6 +1,5 @@
1
1
  import { NMRiumPreferences } from '../NMRium';
2
2
  interface NucleusFormat {
3
- key: string;
4
3
  name: string;
5
4
  ppm: string;
6
5
  hz: string;
@@ -8,9 +7,8 @@ interface NucleusFormat {
8
7
  interface Controllers {
9
8
  dimmedSpectraTransparency: number;
10
9
  }
11
- interface Formatting {
12
- nucleus: NucleusFormat[];
13
- nucleusByKey: Record<string, NucleusFormat>;
10
+ export interface Formatting {
11
+ nuclei: Record<string, NucleusFormat>;
14
12
  panels: any;
15
13
  }
16
14
  export interface Workspace {
@@ -27,15 +27,14 @@ export const basic = {
27
27
  dimmedSpectraTransparency: 0.1,
28
28
  },
29
29
  formatting: {
30
- nucleus: [
31
- { key: '1H', name: '1H', ppm: '0.00', hz: '0.00' },
32
- { key: '13C', name: '13C', ppm: '0.00', hz: '0.00' },
33
- { key: '15N', name: '15N', ppm: '0.00', hz: '0.00' },
34
- { key: '19F', name: '19F', ppm: '0.00', hz: '0.00' },
35
- { key: '29Si', name: '29Si', ppm: '0.00', hz: '0.00' },
36
- { key: '31P', name: '31P', ppm: '0.00', hz: '0.00' },
37
- ],
38
- nucleusByKey: {},
30
+ nuclei: {
31
+ '1h': { name: '1H', ppm: '0.00', hz: '0.00' },
32
+ '13c': { name: '13C', ppm: '0.00', hz: '0.00' },
33
+ '15n': { name: '15N', ppm: '0.00', hz: '0.00' },
34
+ '19f': { name: '19F', ppm: '0.00', hz: '0.00' },
35
+ '29si': { name: '29Si', ppm: '0.00', hz: '0.00' },
36
+ '31p': { name: '31P', ppm: '0.00', hz: '0.00' },
37
+ },
39
38
  panels: {},
40
39
  },
41
40
  };
@@ -29,22 +29,26 @@ export function addJcamp(spectra, jcamp, options, usedColors) {
29
29
  if (entries.length === 0)
30
30
  return;
31
31
  // Should be improved when we have a more complex case
32
- for (let entry of entries) {
33
- let { dependentVariables } = entry;
34
- if (dependentVariables[0].components &&
35
- (dependentVariables[0].components.length > 0 ||
36
- dependentVariables[0].components.z.length)) {
37
- addJcampSS(spectra, entry, options, usedColors);
32
+ for (let index = 0; index < entries.length; index++) {
33
+ let entry = entries[index];
34
+ const components = entry.dependentVariables?.[0]?.components;
35
+ if (components && (components.length > 0 || components.z)) {
36
+ addJcampSS(spectra, { index, entry }, options, usedColors);
38
37
  }
39
38
  }
40
39
  }
41
- function addJcampSS(spectra, entry, options, usedColors) {
42
- const dimension = entry.info.dimension;
43
- if (dimension === 1) {
44
- spectra.push(Data1DManager.fromParsedJcamp(entry, options, usedColors));
45
- }
46
- if (dimension === 2) {
47
- spectra.push(Data2DManager.fromParsedJcamp(entry, options, usedColors));
40
+ function addJcampSS(spectra, jcampDatum, options, usedColors) {
41
+ const source = options?.source || {};
42
+ if (!('jcampSpectrumIndex' in source) ||
43
+ source.jcampSpectrumIndex === jcampDatum.index) {
44
+ const dimension = jcampDatum.entry.info.dimension;
45
+ if (dimension === 1) {
46
+ spectra.push(Data1DManager.fromParsedJcamp(jcampDatum.entry, options, usedColors, jcampDatum.index));
47
+ }
48
+ if (dimension === 2) {
49
+ // console.log(options, jcampDatum.entry);
50
+ spectra.push(Data2DManager.fromParsedJcamp(jcampDatum.entry, options, usedColors, jcampDatum.index));
51
+ }
48
52
  }
49
53
  }
50
54
  function addData(spectra, datum, usedColors) {
@@ -94,8 +98,12 @@ export async function fromJSON(data = [], usedColors = {}) {
94
98
  const spectra = [];
95
99
  let promises = [];
96
100
  for (let datum of data) {
97
- if (datum?.source?.jcampURL != null) {
98
- promises.push(addJcampFromURL(spectra, datum.source.jcampURL, datum, usedColors));
101
+ const { jcamp, jcampURL } = datum?.source || {};
102
+ if (jcamp != null) {
103
+ addJcamp(spectra, jcamp, datum, usedColors);
104
+ }
105
+ else if (jcampURL != null) {
106
+ promises.push(addJcampFromURL(spectra, jcampURL, datum, usedColors));
99
107
  }
100
108
  else {
101
109
  addData(spectra, datum, usedColors);
@@ -1,3 +1,3 @@
1
1
  export declare function fromBruker(result: any, options?: {}, usedColors?: {}): import("../types/data1d").Datum1D;
2
2
  export declare function fromCSD(result: any, options?: {}, usedColors?: {}): import("../types/data1d").Datum1D;
3
- export declare function fromParsedJcamp(parsedJcamp: any, options: any, usedColors: any): import("../types/data1d").Datum1D;
3
+ export declare function fromParsedJcamp(parsedJcamp: any, options: any, usedColors: any, jcampSpectrumIndex: number): import("../types/data1d").Datum1D;