@trebco/treb 25.0.0-rc1 → 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.
package/build/treb.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! API v25.0.0-rc1. 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
3
  /**
4
4
  * add our tag to the map
@@ -41,15 +41,20 @@ export interface EmbeddedSpreadsheetOptions {
41
41
  /** allow drag-and-drop files */
42
42
  dnd?: boolean;
43
43
 
44
- /** expandable grid */
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
+ */
45
49
  expand?: boolean;
46
50
 
47
51
  /**
48
- * key in localStorage for persisting document. it's possible
49
- * to set this to boolean `true`, in which case we will generate
50
- * a storage key based on the page URI.
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.
51
56
  *
52
- * this can be convenient for quickly setting up a document, but don't
57
+ * that can be convenient for quickly setting up a document, but don't
53
58
  * use it if the page URI might change (the storage will get lost)
54
59
  * or if there are multiple spreadsheets on the same page (they will
55
60
  * overwrite each other).
@@ -77,10 +82,16 @@ export interface EmbeddedSpreadsheetOptions {
77
82
  /** export to xlsx, now optional */
78
83
  export?: boolean;
79
84
 
80
- /** fill container */
81
- auto_size?: boolean;
85
+ /**
86
+ * fetch network document. this is a replacement for the old
87
+ * (deprecated) option `network_document`.
88
+ */
89
+ document?: string;
82
90
 
83
- /** fetch network document (URI) */
91
+ /**
92
+ * fetch network document (URI)
93
+ * @deprecated - use `document`
94
+ */
84
95
  network_document?: string;
85
96
 
86
97
  /** freeze rows */
