import type { ActionResult, SubmitFunction } from '@sveltejs/kit'; import type { Page } from '@sveltejs/kit'; import { type Readable, type Writable, type Updater } from 'svelte/store'; import { type TaintedFields, type SuperValidated, type Validators, type UnwrapEffects, type ZodValidation } from '../index.js'; import type { z, AnyZodObject } from 'zod'; import type { FormFields, MaybePromise } from '../index.js'; import { formEnhance, type SuperFormEvents } from './formEnhance.js'; import { validateForm } from './clientValidation.js'; export { intProxy, numberProxy, booleanProxy, dateProxy, fieldProxy, formFieldProxy, stringProxy } from './proxies.js'; export { superValidate, superValidateSync, actionResult, message, setMessage, setError, defaultValues } from '../superValidate.js'; export type FormOptions, M> = Partial<{ id: string; applyAction: boolean; invalidateAll: boolean; resetForm: boolean | (() => boolean); scrollToError: 'auto' | 'smooth' | 'off'; autoFocusOnError: boolean | 'detect'; errorSelector: string; selectErrorText: boolean; stickyNavbar: string; taintedMessage: string | false | null; SPA: true | { failStatus?: number; }; onSubmit: (...params: Parameters) => MaybePromise; onResult: (event: { result: ActionResult; formEl: HTMLFormElement; cancel: () => void; }) => MaybePromise; onUpdate: (event: { form: SuperValidated, M>; formEl: HTMLFormElement; cancel: () => void; }) => MaybePromise; onUpdated: (event: { form: Readonly, M>>; }) => MaybePromise; onError: 'apply' | ((event: { result: { type: 'error'; status?: number; error: App.Error; }; message: Writable, M>['message']>; }) => MaybePromise); dataType: 'form' | 'json'; jsonChunkSize: number; validators: false | Validators> | ZodValidation>; validationMethod: 'auto' | 'oninput' | 'onblur' | 'submit-only'; defaultValidator: 'keep' | 'clear'; clearOnSubmit: 'errors' | 'message' | 'errors-and-message' | 'none'; delayMs: number; timeoutMs: number; multipleSubmits: 'prevent' | 'allow' | 'abort'; syncFlashMessage?: boolean; flashMessage: { module: { getFlash(page: Readable): Writable; updateFlash(page: Readable, update?: () => Promise): Promise; }; onError?: (event: { result: { type: 'error'; status?: number; error: App.Error; }; message: Writable; }) => MaybePromise; cookiePath?: string; cookieName?: string; }; warnings: { duplicateId?: boolean; noValidationAndConstraints?: boolean; }; }>; type SuperFormSnapshot = SuperValidated & { tainted: TaintedFields | undefined; }; export type TaintOption = boolean | 'untaint' | 'untaint-all'; export type SuperForm, M = any> = { form: { subscribe: Readable>>['subscribe']; set(this: void, value: z.infer>, options?: { taint?: TaintOption; }): void; update(this: void, updater: Updater>>, options?: { taint?: TaintOption; }): void; }; formId: Writable; errors: Writable['errors']> & { clear: () => void; }; constraints: Writable['constraints']>; message: Writable['message']>; tainted: Writable> | undefined>; submitting: Readable; delayed: Readable; timeout: Readable; posted: Readable; fields: FormFields>; allErrors: Readable<{ path: string; messages: string[]; }[]>; options: FormOptions; enhance: (el: HTMLFormElement, events?: SuperFormEvents, M>) => ReturnType; reset: (options?: Partial<{ keepMessage: boolean; data: Partial>>; id: string; }>) => void; capture: () => SuperFormSnapshot, M>; restore: (snapshot: SuperFormSnapshot, M>) => void; validate: typeof validateForm>; }; /** * @deprecated Use SuperForm instead. */ export type EnhancedForm = SuperForm; /** * Initializes a SvelteKit form, for convenient handling of values, errors and sumbitting data. * @param {SuperValidated} form Usually data.form from PageData. * @param {FormOptions} options Configuration for the form. * @returns {SuperForm} An object with properties for the form. * @DCI-context */ export declare function superForm = ZodValidation, M = any>(form: SuperValidated, options?: FormOptions, M>): SuperForm, M>;