@trebco/treb 28.3.6 → 28.5.1
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-light.mjs +9 -9
- package/dist/treb-spreadsheet.mjs +10 -10
- package/dist/treb.d.ts +14 -1
- package/package.json +1 -1
- package/treb-embed/markup/layout.html +4 -2
- package/treb-embed/src/embedded-spreadsheet.ts +27 -0
- package/treb-embed/style/tab-bar.scss +41 -10
- package/treb-grid/src/layout/base_layout.ts +15 -5
- package/treb-grid/src/types/grid.ts +2 -2
package/dist/treb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! API v28.
|
|
1
|
+
/*! API v28.4. 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
|
|
@@ -278,6 +278,13 @@ export interface ICellAddress {
|
|
|
278
278
|
*/
|
|
279
279
|
export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
280
280
|
|
|
281
|
+
/**
|
|
282
|
+
* convenience function returns the name of the active sheet. if the
|
|
283
|
+
* sheet name has spaces or other characters that require quoting, it
|
|
284
|
+
* will be quoted using single quotes.
|
|
285
|
+
*/
|
|
286
|
+
get active_sheet(): string;
|
|
287
|
+
|
|
281
288
|
/** document name (metadata) */
|
|
282
289
|
get document_name(): string | undefined;
|
|
283
290
|
|
|
@@ -769,6 +776,12 @@ export declare class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
769
776
|
*/
|
|
770
777
|
About(): void;
|
|
771
778
|
|
|
779
|
+
/**
|
|
780
|
+
* scroll the given address into view. it could be at either side
|
|
781
|
+
* of the window. optionally use smooth scrolling.
|
|
782
|
+
*/
|
|
783
|
+
ScrollIntoView(address: AddressReference, smooth?: boolean): void;
|
|
784
|
+
|
|
772
785
|
/**
|
|
773
786
|
* Scroll to the given address. In the current implementation this method
|
|
774
787
|
* will not change sheets, although it probably should if the reference
|
package/package.json
CHANGED
|
@@ -100,8 +100,10 @@
|
|
|
100
100
|
</button>
|
|
101
101
|
|
|
102
102
|
<!-- list of tabs for sheets -->
|
|
103
|
-
<
|
|
104
|
-
|
|
103
|
+
<div class="treb-spreadsheet-tab-container">
|
|
104
|
+
<ol class="treb-spreadsheet-tabs" role="tablist"></ol>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
105
107
|
<!-- converted to button, more appropriate -->
|
|
106
108
|
<button class="treb-add-tab" data-command="add-tab" data-conditional="add-tab" title="Add sheet">+</button>
|
|
107
109
|
|
|
@@ -451,6 +451,18 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
451
451
|
*/
|
|
452
452
|
private last_selection?: string;
|
|
453
453
|
|
|
454
|
+
/**
|
|
455
|
+
* convenience function returns the name of the active sheet. if the
|
|
456
|
+
* sheet name has spaces or other characters that require quoting, it
|
|
457
|
+
* will be quoted using single quotes.
|
|
458
|
+
*/
|
|
459
|
+
public get active_sheet(): string {
|
|
460
|
+
const name = this.grid.active_sheet.name;
|
|
461
|
+
if (QuotedSheetNameRegex.test(name)) {
|
|
462
|
+
return `'${name}'`;
|
|
463
|
+
}
|
|
464
|
+
return name;
|
|
465
|
+
}
|
|
454
466
|
|
|
455
467
|
/**
|
|
456
468
|
* this was added for riskamp.com; it doesn't track modified, really, because
|
|
@@ -3717,6 +3729,21 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
|
|
|
3717
3729
|
});
|
|
3718
3730
|
}
|
|
3719
3731
|
|
|
3732
|
+
/**
|
|
3733
|
+
* scroll the given address into view. it could be at either side
|
|
3734
|
+
* of the window. optionally use smooth scrolling.
|
|
3735
|
+
*/
|
|
3736
|
+
public ScrollIntoView(address: AddressReference, smooth = false): void {
|
|
3737
|
+
|
|
3738
|
+
if (typeof address === 'string') {
|
|
3739
|
+
const reference = this.model.ResolveAddress(address, this.grid.active_sheet);
|
|
3740
|
+
address = IsCellAddress(reference) ? reference : reference.start;
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
this.grid.ScrollIntoView(address, smooth);
|
|
3744
|
+
|
|
3745
|
+
}
|
|
3746
|
+
|
|
3720
3747
|
/**
|
|
3721
3748
|
* Scroll to the given address. In the current implementation this method
|
|
3722
3749
|
* will not change sheets, although it probably should if the reference
|
|
@@ -29,6 +29,12 @@
|
|
|
29
29
|
|
|
30
30
|
grid-area: 3/1/4/2;
|
|
31
31
|
|
|
32
|
+
.treb-spreadsheet-tab-container {
|
|
33
|
+
align-self: flex-start;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
height: 2.2em;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
&,
|
|
33
39
|
.treb-spreadsheet-tabs {
|
|
34
40
|
display: flex;
|
|
@@ -40,6 +46,14 @@
|
|
|
40
46
|
list-style-type: none;
|
|
41
47
|
padding-inline-start: 0;
|
|
42
48
|
}
|
|
49
|
+
|
|
50
|
+
.treb-spreadsheet-tabs {
|
|
51
|
+
height: auto;
|
|
52
|
+
margin-block-start: 0;
|
|
53
|
+
margin: 0;
|
|
54
|
+
overflow-x: scroll;
|
|
55
|
+
overflow-y: hidden;
|
|
56
|
+
}
|
|
43
57
|
|
|
44
58
|
&[hidden] {
|
|
45
59
|
display: none;
|
|
@@ -74,6 +88,12 @@
|
|
|
74
88
|
border: 1px solid var(--treb-tab-bar-tab-border-color, var(--treb-ui-border-color, #ccc));
|
|
75
89
|
border-top-width: 0px;
|
|
76
90
|
z-index: 1;
|
|
91
|
+
|
|
92
|
+
// the negative margins here (plus some correction below) makes the
|
|
93
|
+
// active tab overlap just a little bit, very tab like. we have to
|
|
94
|
+
// stop at the last one or it causes problems for the containing node
|
|
95
|
+
// (forces a 2-pixel scroll which is infuriating)
|
|
96
|
+
|
|
77
97
|
margin-right: -2px;
|
|
78
98
|
|
|
79
99
|
&:active, &:focus {
|
|
@@ -81,7 +101,22 @@
|
|
|
81
101
|
}
|
|
82
102
|
|
|
83
103
|
}
|
|
104
|
+
|
|
105
|
+
& .treb-spreadsheet-tabs>li {
|
|
106
|
+
height: 2.2em;
|
|
107
|
+
overflow: visible;
|
|
108
|
+
overflow-x: visible;
|
|
109
|
+
|
|
110
|
+
&:last-of-type {
|
|
111
|
+
margin-right: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
}
|
|
84
115
|
|
|
116
|
+
& .treb-add-tab {
|
|
117
|
+
margin-left: -1px;
|
|
118
|
+
}
|
|
119
|
+
|
|
85
120
|
/** don't overflow/ellipsis the add tab button */
|
|
86
121
|
|
|
87
122
|
/**
|
|
@@ -93,7 +128,7 @@
|
|
|
93
128
|
& .treb-spreadsheet-tabs>li {
|
|
94
129
|
|
|
95
130
|
white-space: nowrap;
|
|
96
|
-
overflow-x: hidden;
|
|
131
|
+
// overflow-x: hidden;
|
|
97
132
|
|
|
98
133
|
&[selected] {
|
|
99
134
|
z-index: 2;
|
|
@@ -190,6 +225,8 @@
|
|
|
190
225
|
margin-right: -2px;
|
|
191
226
|
/* margin-right: 1em; */
|
|
192
227
|
|
|
228
|
+
min-width: 2.5em;
|
|
229
|
+
|
|
193
230
|
svg {
|
|
194
231
|
width: 1em;
|
|
195
232
|
height: 1em;
|
|
@@ -216,15 +253,9 @@
|
|
|
216
253
|
|
|
217
254
|
.treb-stats-panel {
|
|
218
255
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
* as this node is in the layout.
|
|
223
|
-
*
|
|
224
|
-
* in the declarative layout, we always have this node, but if it's
|
|
225
|
-
* not used it will just be empty.
|
|
226
|
-
*/
|
|
227
|
-
margin-left: auto;
|
|
256
|
+
flex: 1 1;
|
|
257
|
+
|
|
258
|
+
text-align: end;
|
|
228
259
|
|
|
229
260
|
white-space: nowrap;
|
|
230
261
|
overflow: hidden;
|
|
@@ -1484,7 +1484,7 @@ export abstract class BaseLayout {
|
|
|
1484
1484
|
* scroll address into view, at top-left or bottom-right depending on
|
|
1485
1485
|
* target and current position. also offsets for frozen rows, columns.
|
|
1486
1486
|
*/
|
|
1487
|
-
public ScrollIntoView(address: ICellAddress): void {
|
|
1487
|
+
public ScrollIntoView(address: ICellAddress, smooth = false): void {
|
|
1488
1488
|
|
|
1489
1489
|
const target_rect = this.CellAddressToRectangle(address);
|
|
1490
1490
|
|
|
@@ -1519,24 +1519,34 @@ export abstract class BaseLayout {
|
|
|
1519
1519
|
// in two scroll events. however in practice this is called on key events,
|
|
1520
1520
|
// so it's unlikely.
|
|
1521
1521
|
|
|
1522
|
+
let options: ScrollToOptions = {
|
|
1523
|
+
behavior: smooth ? 'smooth' : 'auto',
|
|
1524
|
+
};
|
|
1525
|
+
|
|
1522
1526
|
if (address.row !== Infinity) {
|
|
1523
1527
|
if (target_rect.top < viewport.top + offset.y && !lock.y) {
|
|
1524
|
-
this.scroll_reference_node.scrollTop = target_rect.top - offset.y;
|
|
1528
|
+
// this.scroll_reference_node.scrollTop = target_rect.top - offset.y;
|
|
1529
|
+
options.top = target_rect.top - offset.y;
|
|
1525
1530
|
}
|
|
1526
1531
|
else if (target_rect.bottom > viewport.bottom) {
|
|
1527
|
-
this.scroll_reference_node.scrollTop = target_rect.bottom - height;
|
|
1532
|
+
// this.scroll_reference_node.scrollTop = target_rect.bottom - height;
|
|
1533
|
+
options.top = target_rect.bottom - height;
|
|
1528
1534
|
}
|
|
1529
1535
|
}
|
|
1530
1536
|
|
|
1531
1537
|
if (address.column !== Infinity) {
|
|
1532
1538
|
if (target_rect.left < viewport.left + offset.x && !lock.x) {
|
|
1533
|
-
this.scroll_reference_node.scrollLeft = target_rect.left - offset.x;
|
|
1539
|
+
// this.scroll_reference_node.scrollLeft = target_rect.left - offset.x;
|
|
1540
|
+
options.left = target_rect.left - offset.x;
|
|
1534
1541
|
}
|
|
1535
1542
|
else if (target_rect.right > viewport.right) {
|
|
1536
|
-
this.scroll_reference_node.scrollLeft = target_rect.right - width;
|
|
1543
|
+
// this.scroll_reference_node.scrollLeft = target_rect.right - width;
|
|
1544
|
+
options.left = target_rect.right - width;
|
|
1537
1545
|
}
|
|
1538
1546
|
}
|
|
1539
1547
|
|
|
1548
|
+
this.scroll_reference_node.scrollTo(options);
|
|
1549
|
+
|
|
1540
1550
|
}
|
|
1541
1551
|
|
|
1542
1552
|
public UpdateTooltip(options: TooltipOptions = {}): void {
|
|
@@ -2087,9 +2087,9 @@ export class Grid extends GridBase {
|
|
|
2087
2087
|
* FIXME: we need a way to do this without scrolling the containing
|
|
2088
2088
|
* page, in the event we do a scroll-on-load. small problem.
|
|
2089
2089
|
*/
|
|
2090
|
-
public ScrollIntoView(address: ICellAddress): void {
|
|
2090
|
+
public ScrollIntoView(address: ICellAddress, smooth = false): void {
|
|
2091
2091
|
if (this.options.scrollbars) {
|
|
2092
|
-
this.layout.ScrollIntoView(address);
|
|
2092
|
+
this.layout.ScrollIntoView(address, smooth);
|
|
2093
2093
|
}
|
|
2094
2094
|
}
|
|
2095
2095
|
|