nmrium 0.39.0 → 0.41.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 (306) hide show
  1. package/lib/component/1d/FooterBanner.js +5 -4
  2. package/lib/component/1d/Viewer1D.js +121 -104
  3. package/lib/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
  4. package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +1 -1
  5. package/lib/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
  6. package/lib/component/1d/multiplicityTree/TreeColors.d.ts +1 -1
  7. package/lib/component/1d/multiplicityTree/TreeColors.js +1 -6
  8. package/lib/component/1d/multiplicityTree/TreeNodes.d.ts +1 -1
  9. package/lib/component/1d/tool/BaseLineZones.d.ts +1 -1
  10. package/lib/component/1d/tool/BaseLineZones.js +7 -4
  11. package/lib/component/1d/tool/PeakPointer.js +1 -1
  12. package/lib/component/1d/utilities/scale.js +1 -3
  13. package/lib/component/1d-2d/components/FloatMoleculeStructures/index.d.ts +1 -1
  14. package/lib/component/1d-2d/tools/BrushXY.js +10 -7
  15. package/lib/component/1d-2d/tools/CrossLinePointer.js +1 -1
  16. package/lib/component/2d/FooterBanner.js +3 -2
  17. package/lib/component/2d/Viewer2D.js +51 -29
  18. package/lib/component/2d/XAxis.js +1 -1
  19. package/lib/component/2d/YAxis.js +1 -1
  20. package/lib/component/2d/utilities/SliceScale.d.ts +2 -2
  21. package/lib/component/2d/utilities/scale.d.ts +5 -5
  22. package/lib/component/2d/zones/Signal.js +1 -2
  23. package/lib/component/EventsTrackers/BrushTracker.d.ts +4 -1
  24. package/lib/component/EventsTrackers/BrushTracker.js +21 -6
  25. package/lib/component/NMRium.d.ts +2 -2
  26. package/lib/component/NMRium.js +39 -26
  27. package/lib/component/assignment/AssignmentsReducer.d.ts +1 -1
  28. package/lib/component/assignment/actions/setActiveAssignment.js +1 -1
  29. package/lib/component/context/LoggerContext.js +11 -6
  30. package/lib/component/elements/InputRange.js +1 -1
  31. package/lib/component/elements/MenuButton.d.ts +1 -1
  32. package/lib/component/elements/MoleculeSelection.d.ts +1 -1
  33. package/lib/component/elements/ReactTable/ReactTable.d.ts +1 -1
  34. package/lib/component/elements/Tab/DeleteButton.d.ts +1 -1
  35. package/lib/component/elements/ToolbarMenu.d.ts +1 -1
  36. package/lib/component/elements/accordion/Accordion.d.ts +1 -1
  37. package/lib/component/elements/draggable/SVGDraggable.d.ts +1 -1
  38. package/lib/component/elements/draggable/useDraggable.d.ts +1 -1
  39. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +1 -1
  40. package/lib/component/elements/dropDownButton/DropDownList.js +3 -1
  41. package/lib/component/elements/formik/SelectBox.d.ts +1 -1
  42. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +8 -0
  43. package/lib/component/elements/popup/Alert/AlertBlock.js +30 -0
  44. package/lib/component/elements/popup/Alert/Context.d.ts +26 -2
  45. package/lib/component/elements/popup/Alert/Context.js +6 -2
  46. package/lib/component/elements/popup/Alert/Provider.d.ts +4 -3
  47. package/lib/component/elements/popup/Alert/Provider.js +5 -23
  48. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +1 -1
  49. package/lib/component/elements/popup/Modal/ConfirmDialog.js +2 -1
  50. package/lib/component/elements/popup/Modal/Provider.js +3 -1
  51. package/lib/component/elements/popup/options.d.ts +22 -19
  52. package/lib/component/elements/resizer/Resizer.d.ts +2 -2
  53. package/lib/component/elements/toggle/ToggleButton.d.ts +2 -2
  54. package/lib/component/elements/toggle/ToggleButton.js +1 -1
  55. package/lib/component/header/Header.js +2 -2
  56. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -8
  57. package/lib/component/highlight/index.d.ts +1 -1
  58. package/lib/component/hooks/useCheckToolsVisibility.js +2 -2
  59. package/lib/component/hooks/useExport.js +2 -1
  60. package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
  61. package/lib/component/hooks/usePanelPreferences.js +2 -2
  62. package/lib/component/hooks/useXScale.d.ts +1 -1
  63. package/lib/component/hooks/useXYReduce.d.ts +2 -2
  64. package/lib/component/modal/AboutSpectrumSimulationModal.d.ts +2 -0
  65. package/lib/component/modal/AboutSpectrumSimulationModal.js +49 -0
  66. package/lib/component/modal/AboutUsModal.js +4 -2
  67. package/lib/component/modal/AlignSpectraModal.js +11 -1
  68. package/lib/component/modal/LogsHistoryModal.d.ts +6 -0
  69. package/lib/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +6 -4
  70. package/lib/component/modal/MultipletAnalysisModal.js +2 -1
  71. package/lib/component/modal/PredictSpectraModal.d.ts +1 -2
  72. package/lib/component/modal/PredictSpectraModal.js +25 -28
  73. package/lib/component/modal/changeSum/ChangeSumModal.js +1 -1
  74. package/lib/component/modal/editRange/forms/components/SignalsForm.js +1 -1
  75. package/lib/component/modal/editZone/SignalsForm.js +1 -1
  76. package/lib/component/modal/metaImportation/MetaImportationModal.js +1 -1
  77. package/lib/component/modal/setting/GeneralSettings.js +28 -27
  78. package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
  79. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  80. package/lib/component/modal/setting/settingsValidation.js +2 -2
  81. package/lib/component/panels/IntegralsPanel/IntegralPanel.d.ts +1 -1
  82. package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +1 -1
  83. package/lib/component/panels/IntegralsPanel/IntegralTable.js +4 -7
  84. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.d.ts +1 -1
  85. package/lib/component/panels/MoleculesPanel/MoleculePanelHeader.js +19 -19
  86. package/lib/component/panels/MoleculesPanel/Utilities.d.ts +1 -1
  87. package/lib/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
  88. package/lib/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
  89. package/lib/component/panels/Panels.js +13 -0
  90. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  91. package/lib/component/panels/RangesPanel/RangesHeader.js +9 -15
  92. package/lib/component/panels/RangesPanel/RangesPanel.js +7 -10
  93. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
  94. package/lib/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
  95. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
  96. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -1
  97. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  98. package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +1 -1
  99. package/lib/component/panels/databasePanel/DatabasePanel.d.ts +1 -1
  100. package/lib/component/panels/databasePanel/DatabasePanel.js +1 -1
  101. package/lib/component/panels/databasePanel/DatabaseTable.js +1 -1
  102. package/lib/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
  103. package/lib/component/panels/extra/utilities/UseToggleStatus.js +1 -1
  104. package/lib/component/panels/filtersPanel/FiltersTable.js +2 -2
  105. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
  106. package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -2
  107. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +2 -2
  108. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.d.ts +1 -0
  109. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +88 -0
  110. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +11 -0
  111. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +37 -0
  112. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.d.ts +4 -0
  113. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +25 -0
  114. package/lib/component/panels/spectrumSimulation/SpinSystemTable.d.ts +5 -0
  115. package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +60 -0
  116. package/lib/component/reducer/Reducer.d.ts +13 -12
  117. package/lib/component/reducer/Reducer.js +251 -239
  118. package/lib/component/reducer/actions/AssignmentsActions.d.ts +1 -1
  119. package/lib/component/reducer/actions/AssignmentsActions.js +1 -1
  120. package/lib/component/reducer/actions/DatabaseActions.js +2 -1
  121. package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
  122. package/lib/component/reducer/actions/DomainActions.js +30 -1
  123. package/lib/component/reducer/actions/FiltersActions.js +4 -4
  124. package/lib/component/reducer/actions/LoadActions.js +1 -1
  125. package/lib/component/reducer/actions/MoleculeActions.d.ts +2 -0
  126. package/lib/component/reducer/actions/MoleculeActions.js +51 -2
  127. package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -2
  128. package/lib/component/reducer/actions/SpectrumsActions.js +43 -4
  129. package/lib/component/reducer/actions/ToolsActions.js +2 -2
  130. package/lib/component/reducer/actions/ZonesActions.js +1 -1
  131. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +4 -6
  132. package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
  133. package/lib/component/reducer/preferences/actions/setPreferences.js +3 -4
  134. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  135. package/lib/component/reducer/preferences/preferencesReducer.js +5 -1
  136. package/lib/component/reducer/preferences/utilities/flatObject.js +1 -1
  137. package/lib/component/toolbar/ToolTypes.d.ts +4 -4
  138. package/lib/component/utility/export.d.ts +5 -4
  139. package/lib/component/utility/export.js +33 -61
  140. package/lib/component/utility/getSpectraObjectPaths.js +1 -1
  141. package/lib/component/utility/getUniqueNuclei.js +1 -1
  142. package/lib/component/utility/jpathToArray.js +1 -1
  143. package/lib/component/workspaces/index.d.ts +1 -0
  144. package/lib/component/workspaces/index.js +2 -0
  145. package/lib/component/workspaces/simulation.d.ts +2 -0
  146. package/lib/component/workspaces/simulation.js +68 -0
  147. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  148. package/lib/data/PredictionManager.d.ts +8 -7
  149. package/lib/data/PredictionManager.js +95 -22
  150. package/lib/data/SpectraManager.js +1 -1
  151. package/lib/data/constants/DefaultPathLengths.d.ts +1 -3
  152. package/lib/data/constants/SignalsKinds.d.ts +2 -2
  153. package/lib/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
  154. package/lib/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
  155. package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.d.ts +1 -1
  156. package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
  157. package/lib/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
  158. package/lib/data/data1d/database.d.ts +5 -5
  159. package/lib/data/data1d/database.js +3 -3
  160. package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -1
  161. package/lib/data/data1d/multipleSpectraAnalysis.js +1 -1
  162. package/lib/data/data1d/spectrumSimulation.d.ts +14 -0
  163. package/lib/data/data1d/spectrumSimulation.js +53 -0
  164. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -4
  165. package/lib/data/data2d/Spectrum2D/contours.js +7 -1
  166. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
  167. package/lib/data/data2d/Spectrum2D/getShift.js +1 -1
  168. package/lib/data/data2d/Spectrum2D/getSlice.js +4 -4
  169. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
  170. package/lib/data/getDefaultMatrixFilters.d.ts +2 -2
  171. package/lib/data/matrixGeneration.js +1 -1
  172. package/lib/data/molecules/MoleculeManager.d.ts +1 -1
  173. package/lib/data/molecules/MoleculeManager.js +7 -7
  174. package/lib/data/parseMeta/linkMetaWithSpectra.js +2 -1
  175. package/lib/data/types/data1d/MatrixOptions.d.ts +2 -2
  176. package/lib/data/utilities/FindUtilities.js +4 -4
  177. package/lib/data/utilities/RangeUtilities.d.ts +1 -1
  178. package/lib/data/utilities/ZoneUtilities.d.ts +1 -1
  179. package/lib/data/utilities/calculateSanPlot.js +3 -3
  180. package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
  181. package/lib/utils/clipboard/clipboard.d.ts +12 -0
  182. package/lib/utils/clipboard/clipboard.js +15 -0
  183. package/lib/utils/clipboard/clipboardComponents.d.ts +45 -0
  184. package/lib/utils/clipboard/clipboardComponents.js +150 -0
  185. package/lib/utils/clipboard/clipboardHooks.d.ts +94 -0
  186. package/lib/utils/clipboard/clipboardHooks.js +142 -0
  187. package/lib/utils/clipboard/types.d.ts +1 -0
  188. package/lib/utils/clipboard/types.js +1 -0
  189. package/lib/versionInfo.js +1 -1
  190. package/lib-cjs/component/1d/FooterBanner.js +5 -4
  191. package/lib-cjs/component/1d/Viewer1D.js +120 -103
  192. package/lib-cjs/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
  193. package/lib-cjs/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
  194. package/lib-cjs/component/1d/multiplicityTree/TreeColors.js +1 -6
  195. package/lib-cjs/component/1d/tool/BaseLineZones.js +6 -3
  196. package/lib-cjs/component/1d/tool/PeakPointer.js +1 -1
  197. package/lib-cjs/component/1d/utilities/scale.js +1 -3
  198. package/lib-cjs/component/1d-2d/tools/BrushXY.js +10 -7
  199. package/lib-cjs/component/1d-2d/tools/CrossLinePointer.js +1 -1
  200. package/lib-cjs/component/2d/FooterBanner.js +3 -2
  201. package/lib-cjs/component/2d/Viewer2D.js +50 -28
  202. package/lib-cjs/component/2d/XAxis.js +1 -1
  203. package/lib-cjs/component/2d/YAxis.js +1 -1
  204. package/lib-cjs/component/2d/zones/Signal.js +1 -2
  205. package/lib-cjs/component/EventsTrackers/BrushTracker.js +21 -6
  206. package/lib-cjs/component/NMRium.js +37 -24
  207. package/lib-cjs/component/assignment/actions/setActiveAssignment.js +1 -1
  208. package/lib-cjs/component/context/LoggerContext.js +10 -5
  209. package/lib-cjs/component/elements/InputRange.js +1 -1
  210. package/lib-cjs/component/elements/dropDownButton/DropDownList.js +3 -1
  211. package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +36 -0
  212. package/lib-cjs/component/elements/popup/Alert/Context.js +6 -2
  213. package/lib-cjs/component/elements/popup/Alert/Provider.js +4 -22
  214. package/lib-cjs/component/elements/popup/Modal/ConfirmDialog.js +2 -1
  215. package/lib-cjs/component/elements/popup/Modal/Provider.js +3 -1
  216. package/lib-cjs/component/header/Header.js +2 -2
  217. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -8
  218. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +2 -2
  219. package/lib-cjs/component/hooks/useExport.js +2 -1
  220. package/lib-cjs/component/hooks/usePanelPreferences.js +1 -1
  221. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +54 -0
  222. package/lib-cjs/component/modal/AboutUsModal.js +4 -2
  223. package/lib-cjs/component/modal/AlignSpectraModal.js +11 -1
  224. package/lib-cjs/component/{header/LogsHistory.js → modal/LogsHistoryModal.js} +8 -6
  225. package/lib-cjs/component/modal/MultipletAnalysisModal.js +2 -1
  226. package/lib-cjs/component/modal/PredictSpectraModal.js +24 -27
  227. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +1 -1
  228. package/lib-cjs/component/modal/editRange/forms/components/SignalsForm.js +1 -1
  229. package/lib-cjs/component/modal/editZone/SignalsForm.js +1 -1
  230. package/lib-cjs/component/modal/metaImportation/MetaImportationModal.js +1 -1
  231. package/lib-cjs/component/modal/setting/GeneralSettings.js +28 -27
  232. package/lib-cjs/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
  233. package/lib-cjs/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  234. package/lib-cjs/component/modal/setting/settingsValidation.js +2 -2
  235. package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +4 -7
  236. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +18 -18
  237. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
  238. package/lib-cjs/component/panels/MultipleSpectraAnalysisPanel/MultipleSpectraAnalysisPanel.js +9 -13
  239. package/lib-cjs/component/panels/Panels.js +13 -0
  240. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  241. package/lib-cjs/component/panels/RangesPanel/RangesHeader.js +9 -15
  242. package/lib-cjs/component/panels/RangesPanel/RangesPanel.js +7 -10
  243. package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +8 -11
  244. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
  245. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
  246. package/lib-cjs/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  247. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +1 -1
  248. package/lib-cjs/component/panels/databasePanel/DatabaseTable.js +1 -1
  249. package/lib-cjs/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
  250. package/lib-cjs/component/panels/extra/utilities/UseToggleStatus.js +1 -1
  251. package/lib-cjs/component/panels/filtersPanel/FiltersTable.js +2 -2
  252. package/lib-cjs/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
  253. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -2
  254. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -1
  255. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +94 -0
  256. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +42 -0
  257. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +31 -0
  258. package/lib-cjs/component/panels/spectrumSimulation/SpinSystemTable.js +67 -0
  259. package/lib-cjs/component/reducer/Reducer.js +251 -239
  260. package/lib-cjs/component/reducer/actions/AssignmentsActions.js +1 -1
  261. package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -1
  262. package/lib-cjs/component/reducer/actions/DomainActions.js +31 -1
  263. package/lib-cjs/component/reducer/actions/FiltersActions.js +4 -4
  264. package/lib-cjs/component/reducer/actions/LoadActions.js +1 -1
  265. package/lib-cjs/component/reducer/actions/MoleculeActions.js +54 -2
  266. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +43 -3
  267. package/lib-cjs/component/reducer/actions/ToolsActions.js +2 -2
  268. package/lib-cjs/component/reducer/actions/ZonesActions.js +1 -1
  269. package/lib-cjs/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
  270. package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +3 -4
  271. package/lib-cjs/component/reducer/preferences/preferencesReducer.js +5 -1
  272. package/lib-cjs/component/reducer/preferences/utilities/flatObject.js +1 -1
  273. package/lib-cjs/component/utility/export.js +33 -63
  274. package/lib-cjs/component/utility/getSpectraObjectPaths.js +1 -1
  275. package/lib-cjs/component/utility/getUniqueNuclei.js +1 -1
  276. package/lib-cjs/component/utility/jpathToArray.js +1 -1
  277. package/lib-cjs/component/workspaces/index.js +2 -0
  278. package/lib-cjs/component/workspaces/simulation.js +71 -0
  279. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +1 -0
  280. package/lib-cjs/data/PredictionManager.js +96 -22
  281. package/lib-cjs/data/SpectraManager.js +1 -1
  282. package/lib-cjs/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
  283. package/lib-cjs/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
  284. package/lib-cjs/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
  285. package/lib-cjs/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
  286. package/lib-cjs/data/data1d/database.js +3 -3
  287. package/lib-cjs/data/data1d/multipleSpectraAnalysis.js +1 -1
  288. package/lib-cjs/data/data1d/spectrumSimulation.js +58 -0
  289. package/lib-cjs/data/data2d/Spectrum2D/contours.js +7 -1
  290. package/lib-cjs/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
  291. package/lib-cjs/data/data2d/Spectrum2D/getShift.js +1 -1
  292. package/lib-cjs/data/data2d/Spectrum2D/getSlice.js +4 -4
  293. package/lib-cjs/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
  294. package/lib-cjs/data/matrixGeneration.js +1 -1
  295. package/lib-cjs/data/molecules/MoleculeManager.js +7 -7
  296. package/lib-cjs/data/parseMeta/linkMetaWithSpectra.js +2 -1
  297. package/lib-cjs/data/utilities/FindUtilities.js +4 -4
  298. package/lib-cjs/data/utilities/calculateSanPlot.js +3 -3
  299. package/lib-cjs/data/utilities/generateNumbersPowerOfX.js +1 -1
  300. package/lib-cjs/utils/clipboard/clipboard.js +23 -0
  301. package/lib-cjs/utils/clipboard/clipboardComponents.js +158 -0
  302. package/lib-cjs/utils/clipboard/clipboardHooks.js +147 -0
  303. package/lib-cjs/utils/clipboard/types.js +2 -0
  304. package/lib-cjs/versionInfo.js +1 -1
  305. package/package.json +26 -25
  306. package/lib/component/header/LogsHistory.d.ts +0 -1
