@trebco/treb 26.0.5 → 27.0.0
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-spreadsheet.mjs +13 -13
- package/dist/treb.d.ts +150 -337
- package/esbuild-utils.mjs +1 -1
- package/package.json +3 -3
- package/treb-base-types/src/cell.ts +3 -3
- package/treb-base-types/src/cells.ts +33 -15
- package/treb-base-types/src/color.ts +21 -21
- package/treb-base-types/src/import.ts +2 -2
- package/treb-base-types/src/style.ts +150 -288
- package/treb-base-types/src/table.ts +3 -2
- package/treb-base-types/src/theme.ts +18 -18
- package/treb-base-types/src/value-type.ts +20 -1
- package/treb-calculator/src/calculator.ts +4 -4
- package/treb-calculator/src/functions/checkbox.ts +8 -8
- package/treb-calculator/src/functions/sparkline.ts +25 -25
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +10 -10
- package/treb-embed/src/embedded-spreadsheet.ts +15 -15
- package/treb-embed/src/selection-state.ts +2 -2
- package/treb-embed/src/toolbar-message.ts +3 -3
- package/treb-embed/src/types.ts +4 -4
- package/treb-embed/style/autocomplete.scss +1 -1
- package/treb-embed/style/dialog.scss +1 -1
- package/treb-embed/style/dropdown-select.scss +1 -1
- package/treb-embed/style/formula-bar.scss +1 -1
- package/treb-embed/style/grid.scss +1 -1
- package/treb-embed/style/layout.scss +13 -2
- package/treb-embed/style/mouse-mask.scss +1 -1
- package/treb-embed/style/note.scss +1 -1
- package/treb-embed/style/overlay-editor.scss +1 -1
- package/treb-embed/style/spinner.scss +1 -1
- package/treb-embed/style/tab-bar.scss +1 -1
- package/treb-embed/style/table.scss +1 -1
- package/treb-embed/style/theme-defaults.scss +1 -1
- package/treb-embed/style/toolbar.scss +1 -1
- package/treb-embed/style/tooltip.scss +1 -1
- package/treb-embed/style/treb-icons.scss +1 -1
- package/treb-embed/style/treb-spreadsheet-element.scss +1 -0
- package/treb-export/src/export2.ts +6 -6
- package/treb-export/src/workbook-style2.ts +19 -19
- package/treb-grid/src/editors/overlay_editor.ts +4 -4
- package/treb-grid/src/render/tile_renderer.ts +15 -14
- package/treb-grid/src/types/annotation.ts +9 -6
- package/treb-grid/src/types/clipboard_data.ts +2 -2
- package/treb-grid/src/types/data_model.ts +2 -2
- package/treb-grid/src/types/grid.ts +9 -7
- package/treb-grid/src/types/grid_base.ts +9 -9
- package/treb-grid/src/types/grid_command.ts +3 -3
- package/treb-grid/src/types/grid_selection.ts +26 -1
- package/treb-grid/src/types/sheet.ts +66 -63
- package/treb-grid/src/types/sheet_types.ts +17 -10
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type {
|
|
23
|
-
import {
|
|
22
|
+
import type { Color, CellStyle } from './style';
|
|
23
|
+
import { ColorFunctions } from './color';
|
|
24
24
|
|
|
25
25
|
/*
|
|
26
26
|
* so this is a little strange. we use CSS to populate a theme object,
|
|
@@ -57,34 +57,34 @@ import { Color } from './color';
|
|
|
57
57
|
export interface TableTheme {
|
|
58
58
|
|
|
59
59
|
/** the first row in a table, showing column titles. */
|
|
60
|
-
header?:
|
|
60
|
+
header?: CellStyle;
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* odd rows in the table. we count the title row as zero, so
|
|
64
64
|
* the first row in the table containing data is 1, hence odd.
|
|
65
65
|
*/
|
|
66
|
-
odd?:
|
|
66
|
+
odd?: CellStyle;
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* even rows in the table.
|
|
70
70
|
*/
|
|
71
|
-
even?:
|
|
71
|
+
even?: CellStyle;
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* styling for the totals row, if included. this will be the last
|
|
75
75
|
* row in the table.
|
|
76
76
|
*/
|
|
77
|
-
total?:
|
|
77
|
+
total?: CellStyle;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/** theme options - colors and fonts */
|
|
81
81
|
export interface Theme {
|
|
82
82
|
|
|
83
83
|
/** grid headers (composite) */
|
|
84
|
-
headers?:
|
|
84
|
+
headers?: CellStyle;
|
|
85
85
|
|
|
86
86
|
/** grid cell defaults (composite: size, font face, color, background) */
|
|
87
|
-
grid_cell?:
|
|
87
|
+
grid_cell?: CellStyle;
|
|
88
88
|
|
|
89
89
|
/** gridlines color */
|
|
90
90
|
grid_color: string;
|
|
@@ -165,7 +165,7 @@ export const DefaultTheme: Theme = {
|
|
|
165
165
|
* @deprecated
|
|
166
166
|
* @internal
|
|
167
167
|
*/
|
|
168
|
-
export const ThemeColor = (theme: Theme, color?:
|
|
168
|
+
export const ThemeColor = (theme: Theme, color?: Color): string => {
|
|
169
169
|
return ThemeColor2(theme, color, 0);
|
|
170
170
|
};
|
|
171
171
|
|
|
@@ -199,10 +199,10 @@ const TintedColor = (theme: Theme, index: number, tint: number) => {
|
|
|
199
199
|
const rgb = (theme.theme_colors_rgb ? theme.theme_colors_rgb[index] : [0, 0, 0]) || [0, 0, 0];
|
|
200
200
|
let tinted: {r: number, g: number, b: number};
|
|
201
201
|
if (tint > 0) {
|
|
202
|
-
tinted =
|
|
202
|
+
tinted = ColorFunctions.Lighten(rgb[0], rgb[1], rgb[2], tint * 100, true);
|
|
203
203
|
}
|
|
204
204
|
else {
|
|
205
|
-
tinted =
|
|
205
|
+
tinted = ColorFunctions.Darken(rgb[0], rgb[1], rgb[2], -tint * 100, true);
|
|
206
206
|
}
|
|
207
207
|
color = `rgb(${tinted.r},${tinted.g},${tinted.b})`;
|
|
208
208
|
theme.tint_cache[index][tint] = color;
|
|
@@ -222,7 +222,7 @@ const TintedColor = (theme: Theme, index: number, tint: number) => {
|
|
|
222
222
|
*
|
|
223
223
|
* @internal
|
|
224
224
|
*/
|
|
225
|
-
export const ThemeColor2 = (theme: Theme, color?:
|
|
225
|
+
export const ThemeColor2 = (theme: Theme, color?: Color, default_index?: number): string => {
|
|
226
226
|
|
|
227
227
|
if (color?.offset) {
|
|
228
228
|
|
|
@@ -245,7 +245,7 @@ export const ThemeColor2 = (theme: Theme, color?: Style.Color, default_index?: n
|
|
|
245
245
|
// ok figure it out?
|
|
246
246
|
const match = resolved.match(/rgb\((\d+), (\d+), (\d+)\)/);
|
|
247
247
|
if (match) {
|
|
248
|
-
const hsl =
|
|
248
|
+
const hsl = ColorFunctions.RGBToHSL(Number(match[1]), Number(match[2]), Number(match[3]));
|
|
249
249
|
// console.info('resolved', resolved, {hsl});
|
|
250
250
|
if (hsl.l > .65) {
|
|
251
251
|
offset = theme.offset_dark;
|
|
@@ -373,11 +373,11 @@ const TableStyleFromCSS = (base: CSSStyleDeclaration, style: CSSStyleDeclaration
|
|
|
373
373
|
*/
|
|
374
374
|
|
|
375
375
|
// testing
|
|
376
|
-
const StyleFromCSS = (css: CSSStyleDeclaration):
|
|
376
|
+
const StyleFromCSS = (css: CSSStyleDeclaration): CellStyle => {
|
|
377
377
|
|
|
378
378
|
const { value, unit } = ParseFontSize(css.fontSize||'');
|
|
379
379
|
|
|
380
|
-
const style:
|
|
380
|
+
const style: CellStyle = {
|
|
381
381
|
fill: { text: css.backgroundColor }, // || 'none',
|
|
382
382
|
text: { text: css.color },
|
|
383
383
|
font_size: {
|
|
@@ -428,11 +428,11 @@ const DeriveColorScheme = (theme: Theme, context: CanvasRenderingContext2D): 'li
|
|
|
428
428
|
|
|
429
429
|
context.fillStyle = foreground_color?.text || '';
|
|
430
430
|
context.fillRect(0, 0, 3, 3);
|
|
431
|
-
const fg =
|
|
431
|
+
const fg = ColorFunctions.RGBToHSL(...(Array.from(context.getImageData(1, 1, 1, 1).data) as [number, number, number]));
|
|
432
432
|
|
|
433
433
|
context.fillStyle = background_color?.text || '';
|
|
434
434
|
context.fillRect(0, 0, 3, 3);
|
|
435
|
-
const bg =
|
|
435
|
+
const bg = ColorFunctions.RGBToHSL(...(Array.from(context.getImageData(1, 1, 1, 1).data) as [number, number, number]));
|
|
436
436
|
|
|
437
437
|
// console.info({fg, bg});
|
|
438
438
|
|
|
@@ -448,7 +448,7 @@ const DeriveColorScheme = (theme: Theme, context: CanvasRenderingContext2D): 'li
|
|
|
448
448
|
*/
|
|
449
449
|
export const ThemeColorTable = (theme_color: number, tint = .7): TableTheme => {
|
|
450
450
|
|
|
451
|
-
const borders:
|
|
451
|
+
const borders: CellStyle = {
|
|
452
452
|
border_top: 1,
|
|
453
453
|
border_top_fill: { theme: theme_color },
|
|
454
454
|
border_bottom: 1,
|
|
@@ -91,6 +91,9 @@ export const IsDimensionedQuantity = (value: unknown): value is DimensionedQuant
|
|
|
91
91
|
*
|
|
92
92
|
* we'll switch to string types for import/export, although we still support
|
|
93
93
|
* importing the old numeric enum types for backwards compatibility.
|
|
94
|
+
*
|
|
95
|
+
* @internal
|
|
96
|
+
*
|
|
94
97
|
*/
|
|
95
98
|
export const ValueTypeList = [
|
|
96
99
|
'undefined',
|
|
@@ -107,8 +110,24 @@ export const ValueTypeList = [
|
|
|
107
110
|
|
|
108
111
|
/**
|
|
109
112
|
* string types for import/export
|
|
113
|
+
*
|
|
114
|
+
* @internalRemarks
|
|
115
|
+
*
|
|
116
|
+
* temporarily switching to literal, see what happens to API
|
|
117
|
+
*
|
|
110
118
|
*/
|
|
111
|
-
export type SerializedValueType = typeof ValueTypeList[number];
|
|
119
|
+
export type SerializedValueType = // typeof ValueTypeList[number];
|
|
120
|
+
'undefined' |
|
|
121
|
+
'formula' |
|
|
122
|
+
'string' |
|
|
123
|
+
'number' |
|
|
124
|
+
'boolean' |
|
|
125
|
+
'object' |
|
|
126
|
+
'error' |
|
|
127
|
+
'complex' |
|
|
128
|
+
'array' |
|
|
129
|
+
'dimensioned_quantity' ;
|
|
130
|
+
|
|
112
131
|
|
|
113
132
|
/**
|
|
114
133
|
* this enum goes back a long way and is pretty ingrained, so I don't
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import type { Cell, ICellAddress, ICellAddress2, UnionValue,
|
|
23
|
-
ArrayUnion, IArea,
|
|
23
|
+
ArrayUnion, IArea, CellDataWithAddress} from 'treb-base-types';
|
|
24
24
|
import { Localization, Area, ValueType, IsCellAddress} from 'treb-base-types';
|
|
25
25
|
|
|
26
26
|
import type { ExpressionUnit, DependencyList, UnitRange, UnitAddress, UnitIdentifier } from 'treb-parser';
|
|
@@ -855,10 +855,10 @@ export class Calculator extends Graph {
|
|
|
855
855
|
* so the leader does the calculation and then we broadcast calculated
|
|
856
856
|
* values to followers.
|
|
857
857
|
*/
|
|
858
|
-
public ExportCalculatedValues(): Record<number,
|
|
858
|
+
public ExportCalculatedValues(): Record<number, CellDataWithAddress[]> {
|
|
859
859
|
const data: any = {};
|
|
860
860
|
for (const sheet of this.model.sheets.list) {
|
|
861
|
-
const calculated = sheet.cells.toJSON({calculated_value: true}).data as
|
|
861
|
+
const calculated = sheet.cells.toJSON({calculated_value: true}).data as CellDataWithAddress[];
|
|
862
862
|
data[sheet.id] = calculated.filter(test => test.calculated !== undefined);
|
|
863
863
|
}
|
|
864
864
|
return data;
|
|
@@ -874,7 +874,7 @@ export class Calculator extends Graph {
|
|
|
874
874
|
* note that we're checking for list mismatch in one direction but not the
|
|
875
875
|
* other direction. should probably check both.
|
|
876
876
|
*/
|
|
877
|
-
public ApplyCalculatedValues(data: Record<number,
|
|
877
|
+
public ApplyCalculatedValues(data: Record<number, CellDataWithAddress[]>): void {
|
|
878
878
|
for (const sheet of this.model.sheets.list) {
|
|
879
879
|
const cells = data[sheet.id];
|
|
880
880
|
if (!cells) {
|
|
@@ -40,22 +40,22 @@ export const ClickCheckbox = (options: ClickFunctionOptions): ClickFunctionResul
|
|
|
40
40
|
|
|
41
41
|
if (cell.style) {
|
|
42
42
|
switch (cell.style.vertical_align) {
|
|
43
|
-
case Style.VerticalAlign.Top:
|
|
43
|
+
case 'top': // Style.VerticalAlign.Top:
|
|
44
44
|
box.y = offset;
|
|
45
45
|
break;
|
|
46
46
|
|
|
47
|
-
case Style.VerticalAlign.Middle:
|
|
47
|
+
case 'middle': // Style.VerticalAlign.Middle:
|
|
48
48
|
box.y = Math.round((height - scaled) / 2);
|
|
49
49
|
break;
|
|
50
50
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
switch (cell.style.horizontal_align) {
|
|
54
|
-
case Style.HorizontalAlign.Right:
|
|
54
|
+
case 'right': // Style.HorizontalAlign.Right:
|
|
55
55
|
box.x = Math.round(width - offset - scaled);
|
|
56
56
|
break;
|
|
57
57
|
|
|
58
|
-
case Style.HorizontalAlign.Center:
|
|
58
|
+
case 'center': // Style.HorizontalAlign.Center:
|
|
59
59
|
box.x = Math.round((width - scaled) / 2);
|
|
60
60
|
break;
|
|
61
61
|
|
|
@@ -87,11 +87,11 @@ export const RenderCheckbox = (options: RenderFunctionOptions): RenderFunctionRe
|
|
|
87
87
|
|
|
88
88
|
if (cell.style) {
|
|
89
89
|
switch (cell.style.vertical_align) {
|
|
90
|
-
case Style.VerticalAlign.Top:
|
|
90
|
+
case 'top': // Style.VerticalAlign.Top:
|
|
91
91
|
y = offset;
|
|
92
92
|
break;
|
|
93
93
|
|
|
94
|
-
case Style.VerticalAlign.Middle:
|
|
94
|
+
case 'middle': // Style.VerticalAlign.Middle:
|
|
95
95
|
y = // Math.round
|
|
96
96
|
((height - scaled) / 2);
|
|
97
97
|
break;
|
|
@@ -99,12 +99,12 @@ export const RenderCheckbox = (options: RenderFunctionOptions): RenderFunctionRe
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
switch (cell.style.horizontal_align) {
|
|
102
|
-
case Style.HorizontalAlign.Right:
|
|
102
|
+
case 'right': // Style.HorizontalAlign.Right:
|
|
103
103
|
x = // Math.round
|
|
104
104
|
(width - offset - scaled);
|
|
105
105
|
break;
|
|
106
106
|
|
|
107
|
-
case Style.HorizontalAlign.Center:
|
|
107
|
+
case 'center': // Style.HorizontalAlign.Center:
|
|
108
108
|
x = // Math.round
|
|
109
109
|
((width - scaled) / 2);
|
|
110
110
|
break;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
22
|
/**
|
|
23
23
|
* moved from sparkline module -- not sure why this needed a separate
|
|
24
24
|
* module. although on reflection it might be better placed in the charts
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
import type { Cell, Style } from 'treb-base-types';
|
|
33
|
+
import type { Cell, Style, CellStyle } from 'treb-base-types';
|
|
34
34
|
|
|
35
35
|
export interface SparklineRenderOptions {
|
|
36
36
|
context: CanvasRenderingContext2D;
|
|
@@ -104,7 +104,7 @@ export class Sparkline {
|
|
|
104
104
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
protected static SparklineCommon(cell: Cell, style:
|
|
107
|
+
protected static SparklineCommon(cell: Cell, style: CellStyle): {
|
|
108
108
|
values: Array<number|undefined>,
|
|
109
109
|
colors: string[],
|
|
110
110
|
} {
|
|
@@ -140,7 +140,7 @@ export class Sparkline {
|
|
|
140
140
|
height: number,
|
|
141
141
|
context: CanvasRenderingContext2D,
|
|
142
142
|
cell: Cell,
|
|
143
|
-
style:
|
|
143
|
+
style: CellStyle,
|
|
144
144
|
): void {
|
|
145
145
|
|
|
146
146
|
const {values, colors} = this.SparklineCommon(cell, style);
|
|
@@ -220,7 +220,7 @@ export class Sparkline {
|
|
|
220
220
|
height: number,
|
|
221
221
|
context: CanvasRenderingContext2D,
|
|
222
222
|
cell: Cell,
|
|
223
|
-
style:
|
|
223
|
+
style: CellStyle,
|
|
224
224
|
): void {
|
|
225
225
|
|
|
226
226
|
const {values, colors} = this.SparklineCommon(cell, style);
|
|
@@ -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 {
|
|
10
|
+
import { ColorFunctions, type Color } from 'treb-base-types';
|
|
11
11
|
import { Measurement } from 'treb-utils';
|
|
12
12
|
import type { ToolbarMessage } from '../toolbar-message';
|
|
13
13
|
|
|
@@ -68,7 +68,7 @@ export class SpreadsheetConstructor {
|
|
|
68
68
|
public sheet?: EmbeddedSpreadsheet
|
|
69
69
|
|
|
70
70
|
/** current border color. will be applied to new borders. */
|
|
71
|
-
protected border_color?:
|
|
71
|
+
protected border_color?: Color;
|
|
72
72
|
|
|
73
73
|
/** color bar elements, since we update them frequently */
|
|
74
74
|
protected color_bar_elements: Record<string, HTMLElement> = {};
|
|
@@ -662,25 +662,25 @@ export class SpreadsheetConstructor {
|
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
switch (state.style?.horizontal_align) {
|
|
665
|
-
case
|
|
665
|
+
case 'left':
|
|
666
666
|
Activate(this.toolbar_controls.left);
|
|
667
667
|
break;
|
|
668
|
-
case
|
|
668
|
+
case 'center':
|
|
669
669
|
Activate(this.toolbar_controls.center);
|
|
670
670
|
break;
|
|
671
|
-
case
|
|
671
|
+
case 'right':
|
|
672
672
|
Activate(this.toolbar_controls.right);
|
|
673
673
|
break;
|
|
674
674
|
}
|
|
675
675
|
|
|
676
676
|
switch (state.style?.vertical_align) {
|
|
677
|
-
case
|
|
677
|
+
case 'top':
|
|
678
678
|
Activate(this.toolbar_controls.top);
|
|
679
679
|
break;
|
|
680
|
-
case
|
|
680
|
+
case 'middle':
|
|
681
681
|
Activate(this.toolbar_controls.middle);
|
|
682
682
|
break;
|
|
683
|
-
case
|
|
683
|
+
case 'bottom':
|
|
684
684
|
Activate(this.toolbar_controls.bottom);
|
|
685
685
|
break;
|
|
686
686
|
}
|
|
@@ -952,7 +952,7 @@ export class SpreadsheetConstructor {
|
|
|
952
952
|
|
|
953
953
|
const props: {
|
|
954
954
|
comment?: string;
|
|
955
|
-
color?:
|
|
955
|
+
color?: Color;
|
|
956
956
|
format?: string;
|
|
957
957
|
scale?: string;
|
|
958
958
|
} = {
|
|
@@ -1108,7 +1108,7 @@ export class SpreadsheetConstructor {
|
|
|
1108
1108
|
// this is a check for "did it resolve properly"
|
|
1109
1109
|
const resolved = color_button.style.backgroundColor || '#fff';
|
|
1110
1110
|
const bytes = Measurement.MeasureColor(resolved);
|
|
1111
|
-
const hsl =
|
|
1111
|
+
const hsl = ColorFunctions.RGBToHSL(bytes[0], bytes[1], bytes[2]);
|
|
1112
1112
|
|
|
1113
1113
|
// light or dark based on background
|
|
1114
1114
|
color_button.style.color = (hsl.l > .5) ? '#000' : '#fff';
|
|
@@ -51,8 +51,8 @@ import type {
|
|
|
51
51
|
} from 'treb-base-types';
|
|
52
52
|
|
|
53
53
|
import {
|
|
54
|
-
IsArea, ThemeColorTable, ComplexToString, Rectangle, IsComplex,
|
|
55
|
-
Localization, Style, ThemeColor2, IsCellAddress, Area, IsFlatData, IsFlatDataArray,
|
|
54
|
+
IsArea, ThemeColorTable, ComplexToString, Rectangle, IsComplex, type CellStyle,
|
|
55
|
+
Localization, Style, type Color, ThemeColor2, IsCellAddress, Area, IsFlatData, IsFlatDataArray,
|
|
56
56
|
} from 'treb-base-types';
|
|
57
57
|
|
|
58
58
|
import { EventSource, Yield, ValidateURI } from 'treb-utils';
|
|
@@ -200,7 +200,7 @@ export interface SheetScrollOptions {
|
|
|
200
200
|
/**
|
|
201
201
|
* function type used for filtering tables
|
|
202
202
|
*/
|
|
203
|
-
export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style:
|
|
203
|
+
export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: CellStyle) => boolean;
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
206
|
* embedded spreadsheet
|
|
@@ -253,7 +253,7 @@ export class EmbeddedSpreadsheet {
|
|
|
253
253
|
public document_styles: {
|
|
254
254
|
number_formats: string[],
|
|
255
255
|
colors: string[],
|
|
256
|
-
theme_colors: Array<{ color:
|
|
256
|
+
theme_colors: Array<{ color: Color, resolved: string, }>[] // FIXME: type
|
|
257
257
|
} = {
|
|
258
258
|
number_formats: [], colors: [], theme_colors: [],
|
|
259
259
|
};
|
|
@@ -1242,7 +1242,7 @@ export class EmbeddedSpreadsheet {
|
|
|
1242
1242
|
return;
|
|
1243
1243
|
}
|
|
1244
1244
|
|
|
1245
|
-
let updated_style:
|
|
1245
|
+
let updated_style: CellStyle = {};
|
|
1246
1246
|
|
|
1247
1247
|
const insert_annotation = (func: string) => {
|
|
1248
1248
|
const selection = this.grid.GetSelection();
|
|
@@ -1341,7 +1341,7 @@ export class EmbeddedSpreadsheet {
|
|
|
1341
1341
|
case 'fill-color':
|
|
1342
1342
|
|
|
1343
1343
|
try {
|
|
1344
|
-
const color:
|
|
1344
|
+
const color: Color = event.color || {};
|
|
1345
1345
|
if (event.command === 'text-color') {
|
|
1346
1346
|
updated_style.text = color;
|
|
1347
1347
|
}
|
|
@@ -1491,27 +1491,27 @@ export class EmbeddedSpreadsheet {
|
|
|
1491
1491
|
break;
|
|
1492
1492
|
|
|
1493
1493
|
case 'justify-left':
|
|
1494
|
-
updated_style = { horizontal_align:
|
|
1494
|
+
updated_style = { horizontal_align: 'left' };
|
|
1495
1495
|
break;
|
|
1496
1496
|
|
|
1497
1497
|
case 'justify-center':
|
|
1498
|
-
updated_style = { horizontal_align:
|
|
1498
|
+
updated_style = { horizontal_align: 'center' };
|
|
1499
1499
|
break;
|
|
1500
1500
|
|
|
1501
1501
|
case 'justify-right':
|
|
1502
|
-
updated_style = { horizontal_align:
|
|
1502
|
+
updated_style = { horizontal_align: 'right' };
|
|
1503
1503
|
break;
|
|
1504
1504
|
|
|
1505
1505
|
case 'align-top':
|
|
1506
|
-
updated_style = { vertical_align:
|
|
1506
|
+
updated_style = { vertical_align: 'top' };
|
|
1507
1507
|
break;
|
|
1508
1508
|
|
|
1509
1509
|
case 'align-middle':
|
|
1510
|
-
updated_style = { vertical_align:
|
|
1510
|
+
updated_style = { vertical_align: 'middle' };
|
|
1511
1511
|
break;
|
|
1512
1512
|
|
|
1513
1513
|
case 'align-bottom':
|
|
1514
|
-
updated_style = { vertical_align:
|
|
1514
|
+
updated_style = { vertical_align: 'bottom' };
|
|
1515
1515
|
break;
|
|
1516
1516
|
|
|
1517
1517
|
case 'reset':
|
|
@@ -3556,7 +3556,7 @@ export class EmbeddedSpreadsheet {
|
|
|
3556
3556
|
*
|
|
3557
3557
|
* @public
|
|
3558
3558
|
*/
|
|
3559
|
-
public ApplyStyle(range?: RangeReference, style:
|
|
3559
|
+
public ApplyStyle(range?: RangeReference, style: CellStyle = {}, delta = true): void {
|
|
3560
3560
|
|
|
3561
3561
|
// ditto re: grid method taking undefined target
|
|
3562
3562
|
|
|
@@ -3776,7 +3776,7 @@ export class EmbeddedSpreadsheet {
|
|
|
3776
3776
|
* @param apply_theme - include theme defaults when returning style
|
|
3777
3777
|
*
|
|
3778
3778
|
*/
|
|
3779
|
-
public GetStyle(range?: RangeReference, apply_theme = false):
|
|
3779
|
+
public GetStyle(range?: RangeReference, apply_theme = false): CellStyle|CellStyle[][]|undefined {
|
|
3780
3780
|
|
|
3781
3781
|
// API v1 OK
|
|
3782
3782
|
|
|
@@ -4968,7 +4968,7 @@ export class EmbeddedSpreadsheet {
|
|
|
4968
4968
|
const tints = [.50, .25, 0, -.25, -.50];
|
|
4969
4969
|
for (let i = 0; i < 10; i++) {
|
|
4970
4970
|
this.document_styles.theme_colors.push(tints.map(tint => {
|
|
4971
|
-
const color:
|
|
4971
|
+
const color: Color = { theme: i, tint };
|
|
4972
4972
|
const resolved = ThemeColor2(this.grid.theme, color);
|
|
4973
4973
|
return { color, resolved };
|
|
4974
4974
|
}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
import type { GridSelection } from 'treb-grid';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CellStyle } from 'treb-base-types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* state that should be reflected in toolbar buttons/selections
|
|
7
7
|
*/
|
|
8
8
|
export interface SelectionState {
|
|
9
|
-
style?:
|
|
9
|
+
style?: CellStyle;
|
|
10
10
|
merge?: boolean;
|
|
11
11
|
table?: boolean;
|
|
12
12
|
frozen?: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import type { Style } from 'treb-base-types';
|
|
2
|
+
import type { Style, Color } from 'treb-base-types';
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
* this is an attempt to lock down toolbar commands, and better
|
|
@@ -9,7 +9,7 @@ import type { Style } from 'treb-base-types';
|
|
|
9
9
|
|
|
10
10
|
export interface SetColorToolbarMessage {
|
|
11
11
|
command: 'fill-color'|'text-color'|'border-color';
|
|
12
|
-
color?:
|
|
12
|
+
color?: Color
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export interface CommentToolbarMessage {
|
|
@@ -19,7 +19,7 @@ export interface CommentToolbarMessage {
|
|
|
19
19
|
|
|
20
20
|
export interface BorderToolbarMessage {
|
|
21
21
|
command: 'border-top'|'border-bottom'|'border-left'|'border-right'|'border-all'|'border-outside'|'border-none'|'border-double-bottom';
|
|
22
|
-
color?:
|
|
22
|
+
color?: Color;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface AnnotationToolbarMessage {
|
package/treb-embed/src/types.ts
CHANGED
|
@@ -40,10 +40,10 @@ export enum SaveFileType {
|
|
|
40
40
|
//
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
43
|
+
* this is the document type used by TREB. it has a lot of small variations
|
|
44
|
+
* for historical reasons and backwards compatibility. usually it's preferable
|
|
45
|
+
* to let TREB create and manage these documents rather than creating them
|
|
46
|
+
* manually.
|
|
47
47
|
*/
|
|
48
48
|
export interface TREBDocument {
|
|
49
49
|
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
.treb-main {
|
|
22
|
+
.treb-main.treb-main {
|
|
23
23
|
|
|
24
24
|
--treb-icon-svg: url("data:image/svg+xml,%3C%3Fxml version='1.0' encoding='utf-8'%3F%3E%3C!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3E%3Csvg version='1.1' id='Layer_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' width='153.073px' height='133.742px' viewBox='0.673 4.629 153.073 133.742' enable-background='new 0.673 4.629 153.073 133.742' xml:space='preserve'%3E%3ClinearGradient id='SVGID_1_' gradientUnits='userSpaceOnUse' x1='0.6729' y1='71.5' x2='153.7461' y2='71.5'%3E%3Cstop offset='0' style='stop-color:%235CB5FF'/%3E%3Cstop offset='1' style='stop-color:%230059B9'/%3E%3C/linearGradient%3E%3Cpath fill='url(%23SVGID_1_)' d='M91.656,28.313c-4.989,0-17.266,6.249-21.305,8.504c-2.344-2.473-2.603-6.162-3.036-10.933 c-2.344,2.429-0.824,9.806,0,12.496c-10.238,7.635-18.83,15.531-27.597,24.471c-2.992-4.729-5.031-8.593-5.726-17.183 c-3.038,6.509,0.867,15.057,3.121,19.784c-9.674,12.193-19.263,25.297-27.03,37.834C-25.405,28.313,82.936-16.248,153.746,14.431 C109.879,43.63,98.554,135.784,21.498,111.274c-5.423,7.809-9.069,18.006-13.538,27.072c-3.73,0.263-6.334-1.646-7.288-3.12 c7.506-18.181,17.183-34.192,27.075-49.984c10.718,0.306,21.346,0.478,30.198-1.04c-7.681-2.038-16.877-0.78-26.032-3.123 c5.597-10.718,13.754-18.876,21.867-27.075c8.808,0.782,17.746,3.21,27.074,1.041c-8.111-1.431-15.966-1.952-22.909-4.165 C65.539,42.502,80.722,33.389,91.656,28.313z'/%3E%3C/svg%3E%0A");
|
|
25
25
|
|
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
@import './treb-icons.scss';
|
|
9
9
|
@import './toolbar.scss';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/*
|
|
12
|
+
* switching to a double-selector to increase specificity. the particular
|
|
13
|
+
* issue we were running into was some general :where ... :is selectors that
|
|
14
|
+
* were breaking into our styles. this is not optimal but it does prevent
|
|
15
|
+
* at least inadvertent overrides.
|
|
16
|
+
*/
|
|
17
|
+
.treb-main.treb-main {
|
|
12
18
|
|
|
13
19
|
/*============================================================================
|
|
14
20
|
*
|
|
@@ -58,7 +64,7 @@
|
|
|
58
64
|
|
|
59
65
|
font-family: var(--treb-default-font, system-ui, $font-stack);
|
|
60
66
|
|
|
61
|
-
div, button, input, ul, ol, li, a, textarea {
|
|
67
|
+
div, button, input, ul, ol, li, a, textarea, svg {
|
|
62
68
|
|
|
63
69
|
// maybe this is being too aggressive. we could be a little
|
|
64
70
|
// more specific about what we unset in order to avoid any
|
|
@@ -71,6 +77,11 @@
|
|
|
71
77
|
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
// addressing some specific problems... increased specificity
|
|
81
|
+
|
|
82
|
+
// &.treb-main svg { all: revert; }
|
|
83
|
+
// &.treb-main div { margin: revert; }
|
|
84
|
+
|
|
74
85
|
/**
|
|
75
86
|
* this is kind of a global property but we don't actually want
|
|
76
87
|
* to inherit from the page, so we should set a font explicitly
|