nmrium 0.52.0 → 0.54.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 (100) hide show
  1. package/lib/component/1d/Viewer1D.js +48 -17
  2. package/lib/component/1d/ranges/AssignmentLabel.d.ts +7 -0
  3. package/lib/component/1d/ranges/AssignmentLabel.js +10 -0
  4. package/lib/component/1d/ranges/Range.js +15 -6
  5. package/lib/component/1d/tool/XLabelPointer.js +4 -12
  6. package/lib/component/2d/tools/XYLabelPointer.js +3 -9
  7. package/lib/component/context/LoggerContext.js +11 -4
  8. package/lib/component/elements/CloseButton.d.ts +1 -1
  9. package/lib/component/elements/CustomToolTip.d.ts +8 -0
  10. package/lib/component/elements/CustomToolTip.js +107 -0
  11. package/lib/component/elements/EditableColumn.js +6 -5
  12. package/lib/component/elements/SaveButton.d.ts +1 -1
  13. package/lib/component/elements/formik/FormikError.js +2 -4
  14. package/lib/component/elements/formik/FormikInput.js +2 -2
  15. package/lib/component/header/Header.js +1 -1
  16. package/lib/component/header/PhaseCorrectionTwoDimensionsPanel.js +41 -10
  17. package/lib/component/hooks/useActiveSpectrumRangesViewState.js +1 -0
  18. package/lib/component/hooks/useActiveSpectrumZonesViewState.js +1 -0
  19. package/lib/component/hooks/useToolsFunctions.js +7 -1
  20. package/lib/component/main/NMRiumStateProvider.js +12 -2
  21. package/lib/component/modal/AboutPredictionModal.js +1 -1
  22. package/lib/component/modal/AboutSpectrumSimulationModal.js +1 -1
  23. package/lib/component/modal/CopyClipboardModal.js +1 -1
  24. package/lib/component/modal/EditPeakShapeModal.js +1 -1
  25. package/lib/component/modal/ImportPublicationStringModal.d.ts +5 -3
  26. package/lib/component/modal/ImportPublicationStringModal.js +18 -9
  27. package/lib/component/modal/PredictSpectraModal.js +1 -1
  28. package/lib/component/modal/aboutUs/AboutUsModal.js +1 -1
  29. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  30. package/lib/component/modal/editRange/EditRangeModal.js +1 -1
  31. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalJCouplingsTable.js +1 -1
  32. package/lib/component/modal/editRange/forms/components/signal-tabs/SignalPeaksTable.js +1 -1
  33. package/lib/component/modal/editZone/EditZoneModal.js +1 -1
  34. package/lib/component/modal/setting/GeneralSettings.js +12 -19
  35. package/lib/component/panels/AutomaticAssignment/AutomaticAssignment.js +2 -2
  36. package/lib/component/panels/IntegralsPanel/IntegralPanel.js +2 -2
  37. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +2 -2
  38. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +1 -1
  39. package/lib/component/panels/PeaksPanel/PeaksPanel.js +5 -5
  40. package/lib/component/panels/RangesPanel/RangesHeader.js +29 -15
  41. package/lib/component/panels/RangesPanel/RangesPreferences.js +19 -13
  42. package/lib/component/panels/RangesPanel/RangesTable.js +1 -1
  43. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -1
  44. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentColumn.d.ts +7 -0
  45. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentColumn.js +16 -0
  46. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +22 -8
  47. package/lib/component/panels/SummaryPanel/CorrelationTable/editLink/EditLinkModal.js +1 -1
  48. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.d.ts +5 -5
  49. package/lib/component/panels/SummaryPanel/SetMolecularFormulaModal.js +79 -89
  50. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.d.ts +5 -4
  51. package/lib/component/panels/SummaryPanel/SetShiftTolerancesModal.js +66 -98
  52. package/lib/component/panels/SummaryPanel/SummaryPanel.js +13 -32
  53. package/lib/component/panels/ZonesPanel/ZonesPanel.js +4 -4
  54. package/lib/component/panels/databasePanel/DatabaseSearchOptions.js +2 -2
  55. package/lib/component/panels/header/DefaultPanelHeader.js +2 -2
  56. package/lib/component/panels/header/PreferencesHeader.js +1 -1
  57. package/lib/component/panels/header/SpectraAutomaticPickingButton.js +1 -1
  58. package/lib/component/panels/multipleAnalysisPanel/MultipleSpectraAnalysisPanel.js +4 -4
  59. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +8 -1
  60. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +1 -1
  61. package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +1 -1
  62. package/lib/component/reducer/Reducer.js +4 -0
  63. package/lib/component/reducer/actions/FiltersActions.d.ts +3 -2
  64. package/lib/component/reducer/actions/FiltersActions.js +364 -318
  65. package/lib/component/reducer/actions/MoleculeActions.js +1 -1
  66. package/lib/component/reducer/actions/RangesActions.d.ts +9 -5
  67. package/lib/component/reducer/actions/RangesActions.js +31 -21
  68. package/lib/component/reducer/actions/SpectraActions.d.ts +5 -4
  69. package/lib/component/reducer/actions/SpectraActions.js +5 -1
  70. package/lib/component/reducer/actions/ToolsActions.js +13 -20
  71. package/lib/component/reducer/preferences/actions/setWorkspace.js +4 -3
  72. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +6 -4
  73. package/lib/component/toolbar/ToolBar.js +112 -26
  74. package/lib/component/utility/export.js +1 -1
  75. package/lib/component/workspaces/workspaceDefaultProperties.js +7 -12
  76. package/lib/data/data1d/Spectrum1D/get1DColor.d.ts +10 -3
  77. package/lib/data/data1d/Spectrum1D/get1DColor.js +28 -2
  78. package/lib/data/data1d/Spectrum1D/index.d.ts +2 -2
  79. package/lib/data/data1d/Spectrum1D/index.js +2 -2
  80. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +50 -0
  81. package/lib/data/data1d/Spectrum1D/ranges/createRange.js +51 -0
  82. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +2 -1
  83. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.js +4 -2
  84. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +52 -0
  85. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.js +28 -0
  86. package/lib/data/data2d/Spectrum2D/get2DColor.d.ts +11 -3
  87. package/lib/data/data2d/Spectrum2D/get2DColor.js +20 -4
  88. package/lib/data/data2d/Spectrum2D/getSlice.js +1 -1
  89. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +1 -0
  90. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +1 -0
  91. package/lib/data/utilities/generateColor.d.ts +7 -3
  92. package/lib/data/utilities/generateColor.js +5 -17
  93. package/lib/versionInfo.js +1 -1
  94. package/package.json +29 -29
  95. package/lib/component/elements/MolecularFormulaInput.d.ts +0 -6
  96. package/lib/component/elements/MolecularFormulaInput.js +0 -63
  97. package/lib/data/data1d/Spectrum1D/ranges/addRange.d.ts +0 -7
  98. package/lib/data/data1d/Spectrum1D/ranges/addRange.js +0 -31
  99. package/lib/data/data1d/Spectrum1D/ranges/changeRange.d.ts +0 -3
  100. package/lib/data/data1d/Spectrum1D/ranges/changeRange.js +0 -32
