react-cheminfo 0.25.0 → 0.26.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 (416) hide show
  1. package/README.md +73 -2
  2. package/bin/check-messages.mjs +229 -0
  3. package/lib/about/ui/AboutBuild.d.ts.map +1 -1
  4. package/lib/about/ui/AboutBuild.js +15 -4
  5. package/lib/about/ui/AboutBuild.js.map +1 -1
  6. package/lib/about/ui/AboutCitations.d.ts.map +1 -1
  7. package/lib/about/ui/AboutCitations.js +3 -1
  8. package/lib/about/ui/AboutCitations.js.map +1 -1
  9. package/lib/about/ui/AboutPage.d.ts.map +1 -1
  10. package/lib/about/ui/AboutPage.js +9 -1
  11. package/lib/about/ui/AboutPage.js.map +1 -1
  12. package/lib/about/ui/AboutProvidedBy.d.ts.map +1 -1
  13. package/lib/about/ui/AboutProvidedBy.js +8 -3
  14. package/lib/about/ui/AboutProvidedBy.js.map +1 -1
  15. package/lib/capsule/ui/Capsule.d.ts +30 -0
  16. package/lib/capsule/ui/Capsule.d.ts.map +1 -0
  17. package/lib/capsule/ui/Capsule.js +12 -0
  18. package/lib/capsule/ui/Capsule.js.map +1 -0
  19. package/lib/capsule/ui/CapsuleFilter.d.ts +19 -3
  20. package/lib/capsule/ui/CapsuleFilter.d.ts.map +1 -1
  21. package/lib/capsule/ui/CapsuleFilter.js +14 -44
  22. package/lib/capsule/ui/CapsuleFilter.js.map +1 -1
  23. package/lib/capsule/ui/capsuleFilterCapsules.d.ts +15 -0
  24. package/lib/capsule/ui/capsuleFilterCapsules.d.ts.map +1 -0
  25. package/lib/capsule/ui/capsuleFilterCapsules.js +47 -0
  26. package/lib/capsule/ui/capsuleFilterCapsules.js.map +1 -0
  27. package/lib/chart/ui/ChartTrackingLayer.d.ts.map +1 -1
  28. package/lib/chart/ui/ChartTrackingLayer.js +4 -2
  29. package/lib/chart/ui/ChartTrackingLayer.js.map +1 -1
  30. package/lib/chrome/ui/SiteHeader.d.ts +1 -1
  31. package/lib/chrome/ui/SiteHeader.d.ts.map +1 -1
  32. package/lib/chrome/ui/SiteHeader.js +4 -2
  33. package/lib/chrome/ui/SiteHeader.js.map +1 -1
  34. package/lib/citation/ui/CitationMenu.d.ts +1 -1
  35. package/lib/citation/ui/CitationMenu.d.ts.map +1 -1
  36. package/lib/citation/ui/CitationMenu.js +7 -3
  37. package/lib/citation/ui/CitationMenu.js.map +1 -1
  38. package/lib/citation/ui/CiteButton.d.ts +1 -1
  39. package/lib/citation/ui/CiteButton.d.ts.map +1 -1
  40. package/lib/citation/ui/CiteButton.js +3 -1
  41. package/lib/citation/ui/CiteButton.js.map +1 -1
  42. package/lib/citation/ui/CopyFormatEntries.d.ts.map +1 -1
  43. package/lib/citation/ui/CopyFormatEntries.js +3 -1
  44. package/lib/citation/ui/CopyFormatEntries.js.map +1 -1
  45. package/lib/citation/ui/WorkEntry.d.ts.map +1 -1
  46. package/lib/citation/ui/WorkEntry.js +3 -1
  47. package/lib/citation/ui/WorkEntry.js.map +1 -1
  48. package/lib/citation/ui/entries.d.ts.map +1 -1
  49. package/lib/citation/ui/entries.js +8 -2
  50. package/lib/citation/ui/entries.js.map +1 -1
  51. package/lib/citation/ui/useCopyFeedback.d.ts.map +1 -1
  52. package/lib/citation/ui/useCopyFeedback.js +9 -4
  53. package/lib/citation/ui/useCopyFeedback.js.map +1 -1
  54. package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
  55. package/lib/clipboard/ui/ClickToCopy.js +12 -6
  56. package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
  57. package/lib/clipboard/ui/CopyButton.d.ts +3 -3
  58. package/lib/clipboard/ui/CopyButton.d.ts.map +1 -1
  59. package/lib/clipboard/ui/CopyButton.js +7 -4
  60. package/lib/clipboard/ui/CopyButton.js.map +1 -1
  61. package/lib/color/ui/ColorScaleEditor.d.ts.map +1 -1
  62. package/lib/color/ui/ColorScaleEditor.js +15 -10
  63. package/lib/color/ui/ColorScaleEditor.js.map +1 -1
  64. package/lib/color/ui/ColorScaleEntry.d.ts.map +1 -1
  65. package/lib/color/ui/ColorScaleEntry.js +4 -2
  66. package/lib/color/ui/ColorScaleEntry.js.map +1 -1
  67. package/lib/color/ui/ColorScaleLegend.d.ts.map +1 -1
  68. package/lib/color/ui/ColorScaleLegend.js +7 -1
  69. package/lib/color/ui/ColorScaleLegend.js.map +1 -1
  70. package/lib/color/ui/ColorScaleSelect.d.ts.map +1 -1
  71. package/lib/color/ui/ColorScaleSelect.js +8 -4
  72. package/lib/color/ui/ColorScaleSelect.js.map +1 -1
  73. package/lib/confirm/ui/ConfirmButton.d.ts +2 -2
  74. package/lib/confirm/ui/ConfirmButton.d.ts.map +1 -1
  75. package/lib/confirm/ui/ConfirmButton.js +4 -2
  76. package/lib/confirm/ui/ConfirmButton.js.map +1 -1
  77. package/lib/core.d.ts +1 -0
  78. package/lib/core.d.ts.map +1 -1
  79. package/lib/core.js +1 -0
  80. package/lib/core.js.map +1 -1
  81. package/lib/credits/ui/CreditsList.d.ts.map +1 -1
  82. package/lib/credits/ui/CreditsList.js +3 -1
  83. package/lib/credits/ui/CreditsList.js.map +1 -1
  84. package/lib/delimited/ui/DelimitedTextDialog.d.ts.map +1 -1
  85. package/lib/delimited/ui/DelimitedTextDialog.js +5 -2
  86. package/lib/delimited/ui/DelimitedTextDialog.js.map +1 -1
  87. package/lib/delimited/ui/DelimitedTextPanel.d.ts.map +1 -1
  88. package/lib/delimited/ui/DelimitedTextPanel.js +8 -8
  89. package/lib/delimited/ui/DelimitedTextPanel.js.map +1 -1
  90. package/lib/download/ui/FigureDownload.d.ts +2 -2
  91. package/lib/download/ui/FigureDownload.d.ts.map +1 -1
  92. package/lib/download/ui/FigureDownload.js +4 -2
  93. package/lib/download/ui/FigureDownload.js.map +1 -1
  94. package/lib/download/ui/FigureDownloadPanel.d.ts.map +1 -1
  95. package/lib/download/ui/FigureDownloadPanel.js +24 -18
  96. package/lib/download/ui/FigureDownloadPanel.js.map +1 -1
  97. package/lib/ecosystem/ui/EcosystemButton.d.ts +1 -1
  98. package/lib/ecosystem/ui/EcosystemButton.d.ts.map +1 -1
  99. package/lib/ecosystem/ui/EcosystemButton.js +4 -2
  100. package/lib/ecosystem/ui/EcosystemButton.js.map +1 -1
  101. package/lib/ecosystem/ui/EcosystemLinks.d.ts +1 -1
  102. package/lib/ecosystem/ui/EcosystemLinks.d.ts.map +1 -1
  103. package/lib/ecosystem/ui/EcosystemLinks.js +5 -2
  104. package/lib/ecosystem/ui/EcosystemLinks.js.map +1 -1
  105. package/lib/ecosystem/ui/EcosystemMenu.d.ts.map +1 -1
  106. package/lib/ecosystem/ui/EcosystemMenu.js +3 -1
  107. package/lib/ecosystem/ui/EcosystemMenu.js.map +1 -1
  108. package/lib/ecosystem/ui/SiteGroupSection.d.ts.map +1 -1
  109. package/lib/ecosystem/ui/SiteGroupSection.js +3 -1
  110. package/lib/ecosystem/ui/SiteGroupSection.js.map +1 -1
  111. package/lib/ecosystem/ui/SiteTile.d.ts.map +1 -1
  112. package/lib/ecosystem/ui/SiteTile.js +3 -1
  113. package/lib/ecosystem/ui/SiteTile.js.map +1 -1
  114. package/lib/error/ui/ErrorFallback.d.ts +2 -2
  115. package/lib/error/ui/ErrorFallback.d.ts.map +1 -1
  116. package/lib/error/ui/ErrorFallback.js +4 -2
  117. package/lib/error/ui/ErrorFallback.js.map +1 -1
  118. package/lib/help/ui/HelpBody.d.ts.map +1 -1
  119. package/lib/help/ui/HelpBody.js +3 -1
  120. package/lib/help/ui/HelpBody.js.map +1 -1
  121. package/lib/help/ui/HelpIcon.d.ts +2 -1
  122. package/lib/help/ui/HelpIcon.d.ts.map +1 -1
  123. package/lib/help/ui/HelpIcon.js +4 -2
  124. package/lib/help/ui/HelpIcon.js.map +1 -1
  125. package/lib/help/ui/HelpToolbarButton.d.ts.map +1 -1
  126. package/lib/help/ui/HelpToolbarButton.js +3 -1
  127. package/lib/help/ui/HelpToolbarButton.js.map +1 -1
  128. package/lib/help/ui/helpName.d.ts +5 -1
  129. package/lib/help/ui/helpName.d.ts.map +1 -1
  130. package/lib/help/ui/helpName.js +4 -2
  131. package/lib/help/ui/helpName.js.map +1 -1
  132. package/lib/i18n/core/chromeCatalog.d.ts +21 -0
  133. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -0
  134. package/lib/i18n/core/chromeCatalog.js +29 -0
  135. package/lib/i18n/core/chromeCatalog.js.map +1 -0
  136. package/lib/i18n/core/index.d.ts +12 -0
  137. package/lib/i18n/core/index.d.ts.map +1 -0
  138. package/lib/i18n/core/index.js +6 -0
  139. package/lib/i18n/core/index.js.map +1 -0
  140. package/lib/i18n/core/languages.d.ts +32 -0
  141. package/lib/i18n/core/languages.d.ts.map +1 -0
  142. package/lib/i18n/core/languages.js +41 -0
  143. package/lib/i18n/core/languages.js.map +1 -0
  144. package/lib/i18n/core/messageCatalog.d.ts +113 -0
  145. package/lib/i18n/core/messageCatalog.d.ts.map +1 -0
  146. package/lib/i18n/core/messageCatalog.js +135 -0
  147. package/lib/i18n/core/messageCatalog.js.map +1 -0
  148. package/lib/i18n/core/messageValues.d.ts +3 -0
  149. package/lib/i18n/core/messageValues.d.ts.map +1 -0
  150. package/lib/i18n/core/messageValues.js +2 -0
  151. package/lib/i18n/core/messageValues.js.map +1 -0
  152. package/lib/i18n/core/session.d.ts +51 -0
  153. package/lib/i18n/core/session.d.ts.map +1 -0
  154. package/lib/i18n/core/session.js +64 -0
  155. package/lib/i18n/core/session.js.map +1 -0
  156. package/lib/i18n/core/translateSetup.d.ts +28 -0
  157. package/lib/i18n/core/translateSetup.d.ts.map +1 -0
  158. package/lib/i18n/core/translateSetup.js +30 -0
  159. package/lib/i18n/core/translateSetup.js.map +1 -0
  160. package/lib/i18n/ui/LanguageSelect.d.ts +37 -0
  161. package/lib/i18n/ui/LanguageSelect.d.ts.map +1 -0
  162. package/lib/i18n/ui/LanguageSelect.js +27 -0
  163. package/lib/i18n/ui/LanguageSelect.js.map +1 -0
  164. package/lib/i18n/ui/index.d.ts +6 -0
  165. package/lib/i18n/ui/index.d.ts.map +1 -0
  166. package/lib/i18n/ui/index.js +4 -0
  167. package/lib/i18n/ui/index.js.map +1 -0
  168. package/lib/i18n/ui/useLanguage.d.ts +23 -0
  169. package/lib/i18n/ui/useLanguage.d.ts.map +1 -0
  170. package/lib/i18n/ui/useLanguage.js +36 -0
  171. package/lib/i18n/ui/useLanguage.js.map +1 -0
  172. package/lib/i18n/ui/useT.d.ts +47 -0
  173. package/lib/i18n/ui/useT.d.ts.map +1 -0
  174. package/lib/i18n/ui/useT.js +51 -0
  175. package/lib/i18n/ui/useT.js.map +1 -0
  176. package/lib/locales/de.json +442 -0
  177. package/lib/locales/en.json +442 -0
  178. package/lib/locales/es.json +442 -0
  179. package/lib/locales/fr.json +442 -0
  180. package/lib/molecule3d/core/gestures.d.ts +10 -0
  181. package/lib/molecule3d/core/gestures.d.ts.map +1 -1
  182. package/lib/molecule3d/core/gestures.js +39 -7
  183. package/lib/molecule3d/core/gestures.js.map +1 -1
  184. package/lib/molecule3d/ui/Molecule3DExport.d.ts.map +1 -1
  185. package/lib/molecule3d/ui/Molecule3DExport.js +3 -1
  186. package/lib/molecule3d/ui/Molecule3DExport.js.map +1 -1
  187. package/lib/molecule3d/ui/Molecule3DHelp.d.ts.map +1 -1
  188. package/lib/molecule3d/ui/Molecule3DHelp.js +7 -2
  189. package/lib/molecule3d/ui/Molecule3DHelp.js.map +1 -1
  190. package/lib/molecule3d/ui/Molecule3DOptions.d.ts.map +1 -1
  191. package/lib/molecule3d/ui/Molecule3DOptions.js +9 -9
  192. package/lib/molecule3d/ui/Molecule3DOptions.js.map +1 -1
  193. package/lib/molecule3d/ui/Molecule3DSurfaceColors.d.ts.map +1 -1
  194. package/lib/molecule3d/ui/Molecule3DSurfaceColors.js +8 -8
  195. package/lib/molecule3d/ui/Molecule3DSurfaceColors.js.map +1 -1
  196. package/lib/molecule3d/ui/Molecule3DToolbar.d.ts.map +1 -1
  197. package/lib/molecule3d/ui/Molecule3DToolbar.js +15 -10
  198. package/lib/molecule3d/ui/Molecule3DToolbar.js.map +1 -1
  199. package/lib/molecule3d/ui/MoleculeViewer3D.d.ts.map +1 -1
  200. package/lib/molecule3d/ui/MoleculeViewer3D.js +6 -3
  201. package/lib/molecule3d/ui/MoleculeViewer3D.js.map +1 -1
  202. package/lib/orbital/ui/AtomicOrbitalCanvas.d.ts.map +1 -1
  203. package/lib/orbital/ui/AtomicOrbitalCanvas.js +3 -1
  204. package/lib/orbital/ui/AtomicOrbitalCanvas.js.map +1 -1
  205. package/lib/orbital/ui/AtomicOrbitalControls.d.ts.map +1 -1
  206. package/lib/orbital/ui/AtomicOrbitalControls.js +12 -15
  207. package/lib/orbital/ui/AtomicOrbitalControls.js.map +1 -1
  208. package/lib/orbital/ui/AtomicOrbitalViewer.d.ts.map +1 -1
  209. package/lib/orbital/ui/AtomicOrbitalViewer.js +6 -3
  210. package/lib/orbital/ui/AtomicOrbitalViewer.js.map +1 -1
  211. package/lib/orbital/ui/capability.d.ts +4 -0
  212. package/lib/orbital/ui/capability.d.ts.map +1 -1
  213. package/lib/orbital/ui/capability.js +4 -0
  214. package/lib/orbital/ui/capability.js.map +1 -1
  215. package/lib/overlay/ui/OverlayBar.d.ts +1 -1
  216. package/lib/overlay/ui/OverlayBar.d.ts.map +1 -1
  217. package/lib/overlay/ui/OverlayBar.js +6 -3
  218. package/lib/overlay/ui/OverlayBar.js.map +1 -1
  219. package/lib/overlay/ui/OverlayInfo.d.ts +1 -1
  220. package/lib/overlay/ui/OverlayInfo.d.ts.map +1 -1
  221. package/lib/overlay/ui/OverlayInfo.js +5 -2
  222. package/lib/overlay/ui/OverlayInfo.js.map +1 -1
  223. package/lib/overlay/ui/OverlayPanel.d.ts +9 -2
  224. package/lib/overlay/ui/OverlayPanel.d.ts.map +1 -1
  225. package/lib/overlay/ui/OverlayPanel.js +5 -11
  226. package/lib/overlay/ui/OverlayPanel.js.map +1 -1
  227. package/lib/overlay/ui/OverlayReadout.d.ts.map +1 -1
  228. package/lib/overlay/ui/OverlayReadout.js +3 -1
  229. package/lib/overlay/ui/OverlayReadout.js.map +1 -1
  230. package/lib/pedagogy/ui/ExerciseActions.d.ts +1 -1
  231. package/lib/pedagogy/ui/ExerciseActions.d.ts.map +1 -1
  232. package/lib/pedagogy/ui/ExerciseActions.js +9 -2
  233. package/lib/pedagogy/ui/ExerciseActions.js.map +1 -1
  234. package/lib/pedagogy/ui/ExerciseProgressHeader.d.ts +1 -1
  235. package/lib/pedagogy/ui/ExerciseProgressHeader.d.ts.map +1 -1
  236. package/lib/pedagogy/ui/ExerciseProgressHeader.js +9 -5
  237. package/lib/pedagogy/ui/ExerciseProgressHeader.js.map +1 -1
  238. package/lib/pedagogy/ui/GlossaryIndex.d.ts +1 -1
  239. package/lib/pedagogy/ui/GlossaryIndex.d.ts.map +1 -1
  240. package/lib/pedagogy/ui/GlossaryIndex.js +6 -8
  241. package/lib/pedagogy/ui/GlossaryIndex.js.map +1 -1
  242. package/lib/pedagogy/ui/HintLadder.d.ts +2 -2
  243. package/lib/pedagogy/ui/HintLadder.d.ts.map +1 -1
  244. package/lib/pedagogy/ui/HintLadder.js +8 -2
  245. package/lib/pedagogy/ui/HintLadder.js.map +1 -1
  246. package/lib/pedagogy/ui/SyntaxTooltip.d.ts +4 -4
  247. package/lib/pedagogy/ui/SyntaxTooltip.d.ts.map +1 -1
  248. package/lib/pedagogy/ui/SyntaxTooltip.js +4 -2
  249. package/lib/pedagogy/ui/SyntaxTooltip.js.map +1 -1
  250. package/lib/pedagogy/ui/TutorialStepStrip.d.ts.map +1 -1
  251. package/lib/pedagogy/ui/TutorialStepStrip.js +7 -2
  252. package/lib/pedagogy/ui/TutorialStepStrip.js.map +1 -1
  253. package/lib/periodic/ui/CategoryLegend.d.ts.map +1 -1
  254. package/lib/periodic/ui/CategoryLegend.js +3 -1
  255. package/lib/periodic/ui/CategoryLegend.js.map +1 -1
  256. package/lib/periodic/ui/ElementCell.d.ts.map +1 -1
  257. package/lib/periodic/ui/ElementCell.js +7 -1
  258. package/lib/periodic/ui/ElementCell.js.map +1 -1
  259. package/lib/periodic/ui/PeriodicTable.d.ts.map +1 -1
  260. package/lib/periodic/ui/PeriodicTable.js +3 -1
  261. package/lib/periodic/ui/PeriodicTable.js.map +1 -1
  262. package/lib/periodic/ui/PeriodicTableChrome.d.ts.map +1 -1
  263. package/lib/periodic/ui/PeriodicTableChrome.js +4 -2
  264. package/lib/periodic/ui/PeriodicTableChrome.js.map +1 -1
  265. package/lib/share/ui/ShareButton.d.ts +2 -2
  266. package/lib/share/ui/ShareButton.d.ts.map +1 -1
  267. package/lib/share/ui/ShareButton.js +5 -2
  268. package/lib/share/ui/ShareButton.js.map +1 -1
  269. package/lib/share/ui/ShareConfigOptions.d.ts.map +1 -1
  270. package/lib/share/ui/ShareConfigOptions.js +4 -2
  271. package/lib/share/ui/ShareConfigOptions.js.map +1 -1
  272. package/lib/share/ui/ShareDialog.d.ts.map +1 -1
  273. package/lib/share/ui/ShareDialog.js +3 -1
  274. package/lib/share/ui/ShareDialog.js.map +1 -1
  275. package/lib/share/ui/ShareDialogContent.d.ts.map +1 -1
  276. package/lib/share/ui/ShareDialogContent.js +10 -1
  277. package/lib/share/ui/ShareDialogContent.js.map +1 -1
  278. package/lib/share/ui/SharePresetTabs.d.ts.map +1 -1
  279. package/lib/share/ui/SharePresetTabs.js +3 -1
  280. package/lib/share/ui/SharePresetTabs.js.map +1 -1
  281. package/lib/slides/ui/BackToSlides.d.ts.map +1 -1
  282. package/lib/slides/ui/BackToSlides.js +4 -2
  283. package/lib/slides/ui/BackToSlides.js.map +1 -1
  284. package/lib/slides/ui/EmbedSlide.d.ts.map +1 -1
  285. package/lib/slides/ui/EmbedSlide.js +3 -1
  286. package/lib/slides/ui/EmbedSlide.js.map +1 -1
  287. package/lib/slides/ui/Slide.d.ts.map +1 -1
  288. package/lib/slides/ui/Slide.js +3 -1
  289. package/lib/slides/ui/Slide.js.map +1 -1
  290. package/lib/slides/ui/SlideshowBar.d.ts.map +1 -1
  291. package/lib/slides/ui/SlideshowBar.js +5 -3
  292. package/lib/slides/ui/SlideshowBar.js.map +1 -1
  293. package/lib/slides/ui/TalkList.d.ts +1 -1
  294. package/lib/slides/ui/TalkList.d.ts.map +1 -1
  295. package/lib/slides/ui/TalkList.js +4 -2
  296. package/lib/slides/ui/TalkList.js.map +1 -1
  297. package/lib/structure/core/editorGuide.d.ts +14 -0
  298. package/lib/structure/core/editorGuide.d.ts.map +1 -1
  299. package/lib/structure/core/editorGuide.js +117 -19
  300. package/lib/structure/core/editorGuide.js.map +1 -1
  301. package/lib/structure/core/editorToolbar.d.ts +3 -1
  302. package/lib/structure/core/editorToolbar.d.ts.map +1 -1
  303. package/lib/structure/core/editorToolbar.js +44 -23
  304. package/lib/structure/core/editorToolbar.js.map +1 -1
  305. package/lib/structure/ui/EditorHelpButton.d.ts.map +1 -1
  306. package/lib/structure/ui/EditorHelpButton.js +3 -2
  307. package/lib/structure/ui/EditorHelpButton.js.map +1 -1
  308. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  309. package/lib/structure/ui/StructureEditor.js +3 -1
  310. package/lib/structure/ui/StructureEditor.js.map +1 -1
  311. package/lib/structure/ui/StructureEditorHelp.d.ts.map +1 -1
  312. package/lib/structure/ui/StructureEditorHelp.js +12 -3
  313. package/lib/structure/ui/StructureEditorHelp.js.map +1 -1
  314. package/lib/structure/ui/ToolbarTooltip.d.ts.map +1 -1
  315. package/lib/structure/ui/ToolbarTooltip.js +5 -3
  316. package/lib/structure/ui/ToolbarTooltip.js.map +1 -1
  317. package/lib/ui.d.ts +1 -0
  318. package/lib/ui.d.ts.map +1 -1
  319. package/lib/ui.js +1 -0
  320. package/lib/ui.js.map +1 -1
  321. package/package.json +4 -2
  322. package/src/about/ui/AboutBuild.tsx +23 -16
  323. package/src/about/ui/AboutCitations.tsx +3 -1
  324. package/src/about/ui/AboutPage.tsx +38 -12
  325. package/src/about/ui/AboutProvidedBy.tsx +13 -3
  326. package/src/capsule/ui/Capsule.tsx +48 -0
  327. package/src/capsule/ui/CapsuleFilter.tsx +38 -114
  328. package/src/capsule/ui/capsuleFilterCapsules.tsx +110 -0
  329. package/src/chart/ui/ChartTrackingLayer.tsx +4 -2
  330. package/src/chrome/ui/SiteHeader.tsx +5 -3
  331. package/src/citation/ui/CitationMenu.tsx +9 -5
  332. package/src/citation/ui/CiteButton.tsx +4 -2
  333. package/src/citation/ui/CopyFormatEntries.tsx +3 -1
  334. package/src/citation/ui/WorkEntry.tsx +5 -3
  335. package/src/citation/ui/entries.tsx +9 -2
  336. package/src/citation/ui/useCopyFeedback.ts +11 -4
  337. package/src/clipboard/ui/ClickToCopy.tsx +15 -5
  338. package/src/clipboard/ui/CopyButton.tsx +14 -10
  339. package/src/color/ui/ColorScaleEditor.tsx +17 -15
  340. package/src/color/ui/ColorScaleEntry.tsx +7 -3
  341. package/src/color/ui/ColorScaleLegend.tsx +7 -1
  342. package/src/color/ui/ColorScaleSelect.tsx +12 -6
  343. package/src/confirm/ui/ConfirmButton.tsx +9 -11
  344. package/src/core.ts +1 -0
  345. package/src/credits/ui/CreditsList.tsx +5 -1
  346. package/src/delimited/ui/DelimitedTextDialog.tsx +10 -10
  347. package/src/delimited/ui/DelimitedTextPanel.tsx +19 -12
  348. package/src/download/ui/FigureDownload.tsx +7 -5
  349. package/src/download/ui/FigureDownloadPanel.tsx +31 -25
  350. package/src/ecosystem/ui/EcosystemButton.tsx +5 -3
  351. package/src/ecosystem/ui/EcosystemLinks.tsx +10 -10
  352. package/src/ecosystem/ui/EcosystemMenu.tsx +3 -1
  353. package/src/ecosystem/ui/SiteGroupSection.tsx +6 -2
  354. package/src/ecosystem/ui/SiteTile.tsx +6 -2
  355. package/src/error/ui/ErrorFallback.tsx +13 -12
  356. package/src/help/ui/HelpBody.tsx +4 -2
  357. package/src/help/ui/HelpIcon.tsx +6 -3
  358. package/src/help/ui/HelpToolbarButton.tsx +4 -1
  359. package/src/help/ui/helpName.ts +10 -2
  360. package/src/i18n/core/chromeCatalog.ts +35 -0
  361. package/src/i18n/core/index.ts +26 -0
  362. package/src/i18n/core/languages.ts +46 -0
  363. package/src/i18n/core/messageCatalog.ts +202 -0
  364. package/src/i18n/core/messageValues.ts +2 -0
  365. package/src/i18n/core/session.ts +82 -0
  366. package/src/i18n/core/translateSetup.ts +47 -0
  367. package/src/i18n/ui/LanguageSelect.tsx +72 -0
  368. package/src/i18n/ui/index.ts +9 -0
  369. package/src/i18n/ui/useLanguage.ts +48 -0
  370. package/src/i18n/ui/useT.ts +90 -0
  371. package/src/locales/de.json +442 -0
  372. package/src/locales/en.json +442 -0
  373. package/src/locales/es.json +442 -0
  374. package/src/locales/fr.json +442 -0
  375. package/src/molecule3d/core/gestures.ts +44 -7
  376. package/src/molecule3d/ui/Molecule3DExport.tsx +3 -1
  377. package/src/molecule3d/ui/Molecule3DHelp.tsx +17 -6
  378. package/src/molecule3d/ui/Molecule3DOptions.tsx +13 -13
  379. package/src/molecule3d/ui/Molecule3DSurfaceColors.tsx +16 -13
  380. package/src/molecule3d/ui/Molecule3DToolbar.tsx +29 -18
  381. package/src/molecule3d/ui/MoleculeViewer3D.tsx +13 -8
  382. package/src/orbital/ui/AtomicOrbitalCanvas.tsx +3 -1
  383. package/src/orbital/ui/AtomicOrbitalControls.tsx +15 -20
  384. package/src/orbital/ui/AtomicOrbitalViewer.tsx +13 -13
  385. package/src/orbital/ui/capability.ts +10 -0
  386. package/src/overlay/ui/OverlayBar.tsx +7 -4
  387. package/src/overlay/ui/OverlayInfo.tsx +6 -3
  388. package/src/overlay/ui/OverlayPanel.tsx +10 -7
  389. package/src/overlay/ui/OverlayReadout.tsx +3 -1
  390. package/src/pedagogy/ui/ExerciseActions.tsx +16 -6
  391. package/src/pedagogy/ui/ExerciseProgressHeader.tsx +13 -11
  392. package/src/pedagogy/ui/GlossaryIndex.tsx +11 -12
  393. package/src/pedagogy/ui/HintLadder.tsx +15 -12
  394. package/src/pedagogy/ui/SyntaxTooltip.tsx +9 -7
  395. package/src/pedagogy/ui/TutorialStepStrip.tsx +8 -3
  396. package/src/periodic/ui/CategoryLegend.tsx +6 -1
  397. package/src/periodic/ui/ElementCell.tsx +7 -1
  398. package/src/periodic/ui/PeriodicTable.tsx +3 -1
  399. package/src/periodic/ui/PeriodicTableChrome.tsx +4 -2
  400. package/src/share/ui/ShareButton.tsx +8 -5
  401. package/src/share/ui/ShareConfigOptions.tsx +6 -7
  402. package/src/share/ui/ShareDialog.tsx +3 -1
  403. package/src/share/ui/ShareDialogContent.tsx +20 -10
  404. package/src/share/ui/SharePresetTabs.tsx +3 -1
  405. package/src/slides/ui/BackToSlides.tsx +4 -2
  406. package/src/slides/ui/EmbedSlide.tsx +3 -3
  407. package/src/slides/ui/Slide.tsx +3 -1
  408. package/src/slides/ui/SlideshowBar.tsx +12 -4
  409. package/src/slides/ui/TalkList.tsx +8 -10
  410. package/src/structure/core/editorGuide.ts +126 -19
  411. package/src/structure/core/editorToolbar.ts +52 -24
  412. package/src/structure/ui/EditorHelpButton.tsx +9 -4
  413. package/src/structure/ui/StructureEditor.tsx +7 -1
  414. package/src/structure/ui/StructureEditorHelp.tsx +34 -11
  415. package/src/structure/ui/ToolbarTooltip.tsx +8 -4
  416. package/src/ui.ts +1 -0
