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.
- package/dist/EmptyState.svelte +10 -2
- package/dist/FilePicker.svelte +154 -96
- package/dist/Icon.svelte +20 -14
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -178
- package/dist/brillouin/BrillouinZone.svelte +299 -198
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +74 -55
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +277 -165
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneTooltip.svelte +17 -7
- package/dist/brillouin/compute.js +11 -6
- package/dist/chempot-diagram/ChemPotDiagram.svelte +327 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +847 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +3194 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +11 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/async-compute.svelte.d.ts +3 -0
- package/dist/chempot-diagram/async-compute.svelte.js +77 -0
- package/dist/chempot-diagram/chempot-worker.d.ts +1 -0
- package/dist/chempot-diagram/chempot-worker.js +11 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +32 -0
- package/dist/chempot-diagram/compute.d.ts +48 -0
- package/dist/chempot-diagram/compute.js +812 -0
- package/dist/chempot-diagram/index.d.ts +6 -0
- package/dist/chempot-diagram/index.js +6 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +36 -0
- package/dist/chempot-diagram/types.d.ts +86 -0
- package/dist/chempot-diagram/types.js +28 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +9 -3
- package/dist/composition/BarChart.svelte +141 -77
- package/dist/composition/BubbleChart.svelte +107 -52
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +973 -353
- package/dist/composition/FormulaFilter.svelte.d.ts +35 -1
- package/dist/composition/PieChart.svelte +199 -99
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/composition/format.d.ts +5 -0
- package/dist/composition/format.js +20 -3
- package/dist/composition/parse.js +14 -9
- package/dist/convex-hull/ConvexHull.svelte +93 -38
- package/dist/convex-hull/ConvexHull2D.svelte +551 -393
- package/dist/convex-hull/ConvexHull3D.svelte +1303 -825
- package/dist/convex-hull/ConvexHull4D.svelte +1012 -686
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +821 -249
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +41 -16
- package/dist/convex-hull/GasPressureControls.svelte +104 -61
- package/dist/convex-hull/StructurePopup.svelte +25 -4
- package/dist/convex-hull/TemperatureSlider.svelte +45 -25
- package/dist/convex-hull/barycentric-coords.js +13 -7
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +40 -0
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +10 -1
- package/dist/convex-hull/helpers.js +79 -38
- package/dist/convex-hull/index.d.ts +1 -0
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +163 -69
- package/dist/convex-hull/types.d.ts +12 -12
- package/dist/convex-hull/types.js +0 -12
- package/dist/coordination/CoordinationBarPlot.svelte +232 -176
- package/dist/element/BohrAtom.svelte +56 -13
- package/dist/element/ElementHeading.svelte +7 -2
- package/dist/element/ElementPhoto.svelte +15 -9
- package/dist/element/ElementStats.svelte +10 -4
- package/dist/element/ElementTile.svelte +137 -73
- package/dist/element/Nucleus.svelte +39 -11
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/feedback/ClickFeedback.svelte +16 -5
- package/dist/feedback/DragOverlay.svelte +10 -2
- package/dist/feedback/Spinner.svelte +4 -2
- package/dist/feedback/StatusMessage.svelte +8 -2
- package/dist/fermi-surface/FermiSlice.svelte +118 -88
- package/dist/fermi-surface/FermiSurface.svelte +336 -239
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceScene.svelte +536 -343
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceTooltip.svelte +14 -5
- package/dist/fermi-surface/compute.js +16 -20
- package/dist/fermi-surface/parse.js +37 -33
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1527 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +225 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +30 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +111 -0
- package/dist/icons.js +158 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +5 -2
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +138 -140
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/is-binary.js +2 -3
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +117 -0
- package/dist/isosurface/Isosurface.svelte +220 -110
- package/dist/isosurface/IsosurfaceControls.svelte +65 -28
- package/dist/isosurface/parse.js +104 -56
- package/dist/isosurface/slice.d.ts +2 -1
- package/dist/isosurface/slice.js +8 -13
- package/dist/isosurface/types.d.ts +14 -1
- package/dist/isosurface/types.js +152 -5
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +12 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +125 -94
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +82 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +266 -223
- package/dist/layout/json-tree/JsonTree.svelte +516 -429
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +281 -173
- package/dist/layout/json-tree/types.d.ts +10 -2
- package/dist/layout/json-tree/utils.d.ts +2 -0
- package/dist/layout/json-tree/utils.js +37 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +20 -17
- package/dist/math.js +474 -57
- package/dist/overlays/ContextMenu.svelte +66 -40
- package/dist/overlays/DraggablePane.svelte +331 -154
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/periodic-table/PeriodicTable.svelte +278 -145
- package/dist/periodic-table/PeriodicTableControls.svelte +178 -128
- package/dist/periodic-table/PropertySelect.svelte +25 -7
- package/dist/periodic-table/TableInset.svelte +8 -3
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +559 -267
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +131 -51
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +126 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +160 -110
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +8 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +217 -86
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/TdbInfoPanel.svelte +28 -4
- package/dist/phase-diagram/build-diagram.js +9 -9
- package/dist/phase-diagram/colors.js +1 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +869 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +8 -4
- package/dist/phase-diagram/utils.js +219 -74
- package/dist/plot/AxisLabel.svelte +51 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +1461 -768
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +33 -6
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +533 -383
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ColorScaleSelect.svelte +28 -7
- package/dist/plot/ElementScatter.svelte +38 -16
- package/dist/plot/FillArea.svelte +152 -92
- package/dist/plot/Histogram.svelte +1162 -709
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +81 -18
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte +34 -11
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +1 -1
- package/dist/plot/Line.svelte +63 -28
- package/dist/plot/PlotControls.svelte +221 -96
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +174 -91
- package/dist/plot/PlotTooltip.svelte +45 -6
- package/dist/plot/PortalSelect.svelte +175 -146
- package/dist/plot/ReferenceLine.svelte +77 -22
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -123
- package/dist/plot/ScatterPlot.svelte +1880 -1156
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +300 -297
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -406
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +150 -70
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ScatterPoint.svelte +98 -26
- package/dist/plot/ScatterPoint.svelte.d.ts +1 -0
- package/dist/plot/SpacegroupBarPlot.svelte +142 -85
- package/dist/plot/Surface3D.svelte +159 -108
- package/dist/plot/ZeroLines.svelte +96 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +23 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/axis-utils.js +1 -3
- package/dist/plot/data-cleaning.js +12 -28
- package/dist/plot/data-transform.js +2 -1
- package/dist/plot/fill-utils.js +2 -0
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +2 -3
- package/dist/plot/layout.d.ts +11 -2
- package/dist/plot/layout.js +44 -17
- package/dist/plot/reference-line.d.ts +5 -22
- package/dist/plot/reference-line.js +12 -84
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +53 -40
- package/dist/plot/types.js +12 -7
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -63
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +173 -132
- package/dist/rdf/calc-rdf.js +4 -5
- package/dist/sanitize.d.ts +4 -0
- package/dist/sanitize.js +107 -0
- package/dist/settings.d.ts +21 -6
- package/dist/settings.js +63 -19
- package/dist/spectral/Bands.svelte +963 -412
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/BandsAndDos.svelte +90 -49
- package/dist/spectral/BrillouinBandsDos.svelte +151 -93
- package/dist/spectral/Dos.svelte +389 -258
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +119 -51
- package/dist/spectral/types.d.ts +2 -0
- package/dist/state.svelte.d.ts +1 -1
- package/dist/state.svelte.js +3 -2
- package/dist/structure/Arrow.svelte +59 -20
- package/dist/structure/AtomLegend.svelte +231 -129
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +148 -51
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1077 -821
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +373 -139
- package/dist/structure/StructureControls.svelte.d.ts +1 -1
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -231
- package/dist/structure/StructureScene.svelte +919 -445
- package/dist/structure/StructureScene.svelte.d.ts +16 -7
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +42 -29
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +22 -34
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +2 -3
- package/dist/structure/index.d.ts +16 -0
- package/dist/structure/index.js +88 -6
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +130 -155
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +99 -0
- package/dist/structure/pbc.d.ts +1 -0
- package/dist/structure/pbc.js +16 -6
- package/dist/structure/supercell.d.ts +2 -2
- package/dist/structure/supercell.js +12 -22
- package/dist/structure/validation.js +5 -3
- package/dist/symmetry/SymmetryStats.svelte +94 -37
- package/dist/symmetry/WyckoffTable.svelte +42 -14
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +87 -21
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +1112 -516
- package/dist/table/HeatmapTable.svelte.d.ts +12 -1
- package/dist/table/ToggleMenu.svelte +125 -90
- package/dist/table/index.d.ts +2 -0
- package/dist/table/index.js +2 -4
- package/dist/theme/ThemeControl.svelte +21 -12
- package/dist/time.js +4 -1
- package/dist/tooltip/TooltipContent.svelte +33 -8
- package/dist/trajectory/Trajectory.svelte +889 -687
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +148 -90
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +13 -31
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +332 -0
- package/dist/trajectory/helpers.d.ts +14 -0
- package/dist/trajectory/helpers.js +172 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +23 -14
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +77 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +129 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +299 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +179 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +68 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +110 -0
- package/dist/trajectory/plotting.js +13 -8
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +3 -0
- package/dist/utils.js +17 -0
- package/dist/xrd/XrdPlot.svelte +337 -245
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -19
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +103 -101
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
2
2
|
import type { FormulaSearchMode } from './index';
|
|
3
|
+
type SearchExampleCategory = {
|
|
4
|
+
label: string;
|
|
5
|
+
description: string;
|
|
6
|
+
examples: string[];
|
|
7
|
+
};
|
|
8
|
+
export type FormulaFilterToken = {
|
|
9
|
+
raw: string;
|
|
10
|
+
element: string;
|
|
11
|
+
operator: `include` | `exclude`;
|
|
12
|
+
constraint: string | null;
|
|
13
|
+
is_wildcard: boolean;
|
|
14
|
+
is_valid: boolean;
|
|
15
|
+
};
|
|
16
|
+
export type FormulaFilterParseResult = {
|
|
17
|
+
value: string;
|
|
18
|
+
normalized_value: string;
|
|
19
|
+
search_mode: FormulaSearchMode;
|
|
20
|
+
tokens: FormulaFilterToken[];
|
|
21
|
+
has_wildcards: boolean;
|
|
22
|
+
is_valid: boolean;
|
|
23
|
+
error_message: string | null;
|
|
24
|
+
};
|
|
25
|
+
export type FormulaFilterValidation = {
|
|
26
|
+
state: `valid` | `warning` | `invalid`;
|
|
27
|
+
message: string | null;
|
|
28
|
+
};
|
|
3
29
|
type $$ComponentProps = {
|
|
4
30
|
value: string;
|
|
5
31
|
search_mode?: FormulaSearchMode;
|
|
6
32
|
input_element?: HTMLInputElement | null;
|
|
7
33
|
show_clear_button?: boolean;
|
|
8
34
|
show_examples?: boolean;
|
|
35
|
+
show_mode_lock?: boolean;
|
|
36
|
+
show_chip_editor?: boolean;
|
|
37
|
+
normalize_exact?: boolean;
|
|
38
|
+
examples?: SearchExampleCategory[];
|
|
9
39
|
disabled?: boolean;
|
|
40
|
+
mode_locked?: boolean;
|
|
10
41
|
max_history?: number;
|
|
11
42
|
history_key?: string;
|
|
43
|
+
validate?: (value: string, search_mode: FormulaSearchMode, parsed: FormulaFilterParseResult) => FormulaFilterValidation | null;
|
|
44
|
+
onparse?: (parsed: FormulaFilterParseResult) => void;
|
|
45
|
+
on_validation?: (validation: FormulaFilterValidation) => void;
|
|
12
46
|
onchange?: (value: string, search_mode: FormulaSearchMode) => void;
|
|
13
47
|
onclear?: () => void;
|
|
14
48
|
} & HTMLAttributes<HTMLDivElement>;
|
|
15
|
-
declare const FormulaFilter: import("svelte").Component<$$ComponentProps, {}, "value" | "search_mode" | "input_element">;
|
|
49
|
+
declare const FormulaFilter: import("svelte").Component<$$ComponentProps, {}, "value" | "search_mode" | "input_element" | "mode_locked">;
|
|
16
50
|
type FormulaFilter = ReturnType<typeof FormulaFilter>;
|
|
17
51
|
export default FormulaFilter;
|
|
@@ -1,107 +1,208 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ColorSchemeName } from '../colors'
|
|
3
|
+
import { ELEMENT_COLOR_SCHEMES, pick_contrast_color } from '../colors'
|
|
4
|
+
import type { CompositionType } from './'
|
|
5
|
+
import type { ElementSymbol } from '../element'
|
|
6
|
+
import { format_num } from '../labels'
|
|
7
|
+
import type { Snippet } from 'svelte'
|
|
8
|
+
import type { SVGAttributes } from 'svelte/elements'
|
|
9
|
+
import { type ChartSegmentData, get_chart_font_scale } from './index'
|
|
10
|
+
import { count_atoms_in_composition, fractional_composition } from './parse'
|
|
11
|
+
|
|
12
|
+
// Constants for pie chart calculations
|
|
13
|
+
const VERY_THIN_SLICE_THRESHOLD = 20 // degrees
|
|
14
|
+
const MEDIUM_SLICE_THRESHOLD = 90 // degrees - increased to move more slices toward outer edge
|
|
15
|
+
const MAX_ANGLE_FOR_FULL_SCALE = 120 // degrees
|
|
16
|
+
|
|
17
|
+
type PieSegmentData = ChartSegmentData & {
|
|
18
|
+
start_angle: number
|
|
19
|
+
end_angle: number
|
|
20
|
+
path: string
|
|
21
|
+
label_x: number
|
|
22
|
+
label_y: number
|
|
23
|
+
is_outside_slice: boolean
|
|
24
|
+
}
|
|
25
|
+
let {
|
|
26
|
+
composition,
|
|
27
|
+
size = 200,
|
|
28
|
+
stroke_width = 0.5,
|
|
29
|
+
inner_radius = 0,
|
|
30
|
+
show_labels = true,
|
|
31
|
+
show_percentages = false,
|
|
32
|
+
show_amounts = true,
|
|
33
|
+
color_scheme = `Vesta`,
|
|
34
|
+
center_content,
|
|
35
|
+
segment_content,
|
|
36
|
+
interactive = true,
|
|
37
|
+
svg_node = $bindable(null),
|
|
38
|
+
children,
|
|
39
|
+
...rest
|
|
40
|
+
}: SVGAttributes<SVGSVGElement> & {
|
|
41
|
+
composition: CompositionType
|
|
42
|
+
size?: number
|
|
43
|
+
stroke_width?: number
|
|
44
|
+
inner_radius?: number
|
|
45
|
+
show_labels?: boolean
|
|
46
|
+
show_percentages?: boolean
|
|
47
|
+
show_amounts?: boolean
|
|
48
|
+
color_scheme?: ColorSchemeName
|
|
49
|
+
center_content?: Snippet<[{ composition: CompositionType; total_atoms: number }]>
|
|
50
|
+
segment_content?: Snippet<[PieSegmentData]>
|
|
51
|
+
interactive?: boolean
|
|
52
|
+
svg_node?: SVGSVGElement | null
|
|
53
|
+
children?: Snippet<[{ hovered_element: ElementSymbol | null }]>
|
|
54
|
+
} = $props()
|
|
55
|
+
|
|
56
|
+
let element_colors = $derived(
|
|
57
|
+
ELEMENT_COLOR_SCHEMES[color_scheme] || ELEMENT_COLOR_SCHEMES.Vesta,
|
|
58
|
+
)
|
|
59
|
+
let fractions = $derived(fractional_composition(composition))
|
|
60
|
+
let total_atoms = $derived(count_atoms_in_composition(composition))
|
|
61
|
+
let outer_radius = $derived(size / 2 - stroke_width)
|
|
62
|
+
let inner_radius_adjusted = $derived(Math.min(inner_radius, outer_radius - 10))
|
|
63
|
+
let center = $derived(size / 2)
|
|
64
|
+
|
|
65
|
+
// Calculate pie segments
|
|
66
|
+
let segments = $derived.by(() => {
|
|
67
|
+
let current_angle = -90 // Start from top
|
|
68
|
+
|
|
19
69
|
return Object.entries(composition)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const element = element_key
|
|
23
|
-
const fraction = fractions[element] || 0
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
70
|
+
.filter(([_, amount]) => amount && amount > 0)
|
|
71
|
+
.map(([element_key, amount]) => {
|
|
72
|
+
const element = element_key as ElementSymbol
|
|
73
|
+
const fraction = fractions[element] || 0
|
|
74
|
+
const color = element_colors[element] || `#cccccc`
|
|
75
|
+
|
|
76
|
+
// Single element: full circle with no radial stroke line, label at center
|
|
77
|
+
if (fraction === 1) {
|
|
78
|
+
const r = outer_radius
|
|
79
|
+
const ir = inner_radius_adjusted
|
|
80
|
+
// Two semicircular arcs to form a full circle (avoids SVG 360° arc bug)
|
|
81
|
+
const outer_arc = `M ${center} ${center - r} A ${r} ${r} 0 1 1 ${center} ${
|
|
82
|
+
center + r
|
|
83
|
+
} A ${r} ${r} 0 1 1 ${center} ${center - r} Z`
|
|
84
|
+
const path = ir > 0
|
|
85
|
+
? `${outer_arc} M ${center} ${
|
|
86
|
+
center - ir
|
|
87
|
+
} A ${ir} ${ir} 0 1 0 ${center} ${
|
|
88
|
+
center + ir
|
|
89
|
+
} A ${ir} ${ir} 0 1 0 ${center} ${center - ir} Z`
|
|
90
|
+
: outer_arc
|
|
91
|
+
const label_text = element + (show_amounts ? String(amount) : ``) +
|
|
92
|
+
(show_percentages ? `${format_num(fraction, `.1~%`)}` : ``)
|
|
93
|
+
return {
|
|
94
|
+
element,
|
|
95
|
+
amount,
|
|
96
|
+
fraction,
|
|
97
|
+
color,
|
|
98
|
+
start_angle: -90,
|
|
99
|
+
end_angle: 270,
|
|
100
|
+
path,
|
|
101
|
+
label_x: center,
|
|
102
|
+
label_y: center,
|
|
103
|
+
is_outside_slice: false,
|
|
104
|
+
font_scale: get_chart_font_scale(2.6, label_text, r * 2),
|
|
105
|
+
text_color: pick_contrast_color({ bg_color: color }),
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const angle_span = fraction * 360
|
|
110
|
+
const start_angle = current_angle
|
|
111
|
+
const end_angle = current_angle + angle_span
|
|
112
|
+
|
|
113
|
+
current_angle = end_angle
|
|
114
|
+
|
|
29
115
|
// Convert to radians for calculations
|
|
30
|
-
const start_rad = (start_angle * Math.PI) / 180
|
|
31
|
-
const end_rad = (end_angle * Math.PI) / 180
|
|
32
|
-
const mid_rad = (((start_angle + end_angle) / 2) * Math.PI) / 180
|
|
116
|
+
const start_rad = (start_angle * Math.PI) / 180
|
|
117
|
+
const end_rad = (end_angle * Math.PI) / 180
|
|
118
|
+
const mid_rad = (((start_angle + end_angle) / 2) * Math.PI) / 180
|
|
119
|
+
|
|
33
120
|
// Arc coordinates for outer radius
|
|
34
|
-
const x1_outer = center + outer_radius * Math.cos(start_rad)
|
|
35
|
-
const y1_outer = center + outer_radius * Math.sin(start_rad)
|
|
36
|
-
const x2_outer = center + outer_radius * Math.cos(end_rad)
|
|
37
|
-
const y2_outer = center + outer_radius * Math.sin(end_rad)
|
|
121
|
+
const x1_outer = center + outer_radius * Math.cos(start_rad)
|
|
122
|
+
const y1_outer = center + outer_radius * Math.sin(start_rad)
|
|
123
|
+
const x2_outer = center + outer_radius * Math.cos(end_rad)
|
|
124
|
+
const y2_outer = center + outer_radius * Math.sin(end_rad)
|
|
125
|
+
|
|
38
126
|
// Arc coordinates for inner radius
|
|
39
|
-
const x1_inner = center + inner_radius_adjusted * Math.cos(start_rad)
|
|
40
|
-
const y1_inner = center + inner_radius_adjusted * Math.sin(start_rad)
|
|
41
|
-
const x2_inner = center + inner_radius_adjusted * Math.cos(end_rad)
|
|
42
|
-
const y2_inner = center + inner_radius_adjusted * Math.sin(end_rad)
|
|
43
|
-
|
|
127
|
+
const x1_inner = center + inner_radius_adjusted * Math.cos(start_rad)
|
|
128
|
+
const y1_inner = center + inner_radius_adjusted * Math.sin(start_rad)
|
|
129
|
+
const x2_inner = center + inner_radius_adjusted * Math.cos(end_rad)
|
|
130
|
+
const y2_inner = center + inner_radius_adjusted * Math.sin(end_rad)
|
|
131
|
+
|
|
132
|
+
const large_arc = angle_span > 180 ? 1 : 0
|
|
133
|
+
|
|
44
134
|
// Create donut path if inner radius > 0, otherwise regular pie slice
|
|
45
135
|
const path = inner_radius_adjusted > 0
|
|
46
|
-
|
|
47
|
-
|
|
136
|
+
? `M ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} L ${x2_inner} ${y2_inner} A ${inner_radius_adjusted} ${inner_radius_adjusted} 0 ${large_arc} 0 ${x1_inner} ${y1_inner} Z`
|
|
137
|
+
: `M ${center} ${center} L ${x1_outer} ${y1_outer} A ${outer_radius} ${outer_radius} 0 ${large_arc} 1 ${x2_outer} ${y2_outer} Z`
|
|
138
|
+
|
|
48
139
|
// Position labels with three-tier strategy
|
|
49
|
-
const is_very_thin_slice = angle_span < VERY_THIN_SLICE_THRESHOLD
|
|
140
|
+
const is_very_thin_slice = angle_span < VERY_THIN_SLICE_THRESHOLD // Place outside
|
|
50
141
|
const is_medium_slice = angle_span >= VERY_THIN_SLICE_THRESHOLD &&
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
let
|
|
142
|
+
angle_span < MEDIUM_SLICE_THRESHOLD // Near outer edge
|
|
143
|
+
|
|
144
|
+
let label_radius: number
|
|
145
|
+
let is_outside_slice = false
|
|
146
|
+
|
|
54
147
|
if (is_very_thin_slice) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
label_radius = (outer_radius + inner_radius_adjusted) / 2;
|
|
67
|
-
is_outside_slice = false;
|
|
148
|
+
// Very thin slices: place outside with distance proportional to chart size
|
|
149
|
+
label_radius = outer_radius + outer_radius * 0.2
|
|
150
|
+
is_outside_slice = true
|
|
151
|
+
} else if (is_medium_slice) {
|
|
152
|
+
// Medium slices: place closer to outer edge, proportional to chart size
|
|
153
|
+
label_radius = outer_radius - outer_radius * 0.3
|
|
154
|
+
is_outside_slice = false
|
|
155
|
+
} else {
|
|
156
|
+
// Large slices: place in middle of ring
|
|
157
|
+
label_radius = (outer_radius + inner_radius_adjusted) / 2
|
|
158
|
+
is_outside_slice = false
|
|
68
159
|
}
|
|
160
|
+
|
|
69
161
|
// Calculate font scale based on slice size and smart text fitting
|
|
70
|
-
const [min_font_scale, max_font_scale] = [1.4, 2]
|
|
71
|
-
const scale_factor = angle_span / MAX_ANGLE_FOR_FULL_SCALE
|
|
162
|
+
const [min_font_scale, max_font_scale] = [1.4, 2] as const
|
|
163
|
+
const scale_factor = angle_span / MAX_ANGLE_FOR_FULL_SCALE
|
|
72
164
|
const base_scale = min_font_scale +
|
|
73
|
-
|
|
74
|
-
const label_text = element + (show_amounts ? amount
|
|
75
|
-
|
|
165
|
+
scale_factor * (max_font_scale - min_font_scale)
|
|
166
|
+
const label_text = element + (show_amounts ? amount?.toString() ?? `` : ``) +
|
|
167
|
+
(show_percentages ? `${format_num(fraction, `.1~%`)}` : ``)
|
|
76
168
|
const available_space = is_very_thin_slice
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
169
|
+
? outer_radius * 0.8 // More space outside the slice
|
|
170
|
+
: Math.min(
|
|
171
|
+
outer_radius - inner_radius_adjusted, // Radial space
|
|
172
|
+
(angle_span * Math.PI / 180) * label_radius * 0.8, // Arc space at label radius
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
const font_scale = get_chart_font_scale(
|
|
176
|
+
base_scale,
|
|
177
|
+
label_text,
|
|
178
|
+
available_space,
|
|
179
|
+
)
|
|
180
|
+
|
|
82
181
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
})
|
|
100
|
-
|
|
182
|
+
element,
|
|
183
|
+
amount,
|
|
184
|
+
fraction,
|
|
185
|
+
color,
|
|
186
|
+
start_angle,
|
|
187
|
+
end_angle,
|
|
188
|
+
path,
|
|
189
|
+
label_x: center + label_radius * Math.cos(mid_rad),
|
|
190
|
+
label_y: center + label_radius * Math.sin(mid_rad),
|
|
191
|
+
is_outside_slice,
|
|
192
|
+
font_scale,
|
|
193
|
+
text_color: is_outside_slice
|
|
194
|
+
? `var(--text-color, #333)`
|
|
195
|
+
: pick_contrast_color({ bg_color: color }),
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
let hovered_element: ElementSymbol | null = $state(null)
|
|
101
201
|
</script>
|
|
102
202
|
|
|
103
203
|
<svg
|
|
104
204
|
viewBox="0 0 {size} {size}"
|
|
205
|
+
style:max-width="{size}px"
|
|
105
206
|
{...rest}
|
|
106
207
|
class="pie-chart {rest.class ?? ``}"
|
|
107
208
|
bind:this={svg_node}
|
|
@@ -111,7 +212,11 @@ let hovered_element = $state(null);
|
|
|
111
212
|
d={segment.path}
|
|
112
213
|
fill={segment.color}
|
|
113
214
|
stroke="white"
|
|
114
|
-
stroke-width={
|
|
215
|
+
stroke-width={segments.length === 1
|
|
216
|
+
? 0
|
|
217
|
+
: hovered_element === segment.element
|
|
218
|
+
? stroke_width + 1
|
|
219
|
+
: stroke_width}
|
|
115
220
|
class="pie-segment"
|
|
116
221
|
class:interactive
|
|
117
222
|
class:hovered={hovered_element === segment.element}
|
|
@@ -154,14 +259,12 @@ let hovered_element = $state(null);
|
|
|
154
259
|
<span class="element-symbol" style:font-size="{14 * segment.font_scale}px">{
|
|
155
260
|
segment.element
|
|
156
261
|
}</span>
|
|
157
|
-
{#if show_amounts}
|
|
158
|
-
<sub class="amount" style:font-size="{
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
{format_num(segment.fraction, `.1~%`)}
|
|
164
|
-
</sub>
|
|
262
|
+
{#if show_amounts || show_percentages}
|
|
263
|
+
<sub class="amount" style:font-size="{8 * segment.font_scale}px">{
|
|
264
|
+
show_amounts ? segment.amount : ``
|
|
265
|
+
}{show_amounts && show_percentages ? `=` : ``}{
|
|
266
|
+
show_percentages ? format_num(segment.fraction, `.1~%`) : ``
|
|
267
|
+
}</sub>
|
|
165
268
|
{/if}
|
|
166
269
|
</div>
|
|
167
270
|
</foreignObject>
|
|
@@ -215,9 +318,6 @@ let hovered_element = $state(null);
|
|
|
215
318
|
}
|
|
216
319
|
.amount {
|
|
217
320
|
margin-left: 1px;
|
|
218
|
-
transform: translateY(
|
|
219
|
-
}
|
|
220
|
-
.percentage {
|
|
221
|
-
transform: translateY(4px);
|
|
321
|
+
transform: translateY(5pt);
|
|
222
322
|
}
|
|
223
323
|
</style>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ColorSchemeName } from '../colors';
|
|
1
2
|
import type { CompositionType } from './';
|
|
2
3
|
import type { ElementSymbol } from '../element';
|
|
3
|
-
import type { ColorSchemeName } from '../colors';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import type { SVGAttributes } from 'svelte/elements';
|
|
6
6
|
import { type ChartSegmentData } from './index';
|
|
@@ -6,5 +6,10 @@ export declare const get_alphabetical_formula: (input: string | CompositionType
|
|
|
6
6
|
export declare const sort_by_electronegativity: (symbols: ElementSymbol[]) => ElementSymbol[];
|
|
7
7
|
export declare const sort_by_hill_notation: (symbols: ElementSymbol[]) => ElementSymbol[];
|
|
8
8
|
export declare const get_electro_neg_formula: (input: string | CompositionType | AnyStructure, plain_text?: boolean, delim?: string, amount_format?: string) => string;
|
|
9
|
+
export interface FormulaLabelSegment {
|
|
10
|
+
text: string;
|
|
11
|
+
subscript: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function get_formula_label_segments(formula: string): FormulaLabelSegment[];
|
|
9
14
|
export declare const get_hill_formula: (input: string | CompositionType | AnyStructure, plain_text?: boolean, delim?: string, amount_format?: string) => string;
|
|
10
15
|
export declare function format_oxi_state(oxidation?: number): string;
|
|
@@ -27,9 +27,7 @@ export const format_composition_formula = (composition, sort_fn, plain_text = fa
|
|
|
27
27
|
if (amount === 1)
|
|
28
28
|
return el;
|
|
29
29
|
const formatted_amount = format_num(Number(amount), amount_format);
|
|
30
|
-
return plain_text
|
|
31
|
-
? `${el}${formatted_amount}`
|
|
32
|
-
: `${el}<sub>${formatted_amount}</sub>`;
|
|
30
|
+
return plain_text ? `${el}${formatted_amount}` : `${el}<sub>${formatted_amount}</sub>`;
|
|
33
31
|
})
|
|
34
32
|
.join(delim);
|
|
35
33
|
};
|
|
@@ -82,6 +80,25 @@ export const sort_by_hill_notation = (symbols) => {
|
|
|
82
80
|
};
|
|
83
81
|
// Create electronegativity-sorted formula
|
|
84
82
|
export const get_electro_neg_formula = (input, plain_text = false, delim = ` `, amount_format = `.3~f`) => format_formula_generic(input, sort_by_electronegativity, plain_text, delim, amount_format);
|
|
83
|
+
export function get_formula_label_segments(formula) {
|
|
84
|
+
const segments = [];
|
|
85
|
+
let cursor = 0;
|
|
86
|
+
for (const match of formula.matchAll(/([A-Za-z])(\d+(?:\.\d+)?)/g)) {
|
|
87
|
+
const match_idx = match.index ?? 0;
|
|
88
|
+
const prefix = match[1];
|
|
89
|
+
const amount = match[2];
|
|
90
|
+
const amount_idx = match_idx + prefix.length;
|
|
91
|
+
if (amount_idx > cursor) {
|
|
92
|
+
segments.push({ text: formula.slice(cursor, amount_idx), subscript: false });
|
|
93
|
+
}
|
|
94
|
+
segments.push({ text: amount, subscript: true });
|
|
95
|
+
cursor = amount_idx + amount.length;
|
|
96
|
+
}
|
|
97
|
+
if (cursor < formula.length) {
|
|
98
|
+
segments.push({ text: formula.slice(cursor), subscript: false });
|
|
99
|
+
}
|
|
100
|
+
return segments.length > 0 ? segments : [{ text: formula, subscript: false }];
|
|
101
|
+
}
|
|
85
102
|
// Create Hill notation formula (C first, H second, then alphabetical)
|
|
86
103
|
export const get_hill_formula = (input, plain_text = false, delim = ` `, amount_format = `.3~s`) => format_formula_generic(input, sort_by_hill_notation, plain_text, delim, amount_format);
|
|
87
104
|
export function format_oxi_state(oxidation) {
|
|
@@ -21,8 +21,8 @@ export const is_valid_element = (sym) => ELEM_SYMBOLS.includes(sym);
|
|
|
21
21
|
// Check if object has atomic numbers as keys (1-118)
|
|
22
22
|
const is_atomic_number_composition = (obj) => {
|
|
23
23
|
const keys = Object.keys(obj);
|
|
24
|
-
return keys.length > 0 &&
|
|
25
|
-
keys.map(Number).every((num) => Number.isInteger(num) && num >= 1 && num <= 118);
|
|
24
|
+
return (keys.length > 0 &&
|
|
25
|
+
keys.map(Number).every((num) => Number.isInteger(num) && num >= 1 && num <= 118));
|
|
26
26
|
};
|
|
27
27
|
// Convert atomic numbers to element symbols
|
|
28
28
|
export const atomic_num_to_symbols = (atomic_composition) => {
|
|
@@ -148,7 +148,7 @@ export const parse_composition = (input) => {
|
|
|
148
148
|
return normalize_composition(input);
|
|
149
149
|
};
|
|
150
150
|
// Calculate GCD of two numbers
|
|
151
|
-
const gcd = (num_a, num_b) =>
|
|
151
|
+
const gcd = (num_a, num_b) => num_b === 0 ? num_a : gcd(num_b, num_a % num_b);
|
|
152
152
|
// Get reduced formula by dividing all amounts by their GCD
|
|
153
153
|
// Example: Fe2O4 -> FeO2, H4O2 -> H2O
|
|
154
154
|
export const get_reduced_formula = (composition) => {
|
|
@@ -176,7 +176,7 @@ const parse_oxidation_state = (oxidation_str) => {
|
|
|
176
176
|
return oxidation_str === `+` ? 1 : -1;
|
|
177
177
|
}
|
|
178
178
|
// Handle formats like "2+", "+2", "2-", "-2"
|
|
179
|
-
const ox_match =
|
|
179
|
+
const ox_match = /([+-]?)(\d+)([+-]?)/.exec(oxidation_str);
|
|
180
180
|
if (!ox_match)
|
|
181
181
|
return 0;
|
|
182
182
|
const [, sign_before, number, sign_after] = ox_match;
|
|
@@ -211,9 +211,7 @@ export const parse_formula_with_oxidation = (formula, strict = false) => {
|
|
|
211
211
|
const count = count_str ? parseInt(count_str, 10) : 1;
|
|
212
212
|
if (!is_valid_element(element))
|
|
213
213
|
throw new Error(`Invalid element symbol: ${element}`);
|
|
214
|
-
const oxidation_state = oxidation_str
|
|
215
|
-
? parse_oxidation_state(oxidation_str)
|
|
216
|
-
: undefined;
|
|
214
|
+
const oxidation_state = oxidation_str ? parse_oxidation_state(oxidation_str) : undefined;
|
|
217
215
|
// Find or add element entry
|
|
218
216
|
const existing = elements.find((el) => el.element === element);
|
|
219
217
|
if (existing) {
|
|
@@ -304,7 +302,10 @@ export function generate_chem_sys_subspaces(input) {
|
|
|
304
302
|
// Example: "Zr, Nb, InvalidElement, H" -> ["H", "Nb", "Zr"]
|
|
305
303
|
// Note: Matching is case-sensitive. Use all_symbols to filter against a subset.
|
|
306
304
|
export const normalize_element_symbols = (csv, all_symbols) => {
|
|
307
|
-
const input_set = new Set(csv
|
|
305
|
+
const input_set = new Set(csv
|
|
306
|
+
.split(`,`)
|
|
307
|
+
.map((sym) => sym.trim())
|
|
308
|
+
.filter(Boolean));
|
|
308
309
|
// Cast needed: ELEM_SYMBOLS is readonly const tuple, T is generic string subtype
|
|
309
310
|
return (all_symbols ?? ELEM_SYMBOLS).filter((sym) => input_set.has(sym));
|
|
310
311
|
};
|
|
@@ -315,7 +316,11 @@ export const has_wildcards = (input) => input.includes(`*`);
|
|
|
315
316
|
// Accepts both hyphen and comma separators.
|
|
316
317
|
// Throws if any non-wildcard token is not a valid element symbol.
|
|
317
318
|
export function parse_chemsys_with_wildcards(input) {
|
|
318
|
-
const tokens = input
|
|
319
|
+
const tokens = input
|
|
320
|
+
.replace(/-/g, `,`)
|
|
321
|
+
.split(`,`)
|
|
322
|
+
.map((tok) => tok.trim())
|
|
323
|
+
.filter(Boolean);
|
|
319
324
|
const elements = [];
|
|
320
325
|
let wildcard_count = 0;
|
|
321
326
|
for (const token of tokens) {
|