abadi199 / elm-input-extra

🔢 Commonly used Html element with extra functionality
http://package.elm-lang.org/packages/abadi199/elm-input-extra/latest
MIT License
51 stars 12 forks source link

Elm Input Extra

Commonly used Html element with extra functionality. This library implements reusable views instead of nested component, making it fit nicely in your view function, and doesn't complicate your update function.

Live Demo

See the source code of the demo page.

Number Input

Html input element that only accept numeric values.

See: Input.BigNumber to work with big number that can't be stored using Int

Options

Example

type Msg = InputUpdated String | FocusUpdated Bool

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

Text Input

Html input element with extra feature.

Options

Example

type Msg = InputUpdated String | FocusUpdated Bool

Input.Text.input
    { maxLength = 10
    , onInput = InputUpdated
    , hasFocus = Just FocusUpdated
    }
    [ class "textInput"
    ...
    ]
    model.currentValue

Masked Input

Html input element with formatting.

Options

Example

type Msg
    = InputUpdated String
    | StateUpdated MaskedInput.State
    | FocusUpdated Bool

MaskedInput.Text.input
    { pattern = "(###) ###-####"
    , inputCharacter = '#'
    , onInput = InputUpdated
    , toMsg = StateUpdated
    , hasFocus = Just FocusUpdated
    }
    [ class "masked-input"
    ...
    ]
    model.currentState
    model.currentValue

Dropdown

Html select element

Options

Example

type Msg = DropdownChanged String

Html.div []
    [ Dropdown.dropdown
        (Dropdown.defaultOptions DropdownChanged)
        [ class "my-dropdown" ]
        model.selectedDropdownValue
    ]

Multi Select

Html select element with multiple selection

Options

Example

type Msg = MultiSelectChanged (List String)

Html.div []
    [ MultiSelect.multiSelect
        (defaultOptions MultiSelectChanged)
        [ class "my-multiSelect" ]
        model.selectedValues
    ]

DatePicker

Moved to abadi199/datetimepicker