import { ComponentOptionsMixin } from 'vue'; import { ComponentProvideOptions } from 'vue'; import { ComputedRef } from 'vue'; import { DefineComponent } from 'vue'; import { PublicProps } from 'vue'; import { Ref } from 'vue'; import { StyleValue } from 'vue'; declare const __VLS_component: DefineComponent<__VLS_Props, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, { wrapperRef: HTMLDivElement; }, HTMLDivElement>; declare const __VLS_component_2: DefineComponent<__VLS_Props_3, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_3> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>; declare const __VLS_component_3: DefineComponent<__VLS_Props_4, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<__VLS_Props_4> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, HTMLDivElement>; declare type __VLS_Props = { contextKey?: symbol | string; }; declare type __VLS_Props_2 = { layout?: "grid" | "stacked" | unknown; columns?: number; fieldWrapperClass?: string; only?: string[]; errorClass?: any; classes?: any; as?: string; containerClass?: string; containerStyle?: StyleValue; excludeRepeaters?: boolean; }; declare type __VLS_Props_3 = { title?: string; classes?: string; titleClasses?: string; }; declare type __VLS_Props_4 = { name: string; includeChildren?: boolean; }; declare function __VLS_template(): { attrs: Partial<{}>; slots: { default?(_: {}): any; }; refs: { wrapperRef: HTMLDivElement; }; rootEl: HTMLDivElement; }; declare function __VLS_template_2(): { attrs: Partial<{}>; slots: { default?(_: {}): any; }; refs: {}; rootEl: HTMLDivElement; }; declare function __VLS_template_3(): { attrs: Partial<{}>; slots: { default?(_: { key: number; index: number; parentIndex: number; value: any; fullName: string; indexes: Record; data: any; }): any; }; refs: {}; rootEl: HTMLDivElement; }; declare type __VLS_TemplateResult = ReturnType; declare type __VLS_TemplateResult_2 = ReturnType; declare type __VLS_TemplateResult_3 = ReturnType; declare type __VLS_WithTemplateSlots = T & { new (): { $slots: S; }; }; declare type __VLS_WithTemplateSlots_2 = T & { new (): { $slots: S; }; }; declare type __VLS_WithTemplateSlots_3 = T & { new (): { $slots: S; }; }; /** * Defines a single async validation rule */ export declare type AsyncValidatorFn = (value: FieldValueType, formData: Record) => Promise; export declare const AutoVorm: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & { validate: (payload: any) => any; blur: (payload: any) => any; input: (payload: any) => any; submit: (evt: SubmitEvent) => any; }, string, PublicProps, Readonly<__VLS_Props_2> & Readonly<{ onValidate?: ((payload: any) => any) | undefined; onBlur?: ((payload: any) => any) | undefined; onInput?: ((payload: any) => any) | undefined; onSubmit?: ((evt: SubmitEvent) => any) | undefined; }>, {}, {}, {}, {}, string, ComponentProvideOptions, false, {}, any>; /** * Function to validate that a value is between two numbers * @param min * @param max * @returns */ export declare function between(min: number, max: number): SyncValidatorFn; /** * Default validation rules */ export declare type BuiltInRuleName = "required" | "email" | "integer" | "url" | "alpha"; export declare function createField(field: VormFieldSchema): VormFieldSchema; /** * Creates a simple i18n context with the default Vorm messages * * @param locale - Reactive locale ref * @param customMessages - Optional custom messages to merge with defaults * @returns VormI18n context */ export declare function createVormI18n(locale: Ref, customMessages?: Record>): VormI18n; /** * Default validation messages for built-in rules */ export declare const defaultMessages: Record>; /** * Internal error data structure that preserves reactivity */ export declare interface ErrorData { /** * The original message (can be a string, ref, computed, or message key) */ messageRef: string | Ref; /** * Optional parameters for message interpolation */ params?: (string | number)[]; } export declare function extractRepeaterIndex(path: string): number | undefined; /** * Returns an object of all repeater indexes in the path. * Example: "contacts[0].business[1].email" → { contacts: 0, 'contacts[0].business': 1 } */ export declare function extractRepeaterIndexes(fieldName: string): Record; export declare interface FieldState { error: string | null; valid: boolean; invalid: boolean; validationMode: "onInput" | "onBlur" | "onSubmit"; classes: string; touched: boolean; dirty: boolean; initialValue: any; } export declare type FieldValueType = T extends keyof FieldValueTypeMap ? FieldValueTypeMap[T] : any; /** * Maps form input types to their corresponding value types */ export declare type FieldValueTypeMap = { text: string; number: number; email: string; password: string; textarea: string; checkbox: boolean; radio: string; select: string | number; "select-multiple": string[] | number[]; date: string; "datetime-local": string; file: File | null; "file-multiple": File[]; [key: string]: any; }; /** * Context provided to reactive functions in schema fields * Uses lazy getters for optimal performance - only accessed properties are tracked */ export declare interface FormContext { /** * Reactive form data */ formData: Record; /** * Current validation errors (lazy getter) */ readonly errors: Record; /** * Whether the form is valid (lazy getter) */ readonly isValid: boolean; /** * Whether the form has been modified (lazy getter) */ readonly isDirty: boolean; /** * Whether any field has been touched (lazy getter) */ readonly isTouched: boolean; /** * Touched state for each field */ readonly touched: Record; /** * Dirty state for each field */ readonly dirty: Record; } export declare function getValueByPath(obj: any, path: string): any; /** * Function to validate if a field matches another field * @param otherFieldName * @param message * @returns */ export declare function matchField(otherFieldName: string): SyncValidatorFn; /** * Function to validate that a value is less than or equal to a maximum value. * @param maxValue * @returns */ export declare function max(maxValue: number): SyncValidatorFn; /** * Validate that the string has at most `max` characters. * @param max - Maximum number of characters allowed */ export declare function maxLength(max: number): SyncValidatorFn; /** * Function to validate that a value is greater than or equal to a minimum value. * @param minValue * @returns */ export declare function min(minValue: number): SyncValidatorFn; /** * Validate that the string has at least `min` characters. * @param min - Minimum number of characters required */ export declare function minLength(min: number): SyncValidatorFn; declare type Option_2 = string | { label: string; value: string | number; disabled?: boolean; [key: string]: any; }; export { Option_2 as Option } /** * Reactive boolean that can be static, ref, computed, or function * Useful for disabled, readonly, or other boolean properties that depend on form state */ export declare type ReactiveBoolean = boolean | Ref | ComputedRef | (() => boolean) | ((ctx: FormContext) => boolean); /** * Reactive options for select, radio, autocomplete fields * Supports static arrays, reactive refs/computed, functions, and async functions */ export declare type ReactiveOptions = Option_2[] | Ref | ComputedRef | (() => Option_2[]) | (() => Promise); /** * Reactive string that can be static, ref, computed, or function */ export declare type ReactiveString = string | Ref | ComputedRef | (() => string) | ((ctx: FormContext) => string); /** * Resolves a validation message to a plain string * Handles: static strings, refs, computed values, functions, and i18n keys * * @param messageOrKey - The message (string, ref, computed, function) or i18n key * @param i18nContext - Optional i18n context for translation * @param params - Optional parameters for message interpolation * @param formContext - Optional form context for functions that need access to formData * @returns The resolved message string */ export declare function resolveMessage(messageOrKey: ReactiveString | undefined, i18nContext: VormI18n | undefined, params?: (string | number)[], formContext?: FormContext): string; /** * Resolves a ReactiveString to a ComputedRef * Handles: string, Ref, ComputedRef, Function, Function with FormContext * * @param value - The reactive string value to resolve * @param vormContext - Optional vorm context for functions that need formData access * @returns ComputedRef that updates when dependencies change */ export declare function resolveReactive(value: ReactiveString | undefined, vormContext?: VormContext): ComputedRef; /** * Resolves a ReactiveBoolean to a ComputedRef * Handles: boolean, Ref, ComputedRef, Function, Function with FormContext * * @param value - The reactive boolean value to resolve * @param vormContext - Optional vorm context for functions that need formData access * @returns ComputedRef that updates when dependencies change */ export declare function resolveReactiveBoolean(value: ReactiveBoolean | undefined, vormContext?: VormContext): ComputedRef; /** * Resolves a ReactiveString to a plain string (non-reactive) * Use this when you need a one-time resolution without reactivity * * @param value - The reactive string value to resolve * @param vormContext - Optional vorm context for functions that need formData access * @returns Plain string value */ export declare function resolveReactiveOnce(value: ReactiveString | undefined, vormContext?: VormContext): string; /** * Resolves ReactiveOptions to a ComputedRef * Handles: Option[], Ref, ComputedRef, () => Option[], () => Promise * * @param options - The reactive options value to resolve * @returns ComputedRef that updates when dependencies change */ export declare function resolveReactiveOptions(options: ReactiveOptions | undefined): ComputedRef; /** * Resolve a relative path from a base path (for showIf dependsOn) * Supports ".." to go up one level * Example: resolveRelativePath("projects[0].url", "../name") => "projects[0].name" */ export declare function resolveRelativePath(basePath: string, relative: string): string; export declare function setValueByPath(obj: any, path: string, value: any): void; export declare type ShowIfCondition = Record | ((formData: Record, path: string) => boolean) | { dependsOn: string; condition: (value: any, formData: Record, path: string) => boolean; }; /** * Function to validate that a value takes a step of a given value. * @param stepValue * @returns */ export declare function step(stepValue: number): SyncValidatorFn; /** * Defines a single validation rule */ export declare type SyncValidatorFn = (value: FieldValueType, formData: Record) => ValidationResult | string | null; export declare function useVorm(schema: VormSchema, options?: { validationMode?: ValidationMode; key?: symbol | string; i18n?: VormI18n; }): VormContext; export declare function useVormContext(key?: symbol | string): VormContext; /** * Public validation function that returns resolved error strings (backward compatible) * @deprecated Internal use - prefer using vorm.validateFieldByName() from useVorm context */ export declare function validateFieldAsync(field: VormFieldSchema, formData: Record, allErrors: Record): Promise; /** * Internal validation function that returns ErrorData for reactive error messages * Used internally by useVorm to maintain reactive error state */ export declare function validateFieldAsyncInternal(field: VormFieldSchema, formData: Record, allErrors: Record): Promise; export declare type ValidationMode = "onInput" | "onBlur" | "onSubmit"; /** * Represents a validation result */ export declare interface ValidationResult { message: string; params?: (string | number)[]; } /** * Represents a validation rule in the `VormFieldSchema` */ export declare interface ValidationRule { rule: BuiltInRuleName | SyncValidatorFn | AsyncValidatorFn; message?: ReactiveString; affects?: string[]; } export declare interface VormContext { schema: VormSchema; formData: Record; errors: Record; validatedFields: Record; touched: Record; dirty: Record; initial: Record; fieldOptionsMap: Record; i18n?: VormI18n; isValid: ComputedRef; isDirty: ComputedRef; isTouched: ComputedRef; validate: () => Promise; validateFieldByName: (fieldName: string) => Promise; getValidationMode: (fieldName: string) => ValidationMode; setFormData: (newData: Record, options?: { fieldOptions?: Record; }) => void; updateField: (name: string, value: any, options?: { touched?: boolean; dirty?: boolean; validate?: boolean; fieldOptions?: Option_2[]; }) => void; updateFields: (updates: Record, options?: { touched?: boolean; dirty?: boolean; validate?: boolean; fieldOptions?: Record; }) => void; resetForm: () => void; addRepeaterItem: (path: string, item: any, index?: number) => void; removeRepeaterItem: (path: string, index: number) => void; moveRepeaterItem: (path: string, fromIndex: number, toIndex: number) => void; clearRepeater: (path: string) => void; touchAll: () => void; getErrors: () => Record; getTouched: () => Record; getDirty: () => Record; getFieldOptions: (fieldName: string) => ComputedRef; bindField: (fieldName: string) => ComputedRef<{ modelValue: any; 'onUpdate:modelValue': (value: any) => void; items: Option_2[]; options: Option_2[]; error: string | undefined; errorMessages: string[]; disabled: boolean; }>; } /** * Defines the types for a single form field */ export declare interface VormFieldSchema { name: string; type: T; label?: ReactiveString; placeholder?: ReactiveString; required?: boolean; /** * Whether the field is disabled * Can be a static boolean or a function that receives FormContext * @example * disabled: true * disabled: (ctx) => !ctx.formData.agreeToTerms * disabled: (ctx) => ctx.formData.password.length < 8 */ disabled?: ReactiveBoolean; helpText?: ReactiveString; showError?: boolean; showIf?: ShowIfCondition; visibility?: (formData: Record) => boolean; validation?: ValidationRule[]; validationMode?: ValidationMode; inheritWrapper?: boolean; classes?: { outer?: string; input?: string; label?: string; help?: string; }; fields?: VormSchema; /** * Options for select, radio, autocomplete fields * Can be static array, reactive ref/computed, function, or async function */ options?: ReactiveOptions; } /** * Vorm i18n configuration */ export declare interface VormI18n { /** * Current locale (reactive) */ locale: Ref; /** * Translation messages for each locale * @example * { * en: { 'vorm.validation.required': 'This field is required.' }, * de: { 'vorm.validation.required': 'Dieses Feld ist erforderlich.' } * } */ messages: Record>; /** * Translate a message key * @param key - Message key (e.g., 'vorm.validation.required') * @param params - Optional parameters for interpolation */ t: (key: string, params?: Record | (string | number)[]) => string; } export declare const VormProvider: __VLS_WithTemplateSlots; export declare const VormRepeater: __VLS_WithTemplateSlots_3; /** * Defines the entire form schema */ export declare type VormSchema = VormFieldSchema[]; export declare const VormSection: __VLS_WithTemplateSlots_2; export { }