PageBuilder

API / @publicodes/forms / PageBuilder

type PageBuilder<RuleName> = (fields) => RuleName[][];

Defined in: formBuilder.ts:62

A function that organizes form fields into logical pages or groups.

Type Parameters

Type ParameterDescription
RuleNameThe type of rule names used in the form

Parameters

ParameterTypeDescription
fieldsRuleName[]Array of field names to organize into pages

Returns

RuleName[][]

A two-dimensional array where each inner array represents a page of fields

Remarks

The default implementation groups fields by their namespace (first part of the dotted name). You can provide a custom implementation to create your own page organization logic.

Example

// Custom page builder that puts each field on its own page
const singleFieldPages: PageBuilder<string> = (fields) =>
  fields.map(field => [field])