Skip to content

feat(modal): implement multi-step (steps) mechanism#290

Open
uttam12331 wants to merge 1 commit into
younisdev:mainfrom
uttam12331:feature/modal-steps
Open

feat(modal): implement multi-step (steps) mechanism#290
uttam12331 wants to merge 1 commit into
younisdev:mainfrom
uttam12331:feature/modal-steps

Conversation

@uttam12331

Copy link
Copy Markdown
Contributor

Summary

Implements the multi-step modal feature from #276. A new steps prop splits a modal into sequential pages with Next/Back navigation and animated transitions, while leaving classic elements based modals unchanged.

<Modal
  title="Register"
  theme="Crimson"
  steps={[
    { title: 'Account Details', elements: [{ type: 'text', name: 'firstName', placeholder: 'First Name', amount: 1 }] },
    { title: 'Security', elements: [{ type: 'password', name: 'password', placeholder: 'Password', amount: 1 }] }
  ]}
  onSubmit={(data) => console.log(data)}
/>

What it does

  • Per-step rendering — only the current step's elements are shown, reusing the existing field-rendering block and SerializeData pipeline (each step is serialized through the same path).
  • NavigationNext/Back buttons replace the default submit button; Next becomes the submit action on the final step. Back is hidden on the first step.
  • Per-step validationhandleValidation runs against the active step before allowing Next; the final submit re-validates every step so a back-navigated/skipped step can't slip through.
  • State persistencedata and errors live in shared state and persist across steps (fields are initialised once across all steps, so navigation never resets input).
  • Animated transitions — GSAP slide/fade between steps, plus a progress-dot indicator and per-step titles.
  • Backwards compatible — existing elements modals are untouched; the field wrapper uses display: contents when not stepped, so layout is identical to before.

Testing

  • Added a two-step registration example to the devbench (devbench/src/component/modal.jsx), toggleable via useSteps.
  • npm run build -w devbench succeeds (96 modules transformed).
  • Prettier-clean; no new lint errors introduced.

Closes #276

Add multi-step modal support via a new `steps` prop. Each step defines its
own `elements` and is rendered one page at a time with Next/Back navigation,
GSAP-animated transitions, a progress indicator and per-step titles.

- Reuses the existing field rendering and validation pipeline (SerializeData,
  handleValidation) per step.
- Next/Back replace the submit button; Next becomes submit on the final step.
- Per-step validation runs before advancing; the final submit re-validates
  every step.
- `data` and `errors` persist across steps.
- Classic `elements` based modals are unaffected (the field wrapper uses
  display: contents when not stepped).
- Adds a two-step registration example to the devbench.

Closes younisdev#276
@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@uttam12331 is attempting to deploy a commit to the younis' projects Team on Vercel.

A member of the Team first needs to authorize it.

@younisdev younisdev self-requested a review June 28, 2026 19:25
@younisdev

Copy link
Copy Markdown
Owner

Hey @uttam12331, great work on this! I'll get to reviewing it soon! Just been a bit busy. Thanks for your patience!

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.

[Feature] Implement steps mechanism for modal component.

2 participants