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

vuejs-auto-complete

v0.9.0

Published

A Vue autocomplete component

Downloads

11,573

Readme

vuejs-auto-complete

Travis Build Version Coveralls github Downloads

A Vue autocomplete component

npm install vuejs-auto-complete --save

Usage

Installation, add autocomplete component into your app

import Vue from 'vue'
import Autocomplete from 'vuejs-auto-complete'

new Vue({
  //...
  components: {
    Autocomplete,
  },
  //...
})

Api data source

<autocomplete
  source="https://api.github.com/search/repositories?q="
  results-property="items"
  results-display="full_name">
</autocomplete>

Object data source

<autocomplete
  :source="[{id:1,name:'abc'},{id:2,name:'def'}]">
</autocomplete>

Full featured example

<autocomplete
  ref="autocomplete"
  placeholder="Search Distribution Groups"
  :source="distributionGroupsEndpoint"
  input-class="form-control"
  results-property="data"
  :results-display="formattedDisplay"
  :request-headers="authHeaders"
  @selected="addDistributionGroup">
</autocomplete>
// parent component
computed: {
  authHeaders () {
    return {
      'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni....'
    }
  },
},
methods: {
  distributionGroupsEndpoint (input) {
    return process.env.API + '/distribution/search?query=' + input
  },
  addDistributionGroup (group) {
    this.group = group
    // access the autocomplete component methods from the parent
    this.$refs.autocomplete.clear()
  },
  authHeaders () {
    return {
      'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1Ni....'
    }
  },
  formattedDisplay (result) {
    return result.name + ' [' + result.groupId + ']'
  }
}

Available props

| Prop | Type | Required | Default | Description | |-----------------------|-----------------------------|----------|-----------|-------------| | source | String|Function|Object|Array | | true | data source for the results| | method | String | | 'get' | http method for api requests| | placeholder | String | | 'Search' | input placeholder| | initialValue | String|Number | | | starting value| | initialDisplay | String | | | starting display value| | inputClass | String|Object | | | css class for the input div| | disableInput | Boolean | | | to disable the input| | name | String | | | name attribute for the value input| | resultsFormatter | Function<Object[]> | | | Function to format the server data. Should return an array of objects with id and name properties | | resultsProperty | String | | | property api results are keyed under| | resultsValue | String | | 'id' | property to use for the value| | resultsDisplay | String|Function | | 'name' | property to use for the display or custom function| | requestHeaders | Object | | | extra headers appended to the request| | showNoResults | Boolean | | true | To show a message that no results were found| | clearButtonIcon | String | | | Optionally provide an icon css class| | maxlength | Number | | | Optional max input length|

Available events

| Event | Output | Description | |----------|----------------|-------------| | results | Object | Results returned from a search | | noResults| Object | When no results are returned | | selected | Object | When an item is selected | | input | String|Number | The value when an item is selected | | clear | | When selected results are cleared | | close | | When the options list is closed | | enter | String | Emits the input value when enter is pressed | | nothingSelected | String | Emits the input value when enter is pressed and nothing was selected |

Available Slots

| Slot | Description | |-------------|-------------| | firstResult | list item placed before all results | | lastResult | list item placed at the end of the results | | noResults | list item shown when no results are present |