nmrium 1.10.0 → 1.11.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 (155) hide show
  1. package/lib/component/1d/BrushTracker1D.d.ts.map +1 -1
  2. package/lib/component/1d/BrushTracker1D.js +7 -0
  3. package/lib/component/1d/BrushTracker1D.js.map +1 -1
  4. package/lib/component/1d/FloatPublicationString.d.ts.map +1 -1
  5. package/lib/component/1d/FloatPublicationString.js +1 -1
  6. package/lib/component/1d/FloatPublicationString.js.map +1 -1
  7. package/lib/component/1d/FloatingRanges.d.ts.map +1 -1
  8. package/lib/component/1d/FloatingRanges.js +1 -1
  9. package/lib/component/1d/FloatingRanges.js.map +1 -1
  10. package/lib/component/1d/inset/DraggableInset.d.ts.map +1 -1
  11. package/lib/component/1d/inset/DraggableInset.js +1 -1
  12. package/lib/component/1d/inset/DraggableInset.js.map +1 -1
  13. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.d.ts.map +1 -1
  14. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +11 -2
  15. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
  16. package/lib/component/2d/useTracesSpectra.d.ts.map +1 -1
  17. package/lib/component/2d/useTracesSpectra.js +3 -2
  18. package/lib/component/2d/useTracesSpectra.js.map +1 -1
  19. package/lib/component/EventsTrackers/KeysListenerTracker.js +3 -3
  20. package/lib/component/EventsTrackers/KeysListenerTracker.js.map +1 -1
  21. package/lib/component/elements/NextPrev.d.ts.map +1 -1
  22. package/lib/component/elements/NextPrev.js +23 -4
  23. package/lib/component/elements/NextPrev.js.map +1 -1
  24. package/lib/component/elements/export/utilities/exportOptionValidationSchema.d.ts +1 -1
  25. package/lib/component/hooks/useExport.d.ts +7 -7
  26. package/lib/component/hooks/useExport.d.ts.map +1 -1
  27. package/lib/component/hooks/useExport.js +22 -42
  28. package/lib/component/hooks/useExport.js.map +1 -1
  29. package/lib/component/hooks/useSetActiveSpectrumAction.d.ts.map +1 -1
  30. package/lib/component/hooks/useSetActiveSpectrumAction.js +3 -1
  31. package/lib/component/hooks/useSetActiveSpectrumAction.js.map +1 -1
  32. package/lib/component/loader/useLoadFiles.d.ts.map +1 -1
  33. package/lib/component/loader/useLoadFiles.js +81 -86
  34. package/lib/component/loader/useLoadFiles.js.map +1 -1
  35. package/lib/component/main/ErrorOverlay.d.ts.map +1 -1
  36. package/lib/component/main/ErrorOverlay.js +6 -1
  37. package/lib/component/main/ErrorOverlay.js.map +1 -1
  38. package/lib/component/main/InnerNMRiumContents.d.ts.map +1 -1
  39. package/lib/component/main/InnerNMRiumContents.js +1 -2
  40. package/lib/component/main/InnerNMRiumContents.js.map +1 -1
  41. package/lib/component/main/NMRiumViewer.js +1 -1
  42. package/lib/component/main/NMRiumViewer.js.map +1 -1
  43. package/lib/component/main/NMRiumViewerWrapper.d.ts.map +1 -1
  44. package/lib/component/main/NMRiumViewerWrapper.js +11 -3
  45. package/lib/component/main/NMRiumViewerWrapper.js.map +1 -1
  46. package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.d.ts +6 -0
  47. package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.d.ts.map +1 -0
  48. package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.js +127 -0
  49. package/lib/component/modal/MoleculeAutoLabelsDatabaseModal.js.map +1 -0
  50. package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
  51. package/lib/component/modal/SaveAsModal.js +4 -8
  52. package/lib/component/modal/SaveAsModal.js.map +1 -1
  53. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  54. package/lib/component/modal/changeSum/ChangeSumModal.js.map +1 -1
  55. package/lib/component/modal/changeSum/SelectMolecule.js +4 -1
  56. package/lib/component/modal/changeSum/SelectMolecule.js.map +1 -1
  57. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  58. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +71 -16
  59. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  60. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.d.ts.map +1 -1
  61. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js +3 -12
  62. package/lib/component/panels/MoleculesPanel/hooks/useAtomAssignment.js.map +1 -1
  63. package/lib/component/panels/Panels.d.ts +0 -9
  64. package/lib/component/panels/Panels.d.ts.map +1 -1
  65. package/lib/component/panels/Panels.js +1 -29
  66. package/lib/component/panels/Panels.js.map +1 -1
  67. package/lib/component/panels/hooks/useTogglePanel.d.ts.map +1 -1
  68. package/lib/component/panels/hooks/useTogglePanel.js +4 -3
  69. package/lib/component/panels/hooks/useTogglePanel.js.map +1 -1
  70. package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
  71. package/lib/component/reducer/actions/LoadAction.js +6 -0
  72. package/lib/component/reducer/actions/LoadAction.js.map +1 -1
  73. package/lib/component/reducer/actions/MoleculeActions.d.ts +23 -1
  74. package/lib/component/reducer/actions/MoleculeActions.d.ts.map +1 -1
  75. package/lib/component/reducer/actions/MoleculeActions.js +2 -2
  76. package/lib/component/reducer/actions/MoleculeActions.js.map +1 -1
  77. package/lib/component/reducer/actions/RangesActions.js +1 -1
  78. package/lib/component/reducer/actions/RangesActions.js.map +1 -1
  79. package/lib/component/reducer/actions/SpectraActions.d.ts +2 -1
  80. package/lib/component/reducer/actions/SpectraActions.d.ts.map +1 -1
  81. package/lib/component/reducer/actions/SpectraActions.js +2 -2
  82. package/lib/component/reducer/actions/SpectraActions.js.map +1 -1
  83. package/lib/component/reducer/preferences/actions/analyzeSpectra.d.ts +2 -1
  84. package/lib/component/reducer/preferences/actions/analyzeSpectra.d.ts.map +1 -1
  85. package/lib/component/reducer/preferences/actions/analyzeSpectra.js +10 -0
  86. package/lib/component/reducer/preferences/actions/analyzeSpectra.js.map +1 -1
  87. package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.d.ts +4 -0
  88. package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.d.ts.map +1 -0
  89. package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.js +9 -0
  90. package/lib/component/reducer/preferences/actions/toggleOpenSplitPanel.js.map +1 -0
  91. package/lib/component/reducer/preferences/preferencesReducer.d.ts +8 -1
  92. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  93. package/lib/component/reducer/preferences/preferencesReducer.js +6 -1
  94. package/lib/component/reducer/preferences/preferencesReducer.js.map +1 -1
  95. package/lib/component/toolbar/ToolBar.d.ts.map +1 -1
  96. package/lib/component/toolbar/ToolBar.js +6 -7
  97. package/lib/component/toolbar/ToolBar.js.map +1 -1
  98. package/lib/component/toolbar/toolbarMenu.d.ts +5 -1
  99. package/lib/component/toolbar/toolbarMenu.d.ts.map +1 -1
  100. package/lib/component/toolbar/toolbarMenu.js +1 -1
  101. package/lib/component/toolbar/toolbarMenu.js.map +1 -1
  102. package/lib/component/utility/export.d.ts +2 -1
  103. package/lib/component/utility/export.d.ts.map +1 -1
  104. package/lib/component/utility/export.js +5 -1
  105. package/lib/component/utility/export.js.map +1 -1
  106. package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -0
  107. package/lib/data/data1d/multipleSpectraAnalysis.d.ts.map +1 -1
  108. package/lib/data/data1d/multipleSpectraAnalysis.js +14 -0
  109. package/lib/data/data1d/multipleSpectraAnalysis.js.map +1 -1
  110. package/lib/data/data2d/Spectrum2D/contours.d.ts.map +1 -1
  111. package/lib/data/data2d/Spectrum2D/contours.js +13 -6
  112. package/lib/data/data2d/Spectrum2D/contours.js.map +1 -1
  113. package/lib/data/molecules/MoleculeManager.d.ts +6 -1
  114. package/lib/data/molecules/MoleculeManager.d.ts.map +1 -1
  115. package/lib/data/molecules/MoleculeManager.js +3 -2
  116. package/lib/data/molecules/MoleculeManager.js.map +1 -1
  117. package/lib/versionInfo.js +1 -1
  118. package/package.json +39 -39
  119. package/src/component/1d/BrushTracker1D.tsx +8 -0
  120. package/src/component/1d/FloatPublicationString.tsx +0 -1
  121. package/src/component/1d/FloatingRanges.tsx +0 -1
  122. package/src/component/1d/inset/DraggableInset.tsx +0 -1
  123. package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +11 -2
  124. package/src/component/2d/useTracesSpectra.ts +4 -3
  125. package/src/component/EventsTrackers/KeysListenerTracker.tsx +3 -3
  126. package/src/component/elements/NextPrev.tsx +28 -4
  127. package/src/component/hooks/useExport.tsx +34 -64
  128. package/src/component/hooks/useSetActiveSpectrumAction.ts +3 -2
  129. package/src/component/loader/useLoadFiles.ts +134 -111
  130. package/src/component/main/ErrorOverlay.tsx +11 -2
  131. package/src/component/main/InnerNMRiumContents.tsx +6 -9
  132. package/src/component/main/NMRiumViewer.tsx +2 -2
  133. package/src/component/main/NMRiumViewerWrapper.tsx +14 -6
  134. package/src/component/modal/MoleculeAutoLabelsDatabaseModal.tsx +219 -0
  135. package/src/component/modal/SaveAsModal.tsx +14 -41
  136. package/src/component/modal/changeSum/ChangeSumModal.tsx +1 -1
  137. package/src/component/modal/changeSum/SelectMolecule.tsx +23 -23
  138. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +94 -15
  139. package/src/component/panels/MoleculesPanel/hooks/useAtomAssignment.tsx +3 -17
  140. package/src/component/panels/Panels.tsx +1 -53
  141. package/src/component/panels/hooks/useTogglePanel.ts +4 -3
  142. package/src/component/reducer/actions/LoadAction.ts +15 -1
  143. package/src/component/reducer/actions/MoleculeActions.ts +4 -2
  144. package/src/component/reducer/actions/RangesActions.ts +1 -1
  145. package/src/component/reducer/actions/SpectraActions.ts +6 -2
  146. package/src/component/reducer/preferences/actions/analyzeSpectra.ts +16 -0
  147. package/src/component/reducer/preferences/actions/toggleOpenSplitPanel.ts +18 -0
  148. package/src/component/reducer/preferences/preferencesReducer.ts +22 -1
  149. package/src/component/toolbar/ToolBar.tsx +9 -9
  150. package/src/component/toolbar/toolbarMenu.tsx +13 -2
  151. package/src/component/utility/export.ts +6 -0
  152. package/src/data/data1d/multipleSpectraAnalysis.ts +20 -0
  153. package/src/data/data2d/Spectrum2D/contours.ts +16 -6
  154. package/src/data/molecules/MoleculeManager.ts +7 -2
  155. package/src/versionInfo.ts +1 -1
