@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
@@ -21,7 +21,10 @@
21
21
 
22
22
  // --- treb imports -----------------------------------------------------------
23
23
 
24
- import { ValueType, Cells, Style,
24
+ import { ValueType, Cells, Style,
25
+ type CellStyle,
26
+ type PropertyKeys,
27
+ type Color,
25
28
  Area, IsFlatDataArray,
26
29
  IsNestedRowArray, IsCellAddress
27
30
  } from 'treb-base-types';
@@ -30,7 +33,7 @@ import { Measurement, ValidateURI } from 'treb-utils';
30
33
 
31
34
  import type { TextPart ,
32
35
  Cell, ICellAddress, CellSerializationOptions, CellValue, ImportedSheetData, Complex,
33
- DimensionedQuantity, IArea, Table, TableTheme} from 'treb-base-types';
36
+ DimensionedQuantity, IArea, Table, TableTheme, HorizontalAlign, VerticalAlign} from 'treb-base-types';
34
37
 
35
38
  // --- local imports ----------------------------------------------------------
36
39
 
@@ -54,7 +57,7 @@ interface CellStyleRef {
54
57
  row: number;
55
58
  column: number;
56
59
  ref?: number;
57
- style?: Style.Properties;
60
+ style?: CellStyle;
58
61
  rows?: number;
59
62
  }
60
63
 
