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

@flapili/vue-form

v1.0.0

Published

A Vue 3 form library that integrates Zod for powerful form validation.

Downloads

1

Readme

@flapili/vue-form

A Vue 3 form library that integrates Zod for powerful form validation.

Features

  • 🔒 Type-safe form handling with Zod schemas
  • 🎯 Simple API with composable functions
  • ⚡ Reactive form state management
  • 🎨 Flexible error handling and display
  • 🔄 Form reset and submission controls
  • 📝 Comprehensive TypeScript support

Installation

npm install @flapili/vue-form zod # npm
pnpm add @flapili/vue-form zod # pnpm
yarn add @flapili/vue-form zod # yarn

Usage

Here's a basic example of how to use the form library:

<script setup lang="ts">
import { useFormComponent } from '@flapili/vue-form'
import { z } from 'zod'

const schema = z.object({
  name: z.string().min(1, 'Name is required'),
  email: z.string().email('Email is invalid'),
}).transform((data) => {
  return {
    ...data,
    NAME_UPPER: data.name.toUpperCase(),
  }
})

const input = reactive({
  email: '',
  name: '',
})

async function onSubmitCallback(res: z.infer<typeof schema>) {
  console.log(res) // will log { NAME_UPPER: '...', email: '...', name: '...' }
  return 'submitted to backend'
}

const FormComponent = useFormComponent(schema, input, onSubmitCallback)
</script>

<template>
  <div class="size-full flex flex-col items-center justify-center">
    <h1>Test form</h1>
    {{ input }}
    <FormComponent v-slot="{ data, submit, parseResult, displayErrors, toggleDisplayErrors, reset, status }">
      <input v-model="data.name" class="border border-gray-300 rounded-md p-2" :class="{ 'border-red-500': displayErrors }">
      <input v-model="data.email" class="border border-gray-300 rounded-md p-2" :class="{ 'border-red-500': displayErrors }">
      <button
        type="button"
        class="rounded-md bg-blue-500 p-2 text-white disabled:opacity-50"
        :disabled="status !== 'valid'"
        @click="submit().then(res => console.warn(`return of onSubmitCallback = ${res}`))"
      >
        Submit
      </button>
      <pre>{{ parseResult?.error?.issues ?? [] }}</pre>
      <div class="flex flex-col gap-2 children:(rounded-md bg-gray-200 p-2)">
        <button type="button" @click="toggleDisplayErrors">
          Toggle errors showing
        </button>
        <button type="button" @click="reset">
          Reset
        </button>
      </div>
    </FormComponent>
  </div>
</template>

API Reference

useFormComponent Parameters

| Parameter | Description | |--------------------------------------|-----------------------------------------------------------------| | schema | The Zod schema for form validation | | input | The reactive form data | | onSubmit | Callback function called with validated data on form submission | | options | Optional configuration object | | options.displayErrors | Optional ref to control error display | | options.mutateDisplayErrorsOnError | Whether to show errors automatically on validation failure |

The options parameter is optional and can be omitted.

Form Context

The form provides a context with the following properties:

| Property | Description | |-----------------------|--------------------------------------------------------| | data | The reactive form data | | parseResult | Current validation result | | displayErrors | Whether validation errors should be displayed | | changedAt | Timestamp of last form change | | hasChanged | Whether the form has been modified | | status | Current form validation status (parsing/valid/invalid) | | submit | Submit the form | | getErrors | Get validation errors for a specific field path | | reset | Reset the form to initial values | | toggleDisplayErrors | Toggle error display |

Form Component Slot Props

The Form component provides all the context properties listed above to its default slot. These can be destructured in the template to access form state and methods:

As an example, the following code renders the form data:

<FormComponent v-slot="{ data }">
  <pre>{{ data }}</pre>
</FormComponent>

License

MIT License © 2024 Benoît Deveaux

Todo:

  • [ ] Add a contributing guide
  • [ ] setup CI/CD
  • [ ] setup tests