react-cheminfo 0.66.0 → 0.67.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 (291) hide show
  1. package/README.md +22 -11
  2. package/lib/download/ui/FigureDownloadPanel.d.ts +7 -1
  3. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  4. package/lib/download/ui/FigureDownloadPanel.js +2 -2
  5. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  6. package/lib/ecosystem/core/sites.js +3 -3
  7. package/lib/ecosystem/core/sites.js.map +1 -1
  8. package/lib/ecosystem/core/types.d.ts +1 -1
  9. package/lib/ecosystem/core/types.d.ts.map +1 -1
  10. package/lib/ecosystem/ui/glyphs.js +1 -1
  11. package/lib/ecosystem/ui/glyphs.js.map +1 -1
  12. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  13. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  14. package/lib/i18n/core/messageCatalog.d.ts +2 -2
  15. package/lib/i18n/vite/localeCatalog.d.ts +1 -1
  16. package/lib/ir/core/index.d.ts +2 -2
  17. package/lib/ir/core/index.d.ts.map +1 -1
  18. package/lib/ir/core/index.js.map +1 -1
  19. package/lib/ir/core/irEditorApi.d.ts +12 -0
  20. package/lib/ir/core/irEditorApi.d.ts.map +1 -1
  21. package/lib/ir/core/irReducer.d.ts +2 -2
  22. package/lib/ir/core/irReducer.d.ts.map +1 -1
  23. package/lib/ir/core/irSidePanels.d.ts +7 -1
  24. package/lib/ir/core/irSidePanels.d.ts.map +1 -1
  25. package/lib/ir/core/irState.d.ts +8 -5
  26. package/lib/ir/core/irState.d.ts.map +1 -1
  27. package/lib/ir/core/irState.js.map +1 -1
  28. package/lib/ir/ui/IrCanvas.d.ts +7 -0
  29. package/lib/ir/ui/IrCanvas.d.ts.map +1 -1
  30. package/lib/ir/ui/IrCanvas.js +8 -3
  31. package/lib/ir/ui/IrCanvas.js.map +1 -1
  32. package/lib/ir/ui/IrChart.d.ts.map +1 -1
  33. package/lib/ir/ui/IrChart.js +5 -1
  34. package/lib/ir/ui/IrChart.js.map +1 -1
  35. package/lib/ir/ui/IrEditor.d.ts +22 -4
  36. package/lib/ir/ui/IrEditor.d.ts.map +1 -1
  37. package/lib/ir/ui/IrEditor.js.map +1 -1
  38. package/lib/ir/ui/IrShell.d.ts +9 -1
  39. package/lib/ir/ui/IrShell.d.ts.map +1 -1
  40. package/lib/ir/ui/IrShell.js +4 -19
  41. package/lib/ir/ui/IrShell.js.map +1 -1
  42. package/lib/ir/ui/IrSidePanel.d.ts +11 -0
  43. package/lib/ir/ui/IrSidePanel.d.ts.map +1 -1
  44. package/lib/ir/ui/IrSidePanel.js +12 -3
  45. package/lib/ir/ui/IrSidePanel.js.map +1 -1
  46. package/lib/ir/ui/RamanEditor.d.ts +22 -4
  47. package/lib/ir/ui/RamanEditor.d.ts.map +1 -1
  48. package/lib/ir/ui/RamanEditor.js.map +1 -1
  49. package/lib/ir/ui/VibrationalEditor.d.ts +18 -4
  50. package/lib/ir/ui/VibrationalEditor.d.ts.map +1 -1
  51. package/lib/ir/ui/VibrationalEditor.js +4 -2
  52. package/lib/ir/ui/VibrationalEditor.js.map +1 -1
  53. package/lib/ir/ui/index.d.ts +1 -0
  54. package/lib/ir/ui/index.d.ts.map +1 -1
  55. package/lib/ir/ui/index.js.map +1 -1
  56. package/lib/ir/ui/irActions.d.ts +3 -3
  57. package/lib/ir/ui/irActions.d.ts.map +1 -1
  58. package/lib/ir/ui/irChartProps.d.ts +7 -0
  59. package/lib/ir/ui/irChartProps.d.ts.map +1 -1
  60. package/lib/ir/ui/irHostPanels.d.ts +53 -0
  61. package/lib/ir/ui/irHostPanels.d.ts.map +1 -0
  62. package/lib/ir/ui/irHostPanels.js +41 -0
  63. package/lib/ir/ui/irHostPanels.js.map +1 -0
  64. package/lib/ir/ui/useIrSide.d.ts +27 -0
  65. package/lib/ir/ui/useIrSide.d.ts.map +1 -0
  66. package/lib/ir/ui/useIrSide.js +42 -0
  67. package/lib/ir/ui/useIrSide.js.map +1 -0
  68. package/lib/ir/ui/useIrZoom.d.ts +8 -0
  69. package/lib/ir/ui/useIrZoom.d.ts.map +1 -1
  70. package/lib/ir/ui/useIrZoom.js +2 -1
  71. package/lib/ir/ui/useIrZoom.js.map +1 -1
  72. package/lib/locales/de.json +9 -1
  73. package/lib/locales/en.json +9 -1
  74. package/lib/locales/es.json +9 -1
  75. package/lib/locales/fr.json +9 -1
  76. package/lib/locales/it.json +9 -1
  77. package/lib/molecule3d/core/animatedPng.d.ts +25 -0
  78. package/lib/molecule3d/core/animatedPng.d.ts.map +1 -0
  79. package/lib/molecule3d/core/animatedPng.js +59 -0
  80. package/lib/molecule3d/core/animatedPng.js.map +1 -0
  81. package/lib/molecule3d/core/file.d.ts +24 -0
  82. package/lib/molecule3d/core/file.d.ts.map +1 -0
  83. package/lib/molecule3d/core/file.js +2 -0
  84. package/lib/molecule3d/core/file.js.map +1 -0
  85. package/lib/molecule3d/core/index.d.ts +4 -1
  86. package/lib/molecule3d/core/index.d.ts.map +1 -1
  87. package/lib/molecule3d/core/index.js +1 -0
  88. package/lib/molecule3d/core/index.js.map +1 -1
  89. package/lib/molecule3d/core/settings.d.ts +0 -7
  90. package/lib/molecule3d/core/settings.d.ts.map +1 -1
  91. package/lib/molecule3d/core/settings.js.map +1 -1
  92. package/lib/molecule3d/ui/Molecule3DExport.d.ts +10 -2
  93. package/lib/molecule3d/ui/Molecule3DExport.d.ts.map +1 -1
  94. package/lib/molecule3d/ui/Molecule3DExport.js +15 -2
  95. package/lib/molecule3d/ui/Molecule3DExport.js.map +1 -1
  96. package/lib/molecule3d/ui/Molecule3DToolbar.js +9 -2
  97. package/lib/molecule3d/ui/Molecule3DToolbar.js.map +1 -1
  98. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  99. package/lib/molecule3d/ui/MoleculeCanvas3D.js +23 -41
  100. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  101. package/lib/molecule3d/ui/drawScene.d.ts +2 -1
  102. package/lib/molecule3d/ui/drawScene.d.ts.map +1 -1
  103. package/lib/molecule3d/ui/drawScene.js.map +1 -1
  104. package/lib/molecule3d/ui/exportMoleculeImage.d.ts +15 -1
  105. package/lib/molecule3d/ui/exportMoleculeImage.d.ts.map +1 -1
  106. package/lib/molecule3d/ui/exportMoleculeImage.js +14 -2
  107. package/lib/molecule3d/ui/exportMoleculeImage.js.map +1 -1
  108. package/lib/molecule3d/ui/moleculeFrames.d.ts +47 -0
  109. package/lib/molecule3d/ui/moleculeFrames.d.ts.map +1 -0
  110. package/lib/molecule3d/ui/moleculeFrames.js +65 -0
  111. package/lib/molecule3d/ui/moleculeFrames.js.map +1 -0
  112. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts +14 -1
  113. package/lib/molecule3d/ui/moleculeViewer3DProps.d.ts.map +1 -1
  114. package/lib/molecule3d/ui/renderMolecule.d.ts +3 -3
  115. package/lib/molecule3d/ui/renderMolecule.d.ts.map +1 -1
  116. package/lib/molecule3d/ui/renderMolecule.js +2 -1
  117. package/lib/molecule3d/ui/renderMolecule.js.map +1 -1
  118. package/lib/molecule3d/ui/sceneDrawer.d.ts +2 -1
  119. package/lib/molecule3d/ui/sceneDrawer.d.ts.map +1 -1
  120. package/lib/molecule3d/ui/sceneDrawer.js +9 -1
  121. package/lib/molecule3d/ui/sceneDrawer.js.map +1 -1
  122. package/lib/molecule3d/ui/useImageExport.d.ts +8 -3
  123. package/lib/molecule3d/ui/useImageExport.d.ts.map +1 -1
  124. package/lib/molecule3d/ui/useImageExport.js +13 -4
  125. package/lib/molecule3d/ui/useImageExport.js.map +1 -1
  126. package/lib/molecule3d/ui/useMoleculeScene.d.ts +2 -1
  127. package/lib/molecule3d/ui/useMoleculeScene.d.ts.map +1 -1
  128. package/lib/molecule3d/ui/useMoleculeScene.js.map +1 -1
  129. package/lib/molecule3d/ui/useMoleculeViewer.d.ts +16 -0
  130. package/lib/molecule3d/ui/useMoleculeViewer.d.ts.map +1 -0
  131. package/lib/molecule3d/ui/useMoleculeViewer.js +37 -0
  132. package/lib/molecule3d/ui/useMoleculeViewer.js.map +1 -0
  133. package/lib/molecule3d/ui/usePolarSurfaceArea.d.ts +3 -3
  134. package/lib/molecule3d/ui/usePolarSurfaceArea.d.ts.map +1 -1
  135. package/lib/molecule3d/ui/usePolarSurfaceArea.js +4 -3
  136. package/lib/molecule3d/ui/usePolarSurfaceArea.js.map +1 -1
  137. package/lib/molecule3d/ui/viewer.d.ts +4 -1
  138. package/lib/molecule3d/ui/viewer.d.ts.map +1 -1
  139. package/lib/molecule3d/ui/viewer.js +21 -19
  140. package/lib/molecule3d/ui/viewer.js.map +1 -1
  141. package/lib/molecule3d/ui/viewerTypes.d.ts +6 -0
  142. package/lib/molecule3d/ui/viewerTypes.d.ts.map +1 -1
  143. package/lib/molstar/core/captureScene.d.ts +19 -1
  144. package/lib/molstar/core/captureScene.d.ts.map +1 -1
  145. package/lib/molstar/core/captureScene.js +57 -2
  146. package/lib/molstar/core/captureScene.js.map +1 -1
  147. package/lib/molstar/core/index.d.ts +5 -2
  148. package/lib/molstar/core/index.d.ts.map +1 -1
  149. package/lib/molstar/core/index.js +4 -2
  150. package/lib/molstar/core/index.js.map +1 -1
  151. package/lib/molstar/core/trajectory.d.ts +56 -0
  152. package/lib/molstar/core/trajectory.d.ts.map +1 -0
  153. package/lib/molstar/core/trajectory.js +96 -0
  154. package/lib/molstar/core/trajectory.js.map +1 -0
  155. package/lib/panel/ui/PanelRail.d.ts.map +1 -1
  156. package/lib/panel/ui/PanelRail.js +1 -1
  157. package/lib/panel/ui/PanelRail.js.map +1 -1
  158. package/lib/raman.d.ts +2 -1
  159. package/lib/raman.d.ts.map +1 -1
  160. package/lib/raman.js.map +1 -1
  161. package/lib/router/core/basePath.d.ts +2 -2
  162. package/lib/router/core/basePath.js +2 -2
  163. package/lib/router/core/siteAddresses.d.ts +1 -1
  164. package/lib/router/core/siteAddresses.js +1 -1
  165. package/lib/seo/core/siteFiles.js +1 -1
  166. package/lib/seo/core/siteFiles.js.map +1 -1
  167. package/lib/server/answerAddresses.d.ts +3 -3
  168. package/lib/server/answerAddresses.js +3 -3
  169. package/lib/structure/core/index.d.ts +2 -0
  170. package/lib/structure/core/index.d.ts.map +1 -1
  171. package/lib/structure/core/index.js +1 -0
  172. package/lib/structure/core/index.js.map +1 -1
  173. package/lib/structure/core/structureTransfer.d.ts +29 -0
  174. package/lib/structure/core/structureTransfer.d.ts.map +1 -0
  175. package/lib/structure/core/structureTransfer.js +26 -0
  176. package/lib/structure/core/structureTransfer.js.map +1 -0
  177. package/lib/structure/ui/EditorImportButton.d.ts +20 -0
  178. package/lib/structure/ui/EditorImportButton.d.ts.map +1 -0
  179. package/lib/structure/ui/EditorImportButton.js +24 -0
  180. package/lib/structure/ui/EditorImportButton.js.map +1 -0
  181. package/lib/structure/ui/EditorImportProblem.d.ts +17 -0
  182. package/lib/structure/ui/EditorImportProblem.d.ts.map +1 -0
  183. package/lib/structure/ui/EditorImportProblem.js +32 -0
  184. package/lib/structure/ui/EditorImportProblem.js.map +1 -0
  185. package/lib/structure/ui/StructureDrop.d.ts +39 -0
  186. package/lib/structure/ui/StructureDrop.d.ts.map +1 -0
  187. package/lib/structure/ui/StructureDrop.js +19 -0
  188. package/lib/structure/ui/StructureDrop.js.map +1 -0
  189. package/lib/structure/ui/StructureDropOverlay.d.ts +16 -0
  190. package/lib/structure/ui/StructureDropOverlay.d.ts.map +1 -0
  191. package/lib/structure/ui/StructureDropOverlay.js +29 -0
  192. package/lib/structure/ui/StructureDropOverlay.js.map +1 -0
  193. package/lib/structure/ui/StructureEditor.d.ts +3 -80
  194. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  195. package/lib/structure/ui/StructureEditor.js +21 -33
  196. package/lib/structure/ui/StructureEditor.js.map +1 -1
  197. package/lib/structure/ui/importedStructure.d.ts +25 -0
  198. package/lib/structure/ui/importedStructure.d.ts.map +1 -0
  199. package/lib/structure/ui/importedStructure.js +74 -0
  200. package/lib/structure/ui/importedStructure.js.map +1 -0
  201. package/lib/structure/ui/index.d.ts +2 -0
  202. package/lib/structure/ui/index.d.ts.map +1 -1
  203. package/lib/structure/ui/index.js +1 -0
  204. package/lib/structure/ui/index.js.map +1 -1
  205. package/lib/structure/ui/structureEditorProps.d.ts +98 -0
  206. package/lib/structure/ui/structureEditorProps.d.ts.map +1 -0
  207. package/lib/structure/ui/structureEditorProps.js +2 -0
  208. package/lib/structure/ui/structureEditorProps.js.map +1 -0
  209. package/lib/structure/ui/useDebouncedChange.d.ts +16 -0
  210. package/lib/structure/ui/useDebouncedChange.d.ts.map +1 -0
  211. package/lib/structure/ui/useDebouncedChange.js +30 -0
  212. package/lib/structure/ui/useDebouncedChange.js.map +1 -0
  213. package/lib/structure/ui/useStructureDrop.d.ts +30 -0
  214. package/lib/structure/ui/useStructureDrop.d.ts.map +1 -0
  215. package/lib/structure/ui/useStructureDrop.js +49 -0
  216. package/lib/structure/ui/useStructureDrop.js.map +1 -0
  217. package/lib/structure/ui/useStructureImport.d.ts +45 -0
  218. package/lib/structure/ui/useStructureImport.d.ts.map +1 -0
  219. package/lib/structure/ui/useStructureImport.js +62 -0
  220. package/lib/structure/ui/useStructureImport.js.map +1 -0
  221. package/package.json +4 -1
  222. package/src/download/ui/FigureDownloadPanel.tsx +9 -2
  223. package/src/ecosystem/core/sites.ts +3 -3
  224. package/src/ecosystem/core/types.ts +1 -1
  225. package/src/ecosystem/ui/glyphs.tsx +1 -1
  226. package/src/i18n/core/messageCatalog.ts +2 -2
  227. package/src/i18n/vite/localeCatalog.ts +1 -1
  228. package/src/ir/core/index.ts +6 -2
  229. package/src/ir/core/irEditorApi.ts +13 -0
  230. package/src/ir/core/irReducer.ts +2 -2
  231. package/src/ir/core/irSidePanels.ts +8 -1
  232. package/src/ir/core/irState.ts +8 -5
  233. package/src/ir/ui/IrCanvas.tsx +27 -2
  234. package/src/ir/ui/IrChart.tsx +11 -0
  235. package/src/ir/ui/IrEditor.tsx +22 -4
  236. package/src/ir/ui/IrShell.tsx +21 -22
  237. package/src/ir/ui/IrSidePanel.tsx +36 -10
  238. package/src/ir/ui/RamanEditor.tsx +22 -4
  239. package/src/ir/ui/VibrationalEditor.tsx +24 -5
  240. package/src/ir/ui/index.ts +1 -0
  241. package/src/ir/ui/irActions.ts +3 -3
  242. package/src/ir/ui/irChartProps.ts +7 -0
  243. package/src/ir/ui/irHostPanels.ts +76 -0
  244. package/src/ir/ui/useIrSide.ts +60 -0
  245. package/src/ir/ui/useIrZoom.ts +10 -0
  246. package/src/locales/de.json +9 -1
  247. package/src/locales/en.json +9 -1
  248. package/src/locales/es.json +9 -1
  249. package/src/locales/fr.json +9 -1
  250. package/src/locales/it.json +9 -1
  251. package/src/molecule3d/core/animatedPng.ts +79 -0
  252. package/src/molecule3d/core/file.ts +23 -0
  253. package/src/molecule3d/core/index.ts +3 -1
  254. package/src/molecule3d/core/settings.ts +0 -8
  255. package/src/molecule3d/ui/Molecule3DExport.tsx +43 -5
  256. package/src/molecule3d/ui/Molecule3DToolbar.tsx +9 -2
  257. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +24 -38
  258. package/src/molecule3d/ui/drawScene.ts +2 -1
  259. package/src/molecule3d/ui/exportMoleculeImage.ts +28 -3
  260. package/src/molecule3d/ui/moleculeFrames.ts +88 -0
  261. package/src/molecule3d/ui/moleculeViewer3DProps.ts +14 -5
  262. package/src/molecule3d/ui/renderMolecule.ts +5 -3
  263. package/src/molecule3d/ui/sceneDrawer.ts +14 -2
  264. package/src/molecule3d/ui/useImageExport.ts +22 -5
  265. package/src/molecule3d/ui/useMoleculeScene.ts +2 -1
  266. package/src/molecule3d/ui/useMoleculeViewer.ts +46 -0
  267. package/src/molecule3d/ui/usePolarSurfaceArea.ts +6 -4
  268. package/src/molecule3d/ui/viewer.ts +34 -27
  269. package/src/molecule3d/ui/viewerTypes.ts +6 -0
  270. package/src/molstar/core/captureScene.ts +85 -2
  271. package/src/molstar/core/index.ts +13 -2
  272. package/src/molstar/core/trajectory.ts +117 -0
  273. package/src/panel/ui/PanelRail.tsx +3 -0
  274. package/src/raman.ts +2 -1
  275. package/src/router/core/basePath.ts +2 -2
  276. package/src/router/core/siteAddresses.ts +1 -1
  277. package/src/seo/core/siteFiles.ts +1 -1
  278. package/src/server/answerAddresses.ts +3 -3
  279. package/src/structure/core/index.ts +8 -0
  280. package/src/structure/core/structureTransfer.ts +37 -0
  281. package/src/structure/ui/EditorImportButton.tsx +59 -0
  282. package/src/structure/ui/EditorImportProblem.tsx +63 -0
  283. package/src/structure/ui/StructureDrop.tsx +66 -0
  284. package/src/structure/ui/StructureDropOverlay.tsx +50 -0
  285. package/src/structure/ui/StructureEditor.tsx +49 -134
  286. package/src/structure/ui/importedStructure.ts +83 -0
  287. package/src/structure/ui/index.ts +2 -0
  288. package/src/structure/ui/structureEditorProps.ts +103 -0
  289. package/src/structure/ui/useDebouncedChange.ts +41 -0
  290. package/src/structure/ui/useStructureDrop.ts +76 -0
  291. package/src/structure/ui/useStructureImport.ts +122 -0
