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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nmrium",
3
3
  "description": "React component to display and process nuclear magnetic resonance (NMR) spectra.",
4
- "version": "1.10.0",
4
+ "version": "1.11.0",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "exports": {
@@ -68,48 +68,48 @@
68
68
  "@emotion/react": "^11.14.0",
69
69
  "@emotion/styled": "^11.14.1",
70
70
  "@hookform/resolvers": "^5.2.2",
71
- "@tanstack/react-form": "^1.23.8",
71
+ "@tanstack/react-form": "^1.27.7",
72
72
  "@zakodium/nmr-types": "^0.5.0",
73
- "@zakodium/nmrium-core": "^0.5.1",
74
- "@zakodium/nmrium-core-plugins": "^0.6.20",
73
+ "@zakodium/nmrium-core": "^0.6.0",
74
+ "@zakodium/nmrium-core-plugins": "^0.6.29",
75
75
  "@zakodium/pdnd-esm": "^1.0.2",
76
- "@zip.js/zip.js": "^2.8.11",
76
+ "@zip.js/zip.js": "^2.8.15",
77
77
  "cheminfo-font": "^1.13.1",
78
- "cheminfo-types": "^1.8.1",
78
+ "cheminfo-types": "^1.10.0",
79
79
  "clipboard-polyfill": "^4.1.1",
80
80
  "d3-array": "^3.2.4",
81
81
  "d3-scale": "^4.0.2",
82
82
  "d3-zoom": "^3.0.0",
83
83
  "dlv": "^1.1.3",
84
- "eventemitter3": "^5.0.1",
84
+ "eventemitter3": "^5.0.4",
85
85
  "fifo-logger": "^2.0.1",
86
- "file-collection": "^6.5.0",
86
+ "file-collection": "^6.6.0",
87
87
  "file-saver": "^2.0.5",
88
- "get-jpaths": "^1.1.0",
89
- "immer": "^11.0.1",
90
- "lodash": "^4.17.21",
88
+ "get-jpaths": "^1.4.0",
89
+ "immer": "^11.1.3",
90
+ "lodash": "^4.17.23",
91
91
  "mf-parser": "^3.6.0",
92
92
  "ml-array-mean": "^1.1.6",
93
93
  "ml-array-median": "^1.1.6",
94
94
  "ml-conrec": "^5.0.3",
95
95
  "ml-gsd": "^13.1.1",
96
- "ml-signal-processing": "^2.1.0",
97
- "ml-spectra-processing": "^14.18.1",
96
+ "ml-signal-processing": "^2.2.0",
97
+ "ml-spectra-processing": "^14.19.0",
98
98
  "ml-tree-similarity": "^2.2.0",
99
99
  "nmr-correlation": "2.3.3",
100
- "nmr-processing": "^22.0.0",
100
+ "nmr-processing": "^22.1.0",
101
101
  "numeral": "^2.0.6",
102
- "openchemlib": "^9.18.2",
103
- "openchemlib-utils": "^8.8.1",
102
+ "openchemlib": "^9.19.0",
103
+ "openchemlib-utils": "^8.12.1",
104
104
  "papaparse": "^5.5.3",
105
105
  "react-d3-utils": "^3.1.2",
106
106
  "react-dropzone": "^14.3.8",
107
- "react-error-boundary": "^6.0.0",
108
- "react-hook-form": "^7.66.1",
107
+ "react-error-boundary": "^6.1.0",
108
+ "react-hook-form": "^7.71.1",
109
109
  "react-icons": "^5.5.0",
110
110
  "react-inspector": "^9.0.0",
111
111
  "react-mf": "^3.1.1",
112
- "react-ocl": "^8.4.0",
112
+ "react-ocl": "^8.5.0",
113
113
  "react-ocl-nmr": "^4.1.1",
114
114
  "react-plot": "^3.1.2",
115
115
  "react-rnd": "^10.5.2",
@@ -117,12 +117,12 @@
117
117
  "react-table": "^7.8.0",
118
118
  "smart-array-filter": "^5.0.0",
119
119
  "yup": "^1.7.1",
120
- "zod": "^4.1.12"
120
+ "zod": "^4.3.5"
121
121
  },
