indicatrix / elm-input-extra / Input.Number

Number input

Options


type alias StringOptions msg =
{ maxLength : Maybe Basics.Int
, maxValue : Maybe Basics.Int
, minValue : Maybe Basics.Int
, onInput : String -> msg
, hasFocus : Maybe (Basics.Bool -> msg) 
}

Options of the input component with String value.


type alias Options msg =
{ maxLength : Maybe Basics.Int
, maxValue : Maybe Basics.Int
, minValue : Maybe Basics.Int
, onInput : Maybe Basics.Int -> msg
, hasFocus : Maybe (Basics.Bool -> msg) 
}

Options of the input component.

defaultStringOptions : (String -> msg) -> StringOptions msg

Default options for input with String value Params:

Value:

{ onInput = onInput
, maxLength = Nothing
, maxValue = Nothing
, minValue = Nothing
, hasFocus = Nothing
}

defaultOptions : (Maybe Basics.Int -> msg) -> Options msg

Default value for Options. Params:

Value:

{ onInput = onInput
, maxLength = Nothing
, maxValue = Nothing
, minValue = Nothing
, hasFocus = Nothing
}

View

input : Options msg -> List (Html.Attribute msg) -> Maybe Basics.Int -> Html msg

View function

Example:

type alias Model = { currentValue : Maybe Int }

type Msg = InputUpdated (Maybe Int) | FocusUpdated Bool

Input.Number.input
    { onInput = InputUpdated
    , maxLength = Nothing
    , maxValue = 1000
    , minValue = 10
    , hasFocus = Just FocusUpdated
    }
    [ class "numberInput"
    ...
    ]
    model.currentValue

inputString : StringOptions msg -> List (Html.Attribute msg) -> String -> Html msg

View function for input with String value

Example:

type alias Model = { currentValue : String }

type Msg = InputUpdated String | FocusUpdated Bool

Input.Number.inputString
    { onInput = InputUpdated
    , maxLength = Nothing
    , maxValue = 1000
    , minValue = 10
    , hasFocus = Just FocusUpdated
    }
    [ class "numberInput"
    ...
    ]
    model.currentValue