@opendata-ai/openchart-react 8.9.0 → 9.0.0-rc.1

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/README.md CHANGED
@@ -139,7 +139,7 @@ function Dashboard({ specs }) {
139
139
 
140
140
  `darkMode` accepts `"auto"` (follows system preference), `"force"` (always dark), or `"off"` (always light).
141
141
 
142
- For one-off overrides, pass `darkMode` or `theme` directly on an individual component. Component-level props take priority over the provider.
142
+ For one-off overrides, pass `darkMode` or `theme` directly on an individual component. Component-level props take priority over the provider: a component `theme` deep-merges over the provider theme (which itself merges over the spec `theme`), and a component dark mode replaces the provider's.
143
143
 
144
144
  ```tsx
145
145
  <VizThemeProvider theme={defaultTheme} darkMode="auto">
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { BarListSpec, ThemeConfig, DarkMode, DataRow, ChartEventHandlers, ChartSpec, LayerSpec, GraphSpec, ElementRef, GeoMapSpec, TableSpec, SortState, ChartLayout, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
1
+ import { BarListSpec, ThemeConfig, DarkMode, DataRow, ChartEventHandlers, ChartSpec, LayerSpec, ElementRef, GeoMapSpec, TableSpec, SortState, GeoReaderSelection, ReaderChangeMeta, GraphSpec, ChartLayout, SankeySpec, TileMapSpec, VizSpec } from '@opendata-ai/openchart-core';
2
2
  export * from '@opendata-ai/openchart-core';
3
- import { BarListInstance, ChartInstance, MountOptions, GeoMapMarkEvent, Camera, GeoMapInstance, CameraFlightOptions, GraphFlyTarget, GraphCamera, GraphHighlightTarget, GraphLegendData, GraphInstance, GraphTooltipFormatter, TableInstance, TableState, TableMountOptions, SankeyInstance, TileMapInstance } from '@opendata-ai/openchart-vanilla';
4
- export { JPGExportOptions, PNGExportOptions, SVGExportOptions, SpecSequenceOptions, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, exportSpecSequence } from '@opendata-ai/openchart-vanilla';
3
+ import { BarListInstance, InteractionMode, ChartReaderProps, ChartInstance, MountOptions, GeoReaderOptions, GeoMapMountOptions, GeoMapMarkEvent, Camera, GeoMapCameraChangeMeta, GeoMapInstance, CameraFlightOptions, GraphFlyTarget, GraphCamera, GraphHighlightTarget, GraphLegendData, GraphInstance, GraphTooltipFormatter, TableInstance, TableState, TableMountOptions, SankeyInstance, TileMapInstance } from '@opendata-ai/openchart-vanilla';
4
+ export { GeoMapCameraChangeMeta, InteractionMode, JPGExportOptions, PNGExportOptions, SVGExportOptions, SpecSequenceOptions, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, exportSpecSequence } from '@opendata-ai/openchart-vanilla';
5
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';
@@ -48,9 +48,15 @@ interface ChartHandle {
48
48
  /** The underlying chart instance (null until mounted). */
49
49
  readonly instance: ChartInstance | null;
50
50
  }
51
- interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers {
52
- /** The visualization spec to render. */
53
- spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec;
51
+ interface ChartBaseProps<TData extends DataRow = DataRow> extends ChartEventHandlers {
52
+ /** The chart spec to render. Graph specs render through `<Graph />` or `<Visualization />`. */
53
+ spec: ChartSpec<TData> | LayerSpec<TData>;
54
+ /**
55
+ * Interaction mode: `'read'`, `'select'`, or `'edit'`. When omitted it is
56
+ * inferred from the callbacks (`onEdit` -> edit, `onSelect`/`onDeselect` ->
57
+ * select, otherwise read). Changing it recreates the chart.
58
+ */
59
+ interaction?: InteractionMode;
54
60
  /** Theme overrides. */
55
61
  theme?: ThemeConfig;
56
62
  /** Dark mode: "auto", "force", or "off". */
@@ -60,8 +66,10 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
60
66
  * option). `'auto'` (default) promotes dense scatters to canvas.
61
67
  */
62
68
  renderer?: 'auto' | 'svg' | 'canvas';
63
- /** Callback when a data point is clicked. @deprecated Use onMarkClick instead. */
64
- onDataPointClick?: (data: Record<string, unknown>) => void;
69
+ /** Quiet row inspection for simple horizontal bars. */
70
+ rowHover?: boolean;
71
+ /** Observe container resizes. */
72
+ autoResize?: boolean;
65
73
  /** The currently selected element (controlled). */
66
74
  selectedElement?: ElementRef;
67
75
  /** Highlight specific color-encoding values. Pass null to clear. */
@@ -71,6 +79,17 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
71
79
  /** Inline styles for the wrapper div. */
72
80
  style?: CSSProperties;
73
81
  }
82
+ type ChartProps<TData extends DataRow = DataRow> = ChartBaseProps<TData> & ChartReaderProps;
83
+ type SliceChartProps<TData extends DataRow = DataRow> = ChartBaseProps<TData> & Extract<ChartReaderProps, {
84
+ reader: {
85
+ mode: 'slices';
86
+ };
87
+ }>;
88
+ type ObservationChartProps<TData extends DataRow = DataRow> = ChartBaseProps<TData> & Exclude<ChartReaderProps, {
89
+ reader: {
90
+ mode: 'slices';
91
+ };
92
+ }>;
74
93
  /**
75
94
  * Generic Chart component with field autocomplete support.
76
95
  *
@@ -82,9 +101,14 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
82
101
  *
83
102
  * Without a type parameter, behaves identically to before — no migration needed.
84
103
  */
85
- declare const Chart: <TData extends DataRow = DataRow>(props: ChartProps<TData> & {
86
- ref?: React.Ref<ChartHandle>;
87
- }) => React.ReactElement | null;
104
+ declare const Chart: {
105
+ <TData extends DataRow = DataRow>(props: SliceChartProps<TData> & {
106
+ ref?: React.Ref<ChartHandle>;
107
+ }): React.ReactElement | null;
108
+ <TData extends DataRow = DataRow>(props: ObservationChartProps<TData> & {
109
+ ref?: React.Ref<ChartHandle>;
110
+ }): React.ReactElement | null;
111
+ };
88
112
 
89
113
  interface ChartStoryHandle {
90
114
  /** Jump the story to a step index (applies patches 0..n, animates the diff). */
@@ -94,7 +118,7 @@ interface ChartStoryHandle {
94
118
  }
95
119
  interface ChartStoryProps<TData extends DataRow = DataRow> {
96
120
  /** Base spec the story drives. */
97
- spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec | GeoMapSpec;
121
+ spec: ChartSpec<TData> | LayerSpec<TData> | GeoMapSpec;
98
122
  /** Ordered step patches. `steps[i]` is applied cumulatively onto the base. */
99
123
  steps: ChartStoryOptions<TData>['steps'];
100
124
  /**
@@ -158,6 +182,10 @@ interface DataTableProps {
158
182
  declare function DataTable({ spec, theme: themeProp, darkMode, onRowClick, onSortChange, onSearchChange, onPageChange, className, style, sort, search, page, }: DataTableProps): react_jsx_runtime.JSX.Element;
159
183
 
160
184
  interface GeoMapProps {
185
+ reader?: false | GeoReaderOptions;
186
+ readerSelection?: GeoReaderSelection;
187
+ onReaderChange?: (selection: GeoReaderSelection, meta: ReaderChangeMeta) => void;
188
+ labelInventory?: GeoMapMountOptions['labelInventory'];
161
189
  /** The map spec to render. */
162
190
  spec: GeoMapSpec;
163
191
  /** Theme overrides. */
@@ -169,7 +197,7 @@ interface GeoMapProps {
169
197
  /** Callback when a map feature is hovered (null when hover ends). */
170
198
  onMarkHover?: (feature: GeoMapMarkEvent | null) => void;
171
199
  /** Called whenever the camera moves (reader zoom/pan, zoomTo, focus). */
172
- onCameraChange?: (camera: Camera) => void;
200
+ onCameraChange?: (camera: Camera, meta?: GeoMapCameraChangeMeta) => void;
173
201
  /** CSS class name for the wrapper div. */
174
202
  className?: string;
175
203
  /** Inline styles for the wrapper div. */
@@ -265,8 +293,8 @@ interface GraphHandle {
265
293
  getLegend: () => GraphLegendData | null;
266
294
  setActiveCategories: (values: string[]) => void;
267
295
  getActiveCategories: () => string[];
268
- /** Re-compile encoding/legend/chrome without restarting the simulation. */
269
- updateVisuals: (spec: GraphSpec) => void;
296
+ /** Update graph data, encoding, or presentation through the unified update path. */
297
+ update: (spec: GraphSpec) => void;
270
298
  /** The underlying GraphInstance from the vanilla adapter. */
271
299
  instance: GraphInstance | null;
272
300
  }
@@ -364,10 +392,8 @@ interface UseChartOptions {
364
392
  theme?: MountOptions['theme'];
365
393
  /** Dark mode setting. */
366
394
  darkMode?: MountOptions['darkMode'];
367
- /** Data point click handler. */
368
- onDataPointClick?: MountOptions['onDataPointClick'];
369
- /** Enable responsive resizing. Defaults to true. */
370
- responsive?: boolean;
395
+ /** Observe container resizes. Defaults to true. */
396
+ autoResize?: boolean;
371
397
  /** Rendering backend for point marks; see the vanilla `MountOptions.renderer`. */
372
398
  renderer?: MountOptions['renderer'];
373
399
  }
@@ -389,7 +415,7 @@ interface UseChartReturn {
389
415
  * @param options - Mount options.
390
416
  * @returns { ref, chart, layout }
391
417
  */
392
- declare function useChart(spec: ChartSpec | LayerSpec | GraphSpec, options?: UseChartOptions): UseChartReturn;
418
+ declare function useChart(spec: ChartSpec | LayerSpec, options?: UseChartOptions): UseChartReturn;
393
419
  /**
394
420
  * Resolve a DarkMode preference to a boolean.
395
421
  *
@@ -575,4 +601,4 @@ interface VisualizationProps {
575
601
  */
576
602
  declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps): react_jsx_runtime.JSX.Element;
577
603
 
578
- 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 };
604
+ 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, type ObservationChartProps, Sankey, type SankeyHandle, type SankeyProps, type SliceChartProps, 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
@@ -25,6 +25,7 @@ import {
25
25
  } from "@opendata-ai/openchart-engine";
26
26
 
27
27
  // src/BarList.tsx
28
+ import { mergeThemeConfig } from "@opendata-ai/openchart-core";
28
29
  import {
29
30
  createBarList
30
31
  } from "@opendata-ai/openchart-vanilla";
@@ -33,6 +34,7 @@ import {
33
34
  useCallback,
34
35
  useEffect,
35
36
  useImperativeHandle,
37
+ useMemo,
36
38
  useRef
37
39
  } from "react";
38
40
 
@@ -56,7 +58,7 @@ import { jsx as jsx2 } from "react/jsx-runtime";
56
58
  var BarList = forwardRef(function BarList2({ spec, theme: themeProp, darkMode, onRowClick, onRowHover, className, style }, ref) {
57
59
  const contextTheme = useVizTheme();
58
60
  const contextDarkMode = useVizDarkMode();
59
- const theme = themeProp ?? contextTheme;
61
+ const theme = useMemo(() => mergeThemeConfig(contextTheme, themeProp), [contextTheme, themeProp]);
60
62
  const resolvedDarkMode = darkMode ?? contextDarkMode;
61
63
  const containerRef = useRef(null);
62
64
  const instanceRef = useRef(null);
@@ -88,7 +90,7 @@ var BarList = forwardRef(function BarList2({ spec, theme: themeProp, darkMode, o
88
90
  darkMode: resolvedDarkMode,
89
91
  onRowClick: stableOnRowClick,
90
92
  onRowHover: stableOnRowHover,
91
- responsive: true
93
+ autoResize: true
92
94
  };
93
95
  instanceRef.current = createBarList(container, spec, options);
94
96
  specRef.current = JSON.stringify(spec);
@@ -116,66 +118,88 @@ var BarList = forwardRef(function BarList2({ spec, theme: themeProp, darkMode, o
116
118
  });
117
119
 
118
120
  // src/Chart.tsx
119
- import { createChart } from "@opendata-ai/openchart-vanilla";
121
+ import { mergeThemeConfig as mergeThemeConfig2 } from "@opendata-ai/openchart-core";
122
+ import {
123
+ createChart,
124
+ createChartReaderBinding
125
+ } from "@opendata-ai/openchart-vanilla";
120
126
  import {
121
127
  forwardRef as forwardRef2,
122
128
  useCallback as useCallback2,
123
129
  useEffect as useEffect2,
124
130
  useImperativeHandle as useImperativeHandle2,
131
+ useMemo as useMemo2,
125
132
  useRef as useRef2
126
133
  } from "react";
127
134
  import { jsx as jsx3 } from "react/jsx-runtime";
128
135
  function ChartInner({
129
136
  spec,
137
+ reader,
138
+ readerSelection,
139
+ onReaderChange,
130
140
  theme: themeProp,
131
141
  darkMode,
132
142
  renderer,
133
- onDataPointClick,
143
+ rowHover,
144
+ autoResize,
145
+ revision,
146
+ onEdit,
134
147
  onMarkClick,
135
148
  onMarkHover,
136
149
  onMarkLeave,
137
150
  onLegendToggle,
138
151
  onHighlightChange,
139
152
  onAnnotationClick,
140
- onAnnotationEdit,
141
- onEdit,
142
153
  onSelect,
143
154
  onDeselect,
144
- onTextEdit,
145
155
  onReveal,
146
- editable,
156
+ interaction,
147
157
  selectedElement: selectedElementProp,
148
158
  highlight,
149
159
  className,
150
160
  style
151
161
  }, ref) {
162
+ const hasEditListener = Boolean(onEdit);
163
+ const hasSelectListener = Boolean(onSelect);
164
+ const hasDeselectListener = Boolean(onDeselect);
152
165
  const contextTheme = useVizTheme();
153
166
  const contextDarkMode = useVizDarkMode();
154
- const theme = themeProp ?? contextTheme;
167
+ const theme = useMemo2(() => mergeThemeConfig2(contextTheme, themeProp), [contextTheme, themeProp]);
155
168
  const resolvedDarkMode = darkMode ?? contextDarkMode;
156
169
  const containerRef = useRef2(null);
157
170
  const chartRef = useRef2(null);
158
171
  const specRef = useRef2("");
172
+ const readerBinding = useRef2(null);
173
+ readerBinding.current ??= createChartReaderBinding();
174
+ const readerConfig = useRef2({ reader, readerSelection, onReaderChange });
175
+ readerConfig.current = { reader, readerSelection, onReaderChange };
176
+ const syncReader = () => {
177
+ if (containerRef.current && chartRef.current) {
178
+ const config = readerConfig.current;
179
+ readerBinding.current.sync(
180
+ containerRef.current,
181
+ chartRef.current,
182
+ spec,
183
+ config.reader,
184
+ config.readerSelection,
185
+ config.onReaderChange
186
+ );
187
+ }
188
+ };
189
+ const revisionRef = useRef2(revision);
159
190
  const handlersRef = useRef2({});
160
191
  handlersRef.current = {
161
- onDataPointClick,
192
+ onEdit,
162
193
  onMarkClick,
163
194
  onMarkHover,
164
195
  onMarkLeave,
165
196
  onLegendToggle,
166
197
  onHighlightChange,
167
198
  onAnnotationClick,
168
- onAnnotationEdit,
169
- onEdit,
170
199
  onSelect,
171
200
  onDeselect,
172
- onTextEdit,
173
201
  onReveal
174
202
  };
175
- const stableOnDataPointClick = useCallback2(
176
- (data) => handlersRef.current.onDataPointClick?.(data),
177
- []
178
- );
179
203
  const stableOnMarkClick = useCallback2(
180
204
  (event) => handlersRef.current.onMarkClick?.(event),
181
205
  []
@@ -194,15 +218,11 @@ function ChartInner({
194
218
  []
195
219
  );
196
220
  const stableOnAnnotationClick = useCallback2(
197
- (annotation, event) => handlersRef.current.onAnnotationClick?.(annotation, event),
198
- []
199
- );
200
- const stableOnAnnotationEdit = useCallback2(
201
- (annotation, updatedOffset) => handlersRef.current.onAnnotationEdit?.(annotation, updatedOffset),
221
+ (annotation, event, element) => handlersRef.current.onAnnotationClick?.(annotation, event, element),
202
222
  []
203
223
  );
204
224
  const stableOnEdit = useCallback2(
205
- (edit) => handlersRef.current.onEdit?.(edit),
225
+ (tx) => handlersRef.current.onEdit?.(tx),
206
226
  []
207
227
  );
208
228
  const stableOnSelect = useCallback2(
@@ -213,10 +233,6 @@ function ChartInner({
213
233
  (element) => handlersRef.current.onDeselect?.(element),
214
234
  []
215
235
  );
216
- const stableOnTextEdit = useCallback2(
217
- (element, oldText, newText) => handlersRef.current.onTextEdit?.(element, oldText, newText),
218
- []
219
- );
220
236
  const stableOnReveal = useCallback2(
221
237
  (guess) => handlersRef.current.onReveal?.(guess),
222
238
  []
@@ -246,7 +262,6 @@ function ChartInner({
246
262
  theme,
247
263
  darkMode: resolvedDarkMode,
248
264
  renderer,
249
- onDataPointClick: stableOnDataPointClick,
250
265
  onMarkClick: stableOnMarkClick,
251
266
  onMarkHover: stableOnMarkHover,
252
267
  onMarkLeave: stableOnMarkLeave,
@@ -256,19 +271,21 @@ function ChartInner({
256
271
  // Only include editing callbacks when the consumer provides them.
257
272
  // The stable wrappers are always truthy, so gating on handlersRef
258
273
  // avoids adding unstable prop references to the effect deps.
259
- ...handlersRef.current.onAnnotationEdit ? { onAnnotationEdit: stableOnAnnotationEdit } : {},
260
- ...handlersRef.current.onEdit ? { onEdit: stableOnEdit } : {},
261
274
  ...handlersRef.current.onSelect ? { onSelect: stableOnSelect } : {},
262
275
  ...handlersRef.current.onDeselect ? { onDeselect: stableOnDeselect } : {},
263
- ...handlersRef.current.onTextEdit ? { onTextEdit: stableOnTextEdit } : {},
264
276
  ...handlersRef.current.onReveal ? { onReveal: stableOnReveal } : {},
265
- ...editable != null ? { editable } : {},
277
+ ...interaction != null ? { interaction } : {},
266
278
  ...selectedElementProp ? { selectedElement: selectedElementProp } : {},
267
- responsive: true
279
+ rowHover,
280
+ autoResize,
281
+ revision,
282
+ ...handlersRef.current.onEdit ? { onEdit: stableOnEdit } : {}
268
283
  };
269
284
  chartRef.current = createChart(container, spec, options);
270
285
  specRef.current = JSON.stringify(spec);
286
+ syncReader();
271
287
  return () => {
288
+ readerBinding.current?.detach();
272
289
  chartRef.current?.destroy();
273
290
  chartRef.current = null;
274
291
  };
@@ -276,30 +293,39 @@ function ChartInner({
276
293
  theme,
277
294
  resolvedDarkMode,
278
295
  renderer,
279
- editable,
296
+ interaction,
280
297
  stableOnAnnotationClick,
281
- stableOnDataPointClick,
282
298
  stableOnEdit,
299
+ hasEditListener,
300
+ hasSelectListener,
301
+ hasDeselectListener,
302
+ rowHover,
303
+ autoResize,
283
304
  stableOnLegendToggle,
284
305
  stableOnHighlightChange,
285
306
  stableOnMarkClick,
286
307
  stableOnMarkHover,
287
308
  stableOnMarkLeave,
288
- stableOnAnnotationEdit,
289
309
  stableOnSelect,
290
310
  stableOnDeselect,
291
- stableOnTextEdit,
292
311
  stableOnReveal
293
312
  ]);
313
+ useEffect2(() => {
314
+ syncReader();
315
+ }, [reader, readerSelection, onReaderChange]);
294
316
  useEffect2(() => {
295
317
  const chart = chartRef.current;
296
318
  if (!chart) return;
297
319
  const specString = JSON.stringify(spec);
298
- if (specString !== specRef.current) {
320
+ if (specString !== specRef.current || revisionRef.current !== revision) {
299
321
  specRef.current = specString;
300
- chart.update(spec);
322
+ const revisionChanged = revisionRef.current !== revision;
323
+ revisionRef.current = revision;
324
+ if (revision !== void 0 || revisionChanged) chart.update(spec, { revision });
325
+ else chart.update(spec);
326
+ syncReader();
301
327
  }
302
- }, [spec]);
328
+ }, [spec, revision]);
303
329
  useEffect2(() => {
304
330
  const chart = chartRef.current;
305
331
  if (!chart || !chart.select) return;
@@ -440,10 +466,11 @@ function ChartStory({
440
466
  }
441
467
 
442
468
  // src/DataTable.tsx
469
+ import { mergeThemeConfig as mergeThemeConfig3 } from "@opendata-ai/openchart-core";
443
470
  import {
444
471
  createTable
445
472
  } from "@opendata-ai/openchart-vanilla";
446
- import { useCallback as useCallback3, useEffect as useEffect4, useRef as useRef4 } from "react";
473
+ import { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef4 } from "react";
447
474
  import { jsx as jsx5 } from "react/jsx-runtime";
448
475
  function DataTable({
449
476
  spec,
@@ -461,7 +488,7 @@ function DataTable({
461
488
  }) {
462
489
  const contextTheme = useVizTheme();
463
490
  const contextDarkMode = useVizDarkMode();
464
- const theme = themeProp ?? contextTheme;
491
+ const theme = useMemo3(() => mergeThemeConfig3(contextTheme, themeProp), [contextTheme, themeProp]);
465
492
  const resolvedDarkMode = darkMode ?? contextDarkMode;
466
493
  const containerRef = useRef4(null);
467
494
  const tableRef = useRef4(null);
@@ -488,7 +515,7 @@ function DataTable({
488
515
  theme,
489
516
  darkMode: resolvedDarkMode,
490
517
  onRowClick: stableOnRowClick,
491
- responsive: true,
518
+ autoResize: true,
492
519
  onStateChange: stableOnStateChange
493
520
  };
494
521
  if (isControlled) {
@@ -534,25 +561,58 @@ function DataTable({
534
561
  }
535
562
 
536
563
  // src/GeoMap.tsx
564
+ import { mergeThemeConfig as mergeThemeConfig4 } from "@opendata-ai/openchart-core";
537
565
  import {
538
- createGeoMap
566
+ createGeoMap,
567
+ createGeoReaderBinding
539
568
  } from "@opendata-ai/openchart-vanilla";
540
569
  import {
541
570
  forwardRef as forwardRef3,
542
571
  useCallback as useCallback4,
543
572
  useEffect as useEffect5,
544
573
  useImperativeHandle as useImperativeHandle4,
574
+ useMemo as useMemo4,
545
575
  useRef as useRef5
546
576
  } from "react";
547
577
  import { jsx as jsx6 } from "react/jsx-runtime";
548
- var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, onMarkClick, onMarkHover, onCameraChange, className, style }, ref) {
578
+ var GeoMap = forwardRef3(function GeoMap2({
579
+ spec,
580
+ reader,
581
+ readerSelection,
582
+ onReaderChange,
583
+ theme: themeProp,
584
+ darkMode,
585
+ labelInventory,
586
+ onMarkClick,
587
+ onMarkHover,
588
+ onCameraChange,
589
+ className,
590
+ style
591
+ }, ref) {
549
592
  const contextTheme = useVizTheme();
550
593
  const contextDarkMode = useVizDarkMode();
551
- const theme = themeProp ?? contextTheme;
594
+ const theme = useMemo4(() => mergeThemeConfig4(contextTheme, themeProp), [contextTheme, themeProp]);
552
595
  const resolvedDarkMode = darkMode ?? contextDarkMode;
553
596
  const containerRef = useRef5(null);
554
597
  const instanceRef = useRef5(null);
555
598
  const specRef = useRef5("");
599
+ const readerBinding = useRef5(null);
600
+ readerBinding.current ??= createGeoReaderBinding();
601
+ const readerConfig = useRef5({ reader, readerSelection, onReaderChange });
602
+ readerConfig.current = { reader, readerSelection, onReaderChange };
603
+ const syncReader = () => {
604
+ if (containerRef.current && instanceRef.current) {
605
+ const config = readerConfig.current;
606
+ readerBinding.current.sync(
607
+ containerRef.current,
608
+ instanceRef.current,
609
+ spec,
610
+ config.reader,
611
+ config.readerSelection,
612
+ config.onReaderChange
613
+ );
614
+ }
615
+ };
556
616
  const handlersRef = useRef5({});
557
617
  handlersRef.current = {
558
618
  onMarkClick,
@@ -568,7 +628,7 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
568
628
  []
569
629
  );
570
630
  const stableOnCameraChange = useCallback4(
571
- (camera) => handlersRef.current.onCameraChange?.(camera),
631
+ (camera, meta) => meta ? handlersRef.current.onCameraChange?.(camera, meta) : handlersRef.current.onCameraChange?.(camera),
572
632
  []
573
633
  );
574
634
  useImperativeHandle4(
@@ -589,11 +649,13 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
589
649
  onMarkClick: stableOnMarkClick,
590
650
  onMarkHover: stableOnMarkHover,
591
651
  onCameraChange: stableOnCameraChange,
592
- responsive: true
652
+ autoResize: true
593
653
  };
594
654
  instanceRef.current = createGeoMap(container, spec, options);
595
655
  specRef.current = JSON.stringify(spec);
656
+ syncReader();
596
657
  return () => {
658
+ readerBinding.current?.detach();
597
659
  instanceRef.current?.destroy();
598
660
  instanceRef.current = null;
599
661
  };
@@ -605,7 +667,14 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
605
667
  if (specString === specRef.current) return;
606
668
  specRef.current = specString;
607
669
  instance.update(spec);
670
+ syncReader();
608
671
  }, [spec]);
672
+ useEffect5(() => {
673
+ instanceRef.current?.setLabelInventory(labelInventory);
674
+ }, [labelInventory, theme, resolvedDarkMode]);
675
+ useEffect5(() => {
676
+ syncReader();
677
+ }, [reader, readerSelection, onReaderChange]);
609
678
  return /* @__PURE__ */ jsx6(
610
679
  "div",
611
680
  {
@@ -617,6 +686,7 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
617
686
  });
618
687
 
619
688
  // src/Graph.tsx
689
+ import { mergeThemeConfig as mergeThemeConfig5 } from "@opendata-ai/openchart-core";
620
690
  import {
621
691
  createGraph
622
692
  } from "@opendata-ai/openchart-vanilla";
@@ -625,6 +695,7 @@ import {
625
695
  useCallback as useCallback5,
626
696
  useEffect as useEffect6,
627
697
  useImperativeHandle as useImperativeHandle5,
698
+ useMemo as useMemo5,
628
699
  useRef as useRef6
629
700
  } from "react";
630
701
  import { jsx as jsx7 } from "react/jsx-runtime";
@@ -659,7 +730,7 @@ var Graph = forwardRef4(function Graph2({
659
730
  }, ref) {
660
731
  const contextTheme = useVizTheme();
661
732
  const contextDarkMode = useVizDarkMode();
662
- const theme = themeProp ?? contextTheme;
733
+ const theme = useMemo5(() => mergeThemeConfig5(contextTheme, themeProp), [contextTheme, themeProp]);
663
734
  const resolvedDarkMode = darkMode ?? contextDarkMode;
664
735
  const containerRef = useRef6(null);
665
736
  const graphRef = useRef6(null);
@@ -769,8 +840,8 @@ var Graph = forwardRef4(function Graph2({
769
840
  getActiveCategories() {
770
841
  return graphRef.current?.getActiveCategories() ?? [];
771
842
  },
772
- updateVisuals(spec2) {
773
- graphRef.current?.updateVisuals(spec2);
843
+ update(spec2) {
844
+ graphRef.current?.update(spec2);
774
845
  },
775
846
  get instance() {
776
847
  return graphRef.current;
@@ -805,7 +876,7 @@ var Graph = forwardRef4(function Graph2({
805
876
  onLegendToggle: stableOnLegendToggle,
806
877
  onHighlightChange: stableOnHighlightChange,
807
878
  onCameraChange: stableOnCameraChange,
808
- responsive: true,
879
+ autoResize: true,
809
880
  suppressEntrance
810
881
  };
811
882
  graphRef.current = createGraph(container, spec, options);
@@ -865,8 +936,7 @@ function useChart(spec, options) {
865
936
  const mountOpts = {
866
937
  theme: options?.theme,
867
938
  darkMode: options?.darkMode,
868
- onDataPointClick: options?.onDataPointClick,
869
- responsive: options?.responsive,
939
+ autoResize: options?.autoResize,
870
940
  renderer: options?.renderer
871
941
  };
872
942
  const chart = createChart2(container, spec, mountOpts);
@@ -878,13 +948,7 @@ function useChart(spec, options) {
878
948
  chartRef.current = null;
879
949
  setLayout(null);
880
950
  };
881
- }, [
882
- options?.theme,
883
- options?.darkMode,
884
- options?.onDataPointClick,
885
- options?.responsive,
886
- options?.renderer
887
- ]);
951
+ }, [options?.theme, options?.darkMode, options?.autoResize, options?.renderer]);
888
952
  useEffect7(() => {
889
953
  const chart = chartRef.current;
890
954
  if (!chart) return;
@@ -1047,7 +1111,7 @@ function useTable(spec, options) {
1047
1111
  options?.theme,
1048
1112
  options?.darkMode,
1049
1113
  options?.onRowClick,
1050
- options?.responsive,
1114
+ options?.autoResize,
1051
1115
  handleStateChange,
1052
1116
  options,
1053
1117
  spec
@@ -1097,6 +1161,7 @@ function useTableState(initialState) {
1097
1161
  }
1098
1162
 
1099
1163
  // src/Sankey.tsx
1164
+ import { mergeThemeConfig as mergeThemeConfig6 } from "@opendata-ai/openchart-core";
1100
1165
  import {
1101
1166
  createSankey
1102
1167
  } from "@opendata-ai/openchart-vanilla";
@@ -1105,6 +1170,7 @@ import {
1105
1170
  useCallback as useCallback9,
1106
1171
  useEffect as useEffect9,
1107
1172
  useImperativeHandle as useImperativeHandle6,
1173
+ useMemo as useMemo6,
1108
1174
  useRef as useRef10
1109
1175
  } from "react";
1110
1176
  import { jsx as jsx8 } from "react/jsx-runtime";
@@ -1121,7 +1187,7 @@ var Sankey = forwardRef5(function Sankey2({
1121
1187
  }, ref) {
1122
1188
  const contextTheme = useVizTheme();
1123
1189
  const contextDarkMode = useVizDarkMode();
1124
- const theme = themeProp ?? contextTheme;
1190
+ const theme = useMemo6(() => mergeThemeConfig6(contextTheme, themeProp), [contextTheme, themeProp]);
1125
1191
  const resolvedDarkMode = darkMode ?? contextDarkMode;
1126
1192
  const containerRef = useRef10(null);
1127
1193
  const instanceRef = useRef10(null);
@@ -1168,7 +1234,7 @@ var Sankey = forwardRef5(function Sankey2({
1168
1234
  onLinkClick: stableOnLinkClick,
1169
1235
  onNodeHover: stableOnNodeHover,
1170
1236
  onLinkHover: stableOnLinkHover,
1171
- responsive: true
1237
+ autoResize: true
1172
1238
  };
1173
1239
  instanceRef.current = createSankey(container, spec, options);
1174
1240
  specRef.current = JSON.stringify(spec);
@@ -1203,6 +1269,7 @@ var Sankey = forwardRef5(function Sankey2({
1203
1269
  });
1204
1270
 
1205
1271
  // src/TileMap.tsx
1272
+ import { mergeThemeConfig as mergeThemeConfig7 } from "@opendata-ai/openchart-core";
1206
1273
  import {
1207
1274
  createTileMap
1208
1275
  } from "@opendata-ai/openchart-vanilla";
@@ -1211,13 +1278,14 @@ import {
1211
1278
  useCallback as useCallback10,
1212
1279
  useEffect as useEffect10,
1213
1280
  useImperativeHandle as useImperativeHandle7,
1281
+ useMemo as useMemo7,
1214
1282
  useRef as useRef11
1215
1283
  } from "react";
1216
1284
  import { jsx as jsx9 } from "react/jsx-runtime";
1217
1285
  var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode, onTileClick, onTileHover, className, style }, ref) {
1218
1286
  const contextTheme = useVizTheme();
1219
1287
  const contextDarkMode = useVizDarkMode();
1220
- const theme = themeProp ?? contextTheme;
1288
+ const theme = useMemo7(() => mergeThemeConfig7(contextTheme, themeProp), [contextTheme, themeProp]);
1221
1289
  const resolvedDarkMode = darkMode ?? contextDarkMode;
1222
1290
  const containerRef = useRef11(null);
1223
1291
  const instanceRef = useRef11(null);
@@ -1252,7 +1320,7 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
1252
1320
  darkMode: resolvedDarkMode,
1253
1321
  onTileClick: stableOnTileClick,
1254
1322
  onTileHover: stableOnTileHover,
1255
- responsive: true
1323
+ autoResize: true
1256
1324
  };
1257
1325
  instanceRef.current = createTileMap(container, spec, options);
1258
1326
  specRef.current = JSON.stringify(spec);