matterviz 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EmptyState.svelte +10 -2
- package/dist/FilePicker.svelte +123 -82
- package/dist/Icon.svelte +18 -12
- package/dist/MillerIndexInput.svelte +27 -21
- package/dist/api/optimade.js +6 -6
- package/dist/app.css +216 -207
- package/dist/brillouin/BrillouinZone.svelte +292 -149
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneControls.svelte +32 -5
- package/dist/brillouin/BrillouinZoneExportPane.svelte +69 -42
- package/dist/brillouin/BrillouinZoneExportPane.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneInfoPane.svelte +99 -68
- package/dist/brillouin/BrillouinZoneScene.svelte +275 -163
- 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 +162 -27
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +451 -281
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2148 -1642
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -5
- 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.js +1 -2
- package/dist/chempot-diagram/compute.d.ts +10 -0
- package/dist/chempot-diagram/compute.js +250 -88
- package/dist/chempot-diagram/index.d.ts +2 -1
- package/dist/chempot-diagram/index.js +2 -1
- package/dist/chempot-diagram/temperature.js +8 -9
- package/dist/chempot-diagram/types.d.ts +3 -0
- package/dist/chempot-diagram/types.js +1 -0
- package/dist/colors/index.d.ts +1 -1
- package/dist/colors/index.js +5 -3
- package/dist/composition/BarChart.svelte +128 -55
- package/dist/composition/BubbleChart.svelte +102 -49
- package/dist/composition/Composition.svelte +100 -79
- package/dist/composition/Formula.svelte +108 -62
- package/dist/composition/FormulaFilter.svelte +665 -537
- package/dist/composition/PieChart.svelte +183 -108
- 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 -40
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +549 -360
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +1296 -827
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +1004 -688
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +115 -28
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullInfoPane.svelte +29 -3
- package/dist/convex-hull/ConvexHullStats.svelte +425 -328
- package/dist/convex-hull/ConvexHullTooltip.svelte +40 -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.js +8 -4
- package/dist/convex-hull/gas-thermodynamics.js +17 -12
- package/dist/convex-hull/helpers.d.ts +9 -0
- package/dist/convex-hull/helpers.js +77 -34
- package/dist/convex-hull/thermodynamics.js +61 -56
- package/dist/convex-hull/types.d.ts +9 -14
- package/dist/convex-hull/types.js +0 -17
- package/dist/coordination/CoordinationBarPlot.svelte +227 -154
- package/dist/element/BohrAtom.svelte +55 -12
- 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/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 +328 -187
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte +113 -46
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +535 -342
- 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 +24 -14
- package/dist/fermi-surface/symmetry.js +2 -7
- package/dist/fermi-surface/types.d.ts +3 -5
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1019 -765
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +1 -1
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +76 -22
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +2 -3
- package/dist/icons.js +47 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/io/decompress.js +1 -1
- package/dist/io/export.d.ts +3 -0
- package/dist/io/export.js +129 -143
- package/dist/io/is-binary.js +2 -3
- package/dist/io/url-drop.js +1 -2
- package/dist/isosurface/Isosurface.svelte +202 -148
- package/dist/isosurface/IsosurfaceControls.svelte +46 -28
- package/dist/isosurface/parse.js +34 -29
- package/dist/isosurface/slice.js +5 -10
- package/dist/isosurface/types.d.ts +2 -1
- package/dist/isosurface/types.js +61 -12
- package/dist/labels.js +11 -8
- package/dist/layout/FullscreenToggle.svelte +11 -2
- package/dist/layout/InfoCard.svelte +38 -6
- package/dist/layout/InfoTag.svelte +63 -32
- package/dist/layout/PropertyFilter.svelte +82 -37
- package/dist/layout/SettingsSection.svelte +85 -55
- package/dist/layout/SubpageGrid.svelte +10 -2
- package/dist/layout/json-tree/JsonNode.svelte +183 -138
- package/dist/layout/json-tree/JsonTree.svelte +499 -413
- package/dist/layout/json-tree/JsonValue.svelte +127 -99
- package/dist/layout/json-tree/utils.js +4 -2
- package/dist/marching-cubes.js +25 -2
- package/dist/math.d.ts +13 -17
- package/dist/math.js +133 -67
- package/dist/overlays/ContextMenu.svelte +65 -40
- package/dist/overlays/DraggablePane.svelte +211 -139
- 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 +446 -309
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramControls.svelte +102 -43
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +63 -40
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +71 -28
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +1 -1
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +158 -101
- 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/parse.js +10 -9
- package/dist/phase-diagram/svg-to-diagram.js +53 -49
- package/dist/phase-diagram/utils.d.ts +1 -0
- package/dist/phase-diagram/utils.js +80 -25
- package/dist/plot/AxisLabel.svelte +28 -3
- package/dist/plot/BarPlot.svelte +1182 -734
- package/dist/plot/BarPlot.svelte.d.ts +2 -2
- package/dist/plot/BarPlotControls.svelte +31 -5
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +479 -329
- package/dist/plot/ColorScaleSelect.svelte +27 -6
- package/dist/plot/ElementScatter.svelte +36 -15
- package/dist/plot/FillArea.svelte +152 -95
- package/dist/plot/Histogram.svelte +934 -571
- package/dist/plot/Histogram.svelte.d.ts +1 -1
- package/dist/plot/HistogramControls.svelte +53 -9
- package/dist/plot/HistogramControls.svelte.d.ts +1 -1
- 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 +157 -114
- 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 -147
- package/dist/plot/ReferenceLine.svelte +76 -22
- package/dist/plot/ReferenceLine3D.svelte +132 -107
- package/dist/plot/ReferencePlane.svelte +146 -121
- package/dist/plot/ScatterPlot.svelte +1681 -1091
- package/dist/plot/ScatterPlot.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3D.svelte +256 -131
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +113 -63
- package/dist/plot/ScatterPlot3DControls.svelte.d.ts +2 -1
- package/dist/plot/ScatterPlot3DScene.svelte +608 -403
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +65 -25
- 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 +55 -3
- package/dist/plot/ZoomRect.svelte +4 -2
- 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/layout.d.ts +4 -1
- package/dist/plot/layout.js +33 -14
- package/dist/plot/reference-line.d.ts +2 -2
- package/dist/plot/reference-line.js +7 -5
- package/dist/plot/scales.js +24 -36
- package/dist/plot/types.d.ts +11 -23
- package/dist/plot/types.js +6 -11
- package/dist/plot/utils/label-placement.d.ts +32 -15
- package/dist/plot/utils/label-placement.js +227 -66
- package/dist/plot/utils/series-visibility.js +2 -3
- package/dist/rdf/RdfPlot.svelte +143 -91
- 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 +18 -6
- package/dist/settings.js +46 -16
- package/dist/spectral/Bands.svelte +632 -453
- 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.js +55 -43
- 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 +215 -134
- package/dist/structure/Bond.svelte +73 -47
- package/dist/structure/CanvasTooltip.svelte +10 -2
- package/dist/structure/CellSelect.svelte +72 -45
- package/dist/structure/Cylinder.svelte +33 -17
- package/dist/structure/Lattice.svelte +88 -33
- package/dist/structure/Structure.svelte +1063 -797
- package/dist/structure/Structure.svelte.d.ts +1 -1
- package/dist/structure/StructureControls.svelte +349 -118
- package/dist/structure/StructureExportPane.svelte +124 -89
- package/dist/structure/StructureExportPane.svelte.d.ts +1 -1
- package/dist/structure/StructureInfoPane.svelte +304 -237
- package/dist/structure/StructureScene.svelte +879 -443
- package/dist/structure/StructureScene.svelte.d.ts +15 -7
- package/dist/structure/atom-properties.js +8 -8
- package/dist/structure/bonding.js +6 -7
- package/dist/structure/export.js +14 -29
- package/dist/structure/ferrox-wasm.js +1 -1
- package/dist/structure/index.d.ts +13 -3
- package/dist/structure/index.js +83 -23
- package/dist/structure/measure.d.ts +2 -2
- package/dist/structure/measure.js +4 -44
- package/dist/structure/parse.js +113 -141
- package/dist/structure/partial-occupancy.js +7 -10
- 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 +1 -2
- package/dist/symmetry/SymmetryStats.svelte +84 -41
- package/dist/symmetry/WyckoffTable.svelte +26 -6
- package/dist/symmetry/cell-transform.js +5 -3
- package/dist/symmetry/index.js +8 -7
- package/dist/symmetry/spacegroups.js +148 -148
- package/dist/table/HeatmapTable.svelte +790 -554
- package/dist/table/HeatmapTable.svelte.d.ts +1 -1
- package/dist/table/ToggleMenu.svelte +125 -92
- 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 +758 -558
- package/dist/trajectory/TrajectoryError.svelte +14 -3
- package/dist/trajectory/TrajectoryExportPane.svelte +137 -83
- package/dist/trajectory/TrajectoryInfoPane.svelte +272 -143
- package/dist/trajectory/extract.js +10 -26
- package/dist/trajectory/format-detect.js +5 -5
- package/dist/trajectory/frame-reader.d.ts +1 -1
- package/dist/trajectory/frame-reader.js +5 -12
- package/dist/trajectory/helpers.d.ts +0 -1
- package/dist/trajectory/helpers.js +2 -17
- package/dist/trajectory/index.js +14 -12
- package/dist/trajectory/parse/ase.js +5 -4
- package/dist/trajectory/parse/hdf5.js +26 -18
- package/dist/trajectory/parse/index.js +13 -18
- package/dist/trajectory/parse/lammps.js +17 -7
- package/dist/trajectory/parse/vasp.js +5 -2
- package/dist/trajectory/parse/xyz.js +8 -7
- package/dist/trajectory/plotting.js +13 -8
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +13 -0
- package/dist/xrd/XrdPlot.svelte +337 -247
- package/dist/xrd/broadening.js +14 -9
- package/dist/xrd/calc-xrd.js +12 -18
- package/dist/xrd/parse.d.ts +1 -1
- package/dist/xrd/parse.js +17 -17
- package/package.json +99 -103
- package/readme.md +1 -1
- /package/dist/theme/{themes.js → themes.mjs} +0 -0
|
@@ -44,6 +44,6 @@ type $$ComponentProps = HTMLAttributes<HTMLDivElement> & {
|
|
|
44
44
|
}]>;
|
|
45
45
|
footer?: Snippet;
|
|
46
46
|
};
|
|
47
|
-
declare const HeatmapTable: import("svelte").Component<$$ComponentProps, {}, "sort" | "data" | "show_controls" | "controls_open" | "
|
|
47
|
+
declare const HeatmapTable: import("svelte").Component<$$ComponentProps, {}, "sort" | "data" | "show_controls" | "controls_open" | "show_heatmap" | "column_order" | "selected_rows" | "hidden_columns" | "loading" | "heatmap_opacity">;
|
|
48
48
|
type HeatmapTable = ReturnType<typeof HeatmapTable>;
|
|
49
49
|
export default HeatmapTable;
|
|
@@ -1,106 +1,139 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../Icon.svelte'
|
|
3
|
+
import { sanitize_html } from '../sanitize'
|
|
4
|
+
import type { Label } from './'
|
|
5
|
+
import { click_outside, tooltip } from 'svelte-multiselect/attachments'
|
|
6
|
+
import { slide } from 'svelte/transition'
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
columns = $bindable([]),
|
|
10
|
+
column_panel_open = $bindable(false),
|
|
11
|
+
n_columns,
|
|
12
|
+
collapsed_sections = $bindable<string[]>([]),
|
|
13
|
+
on_reset,
|
|
14
|
+
}: {
|
|
15
|
+
columns: Label[]
|
|
16
|
+
column_panel_open?: boolean
|
|
17
|
+
// Number of grid columns for toggle layout
|
|
18
|
+
n_columns?: number
|
|
19
|
+
collapsed_sections?: string[]
|
|
20
|
+
// Called after reset with the section name (or undefined for global reset)
|
|
21
|
+
on_reset?: (section?: string) => void
|
|
22
|
+
} = $props()
|
|
23
|
+
|
|
24
|
+
const col_id = (col: Label) => col.key ?? col.label
|
|
25
|
+
|
|
26
|
+
// Snapshot default visibility when column set changes (new dataset).
|
|
27
|
+
// Compare by column keys to avoid re-snapshotting on internal columns = [...columns] reactivity.
|
|
28
|
+
// Intentionally non-reactive: mutated only inside snapshot_defaults() and compared manually.
|
|
29
|
+
let prev_col_keys = ``
|
|
30
|
+
let default_visibility: Record<string, boolean> = {}
|
|
31
|
+
function snapshot_defaults() {
|
|
32
|
+
default_visibility = {}
|
|
13
33
|
for (const col of columns) {
|
|
14
|
-
|
|
34
|
+
default_visibility[col_id(col)] = col.visible !== false
|
|
15
35
|
}
|
|
16
|
-
prev_col_keys = columns.map(col_id).join(`\0`)
|
|
17
|
-
}
|
|
18
|
-
snapshot_defaults()
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
prev_col_keys = columns.map(col_id).join(`\0`)
|
|
37
|
+
}
|
|
38
|
+
snapshot_defaults()
|
|
39
|
+
|
|
40
|
+
$effect(() => {
|
|
41
|
+
const current_keys = columns.map(col_id).join(`\0`)
|
|
21
42
|
if (current_keys !== prev_col_keys) {
|
|
22
|
-
|
|
43
|
+
snapshot_defaults()
|
|
23
44
|
}
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Check if a column's visibility differs from its default
|
|
48
|
+
const is_changed = (col: Label) =>
|
|
49
|
+
(col.visible !== false) !== (default_visibility[col_id(col)] ?? true)
|
|
50
|
+
|
|
51
|
+
let has_any_changes = $derived(columns.some(is_changed))
|
|
52
|
+
|
|
53
|
+
// Reset columns to default visibility
|
|
54
|
+
function reset_columns(items: Label[]): void {
|
|
30
55
|
for (const col of items) {
|
|
31
|
-
|
|
56
|
+
col.visible = default_visibility[col_id(col)] ?? true
|
|
32
57
|
}
|
|
33
|
-
columns = [...columns]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
columns = [...columns]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function reset_all(): void {
|
|
62
|
+
reset_columns(columns)
|
|
63
|
+
on_reset?.()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function reset_section(section_name: string): void {
|
|
67
|
+
const section = sections.find((sec) => sec.name === section_name)
|
|
68
|
+
if (!section) return
|
|
69
|
+
reset_columns(section.items)
|
|
70
|
+
on_reset?.(section_name)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Group columns by their group property
|
|
74
|
+
let sections = $derived.by(() => {
|
|
75
|
+
const grouped: Record<string, Label[]> = {}
|
|
76
|
+
const ungrouped: Label[] = []
|
|
77
|
+
|
|
50
78
|
for (const col of columns) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
79
|
+
if (col.group) {
|
|
80
|
+
grouped[col.group] ??= []
|
|
81
|
+
grouped[col.group].push(col)
|
|
82
|
+
} else {
|
|
83
|
+
ungrouped.push(col)
|
|
84
|
+
}
|
|
58
85
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return result
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
|
|
87
|
+
const result = Object.entries(grouped).map(([name, items]) => ({ name, items }))
|
|
88
|
+
if (ungrouped.length > 0) result.push({ name: ``, items: ungrouped })
|
|
89
|
+
return result
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
// Check if any column defines a group (to decide whether to show sections)
|
|
93
|
+
let has_sections = $derived(columns.some((col) => col.group))
|
|
94
|
+
|
|
95
|
+
function toggle_section(name: string) {
|
|
67
96
|
collapsed_sections = collapsed_sections.includes(name)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
col.visible = event.target.checked
|
|
75
|
-
columns = [...columns]
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
97
|
+
? collapsed_sections.filter((s) => s !== name)
|
|
98
|
+
: [...collapsed_sections, name]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function toggle_column_visibility(col: Label, event: Event) {
|
|
102
|
+
if (!(event.target instanceof HTMLInputElement)) return
|
|
103
|
+
col.visible = event.target.checked
|
|
104
|
+
columns = [...columns] // trigger reactivity on parent binding
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Grid template for section items
|
|
108
|
+
let grid_template = $derived(
|
|
109
|
+
n_columns
|
|
110
|
+
? `repeat(${n_columns}, max-content)`
|
|
111
|
+
: `repeat(auto-fill, minmax(135px, 1fr))`,
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
// Reposition dropdown: left-aligned by default, switch to right if it overflows viewport
|
|
115
|
+
let details_el: HTMLElement | undefined
|
|
116
|
+
$effect(() => {
|
|
117
|
+
if (!column_panel_open || !details_el) return
|
|
86
118
|
// Re-run when section state changes while open
|
|
87
|
-
void n_columns
|
|
88
|
-
void collapsed_sections
|
|
89
|
-
void sections
|
|
90
|
-
const dropdown = details_el.querySelector(
|
|
91
|
-
|
|
92
|
-
|
|
119
|
+
void n_columns
|
|
120
|
+
void collapsed_sections
|
|
121
|
+
void sections
|
|
122
|
+
const dropdown = details_el.querySelector<HTMLElement>(
|
|
123
|
+
`.column-menu, .sections-container`,
|
|
124
|
+
)
|
|
125
|
+
if (!dropdown) return
|
|
93
126
|
// Reset to left-aligned
|
|
94
|
-
dropdown.style.left = `0
|
|
95
|
-
dropdown.style.right = `auto
|
|
127
|
+
dropdown.style.left = `0`
|
|
128
|
+
dropdown.style.right = `auto`
|
|
96
129
|
requestAnimationFrame(() => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
})
|
|
130
|
+
const rect = dropdown.getBoundingClientRect()
|
|
131
|
+
if (rect.right > window.innerWidth) {
|
|
132
|
+
dropdown.style.left = `auto`
|
|
133
|
+
dropdown.style.right = `0`
|
|
134
|
+
}
|
|
135
|
+
})
|
|
136
|
+
})
|
|
104
137
|
</script>
|
|
105
138
|
|
|
106
139
|
{#snippet toggle_item(col: Label)}
|
|
@@ -115,7 +148,7 @@ $effect(() => {
|
|
|
115
148
|
disabled={col.disabled}
|
|
116
149
|
onchange={(event) => toggle_column_visibility(col, event)}
|
|
117
150
|
/>
|
|
118
|
-
{@html col.label}
|
|
151
|
+
{@html sanitize_html(col.label)}
|
|
119
152
|
</label>
|
|
120
153
|
{/snippet}
|
|
121
154
|
|
package/dist/table/index.js
CHANGED
|
@@ -13,16 +13,14 @@ better, // sort direction
|
|
|
13
13
|
color_scale = `interpolateViridis`, // color scale name
|
|
14
14
|
scale_type = `linear`) {
|
|
15
15
|
// Skip color calculation for null/undefined/NaN values or if color_scale is null
|
|
16
|
-
if (val
|
|
16
|
+
if (val == null || Number.isNaN(val) || color_scale === null) {
|
|
17
17
|
return { bg: null, text: null };
|
|
18
18
|
}
|
|
19
19
|
// Log scale cannot handle non-positive values, return null colors
|
|
20
20
|
if (scale_type === `log` && val <= 0) {
|
|
21
21
|
return { bg: null, text: null };
|
|
22
22
|
}
|
|
23
|
-
const numeric_vals = all_values.filter((v) => typeof v === `number` &&
|
|
24
|
-
!Number.isNaN(v) &&
|
|
25
|
-
(scale_type === `log` ? v > 0 : true));
|
|
23
|
+
const numeric_vals = all_values.filter((v) => typeof v === `number` && !Number.isNaN(v) && (scale_type === `log` ? v > 0 : true));
|
|
26
24
|
if (numeric_vals.length === 0)
|
|
27
25
|
return { bg: null, text: null };
|
|
28
26
|
const range = [min(numeric_vals) ?? 0, max(numeric_vals) ?? 1];
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { theme_state } from '../state.svelte'
|
|
3
|
+
import type { HTMLAttributes } from 'svelte/elements'
|
|
4
|
+
import type { ThemeMode } from './index'
|
|
5
|
+
import { apply_theme_to_dom, save_theme_preference, THEME_OPTIONS } from './index'
|
|
6
|
+
|
|
7
|
+
let { theme_mode = $bindable(theme_state.mode), onchange = () => {}, ...rest }:
|
|
8
|
+
& Omit<HTMLAttributes<HTMLSelectElement>, `onchange`>
|
|
9
|
+
& {
|
|
10
|
+
theme_mode?: ThemeMode // Current theme mode (now bindable to global state)
|
|
11
|
+
onchange?: (mode: ThemeMode) => void // Callback when theme changes
|
|
12
|
+
} = $props()
|
|
13
|
+
|
|
14
|
+
$effect(() => { // Sync and save to local storage when theme changes
|
|
15
|
+
const prev = theme_state.mode
|
|
16
|
+
if (prev === theme_mode) return
|
|
17
|
+
theme_state.mode = theme_mode
|
|
18
|
+
save_theme_preference(theme_mode)
|
|
19
|
+
apply_theme_to_dom(theme_mode)
|
|
20
|
+
onchange(theme_mode)
|
|
21
|
+
})
|
|
13
22
|
</script>
|
|
14
23
|
|
|
15
24
|
<select bind:value={theme_mode} {...rest} class="theme-control {rest.class ?? ``}">
|
package/dist/time.js
CHANGED
|
@@ -39,7 +39,10 @@ export const format_utc_time = (date) => {
|
|
|
39
39
|
const timestamp = typeof date === `string` ? new Date(date) : date;
|
|
40
40
|
if (isNaN(timestamp.getTime()))
|
|
41
41
|
return `N/A`;
|
|
42
|
-
return timestamp
|
|
42
|
+
return timestamp
|
|
43
|
+
.toISOString()
|
|
44
|
+
.replace(`T`, ` `)
|
|
45
|
+
.replace(/\.\d+Z$/, ` UTC`);
|
|
43
46
|
};
|
|
44
47
|
// Format duration between two dates: "5h 23m", "2d 3h", "45m".
|
|
45
48
|
export const format_duration = (start, end) => {
|
|
@@ -1,20 +1,45 @@
|
|
|
1
|
-
<script lang="ts" generics="T, SnippetArg = T">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
<script lang="ts" generics="T, SnippetArg = T">
|
|
2
|
+
// Wrapper component that handles the common tooltip pattern:
|
|
3
|
+
// - If tooltip is a snippet function, render it exclusively (replaces default content)
|
|
4
|
+
// - If tooltip is a config object, render prefix/suffix around the default content
|
|
5
|
+
// - Otherwise, render just the default content
|
|
6
|
+
import { sanitize_html } from '../sanitize'
|
|
7
|
+
import type { Snippet } from 'svelte'
|
|
8
|
+
import type { TooltipConfig } from './types'
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
data,
|
|
12
|
+
snippet_arg,
|
|
13
|
+
tooltip,
|
|
14
|
+
children,
|
|
15
|
+
}: {
|
|
16
|
+
data: T // Data passed to config prefix/suffix functions
|
|
17
|
+
snippet_arg: SnippetArg // Single arg passed to custom snippet (can differ from data)
|
|
18
|
+
tooltip?: Snippet<[SnippetArg]> | TooltipConfig<T>
|
|
19
|
+
children: Snippet
|
|
20
|
+
} = $props()
|
|
21
|
+
|
|
22
|
+
const is_snippet = $derived(typeof tooltip === `function`)
|
|
23
|
+
const config = $derived(
|
|
24
|
+
!is_snippet && tooltip ? (tooltip as TooltipConfig<T>) : null,
|
|
25
|
+
)
|
|
26
|
+
const prefix = $derived(
|
|
27
|
+
typeof config?.prefix === `function` ? config.prefix(data) : config?.prefix,
|
|
28
|
+
)
|
|
29
|
+
const suffix = $derived(
|
|
30
|
+
typeof config?.suffix === `function` ? config.suffix(data) : config?.suffix,
|
|
31
|
+
)
|
|
7
32
|
</script>
|
|
8
33
|
|
|
9
34
|
{#if is_snippet}
|
|
10
35
|
{@render (tooltip as Snippet<[SnippetArg]>)(snippet_arg)}
|
|
11
36
|
{:else}
|
|
12
37
|
{#if prefix}
|
|
13
|
-
<div class="tooltip-prefix">{@html prefix}</div>
|
|
38
|
+
<div class="tooltip-prefix">{@html sanitize_html(prefix)}</div>
|
|
14
39
|
{/if}
|
|
15
40
|
{@render children()}
|
|
16
41
|
{#if suffix}
|
|
17
|
-
<div class="tooltip-suffix">{@html suffix}</div>
|
|
42
|
+
<div class="tooltip-suffix">{@html sanitize_html(suffix)}</div>
|
|
18
43
|
{/if}
|
|
19
44
|
{/if}
|
|
20
45
|
|