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-autocomplete-input-tag

v2.0.1

Published

With this library you can search items in an array and select the desired value through an input.

Downloads

159

Readme

npm npm npm

vue-autocomplete-input-tag

With this library you can search items in an array and select the desired value through an input. This library works with vue 3. If you use vue 2, you can use my another library exclusive to this version:: https://www.npmjs.com/package/vue2-autocomplete-input-tag

npm install vue-autocomplete-input-tag

Usage

<template>
  <div>
     <autocomplete 
        v-model="test"
        :items="items"
     />
  </div>
</template>

<script>
  import autocomplete from 'vue-autocomplete-input-tag'
  export default {
    name: "App",
    components: {
      autocomplete,
    },
    data() {
      return {
        test: "",
        items: [
          "Banana",
          "Strawberry",
          "Orange",
          "Lemon",
          "Pineapple",
          "Watermelon",
          "Melon",
        ],
      };
    },
  };
</script>

Attrs

You can pass attributes to input, like disabled and class
<template>
  <div>
     <autocomplete 
        v-model="test" 
        :items="items" 
        disabled
        class="my-custom-class"
     />
  </div>
</template>

Props

<template>
  <div>
     <autocomplete 
        v-model="test" 
        :items="items" 
        permitArbitraryValues
        :returned="['id', 'name']" 
        displayed="name"
     />
  </div>
</template>
<script>
  import autocomplete from 'vue-autocomplete-input-tag'
  
  export default {
    components: {
      autocomplete,
    },
    data() {
      return {
        test: {},
        items: [
          { name: "Banana", id: 1, color: "Yellow" },
          { name: "Strawberry", id: 2, color: "Red" },
          { name: "Orange", id: 3, color: "Orange" },
          { name: "Lemon", id: 4, color: "Green" },
          { name: "Pineapple", id: 5, color: "Yellow" },
          { name: "Watermelon", id: 6, color: "Red" },
          { name: "Melon", id: 7, color: "Yellow" },
        ],
      }
     }
</script>

How can I style my autocomplete?

The input can be styled like a single input. To style the results you can use .vue-autocomplete-input-tag-items and .vue-autocomplete-input-tag-item classes.

A single example:

  input {
    width: 100%;
    border: 1px solid #ccc;
    color: #666;
    border-radius: 10px;
    outline: none;
    padding: 9px 14px;
    box-sizing: border-box;
    font-size: 14px;
  }
  .vue-autocomplete-input-tag-items {
    border: 1px solid #ccc;
    max-height: 200px;
    margin-top: 8px;
    width: 100%;
    background-color: white;
    border-radius: 8px;
    overflow: auto;
  }
  .vue-autocomplete-input-tag-item {
    padding: 6px 16px;
    color: #4a4a4a;
    max-width: 100%;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
  }
  .vue-autocomplete-input-tag-item:hover {
    background-color: #e8e8e8;
  }

example-vue-autocomplete-input-tag

How does the reactivity works?

If you pass an array of strings (first example) the return will be just a string with the typed value, and when you select some option will be the selected value.

If you pass an array of objects (second example), when you type, the returned value will be an object with "typed" property. And when you select some option, will return what you inform in "returned" prop. The typed property is returned because you can use @input and refresh the array.

References

"Como criar e publicar uma biblioteca (em Vue) no npm?" -> https://medium.com/tableless/como-criar-e-publicar-uma-biblioteca-em-vue-no-npm-2dff8271ca7d