@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
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  /**
25
25
  * event mask for mouse drag. currently this is added _within_ node
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  // are these exactly the same? clearly we copied-and-pasted
25
25
  // at first. seems like we could consolidate.
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  .treb-grid {
25
25
 
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  .treb-spinner {
25
25
 
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  .treb-mouse-mask .ghost-tab {
25
25
  position: fixed;
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  .treb-sort-button {
25
25
 
@@ -50,7 +50,7 @@ $text-reference-color-3: rgb(182, 109, 13);
50
50
  $text-reference-color-4: rgb(33, 118, 174);
51
51
  $text-reference-color-5: rgb(254, 47, 1);
52
52
 
53
- .treb-main {
53
+ .treb-main.treb-main {
54
54
 
55
55
  /**
56
56
  * move primary selection focus color to focus-within on the top-level
@@ -18,7 +18,7 @@ $border-radius: 3px;
18
18
  $split-font-size: 10px;
19
19
  $swatch-size: 18px;
20
20
 
21
- .treb-main {
21
+ .treb-main.treb-main {
22
22
 
23
23
  .treb-layout-header {
24
24
 
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- .treb-main {
22
+ .treb-main.treb-main {
23
23
 
24
24
  .treb-tooltip {
25
25
 
@@ -3,7 +3,7 @@
3
3
  * scope these to the node and we can use shorter names
4
4
  */
5
5
 
