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 🙏

© 2024 – Pkg Stats / Ryan Hefner

form-generator-vue

v2.0.1

Published

Create beautiful forms using any component library for vue. ## Features * reactive schema based form. * compatible with third party component libraries like vuetify, element etc and custom components. * customizable form layout. ## [Demo](https://divijbha

Downloads

82

Readme

Create beautiful forms using any component library for vue.

Features

  • reactive schema based form.
  • compatible with third party component libraries like vuetify, element etc and custom components.
  • customizable form layout.

Demo

Installation

npm install form-generator-vue

How to use

<template>
    <form-generator-vue 
        v-model="fields"
        :components="formComponents"
        :schema="schema"
        :on-submit="handleSubmit"
    >
        <template v-slot:footer>
            <button type="submit">submit</button>
        </template>
    </form-generator-vue>
</template>

<script>
import FormGeneratorVue from 'form-generator-vue';
export default {
    data() {
        return {
            fields: {}
        }
    },
    components: {
        FormGeneratorVue
    },
    computed: {
        formComponents: () => [
            {   
                name: 'v-text-field', //should be a globally registered component.
                type: ['text', 'password', 'email', 'number'],
                errorProp: 'errorMessages'
            },
            {   
                name: 'v-radio-group',
                type: ['radio']
            }
        ],
        schema() {
          return {
            fields: [
              {
                model: 'email',
                type: 'email'
              },
              {
                model: 'mobile',
                type: 'number'
              },
              {
                model: 'password',
                type: 'password'
              }
            ]
          }
        }
    },
    methods: {
        async handleSubmit() {
            // await network call ---------;
            console.log('form submitted', this.fields)
        }
    }
}
</script>

Props

|props|type|description| |----|---|----| | schema | obj | json schema to create form | | components | obj | component map to render component for specific type of field | | onSubmit | async/sync function | submit success function | | onSubmitFail | async/sync function | submit fail function.| | disabled | Bool | toggle disable all fields | | activeValidation | bool | toggle validation on input for all fields. Default is false | | activeValidationDelay | Number | debounced validation for all fields| | logs | bool | toggle validation and submit logs | | classes | obj | To add classes to all the rows and columns inside form body |

field schema Options

| options | type | default | purpose | | ------ | ------ | ------ | ----- | | model | String | | v-model with component.| | type | String | 'text' | Input type. Component for it is loaded from components. | | props| obj | {} | Component props | | hide | bool/() => bool | false | show/hide field. Not required when hidden | | v-on | obj | {} | Assigned to component v-on. | |validator | () => //return error data | | function returning error data(string, array etc) on validation fail. | | component | String | | for using any component | | errorProp | String | 'errorMessages' | name of error prop consumed by component to show error | | activeValidation | Boolean | false | toggle validation on input | | activeValidationDelay | Number | 0 | debounced validation |

Layout

Row is a div containing column div containing the component. A row can have multiple cols. Nested rows are not supported.

fields: [   // 1 row 1 column -------
            {
                model: 'name',
                type: 'text'
            },
            // 1 row 1 column -------
            {
                model: 'email',
                type: 'email'
            },
            
            // 1 row 2 columns -------   
            [
                {
                    model: 'mobile',
                    type: 'number'
                },
                {
                    model: 'password',
                    type: 'password'
                }  
            ]
        ]

Slots

  • header
  • before-row
  • after-row`
  • before-col
  • after-col
  • <model> (for using the component slot)
  • before-<model>
  • after-<model>
  • footer

slot prop model is passed to all slots except for slots header and footer.

classes used

  • form - "fgv-form"
    • header - "fgv-form__header"
    • body - "fgv-form__body"
      • row - "fgv-form__body__row"
        • col - "fgv-form__body__row__col <model>"
    • footer - "fgv-form__footer"

Contributors

This project exists thanks to all the people who contribute. Contribute.

Changelog