@@ -1,14 +1,14 @@
1
1
  declare function getTopXScale(width: number, margin: {
2
2
  right: number;
3
3
  left: number;
4
- }, x: Array<number>): {
4
+ }, x: number[]): {
5
5
  xDomain: [number, number] | [undefined, undefined];
6
6
  scaleX: import("d3-scale").ScaleLinear<number, number, never>;
7
7
  };
8
8
  declare function getLeftXScale(width: number, margin: {
9
9
  bottom: number;
10
10
  top: number;
11
- }, x: Array<number>): {
11
+ }, x: number[]): {
12
12
  xDomain: [number, number] | [undefined, undefined];
13
13
  scaleX: import("d3-scale").ScaleLinear<number, number, never>;
14
14
  };
@@ -5,7 +5,7 @@ declare function get2DXScale(props: {
5
5
  right: number;
6
6
  left: number;
7
7
  };
8
- xDomain: Array<number>;
8
+ xDomain: number[];
9
9
  }, reverse?: boolean): import("d3-scale").ScaleLinear<number, number, never>;
10
10
  declare function get2DYScale(props: {
11
11
  height: number;
@@ -13,7 +13,7 @@ declare function get2DYScale(props: {
13
13
  bottom: number;
14
14
  top: number;
15
15
  };
16
- yDomain: Array<number>;
16
+ yDomain: number[];
17
17
  }, reverse?: boolean): import("d3-scale").ScaleLinear<number, number, never>;
18
18
  interface TopLayout {
19
19
  width: number;
@@ -21,7 +21,7 @@ interface TopLayout {
21
21
  right: number;
22
22
  left: number;
23
23
  };
24
- xDomain: Array<number>;
24
+ xDomain: number[];
25
25
  }
26
26
  interface LeftLayout {
27
27
  height: number;
@@ -29,8 +29,8 @@ interface LeftLayout {
29
29
  bottom: number;
30
30
  top: number;
31
31
  };
32
- yDomain: Array<number>;
32
+ yDomain: number[];
33
33
  }
34
34
  declare function get1DXScale(props: TopLayout | LeftLayout, layout: Layout): import("d3-scale").ScaleLinear<number, number, never> | undefined;
35
- declare function get1DYScale(yDomain: Array<number>, height: number, margin?: number): import("d3-scale").ScaleLinear<number, number, never>;
35
+ declare function get1DYScale(yDomain: number[], height: number, margin?: number): import("d3-scale").ScaleLinear<number, number, never>;
36
36
  export { get2DXScale, get2DYScale, get1DXScale, get1DYScale };
@@ -40,7 +40,6 @@ function Signal({ signal, isVisible }) {
40
40
  assignment.hide();
41
41
  highlight.hide();
42
42
  }, cx: scaleX(signal.x.delta || 0), cy: scaleY(signal.y.delta || 0), r: isHighlighted ? 6 : 4, fill: isHighlighted ? 'green' : 'darkgreen' }, signal.id)] })), _jsx("g", { className: "zone-signal-peak", style: { pointerEvents: 'none' }, children: isVisible.peaks &&
43
- signal?.peaks &&
44
- signal.peaks.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, `${signal.id + i}`))) })] }));
43
+ signal?.peaks?.map((peak, i) => (_jsx("circle", { cx: scaleX(peak.x), cy: scaleY(peak.y), r: 2, fill: "black" }, `${signal.id + i}`))) })] }));
45
44
  }
