@trebco/treb 26.0.6 → 27.0.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.
Files changed (50) hide show
  1. package/dist/treb-spreadsheet.mjs +14 -14
  2. package/dist/treb.d.ts +150 -337
  3. package/esbuild-utils.mjs +1 -1
  4. package/package.json +3 -3
  5. package/treb-base-types/src/cell.ts +3 -3
  6. package/treb-base-types/src/cells.ts +33 -15
  7. package/treb-base-types/src/color.ts +21 -21
  8. package/treb-base-types/src/import.ts +2 -2
  9. package/treb-base-types/src/style.ts +150 -288
  10. package/treb-base-types/src/table.ts +3 -2
  11. package/treb-base-types/src/theme.ts +18 -18
  12. package/treb-base-types/src/value-type.ts +20 -1
  13. package/treb-calculator/src/calculator.ts +4 -4
  14. package/treb-calculator/src/functions/checkbox.ts +8 -8
  15. package/treb-calculator/src/functions/sparkline.ts +25 -25
  16. package/treb-charts/style/charts.scss +8 -1
  17. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +10 -10
  18. package/treb-embed/src/embedded-spreadsheet.ts +15 -15
  19. package/treb-embed/src/selection-state.ts +2 -2
  20. package/treb-embed/src/toolbar-message.ts +3 -3
  21. package/treb-embed/src/types.ts +4 -4
  22. package/treb-embed/style/autocomplete.scss +1 -1
  23. package/treb-embed/style/dialog.scss +1 -1
  24. package/treb-embed/style/dropdown-select.scss +1 -1
  25. package/treb-embed/style/formula-bar.scss +1 -1
  26. package/treb-embed/style/grid.scss +1 -1
  27. package/treb-embed/style/layout.scss +13 -2
  28. package/treb-embed/style/mouse-mask.scss +1 -1
  29. package/treb-embed/style/note.scss +1 -1
  30. package/treb-embed/style/overlay-editor.scss +1 -1
  31. package/treb-embed/style/spinner.scss +1 -1
  32. package/treb-embed/style/tab-bar.scss +1 -1
  33. package/treb-embed/style/table.scss +1 -1
  34. package/treb-embed/style/theme-defaults.scss +1 -1
  35. package/treb-embed/style/toolbar.scss +1 -1
  36. package/treb-embed/style/tooltip.scss +1 -1
  37. package/treb-embed/style/treb-icons.scss +1 -1
  38. package/treb-export/src/export2.ts +6 -6
  39. package/treb-export/src/workbook-style2.ts +19 -19
  40. package/treb-grid/src/editors/overlay_editor.ts +4 -4
  41. package/treb-grid/src/render/tile_renderer.ts +15 -14
  42. package/treb-grid/src/types/annotation.ts +9 -6
  43. package/treb-grid/src/types/clipboard_data.ts +2 -2
  44. package/treb-grid/src/types/data_model.ts +2 -2
  45. package/treb-grid/src/types/grid.ts +9 -7
  46. package/treb-grid/src/types/grid_base.ts +9 -9
  47. package/treb-grid/src/types/grid_command.ts +3 -3
  48. package/treb-grid/src/types/grid_selection.ts +26 -1
  49. package/treb-grid/src/types/sheet.ts +66 -63
  50. package/treb-grid/src/types/sheet_types.ts +17 -10
package/esbuild-utils.mjs CHANGED
@@ -5,7 +5,7 @@ import * as esbuild from 'esbuild';
5
5
  import { promises as fs } from 'fs';
6
6
  import { minify } from 'html-minifier';
7
7
  import path from 'path';
8
- import sass from 'sass';
8
+ import * as sass from 'sass';
9
9
  import cssnano from 'cssnano';
10
10
  import postcss from 'postcss';
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "26.0.6",
3
+ "version": "27.0.1",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -12,12 +12,12 @@
12
12
  "type": "module",
