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

v-select-box

v2.3.3

Published

A vue.js component to provide a box with a list of items with search and pagination.

Downloads

66

Readme

v-select-box

npm npm

Demo

There is an example showcasing the component here.

Description

A vue.js component to provide a box with a list of items with search and pagination, without the overhead of jquery.

Features

  • Search
  • Infinite Scroll
  • Single/Multi Select
  • Minimal Size

Installation

npm install v-select-box

Basic Usage

<template>
  <div id="app">
    <v-select-box v-model="selected" :options="options"></v-select-box>
  </div>
</template>

<script>
  import VSelectBox from 'v-select-box'
  export default {
    name: 'app',
    components: {
      VSelectBox
    },
    data () {
      return {
        selected: {},
        options: {
          load: (params) => {
            //Request code goes here
            //Should return a Promise, resolving the result object
            const mock = {
              page: 1,
              pageCount: 1,
              pageSize: 10,
              items: [
                { id: 1, text: 'test1' },
                { id: 2, text: 'test2' }
              ]
            }

            return Promise(mock)
          }
        }
      }
    }
  }
</script>

Options

The only property required for the v-select-box to work is the load function. All the other ones are optional.

Name | Type | Default | Description :-------------- | :------ | :------ |:---------- multi | boolean | false | Whether or not it allows selection of multiple items. debug | boolean | false | Debug flag that enables console messages. page | number | 1 | Used to detemine which is the next page to request. pageCount | number | 1 | Used to detemine if the current page is the last. pageSize | number | 10 | How many items each page will have. minimumInput | number | 0 | The minimum number of characters the search query should have. placeholder | string | '' | The placeholder displayed. locale | string | 'enUS' | The language displayed. items | array | [] | The items that should be displayed. onSelect | function | undefined | Called after the user clicks an item. load | function | undefined | Called to request items to display in the list. params | object | {} | Optional object with the names of params sent in the requests.

Params

Name | Type | Default | Description :-------------- | :------ | :------ | :---------- search | string | q | The name of the param to send the search query in the requests. size | string | pageSize | The name of the param to send the size of the page in the requests.

Methods

onSelect()

The onSelect() method is called after the user clicks an item and receives an object containing the item.

Syntax

onSelect(item)

Parameters
  • item the object representing the list item. It has three properties:
    • id an unique identifier
    • text the text visible on the item itself
    • selected a boolean value indicating if the item is selected or not
Return Value

The onSelect() method doesn't have to return anything.


load()

The load() method is called when the component needs to populate the list with items. When it is called, the parameter is an object with the search term that was typed in the search box and the page size and the number of the page that needs to be requested. The load() method needs to return a Promise. The promise needs to be resolved with an object with the following structure:

  • page the current page
  • pageCount the total of pages
  • pageSize how many items each page has
  • items an array containing the items that should be displayed
    • id an unique identifier
    • text the text visible on the item itself
Syntax

load({ [search], [size], page })

Parameters
  • search the actual name of the property depends on the params.search, that could've been passed to the component via the options object. If a params.search is not set, the default name for this parameter is q.
  • size the actual name of the property depends on the params.size, that could've been passed to the component via the options object. If a params.size is not set, the default name for this parameter is pageSize.
  • page the number of the page that the component is requesting. The next page.
Return Value

For the reasons expressed above, the load() method has to return a Promise.

New Features

There is a list of features that are currently being worked on. They will be pushed to this repository as soon as they're finished.

Your feedback is appreciated!