40 lines
734 B
TypeScript
40 lines
734 B
TypeScript
import React, { ChangeEvent } from 'react';
|
|
|
|
interface SelectOption {
|
|
value: string;
|
|
label: string;
|
|
}
|
|
|
|
interface SelectProps {
|
|
id?: string;
|
|
'aria-label'?: string;
|
|
value?: string;
|
|
onChange?: (e: ChangeEvent<HTMLSelectElement>) => void;
|
|
options: SelectOption[];
|
|
className?: string;
|
|
}
|
|
|
|
export function Select({
|
|
id,
|
|
'aria-label': ariaLabel,
|
|
value,
|
|
onChange,
|
|
options,
|
|
className = '',
|
|
}: SelectProps) {
|
|
return (
|
|
<select
|
|
id={id}
|
|
aria-label={ariaLabel}
|
|
value={value}
|
|
onChange={onChange}
|
|
className={className}
|
|
>
|
|
{options.map((option) => (
|
|
<option key={option.value} value={option.value}>
|
|
{option.label}
|
|
</option>
|
|
))}
|
|
</select>
|
|
);
|
|
} |