@@ -0,0 +1,98 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { CanvasEditorInputFormat } from 'react-ocl';
3
+ import type { StructureTransfer } from '../core/structureTransfer.ts';
4
+ import type { StructureEditorChange, StructureEditorMode } from './editorChange.ts';
5
+ /** What `StructureEditor` needs. */
6
+ export interface StructureEditorProps {
7
+ /**
8
+ * Called after every edit, once the drawing has been still for `debounce`
9
+ * milliseconds, with every notation read out of the editor.
10
+ */
11
+ onChange: (change: StructureEditorChange) => void;
12
+ /**
13
+ * Draw a query fragment rather than a whole structure, which is what a
14
+ * substructure filter needs.
15
+ * @default false
16
+ */
17
+ fragment?: boolean;
18
+ /**
19
+ * How `value` is written.
20
+ * @default 'idcode'
21
+ */
22
+ inputFormat?: CanvasEditorInputFormat;
23
+ /**
24
+ * What the canvas holds. Read once, when the editor appears and again on
25
+ * every change of `revision`: the editor is uncontrolled, so feeding the
26
+ * drawing back into it would replace the structure and reset every
27
+ * coordinate under the pen.
28
+ * @default ''
29
+ */
30
+ value?: string;
31
+ /**
32
+ * Bumped by the caller to load `value` into the canvas again, which is what
33
+ * an example, a share link or a Clear button does. Changing it discards
34
+ * whatever was being drawn.
35
+ * @default 0
36
+ */
37
+ revision?: number;
38
+ /**
39
+ * How long the drawing has to be still before `onChange` is called, in
40
+ * milliseconds. Long enough that drawing a ring does not publish six
41
+ * structures; `0` reports every stroke.
42
+ * @default 300
43
+ */
44
+ debounce?: number;
45
+ /**
46
+ * Smallest height of the drawing area, in pixels. Raised to whatever the
47
+ * toolbar needs, which is usually more.
48
+ * @default 320
49
+ */
50
+ minHeight?: number;
51
+ /**
52
+ * Whether the editor draws one structure or a reaction. A reaction canvas
53
+ * has its own toolbar and its own arrow.
54
+ * @default 'molecule'
55
+ */
56
+ mode?: StructureEditorMode;
57
+ /**
58
+ * Explain each toolbar button in a tooltip, and put a button in the corner
59
+ * that opens a guide to the mouse and the keyboard, which F1 opens too.
60
+ * @default true
61
+ */
62
+ help?: boolean;
63
+ /**
64
+ * Put a button in the corner that opens every notation of the drawing — its
65
+ * SMILES, its molfiles, its canonical identifiers — and the picture of it,
66
+ * ready to copy or to save. A reaction has none of those, so it is never
67
+ * offered one.
68
+ * @default true
69
+ */
70
+ exportable?: boolean;
71
+ /**
72
+ * Take a structure dropped on the canvas — a molfile, an SDF, a SMILES or
73
+ * an idCode, as a file or as text dragged from another page — and put a
74
+ * button in the corner that opens one from disk. A reaction canvas takes
75
+ * none.
76
+ * @default true
77
+ */
78
+ importable?: boolean;
79
+ /**
80
+ * Take what is dropped or opened yourself instead of letting the editor read
81
+ * it, for a page that reads more than the canvas does — an XYZ, a PDB, a 3D
82
+ * geometry the canvas would flatten. The page then loads the structure back
83
+ * through `value` and `revision`, like any other.
84
+ * @default undefined
85
+ */
86
+ onImport?: (transfer: StructureTransfer) => void;
87
+ /**
88
+ * Class the container carries, so a site can reach it from its stylesheet.
89
+ * @default undefined
90
+ */
91
+ className?: string;
92
+ /**
93
+ * Extra style for the container, merged over the packaged one.
94
+ * @default undefined
95
+ */
96
+ style?: CSSProperties;
97
+ }
98
+ //# sourceMappingURL=structureEditorProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structureEditorProps.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/structureEditorProps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAE3B,oCAAoC;AACpC,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAC;IACtC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=structureEditorProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structureEditorProps.js","sourceRoot":"","sources":["../../../src/structure/ui/structureEditorProps.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { StructureEditorChange } from './editorChange.ts';
2
+ /**
3
+ * Report the last edit of a burst rather than every one of them.
4
+ *
5
+ * The editor's own event is read out before the wait starts, so what arrives
6
+ * late is a plain object rather than a handle on an editor that has moved on.
7
+ * An editor removed mid-burst — a tab switched, a card folded — still reports
8
+ * its last edit, which would otherwise be lost with the timer.
9
+ * @param onChange - What the caller wants told.
10
+ * @param delay - How long the drawing has to be still, in milliseconds.
11
+ * @param resetKey - Dropped edits: a burst still waiting when the caller
12
+ * replaces the structure describes a canvas that no longer exists.
13
+ * @returns The handler to give the canvas.
14
+ */
15
+ export declare function useDebouncedChange(onChange: (change: StructureEditorChange) => void, delay: number, resetKey: number): (change: StructureEditorChange) => void;
16
+ //# sourceMappingURL=useDebouncedChange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebouncedChange.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/useDebouncedChange.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAE/D;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,EACjD,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,GACf,CAAC,MAAM,EAAE,qBAAqB,KAAK,IAAI,CAiBzC"}
@@ -0,0 +1,30 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { createPendingCall } from "../core/pendingCall.js";
3
+ /**
4
+ * Report the last edit of a burst rather than every one of them.
5
+ *
6
+ * The editor's own event is read out before the wait starts, so what arrives
7
+ * late is a plain object rather than a handle on an editor that has moved on.
8
+ * An editor removed mid-burst — a tab switched, a card folded — still reports
9
+ * its last edit, which would otherwise be lost with the timer.
10
+ * @param onChange - What the caller wants told.
11
+ * @param delay - How long the drawing has to be still, in milliseconds.
12
+ * @param resetKey - Dropped edits: a burst still waiting when the caller
13
+ * replaces the structure describes a canvas that no longer exists.
14
+ * @returns The handler to give the canvas.
15
+ */
16
+ export function useDebouncedChange(onChange, delay, resetKey) {
17
+ const [pending] = useState((createPendingCall));
18
+ const onChangeRef = useRef(onChange);
19
+ useEffect(() => {
20
+ onChangeRef.current = onChange;
21
+ });
22
+ useEffect(() => {
23
+ pending.drop();
24
+ }, [pending, resetKey]);
25
+ useEffect(() => () => pending.flush(), [pending]);
26
+ return useCallback((change) => {
27
+ pending.push(change, delay, (value) => onChangeRef.current(value));
28
+ }, [pending, delay]);
29
+ }
30
+ //# sourceMappingURL=useDebouncedChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebouncedChange.js","sourceRoot":"","sources":["../../../src/structure/ui/useDebouncedChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAI3D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAiD,EACjD,KAAa,EACb,QAAgB;IAEhB,MAAM,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAA,iBAAwC,CAAA,CAAC,CAAC;IACrE,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IACrC,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC,OAAO,GAAG,QAAQ,CAAC;IACjC,CAAC,CAAC,CAAC;IACH,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxB,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAElD,OAAO,WAAW,CAChB,CAAC,MAA6B,EAAE,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;IACrE,CAAC,EACD,CAAC,OAAO,EAAE,KAAK,CAAC,CACjB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { DragEvent } from 'react';
2
+ import type { StructureTransfer } from '../core/structureTransfer.ts';
3
+ /** The drag handlers of one element. */
4
+ export interface DropHandlers {
5
+ onDragEnter?: (event: DragEvent<HTMLElement>) => void;
6
+ onDragOver?: (event: DragEvent<HTMLElement>) => void;
7
+ onDragLeave?: (event: DragEvent<HTMLElement>) => void;
8
+ onDrop?: (event: DragEvent<HTMLElement>) => void;
9
+ }
10
+ /** A drop target, in two parts: the element and the overlay it raises. */
11
+ export interface StructureDropTarget {
12
+ /** Whether a file or text is being dragged over the target. */
13
+ over: boolean;
14
+ /** Put on the element that takes the drop. */
15
+ targetProps: DropHandlers;
16
+ /**
17
+ * Put on the overlay drawn while `over`. It covers the target and takes
18
+ * every drag event from then on, so moving across the canvas and the buttons
19
+ * underneath never reads as leaving, and leaving the overlay is leaving.
20
+ */
21
+ overlayProps: DropHandlers;
22
+ }
23
+ /**
24
+ * Take a file or text dropped on an element.
25
+ * @param onDrop - Where the drop goes; `undefined` takes none.
26
+ * @returns Whether a drag is over the element, and the handlers to put on it
27
+ * and on its overlay.
28
+ */
29
+ export declare function useStructureDrop(onDrop: ((transfer: StructureTransfer) => void) | undefined): StructureDropTarget;
30
+ //# sourceMappingURL=useStructureDrop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStructureDrop.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/useStructureDrop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAMtE,wCAAwC;AACxC,MAAM,WAAW,YAAY;IAC3B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACtD,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACrD,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACtD,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;CAClD;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IAClC,+DAA+D;IAC/D,IAAI,EAAE,OAAO,CAAC;IACd,8CAA8C;IAC9C,WAAW,EAAE,YAAY,CAAC;IAC1B;;;;OAIG;IACH,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC,GAAG,SAAS,GAC1D,mBAAmB,CAoCrB"}
@@ -0,0 +1,49 @@
1
+ import { useMemo, useState } from 'react';
2
+ import { carriesStructure, readStructureTransfer, } from "../core/structureTransfer.js";
3
+ /**
4
+ * Take a file or text dropped on an element.
5
+ * @param onDrop - Where the drop goes; `undefined` takes none.
6
+ * @returns Whether a drag is over the element, and the handlers to put on it
7
+ * and on its overlay.
8
+ */
9
+ export function useStructureDrop(onDrop) {
10
+ const [over, setOver] = useState(false);
11
+ return useMemo(() => {
12
+ if (onDrop === undefined) {
13
+ return { over: false, targetProps: {}, overlayProps: {} };
14
+ }
15
+ const accept = (event) => {
16
+ if (!carriesStructure(event.dataTransfer.types))
17
+ return false;
18
+ event.preventDefault();
19
+ event.dataTransfer.dropEffect = 'copy';
20
+ return true;
21
+ };
22
+ return {
23
+ over,
24
+ targetProps: {
25
+ onDragEnter: (event) => {
26
+ if (accept(event))
27
+ setOver(true);
28
+ },
29
+ onDragOver: accept,
30
+ },
31
+ overlayProps: {
32
+ onDragOver: accept,
33
+ onDragLeave: (event) => {
34
+ if (event.target === event.currentTarget)
35
+ setOver(false);
36
+ },
37
+ onDrop: (event) => {
38
+ setOver(false);
39
+ const transfer = readStructureTransfer(event.dataTransfer);
40
+ if (transfer === null)
41
+ return;
42
+ event.preventDefault();
43
+ onDrop(transfer);
44
+ },
45
+ },
46
+ };
47
+ }, [onDrop, over]);
48
+ }
49
+ //# sourceMappingURL=useStructureDrop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStructureDrop.js","sourceRoot":"","sources":["../../../src/structure/ui/useStructureDrop.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EACL,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,8BAA8B,CAAC;AAwBtC;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAA2D;IAE3D,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;QAC5D,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,KAA6B,EAAW,EAAE;YACxD,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC9D,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,KAAK,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC;YACvC,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;QACF,OAAO;YACL,IAAI;YACJ,WAAW,EAAE;gBACX,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;oBACrB,IAAI,MAAM,CAAC,KAAK,CAAC;wBAAE,OAAO,CAAC,IAAI,CAAC,CAAC;gBACnC,CAAC;gBACD,UAAU,EAAE,MAAM;aACnB;YACD,YAAY,EAAE;gBACZ,UAAU,EAAE,MAAM;gBAClB,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;oBACrB,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,aAAa;wBAAE,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC3D,CAAC;gBACD,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;oBAChB,OAAO,CAAC,KAAK,CAAC,CAAC;oBACf,MAAM,QAAQ,GAAG,qBAAqB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;oBAC3D,IAAI,QAAQ,KAAK,IAAI;wBAAE,OAAO;oBAC9B,KAAK,CAAC,cAAc,EAAE,CAAC;oBACvB,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACnB,CAAC;aACF;SACF,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { StructureTransfer } from '../core/structureTransfer.ts';
2
+ import type { StructureEditorMoleculeChange } from './editorChange.ts';
3
+ /** What {@link useStructureImport} needs. */
4
+ export interface StructureImportOptions {
5
+ /** Bumped by the caller to load its own value, which drops any import. */
6
+ revision: number;
7
+ /** Whether the editor draws a query fragment. */
8
+ fragment: boolean;
9
+ /** The caller's own reader, which then takes every drop instead. */
10
+ onImport: ((transfer: StructureTransfer) => void) | undefined;
11
+ /** Where a structure the editor read goes: the path an edit takes. */
12
+ onRead: (change: StructureEditorMoleculeChange) => void;
13
+ }
14
+ /** Why the last drop loaded nothing. */
15
+ export interface StructureImportProblem {
16
+ /** The file that was read, `null` for dragged text. */
17
+ file: string | null;
18
+ }
19
+ /** The editor's imports, as the canvas and its corner need them. */
20
+ export interface StructureImport {
21
+ /**
22
+ * The idCode the canvas loads instead of the caller's value, `null` while it
23
+ * shows that value.
24
+ */
25
+ idCode: string | null;
26
+ /** The canvas's key: a new one per import, which loads it. */
27
+ canvasKey: string;
28
+ /** Read a drop or a chosen file. */
29
+ load: (transfer: StructureTransfer) => void;
30
+ /** Why the last drop loaded nothing, `null` when it did. */
31
+ problem: StructureImportProblem | null;
32
+ /** Forget the problem. */
33
+ dismiss: () => void;
34
+ }
35
+ /**
36
+ * Load what is dropped on the editor, or opened from disk, into its canvas.
37
+ *
38
+ * The canvas is uncontrolled, so a dropped structure — one the editor never
39
+ * produced — remounts it with a new key, and is then reported like an edit.
40
+ * A drop overtaken by a later one is dropped rather than applied late.
41
+ * @param options - See {@link StructureImportOptions}.
42
+ * @returns See {@link StructureImport}.
43
+ */
44
+ export declare function useStructureImport(options: StructureImportOptions): StructureImport;
45
+ //# sourceMappingURL=useStructureImport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStructureImport.d.ts","sourceRoot":"","sources":["../../../src/structure/ui/useStructureImport.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAEvE,6CAA6C;AAC7C,MAAM,WAAW,sBAAsB;IACrC,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,QAAQ,EAAE,OAAO,CAAC;IAClB,oEAAoE;IACpE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC9D,sEAAsE;IACtE,MAAM,EAAE,CAAC,MAAM,EAAE,6BAA6B,KAAK,IAAI,CAAC;CACzD;AAED,wCAAwC;AACxC,MAAM,WAAW,sBAAsB;IACrC,uDAAuD;IACvD,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,oEAAoE;AACpE,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,IAAI,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IAC5C,4DAA4D;IAC5D,OAAO,EAAE,sBAAsB,GAAG,IAAI,CAAC;IACvC,0BAA0B;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AASD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CAyCjB"}
@@ -0,0 +1,62 @@
1
+ import { useCallback, useRef, useState } from 'react';
2
+ /**
3
+ * Load what is dropped on the editor, or opened from disk, into its canvas.
4
+ *
5
+ * The canvas is uncontrolled, so a dropped structure — one the editor never
6
+ * produced — remounts it with a new key, and is then reported like an edit.
7
+ * A drop overtaken by a later one is dropped rather than applied late.
8
+ * @param options - See {@link StructureImportOptions}.
9
+ * @returns See {@link StructureImport}.
10
+ */
11
+ export function useStructureImport(options) {
12
+ const { revision, fragment, onImport, onRead } = options;
13
+ const [imported, setImported] = useState(null);
14
+ const [problem, setProblem] = useState(null);
15
+ const token = useRef(0);
16
+ const load = useCallback((transfer) => {
17
+ setProblem(null);
18
+ if (onImport !== undefined) {
19
+ onImport(transfer);
20
+ return;
21
+ }
22
+ const current = ++token.current;
23
+ void readTransfer(transfer, fragment).then(({ file, change }) => {
24
+ if (current !== token.current)
25
+ return;
26
+ if (change === null) {
27
+ setProblem({ file });
28
+ return;
29
+ }
30
+ setImported((previous) => ({
31
+ revision,
32
+ count: previous?.revision === revision ? previous.count + 1 : 1,
33
+ idCode: change.idCode,
34
+ }));
35
+ onRead(change);
36
+ });
37
+ }, [fragment, onImport, onRead, revision]);
38
+ const dismiss = useCallback(() => setProblem(null), []);
39
+ const current = imported?.revision === revision ? imported : null;
40
+ return {
41
+ idCode: current?.idCode ?? null,
42
+ canvasKey: `${revision}.${current?.count ?? 0}`,
43
+ load,
44
+ problem,
45
+ dismiss,
46
+ };
47
+ }
48
+ async function readTransfer(transfer, fragment) {
49
+ const file = transfer.kind === 'files' ? transfer.files[0] : undefined;
50
+ try {
51
+ const text = transfer.kind === 'text' ? transfer.text : ((await file?.text()) ?? '');
52
+ const { readImportedStructure } = await import("./importedStructure.js");
53
+ return {
54
+ file: file?.name ?? null,
55
+ change: readImportedStructure(text, fragment),
56
+ };
57
+ }
58
+ catch {
59
+ return { file: file?.name ?? null, change: null };
60
+ }
61
+ }
62
+ //# sourceMappingURL=useStructureImport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStructureImport.js","sourceRoot":"","sources":["../../../src/structure/ui/useStructureImport.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-cheminfo",
3
- "version": "0.66.0",
3
+ "version": "0.67.0",
4
4
  "license": "MIT",
