matterviz 0.3.2 → 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 (280) hide show
  1. package/dist/EmptyState.svelte +10 -2
  2. package/dist/FilePicker.svelte +123 -82
  3. package/dist/Icon.svelte +18 -12
  4. package/dist/MillerIndexInput.svelte +27 -21
  5. package/dist/api/optimade.js +6 -6
  6. package/dist/app.css +216 -207
  7. package/dist/brillouin/BrillouinZone.svelte +292 -149
  8. package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
  9. package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
  10. package/dist/brillouin/BrillouinZoneExportPane.svelte +69 -42
  11. package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
  12. package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
  13. package/dist/brillouin/BrillouinZoneScene.svelte +275 -163
  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 +162 -27
  18. package/dist/chempot-diagram/ChemPotDiagram2D.svelte +451 -281
  19. package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2148 -1642
  20. package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -5
  21. package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
  22. package/dist/chempot-diagram/async-compute.svelte.js +77 -0
  23. package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
  24. package/dist/chempot-diagram/chempot-worker.js +11 -0
  25. package/dist/chempot-diagram/color.js +1 -2
  26. package/dist/chempot-diagram/compute.d.ts +10 -0
  27. package/dist/chempot-diagram/compute.js +250 -88
  28. package/dist/chempot-diagram/index.d.ts +2 -1
  29. package/dist/chempot-diagram/index.js +2 -1
  30. package/dist/chempot-diagram/temperature.js +8 -9
  31. package/dist/chempot-diagram/types.d.ts +3 -0
  32. package/dist/chempot-diagram/types.js +1 -0
  33. package/dist/colors/index.d.ts +1 -1
  34. package/dist/colors/index.js +5 -3
  35. package/dist/composition/BarChart.svelte +128 -55
  36. package/dist/composition/BubbleChart.svelte +102 -49
  37. package/dist/composition/Composition.svelte +100 -79
  38. package/dist/composition/Formula.svelte +108 -62
  39. package/dist/composition/FormulaFilter.svelte +665 -537
  40. package/dist/composition/PieChart.svelte +183 -108
  41. package/dist/composition/format.d.ts +5 -0
  42. package/dist/composition/format.js +20 -3
  43. package/dist/composition/parse.js +14 -9
  44. package/dist/convex-hull/ConvexHull.svelte +93 -40
  45. package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
  46. package/dist/convex-hull/ConvexHull2D.svelte +549 -360
  47. package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
  48. package/dist/convex-hull/ConvexHull3D.svelte +1296 -827
  49. package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
  50. package/dist/convex-hull/ConvexHull4D.svelte +1004 -688
  51. package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
  52. package/dist/convex-hull/ConvexHullControls.svelte +115 -28
  53. package/dist/convex-hull/ConvexHullControls.svelte.d.ts +1 -1
  54. package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
  55. package/dist/convex-hull/ConvexHullStats.svelte +425 -328
  56. package/dist/convex-hull/ConvexHullTooltip.svelte +40 -16
  57. package/dist/convex-hull/GasPressureControls.svelte +104 -61
  58. package/dist/convex-hull/StructurePopup.svelte +25 -4
  59. package/dist/convex-hull/TemperatureSlider.svelte +45 -25
  60. package/dist/convex-hull/barycentric-coords.js +13 -7
  61. package/dist/convex-hull/demo-temperature.js +8 -4
  62. package/dist/convex-hull/gas-thermodynamics.js +17 -12
  63. package/dist/convex-hull/helpers.d.ts +9 -0
  64. package/dist/convex-hull/helpers.js +77 -34
  65. package/dist/convex-hull/thermodynamics.js +61 -56
  66. package/dist/convex-hull/types.d.ts +9 -14
  67. package/dist/convex-hull/types.js +0 -17
  68. package/dist/coordination/CoordinationBarPlot.svelte +227 -154
  69. package/dist/element/BohrAtom.svelte +55 -12
  70. package/dist/element/ElementHeading.svelte +7 -2
  71. package/dist/element/ElementPhoto.svelte +15 -9
  72. package/dist/element/ElementStats.svelte +10 -4
  73. package/dist/element/ElementTile.svelte +137 -73
  74. package/dist/element/Nucleus.svelte +39 -11
  75. package/dist/feedback/ClickFeedback.svelte +16 -5
  76. package/dist/feedback/DragOverlay.svelte +10 -2
  77. package/dist/feedback/Spinner.svelte +4 -2
  78. package/dist/feedback/StatusMessage.svelte +8 -2
  79. package/dist/fermi-surface/FermiSlice.svelte +118 -88
  80. package/dist/fermi-surface/FermiSurface.svelte +328 -187
  81. package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
  82. package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
  83. package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
  84. package/dist/fermi-surface/FermiSurfaceScene.svelte +535 -342
  85. package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
  86. package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
  87. package/dist/fermi-surface/compute.js +16 -20
  88. package/dist/fermi-surface/parse.js +24 -14
  89. package/dist/fermi-surface/symmetry.js +2 -7
  90. package/dist/fermi-surface/types.d.ts +3 -5
  91. package/dist/heatmap-matrix/HeatmapMatrix.svelte +1019 -765
  92. package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +1 -1
  93. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +76 -22
  94. package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +2 -3
  95. package/dist/icons.js +47 -0
  96. package/dist/index.d.ts +2 -1
  97. package/dist/index.js +2 -1
  98. package/dist/io/decompress.js +1 -1
  99. package/dist/io/export.d.ts +3 -0
  100. package/dist/io/export.js +129 -143
  101. package/dist/io/is-binary.js +2 -3
  102. package/dist/io/url-drop.js +1 -2
  103. package/dist/isosurface/Isosurface.svelte +202 -148
  104. package/dist/isosurface/IsosurfaceControls.svelte +46 -28
  105. package/dist/isosurface/parse.js +34 -29
  106. package/dist/isosurface/slice.js +5 -10
  107. package/dist/isosurface/types.d.ts +2 -1
  108. package/dist/isosurface/types.js +61 -12
  109. package/dist/labels.js +11 -8
  110. package/dist/layout/FullscreenToggle.svelte +11 -2
  111. package/dist/layout/InfoCard.svelte +38 -6
  112. package/dist/layout/InfoTag.svelte +63 -32
  113. package/dist/layout/PropertyFilter.svelte +82 -37
  114. package/dist/layout/SettingsSection.svelte +85 -55
  115. package/dist/layout/SubpageGrid.svelte +10 -2
  116. package/dist/layout/json-tree/JsonNode.svelte +183 -138
  117. package/dist/layout/json-tree/JsonTree.svelte +499 -413
  118. package/dist/layout/json-tree/JsonValue.svelte +127 -99
  119. package/dist/layout/json-tree/utils.js +4 -2
  120. package/dist/marching-cubes.js +25 -2
  121. package/dist/math.d.ts +13 -17
  122. package/dist/math.js +133 -67
  123. package/dist/overlays/ContextMenu.svelte +65 -40
  124. package/dist/overlays/DraggablePane.svelte +211 -139
  125. package/dist/periodic-table/PeriodicTable.svelte +278 -145
  126. package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
  127. package/dist/periodic-table/PropertySelect.svelte +25 -7
  128. package/dist/periodic-table/TableInset.svelte +8 -3
  129. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +446 -309
  130. package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
  131. package/dist/phase-diagram/PhaseDiagramControls.svelte +102 -43
  132. package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
  133. package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +63 -40
  134. package/dist/phase-diagram/PhaseDiagramExportPane.svelte +71 -28
  135. package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +1 -1
  136. package/dist/phase-diagram/PhaseDiagramTooltip.svelte +158 -101
  137. package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
  138. package/dist/phase-diagram/build-diagram.js +9 -9
  139. package/dist/phase-diagram/colors.js +1 -3
  140. package/dist/phase-diagram/parse.js +10 -9
  141. package/dist/phase-diagram/svg-to-diagram.js +53 -49
  142. package/dist/phase-diagram/utils.d.ts +1 -0
  143. package/dist/phase-diagram/utils.js +80 -25
  144. package/dist/plot/AxisLabel.svelte +28 -3
  145. package/dist/plot/BarPlot.svelte +1182 -734
  146. package/dist/plot/BarPlot.svelte.d.ts +2 -2
  147. package/dist/plot/BarPlotControls.svelte +31 -5
  148. package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
  149. package/dist/plot/ColorBar.svelte +479 -329
  150. package/dist/plot/ColorScaleSelect.svelte +27 -6
  151. package/dist/plot/ElementScatter.svelte +36 -15
  152. package/dist/plot/FillArea.svelte +152 -95
  153. package/dist/plot/Histogram.svelte +934 -571
  154. package/dist/plot/Histogram.svelte.d.ts +1 -1
  155. package/dist/plot/HistogramControls.svelte +53 -9
  156. package/dist/plot/HistogramControls.svelte.d.ts +1 -1
  157. package/dist/plot/InteractiveAxisLabel.svelte +34 -11
  158. package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
  159. package/dist/plot/Line.svelte +63 -28
  160. package/dist/plot/PlotControls.svelte +157 -114
  161. package/dist/plot/PlotControls.svelte.d.ts +1 -1
  162. package/dist/plot/PlotLegend.svelte +174 -91
  163. package/dist/plot/PlotTooltip.svelte +45 -6
  164. package/dist/plot/PortalSelect.svelte +175 -147
  165. package/dist/plot/ReferenceLine.svelte +76 -22
  166. package/dist/plot/ReferenceLine3D.svelte +132 -107
  167. package/dist/plot/ReferencePlane.svelte +146 -121
  168. package/dist/plot/ScatterPlot.svelte +1681 -1091
  169. package/dist/plot/ScatterPlot.svelte.d.ts +2 -2
  170. package/dist/plot/ScatterPlot3D.svelte +256 -131
  171. package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
  172. package/dist/plot/ScatterPlot3DControls.svelte +113 -63
  173. package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
  174. package/dist/plot/ScatterPlot3DScene.svelte +608 -403
  175. package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
  176. package/dist/plot/ScatterPlotControls.svelte +65 -25
  177. package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
  178. package/dist/plot/ScatterPoint.svelte +98 -26
  179. package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
  180. package/dist/plot/SpacegroupBarPlot.svelte +142 -85
  181. package/dist/plot/Surface3D.svelte +159 -108
  182. package/dist/plot/ZeroLines.svelte +55 -3
  183. package/dist/plot/ZoomRect.svelte +4 -2
  184. package/dist/plot/axis-utils.js +1 -3
  185. package/dist/plot/data-cleaning.js +12 -28
  186. package/dist/plot/data-transform.js +2 -1
  187. package/dist/plot/fill-utils.js +2 -0
  188. package/dist/plot/layout.d.ts +4 -1
  189. package/dist/plot/layout.js +33 -14
  190. package/dist/plot/reference-line.d.ts +2 -2
  191. package/dist/plot/reference-line.js +7 -5
  192. package/dist/plot/scales.js +24 -36
  193. package/dist/plot/types.d.ts +11 -23
  194. package/dist/plot/types.js +6 -11
  195. package/dist/plot/utils/label-placement.d.ts +32 -15
  196. package/dist/plot/utils/label-placement.js +227 -66
  197. package/dist/plot/utils/series-visibility.js +2 -3
  198. package/dist/rdf/RdfPlot.svelte +143 -91
  199. package/dist/rdf/calc-rdf.js +4 -5
  200. package/dist/sanitize.d.ts +4 -0
  201. package/dist/sanitize.js +107 -0
  202. package/dist/settings.d.ts +18 -6
  203. package/dist/settings.js +46 -16
  204. package/dist/spectral/Bands.svelte +632 -453
  205. package/dist/spectral/BandsAndDos.svelte +90 -49
  206. package/dist/spectral/BrillouinBandsDos.svelte +151 -93
  207. package/dist/spectral/Dos.svelte +389 -258
  208. package/dist/spectral/helpers.js +55 -43
  209. package/dist/state.svelte.d.ts +1 -1
  210. package/dist/state.svelte.js +3 -2
  211. package/dist/structure/Arrow.svelte +59 -20
  212. package/dist/structure/AtomLegend.svelte +215 -134
  213. package/dist/structure/Bond.svelte +73 -47
  214. package/dist/structure/CanvasTooltip.svelte +10 -2
  215. package/dist/structure/CellSelect.svelte +72 -45
  216. package/dist/structure/Cylinder.svelte +33 -17
  217. package/dist/structure/Lattice.svelte +88 -33
  218. package/dist/structure/Structure.svelte +1063 -797
  219. package/dist/structure/Structure.svelte.d.ts +1 -1
  220. package/dist/structure/StructureControls.svelte +349 -118
  221. package/dist/structure/StructureExportPane.svelte +124 -89
  222. package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
  223. package/dist/structure/StructureInfoPane.svelte +304 -237
  224. package/dist/structure/StructureScene.svelte +879 -443
  225. package/dist/structure/StructureScene.svelte.d.ts +15 -7
  226. package/dist/structure/atom-properties.js +8 -8
  227. package/dist/structure/bonding.js +6 -7
  228. package/dist/structure/export.js +14 -29
  229. package/dist/structure/ferrox-wasm.js +1 -1
  230. package/dist/structure/index.d.ts +13 -3
  231. package/dist/structure/index.js +83 -23
  232. package/dist/structure/measure.d.ts +2 -2
  233. package/dist/structure/measure.js +4 -44
  234. package/dist/structure/parse.js +113 -141
  235. package/dist/structure/partial-occupancy.js +7 -10
  236. package/dist/structure/pbc.d.ts +1 -0
  237. package/dist/structure/pbc.js +16 -6
  238. package/dist/structure/supercell.d.ts +2 -2
  239. package/dist/structure/supercell.js +12 -22
  240. package/dist/structure/validation.js +1 -2
  241. package/dist/symmetry/SymmetryStats.svelte +84 -41
  242. package/dist/symmetry/WyckoffTable.svelte +26 -6
  243. package/dist/symmetry/cell-transform.js +5 -3
  244. package/dist/symmetry/index.js +8 -7
  245. package/dist/symmetry/spacegroups.js +148 -148
  246. package/dist/table/HeatmapTable.svelte +790 -554
  247. package/dist/table/HeatmapTable.svelte.d.ts +1 -1
  248. package/dist/table/ToggleMenu.svelte +125 -92
  249. package/dist/table/index.js +2 -4
  250. package/dist/theme/ThemeControl.svelte +21 -12
  251. package/dist/time.js +4 -1
  252. package/dist/tooltip/TooltipContent.svelte +33 -8
  253. package/dist/trajectory/Trajectory.svelte +758 -558
  254. package/dist/trajectory/TrajectoryError.svelte +14 -3
  255. package/dist/trajectory/TrajectoryExportPane.svelte +137 -83
  256. package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
  257. package/dist/trajectory/extract.js +10 -26
  258. package/dist/trajectory/format-detect.js +5 -5
  259. package/dist/trajectory/frame-reader.d.ts +1 -1
  260. package/dist/trajectory/frame-reader.js +5 -12
  261. package/dist/trajectory/helpers.d.ts +0 -1
  262. package/dist/trajectory/helpers.js +2 -17
  263. package/dist/trajectory/index.js +14 -12
  264. package/dist/trajectory/parse/ase.js +5 -4
  265. package/dist/trajectory/parse/hdf5.js +26 -18
  266. package/dist/trajectory/parse/index.js +13 -18
  267. package/dist/trajectory/parse/lammps.js +17 -7
  268. package/dist/trajectory/parse/vasp.js +5 -2
  269. package/dist/trajectory/parse/xyz.js +8 -7
  270. package/dist/trajectory/plotting.js +13 -8
  271. package/dist/utils.d.ts +1 -0
  272. package/dist/utils.js +13 -0
  273. package/dist/xrd/XrdPlot.svelte +337 -247
  274. package/dist/xrd/broadening.js +14 -9
  275. package/dist/xrd/calc-xrd.js +12 -18
  276. package/dist/xrd/parse.d.ts +1 -1
  277. package/dist/xrd/parse.js +17 -17
  278. package/package.json +99 -103
  279. package/readme.md +1 -1
  280. /package/dist/theme/{themes.js → themes.mjs} +0 -0
