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

@kendallroth/vue-simple-forms

v0.3.2

Published

Simple Vue form state management library

Readme

Vue Forms

Simple Vue form state management library (no validation, etc).

npm install @kendallroth/vue-simple-forms --save

Features

  • Create reactive Vue data for forms
  • Track basic form fields
  • Help prevent leaving a route with unsaved changes

createForm

NOTE: The previous FormCreateMixin has been removed as it did not support TypeScript!

Usage

The createForm function handles creating the reactive data and flags from the field keys and initial values. The form name/key and fields (with intial values) can be specified when adding the data to the component.

import { createForm } from "@kendallroth/vue-simple-forms";

const fields = { email: "", password: "" };

const vm = new Vue({
  data() {
    testForm: createForm(fields, { calculateChanged: false }),
  },
});

// Indicate loading
vm.data.testForm.setLoading(true);
// Indicate submitting
vm.data.testForm.setSubmitting(true);

Alternatively, TypeScript users will benefit from vue-property-decorator integration:

import { createForm } from "@kendallroth/vue-simple-forms";
import { Component, Vue } from "vue-property-decorator";

@Component
export default class Form extends Vue {
  testForm = createForm({ ... });

  mounted() {
    this.testForm.setValues({ ... });
  }
}

API

Config

createForm accepts several arguments to configure the form.

| Property | Type | Default | Description | | -------------------------- | --------- | ------- | ------------------------------------------------------ | | fields | Object | | Form fields and initial values | | options | Object | | Form configuration options | | options.calculateChanged | boolean | true | Whether changed flag is calculated (performance) | | options.flags | Object | {} | Custom flags and initial values (set with setFlag()) |

Mixin Data

The form object (name specified by mixin options) provides a simple API, particularly the field values and form flags. There are several additional utility methods to control the flags.

| Property | Description | | --------------------------------------- | ------------------------------------------------------ | | _initial | Initial field values | | flags | Form state flags | | fields | Form field values | | getValues() | Get form values | | setFlag(flag, value) | Set a form flag (only use for custom flags!) | | setInitial(values) | Set the initial form values | | setLoading(isLoading) | Set the loading flag | | setSubmitting(isSubmitting) | Set the submitting flag | | setValues(values, setInitial = false) | Set the form values (update initial values by default) | | reset() | Reset the form to initial values |

NOTE: Included form flags are handled internally and should not be modified with setFlags() method!

Form Flags

The form flags are computed from the form state and should not be modified directly; instead, use their corresponding utility methods.

| Property | Description | Method | | ------------ | ----------------------------------------------------------------- | ----------------- | | changed | Whether form has changed (comparison of values to initial values) | | | disabled | Whether form is disabled (either submitting or loading) | | | loading | Whether form is loading | setLoading() | | submitting | Whether form is submitting | setSubmitting() |

[DEPRECATED] FormCreateMixin

NOTE: This has been deprecated in favour of the fully typed createForm.

FormGuardMixin

Usage

The FormGuardMixin provides helpers to prevent leaving a form (managed by createForm) with unsaved data. These helpers can be utilized by the component to allow the user to handle the route change or cancellation based on the provided properties. The mixin checks the changed flag of a form (or forms) created by the createForm.

import { createForm, FormGuardMixin } from "@kendallroth/vue-simple-forms";

const vm = new Vue({
  data() {
    sampleForm: createForm(...),
    formGuards: [this.sampleForm],
  },
  mixins: [FormLeaveGuardMixin],
  template: `
    <template>
      <ConfirmDialog
        v-if="isFormGuardActive"
        text="Are you sure? There are unsaved changes!"
        @confirm="onFormLeave(true)"
        @cancel="onFormLeave(false)"
      />
    </template>
  `,
});

Alternatively, TypeScript users will benefit from vue-property-decorator integration:

import { createForm, FormGuardMixin } from "@kendallroth/vue-simple-forms";
import { Component, Mixins } from "vue-property-decorator";

@Component({
  template: `
    <template>
      <ConfirmDialog
        v-if="isFormGuardActive"
        text="Are you sure? There are unsaved changes!"
        @confirm="onFormLeave(true)"
        @cancel="onFormLeave(false)"
      />
    </template>
  `,
})
export default class Form extends Mixins(FormGuardMixin) {
  testForm = createForm({ ... });
  formGards = [this.testForm]

  mounted() {
    this.testForm.setValues({ ... });
  }
}

API

Config

FormGuardMixin accepts a configuration data variable.

| Property | Type | Description | | ------------ | -------- | ------------------------------------ | | formGuards | Form[] | Form objects created by createForm |

Mixin Data

The FormGuardMixin provides a computed property to control a confirmation dialog (or other form) and a callback to handle leaving or remaining at the form.

| Property | Description | | -------------------------- | -------------------------------------------------- | | isFormGuardActive | Whether the leave route protection is active/shown | | onFormLeave(shouldLeave) | Confirmation callback (from dialog, etc) |

[DEPRECATED] FormLeaveGuardMixin

NOTE: This has been deprecated in favour of the fully typed FormGuardMixin.

Development

Plugin development can be aided by installing this package locally (through file path) in another project.

cd project-with-dependency

# Relative path depends on location from "depending" project
npm install ../vue-simple-forms

This project can be started and will automatically rebuild on file changes:

npm run build:dev

See this link for information on using TypeScript with Babel. In summary, TypeScript is used for type checking but Babel is used for transpilation!

NOTE: Coverage tests are currently broken after the switch to TypeScript, and some had to be disabled!

Miscellaneous

Project boilerplate from: flexdinesh/npm-module-boilerplate