122
122
  "devDependencies": {
123
- "@blueprintjs/core": "^6.3.4",
124
- "@blueprintjs/icons": "^6.3.1",
125
- "@blueprintjs/select": "^6.0.8",
123
+ "@blueprintjs/core": "^6.6.1",
124
+ "@blueprintjs/icons": "^6.5.0",
125
+ "@blueprintjs/select": "^6.0.13",
126
126
  "@playwright/test": "^1.57.0",
127
127
  "@simbathesailor/use-what-changed": "^2.0.0",
128
128
  "@types/d3-array": "^3.2.2",
@@ -130,40 +130,40 @@
130
130
  "@types/d3-zoom": "^3.0.8",
131
131
  "@types/dlv": "^1.1.5",
132
132
  "@types/file-saver": "^2.0.7",
133
- "@types/lodash": "^4.17.21",
134
- "@types/node": "^24.10.1",
133
+ "@types/lodash": "^4.17.23",
134
+ "@types/node": "^25.0.10",
135
135
  "@types/numeral": "^2.0.5",
136
- "@types/papaparse": "^5.5.1",
136
+ "@types/papaparse": "^5.5.2",
137
137
  "@types/react": "^18.3.13",
138
138
  "@types/react-dom": "^18.3.1",
139
139
  "@types/react-table": "^7.7.20",
140
- "@vitejs/plugin-react": "^5.1.1",
141
- "@vitest/coverage-v8": "^4.0.14",
140
+ "@vitejs/plugin-react": "^5.1.2",
141
+ "@vitest/coverage-v8": "^4.0.17",
142
142
  "@zakodium/tsconfig": "^1.0.2",
143
143
  "cross-env": "^10.1.0",
144
- "cspell": "^9.4.0",
145
- "eslint": "^9.39.1",
146
- "eslint-config-cheminfo-react": "^19.0.0",
144
+ "cspell": "^9.6.0",
145
+ "eslint": "^9.39.2",
146
+ "eslint-config-cheminfo-react": "^19.0.1",
147
147
  "eslint-config-cheminfo-typescript": "^21.0.1",
148
- "knip": "^5.71.0",
148
+ "knip": "^5.82.1",
149
149
  "modern-normalize": "^3.0.1",
150
150
  "postcss": "^8.5.6",
151
151
  "postcss-styled-syntax": "^0.7.1",
152
- "prettier": "^3.7.3",
152
+ "prettier": "^3.8.1",
153
153
  "rc-menu": "^9.16.1",
154
154
  "react": "^18.3.1",
155
155
  "react-dom": "^18.3.1",
156
- "react-router-dom": "^7.9.6",
156
+ "react-router-dom": "^7.12.0",
157
157
  "rimraf": "^6.1.2",
158
158
  "rollup-plugin-analyzer": "^4.0.0",
159
159
  "serve": "^14.2.5",
160
- "stylelint": "^16.26.1",
161
- "stylelint-config-standard": "^39.0.1",
160
+ "stylelint": "^17.0.0",
161
+ "stylelint-config-standard": "^40.0.0",
162
162
  "typescript": "~5.9.3",
163
- "vite": "^7.2.6",
164
- "vitest": "^4.0.14"
163
+ "vite": "^7.3.1",
164
+ "vitest": "^4.0.17"
165
165
  },
166
166
  "volta": {
167
- "node": "24.11.1"
167
+ "node": "24.12.0"
168
168
  }
169
169
  }
@@ -451,6 +451,14 @@ export function BrushTracker1D({ children }: Required<PropsWithChildren>) {
451
451
  }
452
452
  break;
453
453
  }
454
+ case 'multipleSpectraAnalysis': {
455
+ dispatchPreferences({
456
+ type: 'CUT_SPECTRA_ANALYSIS',
457
+ payload: { x: xPPM, nucleus: activeTab },
458
+ });
459
+
460
+ break;
461
+ }
454
462
  case 'phaseCorrection':
