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

@beforeyoubid/form

v2.0.1

Published

BYB form system — TanStack Form field abstractions composed from @beforeyoubid/design-system primitives

Readme

@beforeyoubid/form

BYB's form system — TanStack Form field abstractions composed from @beforeyoubid/design-system primitives. The single source of truth for forms across the BYB platform.

What you get

Three layers:

  1. Standalone composed fields — InputField, SelectField, CheckboxField, … each bundles a design-system primitive with a label, hint, error and consistent spacing. Use them anywhere, with or without TanStack Form.
  2. createBybFormHook — a thin skin over TanStack's createFormHook that pre-populates fieldComponents/formComponents with the bound versions of those fields. You supply only the contexts and the functional form config.
  3. (Internal) the context-bound field components wired between the two.

Install

yarn add @beforeyoubid/form @beforeyoubid/design-system @tanstack/react-form

@beforeyoubid/design-system (2.x), @tanstack/react-form, react, react-dom and tailwindcss (v4) are peer dependencies.

Import this package's stylesheet once, after the design system's:

@import "@beforeyoubid/design-system/globals.css";
@import "@beforeyoubid/form/styles.css";

It holds no styles of its own: it registers this package's build with Tailwind (@source), because Tailwind v4 doesn't scan node_modules. Without it, classes that only these fields use are not generated.

Usage with TanStack Form

import { createFormHookContexts } from '@tanstack/react-form';
import { createBybFormHook } from '@beforeyoubid/form';

// Create the contexts once (the "functional portion" you own) and build the hook.
const { fieldContext, formContext } = createFormHookContexts();
export const { useAppForm, withForm } = createBybFormHook({ fieldContext, formContext });

function SignupForm() {
  const form = useAppForm({
    defaultValues: { email: '', agree: false },
    onSubmit: ({ value }) => console.log(value),
  });

  return (
    <form onSubmit={(e) => { e.preventDefault(); form.handleSubmit(); }}>
      <form.AppField
        name="email"
        validators={{ onChange: ({ value }) => (value.includes('@') ? undefined : 'Invalid email') }}
      >
        {(field) => <field.InputField label="Email" type="email" />}
      </form.AppField>

      <form.AppField name="agree">
        {(field) => <field.CheckboxField label="I agree to the terms" />}
      </form.AppField>

      <form.AppForm>
        <form.SubmitButton>Sign up</form.SubmitButton>
      </form.AppForm>
    </form>
  );
}

The bound fields read their value and errors from the active field and call handleChange/handleBlur for you. Errors surface into the field's error slot once the field is touched.

Typing

Everything is fully typed: form-data inference (field-name autocomplete, field.state.value, validators, form.state) and the bound components on form.AppField's render prop. field.InputField autocompletes, rejects unknown/mis-typed props, and flags missing required props (e.g. SelectField without options).

This is achieved by hand-writing the hook's return type (BybFormApiFor) from TanStack's exported generic types, rather than inferring it — TanStack's inferred createFormHook return includes a recursive extendForm member that overflows the TypeScript .d.ts serializer (TS7056). extendForm is therefore the one piece of the return surface not exposed here; if you need it, call TanStack's createFormHook directly.

Standalone usage (no TanStack Form)

import { InputField, SelectField, productSelectOptions } from '@beforeyoubid/form';

<InputField label="Email" value={email} onChange={(e) => setEmail(e.target.value)} error={error} />
<InputField label="Notes" multiline rows={4} />
<SelectField label="Country" value={country} onValueChange={setCountry} options={options} />
<SelectField multiple label="Products" options={productSelectOptions()} value={products} onValueChange={setProducts} />

SelectField takes category groups ({ label, options }), per-option start / meta / chip content, multiple (chips, maxDisplayed, the "N selected · CLEAR" footer) and, with clearable, an × that clears the selection. DateField is the design system's date picker as a field: DD/MM/YYYY, the lime selected day, and 24-hour time columns when you pass time.

FormFieldWrapper is exported too, for composing bespoke fields with the same label/hint/error chrome. It is built from the design system's Field, FieldLabel, FieldDescription and FieldError, so the field levers (--field-label-*, --field-error-*, …) restyle every field here.

Coming from the design system's InputField / SelectField

Design system 2.0 removed its InputField, SelectField, SelectFieldOption, SelectFieldOptionGroup and productSelectOptions. npx design-system-migrate rewrites those imports to @beforeyoubid/form; the names and props are the same. Add @beforeyoubid/form to the app and the styles.css import above. See the 2.0.0 entry in CHANGELOG.md for the details.

Fields

Text & numeric: InputField, NumberField, TextareaField, InputGroupField, PasswordField, SearchField, PhoneField, CurrencyField, ColorField, InputOTPField

Choice: SelectField, ComboboxField, MultiSelectField, RadioGroupField, RadioCardField, CheckboxField, CheckboxGroupField, SwitchField, ToggleField, ToggleGroupField

Other: SliderField, RatingField, DateField, TimeField, DateRangeField, FileUploadField

FileUploadField is the design system's FileUpload as a field. Without uploadOptions its value is File[]. With uploadOptions each file uploads to a presigned S3 URL as soon as it's picked, and the value is what the upload returned:

const presignAttachment: FileUploadPresignFn = async (file) => {
  const { data } = await prepareUpload({ variables: { fileName: file.name, mimeType: file.type } })
  return data!.prepareUpload.uploadUrl
}

const form = useAppForm({ defaultValues: { contract: null as string | null } })

<form.AppField name="contract">
  {(field) => <field.FileUploadField label="Contract" accept=".pdf" uploadOptions={{ presign: presignAttachment }} />}
</form.AppField>

The value is the file's URL (string | null; string[] with multiple), or whatever uploadOptions.onUploadFinished(file, url) returns. It only changes once an upload finishes, so a required check blocks submit while one is running. In development, the bound field warns when the form's default value isn't the shape it stores (e.g. [] for a single upload).

Plus FormFieldWrapper for composing bespoke fields with the same label/hint/error chrome. Every field works standalone and as a bound form.AppField component.

Working on the fields

Before writing or changing UI, read the design system's own docs, which match the installed version: node_modules/@beforeyoubid/design-system/docs/README.md.

Then follow CONVENTIONS.md: each field passes the props it doesn't handle through to the design system control it wraps, takes no style, and is styled with classes.

Scripts

| Command | What it does | |---|---| | npm run build | Production build — ESM + CJS + types via tsup | | npm run dev | Watch-mode build | | npm run type-check | TypeScript strict check | | npm run lint | ESLint across src/ | | npm test | Vitest binding tests | | npm run verify | type-check + lint + test (the pre-publish gate) | | npm run storybook | Storybook on port 6006 | | npm run release | Publish to npm (runs verify + build first) |

Publishing

@beforeyoubid/form is published under the public @beforeyoubid scope (npm auth required).

npm login                 # one-time, must be a @beforeyoubid maintainer
npm version patch         # or minor / major / 0.1.0-alpha.0
npm run release           # = npm publish --access public

prepublishOnly runs verify (type-check + lint + test) and a fresh build automatically, so a publish can never ship code that doesn't pass checks. For a pre-release, use npm run release -- --tag alpha to keep it off the latest tag.