Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

vadimdemedes/ink-password-input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: This component is deprecated in favor of ink-text-input. Password input could be simulated with <TextInput mask="*"/>.

ink-password-input Build Status

Password input component for Ink.

Install

$ npm install ink-password-input

Usage

const {h, render, Component} = require('ink');
const PasswordInput = require('ink-password-input');

class Auth extends Component {
	constructor(props) {
		super(props);

		this.state = {
			password: ''
		};

		this.handleChange = this.handleChange.bind(this);
		this.handleSubmit = this.handleSubmit.bind(this);
	}

	render(props, state) {
		return (
			<span>
				Password:

				<PasswordInput
					value={state.password}
					placeholder="Enter your password"
					onChange={this.handleChange}
					onSubmit={this.handleSubmit}
				/>
			</span>
		);
	}

	handleChange(value) {
		this.setState({
			password: value
		});
	}

	handleSubmit(value) {
		// Password submitted
	}
}

render(<Auth/>);

Props

value

Type: string

Value to display in a password input.

mask

Type: string
Default: *

Mask char to replace each char of the value with.

placeholder

Type: string

Text to display when value is empty.

onChange

Type: Function

Function to call when value updates.

onSubmit

Type: Function

Function to call when user press Enter.

License

MIT © Vadim Demedes

About

Password input component for Ink

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published