@opentui/react 0.1.10 → 0.1.12

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
@@ -1,6 +1,6 @@
1
1
  # @opentui/react
2
2
 
3
- A React renderer for building terminal user interfaces using OpenTUI core. Create rich, interactive console applications with familiar React patterns and components.
3
+ A React renderer for building terminal user interfaces using [OpenTUI core](https://github.com/sst/opentui). Create rich, interactive console applications with familiar React patterns and components.
4
4
 
5
5
  ## Installation
6
6
 
@@ -148,7 +148,9 @@ function MyComponent() {
148
148
 
149
149
  return (
150
150
  <group>
151
- <text>Terminal dimensions: {width}x{height}</text>
151
+ <text>
152
+ Terminal dimensions: {width}x{height}
153
+ </text>
152
154
  <box style={{ width: Math.floor(width / 2), height: Math.floor(height / 3) }}>
153
155
  <text>Half-width, third-height box</text>
154
156
  </box>
package/index.js CHANGED
@@ -268,7 +268,7 @@ var hostConfig = {
268
268
  if (!components[type]) {
269
269
  throw new Error(`[Reconciler] Unknown component type: ${type}`);
270
270
  }
271
- return new components[type](id, {});
271
+ return new components[type](rootContainerInstance.ctx, {});
272
272
  },
273
273
  appendChild(parent, child) {
274
274
  parent.add(child);
@@ -305,7 +305,8 @@ var hostConfig = {
305
305
  },
306
306
  createTextInstance(text, rootContainerInstance, hostContext) {
307
307
  const components = getComponentCatalogue();
308
- return new components["text"](getNextId("text"), {
308
+ return new components["text"](rootContainerInstance.ctx, {
309
+ id: getNextId("text"),
309
310
  content: text
310
311
  });
311
312
  },
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.10",
7
+ "version": "0.1.12",
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.1.10",
38
+ "@opentui/core": "0.1.12",
39
39
  "react-reconciler": "^0.32.0"
40
40
  },
41
41
  "devDependencies": {
@@ -219,7 +219,7 @@ var hostConfig = {
219
219
  if (!components[type]) {
220
220
  throw new Error(`[Reconciler] Unknown component type: ${type}`);
221
221
  }
222
- return new components[type](id, {});
222
+ return new components[type](rootContainerInstance.ctx, {});
223
223
  },
224
224
  appendChild(parent, child) {
225
225
  parent.add(child);
@@ -256,7 +256,8 @@ var hostConfig = {
256
256
  },
257
257
  createTextInstance(text, rootContainerInstance, hostContext) {
258
258
  const components = getComponentCatalogue();
259
- return new components["text"](getNextId("text"), {
259
+ return new components["text"](rootContainerInstance.ctx, {
260
+ id: getNextId("text"),
260
261
  content: text
261
262
  });
262
263
  },
@@ -1,26 +1,26 @@
1
- import type { ASCIIFontOptions, ASCIIFontRenderable, BoxOptions, BoxRenderable, GroupRenderable, InputRenderable, InputRenderableOptions, Renderable, RenderableOptions, SelectOption, SelectRenderable, SelectRenderableOptions, StyledText, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextChunk, TextOptions, TextRenderable } from "@opentui/core";
1
+ import type { ASCIIFontOptions, ASCIIFontRenderable, BoxOptions, BoxRenderable, GroupRenderable, InputRenderable, InputRenderableOptions, Renderable, RenderableOptions, RenderContext, SelectOption, SelectRenderable, SelectRenderableOptions, StyledText, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextChunk, TextOptions, TextRenderable } from "@opentui/core";
2
2
  import type React from "react";
3
3
  /** Properties that should not be included in the style prop */
4
- export type NonStyledProps = "buffered" | "live" | "enableLayout" | "selectable";
4
+ export type NonStyledProps = "id" | "buffered" | "live" | "enableLayout" | "selectable" | "renderAfter" | "renderBefore" | `on${string}`;
5
5
  /** React-specific props for all components */
6
6
  export type ReactProps<TRenderable = unknown> = {
7
7
  key?: React.Key;
8
8
  ref?: React.Ref<TRenderable>;
9
9
  };
10
10
  /** Base type for any renderable constructor */
11
- export type RenderableConstructor<TRenderable extends Renderable = Renderable> = new (id: string, options: any) => TRenderable;
11
+ export type RenderableConstructor<TRenderable extends Renderable = Renderable> = new (ctx: RenderContext, options: any) => TRenderable;
12
12
  /** Extract the options type from a renderable constructor */
13
- type ExtractRenderableOptions<TConstructor> = TConstructor extends new (id: string, options: infer TOptions) => any ? TOptions : never;
13
+ type ExtractRenderableOptions<TConstructor> = TConstructor extends new (ctx: RenderContext, options: infer TOptions) => any ? TOptions : never;
14
14
  /** Extract the renderable type from a constructor */
15
- type ExtractRenderable<TConstructor> = TConstructor extends new (id: string, options: any) => infer TRenderable ? TRenderable : never;
15
+ type ExtractRenderable<TConstructor> = TConstructor extends new (ctx: RenderContext, options: any) => infer TRenderable ? TRenderable : never;
16
16
  /** Determine which properties should be excluded from styling for different renderable types */
17
- export type GetNonStyledProperties<TConstructor> = TConstructor extends RenderableConstructor<TextRenderable> ? NonStyledProps | "content" : TConstructor extends RenderableConstructor<BoxRenderable> ? NonStyledProps | "title" : TConstructor extends RenderableConstructor<ASCIIFontRenderable> ? NonStyledProps | "text" | "selectable" : NonStyledProps;
17
+ export type GetNonStyledProperties<TConstructor> = TConstructor extends RenderableConstructor<TextRenderable> ? NonStyledProps | "content" : TConstructor extends RenderableConstructor<BoxRenderable> ? NonStyledProps | "title" : TConstructor extends RenderableConstructor<ASCIIFontRenderable> ? NonStyledProps | "text" | "selectable" : TConstructor extends RenderableConstructor<InputRenderable> ? NonStyledProps | "placeholder" | "value" : NonStyledProps;
18
18
  /** Base props for container components that accept children */
19
19
  type ContainerProps<TOptions> = TOptions & {
20
20
  children?: React.ReactNode;
21
21
  };
22
22
  /** Smart component props that automatically determine excluded properties */
23
- type ComponentProps<TOptions extends RenderableOptions, TRenderable extends Renderable> = TOptions & {
23
+ type ComponentProps<TOptions extends RenderableOptions<TRenderable>, TRenderable extends Renderable> = TOptions & {
24
24
  style?: Partial<Omit<TOptions, GetNonStyledProperties<RenderableConstructor<TRenderable>>>>;
25
25
  } & ReactProps<TRenderable>;
26
26
  /** Valid text content types for Text component children */