5.1.8 • Published 2 years ago

ember-advanced-combobox v5.1.8

Weekly downloads
602
License
-
Repository
github
Last release
2 years ago

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)when set to true, user can enter value into the filter and DID NOT select filtered value in the dropdown - he can just click outside the combobox, and the value will still be selected
hideSelectedboolean (default: false)when set to true selected value will be hidden
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");
5.1.8

2 years ago

5.1.7

2 years ago

5.1.6

2 years ago

5.1.5

2 years ago

5.1.4

2 years ago

5.1.3

2 years ago

5.1.2

2 years ago

5.1.1

3 years ago

5.1.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.0

3 years ago

3.5.0

3 years ago

3.4.4

3 years ago

3.4.7

3 years ago

3.4.6

3 years ago

3.4.5

3 years ago

3.4.3

3 years ago

3.4.2

3 years ago

3.4.1

3 years ago

3.4.0

3 years ago

3.3.9

3 years ago

3.3.10

3 years ago

3.3.8

3 years ago

3.3.7

3 years ago

3.3.6

3 years ago

3.3.5

3 years ago

3.3.4

3 years ago

3.3.3

3 years ago

3.3.2

3 years ago

3.3.1

3 years ago

3.3.0

3 years ago

3.2.0

3 years ago

3.1.0

3 years ago

3.0.6

3 years ago

3.0.5

3 years ago

3.0.4

4 years ago

3.0.3

4 years ago

3.0.2

4 years ago

3.0.1

4 years ago

3.0.0

4 years ago

2.15.3

4 years ago

2.15.2

4 years ago

2.15.1

4 years ago

2.15.0

4 years ago

2.14.2

4 years ago

2.14.1

4 years ago

2.14.0

4 years ago

2.13.1

4 years ago

2.13.0

4 years ago

2.12.7

4 years ago

2.12.6

4 years ago

2.12.5

4 years ago

2.12.4

4 years ago

2.12.3

4 years ago

2.12.0

4 years ago

2.12.1

4 years ago

2.12.2

4 years ago

2.11.0

5 years ago

2.10.0

5 years ago

2.9.0

5 years ago

2.8.2

5 years ago

2.8.1

5 years ago

2.8.0

5 years ago

2.7.1

5 years ago

2.7.0

5 years ago

2.6.5

5 years ago

2.6.4

5 years ago

2.6.3

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.3

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.8

5 years ago

2.2.7

5 years ago

2.2.6

5 years ago

2.2.5

5 years ago

2.2.4

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.3

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.16.12

6 years ago

1.16.11

6 years ago

1.16.10

6 years ago

1.16.9

6 years ago

1.16.8

6 years ago

1.16.7

6 years ago

1.16.6

6 years ago

1.16.5

6 years ago

1.16.4

6 years ago

1.16.3

6 years ago

1.16.2

6 years ago

1.16.1

6 years ago

1.16.0

6 years ago

1.15.1

6 years ago

1.15.0

6 years ago

1.14.1

6 years ago

1.14.0

6 years ago

1.13.0

6 years ago

1.12.1

6 years ago

1.12.0

7 years ago

1.11.0

7 years ago

1.10.4

7 years ago

1.10.3

7 years ago

1.10.2

7 years ago

1.10.1

7 years ago

1.10.0

7 years ago

1.9.0

7 years ago

1.8.5

7 years ago

1.8.4

7 years ago

1.8.3

7 years ago

1.8.2

7 years ago

1.8.1

7 years ago

1.8.0

7 years ago

1.7.8

7 years ago

1.7.7

7 years ago

1.7.6

7 years ago

1.7.5

7 years ago

1.7.4

7 years ago

1.7.3

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago