mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-09 23:15:43 +01:00
use reflow to migrate from flow to typescript
This commit is contained in:
56
scm-ui/ui-components/src/forms/DropDown.tsx
Normal file
56
scm-ui/ui-components/src/forms/DropDown.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
type Props = {
|
||||
options: string[];
|
||||
optionValues?: string[];
|
||||
optionSelected: (p: string) => void;
|
||||
preselectedOption?: string;
|
||||
className: any;
|
||||
disabled?: boolean;
|
||||
};
|
||||
|
||||
class DropDown extends React.Component<Props> {
|
||||
render() {
|
||||
const {
|
||||
options,
|
||||
optionValues,
|
||||
preselectedOption,
|
||||
className,
|
||||
disabled,
|
||||
} = this.props;
|
||||
return (
|
||||
<div
|
||||
className={classNames(className, 'select', disabled ? 'disabled' : '')}
|
||||
>
|
||||
<select
|
||||
value={preselectedOption ? preselectedOption : ''}
|
||||
onChange={this.change}
|
||||
disabled={disabled}
|
||||
>
|
||||
<option key="" />
|
||||
{options.map((option, index) => {
|
||||
return (
|
||||
<option
|
||||
key={option}
|
||||
value={
|
||||
optionValues && optionValues[index]
|
||||
? optionValues[index]
|
||||
: option
|
||||
}
|
||||
>
|
||||
{option}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
change = (event: SyntheticInputEvent<HTMLSelectElement>) => {
|
||||
this.props.optionSelected(event.target.value);
|
||||
};
|
||||
}
|
||||
|
||||
export default DropDown;
|
||||
Reference in New Issue
Block a user