scratch-www/src/components/forms/select.jsx
2016-06-23 07:27:43 -04:00

33 lines
937 B
JavaScript

var classNames = require('classnames');
var defaults = require('lodash.defaultsdeep');
var FRCSelect = require('formsy-react-components').Select;
var React = require('react');
var defaultValidationHOC = require('./validations.jsx').defaultValidationHOC;
var inputHOC = require('./input-hoc.jsx');
require('./row.scss');
require('./select.scss');
var Select = React.createClass({
type: 'Select',
propTypes: {
},
render: function () {
var classes = classNames(
'select',
this.props.className
);
var props = this.props;
if (this.props.required && !this.props.value) {
props = defaults({}, this.props, {value: this.props.options[0].value});
}
return (
<div className={classes}>
<FRCSelect {... props} />
</div>
);
}
});
module.exports = inputHOC(defaultValidationHOC(Select));