@trebco/treb 27.12.2 → 28.2.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/README.md +6 -0
- package/dist/treb-spreadsheet-light.mjs +16 -0
- package/dist/treb-spreadsheet.mjs +13 -11
- package/dist/treb.d.ts +33 -5
- package/esbuild-custom-element.mjs +3 -1
- package/package.json +8 -6
- package/treb-base-types/src/dom-utilities.ts +157 -19
- package/treb-base-types/src/import.ts +1 -0
- package/treb-base-types/src/theme.ts +5 -4
- package/treb-charts/src/renderer.ts +4 -58
- package/treb-embed/markup/layout.html +4 -0
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +131 -87
- package/treb-embed/src/embedded-spreadsheet.ts +153 -140
- package/treb-embed/src/options.ts +9 -0
- package/treb-embed/src/spinner.ts +5 -3
- package/treb-embed/src/toolbar-message.ts +5 -0
- package/treb-embed/style/layout.scss +65 -1
- package/treb-export/src/export-worker/export-worker.ts +7 -12
- package/treb-export/src/export2.ts +57 -33
- package/treb-export/src/import2.ts +61 -21
- package/treb-export/src/workbook2.ts +69 -24
- package/treb-export/src/zip-wrapper.ts +96 -0
- package/treb-grid/src/editors/autocomplete.ts +24 -13
- package/treb-grid/src/editors/editor.ts +43 -139
- package/treb-grid/src/editors/external_editor.ts +1 -1
- package/treb-grid/src/editors/formula_bar.ts +24 -24
- package/treb-grid/src/editors/overlay_editor.ts +1 -1
- package/treb-grid/src/layout/base_layout.ts +34 -25
- package/treb-grid/src/layout/grid_layout.ts +20 -20
- package/treb-grid/src/render/selection-renderer.ts +3 -3
- package/treb-grid/src/render/svg_header_overlay.ts +6 -4
- package/treb-grid/src/render/svg_selection_block.ts +10 -7
- package/treb-grid/src/types/annotation.ts +2 -2
- package/treb-grid/src/types/grid.ts +80 -81
- package/treb-grid/src/types/scale-control.ts +69 -81
- package/treb-grid/src/types/sheet.ts +3 -52
- package/treb-grid/src/types/tab_bar.ts +27 -13
- package/treb-grid/src/util/fontmetrics2.ts +24 -21
- package/treb-utils/src/event_source.ts +23 -23
- package/treb-utils/src/index.ts +2 -2
- package/treb-utils/src/measurement.ts +24 -24
- package/treb-utils/src/serialize_html.ts +25 -21
- package/treb-utils/src/dispatch.ts +0 -57
- package/treb-utils/src/resizable.ts +0 -159
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
/**
|
|
23
|
-
* UPDATE: dropping dispatch altogether. there were really very few
|
|
24
|
-
* cases where queue length > 1, so it seems like unecessary overhead.
|
|
25
|
-
*
|
|
26
|
-
* it's still somewhat useful to have an interface, in the event we
|
|
27
|
-
* change this again, so keep using the Yield() function.
|
|
28
|
-
*
|
|
29
|
-
* TODO: is anyone using the callback version? could drop...
|
|
30
|
-
*
|
|
31
|
-
* I'm guessing no one uses it, because it's broken amd we never noticed
|
|
32
|
-
*/
|
|
33
|
-
|
|
34
|
-
/* *
|
|
35
|
-
* yield and then call the passed function
|
|
36
|
-
* /
|
|
37
|
-
export function Yield(fn: () => void): void;
|
|
38
|
-
|
|
39
|
-
/ * *
|
|
40
|
-
* returns a promise that resolves after yield
|
|
41
|
-
* /
|
|
42
|
-
export function Yield(): Promise<void>;
|
|
43
|
-
|
|
44
|
-
/ * * implementation * /
|
|
45
|
-
export function Yield(fn?: () => void) {
|
|
46
|
-
return fn ? Promise.resolve().then(fn) : Promise.resolve();
|
|
47
|
-
}
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
|
-
/* for perf testing, we don't need this anymore
|
|
51
|
-
(self as any).__dispatcher_instance = {
|
|
52
|
-
Call: Yield
|
|
53
|
-
}
|
|
54
|
-
*/
|
|
55
|
-
|
|
56
|
-
export const Yield = () => Promise.resolve();
|
|
57
|
-
|
|
@@ -1,159 +0,0 @@
|
|
|
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
|
-
import { DOMUtilities } from 'treb-base-types';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* support for resizable node, drag handle, drag rect, mask
|
|
26
|
-
* FIXME: make this composable (decorator?)
|
|
27
|
-
* FIXME: make this generic, we can use it for some other stuff (charts?)
|
|
28
|
-
*/
|
|
29
|
-
export class Resizable {
|
|
30
|
-
|
|
31
|
-
private static resize_mask: HTMLElement;
|
|
32
|
-
private static resize_rect: HTMLElement;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* adding layout_reference to move the handle. to keep this backwards
|
|
36
|
-
* compatible, we add it as a last, optional parameter. at some point
|
|
37
|
-
* we can create a replacement class and migrate.
|
|
38
|
-
*
|
|
39
|
-
* this is a weird pattern, we don't need an instance of this class...
|
|
40
|
-
* goint to refactor
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
constructor(container: HTMLElement, node: HTMLElement, resize_callback: () => void,
|
|
44
|
-
layout_reference: HTMLElement = container) {
|
|
45
|
-
|
|
46
|
-
Resizable.Create({
|
|
47
|
-
container,
|
|
48
|
-
node,
|
|
49
|
-
resize_callback,
|
|
50
|
-
layout_reference});
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public static Create(options: {
|
|
55
|
-
container: HTMLElement;
|
|
56
|
-
node: HTMLElement;
|
|
57
|
-
resize_callback?: () => void;
|
|
58
|
-
layout_reference?: HTMLElement;
|
|
59
|
-
}): void {
|
|
60
|
-
|
|
61
|
-
const resize_handle = DOMUtilities.Div('treb-embed-resize-handle');
|
|
62
|
-
|
|
63
|
-
(options.layout_reference || options.container).appendChild(resize_handle);
|
|
64
|
-
|
|
65
|
-
if (!Resizable.resize_mask) {
|
|
66
|
-
let mask = document.querySelector('.treb-embed-mouse-mask');
|
|
67
|
-
if (!mask) {
|
|
68
|
-
mask = DOMUtilities.Div('treb-embed-mouse-mask');
|
|
69
|
-
document.body.appendChild(mask);
|
|
70
|
-
}
|
|
71
|
-
Resizable.resize_mask = mask as HTMLElement;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (!Resizable.resize_rect) {
|
|
75
|
-
let rect = document.querySelector('.treb-embed-resize-rect');
|
|
76
|
-
if (!rect) {
|
|
77
|
-
rect = DOMUtilities.Div('treb-embed-resize-rect');
|
|
78
|
-
Resizable.resize_mask.appendChild(rect);
|
|
79
|
-
}
|
|
80
|
-
Resizable.resize_rect = rect as HTMLElement;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// eslint-disable-next-line prefer-const
|
|
84
|
-
let mouseup: () => void;
|
|
85
|
-
|
|
86
|
-
// eslint-disable-next-line prefer-const
|
|
87
|
-
let mousemove: (event: MouseEvent) => void;
|
|
88
|
-
|
|
89
|
-
let container_rect = { width: 0, height: 0 };
|
|
90
|
-
let offset = { x: 0, y: 0 };
|
|
91
|
-
let delta = { x: 0, y: 0 };
|
|
92
|
-
|
|
93
|
-
const cleanup = () => {
|
|
94
|
-
|
|
95
|
-
Resizable.resize_mask.removeEventListener('mousemove', mousemove);
|
|
96
|
-
Resizable.resize_mask.removeEventListener('mouseup', mouseup);
|
|
97
|
-
Resizable.resize_mask.style.display = 'none';
|
|
98
|
-
|
|
99
|
-
if (delta.x || delta.y) {
|
|
100
|
-
const bounding_rect = options.container.getBoundingClientRect();
|
|
101
|
-
const width = bounding_rect.width + delta.x;
|
|
102
|
-
const height = bounding_rect.height + delta.y;
|
|
103
|
-
options.container.style.width = `${width}px`;
|
|
104
|
-
options.container.style.height = `${height}px`;
|
|
105
|
-
if (options.resize_callback) {
|
|
106
|
-
options.resize_callback();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
mousemove = (event: MouseEvent) => {
|
|
113
|
-
|
|
114
|
-
if (!event.buttons) {
|
|
115
|
-
cleanup();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
if (delta.x !== event.clientX - offset.x) {
|
|
120
|
-
delta.x = event.clientX - offset.x;
|
|
121
|
-
Resizable.resize_rect.style.width = `${container_rect.width + delta.x + 4}px`;
|
|
122
|
-
}
|
|
123
|
-
if (delta.y !== event.clientY - offset.y) {
|
|
124
|
-
delta.y = event.clientY - offset.y;
|
|
125
|
-
Resizable.resize_rect.style.height = `${container_rect.height + delta.y + 4}px`;
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
mouseup = () => {
|
|
130
|
-
cleanup();
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
resize_handle.addEventListener('mousedown', (event) => {
|
|
134
|
-
|
|
135
|
-
event.stopPropagation();
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
|
|
138
|
-
const bounding_rect = options.node.getBoundingClientRect();
|
|
139
|
-
container_rect = { width: bounding_rect.width, height: bounding_rect.height };
|
|
140
|
-
|
|
141
|
-
if (Resizable.resize_rect) {
|
|
142
|
-
Resizable.resize_rect.style.top = `${bounding_rect.top - 2}px`;
|
|
143
|
-
Resizable.resize_rect.style.left = `${bounding_rect.left - 2}px`;
|
|
144
|
-
Resizable.resize_rect.style.width = `${bounding_rect.width + 4}px`;
|
|
145
|
-
Resizable.resize_rect.style.height = `${bounding_rect.height + 4}px`;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
offset = { x: event.clientX, y: event.clientY };
|
|
149
|
-
delta = { x: 0, y: 0 };
|
|
150
|
-
|
|
151
|
-
Resizable.resize_mask.style.display = 'block';
|
|
152
|
-
Resizable.resize_mask.addEventListener('mousemove', mousemove);
|
|
153
|
-
Resizable.resize_mask.addEventListener('mouseup', mouseup);
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
}
|