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 🙏

© 2026 – Pkg Stats / Ryan Hefner

wonder-form

v1.0.2

Published

wonder-form React component

Readme

WonderForm is a really lightweight form building and validation component for React.

Features

  • No built in styles to overwrite
  • Comes with validation for common inputs like date, email, etc
  • Easily add custom validations or overwrite default validation

Demo

Table of Contents

Installation

$ npm install wonder-form

Example

import React, {Component} from 'react'
import {render} from 'react-dom'
import { WonderForm, WonderField } from 'wonder-form'

class Demo extends Component {
  onSubmit(formContents) {
    console.log(formContents)
  }

  render() {
    return (
      <div>
        <WonderForm onSubmit={this.onSubmit.bind(this)}>
          <WonderField name='fullname' type='fullname' required errorMessage={"Error"} />
          <WonderField name='email' type='email' required errorMessage={"Error"} />
          <WonderField name='date' type='date' minDate='4/25/2017' errorMessage={"Error"} />
          <WonderField name='password' type='password' minLength={6} errorMessage={"Error"}/>
          <WonderField name='submit' type='submit' text='Create Account' />
        </WonderForm>
      </div>
    )
  }
}

render(<Demo/>, document.querySelector('#demo'))

Components

WonderField

You can import two components, a WonderForm and WonderField. WonderFields are nested inside WonderForms.

import { WonderForm, WonderField } from 'wonder-form'

WonderField props:

|prop | type | description | |-----|--------|---------------| | *name | string | Must be a unique identifier for a field| | *type | string | Must be one of the following: 'text', 'email', 'password', 'date', 'fullname', 'submit', 'custom' | | placeholder | string | A normal placeholder | | className | string | A class for the WonderField | | errorMessage | string | An errorMessage to be displayed | | label | string | A label that goes above the input | | required | bool | Makes the field required | | minDate | string | Must be of the format MM/DD/YYYY. | | maxDate | string | Must be of the format MM/DD/YYYY. | | maxLength | number | Minimum length of the field. | | minLength | number | Maximum length of the field | | buttonText | string | For the submit type WonderField |

The following table shows which validation props will work for a certain type of input. All other props will be ignored or throw an error.

| type | props |
|-----|-----------------| | fullname | required, minLength, maxLength | | text | required, minLength, maxLength | | password | required, minLength, maxLength | | date | required, minDate, maxDate | | email | required | | submit | buttonText |

Creating a custom WonderField

A custom test must return undefined or an object like { type: 'errorName'}

  customTest(input, props) {
    let error;
    if (input !== 'custard') {
      error = {type: 'custard'};
    }
    return error;
  }
  <WonderField name='custom' type='custom' errorMessage='Error' test={this.customTest.bind(this)}/>

Styling a WonderField

A WonderField is composed of a label, input, and span. Pass in a class for the prop 'className' in a WonderField.

  <WonderField className="custom-class"></WonderField>
.custom-class {}
.custom-class label {}
.custom-class input {}
.custom-class span {}

WonderForm

WonderForm props:

|prop | type | description | |-----|--------|---------------| |children | Array of Objects or an Object | Should be a list of WonderFields| |onSubmit | function | Called whenever the WonderField with type='submit' is clicked. The field values and errors if there are any are passed in| |onSuccess | function | Called when there are no errors in any field in the WonderForm| |onError | function | Called if there are any errors. The field values with errors are passed in.|

Scripts

  • $ npm run test Runs the test suite