@trebco/treb 29.4.1 → 29.5.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.
package/dist/treb.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! API v29.4. Copyright 2018-2024 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
1
+ /*! API v29.5. Copyright 2018-2024 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
2
2
 
3
3
  /**
4
4
  * add our tag to the map
@@ -1042,14 +1042,22 @@ export interface GetRangeOptions {
1042
1042
  formula?: boolean;
1043
1043
 
1044
1044
  /**
1045
- * optional style for returned values (replaces old flags).
1045
+ * by default, GetRange returns cell values. the optional type field
1046
+ * can be used to returns data in different formats.
1046
1047
  *
1047
1048
  * @remarks
1048
1049
  *
1049
1050
  * `formatted` returns formatted values, applying number formatting and
1050
- * returning strings. `formula` returns cell formulas instead of values.
1051
+ * returning strings.
1052
+ *
1053
+ * `A1` returns cell formulas instead of values, in A1 format.
1054
+ *
1055
+ * `R1C1` returns cell formauls in R1C1 format.
1056
+ *
1057
+ * `formula` is an alias for 'A1', for backwards compatibility.
1058
+ *
1051
1059
  */
1052
- type?: 'formatted' | 'formula';
1060
+ type?: 'formatted' | 'A1' | 'R1C1' | 'formula';
1053
1061
  }
1054
1062
 
1055
1063
  /**
@@ -1083,24 +1091,6 @@ export interface FreezePane {
1083
1091
  rows: number;
1084
1092
  columns: number;
1085
1093
  }
1086
- export declare const StandardGradientsList: {
1087
- readonly 'red-green': {
1088
- readonly color_space: "RGB";
1089
- readonly stops: GradientStop[];
1090
- };
1091
- readonly 'red-yellow-green': {
1092
- readonly color_space: "RGB";
1093
- readonly stops: GradientStop[];
1094
- };
1095
- readonly 'green-red': {
1096
- readonly color_space: "RGB";
1097
- readonly stops: GradientStop[];
1098
- };
1099
- readonly 'green-yellow-red': {
1100
- readonly color_space: "RGB";
1101
- readonly stops: GradientStop[];
1102
- };
1103
- };
1104
1094
 
1105
1095
  /**
1106
1096
  * options for serializing data
@@ -1244,6 +1234,7 @@ export type HorizontalAlign = '' | 'left' | 'center' | 'right';
1244
1234
 
1245
1235
  /** vertical align constants for cell style */
1246
1236
  export type VerticalAlign = '' | 'top' | 'bottom' | 'middle';
1237
+ export type ThemeColorType = 'Background' | 'Text' | 'Background2' | 'Text2' | 'Accent' | 'Accent2' | 'Accent3' | 'Accent4' | 'Accent5' | 'Accent6';
1247
1238
 
