toolmark-monorepo / @toolmark/react / UseWizardToolOptions
Interface: UseWizardToolOptions
Defined in: packages/react/src/use-wizard-tool.ts:18
Options for useWizardTool (spec §8.2, D25).
Properties
current
current:
string
Defined in: packages/react/src/use-wizard-tool.ts:46
Name of the current step.
currentAdapter?
optionalcurrentAdapter?:FormAdapter<Record<string,unknown>>
Defined in: packages/react/src/use-wizard-tool.ts:61
The mounted form of the current step, if any. Parent-state mode: optional (its absence falls back to resetCurrent). Stepwise mode: required. Read through a ref on every call, so a fresh adapter object each render is picked up without a re-registration.
data?
optionaldata?:Record<string,Record<string,unknown>>
Defined in: packages/react/src/use-wizard-tool.ts:42
The parent's source of truth (e.g. a useState slice), one values object per step name. Present together with setData selects parent-state mode (createWizardTools); otherwise the hook uses the stepwise fallback (createStepwiseWizardTools), which then requires next, previous and currentAdapter.
description
description:
string
Defined in: packages/react/src/use-wizard-tool.ts:26
LLM-facing description of the wizard.
name
name:
string
Defined in: packages/react/src/use-wizard-tool.ts:24
Tool name prefix. Parent-state mode registers <name>.fill, <name>.goTo, <name>.submit (+ <name>.options when any step declares options); the stepwise fallback registers <name>.step.fill, <name>.next, <name>.previous, <name>.submit.
resetCurrent?
optionalresetCurrent?: (values) =>void
Defined in: packages/react/src/use-wizard-tool.ts:68
Parent-state mode without a mounted currentAdapter: called with the current step's merged values after a fill/undo wrote them into data, so the app can reset its visible step form. Its presence (not just its identity) is read once per registration: switching between "has a resetCurrent" and "has none" re-registers the wizard.
Parameters
values
Record<string, unknown>
Returns
void
setData?
optionalsetData?: (next) =>void
Defined in: packages/react/src/use-wizard-tool.ts:44
Replaces the parent data. Parent-state mode only; called at most once per fill/undo.
Parameters
next
Record<string, Record<string, unknown>>
Returns
void
steps
steps:
WizardStep[]
Defined in: packages/react/src/use-wizard-tool.ts:35
The steps, in order. Read through a ref except for name/input/jsonSchema identity: the wizard re-registers when the step names, their count or an input/jsonSchema identity changes. A step's options providers are read through refs (a fresh closure each render never forces a re-registration); its sensitive list passes straight through to core.
submitSummary?
optionalsubmitSummary?: (data) =>string
Defined in: packages/react/src/use-wizard-tool.ts:92
User-facing submit confirmation summary. In parent-state mode it is called with a copy of UseWizardToolOptions.data in which the current step is replaced by its live values (the mounted currentAdapter's values when present), so the confirmation reflects edits on the visible step that have not been synced into data yet. In stepwise mode (no UseWizardToolOptions.data) this is called with {} — the hook has no parent data to hand it in that mode.
Parameters
data
Record<string, Record<string, unknown>>
Returns
string
title?
optionaltitle?:string
Defined in: packages/react/src/use-wizard-tool.ts:28
User-facing title (used in the submit confirmation summary).
Methods
goTo()
goTo(
step):void
Defined in: packages/react/src/use-wizard-tool.ts:55
Navigates to a step. Before calling this, <name>.goTo (parent-state mode) first writes the mounted current step's values (via currentAdapter) into data — through setData — so a tm.undo() or <name>.submit issued after navigating away still sees them (spec §8.2; the wizard engine itself only writes the current step through its mounted form, not into the parent data — see the Task 4 review). Read through a ref: a fresh closure each render never forces a re-registration.
Parameters
step
string
Returns
void
next()?
optionalnext():Promise<ToolResult<unknown>>
Defined in: packages/react/src/use-wizard-tool.ts:70
Validates the current step and moves forward. Stepwise mode only; required there.
Returns
Promise<ToolResult<unknown>>
previous()?
optionalprevious():void
Defined in: packages/react/src/use-wizard-tool.ts:72
Moves back one step. Stepwise mode only; required there.
Returns
void
submit()
submit(
data):Promise<ToolResult<unknown>>
Defined in: packages/react/src/use-wizard-tool.ts:84
Submits the wizard (consequential). In parent-state mode this is wrapped like goTo: the mounted current step's values are first merged into UseWizardToolOptions.data (via setData), and the merged parent data is passed as the argument.
Use the argument, not closed-over state. setData typically schedules a React state update that only becomes visible on the next render, while submit runs in the same tick — so a data captured by this closure is the pre-merge snapshot and misses the current step's latest edits. A zero-argument submit still works (the argument is simply ignored). In stepwise mode (no UseWizardToolOptions.data) the argument is {}.
Parameters
data
Record<string, Record<string, unknown>>
Returns
Promise<ToolResult<unknown>>