@kanunilabs/pivotgrid-core 1.0.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.
@@ -0,0 +1,787 @@
1
+ import { P as PivotField, a as PivotControllerState, b as PivotLayoutState, c as PivotSelectionStats, d as PivotImportStatus, e as PivotControllerOptions, f as PivotEngineResult, F as FieldMoveEvent, C as CellClickEvent, E as ExportingEvent, g as PivotArea, D as DropIntent, h as PivotImportField, i as ExportFormat, j as ExportOptions, k as PivotCell, l as PivotDragIntentState, m as PivotReport, n as PivotReportState, o as PivotSelectionMode, p as PivotSelectionState, q as PivotCellValueAccessor, r as PivotCellTextAccessor, s as PivotPrefilter, t as PivotNode, u as PivotEngineRegistry, v as PivotValue, w as PivotConditionRule, x as PivotDictionary } from './pivot.worker-DQFl4fMu.js';
2
+ export { y as CellPreparedEvent, z as CustomSummaryOptions, A as FieldDistinctEntry, B as FilterCondition, G as FilterGroup, H as FilterOperator, I as FlatCellMatrix, J as FlatPivotEngine, K as FlatRow, L as PivotCellTemplate, M as PivotControllerCallbacks, N as PivotDataSource, O as PivotGridRef, Q as PivotGroupInterval, R as PivotImportPreviewState, S as PivotLayoutProfile, T as PivotLocale, U as PivotPlugin, V as PivotSelectionRange, W as PivotStateStoringConfig, X as PivotSummaryDisplayMode, Y as PivotSummaryType, Z as PivotTheme, _ as PivotToolbarConfig, $ as PrefilterConditionSpec, a0 as PrefilterGroupSpec, a1 as WorkerComputeRequest, a2 as WorkerFilterRequest, a3 as WorkerFilterSpec, a4 as WorkerInitRequest, a5 as WorkerResponse, a6 as buildCellLookup, a7 as buildColPathsList, a8 as buildColumnHeaders, a9 as buildPivotAOA, aa as buildRowLabelCells, ab as computePivotMatrixAsync, ac as cssColorToRgb, ad as defaultPivotLayout, ae as destroyEngineWorker, af as escapeXmlText, ag as exportPivotData, ah as filterEmptySummaryTree, ai as filterPivotEngineAsync, aj as flattenExportRows, ak as flattenRowTree, al as flattenRowTreeTabular, am as flattenRowTreeTree, an as formatHeaderValue, ao as getCellVal, ap as getFieldDistinctValues, aq as getVisibleColLeaves, ar as getVisibleLeafCount, as as getVisibleMaxDepth, at as initPivotEngineAsync, au as reconfigurePivotEngineAsync, av as resolveColPath, aw as setActiveEngineGrid } from './pivot.worker-DQFl4fMu.js';
3
+
4
+ type PivotStateListener = () => void;
5
+ /** Immutable-snapshot state store with debounced localStorage persistence. */
6
+ declare class PivotStateStore<TRow> {
7
+ private snapshot;
8
+ private listeners;
9
+ private storageKey;
10
+ private persistScheduled;
11
+ constructor(gridId: string, initialFields: PivotField<TRow>[]);
12
+ getSnapshot: () => PivotControllerState<TRow>;
13
+ subscribe: (listener: PivotStateListener) => (() => void);
14
+ setState(updates: Partial<PivotControllerState<TRow>>): void;
15
+ setFields(fields: PivotField<TRow>[]): void;
16
+ setLayout(updates: Partial<PivotLayoutState>): void;
17
+ setExpandedPaths(paths: string[] | Set<string>): void;
18
+ setExpandedColPaths(paths: string[] | Set<string>): void;
19
+ setSelectionStats(selectionStats: PivotSelectionStats | null): void;
20
+ setImportStatus(importStatus: PivotImportStatus): void;
21
+ setImportPreview(importPreview: PivotControllerState<TRow>['importPreview']): void;
22
+ private createInitialSnapshot;
23
+ private schedulePersist;
24
+ private persist;
25
+ }
26
+
27
+ interface PivotControllerEvents<TRow> {
28
+ stateChanged: PivotControllerState<TRow>;
29
+ engineStarted: {
30
+ gridId: string;
31
+ };
32
+ engineCompleted: PivotEngineResult;
33
+ engineError: Error;
34
+ fieldMove: FieldMoveEvent;
35
+ cellClick: CellClickEvent<TRow>;
36
+ reportChanged: {
37
+ activeReportId: string | null;
38
+ };
39
+ exporting: ExportingEvent;
40
+ }
41
+ interface PivotImportLabels {
42
+ initializing: string;
43
+ processing: string;
44
+ importError: string;
45
+ importWarning: string;
46
+ importSuccess: string;
47
+ dataImportUnsupported: string;
48
+ /** Shown when the user cancels an in-flight import. Optional (falls back to a default). */
49
+ cancelled?: string;
50
+ /** Cancel-button caption in the import progress dialog. Optional. */
51
+ cancel?: string;
52
+ }
53
+ /**
54
+ * Framework-agnostic pivot grid controller.
55
+ *
56
+ * Orchestrates field management, engine computation (via Web Worker),
57
+ * state persistence, export, and event emission. Consumed by React/Angular adapters.
58
+ *
59
+ * @typeParam TRow - Shape of source data rows.
60
+ */
61
+ declare class PivotController<TRow> {
62
+ private store;
63
+ private events;
64
+ private options;
65
+ private reportService;
66
+ private engineService;
67
+ private importManager;
68
+ private importAbort?;
69
+ /** Full row set of a parsed import awaiting preview commit (kept out of observable state). */
70
+ private pendingImportRows;
71
+ private disposed;
72
+ constructor(options: PivotControllerOptions<TRow>);
73
+ subscribe: (listener: PivotStateListener) => (() => void);
74
+ getSnapshot: () => PivotControllerState<TRow>;
75
+ getState(): PivotControllerState<TRow>;
76
+ on<K extends keyof PivotControllerEvents<TRow>>(eventName: K, handler: (payload: PivotControllerEvents<TRow>[K]) => void): () => void;
77
+ updateOptions(options: Partial<PivotControllerOptions<TRow>>): void;
78
+ setFields(fields: PivotField<TRow>[]): void;
79
+ updateField(updatedField: PivotField<TRow>): void;
80
+ deleteField(fieldId: string): void;
81
+ changeFieldArea(fieldId: string, area: PivotArea): void;
82
+ removeField(fieldId: string): void;
83
+ moveField(fieldId: string, direction: 'start' | 'end' | 'left' | 'right'): void;
84
+ sortField(fieldId: string, direction: 'asc' | 'desc' | undefined): void;
85
+ sortFieldBySummary(rowFieldId: string, summaryFieldId: string, colPath: string): void;
86
+ clearAllSorting(): void;
87
+ applyFilter(fieldId: string, selectedValues: Set<any>, filterType: 'include' | 'exclude'): void;
88
+ clearFilter(fieldId: string): void;
89
+ setLayout(updates: Partial<PivotLayoutState>): void;
90
+ toggleExpanded(path: string): void;
91
+ expandPaths(paths: string[]): void;
92
+ collapsePaths(paths: string[]): void;
93
+ setExpandedPaths(paths: string[]): void;
94
+ toggleColExpanded(path: string): void;
95
+ expandColPaths(paths: string[]): void;
96
+ collapseColPaths(paths: string[]): void;
97
+ setExpandedColPaths(paths: string[]): void;
98
+ expandAll(): void;
99
+ collapseAll(): void;
100
+ setColumnWidths(widths: Record<string, number>): void;
101
+ setSelectionStats(selectionStats: PivotSelectionStats | null): void;
102
+ setDragActive(activeId: string | null): void;
103
+ setDragIntent(targetId: string | null, targetArea: string | null, intent: DropIntent): void;
104
+ resetDrag(): void;
105
+ calculateDropIntent(pointerX: number, pointerY: number, itemRect: {
106
+ width: number;
107
+ height: number;
108
+ left: number;
109
+ top: number;
110
+ }, previousIntent: DropIntent, isLastItem: boolean, orientation: 'horizontal' | 'vertical'): DropIntent;
111
+ commitDrag(fieldId: string, overId: string | null): Promise<void>;
112
+ /** Import a single uploaded file (worker-streamed for CSV/JSON/XML). */
113
+ importFile(file: File, labels: PivotImportLabels): Promise<void>;
114
+ /** Import one or more files at once, appending their rows (union fields). */
115
+ importFiles(files: FileList | File[], labels: PivotImportLabels): Promise<void>;
116
+ /** Import data fetched from a URL / backend API endpoint. */
117
+ importFromUrl(url: string, labels: PivotImportLabels, fetchInit?: RequestInit): Promise<void>;
118
+ /** Import an already-materialized array of rows (e.g. an API response). */
119
+ importData(rows: any[], labels: PivotImportLabels): Promise<void>;
120
+ /** Import delimited text pasted from the clipboard (auto-detects CSV/TSV). */
121
+ importText(text: string, labels: PivotImportLabels): Promise<void>;
122
+ /**
123
+ * Shared import driver: manages the abort/progress lifecycle and status
124
+ * dialog around any import source (`task` performs the actual parse).
125
+ */
126
+ private runImport;
127
+ /** Cancel an in-flight import started by {@link importFile}/{@link importFiles}/{@link importFromUrl}. */
128
+ cancelImport(): void;
129
+ /** Show a terminal import status message (e.g. clipboard empty / permission denied). */
130
+ showImportStatus(status: 'success' | 'error' | 'warning', title: string, messages: string[]): void;
131
+ /** Stash a parsed import and open the preview/column-mapping step. */
132
+ private openImportPreview;
133
+ /**
134
+ * Commit a previewed import using the reviewed column plan (include/exclude,
135
+ * caption + type overrides). Columns whose type changed are re-coerced.
136
+ */
137
+ commitImport(plan: (PivotImportField & {
138
+ include?: boolean;
139
+ })[] | undefined, labels: PivotImportLabels): void;
140
+ /** Discard a pending previewed import without applying it. */
141
+ cancelImportPreview(): void;
142
+ private showImportCancelled;
143
+ closeImportStatus(): void;
144
+ saveReport(name: string, isDefault: boolean): void;
145
+ updateCurrentReport(): void;
146
+ loadReport(id: string): void;
147
+ deleteReport(id: string): void;
148
+ setDefaultReport(id: string): void;
149
+ refreshEngine(): void;
150
+ exportData(format: ExportFormat | string, options?: ExportOptions): Promise<void>;
151
+ getRawData(): TRow[];
152
+ getEngineResult(): PivotEngineResult | null;
153
+ getCell(rowPath: string[], colPath: string[]): PivotCell | null;
154
+ resolveCellClick(event: CellClickEvent<TRow>): CellClickEvent<TRow>;
155
+ getAreaFields(area: PivotArea): PivotField<TRow>[];
156
+ private cellIndexLookups;
157
+ private getCellIndexLookup;
158
+ dispose(): void;
159
+ private normalizeOptions;
160
+ private setState;
161
+ private emitState;
162
+ private commitFields;
163
+ private setDragState;
164
+ private setImportStatus;
165
+ private loadDefaultReport;
166
+ private createReportState;
167
+ private applyReportState;
168
+ private collectNodePaths;
169
+ }
170
+
171
+ interface PivotEngineServiceConfig<TRow> {
172
+ getOptions: () => PivotControllerOptions<TRow>;
173
+ getState: () => PivotControllerState<TRow>;
174
+ getAreaFields: (area: PivotArea) => PivotField<TRow>[];
175
+ setState: (updates: Partial<PivotControllerState<TRow>>) => void;
176
+ onEngineStarted: (payload: {
177
+ gridId: string;
178
+ }) => void;
179
+ onEngineCompleted: (result: PivotEngineResult) => void;
180
+ onEngineError: (error: Error) => void;
181
+ }
182
+ declare class PivotEngineService<TRow> {
183
+ private config;
184
+ private initTimeout;
185
+ private computeTimeout;
186
+ private progressTimer;
187
+ private progressCompletionTimer;
188
+ private progressStartedAt;
189
+ private progressStartValue;
190
+ private progressCap;
191
+ private progressEstimateMs;
192
+ private initVersion;
193
+ private computeVersion;
194
+ private disposed;
195
+ private isInitComplete;
196
+ private forceNextReencode;
197
+ private hashes;
198
+ constructor(config: PivotEngineServiceConfig<TRow>);
199
+ refresh(): void;
200
+ refreshData(): void;
201
+ computeIfReady(): void;
202
+ dispose(): void;
203
+ private scheduleInit;
204
+ private runInit;
205
+ private scheduleReconfigure;
206
+ private runReconfigure;
207
+ private scheduleFilter;
208
+ private runFilter;
209
+ private scheduleComputeIfReady;
210
+ private runCompute;
211
+ /**
212
+ * Produce a fully-expanded engine snapshot on demand, WITHOUT mutating the
213
+ * grid's live state. Used by `expandAll` exports: the cached engineResult
214
+ * only contains nodes visible under the current expand/collapse state (the
215
+ * worker prunes collapsed subtrees and their cells), so a naive
216
+ * "expand everything" over that snapshot would silently drop collapsed rows.
217
+ * This requests a fresh worker compute with every path expanded and re-runs
218
+ * the same post-aggregation, sort and display-mode phases as {@link runCompute}
219
+ * so the result is identical in shape to what the grid would render if the
220
+ * user expanded all nodes manually.
221
+ */
222
+ computeFullyExpandedSnapshot(): Promise<PivotEngineResult>;
223
+ private startBuildProgress;
224
+ private tickBuildProgress;
225
+ private advanceBuildProgress;
226
+ private completeBuildProgress;
227
+ private stopBuildProgress;
228
+ private initialProgressFor;
229
+ private progressCapFor;
230
+ private estimateProgressDuration;
231
+ private handleEngineError;
232
+ private createStructuralFieldsHash;
233
+ private createFieldsHash;
234
+ private createFilterHash;
235
+ private serializeFilterValue;
236
+ private setHashCache;
237
+ private createSetHash;
238
+ }
239
+
240
+ interface FieldDropCommand {
241
+ fieldId: string;
242
+ overId: string | null;
243
+ dragIntent: PivotDragIntentState;
244
+ validateMove?: (event: FieldMoveEvent) => void | Promise<void>;
245
+ }
246
+ interface DropIntentRect {
247
+ width: number;
248
+ height: number;
249
+ left: number;
250
+ top: number;
251
+ }
252
+ declare class PivotFieldService {
253
+ static normalizeAreaIndexes<TRow>(fields: PivotField<TRow>[]): PivotField<TRow>[];
254
+ static sortField<TRow>(fields: PivotField<TRow>[], fieldId: string, direction: 'asc' | 'desc' | undefined): PivotField<TRow>[];
255
+ static sortFieldBySummary<TRow>(fields: PivotField<TRow>[], rowFieldId: string, summaryFieldId: string, colPath: string): PivotField<TRow>[];
256
+ static clearAllSorting<TRow>(fields: PivotField<TRow>[]): PivotField<TRow>[];
257
+ static updateField<TRow>(fields: PivotField<TRow>[], updatedField: PivotField<TRow>): PivotField<TRow>[];
258
+ static applyFilter<TRow>(fields: PivotField<TRow>[], fieldId: string, selectedValues: Set<any>, filterType: 'include' | 'exclude'): PivotField<TRow>[];
259
+ static clearFilter<TRow>(fields: PivotField<TRow>[], fieldId: string): PivotField<TRow>[];
260
+ static removeField<TRow>(fields: PivotField<TRow>[], fieldId: string): PivotField<TRow>[];
261
+ static deleteField<TRow>(fields: PivotField<TRow>[], fieldId: string): PivotField<TRow>[];
262
+ static changeFieldArea<TRow>(fields: PivotField<TRow>[], fieldId: string, area: PivotArea): PivotField<TRow>[];
263
+ static moveFieldByDirection<TRow>(fields: PivotField<TRow>[], fieldId: string, direction: 'start' | 'end' | 'left' | 'right'): PivotField<TRow>[];
264
+ static moveFieldFromDrop<TRow>(fields: PivotField<TRow>[], command: FieldDropCommand): Promise<PivotField<TRow>[]>;
265
+ static calculateDropIntent(pointerX: number, pointerY: number, itemRect: DropIntentRect, previousIntent: DropIntent, isLastItem: boolean, orientation?: 'horizontal' | 'vertical'): DropIntent;
266
+ private static isArea;
267
+ }
268
+
269
+ interface PivotExportServiceOptions<TRow> {
270
+ format: ExportFormat | string;
271
+ exportOptions?: ExportOptions;
272
+ controllerOptions: PivotControllerOptions<TRow>;
273
+ state: PivotControllerState<TRow>;
274
+ emitExporting: (event: ExportingEvent) => void;
275
+ }
276
+ declare class PivotExportService {
277
+ static exportData<TRow>({ format, exportOptions, controllerOptions, state, emitExporting }: PivotExportServiceOptions<TRow>): Promise<void>;
278
+ }
279
+
280
+ declare class PivotReportService {
281
+ private manager;
282
+ constructor(gridId: string);
283
+ getReports(): PivotReport[];
284
+ getDefaultReport(): PivotReport | null;
285
+ saveReport(name: string, state: PivotReportState, isDefault: boolean): PivotReport;
286
+ updateReport(id: string, state: PivotReportState): PivotReport | null;
287
+ deleteReport(id: string): PivotReport[];
288
+ setDefaultReport(id: string): PivotReport[];
289
+ }
290
+
291
+ declare class PivotSelectionModel {
292
+ static start(row: number, column: number, mode: PivotSelectionMode): PivotSelectionState;
293
+ static extend(state: PivotSelectionState | null, row: number, column: number, mode: PivotSelectionMode): PivotSelectionState | null;
294
+ static finish(state: PivotSelectionState | null): PivotSelectionState | null;
295
+ static containsCell(state: PivotSelectionState | null, row: number, column: number): boolean;
296
+ static calculateStats(state: PivotSelectionState | null, valueAccessor: PivotCellValueAccessor): PivotSelectionStats | null;
297
+ static toTsv(state: PivotSelectionState | null, textAccessor: PivotCellTextAccessor): string;
298
+ private static getBounds;
299
+ }
300
+
301
+ type PivotEventMap = Record<string, any>;
302
+ type PivotEventHandler<TPayload> = (payload: TPayload) => void;
303
+ declare class PivotEventEmitter<TEvents extends PivotEventMap> {
304
+ private handlers;
305
+ on<K extends keyof TEvents>(eventName: K, handler: PivotEventHandler<TEvents[K]>): () => void;
306
+ off<K extends keyof TEvents>(eventName: K, handler: PivotEventHandler<TEvents[K]>): void;
307
+ emit<K extends keyof TEvents>(eventName: K, payload: TEvents[K]): void;
308
+ clear(): void;
309
+ }
310
+
311
+ declare const MAX_C = 67108864;
312
+ declare function cellHash(rId: number, cId: number): number;
313
+ declare function cellHashRow(hash: number): number;
314
+ declare function cellHashCol(hash: number): number;
315
+
316
+ declare class PivotCellAggregator<TRow> {
317
+ private accumulators;
318
+ private dataFields;
319
+ constructor(dataFields: PivotField<TRow>[]);
320
+ push(index: number, columnarData: Record<string, {
321
+ type: 'int32' | 'float64';
322
+ array: Int32Array | Float64Array;
323
+ }>, dictionary: string[]): void;
324
+ merge(other: PivotCellAggregator<TRow>): void;
325
+ finalize(): Record<string, number>;
326
+ }
327
+
328
+ declare class FastTrie {
329
+ size: number;
330
+ nodeToParent: Int32Array;
331
+ nodeToVal: Int32Array;
332
+ nodeToDepth: Int32Array;
333
+ nodeChildCount: Int32Array;
334
+ childrenMap: Map<number, Map<number, number>>;
335
+ constructor(capacity: number);
336
+ private expandCapacity;
337
+ insert(pathArray: Int32Array, len: number): number;
338
+ }
339
+
340
+ /**
341
+ * Compile a user-facing formula string like `[Sales] * [Tax] + 5`
342
+ * into a CSP-safe evaluator function.
343
+ *
344
+ * @param formulaString The raw formula with [FieldCaption] references
345
+ * @param fieldMap Map of caption → data key (e.g. "Sales" → "sales")
346
+ * @returns An evaluator `(context) => number`, or null if the formula is unsafe/invalid
347
+ */
348
+ declare function compileSafeFormula(formulaString: string, fieldMap: Map<string, string>): ((context: Record<string, any>) => number) | null;
349
+ /**
350
+ * Test-compile a formula and throw on error (for UI validation).
351
+ */
352
+ declare function testSafeFormula(formulaString: string, fieldMap: Map<string, string>): void;
353
+
354
+ declare function filterRecords<TRow>(records: TRow[], fields: PivotField<TRow>[], prefilter?: PivotPrefilter): TRow[];
355
+ declare function filterRecordsAsync<TRow>(records: TRow[], fields: PivotField<TRow>[], prefilter?: PivotPrefilter): Promise<TRow[]>;
356
+
357
+ declare function sortPivotTree(nodes: PivotNode[], fields: PivotField<any>[], engineResult: PivotEngineResult, dataFields: PivotField<any>[], isRowTree: boolean, locale?: string, cellMapCache?: Map<number, number>): void;
358
+
359
+ declare function executePostAggregationPhase<TRow>(engineResult: PivotEngineResult, dataFields: PivotField<TRow>[], registry?: PivotEngineRegistry): void;
360
+ declare function executeSummaryDisplayModesPhase<TRow>(engineResult: PivotEngineResult, dataFields: PivotField<TRow>[]): void;
361
+
362
+ declare function extractGroupValue<TRow>(row: TRow, field: PivotField<TRow>): PivotValue;
363
+
364
+ type DateFormatContext = 'grid' | 'chart' | 'export';
365
+ type DateGranularity = 'year' | 'quarter' | 'month' | 'day' | 'dayOfWeek' | string | number;
366
+ declare class DateFormatter {
367
+ private static intlCache;
368
+ private static stringCache;
369
+ /**
370
+ * Formats a raw grouped date value into a human-readable string.
371
+ * Cached to ensure 0 FPS drop on 500k+ rows.
372
+ */
373
+ static format(rawValue: any, context: DateFormatContext, locale: string, granularity?: DateGranularity): string;
374
+ static clearCache(): void;
375
+ }
376
+
377
+ declare class ExportStreamController {
378
+ private worker;
379
+ private static sharedWorker;
380
+ private static workerErrorCount;
381
+ private static readonly MAX_WORKER_ERRORS;
382
+ private static getOrCreateWorker;
383
+ /** Force-terminate and release the shared worker (e.g. on app teardown). */
384
+ static disposeWorker(): void;
385
+ constructor();
386
+ streamToCSV(data: any[], fields: PivotField<any>[], fileName: string, locale?: string, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<void>;
387
+ streamToExcelXML(data: any[], fields: PivotField<any>[], fileName: string, locale?: string, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<void>;
388
+ private processChunkInWorker;
389
+ }
390
+
391
+ interface AdvancedExportRequest {
392
+ format: 'excel-list' | 'excel-pivot' | 'pdf';
393
+ /** Flat source records (used by `excel-list`). */
394
+ listRecords: any[];
395
+ /** Visible fields for the flat list export. */
396
+ visibleListFields: PivotField[];
397
+ engineResult: PivotEngineResult;
398
+ rowFields: PivotField[];
399
+ colFields: PivotField[];
400
+ dataFields: PivotField[];
401
+ layout: PivotLayoutState;
402
+ expandedPaths: Set<string>;
403
+ expandedColPaths: Set<string>;
404
+ allExpanded: boolean;
405
+ fileName: string;
406
+ locale: string;
407
+ signal?: AbortSignal;
408
+ onProgress?: (percent: number) => void;
409
+ }
410
+ type AdvancedExporter = (req: AdvancedExportRequest) => Promise<void>;
411
+ /** Called by the Enterprise package to enable Excel/PDF export. */
412
+ declare function registerAdvancedExporter(fn: AdvancedExporter): void;
413
+ declare function getAdvancedExporter(): AdvancedExporter | null;
414
+
415
+ /**
416
+ * Convert Intl.NumberFormatOptions to an Excel numFmt string.
417
+ * Handles currency, percent, decimal, and basic integer formats.
418
+ */
419
+ declare function intlFormatToExcelNumFmt(format: Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | ((value: number) => string) | undefined, dataType?: string): string | undefined;
420
+ /**
421
+ * Format a cell value using the field's format configuration.
422
+ * Returns the formatted string for display in PDF/CSV/Print export.
423
+ */
424
+ declare function formatCellValue(value: unknown, field: PivotField | undefined, locale?: string): string;
425
+ /**
426
+ * High-performance cached formatter for bulk cell formatting.
427
+ * Avoids creating Intl.NumberFormat instances per-cell.
428
+ */
429
+ declare function formatCellValueCached(value: unknown, field: PivotField | undefined, locale?: string): string;
430
+ /**
431
+ * Convert a PivotConditionRule to ExcelJS cell style properties.
432
+ * Used for conditional formatting export to Excel.
433
+ */
434
+ declare function conditionRuleToExcelStyle(rule: PivotConditionRule, value: number): {
435
+ font?: Record<string, unknown>;
436
+ fill?: Record<string, unknown>;
437
+ } | null;
438
+ /**
439
+ * Clear the formatter cache. Call when locale changes.
440
+ */
441
+ declare function clearFormatCache(): void;
442
+
443
+ declare class PivotReportManager {
444
+ private storageKey;
445
+ constructor(storageKey: string);
446
+ /**
447
+ * Retrieves all saved reports from localStorage
448
+ */
449
+ getReports(): PivotReport[];
450
+ /**
451
+ * Retrieves the default report, if one exists
452
+ */
453
+ getDefaultReport(): PivotReport | null;
454
+ /**
455
+ * Saves a new report
456
+ */
457
+ saveReport(name: string, state: PivotReportState, isDefault?: boolean): PivotReport;
458
+ /**
459
+ * Updates an existing report (Overwrite)
460
+ */
461
+ updateReport(id: string, state: PivotReportState): PivotReport | null;
462
+ /**
463
+ * Creates a copy of an existing report
464
+ */
465
+ saveAs(id: string, newName: string): PivotReport | null;
466
+ /**
467
+ * Deletes a report
468
+ */
469
+ deleteReport(id: string): void;
470
+ /**
471
+ * Sets a specific report as the default
472
+ */
473
+ setDefaultReport(id: string): void;
474
+ private persist;
475
+ }
476
+
477
+ type ImportFormat = 'json' | 'csv' | 'xml' | 'xlsx';
478
+ interface ImportSnapshot<TRow = any> {
479
+ version: string;
480
+ type: 'FULL_SNAPSHOT' | 'LAYOUT_ONLY' | 'DATA_ONLY';
481
+ timestamp: string;
482
+ data?: TRow[];
483
+ fields?: PivotField<TRow>[];
484
+ layout?: PivotLayoutState;
485
+ expandedPaths?: string[];
486
+ preferences?: Record<string, any>;
487
+ }
488
+ interface IFileReader {
489
+ read(file: File): Promise<any[]>;
490
+ supports(file: File): boolean;
491
+ }
492
+ interface ValidationResult {
493
+ isValid: boolean;
494
+ errors: string[];
495
+ warnings: string[];
496
+ }
497
+
498
+ /** Progress update surfaced while a file is parsed in the worker. */
499
+ interface ImportProgress {
500
+ /** Coarse pipeline stage: reading | parsing | typing | finalizing. */
501
+ phase: string;
502
+ /** Overall completion, 0..100. */
503
+ percent: number;
504
+ }
505
+ /** File kinds the import worker can parse off the main thread. */
506
+ type ImportWorkerKind = 'csv' | 'json' | 'xml';
507
+ /** Result posted back by the worker once parsing completes. */
508
+ type ImportWorkerResult = {
509
+ mode: 'data';
510
+ data: any[];
511
+ fields: PivotField<any>[];
512
+ } | {
513
+ mode: 'raw';
514
+ value: any;
515
+ };
516
+ interface ParseFileOptions {
517
+ onProgress?: (p: ImportProgress) => void;
518
+ signal?: AbortSignal;
519
+ }
520
+ /**
521
+ * Drives the import Web Worker for a single file: streams progress, resolves
522
+ * with the parsed payload, and supports cooperative cancellation.
523
+ *
524
+ * Mirrors {@link ExportStreamController}, but imports are one-shot so each job
525
+ * gets a dedicated worker that is terminated on completion, error or cancel —
526
+ * `terminate()` also gives us instant, reliable cancellation mid-parse (a
527
+ * synchronous parse loop cannot otherwise be interrupted).
528
+ */
529
+ declare class ImportStreamController {
530
+ private static jobCounter;
531
+ /** Whether Web Workers are available in the current environment. */
532
+ static isSupported(): boolean;
533
+ /**
534
+ * Parse `file` in the worker. Resolves with the worker payload, rejects with
535
+ * an `AbortError` DOMException if `signal` is aborted, or a generic Error on
536
+ * worker failure.
537
+ */
538
+ parseFile(file: Blob, kind: ImportWorkerKind, opts?: ParseFileOptions): Promise<ImportWorkerResult>;
539
+ }
540
+
541
+ interface ImportManagerOptions {
542
+ /**
543
+ * Reject files larger than this many bytes before reading them, to guard
544
+ * against out-of-memory / browser-crash from oversized uploads. Defaults to
545
+ * 500 MB; pass 0 to disable the guard.
546
+ */
547
+ maxFileSizeBytes?: number;
548
+ }
549
+ interface ImportResult {
550
+ snapshot: ImportSnapshot;
551
+ validation: ValidationResult;
552
+ /** True when the import was cancelled via the abort signal before completing. */
553
+ cancelled?: boolean;
554
+ }
555
+ interface ProcessFileStreamingOptions {
556
+ onProgress?: (p: ImportProgress) => void;
557
+ signal?: AbortSignal;
558
+ }
559
+ interface ProcessFromUrlOptions extends ProcessFileStreamingOptions {
560
+ /** Extra fetch() init (headers, method, credentials, …). */
561
+ fetchInit?: RequestInit;
562
+ }
563
+ declare class ImportManager {
564
+ private readers;
565
+ private maxFileSizeBytes;
566
+ private stream;
567
+ constructor(options?: ImportManagerOptions);
568
+ /**
569
+ * Processes an uploaded file synchronously (whole-file read + parse on the
570
+ * calling thread). Retained for back-compat and non-worker environments;
571
+ * prefer {@link processFileStreaming} for large files.
572
+ */
573
+ processFile(file: File): Promise<{
574
+ snapshot: ImportSnapshot;
575
+ validation: ValidationResult;
576
+ }>;
577
+ /**
578
+ * Processes an uploaded file, offloading CSV/JSON parsing to a Web Worker so
579
+ * the UI stays responsive on large files, reporting progress and honoring
580
+ * cancellation. Excel (and environments without workers) transparently fall
581
+ * back to the synchronous reader path.
582
+ */
583
+ processFileStreaming(file: File, options?: ProcessFileStreamingOptions): Promise<ImportResult>;
584
+ /**
585
+ * Import an already-materialized array of row objects (e.g. an API/JSON
586
+ * response). Fields are auto-discovered; values are used as-is (call
587
+ * {@link coerceRecords} first if they are stringly-typed).
588
+ */
589
+ processFromData(rows: any[], options?: ProcessFileStreamingOptions): Promise<ImportResult>;
590
+ /**
591
+ * Import delimited text (e.g. a clipboard paste from Excel/Sheets, which is
592
+ * tab-separated). Delimiter is auto-detected; values are typed via the shared
593
+ * CSV pipeline.
594
+ */
595
+ processFromText(text: string, options?: ProcessFileStreamingOptions): Promise<ImportResult>;
596
+ /**
597
+ * Fetch data from a URL (or backend API) and import it. The response is
598
+ * wrapped as a File so the format is detected from the URL extension /
599
+ * content-type and parsed through the same worker pipeline.
600
+ */
601
+ processFromUrl(url: string, options?: ProcessFromUrlOptions): Promise<ImportResult>;
602
+ /**
603
+ * Import one or more files, appending their rows into a single dataset with a
604
+ * unioned field set. Progress is aggregated across files; any cancellation
605
+ * aborts the whole batch.
606
+ */
607
+ processFiles(files: FileList | File[], options?: ProcessFileStreamingOptions): Promise<ImportResult>;
608
+ private assertSize;
609
+ /** Which worker parse path applies to this file, or null for Excel/unknown. */
610
+ private workerKind;
611
+ private isAbort;
612
+ private cancelledResult;
613
+ /** Build a result from reader/worker content (raw data array or a snapshot object). */
614
+ private buildFromContent;
615
+ /** Build a DATA_ONLY result from a raw row array, reusing worker-computed fields when supplied. */
616
+ private buildDataResult;
617
+ }
618
+
619
+ /**
620
+ * Dedicated delimited-text reader (CSV / TSV / plain text).
621
+ *
622
+ * Reads the file as UTF-8 TEXT (not raw bytes), so UTF-8 / Turkish / emoji
623
+ * content is preserved instead of being mis-decoded as ANSI. Parsing/typing is
624
+ * delegated to the shared {@link parseCsvToRows} pipeline (delimiter
625
+ * auto-detect, RFC-4180 quoting, per-column type inference and locale-aware
626
+ * coercion, leading-zero ids kept as strings) — the same code path the import
627
+ * worker runs. This is used in preference to the SheetJS path for delimited
628
+ * files.
629
+ */
630
+ declare class CsvReader implements IFileReader {
631
+ supports(file: File): boolean;
632
+ read(file: File): Promise<any[]>;
633
+ /** Parse delimited text into typed row objects. Exposed for testing. */
634
+ static parse(text: string): Record<string, unknown>[];
635
+ }
636
+
637
+ /**
638
+ * Dependency-free XML reader for tabular data exports.
639
+ *
640
+ * Works in Node, Web Workers and the browser (no `DOMParser` needed). Handles
641
+ * the common "rows" shapes:
642
+ * <data><record><a>1</a><b>x</b></record> … </data> (element fields)
643
+ * <rows><row id="1" name="x"/> … </rows> (attribute fields)
644
+ * <root><a>1</a><b>2</b></root> (single flat record)
645
+ * Attributes and leaf child-elements both become columns; values are typed with
646
+ * the shared {@link coerceRecords} pipeline (locale numbers, dates, booleans;
647
+ * leading-zero ids preserved). Prototype-polluting keys are neutralized.
648
+ */
649
+ declare class XmlReader implements IFileReader {
650
+ supports(file: File): boolean;
651
+ read(file: File): Promise<any[]>;
652
+ /** Parse XML text into typed row objects. Exposed for testing. */
653
+ static parse(text: string): Record<string, unknown>[];
654
+ }
655
+
656
+ declare class DataNormalizer {
657
+ /**
658
+ * Generates basic PivotFields from an array of raw data objects.
659
+ * Scans a sample size of rows to determine data types.
660
+ */
661
+ static extractFieldsFromData(data: any[], sampleSize?: number): PivotField<any>[];
662
+ /**
663
+ * Build pivot fields from a reviewed import plan (column mapping): explicit
664
+ * caption + dataType per column, in the plan's order. Applies the same
665
+ * area-assignment heuristic as {@link extractFieldsFromData} (first
666
+ * string/date → row, first number → data).
667
+ */
668
+ static buildFieldsFromPlan(plan: {
669
+ dataField: string;
670
+ caption: string;
671
+ dataType: 'string' | 'number' | 'date' | 'boolean';
672
+ }[], data?: any[], sampleSize?: number): PivotField<any>[];
673
+ private static isAutoRowCandidate;
674
+ private static isAutoDataCandidate;
675
+ private static isHighCardinalityStringColumn;
676
+ private static isIdentifierLikeKey;
677
+ /** Union column keys across a sample of rows, preserving first-seen order. */
678
+ private static collectKeys;
679
+ private static inferType;
680
+ private static formatCaption;
681
+ }
682
+
683
+ type CellType = 'string' | 'number' | 'date' | 'boolean';
684
+ /** Strip a leading UTF-8/UTF-16 BOM if present. */
685
+ declare function stripBom(text: string): string;
686
+ /**
687
+ * Auto-detect the delimiter of a delimited-text sample by counting candidate
688
+ * separators outside of quotes on the first few lines. Supports comma,
689
+ * semicolon, tab and pipe (covers Excel-locale CSV and TSV).
690
+ */
691
+ declare function detectDelimiter(sample: string): string;
692
+ /**
693
+ * Parse RFC-4180-style delimited text into a matrix of string cells.
694
+ * Handles quoted fields, escaped quotes (`""`), embedded newlines and
695
+ * mixed CRLF/LF line endings. The delimiter is auto-detected when omitted.
696
+ *
697
+ * `onProgress` (optional) is invoked periodically with the fraction of the
698
+ * input consumed (0..1) so long parses run in a worker can report progress.
699
+ */
700
+ declare function parseDelimited(text: string, delimiter?: string, onProgress?: (fraction: number) => void): string[][];
701
+ /** Lenient boolean parse used for COERCION within a known boolean column. */
702
+ declare function parseBoolean(raw: unknown): boolean | null;
703
+ /**
704
+ * Parse a locale-formatted number: handles thousands/decimal separators in
705
+ * both `1,234.56` and `1.234,56` conventions, currency symbols, percent,
706
+ * spaces (incl. non-breaking) and accounting parentheses for negatives.
707
+ * Returns null when the input is not a number.
708
+ */
709
+ declare function parseLocaleNumber(raw: unknown): number | null;
710
+ /**
711
+ * Parse a variety of common date formats to a Date: ISO (date or datetime),
712
+ * `yyyy/mm/dd`, `yyyy.mm.dd`, and `dd/mm/yyyy`/`mm/dd/yyyy` (disambiguated by
713
+ * the day value when possible, defaulting to day-first). Plain integers and
714
+ * separatorless strings are intentionally NOT treated as dates.
715
+ */
716
+ declare function parseFlexibleDate(raw: unknown): Date | null;
717
+ /** Classify a single raw cell value into a pivot data type (or 'blank'). */
718
+ declare function classifyValue(val: unknown): CellType | 'blank';
719
+ /**
720
+ * Infer a column's type from a set of sampled values by majority vote over
721
+ * non-blank cells. Ties and empty columns default to 'string'.
722
+ */
723
+ declare function inferColumnType(values: unknown[]): CellType;
724
+ /**
725
+ * Coerce a raw value to the target column type. Returns null for blanks and
726
+ * for values that cannot be represented in the target type (so a stray text
727
+ * cell in a numeric column becomes empty rather than corrupting aggregation).
728
+ */
729
+ declare function coerceValue(val: unknown, type: CellType): unknown;
730
+ /** Return a key safe to assign as an own property (renames prototype-polluting keys). */
731
+ declare function safeKey(key: string): string;
732
+ /**
733
+ * Defensively neutralize prototype-polluting own keys in already-parsed rows
734
+ * (e.g. from SheetJS/JSON, whose keys come from untrusted files). Returns the
735
+ * same array untouched when nothing dangerous is present (the common case).
736
+ */
737
+ declare function sanitizeRows<T extends Record<string, unknown>>(rows: T[]): Record<string, unknown>[];
738
+ interface CsvParseProgress {
739
+ phase: 'parsing' | 'typing';
740
+ /** Overall completion 0..100. */
741
+ percent: number;
742
+ }
743
+ /** Ensure unique, non-empty header names (duplicates get a numeric suffix); prototype-safe. */
744
+ declare function dedupeHeaders(headers: string[]): string[];
745
+ /**
746
+ * Infer per-column types from a sample of already-parsed string/loose records
747
+ * and coerce every cell (locale numbers, dates, booleans; leading-zero ids kept
748
+ * as strings), returning fresh prototype-safe row objects. Shared by any source
749
+ * that yields untyped records (XML, and future sources). `onProgress` reports
750
+ * typing completion 0..100.
751
+ */
752
+ declare function coerceRecords(records: Record<string, unknown>[], onProgress?: (p: CsvParseProgress) => void): Record<string, unknown>[];
753
+ /**
754
+ * Full delimited-text → typed-row pipeline: BOM strip, delimiter auto-detect,
755
+ * RFC-4180 parse, header dedupe, per-column type inference from a sample and
756
+ * per-cell coercion (locale numbers, dates, booleans; leading-zero ids kept as
757
+ * strings). Optional `onProgress` reports overall completion (parse 0→60%,
758
+ * typing 60→100%) so a worker can surface a progress bar. This is the single
759
+ * implementation shared by {@link CsvReader} (sync) and the import worker.
760
+ */
761
+ declare function parseCsvToRows(text: string, onProgress?: (p: CsvParseProgress) => void): Record<string, unknown>[];
762
+
763
+ declare const tr: PivotDictionary;
764
+
765
+ declare const en: PivotDictionary;
766
+
767
+ declare const de: PivotDictionary;
768
+
769
+ declare const fr: PivotDictionary;
770
+
771
+ declare const es: PivotDictionary;
772
+
773
+ declare const it: PivotDictionary;
774
+
775
+ declare const pt: PivotDictionary;
776
+
777
+ declare const ru: PivotDictionary;
778
+
779
+ declare const ar: PivotDictionary;
780
+
781
+ declare const zhCN: PivotDictionary;
782
+
783
+ declare const ja: PivotDictionary;
784
+
785
+ declare const ko: PivotDictionary;
786
+
787
+ export { type AdvancedExportRequest, type AdvancedExporter, CellClickEvent, type CellType, type CsvParseProgress, CsvReader, DataNormalizer, type DateFormatContext, DateFormatter, type DateGranularity, DropIntent, ExportFormat, ExportOptions, ExportStreamController, ExportingEvent, FastTrie, FieldMoveEvent, type IFileReader, type ImportFormat, ImportManager, type ImportManagerOptions, type ImportProgress, type ImportResult, type ImportSnapshot, ImportStreamController, type ImportWorkerKind, type ImportWorkerResult, MAX_C, type ParseFileOptions, PivotArea, PivotCell, PivotCellAggregator, PivotCellTextAccessor, PivotCellValueAccessor, PivotConditionRule, PivotController, type PivotControllerEvents, PivotControllerOptions, PivotControllerState, PivotDictionary, PivotDragIntentState, PivotEngineRegistry, PivotEngineResult, PivotEngineService, type PivotEngineServiceConfig, PivotEventEmitter, type PivotEventHandler, type PivotEventMap, PivotExportService, PivotField, PivotFieldService, PivotImportField, type PivotImportLabels, PivotImportStatus, PivotLayoutState, PivotNode, PivotPrefilter, PivotReport, PivotReportManager, PivotReportService, PivotReportState, PivotSelectionMode, PivotSelectionModel, PivotSelectionState, PivotSelectionStats, type PivotStateListener, PivotStateStore, PivotValue, type ProcessFileStreamingOptions, type ProcessFromUrlOptions, type ValidationResult, XmlReader, ar, cellHash, cellHashCol, cellHashRow, classifyValue, clearFormatCache, coerceRecords, coerceValue, compileSafeFormula, conditionRuleToExcelStyle, de, dedupeHeaders, detectDelimiter, en, es, executePostAggregationPhase, executeSummaryDisplayModesPhase, extractGroupValue, filterRecords, filterRecordsAsync, formatCellValue, formatCellValueCached, fr, getAdvancedExporter, inferColumnType, intlFormatToExcelNumFmt, it, ja, ko, parseBoolean, parseCsvToRows, parseDelimited, parseFlexibleDate, parseLocaleNumber, pt, registerAdvancedExporter, ru, safeKey, sanitizeRows, sortPivotTree, stripBom, testSafeFormula, tr, zhCN };