@timmons-group/config-form
Version:
React Components and helpers to build a form via configuration with react-hook-form and MUI
37 lines (36 loc) • 1.2 kB
TypeScript
export function processDynamicFormLayout(formLayout: object, data: object): ProcessedDynamicFormLayout;
export function useConfigForm(formLayout: object, data: object, options?: {
mode?: HookFormMode;
}, addCustomValidations?: Function, formOptions: any): object;
export function fetchChoices(fieldId: string, url: string, { clearErrors, setError, resetField, urlDomain, mappedId, mappedLabel, triggerFieldId, choiceFormatter }: FetchChoicesOptions): Promise<Array<object>>;
export type HookFormMode = "onBlur" | "onSubmit" | "onChange" | "all" | "onTouched";
export type FetchChoicesOptions = {
/**
* - domain to use when fetching the data
*/
urlDomain?: string;
/**
* - property to use when mapping the id
*/
mappedId?: string;
/**
* - property to use when mapping the label
*/
mappedLabel?: string;
/**
* - id of the field that triggered the load
*/
triggerFieldId?: string;
/**
* - function to format the choices
*/
choiceFormatter?: Function;
/**
* - function to clear errors
*/
clearErrors?: Function;
/**
* - function to set errors
*/
setError?: Function;
};