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,5 +1,13 @@
1
- <script lang="ts">let { message, children, ...rest } = $props();
2
- export {};
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+ import type { HTMLAttributes } from 'svelte/elements'
4
+
5
+ let { message, children, ...rest }: {
6
+ // Simple text message to display. Ignored if children snippet is provided.
7
+ message?: string
8
+ // Custom content to render. Takes precedence over message prop.
9
+ children?: Snippet
10
+ } & HTMLAttributes<HTMLDivElement> = $props()
3
11
  </script>
4
12
 
5
13
  <div {...rest} class="empty-state {rest.class ?? ``}">
@@ -1,86 +1,131 @@
1
- <script lang="ts">import { tooltip } from 'svelte-multiselect';
2
- // Delay for distinguishing click from double-click (ms)
3
- const CLICK_DELAY = 250;
4
- let { files = [], active_files = [], show_category_filters = false, layout = `wrap`, on_drag_start, on_drag_end, on_click, on_dblclick, type_mapper, file_type_colors = {
5
- cif: `rgba(100, 149, 237, 0.8)`,
6
- xyz: `rgba(50, 205, 50, 0.8)`,
7
- extxyz: `rgba(50, 205, 50, 0.8)`,
8
- poscar: `rgba(255, 140, 0, 0.8)`,
9
- json: `rgba(138, 43, 226, 0.8)`,
10
- traj: `rgba(255, 192, 203, 0.8)`,
11
- hdf5: `rgba(255, 69, 0, 0.8)`,
12
- gz: `rgba(169, 169, 169, 0.8)`,
13
- md: `rgba(255, 215, 0, 0.8)`,
14
- yaml: `rgba(255, 0, 255, 0.8)`,
15
- xdatcar: `rgba(255, 215, 0, 0.8)`,
16
- tdb: `rgba(0, 188, 212, 0.8)`,
17
- }, ...rest } = $props();
18
- let active_category_filter = $state(null);
19
- let active_type_filter = $state(null);
20
- // Timer for distinguishing click from double-click (per-component state)
21
- let click_timer = null;
22
- let click_timer_file = null;
23
- const clear_click_timer = () => {
24
- if (click_timer)
25
- clearTimeout(click_timer);
26
- click_timer = null;
27
- click_timer_file = null;
28
- };
29
- // Helper function to get the base file type (removing .gz extension)
30
- const get_base_file_type = (file) => {
31
- // Use custom type mapper if provided
32
- if (type_mapper)
33
- return type_mapper(file);
34
- let base_name = file.name.toLowerCase();
35
- // Remove .gz extension if present
36
- if (base_name.endsWith(`.gz`))
37
- base_name = base_name.slice(0, -3);
38
- return base_name.split(`.`).pop() || `file`;
39
- };
40
- // Helper function to create normalized category identifier for filtering
41
- const get_category_id = (file) => {
42
- if (!file.category)
43
- return `(uncategorized)`;
44
- return `${file.category_icon ?? ``} ${file.category}`.trim();
45
- };
46
- // Filter files based on active filters
47
- let filtered_files = $derived(files.filter((file) => {
48
- if (active_category_filter) {
49
- return get_category_id(file) === active_category_filter;
50
- }
51
- if (active_type_filter) {
52
- const normalized_type = get_base_file_type(file);
53
- return normalized_type === active_type_filter;
54
- }
55
- return true;
56
- }));
57
- const toggle_filter = (kind, filter) => {
1
+ <script lang="ts">
2
+ import type { FileInfo } from './io'
3
+ import { tooltip } from 'svelte-multiselect'
4
+ import type { HTMLAttributes } from 'svelte/elements'
5
+
6
+ // Delay for distinguishing click from double-click (ms)
7
+ const CLICK_DELAY = 250
8
+
9
+ let {
10
+ files = [],
11
+ active_files = [],
12
+ show_category_filters = false,
13
+ layout = `wrap`,
14
+ on_drag_start,
15
+ on_drag_end,
16
+ on_click,
17
+ on_dblclick,
18
+ type_mapper,
19
+ file_type_colors = {
20
+ cif: `rgba(100, 149, 237, 0.8)`,
21
+ xyz: `rgba(50, 205, 50, 0.8)`,
22
+ extxyz: `rgba(50, 205, 50, 0.8)`,
23
+ poscar: `rgba(255, 140, 0, 0.8)`,
24
+ json: `rgba(138, 43, 226, 0.8)`,
25
+ traj: `rgba(255, 192, 203, 0.8)`,
26
+ hdf5: `rgba(255, 69, 0, 0.8)`,
27
+ gz: `rgba(169, 169, 169, 0.8)`,
28
+ md: `rgba(255, 215, 0, 0.8)`,
29
+ yaml: `rgba(255, 0, 255, 0.8)`,
30
+ xdatcar: `rgba(255, 215, 0, 0.8)`,
31
+ tdb: `rgba(0, 188, 212, 0.8)`,
32
+ chgcar: `rgba(59, 130, 246, 0.8)`,
33
+ parchg: `rgba(99, 102, 241, 0.8)`,
34
+ locpot: `rgba(245, 158, 11, 0.8)`,
35
+ elfcar: `rgba(16, 185, 129, 0.8)`,
36
+ cube: `rgba(168, 85, 247, 0.8)`,
37
+ },
38
+ ...rest
39
+ }: HTMLAttributes<HTMLDivElement> & {
40
+ files?: FileInfo[]
41
+ active_files?: string[]
42
+ show_category_filters?: boolean
43
+ layout?: `wrap` | `vertical`
44
+ on_drag_start?: (file: FileInfo, event: DragEvent) => void
45
+ on_drag_end?: () => void
46
+ on_click?: (file: FileInfo, event: MouseEvent | KeyboardEvent) => void
47
+ on_dblclick?: (file: FileInfo, event: MouseEvent) => void
48
+ type_mapper?: (file: FileInfo) => string
49
+ file_type_colors?: Record<string, string>
50
+ } = $props()
51
+
52
+ let active_category_filter = $state<string | null>(null)
53
+ let active_type_filter = $state<string | null>(null)
54
+ type FilterKind = `category` | `type`
55
+
56
+ // Timer for distinguishing click from double-click (per-component state)
57
+ let click_timer: ReturnType<typeof setTimeout> | null = null
58
+ let click_timer_file: string | null = null
59
+
60
+ const clear_click_timer = () => {
61
+ if (click_timer) clearTimeout(click_timer)
62
+ click_timer = null
63
+ click_timer_file = null
64
+ }
65
+
66
+ // Helper function to get the base file type (removing .gz extension)
67
+ const get_base_file_type = (file: FileInfo): string => {
68
+ if (type_mapper) return type_mapper(file)
69
+ if (file.type) return file.type.toLowerCase()
70
+
71
+ let base_name = file.name.toLowerCase()
72
+ if (base_name.endsWith(`.gz`)) base_name = base_name.slice(0, -3)
73
+ return base_name.split(`.`).pop() || `file`
74
+ }
75
+
76
+ // Helper function to create normalized category identifier for filtering
77
+ const get_category_id = (file: FileInfo): string => {
78
+ if (!file.category) return `(uncategorized)`
79
+ return `${file.category_icon ?? ``} ${file.category}`.trim()
80
+ }
81
+
82
+ // Filter files based on active filters
83
+ let filtered_files = $derived(
84
+ files.filter((file) => {
85
+ if (active_category_filter) {
86
+ return get_category_id(file) === active_category_filter
87
+ }
88
+ if (active_type_filter) {
89
+ const normalized_type = get_base_file_type(file)
90
+ return normalized_type === active_type_filter
91
+ }
92
+ return true
93
+ }),
94
+ )
95
+
96
+ const toggle_filter = (kind: FilterKind, filter: string) => {
58
97
  if (kind === `category`) {
59
- active_category_filter = active_category_filter === filter ? null : filter;
60
- active_type_filter = null;
98
+ active_category_filter = active_category_filter === filter ? null : filter
99
+ active_type_filter = null
100
+ } else {
101
+ active_type_filter = active_type_filter === filter ? null : filter
102
+ active_category_filter = null
61
103
  }
62
- else {
63
- active_type_filter = active_type_filter === filter ? null : filter;
64
- active_category_filter = null;
65
- }
66
- };
67
- const handle_drag_start = (file) => (event) => {
68
- const file_url = file.url || file.name; // Get the URL to drag (falling back to name)
104
+ }
105
+
106
+ const handle_drag_start = (file: FileInfo) => (event: DragEvent) => {
107
+ const file_url = file.url || file.name // Get the URL to drag (falling back to name)
108
+
69
109
  const payload = JSON.stringify({
70
- name: file.name,
71
- url: file_url,
72
- type: file.type || get_base_file_type(file),
73
- category: file.category,
74
- });
110
+ name: file.name,
111
+ url: file_url,
112
+ type: file.type || get_base_file_type(file),
113
+ category: file.category,
114
+ })
75
115
  // Set file data as JSON for applications that can handle it
