Skip to content

Solid Package (@gooonzick/wizard-solid) ​

API reference for @gooonzick/wizard-solid.

createWizard(options) ​

ts
function createWizard<T extends WizardData>(options: CreateWizardOptions<T>): Wizard<T>;

Creates a WizardMachine and a WizardStateManager and mirrors the manager's four channel snapshots into Solid signals.

CreateWizardOptions<T> ​

OptionTypeDefaultNotes
definitionWizardDefinition<T>—Read once.
initialDataT—Read once. Also the default for actions.reset().
contextWizardContext{}Read once.
pluginsWizardPlugin<T>[]—Registered once at creation.
autoDestroybooleantrueRegisters onCleanup(destroy) when an owner exists.
onStateChange(state: WizardState<T>) => void—
onStepEnter(stepId: StepId, data: T) => void—
onStepLeave(stepId: StepId, data: T) => void—
onComplete(data: T) => void—
onCancel(data: T) => void | Promise<void>—
onReset() => void—
onError(error: Error) => void—Machine errors and effect errors thrown during signal updates. When omitted, effect errors and reset/restore failures are logged with console.error.
onDataChange(prev: T, next: T, changedFields: (keyof T)[]) => void—

Wizard<T> ​

Reactive getters (read-only)

GetterTypeChannel
currentStepIdStepIdstate
currentStepWizardStepDefinition<T>state
dataTstate
isCompletedbooleanstate
stepStatusesRecord<StepId, StepStatus>state
progressWizardProgressstate
isValidbooleanvalidation
validationErrorsRecord<string, string> | undefinedvalidation
canGoNextbooleannavigation (async)
canGoPreviousbooleannavigation (async)
canGoBackbooleannavigation
isFirstStepbooleannavigation
isLastStepbooleannavigation (async)
visitedStepsStepId[]navigation
availableStepsStepId[]navigation (async)
stepHistoryStepId[]navigation
isValidatingbooleanloading
isSubmittingbooleanloading
isNavigatingbooleanloading
isLoadingStepbooleanloading — true while a lazy step's implementation loads (WIZ-013)
stateWizardStoreState<T>state
validationWizardStoreValidationvalidation
navigationWizardStoreNavigationnavigation
loadingWizardStoreLoadingloading

Navigation

MethodReturnsNotes
goNext()Promise<void>Validates, runs onSubmit, moves. Rejects on invalid step. Toggles isNavigating.
goPrevious()Promise<void>Toggles isNavigating.
goTo(stepId, options?)Promise<void>GoToOptions: skipValidation, skipLifecycle, skipGuards.

actions: WizardStoreActions<T>

ActionSignatureNotes
updateField<K extends keyof T>(field: K, value: T[K]) => voidNo-op when Object.is-equal.
updateData(updater: (data: T) => T) => void
setData(data: T) => void
validate() => Promise<void>Toggles isValidating. Resolves on an invalid step; rejects only if aborted.
validateAll(options?: { updateStatuses?: boolean }) => Promise<ValidationSummary>Toggles isValidating. Resolves even with invalid steps (a throwing validator counts as invalid); rejects if aborted or if a step's enabled guard throws. With updateStatuses: true, statuses are not written if reset() / cancel() / restore() / destroy() happened while it was running.
canSubmit() => Promise<boolean>
submit() => Promise<void>Toggles isSubmitting.
reset(data?: T) => voidFire-and-forget; errors → onError (else console.error).
cancel() => Promise<void>Calls onCancel, then resets.
serialize() => WizardSerializedState<T>
restore(state: WizardSerializedState<T>) => voidFire-and-forget; WizardRestoreError → onError (else console.error).
preloadStep(stepId: StepId) => Promise<void>Prefetches a lazy step's implementation (WIZ-013). Does not set isLoadingStep; never rejects (safe to fire and forget — failures are reported by the navigation that needs the step).

Other members

MemberTypeNotes
field(key)<K extends keyof T>(key: K) => WizardField<T[K]>Stable per key.
getMachine()WizardMachine<T>
getManager()WizardStateManager<T>
destroy()Promise<void>Idempotent.
isDestroyedboolean

WizardField<V> ​

ts
interface WizardField<V> {
	get value(): V; // reactive
	set value(v: V); // machine.updateField(key, v)
}

Context ​

WizardProvider ​

ts
function WizardProvider<T extends WizardData>(props: WizardProviderProps<T>): JSX.Element;

interface WizardProviderProps<T extends WizardData> {
	wizard: Wizard<T>; // read once; never destroyed by the provider
	children?: JSX.Element;
}

useWizardContext<T>() ​

Returns the nearest provided Wizard<T>. Throws Error("useWizardContext() must be called inside a <WizardProvider wizard={...}>.") when there is none.

hasWizardContext() ​

Returns true when a WizardProvider is above the caller, otherwise false. Never throws.

Re-exports ​

For convenience the package re-exports WizardProgress, WizardSerializedState and WizardRestoreError from @gooonzick/wizard-core, and WizardStateManager, LoadingState, NavigationState, StateSnapshot, SubscriptionChannel, ValidationState from @gooonzick/wizard-state.

Released under the MIT License.