@@ -27,6 +27,7 @@ import { addWorkspace } from './actions/addWorkspace.js';
27
27
  import {
28
28
  analyzeSpectra,
29
29
  changeAnalysisColumnValueKey,
30
+ cutSpectraAnalysis,
30
31
  deleteAnalysisColumn,
31
32
  setSpectraAnalysisPanelsPreferences,
32
33
  } from './actions/analyzeSpectra.js';
@@ -54,6 +55,7 @@ import { setPreferences } from './actions/setPreferences.js';
54
55
  import { setVerticalSplitterPosition } from './actions/setVerticalSplitterPosition.js';
55
56
  import { setWorkspace } from './actions/setWorkspace.js';
56
57
  import { toggleInformationBlock } from './actions/toggleInformationBlock.js';
58
+ import { toggleOpenSplitPanel } from './actions/toggleOpenSplitPanel.ts';
57
59
  import { togglePanel } from './actions/togglePanel.js';
58
60
  import { mapWorkspaces } from './utilities/mapWorkspaces.js';
59
61
 
@@ -111,6 +113,12 @@ export type AnalyzeSpectraAction = ActionType<
111
113
  'ANALYZE_SPECTRA',
112
114
  { start: number; end: number; nucleus: string; columnKey?: string }
113
115
  >;
