da158cfd84
Tests / test (push) Successful in 2m26s
Co-authored-by: gorbenko.pavel <gorbenko.pavel@tansu.kz> Reviewed-on: http://git.tnsu.kz/gorbenko.pavel/tnsu-approval-route/pulls/5
22 lines
621 B
TypeScript
22 lines
621 B
TypeScript
import * as React from 'react';
|
|
import styles from './FormField.module.scss';
|
|
|
|
export interface ISelectOption {
|
|
value: string;
|
|
label: string;
|
|
}
|
|
|
|
export interface ISelectProps extends Omit<React.SelectHTMLAttributes<HTMLSelectElement>, 'children'> {
|
|
options: ISelectOption[];
|
|
placeholder?: string;
|
|
}
|
|
|
|
export const Select: React.FC<ISelectProps> = ({ options, placeholder, ...rest }) => (
|
|
<select {...rest} className={styles.select}>
|
|
{placeholder && <option value="">{placeholder}</option>}
|
|
{options.map(opt => (
|
|
<option key={opt.value} value={opt.value}>{opt.label}</option>
|
|
))}
|
|
</select>
|
|
);
|