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

formons

v0.2.44

Published

## What is Formons? πŸ“

Downloads

25

Readme

formons

What is Formons? πŸ“

Formons is a powerful tool designed to simplify the creation of interactive forms in development. Whether you're using React, Vue.js, Angular, or any other JavaScript framework, Formons offers a flexible, framework-agnostic solution for managing forms.

Key Features πŸ› οΈ

  • Building complex forms: With Formons, you can easily create forms containing various types of fields such as text, numeric, select, checkboxes, etc. Its flexibility allows effortless management of complex form structures.

  • Framework independence: Unlike other solutions that may be specific to a particular framework, Formons is designed to be used with any JavaScript framework. This means you can easily integrate it into your existing project, regardless of the front-end technology you are using.

In summary, Formons provides a robust and versatile solution to simplify the creation and management of forms in your web projects, irrespective of the framework you are using.

install

# yarn
yarn add formons

# npm
npm install formons

usage

<form id="form">
  <input type="text" formons-shema="name" placeholder="name" />
  <input type="number" formons-shema="age" placeholder="age" />
  <button type="submit">Click me</button>
</form>
import { create, validators } from "formons";

const model = create({
  schemaOptions: [
    {
      key: "name",

      validators: [
        {
          fn: validators.required,
          args: ["name"],
        },
        {
          fn: function (model, length: number) {
            if (typeof model.formValues.name !== "undefined") {
              if (`${model.formValues.name}`.length !== length) {
                model.schemas[model.schemasIndex.name].errors!.push(
                  `name_length_must_be_${length}`
                );
              }
            }

            return model;
          },
          args: [5],
        },
      ],
    },
    {
      key: "age",

      validators: [
        {
          fn: validators.number,
          args: ["age"],
        },
      ],
    },
  ],
});

model.mount(document.querySelector("#form"));

validators

In order to be able to execute validators by priority, they have been transformed into an array since version 0.2.0. Validator priority based on schema order and order of arrival in Schema.validators.

export interface SchemaInterface {
  /** formons-shema="key" */
  el?: Element;
  [key: string]: any;
}

export interface Schema {
  // --

  /**
   * validation functions are called before submitting form and after `Schema.onBeforeSubmit`.
   * They can also be called directly with the `Model.validate` function.
   *
   * The aim is to fill in `Model.isFormValid` and update `Schema.errors`.
   *
   * Validator priority based on schema order and order of arrival in `Schema.validators`.
   * */
  validators: Array<SchemaValidator>;

  // ---
}

Events πŸ†•

Execute functions at different stages of your form.

export interface Schema {
  // ---

  events: SchemaEvents;

  // ---
}

export interface SchemaEvents {
  /** After creating the model */
  onModelCreated?: (key: string, model: Model) => Model | Promise<Model>;

  /** This function is called after the `Model.mount` function has been called. */
  onMounted?: (key: string, model: Model) => Model | Promise<Model>;

  /** this function is called before the form is submitted */
  onBeforeSubmit?: (key: string, model: Model) => Model | Promise<Model>;

  /** custom event like `onSave` for example  */
  [funcName: string]:
    | ((key: string, model: Model) => Model | Promise<Model>)
    | undefined;
}

onModelCreated

After creating the model

onModelCreated?: (key: string, model: Model) => Model | Promise<Model>;

Example

await create({
  schemaOptions: [
    {
      key: "name",
      events: {
        async onModelCreated(key, model) {
          // your logic here

          return model;
        },
      },
    },
  ],
});

onMounted

This function is called after the Model.mount function has been called.

onMounted?: (key: string, model: Model) => Model | Promise<Model>;

Example

const model = await create({
  schemaOptions: [{ key: "test" }],

  onFormValuesChanged(model) {
    onFormValuesChangedSpy(model);
  },
});
onBeforeSubmit?: (key: string, model: Model) => Model | Promise<Model>;

custom event

custom event like onSave for example

Example

const model = await create({
  schemaOptions: [
    {
      key: "name",
      events: {
        async onBeforeSave(key, model) {
          return model;
        },
      },
    },
  ],
});

function saveData(model: Model) {
  model.schemas.forEach((schema) => {
    if (schema.events.onBeforeSave) {
      schema.events.onBeforeSave(schema.key, model);
    }
  });
}

saveData(model);

Author

Mamadou @domutala