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

select-search-angular

v0.1.6

Published

A select input with a search option. It implements `ControlValueAccessor`. So you can use it as a part of your form. To use it first import it in your component or module.

Readme

SelectSearchAngular

A select input with a search option. It implements ControlValueAccessor. So you can use it as a part of your form. To use it first import it in your component or module.

import { SelectSearchAngular } from 'select-search-angular';
@Component({
selector: 'app-root',
template: `<app-select-search-angular
		[list]="allList()"
		[idKey]="'label'"
		[labelKey]="'value'"
		[localSearch]="true"
		(keySearchEvent)="searchItem($event)"
		[(ngModel)]="itemSelected"
	></app-select-search-angular>`,
'styles': `
	:host {
		--suggestion-bg-color: red;
		--suggestion-text-color: white;
		--suggestion-font: italic  1.2rem  "Fira Sans", serif;
		--suggestion-hover-color: darkred;
		--suggestion-line-height: 1.2;
		--max-suggestions-height: 200px;
		--suggestion-scroll: scroll;
	}`
imports: [ FormsModule, SelectSearchAngular],
})
  • [list] accepts a signal of type list which should have the content you want to see in the select. If the variable passed here changes, changes will be reflected in the suggested list.
  • [idKey] accepts the object key of the list item that would be used as value when an item in the select list is selected.
  • [labelKey] accepts the object key of the list item that would be showed in the select list and used for search.
  • [localSearch] Set it to true if you want to search within the list that you provided when typing. If set to false, you will have to implement your own search functionality in the function provided in (keySearchEvent).
  • (keySearchEvent) You have to provide a function here. This function will not be called if [localSearch] is set to true. In this function you can implement your own search functionality. Here you can also fetch the results of search from a network request.

Also you can implement other functionalities of a form element (like [(ngModel)] or (ngModelChange)).

Here is an example of a component within which this component is used in the way shown above.

import { Component, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SelectSearchAngular } from './select-search-angular/select-search-angular';
type DataType = { label: string, value: string };

@Component({
  selector: 'app-root',
  imports: [ FormsModule, SelectSearchAngular],
  template: `<app-select-search-angular class="search-select"
		[list]="allList()"
		[idKey]="'label'"
		[labelKey]="'value'"
		[localSearch]="false"
		(keySearchEvent)="searchItem($event)"
		[(ngModel)]="itemSelected"
    ></app-select-search-angular>`,
  styles: `
    :host {
      --suggestion-bg-color: red;
      --suggestion-text-color: white;
      --suggestion-font: italic  1.2rem  "Fira Sans", serif;
      --suggestion-hover-color: darkred;
      --suggestion-line-height: 1.2;
      --max-suggestions-height: 200px;
      --suggestion-scroll: scroll;
    }
    
    .search-select {
        position: relative; 
        width: 200px; height: 25px; 
        display: inline-block;
    }
    `
})

export class App {
  
  allList = signal<DataType[]>([]);  
  /*This allList variable will populate the suggestion list*/

  itemSelected = signal<string>('samin'); 
  /*The selected value will be assigned to itemSelected variable. If  a 
  value is assigned to this variable and it is already present in the 
  allList variable (or the variable set to [list] label), then the 
  corresponding label will be shown in the search box. If the value 
  is not present in the list, the search box will be empty. 
  If you want to show a default value in the search box, make sure that 
  the value is present in the list. 
  */
  
  ngOnInit() {
    const normalList = [
      'Ng', 'Select', 'Search', 'Component', 'samin', 'sum', 'annana', 'mukimutsalat', 'supersum'
    ];
    this.allList.set(normalList.map(e => {
      /*Here we are populating the list. Any changes that may happen later 
      to this variable will also be refelceted in the suggestion list*/
      return { label: e, value: e };
    }));
  }

  searchItem(searchText: string) {
    /*This function will be called for every keypress in 
    search field if [localSearch] is set to false*/
    console.log('Search Text:', searchText);
  }
}

In the stylesheet of this component, you can enter the css variables to change the styles of the component.

  • --suggestion-bg-color: background color of the search results
  • --suggestion-text-color: Text color of the search resuts
  • --suggestion-font: italic: Font of the search results. Also applies to search box.
  • --suggestion-hover-color: Background color of search results upon mouseover
  • --suggestion-line-height: Line height of the suggestions. Use this to control the space between the search results.
  • --max-suggestions-height: Max height of suggestion box.
  • --suggestion-scroll: Set to scroll if you want scroll bar in suggestion box. Otherwise set it to hidden.

This project was generated using Angular CLI version 20.1.0. It can be used in projects that do not use zone.js.