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
@@ -8,16 +8,16 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
8
8
  // temporary because nucleus was undefined;
9
9
  if (index === -1)
10
10
  index = 0;
11
- let info = {
11
+ const info = {
12
12
  nucleus: datumInfo.nucleus[index],
13
13
  isFid: false,
14
14
  isComplex: false,
15
15
  dimension: 1,
16
16
  };
17
- let from = index === 0 ? datum.minX : datum.minY;
18
- let to = index === 0 ? datum.maxX : datum.maxY;
19
- let nbPoints = index === 0 ? datum.z[0].length : datum.z.length;
20
- let projection = new Float64Array(nbPoints);
17
+ const from = index === 0 ? datum.minX : datum.minY;
18
+ const to = index === 0 ? datum.maxX : datum.maxY;
19
+ const nbPoints = index === 0 ? datum.z[0].length : datum.z.length;
20
+ const projection = new Float64Array(nbPoints);
21
21
  if (index === 1) {
22
22
  for (let i = 0; i < datum.z.length; i++) {
23
23
  for (let j = 0; j < datum.z[0].length; j++) {
@@ -32,7 +32,7 @@ export function getMissingProjection(datum, nucleus, datumInfo, usedColors) {
32
32
  }
33
33
  }
34
34
  }
35
- let data = {
35
+ const data = {
36
36
  x: zoneToX({ from, to }, nbPoints),
37
37
  re: projection,
38
38
  };
@@ -1,6 +1,6 @@
1
1
  import { Filters } from 'nmr-processing';
2
2
  export function getShift(spectrum) {
3
- let shift = { x: 0, y: 0 };
3
+ const shift = { x: 0, y: 0 };
4
4
  if (spectrum?.filters) {
5
5
  for (const filter of spectrum.filters) {
6
6
  if (filter.name === Filters.shift2DX.id) {
@@ -13,26 +13,26 @@ export function getSlice(spectrum, position) {
13
13
  return;
14
14
  if (yIndex < 0 || yIndex >= data.z.length)
15
15
  return;
16
- let infoX = {
16
+ const infoX = {
17
17
  nucleus: info.nucleus[0],
18
18
  isFid: false,
19
19
  isComplex: false,
20
20
  dimension: 1,
21
21
  };
22
- let dataX = {
22
+ const dataX = {
23
23
  x: zoneToX({ from: data.minX, to: data.maxX }, data.z[0].length),
24
24
  re: new Float64Array(data.z[0].length),
25
25
  };
26
26
  for (let i = 0; i < data.z[0].length; i++) {
27
27
  dataX.re[i] += data.z[yIndex][i];
28
28
  }
29
- let infoY = {
29
+ const infoY = {
30
30
  nucleus: info.nucleus[1],
31
31
  isFid: false,
32
32
  isComplex: false,
33
33
  dimension: 1,
34
34
  };
35
- let dataY = {
35
+ const dataY = {
36
36
  x: zoneToX({ from: data.minY, to: data.maxY }, data.z.length),
37
37
  re: new Float64Array(data.z.length),
38
38
  };
@@ -28,7 +28,7 @@ export function getDetectionZones(spectrum, options) {
28
28
  function autoZonesDetection(data, options) {
29
29
  const { clean, tolerances, thresholdFactor, maxPercentCutOff, convolutionByFFT, info: { nucleus: nuclei, originFrequency }, } = options;
30
30
  const { enhanceSymmetry = nuclei[0] === nuclei[1] } = options;
31
- let zones = xyzAutoZonesPicking(data, {
31
+ const zones = xyzAutoZonesPicking(data, {
32
32
  nuclei,
33
33
  tolerances,
34
34
  observedFrequencies: originFrequency,
@@ -54,7 +54,7 @@ function getSubMatrix(datum, selectedZone) {
54
54
  [xIndexFrom, xIndexTo] = [xIndexTo, xIndexFrom];
55
55
  if (yIndexFrom > yIndexTo)
56
56
  [yIndexFrom, yIndexTo] = [yIndexTo, yIndexFrom];
57
- let dataMatrix = {
57
+ const dataMatrix = {
58
58
  z: [],
59
59
  maxX: data.minX + xIndexTo * xStep,
60
60
  minX: data.minX + xIndexFrom * xStep,
@@ -63,14 +63,14 @@ function getSubMatrix(datum, selectedZone) {
63
63
  };
64
64
  let maxZ = Number.MIN_SAFE_INTEGER;
65
65
  let minZ = Number.MAX_SAFE_INTEGER;
66
- let nbXPoints = xIndexTo - xIndexFrom + 1;
66
+ const nbXPoints = xIndexTo - xIndexFrom + 1;
67
67
  for (let j = yIndexFrom; j < yIndexTo; j++) {
68
- let row = new Float32Array(nbXPoints);
68
+ const row = new Float32Array(nbXPoints);
69
69
  let xIndex = xIndexFrom;
70
70
  for (let i = 0; i < nbXPoints; i++) {
71
71
  row[i] = data.z[j][xIndex++];
72
72
  }
73
- for (let rowValue of row) {
73
+ for (const rowValue of row) {
74
74
  if (maxZ < rowValue)
75
75
  maxZ = rowValue;
76
76
  if (minZ > rowValue)
@@ -5,10 +5,10 @@ interface FilterOptionsInfo {
5
5
  description: string;
6
6
  }
7
7
  type FiltersObjectRecord = Record<string, FilterOptionsInfo>;
8
- export type MatrixFilters = {
8
+ export type MatrixFilters = Array<{
9
9
  name: FilterXYType['name'];
10
10
  options: FiltersObjectRecord;
11
- }[];
11
+ }>;
12
12
  export declare function getDefaultMatrixFilters(): {
13
13
  name: "fromTo" | "centerMean" | "centerMedian" | "normed" | "divideBySD" | "rescale" | "paretoNormalization" | "airPLSBaseline" | "iterativePolynomialBaseline" | "rollingAverageBaseline" | "rollingBallBaseline" | "rollingMedianBaseline" | "firstDerivative" | "secondDerivative" | "thirdDerivative" | "savitzkyGolay" | "ensureGrowing" | "equallySpaced" | "filterX" | "calibrateX" | "xFunction" | "yFunction";
14
14
  options: FiltersObjectRecord;
@@ -13,7 +13,7 @@ function isLeave(fieldOptions) {
13
13
  function flattenFields(filterName, data, properties, keysPath, parentObject, level) {
14
14
  for (const fieldKey in data) {
15
15
  let _keysPath = [];
16
- let _keysPathObject = parentObject || null;
16
+ const _keysPathObject = parentObject || null;
17
17
  let _level = level || 0;
18
18
  if (keysPath) {
19
19
  _keysPath = _keysPath.concat(keysPath);
@@ -3,5 +3,5 @@ export declare function fromJSON(mols: StateMolecule[], reservedMolecules?: Stat
3
3
  export declare function addMolfile(molecules: StateMoleculeExtended[], molfile: string): void;
4
4
  export declare function setMolfile(molecules: StateMoleculeExtended[], currentMolecule: StateMolecule): void;
5
5
  export declare function extractNumber(value: string): string | null;
6
- export declare function extractLabelsNumbers(molecules: Pick<StateMolecule, 'label'>[]): number[];
6
+ export declare function extractLabelsNumbers(molecules: Array<Pick<StateMolecule, 'label'>>): number[];
7
7
  export declare function getLabelNumber(reserveNumbers: number[]): number;
@@ -6,7 +6,7 @@ export function fromJSON(mols, reservedMolecules = []) {
6
6
  for (const mol of mols) {
7
7
  const molecule = OCLMolecule.fromMolfile(mol.molfile);
8
8
  const fragments = molecule.getFragments();
9
- for (let fragment of fragments) {
9
+ for (const fragment of fragments) {
10
10
  molecules.push(initMolecule({
11
11
  molfile: fragment.toMolfileV3(),
12
12
  label: mol.label || `P${getLabelNumber(reservedNumbers)}`,
@@ -21,8 +21,8 @@ export function addMolfile(molecules, molfile) {
21
21
  // try to parse molfile
22
22
  // this will throw if the molecule can not be parsed !
23
23
  const molecule = OCLMolecule.fromMolfile(molfile);
24
- let fragments = molecule.getFragments();
25
- for (let fragment of fragments) {
24
+ const fragments = molecule.getFragments();
25
+ for (const fragment of fragments) {
26
26
  molecules.push(initMolecule({
27
27
  molfile: fragment.toMolfileV3(),
28
28
  label: `P${getLabelNumber(reservedNumbers)}`,
@@ -35,11 +35,11 @@ export function setMolfile(molecules, currentMolecule) {
35
35
  const reservedNumbers = extractLabelsNumbers(molecules);
36
36
  // try to parse molfile
37
37
  // this will throw if the molecule can not be parsed !
38
- let molecule = OCLMolecule.fromMolfile(molfile);
39
- let fragments = molecule.getFragments();
38
+ const molecule = OCLMolecule.fromMolfile(molfile);
39
+ const fragments = molecule.getFragments();
40
40
  if (fragments.length > 1) {
41
41
  molecules = molecules.filter((m) => m.id !== id);
42
- for (let fragment of fragments) {
42
+ for (const fragment of fragments) {
43
43
  molecules.push(initMolecule({
44
44
  molfile: fragment.toMolfileV3(),
45
45
  label: `P${getLabelNumber(reservedNumbers)}`,
@@ -53,7 +53,7 @@ export function setMolfile(molecules, currentMolecule) {
53
53
  id,
54
54
  label,
55
55
  });
56
- let molIndex = molecules.findIndex((m) => m.id === id);
56
+ const molIndex = molecules.findIndex((m) => m.id === id);
57
57
  molecules.splice(molIndex, 1, _mol);
58
58
  }
59
59
  // we will split if we have many fragments
@@ -1,7 +1,8 @@
1
1
  import lodashGet from 'lodash/get';
2
2
  import { prepareKey } from './prepareKey';
3
3
  function linkMetaWithSpectra(options) {
4
- let { source, target, autolink = false, parseMetaFileResult, spectra, } = options;
4
+ const { autolink = false, parseMetaFileResult, spectra } = options;
5
+ let { source, target } = options;
5
6
  const targetValues = {};
6
7
  const { data, meta: { fields = [] }, } = parseMetaFileResult;
7
8
  if (!autolink) {
@@ -6,9 +6,9 @@ export interface MatrixOptions {
6
6
  * @default []
7
7
  *
8
8
  */
9
- filters: (MatrixFilter & {
9
+ filters: Array<MatrixFilter & {
10
10
  options: object;
11
- })[];
11
+ }>;
12
12
  /**
13
13
  * Exclusion zones
14
14
  * @default []
@@ -6,7 +6,7 @@ function findSpectrum(spectraData, spectrumID, checkIsVisible) {
6
6
  return spectrum;
7
7
  }
8
8
  function findSignal1D(spectrum, signalID) {
9
- for (let range of spectrum.ranges.values) {
9
+ for (const range of spectrum.ranges.values) {
10
10
  const signalIndex = range.signals.findIndex((_signal) => _signal.id === signalID);
11
11
  if (signalIndex >= 0) {
12
12
  return range.signals[signalIndex];
@@ -14,7 +14,7 @@ function findSignal1D(spectrum, signalID) {
14
14
  }
15
15
  }
16
16
  function findSignal2D(spectrum, signalID) {
17
- for (let zone of spectrum.zones.values) {
17
+ for (const zone of spectrum.zones.values) {
18
18
  const signalIndex = zone.signals.findIndex((_signal) => _signal.id === signalID);
19
19
  if (signalIndex >= 0) {
20
20
  return zone.signals[signalIndex];
@@ -22,7 +22,7 @@ function findSignal2D(spectrum, signalID) {
22
22
  }
23
23
  }
24
24
  function findRange(spectrum, signalID) {
25
- for (let range of spectrum.ranges.values) {
25
+ for (const range of spectrum.ranges.values) {
26
26
  const signalIndex = range.signals.findIndex((_signal) => _signal.id === signalID);
27
27
  if (signalIndex >= 0) {
28
28
  return range;
@@ -30,7 +30,7 @@ function findRange(spectrum, signalID) {
30
30
  }
31
31
  }
32
32
  function findZone(spectrum, signalID) {
33
- for (let zone of spectrum.zones.values) {
33
+ for (const zone of spectrum.zones.values) {
34
34
  const signalIndex = zone.signals.findIndex((_signal) => _signal.id === signalID);
35
35
  if (signalIndex >= 0) {
36
36
  return zone;
@@ -19,5 +19,5 @@ export declare function unlink(range: Range, options?: UnlinkOptions): Range;
19
19
  export declare function addDefaultSignal(range: any): void;
20
20
  export declare function checkRangeKind(range: any): boolean;
21
21
  export declare function checkSignalKinds(range: any, kinds: any): boolean;
22
- export declare function unlinkInAssignmentData(assignmentData: any, ranges: Partial<Range>[]): void;
22
+ export declare function unlinkInAssignmentData(assignmentData: any, ranges: Array<Partial<Range>>): void;
23
23
  export {};
@@ -6,4 +6,4 @@ export declare function resetDiaIDs(zone: Zone, axis: string): Zone;
6
6
  export declare function checkZoneKind(zone: Zone): boolean;
7
7
  export declare function checkSignalKinds(zone: Zone, kinds: string[]): boolean;
8
8
  export declare function unlink(zone: Zone, isOnZoneLevel?: boolean, signalIndex?: number, axis?: string): Zone;
9
- export declare function unlinkInAssignmentData(assignmentData: any, zones: Partial<Zone>[], axis?: string): void;
9
+ export declare function unlinkInAssignmentData(assignmentData: any, zones: Array<Partial<Zone>>, axis?: string): void;
@@ -16,9 +16,9 @@ function prepare1DData(data) {
16
16
  return array;
17
17
  }
18
18
  function prepare2DData(data) {
19
- let cols = data.z[0].length;
20
- let rows = data.z.length;
21
- let jump = Math.floor((cols * rows) / 204800) || 1;
19
+ const cols = data.z[0].length;
20
+ const rows = data.z.length;
21
+ const jump = Math.floor((cols * rows) / 204800) || 1;
22
22
  const array = new Float64Array(((cols * rows) / jump) >> 0);
23
23
  let index = 0;
24
24
  for (let r = 0; r < rows; r += 1) {
@@ -1,6 +1,6 @@
1
1
  export default function generateNumbersPowerOfX(start, end, options) {
2
2
  const { power = 2, format = formatNumber } = options || {};
3
- let values = [];
3
+ const values = [];
4
4
  for (let i = start; i <= end; i++) {
5
5
  const result = power ** i;
6
6
  values.push({
@@ -0,0 +1,12 @@
1
+ export declare function readText(): Promise<string>;
2
+ export declare function read(): Promise<ClipboardItems>;
3
+ export declare function writeText(data: string): Promise<void>;
4
+ export interface ClipboardItemInterface {
5
+ readonly presentationStyle?: PresentationStyle;
6
+ readonly lastModified?: number;
7
+ readonly delayed?: boolean;
8
+ readonly types: readonly string[];
9
+ getType(type: string): Promise<Blob>;
10
+ }
11
+ export declare function write(data: ClipboardItemInterface[]): Promise<void>;
12
+ export declare function newClipboardItem(items: Record<string, string | Blob | PromiseLike<string | Blob>>, options?: ClipboardItemOptions): Promise<ClipboardItem>;
@@ -0,0 +1,15 @@
1
+ export function readText() {
2
+ return import('clipboard-polyfill').then((c) => c.readText());
3
+ }
4
+ export function read() {
5
+ return import('clipboard-polyfill').then((c) => c.read());
6
+ }
7
+ export function writeText(data) {
8
+ return import('clipboard-polyfill').then((c) => c.writeText(data));
9
+ }
10
+ export function write(data) {
11
+ return import('clipboard-polyfill').then((c) => c.write(data));
12
+ }
13
+ export function newClipboardItem(items, options) {
14
+ return import('clipboard-polyfill').then((c) => new c.ClipboardItem(items, options));
15
+ }
@@ -0,0 +1,45 @@
1
+ import { ClipboardMode } from './types';
2
+ export interface CFBP {
3
+ mode: ClipboardMode | undefined;
4
+ label?: string;
5
+ onDismiss: () => void;
6
+ }
7
+ export interface ClipboardFallbackProps extends CFBP, Partial<Omit<ClipboardFallbackReadProps, 'mode' | 'label' | 'onDismiss'>>, Partial<Omit<ClipboardFallbackReadTextProps, 'mode' | 'label' | 'onDismiss'>>, Partial<Omit<ClipboardFallbackWriteProps, 'mode' | 'label' | 'onDismiss'>>, Partial<Omit<ClipboardFallbackWriteTextProps, 'mode' | 'label' | 'onDismiss'>> {
8
+ }
9
+ /**
10
+ * switch between ClipboardFallback variant over mode props
11
+ * mode === read => ClipboardFallbackReadProps
12
+ * mode === readText => ClipboardFallbackReadTextProps
13
+ * mode === write => ClipboardFallbackWriteProps
14
+ * mode === writeText => ClipboardFallbackWriteTextProps
15
+ *
16
+ * implement what you need in function what part of the clipboard api from useClipboard you use
17
+ * props will be checked at runtime
18
+ *
19
+ * @param props
20
+ */
21
+ export declare function ClipboardFallback(props: ClipboardFallbackProps): import("react/jsx-runtime").JSX.Element | null;
22
+ /**
23
+ * return null if !props.mode
24
+ *
25
+ * @param props
26
+ * @see ClipboardFallback
27
+ */
28
+ export declare function ClipboardFallbackModal(props: ClipboardFallbackProps): import("react/jsx-runtime").JSX.Element | null;
29
+ interface ClipboardFallbackReadProps extends CFBP {
30
+ onRead: (file: File) => void;
31
+ mode: 'read';
32
+ }
33
+ interface ClipboardFallbackReadTextProps extends CFBP {
34
+ onReadText: (text: string) => void;
35
+ mode: 'readText';
36
+ }
37
+ interface ClipboardFallbackWriteProps extends CFBP {
38
+ file: File;
39
+ mode: 'write';
40
+ }
41
+ interface ClipboardFallbackWriteTextProps extends CFBP {
42
+ text: string;
43
+ mode: 'writeText';
44
+ }
45
+ export {};
@@ -0,0 +1,150 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import styled from '@emotion/styled';
3
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
4
+ import { Modal } from 'react-science/ui';
5
+ import Button from '../../component/elements/Button';
6
+ const ClipboardForm = styled.form `
7
+ padding: 0.5rem;
8
+
9
+ & > label {
10
+ display: flex;
11
+ flex-direction: column;
12
+ gap: 0.5rem;
13
+ }
14
+
15
+ textarea {
16
+ padding: 0.5rem;
17
+ }
18
+ `;
19
+ const Actions = styled.div `
20
+ display: flex;
21
+ gap: 0.5rem;
22
+ justify-content: flex-end;
23
+ `;
24
+ function throwError(props, prop) {
25
+ throw new Error(`props.${prop} is mandatory with ${String(props.mode)} mode`);
26
+ }
27
+ function assertReadProps(props) {
28
+ if (typeof props.onRead !== 'function')
29
+ throwError(props, 'onRead');
30
+ }
31
+ function assertReadTextProps(props) {
32
+ if (typeof props.onReadText !== 'function')
33
+ throwError(props, 'onReadText');
34
+ }
35
+ function assertWriteProps(props) {
36
+ if (!props.file)
37
+ throwError(props, 'file');
38
+ if (typeof props.onDismiss !== 'function')
39
+ throwError(props, 'onDismiss');
40
+ }
41
+ function assertWriteTextProps(props) {
42
+ if (typeof props.text !== 'string')
43
+ throwError(props, 'text');
44
+ if (typeof props.onDismiss !== 'function')
45
+ throwError(props, 'onDismiss');
46
+ }
47
+ /**
48
+ * switch between ClipboardFallback variant over mode props
49
+ * mode === read => ClipboardFallbackReadProps
50
+ * mode === readText => ClipboardFallbackReadTextProps
51
+ * mode === write => ClipboardFallbackWriteProps
52
+ * mode === writeText => ClipboardFallbackWriteTextProps
53
+ *
54
+ * implement what you need in function what part of the clipboard api from useClipboard you use
55
+ * props will be checked at runtime
56
+ *
57
+ * @param props
58
+ */
59
+ export function ClipboardFallback(props) {
60
+ switch (props.mode) {
61
+ case 'read':
62
+ assertReadProps(props);
63
+ return _jsx(ClipboardFallbackRead, { ...props });
64
+ case 'readText':
65
+ assertReadTextProps(props);
66
+ return _jsx(ClipboardFallbackReadText, { ...props });
67
+ case 'write': {
68
+ assertWriteProps(props);
69
+ return _jsx(ClipboardFallbackWrite, { ...props });
70
+ }
71
+ case 'writeText':
72
+ assertWriteTextProps(props);
73
+ return _jsx(ClipboardFallbackWriteText, { ...props });
74
+ default:
75
+ return null;
76
+ }
77
+ }
78
+ /**
79
+ * return null if !props.mode
80
+ *
81
+ * @param props
82
+ * @see ClipboardFallback
83
+ */
84
+ export function ClipboardFallbackModal(props) {
85
+ if (!props.mode)
86
+ return null;
87
+ const titles = {
88
+ read: `Import data from file`,
89
+ readText: `Paste text from clipboard`,
90
+ write: `Export data to file`,
91
+ writeText: `Copy text from text area`,
92
+ };
93
+ return (_jsxs(Modal, { hasCloseButton: true, isOpen: true, onRequestClose: props.onDismiss, children: [_jsx(Modal.Header, { children: _jsx("h2", { children: titles[props.mode] }) }), _jsx(Modal.Body, { children: _jsx(ClipboardFallback, { ...props }) })] }));
94
+ }
95
+ function ClipboardFallbackRead(props) {
96
+ const onFileRef = useRef(props.onRead);
97
+ onFileRef.current = props.onRead;
98
+ const onSubmit = useCallback((event) => {
99
+ event.preventDefault();
100
+ const data = new FormData(event.currentTarget);
101
+ const file = data.get('file');
102
+ if (!(file instanceof File))
103
+ return;
104
+ onFileRef.current(file);
105
+ }, []);
106
+ if (props.mode !== 'read')
107
+ return null;
108
+ return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsxs("label", { children: [_jsx("span", { children: props.label ?? 'File' }), _jsx("input", { name: "file", type: "file" })] }), _jsx("p", { children: "We were not able to read from your clipboard. Please input your data in the file field" }), _jsxs(Actions, { children: [_jsx(Button.Done, { type: "submit", children: "Submit" }), _jsx(Button.Secondary, { type: "reset", onClick: props.onDismiss, children: "Cancel" })] })] }));
109
+ }
110
+ function ClipboardFallbackReadText(props) {
111
+ const onTextRef = useRef(props.onReadText);
112
+ onTextRef.current = props.onReadText;
113
+ const onSubmit = useCallback((event) => {
114
+ event.preventDefault();
115
+ const data = new FormData(event.currentTarget);
116
+ const text = data.get('text');
117
+ if (typeof text !== 'string')
118
+ return;
119
+ onTextRef.current(text);
120
+ }, []);
121
+ if (props.mode !== 'readText')
122
+ return null;
123
+ return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsxs("label", { children: [_jsx("span", { children: props.label ?? 'Text' }), _jsx("textarea", { name: "text", cols: 50, rows: 10 })] }), _jsx("p", { children: "We were not able to read text from your clipboard. Please paste your data in the text area." }), _jsxs(Actions, { children: [_jsx(Button.Done, { type: "submit", children: "Submit" }), _jsx(Button.Secondary, { type: "reset", onClick: props.onDismiss, children: "Cancel" })] })] }));
124
+ }
125
+ function ClipboardFallbackWrite(props) {
126
+ const onDismissRef = useRef(props.onDismiss);
127
+ onDismissRef.current = props.onDismiss;
128
+ const onSubmit = useCallback((event) => {
129
+ event.preventDefault();
130
+ onDismissRef.current();
131
+ }, []);
132
+ const downloadLink = useMemo(() => URL.createObjectURL(props.file), [props.file]);
133
+ useEffect(() => {
134
+ return () => URL.revokeObjectURL(downloadLink);
135
+ }, [downloadLink]);
136
+ if (props.mode !== 'write')
137
+ return null;
138
+ return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsx("p", { children: props.label ?? 'Download' }), _jsx("a", { href: downloadLink, download: props.file.name, children: "We were not able to write data to your clipboard. Please download your data with this link." }), _jsx(Actions, { children: _jsx(Button.Secondary, { type: "submit", children: "Dismiss" }) })] }));
139
+ }
140
+ function ClipboardFallbackWriteText(props) {
141
+ const onDismissRef = useRef(props.onDismiss);
142
+ onDismissRef.current = props.onDismiss;
143
+ const onSubmit = useCallback((event) => {
144
+ event.preventDefault();
145
+ onDismissRef.current();
146
+ }, []);
147
+ if (props.mode !== 'writeText')
148
+ return null;
149
+ return (_jsxs(ClipboardForm, { onSubmit: onSubmit, children: [_jsx("span", { children: props.label ?? 'Text' }), _jsx("textarea", { name: "text", cols: 30, rows: 10, ref: (node) => node?.select(), children: props.text }), _jsx("p", { children: "We were not able to write text to your clipboard. Please copy your data in the text area." }), _jsx(Actions, { children: _jsx(Button.Secondary, { type: "submit", children: "Dismiss" }) })] }));
150
+ }
@@ -0,0 +1,94 @@
1
+ import { ClipboardMode } from './types';
2
+ type PN = PermissionName | 'clipboard-read' | 'clipboard-write';
3
+ export interface UsePermissionReturn {
4
+ state: PermissionState | undefined;
5
+ isGranted: boolean;
6
+ }
7
+ export declare function useNavigatorPermission(now: boolean, permissionName: PN, onGranted?: () => void, onError?: typeof reportError): UsePermissionReturn;
8
+ export interface UseClipboardReturn {
9
+ /**
10
+ * polyfill native api (stable)
11
+ */
12
+ /**
13
+ * Fallback on 'read' mode
14
+ */
15
+ read: () => Promise<ClipboardItems | undefined>;
16
+ /**
17
+ * Fallback on 'readText' mode
18
+ */
19
+ readText: () => Promise<string | undefined>;
20
+ /**
21
+ * Fallback on 'write' mode with blobs (get blob for each first type for each item) state
22
+ */
23
+ write: (data: ClipboardItems) => Promise<void>;
24
+ /**
25
+ * Fallback on 'writeText' mode with text state
26
+ */
27
+ writeText: (data: string) => Promise<void>;
28
+ /**
29
+ * custom helper (stable)
30
+ */
31
+ /**
32
+ * use write but no need do to manually ClipboardItems transform
33
+ * Fallback on 'writeText' mode with text state
34
+ * @param data
35
+ * @param type a mime type default to 'text/plain'
36
+ */
37
+ rawWriteWithType: (data: string, type?: 'text/html' | 'text/plain' | string) => Promise<void>;
38
+ /**
39
+ * state for alternative
40
+ */
41
+ /**
42
+ * state to know if you need to display an alternative interface
43
+ */
44
+ shouldFallback: ClipboardMode | undefined;
45
+ /**
46
+ * state for 'writeText' / 'rawWriteWithType' mode fallback
47
+ */
48
+ text: string | undefined;
49
+ /**
50
+ * state for 'write' mode fallback
51
+ */
52
+ blobs: Blob[] | undefined;
53
+ /**
54
+ * method to clean up state for alternative interface (set shouldFallback to undefined, text to undefined and blobs to undefined)
55
+ * stable
56
+ */
57
+ cleanShouldFallback: () => void;
58
+ }
59
+ /**
60
+ * Give you a wrapped clipboard api and a shouldFallback state.
61
+ * ignore if read and readText return promise filled with undefined, and rely on shouldFallback to display an alternative interaction.
62
+ * You should use ClipboardFallback component
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * const { readText, shouldFallback, setShouldFallback } = useClipboard();
67
+ *
68
+ * function handlePasteAction() {
69
+ * // yes you can safely ignore error here,
70
+ * // readText() will never throw, error is caught and set shouldFallback to corresponding mode
71
+ * void readText().then(handlePaste);
72
+ * }
73
+ *
74
+ * function handlePaste(text: string | undefined) {
75
+ * if (!text) return;
76
+ *
77
+ * setState(text);
78
+ * setShouldFallback(null);
79
+ * }
80
+ *
81
+ * return (
82
+ * <>
83
+ * <button onClick={handlePasteAction}>Paste</button>
84
+ * <ClipboardFallbackModal
85
+ * mode={shouldFallback}
86
+ * onDismiss={() => setShouldFallback(null)}
87
+ * onReadText={handlePaste}
88
+ * />
89
+ * </>
90
+ * )
91
+ * ```
92
+ */
93
+ export declare function useClipboard(): UseClipboardReturn;
94
+ export {};