16.0.0 • Published 10 months ago

search-multiselect-dropdown v16.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

Agular Search And Multiselection Dropdown

All Contributors npm npm downloads

search-multiselect-dropdown Custom Dropdown component for Angular 8+ with search item, multiple and single selection options with customizing themes.

Supports

Angular VersionPackage VersionDescription
Angular 8Version 2 anyIf your version is angular 8 use Version 2 from library
Angular 9 or 10Version 3 anyIf your version is angular 9 use Version 3 from library
Angular 12+Version 14 anyIf your version is angular 9 use Version 3 from library
Angular 15+Version 16 anyIf your version is angular 9 use Version 3 from library

Features

  • Single select dropdown
  • Multi select dropdown
  • Search dropdown list
  • Angular forms support
  • Angular v8 and above supported
  • Cross browser support
  • Modify colors and background
  • Modify height of list container

Installation

npm install search-multiselect-dropdown

Include it to your module for example your app.module.ts

import { FormsModule } from "@angular/forms";
import { SearchMultiselectDropdownModule } from "search-multiselect-dropdown";

@NgModule({
  imports: [FormsModule, SearchMultiselectDropdownModule],
})
export class AppModule {}

Usage

import { Component } from "@angular/core";
import { DropDownConfig } from "search-multiselect-dropdown"; // Class for dropdown configuration

export class AppComponent {
  public config: DropDownConfig = {
    displayKey: "name", // If objects array passed which key to be displayed defaults to description
    search: true, // If wants to find item by name and select
    height: "300px", // Set max height of list container
    placeholder: "Search and select", // Set placeholder
    noResultsFound: "No result found", // Set text if no items available
    multiple: true, // Set true if want to select multiple items else for single selection set false
    disabled: false, // To disable the dropdown
    filterBlankData: true, // To filter tha blank or empty value from array of options
    showSelectedAtDropdown: false, // To show the selected list to dropdown lable instead of under dropdown
    theme: {
      inputBackground: "#40404c", // Set backgound color for main input box
      inputColor: "#fff", // Set text color of main input box
      containerListBackground: "#40404c", // Set background color for list container
      ContainerListColor: "#fff", // Set text color for list container
      selectedItemColor: "#fff", // Set text color for selected itemd
      selectedItemBackground: "#EF411F", //Set background color for selected itemd
      listHoverBackground: "#EF411F", // Set background color for mouse hover item list
      listHoverColor: "#fff", // Set text color for mouse hover item list
      searchInputColor: "#fff", // Set search text color for search input box
    },
  };

  selectedOptions = [
    {
      _id: "5a66d6c31d5e4e36c7711b7a",
      index: 0,
      balance: "$2,806.37",
      picture: "http://placehold.it/32x32",
      name: "Burns Dalton",
    },
    {
      _id: "5a66d6c3657e60c6073a2d22",
      index: 1,
      balance: "$2,984.98",
      picture: "http://placehold.it/32x32",
      name: "Mcintyre Lawson",
    },
  ];

  options = [
    {
      _id: "5a66d6c3657e60c6073a2d22",
      index: 1,
      balance: "$2,984.98",
      picture: "http://placehold.it/32x32",
      name: "Mcintyre Lawson",
    },
    {
      _id: "5a66d6c376be165a5a7fae33",
      index: 2,
      balance: "$2,794.16",
      picture: "http://placehold.it/32x32",
      name: "Amie Franklin",
    },
    {
      _id: "5a66d6c3f7854b6b4d96333b",
      index: 3,
      balance: "$2,537.14",
      picture: "http://placehold.it/32x32",
      name: "Jocelyn Horton",
    },
    {
      _id: "5a66d6c31f967d4f3e9d84e9",
      index: 4,
      balance: "$2,141.42",
      picture: "http://placehold.it/32x32",
      name: "Fischer Erickson",
    },
  ];
}
<search-multiselect-dropdown [config]="config" [(ngModel)]="selectedOptions" [options]="options"></search-multiselect-dropdown>

<pre style="margin: 20px 0;">
    {{selectedOptions | json}}
 </pre
>

Settings

SettingTypeDescriptionDefault Value
multipleBooleanMode of this component. If set true user can select more than one option.false
placeholderStringText to be show in the dropdown, when no items are selected.'Select Item'
searchPlaceholderStringText to be show in the search input box.'Search...'
disabledBooleanDisable the dropdownfalse
filterBlankDataBooleanTo filter tha blank or empty value from array of optionsfalse
showSelectedAtDropdownBooleanTo show the selected list to dropdown lable instead of under dropdownfalse
optionsArrayArray of items from which to select. Should be an array of objects with id and text properties. You can also use custom properties. In that case you need to map idField and textField properties. As convenience, you may also pass an array of strings, in which case the same string is used for both the ID and the text(no mapping is required)n/a
searchBooleanIf wants to find item by name and selectfalse
displayKeyStringIf objects array passed which key to be displayed defaults to description'value'
noResultsFoundStringText to be show in list container if array of option list is empty or search result not found'No results found!'
heightStringSet maximum height of the dropdown list in any unit e.g. '400px''auto'
themeObjectUsing class DropDownConfig object set various colors and backgound to dropdownn/a

DropDownConfig Class

SettingTypeDescriptionDefault Value
inputBackgroundStringSet backgound color for main input box'#40404c'
inputColorStringSet text color of main input box'#fff'
containerListBackgroundStringSet background color for list container'#40404c'
ContainerListColorStringSet text color for list container'#fff'
selectedItemColorStringSet text color for selected itemd'#fff'
selectedItemBackgroundStringet background color for selected itemd'#EF411F'
listHoverBackgroundStringSet background color for mouse hover item list'#EF411F'
listHoverColorStringSet text color for mouse hover item list'#fff'
searchInputColorStringSet search text color for search input box'#fff'

Config Basic Setting

public config: DropDownConfig = {
    displayKey: 'name', // If objects array passed which key to be displayed defaults to description
    search: true, // If wants to find item by name and select
    height: '300px', // Set max height of list container
    placeholder: 'Search and select', // Set placeholder
    noResultsFound: 'No result found', // Set text if no items available
    multiple: true, // Set true if want to select multiple items else for single selection set false
    disabled: false, // To disable the dropdown
    filterBlankData: true, // To filter tha blank or empty value from array of options
    showSelectedAtDropdown: false, // To show the selected list to dropdown lable instead of under dropdown
    theme: {
      inputBackground: '#40404c', // Set backgound color for main input box
      inputColor: '#fff', // Set text color of main input box
      containerListBackground: '#40404c', // Set background color for list container
      ContainerListColor: '#fff', // Set text color for list container
      selectedItemColor: '#fff', // Set text color for selected itemd
      selectedItemBackground: '#EF411F', //Set background color for selected itemd
      listHoverBackground: '#EF411F', // Set background color for mouse hover item list
      listHoverColor: '#fff', // Set text color for mouse hover item list
      searchInputColor: '#fff' // Set search text color for search input box
    }
  };

Dependencies

  • Angular 8 and 8+
  • Font awesome icon library 4.7.0

Big Thanks To

  • Rus Lan for finding problem and fixing bugs.
16.0.0

10 months ago

14.0.0

1 year ago

3.0.7

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.4

2 years ago

3.0.6

2 years ago

3.0.4

3 years ago

3.0.5

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

2.0.1

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago