import ErrorMessage from '../ErrorMessage'; import HintText from '../../common/HintText'; import { SelectProps } from './types'; import clsx from 'clsx'; const Select = function ({ children, className, defaultValue, errorMessage, hasError, hintText, id, label, name, onBlur, onChange, placeholder, width, ...props }: SelectProps) { const errorMessageId = `error-message-${id}`; const hintTextId = `hint-text-${id}`; const describedbys: string[] = []; if (hintText) { describedbys.push(hintTextId) }; if (errorMessage) { describedbys.push(errorMessageId) }; function handleBlur(event: React.FocusEvent) { if (typeof onBlur === 'function') { onBlur(event); } } function handleChange(event: React.ChangeEvent) { if (typeof onChange === 'function') { onChange(event); } } return ( <> {hintText && {hintText}} {errorMessage && {errorMessage}}
); }; Select.displayName = 'Select'; export default Select;