@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.
Files changed (32) hide show
  1. package/dist/treb-spreadsheet.mjs +9 -9
  2. package/dist/treb.d.ts +8 -6
  3. package/package.json +1 -1
  4. package/{treb-grid/src/util/dom_utilities.ts → treb-base-types/src/dom-utilities.ts} +29 -20
  5. package/treb-base-types/src/index.ts +1 -0
  6. package/treb-base-types/src/theme.ts +3 -5
  7. package/treb-embed/src/custom-element/global.d.ts +3 -1
  8. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +13 -19
  9. package/treb-embed/src/embedded-spreadsheet.ts +67 -93
  10. package/treb-embed/src/spinner.ts +3 -3
  11. package/treb-embed/style/layout.scss +1 -1
  12. package/treb-embed/style/overlay-editor.scss +9 -0
  13. package/treb-export/src/drawing2/chart2.ts +11 -2
  14. package/treb-export/src/export2.ts +14 -4
  15. package/treb-export/src/workbook-style2.ts +3 -2
  16. package/treb-grid/src/editors/autocomplete.ts +28 -24
  17. package/treb-grid/src/editors/editor.ts +32 -4
  18. package/treb-grid/src/editors/formula_bar.ts +1 -1
  19. package/treb-grid/src/layout/base_layout.ts +11 -16
  20. package/treb-grid/src/layout/grid_layout.ts +17 -28
  21. package/treb-grid/src/render/selection-renderer.ts +2 -3
  22. package/treb-grid/src/render/svg_header_overlay.ts +4 -11
  23. package/treb-grid/src/render/svg_selection_block.ts +27 -34
  24. package/treb-grid/src/render/tile_renderer.ts +6 -5
  25. package/treb-grid/src/types/grid.ts +32 -41
  26. package/treb-grid/src/types/grid_base.ts +2 -0
  27. package/treb-grid/src/types/scale-control.ts +2 -2
  28. package/treb-grid/src/types/sheet.ts +2 -2
  29. package/treb-grid/src/types/tab_bar.ts +4 -8
  30. package/treb-utils/src/index.ts +0 -1
  31. package/treb-utils/src/resizable.ts +26 -27
  32. package/treb-utils/src/template.ts +0 -70
@@ -19,7 +19,7 @@
19
19
  *
20
20
  */
21
21
 
22
- import { DOMUtilities as DOM } from '../util/dom_utilities';
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.CreateDiv('treb-slider-container', /* div */ container);
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 = document.createElement('img');
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 = document.createElement('span');
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 = document.createElement('span');
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
- // const tab = document.createElement('div');
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');
@@ -28,4 +28,3 @@ export * from './measurement';
28
28
  export * from './serialize_html';
29
29
  export * from './validate_uri';
30
30
  export * from './scale';
31
- export * from './template';
@@ -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 = document.createElement('div');
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 = document.createElement('div');
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 = document.createElement('div');
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;