fedragon / elm-typed-dropdown / Dropdown

This library provides a dropdown that handles items of any type t. Items are not part of this component's internal model, meaning that there is a single source of truth: your own Model. It sets the selected item by value, rather than by index, which can be useful when the set of items is dynamic. User selection is communicated by returning an Event that contains the selected item.

Types


type Dropdown

@docs The Dropdown (opaque) model.


type Event t
    = Unchanged
    | ItemSelected t

@docs Events that are used to communicate changes in state relevant to @docs users of this component.


type Msg t

@docs Opaque type representing messages used to change internal state.


type alias Settings =
{ placeHolder : String
, closedClass : String
, openedClass : String
, menuClass : String
, buttonClass : String
, arrowUpClass : String
, arrowDownClass : String
, itemClass : String
, activeItemClass : String 
}

@docs Customization settings.

Functions

defaultSettings : Settings

@docs Default look and feel settings.

init : Dropdown

@docs Initialize a Dropdown with default settings.

initWithSettings : Settings -> Dropdown

@docs Initialize a Dropdown with custom settings.

update : Msg t -> Dropdown -> ( Dropdown, Event t )

@docs Update a Dropdown. Returns the updated Dropdown and an Event @docs that communicates changes that are relevant to the outside world, if @docs any (e.g. item selection).

view : List t -> Maybe t -> (t -> String) -> Dropdown -> Html (Msg t)

@docs Render a Dropdown using provided items, optional selected item, and @docs function that returns a string representation of an item.