5
5
  "description": "React components, hooks and framework-free helpers shared by the cheminfo sites: site chrome, citations, sharing, routing, pedagogy, charts, and the structure, orbital and 3D molecule viewers",
6
6
  "author": "Luc Patiny",
@@ -71,6 +71,7 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "@formatjs/icu-messageformat-parser": "^3.5.20",
74
+ "@pdf-lib/upng": "^1.0.1",
74
75
  "@tanstack/react-virtual": "^3.14.13",
75
76
  "ajv": "^8.20.0",
76
77
  "cheminfo-font": "^1.28.0",
@@ -97,6 +98,7 @@
97
98
  "@playwright/test": "^1.62.1",
98
99
  "@storybook/addon-docs": "^10.5.8",
99
100
  "@storybook/react-vite": "^10.5.8",
101
+ "@testing-library/dom": "^10.4.2",
100
102
  "@types/node": "^26.2.0",
101
103
  "@types/react": "^19.2.18",
102
104
  "@types/react-dom": "^19.2.4",
@@ -109,6 +111,7 @@
109
111
  "eslint": "^9.39.5",
110
112
  "eslint-config-cheminfo-react": "^20.1.0",
111
113
  "eslint-config-cheminfo-typescript": "^22.1.0",
114
+ "fast-png": "^8.0.0",
112
115
  "fastify": "^5.12.7",
