* Changes the active step to the target step if the target step is allowed. * * @param targetStep - The target step
(targetStep: FormKitFrameworkContext, e?: Event)
| 360 | * @param targetStep - The target step |
| 361 | */ |
| 362 | async function setActiveStep(targetStep: FormKitFrameworkContext, e?: Event) { |
| 363 | if (e) { |
| 364 | e.preventDefault() |
| 365 | } |
| 366 | const parentNode = targetStep?.node.parent |
| 367 | if (targetStep && targetStep.node.name && parentNode) { |
| 368 | const currentStep = parentNode.props.steps.find( |
| 369 | (step: FormKitFrameworkContext) => |
| 370 | step.node.name === parentNode.props.activeStep |
| 371 | ) |
| 372 | if (!currentStep) return |
| 373 | const stepIsAllowed = await isTargetStepAllowed(currentStep, targetStep) |
| 374 | if ( |
| 375 | stepIsAllowed && |
| 376 | targetStep.node.parent === parentNode && |
| 377 | parentNode.context |
| 378 | ) { |
| 379 | parentNode.props.activeStep = targetStep.node.name |
| 380 | } |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | async function goToStep(node: FormKitNode, target: number | string) { |
| 385 | await node.settled |
no test coverage detected