import type { ReactNode } from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; import type { TextInputProps } from '../TextInput/types'; import type { TextAreaProps } from '../TextArea/types'; import type { SelectProps } from '../Select/types'; import type { CheckboxProps } from '../Checkbox/types'; import type { RadioGroupProps } from '../RadioButton/types'; import type { SwitchProps } from '../Switch/types'; import type { SliderProps } from '../Slider/types'; export type FieldValue = string | number | boolean | undefined; export type FormValues = Record; export type FormErrors = Partial>; export type ValidateFunction = ( values: T ) => FormErrors | undefined | void; export interface UseFormOptions { initialValues: T; validate?: ValidateFunction; validateOn?: 'onBlur' | 'onChange' | 'onSubmit'; onSubmit: (values: T) => void | Promise; disabled?: boolean; } export interface UseFormReturn { values: T; errors: FormErrors; touched: Partial>; isSubmitting: boolean; isDirty: boolean; isValid: boolean; submitCount: number; disabled: boolean; getValue: (name: keyof T) => T[keyof T]; setValue: (name: keyof T, value: T[keyof T]) => void; setTouched: (name: keyof T) => void; getError: (name: keyof T) => string | undefined; setError: (name: keyof T, error: string | undefined) => void; handleSubmit: () => void | Promise; reset: (nextValues?: Partial) => void; registerField: (name: keyof T, ref: React.RefObject, order?: number) => void; unregisterField: (name: keyof T) => void; focusNextField: (currentName: keyof T) => void; isLastTextField: (name: keyof T) => boolean; } export interface FormContextValue { form: UseFormReturn; } export interface FieldRenderProps { value: FieldValue; onChange: (value: FieldValue) => void; onBlur: () => void; error: string | undefined; touched: boolean; dirty: boolean; disabled: boolean; name: string; } export interface FormProps { form: UseFormReturn; children: ReactNode; style?: StyleProp; testID?: string; id?: string; } // Form field wrapper props - Omit the props that Form wires automatically export interface FormFieldBaseProps { name: string; } export interface FormTextInputProps extends FormFieldBaseProps, Omit { tabOrder?: number; } export interface FormTextAreaProps extends FormFieldBaseProps, Omit {} export interface FormSelectProps extends FormFieldBaseProps, Omit {} export interface FormCheckboxProps extends FormFieldBaseProps, Omit {} export interface FormRadioGroupProps extends FormFieldBaseProps, Omit {} export interface FormSwitchProps extends FormFieldBaseProps, Omit {} export interface FormSliderProps extends FormFieldBaseProps, Omit {} export interface FormFieldProps extends FormFieldBaseProps { children: (field: FieldRenderProps) => ReactNode; }