@datalayer/cells 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +55 -2
- package/lib/chrome/index.d.ts +7 -0
- package/lib/chrome/index.d.ts.map +1 -0
- package/lib/chrome/index.js +7 -0
- package/lib/chrome/index.js.map +1 -0
- package/lib/collab/index.d.ts +7 -0
- package/lib/collab/index.d.ts.map +1 -0
- package/lib/collab/index.js +7 -0
- package/lib/collab/index.js.map +1 -0
- package/lib/core/axis.d.ts +103 -0
- package/lib/core/axis.d.ts.map +1 -0
- package/lib/core/axis.js +470 -0
- package/lib/core/axis.js.map +1 -0
- package/lib/core/cells.d.ts +71 -0
- package/lib/core/cells.d.ts.map +1 -0
- package/lib/core/cells.js +285 -0
- package/lib/core/cells.js.map +1 -0
- package/lib/core/commands.d.ts +157 -0
- package/lib/core/commands.d.ts.map +1 -0
- package/lib/core/commands.js +620 -0
- package/lib/core/commands.js.map +1 -0
- package/lib/core/format.d.ts +52 -0
- package/lib/core/format.d.ts.map +1 -0
- package/lib/core/format.js +264 -0
- package/lib/core/format.js.map +1 -0
- package/lib/core/history.d.ts +42 -0
- package/lib/core/history.d.ts.map +1 -0
- package/lib/core/history.js +63 -0
- package/lib/core/history.js.map +1 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +28 -0
- package/lib/core/index.js.map +1 -0
- package/lib/core/model.d.ts +116 -0
- package/lib/core/model.d.ts.map +1 -0
- package/lib/core/model.js +330 -0
- package/lib/core/model.js.map +1 -0
- package/lib/core/patches.d.ts +140 -0
- package/lib/core/patches.d.ts.map +1 -0
- package/lib/core/patches.js +272 -0
- package/lib/core/patches.js.map +1 -0
- package/lib/core/reactor.d.ts +24 -0
- package/lib/core/reactor.d.ts.map +1 -0
- package/lib/core/reactor.js +48 -0
- package/lib/core/reactor.js.map +1 -0
- package/lib/core/selection.d.ts +81 -0
- package/lib/core/selection.d.ts.map +1 -0
- package/lib/core/selection.js +175 -0
- package/lib/core/selection.js.map +1 -0
- package/lib/core/strings.d.ts +19 -0
- package/lib/core/strings.d.ts.map +1 -0
- package/lib/core/strings.js +61 -0
- package/lib/core/strings.js.map +1 -0
- package/lib/core/styles.d.ts +48 -0
- package/lib/core/styles.d.ts.map +1 -0
- package/lib/core/styles.js +102 -0
- package/lib/core/styles.js.map +1 -0
- package/lib/core/values.d.ts +20 -0
- package/lib/core/values.d.ts.map +1 -0
- package/lib/core/values.js +39 -0
- package/lib/core/values.js.map +1 -0
- package/lib/core/workbook.d.ts +59 -0
- package/lib/core/workbook.d.ts.map +1 -0
- package/lib/core/workbook.js +101 -0
- package/lib/core/workbook.js.map +1 -0
- package/lib/core/zone.d.ts +48 -0
- package/lib/core/zone.d.ts.map +1 -0
- package/lib/core/zone.js +89 -0
- package/lib/core/zone.js.map +1 -0
- package/lib/csv/index.d.ts +7 -0
- package/lib/csv/index.d.ts.map +1 -0
- package/lib/csv/index.js +7 -0
- package/lib/csv/index.js.map +1 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +13 -0
- package/lib/index.js.map +1 -0
- package/lib/plugin/index.d.ts +7 -0
- package/lib/plugin/index.d.ts.map +1 -0
- package/lib/plugin/index.js +7 -0
- package/lib/plugin/index.js.map +1 -0
- package/lib/points/index.d.ts +154 -0
- package/lib/points/index.d.ts.map +1 -0
- package/lib/points/index.js +50 -0
- package/lib/points/index.js.map +1 -0
- package/lib/points/resolve.d.ts +56 -0
- package/lib/points/resolve.d.ts.map +1 -0
- package/lib/points/resolve.js +106 -0
- package/lib/points/resolve.js.map +1 -0
- package/lib/xlsx/index.d.ts +7 -0
- package/lib/xlsx/index.d.ts.map +1 -0
- package/lib/xlsx/index.js +7 -0
- package/lib/xlsx/index.js.map +1 -0
- package/package.json +116 -4
- package/style/cells.css +7 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The workbook's string pool: every string a cell holds, interned once and
|
|
3
|
+
* reference-counted, so a column of repeated labels costs one string.
|
|
4
|
+
*
|
|
5
|
+
* @module core/strings
|
|
6
|
+
*/
|
|
7
|
+
export declare class StringPool {
|
|
8
|
+
#private;
|
|
9
|
+
/** Take a reference to `text`; returns its index. */
|
|
10
|
+
intern(text: string): number;
|
|
11
|
+
/** Drop a reference; the string goes when the last one does. */
|
|
12
|
+
release(index: number): void;
|
|
13
|
+
get(index: number): string;
|
|
14
|
+
/** How many distinct strings are held. */
|
|
15
|
+
get size(): number;
|
|
16
|
+
/** How many references the string at `index` has. */
|
|
17
|
+
references(index: number): number;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=strings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/core/strings.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AAEH,qBAAa,UAAU;;IAMrB,qDAAqD;IACrD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAgB5B,gEAAgE;IAChE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAa5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAM1B,0CAA0C;IAC1C,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,qDAAqD;IACrD,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAGlC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2026 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* The workbook's string pool: every string a cell holds, interned once and
|
|
8
|
+
* reference-counted, so a column of repeated labels costs one string.
|
|
9
|
+
*
|
|
10
|
+
* @module core/strings
|
|
11
|
+
*/
|
|
12
|
+
export class StringPool {
|
|
13
|
+
#strings = [];
|
|
14
|
+
#counts = new Int32Array(64);
|
|
15
|
+
#index = new Map();
|
|
16
|
+
#free = [];
|
|
17
|
+
/** Take a reference to `text`; returns its index. */
|
|
18
|
+
intern(text) {
|
|
19
|
+
let i = this.#index.get(text);
|
|
20
|
+
if (i === undefined) {
|
|
21
|
+
i = this.#free.pop() ?? this.#strings.length;
|
|
22
|
+
this.#strings[i] = text;
|
|
23
|
+
this.#index.set(text, i);
|
|
24
|
+
if (i >= this.#counts.length) {
|
|
25
|
+
const counts = new Int32Array(this.#counts.length * 2);
|
|
26
|
+
counts.set(this.#counts);
|
|
27
|
+
this.#counts = counts;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
this.#counts[i] += 1;
|
|
31
|
+
return i;
|
|
32
|
+
}
|
|
33
|
+
/** Drop a reference; the string goes when the last one does. */
|
|
34
|
+
release(index) {
|
|
35
|
+
const text = this.#strings[index];
|
|
36
|
+
if (text === undefined || this.#counts[index] <= 0) {
|
|
37
|
+
throw new Error(`The string pool holds nothing at ${index}: released twice?`);
|
|
38
|
+
}
|
|
39
|
+
this.#counts[index] -= 1;
|
|
40
|
+
if (this.#counts[index] === 0) {
|
|
41
|
+
this.#strings[index] = undefined;
|
|
42
|
+
this.#index.delete(text);
|
|
43
|
+
this.#free.push(index);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
get(index) {
|
|
47
|
+
const text = this.#strings[index];
|
|
48
|
+
if (text === undefined)
|
|
49
|
+
throw new Error(`The string pool holds nothing at ${index}.`);
|
|
50
|
+
return text;
|
|
51
|
+
}
|
|
52
|
+
/** How many distinct strings are held. */
|
|
53
|
+
get size() {
|
|
54
|
+
return this.#index.size;
|
|
55
|
+
}
|
|
56
|
+
/** How many references the string at `index` has. */
|
|
57
|
+
references(index) {
|
|
58
|
+
return this.#counts[index] ?? 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=strings.js.map
|
|
@@ -0,0 +1 @@
|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AAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,mBAAmB,CAAC,CAAC;QAChF,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACzB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAa;QACf,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,IAAI,KAAK,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,KAAK,GAAG,CAAC,CAAC;QACtF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0CAA0C;IAC1C,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,qDAAqD;IACrD,UAAU,CAAC,KAAa;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cell styles, deduplicated by content into a table cells index with a
|
|
3
|
+
* `Uint16`. The table only grows, so an index is stable for the life of the
|
|
4
|
+
* workbook (undo and the file format rely on that); index 0 is the default.
|
|
5
|
+
*
|
|
6
|
+
* @module core/styles
|
|
7
|
+
*/
|
|
8
|
+
export type HorizontalAlign = 'left' | 'center' | 'right';
|
|
9
|
+
export type VerticalAlign = 'top' | 'middle' | 'bottom';
|
|
10
|
+
export type BorderStyle = 'thin' | 'medium' | 'thick' | 'dashed' | 'dotted' | 'double';
|
|
11
|
+
export interface BorderSide {
|
|
12
|
+
readonly style: BorderStyle;
|
|
13
|
+
readonly color: string;
|
|
14
|
+
}
|
|
15
|
+
export interface Style {
|
|
16
|
+
readonly font?: string;
|
|
17
|
+
readonly size?: number;
|
|
18
|
+
readonly bold?: boolean;
|
|
19
|
+
readonly italic?: boolean;
|
|
20
|
+
readonly underline?: boolean;
|
|
21
|
+
readonly strike?: boolean;
|
|
22
|
+
/** Text colour; absent means the theme's text colour. */
|
|
23
|
+
readonly color?: string;
|
|
24
|
+
readonly fill?: string;
|
|
25
|
+
readonly align?: HorizontalAlign;
|
|
26
|
+
readonly valign?: VerticalAlign;
|
|
27
|
+
readonly wrap?: boolean;
|
|
28
|
+
readonly borders?: {
|
|
29
|
+
readonly top?: BorderSide;
|
|
30
|
+
readonly right?: BorderSide;
|
|
31
|
+
readonly bottom?: BorderSide;
|
|
32
|
+
readonly left?: BorderSide;
|
|
33
|
+
};
|
|
34
|
+
/** An Excel number format, such as `#,##0.00` or `yyyy-mm-dd`. */
|
|
35
|
+
readonly format?: string;
|
|
36
|
+
}
|
|
37
|
+
/** Throws a sentence naming the first thing wrong with a style. */
|
|
38
|
+
export declare function checkStyle(style: unknown, where?: string): asserts style is Style;
|
|
39
|
+
export declare class StyleTable {
|
|
40
|
+
#private;
|
|
41
|
+
/** The index of a style, adding it when new. Index 0 is the default style. */
|
|
42
|
+
intern(style: Style): number;
|
|
43
|
+
get(index: number): Style;
|
|
44
|
+
get size(): number;
|
|
45
|
+
/** Every style, in index order (the file format's `styles`). */
|
|
46
|
+
all(): readonly Style[];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/core/styles.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AAEH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,QAAQ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mE;AACnE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAU,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CA0BlF;AAED,qBAAa,UAAU;;IAIrB,8EAA8E;IAC9E,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM;IAc5B,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK;IAOzB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,gEAAgE;IAChE,GAAG,IAAI,SAAS,KAAK,EAAE;CAGxB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2026 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
const KEYS = [
|
|
7
|
+
'font',
|
|
8
|
+
'size',
|
|
9
|
+
'bold',
|
|
10
|
+
'italic',
|
|
11
|
+
'underline',
|
|
12
|
+
'strike',
|
|
13
|
+
'color',
|
|
14
|
+
'fill',
|
|
15
|
+
'align',
|
|
16
|
+
'valign',
|
|
17
|
+
'wrap',
|
|
18
|
+
'borders',
|
|
19
|
+
'format',
|
|
20
|
+
];
|
|
21
|
+
const KEY_SET = new Set(KEYS);
|
|
22
|
+
const MAX_STYLES = 0xffff;
|
|
23
|
+
/** A canonical text for a style: its set keys in a fixed order, falsy flags dropped. */
|
|
24
|
+
function canonical(style) {
|
|
25
|
+
const out = {};
|
|
26
|
+
for (const key of KEYS) {
|
|
27
|
+
const value = style[key];
|
|
28
|
+
if (value === undefined || value === false)
|
|
29
|
+
continue;
|
|
30
|
+
out[key] = key === 'borders' ? canonicalBorders(value) : value;
|
|
31
|
+
}
|
|
32
|
+
return JSON.stringify(out);
|
|
33
|
+
}
|
|
34
|
+
function canonicalBorders(b) {
|
|
35
|
+
if (b === undefined)
|
|
36
|
+
return undefined;
|
|
37
|
+
const out = {};
|
|
38
|
+
for (const side of ['top', 'right', 'bottom', 'left'])
|
|
39
|
+
if (b[side])
|
|
40
|
+
out[side] = b[side];
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** Throws a sentence naming the first thing wrong with a style. */
|
|
44
|
+
export function checkStyle(style, where = 'style') {
|
|
45
|
+
if (typeof style !== 'object' || style === null || Array.isArray(style)) {
|
|
46
|
+
throw new Error(`${where}: a style is an object.`);
|
|
47
|
+
}
|
|
48
|
+
for (const key of Object.keys(style)) {
|
|
49
|
+
if (!KEY_SET.has(key))
|
|
50
|
+
throw new Error(`${where}: '${key}' is not a style property (${KEYS.join(', ')}).`);
|
|
51
|
+
}
|
|
52
|
+
const s = style;
|
|
53
|
+
for (const key of ['bold', 'italic', 'underline', 'strike', 'wrap']) {
|
|
54
|
+
if (s[key] !== undefined && typeof s[key] !== 'boolean')
|
|
55
|
+
throw new Error(`${where}.${key}: true or false.`);
|
|
56
|
+
}
|
|
57
|
+
for (const key of ['font', 'color', 'fill', 'format']) {
|
|
58
|
+
if (s[key] !== undefined && typeof s[key] !== 'string')
|
|
59
|
+
throw new Error(`${where}.${key}: a string.`);
|
|
60
|
+
}
|
|
61
|
+
if (s.size !== undefined && !(typeof s.size === 'number' && s.size > 0)) {
|
|
62
|
+
throw new Error(`${where}.size: a positive number.`);
|
|
63
|
+
}
|
|
64
|
+
if (s.align !== undefined && !['left', 'center', 'right'].includes(s.align)) {
|
|
65
|
+
throw new Error(`${where}.align: left, center or right.`);
|
|
66
|
+
}
|
|
67
|
+
if (s.valign !== undefined && !['top', 'middle', 'bottom'].includes(s.valign)) {
|
|
68
|
+
throw new Error(`${where}.valign: top, middle or bottom.`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
export class StyleTable {
|
|
72
|
+
#styles = [{}];
|
|
73
|
+
#index = new Map([[canonical({}), 0]]);
|
|
74
|
+
/** The index of a style, adding it when new. Index 0 is the default style. */
|
|
75
|
+
intern(style) {
|
|
76
|
+
const key = canonical(style);
|
|
77
|
+
let i = this.#index.get(key);
|
|
78
|
+
if (i === undefined) {
|
|
79
|
+
if (this.#styles.length > MAX_STYLES) {
|
|
80
|
+
throw new Error(`A workbook holds at most ${MAX_STYLES + 1} distinct styles.`);
|
|
81
|
+
}
|
|
82
|
+
i = this.#styles.length;
|
|
83
|
+
this.#styles.push(JSON.parse(key));
|
|
84
|
+
this.#index.set(key, i);
|
|
85
|
+
}
|
|
86
|
+
return i;
|
|
87
|
+
}
|
|
88
|
+
get(index) {
|
|
89
|
+
const style = this.#styles[index];
|
|
90
|
+
if (style === undefined)
|
|
91
|
+
throw new Error(`No style ${index}; the workbook has ${this.#styles.length}.`);
|
|
92
|
+
return style;
|
|
93
|
+
}
|
|
94
|
+
get size() {
|
|
95
|
+
return this.#styles.length;
|
|
96
|
+
}
|
|
97
|
+
/** Every style, in index order (the file format's `styles`). */
|
|
98
|
+
all() {
|
|
99
|
+
return this.#styles;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../src/core/styles.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA0CH,MAAM,IAAI,GAA6B;IACrC,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,WAAW;IACX,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,QAAQ;IACR,MAAM;IACN,SAAS;IACT,QAAQ;CACT,CAAC;AACF,MAAM,OAAO,GAAwB,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;AACnD,MAAM,UAAU,GAAG,MAAM,CAAC;AAE1B,wFAAwF;AACxF,SAAS,SAAS,CAAC,KAAY;IAC7B,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK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+
*
|
|
4
|
+
* @module core/values
|
|
5
|
+
*/
|
|
6
|
+
/** The errors a cell can hold, as Excel spells them (`#CYCLE!` and `#BUSY!` are ours). */
|
|
7
|
+
export declare const CELL_ERRORS: readonly ["#DIV/0!", "#REF!", "#NAME?", "#VALUE!", "#N/A", "#NUM!", "#NULL!", "#CYCLE!", "#BUSY!", "#SPILL!"];
|
|
8
|
+
export type CellErrorCode = (typeof CELL_ERRORS)[number];
|
|
9
|
+
/** An error value, with an optional sentence saying why (shown in the cell's tooltip). */
|
|
10
|
+
export interface CellError {
|
|
11
|
+
readonly error: CellErrorCode;
|
|
12
|
+
readonly message?: string;
|
|
13
|
+
}
|
|
14
|
+
/** What a cell evaluates to. `null` is empty. */
|
|
15
|
+
export type CellValue = number | string | boolean | CellError | null;
|
|
16
|
+
/** An error value; refuses a code that is not one of {@link CELL_ERRORS}. */
|
|
17
|
+
export declare function cellError(code: CellErrorCode, message?: string): CellError;
|
|
18
|
+
export declare function isCellError(value: unknown): value is CellError;
|
|
19
|
+
export declare function isErrorCode(text: string): text is CellErrorCode;
|
|
20
|
+
//# sourceMappingURL=values.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.d.ts","sourceRoot":"","sources":["../../src/core/values.ts"],"names":[],"mappings":"AAMA;;;;GAIG;AAEH,0FAA0F;AAC1F,eAAO,MAAM,WAAW,+GAWd,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzD,0FAA0F;AAC1F,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;AAIrE,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAI1E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAM9D;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,aAAa,CAE/D"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2026 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Cell values and errors.
|
|
8
|
+
*
|
|
9
|
+
* @module core/values
|
|
10
|
+
*/
|
|
11
|
+
/** The errors a cell can hold, as Excel spells them (`#CYCLE!` and `#BUSY!` are ours). */
|
|
12
|
+
export const CELL_ERRORS = [
|
|
13
|
+
'#DIV/0!',
|
|
14
|
+
'#REF!',
|
|
15
|
+
'#NAME?',
|
|
16
|
+
'#VALUE!',
|
|
17
|
+
'#N/A',
|
|
18
|
+
'#NUM!',
|
|
19
|
+
'#NULL!',
|
|
20
|
+
'#CYCLE!',
|
|
21
|
+
'#BUSY!',
|
|
22
|
+
'#SPILL!',
|
|
23
|
+
];
|
|
24
|
+
const ERROR_SET = new Set(CELL_ERRORS);
|
|
25
|
+
/** An error value; refuses a code that is not one of {@link CELL_ERRORS}. */
|
|
26
|
+
export function cellError(code, message) {
|
|
27
|
+
if (!ERROR_SET.has(code))
|
|
28
|
+
throw new Error(`'${code}' is not a cell error; there are ${CELL_ERRORS.join(' ')}.`);
|
|
29
|
+
return message === undefined ? { error: code } : { error: code, message };
|
|
30
|
+
}
|
|
31
|
+
export function isCellError(value) {
|
|
32
|
+
return (typeof value === 'object' &&
|
|
33
|
+
value !== null &&
|
|
34
|
+
ERROR_SET.has(value.error));
|
|
35
|
+
}
|
|
36
|
+
export function isErrorCode(text) {
|
|
37
|
+
return ERROR_SET.has(text);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values.js","sourceRoot":"","sources":["../../src/core/values.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,SAAS;IACT,OAAO;IACP,QAAQ;IACR,SAAS;IACT,MAAM;IACN,OAAO;IACP,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;CACD,CAAC;AAaX,MAAM,SAAS,GAAwB,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;AAE5D,6EAA6E;AAC7E,MAAM,UAAU,SAAS,CAAC,IAAmB,EAAE,OAAgB;IAC7D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,IAAI,IAAI,oCAAoC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACxF,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,CAAC,GAAG,CAAE,KAA6B,CAAC,KAAe,CAAC,CAC9D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persisted state of a workbook: sheets, their axes and cells, merges and
|
|
3
|
+
* frozen panes, and the pools cells reference (strings, styles, formulas).
|
|
4
|
+
* Only patches write it (core/patches); the model reads it through getters.
|
|
5
|
+
*
|
|
6
|
+
* @module core/workbook
|
|
7
|
+
*/
|
|
8
|
+
import { Axis } from './axis.js';
|
|
9
|
+
import { FormulaTable, SheetCells } from './cells.js';
|
|
10
|
+
import { StringPool } from './strings.js';
|
|
11
|
+
import { StyleTable } from './styles.js';
|
|
12
|
+
import { type Zone } from './zone.js';
|
|
13
|
+
/** The size limits of a sheet. Excel's by default. */
|
|
14
|
+
export interface Limits {
|
|
15
|
+
readonly rows: number;
|
|
16
|
+
readonly cols: number;
|
|
17
|
+
readonly rowHeight: number;
|
|
18
|
+
readonly colWidth: number;
|
|
19
|
+
}
|
|
20
|
+
export declare const DEFAULT_LIMITS: Limits;
|
|
21
|
+
export interface Frozen {
|
|
22
|
+
readonly rows: number;
|
|
23
|
+
readonly cols: number;
|
|
24
|
+
}
|
|
25
|
+
export declare class Sheet {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
readonly rows: Axis;
|
|
29
|
+
readonly cols: Axis;
|
|
30
|
+
readonly cells: SheetCells;
|
|
31
|
+
/** Merged zones, disjoint. */
|
|
32
|
+
merges: Zone[];
|
|
33
|
+
frozen: Frozen;
|
|
34
|
+
constructor(id: string, name: string, limits: Limits, cells: SheetCells);
|
|
35
|
+
/** The merge holding a position, or `undefined`. */
|
|
36
|
+
mergeAt(row: number, col: number): Zone | undefined;
|
|
37
|
+
/** Merges overlapping a zone. */
|
|
38
|
+
mergesIn(zone: Zone): Zone[];
|
|
39
|
+
}
|
|
40
|
+
export declare class Workbook {
|
|
41
|
+
#private;
|
|
42
|
+
readonly limits: Limits;
|
|
43
|
+
readonly strings: StringPool;
|
|
44
|
+
readonly styles: StyleTable;
|
|
45
|
+
readonly formulas: FormulaTable;
|
|
46
|
+
/** In tab order. */
|
|
47
|
+
readonly sheets: Sheet[];
|
|
48
|
+
constructor(limits?: Limits);
|
|
49
|
+
/** A new, detached sheet with a fresh id; `ADD_SHEET` attaches it through a patch. */
|
|
50
|
+
createSheet(name: string, id?: string): Sheet;
|
|
51
|
+
/** The sheet of that id; throws a sentence naming the ids there are. */
|
|
52
|
+
sheet(id: string): Sheet;
|
|
53
|
+
hasSheet(id: string): boolean;
|
|
54
|
+
/** The sheet of that name, case-insensitively, as Excel matches names. */
|
|
55
|
+
sheetByName(name: string): Sheet | undefined;
|
|
56
|
+
/** A name no sheet has: `Sheet1`, `Sheet2`, … */
|
|
57
|
+
freshSheetName(): string;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=workbook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbook.d.ts","sourceRoot":"","sources":["../../src/core/workbook.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,KAAK,IAAI,EAAgB,MAAM,WAAW,CAAC;AAEpD,sDAAsD;AACtD,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,MAK5B,CAAC;AAEF,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qBAAa,KAAK;IAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,IAAI,EAAE,IAAI,C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merges and
|
|
8
|
+
* frozen panes, and the pools cells reference (strings, styles, formulas).
|
|
9
|
+
* Only patches write it (core/patches); the model reads it through getters.
|
|
10
|
+
*
|
|
11
|
+
* @module core/workbook
|
|
12
|
+
*/
|
|
13
|
+
import { Axis } from './axis.js';
|
|
14
|
+
import { FormulaTable, SheetCells } from './cells.js';
|
|
15
|
+
import { StringPool } from './strings.js';
|
|
16
|
+
import { StyleTable } from './styles.js';
|
|
17
|
+
import { zonesOverlap } from './zone.js';
|
|
18
|
+
export const DEFAULT_LIMITS = {
|
|
19
|
+
rows: 1_048_576,
|
|
20
|
+
cols: 16_384,
|
|
21
|
+
rowHeight: 21,
|
|
22
|
+
colWidth: 100,
|
|
23
|
+
};
|
|
24
|
+
export class Sheet {
|
|
25
|
+
id;
|
|
26
|
+
name;
|
|
27
|
+
rows;
|
|
28
|
+
cols;
|
|
29
|
+
cells;
|
|
30
|
+
/** Merged zones, disjoint. */
|
|
31
|
+
merges = [];
|
|
32
|
+
frozen = { rows: 0, cols: 0 };
|
|
33
|
+
constructor(id, name, limits, cells) {
|
|
34
|
+
this.id = id;
|
|
35
|
+
this.name = name;
|
|
36
|
+
this.rows = new Axis({ count: limits.rows, defaultSize: limits.rowHeight });
|
|
37
|
+
this.cols = new Axis({ count: limits.cols, defaultSize: limits.colWidth });
|
|
38
|
+
this.cells = cells;
|
|
39
|
+
}
|
|
40
|
+
/** The merge holding a position, or `undefined`. */
|
|
41
|
+
mergeAt(row, col) {
|
|
42
|
+
return this.merges.find((m) => row >= m.top && row <= m.bottom && col >= m.left && col <= m.right);
|
|
43
|
+
}
|
|
44
|
+
/** Merges overlapping a zone. */
|
|
45
|
+
mergesIn(zone) {
|
|
46
|
+
return this.merges.filter((m) => zonesOverlap(m, zone));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class Workbook {
|
|
50
|
+
limits;
|
|
51
|
+
strings = new StringPool();
|
|
52
|
+
styles = new StyleTable();
|
|
53
|
+
formulas = new FormulaTable();
|
|
54
|
+
/** In tab order. */
|
|
55
|
+
sheets = [];
|
|
56
|
+
#nextSheet = 1;
|
|
57
|
+
constructor(limits = DEFAULT_LIMITS) {
|
|
58
|
+
for (const [key, value] of Object.entries(limits)) {
|
|
59
|
+
if (!(typeof value === 'number' && value > 0))
|
|
60
|
+
throw new Error(`limits.${key} must be positive; ${value} was given.`);
|
|
61
|
+
}
|
|
62
|
+
this.limits = limits;
|
|
63
|
+
}
|
|
64
|
+
/** A new, detached sheet with a fresh id; `ADD_SHEET` attaches it through a patch. */
|
|
65
|
+
createSheet(name, id) {
|
|
66
|
+
const sheetId = id ?? this.#freshSheetId();
|
|
67
|
+
if (this.sheets.some((s) => s.id === sheetId))
|
|
68
|
+
throw new Error(`A sheet with id '${sheetId}' exists already.`);
|
|
69
|
+
return new Sheet(sheetId, name, this.limits, new SheetCells({ strings: this.strings, formulas: this.formulas }));
|
|
70
|
+
}
|
|
71
|
+
/** The sheet of that id; throws a sentence naming the ids there are. */
|
|
72
|
+
sheet(id) {
|
|
73
|
+
const sheet = this.sheets.find((s) => s.id === id);
|
|
74
|
+
if (sheet === undefined) {
|
|
75
|
+
throw new Error(`No sheet '${id}'; the workbook has ${this.sheets.map((s) => s.id).join(', ') || 'none'}.`);
|
|
76
|
+
}
|
|
77
|
+
return sheet;
|
|
78
|
+
}
|
|
79
|
+
hasSheet(id) {
|
|
80
|
+
return this.sheets.some((s) => s.id === id);
|
|
81
|
+
}
|
|
82
|
+
/** The sheet of that name, case-insensitively, as Excel matches names. */
|
|
83
|
+
sheetByName(name) {
|
|
84
|
+
const lower = name.toLowerCase();
|
|
85
|
+
return this.sheets.find((s) => s.name.toLowerCase() === lower);
|
|
86
|
+
}
|
|
87
|
+
/** A name no sheet has: `Sheet1`, `Sheet2`, … */
|
|
88
|
+
freshSheetName() {
|
|
89
|
+
for (let i = 1;; i += 1)
|
|
90
|
+
if (this.sheetByName(`Sheet${i}`) === undefined)
|
|
91
|
+
return `Sheet${i}`;
|
|
92
|
+
}
|
|
93
|
+
#freshSheetId() {
|
|
94
|
+
for (;;) {
|
|
95
|
+
const id = `s${this.#nextSheet++}`;
|
|
96
|
+
if (!this.hasSheet(id))
|
|
97
|
+
return id;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=workbook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workbook.js","sourceRoot":"","sources":["../../src/core/workbook.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAa,YAAY,EAAE,MAAM,WAAW,CAAC;AAUpD,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,MAAM;IACZ,SAAS,EAAE,EAAE;IACb,QAAQ,EAAE,GAAG;CACd,CAAC;AAOF,MAAM,OAAO,KAAK;IACP,EAAE,CAAS;IACpB,IAAI,CAAS;IACJ,IAAI,CAAO;IACX,IAAI,CAAO;IACX,KAAK,CAAa;IAC3B,8BAA8B;IAC9B,MAAM,GAAW,EAAE,CAAC;IACpB,MAAM,GAAW,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAEtC,YAAY,EAAU,EAAE,IAAY,EAAE,MAAc,EAAE,KAAiB;QACrE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,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AG,IAAI,CAAC,WAAW,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC;IACjE,CAAC;IAED,iDAAiD;IACjD,cAAc;QACZ,KAAK,IAAI,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;YAAE,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,SAAS;gBAAE,OAAO,QAAQ,CAAC,EAAE,CAAC;IAChG,CAAC;IAED,aAAa;QACX,SAAS,CAAC;YACR,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAAE,OAAO,EAAE,CAAC;QACpC,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Positions, zones and A1 notation. Rows and columns are 0-based in memory;
|
|
3
|
+
* A1 is 1-based for rows and lettered for columns.
|
|
4
|
+
*
|
|
5
|
+
* @module core/zone
|
|
6
|
+
*/
|
|
7
|
+
/** A cell position: row and column, 0-based. */
|
|
8
|
+
export interface Position {
|
|
9
|
+
readonly row: number;
|
|
10
|
+
readonly col: number;
|
|
11
|
+
}
|
|
12
|
+
/** A rectangle of cells, inclusive on both ends, 0-based. */
|
|
13
|
+
export interface Zone {
|
|
14
|
+
readonly top: number;
|
|
15
|
+
readonly left: number;
|
|
16
|
+
readonly bottom: number;
|
|
17
|
+
readonly right: number;
|
|
18
|
+
}
|
|
19
|
+
/** A position on a named sheet. */
|
|
20
|
+
export interface CellAddress extends Position {
|
|
21
|
+
readonly sheet: string;
|
|
22
|
+
}
|
|
23
|
+
/** Column letters of a 0-based index: 0 → A, 25 → Z, 26 → AA. */
|
|
24
|
+
export declare function columnLetters(col: number): string;
|
|
25
|
+
/** The 0-based index of column letters: A → 0, AA → 26. Case-insensitive. */
|
|
26
|
+
export declare function columnIndex(letters: string): number;
|
|
27
|
+
/** `B3` for {row: 2, col: 1}. */
|
|
28
|
+
export declare function toA1(p: Position): string;
|
|
29
|
+
/** The position of `B3` (anchors ignored). Throws on anything else. */
|
|
30
|
+
export declare function parseA1(text: string): Position;
|
|
31
|
+
/** The zone of `A1:C4`, `B3` (one cell), in any corner order. */
|
|
32
|
+
export declare function parseZone(text: string): Zone;
|
|
33
|
+
/** `A1:C4`, or `B3` for a single cell. */
|
|
34
|
+
export declare function zoneToA1(z: Zone): string;
|
|
35
|
+
/** The smallest zone holding both positions. */
|
|
36
|
+
export declare function zoneOf(a: Position, b?: Position): Zone;
|
|
37
|
+
export declare function zoneContains(z: Zone, p: Position): boolean;
|
|
38
|
+
export declare function zonesOverlap(a: Zone, b: Zone): boolean;
|
|
39
|
+
export declare function zoneSize(z: Zone): {
|
|
40
|
+
rows: number;
|
|
41
|
+
cols: number;
|
|
42
|
+
};
|
|
43
|
+
/** A reference that may name a sheet: `Sheet2!B3`, `'My sheet'!A1:B2`. */
|
|
44
|
+
export declare function splitSheet(ref: string): {
|
|
45
|
+
sheet?: string;
|
|
46
|
+
ref: string;
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=zone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.d.ts","sourceRoot":"","sources":["../../src/core/zone.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AAEH,gDAAgD;AAChD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,6DAA6D;AAC7D,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC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@@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2026 Datalayer, Inc.
|
|
3
|
+
*
|
|
4
|
+
* MIT License
|
|
5
|
+
*/
|
|
6
|
+
/** Column letters of a 0-based index: 0 → A, 25 → Z, 26 → AA. */
|
|
7
|
+
export function columnLetters(col) {
|
|
8
|
+
if (!Number.isInteger(col) || col < 0)
|
|
9
|
+
throw new Error(`No column at index ${col}.`);
|
|
10
|
+
let name = '';
|
|
11
|
+
let n = col + 1;
|
|
12
|
+
while (n > 0) {
|
|
13
|
+
const rest = (n - 1) % 26;
|
|
14
|
+
name = String.fromCharCode(65 + rest) + name;
|
|
15
|
+
n = Math.floor((n - 1) / 26);
|
|
16
|
+
}
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
/** The 0-based index of column letters: A → 0, AA → 26. Case-insensitive. */
|
|
20
|
+
export function columnIndex(letters) {
|
|
21
|
+
if (!/^[A-Za-z]{1,3}$/.test(letters))
|
|
22
|
+
throw new Error(`'${letters}' is not a column (A to XFD).`);
|
|
23
|
+
let n = 0;
|
|
24
|
+
for (const ch of letters.toUpperCase())
|
|
25
|
+
n = n * 26 + (ch.charCodeAt(0) - 64);
|
|
26
|
+
return n - 1;
|
|
27
|
+
}
|
|
28
|
+
/** `B3` for {row: 2, col: 1}. */
|
|
29
|
+
export function toA1(p) {
|
|
30
|
+
return `${columnLetters(p.col)}${p.row + 1}`;
|
|
31
|
+
}
|
|
32
|
+
const CELL = /^\$?([A-Za-z]{1,3})\$?([1-9][0-9]{0,6})$/;
|
|
33
|
+
/** The position of `B3` (anchors ignored). Throws on anything else. */
|
|
34
|
+
export function parseA1(text) {
|
|
35
|
+
const m = CELL.exec(text.trim());
|
|
36
|
+
if (!m)
|
|
37
|
+
throw new Error(`'${text}' is not a cell reference such as B3.`);
|
|
38
|
+
return { row: Number(m[2]) - 1, col: columnIndex(m[1]) };
|
|
39
|
+
}
|
|
40
|
+
/** The zone of `A1:C4`, `B3` (one cell), in any corner order. */
|
|
41
|
+
export function parseZone(text) {
|
|
42
|
+
const parts = text.trim().split(':');
|
|
43
|
+
if (parts.length > 2 || parts[0] === '')
|
|
44
|
+
throw new Error(`'${text}' is not a range such as A1:C4.`);
|
|
45
|
+
const a = parseA1(parts[0]);
|
|
46
|
+
const b = parts.length === 2 ? parseA1(parts[1]) : a;
|
|
47
|
+
return zoneOf(a, b);
|
|
48
|
+
}
|
|
49
|
+
/** `A1:C4`, or `B3` for a single cell. */
|
|
50
|
+
export function zoneToA1(z) {
|
|
51
|
+
const tl = toA1({ row: z.top, col: z.left });
|
|
52
|
+
return z.top === z.bottom && z.left === z.right
|
|
53
|
+
? tl
|
|
54
|
+
: `${tl}:${toA1({ row: z.bottom, col: z.right })}`;
|
|
55
|
+
}
|
|
56
|
+
/** The smallest zone holding both positions. */
|
|
57
|
+
export function zoneOf(a, b = a) {
|
|
58
|
+
return {
|
|
59
|
+
top: Math.min(a.row, b.row),
|
|
60
|
+
left: Math.min(a.col, b.col),
|
|
61
|
+
bottom: Math.max(a.row, b.row),
|
|
62
|
+
right: Math.max(a.col, b.col),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export function zoneContains(z, p) {
|
|
66
|
+
return p.row >= z.top && p.row <= z.bottom && p.col >= z.left && p.col <= z.right;
|
|
67
|
+
}
|
|
68
|
+
export function zonesOverlap(a, b) {
|
|
69
|
+
return a.left <= b.right && b.left <= a.right && a.top <= b.bottom && b.top <= a.bottom;
|
|
70
|
+
}
|
|
71
|
+
export function zoneSize(z) {
|
|
72
|
+
return { rows: z.bottom - z.top + 1, cols: z.right - z.left + 1 };
|
|
73
|
+
}
|
|
74
|
+
/** A reference that may name a sheet: `Sheet2!B3`, `'My sheet'!A1:B2`. */
|
|
75
|
+
export function splitSheet(ref) {
|
|
76
|
+
const bang = ref.lastIndexOf('!');
|
|
77
|
+
if (bang < 0)
|
|
78
|
+
return { ref };
|
|
79
|
+
let sheet = ref.slice(0, bang);
|
|
80
|
+
if (sheet.startsWith("'")) {
|
|
81
|
+
if (!sheet.endsWith("'") || sheet.length < 2)
|
|
82
|
+
throw new Error(`'${ref}' has an unclosed sheet name.`);
|
|
83
|
+
sheet = sheet.slice(1, -1).replace(/''/g, "'");
|
|
84
|
+
}
|
|
85
|
+
if (sheet === '')
|
|
86
|
+
throw new Error(`'${ref}' names an empty sheet.`);
|
|
87
|
+
return { sheet, ref: ref.slice(bang + 1) };
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=zone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zone.js","sourceRoot":"","sources":["../../src/core/zone.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA4BH,iEAAiE;AACjE,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,GAAG,GAAG,CAAC,CAAC;IACrF,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;QAC1B,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;QAC7C,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,IAAI,OAAO,+BAA+B,CAAC,CAAC;IAClG,IAAI,C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