ink-text-input
Advanced tools
Comparing version 5.0.1 to 6.0.0
@@ -1,2 +0,2 @@ | ||
/// <reference types="react" /> | ||
import React from 'react'; | ||
import type { Except } from 'type-fest'; | ||
@@ -7,3 +7,3 @@ export type Props = { | ||
*/ | ||
placeholder?: string; | ||
readonly placeholder?: string; | ||
/** | ||
@@ -13,29 +13,29 @@ * Listen to user's input. Useful in case there are multiple input components | ||
*/ | ||
focus?: boolean; | ||
readonly focus?: boolean; | ||
/** | ||
* Replace all chars and mask the value. Useful for password inputs. | ||
*/ | ||
mask?: string; | ||
readonly mask?: string; | ||
/** | ||
* Whether to show cursor and allow navigation inside text input with arrow keys. | ||
*/ | ||
showCursor?: boolean; | ||
readonly showCursor?: boolean; | ||
/** | ||
* Highlight pasted text | ||
*/ | ||
highlightPastedText?: boolean; | ||
readonly highlightPastedText?: boolean; | ||
/** | ||
* Value to display in a text input. | ||
*/ | ||
value: string; | ||
readonly value: string; | ||
/** | ||
* Function to call when value updates. | ||
*/ | ||
onChange: (value: string) => void; | ||
readonly onChange: (value: string) => void; | ||
/** | ||
* Function to call when `Enter` is pressed, where first argument is a value of the input. | ||
*/ | ||
onSubmit?: (value: string) => void; | ||
readonly onSubmit?: (value: string) => void; | ||
}; | ||
declare function TextInput({ value: originalValue, placeholder, focus, mask, highlightPastedText, showCursor, onChange, onSubmit }: Props): JSX.Element; | ||
declare function TextInput({ value: originalValue, placeholder, focus, mask, highlightPastedText, showCursor, onChange, onSubmit, }: Props): React.JSX.Element; | ||
export default TextInput; | ||
@@ -46,4 +46,4 @@ type UncontrolledProps = { | ||
*/ | ||
initialValue?: string; | ||
readonly initialValue?: string; | ||
} & Except<Props, 'value' | 'onChange'>; | ||
export declare function UncontrolledTextInput({ initialValue, ...props }: UncontrolledProps): JSX.Element; | ||
export declare function UncontrolledTextInput({ initialValue, ...props }: UncontrolledProps): React.JSX.Element; |
import React, { useState, useEffect } from 'react'; | ||
import { Text, useInput } from 'ink'; | ||
import chalk from 'chalk'; | ||
function TextInput({ value: originalValue, placeholder = '', focus = true, mask, highlightPastedText = false, showCursor = true, onChange, onSubmit }) { | ||
function TextInput({ value: originalValue, placeholder = '', focus = true, mask, highlightPastedText = false, showCursor = true, onChange, onSubmit, }) { | ||
const [state, setState] = useState({ | ||
cursorOffset: (originalValue || '').length, | ||
cursorWidth: 0 | ||
cursorWidth: 0, | ||
}); | ||
@@ -19,3 +19,3 @@ const { cursorOffset, cursorWidth } = state; | ||
cursorOffset: newValue.length, | ||
cursorWidth: 0 | ||
cursorWidth: 0, | ||
}; | ||
@@ -102,3 +102,3 @@ } | ||
cursorOffset: nextCursorOffset, | ||
cursorWidth: nextCursorWidth | ||
cursorWidth: nextCursorWidth, | ||
}); | ||
@@ -105,0 +105,0 @@ if (nextValue !== originalValue) { |
{ | ||
"name": "ink-text-input", | ||
"version": "5.0.1", | ||
"version": "6.0.0", | ||
"description": "Text input component for Ink", | ||
@@ -18,3 +18,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=14.16" | ||
"node": ">=18" | ||
}, | ||
@@ -43,27 +43,27 @@ "scripts": { | ||
"dependencies": { | ||
"chalk": "^5.2.0", | ||
"type-fest": "^3.6.1" | ||
"chalk": "^5.3.0", | ||
"type-fest": "^4.18.2" | ||
}, | ||
"devDependencies": { | ||
"@sindresorhus/tsconfig": "^3.0.1", | ||
"@types/react": "^18.0.0", | ||
"@types/sinon": "^10.0.13", | ||
"@vdemedes/prettier-config": "^1.0.1", | ||
"ava": "^5.1.1", | ||
"delay": "^5.0.0", | ||
"@sindresorhus/tsconfig": "^5.0.0", | ||
"@types/react": "^18.3.2", | ||
"@types/sinon": "^17.0.3", | ||
"@vdemedes/prettier-config": "^2.0.1", | ||
"ava": "^6.1.3", | ||
"delay": "^6.0.0", | ||
"eslint-config-xo-react": "^0.27.0", | ||
"eslint-plugin-react": "^7.32.2", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"ink": "^4.0.0", | ||
"ink-testing-library": "^3.0.0", | ||
"prettier": "^2.0.5", | ||
"react": "^18.0.0", | ||
"sinon": "^15.0.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.5", | ||
"xo": "^0.53.0" | ||
"eslint-plugin-react": "^7.34.1", | ||
"eslint-plugin-react-hooks": "^4.6.2", | ||
"ink": "^5.0.0", | ||
"ink-testing-library": "vadimdemedes/ink-testing-library#f44b077e9a05a1d615bab41c72906726d34ea085", | ||
"prettier": "^3.2.5", | ||
"react": "^18.3.1", | ||
"sinon": "^17.0.1", | ||
"tsimp": "^2.0.11", | ||
"typescript": "^5.4.5", | ||
"xo": "^0.58.0" | ||
}, | ||
"peerDependencies": { | ||
"ink": "^4.0.0", | ||
"react": "^18.0.0" | ||
"ink": ">=5", | ||
"react": ">=18" | ||
}, | ||
@@ -76,3 +76,3 @@ "ava": { | ||
"nodeArguments": [ | ||
"--loader=ts-node/esm" | ||
"--import=tsimp/import" | ||
] | ||
@@ -86,3 +86,3 @@ }, | ||
"rules": { | ||
"unicorn/no-hex-escape": 0 | ||
"unicorn/prevent-abbreviations": "off" | ||
} | ||
@@ -89,0 +89,0 @@ }, |
@@ -5,9 +5,7 @@ # ink-text-input ![test](https://github.com/vadimdemedes/ink-text-input/workflows/test/badge.svg) | ||
Looking for a version compatible with Ink 2.x? Check out [this release](https://github.com/vadimdemedes/ink-text-input/tree/v3.3.0). | ||
## Install | ||
```sh | ||
npm install ink-text-input | ||
``` | ||
$ npm install ink-text-input | ||
``` | ||
@@ -14,0 +12,0 @@ ## Usage |
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
15004
123
+ Addedansi-escapes@7.0.0(transitive)
+ Addedcli-truncate@4.0.0(transitive)
+ Addedemoji-regex@10.4.0(transitive)
+ Addedenvironment@1.1.0(transitive)
+ Addedget-east-asian-width@1.2.0(transitive)
+ Addedink@5.0.1(transitive)
+ Addedis-fullwidth-code-point@5.0.0(transitive)
+ Addedis-in-ci@0.1.0(transitive)
+ Addedslice-ansi@7.1.0(transitive)
+ Addedstring-width@7.2.0(transitive)
+ Addedtype-fest@4.26.1(transitive)
+ Addedwidest-line@5.0.0(transitive)
+ Addedwrap-ansi@9.0.0(transitive)
- Removedansi-escapes@6.2.1(transitive)
- Removedci-info@3.9.0(transitive)
- Removedcli-truncate@3.1.0(transitive)
- Removedeastasianwidth@0.2.0(transitive)
- Removedemoji-regex@9.2.2(transitive)
- Removedink@4.4.1(transitive)
- Removedis-ci@3.0.1(transitive)
- Removedis-lower-case@2.0.2(transitive)
- Removedis-upper-case@2.0.2(transitive)
- Removedslice-ansi@6.0.0(transitive)
- Removedstring-width@5.1.2(transitive)
- Removedtslib@2.7.0(transitive)
- Removedtype-fest@0.12.03.13.1(transitive)
- Removedwidest-line@4.0.1(transitive)
- Removedwrap-ansi@8.1.0(transitive)
Updatedchalk@^5.3.0
Updatedtype-fest@^4.18.2