@opentui/react 0.0.0-20250912-12c969f4 → 0.0.0-20250915-f5db043a

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 CHANGED
@@ -61,6 +61,10 @@ OpenTUI React provides several built-in components that map to OpenTUI core rend
61
61
  - **`<tab-select>`** - Tab-based selection
62
62
  - **`<ascii-font>`** - Display ASCII art text with different font styles
63
63
 
64
+ Helpers:
65
+
66
+ - **`<span>`, `<strong>`, `<em>`, `<u>`, `<b>`, `<i>`, `<br>`** - Text modifiers (_must be used inside of the text component_)
67
+
64
68
  ### Styling
65
69
 
66
70
  Components can be styled using props or the `style` prop:
@@ -191,8 +195,6 @@ function App() {
191
195
  Display text with rich formatting.
192
196
 
193
197
  ```tsx
194
- import { bold, fg, t } from "@opentui/core"
195
-
196
198
  function App() {
197
199
  return (
198
200
  <box>
@@ -200,10 +202,14 @@ function App() {
200
202
  <text>Hello World</text>
201
203
 
202
204
  {/* Rich text with children */}
203
- <text>{bold(fg("red")("Bold Red Text"))}</text>
205
+ <text>
206
+ <span fg="red">Red Text</span>
207
+ </text>
204
208
 
205
- {/* Template literals */}
206
- <text>{t`${bold("Bold")} and ${fg("blue")("Blue")}`}</text>
209
+ {/* Text modifiers */}
210
+ <text>
211
+ <strong>Bold</strong>, <em>Italic</em>, and <u>Underlined</u>
212
+ </text>
207
213
  </box>
208
214
  )
209
215
  }
@@ -501,20 +507,31 @@ render(<App />)
501
507
  ### Styled Text Showcase
502
508
 
503
509
  ```tsx
504
- import { blue, bold, red, t, underline } from "@opentui/core"
505
510
  import { render } from "@opentui/react"
506
511
 
507
512
  function App() {
508
513
  return (
509
- <box style={{ flexDirection: "column" }}>
514
+ <>
510
515
  <text>Simple text</text>
511
- <text>{bold("Bold text")}</text>
512
- <text>{underline("Underlined text")}</text>
513
- <text>{red("Red text")}</text>
514
- <text>{blue("Blue text")}</text>
515
- <text>{bold(red("Bold red text"))}</text>
516
- <text>{t`${bold("Bold")} and ${blue("blue")} combined`}</text>
517
- </box>
516
+ <text>
517
+ <strong>Bold text</strong>
518
+ </text>
519
+ <text>
520
+ <u>Underlined text</u>
521
+ </text>
522
+ <text>
523
+ <span fg="red">Red text</span>
524
+ </text>
525
+ <text>
526
+ <span fg="blue">Blue text</span>
527
+ </text>
528
+ <text>
529
+ <strong fg="red">Bold red text</strong>
530
+ </text>
531
+ <text>
532
+ <strong>Bold</strong> and <span fg="blue">blue</span> combined
533
+ </text>
534
+ </>
518
535
  )
519
536
  }
520
537
 
package/index.js CHANGED
@@ -12,7 +12,7 @@ import {
12
12
 
13
13
  // src/components/text.ts
14
14
  import { TextAttributes, TextNodeRenderable } from "@opentui/core";
15
- var textNodeKeys = ["span", "b", "strong", "i", "em", "u"];
15
+ var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br"];
16
16
 
17
17
  class SpanRenderable extends TextNodeRenderable {
18
18
  ctx;
@@ -36,23 +36,34 @@ class TextModifierRenderable extends SpanRenderable {
36
36
  }
37
37
 
38
38
  class BoldSpanRenderable extends TextModifierRenderable {
39
- constructor(options) {
39
+ constructor(_ctx, options) {
40
40
  super(options, "b");
41
41
  }
42
42
  }
43
43
 
44
44
  class ItalicSpanRenderable extends TextModifierRenderable {
45
- constructor(options) {
45
+ constructor(_ctx, options) {
46
46
  super(options, "i");
47
47
  }
48
48
  }
49
49
 
50
50
  class UnderlineSpanRenderable extends TextModifierRenderable {
51
- constructor(options) {
51
+ constructor(_ctx, options) {
52
52
  super(options, "u");
53
53
  }
54
54
  }
55
55
 
56
+ class LineBreakRenderable extends SpanRenderable {
57
+ constructor(_ctx, options) {
58
+ super(null, options);
59
+ this.add();
60
+ }
61
+ add() {
62
+ return super.add(`
63
+ `);
64
+ }
65
+ }
66
+
56
67
  // src/components/index.ts
57
68
  var baseComponents = {
58
69
  box: BoxRenderable,
@@ -63,6 +74,7 @@ var baseComponents = {
63
74
  "ascii-font": ASCIIFontRenderable,
64
75
  "tab-select": TabSelectRenderable,
65
76
  span: SpanRenderable,
77
+ br: LineBreakRenderable,
66
78
  b: BoldSpanRenderable,
67
79
  strong: BoldSpanRenderable,
68
80
  i: ItalicSpanRenderable,
@@ -326,7 +338,7 @@ var hostConfig = {
326
338
  return { isInsideText: false };
327
339
  },
328
340
  getChildHostContext(parentHostContext, type, rootContainerInstance) {
329
- const isInsideText = ["text", "span", "b", "strong", "i", "em", "u"].includes(type);
341
+ const isInsideText = ["text", ...textNodeKeys].includes(type);
330
342
  return { ...parentHostContext, isInsideText };
331
343
  },
332
344
  shouldSetTextContent(type, props) {
@@ -4,6 +4,7 @@ import type {
4
4
  BoxProps,
5
5
  ExtendedIntrinsicElements,
6
6
  InputProps,
7
+ LineBreakProps,
7
8
  OpenTUIComponents,
8
9
  ScrollBoxProps,
9
10
  SelectProps,
@@ -42,5 +43,6 @@ export namespace JSX {
42
43
  u: SpanProps
43
44
  strong: SpanProps
44
45
  em: SpanProps
46
+ br: LineBreakProps
45
47
  }
46
48
  }
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.0.0-20250912-12c969f4",
7
+ "version": "0.0.0-20250915-f5db043a",
8
8
  "description": "React renderer for building terminal user interfaces using OpenTUI core",
9
9
  "license": "MIT",
10
10
  "repository": {
@@ -35,7 +35,7 @@
35
35
  }
36
36
  },
37
37
  "dependencies": {
38
- "@opentui/core": "0.0.0-20250912-12c969f4",
38
+ "@opentui/core": "0.0.0-20250915-f5db043a",
39
39
  "react-reconciler": "^0.32.0"
40
40
  },
41
41
  "devDependencies": {
@@ -1,6 +1,6 @@
1
1
  import { ASCIIFontRenderable, BoxRenderable, InputRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextRenderable } from "@opentui/core";
2
2
  import type { RenderableConstructor } from "../types/components";
3
- import { BoldSpanRenderable, ItalicSpanRenderable, SpanRenderable, UnderlineSpanRenderable } from "./text";
3
+ import { BoldSpanRenderable, ItalicSpanRenderable, LineBreakRenderable, SpanRenderable, UnderlineSpanRenderable } from "./text";
4
4
  export declare const baseComponents: {
5
5
  box: typeof BoxRenderable;
6
6
  text: typeof TextRenderable;
@@ -10,6 +10,7 @@ export declare const baseComponents: {
10
10
  "ascii-font": typeof ASCIIFontRenderable;
11
11
  "tab-select": typeof TabSelectRenderable;
12
12
  span: typeof SpanRenderable;
13
+ br: typeof LineBreakRenderable;
13
14
  b: typeof BoldSpanRenderable;
14
15
  strong: typeof BoldSpanRenderable;
15
16
  i: typeof ItalicSpanRenderable;
@@ -1,20 +1,24 @@
1
1
  import { TextNodeRenderable, type RenderContext, type TextNodeOptions } from "@opentui/core";
2
- export declare const textNodeKeys: readonly ["span", "b", "strong", "i", "em", "u"];
2
+ export declare const textNodeKeys: readonly ["span", "b", "strong", "i", "em", "u", "br"];
3
3
  export type TextNodeKey = (typeof textNodeKeys)[number];
4
4
  export declare class SpanRenderable extends TextNodeRenderable {
5
5
  private readonly ctx;
6
6
  constructor(ctx: RenderContext | null, options: TextNodeOptions);
7
7
  }
8
8
  declare class TextModifierRenderable extends SpanRenderable {
9
- constructor(options: any, modifier?: TextNodeKey);
9
+ constructor(options: TextNodeOptions, modifier?: TextNodeKey);
10
10
  }
11
11
  export declare class BoldSpanRenderable extends TextModifierRenderable {
12
- constructor(options: any);
12
+ constructor(_ctx: RenderContext | null, options: TextNodeOptions);
13
13
  }
14
14
  export declare class ItalicSpanRenderable extends TextModifierRenderable {
15
- constructor(options: any);
15
+ constructor(_ctx: RenderContext | null, options: TextNodeOptions);
16
16
  }
17
17
  export declare class UnderlineSpanRenderable extends TextModifierRenderable {
18
- constructor(options: any);
18
+ constructor(_ctx: RenderContext | null, options: TextNodeOptions);
19
+ }
20
+ export declare class LineBreakRenderable extends SpanRenderable {
21
+ constructor(_ctx: RenderContext | null, options: TextNodeOptions);
22
+ add(): number;
19
23
  }
20
24
  export {};
@@ -32,7 +32,7 @@ import {
32
32
 
33
33
  // src/components/text.ts
34
34
  import { TextAttributes, TextNodeRenderable } from "@opentui/core";
35
- var textNodeKeys = ["span", "b", "strong", "i", "em", "u"];
35
+ var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br"];
36
36
 
37
37
  class SpanRenderable extends TextNodeRenderable {
38
38
  ctx;
@@ -56,23 +56,34 @@ class TextModifierRenderable extends SpanRenderable {
56
56
  }
57
57
 
58
58
  class BoldSpanRenderable extends TextModifierRenderable {
59
- constructor(options) {
59
+ constructor(_ctx, options) {
60
60
  super(options, "b");
61
61
  }
62
62
  }
63
63
 
64
64
  class ItalicSpanRenderable extends TextModifierRenderable {
65
- constructor(options) {
65
+ constructor(_ctx, options) {
66
66
  super(options, "i");
67
67
  }
68
68
  }
69
69
 
70
70
  class UnderlineSpanRenderable extends TextModifierRenderable {
71
- constructor(options) {
71
+ constructor(_ctx, options) {
72
72
  super(options, "u");
73
73
  }
74
74
  }
75
75
 
76
+ class LineBreakRenderable extends SpanRenderable {
77
+ constructor(_ctx, options) {
78
+ super(null, options);
79
+ this.add();
80
+ }
81
+ add() {
82
+ return super.add(`
83
+ `);
84
+ }
85
+ }
86
+
76
87
  // src/components/index.ts
77
88
  var baseComponents = {
78
89
  box: BoxRenderable,
@@ -83,6 +94,7 @@ var baseComponents = {
83
94
  "ascii-font": ASCIIFontRenderable,
84
95
  "tab-select": TabSelectRenderable,
85
96
  span: SpanRenderable,
97
+ br: LineBreakRenderable,
86
98
  b: BoldSpanRenderable,
87
99
  strong: BoldSpanRenderable,
88
100
  i: ItalicSpanRenderable,
@@ -261,7 +273,7 @@ var hostConfig = {
261
273
  return { isInsideText: false };
262
274
  },
263
275
  getChildHostContext(parentHostContext, type, rootContainerInstance) {
264
- const isInsideText = ["text", "span", "b", "strong", "i", "em", "u"].includes(type);
276
+ const isInsideText = ["text", ...textNodeKeys].includes(type);
265
277
  return { ...parentHostContext, isInsideText };
266
278
  },
267
279
  shouldSetTextContent(type, props) {
@@ -31,6 +31,7 @@ export type TextProps = ComponentProps<TextOptions, TextRenderable> & {
31
31
  export type SpanProps = ComponentProps<TextNodeOptions, TextNodeRenderable> & {
32
32
  children?: TextChildren;
33
33
  };
34
+ export type LineBreakProps = Pick<SpanProps, "id">;
34
35
  export type BoxProps = ComponentProps<ContainerProps<BoxOptions>, BoxRenderable>;
35
36
  export type InputProps = ComponentProps<InputRenderableOptions, InputRenderable> & {
36
37
  focused?: boolean;