ink 3.2.0 → 4.1.0
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/build/colorize.d.ts +3 -3
- package/build/colorize.js +30 -35
- package/build/colorize.js.map +1 -1
- package/build/components/App.d.ts +12 -12
- package/build/components/App.js +287 -208
- package/build/components/App.js.map +1 -1
- package/build/components/AppContext.d.ts +2 -2
- package/build/components/AppContext.js +5 -6
- package/build/components/AppContext.js.map +1 -1
- package/build/components/Box.d.ts +77 -5
- package/build/components/Box.js +20 -38
- package/build/components/Box.js.map +1 -1
- package/build/components/ErrorOverview.d.ts +5 -5
- package/build/components/ErrorOverview.js +40 -58
- package/build/components/ErrorOverview.js.map +1 -1
- package/build/components/FocusContext.d.ts +2 -2
- package/build/components/FocusContext.js +13 -14
- package/build/components/FocusContext.js.map +1 -1
- package/build/components/Newline.d.ts +4 -5
- package/build/components/Newline.js +4 -9
- package/build/components/Newline.js.map +1 -1
- package/build/components/Spacer.d.ts +2 -3
- package/build/components/Spacer.js +5 -10
- package/build/components/Spacer.js.map +1 -1
- package/build/components/Static.d.ts +5 -9
- package/build/components/Static.js +12 -33
- package/build/components/Static.js.map +1 -1
- package/build/components/StderrContext.d.ts +4 -4
- package/build/components/StderrContext.js +7 -7
- package/build/components/StderrContext.js.map +1 -1
- package/build/components/StdinContext.d.ts +4 -4
- package/build/components/StdinContext.js +8 -7
- package/build/components/StdinContext.js.map +1 -1
- package/build/components/StdoutContext.d.ts +4 -4
- package/build/components/StdoutContext.js +7 -7
- package/build/components/StdoutContext.js.map +1 -1
- package/build/components/Text.d.ts +9 -10
- package/build/components/Text.js +14 -29
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.d.ts +4 -5
- package/build/components/Transform.js +4 -11
- package/build/components/Transform.js.map +1 -1
- package/build/devtools-window-polyfill.js +3 -8
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/devtools.d.ts +1 -1
- package/build/devtools.js +6 -6
- package/build/devtools.js.map +1 -1
- package/build/dom.d.ts +17 -20
- package/build/dom.js +35 -47
- package/build/dom.js.map +1 -1
- package/build/get-max-width.d.ts +3 -3
- package/build/get-max-width.js +8 -11
- package/build/get-max-width.js.map +1 -1
- package/build/hooks/use-app.d.ts +1 -1
- package/build/hooks/use-app.js +4 -9
- package/build/hooks/use-app.js.map +1 -1
- package/build/hooks/use-focus-manager.d.ts +3 -3
- package/build/hooks/use-focus-manager.js +4 -9
- package/build/hooks/use-focus-manager.js.map +1 -1
- package/build/hooks/use-focus.d.ts +4 -4
- package/build/hooks/use-focus.js +11 -16
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.d.ts +5 -5
- package/build/hooks/use-input.js +13 -14
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/use-stderr.d.ts +1 -1
- package/build/hooks/use-stderr.js +4 -9
- package/build/hooks/use-stderr.js.map +1 -1
- package/build/hooks/use-stdin.d.ts +1 -1
- package/build/hooks/use-stdin.js +4 -9
- package/build/hooks/use-stdin.js.map +1 -1
- package/build/hooks/use-stdout.d.ts +1 -1
- package/build/hooks/use-stdout.js +4 -9
- package/build/hooks/use-stdout.js.map +1 -1
- package/build/index.d.ts +27 -20
- package/build/index.js +15 -32
- package/build/index.js.map +1 -1
- package/build/ink.d.ts +6 -4
- package/build/ink.js +188 -99
- package/build/ink.js.map +1 -1
- package/build/instances.d.ts +4 -2
- package/build/instances.js +2 -3
- package/build/instances.js.map +1 -1
- package/build/log-update.d.ts +5 -6
- package/build/log-update.js +8 -12
- package/build/log-update.js.map +1 -1
- package/build/measure-element.d.ts +5 -5
- package/build/measure-element.js +5 -9
- package/build/measure-element.js.map +1 -1
- package/build/measure-text.d.ts +4 -4
- package/build/measure-text.js +7 -10
- package/build/measure-text.js.map +1 -1
- package/build/output.d.ts +12 -4
- package/build/output.js +108 -31
- package/build/output.js.map +1 -1
- package/build/reconciler.d.ts +1 -1
- package/build/reconciler.js +104 -76
- package/build/reconciler.js.map +1 -1
- package/build/render-border.d.ts +4 -4
- package/build/render-border.js +8 -12
- package/build/render-border.js.map +1 -1
- package/build/render-node-to-output.d.ts +3 -3
- package/build/render-node-to-output.js +44 -24
- package/build/render-node-to-output.js.map +1 -1
- package/build/render.d.ts +8 -8
- package/build/render.js +23 -20
- package/build/render.js.map +1 -1
- package/build/renderer.d.ts +5 -5
- package/build/renderer.js +9 -17
- package/build/renderer.js.map +1 -1
- package/build/squash-text-nodes.d.ts +1 -1
- package/build/squash-text-nodes.js +1 -3
- package/build/squash-text-nodes.js.map +1 -1
- package/build/styles.d.ts +30 -9
- package/build/styles.js +60 -46
- package/build/styles.js.map +1 -1
- package/build/wrap-text.d.ts +3 -3
- package/build/wrap-text.js +9 -12
- package/build/wrap-text.js.map +1 -1
- package/license +1 -1
- package/package.json +87 -67
- package/readme.md +202 -57
package/readme.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
2
6
|
<br>
|
|
3
7
|
<br>
|
|
4
|
-
<img width="
|
|
8
|
+
<img width="240" alt="Ink" src="media/logo.png">
|
|
5
9
|
<br>
|
|
6
10
|
<br>
|
|
7
11
|
<br>
|
|
8
|
-
</
|
|
12
|
+
</div>
|
|
9
13
|
|
|
10
14
|
> React for CLIs. Build and test your CLI output using components.
|
|
11
15
|
|
|
@@ -20,12 +24,39 @@ Since Ink is a React renderer, it means that all features of React are supported
|
|
|
20
24
|
Head over to [React](https://reactjs.org) website for documentation on how to use it.
|
|
21
25
|
Only Ink's methods will be documented in this readme.
|
|
22
26
|
|
|
23
|
-
**Note:** This is documentation for Ink
|
|
27
|
+
**Note:** This is documentation for Ink 4. If you're looking for docs on Ink 3, check out [this release](https://github.com/vadimdemedes/ink/tree/v3.2.0).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
<p>
|
|
33
|
+
<p>
|
|
34
|
+
<sup>
|
|
35
|
+
<a href="https://opencollective.com/vadimdemedes">My open source work is supported by the community ❤️</a>
|
|
36
|
+
</sup>
|
|
37
|
+
</p>
|
|
38
|
+
<sup>Special thanks to:</sup>
|
|
39
|
+
<br>
|
|
40
|
+
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=ink&utm_source=github">
|
|
41
|
+
<div>
|
|
42
|
+
<img src="https://vadimdemedes.com/github/workos.svg" width="200" alt="WorkOS">
|
|
43
|
+
</div>
|
|
44
|
+
<b>Your app, enterprise-ready.</b>
|
|
45
|
+
<div>
|
|
46
|
+
<sub>Start selling to enterprise customers with just a few lines of code.</sub>
|
|
47
|
+
<br>
|
|
48
|
+
<sup>Add Single Sign-On (and more) in minutes instead of months.</sup>
|
|
49
|
+
</div>
|
|
50
|
+
</a>
|
|
51
|
+
</p>
|
|
52
|
+
<br>
|
|
53
|
+
<br>
|
|
54
|
+
</div>
|
|
24
55
|
|
|
25
56
|
## Install
|
|
26
57
|
|
|
27
|
-
```
|
|
28
|
-
|
|
58
|
+
```sh
|
|
59
|
+
npm install ink react
|
|
29
60
|
```
|
|
30
61
|
|
|
31
62
|
## Usage
|
|
@@ -60,36 +91,43 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
|
|
|
60
91
|
|
|
61
92
|
## Who's Using Ink?
|
|
62
93
|
|
|
94
|
+
- [Cloudflare's Wrangler](https://github.com/cloudflare/wrangler2) - The CLI for Cloudflare Workers.
|
|
63
95
|
- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing fast websites.
|
|
64
96
|
- [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript.
|
|
65
97
|
- [Terraform CDK](https://github.com/hashicorp/terraform-cdk) - CDK (Cloud Development Kit) for HashiCorp Terraform.
|
|
66
98
|
- [Twilio's SIGNAL](https://github.com/twilio-labs/plugin-signal2020) - CLI for Twilio's SIGNAL conference. [Blog post](https://www.twilio.com/blog/building-conference-cli-in-react).
|
|
67
99
|
- [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema.
|
|
68
100
|
- [Prisma](https://www.prisma.io) - The unified data layer for modern applications.
|
|
69
|
-
- [Wallace](https://www.projectwallace.com) - Pretty CSS analytics
|
|
101
|
+
- [Wallace](https://www.projectwallace.com) - Pretty CSS analytics.
|
|
70
102
|
- [Blitz](https://blitzjs.com) - The Fullstack React Framework.
|
|
71
103
|
- [New York Times](https://github.com/nytimes/kyt) - NYT uses Ink `kyt` - a toolkit that encapsulates and manages the configuration for web apps.
|
|
72
104
|
- [tink](https://github.com/npm/tink) - Next-generation runtime and package manager.
|
|
73
|
-
- [
|
|
105
|
+
- [Inkle](https://github.com/jrr/inkle) - Wordle game.
|
|
106
|
+
- [loki](https://github.com/oblador/loki) - Visual regression testing for Storybook.
|
|
74
107
|
- [Bit](https://github.com/teambit/bit) - Build, distribute and collaborate on components.
|
|
75
108
|
- [Remirror](https://github.com/remirror/remirror) - Your friendly, world-class editor toolkit.
|
|
76
109
|
- [Prime](https://github.com/birkir/prime) - Open source GraphQL CMS.
|
|
77
110
|
- [Splash](https://github.com/Shopify/polaris-react/tree/master/scripts/splash) - Observe the splash zone of a change across the Shopify's [Polaris](https://polaris.shopify.com) component library.
|
|
78
|
-
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant
|
|
79
|
-
- [emma](https://github.com/maticzav/emma-cli) -
|
|
111
|
+
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emojis.
|
|
112
|
+
- [emma](https://github.com/maticzav/emma-cli) - Find and install npm packages.
|
|
80
113
|
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command line tools for time-saving web developers.
|
|
81
|
-
- [share](https://github.com/marionebl/share-cli) - Quickly share files
|
|
114
|
+
- [share](https://github.com/marionebl/share-cli) - Quickly share files.
|
|
82
115
|
- [Kubelive](https://github.com/ameerthehacker/kubelive) - CLI for Kubernetes to provide live data about the cluster and its resources.
|
|
83
|
-
- [changelog-view](https://github.com/jdeniau/changelog-view) -
|
|
84
|
-
- [cfpush](https://github.com/mamachanko/cfpush) - An interactive Cloud Foundry tutorial
|
|
85
|
-
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app
|
|
86
|
-
- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read summaries
|
|
116
|
+
- [changelog-view](https://github.com/jdeniau/changelog-view) - View changelogs.
|
|
117
|
+
- [cfpush](https://github.com/mamachanko/cfpush) - An interactive Cloud Foundry tutorial.
|
|
118
|
+
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app.
|
|
119
|
+
- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read summaries.
|
|
87
120
|
- [garson](https://github.com/goliney/garson) - Build interactive config-based command-line interfaces.
|
|
88
121
|
- [git-contrib-calendar](https://github.com/giannisp/git-contrib-calendar) - Display a contributions calendar for any git repository.
|
|
89
122
|
- [gitgud](https://github.com/GitGud-org/GitGud) - An interactive command-line GUI for Git.
|
|
90
|
-
- [Autarky](https://github.com/pranshuchittora/autarky) -
|
|
123
|
+
- [Autarky](https://github.com/pranshuchittora/autarky) - Find and delete old `node_modules` directories in order to free up disk space.
|
|
91
124
|
- [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download and upload speed.
|
|
92
125
|
- [tasuku](https://github.com/privatenumber/tasuku) - Minimal task runner.
|
|
126
|
+
- [mnswpr](https://github.com/mordv/mnswpr) - Minesweeper game.
|
|
127
|
+
- [lrn](https://github.com/krychu/lrn) - Learning by repetition.
|
|
128
|
+
- [turdle](https://github.com/mynameisankit/turdle) - Wordle game.
|
|
129
|
+
- [Shopify CLI](https://github.com/Shopify/cli) - Build apps, themes, and storefronts for Shopify.
|
|
130
|
+
- [ToDesktop CLI](https://www.todesktop.com/electron) - An all-in-one platform for building Electron apps.
|
|
93
131
|
|
|
94
132
|
## Contents
|
|
95
133
|
|
|
@@ -120,16 +158,14 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
|
|
|
120
158
|
|
|
121
159
|
Use [create-ink-app](https://github.com/vadimdemedes/create-ink-app) to quickly scaffold a new Ink-based CLI.
|
|
122
160
|
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
$ cd my-ink-cli
|
|
126
|
-
$ npx create-ink-app
|
|
161
|
+
```sh
|
|
162
|
+
npx create-ink-app my-ink-cli
|
|
127
163
|
```
|
|
128
164
|
|
|
129
165
|
Alternatively, create a TypeScript project:
|
|
130
166
|
|
|
131
|
-
```
|
|
132
|
-
|
|
167
|
+
```sh
|
|
168
|
+
npx create-ink-app --typescript my-ink-cli
|
|
133
169
|
```
|
|
134
170
|
|
|
135
171
|
<details><summary>Manual setup</summary>
|
|
@@ -139,8 +175,8 @@ Ink requires the same Babel setup as you would do for regular React-based apps i
|
|
|
139
175
|
Set up Babel with a React preset to ensure all examples in this readme work as expected.
|
|
140
176
|
After [installing Babel](https://babeljs.io/docs/en/usage), install `@babel/preset-react` and insert the following configuration in `babel.config.json`:
|
|
141
177
|
|
|
142
|
-
```
|
|
143
|
-
|
|
178
|
+
```sh
|
|
179
|
+
npm install --save-dev @babel/preset-react
|
|
144
180
|
```
|
|
145
181
|
|
|
146
182
|
```json
|
|
@@ -172,17 +208,17 @@ render(<Demo />);
|
|
|
172
208
|
|
|
173
209
|
Then, transpile this file with Babel:
|
|
174
210
|
|
|
175
|
-
```
|
|
176
|
-
|
|
211
|
+
```sh
|
|
212
|
+
npx babel source.js -o cli.js
|
|
177
213
|
```
|
|
178
214
|
|
|
179
215
|
Now you can run `cli.js` with Node.js:
|
|
180
216
|
|
|
181
|
-
```
|
|
182
|
-
|
|
217
|
+
```sh
|
|
218
|
+
node cli
|
|
183
219
|
```
|
|
184
220
|
|
|
185
|
-
If you don't like transpiling files during development, you can use [import-jsx](https://github.com/vadimdemedes/import-jsx)
|
|
221
|
+
If you don't like transpiling files during development, you can use [import-jsx](https://github.com/vadimdemedes/import-jsx) or [@esbuild-kit/esm-loader](https://github.com/esbuild-kit/esm-loader) to `import` a JSX file and transpile it on the fly.
|
|
186
222
|
|
|
187
223
|
</p>
|
|
188
224
|
</details>
|
|
@@ -545,6 +581,58 @@ Margin on all sides. Equivalent to setting `marginTop`, `marginBottom`, `marginL
|
|
|
545
581
|
<Box margin={2}>Top, bottom, left and right</Box>
|
|
546
582
|
```
|
|
547
583
|
|
|
584
|
+
#### Gap
|
|
585
|
+
|
|
586
|
+
#### gap
|
|
587
|
+
|
|
588
|
+
Type: `number`\
|
|
589
|
+
Default: `0`
|
|
590
|
+
|
|
591
|
+
Size of the gap between an element's columns and rows. Shorthand for `columnGap` and `rowGap`.
|
|
592
|
+
|
|
593
|
+
```jsx
|
|
594
|
+
<Box gap={1} width={3} flexWrap="wrap">
|
|
595
|
+
<Text>A</Text>
|
|
596
|
+
<Text>B</Text>
|
|
597
|
+
<Text>C</Text>
|
|
598
|
+
</Box>
|
|
599
|
+
// A B
|
|
600
|
+
//
|
|
601
|
+
// C
|
|
602
|
+
```
|
|
603
|
+
|
|
604
|
+
#### columnGap
|
|
605
|
+
|
|
606
|
+
Type: `number`\
|
|
607
|
+
Default: `0`
|
|
608
|
+
|
|
609
|
+
Size of the gap between an element's columns.
|
|
610
|
+
|
|
611
|
+
```jsx
|
|
612
|
+
<Box gap={1}>
|
|
613
|
+
<Text>A</Text>
|
|
614
|
+
<Text>B</Text>
|
|
615
|
+
</Box>
|
|
616
|
+
// A B
|
|
617
|
+
```
|
|
618
|
+
|
|
619
|
+
#### rowGap
|
|
620
|
+
|
|
621
|
+
Type: `number`\
|
|
622
|
+
Default: `0`
|
|
623
|
+
|
|
624
|
+
Size of the gap between element's rows.
|
|
625
|
+
|
|
626
|
+
```jsx
|
|
627
|
+
<Box flexDirection="column" gap={1}>
|
|
628
|
+
<Text>A</Text>
|
|
629
|
+
<Text>B</Text>
|
|
630
|
+
</Box>
|
|
631
|
+
// A
|
|
632
|
+
//
|
|
633
|
+
// B
|
|
634
|
+
```
|
|
635
|
+
|
|
548
636
|
#### Flex
|
|
549
637
|
|
|
550
638
|
##### flexGrow
|
|
@@ -646,6 +734,32 @@ See [flex-direction](https://css-tricks.com/almanac/properties/f/flex-direction/
|
|
|
646
734
|
// X
|
|
647
735
|
```
|
|
648
736
|
|
|
737
|
+
##### flexWrap
|
|
738
|
+
|
|
739
|
+
Type: `string`\
|
|
740
|
+
Allowed values: `nowrap` `wrap` `wrap-reverse`
|
|
741
|
+
|
|
742
|
+
See [flex-wrap](https://css-tricks.com/almanac/properties/f/flex-wrap/).
|
|
743
|
+
|
|
744
|
+
```jsx
|
|
745
|
+
<Box width={2} flexWrap="wrap">
|
|
746
|
+
<Text>A</Text>
|
|
747
|
+
<Text>BC</Text>
|
|
748
|
+
</Box>
|
|
749
|
+
// A
|
|
750
|
+
// B C
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
```jsx
|
|
754
|
+
<Box flexDirection="column" height={2} flexWrap="wrap">
|
|
755
|
+
<Text>A</Text>
|
|
756
|
+
<Text>B</Text>
|
|
757
|
+
<Text>C</Text>
|
|
758
|
+
</Box>
|
|
759
|
+
// A C
|
|
760
|
+
// B
|
|
761
|
+
```
|
|
762
|
+
|
|
649
763
|
##### alignItems
|
|
650
764
|
|
|
651
765
|
Type: `string`\
|
|
@@ -707,7 +821,7 @@ See [align-items](https://css-tricks.com/almanac/properties/a/align-items/).
|
|
|
707
821
|
|
|
708
822
|
Type: `string`\
|
|
709
823
|
Default: `auto`\
|
|
710
|
-
Allowed
|
|
824
|
+
Allowed values: `auto` `flex-start` `center` `flex-end`
|
|
711
825
|
|
|
712
826
|
See [align-self](https://css-tricks.com/almanac/properties/a/align-self/).
|
|
713
827
|
|
|
@@ -786,6 +900,30 @@ Default: `flex`
|
|
|
786
900
|
|
|
787
901
|
Set this property to `none` to hide the element.
|
|
788
902
|
|
|
903
|
+
##### overflowX
|
|
904
|
+
|
|
905
|
+
Type: `string`\
|
|
906
|
+
Allowed values: `visible` `hidden`\
|
|
907
|
+
Default: `visible`
|
|
908
|
+
|
|
909
|
+
Behavior for an element's overflow in horizontal direction.
|
|
910
|
+
|
|
911
|
+
##### overflowY
|
|
912
|
+
|
|
913
|
+
Type: `string`\
|
|
914
|
+
Allowed values: `visible` `hidden`\
|
|
915
|
+
Default: `visible`
|
|
916
|
+
|
|
917
|
+
Behavior for an element's overflow in vertical direction.
|
|
918
|
+
|
|
919
|
+
##### overflow
|
|
920
|
+
|
|
921
|
+
Type: `string`\
|
|
922
|
+
Allowed values: `visible` `hidden`\
|
|
923
|
+
Default: `visible`
|
|
924
|
+
|
|
925
|
+
Shortcut for setting `overflowX` and `overflowY` at the same time.
|
|
926
|
+
|
|
789
927
|
#### Borders
|
|
790
928
|
|
|
791
929
|
##### borderStyle
|
|
@@ -1335,7 +1473,7 @@ Default: `process.stdout`
|
|
|
1335
1473
|
import {useStdout} from 'ink';
|
|
1336
1474
|
|
|
1337
1475
|
const Example = () => {
|
|
1338
|
-
const {stdout} = useStdout;
|
|
1476
|
+
const {stdout} = useStdout();
|
|
1339
1477
|
|
|
1340
1478
|
return …
|
|
1341
1479
|
};
|
|
@@ -1461,7 +1599,7 @@ const Example = () => {
|
|
|
1461
1599
|
render(<Example />);
|
|
1462
1600
|
```
|
|
1463
1601
|
|
|
1464
|
-
See example in [examples/use-focus](examples/use-focus/use-focus.js) and [examples/use-focus-with-id](examples/use-focus/use-focus-with-id.js).
|
|
1602
|
+
See example in [examples/use-focus](examples/use-focus/use-focus.js) and [examples/use-focus-with-id](examples/use-focus-with-id/use-focus-with-id.js).
|
|
1465
1603
|
|
|
1466
1604
|
### useFocusManager()
|
|
1467
1605
|
|
|
@@ -1747,14 +1885,14 @@ Check out [ink-testing-library](https://github.com/vadimdemedes/ink-testing-libr
|
|
|
1747
1885
|
Ink supports [React Devtools](https://github.com/facebook/react/tree/master/packages/react-devtools) out-of-the-box.
|
|
1748
1886
|
To enable integration with React Devtools in your Ink-based CLI, run it with `DEV=true` environment variable:
|
|
1749
1887
|
|
|
1750
|
-
```
|
|
1751
|
-
|
|
1888
|
+
```sh
|
|
1889
|
+
DEV=true my-cli
|
|
1752
1890
|
```
|
|
1753
1891
|
|
|
1754
1892
|
Then, start React Devtools itself:
|
|
1755
1893
|
|
|
1756
|
-
```
|
|
1757
|
-
|
|
1894
|
+
```sh
|
|
1895
|
+
npx react-devtools
|
|
1758
1896
|
```
|
|
1759
1897
|
|
|
1760
1898
|
After it starts up, you should see the component tree of your CLI.
|
|
@@ -1767,23 +1905,23 @@ You can even inspect and change the props of components, and see the results imm
|
|
|
1767
1905
|
- [ink-text-input](https://github.com/vadimdemedes/ink-text-input) - Text input.
|
|
1768
1906
|
- [ink-spinner](https://github.com/vadimdemedes/ink-spinner) - Spinner.
|
|
1769
1907
|
- [ink-select-input](https://github.com/vadimdemedes/ink-select-input) - Select (dropdown) input.
|
|
1770
|
-
- [ink-link](https://github.com/sindresorhus/ink-link) - Link
|
|
1771
|
-
- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color
|
|
1772
|
-
- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text
|
|
1908
|
+
- [ink-link](https://github.com/sindresorhus/ink-link) - Link.
|
|
1909
|
+
- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color.
|
|
1910
|
+
- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text.
|
|
1773
1911
|
- [ink-image](https://github.com/kevva/ink-image) - Display images inside the terminal.
|
|
1774
|
-
- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab
|
|
1775
|
-
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings
|
|
1912
|
+
- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab.
|
|
1913
|
+
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings.
|
|
1776
1914
|
- [ink-multi-select](https://github.com/karaggeorge/ink-multi-select) - Select one or more values from a list
|
|
1777
|
-
- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider
|
|
1778
|
-
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) -
|
|
1779
|
-
- [ink-table](https://github.com/maticzav/ink-table) - Table
|
|
1915
|
+
- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider.
|
|
1916
|
+
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) - Progress bar.
|
|
1917
|
+
- [ink-table](https://github.com/maticzav/ink-table) - Table.
|
|
1780
1918
|
- [ink-ascii](https://github.com/hexrcs/ink-ascii) - Awesome text component with more font choices, based on Figlet.
|
|
1781
1919
|
- [ink-markdown](https://github.com/cameronhunter/ink-markdown) - Render syntax highlighted Markdown.
|
|
1782
1920
|
- [ink-quicksearch-input](https://github.com/Eximchain/ink-quicksearch-input) - Select component with fast quicksearch-like navigation.
|
|
1783
1921
|
- [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input.
|
|
1784
1922
|
- [ink-syntax-highlight](https://github.com/vsashyn/ink-syntax-highlight) - Code syntax highlighting.
|
|
1785
|
-
- [ink-form](https://github.com/lukasbach/ink-form) - Form
|
|
1786
|
-
- [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list
|
|
1923
|
+
- [ink-form](https://github.com/lukasbach/ink-form) - Form.
|
|
1924
|
+
- [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list.
|
|
1787
1925
|
|
|
1788
1926
|
## Useful Hooks
|
|
1789
1927
|
|
|
@@ -1791,17 +1929,24 @@ You can even inspect and change the props of components, and see the results imm
|
|
|
1791
1929
|
|
|
1792
1930
|
## Examples
|
|
1793
1931
|
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
- [
|
|
1802
|
-
- [
|
|
1803
|
-
- [
|
|
1804
|
-
- [
|
|
1932
|
+
The [`examples`](/examples) directory contains a set of real examples. You can run them with:
|
|
1933
|
+
|
|
1934
|
+
```bash
|
|
1935
|
+
npm run example examples/[example name]
|
|
1936
|
+
# e.g. npm run example examples/borders
|
|
1937
|
+
```
|
|
1938
|
+
|
|
1939
|
+
- [Jest](examples/jest/jest.tsx) - Implementation of basic Jest UI [(live demo)](https://ink-jest-demo.vadimdemedes.repl.run/).
|
|
1940
|
+
- [Counter](examples/counter/counter.tsx) - Simple counter that increments every 100ms [(live demo)](https://ink-counter-demo.vadimdemedes.repl.run/).
|
|
1941
|
+
- [Form with validation](https://github.com/final-form/rff-cli-example) - Manage form state using [Final Form](https://github.com/final-form/final-form#-final-form).
|
|
1942
|
+
- [Borders](examples/borders/borders.tsx) - Add borders to `<Box>` component.
|
|
1943
|
+
- [Suspense](examples/suspense/suspense.tsx) - Use React Suspense.
|
|
1944
|
+
- [Table](examples/table/table.tsx) - Render a table with multiple columns and rows.
|
|
1945
|
+
- [Focus management](examples/use-focus/use-focus.tsx) - Use `useFocus` hook to manage focus between components.
|
|
1946
|
+
- [User input](examples/use-input/use-input.tsx) - Listen to user input.
|
|
1947
|
+
- [Write to stdout](examples/use-stdout/use-stdout.tsx) - Write to stdout bypassing main Ink output.
|
|
1948
|
+
- [Write to stderr](examples/use-stderr/use-stderr.tsx) - Write to stderr bypassing main Ink output.
|
|
1949
|
+
- [Static](examples/static/static.tsx) - Use `<Static>` to render permanent output.
|
|
1805
1950
|
- [Child process](examples/subprocess-output) - Render output from a child process.
|
|
1806
1951
|
|
|
1807
1952
|
## Maintainers
|