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

shivamreacttemplate

v0.3.0

Published

A lightweight and flexible React hook for managing multi-step forms with easy navigation and state management.

Readme

A lightweight and flexible React hook for managing multi-step forms with easy navigation and state management.

Installation

npm install react-hooks

or

yarn add react-hooks

Mult step Form Features

  • 🚀 Simple and intuitive multi-step form management
  • 🔄 Easy navigation between form steps
  • ✅ Built-in first and last step detection
  • 🌟 Typescript support
  • 🎨 Framework agnostic (works with react-hook-form, formik, etc.)

Usage

Basic Example

import UseMultiStepForm from '@yourusername/use-multi-step-form';
import React from 'react';

function MultiStepFormExample() {
  const steps = [
    () => <Step1 />,
    () => <Step2 />,
    () => <Step3 />
  ];

  const {
    handleBack,
    handleNext,
    step: StepComponent,
    isFirstStep,
    isLastStep
  } = UseMultiStepForm(steps);

  return (
    <div>
      <StepComponent />
      
      <div>
        <button 
          onClick={handleBack} 
          disabled={isFirstStep}
        >
          Previous
        </button>
        
        <button 
          onClick={handleNext} 
          disabled={isLastStep}
        >
          {isLastStep ? 'Submit' : 'Next'}
        </button>
      </div>
    </div>
  );
}

With React Hook Form

import UseMultiStepForm from '@yourusername/use-multi-step-form';
import { useForm } from 'react-hook-form';

function ComplexMultiStepForm() {
  const steps = [
    ({ register }) => (
      <div>
        <input {...register('name')} />
      </div>
    ),
    ({ register }) => (
      <div>
        <input {...register('email')} />
      </div>
    )
  ];

  const methods = useForm();
  const multiStepForm = UseMultiStepForm(steps);

  const onSubmit = (data) => {
    // Handle form submission
  };

  return (
    <form onSubmit={methods.handleSubmit(onSubmit)}>
      <multiStepForm.step 
        register={methods.register} 
      />
      {/* Navigation buttons */}
    </form>
  );
}

API

UseMultiStepForm(steps)

Parameters

  • steps: An array of step components

Returns

  • handleBack(): Navigate to previous step
  • handleNext(): Navigate to next step
  • step: Current step component
  • isFirstStep: Boolean indicating first step
  • isLastStep: Boolean indicating last step

TypeScript Support

type StepComponent = React.ComponentType<{
  register?: any;
  errors?: any;
}>;

declare function UseMultiStepForm(steps: StepComponent[]): {
  handleBack: () => void;
  handleNext: () => void;
  step: StepComponent;
  isFirstStep: boolean;
  isLastStep: boolean;
};

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

@Pagination

A highly customizable and responsive React pagination component with intelligent page number calculation.

Features

  • 🌟 Intelligent page number calculation
  • 🎨 Fully customizable styles
  • 📱 Responsive design
  • 🔢 Configurable page limit
  • ✅ TypeScript support

Usage

Basic Example

import Pagination from '@yourusername/react-smart-pagination';
import React, { useState } from 'react';

function PaginationExample() {
  const [currentPage, setCurrentPage] = useState(1);
  const totalPages = 50;

  return (
    <Pagination
      totalPages={totalPages}
      Page={currentPage}
      handlePageChange={setCurrentPage}
      limit={7}
    />
  );
}

Advanced Configuration

function AdvancedPaginationExample() {
  const [page, setPage] = useState(1);

  return (
    <Pagination
      totalPages={100}           // Total number of pages
      Page={page}                // Current page
      handlePageChange={setPage} // Page change handler
      limit={5}                  // Number of visible page buttons
    />
  );
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | totalPages | number | 0 | Total number of pages | | Page | number | 1 | Current active page | | handlePageChange | (page: number) => void | () => {} | Callback when page changes | | limit | number | 5 | Maximum visible page buttons |

Customization

Custom Styling

You can pass custom styles to override default styling:

<Pagination
  totalPages={20}
  Page={currentPage}
  handlePageChange={setCurrentPage}
  styles={{
    button: {
      backgroundColor: 'purple',
      color: 'white'
    },
    activeButton: {
      backgroundColor: 'pink'
    }
  }}
/>

TypeScript Support

interface PaginationProps {
  totalPages: number;
  Page: number;
  handlePageChange: (page: number) => void;
  limit?: number;
  styles?: {
    button?: React.CSSProperties;
    activeButton?: React.CSSProperties;
  };
}

declare function Pagination(props: PaginationProps): JSX.Element;

Performance

  • Minimalistic design
  • O(n) time complexity for page number calculation
  • Lightweight and tree-shakable

Contributing

Contributions are welcome! Please submit pull requests or open issues on our GitHub repository.

License

MIT License