113
116
  "jsdom": "^30.1.1",
114
117
  "ml-dataset-iris": "^1.2.1",
@@ -1,4 +1,4 @@
1
- import type { ReactElement } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import { useChromeT } from '../../i18n/ui/useT.ts';
4
4
  import { OverlayAction } from '../../overlay/ui/OverlayAction.tsx';
@@ -67,6 +67,12 @@ export interface FigureDownloadPanelProps {
67
67
  * @default undefined
68
68
  */
69
69
  sizing?: FigureSizing;
70
+ /**
71
+ * Rows of the figure's own, shown after the format: what else decides the
72
+ * file, such as which frames of an animation go into it.
73
+ * @default undefined
74
+ */
75
+ children?: ReactNode;
70
76
  }
71
77
 
72
78
  /**
@@ -93,7 +99,7 @@ export function FigureDownloadPanel(
93
99
  ): ReactElement {
94
100
  const { title, format, scale, scales, size, failure, saving } = props;
95
101
  const { onFormatChange, onScaleChange, onSave, rasterSvg = false } = props;
96
- const { sizing, onCopy, notice = null } = props;
102
+ const { sizing, onCopy, notice = null, children } = props;
97
103
  const t = useChromeT();
98
104
 
99
105
  // What the file is drawn at: the figure on screen, or the shape picked.
@@ -142,6 +148,7 @@ export function FigureDownloadPanel(
142
148
  options={FORMAT_CHOICES}
143
149
  onChange={onFormatChange}
144
150
  />
151
+ {children}
145
152
  {sizing === undefined ? null : (
146
153
  <FigureSizeRows sizing={sizing} size={size} />
147
154
  )}
@@ -141,9 +141,9 @@ export const ECOSYSTEM_SITES: readonly EcosystemSite[] = [
141
141
  mark: { plate: '#1e293b', accent: '#127ba3' },
142
142
  },
143
143
  {
144
- id: 'surge',
145
- name: { lead: 'surge', alt: 'cheminfo', dot: true },
146
- host: 'surge.cheminfo.org',
144
+ id: 'isomers',
145
+ name: { lead: 'isomers', alt: 'cheminfo', dot: true },
146
+ host: 'isomers.cheminfo.org',
147
147
  tagline: 'Every constitutional isomer of a molecular formula.',
148
148
  group: 'structures',
149
149
  brand: '#4338ca',
@@ -13,7 +13,7 @@ export type SiteId =
13
13
  | 'nmrium'
14
14
  | 'metabo'
15
15
  | 'derepflow'
16
- | 'surge'
16
+ | 'isomers'
17
17
  | 'tex'
18
18
  | 'lcao'
19
19
  | 'regexp'
@@ -216,7 +216,7 @@ export const GLYPHS: Record<SiteId, (alt: string) => ReactNode> = {
216
216
  </>
217
217
  ),
218
218
  // One formula branching into every structure it can be.
219
- surge: (alt) => (
219
+ isomers: (alt) => (
220
220
  <>
221
221
  <g
222
222
  fill="none"
@@ -26,7 +26,7 @@ export type MessagesLoader = () => Promise<{ default: Messages }>;
26
26
  /**
27
27
  * A key the catalog declares, or any other string.
28
28
  *
29
- * Many keys are built from the data — `site.surge.tagline`, `element.Fe.name`
29
+ * Many keys are built from the data — `site.isomers.tagline`, `element.Fe.name`
30
30
  * — so a row added before the catalogs have caught up must read as itself
31
31
  * rather than fail to compile.
32
32
  */
