MCPcopy Create free account
hub / github.com/formkit/formkit / getTargetStep

Function getTargetStep

packages/addons/src/plugins/multiStep/multiStepPlugin.ts:392–406  ·  view source on GitHub ↗
(
  node: FormKitNode,
  target: number | string
)

Source from the content-addressed store, hash-verified

390}
391
392function getTargetStep(
393 node: FormKitNode,
394 target: number | string
395): FormKitFrameworkContext | undefined {
396 const steps = node.props.steps as FormKitFrameworkContext[] | undefined
397 if (!Array.isArray(steps)) return
398 if (typeof target === 'number') {
399 return steps[target]
400 } else if (typeof target === 'string') {
401 return steps.find(
402 (step: Record<string, any>) => step.node.name === target
403 )
404 }
405 return undefined
406}
407
408/**
409 * Changes the current step by the delta value if the target step is allowed.

Callers 2

goToStepFunction · 0.85
multiStepPluginFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected