New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ember-advanced-combobox

Package Overview
Dependencies
Maintainers
4
Versions
175
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-advanced-combobox

Swiss-knife ember combobox

  • 5.1.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Ember-advanced-combobox

Build Status

Ember combobox that can (beside others):

  • filter items
  • sort items
  • multiselect items
  • mobile support ("almost" as native)
  • lazy loading of combobox items
  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

We use BrowserStack to make sure this addon works on all browsers.

Installation

Warning: works for Ember >= 2.8.0

ember install ember-advanced-combobox

This addon uses FontAwesome by default - at the moment you have to provide it for yourself (this addon does not install it for you). You can however use any font icon set you want, but do not forget to configure this addon (more in section Global configuration -> propery icons)

Basic usage

{{combo-box  
  valueList=valueList
  selected=selectedItem
  itemKey='itemKey'
  itemLabel='itemLabel'  
  onSelected=(action 'onSelected')  
}}

For more usage examples see dummy application.

Configuration optionDescription
valueListArray of items in combobox - can be a plain JSON array or Ember MutableArray (note: either valueList, valuePromise or lazyCallback must be provided)
valuePromisePromise - when evaluated, the result will be used as valueList (note: either valueList, valuePromise or lazyCallback must be provided)
lazyCallbackcallback to retrieve new combobox list items - usefull for lazy-loaded comboboxes (note: either valueList, valuePromise or lazyCallback must be provided)
itemKeyName of the property of valueList items to be used is key to identify items
itemLabelName of the property of valueList items to be used as; can be string or function label
selectedKey of currently selected item
onSelectedAction callback that will be called when user selects an item
disabledWhenEmptyCombobox will be disabled, when there are no options in dropdown menu (recommened to set to false when used with valuePromise) (default: true)
multiselectboolean value; it true user can select multiple items (default is false)
canFilterboolean value; if true user can filter values in the dropdown - filter is case- and accent- insensitive fulltext search
disabledboolean value
orderByName of the property of valueList items to be used to sort the items in dropdown. If orderBy is not provided, items in dropdown will not be sorted.
minLazyCharactersoverrides minLazyCharacters (see global configuration section)
preselectFirstboolean value; if true combobox will automatically select the first item in the dropdown.
onDropdownShowAction callback called when dropdown is going to show
onDropdownHideAction callback called when dropdown is going to hide
showDropdownButtonboolean value; if false the dropdown button will be hidden (default is true)
itemLabelForSelectedPreviewstring value of function; customize how selected value looks like in the combobox (only for single select combobox); default is the same property as itemLabel
showLabelWhenDisabledboolean; false when combobox should be empty when disabled (default is false)
showChooseLabelboolean; false 'chooseLabel' should be shown - see global configuration as well (default is true)
showEmptySelectionLabelboolean; false 'emptySelectionLabel' should be shown - see global configuration as well (default is true)
maxDropdownHeightnumber; max height of dropdown (in pixels) - optional, if not set, dropdown will be stretched to the max height to be still visible in the page
emptySelectionLabeloverrides emptySelectionLabel (see global configuration section)
chooseLabeloverrides chooseLabel (see global configuration section)
paginationboolean (default: false); true if you want items in dropdown to be fetched with pagination
pageSizenumber (default: 10)
showDropdownOnClickboolean (default: true); true if dropdown should be opened on click
confirmInputValueOnBlurboolean (default: false)
hideSelectedboolean (default: false)
onDisabledCallbackcallback that will be called when component changes its disabled or labelOnly state
dropdownIconcustom css class for dropdown icon
onDropdownIconClickedcallback called when dropdown icon is clicked, if callback returns false, dropdown is not opened afterwards
noValueLabeldefault value, if empty 'valueList' is provided

Also note that if there is only one item available in combobox, it will be automatically selected.

Styling

Most often you would like to style the mobile version of combobox. To do this you can make use of following CSS classes:

  • .combobox-mobile-dialog - dialog itself (container for all other elements)
  • .header - DIV above the dialog
  • .footer - DIV below the dialog (contains buttons)
  • .btn-cancel - button to cancel dialog
  • .btn-accept - button to confirm selection (for multiselect combobox only)

Global configuration

Configuration optionDescriptionDefault value
emptySelectionLabelLabel shown when no value is selected""
chooseLabelLabel shown when dropdown is visible"Choose:"
multiselectValueLabelLabel shown when there are multiple values selected - it appends number of selected items at the end"Selected items: "
asyncLoaderStartLabelLabel shown when valuePromise is being evaluated"Loading..."
emptyValueListLabel shown when there are no items in dropdown"No items"
mobileFilterPlaceholderPlaceholder for filter input in mobile dropdown"Enter filter here"
mobileOkButtonText for "OK" button in mobile dropdown"Confirm"
mobileCancelButtonText for "Cancel" button in mobile dropdown"Cancel"
lazyDebounceTimedebounce time (in msec) when typing - used for lazy loading of comobobox items1000
minLazyCharactersminimum number of characters to trigger lazy load fetch3
iconsJSON of font icons usedsee example below
onDisabledCallbackcallback that will be called when component changes its disabled or labelOnly state

There are 2 ways to configure the combobox: using config/environment.js or by injecting service ember-advanced-combobox/adv-combobox-configuration-service:

environment.js configuration

Add this to your config/environment.js file:

  var ENV = {

  //------------------------
  "ember-advanced-combobox": {
    emptySelectionLabel: "",
    chooseLabel: "Choose:",
    multiselectValueLabel: "Selected items: ",
    asyncLoaderStartLabel: "Loading...",
    emptyValueList: 'No items',
    mobileFilterPlaceholder: 'Enter filter here',
    mobileOkButton: 'Confirm',
    mobileCancelButton: 'Cancel',
    lazyDebounceTime: 1000,
    minLazyCharacters: 3,
    icons: {
      dropdown: 'fa fa-chevron-down',
      'checkbox-checked': 'fa fa-check-square-o',
      'checkbox-unchecked': 'fa fa-square-o',
      loading: 'fa fa-circle-o-notch fa-spin fa-fw'
    }
  }
  //---------------------------

}

Configuration service ember-advanced-combobox/adv-combobox-configuration-service enables you to customize the combobox at runtime (e.g. beacuse of translations):

  comboboxConfig: Ember.inject.service('adv-combobox-configuration-service');

  this.get('comboboxConfig').setConfiguration("emptySelectionLabel", "some value");

Keywords

FAQs

Package last updated on 27 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc