/ui/elements/dropdown

The dropdown elements module exports the dropdown method to create a dropdown element group from a params argument.

Requires

Methods

(inner) dropdown(params) → {HTMLElement}

The dropdown method returns a dropdown element created from the params argument.

Parameters:
NameTypeDescription
paramsObject

Parameter for the creation of the dropdown element.

Properties
NameTypeAttributesDefaultDescription
params.placeholderstring<optional>
''

The placeholder for the list of options.

params.multiboolean<optional>

Allow multiple choice if true.

params.dropdown_searchboolean<optional>

Specify wether a searchbox is supplied in a dropdown filter.

params.keepPlaceholderboolean<optional>

set this flag to true in order to keep the original placeholder after an option is selected.

params.entriesObject<optional>

Array of option elements. Expected format: [{title: 'Title for Option 1', option: 'option1'}, ...]. Add property selected: true for entry selected by default. title will appear as the description, option is a value passed as selected.

params.headerOnClickfunction<optional>

Callback to execute when a header is clicked. Overrides default function.

params.maxHeightNumber<optional>

Optional max height property on results unordered list

    in pixels. Defaults to 500px in dropdown stylesheet.

Returns:

HTML dropdown element

Type: 
HTMLElement

(inner) pillsElement(params)

Assign the params.pills property to the be a pills element.

Parameters:
NameTypeDescription
paramsObject

The dropdown element object.

Properties
NameTypeAttributesDescription
params.pillsboolean<optional>

The pills element will be assigned to the flag property.

params.selectedTitlesset

A set of titles from currently selected dropdown items.

params.selectedOptionsset

A set of options from currently selected dropdown items.

(inner) search(params) → {HTMElement}

Assign the params.search property to the be a search element.

Parameters:
NameTypeDescription
paramsObject

The dropdown element object.

Properties
NameTypeAttributesDescription
params.selectedTitlesset

A set of titles from currently selected dropdown items.

params.selectedOptionsset

A set of options from currently selected dropdown items.

params.entriesArray

The options avialble to the dropdown.

params.placeholderString

THe options avialble to the dropdown.

params.searchboolean<optional>

The search element will be assigned to the flag property.

params.pillsboolean<optional>

Pill element for adding the options to when selected.

Returns:

The search element and its datalist.

Type: 
HTMElement