matterviz 0.2.0 → 0.2.1
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.
- package/dist/EmptyState.svelte +39 -0
- package/dist/EmptyState.svelte.d.ts +9 -0
- package/dist/FilePicker.svelte +14 -3
- package/dist/FilePicker.svelte.d.ts +2 -1
- package/dist/api/mp.js +1 -1
- package/dist/app.css +1 -0
- package/dist/brillouin/BrillouinZone.svelte +7 -22
- package/dist/brillouin/BrillouinZone.svelte.d.ts +8 -8
- package/dist/brillouin/BrillouinZoneControls.svelte +2 -1
- package/dist/brillouin/BrillouinZoneControls.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte.d.ts +3 -3
- package/dist/brillouin/BrillouinZoneScene.svelte +3 -2
- package/dist/brillouin/compute.d.ts +1 -1
- package/dist/brillouin/types.d.ts +3 -2
- package/dist/colors/index.d.ts +2 -0
- package/dist/colors/index.js +41 -1
- package/dist/composition/BarChart.svelte +2 -2
- package/dist/composition/BarChart.svelte.d.ts +2 -1
- package/dist/composition/BubbleChart.svelte.d.ts +2 -1
- package/dist/composition/Composition.svelte +1 -1
- package/dist/composition/Composition.svelte.d.ts +2 -1
- package/dist/composition/Formula.svelte +1 -1
- package/dist/composition/Formula.svelte.d.ts +3 -2
- package/dist/composition/FormulaFilter.svelte +37 -15
- package/dist/composition/PieChart.svelte +1 -1
- package/dist/composition/PieChart.svelte.d.ts +2 -1
- package/dist/composition/format.d.ts +2 -1
- package/dist/composition/index.d.ts +1 -1
- package/dist/composition/parse.d.ts +20 -2
- package/dist/composition/parse.js +145 -1
- package/dist/convex-hull/ConvexHull2D.svelte +13 -17
- package/dist/convex-hull/ConvexHull3D.svelte +4 -4
- package/dist/convex-hull/ConvexHull4D.svelte +4 -4
- package/dist/convex-hull/ConvexHullControls.svelte +2 -1
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +2 -2
- package/dist/convex-hull/ConvexHullInfoPane.svelte +1 -1
- package/dist/convex-hull/ConvexHullInfoPane.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullStats.svelte +3 -1
- package/dist/convex-hull/PhaseEntryTooltip.svelte +1 -1
- package/dist/convex-hull/StructurePopup.svelte +1 -1
- package/dist/convex-hull/StructurePopup.svelte.d.ts +1 -1
- package/dist/convex-hull/barycentric-coords.d.ts +2 -2
- package/dist/convex-hull/barycentric-coords.js +5 -7
- package/dist/convex-hull/helpers.d.ts +2 -2
- package/dist/convex-hull/helpers.js +4 -5
- package/dist/convex-hull/thermodynamics.d.ts +2 -2
- package/dist/convex-hull/thermodynamics.js +131 -137
- package/dist/convex-hull/types.d.ts +4 -2
- package/dist/convex-hull/types.js +1 -3
- package/dist/coordination/CoordinationBarPlot.svelte +8 -8
- package/dist/coordination/CoordinationBarPlot.svelte.d.ts +3 -2
- package/dist/coordination/calc-coordination.d.ts +1 -1
- package/dist/element/BohrAtom.svelte +1 -1
- package/dist/element/ElementHeading.svelte.d.ts +1 -1
- package/dist/element/ElementPhoto.svelte +1 -1
- package/dist/element/ElementPhoto.svelte.d.ts +1 -1
- package/dist/element/ElementStats.svelte +3 -1
- package/dist/element/ElementStats.svelte.d.ts +1 -1
- package/dist/element/ElementTile.svelte +8 -4
- package/dist/element/ElementTile.svelte.d.ts +1 -1
- package/dist/element/index.d.ts +1 -0
- package/dist/element/types.d.ts +46 -0
- package/dist/element/types.js +1 -0
- package/dist/feedback/ClickFeedback.svelte +1 -1
- package/dist/feedback/ClickFeedback.svelte.d.ts +1 -1
- package/dist/feedback/DragOverlay.svelte +1 -1
- package/dist/feedback/StatusMessage.svelte +30 -45
- package/dist/feedback/StatusMessage.svelte.d.ts +2 -2
- package/dist/fermi-surface/FermiSlice.svelte +159 -0
- package/dist/fermi-surface/FermiSlice.svelte.d.ts +24 -0
- package/dist/fermi-surface/FermiSurface.svelte +459 -0
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +68 -0
- package/dist/fermi-surface/FermiSurfaceControls.svelte +380 -0
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +34 -0
- package/dist/fermi-surface/FermiSurfaceScene.svelte +504 -0
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +49 -0
- package/dist/fermi-surface/compute.d.ts +5 -0
- package/dist/fermi-surface/compute.js +562 -0
- package/dist/fermi-surface/constants.d.ts +8 -0
- package/dist/fermi-surface/constants.js +24 -0
- package/dist/fermi-surface/export.d.ts +5 -0
- package/dist/fermi-surface/export.js +63 -0
- package/dist/fermi-surface/index.d.ts +11 -0
- package/dist/fermi-surface/index.js +12 -0
- package/dist/fermi-surface/marching-cubes.d.ts +13 -0
- package/dist/fermi-surface/marching-cubes.js +519 -0
- package/dist/fermi-surface/parse.d.ts +2 -0
- package/dist/fermi-surface/parse.js +491 -0
- package/dist/fermi-surface/symmetry.d.ts +3 -0
- package/dist/fermi-surface/symmetry.js +51 -0
- package/dist/fermi-surface/types.d.ts +93 -0
- package/dist/fermi-surface/types.js +4 -0
- package/dist/icons.d.ts +4 -0
- package/dist/icons.js +4 -0
- package/dist/index.d.ts +6 -64
- package/dist/index.js +6 -38
- package/dist/io/decompress.d.ts +1 -0
- package/dist/io/decompress.js +9 -2
- package/dist/io/export.d.ts +1 -1
- package/dist/io/index.d.ts +2 -0
- package/dist/io/index.js +3 -1
- package/dist/io/is-binary.d.ts +1 -0
- package/dist/io/is-binary.js +6 -0
- package/dist/io/types.d.ts +7 -0
- package/dist/io/types.js +1 -0
- package/dist/labels.d.ts +2 -2
- package/dist/labels.js +7 -10
- package/dist/layout/InfoCard.svelte +1 -1
- package/dist/layout/InfoTag.svelte +2 -2
- package/dist/layout/SettingsSection.svelte +1 -1
- package/dist/layout/fullscreen.d.ts +7 -0
- package/dist/layout/fullscreen.js +20 -0
- package/dist/math.d.ts +38 -2
- package/dist/math.js +127 -9
- package/dist/overlays/ContextMenu.svelte +1 -1
- package/dist/overlays/DraggablePane.svelte +1 -1
- package/dist/periodic-table/PeriodicTable.svelte +18 -12
- package/dist/periodic-table/PeriodicTable.svelte.d.ts +2 -2
- package/dist/periodic-table/PropertySelect.svelte.d.ts +1 -1
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +767 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +40 -0
- package/dist/phase-diagram/IsobaricTernaryPhaseDiagram.svelte +291 -0
- package/dist/phase-diagram/IsobaricTernaryPhaseDiagram.svelte.d.ts +45 -0
- package/dist/phase-diagram/IsobaricTernaryPhaseDiagramScene.svelte +396 -0
- package/dist/phase-diagram/IsobaricTernaryPhaseDiagramScene.svelte.d.ts +33 -0
- package/dist/phase-diagram/IsothermalSlicePanel.svelte +224 -0
- package/dist/phase-diagram/IsothermalSlicePanel.svelte.d.ts +12 -0
- package/dist/phase-diagram/PhaseDiagramControls.svelte +368 -0
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +29 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +142 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +12 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +263 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +12 -0
- package/dist/phase-diagram/TdbInfoPanel.svelte +179 -0
- package/dist/phase-diagram/TdbInfoPanel.svelte.d.ts +12 -0
- package/dist/phase-diagram/TernaryPhaseDiagramControls.svelte +214 -0
- package/dist/phase-diagram/TernaryPhaseDiagramControls.svelte.d.ts +24 -0
- package/dist/phase-diagram/VerticalSlicePanel.svelte +293 -0
- package/dist/phase-diagram/VerticalSlicePanel.svelte.d.ts +12 -0
- package/dist/phase-diagram/index.d.ts +13 -0
- package/dist/phase-diagram/index.js +13 -0
- package/dist/phase-diagram/parse.d.ts +55 -0
- package/dist/phase-diagram/parse.js +275 -0
- package/dist/phase-diagram/types.d.ts +181 -0
- package/dist/phase-diagram/types.js +1 -0
- package/dist/phase-diagram/utils.d.ts +184 -0
- package/dist/phase-diagram/utils.js +653 -0
- package/dist/plot/BarPlot.svelte +272 -74
- package/dist/plot/BarPlot.svelte.d.ts +66 -28
- package/dist/plot/BarPlotControls.svelte +5 -5
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +3 -3
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +1 -1
- package/dist/plot/ColorScaleSelect.svelte.d.ts +1 -1
- package/dist/plot/ElementScatter.svelte +3 -1
- package/dist/plot/ElementScatter.svelte.d.ts +1 -1
- package/dist/plot/Histogram.svelte +41 -36
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +6 -5
- package/dist/plot/HistogramControls.svelte.d.ts +1 -1
- package/dist/plot/PlotControls.svelte +8 -6
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +213 -68
- package/dist/plot/PlotLegend.svelte.d.ts +2 -0
- package/dist/plot/PlotTooltip.svelte +2 -1
- package/dist/plot/PlotTooltip.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot.svelte +229 -238
- package/dist/plot/ScatterPlot.svelte.d.ts +67 -51
- package/dist/plot/ScatterPlot3D.svelte +336 -0
- package/dist/plot/ScatterPlot3D.svelte.d.ts +92 -0
- package/dist/plot/ScatterPlot3DControls.svelte +272 -0
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +19 -0
- package/dist/plot/ScatterPlot3DScene.svelte +654 -0
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +72 -0
- package/dist/plot/ScatterPlotControls.svelte +3 -3
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/SpacegroupBarPlot.svelte +1 -2
- package/dist/plot/Surface3D.svelte +149 -0
- package/dist/plot/Surface3D.svelte.d.ts +13 -0
- package/dist/plot/data-transform.d.ts +5 -2
- package/dist/plot/data-transform.js +27 -17
- package/dist/plot/defaults.d.ts +19 -0
- package/dist/plot/defaults.js +9 -0
- package/dist/plot/index.d.ts +5 -1
- package/dist/plot/index.js +5 -1
- package/dist/plot/interactions.d.ts +1 -1
- package/dist/plot/interactions.js +1 -3
- package/dist/plot/layout.d.ts +5 -1
- package/dist/plot/layout.js +37 -9
- package/dist/plot/types.d.ts +118 -15
- package/dist/plot/types.js +23 -0
- package/dist/plot/utils/label-placement.d.ts +1 -11
- package/dist/plot/utils/series-visibility.d.ts +6 -4
- package/dist/plot/utils/series-visibility.js +17 -5
- package/dist/rdf/RdfPlot.svelte +12 -14
- package/dist/rdf/RdfPlot.svelte.d.ts +4 -4
- package/dist/rdf/calc-rdf.d.ts +3 -3
- package/dist/rdf/calc-rdf.js +23 -19
- package/dist/rdf/index.d.ts +1 -0
- package/dist/settings.js +2 -2
- package/dist/spectral/Bands.svelte +57 -1
- package/dist/spectral/Bands.svelte.d.ts +1 -0
- package/dist/spectral/BandsAndDos.svelte +17 -9
- package/dist/spectral/BandsAndDos.svelte.d.ts +2 -2
- package/dist/spectral/BrillouinBandsDos.svelte +32 -9
- package/dist/spectral/BrillouinBandsDos.svelte.d.ts +2 -2
- package/dist/spectral/Dos.svelte +92 -22
- package/dist/spectral/Dos.svelte.d.ts +3 -2
- package/dist/spectral/helpers.d.ts +4 -0
- package/dist/spectral/helpers.js +170 -19
- package/dist/spectral/types.d.ts +5 -3
- package/dist/state.svelte.d.ts +1 -1
- package/dist/structure/Arrow.svelte.d.ts +1 -1
- package/dist/structure/AtomLegend.svelte +15 -13
- package/dist/structure/AtomLegend.svelte.d.ts +4 -2
- package/dist/structure/CellSelect.svelte +254 -0
- package/dist/structure/CellSelect.svelte.d.ts +13 -0
- package/dist/structure/Cylinder.svelte +1 -1
- package/dist/structure/Cylinder.svelte.d.ts +1 -1
- package/dist/structure/Lattice.svelte +2 -3
- package/dist/structure/Structure.svelte +73 -34
- package/dist/structure/Structure.svelte.d.ts +6 -4
- package/dist/structure/StructureControls.svelte +23 -4
- package/dist/structure/StructureControls.svelte.d.ts +6 -4
- package/dist/structure/StructureExportPane.svelte +1 -1
- package/dist/structure/StructureExportPane.svelte.d.ts +3 -3
- package/dist/structure/StructureInfoPane.svelte +14 -10
- package/dist/structure/StructureInfoPane.svelte.d.ts +2 -2
- package/dist/structure/StructureScene.svelte +4 -2
- package/dist/structure/StructureScene.svelte.d.ts +4 -2
- package/dist/structure/atom-properties.d.ts +2 -2
- package/dist/structure/atom-properties.js +22 -24
- package/dist/structure/bonding.d.ts +2 -1
- package/dist/structure/bonding.js +39 -37
- package/dist/structure/export.d.ts +1 -1
- package/dist/structure/export.js +24 -44
- package/dist/structure/index.d.ts +16 -15
- package/dist/structure/index.js +20 -20
- package/dist/structure/measure.d.ts +1 -2
- package/dist/structure/parse.d.ts +6 -4
- package/dist/structure/parse.js +181 -144
- package/dist/structure/pbc.d.ts +2 -1
- package/dist/structure/pbc.js +5 -0
- package/dist/structure/supercell.d.ts +2 -3
- package/dist/structure/supercell.js +50 -69
- package/dist/structure/validation.d.ts +2 -2
- package/dist/structure/validation.js +1 -1
- package/dist/symmetry/SymmetryStats.svelte +1 -1
- package/dist/symmetry/WyckoffTable.svelte +2 -1
- package/dist/symmetry/cell-transform.d.ts +12 -0
- package/dist/symmetry/cell-transform.js +75 -0
- package/dist/symmetry/index.d.ts +5 -4
- package/dist/symmetry/index.js +7 -6
- package/dist/table/HeatmapTable.svelte +1086 -0
- package/dist/table/HeatmapTable.svelte.d.ts +29 -0
- package/dist/table/index.d.ts +66 -0
- package/dist/table/index.js +39 -0
- package/dist/trajectory/Trajectory.svelte +19 -32
- package/dist/trajectory/Trajectory.svelte.d.ts +2 -1
- package/dist/trajectory/TrajectoryExportPane.svelte +2 -1
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +3 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte.d.ts +1 -1
- package/dist/trajectory/index.d.ts +3 -1
- package/dist/trajectory/parse.d.ts +1 -1
- package/dist/trajectory/parse.js +10 -8
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +7 -0
- package/dist/xrd/XrdPlot.svelte +125 -35
- package/dist/xrd/XrdPlot.svelte.d.ts +1 -1
- package/dist/xrd/atomic-scattering-params.d.ts +1 -1
- package/dist/xrd/broadening.js +1 -1
- package/dist/xrd/calc-xrd.d.ts +6 -4
- package/dist/xrd/calc-xrd.js +46 -13
- package/dist/xrd/index.d.ts +4 -2
- package/dist/xrd/index.js +1 -0
- package/dist/xrd/parse.d.ts +13 -0
- package/dist/xrd/parse.js +749 -0
- package/package.json +44 -21
- package/dist/structure/SupercellSelector.svelte +0 -145
- package/dist/structure/SupercellSelector.svelte.d.ts +0 -9
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script lang="ts">let { message, children, ...rest } = $props();
|
|
2
|
+
export {};
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<div {...rest} class="empty-state {rest.class ?? ``}">
|
|
6
|
+
{#if children}
|
|
7
|
+
{@render children()}
|
|
8
|
+
{:else if message}
|
|
9
|
+
<span class="message">{message}</span>
|
|
10
|
+
{/if}
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<style>
|
|
14
|
+
.empty-state {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex-direction: column;
|
|
17
|
+
align-items: center;
|
|
18
|
+
justify-content: center;
|
|
19
|
+
flex: 1;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
min-height: inherit;
|
|
23
|
+
text-align: center;
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
}
|
|
26
|
+
.empty-state :global(.status-message) {
|
|
27
|
+
--status-message-border: none; /* Remove inner border from StatusMessage */
|
|
28
|
+
}
|
|
29
|
+
.empty-state > :global(:is(p, h3, ul, strong)), .empty-state > .message {
|
|
30
|
+
max-width: var(--empty-state-max-width, 500px);
|
|
31
|
+
}
|
|
32
|
+
.empty-state :global(p), .empty-state > .message {
|
|
33
|
+
color: var(--text-color-muted);
|
|
34
|
+
margin: 0;
|
|
35
|
+
}
|
|
36
|
+
.empty-state :global(h3) {
|
|
37
|
+
margin: 0 0 0.5em;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
type $$ComponentProps = {
|
|
4
|
+
message?: string;
|
|
5
|
+
children?: Snippet;
|
|
6
|
+
} & HTMLAttributes<HTMLDivElement>;
|
|
7
|
+
declare const EmptyState: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type EmptyState = ReturnType<typeof EmptyState>;
|
|
9
|
+
export default EmptyState;
|
package/dist/FilePicker.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">import { tooltip } from 'svelte-multiselect';
|
|
2
|
-
let { files = [], active_files = [], show_category_filters = false, on_drag_start, on_drag_end, type_mapper, file_type_colors = {
|
|
2
|
+
let { files = [], active_files = [], show_category_filters = false, on_drag_start, on_drag_end, on_click, type_mapper, file_type_colors = {
|
|
3
3
|
cif: `rgba(100, 149, 237, 0.8)`,
|
|
4
4
|
xyz: `rgba(50, 205, 50, 0.8)`,
|
|
5
5
|
extxyz: `rgba(50, 205, 50, 0.8)`,
|
|
@@ -11,6 +11,7 @@ let { files = [], active_files = [], show_category_filters = false, on_drag_star
|
|
|
11
11
|
md: `rgba(255, 215, 0, 0.8)`,
|
|
12
12
|
yaml: `rgba(255, 0, 255, 0.8)`,
|
|
13
13
|
xdatcar: `rgba(255, 215, 0, 0.8)`,
|
|
14
|
+
tdb: `rgba(0, 188, 212, 0.8)`, // Cyan for thermodynamic database files
|
|
14
15
|
}, ...rest } = $props();
|
|
15
16
|
let active_category_filter = $state(null);
|
|
16
17
|
let active_type_filter = $state(null);
|
|
@@ -134,9 +135,18 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
|
|
|
134
135
|
draggable="true"
|
|
135
136
|
ondragstart={handle_drag_start(file)}
|
|
136
137
|
ondragend={() => on_drag_end?.()}
|
|
138
|
+
onclick={(event) => on_click?.(file, event)}
|
|
139
|
+
onkeydown={(event) => {
|
|
140
|
+
if ([`Enter`, ` `].includes(event.key)) {
|
|
141
|
+
event.preventDefault()
|
|
142
|
+
on_click?.(file, event)
|
|
143
|
+
}
|
|
144
|
+
}}
|
|
137
145
|
role="button"
|
|
138
146
|
tabindex="0"
|
|
139
|
-
title=
|
|
147
|
+
title={on_click
|
|
148
|
+
? `Click to load or drag this ${base_type.toUpperCase()} file`
|
|
149
|
+
: `Drag this ${base_type.toUpperCase()} file`}
|
|
140
150
|
>
|
|
141
151
|
<div class="file-name">
|
|
142
152
|
{file.category ? `${file.category_icon} ` : ``}{file.name}
|
|
@@ -157,8 +167,9 @@ let uniq_categories = $derived([...new Set(files.map(get_category_id))].filter(B
|
|
|
157
167
|
.legend {
|
|
158
168
|
width: 100%;
|
|
159
169
|
display: flex;
|
|
170
|
+
flex-wrap: wrap;
|
|
160
171
|
align-items: center;
|
|
161
|
-
gap:
|
|
172
|
+
gap: 2pt 5pt;
|
|
162
173
|
font-size: 0.6em;
|
|
163
174
|
opacity: 0.8;
|
|
164
175
|
margin: 0 0 0.5em;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FileInfo } from './';
|
|
1
|
+
import type { FileInfo } from './io';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
3
|
type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
4
4
|
files?: FileInfo[];
|
|
@@ -6,6 +6,7 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
6
6
|
show_category_filters?: boolean;
|
|
7
7
|
on_drag_start?: (file: FileInfo, event: DragEvent) => void;
|
|
8
8
|
on_drag_end?: () => void;
|
|
9
|
+
on_click?: (file: FileInfo, event: MouseEvent | KeyboardEvent) => void;
|
|
9
10
|
type_mapper?: (file: FileInfo) => string;
|
|
10
11
|
file_type_colors?: Record<string, string>;
|
|
11
12
|
};
|
package/dist/api/mp.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fetch_zipped } from '../io/fetch';
|
|
2
|
-
//
|
|
2
|
+
// Materials Project S3 bucket for pre-computed data (may be outdated)
|
|
3
3
|
export const mp_bucket = `https://materialsproject-build.s3.amazonaws.com/collections/2022-10-28`;
|
|
4
4
|
// Fetch all material data in parallel
|
|
5
5
|
export async function fetch_material_data(material_id, bucket = mp_bucket) {
|
package/dist/app.css
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
<script lang="ts">import {
|
|
1
|
+
<script lang="ts">import { toggle_fullscreen } from '../layout';
|
|
2
|
+
import EmptyState from '../EmptyState.svelte';
|
|
3
|
+
import Spinner from '../feedback/Spinner.svelte';
|
|
4
|
+
import Icon from '../Icon.svelte';
|
|
2
5
|
import { decompress_file, handle_url_drop, load_from_url } from '../io';
|
|
3
6
|
import { set_fullscreen_bg } from '../layout';
|
|
4
7
|
import { DEFAULTS } from '../settings';
|
|
@@ -257,12 +260,10 @@ $effect(() => {
|
|
|
257
260
|
{:else if structure}
|
|
258
261
|
<p class="warn">Structure must have a lattice to compute Brillouin zone</p>
|
|
259
262
|
{:else}
|
|
260
|
-
<
|
|
263
|
+
<EmptyState>
|
|
261
264
|
<h3>Drop Structure File</h3>
|
|
262
|
-
<p>
|
|
263
|
-
|
|
264
|
-
</p>
|
|
265
|
-
</div>
|
|
265
|
+
<p>Supports CIF, POSCAR, JSON, (ext)XYZ, (+ .gz)</p>
|
|
266
|
+
</EmptyState>
|
|
266
267
|
{/if}
|
|
267
268
|
</div>
|
|
268
269
|
|
|
@@ -362,20 +363,4 @@ $effect(() => {
|
|
|
362
363
|
.error-state button:hover {
|
|
363
364
|
background: var(--error-color-hover, #ff5252);
|
|
364
365
|
}
|
|
365
|
-
.empty-state {
|
|
366
|
-
display: flex;
|
|
367
|
-
flex-direction: column;
|
|
368
|
-
align-items: center;
|
|
369
|
-
justify-content: center;
|
|
370
|
-
height: 100%;
|
|
371
|
-
text-align: center;
|
|
372
|
-
}
|
|
373
|
-
.empty-state h3 {
|
|
374
|
-
margin: 0 0 0.5em;
|
|
375
|
-
font-size: 1.5em;
|
|
376
|
-
}
|
|
377
|
-
.empty-state p {
|
|
378
|
-
color: var(--text-color-muted);
|
|
379
|
-
margin: 0;
|
|
380
|
-
}
|
|
381
366
|
</style>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Spinner from '../feedback/Spinner.svelte';
|
|
2
2
|
import type { Vec3 } from '../math';
|
|
3
3
|
import { type CameraProjection } from '../settings';
|
|
4
|
-
import type {
|
|
4
|
+
import type { Crystal } from '../structure';
|
|
5
5
|
import type { ComponentProps, Snippet } from 'svelte';
|
|
6
6
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
7
|
import type { BrillouinZoneData } from './types';
|
|
8
8
|
type BZHandlerData = {
|
|
9
|
-
structure?:
|
|
9
|
+
structure?: Crystal;
|
|
10
10
|
bz_data?: BrillouinZoneData;
|
|
11
11
|
bz_order?: number;
|
|
12
12
|
filename?: string;
|
|
@@ -15,7 +15,7 @@ type BZHandlerData = {
|
|
|
15
15
|
fullscreen?: boolean;
|
|
16
16
|
};
|
|
17
17
|
type $$ComponentProps = {
|
|
18
|
-
structure?:
|
|
18
|
+
structure?: Crystal;
|
|
19
19
|
bz_order?: number;
|
|
20
20
|
bz_data?: BrillouinZoneData;
|
|
21
21
|
controls_open?: boolean;
|
|
@@ -47,14 +47,14 @@ type $$ComponentProps = {
|
|
|
47
47
|
structure_string?: string;
|
|
48
48
|
k_path_points?: Vec3[];
|
|
49
49
|
k_path_labels?: {
|
|
50
|
-
position:
|
|
50
|
+
position: Vec3;
|
|
51
51
|
label: string | null;
|
|
52
52
|
}[];
|
|
53
|
-
hovered_k_point?:
|
|
53
|
+
hovered_k_point?: Vec3 | null;
|
|
54
54
|
hovered_qpoint_index?: number | null;
|
|
55
55
|
children?: Snippet<[
|
|
56
56
|
{
|
|
57
|
-
structure?:
|
|
57
|
+
structure?: Crystal;
|
|
58
58
|
bz_data?: BrillouinZoneData;
|
|
59
59
|
}
|
|
60
60
|
]>;
|
|
@@ -62,6 +62,6 @@ type $$ComponentProps = {
|
|
|
62
62
|
on_error?: (data: BZHandlerData) => void;
|
|
63
63
|
on_fullscreen_change?: (data: BZHandlerData) => void;
|
|
64
64
|
} & HTMLAttributes<HTMLDivElement>;
|
|
65
|
-
declare const BrillouinZone: import("svelte").Component<$$ComponentProps, {}, "
|
|
65
|
+
declare const BrillouinZone: import("svelte").Component<$$ComponentProps, {}, "height" | "width" | "dragover" | "fullscreen" | "hovered" | "controls_open" | "structure" | "camera_projection" | "info_pane_open" | "loading" | "error_msg" | "wrapper" | "png_dpi" | "bz_order" | "surface_color" | "surface_opacity" | "edge_color" | "edge_width" | "show_vectors" | "bz_data" | "vector_scale">;
|
|
66
66
|
type BrillouinZone = ReturnType<typeof BrillouinZone>;
|
|
67
67
|
export default BrillouinZone;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
<script lang="ts">import
|
|
1
|
+
<script lang="ts">import SettingsSection from '../layout/SettingsSection.svelte';
|
|
2
|
+
import DraggablePane from '../overlays/DraggablePane.svelte';
|
|
2
3
|
let { controls_open = $bindable(false), bz_order = $bindable(1), surface_color = $bindable(`#4488ff`), surface_opacity = $bindable(0.3), edge_color = $bindable(`#000000`), edge_width = $bindable(0.05), show_vectors = $bindable(true), camera_projection = $bindable(`perspective`), } = $props();
|
|
3
4
|
</script>
|
|
4
5
|
|
|
@@ -9,6 +9,6 @@ type $$ComponentProps = {
|
|
|
9
9
|
show_vectors?: boolean;
|
|
10
10
|
camera_projection?: CameraProjection;
|
|
11
11
|
};
|
|
12
|
-
declare const BrillouinZoneControls: import("svelte").Component<$$ComponentProps, {}, "
|
|
12
|
+
declare const BrillouinZoneControls: import("svelte").Component<$$ComponentProps, {}, "controls_open" | "camera_projection" | "bz_order" | "surface_color" | "surface_opacity" | "edge_color" | "edge_width" | "show_vectors">;
|
|
13
13
|
type BrillouinZoneControls = ReturnType<typeof BrillouinZoneControls>;
|
|
14
14
|
export default BrillouinZoneControls;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">import
|
|
1
|
+
<script lang="ts">import DraggablePane from '../overlays/DraggablePane.svelte';
|
|
2
2
|
import { export_canvas_as_png } from '../io/export';
|
|
3
3
|
import { tooltip } from 'svelte-multiselect/attachments';
|
|
4
4
|
let { export_pane_open = $bindable(false), bz_data, wrapper, scene, camera, filename = `brillouin-zone`, png_dpi = $bindable(150), ...rest } = $props();
|
|
@@ -10,6 +10,6 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
10
10
|
filename?: string;
|
|
11
11
|
png_dpi?: number;
|
|
12
12
|
};
|
|
13
|
-
declare const BrillouinZoneExportPane: import("svelte").Component<$$ComponentProps, {}, "
|
|
13
|
+
declare const BrillouinZoneExportPane: import("svelte").Component<$$ComponentProps, {}, "export_pane_open" | "png_dpi">;
|
|
14
14
|
type BrillouinZoneExportPane = ReturnType<typeof BrillouinZoneExportPane>;
|
|
15
15
|
export default BrillouinZoneExportPane;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">import
|
|
1
|
+
<script lang="ts">import DraggablePane from '../overlays/DraggablePane.svelte';
|
|
2
2
|
import { format_num } from '../labels';
|
|
3
3
|
import { analyze_structure_symmetry } from '../symmetry';
|
|
4
4
|
let { pane_open = $bindable(false), structure, bz_data, pane_props = {}, } = $props();
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import DraggablePane from '../overlays/DraggablePane.svelte';
|
|
2
|
+
import type { Crystal } from '../structure';
|
|
3
3
|
import type { ComponentProps } from 'svelte';
|
|
4
4
|
import type { BrillouinZoneData } from './types';
|
|
5
5
|
type $$ComponentProps = {
|
|
6
6
|
pane_open?: boolean;
|
|
7
|
-
structure?:
|
|
7
|
+
structure?: Crystal;
|
|
8
8
|
bz_data?: BrillouinZoneData;
|
|
9
9
|
pane_props?: ComponentProps<typeof DraggablePane>[`pane_props`];
|
|
10
10
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
<script lang="ts">import { AXIS_COLORS, NEG_AXIS_COLORS } from '
|
|
1
|
+
<script lang="ts">import { AXIS_COLORS, NEG_AXIS_COLORS } from '../colors';
|
|
2
2
|
import * as math from '../math';
|
|
3
3
|
import { DEFAULTS } from '../settings';
|
|
4
|
-
import
|
|
4
|
+
import Arrow from '../structure/Arrow.svelte';
|
|
5
|
+
import Cylinder from '../structure/Cylinder.svelte';
|
|
5
6
|
import { T, useThrelte } from '@threlte/core';
|
|
6
7
|
import * as extras from '@threlte/extras';
|
|
7
8
|
import { BufferAttribute, BufferGeometry } from 'three';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Matrix3x3, Vec3 } from '
|
|
1
|
+
import type { Matrix3x3, Vec3 } from '../math';
|
|
2
2
|
import type { BrillouinZoneData, ConvexHullData } from './types';
|
|
3
3
|
export declare function reciprocal_lattice(real_lattice: Matrix3x3): Matrix3x3;
|
|
4
4
|
export declare function generate_bz_vertices(k_lattice: Matrix3x3, order?: 1 | 2 | 3, max_planes_by_order?: Record<1 | 2 | 3, number>): Vec3[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Matrix3x3,
|
|
1
|
+
import type { Matrix3x3, Vec3 } from '../math';
|
|
2
|
+
import type { Crystal } from '../structure';
|
|
2
3
|
export type BrillouinZoneData = {
|
|
3
4
|
order: number;
|
|
4
5
|
vertices: Vec3[];
|
|
@@ -8,7 +9,7 @@ export type BrillouinZoneData = {
|
|
|
8
9
|
volume: number;
|
|
9
10
|
};
|
|
10
11
|
export type BrillouinZoneProps = {
|
|
11
|
-
structure:
|
|
12
|
+
structure: Crystal;
|
|
12
13
|
bz_order?: number;
|
|
13
14
|
surface_color?: string;
|
|
14
15
|
surface_opacity?: number;
|
package/dist/colors/index.d.ts
CHANGED
|
@@ -41,3 +41,5 @@ export declare const contrast_color: (options?: ContrastOptions) => (node: HTMLE
|
|
|
41
41
|
export declare function get_page_background(fallback_dark?: string, fallback_light?: string): string;
|
|
42
42
|
export declare function is_dark_mode(): boolean;
|
|
43
43
|
export declare function watch_dark_mode(on_change: (dark: boolean) => void): () => void;
|
|
44
|
+
export declare function css_color_to_hex(color: string | undefined, fallback: string): string;
|
|
45
|
+
export declare function add_alpha(color: string, alpha: number): string;
|
package/dist/colors/index.js
CHANGED
|
@@ -129,7 +129,7 @@ export function is_dark_mode() {
|
|
|
129
129
|
if (stored === `dark` || stored === `light`)
|
|
130
130
|
return stored === `dark`;
|
|
131
131
|
}
|
|
132
|
-
catch { /* localStorage
|
|
132
|
+
catch { /* localStorage throws in private browsing mode */ }
|
|
133
133
|
return globalThis.matchMedia?.(`(prefers-color-scheme: dark)`).matches ?? false;
|
|
134
134
|
}
|
|
135
135
|
// Watch for dark mode changes and call callback on each change. Returns cleanup function.
|
|
@@ -155,3 +155,43 @@ export function watch_dark_mode(on_change) {
|
|
|
155
155
|
media_query?.removeEventListener(`change`, notify);
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
|
+
// Convert a CSS color string to hex format for use with <input type="color">.
|
|
159
|
+
// Returns fallback for CSS variables, transparent, invalid colors, or undefined.
|
|
160
|
+
// Uses d3-color for robust parsing of named colors, rgb(), hsl(), etc.
|
|
161
|
+
export function css_color_to_hex(color, fallback) {
|
|
162
|
+
if (!color || color.startsWith(`var(`))
|
|
163
|
+
return fallback;
|
|
164
|
+
if (color === `transparent`)
|
|
165
|
+
return `#ffffff`;
|
|
166
|
+
const parsed = rgb(color);
|
|
167
|
+
return Number.isNaN(parsed.r) ? fallback : parsed.formatHex();
|
|
168
|
+
}
|
|
169
|
+
// Add or modify the alpha channel of a color.
|
|
170
|
+
// Supports hex (#rgb, #rgba, #rrggbb, #rrggbbaa), rgb(), and rgba() formats.
|
|
171
|
+
// Returns the color in rgba() format, or the original color if format is unsupported.
|
|
172
|
+
export function add_alpha(color, alpha) {
|
|
173
|
+
// Clamp alpha to valid CSS range [0, 1]
|
|
174
|
+
const clamped_alpha = Math.max(0, Math.min(1, alpha));
|
|
175
|
+
// Handle hex colors (#rgb, #rgba, #rrggbb, #rrggbbaa)
|
|
176
|
+
if (color.startsWith(`#`)) {
|
|
177
|
+
const hex = color.slice(1);
|
|
178
|
+
// Guard against malformed hex (only 3, 4, 6, or 8 chars are valid)
|
|
179
|
+
if (![3, 4, 6, 8].includes(hex.length))
|
|
180
|
+
return color;
|
|
181
|
+
// Extract RGB, ignoring any existing alpha channel
|
|
182
|
+
const is_short = hex.length === 3 || hex.length === 4;
|
|
183
|
+
const r = parseInt(is_short ? hex[0] + hex[0] : hex.slice(0, 2), 16);
|
|
184
|
+
const g = parseInt(is_short ? hex[1] + hex[1] : hex.slice(2, 4), 16);
|
|
185
|
+
const b = parseInt(is_short ? hex[2] + hex[2] : hex.slice(4, 6), 16);
|
|
186
|
+
return `rgba(${r}, ${g}, ${b}, ${clamped_alpha})`;
|
|
187
|
+
}
|
|
188
|
+
// Handle rgb() colors
|
|
189
|
+
if (color.startsWith(`rgb(`)) {
|
|
190
|
+
return color.replace(`rgb(`, `rgba(`).replace(`)`, `, ${clamped_alpha})`);
|
|
191
|
+
}
|
|
192
|
+
// Handle rgba() - replace existing alpha (supports scientific notation like 1e-5)
|
|
193
|
+
if (color.startsWith(`rgba(`)) {
|
|
194
|
+
return color.replace(/,\s*[\d.eE\-+]+\)$/, `, ${clamped_alpha})`);
|
|
195
|
+
}
|
|
196
|
+
return color;
|
|
197
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script lang="ts">import {
|
|
2
|
-
import {
|
|
1
|
+
<script lang="ts">import { ELEMENT_COLOR_SCHEMES, pick_contrast_color } from '../colors';
|
|
2
|
+
import { format_num } from '../labels';
|
|
3
3
|
import { get_chart_font_scale } from './index';
|
|
4
4
|
import { fractional_composition } from './parse';
|
|
5
5
|
let { composition, size = 200, bar_height = 30, label_height = 20, gap = 2, min_segment_size_for_label = 15, thin_segment_threshold = 0.2, external_label_size_threshold = 5, outer_corners_only = true, show_labels = true, show_percentages = false, show_amounts = true, color_scheme = `Vesta`, segment_content, interactive = true, svg_node = $bindable(null), children, ...rest } = $props();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type CompositionType, type ElementSymbol } from '..';
|
|
2
1
|
import type { ColorSchemeName } from '../colors';
|
|
2
|
+
import type { CompositionType } from './';
|
|
3
|
+
import type { ElementSymbol } from '../element';
|
|
3
4
|
import type { Snippet } from 'svelte';
|
|
4
5
|
import type { SVGAttributes } from 'svelte/elements';
|
|
5
6
|
import { type ChartSegmentData } from './index';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { CompositionType, ElementSymbol } from '..';
|
|
2
1
|
import type { ColorSchemeName } from '../colors';
|
|
2
|
+
import type { CompositionType } from './';
|
|
3
|
+
import type { ElementSymbol } from '../element';
|
|
3
4
|
import type { Snippet } from 'svelte';
|
|
4
5
|
import type { SVGAttributes } from 'svelte/elements';
|
|
5
6
|
import { type ChartSegmentData } from './index';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">import { ContextMenu } from '
|
|
1
|
+
<script lang="ts">import { ContextMenu } from '../overlays';
|
|
2
2
|
import { export_svg_as_png, export_svg_as_svg } from '../io/export';
|
|
3
3
|
import { get_electro_neg_formula } from './format';
|
|
4
4
|
import { BarChart, BubbleChart, PieChart } from './index';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ColorSchemeName
|
|
1
|
+
import type { ColorSchemeName } from '../colors';
|
|
2
|
+
import type { CompositionType } from './';
|
|
2
3
|
import type { SVGAttributes } from 'svelte/elements';
|
|
3
4
|
type CompositionChartMode = `pie` | `bubble` | `bar`;
|
|
4
5
|
type $$ComponentProps = SVGAttributes<SVGSVGElement> & {
|
|
@@ -3,7 +3,7 @@ import { element_data } from '../element';
|
|
|
3
3
|
import ElementTile from '../element/ElementTile.svelte';
|
|
4
4
|
import { format_num } from '../labels';
|
|
5
5
|
import { format_oxi_state, sort_by_electronegativity, sort_by_hill_notation, } from './format';
|
|
6
|
-
import { oxi_composition_to_elements, parse_formula_with_oxidation
|
|
6
|
+
import { oxi_composition_to_elements, parse_formula_with_oxidation } from './parse';
|
|
7
7
|
let { formula, color_scheme = `Vesta`, ordering = `original`, as = `span`, amount_format = `.3~s`, tooltip_side = `bottom`, tooltip_offset = 5, on_click, ...rest } = $props();
|
|
8
8
|
const parsed_elements = $derived.by(() => {
|
|
9
9
|
try {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ColorSchemeName
|
|
1
|
+
import type { ColorSchemeName } from '../colors';
|
|
2
|
+
import type { ElementSymbol } from '../element';
|
|
2
3
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import {
|
|
4
|
+
import type { OxiComposition } from './parse';
|
|
4
5
|
type FormulaOrdering = `electronegativity` | `alphabetical` | `original` | `hill`;
|
|
5
6
|
type TooltipSide = `top` | `bottom` | `left` | `right`;
|
|
6
7
|
type $$ComponentProps = HTMLAttributes<HTMLElement> & {
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<script lang="ts">import Icon from '../Icon.svelte';
|
|
2
2
|
import { tooltip } from 'svelte-multiselect';
|
|
3
|
-
import { extract_formula_elements, normalize_element_symbols } from './parse';
|
|
3
|
+
import { extract_formula_elements, has_wildcards, normalize_element_symbols, parse_formula_with_wildcards, } from './parse';
|
|
4
4
|
const SEARCH_EXAMPLES = [
|
|
5
5
|
{
|
|
6
6
|
label: `Contains elements`,
|
|
7
|
-
description: `Materials containing at least these elements (may have others)
|
|
8
|
-
examples: [`Li,Fe`, `Si,O`, `
|
|
7
|
+
description: `Materials containing at least these elements (may have others). Use * for any element.`,
|
|
8
|
+
examples: [`Li,Fe`, `Si,O`, `Li,*,*`],
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
label: `Chemical system`,
|
|
12
|
-
description: `Materials with only these elements (no others)
|
|
13
|
-
examples: [`Li-Fe-O`, `
|
|
12
|
+
description: `Materials with only these elements (no others). Use * for any element.`,
|
|
13
|
+
examples: [`Li-Fe-O`, `Li-Fe-*-*`, `*-*-O`],
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
label: `Exact formula`,
|
|
17
|
-
description: `Materials with this exact stoichiometry
|
|
18
|
-
examples: [`LiFePO4`, `
|
|
17
|
+
description: `Materials with this exact stoichiometry. Use * for any element.`,
|
|
18
|
+
examples: [`LiFePO4`, `LiFe*2*`, `*2O3`],
|
|
19
19
|
},
|
|
20
20
|
];
|
|
21
21
|
let { value = $bindable(``), search_mode = $bindable(`elements`), input_element = $bindable(null), show_clear_button = true, show_examples = true, disabled = false, onchange, onclear, ...rest } = $props();
|
|
@@ -83,7 +83,7 @@ function infer_mode(input) {
|
|
|
83
83
|
// Cycle through modes: elements → chemsys → exact → elements
|
|
84
84
|
const MODE_CYCLE = [`elements`, `chemsys`, `exact`];
|
|
85
85
|
// Extract elements from any input format (formula, comma-separated, dash-separated)
|
|
86
|
-
// Always returns elements in alphabetical order for consistency
|
|
86
|
+
// Always returns elements in alphabetical order for consistency, preserving wildcards (*)
|
|
87
87
|
function extract_elements(input) {
|
|
88
88
|
const trimmed = input.trim();
|
|
89
89
|
if (!trimmed)
|
|
@@ -91,10 +91,23 @@ function extract_elements(input) {
|
|
|
91
91
|
// If contains commas or dashes, split by those and sort alphabetically
|
|
92
92
|
if (trimmed.includes(`,`) || trimmed.includes(`-`)) {
|
|
93
93
|
const parts = trimmed.split(/[-,]/).map((str) => str.trim()).filter(Boolean);
|
|
94
|
-
//
|
|
95
|
-
|
|
94
|
+
// Separate wildcards from regular elements
|
|
95
|
+
const wildcards = parts.filter((part) => part === `*`);
|
|
96
|
+
const regular_parts = parts.filter((part) => part !== `*`);
|
|
97
|
+
// Filter valid elements and sort alphabetically, then append wildcards
|
|
98
|
+
const valid_elements = normalize_element_symbols(regular_parts.join(`,`)).sort();
|
|
99
|
+
return [...valid_elements, ...wildcards];
|
|
96
100
|
}
|
|
97
101
|
// Otherwise parse as formula (already returns sorted by default)
|
|
102
|
+
// For formulas with wildcards, we can't parse them normally
|
|
103
|
+
if (has_wildcards(trimmed)) { // Use shared utility and extract unique elements
|
|
104
|
+
const tokens = parse_formula_with_wildcards(trimmed);
|
|
105
|
+
const elements = [
|
|
106
|
+
...new Set(tokens.filter((token) => token.element !== null).map((token) => token.element)),
|
|
107
|
+
].sort();
|
|
108
|
+
const wildcards = tokens.filter((token) => token.element === null).map(() => `*`);
|
|
109
|
+
return [...elements, ...wildcards];
|
|
110
|
+
}
|
|
98
111
|
try {
|
|
99
112
|
return extract_formula_elements(trimmed, { sorted: true });
|
|
100
113
|
}
|
|
@@ -137,9 +150,18 @@ function sync_value() {
|
|
|
137
150
|
const mode = infer_mode(trimmed);
|
|
138
151
|
if (mode === `exact`)
|
|
139
152
|
return set_value(trimmed);
|
|
140
|
-
// Normalize element symbols for elements/chemsys modes
|
|
153
|
+
// Normalize element symbols for elements/chemsys modes, preserving wildcards
|
|
141
154
|
const separator = mode === `chemsys` ? `-` : `,`;
|
|
142
|
-
const
|
|
155
|
+
const parts = trimmed.replace(/[-,]/g, `,`).split(`,`).map((str) => str.trim())
|
|
156
|
+
.filter(Boolean);
|
|
157
|
+
// Separate wildcards from regular elements
|
|
158
|
+
const wildcards = parts.filter((part) => part === `*`);
|
|
159
|
+
const regular_parts = parts.filter((part) => part !== `*`);
|
|
160
|
+
// Normalize regular elements, sort alphabetically, and append wildcards
|
|
161
|
+
const normalized = [
|
|
162
|
+
...normalize_element_symbols(regular_parts.join(`,`)).sort(),
|
|
163
|
+
...wildcards,
|
|
164
|
+
];
|
|
143
165
|
set_value(normalized.join(separator));
|
|
144
166
|
}
|
|
145
167
|
function onkeydown(event) {
|
|
@@ -197,10 +219,10 @@ $effect(() => {
|
|
|
197
219
|
items?.[focused_item_idx]?.focus({ preventScroll: true });
|
|
198
220
|
});
|
|
199
221
|
let placeholder = $derived(search_mode === `chemsys`
|
|
200
|
-
? `Li-Fe-O
|
|
222
|
+
? `Li-Fe-O or Li-*-*`
|
|
201
223
|
: search_mode === `exact`
|
|
202
|
-
? `LiFePO4
|
|
203
|
-
: `Li,Fe,O
|
|
224
|
+
? `LiFePO4 or LiFe*2*`
|
|
225
|
+
: `Li,Fe,O or Li,*,*`);
|
|
204
226
|
const MODE_LABELS = {
|
|
205
227
|
elements: `contains elements`,
|
|
206
228
|
chemsys: `chemical system`,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts">import { format_num } from '
|
|
1
|
+
<script lang="ts">import { format_num } from '../labels';
|
|
2
2
|
import { ELEMENT_COLOR_SCHEMES, pick_contrast_color } from '../colors';
|
|
3
3
|
import { get_chart_font_scale } from './index';
|
|
4
4
|
import { count_atoms_in_composition, fractional_composition } from './parse';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { CompositionType } from './';
|
|
2
|
+
import type { ElementSymbol } from '../element';
|
|
2
3
|
import type { ColorSchemeName } from '../colors';
|
|
3
4
|
import type { Snippet } from 'svelte';
|
|
4
5
|
import type { SVGAttributes } from 'svelte/elements';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ElementSymbol } from '../element';
|
|
2
|
+
import type { AnyStructure } from '../structure';
|
|
2
3
|
import type { CompositionType } from './';
|
|
3
4
|
export declare const format_composition_formula: (composition: CompositionType, sort_fn: (symbols: ElementSymbol[]) => ElementSymbol[], plain_text?: boolean, delim?: string, amount_format?: string) => string;
|
|
4
5
|
export declare const get_alphabetical_formula: (input: string | CompositionType | AnyStructure, plain_text?: boolean, delim?: string, amount_format?: string) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ElementSymbol } from '
|
|
1
|
+
import type { ElementSymbol } from '../element';
|
|
2
2
|
export { default as BarChart } from './BarChart.svelte';
|
|
3
3
|
export { default as BubbleChart } from './BubbleChart.svelte';
|
|
4
4
|
export { default as Composition } from './Composition.svelte';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ElementSymbol } from '
|
|
1
|
+
import type { ElementSymbol } from '../element';
|
|
2
2
|
import type { CompositionType } from './';
|
|
3
3
|
export declare const ATOMIC_NUMBER_TO_SYMBOL: Record<number, ElementSymbol>;
|
|
4
4
|
export declare const SYMBOL_TO_ATOMIC_NUMBER: Partial<CompositionType>;
|
|
5
5
|
export declare const ATOMIC_WEIGHTS: Map<"S" | "K" | "B" | "H" | "He" | "Li" | "Be" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "Cl" | "Ar" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
|
|
6
6
|
export declare const ELEMENT_ELECTRONEGATIVITY_MAP: Map<"S" | "K" | "B" | "H" | "He" | "Li" | "Be" | "C" | "N" | "O" | "F" | "Ne" | "Na" | "Mg" | "Al" | "Si" | "P" | "Cl" | "Ar" | "Ca" | "Sc" | "Ti" | "V" | "Cr" | "Mn" | "Fe" | "Co" | "Ni" | "Cu" | "Zn" | "Ga" | "Ge" | "As" | "Se" | "Br" | "Kr" | "Rb" | "Sr" | "Y" | "Zr" | "Nb" | "Mo" | "Tc" | "Ru" | "Rh" | "Pd" | "Ag" | "Cd" | "In" | "Sn" | "Sb" | "Te" | "I" | "Xe" | "Cs" | "Ba" | "La" | "Ce" | "Pr" | "Nd" | "Pm" | "Sm" | "Eu" | "Gd" | "Tb" | "Dy" | "Ho" | "Er" | "Tm" | "Yb" | "Lu" | "Hf" | "Ta" | "W" | "Re" | "Os" | "Ir" | "Pt" | "Au" | "Hg" | "Tl" | "Pb" | "Bi" | "Po" | "At" | "Rn" | "Fr" | "Ra" | "Ac" | "Th" | "Pa" | "U" | "Np" | "Pu" | "Am" | "Cm" | "Bk" | "Cf" | "Es" | "Fm" | "Md" | "No" | "Lr" | "Rf" | "Db" | "Sg" | "Bh" | "Hs" | "Mt" | "Ds" | "Rg" | "Cn" | "Nh" | "Fl" | "Mc" | "Lv" | "Ts" | "Og", number>;
|
|
7
7
|
export declare const ELEM_NAME_TO_SYMBOL: Record<string, ElementSymbol>;
|
|
8
|
-
export declare const ELEM_SYMBOL_TO_NAME: Record<ElementSymbol, string
|
|
8
|
+
export declare const ELEM_SYMBOL_TO_NAME: Partial<Record<ElementSymbol, string>>;
|
|
9
9
|
export declare const is_valid_element: (sym: string) => sym is ElementSymbol;
|
|
10
10
|
export declare const atomic_num_to_symbols: (atomic_composition: Record<number, number>) => CompositionType;
|
|
11
11
|
export declare const atomic_symbol_to_num: (symbol_composition: CompositionType) => Record<number, number>;
|
|
@@ -35,3 +35,21 @@ export declare function extract_formula_elements(formula: string, { unique, sort
|
|
|
35
35
|
}): ElementSymbol[];
|
|
36
36
|
export declare function generate_chem_sys_subspaces(input: string | CompositionType | ElementSymbol[]): string[];
|
|
37
37
|
export declare const normalize_element_symbols: <T extends string>(csv: string, all_symbols?: T[]) => T[];
|
|
38
|
+
export type WildcardFormulaToken = {
|
|
39
|
+
element: ElementSymbol | null;
|
|
40
|
+
count: number;
|
|
41
|
+
};
|
|
42
|
+
export type ChemsysWithWildcards = {
|
|
43
|
+
elements: ElementSymbol[];
|
|
44
|
+
wildcard_count: number;
|
|
45
|
+
};
|
|
46
|
+
export declare const has_wildcards: (input: string) => boolean;
|
|
47
|
+
export declare function parse_chemsys_with_wildcards(input: string): ChemsysWithWildcards;
|
|
48
|
+
export declare const ELEM_WILDCARD: {
|
|
49
|
+
readonly placeholder: "Zz";
|
|
50
|
+
readonly to_placeholder: RegExp;
|
|
51
|
+
readonly from_placeholder: RegExp;
|
|
52
|
+
};
|
|
53
|
+
export declare function parse_formula_with_wildcards(formula: string): WildcardFormulaToken[];
|
|
54
|
+
export declare function matches_chemsys_wildcard(formula: string, explicit_elements: string[], wildcard_count: number): boolean;
|
|
55
|
+
export declare function matches_formula_wildcard(formula: string, pattern: WildcardFormulaToken[]): boolean;
|