import { classNames } from '@/utils'; import { ChangeEventHandler } from 'react'; import ErrorMessage from './ErrorMessage'; interface Option { label: string; value: unknown; } export interface SimpleSelectProps { className?: string; errors?: string[]; label: string; value?: unknown; options: Option[]; placeholder?: string; defaultValue?: string | number; onChange?: ChangeEventHandler; helpText?: string; required?: boolean; disabled?: boolean; } /** * @deprecated use `SearchableSelect` component instead */ const SimpleSelect = (props: SimpleSelectProps) => { function slugify(sluggable: string) { sluggable = sluggable.replace(/^\s+|\s+$/g, ''); // trim sluggable = sluggable.toLowerCase(); // remove accents, swap ñ for n, etc const from = 'àáäâèéëêìíïîòóöôùúüûñç·/_,:;'; const to = 'aaaaeeeeiiiioooouuuunc------'; for (let i = 0, l = from.length; i < l; i++) { sluggable = sluggable.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); } sluggable = sluggable .replace(/[^a-z0-9 -]/g, '') // remove invalid chars .replace(/\s+/g, '-') // collapse whitespace and replace by - .replace(/-+/g, '-'); // collapse dashes return sluggable; } const hasErrors = Boolean(props.errors && props.errors.length > 0); return ( <> {props.helpText &&

{props.helpText}

} ); }; export default SimpleSelect;