@20baht/spreadsheet 0.3.0 → 0.3.1
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 +2 -1
- package/dist/book.d.ts +6 -2
- package/dist/book.js +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,8 @@ download.onclick = async () => saveFile(await xlsx(bookWorkbook(el.book)), 'repo
|
|
|
43
43
|
- `load(source, sheet)` is called when a book is opened, a data sheet is added and on `refresh()`.
|
|
44
44
|
Never on a timer.
|
|
45
45
|
- `readonly`, `labels` (`SPREADSHEET_LABELS` has every word).
|
|
46
|
-
- Give the element a height: the grid scrolls inside it and draws only the rows in view
|
|
46
|
+
- Give the element a height: the grid scrolls inside it and draws only the rows in view, so a sheet may hold
|
|
47
|
+
up to 100 000 rows (a data sheet of 40 000 by 30 columns fills in half a second).
|
|
47
48
|
|
|
48
49
|
Worked like Excel: click or arrows to select, Shift for a rectangle, a heading for its whole row or column, type to write, `=` for a formula,
|
|
49
50
|
F2 or a double click to edit, Delete to empty, Ctrl+B / I / U, Ctrl+Z / Y, copy and paste with Excel
|
package/dist/book.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export interface CellRange {
|
|
|
68
68
|
bottom: number;
|
|
69
69
|
right: number;
|
|
70
70
|
}
|
|
71
|
-
export declare const MAX_ROWS =
|
|
71
|
+
export declare const MAX_ROWS = 100000;
|
|
72
72
|
export declare const MAX_COLUMNS = 200;
|
|
73
73
|
export declare const MAX_SHEETS = 20;
|
|
74
74
|
/** The grid a sheet shows when it holds less. */
|
|
@@ -91,7 +91,11 @@ export declare function overlaps(a: CellRange, b: CellRange): boolean;
|
|
|
91
91
|
export declare function mergesOf(sheet: BookSheet): CellRange[];
|
|
92
92
|
/** The merged range a cell is part of. */
|
|
93
93
|
export declare function mergeAt(sheet: BookSheet, cell: CellPos): CellRange | null;
|
|
94
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* How far the sheet's cells reach: the rows and columns that hold something. Counted once for
|
|
96
|
+
* each set of cells (a book is never changed in place), so a sheet of many thousand rows is not
|
|
97
|
+
* walked again each time it is drawn.
|
|
98
|
+
*/
|
|
95
99
|
export declare function extentOf(sheet: BookSheet): {
|
|
96
100
|
rows: number;
|
|
97
101
|
columns: number;
|
package/dist/book.js
CHANGED
|
@@ -2,7 +2,7 @@ export const ALIGNS = ['left', 'center', 'right'];
|
|
|
2
2
|
export const VALIGNS = ['top', 'middle', 'bottom'];
|
|
3
3
|
export const NUMBER_FORMATS = ['number', 'integer', 'percent', 'date', 'datetime'];
|
|
4
4
|
export const BORDER_SIDES = ['top', 'right', 'bottom', 'left'];
|
|
5
|
-
export const MAX_ROWS =
|
|
5
|
+
export const MAX_ROWS = 100_000;
|
|
6
6
|
export const MAX_COLUMNS = 200;
|
|
7
7
|
export const MAX_SHEETS = 20;
|
|
8
8
|
export const DEFAULT_ROWS = 50;
|
|
@@ -66,7 +66,11 @@ export function mergesOf(sheet) {
|
|
|
66
66
|
export function mergeAt(sheet, cell) {
|
|
67
67
|
return mergesOf(sheet).find((range) => inRange(range, cell)) ?? null;
|
|
68
68
|
}
|
|
69
|
+
const EXTENTS = new WeakMap();
|
|
69
70
|
export function extentOf(sheet) {
|
|
71
|
+
const known = EXTENTS.get(sheet.cells);
|
|
72
|
+
if (known)
|
|
73
|
+
return known;
|
|
70
74
|
let rows = 0;
|
|
71
75
|
let columns = 0;
|
|
72
76
|
for (const address of Object.keys(sheet.cells)) {
|
|
@@ -76,7 +80,9 @@ export function extentOf(sheet) {
|
|
|
76
80
|
rows = Math.max(rows, cell.row + 1);
|
|
77
81
|
columns = Math.max(columns, cell.column + 1);
|
|
78
82
|
}
|
|
79
|
-
|
|
83
|
+
const extent = { rows, columns };
|
|
84
|
+
EXTENTS.set(sheet.cells, extent);
|
|
85
|
+
return extent;
|
|
80
86
|
}
|
|
81
87
|
export function sheetOf(book, key) {
|
|
82
88
|
return book.sheets.find((sheet) => sheet.key === key);
|