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

@saplings/forms

v0.3.0

Published

Reusable Saplings forms toolkit

Readme

@saplings/forms

Controlled schema-driven string fields with application-owned validation.

Install

npm install @saplings/forms react

Quick start

import { SchemaForm, validateForm } from '@saplings/forms';

const values = { email: '' };
const errors = validateForm(values, { email: (v) => v.includes('@') ? undefined : 'Enter an email' });
const view = <SchemaForm fields={[{ name: 'email', label: 'Email', type: 'email' }]}
  values={values} errors={errors} onChange={(name, value) => console.log(name, value)}
  onSubmit={(event) => event.preventDefault()}><button>Save</button></SchemaForm>;

API and operational notes

Fields are controlled; supply state, synchronous validation and submission handling. Errors are associated with fields for assistive technology. Server-side validation remains required. The controller below supports nested updates and submission state.

Validation

Run the workspace build and pnpm test after making changes. Confirm application-specific behavior and accessibility in the consuming environment.

Schema validation and steps

import { z } from '@saplings/validations';
import { validateSchema, moveStep } from '@saplings/forms';

const schema = z.object({ email: z.string().email() });
const result = await validateSchema(schema, { email: '' });
if (!result.success) console.log(result.errors.email, result.formErrors);
const nextStep = moveStep(0, 3, 1);

The adapter uses safeParseAsync, including asynchronous refinements, and maps the first issue for each top-level field. Form-wide errors are returned separately. The application decides when to validate and submit each step; the server must repeat authorization and validation.

groupIssues(issues) retains nested schema paths and array indexes as JSON-encoded path arrays, and returns form-wide errors separately. This avoids conflating literal dots in field names with nested paths.

Submission controller

createFormController(initial, schema, submit) validates using an async Saplings-compatible schema, publishes validation issues and submission state, and prevents duplicate submissions. While a submission is pending, edits and reset are rejected; callers must handle server errors and server-side validation.

Nested forms and validated steps

const wizard = createFormWizard({ profile: { name: '' } }, [
  { id: 'profile', validate: v => v.profile.name.trim() ? [] :
    [{ path: ['profile', 'name'], message: 'Enter your name' }] },
  { id: 'review', validate: () => [] },
], schema, save);

<WizardForm wizard={wizard}>{state => state.stepId === 'profile'
  ? <label>Name<input value={state.values.profile.name}
      onChange={e => wizard.setField(['profile', 'name'], e.target.value)} /></label>
  : <p>{state.values.profile.name}</p>}</WizardForm>

Import both functions from @saplings/forms. Create the wizard once per form instance. Use numeric segments to update existing array entries. Steps can validate asynchronously; editing a field invalidates an older step check. Final submission validates the complete schema and passes the parsed data to save.