116
+
117
+ export type CutSpectraAnalysisAction = ActionType<
118
+ 'CUT_SPECTRA_ANALYSIS',
119
+ { x: number; nucleus: string }
120
+ >;
121
+
114
122
  export type ChangeAnalysisColumnValueKeyAction = ActionType<
115
123
  'CHANGE_ANALYSIS_COLUMN_VALUE_KEY',
116
124
  { columnKey: string; valueKey: string; nucleus: string }
@@ -177,6 +185,13 @@ export type ChangeDefaultMoleculeSettingsAction = ActionType<
177
185
  MoleculeView
178
186
  >;
179
187
 
188
+ export type ToggleSplitPanelAction = ActionType<
189
+ 'TOGGLE_SPLIT_PANEL',
190
+ {
191
+ isOpen?: boolean;
192
+ }
193
+ >;
194
+
180
195
  export type PreferencesActions =
181
196
  | InitPreferencesAction
182
197
  | SetPreferencesAction
@@ -198,7 +213,9 @@ export type PreferencesActions =
198
213
  | ChangePeaksLabelPositionAction
199
214
  | TogglePanelAction
200
215
  | ChangeExportACSSettingsAction
201
- | ChangeDefaultMoleculeSettingsAction;
216
+ | ChangeDefaultMoleculeSettingsAction
217
+ | CutSpectraAnalysisAction
218
+ | ToggleSplitPanelAction;
202
219
 
