react-cheminfo 0.76.0 → 0.78.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 (389) hide show
  1. package/README.md +141 -31
  2. package/lib/card/core/cardAddress.d.ts +19 -2
  3. package/lib/card/core/cardAddress.d.ts.map +1 -1
  4. package/lib/card/core/cardAddress.js +35 -2
  5. package/lib/card/core/cardAddress.js.map +1 -1
  6. package/lib/card/core/cardPageUrl.d.ts +7 -1
  7. package/lib/card/core/cardPageUrl.d.ts.map +1 -1
  8. package/lib/card/core/cardPageUrl.js +4 -2
  9. package/lib/card/core/cardPageUrl.js.map +1 -1
  10. package/lib/card/core/index.d.ts +1 -1
  11. package/lib/card/core/index.d.ts.map +1 -1
  12. package/lib/card/core/index.js +1 -1
  13. package/lib/card/core/index.js.map +1 -1
  14. package/lib/credits/core/credits.d.ts +30 -0
  15. package/lib/credits/core/credits.d.ts.map +1 -1
  16. package/lib/credits/core/credits.js +35 -0
  17. package/lib/credits/core/credits.js.map +1 -1
  18. package/lib/download/core/downloadFigure.d.ts +12 -1
  19. package/lib/download/core/downloadFigure.d.ts.map +1 -1
  20. package/lib/download/core/downloadFigure.js +21 -0
  21. package/lib/download/core/downloadFigure.js.map +1 -1
  22. package/lib/download/core/figureDpi.d.ts +59 -0
  23. package/lib/download/core/figureDpi.d.ts.map +1 -0
  24. package/lib/download/core/figureDpi.js +75 -0
  25. package/lib/download/core/figureDpi.js.map +1 -0
  26. package/lib/download/core/figurePng.d.ts +4 -1
  27. package/lib/download/core/figurePng.d.ts.map +1 -1
  28. package/lib/download/core/figurePng.js +11 -2
  29. package/lib/download/core/figurePng.js.map +1 -1
  30. package/lib/download/core/index.d.ts +4 -1
  31. package/lib/download/core/index.d.ts.map +1 -1
  32. package/lib/download/core/index.js +3 -1
  33. package/lib/download/core/index.js.map +1 -1
  34. package/lib/download/core/pngDpi.d.ts +22 -0
  35. package/lib/download/core/pngDpi.d.ts.map +1 -0
  36. package/lib/download/core/pngDpi.js +79 -0
  37. package/lib/download/core/pngDpi.js.map +1 -0
  38. package/lib/download/ui/FigureDownloadPanel.d.ts +13 -0
  39. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  40. package/lib/download/ui/FigureDownloadPanel.js +18 -34
  41. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  42. package/lib/download/ui/figureDownloadHint.d.ts +5 -0
  43. package/lib/download/ui/figureDownloadHint.d.ts.map +1 -1
  44. package/lib/download/ui/figureDownloadHint.js +8 -0
  45. package/lib/download/ui/figureDownloadHint.js.map +1 -1
  46. package/lib/download/ui/figureDownloadOptions.d.ts +84 -0
  47. package/lib/download/ui/figureDownloadOptions.d.ts.map +1 -0
  48. package/lib/download/ui/figureDownloadOptions.js +2 -0
  49. package/lib/download/ui/figureDownloadOptions.js.map +1 -0
  50. package/lib/download/ui/resolutionChoices.d.ts +27 -0
  51. package/lib/download/ui/resolutionChoices.d.ts.map +1 -0
  52. package/lib/download/ui/resolutionChoices.js +48 -0
  53. package/lib/download/ui/resolutionChoices.js.map +1 -0
  54. package/lib/download/ui/useFigureActions.d.ts +4 -1
  55. package/lib/download/ui/useFigureActions.d.ts.map +1 -1
  56. package/lib/download/ui/useFigureActions.js +17 -8
  57. package/lib/download/ui/useFigureActions.js.map +1 -1
  58. package/lib/download/ui/useFigureDownload.d.ts +2 -55
  59. package/lib/download/ui/useFigureDownload.d.ts.map +1 -1
  60. package/lib/download/ui/useFigureDownload.js +45 -13
  61. package/lib/download/ui/useFigureDownload.js.map +1 -1
  62. package/lib/ecosystem/core/sites.d.ts.map +1 -1
  63. package/lib/ecosystem/core/sites.js +14 -0
  64. package/lib/ecosystem/core/sites.js.map +1 -1
  65. package/lib/ecosystem/core/types.d.ts +1 -1
  66. package/lib/ecosystem/core/types.d.ts.map +1 -1
  67. package/lib/ecosystem/ui/glyphs.d.ts.map +1 -1
  68. package/lib/ecosystem/ui/glyphs.js +3 -0
  69. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  70. package/lib/host/core/connectHost.js +1 -1
  71. package/lib/host/core/connectHost.js.map +1 -1
  72. package/lib/host/core/connectTool.d.ts +103 -0
  73. package/lib/host/core/connectTool.d.ts.map +1 -0
  74. package/lib/host/core/connectTool.js +169 -0
  75. package/lib/host/core/connectTool.js.map +1 -0
  76. package/lib/host/core/hostOutputs.d.ts +16 -3
  77. package/lib/host/core/hostOutputs.d.ts.map +1 -1
  78. package/lib/host/core/hostOutputs.js +38 -4
  79. package/lib/host/core/hostOutputs.js.map +1 -1
  80. package/lib/host/core/index.d.ts +8 -2
  81. package/lib/host/core/index.d.ts.map +1 -1
  82. package/lib/host/core/index.js +4 -1
  83. package/lib/host/core/index.js.map +1 -1
  84. package/lib/host/core/kinds.d.ts +31 -3
  85. package/lib/host/core/kinds.d.ts.map +1 -1
  86. package/lib/host/core/kinds.js +35 -4
  87. package/lib/host/core/kinds.js.map +1 -1
  88. package/lib/host/core/messageValues.d.ts +29 -0
  89. package/lib/host/core/messageValues.d.ts.map +1 -0
  90. package/lib/host/core/messageValues.js +57 -0
  91. package/lib/host/core/messageValues.js.map +1 -0
  92. package/lib/host/core/protocol.d.ts +2 -5
  93. package/lib/host/core/protocol.d.ts.map +1 -1
  94. package/lib/host/core/protocol.js +3 -37
  95. package/lib/host/core/protocol.js.map +1 -1
  96. package/lib/host/core/resultKinds.d.ts +74 -0
  97. package/lib/host/core/resultKinds.d.ts.map +1 -0
  98. package/lib/host/core/resultKinds.js +40 -0
  99. package/lib/host/core/resultKinds.js.map +1 -0
  100. package/lib/host/core/toolMessages.d.ts +24 -0
  101. package/lib/host/core/toolMessages.d.ts.map +1 -0
  102. package/lib/host/core/toolMessages.js +136 -0
  103. package/lib/host/core/toolMessages.js.map +1 -0
  104. package/lib/host/ui/index.d.ts +2 -0
  105. package/lib/host/ui/index.d.ts.map +1 -1
  106. package/lib/host/ui/index.js +1 -0
  107. package/lib/host/ui/index.js.map +1 -1
  108. package/lib/host/ui/useFramedTool.d.ts +74 -0
  109. package/lib/host/ui/useFramedTool.d.ts.map +1 -0
  110. package/lib/host/ui/useFramedTool.js +125 -0
  111. package/lib/host/ui/useFramedTool.js.map +1 -0
  112. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  113. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  114. package/lib/locales/de.json +30 -1
  115. package/lib/locales/en.json +30 -1
  116. package/lib/locales/es.json +30 -1
  117. package/lib/locales/fr.json +30 -1
  118. package/lib/locales/it.json +30 -1
  119. package/lib/molecule3d/ui/Molecule3DStage.d.ts +4 -33
  120. package/lib/molecule3d/ui/Molecule3DStage.d.ts.map +1 -1
  121. package/lib/molecule3d/ui/Molecule3DStage.js +3 -37
  122. package/lib/molecule3d/ui/Molecule3DStage.js.map +1 -1
  123. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  124. package/lib/molecule3d/ui/MoleculeCanvas3D.js +10 -2
  125. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  126. package/lib/molecule3d/ui/exportMoleculeImage.d.ts +10 -0
  127. package/lib/molecule3d/ui/exportMoleculeImage.d.ts.map +1 -1
  128. package/lib/molecule3d/ui/exportMoleculeImage.js +17 -0
  129. package/lib/molecule3d/ui/exportMoleculeImage.js.map +1 -1
  130. package/lib/molecule3d/ui/index.d.ts +1 -1
  131. package/lib/molecule3d/ui/index.d.ts.map +1 -1
  132. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +23 -0
  133. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
  134. package/lib/molecule3d/ui/useImageExport.d.ts +3 -0
  135. package/lib/molecule3d/ui/useImageExport.d.ts.map +1 -1
  136. package/lib/molecule3d/ui/useImageExport.js +21 -3
  137. package/lib/molecule3d/ui/useImageExport.js.map +1 -1
  138. package/lib/osiris/core/barGeometry.d.ts +42 -0
  139. package/lib/osiris/core/barGeometry.d.ts.map +1 -0
  140. package/lib/osiris/core/barGeometry.js +46 -0
  141. package/lib/osiris/core/barGeometry.js.map +1 -0
  142. package/lib/osiris/core/computeProperties.d.ts +42 -0
  143. package/lib/osiris/core/computeProperties.d.ts.map +1 -0
  144. package/lib/osiris/core/computeProperties.js +115 -0
  145. package/lib/osiris/core/computeProperties.js.map +1 -0
  146. package/lib/osiris/core/constants.d.ts +70 -0
  147. package/lib/osiris/core/constants.d.ts.map +1 -0
  148. package/lib/osiris/core/constants.js +99 -0
  149. package/lib/osiris/core/constants.js.map +1 -0
  150. package/lib/osiris/core/fitness.d.ts +32 -0
  151. package/lib/osiris/core/fitness.d.ts.map +1 -0
  152. package/lib/osiris/core/fitness.js +48 -0
  153. package/lib/osiris/core/fitness.js.map +1 -0
  154. package/lib/osiris/core/index.d.ts +29 -0
  155. package/lib/osiris/core/index.d.ts.map +1 -0
  156. package/lib/osiris/core/index.js +19 -0
  157. package/lib/osiris/core/index.js.map +1 -0
  158. package/lib/osiris/core/poolSize.d.ts +17 -0
  159. package/lib/osiris/core/poolSize.d.ts.map +1 -0
  160. package/lib/osiris/core/poolSize.js +22 -0
  161. package/lib/osiris/core/poolSize.js.map +1 -0
  162. package/lib/osiris/core/poolTypes.d.ts +140 -0
  163. package/lib/osiris/core/poolTypes.d.ts.map +1 -0
  164. package/lib/osiris/core/poolTypes.js +12 -0
  165. package/lib/osiris/core/poolTypes.js.map +1 -0
  166. package/lib/osiris/core/predictIdCode.d.ts +39 -0
  167. package/lib/osiris/core/predictIdCode.d.ts.map +1 -0
  168. package/lib/osiris/core/predictIdCode.js +54 -0
  169. package/lib/osiris/core/predictIdCode.js.map +1 -0
  170. package/lib/osiris/core/predictProtocol.d.ts +67 -0
  171. package/lib/osiris/core/predictProtocol.d.ts.map +1 -0
  172. package/lib/osiris/core/predictProtocol.js +29 -0
  173. package/lib/osiris/core/predictProtocol.js.map +1 -0
  174. package/lib/osiris/core/predictionPool.d.ts +23 -0
  175. package/lib/osiris/core/predictionPool.d.ts.map +1 -0
  176. package/lib/osiris/core/predictionPool.js +186 -0
  177. package/lib/osiris/core/predictionPool.js.map +1 -0
  178. package/lib/osiris/core/predictionQueue.d.ts +46 -0
  179. package/lib/osiris/core/predictionQueue.d.ts.map +1 -0
  180. package/lib/osiris/core/predictionQueue.js +57 -0
  181. package/lib/osiris/core/predictionQueue.js.map +1 -0
  182. package/lib/osiris/core/predictors.d.ts +62 -0
  183. package/lib/osiris/core/predictors.d.ts.map +1 -0
  184. package/lib/osiris/core/predictors.js +100 -0
  185. package/lib/osiris/core/predictors.js.map +1 -0
  186. package/lib/osiris/core/propertyKeys.d.ts +32 -0
  187. package/lib/osiris/core/propertyKeys.d.ts.map +1 -0
  188. package/lib/osiris/core/propertyKeys.js +44 -0
  189. package/lib/osiris/core/propertyKeys.js.map +1 -0
  190. package/lib/osiris/core/riskAppearance.d.ts +60 -0
  191. package/lib/osiris/core/riskAppearance.d.ts.map +1 -0
  192. package/lib/osiris/core/riskAppearance.js +59 -0
  193. package/lib/osiris/core/riskAppearance.js.map +1 -0
  194. package/lib/osiris/core/riskDetail.d.ts +22 -0
  195. package/lib/osiris/core/riskDetail.d.ts.map +1 -0
  196. package/lib/osiris/core/riskDetail.js +86 -0
  197. package/lib/osiris/core/riskDetail.js.map +1 -0
  198. package/lib/osiris/core/riskDetailRequest.d.ts +31 -0
  199. package/lib/osiris/core/riskDetailRequest.d.ts.map +1 -0
  200. package/lib/osiris/core/riskDetailRequest.js +49 -0
  201. package/lib/osiris/core/riskDetailRequest.js.map +1 -0
  202. package/lib/osiris/core/riskFindings.d.ts +26 -0
  203. package/lib/osiris/core/riskFindings.d.ts.map +1 -0
  204. package/lib/osiris/core/riskFindings.js +79 -0
  205. package/lib/osiris/core/riskFindings.js.map +1 -0
  206. package/lib/osiris/core/runPredictionJob.d.ts +20 -0
  207. package/lib/osiris/core/runPredictionJob.d.ts.map +1 -0
  208. package/lib/osiris/core/runPredictionJob.js +43 -0
  209. package/lib/osiris/core/runPredictionJob.js.map +1 -0
  210. package/lib/osiris/core/scales.d.ts +70 -0
  211. package/lib/osiris/core/scales.d.ts.map +1 -0
  212. package/lib/osiris/core/scales.js +185 -0
  213. package/lib/osiris/core/scales.js.map +1 -0
  214. package/lib/osiris/core/types.d.ts +91 -0
  215. package/lib/osiris/core/types.d.ts.map +1 -0
  216. package/lib/osiris/core/types.js +19 -0
  217. package/lib/osiris/core/types.js.map +1 -0
  218. package/lib/osiris/core/valuation.d.ts +28 -0
  219. package/lib/osiris/core/valuation.d.ts.map +1 -0
  220. package/lib/osiris/core/valuation.js +39 -0
  221. package/lib/osiris/core/valuation.js.map +1 -0
  222. package/lib/osiris/ui/PropertyBar.d.ts +27 -0
  223. package/lib/osiris/ui/PropertyBar.d.ts.map +1 -0
  224. package/lib/osiris/ui/PropertyBar.js +27 -0
  225. package/lib/osiris/ui/PropertyBar.js.map +1 -0
  226. package/lib/osiris/ui/PropertyPanel.d.ts +91 -0
  227. package/lib/osiris/ui/PropertyPanel.d.ts.map +1 -0
  228. package/lib/osiris/ui/PropertyPanel.js +77 -0
  229. package/lib/osiris/ui/PropertyPanel.js.map +1 -0
  230. package/lib/osiris/ui/PropertyRows.d.ts +40 -0
  231. package/lib/osiris/ui/PropertyRows.d.ts.map +1 -0
  232. package/lib/osiris/ui/PropertyRows.js +23 -0
  233. package/lib/osiris/ui/PropertyRows.js.map +1 -0
  234. package/lib/osiris/ui/RiskFindings.d.ts +43 -0
  235. package/lib/osiris/ui/RiskFindings.d.ts.map +1 -0
  236. package/lib/osiris/ui/RiskFindings.js +51 -0
  237. package/lib/osiris/ui/RiskFindings.js.map +1 -0
  238. package/lib/osiris/ui/RiskPanel.d.ts +46 -0
  239. package/lib/osiris/ui/RiskPanel.d.ts.map +1 -0
  240. package/lib/osiris/ui/RiskPanel.js +32 -0
  241. package/lib/osiris/ui/RiskPanel.js.map +1 -0
  242. package/lib/osiris/ui/RiskSquare.d.ts +51 -0
  243. package/lib/osiris/ui/RiskSquare.d.ts.map +1 -0
  244. package/lib/osiris/ui/RiskSquare.js +23 -0
  245. package/lib/osiris/ui/RiskSquare.js.map +1 -0
  246. package/lib/osiris/ui/index.d.ts +15 -0
  247. package/lib/osiris/ui/index.d.ts.map +1 -0
  248. package/lib/osiris/ui/index.js +8 -0
  249. package/lib/osiris/ui/index.js.map +1 -0
  250. package/lib/osiris/ui/usePredictions.d.ts +81 -0
  251. package/lib/osiris/ui/usePredictions.d.ts.map +1 -0
  252. package/lib/osiris/ui/usePredictions.js +102 -0
  253. package/lib/osiris/ui/usePredictions.js.map +1 -0
  254. package/lib/osiris-ui.d.ts +11 -0
  255. package/lib/osiris-ui.d.ts.map +1 -0
  256. package/lib/osiris-ui.js +11 -0
  257. package/lib/osiris-ui.js.map +1 -0
  258. package/lib/osiris.d.ts +17 -0
  259. package/lib/osiris.d.ts.map +1 -0
  260. package/lib/osiris.js +17 -0
  261. package/lib/osiris.js.map +1 -0
  262. package/lib/panel/ui/FilterInput.d.ts.map +1 -1
  263. package/lib/panel/ui/FilterInput.js +3 -1
  264. package/lib/panel/ui/FilterInput.js.map +1 -1
  265. package/lib/panel/ui/SidePanelItem.d.ts +39 -0
  266. package/lib/panel/ui/SidePanelItem.d.ts.map +1 -0
  267. package/lib/panel/ui/SidePanelItem.js +63 -0
  268. package/lib/panel/ui/SidePanelItem.js.map +1 -0
  269. package/lib/panel/ui/SidePanelStack.d.ts +11 -10
  270. package/lib/panel/ui/SidePanelStack.d.ts.map +1 -1
  271. package/lib/panel/ui/SidePanelStack.js +22 -15
  272. package/lib/panel/ui/SidePanelStack.js.map +1 -1
  273. package/lib/panel/ui/SpectrumColorSwatch.d.ts.map +1 -1
  274. package/lib/panel/ui/SpectrumColorSwatch.js +4 -2
  275. package/lib/panel/ui/SpectrumColorSwatch.js.map +1 -1
  276. package/lib/panel/ui/usePanelFolds.d.ts +35 -0
  277. package/lib/panel/ui/usePanelFolds.d.ts.map +1 -0
  278. package/lib/panel/ui/usePanelFolds.js +73 -0
  279. package/lib/panel/ui/usePanelFolds.js.map +1 -0
  280. package/lib/shared/ui/FullscreenStage.d.ts +43 -0
  281. package/lib/shared/ui/FullscreenStage.d.ts.map +1 -0
  282. package/lib/shared/ui/FullscreenStage.js +38 -0
  283. package/lib/shared/ui/FullscreenStage.js.map +1 -0
  284. package/lib/shared/ui/canFillScreen.d.ts +7 -0
  285. package/lib/shared/ui/canFillScreen.d.ts.map +1 -0
  286. package/lib/shared/ui/canFillScreen.js +9 -0
  287. package/lib/shared/ui/canFillScreen.js.map +1 -0
  288. package/lib/shared/ui/index.d.ts +3 -0
  289. package/lib/shared/ui/index.d.ts.map +1 -1
  290. package/lib/shared/ui/index.js +2 -0
  291. package/lib/shared/ui/index.js.map +1 -1
  292. package/lib/split/ui/splitPanes.d.ts +3 -3
  293. package/lib/split/ui/splitPanes.js +1 -1
  294. package/lib/structure/core/structureNotations.d.ts +8 -1
  295. package/lib/structure/core/structureNotations.d.ts.map +1 -1
  296. package/lib/structure/core/structureNotations.js +14 -8
  297. package/lib/structure/core/structureNotations.js.map +1 -1
  298. package/lib/structure/ui/StructureExportPanel.d.ts +8 -0
  299. package/lib/structure/ui/StructureExportPanel.d.ts.map +1 -1
  300. package/lib/structure/ui/StructureExportPanel.js +9 -4
  301. package/lib/structure/ui/StructureExportPanel.js.map +1 -1
  302. package/lib/structure/ui/index.d.ts +1 -0
  303. package/lib/structure/ui/index.d.ts.map +1 -1
  304. package/lib/structure/ui/index.js.map +1 -1
  305. package/package.json +4 -1
  306. package/src/card/core/cardAddress.ts +39 -3
  307. package/src/card/core/cardPageUrl.ts +10 -3
  308. package/src/card/core/index.ts +7 -1
  309. package/src/credits/core/credits.ts +40 -0
  310. package/src/download/core/downloadFigure.ts +26 -1
  311. package/src/download/core/figureDpi.ts +94 -0
  312. package/src/download/core/figurePng.ts +11 -2
  313. package/src/download/core/index.ts +13 -1
  314. package/src/download/core/pngDpi.ts +84 -0
  315. package/src/download/ui/FigureDownloadPanel.tsx +41 -51
  316. package/src/download/ui/figureDownloadHint.ts +13 -0
  317. package/src/download/ui/figureDownloadOptions.ts +85 -0
  318. package/src/download/ui/resolutionChoices.ts +67 -0
  319. package/src/download/ui/useFigureActions.ts +24 -9
  320. package/src/download/ui/useFigureDownload.tsx +57 -71
  321. package/src/ecosystem/core/sites.ts +14 -0
  322. package/src/ecosystem/core/types.ts +2 -1
  323. package/src/ecosystem/ui/glyphs.tsx +20 -0
  324. package/src/host/core/connectHost.ts +1 -1
  325. package/src/host/core/connectTool.ts +285 -0
  326. package/src/host/core/hostOutputs.ts +47 -5
  327. package/src/host/core/index.ts +20 -1
  328. package/src/host/core/kinds.ts +53 -8
  329. package/src/host/core/messageValues.ts +58 -0
  330. package/src/host/core/protocol.ts +5 -37
  331. package/src/host/core/resultKinds.ts +65 -0
  332. package/src/host/core/toolMessages.ts +160 -0
  333. package/src/host/ui/index.ts +6 -0
  334. package/src/host/ui/useFramedTool.ts +213 -0
  335. package/src/locales/de.json +30 -1
  336. package/src/locales/en.json +30 -1
  337. package/src/locales/es.json +30 -1
  338. package/src/locales/fr.json +30 -1
  339. package/src/locales/it.json +30 -1
  340. package/src/molecule3d/ui/Molecule3DStage.tsx +4 -88
  341. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +10 -1
  342. package/src/molecule3d/ui/exportMoleculeImage.ts +22 -0
  343. package/src/molecule3d/ui/index.ts +4 -1
  344. package/src/molecule3d/ui/moleculeViewer3DProps.ts +24 -0
  345. package/src/molecule3d/ui/useImageExport.ts +28 -2
  346. package/src/osiris/core/barGeometry.ts +74 -0
  347. package/src/osiris/core/computeProperties.ts +175 -0
  348. package/src/osiris/core/constants.ts +110 -0
  349. package/src/osiris/core/fitness.ts +59 -0
  350. package/src/osiris/core/index.ts +78 -0
  351. package/src/osiris/core/poolSize.ts +24 -0
  352. package/src/osiris/core/poolTypes.ts +140 -0
  353. package/src/osiris/core/predictIdCode.ts +69 -0
  354. package/src/osiris/core/predictProtocol.ts +78 -0
  355. package/src/osiris/core/predictionPool.ts +237 -0
  356. package/src/osiris/core/predictionQueue.ts +89 -0
  357. package/src/osiris/core/predictors.ts +142 -0
  358. package/src/osiris/core/propertyKeys.ts +54 -0
  359. package/src/osiris/core/riskAppearance.ts +86 -0
  360. package/src/osiris/core/riskDetail.ts +120 -0
  361. package/src/osiris/core/riskDetailRequest.ts +64 -0
  362. package/src/osiris/core/riskFindings.ts +92 -0
  363. package/src/osiris/core/runPredictionJob.ts +49 -0
  364. package/src/osiris/core/scales.ts +236 -0
  365. package/src/osiris/core/types.ts +103 -0
  366. package/src/osiris/core/valuation.ts +44 -0
  367. package/src/osiris/ui/PropertyBar.tsx +77 -0
  368. package/src/osiris/ui/PropertyPanel.tsx +227 -0
  369. package/src/osiris/ui/PropertyRows.tsx +92 -0
  370. package/src/osiris/ui/RiskFindings.tsx +137 -0
  371. package/src/osiris/ui/RiskPanel.tsx +81 -0
  372. package/src/osiris/ui/RiskSquare.tsx +108 -0
  373. package/src/osiris/ui/index.ts +17 -0
  374. package/src/osiris/ui/usePredictions.ts +194 -0
  375. package/src/osiris-ui.ts +11 -0
  376. package/src/osiris.ts +17 -0
  377. package/src/panel/ui/FilterInput.tsx +4 -1
  378. package/src/panel/ui/SidePanelItem.tsx +162 -0
  379. package/src/panel/ui/SidePanelStack.tsx +29 -36
  380. package/src/panel/ui/SpectrumColorSwatch.tsx +5 -3
  381. package/src/panel/ui/usePanelFolds.ts +103 -0
  382. package/src/shared/ui/FullscreenStage.tsx +96 -0
  383. package/src/shared/ui/canFillScreen.ts +8 -0
  384. package/src/shared/ui/index.ts +6 -0
  385. package/src/split/ui/splitPanes.tsx +4 -4
  386. package/src/structure/core/structureNotations.ts +25 -8
  387. package/src/structure/ui/StructureExportPanel.tsx +23 -4
  388. package/src/structure/ui/index.ts +4 -0
  389. package/styles/osiris.css +339 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * Everything OSIRIS predicts about one molecule: the four toxicity risks, then
