Socket
Socket
Sign inDemoInstall

ink-text-input

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ink-text-input - npm Package Compare versions

Comparing version 4.0.3 to 5.0.0

build/index.js.map

14

build/index.d.ts

@@ -1,4 +0,4 @@

import type { FC } from 'react';
/// <reference types="react" />
import type { Except } from 'type-fest';
interface Props {
type Props = {
/**

@@ -37,6 +37,6 @@ * Text to display when `value` is empty.

onSubmit?: (value: string) => void;
}
declare const TextInput: FC<Props>;
};
declare function TextInput({ value: originalValue, placeholder, focus, mask, highlightPastedText, showCursor, onChange, onSubmit }: Props): JSX.Element;
export default TextInput;
interface UncontrolledProps extends Except<Props, 'value' | 'onChange'> {
type UncontrolledProps = {
/**

@@ -46,3 +46,3 @@ * Initial value.

initialValue?: string;
}
export declare const UncontrolledTextInput: FC<UncontrolledProps>;
} & Except<Props, 'value' | 'onChange'>;
export declare function UncontrolledTextInput({ initialValue, ...props }: UncontrolledProps): JSX.Element;

@@ -1,14 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UncontrolledTextInput = void 0;
const React = require("react");
const react_1 = require("react");
const ink_1 = require("ink");
const chalk = require("chalk");
const TextInput = ({ value: originalValue, placeholder = '', focus = true, mask, highlightPastedText = false, showCursor = true, onChange, onSubmit }) => {
const [{ cursorOffset, cursorWidth }, setState] = react_1.useState({
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 }) {
const [state, setState] = useState({
cursorOffset: (originalValue || '').length,
cursorWidth: 0
});
react_1.useEffect(() => {
const { cursorOffset, cursorWidth } = state;
useEffect(() => {
setState(previousState => {

@@ -41,8 +38,6 @@ if (!focus || !showCursor) {

for (const char of value) {
if (i >= cursorOffset - cursorActualWidth && i <= cursorOffset) {
renderedValue += chalk.inverse(char);
}
else {
renderedValue += char;
}
renderedValue +=
i >= cursorOffset - cursorActualWidth && i <= cursorOffset
? chalk.inverse(char)
: char;
i++;

@@ -54,3 +49,3 @@ }

}
ink_1.useInput((input, key) => {
useInput((input, key) => {
if (key.upArrow ||

@@ -114,3 +109,3 @@ key.downArrow ||

}, { isActive: focus });
return (React.createElement(ink_1.Text, null, placeholder
return (React.createElement(Text, null, placeholder
? value.length > 0

@@ -120,7 +115,8 @@ ? renderedValue

: renderedValue));
};
exports.default = TextInput;
exports.UncontrolledTextInput = ({ initialValue = '', ...props }) => {
const [value, setValue] = react_1.useState(initialValue);
return React.createElement(TextInput, Object.assign({}, props, { value: value, onChange: setValue }));
};
}
export default TextInput;
export function UncontrolledTextInput({ initialValue = '', ...props }) {
const [value, setValue] = useState(initialValue);
return React.createElement(TextInput, { ...props, value: value, onChange: setValue });
}
//# sourceMappingURL=index.js.map
{
"name": "ink-text-input",
"version": "4.0.3",
"version": "5.0.0",
"description": "Text input component for Ink",

@@ -9,9 +9,12 @@ "license": "MIT",

"name": "Vadim Demedes",
"email": "vdemedes@gmail.com",
"url": "github.com/vadimdemedes"
"email": "vadimdemedes@hey.com",
"url": "https://github.com/vadimdemedes"
},
"main": "build",
"types": "build/index.d.ts",
"type": "module",
"exports": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
},
"engines": {
"node": ">=10"
"node": ">=14.16"
},

@@ -40,38 +43,36 @@ "scripts": {

"dependencies": {
"chalk": "^4.1.0",
"type-fest": "^0.15.1"
"chalk": "^5.2.0",
"type-fest": "^3.6.1"
},
"devDependencies": {
"@ava/babel": "^1.0.1",
"@babel/preset-react": "^7.10.1",
"@sindresorhus/tsconfig": "^0.7.0",
"@types/react": "^16.8.8",
"@vdemedes/prettier-config": "^1.0.0",
"ava": "^3.9.0",
"delay": "^4.3.0",
"eslint-config-xo-react": "^0.23.0",
"eslint-plugin-react": "^7.20.0",
"eslint-plugin-react-hooks": "^4.0.4",
"husky": "^4.2.5",
"ink": "^3.0.5",
"ink-testing-library": "^2.0.0",
"@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",
"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",
"pretty-quick": "^2.0.1",
"react": "^17.0.0",
"sinon": "^7.2.7",
"typescript": "^3.9.5",
"xo": "^0.32.0"
"react": "^18.0.0",
"sinon": "^15.0.1",
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"xo": "^0.53.0"
},
"peerDependencies": {
"ink": "^3.0.0-3",
"react": "^16.5.2 || ^17.0.0"
"ink": "^4.0.0",
"react": "^18.0.0"
},
"ava": {
"babel": {
"testOptions": {
"presets": [
"@babel/preset-react"
]
}
}
"extensions": {
"ts": "module",
"tsx": "module"
},
"nodeArguments": [
"--loader=ts-node/esm"
]
},

@@ -82,18 +83,8 @@ "xo": {

],
"plugins": [
"react"
],
"prettier": true,
"rules": {
"react/no-unused-prop-types": 0,
"react/prop-types": 0,
"unicorn/no-hex-escape": 0
}
},
"prettier": "@vdemedes/prettier-config",
"husky": {
"hooks": {
"pre-commit": "pretty-quick --staged"
}
}
"prettier": "@vdemedes/prettier-config"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc