abadi199/elm-input-extra/2.1.0

NOTE: this package is not compatible with Elm 0.19.1

Input.Text

Text input

Model

type alias Model =
{ value : String
, hasFocus : Bool
}

(TEA) Model record Fields: * value : current value of the input element. * hasFocus : flag whether the input element has focus or not.

init : Model

(TEA) Initial model constant

Value:

{ value = ""
, hasFocus = False
}

View

input : Options -> List (Attribute Msg) -> Model -> Html Msg

(TEA) View function

Example:

Input.Text.input
    { id = "TextInput"
    , maxLength = Just 4
    }
    [ class "textInput"
    ...
    ]
    model.textModel
type alias Options =
{ id : String
, maxLength : Maybe Int
}

Options of the input component.

* id is the id of the HTML element. * maxLength is the maximum number of character allowed in this input. Set to Nothing for no limit.

defaultOptions : String -> Options

Default value for Options. Params: * id (type: String) : The id of the number input element.

Value:

{ id = id
, maxLength = Nothing
}

Update

update : Msg -> Model -> Model

(TEA) Update function

Example:

type Msg = UpdateText Input.Text.Msg


update msg model =
    case msg of
        UpdateText textMsg ->
            { model | textModel = Input.Text.update textMsg model.textModel }

Msg

type Msg

(TEA) Opaque Msg types