@trebco/treb 25.7.3 → 25.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trebco/treb",
3
- "version": "25.7.3",
3
+ "version": "25.7.7",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "homepage": "https://treb.app",
6
6
  "repository": {
@@ -66,6 +66,9 @@ export interface ImportedSheetData {
66
66
  // new
67
67
  annotations?: AnchoredAnnotation[];
68
68
 
69
+ // new
70
+ outline?: number[];
71
+
69
72
  hidden?: boolean;
70
73
 
71
74
  }
@@ -94,16 +94,16 @@
94
94
  add/remove tab should both be buttons, or at least have tabindexes
95
95
  -->
96
96
 
97
- <!-- why is this a div (...and see below) -->
98
- <div class="treb-delete-tab" title="Delete current sheet" data-command="delete-tab" data-conditional="delete-tab">
99
- <svg viewbox='0 0 16 16'><path d='M4,4 L12,12 M12,4 L4,12'/></svg>
100
- </div>
97
+ <!-- converted to button, more appropriate -->
98
+ <button class="treb-delete-tab" title="Delete current sheet" data-command="delete-tab" data-conditional="delete-tab">
99
+ <svg tabindex="-1" viewbox='0 0 16 16'><path d='M4,4 L12,12 M12,4 L4,12'/></svg>
100
+ </button>
101
101
 
102
102
  <!-- list of tabs for sheets -->
103
103
  <ol class="treb-spreadsheet-tabs" role="tablist"></ol>
104
104
 
105
- <!-- ...and why is this an anchor? -->
106
- <a class="treb-add-tab" data-command="add-tab" data-conditional="add-tab" title="Add sheet">+</a>
105
+ <!-- converted to button, more appropriate -->
106
+ <button class="treb-add-tab" data-command="add-tab" data-conditional="add-tab" title="Add sheet">+</button>
107
107
 
108
108
  <!--
109
109
  we removed the junk node with "flex grow" to split the layout, in
@@ -282,7 +282,9 @@ export class SpreadsheetConstructor {
282
282
  if (element instanceof HTMLScriptElement) {
283
283
  if (element.type === 'application/json') {
284
284
  const name = element.getAttribute('name') || '';
285
- if (name === inline_name) {
285
+
286
+ // add special case for aggressive clients/wrappers
287
+ if (name === inline_name || !name && inline_name === 'true') {
286
288
  const content = element.textContent;
287
289
  if (content) {
288
290
  try {
@@ -228,6 +228,9 @@ export class EmbeddedSpreadsheet {
228
228
  /** @internal */
229
229
  public static enable_formatter = false;
230
230
 
231
+ /** @internal */
232
+ public static one_time_warnings: Record<string, boolean> = {};
233
+
231
234
  /**
232
235
  * this flag will be set on LoadDocument. the intent is to be able to
233
236
  * know if you have loaded a network document, which may happen before you
@@ -865,7 +868,10 @@ export class EmbeddedSpreadsheet {
865
868
 
866
869
  }
867
870
  else {
868
- console.info('not initializing grid; don\'t call UI functions');
871
+ if (!EmbeddedSpreadsheet.one_time_warnings.headless) {
872
+ EmbeddedSpreadsheet.one_time_warnings.headless = true;
873
+ console.info('not initializing grid; don\'t call UI functions');
874
+ }
869
875
  this.grid.headless = true; // ensure
870
876
  }
871
877
 
@@ -33,7 +33,7 @@
33
33
  .treb-spreadsheet-tabs {
34
34
  display: flex;
35
35
  flex-direction: row;
36
- z-index: 1;
36
+ z-index: 2;
37
37
  max-width: 100%;
38
38
  height: 2.2em;
39
39
  color: var(--treb-ui-color, inherit);
@@ -53,7 +53,8 @@
53
53
  }
54
54
 
55
55
  & .treb-spreadsheet-tabs>li,
56
- & .treb-add-tab {
56
+ & .treb-add-tab,
57
+ & .treb-delete-tab {
57
58
 
58
59
  font-size: inherit;
59
60
  padding: .25em .75em;
@@ -75,6 +76,29 @@
75
76
  z-index: 1;
76
77
  margin-right: -2px;
77
78
 
79
+ &:active, &:focus {
80
+ z-index: 3;
81
+ }
82
+
83
+ }
84
+
85
+ /** don't overflow/ellipsis the add tab button */
86
+
87
+ /**
88
+ * for ellipsis to work, it seems like it has to be inside
89
+ * a span in the tab. since we are not using it atm I removed
90
+ * that span, but if we want ellpisis it will need to come back.
91
+ */
92
+
93
+ & .treb-spreadsheet-tabs>li {
94
+
95
+ white-space: nowrap;
96
+ overflow-x: hidden;
97
+
98
+ &[selected] {
99
+ z-index: 2;
100
+ }
101
+
78
102
  }
79
103
 
80
104
  & .treb-scale-control {
@@ -143,6 +167,13 @@
143
167
 
144
168
  & .treb-delete-tab {
145
169
 
170
+ // was a div, now a button, so needs some adjustments
171
+ // why double focus?
172
+
173
+ border: none;
174
+ background: transparent;
175
+ color: currentColor;
176
+
146
177
  font-size: inherit;
147
178
  padding: .25em .75em;
148
179
  cursor: default;
@@ -177,6 +208,10 @@
177
208
  stroke-linecap: round;
178
209
  }
179
210
 
211
+ &:active, &:focus {
212
+ z-index: 3;
213
+ }
214
+
180
215
  }
181
216
 
182
217
  .treb-stats-panel {
@@ -208,24 +243,6 @@
208
243
  }
209
244
  }
210
245
 
211
- /** don't overflow/ellipsis the add tab button */
212
-
213
- /**
214
- * for ellipsis to work, it seems like it has to be inside
215
- * a span in the tab. since we are not using it atm I removed
216
- * that span, but if we want ellpisis it will need to come back.
217
- */
218
-
219
- & .treb-spreadsheet-tabs>li {
220
-
221
- white-space: nowrap;
222
- overflow-x: hidden;
223
-
224
- &[selected] {
225
- z-index: 2;
226
- }
227
-
228
- }
229
246
 
230
247
  }
231
248
 
@@ -478,6 +478,7 @@ export class Importer {
478
478
  // data (and row heights)
479
479
 
480
480
  const row_heights: number[] = [];
481
+ const outline: number[] = [];
481
482
 
482
483
  const rows = FindAll('worksheet/sheetData/row');
483
484
 
@@ -491,6 +492,12 @@ export class Importer {
491
492
  height = Math.round(num * 4 / 3); // seems to be the excel unit -> pixel ratio
492
493
  }
493
494
  }
495
+ if (row.a$?.outlineLevel) {
496
+ const num = Number(row.a$.outlineLevel);
497
+ if (!isNaN(num)) {
498
+ outline[row_index - 1] = num;
499
+ }
500
+ }
494
501
 
495
502
  // if there's a height which is not === default height, but
496
503
  // the customHeight attribute is not set, then it's been auto-sized.
@@ -867,6 +874,10 @@ export class Importer {
867
874
  styles: this.workbook?.style_cache?.CellXfToStyles() || [],
868
875
  };
869
876
 
877
+ if (outline.length) {
878
+ result.outline = outline;
879
+ }
880
+
870
881
  if (sheet.visible_state === VisibleState.hidden || sheet.visible_state === VisibleState.very_hidden) {
871
882
  result.hidden = true;
872
883
  }
@@ -354,7 +354,7 @@ export abstract class BaseLayout {
354
354
 
355
355
  this.sort_button = DOMUtilities.Create<HTMLButtonElement>(
356
356
  'button',
357
- 'treb-sort-button', undefined, undefined, { title: 'Sort table'});
357
+ 'treb-sort-button', undefined, undefined, { title: 'Sort table', tabindex: '-1'});
358
358
 
359
359
  this.HideNote();
360
360
 
@@ -451,6 +451,7 @@ export abstract class BaseLayout {
451
451
  public HideTableSortButton() {
452
452
  this.sort_button.style.opacity = '0';
453
453
  this.sort_button.style.pointerEvents = 'none';
454
+ this.sort_button.setAttribute('tabindex', '-1');
454
455
  }
455
456
 
456
457
  public ShowTableSortButton(table: Table, column: number, address: ICellAddress): void {
@@ -469,6 +470,7 @@ export abstract class BaseLayout {
469
470
  }
470
471
  }
471
472
 
473
+ this.sort_button.setAttribute('tabindex', '0 ');
472
474
  this.sort_button.style.opacity = '1';
473
475
  this.sort_button.style.pointerEvents = 'initial';
474
476
  this.sort_button.classList.remove('asc', 'desc');
@@ -81,7 +81,13 @@ export interface ViewData {
81
81
 
82
82
  export interface ImageAnnotationData {
83
83
  src: string;
84
- scale: string;
84
+
85
+ /**
86
+ * @privateRemarks
87
+ * why is this a string?
88
+ */
89
+ scale: string;
90
+
85
91
  original_size: {
86
92
  width: number;
87
93
  height: number;
@@ -2053,6 +2053,12 @@ export class Grid extends GridBase {
2053
2053
 
2054
2054
  }
2055
2055
 
2056
+ protected RenameSheetInternal(target: Sheet, name: string) {
2057
+ super.RenameSheetInternal(target, name);
2058
+ this.tab_bar?.Update();
2059
+
2060
+ }
2061
+
2056
2062
  /**
2057
2063
  * translate function from common (english) -> local language. this could
2058
2064
  * be inlined (assuming it's only called in one place), but we are breaking
@@ -148,6 +148,13 @@ export class Sheet {
148
148
  return this._image;
149
149
  }
150
150
 
151
+ /**
152
+ * @internal
153
+ *
154
+ * testing, not serialized atm
155
+ */
156
+ public outline: number[] | undefined;
157
+
151
158
  /** internal ID */
152
159
  // tslint:disable-next-line: variable-name
153
160
  private id_: number;
@@ -2686,6 +2693,10 @@ export class Sheet {
2686
2693
 
2687
2694
  const styles = data.styles;
2688
2695
 
2696
+ if (data.outline) {
2697
+ this.outline = data.outline;
2698
+ }
2699
+
2689
2700
  // adding sheet style...
2690
2701
 
2691
2702
  // 0 is implicitly just a general style
@@ -453,6 +453,7 @@ export class TabBar extends EventSource<TabEvent> {
453
453
  const index = tabs.length;
454
454
  // const tab = document.createElement('div');
455
455
  const tab = document.createElement('li');
456
+ tab.setAttribute('tabindex', '0');
456
457
 
457
458
  // tab.classList.add('tab');
458
459
  tab.style.order = (index * 2).toString();