nmrium 0.40.1 → 0.42.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 (293) 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/components/SpectrumInfoBlock.js +4 -1
  15. package/lib/component/1d-2d/tools/BrushXY.js +10 -7
  16. package/lib/component/1d-2d/tools/CrossLinePointer.js +1 -1
  17. package/lib/component/2d/FooterBanner.js +3 -2
  18. package/lib/component/2d/Viewer2D.js +51 -29
  19. package/lib/component/2d/XAxis.js +1 -1
  20. package/lib/component/2d/YAxis.js +1 -1
  21. package/lib/component/2d/utilities/SliceScale.d.ts +2 -2
  22. package/lib/component/2d/utilities/scale.d.ts +5 -5
  23. package/lib/component/2d/zones/Signal.js +1 -2
  24. package/lib/component/EventsTrackers/BrushTracker.d.ts +4 -1
  25. package/lib/component/EventsTrackers/BrushTracker.js +21 -6
  26. package/lib/component/NMRium.d.ts +2 -2
  27. package/lib/component/NMRium.js +39 -26
  28. package/lib/component/assignment/AssignmentsReducer.d.ts +1 -1
  29. package/lib/component/assignment/actions/setActiveAssignment.js +1 -1
  30. package/lib/component/elements/Input.js +1 -0
  31. package/lib/component/elements/InputRange.js +1 -1
  32. package/lib/component/elements/MenuButton.d.ts +1 -1
  33. package/lib/component/elements/MoleculeSelection.d.ts +1 -1
  34. package/lib/component/elements/ReactTable/ReactTable.d.ts +1 -1
  35. package/lib/component/elements/Scroller.d.ts +15 -0
  36. package/lib/component/elements/Scroller.js +31 -0
  37. package/lib/component/elements/Tab/DeleteButton.d.ts +1 -1
  38. package/lib/component/elements/ToolbarMenu.d.ts +1 -1
  39. package/lib/component/elements/accordion/Accordion.d.ts +1 -1
  40. package/lib/component/elements/draggable/SVGDraggable.d.ts +1 -1
  41. package/lib/component/elements/draggable/useDraggable.d.ts +1 -1
  42. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +1 -1
  43. package/lib/component/elements/dropDownButton/DropDownList.js +3 -1
  44. package/lib/component/elements/formik/SelectBox.d.ts +1 -1
  45. package/lib/component/elements/popup/Alert/AlertBlock.d.ts +3 -2
  46. package/lib/component/elements/popup/Alert/AlertBlock.js +21 -15
  47. package/lib/component/elements/popup/Alert/Context.d.ts +26 -2
  48. package/lib/component/elements/popup/Alert/Context.js +6 -2
  49. package/lib/component/elements/popup/Alert/Provider.d.ts +4 -3
  50. package/lib/component/elements/popup/Alert/Provider.js +3 -3
  51. package/lib/component/elements/popup/Modal/ConfirmDialog.d.ts +1 -1
  52. package/lib/component/elements/popup/Modal/Provider.js +3 -1
  53. package/lib/component/elements/popup/options.d.ts +22 -19
  54. package/lib/component/elements/resizer/Resizer.d.ts +2 -2
  55. package/lib/component/elements/toggle/ToggleButton.d.ts +2 -2
  56. package/lib/component/elements/toggle/ToggleButton.js +1 -1
  57. package/lib/component/header/ZeroFillingOptionsPanel.js +3 -8
  58. package/lib/component/highlight/index.d.ts +1 -1
  59. package/lib/component/hooks/useCheckToolsVisibility.js +2 -2
  60. package/lib/component/hooks/useExport.js +2 -1
  61. package/lib/component/hooks/useFormatNumberByNucleus.d.ts +1 -1
  62. package/lib/component/hooks/usePanelPreferences.js +2 -2
  63. package/lib/component/hooks/useSaveSettings.js +9 -11
  64. package/lib/component/hooks/useXScale.d.ts +1 -1
  65. package/lib/component/hooks/useXYReduce.d.ts +2 -2
  66. package/lib/component/modal/AboutPredictionModal.js +1 -1
  67. package/lib/component/modal/AboutSpectrumSimulationModal.d.ts +2 -0
  68. package/lib/component/modal/AboutSpectrumSimulationModal.js +49 -0
  69. package/lib/component/modal/AlignSpectraModal.js +11 -1
  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/settings-tabs/DisplayTabContent.js +4 -0
  78. package/lib/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  79. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  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 +6 -6
  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/Panels.js +13 -0
  89. package/lib/component/panels/PeaksPanel/PeaksTable.js +1 -1
  90. package/lib/component/panels/SpectrumsPanel/SpectraPreferences.js +4 -3
  91. package/lib/component/panels/SpectrumsPanel/SpectraTable.js +1 -1
  92. package/lib/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
  93. package/lib/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
  94. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +2 -1
  95. package/lib/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  96. package/lib/component/panels/ZonesPanel/ZonesTable.d.ts +1 -1
  97. package/lib/component/panels/databasePanel/DatabasePanel.d.ts +1 -1
  98. package/lib/component/panels/databasePanel/DatabasePanel.js +34 -27
  99. package/lib/component/panels/databasePanel/DatabaseTable.js +1 -1
  100. package/lib/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
  101. package/lib/component/panels/extra/utilities/UseToggleStatus.js +1 -1
  102. package/lib/component/panels/filtersPanel/FiltersTable.js +2 -2
  103. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
  104. package/lib/component/panels/predictionPanel/PredictionPanel.js +3 -2
  105. package/lib/component/panels/predictionPanel/PredictionSimpleOptions.js +2 -2
  106. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.d.ts +1 -0
  107. package/lib/component/panels/spectrumSimulation/SpectrumSimulation.js +88 -0
  108. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +11 -0
  109. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +37 -0
  110. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.d.ts +4 -0
  111. package/lib/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +25 -0
  112. package/lib/component/panels/spectrumSimulation/SpinSystemTable.d.ts +5 -0
  113. package/lib/component/panels/spectrumSimulation/SpinSystemTable.js +60 -0
  114. package/lib/component/reducer/Reducer.d.ts +13 -12
  115. package/lib/component/reducer/Reducer.js +253 -239
  116. package/lib/component/reducer/actions/AssignmentsActions.d.ts +1 -1
  117. package/lib/component/reducer/actions/AssignmentsActions.js +1 -1
  118. package/lib/component/reducer/actions/DatabaseActions.js +2 -1
  119. package/lib/component/reducer/actions/DomainActions.d.ts +7 -2
  120. package/lib/component/reducer/actions/DomainActions.js +30 -1
  121. package/lib/component/reducer/actions/FiltersActions.js +4 -4
  122. package/lib/component/reducer/actions/LoadActions.js +1 -1
  123. package/lib/component/reducer/actions/MoleculeActions.d.ts +8 -2
  124. package/lib/component/reducer/actions/MoleculeActions.js +58 -3
  125. package/lib/component/reducer/actions/SpectrumsActions.d.ts +8 -2
  126. package/lib/component/reducer/actions/SpectrumsActions.js +43 -4
  127. package/lib/component/reducer/actions/ToolsActions.js +2 -2
  128. package/lib/component/reducer/actions/ZonesActions.js +1 -1
  129. package/lib/component/reducer/helper/ZoomHistoryManager.d.ts +4 -6
  130. package/lib/component/reducer/preferences/actions/addWorkspace.js +19 -15
  131. package/lib/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
  132. package/lib/component/reducer/preferences/actions/setPreferences.js +3 -4
  133. package/lib/component/reducer/preferences/preferencesReducer.d.ts +1 -1
  134. package/lib/component/reducer/preferences/preferencesReducer.js +5 -1
  135. package/lib/component/reducer/preferences/utilities/flatObject.js +1 -1
  136. package/lib/component/toolbar/ToolTypes.d.ts +4 -4
  137. package/lib/component/utility/PathBuilder.js +11 -0
  138. package/lib/component/utility/export.js +9 -9
  139. package/lib/component/utility/getSpectraObjectPaths.js +1 -1
  140. package/lib/component/utility/getUniqueNuclei.js +1 -1
  141. package/lib/component/utility/jpathToArray.js +1 -1
  142. package/lib/component/workspaces/index.d.ts +1 -0
  143. package/lib/component/workspaces/index.js +2 -0
  144. package/lib/component/workspaces/simulation.d.ts +2 -0
  145. package/lib/component/workspaces/simulation.js +68 -0
  146. package/lib/component/workspaces/workspaceDefaultProperties.js +9 -5
  147. package/lib/data/PredictionManager.d.ts +8 -7
  148. package/lib/data/PredictionManager.js +95 -22
  149. package/lib/data/SpectraManager.js +1 -1
  150. package/lib/data/constants/DefaultPathLengths.d.ts +1 -3
  151. package/lib/data/constants/SignalsKinds.d.ts +2 -2
  152. package/lib/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
  153. package/lib/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
  154. package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.d.ts +1 -1
  155. package/lib/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
  156. package/lib/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
  157. package/lib/data/data1d/database.d.ts +9 -7
  158. package/lib/data/data1d/database.js +13 -6
  159. package/lib/data/data1d/multipleSpectraAnalysis.d.ts +1 -1
  160. package/lib/data/data1d/multipleSpectraAnalysis.js +1 -1
  161. package/lib/data/data1d/spectrumSimulation.d.ts +14 -0
  162. package/lib/data/data1d/spectrumSimulation.js +53 -0
  163. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -4
  164. package/lib/data/data2d/Spectrum2D/contours.js +7 -1
  165. package/lib/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
  166. package/lib/data/data2d/Spectrum2D/getShift.js +1 -1
  167. package/lib/data/data2d/Spectrum2D/getSlice.js +4 -4
  168. package/lib/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
  169. package/lib/data/getDefaultMatrixFilters.d.ts +2 -2
  170. package/lib/data/matrixGeneration.js +1 -1
  171. package/lib/data/molecules/MoleculeManager.d.ts +2 -1
  172. package/lib/data/molecules/MoleculeManager.js +21 -7
  173. package/lib/data/parseMeta/linkMetaWithSpectra.js +2 -1
  174. package/lib/data/types/data1d/MatrixOptions.d.ts +2 -2
  175. package/lib/data/utilities/FindUtilities.js +4 -4
  176. package/lib/data/utilities/RangeUtilities.d.ts +1 -1
  177. package/lib/data/utilities/ZoneUtilities.d.ts +1 -1
  178. package/lib/data/utilities/calculateSanPlot.js +3 -3
  179. package/lib/data/utilities/generateNumbersPowerOfX.js +1 -1
  180. package/lib/utils/clipboard/clipboard.d.ts +1 -1
  181. package/lib/versionInfo.js +1 -1
  182. package/lib-cjs/component/1d/FooterBanner.js +5 -4
  183. package/lib-cjs/component/1d/Viewer1D.js +120 -103
  184. package/lib-cjs/component/1d/database/ResurrectedDatabaseRanges.js +1 -1
  185. package/lib-cjs/component/1d/jCouplingGraph/JsCouplingLinks.js +1 -1
  186. package/lib-cjs/component/1d/multiplicityTree/TreeColors.js +1 -6
  187. package/lib-cjs/component/1d/tool/BaseLineZones.js +6 -3
  188. package/lib-cjs/component/1d/tool/PeakPointer.js +1 -1
  189. package/lib-cjs/component/1d/utilities/scale.js +1 -3
  190. package/lib-cjs/component/1d-2d/components/SpectrumInfoBlock.js +4 -1
  191. package/lib-cjs/component/1d-2d/tools/BrushXY.js +10 -7
  192. package/lib-cjs/component/1d-2d/tools/CrossLinePointer.js +1 -1
  193. package/lib-cjs/component/2d/FooterBanner.js +3 -2
  194. package/lib-cjs/component/2d/Viewer2D.js +50 -28
  195. package/lib-cjs/component/2d/XAxis.js +1 -1
  196. package/lib-cjs/component/2d/YAxis.js +1 -1
  197. package/lib-cjs/component/2d/zones/Signal.js +1 -2
  198. package/lib-cjs/component/EventsTrackers/BrushTracker.js +21 -6
  199. package/lib-cjs/component/NMRium.js +37 -24
  200. package/lib-cjs/component/assignment/actions/setActiveAssignment.js +1 -1
  201. package/lib-cjs/component/elements/Input.js +1 -0
  202. package/lib-cjs/component/elements/InputRange.js +1 -1
  203. package/lib-cjs/component/elements/Scroller.js +35 -0
  204. package/lib-cjs/component/elements/dropDownButton/DropDownList.js +3 -1
  205. package/lib-cjs/component/elements/popup/Alert/AlertBlock.js +21 -15
  206. package/lib-cjs/component/elements/popup/Alert/Context.js +6 -2
  207. package/lib-cjs/component/elements/popup/Alert/Provider.js +2 -2
  208. package/lib-cjs/component/elements/popup/Modal/Provider.js +3 -1
  209. package/lib-cjs/component/header/ZeroFillingOptionsPanel.js +3 -8
  210. package/lib-cjs/component/hooks/useCheckToolsVisibility.js +2 -2
  211. package/lib-cjs/component/hooks/useExport.js +2 -1
  212. package/lib-cjs/component/hooks/usePanelPreferences.js +1 -1
  213. package/lib-cjs/component/hooks/useSaveSettings.js +9 -11
  214. package/lib-cjs/component/modal/AboutPredictionModal.js +1 -1
  215. package/lib-cjs/component/modal/AboutSpectrumSimulationModal.js +54 -0
  216. package/lib-cjs/component/modal/AlignSpectraModal.js +11 -1
  217. package/lib-cjs/component/modal/MultipletAnalysisModal.js +2 -1
  218. package/lib-cjs/component/modal/PredictSpectraModal.js +24 -27
  219. package/lib-cjs/component/modal/changeSum/ChangeSumModal.js +1 -1
  220. package/lib-cjs/component/modal/editRange/forms/components/SignalsForm.js +1 -1
  221. package/lib-cjs/component/modal/editZone/SignalsForm.js +1 -1
  222. package/lib-cjs/component/modal/metaImportation/MetaImportationModal.js +1 -1
  223. package/lib-cjs/component/modal/setting/settings-tabs/DisplayTabContent.js +4 -0
  224. package/lib-cjs/component/modal/setting/settings-tabs/FormattingTabContent.js +1 -1
  225. package/lib-cjs/component/modal/setting/settings-tabs/InfoBlockTabContent.js +9 -2
  226. package/lib-cjs/component/modal/setting/settingsValidation.js +2 -2
  227. package/lib-cjs/component/panels/IntegralsPanel/IntegralTable.js +4 -7
  228. package/lib-cjs/component/panels/MoleculesPanel/MoleculePanelHeader.js +6 -6
  229. package/lib-cjs/component/panels/MoleculesPanel/useAtomAssignment.js +3 -5
  230. package/lib-cjs/component/panels/Panels.js +13 -0
  231. package/lib-cjs/component/panels/PeaksPanel/PeaksTable.js +1 -1
  232. package/lib-cjs/component/panels/SpectrumsPanel/SpectraPreferences.js +3 -2
  233. package/lib-cjs/component/panels/SpectrumsPanel/SpectraTable.js +1 -1
  234. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/SpectrumSetting.js +3 -1
  235. package/lib-cjs/component/panels/SpectrumsPanel/base/setting/processSnapPlot.js +2 -2
  236. package/lib-cjs/component/panels/SummaryPanel/utilities/Utilities.js +1 -1
  237. package/lib-cjs/component/panels/databasePanel/DatabasePanel.js +34 -27
  238. package/lib-cjs/component/panels/databasePanel/DatabaseTable.js +1 -1
  239. package/lib-cjs/component/panels/extra/utilities/MultiplicityUtilities.js +2 -2
  240. package/lib-cjs/component/panels/extra/utilities/UseToggleStatus.js +1 -1
  241. package/lib-cjs/component/panels/filtersPanel/FiltersTable.js +2 -2
  242. package/lib-cjs/component/panels/predictionPanel/PredictionOptionsPanel.js +2 -1
  243. package/lib-cjs/component/panels/predictionPanel/PredictionPanel.js +3 -2
  244. package/lib-cjs/component/panels/predictionPanel/PredictionSimpleOptions.js +1 -1
  245. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulation.js +94 -0
  246. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationPreferences.js +42 -0
  247. package/lib-cjs/component/panels/spectrumSimulation/SpectrumSimulationSimpleOptions.js +31 -0
  248. package/lib-cjs/component/panels/spectrumSimulation/SpinSystemTable.js +67 -0
  249. package/lib-cjs/component/reducer/Reducer.js +253 -239
  250. package/lib-cjs/component/reducer/actions/AssignmentsActions.js +1 -1
  251. package/lib-cjs/component/reducer/actions/DatabaseActions.js +2 -1
  252. package/lib-cjs/component/reducer/actions/DomainActions.js +31 -1
  253. package/lib-cjs/component/reducer/actions/FiltersActions.js +4 -4
  254. package/lib-cjs/component/reducer/actions/LoadActions.js +1 -1
  255. package/lib-cjs/component/reducer/actions/MoleculeActions.js +62 -3
  256. package/lib-cjs/component/reducer/actions/SpectrumsActions.js +43 -3
  257. package/lib-cjs/component/reducer/actions/ToolsActions.js +2 -2
  258. package/lib-cjs/component/reducer/actions/ZonesActions.js +1 -1
  259. package/lib-cjs/component/reducer/preferences/actions/addWorkspace.js +19 -15
  260. package/lib-cjs/component/reducer/preferences/actions/setActiveWorkspace.js +1 -1
  261. package/lib-cjs/component/reducer/preferences/actions/setPreferences.js +3 -4
  262. package/lib-cjs/component/reducer/preferences/preferencesReducer.js +5 -1
  263. package/lib-cjs/component/reducer/preferences/utilities/flatObject.js +1 -1
  264. package/lib-cjs/component/utility/PathBuilder.js +11 -0
  265. package/lib-cjs/component/utility/export.js +9 -9
  266. package/lib-cjs/component/utility/getSpectraObjectPaths.js +1 -1
  267. package/lib-cjs/component/utility/getUniqueNuclei.js +1 -1
  268. package/lib-cjs/component/utility/jpathToArray.js +1 -1
  269. package/lib-cjs/component/workspaces/index.js +2 -0
  270. package/lib-cjs/component/workspaces/simulation.js +71 -0
  271. package/lib-cjs/component/workspaces/workspaceDefaultProperties.js +9 -5
  272. package/lib-cjs/data/PredictionManager.js +96 -22
  273. package/lib-cjs/data/SpectraManager.js +1 -1
  274. package/lib-cjs/data/data1d/Spectrum1D/generateJGraphData.js +3 -3
  275. package/lib-cjs/data/data1d/Spectrum1D/getReferenceShift.js +5 -4
  276. package/lib-cjs/data/data1d/Spectrum1D/integrals/changeIntegralsRelative.js +12 -13
  277. package/lib-cjs/data/data1d/Spectrum1D/ranges/changeRangeRelativeValue.js +10 -9
  278. package/lib-cjs/data/data1d/database.js +13 -6
  279. package/lib-cjs/data/data1d/multipleSpectraAnalysis.js +1 -1
  280. package/lib-cjs/data/data1d/spectrumSimulation.js +58 -0
  281. package/lib-cjs/data/data2d/Spectrum2D/contours.js +7 -1
  282. package/lib-cjs/data/data2d/Spectrum2D/getMissingProjection.js +6 -6
  283. package/lib-cjs/data/data2d/Spectrum2D/getShift.js +1 -1
  284. package/lib-cjs/data/data2d/Spectrum2D/getSlice.js +4 -4
  285. package/lib-cjs/data/data2d/Spectrum2D/zones/getDetectionZones.js +5 -5
  286. package/lib-cjs/data/matrixGeneration.js +1 -1
  287. package/lib-cjs/data/molecules/MoleculeManager.js +23 -8
  288. package/lib-cjs/data/parseMeta/linkMetaWithSpectra.js +2 -1
  289. package/lib-cjs/data/utilities/FindUtilities.js +4 -4
  290. package/lib-cjs/data/utilities/calculateSanPlot.js +3 -3
  291. package/lib-cjs/data/utilities/generateNumbersPowerOfX.js +1 -1
  292. package/lib-cjs/versionInfo.js +1 -1
  293. package/package.json +21 -20