46
45
  export default memo(Signal);
@@ -8,7 +8,9 @@ interface BrushTrackerContext {
8
8
  endY: number;
9
9
  shiftKey: boolean;
10
10
  altKey: boolean;
11
+ mouseButton: MouseButton;
11
12
  }
13
+ type MouseButton = 'main' | 'secondary' | 'unknown';
12
14
  export declare const BrushContext: import("react").Context<BrushTrackerContext>;
13
15
  export declare function useBrushTracker(): BrushTrackerContext;
14
16
  interface Position {
@@ -23,10 +25,11 @@ interface BrushTrackerProps {
23
25
  children: ReactNode;
24
26
  className?: string;
25
27
  style?: CSSProperties;
28
+ onBrushEnd?: OnBrush;
26
29
  onBrush?: OnBrush;
27
30
  onZoom?: OnZoom;
28
31
  onDoubleClick?: OnClick;
29
32
  onClick?: OnClick;
30
33
  noPropagation?: boolean;
31
34
  }
32
- export declare function BrushTracker({ children, className, style, onBrush, onZoom, onDoubleClick, onClick, noPropagation, }: BrushTrackerProps): import("react/jsx-runtime").JSX.Element;
35
+ export declare function BrushTracker({ children, className, style, onBrushEnd, onBrush, onZoom, onDoubleClick, onClick, noPropagation, }: BrushTrackerProps): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import lodashDebounce from 'lodash/debounce';
3
3
  import lodashMap from 'lodash/map';
4
4
  import { createContext, useCallback, useEffect, useReducer, useRef, useState, useContext, } from 'react';
5
+ const MouseButtons = {
6
+ 0: 'main',
7
+ 2: 'secondary',
8
+ };
5
9
  const initialState = {
6
10
  step: 'initial',
11
+ mouseButton: 'unknown',
7
12
  shiftKey: false,
8
13
  altKey: false,
9
14
  startX: 0,
@@ -26,18 +31,21 @@ export function useBrushTracker() {
26
31
  }
27
32
  return useContext(BrushContext);
28
33
  }
29
- export function BrushTracker({ children, className, style, onBrush = () => null, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
34
+ export function BrushTracker({ children, className, style, onBrushEnd, onBrush, onZoom = () => null, onDoubleClick = () => null, onClick = () => null, noPropagation, }) {
30
35
  const [state, dispatch] = useReducer(reducer, initialState);
31
36
  const [mouseDownTime, setMouseDownTime] = useState(0);
32
37
  const debounceClickEventsRef = useRef([]);
38
+ const lastPointRef = useRef(0);
33
39
  const mouseDownHandler = useCallback((event) => {
34
- if (event.button === 0) {
40
+ //check that the right or left mouse button pressed
41
+ if ([0, 2].includes(event.button)) {
35
42
  if (noPropagation) {
36
43
  event.stopPropagation();
37
44
  }
38
45
  dispatch({
39
46
  type: 'DOWN',
40
47
  payload: {
48
+ mouseButton: MouseButtons[event.button],
41
49
  shiftKey: event.shiftKey,
42
50
  altKey: event.altKey,
43
51
  screenX: event.screenX,
@@ -100,13 +108,19 @@ export function BrushTracker({ children, className, style, onBrush = () => null,
100
108
  }, [onZoom]);
101
109
  useEffect(() => {
102
110
  const { step, startX, endX, startY, endY } = state;
103
- if (step === 'end' && Math.hypot(endX - startX, endY - startY) > 5) {
104
- onBrush(state);
111
+ const point = Math.hypot(endX - startX, endY - startY);
112
+ if ((step === 'end' || step === 'brushing') &&
113
+ lastPointRef.current !== point) {
114
+ onBrush?.(state);
115
+ lastPointRef.current = point;
116
+ }
117
+ if (step === 'end' && point > 5) {
118
+ onBrushEnd?.(state);
105
119
  dispatch({
106
120
  type: 'DONE',
107
121
  });
108
122
  }
109
- }, [onBrush, state]);
123
+ }, [onBrush, onBrushEnd, state]);
110
124
  return (_jsx(BrushContext.Provider, { value: state, children: _jsx("div", { className: className, style: style, onMouseDown: mouseDownHandler, onClick: clickHandler, onWheel: handleMouseWheel, onMouseEnter: () => {
111
125
  // disable page scrolling once the mouse over the Displayer
112
126
  window.addEventListener('wheel', stopPageScrolling, {
@@ -129,13 +143,14 @@ function reducer(state, action) {
129
143
  return state;
130
144
  case 'DOWN':
131
145
  if (state.step === 'initial' || state.step === 'end') {
132
- const { shiftKey, altKey, screenX, screenY, clientX, clientY, boundingRect, } = action.payload;
146
+ const { shiftKey, altKey, mouseButton, screenX, screenY, clientX, clientY, boundingRect, } = action.payload;
133
147
  const x = clientX - boundingRect.x;
134
148
  const y = clientY - boundingRect.y;
135
149
  return {
136
150
  ...state,
137
151
  shiftKey,
138
152
  altKey,
153
+ mouseButton,
139
154
  startX: x,
140
155
  startY: y,
141
156
  startScreenX: screenX,
@@ -7,7 +7,7 @@ import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
7
7
  import { BlobObject } from './utility/export';
8
8
  export { serializeNmriumState } from 'nmr-load-save';
9
9
  export type { NmriumState, WorkspacePreferences as NMRiumPreferences, } from 'nmr-load-save';
10
- export type NMRiumWorkspace = 'exercise' | 'process1D' | 'default' | 'prediction' | 'embedded' | 'assignment' | (string & {});
10
+ export type NMRiumWorkspace = 'exercise' | 'process1D' | 'default' | 'prediction' | 'embedded' | 'assignment' | 'simulation' | (string & {});
11
11
  export type OnNMRiumChange = (state: NmriumState, source: 'data' | 'view' | 'settings') => void;
12
12
  export interface NMRiumProps {
13
13
  data?: NMRiumData;
@@ -32,7 +32,7 @@ type DeepPartial<T> = {
32
32
  export interface NMRiumData {
33
33
  source?: WebSource;
34
34
  molecules?: Molecules;
35
- spectra: DeepPartial<Spectrum>[];
35
+ spectra: Array<DeepPartial<Spectrum>>;
36
36
  correlations?: CorrelationData;
37
37
  }
38
38
  export interface NMRiumRef {
@@ -15,12 +15,12 @@ import ErrorOverlay from './ErrorOverlay';
15
15
  import KeysListenerTracker from './EventsTrackers/KeysListenerTracker';
16
16
  import { SplitPaneWrapper } from './SplitPaneWrapper';
17
17
  import { AssignmentProvider } from './assignment';
18
- import { ChartDataProvider } from './context/ChartContext';
18
+ import { ChartDataProvider, useChartData } from './context/ChartContext';
19
19
  import { DispatchProvider } from './context/DispatchContext';
20
20
  import { GlobalProvider } from './context/GlobalContext';
21
21
  import { LoggerProvider } from './context/LoggerContext';
22
22
  import { PreferencesProvider } from './context/PreferencesContext';
23
- import { AlertProvider } from './elements/popup/Alert';
23
+ import { AlertProvider, useAlert } from './elements/popup/Alert';
24
24
  import { ModalProvider } from './elements/popup/Modal';
25
25
  import Header from './header/Header';
26
26
  import { HighlightProvider } from './highlight';
@@ -37,7 +37,7 @@ const viewerContainerStyle = css `
37
37
  border: 0.55px #e6e6e6 solid;
38
38
  display: flex;
39
39
  flex: 1;
40
- flex-direction: 'column';
40
+ flex-direction: column;
41
41
  height: 100%;
42
42
  margin-left: -1px;
43
43
  `;
@@ -197,28 +197,41 @@ function InnerNMRium({ data: dataProp = defaultData, workspace, customWorkspaces
197
197
  rootRef: rootRef.current,
198
198
  elementsWrapperRef: elementsWrapperRef.current,
199
199
  viewerRef: viewerRef.current,
200
- }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(LoggerProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children: _jsx(SpinnerProvider, { value: getSpinner, children: _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
201
- display: 'flex',
202
- flexDirection: 'column',
203
- backgroundColor: 'white',
204
- width: '100%',
205
- }, children: [_jsx(Header, { isFullscreen: isFullscreen, onMaximize: toggle }), _jsxs("div", { style: {
206
- display: 'flex',
207
- flexDirection: 'row',
208
- height: '100%',
209
- }, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, {}), _jsxs("div", { id: "nmrium-viewer", "data-test-id": "viewer", ref: viewerRef, style: {
210
- width: '100%',
211
- height: '100%',
212
- position: 'relative',
213
- }, children: [_jsx(FloatMoleculeStructures, {}), displayerMode ===
214
- DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
215
- position: 'absolute',
216
- pointerEvents: 'none',
217
- zIndex: 2,
218
- left: 0,
219
- right: 0,
220
- top: 0,
221
- bottom: 0,
222
- } }, String(isFullscreen))] })] }) }) }) }) }) }) }) }) }) }) }) }) }) }));
200
+ }, children: _jsx(PreferencesProvider, { value: preferencesState, children: _jsx("div", { ref: mainDivRef, style: { height: '100%', position: 'relative' }, children: _jsx(LoggerProvider, { children: _jsx(AlertProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(DispatchProvider, { value: dispatch, children: _jsx(ChartDataProvider, { value: state, children: _jsx(ModalProvider, { wrapperRef: elementsWrapperRef.current, children: _jsx(HighlightProvider, { children: _jsx(AssignmentProvider, { spectraData: spectraData, children: _jsxs(SpinnerProvider, { value: getSpinner, children: [_jsx(StateError, {}), _jsx("div", { className: "nmrium-container", ref: rootRef, css: containerStyles, onContextMenu: preventContextMenuHandler, style: { height: '100%', width: '100%' }, children: _jsx(DropZone, { children: _jsxs("div", { style: {
201
+ display: 'flex',
202
+ flexDirection: 'column',
203
+ backgroundColor: 'white',
204
+ width: '100%',
205
+ }, children: [_jsx(Header, { isFullscreen: isFullscreen, onMaximize: toggle }), _jsxs("div", { style: {
206
+ display: 'flex',
207
+ flexDirection: 'row',
208
+ height: '100%',
209
+ }, children: [_jsx(ToolBar, {}), _jsxs(SplitPaneWrapper, { children: [_jsxs("div", { css: viewerContainerStyle, children: [_jsx(KeysListenerTracker, {}), _jsxs("div", { id: "nmrium-viewer", "data-test-id": "viewer", ref: viewerRef, style: {
210
+ width: '100%',
211
+ height: '100%',
212
+ position: 'relative',
213
+ }, children: [_jsx(FloatMoleculeStructures, {}), displayerMode ===
214
+ DISPLAYER_MODE.DM_1D ? (_jsx(Viewer1D, { emptyText: emptyText })) : (_jsx(Viewer2D, { emptyText: emptyText }))] })] }), _jsx(Panels, {})] }), _jsx("div", { ref: elementsWrapperRef, id: "main-wrapper", style: {
215
+ position: 'absolute',
216
+ pointerEvents: 'none',
217
+ zIndex: 2,
218
+ left: 0,
219
+ right: 0,
220
+ top: 0,
221
+ bottom: 0,
222
+ } }, String(isFullscreen))] })] }) }) })] }) }) }) }) }) }) }) }) }) }) }));
223
223
  }