13
13
  "devDependencies": {
14
14
  "@types/html-minifier": "^4.0.2",
15
- "@types/node": "^18.15.3",
15
+ "@types/node": "^20.4.0",
16
16
  "@typescript-eslint/eslint-plugin": "^5.30.4",
17
17
  "@typescript-eslint/parser": "^5.30.4",
18
18
  "archiver": "^5.3.0",
19
19
  "cssnano": "^6.0.0",
20
- "esbuild": "^0.17.11",
20
+ "esbuild": "^0.18.11",
21
21
  "eslint": "^8.19.0",
22
22
  "fast-xml-parser": "^4.0.7",
23
23
  "html-minifier": "^4.0.0",
@@ -22,7 +22,7 @@
22
22
  // import { Parser } from 'treb-parser';
23
23
 
24
24
  import type { Area, IArea } from './area';
25
- import type { Style } from './style';
25
+ import type { Style, CellStyle } from './style';
26
26
  import type { TextPart } from './text_part';
27
27
  import type { Complex } from './value-type';
28
28
  import { ValueType, GetValueType } from './value-type';
@@ -35,7 +35,7 @@ export interface RenderFunctionOptions {
35
35
  width: number;
36
36
  context: CanvasRenderingContext2D;
37
37
  cell: Cell;
38
- style: Style.Properties;
38
+ style: CellStyle;
39
39
  scale?: number;
40
40
  }
41
41
 
@@ -275,7 +275,7 @@ export class Cell {
275
275
  // data (FIXME: if style is an object, this would just be a pointer, so
276
276
  // why not just use a reference?)
277
277
  // style:number = 0;
278
- public style?: Style.Properties;
278
+ public style?: CellStyle;
279
279
 
280
280
  /** if this cell is part of an array, pointer to the area. */
281
281
  public area?: Area;
@@ -31,7 +31,7 @@ import { Cell } from './cell';
31
31
  import type { Table } from './table';
32
32
  import { type SerializedValueType, ValueType, GetValueType, ValueTypeList } from './value-type';
33
33
  import type { CellValue, UnionValue } from './union';
34
- import type { Style } from './style';
34
+ import type { Style, CellStyle } from './style';
35
35
 
36
36
  export interface CellSerializationOptions {
37
37
  preserve_type?: boolean;
@@ -88,7 +88,13 @@ export interface BaseCellData {
88
88
  // locked?: boolean;
89
89
  }
90
90
 
91
- export interface FlatCellData extends BaseCellData {
91
+ /**
92
+ * this type is for serialized data that includes the row and column
93
+ * in each cell. this was the original serialized data type, and is
94
+ * still supported. current serialization will group data into rows or
95
+ * columns, whichever results in a smaller overall serialized representation.
96
+ */
97
+ export interface CellDataWithAddress extends BaseCellData {
92
98
  row: number;
93
99
  column: number;
94
100
  }
@@ -97,31 +103,43 @@ export interface NestedCellData {
97
103
  cells: BaseCellData[];
98
104
  }
99
105
 
106
+ /**
107
+ * this type is for serialized data that is grouped by row, with each
108
+ * cell referencing a column in the spreadsheet.
109
+ */
110
+ export interface CellDataWithColumn extends BaseCellData {
111
+ column: number;
112
+ }
113
+
100
114
  export interface NestedRowData extends NestedCellData {
101
115
  row: number;
102
- cells: Array<{
103
- column: number;
104
- } & BaseCellData>;
116
+ cells: CellDataWithColumn[];
117
+ }
118
+
119
+ /**
120
+ * this type is for serialized data that is grouped by column, with each
121
+ * cell referencing a row in the spreadsheet.
122
+ */
123
+ export interface CellDataWithRow extends BaseCellData {
124
+ row: number;
105
125
  }
106
126
 
107
127
  export interface NestedColumnData extends NestedCellData {
108
128
  column: number;
109
- cells: Array<{
110
- row: number;
111
- } & BaseCellData>;
129
+ cells: CellDataWithRow[];
112
130
  }
113
131
 
114
- export type SerializedCellData = FlatCellData[]|NestedRowData[]|NestedColumnData[];
132
+ export type SerializedCellData = CellDataWithAddress[]|NestedRowData[]|NestedColumnData[];
115
133
 
116
134
  // some type guards for the various data types
117
135
 
118
136
  /** @internal */
119
- export const IsFlatData = (test: FlatCellData|NestedCellData): test is FlatCellData => {
137
+ export const IsFlatData = (test: CellDataWithAddress|NestedCellData): test is CellDataWithAddress => {
120
138
  return !(test as NestedCellData).cells;
121
139
  }
122
140
 
123
141
  /** @internal */
124
- export const IsFlatDataArray = (test: FlatCellData[]|NestedCellData[]): test is FlatCellData[] => {
142
+ export const IsFlatDataArray = (test: CellDataWithAddress[]|NestedCellData[]): test is CellDataWithAddress[] => {
125
143
  return (!!test[0]) && IsFlatData(test[0]);
126
144
  };
127
145
 
@@ -418,7 +436,7 @@ export class Cells {
418
436
  /**
419
437
  * UPDATE: adding optional style refs, for export
420
438
  */
421
- public FromJSON(data: SerializedCellData = [], style_refs?: Style.Properties[]): void {
439
+ public FromJSON(data: SerializedCellData = [], style_refs?: CellStyle[]): void {
422
440
 
423
441
  this.data = [];
424
442
 
@@ -428,7 +446,7 @@ export class Cells {
428
446
 
429
447
  if (!IsFlatDataArray(data)) {
430
448
 
431
- const new_data: FlatCellData[] = [];
449
+ const new_data: CellDataWithAddress[] = [];
432
450
 
433
451
  if (IsNestedRowArray(data)) {
434
452
  for (const block of data) {
@@ -595,7 +613,7 @@ export class Cells {
595
613
  end_row = options.subset.end.row;
596
614
  }
597
615
 
598
- const data: FlatCellData[] = [];
616
+ const data: CellDataWithAddress[] = [];
599
617
 
600
618
  let last_row = -1;
601
619
  let last_col = -1;
@@ -662,7 +680,7 @@ export class Cells {
662
680
  ( cell.style.fill || cell.style.border_bottom ||
663
681
  cell.style.border_top || cell.style.border_left || cell.style.border_right)))){
664
682
 
665
- const obj: FlatCellData = { row, column, value: cell.value };
683
+ const obj: CellDataWithAddress = { row, column, value: cell.value };
666
684
  if (cell.note) {
667
685
  obj.note = cell.note;
668
686
  }
@@ -22,32 +22,34 @@
22
22
  /**
23
23
  * utility functions, primarily for adjusting lightness. since we generally
24
24
  * traffic in RGB (or symbolic colors) that requires translating to/from HSL.
25
+ *
26
+ * @internal
25
27
  */
26
- class ColorFunctions {
28
+ export const ColorFunctions = {
27
29
 
28
30
  /** darken rgb color by amount (%), optionally relative */
29
- public Darken(r: number, g: number, b: number, amount: number, relative = false) {
31
+ Darken: (r: number, g: number, b: number, amount: number, relative = false) => {
30
32
 
31
33
  // eslint-disable-next-line prefer-const
32
- let { h, s, l } = this.RGBToHSL(r, g, b);
34
+ let { h, s, l } = ColorFunctions.RGBToHSL(r, g, b);
33
35
  if (relative) l -= l * amount / 100;
34
36
  else l -= amount / 100;
35
37
  l = Math.max(0, Math.min(1, l));
36
- return this.HSLToRGB(h, s, l);
37
- }
38
+ return ColorFunctions.HSLToRGB(h, s, l);
39
+ },
38
40
 
39
41
  /** lighten rgb color by amount (%), optionally relative */
40
- public Lighten(r: number, g: number, b: number, amount: number, relative = false) {
42
+ Lighten: (r: number, g: number, b: number, amount: number, relative = false) => {
41
43
 
42
44
  // eslint-disable-next-line prefer-const
43
- let { h, s, l } = this.RGBToHSL(r, g, b);
45
+ let { h, s, l } = ColorFunctions.RGBToHSL(r, g, b);
44
46
  if (relative) l += l * amount / 100;
45
47
  else l += amount / 100;
46
48
  l = Math.max(0, Math.min(1, l));
47
- return this.HSLToRGB(h, s, l);
48
- }
49
+ return ColorFunctions.HSLToRGB(h, s, l);
50
+ },
49
51
 
50
- public RGBToHSL(r: number, g: number, b: number) {
52
+ RGBToHSL: (r: number, g: number, b: number) => {
51
53
 
52
54
  r /= 255;
53
55
  g /= 255;
@@ -82,9 +84,9 @@ class ColorFunctions {
82
84
  }
83
85
 
84
86
  return { h: h * 360, s, l };
85
- }
87
+ },
86
88
 
87
- public HSLToRGB(h: number, s: number, l: number) {
89
+ HSLToRGB: (h: number, s: number, l: number) => {
88
90
 
89
91
  let r: number;
90
92
  let g: number;
@@ -97,9 +99,9 @@ class ColorFunctions {
97
99
  h = h / 360;
98
100
  const q = l < 0.5 ? l * (1 + s) : l + s - l * s;
99
101
  const p = 2 * l - q;
100
- r = this.HueToRGB(p, q, h + 1 / 3);
101
- g = this.HueToRGB(p, q, h);
102
- b = this.HueToRGB(p, q, h - 1 / 3);
102
+ r = ColorFunctions.HueToRGB(p, q, h + 1 / 3);
103
+ g = ColorFunctions.HueToRGB(p, q, h);
104
+ b = ColorFunctions.HueToRGB(p, q, h - 1 / 3);
103
105
  }
104
106
 
105
107
  return {
@@ -107,18 +109,16 @@ class ColorFunctions {
107
109
  g: Math.round(g * 255),
108
110
  b: Math.round(b * 255),
109
111
  };
110
- }
112
+ },
111
113
 
112
- private HueToRGB(p: number, q: number, t: number) {
114
+ HueToRGB: (p: number, q: number, t: number) => {
113
115
  if (t < 0) t += 1;
114
116
  if (t > 1) t -= 1;
115
117
  if (t < 1 / 6) return p + (q - p) * 6 * t;
116
118
  if (t < 1 / 2) return q;
117
119
  if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
118
120
  return p;
119
- }
121
+ },
120
122
 
121
- }
123
+ };
122
124
 
123
- /** @internal */
124
- export const Color = new ColorFunctions();
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- import type { Style } from './style';
22
+ import type { CellStyle } from './style';
23
23
  import type { SerializedValueType, ValueType } from './value-type';
24
24
  import type { IArea } from './area';
25
25
  import type { AnnotationLayout } from './layout';
@@ -57,7 +57,7 @@ export interface ImportedSheetData {
57
57
  default_column_width: number;
58
58
  column_widths: number[];
59
59
  row_heights: number[];
60
- styles: Style.Properties[];
60
+ styles: CellStyle[];
61
61
 
62
62
  // optional, for backcompat
63
63
  sheet_style?: number;