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

find-an-entity

v0.1.0

Published

A highly configurable Angular component for generating a UI for lists of content.

Downloads

27

Readme

Find an Entity

A highly configurable Angular component for generating a UI for lists of content.

Living example: ngx-find-an-entity

Primary features:

  • A robust list view search/filtering experience with very little effort
  • Full text keyword searching
  • Ability to configure custom filters for fields using a control you specifcy[1]
  • List view automatically generated based on your config
  • A guided search mode that allows the user to choose one filter option at a time before seeing results[2]
  • Filters can be used as query params to enhance the user's experience. This also allows linking of specific search results[3]
  • Uses ngx-infinite-scroll to enhance performance[4]

[1] The following filter controls are currently implemented:

  • Text (A field specific version of the keyword search)
  • Select (Great for a list of options)
  • Radio (Similar functionality as select, but with different styling)
  • Checkbox (Good for bool values)
  • Combo Box (A custom select field that allows the user to limit options with text entry)

[2] To enable the guided search mode pass true as the value for the optional "guidedSearch" input as shown below:

<lib-find-an-entity [properties]="properties" [searchableEntities]="resultsInput" [guidedSearch]="true"></lib-find-an-entity>

[3] To enable the usage of query params pass true as the value for the optional "useQueryParams" input as show below:

<lib-find-an-entity [properties]="properties" [searchableEntities]="resultsInput" [useQueryParams]="true"></lib-find-an-entity>

[4] The number of results to show before scrolling can be customized by using the "resultLimit" input.

Usage

  1. After installing this module, add it to the imports array of the Angular module you intend to use it in, similar to the below:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { FindAnEntityModule } from 'ngx-find-an-entity'; // <- Add this

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    FindAnEntityModule // <- Add this
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  1. Retrieve your data as normal. For the best results, this data should be well structured json. The below is an example used in the next step:
export const resultsInput = [
  {
    name: 'Bob',
    age: 35,
    hasChildren: true,
    gender: 'male',
    favoriteColor: 'red',
    url: 'https://www.google.com',
    profilePhoto: 'https://images.vexels.com/media/users/3/140754/isolated/preview/18b7f2915116bea1ba6ce812505813b6-male-profile-avatar-8-by-vexels.png'
  }
];
  1. Create an array of IProperty that describes your data. The below example describes the data seen above so that it can be consumed by find-an-entity. Learn more about IProperty members through their JSDoc comments.
import { IProperty, ControlType } from 'ngx-find-an-entity';

export const resultsInputProperties: Array<IProperty> = [
  {
    propertyName: 'name',
    label: 'Name',
    controlType: ControlType.Text,
    currentValue: '',
    tag: 'h2'
  },
  {
    propertyName: 'favoriteColor',
    label: 'Favorite Color',
    controlType: ControlType.Select,
    currentValue: '',
    tag: 'p'
  },
  {
    propertyName: 'age',
    label: 'Age',
    controlType: ControlType.Select,
    currentValue: '',
    tag: 'p'
  },
  {
    propertyName: 'gender',
    label: 'Gender',
    controlType: ControlType.Radio,
    currentValue: '',
    tag: 'div'
  },
  {
    propertyName: 'hasChildren',
    label: 'Has children',
    controlType: ControlType.Checkbox,
    currentValue: false,
    tag: 'div'
  },
  {
    propertyName: 'profilePhoto',
    label: 'Profile Photo',
    controlType: ControlType.None,
    currentValue: '',
    tag: 'img'
  },
  {
    propertyName: 'url',
    label: 'Homepage',
    controlType: ControlType.None,
    currentValue: '',
    tag: 'a',
    hide: true
  }
];
  1. Add the find-an-entity component to whatever template you desire like you would any other custom component. Be sure to pass in your data and the array of IProperty you just made as inputs. Here's an example:
<lib-find-an-entity [properties]="properties" [searchableEntities]="resultsInput"></lib-find-an-entity>
  1. Style the results to your liking. The default styles are pretty basic, and you'll likely want to spruce them up a bit. Keep view encapsulation in mind when attempting to override styles, as it is not disabled for the find-an-entity components. In other words, put your style overrides somewhere that bypasses view encapsulation, such as the root styles.css file if you're working with an Angular CLI project.
    *Alternatively, you can disable view-encapsulation on the containing component and style find-and-entity from there.