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

@formitiva/vanilla

v2.1.2

Published

Formitiva Vanilla JS adapter — no framework dependencies

Downloads

430

Readme

@formitiva/vanilla

npm

Vanilla JavaScript adapter for Formitiva — build dynamic, schema-driven forms without any framework dependency.

Features

  • Zero framework dependency — works in any JavaScript environment
  • Class-based API — instantiate a Formitiva form and mount it to any DOM element
  • 25+ built-in field types — text, email, phone, dropdown, date, file, rating, slider, unit values, and more
  • Dynamic validationonEdit, onBlur, or onSubmission modes with built-in and custom validators
  • Conditional visibility — show/hide fields based on other field values via parent-child relationships
  • Computed values — derive field values from other fields automatically
  • Plugin system — register custom widgets, validators, submission handlers, and visibility rules
  • Theming — CSS variable-based theming with light/dark support
  • Localization — 29+ languages with CDN-based translation loading
  • TypeScript — fully typed API

Installation

npm install @formitiva/vanilla
# or
pnpm add @formitiva/vanilla

No framework peer dependencies required.

Quick Start

import { Formitiva } from "@formitiva/vanilla";

const definition = {
  name: "contactForm",
  version: "1.0.0",
  displayName: "Contact Form",
  properties: [
    { name: "fullName", displayName: "Full Name", type: "text", defaultValue: "", required: true },
    { name: "email", displayName: "Email", type: "email", defaultValue: "", required: true },
    { name: "message", displayName: "Message", type: "multiline", defaultValue: "" },
  ],
};

const form = new Formitiva({
  definitionData: definition,
  onSubmit: (_def, _instance, values) => {
    console.log("Submitted:", values);
    return undefined;
  },
});

await form.mount(document.getElementById("form-container")!);
<div id="form-container"></div>
<script type="module" src="./main.ts"></script>

Constructor Options

| Option | Type | Default | Description | |---|---|---|---| | definitionData | string \| object \| FormitivaDefinition | — | Form schema (JSON string, object, or typed definition) | | instance | FormitivaInstance | — | Optional saved instance with pre-filled values | | language | string | "en" | Language code for localization | | theme | string | "light" | Theme name ("light" or "dark") | | fieldValidationMode | FieldValidationMode | "onEdit" | When to validate: "onEdit", "onBlur", or "onSubmission" | | displayInstanceName | boolean | true | Show an editable instance name field | | onSubmit | FormSubmissionHandler | — | Callback on form submission | | onValidation | FormValidationHandler | — | Cross-field validation callback | | className | string | — | Additional CSS class for the container | | style | object | — | Inline styles for the container |

API

Formitiva class

const form = new Formitiva(options);

// Mount the form into a DOM element
await form.mount(container: HTMLElement);

// Unmount the form
form.unmount();

Utilities

| Export | Description | |---|---| | createFormitivaRenderer(options) | Lower-level renderer factory for custom integration | | createDefaultContext() | Creates a default form context (language, theme, translations) | | FormContext | Context type/constructor for advanced usage | | createFieldValidator(field) | Returns a validation function for a field | | createDebouncedCallback(fn, wait) | Debounced callback utility |

Widget Types

| Type | Description | |---|---| | FieldWidget | Interface for implementing custom field widgets | | ButtonFieldWidget | Interface for button-type widgets |

Extending

Custom Widgets

import { registerComponent } from "@formitiva/vanilla";

const myWidget = {
  render(container, field, context) {
    // Render your custom field into the container
  },
  getValue() {
    // Return current value
  },
  destroy() {
    // Clean up
  },
};

registerComponent("my-custom-field", myWidget);

Custom Validators

import { registerFieldValidator, registerTypeValidator } from "@formitiva/vanilla";

// Per-definition field validator
registerFieldValidator("myForm", "validateAge", (fieldName, value, t) => {
  if (Number(value) < 18) return t("Must be at least 18");
  return undefined;
});

// Global type validator
registerTypeValidator("currency", (field, input, t) => {
  if (Number.isNaN(Number(input))) return t("Must be a valid number");
  return undefined;
});

Plugins

import { registerPlugin } from "@formitiva/vanilla";

registerPlugin({
  name: "my-plugin",
  version: "1.0.0",
  components: { "my-field": myWidget },
  fieldTypeValidators: { "my-field": myValidator },
});

Themes

Import a built-in theme CSS file from @formitiva/core:

import "@formitiva/core/themes/material-dark.css";

Or customize via CSS variables:

:root {
  --formitiva-color-primary: #3b82f6;
  --formitiva-color-error: #ef4444;
  --formitiva-border-radius: 8px;
}

Links

License

MIT