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

@laomao800/vue-item-list-selector

v2.1.5

Published

An item selector Vue.js component.

Downloads

30

Readme

item-list-selector

Build Status codecov npm

Install

# npm
npm install --save @laomao800/vue-item-list-selector

# yarn
yarn add @laomao800/vue-item-list-selector

Documentation

中文 | English

Usege

<template>
  <ItemListSelector
    v-model="value"
    :options-data="optionsData"
  />
</template>

<script>
import ItemListSelector from '@laomao800/ItemListSelector'

export default {
  components: { ItemListSelector },
  data() {
    return {
      value: [],
      optionsData: [
        { label: 'label-1', value: 1 },
        { label: 'label-2', value: 2 },
        { label: 'label-3', value: 3 },
        { label: 'label-4', value: 4 }
      ]
    }
  }
}
</script>

Props

value/v-model

  • type: Function
  • default: []

Binding value. Should be an array when multi-select mode.

optionsData

  • type: Array/Promise/Function
  • default: []

The array of options. When the item is the object, it can work with labelKey and valueKey to configure the option text property and the property to be submitted to value.

When the type is a function, it can return directly or use the callback function in the params to resolve the result.

{
  optionsData: (done) => {
    const result = []
    // return result
    // or
    // some sync/async works
    done(result)
  }
}

multiple

  • type: Boolean
  • default: true

Whether multi-select mode

loadingText

  • type: String
  • default: 'Loading...'

Text display when async optionsData resolving data.

notFoundText

  • type: String
  • default: 'No results'

Text display when no matching search results.

searchText

  • type: String
  • default: 'Search'

Search text input's Placeholder

splitKeyword

  • type: Boolean
  • default: true

Whether to use space-separated keywords when searching.

matchTemplate

  • type: Function
  • default: t => `<mark>${t}</mark>`

Matching text formatter.

labelKey

  • type: String
  • default: 'label'

Specify the label text property while optionsData item is an object.

If optionTemplate is not configured, the property value will also be used as the search text of the internal default filter method.

valueKey

  • type: String
  • default: undefined

Specify the binding value/v-model property while optionsData item is an object.

You can also use this property to help bind default values:

data() {
  return {
    value: 1
    optionsData: [
      { label: 'label-1', value: 1 },
      { label: 'label-2', value: 2 }
    ]
  }
}

optionTemplate

  • type: Function
  • default: undefined
  • params: (option)

Custom option label format function. Should return a string, and the return content will also use as a search text for the internal default filter method.

To customize the option's html content should use the slot option-template .

filterMethod

  • type: Function
  • default: undefined
  • params: (option, keyword)

Custom item filter method. Param option is item from options array, keyword is the current query keyword. Return true to match the option. Internal default filter method was @laomao800/mark-match .

optionHeight

  • type: Number
  • default: 34

Each list item height. Use to calculate the virtual-list outside container viewport.

optionsRemain

  • type: Number
  • default: 6

How many items should be shown in virtual-list viewport.

optionsBench

  • type: Number
  • default: 6

How many items not show in virtual-list viewport but exist in real DOM.

Events

| Events | Description | | -------------- | ------------------------------------ | | change | Trigger on binding value changed | | options-inited | Trigger on optionsData was loaded. |

Methods

| Methods | Params | Description | | --------------------- | ----------------------------- | ------------------------------------------------------------------------- | | setValue(filterFn) | filterFn: (option) => boolean | Replace current binding values with the new values filtered by filterFn | | addValue(filterFn) | filterFn: (option) => boolean | Add values filtered by filterFn from the binding value | | removeValue(filterFn) | filterFn: (option) => boolean | Remove values filtered by filterFn from the binding value | | reset() | - | Clear binding values |

Slots

option-template

| Slot prop | info | | --------- | --------------------------------- | | option | optionsData origin array item | | keyword | Search keyword | | selected | Whether current item was selected |