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

Function incrementStep

packages/addons/src/plugins/multiStep/multiStepPlugin.ts:414–435  ·  view source on GitHub ↗

* Changes the current step by the delta value if the target step is allowed. * * @param delta - The number of steps to increment or decrement * @param step - The current step

(
  delta: number,
  currentStep: FormKitFrameworkContext
)

Source from the content-addressed store, hash-verified

412 * @param step - The current step
413 */
414async function incrementStep(
415 delta: number,
416 currentStep: FormKitFrameworkContext
417) {
418 const parentNode = currentStep?.node.parent
419 if (currentStep && currentStep.node.name && parentNode) {
420 const steps = parentNode.props.steps
421 const stepIndex = currentStep.stepIndex
422 const targetStep = steps[(stepIndex as number) + delta]
423 if (!targetStep) return
424 const stepIsAllowed = await isTargetStepAllowed(currentStep, targetStep)
425
426 if (
427 targetStep &&
428 stepIsAllowed &&
429 currentStep.node.parent === parentNode &&
430 parentNode.context
431 ) {
432 parentNode.props.activeStep = targetStep.node.name
433 }
434 }
435}
436
437/**
438 * Causes the display of any validation errors on the target step.

Callers 2

initEventsFunction · 0.85
multiStepPluginFunction · 0.85

Calls 1

isTargetStepAllowedFunction · 0.85

Tested by

no test coverage detected