import { ReactNode } from 'react'; import { ControllerProps, FieldPath, FieldValues, PathValue, RegisterOptions } from 'react-hook-form'; import { IconModalProps } from './components'; /** Should the field show errors as soon as the field has been touched, or wait until the form has been submitted? */ export type ErrorMode = 'immediate' | 'onSubmit'; export type FormFieldProps = FieldPath> = Pick, 'name' | 'rules' | 'shouldUnregister'> & { id?: string; errorMode?: ErrorMode; }; export declare const TextFieldTypes: { TEXT: string; EMAIL: string; PASSWORD: string; NUMBER: string; TEL: string; URL: string; }; export type StatusVariant = 'error' | 'success' | 'warning' | 'info'; export interface FormOption { value: TValue; label: TLabel; disabled?: boolean; helpMessage?: ReactNode; } export type OptionProps = { getOptionKey?(option: TOption): string; getOptionLabel?(option: TOption): ReactNode; getOptionHelpMessage?(option: TOption): ReactNode; isOptionDisabled?(option: TOption): boolean; }; export type OptionValueProps = { getOptionValue?(option: TOption): TFormItemValue; areOptionValuesEqual?(left?: TFormItemValue | null, right?: TFormItemValue | null): boolean; }; /** * Common props for controls that support a list of `options`. */ export type FormOptionsControlProps = FieldPath, TFormItemValue = PathValue, TOptionValue = PathValue, TOption = FormOption> = FormFieldProps & OptionProps & OptionValueProps & { label: ReactNode; helpMessage?: ReactNode; disabled?: boolean; options: TOption[]; infoTooltipProps?: IconModalProps; }; /** * Type assertion for returning only the FieldPaths that have Array values. * This is used by form fields that require array values. */ export type ArrayFieldPath = { [TName in FieldPath]: NonNullable> extends Array ? TName : never; }[FieldPath]; export type ArrayPathValue> = NonNullable> extends Array ? TValue : never; export type FormFieldRules = FieldPath> = Omit, 'valueAsNumber' | 'valueAsDate' | 'setValueAs' | 'disabled'>;