import { derived } from 'svelte/store'; import { z } from 'zod'; interface FormState { values: T; errors: Record; touched: Record; isValid: boolean; isDirty: boolean; isSubmitting: boolean; } /** * Generic Form Manager for any Zod schema with cross-component field support */ export declare class FormManager> { private schema; private _store; private initialValues; private identifier; private fieldRegistrations; readonly values: ReturnType>; readonly errors: ReturnType>>; readonly touched: ReturnType>>; readonly isValid: ReturnType>; readonly isDirty: ReturnType>; readonly isSubmitting: ReturnType>; constructor(identifier: string, schema: z.ZodType, initialValues: T); /** * Register a field with the form for cross-component management */ registerField(fieldName: K, options?: { validate?: (value: T[K]) => string | null; transform?: (value: unknown) => T[K]; }): { value: import("svelte/store").Readable; error: import("svelte/store").Readable[K]>; touched: import("svelte/store").Readable[K]>; setValue: (value: T[K]) => void; setTouched: () => void; validate: () => string[]; }; /** * Set the value of a specific field */ setField(field: K, value: T[K]): void; /** * Set multiple field values at once */ setFields(values: Partial): void; /** * Set a field as touched without changing its value */ setTouched(field: K): void; /** * Validate a specific field */ validateField(field: K): string[]; /** * Reset the form to initial values */ reset(): void; /** * Set the form as submitting */ setSubmitting(isSubmitting: boolean): void; /** * Update the schema (useful for dynamic forms) */ updateSchema(newSchema: z.ZodType): void; /** * Validate the entire form */ private validate; /** * Get the current state of the form */ getState(): FormState; /** * Destroy the form and clean up resources */ destroy(): void; } /** * Creates a generic form with Zod validation */ export declare function createGenericForm>(identifier: string, schema: z.ZodType, initialValues: T): { values: import("svelte/store").Readable; errors: import("svelte/store").Readable>; touched: import("svelte/store").Readable>; isValid: import("svelte/store").Readable; isDirty: import("svelte/store").Readable; isSubmitting: import("svelte/store").Readable; setField: (field: K, value: T[K]) => void; setFields: (values: Partial) => void; setTouched: (field: K) => void; reset: () => void; setSubmitting: (isSubmitting: boolean) => void; updateSchema: (newSchema: z.ZodType>) => void; registerField: (fieldName: K, options?: { validate?: ((value: T[K]) => string | null) | undefined; transform?: ((value: unknown) => T[K]) | undefined; } | undefined) => { value: import("svelte/store").Readable; error: import("svelte/store").Readable[K]>; touched: import("svelte/store").Readable[K]>; setValue: (value: T[K]) => void; setTouched: () => void; validate: () => string[]; }; validateField: (field: K) => string[]; getState: () => FormState; destroy: () => void; }; /** * Creates a form validation utility with Svelte 5 reactive stores * @param identifier - Unique identifier for the form * @param options - Configuration options */ export declare class FormValidator { private schema; private _store; private instancesSet; private initialValues; private identifier; private currentInstanceToIgnore; private classValidationEnabled; readonly values: ReturnType>; readonly errors: ReturnType>>; readonly touched: ReturnType>>; readonly isValid: ReturnType>; readonly isDirty: ReturnType>; readonly isSubmitting: ReturnType>; /** * Generates unique name, instance, and class based on solution name and existing instances * @param existingInstances - Array of existing instance names * @param solution - The base solution name * @returns Object containing name, instance, and class values */ static generateNames(existingInstances: string[], solution: string, name: string): { name: string; instance: string; class: string; }; /** * Cleans up the class name to ensure it's valid * @param className - The class name to clean up * @returns The cleaned up class name */ static sanitizeClassName(className: string): string; constructor(identifier: string, initialValues: T, options?: { existingInstances?: string[]; }); /** * Set a specific instance to ignore during validation * Used in edit mode to prevent the current instance from being flagged as invalid */ ignoreInstanceValidation(instanceValue: string, existingInstances: string[]): void; /** * Set the value of a specific field */ setField(field: K, value: T[K]): void; /** * Set multiple field values at once */ setFields(values: Partial): void; /** * Handle instance field validation with uniqueness check */ validateWithInstances(existingInstances: string[]): void; /** * Reset the form to initial values */ reset(): void; /** * Enable or disable class name validation * @param enabled - Whether to enable class validation */ enableClassValidation(enabled: boolean): void; /** * Validate the form values */ private validate; /** * Set the form as submitting */ setSubmitting(isSubmitting: boolean): void; /** * Get the current state of the form */ getState(): FormState; } /** * Setup form hook */ export declare function createForm(identifier: string, initialValues: T, options?: { existingInstances?: string[]; enableClassValidation?: boolean; }): { values: import("svelte/store").Readable; errors: import("svelte/store").Readable>; touched: import("svelte/store").Readable>; isValid: import("svelte/store").Readable; isDirty: import("svelte/store").Readable; isSubmitting: import("svelte/store").Readable; setField: (field: K, value: T[K]) => void; setFields: (values: Partial) => void; reset: () => void; enableClassValidation: (enabled: boolean) => void; ignoreInstanceValidation: (instanceValue: string, existingInstances: string[]) => void; setSubmitting: (isSubmitting: boolean) => void; validate: () => void; getState: () => FormState; }; /** * Get a form by its identifier */ export declare function getFormById(identifier: string): FormValidator<{ name: string; instance: string; class: string; }> | FormManager> | undefined; /** * Check if a form with a specific identifier is valid */ export declare function isFormValid(identifier: string): boolean; /** * Get error messages for a specific form */ export declare function getFormErrors(identifier: string): Record | null; /** * Reset a form by its identifier */ export declare function resetForm(identifier: string): boolean; export declare function createFormSubscription(identifier: string): import("svelte/store").Writable<{ isValid: boolean; errors: {}; values: {}; }> | { subscribe: (this: void, run: import("svelte/store").Subscriber | FormState>>, invalidate?: () => void) => import("svelte/store").Unsubscriber; destroy: () => void; }; /** * Helper to get field state for a specific form and field */ export declare function getFieldState>(formId: string, fieldName: keyof T): { value: undefined; error: never[]; touched: boolean; isValid: boolean; } | { value: T[keyof T]; error: Record[keyof T]; touched: boolean | Record[keyof T]; isValid: boolean; }; /** * Helper to update a field value for a specific form */ export declare function updateFieldValue>(formId: string, fieldName: keyof T, value: T[typeof fieldName]): void; /** * Helper to get all registered field names for a form */ export declare function getFormFieldNames(formId: string): string[]; /** * Store to track if the form is adding or updating to the Canvas */ export declare const isAddingOrUpdating: import("svelte/store").Writable; export declare const loadingSelectedElement: import("svelte/store").Writable; export {};