@@ -86,7 +86,7 @@ function handleDeleteMolecule(draft, action) {
86
86
  function handlePredictSpectraFromMolecule(draft, action) {
87
87
  const { logger, predictedSpectra, options, molecule, action: predictionAction = 'save', } = action.payload;
88
88
  checkPredictions(predictedSpectra, options, molecule.molfile, logger);
89
- const color = generateColor(false, draft.usedColors['1d']);
89
+ const color = generateColor({ usedColors: draft.usedColors['1d'] });
90
90
  const spectraIds = [];
91
91
  for (const spectrum of generateSpectra(predictedSpectra, options, color, logger)) {
92
92
  draft.data.push(spectrum);
@@ -49,8 +49,7 @@ type ChangeRangeSumAction = ActionType<'CHANGE_RANGE_SUM', {
49
49
  options: SetSumOptions;
50
50
  }>;
51
51
  type AddRangeAction = ActionType<'ADD_RANGE', {
52
- startX: number;
53
- endX: number;
52
+ range: Range;
54
53
  }>;
55
54
  type ChangeRangeRelativeValueAction = ActionType<'CHANGE_RANGE_RELATIVE', ChangeRangeRelativeValueProps>;
56
55
  type ChangeRangeSignalValueAction = ActionType<'CHANGE_RANGE_SIGNAL_VALUE', {
@@ -62,7 +61,7 @@ type UpdateRangAction = ActionType<'UPDATE_RANGE', {
62
61
  range: Range;
63
62
  }>;
64
63
  type CutRangAction = ActionType<'CUT_RANGE', {
65
- cutValue: number;
64
+ ranges: Record<string, Range[]>;
66
65
  }>;
67
66
  type ToggleRangesViewAction = ActionType<'TOGGLE_RANGES_VIEW_PROPERTY', {
68
67
  key: keyof FilterType<RangesViewState, boolean>;
@@ -70,7 +69,11 @@ type ToggleRangesViewAction = ActionType<'TOGGLE_RANGES_VIEW_PROPERTY', {
70
69
  type DeleteRangePeakAction = ActionType<'DELETE_RANGE_PEAK', {
71
70
  id: string;
72
71
  }>;
73
- export type RangesActions = AutoRangesDetectionAction | DeleteRangeAction | ChangeRangeSignalKindAction | SaveEditedRangeAction | DeleteSignalAction | UnlinkRangeAction | SetDiaIDRangeAction | ResizeRangeAction | ChangeRangeSumAction | AddRangeAction | ChangeRangeRelativeValueAction | ChangeRangeSignalValueAction | UpdateRangAction | CutRangAction | ToggleRangesViewAction | DeleteRangePeakAction | ActionType<'AUTO_RANGES_SPECTRA_PICKING' | 'CHANGE_RANGES_SUM_FLAG' | 'TOGGLE_RANGES_PEAKS_DISPLAYING_MODE'>;
72
+ type ChangeRangeAssignmentLabelAction = ActionType<'CHANGE_RANGE_ASSIGNMENT_LABEL', {
73
+ rangeID: string;
74
+ value: string;
75
+ }>;
76
+ export type RangesActions = AutoRangesDetectionAction | DeleteRangeAction | ChangeRangeSignalKindAction | SaveEditedRangeAction | DeleteSignalAction | UnlinkRangeAction | SetDiaIDRangeAction | ResizeRangeAction | ChangeRangeSumAction | AddRangeAction | ChangeRangeRelativeValueAction | ChangeRangeSignalValueAction | UpdateRangAction | CutRangAction | ToggleRangesViewAction | DeleteRangePeakAction | ChangeRangeAssignmentLabelAction | ActionType<'AUTO_RANGES_SPECTRA_PICKING' | 'CHANGE_RANGES_SUM_FLAG' | 'TOGGLE_RANGES_PEAKS_DISPLAYING_MODE'>;
74
77
  declare function handleAutoRangesDetection(draft: Draft<State>, action: AutoRangesDetectionAction): void;
75
78
  declare function handleAutoSpectraRangesDetection(draft: Draft<State>): void;
76
79
  declare function handleDeleteRange(draft: Draft<State>, action: DeleteRangeAction): void;
@@ -92,4 +95,5 @@ declare function handleToggleRangesViewProperty(draft: Draft<State>, action: Tog
92
95
  declare function handleCutRange(draft: Draft<State>, action: CutRangAction): void;
93
96
  declare function handleChangePeaksDisplayingMode(draft: Draft<State>): void;
94
97
  declare function handleDeleteRangePeak(draft: Draft<State>, action: DeleteRangePeakAction): void;
95
- export { handleCutRange, handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleAutoSpectraRangesDetection, handleToggleRangesViewProperty, handleChangePeaksDisplayingMode, handleDeleteRangePeak, };
98
+ declare function handleChangeRangeAssignmentLabel(draft: Draft<State>, action: ChangeRangeAssignmentLabelAction): void;
99
+ export { handleCutRange, handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleAutoSpectraRangesDetection, handleToggleRangesViewProperty, handleChangePeaksDisplayingMode, handleDeleteRangePeak, handleChangeRangeAssignmentLabel, };
@@ -4,11 +4,10 @@ import cloneDeep from 'lodash/cloneDeep';
4
4
  import { xFindClosestIndex } from 'ml-spectra-processing';
5
5
  import { Filters, FiltersManager } from 'nmr-processing';
6
6
  import { DATUM_KIND, SIGNAL_INLCUDED_KINDS, } from '../../../data/constants/signalsKinds';
7
- import { addRange, changeRangeSignal, detectRanges, updateRangesRelativeValues, changeRange, changeRangeRelativeValue, } from '../../../data/data1d/Spectrum1D';
7
+ import { changeRangeSignal, detectRanges, updateRangesRelativeValues, changeRangeRelativeValue, isSpectrum1D, } from '../../../data/data1d/Spectrum1D';
8
8
  import { initSumOptions, setSumOptions, } from '../../../data/data1d/Spectrum1D/SumManager';
9
9
  import { unlink, unlinkInAssignmentData, } from '../../../data/utilities/RangeUtilities';
10
10
  import { getActiveSpectrum } from '../helper/getActiveSpectrum';
11
- import getRange from '../helper/getRange';
12
11
  import { getSpectrum } from '../helper/getSpectrum';
13
12
  import { setRangesViewProperty } from '../helper/setRangesViewProperty';
14
13
  import { handleUpdateCorrelations } from './CorrelationsActions';
@@ -232,12 +231,15 @@ function handleSetDiaIDRange(draft, action) {
232
231
  }
233
232
  //action
234
233
  function handleResizeRange(draft, action) {
235
- const activeSpectrum = getActiveSpectrum(draft);
236
- if (activeSpectrum?.id) {
237
- const { index } = activeSpectrum;
238
- const { range } = action.payload;
239
- changeRange(draft.data[index], range);
240
- }
234
+ const spectrum = getSpectrum(draft);
235
+ if (!spectrum)
236
+ return;
237
+ const { range } = action.payload;
238
+ if (!range && !isSpectrum1D(spectrum))
239
+ return;
240
+ const index = spectrum.ranges.values.findIndex((i) => i.id === range.id);
241
+ spectrum.ranges.values[index] = range;
242
+ updateRangesRelativeValues(spectrum);
241
243
  }
242
244
  //action
243
245
  function handleChangeRangeSum(draft, action) {
@@ -260,18 +262,13 @@ function initiateRangeSumOptions(datum, options) {
260
262
  }
261
263
  //action
262
264
  function handleAddRange(draft, action) {
263
- const { startX, endX } = action.payload;
264
- const range = getRange(draft, { startX, endX });
265
+ const { range } = action.payload;
265
266
  const { data, view: { spectra: { activeTab: nucleus }, }, molecules, } = draft;
266
267
  const activeSpectrum = getActiveSpectrum(draft);
267
268
  if (activeSpectrum?.id) {
268
269
  const { index } = activeSpectrum;
269
- const [from, to] = range;
270
270
  const datum = data[index];
271
- addRange(datum, {
272
- from,
273
- to,
274
- });
271
+ datum.ranges.values.push(range);
275
272
  initiateRangeSumOptions(datum, {
276
273
  nucleus,
277
274
  molecules,
@@ -335,15 +332,14 @@ function handleToggleRangesViewProperty(draft, action) {
335
332
  toggleRangesViewProperty(draft, key);
336
333
  }
337
334
  function handleCutRange(draft, action) {
338
- const { cutValue } = action.payload;
335
+ const { ranges: cutRanges } = action.payload;
339
336
  const spectrum = getSpectrum(draft);
340
337
  const ranges = spectrum.ranges.values;
341
338
  for (let i = 0; i < ranges.length; i++) {
342
- const { to, from } = ranges[i];
343
- if (cutValue > from && cutValue < to) {
339
+ const { id } = ranges[i];
340
+ if (cutRanges?.[id]) {
344
341
  ranges.splice(i, 1);
345
- addRange(spectrum, { from, to: cutValue });
346
- addRange(spectrum, { from: cutValue, to });
342
+ ranges.push(...cutRanges[id]);
347
343
  }
348
344
  }
349
345
  updateRangesRelativeValues(spectrum);
@@ -366,4 +362,18 @@ function handleDeleteRangePeak(draft, action) {
366
362
  }
367
363
  }
368
364
  }
369
- export { handleCutRange, handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleAutoSpectraRangesDetection, handleToggleRangesViewProperty, handleChangePeaksDisplayingMode, handleDeleteRangePeak, };
365
+ function handleChangeRangeAssignmentLabel(draft, action) {
366
+ const { rangeID, value } = action.payload;
367
+ const activeSpectrum = getActiveSpectrum(draft);
368
+ if (activeSpectrum?.id) {
369
+ const { index } = activeSpectrum;
370
+ const spectrum = draft.data[index];
371
+ if (isSpectrum1D(spectrum)) {
372
+ const range = spectrum.ranges.values.find((range) => range.id === rangeID);
373
+ if (range) {
374
+ range.assignment = value;
375
+ }
376
+ }
377
+ }
378
+ }
379
+ export { handleCutRange, handleAutoRangesDetection, handleDeleteRange, deleteSignal1D, handleDeleteSignal, handleChangeRangeSum, handleAddRange, handleResizeRange, handleChangeRangeRelativeValue, handleChangeRangeSignalValue, handleChangeRangeSignalKind, handleSaveEditedRange, handleUnlinkRange, unlinkRange, handleSetDiaIDRange, handleChangeRangesSumFlag, handleUpdateRange, handleAutoSpectraRangesDetection, handleToggleRangesViewProperty, handleChangePeaksDisplayingMode, handleDeleteRangePeak, handleChangeRangeAssignmentLabel, };
@@ -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;
@@ -215,9 +215,9 @@ function handleZoom(draft, action) {
215
215
  const { options, trackID } = action.payload;
216
216
  const { displayerMode, yDomains, toolOptions: { selectedTool }, } = draft;
217
217
  const scaleRatio = toScaleRatio(options);
218
+ const { altKey, shiftKey } = options;
218
219
  switch (displayerMode) {
219
220
  case '2D': {
220
- const { shiftKey } = options;
221
221
  if (trackID === 'CENTER_2D') {
222
222
  // change the vertical scale for traces in 2D phase correction
223
223
  if (selectedTool === 'phaseCorrectionTwoDimensions') {
@@ -226,7 +226,7 @@ function handleZoom(draft, action) {
226
226
  return;
227
227
  }
228
228
  //zoom in/out in 2d
229
- if (selectedTool === 'zoom' && shiftKey) {
229
+ if (shiftKey) {
230
230
  zoomWithScroll(draft, {
231
231
  zoomOptions: options,
232
232
  dimension: '2D',
@@ -249,21 +249,13 @@ function handleZoom(draft, action) {
249
249
  }
250
250
  case '1D': {
251
251
  const activeSpectra = getActiveSpectra(draft);
252
- const { shiftKey } = options;
253
252
  // Horizontal zoom in/out 1d spectra by mouse wheel
254
- if (selectedTool === 'zoom' && shiftKey) {
253
+ if (shiftKey) {
255
254
  zoomWithScroll(draft, { zoomOptions: options, dimension: '1D' });
256
255
  return;
257
256
  }
258
- if (!activeSpectra) {
259
- // rescale the spectra
260
- for (const key of Object.keys(yDomains)) {
261
- const domain = yDomains[key];
262
- yDomains[key] = wheelZoom(options, domain);
263
- }
264
- return;
265
- }
266
- if (activeSpectra.length === 1 && shiftKey) {
257
+ // rescale the integral in ranges and integrals
258
+ if (altKey && activeSpectra?.length === 1) {
267
259
  switch (selectedTool) {
268
260
  case 'rangePicking': {
269
261
  setRangesViewProperty(draft, 'integralsScaleRatio', (scale) => scale * scaleRatio);
@@ -276,14 +268,15 @@ function handleZoom(draft, action) {
276
268
  default:
277
269
  break;
278
270
  }
271
+ return;
279
272
  }
280
- else {
281
- for (const activeSpectrum of activeSpectra) {
282
- const domain = yDomains?.[activeSpectrum?.id];
283
- if (domain) {
284
- yDomains[activeSpectrum?.id] = wheelZoom(options, domain);
285
- }
286
- }
273
+ // reselect the spectra vertically
274
+ const keys = !activeSpectra
275
+ ? Object.keys(yDomains)
276
+ : activeSpectra.map(({ id }) => id);
277
+ for (const key of keys) {
278
+ const domain = yDomains[key];
279
+ yDomains[key] = wheelZoom(options, domain);
287
280
  }
288
281
  break;
289
282
  }
@@ -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
  }
@@ -64,21 +64,22 @@ const getZoneDefaultValues = (nucleus) => {
64
64
  return { nuclei: {} };
65
65
  }
66
66
  if (is2DNucleus(nucleus)) {
67
- const perferences2D = {
67
+ const preferences2D = {
68
68
  showSerialNumber: true,
69
69
  showKind: true,
70
70
  showDeleteAction: true,
71
71
  showZoomAction: true,
72
72
  showEditAction: true,
73
73
  showAssignment: true,
74
+ showAssignmentLabel: false,
74
75
  };
75
- return { ...common, ...getPreferences(perferences2D, nucleus) };
76
+ return { ...common, ...getPreferences(preferences2D, nucleus) };
76
77
  }
77
78
  else {
78
- const perferences1D = {
79
+ const preferences1D = {
79
80
  deltaPPM: { show: true, format: '0.00' },
80
81
  };
81
- return { ...common, ...getPreferences(perferences1D, nucleus) };
82
+ return { ...common, ...getPreferences(preferences1D, nucleus) };
82
83
  }
83
84
  };
84
85
  const getRangeDefaultValues = (nucleus) => {
@@ -98,6 +99,7 @@ const getRangeDefaultValues = (nucleus) => {
98
99
  showDeleteAction: true,
99
100
  showZoomAction: true,
100
101
  showEditAction: true,
102
+ showAssignmentLabel: false,
101
103
  };
102
104
  return getPreferences(preferences, nucleus);
103
105
  };
@@ -7,6 +7,7 @@ import { Toolbar } from 'react-science/ui';
7
7
  import { useChartData } from '../context/ChartContext';
8
8
  import { useDispatch } from '../context/DispatchContext';
9
9
  import { useLoader } from '../context/LoaderContext';
10
+ import { CustomToolTip } from '../elements/CustomToolTip';
10
11
  import { ToolbarPopoverItem, } from '../elements/ToolbarPopoverItem';
11
12
  import useCheckExperimentalFeature from '../hooks/useCheckExperimentalFeature';
12
13
  import { useCheckToolsVisibility, } from '../hooks/useCheckToolsVisibility';
@@ -15,7 +16,7 @@ import { useDialogToggle } from '../hooks/useDialogToggle';
15
16
  import useExport from '../hooks/useExport';
16
17
  import useToolsFunctions from '../hooks/useToolsFunctions';
17
18
  import { useVerticalAlign } from '../hooks/useVerticalAlign';
18
- import ImportPublicationStringModal from '../modal/ImportPublicationStringModal';
19
+ import { ImportPublicationStringModal } from '../modal/ImportPublicationStringModal';
19
20
  import { LoadJCAMPModal } from '../modal/LoadJCAMPModal';
20
21
  import SaveAsModal from '../modal/SaveAsModal';
21
22
  import { MetaImportationModal } from '../modal/metaImportation/MetaImportationModal';
@@ -105,143 +106,228 @@ export default function ToolBar() {
105
106
  const toolItems = [
106
107
  {
107
108
  id: 'zoom',
108
- title: options.zoom.label,
109
+ tooltip: {
110
+ title: options.zoom.label,
111
+ subTitles: [
112
+ { title: 'Vertical', shortcuts: ['Scroll wheel'] },
113
+ { title: 'Horizontal', shortcuts: ['Shift', 'Scroll wheel'] },
114
+ { title: 'Pan', shortcuts: ['Right mouse'] },
115
+ ],
116
+ },
109
117
  icon: _jsx(FaSearchPlus, {}),
110
118
  },
111
119
  {
112
120
  id: 'zoomOut',
113
- title: 'Horizontal zoom out (Press f), Horizontal and Vertical zoom out, double click (Press ff)',
121
+ tooltip: {
122
+ title: 'Zoom out',
123
+ subTitles: [
124
+ { title: 'Horizontal', shortcuts: ['f'] },
125
+ { title: 'Horizontal and Vertical', shortcuts: ['f', 'f'] },
126
+ ],
127
+ description: 'You can zoom out by double click on the left mouse button and full zoom out by press key "f" or press key "f" twice to fit the spectra in the window.',
128
+ link: 'https://docs.nmrium.org/help/zoom-and-scale',
129
+ },
114
130
  onClick: handleFullZoomOut,
115
131
  icon: _jsx(FaExpand, {}),
116
132
  },
117
133
  {
118
134
  id: 'peakPicking',
119
- title: `${options.peakPicking.label} (Press p)`,
135
+ tooltip: {
136
+ title: options.peakPicking.label,
137
+ shortcuts: ['p'],
138
+ description: 'You can detect peaks manually or automatically in the spectrum.',
139
+ link: 'https://docs.nmrium.org/20_1d-spectra/peaks/peaks',
140
+ },
120
141
  icon: _jsx(SvgNmrPeakPicking, {}),
121
142
  },
122
143
  {
123
144
  id: 'integral',
124
- title: `${options.integral.label} (Press i)`,
145
+ tooltip: {
146
+ title: options.integral.label,
147
+ shortcuts: ['i'],
148
+ description: 'To calculate the integration, hold Shift and left-click, then drag over the signal range.',
149
+ link: 'https://docs.nmrium.org/help/integrations',
150
+ },
125
151
  icon: _jsx(SvgNmrIntegrate, {}),
126
152
  },
127
153
  {
128
154
  id: 'zonePicking',
129
- title: `${options.zonePicking.label} (Press r)`,
155
+ tooltip: {
156
+ title: options.zonePicking.label,
157
+ shortcuts: ['r'],
158
+ description: 'You can detect zones manually by selecting, holding Shift,left-click, dragging, and then releasing. Alternatively, detect zones automatically.',
159
+ link: 'https://docs.nmrium.org/30_2d-spectra/zones/zones',
160
+ },
130
161
  icon: _jsx(FaDiceFour, {}),
131
162
  },
132
163
  {
133
164
  id: 'slicing',
134
- title: options.slicing.label,
165
+ tooltip: {
166
+ title: options.slicing.label,
167
+ description: 'You can display the shift on the x-axis and the y-axis for each point of a 2D spectrum.',
168
+ link: 'https://docs.nmrium.org/30_2d-spectra/slicing/slicing',
169
+ },
135
170
  icon: _jsx(PiKnifeBold, {}),
136
171
  },
137
172
  {
138
173
  id: 'rangePicking',
139
- title: `${options.rangePicking.label} (Press r)`,
174
+ tooltip: {
175
+ title: options.rangePicking.label,
176
+ shortcuts: ['r'],
177
+ description: 'You can detect ranges manually by selecting, holding Shift,left-click, dragging, and then releasing. Alternatively, detect ranges automatically.',
178
+ link: 'https://docs.nmrium.org/20_1d-spectra/ranges/ranges',
179
+ },
140
180
  icon: _jsx(SvgNmrRangePicking, {}),
141
181
  },
142
182
  {
143
183
  id: 'multipleSpectraAnalysis',
144
- title: options.multipleSpectraAnalysis.label,
184
+ tooltip: options.multipleSpectraAnalysis.label,
145
185
  icon: _jsx(SvgNmrMultipleAnalysis, {}),
146
186
  checkOptions: { checkSpectrumType: false },
147
187
  condition: ftCounter > 0,
148
188
  },
149
189
  {
150
190
  id: 'apodization',
151
- title: `${options.apodization.label} (Press a)`,
191
+ tooltip: {
192
+ title: options.apodization.label,
193
+ shortcuts: ['a'],
194
+ },
152
195
  icon: _jsx(SvgNmrApodization, {}),
153
196
  },
154
197
  {
155
198
  id: 'zeroFilling',
156
- title: `${options.zeroFilling.label} (Press z)`,
199
+ tooltip: {
200
+ title: options.zeroFilling.label,
201
+ shortcuts: ['z'],
202
+ description: 'To improve spectrum quality by increasing the number of points per ppm, by default, the number of points is twice as many points as in the original FID.',
203
+ link: 'https://docs.nmrium.org/20_1d-spectra/preprocessing/preprocessing#zero-filling',
204
+ },
157
205
  icon: _jsx(SvgNmrZeroFilling, {}),
158
206
  },
159
207
  {
160
208
  id: 'phaseCorrection',
161
- title: `${options.phaseCorrection.label} (Press a)`,
209
+ tooltip: {
210
+ title: options.phaseCorrection.label,
211
+ shortcuts: ['a'],
212
+ description: 'To phase the spectrum after the FFT.',
213
+ link: 'https://docs.nmrium.org/20_1d-spectra/phase/phase',
214
+ },
162
215
  icon: _jsx(SvgNmrPhaseCorrection, {}),
163
216
  },
164
217
  {
165
218
  id: 'phaseCorrectionTwoDimensions',
166
- title: `${options.phaseCorrectionTwoDimensions.label} (Press a)`,
219
+ tooltip: {
220
+ title: options.phaseCorrectionTwoDimensions.label,
221
+ shortcuts: ['a'],
222
+ description: 'To phase the spectrum after the FFT.',
223
+ },
167
224
  icon: _jsx(SvgNmrPhaseCorrection, {}),
168
225
  },
169
226
  {
170
227
  id: 'baselineCorrection',
171
- title: `${options.baselineCorrection.label} (Press b)`,
228
+ tooltip: {
229
+ title: options.baselineCorrection.label,
230
+ shortcuts: ['b'],
231
+ description: 'To process the spectrum to be a straight line at zero absorbance.',
232
+ link: 'https://docs.nmrium.org/20_1d-spectra/baseline/baseline',
233
+ },
172
234
  icon: _jsx(SvgNmrBaselineCorrection, {}),
173
235
  },
174
236
  {
175
237
  id: 'exclusionZones',
176
- title: `${options.exclusionZones.label} (Press e)`,
238
+ tooltip: {
239
+ title: options.exclusionZones.label,
240
+ shortcuts: ['e'],
241
+ },
177
242
  icon: _jsx(SvgNmrMultipleAnalysis, {}),
178
243
  checkOptions: { checkSpectrumType: false },
179
244
  condition: ftCounter > 0,
180
245
  },
181
246
  {
182
247
  id: 'fft',
183
- title: `${options.fft.label} (Press t)`,
248
+ tooltip: {
249
+ title: options.fft.label,
250
+ shortcuts: ['t'],
251
+ description: 'To process the FID to FT spectrum.',
252
+ link: 'https://docs.nmrium.org/20_1d-spectra/ft/ft/',
253
+ },
184
254
  onClick: handleOnFFTFilter,
185
255
  icon: _jsx(SvgNmrFourierTransform, {}),
186
256
  },
187
257
  {
188
258
  id: 'fftDimension1',
189
- title: options.fftDimension1.label,
259
+ tooltip: options.fftDimension1.label,
190
260
  onClick: handleFFtDimension1Filter,
191
261
  icon: _jsx(SvgNmrFourierTransform, {}),
192
262
  },
193
263
  {
194
264
  id: 'fftDimension2',
195
- title: options.fftDimension2.label,
265
+ tooltip: options.fftDimension2.label,
196
266
  onClick: handleFFtDimension2Filter,
197
267
  icon: _jsx(SvgNmrFourierTransform, {}),
198
268
  },
199
269
  {
200
270
  id: 'import',
201
- title: options.import.label,
271
+ tooltip: options.import.label,
202
272
  icon: _jsx(FaFileImport, {}),
203
273
  menuItems: importMenu,
204
274
  onClick: importHandler,
205
275
  },
206
276
  {
207
277
  id: 'exportAs',
208
- title: options.exportAs.label,
278
+ tooltip: options.exportAs.label,
209
279
  icon: _jsx(FaFileExport, {}),
210
280
  menuItems: exportMenu,
211
281
  onClick: exportHandler,
212
282
  },
213
283
  {
214
284
  id: 'spectraStackAlignments',
215
- title: `${options.spectraStackAlignments.label} (Press s)`,
285
+ tooltip: {
286
+ title: options.spectraStackAlignments.label,
287
+ shortcuts: ['s'],
288
+ description: 'To display the spectra in a stack mode.',
289
+ },
216
290
  icon: verticalAlign === 'stack' ? (_jsx(SvgNmrOverlay3Aligned, {})) : (_jsx(SvgNmrOverlay3, {})),
217
291
  condition: ftCounter > 1,
218
292
  onClick: changeDisplayViewModeHandler,
219
293
  },
220
294
  {
221
295
  id: 'realImaginary',
222
- title: isRealSpectrumShown ? 'Display real ' : 'Display imaginary',
296
+ tooltip: {
297
+ title: `Display ${isRealSpectrumShown ? 'real' : 'imaginary'}`,
298
+ description: 'To switch between imaginary and real part of the spectrum.',
299
+ link: 'https://docs.nmrium.org/20_1d-spectra/views/views',
300
+ },
223
301
  icon: _jsx(SvgNmrRealImag, {}),
224
302
  onClick: changeSpectrumViewHandler,
225
303
  },
226
304
  {
227
305
  id: 'spectraCenterAlignments',
228
- title: `Baseline ${verticalAlign === 'bottom' ? 'center' : 'bottom'} (Press c)`,
306
+ tooltip: {
307
+ title: `Baseline ${verticalAlign === 'bottom' ? 'center' : 'bottom'}`,
308
+ shortcuts: ['c'],
309
+ description: 'To align the spectra in the centre or at the bottom of the displayer.',
310
+ },
229
311
  icon: verticalAlign === 'bottom' ? (_jsx(SvgNmrAlignCenter, {})) : (_jsx(SvgNmrAlignBottom, {})),
230
312
  condition: ftCounter > 0 || fidCounter > 0,
231
313
  onClick: alignSpectraVerticallyHandler,
232
314
  },
233
315
  ];
234
316
  return (_jsxs(_Fragment, { children: [_jsx(LoadJCAMPModal, { isOpen: dialog.loadJCAMP, onCloseDialog: closeDialog }), _jsx(ImportPublicationStringModal, { isOpen: dialog.importPublicationString, onClose: closeDialog }), _jsx(MetaImportationModal, { isOpen: dialog.metaImportation, onCloseDialog: closeDialog }), _jsx(SaveAsModal, { isOpen: dialog.saveAs, onCloseDialog: closeDialog }), _jsx(Toolbar, { vertical: true, children: toolItems.map((item) => {
235
- const { id, icon, title, checkOptions, condition } = item;
317
+ const { id, icon, tooltip, checkOptions, condition } = item;
236
318
  const show = isButtonVisible(id, checkOptions) &&
237
319
  (condition === undefined || condition);
238
320
  if (!show)
239
321
  return null;
240
322
  if (isPopoverToolItem(item)) {
241
323
  const { menuItems, onClick } = item;
242
- return (_jsx(ToolbarPopoverItem, { options: menuItems, title: title, id: id, active: selectedTool === id, icon: icon, onClick: onClick }, id));
324
+ return (_jsx(ToolbarPopoverItem, { options: menuItems, tooltip: typeof tooltip === 'string' ? (tooltip) : (_jsx(CustomToolTip, { ...tooltip })), tooltipProps: {
325
+ minimal: true,
326
+ }, id: id, active: selectedTool === id, icon: icon, onClick: onClick }, id));
243
327
  }
244
328
  const { onClick } = item;
245
- return (_jsx(Toolbar.Item, { onClick: onClick || (() => handleChange(id)), title: title, id: id, active: selectedTool === id, icon: icon }, id));
329
+ return (_jsx(Toolbar.Item, { onClick: onClick || (() => handleChange(id)), tooltip: typeof tooltip === 'string' ? (tooltip) : (_jsx(CustomToolTip, { ...tooltip })), tooltipProps: {
330
+ minimal: true,
331
+ }, id: id, active: selectedTool === id, icon: icon }, id));
246
332
  }) })] }));
247
333
  }
@@ -167,7 +167,7 @@ async function copyPNGToClipboard(rootRef, elementID, css) {
167
167
  catch (error) {
168
168
  if (error instanceof ReferenceError) {
169
169
  // eslint-disable-next-line no-alert
170
- alert('Your browser does not support this feature, please use Google Chrome or Firefox');
170
+ window.alert('Your browser does not support this feature, please use Google Chrome or Firefox');
171
171
  }
172
172
  // TODO: handle error.
173
173
  reportError(error);