@pixerate/editor 0.24.0 → 0.26.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.
Files changed (162) hide show
  1. package/README.md +101 -1
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/dist/agent/index.cjs +175 -11
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +18 -4
  6. package/dist/agent/index.d.ts +18 -4
  7. package/dist/agent/index.js +168 -4
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/{arrangeShortcuts-B8O3f8-P.d.cts → arrange-BICutYPk.d.cts} +243 -29
  10. package/dist/{arrangeShortcuts-sLlD2rSX.d.ts → arrange-BICutYPk.d.ts} +243 -29
  11. package/dist/builtins-CdPcLwwF.d.cts +176 -0
  12. package/dist/builtins-Chj6zv_O.d.ts +176 -0
  13. package/dist/canvas/index.cjs +8588 -1857
  14. package/dist/canvas/index.cjs.map +1 -1
  15. package/dist/canvas/index.d.cts +1847 -9
  16. package/dist/canvas/index.d.ts +1847 -9
  17. package/dist/canvas/index.js +8577 -1846
  18. package/dist/canvas/index.js.map +1 -1
  19. package/dist/chunk-3CC7OPUQ.cjs +831 -0
  20. package/dist/chunk-3CC7OPUQ.cjs.map +1 -0
  21. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  22. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  23. package/dist/chunk-BVP3TSLH.cjs +69 -0
  24. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  25. package/dist/{chunk-OLZJXL4R.cjs → chunk-CS6NZWWA.cjs} +59 -25
  26. package/dist/chunk-CS6NZWWA.cjs.map +1 -0
  27. package/dist/{chunk-MCSJFWAO.cjs → chunk-EWCOFSCQ.cjs} +685 -100
  28. package/dist/chunk-EWCOFSCQ.cjs.map +1 -0
  29. package/dist/chunk-HDYMLS3X.cjs +409 -0
  30. package/dist/chunk-HDYMLS3X.cjs.map +1 -0
  31. package/dist/chunk-HRMEDT2L.js +1406 -0
  32. package/dist/chunk-HRMEDT2L.js.map +1 -0
  33. package/dist/{chunk-D27YFC46.cjs → chunk-IFHKKVXH.cjs} +382 -63
  34. package/dist/chunk-IFHKKVXH.cjs.map +1 -0
  35. package/dist/{chunk-PGNZKFQS.js → chunk-JOIREKL7.js} +137 -58
  36. package/dist/chunk-JOIREKL7.js.map +1 -0
  37. package/dist/chunk-KRGXUQ2Y.js +1696 -0
  38. package/dist/chunk-KRGXUQ2Y.js.map +1 -0
  39. package/dist/{chunk-3LV6RRPH.js → chunk-MHEPLBFB.js} +2 -2
  40. package/dist/chunk-MR2764X2.js +831 -0
  41. package/dist/chunk-MR2764X2.js.map +1 -0
  42. package/dist/{chunk-XNORY7M6.cjs → chunk-NFVBT3UZ.cjs} +166 -87
  43. package/dist/chunk-NFVBT3UZ.cjs.map +1 -0
  44. package/dist/chunk-NQF32I6Z.cjs +6478 -0
  45. package/dist/chunk-NQF32I6Z.cjs.map +1 -0
  46. package/dist/chunk-O5RYH2PG.js +69 -0
  47. package/dist/chunk-O5RYH2PG.js.map +1 -0
  48. package/dist/{chunk-ITBSKI26.js → chunk-Q2OHWD2A.js} +1064 -360
  49. package/dist/chunk-Q2OHWD2A.js.map +1 -0
  50. package/dist/{chunk-FODNLX5N.js → chunk-QJSOZFCZ.js} +38 -4
  51. package/dist/chunk-QJSOZFCZ.js.map +1 -0
  52. package/dist/{chunk-SML64VJG.cjs → chunk-RRREAOVM.cjs} +4 -4
  53. package/dist/{chunk-SML64VJG.cjs.map → chunk-RRREAOVM.cjs.map} +1 -1
  54. package/dist/{chunk-5S3Z4PPF.js → chunk-SWE3NPOU.js} +347 -28
  55. package/dist/chunk-SWE3NPOU.js.map +1 -0
  56. package/dist/chunk-TXXNBDQX.cjs +1696 -0
  57. package/dist/chunk-TXXNBDQX.cjs.map +1 -0
  58. package/dist/chunk-UBCFIABU.js +409 -0
  59. package/dist/chunk-UBCFIABU.js.map +1 -0
  60. package/dist/chunk-X7HXL2SB.js +6478 -0
  61. package/dist/chunk-X7HXL2SB.js.map +1 -0
  62. package/dist/{chunk-SBCZ6RN5.cjs → chunk-YOMYSFJU.cjs} +1163 -459
  63. package/dist/chunk-YOMYSFJU.cjs.map +1 -0
  64. package/dist/{chunk-3CN2WD3X.js → chunk-ZRNHGAQT.js} +661 -76
  65. package/dist/chunk-ZRNHGAQT.js.map +1 -0
  66. package/dist/commands/index.cjs +425 -4
  67. package/dist/commands/index.cjs.map +1 -1
  68. package/dist/commands/index.d.cts +39 -77
  69. package/dist/commands/index.d.ts +39 -77
  70. package/dist/commands/index.js +424 -3
  71. package/dist/commands/index.js.map +1 -1
  72. package/dist/compare/index.cjs +3 -3
  73. package/dist/compare/index.d.cts +1 -1
  74. package/dist/compare/index.d.ts +1 -1
  75. package/dist/compare/index.js +2 -2
  76. package/dist/controller-CxXGOEmy.d.cts +2038 -0
  77. package/dist/controller-CxXGOEmy.d.ts +2038 -0
  78. package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
  79. package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
  80. package/dist/export/index.cjs +36 -0
  81. package/dist/export/index.cjs.map +1 -0
  82. package/dist/export/index.d.cts +243 -0
  83. package/dist/export/index.d.ts +243 -0
  84. package/dist/export/index.js +36 -0
  85. package/dist/export/index.js.map +1 -0
  86. package/dist/extensions/index.cjs +101 -6
  87. package/dist/extensions/index.cjs.map +1 -1
  88. package/dist/extensions/index.d.cts +18 -5
  89. package/dist/extensions/index.d.ts +18 -5
  90. package/dist/extensions/index.js +101 -6
  91. package/dist/generation/index.cjs +1013 -69
  92. package/dist/generation/index.cjs.map +1 -1
  93. package/dist/generation/index.d.cts +474 -13
  94. package/dist/generation/index.d.ts +474 -13
  95. package/dist/generation/index.js +976 -32
  96. package/dist/generation/index.js.map +1 -1
  97. package/dist/image-editor/index.cjs +3385 -1275
  98. package/dist/image-editor/index.cjs.map +1 -1
  99. package/dist/image-editor/index.d.cts +693 -128
  100. package/dist/image-editor/index.d.ts +693 -128
  101. package/dist/image-editor/index.js +3325 -1215
  102. package/dist/image-editor/index.js.map +1 -1
  103. package/dist/{index-fJrlkJCd.d.ts → index-B273Zllk.d.ts} +500 -7
  104. package/dist/{index-BhJBSm2d.d.cts → index-jcJwmBYt.d.cts} +500 -7
  105. package/dist/index.cjs +1603 -45
  106. package/dist/index.cjs.map +1 -1
  107. package/dist/index.d.cts +154 -27
  108. package/dist/index.d.ts +154 -27
  109. package/dist/index.js +1584 -26
  110. package/dist/index.js.map +1 -1
  111. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  112. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  113. package/dist/model-C1zApQM8.d.cts +219 -0
  114. package/dist/model-C1zApQM8.d.ts +219 -0
  115. package/dist/persistence/index.d.cts +3 -120
  116. package/dist/persistence/index.d.ts +3 -120
  117. package/dist/registry-CED5C0lA.d.cts +204 -0
  118. package/dist/registry-CED5C0lA.d.ts +204 -0
  119. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
  120. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
  121. package/dist/{registry-D32LpIc4.d.cts → registry-D0GADKc7.d.cts} +1 -1
  122. package/dist/{registry-evKTP4ls.d.ts → registry-DhVUZioj.d.ts} +1 -1
  123. package/dist/serializers/index.cjs +12 -4
  124. package/dist/serializers/index.cjs.map +1 -1
  125. package/dist/serializers/index.d.cts +41 -13
  126. package/dist/serializers/index.d.ts +41 -13
  127. package/dist/serializers/index.js +12 -4
  128. package/dist/spreadsheet/index.cjs +157 -3
  129. package/dist/spreadsheet/index.cjs.map +1 -1
  130. package/dist/spreadsheet/index.d.cts +534 -11
  131. package/dist/spreadsheet/index.d.ts +534 -11
  132. package/dist/spreadsheet/index.js +157 -3
  133. package/dist/storage-BpFfspHm.d.cts +120 -0
  134. package/dist/storage-BpFfspHm.d.ts +120 -0
  135. package/dist/tokens/index.cjs +115 -0
  136. package/dist/tokens/index.cjs.map +1 -0
  137. package/dist/tokens/index.d.cts +212 -0
  138. package/dist/tokens/index.d.ts +212 -0
  139. package/dist/tokens/index.js +115 -0
  140. package/dist/tokens/index.js.map +1 -0
  141. package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
  142. package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
  143. package/package.json +15 -1
  144. package/dist/chunk-3CN2WD3X.js.map +0 -1
  145. package/dist/chunk-5S3Z4PPF.js.map +0 -1
  146. package/dist/chunk-D27YFC46.cjs.map +0 -1
  147. package/dist/chunk-FODNLX5N.js.map +0 -1
  148. package/dist/chunk-ITBSKI26.js.map +0 -1
  149. package/dist/chunk-MA2F5KHF.cjs +0 -3223
  150. package/dist/chunk-MA2F5KHF.cjs.map +0 -1
  151. package/dist/chunk-MCSJFWAO.cjs.map +0 -1
  152. package/dist/chunk-OLZJXL4R.cjs.map +0 -1
  153. package/dist/chunk-PGNZKFQS.js.map +0 -1
  154. package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
  155. package/dist/chunk-U5KWZU4X.js +0 -3223
  156. package/dist/chunk-U5KWZU4X.js.map +0 -1
  157. package/dist/chunk-XNORY7M6.cjs.map +0 -1
  158. package/dist/controller-BhLLAoi8.d.cts +0 -1000
  159. package/dist/controller-BhLLAoi8.d.ts +0 -1000
  160. package/dist/types-DX4Mh4SL.d.cts +0 -217
  161. package/dist/types-DX4Mh4SL.d.ts +0 -217
  162. /package/dist/{chunk-3LV6RRPH.js.map → chunk-MHEPLBFB.js.map} +0 -0