@@ -51,7 +51,7 @@ export interface TranslateOptions {
51
51
  export interface MessageCatalogOptions<TKey extends string> {
52
52
  /**
53
53
  * The name the page knows the catalog by, unique on the page, e.g.
54
- * `react-cheminfo` or `surge.cheminfo.org`.
54
+ * `react-cheminfo` or `isomers.cheminfo.org`.
55
55
  */
56
56
  id: string;
57
57
  /** The GitHub repository the files live in, written `owner/repo`. */
@@ -38,7 +38,7 @@ import { DEFAULT_LANGUAGE, LANGUAGES, MessageCatalog } from '../core/index.ts';
38
38
  export interface LocaleCatalogSource {
39
39
  /**
40
40
  * The name the page knows the catalog by, which is the site's host, e.g.
41
- * `surge.cheminfo.org`. A translator's edit is routed back to the right
41
+ * `isomers.cheminfo.org`. A translator's edit is routed back to the right
42
42
  * repository with it, so the build and the page must agree on it.
43
43
  */
44
44
  id: string;
@@ -50,7 +50,11 @@ export {
50
50
  fittedTo,
51
51
  fullDomain,
52
52
  } from './irDomain.ts';
53
- export type { IrEditorHandle, ZoomToBandOptions } from './irEditorApi.ts';
53
+ export type {
54
+ IrEditorHandle,
55
+ IrPlotClick,
56
+ ZoomToBandOptions,
57
+ } from './irEditorApi.ts';
54
58
  export {
55
59
  ABSORBANCE_DECIMALS,
56
60
  INTENSITY_DIGITS,
@@ -129,5 +133,5 @@ export {
129
133
  } from './spectrumJcamp.ts';
130
134
  export type { ToIrSpectrumOptions } from './toIrSpectrum.ts';
131
135
  export { toIrSpectra, toIrSpectrum } from './toIrSpectrum.ts';
132
- export type { IrSidePanelId } from './irSidePanels.ts';
136
+ export type { IrPanelId, IrSidePanelId } from './irSidePanels.ts';
133
137
  export { irSidePanels } from './irSidePanels.ts';
@@ -42,3 +42,16 @@ export interface IrEditorHandle {
42
42
  /** Point the panels at one spectrum, or at none. */
43
43
  selectSpectrum: (id: string | null) => void;
44
44
  }
45
+
46
+ /**
47
+ * A click on the plot, as the viewer tells its host about it.
48
+ *
49
+ * A click is a press let go over the plot without travelling: the end of a
50
+ * zoom drag is never one, and a click on the axis labels is not reported.
51
+ */
52
+ export interface IrPlotClick {
53
+ /** Where it landed on the horizontal axis, in cm⁻¹ — a Raman shift for Raman. */
54
+ wavenumber: number;
55
+ /** Identity of the spectrum selected when it was made, `null` for none. */
56
+ spectrumId: string | null;
57
+ }
@@ -13,7 +13,7 @@
13
13
  * closed.
14
14
  */
15
15
 
16
- import type { IrSidePanelId } from './irSidePanels.ts';
16
+ import type { IrPanelId } from './irSidePanels.ts';
17
17
  import type { IrDomain, IrSpectrum } from './irSpectrum.ts';
18
18
  import type { IrSettings, IrState, IrTool, PartialIrState } from './irState.ts';
19
19
  import { isIrWindow, mergeIrSettings } from './irState.ts';
@@ -30,7 +30,7 @@ export type IrAction =
30
30
  | { type: 'setDomain'; domain: IrDomain }
31
31
  | { type: 'resetDomain' }
32
32
  | { type: 'setTool'; tool: IrTool }
33
- | { type: 'togglePanel'; panelId: IrSidePanelId }
33
+ | { type: 'togglePanel'; panelId: IrPanelId }
34
34
  | { type: 'setError'; error: string | null }
35
35
  | { type: 'setSettings'; settings: Partial<IrSettings> }
36
36
  | { type: 'loadState'; state: PartialIrState }
@@ -16,5 +16,12 @@ export const irSidePanels = [
16
16
  icon: ActivityBarItemProps['icon'];
17
17
  }>;
18
18
 
19
- /** Identity of one of the panels the activity bar offers. */
19
+ /** Identity of one of the panels the viewer offers of its own. */
20
20
  export type IrSidePanelId = (typeof irSidePanels)[number]['id'];
21
+
22
+ /**
23
+ * Identity of any panel the side can hold: one of the viewer's own, or one a
24
+ * host added to them. Still a union with the viewer's own ids, so those keep
25
+ * autocompleting where a plain `string` would swallow them.
26
+ */
27
+ export type IrPanelId = IrSidePanelId | (string & Record<never, never>);
@@ -13,7 +13,7 @@
13
13
  * a stale band is then impossible rather than merely unlikely.
14
14
  */
15
15
 
16
- import type { IrSidePanelId } from './irSidePanels.ts';
16
+ import type { IrPanelId, IrSidePanelId } from './irSidePanels.ts';
17
17
  import type { IrDomain, IrMode, IrSpectrum } from './irSpectrum.ts';
18
18
  import type { IrTechnique } from './irTechnique.ts';
19
19
  import { defaultIrMode, irModeFor, offersIrMode } from './irTechnique.ts';
@@ -42,8 +42,11 @@ export interface IrView {
42
42
  domain: IrDomain | null;
43
43
  /** Which tool a drag across the chart is running. */
44
44
  tool: IrTool;
45
- /** The side panels that are open, in the order their icons are stacked. */
46
- openPanelIds: IrSidePanelId[];
45
+ /**
46
+ * The side panels that are open: the viewer's own and any a host added. An id
47
+ * no panel on offer answers to opens nothing.
48
+ */
49
+ openPanelIds: IrPanelId[];
47
50
  /** Why the last action was refused, `null` as soon as one succeeds. */
48
51
  error: string | null;
49
52
  }
@@ -139,10 +142,10 @@ export interface CreateIrStateOptions {
139
142
  */
140
143
  settings?: Partial<IrSettings>;
141
144
  /**
142
- * The panels open to begin with.
145
+ * The panels open to begin with, the viewer's own or a host's.
143
146
  * @default DEFAULT_SIDE_PANELS
144
147
  */
145
- panelIds?: IrSidePanelId[];
148
+ panelIds?: readonly IrPanelId[];
146
149
  }
147
150
 
148
151
  /**