@opendata-ai/openchart-react 8.9.1 → 9.0.0-rc.2

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,12 +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';
69
+ /** Quiet row inspection for simple horizontal bars. */
70
+ rowHover?: boolean;
63
71
  /** Observe container resizes. */
64
72
  autoResize?: boolean;
65
- /** @deprecated Use autoResize. */
66
- responsive?: boolean;
67
- /** Callback when a data point is clicked. @deprecated Use onMarkClick instead. */
68
- onDataPointClick?: (data: Record<string, unknown>) => void;
69
73
  /** The currently selected element (controlled). */
70
74
  selectedElement?: ElementRef;
71
75
  /** Highlight specific color-encoding values. Pass null to clear. */
@@ -75,6 +79,17 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
75
79
  /** Inline styles for the wrapper div. */
76
80
  style?: CSSProperties;
77
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
+ }>;
78
93
  /**
79
94
  * Generic Chart component with field autocomplete support.
80
95
  *
@@ -86,9 +101,14 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
86
101
  *
87
102
  * Without a type parameter, behaves identically to before — no migration needed.
88
103
  */
89
- declare const Chart: <TData extends DataRow = DataRow>(props: ChartProps<TData> & {
90
- ref?: React.Ref<ChartHandle>;
91
- }) => 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
+ };
92
112
 
