matterviz 0.4.1 → 0.4.2

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 (395) hide show
  1. package/dist/EmptyState.svelte +10 -4
  2. package/dist/FilePicker.svelte +12 -14
  3. package/dist/Icon.svelte +7 -4
  4. package/dist/MillerIndexInput.svelte +2 -2
  5. package/dist/app.css +53 -0
  6. package/dist/brillouin/BrillouinZone.svelte +75 -85
  7. package/dist/brillouin/BrillouinZone.svelte.d.ts +5 -7
  8. package/dist/brillouin/BrillouinZoneControls.svelte +3 -6
  9. package/dist/brillouin/BrillouinZoneExportPane.svelte +18 -14
  10. package/dist/brillouin/BrillouinZoneInfoPane.svelte +6 -10
  11. package/dist/brillouin/BrillouinZoneScene.svelte +26 -39
  12. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
  13. package/dist/chempot-diagram/ChemPotDiagram.svelte +33 -38
  14. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +62 -74
  15. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +1 -1
  16. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +511 -547
  17. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +1 -1
  18. package/dist/chempot-diagram/async-compute.svelte.js +1 -1
  19. package/dist/chempot-diagram/controls-state.svelte.js +1 -1
  20. package/dist/colors/index.d.ts +0 -4
  21. package/dist/colors/index.js +19 -20
  22. package/dist/composition/BarChart.svelte +37 -31
  23. package/dist/composition/BubbleChart.svelte +17 -17
  24. package/dist/composition/Composition.svelte +7 -11
  25. package/dist/composition/Formula.svelte +18 -25
  26. package/dist/composition/FormulaFilter.svelte +92 -95
  27. package/dist/composition/PieChart.svelte +55 -41
  28. package/dist/composition/format.js +1 -1
  29. package/dist/composition/index.d.ts +2 -0
  30. package/dist/composition/index.js +14 -0
  31. package/dist/composition/parse.d.ts +2 -2
  32. package/dist/composition/parse.js +11 -10
  33. package/dist/constants.js +11 -9
  34. package/dist/convex-hull/ConvexHull.svelte +12 -15
  35. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
  36. package/dist/convex-hull/ConvexHull2D.svelte +93 -92
  37. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  38. package/dist/convex-hull/ConvexHull3D.svelte +109 -140
  39. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  40. package/dist/convex-hull/ConvexHull4D.svelte +75 -94
  41. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  42. package/dist/convex-hull/ConvexHullChrome.svelte +36 -40
  43. package/dist/convex-hull/ConvexHullControls.svelte +46 -48
  44. package/dist/convex-hull/ConvexHullStats.svelte +193 -195
  45. package/dist/convex-hull/ConvexHullTooltip.svelte +5 -12
  46. package/dist/convex-hull/GasPressureControls.svelte +5 -12
  47. package/dist/convex-hull/StructurePopup.svelte +17 -21
  48. package/dist/convex-hull/StructurePopup.svelte.d.ts +2 -0
  49. package/dist/convex-hull/TemperatureSlider.svelte +4 -10
  50. package/dist/convex-hull/canvas-interactions.svelte.js +2 -1
  51. package/dist/convex-hull/helpers.d.ts +8 -10
  52. package/dist/convex-hull/helpers.js +36 -36
  53. package/dist/convex-hull/hull-state.svelte.d.ts +1 -1
  54. package/dist/convex-hull/thermodynamics.js +18 -17
  55. package/dist/coordination/CoordinationBarPlot.svelte +38 -33
  56. package/dist/coordination/CoordinationBarPlot.svelte.d.ts +1 -1
  57. package/dist/coordination/calc-coordination.d.ts +1 -1
  58. package/dist/coordination/calc-coordination.js +28 -25
  59. package/dist/element/BohrAtom.svelte +5 -8
  60. package/dist/element/ElementHeading.svelte +4 -1
  61. package/dist/element/ElementPhoto.svelte +11 -9
  62. package/dist/element/ElementStats.svelte +12 -10
  63. package/dist/element/ElementTile.svelte +24 -29
  64. package/dist/element/Nucleus.svelte +4 -2
  65. package/dist/element/data.d.ts +1 -2
  66. package/dist/element/helpers.d.ts +4 -0
  67. package/dist/element/helpers.js +18 -0
  68. package/dist/element/index.d.ts +1 -4
  69. package/dist/element/index.js +3 -18
  70. package/dist/feedback/DragOverlay.svelte +5 -5
  71. package/dist/feedback/DragOverlay.svelte.d.ts +2 -2
  72. package/dist/feedback/StatusMessage.svelte +7 -4
  73. package/dist/fermi-surface/FermiSlice.svelte +21 -18
  74. package/dist/fermi-surface/FermiSurface.svelte +14 -22
  75. package/dist/fermi-surface/FermiSurface.svelte.d.ts +5 -7
  76. package/dist/fermi-surface/FermiSurfaceControls.svelte +6 -20
  77. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  78. package/dist/fermi-surface/FermiSurfaceScene.svelte +37 -64
  79. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
  80. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +9 -6
  81. package/dist/fermi-surface/compute.js +3 -3
  82. package/dist/fermi-surface/parse.js +22 -24
  83. package/dist/heatmap-matrix/HeatmapMatrix.svelte +109 -148
  84. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +2 -2
  85. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +9 -7
  86. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +1 -1
  87. package/dist/heatmap-matrix/index.d.ts +5 -0
  88. package/dist/icons.d.ts +4 -0
  89. package/dist/icons.js +4 -0
  90. package/dist/io/ExportPane.svelte +10 -6
  91. package/dist/io/decompress.d.ts +2 -1
  92. package/dist/io/decompress.js +22 -35
  93. package/dist/io/export.d.ts +4 -0
  94. package/dist/io/export.js +5 -1
  95. package/dist/io/fetch.d.ts +0 -3
  96. package/dist/io/fetch.js +0 -11
  97. package/dist/io/index.d.ts +0 -1
  98. package/dist/io/index.js +2 -9
  99. package/dist/io/is-binary.d.ts +9 -0
  100. package/dist/io/is-binary.js +45 -1
  101. package/dist/io/url-drop.js +13 -25
  102. package/dist/isosurface/Isosurface.svelte +17 -23
  103. package/dist/isosurface/IsosurfaceControls.svelte +37 -42
  104. package/dist/isosurface/parse-vaspwave.d.ts +3 -0
  105. package/dist/isosurface/parse-vaspwave.js +138 -0
  106. package/dist/isosurface/parse.js +6 -6
  107. package/dist/labels.d.ts +6 -2
  108. package/dist/labels.js +43 -13
  109. package/dist/layout/FullscreenButton.svelte +2 -1
  110. package/dist/layout/FullscreenToggle.svelte +10 -4
  111. package/dist/layout/InfoCard.svelte +7 -18
  112. package/dist/layout/InfoTag.svelte +1 -3
  113. package/dist/layout/NumberRangeInput.svelte +46 -0
  114. package/dist/layout/NumberRangeInput.svelte.d.ts +12 -0
  115. package/dist/layout/PropertyFilter.svelte +2 -6
  116. package/dist/layout/SettingsSection.svelte +21 -17
  117. package/dist/layout/SubpageGrid.svelte +3 -1
  118. package/dist/layout/ViewerChrome.svelte +9 -10
  119. package/dist/layout/ViewerChrome.svelte.d.ts +2 -1
  120. package/dist/layout/fullscreen.js +3 -5
  121. package/dist/layout/fullscreen.svelte.js +1 -2
  122. package/dist/layout/index.d.ts +1 -0
  123. package/dist/layout/index.js +1 -0
  124. package/dist/layout/json-tree/JsonNode.svelte +8 -11
  125. package/dist/layout/json-tree/JsonTree.svelte +53 -77
  126. package/dist/layout/json-tree/JsonValue.svelte +7 -15
  127. package/dist/layout/json-tree/utils.js +14 -23
  128. package/dist/math.d.ts +2 -0
  129. package/dist/math.js +19 -0
  130. package/dist/overlays/ContextMenu.svelte +4 -2
  131. package/dist/overlays/CopyButton.svelte +11 -5
  132. package/dist/overlays/DragControlTab.svelte +6 -1
  133. package/dist/overlays/DraggablePane.svelte +81 -26
  134. package/dist/overlays/DraggablePane.svelte.d.ts +1 -0
  135. package/dist/overlays/GlassChip.svelte +30 -0
  136. package/dist/overlays/GlassChip.svelte.d.ts +8 -0
  137. package/dist/overlays/InfoPaneCards.svelte +11 -23
  138. package/dist/overlays/index.d.ts +7 -0
  139. package/dist/overlays/index.js +26 -0
  140. package/dist/overlays/portal.d.ts +2 -0
  141. package/dist/overlays/portal.js +14 -0
  142. package/dist/periodic-table/PeriodicTable.svelte +113 -145
  143. package/dist/periodic-table/PeriodicTable.svelte.d.ts +5 -3
  144. package/dist/periodic-table/PeriodicTableControls.svelte +11 -63
  145. package/dist/periodic-table/TableInset.svelte +9 -4
  146. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +50 -71
  147. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -8
  148. package/dist/phase-diagram/PhaseDiagramControls.svelte +70 -94
  149. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
  150. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +2 -1
  151. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +12 -12
  152. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +54 -58
  153. package/dist/phase-diagram/TdbInfoPanel.svelte +21 -15
  154. package/dist/phase-diagram/build-diagram.js +3 -3
  155. package/dist/phase-diagram/diagram-input.d.ts +1 -2
  156. package/dist/phase-diagram/parse.js +15 -15
  157. package/dist/phase-diagram/svg-to-diagram.js +21 -15
  158. package/dist/phase-diagram/utils.js +2 -3
  159. package/dist/plot/bar/BarPlot.svelte +430 -391
  160. package/dist/plot/bar/BarPlot.svelte.d.ts +2 -0
  161. package/dist/plot/bar/BarPlotControls.svelte +1 -3
  162. package/dist/plot/bar/BarPlotControls.svelte.d.ts +4 -6
  163. package/dist/plot/bar/SpacegroupBarPlot.svelte +29 -36
  164. package/dist/plot/bar/data.d.ts +5 -4
  165. package/dist/plot/bar/data.js +2 -1
  166. package/dist/plot/box/BoxPlot.svelte +301 -209
  167. package/dist/plot/box/BoxPlot.svelte.d.ts +2 -0
  168. package/dist/plot/box/Violin.svelte.d.ts +1 -0
  169. package/dist/plot/box/box-plot.js +1 -1
  170. package/dist/plot/core/auto-place.js +1 -1
  171. package/dist/plot/core/axis-utils.d.ts +12 -7
  172. package/dist/plot/core/axis-utils.js +48 -48
  173. package/dist/plot/core/components/AxisLabel.svelte +82 -20
  174. package/dist/plot/core/components/AxisLabel.svelte.d.ts +1 -0
  175. package/dist/plot/core/components/ColorBar.svelte +101 -106
  176. package/dist/plot/core/components/ColorScaleSelect.svelte +1 -1
  177. package/dist/plot/core/components/FillArea.svelte +10 -17
  178. package/dist/plot/core/components/HierarchyControls.svelte +249 -0
  179. package/dist/plot/{sunburst/SunburstControls.svelte.d.ts → core/components/HierarchyControls.svelte.d.ts} +12 -8
  180. package/dist/plot/core/components/InteractiveAxisLabel.svelte +1 -1
  181. package/dist/plot/core/components/InteractiveAxisLabel.svelte.d.ts +1 -1
  182. package/dist/plot/core/components/Line.svelte +18 -9
  183. package/dist/plot/core/components/Line.svelte.d.ts +2 -0
  184. package/dist/plot/core/components/PlotAxis.svelte +40 -17
  185. package/dist/plot/core/components/PlotControls.svelte +65 -41
  186. package/dist/plot/core/components/PlotLegend.svelte +31 -35
  187. package/dist/plot/core/components/PlotMarginals.svelte +616 -0
  188. package/dist/plot/core/components/PlotMarginals.svelte.d.ts +15 -0
  189. package/dist/plot/core/components/PlotTooltip.svelte +1 -1
  190. package/dist/plot/core/components/PortalSelect.svelte +4 -8
  191. package/dist/plot/core/components/ReferenceLine.svelte +27 -24
  192. package/dist/plot/core/components/ReferenceLine3D.svelte +54 -57
  193. package/dist/plot/core/components/ReferencePlane.svelte +7 -8
  194. package/dist/plot/core/components/ZeroLines.svelte +4 -8
  195. package/dist/plot/core/components/ZoomRect.svelte +1 -2
  196. package/dist/plot/core/components/index.d.ts +1 -0
  197. package/dist/plot/core/components/index.js +1 -0
  198. package/dist/plot/core/data-cleaning-signal.d.ts +46 -0
  199. package/dist/plot/core/data-cleaning-signal.js +467 -0
  200. package/dist/plot/core/data-cleaning.d.ts +2 -42
  201. package/dist/plot/core/data-cleaning.js +27 -474
  202. package/dist/plot/core/data-transform.js +9 -5
  203. package/dist/plot/core/fill-utils.d.ts +3 -1
  204. package/dist/plot/core/fill-utils.js +28 -6
  205. package/dist/plot/core/index.d.ts +1 -0
  206. package/dist/plot/core/index.js +1 -0
  207. package/dist/plot/core/interactions.js +0 -2
  208. package/dist/plot/core/layout.d.ts +3 -1
  209. package/dist/plot/core/layout.js +22 -13
  210. package/dist/plot/core/marginals.d.ts +170 -0
  211. package/dist/plot/core/marginals.js +436 -0
  212. package/dist/plot/core/reference-line.js +1 -1
  213. package/dist/plot/core/scales.d.ts +23 -0
  214. package/dist/plot/core/scales.js +39 -13
  215. package/dist/plot/core/types/fills.d.ts +101 -0
  216. package/dist/plot/core/types/fills.js +15 -0
  217. package/dist/plot/core/types/plot-3d.d.ts +87 -0
  218. package/dist/plot/core/types/plot-3d.js +4 -0
  219. package/dist/plot/core/types/reference-lines.d.ts +140 -0
  220. package/dist/plot/core/types/reference-lines.js +9 -0
  221. package/dist/plot/core/types.d.ts +29 -324
  222. package/dist/plot/core/types.js +23 -20
  223. package/dist/plot/core/utils/hierarchy-chart.d.ts +51 -0
  224. package/dist/plot/core/utils/hierarchy-chart.js +179 -0
  225. package/dist/plot/core/utils/hierarchy-labels.d.ts +20 -0
  226. package/dist/plot/core/utils/hierarchy-labels.js +99 -0
  227. package/dist/plot/core/utils/label-placement.js +2 -2
  228. package/dist/plot/histogram/Histogram.svelte +304 -325
  229. package/dist/plot/histogram/Histogram.svelte.d.ts +7 -7
  230. package/dist/plot/histogram/HistogramControls.svelte +30 -28
  231. package/dist/plot/histogram/histogram.d.ts +31 -0
  232. package/dist/plot/histogram/histogram.js +70 -0
  233. package/dist/plot/histogram/index.d.ts +1 -0
  234. package/dist/plot/histogram/index.js +1 -0
  235. package/dist/plot/index.d.ts +1 -0
  236. package/dist/plot/index.js +1 -0
  237. package/dist/plot/sankey/Sankey.svelte +78 -69
  238. package/dist/plot/sankey/Sankey.svelte.d.ts +2 -2
  239. package/dist/plot/sankey/SankeyControls.svelte +22 -16
  240. package/dist/plot/scatter/BinnedScatterPlot.svelte +263 -109
  241. package/dist/plot/scatter/BinnedScatterPlot.svelte.d.ts +7 -0
  242. package/dist/plot/scatter/ElementScatter.svelte +4 -1
  243. package/dist/plot/scatter/ScatterPlot.svelte +477 -385
  244. package/dist/plot/scatter/ScatterPlot.svelte.d.ts +2 -0
  245. package/dist/plot/scatter/ScatterPlotControls.svelte +18 -19
  246. package/dist/plot/scatter/ScatterPlotControls.svelte.d.ts +1 -1
  247. package/dist/plot/scatter/ScatterPoint.svelte +16 -9
  248. package/dist/plot/scatter/binned-scatter-types.d.ts +3 -2
  249. package/dist/plot/scatter/binned-scatter-types.js +6 -1
  250. package/dist/plot/scatter/scatter-data.d.ts +1 -1
  251. package/dist/plot/scatter/scatter-data.js +8 -7
  252. package/dist/plot/scatter-3d/ScatterPlot3D.svelte +25 -34
  253. package/dist/plot/scatter-3d/ScatterPlot3D.svelte.d.ts +2 -2
  254. package/dist/plot/scatter-3d/ScatterPlot3DControls.svelte +8 -5
  255. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte +113 -116
  256. package/dist/plot/scatter-3d/ScatterPlot3DScene.svelte.d.ts +2 -2
  257. package/dist/plot/scatter-3d/Surface3D.svelte +4 -13
  258. package/dist/plot/sunburst/Sunburst.svelte +251 -329
  259. package/dist/plot/sunburst/Sunburst.svelte.d.ts +2 -2
  260. package/dist/plot/sunburst/index.d.ts +1 -1
  261. package/dist/plot/sunburst/index.js +2 -1
  262. package/dist/plot/sunburst/render.d.ts +2 -2
  263. package/dist/plot/sunburst/render.js +47 -22
  264. package/dist/plot/sunburst/sunburst.d.ts +5 -1
  265. package/dist/plot/sunburst/sunburst.js +10 -3
  266. package/dist/plot/treemap/Treemap.svelte +907 -0
  267. package/dist/plot/treemap/Treemap.svelte.d.ts +84 -0
  268. package/dist/plot/treemap/index.d.ts +3 -0
  269. package/dist/plot/treemap/index.js +4 -0
  270. package/dist/plot/treemap/treemap.d.ts +26 -0
  271. package/dist/plot/treemap/treemap.js +99 -0
  272. package/dist/rdf/RdfPlot.svelte +22 -26
  273. package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
  274. package/dist/rdf/calc-rdf.js +4 -8
  275. package/dist/sanitize.js +1 -1
  276. package/dist/scene/bind-renderer.svelte.js +14 -6
  277. package/dist/settings.d.ts +19 -9
  278. package/dist/settings.js +77 -50
  279. package/dist/spectral/Bands.svelte +223 -230
  280. package/dist/spectral/BandsAndDos.svelte +11 -9
  281. package/dist/spectral/BrillouinBandsDos.svelte +19 -27
  282. package/dist/spectral/Dos.svelte +70 -73
  283. package/dist/spectral/helpers.d.ts +3 -3
  284. package/dist/spectral/helpers.js +25 -35
  285. package/dist/state.svelte.js +5 -18
  286. package/dist/structure/Arrow.svelte +5 -18
  287. package/dist/structure/ArrowInstances.svelte +160 -0
  288. package/dist/structure/ArrowInstances.svelte.d.ts +16 -0
  289. package/dist/structure/AtomLegend.svelte +115 -75
  290. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  291. package/dist/structure/Bond.svelte +31 -23
  292. package/dist/structure/CanvasTooltip.svelte +15 -3
  293. package/dist/structure/CellSelect.svelte +11 -26
  294. package/dist/structure/Cylinder.svelte +24 -40
  295. package/dist/structure/InstancedAtoms.svelte +114 -0
  296. package/dist/structure/InstancedAtoms.svelte.d.ts +15 -0
  297. package/dist/structure/Lattice.svelte +85 -149
  298. package/dist/structure/SiteLabels.svelte +122 -0
  299. package/dist/structure/SiteLabels.svelte.d.ts +18 -0
  300. package/dist/structure/Structure.svelte +473 -419
  301. package/dist/structure/Structure.svelte.d.ts +4 -2
  302. package/dist/structure/StructureCarousel.svelte +630 -0
  303. package/dist/structure/StructureCarousel.svelte.d.ts +19 -0
  304. package/dist/structure/StructureControls.svelte +157 -399
  305. package/dist/structure/StructureControls.svelte.d.ts +1 -1
  306. package/dist/structure/StructureExportPane.svelte +17 -21
  307. package/dist/structure/StructureInfoPane.svelte +72 -66
  308. package/dist/structure/StructureInfoPane.svelte.d.ts +1 -1
  309. package/dist/structure/StructureScene.svelte +467 -476
  310. package/dist/structure/StructureScene.svelte.d.ts +3 -1
  311. package/dist/structure/StructureViewport.svelte +386 -0
  312. package/dist/structure/StructureViewport.svelte.d.ts +63 -0
  313. package/dist/structure/atom-label-placement.d.ts +16 -12
  314. package/dist/structure/atom-label-placement.js +70 -37
  315. package/dist/structure/atom-properties.d.ts +2 -0
  316. package/dist/structure/atom-properties.js +104 -38
  317. package/dist/structure/bonding.d.ts +10 -3
  318. package/dist/structure/bonding.js +84 -28
  319. package/dist/structure/edit-history.d.ts +6 -0
  320. package/dist/structure/edit-history.js +27 -0
  321. package/dist/structure/export.d.ts +1 -0
  322. package/dist/structure/export.js +39 -31
  323. package/dist/structure/format-detect.d.ts +1 -0
  324. package/dist/structure/format-detect.js +22 -0
  325. package/dist/structure/geometry.d.ts +9 -0
  326. package/dist/structure/geometry.js +27 -0
  327. package/dist/structure/index.d.ts +16 -1
  328. package/dist/structure/index.js +13 -2
  329. package/dist/structure/measure.d.ts +1 -1
  330. package/dist/structure/measure.js +6 -12
  331. package/dist/structure/parse.d.ts +2 -1
  332. package/dist/structure/parse.js +243 -222
  333. package/dist/structure/partial-occupancy.js +4 -2
  334. package/dist/structure/pbc.js +78 -98
  335. package/dist/structure/polyhedra.d.ts +0 -1
  336. package/dist/structure/polyhedra.js +3 -18
  337. package/dist/structure/supercell.d.ts +1 -2
  338. package/dist/structure/supercell.js +7 -13
  339. package/dist/symmetry/SymmetryElements.svelte +11 -15
  340. package/dist/symmetry/SymmetryStats.svelte +56 -68
  341. package/dist/symmetry/WyckoffTable.svelte +5 -24
  342. package/dist/symmetry/cell-transform.js +1 -0
  343. package/dist/symmetry/index.d.ts +1 -0
  344. package/dist/symmetry/index.js +8 -2
  345. package/dist/symmetry/spacegroups.js +3 -2
  346. package/dist/table/HeatmapTable.svelte +1102 -365
  347. package/dist/table/HeatmapTable.svelte.d.ts +12 -2
  348. package/dist/table/ToggleMenu.svelte +5 -12
  349. package/dist/table/index.d.ts +21 -6
  350. package/dist/table/index.js +34 -21
  351. package/dist/theme/ThemeControl.svelte +16 -8
  352. package/dist/theme/index.d.ts +1 -5
  353. package/dist/theme/index.js +4 -10
  354. package/dist/theme/themes.mjs +14 -7
  355. package/dist/tooltip/KCoords.svelte +4 -1
  356. package/dist/tooltip/TooltipContent.svelte +2 -5
  357. package/dist/trajectory/Trajectory.svelte +515 -308
  358. package/dist/trajectory/Trajectory.svelte.d.ts +1 -1
  359. package/dist/trajectory/TrajectoryError.svelte +11 -8
  360. package/dist/trajectory/TrajectoryExportPane.svelte +14 -31
  361. package/dist/trajectory/TrajectoryInfoPane.svelte +85 -97
  362. package/dist/trajectory/extract.js +56 -34
  363. package/dist/trajectory/format-detect.js +11 -9
  364. package/dist/trajectory/frame-reader.d.ts +2 -0
  365. package/dist/trajectory/frame-reader.js +33 -29
  366. package/dist/trajectory/helpers.d.ts +2 -0
  367. package/dist/trajectory/helpers.js +18 -7
  368. package/dist/trajectory/index.d.ts +1 -0
  369. package/dist/trajectory/index.js +3 -0
  370. package/dist/trajectory/parse/h5-utils.d.ts +13 -0
  371. package/dist/trajectory/parse/h5-utils.js +109 -0
  372. package/dist/trajectory/parse/hdf5.d.ts +1 -1
  373. package/dist/trajectory/parse/hdf5.js +116 -106
  374. package/dist/trajectory/parse/index.d.ts +2 -3
  375. package/dist/trajectory/parse/index.js +17 -20
  376. package/dist/trajectory/parse/lammps.js +8 -12
  377. package/dist/trajectory/parse/vasp.js +10 -7
  378. package/dist/trajectory/parse/vaspout-electronic.d.ts +13 -0
  379. package/dist/trajectory/parse/vaspout-electronic.js +207 -0
  380. package/dist/trajectory/parse/vaspout-h5.d.ts +5 -0
  381. package/dist/trajectory/parse/vaspout-h5.js +284 -0
  382. package/dist/trajectory/parse/xyz.js +11 -7
  383. package/dist/trajectory/plotting.d.ts +8 -9
  384. package/dist/trajectory/plotting.js +99 -27
  385. package/dist/utils.d.ts +3 -0
  386. package/dist/utils.js +7 -0
  387. package/dist/xrd/XrdPlot.svelte +47 -61
  388. package/dist/xrd/broadening.js +2 -1
  389. package/dist/xrd/calc-xrd.js +2 -4
  390. package/dist/xrd/parse.d.ts +0 -1
  391. package/dist/xrd/parse.js +56 -73
  392. package/package.json +61 -33
  393. package/dist/api/mp.d.ts +0 -6
  394. package/dist/api/mp.js +0 -22
  395. package/dist/plot/sunburst/SunburstControls.svelte +0 -200
