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

@pbartkowicz/vueselect

v1.2.1

Published

Simple select vue component, that allows you to control selected options from array

Downloads

46

Readme

Table of contents

General

Simple select vue component, that allows you to control selected options from array

component is created with:

  • Vue 2.6.10

Setup

install module locally with npm or yarn

npm i @pbartkowicz/vueselect

or

yarn add @pbartkowicz/vueselect

Usage

Import

import vueselect from '@pbartkowicz/vueselect'

Register in components section

components:{
    vueselect,
},

Define array with select options

data(){

    return{

        yourArrayWithOptions:[
            'option1',
            'option2',
            'option3'
        ],

        output: '',

    }

}

Use component in your code

<vueselect :options="yourArrayWithOptions" v-model="output"/>

You can always define array with objects

data(){

    return{

        yourArrayWithOptions:[
            {id: 1, name: 'option1'},
            {id: 2, name: 'option2'},
            {id: 3, name: 'option3'}
        ],

        output: '',

    }

}

And then use label prop for displayed value in select, and reduce prop for key in object for select output

<vueselect :options="yourArrayWithOptions" label="name" reduce="id" v-model="output"/>

For option named 'option2' output will be '2'

Object options

When you will define array with objects, you can pass in to objects two options:

| Option | Type | Default | Required | Description | | ----------- | ------ | ------- | -------- | ------------------------------------------------------------------------------------------- | | class | String | | No | Name of class for option. | | hide | Boolean| | No | Option to hide item. |

data(){

    return{

        yourArrayWithOptions:[
            {id: 1, name: 'option1', class: 'your-class-for-option'},
            {id: 2, name: 'option2', hide: true},
            {id: 3, name: 'option3'}
        ],

        output: '',

    }

}

In this case 'option1' will have class "your-class-for-option" and 'option2' will not be displayed

Props

| Prop | Type | Default | Required | Description | | ------------ | ------ | ------- | -------- | -------------------------------------------------------------------------------------------------------------------------------- | | options | Array | | No | Array with select options. | | label | String | | No | Displayed value in select for array with objects. | | reduce | String | | No | Select key in object for vueselect component output. | | searchable | Boolean| false | No | Enable search in options | | clearable | Boolean| false | No | Enable clear possibility | | multiselect | Boolean| false | No | Enable multiselect - output changes to array | | customClasses| Object | | No | Allows to add custom classes to elements. Use as keys in object: selected, search, clearIcon, dropdownIcon, dropdown, checkbox |

Slots

| Slot | Description | | ----------------- | ------------------------------------------------------------------------------------------- | | noOptions | Default value "no options". | | icon | Slot for icon. | | clear-icon | Slot for clear icon. |

Example:

<vueselect :options="yourArrayWithOptions" label="name" reduce="id" v-model="output">
    <template v-slot:noOptions>
        No avaible options
    </template>
<vueselect/>

Patch notes

1.2.1

  • Changed keywords for npm

1.2.0

  • Added multiselect
  • Added clear button
  • Added custom classes for elements
  • Added slot for clear icon

1.1.0

  • Added search possibility
  • Dynamic position of dropdown depending on the avaible space
  • Dynamic tooltip
  • Added slot for icon