@trebco/treb 23.6.5 → 25.0.0-rc2

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 (217) hide show
  1. package/.eslintignore +8 -0
  2. package/.eslintrc.js +164 -0
  3. package/README-shadow-DOM.md +88 -0
  4. package/README.md +37 -130
  5. package/api-config.json +29 -0
  6. package/api-generator/api-generator-types.ts +82 -0
  7. package/api-generator/api-generator.ts +1172 -0
  8. package/api-generator/package.json +3 -0
  9. package/build/treb-spreadsheet.mjs +14 -0
  10. package/{treb.d.ts → build/treb.d.ts} +323 -271
  11. package/esbuild-custom-element.mjs +336 -0
  12. package/esbuild.js +305 -0
  13. package/package.json +49 -14
  14. package/treb-base-types/package.json +5 -0
  15. package/treb-base-types/src/api_types.ts +36 -0
  16. package/treb-base-types/src/area.ts +583 -0
  17. package/treb-base-types/src/basic_types.ts +45 -0
  18. package/treb-base-types/src/cell.ts +612 -0
  19. package/treb-base-types/src/cells.ts +1066 -0
  20. package/treb-base-types/src/color.ts +124 -0
  21. package/treb-base-types/src/import.ts +71 -0
  22. package/treb-base-types/src/index-standalone.ts +29 -0
  23. package/treb-base-types/src/index.ts +42 -0
  24. package/treb-base-types/src/layout.ts +47 -0
  25. package/treb-base-types/src/localization.ts +187 -0
  26. package/treb-base-types/src/rectangle.ts +145 -0
  27. package/treb-base-types/src/render_text.ts +72 -0
  28. package/treb-base-types/src/style.ts +545 -0
  29. package/treb-base-types/src/table.ts +109 -0
  30. package/treb-base-types/src/text_part.ts +54 -0
  31. package/treb-base-types/src/theme.ts +608 -0
  32. package/treb-base-types/src/union.ts +152 -0
  33. package/treb-base-types/src/value-type.ts +164 -0
  34. package/treb-base-types/style/resizable.css +59 -0
  35. package/treb-calculator/modern.tsconfig.json +11 -0
  36. package/treb-calculator/package.json +5 -0
  37. package/treb-calculator/src/calculator.ts +2546 -0
  38. package/treb-calculator/src/complex-math.ts +558 -0
  39. package/treb-calculator/src/dag/array-vertex.ts +198 -0
  40. package/treb-calculator/src/dag/graph.ts +951 -0
  41. package/treb-calculator/src/dag/leaf_vertex.ts +118 -0
  42. package/treb-calculator/src/dag/spreadsheet_vertex.ts +327 -0
  43. package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +44 -0
  44. package/treb-calculator/src/dag/vertex.ts +352 -0
  45. package/treb-calculator/src/descriptors.ts +162 -0
  46. package/treb-calculator/src/expression-calculator.ts +1069 -0
  47. package/treb-calculator/src/function-error.ts +103 -0
  48. package/treb-calculator/src/function-library.ts +103 -0
  49. package/treb-calculator/src/functions/base-functions.ts +1214 -0
  50. package/treb-calculator/src/functions/checkbox.ts +164 -0
  51. package/treb-calculator/src/functions/complex-functions.ts +253 -0
  52. package/treb-calculator/src/functions/finance-functions.ts +399 -0
  53. package/treb-calculator/src/functions/information-functions.ts +102 -0
  54. package/treb-calculator/src/functions/matrix-functions.ts +182 -0
  55. package/treb-calculator/src/functions/sparkline.ts +335 -0
  56. package/treb-calculator/src/functions/statistics-functions.ts +350 -0
  57. package/treb-calculator/src/functions/text-functions.ts +298 -0
  58. package/treb-calculator/src/index.ts +27 -0
  59. package/treb-calculator/src/notifier-types.ts +59 -0
  60. package/treb-calculator/src/primitives.ts +428 -0
  61. package/treb-calculator/src/utilities.ts +305 -0
  62. package/treb-charts/package.json +5 -0
  63. package/treb-charts/src/chart-functions.ts +156 -0
  64. package/treb-charts/src/chart-types.ts +230 -0
  65. package/treb-charts/src/chart.ts +1288 -0
  66. package/treb-charts/src/index.ts +24 -0
  67. package/treb-charts/src/main.ts +37 -0
  68. package/treb-charts/src/rectangle.ts +52 -0
  69. package/treb-charts/src/renderer.ts +1841 -0
  70. package/treb-charts/src/util.ts +122 -0
  71. package/treb-charts/style/charts.scss +221 -0
  72. package/treb-charts/style/old-charts.scss +250 -0
  73. package/treb-embed/markup/layout.html +137 -0
  74. package/treb-embed/markup/toolbar.html +175 -0
  75. package/treb-embed/modern.tsconfig.json +25 -0
  76. package/treb-embed/src/custom-element/content-types.d.ts +18 -0
  77. package/treb-embed/src/custom-element/global.d.ts +11 -0
  78. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1228 -0
  79. package/treb-embed/src/custom-element/treb-global.ts +44 -0
  80. package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +52 -0
  81. package/treb-embed/src/embedded-spreadsheet.ts +5358 -0
  82. package/treb-embed/src/index.ts +16 -0
  83. package/treb-embed/src/language-model.ts +41 -0
  84. package/treb-embed/src/options.ts +298 -0
  85. package/treb-embed/src/progress-dialog.ts +228 -0
  86. package/treb-embed/src/selection-state.ts +16 -0
  87. package/treb-embed/src/spinner.ts +42 -0
  88. package/treb-embed/src/toolbar-message.ts +96 -0
  89. package/treb-embed/src/types.ts +167 -0
  90. package/treb-embed/style/autocomplete.scss +103 -0
  91. package/treb-embed/style/dark-theme.scss +114 -0
  92. package/treb-embed/style/defaults.scss +36 -0
  93. package/treb-embed/style/dialog.scss +181 -0
  94. package/treb-embed/style/dropdown-select.scss +101 -0
  95. package/treb-embed/style/formula-bar.scss +193 -0
  96. package/treb-embed/style/grid.scss +374 -0
  97. package/treb-embed/style/layout.scss +424 -0
  98. package/treb-embed/style/mouse-mask.scss +67 -0
  99. package/treb-embed/style/note.scss +92 -0
  100. package/treb-embed/style/overlay-editor.scss +102 -0
  101. package/treb-embed/style/spinner.scss +92 -0
  102. package/treb-embed/style/tab-bar.scss +228 -0
  103. package/treb-embed/style/table.scss +80 -0
  104. package/treb-embed/style/theme-defaults.scss +444 -0
  105. package/treb-embed/style/toolbar.scss +416 -0
  106. package/treb-embed/style/tooltip.scss +68 -0
  107. package/treb-embed/style/treb-icons.scss +130 -0
  108. package/treb-embed/style/treb-spreadsheet-element.scss +20 -0
  109. package/treb-embed/style/z-index.scss +43 -0
  110. package/treb-export/docs/charts.md +68 -0
  111. package/treb-export/modern.tsconfig.json +19 -0
  112. package/treb-export/package.json +4 -0
  113. package/treb-export/src/address-type.ts +77 -0
  114. package/treb-export/src/base-template.ts +22 -0
  115. package/treb-export/src/column-width.ts +85 -0
  116. package/treb-export/src/drawing2/chart-template-components2.ts +389 -0
  117. package/treb-export/src/drawing2/chart2.ts +282 -0
  118. package/treb-export/src/drawing2/column-chart-template2.ts +521 -0
  119. package/treb-export/src/drawing2/donut-chart-template2.ts +296 -0
  120. package/treb-export/src/drawing2/drawing2.ts +355 -0
  121. package/treb-export/src/drawing2/embedded-image.ts +71 -0
  122. package/treb-export/src/drawing2/scatter-chart-template2.ts +555 -0
  123. package/treb-export/src/export-worker/export-worker.ts +99 -0
  124. package/treb-export/src/export-worker/index-modern.ts +22 -0
  125. package/treb-export/src/export2.ts +2204 -0
  126. package/treb-export/src/import2.ts +882 -0
  127. package/treb-export/src/relationship.ts +36 -0
  128. package/treb-export/src/shared-strings2.ts +128 -0
  129. package/treb-export/src/template-2.ts +22 -0
  130. package/treb-export/src/unescape_xml.ts +47 -0
  131. package/treb-export/src/workbook-sheet2.ts +182 -0
  132. package/treb-export/src/workbook-style2.ts +1285 -0
  133. package/treb-export/src/workbook-theme2.ts +88 -0
  134. package/treb-export/src/workbook2.ts +491 -0
  135. package/treb-export/src/xml-utils.ts +201 -0
  136. package/treb-export/template/base/[Content_Types].xml +2 -0
  137. package/treb-export/template/base/_rels/.rels +2 -0
  138. package/treb-export/template/base/docProps/app.xml +2 -0
  139. package/treb-export/template/base/docProps/core.xml +12 -0
  140. package/treb-export/template/base/xl/_rels/workbook.xml.rels +2 -0
  141. package/treb-export/template/base/xl/sharedStrings.xml +2 -0
  142. package/treb-export/template/base/xl/styles.xml +2 -0
  143. package/treb-export/template/base/xl/theme/theme1.xml +2 -0
  144. package/treb-export/template/base/xl/workbook.xml +2 -0
  145. package/treb-export/template/base/xl/worksheets/sheet1.xml +2 -0
  146. package/treb-export/template/base.xlsx +0 -0
  147. package/treb-format/package.json +8 -0
  148. package/treb-format/src/format.test.ts +213 -0
  149. package/treb-format/src/format.ts +942 -0
  150. package/treb-format/src/format_cache.ts +199 -0
  151. package/treb-format/src/format_parser.ts +723 -0
  152. package/treb-format/src/index.ts +25 -0
  153. package/treb-format/src/number_format_section.ts +100 -0
  154. package/treb-format/src/value_parser.ts +337 -0
  155. package/treb-grid/package.json +5 -0
  156. package/treb-grid/src/editors/autocomplete.ts +394 -0
  157. package/treb-grid/src/editors/autocomplete_matcher.ts +260 -0
  158. package/treb-grid/src/editors/formula_bar.ts +473 -0
  159. package/treb-grid/src/editors/formula_editor_base.ts +910 -0
  160. package/treb-grid/src/editors/overlay_editor.ts +511 -0
  161. package/treb-grid/src/index.ts +37 -0
  162. package/treb-grid/src/layout/base_layout.ts +2618 -0
  163. package/treb-grid/src/layout/grid_layout.ts +299 -0
  164. package/treb-grid/src/layout/rectangle_cache.ts +86 -0
  165. package/treb-grid/src/render/selection-renderer.ts +414 -0
  166. package/treb-grid/src/render/svg_header_overlay.ts +93 -0
  167. package/treb-grid/src/render/svg_selection_block.ts +187 -0
  168. package/treb-grid/src/render/tile_renderer.ts +2122 -0
  169. package/treb-grid/src/types/annotation.ts +216 -0
  170. package/treb-grid/src/types/border_constants.ts +34 -0
  171. package/treb-grid/src/types/clipboard_data.ts +31 -0
  172. package/treb-grid/src/types/data_model.ts +334 -0
  173. package/treb-grid/src/types/drag_mask.ts +81 -0
  174. package/treb-grid/src/types/grid.ts +7743 -0
  175. package/treb-grid/src/types/grid_base.ts +3644 -0
  176. package/treb-grid/src/types/grid_command.ts +470 -0
  177. package/treb-grid/src/types/grid_events.ts +124 -0
  178. package/treb-grid/src/types/grid_options.ts +97 -0
  179. package/treb-grid/src/types/grid_selection.ts +60 -0
  180. package/treb-grid/src/types/named_range.ts +369 -0
  181. package/treb-grid/src/types/scale-control.ts +202 -0
  182. package/treb-grid/src/types/serialize_options.ts +72 -0
  183. package/treb-grid/src/types/set_range_options.ts +52 -0
  184. package/treb-grid/src/types/sheet.ts +3099 -0
  185. package/treb-grid/src/types/sheet_types.ts +95 -0
  186. package/treb-grid/src/types/tab_bar.ts +464 -0
  187. package/treb-grid/src/types/tile.ts +59 -0
  188. package/treb-grid/src/types/update_flags.ts +75 -0
  189. package/treb-grid/src/util/dom_utilities.ts +44 -0
  190. package/treb-grid/src/util/fontmetrics2.ts +179 -0
  191. package/treb-grid/src/util/ua.ts +104 -0
  192. package/treb-logo.svg +18 -0
  193. package/treb-parser/package.json +5 -0
  194. package/treb-parser/src/csv-parser.ts +122 -0
  195. package/treb-parser/src/index.ts +25 -0
  196. package/treb-parser/src/md-parser.ts +526 -0
  197. package/treb-parser/src/parser-types.ts +397 -0
  198. package/treb-parser/src/parser.test.ts +298 -0
  199. package/treb-parser/src/parser.ts +2673 -0
  200. package/treb-utils/package.json +5 -0
  201. package/treb-utils/src/dispatch.ts +57 -0
  202. package/treb-utils/src/event_source.ts +147 -0
  203. package/treb-utils/src/ievent_source.ts +33 -0
  204. package/treb-utils/src/index.ts +31 -0
  205. package/treb-utils/src/measurement.ts +174 -0
  206. package/treb-utils/src/resizable.ts +160 -0
  207. package/treb-utils/src/scale.ts +137 -0
  208. package/treb-utils/src/serialize_html.ts +124 -0
  209. package/treb-utils/src/template.ts +70 -0
  210. package/treb-utils/src/validate_uri.ts +61 -0
  211. package/tsconfig.json +10 -0
  212. package/tsproject.json +30 -0
  213. package/util/license-plugin-esbuild.js +86 -0
  214. package/util/list-css-vars.sh +46 -0
  215. package/README-esm.md +0 -37
  216. package/treb-bundle.css +0 -2
  217. package/treb-bundle.mjs +0 -15
