All files / src/Control Input.jsx

87.5% Statements 7/8
83.33% Branches 5/6
100% Functions 3/3
87.5% Lines 7/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24          66x     2x 1x   2x         43x 43x 43x          
import * as React from 'react';
import Base from './Base';
 
class Input extends React.Component {
  static defaultProps = {
    component: props => <input {...props.controlProps}/>
  }
  handleKeyDown(e) {
    if (this.props.preventEnter && e.keyCode == 13) {
      e.preventDefault();
    }
    Iif (this.props.onKeyDown) {
      this.props.onKeyDown(e);
    }
  }
  render() {
    let props = {...this.props};
    delete props['preventEnter'];
    return <Base {...props} onKeyDown={::this.handleKeyDown}/>;
  }
}
 
export default Input;