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

@myfarms/mf-select

v1.7.3

Published

Playground: <https://stackblitz.com/edit/mf-select>

Downloads

22

Readme

@myfarms/mf-select

Playground: https://stackblitz.com/edit/mf-select

Getting started

Step 1: Install @myfarms/mf-select

$ npm install @myfarms/mf-select --save

Step 2: Import the MfSelectModule

import { NgModule } from '@angular/core';

import { MfSelectModule } from '@myfarms/mf-select';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    MfSelectModule,
  ],
  bootstrap: [ AppComponent ]
})
export class AppModule { }

Step3: Use the component in your template

<mf-select
  [items]='items'
></mf-select>

API

Inputs

| Input | Type | Default | Description | | ------------- | ------------- | ------------- | ------------- | | items | string[] | object[] | Observable<string[] \| object[]> | [] | Items array or Observable results in an array | | itemLabel | string | 'name' | Object property to use for label | | categoryLabel | string | 'category' | Grouping based on category, with category header rows | | appendTo | string | null | Append dropdown to body or any other element using css selector | | dropdownPosition | 'bottom' | 'top' | 'auto' | 'auto' | Set the dropdown position on open | | dropdownWidth | number | - | Static width of the dropdown in pixels | | placeholder | string | 'Select...' | Placeholder text | | placeholderLoading | string | 'Loading...' | Placeholder text while loading | | allowClear | boolean | true | Allow dropdown selection to be cleared via 'X' button | | loading | boolean | false | Flag for manually setting loading spinner | | floatingLabel | string | undefined | undefined | Floating label that shows when item is selected | | backgroundColor | string | 'white' | Background color for the select box and dropdown | | floatingLabelColor | string | 'white' | Background color for the floating label | | searchTemplateLeft | TemplateRef<any> | - | Template for content left of search | | searchTemplateRight | TemplateRef<any> | - | Template for content right of search | | selectedTemplate | TemplateRef<any> | - | Template for content of selected item | | optionTemplate | TemplateRef<any> | - | Template for content of each item in the dropdown | | optionCategoryTemplate | TemplateRef<any> | - | Template for content of each category header in the dropdown |

Outputs

| Output | Description | | ------------- | ------------- | | (update) | Fired on selected value change |

Methods and Properties

| Name | Description | | ------------- | ------------- | | selectedItem | The selected item | | toggle() | Opens/closes the select dropdown panel, whichever is appropriate | | open() | Opens the select dropdown panel | | close() | Closes the select dropdown panel | | selectItem(item) | Selects the passed item |

Other

| Name | Type | Description | | ------------- | ------------- | ------------- | | [mfOptionHighlight] | directive | Highlights search term in option. Accepts search term. Should be used on option element when customizing template |

Change Detection

Ng-select component implements OnPush change detection which means the dirty checking checks for immutable data types. That means if you do object mutations like:

this.items.push({id: 1, name: 'New item'})

Component will not detect a change. Instead you need to do:

this.items = [...this.items, { id: 1, name: 'New item' }];

This will cause the component to detect the change and update. Some might have concerns that this is a pricey operation, however, it is much more performant than running ngDoCheck and constantly diffing the array.

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

License

MIT © MyFarms