matterviz 0.3.1 → 0.3.3

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 (358) hide show
  1. package/dist/EmptyState.svelte +10 -2
  2. package/dist/FilePicker.svelte +154 -96
  3. package/dist/Icon.svelte +20 -14
  4. package/dist/MillerIndexInput.svelte +27 -21
  5. package/dist/api/optimade.js +6 -6
  6. package/dist/app.css +216 -178
  7. package/dist/brillouin/BrillouinZone.svelte +299 -198
  8. package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
  9. package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
  10. package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
  11. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  12. package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
  13. package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
  14. package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
  15. package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
  16. package/dist/brillouin/compute.js +11 -6
  17. package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
  18. package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
  19. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
  20. package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
  21. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
  22. package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
  23. package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
  24. package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
  25. package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
  26. package/dist/chempot-diagram/async-compute.svelte.js +77 -0
  27. package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
  28. package/dist/chempot-diagram/chempot-worker.js +11 -0
  29. package/dist/chempot-diagram/color.d.ts +10 -0
  30. package/dist/chempot-diagram/color.js +32 -0
  31. package/dist/chempot-diagram/compute.d.ts +48 -0
  32. package/dist/chempot-diagram/compute.js +812 -0
  33. package/dist/chempot-diagram/index.d.ts +6 -0
  34. package/dist/chempot-diagram/index.js +6 -0
  35. package/dist/chempot-diagram/pointer.d.ts +16 -0
  36. package/dist/chempot-diagram/pointer.js +40 -0
  37. package/dist/chempot-diagram/temperature.d.ts +15 -0
  38. package/dist/chempot-diagram/temperature.js +36 -0
  39. package/dist/chempot-diagram/types.d.ts +86 -0
  40. package/dist/chempot-diagram/types.js +28 -0
  41. package/dist/colors/index.d.ts +3 -1
  42. package/dist/colors/index.js +9 -3
  43. package/dist/composition/BarChart.svelte +141 -77
  44. package/dist/composition/BubbleChart.svelte +107 -52
  45. package/dist/composition/Composition.svelte +100 -79
  46. package/dist/composition/Formula.svelte +108 -62
  47. package/dist/composition/FormulaFilter.svelte +973 -353
  48. package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
  49. package/dist/composition/PieChart.svelte +199 -99
  50. package/dist/composition/PieChart.svelte.d.ts +1 -1
  51. package/dist/composition/format.d.ts +5 -0
  52. package/dist/composition/format.js +20 -3
  53. package/dist/composition/parse.js +14 -9
  54. package/dist/convex-hull/ConvexHull.svelte +93 -38
  55. package/dist/convex-hull/ConvexHull2D.svelte +551 -393
  56. package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
  57. package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
  58. package/dist/convex-hull/ConvexHullControls.svelte +115 -28
  59. package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
  60. package/dist/convex-hull/ConvexHullStats.svelte +821 -249
  61. package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
  62. package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
  63. package/dist/convex-hull/GasPressureControls.svelte +104 -61
  64. package/dist/convex-hull/StructurePopup.svelte +25 -4
  65. package/dist/convex-hull/TemperatureSlider.svelte +45 -25
  66. package/dist/convex-hull/barycentric-coords.js +13 -7
  67. package/dist/convex-hull/demo-temperature.d.ts +6 -0
  68. package/dist/convex-hull/demo-temperature.js +40 -0
  69. package/dist/convex-hull/gas-thermodynamics.js +17 -12
  70. package/dist/convex-hull/helpers.d.ts +10 -1
  71. package/dist/convex-hull/helpers.js +79 -38
  72. package/dist/convex-hull/index.d.ts +1 -0
  73. package/dist/convex-hull/index.js +1 -0
  74. package/dist/convex-hull/thermodynamics.d.ts +8 -21
  75. package/dist/convex-hull/thermodynamics.js +163 -69
  76. package/dist/convex-hull/types.d.ts +12 -12
  77. package/dist/convex-hull/types.js +0 -12
  78. package/dist/coordination/CoordinationBarPlot.svelte +232 -176
  79. package/dist/element/BohrAtom.svelte +56 -13
  80. package/dist/element/ElementHeading.svelte +7 -2
  81. package/dist/element/ElementPhoto.svelte +15 -9
  82. package/dist/element/ElementStats.svelte +10 -4
  83. package/dist/element/ElementTile.svelte +137 -73
  84. package/dist/element/Nucleus.svelte +39 -11
  85. package/dist/element/data.js +2 -14
  86. package/dist/element/data.json.gz +0 -0
  87. package/dist/element/types.d.ts +1 -0
  88. package/dist/feedback/ClickFeedback.svelte +16 -5
  89. package/dist/feedback/DragOverlay.svelte +10 -2
  90. package/dist/feedback/Spinner.svelte +4 -2
  91. package/dist/feedback/StatusMessage.svelte +8 -2
  92. package/dist/fermi-surface/FermiSlice.svelte +118 -88
  93. package/dist/fermi-surface/FermiSurface.svelte +336 -239
  94. package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
  95. package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
  96. package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
  97. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
  98. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
  99. package/dist/fermi-surface/compute.js +16 -20
  100. package/dist/fermi-surface/parse.js +37 -33
  101. package/dist/fermi-surface/symmetry.js +2 -7
  102. package/dist/fermi-surface/types.d.ts +3 -5
  103. package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
  104. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
  105. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
  106. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
  107. package/dist/heatmap-matrix/index.d.ts +53 -0
  108. package/dist/heatmap-matrix/index.js +100 -0
  109. package/dist/heatmap-matrix/shared.d.ts +2 -0
  110. package/dist/heatmap-matrix/shared.js +4 -0
  111. package/dist/icons.d.ts +111 -0
  112. package/dist/icons.js +158 -0
  113. package/dist/index.d.ts +5 -2
  114. package/dist/index.js +5 -2
  115. package/dist/io/decompress.js +1 -1
  116. package/dist/io/export.d.ts +3 -0
  117. package/dist/io/export.js +138 -140
  118. package/dist/io/file-drop.d.ts +7 -0
  119. package/dist/io/file-drop.js +43 -0
  120. package/dist/io/index.d.ts +2 -2
  121. package/dist/io/index.js +2 -112
  122. package/dist/io/is-binary.js +2 -3
  123. package/dist/io/types.d.ts +1 -0
  124. package/dist/io/url-drop.d.ts +2 -0
  125. package/dist/io/url-drop.js +117 -0
  126. package/dist/isosurface/Isosurface.svelte +220 -110
  127. package/dist/isosurface/IsosurfaceControls.svelte +65 -28
  128. package/dist/isosurface/parse.js +104 -56
  129. package/dist/isosurface/slice.d.ts +2 -1
  130. package/dist/isosurface/slice.js +8 -13
  131. package/dist/isosurface/types.d.ts +14 -1
  132. package/dist/isosurface/types.js +152 -5
  133. package/dist/labels.d.ts +2 -1
  134. package/dist/labels.js +12 -8
  135. package/dist/layout/FullscreenToggle.svelte +11 -2
  136. package/dist/layout/InfoCard.svelte +38 -6
  137. package/dist/layout/InfoTag.svelte +125 -94
  138. package/dist/layout/PropertyFilter.svelte +82 -37
  139. package/dist/layout/SettingsSection.svelte +85 -55
  140. package/dist/layout/SubpageGrid.svelte +82 -0
  141. package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
  142. package/dist/layout/index.d.ts +1 -0
  143. package/dist/layout/index.js +1 -0
  144. package/dist/layout/json-tree/JsonNode.svelte +266 -223
  145. package/dist/layout/json-tree/JsonTree.svelte +516 -429
  146. package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
  147. package/dist/layout/json-tree/JsonValue.svelte +281 -173
  148. package/dist/layout/json-tree/types.d.ts +10 -2
  149. package/dist/layout/json-tree/utils.d.ts +2 -0
  150. package/dist/layout/json-tree/utils.js +37 -2
  151. package/dist/marching-cubes.js +25 -2
  152. package/dist/math.d.ts +20 -17
  153. package/dist/math.js +474 -57
  154. package/dist/overlays/ContextMenu.svelte +66 -40
  155. package/dist/overlays/DraggablePane.svelte +331 -154
  156. package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
  157. package/dist/periodic-table/PeriodicTable.svelte +278 -145
  158. package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
  159. package/dist/periodic-table/PropertySelect.svelte +25 -7
  160. package/dist/periodic-table/TableInset.svelte +8 -3
  161. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
  162. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
  163. package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
  164. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
  165. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
  166. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
  167. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
  168. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
  169. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
  170. package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
  171. package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
  172. package/dist/phase-diagram/build-diagram.js +9 -9
  173. package/dist/phase-diagram/colors.js +1 -3
  174. package/dist/phase-diagram/index.d.ts +2 -0
  175. package/dist/phase-diagram/index.js +2 -0
  176. package/dist/phase-diagram/parse.js +10 -9
  177. package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
  178. package/dist/phase-diagram/svg-to-diagram.js +869 -0
  179. package/dist/phase-diagram/types.d.ts +10 -0
  180. package/dist/phase-diagram/utils.d.ts +8 -4
  181. package/dist/phase-diagram/utils.js +219 -74
  182. package/dist/plot/AxisLabel.svelte +51 -0
  183. package/dist/plot/AxisLabel.svelte.d.ts +16 -0
  184. package/dist/plot/BarPlot.svelte +1461 -768
  185. package/dist/plot/BarPlot.svelte.d.ts +3 -3
  186. package/dist/plot/BarPlotControls.svelte +33 -6
  187. package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
  188. package/dist/plot/ColorBar.svelte +533 -383
  189. package/dist/plot/ColorBar.svelte.d.ts +1 -1
  190. package/dist/plot/ColorScaleSelect.svelte +28 -7
  191. package/dist/plot/ElementScatter.svelte +38 -16
  192. package/dist/plot/FillArea.svelte +152 -92
  193. package/dist/plot/Histogram.svelte +1162 -709
  194. package/dist/plot/Histogram.svelte.d.ts +1 -1
  195. package/dist/plot/HistogramControls.svelte +81 -18
  196. package/dist/plot/HistogramControls.svelte.d.ts +6 -2
  197. package/dist/plot/InteractiveAxisLabel.svelte +34 -11
  198. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
  199. package/dist/plot/Line.svelte +63 -28
  200. package/dist/plot/PlotControls.svelte +221 -96
  201. package/dist/plot/PlotControls.svelte.d.ts +1 -1
  202. package/dist/plot/PlotLegend.svelte +174 -91
  203. package/dist/plot/PlotTooltip.svelte +45 -6
  204. package/dist/plot/PortalSelect.svelte +175 -146
  205. package/dist/plot/ReferenceLine.svelte +77 -22
  206. package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
  207. package/dist/plot/ReferenceLine3D.svelte +132 -107
  208. package/dist/plot/ReferencePlane.svelte +146 -123
  209. package/dist/plot/ScatterPlot.svelte +1880 -1156
  210. package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
  211. package/dist/plot/ScatterPlot3D.svelte +256 -131
  212. package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
  213. package/dist/plot/ScatterPlot3DControls.svelte +300 -297
  214. package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
  215. package/dist/plot/ScatterPlot3DScene.svelte +608 -406
  216. package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
  217. package/dist/plot/ScatterPlotControls.svelte +150 -70
  218. package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
  219. package/dist/plot/ScatterPoint.svelte +98 -26
  220. package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
  221. package/dist/plot/SpacegroupBarPlot.svelte +142 -85
  222. package/dist/plot/Surface3D.svelte +159 -108
  223. package/dist/plot/ZeroLines.svelte +96 -0
  224. package/dist/plot/ZeroLines.svelte.d.ts +32 -0
  225. package/dist/plot/ZoomRect.svelte +23 -0
  226. package/dist/plot/ZoomRect.svelte.d.ts +8 -0
  227. package/dist/plot/axis-utils.d.ts +1 -1
  228. package/dist/plot/axis-utils.js +1 -3
  229. package/dist/plot/data-cleaning.js +12 -28
  230. package/dist/plot/data-transform.js +2 -1
  231. package/dist/plot/fill-utils.js +2 -0
  232. package/dist/plot/index.d.ts +6 -2
  233. package/dist/plot/index.js +6 -2
  234. package/dist/plot/interactions.d.ts +8 -10
  235. package/dist/plot/interactions.js +2 -3
  236. package/dist/plot/layout.d.ts +11 -2
  237. package/dist/plot/layout.js +44 -17
  238. package/dist/plot/reference-line.d.ts +5 -22
  239. package/dist/plot/reference-line.js +12 -84
  240. package/dist/plot/scales.js +24 -36
  241. package/dist/plot/types.d.ts +53 -40
  242. package/dist/plot/types.js +12 -7
  243. package/dist/plot/utils/label-placement.d.ts +32 -15
  244. package/dist/plot/utils/label-placement.js +227 -63
  245. package/dist/plot/utils/series-visibility.js +2 -3
  246. package/dist/plot/utils.d.ts +1 -0
  247. package/dist/plot/utils.js +14 -0
  248. package/dist/rdf/RdfPlot.svelte +173 -132
  249. package/dist/rdf/calc-rdf.js +4 -5
  250. package/dist/sanitize.d.ts +4 -0
  251. package/dist/sanitize.js +107 -0
  252. package/dist/settings.d.ts +21 -6
  253. package/dist/settings.js +63 -19
  254. package/dist/spectral/Bands.svelte +963 -412
  255. package/dist/spectral/Bands.svelte.d.ts +22 -2
  256. package/dist/spectral/BandsAndDos.svelte +90 -49
  257. package/dist/spectral/BrillouinBandsDos.svelte +151 -93
  258. package/dist/spectral/Dos.svelte +389 -258
  259. package/dist/spectral/helpers.d.ts +23 -1
  260. package/dist/spectral/helpers.js +119 -51
  261. package/dist/spectral/types.d.ts +2 -0
  262. package/dist/state.svelte.d.ts +1 -1
  263. package/dist/state.svelte.js +3 -2
  264. package/dist/structure/Arrow.svelte +59 -20
  265. package/dist/structure/AtomLegend.svelte +231 -129
  266. package/dist/structure/AtomLegend.svelte.d.ts +1 -1
  267. package/dist/structure/Bond.svelte +73 -47
  268. package/dist/structure/CanvasTooltip.svelte +10 -2
  269. package/dist/structure/CellSelect.svelte +148 -51
  270. package/dist/structure/Cylinder.svelte +33 -17
  271. package/dist/structure/Lattice.svelte +88 -33
  272. package/dist/structure/Structure.svelte +1077 -821
  273. package/dist/structure/Structure.svelte.d.ts +1 -1
  274. package/dist/structure/StructureControls.svelte +373 -139
  275. package/dist/structure/StructureControls.svelte.d.ts +1 -1
  276. package/dist/structure/StructureExportPane.svelte +124 -89
  277. package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
  278. package/dist/structure/StructureInfoPane.svelte +304 -231
  279. package/dist/structure/StructureScene.svelte +919 -445
  280. package/dist/structure/StructureScene.svelte.d.ts +16 -7
  281. package/dist/structure/atom-properties.d.ts +6 -2
  282. package/dist/structure/atom-properties.js +42 -29
  283. package/dist/structure/bonding.js +6 -7
  284. package/dist/structure/export.js +22 -34
  285. package/dist/structure/ferrox-wasm-types.d.ts +3 -2
  286. package/dist/structure/ferrox-wasm-types.js +0 -3
  287. package/dist/structure/ferrox-wasm.d.ts +3 -2
  288. package/dist/structure/ferrox-wasm.js +2 -3
  289. package/dist/structure/index.d.ts +16 -0
  290. package/dist/structure/index.js +88 -6
  291. package/dist/structure/measure.d.ts +2 -2
  292. package/dist/structure/measure.js +4 -44
  293. package/dist/structure/parse.js +130 -155
  294. package/dist/structure/partial-occupancy.d.ts +25 -0
  295. package/dist/structure/partial-occupancy.js +99 -0
  296. package/dist/structure/pbc.d.ts +1 -0
  297. package/dist/structure/pbc.js +16 -6
  298. package/dist/structure/supercell.d.ts +2 -2
  299. package/dist/structure/supercell.js +12 -22
  300. package/dist/structure/validation.js +5 -3
  301. package/dist/symmetry/SymmetryStats.svelte +94 -37
  302. package/dist/symmetry/WyckoffTable.svelte +42 -14
  303. package/dist/symmetry/cell-transform.js +5 -3
  304. package/dist/symmetry/index.d.ts +7 -4
  305. package/dist/symmetry/index.js +87 -21
  306. package/dist/symmetry/spacegroups.js +148 -148
  307. package/dist/table/HeatmapTable.svelte +1112 -516
  308. package/dist/table/HeatmapTable.svelte.d.ts +12 -1
  309. package/dist/table/ToggleMenu.svelte +125 -90
  310. package/dist/table/index.d.ts +2 -0
  311. package/dist/table/index.js +2 -4
  312. package/dist/theme/ThemeControl.svelte +21 -12
  313. package/dist/time.js +4 -1
  314. package/dist/tooltip/TooltipContent.svelte +33 -8
  315. package/dist/trajectory/Trajectory.svelte +889 -687
  316. package/dist/trajectory/TrajectoryError.svelte +14 -3
  317. package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
  318. package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
  319. package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
  320. package/dist/trajectory/constants.d.ts +6 -0
  321. package/dist/trajectory/constants.js +7 -0
  322. package/dist/trajectory/extract.js +13 -31
  323. package/dist/trajectory/format-detect.d.ts +9 -0
  324. package/dist/trajectory/format-detect.js +76 -0
  325. package/dist/trajectory/frame-reader.d.ts +17 -0
  326. package/dist/trajectory/frame-reader.js +332 -0
  327. package/dist/trajectory/helpers.d.ts +14 -0
  328. package/dist/trajectory/helpers.js +172 -0
  329. package/dist/trajectory/index.d.ts +1 -0
  330. package/dist/trajectory/index.js +23 -14
  331. package/dist/trajectory/parse/ase.d.ts +2 -0
  332. package/dist/trajectory/parse/ase.js +77 -0
  333. package/dist/trajectory/parse/hdf5.d.ts +2 -0
  334. package/dist/trajectory/parse/hdf5.js +129 -0
  335. package/dist/trajectory/parse/index.d.ts +12 -0
  336. package/dist/trajectory/parse/index.js +299 -0
  337. package/dist/trajectory/parse/lammps.d.ts +5 -0
  338. package/dist/trajectory/parse/lammps.js +179 -0
  339. package/dist/trajectory/parse/vasp.d.ts +2 -0
  340. package/dist/trajectory/parse/vasp.js +68 -0
  341. package/dist/trajectory/parse/xyz.d.ts +2 -0
  342. package/dist/trajectory/parse/xyz.js +110 -0
  343. package/dist/trajectory/plotting.js +13 -8
  344. package/dist/trajectory/types.d.ts +11 -0
  345. package/dist/trajectory/types.js +1 -0
  346. package/dist/utils.d.ts +3 -0
  347. package/dist/utils.js +17 -0
  348. package/dist/xrd/XrdPlot.svelte +337 -245
  349. package/dist/xrd/broadening.js +14 -9
  350. package/dist/xrd/calc-xrd.js +12 -19
  351. package/dist/xrd/parse.d.ts +1 -1
  352. package/dist/xrd/parse.js +17 -17
  353. package/package.json +103 -101
  354. package/readme.md +4 -4
  355. package/dist/trajectory/parse.d.ts +0 -42
  356. package/dist/trajectory/parse.js +0 -1267
  357. /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
  358. /package/dist/theme/{themes.js → themes.mjs} +0 -0
