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
@@ -47,24 +47,30 @@ const styles = css `
47
47
  `;
48
48
  function FormattingTabContent() {
49
49
  const { values, setFieldValue } = useFormikContext();
50
- const nucleuses = useMemo(() => lodashGet(values, 'formatting.nucleus', []), [values]);
51
- const deleteHandler = useCallback((index) => {
52
- const nucleusesObject = nucleuses.splice(0, index);
53
- setFieldValue('formatting.nucleus', nucleusesObject);
54
- }, [nucleuses, setFieldValue]);
50
+ const nuclei = useMemo(() => lodashGet(values, 'formatting.nuclei', {}), [values]);
51
+ const deleteHandler = useCallback((key) => {
52
+ let _nuclei = {};
53
+ for (const nucleus in nuclei) {
54
+ if (nucleus !== key) {
55
+ _nuclei[nucleus] = nuclei[nucleus];
56
+ }
57
+ }
58
+ setFieldValue('formatting.nuclei', _nuclei);
59
+ }, [nuclei, setFieldValue]);
55
60
  const addNewNucleusFormatHandler = useCallback(() => {
56
61
  const newFormat = {
57
- key: generateID(),
58
62
  name: '',
59
63
  ppm: '0.00',
60
64
  hz: '0.00',
61
65
  };
62
- const newNucleuses = [...nucleuses, newFormat];
63
- setFieldValue('formatting.nucleus', newNucleuses);
64
- }, [nucleuses, setFieldValue]);
65
- return (_jsxs(Fragment, { children: [_jsx("p", { className: "section-header", children: "Formating according to Nucleus" }), _jsx("div", { css: styles, children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "counter-col", children: "#" }), _jsx("th", { className: "nucleus-label-col", children: "Nucleus " }), _jsx("th", { className: "nucleus-format-input-col", children: "\u03B4 (ppm)" }), _jsx("th", { className: "nucleus-format-input-col", children: "Coupling (Hz)" }), _jsx("th", { className: "nucleus-format-input-col" })] }) }), _jsx("tbody", { children: nucleuses?.map((nucleus, index) => {
66
+ const key = generateID();
67
+ const newNuclei = { ...nuclei, [key]: newFormat };
68
+ setFieldValue('formatting.nuclei', newNuclei);
69
+ }, [nuclei, setFieldValue]);
70
+ const nucleiList = Object.keys(nuclei);
71
+ return (_jsxs(Fragment, { children: [_jsx("p", { className: "section-header", children: "Nuclei Formatting" }), _jsx("div", { css: styles, children: _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { className: "counter-col", children: "#" }), _jsx("th", { className: "nucleus-label-col", children: "Nucleus " }), _jsx("th", { className: "nucleus-format-input-col", children: "\u03B4 (ppm)" }), _jsx("th", { className: "nucleus-format-input-col", children: "Coupling (Hz)" }), _jsx("th", { className: "nucleus-format-input-col" })] }) }), _jsx("tbody", { children: nucleiList?.map((key, index) => {
66
72
  const num = index + 1;
67
- return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.nucleus.${index}.name`, className: "width-100" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nucleus.${index}.ppm`, className: "width-100" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nucleus.${index}.hz`, className: "width-100" }) }), _jsxs("td", { className: "operation-container", children: [_jsx(CloseButton, { onClick: () => deleteHandler(index), popupTitle: `remove ${nucleus.name}`, popupPlacement: "right" }), nucleuses.length === index + 1 && (_jsx("button", { className: "add", type: "button", onClick: addNewNucleusFormatHandler, children: _jsx(FaPlus, {}) }))] })] }, `${nucleus.key}`));
73
+ return (_jsxs("tr", { children: [_jsxs("td", { className: "counter-col", children: [_jsxs("span", { children: [num, " - "] }), ' '] }), _jsx("td", { className: "nucleus-label-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.name`, className: "width-100", checkErrorAfterInputTouched: false }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.ppm`, className: "width-100" }) }), _jsx("td", { className: "nucleus-format-input-col", children: _jsx(FormikInput, { name: `formatting.nuclei.${key}.hz`, className: "width-100" }) }), _jsxs("td", { className: "operation-container", children: [_jsx(CloseButton, { onClick: () => deleteHandler(key), popupTitle: `remove ${nuclei[key].name}`, popupPlacement: "right" }), nucleiList.length === index + 1 && (_jsx("button", { className: "add", type: "button", onClick: addNewNucleusFormatHandler, children: _jsx(FaPlus, {}) }))] })] }, `${key}`));
68
74
  }) })] }) })] }));
69
75
  }
70
76
  export default FormattingTabContent;
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
3
3
  import { css } from '@emotion/react';
4
4
  import { useCallback, useMemo, useRef, useState } from 'react';
5
5
  import { usePreferences, useWorkspacesList, } from '../../context/PreferencesContext';
6
+ import ActionButtons from '../../elements/ActionButtons';
6
7
  import CloseButton from '../../elements/CloseButton';
7
8
  import Tab from '../../elements/Tab/Tab';
8
9
  import Tabs, { PositionsEnum } from '../../elements/Tab/Tabs';
@@ -14,6 +15,7 @@ import ControllersTabContent from './ControllersTabContent';
14
15
  import DisplayTabContent from './DisplayTabContent';
15
16
  import FormattingTabContent from './FormattingTabContent';
16
17
  import WorkspaceItem from './WorkspaceItem';
18
+ import { validation } from './settingsValidation';
17
19
  const styles = css `
18
20
  .main-content {
19
21
  width: 100%;
@@ -145,6 +147,6 @@ function GeneralSettings({ onClose }) {
145
147
  const renderItem = useCallback((item) => {
146
148
  return (_jsx(WorkspaceItem, { item: item, onSave: addWorkSpaceHandler, onDelete: deleteWorkSpaceHandler }));
147
149
  }, [addWorkSpaceHandler, deleteWorkSpaceHandler]);
148
- return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsxs("div", { className: "footer-container", children: [_jsx("button", { type: "button", onClick: handleSave, className: "btn", children: "Save" }), _jsx("button", { type: "button", onClick: handleReset, className: "btn", children: "Reset" })] })] }));
150
+ return (_jsxs("div", { css: [ModalStyles, styles], children: [_jsxs("div", { className: "header handle", children: [_jsx("span", { children: "General Settings" }), _jsx(CloseButton, { onClick: onClose, className: "close-bt" })] }), _jsxs("div", { className: "workspace-container", children: [_jsx("span", { className: "label", children: "Workspace : " }), _jsx(DropDownButton, { data: workspacesList, renderItem: renderItem, selectedKey: preferences?.workspace.current, onSelect: ChangeWorkspaceHandler })] }), _jsx("div", { className: "main-content", children: _jsx(FormikForm, { ref: refForm, initialValues: preferences.current, validationSchema: validation, onSubmit: submitHandler, children: _jsxs(Tabs, { position: PositionsEnum.LEFT, activeTab: activeTab, onClick: tabChangeHandler, children: [_jsx(Tab, { tablabel: "Controllers", tabid: "controllers", children: _jsx("div", { className: "inner-content", children: _jsx(ControllersTabContent, {}) }) }), _jsx(Tab, { tablabel: "Formatting", tabid: "formatting", children: _jsx("div", { className: "inner-content", children: _jsx(FormattingTabContent, {}) }) }), _jsx(Tab, { tablabel: "Display", tabid: "display", children: _jsx("div", { className: "inner-content", children: _jsx(DisplayTabContent, { preferences: preferences.current.display }) }) })] }) }, JSON.stringify(preferences.current)) }), _jsx("div", { className: "footer-container", children: _jsx(ActionButtons, { style: { flexDirection: 'row-reverse', margin: 0 }, onDone: handleSave, doneLabel: "Save", onCancel: handleReset, cancelLabel: "Reset" }) })] }));
149
151
  }
150
152
  export default GeneralSettings;
@@ -0,0 +1,8 @@
1
+ import * as Yup from 'yup';
2
+ export declare const validation: import("yup/lib/Lazy").default<Yup.ObjectSchema<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
3
+ formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
4
+ }>, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
5
+ formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
6
+ }>>, import("yup/lib/object").AssertsShape<import("yup/lib/object").Assign<import("yup/lib/object").ObjectShape, {
7
+ formatting: Yup.ObjectSchema<any, import("yup/lib/object").AnyObject, import("yup/lib/object").TypeOfShape<any>, import("yup/lib/object").AssertsShape<any>>;
8
+ }>>>, import("yup/lib/object").AnyObject>;
@@ -0,0 +1,40 @@
1
+ import * as Yup from 'yup';
2
+ const formattingValidation = (obj) => Object.keys(obj.formatting.nuclei).reduce((validate, key) => {
3
+ validate[key] = Yup.object().shape({
4
+ name: Yup.string().trim().required('Nucleus is a required field'),
5
+ ppm: Yup.string().trim().required('PPM format is a required field'),
6
+ hz: Yup.string().trim().required('Hz format is a required field'),
7
+ });
8
+ return validate;
9
+ }, {});
10
+ export const validation = Yup.lazy((obj) => Yup.object().shape({
11
+ formatting: Yup.object().shape({
12
+ nuclei: Yup.object()
13
+ .shape(formattingValidation(obj))
14
+ .test('Unique', 'Nuclei need te be unique', function check(nuclei) {
15
+ let nucleusFrequencies = {};
16
+ for (const key of Object.keys(nuclei)) {
17
+ const _key = nuclei[key].name?.toLowerCase() || '';
18
+ if (_key) {
19
+ if (nucleusFrequencies[_key]) {
20
+ ++nucleusFrequencies[_key].value;
21
+ nucleusFrequencies[_key].fields.push(key);
22
+ }
23
+ else {
24
+ nucleusFrequencies[_key] = { value: 1, fields: [key] };
25
+ }
26
+ }
27
+ }
28
+ const errors = Object.keys(nucleusFrequencies).reduce((errorList, key) => {
29
+ const { value, fields } = nucleusFrequencies[key];
30
+ if (value > 1) {
31
+ for (let field of fields) {
32
+ errorList.push(new Yup.ValidationError(`${key} nucleus must te be unique`, nuclei[key].name, `${this.path}.${field}.name`));
33
+ }
34
+ }
35
+ return errorList;
36
+ }, []);
37
+ return new Yup.ValidationError(errors);
38
+ }),
39
+ }),
40
+ }));
@@ -1,13 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
2
  /** @jsxImportSource @emotion/react */
