@opentui/react 0.1.74 → 0.1.75
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 +1 -1
- package/{src/reconciler/renderer.js → chunk-j5j59zk3.js} +120 -115
- package/index.js +11 -566
- package/jsx-namespace.d.ts +2 -0
- package/package.json +6 -6
- package/src/components/index.d.ts +2 -1
- package/src/test-utils.d.ts +1 -0
- package/src/types/components.d.ts +3 -2
- package/test-utils.js +39 -0
- package/src/reconciler/chunk-e11q5a3p.js +0 -20
- package/src/reconciler/chunk-fcedq94e.js +0 -29
- package/src/test-utils/chunk-e11q5a3p.js +0 -20
- package/src/test-utils/chunk-fcedq94e.js +0 -29
- package/src/test-utils/test-utils.js +0 -598
package/README.md
CHANGED
|
@@ -4,9 +4,116 @@ import {
|
|
|
4
4
|
__toESM
|
|
5
5
|
} from "./chunk-e11q5a3p.js";
|
|
6
6
|
|
|
7
|
-
// src/
|
|
8
|
-
import {
|
|
9
|
-
|
|
7
|
+
// src/components/index.ts
|
|
8
|
+
import {
|
|
9
|
+
ASCIIFontRenderable,
|
|
10
|
+
BoxRenderable,
|
|
11
|
+
CodeRenderable,
|
|
12
|
+
DiffRenderable,
|
|
13
|
+
InputRenderable,
|
|
14
|
+
LineNumberRenderable,
|
|
15
|
+
MarkdownRenderable,
|
|
16
|
+
ScrollBoxRenderable,
|
|
17
|
+
SelectRenderable,
|
|
18
|
+
TabSelectRenderable,
|
|
19
|
+
TextareaRenderable,
|
|
20
|
+
TextRenderable
|
|
21
|
+
} from "@opentui/core";
|
|
22
|
+
|
|
23
|
+
// src/components/text.ts
|
|
24
|
+
import { TextAttributes, TextNodeRenderable } from "@opentui/core";
|
|
25
|
+
var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br", "a"];
|
|
26
|
+
|
|
27
|
+
class SpanRenderable extends TextNodeRenderable {
|
|
28
|
+
ctx;
|
|
29
|
+
constructor(ctx, options) {
|
|
30
|
+
super(options);
|
|
31
|
+
this.ctx = ctx;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
class TextModifierRenderable extends SpanRenderable {
|
|
36
|
+
constructor(options, modifier) {
|
|
37
|
+
super(null, options);
|
|
38
|
+
if (modifier === "b" || modifier === "strong") {
|
|
39
|
+
this.attributes = (this.attributes || 0) | TextAttributes.BOLD;
|
|
40
|
+
} else if (modifier === "i" || modifier === "em") {
|
|
41
|
+
this.attributes = (this.attributes || 0) | TextAttributes.ITALIC;
|
|
42
|
+
} else if (modifier === "u") {
|
|
43
|
+
this.attributes = (this.attributes || 0) | TextAttributes.UNDERLINE;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class BoldSpanRenderable extends TextModifierRenderable {
|
|
49
|
+
constructor(_ctx, options) {
|
|
50
|
+
super(options, "b");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
class ItalicSpanRenderable extends TextModifierRenderable {
|
|
55
|
+
constructor(_ctx, options) {
|
|
56
|
+
super(options, "i");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class UnderlineSpanRenderable extends TextModifierRenderable {
|
|
61
|
+
constructor(_ctx, options) {
|
|
62
|
+
super(options, "u");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class LineBreakRenderable extends SpanRenderable {
|
|
67
|
+
constructor(_ctx, options) {
|
|
68
|
+
super(null, options);
|
|
69
|
+
this.add();
|
|
70
|
+
}
|
|
71
|
+
add() {
|
|
72
|
+
return super.add(`
|
|
73
|
+
`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class LinkRenderable extends SpanRenderable {
|
|
78
|
+
constructor(_ctx, options) {
|
|
79
|
+
const linkOptions = {
|
|
80
|
+
...options,
|
|
81
|
+
link: { url: options.href }
|
|
82
|
+
};
|
|
83
|
+
super(null, linkOptions);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/components/index.ts
|
|
88
|
+
var baseComponents = {
|
|
89
|
+
box: BoxRenderable,
|
|
90
|
+
text: TextRenderable,
|
|
91
|
+
code: CodeRenderable,
|
|
92
|
+
diff: DiffRenderable,
|
|
93
|
+
markdown: MarkdownRenderable,
|
|
94
|
+
input: InputRenderable,
|
|
95
|
+
select: SelectRenderable,
|
|
96
|
+
textarea: TextareaRenderable,
|
|
97
|
+
scrollbox: ScrollBoxRenderable,
|
|
98
|
+
"ascii-font": ASCIIFontRenderable,
|
|
99
|
+
"tab-select": TabSelectRenderable,
|
|
100
|
+
"line-number": LineNumberRenderable,
|
|
101
|
+
span: SpanRenderable,
|
|
102
|
+
br: LineBreakRenderable,
|
|
103
|
+
b: BoldSpanRenderable,
|
|
104
|
+
strong: BoldSpanRenderable,
|
|
105
|
+
i: ItalicSpanRenderable,
|
|
106
|
+
em: ItalicSpanRenderable,
|
|
107
|
+
u: UnderlineSpanRenderable,
|
|
108
|
+
a: LinkRenderable
|
|
109
|
+
};
|
|
110
|
+
var componentCatalogue = { ...baseComponents };
|
|
111
|
+
function extend(objects) {
|
|
112
|
+
Object.assign(componentCatalogue, objects);
|
|
113
|
+
}
|
|
114
|
+
function getComponentCatalogue() {
|
|
115
|
+
return componentCatalogue;
|
|
116
|
+
}
|
|
10
117
|
|
|
11
118
|
// src/components/app.tsx
|
|
12
119
|
import { createContext, useContext } from "react";
|
|
@@ -14,6 +121,13 @@ var AppContext = createContext({
|
|
|
14
121
|
keyHandler: null,
|
|
15
122
|
renderer: null
|
|
16
123
|
});
|
|
124
|
+
var useAppContext = () => {
|
|
125
|
+
return useContext(AppContext);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// src/reconciler/renderer.ts
|
|
129
|
+
import { CliRenderEvents, engine } from "@opentui/core";
|
|
130
|
+
import React2 from "react";
|
|
17
131
|
|
|
18
132
|
// src/components/error-boundary.tsx
|
|
19
133
|
import React from "react";
|
|
@@ -53,7 +167,7 @@ import { TextNodeRenderable as TextNodeRenderable2 } from "@opentui/core";
|
|
|
53
167
|
// package.json
|
|
54
168
|
var package_default = {
|
|
55
169
|
name: "@opentui/react",
|
|
56
|
-
version: "0.1.
|
|
170
|
+
version: "0.1.75",
|
|
57
171
|
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
58
172
|
license: "MIT",
|
|
59
173
|
repository: {
|
|
@@ -123,112 +237,6 @@ var package_default = {
|
|
|
123
237
|
import { createContext as createContext2 } from "react";
|
|
124
238
|
import { DefaultEventPriority, NoEventPriority } from "react-reconciler/constants";
|
|
125
239
|
|
|
126
|
-
// src/components/index.ts
|
|
127
|
-
import {
|
|
128
|
-
ASCIIFontRenderable,
|
|
129
|
-
BoxRenderable,
|
|
130
|
-
CodeRenderable,
|
|
131
|
-
DiffRenderable,
|
|
132
|
-
InputRenderable,
|
|
133
|
-
LineNumberRenderable,
|
|
134
|
-
ScrollBoxRenderable,
|
|
135
|
-
SelectRenderable,
|
|
136
|
-
TabSelectRenderable,
|
|
137
|
-
TextareaRenderable,
|
|
138
|
-
TextRenderable
|
|
139
|
-
} from "@opentui/core";
|
|
140
|
-
|
|
141
|
-
// src/components/text.ts
|
|
142
|
-
import { TextAttributes, TextNodeRenderable } from "@opentui/core";
|
|
143
|
-
var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br", "a"];
|
|
144
|
-
|
|
145
|
-
class SpanRenderable extends TextNodeRenderable {
|
|
146
|
-
ctx;
|
|
147
|
-
constructor(ctx, options) {
|
|
148
|
-
super(options);
|
|
149
|
-
this.ctx = ctx;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
class TextModifierRenderable extends SpanRenderable {
|
|
154
|
-
constructor(options, modifier) {
|
|
155
|
-
super(null, options);
|
|
156
|
-
if (modifier === "b" || modifier === "strong") {
|
|
157
|
-
this.attributes = (this.attributes || 0) | TextAttributes.BOLD;
|
|
158
|
-
} else if (modifier === "i" || modifier === "em") {
|
|
159
|
-
this.attributes = (this.attributes || 0) | TextAttributes.ITALIC;
|
|
160
|
-
} else if (modifier === "u") {
|
|
161
|
-
this.attributes = (this.attributes || 0) | TextAttributes.UNDERLINE;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
class BoldSpanRenderable extends TextModifierRenderable {
|
|
167
|
-
constructor(_ctx, options) {
|
|
168
|
-
super(options, "b");
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
class ItalicSpanRenderable extends TextModifierRenderable {
|
|
173
|
-
constructor(_ctx, options) {
|
|
174
|
-
super(options, "i");
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
class UnderlineSpanRenderable extends TextModifierRenderable {
|
|
179
|
-
constructor(_ctx, options) {
|
|
180
|
-
super(options, "u");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
class LineBreakRenderable extends SpanRenderable {
|
|
185
|
-
constructor(_ctx, options) {
|
|
186
|
-
super(null, options);
|
|
187
|
-
this.add();
|
|
188
|
-
}
|
|
189
|
-
add() {
|
|
190
|
-
return super.add(`
|
|
191
|
-
`);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
class LinkRenderable extends SpanRenderable {
|
|
196
|
-
constructor(_ctx, options) {
|
|
197
|
-
const linkOptions = {
|
|
198
|
-
...options,
|
|
199
|
-
link: { url: options.href }
|
|
200
|
-
};
|
|
201
|
-
super(null, linkOptions);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// src/components/index.ts
|
|
206
|
-
var baseComponents = {
|
|
207
|
-
box: BoxRenderable,
|
|
208
|
-
text: TextRenderable,
|
|
209
|
-
code: CodeRenderable,
|
|
210
|
-
diff: DiffRenderable,
|
|
211
|
-
input: InputRenderable,
|
|
212
|
-
select: SelectRenderable,
|
|
213
|
-
textarea: TextareaRenderable,
|
|
214
|
-
scrollbox: ScrollBoxRenderable,
|
|
215
|
-
"ascii-font": ASCIIFontRenderable,
|
|
216
|
-
"tab-select": TabSelectRenderable,
|
|
217
|
-
"line-number": LineNumberRenderable,
|
|
218
|
-
span: SpanRenderable,
|
|
219
|
-
br: LineBreakRenderable,
|
|
220
|
-
b: BoldSpanRenderable,
|
|
221
|
-
strong: BoldSpanRenderable,
|
|
222
|
-
i: ItalicSpanRenderable,
|
|
223
|
-
em: ItalicSpanRenderable,
|
|
224
|
-
u: UnderlineSpanRenderable,
|
|
225
|
-
a: LinkRenderable
|
|
226
|
-
};
|
|
227
|
-
var componentCatalogue = { ...baseComponents };
|
|
228
|
-
function getComponentCatalogue() {
|
|
229
|
-
return componentCatalogue;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
240
|
// src/utils/id.ts
|
|
233
241
|
var idCounter = new Map;
|
|
234
242
|
function getNextId(type) {
|
|
@@ -561,8 +569,5 @@ function createRoot(renderer) {
|
|
|
561
569
|
unmount: cleanup
|
|
562
570
|
};
|
|
563
571
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
createRoot,
|
|
567
|
-
createPortal
|
|
568
|
-
};
|
|
572
|
+
|
|
573
|
+
export { baseComponents, componentCatalogue, extend, getComponentCatalogue, AppContext, useAppContext, flushSync, createPortal, createRoot };
|