@opendata-ai/openchart-react 8.0.0-rc.9 → 8.1.0
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 +155 -43
- package/dist/index.js +291 -157
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +5 -6
- package/src/BarList.tsx +0 -126
- package/src/Chart.tsx +0 -344
- package/src/ChartStory.tsx +0 -203
- package/src/DataTable.tsx +0 -165
- package/src/Graph.tsx +0 -253
- package/src/Map.tsx +0 -130
- package/src/Sankey.tsx +0 -176
- package/src/ThemeContext.tsx +0 -40
- package/src/TileMap.tsx +0 -165
- package/src/Visualization.tsx +0 -85
- package/src/__tests__/Chart.test.tsx +0 -134
- package/src/__tests__/ChartStory.test.tsx +0 -92
- package/src/__tests__/DataTable.test.tsx +0 -126
- package/src/__tests__/Graph.test.tsx +0 -130
- package/src/__tests__/ThemeContext.test.tsx +0 -238
- package/src/__tests__/hooks.test.tsx +0 -160
- package/src/__tests__/update-vs-remount.test.tsx +0 -133
- package/src/__tests__/useTableState.test.tsx +0 -218
- package/src/hooks/useGraph.ts +0 -87
- package/src/hooks/useTable.ts +0 -98
- package/src/hooks/useTableState.ts +0 -76
- package/src/hooks.ts +0 -154
- package/src/index.ts +0 -104
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
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';
|
|
3
2
|
export * from '@opendata-ai/openchart-core';
|
|
4
|
-
import { BarListInstance, ChartInstance, MountOptions, GraphInstance, TableInstance, TableState, TableMountOptions,
|
|
5
|
-
export { JPGExportOptions, PNGExportOptions, SVGExportOptions, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts } from '@opendata-ai/openchart-vanilla';
|
|
6
|
-
export { ChartRenderer, CompileResult, CompiledGraphEdge, CompiledGraphNode, GraphCompilation, NormalizedBarListSpec, NormalizedChartSpec, NormalizedChrome,
|
|
3
|
+
import { BarListInstance, ChartInstance, MountOptions, GeoMapMarkEvent, GeoMapInstance, CameraFlightOptions, 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';
|
|
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';
|
|
7
6
|
import * as react from 'react';
|
|
8
7
|
import { CSSProperties, ReactNode, Ref } from 'react';
|
|
9
8
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -56,6 +55,11 @@ interface ChartProps<TData extends DataRow = DataRow> extends ChartEventHandlers
|
|
|
56
55
|
theme?: ThemeConfig;
|
|
57
56
|
/** Dark mode: "auto", "force", or "off". */
|
|
58
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';
|
|
59
63
|
/** Callback when a data point is clicked. @deprecated Use onMarkClick instead. */
|
|
60
64
|
onDataPointClick?: (data: Record<string, unknown>) => void;
|
|
61
65
|
/** The currently selected element (controlled). */
|
|
@@ -90,7 +94,7 @@ interface ChartStoryHandle {
|
|
|
90
94
|
}
|
|
91
95
|
interface ChartStoryProps<TData extends DataRow = DataRow> {
|
|
92
96
|
/** Base spec the story drives. */
|
|
93
|
-
spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec |
|
|
97
|
+
spec: ChartSpec<TData> | LayerSpec<TData> | GraphSpec | GeoMapSpec;
|
|
94
98
|
/** Ordered step patches. `steps[i]` is applied cumulatively onto the base. */
|
|
95
99
|
steps: ChartStoryOptions<TData>['steps'];
|
|
96
100
|
/**
|
|
@@ -153,6 +157,42 @@ interface DataTableProps {
|
|
|
153
157
|
*/
|
|
154
158
|
declare function DataTable({ spec, theme: themeProp, darkMode, onRowClick, onSortChange, onSearchChange, onPageChange, className, style, sort, search, page, }: DataTableProps): react_jsx_runtime.JSX.Element;
|
|
155
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
|
+
|
|
182
|
+
/**
|
|
183
|
+
* useGraph: hook for imperative graph control.
|
|
184
|
+
*
|
|
185
|
+
* Provides a ref to pass to <Graph /> and exposes graph methods
|
|
186
|
+
* (search, zoom, select, fly, highlight) for programmatic control of the
|
|
187
|
+
* graph instance. The full vanilla GraphInstance API is threaded through.
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/** Camera transform components (graph-space). */
|
|
191
|
+
type GraphCamera = {
|
|
192
|
+
x: number;
|
|
193
|
+
y: number;
|
|
194
|
+
k: number;
|
|
195
|
+
};
|
|
156
196
|
interface UseGraphReturn {
|
|
157
197
|
/** Ref to pass to <Graph ref={ref} />. */
|
|
158
198
|
ref: React.RefObject<GraphHandle | null>;
|
|
@@ -160,25 +200,85 @@ interface UseGraphReturn {
|
|
|
160
200
|
search: (query: string) => void;
|
|
161
201
|
/** Clear the current search. */
|
|
162
202
|
clearSearch: () => void;
|
|
163
|
-
/**
|
|
164
|
-
|
|
165
|
-
/** Zoom
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
203
|
+
/** Node ids currently matching the active search query. */
|
|
204
|
+
getSearchMatches: () => string[];
|
|
205
|
+
/** Zoom to fit all nodes in view. Animated by default; `{ duration: 0 }` snaps. */
|
|
206
|
+
zoomToFit: (opts?: CameraFlightOptions & {
|
|
207
|
+
padding?: number;
|
|
208
|
+
}) => void;
|
|
209
|
+
/** Fly to a node and zoom in (default scale 2). */
|
|
210
|
+
zoomToNode: (nodeId: string, opts?: CameraFlightOptions & {
|
|
211
|
+
scale?: number;
|
|
212
|
+
}) => void;
|
|
213
|
+
/** Fly the camera to a graph-space target. */
|
|
214
|
+
flyTo: (target: {
|
|
215
|
+
x: number;
|
|
216
|
+
y: number;
|
|
217
|
+
k?: number;
|
|
218
|
+
}, opts?: CameraFlightOptions) => void;
|
|
219
|
+
/** Center the camera on a graph-space point (keeps current zoom). */
|
|
220
|
+
centerAt: (x: number, y: number, opts?: CameraFlightOptions) => void;
|
|
221
|
+
/** Current camera transform. */
|
|
222
|
+
getCamera: () => GraphCamera;
|
|
223
|
+
/** Select a node by id; `{ fly: true }` also flies to it. */
|
|
224
|
+
selectNode: (nodeId: string, opts?: {
|
|
225
|
+
fly?: boolean;
|
|
226
|
+
} & CameraFlightOptions) => void;
|
|
169
227
|
/** Get the currently selected node ids. */
|
|
170
228
|
getSelectedNodes: () => string[];
|
|
229
|
+
/**
|
|
230
|
+
* Emphasize a set of nodes; eased via the focus model. Layers over the
|
|
231
|
+
* standing category filter rather than replacing it.
|
|
232
|
+
*/
|
|
233
|
+
highlight: (target: GraphHighlightTarget, opts?: {
|
|
234
|
+
dimOpacity?: number;
|
|
235
|
+
}) => void;
|
|
236
|
+
/**
|
|
237
|
+
* Clear the transient highlight, returning to the standing category filter.
|
|
238
|
+
* Does NOT clear that filter — use `setActiveCategories([])`.
|
|
239
|
+
*/
|
|
240
|
+
clearHighlight: () => void;
|
|
241
|
+
/** The effective highlighted node ids, or null when nothing is highlighted. */
|
|
242
|
+
getHighlight: () => string[] | null;
|
|
243
|
+
/** Headless snapshot of the legend. */
|
|
244
|
+
getLegend: () => GraphLegendData | null;
|
|
245
|
+
/** Set the active category filter declaratively (replaces legend toggle state). */
|
|
246
|
+
setActiveCategories: (values: string[]) => void;
|
|
247
|
+
/** Current active category values (empty = all active, no filter). */
|
|
248
|
+
getActiveCategories: () => string[];
|
|
171
249
|
}
|
|
172
250
|
/** Handle exposed by Graph component via forwardRef. */
|
|
173
251
|
interface GraphHandle {
|
|
174
252
|
search: (query: string) => void;
|
|
175
253
|
clearSearch: () => void;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
254
|
+
getSearchMatches: () => string[];
|
|
255
|
+
zoomToFit: (opts?: CameraFlightOptions & {
|
|
256
|
+
padding?: number;
|
|
257
|
+
}) => void;
|
|
258
|
+
zoomToNode: (nodeId: string, opts?: CameraFlightOptions & {
|
|
259
|
+
scale?: number;
|
|
260
|
+
}) => void;
|
|
261
|
+
flyTo: (target: {
|
|
262
|
+
x: number;
|
|
263
|
+
y: number;
|
|
264
|
+
k?: number;
|
|
265
|
+
}, opts?: CameraFlightOptions) => void;
|
|
266
|
+
centerAt: (x: number, y: number, opts?: CameraFlightOptions) => void;
|
|
267
|
+
getCamera: () => GraphCamera;
|
|
268
|
+
selectNode: (nodeId: string, opts?: {
|
|
269
|
+
fly?: boolean;
|
|
270
|
+
} & CameraFlightOptions) => void;
|
|
179
271
|
getSelectedNodes: () => string[];
|
|
272
|
+
highlight: (target: GraphHighlightTarget, opts?: {
|
|
273
|
+
dimOpacity?: number;
|
|
274
|
+
}) => void;
|
|
275
|
+
clearHighlight: () => void;
|
|
276
|
+
getHighlight: () => string[] | null;
|
|
277
|
+
getLegend: () => GraphLegendData | null;
|
|
278
|
+
setActiveCategories: (values: string[]) => void;
|
|
279
|
+
getActiveCategories: () => string[];
|
|
180
280
|
/** Re-compile encoding/legend/chrome without restarting the simulation. */
|
|
181
|
-
updateVisuals: (spec:
|
|
281
|
+
updateVisuals: (spec: GraphSpec) => void;
|
|
182
282
|
/** The underlying GraphInstance from the vanilla adapter. */
|
|
183
283
|
instance: GraphInstance | null;
|
|
184
284
|
}
|
|
@@ -193,6 +293,15 @@ interface GraphHandle {
|
|
|
193
293
|
*/
|
|
194
294
|
declare function useGraph(): UseGraphReturn;
|
|
195
295
|
|
|
296
|
+
/** Tooltip prop: `false` off, `true` default, or an object with a formatter. */
|
|
297
|
+
type GraphTooltipProp = boolean | {
|
|
298
|
+
formatter?: GraphTooltipFormatter;
|
|
299
|
+
};
|
|
300
|
+
/** Legend prop: `false` off, `true` default, or an object toggling interactivity/counts. */
|
|
301
|
+
type GraphLegendProp = boolean | {
|
|
302
|
+
interactive?: boolean;
|
|
303
|
+
counts?: boolean;
|
|
304
|
+
};
|
|
196
305
|
interface GraphProps {
|
|
197
306
|
/** The graph spec to render. */
|
|
198
307
|
spec: GraphSpec;
|
|
@@ -210,10 +319,33 @@ interface GraphProps {
|
|
|
210
319
|
onEdgeHover?: (edge: Record<string, unknown> | null) => void;
|
|
211
320
|
/** Callback when selection changes. */
|
|
212
321
|
onSelectionChange?: (nodeIds: string[]) => void;
|
|
213
|
-
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
322
|
+
/** Fired when the user hovers a legend entry (null on leave). */
|
|
323
|
+
onLegendHover?: (entry: {
|
|
324
|
+
field: string;
|
|
325
|
+
value: string;
|
|
326
|
+
} | null) => void;
|
|
327
|
+
/** Fired when legend toggle state changes; `activeValues` is the active set (empty = all). */
|
|
328
|
+
onLegendToggle?: (activeValues: string[]) => void;
|
|
329
|
+
/** Fired whenever the highlight set changes (programmatic or legend), null when cleared. */
|
|
330
|
+
onHighlightChange?: (nodeIds: string[] | null) => void;
|
|
331
|
+
/** Camera change callback, rAF-coalesced (fires at most once per rendered frame). */
|
|
332
|
+
onCameraChange?: (camera: {
|
|
333
|
+
x: number;
|
|
334
|
+
y: number;
|
|
335
|
+
k: number;
|
|
336
|
+
}) => void;
|
|
337
|
+
/**
|
|
338
|
+
* Show built-in tooltip on node/edge hover. Defaults to true. Pass an object
|
|
339
|
+
* with a `formatter` to customize content.
|
|
340
|
+
*/
|
|
341
|
+
tooltip?: GraphTooltipProp;
|
|
342
|
+
/**
|
|
343
|
+
* Show built-in legend. Defaults to true. Pass `false` if you render your own,
|
|
344
|
+
* or an object to toggle interactivity/counts.
|
|
345
|
+
*/
|
|
346
|
+
legend?: GraphLegendProp;
|
|
347
|
+
/** Fit the graph to the viewport on the first tick. Default true. */
|
|
348
|
+
fitOnLoad?: boolean;
|
|
217
349
|
/** CSS class name for the wrapper div. */
|
|
218
350
|
className?: string;
|
|
219
351
|
/** Inline styles for the wrapper div. */
|
|
@@ -250,6 +382,8 @@ interface UseChartOptions {
|
|
|
250
382
|
onDataPointClick?: MountOptions['onDataPointClick'];
|
|
251
383
|
/** Enable responsive resizing. Defaults to true. */
|
|
252
384
|
responsive?: boolean;
|
|
385
|
+
/** Rendering backend for point marks; see the vanilla `MountOptions.renderer`. */
|
|
386
|
+
renderer?: MountOptions['renderer'];
|
|
253
387
|
}
|
|
254
388
|
interface UseChartReturn {
|
|
255
389
|
/** Ref to attach to the container div. */
|
|
@@ -349,28 +483,6 @@ interface UseTableStateOptions {
|
|
|
349
483
|
*/
|
|
350
484
|
declare function useTableState(initialState?: UseTableStateOptions): UseTableStateReturn;
|
|
351
485
|
|
|
352
|
-
interface MapProps {
|
|
353
|
-
/** The map spec to render. */
|
|
354
|
-
spec: MapSpec;
|
|
355
|
-
/** Theme overrides. */
|
|
356
|
-
theme?: ThemeConfig;
|
|
357
|
-
/** Dark mode: "auto", "force", or "off". */
|
|
358
|
-
darkMode?: DarkMode;
|
|
359
|
-
/** Callback when a map feature is clicked. */
|
|
360
|
-
onMarkClick?: (feature: MapMarkEvent) => void;
|
|
361
|
-
/** Callback when a map feature is hovered (null when hover ends). */
|
|
362
|
-
onMarkHover?: (feature: MapMarkEvent | null) => void;
|
|
363
|
-
/** CSS class name for the wrapper div. */
|
|
364
|
-
className?: string;
|
|
365
|
-
/** Inline styles for the wrapper div. */
|
|
366
|
-
style?: CSSProperties;
|
|
367
|
-
}
|
|
368
|
-
interface MapHandle {
|
|
369
|
-
/** The underlying map instance (null until mounted). */
|
|
370
|
-
readonly instance: MapInstance | null;
|
|
371
|
-
}
|
|
372
|
-
declare const GeoMap: react.ForwardRefExoticComponent<MapProps & react.RefAttributes<MapHandle>>;
|
|
373
|
-
|
|
374
486
|
interface SankeyProps {
|
|
375
487
|
/** The sankey spec to render. */
|
|
376
488
|
spec: SankeySpec;
|
|
@@ -477,4 +589,4 @@ interface VisualizationProps {
|
|
|
477
589
|
*/
|
|
478
590
|
declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps): react_jsx_runtime.JSX.Element;
|
|
479
591
|
|
|
480
|
-
export { BarList, type BarListHandle, type BarListProps, Chart, type ChartHandle, type ChartProps, ChartStory, type ChartStoryHandle, type ChartStoryProps, DataTable, type DataTableProps, GeoMap,
|
|
592
|
+
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 };
|