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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wpm-select-box

v2.0.2

Published

A customizable multiselect dropdown component with search functionality, grouped options, recent searches, and tag display. It supports custom slots for rendering selected items, list items, and recent searches.

Readme

WpmSelectBox Component

A customizable multiselect dropdown component with search functionality, grouped options, recent searches, and tag display. It supports custom slots for rendering selected items, list items, and recent searches.


Props

| Prop Name | Type | Default | Description | |-------------------------|--------------------|--------------------|----------------------------------------------------------------------------------------------| | modelValue | String/Array/Object/null | Required | The selected value(s) for the multiselect. | | options | Array | Required | The list of options to display in the dropdown. | | groups | Boolean | false | Enables grouping of options in the dropdown. | | closeAfterSelection | Boolean | false | Automatically closes the dropdown after selecting an item. | | multiple | Boolean | false | Enables selecting multiple options. | | placeholder | String | Kam greste? | Placeholder text to display in the input field when no value is selected. | | includedPlaceholder | String | Already included | Text displayed for the section containing already selected items. | | notIncludedPlaceholder| String | Not included | Text displayed for the section containing options that are not yet selected. | | themeColor | String | #1890ff | The primary theme color used for styling the component. | | noResultsText | String | No results found | Text displayed when no matching results are found. | | loading | Boolean | false | Indicates whether the component is in a loading state. | | showClearButton | Boolean | false | Displays a clear button to reset the selected value(s). | | maxSelection | Number | Infinity | Maximum number of items that can be selected. | | minSelection | Number | 0 | Minimum number of items that must be selected. | | maxShow | Number | 0 | Maximum number of options to display at once in the dropdown. | | search | Array/Function | ['id', 'name'] | Specifies the keys or a custom function for searching through the options. | | keyId | String | id | Key used to uniquely identify items in the options list. | | included | Boolean | false | Displays an additional section for already selected items in the dropdown. | | enableGroups | Boolean | false | Enables support for grouped options in the dropdown. | | clearOnSelection | Boolean | false | Clears the search query after selecting an item. | | clearAll | Boolean | false | Displays a clear icon to remove all selected items at once. |


Slots

wsb-selected-tag

Customizes the appearance of selected tags in the component. This slot is displayed for each item in the list of selected items.

  • Slot Props:
    • item (Object): The currently selected item.
    • toggleSelection (Function): A method that can be invoked to toggle the selection state of the item.

list-search-item

Customizes the appearance of items in the dropdown search results. Slot props:

  • item: The item being displayed in the search results.

list-search-item-name

Customizes the appearance of the name displayed for each item in the dropdown search results.

list-selected-item

Customizes the appearance of selected items displayed in the dropdown. Slot props:

  • item: The currently selected item.

list-recent-item

Customizes the appearance of recent search items. Slot props:

  • item: The recent item being displayed.

list-group-item

Customizes the appearance of grouped dropdown items. Slot props:

  • item: The grouped item being displayed.

wsb-close-indicator

Customizes the appearance of the close or clear icon used to remove all selected items. This slot is typically displayed when there are selected items, allowing users to clear their selection. Slot props:

  • removeSelected: A function to be invoked when the close icon is clicked. It clears all selected items.

Events

update:modelValue

Emitted whenever the selected items are updated.

  • Payload:
    • Array: An array of selected items, reduced by the reduce function if provided.
  • Description:
    • This event is triggered every time the selection changes.
    • It ensures the parent component receives the updated selection state.

toggle:dropdown

Emitted when the dropdown is toggled (opened or closed).

  • Payload:
    • Boolean: true if the dropdown is opened, false if it is closed.
  • Description:
    • This event indicates the current visibility state of the dropdown.
    • Useful for reacting to the dropdown state in the parent component.

toggle:selection

Emitted when an item is selected or deselected.

  • Payload:
    • Boolean: The current visibility state of the dropdown (true or false).
  • Description:
    • This event is emitted after an item is added to or removed from the selection.
    • Useful for tracking the dropdown's state after a selection is made.

Example Usage

  • Single Select

   <WpmSelectBox theme-color="#b69562"
                 recent-cookie="wsb-destination-recent"
                 :search="['tag','country_name','name']"
                 :options="data"
                 :reduce="e => e.id"
                 :maxShow="10"
                 :recent="true"
                 :included="true"
                 v-model="selectedIDs"
                 :multiple="false"
                 :close-after-selection="true"
                 :clear-all="false"
>
  <template #list-search-item-name="{ item }">
    <span class="d-inline me-2 p-0 my-0">{{ item.flag }}</span>
    <span>{{ item.name }}</span>
    <span v-if="item.country_name">, {{ item.country_name }}</span>
    <span class="wsb-tag" :class="item.tagClass">{{ item.tag }}</span>
  </template>
</WpmSelectBox>
  • Multi Select

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="true"
              :close-after-selection="true"
              :clear-on-selection="true"
              :clear-all="false"
>
  <template #list-search-item-name="{ item }">
    <span class="d-inline me-2 p-0 my-0">{{ item.flag }}</span>
    <span>{{ item.name }}</span>
    <span v-if="item.country_name">, {{ item.country_name }}</span>
    <span class="wsb-tag" :class="item.tagClass">{{ item.tag }}</span>
  </template>
</WpmSelectBox>

Slot usage examples

  • No Slot usage

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
</WpmSelectBox>
  • Using the wsb-selected-tag Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
  <template #wsb-selected-tag="{ item, toggleSelection }">
    <div class="custom-selected-tag">
      <span>{{ item.name }}</span>
      <button @click="toggleSelection(item)">Remove</button>
    </div>
  </template>
</WpmSelectBox>
  • Multi Select using list-search-item Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
  <template #list-search-item="{ item }">
    <div class="custom-search-item">
      <span>{{ item.flag }}</span>
      <span>{{ item.name }}</span>,
      <span>{{ item.tag }}</span>
    </div>
  </template>
</WpmSelectBox>
  • Using the list-search-item-name Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
  <template #list-search-item-name="{ item }">
    <span>{{ item.flag }} {{ item.name }}</span>
  </template>
</WpmSelectBox>
  • Using the list-selected-item Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
  <template #list-selected-item="{ item }">
    <div class="custom-selected-item">
      <span>{{ item.name }}</span> 
      <span>({{ item.tag }})</span>
    </div>
  </template>
</WpmSelectBox>
  • Using the list-recent-item Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
  <template #list-recent-item="{ item }">
    <div class="custom-recent-item">
      {{ item.name }} (Recently searched)
    </div>
  </template>
</WpmSelectBox>
  • Using the list-group-item Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="false">
  <template #list-group-item="{ item }">
    <div class="custom-group-item">
      {{ item.name }} (Grouped)
    </div>
  </template>
</WpmSelectBox>
  • Using the wsb-close-indicator Slot

<WpmSelectBox theme-color="#b69562"
              recent-cookie="wsb-destination-recent"
              :search="['tag','country_name','name']"
              :options="data"
              :reduce="e => e.id"
              :maxShow="10"
              :recent="true"
              :included="true"
              v-model="selectedIDs"
              :multiple="false"
              :close-after-selection="true"
              :clear-all="true">
  <template #wsb-close-indicator="{ removeSelected }">
    <button @click="removeSelected" class="custom-clear-btn">Clear All</button>
  </template>
</WpmSelectBox>