@@ -1,100 +1,264 @@
1
- /*! API v23.6. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
1
+ /*! API v25.0.0-rc2. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
2
2
 
3
- /**
4
- * Global instance. In the base script, this object will be created as an
5
- * ambient global object (bound to the window object). If you instead use the
6
- * ES module, import the TREB object from the module.
3
+ /**
4
+ * add our tag to the map
7
5
  */
8
- declare const TREB: TREBGlobal;
9
-
6
+ declare global {
7
+ interface HTMLElementTagNameMap {
8
+ 'treb-spreadsheet': HTMLElement & {
9
+ sheet: EmbeddedSpreadsheet|undefined;
10
+ };
11
+ }
12
+ }
10
13
  /**
11
- * global object used to create spreadsheets
14
+ * API class for creating spreadsheets. this is intended as a singleton,
15
+ * we will export an instance of the class.
12
16
  */
13
17
  export declare class TREBGlobal {
14
18
 
15
- /** TREB version */
16
- version: string;
17
-
18
- /** create a spreadsheet */
19
- CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet;
19
+ /**
20
+ * build version
21
+ */
22
+ version: string;
20
23
 
24
+ /**
25
+ * create a spreadsheet instance
26
+ */
27
+ CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet;
21
28
  }
22
- /**
23
- * options for saving files. we add the option for JSON formatting.
24
- */
25
- export interface SaveOptions extends SerializeOptions {
26
29
 
27
- /** pretty json formatting */
28
- pretty?: boolean;
29
- }
30
+ /** single instance of factory class */
31
+ export declare const TREB: TREBGlobal;
30
32
 
