@trebco/treb 25.6.4 → 25.7.3
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 +5 -5
- package/dist/treb.d.ts +21 -11
- package/package.json +2 -2
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1 -1
- package/treb-embed/src/embedded-spreadsheet.ts +26 -20
- package/treb-embed/src/options.ts +20 -10
- package/treb-embed/style/dark-theme.scss +22 -4
- package/treb-embed/style/layout.scss +7 -0
- package/treb-grid/src/types/grid_options.ts +23 -23
package/dist/treb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! API v25.
|
|
1
|
+
/*! API v25.7. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* add our tag to the map
|
|
@@ -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;
|
|
@@ -112,10 +117,15 @@ export interface EmbeddedSpreadsheetOptions {
|
|
|
112
117
|
/** show tab bar (multi sheet) */
|
|
113
118
|
tab_bar?: boolean | 'auto';
|
|
114
119
|
|
|
115
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* allow add/delete tab
|
|
122
|
+
*/
|
|
116
123
|
add_tab?: boolean;
|
|
117
124
|
|
|
118
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* show delete tab
|
|
127
|
+
* @deprecated - implied by add_tab
|
|
128
|
+
*/
|
|
119
129
|
delete_tab?: boolean;
|
|
120
130
|
|
|
121
131
|
/** set a reference in global (self) */
|
|
@@ -526,7 +536,7 @@ export declare class EmbeddedSpreadsheet {
|
|
|
526
536
|
UnmergeCells(range?: RangeReference): void;
|
|
527
537
|
|
|
528
538
|
/**
|
|
529
|
-
* revert to the network version of this document, if both `
|
|
539
|
+
* revert to the network version of this document, if both `local_storage`
|
|
530
540
|
* and `network_document` are set.
|
|
531
541
|
*/
|
|
532
542
|
Revert(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trebco/treb",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.7.3",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"homepage": "https://treb.app",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"@typescript-eslint/eslint-plugin": "^5.30.4",
|
|
17
17
|
"@typescript-eslint/parser": "^5.30.4",
|
|
18
18
|
"archiver": "^5.3.0",
|
|
19
|
-
"cssnano": "^
|
|
19
|
+
"cssnano": "^6.0.0",
|
|
20
20
|
"esbuild": "^0.17.11",
|
|
21
21
|
"eslint": "^8.19.0",
|
|
22
22
|
"fast-xml-parser": "^4.0.7",
|
|
@@ -423,7 +423,7 @@ export class SpreadsheetConstructor {
|
|
|
423
423
|
// add-tab and delete-tab will still work for the menu
|
|
424
424
|
|
|
425
425
|
'add-tab': !!sheet.options.add_tab,
|
|
426
|
-
'delete-tab': !!sheet.options.delete_tab,
|
|
426
|
+
'delete-tab': (!!sheet.options.delete_tab || !!sheet.options.add_tab),
|
|
427
427
|
|
|
428
428
|
// we actually don't want to remove stats if it's not in use, because
|
|
429
429
|
// we need it for layout
|
|
@@ -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
|
}
|
|
@@ -571,7 +577,7 @@ export class EmbeddedSpreadsheet {
|
|
|
571
577
|
expand_formula_button: this.options.expand_formula_button,
|
|
572
578
|
tab_bar: this.options.tab_bar,
|
|
573
579
|
add_tab: this.options.add_tab,
|
|
574
|
-
delete_tab: this.options.delete_tab,
|
|
580
|
+
// delete_tab: this.options.delete_tab,
|
|
575
581
|
expand: this.options.expand,
|
|
576
582
|
|
|
577
583
|
};
|
|
@@ -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;
|
|
@@ -132,10 +137,15 @@ export interface EmbeddedSpreadsheetOptions {
|
|
|
132
137
|
/** show tab bar (multi sheet) */
|
|
133
138
|
tab_bar?: boolean|'auto';
|
|
134
139
|
|
|
135
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* allow add/delete tab
|
|
142
|
+
*/
|
|
136
143
|
add_tab?: boolean;
|
|
137
144
|
|
|
138
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* show delete tab
|
|
147
|
+
* @deprecated - implied by add_tab
|
|
148
|
+
*/
|
|
139
149
|
delete_tab?: boolean;
|
|
140
150
|
|
|
141
151
|
/** set a reference in global (self) */
|
|
@@ -287,7 +297,7 @@ export const DefaultOptions: EmbeddedSpreadsheetOptions = {
|
|
|
287
297
|
dnd: false,
|
|
288
298
|
add_tab: false,
|
|
289
299
|
expand_formula_button: false,
|
|
290
|
-
delete_tab: false,
|
|
300
|
+
// delete_tab: false,
|
|
291
301
|
|
|
292
302
|
// changing default value for expand -> false, it might be
|
|
293
303
|
// useful to disable it but the common expectation is that
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
--treb-chart-grid-color: #976;
|
|
36
36
|
--treb-chart-text-color: #fff;
|
|
37
37
|
--treb-dialog-background: #000;
|
|
38
|
-
--treb-dialog-border-color: #fff;
|
|
39
38
|
--treb-dialog-color: #fff;
|
|
40
39
|
--treb-dropdown-background: #000;
|
|
41
40
|
--treb-dropdown-border-color: #fff;
|
|
@@ -51,14 +50,14 @@
|
|
|
51
50
|
--treb-grid-header-background: #444;
|
|
52
51
|
--treb-grid-header-grid-color: #000;
|
|
53
52
|
--treb-note-background: #333;
|
|
54
|
-
--treb-note-border-color: #
|
|
53
|
+
--treb-note-border-color: #aaa;
|
|
55
54
|
--treb-note-color: #fff;
|
|
56
55
|
--treb-note-marker-color: pink;
|
|
57
56
|
--treb-resize-tooltip-background: #fff;
|
|
58
57
|
--treb-resize-tooltip-color: #000;
|
|
59
58
|
--treb-scale-slider-accent-color: #fff;
|
|
60
59
|
--treb-scale-slider-background: #333;
|
|
61
|
-
--treb-scale-slider-border-color: #
|
|
60
|
+
--treb-scale-slider-border-color: #aaa;
|
|
62
61
|
--treb-selection-color: yellow;
|
|
63
62
|
--treb-selection-fill-opacity: .2;
|
|
64
63
|
--treb-sidebar-button-background: #000;
|
|
@@ -72,7 +71,6 @@
|
|
|
72
71
|
--treb-toolbar-active-button-background: #555;
|
|
73
72
|
--treb-toolbar-button-background: #000;
|
|
74
73
|
--treb-toolbar-hover-button-background: #444;
|
|
75
|
-
--treb-ui-border-color: #666;
|
|
76
74
|
--treb-ui-color: #fff;
|
|
77
75
|
--treb-table-header-background: #334; // DarkSlateGray;
|
|
78
76
|
--treb-table-odd-background: #122;
|
|
@@ -92,6 +90,26 @@
|
|
|
92
90
|
--treb-resize-handle-color: lightblue;
|
|
93
91
|
--treb-resize-frame-color: lightblue;
|
|
94
92
|
--treb-formula-bar-locked-background: #234;
|
|
93
|
+
|
|
94
|
+
// updates
|
|
95
|
+
|
|
96
|
+
--treb-grid-background: rgb(30,30,30);
|
|
97
|
+
--treb-grid-header-background: rgb(86,86,86);
|
|
98
|
+
--treb-grid-header-color: rgb(221,221,221);
|
|
99
|
+
--treb-tab-bar-active-tab-background: field;
|
|
100
|
+
--treb-tab-bar-tab-background: transparent;
|
|
101
|
+
--treb-tab-bar-tab-border-color: #444;
|
|
102
|
+
--treb-ui-border-color: #aaa;
|
|
103
|
+
|
|
104
|
+
// we should split toolbar buttons and menus
|
|
105
|
+
|
|
106
|
+
--treb-toolbar-button-background: rgb(86,86,86);
|
|
107
|
+
--treb-toolbar-button-background: rgb(33,33,33);
|
|
108
|
+
--treb-toolbar-border-color: rgb(67,67,67);
|
|
109
|
+
|
|
110
|
+
--treb-toolbar-color: rgb(221,221,221);
|
|
111
|
+
|
|
112
|
+
|
|
95
113
|
}
|
|
96
114
|
|
|
97
115
|
.treb-dark-theme {
|
|
@@ -53,6 +53,11 @@
|
|
|
53
53
|
|
|
54
54
|
text-align: start;
|
|
55
55
|
|
|
56
|
+
// set a default font, as well. we used to inherit but that
|
|
57
|
+
// does not necessarily make sense.
|
|
58
|
+
|
|
59
|
+
font-family: var(--treb-default-font, system-ui, $font-stack);
|
|
60
|
+
|
|
56
61
|
div, button, input, ul, ol, li, a, textarea {
|
|
57
62
|
|
|
58
63
|
// maybe this is being too aggressive. we could be a little
|
|
@@ -60,7 +65,9 @@
|
|
|
60
65
|
// unexpected side effects.
|
|
61
66
|
|
|
62
67
|
all: revert;
|
|
68
|
+
|
|
63
69
|
box-sizing: border-box;
|
|
70
|
+
font-family: var(--treb-default-font, system-ui, $font-stack);
|
|
64
71
|
|
|
65
72
|
}
|
|
66
73
|
|
|
@@ -1,24 +1,24 @@
|
|
|
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
22
|
import type { CellValue } from 'treb-base-types';
|
|
23
23
|
import type { StatsEntry } from './tab_bar';
|
|
24
24
|
|
|
@@ -57,8 +57,8 @@ export interface GridOptions {
|
|
|
57
57
|
/** allow add tab */
|
|
58
58
|
add_tab?: boolean;
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
delete_tab?: boolean;
|
|
60
|
+
/* * show delete tab in the tab bar */
|
|
61
|
+
// delete_tab?: boolean;
|
|
62
62
|
|
|
63
63
|
/** show the "insert function" button. requires formula bar. */
|
|
64
64
|
insert_function_button?: boolean;
|