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,13 +1,45 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { format_num } from '../labels'
|
|
3
|
+
import { sanitize_html } from '../sanitize'
|
|
4
|
+
import type { Snippet } from 'svelte'
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
6
|
+
|
|
7
|
+
interface Props<T extends keyof HTMLElementTagNameMap = `section`>
|
|
8
|
+
extends HTMLAttributes<HTMLElementTagNameMap[T]> {
|
|
9
|
+
data?: {
|
|
10
|
+
title: string
|
|
11
|
+
value?: string | number | number[] | null
|
|
12
|
+
unit?: string
|
|
13
|
+
fmt?: string
|
|
14
|
+
condition?: boolean | number | null
|
|
15
|
+
tooltip?: string
|
|
16
|
+
}[]
|
|
17
|
+
title?: string
|
|
18
|
+
fallback?: string
|
|
19
|
+
fmt?: string
|
|
20
|
+
as?: T
|
|
21
|
+
title_snippet?: Snippet
|
|
22
|
+
fallback_snippet?: Snippet
|
|
23
|
+
}
|
|
24
|
+
let {
|
|
25
|
+
data = [],
|
|
26
|
+
title = ``,
|
|
27
|
+
fallback = ``,
|
|
28
|
+
fmt = `.2f`,
|
|
29
|
+
as = `section`,
|
|
30
|
+
title_snippet,
|
|
31
|
+
fallback_snippet,
|
|
32
|
+
...rest
|
|
33
|
+
}: Props = $props()
|
|
34
|
+
|
|
35
|
+
let default_fmt = $derived(fmt) // rename fmt to default_fmt for internal use
|
|
4
36
|
</script>
|
|
5
37
|
|
|
6
38
|
<svelte:element this={as} {...rest} class="info-card {rest.class ?? ``}">
|
|
7
39
|
{#if title || title_snippet}
|
|
8
40
|
<h2>
|
|
9
41
|
{#if title_snippet}{@render title_snippet()}{:else}
|
|
10
|
-
{@html title}
|
|
42
|
+
{@html sanitize_html(title)}
|
|
11
43
|
{/if}
|
|
12
44
|
</h2>
|
|
13
45
|
{/if}
|
|
@@ -20,10 +52,10 @@ let default_fmt = $derived(fmt); // rename fmt to default_fmt for internal use
|
|
|
20
52
|
}
|
|
21
53
|
<div>
|
|
22
54
|
<span class="title" {title}>
|
|
23
|
-
{@html title}
|
|
55
|
+
{@html sanitize_html(title)}
|
|
24
56
|
</span>
|
|
25
57
|
<strong title={tooltip ?? null}>
|
|
26
|
-
{@html typeof value == `number` ? format_num(value, fmt) : value}
|
|
58
|
+
{@html sanitize_html(typeof value == `number` ? format_num(value, fmt) : value)}
|
|
27
59
|
{#if unit}
|
|
28
60
|
<small>{unit}</small>
|
|
29
61
|
{/if}
|
|
@@ -1,33 +1,64 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import { sanitize_html } from '../sanitize'
|
|
4
|
+
import type { Snippet } from 'svelte'
|
|
5
|
+
import { tooltip } from 'svelte-multiselect'
|
|
6
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
7
|
+
import type { InfoTagSize, InfoTagVariant } from './index'
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
label,
|
|
11
|
+
value,
|
|
12
|
+
copy_value,
|
|
13
|
+
title,
|
|
14
|
+
variant = `default`,
|
|
15
|
+
size = `md`,
|
|
16
|
+
removable = false,
|
|
17
|
+
disabled = false,
|
|
18
|
+
onclick,
|
|
19
|
+
onremove,
|
|
20
|
+
children,
|
|
21
|
+
...rest
|
|
22
|
+
}: {
|
|
23
|
+
label: string // Label text (supports HTML)
|
|
24
|
+
value: string | number | undefined // Value to display (supports HTML)
|
|
25
|
+
copy_value?: string | number // Value to copy to clipboard (defaults to value)
|
|
26
|
+
title?: string // Tooltip text
|
|
27
|
+
variant?: InfoTagVariant // Visual variant for semantic meaning
|
|
28
|
+
size?: InfoTagSize // Size variant
|
|
29
|
+
removable?: boolean // Show remove/close button
|
|
30
|
+
disabled?: boolean // Disable interactions
|
|
31
|
+
onclick?: (event: MouseEvent) => void // Custom click handler (overrides copy-to-clipboard default)
|
|
32
|
+
onremove?: () => void // Callback when remove button is clicked
|
|
33
|
+
children?: Snippet<[]> // Additional content to render inside the tag
|
|
34
|
+
} & Omit<HTMLAttributes<HTMLSpanElement>, `onclick` | `onkeydown`> = $props()
|
|
35
|
+
|
|
36
|
+
let just_copied = $state(false)
|
|
37
|
+
|
|
38
|
+
async function copy_to_clipboard(): Promise<void> {
|
|
39
|
+
const to_copy = copy_value ?? value
|
|
40
|
+
if (to_copy === undefined) return
|
|
41
|
+
await navigator.clipboard.writeText(String(to_copy))
|
|
42
|
+
just_copied = true
|
|
43
|
+
setTimeout(() => (just_copied = false), 1000)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function handle_click(event: MouseEvent): void {
|
|
47
|
+
if (disabled) return
|
|
48
|
+
if (onclick) onclick(event)
|
|
49
|
+
else void copy_to_clipboard()
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function handle_keydown(event: KeyboardEvent): void {
|
|
53
|
+
if (disabled || (event.key !== `Enter` && event.key !== ` `)) return
|
|
54
|
+
event.preventDefault()
|
|
55
|
+
;(event.currentTarget as HTMLElement)?.click()
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function handle_remove(event: MouseEvent): void {
|
|
59
|
+
event.stopPropagation()
|
|
60
|
+
onremove?.()
|
|
61
|
+
}
|
|
31
62
|
</script>
|
|
32
63
|
|
|
33
64
|
<span
|
|
@@ -42,8 +73,8 @@ function handle_remove(event) {
|
|
|
42
73
|
aria-disabled={disabled}
|
|
43
74
|
{...rest}
|
|
44
75
|
>
|
|
45
|
-
{@html label}
|
|
46
|
-
<em>{@html value}</em>
|
|
76
|
+
{@html sanitize_html(label)}
|
|
77
|
+
<em>{@html sanitize_html(value)}</em>
|
|
47
78
|
{#if just_copied}
|
|
48
79
|
<Icon
|
|
49
80
|
icon="Check"
|
|
@@ -67,63 +98,63 @@ function handle_remove(event) {
|
|
|
67
98
|
border: 1px solid;
|
|
68
99
|
white-space: nowrap;
|
|
69
100
|
border-color: color-mix(in srgb, var(--tag-color) 25%, transparent);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
101
|
+
em {
|
|
102
|
+
font-style: normal;
|
|
103
|
+
font-weight: 600;
|
|
104
|
+
color: var(--tag-color);
|
|
105
|
+
}
|
|
106
|
+
&:hover:not(.disabled) {
|
|
107
|
+
background: color-mix(in srgb, var(--tag-color) 18%, transparent);
|
|
108
|
+
border-color: color-mix(in srgb, var(--tag-color) 40%, transparent);
|
|
109
|
+
}
|
|
110
|
+
&.sm {
|
|
111
|
+
font-size: 0.72em;
|
|
112
|
+
padding: 0 5pt;
|
|
113
|
+
border-radius: 4px;
|
|
114
|
+
}
|
|
115
|
+
&.md {
|
|
116
|
+
font-size: 0.8em;
|
|
117
|
+
padding: 1pt 6pt;
|
|
118
|
+
border-radius: 5px;
|
|
119
|
+
}
|
|
120
|
+
&.lg {
|
|
121
|
+
font-size: 0.9em;
|
|
122
|
+
padding: 3pt 8pt;
|
|
123
|
+
border-radius: 6px;
|
|
124
|
+
}
|
|
125
|
+
&.default {
|
|
126
|
+
--tag-color: var(--highlight, #4db6ff);
|
|
127
|
+
}
|
|
128
|
+
&.success {
|
|
129
|
+
--tag-color: var(--success-color, #10b981);
|
|
130
|
+
}
|
|
131
|
+
&.warning {
|
|
132
|
+
--tag-color: var(--warning-color, #f59e0b);
|
|
133
|
+
}
|
|
134
|
+
&.error {
|
|
135
|
+
--tag-color: var(--error-color, #ef4444);
|
|
136
|
+
}
|
|
137
|
+
&.info {
|
|
138
|
+
--tag-color: var(--info-color, #3b82f6);
|
|
139
|
+
}
|
|
140
|
+
&.disabled {
|
|
141
|
+
opacity: 0.5;
|
|
142
|
+
cursor: not-allowed;
|
|
143
|
+
}
|
|
144
|
+
&:active:not(.disabled) {
|
|
145
|
+
transform: scale(0.97);
|
|
146
|
+
}
|
|
147
|
+
:global(.copy-checkmark) {
|
|
148
|
+
position: absolute;
|
|
149
|
+
top: 50%;
|
|
150
|
+
right: 3pt;
|
|
151
|
+
transform: translateY(-50%);
|
|
152
|
+
background: rgba(16, 185, 129, 0.9);
|
|
153
|
+
border-radius: 50%;
|
|
154
|
+
padding: 2pt;
|
|
155
|
+
display: flex;
|
|
156
|
+
animation: pop-in 0.15s ease-out;
|
|
157
|
+
}
|
|
127
158
|
}
|
|
128
159
|
[aria-label='Remove'] {
|
|
129
160
|
display: flex;
|
|
@@ -137,11 +168,11 @@ function handle_remove(event) {
|
|
|
137
168
|
border-radius: 50%;
|
|
138
169
|
color: inherit;
|
|
139
170
|
opacity: 0.5;
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
171
|
+
&:hover {
|
|
172
|
+
opacity: 1;
|
|
173
|
+
background: rgba(239, 68, 68, 0.2);
|
|
174
|
+
color: var(--error-color, #ef4444);
|
|
175
|
+
}
|
|
145
176
|
}
|
|
146
177
|
@keyframes pop-in {
|
|
147
178
|
from {
|
|
@@ -1,50 +1,95 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import { sanitize_html } from '../sanitize'
|
|
4
|
+
import type { AxisConfig, DataSeries } from '../plot'
|
|
5
|
+
import { Histogram } from '../plot'
|
|
6
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
label,
|
|
10
|
+
min_value = $bindable(),
|
|
11
|
+
max_value = $bindable(),
|
|
12
|
+
placeholders = {},
|
|
13
|
+
title,
|
|
14
|
+
histogram_data,
|
|
15
|
+
histogram_height = 30,
|
|
16
|
+
histogram_color = `rgba(0, 0, 0, 0.2)`,
|
|
17
|
+
histogram_position = `top`,
|
|
18
|
+
log = false,
|
|
19
|
+
disabled = false,
|
|
20
|
+
unit,
|
|
21
|
+
show_clear_button = true,
|
|
22
|
+
onchange,
|
|
23
|
+
onclear,
|
|
24
|
+
...rest
|
|
25
|
+
}: {
|
|
26
|
+
label: string // Label text (supports HTML)
|
|
27
|
+
min_value?: number // Minimum value for filtering (undefined = unbounded)
|
|
28
|
+
max_value?: number // Maximum value for filtering (undefined = unbounded)
|
|
29
|
+
placeholders?: { min?: string; max?: string } // Placeholder text for min/max inputs
|
|
30
|
+
title?: string // Tooltip title for the label
|
|
31
|
+
histogram_data?: number[] // Data array for histogram visualization
|
|
32
|
+
histogram_height?: number // Height of histogram in pixels
|
|
33
|
+
histogram_color?: string // Color for histogram bars (unfilled data)
|
|
34
|
+
histogram_position?: `top` | `bottom` | `none` // Position of histogram relative to inputs, or 'none' to hide
|
|
35
|
+
log?: boolean // Use logarithmic scale for histogram y-axis
|
|
36
|
+
disabled?: boolean // Disable all inputs
|
|
37
|
+
unit?: string // Unit label to display after inputs
|
|
38
|
+
show_clear_button?: boolean // Show clear button when filters are active
|
|
39
|
+
onchange?: (min: number | undefined, max: number | undefined) => void // Callback when filter values change
|
|
40
|
+
onclear?: () => void // Callback when clear button is clicked (fires before onchange)
|
|
41
|
+
} & HTMLAttributes<HTMLDivElement> = $props()
|
|
42
|
+
|
|
43
|
+
let show_histogram = $derived(
|
|
44
|
+
histogram_position !== `none` && histogram_data?.length,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
// Active when either bound is set (undefined = unbounded)
|
|
48
|
+
let active = $derived(min_value !== undefined || max_value !== undefined)
|
|
49
|
+
let plain_label = $derived(label.replace(/<[^>]*>/g, ``))
|
|
50
|
+
|
|
51
|
+
let filtered_data = $derived.by(() => {
|
|
52
|
+
if (!histogram_data) return []
|
|
11
53
|
// undefined means unbounded (-Infinity for min, +Infinity for max)
|
|
12
|
-
const min = min_value ?? -Infinity
|
|
13
|
-
const max = max_value ?? Infinity
|
|
14
|
-
return histogram_data.filter((val) => val >= min && val <= max)
|
|
15
|
-
})
|
|
16
|
-
|
|
54
|
+
const min = min_value ?? -Infinity
|
|
55
|
+
const max = max_value ?? Infinity
|
|
56
|
+
return histogram_data.filter((val) => val >= min && val <= max)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
function onkeydown(event: KeyboardEvent): void {
|
|
17
60
|
if (event.key === `Enter`) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
clear_filter();
|
|
61
|
+
event.preventDefault()
|
|
62
|
+
;(event.target as HTMLInputElement).blur()
|
|
63
|
+
} else if (event.key === `Escape` && active) {
|
|
64
|
+
event.preventDefault()
|
|
65
|
+
clear_filter()
|
|
24
66
|
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function clear_filter(): void {
|
|
70
|
+
min_value = max_value = undefined
|
|
71
|
+
onclear?.()
|
|
72
|
+
onchange?.(undefined, undefined)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const axis_config: AxisConfig = {
|
|
32
76
|
ticks: 0,
|
|
33
77
|
label: ``,
|
|
34
78
|
grid_style: { style: `opacity: 0` },
|
|
35
79
|
tick: { label: { inside: true } },
|
|
36
80
|
color: `color-mix(in srgb, currentColor 60%, transparent)`,
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// x: [] satisfies DataSeries type requirement; Histogram bins on y values only
|
|
84
|
+
const series: DataSeries[] = $derived([
|
|
40
85
|
{ y: histogram_data ?? [], color: histogram_color, label: `All`, x: [] },
|
|
41
86
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
87
|
+
y: filtered_data,
|
|
88
|
+
color: `var(--accent-color, #228be6)`,
|
|
89
|
+
label: `Filtered`,
|
|
90
|
+
x: [],
|
|
46
91
|
},
|
|
47
|
-
])
|
|
92
|
+
])
|
|
48
93
|
</script>
|
|
49
94
|
|
|
50
95
|
{#snippet histogram_snippet()}
|
|
@@ -76,7 +121,7 @@ const series = $derived([
|
|
|
76
121
|
{@render histogram_snippet()}
|
|
77
122
|
{/if}
|
|
78
123
|
<div class="filter-row">
|
|
79
|
-
<span {title} class="filter-label">{@html label}</span>
|
|
124
|
+
<span {title} class="filter-label">{@html sanitize_html(label)}</span>
|
|
80
125
|
<div class="filter-inputs">
|
|
81
126
|
<input
|
|
82
127
|
bind:value={min_value}
|
|
@@ -1,64 +1,94 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import type { Snippet } from 'svelte'
|
|
4
|
+
import { untrack } from 'svelte'
|
|
5
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
title,
|
|
9
|
+
current_values,
|
|
10
|
+
children,
|
|
11
|
+
on_reset = () => {},
|
|
12
|
+
...rest
|
|
13
|
+
}: HTMLAttributes<HTMLElementTagNameMap[`section`]> & {
|
|
14
|
+
title: string
|
|
15
|
+
current_values: Record<string, unknown>
|
|
16
|
+
children: Snippet<
|
|
17
|
+
[{
|
|
18
|
+
current_values: Record<string, unknown>
|
|
19
|
+
has_changes: boolean
|
|
20
|
+
reference_values: Record<string, unknown>
|
|
21
|
+
}]
|
|
22
|
+
>
|
|
23
|
+
on_reset?: () => void
|
|
24
|
+
} = $props()
|
|
25
|
+
|
|
26
|
+
// Create a deep copy of current_values on mount to use as reference values
|
|
27
|
+
function deep_copy(obj: unknown): unknown {
|
|
28
|
+
if (obj === null || typeof obj !== `object`) return obj
|
|
29
|
+
if (obj instanceof Date) return new Date(obj.getTime())
|
|
30
|
+
if (obj instanceof RegExp) return new RegExp(obj)
|
|
12
31
|
if (Array.isArray(obj)) {
|
|
13
|
-
|
|
32
|
+
return obj.map((item) =>
|
|
33
|
+
typeof item === `object` && item !== null ? deep_copy(item) : item
|
|
34
|
+
)
|
|
14
35
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
36
|
+
|
|
37
|
+
const copy: Record<string, unknown> = {}
|
|
38
|
+
for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
|
|
39
|
+
copy[key] = typeof value === `object` && value !== null
|
|
40
|
+
? deep_copy(value)
|
|
41
|
+
: value
|
|
20
42
|
}
|
|
21
|
-
return copy
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
return copy
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Capture initial values once at mount - must NOT be $derived or it tracks changes
|
|
47
|
+
const reference_values = untrack(() =>
|
|
48
|
+
deep_copy(current_values) as Record<string, unknown>
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
// Check if any values have changed from reference values
|
|
52
|
+
let has_changes = $derived.by(() => {
|
|
27
53
|
for (const [key, reference_value] of Object.entries(reference_values)) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// Handle undefined/null comparisons properly
|
|
46
|
-
if (reference_value === undefined && current_value === undefined)
|
|
47
|
-
continue;
|
|
48
|
-
if (reference_value === null && current_value === null)
|
|
49
|
-
continue;
|
|
50
|
-
// Basic comparison for primitives
|
|
51
|
-
if (current_value !== reference_value) {
|
|
52
|
-
return true;
|
|
54
|
+
const current_value = current_values[key]
|
|
55
|
+
|
|
56
|
+
// Deep comparison for arrays
|
|
57
|
+
if (Array.isArray(reference_value) && Array.isArray(current_value)) {
|
|
58
|
+
if (reference_value.length !== current_value.length) return true
|
|
59
|
+
if (
|
|
60
|
+
reference_value.some((val, idx) => {
|
|
61
|
+
const curr_val = current_value[idx]
|
|
62
|
+
// Handle nested objects/arrays in arrays
|
|
63
|
+
if (
|
|
64
|
+
typeof val === `object` && val !== null &&
|
|
65
|
+
typeof curr_val === `object` && curr_val !== null
|
|
66
|
+
) return JSON.stringify(val) !== JSON.stringify(curr_val) // Quick deep comparison fallback
|
|
67
|
+
return val !== curr_val
|
|
68
|
+
})
|
|
69
|
+
) {
|
|
70
|
+
return true
|
|
53
71
|
}
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Handle undefined/null comparisons properly
|
|
76
|
+
if (reference_value === undefined && current_value === undefined) continue
|
|
77
|
+
if (reference_value === null && current_value === null) continue
|
|
78
|
+
|
|
79
|
+
// Basic comparison for primitives
|
|
80
|
+
if (current_value !== reference_value) {
|
|
81
|
+
return true
|
|
82
|
+
}
|
|
54
83
|
}
|
|
55
|
-
return false
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
event.
|
|
60
|
-
|
|
61
|
-
|
|
84
|
+
return false
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
function handle_reset(event: MouseEvent) {
|
|
88
|
+
event.stopPropagation()
|
|
89
|
+
event.preventDefault()
|
|
90
|
+
on_reset()
|
|
91
|
+
}
|
|
62
92
|
</script>
|
|
63
93
|
|
|
64
94
|
<h4 id="settings-section-title">
|