31
33
  /**
32
- * options for the LoadDocument method
34
+ * options for creating spreadsheet
33
35
  */
34
- export interface LoadDocumentOptions {
36
+ export interface EmbeddedSpreadsheetOptions {
37
+
38
+ /** containing HTML element */
39
+ container?: string | HTMLElement;
40
+
41
+ /** allow drag-and-drop files */
42
+ dnd?: boolean;
43
+
44
+ /**
45
+ * expandable grid. if this option is false, the grid will always
46
+ * stay the same size -- if you keep pressing down arrow, it won't
47
+ * grow. defaults to true.
48
+ */
49
+ expand?: boolean;
50
+
51
+ /**
52
+ * key in localStorage for persisting document.
53
+ *
54
+ * it's possible to set this to boolean `true`, in which case we will
55
+ * generate a storage key based on the page URI.
56
+ *
57
+ * that can be convenient for quickly setting up a document, but don't
58
+ * use it if the page URI might change (the storage will get lost)
59
+ * or if there are multiple spreadsheets on the same page (they will
60
+ * overwrite each other).
61
+ */
62
+ storage_key?: string | boolean;
63
+
64
+ /** don't load immediately (?) */
65
+ toll_initial_load?: boolean;
66
+
67
+ /** show formula bar. default true. */
68
+ formula_bar?: boolean;
69
+
70
+ /** expand formula bar */
71
+ expand_formula_button?: boolean;
72
+
73
+ /** scroll to cell on load */
35
74
  scroll?: string | ICellAddress;
36
- flush?: boolean;
37
- recalculate?: boolean;
38
- override_sheet?: string;
39
- }
40
75
 
41
- /**
42
- * options for the GetRange method
43
- */
44
- export interface GetRangeOptions {
76
+ /** sheet to show on load, overrides anything in the model */
77
+ sheet?: string;
78
+
79
+ /** add resizable wrapper */
80
+ resizable?: boolean;
81
+
82
+ /** export to xlsx, now optional */
83
+ export?: boolean;
45
84
 
46
85
  /**
47
- * return formatted values (apply number formats and return strings)
48
- * @deprecated
86
+ * fetch network document. this is a replacement for the old
87
+ * (deprecated) option `network_document`.
49
88
  */
50
- formatted?: boolean;
89
+ document?: string;
51
90
 
52
91
  /**
53
- * return formulas instead of values. formula takes precedence over
54
- * "formatted"; if you pass both, returned values will *not* be formatted.
55
- * @deprecated
92
+ * fetch network document (URI)
93
+ * @deprecated - use `document`
94
+ */
95
+ network_document?: string;
96
+
97
+ /** freeze rows */
98
+ freeze_rows?: number;
99
+
100
+ /** freeze columns */
101
+ freeze_columns?: number;
102
+
103
+ /** row/column headers */
104
+ headers?: boolean;
105
+
106
+ /** recalculate on load */
107
+ recalculate?: boolean;
108
+
109
+ /** show scrollbars */
110
+ scrollbars?: boolean;
111
+
112
+ /** show tab bar (multi sheet) */
113
+ tab_bar?: boolean | 'auto';
114
+
115
+ /** allow add tab */
116
+ add_tab?: boolean;
117
+
118
+ /** show delete tab */
119
+ delete_tab?: boolean;
120
+
121
+ /** set a reference in global (self) */
122
+ global_name?: string;
123
+
124
+ /** support undo */
125
+ undo?: boolean;
126
+
127
+ /** support in-cell editor */
128
+ in_cell_editor?: boolean;
129
+
130
+ /** prompt "you have unsaved changes" */
131
+ prompt_save?: boolean;
132
+
133
+ /**
134
+ * toolbar display option. true or false means include/don't include
135
+ * the toolbar (and the toolbar button). setting to "narrow" means
136
+ * include the toolbar, but use a narrow version (it compresses the
137
+ * align/justify groups).
56
138
  *
57
- **/
58
- formula?: boolean;
139
+ * the toolbar usually starts hidden. if you set this option to "show",
140
+ * it will start visible. same for "show-narrow".
141
+ */
142
+ toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
143
+
144
+ /** include the file menu in the toolbar */
145
+ file_menu?: boolean;
146
+
147
+ /** include the font scale control in the toolbar */
148
+ font_scale?: boolean;
149
+
150
+ /** include the insert/remove table button in the toolbar */
151
+ table_button?: boolean;
152
+
153
+ /** include the freeze button in the toolbar */
154
+ freeze_button?: boolean;
155
+
156
+ /** include the chart menu in the toolbar */
157
+ chart_menu?: boolean;
158
+
159
+ /** include a recalculate button in the toolbar */
160
+ toolbar_recalculate_button?: boolean;
161
+
162
+ /** better support for headless operations (default false) */
163
+ headless?: boolean;
164
+
165
+ /** max size for image, in bytes */
166
+ max_file_size?: number;
167
+
168
+ /** initial scale */
169
+ scale?: number;
59
170
 
60
171
  /**
61
- * optional style for returned values (replaces old flags).
172
+ * show scale control (slider) under the spreadsheet.
173
+ */
174
+ scale_control?: boolean;
175
+
176
+ /**
177
+ * show the stats panel under the spreadsheet.
178
+ */
179
+ stats?: boolean;
180
+
181
+ /**
182
+ * save/load scale. this can optionally have a string key to disambiguate
183
+ */
184
+ persist_scale?: boolean | string;
185
+
186
+ /**
187
+ * target window for hyperlinks (default _blank); set false to disable hyperlinks altogether
188
+ */
189
+ hyperlinks?: string | false;
190
+
191
+ /**
192
+ * enable handling complex numbers in function calculation. turning this
193
+ * off doesn't actually disable complex numbers. it means that functions
194
+ * will not return complex numbers unless one of the arguments is complex.
62
195
  *
63
- * @remarks
196
+ * for example, if complex numbers are off, `=SQRT(-1)` will return `#VALUE`.
197
+ * if complex numbers are on, `=SQRT(-1)` will return `i`.
64
198
  *
65
- * `formatted` returns formatted values, applying number formatting and
66
- * returning strings. `formula` returns cell formulas instead of values.
199
+ * even if complex numbers are off, however, `=SQRT(-1 + 0i)` will return
200
+ * `i` because the argument is complex.
201
+ *
202
+ * currently this behavior applies to `SQRT`, `POWER` and the exponentiation
203
+ * operator `^`.
204
+ *
205
+ * in version 22, this defaults to `off`.
67
206
  */
68
- type?: 'formatted' | 'formula';
69
- }
207
+ complex?: 'on' | 'off';
70
208
 
71
- /**
72
- * options for the ScrollTo method.
73
- *
74
- * @remarks
75
- *
76
- * this method was renamed because of a conflict with a DOM type,
77
- * which was causing problems with the documentation generator.
78
- */
79
- export interface SheetScrollOptions {
209
+ /**
210
+ * for rendering the imaginary number. this is intended to support
211
+ * switching to a different character for rendering, or adding a leading
212
+ * space/half-space/hair-space.
213
+ *
214
+ * this _does_not_ change how you enter imaginary numbers, you still have
215
+ * to use `i` (lower-case ascii i).
216
+ */
217
+ imaginary_value?: string;
80
218
 
81
- /** scroll in x-direction. defaults to true. */
82
- x?: boolean;
219
+ /**
220
+ * support markdown formatting for text in cells and comments. at the
221
+ * moment we only support bold, italic, and strike text.
222
+ */
223
+ markdown?: boolean;
83
224
 
84
- /** scroll in y-direction. defaults to true. */
85
- y?: boolean;
225
+ /**
226
+ * show tinted colors in toolbar color dropdowns. as of version 25
227
+ * this defaults to true (used to be false).
228
+ */
229
+ tint_theme_colors?: boolean;
86
230
 
87
231
  /**
88
- * smooth scrolling, if supported. we use scrollTo so support is as here:
89
- * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
232
+ * show a spinner for long-running operations
90
233
  */
91
- smooth?: boolean;
234
+ spinner?: boolean;
235
+
236
+ /**
237
+ * start with sidebar closed. defaults to false.
238
+ */
239
+ collapsed?: boolean;
240
+
241
+ /**
242
+ * show the revert button in the sidebar. see the `Revert` method. this
243
+ * was renamed from `revert` to avoid any ambiguity.
244
+ */
245
+ revert_button?: boolean;
92
246
  }
93
247
 
94
248
  /**
95
- * function type used for filtering tables
249
+ * Structure represents a cell address. Note that row and column are 0-based.
96
250
  */
97
- export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: Style.Properties) => boolean;
251
+ export interface ICellAddress {
252
+
253
+ /** 0-based row */
254
+ row: number;
255
+
256
+ /** 0-based column */
257
+ column: number;
258
+ absolute_row?: boolean;
259
+ absolute_column?: boolean;
260
+ sheet_id?: number;
261
+ }
98
262
 
