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-next-typeahead

v0.0.2

Published

Typeahead component done with Vue3

Downloads

49

Readme

A simple component to display a typeahead format with Vue3.

Status

Version js-standard-style Downloads

Demo

Install

npm install vue-next-typeahead

Quick start

Globally

You can import in your main.js file

import App from './App.vue'
import { createApp } from 'vue'
import VueNextTypeahead from 'vue-next-typeahead'

const app = createApp(App)
app.component(VueNextTypeahead)

Locally in any component

import VueNextTypeahead from 'vue-next-typeahead'

export default {
  components: {
    VueNextTypeahead
  }
};

Basic usage

<template>
    <VueNextTypeahead
      v-model:input="inputSearch"
      :api-url="`http://openlibrary.org/search.json${inputSearch ? `?title=${inputSearch}` : ''}`"
      :title="'Encuentra libros que te gusten'"
      :placeholder="'Busca un libro...'"
      :items="results"
      :key-item="'title'"
      :loading-parent-component="loading"
      @response="getResponse"
      @reset="resetComponent()"
      @hit="selectItem" />
</template>

<script>
  export default {
    data () {
        return {
            results: [],
            loading: false,
            inputSearch: '',
            itemSelected: {}
        }
    },
    methods: {
        async getResponse (responseJson) {
            this.loading = true
            const response = await responseJson.json()
            this.results = response.docs
            this.loading = false
        },

        selectItem (item) {
            this.itemSelected = item
        },

        resetComponent () {
            this.results = []
        }
    }
  };
</script>

Props

| Property name | Type | Default |Description | | ------------------------------ | ---------- | --------- | -------------------------------------------------------- | | apiUrl | String | | URL to invoke the GET with fetch | input | String | '' | Default value of the input, used to make the data-binding. | title | String | null | Title that appears above the search input. | className | String | '' | Class to modify component styles. | items | Array | [] | Items to be displayed in the results dropdown. | keyItem | String | null | Key to display the desired value of the array 'items'. | showTitle | Boolean | true | Displays or not the title of the input. | placeholder | String | Qué necesitas... | Placeholder for search input. | noResultsText | String | No existen resultados para esa búsqueda... | Text to be displayed when there are no results in the search. | minChars | Number | 2 | Minimum of values until you start searching, at least it should be 1. | delay | Number | 500 | Time in milliseconds for the timeout used in the typing of the input. | loadingParentComponent | Boolean | true | Used in case it is necessary to make synchronous operations in the main service response in the component.

Emits

| Emit name | Description | | --------------- | ----------- | | update:input | In the parent component, you can use v-model:input="var" so that 'var' is automatically updated when you write in the input. | | response | First response returned by fetch GET. | | hit | Event launched when you click on an option of the items that appears in the dropdown. | | reset | When you reset all data within the component. | | error | Error returned by the GET service. |

Development

contributions welcome

Note: Contributions are very welcomed, however is very important to open a new issue using the issue template before you start working on anything, so we can discuss it before hand

Fork the project and enter this commands in your terminal

git clone https://github.com/cristianpoleyJS/vue-next-typeahead.git
cd vue-next-typeahead
npm install
npm run serve

Commitlint

This project follows the commitlint guidelines, with minor changes.

TODO

  • Unit testing with Jest.
  • Web Component: Currently Vue3 does not support the generation of a Web Component, that's why I haven't generated it yet.

License

MIT © cristianpoleyJS