@pagent-libs/core 0.1.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.
- package/README.md +32 -0
- package/dist/canvas/cell-renderer.d.ts +45 -0
- package/dist/canvas/cell-renderer.d.ts.map +1 -0
- package/dist/canvas/grid-renderer.d.ts +29 -0
- package/dist/canvas/grid-renderer.d.ts.map +1 -0
- package/dist/canvas/header-renderer.d.ts +58 -0
- package/dist/canvas/header-renderer.d.ts.map +1 -0
- package/dist/canvas/hit-testing.d.ts +81 -0
- package/dist/canvas/hit-testing.d.ts.map +1 -0
- package/dist/canvas/index.d.ts +9 -0
- package/dist/canvas/index.d.ts.map +1 -0
- package/dist/canvas/renderer.d.ts +140 -0
- package/dist/canvas/renderer.d.ts.map +1 -0
- package/dist/canvas/selection-renderer.d.ts +55 -0
- package/dist/canvas/selection-renderer.d.ts.map +1 -0
- package/dist/canvas/text-renderer.d.ts +49 -0
- package/dist/canvas/text-renderer.d.ts.map +1 -0
- package/dist/canvas/types.d.ts +200 -0
- package/dist/canvas/types.d.ts.map +1 -0
- package/dist/collaboration/firebase-provider.d.ts +13 -0
- package/dist/collaboration/firebase-provider.d.ts.map +1 -0
- package/dist/collaboration/index.d.ts +3 -0
- package/dist/collaboration/index.d.ts.map +1 -0
- package/dist/collaboration/types.d.ts +34 -0
- package/dist/collaboration/types.d.ts.map +1 -0
- package/dist/event-emitter.d.ts +13 -0
- package/dist/event-emitter.d.ts.map +1 -0
- package/dist/export/csv.d.ts +5 -0
- package/dist/export/csv.d.ts.map +1 -0
- package/dist/export/index.d.ts +2 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/features/filter.d.ts +58 -0
- package/dist/features/filter.d.ts.map +1 -0
- package/dist/features/freeze.d.ts +86 -0
- package/dist/features/freeze.d.ts.map +1 -0
- package/dist/features/index.d.ts +4 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/sort.d.ts +15 -0
- package/dist/features/sort.d.ts.map +1 -0
- package/dist/format-pool.d.ts +17 -0
- package/dist/format-pool.d.ts.map +1 -0
- package/dist/formula-graph.d.ts +12 -0
- package/dist/formula-graph.d.ts.map +1 -0
- package/dist/formula-parser/cell-reference.d.ts +7 -0
- package/dist/formula-parser/cell-reference.d.ts.map +1 -0
- package/dist/formula-parser/formula-adjust.d.ts +13 -0
- package/dist/formula-parser/formula-adjust.d.ts.map +1 -0
- package/dist/formula-parser/formula-ranges.d.ts +22 -0
- package/dist/formula-parser/formula-ranges.d.ts.map +1 -0
- package/dist/formula-parser/index.d.ts +6 -0
- package/dist/formula-parser/index.d.ts.map +1 -0
- package/dist/formula-parser/parser.d.ts +18 -0
- package/dist/formula-parser/parser.d.ts.map +1 -0
- package/dist/formula-parser/types.d.ts +33 -0
- package/dist/formula-parser/types.d.ts.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +5823 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +5885 -0
- package/dist/index.js.map +1 -0
- package/dist/sheet.d.ts +119 -0
- package/dist/sheet.d.ts.map +1 -0
- package/dist/style-pool.d.ts +17 -0
- package/dist/style-pool.d.ts.map +1 -0
- package/dist/types.d.ts +260 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/cell-key.d.ts +7 -0
- package/dist/utils/cell-key.d.ts.map +1 -0
- package/dist/utils/format-utils.d.ts +75 -0
- package/dist/utils/format-utils.d.ts.map +1 -0
- package/dist/utils/range.d.ts +13 -0
- package/dist/utils/range.d.ts.map +1 -0
- package/dist/workbook.d.ts +155 -0
- package/dist/workbook.d.ts.map +1 -0
- package/package.json +46 -0
- package/src/canvas/cell-renderer.ts +181 -0
- package/src/canvas/grid-renderer.ts +238 -0
- package/src/canvas/header-renderer.ts +402 -0
- package/src/canvas/hit-testing.ts +537 -0
- package/src/canvas/index.ts +16 -0
- package/src/canvas/renderer.ts +1056 -0
- package/src/canvas/selection-renderer.ts +604 -0
- package/src/canvas/text-renderer.ts +321 -0
- package/src/canvas/types.ts +289 -0
- package/src/collaboration/firebase-provider.ts +48 -0
- package/src/collaboration/index.ts +5 -0
- package/src/collaboration/types.ts +38 -0
- package/src/event-emitter.ts +73 -0
- package/src/export/csv.ts +101 -0
- package/src/export/index.ts +4 -0
- package/src/features/filter.ts +231 -0
- package/src/features/freeze.ts +271 -0
- package/src/features/index.ts +5 -0
- package/src/features/sort.ts +282 -0
- package/src/format-pool.ts +61 -0
- package/src/formula-graph.ts +84 -0
- package/src/formula-parser/cell-reference.ts +99 -0
- package/src/formula-parser/formula-adjust.ts +129 -0
- package/src/formula-parser/formula-ranges.ts +159 -0
- package/src/formula-parser/index.ts +8 -0
- package/src/formula-parser/parser.ts +438 -0
- package/src/formula-parser/types.ts +39 -0
- package/src/index.ts +25 -0
- package/src/sheet.ts +502 -0
- package/src/style-pool.ts +62 -0
- package/src/types.ts +291 -0
- package/src/utils/cell-key.ts +19 -0
- package/src/utils/format-utils.ts +515 -0
- package/src/utils/range.ts +53 -0
- package/src/workbook.ts +1031 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @pagent-sheets/core
|
|
2
|
+
|
|
3
|
+
Core spreadsheet engine for pagent-sheets. Zero React dependencies.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Sparse cell storage (Map-based)
|
|
8
|
+
- Efficient range operations
|
|
9
|
+
- Formula dependency graph
|
|
10
|
+
- Style pooling for memory efficiency
|
|
11
|
+
- Event system with batching
|
|
12
|
+
- TypeScript strict mode
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { WorkbookImpl } from '@pagent-sheets/core';
|
|
18
|
+
|
|
19
|
+
const workbook = new WorkbookImpl('workbook_1', 'My Workbook');
|
|
20
|
+
const sheet = workbook.getSheet();
|
|
21
|
+
|
|
22
|
+
workbook.setCellValue(undefined, 0, 0, 'Hello');
|
|
23
|
+
workbook.setCellValue(undefined, 0, 1, 'World');
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Performance
|
|
27
|
+
|
|
28
|
+
- O(1) cell lookups
|
|
29
|
+
- Memory efficient for sparse sheets
|
|
30
|
+
- Incremental formula recalculation
|
|
31
|
+
- Shared style objects
|
|
32
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { CanvasTheme, Rect } from '../../src/canvas/types';
|
|
2
|
+
import type { Cell, CellStyle, CellFormat } from '../../src/types';
|
|
3
|
+
import { TextRenderer } from '../../src/canvas/text-renderer';
|
|
4
|
+
/**
|
|
5
|
+
* Renders cell content including backgrounds, text, and borders
|
|
6
|
+
*/
|
|
7
|
+
export declare class CellRenderer {
|
|
8
|
+
private theme;
|
|
9
|
+
private textRenderer;
|
|
10
|
+
private gridRenderer;
|
|
11
|
+
constructor(theme: CanvasTheme, textRenderer: TextRenderer);
|
|
12
|
+
/**
|
|
13
|
+
* Render a cell with all its content
|
|
14
|
+
*/
|
|
15
|
+
renderCell(ctx: CanvasRenderingContext2D, cell: Cell | undefined, bounds: Rect, style: CellStyle | undefined, format: CellFormat | undefined): void;
|
|
16
|
+
/**
|
|
17
|
+
* Render an empty cell (just background)
|
|
18
|
+
*/
|
|
19
|
+
renderEmptyCell(ctx: CanvasRenderingContext2D, bounds: Rect): void;
|
|
20
|
+
/**
|
|
21
|
+
* Render cell background
|
|
22
|
+
*/
|
|
23
|
+
private renderBackground;
|
|
24
|
+
/**
|
|
25
|
+
* Format cell value for display
|
|
26
|
+
*/
|
|
27
|
+
private formatCellValue;
|
|
28
|
+
/**
|
|
29
|
+
* Format a number according to the cell format
|
|
30
|
+
*/
|
|
31
|
+
private formatNumber;
|
|
32
|
+
/**
|
|
33
|
+
* Convert CellStyle to TextStyle for rendering
|
|
34
|
+
*/
|
|
35
|
+
private cellStyleToTextStyle;
|
|
36
|
+
/**
|
|
37
|
+
* Convert CellStyle borders to CellBorders
|
|
38
|
+
*/
|
|
39
|
+
private cellStyleToBorders;
|
|
40
|
+
/**
|
|
41
|
+
* Render a hyperlink cell (with special styling)
|
|
42
|
+
*/
|
|
43
|
+
renderHyperlinkCell(ctx: CanvasRenderingContext2D, cell: Cell, bounds: Rect, style: CellStyle | undefined, format: CellFormat | undefined): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=cell-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cell-renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/cell-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAA0B,MAAM,SAAS,CAAC;AACzE,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,YAAY,CAAe;gBAEvB,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY;IAM1D;;OAEG;IACH,UAAU,CACR,GAAG,EAAE,wBAAwB,EAC7B,IAAI,EAAE,IAAI,GAAG,SAAS,EACtB,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,MAAM,EAAE,UAAU,GAAG,SAAS,GAC7B,IAAI;IA4BP;;OAEG;IACH,eAAe,CAAC,GAAG,EAAE,wBAAwB,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI;IAIlE;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqBvB;;OAEG;IACH,OAAO,CAAC,YAAY;IAOpB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAiB5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAS1B;;OAEG;IACH,mBAAmB,CACjB,GAAG,EAAE,wBAAwB,EAC7B,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,SAAS,GAAG,SAAS,EAC5B,MAAM,EAAE,UAAU,GAAG,SAAS,GAC7B,IAAI;CAwBR"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CanvasTheme, Viewport, BorderStyle, CellBorders, Rect } from '../../src/canvas/types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders grid lines and cell borders
|
|
4
|
+
*/
|
|
5
|
+
export declare class GridRenderer {
|
|
6
|
+
private theme;
|
|
7
|
+
constructor(theme: CanvasTheme);
|
|
8
|
+
/**
|
|
9
|
+
* Render grid lines for the visible area
|
|
10
|
+
*/
|
|
11
|
+
renderGridLines(ctx: CanvasRenderingContext2D, viewport: Viewport, rowHeights: Map<number, number>, colWidths: Map<number, number>, defaultRowHeight: number, defaultColWidth: number, headerWidth: number, headerHeight: number, startRow: number, endRow: number, startCol: number, endCol: number, hiddenRows?: Set<number>, hiddenCols?: Set<number>): void;
|
|
12
|
+
/**
|
|
13
|
+
* Parse a CSS border string into a BorderStyle object
|
|
14
|
+
*/
|
|
15
|
+
parseBorderString(border: string | undefined): BorderStyle | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Render borders for a single cell
|
|
18
|
+
*/
|
|
19
|
+
renderCellBorders(ctx: CanvasRenderingContext2D, bounds: Rect, borders: CellBorders): void;
|
|
20
|
+
/**
|
|
21
|
+
* Render a single border line with the specified style
|
|
22
|
+
*/
|
|
23
|
+
private renderBorderLine;
|
|
24
|
+
/**
|
|
25
|
+
* Render borders for all visible cells that have custom borders
|
|
26
|
+
*/
|
|
27
|
+
renderAllCellBorders(ctx: CanvasRenderingContext2D, cellBorders: Map<string, CellBorders>, viewport: Viewport, rowHeights: Map<number, number>, colWidths: Map<number, number>, defaultRowHeight: number, defaultColWidth: number, headerWidth: number, headerHeight: number, startRow: number, endRow: number, startCol: number, endCol: number): void;
|
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AClB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,IAAI;CAqCR"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CanvasTheme, CellPosition } from '../../src/canvas/types';
|
|
2
|
+
import type { Selection, ColumnFilter } from '../../src/types';
|
|
3
|
+
/**
|
|
4
|
+
* Renders row and column headers
|
|
5
|
+
*/
|
|
6
|
+
export declare class HeaderRenderer {
|
|
7
|
+
private theme;
|
|
8
|
+
constructor(theme: CanvasTheme);
|
|
9
|
+
/**
|
|
10
|
+
* Convert column index to letter label (0 -> A, 1 -> B, ..., 26 -> AA, etc.)
|
|
11
|
+
*/
|
|
12
|
+
columnIndexToLabel(index: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Check if a column is in the selection
|
|
15
|
+
*/
|
|
16
|
+
private isColumnSelected;
|
|
17
|
+
/**
|
|
18
|
+
* Check if a row is in the selection
|
|
19
|
+
*/
|
|
20
|
+
private isRowSelected;
|
|
21
|
+
/**
|
|
22
|
+
* Check if there are hidden columns immediately before the given column
|
|
23
|
+
*/
|
|
24
|
+
private hasHiddenColumnsBefore;
|
|
25
|
+
/**
|
|
26
|
+
* Render column headers
|
|
27
|
+
*/
|
|
28
|
+
renderColumnHeaders(ctx: CanvasRenderingContext2D, startCol: number, endCol: number, scrollLeft: number, colWidths: Map<number, number>, defaultColWidth: number, headerWidth: number, headerHeight: number, selection: Selection | null, activeCell: CellPosition | null, hiddenCols?: Set<number>, skipAccumulationBefore?: number, filters?: Map<number, ColumnFilter>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check if there are hidden rows immediately before the given row
|
|
31
|
+
*/
|
|
32
|
+
private hasHiddenRowsBefore;
|
|
33
|
+
/**
|
|
34
|
+
* Render row headers
|
|
35
|
+
*/
|
|
36
|
+
renderRowHeaders(ctx: CanvasRenderingContext2D, startRow: number, endRow: number, scrollTop: number, rowHeights: Map<number, number>, defaultRowHeight: number, headerWidth: number, headerHeight: number, selection: Selection | null, activeCell: CellPosition | null, hiddenRows?: Set<number>, skipAccumulationBefore?: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Render the corner cell (intersection of row and column headers)
|
|
39
|
+
*/
|
|
40
|
+
renderCornerCell(ctx: CanvasRenderingContext2D, headerWidth: number, headerHeight: number): void;
|
|
41
|
+
/**
|
|
42
|
+
* Render resize handles for columns
|
|
43
|
+
*/
|
|
44
|
+
renderColumnResizeHandle(ctx: CanvasRenderingContext2D, x: number, headerHeight: number): void;
|
|
45
|
+
/**
|
|
46
|
+
* Render resize handles for rows
|
|
47
|
+
*/
|
|
48
|
+
renderRowResizeHandle(ctx: CanvasRenderingContext2D, y: number, headerWidth: number): void;
|
|
49
|
+
/**
|
|
50
|
+
* Render filter icon in column header
|
|
51
|
+
*/
|
|
52
|
+
private renderFilterIcon;
|
|
53
|
+
/**
|
|
54
|
+
* Darken a hex color by a percentage
|
|
55
|
+
*/
|
|
56
|
+
private darkenColor;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=header-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/header-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExD;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAc;gBAEf,KAAK,EAAE,WAAW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M,GACnB,IAAI;IAoBP;;OAEG;IACH,wBAAwB,CACtB,GAAG,EAAE,wBAAwB,EAC7B,CAAC,EAAE,MAAM,EACT,YAAY,EAAE,MAAM,GACnB,IAAI;IASP;;OAEG;IACH,qBAAqB,CACnB,GAAG,EAAE,wBAAwB,EAC7B,CAAC,EAAE,MAAM,EACT,WAAW,EAAE,MAAM,GAClB,IAAI;IASP;;OAEG;IACH,OAAO,CAAC,gBAAgB;IA8BxB;;OAEG;IACH,OAAO,CAAC,WAAW;CAiBpB"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { CellPosition, HeaderHit, ResizeHandle } from '../../src/canvas/types';
|
|
2
|
+
import type { Range } from '../../src/types';
|
|
3
|
+
/**
|
|
4
|
+
* Handles hit testing for mouse interactions
|
|
5
|
+
*/
|
|
6
|
+
export declare class HitTester {
|
|
7
|
+
private headerWidth;
|
|
8
|
+
private headerHeight;
|
|
9
|
+
private defaultRowHeight;
|
|
10
|
+
private defaultColWidth;
|
|
11
|
+
private scrollTop;
|
|
12
|
+
private scrollLeft;
|
|
13
|
+
private rowHeights;
|
|
14
|
+
private colWidths;
|
|
15
|
+
private rowCount;
|
|
16
|
+
private colCount;
|
|
17
|
+
private hiddenRows;
|
|
18
|
+
private hiddenCols;
|
|
19
|
+
private frozenRows;
|
|
20
|
+
private frozenCols;
|
|
21
|
+
private frozenWidth;
|
|
22
|
+
private frozenHeight;
|
|
23
|
+
constructor(headerWidth: number, headerHeight: number, defaultRowHeight: number, defaultColWidth: number);
|
|
24
|
+
/**
|
|
25
|
+
* Update scroll position
|
|
26
|
+
*/
|
|
27
|
+
setScroll(scrollTop: number, scrollLeft: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Update dimension information
|
|
30
|
+
*/
|
|
31
|
+
setDimensions(rowHeights: Map<number, number>, colWidths: Map<number, number>, defaultRowHeight: number, defaultColWidth: number, rowCount: number, colCount: number, hiddenRows?: Set<number>, hiddenCols?: Set<number>): void;
|
|
32
|
+
/**
|
|
33
|
+
* Update freeze panes configuration
|
|
34
|
+
*/
|
|
35
|
+
setFreezeConfig(frozenRows: number, frozenCols: number, frozenWidth: number, frozenHeight: number): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get the cell at a canvas point (accounting for freeze panes)
|
|
38
|
+
*/
|
|
39
|
+
getCellAt(x: number, y: number): CellPosition | null;
|
|
40
|
+
/**
|
|
41
|
+
* Get the header at a canvas point (accounting for freeze panes)
|
|
42
|
+
*/
|
|
43
|
+
getHeaderAt(x: number, y: number): HeaderHit | null;
|
|
44
|
+
/**
|
|
45
|
+
* Get resize handle at a point
|
|
46
|
+
*/
|
|
47
|
+
getResizeHandleAt(x: number, y: number): ResizeHandle | null;
|
|
48
|
+
/**
|
|
49
|
+
* Check if point is on the fill handle (accounting for freeze panes)
|
|
50
|
+
*/
|
|
51
|
+
getFillHandleAt(x: number, y: number, selectionRange: Range | undefined): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Convert grid position to canvas coordinates (accounting for freeze panes)
|
|
54
|
+
*/
|
|
55
|
+
gridToCanvas(row: number, col: number): {
|
|
56
|
+
x: number;
|
|
57
|
+
y: number;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Get the bounds of a cell in canvas coordinates (accounting for freeze panes)
|
|
61
|
+
*/
|
|
62
|
+
getCellBounds(row: number, col: number): {
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
} | null;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a point is in the corner cell
|
|
70
|
+
*/
|
|
71
|
+
isInCornerCell(x: number, y: number): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Get the total width of the grid (excluding hidden columns)
|
|
74
|
+
*/
|
|
75
|
+
getTotalWidth(): number;
|
|
76
|
+
/**
|
|
77
|
+
* Get the total height of the grid (excluding hidden rows)
|
|
78
|
+
*/
|
|
79
|
+
getTotalHeight(): number;
|
|
80
|
+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1
|
+
export * from '../../src/canvas/types';
|
|
2
|
+
export { CanvasRenderer } from '../../src/canvas/renderer';
|
|
3
|
+
export { TextRenderer } from '../../src/canvas/text-renderer';
|
|
4
|
+
export { GridRenderer } from '../../src/canvas/grid-renderer';
|
|
5
|
+
export { CellRenderer } from '../../src/canvas/cell-renderer';
|
|
6
|
+
export { HeaderRenderer } from '../../src/canvas/header-renderer';
|
|
7
|
+
export { SelectionRenderer } from '../../src/canvas/selection-renderer';
|
|
8
|
+
export { HitTester } from '../../src/canvas/hit-testing';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/canvas/index.ts"],"names":[],"mappings":"AAGA,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { CanvasRendererConfig, RenderState, Viewport, CellPosition, DirtyRegion, Rect } from '../../src/canvas/types';
|
|
2
|
+
import { HitTester } from '../../src/canvas/hit-testing';
|
|
3
|
+
import { type FreezeDimensions } from '../../src/features/freeze';
|
|
4
|
+
/**
|
|
5
|
+
* Main canvas renderer that coordinates all rendering operations
|
|
6
|
+
*/
|
|
7
|
+
export declare class CanvasRenderer {
|
|
8
|
+
private canvas;
|
|
9
|
+
private ctx;
|
|
10
|
+
private devicePixelRatio;
|
|
11
|
+
private defaultRowHeight;
|
|
12
|
+
private defaultColWidth;
|
|
13
|
+
private headerHeight;
|
|
14
|
+
private headerWidth;
|
|
15
|
+
private theme;
|
|
16
|
+
private viewport;
|
|
17
|
+
private renderState;
|
|
18
|
+
private textRenderer;
|
|
19
|
+
private gridRenderer;
|
|
20
|
+
private cellRenderer;
|
|
21
|
+
private headerRenderer;
|
|
22
|
+
private selectionRenderer;
|
|
23
|
+
private hitTester;
|
|
24
|
+
private isDirty;
|
|
25
|
+
private dirtyRegions;
|
|
26
|
+
private animationFrameId;
|
|
27
|
+
private freezeDimensions;
|
|
28
|
+
private frozenRows;
|
|
29
|
+
private frozenCols;
|
|
30
|
+
constructor(config: CanvasRendererConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Set up canvas for high DPI displays
|
|
33
|
+
*/
|
|
34
|
+
private setupCanvas;
|
|
35
|
+
/**
|
|
36
|
+
* Resize the canvas
|
|
37
|
+
*/
|
|
38
|
+
resize(width: number, height: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Set the viewport scroll position
|
|
41
|
+
*/
|
|
42
|
+
setViewport(scrollTop: number, scrollLeft: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Calculate the visible range based on current viewport and optionally provided dimensions.
|
|
45
|
+
* This can be called before setState to get an accurate viewport for cell loading.
|
|
46
|
+
*/
|
|
47
|
+
calculateVisibleRangeForDimensions(rowCount: number, colCount: number, rowHeights?: Map<number, number>, colWidths?: Map<number, number>): void;
|
|
48
|
+
/**
|
|
49
|
+
* Update the render state
|
|
50
|
+
*/
|
|
51
|
+
setState(state: RenderState): void;
|
|
52
|
+
/**
|
|
53
|
+
* Mark the canvas as needing redraw
|
|
54
|
+
*/
|
|
55
|
+
invalidate(region?: DirtyRegion): void;
|
|
56
|
+
/**
|
|
57
|
+
* Force an immediate render
|
|
58
|
+
*/
|
|
59
|
+
renderNow(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Main render method
|
|
62
|
+
*/
|
|
63
|
+
private render;
|
|
64
|
+
/**
|
|
65
|
+
* Render a specific freeze region (cells, grid lines, selection)
|
|
66
|
+
*/
|
|
67
|
+
private renderRegion;
|
|
68
|
+
/**
|
|
69
|
+
* Render freeze divider lines
|
|
70
|
+
*/
|
|
71
|
+
private renderFreezeDividers;
|
|
72
|
+
/**
|
|
73
|
+
* Calculate which rows and columns are visible
|
|
74
|
+
*/
|
|
75
|
+
private calculateVisibleRange;
|
|
76
|
+
/**
|
|
77
|
+
* Render cells in a specific region
|
|
78
|
+
*/
|
|
79
|
+
private renderCellsInRegion;
|
|
80
|
+
/**
|
|
81
|
+
* Render grid lines in a specific region
|
|
82
|
+
*/
|
|
83
|
+
private renderGridLinesInRegion;
|
|
84
|
+
/**
|
|
85
|
+
* Render selection in a specific region
|
|
86
|
+
*/
|
|
87
|
+
private renderSelectionInRegion;
|
|
88
|
+
/**
|
|
89
|
+
* Render row and column headers
|
|
90
|
+
*/
|
|
91
|
+
private renderHeaders;
|
|
92
|
+
/**
|
|
93
|
+
* Render the corner cell
|
|
94
|
+
*/
|
|
95
|
+
private renderCornerCell;
|
|
96
|
+
/**
|
|
97
|
+
* Get the cell at a canvas point
|
|
98
|
+
*/
|
|
99
|
+
getCellAtPoint(x: number, y: number): CellPosition | null;
|
|
100
|
+
/**
|
|
101
|
+
* Get header at a canvas point
|
|
102
|
+
*/
|
|
103
|
+
getHeaderAtPoint(x: number, y: number): import("../../src/canvas/types").HeaderHit | null;
|
|
104
|
+
/**
|
|
105
|
+
* Get resize handle at a canvas point
|
|
106
|
+
*/
|
|
107
|
+
getResizeHandleAtPoint(x: number, y: number): import("../../src/canvas/types").ResizeHandle | null;
|
|
108
|
+
/**
|
|
109
|
+
* Check if point is on fill handle
|
|
110
|
+
*/
|
|
111
|
+
isFillHandleAtPoint(x: number, y: number): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Get cell bounds in canvas coordinates (accounting for freeze panes)
|
|
114
|
+
*/
|
|
115
|
+
getCellBounds(row: number, col: number): Rect | null;
|
|
116
|
+
/**
|
|
117
|
+
* Get the current viewport
|
|
118
|
+
*/
|
|
119
|
+
getViewport(): Viewport;
|
|
120
|
+
/**
|
|
121
|
+
* Get the hit tester
|
|
122
|
+
*/
|
|
123
|
+
getHitTester(): HitTester;
|
|
124
|
+
/**
|
|
125
|
+
* Get the current freeze dimensions
|
|
126
|
+
*/
|
|
127
|
+
getFreezeDimensions(): FreezeDimensions;
|
|
128
|
+
/**
|
|
129
|
+
* Get frozen row/col counts
|
|
130
|
+
*/
|
|
131
|
+
getFreezeConfig(): {
|
|
132
|
+
frozenRows: number;
|
|
133
|
+
frozenCols: number;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Cleanup resources
|
|
137
|
+
*/
|
|
138
|
+
destroy(): void;
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,WAAW,EAEX,IAAI,EACL,MAAM,SAAS,CAAC;AAOjB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,GAAG,CAA2B;IACtC,OAAO,CAAC,gBAAgB,CAAS;IAGjC,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,KAAK,CAAc;IAG3B,OAAO,CAAC,QAAQ,CAAW;IAG3B,OAAO,CAAC,WAAW,CAA4B;IAG/C,OAAO,CAAC,YAAY,CAAe;IACn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,CAAC,uBAAuB;IAmD/B;;OAEG;IACH,OAAO,CAAC,aAAa;IA+GrB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAQxB;;OAEG;IACH,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI;IAIzD;;OAEG;IACH,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAIrC;;OAEG;IACH,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAI3C;;OAEG;IACH,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO;IAWlD;;OAEG;IACH,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAkEpD;;OAEG;IACH,WAAW,IAAI,QAAQ;IAIvB;;OAEG;IACH,YAAY,IAAI,SAAS;IAIzB;;OAEG;IACH,mBAAmB,IAAI,gBAAgB;IAIvC;;OAEG;IACH,eAAe,IAAI;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;IAI7D;;OAEG;IACH,OAAO,IAAI,IAAI;CAMhB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CanvasTheme, Viewport, CellPosition, FormulaRangeHighlight } from '../../src/canvas/types';
|
|
2
|
+
import type { Selection, Range } from '../../src/types';
|
|
3
|
+
import type { FreezeRegion } from '../../src/features/freeze';
|
|
4
|
+
/**
|
|
5
|
+
* Renders selection highlighting and active cell border
|
|
6
|
+
*/
|
|
7
|
+
export declare class SelectionRenderer {
|
|
8
|
+
private theme;
|
|
9
|
+
constructor(theme: CanvasTheme);
|
|
10
|
+
/**
|
|
11
|
+
* Main render method for all selection elements
|
|
12
|
+
* @param frozenRows - Number of frozen rows (optional, for freeze pane support)
|
|
13
|
+
* @param frozenCols - Number of frozen columns (optional, for freeze pane support)
|
|
14
|
+
* @param currentRegion - Current freeze region being rendered (optional)
|
|
15
|
+
*/
|
|
16
|
+
render(ctx: CanvasRenderingContext2D, selection: Selection | null, activeCell: CellPosition | null, viewport: Viewport, rowHeights: Map<number, number>, colWidths: Map<number, number>, defaultRowHeight: number, defaultColWidth: number, headerWidth: number, headerHeight: number, formulaRanges?: FormulaRangeHighlight[], hiddenRows?: Set<number>, hiddenCols?: Set<number>, frozenRows?: number, frozenCols?: number, currentRegion?: FreezeRegion): void;
|
|
17
|
+
/**
|
|
18
|
+
* Determine if a range should be rendered in the current freeze region.
|
|
19
|
+
* A range should be rendered if any of its cells overlap with the current region.
|
|
20
|
+
*/
|
|
21
|
+
private shouldRenderRangeInRegion;
|
|
22
|
+
/**
|
|
23
|
+
* Get color for formula range by index
|
|
24
|
+
*/
|
|
25
|
+
private getFormulaRangeColor;
|
|
26
|
+
/**
|
|
27
|
+
* Render a formula range highlight (cell references in formulas)
|
|
28
|
+
*/
|
|
29
|
+
private renderFormulaRange;
|
|
30
|
+
/**
|
|
31
|
+
* Calculate bounds for a range in canvas coordinates
|
|
32
|
+
*/
|
|
33
|
+
private getRangeBounds;
|
|
34
|
+
/**
|
|
35
|
+
* Render a selection range (highlight fill and border)
|
|
36
|
+
*/
|
|
37
|
+
private renderSelectionRange;
|
|
38
|
+
/**
|
|
39
|
+
* Render the active cell border
|
|
40
|
+
*/
|
|
41
|
+
private renderActiveCell;
|
|
42
|
+
/**
|
|
43
|
+
* Render the fill handle (small square at bottom-right of selection)
|
|
44
|
+
*/
|
|
45
|
+
private renderFillHandle;
|
|
46
|
+
/**
|
|
47
|
+
* Render copy/paste marching ants border
|
|
48
|
+
*/
|
|
49
|
+
renderMarchingAnts(ctx: CanvasRenderingContext2D, range: Range, viewport: Viewport, rowHeights: Map<number, number>, colWidths: Map<number, number>, defaultRowHeight: number, defaultColWidth: number, headerWidth: number, headerHeight: number, offset: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Render fill preview during fill handle drag
|
|
52
|
+
*/
|
|
53
|
+
renderFillPreview(ctx: CanvasRenderingContext2D, range: Range, viewport: Viewport, rowHeights: Map<number, number>, colWidths: Map<number, number>, defaultRowHeight: number, defaultColWidth: number, headerWidth: number, headerHeight: number): void;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=selection-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/selection-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAQ,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAAc;gBAEf,KAAK,EAAE,WAAW;IAI9B;;;;;OAKG;IACH,MAAM,CACJ,GAAG,EAAE,wBAAwB,EAC7B,SAAS,EAAE,SAAS,GAAG,IAAI,EAC3B,UAAU,EAAE,YAAY,GAAG,IAAI,EAC/B,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,qBAAqB,EAAE,EACvC,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EACxB,UAAU,CAAC,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EACnB,aAAa,CAAC,EAAE,YAAY,GAC3B,IAAI;IAgHP;;;OAGG;IACH,OAAO,CAAC,yBAAyB;IA2CjC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAwD1B;;OAEG;IACH,OAAO,CAAC,cAAc;IA4EtB;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA+C5B;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAkDxB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAwDxB;;OAEG;IACH,kBAAkB,CAChB,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,GACb,IAAI;IA8BP;;OAEG;IACH,iBAAiB,CACf,GAAG,EAAE,wBAAwB,EAC7B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/B,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,gBAAgB,EAAE,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,GACnB,IAAI;CA4BR"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { CanvasTheme, TextStyle, Rect } from '../../src/canvas/types';
|
|
2
|
+
/**
|
|
3
|
+
* Cached text metrics for a specific font configuration
|
|
4
|
+
*/
|
|
5
|
+
interface FontMetricsCache {
|
|
6
|
+
font: string;
|
|
7
|
+
lineHeight: number;
|
|
8
|
+
baseline: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Handles text measurement and rendering with caching
|
|
12
|
+
*/
|
|
13
|
+
export declare class TextRenderer {
|
|
14
|
+
private theme;
|
|
15
|
+
private metricsCache;
|
|
16
|
+
private measureCanvas;
|
|
17
|
+
private measureCtx;
|
|
18
|
+
constructor(theme: CanvasTheme);
|
|
19
|
+
/**
|
|
20
|
+
* Build CSS font string from style
|
|
21
|
+
*/
|
|
22
|
+
buildFontString(style: Partial<TextStyle>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get font metrics (with caching)
|
|
25
|
+
*/
|
|
26
|
+
getFontMetrics(font: string): FontMetricsCache;
|
|
27
|
+
/**
|
|
28
|
+
* Measure text width
|
|
29
|
+
*/
|
|
30
|
+
measureText(text: string, style: Partial<TextStyle>): number;
|
|
31
|
+
/**
|
|
32
|
+
* Truncate text to fit within maxWidth, adding ellipsis if needed
|
|
33
|
+
*/
|
|
34
|
+
truncateText(text: string, maxWidth: number, style: Partial<TextStyle>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Render text within bounds
|
|
37
|
+
*/
|
|
38
|
+
renderText(ctx: CanvasRenderingContext2D, text: string, bounds: Rect, style: Partial<TextStyle>, padding?: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* Render wrapped text (for cells with text wrapping enabled)
|
|
41
|
+
*/
|
|
42
|
+
renderWrappedText(ctx: CanvasRenderingContext2D, text: string, bounds: Rect, style: Partial<TextStyle>, padding?: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Clear the metrics cache
|
|
45
|
+
*/
|
|
46
|
+
clearCache(): void;
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
49
|
+
//# sourceMappingURL=text-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text-renderer.d.ts","sourceRoot":"","sources":["../../src/canvas/text-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAE,MAA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