@@ -1,1000 +0,0 @@
1
- type CellFormat = 'text' | 'number' | 'currency' | 'percentage' | 'date' | 'badge' | 'status' | 'assignee';
2
- type ColumnType = 'bound' | 'freeform' | 'formula';
3
- interface ColumnBinding {
4
- dataSource: string;
5
- field: string;
6
- }
7
- interface SpreadsheetColumn {
8
- id: string;
9
- key: string;
10
- title: string;
11
- width?: number;
12
- type: ColumnType;
13
- binding?: ColumnBinding;
14
- formula?: string;
15
- format?: CellFormat;
16
- /**
17
- * Number format code for the column's cells (e.g. `#,##0.00`,
18
- * `"$"#,##0.00;[Red]("$"#,##0.00)`, `m/d/yyyy`). Cells without an explicit
19
- * code of their own use it instead of the automatic one chosen for typed
20
- * input. See `SpreadsheetController.setColumnNumberFormat`.
21
- */
22
- numberFormat?: string;
23
- readOnly?: boolean;
24
- hidden?: boolean;
25
- }
26
- type RowType = 'record' | 'freeform';
27
- interface SpreadsheetRow {
28
- id: string;
29
- index: number;
30
- height?: number;
31
- recordId?: string;
32
- type: RowType;
33
- hidden?: boolean;
34
- }
35
- interface CellCoordinate {
36
- row: number;
37
- col: number;
38
- rowId?: string;
39
- colId?: string;
40
- }
41
- interface CellRange {
42
- startRow: number;
43
- startCol: number;
44
- endRow: number;
45
- endCol: number;
46
- }
47
- interface CellData {
48
- raw: string;
49
- /**
50
- * Evaluated value. Typed (non-formula) input is parsed: `"120"` → 120,
51
- * `"TRUE"` → true, `"3/4/2026"` → `"2026-03-04"` (dates are ISO text),
52
- * `"10:30"` → 0.4375 (a time alone is a fraction of a day); `'120` forces
53
- * the text `"120"`. Formulas store their result.
54
- */
55
- value: any;
56
- error?: string;
57
- /** Why the formula failed, e.g. `Argument 2 of SUMIF must be a range.` Set alongside `error`. */
58
- errorMessage?: string;
59
- format?: CellFormat;
60
- /**
61
- * Excel number format code used to display the value (see
62
- * `formatCellDisplay`). Set explicitly (`explicitNumberFormat`), inherited
63
- * from the column's `numberFormat`, or chosen automatically for typed input,
64
- * e.g. `"$"#,##0.00` for `$1,200.50`, `0%` for `10%`, `#,##0` for `1,234`,
65
- * `m/d/yyyy` for `3/4/2026`, `h:mm` for `10:30`. Absent for General.
66
- */
67
- numberFormat?: string;
68
- /**
69
- * True when `numberFormat` was set explicitly (`setCellNumberFormat`):
70
- * typing into the cell keeps it instead of choosing an automatic format.
71
- */
72
- explicitNumberFormat?: boolean;
73
- readOnly?: boolean;
74
- /**
75
- * Set (only) on cells showing a value spilled from a dynamic array: the
76
- * anchor cell holding the formula, e.g. `A1`. Spilled cells keep an empty
77
- * `raw` and are never stored in the document.
78
- */
79
- spillAnchor?: string;
80
- }
81
- /** A dynamic array spilled from its anchor cell (the cell holding the formula). */
82
- interface SpreadsheetSpill {
83
- /** Anchor cell key, e.g. `A1`. */
84
- key: string;
85
- anchor: {
86
- row: number;
87
- col: number;
88
- };
89
- /** Every cell the array covers, anchor included. */
90
- range: CellRange;
91
- /** The anchor's formula. */
92
- formula: string;
93
- }
94
- interface SpreadsheetDocument {
95
- id: string;
96
- name: string;
97
- columns: SpreadsheetColumn[];
98
- rows: SpreadsheetRow[];
99
- cells: Record<string, Record<string, CellData>>;
100
- createdAt?: number;
101
- updatedAt?: number;
102
- table?: SpreadsheetTableSettings;
103
- }
104
- type SortDirection = 'asc' | 'desc';
105
- interface SortKey {
106
- colId: string;
107
- direction?: SortDirection;
108
- }
109
- type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'greaterThan' | 'greaterThanOrEqual' | 'lessThan' | 'lessThanOrEqual' | 'between' | 'isBlank' | 'isNotBlank' | 'oneOf';
110
- interface FilterRule {
111
- id: string;
112
- colId: string;
113
- operator: FilterOperator;
114
- value?: string | number;
115
- value2?: string | number;
116
- values?: string[];
117
- }
118
- interface SpreadsheetFilterState {
119
- enabled: boolean;
120
- rules: FilterRule[];
121
- }
122
- type GroupAggregate = 'sum' | 'count' | 'average' | 'min' | 'max';
123
- interface GroupSummary {
124
- colId: string;
125
- aggregate: GroupAggregate;
126
- }
127
- interface SpreadsheetGrouping {
128
- colId: string;
129
- summaries: GroupSummary[];
130
- collapsed: string[];
131
- }
132
- interface SpreadsheetTableSettings {
133
- headerRowCount?: number;
134
- footerRowCount?: number;
135
- headerColumnCount?: number;
136
- frozenRowCount?: number;
137
- frozenColumnCount?: number;
138
- merges?: CellRange[];
139
- filter?: SpreadsheetFilterState;
140
- grouping?: SpreadsheetGrouping;
141
- }
142
- interface SpreadsheetDataSourceField {
143
- key: string;
144
- label: string;
145
- type: 'string' | 'number' | 'date' | 'boolean' | 'enum';
146
- options?: Array<{
147
- key: string;
148
- label: string;
149
- color?: string;
150
- }>;
151
- }
152
- interface SpreadsheetDataSource {
153
- id: string;
154
- name: string;
155
- getRecords(): Array<{
156
- id: string;
157
- [key: string]: any;
158
- }>;
159
- getFields(): SpreadsheetDataSourceField[];
160
- updateRecord(recordId: string, field: string, value: any): Promise<void> | void;
161
- }
162
-
163
- type FormulaTokenType = 'NUMBER' | 'STRING' | 'BOOLEAN' | 'ERROR' | 'CELL_REF' | 'RANGE' | 'SPILL_REF' | 'PROPERTY_REF' | 'IDENTIFIER' | 'OPERATOR' | 'LPAREN' | 'RPAREN' | 'COMMA' | 'EOF';
164
- interface FormulaToken {
165
- type: FormulaTokenType;
166
- value: string;
167
- position: number;
168
- }
169
- declare function tokenizeFormula(formula: string): FormulaToken[];
170
-
171
- /** Row number used for the open end of whole-column ranges such as `A:A`. */
172
- declare const WHOLE_COLUMN_END_ROW = 1048576;
173
- type ASTNode = LiteralNode | CellRefNode | RangeNode | SpillRefNode | NameNode | PropertyRefNode | BinaryOpNode | UnaryOpNode | FunctionCallNode;
174
- interface LiteralNode {
175
- type: 'Literal';
176
- value: number | string | boolean;
177
- }
178
- interface CellRefNode {
179
- type: 'CellRef';
180
- ref: string;
181
- col: string;
182
- row: number;
183
- }
184
- interface RangeNode {
185
- type: 'Range';
186
- raw: string;
187
- startCol: string;
188
- startRow: number;
189
- endCol: string;
190
- endRow: number;
191
- }
192
- /** `A1#`: the whole spill range of the dynamic array anchored at A1. */
193
- interface SpillRefNode {
194
- type: 'SpillRef';
195
- /** Anchor cell, e.g. `A1`. */
196
- ref: string;
197
- col: string;
198
- row: number;
199
- }
200
- /** A bare name: a LET variable, or `#NAME?` when nothing defines it. */
201
- interface NameNode {
202
- type: 'Name';
203
- name: string;
204
- }
205
- interface PropertyRefNode {
206
- type: 'PropertyRef';
207
- property: string;
208
- }
209
- interface BinaryOpNode {
210
- type: 'BinaryOp';
211
- op: string;
212
- left: ASTNode;
213
- right: ASTNode;
214
- }
215
- interface UnaryOpNode {
216
- type: 'UnaryOp';
217
- op: string;
218
- argument: ASTNode;
219
- }
220
- interface FunctionCallNode {
221
- type: 'FunctionCall';
222
- name: string;
223
- args: ASTNode[];
224
- }
225
- declare function parseCellReference(ref: string): {
226
- col: string;
227
- row: number;
228
- };
229
- declare function parseRange(rangeStr: string): RangeNode;
230
- declare class FormulaParser {
231
- private tokens;
232
- private current;
233
- constructor(tokens: FormulaToken[]);
234
- parse(): ASTNode;
235
- private expression;
236
- private comparison;
237
- private concatenation;
238
- private addition;
239
- private multiplication;
240
- private exponentiation;
241
- private unary;
242
- private primary;
243
- private match;
244
- private matchOperator;
245
- private check;
246
- private advance;
247
- private isAtEnd;
248
- private peek;
249
- private previous;
250
- private consume;
251
- }
252
- declare function parseFormula(formula: string): ASTNode;
253
-
254
- /** Spreadsheet error values. They propagate through operators and functions. */
255
- declare const FORMULA_ERRORS: Set<string>;
256
- type FormulaErrorCode = '#DIV/0!' | '#VALUE!' | '#REF!' | '#NAME?' | '#N/A' | '#NUM!' | '#CYCLE!' | '#ERROR!' | '#SPILL!' | '#CALC!';
257
- declare function isFormulaError(value: unknown): value is string;
258
- /**
259
- * Number to text as Excel converts it in `&` and General display: up to 15
260
- * significant digits, scientific for very large or very small magnitudes.
261
- */
262
- declare function numberToText(n: number): string;
263
- /**
264
- * Compares numbers the way Excel does: both are rounded to 15 significant
265
- * digits first, so binary noise such as `0.1+0.2` versus `0.3` counts as equal.
266
- */
267
- declare function compareNumbers(a: number, b: number): number;
268
- /**
269
- * Excel's comparison for the `=`, `<>`, `<`… operators: numbers < text <
270
- * booleans < errors, numbers compared at 15 significant digits, text
271
- * case-insensitively. A blank acts as 0, "" or FALSE depending on the other
272
- * side. Dates are ISO text: two ISO dates compare chronologically
273
- * ("2026-1-5" is before "2026-01-10"), and an ISO date against a number
274
- * compares as its serial number.
275
- */
276
- declare function compareValues(left: unknown, right: unknown): number;
277
- /**
278
- * Sort order (ascending): numbers, text, booleans, errors, then blanks last.
279
- * Errors are equal to each other, so sorting keeps their order.
280
- */
281
- declare function sortCompareValues(left: unknown, right: unknown): number;
282
- declare function colNameToIndex(col: string): number;
283
- declare function indexToColName(index: number): string;
284
- /**
285
- * A rectangular block of values. `values` is column-major (the order in which
286
- * `EvaluationContext.resolveRange` returns cells): `values[col * rows + row]`.
287
- */
288
- interface FormulaRange {
289
- rows: number;
290
- cols: number;
291
- values: any[];
292
- }
293
-
294
- interface EvaluationContext {
295
- resolveCell?: (col: string, row: number) => any;
296
- /**
297
- * Values of a rectangular range, column by column (all rows of the first
298
- * column, then the next column). Lookup functions rely on this order.
299
- */
300
- resolveRange?: (startCol: string, startRow: number, endCol: string, endRow: number) => any[];
301
- resolveProperty?: (property: string) => any;
302
- /**
303
- * The spilled array anchored at a cell, for `A1#` references: its shape and
304
- * values (column-major, like `resolveRange`), or an error code (e.g.
305
- * `#REF!` when the cell holds no array).
306
- */
307
- resolveSpill?: (col: string, row: number) => FormulaRange | string;
308
- /**
309
- * The cell holding the formula being evaluated, used by the implicit
310
- * intersection operator (`=@A:A` reads the cell in the formula's row).
311
- */
312
- getFormulaCell?: () => {
313
- col: string;
314
- row: number;
315
- } | null;
316
- }
317
- /** A human-readable reason for an error value. */
318
- interface FormulaDiagnostic {
319
- code: FormulaErrorCode;
320
- message: string;
321
- }
322
- interface FormulaEvaluationResult {
323
- /** The computed value; an error code such as `#VALUE!` when the formula fails. */
324
- value: any;
325
- /** The error code when `value` is an error. */
326
- error?: FormulaErrorCode;
327
- /** Why the formula failed, e.g. `Argument 2 of SUMIF must be a range.` */
328
- message?: string;
329
- /**
330
- * Set when the formula returned an array of more than one value (a
331
- * dynamic array). `value` is then its top-left value; a spreadsheet spills
332
- * the whole array into the cells below and to the right.
333
- */
334
- array?: FormulaRange;
335
- }
336
- /** Generic explanation of an error code, used when no specific reason was recorded. */
337
- declare function describeFormulaError(code: string): string;
338
- /** Largest array a formula may build (SEQUENCE, RANDARRAY, broadcasting). */
339
- declare const MAX_FORMULA_ARRAY_SIZE = 1000000;
340
- declare class FormulaEvaluator {
341
- private context;
342
- private diagnostics;
343
- private scopes;
344
- constructor(context?: EvaluationContext);
345
- /**
346
- * Evaluates a formula. Errors in the formula are returned as error values
347
- * (`#VALUE!` etc.); malformed formulas and missing resolvers throw.
348
- */
349
- evaluate(astOrFormula: ASTNode | string): any;
350
- /**
351
- * Evaluates a formula and explains errors. Never throws: malformed formulas
352
- * return `#ERROR!` with the parser's message. A result with several values
353
- * (a range or a dynamic array) is returned in `array`, with its top-left
354
- * value as `value`; a one-value array is just that value.
355
- */
356
- evaluateWithDiagnostics(astOrFormula: ASTNode | string): FormulaEvaluationResult;
357
- /** Records why an error happened and returns the error code. */
358
- private fail;
359
- private evaluateNode;
360
- private unary;
361
- /** A binary operator on two single values. */
362
- private binary;
363
- /**
364
- * Dates are ISO text: date +/- days is a date, date - date is a number of
365
- * days (fractional when times are involved).
366
- */
367
- private dateArithmetic;
368
- /**
369
- * `@` (implicit intersection): a range reference reads the cell in the
370
- * formula's row (one column) or column (one row); arrays give their
371
- * top-left value.
372
- */
373
- private implicitIntersection;
374
- private evaluateSpillRef;
375
- private evaluateRange;
376
- private callFunction;
377
- private finishCall;
378
- private lazyArguments;
379
- /**
380
- * Applies a scalar function element by element when it receives arrays
381
- * (`=LEN(A1:A3)`, `=IF(A1:A3>1, "y", "n")`). Arguments typed `range` are
382
- * passed whole. Returns undefined when no trigger argument is a
383
- * multi-value array.
384
- */
385
- private liftOverArrays;
386
- /** LET(name1, value1, [name2, value2, ...], calculation). */
387
- private evaluateLet;
388
- private createContext;
389
- }
390
-
391
- interface CellDep {
392
- col: string;
393
- row: number;
394
- }
395
- /**
396
- * Dependency key for "every cell in column `col`", used by whole-column ranges
397
- * (`A:A`) instead of expanding a million cell keys.
398
- */
399
- declare const columnDependencyKey: (col: string) => string;
400
- declare function extractCellDependencies(node: ASTNode): CellDep[];
401
- declare class DependencyGraph {
402
- private dependencies;
403
- private dependents;
404
- private spillDependencies;
405
- private spillDependents;
406
- private spillEdges;
407
- setCellFormula(cellKey: string, formulaStr: string | null): void;
408
- /** Removes every registered formula and dependency. */
409
- clear(): void;
410
- /**
411
- * Records the dynamic-array edges of the anchor `anchorKey`, replacing its
412
- * previous ones: every key in `spilledKeys` (cells holding its spilled
413
- * values) depends on the anchor, and the anchor depends on every key in
414
- * `blockingKeys` (cells that stop it spilling). Pass empty lists to remove
415
- * the anchor's edges.
416
- */
417
- setSpillEdges(anchorKey: string, spilledKeys: Iterable<string>, blockingKeys?: Iterable<string>): void;
418
- /** The spilled cells registered for `anchorKey` by `setSpillEdges`. */
419
- getSpilledKeys(anchorKey: string): string[];
420
- /** Formula dependencies plus dynamic-array (spill) dependencies of a cell. */
421
- getDependencies(cellKey: string): string[];
422
- /** Cells depending on `cellKey`, through formulas or spills. */
423
- getDependents(cellKey: string): string[];
424
- /**
425
- * Detects if there is a cycle containing cellKey.
426
- */
427
- hasCycle(cellKey: string): boolean;
428
- /**
429
- * Returns cells affected by updating cellKey in topological order.
430
- */
431
- getEvaluationOrder(startCellKey: string): {
432
- order: string[];
433
- hasCycle: boolean;
434
- };
435
- /**
436
- * Plans a recalculation over `cellKeys` (and, with `includeDependents`, every
437
- * cell that transitively depends on them). Returns the keys in evaluation
438
- * order (dependencies first) and the set of keys that are part of a cycle,
439
- * which must be marked `#CYCLE!` instead of evaluated. Every member of a
440
- * cycle is reported, not just the cell that closed it.
441
- */
442
- getEvaluationPlan(cellKeys: Iterable<string>, options?: {
443
- includeDependents?: boolean;
444
- }): {
445
- order: string[];
446
- cyclic: Set<string>;
447
- };
448
- }
449
-
450
- /**
451
- * A row or column insertion/deletion. `index` is the 0-based position of the
452
- * inserted or deleted row/column.
453
- */
454
- interface StructuralChange {
455
- axis: 'row' | 'col';
456
- index: number;
457
- type: 'insert' | 'delete';
458
- }
459
- /**
460
- * Rewrites the cell and range references in `formula` after a row or column
461
- * is inserted or deleted, the way spreadsheet apps do: references after the
462
- * change shift, ranges grow or shrink, and references to a deleted row/column
463
- * become `#REF!`. Absolute (`$`) markers are kept. String literals, property
464
- * references and function names are left untouched.
465
- */
466
- declare function shiftFormulaReferences(formula: string, change: StructuralChange): string;
467
- /**
468
- * Calls `rewrite` with the source text of every cell or range reference in
469
- * `formula` (e.g. `"$A1"`, `"B2:C10"`, `"A:A"`) and splices in its result.
470
- * For a spill reference (`A1#`) it receives the anchor (`"A1"`) and the `#`
471
- * is kept, unless the rewrite returns `#REF!`. String literals, property references and function names (e.g. `LOG10(`)
472
- * are skipped. Formulas that fail to tokenize are returned unchanged.
473
- */
474
- declare function mapFormulaReferences(formula: string, rewrite: (reference: string) => string): string;
475
- /**
476
- * Moves a formula by (`rowOffset`, `colOffset`), as copy/paste and autofill
477
- * do: relative row/column parts shift, `$`-absolute parts stay. A reference
478
- * pushed above row 1 or left of column A becomes `#REF!`.
479
- */
480
- declare function offsetFormulaReferences(formula: string, rowOffset: number, colOffset: number): string;
481
- /** A 0-based cell position. */
482
- interface CellPosition {
483
- row: number;
484
- col: number;
485
- }
486
- /**
487
- * Rewrites references when cells *move* (sort, transpose): references follow
488
- * the cell they point at, whether relative or absolute. `moveCell` returns a
489
- * cell's new position, or null when it did not move. A range is remapped only
490
- * when its cells moved together as a rectangle of the same size (e.g. a
491
- * one-row range inside a sorted row, or a range inside a transposed block);
492
- * otherwise it is kept, since it still covers the same rows and columns.
493
- */
494
- declare function remapFormulaReferences(formula: string, moveCell: (position: CellPosition) => CellPosition | null): string;
495
-
496
- declare class DataSourceBinder {
497
- private dataSources;
498
- register(dataSource: SpreadsheetDataSource): void;
499
- unregister(dataSourceId: string): void;
500
- getDataSource(id: string): SpreadsheetDataSource | undefined;
501
- /**
502
- * Generates or reconciles spreadsheet rows from a primary data source.
503
- */
504
- syncRows(currentRows: SpreadsheetRow[], dataSourceId: string): SpreadsheetRow[];
505
- /**
506
- * Resolves a record's bound field value.
507
- */
508
- resolveBoundValue(dataSourceId: string, recordId: string, field: string): any;
509
- /**
510
- * Dispatches an update to the underlying data source.
511
- */
512
- commitBoundValue(dataSourceId: string, recordId: string, field: string, value: any): Promise<void>;
513
- }
514
-
515
- /**
516
- * Spreadsheet clipboard formats. Copying writes three representations:
517
- *
518
- * - `text/plain`: TSV of the displayed values (pastes into any app)
519
- * - `text/html`: an HTML `<table>` (pastes into docs, mail, other sheets)
520
- * - `application/x.pixerate.spreadsheet+json`: raw inputs and formulas, so a
521
- * paste into a pixerate spreadsheet is lossless; formulas are re-based to
522
- * the paste position like a spreadsheet copy/paste
523
- *
524
- * Pasting prefers the custom format, then an HTML table, then TSV. All
525
- * functions here are pure and DOM-free.
526
- */
527
-
528
- declare const SPREADSHEET_CLIPBOARD_MIME = "application/x.pixerate.spreadsheet+json";
529
- interface SpreadsheetClipboardCell {
530
- raw: string;
531
- value: unknown;
532
- /** Display text for `text/plain` and `text/html` (e.g. `10%` for 0.1); defaults to the value as text. Not stored in the JSON payload. */
533
- text?: string;
534
- }
535
- interface SpreadsheetClipboardPayload {
536
- type: 'pixerate-spreadsheet';
537
- version: 1;
538
- /** Position of the copied block's top-left cell, used to re-base formulas. */
539
- origin: CellPosition;
540
- cells: SpreadsheetClipboardCell[][];
541
- }
542
- /** MIME type -> data, as written to `DataTransfer.setData`. */
543
- type SpreadsheetClipboardData = Record<string, string>;
544
- /** Anything clipboard data can be read from: a `DataTransfer` or a plain record. */
545
- type SpreadsheetClipboardSource = {
546
- getData(format: string): string;
547
- } | Record<string, string | undefined>;
548
- interface ParsedSpreadsheetClipboard {
549
- format: 'internal' | 'html' | 'text';
550
- /** Raw inputs to write, row by row. */
551
- rows: string[][];
552
- /** For internal pastes: where the block was copied from. */
553
- origin?: CellPosition;
554
- }
555
- /** Serializes displayed values as an HTML table. Line breaks become `<br>`. */
556
- declare function serializeHtmlTable(values: ReadonlyArray<ReadonlyArray<unknown>>): string;
557
- /**
558
- * Extracts cell texts from the first `<table>` in `html` (as written by
559
- * spreadsheet apps and browsers). `colspan`/`rowspan` cells are expanded with
560
- * blank cells so positions line up. Returns null when there is no table.
561
- */
562
- declare function parseHtmlTable(html: string): string[][] | null;
563
- /** Builds the three clipboard representations of a copied block. */
564
- declare function createSpreadsheetClipboardData(cells: SpreadsheetClipboardCell[][], origin: CellPosition): SpreadsheetClipboardData;
565
- /**
566
- * Reads clipboard data, preferring the lossless internal format, then an
567
- * HTML table, then TSV text. Returns null when there is nothing to paste.
568
- */
569
- declare function readSpreadsheetClipboard(source: SpreadsheetClipboardSource): ParsedSpreadsheetClipboard | null;
570
- /**
571
- * Moves formulas copied from `origin` so they keep their relative references
572
- * when pasted at `target`. Non-formula inputs are returned unchanged.
573
- */
574
- declare function rebaseClipboardRows(rows: string[][], origin: CellPosition, target: CellPosition): string[][];
575
-
576
- /**
577
- * The render model of a spreadsheet: which rows and columns are shown, in
578
- * which order, with group header rows, frozen (sticky) offsets and merged
579
- * cell spans. Filters, hidden rows/columns and collapsed groups only affect
580
- * this view; the document keeps every row.
581
- */
582
-
583
- declare const DEFAULT_ROW_HEIGHT = 32;
584
- declare const DEFAULT_COLUMN_WIDTH = 130;
585
- type SpreadsheetRowSection = 'header' | 'body' | 'footer';
586
- interface SpreadsheetRowGroup {
587
- key: string;
588
- label: string;
589
- rowIndices: number[];
590
- collapsed: boolean;
591
- summaries: Record<string, number | null>;
592
- }
593
- type SpreadsheetViewRow = {
594
- kind: 'row';
595
- row: SpreadsheetRow;
596
- index: number;
597
- section: SpreadsheetRowSection;
598
- frozen: boolean;
599
- stickyTop: number;
600
- groupKey?: string;
601
- } | {
602
- kind: 'group';
603
- group: SpreadsheetRowGroup;
604
- };
605
- interface SpreadsheetViewColumn {
606
- column: SpreadsheetColumn;
607
- index: number;
608
- header: boolean;
609
- frozen: boolean;
610
- stickyLeft: number;
611
- }
612
- interface SpreadsheetCellSpan {
613
- rowSpan: number;
614
- colSpan: number;
615
- /** The cell whose content is shown (a merge's top-left cell). */
616
- source: CellPosition;
617
- merge?: CellRange;
618
- }
619
- interface SpreadsheetViewModel {
620
- rows: SpreadsheetViewRow[];
621
- columns: SpreadsheetViewColumn[];
622
- groups: SpreadsheetRowGroup[];
623
- /** Visible document row indices in display order (for keyboard navigation). */
624
- rowOrder: number[];
625
- /** Visible document column indices in display order. */
626
- columnOrder: number[];
627
- filteredOutCount: number;
628
- hiddenRowCount: number;
629
- hiddenColumnCount: number;
630
- /**
631
- * Span of the cell rendered at (row, col): `{ rowSpan: 1, colSpan: 1 }` for
632
- * an ordinary cell, the visible extent for a merge's first visible cell, and
633
- * null for cells covered by a merge (render nothing).
634
- */
635
- getCellSpan(row: number, col: number): SpreadsheetCellSpan | null;
636
- }
637
- type CellValueReader = (rowIndex: number, colIndex: number) => unknown;
638
- /** Header and footer row counts, clamped so they never overlap. */
639
- declare function getTableSections(doc: SpreadsheetDocument): {
640
- headerRows: number;
641
- footerRows: number;
642
- };
643
- declare function getRowSection(doc: SpreadsheetDocument, rowIndex: number): SpreadsheetRowSection;
644
- /** Whether a body row passes the active filters. Header/footer rows always do. */
645
- declare function rowPassesFilters(doc: SpreadsheetDocument, rowIndex: number, getValue: CellValueReader): boolean;
646
- /** Category groups of the (unhidden, unfiltered) body rows. */
647
- declare function computeRowGroups(doc: SpreadsheetDocument, getValue: CellValueReader): SpreadsheetRowGroup[];
648
- declare function buildSpreadsheetView(doc: SpreadsheetDocument, getValue: CellValueReader): SpreadsheetViewModel;
649
-
650
- interface CsvExportOptions {
651
- range?: CellRange | null;
652
- delimiter?: string;
653
- lineEnding?: string;
654
- bom?: boolean;
655
- /** Export formulas as typed (`=SUM(A1:A3)`) instead of their values. */
656
- formulas?: boolean;
657
- }
658
- interface CsvImportOptions {
659
- startRow?: number;
660
- startCol?: number;
661
- delimiter?: string;
662
- }
663
- type NewFilterRule = Omit<FilterRule, 'id'> & {
664
- id?: string;
665
- };
666
- interface SpreadsheetControllerOptions {
667
- document?: Partial<SpreadsheetDocument>;
668
- dataSources?: SpreadsheetDataSource[];
669
- primaryDataSourceId?: string;
670
- onDocumentChange?: (doc: SpreadsheetDocument) => void;
671
- onSelectionChange?: (activeCell: CellCoordinate | null, range: CellRange | null) => void;
672
- onCellCommit?: (rowId: string, colId: string, raw: string, value: any) => void;
673
- /**
674
- * Approximate memory budget for undo/redo snapshots, in bytes (UTF-16 size of
675
- * the serialized documents). The oldest undo steps beyond it are dropped, but
676
- * the most recent one is always kept. Defaults to 64 MiB; 0 = unlimited.
677
- */
678
- maxHistoryBytes?: number;
679
- }
680
- declare class SpreadsheetController {
681
- document: SpreadsheetDocument;
682
- activeCell: CellCoordinate | null;
683
- selectedRange: CellRange | null;
684
- editingCell: CellCoordinate | null;
685
- draftValue: string;
686
- readonly binder: DataSourceBinder;
687
- readonly depGraph: DependencyGraph;
688
- readonly evaluator: FormulaEvaluator;
689
- private primaryDataSourceId?;
690
- private onDocumentChange?;
691
- private onSelectionChange?;
692
- private onCellCommit?;
693
- private undoStack;
694
- private redoStack;
695
- private isApplyingHistory;
696
- private readonly maxHistoryBytes;
697
- private batching;
698
- private pendingCommits;
699
- private evaluatingRowIndex;
700
- private evaluatingCell;
701
- private spills;
702
- private spilledBy;
703
- private spillCells;
704
- private spillChanges;
705
- constructor(options?: SpreadsheetControllerOptions);
706
- loadDocument(document: SpreadsheetDocument): void;
707
- /**
708
- * Re-parses the value of every stored typed (non-formula) cell from its
709
- * `raw` input, so documents saved before typed input was parsed (whose
710
- * values are text such as `"120"`) compare and sort as numbers. Cells of
711
- * bound columns in record rows keep their value: it belongs to the data
712
- * source.
713
- */
714
- private rederiveTypedValues;
715
- /**
716
- * Value of typed (non-formula) input: a number, boolean, ISO date, error
717
- * or text (see `parseCellInput`), its automatic number format, and the
718
- * `CellFormat` to use: the automatic one (currency, percentage, date,
719
- * number) when `format` is unset or `text` (the default of new columns).
720
- */
721
- private typedCell;
722
- /**
723
- * The number format a cell keeps whatever is typed into it: its explicit
724
- * one, else its column's. Undefined lets typed input choose one.
725
- */
726
- private fixedNumberFormat;
727
- /** `numberFormat` / `explicitNumberFormat` fields for a formula, bound or spilled cell. */
728
- private fixedNumberFormatFields;
729
- /**
730
- * Typed input for a bound field, coerced by the field's declared type:
731
- * number, boolean and date fields get a number, boolean or ISO date when
732
- * the input parses as one; string and enum fields (and unknown fields)
733
- * keep the text exactly as typed.
734
- */
735
- private boundInputValue;
736
- registerDataSource(ds: SpreadsheetDataSource): void;
737
- setPrimaryDataSource(dataSourceId: string | undefined): void;
738
- syncWithDataSource(): void;
739
- private recomputeRowIndices;
740
- getColumn(colIdOrKey: string): SpreadsheetColumn | undefined;
741
- getRow(rowIdOrIndex: string | number): SpreadsheetRow | undefined;
742
- getCell(rowId: string, colId: string): CellData;
743
- /** Value of a cell with no stored data: bound record value, column formula, or blank. */
744
- private getDerivedCell;
745
- setCellValue(rowId: string, colId: string, raw: string): void;
746
- private getCellKey;
747
- /**
748
- * Recalculates a cell and everything that depends on it, in dependency
749
- * order. Every cell in a reference cycle is marked `#CYCLE!`.
750
- */
751
- recalculateCell(rowId: string, colId: string): void;
752
- /**
753
- * Recalculates `keys` (and, with `includeDependents`, their dependents) in
754
- * dependency order. Spill ranges are only known after evaluating their
755
- * anchors, so when a pass changes which cells hold spilled values (and so
756
- * the dependency graph), the dependents of those cells are recalculated in
757
- * another pass, until nothing changes.
758
- */
759
- private recalculateKeys;
760
- /**
761
- * Rebuilds the dependency graph from scratch and recalculates every formula
762
- * in dependency order.
763
- */
764
- recalculateAll(): void;
765
- private runEvaluationPlan;
766
- private locateCellKey;
767
- private markCycle;
768
- private evalSingleCellByKey;
769
- /**
770
- * Spills `array` from the anchor at (row, col) into the cells below and to
771
- * the right. Returns why it can't (the anchor then shows `#SPILL!`), or
772
- * null once placed. The grid never grows to fit an array, as in Excel.
773
- */
774
- private placeSpill;
775
- /** Removes the array spilled from `anchor`. With `keepEdges`, its dependency edges stay. */
776
- private clearSpill;
777
- private forgetSpilledCell;
778
- private resolveSpillByCoord;
779
- private toSpill;
780
- /**
781
- * The dynamic array covering (row, col), whether it is the anchor (the cell
782
- * holding the formula) or a spilled cell; null when there is none.
783
- */
784
- getSpillAt(row: number, col: number): SpreadsheetSpill | null;
785
- /** Every dynamic array currently spilled. */
786
- getSpills(): SpreadsheetSpill[];
787
- /** Whether `range` overlaps a spilled array (its anchor or spilled cells). */
788
- private intersectsSpill;
789
- private resolveCellByCoord;
790
- private resolveRangeByCoords;
791
- private resolveCurrentRowProperty;
792
- selectCell(row: number, col: number, extendSelection?: boolean): void;
793
- selectRange(range: CellRange): void;
794
- startEditing(row?: number, col?: number, initialValue?: string): void;
795
- commitEditing(valueToCommit?: string): void;
796
- cancelEditing(): void;
797
- moveCursor(direction: 'up' | 'down' | 'left' | 'right', extendSelection?: boolean): void;
798
- insertColumn(index: number, config?: Partial<SpreadsheetColumn>): void;
799
- deleteColumn(colId: string): void;
800
- insertRow(index: number, config?: Partial<SpreadsheetRow>): void;
801
- deleteRow(rowId: string): void;
802
- private generateId;
803
- /**
804
- * Rewrites references in every cell formula (and, for column changes, every
805
- * column formula) so they keep pointing at the same cells.
806
- */
807
- private shiftReferences;
808
- setColumnWidth(colId: string, width: number): void;
809
- autoFitColumnWidth(colId: string, customWidth?: number): void;
810
- /**
811
- * Exports cell values as TSV: the whole sheet, or only `range` (e.g. the
812
- * current selection) when given.
813
- */
814
- exportToTsv(range?: CellRange | null): string;
815
- /**
816
- * Pastes tab-separated values starting at (startRow, startCol), adding rows
817
- * and columns as needed. The whole paste is a single undo step.
818
- */
819
- importFromTsv(tsvData: string, startRow?: number, startCol?: number): void;
820
- /** Adds rows/columns at the end until (rowIndex, colIndex) exists. */
821
- private growGrid;
822
- /**
823
- * Writes raw inputs starting at (startRow, startCol), growing the grid as
824
- * needed, as a single undo step with one recalculation.
825
- */
826
- private writeMatrix;
827
- /**
828
- * Runs `fn` as one undo step: cell writes inside it are batched and
829
- * recalculated once, then listeners are notified.
830
- */
831
- private runBatch;
832
- /**
833
- * Exports the sheet (or `range`) as RFC 4180 CSV. Values are exported as
834
- * displayed unless `formulas` is set.
835
- */
836
- exportToCsv(options?: CsvExportOptions): string;
837
- /**
838
- * Imports CSV text at (startRow, startCol) (default A1), growing the grid
839
- * as needed. The whole import is a single undo step.
840
- */
841
- importFromCsv(csv: string, options?: CsvImportOptions): void;
842
- /**
843
- * Writes already-parsed rows of raw inputs (e.g. from an import adapter)
844
- * starting at (startRow, startCol), as a single undo step.
845
- */
846
- importRows(rows: string[][], options?: Omit<CsvImportOptions, 'delimiter'>): void;
847
- /** The cells of `range` (or the whole sheet), row by row. */
848
- private readMatrix;
849
- /**
850
- * Builds clipboard data for `range` (default: the selection) as TSV,
851
- * an HTML table and the lossless internal JSON format. Write every entry
852
- * with `clipboardData.setData(type, data)` in a `copy` event.
853
- */
854
- copyToClipboardData(range?: CellRange | null): SpreadsheetClipboardData;
855
- /**
856
- * Pastes clipboard data at `target` (default: the selection's top-left).
857
- * Prefers the internal format (formulas re-based to the target), then an
858
- * HTML table, then TSV. Returns false when there was nothing to paste.
859
- */
860
- pasteClipboardData(source: SpreadsheetClipboardSource, target?: CellPosition): boolean;
861
- private spillAnchorInRange;
862
- private getSelectionTopLeft;
863
- /** The table settings object, created on first use. */
864
- private get table();
865
- /** Records an undo step, applies `fn`, then notifies listeners. */
866
- private applyTableChange;
867
- /** First and last (inclusive) body row: rows between header and footer rows. */
868
- private getBodyRowBounds;
869
- private getCellValueAt;
870
- /** Rewrites every formula so references follow cells that moved. */
871
- private remapAllFormulas;
872
- /**
873
- * Keeps merges in place when rows/columns are inserted or deleted:
874
- * merges after the change shift, merges across it grow or shrink, and
875
- * merges reduced to a single cell are dropped.
876
- */
877
- private adjustTableForStructuralChange;
878
- /**
879
- * Sorts rows by one or more columns (stable; numbers before text, blanks
880
- * last). Without a range (or with a range spanning every column) whole rows
881
- * move; with a range only the cells inside it move. Header and footer rows
882
- * never move. References follow the moved cells. Returns false when the
883
- * sort is rejected (no valid keys, a key outside the range, or merged
884
- * cells in the sorted area).
885
- */
886
- sortRows(keys: SortKey[], options?: {
887
- range?: CellRange | null;
888
- }): boolean;
889
- getFilterState(): SpreadsheetFilterState;
890
- /** Replaces all filter rules (and turns filters on when there are any). */
891
- setFilterRules(rules: NewFilterRule[]): void;
892
- /** Adds a filter rule (AND-combined with the others) and turns filters on. Returns its id. */
893
- addFilterRule(rule: NewFilterRule): string;
894
- updateFilterRule(ruleId: string, changes: Partial<Omit<FilterRule, 'id'>>): void;
895
- removeFilterRule(ruleId: string): void;
896
- clearFilters(): void;
897
- /** Turns filtering on or off, keeping the rules. */
898
- setFiltersEnabled(enabled: boolean): void;
899
- toggleFilters(): void;
900
- private generateFilterId;
901
- setHeaderRowCount(count: number): void;
902
- setFooterRowCount(count: number): void;
903
- setHeaderColumnCount(count: number): void;
904
- /** Keeps the first `count` rows visible while scrolling. 0 unfreezes. */
905
- setFrozenRowCount(count: number): void;
906
- /** Keeps the first `count` columns visible while scrolling. 0 unfreezes. */
907
- setFrozenColumnCount(count: number): void;
908
- private setTableCount;
909
- /**
910
- * Sets an explicit number format code (e.g. `0.00`, `"$"#,##0.00`,
911
- * `m/d/yyyy`, `[Red]0;[Blue]-0`) on every cell in `range`, including blank
912
- * cells, so values typed later keep it. `null` removes explicit formats: the
913
- * cells go back to their column's format or the one chosen for typed input.
914
- * Undoable as one step. Returns false when there is no range.
915
- */
916
- setCellNumberFormat(range: CellRange | null, code: string | null): boolean;
917
- /**
918
- * Sets the number format code of a column (`null` or `General` clears it).
919
- * Its cells without an explicit format of their own use it, including
920
- * values typed later; when cleared they go back to the format chosen for
921
- * typed input. Undoable.
922
- */
923
- setColumnNumberFormat(colId: string, code: string | null): void;
924
- /** The column's format, or the one typed input chose (typed cells only). */
925
- private implicitNumberFormat;
926
- /** A copy of `cell` with `numberFormat` set, or removed when undefined. */
927
- private withNumberFormat;
928
- /** Re-applies the stored cell's (or the column's) format to a spilled value shown there. */
929
- private refreshSpilledNumberFormat;
930
- hideRows(indices: number[]): void;
931
- unhideRows(indices: number[]): void;
932
- hideColumns(indices: number[]): void;
933
- unhideColumns(indices: number[]): void;
934
- /** Unhides every hidden row and column (filters are unaffected). */
935
- unhideAll(): void;
936
- private setHidden;
937
- getMerges(): CellRange[];
938
- /** The merge containing (row, col), or null. */
939
- getMergeAt(row: number, col: number): CellRange | null;
940
- /** Grows `range` until no merge crosses its edge. Keeps the drag direction. */
941
- expandRangeToMerges(range: CellRange): CellRange;
942
- /**
943
- * Merges `range` (default: the selection) into one cell anchored on its
944
- * top-left cell; the other cells are cleared. Merges fully inside the range
945
- * are absorbed. Returns false for single cells and for ranges that
946
- * partially overlap an existing merge.
947
- */
948
- mergeCells(range?: CellRange | null): boolean;
949
- /** Removes every merge intersecting `range` (default: the selection). */
950
- unmergeCells(range?: CellRange | null): boolean;
951
- /**
952
- * Fills `target` from `source` like dragging the fill handle. `target` is
953
- * the extended range (source included) and must extend `source` down, up,
954
- * right or left. Numbers and dates continue their series, text ending in a
955
- * number counts up, other text repeats, and formulas are copied with
956
- * their relative references shifted (`$` parts stay). Returns false when
957
- * the ranges don't line up.
958
- */
959
- autofill(source: CellRange, target: CellRange): boolean;
960
- /**
961
- * Groups body rows by the value in `colId`, with optional per-group
962
- * summaries (e.g. `[{ colId, aggregate: 'sum' }]`).
963
- */
964
- groupRowsBy(colId: string, summaries?: GroupSummary[]): void;
965
- ungroupRows(): void;
966
- /** Sets (or with `null`, removes) the group summary for a column. */
967
- setGroupSummary(colId: string, aggregate: GroupAggregate | null): void;
968
- setGroupCollapsed(key: string, collapsed: boolean): void;
969
- toggleGroupCollapsed(key: string): void;
970
- /** The current row groups with their summaries (empty when not grouped). */
971
- getGroups(): SpreadsheetRowGroup[];
972
- /**
973
- * Transposes `range` (default: the selection) in place around its top-left
974
- * cell: rows become columns. Cells left uncovered are cleared, the grid
975
- * grows if needed, and references follow the moved cells. Returns false
976
- * for single cells or when merged cells are involved.
977
- */
978
- transposeRange(range?: CellRange | null): boolean;
979
- /**
980
- * What to render: visible rows (with group headers) and columns in display
981
- * order, frozen offsets and merged-cell spans. Filters, hidden rows/columns
982
- * and collapsed groups only affect this view, never the document.
983
- */
984
- getViewModel(): SpreadsheetViewModel;
985
- private recordSnapshot;
986
- /** Drops the oldest snapshots beyond `maxHistoryBytes`, always keeping the newest. */
987
- private trimHistory;
988
- /** Approximate bytes held by the undo/redo snapshots (UTF-16 size). */
989
- getHistoryByteSize(): number;
990
- /** Number of undo / redo snapshots currently held. */
991
- getHistoryDepth(): {
992
- undo: number;
993
- redo: number;
994
- };
995
- undo(): void;
996
- redo(): void;
997
- private notifyChange;
998
- }
999
-
1000
- export { type SpreadsheetDataSource as $, type ASTNode as A, type BinaryOpNode as B, type CellCoordinate as C, DEFAULT_COLUMN_WIDTH as D, type EvaluationContext as E, FORMULA_ERRORS as F, type GroupAggregate as G, type NewFilterRule as H, type PropertyRefNode as I, type RowType as J, SPREADSHEET_CLIPBOARD_MIME as K, type LiteralNode as L, MAX_FORMULA_ARRAY_SIZE as M, type NameNode as N, type SortDirection as O, type ParsedSpreadsheetClipboard as P, type SortKey as Q, type RangeNode as R, SpreadsheetController as S, type SpillRefNode as T, type SpreadsheetCellSpan as U, type SpreadsheetClipboardCell as V, type SpreadsheetClipboardData as W, type SpreadsheetClipboardPayload as X, type SpreadsheetClipboardSource as Y, type SpreadsheetColumn as Z, type SpreadsheetControllerOptions as _, type CellData as a, type SpreadsheetDataSourceField as a0, type SpreadsheetDocument as a1, type SpreadsheetFilterState as a2, type SpreadsheetGrouping as a3, type SpreadsheetRow as a4, type SpreadsheetRowGroup as a5, type SpreadsheetRowSection as a6, type SpreadsheetSpill as a7, type SpreadsheetTableSettings as a8, type SpreadsheetViewColumn as a9, rebaseClipboardRows as aA, remapFormulaReferences as aB, rowPassesFilters as aC, serializeHtmlTable as aD, shiftFormulaReferences as aE, sortCompareValues as aF, tokenizeFormula as aG, type SpreadsheetViewModel as aa, type SpreadsheetViewRow as ab, type StructuralChange as ac, type UnaryOpNode as ad, WHOLE_COLUMN_END_ROW as ae, buildSpreadsheetView as af, colNameToIndex as ag, columnDependencyKey as ah, compareNumbers as ai, compareValues as aj, computeRowGroups as ak, createSpreadsheetClipboardData as al, describeFormulaError as am, extractCellDependencies as an, getRowSection as ao, getTableSections as ap, indexToColName as aq, isFormulaError as ar, mapFormulaReferences as as, numberToText as at, offsetFormulaReferences as au, parseCellReference as av, parseFormula as aw, parseHtmlTable as ax, parseRange as ay, readSpreadsheetClipboard as az, type CellDep as b, type CellFormat as c, type CellPosition as d, type CellRange as e, type CellRefNode as f, type CellValueReader as g, type ColumnBinding as h, type ColumnType as i, type CsvExportOptions as j, type CsvImportOptions as k, DEFAULT_ROW_HEIGHT as l, DataSourceBinder as m, DependencyGraph as n, type FilterOperator as o, type FilterRule as p, type FormulaDiagnostic as q, type FormulaErrorCode as r, type FormulaEvaluationResult as s, FormulaEvaluator as t, FormulaParser as u, type FormulaRange as v, type FormulaToken as w, type FormulaTokenType as x, type FunctionCallNode as y, type GroupSummary as z };