From efa037d34be7b1570efdc767c79fad8d4005f10e Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 12:57:33 +0200 Subject: Add new code new version Change-Id: Ic02a76313503b526f17c3df29eb387a29fe6a42a Signed-off-by: Michael Lando --- .../src/nfvo-components/input/ExpandableInput.jsx | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx (limited to 'openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx') diff --git a/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx b/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx new file mode 100644 index 0000000000..3ac3fcad28 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx @@ -0,0 +1,77 @@ +import React from 'react'; +import FontAwesome from 'react-fontawesome'; +import classnames from 'classnames'; +import Input from 'react-bootstrap/lib/Input'; + + +class ExpandableInput extends React.Component { + constructor(props){ + super(props); + this.state = {showInput: false, value: ''}; + this.toggleInput = this.toggleInput.bind(this); + this.handleFocus = this.handleFocus.bind(this); + this.handleInput = this.handleInput.bind(this); + this.handleClose = this.handleClose.bind(this); + } + + toggleInput(){ + if (!this.state.showInput){ + this.searchInputNode.refs.input.focus(); + } else { + this.setState({showInput: false}); + } + } + + handleInput(e){ + let {onChange} = this.props; + + this.setState({value: e.target.value}); + onChange(e); + } + + handleClose(){ + this.handleInput({target: {value: ''}}); + this.searchInputNode.refs.input.focus(); + } + + handleFocus(){ + if (!this.state.showInput){ + this.setState({showInput: true}); + } + } + + getValue(){ + return this.state.value; + } + + render(){ + let {iconType} = this.props; + + let inputClasses = classnames({ + 'expandable-active': this.state.showInput, + 'expandable-not-active': !this.state.showInput + }); + + let iconClasses = classnames( + 'expandable-icon', + {'expandable-icon-active': this.state.showInput} + ); + + return ( +
+ this.searchInputNode = input} + className={inputClasses} + groupClassName='expandable-input-control' + onChange={e => this.handleInput(e)} + onFocus={this.handleFocus}/> + {this.state.showInput && this.state.value && } + {!this.state.value && } +
+ ); + } +} + +export default ExpandableInput; -- cgit 1.2.3-korg