@@ -1,248 +1,321 @@
1
- <script lang="ts">import { get_electro_neg_formula } from '../composition';
2
- import { element_data } from '../element';
3
- import Icon from '../Icon.svelte';
4
- import { format_num } from '../labels';
5
- import DraggablePane from '../overlays/DraggablePane.svelte';
6
- import { get_density } from './';
7
- import { wyckoff_positions_from_moyo, WyckoffTable } from '../symmetry';
8
- import { SvelteSet } from 'svelte/reactivity';
9
- let { structure, pane_open = $bindable(false), atom_count_thresholds = [50, 500], toggle_props = {}, pane_props = {}, highlighted_sites = $bindable([]), selected_sites = $bindable([]), sym_data = null, ...rest } = $props();
10
- let copied_items = new SvelteSet();
11
- let sites_expanded = $state(false);
12
- async function copy_to_clipboard(label, value, key) {
1
+ <script lang="ts">
2
+ import { get_electro_neg_formula } from '../composition'
3
+ import { element_data } from '../element'
4
+ import Icon from '../Icon.svelte'
5
+ import { format_num } from '../labels'
6
+ import type { InfoItem } from '../layout'
7
+ import DraggablePane from '../overlays/DraggablePane.svelte'
8
+ import type { AnyStructure, Site } from './'
9
+ import { get_density } from './'
10
+ import { wyckoff_positions_from_moyo, WyckoffTable } from '../symmetry'
11
+ import type { MoyoDataset } from '@spglib/moyo-wasm'
12
+ import type { ComponentProps } from 'svelte'
13
+ import type { HTMLAttributes } from 'svelte/elements'
14
+ import { sanitize_html } from '../sanitize'
15
+ import { SvelteSet } from 'svelte/reactivity'
16
+
17
+ let {
18
+ structure,
19
+ pane_open = $bindable(false),
20
+ atom_count_thresholds = [50, 500],
21
+ toggle_props = {},
22
+ pane_props = {},
23
+ highlighted_sites = $bindable([]),
24
+ selected_sites = $bindable([]),
25
+ sym_data = null,
26
+ ...rest
27
+ }: Omit<HTMLAttributes<HTMLDivElement>, `onclose`> & {
28
+ structure: AnyStructure
29
+ pane_open?: boolean
30
+ atom_count_thresholds?: [number, number] // if atom count is less than min_threshold, show sites, if atom count is greater than max_threshold, hide sites. in between, show sites behind a toggle button.
31
+ toggle_props?: ComponentProps<typeof DraggablePane>[`toggle_props`]
32
+ pane_props?: ComponentProps<typeof DraggablePane>[`pane_props`]
33
+ highlighted_sites?: number[] // Sites highlighted from Wyckoff table hover
34
+ selected_sites?: number[] // Sites selected from Wyckoff table click
35
+ sym_data?: MoyoDataset | null // Symmetry analysis data (bindable for external access)
36
+ } = $props()
37
+
38
+ let copied_items = new SvelteSet<string>()
39
+ let sites_expanded = $state(false)
40
+
41
+ async function copy_to_clipboard(label: string, value: string, key: string) {
13
42
  try {
14
- await navigator.clipboard.writeText(`${label}: ${value}`);
15
- copied_items.add(key);
16
- setTimeout(() => copied_items.delete(key), 1000);
17
- }
18
- catch (error) {
19
- console.error(`Failed to copy to clipboard:`, error);
43
+ await navigator.clipboard.writeText(`${label}: ${value}`)
44
+ copied_items.add(key)
45
+ setTimeout(() => copied_items.delete(key), 1000)
46
+ } catch (error) {
47
+ console.error(`Failed to copy to clipboard:`, error)
20
48
  }
21
- }
22
- function handle_click(item, section_title) {
23
- if (section_title === `Usage Tips`)
24
- return;
25
- if (item.key === `sites-toggle`)
26
- sites_expanded = !sites_expanded;
27
- else
28
- copy_to_clipboard(item.label, String(item.value), item.key ?? item.label);
29
- }
30
- let pane_data = $derived.by(() => {
31
- if (!structure)
32
- return [];
33
- const sections = [];
34
- const [min_threshold, max_threshold] = atom_count_thresholds;
49
+ }
50
+
51
+ function handle_click(item: InfoItem, section_title: string) {
52
+ if (section_title === `Usage Tips`) return
53
+ if (item.key === `sites-toggle`) sites_expanded = !sites_expanded
54
+ else copy_to_clipboard(item.label, String(item.value), item.key ?? item.label)
55
+ }
56
+
57
+ let pane_data = $derived.by(() => {
58
+ if (!structure) return []
59
+ const sections: { title: string; items: InfoItem[] }[] = []
60
+ const [min_threshold, max_threshold] = atom_count_thresholds
61
+
35
62
  // Structure Info
36
- const structure_items = [
37
- {
38
- label: `Formula`,
39
- value: `${get_electro_neg_formula(structure)} (${structure.sites.length} sites)`,
40
- key: `structure-formula`,
41
- },
42
- {
43
- label: `Charge`,
44
- value: `${structure.charge || 0}e`,
45
- key: `structure-charge`,
46
- },
47
- ];
63
+ const structure_items: InfoItem[] = [
64
+ {
65
+ label: `Formula`,
66
+ value: `${
67
+ get_electro_neg_formula(structure)
68
+ } (${structure.sites.length} sites)`,
69
+ key: `structure-formula`,
70
+ },
71
+ {
72
+ label: `Charge`,
73
+ value: `${structure.charge || 0}e`,
74
+ key: `structure-charge`,
75
+ },
76
+ ]
77
+
48
78
  if (`properties` in structure) {
49
- for (const [key, value] of Object.entries(structure.properties ?? {})) {
50
- // Only display scalar values (skip arrays and objects)
51
- if (value == null || typeof value === `object`)
52
- continue;
53
- structure_items.push({
54
- label: key.replace(/_/g, ` `).replace(/\b\w/g, (char) => char.toUpperCase()),
55
- value: String(value),
56
- key: `structure-prop-${key}`,
57
- });
58
- }
79
+ for (const [key, value] of Object.entries(structure.properties ?? {})) {
80
+ // Only display scalar values (skip arrays and objects)
81
+ if (value == null || typeof value === `object`) continue
82
+ structure_items.push({
83
+ label: key.replace(/_/g, ` `).replace(
84
+ /\b\w/g,
85
+ (char) => char.toUpperCase(),
86
+ ),
87
+ value: String(value),
88
+ key: `structure-prop-${key}`,
89
+ })
90
+ }
59
91
  }
60
- sections.push({ title: `Structure`, items: structure_items });
92
+ sections.push({ title: `Structure`, items: structure_items })
93
+
61
94
  // Cell Info
62
95
  if (`lattice` in structure) {
63
- const { a, b, c, alpha, beta, gamma, volume } = structure.lattice;
64
- sections.push({
65
- title: `Cell`,
66
- items: [
67
- {
68
- label: `Volume, Density`,
69
- value: `${format_num(volume, `.3~s`)} ų, ${format_num(get_density(structure), `.3~f`)} g/cm³`,
70
- key: `cell-volume-density`,
71
- },
72
- {
73
- label: `a, b, c`,
74
- value: `${format_num(a, `.4~f`)}, ${format_num(b, `.4~f`)}, ${format_num(c, `.4~f`)} Å`,
75
- key: `cell-abc`,
76
- },
77
- {
78
- label: `α, β, γ`,
79
- value: `${format_num(alpha, `.2~f`)}°, ${format_num(beta, `.2~f`)}°, ${format_num(gamma, `.2~f`)}°`,
80
- key: `cell-angles`,
81
- },
82
- ],
83
- });
96
+ const { a, b, c, alpha, beta, gamma, volume } = structure.lattice
97
+ sections.push({
98
+ title: `Cell`,
99
+ items: [
100
+ {
101
+ label: `Volume, Density`,
102
+ value: `${format_num(volume, `.3~s`)} ų, ${
103
+ format_num(get_density(structure), `.3~f`)
104
+ } g/cm³`,
105
+ key: `cell-volume-density`,
106
+ },
107
+ {
108
+ label: `a, b, c`,
109
+ value: `${format_num(a, `.4~f`)}, ${format_num(b, `.4~f`)}, ${
110
+ format_num(c, `.4~f`)
111
+ } Å`,
112
+ key: `cell-abc`,
113
+ },
114
+ {
115
+ label: `α, β, γ`,
116
+ value: `${format_num(alpha, `.2~f`)}°, ${format_num(beta, `.2~f`)}°, ${
117
+ format_num(gamma, `.2~f`)
118
+ }°`,
119
+ key: `cell-angles`,
120
+ },
121
+ ],
122
+ })
84
123
  }
124
+
85
125
  // Symmetry Info
86
126
  if (`lattice` in structure && sym_data) {
87
- const { operations } = sym_data;
88
- let translations = 0, rotations = 0, roto_translations = 0;
89
- for (const op of operations) {
90
- const has_translation = op.translation.some((t) => t !== 0);
91
- const is_identity = String(op.rotation) === `1,0,0,0,1,0,0,0,1`;
92
- if (is_identity && has_translation)
93
- translations++;
94
- else if (!has_translation)
95
- rotations++;
96
- else
97
- roto_translations++;
98
- }
99
- sections.push({
100
- title: `Symmetry`,
101
- items: [
102
- {
103
- label: `Space Group`,
104
- value: String(sym_data.number),
105
- key: `symmetry-space-group`,
106
- },
107
- {
108
- label: `Hall Number`,
109
- value: String(sym_data.hall_number),
110
- key: `symmetry-hall-number`,
111
- },
112
- {
113
- label: `Pearson Symbol`,
114
- value: sym_data.pearson_symbol,
115
- key: `symmetry-pearson-symbol`,
116
- },
117
- {
118
- label: `Symmetry Ops`,
119
- value: `${operations.length} (${translations} trans, ${rotations} rot, ${roto_translations} roto-trans)`,
120
- key: `symmetry-operations-total`,
121
- },
122
- ],
123
- });
127
+ const { operations } = sym_data
128
+ let translations = 0, rotations = 0, roto_translations = 0
129
+ for (const op of operations) {
130
+ const has_translation = op.translation.some((t) => t !== 0)
131
+ const is_identity = String(op.rotation) === `1,0,0,0,1,0,0,0,1`
132
+ if (is_identity && has_translation) translations++
133
+ else if (!has_translation) rotations++
134
+ else roto_translations++
135
+ }
136
+
137
+ const international_symbol = (sym_data as MoyoDataset & {
138
+ international_short?: string
139
+ }).international_short
140
+ const space_group_symbol = (sym_data.hm_symbol ?? international_symbol)
141
+ ?.replace(
142
+ /\s+/g,
143
+ ``,
144
+ )
145
+ const space_group_value = space_group_symbol
146
+ ? `${sym_data.number} (${space_group_symbol})`
147
+ : String(sym_data.number)
148
+
149
+ sections.push({
150
+ title: `Symmetry`,
151
+ items: [
152
+ {
153
+ label: `Space Group`,
154
+ value: space_group_value,
155
+ key: `symmetry-space-group`,
156
+ },
157
+ {
158
+ label: `Hall Number`,
159
+ value: String(sym_data.hall_number),
160
+ key: `symmetry-hall-number`,
161
+ },
162
+ {
163
+ label: `Pearson Symbol`,
164
+ value: sym_data.pearson_symbol,
165
+ key: `symmetry-pearson-symbol`,
166
+ },
167
+ {
168
+ label: `Symmetry Ops`,
169
+ value:
170
+ `${operations.length} (${translations} trans, ${rotations} rot, ${roto_translations} roto-trans)`,
171
+ key: `symmetry-operations-total`,
172
+ },
173
+ ],
174
+ })
124
175
  }
176
+
125
177
  // Sites Section
126
- const atom_count = structure.sites.length;
178
+ const atom_count = structure.sites.length
127
179
  if (atom_count <= max_threshold) {
128
- const site_items = [];
129
- // Merged toggle button with Sites title
130
- if (atom_count >= min_threshold) {
131
- const toggle_label = sites_expanded
132
- ? `Hide Sites`
133
- : `Show ${atom_count} sites`;
180
+ const site_items: InfoItem[] = []
181
+
182
+ // Merged toggle button with Sites title
183
+ if (atom_count >= min_threshold) {
184
+ const toggle_label = sites_expanded
185
+ ? `Hide Sites`
186
+ : `Show ${atom_count} sites`
187
+ site_items.push({
188
+ label: toggle_label,
189
+ value: sites_expanded ? `▲` : `▼`,
190
+ key: `sites-toggle`,
191
+ tooltip: `Click to ${
192
+ sites_expanded ? `hide` : `show`
193
+ } all site information`,
194
+ })
195
+ }
196
+
197
+ if (atom_count < min_threshold || sites_expanded) {
198
+ structure.sites.forEach((site: Site, idx: number) => {
199
+ const element = site.species?.[0]?.element || `Unknown`
200
+ const element_name = element_data?.find((el) =>
201
+ el.symbol === element
202
+ )?.name || element
203
+
204
+ site_items.push({
205
+ label: `${element}${idx + 1}`,
206
+ value: element_name,
207
+ key: `site-${idx}-header`,
208
+ })
209
+
210
+ if (site.abc) {
134
211
  site_items.push({
135
- label: toggle_label,
136
- value: sites_expanded ? `▲` : `▼`,
137
- key: `sites-toggle`,
138
- tooltip: `Click to ${sites_expanded ? `hide` : `show`} all site information`,
139
- });
140
- }
141
- if (atom_count < min_threshold || sites_expanded) {
142
- structure.sites.forEach((site, idx) => {
143
- const element = site.species?.[0]?.element || `Unknown`;
144
- const element_name = element_data?.find((el) => el.symbol === element)?.name || element;
145
- site_items.push({
146
- label: `${element}${idx + 1}`,
147
- value: element_name,
148
- key: `site-${idx}-header`,
149
- });
150
- if (site.abc) {
151
- site_items.push({
152
- label: ` Fractional`,
153
- value: `(${site.abc.map((x) => format_num(x, `.4~f`)).join(`, `)})`,
154
- key: `site-${idx}-fractional`,
155
- });
156
- }
157
- if (site.xyz) {
158
- site_items.push({
159
- label: ` Cartesian`,
160
- value: `(${site.xyz.map((x) => format_num(x, `.4~f`)).join(`, `)}) Å`,
161
- key: `site-${idx}-cartesian`,
162
- });
163
- }
164
- if (site.properties) {
165
- for (const [prop_key, prop_value] of Object.entries(site.properties)) {
166
- if (prop_value != null && prop_value !== undefined) {
167
- let formatted_value;
168
- let tooltip;
169
- if (prop_key === `force` && Array.isArray(prop_value) &&
170
- prop_value.length === 3 && prop_value.every((v) => typeof v === `number`)) {
171
- const force_magnitude = Math.hypot(...prop_value);
172
- formatted_value = `${format_num(force_magnitude, `.3~f`)} eV/Å`;
173
- tooltip = `Force vector: (${prop_value.map((force) => format_num(force, `.3~f`)).join(`, `)}) eV/Å`;
174
- }
175
- else if (prop_key === `magmom` || prop_key.includes(`magnet`)) {
176
- const num_val = Number(prop_value);
177
- if (isNaN(num_val))
178
- continue;
179
- formatted_value = `${format_num(num_val, `.3~f`)} μB`;
180
- tooltip = `Magnetic moment in Bohr magnetons`;
181
- }
182
- else if (Array.isArray(prop_value)) {
183
- formatted_value = `(${prop_value.map((v) => {
184
- const num_val = Number(v);
185
- return isNaN(num_val) ? String(v) : format_num(num_val, `.3~f`);
186
- }).join(`, `)})`;
187
- }
188
- else {
189
- const num_val = Number(prop_value);
190
- formatted_value = isNaN(num_val)
191
- ? String(prop_value)
192
- : format_num(num_val, `.3~f`);
193
- }
194
- site_items.push({
195
- label: ` ${prop_key}`,
196
- value: formatted_value,
197
- key: `site-${idx}-${prop_key}`,
198
- tooltip,
199
- });
200
- }
201
- }
212
+ label: ` Fractional`,
213
+ value: `(${site.abc.map((x) => format_num(x, `.4~f`)).join(`, `)})`,
214
+ key: `site-${idx}-fractional`,
215
+ })
216
+ }
217
+ if (site.xyz) {
218
+ site_items.push({
219
+ label: ` Cartesian`,
220
+ value: `(${site.xyz.map((x) => format_num(x, `.4~f`)).join(`, `)}) Å`,
221
+ key: `site-${idx}-cartesian`,
222
+ })
223
+ }
224
+
225
+ if (site.properties) {
226
+ for (const [prop_key, prop_value] of Object.entries(site.properties)) {
227
+ if (prop_value != null && prop_value !== undefined) {
228
+ let formatted_value: string
229
+ let tooltip: string | undefined
230
+
231
+ if (
232
+ prop_key === `force` && Array.isArray(prop_value) &&
233
+ prop_value.length === 3 && prop_value.every((v) =>
234
+ typeof v === `number`
235
+ )
236
+ ) {
237
+ const force_magnitude = Math.hypot(...prop_value)
238
+ formatted_value = `${format_num(force_magnitude, `.3~f`)} eV/Å`
239
+ tooltip = `Force vector: (${
240
+ prop_value.map((force) => format_num(force, `.3~f`)).join(`, `)
241
+ }) eV/Å`
242
+ } else if (prop_key === `magmom` || prop_key.includes(`magnet`)) {
243
+ const num_val = Number(prop_value)
244
+ if (isNaN(num_val)) continue
245
+ formatted_value = `${format_num(num_val, `.3~f`)} μB`
246
+ tooltip = `Magnetic moment in Bohr magnetons`
247
+ } else if (Array.isArray(prop_value)) {
248
+ formatted_value = `(${
249
+ prop_value.map((v) => {
250
+ const num_val = Number(v)
251
+ return isNaN(num_val) ? String(v) : format_num(num_val, `.3~f`)
252
+ }).join(`, `)
253
+ })`
254
+ } else {
255
+ const num_val = Number(prop_value)
256
+ formatted_value = isNaN(num_val)
257
+ ? String(prop_value)
258
+ : format_num(num_val, `.3~f`)
202
259
  }
203
- });
204
- }
205
- if (site_items.length > 0) {
206
- sections.push({
207
- title: atom_count >= min_threshold ? `` : `Sites`,
208
- items: site_items,
209
- });
210
- }
260
+
261
+ site_items.push({
262
+ label: ` ${prop_key}`,
263
+ value: formatted_value,
264
+ key: `site-${idx}-${prop_key}`,
265
+ tooltip,
266
+ })
267
+ }
268
+ }
269
+ }
270
+ })
271
+ }
272
+
273
+ if (site_items.length > 0) {
274
+ sections.push({
275
+ title: atom_count >= min_threshold ? `` : `Sites`,
276
+ items: site_items,
277
+ })
278
+ }
211
279
  }
280
+
212
281
  // Usage Tips
213
282
  sections.push({
214
- title: `Usage Tips`,
215
- items: [
216
- {
217
- label: `File Drop`,
218
- value: `Drop POSCAR, XYZ, CIF or JSON files to load structures`,
219
- },
220
- {
221
- label: `Atom Selection`,
222
- value: `Click atoms to select them, then pick distance or angle mode to measure all pairwise distances/angles`,
223
- },
224
- {
225
- label: `Navigation`,
226
- value: `Hold Shift/Cmd/Ctrl + drag to pan the scene`,
227
- },
228
- {
229
- label: `Camera Reset`,
230
- value: `Double-click anywhere to reset camera to default view`,
231
- },
232
- {
233
- label: `Colors`,
234
- value: `Click legend labels to change colors, double-click to reset, right-click to remap elements`,
235
- },
236
- {
237
- label: `Keyboard`,
238
- value: `Press 'f' for fullscreen, 'i' to toggle this pane`,
239
- },
240
- ],
241
- });
242
- return sections;
243
- });
244
- // Compute Wyckoff positions from symmetry data
245
- let wyckoff_positions = $derived(wyckoff_positions_from_moyo(sym_data));
283
+ title: `Usage Tips`,
284
+ items: [
285
+ {
286
+ label: `File Drop`,
287
+ value: `Drop POSCAR, XYZ, CIF or JSON files to load structures`,
288
+ },
289
+ {
290
+ label: `Atom Selection`,
291
+ value:
292
+ `Click atoms to select them, then pick distance or angle mode to measure all pairwise distances/angles`,
293
+ },
294
+ {
295
+ label: `Navigation`,
296
+ value: `Hold Shift/Cmd/Ctrl + drag to pan the scene`,
297
+ },
298
+ {
299
+ label: `Camera Reset`,
300
+ value: `Double-click anywhere to reset camera to default view`,
301
+ },
302
+ {
303
+ label: `Colors`,
304
+ value:
305
+ `Click legend labels to change colors, double-click to reset, right-click to remap elements`,
306
+ },
307
+ {
308
+ label: `Keyboard`,
309
+ value: `Press 'f' for fullscreen, 'i' to toggle this pane`,
310
+ },
311
+ ],
312
+ })
313
+
314
+ return sections
315
+ })
316
+
317
+ // Compute Wyckoff positions from symmetry data
318
+ let wyckoff_positions = $derived(wyckoff_positions_from_moyo(sym_data))
246
319
  </script>
247
320
 
248
321
  <DraggablePane
@@ -269,8 +342,8 @@ let wyckoff_positions = $derived(wyckoff_positions_from_moyo(sym_data));
269
342
  {@const { key, label, value, tooltip } = item}
270
343
  {#if section.title === `Usage Tips`}
271
344
  <div class="tips-item">
272
- <span>{@html label}</span>
273
- <span>{@html value}</span>
345
+ <span>{@html sanitize_html(label)}</span>
346
+ <span>{@html sanitize_html(value)}</span>
274
347
  </div>
275
348
  {:else}
276
349
  <div
@@ -288,8 +361,8 @@ let wyckoff_positions = $derived(wyckoff_positions_from_moyo(sym_data));
288
361
  }
289
362
  }}
290
363
  >
291
- <span>{@html label}</span>
292
- <span title={tooltip}>{@html value}</span>
364
+ <span>{@html sanitize_html(label)}</span>
365
+ <span title={tooltip}>{@html sanitize_html(value)}</span>
293
366
  {#if key !== `sites-toggle` && key && copied_items.has(key)}
294
367
  <Icon
295
368
  icon="Check"