Files
ohif-viewer/platform/ui/src/elements/form/Select.js
T

48 lines
978 B
JavaScript
Raw Normal View History

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);
this.state = { value: this.props.value };
}
handleChange = event => {
this.setState({ value: event.target.value });
if (this.props.onChange) this.props.onChange();
};
render() {
return (
<select
className="select-ohif"
value={this.state.selected}
onChange={this.handleChange}
>
{this.props.options.map(({ key, value }) => {
return (
<option key={key} value={value}>
{key}
</option>
);
})}
</select>
);
}
}
Select.propTypes = {
options: PropTypes.arrayOf(
PropTypes.shape({
key: PropTypes.string.isRequired,
value: PropTypes.string.isRequired,
})
),
value: PropTypes.string,
onChange: PropTypes.func,
};
export { Select };