@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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "main": "index.js",
5
5
  "types": "index.d.ts",
6
6
  "type": "module",
7
- "version": "0.1.21",
7
+ "version": "0.1.23",
8
8
  "description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -38,11 +38,11 @@
38
38
  "bun-webgpu": "0.1.3",
39
39
  "planck": "^1.4.2",
40
40
  "three": "0.177.0",
41
- "@opentui/core-darwin-x64": "0.1.21",
42
- "@opentui/core-darwin-arm64": "0.1.21",
43
- "@opentui/core-linux-x64": "0.1.21",
44
- "@opentui/core-linux-arm64": "0.1.21",
45
- "@opentui/core-win32-x64": "0.1.21",
46
- "@opentui/core-win32-arm64": "0.1.21"
41
+ "@opentui/core-darwin-x64": "0.1.23",
42
+ "@opentui/core-darwin-arm64": "0.1.23",
43
+ "@opentui/core-linux-x64": "0.1.23",
44
+ "@opentui/core-linux-arm64": "0.1.23",
45
+ "@opentui/core-win32-x64": "0.1.23",
46
+ "@opentui/core-win32-arm64": "0.1.23"
47
47
  }
48
48
  }
@@ -20,7 +20,7 @@ export declare enum InputRenderableEvents {
20
20
  ENTER = "enter"
21
21
  }