@@ -1,254 +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
- const international_symbol = sym_data.international_short;
100
- const space_group_symbol = (sym_data.hm_symbol ?? international_symbol)
101
- ?.replace(/\s+/g, ``);
102
- const space_group_value = space_group_symbol
103
- ? `${sym_data.number} (${space_group_symbol})`
104
- : String(sym_data.number);
105
- sections.push({
106
- title: `Symmetry`,
107
- items: [
108
- {
109
- label: `Space Group`,
110
- value: space_group_value,
111
- key: `symmetry-space-group`,
112
- },
113
- {
114
- label: `Hall Number`,
115
- value: String(sym_data.hall_number),
116
- key: `symmetry-hall-number`,
117
- },
118
- {
119
- label: `Pearson Symbol`,
120
- value: sym_data.pearson_symbol,
121
- key: `symmetry-pearson-symbol`,
122
- },
123
- {
124
- label: `Symmetry Ops`,
125
- value: `${operations.length} (${translations} trans, ${rotations} rot, ${roto_translations} roto-trans)`,
126
- key: `symmetry-operations-total`,
127
- },
128
- ],
129
- });
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
+ })
130
175
  }
176
+
131
177
  // Sites Section
132
- const atom_count = structure.sites.length;
178
+ const atom_count = structure.sites.length
133
179
  if (atom_count <= max_threshold) {
134
- const site_items = [];
135
- // Merged toggle button with Sites title
136
- if (atom_count >= min_threshold) {
137
- const toggle_label = sites_expanded
138
- ? `Hide Sites`
139
- : `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) {
140
211
  site_items.push({
141
- label: toggle_label,
142
- value: sites_expanded ? `▲` : `▼`,
143
- key: `sites-toggle`,
144
- tooltip: `Click to ${sites_expanded ? `hide` : `show`} all site information`,
145
- });
146
- }
147
- if (atom_count < min_threshold || sites_expanded) {
148
- structure.sites.forEach((site, idx) => {
149
- const element = site.species?.[0]?.element || `Unknown`;
150
- const element_name = element_data?.find((el) => el.symbol === element)?.name || element;
151
- site_items.push({
152
- label: `${element}${idx + 1}`,
153
- value: element_name,
154
- key: `site-${idx}-header`,
155
- });
156
- if (site.abc) {
157
- site_items.push({
158
- label: ` Fractional`,
159
- value: `(${site.abc.map((x) => format_num(x, `.4~f`)).join(`, `)})`,
160
- key: `site-${idx}-fractional`,
161
- });
162
- }
163
- if (site.xyz) {
164
- site_items.push({
165
- label: ` Cartesian`,
166
- value: `(${site.xyz.map((x) => format_num(x, `.4~f`)).join(`, `)}) Å`,
167
- key: `site-${idx}-cartesian`,
168
- });
169
- }
170
- if (site.properties) {
171
- for (const [prop_key, prop_value] of Object.entries(site.properties)) {
172
- if (prop_value != null && prop_value !== undefined) {
173
- let formatted_value;
174
- let tooltip;
175
- if (prop_key === `force` && Array.isArray(prop_value) &&
176
- prop_value.length === 3 && prop_value.every((v) => typeof v === `number`)) {
177
- const force_magnitude = Math.hypot(...prop_value);
178
- formatted_value = `${format_num(force_magnitude, `.3~f`)} eV/Å`;
179
- tooltip = `Force vector: (${prop_value.map((force) => format_num(force, `.3~f`)).join(`, `)}) eV/Å`;
180
- }
181
- else if (prop_key === `magmom` || prop_key.includes(`magnet`)) {
182
- const num_val = Number(prop_value);
183
- if (isNaN(num_val))
184
- continue;
185
- formatted_value = `${format_num(num_val, `.3~f`)} μB`;
186
- tooltip = `Magnetic moment in Bohr magnetons`;
187
- }
188
- else if (Array.isArray(prop_value)) {
189
- formatted_value = `(${prop_value.map((v) => {
190
- const num_val = Number(v);
191
- return isNaN(num_val) ? String(v) : format_num(num_val, `.3~f`);
192
- }).join(`, `)})`;
193
- }
194
- else {
195
- const num_val = Number(prop_value);
196
- formatted_value = isNaN(num_val)
197
- ? String(prop_value)
198
- : format_num(num_val, `.3~f`);
199
- }
200
- site_items.push({
201
- label: ` ${prop_key}`,
202
- value: formatted_value,
203
- key: `site-${idx}-${prop_key}`,
204
- tooltip,
205
- });
206
- }
207
- }
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`)
208
259
  }