@@ -0,0 +1,135 @@
1
+ /**
2
+ * One directory of messages, and the reading of it.
3
+ *
4
+ * A catalog is `en.json` — the source of truth — with one file per language
5
+ * beside it. English is part of the page, because it is what every missing
6
+ * message falls back to; the others are fetched when a visitor asks for them,
7
+ * so a site nobody reads in German never downloads the German.
8
+ *
9
+ * Only the plain `{name}` argument of ICU MessageFormat is filled here. A
10
+ * plural or a select needs the formatter itself, which is 40 kB an ordinary
11
+ * visit must not pay for — `check-messages` refuses one in a catalog, and the
12
+ * page is written with a key per branch instead.
13
+ */
14
+ import { ownMessage } from "../../translate/core/catalog.js";
15
+ import { DEFAULT_LANGUAGE } from "./languages.js";
16
+ import { messageSession, notifyMessages } from "./session.js";
17
+ /**
18
+ * The messages of one repository, read in whichever language the page is
19
+ * written in.
20
+ */
21
+ export class MessageCatalog {
22
+ /** The name the page knows this catalog by. */
23
+ id;
24
+ /** What a translator's session and the overlay need to place an edit. */
25
+ source;
26
+ #loaded = new Map();
27
+ #loaders = new Map();
28
+ #pending = new Map();
29
+ /**
30
+ * Declare a catalog.
31
+ * @param options - See {@link MessageCatalogOptions}.
32
+ */
33
+ constructor(options) {
34
+ const { id, repository, directory, source, translations = {} } = options;
35
+ this.id = id;
36
+ this.source = { id, repository, directory, messages: source };
37
+ this.#loaded.set(DEFAULT_LANGUAGE, source);
38
+ for (const [language, messages] of Object.entries(translations)) {
39
+ if (messages === undefined)
40
+ continue;
41
+ if (typeof messages === 'function') {
42
+ this.#loaders.set(language, messages);
43
+ }
44
+ else {
45
+ this.#loaded.set(language, messages);
46
+ }
47
+ }
48
+ }
49
+ /**
50
+ * The languages this catalog carries, whether or not they are in memory.
51
+ * @returns The languages, English first.
52
+ */
53
+ get languages() {
54
+ return [...new Set([...this.#loaded.keys(), ...this.#loaders.keys()])];
55
+ }
56
+ /**
57
+ * The text a key carries in one language.
58
+ * @param key - Key to read.
59
+ * @param language - Language to read it in.
60
+ * @param options - See {@link TranslateOptions}.
61
+ * @returns The text.
62
+ */
63
+ translate(key, language, options = {}) {
64
+ const { fallback = key, values } = options;
65
+ const english = this.source.messages;
66
+ const session = messageSession();
67
+ if (session !== null) {
68
+ // A key the catalog does not declare is not the translator's to edit:
69
+ // marking it would offer them a message that lives nowhere.
70
+ if (ownMessage(english, key) === undefined)
71
+ return fill(fallback, values);
72
+ return session.format(this.id, key, values);
73
+ }
74
+ const translated = this.#loaded.get(language);
75
+ const message = (translated === undefined ? undefined : ownMessage(translated, key)) ??
76
+ ownMessage(english, key) ??
77
+ fallback;
78
+ return fill(message, values);
79
+ }
80
+ /**
81
+ * The messages of a language, once they are in memory.
82
+ * @param language - Language asked for.
83
+ * @returns The messages, or an empty catalog while they are still coming.
84
+ */
85
+ messages(language) {
86
+ return this.#loaded.get(language) ?? {};
87
+ }
88
+ /**
89
+ * Fetch a language's messages, if they are not in memory already.
90
+ * @param language - Language to read next.
91
+ * @returns Its messages.
92
+ */
93
+ async load(language) {
94
+ const loaded = this.#loaded.get(language);
95
+ if (loaded !== undefined)
96
+ return loaded;
97
+ const pending = this.#pending.get(language);
98
+ if (pending !== undefined)
99
+ return pending;
100
+ const loader = this.#loaders.get(language);
101
+ if (loader === undefined)
102
+ return {};
103
+ const fetching = loader().then((module) => {
104
+ this.#loaded.set(language, module.default);
105
+ this.#pending.delete(language);
106
+ notifyMessages();
107
+ return module.default;
108
+ }, () => {
109
+ // A language that cannot be fetched is a page in English, never a
110
+ // page of raw keys: forget the attempt so a later render retries.
111
+ this.#pending.delete(language);
112
+ return {};
113
+ });
114
+ this.#pending.set(language, fetching);
115
+ return fetching;
116
+ }
117
+ /**
118
+ * Start fetching a language without waiting for it. Safe to call on every
119
+ * render: a language already in memory, or already on its way, costs
120
+ * nothing.
121
+ * @param language - Language the page is about to be written in.
122
+ */
123
+ prefetch(language) {
124
+ if (this.#loaded.has(language) || this.#pending.has(language))
125
+ return;
126
+ void this.load(language);
127
+ }
128
+ }
129
+ const PLACEHOLDER = /\{(?<name>\w+)\}/g;
130
+ function fill(message, values) {
131
+ if (values === undefined)
132
+ return message;
133
+ return message.replaceAll(PLACEHOLDER, (match, name) => Object.hasOwn(values, name) ? String(values[name]) : match);
134
+ }
135
+ //# sourceMappingURL=messageCatalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageCatalog.js","sourceRoot":"","sources":["../../../src/i18n/core/messageCatalog.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,3 @@
1
+ /** What a message's `{placeholder}`s stand for. */
2
+ export type MessageValues = Record<string, string | number>;
3
+ //# sourceMappingURL=messageValues.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageValues.d.ts","sourceRoot":"","sources":["../../../src/i18n/core/messageValues.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=messageValues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageValues.js","sourceRoot":"","sources":["../../../src/i18n/core/messageValues.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Where the page formats its messages from, and who is told when that changes.
3
+ *
4
+ * Ordinarily a message is read straight out of a catalog. While a translator
5
+ * has the page open, every message goes through their session instead — marked
6
+ * invisibly so the overlay can find it in the DOM, and answered with whatever
7
+ * they have typed rather than with what was published. Both the session and a
8
+ * language arriving late are changes the page has to redraw for, so they share
9
+ * one version counter and one set of listeners.
10
+ */
11
+ import type { MessageValues } from './messageValues.ts';
12
+ /**
13
+ * What a page in translate mode formats through — satisfied by
14
+ * `TranslateSession` from `react-cheminfo/translate`, which is never imported
15
+ * here: an ordinary visit must not load the ICU formatter behind it.
16
+ */
17
+ export interface MessageSession {
18
+ /** The message of a catalog, formatted and marked. */
19
+ format: (catalogId: string, key: string, values?: MessageValues) => string;
20
+ /** Be told whenever an edit is typed; returns the function that stops it. */
21
+ subscribe?: (listener: () => void) => () => void;
22
+ }
23
+ /**
24
+ * Format every message through a translator's session from now on.
25
+ *
26
+ * While one is set it is the session's locale the page is written in, not the
27
+ * visitor's preference, and every message carries the marker the overlay finds
28
+ * it by.
29
+ * @param active - The session, or `null` to go back to the catalogs.
30
+ */
31
+ export declare function setMessageSession(active: MessageSession | null): void;
32
+ /**
33
+ * The session the page formats through, if a translator has it open.
34
+ * @returns The session, or `null`.
35
+ */
36
+ export declare function messageSession(): MessageSession | null;
37
+ /**
38
+ * How many times the text of the page has changed — a session set or dropped,
39
+ * an edit typed, a language finished loading.
40
+ * @returns The count, which only ever grows.
41
+ */
42
+ export declare function messagesVersion(): number;
43
+ /**
44
+ * Be told whenever the text of the page changes.
45
+ * @param listener - Called after each change.
46
+ * @returns The function that stops it.
47
+ */
48
+ export declare function subscribeToMessages(listener: () => void): () => void;
49
+ /** Say that the text of the page has changed. Never part of the public API. */
50
+ export declare function notifyMessages(): void;
51
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/i18n/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,sDAAsD;IACtD,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;IAC3E,6EAA6E;IAC7E,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAClD;AAOD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAQrE;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,cAAc,GAAG,IAAI,CAEtD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAKpE;AAED,+EAA+E;AAC/E,wBAAgB,cAAc,IAAI,IAAI,CAGrC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Where the page formats its messages from, and who is told when that changes.
3
+ *
4
+ * Ordinarily a message is read straight out of a catalog. While a translator
5
+ * has the page open, every message goes through their session instead — marked
6
+ * invisibly so the overlay can find it in the DOM, and answered with whatever
7
+ * they have typed rather than with what was published. Both the session and a
8
+ * language arriving late are changes the page has to redraw for, so they share
9
+ * one version counter and one set of listeners.
10
+ */
11
+ let session = null;
12
+ let stopListening = null;
13
+ let version = 0;
14
+ const listeners = new Set();
15
+ /**
16
+ * Format every message through a translator's session from now on.
17
+ *
18
+ * While one is set it is the session's locale the page is written in, not the
19
+ * visitor's preference, and every message carries the marker the overlay finds
20
+ * it by.
21
+ * @param active - The session, or `null` to go back to the catalogs.
22
+ */
23
+ export function setMessageSession(active) {
24
+ stopListening?.();
25
+ stopListening = null;
26
+ session = active;
27
+ if (active?.subscribe !== undefined) {
28
+ stopListening = active.subscribe(notifyMessages);
29
+ }
30
+ notifyMessages();
31
+ }
32
+ /**
33
+ * The session the page formats through, if a translator has it open.
34
+ * @returns The session, or `null`.
35
+ */
36
+ export function messageSession() {
37
+ return session;
38
+ }
39
+ /**
40
+ * How many times the text of the page has changed — a session set or dropped,
41
+ * an edit typed, a language finished loading.
42
+ * @returns The count, which only ever grows.
43
+ */
44
+ export function messagesVersion() {
45
+ return version;
46
+ }
47
+ /**
48
+ * Be told whenever the text of the page changes.
49
+ * @param listener - Called after each change.
50
+ * @returns The function that stops it.
51
+ */
52
+ export function subscribeToMessages(listener) {
53
+ listeners.add(listener);
54
+ return () => {
55
+ listeners.delete(listener);
56
+ };
57
+ }
58
+ /** Say that the text of the page has changed. Never part of the public API. */
59
+ export function notifyMessages() {
60
+ version++;
61
+ for (const listener of listeners)
62
+ listener();
63
+ }
64
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/i18n/core/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAgBH,IAAI,OAAO,GAA0B,IAAI,CAAC;AAC1C,IAAI,aAAa,GAAwB,IAAI,CAAC;AAC9C,IAAI,OAAO,GAAG,CAAC,CAAC;AAChB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;AAExC;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAA6B;IAC7D,aAAa,EAAE,EAAE,CAAC;IAClB,aAAa,GAAG,IAAI,CAAC;IACrB,OAAO,GAAG,MAAM,CAAC;IACjB,IAAI,MAAM,EAAE,SAAS,KAAK,SAAS,EAAE,CAAC;QACpC,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACnD,CAAC;IACD,cAAc,EAAE,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAoB;IACtD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxB,OAAO,GAAG,EAAE;QACV,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,cAAc;IAC5B,OAAO,EAAE,CAAC;IACV,KAAK,MAAM,QAAQ,IAAI,SAAS;QAAE,QAAQ,EAAE,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Handing a page's catalogs to a translator.
3
+ *
4
+ * `startTranslating` wants the catalogs and, beside them, whatever of the
5
+ * target language is already published — that is what tells the overlay which
6
+ * messages are still missing. The published messages of a language are exactly
7
+ * what a catalog fetches on demand, so they are gathered here rather than
8
+ * re-imported by every site.
9
+ */
10
+ import type { CatalogSource, Messages } from '../../translate/core/catalog.ts';
11
+ import type { MessageCatalog } from './messageCatalog.ts';
12
+ /** What `startTranslating` is handed. */
13
+ export interface LoadedCatalogs {
14
+ /** The catalogs, as the session registers them. */
15
+ catalogs: CatalogSource[];
16
+ /** What is already published in the locale, by catalog id. */
17
+ translations: Record<string, Messages>;
18
+ }
19
+ /**
20
+ * Fetch what each catalog already publishes in a locale.
21
+ * @param catalogs - The catalogs the page renders from.
22
+ * @param locale - The locale being translated into, which may well be one the
23
+ * family does not speak yet — then nothing is published and every message is
24
+ * offered as missing.
25
+ * @returns See {@link LoadedCatalogs}.
26
+ */
27
+ export declare function loadCatalogs(catalogs: ReadonlyArray<MessageCatalog<string>>, locale: string): Promise<LoadedCatalogs>;
28
+ //# sourceMappingURL=translateSetup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translateSetup.d.ts","sourceRoot":"","sources":["../../../src/i18n/core/translateSetup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAG/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,yCAAyC;AACzC,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,QAAQ,EAAE,aAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAC/C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,cAAc,CAAC,CAYzB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Handing a page's catalogs to a translator.
3
+ *
4
+ * `startTranslating` wants the catalogs and, beside them, whatever of the
5
+ * target language is already published — that is what tells the overlay which
6
+ * messages are still missing. The published messages of a language are exactly
7
+ * what a catalog fetches on demand, so they are gathered here rather than
8
+ * re-imported by every site.
9
+ */
10
+ import { isLanguage } from "./languages.js";
11
+ /**
12
+ * Fetch what each catalog already publishes in a locale.
13
+ * @param catalogs - The catalogs the page renders from.
14
+ * @param locale - The locale being translated into, which may well be one the
15
+ * family does not speak yet — then nothing is published and every message is
16
+ * offered as missing.
17
+ * @returns See {@link LoadedCatalogs}.
18
+ */
19
+ export async function loadCatalogs(catalogs, locale) {
20
+ const language = isLanguage(locale) ? locale : undefined;
21
+ const translations = {};
22
+ if (language !== undefined) {
23
+ const loaded = await Promise.all(catalogs.map(async (catalog) => catalog.load(language)));
24
+ for (const [index, catalog] of catalogs.entries()) {
25
+ translations[catalog.id] = loaded[index] ?? {};
26
+ }
27
+ }
28
+ return { catalogs: catalogs.map((catalog) => catalog.source), translations };
29
+ }
30
+ //# sourceMappingURL=translateSetup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translateSetup.js","sourceRoot":"","sources":["../../../src/i18n/core/translateSetup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAW5C;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,QAA+C,EAC/C,MAAc;IAEd,MAAM,QAAQ,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACzD,MAAM,YAAY,GAA6B,EAAE,CAAC;IAClD,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CACxD,CAAC;QACF,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YAClD,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { Language } from '../core/languages.ts';
3
+ /** Props of {@link LanguageSelect}. */
4
+ export interface LanguageSelectProps {
5
+ /** The language the site is written in. */
6
+ value: Language;
7
+ /** Called with the language picked. */
8
+ onChange: (language: Language) => void;
9
+ /**
10
+ * The languages on offer, for a site that is not written in all four yet.
11
+ * @default LANGUAGES
12
+ */
13
+ languages?: readonly Language[];
14
+ /**
15
+ * Whether the bar has run out of room, so the row collapses to the language
16
+ * in force and a click advances to the next.
17
+ * @default false
18
+ */
19
+ compact?: boolean;
20
+ /**
21
+ * `data-testid` of the row; each button carries it suffixed by its tag.
22
+ * @default 'language-select'
23
+ */
24
+ testId?: string;
25
+ }
26
+ /**
27
+ * The language switch of the site header: the tags themselves, the one in
28
+ * force pressed.
29
+ *
30
+ * A language names itself — `FR` in the bar, `Français` behind it — because a
31
+ * reader looking for their own language would have to know English to find it
32
+ * written any other way.
33
+ * @param props - See {@link LanguageSelectProps}.
34
+ * @returns The row.
35
+ */
36
+ export declare function LanguageSelect(props: LanguageSelectProps): ReactElement;
37
+ //# sourceMappingURL=LanguageSelect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LanguageSelect.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/LanguageSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAI1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAKrD,uCAAuC;AACvC,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,CAAC;IAChB,uCAAuC;IACvC,QAAQ,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;IACvC;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,CAoBvE"}
@@ -0,0 +1,27 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { HeaderToggle } from "../../chrome/ui/HeaderToggle.js";
3
+ import { LANGUAGES, LANGUAGE_LABELS } from "../core/languages.js";
4
+ import { useChromeT } from "./useT.js";
5
+ /**
6
+ * The language switch of the site header: the tags themselves, the one in
7
+ * force pressed.
8
+ *
9
+ * A language names itself — `FR` in the bar, `Français` behind it — because a
10
+ * reader looking for their own language would have to know English to find it
11
+ * written any other way.
12
+ * @param props - See {@link LanguageSelectProps}.
13
+ * @returns The row.
14
+ */
15
+ export function LanguageSelect(props) {
16
+ const { value, onChange, languages = LANGUAGES, compact = false, testId = 'language-select', } = props;
17
+ const t = useChromeT();
18
+ return (_jsx(HeaderToggle, { label: t('language.label'), options: languages.map(toOption), value: value, onChange: onChange, compact: compact, testId: testId }));
19
+ }
20
+ function toOption(language) {
21
+ return {
22
+ value: language,
23
+ label: language.toUpperCase(),
24
+ title: LANGUAGE_LABELS[language],
25
+ };
26
+ }
27
+ //# sourceMappingURL=LanguageSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LanguageSelect.js","sourceRoot":"","sources":["../../../src/i18n/ui/LanguageSelect.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAkC,CAAC;AAEhE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AA0BvC;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,KAA0B;IACvD,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,SAAS,GAAG,SAAS,EACrB,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,iBAAiB,GAC3B,GAAG,KAAK,CAAC;IACV,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IAEvB,OAAO,CACL,KAAC,YAAY,IACX,KAAK,EAAE,CAAC,CAAC,gBAAgB,CAAC,EAC1B,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAChC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACd,CACH,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,QAAkB;IAClC,OAAO;QACL,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,QAAQ,CAAC,WAAW,EAAE;QAC7B,KAAK,EAAE,eAAe,CAAC,QAAQ,CAAC;KACjC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type { LanguageSelectProps } from './LanguageSelect.tsx';
2
+ export { LanguageSelect } from './LanguageSelect.tsx';
3
+ export { useIsTranslating, useLanguage, useMessagesVersion, } from './useLanguage.ts';
4
+ export type { Translate } from './useT.ts';
5
+ export { translateMessage, useChromeT, useT } from './useT.ts';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { LanguageSelect } from "./LanguageSelect.js";
2
+ export { useIsTranslating, useLanguage, useMessagesVersion, } from "./useLanguage.js";
3
+ export { translateMessage, useChromeT, useT } from "./useT.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/i18n/ui/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAsB,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { Language } from '../core/languages.ts';
2
+ /**
3
+ * The language the page is written in.
4
+ *
5
+ * It is what the site declared with `SiteLanguage`, or what the address names
6
+ * when the site declared nothing — the same value every link out of the page
7
+ * carries, so the chrome is never written in a language the links deny.
8
+ * @returns The language.
9
+ */
10
+ export declare function useLanguage(): Language;
11
+ /**
12
+ * Redraw whenever the text of the page changes — a language finished loading,
13
+ * a translator typed an edit, a session was set or dropped.
14
+ * @returns The version the page was drawn at.
15
+ */
16
+ export declare function useMessagesVersion(): number;
17
+ /**
18
+ * Whether a translator has the page open, in which case the language switch
19
+ * says nothing about what is on show.
20
+ * @returns True in translate mode.
21
+ */
22
+ export declare function useIsTranslating(): boolean;
23
+ //# sourceMappingURL=useLanguage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLanguage.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/useLanguage.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAQrD;;;;;;;GAOG;AACH,wBAAgB,WAAW,IAAI,QAAQ,CAKtC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAM3C;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,OAAO,CAG1C"}
@@ -0,0 +1,36 @@
1
+ import { useSyncExternalStore } from 'react';
2
+ import { useSiteLanguage } from "../../language/ui/siteLanguageContext.js";
3
+ import { DEFAULT_LANGUAGE, isLanguage } from "../core/languages.js";
4
+ import { messageSession, messagesVersion, subscribeToMessages, } from "../core/session.js";
5
+ /**
6
+ * The language the page is written in.
7
+ *
8
+ * It is what the site declared with `SiteLanguage`, or what the address names
9
+ * when the site declared nothing — the same value every link out of the page
10
+ * carries, so the chrome is never written in a language the links deny.
11
+ * @returns The language.
12
+ */
13
+ export function useLanguage() {
14
+ const declared = useSiteLanguage();
15
+ return declared !== undefined && isLanguage(declared)
16
+ ? declared
17
+ : DEFAULT_LANGUAGE;
18
+ }
19
+ /**
20
+ * Redraw whenever the text of the page changes — a language finished loading,
21
+ * a translator typed an edit, a session was set or dropped.
22
+ * @returns The version the page was drawn at.
23
+ */
24
+ export function useMessagesVersion() {
25
+ return useSyncExternalStore(subscribeToMessages, messagesVersion, messagesVersion);
26
+ }
27
+ /**
28
+ * Whether a translator has the page open, in which case the language switch
29
+ * says nothing about what is on show.
30
+ * @returns True in translate mode.
31
+ */
32
+ export function useIsTranslating() {
33
+ useMessagesVersion();
34
+ return messageSession() !== null;
35
+ }
36
+ //# sourceMappingURL=useLanguage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLanguage.js","sourceRoot":"","sources":["../../../src/i18n/ui/useLanguage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EACL,cAAc,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAE5B;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC;IACnC,OAAO,QAAQ,KAAK,SAAS,IAAI,UAAU,CAAC,QAAQ,CAAC;QACnD,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,gBAAgB,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,oBAAoB,CACzB,mBAAmB,EACnB,eAAe,EACf,eAAe,CAChB,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,gBAAgB;IAC9B,kBAAkB,EAAE,CAAC;IACrB,OAAO,cAAc,EAAE,KAAK,IAAI,CAAC;AACnC,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { ChromeKey } from '../core/chromeCatalog.ts';
2
+ import type { Language, LooseKey, MessageValues, TranslateOptions } from '../core/index.ts';
3
+ import type { MessageCatalog } from '../core/messageCatalog.ts';
4
+ /**
5
+ * What a component reads its text with.
6
+ *
7
+ * `t(key)` is a key the catalog declares, checked at compile time.
8
+ * `t.or(key, fallback)` is a key built from the data — a site's id, an
9
+ * element's symbol — which the catalog may not have caught up with yet; it
10
+ * reads as the fallback rather than as a raw key.
11
+ */
12
+ export type Translate<TKey extends string> = ((key: LooseKey<TKey>, values?: MessageValues) => string) & {
13
+ or: (key: string, fallback: string, values?: MessageValues) => string;
14
+ };
15
+ /**
16
+ * The formatter of a catalog's text, in the language the page is written in.
17
+ *
18
+ * It is meant to be called while rendering, never kept in a module constant:
19
+ * the language and a translator's edits both change under the page, and only a
20
+ * render picks them up.
21
+ * @param catalog - The catalog to read, typed by its English keys.
22
+ * @returns See {@link Translate}.
23
+ */
24
+ export declare function useT<TKey extends string>(catalog: MessageCatalog<TKey>): Translate<TKey>;
25
+ /**
26
+ * The formatter of this library's own text — the header, the Tools menu, the
27
+ * share dialog, the About page.
28
+ *
29
+ * A site reads it for a word it shows beside the chrome's own, so `Share` and
30
+ * `Cite` are written the same way everywhere.
31
+ * @returns `t(key, values)`, typed by the chrome's English catalog.
32
+ */
33
+ export declare function useChromeT(): Translate<ChromeKey>;
34
+ /**
35
+ * One message of a catalog, outside a component.
36
+ *
37
+ * Only for the rare place a hook cannot go — a label computed in a module
38
+ * helper, a message thrown from a worker. A component uses {@link useT}, which
39
+ * redraws when the language does.
40
+ * @param catalog - The catalog to read.
41
+ * @param key - Key to read.
42
+ * @param language - Language to read it in.
43
+ * @param options - See `TranslateOptions`.
44
+ * @returns The text.
45
+ */
46
+ export declare function translateMessage<TKey extends string>(catalog: MessageCatalog<TKey>, key: LooseKey<TKey>, language: Language, options?: TranslateOptions): string;
47
+ //# sourceMappingURL=useT.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useT.d.ts","sourceRoot":"","sources":["../../../src/i18n/ui/useT.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EACV,QAAQ,EACR,QAAQ,EACR,aAAa,EACb,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAIhE;;;;;;;GAOG;AACH,MAAM,MAAM,SAAS,CAAC,IAAI,SAAS,MAAM,IAAI,CAAC,CAC5C,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,EACnB,MAAM,CAAC,EAAE,aAAa,KACnB,MAAM,CAAC,GAAG;IACb,EAAE,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,aAAa,KAAK,MAAM,CAAC;CACvE,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,IAAI,SAAS,MAAM,EACtC,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,GAC5B,SAAS,CAAC,IAAI,CAAC,CAKjB;AAeD;;;;;;;GAOG;AACH,wBAAgB,UAAU,IAAI,SAAS,CAAC,SAAS,CAAC,CAEjD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,OAAO,EAAE,cAAc,CAAC,IAAI,CAAC,EAC7B,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,gBAAgB,GACzB,MAAM,CAER"}
@@ -0,0 +1,51 @@
1
+ import { CHROME_CATALOG } from "../core/chromeCatalog.js";
2
+ import { useLanguage, useMessagesVersion } from "./useLanguage.js";
3
+ /**
4
+ * The formatter of a catalog's text, in the language the page is written in.
5
+ *
6
+ * It is meant to be called while rendering, never kept in a module constant:
7
+ * the language and a translator's edits both change under the page, and only a
8
+ * render picks them up.
9
+ * @param catalog - The catalog to read, typed by its English keys.
10
+ * @returns See {@link Translate}.
11
+ */
12
+ export function useT(catalog) {
13
+ const language = useLanguage();
14
+ useMessagesVersion();
15
+ catalog.prefetch(language);
16
+ return translator(catalog, language);
17
+ }
18
+ // Built outside the hook, because the `or` form is a property of the function
19
+ // itself and a render may not write to a value it has just read.
20
+ function translator(catalog, language) {
21
+ const translate = (key, values) => catalog.translate(key, language, { values });
22
+ translate.or = (key, fallback, values) => catalog.translate(key, language, { fallback, values });
23
+ return translate;
24
+ }
25
+ /**
26
+ * The formatter of this library's own text — the header, the Tools menu, the
27
+ * share dialog, the About page.
28
+ *
29
+ * A site reads it for a word it shows beside the chrome's own, so `Share` and
30
+ * `Cite` are written the same way everywhere.
31
+ * @returns `t(key, values)`, typed by the chrome's English catalog.
32
+ */
33
+ export function useChromeT() {
34
+ return useT(CHROME_CATALOG);
35
+ }
36
+ /**
37
+ * One message of a catalog, outside a component.
38
+ *
39
+ * Only for the rare place a hook cannot go — a label computed in a module
40
+ * helper, a message thrown from a worker. A component uses {@link useT}, which
41
+ * redraws when the language does.
42
+ * @param catalog - The catalog to read.
43
+ * @param key - Key to read.
44
+ * @param language - Language to read it in.
45
+ * @param options - See `TranslateOptions`.
46
+ * @returns The text.
47
+ */
48
+ export function translateMessage(catalog, key, language, options) {
49
+ return catalog.translate(key, language, options);
50
+ }
51
+ //# sourceMappingURL=useT.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useT.js","sourceRoot":"","sources":["../../../src/i18n/ui/useT.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAS1D,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAiBnE;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAClB,OAA6B;IAE7B,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,kBAAkB,EAAE,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC3B,OAAO,UAAU,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACvC,CAAC;AAED,8EAA8E;AAC9E,iEAAiE;AACjE,SAAS,UAAU,CACjB,OAA6B,EAC7B,QAAkB;IAElB,MAAM,SAAS,GAAG,CAAC,GAAmB,EAAE,MAAsB,EAAE,EAAE,CAChE,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/C,SAAS,CAAC,EAAE,GAAG,CAAC,GAAW,EAAE,QAAgB,EAAE,MAAsB,EAAE,EAAE,CACvE,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACzD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAA6B,EAC7B,GAAmB,EACnB,QAAkB,EAClB,OAA0B;IAE1B,OAAO,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AACnD,CAAC"}