Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Material/TextField.elm
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Material.TextField exposing
( Config, config
, setOnInput
, setOnFocus
, setOnBlur
, setOnChange
, setLabel
Expand Down Expand Up @@ -85,6 +86,7 @@ module Material.TextField exposing
## Configuration Options

@docs setOnInput
@docs setOnFocus
@docs setOnBlur
@docs setOnChange
@docs setLabel
Expand Down Expand Up @@ -293,6 +295,7 @@ type Config msg
, endAligned : Bool
, additionalAttributes : List (Html.Attribute msg)
, onInput : Maybe (String -> msg)
, onFocus : Maybe msg
, onBlur : Maybe msg
, onChange : Maybe (String -> msg)
}
Expand Down Expand Up @@ -324,6 +327,7 @@ config =
, endAligned = False
, additionalAttributes = []
, onInput = Nothing
, onFocus = Nothing
, onBlur = Nothing
, onChange = Nothing
}
Expand Down Expand Up @@ -473,6 +477,13 @@ setOnInput onInput (Config config_) =
Config { config_ | onInput = Just onInput }


{-| Specify a message when the user moves focus to the text field
-}
setOnFocus : msg -> Config msg -> Config msg
setOnFocus onFocus (Config config_) =
Config { config_ | onFocus = Just onFocus }


{-| Specify a message when the user moves focus away from the text field
-}
setOnBlur : msg -> Config msg -> Config msg
Expand Down Expand Up @@ -835,6 +846,11 @@ inputHandler (Config { onInput }) =
Maybe.map Html.Events.onInput onInput


focusHandler : Config msg -> Maybe (Html.Attribute msg)
focusHandler (Config { onFocus }) =
Maybe.map Html.Events.onFocus onFocus


blurHandler : Config msg -> Maybe (Html.Attribute msg)
blurHandler (Config { onBlur }) =
Maybe.map Html.Events.onBlur onBlur
Expand All @@ -855,6 +871,7 @@ inputElt config_ =
, ariaLabelAttr config_
, placeholderAttr config_
, inputHandler config_
, focusHandler config_
, blurHandler config_
, changeHandler config_
, minLengthAttr config_
Expand Down