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-suggestion

v2.1.0

Published

Suggestion list input with Vue

Downloads

5,123

Readme

vue-suggestion

Suggestion list input for Vue

npm stars

Documentation and Demo

Visit the website

Changelog

Go to Github Releases

Getting started

  • Install the plugin:

    npm install vue-suggestion
  • Add the plugin into your app:

    import Vue from 'vue';
    import VueSuggestion from 'vue-suggestion';
    
    Vue.use(VueSuggestion);

    More info on installation

  • Use the vue-suggestion component:

    <template>
      <vue-suggestion
        :items="items"
        v-model="item"
        :setLabel="setLabel"
        :itemTemplate="itemTemplate"
        @changed="inputChange"
        @selected="itemSelected"
      >
      </vue-suggestion>
    </template>
    
    <script>
      import itemTemplate from './item-template.vue';
      export default {
        data() {
          return {
            item: {},
            items: [
              { id: 1, name: 'Golden Retriever' },
              { id: 2, name: 'Cat' },
              { id: 3, name: 'Squirrel' },
            ],
            itemTemplate,
          };
        },
        methods: {
          itemSelected(item) {
            this.item = item;
          },
          setLabel(item) {
            return item.name;
          },
          inputChange(text) {
            // your search method
            this.items = this.items.filter((item) => item.name.indexOf(text) > -1);
            // now `items` will be showed in the suggestion list
          },
        },
      };
    </script>

    ItemTemplate example:

    <template>
      <div>
        <b>#{{ item.id }}</b>
        <span>{{ item.name }}</span>
      </div>
    </template>
    
    <script>
      export default {
        props: {
          item: { required: true },
        },
      };
    </script>

Installation

npm

  npm install vue-suggestion

Install the plugin into Vue:

import Vue from 'vue';
import VueSuggestion from 'vue-suggestion';

Vue.use(VueSuggestion, [(globalOptions = {})]); // Define default global options here (optional)

View all available options in Props.

Or use the component directly:

<!-- your-component.vue-->
<template>
  <vue-suggestion v-model="value"></vue-suggestion>
</template>

<!-- some-sample-css-as-example-for-your-dropdown-autocomplete  -->
<style scope>
  .vue-suggestion .vs__list {
    width: 100%;
    text-align: left;
    border: none;
    border-top: none;
    max-height: 400px;
    overflow-y: auto;
    border-bottom: 1px solid #023d7b;
    position: relative;
  }
  .vue-suggestion .vs__list .vs__list-item {
    background-color: #fff;
    padding: 10px;
    border-left: 1px solid #023d7b;
    border-right: 1px solid #023d7b;
  }
  .vue-suggestion .vs__list .vs__list-item:last-child {
    border-bottom: none;
  }
  .vue-suggestion .vs__list .vs__list-item:hover {
    background-color: #eee !important;
  }
  .vue-suggestion .vs__list,
  .vue-suggestion .vs__loading {
    position: absolute;
  }
  .vue-suggestion .vs__list .vs__list-item {
    cursor: pointer;
  }
  .vue-suggestion .vs__list .vs__list-item.vs__item-active {
    background-color: #f3f6fa;
  }
</style>

<script>
  import { VueSuggestion } from 'vue-suggestion';

  export default {
    components: {
      VueSuggestion,
    },
  };
</script>

Browser

Include vue-suggestion in the page.

<script src="https://unpkg.com/vue-suggestion"></script>

If Vue is detected in the Page, the plugin is installed automatically.

Manually install the plugin into Vue:

Vue.use(VueSuggestion);

Or use the component directly:

Vue.component('vue-suggestion', VueSuggestion.VueSuggestion);

License

Copyright (c) 2018 Steven Dao. Released under the MIT License.

made with ❤ by Steven.