@trebco/treb 27.9.0 → 27.11.4
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 +9 -9
- package/dist/treb.d.ts +8 -6
- package/package.json +1 -1
- package/{treb-grid/src/util/dom_utilities.ts → treb-base-types/src/dom-utilities.ts} +29 -20
- package/treb-base-types/src/index.ts +1 -0
- package/treb-base-types/src/theme.ts +3 -5
- package/treb-embed/src/custom-element/global.d.ts +3 -1
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +13 -19
- package/treb-embed/src/embedded-spreadsheet.ts +67 -93
- package/treb-embed/src/spinner.ts +3 -3
- package/treb-embed/style/layout.scss +1 -1
- package/treb-embed/style/overlay-editor.scss +9 -0
- package/treb-export/src/drawing2/chart2.ts +11 -2
- package/treb-export/src/export2.ts +14 -4
- package/treb-export/src/workbook-style2.ts +3 -2
- package/treb-grid/src/editors/autocomplete.ts +28 -24
- package/treb-grid/src/editors/editor.ts +32 -4
- package/treb-grid/src/editors/formula_bar.ts +1 -1
- package/treb-grid/src/layout/base_layout.ts +11 -16
- package/treb-grid/src/layout/grid_layout.ts +17 -28
- package/treb-grid/src/render/selection-renderer.ts +2 -3
- package/treb-grid/src/render/svg_header_overlay.ts +4 -11
- package/treb-grid/src/render/svg_selection_block.ts +27 -34
- package/treb-grid/src/render/tile_renderer.ts +6 -5
- package/treb-grid/src/types/grid.ts +32 -41
- package/treb-grid/src/types/grid_base.ts +2 -0
- package/treb-grid/src/types/scale-control.ts +2 -2
- package/treb-grid/src/types/sheet.ts +2 -2
- package/treb-grid/src/types/tab_bar.ts +4 -8
- package/treb-utils/src/index.ts +0 -1
- package/treb-utils/src/resizable.ts +26 -27
- package/treb-utils/src/template.ts +0 -70
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import { DOMUtilities as DOM } from '
|
|
22
|
+
import { DOMUtilities as DOM } from 'treb-base-types';
|
|
23
23
|
import { NumberFormat, NumberFormatCache, ValueParser } from 'treb-format';
|
|
24
24
|
import { ValueType } from 'treb-base-types';
|
|
25
25
|
import { EventSource } from 'treb-utils';
|
|
@@ -54,7 +54,7 @@ export class ScaleControl extends EventSource<ScaleEvent> {
|
|
|
54
54
|
// const div = DOM.CreateDiv('treb-scale-control-2', container);
|
|
55
55
|
|
|
56
56
|
this.input = DOM.Create('input', 'treb-scale-input', /* div */ container);
|
|
57
|
-
const popup = DOM.
|
|
57
|
+
const popup = DOM.Div('treb-slider-container', /* div */ container);
|
|
58
58
|
|
|
59
59
|
/*
|
|
60
60
|
this.input.addEventListener('keyup', (event) => {
|
|
@@ -26,7 +26,7 @@ import { ValueType, Cells, Style,
|
|
|
26
26
|
type PropertyKeys,
|
|
27
27
|
type Color,
|
|
28
28
|
Area, IsFlatDataArray,
|
|
29
|
-
IsNestedRowArray, IsCellAddress
|
|
29
|
+
IsNestedRowArray, IsCellAddress, DOMUtilities
|
|
30
30
|
} from 'treb-base-types';
|
|
31
31
|
import { NumberFormatCache } from 'treb-format';
|
|
32
32
|
import { Measurement, ValidateURI } from 'treb-utils';
|
|
@@ -748,7 +748,7 @@ export class Sheet {
|
|
|
748
748
|
if (this.background_image) {
|
|
749
749
|
const resource = ValidateURI(this.background_image);
|
|
750
750
|
if (resource) {
|
|
751
|
-
this._image =
|
|
751
|
+
this._image = DOMUtilities.Create('img');
|
|
752
752
|
this._image.src = resource;
|
|
753
753
|
}
|
|
754
754
|
|
|
@@ -26,6 +26,7 @@ import type { BaseLayout } from '../layout/base_layout';
|
|
|
26
26
|
import { MouseDrag } from './drag_mask';
|
|
27
27
|
import type { GridOptions } from './grid_options';
|
|
28
28
|
import { type ScaleEvent, ScaleControl } from './scale-control';
|
|
29
|
+
import { DOMUtilities } from 'treb-base-types';
|
|
29
30
|
|
|
30
31
|
export interface ActivateSheetEvent {
|
|
31
32
|
type: 'activate-sheet';
|
|
@@ -112,15 +113,11 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
112
113
|
this.stats_panel.innerText = ''; // clear
|
|
113
114
|
for (const entry of value) {
|
|
114
115
|
|
|
115
|
-
const label =
|
|
116
|
-
label.classList.add('treb-stats-label');
|
|
116
|
+
const label = DOMUtilities.Create('span', 'treb-stats-label', this.stats_panel);
|
|
117
117
|
label.textContent = entry.label;
|
|
118
|
-
this.stats_panel.appendChild(label);
|
|
119
118
|
|
|
120
|
-
const figure =
|
|
121
|
-
figure.classList.add('treb-stats-value');
|
|
119
|
+
const figure = DOMUtilities.Create('span', 'treb-stats-value', this.stats_panel);
|
|
122
120
|
figure.textContent = entry.value;
|
|
123
|
-
this.stats_panel.appendChild(figure);
|
|
124
121
|
}
|
|
125
122
|
}
|
|
126
123
|
}
|
|
@@ -451,8 +448,7 @@ export class TabBar extends EventSource<TabEvent> {
|
|
|
451
448
|
if (!sheet.visible) { continue; }
|
|
452
449
|
|
|
453
450
|
const index = tabs.length;
|
|
454
|
-
|
|
455
|
-
const tab = document.createElement('li');
|
|
451
|
+
const tab = DOMUtilities.Create('li');
|
|
456
452
|
tab.setAttribute('tabindex', '0');
|
|
457
453
|
|
|
458
454
|
// tab.classList.add('tab');
|
package/treb-utils/src/index.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
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
|
+
import { DOMUtilities } from 'treb-base-types';
|
|
23
|
+
|
|
22
24
|
/**
|
|
23
25
|
* support for resizable node, drag handle, drag rect, mask
|
|
24
26
|
* FIXME: make this composable (decorator?)
|
|
@@ -56,16 +58,14 @@ export class Resizable {
|
|
|
56
58
|
layout_reference?: HTMLElement;
|
|
57
59
|
}): void {
|
|
58
60
|
|
|
59
|
-
const resize_handle =
|
|
60
|
-
resize_handle.classList.add('treb-embed-resize-handle');
|
|
61
|
+
const resize_handle = DOMUtilities.Div('treb-embed-resize-handle');
|
|
61
62
|
|
|
62
63
|
(options.layout_reference || options.container).appendChild(resize_handle);
|
|
63
64
|
|
|
64
65
|
if (!Resizable.resize_mask) {
|
|
65
66
|
let mask = document.querySelector('.treb-embed-mouse-mask');
|
|
66
67
|
if (!mask) {
|
|
67
|
-
mask =
|
|
68
|
-
mask.classList.add('treb-embed-mouse-mask');
|
|
68
|
+
mask = DOMUtilities.Div('treb-embed-mouse-mask');
|
|
69
69
|
document.body.appendChild(mask);
|
|
70
70
|
}
|
|
71
71
|
Resizable.resize_mask = mask as HTMLElement;
|
|
@@ -74,8 +74,7 @@ export class Resizable {
|
|
|
74
74
|
if (!Resizable.resize_rect) {
|
|
75
75
|
let rect = document.querySelector('.treb-embed-resize-rect');
|
|
76
76
|
if (!rect) {
|
|
77
|
-
rect =
|
|
78
|
-
rect.classList.add('treb-embed-resize-rect');
|
|
77
|
+
rect = DOMUtilities.Div('treb-embed-resize-rect');
|
|
79
78
|
Resizable.resize_mask.appendChild(rect);
|
|
80
79
|
}
|
|
81
80
|
Resizable.resize_rect = rect as HTMLElement;
|
|
@@ -1,70 +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
|
-
export interface NodeModel {[index: string]: HTMLElement}
|
|
23
|
-
|
|
24
|
-
const ParseTail = (node: HTMLElement, scope: string, model: NodeModel): void => {
|
|
25
|
-
[].forEach.call(node.children, (child: HTMLElement) => {
|
|
26
|
-
if (child.id) {
|
|
27
|
-
model[child.id] = child;
|
|
28
|
-
child.id = `${scope}-${child.id}`;
|
|
29
|
-
}
|
|
30
|
-
if (child.children && child.children.length) {
|
|
31
|
-
ParseTail(child, scope, model);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const ParseTemplate = (template: string, container?: HTMLElement|string) => {
|
|
37
|
-
|
|
38
|
-
const scope = Math.random().toString(36).substring(2, 15);
|
|
39
|
-
const temp = document.createElement('div');
|
|
40
|
-
temp.innerHTML = template;
|
|
41
|
-
|
|
42
|
-
const model: NodeModel = {};
|
|
43
|
-
ParseTail(temp, scope, model);
|
|
44
|
-
|
|
45
|
-
if (typeof container === 'string') {
|
|
46
|
-
container = document.querySelector(container) as HTMLElement;
|
|
47
|
-
}
|
|
48
|
-
if (container) {
|
|
49
|
-
const nodes = [].map.call(temp.childNodes, child => child);
|
|
50
|
-
for (const child of nodes) { container.appendChild(child as Node); }
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return model;
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export const composite = (strings: TemplateStringsArray, ...args: any[]): string => {
|
|
58
|
-
const output: string[] = [];
|
|
59
|
-
for (let i = 0; i < strings.length; i++) {
|
|
60
|
-
output.push(strings[i]);
|
|
61
|
-
if (args[i]) { output.push(args[i].toString()); }
|
|
62
|
-
}
|
|
63
|
-
return output.join('');
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const tmpl = (strings: TemplateStringsArray, ...args: any[]): NodeModel => {
|
|
67
|
-
return ParseTemplate(composite(strings, ...args));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export const css = composite;
|