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

vue-selectify

v0.0.2

Published

To globally register vue-selectify just import register.js.

Downloads

7

Readme

Vue Selectify

Vue component for HTML select

To globally register vue-selectify just import register.js.

import "register.js"

Or to register locally

import VueSelectify from "./vue-selectify.vue"

new Vue({
    // Other options
    components: {
        // <vue-selectify> will only be available in parent's template
        'vue-selectify': VueSelectify
      }
});

##Properties You can use the following properties to customise vue-selectify

1. label

label must be present denoting the label of the vue-selectify.

<vue-selectify label="Year"></vue-selectify>

This will generate

<div class="">
    <label class="" for="year">Year</label> 
    <div class="">
        <select class="" id="year" name="year"></select>
    </div>
</div>

2. list

This is the list of options; a mandatory field.

<vue-select label="Year" :list="list"></vue-select>
new Vue({
    // Other options
    data: {
        list: [
            {
                id: 1,
                year: 'a'
            },
            {
                id: 2,
                year: 'b'
            },
            {
                id: 3,
                year: 'c'
            }
        ]
      }
});

This will render

<div class="">
    <label for="year" class="">Year</label> 
    <div class="">
        <select id="year" name="year" class="">
            <option value="1">a</option>
            <option value="2">b</option>
            <option value="3">c</option>
        </select>
    </div>
</div>

By default, of each item of list, id property will be used for value of option and snake_case of label will be used as text of option.

3. list-id

list-id is the value property of each of option in select element. if not specified, id will be used as default value.

<vue-select label="Year" :list="list" list-id="index"></vue-select>
new Vue({
    // Other options
    data: {
        list: [
            {
                index: 1,
                year: 'a'
            },
            {
                index: 2,
                year: 'b'
            },
            {
                index: 3,
                year: 'c'
            }
        ],
        model: 2,
    }
})

This will be rendered as

<div class="">
    <label for="year" class="">Year</label> 
    <div class="">
        <select id="year" name="year" class="">
            <option value="1">a</option>
            <option value="2">b</option>
            <option value="3">c</option>
        </select>
    </div>
</div>

Default value of list-id is 'id'.

4. list-item

list-item is the inner text of each of option in select element. if not specified, snake_case of label will be used as default value.

<vue-select label="Year" :list="list" list-id="index" list-item="value"></vue-select>
new Vue({
    // Other options
    data: {
        list: [
            {
                index: 1,
                value: 'a'
            },
            {
                index: 2,
                value: 'b'
            },
            {
                index: 3,
                value: 'c'
            }
        ],
        model: 2,
    }
})

This will be rendered as

<div class="">
    <label for="year" class="">Year</label> 
    <div class="">
        <select id="year" name="year" class="">
            <option value="1">a</option>
            <option value="2">b</option>
            <option value="3">c</option>
        </select>
    </div>
</div>

5. name

name is a optional property denoting the name of the select element.

<vue-selectify label="Year" name="year"></vue-selectify>

This will generate

<div class="">
    <label class="" for="year">Year</label>
    <div class="">
        <select class="" id="year" name="year"></select>
    </div>
</div>

If absent, name will be the kebab-case version of label as you see in preceding example.

6. id

id is a optional property denoting the id of the select element.

<vue-select label="Year" id="year-id"></vue-select>

This will generate

<div class="">
    <label for="year-id" class="">Year</label> 
    <div class="">
        <select id="year-id" name="year" class=""></select>
    </div>
</div>

If absent, id will be same as the name.

7. multiple

As you guess, this denote if the select can have multiple selected options or not.

8. css

Currently only 'bootstrap' is supported value of css property. If set, vue-selectify will use Bootstrap like styling.

<vue-select label="Year" css="bootstrap"></vue-select>

This will be rendered as

<div class="form-group">
    <label for="year" class="control-label col-sm-4">Year</label> 
    <div class="col-sm-8">
        <select id="year" name="year" class="form-control"></select>
    </div>
</div>

You should wrap vue-selectify with <div class="form-horizontal"></div> while using bootstrap style.

v-model

Requires version >= 2.2.0

If you're using version >2.2.0, then you can use v-model. Just as following

<vue-select label="Year" :list="[]" v-model="year"></vue-select>

selected-value property and change event

If you're using version below 2.2.0, then you need to use selected-value property to initially set the selected value. Later, if the selected value changes, a change event will be emitted. The only parameter is the new value.

<vue-select label="Year" :list="[]" 
    selected-value="2" @change="(val) => {selectedYear = val}"></vue-select>

You can also set any event handler method to @change event.