2019-08-13 15:36:46 -04:00
|
|
|
import './Select.css';
|
|
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
|
|
|
|
class Select extends Component {
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-25 23:46:32 -03:00
|
|
|
static propTypes = {
|
|
|
|
|
options: PropTypes.arrayOf(
|
|
|
|
|
PropTypes.shape({
|
|
|
|
|
key: PropTypes.string.isRequired,
|
|
|
|
|
value: PropTypes.string.isRequired,
|
|
|
|
|
})
|
|
|
|
|
),
|
|
|
|
|
value: PropTypes.string,
|
|
|
|
|
onChange: PropTypes.func,
|
|
|
|
|
};
|
|
|
|
|
|
2019-08-13 15:36:46 -04:00
|
|
|
handleChange = event => {
|
2019-10-01 05:06:56 -03:00
|
|
|
const value = event.target.value;
|
|
|
|
|
this.setState({ value });
|
|
|
|
|
if (this.props.onChange) this.props.onChange(value);
|
2019-08-13 15:36:46 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
2019-10-25 23:46:32 -03:00
|
|
|
<div className="select-ohif-container">
|
|
|
|
|
<label className="select-ohif-label" htmlFor={this.id}>
|
|
|
|
|
{this.props.label}
|
2019-10-27 23:10:20 -04:00
|
|
|
<select className="form-control select-ohif" {...this.props}>
|
2019-10-25 23:46:32 -03:00
|
|
|
{this.props.options.map(({ key, value }) => {
|
|
|
|
|
return (
|
|
|
|
|
<option key={key} value={value}>
|
|
|
|
|
{key}
|
|
|
|
|
</option>
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</select>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
2019-08-13 15:36:46 -04:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { Select };
|