diff options
Diffstat (limited to 'elm/Lib')
-rw-r--r-- | elm/Lib/Ffi.elm | 14 | ||||
-rw-r--r-- | elm/Lib/Html.elm | 7 |
2 files changed, 17 insertions, 4 deletions
diff --git a/elm/Lib/Ffi.elm b/elm/Lib/Ffi.elm index 1df0c50f..9c3b1c23 100644 --- a/elm/Lib/Ffi.elm +++ b/elm/Lib/Ffi.elm @@ -10,9 +10,15 @@ -- Use sparingly, all of this will likely break in future Elm versions. module Lib.Ffi exposing (..) -import Html exposing (Attribute) -import Html.Attributes exposing (title) +import Html +import Html.Attributes +import Browser.Dom +import Task -- Set the innerHTML attribute of a node -innerHtml : String -> Attribute msg -innerHtml = always (title "") +innerHtml : String -> Html.Attribute msg +innerHtml s = Html.Attributes.title "" + +-- Like Browser.Dom.focus, except it can call any function (without arguments) +elemCall : String -> String -> Task.Task Browser.Dom.Error () +elemCall s = Browser.Dom.focus diff --git a/elm/Lib/Html.elm b/elm/Lib/Html.elm index edf0a0c5..d9c0594a 100644 --- a/elm/Lib/Html.elm +++ b/elm/Lib/Html.elm @@ -12,6 +12,13 @@ import Lib.Api as Api onClickN : m -> Attribute m onClickN action = custom "click" (JD.succeed { message = action, stopPropagation = True, preventDefault = True}) +-- onInput that also tells us whether the input is valid +onInputValidation : (String -> Bool -> msg) -> Attribute msg +onInputValidation msg = custom "input" <| + JD.map2 (\value valid -> { preventDefault = False, stopPropagation = True, message = msg value valid }) + targetValue + (JD.at ["target", "validity", "valid"] JD.bool) + -- Multi-<br> (ugly but oh, so, convenient) br_ : Int -> Html m |