@trebco/treb 32.6.8 → 32.7.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/dist/treb.d.ts ADDED
@@ -0,0 +1,2294 @@
1
+ /*! API v32.7. Copyright 2018-2025 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
2
+ /*
3
+ * This file is part of TREB.
4
+ *
5
+ * TREB is free software: you can redistribute it and/or modify it under the
6
+ * terms of the GNU General Public License as published by the Free Software
7
+ * Foundation, either version 3 of the License, or (at your option) any
8
+ * later version.
9
+ *
10
+ * TREB is distributed in the hope that it will be useful, but WITHOUT ANY
11
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13
+ * details.
14
+ *
15
+ * You should have received a copy of the GNU General Public License along
16
+ * with TREB. If not, see <https://www.gnu.org/licenses/>.
17
+ *
18
+ * Copyright 2022-2025 trebco, llc.
19
+ * info@treb.app
20
+ *
21
+ */
22
+
23
+
24
+ /**
25
+ * add our tag to the map
26
+ */
27
+ declare global {
28
+ interface HTMLElementTagNameMap {
29
+ 'treb-spreadsheet': HTMLElement & {
30
+ instance: {
31
+ sheet: EmbeddedSpreadsheet | undefined;
32
+ } | undefined;
33
+ };
34
+ }
35
+ }
36
+ /**
37
+ * API class for creating spreadsheets. this is intended as a singleton,
38
+ * we will export an instance of the class.
39
+ */
40
+ export declare class TREBGlobal {
41
+
42
+ /**
43
+ * Package version
44
+ */
45
+ version: string;
46
+
47
+ /**
48
+ * Create a spreadsheet. The `USER_DATA_TYPE` template parameter is the type
49
+ * assigned to the `user_data` field of the spreadsheet instance -- it can
50
+ * help simplify typing if you are storing extra data in spreadsheet
51
+ * files.
52
+ *
53
+ * Just ignore this parameter if you don't need it.
54
+ *
55
+ * @typeParam USER_DATA_TYPE - type for the `user_data` field in the
56
+ * spreadsheet instance
57
+ */
58
+ CreateSpreadsheet<USER_DATA_TYPE = unknown>(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet<USER_DATA_TYPE>;
59
+ }
60
+
61
+ /** single instance of factory class */
62
+ export declare const TREB: TREBGlobal;
63
+
64
+ /**
65
+ * options for creating spreadsheet
66
+ */
67
+ export interface EmbeddedSpreadsheetOptions {
68
+
69
+ /** containing HTML element */
70
+ container?: string | HTMLElement;
71
+
72
+ /** allow drag-and-drop files */
73
+ dnd?: boolean;
74
+
75
+ /**
76
+ * expandable grid. if this option is false, the grid will always
77
+ * stay the same size -- if you keep pressing down arrow, it won't
78
+ * grow. defaults to true.
79
+ */
80
+ expand?: boolean;
81
+
82
+ /**
83
+ * key in localStorage for persisting document.
84
+ * @deprecated - this was renamed to local_storage for clarity. if both
85
+ * storage_key and local_storage are set we will use the value in local_storage.
86
+ */
87
+ storage_key?: string | boolean;
88
+
89
+ /**
90
+ * persist user changes to document in browser localStorage.
91
+ *
92
+ * if set to a string, the value is used as the storage key.
93
+ *
94
+ * if set to `true`, we will generate a storage key based on the page URI.
95
+ * don't do that if you have multiple spreadsheets on a single page, or
96
+ * they will overwrite each other.
97
+ */
98
+ local_storage?: string | boolean;
99
+
100
+ /** don't load immediately (?) */
101
+ toll_initial_load?: boolean;
102
+
103
+ /** show formula bar. default true. */
104
+ formula_bar?: boolean;
105
+
106
+ /** expand formula bar */
107
+ expand_formula_button?: boolean;
108
+
109
+ /** scroll to cell on load */
110
+ scroll?: string | ICellAddress;
111
+
112
+ /** sheet to show on load, overrides anything in the model */
113
+ sheet?: string;
114
+
115
+ /** add resizable wrapper */
116
+ resizable?: boolean;
117
+
118
+ /** even if we allow resizing, constrain width. this is to support fixed width columns. */
119
+ constrain_width?: boolean;
120
+
121
+ /** export to xlsx, now optional */
122
+ export?: boolean;
123
+
124
+ /**
125
+ * fetch network document. this is a replacement for the old
126
+ * (deprecated) option `network_document`.
127
+ */
128
+ document?: string;
129
+
130
+ /**
131
+ * fetch network document (URI)
132
+ * @deprecated - use `document`
133
+ */
134
+ network_document?: string;
135
+
136
+ /** freeze rows */
137
+ freeze_rows?: number;
138
+
139
+ /** freeze columns */
140
+ freeze_columns?: number;
141
+
142
+ /** row/column headers */
143
+ headers?: boolean;
144
+
145
+ /** recalculate on load */
146
+ recalculate?: boolean;
147
+
148
+ /** show scrollbars */
149
+ scrollbars?: boolean;
150
+
151
+ /** show tab bar (multi sheet) */
152
+ tab_bar?: boolean | 'auto';
153
+
154
+ /**
155
+ * allow add/delete tab
156
+ */
157
+ add_tab?: boolean;
158
+
159
+ /**
160
+ * show delete tab
161
+ * @deprecated - implied by add_tab
162
+ */
163
+ delete_tab?: boolean;
164
+
165
+ /** set a reference in global (self) */
166
+ global_name?: string;
167
+
168
+ /** support undo */
169
+ undo?: boolean;
170
+
171
+ /** support in-cell editor */
172
+ in_cell_editor?: boolean;
173
+
174
+ /** prompt "you have unsaved changes" */
175
+ prompt_save?: boolean;
176
+
177
+ /**
178
+ * toolbar display option. true or false means include/don't include
179
+ * the toolbar (and the toolbar button). setting to "narrow" means
180
+ * include the toolbar, but use a narrow version (it compresses the
181
+ * align/justify groups).
182
+ *
183
+ * the toolbar usually starts hidden. if you set this option to "show",
184
+ * it will start visible. same for "show-narrow".
185
+ */
186
+ toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
187
+
188
+ /** include the file menu in the toolbar */
189
+ file_menu?: boolean;
190
+
191
+ /** include the font scale control in the toolbar */
192
+ font_scale?: boolean;
193
+
194
+ /** include the font stack control in the toolbar */
195
+ font_stack?: boolean;
196
+
197
+ /** include the insert/remove table button in the toolbar */
198
+ table_button?: boolean;
199
+
200
+ /** include the freeze button in the toolbar */
201
+ freeze_button?: boolean;
202
+
203
+ /** include the chart menu in the toolbar */
204
+ chart_menu?: boolean;
205
+
206
+ /** include a recalculate button in the toolbar */
207
+ toolbar_recalculate_button?: boolean;
208
+
209
+ /** better support for headless operations (default false) */
210
+ headless?: boolean;
211
+
212
+ /** max size for image, in bytes */
213
+ max_file_size?: number;
214
+
215
+ /** initial scale */
216
+ scale?: number;
217
+
218
+ /**
219
+ * show scale control (slider) under the spreadsheet.
220
+ */
221
+ scale_control?: boolean;
222
+
223
+ /**
224
+ * show the stats panel under the spreadsheet.
225
+ */
226
+ stats?: boolean;
227
+
228
+ /**
229
+ * save/load scale. this can optionally have a string key to disambiguate
230
+ */
231
+ persist_scale?: boolean | string;
232
+
233
+ /**
234
+ * target window for hyperlinks (default _blank); set false to disable hyperlinks altogether
235
+ */
236
+ hyperlinks?: string | false;
237
+
238
+ /**
239
+ * enable handling complex numbers in function calculation. turning this
240
+ * off doesn't actually disable complex numbers. it means that functions
241
+ * will not return complex numbers unless one of the arguments is complex.
242
+ * @see https://docs.treb.app/en/complex-numbers
243
+ *
244
+ * in version 25, complex defaults to `off`.
245
+ */
246
+ complex?: 'on' | 'off';
247
+
248
+ /**
249
+ * for rendering the imaginary number. this is intended to support
250
+ * switching to a different character for rendering, or adding a leading
251
+ * space/half-space/hair-space.
252
+ *
253
+ * this _does_not_ change how you enter imaginary numbers, you still have
254
+ * to use `i` (lower-case ascii i).
255
+ */
256
+ imaginary_value?: string;
257
+
258
+ /**
259
+ * support markdown formatting for text in cells and comments. at the
260
+ * moment we only support bold, italic, and strike text.
261
+ */
262
+ markdown?: boolean;
263
+
264
+ /**
265
+ * show tinted colors in toolbar color dropdowns. as of version 25
266
+ * this defaults to true (used to be false).
267
+ */
268
+ tint_theme_colors?: boolean;
269
+
270
+ /**
271
+ * show a spinner for long-running operations
272
+ */
273
+ spinner?: boolean;
274
+
275
+ /**
276
+ * start with sidebar closed. defaults to false.
277
+ */
278
+ collapsed?: boolean;
279
+
280
+ /**
281
+ * show the revert button in the sidebar. see the `Revert` method. this
282
+ * was renamed from `revert` to avoid any ambiguity.
283
+ */
284
+ revert_button?: boolean;
285
+
286
+ /**
287
+ * show the revert indicator. this is an indicator that shows on the
288
+ * top-left of the spreadsheet when a network document has local changes.
289
+ */
290
+ revert_indicator?: boolean;
291
+
292
+ /**
293
+ * handle the F9 key and recalculate the spreadsheet. for compatibility.
294
+ * we're leaving this option to default `false` for now, but that may
295
+ * change in the future. key modifiers have no effect.
296
+ */
297
+ recalculate_on_f9?: boolean;
298
+
299
+ /**
300
+ * indent/outdent buttons; default false
301
+ */
302
+ indent_buttons?: boolean;
303
+
304
+ /**
305
+ * enable spill arrays and spill references. this is on by default
306
+ * starting in 30.1.0. set to false to disable.
307
+ */
308
+ spill?: boolean;
309
+
310
+ /**
311
+ * language. at the moment this controls spreadsheet function names
312
+ * only; the plan is to expand to the rest of the interface over time.
313
+ * should be an ISO 639-1 language code, like "en", "fr" or "sv" (case
314
+ * insensitive). we only support a limited subset of languages at the
315
+ * moment.
316
+ *
317
+ * leave blank or set to "locale" to use the current locale.
318
+ */
319
+ language?: string;
320
+ }
321
+
322
+ /**
323
+ * Structure represents a cell address. Note that row and column are 0-based.
324
+ */
325
+ export interface ICellAddress {
326
+
327
+ /** 0-based row */
328
+ row: number;
329
+
330
+ /** 0-based column */
331
+ column: number;
332
+ absolute_row?: boolean;
333
+ absolute_column?: boolean;
334
+ sheet_id?: number;
335
+
336
+ /** spill reference */
337
+ spill?: boolean;
338
+ }
339
+
340
+ /**
341
+ * embedded spreadsheet
342
+ */
343
+ export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
344
+
345
+ /**
346
+ * convenience function returns the name of the active sheet. if the
347
+ * sheet name has spaces or other characters that require quoting, it
348
+ * will be quoted using single quotes.
349
+ */
350
+ get active_sheet(): string;
351
+
352
+ /** document name (metadata) */
353
+ get document_name(): string | undefined;
354
+
355
+ /** document name (metadata) */
356
+ set document_name(name: string | undefined);
357
+
358
+ /**
359
+ * opaque user data (metadata). `USER_DATA_TYPE` is a template
360
+ * parameter you can set when creating the spreadsheet.
361
+ */
362
+ get user_data(): USER_DATA_TYPE | undefined;
363
+
364
+ /**
365
+ * opaque user data (metadata). `USER_DATA_TYPE` is a template
366
+ * parameter you can set when creating the spreadsheet.
367
+ */
368
+ set user_data(data: USER_DATA_TYPE | undefined);
369
+
370
+ /** current grid scale */
371
+ get scale(): number;
372
+
373
+ /** current grid scale */
374
+ set scale(value: number);
375
+
376
+ /** headless state */
377
+ get headless(): boolean;
378
+
379
+ /** headless state */
380
+ set headless(value: boolean);
381
+
382
+ /**
383
+ * state is the current revision of the document. it is preserved any
384
+ * time the document is saved. it should be a consistent indication of
385
+ * the document version and can be used to compare versions.
386
+ *
387
+ * state is an atomically-incrementing integer but rolls over at 2^16.
388
+ */
389
+ get state(): number;
390
+
391
+ /**
392
+ * this flag indicates we can revert the document. what that means is
393
+ * we loaded a user-created version from localStorage, but there's a
394
+ * backing network or inline document. or we did load the original version
395
+ * but the user has made some document changes.
396
+ *
397
+ * it's like `dirty`, but that uses the load source as the ground truth,
398
+ * which means if you load a modified document from localStorage it's
399
+ * initially considered not-dirty (which is maybe just a bad design?)
400
+ *
401
+ * the intent of this field is to support enabling/disabling revert
402
+ * logic, or to add a visual indicator that you are not looking at the
403
+ * canonical version.
404
+ */
405
+ get can_revert(): boolean;
406
+
407
+ /**
408
+ * indicates the current revision of the document is not equal to the
409
+ * last-saved revision of the document.
410
+ */
411
+ get dirty(): boolean;
412
+
413
+ /**
414
+ * explicitly set or clear the dirty flag. it's intended for use by clients
415
+ * that have their own save routine.
416
+ */
417
+ set dirty(value: boolean);
418
+
419
+ /**
420
+ * returns the names of all sheets in the current document
421
+ */
422
+ get sheet_names(): string[];
423
+
424
+ /**
425
+ * set or remove an external editor. external editor is an interface used
426
+ * to support outside tooling by highlighting a list of arguments and
427
+ * responding to selection.
428
+ */
429
+ ExternalEditor(config?: Partial<ExternalEditorConfig>): void;
430
+
431
+ /**
432
+ * @internalRemarks removing internal flag
433
+ */
434
+ ConditionalFormatDuplicateValues(range: RangeReference | undefined, options: ConditionalFormatDuplicateValuesOptions): ConditionalFormat;
435
+
436
+ /**
437
+ * @internalRemarks removing internal flag
438
+ */
439
+ ConditionalFormatGradient(range: RangeReference | undefined, options: ConditionalFormatGradientOptions | StandardGradient): ConditionalFormat;
440
+
441
+ /**
442
+ *
443
+ */
444
+ ConditionalFormatDataBars(range: RangeReference | undefined, options?: ConditionalFormatDataBarOptions): ConditionalFormat;
445
+
446
+ /**
447
+ * @internalRemarks removing internal flag
448
+ */
449
+ ConditionalFormatCellMatch(range: RangeReference | undefined, options: ConditionalFormatCellMatchOptions): ConditionalFormat;
450
+
451
+ /**
452
+ * @internalRemarks removing internal flag
453
+ */
454
+ ConditionalFormatExpression(range: RangeReference | undefined, options: CondifionalFormatExpressionOptions): ConditionalFormat;
455
+
456
+ /**
457
+ * remove conditional format
458
+ *
459
+ * @internalRemarks removing internal flag
460
+ */
461
+ RemoveConditionalFormat(format: ConditionalFormat): void;
462
+
463
+ /**
464
+ * clear conditional formats from the target range (or currently selected
465
+ * range). we operate on format objects, meaning we'll remove the whole
466
+ * format object rather than clip the area.
467
+ *
468
+ * @internalRemarks removing internal flag
469
+ */
470
+ RemoveConditionalFormats(range?: RangeReference): void;
471
+
472
+ /** dynamically load language module */
473
+ LoadLanguage(language?: string): Promise<void>;
474
+
475
+ /**
476
+ * Use this function to batch multiple document changes. Essentially the
477
+ * grid stops broadcasting events for the duration of the function call,
478
+ * and collects them instead. After the function call we update as necessary.
479
+ */
480
+ Batch(func: () => void, paint?: boolean): void;
481
+
482
+ /** set freeze area */
483
+ Freeze(rows?: number, columns?: number): void;
484
+
485
+ /** freeze at current selection */
486
+ FreezeSelection(): void;
487
+
488
+ /** return current freeze area */
489
+ GetFreeze(): FreezePane;
490
+
491
+ /**
492
+ * Update theme from CSS. Because the spreadsheet is painted, not
493
+ * rendered, you need to notifiy us if external style (CSS) properties
494
+ * have changed. We will update and repaint.
495
+ */
496
+ UpdateTheme(): void;
497
+
498
+ /**
499
+ * Get sheet ID, by name (sheet name) or index. This may be useful for
500
+ * constructing references programatically.
501
+ *
502
+ * @remarks
503
+ *
504
+ * Sheet IDs are positive integers. IDs are ephemeral, they should not be
505
+ * retained after a document is closed or reloaded. They will likely (almost)
506
+ * always be the same, but that's not guaranteed, so don't rely on them.
507
+ *
508
+ * @param sheet - sheet name or index. sheet names are matched case-insensitively.
509
+ *
510
+ * @returns ID, or undefined if the index is not found (0 is not a valid
511
+ * sheet ID, so you can test for falsy).
512
+ *
513
+ * @public
514
+ */
515
+ GetSheetID(sheet: string | number): number | undefined;
516
+
517
+ /**
518
+ * insert a table in the given range. optionally include a totals row.
519
+ * this method does not make any changes to content or layout. it just
520
+ * converts the range to a table.
521
+ *
522
+ * @param reference
523
+ */
524
+ InsertTable(range?: RangeReference, options?: InsertTableOptions): void;
525
+ RemoveTable(range?: RangeReference): void;
526
+ UpdateTableStyle(range?: RangeReference, theme?: TableTheme | number): void;
527
+ SetTabColor(sheet?: number | string, color?: Color): void;
528
+
529
+ /**
530
+ * Add a sheet, optionally named.
531
+ */
532
+ AddSheet(name?: string): number;
533
+ RemoveConnectedChart(id: number): void;
534
+ UpdateConnectedChart(id: number, formula: string): void;
535
+
536
+ /**
537
+ * Insert an annotation node. Usually this means inserting a chart. Regarding
538
+ * the argument separator, see the Evaluate function.
539
+ *
540
+ * @param formula - annotation formula. For charts, the chart formula.
541
+ * @param type - annotation type. Defaults to `treb-chart`.
542
+ * @param rect - coordinates, or a range reference for layout.
543
+ * @param options - evaluate options. because this function used to take
544
+ * the argument separator, we allow that to be passed directly, but this
545
+ * is deprecated. new code should use the options object.
546
+ */
547
+ InsertAnnotation(formula: string, type?: AnnotationType, rect?: IRectangle | RangeReference, options?: EvaluateOptions | ',' | ';'): void;
548
+
549
+ /**
550
+ * Insert an image. This method will open a file chooser and (if an image
551
+ * is selected) insert the image into the document.
552
+ */
553
+ InsertImage(): void;
554
+
555
+ /**
556
+ * Rename a sheet.
557
+ *
558
+ * @param index - old name or index of sheet. leave undefined to use
559
+ * current active sheet.
560
+ *
561
+ * @public
562
+ */
563
+ RenameSheet(index: string | number | undefined, new_name: string): void;
564
+
565
+ /**
566
+ * Delete a sheet.
567
+ *
568
+ * @param index - sheet name or index. Leave undefined to delete the active sheet.
569
+ *
570
+ * @public
571
+ */
572
+ DeleteSheet(index?: string | number): void;
573
+
574
+ /**
575
+ * Show or hide sheet. This is a replacement for the `ShowSheet` method,
576
+ * because that name is somewhat ambiguous.
577
+ *
578
+ * @param index - sheet name or index.
579
+ *
580
+ * @public
581
+ */
582
+ HideSheet(index?: number | string, hide?: boolean): void;
583
+
584
+ /** list sheets in the model */
585
+ ListSheets(): {
586
+ name: string;
587
+ hidden?: boolean;
588
+ }[];
589
+
590
+ /**
591
+ * Show or hide sheet. This method is deprecated because it's ambiguous.
592
+ * To set a sheet's visibility, use `HideSheet`. To activate a sheet, use
593
+ * `ActivateSheet`.
594
+ *
595
+ * @param index - sheet name or index.
596
+ *
597
+ * @see HideSheet
598
+ * @deprecated Use `HideSheet` instead.
599
+ */
600
+ ShowSheet(index?: number | string, show?: boolean): void;
601
+
602
+ /**
603
+ * Activate sheet.
604
+ *
605
+ * @param index - sheet name or index.
606
+ *
607
+ * @public
608
+ */
609
+ ActivateSheet(index: number | string): void;
610
+
611
+ /**
612
+ * Set width of column(s).
613
+ *
614
+ * @param column - column, or columns (array), or undefined means all columns
615
+ * @param width - desired width (can be 0) or undefined means 'auto-size'
616
+ *
617
+ * @public
618
+ */
619
+ SetColumnWidth(column?: number | number[], width?: number): void;
620
+
621
+ /**
622
+ * Set height of row(s).
623
+ *
624
+ * @param row - row, or rows (array), or undefined means all rows
625
+ * @param height - desired height (can be 0) or undefined means 'auto-size'
626
+ *
627
+ * @public
628
+ */
629
+ SetRowHeight(row?: number | number[], height?: number): void;
630
+
631
+ /**
632
+ * Insert row(s).
633
+ *
634
+ * @param before_row - leave undefined to use current selection.
635
+ *
636
+ * @public
637
+ */
638
+ InsertRows(before_row?: number, count?: number): void;
639
+
640
+ /**
641
+ * Insert column(s).
642
+ *
643
+ * @param before_column - leave undefined to use current selection.
644
+ *
645
+ * @public
646
+ */
647
+ InsertColumns(before_column?: number, count?: number): void;
648
+
649
+ /**
650
+ * Delete row(s).
651
+ *
652
+ * @param start_row - leave undefined to use current selection. in this
653
+ * case the `count` parameter will be ignored and all rows in the selection
654
+ * will be deleted.
655
+ */
656
+ DeleteRows(start_row?: number, count?: number): void;
657
+
658
+ /**
659
+ * Delete columns(s).
660
+ *
661
+ * @param start_column - leave undefined to use current selection. in this
662
+ * case the `count` parameter will be ignored and all columns in the
663
+ * selection will be deleted.
664
+ */
665
+ DeleteColumns(start_column?: number, count?: number): void;
666
+
667
+ /**
668
+ * filter a table. the reference can be the table name, or a cell in the table.
669
+ * if the reference is an area (range), we're going to look at the top-left
670
+ * cell.
671
+ *
672
+ * this method uses a function to filter rows based on cell values. leave the
673
+ * function undefined to show all rows. this is a shortcut for "unfilter".
674
+ *
675
+ * @param column - the column to sort on. values from this column will be
676
+ * passed to the filter function.
677
+ *
678
+ * @param filter - a callback function to filter based on cell values. this
679
+ * will be called with the cell value (formula), the calculated value (if any),
680
+ * and the cell style. return false to hide the row, and true to show the row.
681
+ * if the filter parameter is omitted, all values will be shown.
682
+ *
683
+ */
684
+ FilterTable(reference: RangeReference, column?: number, filter?: TableFilterFunction): void;
685
+
686
+ /**
687
+ * sort a table. the reference can be the table name, or a cell in the table.
688
+ * if the reference is an area (range), we're going to look at the top-left
689
+ * cell.
690
+ */
691
+ SortTable(reference: RangeReference, options?: Partial<TableSortOptions>): void;
692
+
693
+ /**
694
+ * Merge cells in range.
695
+ *
696
+ * @param range - target range. leave undefined to use current selection.
697
+ *
698
+ * @public
699
+ */
700
+ MergeCells(range?: RangeReference): void;
701
+
702
+ /**
703
+ * Unmerge cells in range.
704
+ *
705
+ * @param range - target range. leave undefined to use current selection.
706
+ *
707
+ * @public
708
+ */
709
+ UnmergeCells(range?: RangeReference): void;
710
+
711
+ /**
712
+ * revert to the network version of this document, if `local_storage`
713
+ * is set and the create options had either `document` or `inline-document`
714
+ * set.
715
+ *
716
+ * FIXME: we should adjust for documents that fail to load.
717
+ */
718
+ Revert(): void;
719
+
720
+ /**
721
+ * Export to XLSX file.
722
+ *
723
+ * @remarks
724
+ *
725
+ * this requires a bunch of processing -- one, we do this in a worker, and
726
+ * two, it's demand loaded so we don't bloat up this embed script.
727
+ */
728
+ Export(): void;
729
+
730
+ /**
731
+ * Focus the grid.
732
+ *
733
+ * @public
734
+ */
735
+ Focus(): void;
736
+
737
+ /**
738
+ * Update layout and repaint if necessary.
739
+ *
740
+ * @remarks
741
+ *
742
+ * This method should be called when the container is resized, to
743
+ * trigger an update to layout. It should be called automatically
744
+ * by a resize observer set in the containing tag class, but you
745
+ * can call it manually if necessary.
746
+ *
747
+ * @public
748
+ */
749
+ Resize(): void;
750
+
751
+ /**
752
+ * Clear/reset sheet. This will reset the undo stack as well,
753
+ * so it cannot be undone.
754
+ *
755
+ * @public
756
+ */
757
+ Reset(): void;
758
+
759
+ /**
760
+ * load a document from from local storage, using the given key.
761
+ * this method will also set the local option for the storage key, so the
762
+ * document will potentially be saved on modification.
763
+ */
764
+ LoadFromLocalStorage(key: string): boolean;
765
+
766
+ /**
767
+ * load a network document by URI. CORS headers must be set appropriately
768
+ * on documents originating from different hosts.
769
+ */
770
+ LoadNetworkDocument(uri: string, options?: EmbeddedSpreadsheetOptions): Promise<void>;
771
+
772
+ /**
773
+ * Load a desktop file. This method will show a file chooser and open
774
+ * the selected file (if any).
775
+ *
776
+ * @public
777
+ */
778
+ LoadLocalFile(): Promise<void>;
779
+
780
+ /**
781
+ * Export sheet as CSV/TSV. This is an internal method called by the save
782
+ * document methods, but you can call it directly if you want the text as
783
+ * a string.
784
+ *
785
+ * @returns string
786
+ *
787
+ * @public
788
+ */
789
+ ExportDelimited(options?: ExportOptions): string;
790
+
791
+ /**
792
+ * @deprecated - use SaveToDesktop
793
+ *
794
+ * @param filename
795
+ * @param additional_options
796
+ */
797
+ SaveLocalFile(filename?: string, additional_options?: SaveOptions): void;
798
+
799
+ /**
800
+ * Save the current document to a desktop file. This is the new version
801
+ * of the method, renamed from SaveLocalFile.
802
+ *
803
+ * @param filename Filename or extension to use the document name.
804
+ */
805
+ SaveToDesktop(filename?: string, additional_options?: SaveOptions): void;
806
+
807
+ /**
808
+ * Load CSV from string. This is used internally when loading network
809
+ * documents and local files, but you can call it directly if you have
810
+ * a CSV file as text.
811
+ *
812
+ * @public
813
+ */
814
+ LoadCSV(csv: string, source?: LoadSource): void;
815
+
816
+ /**
817
+ * get or set the current scroll offset. scroll offset is automatically
818
+ * saved if you save the document or switch tabs; this is for saving/
819
+ * restoring scroll if you cache the containing element.
820
+ */
821
+ ScrollOffset(offset?: Point): Point | undefined;
822
+
823
+ /**
824
+ * unserialize document from data.
825
+ */
826
+ LoadDocument(data: TREBDocument, options?: LoadDocumentOptions): void;
827
+
828
+ /**
829
+ * Set note (comment) in cell.
830
+ *
831
+ * @param address target address, or leave undefined to use current selection.
832
+ * @param note note text, or leave undefined to clear existing note.
833
+ */
834
+ SetNote(address: AddressReference | undefined, note?: string): void;
835
+
836
+ /**
837
+ * set or clear cell valiation.
838
+ *
839
+ * @param target - target cell/area
840
+ * @param validation - a spreadsheet range, list of data, or undefined. pass
841
+ * undefined to remove existing cell validation.
842
+ * @param error - setting an invalid value in the target cell is an error (and
843
+ * is blocked). defaults to false.
844
+ */
845
+ SetValidation(target: RangeReference, validation?: RangeReference | CellValue[], error?: boolean): void;
846
+
847
+ /**
848
+ * Delete a macro function.
849
+ *
850
+ * @public
851
+ */
852
+ RemoveFunction(name: string): void;
853
+
854
+ /**
855
+ * Create a macro function.
856
+ *
857
+ * FIXME: this needs a control for argument separator, like other
858
+ * functions that use formulas (@see SetRange)
859
+ *
860
+ * @public
861
+ */
862
+ DefineFunction(name: string, argument_names?: string | string[], function_def?: string): void;
863
+
864
+ /**
865
+ * Serialize document to a plain javascript object. The result is suitable
866
+ * for converting to JSON. This method is used by the SaveLocalFile and
867
+ * SaveLocalStorage methods, but you can call it directly if you want to
868
+ * save the document some other way.
869
+ *
870
+ * @public
871
+ */
872
+ SerializeDocument(options?: SerializeOptions): TREBDocument;
873
+
874
+ /**
875
+ * Recalculate sheet.
876
+ *
877
+ * @public
878
+ */
879
+ Recalculate(): void;
880
+
881
+ /**
882
+ * Save document to local storage.
883
+ *
884
+ * @param key optional storage key. if omitted, the method will use
885
+ * the key from local options (set at create time).
886
+ */
887
+ SaveLocalStorage(key?: string | undefined): void;
888
+
889
+ /**
890
+ * Revert state one level from the undo stack.
891
+ *
892
+ * @public
893
+ */
894
+ Undo(): void;
895
+
896
+ /**
897
+ * Show the about dialog.
898
+ *
899
+ * @public
900
+ */
901
+ About(): void;
902
+
903
+ /**
904
+ * scroll the given address into view. it could be at either side
905
+ * of the window. optionally use smooth scrolling.
906
+ */
907
+ ScrollIntoView(address: AddressReference, smooth?: boolean): void;
908
+
909
+ /**
910
+ * Scroll to the given address. In the current implementation this method
911
+ * will not change sheets, although it probably should if the reference
912
+ * is to a different sheet.
913
+ *
914
+ * @public
915
+ */
916
+ ScrollTo(address: AddressReference, options?: SheetScrollOptions): void;
917
+
918
+ /**
919
+ * Resolve a string address/range to an address or area (range) object.
920
+ *
921
+ * @param reference A string like "A1" or "Sheet1!B2:C3". If a sheet name
922
+ * is not included, the current active sheet is used. You can also pass a
923
+ * named range as reference.
924
+ *
925
+ * @public
926
+ */
927
+ Resolve(reference: string, options?: {
928
+ r1c1?: boolean;
929
+ }): ICellAddress | IArea | undefined;
930
+
931
+ /**
932
+ * Convert an address/range object to a string. this is a convenience
933
+ * function for composing formulas.
934
+ *
935
+ * @param ref sheet reference as a string or structured object
936
+ * @param [qualified=true] include sheet names
937
+ * @param [named=true] resolve to named ranges, where applicable
938
+ */
939
+ Unresolve(ref: RangeReference, qualified?: boolean, named?: boolean): string;
940
+
941
+ /**
942
+ * Evaluate an arbitrary expression in the spreadsheet. You should generally
943
+ * use sheet names when referring to cells, to avoid ambiguity. Otherwise
944
+ * cell references will resolve to the active sheet.
945
+ *
946
+ * @param expression - an expression in spreadsheet language
947
+ * @param options - options for parsing the passed function
948
+ *
949
+ * @public
950
+ */
951
+ Evaluate(expression: string, options?: EvaluateOptions): CellValue | CellValue[][];
952
+
953
+ /**
954
+ * Returns the current selection, as a string address or range.
955
+ *
956
+ * @param qualified include sheet name in result. default true.
957
+ *
958
+ * @returns selection as a string, or empty string if there's no selection.
959
+ *
960
+ * @public
961
+ */
962
+ GetSelection(qualified?: boolean): string;
963
+
964
+ /**
965
+ * Parse a string and return a number (if possible).
966
+ *
967
+ * @public
968
+ */
969
+ ParseNumber(text: string): number | Complex | boolean | string | undefined;
970
+
971
+ /**
972
+ * Format a number with an arbitrary formatter.
973
+ *
974
+ * @public
975
+ */
976
+ FormatNumber(value: number | Complex, format?: string): string;
977
+
978
+ /**
979
+ * convert a javascript date (or timestamp) to a spreadsheet date
980
+ */
981
+ SpreadsheetDate(javascript_date: number | Date): number;
982
+
983
+ /**
984
+ * convert a spreadsheet date to a javascript date
985
+ */
986
+ JavascriptDate(spreadsheet_date: number): number;
987
+
988
+ /**
989
+ * Apply borders to range.
990
+ *
991
+ * @param range pass `undefined` as range to apply to current selection.
992
+ *
993
+ * @remarks
994
+ *
995
+ * Borders are part of style, but setting/removing borders is more
996
+ * complicated than setting other style properties. usually you want
997
+ * things to apply to ranges, rather than individual cells. removing
998
+ * borders needs to consider neighbor borders. and so on.
999
+ *
1000
+ * @public
1001
+ */
1002
+ ApplyBorders(range: RangeReference | undefined, borders: BorderConstants, width?: number): void;
1003
+
1004
+ /**
1005
+ * Apply style to range.
1006
+ *
1007
+ * @param range pass `undefined` as range to apply to current selection.
1008
+ * @param delta apply over existing properties. default true.
1009
+ *
1010
+ * @remarks
1011
+ *
1012
+ * Don't use this method to set borders, use `ApplyBorders`.
1013
+ *
1014
+ * @public
1015
+ */
1016
+ ApplyStyle(range?: RangeReference, style?: CellStyle, delta?: boolean): void;
1017
+
1018
+ /**
1019
+ * Remove a named range (removes the name, not the range).
1020
+ *
1021
+ * @public
1022
+ */
1023
+ ClearName(name: string): void;
1024
+ ListNames(): SerializedNamed[];
1025
+
1026
+ /**
1027
+ * Create a named range or named expression. A named range refers to an
1028
+ * address or range. A named expression can be any value or formula. To set
1029
+ * the value as a literal string, enclose the string in double-quotes (as
1030
+ * you would when using a string as a function argument).
1031
+ *
1032
+ * @param value range, value or expression
1033
+ *
1034
+ * @remarks
1035
+ *
1036
+ * This function used to support passing `undefined` as the value,
1037
+ * which meant "create a named range using current selection". We don't
1038
+ * support that any more but you can accompilsh that with
1039
+ * `sheet.DefineName("Name", sheet.GetSelection())`.
1040
+ *
1041
+ * @public
1042
+ */
1043
+ DefineName(name: string, value: RangeReference | CellValue, scope?: string | number, overwrite?: boolean): void;
1044
+
1045
+ /**
1046
+ * Set or remove a link in a cell.
1047
+ *
1048
+ * @param target http/https URL or a spreadsheet reference (as text). set blank to remove link.
1049
+ *
1050
+ * @public
1051
+ */
1052
+ SetLink(address?: AddressReference, target?: string): void;
1053
+
1054
+ /**
1055
+ * Select a range. This function will change sheets if your reference
1056
+ * refers to a different sheet. if the argument is undefined or falsy
1057
+ * it will remove the selection (set to no selection).
1058
+ *
1059
+ * @public
1060
+ */
1061
+ Select(range?: RangeReference): void;
1062
+
1063
+ /**
1064
+ * override for paste method omits the data parameter.
1065
+ */
1066
+ Paste(target?: RangeReference, options?: PasteOptions): void;
1067
+
1068
+ /**
1069
+ * standard paste method accepts data argument
1070
+ *
1071
+ * @param target
1072
+ * @param data
1073
+ * @param options
1074
+ */
1075
+ Paste(target?: RangeReference, data?: ClipboardData, options?: PasteOptions): void;
1076
+
1077
+ /**
1078
+ * copy data. this method returns the copied data. it does not put it on
1079
+ * the system clipboard. this is for API access when the system clipboard
1080
+ * might not be available.
1081
+ */
1082
+ Copy(source?: RangeReference): ClipboardData;
1083
+
1084
+ /**
1085
+ * cut data. this method returns the cut data. it does not put it on the
1086
+ * system clipboard. this method is similar to the Copy method, with
1087
+ * two differences: (1) we remove the source data, effectively clearing
1088
+ * the source range; and (2) the clipboard data retains references, meaning
1089
+ * if you paste the data in a different location it will refer to the same
1090
+ * cells.
1091
+ */
1092
+ Cut(source?: RangeReference): ClipboardData;
1093
+
1094
+ /**
1095
+ *
1096
+ * @param range target range. leave undefined to use current selection.
1097
+ *
1098
+ * @public
1099
+ */
1100
+ GetRange(range?: RangeReference, options?: GetRangeOptions): CellValue | CellValue[][] | undefined;
1101
+
1102
+ /**
1103
+ * returns the style from the target address or range.
1104
+ *
1105
+ * @param range - target range. leave undefined to use current selection
1106
+ * @param apply_theme - include theme defaults when returning style
1107
+ *
1108
+ */
1109
+ GetStyle(range?: RangeReference, apply_theme?: boolean): CellStyle | CellStyle[][] | undefined;
1110
+
1111
+ /**
1112
+ * Set data in range.
1113
+ *
1114
+ * @param range target range. leave undefined to use current selection.
1115
+ *
1116
+ * @public
1117
+ */
1118
+ SetRange(range?: RangeReference, data?: CellValue | CellValue[][], options?: SetRangeOptions): void;
1119
+
1120
+ /**
1121
+ * Subscribe to spreadsheet events
1122
+ * @param subscriber - callback function
1123
+ * @returns a token used to cancel the subscription
1124
+ */
1125
+ Subscribe(subscriber: (event: EmbeddedSheetEvent) => void): number;
1126
+
1127
+ /**
1128
+ * Cancel subscription
1129
+ * @param token - the token returned from `Subscribe`
1130
+ */
1131
+ Cancel(token: number): void;
1132
+ }
1133
+
1134
+ /**
1135
+ * options for saving files. we add the option for JSON formatting.
1136
+ */
1137
+ export interface SaveOptions extends SerializeOptions {
1138
+
1139
+ /** pretty json formatting */
1140
+ pretty?: boolean;
1141
+ }
1142
+
1143
+ /**
1144
+ * options for the LoadDocument method
1145
+ */
1146
+ export interface LoadDocumentOptions {
1147
+ scroll?: string | ICellAddress;
1148
+ flush?: boolean;
1149
+ recalculate?: boolean;
1150
+ override_sheet?: string;
1151
+ }
1152
+
1153
+ /**
1154
+ * options for the GetRange method
1155
+ */
1156
+ export interface GetRangeOptions {
1157
+
1158
+ /**
1159
+ * return formatted values (apply number formats and return strings)
1160
+ * @deprecated
1161
+ */
1162
+ formatted?: boolean;
1163
+
1164
+ /**
1165
+ * return formulas instead of values. formula takes precedence over
1166
+ * "formatted"; if you pass both, returned values will *not* be formatted.
1167
+ * @deprecated
1168
+ */
1169
+ formula?: boolean;
1170
+
1171
+ /**
1172
+ * by default, GetRange returns cell values. the optional type field
1173
+ * can be used to returns data in different formats.
1174
+ *
1175
+ * @remarks
1176
+ *
1177
+ * `formatted` returns formatted values, applying number formatting and
1178
+ * returning strings.
1179
+ *
1180
+ * `A1` returns cell formulas instead of values, in A1 format.
1181
+ *
1182
+ * `R1C1` returns cell formauls in R1C1 format.
1183
+ *
1184
+ * `formula` is an alias for 'A1', for backwards compatibility.
1185
+ *
1186
+ */
1187
+ type?: 'formatted' | 'A1' | 'R1C1' | 'formula';
1188
+ }
1189
+
1190
+ /**
1191
+ * options for the ScrollTo method.
1192
+ *
1193
+ * @remarks
1194
+ *
1195
+ * this method was renamed because of a conflict with a DOM type,
1196
+ * which was causing problems with the documentation generator.
1197
+ */
1198
+ export interface SheetScrollOptions {
1199
+
1200
+ /** scroll in x-direction. defaults to true. */
1201
+ x?: boolean;
1202
+
1203
+ /** scroll in y-direction. defaults to true. */
1204
+ y?: boolean;
1205
+
1206
+ /**
1207
+ * smooth scrolling, if supported. we use scrollTo so support is as here:
1208
+ * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
1209
+ */
1210
+ smooth?: boolean;
1211
+ }
1212
+
1213
+ /**
1214
+ * function type used for filtering tables
1215
+ */
1216
+ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: CellStyle) => boolean;
1217
+
1218
+ /**
1219
+ * serialized type is a composite of expression/range. we determine
1220
+ * what it is when parsing the expression. this simplifies passing these
1221
+ * things around.
1222
+ *
1223
+ * (named expressions and ranges they have slightly different behavior,
1224
+ * which is why we have a distinction at all).
1225
+ *
1226
+ */
1227
+ export interface SerializedNamed {
1228
+ name: string;
1229
+
1230
+ /** expression or address/area */
1231
+ expression: string;
1232
+
1233
+ /** scope is a sheet name (not ID) */
1234
+ scope?: string;
1235
+
1236
+ /**
1237
+ * adding type. this is optional, it's not used by tooling. it's
1238
+ * just for informational purpopses for clients.
1239
+ */
1240
+ type?: 'range' | 'expression';
1241
+ }
1242
+ export interface FreezePane {
1243
+ rows: number;
1244
+ columns: number;
1245
+ }
1246
+ export interface CondifionalFormatExpressionOptions {
1247
+ style: CellStyle;
1248
+ expression: string;
1249
+ options?: EvaluateOptions;
1250
+ }
1251
+ export interface ConditionalFormatGradientOptions {
1252
+
1253
+ /** property defaults to fill */
1254
+ property?: 'fill' | 'text';
1255
+
1256
+ /** defaults to RGB */
1257
+ color_space?: 'HSL' | 'RGB';
1258
+
1259
+ /** gradient stops, required */
1260
+ stops: Array<{
1261
+ value: number;
1262
+ color: Color;
1263
+ }>;
1264
+
1265
+ /** min and max are optional. if not provided, we use the min/max of the range of data. */
1266
+ min?: number;
1267
+
1268
+ /** min and max are optional. if not provided, we use the min/max of the range of data. */
1269
+ max?: number;
1270
+ }
1271
+ export type StandardGradient = 'red-green' | 'green-red' | 'red-yellow-green' | 'green-yellow-red';
1272
+ export interface ConditionalFormatDataBarOptions {
1273
+
1274
+ /** min and max are optional. if not provided, we use the min/max of the range of data. */
1275
+ min?: number;
1276
+
1277
+ /** min and max are optional. if not provided, we use the min/max of the range of data. */
1278
+ max?: number;
1279
+
1280
+ /** */
1281
+ fill: Color;
1282
+
1283
+ /** */
1284
+ negative?: Color;
1285
+
1286
+ /** */
1287
+ hide_values?: boolean;
1288
+ }
1289
+ export interface ConditionalFormatCellMatchOptions {
1290
+ style: CellStyle;
1291
+ expression: string;
1292
+ options?: EvaluateOptions;
1293
+ }
1294
+ export interface ConditionalFormatDuplicateValuesOptions {
1295
+ style: CellStyle;
1296
+
1297
+ /** true to highlight unique cells, false to highlight duplicates. defaults to false. */
1298
+ unique?: boolean;
1299
+ }
1300
+
1301
+ /**
1302
+ * union, plus we're adding a state used to track application.
1303
+ * that state is serialized if it's true.
1304
+ * we also add an internal field that will be type-specific, and not serialized.
1305
+ *
1306
+ * ...everybody has a vertex now, we could standardize it
1307
+ *
1308
+ * update: adding a priority field, optional
1309
+ *
1310
+ */
1311
+ export type ConditionalFormat = {
1312
+ internal?: unknown;
1313
+ priority?: number;
1314
+ } & (ConditionalFormatDuplicateValues | ConditionalFormatExpression | ConditionalFormatCellMatch | ConditionalFormatGradient | ConditionalFormatDataBar);
1315
+
1316
+ /**
1317
+ * conditional format predicated on an expression. if the expression
1318
+ * evaluates to true, we apply the style. otherwise no.
1319
+ */
1320
+ export interface ConditionalFormatExpression extends CondifionalFormatExpressionOptions {
1321
+ type: 'expression';
1322
+ area: IArea;
1323
+ }
1324
+ export interface ConditionalFormatGradient extends ConditionalFormatGradientOptions {
1325
+ type: 'gradient';
1326
+ area: IArea;
1327
+ }
1328
+ export interface ConditionalFormatDataBar extends ConditionalFormatDataBarOptions {
1329
+ type: 'data-bar';
1330
+ area: IArea;
1331
+ }
1332
+ export interface ConditionalFormatCellMatch extends ConditionalFormatCellMatchOptions {
1333
+ type: 'cell-match';
1334
+ area: IArea;
1335
+ }
1336
+ export interface ConditionalFormatDuplicateValues extends ConditionalFormatDuplicateValuesOptions {
1337
+ type: 'duplicate-values';
1338
+ area: IArea;
1339
+ }
1340
+
1341
+ /**
1342
+ * Structure represents a 2d range of cells.
1343
+ */
1344
+ export interface IArea {
1345
+ start: ICellAddress;
1346
+ end: ICellAddress;
1347
+ }
1348
+ export type Color = ThemeColor | HTMLColor | NullColor;
1349
+
1350
+ /**
1351
+ * style properties applied to a single cell, row, column, or sheet.
1352
+ * when rendering a cell, we composite all styles that might apply.
1353
+ */
1354
+ export interface CellStyle {
1355
+
1356
+ /** horizontal align defaults to left */
1357
+ horizontal_align?: HorizontalAlign;
1358
+
1359
+ /** vertical align defaults to bottom */
1360
+ vertical_align?: VerticalAlign;
1361
+
1362
+ /** representation for NaN */
1363
+ nan?: string;
1364
+
1365
+ /** number format, either a symbolic name like "General" or a format string */
1366
+ number_format?: string;
1367
+
1368
+ /** wrap text */
1369
+ wrap?: boolean;
1370
+
1371
+ /**
1372
+ * font size. we recommend using relative font sizes (either % or em)
1373
+ * which will be relative to the theme font size.
1374
+ */
1375
+ font_size?: FontSize;
1376
+
1377
+ /** font face. this can be a comma-delimited list, like CSS */
1378
+ font_face?: string;
1379
+
1380
+ /** flag */
1381
+ bold?: boolean;
1382
+
1383
+ /** flag */
1384
+ italic?: boolean;
1385
+
1386
+ /** flag */
1387
+ underline?: boolean;
1388
+
1389
+ /** flag */
1390
+ strike?: boolean;
1391
+
1392
+ /** border weight */
1393
+ border_top?: number;
1394
+
1395
+ /** border weight */
1396
+ border_right?: number;
1397
+
1398
+ /** border weight */
1399
+ border_left?: number;
1400
+
1401
+ /** border weight */
1402
+ border_bottom?: number;
1403
+
1404
+ /** text color */
1405
+ text?: Color;
1406
+
1407
+ /** background color */
1408
+ fill?: Color;
1409
+
1410
+ /** border color */
1411
+ border_top_fill?: Color;
1412
+
1413
+ /** border color */
1414
+ border_left_fill?: Color;
1415
+
1416
+ /** border color */
1417
+ border_right_fill?: Color;
1418
+
1419
+ /** border color */
1420
+ border_bottom_fill?: Color;
1421
+
1422
+ /** text indent */
1423
+ indent?: number;
1424
+
1425
+ /**
1426
+ * cell is locked for editing
1427
+ */
1428
+ locked?: boolean;
1429
+ }
1430
+
1431
+ /** horizontal align constants for cell style */
1432
+ export type HorizontalAlign = '' | 'left' | 'center' | 'right';
1433
+
1434
+ /** vertical align constants for cell style */
1435
+ export type VerticalAlign = '' | 'top' | 'bottom' | 'middle';
1436
+ export type ThemeColorType = 'Background' | 'Text' | 'Background2' | 'Text2' | 'Accent' | 'Accent2' | 'Accent3' | 'Accent4' | 'Accent5' | 'Accent6';
1437
+
1438
+ /**
1439
+ * font size for cell style. we generally prefer relative sizes
1440
+ * (percent or em) because they are relative to the default theme
1441
+ * size, which might be different on different platforms.
1442
+ */
1443
+ export interface FontSize {
1444
+ unit: 'pt' | 'px' | 'em' | '%';
1445
+ value: number;
1446
+ }
1447
+ export interface HTMLColor {
1448
+ text: string;
1449
+ }
1450
+ export interface ThemeColor {
1451
+ theme: number | ThemeColorType;
1452
+ tint?: number;
1453
+ }
1454
+ export interface NullColor {
1455
+ }
1456
+ export declare const ThemeColorIndex: (color: ThemeColor) => number;
1457
+ export declare const IsHTMLColor: (color?: Color) => color is HTMLColor;
1458
+ export declare const IsThemeColor: (color?: Color) => color is ThemeColor;
1459
+ export declare const IsDefinedColor: (color?: Color) => color is (ThemeColor | HTMLColor);
1460
+
1461
+ /** temp until we have a solid type */
1462
+ export declare const IsFunctionType: (value: unknown) => boolean;
1463
+
1464
+ /**
1465
+ * options for the evaluate function
1466
+ */
1467
+ export interface EvaluateOptions {
1468
+
1469
+ /**
1470
+ * argument separator to use when parsing input. set this option to
1471
+ * use a consistent argument separator independent of current locale.
1472
+ */
1473
+ argument_separator?: ',' | ';';
1474
+
1475
+ /**
1476
+ * allow R1C1-style references. the Evaluate function cannot use
1477
+ * relative references (e.g. R[-1]C[0]), so those will always fail.
1478
+ * however it may be useful to use direct R1C1 references (e.g. R3C4),
1479
+ * so we optionally support that behind this flag.
1480
+ */
1481
+ r1c1?: boolean;
1482
+ }
1483
+
1484
+ /**
1485
+ * options for serializing data
1486
+ */
1487
+ export interface SerializeOptions {
1488
+
1489
+ /** optimize for size */
1490
+ optimize?: 'size' | 'speed';
1491
+
1492
+ /** include the rendered/calculated value in export */
1493
+ rendered_values?: boolean;
1494
+
1495
+ /** translate colors to xlsx-friendly values */
1496
+ export_colors?: boolean;
1497
+
1498
+ /** export cells that have no value, but have a border or background color */
1499
+ decorated_cells?: boolean;
1500
+
1501
+ /** prune unused rows/columns */
1502
+ shrink?: boolean;
1503
+
1504
+ /**
1505
+ * include tables. tables will be serialized in the model, so we can
1506
+ * drop them from cells. but you can leave them in if that's useful.
1507
+ */
1508
+ tables?: boolean;
1509
+
1510
+ /** share resources (images, for now) to prevent writing data URIs more than once */
1511
+ share_resources?: boolean;
1512
+
1513
+ /**
1514
+ * if a function has an export() handler, call that
1515
+ */
1516
+ export_functions?: boolean;
1517
+ }
1518
+ export type AnnotationType = 'treb-chart' | 'image' | 'textbox' | 'external';
1519
+ export interface Point {
1520
+ x: number;
1521
+ y: number;
1522
+ }
1523
+
1524
+ /** structure represents rectangle coordinates */
1525
+ export interface IRectangle {
1526
+ top: number;
1527
+ left: number;
1528
+ width: number;
1529
+ height: number;
1530
+ }
1531
+ export type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
1532
+
1533
+ /**
1534
+ * Complex number type
1535
+ */
1536
+ export interface Complex {
1537
+ real: number;
1538
+ imaginary: number;
1539
+ }
1540
+
1541
+ /**
1542
+ * dimensioned quantity: 3.2 m/s, 2kg, 5m, &c.
1543
+ */
1544
+ export interface DimensionedQuantity {
1545
+ value: number;
1546
+ unit: string;
1547
+ }
1548
+
1549
+ /**
1550
+ * composite styling for tables.
1551
+ */
1552
+ export interface TableTheme {
1553
+
1554
+ /** the first row in a table, showing column titles. */
1555
+ header?: CellStyle;
1556
+
1557
+ /**
1558
+ * odd rows in the table. we count the title row as zero, so
1559
+ * the first row in the table containing data is 1, hence odd.
1560
+ */
1561
+ odd?: CellStyle;
1562
+
1563
+ /**
1564
+ * even rows in the table.
1565
+ */
1566
+ even?: CellStyle;
1567
+
1568
+ /**
1569
+ * styling for the totals row, if included. this will be the last
1570
+ * row in the table.
1571
+ */
1572
+ total?: CellStyle;
1573
+ }
1574
+
1575
+ /**
1576
+ * type represents a reference passed in to API functions. it can be an
1577
+ * address object, or a string.
1578
+ */
1579
+ export type AddressReference = string | ICellAddress;
1580
+
1581
+ /**
1582
+ * type represents a reference passed in to API functions. it can be an
1583
+ * address object, an area (range) object, or a string.
1584
+ */
1585
+ export type RangeReference = string | ICellAddress | IArea;
1586
+ export interface TableSortOptions {
1587
+
1588
+ /**
1589
+ * when sorting, column is relative to the table (and 0-based). so the
1590
+ * first column in the table is 0, regardless of where the table is in
1591
+ * the spreadsheet. defaults to 0, if not specified.
1592
+ */
1593
+ column: number;
1594
+
1595
+ /**
1596
+ * sort type. defaults to 'auto'. 'auto' looks at the values in the column,
1597
+ * and uses text sort if there are more strings, or numeric if there are
1598
+ * more numbers. if it's even, sorts as text.
1599
+ */
1600
+ type: TableSortType;
1601
+
1602
+ /** ascending sort. defaults to true. */
1603
+ asc: boolean;
1604
+ }
1605
+ export type TableSortType = 'text' | 'numeric' | 'auto';
1606
+
1607
+ /** clipboard data is a 2d array */
1608
+ export type ClipboardData = ClipboardDataElement[][];
1609
+
1610
+ /**
1611
+ * optional paste options. we can paste formulas or values, and we
1612
+ * can use the source style, target style, or just use the source
1613
+ * number formats.
1614
+ */
1615
+ export interface PasteOptions {
1616
+
1617
+ /**
1618
+ * when clipboard data includes formulas, optionally paste calculated
1619
+ * values instead of the original formulas. defaults to false.
1620
+ */
1621
+ values?: boolean;
1622
+
1623
+ /**
1624
+ * when pasting data from the clipboard, we can copy formatting/style
1625
+ * from the original data, or we can retain the target range formatting
1626
+ * and just paste data. a third option allows pasting source number
1627
+ * formats but dropping other style information.
1628
+ *
1629
+ * defaults to "source", meaning paste source styles.
1630
+ */
1631
+ formatting?: 'source' | 'target' | 'number-formats';
1632
+ }
1633
+
1634
+ /**
1635
+ * this is a structure for copy/paste data. clipboard data may include
1636
+ * relative formauls and resolved styles, so it's suitable for pasting into
1637
+ * other areas of the spreadsheet.
1638
+ */
1639
+ export interface ClipboardDataElement {
1640
+
1641
+ /** calculated cell value */
1642
+ calculated: CellValue;
1643
+
1644
+ /** the actual cell value or formula */
1645
+ value: CellValue;
1646
+
1647
+ /** cell style. this may include row/column styles from the copy source */
1648
+ style?: CellStyle;
1649
+
1650
+ /** area. if this cell is part of an array, this is the array range */
1651
+ area?: IArea;
1652
+ }
1653
+ export declare type BorderConstants = "none" | "all" | "outside" | "top" | "bottom" | "left" | "right";
1654
+
1655
+ /**
1656
+ * options for the SetRange method
1657
+ */
1658
+ export interface SetRangeOptions {
1659
+
1660
+ /** transpose rectangular array before inserting */
1661
+ transpose?: boolean;
1662
+
1663
+ /** recycle values (R-style) */
1664
+ recycle?: boolean;
1665
+
1666
+ /** apply as an array (as if you pressed ctrl+shift+enter) */
1667
+ array?: boolean;
1668
+
1669
+ /** spill over */
1670
+ spill?: boolean;
1671
+
1672
+ /**
1673
+ * argument separator to use when parsing the input formula. set this
1674
+ * option to call SetRange with a consistent argument separator,
1675
+ * independent of current locale.
1676
+ */
1677
+ argument_separator?: ',' | ';';
1678
+
1679
+ /**
1680
+ * allow R1C1-style references; these can be either absolute
1681
+ * addresses (e.g. R2C4) or relative to the cell (e.g. R[-3]C[0]).
1682
+ */
1683
+ r1c1?: boolean;
1684
+ }
1685
+ export interface ExternalEditorConfig {
1686
+
1687
+ /**
1688
+ * list of dependencies to highlight. we support undefined entries in
1689
+ * this list so you can use the result of `EmbeddedSpreadsheet.Resolve`,
1690
+ * which may return undefined.
1691
+ */
1692
+ dependencies: DependencyList;
1693
+
1694
+ /**
1695
+ * this callback will be called when the selection changes in the
1696
+ * spreadsheet and this external editor is active. return an updated
1697
+ * list of dependencies to highlight.
1698
+ *
1699
+ * NOTE: this is currently synchronous, but don't rely on that. it
1700
+ * might switch to async in the future depending on how it works in
1701
+ * practice.
1702
+ */
1703
+ update: ExternalEditorCallback;
1704
+
1705
+ /**
1706
+ * a list of nodes that will serve as editors. when you attach, we will do
1707
+ * an initial pass of context highlighting. we highlight on text changes
1708
+ * and insert references if you make a selection in the spreadsheet while
1709
+ * an editor is focused.
1710
+ */
1711
+ nodes: HTMLElement[];
1712
+
1713
+ /**
1714
+ * assume that we're editing a formula. does not require leading `=`.
1715
+ * defaults to `true` for historical reasons.
1716
+ */
1717
+ assume_formula?: boolean;
1718
+ }
1719
+ export type DependencyList = Array<IArea | ICellAddress | undefined>;
1720
+ export type ExternalEditorCallback = (selection?: string) => DependencyList | undefined;
1721
+
1722
+ /**
1723
+ * this is the document type used by TREB. it has a lot of small variations
1724
+ * for historical reasons and backwards compatibility. usually it's preferable
1725
+ * to let TREB create and manage these documents rather than creating them
1726
+ * manually.
1727
+ */
1728
+ export interface TREBDocument {
1729
+
1730
+ /** app name, as identifier */
1731
+ app: string;
1732
+
1733
+ /** app version. we'll warn if you use a file from a newer version */
1734
+ version: string;
1735
+
1736
+ /**
1737
+ * revision number. this is a value that increments on any document change,
1738
+ * useful for checking if a document is "dirty".
1739
+ */
1740
+ revision?: number;
1741
+
1742
+ /** document name */
1743
+ name?: string;
1744
+
1745
+ /**
1746
+ * opaque user data. we don't read or parse this, but applications can
1747
+ * use it to store arbitrary data.
1748
+ */
1749
+ user_data?: unknown;
1750
+
1751
+ /**
1752
+ * per-sheet data. this should be an array, but for historical reasons
1753
+ * we still support a single sheet outside of an array.
1754
+ */
1755
+ sheet_data?: SerializedSheet | SerializedSheet[];
1756
+
1757
+ /** document decimal mark */
1758
+ decimal_mark?: '.' | ',';
1759
+
1760
+ /** active sheet. if unset we'll show the first un-hidden sheet */
1761
+ active_sheet?: number;
1762
+
1763
+ /**
1764
+ * this document includes rendered calculated values. using this lets the
1765
+ * app show a document faster, without requiring an initial calculation.
1766
+ */
1767
+ rendered_values?: boolean;
1768
+
1769
+ /** document named ranges @deprecated */
1770
+ named_ranges?: Record<string, IArea>;
1771
+
1772
+ /** document named expressions @deprecated */
1773
+ named_expressions?: SerializedNamedExpression[];
1774
+
1775
+ /**
1776
+ * new consolidated named ranges & expressions
1777
+ */
1778
+ named?: SerializedNamed[];
1779
+
1780
+ /** document macro functions */
1781
+ macro_functions?: SerializedMacroFunction[];
1782
+
1783
+ /** document tables */
1784
+ tables?: Table[];
1785
+
1786
+ /** document shared resources (usually images) */
1787
+ shared_resources?: Record<string, string>;
1788
+ }
1789
+ export declare type LoadSource = "drag-and-drop" | "local-file" | "network-file" | "local-storage" | "inline-document" | "undo";
1790
+
1791
+ /**
1792
+ * EmbeddedSheetEvent is a discriminated union. Switch on the `type` field
1793
+ * of the event.
1794
+ */
1795
+ export type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | ThemeChangeEvent | ViewChangeEvent | DataChangeEvent | FocusViewEvent | SelectionEvent | ResizeEvent | AnnotationSelectionEvent;
1796
+
1797
+ /**
1798
+ * options when inserting a table into a sheet
1799
+ */
1800
+ export interface InsertTableOptions {
1801
+
1802
+ /**
1803
+ * include a totals/summation row. this impacts the layout and styling:
1804
+ * totals row have a unique style and are not included when sorting.
1805
+ * defaults to true.
1806
+ */
1807
+ totals_row?: boolean;
1808
+
1809
+ /**
1810
+ * show a sort button in table headers. defaults to true.
1811
+ */
1812
+ sortable?: boolean;
1813
+
1814
+ /**
1815
+ * base theme color, or a set of styles for the table. useful values for
1816
+ * theme color are accent colors 4 (the default), 5, 7 and 9.
1817
+ */
1818
+ theme?: number | TableTheme;
1819
+ }
1820
+ export interface ResizeEvent {
1821
+ type: 'resize';
1822
+ }
1823
+ export declare type LoadType = "treb" | "csv" | "xlsx";
1824
+
1825
+ /**
1826
+ * This event is sent when the view changes -- at the moment, that only
1827
+ * means the view scale has been changed. We might use it in the future
1828
+ * for other things.
1829
+ */
1830
+ export interface ViewChangeEvent {
1831
+ type: 'view-change';
1832
+ }
1833
+
1834
+ /**
1835
+ * this event is sent when the theme is updated. it's intended for any
1836
+ * subscribers to update corresponding colors or fonts.
1837
+ */
1838
+ export interface ThemeChangeEvent {
1839
+ type: 'theme-change';
1840
+ }
1841
+
1842
+ /**
1843
+ * This event is sent when a document is loaded, and also on undo. The
1844
+ * source field can help determine if it was triggered by an undo operation.
1845
+ */
1846
+ export interface DocumentLoadEvent {
1847
+ type: 'load';
1848
+ source?: LoadSource;
1849
+ file_type?: LoadType;
1850
+ }
1851
+
1852
+ /**
1853
+ * This event is sent when the document is reset.
1854
+ */
1855
+ export interface DocumentResetEvent {
1856
+ type: 'reset';
1857
+ }
1858
+
1859
+ /**
1860
+ * This event is sent when data in the spreadsheet changes, but there are
1861
+ * no structural or cell changes. For example, the `RAND` function returns
1862
+ * a new value on every calculation, but the function itself does not change.
1863
+ */
1864
+ export interface DataChangeEvent {
1865
+ type: 'data';
1866
+ }
1867
+
1868
+ /**
1869
+ * This event is sent when the value of a cell changes, or when the document
1870
+ * structure chages. Structure changes might be inserting/deleting rows or
1871
+ * columns, or adding/removing a sheet.
1872
+ */
1873
+ export interface DocumentChangeEvent {
1874
+ type: 'document-change';
1875
+ }
1876
+
1877
+ /**
1878
+ * This event is sent when the spreadsheet selection changes. Use the
1879
+ * `GetSelection` method to get the address of the current selection.
1880
+ */
1881
+ export interface SelectionEvent {
1882
+ type: 'selection';
1883
+ }
1884
+
1885
+ /**
1886
+ * this event is used when an annotation is selected. we're not changing
1887
+ * the original selection event, because I don't want to break anything.
1888
+ */
1889
+ export interface AnnotationSelectionEvent {
1890
+ type: 'annotation-selection';
1891
+ }
1892
+
1893
+ /**
1894
+ * This event is sent when the focused view changes, if you have more
1895
+ * than one view.
1896
+ */
1897
+ export interface FocusViewEvent {
1898
+ type: 'focus-view';
1899
+ }
1900
+ export interface SerializedSheet {
1901
+
1902
+ /** cell data */
1903
+ data: SerializedCellData;
1904
+
1905
+ /** top-level sheet style, if any */
1906
+ sheet_style: CellStyle;
1907
+
1908
+ /** row count */
1909
+ rows: number;
1910
+
1911
+ /** column count */
1912
+ columns: number;
1913
+
1914
+ /**
1915
+ * cell styles is for empty cells that have styling
1916
+ */
1917
+ cell_styles: CellStyleRecord[];
1918
+
1919
+ /**
1920
+ * @deprecated use `styles` instead
1921
+ */
1922
+ cell_style_refs?: CellStyle[];
1923
+
1924
+ /**
1925
+ * new implementation
1926
+ */
1927
+ styles?: CellStyle[];
1928
+
1929
+ /**
1930
+ * per-row styles
1931
+ */
1932
+ row_style: Record<number, CellStyle | number>;
1933
+
1934
+ /**
1935
+ * per-column styles
1936
+ */
1937
+ column_style: Record<number, CellStyle | number>;
1938
+
1939
+ /**
1940
+ * @deprecated no one uses this anymore and it's weird
1941
+ */
1942
+ row_pattern?: CellStyle[];
1943
+
1944
+ /** default for new rows */
1945
+ default_row_height?: number;
1946
+
1947
+ /** default for new columns */
1948
+ default_column_width?: number;
1949
+
1950
+ /** list of row heights. we use a Record instead of an array because it's sparse */
1951
+ row_height?: Record<number, number>;
1952
+
1953
+ /** list of column widths. we use a Record instead of an array because it's sparse */
1954
+ column_width?: Record<number, number>;
1955
+
1956
+ /**
1957
+ * @deprecated these were moved to the containing document
1958
+ */
1959
+ named_ranges?: Record<string, IArea>;
1960
+ freeze?: FreezePane;
1961
+
1962
+ /** sheet ID, for serializing references */
1963
+ id?: number;
1964
+
1965
+ /** sheet name */
1966
+ name?: string;
1967
+
1968
+ /** tab color */
1969
+ tab_color?: Color;
1970
+
1971
+ /** current active selection */
1972
+ selection: SerializedGridSelection;
1973
+
1974
+ /** */
1975
+ annotations?: Partial<AnnotationData>[];
1976
+
1977
+ /** current scroll position */
1978
+ scroll?: ScrollOffset;
1979
+
1980
+ /** visible flag. we only support visible/hidden */
1981
+ visible?: boolean;
1982
+
1983
+ /** testing */
1984
+ background_image?: string;
1985
+ }
1986
+ export interface ScrollOffset {
1987
+ x: number;
1988
+ y: number;
1989
+ }
1990
+ export interface CellStyleRecord {
1991
+ row: number;
1992
+ column: number;
1993
+ ref: number;
1994
+ rows?: number;
1995
+ }
1996
+ export type SerializedCellData = CellDataWithAddress[] | NestedRowData[] | NestedColumnData[];
1997
+ export interface BaseCellData {
1998
+ value: CellValue;
1999
+ style_ref?: number;
2000
+ calculated?: CellValue;
2001
+ table?: Table;
2002
+ area?: IArea;
2003
+ merge_area?: IArea;
2004
+ calculated_type?: SerializedValueType;
2005
+ note?: string;
2006
+ hyperlink?: string;
2007
+ type?: SerializedValueType;
2008
+ sheet_id?: number;
2009
+ spill?: IArea;
2010
+ }
2011
+
2012
+ /**
2013
+ * this type is for serialized data that includes the row and column
2014
+ * in each cell. this was the original serialized data type, and is
2015
+ * still supported. current serialization will group data into rows or
2016
+ * columns, whichever results in a smaller overall serialized representation.
2017
+ */
2018
+ export interface CellDataWithAddress extends BaseCellData {
2019
+ row: number;
2020
+ column: number;
2021
+ }
2022
+ export interface NestedCellData {
2023
+ cells: BaseCellData[];
2024
+ }
2025
+
2026
+ /**
2027
+ * this type is for serialized data that is grouped by row, with each
2028
+ * cell referencing a column in the spreadsheet.
2029
+ */
2030
+ export interface CellDataWithColumn extends BaseCellData {
2031
+ column: number;
2032
+ }
2033
+ export interface NestedRowData extends NestedCellData {
2034
+ row: number;
2035
+ cells: CellDataWithColumn[];
2036
+ }
2037
+
2038
+ /**
2039
+ * this type is for serialized data that is grouped by column, with each
2040
+ * cell referencing a row in the spreadsheet.
2041
+ */
2042
+ export interface CellDataWithRow extends BaseCellData {
2043
+ row: number;
2044
+ }
2045
+ export interface NestedColumnData extends NestedCellData {
2046
+ column: number;
2047
+ cells: CellDataWithRow[];
2048
+ }
2049
+
2050
+ /**
2051
+ * struct representing a table
2052
+ */
2053
+ export interface Table {
2054
+
2055
+ /**
2056
+ * table must have a name
2057
+ */
2058
+ name: string;
2059
+
2060
+ /** table area */
2061
+ area: IArea;
2062
+
2063
+ /**
2064
+ * table column headers. normalize case before inserting.
2065
+ */
2066
+ columns?: string[];
2067
+
2068
+ /**
2069
+ * table has a totals row. this impacts layout and what's included
2070
+ * in the range when you refer to a column. also on import/export, the
2071
+ * AutoFilter element should exclude the totals row.
2072
+ *
2073
+ * NOTE: xlsx actually uses an integer for this -- can it be > 1?
2074
+ */
2075
+ totals_row?: boolean;
2076
+
2077
+ /**
2078
+ * table is sortable. defaults to true. if false, disables UI sorting.
2079
+ */
2080
+ sortable?: boolean;
2081
+
2082
+ /**
2083
+ * theme for table. we have a default, but you can set explicitly.
2084
+ */
2085
+ theme?: TableTheme;
2086
+
2087
+ /**
2088
+ * sort data. sorts are hard, meaning we actually move data around.
2089
+ * (not meaning difficult). we may keep track of the last sort so we
2090
+ * can toggle asc/desc, for example. atm this will not survive serialization.
2091
+ */
2092
+ sort?: TableSortOptions;
2093
+ }
2094
+
2095
+ /**
2096
+ * string types for import/export
2097
+ *
2098
+ * @internalRemarks
2099
+ *
2100
+ * temporarily switching to literal, see what happens to API
2101
+ *
2102
+ */
2103
+ export type SerializedValueType = // typeof ValueTypeList[number];
2104
+ 'undefined' | 'formula' | 'string' | 'number' | 'boolean' | 'object' | 'function' | 'error' | 'complex' | 'array' | 'dimensioned_quantity';
2105
+
2106
+ /**
2107
+ * temporarily splitting into a serialized version that uses IArea instead
2108
+ * of Area. we should do this for the actual selection type, but it breaks
2109
+ * too many things atm to do that immediately. TODO/FIXME.
2110
+ */
2111
+ export interface SerializedGridSelection {
2112
+
2113
+ /** target or main cell in the selection */
2114
+ target: ICellAddress;
2115
+
2116
+ /** selection area */
2117
+ area: IArea;
2118
+
2119
+ /** there is nothing selected, even though this object exists */
2120
+ empty?: boolean;
2121
+
2122
+ /** for cacheing addtional selections. optimally don't serialize */
2123
+ rendered?: boolean;
2124
+ }
2125
+ export type AnnotationData = AnnotationChartData | AnnotationImageData | AnnotationExternalData | AnnotationTextBoxData;
2126
+ export interface ImageSize {
2127
+ width: number;
2128
+ height: number;
2129
+ }
2130
+ export interface ImageAnnotationData {
2131
+ src: string;
2132
+
2133
+ /**/
2134
+ scale?: string;
2135
+ original_size?: ImageSize;
2136
+ }
2137
+
2138
+ /**
2139
+ * splitting persisted data from the annotation class. that class might
2140
+ * disappear in the future in favor of just a type. this interface should
2141
+ * fully match the old Partial<Annotation> we used before. note that we
2142
+ * used to define values for all members, but they may now be undefined
2143
+ * because the Annotation class as a Partial instance of this data.
2144
+ *
2145
+ * conceptually annotation was originally intended to support types other
2146
+ * than our own charts and images, but no one ever used it. so we could
2147
+ * lock down the `type` field if we wanted to. or perhaps have an `external`
2148
+ * type with opaque data. TODO.
2149
+ *
2150
+ */
2151
+ export interface AnnotationDataBase {
2152
+
2153
+ /** the new layout, persisted and takes preference over the old one */
2154
+ layout?: AnnotationLayout;
2155
+
2156
+ /**
2157
+ * adding cell style as a convenient store for font stack; atm we are
2158
+ * ignoring everything but the font_face attribute
2159
+ */
2160
+ style?: CellStyle;
2161
+
2162
+ /**
2163
+ * the old layout used rectangles, and we need to keep support for
2164
+ * that. this is not the layout rectangle. this rectangle is just
2165
+ * for serialization/deserialization. the actual rectangle is maintained
2166
+ * in the Annotation class.
2167
+ */
2168
+ rect?: Partial<IRectangle>;
2169
+
2170
+ /** annotation can be resized. this is advisory, for UI */
2171
+ resizable: boolean;
2172
+
2173
+ /** annotation can be moved. this is advisory, for UI */
2174
+ movable: boolean;
2175
+
2176
+ /** annotation can be removed/deleted. this is advisory, for UI */
2177
+ removable: boolean;
2178
+
2179
+ /** annotation can be selected. this is advisory, for UI */
2180
+ selectable: boolean;
2181
+
2182
+ /** move when resizing/inserting rows/columns */
2183
+ move_with_cells: boolean;
2184
+
2185
+ /** resize when resizing/inserting rows/columns */
2186
+ resize_with_cells: boolean;
2187
+
2188
+ /**
2189
+ * optional formula. the formula will be updated on structure events
2190
+ * (insert/delete row/column).
2191
+ */
2192
+ formula: string;
2193
+
2194
+ /**
2195
+ * extent, useful for exporting. we could probably serialize this,
2196
+ * just be sure to clear it when layout changes so it will be
2197
+ * recalculated.
2198
+ *
2199
+ * the idea is to know the bottom/right row/column of the annotation,
2200
+ * so when we preserve/restore the sheet we don't trim those rows/columns.
2201
+ * they don't need any data, but it just looks bad. we can do this
2202
+ * dynamically but since it won't change all that often, we might
2203
+ * as well precalculate.
2204
+ */
2205
+ extent: ICellAddress;
2206
+ }
2207
+ export interface AnnotationImageData extends AnnotationDataBase {
2208
+ type: 'image';
2209
+ data: ImageAnnotationData;
2210
+ }
2211
+ export interface AnnotationChartData extends AnnotationDataBase {
2212
+ type: 'treb-chart';
2213
+ }
2214
+ export interface AnnotationTextBoxData extends AnnotationDataBase {
2215
+ type: 'textbox';
2216
+
2217
+ /**
2218
+ * @internalRemarks
2219
+ * what's with this weird structure? did we inherit it? can we clean it up?
2220
+ */
2221
+ data: {
2222
+ style?: CellStyle;
2223
+ paragraphs: {
2224
+ style?: CellStyle;
2225
+ content: {
2226
+ text: string;
2227
+ style?: CellStyle;
2228
+ }[];
2229
+ }[];
2230
+ };
2231
+ }
2232
+ export interface AnnotationExternalData extends AnnotationDataBase {
2233
+ type: 'external';
2234
+ data: Record<string, string>;
2235
+ }
2236
+
2237
+ /**
2238
+ * represents the layout of an annotation, reference to the sheet
2239
+ */
2240
+ export interface AnnotationLayout {
2241
+ tl: Corner;
2242
+ br: Corner;
2243
+ }
2244
+
2245
+ /**
2246
+ * offset from corner, as % of cell
2247
+ */
2248
+ export interface AddressOffset {
2249
+ x: number;
2250
+ y: number;
2251
+ }
2252
+
2253
+ /**
2254
+ * represents one corner of a layout rectangle
2255
+ */
2256
+ export interface Corner {
2257
+ address: ICellAddress;
2258
+ offset: AddressOffset;
2259
+ }
2260
+ export interface SerializedMacroFunction {
2261
+ name: string;
2262
+ function_def: string;
2263
+ argument_names?: string[];
2264
+ description?: string;
2265
+ }
2266
+
2267
+ /**
2268
+ * this type is no longer in use, but we retain it to parse old documents
2269
+ * that use it.
2270
+ *
2271
+ * @deprecated
2272
+ */
2273
+ export interface SerializedNamedExpression {
2274
+ name: string;
2275
+ expression: string;
2276
+ }
2277
+
2278
+ /**
2279
+ * options for exporting CSV/TSV
2280
+ */
2281
+ export interface ExportOptions {
2282
+
2283
+ /** comma or tab */
2284
+ delimiter?: ',' | '\t';
2285
+
2286
+ /** optionally choose a sheet to export (defaults to active sheet) */
2287
+ sheet?: string | number;
2288
+
2289
+ /** export formulas not values */
2290
+ formulas?: boolean;
2291
+
2292
+ /** use number formats when exporting numbers */
2293
+ formatted?: boolean;
2294
+ }