3
3
  import { SvgNmrAssignment2 } from 'cheminfo-font';
4
- import { useCallback } from 'react';
4
+ import { FaBolt } from 'react-icons/fa';
5
5
  import Button from '../../elements/ButtonToolTip';
6
6
  import { tablePanelStyle } from '../extra/BasicPanelStyle';
7
7
  import DefaultPanelHeader from '../header/DefaultPanelHeader';
8
+ import { SpectraAutomaticPickingButton } from '../header/SpectraAutomaticPickingButton';
9
+ import AutomaticAssignmentTable from './AutomaticAssignmentTable';
10
+ import { useAutoAssignments } from './useAutoAssignments';
8
11
  function AutomaticAssignment() {
9
- // eslint-disable-next-line @typescript-eslint/no-empty-function
10
- const automaticAssignmentHandler = useCallback(() => { }, []);
11
- return (_jsxs("div", { css: tablePanelStyle, children: [_jsx(DefaultPanelHeader, { showSettingButton: false, canDelete: false, children: _jsx(Button, { popupTitle: "automatic assignment", onClick: automaticAssignmentHandler, children: _jsx(SvgNmrAssignment2, { style: { fontSize: '18px' } }) }) }), _jsx("div", { className: "inner-container" })] }));
12
+ const { getAssignments, assignments, restAssignments } = useAutoAssignments();
13
+ return (_jsxs("div", { css: tablePanelStyle, children: [_jsxs(DefaultPanelHeader, { showSettingButton: false, canDelete: false, children: [_jsx(SpectraAutomaticPickingButton, {}), _jsx(Button, { popupTitle: "automatic assignment", onClick: getAssignments, children: _jsx(SvgNmrAssignment2, { style: { fontSize: '18px' } }) }), _jsx(Button, { popupTitle: "reset assignment", onClick: restAssignments, children: _jsx(FaBolt, {}) })] }), _jsx("div", { className: "inner-container", children: _jsx(AutomaticAssignmentTable, { data: assignments }) })] }));
12
14
  }