6
- .treb-main {
6
+ .treb-main.treb-main {
7
7
 
8
8
  // --- other -----------------------------------------------------------------
9
9
 
@@ -34,7 +34,7 @@ const XMLDeclaration = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\
34
34
  import { template } from './template-2';
35
35
  import type { SerializedSheet } from 'treb-grid';
36
36
 
37
- import type { IArea, ICellAddress, CellValue, DataValidation,
37
+ import type { IArea, ICellAddress, CellValue, DataValidation, CellStyle,
38
38
  AnnotationLayout, Corner as LayoutCorner, Cell, Rectangle } from 'treb-base-types';
39
39
  import { Area, Cells, ValueType, Style, ValidationType } from 'treb-base-types';
40
40
 
@@ -527,7 +527,7 @@ export class Exporter {
527
527
  public RowStyle(sheet: SerializedSheet, style_cache: StyleCache, row: number) {
528
528
 
529
529
  const cell_style_refs = sheet.styles || sheet.cell_style_refs || [];
530
- const list: Style.Properties[] = [sheet.sheet_style];
530
+ const list: CellStyle[] = [sheet.sheet_style];
531
531
 
532
532
  if (sheet.row_style) {
533
533
  let style = sheet.row_style[row];
@@ -550,7 +550,7 @@ export class Exporter {
550
550
  public ColumnStyle(sheet: SerializedSheet, style_cache: StyleCache, column: number) {
551
551
 
552
552
  const cell_style_refs = sheet.styles || sheet.cell_style_refs || [];
553
- const list: Style.Properties[] = [sheet.sheet_style];
553
+ const list: CellStyle[] = [sheet.sheet_style];
554
554
 
555
555
  if (sheet.column_style) {
556
556
  let style = sheet.column_style[column];
@@ -570,14 +570,14 @@ export class Exporter {
570
570
 
571
571
  }
572
572
 
573
- public StyleFromCell(sheet: SerializedSheet, style_cache: StyleCache, row: number, column: number, style: Style.Properties = {}) {
573
+ public StyleFromCell(sheet: SerializedSheet, style_cache: StyleCache, row: number, column: number, style: CellStyle = {}) {
574
574
 
575
575
  //if (row === 2 && column === 5)
576
576
  // console.info("SFC", JSON.stringify(style, undefined, 2));
577
577
 
578
578
  const cell_style_refs = sheet.styles || sheet.cell_style_refs || [];
579
579
 
580
- const list: Style.Properties[] = [sheet.sheet_style];
580
+ const list: CellStyle[] = [sheet.sheet_style];
581
581
 
582
582
  if (sheet.row_pattern && sheet.row_pattern.length) {
583
583
  list.push(sheet.row_pattern[row % sheet.row_pattern.length]);
@@ -1298,7 +1298,7 @@ export class Exporter {
1298
1298
  const sparklines: Array<{
1299
1299
  address: ICellAddress,
1300
1300
  formula: string,
1301
- style?: Style.Properties,
1301
+ style?: CellStyle,
1302
1302
  }> = [];
1303
1303
 
1304
1304
  const merges: Area[] = [];
@@ -22,7 +22,7 @@
22
22
  // import * as ElementTree from 'elementtree';
23
23
  // import { Element, ElementTree as Tree } from 'elementtree';
24
24
 
25
- import { Style } from 'treb-base-types';
25
+ import { type CompositeBorderEdge, Style, type CellStyle, type PropertyKeys } from 'treb-base-types';
26
26
  import { Theme } from './workbook-theme2';
27
27
  import { NumberFormatCache } from 'treb-format';
28
28
  import { XMLUtils } from './xml-utils';
@@ -237,12 +237,12 @@ export class StyleCache {
237
237
 
238
238
  ///
239
239
 
240
- public StyleOptionsFromProperties(source: Style.Properties): StyleOptions {
240
+ public StyleOptionsFromProperties(source: CellStyle): StyleOptions {
241
241
 
242
- const composite: Style.Properties = // Style.Composite(list);
242
+ const composite: CellStyle = // Style.Composite(list);
243
243
  JSON.parse(JSON.stringify(source));
244
244
 
245
- for (const key of Object.keys(composite) as Style.PropertyKeys[]) {
245
+ for (const key of Object.keys(composite) as PropertyKeys[]) {
246
246
  if (composite[key] === 'none') {
247
247
  delete composite[key];
248
248
  }
@@ -297,7 +297,7 @@ export class StyleCache {
297
297
  }
298
298
  }
299
299
 
300
- const TranslateBorder = (src: Style.CompositeBorderEdge, dest: BorderEdge) => {
300
+ const TranslateBorder = (src: CompositeBorderEdge, dest: BorderEdge) => {
301
301
  if (src.width) {
302
302
  dest.style = 'thin';
303
303
  if (src.color.text) {
@@ -399,22 +399,22 @@ export class StyleCache {
399
399
  // leave blank for bottom, default
400
400
 
401
401
  switch (composite.vertical_align) {
402
- case Style.VerticalAlign.Top:
402
+ case 'top': // Style.VerticalAlign.Top:
403
403
  options.vertical_alignment = 'top';
404
404
  break;
405
- case Style.VerticalAlign.Middle:
405
+ case 'middle': // Style.VerticalAlign.Middle:
406
406
  options.vertical_alignment = 'center';
407
407
  break;
408
408
  }
409
409
 
410
410
  switch (composite.horizontal_align) {
411
- case Style.HorizontalAlign.Center:
411
+ case 'center': // Style.HorizontalAlign.Center:
412
412
  options.horizontal_alignment = 'center';
413
413
  break;
414
- case Style.HorizontalAlign.Left:
414
+ case 'left': // Style.HorizontalAlign.Left:
415
415
  options.horizontal_alignment = 'left';
416
416
  break;
417
- case Style.HorizontalAlign.Right:
417
+ case 'right': // Style.HorizontalAlign.Right:
418
418
  options.horizontal_alignment = 'right';
419
419
  break;
420
420
  }
@@ -446,9 +446,9 @@ export class StyleCache {
446
446
 
447
447
  ///
448
448
 
449
- public CellXfToStyle(xf: CellXf): Style.Properties {
449
+ public CellXfToStyle(xf: CellXf): CellStyle {
450
450
 
451
- const props: Style.Properties = {};
451
+ const props: CellStyle = {};
452
452
 
453
453
  // number format
454
454
 
@@ -625,25 +625,25 @@ export class StyleCache {
625
625
 
626
626
  switch (xf.horizontal_alignment) {
627
627
  case 'center':
628
- props.horizontal_align = Style.HorizontalAlign.Center;
628
+ props.horizontal_align = 'center'; // Style.HorizontalAlign.Center;
629
629
  break;
630
630
  case 'right':
631
- props.horizontal_align = Style.HorizontalAlign.Right;
631
+ props.horizontal_align = 'right'; // Style.HorizontalAlign.Right;
632
632
  break;
633
633
  case 'left':
634
- props.horizontal_align = Style.HorizontalAlign.Left;
634
+ props.horizontal_align = 'left'; // Style.HorizontalAlign.Left;
635
635
  break;
636
636
  }
637
637
 
638
638
  switch (xf.vertical_alignment) {
639
639
  case 'center':
640
- props.vertical_align = Style.VerticalAlign.Middle;
640
+ props.vertical_align = 'middle'; // Style.VerticalAlign.Middle;
641
641
  break;
642
642
  case 'top':
643
- props.vertical_align = Style.VerticalAlign.Top;
643
+ props.vertical_align = 'top'; // Style.VerticalAlign.Top;
644
644
  break;
645
645
  case 'bottom':
646
- props.vertical_align = Style.VerticalAlign.Bottom;
646
+ props.vertical_align = 'bottom'; // Style.VerticalAlign.Bottom;
647
647
  break;
648
648
  }
649
649
 
@@ -674,7 +674,7 @@ export class StyleCache {
674
674
  }
675
675
 
676
676
  /** map all cell xfs to styles; retain order */
677
- public CellXfToStyles(): Style.Properties[] {
677
+ public CellXfToStyles(): CellStyle[] {
678
678
  return this.cell_xfs.map((xf) => this.CellXfToStyle(xf));
679
679
  }
680
680
 
@@ -29,7 +29,7 @@
29
29
  */
30
30
 
31
31
  import type { Theme, CellValue, Rectangle, Cell } from 'treb-base-types';
32
- import { Style, ThemeColor2 } from 'treb-base-types';
32
+ import { Style, ThemeColor2, type CellStyle } from 'treb-base-types';
33
33
  import { Yield } from 'treb-utils';
34
34
  import type { Parser } from 'treb-parser';
35
35
  import type { GridSelection } from '../types/grid_selection';
@@ -288,7 +288,7 @@ export class OverlayEditor extends FormulaEditorBase {
288
288
  this.active_cell = cell;
289
289
  this.target_address = {...gridselection.target};
290
290
 
291
- const style: Style.Properties = cell.style || {};
291
+ const style: CellStyle = cell.style || {};
292
292
 
293
293
  this.edit_node.style.font = Style.Font(style, this.scale);
294
294
  this.edit_node.style.color = ThemeColor2(this.theme, style.text, 1);
@@ -303,11 +303,11 @@ export class OverlayEditor extends FormulaEditorBase {
303
303
  // until v[x]? I think that may have been years ago...)
304
304
 
305
305
  switch (style.horizontal_align) {
306
- case Style.HorizontalAlign.Right:
306
+ case 'right': // Style.HorizontalAlign.Right:
307
307
  this.edit_container.classList.remove('align-center', 'align-left');
308
308
  this.edit_container.classList.add('align-right');
309
309
  break;
310
- case Style.HorizontalAlign.Center:
310
+ case 'center': // Style.HorizontalAlign.Center:
311
311
  this.edit_container.classList.remove('align-right', 'align-left');
312
312
  this.edit_container.classList.add('align-center');
313
313
  break;
@@ -22,6 +22,7 @@
22
22
  import type { ICellAddress,
23
23
  PreparedText, RenderTextPart,
24
24
  Cell, Size,
25
+ CellStyle,
25
26
  Theme} from 'treb-base-types';
26
27
  import { TextPartFlag, Style, ValueType, Area, Rectangle, ThemeColor, ThemeColor2 } from 'treb-base-types';
27
28
 
@@ -711,7 +712,7 @@ export class TileRenderer {
711
712
  cell_width: number /*, override_text?: string*/ ): PreparedText {
712
713
 
713
714
  const strings: RenderTextPart[] = [];
714
- const style: Style.Properties = cell.style || {};
715
+ const style: CellStyle = cell.style || {};
715
716
 
716
717
  let pad_entry: RenderTextPart | undefined;
717
718
  let composite_width = 0;
@@ -982,7 +983,7 @@ export class TileRenderer {
982
983
 
983
984
  }
984
985
 
985
- protected ResolveColors(style: Style.Properties): Style.Properties {
986
+ protected ResolveColors(style: CellStyle): CellStyle {
986
987
 
987
988
  const resolved = {...style};
988
989
  resolved.text = { text: ThemeColor2(this.theme, style.text, 1) };
@@ -996,7 +997,7 @@ export class TileRenderer {
996
997
  protected RenderCellBorders(
997
998
  address: ICellAddress,
998
999
  context: CanvasRenderingContext2D,
999
- style: Style.Properties,
1000
+ style: CellStyle,
1000
1001
  left = 0, top = 0, width = 0, height = 0): void {
1001
1002
 
1002
1003
  // cell borders is one of those things that seems simple, even trivial,
@@ -1312,7 +1313,7 @@ export class TileRenderer {
1312
1313
  note: boolean,
1313
1314
  address: ICellAddress,
1314
1315
  context: CanvasRenderingContext2D,
1315
- style: Style.Properties,
1316
+ style: CellStyle,
1316
1317
  width: number, height: number, cell_left = 0, cell_top = 0): void {
1317
1318
 
1318
1319
  // so here we draw the background and the bottom and right grid edges.
@@ -1405,7 +1406,7 @@ export class TileRenderer {
1405
1406
  return {};
1406
1407
  }
1407
1408
 
1408
- let style: Style.Properties = cell.style ? {...cell.style} : {};
1409
+ let style: CellStyle = cell.style ? {...cell.style} : {};
1409
1410
 
1410
1411
  if (cell.table) {
1411
1412
  style = this.view.active_sheet.CellStyleData(address, cell.table.theme || this.theme.table) || {};
@@ -1616,7 +1617,7 @@ export class TileRenderer {
1616
1617
 
1617
1618
  let horizontal_align = style.horizontal_align;
1618
1619
  if (!horizontal_align) {
1619
- horizontal_align = is_number ? Style.HorizontalAlign.Right : Style.HorizontalAlign.Left;
1620
+ horizontal_align = is_number ? 'right' : 'left'; // Style.HorizontalAlign.Right : Style.HorizontalAlign.Left;
1620
1621
  }
1621
1622
 
1622
1623
  // NOTE: text rendering options (align, baseline) are set globally
@@ -1649,10 +1650,10 @@ export class TileRenderer {
1649
1650
  let overflow_pixels_left = 0;
1650
1651
  let overflow_pixels_right = 0;
1651
1652
 
1652
- if (horizontal_align === Style.HorizontalAlign.Center) {
1653
+ if (horizontal_align === 'center' /* Style.HorizontalAlign.Center */ ) {
1653
1654
  overflow_pixels_left = overflow_pixels_right = delta / 2;
1654
1655
  }
1655
- else if (horizontal_align === Style.HorizontalAlign.Right) {
1656
+ else if (horizontal_align === 'right' /* Style.HorizontalAlign.Right */ ) {
1656
1657
  overflow_pixels_left = delta;
1657
1658
  }
1658
1659
  else {
@@ -1884,10 +1885,10 @@ export class TileRenderer {
1884
1885
  let original_baseline = Math.round(height - 2 - (m2.block * line_height * (line_count - 1)) + WK); // switched baseline to "bottom"
1885
1886
 
1886
1887
  switch (style.vertical_align) {
1887
- case Style.VerticalAlign.Top:
1888
+ case 'top': // Style.VerticalAlign.Top:
1888
1889
  original_baseline = Math.round(m2.block * line_height) + 1;
1889
1890
  break;
1890
- case Style.VerticalAlign.Middle:
1891
+ case 'middle': // Style.VerticalAlign.Middle:
1891
1892
  original_baseline = Math.round((height - text_height) / 2 + m2.block * line_height);
1892
1893
  break;
1893
1894
  }
@@ -1905,10 +1906,10 @@ export class TileRenderer {
1905
1906
  for (let i = 0; i < count; i++) { text += '#'; }
1906
1907
  const text_width = context.measureText(text).width;
1907
1908
 
1908
- if (horizontal_align === Style.HorizontalAlign.Center) {
1909
+ if (horizontal_align === 'center' /* Style.HorizontalAlign.Center */ ) {
1909
1910
  left = Math.round((width - text_width) / 2);
1910
1911
  }
1911
- else if (horizontal_align === Style.HorizontalAlign.Right) {
1912
+ else if (horizontal_align === 'right' /* Style.HorizontalAlign.Right */ ) {
1912
1913
  left = width - this.cell_edge_buffer - text_width;
1913
1914
  }
1914
1915
 
@@ -1931,10 +1932,10 @@ export class TileRenderer {
1931
1932
  let line_width = 0;
1932
1933
  for (const part of line) { line_width += part.width; }
1933
1934
 
1934
- if (horizontal_align === Style.HorizontalAlign.Center) {
1935
+ if (horizontal_align === 'center' /* Style.HorizontalAlign.Center */ ) {
1935
1936
  left = Math.round((width - line_width) / 2);
1936
1937
  }
1937
- else if (horizontal_align === Style.HorizontalAlign.Right) {
1938
+ else if (horizontal_align === 'right' /* Style.HorizontalAlign.Right */ ) {
1938
1939
  left = width - this.cell_edge_buffer - line_width;
1939
1940
  }
1940
1941
 
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- import type { ICellAddress, AnnotationLayout } from 'treb-base-types';
22
+ import type { ICellAddress, AnnotationLayout, IRectangle } from 'treb-base-types';
23
23
  import { Rectangle } from 'treb-base-types';
24
24
 
25
25
  /**
@@ -79,6 +79,11 @@ export interface ViewData {
79
79
 
80
80
  }
81
81
 
82
+ export interface ImageSize {
83
+ width: number;
84
+ height: number;
85
+ }
86
+
82
87
  export interface ImageAnnotationData {
83
88
  src: string;
84
89
 
@@ -88,10 +93,8 @@ export interface ImageAnnotationData {
88
93
  */
89
94
  scale: string;
90
95
 
91
- original_size: {
92
- width: number;
93
- height: number;
94
- };
96
+ original_size: ImageSize;
97
+
95
98
  }
96
99
 
97
100
  export type AnnotationType = 'treb-chart'|'image'|'external';
@@ -120,7 +123,7 @@ export interface AnnotationDataBase {
120
123
  * for serialization/deserialization. the actual rectangle is maintained
121
124
  * in the Annotation class.
122
125
  */
123
- rect?: Partial<Rectangle>;
126
+ rect?: Partial<IRectangle>;
124
127
 
125
128
  /** annotation can be resized. this is advisory, for UI */
126
129
  resizable: boolean;
@@ -20,12 +20,12 @@
20
20
  */
21
21
 
22
22
 
23
- import type { ICellAddress, CellValue, ValueType, Style } from 'treb-base-types';
23
+ import type { ICellAddress, CellValue, ValueType, CellStyle } from 'treb-base-types';
24
24
 
25
25
  export interface ClipboardCellData {
26
26
  address: ICellAddress;
27
27
  data: CellValue;
28
28
  type: ValueType;
29
- style?: Style.Properties;
29
+ style?: CellStyle;
30
30
  array?: {rows: number, columns: number};
31
31
  }
@@ -20,7 +20,7 @@
20
20
  */
21
21
 
22
22
  import type { Sheet } from './sheet';
23
- import type { IArea, ICellAddress, Table } from 'treb-base-types';
23
+ import type { IArea, ICellAddress, Table, CellStyle } from 'treb-base-types';
24
24
  import type { SerializedSheet } from './sheet_types';
25
25
  import { NamedRangeCollection } from './named_range';
26
26
  import type { ExpressionUnit, UnitAddress, UnitStructuredReference, UnitRange } from 'treb-parser';
@@ -200,7 +200,7 @@ export class DataModel {
200
200
  * base style properties moved to model, so we can have a single
201
201
  * and consistent reference.
202
202
  */
203
- public theme_style_properties: Style.Properties = JSON.parse(JSON.stringify(Style.DefaultProperties));
203
+ public theme_style_properties: CellStyle = JSON.parse(JSON.stringify(Style.DefaultProperties));
204
204
 
205
205
  /**
206
206
  * tables are global, because we need to reference them by name; and they
@@ -28,6 +28,8 @@ import type {
28
28
  ICellAddress,
29
29
  ImportedSheetData,
30
30
  Complex,
31
+ Color,
32
+ CellStyle,
31
33
  IRectangle} from 'treb-base-types';
32
34
 
33
35
  import {
@@ -1670,7 +1672,7 @@ export class Grid extends GridBase {
1670
1672
  * @param range
1671
1673
  * @returns
1672
1674
  */
1673
- public GetRangeStyle(range: ICellAddress|IArea, apply_theme = false): Style.Properties|Style.Properties[][]|undefined {
1675
+ public GetRangeStyle(range: ICellAddress|IArea, apply_theme = false): CellStyle|CellStyle[][]|undefined {
1674
1676
 
1675
1677
  let sheet_id = 0;
1676
1678
 
@@ -1879,7 +1881,7 @@ export class Grid extends GridBase {
1879
1881
  *
1880
1882
  * API method
1881
1883
  */
1882
- public ApplyStyle(area?: Area, properties: Style.Properties = {}, delta = true): void {
1884
+ public ApplyStyle(area?: Area, properties: CellStyle = {}, delta = true): void {
1883
1885
 
1884
1886
  if (!area) {
1885
1887
  if (this.primary_selection.empty) {
@@ -1949,7 +1951,7 @@ export class Grid extends GridBase {
1949
1951
  */
1950
1952
 
1951
1953
  /** updated API method, probably change the name */
1952
- public ApplyBorders2(area?: Area, borders: BorderConstants = BorderConstants.None, color?: Style.Color, width = 1): void {
1954
+ public ApplyBorders2(area?: Area, borders: BorderConstants = BorderConstants.None, color?: Color, width = 1): void {
1953
1955
 
1954
1956
  if (!area) {
1955
1957
  if (this.primary_selection.empty) { return; }
@@ -4086,7 +4088,7 @@ export class Grid extends GridBase {
4086
4088
  }
4087
4089
 
4088
4090
  const data: CellValue[][] = [];
4089
- let style: Style.Properties[][] = [];
4091
+ let style: CellStyle[][] = [];
4090
4092
 
4091
4093
  let source_columns = source_area.columns;
4092
4094
  let target_rows = target_area.rows;
@@ -4453,8 +4455,8 @@ export class Grid extends GridBase {
4453
4455
  }
4454
4456
  else {
4455
4457
 
4456
- const applied_style: Style.Properties = {};
4457
- const selected_style: Style.Properties =
4458
+ const applied_style: CellStyle = {};
4459
+ const selected_style: CellStyle =
4458
4460
  this.primary_selection.empty ? {} :
4459
4461
  this.active_sheet.CellData(this.primary_selection.target).style || {};
4460
4462
 
@@ -4932,7 +4934,7 @@ export class Grid extends GridBase {
4932
4934
  if (this.active_sheet.HasCellStyle({ ...address })) {
4933
4935
  const test = this.active_sheet.CellData({ ...address });
4934
4936
  if (test.style && test.style.number_format) {
4935
- const style: Style.Properties = {
4937
+ const style: CellStyle = {
4936
4938
  number_format: test.style.number_format,
4937
4939
  };
4938
4940
  // if (array) this.model.sheet.UpdateAreaStyle(selection.area, style, true, true);
@@ -40,7 +40,7 @@ import type { DataModel, MacroFunction, SerializedModel, SerializedNamedExpressi
40
40
  import type { Parser, UnitAddress} from 'treb-parser';
41
41
  import { type ExpressionUnit, IllegalSheetNameRegex, ParseCSV, ArgumentSeparatorType, DecimalMarkType } from 'treb-parser';
42
42
  import { Area, IsCellAddress, ValidationType, ValueType, DefaultTableSortOptions } from 'treb-base-types';
43
- import type { ICellAddress, IArea, Cell, CellValue , Style, Table, TableSortOptions, TableTheme, Complex } from 'treb-base-types';
43
+ import type { ICellAddress, IArea, Cell, CellValue , Style, CellStyle, Table, TableSortOptions, TableTheme, Complex } from 'treb-base-types';
44
44
  import { Sheet } from './sheet';
45
45
  import type { FunctionDescriptor} from '../editors/autocomplete_matcher';
46
46
  import { AutocompleteMatcher, DescriptorType } from '../editors/autocomplete_matcher';
@@ -2254,15 +2254,15 @@ export class GridBase {
2254
2254
  }
2255
2255
  */
2256
2256
 
2257
- const top: Style.Properties = { border_top: width };
2258
- const bottom: Style.Properties = { border_bottom: width };
2259
- const left: Style.Properties = { border_left: width };
2260
- const right: Style.Properties = { border_right: width };
2257
+ const top: CellStyle = { border_top: width };
2258
+ const bottom: CellStyle = { border_bottom: width };
2259
+ const left: CellStyle = { border_left: width };
2260
+ const right: CellStyle = { border_right: width };
2261
2261
 
2262
- const clear_top: Style.Properties = { border_top: 0, border_top_fill: {} };
2263
- const clear_bottom: Style.Properties = { border_bottom: 0, border_bottom_fill: {} };
2264
- const clear_left: Style.Properties = { border_left: 0, border_left_fill: {} };
2265
- const clear_right: Style.Properties = { border_right: 0, border_right_fill: {} };
2262
+ const clear_top: CellStyle = { border_top: 0, border_top_fill: {} };
2263
+ const clear_bottom: CellStyle = { border_bottom: 0, border_bottom_fill: {} };
2264
+ const clear_left: CellStyle = { border_left: 0, border_left_fill: {} };
2265
+ const clear_right: CellStyle = { border_right: 0, border_right_fill: {} };
2266
2266
 
2267
2267
  // default to "none", which means "default"
2268
2268
 
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- import type { ICellAddress, IArea, Style, CellValue, Table, TableSortType, TableTheme } from 'treb-base-types';
22
+ import type { ICellAddress, IArea, Style, CellStyle, Color, CellValue, Table, TableSortType, TableTheme } from 'treb-base-types';
23
23
  import type { ExpressionUnit } from 'treb-parser';
24
24
  import type { BorderConstants } from './border_constants';
25
25
 
@@ -268,7 +268,7 @@ export interface UpdateBordersCommand {
268
268
  area: IArea;
269
269
  borders: BorderConstants;
270
270
  // color?: string; // pending
271
- color?: Style.Color;
271
+ color?: Color;
272
272
 
273
273
  /** defaults to one. optional for the case of "none" (remove borders) */
274
274
  width?: number;
@@ -278,7 +278,7 @@ export interface UpdateBordersCommand {
278
278
  export interface UpdateStyleCommand {
279
279
  key: CommandKey.UpdateStyle;
280
280
  area: IArea|ICellAddress;
281
- style: Style.Properties;
281
+ style: CellStyle;
282
282
  delta?: boolean;
283
283
  }
284
284
 
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- import { Area, type ICellAddress } from 'treb-base-types';
22
+ import { Area, type IArea, type ICellAddress } from 'treb-base-types';
23
23
 
24
24
  /**
25
25
  * FIXME: this is broken. we treat this as a simple javascript object,
@@ -44,8 +44,30 @@ export interface GridSelection {
44
44
 
45
45
  }
46
46
 
47
+ /**
48
+ * temporarily splitting into a serialized version that uses IArea instead
49
+ * of Area. we should do this for the actual selection type, but it breaks
50
+ * too many things atm to do that immediately. TODO/FIXME.
51
+ */
52
+ export interface SerializedGridSelection {
53
+
54
+ /** target or main cell in the selection */
55
+ target: ICellAddress;
56
+
57
+ /** selection area */
58
+ area: IArea;
59
+
60
+ /** there is nothing selected, even though this object exists */
61
+ empty?: boolean;
62
+
63
+ /** for cacheing addtional selections. optimally don't serialize */
64
+ rendered?: boolean;
65
+
66
+ }
67
+
47
68
  /**
48
69
  * create an empty selection
70
+ * @internal
49
71
  */
50
72
  export const CreateSelection = (): GridSelection => {
51
73
  return {
@@ -55,6 +77,9 @@ export const CreateSelection = (): GridSelection => {
55
77
  };
56
78
  };
57
79
 
80
+ /**
81
+ * @internal
82
+ */
58
83
  export const CloneSelection = (rhs: GridSelection): GridSelection => {
59
84
  return JSON.parse(JSON.stringify(rhs));
60
85
  };