react-cheminfo 0.37.0 → 0.39.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 (417) hide show
  1. package/README.md +77 -1
  2. package/bin/check-seo.mjs +43 -1
  3. package/lib/chart/ui/Axes.d.ts +19 -0
  4. package/lib/chart/ui/Axes.d.ts.map +1 -1
  5. package/lib/chart/ui/Axes.js +25 -5
  6. package/lib/chart/ui/Axes.js.map +1 -1
  7. package/lib/chrome/ui/NavMenuButton.d.ts.map +1 -1
  8. package/lib/chrome/ui/NavMenuButton.js +41 -11
  9. package/lib/chrome/ui/NavMenuButton.js.map +1 -1
  10. package/lib/chrome/ui/SiteHeader.js +24 -1
  11. package/lib/chrome/ui/SiteHeader.js.map +1 -1
  12. package/lib/chrome/ui/navItem.d.ts +7 -0
  13. package/lib/chrome/ui/navItem.d.ts.map +1 -1
  14. package/lib/chrome/ui/navItem.js.map +1 -1
  15. package/lib/citation/ui/entries.d.ts.map +1 -1
  16. package/lib/citation/ui/entries.js +6 -1
  17. package/lib/citation/ui/entries.js.map +1 -1
  18. package/lib/clipboard/ui/ClickToCopy.d.ts +11 -0
  19. package/lib/clipboard/ui/ClickToCopy.d.ts.map +1 -1
  20. package/lib/clipboard/ui/ClickToCopy.js +28 -10
  21. package/lib/clipboard/ui/ClickToCopy.js.map +1 -1
  22. package/lib/clipboard/ui/CopyButton.d.ts +2 -1
  23. package/lib/clipboard/ui/CopyButton.d.ts.map +1 -1
  24. package/lib/clipboard/ui/CopyButton.js +2 -1
  25. package/lib/clipboard/ui/CopyButton.js.map +1 -1
  26. package/lib/clipboard/ui/CopyableValue.d.ts +24 -4
  27. package/lib/clipboard/ui/CopyableValue.d.ts.map +1 -1
  28. package/lib/clipboard/ui/CopyableValue.js +35 -3
  29. package/lib/clipboard/ui/CopyableValue.js.map +1 -1
  30. package/lib/clipboard/ui/index.d.ts +1 -1
  31. package/lib/clipboard/ui/index.d.ts.map +1 -1
  32. package/lib/clipboard/ui/index.js.map +1 -1
  33. package/lib/confirm/ui/ConfirmButton.d.ts.map +1 -1
  34. package/lib/confirm/ui/ConfirmButton.js +2 -1
  35. package/lib/confirm/ui/ConfirmButton.js.map +1 -1
  36. package/lib/core.d.ts +1 -0
  37. package/lib/core.d.ts.map +1 -1
  38. package/lib/core.js +1 -0
  39. package/lib/core.js.map +1 -1
  40. package/lib/delimited/ui/TableDataButton.d.ts.map +1 -1
  41. package/lib/delimited/ui/TableDataButton.js +2 -1
  42. package/lib/delimited/ui/TableDataButton.js.map +1 -1
  43. package/lib/download/core/figureSvg.d.ts.map +1 -1
  44. package/lib/download/core/figureSvg.js +37 -12
  45. package/lib/download/core/figureSvg.js.map +1 -1
  46. package/lib/help/ui/HelpToolbarButton.d.ts.map +1 -1
  47. package/lib/help/ui/HelpToolbarButton.js +2 -1
  48. package/lib/help/ui/HelpToolbarButton.js.map +1 -1
  49. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  50. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  51. package/lib/locales/de.json +48 -5
  52. package/lib/locales/en.json +48 -5
  53. package/lib/locales/es.json +48 -5
  54. package/lib/locales/fr.json +48 -5
  55. package/lib/locales/it.json +48 -5
  56. package/lib/number/core/index.d.ts +1 -1
  57. package/lib/number/core/index.d.ts.map +1 -1
  58. package/lib/number/core/index.js +1 -1
  59. package/lib/number/core/index.js.map +1 -1
  60. package/lib/number/core/numberText.d.ts +13 -0
  61. package/lib/number/core/numberText.d.ts.map +1 -1
  62. package/lib/number/core/numberText.js +20 -0
  63. package/lib/number/core/numberText.js.map +1 -1
  64. package/lib/number/ui/NumberInput.js +1 -1
  65. package/lib/number/ui/NumberInput.js.map +1 -1
  66. package/lib/overlay/ui/OverlayIconButton.d.ts.map +1 -1
  67. package/lib/overlay/ui/OverlayIconButton.js +1 -1
  68. package/lib/overlay/ui/OverlayIconButton.js.map +1 -1
  69. package/lib/panel/ui/ClearButton.d.ts.map +1 -1
  70. package/lib/panel/ui/ClearButton.js +1 -1
  71. package/lib/panel/ui/ClearButton.js.map +1 -1
  72. package/lib/pedagogy/core/inlineMarks.d.ts +9 -5
  73. package/lib/pedagogy/core/inlineMarks.d.ts.map +1 -1
  74. package/lib/pedagogy/core/inlineMarks.js +14 -6
  75. package/lib/pedagogy/core/inlineMarks.js.map +1 -1
  76. package/lib/pedagogy/ui/GlossaryDefinition.d.ts +4 -10
  77. package/lib/pedagogy/ui/GlossaryDefinition.d.ts.map +1 -1
  78. package/lib/pedagogy/ui/GlossaryDefinition.js +7 -7
  79. package/lib/pedagogy/ui/GlossaryDefinition.js.map +1 -1
  80. package/lib/pedagogy/ui/GlossaryIndex.d.ts.map +1 -1
  81. package/lib/pedagogy/ui/GlossaryIndex.js +1 -1
  82. package/lib/pedagogy/ui/GlossaryIndex.js.map +1 -1
  83. package/lib/pedagogy/ui/GlossaryProvider.d.ts +7 -0
  84. package/lib/pedagogy/ui/GlossaryProvider.d.ts.map +1 -1
  85. package/lib/pedagogy/ui/GlossaryProvider.js +3 -2
  86. package/lib/pedagogy/ui/GlossaryProvider.js.map +1 -1
  87. package/lib/pedagogy/ui/GlossaryText.d.ts +7 -2
  88. package/lib/pedagogy/ui/GlossaryText.d.ts.map +1 -1
  89. package/lib/pedagogy/ui/GlossaryText.js +3 -2
  90. package/lib/pedagogy/ui/GlossaryText.js.map +1 -1
  91. package/lib/pedagogy/ui/InlineText.d.ts +8 -2
  92. package/lib/pedagogy/ui/InlineText.d.ts.map +1 -1
  93. package/lib/pedagogy/ui/InlineText.js +7 -2
  94. package/lib/pedagogy/ui/InlineText.js.map +1 -1
  95. package/lib/pedagogy/ui/ReferenceSectionBlock.d.ts +4 -1
  96. package/lib/pedagogy/ui/ReferenceSectionBlock.d.ts.map +1 -1
  97. package/lib/pedagogy/ui/ReferenceSectionBlock.js +2 -1
  98. package/lib/pedagogy/ui/ReferenceSectionBlock.js.map +1 -1
  99. package/lib/pedagogy/ui/SyntaxTooltip.d.ts.map +1 -1
  100. package/lib/pedagogy/ui/SyntaxTooltip.js +11 -10
  101. package/lib/pedagogy/ui/SyntaxTooltip.js.map +1 -1
  102. package/lib/pedagogy/ui/TutorialStepStrip.d.ts.map +1 -1
  103. package/lib/pedagogy/ui/TutorialStepStrip.js +18 -4
  104. package/lib/pedagogy/ui/TutorialStepStrip.js.map +1 -1
  105. package/lib/pedagogy/ui/glossaryContext.d.ts +7 -0
  106. package/lib/pedagogy/ui/glossaryContext.d.ts.map +1 -1
  107. package/lib/pedagogy/ui/glossaryContext.js.map +1 -1
  108. package/lib/pedagogy/ui/index.d.ts +1 -1
  109. package/lib/pedagogy/ui/index.d.ts.map +1 -1
  110. package/lib/pedagogy/ui/inlineSegments.d.ts +5 -0
  111. package/lib/pedagogy/ui/inlineSegments.d.ts.map +1 -1
  112. package/lib/pedagogy/ui/inlineSegments.js +2 -0
  113. package/lib/pedagogy/ui/inlineSegments.js.map +1 -1
  114. package/lib/pedagogy/ui/pedagogyStyle.d.ts +8 -9
  115. package/lib/pedagogy/ui/pedagogyStyle.d.ts.map +1 -1
  116. package/lib/pedagogy/ui/pedagogyStyle.js +10 -18
  117. package/lib/pedagogy/ui/pedagogyStyle.js.map +1 -1
  118. package/lib/range/core/index.d.ts +4 -0
  119. package/lib/range/core/index.d.ts.map +1 -0
  120. package/lib/range/core/index.js +3 -0
  121. package/lib/range/core/index.js.map +1 -0
  122. package/lib/range/core/rangeBounds.d.ts +79 -0
  123. package/lib/range/core/rangeBounds.d.ts.map +1 -0
  124. package/lib/range/core/rangeBounds.js +110 -0
  125. package/lib/range/core/rangeBounds.js.map +1 -0
  126. package/lib/range/core/rangeHistogram.d.ts +13 -0
  127. package/lib/range/core/rangeHistogram.d.ts.map +1 -0
  128. package/lib/range/core/rangeHistogram.js +39 -0
  129. package/lib/range/core/rangeHistogram.js.map +1 -0
  130. package/lib/range/ui/RangeHistogram.d.ts +20 -0
  131. package/lib/range/ui/RangeHistogram.d.ts.map +1 -0
  132. package/lib/range/ui/RangeHistogram.js +18 -0
  133. package/lib/range/ui/RangeHistogram.js.map +1 -0
  134. package/lib/range/ui/RangeSlider.d.ts +77 -0
  135. package/lib/range/ui/RangeSlider.d.ts.map +1 -0
  136. package/lib/range/ui/RangeSlider.js +60 -0
  137. package/lib/range/ui/RangeSlider.js.map +1 -0
  138. package/lib/range/ui/RangeValue.d.ts +41 -0
  139. package/lib/range/ui/RangeValue.d.ts.map +1 -0
  140. package/lib/range/ui/RangeValue.js +73 -0
  141. package/lib/range/ui/RangeValue.js.map +1 -0
  142. package/lib/range/ui/index.d.ts +3 -0
  143. package/lib/range/ui/index.d.ts.map +1 -0
  144. package/lib/range/ui/index.js +2 -0
  145. package/lib/range/ui/index.js.map +1 -0
  146. package/lib/seo/core/documentMeta.d.ts +16 -0
  147. package/lib/seo/core/documentMeta.d.ts.map +1 -1
  148. package/lib/seo/core/documentMeta.js +18 -0
  149. package/lib/seo/core/documentMeta.js.map +1 -1
  150. package/lib/seo/core/index.d.ts +3 -1
  151. package/lib/seo/core/index.d.ts.map +1 -1
  152. package/lib/seo/core/index.js +2 -1
  153. package/lib/seo/core/index.js.map +1 -1
  154. package/lib/seo/core/noscript.d.ts +8 -0
  155. package/lib/seo/core/noscript.d.ts.map +1 -1
  156. package/lib/seo/core/noscript.js +10 -3
  157. package/lib/seo/core/noscript.js.map +1 -1
  158. package/lib/seo/core/pageMeta.d.ts +10 -2
  159. package/lib/seo/core/pageMeta.d.ts.map +1 -1
  160. package/lib/seo/core/pageMeta.js +12 -3
  161. package/lib/seo/core/pageMeta.js.map +1 -1
  162. package/lib/seo/core/plainDescription.d.ts +2 -2
  163. package/lib/seo/core/plainDescription.js +5 -2
  164. package/lib/seo/core/plainDescription.js.map +1 -1
  165. package/lib/seo/core/siteFiles.d.ts +32 -3
  166. package/lib/seo/core/siteFiles.d.ts.map +1 -1
  167. package/lib/seo/core/siteFiles.js +13 -4
  168. package/lib/seo/core/siteFiles.js.map +1 -1
  169. package/lib/seo/core/startDocumentMeta.js +8 -7
  170. package/lib/seo/core/startDocumentMeta.js.map +1 -1
  171. package/lib/seo/vite/prerender.d.ts +26 -4
  172. package/lib/seo/vite/prerender.d.ts.map +1 -1
  173. package/lib/seo/vite/prerender.js +100 -30
  174. package/lib/seo/vite/prerender.js.map +1 -1
  175. package/lib/share/core/devices.d.ts +41 -0
  176. package/lib/share/core/devices.d.ts.map +1 -0
  177. package/lib/share/core/devices.js +58 -0
  178. package/lib/share/core/devices.js.map +1 -0
  179. package/lib/share/core/index.d.ts +4 -0
  180. package/lib/share/core/index.d.ts.map +1 -1
  181. package/lib/share/core/index.js +2 -0
  182. package/lib/share/core/index.js.map +1 -1
  183. package/lib/share/core/regions.d.ts +43 -0
  184. package/lib/share/core/regions.d.ts.map +1 -0
  185. package/lib/share/core/regions.js +71 -0
  186. package/lib/share/core/regions.js.map +1 -0
  187. package/lib/share/ui/HiddenPartsProvider.d.ts.map +1 -1
  188. package/lib/share/ui/HiddenPartsProvider.js +4 -1
  189. package/lib/share/ui/HiddenPartsProvider.js.map +1 -1
  190. package/lib/share/ui/PagePart.d.ts.map +1 -1
  191. package/lib/share/ui/PagePart.js +10 -1
  192. package/lib/share/ui/PagePart.js.map +1 -1
  193. package/lib/share/ui/ShareButton.d.ts.map +1 -1
  194. package/lib/share/ui/ShareButton.js +3 -4
  195. package/lib/share/ui/ShareButton.js.map +1 -1
  196. package/lib/share/ui/ShareConfigOptions.d.ts +6 -1
  197. package/lib/share/ui/ShareConfigOptions.d.ts.map +1 -1
  198. package/lib/share/ui/ShareConfigOptions.js +6 -13
  199. package/lib/share/ui/ShareConfigOptions.js.map +1 -1
  200. package/lib/share/ui/ShareDialog.d.ts +14 -0
  201. package/lib/share/ui/ShareDialog.d.ts.map +1 -1
  202. package/lib/share/ui/ShareDialog.js +3 -3
  203. package/lib/share/ui/ShareDialog.js.map +1 -1
  204. package/lib/share/ui/ShareDialogContent.d.ts +2 -2
  205. package/lib/share/ui/ShareDialogContent.d.ts.map +1 -1
  206. package/lib/share/ui/ShareDialogContent.js +36 -30
  207. package/lib/share/ui/ShareDialogContent.js.map +1 -1
  208. package/lib/share/ui/ShareLinkBar.d.ts +21 -0
  209. package/lib/share/ui/ShareLinkBar.d.ts.map +1 -0
  210. package/lib/share/ui/ShareLinkBar.js +32 -0
  211. package/lib/share/ui/ShareLinkBar.js.map +1 -0
  212. package/lib/share/ui/SharePanes.d.ts +17 -0
  213. package/lib/share/ui/SharePanes.d.ts.map +1 -0
  214. package/lib/share/ui/SharePanes.js +27 -0
  215. package/lib/share/ui/SharePanes.js.map +1 -0
  216. package/lib/share/ui/SharePartOptions.d.ts +9 -3
  217. package/lib/share/ui/SharePartOptions.d.ts.map +1 -1
  218. package/lib/share/ui/SharePartOptions.js +12 -16
  219. package/lib/share/ui/SharePartOptions.js.map +1 -1
  220. package/lib/share/ui/SharePartRow.d.ts +37 -0
  221. package/lib/share/ui/SharePartRow.d.ts.map +1 -0
  222. package/lib/share/ui/SharePartRow.js +25 -0
  223. package/lib/share/ui/SharePartRow.js.map +1 -0
  224. package/lib/share/ui/SharePresetTabs.d.ts +10 -7
  225. package/lib/share/ui/SharePresetTabs.d.ts.map +1 -1
  226. package/lib/share/ui/SharePresetTabs.js +17 -17
  227. package/lib/share/ui/SharePresetTabs.js.map +1 -1
  228. package/lib/share/ui/SharePreview.d.ts +32 -0
  229. package/lib/share/ui/SharePreview.d.ts.map +1 -0
  230. package/lib/share/ui/SharePreview.js +104 -0
  231. package/lib/share/ui/SharePreview.js.map +1 -0
  232. package/lib/share/ui/SharePreviewDevices.d.ts +20 -0
  233. package/lib/share/ui/SharePreviewDevices.d.ts.map +1 -0
  234. package/lib/share/ui/SharePreviewDevices.js +40 -0
  235. package/lib/share/ui/SharePreviewDevices.js.map +1 -0
  236. package/lib/share/ui/index.d.ts +1 -0
  237. package/lib/share/ui/index.d.ts.map +1 -1
  238. package/lib/share/ui/index.js.map +1 -1
  239. package/lib/share/ui/shareMarking.d.ts +14 -0
  240. package/lib/share/ui/shareMarking.d.ts.map +1 -0
  241. package/lib/share/ui/shareMarking.js +17 -0
  242. package/lib/share/ui/shareMarking.js.map +1 -0
  243. package/lib/share/ui/useShareRegionReports.d.ts +12 -0
  244. package/lib/share/ui/useShareRegionReports.d.ts.map +1 -0
  245. package/lib/share/ui/useShareRegionReports.js +73 -0
  246. package/lib/share/ui/useShareRegionReports.js.map +1 -0
  247. package/lib/shared/ui/ActionTooltip.d.ts +42 -0
  248. package/lib/shared/ui/ActionTooltip.d.ts.map +1 -0
  249. package/lib/shared/ui/ActionTooltip.js +21 -0
  250. package/lib/shared/ui/ActionTooltip.js.map +1 -0
  251. package/lib/shared/ui/index.d.ts +4 -0
  252. package/lib/shared/ui/index.d.ts.map +1 -1
  253. package/lib/shared/ui/index.js +2 -0
  254. package/lib/shared/ui/index.js.map +1 -1
  255. package/lib/shared/ui/useActionTooltip.d.ts +48 -0
  256. package/lib/shared/ui/useActionTooltip.d.ts.map +1 -0
  257. package/lib/shared/ui/useActionTooltip.js +78 -0
  258. package/lib/shared/ui/useActionTooltip.js.map +1 -0
  259. package/lib/structure/core/index.d.ts +2 -0
  260. package/lib/structure/core/index.d.ts.map +1 -1
  261. package/lib/structure/core/index.js +1 -0
  262. package/lib/structure/core/index.js.map +1 -1
  263. package/lib/structure/core/sourceMolecule.d.ts +18 -0
  264. package/lib/structure/core/sourceMolecule.d.ts.map +1 -0
  265. package/lib/structure/core/sourceMolecule.js +26 -0
  266. package/lib/structure/core/sourceMolecule.js.map +1 -0
  267. package/lib/structure/core/structureNotations.d.ts +57 -0
  268. package/lib/structure/core/structureNotations.d.ts.map +1 -0
  269. package/lib/structure/core/structureNotations.js +74 -0
  270. package/lib/structure/core/structureNotations.js.map +1 -0
  271. package/lib/structure/core/structurePicture.d.ts +49 -0
  272. package/lib/structure/core/structurePicture.d.ts.map +1 -0
  273. package/lib/structure/core/structurePicture.js +83 -0
  274. package/lib/structure/core/structurePicture.js.map +1 -0
  275. package/lib/structure/ui/EditorExportButton.d.ts +23 -0
  276. package/lib/structure/ui/EditorExportButton.d.ts.map +1 -0
  277. package/lib/structure/ui/EditorExportButton.js +23 -0
  278. package/lib/structure/ui/EditorExportButton.js.map +1 -0
  279. package/lib/structure/ui/EditorHelpButton.d.ts +5 -2
  280. package/lib/structure/ui/EditorHelpButton.d.ts.map +1 -1
  281. package/lib/structure/ui/EditorHelpButton.js +8 -9
  282. package/lib/structure/ui/EditorHelpButton.js.map +1 -1
  283. package/lib/structure/ui/StructureEditor.d.ts +8 -0
  284. package/lib/structure/ui/StructureEditor.d.ts.map +1 -1
  285. package/lib/structure/ui/StructureEditor.js +26 -3
  286. package/lib/structure/ui/StructureEditor.js.map +1 -1
  287. package/lib/structure/ui/StructureExportDialog.d.ts +34 -0
  288. package/lib/structure/ui/StructureExportDialog.d.ts.map +1 -0
  289. package/lib/structure/ui/StructureExportDialog.js +43 -0
  290. package/lib/structure/ui/StructureExportDialog.js.map +1 -0
  291. package/lib/structure/ui/StructureExportPanel.d.ts +37 -0
  292. package/lib/structure/ui/StructureExportPanel.d.ts.map +1 -0
  293. package/lib/structure/ui/StructureExportPanel.js +75 -0
  294. package/lib/structure/ui/StructureExportPanel.js.map +1 -0
  295. package/lib/structure/ui/StructureNotationRow.d.ts +22 -0
  296. package/lib/structure/ui/StructureNotationRow.d.ts.map +1 -0
  297. package/lib/structure/ui/StructureNotationRow.js +34 -0
  298. package/lib/structure/ui/StructureNotationRow.js.map +1 -0
  299. package/lib/structure/ui/StructurePicturePane.d.ts +23 -0
  300. package/lib/structure/ui/StructurePicturePane.d.ts.map +1 -0
  301. package/lib/structure/ui/StructurePicturePane.js +113 -0
  302. package/lib/structure/ui/StructurePicturePane.js.map +1 -0
  303. package/lib/structure/ui/StructureSvg.d.ts.map +1 -1
  304. package/lib/structure/ui/StructureSvg.js +2 -18
  305. package/lib/structure/ui/StructureSvg.js.map +1 -1
  306. package/lib/structure/ui/ToolbarTooltip.d.ts.map +1 -1
  307. package/lib/structure/ui/ToolbarTooltip.js +1 -2
  308. package/lib/structure/ui/ToolbarTooltip.js.map +1 -1
  309. package/lib/structure/ui/index.d.ts +7 -3
  310. package/lib/structure/ui/index.d.ts.map +1 -1
  311. package/lib/structure/ui/index.js +5 -3
  312. package/lib/structure/ui/index.js.map +1 -1
  313. package/lib/structure/ui/structureNotationText.d.ts +23 -0
  314. package/lib/structure/ui/structureNotationText.d.ts.map +1 -0
  315. package/lib/structure/ui/structureNotationText.js +42 -0
  316. package/lib/structure/ui/structureNotationText.js.map +1 -0
  317. package/lib/structure/ui/useEditorStructure.d.ts +37 -0
  318. package/lib/structure/ui/useEditorStructure.d.ts.map +1 -0
  319. package/lib/structure/ui/useEditorStructure.js +70 -0
  320. package/lib/structure/ui/useEditorStructure.js.map +1 -0
  321. package/lib/ui.d.ts +1 -0
  322. package/lib/ui.d.ts.map +1 -1
  323. package/lib/ui.js +1 -0
  324. package/lib/ui.js.map +1 -1
  325. package/package.json +1 -1
  326. package/src/chart/ui/Axes.tsx +53 -5
  327. package/src/chrome/ui/NavMenuButton.tsx +61 -18
  328. package/src/chrome/ui/SiteHeader.tsx +37 -1
  329. package/src/chrome/ui/navItem.ts +7 -0
  330. package/src/citation/ui/entries.tsx +10 -2
  331. package/src/clipboard/ui/ClickToCopy.tsx +47 -13
  332. package/src/clipboard/ui/CopyButton.tsx +4 -2
  333. package/src/clipboard/ui/CopyableValue.tsx +88 -13
  334. package/src/clipboard/ui/index.ts +5 -1
  335. package/src/confirm/ui/ConfirmButton.tsx +2 -0
  336. package/src/core.ts +1 -0
  337. package/src/delimited/ui/TableDataButton.tsx +2 -1
  338. package/src/download/core/figureSvg.ts +42 -10
  339. package/src/help/ui/HelpToolbarButton.tsx +2 -1
  340. package/src/locales/de.json +48 -5
  341. package/src/locales/en.json +48 -5
  342. package/src/locales/es.json +48 -5
  343. package/src/locales/fr.json +48 -5
  344. package/src/locales/it.json +48 -5
  345. package/src/number/core/index.ts +1 -0
  346. package/src/number/core/numberText.ts +20 -0
  347. package/src/number/ui/NumberInput.tsx +1 -1
  348. package/src/overlay/ui/OverlayIconButton.tsx +1 -0
  349. package/src/panel/ui/ClearButton.tsx +1 -0
  350. package/src/pedagogy/core/inlineMarks.ts +15 -7
  351. package/src/pedagogy/ui/GlossaryDefinition.tsx +8 -18
  352. package/src/pedagogy/ui/GlossaryIndex.tsx +0 -1
  353. package/src/pedagogy/ui/GlossaryProvider.tsx +10 -2
  354. package/src/pedagogy/ui/GlossaryText.tsx +10 -2
  355. package/src/pedagogy/ui/InlineText.tsx +21 -4
  356. package/src/pedagogy/ui/ReferenceSectionBlock.tsx +8 -2
  357. package/src/pedagogy/ui/SyntaxTooltip.tsx +11 -9
  358. package/src/pedagogy/ui/TutorialStepStrip.tsx +50 -18
  359. package/src/pedagogy/ui/glossaryContext.ts +7 -0
  360. package/src/pedagogy/ui/index.ts +1 -1
  361. package/src/pedagogy/ui/inlineSegments.tsx +7 -0
  362. package/src/pedagogy/ui/pedagogyStyle.ts +12 -24
  363. package/src/range/core/index.ts +11 -0
  364. package/src/range/core/rangeBounds.ts +143 -0
  365. package/src/range/core/rangeHistogram.ts +38 -0
  366. package/src/range/ui/RangeHistogram.tsx +49 -0
  367. package/src/range/ui/RangeSlider.tsx +209 -0
  368. package/src/range/ui/RangeValue.tsx +166 -0
  369. package/src/range/ui/index.ts +2 -0
  370. package/src/seo/core/documentMeta.ts +22 -0
  371. package/src/seo/core/index.ts +8 -1
  372. package/src/seo/core/noscript.ts +20 -2
  373. package/src/seo/core/pageMeta.ts +29 -5
  374. package/src/seo/core/plainDescription.ts +4 -2
  375. package/src/seo/core/siteFiles.ts +45 -10
  376. package/src/seo/core/startDocumentMeta.ts +9 -9
  377. package/src/seo/vite/prerender.ts +160 -36
  378. package/src/share/core/devices.ts +80 -0
  379. package/src/share/core/index.ts +14 -0
  380. package/src/share/core/regions.ts +87 -0
  381. package/src/share/ui/HiddenPartsProvider.tsx +6 -1
  382. package/src/share/ui/PagePart.tsx +12 -1
  383. package/src/share/ui/ShareButton.tsx +3 -6
  384. package/src/share/ui/ShareConfigOptions.tsx +25 -16
  385. package/src/share/ui/ShareDialog.tsx +17 -3
  386. package/src/share/ui/ShareDialogContent.tsx +80 -77
  387. package/src/share/ui/ShareLinkBar.tsx +70 -0
  388. package/src/share/ui/SharePanes.tsx +62 -0
  389. package/src/share/ui/SharePartOptions.tsx +25 -26
  390. package/src/share/ui/SharePartRow.tsx +78 -0
  391. package/src/share/ui/SharePresetTabs.tsx +36 -43
  392. package/src/share/ui/SharePreview.tsx +204 -0
  393. package/src/share/ui/SharePreviewDevices.tsx +70 -0
  394. package/src/share/ui/index.ts +1 -0
  395. package/src/share/ui/shareMarking.ts +18 -0
  396. package/src/share/ui/useShareRegionReports.ts +84 -0
  397. package/src/shared/ui/ActionTooltip.tsx +70 -0
  398. package/src/shared/ui/index.ts +7 -0
  399. package/src/shared/ui/useActionTooltip.ts +103 -0
  400. package/src/structure/core/index.ts +5 -0
  401. package/src/structure/core/sourceMolecule.ts +26 -0
  402. package/src/structure/core/structureNotations.ts +125 -0
  403. package/src/structure/core/structurePicture.ts +119 -0
  404. package/src/structure/ui/EditorExportButton.tsx +62 -0
  405. package/src/structure/ui/EditorHelpButton.tsx +26 -30
  406. package/src/structure/ui/StructureEditor.tsx +51 -5
  407. package/src/structure/ui/StructureExportDialog.tsx +90 -0
  408. package/src/structure/ui/StructureExportPanel.tsx +156 -0
  409. package/src/structure/ui/StructureNotationRow.tsx +74 -0
  410. package/src/structure/ui/StructurePicturePane.tsx +208 -0
  411. package/src/structure/ui/StructureSvg.tsx +3 -12
  412. package/src/structure/ui/ToolbarTooltip.tsx +1 -1
  413. package/src/structure/ui/index.ts +7 -3
  414. package/src/structure/ui/structureNotationText.ts +56 -0
  415. package/src/structure/ui/useEditorStructure.ts +119 -0
  416. package/src/ui.ts +1 -0
  417. package/styles/chrome.css +546 -11
