0.6.1 • Published 9 years ago

react-console-component v0.6.1

Weekly downloads
398
License
GPL-3.0
Repository
github
Last release
9 years ago

react-console

Simple React.js console emulator.

NPM Version NPM Downloads Travis Build Coverage Status

Dependency Status devDependency Status peerDependency Status

Demo Image

Example

Simple prompt that echoes back input:

let EchoConsole = React.createClass({
	echo: function(text) {
		this.refs.console.log(text);
		this.refs.console.return();
	},
	render: function() {
		return <Console ref="console"
			handler={this.echo}
			autofocus={true}
		/>;
	}
});

See the example project used in the live demo.

Installation

npm install --save-dev react-console-component

Features

  • Readline emulation
  • Mobile friendly
  • Input Method Editor (IME) support

Props

Properties you can pass to the console element

PropTypeDescription
autofocus?boolAutofocus the console on component mount.
cancel?function(): anyFunction that should stop execution of the current command and call this.return().
complete?function(words: string[], cursor: number, prompt: string): string[]Return a list of possible completions given a list of (words), index of the word containing the cursor (cursor) , and the full prompt text (prompt).
continue?function(prompt: string): boolReturn a boolean indicating whether to continue asking for user input on a newline given the current prompt text (prompt).
handlerfunction(command: string): anyHandle a command (command), logging data with this.log() or this.logX(), and calling this.return() when finished.
promptLabel?stringfunction(): stringString displayed to prompt user for input.
welcomeMessage?stringInitial message displayed after mount.

Public members

MemberTypeDescription
logfunction(...messages: any): voidLog messages to the console. If string, print the value, otherwise, print the JSON value of the message.
logXfunction(type: string, ...messages: any): voidLog messages of a particular type to the console. The messages will be given the class react-console-message-{type}.
returnfunction(): voidSignal the current command has finished and a new prompt should be displayed.

Awknoledgements

React-console is inspired by chrisdone/jquery-console.

0.6.1

9 years ago

0.6.0

10 years ago

0.5.2

10 years ago

0.5.1

10 years ago

0.5.0

10 years ago

0.4.2

10 years ago

0.4.1

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago