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

@oasisdigital/angular-material-search-select

v1.1.1

Published

This library implements a "search select" or "select with search" control, to match (and building on) Angular Material. To provide the UI, the Material mat-autocomplete control is used; but the result is not quite an autocomplete per se, it really is a se

Downloads

142

Readme

Angular Material Search-select control

This library implements a "search select" or "select with search" control, to match (and building on) Angular Material. To provide the UI, the Material mat-autocomplete control is used; but the result is not quite an autocomplete per se, it really is a search select, intended to pick an item from a list.

Video demo and explanation

Video explaining search-select

How it works, and why

This control handles cases where the displayed 'name' does not match the internal ID. As a developer using this control, you supply methods to translate from ID to displayed name, and to search data during selection.

Both directions of data lookup/search are handles asynchronously, suitable for a database-based, long list of searchable items.

We have found this problem comes up regularly on our projects, and have finally created this reusable solution. This repository/project contains both the component itself, and screens that demonstrate its use.

Try it

Demo running at:

https://oasisdigital.github.io/angular-material-search-select/

NPM package:

https://www.npmjs.com/package/@oasisdigital/angular-material-search-select

To use this in a project

npm install --save @oasisdigital/angular-material-search-select

There are two ways to consume this code. You can see examples of them in the various tabs of the demo.

  1. Use the provided search-select component, as shown in "simple", "Long slow", "real API".
  2. Write a custom component using only the base class provided in this package; your component will provide all the visuals, but typically doesn't need to provide any code at all. For an example of this, look in the source code, directory demo-5-multicolumn and the corresponding multi-column demo tab.

For better or worse, various aspects of HTML, CSS, Angular, and other tools conspire to frequently require option 2. This is the only way to provide full flexibility in the appearance of the component, to match your application's needs.

Regardless of which layout approach you choose, at run time you must provide a DataSource, which is similar conceptually to the DataSource concept used by a mat-table; that interface defines (and application code must provide) methods:

  • Method which searches for a values, and provides corresponding display text.
  • Method which takes a search query fragment and provides a list of match candidates.
  • Optionally, a match method that can widen the definition of a matching entry - for example, make it a user can type an entry that varies from a list entry only in upper/lowercase.

Study the example code in the various demo-N-* for more about these methods. It shows several ways to provide such a data source.

Also an example of how to publish a component

In addition to being a useful component, we have been using this repository as an example of how to publish a Angular component to NPM. You can see these patterns in use here, and borrow them for other components:

  • Start with an Angular CLI project.
  • Add a module inside, for the components to be packaged.
  • Make the overall application provide a demo, test environment, etc. for the components in the to-be-packaged module.
  • Use ng-packagr: outsource the complexity in bundling to that brilliant package.

Who?

Primary authors:

  • Kyle Cordes, twitter @kylecordes
  • Paul Spears, twitter @TheEvergreenDev

We both work at Oasis Digital / Angular Boot Camp.