@opendata-ai/openchart-react 8.0.0-rc.23 → 8.0.0-rc.25

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/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { BarListSpec, ThemeConfig, DarkMode, DataRow, ChartEventHandlers, ChartSpec, LayerSpec, GraphSpec, ElementRef, MapSpec, TableSpec, SortState, ChartLayout, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
1
+ import { BarListSpec, ThemeConfig, DarkMode, DataRow, ChartEventHandlers, ChartSpec, LayerSpec, GraphSpec, ElementRef, GeoMapSpec, TableSpec, SortState, ChartLayout, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
2
2
  export * from '@opendata-ai/openchart-core';
3
- import { BarListInstance, ChartInstance, MountOptions, CameraFlightOptions, GraphHighlightTarget, GraphLegendData, GraphInstance, GraphTooltipFormatter, TableInstance, TableState, TableMountOptions, MapMarkEvent, MapInstance, SankeyInstance, TileMapInstance } from '@opendata-ai/openchart-vanilla';
3
+ import { BarListInstance, ChartInstance, MountOptions, GeoMapMarkEvent, GeoMapInstance, CameraFlightOptions, GraphHighlightTarget, GraphLegendData, GraphInstance, GraphTooltipFormatter, TableInstance, TableState, TableMountOptions, SankeyInstance, TileMapInstance } from '@opendata-ai/openchart-vanilla';
4
4
  export { JPGExportOptions, PNGExportOptions, SVGExportOptions, SpecSequenceOptions, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, exportSpecSequence } from '@opendata-ai/openchart-vanilla';
5
- export { ChartRenderer, CompileResult, CompiledGraphEdge, CompiledGraphNode, GraphCompilation, NormalizedBarListSpec, NormalizedChartSpec, NormalizedChrome, NormalizedGraphSpec, NormalizedMapSpec, NormalizedSankeySpec, NormalizedSpec, NormalizedTableSpec, NormalizedTileMapSpec, SimulationConfig, ValidationError, ValidationErrorCode, ValidationResult, clearRenderers, compile, compileBarList, compileChart, compileGraph, compileMap, compileSankey, compileTable, compileTileMap, getChartRenderer, normalizeSpec, registerChartRenderer, validateSpec } from '@opendata-ai/openchart-engine';
5
+ export { ChartRenderer, CompileResult, CompiledGraphEdge, CompiledGraphNode, GraphCompilation, NormalizedBarListSpec, NormalizedChartSpec, NormalizedChrome, NormalizedGeoMapSpec, NormalizedGraphSpec, NormalizedSankeySpec, NormalizedSpec, NormalizedTableSpec, NormalizedTileMapSpec, SimulationConfig, ValidationError, ValidationErrorCode, ValidationResult, clearRenderers, compile, compileBarList, compileChart, compileGeoMap, compileGraph, compileSankey, compileTable, compileTileMap, getChartRenderer, normalizeSpec, registerChartRenderer, validateSpec } from '@opendata-ai/openchart-engine';
6
6
  import * as react from 'react';
7
7
  import { CSSProperties, ReactNode, Ref } from 'react';
8
8
  import * as react_jsx_runtime from 'react/jsx-runtime';
@@ -55,6 +55,11 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
55
55
  theme?: ThemeConfig;
56
56
  /** Dark mode: "auto", "force", or "off". */
57
57
  darkMode?: DarkMode;
58
+ /**
59
+ * Rendering backend for point marks (mirrors vega-embed's `renderer`
60
+ * option). `'auto'` (default) promotes dense scatters to canvas.
61
+ */
62
+ renderer?: 'auto' | 'svg' | 'canvas';
58
63
  /** Callback when a data point is clicked. @deprecated Use onMarkClick instead. */
59
64
  onDataPointClick?: (data: Record<string, unknown>) => void;
60
65
  /** The currently selected element (controlled). */
@@ -89,7 +94,7 @@ interface ChartStoryHandle {
89
94
  }
90
95
  interface ChartStoryProps<TData extends DataRow = DataRow> {
91
96
  /** Base spec the story drives. */
92
- spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec | MapSpec;
97
+ spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec | GeoMapSpec;
93
98
  /** Ordered step patches. `steps[i]` is applied cumulatively onto the base. */
94
99
  steps: ChartStoryOptions<TData>['steps'];
95
100
  /**
@@ -152,6 +157,28 @@ interface DataTableProps {
152
157
  */
153
158
  declare function DataTable({ spec, theme: themeProp, darkMode, onRowClick, onSortChange, onSearchChange, onPageChange, className, style, sort, search, page, }: DataTableProps): react_jsx_runtime.JSX.Element;
154
159
 
160
+ interface GeoMapProps {
161
+ /** The map spec to render. */
162
+ spec: GeoMapSpec;
163
+ /** Theme overrides. */
164
+ theme?: ThemeConfig;
165
+ /** Dark mode: "auto", "force", or "off". */
166
+ darkMode?: DarkMode;
167
+ /** Callback when a map feature is clicked. */
168
+ onMarkClick?: (feature: GeoMapMarkEvent) => void;
169
+ /** Callback when a map feature is hovered (null when hover ends). */
170
+ onMarkHover?: (feature: GeoMapMarkEvent | null) => void;
171
+ /** CSS class name for the wrapper div. */
172
+ className?: string;
173
+ /** Inline styles for the wrapper div. */
174
+ style?: CSSProperties;
175
+ }
176
+ interface GeoMapHandle {
177
+ /** The underlying map instance (null until mounted). */
178
+ readonly instance: GeoMapInstance | null;
179
+ }
180
+ declare const GeoMap: react.ForwardRefExoticComponent<GeoMapProps & react.RefAttributes<GeoMapHandle>>;
181
+
155
182
  /**
156
183
  * useGraph: hook for imperative graph control.
157
184
  *
@@ -349,6 +376,8 @@ interface UseChartOptions {
349
376
  onDataPointClick?: MountOptions['onDataPointClick'];
350
377
  /** Enable responsive resizing. Defaults to true. */
351
378
  responsive?: boolean;
379
+ /** Rendering backend for point marks; see the vanilla `MountOptions.renderer`. */
380
+ renderer?: MountOptions['renderer'];
352
381
  }
353
382
  interface UseChartReturn {
354
383
  /** Ref to attach to the container div. */
@@ -448,28 +477,6 @@ interface UseTableStateOptions {
448
477
  */
449
478
  declare function useTableState(initialState?: UseTableStateOptions): UseTableStateReturn;
450
479
 
451
- interface MapProps {
452
- /** The map spec to render. */
453
- spec: MapSpec;
454
- /** Theme overrides. */
455
- theme?: ThemeConfig;
456
- /** Dark mode: "auto", "force", or "off". */
457
- darkMode?: DarkMode;
458
- /** Callback when a map feature is clicked. */
459
- onMarkClick?: (feature: MapMarkEvent) => void;
460
- /** Callback when a map feature is hovered (null when hover ends). */
461
- onMarkHover?: (feature: MapMarkEvent | null) => void;
462
- /** CSS class name for the wrapper div. */
463
- className?: string;
464
- /** Inline styles for the wrapper div. */
465
- style?: CSSProperties;
466
- }
467
- interface MapHandle {
468
- /** The underlying map instance (null until mounted). */
469
- readonly instance: MapInstance | null;
470
- }
471
- declare const GeoMap: react.ForwardRefExoticComponent<MapProps & react.RefAttributes<MapHandle>>;
472
-
473
480
  interface SankeyProps {
474
481
  /** The sankey spec to render. */
475
482
  spec: SankeySpec;
@@ -576,4 +583,4 @@ interface VisualizationProps {
576
583
  */
577
584
  declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps): react_jsx_runtime.JSX.Element;
578
585
 
579
- export { BarList, type BarListHandle, type BarListProps, Chart, type ChartHandle, type ChartProps, ChartStory, type ChartStoryHandle, type ChartStoryProps, DataTable, type DataTableProps, GeoMap, Graph, type GraphHandle, type GraphProps, type MapHandle, type MapProps, Sankey, type SankeyHandle, type SankeyProps, TileMap, type TileMapHandle, type TileMapProps, type UseChartOptions, type UseChartReturn, type UseGraphReturn, type UseTableReturn, type UseTableStateOptions, type UseTableStateReturn, Visualization, type VisualizationProps, VizThemeProvider, type VizThemeProviderProps, useChart, useDarkMode, useGraph, useTable, useTableState, useVizDarkMode, useVizTheme };
586
+ export { BarList, type BarListHandle, type BarListProps, Chart, type ChartHandle, type ChartProps, ChartStory, type ChartStoryHandle, type ChartStoryProps, DataTable, type DataTableProps, GeoMap, type GeoMapHandle, type GeoMapProps, Graph, type GraphHandle, type GraphProps, Sankey, type SankeyHandle, type SankeyProps, TileMap, type TileMapHandle, type TileMapProps, type UseChartOptions, type UseChartReturn, type UseGraphReturn, type UseTableReturn, type UseTableStateOptions, type UseTableStateReturn, Visualization, type VisualizationProps, VizThemeProvider, type VizThemeProviderProps, useChart, useDarkMode, useGraph, useTable, useTableState, useVizDarkMode, useVizTheme };
package/dist/index.js CHANGED
@@ -13,8 +13,8 @@ import {
13
13
  compile,
14
14
  compileBarList,
15
15
  compileChart,
16
+ compileGeoMap,
16
17
  compileGraph,
17
- compileMap,
18
18
  compileSankey,
19
19
  compileTable,
20
20
  compileTileMap,
@@ -129,6 +129,7 @@ function ChartInner({
129
129
  spec,
130
130
  theme: themeProp,
131
131
  darkMode,
132
+ renderer,
132
133
  onDataPointClick,
133
134
  onMarkClick,
134
135
  onMarkHover,
@@ -244,6 +245,7 @@ function ChartInner({
244
245
  const options = {
245
246
  theme,
246
247
  darkMode: resolvedDarkMode,
248
+ renderer,
247
249
  onDataPointClick: stableOnDataPointClick,
248
250
  onMarkClick: stableOnMarkClick,
249
251
  onMarkHover: stableOnMarkHover,
@@ -273,6 +275,7 @@ function ChartInner({
273
275
  }, [
274
276
  theme,
275
277
  resolvedDarkMode,
278
+ renderer,
276
279
  editable,
277
280
  stableOnAnnotationClick,
278
281
  stableOnDataPointClick,
@@ -530,9 +533,9 @@ function DataTable({
530
533
  );
531
534
  }
532
535
 
533
- // src/Graph.tsx
536
+ // src/GeoMap.tsx
534
537
  import {
535
- createGraph
538
+ createGeoMap
536
539
  } from "@opendata-ai/openchart-vanilla";
537
540
  import {
538
541
  forwardRef as forwardRef3,
@@ -542,6 +545,83 @@ import {
542
545
  useRef as useRef5
543
546
  } from "react";
544
547
  import { jsx as jsx6 } from "react/jsx-runtime";
548
+ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, onMarkClick, onMarkHover, className, style }, ref) {
549
+ const contextTheme = useVizTheme();
550
+ const contextDarkMode = useVizDarkMode();
551
+ const theme = themeProp ?? contextTheme;
552
+ const resolvedDarkMode = darkMode ?? contextDarkMode;
553
+ const containerRef = useRef5(null);
554
+ const instanceRef = useRef5(null);
555
+ const specRef = useRef5("");
556
+ const handlersRef = useRef5({});
557
+ handlersRef.current = {
558
+ onMarkClick,
559
+ onMarkHover
560
+ };
561
+ const stableOnMarkClick = useCallback4(
562
+ (feature) => handlersRef.current.onMarkClick?.(feature),
563
+ []
564
+ );
565
+ const stableOnMarkHover = useCallback4(
566
+ (feature) => handlersRef.current.onMarkHover?.(feature),
567
+ []
568
+ );
569
+ useImperativeHandle4(
570
+ ref,
571
+ () => ({
572
+ get instance() {
573
+ return instanceRef.current;
574
+ }
575
+ }),
576
+ []
577
+ );
578
+ useEffect5(() => {
579
+ const container = containerRef.current;
580
+ if (!container) return;
581
+ const options = {
582
+ theme,
583
+ darkMode: resolvedDarkMode,
584
+ onMarkClick: stableOnMarkClick,
585
+ onMarkHover: stableOnMarkHover,
586
+ responsive: true
587
+ };
588
+ instanceRef.current = createGeoMap(container, spec, options);
589
+ specRef.current = JSON.stringify(spec);
590
+ return () => {
591
+ instanceRef.current?.destroy();
592
+ instanceRef.current = null;
593
+ };
594
+ }, [theme, resolvedDarkMode, stableOnMarkClick, stableOnMarkHover]);
595
+ useEffect5(() => {
596
+ const instance = instanceRef.current;
597
+ if (!instance) return;
598
+ const specString = JSON.stringify(spec);
599
+ if (specString === specRef.current) return;
600
+ specRef.current = specString;
601
+ instance.update(spec);
602
+ }, [spec]);
603
+ return /* @__PURE__ */ jsx6(
604
+ "div",
605
+ {
606
+ ref: containerRef,
607
+ className: className ? `oc-map-root ${className}` : "oc-map-root",
608
+ style
609
+ }
610
+ );
611
+ });
612
+
613
+ // src/Graph.tsx
614
+ import {
615
+ createGraph
616
+ } from "@opendata-ai/openchart-vanilla";
617
+ import {
618
+ forwardRef as forwardRef4,
619
+ useCallback as useCallback5,
620
+ useEffect as useEffect6,
621
+ useImperativeHandle as useImperativeHandle5,
622
+ useRef as useRef6
623
+ } from "react";
624
+ import { jsx as jsx7 } from "react/jsx-runtime";
545
625
  function tooltipStructural(tooltip) {
546
626
  if (tooltip === false) return false;
547
627
  return true;
@@ -551,7 +631,7 @@ function legendStructural(legend) {
551
631
  if (legend === true || legend === void 0) return "true";
552
632
  return JSON.stringify({ interactive: legend.interactive, counts: legend.counts });
553
633
  }
554
- var Graph = forwardRef3(function Graph2({
634
+ var Graph = forwardRef4(function Graph2({
555
635
  spec,
556
636
  theme: themeProp,
557
637
  darkMode,
@@ -574,11 +654,11 @@ var Graph = forwardRef3(function Graph2({
574
654
  const contextDarkMode = useVizDarkMode();
575
655
  const theme = themeProp ?? contextTheme;
576
656
  const resolvedDarkMode = darkMode ?? contextDarkMode;
577
- const containerRef = useRef5(null);
578
- const graphRef = useRef5(null);
579
- const specRef = useRef5("");
580
- const prevMountDepsRef = useRef5(null);
581
- const handlersRef = useRef5({});
657
+ const containerRef = useRef6(null);
658
+ const graphRef = useRef6(null);
659
+ const specRef = useRef6("");
660
+ const prevMountDepsRef = useRef6(null);
661
+ const handlersRef = useRef6({});
582
662
  handlersRef.current = {
583
663
  onNodeClick,
584
664
  onNodeDoubleClick,
@@ -591,47 +671,47 @@ var Graph = forwardRef3(function Graph2({
591
671
  onCameraChange,
592
672
  tooltipFormatter: typeof tooltip === "object" ? tooltip.formatter : void 0
593
673
  };
594
- const stableOnNodeClick = useCallback4(
674
+ const stableOnNodeClick = useCallback5(
595
675
  (node) => handlersRef.current.onNodeClick?.(node),
596
676
  []
597
677
  );
598
- const stableOnNodeDoubleClick = useCallback4(
678
+ const stableOnNodeDoubleClick = useCallback5(
599
679
  (node) => handlersRef.current.onNodeDoubleClick?.(node),
600
680
  []
601
681
  );
602
- const stableOnNodeHover = useCallback4(
682
+ const stableOnNodeHover = useCallback5(
603
683
  (node) => handlersRef.current.onNodeHover?.(node),
604
684
  []
605
685
  );
606
- const stableOnEdgeHover = useCallback4(
686
+ const stableOnEdgeHover = useCallback5(
607
687
  (edge) => handlersRef.current.onEdgeHover?.(edge),
608
688
  []
609
689
  );
610
- const stableOnSelectionChange = useCallback4(
690
+ const stableOnSelectionChange = useCallback5(
611
691
  (nodeIds) => handlersRef.current.onSelectionChange?.(nodeIds),
612
692
  []
613
693
  );
614
- const stableOnLegendHover = useCallback4(
694
+ const stableOnLegendHover = useCallback5(
615
695
  (entry) => handlersRef.current.onLegendHover?.(entry),
616
696
  []
617
697
  );
618
- const stableOnLegendToggle = useCallback4(
698
+ const stableOnLegendToggle = useCallback5(
619
699
  (activeValues) => handlersRef.current.onLegendToggle?.(activeValues),
620
700
  []
621
701
  );
622
- const stableOnHighlightChange = useCallback4(
702
+ const stableOnHighlightChange = useCallback5(
623
703
  (nodeIds) => handlersRef.current.onHighlightChange?.(nodeIds),
624
704
  []
625
705
  );
626
- const stableOnCameraChange = useCallback4(
706
+ const stableOnCameraChange = useCallback5(
627
707
  (camera) => handlersRef.current.onCameraChange?.(camera),
628
708
  []
629
709
  );
630
- const stableTooltipFormatter = useCallback4(
710
+ const stableTooltipFormatter = useCallback5(
631
711
  (item, defaults) => handlersRef.current.tooltipFormatter?.(item, defaults) ?? defaults,
632
712
  []
633
713
  );
634
- useImperativeHandle4(
714
+ useImperativeHandle5(
635
715
  ref,
636
716
  () => ({
637
717
  search(query) {
@@ -693,7 +773,7 @@ var Graph = forwardRef3(function Graph2({
693
773
  );
694
774
  const tooltipOn = tooltipStructural(tooltip);
695
775
  const legendKey = legendStructural(legend);
696
- useEffect5(() => {
776
+ useEffect6(() => {
697
777
  const container = containerRef.current;
698
778
  if (!container) return;
699
779
  const tooltipOption = tooltipOn ? { formatter: stableTooltipFormatter } : false;
@@ -742,7 +822,7 @@ var Graph = forwardRef3(function Graph2({
742
822
  stableOnCameraChange,
743
823
  stableTooltipFormatter
744
824
  ]);
745
- useEffect5(() => {
825
+ useEffect6(() => {
746
826
  const graph = graphRef.current;
747
827
  if (!graph) return;
748
828
  const specString = JSON.stringify(spec);
@@ -750,7 +830,7 @@ var Graph = forwardRef3(function Graph2({
750
830
  specRef.current = specString;
751
831
  graph.update(spec);
752
832
  }, [spec]);
753
- return /* @__PURE__ */ jsx6(
833
+ return /* @__PURE__ */ jsx7(
754
834
  "div",
755
835
  {
756
836
  ref: containerRef,
@@ -762,20 +842,21 @@ var Graph = forwardRef3(function Graph2({
762
842
 
763
843
  // src/hooks.ts
764
844
  import { createChart as createChart2 } from "@opendata-ai/openchart-vanilla";
765
- import { useEffect as useEffect6, useRef as useRef6, useState } from "react";
845
+ import { useEffect as useEffect7, useRef as useRef7, useState } from "react";
766
846
  function useChart(spec, options) {
767
- const ref = useRef6(null);
768
- const chartRef = useRef6(null);
847
+ const ref = useRef7(null);
848
+ const chartRef = useRef7(null);
769
849
  const [layout, setLayout] = useState(null);
770
- const specRef = useRef6("");
771
- useEffect6(() => {
850
+ const specRef = useRef7("");
851
+ useEffect7(() => {
772
852
  const container = ref.current;
773
853
  if (!container) return;
774
854
  const mountOpts = {
775
855
  theme: options?.theme,
776
856
  darkMode: options?.darkMode,
777
857
  onDataPointClick: options?.onDataPointClick,
778
- responsive: options?.responsive
858
+ responsive: options?.responsive,
859
+ renderer: options?.renderer
779
860
  };
780
861
  const chart = createChart2(container, spec, mountOpts);
781
862
  chartRef.current = chart;
@@ -786,8 +867,14 @@ function useChart(spec, options) {
786
867
  chartRef.current = null;
787
868
  setLayout(null);
788
869
  };
789
- }, [options?.theme, options?.darkMode, options?.onDataPointClick, options?.responsive]);
790
- useEffect6(() => {
870
+ }, [
871
+ options?.theme,
872
+ options?.darkMode,
873
+ options?.onDataPointClick,
874
+ options?.responsive,
875
+ options?.renderer
876
+ ]);
877
+ useEffect7(() => {
791
878
  const chart = chartRef.current;
792
879
  if (!chart) return;
793
880
  const specString = JSON.stringify(spec);
@@ -805,7 +892,7 @@ function useChart(spec, options) {
805
892
  }
806
893
  function useDarkMode(mode) {
807
894
  const [isDark, setIsDark] = useState(() => resolveInitial(mode));
808
- useEffect6(() => {
895
+ useEffect7(() => {
809
896
  if (mode !== "auto") {
810
897
  setIsDark(mode === "force");
811
898
  return;
@@ -832,64 +919,64 @@ function resolveInitial(mode) {
832
919
  }
833
920
 
834
921
  // src/hooks/useGraph.ts
835
- import { useCallback as useCallback5, useRef as useRef7 } from "react";
922
+ import { useCallback as useCallback6, useRef as useRef8 } from "react";
836
923
  function useGraph() {
837
- const ref = useRef7(null);
838
- const search = useCallback5((query) => {
924
+ const ref = useRef8(null);
925
+ const search = useCallback6((query) => {
839
926
  ref.current?.search(query);
840
927
  }, []);
841
- const clearSearch = useCallback5(() => {
928
+ const clearSearch = useCallback6(() => {
842
929
  ref.current?.clearSearch();
843
930
  }, []);
844
- const getSearchMatches = useCallback5(() => {
931
+ const getSearchMatches = useCallback6(() => {
845
932
  return ref.current?.getSearchMatches() ?? [];
846
933
  }, []);
847
- const zoomToFit = useCallback5((opts) => {
934
+ const zoomToFit = useCallback6((opts) => {
848
935
  ref.current?.zoomToFit(opts);
849
936
  }, []);
850
- const zoomToNode = useCallback5(
937
+ const zoomToNode = useCallback6(
851
938
  (nodeId, opts) => {
852
939
  ref.current?.zoomToNode(nodeId, opts);
853
940
  },
854
941
  []
855
942
  );
856
- const flyTo = useCallback5(
943
+ const flyTo = useCallback6(
857
944
  (target, opts) => {
858
945
  ref.current?.flyTo(target, opts);
859
946
  },
860
947
  []
861
948
  );
862
- const centerAt = useCallback5((x, y, opts) => {
949
+ const centerAt = useCallback6((x, y, opts) => {
863
950
  ref.current?.centerAt(x, y, opts);
864
951
  }, []);
865
- const getCamera = useCallback5(() => {
952
+ const getCamera = useCallback6(() => {
866
953
  return ref.current?.getCamera() ?? { x: 0, y: 0, k: 1 };
867
954
  }, []);
868
- const selectNode = useCallback5(
955
+ const selectNode = useCallback6(
869
956
  (nodeId, opts) => {
870
957
  ref.current?.selectNode(nodeId, opts);
871
958
  },
872
959
  []
873
960
  );
874
- const getSelectedNodes = useCallback5(() => {
961
+ const getSelectedNodes = useCallback6(() => {
875
962
  return ref.current?.getSelectedNodes() ?? [];
876
963
  }, []);
877
- const highlight = useCallback5((target, opts) => {
964
+ const highlight = useCallback6((target, opts) => {
878
965
  ref.current?.highlight(target, opts);
879
966
  }, []);
880
- const clearHighlight = useCallback5(() => {
967
+ const clearHighlight = useCallback6(() => {
881
968
  ref.current?.clearHighlight();
882
969
  }, []);
883
- const getHighlight = useCallback5(() => {
970
+ const getHighlight = useCallback6(() => {
884
971
  return ref.current?.getHighlight() ?? null;
885
972
  }, []);
886
- const getLegend = useCallback5(() => {
973
+ const getLegend = useCallback6(() => {
887
974
  return ref.current?.getLegend() ?? null;
888
975
  }, []);
889
- const setActiveCategories = useCallback5((values) => {
976
+ const setActiveCategories = useCallback6((values) => {
890
977
  ref.current?.setActiveCategories(values);
891
978
  }, []);
892
- const getActiveCategories = useCallback5(() => {
979
+ const getActiveCategories = useCallback6(() => {
893
980
  return ref.current?.getActiveCategories() ?? [];
894
981
  }, []);
895
982
  return {
@@ -917,24 +1004,24 @@ function useGraph() {
917
1004
  import {
918
1005
  createTable as createTable2
919
1006
  } from "@opendata-ai/openchart-vanilla";
920
- import { useCallback as useCallback6, useEffect as useEffect7, useRef as useRef8, useState as useState2 } from "react";
1007
+ import { useCallback as useCallback7, useEffect as useEffect8, useRef as useRef9, useState as useState2 } from "react";
921
1008
  function useTable(spec, options) {
922
- const ref = useRef8(null);
923
- const tableRef = useRef8(null);
1009
+ const ref = useRef9(null);
1010
+ const tableRef = useRef9(null);
924
1011
  const [state, setState] = useState2({
925
1012
  sort: null,
926
1013
  search: "",
927
1014
  page: 0
928
1015
  });
929
1016
  const originalOnStateChange = options?.onStateChange;
930
- const handleStateChange = useCallback6(
1017
+ const handleStateChange = useCallback7(
931
1018
  (newState) => {
932
1019
  setState(newState);
933
1020
  originalOnStateChange?.(newState);
934
1021
  },
935
1022
  [originalOnStateChange]
936
1023
  );
937
- useEffect7(() => {
1024
+ useEffect8(() => {
938
1025
  const container = ref.current;
939
1026
  if (!container) return;
940
1027
  const mountOpts = {
@@ -957,7 +1044,7 @@ function useTable(spec, options) {
957
1044
  options,
958
1045
  spec
959
1046
  ]);
960
- useEffect7(() => {
1047
+ useEffect8(() => {
961
1048
  const table = tableRef.current;
962
1049
  if (!table) return;
963
1050
  table.update(spec);
@@ -971,21 +1058,21 @@ function useTable(spec, options) {
971
1058
  }
972
1059
 
973
1060
  // src/hooks/useTableState.ts
974
- import { useCallback as useCallback7, useState as useState3 } from "react";
1061
+ import { useCallback as useCallback8, useState as useState3 } from "react";
975
1062
  function useTableState(initialState) {
976
1063
  const [sort, setSortInternal] = useState3(initialState?.sort ?? null);
977
1064
  const [search, setSearchInternal] = useState3(initialState?.search ?? "");
978
1065
  const [page, setPageInternal] = useState3(initialState?.page ?? 0);
979
- const setSort = useCallback7((newSort) => {
1066
+ const setSort = useCallback8((newSort) => {
980
1067
  setSortInternal(newSort);
981
1068
  }, []);
982
- const setSearch = useCallback7((query) => {
1069
+ const setSearch = useCallback8((query) => {
983
1070
  setSearchInternal(query);
984
1071
  }, []);
985
- const setPage = useCallback7((newPage) => {
1072
+ const setPage = useCallback8((newPage) => {
986
1073
  setPageInternal(newPage);
987
1074
  }, []);
988
- const resetState = useCallback7(() => {
1075
+ const resetState = useCallback8(() => {
989
1076
  setSortInternal(initialState?.sort ?? null);
990
1077
  setSearchInternal(initialState?.search ?? "");
991
1078
  setPageInternal(initialState?.page ?? 0);
@@ -1001,83 +1088,6 @@ function useTableState(initialState) {
1001
1088
  };
1002
1089
  }
1003
1090
 
1004
- // src/Map.tsx
1005
- import {
1006
- createMap
1007
- } from "@opendata-ai/openchart-vanilla";
1008
- import {
1009
- forwardRef as forwardRef4,
1010
- useCallback as useCallback8,
1011
- useEffect as useEffect8,
1012
- useImperativeHandle as useImperativeHandle5,
1013
- useRef as useRef9
1014
- } from "react";
1015
- import { jsx as jsx7 } from "react/jsx-runtime";
1016
- var GeoMap = forwardRef4(function GeoMap2({ spec, theme: themeProp, darkMode, onMarkClick, onMarkHover, className, style }, ref) {
1017
- const contextTheme = useVizTheme();
1018
- const contextDarkMode = useVizDarkMode();
1019
- const theme = themeProp ?? contextTheme;
1020
- const resolvedDarkMode = darkMode ?? contextDarkMode;
1021
- const containerRef = useRef9(null);
1022
- const instanceRef = useRef9(null);
1023
- const specRef = useRef9("");
1024
- const handlersRef = useRef9({});
1025
- handlersRef.current = {
1026
- onMarkClick,
1027
- onMarkHover
1028
- };
1029
- const stableOnMarkClick = useCallback8(
1030
- (feature) => handlersRef.current.onMarkClick?.(feature),
1031
- []
1032
- );
1033
- const stableOnMarkHover = useCallback8(
1034
- (feature) => handlersRef.current.onMarkHover?.(feature),
1035
- []
1036
- );
1037
- useImperativeHandle5(
1038
- ref,
1039
- () => ({
1040
- get instance() {
1041
- return instanceRef.current;
1042
- }
1043
- }),
1044
- []
1045
- );
1046
- useEffect8(() => {
1047
- const container = containerRef.current;
1048
- if (!container) return;
1049
- const options = {
1050
- theme,
1051
- darkMode: resolvedDarkMode,
1052
- onMarkClick: stableOnMarkClick,
1053
- onMarkHover: stableOnMarkHover,
1054
- responsive: true
1055
- };
1056
- instanceRef.current = createMap(container, spec, options);
1057
- specRef.current = JSON.stringify(spec);
1058
- return () => {
1059
- instanceRef.current?.destroy();
1060
- instanceRef.current = null;
1061
- };
1062
- }, [theme, resolvedDarkMode, stableOnMarkClick, stableOnMarkHover]);
1063
- useEffect8(() => {
1064
- const instance = instanceRef.current;
1065
- if (!instance) return;
1066
- const specString = JSON.stringify(spec);
1067
- if (specString === specRef.current) return;
1068
- specRef.current = specString;
1069
- instance.update(spec);
1070
- }, [spec]);
1071
- return /* @__PURE__ */ jsx7(
1072
- "div",
1073
- {
1074
- ref: containerRef,
1075
- className: className ? `oc-map-root ${className}` : "oc-map-root",
1076
- style
1077
- }
1078
- );
1079
- });
1080
-
1081
1091
  // src/Sankey.tsx
1082
1092
  import {
1083
1093
  createSankey
@@ -1264,8 +1274,8 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
1264
1274
  // src/Visualization.tsx
1265
1275
  import {
1266
1276
  isBarListSpec,
1277
+ isGeoMapSpec,
1267
1278
  isGraphSpec,
1268
- isMapSpec,
1269
1279
  isSankeySpec,
1270
1280
  isTableSpec,
1271
1281
  isTileMapSpec
@@ -1296,7 +1306,7 @@ function Visualization({ spec, theme, darkMode, className, style }) {
1296
1306
  if (isBarListSpec(spec)) {
1297
1307
  return /* @__PURE__ */ jsx10(BarList, { spec, theme, darkMode, className, style });
1298
1308
  }
1299
- if (isMapSpec(spec)) {
1309
+ if (isGeoMapSpec(spec)) {
1300
1310
  return /* @__PURE__ */ jsx10(GeoMap, { spec, theme, darkMode, className, style });
1301
1311
  }
1302
1312
  return /* @__PURE__ */ jsx10(Chart, { spec, theme, darkMode, className, style });
@@ -1316,8 +1326,8 @@ export {
1316
1326
  compile,
1317
1327
  compileBarList,
1318
1328
  compileChart,
1329
+ compileGeoMap,
1319
1330
  compileGraph,
1320
- compileMap,
1321
1331
  compileSankey,
1322
1332
  compileTable,
1323
1333
  compileTileMap,