Comparing version 2.5.0 to 2.6.0
@@ -24,3 +24,3 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -140,3 +140,4 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
exitOnCtrlC: _propTypes.default.bool.isRequired, | ||
// eslint-disable-line react/boolean-prop-naming | ||
onExit: _propTypes.default.func.isRequired | ||
}); |
@@ -16,3 +16,3 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -19,0 +19,0 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } |
@@ -16,7 +16,7 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -23,0 +23,0 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } |
@@ -56,3 +56,5 @@ "use strict"; | ||
}; | ||
/* eslint-disable react/boolean-prop-naming */ | ||
Text.propTypes = { | ||
@@ -66,2 +68,4 @@ bold: _propTypes.default.bool, | ||
}; | ||
/* eslint-enable react/boolean-prop-naming */ | ||
Text.defaultProps = { | ||
@@ -68,0 +72,0 @@ bold: false, |
@@ -40,3 +40,3 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -43,0 +43,0 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -16,3 +16,3 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -19,0 +19,0 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } |
{ | ||
"name": "ink", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "React for CLI", | ||
@@ -43,9 +43,8 @@ "license": "MIT", | ||
"dependencies": { | ||
"@types/react": "^16.8.6", | ||
"ansi-escapes": "^4.2.1", | ||
"arrify": "^1.0.1", | ||
"auto-bind": "^2.0.0", | ||
"chalk": "^2.4.1", | ||
"cli-cursor": "^2.1.0", | ||
"cli-truncate": "^1.1.0", | ||
"arrify": "^2.0.1", | ||
"auto-bind": "^3.0.0", | ||
"chalk": "^3.0.0", | ||
"cli-cursor": "^3.1.0", | ||
"cli-truncate": "^2.0.0", | ||
"is-ci": "^2.0.0", | ||
@@ -55,9 +54,9 @@ "lodash.throttle": "^4.1.1", | ||
"prop-types": "^15.6.2", | ||
"react-reconciler": "^0.21.0", | ||
"scheduler": "^0.15.0", | ||
"react-reconciler": "^0.24.0", | ||
"scheduler": "^0.18.0", | ||
"signal-exit": "^3.0.2", | ||
"slice-ansi": "^1.0.0", | ||
"string-length": "^2.0.0", | ||
"widest-line": "^2.0.0", | ||
"wrap-ansi": "^5.0.0", | ||
"slice-ansi": "^3.0.0", | ||
"string-length": "^3.1.0", | ||
"widest-line": "^3.1.0", | ||
"wrap-ansi": "^6.2.0", | ||
"yoga-layout-prebuilt": "^1.9.3" | ||
@@ -71,20 +70,22 @@ }, | ||
"@babel/preset-react": "^7.0.0", | ||
"ava": "^1.3.1", | ||
"@types/react": "^16.8.6", | ||
"ava": "^2.4.0", | ||
"babel-eslint": "^10.0.1", | ||
"delay": "^4.1.0", | ||
"eslint-config-xo-react": "^0.19.0", | ||
"eslint-config-xo-react": "^0.20.0", | ||
"eslint-plugin-react": "^7.11.1", | ||
"eslint-plugin-react-hooks": "^1.4.0", | ||
"import-jsx": "^1.3.0", | ||
"eslint-plugin-react-hooks": "^2.3.0", | ||
"import-jsx": "^3.0.0", | ||
"ms": "^2.1.1", | ||
"node-pty": "^0.8.1", | ||
"p-queue": "^3.0.0", | ||
"node-pty": "^0.9.0", | ||
"p-queue": "^6.2.1", | ||
"react": "^16.9.0", | ||
"sinon": "^7.2.7", | ||
"strip-ansi": "^5.2.0", | ||
"strip-ansi": "^6.0.0", | ||
"svg-term-cli": "^2.1.1", | ||
"tsd": "^0.8.0", | ||
"xo": "^0.24.0" | ||
"tsd": "^0.11.0", | ||
"xo": "^0.25.3" | ||
}, | ||
"peerDependencies": { | ||
"@types/react": ">=16.8.0", | ||
"react": ">=16.8.0" | ||
@@ -114,3 +115,9 @@ }, | ||
} | ||
} | ||
}, | ||
"files": [ | ||
"test/*.js" | ||
], | ||
"helpers": [ | ||
"test/helpers/*.js" | ||
] | ||
}, | ||
@@ -126,3 +133,4 @@ "xo": { | ||
"rules": { | ||
"react/no-unescaped-entities": "off" | ||
"react/no-unescaped-entities": "off", | ||
"react/state-in-constructor": "off" | ||
}, | ||
@@ -137,3 +145,3 @@ "overrides": [ | ||
"unicorn/filename-case": "off", | ||
"react/require-default-props": "warning" | ||
"react/require-default-props": "warn" | ||
} | ||
@@ -140,0 +148,0 @@ } |
261
readme.md
@@ -14,3 +14,2 @@ <h1 align="center"> | ||
## Install | ||
@@ -22,8 +21,7 @@ | ||
## Usage | ||
```jsx | ||
import React, {Component} from 'react'; | ||
import {render, Color} from 'ink'; | ||
import React, { Component } from "react"; | ||
import { render, Color } from "ink"; | ||
@@ -40,7 +38,3 @@ class Counter extends Component { | ||
render() { | ||
return ( | ||
<Color green> | ||
{this.state.i} tests passed | ||
</Color> | ||
); | ||
return <Color green>{this.state.i} tests passed</Color>; | ||
} | ||
@@ -61,3 +55,3 @@ | ||
render(<Counter/>); | ||
render(<Counter />); | ||
``` | ||
@@ -70,38 +64,35 @@ | ||
## Who's Using Ink? | ||
- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing fast websites. | ||
- [Parcel](https://parceljs.org) - Blazing fast, zero configuration web application bundler. | ||
- [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript. | ||
- [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema. | ||
- [Prisma](https://www.prisma.io) - The unified data layer for modern applications. | ||
- [Wallace](https://www.projectwallace.com) - Pretty CSS analytics on the CLI. | ||
- [tink](https://github.com/npm/tink) - Next-generation runtime and package manager. | ||
- [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. | ||
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emoji on the command-line. | ||
- [emma](https://github.com/maticzav/emma-cli) - Terminal assistant to find and install npm packages. | ||
- [sindresorhus](https://github.com/sindresorhus/sindresorhus) - The Sindre Sorhus CLI. | ||
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command line tools for time-saving web developers. | ||
- [share](https://github.com/marionebl/share-cli) - Quickly share files from your command line. | ||
- [Kubelive](https://github.com/ameerthehacker/kubelive) - CLI for Kubernetes to provide live data about the cluster and its resources. | ||
- [changelog-view](https://github.com/jdeniau/changelog-view) - Tool view changelog in console. | ||
- [gomoku-terminal](https://github.com/acrazing/gomoku-terminal) - Play online Gomoku in the terminal. | ||
- [cfpush](https://github.com/mamachanko/cfpush) - An interactive Cloud Foundry tutorial in your terminal. | ||
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app from the command-line. | ||
- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing fast websites. | ||
- [Parcel](https://parceljs.org) - Blazing fast, zero configuration web application bundler. | ||
- [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript. | ||
- [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema. | ||
- [Prisma](https://www.prisma.io) - The unified data layer for modern applications. | ||
- [Wallace](https://www.projectwallace.com) - Pretty CSS analytics on the CLI. | ||
- [tink](https://github.com/npm/tink) - Next-generation runtime and package manager. | ||
- [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. | ||
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emoji on the command-line. | ||
- [emma](https://github.com/maticzav/emma-cli) - Terminal assistant to find and install npm packages. | ||
- [sindresorhus](https://github.com/sindresorhus/sindresorhus) - The Sindre Sorhus CLI. | ||
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command line tools for time-saving web developers. | ||
- [share](https://github.com/marionebl/share-cli) - Quickly share files from your command line. | ||
- [Kubelive](https://github.com/ameerthehacker/kubelive) - CLI for Kubernetes to provide live data about the cluster and its resources. | ||
- [changelog-view](https://github.com/jdeniau/changelog-view) - Tool view changelog in console. | ||
- [gomoku-terminal](https://github.com/acrazing/gomoku-terminal) - Play online Gomoku in the terminal. | ||
- [cfpush](https://github.com/mamachanko/cfpush) - An interactive Cloud Foundry tutorial in your terminal. | ||
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app from the command-line. | ||
## Contents | ||
- [Getting Started](#getting-started) | ||
- [Examples](#examples) | ||
- [API](#api) | ||
- [Building Layouts](#building-layouts) | ||
- [Built-in Components](#built-in-components) | ||
- [Hooks](#hooks) | ||
- [Useful Components](#useful-components) | ||
- [Testing](#testing) | ||
- [Experimental mode](#experimental-mode) | ||
- [Getting Started](#getting-started) | ||
- [Examples](#examples) | ||
- [API](#api) | ||
- [Building Layouts](#building-layouts) | ||
- [Built-in Components](#built-in-components) | ||
- [Hooks](#hooks) | ||
- [Useful Components](#useful-components) | ||
- [Testing](#testing) | ||
- [Experimental mode](#experimental-mode) | ||
## Getting Started | ||
@@ -136,22 +127,16 @@ | ||
```jsx | ||
import React from 'react'; | ||
import {render, Box} from 'ink'; | ||
import React from "react"; | ||
import { render, Box } from "ink"; | ||
const Demo = () => ( | ||
<Box> | ||
Hello World | ||
</Box> | ||
); | ||
const Demo = () => <Box>Hello World</Box>; | ||
render(<Demo/>); | ||
render(<Demo />); | ||
``` | ||
## Examples | ||
- [Jest](examples/jest/jest.js) - Implementation of basic Jest UI [(live demo)](https://ink-jest-demo.vadimdemedes.repl.run/). | ||
- [Counter](examples/counter/counter.js) - Simple counter that increments every 100ms [(live demo)](https://ink-counter-demo.vadimdemedes.repl.run/). | ||
- [Form with Validation](https://github.com/final-form/rff-cli-example) - Using framework agnostic form library, [🏁 Final Form](https://github.com/final-form/final-form#-final-form) to manage input state. | ||
- [Jest](examples/jest/jest.js) - Implementation of basic Jest UI [(live demo)](https://ink-jest-demo.vadimdemedes.repl.run/). | ||
- [Counter](examples/counter/counter.js) - Simple counter that increments every 100ms [(live demo)](https://ink-counter-demo.vadimdemedes.repl.run/). | ||
- [Form with Validation](https://github.com/final-form/rff-cli-example) - Using framework agnostic form library, [🏁 Final Form](https://github.com/final-form/final-form#-final-form) to manage input state. | ||
## API | ||
@@ -214,4 +199,4 @@ | ||
```jsx | ||
import React, {Component} from 'react'; | ||
import {render, Box} from 'ink'; | ||
import React, { Component } from "react"; | ||
import { render, Box } from "ink"; | ||
@@ -228,7 +213,3 @@ class Counter extends Component { | ||
render() { | ||
return ( | ||
<Box> | ||
Iteration #{this.state.i} | ||
</Box> | ||
); | ||
return <Box>Iteration #{this.state.i}</Box>; | ||
} | ||
@@ -249,3 +230,3 @@ | ||
const app = render(<Counter/>); | ||
const app = render(<Counter />); | ||
@@ -274,8 +255,8 @@ setTimeout(() => { | ||
// Update props of the root node | ||
const {rerender} = render(<Counter count={1}/>); | ||
rerender(<Counter count={2}/>); | ||
const { rerender } = render(<Counter count={1} />); | ||
rerender(<Counter count={2} />); | ||
// Replace root node | ||
const {rerender} = render(<OldCounter/>); | ||
rerender(<NewCounter/>); | ||
const { rerender } = render(<OldCounter />); | ||
rerender(<NewCounter />); | ||
``` | ||
@@ -288,3 +269,3 @@ | ||
```jsx | ||
const {unmount} = render(<MyApp/>); | ||
const { unmount } = render(<MyApp />); | ||
unmount(); | ||
@@ -298,3 +279,3 @@ ``` | ||
```jsx | ||
const {unmount, waitUntilExit} = render(<MyApp/>); | ||
const { unmount, waitUntilExit } = render(<MyApp />); | ||
@@ -313,3 +294,2 @@ setTimeout(unmount, 1000); | ||
### Built-in Components | ||
@@ -324,3 +304,3 @@ | ||
```js | ||
import {Box} from 'ink'; | ||
import { Box } from "ink"; | ||
``` | ||
@@ -342,4 +322,3 @@ | ||
<Box width={10}> | ||
<Box width="50%">X</Box> | ||
Y | ||
<Box width="50%">X</Box>Y | ||
</Box> //=> 'X Y' | ||
@@ -360,4 +339,3 @@ ``` | ||
<Box height={6} flexDirection="column"> | ||
<Box height="50%">X</Box> | ||
Y | ||
<Box height="50%">X</Box>Y | ||
</Box> //=> 'X\n\n\nY\n\n' | ||
@@ -387,3 +365,3 @@ ``` | ||
*Note:* Ink doesn't wrap text by default. | ||
_Note:_ Ink doesn't wrap text by default. | ||
@@ -511,5 +489,3 @@ ```jsx | ||
Label: | ||
<Box flexGrow={1}> | ||
Fills all remaining space | ||
</Box> | ||
<Box flexGrow={1}>Fills all remaining space</Box> | ||
</Box> | ||
@@ -530,5 +506,3 @@ ``` | ||
</Box> | ||
<Box width={10}> | ||
Will be 3/4 | ||
</Box> | ||
<Box width={10}>Will be 3/4</Box> | ||
</Box> | ||
@@ -545,4 +519,3 @@ ``` | ||
<Box width={6}> | ||
<Box flexBasis={3}>X</Box> | ||
Y | ||
<Box flexBasis={3}>X</Box>Y | ||
</Box> //=> 'X Y' | ||
@@ -553,4 +526,3 @@ ``` | ||
<Box width={6}> | ||
<Box flexBasis="50%">X</Box> | ||
Y | ||
<Box flexBasis="50%">X</Box>Y | ||
</Box> //=> 'X Y' | ||
@@ -663,3 +635,2 @@ ``` | ||
#### `<Color>` | ||
@@ -673,3 +644,3 @@ | ||
```js | ||
import {Color} from 'ink'; | ||
import { Color } from "ink"; | ||
``` | ||
@@ -700,3 +671,3 @@ | ||
```js | ||
import {Text} from 'ink'; | ||
import { Text } from "ink"; | ||
``` | ||
@@ -752,3 +723,3 @@ | ||
{tests.map(test => ( | ||
<Test key={test.id} title={test.title}/> | ||
<Test key={test.id} title={test.title} /> | ||
))} | ||
@@ -758,3 +729,3 @@ </Static> | ||
<Box marginTop={1}> | ||
<TestResults passed={results.passed} failed={results.failed}/> | ||
<TestResults passed={results.passed} failed={results.failed} /> | ||
</Box> | ||
@@ -773,3 +744,3 @@ </> | ||
```js | ||
import {AppContext} from 'ink'; | ||
import { AppContext } from "ink"; | ||
``` | ||
@@ -803,3 +774,3 @@ | ||
```js | ||
import {StdinContext} from 'ink'; | ||
import { StdinContext } from "ink"; | ||
``` | ||
@@ -819,5 +790,3 @@ | ||
<StdinContext.Consumer> | ||
{({ stdin }) => ( | ||
<MyComponent stdin={stdin}/> | ||
)} | ||
{({ stdin }) => <MyComponent stdin={stdin} />} | ||
</StdinContext.Consumer> | ||
@@ -837,5 +806,9 @@ ``` | ||
<StdinContext.Consumer> | ||
{({ isRawModeSupported, setRawMode, stdin }) => ( | ||
isRawModeSupported ? <MyInputComponent setRawMode={setRawMode} stdin={stdin}/> : <MyComponentThatDoesntUseInput /> | ||
)} | ||
{({ isRawModeSupported, setRawMode, stdin }) => | ||
isRawModeSupported ? ( | ||
<MyInputComponent setRawMode={setRawMode} stdin={stdin} /> | ||
) : ( | ||
<MyComponentThatDoesntUseInput /> | ||
) | ||
} | ||
</StdinContext.Consumer> | ||
@@ -849,3 +822,3 @@ ``` | ||
See [`setRawMode`](https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode). | ||
Ink exposes this function via own `<StdinContext>` to be able to handle <kbd>Ctrl</kbd>+<kbd>C</kbd>, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`. Ink also enables `keypress` events via [`readline.emitKeypressEvents()`](https://nodejs.org/api/readline.html#readline_readline_emitkeypressevents_stream_interface) when raw mode is enabled. | ||
Ink exposes this function via own `<StdinContext>` to be able to handle <kbd>Ctrl</kbd>+<kbd>C</kbd>, that's why you should use Ink's `setRawMode` instead of `process.stdin.setRawMode`. | ||
@@ -858,5 +831,3 @@ **Warning:** This function will throw unless the current `stdin` supports `setRawMode`. Use [`isRawModeSupported`](#israwmodesupported) to detect `setRawMode` support. | ||
<StdinContext.Consumer> | ||
{({ setRawMode }) => ( | ||
<MyComponent setRawMode={setRawMode}/> | ||
)} | ||
{({ setRawMode }) => <MyComponent setRawMode={setRawMode} />} | ||
</StdinContext.Consumer> | ||
@@ -872,3 +843,3 @@ ``` | ||
```js | ||
import {StdoutContext} from 'ink'; | ||
import { StdoutContext } from "ink"; | ||
``` | ||
@@ -885,5 +856,3 @@ | ||
<StdoutContext.Consumer> | ||
{({ stdout }) => ( | ||
<MyComponent stdout={stdout}/> | ||
)} | ||
{({ stdout }) => <MyComponent stdout={stdout} />} | ||
</StdoutContext.Consumer> | ||
@@ -935,4 +904,7 @@ ``` | ||
##### key.leftArrow | ||
##### key.rightArrow | ||
##### key.upArrow | ||
##### key.downArrow | ||
@@ -979,6 +951,6 @@ | ||
```js | ||
import {useApp} from 'ink'; | ||
import { useApp } from "ink"; | ||
const MyApp = () => { | ||
const {exit} = useApp(); | ||
const { exit } = useApp(); | ||
}; | ||
@@ -991,3 +963,3 @@ ``` | ||
<AppContext.Consumer> | ||
{({exit}) => { | ||
{({ exit }) => { | ||
// … | ||
@@ -1008,19 +980,18 @@ }} | ||
## Useful Components | ||
- [ink-text-input](https://github.com/vadimdemedes/ink-text-input) - Text input. | ||
- [ink-spinner](https://github.com/vadimdemedes/ink-spinner) - Spinner. | ||
- [ink-select-input](https://github.com/vadimdemedes/ink-select-input) - Select (dropdown) input. | ||
- [ink-link](https://github.com/sindresorhus/ink-link) - Link component. | ||
- [ink-box](https://github.com/sindresorhus/ink-box) - Styled box component. | ||
- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color component. | ||
- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text component. | ||
- [ink-image](https://github.com/kevva/ink-image) - Display images inside the terminal. | ||
- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab component. | ||
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings in Ink. | ||
- [ink-multi-select](https://github.com/karaggeorge/ink-multi-select) - Select one or more values from a list | ||
- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider component. | ||
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) - Configurable component for rendering progress bars. | ||
- [ink-table](https://github.com/maticzav/ink-table) - Table component. | ||
- [ink-text-input](https://github.com/vadimdemedes/ink-text-input) - Text input. | ||
- [ink-spinner](https://github.com/vadimdemedes/ink-spinner) - Spinner. | ||
- [ink-select-input](https://github.com/vadimdemedes/ink-select-input) - Select (dropdown) input. | ||
- [ink-link](https://github.com/sindresorhus/ink-link) - Link component. | ||
- [ink-box](https://github.com/sindresorhus/ink-box) - Styled box component. | ||
- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color component. | ||
- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text component. | ||
- [ink-image](https://github.com/kevva/ink-image) - Display images inside the terminal. | ||
- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab component. | ||
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings in Ink. | ||
- [ink-multi-select](https://github.com/karaggeorge/ink-multi-select) - Select one or more values from a list | ||
- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider component. | ||
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) - Configurable component for rendering progress bars. | ||
- [ink-table](https://github.com/maticzav/ink-table) - Table component. | ||
@@ -1031,15 +1002,14 @@ ### Incompatible components | ||
- [ink-console](https://github.com/ForbesLindesay/ink-console) - Render output from `console[method]` calls in a scrollable panel. | ||
- [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input. | ||
- [ink-checkbox-list](https://github.com/MaxMEllon/ink-checkbox-list) - Checkbox. | ||
- [ink-quicksearch](https://github.com/aicioara/ink-quicksearch) - Select Component with fast quicksearch-like navigation | ||
- [ink-autocomplete](https://github.com/maticzav/ink-autocomplete) - Autocomplete. | ||
- [ink-broadcast](https://github.com/jimmed/ink-broadcast) - Implementation of react-broadcast for Ink. | ||
- [ink-router](https://github.com/jimmed/ink-router) - Implementation of react-router for Ink. | ||
- [ink-select](https://github.com/karaggeorge/ink-select) - Select component. | ||
- [ink-scrollbar](https://github.com/karaggeorge/ink-scrollbar) - Scrollbar component. | ||
- [ink-text-animation](https://github.com/yardnsm/ink-text-animation) - Text animation component. | ||
- [ink-figlet](https://github.com/KimotoYanke/ink-figlet) - Large text component with Figlet fonts. | ||
- [ink-console](https://github.com/ForbesLindesay/ink-console) - Render output from `console[method]` calls in a scrollable panel. | ||
- [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input. | ||
- [ink-checkbox-list](https://github.com/MaxMEllon/ink-checkbox-list) - Checkbox. | ||
- [ink-quicksearch](https://github.com/aicioara/ink-quicksearch) - Select Component with fast quicksearch-like navigation | ||
- [ink-autocomplete](https://github.com/maticzav/ink-autocomplete) - Autocomplete. | ||
- [ink-broadcast](https://github.com/jimmed/ink-broadcast) - Implementation of react-broadcast for Ink. | ||
- [ink-router](https://github.com/jimmed/ink-router) - Implementation of react-router for Ink. | ||
- [ink-select](https://github.com/karaggeorge/ink-select) - Select component. | ||
- [ink-scrollbar](https://github.com/karaggeorge/ink-scrollbar) - Scrollbar component. | ||
- [ink-text-animation](https://github.com/yardnsm/ink-text-animation) - Text animation component. | ||
- [ink-figlet](https://github.com/KimotoYanke/ink-figlet) - Large text component with Figlet fonts. | ||
## Testing | ||
@@ -1051,10 +1021,10 @@ | ||
```jsx | ||
import React from 'react'; | ||
import {Text} from 'ink'; | ||
import {render} from 'ink-testing-library'; | ||
import React from "react"; | ||
import { Text } from "ink"; | ||
import { render } from "ink-testing-library"; | ||
const Test = () => <Text>Hello World</Text>; | ||
const {lastFrame} = render(<Test/>); | ||
const { lastFrame } = render(<Test />); | ||
lastFrame() === 'Hello World'; //=> true | ||
lastFrame() === "Hello World"; //=> true | ||
``` | ||
@@ -1073,3 +1043,3 @@ | ||
```jsx | ||
render(<App/>, {experimental: true}); | ||
render(<App />, { experimental: true }); | ||
``` | ||
@@ -1092,11 +1062,10 @@ | ||
- Output can become janky, since erasing terminal is not a "cheap" operation. | ||
- Entire scrollback history in that terminal session will be lost. | ||
- Output can become janky, since erasing terminal is not a "cheap" operation. | ||
- Entire scrollback history in that terminal session will be lost. | ||
It is, however, the only way known now to handle this. | ||
## Maintainers | ||
- [Vadim Demedes](https://github.com/vadimdemedes) | ||
- [Sindre Sorhus](https://github.com/sindresorhus) | ||
- [Vadim Demedes](https://github.com/vadimdemedes) | ||
- [Sindre Sorhus](https://github.com/sindresorhus) |
119100
2259
22
1030
+ Added@types/react@18.3.3(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedarrify@2.0.1(transitive)
+ Addedastral-regex@2.0.0(transitive)
+ Addedauto-bind@3.0.0(transitive)
+ Addedchalk@3.0.0(transitive)
+ Addedcli-cursor@3.1.0(transitive)
+ Addedcli-truncate@2.1.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedmimic-fn@2.1.0(transitive)
+ Addedonetime@5.1.2(transitive)
+ Addedreact-reconciler@0.24.0(transitive)
+ Addedrestore-cursor@3.1.0(transitive)
+ Addedscheduler@0.18.0(transitive)
+ Addedslice-ansi@3.0.0(transitive)
+ Addedstring-length@3.1.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedwidest-line@3.1.0(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
- Removed@types/react@^16.8.6
- Removed@types/react@16.14.60(transitive)
- Removed@types/scheduler@0.16.8(transitive)
- Removedansi-regex@3.0.1(transitive)
- Removedarrify@1.0.1(transitive)
- Removedauto-bind@2.1.1(transitive)
- Removedchalk@2.4.2(transitive)
- Removedcli-truncate@1.1.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedreact-reconciler@0.21.0(transitive)
- Removedscheduler@0.15.0(transitive)
- Removedslice-ansi@1.0.0(transitive)
- Removedstring-length@2.0.0(transitive)
- Removedstring-width@2.1.1(transitive)
- Removedstrip-ansi@4.0.0(transitive)
- Removedsupports-color@5.5.0(transitive)
- Removedwidest-line@2.0.1(transitive)
Updatedarrify@^2.0.1
Updatedauto-bind@^3.0.0
Updatedchalk@^3.0.0
Updatedcli-cursor@^3.1.0
Updatedcli-truncate@^2.0.0
Updatedreact-reconciler@^0.24.0
Updatedscheduler@^0.18.0
Updatedslice-ansi@^3.0.0
Updatedstring-length@^3.1.0
Updatedwidest-line@^3.1.0
Updatedwrap-ansi@^6.2.0