@opendata-ai/openchart-vanilla 6.3.0 → 6.5.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 +53 -5
- package/dist/index.js +897 -168
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -764
- package/package.json +3 -3
- package/src/__tests__/animation.test.ts +358 -0
- package/src/__tests__/edit-events.test.ts +35 -35
- package/src/__tests__/events.test.ts +7 -7
- package/src/__tests__/export.test.ts +1 -1
- package/src/__tests__/mount.test.ts +10 -10
- package/src/__tests__/selection-events.test.ts +869 -0
- package/src/__tests__/svg-renderer.test.ts +67 -67
- package/src/__tests__/table-keyboard.test.ts +18 -18
- package/src/__tests__/table-mount.test.ts +138 -17
- package/src/__tests__/tooltip.test.ts +12 -12
- package/src/animation.ts +75 -0
- package/src/graph/__tests__/graph-mount.test.ts +16 -16
- package/src/graph-mount.ts +18 -18
- package/src/index.ts +3 -1
- package/src/mount.ts +668 -30
- package/src/renderers/table-cells.ts +11 -9
- package/src/svg-renderer.ts +164 -54
- package/src/table-keyboard.ts +5 -5
- package/src/table-mount.ts +34 -11
- package/src/table-renderer.ts +70 -39
- package/src/text-edit-overlay.ts +255 -0
- package/src/tooltip.ts +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ChartLayout, ChartSpec, CompileOptions, TableLayout, TableSpec, VizSpec } from '@opendata-ai/openchart-engine';
|
|
2
|
-
import { GraphSpec, ThemeConfig, DarkMode, ChartSpec, LayerSpec, ChartLayout, ChartEventHandlers, BarTableCell, CategoryTableCell, TableCell, FlagTableCell, HeatmapTableCell, ImageTableCell, SparklineTableCell, TextTableCell, Mark, TableSpec, SortState, TableLayout, TooltipContent } from '@opendata-ai/openchart-core';
|
|
2
|
+
import { GraphSpec, ThemeConfig, DarkMode, ChartSpec, LayerSpec, ElementRef, ChartLayout, ChartEventHandlers, BarTableCell, CategoryTableCell, TableCell, FlagTableCell, HeatmapTableCell, ImageTableCell, SparklineTableCell, TextTableCell, Mark, TableSpec, SortState, TableLayout, TooltipContent } from '@opendata-ai/openchart-core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Export utilities: serialize charts to SVG, PNG, JPG, or CSV.
|
|
@@ -151,12 +151,18 @@ interface MountOptions extends ChartEventHandlers {
|
|
|
151
151
|
onDataPointClick?: (data: Record<string, unknown>) => void;
|
|
152
152
|
/** Enable responsive resizing. Defaults to true. */
|
|
153
153
|
responsive?: boolean;
|
|
154
|
+
/** Initial selected element. */
|
|
155
|
+
selectedElement?: ElementRef;
|
|
156
|
+
}
|
|
157
|
+
interface UpdateOptions {
|
|
158
|
+
/** Override the selected element after update. When omitted, preserves current selection. */
|
|
159
|
+
selectedElement?: ElementRef;
|
|
154
160
|
}
|
|
155
161
|
interface ExportOptions extends JPGExportOptions {
|
|
156
162
|
}
|
|
157
163
|
interface ChartInstance {
|
|
158
164
|
/** Re-compile and re-render with a new spec. */
|
|
159
|
-
update(spec: ChartSpec | LayerSpec | GraphSpec): void;
|
|
165
|
+
update(spec: ChartSpec | LayerSpec | GraphSpec, options?: UpdateOptions): void;
|
|
160
166
|
/** Re-compile at current container dimensions. */
|
|
161
167
|
resize(): void;
|
|
162
168
|
/** Export the chart. */
|
|
@@ -170,6 +176,14 @@ interface ChartInstance {
|
|
|
170
176
|
destroy(): void;
|
|
171
177
|
/** The current compiled layout (for hooks / debugging). */
|
|
172
178
|
readonly layout: ChartLayout;
|
|
179
|
+
/** Get the currently selected element, or null if none. */
|
|
180
|
+
getSelectedElement(): ElementRef | null;
|
|
181
|
+
/** Programmatically select an element. Silent no-op if element not found. */
|
|
182
|
+
select(ref: ElementRef): void;
|
|
183
|
+
/** Deselect the current element. */
|
|
184
|
+
deselect(): void;
|
|
185
|
+
/** Whether inline text editing is active. */
|
|
186
|
+
readonly isEditing: boolean;
|
|
173
187
|
}
|
|
174
188
|
/**
|
|
175
189
|
* Create a chart instance from a spec and mount it into a container.
|
|
@@ -245,7 +259,9 @@ declare function registerMarkRenderer<T extends Mark>(type: T['type'], renderer:
|
|
|
245
259
|
* @param container - DOM element to mount the SVG into.
|
|
246
260
|
* @returns The created SVG element.
|
|
247
261
|
*/
|
|
248
|
-
declare function renderChartSVG(layout: ChartLayout, container: HTMLElement
|
|
262
|
+
declare function renderChartSVG(layout: ChartLayout, container: HTMLElement, opts?: {
|
|
263
|
+
animate?: boolean;
|
|
264
|
+
}): SVGElement;
|
|
249
265
|
|
|
250
266
|
/**
|
|
251
267
|
* Table keyboard navigation: arrow-key cell navigation, Enter to sort,
|
|
@@ -326,6 +342,11 @@ declare function createTable(container: HTMLElement, spec: TableSpec, options?:
|
|
|
326
342
|
* The returned element replaces or appends to the given container.
|
|
327
343
|
*/
|
|
328
344
|
|
|
345
|
+
/** Options for renderTable(). */
|
|
346
|
+
interface TableRenderOptions {
|
|
347
|
+
/** Whether to apply entrance animation on this render. */
|
|
348
|
+
animate?: boolean;
|
|
349
|
+
}
|
|
329
350
|
/**
|
|
330
351
|
* Render a TableLayout into a full DOM structure.
|
|
331
352
|
*
|
|
@@ -333,7 +354,34 @@ declare function createTable(container: HTMLElement, spec: TableSpec, options?:
|
|
|
333
354
|
* @param container - The container element to render into.
|
|
334
355
|
* @returns The wrapper element that was created.
|
|
335
356
|
*/
|
|
336
|
-
declare function renderTable(layout: TableLayout, container: HTMLElement): HTMLElement;
|
|
357
|
+
declare function renderTable(layout: TableLayout, container: HTMLElement, opts?: TableRenderOptions): HTMLElement;
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Text edit overlay: creates a positioned textarea over an SVG text element
|
|
361
|
+
* for inline editing. Handles commit (Enter), cancel (Escape), and
|
|
362
|
+
* click-outside-to-commit behavior.
|
|
363
|
+
*/
|
|
364
|
+
interface TextEditOverlayConfig {
|
|
365
|
+
/** The container div that holds the SVG. */
|
|
366
|
+
container: HTMLElement;
|
|
367
|
+
/** The root SVG element. */
|
|
368
|
+
svg: SVGSVGElement;
|
|
369
|
+
/** The SVG text element being edited. */
|
|
370
|
+
targetElement: SVGElement;
|
|
371
|
+
/** Current text content to populate the textarea. */
|
|
372
|
+
currentText: string;
|
|
373
|
+
/** Called when the user commits the edit (Enter or click outside). */
|
|
374
|
+
onCommit: (newText: string) => void;
|
|
375
|
+
/** Called when the user cancels the edit (Escape). */
|
|
376
|
+
onCancel: () => void;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Create an inline text editing overlay positioned over an SVG text element.
|
|
380
|
+
* Returns an object with a `destroy()` method to clean up.
|
|
381
|
+
*/
|
|
382
|
+
declare function createTextEditOverlay(config: TextEditOverlayConfig): {
|
|
383
|
+
destroy: () => void;
|
|
384
|
+
};
|
|
337
385
|
|
|
338
386
|
/**
|
|
339
387
|
* Tooltip manager: creates and positions a floating tooltip element.
|
|
@@ -363,4 +411,4 @@ interface TooltipManager {
|
|
|
363
411
|
*/
|
|
364
412
|
declare function createTooltipManager(container: HTMLElement): TooltipManager;
|
|
365
413
|
|
|
366
|
-
export { type ChartInstance, type ExportOptions, type GraphInstance, type GraphMountOptions, type JPGExportOptions, type KeyboardNavOptions, type MountOptions, type PNGExportOptions, type SVGExportOptions, type TableInstance, type TableMountOptions, type TableState, type TooltipManager, attachKeyboardNav, createChart, createGraph, createSimulationWorker, createTable, createTooltipManager, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, observeResize, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|
|
414
|
+
export { type ChartInstance, type ExportOptions, type GraphInstance, type GraphMountOptions, type JPGExportOptions, type KeyboardNavOptions, type MountOptions, type PNGExportOptions, type SVGExportOptions, type TableInstance, type TableMountOptions, type TableState, type TextEditOverlayConfig, type TooltipManager, type UpdateOptions, attachKeyboardNav, createChart, createGraph, createSimulationWorker, createTable, createTextEditOverlay, createTooltipManager, exportCSV, exportJPG, exportPNG, exportSVG, exportSVGWithFonts, observeResize, registerMarkRenderer, renderBarCell, renderCategoryCell, renderCell, renderChartSVG, renderFlagCell, renderHeatmapCell, renderImageCell, renderSparklineCell, renderTable, renderTextCell };
|