@canard/schema-form
Version:
React-based component library that renders forms based on JSON Schema with plugin system support for validators and UI components
40 lines (39 loc) • 2.33 kB
TypeScript
import { type ComponentType, type PropsWithChildren } from 'react';
import type { Dictionary } from '../../@aileron/declare';
import type { ValidationMode } from '../../core';
import type { FormTypeInputDefinition, FormTypeRendererProps, FormatError, ShowError, ValidatorFactory } from '../../types';
export interface ExternalFormContextProviderProps {
/** List of FormTypeInputDefinition declared externally */
formTypeInputDefinitions?: FormTypeInputDefinition[];
/** FormGroupRenderer component declared externally */
FormGroupRenderer?: ComponentType<FormTypeRendererProps>;
/** FormLabelRenderer component declared externally */
FormLabelRenderer?: ComponentType<FormTypeRendererProps>;
/** FormInputRenderer component declared externally */
FormInputRenderer?: ComponentType<FormTypeRendererProps>;
/** FormErrorRenderer component declared externally */
FormErrorRenderer?: ComponentType<FormTypeRendererProps>;
/** FormatError function declared externally */
formatError?: FormatError;
/**
* Error display condition (default: ShowError.DirtyTouched)
* - `true`: Always show errors
* - `false`: Never show errors
* - `ShowError.Dirty`: Show errors when value has changed
* - `ShowError.Touched`: Show errors when input has been focused
* - `ShowError.DirtyTouched`: Show errors when both Dirty and Touched states are met
*/
showError?: boolean | ShowError;
/**
* Execute Validation Mode (default: ValidationMode.OnChange)
* - `ValidationMode.None`: Disable validation
* - `ValidationMode.OnChange`: Validate when value changes
* - `ValidationMode.OnRequest`: Validate on request
*/
validationMode?: ValidationMode;
/** ValidatorFactory declared externally, creates internally if not provided */
validatorFactory?: ValidatorFactory;
/** Global user-defined context, merged with user-defined context */
context?: Dictionary;
}
export declare const ExternalFormContextProvider: ({ formTypeInputDefinitions, FormGroupRenderer, FormLabelRenderer, FormInputRenderer, FormErrorRenderer, formatError, showError, validationMode, context: inputContext, validatorFactory, children, }: PropsWithChildren<ExternalFormContextProviderProps>) => import("react/jsx-runtime").JSX.Element;