import React, { forwardRef } from "react"; import { Controller, FieldValues } from "react-hook-form"; import { Select as BaseSelect } from "tamagui"; import { FormFieldBaseProps } from "./utility"; import { ErrorMessage } from "./form"; import Icons from "./icons"; export type SelectItem = { label: string; value: string; }; type SelectProps = React.ComponentPropsWithoutRef & { items?: SelectItem[] | null; value?: string; defaultValue?: string; onChange?: (value: string) => void; placeholder?: string; }; type SelectRef = React.ElementRef; const Select = forwardRef( ( { items, value, defaultValue, onChange, placeholder = "Select...", ...props }, ref ) => { return ( {placeholder} {items?.map((item, idx) => ( {value === item.value && } {item.label} ))} ); } ); type SelectFieldProps = FormFieldBaseProps & SelectProps; export const SelectField = ({ form, name, ...props }: SelectFieldProps) => ( ( <>