@trebco/treb 25.7.7 → 25.8.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.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -653,7 +653,11 @@ export class EmbeddedSpreadsheet {
|
|
|
653
653
|
//this.extra_calculator = //new Calculator(this.model);
|
|
654
654
|
// this.CreateCalculator(this.model);
|
|
655
655
|
|
|
656
|
-
|
|
656
|
+
// update: tell the grid if we don't want to initialize the DOM,
|
|
657
|
+
// if we don't have a container. that's distinct (at the moment)
|
|
658
|
+
// from headless, which is a state that can change.
|
|
659
|
+
|
|
660
|
+
this.grid = new Grid(grid_options, this.parser, this.model, undefined, !!container);
|
|
657
661
|
|
|
658
662
|
if (this.options.headless) {
|
|
659
663
|
this.grid.headless = true; // FIXME: move into grid options
|
|
@@ -870,9 +874,9 @@ export class EmbeddedSpreadsheet {
|
|
|
870
874
|
else {
|
|
871
875
|
if (!EmbeddedSpreadsheet.one_time_warnings.headless) {
|
|
872
876
|
EmbeddedSpreadsheet.one_time_warnings.headless = true;
|
|
873
|
-
console.info('not initializing
|
|
877
|
+
console.info('not initializing layout; don\'t call UI functions');
|
|
874
878
|
}
|
|
875
|
-
this.grid.headless = true; // ensure
|
|
879
|
+
// this.grid.headless = true; // ensure
|
|
876
880
|
}
|
|
877
881
|
|
|
878
882
|
// moved up so we can share parser w/ grid
|
|
@@ -151,7 +151,7 @@ export abstract class BaseLayout {
|
|
|
151
151
|
this.scroll_reference_node.scrollTop = offset.y;
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
protected dropdown_caret
|
|
154
|
+
protected dropdown_caret!: SVGSVGElement;
|
|
155
155
|
|
|
156
156
|
/** we have to disable mock selection for IE or it breaks key handling */
|
|
157
157
|
private trident = ((typeof navigator !== 'undefined') &&
|
|
@@ -162,9 +162,9 @@ export abstract class BaseLayout {
|
|
|
162
162
|
|
|
163
163
|
private tooltip_state?: 'up' | 'left';
|
|
164
164
|
|
|
165
|
-
private tooltip
|
|
165
|
+
private tooltip!: HTMLDivElement;
|
|
166
166
|
|
|
167
|
-
private dropdown_list
|
|
167
|
+
private dropdown_list!: HTMLDivElement;
|
|
168
168
|
private dropdown_caret_visible = false;
|
|
169
169
|
private dropdown_callback?: (value: CellValue) => void;
|
|
170
170
|
private dropdown_selected?: HTMLElement;
|
|
@@ -174,10 +174,9 @@ export abstract class BaseLayout {
|
|
|
174
174
|
// private error_highlight: HTMLDivElement;
|
|
175
175
|
// private error_highlight_timeout?: any;
|
|
176
176
|
|
|
177
|
-
private note_node
|
|
178
|
-
private sort_button
|
|
179
|
-
|
|
180
|
-
private title_node: HTMLDivElement;
|
|
177
|
+
private note_node!: HTMLDivElement;
|
|
178
|
+
private sort_button!: HTMLButtonElement;
|
|
179
|
+
private title_node!: HTMLDivElement;
|
|
181
180
|
|
|
182
181
|
private row_cache: number[] = [];
|
|
183
182
|
private column_cache: number[] = [];
|
|
@@ -188,7 +187,11 @@ export abstract class BaseLayout {
|
|
|
188
187
|
private initialized = false;
|
|
189
188
|
|
|
190
189
|
|
|
191
|
-
constructor(protected model: DataModel, protected view: ViewModel) {
|
|
190
|
+
constructor(protected model: DataModel, protected view: ViewModel, mock = false) {
|
|
191
|
+
|
|
192
|
+
if (mock) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
192
195
|
|
|
193
196
|
// now attaching to node... no longer global
|
|
194
197
|
// actually if we are not in a web component, we might as well
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
import type { DataModel, ViewModel } from '../types/data_model';
|
|
3
|
+
import type { Tile } from '../types/tile';
|
|
4
|
+
import { BaseLayout } from './base_layout';
|
|
5
|
+
|
|
6
|
+
export class MockLayout extends BaseLayout {
|
|
7
|
+
|
|
8
|
+
public constructor(model: DataModel, view: ViewModel) {
|
|
9
|
+
super(model, view, true);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public InitializeInternal(container: HTMLElement, scroll_callback: () => void): void {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
protected UpdateGridTemplates(columns: boolean, rows: boolean): void {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
protected UpdateTileGridPosition(tile: Tile): void {
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
protected UpdateContainingGrid(): void {
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public ResizeCursor(resize?: 'row' | 'column' | undefined): void {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
@@ -65,6 +65,7 @@ import { TabBar } from './tab_bar';
|
|
|
65
65
|
import type { StatsEntry } from './tab_bar';
|
|
66
66
|
|
|
67
67
|
import { Sheet } from './sheet';
|
|
68
|
+
import { MockLayout } from '../layout/mock-layout';
|
|
68
69
|
import type { BaseLayout } from '../layout/base_layout';
|
|
69
70
|
import { TileRange } from '../layout/base_layout';
|
|
70
71
|
|
|
@@ -328,10 +329,10 @@ export class Grid extends GridBase {
|
|
|
328
329
|
private render_token = 0;
|
|
329
330
|
|
|
330
331
|
/** */
|
|
331
|
-
private tile_renderer
|
|
332
|
+
private tile_renderer?: TileRenderer;
|
|
332
333
|
|
|
333
334
|
/** */
|
|
334
|
-
private selection_renderer
|
|
335
|
+
private selection_renderer?: SelectionRenderer;
|
|
335
336
|
|
|
336
337
|
// FIXME: move [why?]
|
|
337
338
|
|
|
@@ -346,7 +347,8 @@ export class Grid extends GridBase {
|
|
|
346
347
|
options: GridOptions = {},
|
|
347
348
|
parser: Parser,
|
|
348
349
|
model: DataModel,
|
|
349
|
-
theme: Theme = DefaultTheme
|
|
350
|
+
theme: Theme = DefaultTheme,
|
|
351
|
+
initialze_dom = true ) {
|
|
350
352
|
|
|
351
353
|
super(options, parser, model);
|
|
352
354
|
|
|
@@ -356,6 +358,12 @@ export class Grid extends GridBase {
|
|
|
356
358
|
|
|
357
359
|
this.theme = JSON.parse(JSON.stringify(theme));
|
|
358
360
|
|
|
361
|
+
if (!initialze_dom) {
|
|
362
|
+
this.headless = true;
|
|
363
|
+
this.layout = new MockLayout(this.model, this.view);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
|
|
359
367
|
this.layout = new GridLayout(this.model, this.view);
|
|
360
368
|
|
|
361
369
|
if (options.initial_scale) {
|
|
@@ -1226,6 +1234,10 @@ export class Grid extends GridBase {
|
|
|
1226
1234
|
*/
|
|
1227
1235
|
public Initialize(view_node: HTMLElement, toll_initial_render = false): void {
|
|
1228
1236
|
|
|
1237
|
+
if (!this.tile_renderer || !this.selection_renderer) {
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1229
1241
|
// grid no longer has access to the outer container, it just has
|
|
1230
1242
|
// the "view" container. so we need to move things like UA classes
|
|
1231
1243
|
// outside of this class. we should move theme parsing as well, so
|
|
@@ -2125,6 +2137,10 @@ export class Grid extends GridBase {
|
|
|
2125
2137
|
|
|
2126
2138
|
private AutoSizeColumn(sheet: Sheet, column: number, allow_shrink = true): void {
|
|
2127
2139
|
|
|
2140
|
+
if (!this.tile_renderer) {
|
|
2141
|
+
return;
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2128
2144
|
// const context = Sheet.measurement_canvas.getContext('2d');
|
|
2129
2145
|
// if (!context) return;
|
|
2130
2146
|
|
|
@@ -2729,7 +2745,7 @@ export class Grid extends GridBase {
|
|
|
2729
2745
|
|
|
2730
2746
|
private Repaint(force = false, full_tile = false, force_headers = false) {
|
|
2731
2747
|
|
|
2732
|
-
if (this.headless) { return; }
|
|
2748
|
+
if (this.headless || !this.tile_renderer) { return; }
|
|
2733
2749
|
|
|
2734
2750
|
if (this.tile_update_pending) {
|
|
2735
2751
|
this.tile_update_pending = false;
|
|
@@ -3497,6 +3513,10 @@ export class Grid extends GridBase {
|
|
|
3497
3513
|
event.stopPropagation();
|
|
3498
3514
|
event.preventDefault();
|
|
3499
3515
|
|
|
3516
|
+
if (!this.selection_renderer) {
|
|
3517
|
+
return;
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3500
3520
|
// needed for legacy
|
|
3501
3521
|
|
|
3502
3522
|
if (this.cell_resize.row >= 0 || this.cell_resize.column >= 0) {
|
|
@@ -4616,7 +4636,7 @@ export class Grid extends GridBase {
|
|
|
4616
4636
|
const show_primary_selection = this.hide_selection ? false :
|
|
4617
4637
|
(!this.editing_state) || (this.editing_cell.sheet_id === this.active_sheet.id);
|
|
4618
4638
|
|
|
4619
|
-
this.selection_renderer
|
|
4639
|
+
this.selection_renderer?.RenderSelections(show_primary_selection, rerender);
|
|
4620
4640
|
}
|
|
4621
4641
|
|
|
4622
4642
|
/**
|
|
@@ -6876,7 +6896,7 @@ export class Grid extends GridBase {
|
|
|
6876
6896
|
// columns. we should be able to fix this, or we can just flush
|
|
6877
6897
|
// all overflows and force them to get recreated.
|
|
6878
6898
|
|
|
6879
|
-
this.tile_renderer
|
|
6899
|
+
this.tile_renderer?.FlushOverflows();
|
|
6880
6900
|
|
|
6881
6901
|
// note event is sent in exec command, not implicit here
|
|
6882
6902
|
|