import type { ApexGrid } from '../components/grid.js'; import type { ColumnConfiguration, Keys } from './types.js'; /** * Primitive cell values supported by the export pipeline. * * @remarks * Returned by the default formatter and accepted from user-supplied formatters. * `Date` is preserved (not stringified) so that XLSX export can write it as a * native date cell instead of inline text. */ export type ExportCellValue = string | number | boolean | Date | null | undefined; /** * Which row set should drive the export. * * - `'view'` (default) — post-filter, post-sort rows across all pages. * - `'all'` — the raw `data` array as supplied by the consumer. * - `'page'` — only the rows in the current page slice. * - `'selected'` — the current row selection (insertion order). */ export type ExportSource = 'view' | 'all' | 'page' | 'selected'; /** * Options shared by all export targets. */ export interface ExportOptions { /** Output filename, without extension. Defaults to `'data'`. */ filename?: string; /** Row set to export. Defaults to `'view'`. */ source?: ExportSource; /** * Column keys to include. When omitted, every visible non-hidden column with * `exportable !== false` is exported, in display order. */ columns?: ReadonlyArray>; /** Whether to emit a header row. Defaults to `true`. */ includeHeader?: boolean; /** * Per-cell value formatter. Receives the column configuration, the raw value * from the record, and the record itself. Return one of {@link ExportCellValue} * (return a `Date` to keep date typing in XLSX). */ formatter?: (column: ColumnConfiguration, value: unknown, row: T) => ExportCellValue; } /** * Options for {@link ApexGrid.exportToCSV}. */ export interface CSVExportOptions extends ExportOptions { /** Field delimiter. Defaults to `','`. */ delimiter?: string; /** * Prepend a UTF-8 byte-order mark so Excel auto-detects the encoding when * opening the file. Defaults to `true`. */ bom?: boolean; /** Line separator. Defaults to `'\r\n'` (RFC 4180). */ newline?: string; } /** * Describes an export format offered by the grid's toolbar menu. * * @remarks * The toolbar renders one menu item per entry returned by * {@link ApexGrid.exportFormats} and dispatches the chosen `id` to * {@link ApexGrid.exportAs}. The community grid offers `'csv'`; derived grids * (e.g. `apex-grid-enterprise`) extend the list (e.g. with `'xlsx'`). */ export interface ExportFormat { /** Stable format identifier, e.g. `'csv'`. */ id: string; /** Menu item label, e.g. `'Export CSV'`. */ label: string; } /** * Resolves the columns that should appear in the export, in display order. */ export declare function resolveExportColumns(grid: ApexGrid, opts: ExportOptions): Array>; /** * Resolves the rows that should appear in the export. */ export declare function resolveExportRows(grid: ApexGrid, source?: ExportSource): ReadonlyArray; /** * Returns the column's display label, used as the header cell value. */ export declare function getColumnLabel(column: ColumnConfiguration): string; /** * Default cell-value formatter. Mirrors the on-screen rendering for each * column type while keeping primitive types primitive (so number/boolean/date * survive into XLSX as native cells instead of strings). */ export declare function defaultExportFormat(column: ColumnConfiguration, value: unknown): ExportCellValue; /** * Resolves the export value for a single cell, applying the user-supplied * formatter when present and falling back to {@link defaultExportFormat}. */ export declare function resolveExportValue(column: ColumnConfiguration, row: T, opts: ExportOptions): ExportCellValue; /** Formats a `Date` into the configured date style for CSV output. */ export declare function formatDateForCSV(column: ColumnConfiguration, value: Date): string; /** * Builds the CSV string for the grid without triggering a download. * * @remarks * Useful when consumers want to ship the bytes through their own transport * (clipboard, HTTP upload). The {@link ApexGrid.exportToCSV} method calls * this and then triggers a browser download. */ export declare function buildCSV(grid: ApexGrid, opts?: CSVExportOptions): string; /** * Triggers a browser download for the given payload. * * @remarks * Falls back to a no-op when called outside the browser (during SSR or unit * tests on JSDOM without a body), so consumers can still call the public * export API safely. */ export declare function downloadBlob(filename: string, content: string | Uint8Array, mimeType: string): void;