@opendata-ai/openchart-react 8.0.0-rc.8 → 8.0.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 +149 -43
- package/dist/index.js +294 -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 -341
- 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,79 @@ 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
|
+
/** Emphasize a set of nodes; eased via the focus model. */
|
|
230
|
+
highlight: (target: GraphHighlightTarget, opts?: {
|
|
231
|
+
dimOpacity?: number;
|
|
232
|
+
}) => void;
|
|
233
|
+
/** Clear any programmatic highlight (and legend toggles). */
|
|
234
|
+
clearHighlight: () => void;
|
|
235
|
+
/** The currently highlighted node ids, or null when nothing is highlighted. */
|
|
236
|
+
getHighlight: () => string[] | null;
|
|
237
|
+
/** Headless snapshot of the legend. */
|
|
238
|
+
getLegend: () => GraphLegendData | null;
|
|
239
|
+
/** Set the active category filter declaratively (replaces legend toggle state). */
|
|
240
|
+
setActiveCategories: (values: string[]) => void;
|
|
241
|
+
/** Current active category values (empty = all active, no filter). */
|
|
242
|
+
getActiveCategories: () => string[];
|
|
171
243
|
}
|
|
172
244
|
/** Handle exposed by Graph component via forwardRef. */
|
|
173
245
|
interface GraphHandle {
|
|
174
246
|
search: (query: string) => void;
|
|
175
247
|
clearSearch: () => void;
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
248
|
+
getSearchMatches: () => string[];
|
|
249
|
+
zoomToFit: (opts?: CameraFlightOptions & {
|
|
250
|
+
padding?: number;
|
|
251
|
+
}) => void;
|
|
252
|
+
zoomToNode: (nodeId: string, opts?: CameraFlightOptions & {
|
|
253
|
+
scale?: number;
|
|
254
|
+
}) => void;
|
|
255
|
+
flyTo: (target: {
|
|
256
|
+
x: number;
|
|
257
|
+
y: number;
|
|
258
|
+
k?: number;
|
|
259
|
+
}, opts?: CameraFlightOptions) => void;
|
|
260
|
+
centerAt: (x: number, y: number, opts?: CameraFlightOptions) => void;
|
|
261
|
+
getCamera: () => GraphCamera;
|
|
262
|
+
selectNode: (nodeId: string, opts?: {
|
|
263
|
+
fly?: boolean;
|
|
264
|
+
} & CameraFlightOptions) => void;
|
|
179
265
|
getSelectedNodes: () => string[];
|
|
266
|
+
highlight: (target: GraphHighlightTarget, opts?: {
|
|
267
|
+
dimOpacity?: number;
|
|
268
|
+
}) => void;
|
|
269
|
+
clearHighlight: () => void;
|
|
270
|
+
getHighlight: () => string[] | null;
|
|
271
|
+
getLegend: () => GraphLegendData | null;
|
|
272
|
+
setActiveCategories: (values: string[]) => void;
|
|
273
|
+
getActiveCategories: () => string[];
|
|
180
274
|
/** Re-compile encoding/legend/chrome without restarting the simulation. */
|
|
181
|
-
updateVisuals: (spec:
|
|
275
|
+
updateVisuals: (spec: GraphSpec) => void;
|
|
182
276
|
/** The underlying GraphInstance from the vanilla adapter. */
|
|
183
277
|
instance: GraphInstance | null;
|
|
184
278
|
}
|
|
@@ -193,6 +287,15 @@ interface GraphHandle {
|
|
|
193
287
|
*/
|
|
194
288
|
declare function useGraph(): UseGraphReturn;
|
|
195
289
|
|
|
290
|
+
/** Tooltip prop: `false` off, `true` default, or an object with a formatter. */
|
|
291
|
+
type GraphTooltipProp = boolean | {
|
|
292
|
+
formatter?: GraphTooltipFormatter;
|
|
293
|
+
};
|
|
294
|
+
/** Legend prop: `false` off, `true` default, or an object toggling interactivity/counts. */
|
|
295
|
+
type GraphLegendProp = boolean | {
|
|
296
|
+
interactive?: boolean;
|
|
297
|
+
counts?: boolean;
|
|
298
|
+
};
|
|
196
299
|
interface GraphProps {
|
|
197
300
|
/** The graph spec to render. */
|
|
198
301
|
spec: GraphSpec;
|
|
@@ -210,10 +313,33 @@ interface GraphProps {
|
|
|
210
313
|
onEdgeHover?: (edge: Record<string, unknown> | null) => void;
|
|
211
314
|
/** Callback when selection changes. */
|
|
212
315
|
onSelectionChange?: (nodeIds: string[]) => void;
|
|
213
|
-
/**
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
316
|
+
/** Fired when the user hovers a legend entry (null on leave). */
|
|
317
|
+
onLegendHover?: (entry: {
|
|
318
|
+
field: string;
|
|
319
|
+
value: string;
|
|
320
|
+
} | null) => void;
|
|
321
|
+
/** Fired when legend toggle state changes; `activeValues` is the active set (empty = all). */
|
|
322
|
+
onLegendToggle?: (activeValues: string[]) => void;
|
|
323
|
+
/** Fired whenever the highlight set changes (programmatic or legend), null when cleared. */
|
|
324
|
+
onHighlightChange?: (nodeIds: string[] | null) => void;
|
|
325
|
+
/** Camera change callback, rAF-coalesced (fires at most once per rendered frame). */
|
|
326
|
+
onCameraChange?: (camera: {
|
|
327
|
+
x: number;
|
|
328
|
+
y: number;
|
|
329
|
+
k: number;
|
|
330
|
+
}) => void;
|
|
331
|
+
/**
|
|
332
|
+
* Show built-in tooltip on node/edge hover. Defaults to true. Pass an object
|
|
333
|
+
* with a `formatter` to customize content.
|
|
334
|
+
*/
|
|
335
|
+
tooltip?: GraphTooltipProp;
|
|
336
|
+
/**
|
|
337
|
+
* Show built-in legend. Defaults to true. Pass `false` if you render your own,
|
|
338
|
+
* or an object to toggle interactivity/counts.
|
|
339
|
+
*/
|
|
340
|
+
legend?: GraphLegendProp;
|
|
341
|
+
/** Fit the graph to the viewport on the first tick. Default true. */
|
|
342
|
+
fitOnLoad?: boolean;
|
|
217
343
|
/** CSS class name for the wrapper div. */
|
|
218
344
|
className?: string;
|
|
219
345
|
/** Inline styles for the wrapper div. */
|
|
@@ -250,6 +376,8 @@ interface UseChartOptions {
|
|
|
250
376
|
onDataPointClick?: MountOptions['onDataPointClick'];
|
|
251
377
|
/** Enable responsive resizing. Defaults to true. */
|
|
252
378
|
responsive?: boolean;
|
|
379
|
+
/** Rendering backend for point marks; see the vanilla `MountOptions.renderer`. */
|
|
380
|
+
renderer?: MountOptions['renderer'];
|
|
253
381
|
}
|
|
254
382
|
interface UseChartReturn {
|
|
255
383
|
/** Ref to attach to the container div. */
|
|
@@ -349,28 +477,6 @@ interface UseTableStateOptions {
|
|
|
349
477
|
*/
|
|
350
478
|
declare function useTableState(initialState?: UseTableStateOptions): UseTableStateReturn;
|
|
351
479
|
|
|
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
480
|
interface SankeyProps {
|
|
375
481
|
/** The sankey spec to render. */
|
|
376
482
|
spec: SankeySpec;
|
|
@@ -477,4 +583,4 @@ interface VisualizationProps {
|
|
|
477
583
|
*/
|
|
478
584
|
declare function Visualization({ spec, theme, darkMode, className, style }: VisualizationProps): react_jsx_runtime.JSX.Element;
|
|
479
585
|
|
|
480
|
-
export { BarList, type BarListHandle, type BarListProps, Chart, type ChartHandle, type ChartProps, ChartStory, type ChartStoryHandle, type ChartStoryProps, DataTable, type DataTableProps, GeoMap,
|
|
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 };
|