203
220
  export type WorkspaceWithSource = Workspace & { source: WorkSpaceSource };
204
221
  type WorkspacesWithSource = Record<string, WorkspaceWithSource>;
@@ -294,6 +311,8 @@ function innerPreferencesReducer(
294
311
  return deleteAnalysisColumn(draft, action);
295
312
  case 'SET_SPECTRA_ANALYSIS_PREFERENCES':
296
313
  return setSpectraAnalysisPanelsPreferences(draft, action);
314
+ case 'CUT_SPECTRA_ANALYSIS':
315
+ return cutSpectraAnalysis(draft, action);
297
316
  case 'SET_MATRIX_GENERATION_OPTIONS':
298
317
  return setMatrixGenerationOptions(draft, action);
299
318
  case 'ADD_MATRIX_GENERATION_EXCLUSION_ZONE':
@@ -324,6 +343,8 @@ function innerPreferencesReducer(
324
343
  return changeExportAcsSettings(draft, action);
325
344
  case 'CHANGE_DEFAULT_MOLECULE_SETTINGS':
326
345
  return changeDefaultMoleculeSettings(draft, action);
346
+ case 'TOGGLE_SPLIT_PANEL':
347
+ return toggleOpenSplitPanel(draft, action);
327
348
 
328
349
  default:
329
350
  return draft;
@@ -53,6 +53,7 @@ import { MetaImportationModal } from '../modal/metaImportation/MetaImportationMo
53
53
 
54
54
  import type { MainTool } from './ToolTypes.js';
55
55
  import { options } from './ToolTypes.js';
56
+ import type { ExportMenuItems } from './toolbarMenu.js';
56
57
  import { EXPORT_MENU, IMPORT_MENU } from './toolbarMenu.js';
57
58
 
58
59
  interface BaseToolItem extends Pick<ToolbarItemProps, 'icon' | 'disabled'> {
@@ -161,7 +162,7 @@ export default function ToolBar() {
161
162
  });
162
163
  }, [dispatch]);
