@opendata-ai/openchart-vanilla 6.2.1 → 6.4.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/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.
@@ -335,6 +349,33 @@ declare function createTable(container: HTMLElement, spec: TableSpec, options?:
335
349
  */
336
350
  declare function renderTable(layout: TableLayout, container: HTMLElement): HTMLElement;
337
351
 
352
+ /**
353
+ * Text edit overlay: creates a positioned textarea over an SVG text element
354
+ * for inline editing. Handles commit (Enter), cancel (Escape), and
355
+ * click-outside-to-commit behavior.
356
+ */
357
+ interface TextEditOverlayConfig {
358
+ /** The container div that holds the SVG. */
359
+ container: HTMLElement;
360
+ /** The root SVG element. */
361
+ svg: SVGSVGElement;
362
+ /** The SVG text element being edited. */
363
+ targetElement: SVGElement;
364
+ /** Current text content to populate the textarea. */
365
+ currentText: string;
366
+ /** Called when the user commits the edit (Enter or click outside). */
367
+ onCommit: (newText: string) => void;
368
+ /** Called when the user cancels the edit (Escape). */
369
+ onCancel: () => void;
370
+ }
371
+ /**
372
+ * Create an inline text editing overlay positioned over an SVG text element.
373
+ * Returns an object with a `destroy()` method to clean up.
374
+ */
375
+ declare function createTextEditOverlay(config: TextEditOverlayConfig): {
376
+ destroy: () => void;
377
+ };
378
+
338
379
  /**
339
380
  * Tooltip manager: creates and positions a floating tooltip element.
340
381
  *
@@ -363,4 +404,4 @@ interface TooltipManager {
363
404
  */
364
405
  declare function createTooltipManager(container: HTMLElement): TooltipManager;
365
406
 
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 };
407
+ 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 };