o-train/elm-search-input/1.0.0

NOTE: the latest version is 2.0.1

Select

simple elm search/select input with debouncer

This is in Alpha and is currently not intended for external use (yet).

Currently working on stylings (elm-css or supply your own css)

See a full example of the select input here

Types

type alias Item item =
{ id : String
, label : String
, identity : item
, isSelectable : Bool
}

An item for selection

type alias Model item =
{ label : String
, selected : Maybe (Item item)
, toItem : item -> Item item
, runSearch : Search item -> ( Search item, Maybe (Msg item) )
, search : Search item
, mode : OpenState
, searchDebouncer : Debouncer (Msg item) (Msg item)
, autocompleteIndex : Maybe Int
, allowMultipleFilters : Bool
, minimumSearchTermsLength : Int
}

Select Input configuration model

type Msg item
= Autocomplete
| Set (Setters item)
| FocusInput (Result Error ())
| RunSearch
| QueueSearch (Msg (Msg item))
| NoOperation

Select Input messages

= Opened
| Closed

Dropdown open state

type Setters item
= Mode OpenState
| Select (Item item)
| Deselect (Item item)
| AutocompleteIndex Direction
| SearchTerms String
| SuggestedItems
| SearchResults (WebData (List (Item item)))
| Filter Filter

Select Input internal state setters

Configuration

msg
-> String
-> Int
-> List (Item item)
-> Maybe (Item item)
-> (item -> Item item)
-> (Search item -> ( Search item, Maybe (Msg item) ))
-> Model item

Minimum model creation. This will be split out into 'RequiredModel' in future

Usage

update : Msg a -> Model a -> ( Model a, Cmd (Msg a) )

Update function in future it will have a third el to its tuple for synchronisation

view : Model a -> Html (Msg a)

Display search input and results

isOpen : Model item -> Bool

Check if selector is open or not