UNPKG

@xraph/smartform-react

Version:

React library for rendering and validating SmartForms with shadcn components

18 lines (17 loc) 936 B
import type { TemplateEngine } from "../template-engine"; import type { Field, FormSchema, ValidationResult } from "../core"; import type { ComponentRegistry } from "./components-registry.ts"; export interface SmartFormContextType { schema: FormSchema; templateEngine: TemplateEngine; formState: Record<string, any>; componentRegistry: ComponentRegistry; getDynamicOptions: (fieldId: string, dependentValues: Record<string, any>) => Promise<any[]>; isFieldVisible: (field: Field) => boolean; isFieldEnabled: (field: Field) => boolean; isFieldRequired: (field: Field) => boolean; validateField: (fieldId: string, value: any) => ValidationResult; evaluateTemplateExpression: (expression: string, context?: Record<string, any>) => any; } export declare const SmartFormContext: import("react").Context<SmartFormContextType | undefined>; export declare const useSmartForm: () => SmartFormContextType;