@@ -46,20 +46,17 @@
46
46
  const DEFAULT_SEARCH_EXAMPLES: SearchExampleCategory[] = [
47
47
  {
48
48
  label: `Has elements`,
49
- description:
50
- `Materials containing these elements. Operators/ranges: +Li,-O,Fe:1-2. Use * for any element.`,
49
+ description: `Materials containing these elements. Operators/ranges: +Li,-O,Fe:1-2. Use * for any element.`,
51
50
  examples: [`Li,Fe`, `+Li,-O`, `Li,*,*`],
52
51
  },
53
52
  {
54
53
  label: `Chemical system`,
55
- description:
56
- `Materials with only these elements (no others). Wildcards/ranges supported.`,
54
+ description: `Materials with only these elements (no others). Wildcards/ranges supported.`,
57
55
  examples: [`Li-Fe-O`, `Li-Fe-*-*`, `*-*-O`],
58
56
  },
59
57
  {
60
58
  label: `Exact formula`,
61
- description:
62
- `Materials with this exact stoichiometry. Unicode paste, wildcards, and canonicalization supported.`,
59
+ description: `Materials with this exact stoichiometry. Unicode paste, wildcards, and canonicalization supported.`,
63
60
  examples: [`LiFePO4`, `LiFe*2*`, `*2O3`],
64
61
  },
65
62
  ]
