@dealdeploy/skl 0.1.7 → 0.1.8
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/.agents/skills/opentui/SKILL.md +198 -0
- package/.agents/skills/opentui/references/animation/REFERENCE.md +431 -0
- package/.agents/skills/opentui/references/components/REFERENCE.md +143 -0
- package/.agents/skills/opentui/references/components/code-diff.md +496 -0
- package/.agents/skills/opentui/references/components/containers.md +412 -0
- package/.agents/skills/opentui/references/components/inputs.md +531 -0
- package/.agents/skills/opentui/references/components/text-display.md +384 -0
- package/.agents/skills/opentui/references/core/REFERENCE.md +145 -0
- package/.agents/skills/opentui/references/core/api.md +506 -0
- package/.agents/skills/opentui/references/core/configuration.md +166 -0
- package/.agents/skills/opentui/references/core/gotchas.md +393 -0
- package/.agents/skills/opentui/references/core/patterns.md +448 -0
- package/.agents/skills/opentui/references/keyboard/REFERENCE.md +511 -0
- package/.agents/skills/opentui/references/layout/REFERENCE.md +337 -0
- package/.agents/skills/opentui/references/layout/patterns.md +444 -0
- package/.agents/skills/opentui/references/react/REFERENCE.md +174 -0
- package/.agents/skills/opentui/references/react/api.md +435 -0
- package/.agents/skills/opentui/references/react/configuration.md +301 -0
- package/.agents/skills/opentui/references/react/gotchas.md +443 -0
- package/.agents/skills/opentui/references/react/patterns.md +501 -0
- package/.agents/skills/opentui/references/solid/REFERENCE.md +201 -0
- package/.agents/skills/opentui/references/solid/api.md +543 -0
- package/.agents/skills/opentui/references/solid/configuration.md +315 -0
- package/.agents/skills/opentui/references/solid/gotchas.md +415 -0
- package/.agents/skills/opentui/references/solid/patterns.md +558 -0
- package/.agents/skills/opentui/references/testing/REFERENCE.md +614 -0
- package/.claude/settings.local.json +11 -0
- package/.claude/skills/opentui/SKILL.md +198 -0
- package/.claude/skills/opentui/references/animation/REFERENCE.md +431 -0
- package/.claude/skills/opentui/references/components/REFERENCE.md +143 -0
- package/.claude/skills/opentui/references/components/code-diff.md +496 -0
- package/.claude/skills/opentui/references/components/containers.md +412 -0
- package/.claude/skills/opentui/references/components/inputs.md +531 -0
- package/.claude/skills/opentui/references/components/text-display.md +384 -0
- package/.claude/skills/opentui/references/core/REFERENCE.md +145 -0
- package/.claude/skills/opentui/references/core/api.md +506 -0
- package/.claude/skills/opentui/references/core/configuration.md +166 -0
- package/.claude/skills/opentui/references/core/gotchas.md +393 -0
- package/.claude/skills/opentui/references/core/patterns.md +448 -0
- package/.claude/skills/opentui/references/keyboard/REFERENCE.md +511 -0
- package/.claude/skills/opentui/references/layout/REFERENCE.md +337 -0
- package/.claude/skills/opentui/references/layout/patterns.md +444 -0
- package/.claude/skills/opentui/references/react/REFERENCE.md +174 -0
- package/.claude/skills/opentui/references/react/api.md +435 -0
- package/.claude/skills/opentui/references/react/configuration.md +301 -0
- package/.claude/skills/opentui/references/react/gotchas.md +443 -0
- package/.claude/skills/opentui/references/react/patterns.md +501 -0
- package/.claude/skills/opentui/references/solid/REFERENCE.md +201 -0
- package/.claude/skills/opentui/references/solid/api.md +543 -0
- package/.claude/skills/opentui/references/solid/configuration.md +315 -0
- package/.claude/skills/opentui/references/solid/gotchas.md +415 -0
- package/.claude/skills/opentui/references/solid/patterns.md +558 -0
- package/.claude/skills/opentui/references/testing/REFERENCE.md +614 -0
- package/bun.lock +0 -1
- package/index.ts +163 -38
- package/package.json +1 -1
- package/update.ts +87 -0
|
@@ -0,0 +1,543 @@
|
|
|
1
|
+
# Solid API Reference
|
|
2
|
+
|
|
3
|
+
## Rendering
|
|
4
|
+
|
|
5
|
+
### render(node, rendererOrConfig?)
|
|
6
|
+
|
|
7
|
+
Renders a Solid component tree into a CLI renderer.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { render } from "@opentui/solid"
|
|
11
|
+
|
|
12
|
+
// Simple usage - creates renderer automatically
|
|
13
|
+
render(() => <App />)
|
|
14
|
+
|
|
15
|
+
// With config
|
|
16
|
+
render(() => <App />, {
|
|
17
|
+
exitOnCtrlC: false,
|
|
18
|
+
targetFPS: 60,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// With existing renderer
|
|
22
|
+
import { createCliRenderer } from "@opentui/core"
|
|
23
|
+
|
|
24
|
+
const renderer = await createCliRenderer()
|
|
25
|
+
render(() => <App />, renderer)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### testRender(node, options?)
|
|
29
|
+
|
|
30
|
+
Create a test renderer for snapshots and tests.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { testRender } from "@opentui/solid"
|
|
34
|
+
|
|
35
|
+
const testSetup = await testRender(() => <App />, {
|
|
36
|
+
width: 40,
|
|
37
|
+
height: 10,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Access test utilities
|
|
41
|
+
testSetup.snapshot() // Get current render
|
|
42
|
+
testSetup.renderer // Access renderer
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### extend(components)
|
|
46
|
+
|
|
47
|
+
Register custom renderables as JSX intrinsic elements.
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
import { extend } from "@opentui/solid"
|
|
51
|
+
import { CustomRenderable } from "./custom"
|
|
52
|
+
|
|
53
|
+
extend({
|
|
54
|
+
custom: CustomRenderable,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// Now usable in JSX
|
|
58
|
+
<custom prop="value" />
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### getComponentCatalogue()
|
|
62
|
+
|
|
63
|
+
Returns the current component catalogue.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { getComponentCatalogue } from "@opentui/solid"
|
|
67
|
+
|
|
68
|
+
const catalogue = getComponentCatalogue()
|
|
69
|
+
console.log(Object.keys(catalogue))
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Hooks
|
|
73
|
+
|
|
74
|
+
### useRenderer()
|
|
75
|
+
|
|
76
|
+
Access the OpenTUI renderer instance.
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { useRenderer } from "@opentui/solid"
|
|
80
|
+
import { onMount } from "solid-js"
|
|
81
|
+
|
|
82
|
+
function App() {
|
|
83
|
+
const renderer = useRenderer()
|
|
84
|
+
|
|
85
|
+
onMount(() => {
|
|
86
|
+
console.log(`Terminal: ${renderer.width}x${renderer.height}`)
|
|
87
|
+
renderer.console.show()
|
|
88
|
+
|
|
89
|
+
// Access theme mode (dark/light based on terminal settings)
|
|
90
|
+
console.log(`Theme: ${renderer.themeMode}`) // "dark" | "light" | null
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
return <text>Hello</text>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Listen for theme mode changes
|
|
97
|
+
function ThemedApp() {
|
|
98
|
+
const renderer = useRenderer()
|
|
99
|
+
const [theme, setTheme] = createSignal(renderer.themeMode ?? "dark")
|
|
100
|
+
|
|
101
|
+
onMount(() => {
|
|
102
|
+
renderer.on("theme_mode", (mode: "dark" | "light") => setTheme(mode))
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
return (
|
|
106
|
+
<box backgroundColor={theme() === "dark" ? "#1a1a2e" : "#ffffff"}>
|
|
107
|
+
<text fg={theme() === "dark" ? "#fff" : "#000"}>
|
|
108
|
+
Current theme: {theme()}
|
|
109
|
+
</text>
|
|
110
|
+
</box>
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### useKeyboard(handler, options?)
|
|
116
|
+
|
|
117
|
+
Handle keyboard events.
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
import { useKeyboard, useRenderer } from "@opentui/solid"
|
|
121
|
+
|
|
122
|
+
function App() {
|
|
123
|
+
const renderer = useRenderer()
|
|
124
|
+
|
|
125
|
+
useKeyboard((key) => {
|
|
126
|
+
if (key.name === "escape") {
|
|
127
|
+
renderer.destroy() // Never use process.exit() directly!
|
|
128
|
+
}
|
|
129
|
+
if (key.ctrl && key.name === "s") {
|
|
130
|
+
saveDocument()
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
return <text>Press ESC to exit</text>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// With release events
|
|
138
|
+
function GameControls() {
|
|
139
|
+
const [pressed, setPressed] = createSignal(new Set<string>())
|
|
140
|
+
|
|
141
|
+
useKeyboard(
|
|
142
|
+
(event) => {
|
|
143
|
+
setPressed(keys => {
|
|
144
|
+
const newKeys = new Set(keys)
|
|
145
|
+
if (event.eventType === "release") {
|
|
146
|
+
newKeys.delete(event.name)
|
|
147
|
+
} else {
|
|
148
|
+
newKeys.add(event.name)
|
|
149
|
+
}
|
|
150
|
+
return newKeys
|
|
151
|
+
})
|
|
152
|
+
},
|
|
153
|
+
{ release: true }
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
return <text>Pressed: {Array.from(pressed()).join(", ")}</text>
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### usePaste(handler)
|
|
161
|
+
|
|
162
|
+
Handle paste events.
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { usePaste } from "@opentui/solid"
|
|
166
|
+
|
|
167
|
+
function PasteHandler() {
|
|
168
|
+
usePaste((text) => {
|
|
169
|
+
console.log("Pasted:", text)
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
return <text>Paste something</text>
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### onResize(callback)
|
|
177
|
+
|
|
178
|
+
Handle terminal resize events.
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import { onResize } from "@opentui/solid"
|
|
182
|
+
|
|
183
|
+
function App() {
|
|
184
|
+
onResize((width, height) => {
|
|
185
|
+
console.log(`Resized to ${width}x${height}`)
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
return <text>Resize the terminal</text>
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### useTerminalDimensions()
|
|
193
|
+
|
|
194
|
+
Get reactive terminal dimensions.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import { useTerminalDimensions } from "@opentui/solid"
|
|
198
|
+
|
|
199
|
+
function ResponsiveLayout() {
|
|
200
|
+
const dimensions = useTerminalDimensions()
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<box flexDirection={dimensions().width > 80 ? "row" : "column"}>
|
|
204
|
+
<text>Width: {dimensions().width}</text>
|
|
205
|
+
<text>Height: {dimensions().height}</text>
|
|
206
|
+
</box>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### useSelectionHandler(handler)
|
|
212
|
+
|
|
213
|
+
Handle text selection events. Solid-only hook - React does not have this.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
import { useSelectionHandler } from "@opentui/solid"
|
|
217
|
+
import type { Selection } from "@opentui/core"
|
|
218
|
+
|
|
219
|
+
function SelectableText() {
|
|
220
|
+
const [selected, setSelected] = createSignal("")
|
|
221
|
+
|
|
222
|
+
useSelectionHandler((selection: Selection) => {
|
|
223
|
+
const text = selection.getSelectedText()
|
|
224
|
+
if (text) {
|
|
225
|
+
setSelected(text)
|
|
226
|
+
// Copy to clipboard if needed
|
|
227
|
+
selection.copyToClipboard()
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
|
|
231
|
+
return (
|
|
232
|
+
<box flexDirection="column">
|
|
233
|
+
<text selectable>Select this text with your mouse</text>
|
|
234
|
+
<text fg="#888">Selected: {selected()}</text>
|
|
235
|
+
</box>
|
|
236
|
+
)
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**Selection properties/methods:**
|
|
241
|
+
- `getSelectedText(): string` - Get the selected text content
|
|
242
|
+
- `copyToClipboard(): void` - Copy selection to system clipboard (via OSC 52)
|
|
243
|
+
- `start: ConsolePosition` - Selection start position
|
|
244
|
+
- `end: ConsolePosition` - Selection end position
|
|
245
|
+
|
|
246
|
+
### useTimeline(options?)
|
|
247
|
+
|
|
248
|
+
Create animations with the timeline system.
|
|
249
|
+
|
|
250
|
+
```tsx
|
|
251
|
+
import { useTimeline } from "@opentui/solid"
|
|
252
|
+
import { createSignal, onMount } from "solid-js"
|
|
253
|
+
|
|
254
|
+
function AnimatedBox() {
|
|
255
|
+
const [width, setWidth] = createSignal(0)
|
|
256
|
+
|
|
257
|
+
const timeline = useTimeline({
|
|
258
|
+
duration: 2000,
|
|
259
|
+
loop: false,
|
|
260
|
+
})
|
|
261
|
+
|
|
262
|
+
onMount(() => {
|
|
263
|
+
timeline.add(
|
|
264
|
+
{ width: 0 },
|
|
265
|
+
{
|
|
266
|
+
width: 50,
|
|
267
|
+
duration: 2000,
|
|
268
|
+
ease: "easeOutQuad",
|
|
269
|
+
onUpdate: (anim) => {
|
|
270
|
+
setWidth(Math.round(anim.targets[0].width))
|
|
271
|
+
},
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
})
|
|
275
|
+
|
|
276
|
+
return <box style={{ width: width(), height: 3, backgroundColor: "#6a5acd" }} />
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Components
|
|
281
|
+
|
|
282
|
+
### Text Component
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
<text
|
|
286
|
+
content="Hello" // Or use children
|
|
287
|
+
fg="#FFFFFF" // Foreground color
|
|
288
|
+
bg="#000000" // Background color
|
|
289
|
+
selectable={true} // Allow text selection
|
|
290
|
+
>
|
|
291
|
+
{/* Use nested modifier tags for styling */}
|
|
292
|
+
<span fg="red">Red</span>
|
|
293
|
+
<strong>Bold</strong>
|
|
294
|
+
<em>Italic</em>
|
|
295
|
+
<u>Underline</u>
|
|
296
|
+
<br />
|
|
297
|
+
<a href="https://...">Link</a>
|
|
298
|
+
</text>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
> **Note**: Do NOT use `bold`, `italic`, `underline` as props on `<text>`. Use nested modifier tags like `<strong>`, `<em>`, `<u>` instead.
|
|
302
|
+
|
|
303
|
+
### Box Component
|
|
304
|
+
|
|
305
|
+
```tsx
|
|
306
|
+
<box
|
|
307
|
+
// Borders
|
|
308
|
+
border // Enable border
|
|
309
|
+
borderStyle="single" // single | double | rounded | bold
|
|
310
|
+
borderColor="#FFFFFF"
|
|
311
|
+
title="Title"
|
|
312
|
+
titleAlignment="center" // left | center | right
|
|
313
|
+
|
|
314
|
+
// Colors
|
|
315
|
+
backgroundColor="#1a1a2e"
|
|
316
|
+
|
|
317
|
+
// Layout
|
|
318
|
+
flexDirection="row"
|
|
319
|
+
justifyContent="center"
|
|
320
|
+
alignItems="center"
|
|
321
|
+
gap={2}
|
|
322
|
+
|
|
323
|
+
// Spacing
|
|
324
|
+
padding={2}
|
|
325
|
+
paddingX={2} // Horizontal (left + right)
|
|
326
|
+
paddingY={1} // Vertical (top + bottom)
|
|
327
|
+
margin={1}
|
|
328
|
+
marginX={2} // Horizontal (left + right)
|
|
329
|
+
marginY={1} // Vertical (top + bottom)
|
|
330
|
+
|
|
331
|
+
// Dimensions
|
|
332
|
+
width={40}
|
|
333
|
+
height={10}
|
|
334
|
+
flexGrow={1}
|
|
335
|
+
|
|
336
|
+
// Focus
|
|
337
|
+
focusable // Allow box to receive focus
|
|
338
|
+
focused={isFocused()} // Controlled focus state
|
|
339
|
+
|
|
340
|
+
// Events
|
|
341
|
+
onMouseDown={(e) => {}}
|
|
342
|
+
onMouseUp={(e) => {}}
|
|
343
|
+
>
|
|
344
|
+
{children}
|
|
345
|
+
</box>
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Scrollbox Component
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
<scrollbox
|
|
352
|
+
focused // Enable keyboard scrolling
|
|
353
|
+
style={{
|
|
354
|
+
scrollbarOptions: {
|
|
355
|
+
showArrows: true,
|
|
356
|
+
trackOptions: {
|
|
357
|
+
foregroundColor: "#7aa2f7",
|
|
358
|
+
backgroundColor: "#414868",
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
}}
|
|
362
|
+
>
|
|
363
|
+
<For each={items()}>
|
|
364
|
+
{(item) => <text>{item}</text>}
|
|
365
|
+
</For>
|
|
366
|
+
</scrollbox>
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Input Component
|
|
370
|
+
|
|
371
|
+
```tsx
|
|
372
|
+
<input
|
|
373
|
+
value={value()}
|
|
374
|
+
onInput={(newValue) => setValue(newValue)}
|
|
375
|
+
placeholder="Enter text..."
|
|
376
|
+
focused
|
|
377
|
+
width={30}
|
|
378
|
+
/>
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
### Textarea Component
|
|
382
|
+
|
|
383
|
+
```tsx
|
|
384
|
+
<textarea
|
|
385
|
+
value={text()}
|
|
386
|
+
onInput={(newValue) => setText(newValue)}
|
|
387
|
+
placeholder="Enter multiple lines..."
|
|
388
|
+
focused
|
|
389
|
+
width={40}
|
|
390
|
+
height={10}
|
|
391
|
+
/>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### Select Component
|
|
395
|
+
|
|
396
|
+
```tsx
|
|
397
|
+
<select
|
|
398
|
+
options={[
|
|
399
|
+
{ name: "Option 1", description: "First", value: "1" },
|
|
400
|
+
{ name: "Option 2", description: "Second", value: "2" },
|
|
401
|
+
]}
|
|
402
|
+
onChange={(index, option) => setSelected(option)}
|
|
403
|
+
selectedIndex={0}
|
|
404
|
+
focused
|
|
405
|
+
/>
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### Tab Select Component (Note: underscore)
|
|
409
|
+
|
|
410
|
+
```tsx
|
|
411
|
+
<tab_select
|
|
412
|
+
options={[
|
|
413
|
+
{ name: "Home", description: "Dashboard" },
|
|
414
|
+
{ name: "Settings", description: "Configuration" },
|
|
415
|
+
]}
|
|
416
|
+
onChange={(index, option) => setTab(option)}
|
|
417
|
+
tabWidth={20}
|
|
418
|
+
focused
|
|
419
|
+
/>
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### ASCII Font Component (Note: underscore)
|
|
423
|
+
|
|
424
|
+
```tsx
|
|
425
|
+
<ascii_font
|
|
426
|
+
text="TITLE"
|
|
427
|
+
font="tiny" // tiny | block | slick | shade
|
|
428
|
+
color="#FFFFFF"
|
|
429
|
+
/>
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### Code Component
|
|
433
|
+
|
|
434
|
+
```tsx
|
|
435
|
+
<code
|
|
436
|
+
code={sourceCode}
|
|
437
|
+
language="typescript"
|
|
438
|
+
/>
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
### Line Number Component (Note: underscore)
|
|
442
|
+
|
|
443
|
+
```tsx
|
|
444
|
+
<line_number
|
|
445
|
+
code={sourceCode}
|
|
446
|
+
language="typescript"
|
|
447
|
+
startLine={1}
|
|
448
|
+
highlightedLines={[5]}
|
|
449
|
+
/>
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
### Diff Component
|
|
453
|
+
|
|
454
|
+
```tsx
|
|
455
|
+
<diff
|
|
456
|
+
oldCode={originalCode}
|
|
457
|
+
newCode={modifiedCode}
|
|
458
|
+
language="typescript"
|
|
459
|
+
mode="unified" // unified | split
|
|
460
|
+
/>
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
## Control Flow
|
|
464
|
+
|
|
465
|
+
Solid's control flow components work with OpenTUI:
|
|
466
|
+
|
|
467
|
+
### For
|
|
468
|
+
|
|
469
|
+
```tsx
|
|
470
|
+
import { For } from "solid-js"
|
|
471
|
+
|
|
472
|
+
<For each={items()}>
|
|
473
|
+
{(item, index) => (
|
|
474
|
+
<box key={index()}>
|
|
475
|
+
<text>{item.name}</text>
|
|
476
|
+
</box>
|
|
477
|
+
)}
|
|
478
|
+
</For>
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
### Show
|
|
482
|
+
|
|
483
|
+
```tsx
|
|
484
|
+
import { Show } from "solid-js"
|
|
485
|
+
|
|
486
|
+
<Show when={isVisible()} fallback={<text>Hidden</text>}>
|
|
487
|
+
<text>Visible content</text>
|
|
488
|
+
</Show>
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### Switch/Match
|
|
492
|
+
|
|
493
|
+
```tsx
|
|
494
|
+
import { Switch, Match } from "solid-js"
|
|
495
|
+
|
|
496
|
+
<Switch>
|
|
497
|
+
<Match when={status() === "loading"}>
|
|
498
|
+
<text>Loading...</text>
|
|
499
|
+
</Match>
|
|
500
|
+
<Match when={status() === "error"}>
|
|
501
|
+
<text fg="red">Error!</text>
|
|
502
|
+
</Match>
|
|
503
|
+
<Match when={status() === "success"}>
|
|
504
|
+
<text fg="green">Success!</text>
|
|
505
|
+
</Match>
|
|
506
|
+
</Switch>
|
|
507
|
+
```
|
|
508
|
+
|
|
509
|
+
### Index
|
|
510
|
+
|
|
511
|
+
```tsx
|
|
512
|
+
import { Index } from "solid-js"
|
|
513
|
+
|
|
514
|
+
<Index each={items()}>
|
|
515
|
+
{(item, index) => (
|
|
516
|
+
<text>{index}: {item().name}</text>
|
|
517
|
+
)}
|
|
518
|
+
</Index>
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
## Special Components
|
|
522
|
+
|
|
523
|
+
### Portal
|
|
524
|
+
|
|
525
|
+
```tsx
|
|
526
|
+
import { Portal } from "@opentui/solid"
|
|
527
|
+
|
|
528
|
+
<Portal mount={targetNode}>
|
|
529
|
+
<box>Portal content</box>
|
|
530
|
+
</Portal>
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### Dynamic
|
|
534
|
+
|
|
535
|
+
```tsx
|
|
536
|
+
import { Dynamic } from "@opentui/solid"
|
|
537
|
+
|
|
538
|
+
<Dynamic
|
|
539
|
+
component={isMultiline() ? "textarea" : "input"}
|
|
540
|
+
placeholder="Enter text..."
|
|
541
|
+
focused
|
|
542
|
+
/>
|
|
543
|
+
```
|