3
+ * the ten numbers, in the order the original panel showed them.
4
+ *
5
+ * One panel wherever a molecule is predicted — beside an editor's canvas, for
6
+ * the row of a table the reader focused, beside a drawing — because a second
7
+ * panel would be a second place for the same ten rows to drift apart.
8
+ *
9
+ * The sections stand whether or not there is anything in them. A prediction
10
+ * costs a fifth of a second, and a panel that appeared only once it was ready
11
+ * would move the page under the reader's eye every time they drew a bond.
12
+ *
13
+ * Which explanation is open is the caller's state — it belongs to the page, and
14
+ * on the explorer it is what a click on a square changes — but *fetching* it is
15
+ * the panel's own business, so no page repeats the dance.
16
+ */
17
+
18
+ import { Callout, H5 } from '@blueprintjs/core';
19
+ import type { ReactElement, ReactNode } from 'react';
20
+ import { useEffect, useState } from 'react';
21
+ import { MF } from 'react-mf';
22
+
23
+ import { errorMessage } from '../../error/core/toError.ts';
24
+ import { PagePart } from '../../share/ui/PagePart.tsx';
25
+ import type { PropertyKey } from '../core/propertyKeys.ts';
26
+ import { PROPERTY_KEYS } from '../core/propertyKeys.ts';
27
+ import type { OsirisProperties, RiskDetail, RiskType } from '../core/types.ts';
28
+
29
+ import { PropertyRows } from './PropertyRows.tsx';
30
+ import { RiskFindings } from './RiskFindings.tsx';
31
+ import { RiskPanel } from './RiskPanel.tsx';
32
+
33
+ /** What {@link PropertyPanel} needs. */
34
+ export interface PropertyPanelProps {
35
+ /**
36
+ * What was predicted, or `null` when there is nothing to show yet.
37
+ * @default null
38
+ */
39
+ properties?: OsirisProperties | null;
40
+ /**
41
+ * The atom layout to draw the molecule with, in an explanation. Empty leaves
42
+ * openchemlib to invent one.
43
+ * @default ''
44
+ */
45
+ coordinates?: string;
46
+ /**
47
+ * Whether a prediction is running for the molecule the panel is showing.
48
+ * @default false
49
+ */
50
+ pending?: boolean;
51
+ /**
52
+ * What went wrong with this structure, in one sentence, or `null`.
53
+ * @default null
54
+ */
55
+ problem?: string | null;
56
+ /**
57
+ * Whether to open on the molecule's formula and name. Off for a host that
58
+ * already shows the formula beside the panel, such as a structure editor's
59
+ * side panel.
60
+ * @default true
61
+ */
62
+ head?: boolean;
63
+ /**
64
+ * Whether to draw the four risks, and the explanation a square opens. Off
65
+ * for a page answering a question about the numbers alone.
66
+ * @default true
67
+ */
68
+ risks?: boolean;
69
+ /**
70
+ * The property rows to draw, in the panel's order whatever order they are
71
+ * given in. Empty leaves the section out, for a page answering a question
72
+ * about the risks alone.
73
+ * @default PROPERTY_KEYS
74
+ */
75
+ rows?: readonly PropertyKey[];
76
+ /**
77
+ * What is said when there is nothing predicted and nothing running.
78
+ * @default 'Nothing to predict yet.'
79
+ */
80
+ emptyMessage?: ReactNode;
81
+ /**
82
+ * Which risk has its explanation open.
83
+ * @default null
84
+ */
85
+ openRisk?: RiskType | null;
86
+ /**
87
+ * Called with the risk to open, or `null` to close it. Without it the squares
88
+ * are not clickable.
89
+ * @default undefined
90
+ */
91
+ onOpenRisk?: (risk: RiskType | null) => void;
92
+ /**
93
+ * Why a risk came back as it did. Without it no explanation is offered.
94
+ * @default undefined
95
+ */
96
+ loadDetail?: (structure: string, risk: RiskType) => Promise<RiskDetail>;
97
+ }
98
+
99
+ /** One fetched explanation, and the request it answers. */
100
+ interface DetailAnswer {
101
+ key: string;
102
+ detail: RiskDetail | null;
103
+ error: string | null;
104
+ }
105
+
106
+ /**
107
+ * The risks and the properties of one molecule.
108
+ * @param props - See {@link PropertyPanelProps}.
109
+ * @returns The two panels, and the open explanation between them.
110
+ */
111
+ export function PropertyPanel(props: PropertyPanelProps): ReactElement {
112
+ const {
113
+ properties = null,
114
+ coordinates = '',
115
+ pending = false,
116
+ problem = null,
117
+ head = true,
118
+ risks = true,
119
+ rows = PROPERTY_KEYS,
120
+ emptyMessage = 'Nothing to predict yet.',
121
+ openRisk = null,
122
+ onOpenRisk,
123
+ loadDetail,
124
+ } = props;
125
+
126
+ const structure =
127
+ properties === null
128
+ ? ''
129
+ : coordinates === ''
130
+ ? properties.idCode
131
+ : `${properties.idCode} ${coordinates}`;
132
+ const answer = useRiskDetail(structure, openRisk, loadDetail);
133
+
134
+ return (
135
+ <div className="property-panel">
136
+ {problem === null ? null : (
137
+ <Callout intent="warning" compact>
138
+ {problem}
139
+ </Callout>
140
+ )}
141
+
142
+ {properties === null ? (
143
+ <p className="osiris-note">{pending ? 'Predicting…' : emptyMessage}</p>
144
+ ) : head ? (
145
+ <header className="property-panel__head">
146
+ <MF mf={properties.molecularFormula} />
147
+ <span className="property-panel__label">{properties.label}</span>
148
+ </header>
149
+ ) : null}
150
+
151
+ {risks ? (
152
+ <PagePart part="risks">
153
+ <RiskPanel
154
+ risks={properties?.risks ?? null}
155
+ pending={pending}
156
+ openRisk={openRisk}
157
+ onOpenRisk={onOpenRisk}
158
+ />
159
+ </PagePart>
160
+ ) : null}
161
+
162
+ {!risks ||
163
+ openRisk === null ||
164
+ structure === '' ||
165
+ loadDetail === undefined ? null : (
166
+ <PagePart part="detail">
167
+ <RiskFindings
168
+ risk={openRisk}
169
+ structure={structure}
170
+ detail={answer?.detail ?? null}
171
+ error={answer?.error ?? null}
172
+ />
173
+ </PagePart>
174
+ )}
175
+
176
+ {rows.length === 0 ? null : (
177
+ <PagePart part="properties">
178
+ <section className="property-section">
179
+ <H5>Predicted properties</H5>
180
+ <PropertyRows properties={properties} keys={rows} />
181
+ </section>
182
+ </PagePart>
183
+ )}
184
+ </div>
185
+ );
186
+ }
187
+
188
+ /**
189
+ * Fetch the open risk's explanation, and answer only about the request that is
190
+ * open now.
191
+ *
192
+ * The answer carries the request it belongs to rather than being cleared when a
193
+ * new one starts: clearing would mean writing state from inside the effect, and
194
+ * comparing keys says the same thing without the extra render.
195
+ * @param structure - The molecule: an idCode, with its coordinates after a space.
196
+ * @param openRisk - Which risk is open, or `null`.
197
+ * @param loadDetail - What answers the question, or `undefined` when nothing does.
198
+ * @returns The answer to the open request, or `null` while it is being worked out.
199
+ */
200
+ function useRiskDetail(
201
+ structure: string,
202
+ openRisk: RiskType | null,
203
+ loadDetail:
204
+ ((structure: string, risk: RiskType) => Promise<RiskDetail>) | undefined,
205
+ ): DetailAnswer | null {
206
+ const key =
207
+ openRisk === null || structure === '' ? '' : `${structure} ${openRisk}`;
208
+ const [answer, setAnswer] = useState<DetailAnswer | null>(null);
209
+
210
+ useEffect(() => {
211
+ if (key === '' || openRisk === null || loadDetail === undefined) return;
212
+ let live = true;
213
+ loadDetail(structure, openRisk).then(
214
+ (detail) => {
215
+ if (live) setAnswer({ key, detail, error: null });
216
+ },
217
+ (error: unknown) => {
218
+ if (live) setAnswer({ key, detail: null, error: errorMessage(error) });
219
+ },
220
+ );
221
+ return () => {
222
+ live = false;
223
+ };
224
+ }, [key, structure, openRisk, loadDetail]);
225
+
226
+ return answer !== null && answer.key === key ? answer : null;
227
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The ten predicted numbers, one row each: a name, a bar and a value.
3
+ *
4
+ * The order is the legacy panel's — cLogP, solubility, molweight, TPSA,
5
+ * drug-likeness, the two hydrogen-bond counts, stereocentres, rotatable bonds,
6
+ * drug score — and it is `PROPERTY_KEYS`, which the comparison table's columns
7
+ * and the plot's default axes also read. A reader who learned the panel reads
8
+ * the table without relearning it.
9
+ *
10
+ * A value the predictor could not answer prints the missing marker and draws no
11
+ * bar. It is never zero: `DrugScoreCalculator` consumes every sentinel and
12
+ * hands back a plausible number, so a bar drawn from one would be a wrong
13
+ * answer with nothing saying it is wrong.
14
+ */
15
+
16
+ import type { ReactElement } from 'react';
17
+
18
+ import { MISSING_VALUE } from '../../format/core/missing.ts';
19
+ import { formatDecimal } from '../../format/core/numbers.ts';
20
+ import { barGeometry } from '../core/barGeometry.ts';
21
+ import type { PropertyKey } from '../core/propertyKeys.ts';
22
+ import { PROPERTY_KEYS, propertyValue } from '../core/propertyKeys.ts';
23
+ import { propertyScale } from '../core/scales.ts';
24
+ import type { OsirisProperties } from '../core/types.ts';
25
+
26
+ import { PropertyBar } from './PropertyBar.tsx';
27
+
28
+ /** What {@link PropertyRows} needs. */
29
+ export interface PropertyRowsProps {
30
+ /**
31
+ * What was predicted, or `null` while the molecule is still being worked on —
32
+ * in which case every row stands with its name and no value, so nothing moves
33
+ * when the answer arrives.
34
+ * @default null
35
+ */
36
+ properties?: OsirisProperties | null;
37
+ /**
38
+ * The rows to draw. They are drawn in the panel's order whatever order they
39
+ * are given in, so a narrowed panel still reads as the whole one does.
40
+ * @default PROPERTY_KEYS
41
+ */
42
+ keys?: readonly PropertyKey[];
43
+ }
44
+
45
+ /**
46
+ * The property rows, all ten unless fewer are asked, in the panel's order.
47
+ * @param props - See {@link PropertyRowsProps}.
48
+ * @returns One row per property.
49
+ */
50
+ export function PropertyRows(props: PropertyRowsProps): ReactElement {
51
+ const { properties = null, keys = PROPERTY_KEYS } = props;
52
+
53
+ return (
54
+ <div className="property-rows">
55
+ {PROPERTY_KEYS.filter((key) => keys.includes(key)).map((key) => (
56
+ <PropertyRow
57
+ key={key}
58
+ propertyKey={key}
59
+ value={properties === null ? null : propertyValue(properties, key)}
60
+ />
61
+ ))}
62
+ </div>
63
+ );
64
+ }
65
+
66
+ interface PropertyRowProps {
67
+ propertyKey: PropertyKey;
68
+ value: number | null;
69
+ }
70
+
71
+ function PropertyRow(props: PropertyRowProps): ReactElement {
72
+ const { propertyKey, value } = props;
73
+ const scale = propertyScale(propertyKey);
74
+ const geometry = barGeometry(propertyKey, value);
75
+
76
+ return (
77
+ <div className="property-row">
78
+ <span className="property-row__label">
79
+ {scale.label}
80
+ {scale.unit === '' ? null : (
81
+ <span className="property-row__unit">{scale.unit}</span>
82
+ )}
83
+ </span>
84
+ <span className="property-row__bar">
85
+ {geometry === null ? null : <PropertyBar geometry={geometry} />}
86
+ </span>
87
+ <span className="property-row__value">
88
+ {value === null ? MISSING_VALUE : formatDecimal(value, scale.decimals)}
89
+ </span>
90
+ </div>
91
+ );
92
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Why one risk came back as it did.
3
+ *
4
+ * Two branches of the predictor reach the same red square and mean different
5
+ * things. *This molecule is known to be mutagenic* means the compound's own
6
+ * idCode is in a list derived from RTECS — data on this exact compound, and
7
+ * nothing on the drawing to point at. *High-risk fragments indicating
8
+ * Mutagenicity* means a substructure matched, and that substructure is drawn
9
+ * beside the molecule with its atoms painted on it.
10
+ *
11
+ * Telling them apart is the whole point of opening a square: aspirin, caffeine
12
+ * and paracetamol are all red through the first branch, and highlighting the
13
+ * whole molecule there would call the compound its own toxicophore.
14
+ *
15
+ * A fragment heading is repeated on each of the fragments under it, so it is
16
+ * printed once and the matches follow.
17
+ */
18
+
19
+ import { Callout, Spinner } from '@blueprintjs/core';
20
+ import type { ReactElement } from 'react';
21
+
22
+ import { Structure } from '../../structure/ui/Structure.tsx';
23
+ import { RISK_LABELS } from '../core/constants.ts';
24
+ import { KNOWN_MOLECULE_NOTE } from '../core/riskAppearance.ts';
25
+ import type { RiskDetail, RiskFinding, RiskType } from '../core/types.ts';
26
+
27
+ /** What {@link RiskFindings} needs. */
28
+ export interface RiskFindingsProps {
29
+ /** Which risk is open. */
30
+ risk: RiskType;
31
+ /** The molecule it was assessed on: the idCode, with its coordinates after a space. */
32
+ structure: string;
33
+ /**
34
+ * What the predictor found, or `null` while it is being worked out.
35
+ * @default null
36
+ */
37
+ detail?: RiskDetail | null;
38
+ /**
39
+ * Why the explanation could not be fetched, or `null`.
40
+ * @default null
41
+ */
42
+ error?: string | null;
43
+ }
44
+
45
+ /** How big a drawing in the explanation is, in pixels. */
46
+ const DRAWING = { width: 190, height: 130 };
47
+
48
+ /**
49
+ * The explanation of one risk.
50
+ * @param props - See {@link RiskFindingsProps}.
51
+ * @returns The predictor's own sentences, with every matched fragment drawn.
52
+ */
53
+ export function RiskFindings(props: RiskFindingsProps): ReactElement {
54
+ const { risk, structure, detail = null, error = null } = props;
55
+
56
+ if (error !== null) {
57
+ return <Callout intent="warning">{error}</Callout>;
58
+ }
59
+ if (detail === null) {
60
+ return (
61
+ // A div, not a paragraph: the spinner draws a div of its own.
62
+ <div className="osiris-note osiris-note--working">
63
+ <Spinner size={14} /> Working out why {RISK_LABELS[risk]} came back as
64
+ it did.
65
+ </div>
66
+ );
67
+ }
68
+
69
+ return (
70
+ <div className="risk-findings">
71
+ {detail.findings.map((finding, index) => (
72
+ <Finding
73
+ // The predictor prints each heading once and each matching fragment
74
+ // once under it, so the pair names the line without an index.
75
+ key={`${finding.kind}:${finding.description}:${finding.idCode ?? ''}`}
76
+ finding={finding}
77
+ structure={structure}
78
+ heading={
79
+ detail.findings[index - 1]?.description === finding.description
80
+ ? null
81
+ : finding.description
82
+ }
83
+ />
84
+ ))}
85
+ </div>
86
+ );
87
+ }
88
+
89
+ interface FindingProps {
90
+ finding: RiskFinding;
91
+ structure: string;
92
+ heading: string | null;
93
+ }
94
+
95
+ function Finding(props: FindingProps): ReactElement {
96
+ const { finding, structure, heading } = props;
97
+
98
+ return (
99
+ <div className="risk-finding">
100
+ {heading === null ? null : (
101
+ <p className="risk-finding__heading">{heading}</p>
102
+ )}
103
+ {finding.kind === 'known' ? (
104
+ <p className="osiris-note">{KNOWN_MOLECULE_NOTE}</p>
105
+ ) : null}
106
+ {finding.idCode === null ? null : (
107
+ <div className="risk-finding__drawings">
108
+ <figure className="risk-finding__figure">
109
+ <Structure
110
+ idCode={finding.idCode}
111
+ width={DRAWING.width}
112
+ height={DRAWING.height}
113
+ />
114
+ <figcaption>
115
+ {finding.severity === 'medium' ? 'Medium-risk' : 'High-risk'}{' '}
116
+ fragment
117
+ </figcaption>
118
+ </figure>
119
+ <figure className="risk-finding__figure">
120
+ <Structure
121
+ idCode={structure}
122
+ width={DRAWING.width}
123
+ height={DRAWING.height}
124
+ atomHighlight={[...finding.atoms]}
125
+ bondHighlight={[...finding.bonds]}
126
+ />
127
+ <figcaption>
128
+ {finding.atoms.length === 0
129
+ ? 'Not located on this drawing'
130
+ : 'Where it sits on the molecule'}
131
+ </figcaption>
132
+ </figure>
133
+ </div>
134
+ )}
135
+ </div>
136
+ );
137
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The four toxicity risks, and the sentence that keeps them honest.
3
+ *
4
+ * OSIRIS assesses mutagenicity, tumorigenicity, irritating effects and
5
+ * reproductive effects, in that order, and answers each with one of three
6
+ * levels — the same three the drug score multiplies by. A red square is very
7
+ * often the known-molecule branch rather than a matched fragment, which is why
8
+ * every assessed square opens its explanation.
9
+ *
10
+ * The caveat under them is the author's own, quoted rather than paraphrased: it
11
+ * is the sentence that stops a red square being read as a verdict, and softening
12
+ * it would be our words over his.
13
+ */
14
+
15
+ import { H5 } from '@blueprintjs/core';
16
+ import type { ReactElement } from 'react';
17
+
18
+ import { RISK_CAVEAT } from '../core/riskAppearance.ts';
19
+ import type { RiskLevel, RiskType } from '../core/types.ts';
20
+ import { RISK_TYPES } from '../core/types.ts';
21
+
22
+ import { RiskSquare } from './RiskSquare.tsx';
23
+
24
+ /** What {@link RiskPanel} needs. */
25
+ export interface RiskPanelProps {
26
+ /**
27
+ * How the four came back, or `null` when none of them has been assessed.
28
+ * @default null
29
+ */
30
+ risks?: Record<RiskType, RiskLevel> | null;
31
+ /**
32
+ * Whether a prediction is running for the molecule the panel is showing.
33
+ * @default false
34
+ */
35
+ pending?: boolean;
36
+ /**
37
+ * Which risk has its explanation open.
38
+ * @default null
39
+ */
40
+ openRisk?: RiskType | null;
41
+ /**
42
+ * Called with the risk to open, or `null` to close the one that is open.
43
+ * Without it the squares are not clickable.
44
+ * @default undefined
45
+ */
46
+ onOpenRisk?: (risk: RiskType | null) => void;
47
+ }
48
+
49
+ /**
50
+ * The four risk squares.
51
+ * @param props - See {@link RiskPanelProps}.
52
+ * @returns The panel, with the caveat under it.
53
+ */
54
+ export function RiskPanel(props: RiskPanelProps): ReactElement {
55
+ const { risks = null, pending = false, openRisk = null, onOpenRisk } = props;
56
+
57
+ return (
58
+ <section className="risk-panel">
59
+ <H5>Predicted toxicity risks</H5>
60
+ <div className="risk-grid">
61
+ {RISK_TYPES.map((risk) => (
62
+ <RiskSquare
63
+ key={risk}
64
+ risk={risk}
65
+ level={risks?.[risk]}
66
+ pending={pending}
67
+ selected={openRisk === risk}
68
+ onSelect={
69
+ onOpenRisk === undefined
70
+ ? undefined
71
+ : (chosen) => {
72
+ onOpenRisk(chosen === openRisk ? null : chosen);
73
+ }
74
+ }
75
+ />
76
+ ))}
77
+ </div>
78
+ <p className="osiris-note">{RISK_CAVEAT}</p>
79
+ </section>
80
+ );
81
+ }
@@ -0,0 +1,108 @@
1
+ /**
2
+ * One toxicity risk, as a coloured square with its name beside it.
3
+ *
4
+ * The square is a button whenever the page can explain it, because the
5
+ * explanation is the honest half of the colour: aspirin, caffeine and
6
+ * paracetamol come back red through the known-molecule branch, not through a
7
+ * toxicophore, and only opening it says so.
8
+ *
9
+ * `compact` drops the words and keeps the square, which is what a cell of the
10
+ * comparison table needs; the name and the level stay on the accessible label,
11
+ * so the cell is still readable to a screen reader and on hover.
12
+ */
13
+
14
+ import type { ReactElement } from 'react';
15
+
16
+ import { RISK_LABELS } from '../core/constants.ts';
17
+ import { riskAppearance } from '../core/riskAppearance.ts';
18
+ import type { RiskLevel, RiskType } from '../core/types.ts';
19
+
20
+ /** What {@link RiskSquare} needs. */
21
+ export interface RiskSquareProps {
22
+ /** Which of the four risks this shows. */
23
+ risk: RiskType;
24
+ /** How it came back, or `undefined` when it has not been assessed. */
25
+ level: RiskLevel | undefined;
26
+ /**
27
+ * Whether a prediction is running for this molecule. It is what tells an
28
+ * unassessed square to say it is working rather than that there is nothing
29
+ * to work on.
30
+ * @default false
31
+ */
32
+ pending?: boolean;
33
+ /**
34
+ * Whether this risk's explanation is the one open.
35
+ * @default false
36
+ */
37
+ selected?: boolean;
38
+ /**
39
+ * Called with the risk when the square is clicked. Without it the square is
40
+ * not a button.
41
+ * @default undefined
42
+ */
43
+ onSelect?: (risk: RiskType) => void;
44
+ /**
45
+ * Draw the square alone, for a cell of a table.
46
+ * @default false
47
+ */
48
+ compact?: boolean;
49
+ }
50
+
51
+ /**
52
+ * One risk's square.
53
+ * @param props - See {@link RiskSquareProps}.
54
+ * @returns The square, as a button when the page can explain it.
55
+ */
56
+ export function RiskSquare(props: RiskSquareProps): ReactElement {
57
+ const {
58
+ risk,
59
+ level,
60
+ pending = false,
61
+ selected = false,
62
+ onSelect,
63
+ compact = false,
64
+ } = props;
65
+ const { tone, label, explainable } = riskAppearance(level, pending);
66
+ const name = RISK_LABELS[risk];
67
+ const description = `${name}: ${label}`;
68
+ const clickable = onSelect !== undefined && explainable;
69
+
70
+ const body = (
71
+ <>
72
+ <span className="risk-square__swatch" data-level={tone} />
73
+ {compact ? null : (
74
+ <span className="risk-square__text">
75
+ <span className="risk-square__name">{name}</span>
76
+ <span className="risk-square__level">{label}</span>
77
+ </span>
78
+ )}
79
+ </>
80
+ );
81
+
82
+ if (!clickable) {
83
+ return (
84
+ <span
85
+ className={compact ? 'risk-square risk-square--compact' : 'risk-square'}
86
+ title={description}
87
+ aria-label={compact ? description : undefined}
88
+ >
89
+ {body}
90
+ </span>
91
+ );
92
+ }
93
+
94
+ return (
95
+ <button
96
+ type="button"
97
+ className={compact ? 'risk-square risk-square--compact' : 'risk-square'}
98
+ title={`${description} — why?`}
99
+ aria-label={compact ? description : undefined}
100
+ aria-pressed={selected}
101
+ onClick={() => {
102
+ onSelect(risk);
103
+ }}
104
+ >
105
+ {body}
106
+ </button>
107
+ );
108
+ }
@@ -0,0 +1,17 @@
1
+ export type { PropertyBarProps } from './PropertyBar.tsx';
2
+ export { PropertyBar } from './PropertyBar.tsx';
3
+ export type { PropertyPanelProps } from './PropertyPanel.tsx';
4
+ export { PropertyPanel } from './PropertyPanel.tsx';
5
+ export type { PropertyRowsProps } from './PropertyRows.tsx';
6
+ export { PropertyRows } from './PropertyRows.tsx';
7
+ export type { RiskFindingsProps } from './RiskFindings.tsx';
8
+ export { RiskFindings } from './RiskFindings.tsx';
9
+ export type { RiskPanelProps } from './RiskPanel.tsx';
10
+ export { RiskPanel } from './RiskPanel.tsx';
11
+ export type { RiskSquareProps } from './RiskSquare.tsx';
12
+ export { RiskSquare } from './RiskSquare.tsx';
13
+ export type {
14
+ UsePredictionsOptions,
15
+ UsePredictionsResult,
16
+ } from './usePredictions.ts';
17
+ export { usePredictions } from './usePredictions.ts';