2015-10-15 11:38:45 -04:00
|
|
|
var classNames = require('classnames');
|
2016-05-13 18:48:21 -04:00
|
|
|
var defaults = require('lodash.defaultsdeep');
|
2016-05-12 17:42:04 -04:00
|
|
|
var FRCSelect = require('formsy-react-components').Select;
|
|
|
|
var React = require('react');
|
2016-06-02 15:25:02 -04:00
|
|
|
var defaultValidationHOC = require('./validations.jsx').defaultValidationHOC;
|
2016-06-13 12:48:58 -04:00
|
|
|
var inputHOC = require('./input-hoc.jsx');
|
2015-10-15 11:38:45 -04:00
|
|
|
|
2016-06-13 12:48:58 -04:00
|
|
|
require('./row.scss');
|
2015-10-15 11:38:45 -04:00
|
|
|
require('./select.scss');
|
|
|
|
|
|
|
|
var Select = React.createClass({
|
|
|
|
type: 'Select',
|
|
|
|
propTypes: {
|
|
|
|
|
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
var classes = classNames(
|
|
|
|
'select',
|
|
|
|
this.props.className
|
|
|
|
);
|
2016-05-13 18:48:21 -04:00
|
|
|
var props = this.props;
|
|
|
|
if (this.props.required && !this.props.value) {
|
|
|
|
props = defaults({}, this.props, {value: this.props.options[0].value});
|
|
|
|
}
|
2015-10-15 11:38:45 -04:00
|
|
|
return (
|
2016-06-23 07:27:43 -04:00
|
|
|
<div className={classes}>
|
|
|
|
<FRCSelect {... props} />
|
|
|
|
</div>
|
2015-10-15 11:38:45 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-06-13 12:48:58 -04:00
|
|
|
module.exports = inputHOC(defaultValidationHOC(Select));
|