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,169 +1,214 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import Icon from '../../Icon.svelte'
|
|
3
|
+
import { getContext, onMount } from 'svelte'
|
|
4
|
+
import JsonNode from './JsonNode.svelte'
|
|
5
|
+
import JsonValue from './JsonValue.svelte'
|
|
6
|
+
import type { JsonTreeContext } from './types'
|
|
7
|
+
import { JSON_TREE_CONTEXT_KEY } from './types'
|
|
8
|
+
import {
|
|
9
|
+
build_path,
|
|
10
|
+
estimate_byte_size,
|
|
11
|
+
format_byte_size,
|
|
12
|
+
format_preview,
|
|
13
|
+
get_child_count,
|
|
14
|
+
get_value_type,
|
|
15
|
+
is_expandable,
|
|
16
|
+
} from './utils'
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
node_key = null,
|
|
20
|
+
value,
|
|
21
|
+
path,
|
|
22
|
+
depth,
|
|
23
|
+
is_last = true,
|
|
24
|
+
}: {
|
|
25
|
+
node_key?: string | number | null
|
|
26
|
+
value: unknown
|
|
27
|
+
path: string
|
|
28
|
+
depth: number
|
|
29
|
+
is_last?: boolean
|
|
30
|
+
} = $props()
|
|
31
|
+
|
|
32
|
+
const ctx = getContext<JsonTreeContext>(JSON_TREE_CONTEXT_KEY)
|
|
33
|
+
|
|
34
|
+
onMount(() => {
|
|
10
35
|
// Register this path with context for keyboard navigation
|
|
11
36
|
if (ctx && path) {
|
|
12
|
-
|
|
13
|
-
|
|
37
|
+
ctx.register_path(path)
|
|
38
|
+
return () => ctx.unregister_path(path)
|
|
14
39
|
}
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
let
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
// Determine value type
|
|
43
|
+
let value_type = $derived(get_value_type(value))
|
|
44
|
+
|
|
45
|
+
// Check if this node is expandable
|
|
46
|
+
let expandable = $derived(is_expandable(value))
|
|
47
|
+
|
|
48
|
+
// Get child count for preview
|
|
49
|
+
let child_count = $derived(expandable ? get_child_count(value) : 0)
|
|
50
|
+
|
|
51
|
+
// Determine if this node should be collapsed
|
|
52
|
+
let is_collapsed = $derived.by(() => {
|
|
53
|
+
if (!expandable) return false
|
|
54
|
+
|
|
26
55
|
// Check if explicitly collapsed
|
|
27
|
-
if (ctx?.collapsed.has(path))
|
|
28
|
-
|
|
56
|
+
if (ctx?.collapsed.has(path)) return true
|
|
57
|
+
|
|
29
58
|
// Check if explicitly force-expanded (overrides auto-fold)
|
|
30
|
-
if (ctx?.force_expanded.has(path))
|
|
31
|
-
|
|
59
|
+
if (ctx?.force_expanded.has(path)) return false
|
|
60
|
+
|
|
32
61
|
// If depth >= default_fold_level, default to collapsed
|
|
33
|
-
const fold_level = ctx?.settings.default_fold_level ?? 2
|
|
34
|
-
if (depth >= fold_level)
|
|
35
|
-
|
|
62
|
+
const fold_level = ctx?.settings.default_fold_level ?? 2
|
|
63
|
+
if (depth >= fold_level) return true
|
|
64
|
+
|
|
36
65
|
// Check auto-fold thresholds
|
|
37
66
|
if (value_type === `array`) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return true;
|
|
67
|
+
const threshold = ctx?.settings.auto_fold_arrays ?? 10
|
|
68
|
+
if (child_count > threshold) return true
|
|
41
69
|
}
|
|
42
70
|
if (value_type === `object`) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return true;
|
|
71
|
+
const threshold = ctx?.settings.auto_fold_objects ?? 20
|
|
72
|
+
if (child_count > threshold) return true
|
|
46
73
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
74
|
+
|
|
75
|
+
return false
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Note: Search highlighting is handled by CSS Highlight API in JsonTree.svelte
|
|
79
|
+
|
|
80
|
+
// Check if this node is focused
|
|
81
|
+
let is_focused = $derived(ctx?.focused_path === path)
|
|
82
|
+
|
|
83
|
+
// Check if this is the current search match being navigated
|
|
84
|
+
let is_current_match = $derived(ctx?.current_match_path === path)
|
|
85
|
+
|
|
86
|
+
// Check if this node is selected
|
|
87
|
+
let is_selected = $derived(ctx?.selected_paths.has(path) ?? false)
|
|
88
|
+
|
|
89
|
+
// Diff status for this node (null if no diff or unchanged)
|
|
90
|
+
let diff_status = $derived(ctx?.diff_map?.get(path)?.status ?? null)
|
|
91
|
+
|
|
92
|
+
// Estimated byte size for collapsed preview (only compute when collapsed)
|
|
93
|
+
let byte_size = $derived(
|
|
94
|
+
expandable && is_collapsed ? format_byte_size(estimate_byte_size(value)) : ``,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
// Toggle collapse state
|
|
98
|
+
function toggle_collapse(event?: MouseEvent) {
|
|
99
|
+
event?.stopPropagation()
|
|
63
100
|
if (ctx && expandable) {
|
|
64
|
-
|
|
101
|
+
ctx.toggle_collapse(path, is_collapsed)
|
|
65
102
|
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Toggle collapse recursively on double-click
|
|
106
|
+
function toggle_collapse_recursive(event: MouseEvent) {
|
|
107
|
+
event.stopPropagation()
|
|
70
108
|
if (ctx && expandable) {
|
|
71
|
-
|
|
72
|
-
|
|
109
|
+
// If collapsed, expand all; if expanded, collapse all
|
|
110
|
+
ctx.toggle_collapse_recursive(path, !is_collapsed)
|
|
73
111
|
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// Focus this node
|
|
115
|
+
function focus_node() {
|
|
116
|
+
ctx?.set_focused(path)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Get children based on value type
|
|
120
|
+
function get_children(): Array<{ key: string | number; value: unknown }> {
|
|
121
|
+
if (!expandable) return []
|
|
122
|
+
|
|
83
123
|
if (value_type === `array`) {
|
|
84
|
-
|
|
124
|
+
return (value as unknown[]).map((val, idx) => ({ key: idx, value: val }))
|
|
85
125
|
}
|
|
126
|
+
|
|
86
127
|
if (value_type === `object`) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
128
|
+
let keys = Object.keys(value as Record<string, unknown>)
|
|
129
|
+
if (ctx?.settings.sort_keys) {
|
|
130
|
+
keys = keys.sort()
|
|
131
|
+
}
|
|
132
|
+
return keys.map((key) => ({
|
|
133
|
+
key,
|
|
134
|
+
value: (value as Record<string, unknown>)[key],
|
|
135
|
+
}))
|
|
95
136
|
}
|
|
137
|
+
|
|
96
138
|
if (value_type === `map`) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
139
|
+
const map = value as Map<unknown, unknown>
|
|
140
|
+
return Array.from(map.entries()).map(([key, val], idx) => ({
|
|
141
|
+
key: idx,
|
|
142
|
+
value: { key, value: val },
|
|
143
|
+
}))
|
|
102
144
|
}
|
|
145
|
+
|
|
103
146
|
if (value_type === `set`) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
147
|
+
return Array.from(value as Set<unknown>).map((val, idx) => ({
|
|
148
|
+
key: idx,
|
|
149
|
+
value: val,
|
|
150
|
+
}))
|
|
108
151
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
152
|
+
|
|
153
|
+
return []
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let children = $derived(get_children())
|
|
157
|
+
|
|
158
|
+
// Ghost children: removed entries from diff (pre-computed in JsonTree for O(1) lookup)
|
|
159
|
+
let ghost_children = $derived.by(() => {
|
|
160
|
+
if (!expandable || is_collapsed) return []
|
|
161
|
+
const all_ghosts = ctx?.ghost_map.get(path) ?? []
|
|
162
|
+
if (all_ghosts.length === 0) return []
|
|
119
163
|
// Filter out ghosts whose keys already exist in current children
|
|
120
|
-
const existing_keys = new Set(children.map((child) => String(child.key)))
|
|
121
|
-
return all_ghosts.filter((ghost) => !existing_keys.has(String(ghost.key)))
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
164
|
+
const existing_keys = new Set(children.map((child) => String(child.key)))
|
|
165
|
+
return all_ghosts.filter((ghost) => !existing_keys.has(String(ghost.key)))
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Get bracket characters based on type
|
|
169
|
+
let open_bracket = $derived(value_type === `array` ? `[` : `{`)
|
|
170
|
+
let close_bracket = $derived(value_type === `array` ? `]` : `}`)
|
|
171
|
+
|
|
172
|
+
// Handle keyboard navigation
|
|
173
|
+
function handle_keydown(event: KeyboardEvent) {
|
|
174
|
+
if (!is_focused) return
|
|
175
|
+
|
|
130
176
|
if (event.key === `Enter` || event.key === ` `) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
event.preventDefault();
|
|
156
|
-
event.stopPropagation();
|
|
157
|
-
ctx?.copy_value(path, value);
|
|
177
|
+
event.preventDefault()
|
|
178
|
+
if (expandable) {
|
|
179
|
+
toggle_collapse()
|
|
180
|
+
} else {
|
|
181
|
+
ctx?.copy_value(path, value)
|
|
182
|
+
}
|
|
183
|
+
} else if (event.key === `ArrowRight`) {
|
|
184
|
+
event.preventDefault()
|
|
185
|
+
if (expandable && is_collapsed) {
|
|
186
|
+
toggle_collapse()
|
|
187
|
+
}
|
|
188
|
+
} else if (event.key === `ArrowLeft`) {
|
|
189
|
+
event.preventDefault()
|
|
190
|
+
if (expandable && !is_collapsed) {
|
|
191
|
+
toggle_collapse()
|
|
192
|
+
}
|
|
193
|
+
} else if (
|
|
194
|
+
(event.key === `c` || event.key === `C`) && (event.ctrlKey || event.metaKey)
|
|
195
|
+
) {
|
|
196
|
+
// When nodes are selected, let the tree-level handler do bulk copy
|
|
197
|
+
if (ctx?.selected_paths.size) return
|
|
198
|
+
event.preventDefault()
|
|
199
|
+
event.stopPropagation()
|
|
200
|
+
ctx?.copy_value(path, value)
|
|
158
201
|
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
$
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Element reference for focus management
|
|
205
|
+
let node_element: HTMLDivElement | undefined = $state()
|
|
206
|
+
|
|
207
|
+
$effect(() => {
|
|
163
208
|
if (is_focused && node_element) {
|
|
164
|
-
|
|
209
|
+
node_element.focus()
|
|
165
210
|
}
|
|
166
|
-
})
|
|
211
|
+
})
|
|
167
212
|
</script>
|
|
168
213
|
|
|
169
214
|
<div
|
|
@@ -223,9 +268,6 @@ $effect(() => {
|
|
|
223
268
|
type="button"
|
|
224
269
|
class="node-key"
|
|
225
270
|
class:array-index={typeof node_key === `number`}
|
|
226
|
-
title={expandable && is_collapsed
|
|
227
|
-
? `Click to expand · Shift+click: copy path · Ctrl+click: select`
|
|
228
|
-
: `Click to copy value · Shift+click: copy path · Ctrl+click: select`}
|
|
229
271
|
tabindex="-1"
|
|
230
272
|
onclick={(event) => {
|
|
231
273
|
event.stopPropagation()
|
|
@@ -348,17 +390,50 @@ $effect(() => {
|
|
|
348
390
|
font-size: var(--jt-font-size, 13px);
|
|
349
391
|
line-height: var(--jt-line-height, 1.5);
|
|
350
392
|
outline: none;
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
393
|
+
&:focus {
|
|
394
|
+
outline: none;
|
|
395
|
+
}
|
|
396
|
+
&.focused > .node-content {
|
|
397
|
+
background: var(--jt-focus-bg, light-dark(#e3f2fd, #0d3a58));
|
|
398
|
+
border-radius: 2px;
|
|
399
|
+
}
|
|
400
|
+
&.current-match > .node-content {
|
|
401
|
+
background: var(--jt-current-match-bg, light-dark(#ffcc80, #8a5600));
|
|
402
|
+
border-radius: 2px;
|
|
403
|
+
}
|
|
404
|
+
&.selected > .node-content {
|
|
405
|
+
background: var(--jt-select-bg, light-dark(#bbdefb, #0a3050));
|
|
406
|
+
}
|
|
407
|
+
&.diff-added > .node-content {
|
|
408
|
+
background: var(
|
|
409
|
+
--jt-diff-added,
|
|
410
|
+
light-dark(rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.2))
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
&.diff-removed > .node-content {
|
|
414
|
+
background: var(
|
|
415
|
+
--jt-diff-removed,
|
|
416
|
+
light-dark(rgba(244, 67, 54, 0.12), rgba(244, 67, 54, 0.18))
|
|
417
|
+
);
|
|
418
|
+
text-decoration: line-through;
|
|
419
|
+
opacity: 0.7;
|
|
420
|
+
}
|
|
421
|
+
&.diff-changed > .node-content {
|
|
422
|
+
background: var(
|
|
423
|
+
--jt-diff-changed,
|
|
424
|
+
light-dark(rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.2))
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
&.sticky-header > .node-content {
|
|
428
|
+
position: sticky;
|
|
429
|
+
top: calc(var(--jt-sticky-depth) * 20px);
|
|
430
|
+
z-index: calc(100 - var(--jt-sticky-depth));
|
|
431
|
+
background: var(--jt-sticky-bg, var(--jt-bg, transparent));
|
|
432
|
+
display: flex;
|
|
433
|
+
}
|
|
434
|
+
&:hover > .node-content > .collapse-level-btn {
|
|
435
|
+
opacity: 0.5;
|
|
436
|
+
}
|
|
362
437
|
}
|
|
363
438
|
.node-content {
|
|
364
439
|
display: inline-flex;
|
|
@@ -366,14 +441,22 @@ $effect(() => {
|
|
|
366
441
|
gap: 2px;
|
|
367
442
|
padding: 1px 2px;
|
|
368
443
|
border-radius: 2px;
|
|
444
|
+
/* Higher specificity than DraggablePane's :where(button) so our reset wins when nested */
|
|
445
|
+
button {
|
|
446
|
+
background: none;
|
|
447
|
+
border: none;
|
|
448
|
+
padding: 0;
|
|
449
|
+
cursor: pointer;
|
|
450
|
+
font: inherit;
|
|
451
|
+
color: inherit;
|
|
452
|
+
}
|
|
369
453
|
}
|
|
370
|
-
.node-content
|
|
371
|
-
background:
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
color: inherit;
|
|
454
|
+
.ghost .node-content {
|
|
455
|
+
background: var(
|
|
456
|
+
--jt-diff-removed,
|
|
457
|
+
light-dark(rgba(244, 67, 54, 0.12), rgba(244, 67, 54, 0.18))
|
|
458
|
+
);
|
|
459
|
+
text-decoration: line-through;
|
|
377
460
|
}
|
|
378
461
|
.collapse-toggle {
|
|
379
462
|
display: inline-flex;
|
|
@@ -384,17 +467,17 @@ $effect(() => {
|
|
|
384
467
|
margin: 0;
|
|
385
468
|
color: var(--jt-arrow, light-dark(#6e6e6e, #858585));
|
|
386
469
|
flex-shrink: 0;
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
470
|
+
&:hover {
|
|
471
|
+
color: light-dark(#000, #fff);
|
|
472
|
+
}
|
|
390
473
|
}
|
|
391
474
|
.arrow {
|
|
392
475
|
display: inline-block;
|
|
393
476
|
font-size: 0.7em;
|
|
394
477
|
transition: transform 0.15s ease;
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
478
|
+
&.collapsed {
|
|
479
|
+
transform: rotate(-90deg);
|
|
480
|
+
}
|
|
398
481
|
}
|
|
399
482
|
.no-toggle {
|
|
400
483
|
display: inline-block;
|
|
@@ -403,30 +486,29 @@ $effect(() => {
|
|
|
403
486
|
}
|
|
404
487
|
.node-key {
|
|
405
488
|
color: var(--jt-key, light-dark(#001080, #9cdcfe));
|
|
489
|
+
&:hover {
|
|
490
|
+
text-decoration: underline;
|
|
491
|
+
.action-hint {
|
|
492
|
+
opacity: 0.6;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
&.array-index .index {
|
|
496
|
+
color: var(--jt-number, light-dark(#098658, #b5cea8));
|
|
497
|
+
}
|
|
406
498
|
}
|
|
407
|
-
.
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
.node-key.array-index .index {
|
|
411
|
-
color: var(--jt-number, light-dark(#098658, #b5cea8));
|
|
499
|
+
.colon, .comma, .bracket {
|
|
500
|
+
color: var(--jt-punctuation, light-dark(#000, #d4d4d4));
|
|
412
501
|
}
|
|
413
502
|
.colon {
|
|
414
|
-
color: var(--jt-punctuation, light-dark(#000, #d4d4d4));
|
|
415
503
|
margin-right: 4px;
|
|
416
504
|
}
|
|
417
|
-
.bracket {
|
|
418
|
-
color: var(--jt-punctuation, light-dark(#000, #d4d4d4));
|
|
419
|
-
}
|
|
420
505
|
.preview {
|
|
421
506
|
color: var(--jt-preview, light-dark(#808080, #808080));
|
|
422
507
|
font-style: italic;
|
|
423
508
|
margin: 0 4px;
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
.comma {
|
|
429
|
-
color: var(--jt-punctuation, light-dark(#000, #d4d4d4));
|
|
509
|
+
&:hover {
|
|
510
|
+
text-decoration: underline;
|
|
511
|
+
}
|
|
430
512
|
}
|
|
431
513
|
.children {
|
|
432
514
|
padding-left: var(--jt-indent, 1.2em);
|
|
@@ -434,39 +516,6 @@ $effect(() => {
|
|
|
434
516
|
var(--jt-indent-guide, light-dark(rgba(0, 0, 0, 0.1), rgba(255, 255, 255, 0.1)));
|
|
435
517
|
margin-left: 0.5em;
|
|
436
518
|
}
|
|
437
|
-
.json-node.selected > .node-content {
|
|
438
|
-
background: var(--jt-select-bg, light-dark(#bbdefb, #0a3050));
|
|
439
|
-
}
|
|
440
|
-
.json-node.diff-added > .node-content {
|
|
441
|
-
background: var(
|
|
442
|
-
--jt-diff-added,
|
|
443
|
-
light-dark(rgba(76, 175, 80, 0.15), rgba(76, 175, 80, 0.2))
|
|
444
|
-
);
|
|
445
|
-
}
|
|
446
|
-
.json-node.diff-removed > .node-content,
|
|
447
|
-
.ghost .node-content {
|
|
448
|
-
background: var(
|
|
449
|
-
--jt-diff-removed,
|
|
450
|
-
light-dark(rgba(244, 67, 54, 0.12), rgba(244, 67, 54, 0.18))
|
|
451
|
-
);
|
|
452
|
-
text-decoration: line-through;
|
|
453
|
-
}
|
|
454
|
-
.json-node.diff-removed > .node-content {
|
|
455
|
-
opacity: 0.7;
|
|
456
|
-
}
|
|
457
|
-
.json-node.diff-changed > .node-content {
|
|
458
|
-
background: var(
|
|
459
|
-
--jt-diff-changed,
|
|
460
|
-
light-dark(rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.2))
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
.json-node.sticky-header > .node-content {
|
|
464
|
-
position: sticky;
|
|
465
|
-
top: calc(var(--jt-sticky-depth) * 20px);
|
|
466
|
-
z-index: calc(100 - var(--jt-sticky-depth));
|
|
467
|
-
background: var(--jt-sticky-bg, var(--jt-bg, light-dark(white, #1e1e1e)));
|
|
468
|
-
display: flex;
|
|
469
|
-
}
|
|
470
519
|
.action-hint {
|
|
471
520
|
opacity: 0;
|
|
472
521
|
font-size: 0.8em;
|
|
@@ -474,9 +523,6 @@ $effect(() => {
|
|
|
474
523
|
transition: opacity 0.15s;
|
|
475
524
|
color: var(--jt-arrow, light-dark(#6e6e6e, #858585));
|
|
476
525
|
}
|
|
477
|
-
.node-key:hover .action-hint {
|
|
478
|
-
opacity: 0.6;
|
|
479
|
-
}
|
|
480
526
|
.size-hint {
|
|
481
527
|
font-size: 0.8em;
|
|
482
528
|
color: var(--jt-preview, light-dark(#808080, #808080));
|
|
@@ -490,13 +536,10 @@ $effect(() => {
|
|
|
490
536
|
color: var(--jt-arrow, light-dark(#6e6e6e, #858585));
|
|
491
537
|
transition: opacity 0.15s;
|
|
492
538
|
margin-left: 4px;
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
.collapse-level-btn:hover {
|
|
498
|
-
opacity: 1;
|
|
499
|
-
color: light-dark(#000, #fff);
|
|
539
|
+
&:hover {
|
|
540
|
+
opacity: 1;
|
|
541
|
+
color: light-dark(#000, #fff);
|
|
542
|
+
}
|
|
500
543
|
}
|
|
501
544
|
.ghost {
|
|
502
545
|
opacity: 0.5;
|