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

@jadesrochers/formbuilder

v0.4.2

Published

Components to set up selection forms with selector updates

Downloads

43

Readme

Formbuilder; for selection forms with changing fields

The form library is aimed specifically at forms where changing one field
can change the options in the other fields.

Set up using the Form and Selector components -

RegSelectors will hold a static set of selections, while UpdateSelectors
fields can change based on the variables in other Selectors.

Each selector needs a dataget fcn/object to set the contents

This can be a function that retrieves data or just an array that specifies
what the options will be.
For UpdateSelectors it needs to be a fcn because the UpdateSelector will call
it anytime the specified other fields (changeon) change.
RegSelectors will just call it/use it once to populate the selector.

The form needs a submit fcn

The submit function will be passed the values stored in each selector, as well
as the submit event. I found the event hard to work with so it is just there
if anyone else prefers that format.

Also takes a defaultval

The argument is optional, but there is a good chance the Selector will not
pick the default value you want, since there are a lot of possible formats,
values and sorting preferences.

Selector variable sorting is alphabetical/numeric by default -

I just try and get it to do ascending order alpha/numeric sort as consistently
as possible.

Example setup

Two RegSelectors and and UpdateSelector that will update its values if either
of the others changes.

import { Form, RegSelector, UpdateSelector } from '@jadesrochers/formbuilder'
const Form = (props) => {
  return(
    <Form
      submitFormFcn = {handleFormSubmit}
    >
      <RegSelector dataget={getDataYears} varname='year' defaultval={props.year} />
      <RegSelector dataget={getDataMonths} varname='month' defaultval={props.month} />
      <UpdateSelector dataget={getDataVars} varname='varname' defaultval={props.varname} changeon={['year', 'month']}
/>
    </Form>
  )
}