2017-09-25 02:06:28 +00:00
|
|
|
import React from 'react';
|
2017-10-04 17:51:37 +00:00
|
|
|
import Dropdown from 'components/ui/Dropdown';
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
interface UnitDropdownProps {
|
|
|
|
value: string;
|
|
|
|
options: string[];
|
|
|
|
onChange?(value: string): void;
|
|
|
|
}
|
2017-10-04 17:51:37 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
interface State {
|
|
|
|
expanded: boolean;
|
|
|
|
}
|
2017-10-04 17:51:37 +00:00
|
|
|
|
|
|
|
const initialState = {
|
|
|
|
expanded: false
|
|
|
|
};
|
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export default class UnitDropdown extends React.Component<
|
|
|
|
UnitDropdownProps,
|
|
|
|
State
|
|
|
|
> {
|
2017-10-04 17:51:37 +00:00
|
|
|
public state: State = initialState;
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public render() {
|
2017-09-07 20:14:52 +00:00
|
|
|
const { value, options } = this.props;
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-10-04 17:51:37 +00:00
|
|
|
const StringDropdown = Dropdown as new () => Dropdown<string>;
|
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
return (
|
|
|
|
<div className="input-group-btn">
|
2017-10-04 17:51:37 +00:00
|
|
|
<StringDropdown
|
|
|
|
options={options}
|
2017-09-07 20:14:52 +00:00
|
|
|
value={value}
|
|
|
|
onChange={this.onChange}
|
2017-10-04 17:51:37 +00:00
|
|
|
ariaLabel={'dropdown'}
|
2017-09-07 20:14:52 +00:00
|
|
|
/>
|
2017-07-02 05:49:06 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-06-26 22:27:55 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
public onChange = (value: string) => {
|
2017-08-11 21:54:10 +00:00
|
|
|
if (this.props.onChange) {
|
|
|
|
this.props.onChange(value);
|
|
|
|
}
|
2017-07-15 23:05:57 +00:00
|
|
|
};
|
2017-06-26 22:27:55 +00:00
|
|
|
}
|