Skip to content

feat(codegen): multi-step wizard form generation (#121)#127

Open
ssilvius wants to merge 3 commits intomainfrom
feat/codegen-multi-step-forms
Open

feat(codegen): multi-step wizard form generation (#121)#127
ssilvius wants to merge 3 commits intomainfrom
feat/codegen-multi-step-forms

Conversation

@ssilvius
Copy link
Contributor

Summary

  • Adds FormStep interface and optional steps property to FormDescriptor
  • When steps is defined, codegen produces a wizard-style form component with:
    • Step progress indicator with role="tablist" accessibility
    • Card-wrapped step content with conditional rendering per step
    • handleNext() with per-step field validation via form.validateField()
    • Back/Next/Submit navigation buttons
    • useState for step tracking
  • When steps is undefined, existing single-step form generation is unchanged
  • FormStep exported from both introspection barrel and root package barrel
  • Works with built-in primitives, shadcn/ui, and Rafters (shared component API)

Test plan

  • 25 new wizard form tests covering: imports, state, aria, content, validation, navigation
  • 2 backward compatibility tests (undefined steps, empty steps)
  • 349 total tests passing
  • Biome lint clean, TypeScript clean

Closes #121

🤖 Generated with Claude Code

ssilvius and others added 3 commits February 26, 2026 16:43
…121)

Add FormStep type and optional steps field to FormDescriptor. When steps
are defined, codegen produces a wizard-style form with step indicator,
Card-wrapped step content, Next/Back/Submit navigation, and per-step
field validation using TanStack Form's validateField API. Single-step
forms remain unchanged (backward compatible).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add FormStep to root barrel export (src/index.ts)
- Fix per-step validation: use 'submit' cause instead of 'change'
  to match the onSubmit validator registration
- Extract indentJSX helper to reduce duplication
- Simplify generateStepContentBlocks with functional patterns
- Add generateWizardOutput() test helper to reduce 19-test boilerplate

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Validate step field references: throw when a step references an
  unknown field name (fail-hard, no silent drops)
- Validate field coverage: throw when a form field is not assigned
  to any step in wizard mode
- Replace hardcoded color classes (bg-gray-*, text-gray-*, etc.)
  with semantic Tailwind tokens (bg-primary, text-muted-foreground,
  bg-border, etc.) for theme compatibility
- Fix ARIA pattern: replace incorrect role="tablist"/role="tab" with
  nav element and aria-current="step" for sequential wizard progress
- Escape step labels and descriptions to prevent broken output from
  special characters (quotes, angle brackets, etc.)
- Add as const to STEPS array for better type inference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

feat(codegen): multi-step form generation with per-step validation

1 participant