inkuzmin/elm-multiselect/2.0.3

NOTE: the latest version is 4.0.0

Multiselect

An implementation of multiselect control built with and for Elm.

Please, check example/src/MinimalExample.elm for the minimal example on how to use this library.

Helpers

initModel : List ( String, String ) -> String -> Model

Init model based on the values : List (String, String) and id : String provided by the user.

model =
    { multiselect = Multiselect.initModel [ ( "one", "The 1st option" ), ( "two", "The 2nd option" ), ( "three", "The 3rd option" ) ] "id_1"
    }
getSelectedValues : Model -> List ( String, String )

Get selected values : List (String, String)

populateValues : Model -> List ( String, String ) -> List ( String, String ) -> Model

Populate model with values : List (String, String) and preselect selected : List (String, String).

Model

type alias Model =
{ status : Status
, values : List ( String, String )
, filtered : List ( String, String )
, selected : List ( String, String )
, protected : Bool
, error : Maybe String
, input : String
, inputWidth : Float
, hovered : Maybe ( String, String )
, tag : String
}

Opaque type that holds the model

type alias Model =
    { multiselect : Multiselect.Model
    }

Msg

type Msg

Opaque type for internal library messages

OutMsg

type OutMsg
= Selected ( String, String )
| Unselected ( String, String )
| Cleared

Transparent type for external library messages

View

view : Model -> Html Msg

Render the view

Html.map MultiselectMsg <| Multiselect.view model.multiselect

Update

update : Msg -> Model -> ( Model, Cmd Msg, Maybe OutMsg )

Update the control state

MultiselectMsg subMsg ->
    let
        ( subModel, subCmd ) =
            Multiselect.update subMsg model.multiselect
    in
        { model | multiselect = subModel } ! [ Cmd.map MultiselectMsg subCmd ]

Subscriptions

subscriptions : Model -> Sub Msg

Subscribe for messages

Sub.map MultiselectMsg <| Multiselect.subscriptions model.multiselect