@@ -162,10 +159,9 @@
162
159
  if (!raw) return []
163
160
  const parsed: unknown = JSON.parse(raw)
164
161
  if (!Array.isArray(parsed)) return []
165
- return parsed.filter((item): item is string => typeof item === `string`).slice(
166
- 0,
167
- max_history,
168
- )
162
+ return parsed
163
+ .filter((item): item is string => typeof item === `string`)
164
+ .slice(0, max_history)
169
165
  } catch {
170
166
  return []
171
167
  }
@@ -249,9 +245,7 @@
249
245
  let visible_history = $derived.by(() => {
250
246
  const filtered = history
251
247
  .filter((item) => item !== value)
252
- .filter((item) =>
253
- item.toLowerCase().includes(history_query.toLowerCase().trim())
254
- )
248
+ .filter((item) => item.toLowerCase().includes(history_query.toLowerCase().trim()))
255
249
  const pinned = filtered.filter((item) => pinned_history.includes(item))
256
250
  const unpinned = filtered.filter((item) => !pinned_history.includes(item))
257
251
  return [...pinned, ...unpinned]
@@ -305,9 +299,9 @@
305
299
  $effect(() => {
306
300
  if (!examples_open || !examples_wrapper) return
307
301
  requestAnimationFrame(() => {
308
- const dropdown = examples_wrapper?.querySelector(`.examples-dropdown`) as
309
- | HTMLElement
310
- | null
302
+ const dropdown = examples_wrapper?.querySelector(
303
+ `.examples-dropdown`,
304
+ ) as HTMLElement | null
311
305
  if (!dropdown) return
312
306
  const rect = dropdown.getBoundingClientRect()
313
307
  if (rect.right > window.innerWidth && !anchor_left) anchor_left = true
@@ -337,11 +331,13 @@
337
331
  for (const [superscript, ascii] of Object.entries(SUPERSCRIPT_TO_ASCII)) {
338
332
  normalized = normalized.replaceAll(superscript, ascii)
339
333
  }
340
- return normalized
341
- // keep hydrate dots (deleting would glue digits: CuSO4·5H2O -> CuSO45H2O)
342
- .replaceAll(`⋅`, `·`)
343
- .replaceAll(`−`, `-`)
344
- .replaceAll(/\s+/g, ``)
334
+ return (
335
+ normalized
336
+ // keep hydrate dots (deleting would glue digits: CuSO4·5H2O -> CuSO45H2O)
337
+ .replaceAll(`⋅`, `·`)
338
+ .replaceAll(`−`, `-`)
339
+ .replaceAll(/\s+/g, ``)
340
+ )
345
341
  }
346
342
 
347
343
  function normalize_exact_formula(input: string): string {
@@ -356,8 +352,9 @@
356
352
  try {
357
353
  const tokens = parse_formula_with_wildcards(sanitized_input)
358
354
  const explicit = tokens
359
- .filter((token): token is { element: ElementSymbol; count: number } =>
360
- token.element !== null
355
+ .filter(
356
+ (token): token is { element: ElementSymbol; count: number } =>
357
+ token.element !== null,
361
358
  )
362
359
  .map((token) => ({ element: token.element, count: token.count }))
363
360
  const wildcard_tokens = tokens.filter((token) => token.element === null)
@@ -365,21 +362,19 @@
365
362
  // Merge explicit element counts before sorting.
366
363
  const merged_explicit: { element: string; count: number }[] = []
367
364
  for (const token of explicit) {
368
- const existing = merged_explicit.find((item) =>
369
- item.element === token.element
370
- )
365
+ const existing = merged_explicit.find((item) => item.element === token.element)
371
366
  if (existing) existing.count += token.count
372
367
  else merged_explicit.push(token)
373
368
  }
374
369
  const sorted_explicit = merged_explicit.sort((elem_a, elem_b) =>
375
- elem_a.element.localeCompare(elem_b.element)
370
+ elem_a.element.localeCompare(elem_b.element),
376
371
  )
377
- const wildcard_str = wildcard_tokens.map((token) =>
378
- token.count > 1 ? `*${token.count}` : `*`
379
- ).join(``)
380
- const explicit_str = sorted_explicit.map((token) =>
381
- token.count > 1 ? `${token.element}${token.count}` : token.element
382
- ).join(``)
372
+ const wildcard_str = wildcard_tokens
373
+ .map((token) => (token.count > 1 ? `*${token.count}` : `*`))
374
+ .join(``)
375
+ const explicit_str = sorted_explicit
376
+ .map((token) => (token.count > 1 ? `${token.element}${token.count}` : token.element))
377
+ .join(``)
383
378
  return `${explicit_str}${wildcard_str}`
384
379
  } catch {
385
380
  return sanitized_input
@@ -388,16 +383,18 @@
388
383
 
389
384
  function is_valid_constraint(constraint: string): boolean {
390
385
  if (!constraint) return true
391
- return /^\d+$/.test(constraint) || /^\d+-\d+$/.test(constraint) ||
392
- /^(>=|<=|>|<)\d+$/.test(constraint)
386
+ return (
387
+ /^\d+$/.test(constraint) ||
388
+ /^\d+-\d+$/.test(constraint) ||
389
+ /^(?:>=|<=|>|<)\d+$/.test(constraint)
390
+ )
393
391
  }
394
392
 
395
- function strip_operator_prefix(
396
- token: string,
397
- ): { operator: FormulaFilterToken[`operator`]; value: string } {
398
- const operator = token.startsWith(`-`) || token.startsWith(`!`)
399
- ? `exclude`
400
- : `include`
393
+ function strip_operator_prefix(token: string): {
394
+ operator: FormulaFilterToken[`operator`]
395
+ value: string
396
+ } {
397
+ const operator = token.startsWith(`-`) || token.startsWith(`!`) ? `exclude` : `include`
401
398
  const stripped_value =
402
399
  token.startsWith(`+`) || token.startsWith(`-`) || token.startsWith(`!`)
403
400
  ? token.slice(1)
@@ -429,8 +426,9 @@
429
426
  const is_wildcard = element === `*`
430
427
  const is_valid_element = is_wildcard || is_elem_symbol(element)
431
428
  const normalized_constraint = constraint?.trim() || null
432
- const is_valid = is_valid_element && (normalized_constraint === null ||
433
- is_valid_constraint(normalized_constraint))
429
+ const is_valid =
430
+ is_valid_element &&
431
+ (normalized_constraint === null || is_valid_constraint(normalized_constraint))
434
432
 
435
433
  return {
436
434
  raw: raw_token,
@@ -442,36 +440,37 @@
442
440
  }
443
441
  }
444
442
 
445
- function tokenize_query(
446
- input: string,
447
- mode: FormulaSearchMode,
448
- ): FormulaFilterToken[] {
443
+ function tokenize_query(input: string, mode: FormulaSearchMode): FormulaFilterToken[] {
449
444
  const trimmed = input.trim()
450
445
  if (!trimmed) return []
451
446
  if (mode === `exact`) {
452
- return [{
453
- raw: trimmed,
454
- element: trimmed,
455
- operator: `include`,
456
- constraint: null,
457
- is_wildcard: has_wildcards(trimmed),
458
- is_valid: sanitize_exact_formula(trimmed).is_valid,
459
- }]
447
+ return [
448
+ {
449
+ raw: trimmed,
450
+ element: trimmed,
451
+ operator: `include`,
452
+ constraint: null,
453
+ is_wildcard: has_wildcards(trimmed),
454
+ is_valid: sanitize_exact_formula(trimmed).is_valid,
455
+ },
456
+ ]
460
457
  }
461
458
  const normalized = mode === `chemsys` ? trimmed.replaceAll(`,`, `-`) : trimmed
462
- const tokens = mode === `chemsys`
463
- // Keep range constraints like Fe:1-2 intact while splitting token separators.
464
- ? normalized.split(/-(?!\d)/)
465
- : normalized.split(`,`)
459
+ const tokens =
460
+ mode === `chemsys`
461
+ ? // Keep range constraints like Fe:1-2 intact while splitting token separators.
462
+ normalized.split(/-(?!\d)/)
463
+ : normalized.split(`,`)
466
464
  return tokens
467
465
  .map((token) => token.trim())
468
466
  .filter(Boolean)
469
467
  .map(parse_token)
470
468
  }
471
469
 
472
- function sanitize_exact_formula(
473
- input: string,
474
- ): { is_valid: boolean; error_message: string | null } {
470
+ function sanitize_exact_formula(input: string): {
471
+ is_valid: boolean
472
+ error_message: string | null
473
+ } {
475
474
  const trimmed = input.trim()
476
475
  if (!trimmed) return { is_valid: true, error_message: null }
477
476
  try {
@@ -510,9 +509,7 @@
510
509
  return token_a.element.localeCompare(token_b.element)
511
510
  })
512
511
 
513
- return normalized_tokens
514
- .map(serialize_token)
515
- .join(separator)
512
+ return normalized_tokens.map(serialize_token).join(separator)
516
513
  }
517
514
 
518
515
  function parse_query(
@@ -521,14 +518,15 @@
521
518
  ): FormulaFilterParseResult {
522
519
  const tokens = tokenize_query(normalized_value, mode)
523
520
  const first_invalid_token = tokens.find((token) => !token.is_valid)
524
- const exact_validation = mode === `exact`
525
- ? sanitize_exact_formula(normalized_value)
526
- : {
527
- is_valid: !first_invalid_token,
528
- error_message: first_invalid_token
529
- ? `Invalid token: ${first_invalid_token.raw}`
530
- : null,
531
- }
521
+ const exact_validation =
522
+ mode === `exact`
523
+ ? sanitize_exact_formula(normalized_value)
524
+ : {
525
+ is_valid: !first_invalid_token,
526
+ error_message: first_invalid_token
527
+ ? `Invalid token: ${first_invalid_token.raw}`
528
+ : null,
529
+ }
532
530
  return {
533
531
  value: normalized_value,
534
532
  normalized_value,
@@ -559,7 +557,10 @@
559
557
  if (!trimmed) return []
560
558
  // If contains commas or dashes, split by those and sort alphabetically
561
559
  if (trimmed.includes(`,`) || trimmed.includes(`-`)) {
562
- const parts = trimmed.split(/[-,]/).map((str) => str.trim()).filter(Boolean)
560
+ const parts = trimmed
561
+ .split(/[-,]/)
562
+ .map((str) => str.trim())
563
+ .filter(Boolean)
563
564
  // Separate wildcards from regular elements
564
565
  const wildcards = parts.filter((part) => part === `*`)
565
566
  const regular_parts = parts.filter((part) => part !== `*`)
@@ -569,7 +570,8 @@
569
570
  }
570
571
  // Otherwise parse as formula (already returns sorted by default)
571
572
  // For formulas with wildcards, we can't parse them normally
572
- if (has_wildcards(trimmed)) { // Use shared utility and extract unique elements
573
+ if (has_wildcards(trimmed)) {
574
+ // Use shared utility and extract unique elements
573
575
  const tokens = parse_formula_with_wildcards(trimmed)
574
576
  const unique_elements: string[] = []
575
577
  for (const token of tokens) {
@@ -578,9 +580,7 @@
578
580
  }
579
581
  }
580
582
  const elements = unique_elements.sort()
581
- const wildcards = tokens.filter((token) => token.element === null).map(() =>
582
- `*`
583
- )
583
+ const wildcards = tokens.filter((token) => token.element === null).map(() => `*`)
584
584
  return [...elements, ...wildcards]
585
585
  }
586
586
  try {
@@ -672,9 +672,7 @@
672
672
  focused_history_idx = (focused_history_idx + 1) % len
673
673
  } else if (event.key === `ArrowUp`) {
674
674
  event.preventDefault()
675
- focused_history_idx = focused_history_idx <= 0
676
- ? len - 1
677
- : focused_history_idx - 1
675
+ focused_history_idx = focused_history_idx <= 0 ? len - 1 : focused_history_idx - 1
678
676
  }
679
677
  }
680
678
  }
@@ -709,8 +707,8 @@
709
707
  function handle_menu_keydown(event: KeyboardEvent): void {
710
708
  const len = all_examples.length
711
709
  if (!len) return
712
- const is_button_activation = (event.key === `Enter` || event.key === ` `) &&
713
- event.target instanceof HTMLButtonElement
710
+ const is_button_activation =
711
+ (event.key === `Enter` || event.key === ` `) && event.target instanceof HTMLButtonElement
714
712
  if (is_button_activation) return
715
713
 
716
714
  const key_actions: Record<string, () => void> = {
@@ -734,8 +732,9 @@
734
732
  function remove_token(token_idx: number): void {
735
733
  if (search_mode === `exact`) return
736
734
  const separator = search_mode === `chemsys` ? `-` : `,`
737
- const tokens = tokenize_query(input_value, search_mode)
738
- .filter((_, idx) => idx !== token_idx)
735
+ const tokens = tokenize_query(input_value, search_mode).filter(
736
+ (_, idx) => idx !== token_idx,
737
+ )
739
738
  const next_value = tokens.map(serialize_token).join(separator)
740
739
  input_value = next_value
741
740
  set_value(next_value, search_mode)
@@ -752,8 +751,8 @@
752
751
  search_mode === `chemsys`
753
752
  ? `Li-Fe-O or Li-*-*`
754
753
  : search_mode === `exact`
755
- ? `LiFePO4 or LiFe*2*`
756
- : `Li,Fe,O or Li,*,*`,
754
+ ? `LiFePO4 or LiFe*2*`
755
+ : `Li,Fe,O or Li,*,*`,
757
756
  )
758
757
 
759
758
  const MODE_LABELS: Record<FormulaSearchMode, string> = {
@@ -877,8 +876,8 @@
877
876
  class:locked={mode_locked}
878
877
  onclick={cycle_mode}
879
878
  title={mode_locked
880
- ? `Mode is locked`
881
- : `Click to switch to '${next_mode.mode}' → ${next_mode.value}`}
879
+ ? `Mode is locked`
880
+ : `Click to switch to '${next_mode.mode}' → ${next_mode.value}`}
882
881
  {@attach tooltip()}
883
882
  aria-label="Change search mode"
884
883
  >
@@ -959,11 +958,7 @@
959
958
  </div>
960
959
  {#if show_chip_row}
961
960
  <div class="token-chip-row">
962
- {#each parsed_tokens as
963
- token,
964
- idx
965
- (`${token.operator}:${token.element}:${token.constraint ?? ``}:${idx}`)
966
- }
961
+ {#each parsed_tokens as token, idx (`${token.operator}:${token.element}:${token.constraint ?? ``}:${idx}`)}
967
962
  <button
968
963
  type="button"
969
964
  class="token-chip"
@@ -1037,7 +1032,9 @@
1037
1032
  cursor: pointer;
1038
1033
  color: var(--highlight, #4db6ff);
1039
1034
  opacity: 0.8;
1040
- transition: opacity 0.15s, background 0.15s;
1035
+ transition:
1036
+ opacity 0.15s,
1037
+ background 0.15s;
1041
1038
  &:hover {
1042
1039
  opacity: 1;
1043
1040
  background: rgba(77, 182, 255, 0.2);
@@ -6,7 +6,12 @@
6
6
  import { format_num } from '../labels'
7
7
  import type { Snippet } from 'svelte'
8
8
  import type { SVGAttributes } from 'svelte/elements'
9
- import { type ChartSegmentData, get_chart_font_scale } from './index'
9
+ import {
10
+ chart_segment_label,
11
+ chart_segment_suffix,
12
+ type ChartSegmentData,
13
+ get_chart_font_scale,
14
+ } from './index'
10
15
  import { count_atoms_in_composition, fractional_composition } from './parse'
11
16
 
12
17
  // Constants for pie chart calculations
@@ -81,15 +86,19 @@
81
86
  const outer_arc = `M ${center} ${center - radius} A ${radius} ${radius} 0 1 1 ${center} ${
82
87
  center + radius
83
88
  } A ${radius} ${radius} 0 1 1 ${center} ${center - radius} Z`
84
- const path = ir > 0
85
- ? `${outer_arc} M ${center} ${
86
- center - ir
87
- } A ${ir} ${ir} 0 1 0 ${center} ${
88
- center + ir
89
- } A ${ir} ${ir} 0 1 0 ${center} ${center - ir} Z`
90
- : outer_arc
91
- const label_text = element + (show_amounts ? String(amount) : ``) +
92
- (show_percentages ? `${format_num(fraction, `.1~%`)}` : ``)
89
+ const path =
90
+ ir > 0
91
+ ? `${outer_arc} M ${center} ${center - ir} A ${ir} ${ir} 0 1 0 ${center} ${
92
+ center + ir
93
+ } A ${ir} ${ir} 0 1 0 ${center} ${center - ir} Z`
94
+ : outer_arc
95
+ const label_text = chart_segment_label(
96
+ element,
97
+ amount,
98
+ fraction,
99
+ show_amounts,
100
+ show_percentages,
101
+ )
93
102
  return {
94
103
  element,
95
104
  amount,
@@ -132,14 +141,15 @@
132
141
  const large_arc = angle_span > 180 ? 1 : 0
133
142
 
134
143
  // Create donut path if inner radius > 0, otherwise regular pie slice
135
- const path = inner_radius_adjusted > 0
136
- ? `M ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} L ${x2_inner} ${y2_inner} A ${inner_radius_adjusted} ${inner_radius_adjusted} 0 ${large_arc} 0 ${x1_inner} ${y1_inner} Z`
137
- : `M ${center} ${center} L ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} Z`
144
+ const path =
145
+ inner_radius_adjusted > 0
146
+ ? `M ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} L ${x2_inner} ${y2_inner} A ${inner_radius_adjusted} ${inner_radius_adjusted} 0 ${large_arc} 0 ${x1_inner} ${y1_inner} Z`
147
+ : `M ${center} ${center} L ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} Z`
138
148
 
139
149
  // Position labels with three-tier strategy
140
150
  const is_very_thin_slice = angle_span < VERY_THIN_SLICE_THRESHOLD // Place outside
141
- const is_medium_slice = angle_span >= VERY_THIN_SLICE_THRESHOLD &&
142
- angle_span < MEDIUM_SLICE_THRESHOLD // Near outer edge
151
+ const is_medium_slice =
152
+ angle_span >= VERY_THIN_SLICE_THRESHOLD && angle_span < MEDIUM_SLICE_THRESHOLD // Near outer edge
143
153
 
144
154
  let label_radius: number
145
155
  let is_outside_slice = false
@@ -159,22 +169,22 @@
159
169
  // Calculate font scale based on slice size and smart text fitting
160
170
  const [min_font_scale, max_font_scale] = [1.4, 2] as const
161
171
  const scale_factor = angle_span / MAX_ANGLE_FOR_FULL_SCALE
162
- const base_scale = min_font_scale +
163
- scale_factor * (max_font_scale - min_font_scale)
164
- const label_text = element + (show_amounts ? amount?.toString() ?? `` : ``) +
165
- (show_percentages ? `${format_num(fraction, `.1~%`)}` : ``)
172
+ const base_scale = min_font_scale + scale_factor * (max_font_scale - min_font_scale)
173
+ const label_text = chart_segment_label(
174
+ element,
175
+ amount,
176
+ fraction,
177
+ show_amounts,
178
+ show_percentages,
179
+ )
166
180
  const available_space = is_very_thin_slice
167
181
  ? outer_radius * 0.8 // More space outside the slice
168
182
  : Math.min(
169
- outer_radius - inner_radius_adjusted, // Radial space
170
- (angle_span * Math.PI / 180) * label_radius * 0.8, // Arc space at label radius
171
- )
183
+ outer_radius - inner_radius_adjusted, // Radial space
184
+ ((angle_span * Math.PI) / 180) * label_radius * 0.8, // Arc space at label radius
185
+ )
172
186
 
173
- const font_scale = get_chart_font_scale(
174
- base_scale,
175
- label_text,
176
- available_space,
177
- )
187
+ const font_scale = get_chart_font_scale(base_scale, label_text, available_space)
178
188
 
179
189
  return {
180
190
  element,
@@ -202,7 +212,7 @@
202
212
  viewBox="0 0 {size} {size}"
203
213
  style:max-width="{size}px"
204
214
  {...rest}
205
- class="pie-chart {rest.class ?? ``}"
215
+ class={[`pie-chart`, rest.class]}
206
216
  bind:this={svg_node}
207
217
  >
208
218
  {#each segments as segment (segment.element)}
@@ -211,10 +221,10 @@
211
221
  fill={segment.color}
212
222
  stroke="white"
213
223
  stroke-width={segments.length === 1
214
- ? 0
215
- : hovered_element === segment.element
216
- ? stroke_width + 1
217
- : stroke_width}
224
+ ? 0
225
+ : hovered_element === segment.element
226
+ ? stroke_width + 1
227
+ : stroke_width}
218
228
  class="pie-segment"
219
229
  class:interactive
220
230
  class:hovered={hovered_element === segment.element}
@@ -254,15 +264,18 @@
254
264
  class:outside-slice={segment.is_outside_slice}
255
265
  style:color={segment.text_color}
256
266
  >
257
- <span class="element-symbol" style:font-size="{14 * segment.font_scale}px">{
258
- segment.element
259
- }</span>
267
+ <span class="element-symbol" style:font-size="{14 * segment.font_scale}px"
268
+ >{segment.element}</span
269
+ >
260
270
  {#if show_amounts || show_percentages}
261
- <sub class="amount" style:font-size="{8 * segment.font_scale}px">{
262
- show_amounts ? segment.amount : ``
263
- }{show_amounts && show_percentages ? `=` : ``}{
264
- show_percentages ? format_num(segment.fraction, `.1~%`) : ``
265
- }</sub>
271
+ <sub class="amount" style:font-size="{8 * segment.font_scale}px"
272
+ >{chart_segment_suffix(
273
+ segment.amount,
274
+ segment.fraction,
275
+ show_amounts,
276
+ show_percentages,
277
+ )}</sub
278
+ >
266
279
  {/if}
267
280
  </div>
268
281
  </foreignObject>
@@ -285,7 +298,8 @@
285
298
  .pie-segment.interactive {
286
299
  cursor: pointer;
287
300
  }
288
- .pie-segment.interactive:hover, .pie-segment.hovered {
301
+ .pie-segment.interactive:hover,
302
+ .pie-segment.hovered {
289
303
  filter: brightness(1.1);
290
304
  }
291
305
  .pie-segment.interactive:focus {
@@ -86,7 +86,7 @@ export const get_electro_neg_formula = (input, plain_text = false, delim = ` `,
86
86
  export function get_formula_label_segments(formula) {
87
87
  const segments = [];
88
88
  let cursor = 0;
89
- for (const match of formula.matchAll(/([A-Za-z])(\d+(?:\.\d+)?)/g)) {
89
+ for (const match of formula.matchAll(/(?<letter>[A-Za-z])(?<amount>\d+(?:\.\d+)?)/g)) {
90
90
  const match_idx = match.index ?? 0;
91
91
  const prefix = match[1];
92
92
  const amount = match[2];
@@ -18,4 +18,6 @@ export type ChartSegmentData = {
18
18
  font_scale: number;
19
19
  text_color: string;
20
20
  };
21
+ export declare const chart_segment_suffix: (amount: number | undefined, fraction: number, show_amounts: boolean, show_percentages: boolean) => string;
22
+ export declare const chart_segment_label: (element: string, amount: number | undefined, fraction: number, show_amounts: boolean, show_percentages: boolean) => string;
21
23
  export declare function get_chart_font_scale(base_scale: number, label_text: string, available_space: number, min_scale_factor?: number, base_font_size?: number): number;
@@ -1,3 +1,4 @@
1
+ import { format_num } from '../labels';
1
2
  export { default as BarChart } from './BarChart.svelte';
2
3
  export { default as BubbleChart } from './BubbleChart.svelte';
3
4
  export * from './chem-sys';
@@ -7,6 +8,19 @@ export { default as Formula } from './Formula.svelte';
7
8
  export { default as FormulaFilter } from './FormulaFilter.svelte';
8
9
  export * from './parse';
9
10
  export { default as PieChart } from './PieChart.svelte';
11
+ // Amount/percentage suffix rendered after the element symbol in bar/pie chart
12
+ // segments; `=` separates amount from percentage when both are shown (Fe2=20%).
13
+ // format_num (not toString) so float noise like 0.30000000000000004 can't leak
14
+ // into labels; same format convention as format_composition_formula subscripts
15
+ // (`.3~s`, avoiding SI prefixes for sub-1 amounts where `s` renders 0.5 as 500m)
16
+ export const chart_segment_suffix = (amount, fraction, show_amounts, show_percentages) => (show_amounts && amount !== undefined
17
+ ? format_num(amount, Math.abs(amount) < 1 ? `.3~g` : `.3~s`)
18
+ : ``) +
19
+ (show_amounts && show_percentages ? `=` : ``) +
20
+ (show_percentages ? format_num(fraction, `.1~%`) : ``);
21
+ // Full segment label used to estimate label width for font scaling; must match
22
+ // the text the charts actually render (element symbol + chart_segment_suffix)
23
+ export const chart_segment_label = (element, amount, fraction, show_amounts, show_percentages) => element + chart_segment_suffix(amount, fraction, show_amounts, show_percentages);
10
24
  export function get_chart_font_scale(base_scale, label_text, available_space, min_scale_factor = 0.7, base_font_size = 16) {
11
25
  const text_width = label_text.length * 0.6 * base_font_size * base_scale;
12
26
  return available_space > 0 && text_width > available_space
@@ -2,8 +2,8 @@ import type { ElementSymbol } from '../element';
2
2
  import type { CompositionType } from './';
3
3
  export declare const ATOMIC_NUMBER_TO_SYMBOL: Record<number, ElementSymbol>;
4
4
  export declare const SYMBOL_TO_ATOMIC_NUMBER: Partial<CompositionType>;
5
- export declare const ATOMIC_WEIGHTS: Map<"S" | "K" | "B" | "H" | "He" | "Li" | "Be" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "Cl" | "Ar" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
6
- export declare const ELEMENT_ELECTRONEGATIVITY_MAP: Map<"S" | "K" | "B" | "H" | "He" | "Li" | "Be" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "Cl" | "Ar" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
5
+ export declare const ATOMIC_WEIGHTS: Map<"Ac" | "Ag" | "Al" | "Am" | "Ar" | "As" | "At" | "Au" | "B" | "Ba" | "Be" | "Bh" | "Bi" | "Bk" | "Br" | "C" | "Ca" | "Cd" | "Ce" | "Cf" | "Cl" | "Cm" | "Co" | "Cr" | "Cs" | "Cu" | "Db" | "Dy" | "Er" | "Es" | "Eu" | "F" | "Fe" | "Fm" | "Fr" | "Ga" | "Gd" | "Ge" | "H" | "He" | "Hf" | "Hg" | "Ho" | "Hs" | "I" | "In" | "Ir" | "K" | "Kr" | "La" | "Li" | "Lr" | "Lu" | "Md" | "Mg" | "Mn" | "Mo" | "Mt" | "N" | "Na" | "Nb" | "Nd" | "Ne" | "Ni" | "No" | "Np" | "O" | "Os" | "P" | "Pa" | "Pb" | "Pd" | "Pm" | "Po" | "Pr" | "Pt" | "Pu" | "Ra" | "Rb" | "Re" | "Rf" | "Rh" | "Rn" | "Ru" | "S" | "Sb" | "Sc" | "Se" | "Sg" | "Si" | "Sm" | "Sn" | "Sr" | "Ta" | "Tb" | "Tc" | "Te" | "Th" | "Ti" | "Tl" | "Tm" | "U" | "V" | "W" | "Xe" | "Y" | "Yb" | "Zn" | "Zr" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
6
+ export declare const ELEMENT_ELECTRONEGATIVITY_MAP: Map<"Ac" | "Ag" | "Al" | "Am" | "Ar" | "As" | "At" | "Au" | "B" | "Ba" | "Be" | "Bh" | "Bi" | "Bk" | "Br" | "C" | "Ca" | "Cd" | "Ce" | "Cf" | "Cl" | "Cm" | "Co" | "Cr" | "Cs" | "Cu" | "Db" | "Dy" | "Er" | "Es" | "Eu" | "F" | "Fe" | "Fm" | "Fr" | "Ga" | "Gd" | "Ge" | "H" | "He" | "Hf" | "Hg" | "Ho" | "Hs" | "I" | "In" | "Ir" | "K" | "Kr" | "La" | "Li" | "Lr" | "Lu" | "Md" | "Mg" | "Mn" | "Mo" | "Mt" | "N" | "Na" | "Nb" | "Nd" | "Ne" | "Ni" | "No" | "Np" | "O" | "Os" | "P" | "Pa" | "Pb" | "Pd" | "Pm" | "Po" | "Pr" | "Pt" | "Pu" | "Ra" | "Rb" | "Re" | "Rf" | "Rh" | "Rn" | "Ru" | "S" | "Sb" | "Sc" | "Se" | "Sg" | "Si" | "Sm" | "Sn" | "Sr" | "Ta" | "Tb" | "Tc" | "Te" | "Th" | "Ti" | "Tl" | "Tm" | "U" | "V" | "W" | "Xe" | "Y" | "Yb" | "Zn" | "Zr" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
7
7
  export declare const ELEM_NAME_TO_SYMBOL: Record<string, ElementSymbol>;
8
8
  export declare const ELEM_SYMBOL_TO_NAME: Partial<Record<ElementSymbol, string>>;
9
9
  export declare const atomic_num_to_symbols: (atomic_composition: Record<number, number>) => CompositionType;