1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-01 00:08:27 +01:00
unleash.unleash/packages/unleash-frontend/public/js/components/form/TextInput.jsx

48 lines
1.2 KiB
React
Raw Normal View History

2016-06-18 21:53:18 +02:00
'use strict';
const React = require('react');
2016-06-18 21:53:18 +02:00
const TextInput = React.createClass({
propTypes: {
name: React.PropTypes.string.isRequired,
label: React.PropTypes.string.isRequired,
id: React.PropTypes.string.isRequired,
placeholder: React.PropTypes.string,
value: React.PropTypes.string,
2016-06-18 21:55:46 +02:00
required: React.PropTypes.bool,
},
2016-07-02 11:54:50 +02:00
getDefaultProps () {
return {
2016-06-18 21:55:46 +02:00
required: false,
};
},
2016-07-02 11:54:50 +02:00
getInitialState () {
return {};
},
2016-07-02 11:54:50 +02:00
getValue () {
return this.refs.input.getDOMNode().value.trim();
},
2016-07-02 11:54:50 +02:00
render () {
return (
<div className="formelement required">
<label htmlFor={this.props.id} className="t4">{this.props.label}</label>
<div className="input">
<input type="text"
id={this.props.id}
name={this.props.name}
defaultValue={this.props.value}
placeholder={this.props.placeholder}
disabled={this.props.disabled}
ref="input" />
</div>
</div>
);
2016-06-18 21:55:46 +02:00
},
});
2016-06-18 21:55:46 +02:00
module.exports = TextInput;