UNPKG

@formulier/core

Version:

Simple, performant form library

31 lines (30 loc) 1.28 kB
import type { FieldValidator, FormulierOptions, FormulierState, Nullable, Primitives, Values } from './types.js'; declare class Formulier<V extends Values = Values, P = Primitives> { store: Store<FormulierState<V, P>>; instances: Record<string, Set<string>>; hasMounted: boolean; constructor({ initialValues }: FormulierOptions<V, P>); setValues: (values: Nullable<V, P>) => void; setFieldErrors: (fieldErrors: FormulierState<V, P>["errors"]) => void; validateFields: () => boolean; validateField: (name: string) => boolean; registerField: (name: string, validate: FieldValidator | undefined) => (() => void); addInstance: (name: string, instanceId: string) => (() => void); hasInstance: (name: string) => boolean; setFieldValue: (name: string, value: unknown) => void; touchField: (name: string, value?: boolean) => void; incrementSubmitCount: () => void; } declare class Store<S> { private batching; private flushing; private listeners; private state; constructor(state: S); getState: () => S; setState: (updater: (previous: S) => S) => void; subscribe: (listener: (state: S) => void) => (() => void); batch: (callback: () => void) => void; private flush; } export { Formulier };