UNPKG

@proveanything/smartlinks-form-renderer

Version:

A flexible React component for rendering forms from JSON schema with conditional logic and storage configuration

103 lines 3.34 kB
export interface SchemaFormFieldCondition { targetFieldId: string; operator: 'equals' | 'not_equals' | 'contains' | 'not_contains' | 'greater_than' | 'less_than' | 'is_empty' | 'is_not_empty'; value?: any; logicalOperator?: 'AND' | 'OR'; } export interface TableColumn { id: string; title: string; type: 'string' | 'number' | 'boolean' | 'date'; required?: boolean; width?: string; } export interface SchemaFormField { type: 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'table'; title?: string; description?: string; default?: any; enum?: any[]; enumNames?: string[]; format?: 'email' | 'date' | 'date-time' | 'uri' | 'textarea' | 'file' | 'select' | 'radio' | 'combobox' | 'checkbox' | 'switch' | 'checkboxes' | 'multiselect'; minimum?: number; maximum?: number; minLength?: number; maxLength?: number; pattern?: string; items?: SchemaFormField; properties?: Record<string, SchemaFormField>; required?: string[]; conditions?: SchemaFormFieldCondition[]; showWhen?: 'all' | 'any'; columns?: TableColumn[]; minRows?: number; maxRows?: number; } export interface SchemaFormUIConfig { 'ui:widget'?: 'text' | 'textarea' | 'select' | 'radio' | 'checkboxes' | 'file' | 'email' | 'date' | 'number' | 'checkbox' | 'switch' | 'combobox' | 'multiselect' | 'table'; 'ui:placeholder'?: string; 'ui:help'?: string; 'ui:options'?: { label?: boolean; rows?: number; accept?: string; }; 'ui:order'?: string[]; } export interface SchemaFormUISchema { [key: string]: SchemaFormUIConfig | SchemaFormUISchema; } export interface SchemaFormConfig { id?: string; title: string; description: string; schema: { type: 'object'; properties: Record<string, SchemaFormField>; required?: string[]; }; uiSchema: SchemaFormUISchema; storage: Record<string, 'private' | 'public' | 'proof' | 'personal'>; settings: { allowMultipleSubmissions: boolean; requireAuthentication: boolean; showProgressBar: boolean; submitButtonText: string; successMessage: string; }; styling: { theme: 'default' | 'modern' | 'minimal'; primaryColor: string; backgroundColor: string; }; fieldOrder?: string[]; createdAt?: string; updatedAt?: string; } export interface TableInputProps { columns: TableColumn[]; value: Record<string, any>[]; onChange: (value: Record<string, any>[]) => void; minRows?: number; maxRows?: number; className?: string; } export interface SchemaFormRendererProps { config: SchemaFormConfig; onSubmit: (data: Record<string, any>) => void; isSubmitting?: boolean; className?: string; initialData?: Record<string, any>; components?: { Button?: React.ComponentType<any>; Input?: React.ComponentType<any>; Textarea?: React.ComponentType<any>; Select?: React.ComponentType<any>; Checkbox?: React.ComponentType<any>; RadioGroup?: React.ComponentType<any>; Switch?: React.ComponentType<any>; Label?: React.ComponentType<any>; TableInput?: React.ComponentType<TableInputProps>; }; } //# sourceMappingURL=types.d.ts.map