import { FC, ReactNode } from 'react'; import { CheckboxesProps } from '@not-govuk/checkboxes'; import { DateInputProps } from '@not-govuk/date-input'; import { RadiosProps } from '@not-govuk/radios'; import { SelectProps } from '@not-govuk/select'; import { TextInputProps } from '@not-govuk/text-input'; import { TextareaProps } from '@not-govuk/textarea'; import '../assets/FormField.scss'; type CommonProps = { /** Label */ label: ReactNode; /** Name */ name: string; }; type Option = { label: string; value: string; }; type CommonOptionProps = CommonProps & { /** List of options to select from */ options: Option[]; }; type SubFieldWithSelectProps = SelectProps & { type: 'select'; }; type FieldWithDateInputProps = DateInputProps & { type: 'date'; }; type FieldWithTextareaProps = TextareaProps & { type: 'textarea'; }; type FieldWithTextInputProps = TextInputProps & { type: string; rows?: 1; }; type FieldWithCheckboxesProps = CheckboxesProps & { type: 'checkboxes'; multiple?: true; }; type FieldWithRadiosProps = RadiosProps & { type: 'radios'; multiple?: false; }; type FieldWithMultiSelectProps = SubFieldWithSelectProps & { multiple: true; }; type FieldWithSingleSelectProps = SubFieldWithSelectProps & { multiple?: false; }; type FieldWithUnknownTextProps = Partial & Partial & CommonProps & { rows?: number; }; type FieldWithUnknownMultiProps = Partial & Partial & CommonOptionProps & { multiple: true; }; type FieldWithUnknownSingleProps = Partial & Partial & CommonOptionProps & { multiple?: false; }; type FieldWithTextProps = FieldWithTextInputProps | FieldWithTextareaProps | FieldWithUnknownTextProps; type FieldWithMultiOptionsProps = FieldWithCheckboxesProps | FieldWithMultiSelectProps | FieldWithUnknownMultiProps; type FieldWithSingleOptionsProps = FieldWithRadiosProps | FieldWithSingleSelectProps | FieldWithUnknownSingleProps; type FieldWithoutOptionsProps = FieldWithTextProps | FieldWithDateInputProps; type FieldWithOptionsProps = FieldWithMultiOptionsProps | FieldWithSingleOptionsProps; export type FormFieldProps = FieldWithOptionsProps | FieldWithoutOptionsProps; export declare const FormField: FC; export default FormField;