import { Signal, Value } from '@tempots/dom';
import { StandardSchemaV1 } from './schema/standard-schema-v1';
import { ControllerValidation, Controller, ObjectController } from './controller';
export interface UseFormOptions<T> {
    schema?: StandardSchemaV1<T, T>;
    initialValue?: Value<T>;
    onSubmit?: (value: T) => Promise<ControllerValidation>;
    validationMode?: 'onSubmit' | 'continuous' | 'touchedOrSubmit';
    validateDebounceMs?: number;
}
export interface UseControllerOptions<T> {
    initialValue: Value<T>;
    onChange?: (value: T) => void;
    validate?: (value: T) => Promise<ControllerValidation> | ControllerValidation;
    equals?: (a: T, b: T) => boolean;
    validationMode?: 'onSubmit' | 'continuous' | 'touchedOrSubmit';
    validateDebounceMs?: number;
}
/**
 * Creates a Controller instance with automatic resource cleanup.
 * The controller will be automatically disposed when the component unmounts.
 */
export declare function useController<T>({ initialValue, onChange, validate, equals, validationMode, validateDebounceMs, }: UseControllerOptions<T>): {
    controller: Controller<T>;
    setStatus: (result: ControllerValidation) => void;
};
export declare function connectCommonAttributes<T>(value: Controller<T>): import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
export declare function connectStringInput(value: Controller<string>, { triggerOn, }?: {
    triggerOn?: 'change' | 'input';
}): import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
export declare function connectNumberInput(value: Controller<number>, { triggerOn, }?: {
    triggerOn?: 'change' | 'input';
}): import("@tempots/dom").Renderable<import("@tempots/dom").DOMContext>;
export declare function standardSchemaResultToValidation<Out>(result: StandardSchemaV1.Result<Out>): ControllerValidation;
/**
 * Wraps an async operation and converts any thrown errors into a ControllerValidation.
 * This is useful for form submission handlers that need to convert async operations
 * into the ControllerValidation format expected by the form system.
 *
 * @param task - The async operation to execute
 * @param errorMessage - Optional custom error message. If not provided, uses the error's message or a default message
 * @param errorPath - Optional path for the error. Defaults to ['root']
 * @returns A Promise that resolves to a ControllerValidation
 *
 * @example
 * ```typescript
 * const result = await taskToValidation(
 *   () => signUpUser(userData),
 *   'Sign up failed'
 * )
 * ```
 */
export declare function taskToValidation<T>({ task, errorMessage, errorPath, validation, }: {
    task: () => Promise<T>;
    errorMessage?: string;
    errorPath?: string[];
    validation?: (result: T) => ControllerValidation;
}): Promise<ControllerValidation>;
export type UseFormResult<T extends object> = {
    controller: ObjectController<T>;
    setStatus: (result: ControllerValidation) => void;
    submit: (e?: Event) => Promise<void>;
    submitting: Signal<boolean>;
};
export declare function useForm<T extends object>({ initialValue, schema, onSubmit, validationMode, validateDebounceMs, }: UseFormOptions<T>): UseFormResult<T>;
