@teaui/core 1.7.8 → 1.9.8
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/Buffer.d.ts +5 -0
- package/.dist/Buffer.js +23 -0
- package/.dist/Buffer.js.map +1 -1
- package/.dist/Color.js.map +1 -1
- package/.dist/Screen.d.ts +2 -1
- package/.dist/Screen.js +24 -10
- package/.dist/Screen.js.map +1 -1
- package/.dist/Theme.d.ts +7 -3
- package/.dist/Theme.js +42 -25
- package/.dist/Theme.js.map +1 -1
- package/.dist/UI.js +3 -1
- package/.dist/UI.js.map +1 -1
- package/.dist/View.d.ts +29 -0
- package/.dist/View.js +40 -2
- package/.dist/View.js.map +1 -1
- package/.dist/Viewport.d.ts +17 -3
- package/.dist/Viewport.js +21 -11
- package/.dist/Viewport.js.map +1 -1
- package/.dist/components/Alert.d.ts +76 -0
- package/.dist/components/Alert.js +133 -0
- package/.dist/components/Alert.js.map +1 -0
- package/.dist/components/Box.d.ts +6 -2
- package/.dist/components/Box.js +51 -14
- package/.dist/components/Box.js.map +1 -1
- package/.dist/components/Button.d.ts +5 -2
- package/.dist/components/Button.js +44 -13
- package/.dist/components/Button.js.map +1 -1
- package/.dist/components/Calendar.d.ts +4 -1
- package/.dist/components/Calendar.js +371 -137
- package/.dist/components/Calendar.js.map +1 -1
- package/.dist/components/Callout.d.ts +12 -0
- package/.dist/components/Callout.js +82 -0
- package/.dist/components/Callout.js.map +1 -0
- package/.dist/components/Checkbox.js +1 -1
- package/.dist/components/Checkbox.js.map +1 -1
- package/.dist/components/Drawer.d.ts +3 -0
- package/.dist/components/Drawer.js +71 -2
- package/.dist/components/Drawer.js.map +1 -1
- package/.dist/components/Dropdown.js +20 -12
- package/.dist/components/Dropdown.js.map +1 -1
- package/.dist/components/Header.d.ts +1 -1
- package/.dist/components/Header.js +12 -10
- package/.dist/components/Header.js.map +1 -1
- package/.dist/components/Input.d.ts +1 -0
- package/.dist/components/Input.js +39 -15
- package/.dist/components/Input.js.map +1 -1
- package/.dist/components/Legend.d.ts +20 -0
- package/.dist/components/Legend.js +180 -0
- package/.dist/components/Legend.js.map +1 -0
- package/.dist/components/Log.js +3 -4
- package/.dist/components/Log.js.map +1 -1
- package/.dist/components/Modal.js +1 -1
- package/.dist/components/Modal.js.map +1 -1
- package/.dist/components/Notification.d.ts +35 -0
- package/.dist/components/Notification.js +120 -0
- package/.dist/components/Notification.js.map +1 -0
- package/.dist/components/Page.d.ts +55 -0
- package/.dist/components/Page.js +374 -0
- package/.dist/components/Page.js.map +1 -0
- package/.dist/components/Progress.d.ts +15 -0
- package/.dist/components/Progress.js +62 -16
- package/.dist/components/Progress.js.map +1 -1
- package/.dist/components/Scrollable.d.ts +60 -15
- package/.dist/components/Scrollable.js +209 -58
- package/.dist/components/Scrollable.js.map +1 -1
- package/.dist/components/ScrollableList.d.ts +16 -9
- package/.dist/components/ScrollableList.js +50 -19
- package/.dist/components/ScrollableList.js.map +1 -1
- package/.dist/components/Slider.d.ts +2 -1
- package/.dist/components/Slider.js +151 -46
- package/.dist/components/Slider.js.map +1 -1
- package/.dist/components/Space.d.ts +0 -3
- package/.dist/components/Space.js +0 -1
- package/.dist/components/Space.js.map +1 -1
- package/.dist/components/Spinner.js +1 -1
- package/.dist/components/Spinner.js.map +1 -1
- package/.dist/components/Stack.js +33 -2
- package/.dist/components/Stack.js.map +1 -1
- package/.dist/components/Table.js +43 -60
- package/.dist/components/Table.js.map +1 -1
- package/.dist/components/Tabs.d.ts +8 -0
- package/.dist/components/Tabs.js +22 -5
- package/.dist/components/Tabs.js.map +1 -1
- package/.dist/components/ToggleGroup.js +1 -1
- package/.dist/components/ToggleGroup.js.map +1 -1
- package/.dist/components/ZStack.d.ts +9 -0
- package/.dist/components/ZStack.js +68 -5
- package/.dist/components/ZStack.js.map +1 -1
- package/.dist/components/index.d.ts +5 -2
- package/.dist/components/index.js +4 -1
- package/.dist/components/index.js.map +1 -1
- package/.dist/events/index.d.ts +6 -2
- package/.dist/events/key.d.ts +18 -4
- package/.dist/events/key.js +42 -6
- package/.dist/events/key.js.map +1 -1
- package/.dist/events/mouse.d.ts +1 -0
- package/.dist/events/mouse.js.map +1 -1
- package/.dist/events/translate.js +17 -4
- package/.dist/events/translate.js.map +1 -1
- package/.dist/index.d.ts +1 -1
- package/.dist/index.js.map +1 -1
- package/.dist/inspect.js +3 -0
- package/.dist/inspect.js.map +1 -1
- package/.dist/managers/FocusManager.d.ts +2 -1
- package/.dist/managers/FocusManager.js +39 -4
- package/.dist/managers/FocusManager.js.map +1 -1
- package/.dist/managers/MouseManager.js +2 -0
- package/.dist/managers/MouseManager.js.map +1 -1
- package/.dist/renderToAnsi.js +1 -1
- package/.dist/renderToAnsi.js.map +1 -1
- package/.dist/terminal.d.ts +1 -0
- package/.dist/testing.d.ts +29 -2
- package/.dist/testing.js +34 -27
- package/.dist/testing.js.map +1 -1
- package/package.json +5 -4
- package/.dist/components/Pin.d.ts +0 -25
- package/.dist/components/Pin.js +0 -80
- package/.dist/components/Pin.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Legend.js","sourceRoot":"","sources":["../../lib/components/Legend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AAItC,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAA;AAC/B,OAAO,EAAC,KAAK,EAAE,IAAI,EAAC,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAYvC,SAAS,UAAU,CAAC,GAAsB;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACjC,CAAC;IAED,gCAAgC;IAChC,IAAI,GAAG,CAAC,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CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
package/.dist/components/Log.js
CHANGED
|
@@ -9,8 +9,7 @@ import { Stack } from './Stack.js';
|
|
|
9
9
|
export class Log extends Container {
|
|
10
10
|
#logs = [];
|
|
11
11
|
#scrollableList = new ScrollableList({
|
|
12
|
-
|
|
13
|
-
items: this.#logs,
|
|
12
|
+
data: this.#logs,
|
|
14
13
|
renderItem: log => {
|
|
15
14
|
return new LogLineView(log);
|
|
16
15
|
},
|
|
@@ -22,14 +21,14 @@ export class Log extends Container {
|
|
|
22
21
|
}
|
|
23
22
|
setLogs(logs) {
|
|
24
23
|
this.#logs = logs;
|
|
25
|
-
this.#scrollableList.
|
|
24
|
+
this.#scrollableList.updateData(logs);
|
|
26
25
|
}
|
|
27
26
|
appendLog(log) {
|
|
28
27
|
this.#logs.push(log);
|
|
29
28
|
}
|
|
30
29
|
clear() {
|
|
31
30
|
this.#logs = [];
|
|
32
|
-
this.#scrollableList.
|
|
31
|
+
this.#scrollableList.updateData(this.#logs);
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
class LogLineView extends Container {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Log.js","sourceRoot":"","sources":["../../lib/components/Log.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAGT,WAAW,IAAI,cAAc,EAC7B,cAAc,IAAI,iBAAiB,GACpC,MAAM,WAAW,CAAA;AAClB,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAA;AACpC,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAA;AAKjC,OAAO,EAAC,SAAS,EAAC,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAC,KAAK,EAAC,MAAM,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IACxB,CAAC;IAED,UAAU,CAAC,MAAc;QACvB,iBAAiB,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QACjD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;IAC1B,CAAC;IAED,MAAM,CAAC,QAAkB;QACvB,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/C,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -99,7 +99,7 @@ export class Modal extends Container {
|
|
|
99
99
|
foreground: this.theme.dimTextColor,
|
|
100
100
|
background: this.theme.dimBackgroundColor,
|
|
101
101
|
});
|
|
102
|
-
viewport.
|
|
102
|
+
viewport.restyle(style);
|
|
103
103
|
}
|
|
104
104
|
if (this.#dismissOnClick) {
|
|
105
105
|
viewport.registerMouse('mouse.button.left');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../lib/components/Modal.ts"],"names":[],"mappings":"AACA,OAAO,EAA+B,SAAS,EAAC,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAGL,cAAc,EACd,WAAW,GACZ,MAAM,oBAAoB,CAAA;AA6B3B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,KAAM,SAAQ,SAAS;IAClC,IAAI,CAAS;IACb,SAAS,CAAmB;IAC5B,eAAe,CAAS;IACxB,aAAa,CAAS;IACtB,UAAU,CAA0B;IAEpC;;;OAGG;IACH,aAAa,GAAS,IAAI,CAAC,IAAI,CAAA;IAE/B;;OAEG;IACH,UAAU,GAAS,IAAI,CAAC,IAAI,CAAA;IAE5B,YAAY,QA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IAAI,CAAC,KAAK,CAAC,kBAAkB;iBAC1C,CAAC,CAAA;YACJ,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QACzB,CAAC;QAED,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,QAAQ,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAA;QAC7C,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACvB,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAA;QAChD,CAAC;QAED,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;IACxB,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Props as ContainerProps, Container } from '../Container.js';
|
|
2
|
+
import { type Purpose } from '../Theme.js';
|
|
3
|
+
import type { View } from '../View.js';
|
|
4
|
+
import { Stack } from './Stack.js';
|
|
5
|
+
import { type Direction } from './types.js';
|
|
6
|
+
export interface Props extends ContainerProps {
|
|
7
|
+
title?: string;
|
|
8
|
+
purpose?: Purpose;
|
|
9
|
+
direction?: Direction;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Internal base class for Alert and Callout. Not exported.
|
|
13
|
+
*
|
|
14
|
+
* Owns a managed Stack for child layout. Subclasses must call
|
|
15
|
+
* `this.addDirect(view)` to add views to the Container directly
|
|
16
|
+
* (bypassing the stack-forwarding `add()` override), and use
|
|
17
|
+
* `this.contentStack` to place the stack in their view hierarchy.
|
|
18
|
+
*/
|
|
19
|
+
export declare class Notification extends Container {
|
|
20
|
+
#private;
|
|
21
|
+
constructor({ title, purpose, direction, children, child, ...props }: Props);
|
|
22
|
+
/**
|
|
23
|
+
* The managed Stack that holds title + children.
|
|
24
|
+
* Subclasses use this to place the stack in their view hierarchy.
|
|
25
|
+
*/
|
|
26
|
+
protected get contentStack(): Stack;
|
|
27
|
+
/**
|
|
28
|
+
* Add a view directly to the Container, bypassing the stack-forwarding
|
|
29
|
+
* `add()` override. Used by subclasses to set up their view hierarchy.
|
|
30
|
+
*/
|
|
31
|
+
protected addDirect(child: View, at?: number): void;
|
|
32
|
+
update(props: Props): void;
|
|
33
|
+
add(child: View, at?: number): void;
|
|
34
|
+
removeChild(child: View): void;
|
|
35
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { Container } from '../Container.js';
|
|
2
|
+
import { Style } from '../Style.js';
|
|
3
|
+
import { Theme } from '../Theme.js';
|
|
4
|
+
import { Stack } from './Stack.js';
|
|
5
|
+
import { Separator } from './Separator.js';
|
|
6
|
+
import { Text } from './Text.js';
|
|
7
|
+
/**
|
|
8
|
+
* Internal base class for Alert and Callout. Not exported.
|
|
9
|
+
*
|
|
10
|
+
* Owns a managed Stack for child layout. Subclasses must call
|
|
11
|
+
* `this.addDirect(view)` to add views to the Container directly
|
|
12
|
+
* (bypassing the stack-forwarding `add()` override), and use
|
|
13
|
+
* `this.contentStack` to place the stack in their view hierarchy.
|
|
14
|
+
*/
|
|
15
|
+
export class Notification extends Container {
|
|
16
|
+
#stack;
|
|
17
|
+
#title;
|
|
18
|
+
#titleStyle;
|
|
19
|
+
#titleView;
|
|
20
|
+
#separator;
|
|
21
|
+
constructor({ title, purpose, direction, children, child, ...props }) {
|
|
22
|
+
super(props);
|
|
23
|
+
this.#title = title;
|
|
24
|
+
this.#titleStyle = new Style({ bold: true });
|
|
25
|
+
this.#stack = new Stack({ direction: direction ?? 'down' });
|
|
26
|
+
if (purpose) {
|
|
27
|
+
this.theme = Theme[purpose];
|
|
28
|
+
}
|
|
29
|
+
if (child) {
|
|
30
|
+
this.add(child);
|
|
31
|
+
}
|
|
32
|
+
else if (children) {
|
|
33
|
+
for (const c of children) {
|
|
34
|
+
this.add(c);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Resolve title after children are added so we can fall back to child heading
|
|
38
|
+
this.#syncTitle();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The managed Stack that holds title + children.
|
|
42
|
+
* Subclasses use this to place the stack in their view hierarchy.
|
|
43
|
+
*/
|
|
44
|
+
get contentStack() {
|
|
45
|
+
return this.#stack;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Add a view directly to the Container, bypassing the stack-forwarding
|
|
49
|
+
* `add()` override. Used by subclasses to set up their view hierarchy.
|
|
50
|
+
*/
|
|
51
|
+
addDirect(child, at) {
|
|
52
|
+
super.add(child, at);
|
|
53
|
+
}
|
|
54
|
+
update(props) {
|
|
55
|
+
this.#updateNotification(props);
|
|
56
|
+
super.update(props);
|
|
57
|
+
}
|
|
58
|
+
#updateNotification({ title, purpose, direction }) {
|
|
59
|
+
this.#title = title;
|
|
60
|
+
this.#stack.direction = direction ?? 'down';
|
|
61
|
+
this.#syncTitle();
|
|
62
|
+
if (purpose) {
|
|
63
|
+
this.theme = Theme[purpose];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The resolved title: explicit `title` prop, or the first user child's
|
|
68
|
+
* `heading`.
|
|
69
|
+
*/
|
|
70
|
+
#resolvedTitle() {
|
|
71
|
+
if (this.#title !== undefined)
|
|
72
|
+
return this.#title;
|
|
73
|
+
return this.#firstUserChild()?.heading;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Returns the first child that isn't the internal title/separator views.
|
|
77
|
+
*/
|
|
78
|
+
#firstUserChild() {
|
|
79
|
+
for (const child of this.#stack.children) {
|
|
80
|
+
if (child !== this.#titleView && child !== this.#separator) {
|
|
81
|
+
return child;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Syncs the title view in the stack with the resolved title.
|
|
88
|
+
*/
|
|
89
|
+
#syncTitle() {
|
|
90
|
+
const resolved = this.#resolvedTitle();
|
|
91
|
+
if (resolved) {
|
|
92
|
+
if (this.#titleView) {
|
|
93
|
+
this.#titleView.text = resolved;
|
|
94
|
+
}
|
|
95
|
+
else if (!this.#titleView) {
|
|
96
|
+
this.#titleView = new Text({
|
|
97
|
+
text: resolved,
|
|
98
|
+
style: this.#titleStyle,
|
|
99
|
+
wrap: true,
|
|
100
|
+
});
|
|
101
|
+
this.#separator = Separator.horizontal();
|
|
102
|
+
this.#stack.add(this.#titleView, 0);
|
|
103
|
+
this.#stack.add(this.#separator, 1);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else if (!resolved && this.#titleView) {
|
|
107
|
+
this.#stack.removeChild(this.#titleView);
|
|
108
|
+
this.#stack.removeChild(this.#separator);
|
|
109
|
+
this.#titleView = undefined;
|
|
110
|
+
this.#separator = undefined;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
add(child, at) {
|
|
114
|
+
this.#stack.add(child, at);
|
|
115
|
+
}
|
|
116
|
+
removeChild(child) {
|
|
117
|
+
this.#stack.removeChild(child);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=Notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Notification.js","sourceRoot":"","sources":["../../lib/components/Notification.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,SAAS,EAAC,MAAM,iBAAiB,CAAA;AACvE,OAAO,EAAC,KAAK,EAAC,MAAM,aAAa,CAAA;AACjC,OAAO,EAAC,KAAK,EAAe,MAAM,aAAa,CAAA;AAE/C,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAA;AAChC,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAA;AACxC,OAAO,EAAC,IAAI,EAAC,MAAM,WAAW,CAAA;AAS9B;;;;;;;GAOG;AACH,MAAM,OAAO,YAAa,SAAQ,SAAS;IACzC,MAAM,CAAO;IACb,MAAM,CAAoB;IAC1B,WAAW,CAAO;IAClB,UAAU,CAAkB;IAC5B,UAAU,CAAuB;IAEjC,YAAY,EAAC,KAAK,EAAE,OAAO,EAAE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EAAE,CAAC,CAAC,CAAA;YACtC,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;YACxC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,UAAW,CAAC,CAAA;YACzC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;YAC3B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC7B,CAAC;IACH,CAAC;IAED,GAAG,CAAC,KAAW,EAAE,EAAW;QAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;IAC5B,CAAC;IAED,WAAW,CAAC,KAAW;QACrB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Container, type Props as ContainerProps } from '../Container.js';
|
|
2
|
+
import { Size } from '../geometry.js';
|
|
3
|
+
import { View } from '../View.js';
|
|
4
|
+
import { Viewport } from '../Viewport.js';
|
|
5
|
+
import { System } from '../System.js';
|
|
6
|
+
import { type MouseEvent, type KeyEvent } from '../events/index.js';
|
|
7
|
+
interface Props extends ContainerProps {
|
|
8
|
+
activeIndex?: number;
|
|
9
|
+
onChange?: (index: number) => void;
|
|
10
|
+
}
|
|
11
|
+
interface SectionProps extends ContainerProps {
|
|
12
|
+
title?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare class Page extends Container {
|
|
15
|
+
#private;
|
|
16
|
+
static Section: typeof Section;
|
|
17
|
+
static create(sections: ([string, View] | Section)[], extraProps?: Props): Page;
|
|
18
|
+
constructor(props?: Props);
|
|
19
|
+
update(props: Props): void;
|
|
20
|
+
get sections(): SectionLike[];
|
|
21
|
+
get activeIndex(): number;
|
|
22
|
+
set activeIndex(value: number);
|
|
23
|
+
addSection(title: string, view: View): void;
|
|
24
|
+
addSection(section: Section): void;
|
|
25
|
+
naturalSize(available: Size): Size;
|
|
26
|
+
receiveKey(event: KeyEvent): void;
|
|
27
|
+
receiveMouse(event: MouseEvent, system: System): void;
|
|
28
|
+
receiveTick(dt: number): boolean;
|
|
29
|
+
render(viewport: Viewport): void;
|
|
30
|
+
}
|
|
31
|
+
declare class Section extends Container {
|
|
32
|
+
#private;
|
|
33
|
+
static create(title: string, child: View, extraProps?: Omit<SectionProps, 'title'>): Section;
|
|
34
|
+
constructor({ title, ...props }: SectionProps);
|
|
35
|
+
/**
|
|
36
|
+
* Returns the explicit title if set, otherwise falls back to the first
|
|
37
|
+
* child's `heading` property.
|
|
38
|
+
*/
|
|
39
|
+
get title(): string;
|
|
40
|
+
set title(value: string);
|
|
41
|
+
update({ title, ...props }: SectionProps): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Lightweight wrapper so non-Section children can be treated uniformly.
|
|
45
|
+
* Delegates rendering and sizing to the underlying view.
|
|
46
|
+
*/
|
|
47
|
+
declare class ImplicitSection {
|
|
48
|
+
#private;
|
|
49
|
+
constructor(view: View);
|
|
50
|
+
get title(): string;
|
|
51
|
+
naturalSize(available: Size): Size;
|
|
52
|
+
render(viewport: Viewport): void;
|
|
53
|
+
}
|
|
54
|
+
type SectionLike = Section | ImplicitSection;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { Container } from '../Container.js';
|
|
2
|
+
import { Point, Rect, Size } from '../geometry.js';
|
|
3
|
+
import { isMouseClicked, isMouseExit, isMouseWheel, } from '../events/index.js';
|
|
4
|
+
import { Style } from '../Style.js';
|
|
5
|
+
import { define } from '../util.js';
|
|
6
|
+
export class Page extends Container {
|
|
7
|
+
static Section;
|
|
8
|
+
#activeIndex = 0;
|
|
9
|
+
#onChange;
|
|
10
|
+
// Animation state
|
|
11
|
+
#animating = false;
|
|
12
|
+
#animationElapsed = 0; // elapsed time in ms
|
|
13
|
+
#animationDirection = 0; // -1 = sliding left (going forward), +1 = sliding right (going backward)
|
|
14
|
+
#outgoingIndex = -1; // section index of the outgoing page
|
|
15
|
+
#incomingIndex = -1; // section index of the incoming page
|
|
16
|
+
// Mouse scroll state
|
|
17
|
+
#scrollDx = 0;
|
|
18
|
+
#scrollTimeout = 0;
|
|
19
|
+
#disableScrollTimeout = 0;
|
|
20
|
+
// Dot layout (computed during render, used for mouse hit-testing)
|
|
21
|
+
#dotRects = [];
|
|
22
|
+
#hoveredDot = -1;
|
|
23
|
+
#dotsY = 0;
|
|
24
|
+
static create(sections, extraProps = {}) {
|
|
25
|
+
const page = new Page(extraProps);
|
|
26
|
+
for (const section of sections) {
|
|
27
|
+
if (section instanceof Section) {
|
|
28
|
+
page.addSection(section);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const [title, view] = section;
|
|
32
|
+
page.addSection(title, view);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return page;
|
|
36
|
+
}
|
|
37
|
+
constructor(props = {}) {
|
|
38
|
+
super(props);
|
|
39
|
+
this.#update(props);
|
|
40
|
+
}
|
|
41
|
+
update(props) {
|
|
42
|
+
this.#update(props);
|
|
43
|
+
super.update(props);
|
|
44
|
+
}
|
|
45
|
+
#update({ activeIndex, onChange }) {
|
|
46
|
+
if (activeIndex !== undefined && activeIndex !== this.#activeIndex) {
|
|
47
|
+
this.#navigateTo(activeIndex);
|
|
48
|
+
}
|
|
49
|
+
this.#onChange = onChange;
|
|
50
|
+
}
|
|
51
|
+
get sections() {
|
|
52
|
+
return this.children.map(view => view instanceof Section ? view : new ImplicitSection(view));
|
|
53
|
+
}
|
|
54
|
+
get activeIndex() {
|
|
55
|
+
return this.#activeIndex;
|
|
56
|
+
}
|
|
57
|
+
set activeIndex(value) {
|
|
58
|
+
if (value === this.#activeIndex)
|
|
59
|
+
return;
|
|
60
|
+
this.#navigateTo(value);
|
|
61
|
+
}
|
|
62
|
+
addSection(titleOrSection, view) {
|
|
63
|
+
let sectionView;
|
|
64
|
+
if (titleOrSection instanceof Section) {
|
|
65
|
+
sectionView = titleOrSection;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
sectionView = Section.create(titleOrSection, view);
|
|
69
|
+
}
|
|
70
|
+
this.add(sectionView);
|
|
71
|
+
}
|
|
72
|
+
#navigateTo(index) {
|
|
73
|
+
const sections = this.sections;
|
|
74
|
+
if (sections.length === 0)
|
|
75
|
+
return;
|
|
76
|
+
index = Math.max(0, Math.min(sections.length - 1, index));
|
|
77
|
+
if (index === this.#activeIndex && !this.#animating)
|
|
78
|
+
return;
|
|
79
|
+
const prevIndex = this.#animating ? this.#incomingIndex : this.#activeIndex;
|
|
80
|
+
if (index === prevIndex)
|
|
81
|
+
return;
|
|
82
|
+
this.#outgoingIndex = prevIndex;
|
|
83
|
+
this.#incomingIndex = index;
|
|
84
|
+
this.#animationDirection = index > prevIndex ? -1 : 1;
|
|
85
|
+
this.#animationElapsed = 0;
|
|
86
|
+
this.#animating = true;
|
|
87
|
+
this.#activeIndex = index;
|
|
88
|
+
this.#onChange?.(index);
|
|
89
|
+
this.invalidateSize();
|
|
90
|
+
}
|
|
91
|
+
#hasTitles() {
|
|
92
|
+
return this.sections.some(s => s.title.length > 0);
|
|
93
|
+
}
|
|
94
|
+
#indicatorHeight() {
|
|
95
|
+
return 1 + (this.#hasTitles() ? 1 : 0);
|
|
96
|
+
}
|
|
97
|
+
naturalSize(available) {
|
|
98
|
+
const indicatorHeight = this.#indicatorHeight();
|
|
99
|
+
const childAvailable = available.shrink(0, indicatorHeight);
|
|
100
|
+
let maxWidth = 0, maxHeight = 0;
|
|
101
|
+
for (const section of this.sections) {
|
|
102
|
+
const size = section.naturalSize(childAvailable);
|
|
103
|
+
maxWidth = Math.max(maxWidth, size.width);
|
|
104
|
+
maxHeight = Math.max(maxHeight, size.height);
|
|
105
|
+
}
|
|
106
|
+
return new Size(maxWidth, maxHeight + indicatorHeight);
|
|
107
|
+
}
|
|
108
|
+
receiveKey(event) {
|
|
109
|
+
const sections = this.sections;
|
|
110
|
+
if (sections.length === 0)
|
|
111
|
+
return;
|
|
112
|
+
switch (event.name) {
|
|
113
|
+
case 'pagedown':
|
|
114
|
+
this.#navigateTo(this.#activeIndex + 1);
|
|
115
|
+
break;
|
|
116
|
+
case 'pageup':
|
|
117
|
+
this.#navigateTo(this.#activeIndex - 1);
|
|
118
|
+
break;
|
|
119
|
+
case 'home':
|
|
120
|
+
this.#navigateTo(0);
|
|
121
|
+
break;
|
|
122
|
+
case 'end':
|
|
123
|
+
this.#navigateTo(sections.length - 1);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
receiveMouse(event, system) {
|
|
128
|
+
super.receiveMouse(event, system);
|
|
129
|
+
if (isMouseWheel(event)) {
|
|
130
|
+
if (this.#disableScrollTimeout > 0)
|
|
131
|
+
return;
|
|
132
|
+
if (event.name === 'mouse.wheel.up' ||
|
|
133
|
+
event.name === 'mouse.wheel.left') {
|
|
134
|
+
this.#scrollDx -= 1;
|
|
135
|
+
}
|
|
136
|
+
else if (event.name === 'mouse.wheel.down' ||
|
|
137
|
+
event.name === 'mouse.wheel.right') {
|
|
138
|
+
this.#scrollDx += 1;
|
|
139
|
+
}
|
|
140
|
+
if (this.#scrollDx <= -SCROLL_THRESHOLD) {
|
|
141
|
+
this.#scrollDx = 0;
|
|
142
|
+
this.#scrollTimeout = 0;
|
|
143
|
+
this.#disableScrollTimeout = DISABLE_TIMEOUT;
|
|
144
|
+
this.#navigateTo(this.#activeIndex - 1);
|
|
145
|
+
}
|
|
146
|
+
else if (this.#scrollDx >= SCROLL_THRESHOLD) {
|
|
147
|
+
this.#scrollDx = 0;
|
|
148
|
+
this.#scrollTimeout = 0;
|
|
149
|
+
this.#disableScrollTimeout = DISABLE_TIMEOUT;
|
|
150
|
+
this.#navigateTo(this.#activeIndex + 1);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this.#scrollTimeout = SCROLL_TIMEOUT;
|
|
154
|
+
this.invalidateSize();
|
|
155
|
+
}
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
// Update dot hover based on mouse position
|
|
159
|
+
if (isMouseExit(event)) {
|
|
160
|
+
this.#hoveredDot = -1;
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.#hoveredDot = this.#dotIndexAt(event.position);
|
|
164
|
+
}
|
|
165
|
+
if (isMouseClicked(event)) {
|
|
166
|
+
const dotIndex = this.#dotIndexAt(event.position);
|
|
167
|
+
if (dotIndex >= 0) {
|
|
168
|
+
this.#navigateTo(dotIndex);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
#dotIndexAt(position) {
|
|
173
|
+
for (let i = 0; i < this.#dotRects.length; i++) {
|
|
174
|
+
if (this.#dotRects[i].includes(position)) {
|
|
175
|
+
return i;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return -1;
|
|
179
|
+
}
|
|
180
|
+
receiveTick(dt) {
|
|
181
|
+
let needsTick = false;
|
|
182
|
+
if (this.#disableScrollTimeout > 0) {
|
|
183
|
+
this.#disableScrollTimeout -= dt;
|
|
184
|
+
if (this.#disableScrollTimeout <= 0) {
|
|
185
|
+
this.#disableScrollTimeout = 0;
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
needsTick = true;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (this.#scrollDx !== 0) {
|
|
192
|
+
this.#scrollTimeout -= dt;
|
|
193
|
+
if (this.#scrollTimeout <= 0) {
|
|
194
|
+
this.#scrollDx = 0;
|
|
195
|
+
this.#scrollTimeout = 0;
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
needsTick = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (!this.#animating)
|
|
202
|
+
return needsTick;
|
|
203
|
+
this.#animationElapsed += dt;
|
|
204
|
+
if (this.#animationElapsed >= ANIMATION_DURATION) {
|
|
205
|
+
this.#animating = false;
|
|
206
|
+
this.#animationElapsed = 0;
|
|
207
|
+
this.#outgoingIndex = -1;
|
|
208
|
+
this.#incomingIndex = -1;
|
|
209
|
+
this.invalidateSize();
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
this.invalidateSize();
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
render(viewport) {
|
|
216
|
+
const sections = this.sections;
|
|
217
|
+
if (sections.length === 0)
|
|
218
|
+
return;
|
|
219
|
+
viewport.registerFocus();
|
|
220
|
+
viewport.registerMouse(['mouse.button.left', 'mouse.move', 'mouse.wheel']);
|
|
221
|
+
if (this.#animating ||
|
|
222
|
+
this.#scrollDx !== 0 ||
|
|
223
|
+
this.#disableScrollTimeout > 0) {
|
|
224
|
+
viewport.registerTick();
|
|
225
|
+
}
|
|
226
|
+
const indicatorHeight = this.#indicatorHeight();
|
|
227
|
+
const contentHeight = viewport.contentSize.height - indicatorHeight;
|
|
228
|
+
const contentWidth = viewport.contentSize.width;
|
|
229
|
+
if (contentHeight > 0) {
|
|
230
|
+
const contentRect = new Rect([0, 0], [contentWidth, contentHeight]);
|
|
231
|
+
if (this.#animating && this.#outgoingIndex >= 0) {
|
|
232
|
+
const t = Math.min(1, this.#animationElapsed / ANIMATION_DURATION);
|
|
233
|
+
const eased = easeInOut(t);
|
|
234
|
+
const offset = Math.round(eased * contentWidth);
|
|
235
|
+
// Both pages slide in the same direction:
|
|
236
|
+
// forward (direction = -1): both slide left
|
|
237
|
+
// backward (direction = +1): both slide right
|
|
238
|
+
const outX = this.#animationDirection * offset;
|
|
239
|
+
const inX = this.#animationDirection * (offset - contentWidth);
|
|
240
|
+
const outgoing = sections[this.#outgoingIndex];
|
|
241
|
+
const incoming = sections[this.#incomingIndex];
|
|
242
|
+
viewport.clipped(contentRect, inner => {
|
|
243
|
+
if (outgoing) {
|
|
244
|
+
inner.clipped(new Rect([outX, 0], [contentWidth, contentHeight]), inner2 => outgoing.render(inner2));
|
|
245
|
+
}
|
|
246
|
+
if (incoming) {
|
|
247
|
+
inner.clipped(new Rect([inX, 0], [contentWidth, contentHeight]), inner2 => incoming.render(inner2));
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
const active = sections[this.#activeIndex];
|
|
253
|
+
if (active) {
|
|
254
|
+
viewport.clipped(contentRect, inner => {
|
|
255
|
+
active.render(inner);
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Render indicator area
|
|
261
|
+
this.#renderIndicator(viewport, sections, contentHeight);
|
|
262
|
+
}
|
|
263
|
+
#renderIndicator(viewport, sections, contentY) {
|
|
264
|
+
const textStyle = this.theme.text();
|
|
265
|
+
const totalDotsWidth = sections.length * DOT_WIDTH;
|
|
266
|
+
const startX = Math.max(0, Math.floor((viewport.contentSize.width - totalDotsWidth) / 2));
|
|
267
|
+
const hasTitles = this.#hasTitles();
|
|
268
|
+
const indicatorHeight = this.#indicatorHeight();
|
|
269
|
+
const dotsY = contentY + (hasTitles ? 1 : 0);
|
|
270
|
+
// Paint subtle background across the indicator area
|
|
271
|
+
const bgStyle = this.#controlsBackground();
|
|
272
|
+
viewport.paint(bgStyle, new Rect([0, contentY], [viewport.contentSize.width, indicatorHeight]));
|
|
273
|
+
// Render title if any section has a title
|
|
274
|
+
if (hasTitles) {
|
|
275
|
+
const titleY = contentY;
|
|
276
|
+
// Show hovered dot's title, or active section's title
|
|
277
|
+
const titleIndex = this.#hoveredDot >= 0 ? this.#hoveredDot : this.#activeIndex;
|
|
278
|
+
const title = sections[titleIndex]?.title ?? '';
|
|
279
|
+
if (title.length > 0) {
|
|
280
|
+
const titleX = Math.max(0, Math.floor((viewport.contentSize.width - title.length) / 2));
|
|
281
|
+
viewport.write(title, new Point(titleX, titleY), textStyle.merge(bgStyle));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
// Render dots and store rects for hit-testing
|
|
285
|
+
this.#dotRects = [];
|
|
286
|
+
this.#dotsY = dotsY;
|
|
287
|
+
for (let i = 0; i < sections.length; i++) {
|
|
288
|
+
const dotX = startX + i * DOT_WIDTH;
|
|
289
|
+
const dotChar = i === this.#activeIndex ? DOT_ACTIVE : DOT_INACTIVE;
|
|
290
|
+
// DOT_WIDTH = 3: [pad] [dot] [pad]
|
|
291
|
+
const dotRect = new Rect([dotX, dotsY], [DOT_WIDTH, 1]);
|
|
292
|
+
this.#dotRects.push(dotRect);
|
|
293
|
+
const isHover = this.#hoveredDot === i;
|
|
294
|
+
const style = this.#dotStyle(i === this.#activeIndex, isHover);
|
|
295
|
+
if (isHover) {
|
|
296
|
+
viewport.paint(style, dotRect);
|
|
297
|
+
}
|
|
298
|
+
viewport.write(dotChar, new Point(dotX + 1, dotsY), style);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
#controlsBackground() {
|
|
302
|
+
return new Style({ background: this.theme.ui().background });
|
|
303
|
+
}
|
|
304
|
+
#dotStyle(isActive, isHover) {
|
|
305
|
+
if (isHover) {
|
|
306
|
+
const { foreground, background } = this.theme.ui({ isHover: true });
|
|
307
|
+
return new Style({ bold: true, foreground, background });
|
|
308
|
+
}
|
|
309
|
+
const background = this.theme.ui().background;
|
|
310
|
+
if (isActive) {
|
|
311
|
+
return new Style({ bold: true, background });
|
|
312
|
+
}
|
|
313
|
+
return new Style({ dim: true, background });
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
class Section extends Container {
|
|
317
|
+
#title;
|
|
318
|
+
static create(title, child, extraProps = {}) {
|
|
319
|
+
return new Section({ title, child, ...extraProps });
|
|
320
|
+
}
|
|
321
|
+
constructor({ title, ...props }) {
|
|
322
|
+
super(props);
|
|
323
|
+
this.#title = title;
|
|
324
|
+
define(this, 'title', { enumerable: true });
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Returns the explicit title if set, otherwise falls back to the first
|
|
328
|
+
* child's `heading` property.
|
|
329
|
+
*/
|
|
330
|
+
get title() {
|
|
331
|
+
return this.#title ?? this.children[0]?.heading ?? '';
|
|
332
|
+
}
|
|
333
|
+
set title(value) {
|
|
334
|
+
this.#title = value;
|
|
335
|
+
this.invalidateSize();
|
|
336
|
+
}
|
|
337
|
+
update({ title, ...props }) {
|
|
338
|
+
if (title !== undefined) {
|
|
339
|
+
this.title = title;
|
|
340
|
+
}
|
|
341
|
+
super.update(props);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Lightweight wrapper so non-Section children can be treated uniformly.
|
|
346
|
+
* Delegates rendering and sizing to the underlying view.
|
|
347
|
+
*/
|
|
348
|
+
class ImplicitSection {
|
|
349
|
+
#view;
|
|
350
|
+
constructor(view) {
|
|
351
|
+
this.#view = view;
|
|
352
|
+
}
|
|
353
|
+
get title() {
|
|
354
|
+
return this.#view.heading ?? '';
|
|
355
|
+
}
|
|
356
|
+
naturalSize(available) {
|
|
357
|
+
return this.#view.naturalSize(available);
|
|
358
|
+
}
|
|
359
|
+
render(viewport) {
|
|
360
|
+
this.#view.render(viewport);
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
Page.Section = Section;
|
|
364
|
+
const DOT_ACTIVE = '●';
|
|
365
|
+
const DOT_INACTIVE = '○';
|
|
366
|
+
const DOT_WIDTH = 3;
|
|
367
|
+
const SCROLL_THRESHOLD = 3;
|
|
368
|
+
const SCROLL_TIMEOUT = 3000; // ms to accrue scroll events before resetting
|
|
369
|
+
const DISABLE_TIMEOUT = 300; // ms to ignore scroll events after a page change
|
|
370
|
+
const ANIMATION_DURATION = 400; // ms
|
|
371
|
+
function easeInOut(t) {
|
|
372
|
+
return t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2;
|
|
373
|
+
}
|
|
374
|
+
//# sourceMappingURL=Page.js.map
|