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

octo-form

v2.0.13

Published

![OctoForm logo](docs/logo.png)

Downloads

13

Readme

OctoForm logo

OctoForm

Write less code to create your forms.

OctoForm is a wrapper that combines Bootstrap 5 + react-hook-form + yup using ReactJS.

Example repository https://github.com/jmaister/octo-form-example

Screenshot

Screenshot

Install

With npm:

npm install --save octo-form

or yarn:

yarn add octo-form

Usage

  1. Import the component:
import { OctoForm } from 'octo-form';
  1. Create a yup schema
const iceCreamOptions: OptionLabel[] = [
  { value: "", label: "-- no flavor --" },
  { value: "chocolate", label: "Chocolate" },
  { value: "strawberry", label: "Strawberry" },
  { value: "vanilla", label: "Vanilla" },
];

const dayOptions: OptionLabel[] = [
  { value: "", label: "-- no day --" },
  { value: "Monday", label: "Monday" },
  { value: "Tuesday", label: "Tuesday" },
  { value: "Wednesday", label: "Wednesday" },
  { value: "Thursday", label: "Thursday" },
  { value: "Friday", label: "Friday" },
  { value: "Saturday", label: "Saturday" },
  { value: "Sunday", label: "Sunday" },
];

const schema = yup.object({
  example: yup.string(),
  exampleRequired: yup.string().required(),
  iceCreamType: yup.string().oneOf(iceCreamOptions.filter(o => o.label != "").map(option => option.value.toString())),
  age: yup.number().positive().integer().moreThan(0).required(),
  todaysDate: yup.date().required(),
  todaysDateAndTime: yup.date().required(),
  days: yup.array().of(yup.string().required().oneOf(dayOptions.filter(o => o.label != "").map(option => option.value.toString()))).required(),
  volume: yup.number().positive().integer().min(0).max(10).required(),
});
  1. Create a form component
const onSubmit: SubmitHandler<SampleFormType> = (data) => {
    console.log(data);
  }


<OctoForm defaultValues={defaultValues} schema={schema} onSubmit={onSubmit}>
    <div className="container">

      <FormInputText name="example" label="Example" />
      <FormInputText name="exampleRequired" label="Example required" />
      <FormInputDropdown name="iceCreamType" label="Ice Cream Type" options={iceCreamOptions} />
      <FormInputText name="age" label="Age" />
      <FormInputDate name="todaysDate" label="Today's date" />
      <FormInputDateTime name="todaysDateAndTime" label="Today's date and time" />
      <FormInputSlider name="volume" label="Volume" />
      <FormInputCheckbox name="isVegan" label="Vegan" />

      <Button
        type="submit"
        variant="contained"
      >Submit</Button>
    </div>

  </OctoForm>

Contribute

Bump version and publish

yarn bump

TODO

  • File component
  • Password component
  • Number component: auto wity yup.number(), decimals?
  • Add autocalculated field -> textfield with calculated value, watch/useWatch
  • Table selection: https://mui.com/material-ui/react-table/#sorting-amp-selecting
  • Edit data type T and submit data type S can be different, i.e. Subscription - SubscriptionData