@@ -16,8 +16,8 @@ import { HOVER_OPEN_DELAY } from './pedagogyStyle.ts';
16
16
  export interface GlossaryTextProps<TExample = GlossaryExample> {
17
17
  /**
18
18
  * Authored prose. Every `[[term]]` — or `[[term|displayed text]]` — the
19
- * glossary knows becomes a hoverable chip, and `` `code` ``, `**strong**`
20
- * and `*emphasis*` are drawn as such.
19
+ * glossary knows becomes a hoverable chip, and `` `code` ``, `{{C6H6O}}`,
20
+ * `**strong**` and `*emphasis*` are drawn as such.
21
21
  */
22
22
  text: string;
23
23
  /**
@@ -47,6 +47,11 @@ export interface GlossaryTextProps<TExample = GlossaryExample> {
47
47
  * @default the surrounding provider's, and otherwise a plain `<code>`
48
48
  */
49
49
  renderCode?: (code: string) => ReactNode;
50
+ /**
51
+ * Draws a `{{C6H6O}}` of the prose.
52
+ * @default the surrounding provider's, and otherwise the formula as typed
53
+ */
54
+ renderMf?: (mf: string) => ReactNode;
50
55
  }
51
56
 
52
57
  /**
@@ -69,6 +74,7 @@ export function GlossaryText<TExample = GlossaryExample>(
69
74
  className = 'glossary-term',
70
75
  renderExample,
71
76
  renderCode,
77
+ renderMf,
72
78
  } = props;
73
79
  const context = useGlossary();
74
80
  const terms: Glossary<unknown> = glossary ?? context.glossary;
@@ -78,6 +84,7 @@ export function GlossaryText<TExample = GlossaryExample>(
78
84
  <>
79
85
  {renderInlineSegments(segments, {
80
86
  code: renderCode ?? context.renderCode ?? plainCode,
87
+ mf: renderMf ?? context.renderMf,
81
88
  term: (term, shown) => {
82
89
  const entry = lookupGlossaryTerm(terms, term);
83
90
  if (entry === undefined) return shown;
@@ -94,6 +101,7 @@ export function GlossaryText<TExample = GlossaryExample>(
94
101
  }
95
102
  hoverOpenDelay={HOVER_OPEN_DELAY}
96
103
  placement={placement}
104
+ popoverClassName="help-tooltip"
97
105
  >
98
106
  <span className={className} style={TERM_STYLE}>
99
107
  {shown}
@@ -2,13 +2,14 @@ import type { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import { parseInlineMarks } from '../core/inlineMarks.ts';
4
4
 
5
+ import { useGlossary } from './glossaryContext.ts';
5
6
  import { plainCode, renderInlineSegments } from './inlineSegments.tsx';
6
7
 
7
8
  /** Props of {@link InlineText}. */
