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

react-forms-data-aggregator

v1.0.0

Published

A React HOC to easily aggregate data from a form.

Readme

objective

A React HOC to easily aggregate data from a form.

installation

usage example

wizard.js:

<PersonForm 
  onSubmit={this.onSubmit}
  reporter={
    ({errors}) => (
      errors.map(err => (<Message key={err} error size='mini'>{err}</Message>))
    )
  }
/>

PersonForm.js:

import React from 'react'
import { formHoc, Field, Submitter } from '../../src'
import { Form, Button } from 'semantic-ui-react'
import semanticConfig from './semanticConfig'

const options = [
  { key: 'm', text: 'Male', value: 'male' },
  { key: 'f', text: 'Female', value: 'female' },
]

const ageValidationRules = [
  {
    func: value => {
      const failed = value === undefined || value === ''
      return !failed
    },
    error: 'age should not be empty.'
  }, 
  {
    func: str => {
      if (!(/^\d+$/.test(str))) {
          return false
      }
      if (/^0/.test(str)) {
          return false
      }
      return true
    },
    error: 'age must be a number'
  },
  {
    func: value => {
      const intValue = parseInt(value)
      if (intValue < 18 || intValue > 121) { return false }
      return true
    },
    error: 'age must be between 18 and 121'
  }
]

const PersonForm = props => (
  <Form>

    <Form.Group widths='equal'>

      <Field {...semanticConfig('input', 'firstName')}>
        <Form.Input fluid label='First name' placeholder='First name' />
      </Field>
      <Field {...semanticConfig('input', 'lastName')}>
        <Form.Input fluid label='Last name' placeholder='Last name' />
      </Field>
      <Field {...semanticConfig('select', 'gender')}>
        <Form.Select fluid label='Gender' options={options} placeholder='Gender' />
      </Field>
    </Form.Group>
    <Form.Group widths='equal'>
      <Field {...semanticConfig('input', 'age', ageValidationRules)} dataTransformer={value => parseInt(value)}>
        <Form.Input fluid label='Age' placeholder='Age' />
      </Field>
    </Form.Group>

    <Submitter>
      <Button>Submit</Button>
    </Submitter>

  </Form>
)

export default formHoc(PersonForm)

props documentation

formHoc

| prop | type | default value | description | | --- | --- | --- | --- | | onSubmit | function | - | function that will be called on Submitter click | | reporter | function as rect component | - | react component that will render validation erros; errors will be passed to it with the errors prop |

Field

| prop | type | default value | description | | --- | --- | --- | --- | | name | string | - | is required; that's the name of field that is binded to data field that, in its turn, will be reported with the onSubmit event | | onChange | object | { listenTo: 'onChange',valueExtractor: (...args) => { return args[0].target.value }} | defines how to listen to the control changes, wrapped with Field | | validators | array | - | array of validation rules; each rule is shape of object with func property (functin like value => value !== ') and with error property - textual representation of validation error | | onBlurValidation | boolean | false | indicates whether validation is going to be done onBlur event | | validationTrigger | string | - | required only if validators are defined; that's a name of wrapped component prop responsible for displaying validation failed state of the component | | reversedTrigger | boolen | false | indicats if the validationTrigger should be provided with reversed valid value; i.e. semantic controls indicate invalid state with error={true} property; the Field will hold valid={false} in its state; so with reversedTrigger the valid={false} will be transformed to error={!valid}={true} | | dataTransformer | function | - | as a rule, wrapped controls hold their valus in string format; if there is a need to transform string into something else - dataTransformer prop should be used; i.e. dataTransformer={value => parseInt()} will pass int into the data repored with formHoc onSubmit event |

development and demo

git clone ...
cd ...
npm install 
npm start

to publish

if nwb isn't installed:

npm install -g nwb

and then:

nwb build-react-component
npm login
...
...
...
npm publish