93
113
  interface ChartStoryHandle {
94
114
  /** Jump the story to a step index (applies patches 0..n, animates the diff). */
@@ -98,7 +118,7 @@ interface ChartStoryHandle {
98
118
  }
99
119
  interface ChartStoryProps<TData extends DataRow = DataRow> {
100
120
  /** Base spec the story drives. */
101
- spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec | GeoMapSpec;
121
+ spec: ChartSpec<TData> | LayerSpec<TData> | GeoMapSpec;
102
122
  /** Ordered step patches. `steps[i]` is applied cumulatively onto the base. */
103
123
  steps: ChartStoryOptions<TData>['steps'];
104
124
  /**
@@ -162,6 +182,10 @@ interface DataTableProps {
162
182
  declare function DataTable({ spec, theme: themeProp, darkMode, onRowClick, onSortChange, onSearchChange, onPageChange, className, style, sort, search, page, }: DataTableProps): react_jsx_runtime.JSX.Element;
163
183
 
164
184
  interface GeoMapProps {
185
+ reader?: false | GeoReaderOptions;
186
+ readerSelection?: GeoReaderSelection;
187
+ onReaderChange?: (selection: GeoReaderSelection, meta: ReaderChangeMeta) => void;
188
+ labelInventory?: GeoMapMountOptions['labelInventory'];
165
189
  /** The map spec to render. */
166
190
  spec: GeoMapSpec;
167
191
  /** Theme overrides. */
@@ -173,7 +197,7 @@ interface GeoMapProps {
173
197
  /** Callback when a map feature is hovered (null when hover ends). */
174
198
  onMarkHover?: (feature: GeoMapMarkEvent | null) => void;
175
199
  /** Called whenever the camera moves (reader zoom/pan, zoomTo, focus). */
176
- onCameraChange?: (camera: Camera) => void;
200
+ onCameraChange?: (camera: Camera, meta?: GeoMapCameraChangeMeta) => void;
177
201
  /** CSS class name for the wrapper div. */
178
202
  className?: string;
179
203
  /** Inline styles for the wrapper div. */
@@ -269,8 +293,8 @@ interface GraphHandle {
269
293
  getLegend: () => GraphLegendData | null;
270
294
  setActiveCategories: (values: string[]) => void;
271
295
  getActiveCategories: () => string[];
272
- /** Re-compile encoding/legend/chrome without restarting the simulation. */
273
- updateVisuals: (spec: GraphSpec) => void;
296
+ /** Update graph data, encoding, or presentation through the unified update path. */
297
+ update: (spec: GraphSpec) => void;
274
298
  /** The underlying GraphInstance from the vanilla adapter. */
275
299
  instance: GraphInstance | null;
276
300
  }
@@ -368,10 +392,8 @@ interface UseChartOptions {
368
392
  theme?: MountOptions['theme'];
369
393
  /** Dark mode setting. */
370
394
  darkMode?: MountOptions['darkMode'];
371
- /** Data point click handler. */
372
- onDataPointClick?: MountOptions['onDataPointClick'];
373
- /** Enable responsive resizing. Defaults to true. */
374
- responsive?: boolean;
395
+ /** Observe container resizes. Defaults to true. */
396
+ autoResize?: boolean;
375
397
  /** Rendering backend for point marks; see the vanilla `MountOptions.renderer`. */
376
398
  renderer?: MountOptions['renderer'];
377
399
  }
@@ -393,7 +415,7 @@ interface UseChartReturn {
393
415
  * @param options - Mount options.
394
416
  * @returns { ref, chart, layout }
395
417
  */
396
- declare function useChart(spec: ChartSpec | LayerSpec | GraphSpec, options?: UseChartOptions): UseChartReturn;
418
+ declare function useChart(spec: ChartSpec | LayerSpec, options?: UseChartOptions): UseChartReturn;
397
419
  /**
398
420
  * Resolve a DarkMode preference to a boolean.
399
421
  *
@@ -579,4 +601,4 @@ interface VisualizationProps {
579
601
  */
580
602
  declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps): react_jsx_runtime.JSX.Element;
581
603
 
582
- 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,73 +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,
143
+ rowHover,
133
144
  autoResize,
134
- responsive,
135
145
  revision,
136
- onEditTransaction,
137
- onDataPointClick,
146
+ onEdit,
138
147
  onMarkClick,
139
148
  onMarkHover,
140
149
  onMarkLeave,
141
150
  onLegendToggle,
142
151
  onHighlightChange,
143
152
  onAnnotationClick,
144
- onAnnotationEdit,
145
- onEdit,
146
153
  onSelect,
147
154
  onDeselect,
148
- onTextEdit,
149
155
  onReveal,
150
- editable,
156
+ interaction,
151
157
  selectedElement: selectedElementProp,
152
158
  highlight,
153
159
  className,
154
160
  style
155
161
  }, ref) {
156
- const hasTransactionListener = Boolean(onEditTransaction);
162
+ const hasEditListener = Boolean(onEdit);
163
+ const hasSelectListener = Boolean(onSelect);
164
+ const hasDeselectListener = Boolean(onDeselect);
157
165
  const contextTheme = useVizTheme();
158
166
  const contextDarkMode = useVizDarkMode();
159
- const theme = themeProp ?? contextTheme;
167
+ const theme = useMemo2(() => mergeThemeConfig2(contextTheme, themeProp), [contextTheme, themeProp]);
160
168
  const resolvedDarkMode = darkMode ?? contextDarkMode;
161
169
  const containerRef = useRef2(null);
162
170
  const chartRef = useRef2(null);
163
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
+ };
164
189
  const revisionRef = useRef2(revision);
165
190
  const handlersRef = useRef2({});
166
191
  handlersRef.current = {
167
- onEditTransaction,
168
- onDataPointClick,
192
+ onEdit,
169
193
  onMarkClick,
170
194
  onMarkHover,
171
195
  onMarkLeave,
172
196
  onLegendToggle,
173
197
  onHighlightChange,
174
198
  onAnnotationClick,
175
- onAnnotationEdit,
176
- onEdit,
177
199
  onSelect,
178
200
  onDeselect,
179
- onTextEdit,
180
201
  onReveal
181
202
  };
182
- const stableOnDataPointClick = useCallback2(
183
- (data) => handlersRef.current.onDataPointClick?.(data),
184
- []
185
- );
186
203
  const stableOnMarkClick = useCallback2(
187
204
  (event) => handlersRef.current.onMarkClick?.(event),
188
205
  []
@@ -204,16 +221,8 @@ function ChartInner({
204
221
  (annotation, event, element) => handlersRef.current.onAnnotationClick?.(annotation, event, element),
205
222
  []
206
223
  );
207
- const stableOnAnnotationEdit = useCallback2(
208
- (annotation, updatedOffset) => handlersRef.current.onAnnotationEdit?.(annotation, updatedOffset),
209
- []
210
- );
211
224
  const stableOnEdit = useCallback2(
212
- (edit) => handlersRef.current.onEdit?.(edit),
213
- []
214
- );
215
- const stableOnEditTransaction = useCallback2(
216
- (tx) => handlersRef.current.onEditTransaction?.(tx),
225
+ (tx) => handlersRef.current.onEdit?.(tx),
217
226
  []
218
227
  );
219
228
  const stableOnSelect = useCallback2(
@@ -224,10 +233,6 @@ function ChartInner({
224
233
  (element) => handlersRef.current.onDeselect?.(element),
225
234
  []
226
235
  );
227
- const stableOnTextEdit = useCallback2(
228
- (element, oldText, newText) => handlersRef.current.onTextEdit?.(element, oldText, newText),
229
- []
230
- );
231
236
  const stableOnReveal = useCallback2(
232
237
  (guess) => handlersRef.current.onReveal?.(guess),
233
238
  []
@@ -257,7 +262,6 @@ function ChartInner({
257
262
  theme,
258
263
  darkMode: resolvedDarkMode,
259
264
  renderer,
260
- ...handlersRef.current.onDataPointClick ? { onDataPointClick: stableOnDataPointClick } : {},
261
265
  onMarkClick: stableOnMarkClick,
262
266
  onMarkHover: stableOnMarkHover,
263
267
  onMarkLeave: stableOnMarkLeave,
@@ -267,22 +271,21 @@ function ChartInner({
267
271
  // Only include editing callbacks when the consumer provides them.
268
272
  // The stable wrappers are always truthy, so gating on handlersRef
269
273
  // avoids adding unstable prop references to the effect deps.
270
- ...handlersRef.current.onAnnotationEdit ? { onAnnotationEdit: stableOnAnnotationEdit } : {},
271
- ...handlersRef.current.onEdit ? { onEdit: stableOnEdit } : {},
272
274
  ...handlersRef.current.onSelect ? { onSelect: stableOnSelect } : {},
273
275
  ...handlersRef.current.onDeselect ? { onDeselect: stableOnDeselect } : {},
274
- ...handlersRef.current.onTextEdit ? { onTextEdit: stableOnTextEdit } : {},
275
276
  ...handlersRef.current.onReveal ? { onReveal: stableOnReveal } : {},
276
- ...editable != null ? { editable } : {},
277
+ ...interaction != null ? { interaction } : {},
277
278
  ...selectedElementProp ? { selectedElement: selectedElementProp } : {},
279
+ rowHover,
278
280
  autoResize,
279
- responsive,
280
281
  revision,
281
- ...handlersRef.current.onEditTransaction ? { onEditTransaction: stableOnEditTransaction } : {}
282
+ ...handlersRef.current.onEdit ? { onEdit: stableOnEdit } : {}
282
283
  };
283
284
  chartRef.current = createChart(container, spec, options);
284
285
  specRef.current = JSON.stringify(spec);
286
+ syncReader();
285
287
  return () => {
288
+ readerBinding.current?.detach();
286
289
  chartRef.current?.destroy();
287
290
  chartRef.current = null;
288
291
  };
@@ -290,25 +293,26 @@ function ChartInner({
290
293
  theme,
291
294
  resolvedDarkMode,
292
295
  renderer,
293
- editable,
296
+ interaction,
294
297
  stableOnAnnotationClick,
295
- stableOnDataPointClick,
296
298
  stableOnEdit,
297
- stableOnEditTransaction,
298
- hasTransactionListener,
299
+ hasEditListener,
300
+ hasSelectListener,
301
+ hasDeselectListener,
302
+ rowHover,
299
303
  autoResize,
300
- responsive,
301
304
  stableOnLegendToggle,
302
305
  stableOnHighlightChange,
303
306
  stableOnMarkClick,
304
307
  stableOnMarkHover,
305
308
  stableOnMarkLeave,
306
- stableOnAnnotationEdit,
307
309
  stableOnSelect,
308
310
  stableOnDeselect,
309
- stableOnTextEdit,
310
311
  stableOnReveal
311
312
  ]);
313
+ useEffect2(() => {
314
+ syncReader();
315
+ }, [reader, readerSelection, onReaderChange]);
312
316
  useEffect2(() => {
313
317
  const chart = chartRef.current;
314
318
  if (!chart) return;
@@ -319,6 +323,7 @@ function ChartInner({
319
323
  revisionRef.current = revision;
320
324
  if (revision !== void 0 || revisionChanged) chart.update(spec, { revision });
321
325
  else chart.update(spec);
326
+ syncReader();
322
327
  }
323
328
  }, [spec, revision]);
324
329
  useEffect2(() => {
@@ -461,10 +466,11 @@ function ChartStory({
461
466
  }
462
467
 
463
468
  // src/DataTable.tsx
469
+ import { mergeThemeConfig as mergeThemeConfig3 } from "@opendata-ai/openchart-core";
464
470
  import {
465
471
  createTable
466
472
  } from "@opendata-ai/openchart-vanilla";
467
- 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";
468
474
  import { jsx as jsx5 } from "react/jsx-runtime";
469
475
  function DataTable({
470
476
  spec,
@@ -482,7 +488,7 @@ function DataTable({
482
488
  }) {
483
489
  const contextTheme = useVizTheme();
484
490
  const contextDarkMode = useVizDarkMode();
485
- const theme = themeProp ?? contextTheme;
491
+ const theme = useMemo3(() => mergeThemeConfig3(contextTheme, themeProp), [contextTheme, themeProp]);
486
492
  const resolvedDarkMode = darkMode ?? contextDarkMode;
487
493
  const containerRef = useRef4(null);
488
494
  const tableRef = useRef4(null);
@@ -509,7 +515,7 @@ function DataTable({
509
515
  theme,
510
516
  darkMode: resolvedDarkMode,
511
517
  onRowClick: stableOnRowClick,
512
- responsive: true,
518
+ autoResize: true,
513
519
  onStateChange: stableOnStateChange
514
520
  };
515
521
  if (isControlled) {
@@ -555,25 +561,58 @@ function DataTable({
555
561
  }
556
562
 
557
563
  // src/GeoMap.tsx
564
+ import { mergeThemeConfig as mergeThemeConfig4 } from "@opendata-ai/openchart-core";
558
565
  import {
559
- createGeoMap
566
+ createGeoMap,
567
+ createGeoReaderBinding
560
568
  } from "@opendata-ai/openchart-vanilla";
561
569
  import {
562
570
  forwardRef as forwardRef3,
563
571
  useCallback as useCallback4,
564
572
  useEffect as useEffect5,
565
573
  useImperativeHandle as useImperativeHandle4,
574
+ useMemo as useMemo4,
566
575
  useRef as useRef5
567
576
  } from "react";
568
577
  import { jsx as jsx6 } from "react/jsx-runtime";
569
- 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) {
570
592
  const contextTheme = useVizTheme();
571
593
  const contextDarkMode = useVizDarkMode();
572
- const theme = themeProp ?? contextTheme;
594
+ const theme = useMemo4(() => mergeThemeConfig4(contextTheme, themeProp), [contextTheme, themeProp]);
573
595
  const resolvedDarkMode = darkMode ?? contextDarkMode;
574
596
  const containerRef = useRef5(null);
575
597
  const instanceRef = useRef5(null);
576
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
+ };
577
616
  const handlersRef = useRef5({});
578
617
  handlersRef.current = {
579
618
  onMarkClick,
@@ -589,7 +628,7 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
589
628
  []
590
629
  );
591
630
  const stableOnCameraChange = useCallback4(
592
- (camera) => handlersRef.current.onCameraChange?.(camera),
631
+ (camera, meta) => meta ? handlersRef.current.onCameraChange?.(camera, meta) : handlersRef.current.onCameraChange?.(camera),
593
632
  []
594
633
  );
595
634
  useImperativeHandle4(
@@ -610,11 +649,13 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
610
649
  onMarkClick: stableOnMarkClick,
611
650
  onMarkHover: stableOnMarkHover,
612
651
  onCameraChange: stableOnCameraChange,
613
- responsive: true
652
+ autoResize: true
614
653
  };
615
654
  instanceRef.current = createGeoMap(container, spec, options);
616
655
  specRef.current = JSON.stringify(spec);
656
+ syncReader();
617
657
  return () => {
658
+ readerBinding.current?.detach();
618
659
  instanceRef.current?.destroy();
619
660
  instanceRef.current = null;
620
661
  };
@@ -626,7 +667,14 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
626
667
  if (specString === specRef.current) return;
627
668
  specRef.current = specString;
628
669
  instance.update(spec);
670
+ syncReader();
629
671
  }, [spec]);
672
+ useEffect5(() => {
673
+ instanceRef.current?.setLabelInventory(labelInventory);
674
+ }, [labelInventory, theme, resolvedDarkMode]);
675
+ useEffect5(() => {
676
+ syncReader();
677
+ }, [reader, readerSelection, onReaderChange]);
630
678
  return /* @__PURE__ */ jsx6(
631
679
  "div",
632
680
  {
@@ -638,6 +686,7 @@ var GeoMap = forwardRef3(function GeoMap2({ spec, theme: themeProp, darkMode, on
638
686
  });
639
687
 
640
688
  // src/Graph.tsx
689
+ import { mergeThemeConfig as mergeThemeConfig5 } from "@opendata-ai/openchart-core";
641
690
  import {
642
691
  createGraph
643
692
  } from "@opendata-ai/openchart-vanilla";
@@ -646,6 +695,7 @@ import {
646
695
  useCallback as useCallback5,
647
696
  useEffect as useEffect6,
648
697
  useImperativeHandle as useImperativeHandle5,
698
+ useMemo as useMemo5,
649
699
  useRef as useRef6
650
700
  } from "react";
651
701
  import { jsx as jsx7 } from "react/jsx-runtime";
@@ -680,7 +730,7 @@ var Graph = forwardRef4(function Graph2({
680
730
  }, ref) {
681
731
  const contextTheme = useVizTheme();
682
732
  const contextDarkMode = useVizDarkMode();
683
- const theme = themeProp ?? contextTheme;
733
+ const theme = useMemo5(() => mergeThemeConfig5(contextTheme, themeProp), [contextTheme, themeProp]);
684
734
  const resolvedDarkMode = darkMode ?? contextDarkMode;
685
735
  const containerRef = useRef6(null);
686
736
  const graphRef = useRef6(null);
@@ -790,8 +840,8 @@ var Graph = forwardRef4(function Graph2({
790
840
  getActiveCategories() {
791
841
  return graphRef.current?.getActiveCategories() ?? [];
792
842
  },
793
- updateVisuals(spec2) {
794
- graphRef.current?.updateVisuals(spec2);
843
+ update(spec2) {
844
+ graphRef.current?.update(spec2);
795
845
  },
796
846
  get instance() {
797
847
  return graphRef.current;
@@ -826,7 +876,7 @@ var Graph = forwardRef4(function Graph2({
826
876
  onLegendToggle: stableOnLegendToggle,
827
877
  onHighlightChange: stableOnHighlightChange,
828
878
  onCameraChange: stableOnCameraChange,
829
- responsive: true,
879
+ autoResize: true,
830
880
  suppressEntrance
831
881
  };
832
882
  graphRef.current = createGraph(container, spec, options);
@@ -886,8 +936,7 @@ function useChart(spec, options) {
886
936
  const mountOpts = {
887
937
  theme: options?.theme,
888
938
  darkMode: options?.darkMode,
889
- onDataPointClick: options?.onDataPointClick,
890
- responsive: options?.responsive,
939
+ autoResize: options?.autoResize,
891
940
  renderer: options?.renderer
892
941
  };
893
942
  const chart = createChart2(container, spec, mountOpts);
@@ -899,13 +948,7 @@ function useChart(spec, options) {
899
948
  chartRef.current = null;
900
949
  setLayout(null);
901
950
  };
902
- }, [
903
- options?.theme,
904
- options?.darkMode,
905
- options?.onDataPointClick,
906
- options?.responsive,
907
- options?.renderer
908
- ]);
951
+ }, [options?.theme, options?.darkMode, options?.autoResize, options?.renderer]);
909
952
  useEffect7(() => {
910
953
  const chart = chartRef.current;
911
954
  if (!chart) return;
@@ -1068,7 +1111,7 @@ function useTable(spec, options) {
1068
1111
  options?.theme,
1069
1112
  options?.darkMode,
1070
1113
  options?.onRowClick,
1071
- options?.responsive,
1114
+ options?.autoResize,
1072
1115
  handleStateChange,
1073
1116
  options,
1074
1117
  spec
@@ -1118,6 +1161,7 @@ function useTableState(initialState) {
1118
1161
  }
1119
1162
 
1120
1163
  // src/Sankey.tsx
1164
+ import { mergeThemeConfig as mergeThemeConfig6 } from "@opendata-ai/openchart-core";
1121
1165
  import {
1122
1166
  createSankey
1123
1167
  } from "@opendata-ai/openchart-vanilla";
@@ -1126,6 +1170,7 @@ import {
1126
1170
  useCallback as useCallback9,
1127
1171
  useEffect as useEffect9,
1128
1172
  useImperativeHandle as useImperativeHandle6,
1173
+ useMemo as useMemo6,
1129
1174
  useRef as useRef10
1130
1175
  } from "react";
1131
1176
  import { jsx as jsx8 } from "react/jsx-runtime";
@@ -1142,7 +1187,7 @@ var Sankey = forwardRef5(function Sankey2({
1142
1187
  }, ref) {
1143
1188
  const contextTheme = useVizTheme();
1144
1189
  const contextDarkMode = useVizDarkMode();
1145
- const theme = themeProp ?? contextTheme;
1190
+ const theme = useMemo6(() => mergeThemeConfig6(contextTheme, themeProp), [contextTheme, themeProp]);
1146
1191
  const resolvedDarkMode = darkMode ?? contextDarkMode;
1147
1192
  const containerRef = useRef10(null);
1148
1193
  const instanceRef = useRef10(null);
@@ -1189,7 +1234,7 @@ var Sankey = forwardRef5(function Sankey2({
1189
1234
  onLinkClick: stableOnLinkClick,
1190
1235
  onNodeHover: stableOnNodeHover,
1191
1236
  onLinkHover: stableOnLinkHover,
1192
- responsive: true
1237
+ autoResize: true
1193
1238
  };
1194
1239
  instanceRef.current = createSankey(container, spec, options);
1195
1240
  specRef.current = JSON.stringify(spec);
@@ -1224,6 +1269,7 @@ var Sankey = forwardRef5(function Sankey2({
1224
1269
  });
1225
1270
 
1226
1271
  // src/TileMap.tsx
1272
+ import { mergeThemeConfig as mergeThemeConfig7 } from "@opendata-ai/openchart-core";
1227
1273
  import {
1228
1274
  createTileMap
1229
1275
  } from "@opendata-ai/openchart-vanilla";
@@ -1232,13 +1278,14 @@ import {
1232
1278
  useCallback as useCallback10,
1233
1279
  useEffect as useEffect10,
1234
1280
  useImperativeHandle as useImperativeHandle7,
1281
+ useMemo as useMemo7,
1235
1282
  useRef as useRef11
1236
1283
  } from "react";
1237
1284
  import { jsx as jsx9 } from "react/jsx-runtime";
1238
1285
  var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode, onTileClick, onTileHover, className, style }, ref) {
1239
1286
  const contextTheme = useVizTheme();
1240
1287
  const contextDarkMode = useVizDarkMode();
1241
- const theme = themeProp ?? contextTheme;
1288
+ const theme = useMemo7(() => mergeThemeConfig7(contextTheme, themeProp), [contextTheme, themeProp]);
1242
1289
  const resolvedDarkMode = darkMode ?? contextDarkMode;
1243
1290
  const containerRef = useRef11(null);
1244
1291
  const instanceRef = useRef11(null);
@@ -1273,7 +1320,7 @@ var TileMap = forwardRef6(function TileMap2({ spec, theme: themeProp, darkMode,
1273
1320
  darkMode: resolvedDarkMode,
1274
1321
  onTileClick: stableOnTileClick,
1275
1322
  onTileHover: stableOnTileHover,
1276
- responsive: true
1323
+ autoResize: true
1277
1324
  };
1278
1325
  instanceRef.current = createTileMap(container, spec, options);
1279
1326
  specRef.current = JSON.stringify(spec);