8
9
  export interface InlineTextProps {
9
10
  /**
10
- * Authored prose: `` `code` ``, `**strong**` and `*emphasis*`. Anything else,
11
- * `[[markers]]` included, is shown as typed.
11
+ * Authored prose: `` `code` ``, `{{C6H6O}}`, `**strong**` and `*emphasis*`.
12
+ * Anything else, `[[markers]]` included, is shown as typed.
12
13
  */
13
14
  text: string;
14
15
  /**
@@ -17,6 +18,12 @@ export interface InlineTextProps {
17
18
  * @default a plain `<code>`
18
19
  */
19
20
  renderCode?: (code: string) => ReactNode;
21
+ /**
22
+ * Draws a `{{C6H6O}}`: as a formula, with `react-mf`.
23
+ * @default the surrounding `GlossaryProvider`'s, and otherwise the formula
24
+ * as typed
25
+ */
26
+ renderMf?: (mf: string) => ReactNode;
20
27
  }
21
28
 
22
29
  /**
@@ -31,9 +38,19 @@ export interface InlineTextProps {
31
38
  * @returns The prose, with its marks drawn.
32
39
  */
33
40
  export function InlineText(props: InlineTextProps): ReactElement {
34
- const { text, renderCode = plainCode } = props;
41
+ const context = useGlossary();
42
+ const {
43
+ text,
44
+ renderCode = context.renderCode ?? plainCode,
45
+ renderMf = context.renderMf,
46
+ } = props;
35
47
 
36
48
  return (
37
- <>{renderInlineSegments(parseInlineMarks(text), { code: renderCode })}</>
49
+ <>
50
+ {renderInlineSegments(parseInlineMarks(text), {
51
+ code: renderCode,
52
+ mf: renderMf,
53
+ })}
54
+ </>
38
55
  );
39
56
  }
