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

vue2-input

v0.0.14

Published

Vue2Input: Vue2 component

Downloads

39

Readme

Vue2Input

Vue2Input Component for Vue 2.x

Install

    npm install vue2-input --save

Demo

For demo, please see this fiddle

Usage

1. Import the component

import Vue2Input from 'vue2-input';
import {Vue2InputGroup} from 'vue2-input';

2.1 Use it globally

Vue.use(Vue2Input);

2.2 Or use it locally

components: {
    'vue2-input': Vue2Input,
    'vue2-input-group': Vue2InputGroup,
},

3. Update your app or template:

<div>
...
<vue2-input></vue2-input>
...
</div>

Properties / Methods

Vue2Input

  • Properties

    • type: text, email, url, textarea, select, checkbox, radio, ...

    • label: field caption

    • name: optional (for validation)

    • placeholder

    • required

    • horizontal: col-sm-2 col-md-3, etc for horiz layout

    • help: help text underneath

    • min: min length

    • max: max length

    • scope: scope for vee-validate (if two fields have same name)

    • rows: textarea

    • options: checkbox, select, radio (options => [{label: label, value: value}, ..] or ['val', 'val'..]

    • inline: true (place checkbox, radios horizontally)

    • fixed: fixed checkbox fields (array)

    • readonly

    • labelClass, inputClass, controlClass:

    • size: sm, lg (for form-control-sm)

    • yes-no: radio, select ['enabled', 'disabled'] => options => [{label: 'enabled', value: true}, {label: 'disabled', value: false}]

    • default: sets defaults value of model

    • prepend: prepends text in front of text, textarea

    • append: appends text in after of text, textarea

    • disabled

  • Methods:

    • validate: returns promise

Vue2InputGroup:

  • Properties

    • disabled: Disables entire group of fields by putting a white overlay on top
  • Methods:

    • validate: returns promise after validating all fields contained inside group

    • getAllChildren: returns array with all vue2-input fields (even nested)

Example

<template>
    <div>
        <form @submit.prevent="check('step1')" novalidate>
            <vue2-input type="textarea" rows="3" v-model="value.text" label="Your site name:" placeholder="My site" required min="3" help="(this is a test)" scope="step1"></vue2-input>
            <vue2-input type="email" v-model="value.email" label="Your email:" placeholder="My email" required help="(this is a test)" scope="step1"></vue2-input>
            <vue2-input type="password" v-model="value.password" label="Your password:" placeholder="Strict" required help="(this is a test)" scope="step1" :strict-password="true"></vue2-input>

            <vue2-input type="radio" required name="ok" v-model="value.radio" scope="step1"></vue2-input>
            <vue2-input type="checkbox" required :options="[{label: 'one', value: 1},{label: 'two', value: 2},]" v-model="value.checkbox" label="sure?" scope="step1"></vue2-input>
            <vue2-input type="checkbox" required :options="[{label: 'yes', value: true}]" v-model="value.agree" label="agree?" scope="step1"></vue2-input>
            <vue2-input type="select" required :options="[{label: 'one', value: 1},{label: 'two', value: 2},]" v-model="value.select" scope="step1"></vue2-input>


            <div class="card card-body">
                <p>Horizontal</p>

                <vue2-input type="text" horizontal="col-sm-3" v-model="value.text1" label="Your site name 2:" placeholder="My site" required min="3" help="(this is a test)" scope="step1"></vue2-input>
                <vue2-input type="radio" :inline="false" required="" horizontal="col-sm-3" v-model="value.radio1" label="Yes or no?" scope="step1" help="that is the question"></vue2-input>
            </div>

            <hr>

            <button class="btn btn-primary" :disabledd="errors.any('step1')">btn</button>

        </form>

        <pre>value: {{value}}</pre>
    </div>
</template>

<script>
    import Vue from 'vue';
    import VeeValidate from 'vee-validate';
    import Vue2Input from '../src/index';

    Vue.use(VeeValidate);

    import './validator';

    export default {
        name: 'app',
        data() {
            return {
                value: {}
            }
        },
        components: {
            Vue2Input
        },
        methods: {
            check() {
                this.$validator.validateAll('step1')
                    .then((obj) => console.log("result: ", obj))
                    .catch((err) => console.log("error: ", err));
            }
        },
    }
</script>

Contributing

Contributions are welcome

Build Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build