npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@gluedigital/multistep-form

v0.2.1

Published

Helper components to easily make multistep forms

Downloads

5

Readme

Multistep Form

A simple solution to create multi-step forms.

It supports:

  • Validation at each step
  • TransitionGroup integration
  • Submit event with all the fields available

Usage demo

import { MultistepForm, FormStep, FormState } from '@gluedigital/multistep-form'

// ...

const MyComponent = () => (
  <MultistepForm steps={2} onSubmit={handleSubmit}>

    <FormStep step={1}>
      <label>
        Name:
        <input name="name" />
      </label>
    </FormStep>

    <FormStep step={2}>
      Tell us a bit about yourself:
      <textarea name="bio" />
    </FormStep>

    <FormState>
      {({step}) => `Step: ${step}/2`}
    </FormState>

    <input type="submit" value="Send" />
  </MultistepForm>
)

All options

Below we list all the available components and their props:

MultistepForm

The main component, which acts as a replacement for the <form> tag. All other components should appear inside this one, and it can't be nested.

| Prop | Type | Meaning | |----------|--------|---------| | steps | number | The number of total steps on the form | | onSubmit | func | Handler that will be called on submit, and will receive all the saved data | | children | any | The form contents |

All other props will be passed through to the <form> tag.

FormStep

Defines a form step, wrapping some contents which will be shown only when active. Can be nested, which can be useful if the child steps have stricter conditions.

| Prop | Type | Meaning | |-----------|---------|---------| | step | number | The step number for this group | | steps | array | Array of steps for this group (if shown on multiple steps) | | condition | func | Function (data) => boolean to check whether this step should be enabled | | children | any | The step contents | | nowrap | boolean | Whether to wrap the contents on a div or not |

All other props will be passed through to the <div> tag, unless nowrap is set.

FormState

A render-props enabled component to get form info for your own usage. Useful for showing form info, like the current step or previously saved values.

| Prop | Type | Meaning | |----------|------|---------| | children | func | Render props: ({data, step}) => any |

NextButton

A next/submit button to jump to the next step. While you can use a regular <input type="submit" />, this component allows to set the next step, in case you want to skip some steps, or even go back.

| Prop | Type | Meaning | |------------|----------------|---------| | next | number or func | Next step number, or function (data) => number | | noValidate | boolean | Skip form validation (and discard the current step inputs) | | children | any | Button contents |