@novnox/grid 0.0.0-stage → 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,573 @@
1
+ import { ConditionalFormatCollection } from './conditional';
2
+ import { type GridEventHandler, type GridEventName, type ValueChangeSource } from './events';
3
+ import { Column, GridModel } from './model';
4
+ import { CellRef, ColumnCollection, RangeRef } from './refs';
5
+ import { type FindOptions } from './find';
6
+ import { type PrintOptions } from './print';
7
+ import { type SubtotalFunction } from './outline';
8
+ import { type GridColors } from './scheme';
9
+ import type { CellAddress, CellRange, CellValue, ColorSchemeName, ColumnOptions, GridOptions, MergeArea, SortOrder, SortSpec } from './types';
10
+ import { type CsvOptions, type FooterCell, type LoadSheetOptions, type SheetData, type WorkbookData } from './sheetData';
11
+ import { type HeaderGroups } from './headerGroups';
12
+ /** Result of a layout calculation. */
13
+ export interface GridLayout {
14
+ width: number;
15
+ height: number;
16
+ headerH: number;
17
+ /** Row header width (including the group area). */
18
+ rowHeaderW: number;
19
+ /** Row group area width (0 if none). */
20
+ outlineW: number;
21
+ frozenRows: number;
22
+ frozenCols: number;
23
+ frozenH: number;
24
+ frozenW: number;
25
+ scrollTop: number;
26
+ scrollLeft: number;
27
+ /** Footer row height (0 if hidden). */
28
+ footerH: number;
29
+ /** Bottom of the row area (the footer row is below it). */
30
+ bodyBottom: number;
31
+ /** Height of one header row (group rows and the column header row). */
32
+ headerRowH: number;
33
+ /** Multi-row header groups (levels 0: none). */
34
+ groups: HeaderGroups;
35
+ }
36
+ /** Hit-test result for a mouse position. */
37
+ export interface HitInfo {
38
+ area: 'corner' | 'colHeader' | 'colGroup' | 'rowHeader' | 'cell' | 'outline' | 'outlineLevel' | 'footer' | 'none';
39
+ /** Group level (outline, outlineLevel). */
40
+ level?: number;
41
+ row: number;
42
+ col: number;
43
+ /** Column border (resize). */
44
+ resizeCol?: number;
45
+ /** Header filter button. */
46
+ filterButton?: boolean;
47
+ }
48
+ /**
49
+ * NoxGrid for the web. Uses custom drawing (Canvas) to render only the visible cells.
50
+ *
51
+ * ```ts
52
+ * const grid = new NoxGrid(document.getElementById('grid')!, {
53
+ * columns: [{ name: 'name', header: 'Name' }, { name: 'age', header: 'Age', kind: 'number' }],
54
+ * rowCount: 100,
55
+ * });
56
+ * grid.setValue(0, 0, 'John Smith');
57
+ * ```
58
+ */
59
+ export declare class NoxGrid {
60
+ /** @internal */ readonly model: GridModel;
61
+ readonly host: HTMLElement;
62
+ /** Columns. */
63
+ readonly columns: ColumnCollection;
64
+ /** Conditional formats. */
65
+ readonly conditionalFormats: ConditionalFormatCollection;
66
+ /** @internal */ readonly root: HTMLDivElement;
67
+ /** @internal */ readonly scroller: HTMLDivElement;
68
+ /** @internal */ readonly spacer: HTMLDivElement;
69
+ /** @internal */ readonly canvas: HTMLCanvasElement;
70
+ /** @internal */ readonly input: HTMLTextAreaElement;
71
+ private readonly renderer;
72
+ private readonly emitter;
73
+ private resizeObserver?;
74
+ private frame;
75
+ private destroyed;
76
+ private _rowHeight;
77
+ private _headerHeight;
78
+ private _footerVisible;
79
+ private footerCache;
80
+ private footerBusy;
81
+ private _rowHeaderWidth;
82
+ private _rowHeadersVisible;
83
+ private _columnHeadersVisible;
84
+ private _frozenRows;
85
+ private _frozenColumns;
86
+ private _readOnly;
87
+ private _scheme;
88
+ /** @internal */ colors: GridColors;
89
+ /** @internal */ alternatingRows: boolean;
90
+ private _verticalGridLines;
91
+ /** The app set verticalGridLines itself: changing colorScheme keeps it. */
92
+ private ownVerticalGridLines;
93
+ /** Vertical lines between body cells. Defaults to the color scheme's (off for modern schemes); once set, changing colorScheme keeps it. */
94
+ get verticalGridLines(): boolean;
95
+ set verticalGridLines(v: boolean);
96
+ /** @internal */ horizontalGridLines: boolean;
97
+ /** @internal */ fontFamily: string;
98
+ /** @internal */ fontSize: number;
99
+ /** @internal */ headerBold: boolean;
100
+ allowSort: boolean;
101
+ allowFilter: boolean;
102
+ allowColumnResize: boolean;
103
+ allowEdit: boolean;
104
+ /** Find and replace via Ctrl+F, Ctrl+H, F3. */
105
+ allowFind: boolean;
106
+ private findPanel;
107
+ /** Lets users type or paste formulas starting with = (setFormula in code works regardless). */
108
+ allowUserFormulas: boolean;
109
+ /** @internal */ showValidationErrors: boolean;
110
+ /** Formulas from the last copy (relative references are shifted on paste). */
111
+ private formulaClip;
112
+ /** @internal */ cur: CellAddress;
113
+ /** @internal */ anchor: CellAddress;
114
+ private _sel;
115
+ /** @internal Selected range (whole rows in selectionMode 'fullRow'). */
116
+ get sel(): CellRange;
117
+ set sel(v: CellRange);
118
+ private _selectionMode;
119
+ /** @internal False until the user interacts when initialSelection is 'none'. */
120
+ selectionShown: boolean;
121
+ private _hoverRow;
122
+ /** 'cell' (default) or 'fullRow' (whole rows are selected, as the desktop FullRowSelect). */
123
+ get selectionMode(): 'cell' | 'fullRow';
124
+ set selectionMode(v: 'cell' | 'fullRow');
125
+ private _captureFind;
126
+ private offPageFind;
127
+ /** Where Ctrl+F opens the grid's find dialog: 'grid' (when focused, default) or 'page' (anywhere, if this is the only grid on screen). */
128
+ get captureFind(): 'grid' | 'page';
129
+ set captureFind(v: 'grid' | 'page');
130
+ /** Shows the whole text in a tooltip when the mouse is over a cell whose text is cut off. */
131
+ showCellToolTips: boolean;
132
+ /** Pasting more lines than there are rows below adds rows (same undo step). Default false: extra lines are dropped (see the pasted event). */
133
+ pasteAddsRows: boolean;
134
+ /** Text drawn in the middle of the grid when no rows are shown. */
135
+ get emptyMessage(): string;
136
+ set emptyMessage(v: string);
137
+ private _emptyMessage;
138
+ /** Selected cells keep their own background (and text color); see GridOptions.selectionKeepsBackColors. */
139
+ get selectionKeepsBackColors(): boolean;
140
+ set selectionKeepsBackColors(v: boolean);
141
+ private _selectionKeepsBackColors;
142
+ /** State of a check column over the shown rows: 'on' (all checked), 'off' (none) or 'mixed'. Subtotal rows are not counted. */
143
+ headerCheckState(col: number | string): 'on' | 'off' | 'mixed';
144
+ /** @internal Header check box clicked: check all shown rows unless all are checked already. */
145
+ private toggleHeaderCheck;
146
+ /** Hides the selection until the user clicks a cell or uses the keyboard in the grid (like initialSelection: 'none' at the start). */
147
+ hideSelection(): void;
148
+ /** Bound data: the field that identifies a row (GridOptions.rowKey). */
149
+ get rowKey(): string | undefined;
150
+ set rowKey(field: string | undefined);
151
+ /** Key of a row: the rowKey field of the bound object, or the key set with setRowKey. */
152
+ getRowKey(row: number): unknown;
153
+ /** Sets the key of a row (unbound grids, or bound grids without rowKey). The key follows the row when rows are inserted, removed or sorted. */
154
+ setRowKey(row: number, key: unknown): void;
155
+ /** Row index (screen order) of the row with this key, -1 if none. Hidden and filtered rows are found too. */
156
+ indexOfKey(key: unknown): number;
157
+ /**
158
+ * Checks or unchecks a check column for every row (like the desktop SetAllChecked). By default only the rows shown
159
+ * (not filtered out or hidden); read-only cells and subtotal rows are left as they are. One undo step. Returns the number of changed cells.
160
+ */
161
+ setAllChecked(col: number | string, checked: boolean, options?: {
162
+ visibleOnly?: boolean;
163
+ }): number;
164
+ /** Bound data: the object for each new row (insertRows, pasteAddsRows). */
165
+ get newRowData(): (() => Record<string, unknown>) | undefined;
166
+ set newRowData(fn: (() => Record<string, unknown>) | undefined);
167
+ /** The current colors (a copy; change them with setColors). */
168
+ getColors(): GridColors;
169
+ /** Selected cells use the selection text color instead of colors set on the cell, row, column or by conditional formats. Default false (those colors are kept, like the desktop). */
170
+ selectionOverridesCellColors: boolean;
171
+ /**
172
+ * Where a cell is drawn, relative to the grid element: { x, y, width, height } (merged cells: the whole area).
173
+ * null when the cell is scrolled out of view or hidden; call scrollToCell(row, col) first. For automated tests and pop-ups.
174
+ */
175
+ getCellRect(row: number, col: number | string): {
176
+ x: number;
177
+ y: number;
178
+ width: number;
179
+ height: number;
180
+ } | null;
181
+ /** Where a column header is drawn, relative to the grid element (the bottom header row with multi-row headers); null when scrolled out of view. */
182
+ getHeaderRect(col: number | string): {
183
+ x: number;
184
+ y: number;
185
+ width: number;
186
+ height: number;
187
+ } | null;
188
+ /**
189
+ * Keeps only rows where any of the columns (default: every visible column) contains the text (case-insensitive, as displayed).
190
+ * Works together with the column filters; the footer row counts the remaining rows. '' or null clears it.
191
+ * Safe to call while Korean text is being composed (the grid only filters).
192
+ */
193
+ setQuickFilter(text: string | null, options?: {
194
+ columns?: Array<number | string>;
195
+ }): void;
196
+ /** Current quick filter text ('' when none). */
197
+ get quickFilter(): string;
198
+ /**
199
+ * Number of rows left after the column filters and the quick filter (e.g. "N results").
200
+ * Hidden rows and subtotal rows are not counted; rows inside collapsed groups are. Same value as footerText's visibleRowCount.
201
+ */
202
+ get visibleRowCount(): number;
203
+ /** Row indices (screen order) of the rows counted by visibleRowCount. */
204
+ visibleRows(): number[];
205
+ private cellTipEl;
206
+ private cellTipTimer;
207
+ private cellTipAt;
208
+ private measureCtx;
209
+ private cellTipText;
210
+ /** Header tooltip: the column's headerToolTip, or with showCellToolTips the header text when it is cut off. */
211
+ private headerTipText;
212
+ private scheduleCellTip;
213
+ private hideCellTip;
214
+ /** Highlights the row under the mouse. */
215
+ get hoverRow(): boolean;
216
+ set hoverRow(v: boolean);
217
+ /** @internal The row the mouse is over (for hoverRow), -1 if none. */
218
+ get hoverRowIndex(): number;
219
+ /** @internal The cell the mouse is over. */
220
+ get hoverCell(): {
221
+ row: number;
222
+ col: number;
223
+ } | null;
224
+ /** @internal */ editing: boolean;
225
+ /** Editing started by typing (arrow keys move between cells). */
226
+ private enterMode;
227
+ private composing;
228
+ private editRow;
229
+ private editCol;
230
+ private popupEditor;
231
+ private drag;
232
+ private autoScroll;
233
+ private lastPointer;
234
+ private hover;
235
+ private tipEl;
236
+ private tipCell;
237
+ private tipTimer;
238
+ private filterPopup;
239
+ private dprQuery;
240
+ private offLicense;
241
+ constructor(host: HTMLElement, options?: GridOptions);
242
+ private applyOptions;
243
+ get rowCount(): number;
244
+ set rowCount(n: number);
245
+ get columnCount(): number;
246
+ get rowHeight(): number;
247
+ set rowHeight(h: number);
248
+ get headerHeight(): number;
249
+ set headerHeight(h: number);
250
+ /** Shows the footer (summary) row fixed at the bottom. Set `footer` on the columns. */
251
+ get footerVisible(): boolean;
252
+ set footerVisible(v: boolean);
253
+ /**
254
+ * Footer value of a column (calculated from its `footer` function over the rows shown by the filter;
255
+ * the `footerValue` event can change it).
256
+ */
257
+ getFooterValue(col: number | string): CellValue;
258
+ /** @internal Footer display text of a column. */
259
+ footerTextOf(c: number): string;
260
+ /** Recalculates the footer values (after changing a column's footer settings in code). */
261
+ refreshFooter(): void;
262
+ private ensureFooter;
263
+ /** @internal Multi-row header groups for the visible columns (in visible order). */
264
+ headerGroups(): HeaderGroups;
265
+ /** @internal Top of the column header cell at visible position u (columns with fewer group levels extend upward). */
266
+ leafTop(u: number, L: GridLayout): number;
267
+ get rowHeadersVisible(): boolean;
268
+ set rowHeadersVisible(v: boolean);
269
+ get columnHeadersVisible(): boolean;
270
+ set columnHeadersVisible(v: boolean);
271
+ get frozenRows(): number;
272
+ set frozenRows(n: number);
273
+ get frozenColumns(): number;
274
+ set frozenColumns(n: number);
275
+ get readOnly(): boolean;
276
+ set readOnly(v: boolean);
277
+ /** Color scheme (the same 13 as the desktop version, including the Nox signature scheme). */
278
+ get colorScheme(): ColorSchemeName;
279
+ set colorScheme(name: ColorSchemeName);
280
+ /** Overrides individual colors (e.g. grid.setColors({ accent: '#e11d48' })). */
281
+ setColors(patch: Partial<GridColors>): void;
282
+ /** Alternating row colors. */
283
+ get alternatingRowColors(): boolean;
284
+ set alternatingRowColors(v: boolean);
285
+ getValue(row: number, col: number | string): CellValue;
286
+ /** Sets a value (undoable). */
287
+ setValue(row: number, col: number | string, value: CellValue): void;
288
+ /** Gets the display text. */
289
+ getText(row: number, col: number | string): string;
290
+ /** Gets a reference to a single cell. */
291
+ cells(row: number, col: number | string): CellRef;
292
+ /** Gets a reference to a range. */
293
+ range(row: number, col: number | string, row2: number, col2: number | string): RangeRef;
294
+ /** Sets values from a 2D array in one go (a single undo step). */
295
+ setValues(row: number, col: number, values: CellValue[][]): void;
296
+ /** Gets range values as a 2D array. */
297
+ getValues(row: number, col: number, rowCount: number, colCount: number): CellValue[][];
298
+ /** Clears range values (a single undo step). */
299
+ clearRange(row: number, col: number, rowCount: number, colCount: number): void;
300
+ /** Converts text to the column's kind and sets it. Throws if it cannot be converted. */
301
+ setText(row: number, col: number | string, text: string): void;
302
+ /** Sets a formula in a cell ("=SUM(A1:A3)" or "SUM(A1:A3)"). Empty text or null clears it. Throws FormulaSyntaxError on invalid syntax. */
303
+ setFormula(row: number, col: number | string, formula: string | null): void;
304
+ /** Gets the cell's formula ("=…", or null if none). */
305
+ getFormula(row: number, col: number | string): string | null;
306
+ hasFormula(row: number, col: number | string): boolean;
307
+ /** Evaluates a formula once at the current cell position (without storing it in the cell). */
308
+ evaluate(formula: string): CellValue;
309
+ /** Recalculates all formulas (TODAY, RAND, etc.). */
310
+ recalculate(): void;
311
+ /** Sheet name used to refer to this grid in formulas. */
312
+ get sheetName(): string | null;
313
+ set sheetName(v: string | null);
314
+ /** Printable HTML document (visible rows and columns, including formats and merges). */
315
+ toPrintHtml(options?: PrintOptions): string;
316
+ /** Opens the print dialog (the browser's print preview can also save as PDF). */
317
+ print(options?: PrintOptions): Promise<void>;
318
+ /** Finds the next matching cell and selects it. Searches visible rows and columns, wrapping from end to start. */
319
+ findNext(text: string, options?: FindOptions): CellAddress | null;
320
+ /** Replaces the current cell if it matches, then finds the next one (excludes read-only and formula cells). */
321
+ replace(text: string, replacement: string, options?: FindOptions): boolean;
322
+ /** Replaces all matches (a single undo step). Returns the number of cells replaced. */
323
+ replaceAll(text: string, replacement: string, options?: FindOptions): number;
324
+ /** Opens the find dialog (replace = also show the replace field). */
325
+ showFindDialog(replace?: boolean): void;
326
+ /** Groups a row range (one level deeper). Undoable. */
327
+ groupRows(row: number, row2: number): void;
328
+ /** Ungroups a row range (one level shallower). */
329
+ ungroupRows(row: number, row2: number): void;
330
+ /** Collapses the group containing the row (innermost if level is omitted). */
331
+ collapseGroup(row: number, level?: number): boolean;
332
+ expandGroup(row: number, level?: number): boolean;
333
+ /** Shows only up to level n (1 = summary only, deepest level + 1 = all). */
334
+ showOutlineLevel(n: number): void;
335
+ /** Deepest group level (0 if none). */
336
+ get outlineLevels(): number;
337
+ /**
338
+ * Inserts subtotals: adds a subtotal row (SUBTOTAL formula) wherever the groupBy column value changes and groups the rows. Returns the number of rows inserted.
339
+ * Data must be sorted by the groupBy column (with sortFirst: true it is sorted first).
340
+ */
341
+ addSubtotals(o: {
342
+ groupBy: number | string;
343
+ columns: Array<number | string>;
344
+ function?: SubtotalFunction;
345
+ grandTotal?: boolean;
346
+ sortFirst?: boolean;
347
+ backColor?: string;
348
+ }): number;
349
+ /** Removes subtotal rows and ungroups. Returns the number of rows removed. */
350
+ removeSubtotals(): number;
351
+ isSubtotalRow(row: number): boolean;
352
+ private afterOutline;
353
+ /** Loads sheet data received from the server (columns, values, formulas, formats, merges, frozen panes). Clears the undo history. */
354
+ loadSheetData(sheet: SheetData, options?: LoadSheetOptions): void;
355
+ /** Loads one sheet from workbook data (by index or name; defaults to activeSheet). */
356
+ loadWorkbookData(book: WorkbookData, sheet?: number | string, options?: LoadSheetOptions): void;
357
+ /** Sheet data to send to the server (with headerRow, headers go in the first row). */
358
+ toSheetData(options?: {
359
+ headerRow?: boolean;
360
+ }): SheetData;
361
+ /** @internal Footer row for sheet data: SUBTOTAL formulas (right in Excel filters too); values set by the footerValue event as values. */
362
+ exportFooter(headerRow: boolean): Array<FooterCell | null> | undefined;
363
+ /** Workbook data to send to the server (a single sheet). */
364
+ toWorkbookData(options?: {
365
+ headerRow?: boolean;
366
+ }): WorkbookData;
367
+ /** CSV of the display text as-is (no server needed). The first line is the header. */
368
+ toCsv(options?: string | CsvOptions): string;
369
+ /**
370
+ * Saves the grid as a CSV file in the browser (UTF-8 with BOM, so Excel shows Korean text correctly).
371
+ * Options are the same as toCsv (raw values, columns, header row, filtered rows only).
372
+ */
373
+ downloadCsv(fileName?: string, options?: CsvOptions): void;
374
+ /**
375
+ * Applies a new set of column options: columns are matched by name (or field) and updated in place (their width is kept
376
+ * unless a width is given), new ones are added and missing ones removed, in the given order. Cell values stay.
377
+ */
378
+ setColumns(columns: ColumnOptions[]): void;
379
+ private updateCount;
380
+ /** Suspends drawing (before bulk changes). Pair with endUpdate. */
381
+ beginUpdate(): void;
382
+ endUpdate(): void;
383
+ /** Enables Ctrl+Z / Ctrl+Y undo. Turning it off clears the history. */
384
+ get allowUndo(): boolean;
385
+ set allowUndo(v: boolean);
386
+ /** Clears the undo history. */
387
+ clearUndo(): void;
388
+ /**
389
+ * Binds an array of objects (read and written via each column's field). null unbinds.
390
+ * `keepSort: true` sorts the new rows by the current sort again (for lists that are searched or reloaded).
391
+ */
392
+ setData(data: Record<string, unknown>[] | null, options?: {
393
+ keepSort?: boolean;
394
+ }): void;
395
+ /** Gives the spare width to fillWeight columns (called when the size or the columns change). */
396
+ private updateFill;
397
+ /**
398
+ * The bound array of objects (the same array you passed in). Sorting changes only the screen order and never reorders this array;
399
+ * rows inserted or removed in the grid are inserted into or removed from it.
400
+ */
401
+ get data(): Record<string, unknown>[] | null;
402
+ /** The bound object shown on a screen row (undefined when unbound). */
403
+ rowData(row: number): Record<string, unknown> | undefined;
404
+ /** Index in the bound array of the object shown on a screen row (-1 when unbound). Screen rows and array indexes differ after sorting. */
405
+ dataIndex(row: number): number;
406
+ insertRows(at: number, count?: number): void;
407
+ removeRows(at: number, count?: number): void;
408
+ setRowHeight(row: number, height: number | null): void;
409
+ getRowHeight(row: number): number;
410
+ setRowVisible(row: number, visible: boolean): void;
411
+ /**
412
+ * Whether the row is shown: false for rows hidden with setRowVisible, filtered out by a column filter or the quick filter,
413
+ * or inside a collapsed group. visibleRows() lists the rows left after filtering (subtotal rows not included).
414
+ */
415
+ isRowVisible(row: number): boolean;
416
+ /** Merges cells. */
417
+ mergeCells(row: number, col: number, rowSpan: number, colSpan: number): void;
418
+ /** Removes merges that overlap the range. */
419
+ unmergeCells(row: number, col: number, rowSpan?: number, colSpan?: number): void;
420
+ get merges(): readonly MergeArea[];
421
+ /** Sorts by one or more columns. E.g. grid.sort([{ col: 'dept' }, { col: 'age', order: 'desc' }]) */
422
+ sort(specs: Array<{
423
+ col: number | string;
424
+ order?: SortOrder;
425
+ }>): void;
426
+ /**
427
+ * Removes the sort. Bound rows go back to the order of the bound array (as the desktop ClearSort does);
428
+ * clearSort(false) only removes the sort indicator and keeps the current order. Undoable.
429
+ */
430
+ clearSort(restoreOrder?: boolean): void;
431
+ private _sortCycle;
432
+ /** What clicking a header cycles through: 'ascDesc' (default) or 'ascDescNone' (third click: clearSort()). */
433
+ get sortCycle(): 'ascDesc' | 'ascDescNone';
434
+ set sortCycle(v: 'ascDesc' | 'ascDescNone');
435
+ /** Current sort. */
436
+ get sortColumns(): SortSpec[];
437
+ /** Header-click sort: toggles direction on the same column; with add, appends a sort column. */
438
+ sortByHeader(col: number, add: boolean): void;
439
+ /** Filter: a list of values (display text) to show, or a predicate. null clears it. */
440
+ setFilter(col: number | string, filter: string[] | ((value: CellValue, row: number) => boolean) | null): void;
441
+ clearFilters(): void;
442
+ isFiltered(col: number | string): boolean;
443
+ /** Gets the cell's validation error (null if none). */
444
+ getValidationError(row: number, col: number | string): string | null;
445
+ /** Validates all cells. Moves to the first invalid cell and returns the list of errors. */
446
+ validate(): Array<{
447
+ row: number;
448
+ col: number;
449
+ message: string;
450
+ }>;
451
+ /** Current cell. */
452
+ get currentCell(): CellAddress;
453
+ /** Selected range. */
454
+ get selection(): CellRange;
455
+ /** Selects a cell or range. */
456
+ select(row: number, col: number | string, row2?: number, col2?: number | string): void;
457
+ selectAll(): void;
458
+ /** Scrolls so the cell is visible. */
459
+ scrollToCell(row: number, col: number | string): void;
460
+ private valueChangedDepth;
461
+ /**
462
+ * @internal Runs fn with the reason for value changes set (cellValueChanged source). User actions run as one undo step,
463
+ * so values an app sets in its cellValueChanged handler are undone and redone together with the user's change.
464
+ */
465
+ withSource<T>(source: ValueChangeSource, fn: () => T): T;
466
+ undo(): boolean;
467
+ redo(): boolean;
468
+ get canUndo(): boolean;
469
+ get canRedo(): boolean;
470
+ /** Groups multiple changes into a single undo step. */
471
+ batch<T>(fn: () => T): T;
472
+ private afterReplay;
473
+ /** Gets the selection as tab-separated text (formulas are remembered separately for pasting). */
474
+ copySelectionText(): string;
475
+ /** Pastes tab-separated text starting at the current cell (a single value fills the whole selection). Returns the number of cells set. */
476
+ pasteText(text: string): number;
477
+ private pasteTextCore;
478
+ /** Clears values in the selection. */
479
+ clearSelection(): void;
480
+ /** Whether the cell is read-only. */
481
+ isCellReadOnly(row: number, col: number): boolean;
482
+ /** Fits the column width to its contents (based on visible rows, up to 2000 rows). */
483
+ autoFitColumn(col: number | string): void;
484
+ on<K extends GridEventName>(name: K, fn: GridEventHandler<K>): () => void;
485
+ off<K extends GridEventName>(name: K, fn: GridEventHandler<K>): void;
486
+ /** Schedules a redraw. */
487
+ invalidate(): void;
488
+ /** Draws immediately (for testing). */
489
+ paintNow(): void;
490
+ /** Call when the size has changed (usually automatic). */
491
+ resize(): void;
492
+ /** Gives the grid input focus. */
493
+ focus(): void;
494
+ /** Destroys the grid and releases its resources. */
495
+ destroy(): void;
496
+ /** @internal */
497
+ layout(): GridLayout;
498
+ /** @internal Visible index → screen y. */
499
+ rowY(v: number, L: GridLayout): number;
500
+ /** @internal Visible index → screen x. */
501
+ colX(v: number, L: GridLayout): number;
502
+ /** @internal Screen rectangle of a cell (actual index). For merged cells, the whole merge. */
503
+ cellRect(row: number, col: number, L?: GridLayout, withMerge?: boolean): {
504
+ x: number;
505
+ y: number;
506
+ w: number;
507
+ h: number;
508
+ } | null;
509
+ /** @internal Hit-tests screen coordinates. */
510
+ hitTest(x: number, y: number): HitInfo;
511
+ /** Whether the right edge of visible column u is a drawn border at header height y. */
512
+ private isHeaderBorder;
513
+ private updateScrollSize;
514
+ private _autoHeight;
515
+ private _maxHeight;
516
+ /** The grid's height follows its rows, so the page scrolls instead of the grid (see GridOptions.autoHeight). */
517
+ get autoHeight(): boolean;
518
+ set autoHeight(v: boolean);
519
+ /** With autoHeight: the largest height in px (0 = no limit). */
520
+ get maxHeight(): number;
521
+ set maxHeight(v: number);
522
+ private outlineWidth;
523
+ private rowHeaderTotal;
524
+ private clampSelection;
525
+ /** @internal */
526
+ setCurrent(row: number, col: number, extend: boolean): void;
527
+ private selectionChanged;
528
+ private moveBy;
529
+ private pageRows;
530
+ private attachEvents;
531
+ private watchDpr;
532
+ private onDprChange;
533
+ private hitAt;
534
+ private onPointerDown;
535
+ private onPointerMove;
536
+ private dragSelect;
537
+ private expandForMerges;
538
+ private startAutoScroll;
539
+ /** @internal Touch press waiting to become a tap (see attachEvents). */
540
+ private touchStart;
541
+ private onPointerUp;
542
+ private onDoubleClick;
543
+ private onKeyDown;
544
+ private onArrow;
545
+ private toggleChecks;
546
+ /**
547
+ * Begins editing. typed = started by typing (arrow keys move between cells); initial = initial text (null uses the current value).
548
+ * @internal
549
+ */
550
+ beginEdit(typed: boolean, initial: string | null): boolean;
551
+ /** Ends editing. commit = apply the value. Returns false and keeps editing if validation fails. */
552
+ endEdit(commit: boolean): boolean;
553
+ private applyEditorStyle;
554
+ /** Positions the input element over the current cell (transparent when not editing, so IME composition can start). */
555
+ private positionInput;
556
+ private openPopupEditor;
557
+ private closePopupEditor;
558
+ /** Hint text below the cell (validation error). */
559
+ showTip(row: number, col: number, message: string): void;
560
+ /** Keeps the tip under its cell while scrolling; hides it when the cell scrolls out of view. */
561
+ private positionTip;
562
+ private hideTip;
563
+ /** Opens the header filter popup. */
564
+ openFilterPopup(col: number): void;
565
+ private onDocPointerDown;
566
+ private closeFilterPopup;
567
+ /** @internal Hit-test info for the position under the mouse. */
568
+ get hoverInfo(): HitInfo | null;
569
+ /** @internal Adds a header column (for ColumnCollection). */
570
+ addColumnInternal(at: number, o: ColumnOptions | Column): Column;
571
+ }
572
+ /** Parses tab-separated text (quotes supported). */
573
+ export declare function parseTsv(text: string): string[][];
@@ -0,0 +1,23 @@
1
+ import type { Column } from './model';
2
+ /** One merged group cell: level (0 = top), visible column range u0..u1. */
3
+ export interface HeaderGroupCell {
4
+ level: number;
5
+ u0: number;
6
+ u1: number;
7
+ text: string;
8
+ }
9
+ export interface HeaderGroups {
10
+ /** Number of group rows above the column headers (0: no groups). */
11
+ levels: number;
12
+ /** Group depth by visible column position. */
13
+ depth: number[];
14
+ cells: HeaderGroupCell[];
15
+ }
16
+ export declare const NO_GROUPS: HeaderGroups;
17
+ /**
18
+ * Builds the merged group cells for columns in visible order.
19
+ * Adjacent columns with the same path up to a level share one cell; cells never cross `splitAt` (the frozen edge).
20
+ */
21
+ export declare function buildHeaderGroups(paths: string[][], splitAt: number): HeaderGroups;
22
+ /** Header text for one-line outputs (CSV): group names before the header ("Qty Plan"). */
23
+ export declare function flatHeader(col: Column): string;
@@ -0,0 +1,66 @@
1
+ export type Locale = 'ko' | 'en';
2
+ declare const ko: {
3
+ editCell: string;
4
+ sortAsc: string;
5
+ sortDesc: string;
6
+ search: string;
7
+ selectAll: string;
8
+ blank: string;
9
+ clearFilter: string;
10
+ ok: string;
11
+ badFormat: string;
12
+ badFormula: string;
13
+ formulaError: (m: string) => string;
14
+ required: (name: string) => string;
15
+ min: (v: number) => string;
16
+ max: (v: number) => string;
17
+ maxLength: (n: number) => string;
18
+ notInList: string;
19
+ findWhat: string;
20
+ findNext: string;
21
+ close: string;
22
+ replaceWith: string;
23
+ replace: string;
24
+ replaceAll: string;
25
+ matchCase: string;
26
+ wholeCell: string;
27
+ inColumn: string;
28
+ replaced: string;
29
+ notReplaceable: string;
30
+ replacedCount: (n: number) => string;
31
+ notFound: string;
32
+ addSheet: string;
33
+ licenseNotice: string;
34
+ am: string;
35
+ pm: string;
36
+ subtotal: {
37
+ sum: string;
38
+ count: string;
39
+ average: string;
40
+ max: string;
41
+ min: string;
42
+ };
43
+ subtotalLabel: (value: string, fn: string) => string;
44
+ grandTotal: (fn: string) => string;
45
+ parse: {
46
+ incomplete: string;
47
+ badRef: string;
48
+ cannotRead: (ch: string) => string;
49
+ noRefAfterSheet: string;
50
+ unclosedString: string;
51
+ unknownError: string;
52
+ badNumber: string;
53
+ unclosedSheet: string;
54
+ noBang: string;
55
+ expected: (ch: string) => string;
56
+ at: (msg: string, pos: number) => string;
57
+ empty: string;
58
+ };
59
+ };
60
+ export type Messages = typeof ko;
61
+ /** UI text language (applies to all grids). */
62
+ export declare function setLocale(locale: Locale): void;
63
+ export declare function getLocale(): Locale;
64
+ /** UI text for the current language. */
65
+ export declare function i18n(): Messages;
66
+ export {};