@opentuah/react 0.1.78 → 0.1.80
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/README.md +30 -30
- package/{chunk-zr0nkmwe.js → chunk-79j2krnf.js} +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
- package/src/hooks/use-renderer.d.ts +1 -1
- package/src/hooks/use-resize.d.ts +1 -1
- package/src/test-utils.d.ts +1 -1
- package/test-utils.js +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @opentuah/react
|
|
2
2
|
|
|
3
3
|
A React renderer for building terminal user interfaces using [OpenTUI core](https://github.com/anomalyco/opentui). Create rich, interactive console applications with familiar React patterns and components.
|
|
4
4
|
|
|
@@ -13,14 +13,14 @@ bun create tui --template react
|
|
|
13
13
|
Manual installation:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
bun install @
|
|
16
|
+
bun install @opentuah/react @opentuah/core react
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
import { createCliRenderer } from "@
|
|
23
|
-
import { createRoot } from "@
|
|
22
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
23
|
+
import { createRoot } from "@opentuah/react"
|
|
24
24
|
|
|
25
25
|
function App() {
|
|
26
26
|
return <text>Hello, world!</text>
|
|
@@ -42,7 +42,7 @@ For optimal TypeScript support, configure your `tsconfig.json`:
|
|
|
42
42
|
"module": "ESNext",
|
|
43
43
|
"moduleResolution": "bundler",
|
|
44
44
|
"jsx": "react-jsx",
|
|
45
|
-
"jsxImportSource": "@
|
|
45
|
+
"jsxImportSource": "@opentuah/react",
|
|
46
46
|
"strict": true,
|
|
47
47
|
"skipLibCheck": true
|
|
48
48
|
}
|
|
@@ -138,8 +138,8 @@ Components can be styled using props or the `style` prop:
|
|
|
138
138
|
Creates a root for rendering a React tree with the given CLI renderer.
|
|
139
139
|
|
|
140
140
|
```tsx
|
|
141
|
-
import { createCliRenderer } from "@
|
|
142
|
-
import { createRoot } from "@
|
|
141
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
142
|
+
import { createRoot } from "@opentuah/react"
|
|
143
143
|
|
|
144
144
|
const renderer = await createCliRenderer({
|
|
145
145
|
// Optional renderer configuration
|
|
@@ -167,7 +167,7 @@ Renders a React element to the terminal. This function is deprecated in favor of
|
|
|
167
167
|
Access the OpenTUI renderer instance.
|
|
168
168
|
|
|
169
169
|
```tsx
|
|
170
|
-
import { useRenderer } from "@
|
|
170
|
+
import { useRenderer } from "@opentuah/react"
|
|
171
171
|
|
|
172
172
|
function App() {
|
|
173
173
|
const renderer = useRenderer()
|
|
@@ -186,7 +186,7 @@ function App() {
|
|
|
186
186
|
Handle keyboard events.
|
|
187
187
|
|
|
188
188
|
```tsx
|
|
189
|
-
import { useKeyboard } from "@
|
|
189
|
+
import { useKeyboard } from "@opentuah/react"
|
|
190
190
|
|
|
191
191
|
function App() {
|
|
192
192
|
useKeyboard((key) => {
|
|
@@ -210,7 +210,7 @@ By default, only receives press events (including key repeats with `repeated: tr
|
|
|
210
210
|
**Example with release events:**
|
|
211
211
|
|
|
212
212
|
```tsx
|
|
213
|
-
import { useKeyboard } from "@
|
|
213
|
+
import { useKeyboard } from "@opentuah/react"
|
|
214
214
|
import { useState } from "react"
|
|
215
215
|
|
|
216
216
|
function App() {
|
|
@@ -244,7 +244,7 @@ function App() {
|
|
|
244
244
|
Handle terminal resize events.
|
|
245
245
|
|
|
246
246
|
```tsx
|
|
247
|
-
import { useOnResize, useRenderer } from "@
|
|
247
|
+
import { useOnResize, useRenderer } from "@opentuah/react"
|
|
248
248
|
import { useEffect } from "react"
|
|
249
249
|
|
|
250
250
|
function App() {
|
|
@@ -267,7 +267,7 @@ function App() {
|
|
|
267
267
|
Get current terminal dimensions and automatically update when the terminal is resized.
|
|
268
268
|
|
|
269
269
|
```tsx
|
|
270
|
-
import { useTerminalDimensions } from "@
|
|
270
|
+
import { useTerminalDimensions } from "@opentuah/react"
|
|
271
271
|
|
|
272
272
|
function App() {
|
|
273
273
|
const { width, height } = useTerminalDimensions()
|
|
@@ -292,7 +292,7 @@ function App() {
|
|
|
292
292
|
Create and manage animations using OpenTUI's timeline system. This hook automatically registers and unregisters the timeline with the animation engine.
|
|
293
293
|
|
|
294
294
|
```tsx
|
|
295
|
-
import { useTimeline } from "@
|
|
295
|
+
import { useTimeline } from "@opentuah/react"
|
|
296
296
|
import { useEffect, useState } from "react"
|
|
297
297
|
|
|
298
298
|
function App() {
|
|
@@ -532,8 +532,8 @@ function App() {
|
|
|
532
532
|
#### Textarea Component
|
|
533
533
|
|
|
534
534
|
```tsx
|
|
535
|
-
import type { TextareaRenderable } from "@
|
|
536
|
-
import { useKeyboard, useRenderer } from "@
|
|
535
|
+
import type { TextareaRenderable } from "@opentuah/core"
|
|
536
|
+
import { useKeyboard, useRenderer } from "@opentuah/react"
|
|
537
537
|
import { useEffect, useRef } from "react"
|
|
538
538
|
|
|
539
539
|
function App() {
|
|
@@ -563,7 +563,7 @@ function App() {
|
|
|
563
563
|
Dropdown selection component.
|
|
564
564
|
|
|
565
565
|
```tsx
|
|
566
|
-
import type { SelectOption } from "@
|
|
566
|
+
import type { SelectOption } from "@opentuah/core"
|
|
567
567
|
import { useState } from "react"
|
|
568
568
|
|
|
569
569
|
function App() {
|
|
@@ -596,7 +596,7 @@ function App() {
|
|
|
596
596
|
#### Code Component
|
|
597
597
|
|
|
598
598
|
```tsx
|
|
599
|
-
import { RGBA, SyntaxStyle } from "@
|
|
599
|
+
import { RGBA, SyntaxStyle } from "@opentuah/core"
|
|
600
600
|
|
|
601
601
|
const syntaxStyle = SyntaxStyle.fromStyles({
|
|
602
602
|
keyword: { fg: RGBA.fromHex("#ff6b6b"), bold: true }, // red, bold
|
|
@@ -629,8 +629,8 @@ function App() {
|
|
|
629
629
|
Display code with line numbers, and optionally add diff highlights or diagnostic indicators.
|
|
630
630
|
|
|
631
631
|
```tsx
|
|
632
|
-
import type { LineNumberRenderable } from "@
|
|
633
|
-
import { RGBA, SyntaxStyle } from "@
|
|
632
|
+
import type { LineNumberRenderable } from "@opentuah/core"
|
|
633
|
+
import { RGBA, SyntaxStyle } from "@opentuah/core"
|
|
634
634
|
import { useEffect, useRef } from "react"
|
|
635
635
|
|
|
636
636
|
function App() {
|
|
@@ -691,8 +691,8 @@ For a complete interactive example with theme switching and keybindings, see [`e
|
|
|
691
691
|
### Login Form
|
|
692
692
|
|
|
693
693
|
```tsx
|
|
694
|
-
import { createCliRenderer } from "@
|
|
695
|
-
import { createRoot, useKeyboard } from "@
|
|
694
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
695
|
+
import { createRoot, useKeyboard } from "@opentuah/react"
|
|
696
696
|
import { useCallback, useState } from "react"
|
|
697
697
|
|
|
698
698
|
function App() {
|
|
@@ -755,8 +755,8 @@ createRoot(renderer).render(<App />)
|
|
|
755
755
|
### Counter with Timer
|
|
756
756
|
|
|
757
757
|
```tsx
|
|
758
|
-
import { createCliRenderer } from "@
|
|
759
|
-
import { createRoot } from "@
|
|
758
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
759
|
+
import { createRoot } from "@opentuah/react"
|
|
760
760
|
import { useEffect, useState } from "react"
|
|
761
761
|
|
|
762
762
|
function App() {
|
|
@@ -784,8 +784,8 @@ createRoot(renderer).render(<App />)
|
|
|
784
784
|
### System Monitor Animation
|
|
785
785
|
|
|
786
786
|
```tsx
|
|
787
|
-
import { createCliRenderer, TextAttributes } from "@
|
|
788
|
-
import { createRoot, useTimeline } from "@
|
|
787
|
+
import { createCliRenderer, TextAttributes } from "@opentuah/core"
|
|
788
|
+
import { createRoot, useTimeline } from "@opentuah/react"
|
|
789
789
|
import { useEffect, useState } from "react"
|
|
790
790
|
|
|
791
791
|
type Stats = {
|
|
@@ -868,8 +868,8 @@ createRoot(renderer).render(<App />)
|
|
|
868
868
|
### Styled Text Showcase
|
|
869
869
|
|
|
870
870
|
```tsx
|
|
871
|
-
import { createCliRenderer } from "@
|
|
872
|
-
import { createRoot } from "@
|
|
871
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
872
|
+
import { createRoot } from "@opentuah/react"
|
|
873
873
|
|
|
874
874
|
function App() {
|
|
875
875
|
return (
|
|
@@ -913,8 +913,8 @@ import {
|
|
|
913
913
|
RGBA,
|
|
914
914
|
type BoxOptions,
|
|
915
915
|
type RenderContext,
|
|
916
|
-
} from "@
|
|
917
|
-
import { createRoot, extend } from "@
|
|
916
|
+
} from "@opentuah/core"
|
|
917
|
+
import { createRoot, extend } from "@opentuah/react"
|
|
918
918
|
|
|
919
919
|
// Create custom component class
|
|
920
920
|
class ButtonRenderable extends BoxRenderable {
|
|
@@ -949,7 +949,7 @@ class ButtonRenderable extends BoxRenderable {
|
|
|
949
949
|
}
|
|
950
950
|
|
|
951
951
|
// Add TypeScript support
|
|
952
|
-
declare module "@
|
|
952
|
+
declare module "@opentuah/react" {
|
|
953
953
|
interface OpenTUIComponents {
|
|
954
954
|
consoleButton: typeof ButtonRenderable
|
|
955
955
|
}
|
|
@@ -163,7 +163,7 @@ import { TextNodeRenderable as TextNodeRenderable2 } from "@opentuah/core";
|
|
|
163
163
|
// package.json
|
|
164
164
|
var package_default = {
|
|
165
165
|
name: "@opentuah/react",
|
|
166
|
-
version: "0.1.
|
|
166
|
+
version: "0.1.80",
|
|
167
167
|
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
168
168
|
license: "MIT",
|
|
169
169
|
repository: {
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.80",
|
|
8
8
|
"description": "React renderer for building terminal user interfaces using OpenTUI core",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@opentuah/core": "0.1.
|
|
43
|
+
"@opentuah/core": "0.1.80",
|
|
44
44
|
"react-reconciler": "^0.32.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useRenderer: () => import("
|
|
1
|
+
export declare const useRenderer: () => import("@opentuah/core").CliRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useOnResize: (callback: (width: number, height: number) => void) => import("
|
|
1
|
+
export declare const useOnResize: (callback: (width: number, height: number) => void) => import("@opentuah/core").CliRenderer;
|
package/src/test-utils.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ export declare function testRender(node: ReactNode, testRendererOptions: TestRen
|
|
|
6
6
|
mockMouse: import("@opentuah/core/testing").MockMouse;
|
|
7
7
|
renderOnce: () => Promise<void>;
|
|
8
8
|
captureCharFrame: () => string;
|
|
9
|
-
captureSpans: () => import("
|
|
9
|
+
captureSpans: () => import("@opentuah/core").CapturedFrame;
|
|
10
10
|
resize: (width: number, height: number) => void;
|
|
11
11
|
}>;
|