nmrium 2.2.0 → 2.3.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 (273) hide show
  1. package/lib/component/1d/PredictionErrorsNotations.js +3 -3
  2. package/lib/component/1d/PredictionErrorsNotations.js.map +1 -1
  3. package/lib/component/1d/peaks/Peaks.d.ts.map +1 -1
  4. package/lib/component/1d/peaks/Peaks.js +2 -1
  5. package/lib/component/1d/peaks/Peaks.js.map +1 -1
  6. package/lib/component/1d/peaks/usePeakShapesPath.d.ts.map +1 -1
  7. package/lib/component/1d/peaks/usePeakShapesPath.js.map +1 -1
  8. package/lib/component/1d/ranges/AssignmentLabel.js +1 -1
  9. package/lib/component/1d/ranges/AssignmentLabel.js.map +1 -1
  10. package/lib/component/1d/ranges/FloatingRangeTablePreferencesModal.d.ts +9 -0
  11. package/lib/component/1d/ranges/FloatingRangeTablePreferencesModal.d.ts.map +1 -0
  12. package/lib/component/1d/ranges/FloatingRangeTablePreferencesModal.js +138 -0
  13. package/lib/component/1d/ranges/FloatingRangeTablePreferencesModal.js.map +1 -0
  14. package/lib/component/1d/ranges/FloatingRanges.d.ts.map +1 -0
  15. package/lib/component/1d/ranges/FloatingRanges.js +362 -0
  16. package/lib/component/1d/ranges/FloatingRanges.js.map +1 -0
  17. package/lib/component/1d/ranges/Ranges.js +2 -2
  18. package/lib/component/1d/ranges/Ranges.js.map +1 -1
  19. package/lib/component/1d-2d/FieldEdition.d.ts +2 -2
  20. package/lib/component/1d-2d/FieldEdition.d.ts.map +1 -1
  21. package/lib/component/1d-2d/FieldEdition.js +2 -2
  22. package/lib/component/1d-2d/FieldEdition.js.map +1 -1
  23. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js +7 -7
  24. package/lib/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.js.map +1 -1
  25. package/lib/component/2d/zones/SignalsGuideLines.js +1 -1
  26. package/lib/component/2d/zones/SignalsGuideLines.js.map +1 -1
  27. package/lib/component/2d/zones/ZonesAssignmentsLabels.js +1 -1
  28. package/lib/component/2d/zones/ZonesAssignmentsLabels.js.map +1 -1
  29. package/lib/component/EventsTrackers/BrushTracker.d.ts.map +1 -1
  30. package/lib/component/EventsTrackers/BrushTracker.js.map +1 -1
  31. package/lib/component/SVGTable.d.ts +5 -3
  32. package/lib/component/SVGTable.d.ts.map +1 -1
  33. package/lib/component/SVGTable.js +16 -16
  34. package/lib/component/SVGTable.js.map +1 -1
  35. package/lib/component/context/KeyModifierContext.d.ts.map +1 -1
  36. package/lib/component/context/KeyModifierContext.js.map +1 -1
  37. package/lib/component/context/LoggerContext.d.ts.map +1 -1
  38. package/lib/component/context/LoggerContext.js.map +1 -1
  39. package/lib/component/context/SortSpectraContext.d.ts.map +1 -1
  40. package/lib/component/context/SortSpectraContext.js.map +1 -1
  41. package/lib/component/elements/ActionsButtonsPopover.d.ts +2 -2
  42. package/lib/component/elements/ActionsButtonsPopover.d.ts.map +1 -1
  43. package/lib/component/elements/ActionsButtonsPopover.js +6 -9
  44. package/lib/component/elements/ActionsButtonsPopover.js.map +1 -1
  45. package/lib/component/elements/Button.d.ts.map +1 -1
  46. package/lib/component/elements/Button.js.map +1 -1
  47. package/lib/component/elements/Sections.d.ts.map +1 -1
  48. package/lib/component/elements/Sections.js.map +1 -1
  49. package/lib/component/elements/TabTitle.d.ts.map +1 -1
  50. package/lib/component/elements/TabTitle.js +2 -2
  51. package/lib/component/elements/TabTitle.js.map +1 -1
  52. package/lib/component/elements/ToolbarPopoverItem.d.ts +1 -0
  53. package/lib/component/elements/ToolbarPopoverItem.d.ts.map +1 -1
  54. package/lib/component/elements/ToolbarPopoverItem.js +10 -3
  55. package/lib/component/elements/ToolbarPopoverItem.js.map +1 -1
  56. package/lib/component/elements/dropDownButton/DropDownButton.d.ts.map +1 -1
  57. package/lib/component/elements/dropDownButton/DropDownButton.js +2 -2
  58. package/lib/component/elements/dropDownButton/DropDownButton.js.map +1 -1
  59. package/lib/component/elements/export/ExportOptionsModal.d.ts +1 -1
  60. package/lib/component/elements/export/ExportOptionsModal.d.ts.map +1 -1
  61. package/lib/component/elements/export/ExportOptionsModal.js +31 -110
  62. package/lib/component/elements/export/ExportOptionsModal.js.map +1 -1
  63. package/lib/component/elements/export/units.d.ts +0 -28
  64. package/lib/component/elements/export/units.d.ts.map +1 -1
  65. package/lib/component/elements/export/units.js +0 -5
  66. package/lib/component/elements/export/units.js.map +1 -1
  67. package/lib/component/elements/export/utilities/getExportOptions.d.ts.map +1 -1
  68. package/lib/component/elements/export/utilities/getExportOptions.js.map +1 -1
  69. package/lib/component/elements/print/pageSize.d.ts +1 -1
  70. package/lib/component/elements/print/pageSize.d.ts.map +1 -1
  71. package/lib/component/hooks/useExport.d.ts.map +1 -1
  72. package/lib/component/hooks/useExport.js.map +1 -1
  73. package/lib/component/hooks/usePanelPreferences.d.ts +3 -3
  74. package/lib/component/hooks/usePanelPreferences.d.ts.map +1 -1
  75. package/lib/component/hooks/useTextMetrics.d.ts.map +1 -1
  76. package/lib/component/hooks/useTextMetrics.js +1 -0
  77. package/lib/component/hooks/useTextMetrics.js.map +1 -1
  78. package/lib/component/main/NMRiumViewer.js +1 -1
  79. package/lib/component/main/NMRiumViewer.js.map +1 -1
  80. package/lib/component/modal/EditPeakShapeModal.js +2 -2
  81. package/lib/component/modal/EditPeakShapeModal.js.map +1 -1
  82. package/lib/component/modal/SaveAsModal.d.ts +2 -2
  83. package/lib/component/modal/SaveAsModal.d.ts.map +1 -1
  84. package/lib/component/modal/SaveAsModal.js +43 -35
  85. package/lib/component/modal/SaveAsModal.js.map +1 -1
  86. package/lib/component/modal/editRange/EditRangeModal.js +4 -3
  87. package/lib/component/modal/editRange/EditRangeModal.js.map +1 -1
  88. package/lib/component/modal/editRange/forms/components/NewSignalTab.js +2 -2
  89. package/lib/component/modal/editRange/forms/components/NewSignalTab.js.map +1 -1
  90. package/lib/component/modal/setting/tanstack_general_settings/errors/context.d.ts +5 -5
  91. package/lib/component/modal/setting/tanstack_general_settings/errors/context.js +3 -3
  92. package/lib/component/modal/setting/tanstack_general_settings/errors/context.js.map +1 -1
  93. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.d.ts +5 -5
  94. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.js +2 -2
  95. package/lib/component/modal/setting/tanstack_general_settings/errors/renderer.js.map +1 -1
  96. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.d.ts +5 -5
  97. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.js +2 -2
  98. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.js.map +1 -1
  99. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.d.ts +5 -5
  100. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.js +2 -2
  101. package/lib/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.js.map +1 -1
  102. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.d.ts +5 -5
  103. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.js +2 -2
  104. package/lib/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.js.map +1 -1
  105. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.d.ts +14 -14
  106. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.js +2 -2
  107. package/lib/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.js.map +1 -1
  108. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.d.ts.map +1 -1
  109. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.js +3 -2
  110. package/lib/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.js.map +1 -1
  111. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.d.ts.map +1 -1
  112. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.js +3 -2
  113. package/lib/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.js.map +1 -1
  114. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts.map +1 -1
  115. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +30 -3
  116. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js.map +1 -1
  117. package/lib/component/panels/PeaksPanel/PeaksPreferences.js +18 -18
  118. package/lib/component/panels/PeaksPanel/PeaksPreferences.js.map +1 -1
  119. package/lib/component/panels/PeaksPanel/PeaksTable.js +11 -11
  120. package/lib/component/panels/PeaksPanel/PeaksTable.js.map +1 -1
  121. package/lib/component/panels/RangesPanel/RangesHeader.d.ts.map +1 -1
  122. package/lib/component/panels/RangesPanel/RangesHeader.js.map +1 -1
  123. package/lib/component/panels/RangesPanel/RangesPreferences.js +22 -22
  124. package/lib/component/panels/RangesPanel/RangesPreferences.js.map +1 -1
  125. package/lib/component/panels/RangesPanel/RangesTable.d.ts +2 -2
  126. package/lib/component/panels/RangesPanel/RangesTable.d.ts.map +1 -1
  127. package/lib/component/panels/RangesPanel/RangesTable.js +5 -4
  128. package/lib/component/panels/RangesPanel/RangesTable.js.map +1 -1
  129. package/lib/component/panels/RangesPanel/RangesTableRow.d.ts +2 -2
  130. package/lib/component/panels/RangesPanel/RangesTableRow.js +2 -2
  131. package/lib/component/panels/RangesPanel/RangesTableRow.js.map +1 -1
  132. package/lib/component/panels/SpectraPanel/SpectraTable.d.ts.map +1 -1
  133. package/lib/component/panels/SpectraPanel/SpectraTable.js +5 -1
  134. package/lib/component/panels/SpectraPanel/SpectraTable.js.map +1 -1
  135. package/lib/component/panels/SpectraPanel/base/RenderAsHTML.d.ts.map +1 -1
  136. package/lib/component/panels/SpectraPanel/base/RenderAsHTML.js +7 -4
  137. package/lib/component/panels/SpectraPanel/base/RenderAsHTML.js.map +1 -1
  138. package/lib/component/panels/SpectraPanel/base/SpectrumName.d.ts.map +1 -1
  139. package/lib/component/panels/SpectraPanel/base/SpectrumName.js +5 -1
  140. package/lib/component/panels/SpectraPanel/base/SpectrumName.js.map +1 -1
  141. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts.map +1 -1
  142. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.js +2 -2
  143. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.js.map +1 -1
  144. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts.map +1 -1
  145. package/lib/component/panels/SummaryPanel/SummaryPanel.js.map +1 -1
  146. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts +3 -2
  147. package/lib/component/panels/hooks/useMoleculeAnnotationCore.d.ts.map +1 -1
  148. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js +14 -8
  149. package/lib/component/panels/hooks/useMoleculeAnnotationCore.js.map +1 -1
  150. package/lib/component/panels/informationPanel/MixedValuesBadge.d.ts.map +1 -1
  151. package/lib/component/panels/informationPanel/MixedValuesBadge.js +2 -2
  152. package/lib/component/panels/informationPanel/MixedValuesBadge.js.map +1 -1
  153. package/lib/component/panels/informationPanel/SpectraPicker.d.ts.map +1 -1
  154. package/lib/component/panels/informationPanel/SpectraPicker.js +2 -2
  155. package/lib/component/panels/informationPanel/SpectraPicker.js.map +1 -1
  156. package/lib/component/reducer/actions/DomainActions.d.ts.map +1 -1
  157. package/lib/component/reducer/actions/DomainActions.js.map +1 -1
  158. package/lib/component/reducer/actions/FiltersActions.d.ts.map +1 -1
  159. package/lib/component/reducer/actions/FiltersActions.js.map +1 -1
  160. package/lib/component/reducer/actions/LoadAction.d.ts.map +1 -1
  161. package/lib/component/reducer/actions/LoadAction.js.map +1 -1
  162. package/lib/component/reducer/helper/setRangesViewProperty.d.ts.map +1 -1
  163. package/lib/component/reducer/helper/setRangesViewProperty.js.map +1 -1
  164. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts.map +1 -1
  165. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +35 -26
  166. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js.map +1 -1
  167. package/lib/component/reducer/preferences/preferencesReducer.d.ts +2 -2
  168. package/lib/component/reducer/preferences/preferencesReducer.d.ts.map +1 -1
  169. package/lib/component/reducer/preferences/utilities/initWorkspace.d.ts +2 -2
  170. package/lib/component/reducer/preferences/utilities/mapWorkspaces.d.ts +2 -2
  171. package/lib/component/reducer/preferences/utilities/mapWorkspaces.d.ts.map +1 -1
  172. package/lib/component/toolbar/ToolTypes.d.ts +2 -2
  173. package/lib/component/utility/export.d.ts.map +1 -1
  174. package/lib/component/utility/export.js +1 -0
  175. package/lib/component/utility/export.js.map +1 -1
  176. package/lib/data/PredictionManager.js.map +1 -1
  177. package/lib/data/constants/signalsKinds.d.ts +1 -2
  178. package/lib/data/constants/signalsKinds.d.ts.map +1 -1
  179. package/lib/data/data1d/multipleSpectraAnalysis.d.ts +2 -2
  180. package/lib/data/matrixGeneration.d.ts.map +1 -1
  181. package/lib/data/matrixGeneration.js.map +1 -1
  182. package/lib/versionInfo.js +1 -1
  183. package/package.json +30 -31
  184. package/src/component/1d/PredictionErrorsNotations.tsx +5 -4
  185. package/src/component/1d/peaks/Peaks.tsx +5 -2
  186. package/src/component/1d/peaks/usePeakShapesPath.ts +0 -1
  187. package/src/component/1d/ranges/AssignmentLabel.tsx +1 -1
  188. package/src/component/1d/ranges/FloatingRangeTablePreferencesModal.tsx +238 -0
  189. package/src/component/1d/ranges/FloatingRanges.tsx +529 -0
  190. package/src/component/1d/ranges/Ranges.tsx +2 -2
  191. package/src/component/1d-2d/FieldEdition.tsx +4 -4
  192. package/src/component/1d-2d/components/FloatMoleculeStructures/DraggableStructure.tsx +8 -8
  193. package/src/component/2d/zones/SignalsGuideLines.tsx +1 -1
  194. package/src/component/2d/zones/ZonesAssignmentsLabels.tsx +1 -1
  195. package/src/component/EventsTrackers/BrushTracker.tsx +1 -2
  196. package/src/component/SVGTable.tsx +35 -33
  197. package/src/component/context/KeyModifierContext.tsx +1 -2
  198. package/src/component/context/LoggerContext.tsx +1 -7
  199. package/src/component/context/SortSpectraContext.tsx +1 -3
  200. package/src/component/elements/ActionsButtonsPopover.tsx +12 -14
  201. package/src/component/elements/Button.tsx +1 -6
  202. package/src/component/elements/Sections.tsx +5 -3
  203. package/src/component/elements/TabTitle.tsx +7 -5
  204. package/src/component/elements/ToolbarPopoverItem.tsx +13 -2
  205. package/src/component/elements/dropDownButton/DropDownButton.tsx +7 -5
  206. package/src/component/elements/export/ExportOptionsModal.tsx +56 -276
  207. package/src/component/elements/export/units.ts +0 -6
  208. package/src/component/elements/export/utilities/getExportOptions.ts +1 -0
  209. package/src/component/elements/print/pageSize.ts +1 -1
  210. package/src/component/hooks/useExport.tsx +1 -3
  211. package/src/component/hooks/usePanelPreferences.ts +4 -4
  212. package/src/component/hooks/useTextMetrics.ts +1 -0
  213. package/src/component/main/NMRiumViewer.tsx +1 -1
  214. package/src/component/modal/EditPeakShapeModal.tsx +2 -2
  215. package/src/component/modal/SaveAsModal.tsx +89 -82
  216. package/src/component/modal/editRange/EditRangeModal.tsx +6 -4
  217. package/src/component/modal/editRange/forms/components/NewSignalTab.tsx +3 -3
  218. package/src/component/modal/setting/WorkspaceItem.tsx +2 -2
  219. package/src/component/modal/setting/tanstack_general_settings/errors/context.tsx +3 -3
  220. package/src/component/modal/setting/tanstack_general_settings/errors/renderer.tsx +2 -2
  221. package/src/component/modal/setting/tanstack_general_settings/general_settings_dialog_body.tsx +2 -2
  222. package/src/component/modal/setting/tanstack_general_settings/general_settings_dialog_header.tsx +2 -2
  223. package/src/component/modal/setting/tanstack_general_settings/tabs/auto_processing_tab.tsx +2 -2
  224. package/src/component/modal/setting/tanstack_general_settings/tabs/export_tab.fields.tsx +2 -2
  225. package/src/component/modal/setting/tanstack_general_settings/tabs/spectra_label_tab.tsx +3 -2
  226. package/src/component/modal/setting/tanstack_general_settings/tabs/title_block_tab.tsx +3 -2
  227. package/src/component/panels/MoleculesPanel/MoleculePanelHeader.tsx +41 -8
  228. package/src/component/panels/PeaksPanel/PeaksPreferences.tsx +18 -18
  229. package/src/component/panels/PeaksPanel/PeaksTable.tsx +11 -11
  230. package/src/component/panels/RangesPanel/RangesHeader.tsx +1 -2
  231. package/src/component/panels/RangesPanel/RangesPanel.tsx +2 -2
  232. package/src/component/panels/RangesPanel/RangesPreferences.tsx +22 -22
  233. package/src/component/panels/RangesPanel/RangesTable.tsx +19 -17
  234. package/src/component/panels/RangesPanel/RangesTableRow.tsx +25 -25
  235. package/src/component/panels/SpectraPanel/SpectraTable.tsx +12 -1
  236. package/src/component/panels/SpectraPanel/base/RenderAsHTML.tsx +22 -4
  237. package/src/component/panels/SpectraPanel/base/SpectrumName.tsx +15 -6
  238. package/src/component/panels/SpectraPanel/base/setting/SpectrumSetting.tsx +3 -2
  239. package/src/component/panels/SummaryPanel/SummaryPanel.tsx +1 -5
  240. package/src/component/panels/hooks/useMoleculeAnnotationCore.ts +17 -9
  241. package/src/component/panels/informationPanel/MixedValuesBadge.tsx +3 -2
  242. package/src/component/panels/informationPanel/SpectraPicker.tsx +12 -4
  243. package/src/component/panels/multipleAnalysisPanel/AnalysisChart.tsx +2 -2
  244. package/src/component/reducer/actions/DomainActions.ts +1 -4
  245. package/src/component/reducer/actions/FiltersActions.ts +1 -2
  246. package/src/component/reducer/actions/LoadAction.ts +1 -3
  247. package/src/component/reducer/helper/setRangesViewProperty.ts +1 -2
  248. package/src/component/reducer/preferences/panelsPreferencesDefaultValues.ts +32 -19
  249. package/src/component/reducer/preferences/preferencesReducer.ts +2 -2
  250. package/src/component/reducer/preferences/utilities/initWorkspace.ts +2 -2
  251. package/src/component/reducer/preferences/utilities/mapWorkspaces.ts +2 -2
  252. package/src/component/toolbar/ToolTypes.ts +2 -2
  253. package/src/component/utility/export.ts +1 -0
  254. package/src/data/PredictionManager.ts +4 -6
  255. package/src/data/constants/signalsKinds.ts +1 -1
  256. package/src/data/data1d/multipleSpectraAnalysis.ts +2 -2
  257. package/src/data/matrixGeneration.ts +1 -5
  258. package/src/versionInfo.ts +1 -1
  259. package/lib/component/1d/FloatingRanges.d.ts.map +0 -1
  260. package/lib/component/1d/FloatingRanges.js +0 -263
  261. package/lib/component/1d/FloatingRanges.js.map +0 -1
  262. package/lib/component/elements/export/utilities/exportOptionValidationSchema.d.ts +0 -17
  263. package/lib/component/elements/export/utilities/exportOptionValidationSchema.d.ts.map +0 -1
  264. package/lib/component/elements/export/utilities/exportOptionValidationSchema.js +0 -79
  265. package/lib/component/elements/export/utilities/exportOptionValidationSchema.js.map +0 -1
  266. package/lib/component/elements/export/utilities/getModes.d.ts +0 -4
  267. package/lib/component/elements/export/utilities/getModes.d.ts.map +0 -1
  268. package/lib/component/elements/export/utilities/getModes.js +0 -11
  269. package/lib/component/elements/export/utilities/getModes.js.map +0 -1
  270. package/src/component/1d/FloatingRanges.tsx +0 -378
  271. package/src/component/elements/export/utilities/exportOptionValidationSchema.ts +0 -106
  272. package/src/component/elements/export/utilities/getModes.ts +0 -14
  273. /package/lib/component/1d/{FloatingRanges.d.ts → ranges/FloatingRanges.d.ts} +0 -0
