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

step-wizard-react-hook

v0.3.2

Published

This is an attempt to create a form that validates as the user goes through each step. For now, it's most useful if you want to split the form but still have validation.

Downloads

7

Readme

Step Wizard for React Hook Form

This is an attempt to create a form that validates as the user goes through each step. For now, it's most useful if you want to split the form but still have validation.

Install

yarn add step-wizard-react-hook react-hook-form @hookform/resolvers yup

Code Example

import React from 'react';

import { StepWizardWrapper, StepWizardTab } from 'step-wizard-react-hook';

const MyStepWizard = StepWizardWrapper(<TabComponent />);

export const App = () => {
    return (
        <MyStepWizard onSubmit={(data) => console.log(data)}>
            <StepWizardTab name="Step 1">
                <p>Step 1</p>
            </StepWizardTab>

            <StepWizardTab name="Step 2">
                <p>Step 2</p>
            </StepWizardTab>

            <StepWizardTab name="Step 3">
                <p>Step 3</p>
            </StepWizardTab>
        </MyStepWizard>
    );
};

StepWizardWrapper

StepWizardWrapper needs to be called with the layout component inside so that it becomes StepWizardProvider. The Provider has the following properties and extends react-hook-form UseFormProps.

| Key | Type | Required | Description | | --------------- | --------------------------- | -------- | -------------------------------------------------------------------------------------- | | onSubmit | SubmitHandler<FormValues> | true | On submit event for the last step. | | aditionalData | { [key: string]: any } | false | Any additional data you want to provide in case you don't want to use another Context. | | children | React.ReactNode | true | Tabs indicating each step of the form. |

StepWizardTab

This component is used to help the lib gather important information regarding each step.

| Key | Type | Required | Description | | ------------------ | --------------------------- | -------- | ------------------------------------- | | id | string | false | Create a unique identifier if needed. | | name | string or React.ReactNode | true | Name for the layout tab bar. | | validationSchema | any | false | Yup validation schema for the step. | | children | React.ReactNode | true | Tab UI component for the form step. |

useStepWizard

This is the step wizard context containing the following data.

| Key | Type | Description | | --------------- | ---------------------------------- | ---------------------------------------- | | formRef | React.RefObject<HTMLFormElement> | Reference to the wrapper form | | tabs | StepWizardTabProps[] | List of all children tabs props. | | step | number | Current step. | | currentTab | StepWizardTabProps | Current step tab. | | aditionalData | { [key: string]: any } | Additional Data passed through Provider. | | gotoStep | (newStep?: number) => void | Go to a specific step. | | nextStep | () => void | Go to the next step. | | previousStep | () => void | Go to the previous step. |