209
- });
210
- }
211
- if (site_items.length > 0) {
212
- sections.push({
213
- title: atom_count >= min_threshold ? `` : `Sites`,
214
- items: site_items,
215
- });
216
- }
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
+ }
217
279
  }
280
+
218
281
  // Usage Tips
219
282
  sections.push({
220
- title: `Usage Tips`,
221
- items: [
222
- {
223
- label: `File Drop`,
224
- value: `Drop POSCAR, XYZ, CIF or JSON files to load structures`,
225
- },
226
- {
227
- label: `Atom Selection`,
228
- value: `Click atoms to select them, then pick distance or angle mode to measure all pairwise distances/angles`,
229
- },
230
- {
231
- label: `Navigation`,
232
- value: `Hold Shift/Cmd/Ctrl + drag to pan the scene`,
233
- },
234
- {
235
- label: `Camera Reset`,
236
- value: `Double-click anywhere to reset camera to default view`,
237
- },
238
- {
239
- label: `Colors`,
240
- value: `Click legend labels to change colors, double-click to reset, right-click to remap elements`,
241
- },
242
- {
243
- label: `Keyboard`,
244
- value: `Press 'f' for fullscreen, 'i' to toggle this pane`,
245
- },
246
- ],
247
- });
248
- return sections;
249
- });
250
- // Compute Wyckoff positions from symmetry data
251
- 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))
252
319
  </script>
253
320
 
254
321
  <DraggablePane
@@ -275,8 +342,8 @@ let wyckoff_positions = $derived(wyckoff_positions_from_moyo(sym_data));
275
342
  {@const { key, label, value, tooltip } = item}
276
343
  {#if section.title === `Usage Tips`}
277
344
  <div class="tips-item">
278
- <span>{@html label}</span>
279
- <span>{@html value}</span>
345
+ <span>{@html sanitize_html(label)}</span>
346
+ <span>{@html sanitize_html(value)}</span>
280
347
  </div>
281
348
  {:else}
282
349
  <div
@@ -294,8 +361,8 @@ let wyckoff_positions = $derived(wyckoff_positions_from_moyo(sym_data));
294
361
  }
295
362
  }}
296
363
  >
297
- <span>{@html label}</span>
298
- <span title={tooltip}>{@html value}</span>
364
+ <span>{@html sanitize_html(label)}</span>
365
+ <span title={tooltip}>{@html sanitize_html(value)}</span>
299
366
  {#if key !== `sites-toggle` && key && copied_items.has(key)}
300
367
  <Icon
301
368
  icon="Check"