import { Field, Label, Select as HeadlessSelect } from '@headlessui/react' import { type ComponentProps, type ReactNode } from 'react' import { get, type FieldError, type FieldValues, type Path, type RegisterOptions, } from 'react-hook-form' import { useRemixFormContext } from 'remix-hook-form' type TInputProperties = Omit< ComponentProps<'select'>, 'size' > & { id: string label?: ReactNode name: Path rules?: RegisterOptions placeholder?: string options?: { code: string name: string id: string }[] } export const Select = >( properties: TInputProperties, ) => { const { id, label, name, rules, disabled, placeholder, options, ...rest } = properties const { register, formState: { errors }, } = useRemixFormContext() const error: FieldError = get(errors, name) return ( {options?.map(({ id, name }) => ( ))} ) }