@worksheet-js/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,1961 @@
1
+ import { SheetData as SheetData$1, CsvOptions, JsonOptions, HtmlOptions } from '@worksheet-js/excel';
2
+ export { AnchorMarker, AutoFilterData, CellData, CellType, ConditionalFormattingData, CsvOptions, DataValidationData, HtmlOptions, HyperlinkData, ImageData, JsonOptions, MergeData, ParsedStyle, ParserError, ParserResult, SheetData, WorkbookData, excelDateToJSDate, isDateFormat, parseCsv, parseHtml, parseJson, parseTsv } from '@worksheet-js/excel';
3
+ import { FormulaEngine } from '@worksheet-js/formula';
4
+
5
+ type CellType = 'string' | 'number' | 'boolean' | 'date' | 'error';
6
+ /** Visual style properties for a cell — mirrors Google Sheets toolbar options */
7
+ interface CellStyle {
8
+ bold?: boolean;
9
+ italic?: boolean;
10
+ underline?: boolean;
11
+ strikethrough?: boolean;
12
+ fontFamily?: string;
13
+ fontSize?: number;
14
+ color?: string;
15
+ fillColor?: string;
16
+ align?: 'left' | 'center' | 'right';
17
+ valign?: 'top' | 'middle' | 'bottom';
18
+ wrap?: 'overflow' | 'wrap' | 'clip';
19
+ rotation?: number;
20
+ numberFormat?: 'auto' | 'text' | 'number' | 'currency' | 'currency_rounded' | 'percent' | 'scientific' | 'accounting' | 'financial' | 'date' | 'time' | 'datetime' | 'duration';
21
+ decimals?: number;
22
+ borderTop?: boolean;
23
+ borderBottom?: boolean;
24
+ borderLeft?: boolean;
25
+ borderRight?: boolean;
26
+ borderWeight?: number;
27
+ borderStyle?: string;
28
+ borderColor?: string;
29
+ link?: string;
30
+ currencyCode?: string;
31
+ direction?: 'ltr' | 'rtl';
32
+ borderTopColor?: string;
33
+ borderTopStyle?: string;
34
+ borderTopWeight?: number;
35
+ borderBottomColor?: string;
36
+ borderBottomStyle?: string;
37
+ borderBottomWeight?: number;
38
+ borderLeftColor?: string;
39
+ borderLeftStyle?: string;
40
+ borderLeftWeight?: number;
41
+ borderRightColor?: string;
42
+ borderRightStyle?: string;
43
+ borderRightWeight?: number;
44
+ }
45
+ interface CommentReply {
46
+ id: string;
47
+ author: string;
48
+ text: string;
49
+ timestamp: Date;
50
+ }
51
+ interface CommentThread {
52
+ id: string;
53
+ author: string;
54
+ text: string;
55
+ timestamp: Date;
56
+ resolved: boolean;
57
+ replies: CommentReply[];
58
+ }
59
+ interface CellData {
60
+ value: string;
61
+ parsedValue: unknown;
62
+ type: CellType;
63
+ format?: string;
64
+ style?: CellStyle;
65
+ note?: string;
66
+ comments?: CommentThread[];
67
+ }
68
+
69
+ declare class CellEditor {
70
+ private ws;
71
+ element: HTMLTextAreaElement;
72
+ isOpen: boolean;
73
+ isComposing: boolean;
74
+ private _x;
75
+ private _y;
76
+ private _isFormula;
77
+ private _originalValue;
78
+ private _ghost;
79
+ constructor(ws: WorksheetModel);
80
+ /**
81
+ * Open the editor on cell (x, y), optionally prefilling with a char.
82
+ */
83
+ open(x: number, y: number, initialChar?: string, options?: {
84
+ preventFocus?: boolean;
85
+ }): void;
86
+ /**
87
+ * Close the editor, optionally saving the value.
88
+ */
89
+ close(save: boolean): void;
90
+ /** Get current editor value */
91
+ getValue(): string;
92
+ /** Insert text at current cursor position */
93
+ insertAtCursor(text: string): void;
94
+ private _position;
95
+ private _resize;
96
+ private _syncFormulaBar;
97
+ private _cycleRefAtCursor;
98
+ }
99
+
100
+ /** Zero-based column (x) and row (y) coordinates */
101
+ interface CellAddress {
102
+ x: number;
103
+ y: number;
104
+ }
105
+ /** Selection range using inclusive corner coordinates (matches jspreadsheet coords convention) */
106
+ interface SelectionRange {
107
+ x1: number;
108
+ y1: number;
109
+ x2: number;
110
+ y2: number;
111
+ }
112
+ /** Sheet tab metadata */
113
+ interface SheetMeta {
114
+ worksheetName: string;
115
+ tabColor?: string;
116
+ hidden?: boolean;
117
+ minDimensions?: [number, number];
118
+ defaultColWidth?: number;
119
+ defaultRowHeight?: number;
120
+ minColWidth?: number;
121
+ minRowHeight?: number;
122
+ hiddenColumns?: number[];
123
+ hiddenRows?: number[];
124
+ frozenRows?: number;
125
+ frozenCols?: number;
126
+ direction?: 'ltr' | 'rtl';
127
+ }
128
+ /** Base type for extensible sheet overlays (images, charts, widgets) */
129
+ interface OverlayItem {
130
+ id: string;
131
+ type: string;
132
+ x: number;
133
+ y: number;
134
+ w?: number;
135
+ h?: number;
136
+ data: any;
137
+ }
138
+ /** A single style snapshot for one cell in a batch */
139
+ interface CellStyleSnapshot {
140
+ x: number;
141
+ y: number;
142
+ before: unknown;
143
+ after: unknown;
144
+ }
145
+ /**
146
+ * A single history entry — discriminated union so each type carries precise before/after types.
147
+ * This enables TypeScript to narrow types in _applyHistory without casts.
148
+ */
149
+ type HistoryEntry = {
150
+ type: 'value';
151
+ x: number;
152
+ y: number;
153
+ before: string;
154
+ after: string;
155
+ } | {
156
+ type: 'style';
157
+ x: number;
158
+ y: number;
159
+ before: unknown;
160
+ after: unknown;
161
+ } | {
162
+ type: 'style-batch';
163
+ x?: never;
164
+ y?: never;
165
+ before: null;
166
+ after: null;
167
+ cells: CellStyleSnapshot[];
168
+ } | {
169
+ type: 'width';
170
+ x: number;
171
+ y?: never;
172
+ before: number;
173
+ after: number;
174
+ } | {
175
+ type: 'height';
176
+ x?: never;
177
+ y: number;
178
+ before: number;
179
+ after: number;
180
+ } | {
181
+ type: 'insert-row';
182
+ x?: never;
183
+ y: number;
184
+ before: null;
185
+ after: number;
186
+ } | {
187
+ type: 'delete-row';
188
+ x?: never;
189
+ y: number;
190
+ before: null;
191
+ after: number;
192
+ } | {
193
+ type: 'insert-col';
194
+ x: number;
195
+ y?: never;
196
+ before: null;
197
+ after: number;
198
+ } | {
199
+ type: 'delete-col';
200
+ x: number;
201
+ y?: never;
202
+ before: null;
203
+ after: number;
204
+ } | {
205
+ type: 'merge';
206
+ x?: never;
207
+ y?: never;
208
+ before: null;
209
+ after: {
210
+ x1: number;
211
+ y1: number;
212
+ x2: number;
213
+ y2: number;
214
+ };
215
+ } | {
216
+ /** Multiple value changes as a single undoable action (e.g. clear selection, fill down) */
217
+ type: 'value-batch';
218
+ x?: never;
219
+ y?: never;
220
+ before: null;
221
+ after: null;
222
+ cells: Array<{
223
+ x: number;
224
+ y: number;
225
+ before: string;
226
+ after: string;
227
+ }>;
228
+ } | {
229
+ /**
230
+ * Copy/cut+paste — carries full cell state (value + style) before and after.
231
+ * Undo restores all destination cells to their pre-paste state.
232
+ * For cut, also restores source cells.
233
+ */
234
+ type: 'paste-batch';
235
+ x?: never;
236
+ y?: never;
237
+ before: null;
238
+ after: null;
239
+ cells: Array<{
240
+ x: number;
241
+ y: number;
242
+ beforeValue: string;
243
+ afterValue: string;
244
+ beforeStyle: CellStyle | undefined;
245
+ afterStyle: CellStyle | undefined;
246
+ beforeOverlay: any | undefined;
247
+ afterOverlay: any | undefined;
248
+ }>;
249
+ } | {
250
+ type: 'overlay';
251
+ x: number;
252
+ y: number;
253
+ before: any | undefined;
254
+ after: any | undefined;
255
+ };
256
+ /** Custom color overrides */
257
+ interface ThemeColors {
258
+ primary?: string;
259
+ accent?: string;
260
+ headerBg?: string;
261
+ headerText?: string;
262
+ cellBg?: string;
263
+ cellText?: string;
264
+ toolbarBg?: string;
265
+ gridBorder?: string;
266
+ }
267
+ /** Custom font overrides */
268
+ interface ThemeFonts {
269
+ ui?: string;
270
+ cell?: string;
271
+ }
272
+ type OnLoadCallback = (spreadsheet: Spreadsheet) => void;
273
+ type OnSelectionCallback = (worksheet: WorksheetModel, x1: number, y1: number, x2: number, y2: number) => void;
274
+ type OnChangeCallback = (worksheet: WorksheetModel, cell: HTMLElement | null, x: number, y: number, value: string, oldValue: string) => void;
275
+ type OnCreateWorksheetCallback = (worksheet: WorksheetModel, index: number) => void;
276
+ type OnDestroyCallback = () => void;
277
+ /** Main options passed to Worksheet.create() */
278
+ interface WorksheetOptions {
279
+ /** Container element to mount the spreadsheet into */
280
+ container: HTMLElement;
281
+ /** One or more worksheet configs (default: one sheet named "Sheet1") */
282
+ worksheets?: SheetMeta[];
283
+ /** Global default column width in px (default: 100) */
284
+ defaultColWidth?: number;
285
+ /** Global default row height in px (default: 24) */
286
+ defaultRowHeight?: number;
287
+ /** Maximum number of worksheets allowed (default: 200) */
288
+ maxSheets?: number;
289
+ /** Show sheet tab bar (default: true) */
290
+ tabs?: boolean;
291
+ /** Show ribbon toolbar (default: true) */
292
+ toolbar?: boolean;
293
+ /** Show formula bar (default: true) */
294
+ formulaBar?: boolean;
295
+ /** Frozen rows count (default: 0) */
296
+ frozenRows?: number;
297
+ /** Frozen columns count (default: 0) */
298
+ frozenCols?: number;
299
+ /** Color theme (default: 'light') */
300
+ theme?: 'light' | 'dark';
301
+ /** Custom color overrides */
302
+ colors?: ThemeColors;
303
+ /** Custom font overrides */
304
+ fonts?: ThemeFonts;
305
+ /**
306
+ * Spreadsheet-wide default font name (display name from the font registry, e.g. "Roboto").
307
+ * Applies to UI labels (toolbar, tabs, formula bar) and blank cell rendering.
308
+ * Typing a font name here is equivalent to calling setDefaultFont() after creation.
309
+ */
310
+ defaultFont?: string;
311
+ /** Zoom level 10–400 (default: 100) */
312
+ zoom?: number;
313
+ /** Locale for number formatting (default: navigator.language) */
314
+ locale?: string;
315
+ /** Encoded and signed license key string */
316
+ licenseKey?: string;
317
+ /** Custom watermark text for Enterprise edition */
318
+ watermark?: string;
319
+ onload?: OnLoadCallback;
320
+ onselection?: OnSelectionCallback;
321
+ onchange?: OnChangeCallback;
322
+ oncreateworksheet?: OnCreateWorksheetCallback;
323
+ ondestroy?: OnDestroyCallback;
324
+ }
325
+
326
+ type SelectionMode = 'normal' | 'row' | 'col' | 'all';
327
+ type EnterDirection = 'down' | 'up' | 'right' | 'left';
328
+ /**
329
+ * SelectionModel — full selection state with anchor/focus distinction.
330
+ * The anchor is where dragging/shift-extending started.
331
+ * The focus is where the keyboard/mouse currently points.
332
+ * Derived x1,y1,x2,y2 = bounding box of anchor + focus.
333
+ */
334
+ declare class SelectionModel {
335
+ anchorX: number;
336
+ anchorY: number;
337
+ focusX: number;
338
+ focusY: number;
339
+ mode: SelectionMode;
340
+ copyRange: SelectionRange | null;
341
+ isCut: boolean;
342
+ enterDirection: EnterDirection;
343
+ tabOriginX: number;
344
+ /**
345
+ * Set anchor = focus = (x, y). Used on plain click or single-cell move.
346
+ */
347
+ setAnchor(x: number, y: number): void;
348
+ /**
349
+ * Extend focus to (x, y) keeping anchor fixed.
350
+ * Used on shift+click, shift+arrow, mousemove during drag.
351
+ */
352
+ extendFocus(x: number, y: number): void;
353
+ /**
354
+ * Get the bounding SelectionRange (always normalized: x1 ≤ x2, y1 ≤ y2).
355
+ */
356
+ getRange(): SelectionRange;
357
+ /**
358
+ * The display cell — top-left of bounding box (matches what NameBox shows).
359
+ */
360
+ getDisplayCell(): {
361
+ x: number;
362
+ y: number;
363
+ };
364
+ /**
365
+ * Move anchor+focus by (dx, dy). Clamps to [0, maxCol/maxRow].
366
+ */
367
+ move(dx: number, dy: number, maxCol: number, maxRow: number): void;
368
+ /**
369
+ * Extend focus by (dx, dy) keeping anchor fixed.
370
+ */
371
+ extend(dx: number, dy: number, maxCol: number, maxRow: number): void;
372
+ /**
373
+ * Select full row y.
374
+ */
375
+ selectRow(y: number, maxCol: number): void;
376
+ /**
377
+ * Extend row selection to row y (keeping anchor row).
378
+ */
379
+ extendRowTo(y: number, maxCol: number): void;
380
+ /**
381
+ * Select full column x.
382
+ */
383
+ selectCol(x: number, maxRow: number): void;
384
+ /**
385
+ * Extend column selection to col x.
386
+ */
387
+ extendColTo(x: number, maxRow: number): void;
388
+ /**
389
+ * Select all cells.
390
+ */
391
+ selectAll(maxCol: number, maxRow: number): void;
392
+ /**
393
+ * Set the copy range and start "marching ants" mode.
394
+ */
395
+ setCopyRange(range: SelectionRange, isCut?: boolean): void;
396
+ /**
397
+ * Clear copy range (escape or after paste).
398
+ */
399
+ clearCopyRange(): void;
400
+ isSingleCell(): boolean;
401
+ contains(x: number, y: number): boolean;
402
+ }
403
+
404
+ /**
405
+ * SelectionPainter — applies/removes CSS classes to reflect the current selection.
406
+ * Manages the floating selection border overlay and fill handle (corner) position.
407
+ */
408
+ declare class SelectionPainter {
409
+ private ws;
410
+ private borderEl;
411
+ private highlighted;
412
+ private selectedHeaders;
413
+ constructor(ws: WorksheetModel);
414
+ /** Apply selection classes and position the border + fill handle */
415
+ paint(x1: number, y1: number, x2: number, y2: number): void;
416
+ /** Remove all selection highlight classes */
417
+ clear(): void;
418
+ }
419
+
420
+ /**
421
+ * SelectionState — stores the current selection rectangle.
422
+ * Uses same {x1,y1,x2,y2} coords convention as jSpreadsheet CE.
423
+ */
424
+ declare class SelectionState {
425
+ private x1;
426
+ private y1;
427
+ private x2;
428
+ private y2;
429
+ set(x1: number, y1: number, x2: number, y2: number): void;
430
+ getRange(): SelectionRange;
431
+ getAnchor(): {
432
+ x: number;
433
+ y: number;
434
+ };
435
+ contains(x: number, y: number): boolean;
436
+ isAnchor(x: number, y: number): boolean;
437
+ isSingleCell(): boolean;
438
+ }
439
+
440
+ /**
441
+ * OverlayRegistry — a thin container for sheet widgets (images, charts, etc.).
442
+ * Designed to be extensible: adding a new widget type doesn't require changing this class.
443
+ */
444
+ declare class OverlayRegistry {
445
+ private items;
446
+ add(item: OverlayItem): void;
447
+ remove(id: string): void;
448
+ getAll(): OverlayItem[];
449
+ getAt(x: number, y: number): OverlayItem[];
450
+ clear(): void;
451
+ /** Deep-clone all items from another registry. */
452
+ copyFrom(source: OverlayRegistry): void;
453
+ }
454
+
455
+ type CFOperator = 'cell_empty' | 'cell_not_empty' | 'text_contains' | 'text_not_contains' | 'text_starts' | 'text_ends' | 'text_is' | 'date_is' | 'date_before' | 'date_after' | 'num_greater' | 'num_greater_equal' | 'num_less' | 'num_less_equal' | 'num_equal' | 'num_not_equal' | 'num_between' | 'num_not_between' | 'custom_formula';
456
+ interface CFRule {
457
+ ranges: SelectionRange[];
458
+ operator: CFOperator;
459
+ value1?: string;
460
+ value2?: string;
461
+ style: Partial<CellStyle>;
462
+ }
463
+ /**
464
+ * ConditionalFormattingManager — Handles rule storage and evaluation.
465
+ */
466
+ declare class ConditionalFormattingManager {
467
+ private rules;
468
+ constructor();
469
+ getRules(): CFRule[];
470
+ addRule(rule: CFRule): void;
471
+ updateRule(index: number, rule: CFRule): void;
472
+ removeRule(index: number): void;
473
+ moveRule(from: number, to: number): void;
474
+ evaluate(x: number, y: number, value: unknown): Partial<CellStyle>;
475
+ private _isCellInRange;
476
+ private _checkRule;
477
+ clearRules(): void;
478
+ }
479
+
480
+ type ConditionType = 'none' | 'is_empty' | 'is_not_empty' | 'text_contains' | 'text_not_contains' | 'text_starts_with' | 'text_ends_with' | 'text_exactly' | 'text_not_exactly' | 'text_is_email' | 'text_is_url' | 'eq' | 'not_eq' | 'greater_than' | 'less_than' | 'greater_equal' | 'less_equal' | 'between' | 'num_not_between' | 'date_is' | 'date_before' | 'date_after' | 'date_on_or_before' | 'date_on_or_after' | 'date_between' | 'date_not_between' | 'date_is_valid';
481
+ interface ColumnFilter {
482
+ /** If defined: only show rows whose value is in this set. */
483
+ valueSet?: Set<string>;
484
+ /** If defined and type !== 'none': also apply this condition. */
485
+ condition?: {
486
+ type: ConditionType;
487
+ value: string;
488
+ value2?: string;
489
+ };
490
+ }
491
+ declare class FilterState {
492
+ /** Set of columns that have filtering UI enabled via icon. */
493
+ enabledColumns: Set<number>;
494
+ /** Per-column active filter rules (0-indexed column). */
495
+ filters: Map<number, ColumnFilter>;
496
+ /** True if column `col` has a non-trivial active filter. */
497
+ isColumnFiltered(col: number): boolean;
498
+ /** True if any column has an active filter. */
499
+ get anyFiltered(): boolean;
500
+ /**
501
+ * Returns true if the given row should be VISIBLE (passes all active filters).
502
+ * Row 0 (header) always returns true.
503
+ */
504
+ rowPassesFilters(ws: WorksheetModel, row: number): boolean;
505
+ /**
506
+ * Set the filter for a column. Pass `null` to clear that column's filter.
507
+ */
508
+ setColumnFilter(col: number, filter: ColumnFilter | null): void;
509
+ /** Remove all active filters (but keep `hasFilter = true` so buttons remain). */
510
+ clearFilters(): void;
511
+ /** fully disable filtering for a specific column or all columns. */
512
+ disable(col?: number): void;
513
+ enableFilters(col?: number): void;
514
+ /** Deep-clone another FilterState instance. */
515
+ copyFrom(source: FilterState): void;
516
+ }
517
+
518
+ /**
519
+ * Viewport — High-performance grid virtualization engine.
520
+ *
521
+ * Instead of creating 100,000 DOM nodes, it creates a small pool of `<div class="worksheet-cell">`
522
+ * and recycles them as the user scrolls. The cells are absolutely positioned.
523
+ */
524
+ declare class Viewport {
525
+ private ws;
526
+ private container;
527
+ private ghost;
528
+ private viewLayer;
529
+ private selectAllBlock;
530
+ private colContainer;
531
+ private rowContainer;
532
+ private poolSize;
533
+ private cells;
534
+ private rowHeaders;
535
+ private colHeaders;
536
+ private contentWidth;
537
+ private overscan;
538
+ private startCol;
539
+ private endCol;
540
+ private startRow;
541
+ private endRow;
542
+ private _measurer;
543
+ constructor(ws: WorksheetModel, container: HTMLElement);
544
+ /** Returns the view layer element for external consumers (e.g., SelectionPainter). */
545
+ getViewLayer(): HTMLElement;
546
+ private _linkTooltip;
547
+ private _linkTooltipTimer;
548
+ private _bindLinkTooltip;
549
+ private _showLinkTooltip;
550
+ private _hideLinkTooltip;
551
+ private isResizing;
552
+ private resizeAxis;
553
+ private resizeIndex;
554
+ private resizeStartPos;
555
+ private resizeStartSize;
556
+ private resizeLine;
557
+ private _boundResizeMove;
558
+ private _boundResizeUp;
559
+ private _bindResizeHandlers;
560
+ private _startResize;
561
+ /**
562
+ * Called by TableBuilder after seeding the initial DOM pool.
563
+ */
564
+ initPool(cells: HTMLElement[], rowHeaders: HTMLElement[], colHeaders: HTMLElement[], colContainer: HTMLElement, rowContainer: HTMLElement): void;
565
+ /**
566
+ * Compute cumulative pixel offsets to find which rows/cols are visible based on scroll pos.
567
+ */
568
+ private _calculateVisibleRange;
569
+ /**
570
+ * Render loop: recycles DOM nodes to match current visible range.
571
+ */
572
+ render(): void;
573
+ private _activeFilterPanel;
574
+ private _openFilterPanel;
575
+ /** Apply stored cell style properties to a DOM element */
576
+ private _applyStyleToCell;
577
+ private _onScroll;
578
+ _isCellVisible(x: number, y: number): boolean;
579
+ _updateGhostSize(): void;
580
+ _getCumulativeWidth(col: number): number;
581
+ _getCumulativeHeight(row: number): number;
582
+ getCellRect(x: number, y: number): {
583
+ left: number;
584
+ top: number;
585
+ width: number;
586
+ height: number;
587
+ };
588
+ scrollToCell(x: number, y: number): void;
589
+ measureRowHeight(y: number): number;
590
+ destroy(): void;
591
+ }
592
+
593
+ /**
594
+ * @worksheet/utils — shared types for cell overlay components
595
+ */
596
+ type OverlayType = 'checkbox' | 'dropdown' | 'image';
597
+ interface CheckboxConfig {
598
+ /** If true, the underlying cell text is hidden and only the checkbox shows */
599
+ hideText?: boolean;
600
+ }
601
+ type ValidationCriteria = 'dropdown' | 'dropdown_range' | 'text_contains' | 'text_not_contains' | 'text_is' | 'text_is_email' | 'text_is_url' | 'date_is' | 'date_before' | 'date_after' | 'date_on_or_before' | 'date_on_or_after' | 'date_between' | 'date_not_between' | 'date_is_valid' | 'num_greater' | 'num_greater_equal' | 'num_less' | 'num_less_equal' | 'num_equal' | 'num_not_equal' | 'num_between' | 'num_not_between' | 'custom_formula' | 'checkbox';
602
+ interface DropdownOption {
603
+ text: string;
604
+ color?: string;
605
+ }
606
+ interface ValidationConfig {
607
+ criteria: ValidationCriteria;
608
+ options?: DropdownOption[];
609
+ value1?: string;
610
+ value2?: string;
611
+ displayStyle?: 'chip' | 'arrow' | 'text';
612
+ showWarning?: boolean;
613
+ rejectInput?: boolean;
614
+ helpText?: string;
615
+ showHelpText?: boolean;
616
+ allowMultiSelect?: boolean;
617
+ showInputMessage?: boolean;
618
+ showErrorMessage?: boolean;
619
+ checkedValue?: string;
620
+ uncheckedValue?: string;
621
+ }
622
+ interface ImageConfig {
623
+ /** URL or data-URL of the image */
624
+ url: string;
625
+ /** 'in-cell' fills the cell; 'over-cells' floats freely on top of the grid */
626
+ mode: 'in-cell' | 'over-cells';
627
+ /** Native pixel width of the source image (captured after load) */
628
+ originalWidth?: number;
629
+ /** Native pixel height of the source image (captured after load) */
630
+ originalHeight?: number;
631
+ /** Horizontal drag offset in pixels from the anchor cell's left edge */
632
+ dx?: number;
633
+ /** Vertical drag offset in pixels from the anchor cell's top edge */
634
+ dy?: number;
635
+ /** Custom rendered width in pixels (overrides grid-computed width when set) */
636
+ dw?: number;
637
+ /** Custom rendered height in pixels (overrides grid-computed height when set) */
638
+ dh?: number;
639
+ /** Number of grid columns spanned (default 1) */
640
+ colSpan?: number;
641
+ /** Number of grid rows spanned (default 1) */
642
+ rowSpan?: number;
643
+ }
644
+ interface OverlayConfigMap {
645
+ checkbox: CheckboxConfig;
646
+ dropdown: ValidationConfig;
647
+ image: ImageConfig;
648
+ }
649
+ /** Generic config for a specific overlay type */
650
+ type OverlayConfig<T extends OverlayType> = OverlayConfigMap[T];
651
+ interface OverlayEntry {
652
+ type: OverlayType;
653
+ config: OverlayConfigMap[OverlayType];
654
+ el: HTMLElement;
655
+ /** Extra span columns (for images / shapes that cover multiple cells) */
656
+ colSpan: number;
657
+ rowSpan: number;
658
+ /** Custom pixel offsets from the anchor cell's calculated position (for dragging) */
659
+ dx?: number;
660
+ dy?: number;
661
+ /** Custom pixel dimensions (for resizing images) */
662
+ dw?: number;
663
+ dh?: number;
664
+ }
665
+ type PivotAggregation = 'SUM' | 'COUNT' | 'COUNTA' | 'COUNTUNIQUE' | 'AVERAGE' | 'MAX' | 'MIN' | 'MEDIAN' | 'PRODUCT' | 'STDEV' | 'STDEVP' | 'VAR' | 'VARP';
666
+ interface PivotField {
667
+ /** Index of the column in the source data (0-based) */
668
+ sourceColumn: number;
669
+ /** Custom name/label for the field */
670
+ name: string;
671
+ /** Sort order for the groups generated by this field */
672
+ sort?: 'ASC' | 'DESC';
673
+ /** Whether to show totals for this grouping level */
674
+ showTotals?: boolean;
675
+ /** Field name to sort by (for values) or 'source' for the field itself */
676
+ sortBy?: string;
677
+ /** Whether to repeat row labels for multi-level pivots */
678
+ repeatLabels?: boolean;
679
+ }
680
+ interface PivotValue {
681
+ /** Index of the column in the source data (0-based) */
682
+ sourceColumn: number;
683
+ /** Custom name/label for the aggregated value */
684
+ name: string;
685
+ /** Aggregation function to apply */
686
+ aggregation: PivotAggregation;
687
+ /** How to display the value (e.g., as a percentage of total) */
688
+ showAs?: 'default' | 'percent_of_row' | 'percent_of_column' | 'percent_of_grand_total';
689
+ }
690
+ interface PivotConfig {
691
+ /** Range of the source data (inclusive) using 0-based indices */
692
+ sourceRange: {
693
+ x1: number;
694
+ y1: number;
695
+ x2: number;
696
+ y2: number;
697
+ };
698
+ /** Fields to use as rows (grouping) */
699
+ rows: PivotField[];
700
+ /** Fields to use as columns (grouping) */
701
+ columns: PivotField[];
702
+ /** Fields to use as values (aggregation) */
703
+ values: PivotValue[];
704
+ /** Human-readable string representation of the source range (e.g. "Sheet1!A1:D100") */
705
+ sourceRangeString?: string;
706
+ /** Whether to show grand totals for rows/columns */
707
+ showGrandTotals?: boolean;
708
+ /** Name of the worksheet containing the source data */
709
+ sourceSheet?: string;
710
+ /** Anchor coordinate for the top-left of the pivot result (x: column, y: row) */
711
+ destAnchor?: {
712
+ x: number;
713
+ y: number;
714
+ };
715
+ }
716
+
717
+ /** Minimal interface the OverlayManager needs from Viewport for positioning. */
718
+ interface ViewportPositionCtx {
719
+ getCumulativeWidth(col: number): number;
720
+ getCumulativeHeight(row: number): number;
721
+ getColWidth(col: number): number;
722
+ getRowHeight(row: number): number;
723
+ scrollLeft: number;
724
+ scrollTop: number;
725
+ }
726
+ /** Minimal Worksheet interface used to read/write cell values. */
727
+ interface WorksheetLike {
728
+ data: {
729
+ getValue(x: number, y: number): string;
730
+ };
731
+ setValue(x: number, y: number, value: string): void;
732
+ setOverlay<T extends OverlayType>(x: number, y: number, type: T, config: OverlayConfig<T>): void;
733
+ removeOverlay(x: number, y: number): void;
734
+ colModel: {
735
+ getWidth(col: number): number;
736
+ };
737
+ rowModel: {
738
+ getHeight(row: number): number;
739
+ };
740
+ selectionModel?: {
741
+ anchorX: number;
742
+ anchorY: number;
743
+ };
744
+ }
745
+ /**
746
+ * OverlayManager
747
+ *
748
+ * Manages absolutely-positioned overlay elements that sit above the virtual grid.
749
+ * Mount via `ws.overlayManager = new OverlayManager(ws, viewLayer)`.
750
+ *
751
+ * Positioning is re-synced on every Viewport.render() call so overlays scroll
752
+ * and reposition correctly without any separate scroll listener.
753
+ */
754
+ declare class OverlayManager {
755
+ private ws;
756
+ /** Map key: `"x,y"` */
757
+ private entries;
758
+ /** The overlay layer div — sits inside viewLayer, above cells */
759
+ private layer;
760
+ /** Last seen viewport context — used to immediately position new overlays */
761
+ private lastCtx;
762
+ constructor(ws: WorksheetLike, viewLayer: HTMLElement);
763
+ /**
764
+ * Add or replace an overlay at cell (x, y).
765
+ * @param x 0-based column
766
+ * @param y 0-based row
767
+ * @param type Overlay kind
768
+ * @param config Type-specific options
769
+ */
770
+ set<T extends OverlayType>(x: number, y: number, type: T, config: OverlayConfig<T>): void;
771
+ /**
772
+ * Get an overlay at cell (x, y).
773
+ */
774
+ get(x: number, y: number): OverlayEntry | undefined;
775
+ /**
776
+ * Remove an overlay at cell (x, y).
777
+ */
778
+ remove(x: number, y: number): void;
779
+ /**
780
+ * Iterate over all overlays.
781
+ */
782
+ forEach(callback: (entry: OverlayEntry, key: string) => void): void;
783
+ /**
784
+ * Remove all overlays.
785
+ */
786
+ clear(): void;
787
+ /**
788
+ * Re-position all overlays to match current scroll / cell sizes.
789
+ * Called by Viewport.render() via ws.overlayManager?.sync(ctx).
790
+ */
791
+ sync(ctx: ViewportPositionCtx): void;
792
+ private _makeCtx;
793
+ private _destroyEntry;
794
+ }
795
+
796
+ declare class PivotPanel {
797
+ element: HTMLElement;
798
+ private config;
799
+ private sourceColumns;
800
+ private sourceData;
801
+ private onUpdate;
802
+ constructor(parent: HTMLElement, config: PivotConfig, sourceColumns: string[], sourceData: any[][], onUpdate: (config: PivotConfig) => void);
803
+ open(): void;
804
+ close(): void;
805
+ private render;
806
+ private createSection;
807
+ private showAddFieldMenu;
808
+ }
809
+
810
+ declare class RowModel {
811
+ private defaultHeight;
812
+ private heights;
813
+ private hidden;
814
+ constructor(defaultHeight?: number);
815
+ getHeight(index: number): number;
816
+ setHeight(index: number, heightPx: number): void;
817
+ hide(index: number): void;
818
+ show(index: number): void;
819
+ splice(index: number, count: number, direction: 'insert' | 'delete'): void;
820
+ copyFrom(source: RowModel): void;
821
+ }
822
+ declare class ColModel {
823
+ private defaultWidth;
824
+ private widths;
825
+ private hidden;
826
+ constructor(defaultWidth?: number);
827
+ getWidth(index: number): number;
828
+ setWidth(index: number, widthPx: number): void;
829
+ hide(index: number): void;
830
+ show(index: number): void;
831
+ splice(index: number, count: number, direction: 'insert' | 'delete'): void;
832
+ copyFrom(source: ColModel): void;
833
+ }
834
+
835
+ type LicensePlan = 'starter' | 'pro' | 'enterprise';
836
+
837
+ declare class SheetData {
838
+ /** Sparse cell storage keyed by "x,y" */
839
+ private cells;
840
+ /** Set by Worksheet after construction to enable formula evaluation */
841
+ formulaEngine?: FormulaEngine;
842
+ /** Set by Worksheet to enable license-based validation */
843
+ getEdition?: () => LicensePlan;
844
+ /** Read-only access to the internal cell map (used for cloning). */
845
+ protected getCells(): ReadonlyMap<string, CellData>;
846
+ /** Get the raw input string value (e.g. "1200" or "=A1") */
847
+ getValue(x: number, y: number): string;
848
+ /** Iterate over all populated cells (sparse scan) */
849
+ forEachCell(callback: (x: number, y: number, cell: CellData) => void): void;
850
+ /** Get all populated cells in a specific row (sparse scan) */
851
+ getCellsInRow(rowIdx: number): Array<[number, CellData]>;
852
+ /**
853
+ * Efficiently bulk-load parsed data from @worksheet/parser directly into the underlying maps.
854
+ * Bypasses the FormatEngine's slow parsing for string/number extraction, mapping cell types directly.
855
+ */
856
+ loadFromParser(parsedData: SheetData$1): Promise<void>;
857
+ /** Get the parsed typed data */
858
+ getCell(x: number, y: number): CellData | undefined;
859
+ /** Set a new raw input value, parsing it automatically */
860
+ setValue(x: number, y: number, rawInput: string): void;
861
+ /** Delete a cell entirely (including values, styles, formats, notes, comments) */
862
+ deleteCell(x: number, y: number): void;
863
+ /** Get note for a cell */
864
+ getNote(x: number, y: number): string | undefined;
865
+ /** Set note for a cell */
866
+ setNote(x: number, y: number, note: string | undefined): void;
867
+ /** Get comments for a cell */
868
+ getComments(x: number, y: number): any[] | undefined;
869
+ /** Set comments for a cell */
870
+ setComments(x: number, y: number, comments: any[] | undefined): void;
871
+ /** Set format mask explicitly (e.g "$#,##0.00") — legacy */
872
+ setFormat(x: number, y: number, formatString: string): void;
873
+ /** Get the full style object for a cell (returns empty object if none) */
874
+ getStyle(x: number, y: number): CellStyle;
875
+ /** Replace the full style object for a cell */
876
+ setStyle(x: number, y: number, style: CellStyle): void;
877
+ /** Deep-copy all cells and merges from another SheetData instance. */
878
+ copyFrom(source: SheetData): void;
879
+ /** Merge partial style properties into the existing cell style. */
880
+ mergeStyle(x: number, y: number, partial: Partial<CellStyle>): void;
881
+ /**
882
+ * Get the computed (evaluated) value of a cell.
883
+ * If the cell contains a formula, runs it through FormulaEngine.
884
+ * Otherwise returns parsedValue from FormatEngine.
885
+ */
886
+ getComputedValue(x: number, y: number): unknown;
887
+ /** Get display string formatted for the DOM */
888
+ getDisplayString(x: number, y: number): string;
889
+ /** Each merge range: { x1, y1, x2, y2 } (inclusive, 0-indexed) */
890
+ private merges;
891
+ /** Add a merge range */
892
+ addMerge(x1: number, y1: number, x2: number, y2: number): void;
893
+ /** Remove merges that overlap the given range */
894
+ removeMerge(x1: number, y1: number, x2: number, y2: number): void;
895
+ /** Get all merge ranges */
896
+ getMerges(): MergeRange[];
897
+ /** Find the merge range that contains cell (x, y), or null */
898
+ getMergeForCell(x: number, y: number): MergeRange | null;
899
+ /** Returns true if (x, y) is inside a merge but is NOT the top-left anchor cell */
900
+ isMergedHidden(x: number, y: number): boolean;
901
+ /**
902
+ * Shift cells and merges row-wise.
903
+ * If x1/x2 are provided, ONLY those columns are shifted.
904
+ */
905
+ spliceRows(y: number, count: number, direction: 'insert' | 'delete', x1?: number, x2?: number): void;
906
+ /**
907
+ * Shift cells and merges column-wise.
908
+ * If y1/y2 are provided, ONLY those rows are shifted.
909
+ */
910
+ spliceCols(x: number, count: number, direction: 'insert' | 'delete', y1?: number, y2?: number): void;
911
+ /** Clear all data */
912
+ clear(): void;
913
+ }
914
+ /** Merge range definition */
915
+ interface MergeRange {
916
+ x1: number;
917
+ y1: number;
918
+ x2: number;
919
+ y2: number;
920
+ }
921
+
922
+ /**
923
+ * data/utils.ts — pure coordinate & address utilities.
924
+ *
925
+ * No DOM dependencies — safe to use universally across the package.
926
+ */
927
+ /**
928
+ * Convert a 0-based column index to an Excel letter label.
929
+ * 0 → "A", 25 → "Z", 26 → "AA", …
930
+ */
931
+ declare function colIndexToLetter(n: number): string;
932
+ /**
933
+ * Convert 0-based (x, y) coordinates to an Excel address string.
934
+ * (0, 0) → "A1", (1, 2) → "B3"
935
+ */
936
+ declare function coordsToAddr(x: number, y: number): string;
937
+ /**
938
+ * Parse an Excel address string into 0-based (x, y) coordinates.
939
+ * Returns `null` for invalid input.
940
+ * "A1" → { x: 0, y: 0 }, "B3" → { x: 1, y: 2 }
941
+ */
942
+ declare function parseAddress(addr: string): {
943
+ x: number;
944
+ y: number;
945
+ } | null;
946
+
947
+ /**
948
+ * Worksheet — per-sheet object. Phase 2 enhanced.
949
+ * Integrates SelectionModel (anchor/focus), CellEditor, and ClipboardHandler.
950
+ * Mirrors jSpreadsheet CE's worksheet object pattern.
951
+ */
952
+ declare class WorksheetModel {
953
+ parent: Spreadsheet;
954
+ options: SheetMeta;
955
+ element: HTMLElement;
956
+ content: HTMLElement;
957
+ table: HTMLTableElement;
958
+ thead: HTMLTableSectionElement;
959
+ tbody: HTMLTableSectionElement;
960
+ headerContainer: HTMLTableRowElement;
961
+ colgroupContainer: HTMLElement;
962
+ get root(): HTMLElement;
963
+ data: SheetData;
964
+ rowModel: RowModel;
965
+ colModel: ColModel;
966
+ filterState: FilterState;
967
+ overlays: OverlayRegistry;
968
+ cfManager: ConditionalFormattingManager;
969
+ viewport?: Viewport;
970
+ pivotTables: any[];
971
+ corner: HTMLElement;
972
+ textarea: HTMLTextAreaElement;
973
+ addRowsBar: HTMLElement;
974
+ selectionState: SelectionState;
975
+ selectionModel: SelectionModel;
976
+ selectionPainter: SelectionPainter;
977
+ cellEditor: CellEditor | null;
978
+ overlayManager?: OverlayManager;
979
+ history: HistoryEntry[];
980
+ historyIndex: number;
981
+ private readonly HISTORY_LIMIT;
982
+ /** When true, setValue/setWidth/setHeight skip pushing to history (used by _applyHistory) */
983
+ private _skipHistory;
984
+ /** When true, UI updates (viewport renders) are suppressed (used for batch loading) */
985
+ private _skipViewUpdate;
986
+ /** Lock for lazy overlay manager initialization */
987
+ private _ensuringOverlays;
988
+ resizing: {
989
+ column?: number;
990
+ row?: number;
991
+ width?: number;
992
+ height?: number;
993
+ element?: HTMLElement;
994
+ } | null;
995
+ editingCell: {
996
+ x: number;
997
+ y: number;
998
+ } | null;
999
+ _onViewChange?: (x: number, y: number) => void;
1000
+ constructor(parent: Spreadsheet, options: SheetMeta);
1001
+ /** Max column index (0-based) */
1002
+ get maxCol(): number;
1003
+ /** Max row index (0-based) */
1004
+ get maxRow(): number;
1005
+ applyParsedMeta(meta: SheetMeta): void;
1006
+ /** Deep-clone state from another WorksheetModel instance. */
1007
+ cloneFrom(source: WorksheetModel): void;
1008
+ /** Efficiently injects structured parser outputs for fast layout building */
1009
+ loadFromParser(parsedData: SheetData$1): Promise<void>;
1010
+ /** Detect if a row should be auto-fitted based on parser data (e.g. no height, but has wrapping or dropdowns) */
1011
+ private rowHeightsNeedAutoFit;
1012
+ /**
1013
+ * Auto-fit a row's height based on its current content and column widths.
1014
+ */
1015
+ autoFitRowHeight(rowIdx: number): void;
1016
+ /** Get cell text value at (x, y) */
1017
+ getValue(x: number, y: number): string;
1018
+ /** Get the evaluated result of a cell (for formulas) or its literal value */
1019
+ getEvaluatedValue(x: number, y: number): string;
1020
+ private _invalidCells;
1021
+ private _validationPopover;
1022
+ /** Check if a cell has a validation warning */
1023
+ isInvalid(x: number, y: number): boolean;
1024
+ /**
1025
+ * Evaluates if a given string passes the cell's validation rules (if any).
1026
+ * @returns true if valid or if there are no strict rules.
1027
+ */
1028
+ checkValidationValue(x: number, y: number, testValue: string): boolean;
1029
+ /** Run validation for a specific cell, updating UI state */
1030
+ validateCell(x: number, y: number): void;
1031
+ private _getOptionsFromRange;
1032
+ private _refreshDependentDropdowns;
1033
+ private _isCellInRange;
1034
+ /** Set cell text value at (x, y) */
1035
+ setValue(x: number, y: number, value: string): void;
1036
+ /**
1037
+ * Set the style of a cell.
1038
+ *
1039
+ * @param x - Column index (0-based).
1040
+ * @param y - Row index (0-based).
1041
+ * @param style - Partial style object.
1042
+ */
1043
+ setStyle(x: number, y: number, style: Partial<CellStyle>): void;
1044
+ /**
1045
+ * Set multiple cell values at once as a single undoable history entry.
1046
+ */
1047
+ setValueBatch(cells: Array<{
1048
+ x: number;
1049
+ y: number;
1050
+ value: string;
1051
+ }>): void;
1052
+ /** Get current selection coords (normalized bounding box) */
1053
+ getSelection(): SelectionRange;
1054
+ /**
1055
+ * Update selection from explicit coords (public API + legacy support).
1056
+ * Sets anchor = x1,y1 and focus = x2,y2.
1057
+ */
1058
+ updateSelectionFromCoords(x1: number, y1: number, x2: number, y2: number): void;
1059
+ /** Force repaint the selection (e.g. after resize) */
1060
+ refreshSelection(): void;
1061
+ /**
1062
+ * Apply the current SelectionModel state:
1063
+ * 1. Sync legacy SelectionState
1064
+ * 2. Repaint via SelectionPainter
1065
+ * 3. Update FormulaBar
1066
+ * 4. Update StatusBar aggregates
1067
+ * 5. Fire onselection callback
1068
+ * 6. Scroll anchor into view
1069
+ */
1070
+ _applySelectionModel(): void;
1071
+ /** Move anchor+focus by (dx, dy) — plain navigation */
1072
+ moveSelection(dx: number, dy: number): void;
1073
+ /** Extend focus by (dx, dy) — shift navigation */
1074
+ extendSelection(dx: number, dy: number): void;
1075
+ /** Select all cells */
1076
+ selectAll(): void;
1077
+ /** Select entire column x */
1078
+ selectColumn(x: number): void;
1079
+ /** Select entire row y */
1080
+ selectRow(y: number): void;
1081
+ /** Open inline cell editor at (x, y), optionally with an initial character */
1082
+ openEditor(x: number, y: number, initialChar?: string, options?: {
1083
+ preventFocus?: boolean;
1084
+ }): void;
1085
+ /** Close inline cell editor */
1086
+ closeEditor(save: boolean): void;
1087
+ /** Undo last action */
1088
+ undo(): void;
1089
+ /** Redo last undone action */
1090
+ redo(): void;
1091
+ /** Set column width in px */
1092
+ setWidth(col: number, width: number, skipHistory?: boolean): void;
1093
+ /** Set row height in px */
1094
+ setHeight(row: number, height: number, skipHistory?: boolean): void;
1095
+ /** Turn on filter buttons in all column headers. */
1096
+ enableFilters(col?: number): void;
1097
+ /**
1098
+ * Remove all filters: un-hide all filter-hidden rows and hide funnel buttons.
1099
+ * Rows hidden by other means (explicit hide) are NOT un-hidden.
1100
+ */
1101
+ disableFilters(col?: number): void;
1102
+ /**
1103
+ * Recompute row visibility based on the current FilterState.
1104
+ * Hides rows that do not pass the active filters.
1105
+ * Row 0 (header) is never hidden.
1106
+ */
1107
+ applyFilters(): void;
1108
+ insertRow(y: number, count?: number): void;
1109
+ deleteRow(y: number, count?: number): void;
1110
+ insertColumn(x: number, count?: number): void;
1111
+ deleteColumn(x: number, count?: number): void;
1112
+ /** Called by ResizeObserver when container resizes */
1113
+ onResize(): void;
1114
+ /** Download current sheet as CSV */
1115
+ download(): Promise<void>;
1116
+ /** Get the style object for anchor cell (used by toolbar sync) */
1117
+ getStyle(x: number, y: number): CellStyle;
1118
+ /**
1119
+ * Apply a partial style to all cells in the current selection.
1120
+ * Records a SINGLE 'style-batch' history entry so undo/redo is atomic.
1121
+ */
1122
+ applyStyleToSelection(partial: Partial<CellStyle>): void;
1123
+ /**
1124
+ * Apply a number format style to all cells in the current selection.
1125
+ */
1126
+ setFormatToSelection(fmt: CellStyle['numberFormat'], decimals?: number): void;
1127
+ /** Merge all cells in the current selection into one */
1128
+ mergeSelection(): void;
1129
+ /** Unmerge all merges within the current selection */
1130
+ unmergeSelection(): void;
1131
+ /** Merge each row in the selection horizontally */
1132
+ mergeHorizontally(): void;
1133
+ /** Merge each column in the selection vertically */
1134
+ mergeVertically(): void;
1135
+ /** Apply manual direction override to selection */
1136
+ applyDirectionToSelection(dir: 'ltr' | 'rtl'): void;
1137
+ /**
1138
+ * Applies borders dynamically to avoid double borders between adjacent cells.
1139
+ */
1140
+ applyBordersToSelection(type: string, weight: number, style: string, borderColor: string): void;
1141
+ /**
1142
+ * Apply a paste snapshot (value + style per cell) atomically with one undo entry.
1143
+ * Called by ClipboardHandler after building the before/after cell snapshots.
1144
+ */
1145
+ pasteRange(record: Array<{
1146
+ x: number;
1147
+ y: number;
1148
+ beforeValue: string;
1149
+ afterValue: string;
1150
+ beforeStyle: CellStyle | undefined;
1151
+ afterStyle: CellStyle | undefined;
1152
+ beforeOverlay: any | undefined;
1153
+ afterOverlay: any | undefined;
1154
+ afterNote?: string;
1155
+ afterComments?: any[];
1156
+ }>): void;
1157
+ /**
1158
+ * Get all data (cells, styles, merges, overlays) for a range.
1159
+ * Useful for advanced copy/paste.
1160
+ */
1161
+ getRangeData(range: SelectionRange): {
1162
+ cells: Array<Array<{
1163
+ value: string;
1164
+ style?: CellStyle;
1165
+ overlay?: any;
1166
+ note?: string;
1167
+ comments?: any[];
1168
+ }>>;
1169
+ merges: Array<{
1170
+ x1: number;
1171
+ y1: number;
1172
+ x2: number;
1173
+ y2: number;
1174
+ }>;
1175
+ };
1176
+ /**
1177
+ * Clear all cell values AND styles in a range as a single undoable action.
1178
+ */
1179
+ clearRange(x1: number, y1: number, x2: number, y2: number): void;
1180
+ private _pushHistory;
1181
+ private _applyHistory;
1182
+ private _updateFormulaBar;
1183
+ /** Scroll cell at (x,y) into view */
1184
+ _scrollCellIntoView(x: number, y: number): void;
1185
+ /**
1186
+ * Get an overlay at the given cell position.
1187
+ */
1188
+ getOverlay(x: number, y: number): OverlayEntry | undefined;
1189
+ /**
1190
+ * Place a cell overlay (checkbox)
1191
+ * at the given cell position. Lazy-loads @worksheet/utils on first call.
1192
+ */
1193
+ setOverlay<T extends OverlayType>(x: number, y: number, type: T, config: OverlayConfig<T>,
1194
+ /** @internal — pre-mutation before-snapshot injected by OverlayManager.updateConfig */
1195
+ _beforeHint?: {
1196
+ type: OverlayType;
1197
+ config: any;
1198
+ }): Promise<void>;
1199
+ /** Remove the overlay at cell (x, y). */
1200
+ removeOverlay(x: number, y: number): void;
1201
+ private _parseSqref;
1202
+ private _mapCFOperator;
1203
+ private _mapParsedStyleToCellStyle;
1204
+ /** Remove all overlays on this worksheet. */
1205
+ clearOverlays(): void;
1206
+ private _ensureOverlayManager;
1207
+ private _updateValidationPopover;
1208
+ private _showValidationPopover;
1209
+ private _hideValidationPopover;
1210
+ }
1211
+
1212
+ /**
1213
+ * ClipboardHandler — manages copy/cut/paste with marching ants visual.
1214
+ * Copies cell values, styles, merges, and overlays.
1215
+ * Supports multiple MIME types for cross-app compatibility.
1216
+ */
1217
+ declare class ClipboardHandler {
1218
+ /** Internal snapshot for same-instance copy/paste */
1219
+ private snapshot;
1220
+ /** Source range for the snapshot */
1221
+ private srcRange;
1222
+ private isCutMode;
1223
+ private ws;
1224
+ /** The SVG marching-ants overlay element */
1225
+ private copyBorderEl;
1226
+ copy(ws: WorksheetModel): void;
1227
+ cut(ws: WorksheetModel): void;
1228
+ /**
1229
+ * Paste at current selection anchor.
1230
+ * Priority: application/x-worksheet > text/html > text/plain.
1231
+ */
1232
+ paste(ws: WorksheetModel, text?: string): Promise<void>;
1233
+ clear(): void;
1234
+ private _pasteRange;
1235
+ private _pasteTSV;
1236
+ private _clear;
1237
+ private _startAnts;
1238
+ private _positionBorder;
1239
+ private _applyClass;
1240
+ private _writeToClipboard;
1241
+ private _toHTML;
1242
+ }
1243
+
1244
+ /**
1245
+ * CommentPanel — A floating panel to display and edit threaded comments.
1246
+ * Matches Google Sheets exact styling (white box, shadows, threaded replies).
1247
+ */
1248
+ declare class CommentPanel {
1249
+ element: HTMLElement;
1250
+ private ws;
1251
+ private currentX;
1252
+ private currentY;
1253
+ private _visible;
1254
+ constructor();
1255
+ attach(container: HTMLElement): void;
1256
+ get isVisible(): boolean;
1257
+ private _boundClickOutside;
1258
+ /** Open comments for a specific cell */
1259
+ open(ws: WorksheetModel, x: number, y: number): void;
1260
+ private _renderContent;
1261
+ private _renderNewCommentInput;
1262
+ private _createAvatar;
1263
+ private _renderThread;
1264
+ private _createMoreMenu;
1265
+ private _renderEditMode;
1266
+ private _formatTime;
1267
+ close(): void;
1268
+ }
1269
+
1270
+ /**
1271
+ * NoteEditor — A floating textarea to edit cell notes.
1272
+ * Matches Google Sheets exact styling (black border, yellow background tooltip).
1273
+ */
1274
+ declare class NoteEditor {
1275
+ element: HTMLElement;
1276
+ private textarea;
1277
+ private ws;
1278
+ private currentX;
1279
+ private currentY;
1280
+ private _visible;
1281
+ constructor();
1282
+ attach(container: HTMLElement): void;
1283
+ get isVisible(): boolean;
1284
+ private _boundClickOutside;
1285
+ /** Open editor for a specific cell in the given worksheet */
1286
+ open(ws: WorksheetModel, x: number, y: number, editMode?: boolean): void;
1287
+ /** Close and optionally save the note */
1288
+ close(save?: boolean): void;
1289
+ }
1290
+
1291
+ /**
1292
+ * ConditionalFormattingPanel — Sidebar for managing conditional formatting rules.
1293
+ * Redesigned to match Google Sheets UI/UX with premium aesthetics.
1294
+ */
1295
+ declare class ConditionalFormattingPanel {
1296
+ element: HTMLElement;
1297
+ private parent;
1298
+ private body;
1299
+ private currentWs;
1300
+ private editingRuleIndex;
1301
+ private tempRule;
1302
+ constructor(parent: Spreadsheet);
1303
+ open(ws: WorksheetModel): void;
1304
+ close(): void;
1305
+ private _buildHeader;
1306
+ private _render;
1307
+ private _renderRuleList;
1308
+ private _renderRuleEditor;
1309
+ private _createSection;
1310
+ private _getOperatorLabel;
1311
+ private _hasValueInput;
1312
+ }
1313
+
1314
+ /**
1315
+ * FillHandler — handles fill-handle drag to auto-fill cells.
1316
+ * Detects number patterns, dates, and falls back to copy.
1317
+ */
1318
+ declare class FillHandler {
1319
+ private ws;
1320
+ private startRange;
1321
+ private previewEl;
1322
+ private isDragging;
1323
+ private fillDir;
1324
+ /**
1325
+ * Called when pointerdown lands on the fill handle corner.
1326
+ */
1327
+ startDrag(e: PointerEvent, ws: WorksheetModel): void;
1328
+ /**
1329
+ * Called on pointermove while dragging fill handle.
1330
+ */
1331
+ onMove(e: PointerEvent): void;
1332
+ /**
1333
+ * Called on pointerup — execute the fill.
1334
+ */
1335
+ endDrag(e: PointerEvent): void;
1336
+ private _executeFill;
1337
+ /** Detect pattern and return a series function */
1338
+ private _detectSeries;
1339
+ private _colValues;
1340
+ private _rowValues;
1341
+ private _positionPreview;
1342
+ private _cleanup;
1343
+ private _getCell;
1344
+ }
1345
+
1346
+ /**
1347
+ * FindReplace — Google Sheets-style Find and Replace dialog.
1348
+ * Matches the exact Google Sheets UI layout.
1349
+ */
1350
+ declare class FindReplace {
1351
+ element: HTMLElement;
1352
+ private parent;
1353
+ private findInput;
1354
+ private replaceInput;
1355
+ private searchDropdown;
1356
+ private matchCaseCheckbox;
1357
+ private entireCellCheckbox;
1358
+ private useRegexCheckbox;
1359
+ private formulaeCheckbox;
1360
+ private linksCheckbox;
1361
+ private statusLabel;
1362
+ private matches;
1363
+ private currentMatchIdx;
1364
+ constructor(parent: Spreadsheet);
1365
+ open(): void;
1366
+ close(): void;
1367
+ isOpen(): boolean;
1368
+ private _createInputRow;
1369
+ private _createCheckbox;
1370
+ private _createActionButton;
1371
+ private _getWorksheet;
1372
+ private _search;
1373
+ private _isMatch;
1374
+ private _findNext;
1375
+ private _findPrev;
1376
+ private _goToMatch;
1377
+ private _replaceCurrent;
1378
+ private _replaceAll;
1379
+ private _replaceValue;
1380
+ private _updateStatus;
1381
+ }
1382
+
1383
+ /**
1384
+ * DataValidation — Google Sheets-style Data validation rules sidebar.
1385
+ * Specifically handles Dropdown configuration.
1386
+ */
1387
+ declare class DataValidation {
1388
+ element: HTMLElement;
1389
+ private parent;
1390
+ private body;
1391
+ private rangeContainer;
1392
+ private rangeLabel;
1393
+ private criteriaContainer;
1394
+ private advancedContainer;
1395
+ private optionsContainer;
1396
+ private currentWs;
1397
+ private currentX;
1398
+ private currentY;
1399
+ private options;
1400
+ private displayStyle;
1401
+ private showWarning;
1402
+ private criteria;
1403
+ private value1;
1404
+ private value2;
1405
+ private showHelpText;
1406
+ private helpText;
1407
+ private allowMultiSelect;
1408
+ private advancedExpanded;
1409
+ private activePicker;
1410
+ private pickerHandler;
1411
+ constructor(parent: Spreadsheet);
1412
+ open(ws: WorksheetModel, x: number, y: number): void;
1413
+ close(): void;
1414
+ updateSelection(ws: WorksheetModel): void;
1415
+ private _buildHeader;
1416
+ private _errorMsg;
1417
+ private _inputRefs;
1418
+ private _buildFooter;
1419
+ private _render;
1420
+ private _renderRange;
1421
+ private _renderCriteria;
1422
+ private _renderAdvanced;
1423
+ private _renderOptions;
1424
+ private _openColorPicker;
1425
+ private _closePicker;
1426
+ private _updateCPPreview;
1427
+ private _save;
1428
+ private _getRangeRef;
1429
+ }
1430
+
1431
+ type MenuType = 'cell' | 'row-header' | 'col-header' | 'tab' | 'image';
1432
+ interface MenuItem {
1433
+ label: string;
1434
+ shortcut?: string;
1435
+ icon?: string;
1436
+ disabled?: boolean;
1437
+ separator?: false;
1438
+ items?: MenuDef[];
1439
+ action?: (ws: WorksheetModel | null, targetEl: HTMLElement | null) => void;
1440
+ }
1441
+ interface MenuSeparator {
1442
+ separator: true;
1443
+ }
1444
+ type MenuDef = MenuItem | MenuSeparator;
1445
+ /**
1446
+ * ContextMenu — Web-native popup menu supporting cascading submenus.
1447
+ */
1448
+ declare class ContextMenu {
1449
+ element: HTMLElement;
1450
+ private spreadsheet;
1451
+ private _visible;
1452
+ private childMenu;
1453
+ private activeItemEl;
1454
+ private activeTarget;
1455
+ private parentMenu;
1456
+ constructor(spreadsheet: Spreadsheet, parentMenu?: ContextMenu | null);
1457
+ private _contains;
1458
+ openMenu(x: number, y: number, items: MenuDef[], ws: WorksheetModel | null, options?: {
1459
+ isMenuList?: boolean;
1460
+ targetEl?: HTMLElement | null;
1461
+ }): void;
1462
+ open(x: number, y: number, type: MenuType, ws: WorksheetModel | null, targetEl?: HTMLElement): void;
1463
+ close(): void;
1464
+ closeAll(): void;
1465
+ private _render;
1466
+ private _getItems;
1467
+ /**
1468
+ * Sort all rows by the values in `col`.
1469
+ * Sorts ALL rows (no assumed header row).
1470
+ * Numbers are compared numerically; strings use locale-aware natural sort.
1471
+ * Empty cells always sort to the bottom regardless of direction.
1472
+ */
1473
+ private _sortRows;
1474
+ }
1475
+ declare module '../sheet-tabs/SheetTabs' {
1476
+ interface SheetTabs {
1477
+ startRename(): void;
1478
+ }
1479
+ }
1480
+
1481
+ /**
1482
+ * FormulaBar — NameBox + ƒx button + formula input.
1483
+ */
1484
+ declare class FormulaBar {
1485
+ element: HTMLElement;
1486
+ private nameBoxEl;
1487
+ private formulaInputEl;
1488
+ private confirmBtns;
1489
+ private spreadsheet;
1490
+ private _fnMenu?;
1491
+ private _fxBtn;
1492
+ constructor(spreadsheet: Spreadsheet);
1493
+ private build;
1494
+ update(address: string, value: string): void;
1495
+ enterEditMode(value: string): void;
1496
+ exitEditMode(): void;
1497
+ private _navigateToAddress;
1498
+ }
1499
+
1500
+ /**
1501
+ * LoadingOverlay — A premium loading screen with the custom "W" Chart logo from test.svg.
1502
+ */
1503
+ declare class LoadingOverlay {
1504
+ element: HTMLElement;
1505
+ private _visible;
1506
+ constructor(parent: HTMLElement);
1507
+ show(): void;
1508
+ hide(): void;
1509
+ private _injectStyles;
1510
+ }
1511
+
1512
+ /**
1513
+ * SheetTabs — horizontal tab strip replacing jSuites.tabs().
1514
+ * Zero dependencies.
1515
+ */
1516
+ declare class SheetTabs {
1517
+ element: HTMLElement;
1518
+ private spreadsheet;
1519
+ private strip;
1520
+ activeIndex: number;
1521
+ private addBtn;
1522
+ private navLeft;
1523
+ private navRight;
1524
+ private navContainer;
1525
+ private resizeObserver;
1526
+ constructor(spreadsheet: Spreadsheet);
1527
+ private build;
1528
+ private updateScrollState;
1529
+ render(): void;
1530
+ /** Update the visibility state of the add-sheet button based on maxSheets config and license limits */
1531
+ updateAddButton(): void;
1532
+ setActiveTab(index: number): void;
1533
+ private _startRename;
1534
+ private _attachDragReorder;
1535
+ private navBtn;
1536
+ private openAllSheetsMenu;
1537
+ private getWatermark;
1538
+ }
1539
+
1540
+ declare class KeyboardShortcuts {
1541
+ element: HTMLElement;
1542
+ private parent;
1543
+ private searchInput;
1544
+ private listContainer;
1545
+ constructor(parent: Spreadsheet);
1546
+ open(): void;
1547
+ close(): void;
1548
+ private _renderList;
1549
+ }
1550
+
1551
+ declare class Toolbar {
1552
+ element: HTMLElement;
1553
+ private parent;
1554
+ private _fnMenu?;
1555
+ private btnBold;
1556
+ private btnItalic;
1557
+ private btnStrikethrough;
1558
+ private spanFontFamily;
1559
+ private spanFontSize;
1560
+ private spanZoom;
1561
+ private colorBarText;
1562
+ private colorBarFill;
1563
+ private colorBarBorder;
1564
+ private _activeDropdowns;
1565
+ private _activeAnchors;
1566
+ private _zoom;
1567
+ private _borderPenColor;
1568
+ private _borderPenWeight;
1569
+ private _borderPenStyle;
1570
+ constructor(parent: Spreadsheet);
1571
+ syncToWorksheet(ws: WorksheetModel): void;
1572
+ /** Called by Viewport link tooltip to open the insert-link panel */
1573
+ openLinkEditor(x: number, y: number): void;
1574
+ private _build;
1575
+ private _makeBtn;
1576
+ private _setupResponsive;
1577
+ private _onResize;
1578
+ private _dispatch;
1579
+ private _openFunctionMenu;
1580
+ private _openImageDropdown;
1581
+ openImageDialog(title: string, onApplyImg: (url: string) => void): void;
1582
+ private _openOverflowMenu;
1583
+ private _openDropdown;
1584
+ private _closeDropdowns;
1585
+ private _ddItem;
1586
+ private _openFileMenu;
1587
+ private _openZoomDropdown;
1588
+ private _openFormatDropdown;
1589
+ private _openFontFamilyDropdown;
1590
+ private _openFontSizeDropdown;
1591
+ private _openColorDropdown;
1592
+ private _openBordersDropdown;
1593
+ private _openBorderStyleDropdown;
1594
+ private _openMergeDropdown;
1595
+ private _openAlignDropdown;
1596
+ private _openVAlignDropdown;
1597
+ private _openWrapDropdown;
1598
+ private _openRotationDropdown;
1599
+ private _openLinkPanel;
1600
+ /** Reusable dialog shell */
1601
+ private _createCustomFmtDialog;
1602
+ /** Custom Currency dialog — exact Google Sheets clone */
1603
+ private _openCustomCurrencyDialog;
1604
+ /** Custom Date and Time dialog — Google Sheets clone */
1605
+ private _openCustomDateTimeDialog;
1606
+ /** Custom Number Format dialog — Google Sheets clone */
1607
+ private _openCustomNumberDialog;
1608
+ private _insertCheckbox;
1609
+ private _insertDropdown;
1610
+ private _openDirectionDropdown;
1611
+ }
1612
+
1613
+ /**
1614
+ * Watermark — a repeating diagonal overlay for trial and expired licenses.
1615
+ */
1616
+ declare class Watermark {
1617
+ element: HTMLElement;
1618
+ private spreadsheet;
1619
+ constructor(spreadsheet: Spreadsheet);
1620
+ update(): void;
1621
+ destroy(): void;
1622
+ }
1623
+
1624
+ /**
1625
+ * ThemeManager — handles Built-in themes and Custom color overrides.
1626
+ * Maps user-friendly color names to internal CSS Custom Properties.
1627
+ */
1628
+ declare class ThemeManager {
1629
+ private root;
1630
+ /** The currently active default cell font display name */
1631
+ defaultCellFont: string;
1632
+ private static COLOR_MAP;
1633
+ constructor(root: HTMLElement);
1634
+ /** Set built-in theme (light/dark) */
1635
+ setTheme(theme: 'light' | 'dark'): void;
1636
+ /** Apply custom color overrides via inline styles on the root element */
1637
+ setColors(colors: Partial<ThemeColors>): void;
1638
+ /** Apply custom font overrides via CSS variables */
1639
+ setFonts(fonts: ThemeFonts): void;
1640
+ /**
1641
+ * Set the UI-chrome font (toolbar labels, sheet tabs, formula bar, status bar etc.).
1642
+ * This intentionally does NOT affect cell content — cells use per-cell fontFamily styles.
1643
+ * @param displayName - Font display name (stored for reference)
1644
+ * @param cssFamily - Full CSS font-family string to apply to --worksheet-font
1645
+ */
1646
+ setDefaultFont(displayName: string, cssFamily: string): void;
1647
+ }
1648
+
1649
+ /**
1650
+ * Spreadsheet — top-level owner.
1651
+ * Mirrors jSpreadsheet CE's spreadsheet plain-object, but as a class.
1652
+ * Owns all WorksheetModel instances and UI chrome components.
1653
+ */
1654
+ declare class Spreadsheet {
1655
+ element: HTMLElement;
1656
+ root: HTMLElement;
1657
+ config: WorksheetOptions;
1658
+ worksheets: WorksheetModel[];
1659
+ current: WorksheetModel | null;
1660
+ toolbarUI: Toolbar;
1661
+ formulaBar: FormulaBar;
1662
+ sheetTabs?: SheetTabs;
1663
+ contextMenu: ContextMenu;
1664
+ findReplace: FindReplace;
1665
+ dataValidation: DataValidation;
1666
+ keyboardShortcuts: KeyboardShortcuts;
1667
+ noteEditor: NoteEditor;
1668
+ commentPanel: CommentPanel;
1669
+ conditionalFormatting: ConditionalFormattingPanel;
1670
+ pivotPanel: PivotPanel;
1671
+ watermarkUI: Watermark;
1672
+ loadingOverlay: LoadingOverlay;
1673
+ clipboardHandler: ClipboardHandler;
1674
+ fillHandler: FillHandler;
1675
+ themeManager: ThemeManager;
1676
+ worksheetHost: HTMLElement;
1677
+ private _events;
1678
+ constructor(element: HTMLElement, root: HTMLElement, config: WorksheetOptions);
1679
+ /**
1680
+ * Mount all UI chrome into root after worksheets are built.
1681
+ */
1682
+ mount(): void;
1683
+ /**
1684
+ * Close all active sidebars and panels.
1685
+ */
1686
+ closeAllSidebars(): void;
1687
+ /** Switch the active worksheet model by index */
1688
+ setActiveWorksheet(index: number): void;
1689
+ /** Change the current theme (light | dark) */
1690
+ setTheme(theme: 'light' | 'dark'): void;
1691
+ /** Apply custom color overrides */
1692
+ setColors(colors: Partial<ThemeColors>): void;
1693
+ /** Apply custom font overrides */
1694
+ setFonts(fonts: ThemeFonts): void;
1695
+ /**
1696
+ * Set the UI chrome font (toolbar labels, tabs, formula bar, status bar).
1697
+ * This does NOT affect cell content — cell fonts are set per-cell via the font picker.
1698
+ * Default UI font is Poppins.
1699
+ *
1700
+ * @param displayName - Font display name, e.g. "Roboto"
1701
+ * @param cssFamily - Full CSS font-family string (e.g. "Roboto, sans-serif").
1702
+ * If omitted, the display name is used as-is.
1703
+ */
1704
+ setDefaultFont(displayName: string, cssFamily?: string): void;
1705
+ /** Return the currently active worksheet model */
1706
+ getActiveWorksheet(): WorksheetModel | null;
1707
+ /** Add a new worksheet model (async — DOM built after promise resolves) */
1708
+ addWorksheet(options?: Partial<SheetMeta>): Promise<WorksheetModel | null>;
1709
+ /** Delete a worksheet model by index */
1710
+ deleteWorksheet(index: number): void;
1711
+ /** Duplicate an existing worksheet model */
1712
+ duplicateWorksheet(index: number): Promise<void>;
1713
+ /** Move a worksheet model from one index to another */
1714
+ moveWorksheet(fromIdx: number, toIdx: number): void;
1715
+ /** Rename a worksheet model */
1716
+ renameWorksheet(index: number, newName: string): void;
1717
+ /** Destroy the spreadsheet and release all resources. */
1718
+ destroy(): void;
1719
+ /**
1720
+ * Import a workbook from a File object (XLSX, CSV, etc.)
1721
+ * Distributes sheets and applies metadata.
1722
+ */
1723
+ importFromFile(file: File): Promise<void>;
1724
+ /**
1725
+ * Opens the pivot dialog to start creating a pivot table.
1726
+ */
1727
+ openPivotEditor(): void;
1728
+ private _pivotWorksheet;
1729
+ private _activePivotConfig;
1730
+ private _lastPivotSize;
1731
+ refreshPivotTable(config: PivotConfig, explicitWs?: WorksheetModel): Promise<void>;
1732
+ /**
1733
+ * Subscribes to spreadsheet events.
1734
+ */
1735
+ on(event: string, callback: (...args: any[]) => void): void;
1736
+ /**
1737
+ * Unsubscribes from spreadsheet events.
1738
+ */
1739
+ off(event: string, callback: (...args: any[]) => void): void;
1740
+ /**
1741
+ * Internal emit method for dispatching events.
1742
+ */
1743
+ emit(event: string, ...args: any[]): void;
1744
+ }
1745
+
1746
+ /**
1747
+ * @worksheet-js/core - Industrial-grade spreadsheet UI engine
1748
+ * (c) 2024-present Worksheet Systems <support@worksheet.js>
1749
+ * All Rights Reserved.
1750
+ *
1751
+ * PROPRIETARY AND CONFIDENTIAL: Unauthorized copying of this file,
1752
+ * via any medium is strictly prohibited.
1753
+ */
1754
+
1755
+ /**
1756
+ * The Worksheet class is the primary entry point for consumers to interact with the spreadsheet.
1757
+ * It provides static factory methods to create and load spreadsheets, and instance methods
1758
+ * to manipulate data, manage sheets, and handle exports.
1759
+ *
1760
+ * @example
1761
+ * ```ts
1762
+ * import { Worksheet } from '@worksheet-js/core';
1763
+ *
1764
+ * const sheet = await Worksheet.create({
1765
+ * container: document.getElementById('app')!,
1766
+ * worksheets: [{ worksheetName: 'Sheet1' }],
1767
+ * });
1768
+ * ```
1769
+ */
1770
+ declare class Worksheet {
1771
+ private _spreadsheet;
1772
+ private constructor();
1773
+ /**
1774
+ * Create and mount a new Worksheet instance (async factory method).
1775
+ */
1776
+ static create(options: WorksheetOptions): Promise<Worksheet>;
1777
+ /**
1778
+ * Explicitly set the license globally.
1779
+ */
1780
+ static setLicense(licenseKey: string): Promise<void>;
1781
+ /**
1782
+ * Parses an XLSX file from a buffer and initializes a Worksheet instance.
1783
+ */
1784
+ static loadXlsx(buffer: Uint8Array, options: Omit<WorksheetOptions, 'worksheets'>): Promise<Worksheet>;
1785
+ /**
1786
+ * Imports a CSV file into the spreadsheet.
1787
+ */
1788
+ static loadCsv(buffer: Uint8Array, options: Omit<WorksheetOptions, 'worksheets'>, csvOptions?: CsvOptions): Promise<Worksheet>;
1789
+ /**
1790
+ * Imports a JSON into the spreadsheet.
1791
+ */
1792
+ static loadJson(data: any[], options: Omit<WorksheetOptions, 'worksheets'>, jsonOptions?: JsonOptions): Promise<Worksheet>;
1793
+ /**
1794
+ * Imports a HTML into the spreadsheet.
1795
+ */
1796
+ static loadHtml(html: string, options: Omit<WorksheetOptions, 'worksheets'>, htmlOptions?: HtmlOptions): Promise<Worksheet>;
1797
+ /**
1798
+ * Imports a WorkbookData object into a new Worksheet instance.
1799
+ */
1800
+ static loadData(data: any, options: Omit<WorksheetOptions, 'worksheets'>): Promise<Worksheet>;
1801
+ /**
1802
+ * Returns the underlying Spreadsheet engine instance.
1803
+ */
1804
+ get spreadsheet(): Spreadsheet;
1805
+ /**
1806
+ * Returns the currently active worksheet model.
1807
+ */
1808
+ get activeWorksheet(): WorksheetModel | null;
1809
+ /**
1810
+ * Returns an array of all worksheet models in the workbook.
1811
+ */
1812
+ get worksheets(): WorksheetModel[];
1813
+ /**
1814
+ * Switches the active worksheet.
1815
+ *
1816
+ * @param index - The index of the worksheet to activate (0-based).
1817
+ */
1818
+ setActiveWorksheet(index: number): void;
1819
+ /**
1820
+ * Exports the entire workbook to an XLSX file.
1821
+ *
1822
+ * @param filename - The name of the file to save (default: "spreadsheet.xlsx").
1823
+ */
1824
+ exportXlsx(filename?: string): Promise<void>;
1825
+ /**
1826
+ * Exports the active sheet to a CSV file.
1827
+ *
1828
+ * @param filename - The name of the file to save (default: "spreadsheet.csv").
1829
+ */
1830
+ exportCsv(filename?: string): Promise<void>;
1831
+ /**
1832
+ * Exports the active sheet to a JSON object.
1833
+ *
1834
+ * @returns An array of objects representing the sheet data.
1835
+ */
1836
+ exportJson(): Promise<any[]>;
1837
+ private _triggerDownload;
1838
+ /**
1839
+ * Adds a new worksheet to the workbook.
1840
+ *
1841
+ * @param options - Optional metadata for the new sheet (name, color, etc.).
1842
+ */
1843
+ addWorksheet(options?: Partial<SheetMeta>): Promise<WorksheetModel | null>;
1844
+ /**
1845
+ * Deletes a worksheet from the workbook.
1846
+ *
1847
+ * @param index - The index of the worksheet to delete (0-based).
1848
+ */
1849
+ deleteWorksheet(index: number): void;
1850
+ /**
1851
+ * Duplicates an existing worksheet.
1852
+ *
1853
+ * @param index - The index of the worksheet to duplicate (0-based).
1854
+ */
1855
+ duplicateWorksheet(index: number): Promise<void>;
1856
+ /**
1857
+ * Moves a worksheet from one index to another.
1858
+ *
1859
+ * @param fromIdx - Current index of the worksheet.
1860
+ * @param toIdx - New index for the worksheet.
1861
+ */
1862
+ moveWorksheet(fromIdx: number, toIdx: number): void;
1863
+ /**
1864
+ * Import a workbook from a File object (XLSX, CSV, etc.)
1865
+ */
1866
+ importFromFile(file: File): Promise<void>;
1867
+ /**
1868
+ * Retrieves the raw clinical value of a cell.
1869
+ *
1870
+ * @param address - The cell address string (e.g., "A1", "B2").
1871
+ * @returns The raw string value of the cell.
1872
+ */
1873
+ getValue(address: string): string;
1874
+ /**
1875
+ * Retrieves the raw clinical value of a cell.
1876
+ *
1877
+ * @param x - Column index (0-based).
1878
+ * @param y - Row index (0-based).
1879
+ * @returns The raw string value of the cell.
1880
+ */
1881
+ getValue(x: number, y: number): string;
1882
+ /**
1883
+ * Sets the value of a cell.
1884
+ *
1885
+ * @param address - The cell address string (e.g., "A1").
1886
+ * @param value - The new value to set.
1887
+ */
1888
+ setValue(address: string, value: string): void;
1889
+ /**
1890
+ * Sets the value of a cell.
1891
+ *
1892
+ * @param x - Column index (0-based).
1893
+ * @param y - Row index (0-based).
1894
+ * @param value - The new value to set.
1895
+ */
1896
+ setValue(x: number, y: number, value: string): void;
1897
+ /**
1898
+ * Sets the style of a cell.
1899
+ *
1900
+ * @param address - The cell address string (e.g., "A1").
1901
+ * @param style - The style object.
1902
+ */
1903
+ setStyle(address: string, style: Partial<CellStyle>): void;
1904
+ /**
1905
+ * Sets the style of a cell.
1906
+ *
1907
+ * @param x - Column index (0-based).
1908
+ * @param y - Row index (0-based).
1909
+ * @param style - The style object.
1910
+ */
1911
+ setStyle(x: number, y: number, style: Partial<CellStyle>): void;
1912
+ /**
1913
+ * Retrieves the style of a cell.
1914
+ *
1915
+ * @param address - The cell address string (e.g., "A1").
1916
+ * @returns The style object.
1917
+ */
1918
+ getStyle(address: string): Partial<CellStyle>;
1919
+ /**
1920
+ * Retrieves the style of a cell.
1921
+ *
1922
+ * @param x - Column index (0-based).
1923
+ * @param y - Row index (0-based).
1924
+ * @returns The style object.
1925
+ */
1926
+ getStyle(x: number, y: number): Partial<CellStyle>;
1927
+ /**
1928
+ * Renames a worksheet.
1929
+ *
1930
+ * @param index - Index of the worksheet.
1931
+ * @param name - New name for the worksheet.
1932
+ */
1933
+ renameWorksheet(index: number, name: string): void;
1934
+ /**
1935
+ * Subscribes to spreadsheet events.
1936
+ */
1937
+ on(event: string, callback: (...args: any[]) => void): void;
1938
+ /**
1939
+ * Unsubscribes from spreadsheet events.
1940
+ */
1941
+ off(event: string, callback: (...args: any[]) => void): void;
1942
+ /**
1943
+ * Destroys the spreadsheet instance.
1944
+ */
1945
+ destroy(): void;
1946
+ }
1947
+
1948
+ /**
1949
+ * manager.ts — License lifecycle manager.
1950
+ * Handles initialization, periodic re-validation, integrity checks,
1951
+ * and runtime tamper detection.
1952
+ */
1953
+
1954
+ /**
1955
+ * Initialize the license system using the provided license key.
1956
+ *
1957
+ * @param licenseKey - The signed license key string.
1958
+ */
1959
+ declare function initializeLicense(licenseKey?: string): Promise<void>;
1960
+
1961
+ export { type CellAddress, type CellStyle, type CellStyleSnapshot, type CheckboxConfig, type HistoryEntry, type ImageConfig, type OnChangeCallback, type OnCreateWorksheetCallback, type OnDestroyCallback, type OnLoadCallback, type OnSelectionCallback, type OverlayConfig, type OverlayItem, OverlayManager, type OverlayType, type SelectionRange, type SheetMeta, Spreadsheet, type ThemeColors, type ThemeFonts, Worksheet, WorksheetModel, type WorksheetOptions, colIndexToLetter, coordsToAddr, initializeLicense, parseAddress };