@suds-cli/textinput 0.0.0 → 0.1.0-alpha.1
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 +13 -17
- package/dist/index.cjs +665 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{model.d.ts → index.d.cts} +93 -6
- package/dist/index.d.ts +173 -4
- package/dist/index.js +649 -3
- package/dist/index.js.map +1 -1
- package/package.json +31 -18
- package/dist/index.d.ts.map +0 -1
- package/dist/messages.d.ts +0 -26
- package/dist/messages.d.ts.map +0 -1
- package/dist/messages.js +0 -40
- package/dist/messages.js.map +0 -1
- package/dist/model.d.ts.map +0 -1
- package/dist/model.js +0 -619
- package/dist/model.js.map +0 -1
- package/dist/types.d.ts +0 -63
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -33
- package/dist/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Single-line text input component for Suds terminal UIs. Port of Charmbracelet Bubbles textinput.
|
|
4
4
|
|
|
5
|
+
<img src="../../examples/textinput-demo.gif" width="950" alt="Textinput component demo" />
|
|
6
|
+
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
9
|
```bash
|
|
@@ -11,32 +13,29 @@ pnpm add @suds-cli/textinput
|
|
|
11
13
|
## Quickstart
|
|
12
14
|
|
|
13
15
|
```ts
|
|
14
|
-
import { TextInputModel, EchoMode } from
|
|
15
|
-
import type { Cmd, Msg } from
|
|
16
|
+
import { TextInputModel, EchoMode } from '@suds-cli/textinput'
|
|
17
|
+
import type { Cmd, Msg } from '@suds-cli/tea'
|
|
16
18
|
|
|
17
19
|
let input = TextInputModel.new({
|
|
18
|
-
placeholder:
|
|
20
|
+
placeholder: 'Type your name…',
|
|
19
21
|
width: 40,
|
|
20
22
|
echoMode: EchoMode.Normal,
|
|
21
|
-
})
|
|
23
|
+
})
|
|
22
24
|
|
|
23
25
|
function init(): Cmd<Msg> {
|
|
24
|
-
const [focused, cmd] = input.focus()
|
|
25
|
-
input = focused
|
|
26
|
-
return cmd
|
|
26
|
+
const [focused, cmd] = input.focus()
|
|
27
|
+
input = focused
|
|
28
|
+
return cmd
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
function update(msg: Msg): [typeof model, Cmd<Msg>] {
|
|
30
|
-
const [nextInput, cmd] = input.update(msg)
|
|
31
|
-
input = nextInput
|
|
32
|
-
return [model, cmd]
|
|
32
|
+
const [nextInput, cmd] = input.update(msg)
|
|
33
|
+
input = nextInput
|
|
34
|
+
return [model, cmd]
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
function view(): string {
|
|
36
|
-
return [
|
|
37
|
-
"Name:",
|
|
38
|
-
input.view(),
|
|
39
|
-
].join("\n");
|
|
38
|
+
return ['Name:', input.view()].join('\n')
|
|
40
39
|
}
|
|
41
40
|
```
|
|
42
41
|
|
|
@@ -80,6 +79,3 @@ function view(): string {
|
|
|
80
79
|
## License
|
|
81
80
|
|
|
82
81
|
MIT
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|