* 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 )
| 412 | * @param step - The current step |
| 413 | */ |
| 414 | async 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. |
no test coverage detected