@@ -27,7 +27,7 @@ function XAxis(props) {
27
27
  useEffect(() => {
28
28
  if (!show)
29
29
  return;
30
- let scaleX = get2DXScale({
30
+ const scaleX = get2DXScale({
31
31
  width,
32
32
  margin,
33
33
  xDomain,
@@ -27,7 +27,7 @@ function YAxis(props) {
27
27
  useEffect(() => {
28
28
  if (!show || !yDomain)
29
29
  return;
30
- let scaleY = get2DYScale({ height, yDomain, margin }, !!spectrum?.info?.isFid);
30
+ const scaleY = get2DYScale({ height, yDomain, margin }, !!spectrum?.info?.isFid);
31
31
  const axis = d3.axisRight(scaleY).ticks(8).tickFormat(d3.format('0'));
32
32
  // @ts-expect-error well typed
33
33
  d3.select(refAxis.current).call(axis);
@@ -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,10 +15,10 @@ 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
- import { LoggerProvider } from './context/LoggerContext';
21
+ import { LoggerProvider, useLogger } from './context/LoggerContext';
22
22
  import { PreferencesProvider } from './context/PreferencesContext';
23
23
  import { AlertProvider } from './elements/popup/Alert';
24
24
  import { ModalProvider } from './elements/popup/Modal';
@@ -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 { logger } = useLogger();
231
+ useEffect(() => {
232
+ if (!errorAction)
233
+ return;
234
+ logger.error(errorAction);
235
+ }, [errorAction, logger]);
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,
@@ -125,6 +125,7 @@ const Input = forwardRef((props, ref) => {
125
125
  onClear?.();
126
126
  }
127
127
  return (_jsxs("div", { style: {
128
+ ...(renderIcon || (canClear && { padding: '0 5px' })),
128
129
  ...styles.inputWrapper,
129
130
  ...style?.inputWrapper,
130
131
  }, className: `input ${className || ''}`, children: [renderIcon?.(), _jsx("input", { ...otherProps, ref: combinedRef, name: name, style: {
@@ -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 {
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from 'react';
2
+ interface ScrollerProps {
3
+ scrollTo: string;
4
+ children: ReactNode;
5
+ }
6
+ export declare function Scroller(props: ScrollerProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare namespace Scroller {
8
+ var Item: typeof ScrollerElement;
9
+ }
10
+ interface ScrollerElementProps {
11
+ elementKey: string;
12
+ children: ReactNode;
13
+ }
14
+ declare function ScrollerElement(props: ScrollerElementProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,31 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Children, createContext, isValidElement, useContext, useEffect, useRef, } from 'react';
3
+ const ScrollContext = createContext('');
4
+ const ScrollProvider = ScrollContext.Provider;
5
+ function useScrollKey() {
6
+ const context = useContext(ScrollContext);
7
+ if (!context) {
8
+ throw new Error('Scroller context was not found');
9
+ }
10
+ return context;
11
+ }
12
+ export function Scroller(props) {
13
+ const { scrollTo, children } = props;
14
+ const isAllScrollItem = Children.toArray(children).some((child) => isValidElement(child) && child.type === ScrollerElement);
15
+ if (!isAllScrollItem && Children.count(children) > 0) {
16
+ throw new Error("one of the children should be of type <Scroller.Item elementKey='...' > children </Scroller.Item>");
17
+ }
18
+ return _jsxs(ScrollProvider, { value: scrollTo, children: [" ", children, " "] });
19
+ }
20
+ function ScrollerElement(props) {
21
+ const { children, elementKey } = props;
22
+ const scrollToKey = useScrollKey();
23
+ const ref = useRef(null);
24
+ useEffect(() => {
25
+ if (ref.current && elementKey === scrollToKey) {
26
+ ref.current.scrollIntoView({ behavior: 'smooth' });
27
+ }
28
+ }, [elementKey, scrollToKey]);
29
+ return _jsx("div", { ref: ref, children: children });
30
+ }
31
+ Scroller.Item = ScrollerElement;
@@ -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;
@@ -1,7 +1,8 @@
1
+ import { Alert } from './Context';
1
2
  interface AlertBlockProps {
2
3
  offset: string;
3
- alert: any;
4
+ alert: Alert;
4
5
  onClose: () => void;
5
6
  }
6
- export default function AlertBlock(props: AlertBlockProps): import("react/jsx-runtime").JSX.Element;
7
+ export default function AlertBlock(props: AlertBlockProps): import("@emotion/react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -1,24 +1,30 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
2
+ /** @jsxImportSource @emotion/react */
3
+ import { css } from '@emotion/react';
2
4
  import { FaTimes } from 'react-icons/fa';
3
5
  import { types } from '../options';
4
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
+ `;
5
23
  export default function AlertBlock(props) {
6
24
  const { offset, alert, onClose } = props;
7
- return (_jsxs("div", { style: {
25
+ return (_jsxs("div", { css: style, style: {
8
26
  margin: offset,
9
- padding: '25px',
10
- borderRadius: '10px',
11
- pointerEvents: 'all',
12
27
  backgroundColor: alert.options.backgroundColor,
13
28
  color: alert.options.color,
14
- minHeight: '60px',
15
- position: 'relative',
16
- }, children: [_jsx("button", { style: {
17
- position: 'absolute',
18
- right: '5px',
19
- top: '5px',
20
- border: 'none',
21
- backgroundColor: 'transparent',
22
- color: 'white',
23
- }, type: "button", onClick: onClose, children: _jsx(FaTimes, {}) }), _jsx("span", { children: alert.message }), alert.options.type === types.PROGRESS_INDICATOR && _jsx(ProgressIndicator, {})] }, alert.id));
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));
24
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?: {
@@ -5,7 +5,7 @@ import { createPortal } from 'react-dom';
5
5
  import { TransitionGroup } from 'react-transition-group';
6
6
  import Transition from '../Transition';
7
7
  import Wrapper from '../Wrapper';
8
- import { positions, transitions, types } from '../options';
8
+ import { positions, transitions, types, } from '../options';
9
9
  import AlertBlock from './AlertBlock';
10
10
  import { AlertProvider } from './Context';
11
11
  function Provider({ children, wrapperRef = null, offset = '5px', position = positions.BOTTOM_CENTER, timeout = 3000, type, transition = transitions.FADE, ...props }) {
@@ -52,10 +52,10 @@ function Provider({ children, wrapperRef = null, offset = '5px', position = posi
52
52
  id,
53
53
  message,
54
54
  options: alertOptions,
55
+ close: () => remove(alert),
55
56
  };
56
- alert.close = () => remove(alert);
57
57
  if (alert.options.timeout) {
58
- const timerId = setTimeout(() => {
58
+ const timerId = window.setTimeout(() => {
59
59
  remove(alert);
60
60
  timersId.current.splice(timersId.current.indexOf(timerId), 1);
61
61
  }, alert.options.timeout);