@boba-cli/textarea 0.1.0-alpha.2
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 +73 -0
- package/dist/index.cjs +686 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +184 -0
- package/dist/index.d.ts +184 -0
- package/dist/index.js +672 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @boba-cli/textarea
|
|
2
|
+
|
|
3
|
+
Multi-line textarea component for Boba terminal UIs. Early port of Charmbracelet Bubbles textarea.
|
|
4
|
+
|
|
5
|
+
<img src="../../examples/textarea-demo.gif" width="950" alt="Textarea component demo" />
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm add @boba-cli/textarea
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quickstart
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { TextareaModel } from '@boba-cli/textarea'
|
|
17
|
+
import type { Cmd, Msg } from '@boba-cli/tea'
|
|
18
|
+
|
|
19
|
+
let editor = TextareaModel.new({
|
|
20
|
+
placeholder: 'Write your note...',
|
|
21
|
+
width: 60,
|
|
22
|
+
maxHeight: 5,
|
|
23
|
+
showLineNumbers: true,
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
function init(): Cmd<Msg> {
|
|
27
|
+
const [focused, cmd] = editor.focus()
|
|
28
|
+
editor = focused
|
|
29
|
+
return cmd
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function update(msg: Msg): [typeof model, Cmd<Msg>] {
|
|
33
|
+
const [next, cmd] = editor.update(msg)
|
|
34
|
+
editor = next
|
|
35
|
+
return [model, cmd]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function view(): string {
|
|
39
|
+
return editor.view()
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Features (current slice)
|
|
44
|
+
|
|
45
|
+
- Multi-line editing with grapheme-aware cursor
|
|
46
|
+
- Insert/delete, newline, delete line, duplicate line
|
|
47
|
+
- Line navigation (up/down/start/end), scrolling with maxHeight
|
|
48
|
+
- Optional line numbers and prompt prefix
|
|
49
|
+
- Placeholder rendering when empty
|
|
50
|
+
- Clipboard paste (ctrl+v) via `clipboardy`
|
|
51
|
+
- Validation callback support
|
|
52
|
+
|
|
53
|
+
## Key bindings (defaults)
|
|
54
|
+
|
|
55
|
+
- Move: `up/down`, `home/end`
|
|
56
|
+
- Insert newline: `enter`
|
|
57
|
+
- Delete char: `backspace`, `delete`
|
|
58
|
+
- Delete line: `ctrl+u`
|
|
59
|
+
- Paste: `ctrl+v`
|
|
60
|
+
- Quit keys are provided by your app, not the component
|
|
61
|
+
|
|
62
|
+
## Scripts
|
|
63
|
+
|
|
64
|
+
- `pnpm -C packages/textarea build`
|
|
65
|
+
- `pnpm -C packages/textarea test`
|
|
66
|
+
- `pnpm -C packages/textarea lint`
|
|
67
|
+
- `pnpm -C packages/textarea generate:api-report`
|
|
68
|
+
|
|
69
|
+
## Notes / gaps
|
|
70
|
+
|
|
71
|
+
- Horizontal scrolling and wrapping are minimal; long lines render fully.
|
|
72
|
+
- Memoization from the Go version is not yet ported.
|
|
73
|
+
- Selection support is not yet implemented.
|