1248
1239
  /**
1249
1240
  * font size for cell style. we generally prefer relative sizes
@@ -1254,20 +1245,20 @@ export interface FontSize {
1254
1245
  unit: 'pt' | 'px' | 'em' | '%';
1255
1246
  value: number;
1256
1247
  }
1257
-
1258
- /**
1259
- * color for cell style. color is used for foreground, background and
1260
- * borders in the cell style. can be either a theme color (theme index
1261
- * plus tint), or CSS text.
1262
- */
1263
- export interface Color {
1264
- theme?: number;
1248
+ export interface HTMLColor {
1249
+ text: string;
1250
+ }
1251
+ export interface ThemeColor {
1252
+ theme: number | ThemeColorType;
1265
1253
  tint?: number;
1266
- text?: string;
1267
-
1268
- /** @deprecated */
1269
- none?: boolean;
1270
1254
  }
1255
+ export interface NullColor {
1256
+ }
1257
+ export type Color = ThemeColor | HTMLColor | NullColor;
1258
+ export declare const ThemeColorIndex: (color: ThemeColor) => number;
1259
+ export declare const IsHTMLColor: (color?: Color) => color is HTMLColor;
1260
+ export declare const IsThemeColor: (color?: Color) => color is ThemeColor;
1261
+ export declare const IsDefinedColor: (color?: Color) => color is ThemeColor | HTMLColor;
1271
1262
  export type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
1272
1263
 
1273
1264
  /**
@@ -1501,7 +1492,7 @@ export declare type LoadSource = "drag-and-drop" | "local-file" | "network-file"
1501
1492
  * EmbeddedSheetEvent is a discriminated union. Switch on the `type` field
1502
1493
  * of the event.
1503
1494
  */
1504
- export type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | ViewChangeEvent | DataChangeEvent | FocusViewEvent | SelectionEvent | ResizeEvent;
1495
+ export type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | ThemeChangeEvent | ViewChangeEvent | DataChangeEvent | FocusViewEvent | SelectionEvent | ResizeEvent;
1505
1496
 
1506
1497
  /**
1507
1498
  * options when inserting a table into a sheet
@@ -1540,6 +1531,14 @@ export interface ViewChangeEvent {
1540
1531
  type: 'view-change';
1541
1532
  }
1542
1533
 
1534
+ /**
1535
+ * this event is sent when the theme is updated. it's intended for any
1536
+ * subscribers to update corresponding colors or fonts.
1537
+ */
1538
+ export interface ThemeChangeEvent {
1539
+ type: 'theme-change';
1540
+ }
1541
+
1543
1542
  /**
1544
1543
  * This event is sent when a document is loaded, and also on undo. The
1545
1544
  * source field can help determine if it was triggered by an undo operation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "29.4.1",
3
+ "version": "29.5.1",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
 
2
2
  import { Measurement } from 'treb-utils';
3
3
  import { type Color } from './style';
4
- import { type Theme, ThemeColor2 } from './theme';
4
+ import { type Theme, ResolveThemeColor } from './theme';
5
5
  import { ColorFunctions } from './color';
6
6
 
7
7
  export interface GradientStop {
@@ -23,7 +23,7 @@ export class Gradient {
23
23
  throw new Error('invalid stop value');
24
24
  }
25
25
 
26
- const rgb = Measurement.MeasureColor(ThemeColor2(theme, stop.color));
26
+ const rgb = Measurement.MeasureColor(ResolveThemeColor(theme, stop.color));
27
27
 
28
28
  let resolved: number[] = [];
29
29
 
@@ -27,6 +27,44 @@ export type HorizontalAlign = '' | 'left' | 'center' | 'right';
27
27
  /** vertical align constants for cell style */
28
28
  export type VerticalAlign = '' | 'top' | 'bottom' | 'middle';
29
29
 
30
+ export type ThemeColorType =
31
+ 'Background'|
32
+ 'Text'|
33
+ 'Background2'|
34
+ 'Text2'|
35
+ 'Accent'|
36
+ 'Accent2'|
37
+ 'Accent3'|
38
+ 'Accent4'|
39
+ 'Accent5'|
40
+ 'Accent6';
41
+
42
+ const ThemeColorMap: Record<string, number> = {
43
+ 'Background': 0,
44
+ 'Text': 1,
45
+ 'Background2': 2,
46
+ 'Text2': 3,
47
+ 'Accent': 4,
48
+ 'Accent2': 5,
49
+ 'Accent3': 6,
50
+ 'Accent4': 7,
51
+ 'Accent5': 8,
52
+ 'Accent6': 9,
53
+ };
54
+
55
+ /*
56
+ for (const [index, entry] of ThemeColorList.entries()) {
57
+ ThemeColorMap[entry] = index;
58
+ }
59
+ */
60
+
61
+ export const ThemeColorIndex = (color: ThemeColor) => {
62
+ if (typeof color.theme === 'number') {
63
+ return color.theme;
64
+ }
65
+ return ThemeColorMap[color.theme] || 0;
66
+ };
67
+
30
68
  /**
31
69
  * font size for cell style. we generally prefer relative sizes
32
70
  * (percent or em) because they are relative to the default theme
@@ -37,26 +75,67 @@ export interface FontSize {
37
75
  value: number;
38
76
  }
39
77
 
40
- /**
78
+ /* *
41
79
  * color for cell style. color is used for foreground, background and
42
80
  * borders in the cell style. can be either a theme color (theme index
43
81
  * plus tint), or CSS text.
44
82
  *
45
83
  * @privateRemarks
46
84
  * FIXME: this should be a union type. we do a lot of if switching anyway.
47
- */
85
+ * /
48
86
  export interface Color {
49
87
 
50
88
  theme?: number;
51
89
  tint?: number;
52
90
  text?: string;
53
91
 
54
- /** @internal */
92
+ / ** @internal * /
55
93
  offset?: Color;
56
94
 
57
- /** @deprecated */
95
+ / ** @deprecated * /
58
96
  none?: boolean;
59
97
  }
98
+ */
99
+
100
+ export interface HTMLColor {
101
+ text: string;
102
+
103
+ /** @internal */
104
+ offset?: Color;
105
+
106
+ }
107
+
108
+ export interface ThemeColor {
109
+ theme: number|ThemeColorType;
110
+ tint?: number;
111
+
112
+ /** @internal */
113
+ offset?: Color;
114
+
115
+ }
116
+
117
+ export interface NullColor {
118
+
119
+ /** @internal */
120
+ offset?: Color;
121
+
122
+ }
123
+
124
+ export type Color = ThemeColor|HTMLColor|NullColor;
125
+
126
+ export const IsHTMLColor = (color?: Color): color is HTMLColor => {
127
+ return !!color && (typeof (color as HTMLColor).text === 'string');
128
+ };
129
+
130
+ export const IsThemeColor = (color?: Color): color is ThemeColor => {
131
+ return !!color && (typeof (color as ThemeColor).theme !== 'undefined');
132
+ };
133
+
134
+ export const IsDefinedColor = (color?: Color): color is (ThemeColor|HTMLColor) => {
135
+ return !!color && (
136
+ (typeof (color as HTMLColor).text === 'string') ||
137
+ (typeof (color as ThemeColor).theme !== 'undefined'));
138
+ }
60
139
 
61
140
  /** @internal */
62
141
  export interface CompositeBorderEdge {
@@ -258,15 +337,19 @@ export const Style = {
258
337
  return JSON.stringify(style) === empty_json;
259
338
  },
260
339
 
261
- /**
340
+ /* *
262
341
  * this looks like a type guard, we should switch to a union
263
342
  * type and then add real type guards
264
343
  *
265
344
  * @internal
266
- */
345
+ * /
267
346
  ValidColor: (color?: Color): boolean => {
268
347
  return !!(color && (!color.none) && (color.text || color.theme || color.theme === 0));
269
348
  },
349
+ */
350
+
351
+
352
+
270
353
 
271
354
  /** @internal */
272
355
  ParseFontSize: (text = '', default_unit = 'em'): CellStyle => {
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- import type { Color, CellStyle } from './style';
22
+ import { type Color, type CellStyle, IsHTMLColor, IsThemeColor, ThemeColorIndex, type ThemeColor } from './style';
23
23
  import { ColorFunctions } from './color';
24
24
  import { DOMContext } from './dom-utilities';
25
25
 
@@ -161,14 +161,20 @@ export const DefaultTheme: Theme = {
161
161
  offset_dark: '#000',
162
162
  };
163
163
 
164
- /**
164
+ /* *
165
165
  * now just a wrapper, we should remove
166
+ *
167
+ * the only difference between this and the other function (ThemeColor2)
168
+ * is that this has a default for "defaultindex" => 0; calls can just
169
+ * call the second method with the extra argument.
170
+ *
166
171
  * @deprecated
167
172
  * @internal
168
- */
173
+ * /
169
174
  export const ThemeColor = (theme: Theme, color?: Color): string => {
170
175
  return ThemeColor2(theme, color, 0);
171
176
  };
177
+ */
172
178
 
173
179
  /**
174
180
  * we cache values in the theme object so that we can dump it when we
@@ -180,7 +186,10 @@ export const ThemeColor = (theme: Theme, color?: Color): string => {
180
186
  *
181
187
  * because this is ephemeral it won't impact export.
182
188
  */
183
- const TintedColor = (theme: Theme, index: number, tint: number) => {
189
+ const TintedColor = (theme: Theme, source: ThemeColor) => {
190
+
191
+ const index = ThemeColorIndex(source);
192
+ let tint = (source.tint || 0);
184
193
 
185
194
  if (theme.mode === 'dark') {
186
195
  tint = -tint; // invert;
@@ -223,9 +232,9 @@ const TintedColor = (theme: Theme, index: number, tint: number) => {
223
232
  *
224
233
  * @internal
225
234
  */
226
- export const ThemeColor2 = (theme: Theme, color?: Color, default_index?: number): string => {
235
+ export const ResolveThemeColor = (theme: Theme, color?: Color, default_index?: number): string => {
227
236
 
228
- if (color?.offset) {
237
+ if (color && color.offset) {
229
238
 
230
239
  // don't do this
231
240
  if (color.offset.offset) {
@@ -233,7 +242,7 @@ export const ThemeColor2 = (theme: Theme, color?: Color, default_index?: number)
233
242
  return '';
234
243
  }
235
244
 
236
- const resolved = ThemeColor2(theme, color.offset);
245
+ const resolved = ResolveThemeColor(theme, color.offset);
237
246
 
238
247
  // check cache
239
248
  if (theme.offset_cache && theme.offset_cache[resolved]) {
@@ -271,17 +280,17 @@ export const ThemeColor2 = (theme: Theme, color?: Color, default_index?: number)
271
280
 
272
281
  // explicit color, or none
273
282
 
274
- if (color?.text) {
283
+ if (IsHTMLColor(color)) {
275
284
  return color.text === 'none' ? '' : color.text;
276
285
  }
277
286
 
278
287
  // theme color. we need a way to cache these lookups, especially for tinting
279
288
 
280
- if (color?.theme || color?.theme === 0) {
289
+ if (IsThemeColor(color)) {
281
290
  if (color.tint) {
282
- return TintedColor(theme, color.theme, color.tint);
291
+ return TintedColor(theme, color);
283
292
  }
284
- return theme.theme_colors ? theme.theme_colors[color.theme] : '';
293
+ return theme.theme_colors ? theme.theme_colors[ThemeColorIndex(color)] : '';
285
294
  }
286
295
 
287
296
  // default from argument
@@ -427,11 +436,11 @@ const DeriveColorScheme = (theme: Theme, context: CanvasRenderingContext2D): 'li
427
436
 
428
437
  // because these are rendered to a canvas, we know that A is 255
429
438
 
430
- context.fillStyle = foreground_color?.text || '';
439
+ context.fillStyle = IsHTMLColor(foreground_color) ? foreground_color.text : '';
431
440
  context.fillRect(0, 0, 3, 3);
432
441
  const fg = ColorFunctions.RGBToHSL(...(Array.from(context.getImageData(1, 1, 1, 1).data) as [number, number, number]));
433
442
 
434
- context.fillStyle = background_color?.text || '';
443
+ context.fillStyle = IsHTMLColor(background_color) ? background_color.text : '';
435
444
  context.fillRect(0, 0, 3, 3);
436
445
  const bg = ColorFunctions.RGBToHSL(...(Array.from(context.getImageData(1, 1, 1, 1).data) as [number, number, number]));
437
446
 
@@ -558,8 +567,8 @@ export const LoadThemeProperties = (container: HTMLElement): Theme => {
558
567
  const compare = css.color;
559
568
 
560
569
  theme.theme_colors = [
561
- theme.grid_cell.fill?.text || 'rgb(255, 255, 255)',
562
- theme.grid_cell.text?.text || 'rgb(51, 51, 51)',
570
+ IsHTMLColor(theme.grid_cell.fill) ? theme.grid_cell.fill.text : 'rgb(255, 255, 255)',
571
+ IsHTMLColor(theme.grid_cell.text) ? theme.grid_cell.text.text : 'rgb(51, 51, 51)',
563
572
  ];
564
573
 
565
574
  for (let i = 1; i < 32; i++) {
@@ -30,7 +30,7 @@
30
30
  */
31
31
 
32
32
 
33
- import type { Cell, CellStyle } from 'treb-base-types';
33
+ import { IsHTMLColor, type Cell, type CellStyle } from 'treb-base-types';
34
34
 
35
35
  export interface SparklineRenderOptions {
36
36
  context: CanvasRenderingContext2D;
@@ -120,7 +120,7 @@ export class Sparkline {
120
120
  // theme default _should_ always be passed in, so we should (theoretically)
121
121
  // never need our default.
122
122
 
123
- const text_color = style.text?.text || this.default_color;
123
+ const text_color = IsHTMLColor(style.text) ? style.text.text : this.default_color;
124
124
  const colors: string[] = [ text_color, text_color ];
125
125
 
126
126
  if (Array.isArray(cell.calculated)) {
@@ -67,7 +67,14 @@ export interface ConditionalFormatGradientOptions {
67
67
 
68
68
  }
69
69
 
70
-
70
+ /**
71
+ * @internal
72
+ *
73
+ * @privateRemarks
74
+ *
75
+ * this is marked internal temporarily while I figure out why our API
76
+ * generator is not exporting the gradient stop type
77
+ */
71
78
  export const StandardGradientsList = {
72
79
  'red-green': {
73
80
  color_space: 'RGB',
@@ -26,7 +26,7 @@ import { ValueType, Cells, Style,
26
26
  type PropertyKeys,
27
27
  type Color,
28
28
  Area, IsFlatDataArray,
29
- IsNestedRowArray, IsCellAddress, DOMContext
29
+ IsNestedRowArray, IsCellAddress, DOMContext, IsHTMLColor, IsThemeColor
30
30
  } from 'treb-base-types';
31
31
  import { NumberFormatCache } from 'treb-format';
32
32
  import { Measurement, ValidateURI } from 'treb-utils';
@@ -2311,12 +2311,11 @@ export class Sheet {
2311
2311
  number_format_map[style.number_format] = 1;
2312
2312
  }
2313
2313
 
2314
- if (style.text?.text && style.text.text !== 'none') {
2315
- // const color = Measurement.MeasureColorARGB(style.text_color);
2314
+ if (IsHTMLColor(style.text)) {
2316
2315
  color_map[style.text.text] = 1;
2317
2316
  }
2318
2317
 
2319
- if (style.fill?.text) {
2318
+ if (IsHTMLColor(style.fill)) {
2320
2319
  color_map[style.fill.text] = 1;
2321
2320
  }
2322
2321
 
@@ -2324,16 +2323,16 @@ export class Sheet {
2324
2323
  // color_map[style.background] = 1;
2325
2324
  //}
2326
2325
 
2327
- if (style.border_top_fill?.text) {
2326
+ if (IsHTMLColor(style.border_top_fill)) {
2328
2327
  color_map[style.border_top_fill.text] = 1;
2329
2328
  }
2330
- if (style.border_left_fill?.text) {
2329
+ if (IsHTMLColor(style.border_left_fill)) {
2331
2330
  color_map[style.border_left_fill.text] = 1;
2332
2331
  }
2333
- if (style.border_right_fill?.text) {
2332
+ if (IsHTMLColor(style.border_right_fill)) {
2334
2333
  color_map[style.border_right_fill.text] = 1;
2335
2334
  }
2336
- if (style.border_bottom_fill?.text) {
2335
+ if (IsHTMLColor(style.border_bottom_fill)) {
2337
2336
  color_map[style.border_bottom_fill.text] = 1;
2338
2337
  }
2339
2338
 
@@ -2576,13 +2575,15 @@ export class Sheet {
2576
2575
  ...default_color,
2577
2576
  ...color,
2578
2577
  };
2579
- if (result.text) {
2578
+
2579
+ if (IsHTMLColor(result)) {
2580
2580
  result.text = Measurement.MeasureColorARGB(result.text);
2581
2581
  return result;
2582
2582
  }
2583
- else if (typeof result.theme === 'number') {
2583
+ else if (IsThemeColor(result)) {
2584
2584
  return result;
2585
2585
  }
2586
+
2586
2587
  return undefined;
2587
2588
  };
2588
2589
 
@@ -2617,7 +2618,7 @@ export class Sheet {
2617
2618
  fill = translate_border_fill(style.border_bottom_fill, Style.DefaultProperties.border_bottom_fill);
2618
2619
  if (fill !== undefined) { style.border_bottom_fill = fill; }
2619
2620
 
2620
- if (style.fill?.text) {
2621
+ if (IsHTMLColor(style.fill)) {
2621
2622
  style.fill.text = Measurement.MeasureColorARGB(style.fill.text);
2622
2623
  }
2623
2624
 
@@ -2625,10 +2626,8 @@ export class Sheet {
2625
2626
  // style.background = Measurement.MeasureColorARGB(style.background);
2626
2627
  //}
2627
2628
 
2628
- if (style.text) {
2629
- if (style.text.text && style.text.text !== 'none') {
2630
- style.text.text = Measurement.MeasureColorARGB(style.text.text);
2631
- }
2629
+ if (IsHTMLColor(style.text)) {
2630
+ style.text.text = Measurement.MeasureColorARGB(style.text.text);
2632
2631
  }
2633
2632
 
2634
2633
  }
@@ -7,7 +7,7 @@ import html from '../../markup/layout.html';
7
7
  import toolbar_html from '../../markup/toolbar.html';
8
8
 
9
9
  import { NumberFormatCache } from 'treb-format';
10
- import { ColorFunctions, type Color } from 'treb-base-types';
10
+ import { ColorFunctions, type Color, IsThemeColor } from 'treb-base-types';
11
11
  import { Measurement } from 'treb-utils';
12
12
  import type { ToolbarMessage } from '../toolbar-message';
13
13
 
@@ -729,8 +729,7 @@ export class SpreadsheetConstructor<USER_DATA_TYPE = unknown> {
729
729
  const entry = sheet.document_styles.theme_colors[j][i];
730
730
  const style = `background: ${entry.resolved};`;
731
731
  let title = themes[j] || themes[4];
732
- if (entry.color.tint) {
733
- // title += ` (${Math.abs(entry.color.tint) * 100}% ${ entry.color.tint > 0 ? 'lighter' : 'darker'})`;
732
+ if (IsThemeColor(entry.color) && entry.color.tint) {
734
733
  title += ` (${(entry.color.tint > 0 ? '+' : '') + (entry.color.tint) * 100}%)`;
735
734
  }
736
735
  else {
@@ -1372,6 +1371,11 @@ export class SpreadsheetConstructor<USER_DATA_TYPE = unknown> {
1372
1371
  this.UpdateRevertState(sheet);
1373
1372
  break;
1374
1373
 
1374
+ case 'theme-change':
1375
+ this.UpdateDocumentStyles(sheet, format_menu);
1376
+ this.UpdateSelectionStyle(sheet, toolbar, comment_box);
1377
+ break;
1378
+
1375
1379
  case 'selection':
1376
1380
  this.UpdateSelectionStyle(sheet, toolbar, comment_box);
1377
1381
  break;
@@ -73,7 +73,7 @@ import type {
73
73
 
74
74
  import {
75
75
  IsArea, ThemeColorTable, ComplexToString, Rectangle, IsComplex, type CellStyle,
76
- Localization, Style, type Color, ThemeColor2, IsCellAddress, Area, IsFlatData, IsFlatDataArray, Gradient, DOMContext,
76
+ Localization, Style, type Color, ResolveThemeColor, IsCellAddress, Area, IsFlatData, IsFlatDataArray, Gradient, DOMContext,
77
77
  } from 'treb-base-types';
78
78
 
79
79
  import { EventSource, ValidateURI } from 'treb-utils';
@@ -194,14 +194,22 @@ export interface LoadDocumentOptions {
194
194
  formula?: boolean;
195
195
 
196
196
  /**
197
- * optional style for returned values (replaces old flags).
197
+ * by default, GetRange returns cell values. the optional type field
198
+ * can be used to returns data in different formats.
198
199
  *
199
200
  * @remarks
200
201
  *
201
202
  * `formatted` returns formatted values, applying number formatting and
202
- * returning strings. `formula` returns cell formulas instead of values.
203
+ * returning strings.
204
+ *
205
+ * `A1` returns cell formulas instead of values, in A1 format.
206
+ *
207
+ * `R1C1` returns cell formauls in R1C1 format.
208
+ *
209
+ * `formula` is an alias for 'A1', for backwards compatibility.
210
+ *
203
211
  */
204
- type?: 'formatted'|'formula';
212
+ type?: 'formatted'|'A1'|'R1C1'|'formula';
205
213
 
206
214
  }
207
215
 
@@ -2115,6 +2123,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2115
2123
  this.ApplyConditionalFormats(this.grid.active_sheet, false);
2116
2124
  this.grid.Update(true);
2117
2125
 
2126
+ this.Publish({ type: 'theme-change' });
2127
+
2118
2128
  }
2119
2129
 
2120
2130
  /**
@@ -2588,9 +2598,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2588
2598
  * @public
2589
2599
  */
2590
2600
  public SetColumnWidth(column?: number | number[], width?: number): void {
2591
-
2592
- // API v1 OK
2593
-
2601
+
2594
2602
  this.grid.SetColumnWidth(column, width);
2595
2603
  }
2596
2604
 
@@ -4301,16 +4309,24 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4301
4309
 
4302
4310
  // handle the old flags and the precedence rule. type takes precedence.
4303
4311
 
4304
- if (!options.type) {
4312
+ let type = options.type;
4313
+
4314
+ if (!type) {
4305
4315
  if (options.formatted) {
4306
- options.type = 'formatted';
4316
+ type = 'formatted';
4307
4317
  }
4308
4318
  if (options.formula) {
4309
- options.type = 'formula';
4319
+ type = 'A1';
4310
4320
  }
4311
4321
  }
4312
4322
 
4313
- return this.grid.GetRange(this.model.ResolveAddress(range, this.grid.active_sheet), options.type);
4323
+ // alias
4324
+
4325
+ if (type === 'formula') {
4326
+ type = 'A1';
4327
+ }
4328
+
4329
+ return this.grid.GetRange(this.model.ResolveAddress(range, this.grid.active_sheet), type);
4314
4330
 
4315
4331
  }
4316
4332
 
@@ -5331,7 +5347,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5331
5347
  const update_textbox = () => {
5332
5348
 
5333
5349
  if (style.fill) {
5334
- const color = ThemeColor2(this.grid.theme, style.fill);
5350
+ const color = ResolveThemeColor(this.grid.theme, style.fill);
5335
5351
  container.style.background = color;
5336
5352
  }
5337
5353
 
@@ -5597,7 +5613,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5597
5613
  for (let i = 0; i < 10; i++) {
5598
5614
  this.document_styles.theme_colors.push(tints.map(tint => {
5599
5615
  const color: Color = { theme: i, tint };
5600
- const resolved = ThemeColor2(this.grid.theme, color);
5616
+ const resolved = ResolveThemeColor(this.grid.theme, color);
5601
5617
  return { color, resolved };
5602
5618
  }));
5603
5619
  }
@@ -144,6 +144,14 @@ export interface ViewChangeEvent {
144
144
  type: 'view-change';
145
145
  }
146
146
 
147
+ /**
148
+ * this event is sent when the theme is updated. it's intended for any
149
+ * subscribers to update corresponding colors or fonts.
150
+ */
151
+ export interface ThemeChangeEvent {
152
+ type: 'theme-change';
153
+ }
154
+
147
155
  /**
148
156
  * This event is sent when a document is loaded, and also on undo. The
149
157
  * source field can help determine if it was triggered by an undo operation.
@@ -206,6 +214,7 @@ export type EmbeddedSheetEvent
206
214
  = DocumentChangeEvent
207
215
  | DocumentResetEvent
208
216
  | DocumentLoadEvent
217
+ | ThemeChangeEvent
209
218
  | ViewChangeEvent
210
219
  | DataChangeEvent
211
220
  | FocusViewEvent