import { CustomFieldDefinition, CustomFieldValueAndDefinition } from "@trackunit/custom-field-api"; import { ReactElement } from "react"; import { Control, FieldValues, FormState, UseFormRegister, UseFormSetValue } from "react-hook-form"; import { UnitPreference } from "./UnitPreference"; /** * CustomFieldProps interface defines the structure for the properties * accepted by the CustomField component and useCustomFieldResolver hook. */ interface CustomFieldProps { /** * The value and definition of the custom field to be rendered. */ field?: CustomFieldValueAndDefinition; /** * The definition of the custom field to be rendered. */ definition?: CustomFieldDefinition; /** * A function from react-hook-form to register input for validation. */ register: UseFormRegister; /** * The current state of the form from react-hook-form, including any validation errors. */ formState: FormState; /** * The current value of the form field. */ formValue?: string; /** * A function from react-hook-form to update the value of a registered field. */ setValue: UseFormSetValue; /** * (Optional) Specifies the unit system to be used (e.g., 'SI' or 'US_CUSTOMARY'). */ unitPreference?: UnitPreference | null; /** * (Optional) Indicates if the field is editable or should be displayed in read-only mode. */ isEditable?: boolean; /** * (Optional) An alternative identifier for the field, which overrides the default definition.key. */ fieldId?: string; /** * Instance of `Control` from `react-hook-form`. */ control: Control; } /** * A hook that resolves and returns a JSX Element for a given custom field. * It handles various custom field types by providing appropriate validation rules * and input components with the necessary props. * * @param {CustomFieldProps} props - The properties of the custom field, including its definition, value, * and functions for form registration and state management. * @returns {ReactElement | null} - The JSX Element for the custom field or null if the field definition is not provided. */ export declare const useCustomFieldResolver: ({ field, definition, register, setValue, formState, formValue, unitPreference, fieldId, isEditable, control, }: CustomFieldProps) => ReactElement | null; /** * CustomField is a React component that takes in the properties of a custom field and renders it. * It utilizes the `useCustomFieldResolver` hook to resolve the field into an input element * based on the field's type and definition. * * @param {CustomFieldProps} props - Props for defining the custom field, including its type, value, * validation rules, and form registration functions from react-hook-form. * @returns {ReactElement | null} - The resolved custom field component or null if the field cannot be resolved. */ export declare const CustomField: (props: CustomFieldProps) => ReactElement | null; export {};