13
15
  export default AutomaticAssignment;
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
+ import { AutoAssignmentsData } from './useAutoAssignments';
2
3
  interface AutomaticAssignmentTableProps {
3
- data: any;
4
+ data: AutoAssignmentsData[];
4
5
  }
5
- declare function PeaksTable({ data }: AutomaticAssignmentTableProps): JSX.Element;
6
- declare const _default: import("react").MemoExoticComponent<typeof PeaksTable>;
6
+ declare function AutomaticAssignmentTable({ data }: AutomaticAssignmentTableProps): JSX.Element;
7
+ declare const _default: import("react").MemoExoticComponent<typeof AutomaticAssignmentTable>;
7
8
  export default _default;
@@ -1,15 +1,21 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SvgNmrAssignment } from 'cheminfo-font';
3
3
  import { useCallback, useMemo, memo } from 'react';
4
+ import { useDispatch } from '../../context/DispatchContext';
4
5
  import ReactTable from '../../elements/ReactTable/ReactTable';
6
+ import { SET_AUTOMATIC_ASSIGNMENTS } from '../../reducer/types/Types';
5
7
  import NoTableData from '../extra/placeholder/NoTableData';
6
- function PeaksTable({ data }) {
8
+ function AutomaticAssignmentTable({ data }) {
9
+ const dispatch = useDispatch();
7
10
  const assignHandler = useCallback((e, row) => {
8
11
  e.preventDefault();
9
12
  e.stopPropagation();
10
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11
- const params = row.original;
12
- }, []);
13
+ const assignments = row.original.assignment;
14
+ dispatch({
15
+ type: SET_AUTOMATIC_ASSIGNMENTS,
16
+ payload: { assignments },
17
+ });
18
+ }, [dispatch]);
13
19
  const COLUMNS = useMemo(() => [
14
20
  {
15
21
  index: 1,
@@ -20,6 +26,7 @@ function PeaksTable({ data }) {
20
26
  {
21
27
  index: 2,
22
28
  Header: 'Score',
29
+ accessor: 'score',
23
30
  },
24
31
  {
25
32
  index: 3,
@@ -33,6 +40,6 @@ function PeaksTable({ data }) {
33
40
  Cell: ({ row }) => (_jsx("button", { type: "button", className: "assign-button", onClick: (e) => assignHandler(e, row), children: _jsx(SvgNmrAssignment, {}) })),
34
41
  },
35
42
  ], [assignHandler]);
36
- return data && data.length > 0 ? (_jsx(ReactTable, { data: data, columns: COLUMNS })) : (_jsx(NoTableData, {}));
43
+ return data && data.length > 0 ? (_jsx(ReactTable, { data: data, columns: COLUMNS, onClick: assignHandler, highlightActiveRow: true })) : (_jsx(NoTableData, {}));
37
44
  }
38
- export default memo(PeaksTable);
45
+ export default memo(AutomaticAssignmentTable);
@@ -0,0 +1,10 @@
1
+ import { SpectraData1D, SpectraData2D } from 'nmr-processing';
2
+ export interface AutoAssignmentsData {
3
+ score: number;
4
+ assignment: (SpectraData1D | SpectraData2D)[];
5
+ }
6
+ export declare function useAutoAssignments(): {
7
+ getAssignments: () => void;
8
+ assignments: AutoAssignmentsData[];
9
+ restAssignments: () => void;
10
+ };
@@ -0,0 +1,60 @@
1
+ import { getAssignments as getAssignmentsData, } from 'nmr-processing';
2
+ import OCL from 'openchemlib/full';
3
+ import { useCallback, useMemo, useRef, useState } from 'react';
4
+ import { useChartData } from '../../context/ChartContext';
5
+ import { useDispatch } from '../../context/DispatchContext';
6
+ import { useAlert } from '../../elements/popup/Alert';
7
+ import { SET_AUTOMATIC_ASSIGNMENTS } from '../../reducer/types/Types';
8
+ function mapSpectra(data) {
9
+ return data.reduce((acc, spectrum) => {
10
+ const { id, info } = spectrum;
11
+ const dimension = spectrum.info.dimension;
12
+ if (dimension === 1) {
13
+ const ranges = spectrum.ranges.values;
14
+ acc.push({ id, info, ranges });
15
+ }
16
+ else if (dimension === 2) {
17
+ const zones = spectrum.zones.values;
18
+ acc.push({ id, info, zones });
19
+ }
20
+ return acc;
21
+ }, []);
22
+ }
23
+ export function useAutoAssignments() {
24
+ const dispatch = useDispatch();
25
+ const { data, molecules } = useChartData();
26
+ const originData = useRef();
27
+ const alert = useAlert();
28
+ const [assignments, setAssignments] = useState([]);
29
+ const restAssignments = useCallback(() => {
30
+ dispatch({
31
+ type: SET_AUTOMATIC_ASSIGNMENTS,
32
+ payload: { assignments: originData.current },
33
+ });
34
+ }, [dispatch]);
35
+ const getAssignments = useCallback(() => {
36
+ void (async () => {
37
+ const hideLoading = await alert.showLoading('Auto Assignments');
38
+ const molecule = OCL.Molecule.fromMolfile(molecules[0]?.molfile || '');
39
+ const spectra = mapSpectra(data);
40
+ if (!originData.current) {
41
+ originData.current = spectra;
42
+ }
43
+ const result = await getAssignmentsData({
44
+ spectra,
45
+ molecule,
46
+ }, { minScore: 0 });
47
+ dispatch({
48
+ type: SET_AUTOMATIC_ASSIGNMENTS,
49
+ payload: { assignments: result[0].assignment },
50
+ });
51
+ hideLoading();
52
+ setAssignments(result);
53
+ })();
54
+ }, [alert, data, dispatch, molecules]);
55
+ return useMemo(() => ({
56
+ getAssignments,
57
+ assignments,
58
+ restAssignments,
59
+ }), [assignments, getAssignments, restAssignments]);
60
+ }
@@ -4,8 +4,9 @@ import { css } from '@emotion/react';
4
4
  import { SvgNmrFt } from 'cheminfo-font';
5
5
  import { useCallback } from 'react';
6
6
  import { FaCopy, FaDownload, FaFileExport, FaFileImage, FaPaste, FaPlus, FaRegTrashAlt, } from 'react-icons/fa';
7
- import { useAssignmentData } from '../../assignment';
7
+ import { useAssignmentData } from '../../assignment/AssignmentsContext';
8
8
  import { useDispatch } from '../../context/DispatchContext';
9
+ import { useGlobal } from '../../context/GlobalContext';
9
10
  import ButtonToolTip from '../../elements/ButtonToolTip';
10
11
  import MenuButton from '../../elements/MenuButton';
11
12
  import ToolTip from '../../elements/ToolTip/ToolTip';
@@ -56,17 +57,22 @@ const MOL_EXPORT_MENU = [
56
57
  },
57
58
  ];
58
59
  export default function MoleculePanelHeader({ currentIndex, molecules, onMoleculeIndexChange = () => null, onOpenMoleculeEditor = () => null, actionsOptions = {}, }) {
60
+ const { rootRef } = useGlobal();
59
61
  const alert = useAlert();
60
62
  const dispatch = useDispatch();
61
63
  const modal = useModal();
62
64
  const assignmentData = useAssignmentData();
63
65
  const saveAsSVGHandler = useCallback(() => {
64
- exportAsSVG(`molSVG${currentIndex}`, 'molFile');
65
- }, [currentIndex]);
66
+ if (!rootRef)
67
+ return;
68
+ exportAsSVG(rootRef, `molSVG${currentIndex}`, 'molFile');
69
+ }, [rootRef, currentIndex]);
66
70
  const saveAsPNGHandler = useCallback(() => {
67
- copyPNGToClipboard(`molSVG${currentIndex}`);
71
+ if (!rootRef)
72
+ return;
73
+ copyPNGToClipboard(rootRef, `molSVG${currentIndex}`);
68
74
  alert.success('MOL copied as PNG to clipboard');
69
- }, [alert, currentIndex]);
75
+ }, [rootRef, alert, currentIndex]);
70
76
  const saveAsMolHandler = useCallback(() => {
71
77
  if (molecules[currentIndex]) {
72
78
  void copyTextToClipboard(molecules[currentIndex].molfile).then((flag) => {
@@ -1,14 +1,23 @@
1
- export declare function extractFromAtom(atom: any, elements: any, activeAxis: any): {
2
- oclIDs: any[];
3
- nbAtoms: any;
4
- } | {
5
- oclIDs: any;
1
+ import { Range } from '../../../data/types/data1d';
2
+ import { Zone } from '../../../data/types/data2d';
3
+ import { AssignmentContext, Axis } from '../../assignment/AssignmentsContext';
4
+ interface Atom {
5
+ oclID: string;
6
+ atomLabel: string;
6
7
  nbAtoms: number;
7
- };
8
- export declare function findDatumAndSignalIndex(spectraData: any, id: any): {
9
- datum: any;
8
+ nbHydrogens: number;
9
+ hydrogenOCLIDs: string[];
10
+ }
11
+ export interface AtomData {
12
+ oclIDs: string[];
13
+ nbAtoms: number;
14
+ }
15
+ export declare function extractFromAtom(atom: Atom, activeTab: string, axis?: Axis | null): AtomData;
16
+ export declare function findDatumAndSignalIndex(data: (Range | Zone)[], id: string): {
17
+ datum: Range | Zone | undefined;
10
18
  signalIndex: any;
11
19
  };
12
- export declare function getHighlightsOnHover(assignmentData: any, oclIDs: any, data: any): number[];
13
- export declare function getCurrentDiaIDsToHighlight(assignmentData: any, displayerMode: any): any;
14
- export declare function toggleDiaIDs(diaID: any, atomInformation: any): any[];
20
+ export declare function getHighlightsOnHover(assignments: AssignmentContext, oclIDs: any, data: any): string[];
21
+ export declare function getCurrentDiaIDsToHighlight(assignmentData: AssignmentContext): string[];
22
+ export declare function toggleDiaIDs(diaIDs: string[], atomInformation: AtomData): (number | string[])[];
23
+ export {};
@@ -1,110 +1,92 @@
1
- import { DISPLAYER_MODE } from '../../reducer/core/Constants';
2
- export function extractFromAtom(atom, elements, activeAxis) {
1
+ function getElements(activeTab) {
2
+ const nuclei = activeTab.split(',');
3
+ return nuclei.map((nucleus) => nucleus.replace(/[0-9]/g, ''));
4
+ }
5
+ export function extractFromAtom(atom, activeTab, axis) {
6
+ const elements = getElements(activeTab);
3
7
  if (elements.length > 0 && Object.keys(atom).length > 0) {
4
- const dim = activeAxis === 'x' ? 0 : activeAxis === 'y' ? 1 : undefined;
5
- if (dim !== undefined) {
6
- if (elements[dim] === atom.atomLabel) {
8
+ const dim = axis === 'x' ? 0 : axis === 'y' ? 1 : null;
9
+ switch (dim !== null && elements[dim]) {
10
+ case atom.atomLabel: {
7
11
  // take always oclID if atom type is same as element of activeTab)
8
12
  return { oclIDs: [atom.oclID], nbAtoms: atom.nbAtoms };
9
13
  }
10
- if (elements[dim] === 'H') {
14
+ case 'H': {
11
15
  // if we are in proton spectrum and use then the IDs of attached hydrogens of an atom
12
16
  return {
13
17
  oclIDs: atom.hydrogenOCLIDs,
14
18
  nbAtoms: atom.nbAtoms * atom.nbHydrogens,
15
19
  };
16
20
  }
17
- }
18
- else {
19
- return {
20
- oclIDs: [atom.oclID].concat(atom.hydrogenOCLIDs),
21
- nbAtoms: atom.nbAtoms + atom.nbAtoms * atom.nbHydrogens,
22
- };
21
+ default:
22
+ return {
23
+ oclIDs: [atom.oclID].concat(atom.hydrogenOCLIDs),
24
+ nbAtoms: atom.nbAtoms + atom.nbAtoms * atom.nbHydrogens,
25
+ };
23
26
  }
24
27
  }
25
28
  return { oclIDs: [], nbAtoms: 0 };
26
29
  }
27
- export function findDatumAndSignalIndex(spectraData, id) {
30
+ export function findDatumAndSignalIndex(data, id) {
28
31
  // if datum could be found then the id is on range/zone level
29
- let datum = spectraData.find((_datum) => _datum.id === id);
32
+ let datum = data.find((_datum) => _datum.id === id);
30
33
  let signalIndex;
31
34
  if (!datum) {
32
35
  // figure out the datum via id
33
- for (const data of spectraData) {
34
- signalIndex = data.signals.findIndex((signal) => signal.id === id);
36
+ for (const record of data) {
37
+ signalIndex = record.signals.findIndex((signal) => signal.id === id);
35
38
  if (signalIndex >= 0) {
36
- datum = data;
39
+ datum = record;
37
40
  break;
38
41
  }
39
42
  }
40
43
  }
41
44
  return { datum, signalIndex };
42
45
  }
43
- export function getHighlightsOnHover(assignmentData, oclIDs, data) {
46
+ export function getHighlightsOnHover(assignments, oclIDs, data) {
44
47
  // set all IDs to highlight when hovering over an atom from assignment data
45
48
  let highlights = [];
46
- for (let key in assignmentData.assignment.assignment) {
47
- let datum, signalIndex;
48
- let stop = false;
49
- if ((assignmentData.assignment.assignment[key].x || []).some((_assigned) => oclIDs.includes(_assigned))) {
50
- highlights = highlights.concat(assignmentData.assignment.assignment[key].x);
51
- const result = findDatumAndSignalIndex(data, key);
52
- datum = result.datum;
53
- signalIndex = result.signalIndex;
54
- stop = true;
55
- }
56
- if ((assignmentData.assignment.assignment[key].y || []).some((_assigned) => oclIDs.includes(_assigned))) {
57
- highlights = highlights.concat(assignmentData.assignment.assignment[key].y);
58
- const result = findDatumAndSignalIndex(data, key);
59
- datum = result.datum;
60
- signalIndex = result.signalIndex;
61
- stop = true;
62
- }
63
- if (datum) {
64
- highlights.push(datum.id);
65
- if (signalIndex !== undefined) {
66
- highlights.push(datum.signals[signalIndex].id);
49
+ const assignmentsByKey = assignments.data.assignments;
50
+ for (const key in assignmentsByKey) {
51
+ const assignments = assignmentsByKey[key];
52
+ for (const axis in assignments) {
53
+ if (assignments[axis]?.some((oclKey) => oclIDs.includes(oclKey))) {
54
+ highlights = highlights.concat(assignments[axis]);
55
+ const { datum, signalIndex } = findDatumAndSignalIndex(data, key);
56
+ if (datum) {
57
+ highlights.push(datum.id);
58
+ if (signalIndex !== undefined) {
59
+ highlights.push(datum.signals[signalIndex].id);
60
+ }
61
+ }
67
62
  }
68
63
  }
69
- if (stop) {
70
- break;
71
- }
72
64
  }
73
65
  return highlights;
74
66
  }
75
- export function getCurrentDiaIDsToHighlight(assignmentData, displayerMode) {
76
- const assignmentOnHover = assignmentData.assignment.isOnHover
77
- ? assignmentData.assignment.assignment[assignmentData.assignment.onHoverID]
78
- : null;
79
- const axisOnHover = assignmentData.assignment.isOnHover
80
- ? assignmentData.assignment.onHoverAxis
81
- : null;
82
- return assignmentOnHover
83
- ? displayerMode === DISPLAYER_MODE.DM_1D
84
- ? assignmentOnHover.x || []
85
- : displayerMode === DISPLAYER_MODE.DM_2D
86
- ? axisOnHover
87
- ? axisOnHover === 'x'
88
- ? assignmentOnHover.x || []
89
- : axisOnHover === 'y'
90
- ? assignmentOnHover.y || []
91
- : (assignmentOnHover.x || []).concat(assignmentOnHover.y || [])
92
- : (assignmentOnHover.x || []).concat(assignmentOnHover.y || [])
93
- : []
94
- : [];
67
+ export function getCurrentDiaIDsToHighlight(assignmentData) {
68
+ const { highlighted, assignments } = assignmentData.data;
69
+ const assignment = highlighted ? assignments[highlighted.id] : null;
70
+ const axisHover = highlighted ? highlighted.axis : null;
71
+ if (axisHover && assignment && assignment[axisHover]) {
72
+ return assignment[axisHover];
73
+ }
74
+ else {
75
+ return (assignment?.x || []).concat(assignment?.y || []);
76
+ }
95
77
  }
96
- export function toggleDiaIDs(diaID, atomInformation) {
97
- let _diaID = diaID ? diaID.slice() : [];
78
+ export function toggleDiaIDs(diaIDs, atomInformation) {
79
+ let _diaIDs = diaIDs ? diaIDs.slice() : [];
98
80
  const { nbAtoms, oclIDs } = atomInformation;
99
81
  let tempNbAtoms = nbAtoms;
100
82
  oclIDs.forEach((_oclID) => {
101
- if (_diaID.includes(_oclID)) {
83
+ if (_diaIDs.includes(_oclID)) {
102
84
  tempNbAtoms *= -1;
103
- _diaID = _diaID.filter((_id) => _id !== _oclID);
85
+ _diaIDs = _diaIDs.filter((_id) => _id !== _oclID);
104
86
  }
105
87
  else {
106
- _diaID.push(_oclID);
88
+ _diaIDs.push(_oclID);
107
89
  }
108
90
  });
109
- return [_diaID, tempNbAtoms];
91
+ return [_diaIDs, tempNbAtoms];
110
92
  }
@@ -1,4 +1,4 @@
1
- export default function useAtomAssignment({ displayerMode, activeTab, zones, ranges, }: {
1
+ export default function useAtomAssignment({ displayerMode, activeTab: nucleus, zones, ranges, }: {
2
2
  displayerMode: any;
3
3
  activeTab: any;
4
4
  zones: any;
@@ -6,6 +6,6 @@ export default function useAtomAssignment({ displayerMode, activeTab, zones, ran
6
6
  }): {
7
7
  handleOnAtomHover: (atom: any) => void;
8
8
  handleOnClickAtom: (atom: any, event: any) => void;
9
- currentDiaIDsToHighlight: any;
9
+ currentDiaIDsToHighlight: string[];
10
10
  assignedDiaIDsMerged: any[];
11
11
  };