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
@@ -1,5 +1,5 @@
1
1
  import { Draft } from 'immer';
2
- import { Spectrum, Display1D, Display2D } from 'nmr-load-save';
2
+ import { Spectrum, Display1D, Display2D, SpectraColors } from 'nmr-load-save';
3
3
  import { NMRRange } from 'nmr-processing';
4
4
  import { SpectrumSimulationOptions } from '../../../data/data1d/spectrumSimulation';
5
5
  import { Nuclei, Nucleus } from '../../../data/types/common/Nucleus';
@@ -45,8 +45,9 @@ type GenerateSpectrumFromPublicationStringAction = ActionType<'GENERATE_SPECTRUM
45
45
  type ImportSpectraMetaInfoAction = ActionType<'IMPORT_SPECTRA_META_INFO', {
46
46
  spectraMeta: Record<string, Record<string, any>>;
47
47
  }>;
48
- type RecolorSpectraBasedOnDistinctValueAction = ActionType<'RECOLOR_SPECTRA_COLOR', {
48
+ type ReColorSpectraBasedOnDistinctValueAction = ActionType<'RECOLOR_SPECTRA_COLOR', {
49
49
  jpath?: string[];
50
+ customColors?: SpectraColors;
50
51
  }>;
51
52
  type OrderSpectraAction = ActionType<'ORDER_SPECTRA', {
52
53
  data: Spectrum[];
@@ -55,7 +56,7 @@ type SimulateSpectrumAction = ActionType<'SIMULATE_SPECTRUM', {
55
56
  keepSpectrum?: boolean;
56
57
  spinSystem: string;
57
58
  } & SpectrumSimulationOptions>;
58
- export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | RecolorSpectraBasedOnDistinctValueAction | OrderSpectraAction | SimulateSpectrumAction;
59
+ export type SpectrumActions = ActionType<'TOGGLE_SPECTRA_LEGEND'> | ChangeSpectrumVisibilityByIdAction | ChangeSpectraVisibilityByNucleusAction | ChangeActiveSpectrumAction | ChangeSpectrumSettingAction | DeleteSpectraAction | AddMissingProjectionAction | AlignSpectraAction | GenerateSpectrumFromPublicationStringAction | ImportSpectraMetaInfoAction | ReColorSpectraBasedOnDistinctValueAction | OrderSpectraAction | SimulateSpectrumAction;
59
60
  declare function setSpectraMetaInfo(draft: Draft<State>, spectraMetaInfo: Record<string, Record<string, any>>): void;
60
61
  declare function handleChangeSpectrumVisibilityById(draft: Draft<State>, action: ChangeSpectrumVisibilityByIdAction): void;
61
62
  declare function handleChangeSpectraVisibilityByNucleus(draft: Draft<State>, action: ChangeSpectraVisibilityByNucleusAction): void;
@@ -67,7 +68,7 @@ declare function handleAlignSpectraHandler(draft: Draft<State>, action: AlignSpe
67
68
  declare function handleGenerateSpectrumFromPublicationStringHandler(draft: Draft<State>, action: GenerateSpectrumFromPublicationStringAction): void;
68
69
  declare function handleImportSpectraMetaInfo(draft: Draft<State>, action: ImportSpectraMetaInfoAction): void;
69
70
  declare function handleToggleSpectraLegend(draft: Draft<State>): void;
70
- declare function handleRecolorSpectraBasedOnDistinctValue(draft: Draft<State>, action: RecolorSpectraBasedOnDistinctValueAction): void;
71
+ declare function handleRecolorSpectraBasedOnDistinctValue(draft: Draft<State>, action: ReColorSpectraBasedOnDistinctValueAction): void;
71
72
  declare function handleOrderSpectra(draft: Draft<State>, action: OrderSpectraAction): void;
72
73
  declare function handleSimulateSpectrum(draft: Draft<State>, simulateSpectrumOptions: SimulateSpectrumAction): void;
73
74
  export { handleChangeSpectrumVisibilityById, handleChangeSpectraVisibilityByNucleus, handleChangeActiveSpectrum, handleChangeSpectrumSetting, handleDeleteSpectra, handleAddMissingProjectionHandler, handleAlignSpectraHandler, handleGenerateSpectrumFromPublicationStringHandler, handleImportSpectraMetaInfo, handleToggleSpectraLegend, handleRecolorSpectraBasedOnDistinctValue, handleOrderSpectra, handleSimulateSpectrum, setSpectraMetaInfo, };
@@ -320,7 +320,7 @@ function handleToggleSpectraLegend(draft) {
320
320
  //action
321
321
  function handleRecolorSpectraBasedOnDistinctValue(draft, action) {
322
322
  const { data, view: { spectra: { activeTab }, }, } = draft;
323
- const { jpath = null } = action.payload;
323
+ const { jpath = null, customColors } = action.payload;
324
324
  const spectra = getSpectraByNucleus(activeTab, data);
325
325
  if (jpath) {
326
326
  //recolor spectra based on distinct value
@@ -352,12 +352,16 @@ function handleRecolorSpectraBasedOnDistinctValue(draft, action) {
352
352
  spectrum.display.color = get1DColor(spectrum, {
353
353
  usedColors,
354
354
  regenerate: true,
355
+ random: !customColors,
356
+ colors: customColors?.oneDimension || [],
355
357
  }).color;
356
358
  }
357
359
  else {
358
360
  const { positiveColor, negativeColor } = get2DColor(spectrum, {
359
361
  usedColors,
360
362
  regenerate: true,
363
+ random: !customColors,
364
+ colors: customColors?.twoDimensions || [],
361
365
  });
362
366
  spectrum.display.positiveColor = positiveColor;
363
367
  spectrum.display.negativeColor = negativeColor;
@@ -65,7 +65,18 @@ type UnlinkZoneAction = ActionType<'UNLINK_ZONE', UnlinkZoneProps>;
65
65
  type ToggleZonesViewAction = ActionType<'TOGGLE_ZONES_VIEW_PROPERTY', {
66
66
  key: keyof FilterType<ZonesViewState, boolean>;
67
67
  }>;
68
- export type ZonesActions = AutoZonesDetectionAction | ChangeZonesFactorAction | Add2dZoneAction | ChangeZoneSignalDeltaAction | ChangeZoneSignalKindAction | DeleteZoneAction | DeleteSignal2DAction | SetSignalPathLengthAction | SetZoneDiaIDAction | SaveEditedZoneAction | UnlinkZoneAction | ToggleZonesViewAction | ActionType<'AUTO_ZONES_SPECTRA_PICKING'>;
68
+ type ChangeZoneAssignmentLabelAction = ActionType<'CHANGE_ZONE_ASSIGNMENT_LABEL', {
69
+ zoneID: string;
70
+ value: string;
71
+ }>;
72
+ type SetZoneAssignmentLabelCoordinationAction = ActionType<'SET_ZONE_ASSIGNMENT_LABEL_COORDINATION', {
73
+ zoneID: string;
74
+ coordination: {
75
+ x: number;
76
+ y: number;
77
+ };
78
+ }>;
79
+ export type ZonesActions = AutoZonesDetectionAction | ChangeZonesFactorAction | Add2dZoneAction | ChangeZoneSignalDeltaAction | ChangeZoneSignalKindAction | DeleteZoneAction | DeleteSignal2DAction | SetSignalPathLengthAction | SetZoneDiaIDAction | SaveEditedZoneAction | UnlinkZoneAction | ToggleZonesViewAction | ChangeZoneAssignmentLabelAction | SetZoneAssignmentLabelCoordinationAction | ActionType<'AUTO_ZONES_SPECTRA_PICKING'>;
69
80
  declare function handleChangeZonesFactor(draft: Draft<State>, action: ChangeZonesFactorAction): void;
70
81
  declare function handleAdd2dZone(draft: Draft<State>, action: Add2dZoneAction): void;
71
82
  declare function handleAutoZonesDetection(draft: Draft<State>, action: AutoZonesDetectionAction): void;
@@ -81,4 +92,6 @@ declare function handleUnlinkZone(draft: Draft<State>, action: UnlinkZoneAction)
81
92
  declare function handleSetDiaIDZone(draft: Draft<State>, action: SetZoneDiaIDAction): void;
82
93
  declare function handleSaveEditedZone(draft: Draft<State>, action: SaveEditedZoneAction): void;
83
94
  declare function handleToggleZonesViewProperty(draft: Draft<State>, action: ToggleZonesViewAction): void;
84
- export { handleAdd2dZone, handleAutoZonesDetection, handleDeleteSignal, deleteSignal2D, handleDeleteZone, handleChangeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, unlinkZone, handleSaveEditedZone, handleSetDiaIDZone, handleSetSignalPathLength, handleChangeZonesFactor, handleAutoSpectraZonesDetection, handleToggleZonesViewProperty, };
95
+ declare function handleChangeZoneAssignmentLabel(draft: Draft<State>, action: ChangeZoneAssignmentLabelAction): void;
96
+ declare function handleSetZoneAssignmentLabelCoordination(draft: Draft<State>, action: SetZoneAssignmentLabelCoordinationAction): void;
97
+ export { handleAdd2dZone, handleAutoZonesDetection, handleDeleteSignal, deleteSignal2D, handleDeleteZone, handleChangeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, unlinkZone, handleSaveEditedZone, handleSetDiaIDZone, handleSetSignalPathLength, handleChangeZonesFactor, handleAutoSpectraZonesDetection, handleToggleZonesViewProperty, handleChangeZoneAssignmentLabel, handleSetZoneAssignmentLabelCoordination, };
@@ -3,7 +3,7 @@ import lodashCloneDeep from 'lodash/cloneDeep';
3
3
  import { setPathLength } from 'nmr-correlation';
4
4
  import { Filters, FiltersManager } from 'nmr-processing';
5
5
  import { DATUM_KIND, SIGNAL_INLCUDED_KINDS, } from '../../../data/constants/signalsKinds';
6
- import { changeZoneSignal, detectZones, detectZonesManual, } from '../../../data/data2d/Spectrum2D';
6
+ import { changeZoneSignal, detectZones, detectZonesManual, isSpectrum2D, } from '../../../data/data2d/Spectrum2D';
7
7
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/ZoneUtilities';
8
8
  import { isNumber } from '../../../data/utilities/isNumber';
9
9
  import { defaultZonesViewState } from '../../hooks/useActiveSpectrumZonesViewState';
@@ -233,23 +233,57 @@ function handleSaveEditedZone(draft, action) {
233
233
  handleUpdateCorrelations(draft);
234
234
  }
235
235
  }
236
+ function initializeZoneViewObject(draft, spectrumID) {
237
+ const zonesView = draft.view.zones;
238
+ if (spectrumID in zonesView)
239
+ return;
240
+ const defaultZonesView = { ...defaultZonesViewState };
241
+ zonesView[spectrumID] = defaultZonesView;
242
+ }
236
243
  function togglePeaksViewProperty(draft, key) {
237
244
  const activeSpectrum = getActiveSpectrum(draft);
238
- if (activeSpectrum?.id) {
239
- const zonesView = draft.view.zones;
240
- if (zonesView[activeSpectrum.id]) {
241
- zonesView[activeSpectrum.id][key] = !zonesView[activeSpectrum.id][key];
242
- }
243
- else {
244
- const defaultZonesView = { ...defaultZonesViewState };
245
- defaultZonesView[key] = !defaultZonesView[key];
246
- zonesView[activeSpectrum.id] = defaultZonesView;
247
- }
248
- }
245
+ if (!activeSpectrum?.id)
246
+ return;
247
+ initializeZoneViewObject(draft, activeSpectrum.id);
248
+ const zonesView = draft.view.zones;
249
+ zonesView[activeSpectrum.id][key] = !zonesView[activeSpectrum.id][key];
249
250
  }
250
251
  //action
251
252
  function handleToggleZonesViewProperty(draft, action) {
252
253
  const { key } = action.payload;
253
254
  togglePeaksViewProperty(draft, key);
254
255
  }
255
- export { handleAdd2dZone, handleAutoZonesDetection, handleDeleteSignal, deleteSignal2D, handleDeleteZone, handleChangeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, unlinkZone, handleSaveEditedZone, handleSetDiaIDZone, handleSetSignalPathLength, handleChangeZonesFactor, handleAutoSpectraZonesDetection, handleToggleZonesViewProperty, };
256
+ function handleChangeZoneAssignmentLabel(draft, action) {
257
+ const { zoneID, value } = action.payload;
258
+ const activeSpectrum = getActiveSpectrum(draft);
259
+ if (!activeSpectrum?.id)
260
+ return;
261
+ const { index } = activeSpectrum;
262
+ const spectrum = draft.data[index];
263
+ if (!isSpectrum2D(spectrum))
264
+ return;
265
+ initializeZoneViewObject(draft, activeSpectrum.id);
266
+ const zoneView = draft.view.zones[spectrum.id];
267
+ if (!zoneView.showAssignmentsLabels) {
268
+ zoneView.showAssignmentsLabels = true;
269
+ }
270
+ const zone = spectrum.zones.values.find((zone) => zone.id === zoneID);
271
+ if (zone) {
272
+ zone.assignment = value;
273
+ if (!value) {
274
+ // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
275
+ delete zoneView.assignmentsLabelsCoordinates[zoneID];
276
+ }
277
+ }
278
+ }
279
+ function handleSetZoneAssignmentLabelCoordination(draft, action) {
280
+ const { zoneID, coordination } = action.payload;
281
+ const activeSpectrum = getActiveSpectrum(draft);
282
+ if (!activeSpectrum)
283
+ return;
284
+ initializeZoneViewObject(draft, activeSpectrum.id);
285
+ const zonesView = draft.view.zones;
286
+ zonesView[activeSpectrum.id].assignmentsLabelsCoordinates[zoneID] =
287
+ coordination;
288
+ }
289
+ export { handleAdd2dZone, handleAutoZonesDetection, handleDeleteSignal, deleteSignal2D, handleDeleteZone, handleChangeZoneSignalDelta, handleChangeZoneSignalKind, handleUnlinkZone, unlinkZone, handleSaveEditedZone, handleSetDiaIDZone, handleSetSignalPathLength, handleChangeZonesFactor, handleAutoSpectraZonesDetection, handleToggleZonesViewProperty, handleChangeZoneAssignmentLabel, handleSetZoneAssignmentLabelCoordination, };
@@ -3,3 +3,4 @@ import { RangesViewState } from 'nmr-load-save';
3
3
  import { State } from '../Reducer';
4
4
  export declare function setRangesViewProperty<T extends keyof RangesViewState>(draft: Draft<State>, key: T, value: (value: RangesViewState[T]) => RangesViewState[T]): void;
5
5
  export declare function setRangesViewProperty<T extends keyof RangesViewState>(draft: Draft<State>, key: T, value: RangesViewState[T]): void;
6
+ export declare function initializeRangeViewObject(draft: Draft<State>, spectrumID: string): void;
@@ -1,19 +1,19 @@
1
1
  import { defaultRangesViewState } from '../../hooks/useActiveSpectrumRangesViewState';
2
2
  import { getActiveSpectrum } from './getActiveSpectrum';
3
3
  export function setRangesViewProperty(draft, key, value) {
4
- const viewData = draft.view.ranges;
4
+ const rangesView = draft.view.ranges;
5
5
  const activeSpectrum = getActiveSpectrum(draft);
6
6
  if (!activeSpectrum?.id)
7
7
  return;
8
8
  const id = activeSpectrum.id;
9
- if (viewData[id]) {
10
- viewData[id][key] =
11
- typeof value === 'function' ? value(viewData[id][key]) : value;
12
- }
13
- else {
14
- const defaultView = { ...defaultRangesViewState };
15
- defaultView[key] =
16
- typeof value === 'function' ? value(defaultView[key]) : value;
17
- viewData[id] = defaultView;
18
- }
9
+ initializeRangeViewObject(draft, id);
10
+ rangesView[id][key] =
11
+ typeof value === 'function' ? value(rangesView[id][key]) : value;
12
+ }
13
+ export function initializeRangeViewObject(draft, spectrumID) {
14
+ const rangesView = draft.view.ranges;
15
+ if (spectrumID in rangesView)
16
+ return;
17
+ const defaultRangesView = { ...defaultRangesViewState };
18
+ rangesView[spectrumID] = defaultRangesView;
19
19
  }
@@ -1,27 +1,8 @@
1
- import { v4 } from '@lukeed/uuid';
2
- import lodashMerge from 'lodash/merge';
3
- import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
4
- import { workspaceDefaultProperties } from '../../../workspaces/workspaceDefaultProperties';
5
1
  export function addWorkspace(draft, action) {
6
2
  const { workspaceKey, data } = action.payload;
7
- // eslint-disable-next-line unicorn/prefer-logical-operator-over-ternary
8
- const workSpaceData = data
9
- ? data
10
- : draft.workspaces?.[draft.workspace.current];
11
- if (workSpaceData) {
12
- const newWorkSpace = lodashMerge({}, workspaceDefaultProperties, workSpaceData, {
13
- version: 1,
14
- label: workspaceKey,
15
- source: 'user',
16
- });
17
- const newWorkspaceKey = v4();
18
- const localData = getLocalStorage('nmr-general-settings');
19
- localData.currentWorkspace = newWorkspaceKey;
20
- localData.workspaces[newWorkspaceKey] = newWorkSpace;
21
- storeData('nmr-general-settings', JSON.stringify(localData));
22
- draft.workspaces[newWorkspaceKey] = newWorkSpace;
23
- draft.originalWorkspaces[newWorkspaceKey] =
24
- newWorkSpace;
25
- draft.workspace.current = newWorkspaceKey;
3
+ if (data) {
4
+ draft.workspaces[workspaceKey] = data;
5
+ draft.originalWorkspaces[workspaceKey] = data;
6
+ draft.workspace.current = workspaceKey;
26
7
  }
27
8
  }
@@ -4,7 +4,7 @@ import { getMultipleSpectraAnalysisDefaultValues } from '../panelsPreferencesDef
4
4
  import { getActiveWorkspace } from '../utilities/getActiveWorkspace';
5
5
  export function analyzeSpectra(draft, action) {
6
6
  const currentWorkspacePreferences = getActiveWorkspace(draft);
7
- const panels = currentWorkspacePreferences.formatting.panels;
7
+ const panels = currentWorkspacePreferences.panels;
8
8
  const { start, end, nucleus, columnKey } = action.payload;
9
9
  if (!panels.multipleSpectraAnalysis) {
10
10
  panels.multipleSpectraAnalysis =
@@ -21,20 +21,20 @@ export function analyzeSpectra(draft, action) {
21
21
  export function changeAnalysisColumnValueKey(draft, action) {
22
22
  const { columnKey, valueKey, nucleus } = action.payload;
23
23
  const currentWorkspacePreferences = getActiveWorkspace(draft);
24
- const panels = currentWorkspacePreferences.formatting.panels;
24
+ const panels = currentWorkspacePreferences.panels;
25
25
  MultipleAnalysis.changeColumnValueKey(panels.multipleSpectraAnalysis, nucleus, columnKey, valueKey);
26
26
  }
27
27
  export function deleteAnalysisColumn(draft, action) {
28
28
  const { columnKey, nucleus } = action.payload;
29
29
  const currentWorkspacePreferences = getActiveWorkspace(draft);
30
- const panels = currentWorkspacePreferences.formatting.panels;
30
+ const panels = currentWorkspacePreferences.panels;
31
31
  MultipleAnalysis.deleteSpectraAnalysis(panels.multipleSpectraAnalysis, columnKey, nucleus);
32
32
  }
33
33
  export function setSpectraAnalysisPanelsPreferences(draft, action) {
34
34
  if (action.payload) {
35
35
  const currentWorkspacePreferences = getActiveWorkspace(draft);
36
36
  const { nucleus, data } = action.payload;
37
- const panels = currentWorkspacePreferences.formatting.panels;
37
+ const panels = currentWorkspacePreferences.panels;
38
38
  if (!panels?.multipleSpectraAnalysis) {
39
39
  panels.multipleSpectraAnalysis =
40
40
  getMultipleSpectraAnalysisDefaultValues(nucleus);
@@ -1,4 +1,3 @@
1
- import { getLocalStorage } from '../../../utility/LocalStorage';
2
1
  import { WORKSPACES_KEYS } from '../preferencesReducer';
3
2
  import { initWorkspace } from '../utilities/initWorkspace';
4
3
  import { mapWorkspaces } from '../utilities/mapWorkspaces';
@@ -7,8 +6,7 @@ function getWorkspace(draft, workspace) {
7
6
  }
8
7
  export function initPreferences(draft, action) {
9
8
  if (action.payload) {
10
- const localData = getLocalStorage('nmr-general-settings');
11
- const { dispatch, workspace, customWorkspaces: cw, preferences, } = action.payload;
9
+ const { dispatch, workspace, customWorkspaces: cw, preferences, currentWorkspace, } = action.payload;
12
10
  const customWorkspaces = mapWorkspaces(cw, { source: 'custom' });
13
11
  draft.workspaces = {
14
12
  ...draft.workspaces,
@@ -39,7 +37,7 @@ export function initPreferences(draft, action) {
39
37
  };
40
38
  }
41
39
  else {
42
- const _workspace = getWorkspace(draft, localData.currentWorkspace);
40
+ const _workspace = getWorkspace(draft, currentWorkspace);
43
41
  draft.workspace = { current: _workspace, base: null };
44
42
  }
45
43
  if (preferences) {
@@ -3,7 +3,7 @@ import { getActiveWorkspace } from '../utilities/getActiveWorkspace';
3
3
  function addExclusionZone(draft, action) {
4
4
  const { zone, range, nucleus } = action.payload;
5
5
  const currentWorkspacePreferences = getActiveWorkspace(draft);
6
- const panels = currentWorkspacePreferences.formatting.panels;
6
+ const panels = currentWorkspacePreferences.panels;
7
7
  const exclusionZone = {
8
8
  id: v4(),
9
9
  ...zone,
@@ -27,7 +27,7 @@ function addExclusionZone(draft, action) {
27
27
  function deleteExclusionZone(draft, action) {
28
28
  const { zone, nucleus } = action.payload;
29
29
  const currentWorkspacePreferences = getActiveWorkspace(draft);
30
- const panels = currentWorkspacePreferences.formatting.panels;
30
+ const panels = currentWorkspacePreferences.panels;
31
31
  if (panels.matrixGeneration?.[nucleus]) {
32
32
  const options = panels.matrixGeneration[nucleus];
33
33
  options.exclusionsZones = options.exclusionsZones.filter((_zone) => _zone.id !== zone.id);
@@ -36,7 +36,7 @@ function deleteExclusionZone(draft, action) {
36
36
  function setMatrixGenerationOptions(draft, action) {
37
37
  const { options, nucleus } = action.payload;
38
38
  const currentWorkspacePreferences = getActiveWorkspace(draft);
39
- const panels = currentWorkspacePreferences.formatting.panels;
39
+ const panels = currentWorkspacePreferences.panels;
40
40
  panels.matrixGeneration = { ...panels.matrixGeneration, [nucleus]: options };
41
41
  }
42
42
  export { addExclusionZone, deleteExclusionZone, setMatrixGenerationOptions };
@@ -1,13 +1,8 @@
1
- import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
2
1
  export function removeWorkspace(draft, action) {
3
2
  const { workspace } = action.payload;
4
3
  if (workspace === draft.workspace.current) {
5
4
  draft.workspace.current = 'default';
6
5
  }
7
- const localData = getLocalStorage('nmr-general-settings');
8
6
  // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
9
7
  delete draft.workspaces[workspace];
10
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
11
- delete localData.workspaces[workspace];
12
- storeData('nmr-general-settings', JSON.stringify(localData));
13
8
  }
@@ -1,10 +1,6 @@
1
- import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
2
1
  export function setActiveWorkspace(draft, action) {
3
2
  if (action.payload) {
4
3
  const { workspace } = action.payload;
5
- const localData = getLocalStorage('nmr-general-settings');
6
4
  draft.workspace.current = workspace;
7
- localData.currentWorkspace = workspace;
8
- storeData('nmr-general-settings', JSON.stringify(localData));
9
5
  }
10
6
  }
@@ -3,7 +3,7 @@ export function setPanelsPreferences(draft, action) {
3
3
  if (action.payload) {
4
4
  const currentWorkspacePreferences = getActiveWorkspace(draft);
5
5
  const { key, value } = action.payload;
6
- const panels = currentWorkspacePreferences.formatting.panels;
6
+ const panels = currentWorkspacePreferences.panels;
7
7
  if (value?.nuclei) {
8
8
  const { nuclei, ...commonPreferences } = value;
9
9
  panels[key] = {
@@ -1,27 +1,13 @@
1
1
  import cloneDeep from 'lodash/cloneDeep';
2
- import { getLocalStorage, storeData } from '../../../utility/LocalStorage';
3
2
  import { getActiveWorkspace } from '../utilities/getActiveWorkspace';
4
- import { mapNucleiFormatting } from '../utilities/mapNucleiFormatting';
5
3
  export function setPreferences(draft, action) {
6
- const localData = getLocalStorage('nmr-general-settings');
7
4
  const currentWorkspacePreferences = getActiveWorkspace(draft);
8
5
  if (action.payload) {
9
- const { formatting, ...restPreferences } = action.payload;
6
+ const preferences = action.payload;
10
7
  draft.workspaces[draft.workspace.current] = {
11
8
  ...currentWorkspacePreferences,
12
- ...restPreferences,
13
- formatting: mapNucleiFormatting(formatting),
9
+ ...preferences,
14
10
  };
15
11
  }
16
- if (draft.workspaces[draft.workspace.current].source === 'user') {
17
- draft.workspaces[draft.workspace.current].version++;
18
- storeData('nmr-general-settings', JSON.stringify({
19
- ...localData,
20
- workspaces: {
21
- ...localData.workspaces,
22
- [draft.workspace.current]: draft.workspaces[draft.workspace.current],
23
- },
24
- }));
25
- }
26
12
  draft.originalWorkspaces[draft.workspace.current] = cloneDeep(draft.workspaces[draft.workspace.current]);
27
13
  }
@@ -11,8 +11,9 @@ export function setWorkspace(draft, action) {
11
11
  }
12
12
  else if (action.payload.workspaceSource === 'nmriumFile') {
13
13
  const workspaceData = { label: 'NMRium File', source: 'nmriumFile' };
14
- draft.workspaces[WORKSPACES_KEYS.nmriumKey] = initWorkspace(action.payload.data, workspaceData);
15
- draft.originalWorkspaces[WORKSPACES_KEYS.nmriumKey] = initWorkspace(action.payload.data, workspaceData);
16
- draft.workspace.current = WORKSPACES_KEYS.nmriumKey;
14
+ const workspaceKey = WORKSPACES_KEYS.nmriumKey;
15
+ draft.workspaces[workspaceKey] = initWorkspace(action.payload.data, workspaceData);
16
+ draft.originalWorkspaces[workspaceKey] = initWorkspace(action.payload.data, workspaceData);
17
+ draft.workspace = { current: workspaceKey, base: workspaceKey };
17
18
  }
18
19
  }
@@ -8,6 +8,11 @@ export declare const WORKSPACES_KEYS: {
8
8
  componentKey: string;
9
9
  nmriumKey: string;
10
10
  };
11
+ export interface Settings {
12
+ version: number;
13
+ workspaces: Record<string, WorkspaceWithSource>;
14
+ currentWorkspace: any;
15
+ }
11
16
  type InitPreferencesAction = ActionType<'INIT_PREFERENCES', {
12
17
  display: NMRiumPreferences;
13
18
  workspace: NMRiumWorkspace;
@@ -101,6 +106,8 @@ export interface PreferencesState {
101
106
  };
102
107
  }
103
108
  export declare const preferencesInitialState: PreferencesState;
109
+ export declare function readSettings(): Settings;
110
+ export declare function updateSettings(settings: Settings): void;
104
111
  export declare function initPreferencesState(state: PreferencesState): PreferencesState;
105
112
  declare const preferencesReducer: Reducer<PreferencesState, any>;
106
113
  export default preferencesReducer;
@@ -1,5 +1,6 @@
1
1
  import { produce } from 'immer';
2
- import { getLocalStorage, removeData, storeData, } from '../../utility/LocalStorage';
2
+ import { CURRENT_EXPORT_VERSION, migrateSettings, } from 'nmr-load-save';
3
+ import { getLocalStorage, storeData } from '../../utility/LocalStorage';
3
4
  import Workspaces from '../../workspaces';
4
5
  import { addWorkspace } from './actions/addWorkspace';
5
6
  import { analyzeSpectra, changeAnalysisColumnValueKey, deleteAnalysisColumn, setSpectraAnalysisPanelsPreferences, } from './actions/analyzeSpectra';
@@ -13,7 +14,7 @@ import { setPreferences } from './actions/setPreferences';
13
14
  import { setVerticalSplitterPosition } from './actions/setVerticalSplitterPosition';
14
15
  import { setWorkspace } from './actions/setWorkspace';
15
16
  import { mapWorkspaces } from './utilities/mapWorkspaces';
16
- const LOCAL_STORAGE_VERSION = 17;
17
+ const LOCAL_STORAGE_SETTINGS_KEY = 'nmr-general-settings';
17
18
  export const WORKSPACES_KEYS = {
18
19
  componentKey: `nmrium-component-workspace`,
19
20
  nmriumKey: `nmrium-file-workspace`,
@@ -49,7 +50,7 @@ export const WORKSPACES = [
49
50
  },
50
51
  ];
51
52
  export const preferencesInitialState = {
52
- version: LOCAL_STORAGE_VERSION,
53
+ version: CURRENT_EXPORT_VERSION,
53
54
  workspaces: {},
54
55
  originalWorkspaces: {},
55
56
  dispatch: () => null,
@@ -58,26 +59,28 @@ export const preferencesInitialState = {
58
59
  base: null,
59
60
  },
60
61
  };
62
+ export function readSettings() {
63
+ const localData = getLocalStorage(LOCAL_STORAGE_SETTINGS_KEY) || {
64
+ version: CURRENT_EXPORT_VERSION,
65
+ currentWorkspace: null,
66
+ workspaces: {},
67
+ };
68
+ return migrateSettings(localData);
69
+ }
70
+ export function updateSettings(settings) {
71
+ storeData(LOCAL_STORAGE_SETTINGS_KEY, JSON.stringify(settings));
72
+ }
61
73
  export function initPreferencesState(state) {
62
- const nmrLocalStorageVersion = getLocalStorage('nmr-local-storage-version', false);
63
- const localData = getLocalStorage('nmr-general-settings');
64
- // remove old nmr-local-storage-version key
65
- if (nmrLocalStorageVersion && localData?.version) {
66
- removeData('nmr-local-storage-version');
67
- }
74
+ const localData = getLocalStorage(LOCAL_STORAGE_SETTINGS_KEY);
75
+ const settings = readSettings();
68
76
  // if the local setting version != current settings version number
69
- if (!localData?.version || localData?.version !== LOCAL_STORAGE_VERSION) {
70
- removeData('nmr-general-settings');
71
- const data = {
72
- version: LOCAL_STORAGE_VERSION,
73
- workspaces: {},
74
- };
75
- storeData('nmr-general-settings', JSON.stringify(data));
77
+ if (localData?.version !== CURRENT_EXPORT_VERSION) {
78
+ updateSettings(settings);
76
79
  }
77
80
  const predefinedWorkspaces = mapWorkspaces(Workspaces, {
78
81
  source: 'predefined',
79
82
  });
80
- const localWorkspaces = mapWorkspaces(localData?.workspaces || {}, {
83
+ const localWorkspaces = mapWorkspaces(settings?.workspaces || {}, {
81
84
  source: 'user',
82
85
  });
83
86
  return {
@@ -85,7 +88,7 @@ export function initPreferencesState(state) {
85
88
  originalWorkspaces: { ...predefinedWorkspaces, ...localWorkspaces },
86
89
  workspaces: { ...predefinedWorkspaces, ...localWorkspaces },
87
90
  workspace: {
88
- current: localData?.currentWorkspace || 'default',
91
+ current: settings?.currentWorkspace || 'default',
89
92
  base: null,
90
93
  },
91
94
  };