@@ -120,29 +131,35 @@ export interface EmbeddedSpreadsheetOptions {
120
131
  prompt_save?: boolean;
121
132
 
122
133
  /**
123
- * toolbar display option
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).
138
+ *
139
+ * the toolbar usually starts hidden. if you set this option to "show",
140
+ * it will start visible. same for "show-narrow".
124
141
  */
125
142
  toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
126
143
 
127
- /** file options in the toolbar */
144
+ /** include the file menu in the toolbar */
128
145
  file_menu?: boolean;
129
146
 
130
- /** font size in the toolbar */
147
+ /** include the font scale control in the toolbar */
131
148
  font_scale?: boolean;
132
149
 
133
- /** show insert/remove table button in toolbar */
150
+ /** include the insert/remove table button in the toolbar */
134
151
  table_button?: boolean;
135
152
 
136
- /** show freeze button in toolbar */
153
+ /** include the freeze button in the toolbar */
137
154
  freeze_button?: boolean;
138
155
 
139
- /** chart menu in the toolbar */
156
+ /** include the chart menu in the toolbar */
140
157
  chart_menu?: boolean;
141
158
 
142
- /** recalculate button in the toolbar */
159
+ /** include a recalculate button in the toolbar */
143
160
  toolbar_recalculate_button?: boolean;
144
161
 
145
- /** new option, better support for headless operations (default false) */
162
+ /** better support for headless operations (default false) */
146
163
  headless?: boolean;
147
164
 
148
165
  /** max size for image, in bytes */
@@ -151,16 +168,24 @@ export interface EmbeddedSpreadsheetOptions {
151
168
  /** initial scale */
152
169
  scale?: number;
153
170
 
154
- /** show scale buttons */
171
+ /**
172
+ * show scale control (slider) under the spreadsheet.
173
+ */
155
174
  scale_control?: boolean;
156
175
 
157
- /** show stats panel */
176
+ /**
177
+ * show the stats panel under the spreadsheet.
178
+ */
158
179
  stats?: boolean;
159
180
 
160
- /** save/load scale. this can optionally have a string key to disambiguate */
181
+ /**
182
+ * save/load scale. this can optionally have a string key to disambiguate
183
+ */
161
184
  persist_scale?: boolean | string;
162
185
 
163
- /** target window for hyperlinks (default _blank); set false to disable hyperlinks altogether */
186
+ /**
187
+ * target window for hyperlinks (default _blank); set false to disable hyperlinks altogether
188
+ */
164
189
  hyperlinks?: string | false;
165
190
 
166
191
  /**
@@ -185,10 +210,16 @@ export interface EmbeddedSpreadsheetOptions {
185
210
  * for rendering the imaginary number. this is intended to support
186
211
  * switching to a different character for rendering, or adding a leading
187
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).
188
216
  */
189
217
  imaginary_value?: string;
190
218
 
191
- /** support MD formatting for text */
219
+ /**
220
+ * support markdown formatting for text in cells and comments. at the
221
+ * moment we only support bold, italic, and strike text.
222
+ */
192
223
  markdown?: boolean;
193
224
 
194
225
  /**
@@ -197,15 +228,19 @@ export interface EmbeddedSpreadsheetOptions {
197
228
  */
198
229
  tint_theme_colors?: boolean;
199
230
 
200
- /** show a spinner for long-running operations */
231
+ /**
232
+ * show a spinner for long-running operations
233
+ */
201
234
  spinner?: boolean;
202
235
 
203
- /** collapsed: start sidebar closed */
236
+ /**
237
+ * start with sidebar closed. defaults to false.
238
+ */
204
239
  collapsed?: boolean;
205
240
 
206
241
  /**
207
- * show the revert button. see the Revert method. this was renamed
208
- * from `revert` to avoid any ambiguity.
242
+ * show the revert button in the sidebar. see the `Revert` method. this
243
+ * was renamed from `revert` to avoid any ambiguity.
209
244
  */
210
245
  revert_button?: boolean;
211
246
  }
@@ -526,9 +561,10 @@ export declare class EmbeddedSpreadsheet {
526
561
  *
527
562
  * @remarks
528
563
  *
529
- * Call this method when the container is resized. It's not necessary
530
- * if the resize is triggered by our resize handle, only if the container
531
- * 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.
532
568
  *
533
569
  * @public
534
570
  */
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "25.0.0-rc1",
3
+ "version": "25.0.0-rc2",
4
+ "license": "LGPL-3.0-or-later",
5
+ "homepage": "https://treb.app",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/trebco/treb.git"
9
+ },
4
10
  "main": "build/treb-spreadsheet.mjs",
5
11
  "types": "build/treb.d.ts",
6
12
  "type": "module",
@@ -163,7 +163,7 @@ export class SpreadsheetConstructor {
163
163
  */
164
164
  public ParseOptionAttributes(): Partial<EmbeddedSpreadsheetOptions> {
165
165
 
166
- const attribute_options: Record<string, string|boolean|number> = {};
166
+ const attribute_options: Record<string, string|boolean|number|undefined> = {};
167
167
 
168
168
  if (this.root) {
169
169
 
@@ -211,7 +211,8 @@ export class SpreadsheetConstructor {
211
211
  continue;
212
212
 
213
213
  // special case
214
- case 'document':
214
+ case 'src':
215
+ attribute_options.document = this.root.getAttribute('src') || undefined;
215
216
  continue;
216
217
 
217
218
  }
@@ -493,7 +493,14 @@ export class EmbeddedSpreadsheet {
493
493
  NumberFormat.imaginary_character = this.options.imaginary_value;
494
494
  }
495
495
 
496
- const network_document = this.options.network_document;
496
+ if (this.options.network_document) {
497
+ console.warn('the option `network_document` is deprecated. please use `document` instead.');
498
+ if (!this.options.document) {
499
+ this.options.document = this.options.network_document;
500
+ }
501
+ }
502
+
503
+ const network_document = this.options.document;
497
504
 
498
505
  // optionally data from storage, with fallback
499
506
 
@@ -504,18 +511,10 @@ export class EmbeddedSpreadsheet {
504
511
  // unload event, as parent will already have that set
505
512
 
506
513
  if (this.options.storage_key && !this.options.toll_initial_load && !options.model) {
507
-
508
514
  data = localStorage.getItem(this.options.storage_key) || undefined;
509
515
  if (data) {
510
516
  source = LoadSource.LOCAL_STORAGE;
511
517
  }
512
-
513
- /*
514
- if (!data && this.options.alternate_document) {
515
- network_document = this.options.alternate_document;
516
- }
517
- */
518
-
519
518
  }
520
519
 
521
520
  // this one should not be done for a split view, but we should still
@@ -687,7 +686,7 @@ export class EmbeddedSpreadsheet {
687
686
  this.key_listener = this.HandleKeyDown.bind(this);
688
687
  container.addEventListener('keydown', this.key_listener);
689
688
 
690
- const toll_initial_render = !!(data || this.options.network_document);
689
+ const toll_initial_render = !!(data || this.options.document);
691
690
 
692
691
  // const view = container.querySelector('.treb-view') as HTMLElement;
693
692
 
@@ -883,7 +882,7 @@ export class EmbeddedSpreadsheet {
883
882
 
884
883
  // optionally scroll grid on create (async -- why?)
885
884
 
886
- if (this.options.scroll && !this.options.network_document) {
885
+ if (this.options.scroll && !this.options.document) {
887
886
  const address = this.options.scroll;
888
887
  requestAnimationFrame(() => {
889
888
  this.ScrollTo(address);
@@ -2246,8 +2245,6 @@ export class EmbeddedSpreadsheet {
2246
2245
  public async ExportBlob(): Promise<Blob> {
2247
2246
 
2248
2247
  if (!this.export_worker) {
2249
- // const worker_name = process.env.BUILD_ENTRY_EXPORT_WORKER || '';
2250
- // this.export_worker = await this.LoadWorker(worker_name);
2251
2248
  this.export_worker = await this.LoadWorker('export');
2252
2249
  }
2253
2250
 
@@ -2297,8 +2294,7 @@ export class EmbeddedSpreadsheet {
2297
2294
  */
2298
2295
  public Revert(): void {
2299
2296
 
2300
- const canonical = // this.options.alternate_document ||
2301
- this.options.network_document;
2297
+ const canonical = this.options.document;
2302
2298
 
2303
2299
  if (canonical) {
2304
2300
 
@@ -2419,9 +2415,10 @@ export class EmbeddedSpreadsheet {
2419
2415
  *
2420
2416
  * @remarks
2421
2417
  *
2422
- * Call this method when the container is resized. It's not necessary
2423
- * if the resize is triggered by our resize handle, only if the container
2424
- * is resized externally.
2418
+ * This method should be called when the container is resized, to
2419
+ * trigger an update to layout. It should be called automatically
2420
+ * by a resize observer set in the containing tag class, but you
2421
+ * can call it manually if necessary.
2425
2422
  *
2426
2423
  * @public
2427
2424
  */
@@ -3907,8 +3904,7 @@ export class EmbeddedSpreadsheet {
3907
3904
  }
3908
3905
 
3909
3906
  if (!this.export_worker) {
3910
- const worker_name = process.env.BUILD_ENTRY_EXPORT_WORKER || '';
3911
- this.export_worker = await this.LoadWorker(worker_name);
3907
+ this.export_worker = await this.LoadWorker('export');
3912
3908
  }
3913
3909
 
3914
3910
  // this originally returned a Promise<Blob> but the actual
@@ -50,15 +50,20 @@ export interface EmbeddedSpreadsheetOptions {
50
50
  /** allow drag-and-drop files */
51
51
  dnd?: boolean;
52
52
 
53
- /** expandable grid */
53
+ /**
54
+ * expandable grid. if this option is false, the grid will always
55
+ * stay the same size -- if you keep pressing down arrow, it won't
56
+ * grow. defaults to true.
57
+ */
54
58
  expand?: boolean;
55
59
 
56
60
  /**
57
- * key in localStorage for persisting document. it's possible
58
- * to set this to boolean `true`, in which case we will generate
59
- * a storage key based on the page URI.
61
+ * key in localStorage for persisting document.
62
+ *
63
+ * it's possible to set this to boolean `true`, in which case we will
64
+ * generate a storage key based on the page URI.
60
65
  *
61
- * this can be convenient for quickly setting up a document, but don't
66
+ * that can be convenient for quickly setting up a document, but don't
62
67
  * use it if the page URI might change (the storage will get lost)
63
68
  * or if there are multiple spreadsheets on the same page (they will
64
69
  * overwrite each other).
@@ -86,30 +91,17 @@ export interface EmbeddedSpreadsheetOptions {
86
91
  /** export to xlsx, now optional */
87
92
  export?: boolean;
88
93
 
89
- /** fill container */
90
- auto_size?: boolean;
91
-
92
- /* *
93
- * popout icon
94
- * removed as of version 25
94
+ /**
95
+ * fetch network document. this is a replacement for the old
96
+ * (deprecated) option `network_document`.
95
97
  */
96
- // popout?: boolean;
97
-
98
- /* * the old "fork and edit" button */
99
- // fork?: boolean;
98
+ document?: string;
100
99
 
101
- /** fetch network document (URI) */
102
- network_document?: string;
103
-
104
- /* *
105
- * load this document if the storage document isn't found (fallback)
106
- *
107
- * @deprecated - this is superfluous, using network_document with
108
- * storage_key is sufficient for this pattern.
109
- *
110
- * removed as of version 25
100
+ /**
101
+ * fetch network document (URI)
102
+ * @deprecated - use `document`
111
103
  */
112
- // alternate_document?: string;
104
+ network_document?: string;
113
105
 
114
106
  /** freeze rows */
115
107
  freeze_rows?: number;
@@ -148,29 +140,35 @@ export interface EmbeddedSpreadsheetOptions {
148
140
  prompt_save?: boolean;
149
141
 
150
142
  /**
151
- * toolbar display option
143
+ * toolbar display option. true or false means include/don't include
144
+ * the toolbar (and the toolbar button). setting to "narrow" means
145
+ * include the toolbar, but use a narrow version (it compresses the
146
+ * align/justify groups).
147
+ *
148
+ * the toolbar usually starts hidden. if you set this option to "show",
149
+ * it will start visible. same for "show-narrow".
152
150
  */
153
151
  toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
154
152
 
155
- /** file options in the toolbar */
153
+ /** include the file menu in the toolbar */
156
154
  file_menu?: boolean;
157
155
 
158
- /** font size in the toolbar */
156
+ /** include the font scale control in the toolbar */
159
157
  font_scale?: boolean;
160
158
 
161
- /** show insert/remove table button in toolbar */
159
+ /** include the insert/remove table button in the toolbar */
162
160
  table_button?: boolean;
163
161
 
164
- /** show freeze button in toolbar */
162
+ /** include the freeze button in the toolbar */
165
163
  freeze_button?: boolean;
166
164
 
167
- /** chart menu in the toolbar */
165
+ /** include the chart menu in the toolbar */
168
166
  chart_menu?: boolean;
169
167
 
170
- /** recalculate button in the toolbar */
168
+ /** include a recalculate button in the toolbar */
171
169
  toolbar_recalculate_button?: boolean;
172
170
 
173
- /** new option, better support for headless operations (default false) */
171
+ /** better support for headless operations (default false) */
174
172
  headless?: boolean;
175
173
 
176
174
  /** max size for image, in bytes */
@@ -179,16 +177,24 @@ export interface EmbeddedSpreadsheetOptions {
179
177
  /** initial scale */
180
178
  scale?: number;
181
179
 
182
- /** show scale buttons */
180
+ /**
181
+ * show scale control (slider) under the spreadsheet.
182
+ */
183
183
  scale_control?: boolean;
184
184
 
185
- /** show stats panel */
185
+ /**
186
+ * show the stats panel under the spreadsheet.
187
+ */
186
188
  stats?: boolean;
187
189
 
188
- /** save/load scale. this can optionally have a string key to disambiguate */
190
+ /**
191
+ * save/load scale. this can optionally have a string key to disambiguate
192
+ */
189
193
  persist_scale?: boolean|string;
190
194
 
191
- /** target window for hyperlinks (default _blank); set false to disable hyperlinks altogether */
195
+ /**
196
+ * target window for hyperlinks (default _blank); set false to disable hyperlinks altogether
197
+ */
192
198
  hyperlinks?: string|false;
193
199
 
194
200
  /**
@@ -209,25 +215,20 @@ export interface EmbeddedSpreadsheetOptions {
209
215
  */
210
216
  complex?: 'on'|'off';
211
217
 
212
- /* *
213
- * support complex numbers. the meaning of this flag is changing -- the
214
- * parser is going to always support complex numbers, but we might load
215
- * a different set of functions if they're not expected to be used.
216
- * ...
217
- * no, we're not doing that. atm complex support is always baked in.
218
- * @deprecated
219
- * @internal
220
- */
221
- // complex?: boolean;
222
-
223
218
  /**
224
219
  * for rendering the imaginary number. this is intended to support
225
220
  * switching to a different character for rendering, or adding a leading
226
221
  * space/half-space/hair-space.
222
+ *
223
+ * this _does_not_ change how you enter imaginary numbers, you still have
224
+ * to use `i` (lower-case ascii i).
227
225
  */
228
226
  imaginary_value?: string;
229
227
 
230
- /** support MD formatting for text */
228
+ /**
229
+ * support markdown formatting for text in cells and comments. at the
230
+ * moment we only support bold, italic, and strike text.
231
+ */
231
232
  markdown?: boolean;
232
233
 
233
234
  /**
@@ -236,15 +237,19 @@ export interface EmbeddedSpreadsheetOptions {
236
237
  */
237
238
  tint_theme_colors?: boolean;
238
239
 
239
- /** show a spinner for long-running operations */
240
+ /**
241
+ * show a spinner for long-running operations
242
+ */
240
243
  spinner?: boolean;
241
244
 
242
- /** collapsed: start sidebar closed */
245
+ /**
246
+ * start with sidebar closed. defaults to false.
247
+ */
243
248
  collapsed?: boolean;
244
249
 
245
250
  /**
246
- * show the revert button. see the Revert method. this was renamed
247
- * from `revert` to avoid any ambiguity.
251
+ * show the revert button in the sidebar. see the `Revert` method. this
252
+ * was renamed from `revert` to avoid any ambiguity.
248
253
  */
249
254
  revert_button?: boolean;
250
255
 
@@ -291,30 +296,3 @@ export const DefaultOptions: EmbeddedSpreadsheetOptions = {
291
296
  complex: 'off',
292
297
 
293
298
  };
294
-
295
- /* *
296
- * actual options requires the container node
297
- * /
298
- export interface EmbeddedSpreadsheetOptions extends BaseOptions {
299
- container?: string|HTMLElement;
300
- }
301
- */
302
-
303
- /**
304
- * embed creation adds option for icons
305
- */
306
- export interface CreateSheetOptions extends EmbeddedSpreadsheetOptions {
307
-
308
- /** icons */
309
- decorated?: boolean;
310
-
311
-
312
- /**
313
- * optional callback function on create. we're not using this anymore, but
314
- * leaving it in for backwards compatibility.
315
- *
316
- * @internal
317
- */
318
- load?: string;
319
-
320
- }