@@ -93,7 +96,7 @@ export class Sheet {
93
96
  * because it's a reference, it should be constant.
94
97
  * FIXME: move to model...
95
98
  */
96
- public readonly default_style_properties: Style.Properties;
99
+ public readonly default_style_properties: CellStyle;
97
100
 
98
101
  /* moved from grid */
99
102
  public annotations: Annotation[] = [];
@@ -188,7 +191,7 @@ export class Sheet {
188
191
  // we cache composite styles so we don't wind up with objects
189
192
  // for every cell, when all we need is a single reference.
190
193
 
191
- private style_map: Style.Properties[] = [];
194
+ private style_map: CellStyle[] = [];
192
195
 
193
196
  // we use json for comparison. it should be faster than the alternative
194
197
  // (even if that doesn't make sense).
@@ -202,13 +205,13 @@ export class Sheet {
202
205
  // there's a default at the bottom that gets applied to everything.
203
206
  // (in Style). above that, we have the sheet style
204
207
 
205
- private sheet_style: Style.Properties = {};
208
+ private sheet_style: CellStyle = {};
206
209
 
207
210
  // then individual (applied) row and column styles (indexed by row/column)
208
211
 
209
- private row_styles: Record<number, Style.Properties> = {};
212
+ private row_styles: Record<number, CellStyle> = {};
210
213
 
211
- private column_styles: Record<number, Style.Properties> = {};
214
+ private column_styles: Record<number, CellStyle> = {};
212
215
 
213
216
  /*
214
217
  we used to have "alternate row" styles. it's clumsy, but it is a nice
@@ -218,12 +221,12 @@ export class Sheet {
218
221
  just rows atm, not columns.
219
222
  */
220
223
 
221
- private row_pattern: Style.Properties[] = [];
224
+ private row_pattern: CellStyle[] = [];
222
225
 
223
226
  // and finally any cell-specific styles. [FIXME: this is sparse]
224
227
  // [why FIXME? sparse is OK in js]
225
228
 
226
- private cell_style: Style.Properties[][] = [];
229
+ private cell_style: CellStyle[][] = [];
227
230
 
228
231
  // --- accessors ------------------------------------------------------------
229
232
 
@@ -251,7 +254,7 @@ export class Sheet {
251
254
  /**
252
255
  * constructor is now protected. use a factory method (Blank or FromJSON).
253
256
  */
254
- protected constructor(theme_style_properties: Style.Properties) {
257
+ protected constructor(theme_style_properties: CellStyle) {
255
258
 
256
259
  this.default_style_properties = theme_style_properties;
257
260
 
@@ -275,7 +278,7 @@ export class Sheet {
275
278
  /**
276
279
  * factory method creates a new sheet
277
280
  */
278
- public static Blank(style_defaults: Style.Properties, name?: string, rows = 30, columns = 20): Sheet {
281
+ public static Blank(style_defaults: CellStyle, name?: string, rows = 30, columns = 20): Sheet {
279
282
 
280
283
  const sheet = new Sheet(style_defaults);
281
284
 
@@ -293,24 +296,24 @@ export class Sheet {
293
296
  * update old-style alignment constants to the new symbolic values.
294
297
  * updates in place.
295
298
  */
296
- public static UpdateStyle(properties: Style.Properties) {
299
+ public static UpdateStyle(properties: CellStyle) {
297
300
 
298
301
  if (typeof properties.horizontal_align === 'number') {
299
- const members = [
300
- Style.HorizontalAlign.None,
301
- Style.HorizontalAlign.Left,
302
- Style.HorizontalAlign.Center,
303
- Style.HorizontalAlign.Right,
302
+ const members: HorizontalAlign[] = [
303
+ '', // Style.HorizontalAlign.None,
304
+ 'left', // Style.HorizontalAlign.Left,
305
+ 'center', // Style.HorizontalAlign.Center,
306
+ 'right', // Style.HorizontalAlign.Right,
304
307
  ]
305
308
  properties.horizontal_align = members[properties.horizontal_align] || undefined;
306
309
  }
307
310
 
308
311
  if (typeof properties.vertical_align === 'number') {
309
- const members = [
310
- Style.VerticalAlign.None,
311
- Style.VerticalAlign.Top,
312
- Style.VerticalAlign.Bottom,
313
- Style.VerticalAlign.Middle,
312
+ const members: VerticalAlign[] = [
313
+ '', // Style.VerticalAlign.None,
314
+ 'top', // Style.VerticalAlign.Top,
315
+ 'bottom', // Style.VerticalAlign.Bottom,
316
+ 'middle', // Style.VerticalAlign.Middle,
314
317
  ]
315
318
  properties.vertical_align = members[properties.vertical_align] || undefined;
316
319
  }
@@ -326,7 +329,7 @@ export class Sheet {
326
329
  * @param hints UpdateHints supports partial deserialization/replacement
327
330
  * if we know there are only minor changes (as part of undo/redo, probably)
328
331
  */
329
- public static FromJSON(json: string | Partial<SerializedSheet>, style_defaults: Style.Properties, sheet?: Sheet): Sheet {
332
+ public static FromJSON(json: string | Partial<SerializedSheet>, style_defaults: CellStyle, sheet?: Sheet): Sheet {
330
333
 
331
334
  const source: SerializedSheet = (typeof json === 'string') ?
332
335
  JSON.parse(json) : json as SerializedSheet;
@@ -366,14 +369,14 @@ export class Sheet {
366
369
  // we don't need to do it on every parse, which also happens on
367
370
  // undo and some other things.
368
371
 
369
- const patch_style = (style: Style.Properties) => {
372
+ const patch_style = (style: CellStyle) => {
370
373
 
371
374
  // this part is for back compat with older color schemes, it
372
375
  // could theoretically come out if we don't care (or maybe have a tool)
373
376
 
374
377
  // UPDATE for updated font properties
375
378
 
376
- const ref = (style as Style.Properties & {
379
+ const ref = (style as CellStyle & {
377
380
  text_color?: string;
378
381
  background?: string;
379
382
  border_top_color?: string;
@@ -597,7 +600,7 @@ export class Sheet {
597
600
  sheet.column_styles = {};
598
601
  sheet.row_styles = {};
599
602
 
600
- const MapStyles = (source_list: Record<number, number | Style.Properties>, target_list: Record<number, Style.Properties>) => {
603
+ const MapStyles = (source_list: Record<number, number | CellStyle>, target_list: Record<number, CellStyle>) => {
601
604
 
602
605
  for (const key of Object.keys(source_list)) {
603
606
  const index = Number(key);
@@ -788,7 +791,7 @@ export class Sheet {
788
791
  * canvas won't work if there's no DOM but it's OK if this method fails in
789
792
  * that case; the only question is will it break if it's running headless?
790
793
  */
791
- public StyleFontSize(style: Style.Properties, default_properties: Style.Properties = {}): number {
794
+ public StyleFontSize(style: CellStyle, default_properties: CellStyle = {}): number {
792
795
 
793
796
  let font_height = (style.font_size?.value || 0);
794
797
 
@@ -933,7 +936,7 @@ export class Sheet {
933
936
  * property values from B.
934
937
  *
935
938
  * this is the function I could never get to work inline for
936
- * Style.Properties -- not sure why it works better with a generic
939
+ * CellStyle -- not sure why it works better with a generic
937
940
  * function (although the partial here is new, so maybe it's that?)
938
941
  *
939
942
  * seems to be related to
@@ -993,7 +996,7 @@ export class Sheet {
993
996
  * @param delta merge with existing properties (we will win conflicts)
994
997
  * @param inline this is part of another operation, don't do any undo/state updates
995
998
  */
996
- public UpdateCellStyle(address: ICellAddress, properties: Style.Properties, delta = true): void {
999
+ public UpdateCellStyle(address: ICellAddress, properties: CellStyle, delta = true): void {
997
1000
 
998
1001
  // so what this is doing is constructing two merge stacks: one including
999
1002
  // the cell style, and one without. any deltas among the two are the cell
@@ -1066,7 +1069,7 @@ export class Sheet {
1066
1069
  * @param delta
1067
1070
  * @param render LEGACY PARAMETER NOT USED
1068
1071
  */
1069
- public UpdateAreaStyle(area?: Area, style: Style.Properties = {}, delta = true): void {
1072
+ public UpdateAreaStyle(area?: Area, style: CellStyle = {}, delta = true): void {
1070
1073
 
1071
1074
  if (!area) return;
1072
1075
 
@@ -1206,8 +1209,8 @@ export class Sheet {
1206
1209
  * move it here so we can inline the next/previous loops.
1207
1210
  *
1208
1211
  */
1209
- public SurroundingStyle(address: ICellAddress, table?: TableTheme): Style.Properties[] {
1210
- const map: Style.Properties[] = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
1212
+ public SurroundingStyle(address: ICellAddress, table?: TableTheme): CellStyle[] {
1213
+ const map: CellStyle[] = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];
1211
1214
 
1212
1215
  // FIXME: what about merges? (...)
1213
1216
 
@@ -1260,7 +1263,7 @@ export class Sheet {
1260
1263
  * and we don't preserve the style.
1261
1264
  *
1262
1265
  */
1263
- public CellStyleData(address: ICellAddress, default_table_theme?: TableTheme): Style.Properties | undefined {
1266
+ public CellStyleData(address: ICellAddress, default_table_theme?: TableTheme): CellStyle | undefined {
1264
1267
 
1265
1268
  // don't create if it doesn't exist
1266
1269
  const cell = this.cells.GetCell(address);
@@ -1328,7 +1331,7 @@ export class Sheet {
1328
1331
  * accessor to get cell style without row pattern -- for cut/copy
1329
1332
  * @param address
1330
1333
  */
1331
- public GetCopyStyle(address: ICellAddress): Style.Properties {
1334
+ public GetCopyStyle(address: ICellAddress): CellStyle {
1332
1335
  return this.CompositeStyleForCell(address, true, false);
1333
1336
  }
1334
1337
 
@@ -1526,7 +1529,7 @@ export class Sheet {
1526
1529
  * UPDATE: since the only caller calls with inline = true, removing
1527
1530
  * parameter, test, and extra behavior.
1528
1531
  */
1529
- public AutoSizeRow(row: number, default_properties: Style.Properties = {}, allow_shrink = true): void {
1532
+ public AutoSizeRow(row: number, default_properties: CellStyle = {}, allow_shrink = true): void {
1530
1533
 
1531
1534
  let height = this.default_row_height;
1532
1535
  const padding = 9; // 9?
@@ -1607,7 +1610,7 @@ export class Sheet {
1607
1610
  */
1608
1611
 
1609
1612
  /** returns the style properties for a given style index */
1610
- public GetStyle(index: number): Style.Properties {
1613
+ public GetStyle(index: number): CellStyle {
1611
1614
  return this.style_map[index];
1612
1615
  }
1613
1616
 
@@ -1757,7 +1760,7 @@ export class Sheet {
1757
1760
  // row styles
1758
1761
 
1759
1762
  const row_keys = Object.keys(this.row_styles);
1760
- const new_row_style: Record<number, Style.Properties> = {};
1763
+ const new_row_style: Record<number, CellStyle> = {};
1761
1764
 
1762
1765
  row_keys.forEach((key) => {
1763
1766
  const index = Number(key);
@@ -1786,7 +1789,7 @@ export class Sheet {
1786
1789
 
1787
1790
  if (column && column.length >= before_row) {
1788
1791
  // eslint-disable-next-line prefer-spread
1789
- column.splice.apply(column, args as [number, number, Style.Properties]);
1792
+ column.splice.apply(column, args as [number, number, CellStyle]);
1790
1793
  }
1791
1794
  });
1792
1795
 
@@ -1889,7 +1892,7 @@ export class Sheet {
1889
1892
  // column styles
1890
1893
 
1891
1894
  const column_keys = Object.keys(this.column_styles);
1892
- const new_column_style: Record<number, Style.Properties> = {};
1895
+ const new_column_style: Record<number, CellStyle> = {};
1893
1896
 
1894
1897
  column_keys.forEach((key) => {
1895
1898
  const index = Number(key);
@@ -1913,7 +1916,7 @@ export class Sheet {
1913
1916
  }
1914
1917
 
1915
1918
  // eslint-disable-next-line prefer-spread
1916
- this.cell_style.splice.apply(this.cell_style, args as [number, number, Style.Properties[]]);
1919
+ this.cell_style.splice.apply(this.cell_style, args as [number, number, CellStyle[]]);
1917
1920
 
1918
1921
  // row heights
1919
1922
 
@@ -2067,7 +2070,7 @@ export class Sheet {
2067
2070
  * to style (for API access). there was an old GetCellStyle function
2068
2071
  * for rendering, but that's been removed (control+F for info).
2069
2072
  */
2070
- public GetCellStyle(area: ICellAddress|IArea, apply_theme = false): Style.Properties|Style.Properties[][] {
2073
+ public GetCellStyle(area: ICellAddress|IArea, apply_theme = false): CellStyle|CellStyle[][] {
2071
2074
 
2072
2075
  if (IsCellAddress(area)) {
2073
2076
  return this.CompositeStyleForCell(area, true, false, apply_theme);
@@ -2077,10 +2080,10 @@ export class Sheet {
2077
2080
  return this.CompositeStyleForCell(area.start, true, false, apply_theme);
2078
2081
  }
2079
2082
 
2080
- const result: Style.Properties[][] = [];
2083
+ const result: CellStyle[][] = [];
2081
2084
 
2082
2085
  for (let r = area.start.row; r <= area.end.row; r++) {
2083
- const row: Style.Properties[] = [];
2086
+ const row: CellStyle[] = [];
2084
2087
  for (let c = area.start.column; c <= area.end.column; c++) {
2085
2088
  // const cell = this.CellData({row: r, column: c});
2086
2089
  // row.push(cell.style || {});
@@ -2153,7 +2156,7 @@ export class Sheet {
2153
2156
  number_format_map: Record<string, number>,
2154
2157
  ): void {
2155
2158
 
2156
- const parse = (style: Style.Properties) => {
2159
+ const parse = (style: CellStyle) => {
2157
2160
 
2158
2161
  if (style.number_format) {
2159
2162
  number_format_map[style.number_format] = 1;
@@ -2346,7 +2349,7 @@ export class Sheet {
2346
2349
  /**
2347
2350
  * this assumes that "empty" style is at index 0
2348
2351
  */
2349
- const StyleToRef = (style: Style.Properties) => {
2352
+ const StyleToRef = (style: CellStyle) => {
2350
2353
 
2351
2354
  const style_as_json = JSON.stringify(style);
2352
2355
  if (style_as_json === empty_json) {
@@ -2377,11 +2380,11 @@ export class Sheet {
2377
2380
  // using records (objects) converts keys to strings, which is sloppy.
2378
2381
 
2379
2382
 
2380
- // const column_style: Array<number|Style.Properties> = [];
2381
- // const row_style: Array<number|Style.Properties> = [];
2383
+ // const column_style: Array<number|CellStyle> = [];
2384
+ // const row_style: Array<number|CellStyle> = [];
2382
2385
 
2383
- const column_style: Record<number, Style.Properties | number> = {};
2384
- const row_style: Record<number, Style.Properties | number> = {};
2386
+ const column_style: Record<number, CellStyle | number> = {};
2387
+ const row_style: Record<number, CellStyle | number> = {};
2385
2388
 
2386
2389
  for (const key of Object.keys(this.column_styles)) {
2387
2390
  const index = Number(key);
@@ -2417,8 +2420,8 @@ export class Sheet {
2417
2420
  return undefined;
2418
2421
  }
2419
2422
 
2420
- const translate_border_fill = (color: Style.Color = {}, default_color: Style.Color = {}) => {
2421
- const result: Style.Color = {
2423
+ const translate_border_fill = (color: Color = {}, default_color: Color = {}) => {
2424
+ const result: Color = {
2422
2425
  ...default_color,
2423
2426
  ...color,
2424
2427
  };
@@ -2434,7 +2437,7 @@ export class Sheet {
2434
2437
 
2435
2438
  // translate, if necessary
2436
2439
  if (options.export_colors) {
2437
- const style_list: Style.Properties[] = [];
2440
+ const style_list: CellStyle[] = [];
2438
2441
  for (const group of [
2439
2442
  //row_style, column_style, // these are moved -> csr (which should be renamed)
2440
2443
  cell_style_refs, [sheet_style], row_pattern]) {
@@ -2446,7 +2449,7 @@ export class Sheet {
2446
2449
  }
2447
2450
  }
2448
2451
 
2449
- for (const style of style_list as Style.Properties[]) {
2452
+ for (const style of style_list as CellStyle[]) {
2450
2453
 
2451
2454
  // don't set "undefined" overrides. also, was this broken
2452
2455
  // wrt all the defaults from top? probably
@@ -2854,14 +2857,14 @@ export class Sheet {
2854
2857
  * expect that the unbold style will control. instead of explicitly setting
2855
2858
  * the cell style, we go up the chain and remove any matching properties.
2856
2859
  */
2857
- private UpdateSheetStyle(properties: Style.Properties, delta = true) {
2860
+ private UpdateSheetStyle(properties: CellStyle, delta = true) {
2858
2861
 
2859
2862
  this.sheet_style = Style.Merge(this.sheet_style, properties, delta);
2860
2863
 
2861
2864
  // reverse-override...
2862
2865
 
2863
2866
  // const keys = Object.keys(properties);
2864
- const keys = Object.keys(properties) as Style.PropertyKeys[];
2867
+ const keys = Object.keys(properties) as PropertyKeys[];
2865
2868
  // const keys = Object.keys(this.sheet_style) as Style.PropertyKeys[];
2866
2869
 
2867
2870
  for (const style_column of this.cell_style) {
@@ -2895,7 +2898,7 @@ export class Sheet {
2895
2898
  * there's an overriding column property (columns have priority), we will
2896
2899
  * need to update the cell property to match the desired output.
2897
2900
  */
2898
- private UpdateRowStyle(row: number, properties: Style.Properties, delta = true) {
2901
+ private UpdateRowStyle(row: number, properties: CellStyle, delta = true) {
2899
2902
 
2900
2903
  this.row_styles[row] = Style.Merge(this.row_styles[row] || {}, properties, delta);
2901
2904
 
@@ -2903,7 +2906,7 @@ export class Sheet {
2903
2906
  // (we can do this in-place)
2904
2907
 
2905
2908
  // const keys = Object.keys(properties);
2906
- const keys = Object.keys(properties) as Style.PropertyKeys[];
2909
+ const keys = Object.keys(properties) as PropertyKeys[];
2907
2910
  // const keys = Object.keys(this.row_styles[row]) as Style.PropertyKeys[];
2908
2911
 
2909
2912
  for (const column of this.cell_style) {
@@ -2952,7 +2955,7 @@ export class Sheet {
2952
2955
  for (let i = 0; i < this.cells.columns; i++) {
2953
2956
  if (this.column_styles[i]) {
2954
2957
  const column_style = this.column_styles[i];
2955
- const overrides: Style.Properties = this.cell_style[i] ? this.cell_style[i][row] || {} : {};
2958
+ const overrides: CellStyle = this.cell_style[i] ? this.cell_style[i][row] || {} : {};
2956
2959
 
2957
2960
  for (const key of keys) {
2958
2961
  if (typeof column_style[key] !== 'undefined') {
@@ -2998,7 +3001,7 @@ export class Sheet {
2998
3001
  /**
2999
3002
  * updates column properties. reverse-overrides cells (@see UpdateSheetStyle).
3000
3003
  */
3001
- private UpdateColumnStyle(column: number, properties: Style.Properties, delta = true) {
3004
+ private UpdateColumnStyle(column: number, properties: CellStyle, delta = true) {
3002
3005
 
3003
3006
  this.column_styles[column] = Style.Merge(this.column_styles[column] || {}, properties, delta);
3004
3007
 
@@ -3028,7 +3031,7 @@ export class Sheet {
3028
3031
 
3029
3032
  // reverse-override... I think we only need to override _cell_ values.
3030
3033
 
3031
- const keys = Object.keys(properties) as Style.PropertyKeys[];
3034
+ const keys = Object.keys(properties) as PropertyKeys[];
3032
3035
  // const keys = Object.keys(this.column_styles[column]) as Style.PropertyKeys[];
3033
3036
 
3034
3037
  if (this.cell_style[column]) {
@@ -3057,7 +3060,7 @@ export class Sheet {
3057
3060
  private CompositeStyleForCell(address: ICellAddress, apply_cell_style = true, apply_row_pattern = true, apply_default = true) {
3058
3061
 
3059
3062
  const { row, column } = address;
3060
- const stack: Style.Properties[] = [];
3063
+ const stack: CellStyle[] = [];
3061
3064
 
3062
3065
  if (apply_default) {
3063
3066
  stack.push(this.default_style_properties);
@@ -3088,7 +3091,7 @@ export class Sheet {
3088
3091
  /**
3089
3092
  * can we use the rendered JSON as a key, instead?
3090
3093
  */
3091
- private GetStyleIndex(style: Style.Properties) {
3094
+ private GetStyleIndex(style: CellStyle) {
3092
3095
 
3093
3096
  const json = JSON.stringify(style);
3094
3097
 
@@ -19,9 +19,9 @@
19
19
  *
20
20
  */
21
21
 
22
- import type { IArea, SerializedCellData, Style } from 'treb-base-types';
22
+ import type { IArea, SerializedCellData, Style, CellStyle } from 'treb-base-types';
23
23
  import type { Annotation, AnnotationData } from './annotation';
24
- import type { GridSelection } from './grid_selection';
24
+ import type { GridSelection, SerializedGridSelection } from './grid_selection';
25
25
 
26
26
  export interface UpdateHints {
27
27
  data?: boolean;
@@ -42,13 +42,20 @@ export interface ScrollOffset {
42
42
  y: number;
43
43
  }
44
44
 
45
+ export interface CellStyleRecord {
46
+ row: number;
47
+ column: number;
48
+ ref: number;
49
+ rows?: number;
50
+ }
51
+
45
52
  export interface SerializedSheet {
46
53
 
47
54
  /** cell data */
48
55
  data: SerializedCellData;
49
56
 
50
57
  /** top-level sheet style, if any */
51
- sheet_style: Style.Properties;
58
+ sheet_style: CellStyle;
52
59
 
53
60
  /** row count */
54
61
  rows: number;
@@ -59,32 +66,32 @@ export interface SerializedSheet {
59
66
  /**
60
67
  * cell styles is for empty cells that have styling
61
68
  */
62
- cell_styles: Array<{row: number; column: number; ref: number, rows?: number}>;
69
+ cell_styles: CellStyleRecord[]; // Array<{row: number; column: number; ref: number, rows?: number}>;
63
70
 
64
71
  /**
65
72
  * @deprecated use `styles` instead
66
73
  */
67
- cell_style_refs?: Style.Properties[]; // old
74
+ cell_style_refs?: CellStyle[]; // old
68
75
 
69
76
  /**
70
77
  * new implementation
71
78
  */
72
- styles?: Style.Properties[];
79
+ styles?: CellStyle[];
73
80
 
74
81
  /**
75
82
  * per-row styles
76
83
  */
77
- row_style: Record<number, Style.Properties|number>;
84
+ row_style: Record<number, CellStyle|number>;
78
85
 
79
86
  /**
80
87
  * per-column styles
81
88
  */
82
- column_style: Record<number, Style.Properties|number>;
89
+ column_style: Record<number, CellStyle|number>;
83
90
 
84
91
  /**
85
92
  * @deprecated no one uses this anymore and it's weird
86
93
  */
87
- row_pattern?: Style.Properties[];
94
+ row_pattern?: CellStyle[];
88
95
 
89
96
  /** default for new rows */
90
97
  default_row_height?: number;
@@ -112,7 +119,7 @@ export interface SerializedSheet {
112
119
  name?: string;
113
120
 
114
121
  /** current active selection */
115
- selection: GridSelection;
122
+ selection: SerializedGridSelection;
116
123
 
117
124
  /** */
118
125
  annotations?: Partial<AnnotationData>[]; // Partial<Annotation>[];