22
22
  export declare class InputRenderable extends Renderable {
23
- protected focusable: boolean;
23
+ protected _focusable: boolean;
24
24
  private _value;
25
25
  private _cursorPosition;
26
26
  private _placeholder;
@@ -17,7 +17,7 @@ export declare class ScrollBarRenderable extends Renderable {
17
17
  readonly startArrow: ArrowRenderable;
18
18
  readonly endArrow: ArrowRenderable;
19
19
  readonly orientation: "vertical" | "horizontal";
20
- protected focusable: boolean;
20
+ protected _focusable: boolean;
21
21
  private _scrollSize;
22
22
  private _scrollPosition;
23
23
  private _viewportSize;
@@ -18,6 +18,8 @@ export interface ScrollBoxOptions extends BoxOptions<ScrollBoxRenderable> {
18
18
  scrollbarOptions?: Omit<ScrollBarOptions, "orientation">;
19
19
  verticalScrollbarOptions?: Omit<ScrollBarOptions, "orientation">;
20
20
  horizontalScrollbarOptions?: Omit<ScrollBarOptions, "orientation">;
21
+ stickyScroll?: boolean;
22
+ stickyStart?: "bottom" | "top" | "left" | "right";
21
23
  }
22
24
  export declare class ScrollBoxRenderable extends BoxRenderable {
23
25
  static idCounter: number;
@@ -27,7 +29,7 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
27
29
  readonly content: ContentRenderable;
28
30
  readonly horizontalScrollBar: ScrollBarRenderable;
29
31
  readonly verticalScrollBar: ScrollBarRenderable;
30
- protected focusable: boolean;
32
+ protected _focusable: boolean;
31
33
  private selectionListener?;
32
34
  private autoScrollMouseX;
33
35
  private autoScrollMouseY;
@@ -40,13 +42,26 @@ export declare class ScrollBoxRenderable extends BoxRenderable {
40
42
  private cachedAutoScrollSpeed;
41
43
  private autoScrollAccumulatorX;
42
44
  private autoScrollAccumulatorY;
45
+ private _stickyScroll;
46
+ private _stickyScrollTop;
47
+ private _stickyScrollBottom;
48
+ private _stickyScrollLeft;
49
+ private _stickyScrollRight;
50
+ private _stickyStart?;
51
+ private _hasManualScroll;
52
+ get stickyScroll(): boolean;
53
+ set stickyScroll(value: boolean);
54
+ get stickyStart(): "bottom" | "top" | "left" | "right" | undefined;
55
+ set stickyStart(value: "bottom" | "top" | "left" | "right" | undefined);
43
56
  get scrollTop(): number;
44
57
  set scrollTop(value: number);
45
58
  get scrollLeft(): number;
46
59
  set scrollLeft(value: number);
47
60
  get scrollWidth(): number;
48
61
  get scrollHeight(): number;
49
- constructor(ctx: RenderContext, { wrapperOptions, viewportOptions, contentOptions, rootOptions, scrollbarOptions, verticalScrollbarOptions, horizontalScrollbarOptions, ...options }: ScrollBoxOptions);
62
+ private updateStickyState;
63
+ private applyStickyStart;
64
+ constructor(ctx: RenderContext, { wrapperOptions, viewportOptions, contentOptions, rootOptions, scrollbarOptions, verticalScrollbarOptions, horizontalScrollbarOptions, stickyScroll, stickyStart, ...options }: ScrollBoxOptions);
50
65
  protected onUpdate(deltaTime: number): void;
51
66
  scrollBy(delta: number | {
52
67
  x: number;
@@ -31,7 +31,7 @@ export declare enum SelectRenderableEvents {
31
31
  ITEM_SELECTED = "itemSelected"
32
32
  }
33
33
  export declare class SelectRenderable extends Renderable {
34
- protected focusable: boolean;
34
+ protected _focusable: boolean;
35
35
  private _options;
36
36
  private selectedIndex;
37
37
  private scrollOffset;
@@ -29,7 +29,7 @@ export declare enum TabSelectRenderableEvents {
29
29
  ITEM_SELECTED = "itemSelected"
30
30
  }
31
31
  export declare class TabSelectRenderable extends Renderable {
32
- protected focusable: boolean;
32
+ protected _focusable: boolean;
33
33
  private _options;
34
34
  private selectedIndex;
35
35
  private scrollOffset;
package/renderer.d.ts CHANGED
@@ -70,7 +70,7 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
70
70
  private static animationFrameId;
71
71
  private lib;
72
72
  rendererPtr: Pointer;
73
- private stdin;
73
+ stdin: NodeJS.ReadStream;
74
74
  private stdout;
75
75
  private exitOnCtrlC;
76
76
  private isDestroyed;
@@ -134,7 +134,10 @@ export declare class CliRenderer extends EventEmitter implements RenderContext {
134
134
  private sigwinchHandler;
135
135
  private _capabilities;
136
136
  private _latestPointer;
137
+ private _currentFocusedRenderable;
137
138
  constructor(lib: RenderLib, rendererPtr: Pointer, stdin: NodeJS.ReadStream, stdout: NodeJS.WriteStream, width: number, height: number, config?: CliRendererConfig);
139
+ get currentFocusedRenderable(): Renderable | null;
140
+ focusRenderable(renderable: Renderable): void;
138
141
  addToHitGrid(x: number, y: number, width: number, height: number, id: number): void;
139
142
  get widthMethod(): WidthMethod;
140
143
  private writeOut;
@@ -0,0 +1,67 @@
1
+ import type { CliRenderer } from "../renderer";
2
+ export declare const KeyCodes: {
3
+ readonly ENTER: "\r";
4
+ readonly TAB: "\t";
5
+ readonly BACKSPACE: "\b";
6
+ readonly DELETE: "\u001B[3~";
7
+ readonly HOME: "\u001B[H";
8
+ readonly END: "\u001B[F";
9
+ readonly ESCAPE: "\u001B";
10
+ readonly ARROW_UP: "\u001B[A";
11
+ readonly ARROW_DOWN: "\u001B[B";
12
+ readonly ARROW_RIGHT: "\u001B[C";
13
+ readonly ARROW_LEFT: "\u001B[D";
14
+ readonly F1: "\u001BOP";
15
+ readonly F2: "\u001BOQ";
16
+ readonly F3: "\u001BOR";
17
+ readonly F4: "\u001BOS";
18
+ readonly F5: "\u001B[15~";
19
+ readonly F6: "\u001B[17~";
20
+ readonly F7: "\u001B[18~";
21
+ readonly F8: "\u001B[19~";
22
+ readonly F9: "\u001B[20~";
23
+ readonly F10: "\u001B[21~";
24
+ readonly F11: "\u001B[23~";
25
+ readonly F12: "\u001B[24~";
26
+ readonly CTRL_A: "\u0001";
27
+ readonly CTRL_B: "\u0002";
28
+ readonly CTRL_C: "\u0003";
29
+ readonly CTRL_D: "\u0004";
30
+ readonly CTRL_E: "\u0005";
31
+ readonly CTRL_F: "\u0006";
32
+ readonly CTRL_G: "\u0007";
33
+ readonly CTRL_H: "\b";
34
+ readonly CTRL_I: "\t";
35
+ readonly CTRL_J: "\n";
36
+ readonly CTRL_K: "\v";
37
+ readonly CTRL_L: "\f";
38
+ readonly CTRL_M: "\r";
39
+ readonly CTRL_N: "\u000E";
40
+ readonly CTRL_O: "\u000F";
41
+ readonly CTRL_P: "\u0010";
42
+ readonly CTRL_Q: "\u0011";
43
+ readonly CTRL_R: "\u0012";
44
+ readonly CTRL_S: "\u0013";
45
+ readonly CTRL_T: "\u0014";
46
+ readonly CTRL_U: "\u0015";
47
+ readonly CTRL_V: "\u0016";
48
+ readonly CTRL_W: "\u0017";
49
+ readonly CTRL_X: "\u0018";
50
+ readonly CTRL_Y: "\u0019";
51
+ readonly CTRL_Z: "\u001A";
52
+ readonly ALT_A: "\u001Ba";
53
+ readonly ALT_B: "\u001Bb";
54
+ readonly ALT_C: "\u001Bc";
55
+ };
56
+ export type KeyInput = string | keyof typeof KeyCodes;
57
+ export declare function createMockKeys(renderer: CliRenderer): {
58
+ pressKeys: (keys: KeyInput[], delayMs?: number) => Promise<void>;
59
+ pressKey: (key: KeyInput) => void;
60
+ typeText: (text: string, delayMs?: number) => Promise<void>;
61
+ pressEnter: () => void;
62
+ pressEscape: () => void;
63
+ pressTab: () => void;
64
+ pressBackspace: () => void;
65
+ pressArrow: (direction: "up" | "down" | "left" | "right") => void;
66
+ pressCtrlC: () => void;
67
+ };
@@ -0,0 +1,6 @@
1
+ import { CliRenderer, type CliRendererConfig } from "../renderer";
2
+ import { createMockKeys } from "./mock-keys";
3
+ export declare function createTestRenderer(options: CliRendererConfig): Promise<{
4
+ renderer: CliRenderer;
5
+ mockInput: ReturnType<typeof createMockKeys>;
6
+ }>;
package/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { RGBA } from "./lib/RGBA";
2
2
  import type { EventEmitter } from "events";
3
3
  import type { Selection } from "./lib/selection";
4
+ import type { Renderable } from "./Renderable";
4
5
  export declare const TextAttributes: {
5
6
  NONE: number;
6
7
  BOLD: number;
@@ -46,6 +47,8 @@ export interface RenderContext extends EventEmitter {
46
47
  hasSelection: boolean;
47
48
  getSelection: () => Selection | null;
48
49
  requestSelectionUpdate: () => void;
50
+ currentFocusedRenderable: Renderable | null;
51
+ focusRenderable: (renderable: Renderable) => void;
49
52
  }
50
53
  export type Timeout = ReturnType<typeof setTimeout> | undefined;
51
54
  export interface ViewportBounds {