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