computeNextFields
API / @publicodes/forms / computeNextFields
function computeNextFields<Name>(engine, state): Name[] Defined in: computeNextFields.ts:18
Computes the next fields that need to be asked next in a form.
This function evaluates the given targets using the engine and returns a sorted array of missing variable names (dotted names) that haven’t been asked yet in previous pages. The fields are sorted by their “missing score” in descending order.
Type Parameters
| Type Parameter |
|---|
Name extends string |
Parameters
| Parameter | Type | Description |
|---|---|---|
engine | Engine<Name> | The Publicodes engine instance used for evaluation |
state | { pages: FormPages<Name>; targets: Name[]; } | Object containing form state with targets and previous pages |
state.pages | FormPages<Name> | Array of pages, where each page is an array of rule names |
state.targets | Name[] | Array of target rule names to evaluate |
Returns
Name[]
Array of dotted names representing the next fields to ask, sorted by priority