99
263
  /**
100
264
  * embedded spreadsheet
@@ -397,9 +561,10 @@ export declare class EmbeddedSpreadsheet {
397
561
  *
398
562
  * @remarks
399
563
  *
400
- * Call this method when the container is resized. It's not necessary
401
- * if the resize is triggered by our resize handle, only if the container
402
- * is resized externally.
564
+ * This method should be called when the container is resized, to
565
+ * trigger an update to layout. It should be called automatically
566
+ * by a resize observer set in the containing tag class, but you
567
+ * can call it manually if necessary.
403
568
  *
404
569
  * @public
405
570
  */
@@ -472,8 +637,7 @@ export declare class EmbeddedSpreadsheet {
472
637
 
473
638
  /**
474
639
  * unserialize document from data.
475
- *
476
- **/
640
+ */
477
641
  LoadDocument(data: any, options?: LoadDocumentOptions): void;
478
642
 
479
643
  /**
@@ -716,16 +880,91 @@ export declare class EmbeddedSpreadsheet {
716
880
  */
717
881
  Cancel(token: number): void;
718
882
  }
883
+
884
+ /**
885
+ * options for saving files. we add the option for JSON formatting.
886
+ */
887
+ export interface SaveOptions extends SerializeOptions {
888
+
889
+ /** pretty json formatting */
890
+ pretty?: boolean;
891
+ }
892
+
893
+ /**
894
+ * options for the LoadDocument method
895
+ */
896
+ export interface LoadDocumentOptions {
897
+ scroll?: string | ICellAddress;
898
+ flush?: boolean;
899
+ recalculate?: boolean;
900
+ override_sheet?: string;
901
+ }
902
+
903
+ /**
904
+ * options for the GetRange method
905
+ */
906
+ export interface GetRangeOptions {
907
+
908
+ /**
909
+ * return formatted values (apply number formats and return strings)
910
+ * @deprecated
911
+ */
912
+ formatted?: boolean;
913
+
914
+ /**
915
+ * return formulas instead of values. formula takes precedence over
916
+ * "formatted"; if you pass both, returned values will *not* be formatted.
917
+ * @deprecated
918
+ */
919
+ formula?: boolean;
920
+
921
+ /**
922
+ * optional style for returned values (replaces old flags).
923
+ *
924
+ * @remarks
925
+ *
926
+ * `formatted` returns formatted values, applying number formatting and
927
+ * returning strings. `formula` returns cell formulas instead of values.
928
+ */
929
+ type?: 'formatted' | 'formula';
930
+ }
931
+
932
+ /**
933
+ * options for the ScrollTo method.
934
+ *
935
+ * @remarks
936
+ *
937
+ * this method was renamed because of a conflict with a DOM type,
938
+ * which was causing problems with the documentation generator.
939
+ */
940
+ export interface SheetScrollOptions {
941
+
942
+ /** scroll in x-direction. defaults to true. */
943
+ x?: boolean;
944
+
945
+ /** scroll in y-direction. defaults to true. */
946
+ y?: boolean;
947
+
948
+ /**
949
+ * smooth scrolling, if supported. we use scrollTo so support is as here:
950
+ * https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTo
951
+ */
952
+ smooth?: boolean;
953
+ }
954
+
955
+ /**
956
+ * function type used for filtering tables
957
+ */
958
+ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: Style.Properties) => boolean;
719
959
  export interface FreezePane {
720
960
  rows: number;
721
961
  columns: number;
722
962
  }
