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

ionic-vue-form

v1.2.2

Published

Dynamic form render

Downloads

50

Readme

Ionic Vue Form

Render fully customizable dynamic form with form-field conditional logic.

Install

npm install ionic-vue-form

// Register globally (optional)
import { IonicVueForm } from "ionic-vue-form"

Vue.component("IonicVueForm",IonicVueForm)


// Register locally (optional)
<script>
  import { IonicVueForm } from 'ionic-vue-form'

  export default {
    components: {
      IonicVueForm
    }
  }
<script>

Basic usage

<template>
  <div>
    <IonicVueForm :formFields="form" btnText="Submit" @submit="submit" />
  </div>
</template>

<script>
  import { IonicVueForm } from 'ionic-vue-form'

  export default {
    components: {
      IonicVueForm
    },
    data () {
      return {
        form: [
          {
            key: "email",
            label: "Email"
          },
          {
            key: "password",
            label: "Password
          }
        ]
      }
    },
    methods: {
      submit(data) {
        // Submit logic
        // data - Form input(s)
      }
    }
  }
</script>

Note

In your project's main.js import and use vee-validate

import VeeValidate from 'vee-validate'

Vue.use(VeeValidate)

Auto-fill example

data prop takes the data object, binds each key-value pair to the relavent form field

<template>
  <div>
    <IonicVueForm :formFields="form" :data="formData" btnText="Submit" @submit="submit" />
  </div>
</template>

<script>
  import { IonicVueForm } from 'ionic-vue-form'

  export default {
    components: { IonicVueForm },
    data () {
      return {
        form: [
          {
            key: "first_name",
            label: "First name"
          },
          {
            key: "last_name",
            label: "Last name
          }
        ],
        formData: {
          first_name: "John",
          last_name: "Doe"
        }
      }
    },
    methods: {
      submit(data) {
        // Submit logic
        // data - Form input(s)
      }
    }
  }
</script>

Props

|Name|Type|Required|Default|Description |---|---|---|---|---| |formFields|Array|true|-|List of fields to render| |data|Object|false|-|Form datta (if you need to auto-fill the form)| |btnText|String|false|Continue|Submit button text| |wrapperClass|String|false|-|Form wrapper class|

Events

|Event|Description|Parameters| |---|---|---| |submit|Submit form|-| |fileUpload|Useful when you want to handle file processing separately |-|

Field Properties

  • key required | String Must be unique, the key will be used in formData.
  • type optional | String Input type, defaults to text.
  • label optional | String Input field's label
  • validation optional | String Field validation rules, Ionic vue form uses VeeValidate
  • class optional | String Input CSS class
  • rows optional | Integer rows attribute for textarea input
  • rows optional | Integer cols attribute for textarea input
  • options required | Array List of option values for select dropdown
  • condition optional | Object Show number field if email value is [email protected]
{
  key: "email",
  label: "Email",
},
{
  key: "number",
  type: "number",
  label: "Number",
  condition: {
    key: "email",
    value: "[email protected]"
  }
}
  • component is required if type is component. If the component requires props you can use props property which takes an object

This is useful when you want to use a 3rd party component in your form. In the example below, I want to use vue-multiselect in my form.

<script>
import multiselect from "vue-multiselect";

export default {
  data() {
    form: [
      {
        key: "category",
        label: "Select Category",
        type: "component",
        component: multiselect,
        props: {
          options: [],
          multiple: true,
          closeOnSelect: false,
          clearOnSelect: false,
          hideSelected: true,
          preserveSearch: true,
          trackBy: "category_label",
          label: "category_label"
        }
      }
    ]
  }
}

Demo

Sandbox Demo

Ionic Vue Form Screenshot