FormState
API / @publicodes/forms / FormState
type FormState<RuleName> = object;
Defined in: formBuilder.ts:35
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 |
---|---|
RuleName extends string | The type of rule names used in the form |
Type declaration
Name | Type | Defined in |
---|---|---|
currentPageIndex | number | formBuilder.ts:39 |
lastAnswered | RuleName | null | formBuilder.ts:41 |
nextPages | RuleName [][] | formBuilder.ts:40 |
pages | RuleName [][] | formBuilder.ts:38 |
situation | Situation <RuleName > | formBuilder.ts:36 |
targets | RuleName [] | formBuilder.ts:37 |
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())