163
164
 
164
- const { saveAsJSONHandler } = useExport();
165
+ const { defaultSaveAsHandler } = useExport();
165
166
 
166
167
  const exportViewportAPI = useExportManagerAPI();
167
168
 
@@ -183,16 +184,16 @@ export default function ToolBar() {
183
184
  }
184
185
  }
185
186
 
186
- function exportHandler(data: any) {
187
- switch (data?.id) {
187
+ function exportHandler(data: ExportMenuItems[number]['data']) {
188
+ const id = data?.id;
189
+
190
+ switch (id) {
188
191
  case 'svg':
189
- exportViewportAPI.current?.export({ format: 'svg' });
190
- break;
191
192
  case 'png':
192
- exportViewportAPI.current?.export({ format: 'png' });
193
+ exportViewportAPI.current?.export({ format: id });
193
194
  break;
194
- case 'json':
195
- saveAsJSONHandler();
195
+ case 'nmrium_archive':
196
+ defaultSaveAsHandler();
196
197
  break;
197
198
  case 'advance_save':
198
199
  openDialog('saveAs');
@@ -206,7 +207,6 @@ export default function ToolBar() {
206
207
  case 'exportAsJcamp':
207
208
  openDialog('exportAsJcamp');
208
209
  break;
209
-
210
210
  default:
211
211
  break;
212
212
  }
@@ -39,7 +39,18 @@ const IMPORT_MENU: ToolbarPopoverMenuItem[] = [
39
39
  },
40
40
  ] as const;
41
41
 
42
- const EXPORT_MENU: ToolbarPopoverMenuItem[] = [
42
+ type ExportMenuItemsId =
43
+ | 'nmrium_archive'
44
+ | 'advance_save'
45
+ | 'svg'
46
+ | 'png'
47
+ | 'copy'
48
+ | 'nmre'
49
+ | 'exportAsJcamp';
50
+ export type ExportMenuItems = Array<
51
+ ToolbarPopoverMenuItem<{ id: ExportMenuItemsId }>
52
+ >;
53
+ const EXPORT_MENU: ExportMenuItems = [
43
54
  {
44
55
  icon: <FaFileDownload />,
45
56
  text: 'Save data',
@@ -48,7 +59,7 @@ const EXPORT_MENU: ToolbarPopoverMenuItem[] = [
48
59
  shortcuts: ['CTRL', 's'],
49
60
  },
50
61
  data: {
51
- id: 'json',
62
+ id: 'nmrium_archive',
52
63
  },
53
64
  },
54
65
  {
@@ -420,10 +420,16 @@ function getBlob(targetElementID: string, options: GetBlobOptions): BlobObject {
420
420
  return { blob, width, height };
421
421
  }
422
422
 
423
+ function exportAsMolfile(molText: string, fileName: string) {
424
+ const blob = new Blob([molText], { type: 'text/plain' });
425
+ saveAs({ blob, name: fileName, extension: '.mol' });
426
+ }
427
+
423
428
  export {
424
429
  copyPNGToClipboard,
425
430
  exportAsJsonBlob,
426
431
  exportAsMatrix,
432
+ exportAsMolfile,
427
433
  exportAsPng,
428
434
  exportAsSVG,
429
435
  getBlob,
@@ -33,6 +33,26 @@ export interface SpectraAnalysisData {
33
33
  values: Array<Record<string, AnalyzeSpectraCalculateResult>>;
34
34
  }
35
35
 
36
+ export function cutAnalysis(
37
+ spectraAnalysis: PanelsPreferences['multipleSpectraAnalysis'],
38
+ nucleus: string,
39
+ x: number,
40
+ ) {
41
+ const cutColumns: Record<string, SpectraAnalysisColumn> = {};
42
+
43
+ const analysisOptions = spectraAnalysis[nucleus].analysisOptions;
44
+ for (const [columnKey, column] of Object.entries(analysisOptions.columns)) {
45
+ const { to, from } = column;
46
+ if (x > from && x < to) {
47
+ cutColumns[columnKey] = { ...column, from: x, to };
48
+ const newKey = generateChar(analysisOptions.columnIndex).toUpperCase();
49
+ cutColumns[newKey] = { ...column, from, to: x };
50
+ analysisOptions.columnIndex++;
51
+ }
52
+ }
53
+ analysisOptions.columns = { ...analysisOptions.columns, ...cutColumns };
54
+ }
55
+
36
56
  function addColumnKey(
37
57
  spectraAnalysis: PanelsPreferences['multipleSpectraAnalysis'],
38
58
  nucleus: string,
@@ -66,16 +66,26 @@ function getDefaultContoursLevel(spectrum: Spectrum2D, quadrant = 'rr') {
66
66
  const minAllowed = 3 * xMaxAbsoluteValue([positive, negative]);
67
67
 
68
68
  const minLevel = Math.max(minAbsPeakBase, minAllowed);
69
- const minContourLevel = calculateValueOfLevel(minLevel, max, true);
69
+ const minContourLevel = Math.min(
70
+ calculateValueOfLevel(minLevel, max, true),
71
+ DEFAULT_CONTOURS_OPTIONS.positive.contourLevels[1] -
72
+ DEFAULT_CONTOURS_OPTIONS.positive.numberOfLayers,
73
+ );
70
74
 
71
75
  const defaultLevel: ContourOptions = {
72
76
  negative: {
73
- numberOfLayers: 10,
74
- contourLevels: [minContourLevel, 100],
77
+ numberOfLayers: DEFAULT_CONTOURS_OPTIONS.negative.numberOfLayers,
78
+ contourLevels: [
79
+ minContourLevel,
80
+ DEFAULT_CONTOURS_OPTIONS.negative.contourLevels[1],
81
+ ],
75
82
  },
76
83
  positive: {
77
- numberOfLayers: 10,
78
- contourLevels: [minContourLevel, 100],
84
+ numberOfLayers: DEFAULT_CONTOURS_OPTIONS.positive.numberOfLayers,
85
+ contourLevels: [
86
+ minContourLevel,
87
+ DEFAULT_CONTOURS_OPTIONS.positive.contourLevels[1],
88
+ ],
79
89
  },
80
90
  };
81
91
  return defaultLevel;
@@ -154,7 +164,7 @@ function prepareCheckLevel(options: ContourOptions) {
154
164
  }
155
165
 
156
166
  function getRange(min: number, max: number, length: number, exp?: number) {
157
- if (exp !== undefined) {
167
+ if (exp !== undefined && length > 0) {
158
168
  const factors = new Float64Array(length + 1);
159
169
 
160
170
  for (let i = 1; i < length + 1; i++) {
@@ -35,11 +35,16 @@ export function fromJSON(
35
35
  return molecules;
36
36
  }
37
37
 
38
+ interface AddMolfileOptions {
39
+ id?: string;
40
+ label?: string;
41
+ }
38
42
  export function addMolfile(
39
43
  molecules: StateMoleculeExtended[],
40
44
  molfile: string,
41
- id?: string,
45
+ options: AddMolfileOptions,
42
46
  ) {
47
+ const { id, label } = options;
43
48
  const reservedNumbers = extractLabelsNumbers(molecules);
44
49
 
45
50
  // try to parse molfile
@@ -48,7 +53,7 @@ export function addMolfile(
48
53
  molecules.push(
49
54
  initMolecule({
50
55
  molfile: molecule.toMolfileV3(),
51
- label: `P${getLabelNumber(reservedNumbers)}`,
56
+ label: label ?? `P${getLabelNumber(reservedNumbers)}`,
52
57
  id,
53
58
  }),
54
59
  );
@@ -1 +1 @@
1
- export default { version: 'v1.10.0' };
1
+ export default { version: 'v1.11.0' };