@opentui/core 0.1.21 → 0.1.23
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/3d.js +1 -1
- package/Renderable.d.ts +3 -1
- package/{index-8sac0sgm.js → index-a6ydv6yb.js} +29 -5
- package/{index-8sac0sgm.js.map → index-a6ydv6yb.js.map} +5 -5
- package/index.js +109 -7
- package/index.js.map +7 -7
- package/package.json +7 -7
- package/renderables/Input.d.ts +1 -1
- package/renderables/ScrollBar.d.ts +1 -1
- package/renderables/ScrollBox.d.ts +17 -2
- package/renderables/Select.d.ts +1 -1
- package/renderables/TabSelect.d.ts +1 -1
- package/renderer.d.ts +4 -1
- package/testing/mock-keys.d.ts +67 -0
- package/testing/test-renderer.d.ts +6 -0
- package/types.d.ts +3 -0
package/index.js
CHANGED
|
@@ -120,7 +120,7 @@ import {
|
|
|
120
120
|
white,
|
|
121
121
|
wrapWithDelegates,
|
|
122
122
|
yellow
|
|
123
|
-
} from "./index-
|
|
123
|
+
} from "./index-a6ydv6yb.js";
|
|
124
124
|
// src/post/filters.ts
|
|
125
125
|
function applyScanlines(buffer, strength = 0.8, step = 2) {
|
|
126
126
|
const width = buffer.width;
|
|
@@ -2077,7 +2077,7 @@ var InputRenderableEvents;
|
|
|
2077
2077
|
})(InputRenderableEvents ||= {});
|
|
2078
2078
|
|
|
2079
2079
|
class InputRenderable extends Renderable {
|
|
2080
|
-
|
|
2080
|
+
_focusable = true;
|
|
2081
2081
|
_value = "";
|
|
2082
2082
|
_cursorPosition = 0;
|
|
2083
2083
|
_placeholder;
|
|
@@ -2350,7 +2350,7 @@ var SelectRenderableEvents;
|
|
|
2350
2350
|
})(SelectRenderableEvents ||= {});
|
|
2351
2351
|
|
|
2352
2352
|
class SelectRenderable extends Renderable {
|
|
2353
|
-
|
|
2353
|
+
_focusable = true;
|
|
2354
2354
|
_options = [];
|
|
2355
2355
|
selectedIndex = 0;
|
|
2356
2356
|
scrollOffset = 0;
|
|
@@ -2686,7 +2686,7 @@ function calculateDynamicHeight(showUnderline, showDescription) {
|
|
|
2686
2686
|
}
|
|
2687
2687
|
|
|
2688
2688
|
class TabSelectRenderable extends Renderable {
|
|
2689
|
-
|
|
2689
|
+
_focusable = true;
|
|
2690
2690
|
_options = [];
|
|
2691
2691
|
selectedIndex = 0;
|
|
2692
2692
|
scrollOffset = 0;
|
|
@@ -3099,7 +3099,7 @@ class ScrollBarRenderable extends Renderable {
|
|
|
3099
3099
|
startArrow;
|
|
3100
3100
|
endArrow;
|
|
3101
3101
|
orientation;
|
|
3102
|
-
|
|
3102
|
+
_focusable = true;
|
|
3103
3103
|
_scrollSize = 0;
|
|
3104
3104
|
_scrollPosition = 0;
|
|
3105
3105
|
_viewportSize = 0;
|
|
@@ -3431,7 +3431,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3431
3431
|
content;
|
|
3432
3432
|
horizontalScrollBar;
|
|
3433
3433
|
verticalScrollBar;
|
|
3434
|
-
|
|
3434
|
+
_focusable = true;
|
|
3435
3435
|
selectionListener;
|
|
3436
3436
|
autoScrollMouseX = 0;
|
|
3437
3437
|
autoScrollMouseY = 0;
|
|
@@ -3444,17 +3444,42 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3444
3444
|
cachedAutoScrollSpeed = 3;
|
|
3445
3445
|
autoScrollAccumulatorX = 0;
|
|
3446
3446
|
autoScrollAccumulatorY = 0;
|
|
3447
|
+
_stickyScroll;
|
|
3448
|
+
_stickyScrollTop = false;
|
|
3449
|
+
_stickyScrollBottom = false;
|
|
3450
|
+
_stickyScrollLeft = false;
|
|
3451
|
+
_stickyScrollRight = false;
|
|
3452
|
+
_stickyStart;
|
|
3453
|
+
_hasManualScroll = false;
|
|
3454
|
+
get stickyScroll() {
|
|
3455
|
+
return this._stickyScroll;
|
|
3456
|
+
}
|
|
3457
|
+
set stickyScroll(value) {
|
|
3458
|
+
this._stickyScroll = value;
|
|
3459
|
+
this.updateStickyState();
|
|
3460
|
+
}
|
|
3461
|
+
get stickyStart() {
|
|
3462
|
+
return this._stickyStart;
|
|
3463
|
+
}
|
|
3464
|
+
set stickyStart(value) {
|
|
3465
|
+
this._stickyStart = value;
|
|
3466
|
+
this.updateStickyState();
|
|
3467
|
+
}
|
|
3447
3468
|
get scrollTop() {
|
|
3448
3469
|
return this.verticalScrollBar.scrollPosition;
|
|
3449
3470
|
}
|
|
3450
3471
|
set scrollTop(value) {
|
|
3451
3472
|
this.verticalScrollBar.scrollPosition = value;
|
|
3473
|
+
this._hasManualScroll = true;
|
|
3474
|
+
this.updateStickyState();
|
|
3452
3475
|
}
|
|
3453
3476
|
get scrollLeft() {
|
|
3454
3477
|
return this.horizontalScrollBar.scrollPosition;
|
|
3455
3478
|
}
|
|
3456
3479
|
set scrollLeft(value) {
|
|
3457
3480
|
this.horizontalScrollBar.scrollPosition = value;
|
|
3481
|
+
this._hasManualScroll = true;
|
|
3482
|
+
this.updateStickyState();
|
|
3458
3483
|
}
|
|
3459
3484
|
get scrollWidth() {
|
|
3460
3485
|
return this.horizontalScrollBar.scrollSize;
|
|
@@ -3462,6 +3487,56 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3462
3487
|
get scrollHeight() {
|
|
3463
3488
|
return this.verticalScrollBar.scrollSize;
|
|
3464
3489
|
}
|
|
3490
|
+
updateStickyState() {
|
|
3491
|
+
if (!this._stickyScroll)
|
|
3492
|
+
return;
|
|
3493
|
+
const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
3494
|
+
const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
3495
|
+
if (this.scrollTop <= 0) {
|
|
3496
|
+
this._stickyScrollTop = true;
|
|
3497
|
+
this._stickyScrollBottom = false;
|
|
3498
|
+
} else if (this.scrollTop >= maxScrollTop) {
|
|
3499
|
+
this._stickyScrollTop = false;
|
|
3500
|
+
this._stickyScrollBottom = true;
|
|
3501
|
+
} else {
|
|
3502
|
+
this._stickyScrollTop = false;
|
|
3503
|
+
this._stickyScrollBottom = false;
|
|
3504
|
+
}
|
|
3505
|
+
if (this.scrollLeft <= 0) {
|
|
3506
|
+
this._stickyScrollLeft = true;
|
|
3507
|
+
this._stickyScrollRight = false;
|
|
3508
|
+
} else if (this.scrollLeft >= maxScrollLeft) {
|
|
3509
|
+
this._stickyScrollLeft = false;
|
|
3510
|
+
this._stickyScrollRight = true;
|
|
3511
|
+
} else {
|
|
3512
|
+
this._stickyScrollLeft = false;
|
|
3513
|
+
this._stickyScrollRight = false;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
applyStickyStart(stickyStart) {
|
|
3517
|
+
switch (stickyStart) {
|
|
3518
|
+
case "top":
|
|
3519
|
+
this._stickyScrollTop = true;
|
|
3520
|
+
this._stickyScrollBottom = false;
|
|
3521
|
+
this.verticalScrollBar.scrollPosition = 0;
|
|
3522
|
+
break;
|
|
3523
|
+
case "bottom":
|
|
3524
|
+
this._stickyScrollTop = false;
|
|
3525
|
+
this._stickyScrollBottom = true;
|
|
3526
|
+
this.verticalScrollBar.scrollPosition = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
3527
|
+
break;
|
|
3528
|
+
case "left":
|
|
3529
|
+
this._stickyScrollLeft = true;
|
|
3530
|
+
this._stickyScrollRight = false;
|
|
3531
|
+
this.horizontalScrollBar.scrollPosition = 0;
|
|
3532
|
+
break;
|
|
3533
|
+
case "right":
|
|
3534
|
+
this._stickyScrollLeft = false;
|
|
3535
|
+
this._stickyScrollRight = true;
|
|
3536
|
+
this.horizontalScrollBar.scrollPosition = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
3537
|
+
break;
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3465
3540
|
constructor(ctx, {
|
|
3466
3541
|
wrapperOptions,
|
|
3467
3542
|
viewportOptions,
|
|
@@ -3470,6 +3545,8 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3470
3545
|
scrollbarOptions,
|
|
3471
3546
|
verticalScrollbarOptions,
|
|
3472
3547
|
horizontalScrollbarOptions,
|
|
3548
|
+
stickyScroll = false,
|
|
3549
|
+
stickyStart,
|
|
3473
3550
|
...options
|
|
3474
3551
|
}) {
|
|
3475
3552
|
super(ctx, {
|
|
@@ -3482,6 +3559,8 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3482
3559
|
...rootOptions
|
|
3483
3560
|
});
|
|
3484
3561
|
this.internalId = ScrollBoxRenderable.idCounter++;
|
|
3562
|
+
this._stickyScroll = stickyScroll;
|
|
3563
|
+
this._stickyStart = stickyStart;
|
|
3485
3564
|
this.wrapper = new BoxRenderable(ctx, {
|
|
3486
3565
|
flexDirection: "column",
|
|
3487
3566
|
flexGrow: 1,
|
|
@@ -3548,6 +3627,9 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3548
3627
|
});
|
|
3549
3628
|
this.wrapper.add(this.horizontalScrollBar);
|
|
3550
3629
|
this.recalculateBarProps();
|
|
3630
|
+
if (stickyStart && stickyScroll) {
|
|
3631
|
+
this.applyStickyStart(stickyStart);
|
|
3632
|
+
}
|
|
3551
3633
|
this.selectionListener = () => {
|
|
3552
3634
|
const selection = this._ctx.getSelection();
|
|
3553
3635
|
if (!selection || !selection.isSelecting) {
|
|
@@ -3566,6 +3648,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3566
3648
|
this.verticalScrollBar.scrollBy(delta.y, unit);
|
|
3567
3649
|
this.horizontalScrollBar.scrollBy(delta.x, unit);
|
|
3568
3650
|
}
|
|
3651
|
+
this._hasManualScroll = true;
|
|
3569
3652
|
}
|
|
3570
3653
|
scrollTo(position) {
|
|
3571
3654
|
if (typeof position === "number") {
|
|
@@ -3597,6 +3680,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3597
3680
|
this.scrollLeft -= event.scroll?.delta ?? 0;
|
|
3598
3681
|
else if (dir === "right")
|
|
3599
3682
|
this.scrollLeft += event.scroll?.delta ?? 0;
|
|
3683
|
+
this._hasManualScroll = true;
|
|
3600
3684
|
}
|
|
3601
3685
|
if (event.type === "drag" && event.isSelecting) {
|
|
3602
3686
|
this.updateAutoScroll(event.x, event.y);
|
|
@@ -3722,6 +3806,24 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3722
3806
|
this.verticalScrollBar.viewportSize = this.viewport.height;
|
|
3723
3807
|
this.horizontalScrollBar.scrollSize = this.content.width;
|
|
3724
3808
|
this.horizontalScrollBar.viewportSize = this.viewport.width;
|
|
3809
|
+
if (this._stickyScroll) {
|
|
3810
|
+
const newMaxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
|
|
3811
|
+
const newMaxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
|
|
3812
|
+
if (this._stickyStart && !this._hasManualScroll) {
|
|
3813
|
+
this.applyStickyStart(this._stickyStart);
|
|
3814
|
+
} else {
|
|
3815
|
+
if (this._stickyScrollTop) {
|
|
3816
|
+
this.scrollTop = 0;
|
|
3817
|
+
} else if (this._stickyScrollBottom && newMaxScrollTop > 0) {
|
|
3818
|
+
this.scrollTop = newMaxScrollTop;
|
|
3819
|
+
}
|
|
3820
|
+
if (this._stickyScrollLeft) {
|
|
3821
|
+
this.scrollLeft = 0;
|
|
3822
|
+
} else if (this._stickyScrollRight && newMaxScrollLeft > 0) {
|
|
3823
|
+
this.scrollLeft = newMaxScrollLeft;
|
|
3824
|
+
}
|
|
3825
|
+
}
|
|
3826
|
+
}
|
|
3725
3827
|
}
|
|
3726
3828
|
set rootOptions(options) {
|
|
3727
3829
|
Object.assign(this, options);
|
|
@@ -3989,5 +4091,5 @@ export {
|
|
|
3989
4091
|
ASCIIFont
|
|
3990
4092
|
};
|
|
3991
4093
|
|
|
3992
|
-
//# debugId=
|
|
4094
|
+
//# debugId=E4AC186230704DBA64756E2164756E21
|
|
3993
4095
|
//# sourceMappingURL=index.js.map
|