import { type Readable } from 'svelte/store'; import type { TablePlugin } from '../types/TablePlugin.js'; /** * Supported export formats for the data export plugin. */ export type DataExportFormat = 'object' | 'json' | 'csv'; /** * Maps export formats to their output types. * @internal */ type ExportForFormat = { object: Record[]; json: string; csv: string; }; /** * The export output type based on the format. * * @template F - The export format. */ export type DataExport = ExportForFormat[F]; /** * Configuration options for the addDataExport plugin. * * @template F - The export format type. */ export interface DataExportConfig { /** Key used for nested children in hierarchical exports. Defaults to 'children'. */ childrenKey?: string; /** Export format: 'object', 'json', or 'csv'. Defaults to 'object'. */ format?: F; } /** * State exposed by the addDataExport plugin. * * @template F - The export format type. */ export interface DataExportState { /** Readable store containing the exported data in the specified format. */ exportedData: Readable>; } /** * Per-column configuration options for data export. */ export interface DataExportColumnOptions { /** If true, this column is excluded from exports. */ exclude?: boolean; } /** * Creates a data export plugin that provides reactive exports of table data. * Supports exporting to objects, JSON, or CSV formats. * * @template Item - The type of data items in the table. * @template F - The export format type. * @param config - Configuration options. * @returns A TablePlugin that provides data export functionality. * @example * ```typescript * const table = createTable(data, { * export: addDataExport({ * format: 'csv', * childrenKey: 'subItems' * }) * }) * * // Access exported data * const { exportedData } = table.pluginStates.export * $: csvData = $exportedData * ``` */ export declare const addDataExport: ({ format, childrenKey }?: DataExportConfig) => TablePlugin, DataExportColumnOptions>; export {};