extended-dynamic-forms
Version:
Extended React JSON Schema Form (RJSF) v6 with custom components, widgets, templates, layouts, and form events
54 lines (52 loc) • 1.87 kB
TypeScript
import { FormProps } from '@rjsf/core';
import { RJSFSchema, UiSchema } from '@rjsf/utils';
export type WebhookEventType = 'focus' | 'blur' | 'change' | 'submit' | 'stepChange' | 'validationError';
export interface FormEventHandlers {
beforeSubmit?: (data: any) => Promise<any> | any;
afterSubmit?: (data: any) => Promise<void> | void;
beforeValidation?: (data: any) => Promise<any> | any;
afterValidation?: (data: any, errors: any) => Promise<void> | void;
}
export interface FormFieldEvent {
eventType: 'focus' | 'blur' | 'change';
fieldId: string;
fieldValue: any;
schema?: any;
formData?: any;
timestamp: number;
fieldPath?: string[];
}
export interface WebhookConfig {
url: string;
method?: 'POST' | 'PUT' | 'PATCH';
headers?: Record<string, string>;
events?: WebhookEventType[];
debounceMs?: number;
retries?: number;
timeout?: number;
}
export interface FieldEventHandlers {
onFieldFocus?: (event: FormFieldEvent) => Promise<void> | void;
onFieldBlur?: (event: FormFieldEvent) => Promise<void> | void;
onFieldChange?: (event: FormFieldEvent) => Promise<void> | void;
}
export interface ExtendedFormProps extends Omit<FormProps, 'validator'>, FormEventHandlers, FieldEventHandlers {
schema: RJSFSchema;
uiSchema?: UiSchema;
webhooks?: WebhookConfig[];
eventHub?: any;
onWebhookStart?: (webhook: WebhookConfig, event: any) => void;
onWebhookComplete?: (webhook: WebhookConfig, event: any, response: any) => void;
onWebhookError?: (webhook: WebhookConfig, event: any, error: Error) => void;
enableDynamicBinding?: boolean;
}
export interface CustomWidgetProps {
label?: string;
required?: boolean;
disabled?: boolean;
readonly?: boolean;
autofocus?: boolean;
placeholder?: string;
help?: string;
rawErrors?: string[];
}