76
- event.dataTransfer?.setData(`application/json`, payload);
116
+ event.dataTransfer?.setData(`application/json`, payload)
117
+
77
118
  // Also set plain text as fallback for external applications
78
- event.dataTransfer?.setData(`text/plain`, file_url);
79
- on_drag_start?.(file, event);
80
- };
81
- // Get unique file types/categories for format/category filters
82
- let uniq_formats = $derived([...new Set(files.map(get_base_file_type))].sort());
83
- let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(Boolean).sort());
119
+ event.dataTransfer?.setData(`text/plain`, file_url)
120
+
121
+ on_drag_start?.(file, event)
122
+ }
123
+
124
+ // Get unique file types/categories for format/category filters
125
+ let uniq_formats = $derived([...new Set(files.map(get_base_file_type))].sort())
126
+ let uniq_categories = $derived(
127
+ [...new Set(files.map(get_category_id))].filter(Boolean).sort(),
128
+ )
84
129
  </script>
85
130
 
86
131
  <div class="file-picker" class:vertical={layout === `vertical`} {...rest}>
@@ -103,7 +148,10 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
103
148
  {category}
104
149
  </span>
105
150
  {/each}
106
- {#if uniq_categories.length > 0 && uniq_formats.length > 0}&emsp;{/if}
151
+ {#if show_category_filters && uniq_categories.length > 0 &&
152
+ uniq_formats.length > 0}
153
+ <span class="divider"></span>
154
+ {/if}
107
155
 
108
156
  {#each uniq_formats as format (format)}
109
157
  {@const is_active = active_type_filter === format}
@@ -137,11 +185,9 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
137
185
 
138
186
  {#each filtered_files as file (file.name)}
139
187
  {@const base_type = get_base_file_type(file)}
140
- {@const is_compressed = file.name.toLowerCase().endsWith(`.gz`)}
141
188
  <div
142
189
  class="file-item"
143
190
  class:active={active_files.includes(file.name)}
144
- class:compressed={is_compressed}
145
191
  style:background-color={file_type_colors[base_type]?.replace(`0.8`, `0.08`)}
146
192
  draggable="true"
147
193
  ondragstart={handle_drag_start(file)}
@@ -179,9 +225,14 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
179
225
  ? `Click to load or drag this ${base_type.toUpperCase()} file`
180
226
  : `Drag this ${base_type.toUpperCase()} file`}
181
227
  >
228
+ {#if file.label}
229
+ <span
230
+ class="file-type-badge"
231
+ style:background-color={file_type_colors[base_type] ?? `rgba(128,128,128,0.8)`}
232
+ >{base_type.toUpperCase()}</span>
233
+ {/if}
182
234
  <div class="file-name">
183
- {file.category ? `${file.category_icon} ` : ``}{file.name}
184
- {#if is_compressed}<span class="compression-indicator">📦</span>{/if}
235
+ {file.category ? `${file.category_icon} ` : ``}{file.label ?? file.name}
185
236
  </div>
186
237
  </div>
187
238
  {/each}
@@ -220,6 +271,12 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
220
271
  opacity: 0.8;
221
272
  margin: 0 0 0.5em;
222
273
  }
274
+ .divider {
275
+ width: 1px;
276
+ align-self: stretch;
277
+ background: light-dark(rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.2));
278
+ margin-inline: 0.3em;
279
+ }
223
280
  .legend-item {
224
281
  cursor: pointer;
225
282
  padding: 0.2em 0.4em;
@@ -267,7 +324,10 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
267
324
  cursor: grab;
268
325
  background: light-dark(rgba(0, 0, 0, 0.02), rgba(255, 255, 255, 0.1));
269
326
  transition: all 0.2s ease;
270
- gap: 0.5em;
327
+ gap: 4pt;
328
+ &:has(.file-type-badge) {
329
+ padding-left: 3pt;
330
+ }
271
331
  }
272
332
  .file-item.active {
273
333
  border-color: var(--success-color, #00ff00);
@@ -282,21 +342,19 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
282
342
  background: light-dark(rgba(0, 122, 204, 0.15), rgba(0, 122, 204, 0.25));
283
343
  filter: brightness(1.1);
284
344
  }
345
+ .file-type-badge {
346
+ font-size: 0.5em;
347
+ font-weight: 700;
348
+ letter-spacing: 0.03em;
349
+ padding: 1px 5px;
350
+ border-radius: 10px;
351
+ color: white;
352
+ white-space: nowrap;
353
+ line-height: 1.4;
354
+ }
285
355
  .file-name {
286
356
  font-size: 0.7em;
287
357
  line-height: 1.1;
288
358
  white-space: pre-line;
289
359
  }
290
- .compression-indicator {
291
- opacity: 0.7;
292
- font-size: 0.8em;
293
- margin-left: 0.2em;
294
- }
295
- .file-item.compressed {
296
- border-style: dashed;
297
- opacity: 0.9;
298
- }
299
- .file-item.compressed:hover {
300
- opacity: 1;
301
- }
302
360
  </style>
package/dist/Icon.svelte CHANGED
@@ -1,14 +1,20 @@
1
- <script lang="ts">import { ICON_DATA } from './icons';
2
- let { icon, path, viewBox = `0 0 24 24`, stroke, ...rest } = $props();
3
- const data = $derived.by(() => {
4
- if (path)
5
- return { path, viewBox: viewBox ?? `0 0 24 24`, stroke };
6
- if (icon && icon in ICON_DATA)
7
- return ICON_DATA[icon];
8
- if (icon)
9
- console.error(`Icon '${icon}' not found`);
10
- return ICON_DATA.Alert;
11
- });
1
+ <script lang="ts">
2
+ import type { SVGAttributes } from 'svelte/elements'
3
+ import { ICON_DATA, type IconName } from './icons'
4
+ import { sanitize_icon_svg } from './sanitize'
5
+
6
+ type IconData = { path: string; viewBox: string; stroke?: string }
7
+ let { icon, path, viewBox = `0 0 24 24`, stroke, ...rest }:
8
+ & { icon?: IconName }
9
+ & Partial<IconData>
10
+ & SVGAttributes<SVGSVGElement> = $props()
11
+
12
+ const data: IconData = $derived.by(() => {
13
+ if (path) return { path, viewBox: viewBox ?? `0 0 24 24`, stroke }
14
+ if (icon && icon in ICON_DATA) return ICON_DATA[icon]
15
+ if (icon) console.error(`Icon '${icon}' not found`)
16
+ return ICON_DATA.Alert
17
+ })
12
18
  </script>
13
19
 
14
20
  <svg
@@ -19,7 +25,7 @@ const data = $derived.by(() => {
19
25
  {...rest}
20
26
  >
21
27
  {#if data.path.trim().startsWith(`<`)}
22
- {@html data.path}
28
+ {@html sanitize_icon_svg(data.path)}
23
29
  {:else}
24
30
  <path d={data.path} />
25
31
  {/if}
@@ -27,8 +33,8 @@ const data = $derived.by(() => {
27
33
 
28
34
  <style>
29
35
  svg {
30
- width: 1em;
31
- height: auto;
36
+ width: var(--icon-size, 1em);
37
+ height: var(--icon-size, auto);
32
38
  display: inline-block;
33
39
  vertical-align: middle;
34
40
  }
@@ -1,28 +1,34 @@
1
- <script lang="ts">let { value = $bindable([0, 0, 1]) } = $props();
2
- // Format: compact "001" for single-digit, spaced "10 0 1" for multi-digit
3
- let hkl_text = $derived(value.every((v) => Math.abs(v) < 10) ? value.join(``) : value.join(` `));
4
- // Parse hkl string: supports compact "001"/"-101" and spaced/comma "10, 0, 1"
5
- function parse_hkl(input) {
1
+ <script lang="ts">
2
+ // Compact single-field input for Miller indices (hkl).
3
+ // Accepts "001", "111", "-101", "1 0 1", "10, 0, 1" and emits a Vec3 tuple.
4
+ import type { Vec3 } from './math'
5
+
6
+ let { value = $bindable([0, 0, 1]) }: { value?: Vec3 } = $props()
7
+
8
+ // Format: compact "001" for single-digit, spaced "10 0 1" for multi-digit
9
+ let hkl_text = $derived(
10
+ value.every((v) => Math.abs(v) < 10) ? value.join(``) : value.join(` `),
11
+ )
12
+
13
+ // Parse hkl string: supports compact "001"/"-101" and spaced/comma "10, 0, 1"
14
+ function parse_hkl(input: string): Vec3 | null {
6
15
  // Try spaced/comma format first (handles multi-digit)
7
- const spaced = input.trim().split(/[,\s]+/);
16
+ const spaced = input.trim().split(/[,\s]+/)
8
17
  if (spaced.length === 3) {
9
- const nums = spaced.map(Number);
10
- if (nums.every((n) => !isNaN(n)))
11
- return nums;
18
+ const nums = spaced.map(Number)
19
+ if (nums.every((n) => !isNaN(n))) return nums as Vec3
12
20
  }
13
21
  // Fall back to compact single-digit format: "001", "-101"
14
- const compact = input.replace(/\s+/g, ``);
15
- const match = compact.match(/^(-?\d)(-?\d)(-?\d)$/);
16
- if (match)
17
- return [Number(match[1]), Number(match[2]), Number(match[3])];
18
- return null;
19
- }
20
- function handle_input(event) {
21
- const parsed = parse_hkl(event.target.value);
22
- if (parsed)
23
- value = parsed;
24
- }
25
- export {};
22
+ const compact = input.replace(/\s+/g, ``)
23
+ const match = compact.match(/^(-?\d)(-?\d)(-?\d)$/)
24
+ if (match) return [Number(match[1]), Number(match[2]), Number(match[3])] as Vec3
25
+ return null
26
+ }
27
+
28
+ function handle_input(event: Event) {
29
+ const parsed = parse_hkl((event.target as HTMLInputElement).value)
30
+ if (parsed) value = parsed
31
+ }
26
32
  </script>
27
33
 
28
34
  <label class="miller-input">
@@ -1,4 +1,3 @@
1
- // deno-lint-ignore-file no-await-in-loop
2
1
  // OPTIMADE API utilities for fetching structure data
3
2
  // Based on OPTIMADE 1.2.0 specification
4
3
  // Multiple CORS proxies for fallback reliability
@@ -18,7 +17,7 @@ const RESOLVED_URLS_CACHE_DURATION = 10 * 60 * 1000;
18
17
  async function fetch_with_cors_proxy(url) {
19
18
  try {
20
19
  const direct_response = await fetch(url, {
21
- headers: { 'Accept': `application/vnd.api+json`, 'User-Agent': `MatterViz/1.0` },
20
+ headers: { Accept: `application/vnd.api+json`, 'User-Agent': `MatterViz/1.0` },
22
21
  });
23
22
  if (direct_response.ok)
24
23
  return direct_response;
@@ -29,7 +28,7 @@ async function fetch_with_cors_proxy(url) {
29
28
  for (const proxy of CORS_PROXIES) {
30
29
  try {
31
30
  const response = await fetch(`${proxy}${encodeURIComponent(url)}`, {
32
- headers: { 'Accept': `application/vnd.api+json`, 'User-Agent': `MatterViz/1.0` },
31
+ headers: { Accept: `application/vnd.api+json`, 'User-Agent': `MatterViz/1.0` },
33
32
  });
34
33
  if (response.ok)
35
34
  return response;
@@ -43,14 +42,15 @@ async function fetch_with_cors_proxy(url) {
43
42
  async function resolve_provider_url(provider_base_url) {
44
43
  const now = Date.now();
45
44
  if (resolved_provider_urls[provider_base_url] &&
46
- (now - resolved_urls_cache_time) < RESOLVED_URLS_CACHE_DURATION) {
45
+ now - resolved_urls_cache_time < RESOLVED_URLS_CACHE_DURATION) {
47
46
  return resolved_provider_urls[provider_base_url];
48
47
  }
49
48
  for (const endpoint of [`/links`, `/v1/links`]) {
50
49
  try {
51
50
  const response = await fetch_with_cors_proxy(`${provider_base_url}${endpoint}`);
52
51
  const data = await response.json();
53
- const self_link = data.data?.find((link) => link.type === `links` && link.attributes?.base_url &&
52
+ const self_link = data.data?.find((link) => link.type === `links` &&
53
+ link.attributes?.base_url &&
54
54
  link.attributes.link_type === `child`);
55
55
  if (self_link?.attributes.base_url) {
56
56
  resolved_provider_urls[provider_base_url] = self_link.attributes.base_url;
@@ -68,7 +68,7 @@ async function resolve_provider_url(provider_base_url) {
68
68
  }
69
69
  export async function fetch_optimade_providers() {
70
70
  const now = Date.now();
71
- if (cached_providers && (now - providers_cache_time) < CACHE_DURATION) {
71
+ if (cached_providers && now - providers_cache_time < CACHE_DURATION) {
72
72
  return cached_providers;
73
73
  }
74
74
  try {