@@ -1,79 +0,0 @@
1
- import * as Yup from 'yup';
2
- import { pageSizes } from '../../print/pageSize.js';
3
- import { convertToPixels, units } from '../units.js';
4
- const MAX_PIXEL = 16000;
5
- const unitsKeys = units.map(({ unit }) => unit, []);
6
- const pageSizesKeys = pageSizes.map(({ name }) => name, []);
7
- function testSize(value, unit, dpi) {
8
- const valueInPixel = convertToPixels(value, unit, dpi, {
9
- precision: 2,
10
- });
11
- if (value) {
12
- return valueInPixel <= MAX_PIXEL;
13
- }
14
- return true;
15
- }
16
- // export const exportOptionValidationSchema = Yup.object().shape({
17
- // width: Yup.number()
18
- // .required()
19
- // .test(
20
- // 'width-test',
21
- // `Width should be less or equal to ${MAX_PIXEL}`,
22
- // // eslint-disable-next-line func-names
23
- // function (value) {
24
- // // eslint-disable-next-line no-invalid-this
25
- // const { unit, dpi } = this.parent;
26
- // return testSize(value, unit, dpi);
27
- // },
28
- // ),
29
- // height: Yup.number()
30
- // .required()
31
- // .test(
32
- // 'height-test',
33
- // `Height should be less or equal to ${MAX_PIXEL}`,
34
- // // eslint-disable-next-line func-names
35
- // function (value) {
36
- // // eslint-disable-next-line no-invalid-this
37
- // const { unit, dpi } = this.parent;
38
- // return testSize(value, unit, dpi);
39
- // },
40
- // ),
41
- // dpi: Yup.number().required(),
42
- // unit: Yup.mixed<Unit>().oneOf(unitsKeys, 'Unit is invalid').required(),
43
- // useDefaultSettings: Yup.boolean().required(),
44
- // });
45
- const advanceExportOptionValidationSchema = Yup.object().shape({
46
- mode: Yup.string().oneOf(['basic', 'advance']).required(),
47
- width: Yup.number()
48
- .required()
49
- .test('width-test', `Width should be less or equal to ${MAX_PIXEL}`, (value, context) => {
50
- const { unit, dpi } = context.parent;
51
- return testSize(value, unit, dpi);
52
- }),
53
- height: Yup.number()
54
- .required()
55
- .test('height-test', `Height should be less or equal to ${MAX_PIXEL}`, (value, context) => {
56
- const { unit, dpi } = context.parent;
57
- return testSize(value, unit, dpi);
58
- }),
59
- dpi: Yup.number().required(),
60
- unit: Yup.mixed().oneOf(unitsKeys).required(),
61
- useDefaultSettings: Yup.boolean().required(),
62
- });
63
- const basicExportOptionValidationSchema = Yup.object().shape({
64
- mode: Yup.string().oneOf(['basic', 'advance']).required(),
65
- size: Yup.mixed()
66
- .oneOf(pageSizesKeys, 'Size is invalid')
67
- .required(),
68
- layout: Yup.mixed()
69
- .oneOf(['portrait', 'landscape'], 'Layout is invalid')
70
- .required(),
71
- dpi: Yup.number().required(),
72
- useDefaultSettings: Yup.boolean().required(),
73
- });
74
- export const exportOptionValidationSchema = Yup.lazy((values) => {
75
- return values?.mode === 'advance'
76
- ? advanceExportOptionValidationSchema
77
- : basicExportOptionValidationSchema;
78
- });
79
- //# sourceMappingURL=exportOptionValidationSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exportOptionValidationSchema.js","sourceRoot":"","sources":["../../../../../src/component/elements/export/utilities/exportOptionValidationSchema.ts"],"names":[],"mappings":"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"}
@@ -1,4 +0,0 @@
1
- import type { OptionProps } from '@blueprintjs/core';
2
- export declare const MODES: Array<OptionProps<string>>;
3
- export type Mode = (typeof MODES)[number]['value'];
4
- //# sourceMappingURL=getModes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getModes.d.ts","sourceRoot":"","sources":["../../../../../src/component/elements/export/utilities/getModes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAS5C,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- export const MODES = [
2
- {
3
- label: 'Basic',
4
- value: 'basic',
5
- },
6
- {
7
- label: 'Advanced',
8
- value: 'advance',
9
- },
10
- ];
11
- //# sourceMappingURL=getModes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getModes.js","sourceRoot":"","sources":["../../../../../src/component/elements/export/utilities/getModes.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAA+B;IAC/C;QACE,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf;IACD;QACE,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,SAAS;KACjB;CACF,CAAC"}
@@ -1,378 +0,0 @@
1
- import styled from '@emotion/styled';
2
- import type { Ranges } from '@zakodium/nmr-types';
3
- import type { BoundingBox } from '@zakodium/nmrium-core';
4
- import { checkMultiplicity } from 'nmr-processing';
5
- import { memo, useEffect, useState } from 'react';
6
- import { BsArrowsMove } from 'react-icons/bs';
7
- import { FaTimes } from 'react-icons/fa';
8
- import { Rnd } from 'react-rnd';
9
-
10
- import { isSpectrum1D } from '../../data/data1d/Spectrum1D/index.js';
11
- import { isSignalRange } from '../../data/utilities/RangeUtilities.js';
12
- import type { SVGTableColumn } from '../SVGTable.js';
13
- import { SVGTable } from '../SVGTable.js';
14
- import { useChartData } from '../context/ChartContext.js';
15
- import { useDispatch } from '../context/DispatchContext.js';
16
- import { useGlobal } from '../context/GlobalContext.js';
17
- import type { ActionsButtonsPopoverProps } from '../elements/ActionsButtonsPopover.js';
18
- import { ActionsButtonsPopover } from '../elements/ActionsButtonsPopover.js';
19
- import { useActiveNucleusTab } from '../hooks/useActiveNucleusTab.js';
20
- import { usePanelPreferences } from '../hooks/usePanelPreferences.js';
21
- import { useSVGUnitConverter } from '../hooks/useSVGUnitConverter.js';
22
- import useSpectraByActiveNucleus from '../hooks/useSpectraPerNucleus.js';
23
- import { useCheckExportStatus } from '../hooks/useViewportSize.js';
24
- import { extractChemicalElement } from '../utility/extractChemicalElement.js';
25
- import { formatNumber } from '../utility/formatNumber.js';
26
-
27
- const ReactRnd = styled(Rnd)`
28
- border: 1px solid transparent;
29
-
30
- :hover {
31
- background-color: white;
32
- border: 1px solid #ebecf1;
33
-
34
- button {
35
- visibility: visible;
36
- }
37
- }
38
- `;
39
-
40
- interface RangesTableProps {
41
- ranges: Ranges['values'];
42
- }
43
-
44
- interface RangeItem {
45
- id: string;
46
- delta: string;
47
- multiplicity: string;
48
- integration: string;
49
- coupling: string;
50
- }
51
-
52
- function useMapRanges(ranges: Ranges['values']) {
53
- const output: RangeItem[] = [];
54
- const activeTab = useActiveNucleusTab();
55
- const preferences = usePanelPreferences('ranges', activeTab);
56
- for (const range of ranges) {
57
- const { id, from, to, integration, signals = [] } = range;
58
- const relativeFlag = isSignalRange(range);
59
- const formattedValue = formatNumber(
60
- integration,
61
- preferences.relative.format,
62
- );
63
- const integrationValue = relativeFlag
64
- ? formattedValue
65
- : `[ ${formattedValue} ]`;
66
-
67
- const rangeText = `${formatNumber(from, preferences.from.format)} - ${formatNumber(
68
- to,
69
- preferences.to.format,
70
- )}`;
71
- if (signals.length > 0) {
72
- for (const signal of signals) {
73
- const { multiplicity, delta, js = [] } = signal;
74
- const coupling = js
75
- .map((jsItem) =>
76
- !Number.isNaN(jsItem.coupling)
77
- ? formatNumber(jsItem.coupling, preferences.coupling.format)
78
- : '',
79
- )
80
- .join(',');
81
- const signalDelta = !checkMultiplicity(multiplicity, ['m'])
82
- ? rangeText
83
- : formatNumber(delta, preferences.deltaPPM.format);
84
- output.push({
85
- id,
86
- delta: signalDelta,
87
- multiplicity,
88
- integration: integrationValue,
89
- coupling,
90
- });
91
- }
92
- } else {
93
- output.push({
94
- id,
95
- delta: rangeText,
96
- multiplicity: 'm',
97
- integration: integrationValue,
98
- coupling: '',
99
- });
100
- }
101
- }
102
- return output;
103
- }
104
- function InnerSVGRangesTable(props: RangesTableProps) {
105
- const { ranges } = props;
106
- const {
107
- view: {
108
- spectra: { activeTab },
109
- },
110
- } = useChartData();
111
- const data = useMapRanges(ranges);
112
-
113
- if (!data) return null;
114
-
115
- const element = extractChemicalElement(activeTab);
116
-
117
- const columns: Array<SVGTableColumn<RangeItem>> = [
118
- {
119
- accessorKey: 'delta',
120
- header: 'δ (ppm)',
121
- width: 100,
122
- rowSpanGroupKey: 'id',
123
- headerTextProps: { fontWeight: 'bold' },
124
- cellBoxProps: { stroke: '#dedede', fill: 'white', fillOpacity: 0.8 },
125
- headerBoxProps: { stroke: '#dedede', fill: '#E5E8EB' },
126
- },
127
- {
128
- accessorKey: 'integration',
129
- header: `Rel. ${element}`,
130
- width: 60,
131
- rowSpanGroupKey: 'id',
132
- headerTextProps: { fontWeight: 'bold' },
133
- cellBoxProps: { stroke: '#dedede', fill: 'white', fillOpacity: 0.8 },
134
- headerBoxProps: { stroke: '#dedede', fill: '#E5E8EB' },
135
- },
136
- {
137
- accessorKey: 'multiplicity',
138
- header: 'Mult.',
139
- width: 60,
140
- rowSpanGroupKey: 'id',
141
- headerTextProps: { fontWeight: 'bold' },
142
- cellBoxProps: { stroke: '#dedede', fill: 'white', fillOpacity: 0.8 },
143
- headerBoxProps: { stroke: '#dedede', fill: '#E5E8EB' },
144
- },
145
- {
146
- accessorKey: 'coupling',
147
- header: 'J (Hz)',
148
- width: 120,
149
- headerTextProps: { fontWeight: 'bold' },
150
- cellBoxProps: { stroke: '#dedede', fill: 'white', fillOpacity: 0.8 },
151
- headerBoxProps: { stroke: '#dedede', fill: '#E5E8EB' },
152
- },
153
- ];
154
-
155
- return <SVGTable<RangeItem> data={data} columns={columns} />;
156
- }
157
-
158
- const SVGRangesTable = memo(InnerSVGRangesTable);
159
-
160
- interface DraggablePublicationStringProps {
161
- ranges: Ranges['values'] | undefined;
162
- bonding: BoundingBox;
163
- spectrumKey: string;
164
- }
165
-
166
- function DraggableRanges(props: DraggablePublicationStringProps) {
167
- const { ranges = [], bonding: externalBounding, spectrumKey } = props;
168
- const dispatch = useDispatch();
169
- const { viewerRef } = useGlobal();
170
- const [bounding, setBounding] = useState<BoundingBox>(externalBounding);
171
- const [isMoveActive, setIsMoveActive] = useState(false);
172
- const { percentToPixel, pixelToPercent } = useSVGUnitConverter();
173
- const isExportProcessStart = useCheckExportStatus();
174
-
175
- useEffect(() => {
176
- setBounding({ ...externalBounding });
177
- }, [externalBounding]);
178
-
179
- function handleResize(
180
- internalBounding: Pick<BoundingBox, 'height' | 'width'>,
181
- ) {
182
- const { width = 0, height = 0 } = convertToPixel(externalBounding);
183
- internalBounding.width += width;
184
- internalBounding.height += height;
185
- setBounding((prevBounding) => ({
186
- ...prevBounding,
187
- ...convertToPercent(internalBounding),
188
- }));
189
- }
190
-
191
- function handleDrag(internalBounding: Pick<BoundingBox, 'x' | 'y'>) {
192
- setBounding((prevBounding) => ({
193
- ...prevBounding,
194
- ...convertToPercent(internalBounding),
195
- }));
196
- }
197
- function handleChangeInsetBounding(bounding: Partial<BoundingBox>) {
198
- if (
199
- typeof bounding?.width === 'number' &&
200
- typeof bounding?.height === 'number'
201
- ) {
202
- const { width, height } = externalBounding;
203
- bounding.width += width;
204
- bounding.height += height;
205
- }
206
-
207
- dispatch({
208
- type: 'CHANGE_RANGES_VIEW_FLOATING_BOX_BOUNDING',
209
- payload: {
210
- spectrumKey,
211
- bounding: convertToPercent(bounding),
212
- target: 'rangesBounding',
213
- },
214
- });
215
- }
216
-
217
- function convertToPixel(bounding: Partial<BoundingBox>) {
218
- const { x, y, height, width } = bounding;
219
- const output: Partial<BoundingBox> = {};
220
-
221
- if (x) {
222
- output.x = percentToPixel(x, 'x');
223
- }
224
- if (y) {
225
- output.y = percentToPixel(y, 'y');
226
- }
227
- if (width) {
228
- output.width = width;
229
- }
230
- if (height) {
231
- output.height = height;
232
- }
233
-
234
- return output;
235
- }
236
- function convertToPercent(bounding: Partial<BoundingBox>) {
237
- const { x, y, height, width } = bounding;
238
- const output: Partial<BoundingBox> = {};
239
-
240
- if (x) {
241
- output.x = pixelToPercent(x, 'x');
242
- }
243
- if (y) {
244
- output.y = pixelToPercent(y, 'y');
245
- }
246
- if (width) {
247
- output.width = width;
248
- }
249
- if (height) {
250
- output.height = height;
251
- }
252
-
253
- return output;
254
- }
255
-
256
- function handleRemove() {
257
- dispatch({
258
- type: 'TOGGLE_RANGES_VIEW_PROPERTY',
259
- payload: { key: 'showRanges', spectrumKey },
260
- });
261
- }
262
-
263
- const actionButtons: ActionsButtonsPopoverProps['buttons'] = [
264
- {
265
- icon: <BsArrowsMove />,
266
-
267
- intent: 'none',
268
- title: 'Move ranges table',
269
- style: { cursor: 'move' },
270
- className: 'handle',
271
- },
272
- {
273
- icon: <FaTimes />,
274
- intent: 'danger',
275
- title: 'Hide ranges table',
276
- onClick: handleRemove,
277
- },
278
- ];
279
- if (!viewerRef || ranges.length === 0) return null;
280
-
281
- const { x: xInPercent, y: yInPercent } = bounding;
282
-
283
- const x = percentToPixel(xInPercent, 'x');
284
- const y = percentToPixel(yInPercent, 'y');
285
-
286
- if (isExportProcessStart) {
287
- return (
288
- <g transform={`translate(${x} ${y})`}>
289
- <SVGRangesTable ranges={ranges} />
290
- </g>
291
- );
292
- }
293
-
294
- return (
295
- <ReactRnd
296
- default={{ x, y, width: 'auto', height: 'auto' }}
297
- position={{ x, y }}
298
- enableResizing={false}
299
- minWidth={100}
300
- minHeight={50}
301
- dragHandleClassName="handle"
302
- enableUserSelectHack={false}
303
- bounds={`#${viewerRef.id}`}
304
- onDragStart={() => setIsMoveActive(true)}
305
- onResize={(e, dir, eRef, size, position) =>
306
- handleResize({ ...size, ...position })
307
- }
308
- onResizeStop={(e, dir, eRef, size, position) =>
309
- handleChangeInsetBounding({ ...size, ...position })
310
- }
311
- onDrag={(e, { x, y }) => {
312
- handleDrag({ x, y });
313
- }}
314
- onDragStop={(e, { x, y }) => {
315
- handleChangeInsetBounding({ x, y });
316
- setIsMoveActive(false);
317
- }}
318
- resizeHandleWrapperStyle={{ backgroundColor: 'white' }}
319
- >
320
- <ActionsButtonsPopover
321
- buttons={actionButtons}
322
- fill
323
- positioningStrategy="fixed"
324
- direction="row"
325
- targetProps={{ style: { width: '100%', height: '100%' } }}
326
- space={2}
327
- {...(isMoveActive && { isOpen: true })}
328
- x={x}
329
- y={y}
330
- >
331
- <SVGRangesTable ranges={ranges} />
332
- </ActionsButtonsPopover>
333
- </ReactRnd>
334
- );
335
- }
336
-
337
- function useSpectraRanges() {
338
- const spectra = useSpectraByActiveNucleus();
339
- const output: Record<string, Ranges['values']> = {};
340
-
341
- for (const spectrum of spectra) {
342
- if (!isSpectrum1D(spectrum)) {
343
- continue;
344
- }
345
- const { id: spectrumKey, ranges } = spectrum;
346
-
347
- if (!Array.isArray(ranges?.values) || ranges.values.length === 0) {
348
- continue;
349
- }
350
-
351
- output[spectrumKey] = ranges.values;
352
- }
353
-
354
- return output;
355
- }
356
-
357
- export function FloatingRanges() {
358
- const spectraRanges = useSpectraRanges();
359
- const {
360
- view: { ranges },
361
- } = useChartData();
362
-
363
- const options = Object.entries(ranges);
364
-
365
- return options.map(([spectrumKey, viewOptions]) => {
366
- const { showRanges, rangesBounding } = viewOptions;
367
- if (!showRanges) return null;
368
-
369
- return (
370
- <DraggableRanges
371
- key={spectrumKey}
372
- spectrumKey={spectrumKey}
373
- bonding={rangesBounding}
374
- ranges={spectraRanges[spectrumKey]}
375
- />
376
- );
377
- });
378
- }
@@ -1,106 +0,0 @@
1
- import type {
2
- ExportSettings,
3
- Layout,
4
- PageSizeName,
5
- Unit,
6
- } from '@zakodium/nmrium-core';
7
- import * as Yup from 'yup';
8
-
9
- import { pageSizes } from '../../print/pageSize.js';
10
- import { convertToPixels, units } from '../units.js';
11
-
12
- const MAX_PIXEL = 16000;
13
-
14
- const unitsKeys = units.map(({ unit }) => unit, []);
15
- const pageSizesKeys = pageSizes.map(({ name }) => name, []);
16
-
17
- function testSize(value: number, unit: Unit, dpi: number) {
18
- const valueInPixel = convertToPixels(value, unit, dpi, {
19
- precision: 2,
20
- });
21
- if (value) {
22
- return valueInPixel <= MAX_PIXEL;
23
- }
24
- return true;
25
- }
26
-
27
- // export const exportOptionValidationSchema = Yup.object().shape({
28
- // width: Yup.number()
29
- // .required()
30
- // .test(
31
- // 'width-test',
32
- // `Width should be less or equal to ${MAX_PIXEL}`,
33
- // // eslint-disable-next-line func-names
34
- // function (value) {
35
- // // eslint-disable-next-line no-invalid-this
36
- // const { unit, dpi } = this.parent;
37
- // return testSize(value, unit, dpi);
38
- // },
39
- // ),
40
-
41
- // height: Yup.number()
42
- // .required()
43
- // .test(
44
- // 'height-test',
45
- // `Height should be less or equal to ${MAX_PIXEL}`,
46
- // // eslint-disable-next-line func-names
47
- // function (value) {
48
- // // eslint-disable-next-line no-invalid-this
49
- // const { unit, dpi } = this.parent;
50
- // return testSize(value, unit, dpi);
51
- // },
52
- // ),
53
-
54
- // dpi: Yup.number().required(),
55
- // unit: Yup.mixed<Unit>().oneOf(unitsKeys, 'Unit is invalid').required(),
56
- // useDefaultSettings: Yup.boolean().required(),
57
- // });
58
-
59
- const advanceExportOptionValidationSchema = Yup.object().shape({
60
- mode: Yup.string().oneOf(['basic', 'advance']).required(),
61
- width: Yup.number()
62
- .required()
63
- .test(
64
- 'width-test',
65
- `Width should be less or equal to ${MAX_PIXEL}`,
66
- (value, context) => {
67
- const { unit, dpi } = context.parent;
68
- return testSize(value, unit, dpi);
69
- },
70
- ),
71
-
72
- height: Yup.number()
73
- .required()
74
- .test(
75
- 'height-test',
76
- `Height should be less or equal to ${MAX_PIXEL}`,
77
- (value, context) => {
78
- const { unit, dpi } = context.parent;
79
- return testSize(value, unit, dpi);
80
- },
81
- ),
82
-
83
- dpi: Yup.number().required(),
84
- unit: Yup.mixed<Unit>().oneOf(unitsKeys).required(),
85
- useDefaultSettings: Yup.boolean().required(),
86
- });
87
-
88
- const basicExportOptionValidationSchema = Yup.object().shape({
89
- mode: Yup.string().oneOf(['basic', 'advance']).required(),
90
- size: Yup.mixed<PageSizeName>()
91
- .oneOf(pageSizesKeys, 'Size is invalid')
92
- .required(),
93
- layout: Yup.mixed<Layout>()
94
- .oneOf(['portrait', 'landscape'], 'Layout is invalid')
95
- .required(),
96
- dpi: Yup.number().required(),
97
- useDefaultSettings: Yup.boolean().required(),
98
- });
99
-
100
- export const exportOptionValidationSchema = Yup.lazy(
101
- (values: ExportSettings) => {
102
- return values?.mode === 'advance'
103
- ? advanceExportOptionValidationSchema
104
- : basicExportOptionValidationSchema;
105
- },
106
- );
@@ -1,14 +0,0 @@
1
- import type { OptionProps } from '@blueprintjs/core';
2
-
3
- export const MODES: Array<OptionProps<string>> = [
4
- {
5
- label: 'Basic',
6
- value: 'basic',
7
- },
8
- {
9
- label: 'Advanced',
10
- value: 'advance',
11
- },
12
- ];
13
-
14
- export type Mode = (typeof MODES)[number]['value'];