/** * The **Export Service** — the orchestrator behind `GridApi.export()`. * * It owns the whole export flow and nothing else: merge options over the grid's * defaults, resolve a {@link GridExporter} from the registry, prepare the data * once, hand it to the exporter, and report the outcome as events, callbacks * and (for a missing optional exporter) a toast. * * The one piece of real policy here is what happens when Excel or PDF is asked * for and no exporter has been registered. Photon Grid Core cannot bundle * `xlsx` or `jspdf` without breaking its zero-dependency contract, and it * deliberately does not dynamically import them either — so the honest failure * is a message that names the format, the packages and the registration step, * shown through the grid's own toast system rather than thrown as an opaque * `TypeError` from somewhere deep in a menu handler. * * @packageDocumentation */ import type { EventBus } from '../event-bus/event-bus'; import type { ToastService } from '../toast/toast-service'; import type { ExportDataSource, ExportFeatureConfig, ExportFormat, ExportOptions, GridExporter, PreparedExportData } from './export.types'; /** Formats offered by the Export menu when the host names none. */ export declare const DEFAULT_EXPORT_FORMATS: readonly ExportFormat[]; /** Collaborators the service needs, injected as a DI bag. */ export interface ExportServiceDeps { /** Read-only view of the grid's rows, columns and formatting settings. */ readonly source: ExportDataSource; /** The grid event bus — `EXPORT_START` / `EXPORT_COMPLETE` / `EXPORT_ERROR`. */ readonly eventBus: EventBus; /** * The grid's toast service, resolved lazily. A function rather than the * instance so the service can be constructed before the toast layer's host * exists, matching how the editing services take theirs. */ readonly getToasts?: () => ToastService | null; /** The grid's `GridOptions.export`, re-read on every call so it stays live. */ readonly getConfig?: () => ExportFeatureConfig | undefined; } /** * Runs exports for one grid. * * Holds a grid-local {@link ExporterRegistry} chained to the global one, so * `gridApi.registerExporter(...)` affects this grid while * `registerExporter(...)` affects the page. */ export declare class ExportService { private readonly deps; private readonly registry; private readonly preparer; constructor(deps: ExportServiceDeps); /** Registers an exporter for this grid only. Outranks a global registration. */ registerExporter(format: ExportFormat, exporter: GridExporter): void; /** Removes a grid-local registration, revealing any global one again. */ unregisterExporter(format: ExportFormat): boolean; /** Whether this grid can export the format (grid-local, then global). */ hasExporter(format: ExportFormat): boolean; /** Resolves the exporter this grid would use, or `undefined`. */ getExporter(format: ExportFormat): GridExporter | undefined; /** Every format this grid can export, sorted. */ getFormats(): ExportFormat[]; /** The formats the Export menu should offer, in configured order. */ getMenuFormats(): readonly ExportFormat[]; /** * Prepares the export payload without writing a file. * * Useful for hosts that want to post the data somewhere rather than download * it, and for testing an exporter against real grid state. * * @param options - Scope and hook options; merged over the grid defaults. */ prepare(options?: ExportOptions): PreparedExportData; /** * Exports the grid in `format`. * * @param format - `'csv'`, `'json'`, `'excel'`, `'pdf'`, or any registered format. * @param options - Per-call options, merged over `GridOptions.export`. * @returns Resolves once the exporter has finished. * @throws {ExportError} With {@link ExportErrorCode.ExporterNotRegistered} * when the format has no exporter, or * {@link ExportErrorCode.ExporterFailed} when the exporter threw. Both are * reported as an `EXPORT_ERROR` event and (for the former) a toast before * the promise rejects, so a caller that does not care can safely ignore it. */ export(format: ExportFormat, options?: ExportOptions): Promise; /** * Reports a failure through every channel, then hands the error back so the * caller can `throw` it — one place that knows a failure means *event + * callback + toast*, rather than three call sites each remembering two of them. */ private fail; /** * Layers per-call options over the grid's format-specific defaults, then its * global defaults, and resolves the file name. * * Precedence, highest first: the call → `GridOptions.export.` → * `GridOptions.export`. */ private resolveOptions; } //# sourceMappingURL=export-service.d.ts.map