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

@288-toolkit/forms

v4.4.1

Published

A collection of functions and builders to build forms.

Downloads

404

Readme

Forms

A collection of functions and builders to build forms.

The builders are based on Melt-ui's APIs.

createPostForm

Creates a form to post data to an endpoint.

Usage

<script lang="ts">
	import { createPostForm } from '@288-toolkit/forms';
	import { melt } from '@melt-ui/svelte';

	const {
		elements: { form, honeypot },
		states: { state },
		helpers: { submit, values, errors, data }
	} = createPostForm({ resetDelay: 15000, novalidate: true });
</script>

<form use:melt={$form}>
	<input use:melt={$honeypot} />
</form>

Options

type CreatePostFormOptions = {
	/**
	 * The delay in milliseconds before the form is reset
	 * after a successful submission.
	 */
	resetDelay?: Maybe<number>;
	/**
	 * The key of the form in the page store. Must be used if there are
	 * multiple forms on the page.
	 */
	formKey?: Maybe<string>;
	/**
	 * Applies the novalidate attribute to the form element, which disables browser validation, only when
	 * javascript is enabled.
	 */
	novalidate?: boolean;
};

Elements

  • form: The form element.
  • honeypot: A honeypot input.

States

  • state ('idle' | 'submitting' | 'success' | 'error'): The current state of the form.

Helpers

  • submit (() => void): A function to programmatically submit the form.
  • values (Readable<Record<string, string>>): A readable store of the form values returned from the server. The keys are the input names.
  • errors (Readable<Record<string, string>>): A readable store of the form errors returned from the server. The keys are the input names.
  • data (Readable<Record<string, string>>): The whole data object returned from the server.

createValidatedField

Creates a validated input and error hint.

Usage

<script lang="ts">
	import { ValidatedField } from '@288-toolkit/forms';
	import { melt } from '@melt-ui/svelte';
	import classNames from 'classnames';
	import { elasticOut } from 'svelte/easing';
	import { fade, fly } from 'svelte/transition';

	const {
		elements: { input, hint },
		helpers: { value, error }
	} = createValidatedField();

	$: console.log($value);
</script>

<div class="flex w-full flex-col items-start gap-8 pt-24">
	<label class="flex w-full flex-col items-start gap-12">
		<span class="text-16 leading-100">My input</span>
		<input use:melt={$input} />
	</label>
	{#if $error}
		<div
			use:melt={$hint}
			in:fly={{ duration: 500, easing: elasticOut, x: 50 }}
			out:fade={{ duration: 200 }}
			class="text-14 leading-100 text-left text-[red]"
		>
			{$error}
		</div>
	{/if}
</div>

Options

export type FieldOptions = {
	/**
	 * The type of the input element. DEFAULT: 'text'
	 */
	type?: string;
	/**
	 * The name of the field. This is used to access the value and error of the field.
	 */
	name: string;
	/**
	 * A readable store containing the errors of the form.
	 */
	errors: Readable<FormErrors>;
	/**
	 * A readable store containing the values of the form.
	 */
	values: Readable<FormValues>;
	/**
	 * If true, the field will be focused when an error is set. DEFAULT: true
	 */
	focusOnError?: boolean;
};

Elements

  • input: The input element.
  • hint: The associated error message.

Helpers

  • value (Readable<Maybe<string>>): The input value returned from the server.
  • error (Readable<Maybe<string>>): The input error returned from the server.

createHoneypot

Creates a honeypot input which can be validated on the server with validateHoneypot.

Usage

<script lang="ts">
	import { createHoneypot } from '@288-toolkit/forms';
	import { melt } from '@melt-ui/svelte';

	const {
		elements: { honeypot }
	} = createHoneypot();
</script>

<input use:melt={$honeypot} />

createNewsletterForm

Creates an accessible newsletter form which can be validated on the server with validateNewsletter. Uses createPostForm.

Usage

<script lang="ts">
	import { createNewsletterForm } from '@288-toolkit/forms';
	import { melt } from '@melt-ui/svelte';

	const {
		elements: { form, honeypot, emailInput, emailHint, announcer },
		states: { state },
		helpers: { submit, values, errors, data, emailError, emailValue }
	} = createNewsletterForm({ resetDelay: 15000, novalidate: true });
</script>

<form use:melt={$form}>
	<label>
		<input use:melt={$emailInput} />
	</label>
	{#if $emailError}
		<p use:melt={$emailHint}>{$emailError}</p>
	{/if}
	<input use:melt={$honeypot} />
	<div use:melt={$announcer}></div>
</form>

Options

Same as createPostForm.

Elements

Same as createPostForm, plus:

  • emailInput: The email input.
  • emailHint: The associated email error message.
  • announcer: A screen-reader announcer for the state of the form.

States

Same as createPostForm.

Helpers

Same as createPostForm, plus:

  • emailValue (Readable<Maybe<string>>): The email value returned from the server.
  • emailError (Readable<Maybe<string>>): The email error returned from the server.

requestSubmit

A function to trigger a submit event (along with validation) on a form.

use:enhancePost

Wraps Sveltekit's enhance action to cancel in-flight request (by using the current AbortController) if the form is re-submitted to quickly.