FormState
API / @publicodes/forms / FormState
type FormState<RuleName> = object;Defined in: formBuilder.ts:36
Represents the complete state of a multi-page form.
This object encapsulates all data needed to track a user’s progress through a form, including their answers, the form structure, and navigation state.
Type Parameters
| Type Parameter | Description | 
|---|---|
| RuleNameextendsstring | The type of rule names used in the form | 
Type declaration
| Name | Type | Defined in | 
|---|---|---|
| currentPageIndex | number | formBuilder.ts:40 | 
| lastAnswered | RuleName|null | formBuilder.ts:42 | 
| nextPages | FormPages<RuleName> | formBuilder.ts:41 | 
| pages | FormPages<RuleName> | formBuilder.ts:39 | 
| situation | Situation<RuleName> | formBuilder.ts:37 | 
| targets | RuleName[] | formBuilder.ts:38 | 
Remarks
This state should be stored in your application and made reactive using your framework’s state management (React useState, Vue $state, Svelte stores, etc.). All form operations return a new state object that should replace the previous one.
Example
// In React
const [formState, setFormState] = useState<FormState<string>>(
  FormBuilder.newState()
)
// In Vue
const formState = ref(FormBuilder.newState())