723
- export declare type BorderConstants = "none" | "all" | "outside" | "top" | "bottom" | "left" | "right" | "double-top" | "double-bottom";
963
+ export declare type BorderConstants = "none" | "all" | "outside" | "top" | "bottom" | "left" | "right";
724
964
 
725
965
  /**
726
966
  * options for serializing data
727
- *
728
- **/
967
+ */
729
968
  export interface SerializeOptions {
730
969
 
731
970
  /** optimize for size */
@@ -784,25 +1023,9 @@ export interface SetRangeOptions {
784
1023
  r1c1?: boolean;
785
1024
  }
786
1025
 
787
- /**
788
- * Structure represents a cell address. Note that row and column are 0-based.
789
- */
790
- export interface ICellAddress {
791
-
792
- /** 0-based row */
793
- row: number;
794
-
795
- /** 0-based column */
796
- column: number;
797
- absolute_row?: boolean;
798
- absolute_column?: boolean;
799
- sheet_id?: number;
800
- }
801
-
802
1026
  /**
803
1027
  * Structure represents a 2d range of cells.
804
- *
805
- **/
1028
+ */
806
1029
  export interface IArea {
807
1030
  start: ICellAddress;
808
1031
  end: ICellAddress;
@@ -827,8 +1050,7 @@ export declare namespace Style {
827
1050
 
828
1051
  /**
829
1052
  * vertical align constants
830
- *
831
- **/ type VerticalAlign = "" | "top" | "bottom" | "middle";
1053
+ */ type VerticalAlign = "" | "top" | "bottom" | "middle";
832
1054
 
833
1055
  /** composite font size */
834
1056
  interface FontSize {
@@ -838,8 +1060,7 @@ export declare namespace Style {
838
1060
 
839
1061
  /**
840
1062
  * color is either a theme color (theme index plus tint), or CSS text
841
- *
842
- **/
1063
+ */
843
1064
  interface Color {
844
1065
  theme?: number;
845
1066
  tint?: number;
@@ -942,8 +1163,7 @@ export interface DimensionedQuantity {
942
1163
 
943
1164
  /**
944
1165
  * composite styling for tables.
945
- *
946
- **/
1166
+ */
947
1167
  export interface TableTheme {
948
1168
 
949
1169
  /** the first row in a table, showing column titles. */
@@ -1004,7 +1224,7 @@ export declare type LoadSource = "drag-and-drop" | "local-file" | "network-file"
1004
1224
  * EmbeddedSheetEvent is a discriminated union. Switch on the `type` field
1005
1225
  * of the event.
1006
1226
  */
1007
- export type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | DataChangeEvent | SelectionEvent | ResizeEvent;
1227
+ export type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | DataChangeEvent | FocusViewEvent | SelectionEvent | ResizeEvent;
1008
1228
 
1009
1229
  /**
1010
1230
  * options when inserting a table into a sheet
@@ -1046,8 +1266,7 @@ export interface DocumentLoadEvent {
1046
1266
 
1047
1267
  /**
1048
1268
  * This event is sent when the document is reset.
1049
- *
1050
- **/
1269
+ */
1051
1270
  export interface DocumentResetEvent {
1052
1271
  type: 'reset';
1053
1272
  }
@@ -1078,6 +1297,14 @@ export interface SelectionEvent {
1078
1297
  type: 'selection';
1079
1298
  }
1080
1299
 
1300
+ /**
1301
+ * This event is sent when the focused view changes, if you have more
1302
+ * than one view.
1303
+ */
1304
+ export interface FocusViewEvent {
1305
+ type: 'focus-view';
1306
+ }
1307
+
1081
1308
  /**
1082
1309
  * options for exporting CSV/TSV
1083
1310
  */
@@ -1096,181 +1323,6 @@ export interface ExportOptions {
1096
1323
  formatted?: boolean;
1097
1324
  }
1098
1325
 
1099
- /**
1100
- * options for creating spreadsheet
1101
- */
1102
- export interface EmbeddedSpreadsheetOptions {
1103
-
1104
- /** containing HTML element */
1105
- container?: string | HTMLElement;
1106
-
1107
- /** allow drag-and-drop files */
1108
- dnd?: boolean;
1109
-
1110
- /** expandable grid */
1111
- expand?: boolean;
1112
-
1113
- /** key in localStorage for persisting document */
1114
- storage_key?: string;
1115
-
1116
- /** don't load immediately (?) */
1117
- toll_initial_load?: boolean;
1118
-
1119
- /** show formula bar */
1120
- formula_bar?: boolean;
1121
-
1122
- /** expand formula bar */
1123
- expand_formula_button?: boolean;
1124
-
1125
- /** scroll to cell on load */
1126
- scroll?: string | ICellAddress;
1127
-
1128
- /** sheet to show on load, overrides anything in the model */
1129
- sheet?: string;
1130
-
1131
- /** add resizable wrapper */
1132
- resizable?: boolean;
1133
-
1134
- /** export to xlsx, now optional */
1135
- export?: boolean;
1136
-
1137
- /** fill container */
1138
- auto_size?: boolean;
1139
-
1140
- /** popout icon */
1141
- popout?: boolean;
1142
-
1143
- /** fetch network document (URI) */
1144
- network_document?: string;
1145
-
1146
- /**
1147
- * load this document if the storage document isn't found (fallback)
1148
- *
1149
- * @deprecated - this is superfluous, using network_document with
1150
- * storage_key is sufficient for this pattern.
1151
- */
1152
- alternate_document?: string;
1153
-
1154
- /** freeze rows */
1155
- freeze_rows?: number;
1156
-
1157
- /** freeze columns */
1158
- freeze_columns?: number;
1159
-
1160
- /** row/column headers */
1161
- headers?: boolean;
1162
-
1163
- /** recalculate on load */
1164
- recalculate?: boolean;
1165
-
1166
- /** show scrollbars */
1167
- scrollbars?: boolean;
1168
-
1169
- /** show tab bar (multi sheet) */
1170
- tab_bar?: boolean | 'auto';
1171
-
1172
- /** allow add tab */
1173
- add_tab?: boolean;
1174
-
1175
- /** show delete tab */
1176
- delete_tab?: boolean;
1177
-
1178
- /** set a reference in global (self) */
1179
- global_name?: string;
1180
-
1181
- /** support undo */
1182
- undo?: boolean;
1183
-
1184
- /** support in-cell editor */
1185
- in_cell_editor?: boolean;
1186
-
1187
- /** prompt "you have unsaved changes" */
1188
- prompt_save?: boolean;
1189
-
1190
- /**
1191
- * toolbar display option
1192
- */
1193
- toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
1194
-
1195
- /** file options in the toolbar */
1196
- file_menu?: boolean;
1197
-
1198
- /** font size in the toolbar */
1199
- font_scale?: boolean;
1200
-
1201
- /** show insert/remove table button in toolbar */
1202
- table_button?: boolean;
1203
-
1204
- /** chart menu in the toolbar */
1205
- chart_menu?: boolean;
1206
-
1207
- /** recalculate button in the toolbar */
1208
- toolbar_recalculate_button?: boolean;
1209
-
1210
- /** new option, better support for headless operations (default false) */
1211
- headless?: boolean;
1212
-
1213
- /** max size for image, in bytes */
1214
- max_file_size?: number;
1215
-
1216
- /** initial scale */
1217
- scale?: number;
1218
-
1219
- /** show scale buttons */
1220
- scale_control?: boolean;
1221
-
1222
- /** show stats panel */
1223
- stats?: boolean;
1224
-
1225
- /** save/load scale. this can optionally have a string key to disambiguate */
1226
- persist_scale?: boolean | string;
1227
-
1228
- /** target window for hyperlinks (default _blank); set false to disable hyperlinks altogether */
1229
- hyperlinks?: string | false;
1230
-
1231
- /**
1232
- * enable handling complex numbers in function calculation. turning this
1233
- * off doesn't actually disable complex numbers. it means that functions
1234
- * will not return complex numbers unless one of the arguments is complex.
1235
- *
1236
- * for example, if complex numbers are off, `=SQRT(-1)` will return `#VALUE`.
1237
- * if complex numbers are on, `=SQRT(-1)` will return `i`.
1238
- *
1239
- * even if complex numbers are off, however, `=SQRT(-1 + 0i)` will return
1240
- * `i` because the argument is complex.
1241
- *
1242
- * currently this behavior applies to `SQRT`, `POWER` and the exponentiation
1243
- * operator `^`.
1244
- *
1245
- * in version 22, this defaults to `off`.
1246
- */
1247
- complex?: 'on' | 'off';
1248
-
1249
- /**
1250
- * for rendering the imaginary number. this is intended to support
1251
- * switching to a different character for rendering, or adding a leading
1252
- * space/half-space/hair-space.
1253
- */
1254
- imaginary_value?: string;
1255
-
1256
- /** support MD formatting for text */
1257
- markdown?: boolean;
1258
-
1259
- /** show tinted colors in toolbar color dropdowns */
1260
- tint_theme_colors?: boolean;
1261
-
1262
- /** show a spinner for long-running operations */
1263
- spinner?: boolean;
1264
-
1265
- /** collapsed: start sidebar closed */
1266
- collapsed?: boolean;
1267
-
1268
- /**
1269
- * show the revert button. see the Revert method.
1270
- */
1271
- revert?: boolean;
1272
- }
1273
-
1274
1326
  /**
1275
1327
  * options for the evaluate function
1276
1328
  */