455
463
  dispatch({
456
464
  type: 'SET_ONE_DIMENSION_PIVOT_POINT',
@@ -269,7 +269,6 @@ function DraggablePublicationString(props: DraggablePublicationStringProps) {
269
269
  dragHandleClassName="handle"
270
270
  enableUserSelectHack={false}
271
271
  bounds={`#${viewerRef.id}`}
272
- style={{ zIndex: 1 }}
273
272
  onDragStart={() => setIsMoveActive(true)}
274
273
  onResize={(e, dir, eRef, size, position) =>
275
274
  handleResize({ ...size, ...position })
@@ -301,7 +301,6 @@ function DraggableRanges(props: DraggablePublicationStringProps) {
301
301
  dragHandleClassName="handle"
302
302
  enableUserSelectHack={false}
303
303
  bounds={`#${viewerRef.id}`}
304
- style={{ zIndex: 1 }}
305
304
  onDragStart={() => setIsMoveActive(true)}
306
305
  onResize={(e, dir, eRef, size, position) =>
307
306
  handleResize({ ...size, ...position })
@@ -189,7 +189,6 @@ export function DraggableInset(props: Inset) {
189
189
  dragHandleClassName="handle"
190
190
  enableUserSelectHack={false}
191
191
  bounds={`#${viewerRef.id}`}
192
- style={{ zIndex: 1 }}
193
192
  onDragStart={() => setIsMoveActive(true)}
194
193
  onResize={(e, dir, eRef, size, position) =>
195
194
  handleResize({ ...size, ...position })
@@ -40,6 +40,10 @@ const ReactRnd = styled(Rnd)`
40
40
  background-color: white;
41
41
  border: 1px solid #ebecf1;
42
42
  }
43
+
44
+ form {
45
+ z-index: 1;
46
+ }
43
47
  `;
44
48
 
45
49
  export function DraggableStructure(props: DraggableStructureProps) {
@@ -165,7 +169,6 @@ export function DraggableStructure(props: DraggableStructureProps) {
165
169
  dragHandleClassName="handle"
166
170
  enableUserSelectHack={false}
167
171
  bounds={`#${viewerRef.id}`}
168
- style={{ zIndex: 1 }}
169
172
  className="draggable-molecule"
170
173
  onDragStart={() => setIsMoveActive(true)}
171
174
  onResizeStop={(e, dir, eRef, { width, height }) =>
@@ -194,7 +197,13 @@ export function DraggableStructure(props: DraggableStructureProps) {
194
197
  >
195
198
  <div
196
199
  className="content"
197
- onDoubleClick={() => openMoleculeEditor(molecule)}
200
+ onDoubleClick={(e) => {
201
+ if ((e.target as HTMLElement).closest('form')) {
202
+ return;
203
+ }
204
+
205
+ openMoleculeEditor(molecule);
206
+ }}
198
207
  >
199
208
  <ResponsiveChart>
200
209
  {({ width, height }) => {
@@ -56,9 +56,10 @@ export function useTracesSpectra() {
56
56
  } = useChartData();
57
57
 
58
58
  return useMemo(() => {
59
- if (!activeTab) return { ...defaultEmptyTraces };
60
-
61
- const nuclei = activeTab.split(',');
59
+ const nuclei = activeTab?.split(',');
60
+ if (nuclei?.length !== 2) {
61
+ return { ...defaultEmptyTraces };
62
+ }
62
63
 
63
64
  return getTracesSpectra({ nuclei, spectra, activeSpectra });
64
65
  }, [activeTab, spectra, activeSpectra]);
@@ -51,7 +51,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
51
51
  changeDisplayViewModeHandler,
52
52
  } = useToolsFunctions();
53
53
 
54
- const { saveAsJSONHandler } = useExport();
54
+ const { defaultSaveAsHandler } = useExport();
55
55
  const isToolVisible = useCheckToolsVisibility();
56
56
 
57
57
  const { highlight, remove } = useHighlightData();
@@ -428,7 +428,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
428
428
  break;
429
429
  case 's':
430
430
  if (isToolVisible('exportAs')) {
431
- saveAsJSONHandler();
431
+ defaultSaveAsHandler();
432
432
  e.preventDefault();
433
433
  }
434
434
  break;
@@ -488,7 +488,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
488
488
  nuclei,
489
489
  openLoader,
490
490
  openSaveAsDialog,
491
- saveAsJSONHandler,
491
+ defaultSaveAsHandler,
492
492
  toaster,
493
493
  ],
494
494
  );
@@ -1,7 +1,6 @@
1
1
  import styled from '@emotion/styled';
2
2
  import type { CSSProperties, ReactElement } from 'react';
3
- import { Children } from 'react';
4
- import { useResizeObserver } from 'react-d3-utils';
3
+ import { Children, useLayoutEffect, useRef, useState } from 'react';
5
4
  import { FaAngleLeft } from 'react-icons/fa';
6
5
 
7
6
  type Direction = 'right' | 'left';
@@ -90,10 +89,35 @@ interface NextPrevProps {
90
89
 
91
90
  export function NextPrev(props: NextPrevProps) {
92
91
  const { children, index = 0, onChange = () => null, style = {} } = props;
93
- const [ref, { width } = { width: 0 }] = useResizeObserver();
94
92
  const slidersCount = Children.count(children);
95
93
  const lastIndex = slidersCount > 0 ? slidersCount - 1 : 0;
96
94
  const activeIndex = Math.min(index, lastIndex);
95
+ const containerRef = useRef<HTMLDivElement>(null);
96
+
97
+ const [width, setWidth] = useState(0);
98
+
99
+ useLayoutEffect(() => {
100
+ const container = containerRef.current;
101
+ if (!container) return;
102
+
103
+ const observer = new ResizeObserver((entries) => {
104
+ for (const entry of entries) {
105
+ const newWidth = entry.contentRect.width;
106
+ if (newWidth > 0) {
107
+ setWidth(newWidth);
108
+ }
109
+ }
110
+ });
111
+
112
+ observer.observe(container);
113
+
114
+ const rect = container.getBoundingClientRect();
115
+ if (rect.width > 0) {
116
+ setWidth(rect.width);
117
+ }
118
+
119
+ return () => observer.disconnect();
120
+ }, []);
97
121
 
98
122
  function nextHandler() {
99
123
  if (index < lastIndex) {
@@ -113,7 +137,7 @@ export function NextPrev(props: NextPrevProps) {
113
137
  const slidersWidth = width * slidersCount;
114
138
 
115
139
  return (
116
- <Container ref={ref}>
140
+ <Container ref={containerRef}>
117
141
  <TransformController
118
142
  translation={translation}
119
143
  slidersWidth={slidersWidth}
@@ -1,6 +1,6 @@
1
+ import type { NmriumState } from '@zakodium/nmrium-core';
1
2
  import { useCallback } from 'react';
2
3
 
3
- import type { ExportOptions } from '../../data/SpectraManager.js';
4
4
  import { toJSON } from '../../data/SpectraManager.js';
5
5
  import { useChartData } from '../context/ChartContext.js';
6
6
  import { useCore } from '../context/CoreContext.js';
@@ -9,17 +9,21 @@ import { useToaster } from '../context/ToasterContext.js';
9
9
  import {
10
10
  browserNotSupportedErrorToast,
11
11
  copyPNGToClipboard,
12
- exportAsJsonBlob,
13
12
  exportAsPng,
14
13
  exportAsSVG,
15
14
  } from '../utility/export.js';
16
15
  import { saveAs } from '../utility/save_as.ts';
17
16
 
18
- interface SaveOptions {
19
- include: ExportOptions;
17
+ export interface SaveOptions {
18
+ include: {
19
+ settings: boolean;
20
+ view: boolean;
21
+ dataType:
22
+ | 'NO_DATA'
23
+ | 'SELF_CONTAINED'
24
+ | 'SELF_CONTAINED_EXTERNAL_DATASOURCE';
25
+ };
20
26
  name: string;
21
- compressed: boolean;
22
- pretty: boolean;
23
27
  }
24
28
 
25
29
  export function useExport() {
@@ -28,75 +32,29 @@ export function useExport() {
28
32
  const preferencesState = usePreferences();
29
33
  const core = useCore();
30
34
 
31
- const saveAsJSONHandler = useCallback(
32
- (spaceIndent = 0, isCompressed = true) => {
33
- const hideLoading = toaster.showLoading({
34
- message: 'Exporting as NMRium process in progress',
35
- });
36
- setTimeout(async () => {
37
- try {
38
- const name = state.data[0]?.info?.name || 'experiment';
39
- const exportedData = toJSON(core, state, preferencesState, {
40
- exportTarget: 'nmrium',
41
- view: true,
42
- });
43
-
44
- const blob = await exportAsJsonBlob(
45
- exportedData,
46
- name,
47
- spaceIndent,
48
- isCompressed,
49
- );
50
- saveAs({ blob, name, extension: '.nmrium' });
51
- } catch (error) {
52
- toaster.show({
53
- intent: 'danger',
54
- message: `Export failed due to an unexpected error: ${(error as Error)?.message || 'Unknown error'}`,
55
- });
56
- reportError(error);
57
- } finally {
58
- hideLoading();
59
- }
60
- }, 0);
61
- },
62
- [core, preferencesState, state, toaster],
63
- );
64
-
65
35
  const saveHandler = useCallback(
66
36
  (options: SaveOptions) => {
67
37
  async function handler() {
68
- const { pretty, compressed, include } = options;
69
38
  const name = options.name || 'experiment';
70
- const exportArchive =
71
- include.dataType?.startsWith('SELF_CONTAINED') ?? false;
39
+ const include = options.include;
72
40
 
73
41
  const hideLoading = toaster.showLoading({
74
- message: `Exporting as ${name}.nmrium process in progress`,
42
+ message: `Exporting as ${name}.nmrium.zip process in progress`,
75
43
  });
76
44
  setTimeout(async () => {
77
45
  try {
78
- const exportedData = toJSON(core, state, preferencesState, {
79
- ...include,
46
+ const nmriumState = toJSON(core, state, preferencesState, {
47
+ serialize: false,
80
48
  exportTarget: 'nmrium',
81
- });
82
- const spaceIndent = pretty || exportArchive ? 2 : 0;
83
- const blob = await exportAsJsonBlob(
84
- exportedData,
85
- name,
86
- spaceIndent,
87
- compressed && !exportArchive,
88
- );
89
-
90
- if (!exportArchive) {
91
- return saveAs({ blob, name, extension: '.nmrium' });
92
- }
93
-
49
+ }) as NmriumState;
94
50
  const archive = await core.serializeNmriumArchive({
95
- molecules: state.molecules,
96
- spectra: state.data,
51
+ state: nmriumState,
97
52
  aggregator: state.aggregator,
98
- includeData: options.include.dataType === 'SELF_CONTAINED',
99
- serializedState: blob,
53
+ includeData: include.dataType !== 'NO_DATA',
54
+ externalData:
55
+ include.dataType === 'SELF_CONTAINED' ? 'embedded' : 'linked',
56
+ includeSettings: include.settings,
57
+ includeView: include.view,
100
58
  });
101
59
  const zipBlob = new Blob([archive], {
102
60
  type: 'chemical/x-nmrium+zip',
@@ -119,8 +77,20 @@ export function useExport() {
119
77
  [core, preferencesState, state, toaster],
120
78
  );
121
79
 
80
+ const defaultName = state.data[0]?.info?.name || 'experiment';
81
+ const defaultSaveAsHandler = useCallback(() => {
82
+ saveHandler({
83
+ name: defaultName,
84
+ include: {
85
+ dataType: 'SELF_CONTAINED',
86
+ view: true,
87
+ settings: false,
88
+ },
89
+ });
90
+ }, [saveHandler, defaultName]);
91
+
122
92
  return {
123
- saveAsJSONHandler,
93
+ defaultSaveAsHandler,
124
94
  saveHandler,
125
95
  };
126
96
  }
@@ -1,10 +1,11 @@
1
+ import { useChartData } from '../context/ChartContext.tsx';
1
2
  import { useDispatch } from '../context/DispatchContext.js';
2
3
  import type { EventModifierKeys } from '../context/KeyModifierContext.js';
3
4
  import { getModifiers } from '../context/KeyModifierContext.js';
4
5
 
5
6
  export function useSetActiveSpectrumAction() {
6
7
  const dispatch = useDispatch();
7
-
8
+ const { data: spectra } = useChartData();
8
9
  function setActiveSpectrum(event: EventModifierKeys, id: string) {
9
10
  setTimeout(() => {
10
11
  const { ctrlKey, shiftKey } = getModifiers(event);
@@ -13,7 +14,7 @@ export function useSetActiveSpectrumAction() {
13
14
  }]`;
14
15
  dispatch({
15
16
  type: 'CHANGE_ACTIVE_SPECTRUM',
16
- payload: { modifier, id },
17
+ payload: { modifier, id, sortedSpectra: spectra },
17
18
  });
18
19
  }, 0);
19
20
  }