2.0.0 • Published 6 years ago

ink-password-input v2.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

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