Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vuejs-auto-complete

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuejs-auto-complete

A Vue autocomplete component

  • 0.9.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.5K
decreased by-16.11%
Maintainers
1
Weekly downloads
 
Created
Source

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

PropTypeRequiredDefaultDescription
sourceString|Function|Object|Arraytruedata source for the results
methodString'get'http method for api requests
placeholderString'Search'input placeholder
initialValueString|Numberstarting value
initialDisplayStringstarting display value
inputClassString|Objectcss class for the input div
disableInputBooleanto disable the input
nameStringname attribute for the value input
resultsFormatterFunction<Object[]>Function to format the server data. Should return an array of objects with id and name properties
resultsPropertyStringproperty api results are keyed under
resultsValueString'id'property to use for the value
resultsDisplayString|Function'name'property to use for the display or custom function
requestHeadersObjectextra headers appended to the request
showNoResultsBooleantrueTo show a message that no results were found
clearButtonIconStringOptionally provide an icon css class
maxlengthNumberOptional max input length

Available events

EventOutputDescription
resultsObjectResults returned from a search
noResultsObjectWhen no results are returned
selectedObjectWhen an item is selected
inputString|NumberThe value when an item is selected
clearWhen selected results are cleared
closeWhen the options list is closed
enterStringEmits the input value when enter is pressed
nothingSelectedStringEmits the input value when enter is pressed and nothing was selected

Available Slots

SlotDescription
firstResultlist item placed before all results
lastResultlist item placed at the end of the results
noResultslist item shown when no results are present

Keywords

FAQs

Package last updated on 06 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc