@trebco/treb 25.7.1 → 25.7.5
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 +7 -7
- package/dist/treb.d.ts +13 -8
- package/package.json +1 -1
- package/treb-embed/markup/layout.html +6 -6
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +3 -1
- package/treb-embed/src/embedded-spreadsheet.ts +25 -19
- package/treb-embed/src/options.ts +12 -7
- package/treb-embed/style/tab-bar.scss +37 -20
- package/treb-grid/src/layout/base_layout.ts +3 -1
- package/treb-grid/src/types/grid.ts +7 -0
- package/treb-grid/src/types/tab_bar.ts +1 -0
package/dist/treb.d.ts
CHANGED
|
@@ -50,16 +50,21 @@ export interface EmbeddedSpreadsheetOptions {
|
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
52
|
* key in localStorage for persisting document.
|
|
53
|
+
* @deprecated - this was renamed to local_storage for clarity. if both
|
|
54
|
+
* storage_key and local_storage are set we will use the value in local_storage.
|
|
55
|
+
*/
|
|
56
|
+
storage_key?: string | boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* persist user changes to document in browser localStorage.
|
|
53
60
|
*
|
|
54
|
-
*
|
|
55
|
-
* generate a storage key based on the page URI.
|
|
61
|
+
* if set to a string, the value is used as the storage key.
|
|
56
62
|
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* overwrite each other).
|
|
63
|
+
* if set to `true`, we will generate a storage key based on the page URI.
|
|
64
|
+
* don't do that if you have multiple spreadsheets on a single page, or
|
|
65
|
+
* they will overwrite each other.
|
|
61
66
|
*/
|
|
62
|
-
|
|
67
|
+
local_storage?: string | boolean;
|
|
63
68
|
|
|
64
69
|
/** don't load immediately (?) */
|
|
65
70
|
toll_initial_load?: boolean;
|
|
@@ -531,7 +536,7 @@ export declare class EmbeddedSpreadsheet {
|
|
|
531
536
|
UnmergeCells(range?: RangeReference): void;
|
|
532
537
|
|
|
533
538
|
/**
|
|
534
|
-
* revert to the network version of this document, if both `
|
|
539
|
+
* revert to the network version of this document, if both `local_storage`
|
|
535
540
|
* and `network_document` are set.
|
|
536
541
|
*/
|
|
537
542
|
Revert(): void;
|
package/package.json
CHANGED
|
@@ -94,16 +94,16 @@
|
|
|
94
94
|
add/remove tab should both be buttons, or at least have tabindexes
|
|
95
95
|
-->
|
|
96
96
|
|
|
97
|
-
<!--
|
|
98
|
-
<
|
|
99
|
-
<svg viewbox='0 0 16 16'><path d='M4,4 L12,12 M12,4 L4,12'/></svg>
|
|
100
|
-
</
|
|
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
|
-
<!--
|
|
106
|
-
<
|
|
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
|
-
|
|
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 {
|
|
@@ -280,7 +280,7 @@ export class EmbeddedSpreadsheet {
|
|
|
280
280
|
*
|
|
281
281
|
* @internal
|
|
282
282
|
*/
|
|
283
|
-
public options: EmbeddedSpreadsheetOptions & {
|
|
283
|
+
public options: EmbeddedSpreadsheetOptions & { local_storage: string|undefined };
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
286
|
* @internal
|
|
@@ -491,10 +491,16 @@ export class EmbeddedSpreadsheet {
|
|
|
491
491
|
|
|
492
492
|
// super();
|
|
493
493
|
|
|
494
|
+
// we renamed this option, default to the new name
|
|
495
|
+
|
|
496
|
+
if (options.storage_key && !options.local_storage) {
|
|
497
|
+
options.local_storage = options.storage_key;
|
|
498
|
+
}
|
|
499
|
+
|
|
494
500
|
// consolidate options w/ defaults. note that this does not
|
|
495
501
|
// support nested options, for that you need a proper merge
|
|
496
502
|
|
|
497
|
-
this.options = { ...DefaultOptions, ...options,
|
|
503
|
+
this.options = { ...DefaultOptions, ...options, local_storage: this.ResolveStorageKey(options.local_storage, 'document') };
|
|
498
504
|
|
|
499
505
|
if (typeof this.options.imaginary_value === 'string') {
|
|
500
506
|
NumberFormat.imaginary_character = this.options.imaginary_value;
|
|
@@ -521,8 +527,8 @@ export class EmbeddedSpreadsheet {
|
|
|
521
527
|
// don't load if we're a split view. we can also skip the
|
|
522
528
|
// unload event, as parent will already have that set
|
|
523
529
|
|
|
524
|
-
if (this.options.
|
|
525
|
-
data = localStorage.getItem(this.options.
|
|
530
|
+
if (this.options.local_storage && !this.options.toll_initial_load && !options.model) {
|
|
531
|
+
data = localStorage.getItem(this.options.local_storage) || undefined;
|
|
526
532
|
if (data) {
|
|
527
533
|
source = LoadSource.LOCAL_STORAGE;
|
|
528
534
|
}
|
|
@@ -539,10 +545,10 @@ export class EmbeddedSpreadsheet {
|
|
|
539
545
|
// this one should not be done for a split view, but we should still
|
|
540
546
|
// do it if the toll flag is set, and storage key is set.
|
|
541
547
|
|
|
542
|
-
if (this.options.
|
|
548
|
+
if (this.options.local_storage && !options.model ) {
|
|
543
549
|
window.addEventListener('beforeunload', () => {
|
|
544
|
-
if (this.options.
|
|
545
|
-
this.SaveLocalStorage(this.options.
|
|
550
|
+
if (this.options.local_storage) {
|
|
551
|
+
this.SaveLocalStorage(this.options.local_storage);
|
|
546
552
|
}
|
|
547
553
|
});
|
|
548
554
|
}
|
|
@@ -927,9 +933,9 @@ export class EmbeddedSpreadsheet {
|
|
|
927
933
|
}
|
|
928
934
|
|
|
929
935
|
// don't load if we are a split view
|
|
930
|
-
// UPDATE: don't load if we have a
|
|
931
|
-
// over the old
|
|
932
|
-
// otherwise. what would
|
|
936
|
+
// UPDATE: don't load if we have a local_storage document. this is taking
|
|
937
|
+
// over the old alternate_document flow, because it doesn't make any sense
|
|
938
|
+
// otherwise. what would local_storage with document_name mean otherwise?
|
|
933
939
|
|
|
934
940
|
if (network_document && !options.model && !data) {
|
|
935
941
|
this.LoadNetworkDocument(network_document, this.options);
|
|
@@ -2319,16 +2325,16 @@ export class EmbeddedSpreadsheet {
|
|
|
2319
2325
|
}
|
|
2320
2326
|
|
|
2321
2327
|
/**
|
|
2322
|
-
* revert to the network version of this document, if both `
|
|
2328
|
+
* revert to the network version of this document, if both `local_storage`
|
|
2323
2329
|
* and `network_document` are set.
|
|
2324
2330
|
*/
|
|
2325
2331
|
public Revert(): void {
|
|
2326
2332
|
|
|
2327
2333
|
if (this.options.inline_document) {
|
|
2328
2334
|
this.LoadDocument(this.options.inline_document);
|
|
2329
|
-
if (this.options.
|
|
2335
|
+
if (this.options.local_storage) {
|
|
2330
2336
|
this.SaveLocalStorage('reverted_backup');
|
|
2331
|
-
localStorage.removeItem(this.options.
|
|
2337
|
+
localStorage.removeItem(this.options.local_storage);
|
|
2332
2338
|
}
|
|
2333
2339
|
return;
|
|
2334
2340
|
}
|
|
@@ -2351,9 +2357,9 @@ export class EmbeddedSpreadsheet {
|
|
|
2351
2357
|
// flush storage? what about mistakes? maybe we should
|
|
2352
2358
|
// back it up somewhere? (...)
|
|
2353
2359
|
|
|
2354
|
-
if (this.options.
|
|
2360
|
+
if (this.options.local_storage) {
|
|
2355
2361
|
this.SaveLocalStorage('reverted_backup');
|
|
2356
|
-
localStorage.removeItem(this.options.
|
|
2362
|
+
localStorage.removeItem(this.options.local_storage);
|
|
2357
2363
|
}
|
|
2358
2364
|
|
|
2359
2365
|
return;
|
|
@@ -2514,7 +2520,7 @@ export class EmbeddedSpreadsheet {
|
|
|
2514
2520
|
// FIXME: this is weird, why do we have a method for this, why
|
|
2515
2521
|
// does it modify the key, and so on
|
|
2516
2522
|
|
|
2517
|
-
this.options.
|
|
2523
|
+
this.options.local_storage = key;
|
|
2518
2524
|
const json = localStorage.getItem(key);
|
|
2519
2525
|
|
|
2520
2526
|
if (json) {
|
|
@@ -3243,7 +3249,7 @@ export class EmbeddedSpreadsheet {
|
|
|
3243
3249
|
* @param key optional storage key. if omitted, the method will use
|
|
3244
3250
|
* the key from local options (set at create time).
|
|
3245
3251
|
*/
|
|
3246
|
-
public SaveLocalStorage(key = this.options.
|
|
3252
|
+
public SaveLocalStorage(key = this.options.local_storage): void {
|
|
3247
3253
|
|
|
3248
3254
|
// API v1 OK
|
|
3249
3255
|
|
|
@@ -4761,8 +4767,8 @@ export class EmbeddedSpreadsheet {
|
|
|
4761
4767
|
|
|
4762
4768
|
// console.info(json);
|
|
4763
4769
|
|
|
4764
|
-
if (this.options.
|
|
4765
|
-
localStorage.setItem(this.options.
|
|
4770
|
+
if (this.options.local_storage) {
|
|
4771
|
+
localStorage.setItem(this.options.local_storage, json);
|
|
4766
4772
|
}
|
|
4767
4773
|
if (this.options.undo) {
|
|
4768
4774
|
this.PushUndo(json, undo_selection, false);
|
|
@@ -60,16 +60,21 @@ export interface EmbeddedSpreadsheetOptions {
|
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* key in localStorage for persisting document.
|
|
63
|
+
* @deprecated - this was renamed to local_storage for clarity. if both
|
|
64
|
+
* storage_key and local_storage are set we will use the value in local_storage.
|
|
65
|
+
*/
|
|
66
|
+
storage_key?: string|boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* persist user changes to document in browser localStorage.
|
|
63
70
|
*
|
|
64
|
-
*
|
|
65
|
-
* generate a storage key based on the page URI.
|
|
71
|
+
* if set to a string, the value is used as the storage key.
|
|
66
72
|
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* overwrite each other).
|
|
73
|
+
* if set to `true`, we will generate a storage key based on the page URI.
|
|
74
|
+
* don't do that if you have multiple spreadsheets on a single page, or
|
|
75
|
+
* they will overwrite each other.
|
|
71
76
|
*/
|
|
72
|
-
|
|
77
|
+
local_storage?: string|boolean;
|
|
73
78
|
|
|
74
79
|
/** don't load immediately (?) */
|
|
75
80
|
toll_initial_load?: boolean;
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
.treb-spreadsheet-tabs {
|
|
34
34
|
display: flex;
|
|
35
35
|
flex-direction: row;
|
|
36
|
-
z-index:
|
|
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
|
|
|
@@ -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');
|
|
@@ -2053,6 +2053,13 @@ export class Grid extends GridBase {
|
|
|
2053
2053
|
|
|
2054
2054
|
}
|
|
2055
2055
|
|
|
2056
|
+
protected RenameSheetInternal(target: Sheet, name: string) {
|
|
2057
|
+
console.info("RIS");
|
|
2058
|
+
super.RenameSheetInternal(target, name);
|
|
2059
|
+
this.tab_bar?.Update();
|
|
2060
|
+
|
|
2061
|
+
}
|
|
2062
|
+
|
|
2056
2063
|
/**
|
|
2057
2064
|
* translate function from common (english) -> local language. this could
|
|
2058
2065
|
* be inlined (assuming it's only called in one place), but we are breaking
|
|
@@ -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();
|