UNPKG

sveltekit-superforms

Version:

Making SvelteKit validation and displaying of forms easier than ever!

31 lines (30 loc) 2.35 kB
import { type Writable } from 'svelte/store'; import { type InputConstraint, type UnwrapEffects } from '../index.js'; import type { SuperForm } from './index.js'; import type { z, AnyZodObject } from 'zod'; import { type FormPath, type FormPathLeaves, type FormPathType } from '../stringPath.js'; import type { ZodValidation } from '../index.js'; type DefaultOptions = { trueStringValue: string; dateFormat: 'date' | 'datetime' | 'time' | 'date-utc' | 'datetime-utc' | 'time-utc' | 'date-local' | 'datetime-local' | 'time-local' | 'iso'; delimiter?: '.' | ','; empty?: 'null' | 'undefined'; }; export declare function intProxy<T extends Record<string, unknown>, Path extends FormPath<T>>(form: Writable<T>, path: Path, options?: Pick<DefaultOptions, 'empty'>): FormPathType<T, Path> extends number ? Writable<string> : never; export declare function booleanProxy<T extends Record<string, unknown>, Path extends FormPath<T>>(form: Writable<T>, path: Path, options?: Pick<DefaultOptions, 'trueStringValue'>): FormPathType<T, Path> extends boolean ? Writable<string> : never; export declare function numberProxy<T extends Record<string, unknown>, Path extends FormPath<T>>(form: Writable<T>, path: Path, options?: Pick<DefaultOptions, 'empty' | 'delimiter'>): FormPathType<T, Path> extends number ? Writable<string> : never; export declare function dateProxy<T extends Record<string, unknown>, Path extends FormPath<T>>(form: Writable<T>, path: Path, options?: { format: DefaultOptions['dateFormat']; empty?: DefaultOptions['empty']; }): FormPathType<T, Path> extends Date ? Writable<string> : never; export declare function stringProxy<T extends Record<string, unknown>, Path extends FormPath<T>>(form: Writable<T>, path: Path, options: { empty: NonNullable<DefaultOptions['empty']>; }): Writable<string>; export declare function formFieldProxy<T extends ZodValidation<AnyZodObject>, Path extends FormPathLeaves<z.infer<UnwrapEffects<T>>>>(form: SuperForm<T, unknown>, path: Path): { path: Path; value: Writable<FormPathType<z.infer<UnwrapEffects<T>>, Path>>; errors: Writable<string[] | undefined>; constraints: Writable<InputConstraint | undefined>; }; export declare function fieldProxy<T extends object, Path extends FormPath<T>>(form: Writable<T>, path: Path): Writable<FormPathType<T, Path>>; export {};