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

react-step-flow-wizard

v1.1.2

Published

An intelligent step workflow wizard for React

Downloads

4

Readme

react-step-flow-wizard

An intelligent multistep wizard for React

npm version

Demo

Storybook

Try it out

Example

Installation

npm install react-step-flow-wizard

yarn add react-step-flow-wizard

Quick Start

Import

import StepFlowWizard from "react-step-flow-wizard";

JSX

Create an array elements describing the components that make an individual step in the workflow. Each component will receive props which help to move forward or backward in the wizard. See the Props section for more detail on the props.

const screens = [
  {
    identifier: 'step1',
    component: (props) => {
      const { onNextClick } = props;
      return (
        <>
          // render something
          <button onClick={onNextClick}>Next </button>
        </>
      ):
    },
    // Any additional params you want to configure in the config file.
    params: {
      product: 'xxx',
    }
  },
  {
    identifier: 'step2',
    component: (props) => {
      const { onPreviousClick, onNextClick } = props;
      return (
        <>
          // render something
          <button onClick={onPreviousClick}>Previous </button>
          <button onClick={onNextClick}>Next </button>
        </>
      ):
    },
    shouldRender: ({ region }) => {
      // Show this step only for US region
      return region !== 'US';
    }
  },
   {
    identifier: 'step3',
    component: (props) => {
      const { onPreviousClick, onNextClick } = props;
      return (
        <>
          // render something
          <button onClick={onPreviousClick}>Previous </button>
          <button onClick={() => onNextClick({ data: {
            name: 'X',
            age: 18
          }})}>Next </button>
        </>
      ):
    },
  },
  {
    identifier: 'step4',
    component: (props) => {
      const { onPreviousClick, onNextClick } = props;
      return (
        <>
          // render something
          <button onClick={onPreviousClick}>Previous </button>
          <button onClick={onNextClick}>Next </button>
        </>
      ):
    },
    shouldRender: ({ age }) => {
      // Do not show this screen for minors.
      return age > 18;
    }
  },
  {
    identifier: 'step5',
    component: (props) => {
      const { onPreviousClick } = props;
      return (
        <>
          // render something
          <button onClick={onPreviousClick}>Previous</button>
        </>
      ):
    },
  },
];


<StepFlowWizard screens={screens} region="CA"/>

Highlights

  • Each individual component in the workflow will receive following props to manage the navigation in the wizard

    • onPreviousClick - go to the previous step
    • onNextClick - go to the next step
    • onGoToScreen - go to a step using the step identifier
  • Wizard also manages a Store where you can PUT things from any Step and GET things from any other Step.

    • Wizard Store gets exposed as Props to individual component
    • The navigation functions support adding things to the wizard Store
        onNextClick({ data: {
          name: 'Mr X',
          age: 42,
          address: {}
        }})
      
  • Dynamic control of skipping Step based on the config.

        const steps = [
          {
            identifier: 'step1',
            component: View1,
            shouldRender: (props) {
              const { region } = props;
              //Skip this step for non US regions
              return region === 'US';
            }
          }
          ...
        ]
  • Configure additional parameter in the Step definition, which are passed as props to component

          const steps = [
            {
              identifier: 'step1',
              component: View1,
              params: {
                // product will be available as props
                product: 'Iphone'
              }
            }
            ...
          ]

Props

Each component in the wizard will receive the following props that help perform navigation

Props Accessible On Each Step Component

| Prop | Data Type | Description | | ------------- | ---------- | ---------------------------------------------------------------------------------------- | | onPreviousClick | function | Go to previous step in the workflow, null if previous step is not present | | onNextClick | function | Go to next step in the workflow, null if next step is not present | | onGoToScreen | function | Navigate to a step using a named identifier | | props | object | StepFlowWizard also acts as a store where you can put and get things. onPreviousClick, onNextClick and onGoToScreen takes an argument of type { data: {foo: 'bar'} }, which results in adding a foo attribute to the Store, which can be accessed as a prop from the components. |

Author

Anoop Devadiga ([email protected])

Contributing

Contributions, issues and feature requests are welcome!