import { Writable } from 'svelte/store'; import { Formula, FormulaError, FormulaOptions, FormulaValue, FormulaValueDefault } from '../types'; /** * The stores available in Beaker */ export interface BeakerStores { /** * A store containing the current form values */ formValues: Writable; /** * A store containing the values at the time of `
` submission */ submitValues: Writable; /** * A store containing the initial values */ initialValues: Writable; /** * A store containing the touched status of each named field */ touched: Writable[]>; /** * A store containing the dirty status of each named field */ dirty: Writable[]>; /** * A store containing the current validity of all named fields from HTML and custom validations */ validity: Writable[]>; /** * A store containing the current validity of all custom form validations */ formValidity: Writable[]>; /** * A store containing a boolean value if the form is overall valid */ isFormValid: Writable; /** * Observable value if the form state is ready to be used */ isFormReady: Writable; /** * A store containing additional field enrichment */ enrichment: Writable[]>; } /** * The Formula interface with stores and form factory */ export interface Beaker extends BeakerStores { /** * The form object for use with the Svelte use directive * @param node */ group: (node: HTMLElement) => { destroy: () => void; }; /** * Update all the underlying forms */ update: (options?: FormulaOptions) => void; /** * Destroy */ destroy: () => void; /** * Instance forms */ forms: Map>; /** * Stores */ stores: BeakerStores; /** * Initialise the store * @param items */ init: (items: T[]) => void; /** * Add an item to the group store */ add: (item: T) => void; /** * Add an item to the group store */ set: (index: number, item: T) => void; /** * Remove and item from the group store */ delete: (index: number) => void; /** * Clear all items */ clear: () => void; }