@trebco/treb 31.7.4 → 31.7.7
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
|
@@ -1214,7 +1214,7 @@ export interface ConditionalFormatGradientOptions {
|
|
|
1214
1214
|
/** min and max are optional. if not provided, we use the min/max of the range of data. */
|
|
1215
1215
|
max?: number;
|
|
1216
1216
|
}
|
|
1217
|
-
export type StandardGradient =
|
|
1217
|
+
export type StandardGradient = 'red-green' | 'green-red' | 'red-yellow-green' | 'green-yellow-red';
|
|
1218
1218
|
export interface ConditionalFormatCellMatchOptions {
|
|
1219
1219
|
style: CellStyle;
|
|
1220
1220
|
expression: string;
|
package/package.json
CHANGED
|
@@ -68,6 +68,7 @@ export interface ConditionalFormatGradientOptions {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
|
+
*
|
|
71
72
|
* @internal
|
|
72
73
|
*
|
|
73
74
|
* @privateRemarks
|
|
@@ -107,7 +108,10 @@ export const StandardGradientsList = {
|
|
|
107
108
|
] as GradientStop[],
|
|
108
109
|
},
|
|
109
110
|
} as const;
|
|
110
|
-
|
|
111
|
+
|
|
112
|
+
// temp while I figure out what's wrong with the API generator
|
|
113
|
+
// export type StandardGradient = keyof typeof StandardGradientsList;
|
|
114
|
+
export type StandardGradient = 'red-green' | 'green-red' | 'red-yellow-green' | 'green-yellow-red';
|
|
111
115
|
|
|
112
116
|
export interface ConditionalFormatGradient extends ConditionalFormatGradientOptions {
|
|
113
117
|
type: 'gradient';
|
|
@@ -186,7 +186,8 @@ export class Sheet {
|
|
|
186
186
|
private id_: number;
|
|
187
187
|
|
|
188
188
|
// tslint:disable-next-line:variable-name
|
|
189
|
-
private row_height_: number[] = [];
|
|
189
|
+
// private row_height_: number[] = [];
|
|
190
|
+
private row_height_map: Map<number, number> = new Map();
|
|
190
191
|
|
|
191
192
|
// tslint:disable-next-line:variable-name
|
|
192
193
|
private column_width_: number[] = [];
|
|
@@ -715,26 +716,21 @@ export class Sheet {
|
|
|
715
716
|
|
|
716
717
|
// ok
|
|
717
718
|
|
|
719
|
+
sheet.row_height_map = new Map();
|
|
720
|
+
if (source.row_height) {
|
|
721
|
+
for (const [key, value] of Object.entries(source.row_height)) {
|
|
722
|
+
sheet.row_height_map.set(Number(key), value);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
718
725
|
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
// sheet.default_column_width = obj.default_column_width;
|
|
723
|
-
|
|
724
|
-
sheet.row_height_ = [];
|
|
725
|
-
unflatten_numeric_array(sheet.row_height_, source.row_height || {},
|
|
726
|
-
); // sheet.default_row_height);
|
|
727
|
-
// obj.default_row_height);
|
|
728
|
-
|
|
729
|
-
if (sheet.row_height_.length) {
|
|
730
|
-
sheet.cells.EnsureRow(sheet.row_height_.length - 1);
|
|
726
|
+
if (sheet.row_height_map.size > 0) {
|
|
727
|
+
const max = Math.max(...sheet.row_height_map.keys());
|
|
728
|
+
sheet.cells.EnsureRow(max);
|
|
731
729
|
}
|
|
732
730
|
|
|
733
731
|
sheet.column_width_ = [];
|
|
734
|
-
unflatten_numeric_array(sheet.column_width_, source.column_width || {},
|
|
735
|
-
|
|
736
|
-
// obj.default_column_width);
|
|
737
|
-
|
|
732
|
+
unflatten_numeric_array(sheet.column_width_, source.column_width || {}, );
|
|
733
|
+
|
|
738
734
|
if (sheet.column_width_.length) {
|
|
739
735
|
sheet.cells.EnsureColumn(sheet.column_width_.length - 1);
|
|
740
736
|
}
|
|
@@ -1011,13 +1007,13 @@ export class Sheet {
|
|
|
1011
1007
|
}
|
|
1012
1008
|
|
|
1013
1009
|
public GetRowHeight(row: number): number {
|
|
1014
|
-
const height = this.
|
|
1010
|
+
const height = this.row_height_map.get(row);
|
|
1015
1011
|
if (typeof height === 'undefined') return this.default_row_height;
|
|
1016
1012
|
return height;
|
|
1017
1013
|
}
|
|
1018
1014
|
|
|
1019
1015
|
public SetRowHeight(row: number, height: number): number {
|
|
1020
|
-
this.
|
|
1016
|
+
this.row_height_map.set(row, height);
|
|
1021
1017
|
this.cells.EnsureRow(row);
|
|
1022
1018
|
return height;
|
|
1023
1019
|
}
|
|
@@ -1241,7 +1237,7 @@ export class Sheet {
|
|
|
1241
1237
|
* @see NextVisibleColumn
|
|
1242
1238
|
*/
|
|
1243
1239
|
public NextVisibleRow(row: number): number {
|
|
1244
|
-
for (++row; this.
|
|
1240
|
+
for (++row; this.GetRowHeight(row) === 0; row++) { /* */ }
|
|
1245
1241
|
return row;
|
|
1246
1242
|
}
|
|
1247
1243
|
|
|
@@ -1249,7 +1245,7 @@ export class Sheet {
|
|
|
1249
1245
|
* @see PreviousVisibleColumn
|
|
1250
1246
|
*/
|
|
1251
1247
|
public PreviousVisibleRow(row: number): number {
|
|
1252
|
-
for (--row; row >= 0 && this.
|
|
1248
|
+
for (--row; row >= 0 && this.GetRowHeight(row) === 0; row--) { /* */ }
|
|
1253
1249
|
return row;
|
|
1254
1250
|
}
|
|
1255
1251
|
|
|
@@ -1281,11 +1277,20 @@ export class Sheet {
|
|
|
1281
1277
|
return result;
|
|
1282
1278
|
}
|
|
1283
1279
|
|
|
1280
|
+
|
|
1281
|
+
// oh these loops are a problem if the table is very large. need to
|
|
1282
|
+
// address, maybe we can cache? not sure. as a hint, we have a list
|
|
1283
|
+
// of non-default row heights.
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1284
1287
|
// how we handle last row depends on totals. if we have a totals
|
|
1285
1288
|
// row, and it's visible, we don't need to do the "last row" thing.
|
|
1286
1289
|
|
|
1287
1290
|
const totals_visible = (table.totals_row && (this.GetRowHeight(table.area.end.row) > 0));
|
|
1288
1291
|
|
|
1292
|
+
// this one is probably ok
|
|
1293
|
+
|
|
1289
1294
|
if (!totals_visible) {
|
|
1290
1295
|
let last = table.area.end.row;
|
|
1291
1296
|
for ( ; last >= table.area.start.row; last-- ) {
|
|
@@ -1296,7 +1301,40 @@ export class Sheet {
|
|
|
1296
1301
|
}
|
|
1297
1302
|
}
|
|
1298
1303
|
|
|
1304
|
+
|
|
1305
|
+
// this is an improvement if the table is mostly not hidden. but
|
|
1306
|
+
// if the table is mostly hidden we'll run into the same problem
|
|
1307
|
+
// again. not sure the most effective way to address this. we probably
|
|
1308
|
+
// need to cache this information somewhere.
|
|
1309
|
+
|
|
1310
|
+
// ACTUALLY this does not work (at least not the way you think it
|
|
1311
|
+
// does). row_height_ is a sparse array so iterating will still
|
|
1312
|
+
// check every skipped index.
|
|
1313
|
+
|
|
1314
|
+
// OK now it's a map
|
|
1315
|
+
|
|
1316
|
+
const start = table.area.start.row + 1 ; // (table.headers ? 1 : 0);
|
|
1317
|
+
|
|
1318
|
+
let delta = row - start;
|
|
1319
|
+
for (const [index, height] of this.row_height_map.entries()) {
|
|
1320
|
+
if (index < start) {
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
if (index > table.area.end.row) {
|
|
1324
|
+
break;
|
|
1325
|
+
}
|
|
1326
|
+
if (!height) {
|
|
1327
|
+
delta--;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
result.alternate = (delta % 2 === 1);
|
|
1332
|
+
|
|
1333
|
+
// this one looks bad
|
|
1334
|
+
|
|
1335
|
+
/*
|
|
1299
1336
|
let start = table.area.start.row + 1 ; // (table.headers ? 1 : 0);
|
|
1337
|
+
|
|
1300
1338
|
for ( ; start <= table.area.end.row; start++ ) {
|
|
1301
1339
|
if (!this.GetRowHeight(start)) {
|
|
1302
1340
|
continue;
|
|
@@ -1307,6 +1345,7 @@ export class Sheet {
|
|
|
1307
1345
|
break;
|
|
1308
1346
|
}
|
|
1309
1347
|
}
|
|
1348
|
+
*/
|
|
1310
1349
|
|
|
1311
1350
|
return result;
|
|
1312
1351
|
}
|
|
@@ -1338,10 +1377,10 @@ export class Sheet {
|
|
|
1338
1377
|
let row_above = address.row - 1;
|
|
1339
1378
|
|
|
1340
1379
|
for (; this.column_width_[column_right] === 0; column_right++) { /* */ }
|
|
1341
|
-
for (; this.
|
|
1380
|
+
for (; this.GetRowHeight(row_below) === 0; row_below++) { /* */ }
|
|
1342
1381
|
|
|
1343
1382
|
for (; column_left >= 0 && this.column_width_[column_left] === 0; column_left--) { /* */ }
|
|
1344
|
-
for (; row_above >= 0 && this.
|
|
1383
|
+
for (; row_above >= 0 && this.GetRowHeight(row_above) === 0; row_above--) { /* */ }
|
|
1345
1384
|
|
|
1346
1385
|
if (column_left >= 0 && row_above >= 0) {
|
|
1347
1386
|
map[7] = this.CellStyleData({ row: row_above, column: column_left }, table) || {};
|
|
@@ -1901,8 +1940,35 @@ export class Sheet {
|
|
|
1901
1940
|
|
|
1902
1941
|
// row heights
|
|
1903
1942
|
|
|
1943
|
+
// row heights is now a map, so this has to change...
|
|
1944
|
+
|
|
1904
1945
|
// eslint-disable-next-line prefer-spread
|
|
1905
|
-
this.row_height_.splice.apply(this.row_height_, args as [number, number, number]);
|
|
1946
|
+
// this.row_height_.splice.apply(this.row_height_, args as [number, number, number]);
|
|
1947
|
+
|
|
1948
|
+
const tmp: Map<number, number> = new Map();
|
|
1949
|
+
if (count > 0) {
|
|
1950
|
+
for (const [row, height] of this.row_height_map) {
|
|
1951
|
+
if (row >= before_row) {
|
|
1952
|
+
tmp.set(row + count, height);
|
|
1953
|
+
}
|
|
1954
|
+
else {
|
|
1955
|
+
tmp.set(row, height);
|
|
1956
|
+
}
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
else if (count < 0) {
|
|
1960
|
+
for (const [row, height] of this.row_height_map) {
|
|
1961
|
+
if (row >= before_row) {
|
|
1962
|
+
if (row >= before_row - count) {
|
|
1963
|
+
tmp.set(row + count, height);
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
else {
|
|
1967
|
+
tmp.set(row, height);
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
this.row_height_map = tmp;
|
|
1906
1972
|
|
|
1907
1973
|
// invalidate style cache
|
|
1908
1974
|
this.FlushCellStyles();
|
|
@@ -2737,6 +2803,10 @@ export class Sheet {
|
|
|
2737
2803
|
|
|
2738
2804
|
const data_validations = this.data_validation.length ? JSON.parse(JSON.stringify(this.data_validation)) : undefined;
|
|
2739
2805
|
|
|
2806
|
+
const row_height: Record<number, number> = {};
|
|
2807
|
+
for (const [key, value] of this.row_height_map.entries()) {
|
|
2808
|
+
row_height[key] = value;
|
|
2809
|
+
}
|
|
2740
2810
|
|
|
2741
2811
|
const result: SerializedSheet = {
|
|
2742
2812
|
|
|
@@ -2771,7 +2841,7 @@ export class Sheet {
|
|
|
2771
2841
|
default_row_height: this.default_row_height,
|
|
2772
2842
|
default_column_width: this.default_column_width,
|
|
2773
2843
|
|
|
2774
|
-
row_height: flatten_numeric_array(this.row_height_, this.default_row_height),
|
|
2844
|
+
row_height, // : flatten_numeric_array(this.row_height_, this.default_row_height),
|
|
2775
2845
|
column_width: flatten_numeric_array(this.column_width_, this.default_column_width),
|
|
2776
2846
|
|
|
2777
2847
|
selection: JSON.parse(JSON.stringify(this.selection)),
|
|
@@ -244,6 +244,11 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
244
244
|
tab.style.backgroundColor = `color-mix(in srgb, ${tab.dataset.background_color} 20%, var(--treb-tab-bar-active-tab-background, #fff))`;
|
|
245
245
|
tab.style.color = '';
|
|
246
246
|
}
|
|
247
|
+
|
|
248
|
+
requestAnimationFrame(() => {
|
|
249
|
+
tab.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'nearest'});
|
|
250
|
+
});
|
|
251
|
+
|
|
247
252
|
}
|
|
248
253
|
else {
|
|
249
254
|
// tab.classList.remove('treb-selected');
|