ink-text-input
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -49,13 +49,10 @@ 'use strict'; | ||
const chars = value.split(''); | ||
if (key.name === 'backspace') { | ||
chars.pop(); | ||
onChange(value.slice(0, -1)); | ||
return; | ||
} | ||
if (key.sequence === ch) { | ||
chars.push(ch); | ||
if (key.name === 'space' || key.sequence === ch && /^.*$/.test(ch) && !key.ctrl) { | ||
onChange(value + ch); | ||
} | ||
onChange(chars.join('')); | ||
} | ||
@@ -62,0 +59,0 @@ } |
170
package.json
{ | ||
"name": "ink-text-input", | ||
"version": "1.0.0", | ||
"description": "Text input component for Ink", | ||
"license": "MIT", | ||
"repository": "vadimdemedes/ink-text-input", | ||
"author": { | ||
"name": "Vadim Demedes", | ||
"email": "vdemedes@gmail.com", | ||
"url": "github.com/vadimdemedes" | ||
}, | ||
"engines": { | ||
"node": ">= 6" | ||
}, | ||
"scripts": { | ||
"pretest": "npm run build", | ||
"test": "xo && ava", | ||
"build": "babel src -d dist", | ||
"prepublish": "npm run build" | ||
}, | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"ink" | ||
], | ||
"dependencies": { | ||
"has-ansi": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.20.0", | ||
"babel-cli": "^6.24.1", | ||
"babel-plugin-transform-react-jsx": "^6.24.1", | ||
"eslint-config-xo-react": "^0.13.0", | ||
"eslint-plugin-react": "^7.1.0", | ||
"ink": "^0.1.2", | ||
"sinon": "^2.3.6", | ||
"xo": "^0.18.2" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@ava/stage-4" | ||
], | ||
"plugins": [ | ||
[ | ||
"transform-react-jsx", | ||
{ | ||
"pragma": "h", | ||
"useBuiltIns": true | ||
} | ||
] | ||
] | ||
}, | ||
"ava": { | ||
"babel": { | ||
"plugins": [ | ||
[ | ||
"transform-react-jsx", | ||
{ | ||
"pragma": "h", | ||
"useBuiltIns": true | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
"xo": { | ||
"extends": [ | ||
"xo-react" | ||
], | ||
"plugins": [ | ||
"react" | ||
], | ||
"rules": { | ||
"react/prop-types": 0 | ||
}, | ||
"settings": { | ||
"react": { | ||
"pragma": "h" | ||
} | ||
} | ||
} | ||
"name": "ink-text-input", | ||
"version": "1.0.1", | ||
"description": "Text input component for Ink", | ||
"license": "MIT", | ||
"repository": "vadimdemedes/ink-text-input", | ||
"author": { | ||
"name": "Vadim Demedes", | ||
"email": "vdemedes@gmail.com", | ||
"url": "github.com/vadimdemedes" | ||
}, | ||
"main": "dist/index.js", | ||
"engines": { | ||
"node": ">=6" | ||
}, | ||
"scripts": { | ||
"pretest": "npm run build", | ||
"test": "xo && ava", | ||
"build": "babel src --out-dir=dist", | ||
"prepublish": "npm run build" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"keywords": [ | ||
"ink", | ||
"text", | ||
"input", | ||
"component", | ||
"jsx", | ||
"react", | ||
"stdin", | ||
"keypress", | ||
"search", | ||
"query" | ||
], | ||
"dependencies": { | ||
"has-ansi": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.20.0", | ||
"babel-cli": "^6.24.1", | ||
"babel-plugin-transform-react-jsx": "^6.24.1", | ||
"eslint-config-xo-react": "^0.13.0", | ||
"eslint-plugin-react": "^7.1.0", | ||
"ink": "^0.1.2", | ||
"sinon": "^2.3.6", | ||
"xo": "^0.18.2" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@ava/stage-4" | ||
], | ||
"plugins": [ | ||
[ | ||
"transform-react-jsx", | ||
{ | ||
"pragma": "h", | ||
"useBuiltIns": true | ||
} | ||
] | ||
] | ||
}, | ||
"ava": { | ||
"babel": { | ||
"plugins": [ | ||
[ | ||
"transform-react-jsx", | ||
{ | ||
"pragma": "h", | ||
"useBuiltIns": true | ||
} | ||
] | ||
] | ||
} | ||
}, | ||
"xo": { | ||
"extends": [ | ||
"xo-react" | ||
], | ||
"rules": { | ||
"react/prop-types": 0 | ||
}, | ||
"settings": { | ||
"react": { | ||
"pragma": "h" | ||
} | ||
} | ||
} | ||
} |
@@ -9,3 +9,3 @@ # ink-text-input [![Build Status](https://travis-ci.org/vadimdemedes/ink-text-input.svg?branch=master)](https://travis-ci.org/vadimdemedes/ink-text-input) | ||
``` | ||
$ npm install --save ink-text-input | ||
$ npm install ink-text-input | ||
``` | ||
@@ -53,3 +53,3 @@ | ||
handleSubmit(value) { | ||
// query submitted | ||
// Query submitted | ||
} | ||
@@ -61,3 +61,3 @@ } | ||
**Note**: For `<TextInput>` to be able to receive `keypress` events, `process.stdin` must be in raw mode. As a result, default behavior like Ctrl+C is disabled, so you must handle that manually. | ||
**Note**: For `<TextInput>` to be able to receive `keypress` events, `process.stdin` must be in [raw mode](https://nodejs.org/api/tty.html#tty_readstream_setrawmode_mode). As a result, default behavior like Ctrl+C is disabled, so you must handle that manually. | ||
@@ -67,2 +67,4 @@ Use this snippet to enable `keypress` events: | ||
```js | ||
const readline = require('readline'); | ||
readline.emitKeypressEvents(process.stdin); | ||
@@ -89,3 +91,3 @@ process.stdin.setRawMode(true); | ||
Type: `function` | ||
Type: `Function` | ||
@@ -96,5 +98,5 @@ Function to call when value updates. | ||
Type: `function` | ||
Type: `Function` | ||
Function to call when user presses Enter. | ||
Function to call when user press <kbd>Enter</kbd>. | ||
@@ -101,0 +103,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6064
5
78
101