UNPKG

@modular-forms/qwik

Version:

The modular and type-safe form library for Qwik

32 lines (31 loc) 739 B
/** * Returns the initial store of a field array. * * @param name The name of the field array. * @param state The initial state. * * @returns The initial store. */ export function getInitialFieldArrayStore(name, { items, initialItems, error } = { items: [], initialItems: [], error: '', }) { const dirty = initialItems.join() !== items.join(); return { internal: { initialItems: [...initialItems], startItems: [...initialItems], validate: [], validateOn: undefined, revalidateOn: undefined, consumers: [], }, name, items, error, active: false, touched: dirty, dirty, }; }