abadi199/elm-input-extra/2.0.1

NOTE: this package is not compatible with Elm 0.19.1

Input.Number

Number 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.Number.input
    { id = "NumberInput"
    , maxLength = Just 4
    , maxValue = Nothing
    , minValue = Nothing
    }
    [ class "numberInput"
    ...
    ]
    model.numberModel
type alias Options =
{ id : String
, maxLength : Maybe Int
, maxValue : Maybe Int
, minValue : 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. * maxValue is the maximum number value allowed in this input. Set to Nothing for no limit. * minValue is the minimum number value 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 , maxValue = Nothing , minValue = Nothing }

Update

update : Msg -> Model -> Model

(TEA) Update function

Example:

type Msg = UpdateNumber Input.Number.Msg


update msg model =
    case msg of
        UpdateNumber numberMsg ->
            { model | numberModel = Input.Number.update numberMsg model.numberModel }

Msg

type Msg

(TEA) Opaque Msg types