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

@weave-framework/forms

v3.5.0

Published

Weave forms — signal-native field/form state + validation over bind:value. Zero third-party deps.

Readme

@weave-framework/forms

Weave forms — signal-native field/form state + validation, wired to inputs with use:control. Zero third-party deps.

Part of Weave — a fine-grained reactive, signal-native UI framework: no Virtual DOM, zero third-party runtime dependencies.

npm install @weave-framework/forms

Most apps get this (and the rest of Weave) in one step:

npm create weave@latest my-app

Usage

A field is a value signal plus reactive validity, touched, and dirty state. A form (an alias of group) aggregates named controls and owns the submit dance.

import { field, form, validators } from '@weave-framework/forms';

const login = form({
  email: field('', [validators.required(), validators.email()]),
  password: field('', [validators.required(), validators.minLength(8)]),
});

const onSubmit = login.submit(async (values) => {
  await api.post('/login', values); // values is { email, password }, typed
});

Bind it in the template with one directive. use:control binds the value, flips touched on blur, and sets aria-invalid — which is what submit uses to focus the first bad control:

<form on:submit={{ onSubmit }}>
  <input type="email" use:control={{ login.controls.email }} />
  @if (login.controls.email.touched() && login.controls.email.error()) {
    <p class="error">{{ login.controls.email.error() }}</p>
  }
  <button type="submit" disabled={{ login.submitting() }}>Sign in</button>
</form>

control comes from the DOM subpath:

import { control } from '@weave-framework/forms/dom';

What submit does for you

form.submit(handler) returns an event handler that runs the whole sequence: preventDefault → touchAll() to reveal every error → await any in-flight async validation → if invalid, focus the first control marked aria-invalid and stop → else run handler(values) while tracking submitting() and submitError().

Composition

field, group, and fieldArray all satisfy one Control interface, so they nest to any depth (form → group → fieldArray → group → field). Validity, the value snapshot, touched, dirty, reset, and touchAll recurse through the whole tree.

import { field, fieldArray, validators } from '@weave-framework/forms';

const emails = fieldArray((seed = '') => field(seed, [validators.email()]), ['[email protected]']);
emails.push();        // append a control
emails.removeAt(0);
emails.controls();    // reactive list — render with @for

Validation

Built-in validators: required, minLength, maxLength, pattern, email, min, max — each takes an optional message, and the first failure wins. A validator is just (value) => string | null, so your own drop in beside them.

Async validation is per-field, debounced (300 ms by default) and abortable, and only fires once the sync layer is clean:

const username = field('', [validators.required()], {
  asyncValidate: async (value, { signal }) => {
    const taken = await api.get(`/check?u=${value}`, { signal });
    return taken ? 'Already taken' : null;
  },
  debounceMs: 400,
});

Cross-field validation lives on the group. Keys target its direct field children; the reserved _form key (FORM_ERROR_KEY) surfaces via group.formError():

const signup = form(
  { password: field(''), confirm: field('') },
  { validate: (v) => (v.password === v.confirm ? {} : { confirm: 'Passwords must match' }) }
);

📚 Guides + full API reference: Forms guide · API reference

License

MIT