Skip to content

feat: add step-wizard#5162

Merged
chronark merged 2 commits intomainfrom
feat-step-wizard
Mar 3, 2026
Merged

feat: add step-wizard#5162
chronark merged 2 commits intomainfrom
feat-step-wizard

Conversation

@ogzhanolguncu
Copy link
Contributor

@ogzhanolguncu ogzhanolguncu commented Mar 2, 2026

What does this PR do?

Adds a new StepWizard component to the UI library that provides a flexible multi-step wizard interface. The component includes:

  • A StepWizard.Root container that manages wizard state and navigation
  • A StepWizard.Step component for individual steps with smooth transitions
  • Support for required and optional steps with skip functionality
  • Navigation controls (next, back, skip, goTo) with validation
  • Step registration system that maintains insertion order
  • Context-based API with useStepWizard hook for accessing wizard state
  • TypeScript types for step metadata, positions, and context values

The wizard handles step transitions with opacity and transform animations, prevents navigation when appropriate (e.g., preventBack flag), and triggers an onComplete callback when reaching the final step.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

  • Create a multi-step form using StepWizard.Root and multiple StepWizard.Step components
  • Test navigation between steps using the next, back, and goTo functions
  • Verify optional steps can be skipped using the skip function
  • Test that steps with preventBack flag block backward navigation
  • Confirm step transitions animate smoothly with opacity and transform effects
  • Verify the onComplete callback fires when reaching the final step

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Ran make fmt on /go directory
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

@vercel
Copy link

vercel bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Mar 2, 2026 4:24pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 2, 2026

📝 Walkthrough

Walkthrough

Introduces a new Step Wizard UI component with reducer-based state management, enabling multi-step navigation with step registration, forward/backward movement, completion callbacks, and derived positioning metadata.

Changes

Cohort / File(s) Summary
Step Wizard Core Implementation
web/internal/ui/src/components/step-wizard/types.ts, web/internal/ui/src/components/step-wizard/step-wizard.tsx
New types defining step metadata (StepKind, StepMeta, StepPosition), wizard state machine (WizardState, WizardAction), and context value shape. StepWizard component exposes Root and Step sub-components with reducer-based state management, step registration lifecycle, navigation actions (next, back, goTo), and context-driven rendering.
Public API Exports
web/internal/ui/src/components/step-wizard/index.ts, web/internal/ui/src/index.ts
Barrel export file re-exporting StepWizard component, useStepWizard hook, and public types. Main package index extended to expose step-wizard module in public API.

Sequence Diagram

sequenceDiagram
    participant User
    participant StepWizardRoot
    participant StepWizardStep
    participant Reducer
    participant Context

    User->>StepWizardRoot: Render StepWizard.Root with steps
    StepWizardRoot->>Reducer: Initialize state (empty steps)
    
    StepWizardStep->>Reducer: REGISTER_STEP on mount
    Reducer->>Reducer: Add step to state, update activeStepId
    Reducer->>Context: Publish state update
    Context->>StepWizardStep: Provide position, canGoBack, canGoForward
    
    User->>Context: Call next() action
    Context->>Reducer: GO_NEXT action
    Reducer->>Reducer: Advance activeStepId, compute position
    Reducer->>Context: Update context value
    Context->>StepWizardStep: Re-render active step with transitions
    
    User->>Context: Call back() action
    Context->>Reducer: GO_BACK action (if canGoBack)
    Reducer->>Reducer: Decrement activeStepId
    Reducer->>Context: Publish updated state
    
    StepWizardStep->>Reducer: UNREGISTER_STEP on unmount
    Reducer->>Reducer: Remove step from state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add step-wizard' clearly and concisely describes the main change: introducing a new StepWizard component to the UI library.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering what the component does, type of change, testing instructions, and includes the required checklist.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-step-wizard

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/internal/ui/src/components/step-wizard/step-wizard.tsx`:
- Around line 186-189: The root wrapper rendered by StepWizardContext.Provider
is not positioned, so absolutely positioned step panels in StepWizard.Step
(which use "absolute inset-0") will be anchored to an unintended
ancestor/viewport; update the wrapper div rendered in StepWizard (the element
using className and cn("flex flex-col", className)) to include a positioning
class (e.g., "relative") so that StepWizard.Step panels are positioned against
this root container rather than an outer ancestor.
- Around line 65-73: When handling the "UNREGISTER_STEP" action in the reducer,
ensure state.activeStepId remains valid: if action.id === state.activeStepId,
pick a fallback from the remaining steps (for example use nextSteps[0]?.id or
null) and include that value in the returned state alongside the updated steps
and insertionOrder; update the "UNREGISTER_STEP" return to set activeStepId to a
valid id instead of leaving the old (now-deleted) id so code that computes
activeStepIndex no longer gets -1.
- Around line 96-101: The GO_TO handler currently allows jumping backward even
when the current step has preventBack; update the case in the reducer so it
first finds the current step by state.activeStepId and the indices of the
current step and target step (using state.steps and action.id), and if the
target index is less than the current index and currentStep.preventBack is true,
return state (no-op); otherwise proceed to return the new state with
activeStepId: action.id. Ensure you still validate the target exists
(state.steps.some(...)) and use the step ids/indexes to enforce the preventBack
rule.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13915d2 and c1cf6ff.

📒 Files selected for processing (4)
  • web/internal/ui/src/components/step-wizard/index.ts
  • web/internal/ui/src/components/step-wizard/step-wizard.tsx
  • web/internal/ui/src/components/step-wizard/types.ts
  • web/internal/ui/src/index.ts

@chronark chronark merged commit db737e8 into main Mar 3, 2026
24 checks passed
@chronark chronark deleted the feat-step-wizard branch March 3, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants