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

bloom-forms

v2.0.0

Published

form functionality used in bloom packages

Downloads

264

Readme

Bloom Forms

All your form functionality in one place.

2.0.0 Release Notes

1.0.0 Release Notes

Compatibility Note:

All of the functionality in this library is compatible with React 15 and 16 EXCEPT for the arrowdown focus functionality on SelectInputs. Your project must use React 16 if you want fully accessible SelectInputs, due to the internal changes surrounding setState.

Suggested Use

It's suggested to use this package to manage your form state and validation, and use the Bloom Inputs package for accessible, stylable inputs.

Features:

  • Standardized form value updates, regardless of input type.
  • Integrates seamlessly with bloom-starter.
  • All form actions available through redux.
  • Fully customizable validation. Works through form.jsx and independently.
  • Tracks any fields passed into fieldNames. Allows fully custom inputs without any special wrappers around each of them.

Why use Bloom Forms?

  • Built-in state management
  • Built-in error handling
  • Built-in form population
  • Built-in accessibility
  • All field values and errors available through Redux
  • Unopinionated about contents

Includes:

  • Redux:

    • formActions.js
    • formReducer.js
  • Components:

    • Form (form wrapper)

README Contents:

General:

<Form/> Wrapper

What Props are passed down to child inputs?

Validation & Error Handling

Redux -- Reducers, Actions, and Store format

Comparisons to other Redux form libraries

Setup

To use this package, you can install with either npm or yarn.

npm install bloom-forms --save

or

yarn add bloom-forms

To import the files/components in this package, import like:

import { Form, formReducer } from 'bloom-forms';

Contributing

Fork this repo, and submit any changes as a PR to master. Accepted PRs will be merged and published to npm.

Basic Usage

  • Every form needs two files: a container and a presentation component (with all the inputs inside it)
  • The container should render the presentation component wrapped inside of the generic Form.jsx container. This wrapper handles all your state, updating redux, errors, etc.
  • Example: A login form might look like this: (simplified -- make sure all your inputs have required props, etc.)
const LoginForm = (props) => {
  return (
    <form id='login-form'>
      <TextInput name='username' value={ formData.username } />
      <TextInput name='password' isPassword={ true } value={ formData.password.value } onBlur={ props.checkField } />
      <Button text='submit' onClick={ props.submitForm } />
    </form>
  )
}

And its container would look like this:

class LoginFormContainer extends React.Component {
  submitForm = (formData, files, successCallback, failCallback) => {
    WebService.login(formData)
      .then(res => {
        successCallback()
      })
      .catch(err => {
        failCallback()
      })
  }

  render() {
    let fieldNames = ['username', 'password']
  
    return (
      <Form id='login-form' fieldNames={ fieldNames } submitForm={ this.submitForm }>
        <LoginForm />
      </Form>
    )
  }
}
  • Note that the IDs match ('login-form'), and the fieldNames match the names of the TextInputs.

Now make sure that you've imported your formReducer into your reducers file in redux, like:

import { formReducer } from 'bloom-forms'
...

export default combineReducers({
  ...
  forms: formReducer
  ...
})

Back to Contents