Genesis

Packages

@marktiderman/genesis-forms-react

0.3.3Primitive · Forms

React bindings for Genesis Forms: useForm, useField with one-field re-renders, a ranked renderer registry and a headless FormRuntime. Works in React DOM and React Native. Part of the Genesis framework.

React bindings for Genesis Forms. Headless: no markup, no styles. Works in React DOM and React Native.

It returns:

pnpm add @marktiderman/genesis-forms-react

READMEChangelognpm

@marktiderman/genesis-forms-react

Components (2)

  • FieldRenderer

    Render one block with whatever the registry resolves.

  • FormRuntime

    Headless: provides the engine, the renderer registry and an id prefix to everything below.

Hooks (9)

  • useChoiceOptions

    The options a choice question shows now (`visibleOptions` over `answersOnPath`): all of them, or, when its list is filtered by another answer (`props.optionsFrom.filter`), the ones matching that answer. It re-renders only when that list ...

  • useField

    Everything one field renderer needs. Typing in one field re-renders that field only.

  • useForm

    Create a form engine for a definition. The engine lives as long as the definition's identity: pass a different definition object and you get a fresh engine (and a fresh response). Keep the definition stable (module scope, `useMemo`) so a...

  • useFormContext
  • useFormController

    The headless controller behind a form renderer: the step on screen and the path, errors, Next and Back, sending with retry, auto-advance, saving progress, what to announce and where focus goes. A renderer (web, native) draws what it retu...

  • useFormDraft

    `useForm` with a draft on the device: the saved answers are put back when the form opens (where the respondent got to, too), saved again `delayMs` after each change, and flushed when the page is hidden or the component unmounts. With a s...

  • useFormSelector

    Subscribe to one slice of the form state. The component re-renders only when the selected value changes (`Object.is`), so return primitives or references the engine keeps stable (a field's value, an error string).

  • useRespondentPath

    The blocks the respondent steps through (`respondentPath`): the path without questions a prefill answered and hides (`props.prefill.hideWhenPrefilled`). Render these, not `state.path`, so a hidden question is neither shown nor counted.

  • useSubmitOutbox

    The outbox's state (what's waiting, what failed, online or not), re-rendered as it changes. Starts the outbox (its timers) on mount; it keeps running after unmount, because one outbox serves the whole app: make it once, at module scope o...

Other exports (6)

ADVANCE_DELAY_MS · CLASSIC_PROGRESS_DELAY_MS · createRendererRegistry · formEngineOptions · outboxSubmit · PROGRESS_DELAY_MS

And 14 types.