UNPKG

@modular-forms/qwik

Version:

The modular and type-safe form library for Qwik

34 lines (33 loc) 779 B
import { isFieldDirty } from './isFieldDirty'; /** * Returns the initial store of a field. * * @param initialState The initial state. * * @returns The initial store. */ export function getInitialFieldStore(name, { value, initialValue, error, } = { value: undefined, initialValue: undefined, error: '', }) { const dirty = isFieldDirty(initialValue, value); return { internal: { initialValue, startValue: initialValue, validate: [], validateOn: undefined, revalidateOn: undefined, transform: [], elements: [], consumers: [], }, name, value, error, active: false, touched: dirty, dirty, }; }