@trebco/treb 28.2.2 → 28.3.4

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 CHANGED
@@ -1,4 +1,4 @@
1
- /*! API v28.2. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
1
+ /*! API v28.3. 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
@@ -26,7 +26,7 @@ export declare class TREBGlobal {
26
26
  /**
27
27
  * create a spreadsheet instance
28
28
  */
29
- CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet;
29
+ CreateSpreadsheet<USER_DATA_TYPE = unknown>(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet<USER_DATA_TYPE>;
30
30
  }
31
31
 
32
32
  /** single instance of factory class */
@@ -276,7 +276,7 @@ export interface ICellAddress {
276
276
  /**
277
277
  * embedded spreadsheet
278
278
  */
279
- export declare class EmbeddedSpreadsheet {
279
+ export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
280
280
 
281
281
  /** document name (metadata) */
282
282
  get document_name(): string | undefined;
@@ -285,10 +285,10 @@ export declare class EmbeddedSpreadsheet {
285
285
  set document_name(name: string | undefined);
286
286
 
287
287
  /** opaque user data (metadata) */
288
- get user_data(): unknown;
288
+ get user_data(): USER_DATA_TYPE | undefined;
289
289
 
290
290
  /** opaque user data (metadata) */
291
- set user_data(data: unknown);
291
+ set user_data(data: USER_DATA_TYPE);
292
292
 
293
293
  /** current grid scale */
294
294
  get scale(): number;
@@ -333,6 +333,12 @@ export declare class EmbeddedSpreadsheet {
333
333
  */
334
334
  get dirty(): boolean;
335
335
 
336
+ /**
337
+ * explicitly set or clear the dirty flag. it's intended for use by clients
338
+ * that have their own save routine.
339
+ */
340
+ set dirty(value: boolean);
341
+
336
342
  /**
337
343
  * returns the names of all sheets in the current document
338
344
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "28.2.2",
3
+ "version": "28.3.4",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -14,13 +14,13 @@ import type { ToolbarMessage } from '../toolbar-message';
14
14
  import { DOMContext } from 'treb-base-types';
15
15
 
16
16
  /** @internal */
17
- export class SpreadsheetConstructor {
17
+ export class SpreadsheetConstructor<USER_DATA_TYPE = unknown> {
18
18
 
19
19
  /** container, if any */
20
20
  public root?: HTMLElement;
21
21
 
22
22
  /** spreadsheet instance */
23
- public sheet?: EmbeddedSpreadsheet
23
+ public sheet?: EmbeddedSpreadsheet<USER_DATA_TYPE>;
24
24
 
25
25
  /** current border color. will be applied to new borders. */
26
26
  protected border_color?: Color;
@@ -278,7 +278,7 @@ export class SpreadsheetConstructor {
278
278
 
279
279
  // set a local variable so we don't have to keep testing the member
280
280
 
281
- this.sheet = new EmbeddedSpreadsheet(options);
281
+ this.sheet = new EmbeddedSpreadsheet<USER_DATA_TYPE>(options);
282
282
 
283
283
  if (this.root) {
284
284
  this.CreateLayout(this.sheet, this.root);
@@ -27,9 +27,9 @@ export class TREBGlobal {
27
27
  /**
28
28
  * create a spreadsheet instance
29
29
  */
30
- public CreateSpreadsheet(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet {
30
+ public CreateSpreadsheet<USER_DATA_TYPE = unknown>(options: EmbeddedSpreadsheetOptions): EmbeddedSpreadsheet<USER_DATA_TYPE> {
31
31
  const container = options.container;
32
- const instance = new SpreadsheetConstructor(container);
32
+ const instance = new SpreadsheetConstructor<USER_DATA_TYPE>(container);
33
33
  instance.AttachElement(options);
34
34
  if (!instance.sheet) {
35
35
  throw new Error('construction failed');
@@ -221,7 +221,7 @@ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue
221
221
  /**
222
222
  * embedded spreadsheet
223
223
  */
224
- export class EmbeddedSpreadsheet {
224
+ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
225
225
 
226
226
  /** @internal */
227
227
  public static treb_base_path = '';
@@ -475,12 +475,12 @@ export class EmbeddedSpreadsheet {
475
475
  }
476
476
 
477
477
  /** opaque user data (metadata) */
478
- public get user_data(): unknown {
478
+ public get user_data(): USER_DATA_TYPE|undefined {
479
479
  return this.grid.model.user_data;
480
480
  }
481
481
 
482
482
  /** opaque user data (metadata) */
483
- public set user_data(data: unknown) {
483
+ public set user_data(data: USER_DATA_TYPE) {
484
484
  this.grid.model.user_data = data;
485
485
  this.DocumentChange();
486
486
  }
@@ -574,6 +574,19 @@ export class EmbeddedSpreadsheet {
574
574
  return this.file_version !== this.last_save_version;
575
575
  }
576
576
 
577
+ /**
578
+ * explicitly set or clear the dirty flag. it's intended for use by clients
579
+ * that have their own save routine.
580
+ */
581
+ public set dirty(value: boolean) {
582
+ if (value) {
583
+ this.file_version++;
584
+ }
585
+ else {
586
+ this.last_save_version = this.file_version;
587
+ }
588
+ }
589
+
577
590
  /**
578
591
  * returns the names of all sheets in the current document
579
592
  */
@@ -1172,7 +1185,7 @@ export class EmbeddedSpreadsheet {
1172
1185
  * create the correct type
1173
1186
  */
1174
1187
  protected CreateView(): EmbeddedSpreadsheet {
1175
- const child = new EmbeddedSpreadsheet({
1188
+ const child = new EmbeddedSpreadsheet<USER_DATA_TYPE>({
1176
1189
  ...this.options,
1177
1190
  global_name: undefined, // don't overwrite
1178
1191
  model: this,
@@ -5062,7 +5062,7 @@ export class Grid extends GridBase {
5062
5062
  if (found_number_format) {
5063
5063
 
5064
5064
  const style: CellStyle = {
5065
- number_format: found_number_format,
5065
+ number_format: NumberFormatCache.SymbolicName(found_number_format) || found_number_format,
5066
5066
  };
5067
5067
 
5068
5068
  commands.push({