import React from 'react'; import type { Path, FieldValues } from 'react-hook-form'; import { useController, useFormContext } from 'react-hook-form'; import type { FormFieldPropsBase } from './types'; import type { SelectProps } from '@luxfi/ui/select'; import { Select } from '@luxfi/ui/select'; import { getFormFieldErrorText } from '../utils/getFormFieldErrorText'; export type FormFieldSelectProps< FormFields extends FieldValues, Name extends Path, > = FormFieldPropsBase & SelectProps; const FormFieldSelectContent = < FormFields extends FieldValues, Name extends Path, >(props: FormFieldSelectProps) => { const { name, rules, size = 'lg', controllerProps, ...rest } = props; const { control } = useFormContext(); const { field, fieldState, formState } = useController({ control, name, rules, ...controllerProps, }); const isDisabled = formState.isSubmitting; const handleChange = React.useCallback(({ value }: { value: Array }) => { field.onChange(value); }, [ field ]); const handleBlur = React.useCallback(() => { field.onBlur(); }, [ field ]); return (