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

pyro-form

v3.0.0

Published

Pyro-Form is a fast and simple form manager for react that helps you with managing your components data in a form.

Downloads

176

Readme

Pyro-Form

Pyro-Form is a fast and simple form manager that helps you with managing the state of components in a form. It's also unbelievably small and has ZERO external dependencies. Give it a try!

🔥 Now with react hooks support 🔥

Why use Pyro-Form

Compact, simple and fast state management in react is hard. Pyro-Form takes away all the worries while still allowing you to hook into every process you want. I allows you to build forms fast, keeps overhead minimal and makes maintainability a breeze.

You probably think now "Ok I get why I need to use a form manager. But why should I use Pyro-Form and not one of the others out there?"

  1. Pyro form is small (and in the JS world size does matter) - Since Pyro-Form was built with the overall package size in mind it has zero external dependencies which makes it so small (1.1kb gzipped 😱). For more information see the size comparison here.

  2. Simple API - Why make it hard when it can be so easy? The API provides you with all necessary hooks you are used to while not making you worry about them if you don't want to. Also the Field Wrapper Component will allow you to make your components reuseable and easy-to-use with almost no changes to your current codebase.

  3. 100% built in Typescript - Almost everything is strictly typed. This not only makes it easier for us to provide high-quality and maintainable code for you, but also allows you to use our typings to make your code better.

Comparison with the most popular form management libraries for react

| | Redux-Form | Formik | React-Form | Pyro-Form | | --- | --- | --- | --- | --- | | Minified | 99.4kB | 40.6kB | 113.1kB | 5.8kB | | Minified+Gzipped | 26.7kB | 12kB | 30.1kB | 2.1kB |

Installation

Add via Yarn:

yarn add pyro-form

Add via NPM:

npm i pyro-form

If you would like us to support other ways of using pyro-form please open an issue.

Example

Here is a simple example for a login form.

// Define initial values for the form
const initialValues = {
  name: '',
  email: '',
  password: '',
}

// Define an onSubmit handler (this is optional, you could also instead define an onChange handler)
const onSubmit = (values) => {
  console.log('onSubmit', values)
}

// PyroForm expects a render function as a child (if you don't know what this is you can
// read more here: https://reactjs.org/docs/render-props.html#using-props-other-than-render)
export const BasicExample = () => (
  <PyroForm initialValues={initialValues} onSubmit={onSubmit}>
    {({ handleSubmit }) => (
      <form onSubmit={handleSubmit}>
        <h1>Basic Example</h1>
        <HookInput name="name" type="text" />
        <ComplexInput name="email" type="email" />
        <SimpleInput name="password" type="password" />
        <button type="submit">Submit</button>
      </form>
    )}
  </PyroForm>
)

Input Implementations

The preferred one is using hooks:

const HookInput = (props) => {
  const { core, meta } = usePyroField(props.name)

  return <input {...props} {...core} />
}

But you can also stay classy with render props

// Wrap a simple input with the field (PyroField recognices events and pulls there value automatically)
export class SimpleInput extends React.PureComponent {
  public render() {
    return (
      <PyroField name={this.props.name}>
        {({ core }) => <input {...this.props} {...core} />}
      </PyroField>
    )
  }
}

// Wrap a complex input with the field (You can also map the received value manually)
export class ComplexInput extends React.PureComponent {
  public render() {
    return (
      <PyroField name={this.props.name}>
        {({ core }) => (
          <input
            {...this.props}
            {...core}
            onChange={(e) => core.onChange(getValueFromEvent(e))}
          />
        )}
      </PyroField>
    )
  }
}

If you want to try more:

  1. Clone the repository: git clone [email protected]:eversport/pyro-form.git
  2. Start the dev server: yarn run dev
  3. Play around in the /example folder and try crazy stuff

Documentation

TODO

Who already uses Pyro-Form?

TODO

  • [x] Add ts-lint
  • [x] Add example
  • [ ] Add tests
  • [ ] Add documentation