@@ -4,6 +4,7 @@ import { ClickToCopy } from '../../clipboard/ui/ClickToCopy.tsx';
4
4
  import { joinClassNames } from '../../shared/ui/joinClassNames.ts';
5
5
  import { TOKEN } from '../../tokens/core/familyTokens.ts';
6
6
 
7
+ import { InlineText } from './InlineText.tsx';
7
8
  import type { SyntaxTooltipContent } from './SyntaxTooltip.tsx';
8
9
  import { SyntaxTooltip } from './SyntaxTooltip.tsx';
9
10
  import { MONOSPACE } from './pedagogyStyle.ts';
@@ -12,7 +13,10 @@ import { MONOSPACE } from './pedagogyStyle.ts';
12
13
  export interface ReferenceRow {
13
14
  /** The construct itself, set in monospace. */
14
15
  syntax: string;
15
- /** What it does, in one line — short enough to read on paper. */
16
+ /**
17
+ * What it does, in one line — short enough to read on paper. Authored prose,
18
+ * so a `{{C6H6O}}` in it is drawn as a formula and a `` `code` `` as code.
19
+ */
16
20
  description: string;
17
21
  /**
18
22
  * The longer story, opened by hovering the row. A sparse section is meant to
@@ -118,7 +122,9 @@ function ReferenceRowLine(props: {
118
122
  {row.syntax}
119
123
  </ClickToCopy>
120
124
  </span>
121
- <span style={DESCRIPTION_STYLE}>{row.description}</span>
125
+ <span style={DESCRIPTION_STYLE}>
126
+ <InlineText text={row.description} />
127
+ </span>
122
128
  </span>
123
129
  );
124
130
  if (row.tooltip === undefined) return line;
@@ -3,6 +3,7 @@ import { Tooltip } from '@blueprintjs/core';
3
3
  import type { CSSProperties, ReactElement, ReactNode } from 'react';
4
4
 
5
5
  import { useChromeT } from '../../i18n/ui/useT.ts';
6
+ import { TOKEN } from '../../tokens/core/familyTokens.ts';
6
7
  import type { GlossaryExample } from '../core/glossary.ts';
7
8
 
8
9
  import { HOVER_OPEN_DELAY, MONOSPACE, PROSE_INK } from './pedagogyStyle.ts';
@@ -98,6 +99,7 @@ export function SyntaxTooltip(props: SyntaxTooltipProps): ReactElement {
98
99
  hoverOpenDelay={HOVER_OPEN_DELAY}
99
100
  placement={placement}
100
101
  isOpen={isOpen}
102
+ popoverClassName="help-tooltip"
101
103
  >
102
104
  {children}
103
105
  </Tooltip>
@@ -164,7 +166,6 @@ const BODY_STYLE: CSSProperties = {
164
166
  display: 'flex',
165
167
  flexDirection: 'column',
166
168
  gap: 6,
167
- maxWidth: 360,
168
169
  };
169
170
 
170
171
  const HEADER_STYLE: CSSProperties = {
@@ -175,9 +176,10 @@ const HEADER_STYLE: CSSProperties = {
175
176
  };
176
177
 
177
178
  const SYNTAX_STYLE: CSSProperties = {
178
- background: PROSE_INK.tooltip.rule,
179
+ background: TOKEN.surfaceSunken,
180
+ border: `1px solid ${PROSE_INK.rule}`,
179
181
  borderRadius: 3,
180
- color: '#ffffff',
182
+ color: PROSE_INK.code,
181
183
  fontFamily: MONOSPACE,
182
184
  fontSize: 14,
183
185
  fontWeight: 600,
@@ -187,20 +189,20 @@ const SYNTAX_STYLE: CSSProperties = {
187
189
  const NAME_STYLE: CSSProperties = { fontWeight: 600, fontSize: 13 };
188
190
 
189
191
  const TAG_STYLE: CSSProperties = {
190
- color: PROSE_INK.tooltip.muted,
192
+ color: PROSE_INK.muted,
191
193
  fontSize: 11,
192
194
  };
193
195
 
194
196
  const SUMMARY_STYLE: CSSProperties = { fontSize: 12, lineHeight: 1.4 };
195
197
 
196
198
  const DETAIL_STYLE: CSSProperties = {
197
- color: PROSE_INK.tooltip.text,
199
+ color: PROSE_INK.text,
198
200
  fontSize: 12,
199
201
  lineHeight: 1.45,
200
202
  };
201
203
 
202
204
  const EXAMPLE_STYLE: CSSProperties = {
203
- borderTop: `1px solid ${PROSE_INK.tooltip.rule}`,
205
+ borderTop: `1px solid ${PROSE_INK.rule}`,
204
206
  display: 'flex',
205
207
  flexDirection: 'column',
206
208
  gap: 2,
@@ -210,18 +212,18 @@ const EXAMPLE_STYLE: CSSProperties = {
210
212
  const ROW_STYLE: CSSProperties = { display: 'flex', gap: 6, fontSize: 12 };
211
213
 
212
214
  const LABEL_STYLE: CSSProperties = {
213
- color: PROSE_INK.tooltip.muted,
215
+ color: PROSE_INK.muted,
214
216
  flex: '0 0 68px',
215
217
  };
216
218
 
217
219
  const VALUE_STYLE: CSSProperties = {
218
- color: PROSE_INK.tooltip.text,
220
+ color: PROSE_INK.text,
219
221
  fontFamily: MONOSPACE,
220
222
  overflowWrap: 'anywhere',
221
223
  };
222
224
 
223
225
  const NOTE_STYLE: CSSProperties = {
224
- color: PROSE_INK.tooltip.muted,
226
+ color: PROSE_INK.muted,
225
227
  fontSize: 12,
226
228
  fontStyle: 'italic',
227
229
  marginTop: 2,
@@ -1,8 +1,9 @@
1
- import { Button, Tag, Tooltip } from '@blueprintjs/core';
1
+ import { Button, Tag } from '@blueprintjs/core';
2
2
  import type { CSSProperties, ReactElement, ReactNode } from 'react';
3
3
 
4
4
  import { clamp } from '../../format/core/clamp.ts';
5
5
  import { useChromeT } from '../../i18n/ui/useT.ts';
6
+ import { ActionTooltip } from '../../shared/ui/ActionTooltip.tsx';
6
7
  import { TOKEN } from '../../tokens/core/familyTokens.ts';
7
8
  import type { ExerciseLevel } from '../core/types.ts';
8
9
 
@@ -150,24 +151,14 @@ function LevelStrip(props: LevelStripProps): ReactElement {
150
151
  const step = steps[position] as TutorialStripStep;
151
152
  const active = position === activeIndex;
152
153
  buttons.push(
153
- <Tooltip
154
+ <StepButton
154
155
  key={step.id ?? position}
155
- content={step.title}
156
- hoverOpenDelay={HOVER_OPEN_DELAY}
157
- placement="bottom"
158
- >
159
- <button
160
- type="button"
161
- aria-label={`Step ${position + 1}: ${step.title}`}
162
- aria-current={active ? 'step' : undefined}
163
- style={numberStyle(colours, active)}
164
- onClick={() => {
165
- onSelect(position);
166
- }}
167
- >
168
- {position + 1}
169
- </button>
170
- </Tooltip>,
156
+ step={step}
157
+ position={position}
158
+ colours={colours}
159
+ active={active}
160
+ onSelect={onSelect}
161
+ />,
171
162
  );
172
163
  }
173
164
 
@@ -179,6 +170,47 @@ function LevelStrip(props: LevelStripProps): ReactElement {
179
170
  );
180
171
  }
181
172
 
173
+ interface StepButtonProps {
174
+ step: TutorialStripStep;
175
+ position: number;
176
+ colours: TutorialLevelColours;
177
+ active: boolean;
178
+ onSelect: (index: number) => void;
179
+ }
180
+
181
+ /**
182
+ * One numbered step, naming itself on hover.
183
+ *
184
+ * The name is held by {@link ActionTooltip} rather than by Blueprint: pressing
185
+ * a number within the hover delay would otherwise open the card afterwards,
186
+ * over the step it has just walked away from.
187
+ * @param props - The step, where it sits, and what picking it does.
188
+ * @returns The button.
189
+ */
190
+ function StepButton(props: StepButtonProps): ReactElement {
191
+ const { step, position, colours, active, onSelect } = props;
192
+
193
+ return (
194
+ <ActionTooltip
195
+ content={step.title}
196
+ delay={HOVER_OPEN_DELAY}
197
+ placement="bottom"
198
+ >
199
+ <button
200
+ type="button"
201
+ aria-label={`Step ${position + 1}: ${step.title}`}
202
+ aria-current={active ? 'step' : undefined}
203
+ style={numberStyle(colours, active)}
204
+ onClick={() => {
205
+ onSelect(position);
206
+ }}
207
+ >
208
+ {position + 1}
209
+ </button>
210
+ </ActionTooltip>
211
+ );
212
+ }
213
+
182
214
  function positionsOfLevel(
183
215
  steps: readonly TutorialStripStep[],
184
216
  level: ExerciseLevel,
@@ -26,6 +26,13 @@ export interface GlossaryContextValue {
26
26
  * @default undefined — a plain `<code>`
27
27
  */
28
28
  renderCode?: (code: string) => ReactNode;
29
+ /**
30
+ * Draws a `{{C6H6O}}` of the prose. A chemistry site passes
31
+ * `(mf) => <MF mf={mf} />` from `react-mf` here, once, so that every formula
32
+ * below reads as a formula rather than as a line of digits.
33
+ * @default undefined — the formula as typed
34
+ */
35
+ renderMf?: (mf: string) => ReactNode;
29
36
  }
30
37
 
31
38
  /**
@@ -41,7 +41,7 @@ export type {
41
41
  SyntaxTooltipProps,
42
42
  } from './SyntaxTooltip.tsx';
43
43
  export { SyntaxTooltip } from './SyntaxTooltip.tsx';
44
- export type { ProseTone } from './pedagogyStyle.ts';
44
+ export type { ProseInk } from './pedagogyStyle.ts';
45
45
  export type { TestCaseListProps } from './TestCaseList.tsx';
46
46
  export { TestCaseList } from './TestCaseList.tsx';
47
47
  export type {
@@ -7,6 +7,11 @@ import type { InlineSegment } from '../core/inlineMarks.ts';
7
7
  interface InlineRenderers {
8
8
  /** Draws a code span, from the text between its backticks. */
9
9
  code: (code: string) => ReactNode;
10
+ /**
11
+ * Draws a molecular formula, from the text between its braces.
12
+ * @default undefined — the formula as typed, which no chemistry site wants
13
+ */
14
+ mf?: (mf: string) => ReactNode;
10
15
  /**
11
16
  * Draws a glossary marker, from its lowercased term and the text to show.
12
17
  * @default undefined — the text, as plain prose
@@ -53,6 +58,8 @@ function renderSegment(
53
58
  return segment.text;
54
59
  case 'code':
55
60
  return renderers.code(segment.text);
61
+ case 'mf':
62
+ return renderers.mf === undefined ? segment.mf : renderers.mf(segment.mf);
56
63
  case 'term':
57
64
  return renderers.term === undefined
58
65
  ? segment.text
@@ -1,11 +1,9 @@
1
1
  /**
2
2
  * What the pedagogy components share about how they look: how long a pointer
3
3
  * rests before a definition opens, the monospace stack, and the ink prose is
4
- * set in on each of the two grounds it is shown on.
4
+ * set in.
5
5
  */
6
6
 
7
- import { Colors } from '@blueprintjs/core';
8
-
9
7
  import { TOKEN } from '../../tokens/core/familyTokens.ts';
10
8
 
11
9
  /** Long enough that the pointer can cross a chip or a row without opening it. */
@@ -15,10 +13,7 @@ export const HOVER_OPEN_DELAY = 150;
15
13
  export const MONOSPACE =
16
14
  'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace';
17
15
 
18
- /** Where prose is drawn: on the dark plate of a tooltip, or on the page. */
19
- export type ProseTone = 'tooltip' | 'page';
20
-
21
- /** The colours prose is set in on one ground. */
16
+ /** The colours prose is set in. */
22
17
  export interface ProseInk {
23
18
  /** The body of a paragraph. */
24
19
  text: string;
@@ -31,23 +26,16 @@ export interface ProseInk {
31
26
  }
32
27
 
33
28
  /**
34
- * The ink of each ground.
29
+ * The one ink, because there is one ground.
35
30
  *
36
- * A Blueprint tooltip is the same dark plate on every site, so its ink is white
37
- * at decreasing strength, read off the plate rather than off the family tokens,
38
- * which are written for a light page. The page ink is the tokens.
31
+ * A definition, a documented construct and a help card are the same job, and
32
+ * the family answers it with one card: `help-tooltip` in `chrome.css`, light,
33
+ * on a border and a shadow. So the prose here is the family's tokens wherever
34
+ * it is read — on a page, or on that card.
39
35
  */
40
- export const PROSE_INK: Readonly<Record<ProseTone, ProseInk>> = {
41
- tooltip: {
42
- text: 'rgb(255 255 255 / 82%)',
43
- muted: 'rgb(255 255 255 / 62%)',
44
- code: Colors.BLUE5,
45
- rule: 'rgb(255 255 255 / 15%)',
46
- },
47
- page: {
48
- text: TOKEN.text,
49
- muted: TOKEN.textMuted,
50
- code: TOKEN.text,
51
- rule: TOKEN.border,
52
- },
36
+ export const PROSE_INK: ProseInk = {
37
+ text: TOKEN.text,
38
+ muted: TOKEN.textMuted,
39
+ code: TOKEN.text,
40
+ rule: TOKEN.border,
53
41
  };
@@ -0,0 +1,11 @@
1
+ export type { RangeBounds, RangeDomain, RangeHandles } from './rangeBounds.ts';
2
+ export {
3
+ OPEN_RANGE,
4
+ isRangeBounded,
5
+ isRangeDomain,
6
+ movedRange,
7
+ rangeHandles,
8
+ sameRange,
9
+ settleHandles,
10
+ } from './rangeBounds.ts';
11
+ export { rangeHistogramPath } from './rangeHistogram.ts';
@@ -0,0 +1,143 @@
1
+ /**
2
+ * What a range filter keeps, and how its two handles map to it.
3
+ *
4
+ * A filter is two bounds, either of which may be left open. A handle parked at
5
+ * the end of the track is an open side rather than a bound at the track's end,
6
+ * because the track only covers the values the page knows about: a molecule
7
+ * heavier than the heaviest one in the statistics must not be cut by a filter
8
+ * nobody touched.
9
+ */
10
+
11
+ import { clamp } from '../../format/core/clamp.ts';
12
+ import { snapToStep } from '../../number/core/numberText.ts';
13
+
14
+ /** A lowest and a highest value kept, either of which may be left open. */
15
+ export interface RangeBounds {
16
+ /** The lowest value kept, or `null` when nothing is cut from below. */
17
+ readonly min: number | null;
18
+ /** The highest value kept, or `null` when nothing is cut from above. */
19
+ readonly max: number | null;
20
+ }
21
+
22
+ /** The two ends of a slider's track, low first. */
23
+ export type RangeDomain = readonly [number, number];
24
+
25
+ /** Where the two handles of a slider stand, low first. */
26
+ export type RangeHandles = readonly [number, number];
27
+
28
+ /** A range that keeps everything. */
29
+ export const OPEN_RANGE: RangeBounds = Object.freeze({ min: null, max: null });
30
+
31
+ /**
32
+ * Whether a range cuts anything at all.
33
+ * @param range - The range.
34
+ * @returns Whether either side carries a bound.
35
+ */
36
+ export function isRangeBounded(range: RangeBounds): boolean {
37
+ return range.min !== null || range.max !== null;
38
+ }
39
+
40
+ /**
41
+ * Whether two ranges keep the same values.
42
+ * @param left - One range.
43
+ * @param right - The other.
44
+ * @returns Whether both sides agree, an open side matching only an open side.
45
+ */
46
+ export function sameRange(left: RangeBounds, right: RangeBounds): boolean {
47
+ return Object.is(left.min, right.min) && Object.is(left.max, right.max);
48
+ }
49
+
50
+ /**
51
+ * Whether a track can be drawn: two finite ends, the high one above the low.
52
+ * Statistics that have not arrived yet are usually a track of `[0, 0]`.
53
+ * @param domain - The two ends.
54
+ * @returns Whether a slider can be laid along it.
55
+ */
56
+ export function isRangeDomain(domain: RangeDomain): boolean {
57
+ const [low, high] = domain;
58
+ return Number.isFinite(low) && Number.isFinite(high) && high > low;
59
+ }
60
+
61
+ /**
62
+ * Where the handles stand for a range: an open side at the end of the track,
63
+ * and a bound past the track held at its end.
64
+ * @param range - The range.
65
+ * @param domain - The track, already checked with {@link isRangeDomain}.
66
+ * @returns The two handle positions, low first.
67
+ */
68
+ export function rangeHandles(
69
+ range: RangeBounds,
70
+ domain: RangeDomain,
71
+ ): RangeHandles {
72
+ const [low, high] = domain;
73
+ const start = range.min === null ? low : clamp(range.min, low, high);
74
+ const end = range.max === null ? high : clamp(range.max, low, high);
75
+ return start <= end ? [start, end] : [end, start];
76
+ }
77
+
78
+ /**
79
+ * The range two handles stand for once they have moved.
80
+ *
81
+ * Only a handle that moved changes its side. A bound past the end of the track
82
+ * sits at that end, and dragging the other handle must not turn it into an
83
+ * open side; a handle the reader took to the end of the track, on the other
84
+ * hand, opens its side.
85
+ * @param from - The range before the handles moved.
86
+ * @param handles - Where the handles are now.
87
+ * @param domain - The track.
88
+ * @returns The range the reader asked for.
89
+ */
90
+ export function movedRange(
91
+ from: RangeBounds,
92
+ handles: RangeHandles,
93
+ domain: RangeDomain,
94
+ ): RangeBounds {
95
+ const [low, high] = domain;
96
+ const [start, end] = rangeHandles(from, domain);
97
+ return {
98
+ min:
99
+ handles[0] === start ? from.min : handles[0] <= low ? null : handles[0],
100
+ max: handles[1] === end ? from.max : handles[1] >= high ? null : handles[1],
101
+ };
102
+ }
103
+
104
+ /**
105
+ * Where handles settle while they are dragged: a moved handle onto the step
106
+ * grid laid from the low end of the track, an untouched one where it stood.
107
+ *
108
+ * Snapping the untouched handle too would move a bound the reader typed, say
109
+ * `1.23` on a track stepped by `0.5`, the moment the other handle is dragged.
110
+ * The ends of the track are kept even when they are off the grid, since an end
111
+ * is what opens a side.
112
+ * @param next - Where the slider reports the handles.
113
+ * @param from - The range before the drag started.
114
+ * @param step - The grid spacing.
115
+ * @param domain - The track.
116
+ * @returns The handle positions to draw and to report.
117
+ */
118
+ export function settleHandles(
119
+ next: RangeHandles,
120
+ from: RangeBounds,
121
+ step: number,
122
+ domain: RangeDomain,
123
+ ): RangeHandles {
124
+ const [start, end] = rangeHandles(from, domain);
125
+ return [
126
+ next[0] === start ? start : snapHandle(next[0], step, domain),
127
+ next[1] === end ? end : snapHandle(next[1], step, domain),
128
+ ];
129
+ }
130
+
131
+ /**
132
+ * One handle moved onto the step grid, the ends of the track kept as they are.
133
+ * @param value - Where the handle was dropped.
134
+ * @param step - The grid spacing.
135
+ * @param domain - The track.
136
+ * @returns The position the handle settles on.
137
+ */
138
+ function snapHandle(value: number, step: number, domain: RangeDomain): number {
139
+ const [low, high] = domain;
140
+ if (value <= low) return low;
141
+ if (value >= high) return high;
142
+ return clamp(snapToStep(value, step, low), low, high);
143
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The outline of a histogram whose bins split the track into equal widths, as
3
+ * SVG path data in a box one unit wide and one unit tall.
4
+ *
5
+ * One stepped outline rather than a rectangle per bin: adjacent rectangles
6
+ * leave a hairline seam between them wherever their shared edge falls between
7
+ * two pixels, and a thousand bins would be two thousand elements.
8
+ * @param counts - One count per bin, from the low end of the track.
9
+ * @returns The path data, the tallest bin reaching the top; empty when nothing
10
+ * was counted.
11
+ */
12
+ export function rangeHistogramPath(counts: ArrayLike<number>): string {
13
+ const bins = counts.length;
14
+ let tallest = 0;
15
+ for (let index = 0; index < bins; index++) {
16
+ const count = counts[index] as number;
17
+ if (count > tallest) tallest = count;
18
+ }
19
+ if (tallest <= 0) return '';
20
+
21
+ let path = 'M0 1';
22
+ for (let index = 0; index < bins; index++) {
23
+ const count = counts[index] as number;
24
+ const height = count > 0 ? count / tallest : 0;
25
+ path += `V${trim(1 - height)}H${trim((index + 1) / bins)}`;
26
+ }
27
+ return `${path}V1Z`;
28
+ }
29
+
30
+ /**
31
+ * A coordinate written with the five decimals a box of a few hundred pixels
32
+ * can use.
33
+ * @param value - The coordinate.
34
+ * @returns Its text.
35
+ */
36
+ function trim(value: number): string {
37
+ return String(Math.round(value * 1e5) / 1e5);
38
+ }
@@ -0,0 +1,49 @@
1
+ import type { ReactElement } from 'react';
2
+ import { useId, useMemo } from 'react';
3
+
4
+ import { rangeHistogramPath } from '../core/rangeHistogram.ts';
5
+
6
+ /** What the histogram over a range slider needs. */
7
+ export interface RangeHistogramProps {
8
+ /** One count per bin, the bins splitting the track into equal widths. */
9
+ counts: ArrayLike<number>;
10
+ /** Where the kept part starts, as a fraction of the track. */
11
+ start: number;
12
+ /** Where it ends. */
13
+ end: number;
14
+ }
15
+
16
+ /**
17
+ * How the values are spread along the track, the part the handles keep drawn
18
+ * in the brand colour. The outline is drawn twice, the second copy clipped to
19
+ * the handles, so a drag moves one rectangle and the outline is never redrawn.
20
+ * @param props - See {@link RangeHistogramProps}.
21
+ * @returns The histogram, hidden from a screen reader: the values under the
22
+ * track already say what it keeps.
23
+ */
24
+ export function RangeHistogram(props: RangeHistogramProps): ReactElement {
25
+ const { counts, start, end } = props;
26
+ const clip = `range-histogram-${useId().replaceAll(/\W/g, '')}`;
27
+ const outline = useMemo(() => rangeHistogramPath(counts), [counts]);
28
+
29
+ return (
30
+ <svg
31
+ className="range-slider__histogram"
32
+ viewBox="0 0 1 1"
33
+ preserveAspectRatio="none"
34
+ aria-hidden="true"
35
+ >
36
+ <defs>
37
+ <clipPath id={clip}>
38
+ <rect x={start} y={0} width={Math.max(end - start, 0)} height={1} />
39
+ </clipPath>
40
+ </defs>
41
+ <path className="range-slider__bars" d={outline} />
42
+ <path
43
+ className="range-slider__bars range-slider__bars--kept"
44
+ d={outline}
45
+ clipPath={`url(#${clip})`}
46
+ />
47
+ </svg>
48
+ );
49
+ }