224
224
  export default memo(NMRium);
225
+ /**
226
+ * Alert user in UI when state have errorAction (error from reducer)
227
+ */
228
+ function StateError() {
229
+ const { errorAction } = useChartData();
230
+ const { error: alertError } = useAlert();
231
+ useEffect(() => {
232
+ if (!errorAction)
233
+ return;
234
+ alertError(errorAction?.message ?? String(errorAction));
235
+ }, [errorAction, alertError]);
236
+ return null;
237
+ }
@@ -2,7 +2,7 @@ import { NmrData1D, NmrData2D } from 'cheminfo-types';
2
2
  import { ActionType } from '../reducer/types/ActionType';
3
3
  import { AssignmentDimension, AssignmentState, Axis } from './AssignmentsContext';
4
4
  export type InitiateAction = ActionType<'INITIATE_ASSIGNMENTS', {
5
- spectra: (NmrData1D | NmrData2D)[];
5
+ spectra: Array<NmrData1D | NmrData2D>;
6
6
  }>;
7
7
  export type ToggleAction = ActionType<'TOGGLE', {
8
8
  atomIDs: string[];
@@ -1,5 +1,5 @@
1
1
  export default function setActiveAssignment(state, action) {
2
- let { id, axis } = action.payload;
2
+ const { id, axis } = action.payload;
3
3
  const isActive = state.activated?.id === id;
4
4
  return {
5
5
  ...state,
@@ -1,6 +1,7 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { FifoLogger } from 'fifo-logger';
3
3
  import { createContext, useContext, useRef, useMemo, useState, useCallback, useEffect, } from 'react';
4
+ import { LogsHistoryModal } from '../modal/LogsHistoryModal';
4
5
  import { usePreferences } from './PreferencesContext';
5
6
  export const LoggerContext = createContext(null);
6
7
  export function useLogger() {
@@ -14,12 +15,16 @@ export function LoggerProvider({ children }) {
14
15
  const { current: { general: { loggingLevel }, }, } = usePreferences();
15
16
  const [lastReadLogId, setLastLogId] = useState(0);
16
17
  const [logsHistory, setLogsHistory] = useState([]);
18
+ const [isLogHistoryOpened, openLogHistory] = useState(false);
17
19
  const loggerRef = useRef(new FifoLogger({
18
20
  onChange: (log, logs) => {
19
- if (log?.error &&
20
- (log?.levelLabel === 'error' || log?.levelLabel === 'fatal')) {
21
- // eslint-disable-next-line no-console
22
- console.error(log.error);
21
+ if (log && ['warn', 'error', 'fatal'].includes(log.levelLabel)) {
22
+ //open the log history automatically if we have warn,error, or fatal
23
+ openLogHistory(true);
24
+ if (log?.error) {
25
+ // eslint-disable-next-line no-console
26
+ console.error(log.error);
27
+ }
23
28
  }
24
29
  setLogsHistory(logs.slice());
25
30
  },
@@ -43,5 +48,5 @@ export function LoggerProvider({ children }) {
43
48
  lastReadLogId,
44
49
  };
45
50
  }, [lastReadLogId, logsHistory, markAsRead]);
46
- return (_jsx(LoggerContext.Provider, { value: loggerState, children: children }));
51
+ return (_jsxs(LoggerContext.Provider, { value: loggerState, children: [isLogHistoryOpened && (_jsx(LogsHistoryModal, { autoOpen: true, onClose: () => openLogHistory(false) })), children] }));
47
52
  }
@@ -36,7 +36,7 @@ function InputRange(props, ref) {
36
36
  }));
37
37
  const mouseDownCallback = useCallback((event) => {
38
38
  function mouseMoveCallback(event) {
39
- let diff = event.clientX - previousPosition.current;
39
+ const diff = event.clientX - previousPosition.current;
40
40
  previousPosition.current = event.clientX;
41
41
  if (event.buttons === 1) {
42
42
  const step = diff / (event.shiftKey ? 10 : 1);
@@ -3,7 +3,7 @@ interface MenuButtonProps {
3
3
  component: any;
4
4
  toolTip: string;
5
5
  className?: string;
6
- items: Array<any>;
6
+ items: any[];
7
7
  onClick: (element: any) => void;
8
8
  }
9
9
  export default function MenuButton({ style, component, toolTip, className, items, onClick, }: MenuButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { StateMoleculeExtended } from '../../data/molecules/Molecule';
2
2
  interface MoleculeSelectionProps {
3
- molecules: Array<StateMoleculeExtended>;
3
+ molecules: StateMoleculeExtended[];
4
4
  onChange: (element: number) => void;
5
5
  index?: number;
6
6
  }
@@ -8,7 +8,7 @@ import { ClickEvent } from './Elements/ReactTableRow';
8
8
  interface ExtraColumn<T extends object> {
9
9
  enableRowSpan?: boolean;
10
10
  style?: CSSProperties;
11
- Cell?: (cell: CellProps<T, any>) => JSX.Element | string;
11
+ Cell?: (cell: CellProps<T>) => JSX.Element | string;
12
12
  }
13
13
  export type Column<T extends object> = ReactColumn<T> & ExtraColumn<T> & UseSortByColumnOptions<T>;
14
14
  interface SortEvent {
@@ -1,6 +1,6 @@
1
1
  import { CSSProperties } from 'react';
2
2
  interface DeleteButtonProps {
3
- onDelete: (element: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
3
+ onDelete: (element: React.MouseEvent<HTMLButtonElement>) => void;
4
4
  className?: string;
5
5
  style?: CSSProperties;
6
6
  }
@@ -1,7 +1,7 @@
1
1
  interface MenuButtonProps {
2
2
  component: any;
3
3
  toolTip: string;
4
- items: Array<any>;
4
+ items: any[];
5
5
  onClick: (element: any) => void;
6
6
  }
7
7
  export default function ToolbarMenu({ component, toolTip, items, onClick, }: MenuButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
2
  interface AccordionProps {
3
- children: Array<ReactNode>;
3
+ children: ReactNode[];
4
4
  defaultOpenIndex: number | null;
5
5
  }
6
6
  declare function Accordion({ children, defaultOpenIndex }: AccordionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,6 @@
1
1
  import { ReactFragment } from 'react';
2
2
  import { Position } from './useDraggable';
3
- type ChildType = Array<React.ReactElement> | React.ReactElement | ReactFragment | boolean | null;
3
+ type ChildType = React.ReactElement[] | React.ReactElement | ReactFragment | boolean | null;
4
4
  type PositionChangeHandler = (data: Position) => void;
5
5
  export interface DraggableProps {
6
6
  children?: ChildType | ((x1: number, x2: number) => ChildType);
@@ -10,7 +10,7 @@ interface UseDraggable {
10
10
  dragHandleClassName?: string;
11
11
  }
12
12
  export interface Draggable {
13
- onMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGElement, MouseEvent>) => void;
13
+ onMouseDown: (event: React.MouseEvent<HTMLDivElement | SVGElement>) => void;
14
14
  position: {
15
15
  value: Position;
16
16
  action: Action;
@@ -11,7 +11,7 @@ export interface ItemProps {
11
11
  visibleKey?: string;
12
12
  }
13
13
  export interface DropDownListProps<T> {
14
- data: Array<T>;
14
+ data: T[];
15
15
  renderItem?: ((item: DropDownListItem) => ReactNode) | null;
16
16
  }
17
17
  interface DropDownButtonProps<T> extends DropDownListProps<T>, ItemProps {
@@ -8,7 +8,9 @@ const styles = {
8
8
  position: absolute;
9
9
  height: auto;
10
10
  z-index: 99999999999999;
11
- box-shadow: 0 19px 38px rgb(0 0 0 / 30%), 0 15px 12px rgb(0 0 0 / 22%);
11
+ box-shadow:
12
+ 0 19px 38px rgb(0 0 0 / 30%),
13
+ 0 15px 12px rgb(0 0 0 / 22%);
12
14
  border-radius: 10px;
13
15
  margin-bottom: 20px;
14
16
  overflow: hidden;
@@ -1,6 +1,6 @@
1
1
  import { ErrorMessageProps } from './ErrorMessage';
2
2
  interface SelectBoxProps extends ErrorMessageProps {
3
- values: Array<any>;
3
+ values: any[];
4
4
  }
5
5
  declare function SelectBox({ values, ...props }: SelectBoxProps): import("@emotion/react/jsx-runtime").JSX.Element | null;
6
6
  export default SelectBox;
@@ -0,0 +1,8 @@
1
+ import { Alert } from './Context';
2
+ interface AlertBlockProps {
3
+ offset: string;
4
+ alert: Alert;
5
+ onClose: () => void;
6
+ }
7
+ export default function AlertBlock(props: AlertBlockProps): import("@emotion/react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
4
+ import { FaTimes } from 'react-icons/fa';
5
+ import { types } from '../options';
6
+ import ProgressIndicator from './ProgressIndicator';
7
+ const style = css `
8
+ padding: 25px;
9
+ border-radius: 10px;
10
+ pointer-events: all;
11
+ min-height: 60px;
12
+ position: relative;
13
+
14
+ > button {
15
+ position: absolute;
16
+ right: 5px;
17
+ top: 5px;
18
+ border: none;
19
+ background-color: transparent;
20
+ color: white;
21
+ }
22
+ `;
23
+ export default function AlertBlock(props) {
24
+ const { offset, alert, onClose } = props;
25
+ return (_jsxs("div", { css: style, style: {
26
+ margin: offset,
27
+ backgroundColor: alert.options.backgroundColor,
28
+ color: alert.options.color,
29
+ }, children: [_jsx("button", { type: "button", onClick: onClose, children: _jsx(FaTimes, {}) }), _jsx("span", { children: alert.message }), alert.options.type === types.PROGRESS_INDICATOR && _jsx(ProgressIndicator, {})] }, alert.id));
30
+ }
@@ -1,3 +1,27 @@
1
1
  /// <reference types="react" />
2
- export declare const AlertProvider: import("react").Provider<any>;
3
- export declare function useAlert(): any;
2
+ import { Position, Type } from '../options';
3
+ export interface AlertOption {
4
+ position?: Position;
5
+ timeout?: number;
6
+ type?: Type;
7
+ /** CSS string color */
8
+ backgroundColor?: string;
9
+ /** CSS string color */
10
+ color?: string;
11
+ onOpen?: () => void;
12
+ }
13
+ export interface Alert {
14
+ id: string;
15
+ message?: string;
16
+ options: AlertOption;
17
+ close: () => void;
18
+ }
19
+ export interface AlertAPI {
20
+ show: (message?: string, options?: AlertOption) => Alert;
21
+ success: (message?: string, options?: AlertOption) => Alert;
22
+ error: (message?: string, options?: AlertOption) => Alert;
23
+ info: (message?: string, options?: AlertOption) => Alert;
24
+ showLoading: (message?: string, options?: AlertOption) => Promise<() => void>;
25
+ }
26
+ export declare const AlertProvider: import("react").Provider<AlertAPI | null>;
27
+ export declare function useAlert(): AlertAPI;
@@ -1,6 +1,10 @@
1
1
  import { createContext, useContext } from 'react';
2
- const AlertContext = createContext({});
2
+ const AlertContext = createContext(null);
3
3
  export const AlertProvider = AlertContext.Provider;
4
4
  export function useAlert() {
5
- return useContext(AlertContext);
5
+ const context = useContext(AlertContext);
6
+ if (!context) {
7
+ throw new Error('useAlert should be mount into an AlertProvider');
8
+ }
9
+ return context;
6
10
  }
@@ -1,11 +1,12 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
+ import { Position, Type, Transition as TransitionOption } from '../options';
2
3
  interface ProviderProps {
3
4
  children: ReactNode;
4
5
  offset?: string;
5
- position?: any;
6
+ position?: Position;
6
7
  timeout?: number;
7
- type?: any;
8
- transition?: any;
8
+ type?: Type;
9
+ transition?: TransitionOption;
9
10
  containerStyle?: CSSProperties;
10
11
  wrapperRef?: any;
11
12
  context?: {
@@ -2,13 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import groupBy from 'lodash/groupBy';
3
3
  import { Fragment, useState, useRef, useEffect, useCallback, useMemo, memo, } from 'react';
4
4
  import { createPortal } from 'react-dom';
5
- import { FaTimes } from 'react-icons/fa';
6
5
  import { TransitionGroup } from 'react-transition-group';
7
6
  import Transition from '../Transition';
8
7
  import Wrapper from '../Wrapper';
9
- import { positions, transitions, types } from '../options';
8
+ import { positions, transitions, types, } from '../options';
9
+ import AlertBlock from './AlertBlock';
10
10
  import { AlertProvider } from './Context';
11
- import ProgressIndicator from './ProgressIndicator';
12
11
  function Provider({ children, wrapperRef = null, offset = '5px', position = positions.BOTTOM_CENTER, timeout = 3000, type, transition = transitions.FADE, ...props }) {
13
12
  const root = useRef(null);
14
13
  const timersId = useRef([]);
@@ -53,10 +52,10 @@ function Provider({ children, wrapperRef = null, offset = '5px', position = posi
53
52
  id,
54
53
  message,
55
54
  options: alertOptions,
55
+ close: () => remove(alert),
56
56
  };
57
- alert.close = () => remove(alert);
58
57
  if (alert.options.timeout) {
59
- const timerId = setTimeout(() => {
58
+ const timerId = window.setTimeout(() => {
60
59
  remove(alert);
61
60
  timersId.current.splice(timersId.current.indexOf(timerId), 1);
62
61
  }, alert.options.timeout);
@@ -121,24 +120,7 @@ function Provider({ children, wrapperRef = null, offset = '5px', position = posi
121
120
  createPortal(_jsx(Fragment, { children: Object.keys(positions).map((key) => {
122
121
  const position = positions[key];
123
122
  return (_jsx(TransitionGroup, { appear: true, options: { position, zIndex: 999999 }, component: Wrapper, containerStyle: parentStyle, ...props, children: alertsByPosition[position]
124
- ? alertsByPosition[position].map((alert) => (_jsx(Transition, { type: transition, children: _jsxs("div", { style: {
125
- margin: offset,
126
- padding: '25px',
127
- borderRadius: '10px',
128
- pointerEvents: 'all',
129
- backgroundColor: alert.options.backgroundColor,
130
- color: alert.options.color,
131
- minHeight: '60px',
132
- position: 'relative',
133
- }, children: [_jsx("button", { style: {
134
- position: 'absolute',
135
- right: '5px',
136
- top: '5px',
137
- border: 'none',
138
- backgroundColor: 'transparent',
139
- color: 'white',
140
- }, type: "button", onClick: () => closeHandler(alert), children: _jsx(FaTimes, {}) }), _jsx("span", { children: alert.message }), alert.options.type ===
141
- types.PROGRESS_INDICATOR && _jsx(ProgressIndicator, {})] }, alert.id) }, alert.id)))
123
+ ? alertsByPosition[position].map((alert) => (_jsx(Transition, { type: transition, children: _jsx(AlertBlock, { offset: offset, alert: alert, onClose: () => closeHandler(alert) }) }, alert.id)))
142
124
  : null }, position));
143
125
  }) }), root.current)] }));
144
126
  }
@@ -7,7 +7,7 @@ interface AlertButtonOptions {
7
7
  }
8
8
  interface ConfirmationDialogProps {
9
9
  style?: CSSProperties;
10
- buttons: Array<AlertButtonOptions>;
10
+ buttons: AlertButtonOptions[];
11
11
  onClose: () => void;
12
12
  message: ReactNode;
13
13
  render?: (data: {
@@ -6,7 +6,8 @@ const styles = css `
6
6
  display: block;
7
7
  border-radius: 5px;
8
8
  overflow: hidden;
9
- width: 350px;
9
+ width: 30vw;
10
+ min-width: 350px;
10
11
  border-top: 10px solid #ed0000;
11
12
 
12
13
  .message {