diff --git a/examples/blog-engine/script/src/AddRoute.elm b/examples/blog-engine/script/src/AddRoute.elm index f1d8aa41..2e242fad 100644 --- a/examples/blog-engine/script/src/AddRoute.elm +++ b/examples/blog-engine/script/src/AddRoute.elm @@ -188,8 +188,7 @@ createFile { moduleName, fields } = Just justFormHelp -> [ Html.h2 [] [ Html.text "Form" ] , justFormHelp.form - |> Form.toDynamicTransition "form" - |> Form.renderHtml [] (Elm.get "errors" >> Elm.just) app Elm.unit + |> Form.renderHtml "form" [] (Elm.get "errors" >> Elm.just) app Elm.unit ] Nothing -> @@ -266,8 +265,8 @@ errorsView = (Type.namedWith [ "Html" ] "Html" [ Type.namedWith - [ "Pages", "Msg" ] - "Msg" + [ "PagesMsg" ] + "PagesMsg" [ Type.named [] "Msg" ] ] ) diff --git a/examples/end-to-end/app/Route/DarkMode.elm b/examples/end-to-end/app/Route/DarkMode.elm index da77de48..f9c4fdfb 100644 --- a/examples/end-to-end/app/Route/DarkMode.elm +++ b/examples/end-to-end/app/Route/DarkMode.elm @@ -215,8 +215,8 @@ view app shared model = ) ] [ form - |> Form.toDynamicFetcher "dark-mode" - |> Form.renderStyledHtml [] (.formResponse >> Just) app app.data.isDarkMode + |> Form.toDynamicFetcher + |> Form.renderStyledHtml "dark-mode" [] (.formResponse >> Just) app app.data.isDarkMode , Html.text <| "Current mode: " ++ (if app.data.isDarkMode then diff --git a/examples/end-to-end/app/Route/Form.elm b/examples/end-to-end/app/Route/Form.elm index 0a93de01..610154cd 100644 --- a/examples/end-to-end/app/Route/Form.elm +++ b/examples/end-to-end/app/Route/Form.elm @@ -245,8 +245,7 @@ view app shared = [] [ Html.text <| "Edit profile " ++ user.first ++ " " ++ user.last ] , form - |> Form.toDynamicTransition "user-form" - |> Form.renderHtml + |> Form.renderHtml "user-form" [ Attr.style "display" "flex" , Attr.style "flex-direction" "column" , Attr.style "gap" "20px" diff --git a/examples/end-to-end/app/Route/GetForm.elm b/examples/end-to-end/app/Route/GetForm.elm index bee6d946..0042d302 100644 --- a/examples/end-to-end/app/Route/GetForm.elm +++ b/examples/end-to-end/app/Route/GetForm.elm @@ -123,9 +123,8 @@ view app shared = { title = "GET Form Example" , body = [ form - |> Form.toDynamicTransition "user-form" |> Form.withGetMethod - |> Form.renderHtml + |> Form.renderHtml "user-form" [ Attr.style "display" "flex" , Attr.style "flex-direction" "column" , Attr.style "gap" "20px" diff --git a/examples/end-to-end/app/Route/Login.elm b/examples/end-to-end/app/Route/Login.elm index e718bffd..b84d1896 100644 --- a/examples/end-to-end/app/Route/Login.elm +++ b/examples/end-to-end/app/Route/Login.elm @@ -218,8 +218,8 @@ view app shared = ) ] , form - |> Form.toDynamicTransition "form" - |> Form.renderStyledHtml [] + |> Form.renderStyledHtml "form" + [] (.errors >> Just) app () diff --git a/examples/end-to-end/script/src/AddForm.elm b/examples/end-to-end/script/src/AddForm.elm index 030d0891..5c83b616 100644 --- a/examples/end-to-end/script/src/AddForm.elm +++ b/examples/end-to-end/script/src/AddForm.elm @@ -379,8 +379,7 @@ createFile moduleName fields = Elm.list [ Html.h2 [] [ Html.text "Form" ] , form.call [] - |> Gen.Form.toDynamicTransition "form" - |> Gen.Form.renderStyledHtml [] (Elm.get "errors" >> Elm.just) app Elm.unit + |> Gen.Form.renderStyledHtml "form" [] (Elm.get "errors" >> Elm.just) app Elm.unit ] } , update = diff --git a/examples/pokedex/app/Route/Form.elm b/examples/pokedex/app/Route/Form.elm index 8d2b1227..5bee80ba 100644 --- a/examples/pokedex/app/Route/Form.elm +++ b/examples/pokedex/app/Route/Form.elm @@ -261,8 +261,7 @@ view app shared = [] [ Html.text <| "Edit profile " ++ user.first ++ " " ++ user.last ] , form - |> Form.toDynamicTransition "test1" - |> Form.renderHtml + |> Form.renderHtml "test1" [ Attr.style "display" "flex" , Attr.style "flex-direction" "column" , Attr.style "gap" "20px" diff --git a/examples/pokedex/app/Route/Search.elm b/examples/pokedex/app/Route/Search.elm index 05bb1df5..6c804d3c 100644 --- a/examples/pokedex/app/Route/Search.elm +++ b/examples/pokedex/app/Route/Search.elm @@ -201,9 +201,9 @@ view static sharedModel model = , body = [ Html.h2 [] [ Html.text "Search" ] , form - |> Form.toDynamicTransition "test1" |> Form.withGetMethod - |> Form.renderHtml [] + |> Form.renderHtml "test1" + [] -- TODO pass in server data (\_ -> Nothing) static diff --git a/examples/pokedex/app/Route/Signup.elm b/examples/pokedex/app/Route/Signup.elm index 77cac86e..10192d13 100644 --- a/examples/pokedex/app/Route/Signup.elm +++ b/examples/pokedex/app/Route/Signup.elm @@ -265,8 +265,8 @@ view app shared model = ] , flashView app.data.flashMessage , form - |> Form.toDynamicTransition "test1" - |> Form.renderHtml [] + |> Form.renderHtml "test1" + [] -- TODO pass in server data (\_ -> Nothing) app diff --git a/examples/pokedex/app/Route/TailwindForm.elm b/examples/pokedex/app/Route/TailwindForm.elm index 8abd5e65..335b64a6 100644 --- a/examples/pokedex/app/Route/TailwindForm.elm +++ b/examples/pokedex/app/Route/TailwindForm.elm @@ -719,8 +719,9 @@ view app model sharedModel = |> Debug.toString ) , form - |> Form.toDynamicTransition "test" - |> Form.renderStyledHtml [] + |> Form.toDynamicTransition + |> Form.renderStyledHtml "test" + [] --app.action -- |> Maybe.andThen .formResponse (\_ -> Nothing) diff --git a/examples/smoothies/app/Route/CreateGroup.elm b/examples/smoothies/app/Route/CreateGroup.elm index 9262a37b..1e44c5de 100644 --- a/examples/smoothies/app/Route/CreateGroup.elm +++ b/examples/smoothies/app/Route/CreateGroup.elm @@ -126,8 +126,7 @@ view maybeUrl sharedModel model app = { title = "Create Group" , body = [ postForm - |> Form.toDynamicTransition "create-group" - |> Form.renderHtml [] + |> Form.renderHtml "create-group" [] -- TODO pass in form response from ActionData Nothing app diff --git a/examples/smoothies/app/Route/DependentForm.elm b/examples/smoothies/app/Route/DependentForm.elm index 8983aa3c..e72d7eb9 100644 --- a/examples/smoothies/app/Route/DependentForm.elm +++ b/examples/smoothies/app/Route/DependentForm.elm @@ -129,8 +129,8 @@ view maybeUrl sharedModel model app = , body = [ Html.h2 [] [ Html.text "Example" ] , dependentParser - |> Form.toDynamicTransition "dependent-example" - |> Form.renderHtml [] + |> Form.toDynamicTransition + |> Form.renderHtml "dependent-example" [] -- TODO pass in form response from ActionData Nothing app diff --git a/examples/smoothies/app/Route/Login.elm b/examples/smoothies/app/Route/Login.elm index cf90b67b..33cf022a 100644 --- a/examples/smoothies/app/Route/Login.elm +++ b/examples/smoothies/app/Route/Login.elm @@ -264,7 +264,6 @@ view maybeUrl sharedModel app = ) ] , form - |> Form.toDynamicTransition "login" - |> Form.renderHtml [] app.action app () + |> Form.renderHtml "login" [] app.action app () ] } diff --git a/examples/smoothies/app/Route/New.elm b/examples/smoothies/app/Route/New.elm index 2e1f8a12..8c64e65d 100644 --- a/examples/smoothies/app/Route/New.elm +++ b/examples/smoothies/app/Route/New.elm @@ -210,8 +210,7 @@ view maybeUrl sharedModel model app = , body = [ Html.h2 [] [ Html.text "New item" ] , form - |> Form.toDynamicTransition "form" - |> Form.renderHtml + |> Form.renderHtml "form" [ Attr.style "display" "flex" , Attr.style "flex-direction" "column" , Attr.style "gap" "20px" diff --git a/examples/smoothies/app/Route/PasswordConfirmation.elm b/examples/smoothies/app/Route/PasswordConfirmation.elm index 05e412ef..5ac4b373 100644 --- a/examples/smoothies/app/Route/PasswordConfirmation.elm +++ b/examples/smoothies/app/Route/PasswordConfirmation.elm @@ -120,8 +120,7 @@ view maybeUrl sharedModel model app = , body = [ Html.h2 [] [ Html.text "Example" ] , dependentParser - |> Form.toDynamicTransition "form" - |> Form.renderHtml [] + |> Form.renderHtml "form" [] -- TODO pass in form response from ActionData Nothing app diff --git a/examples/smoothies/app/Route/Profile/Edit.elm b/examples/smoothies/app/Route/Profile/Edit.elm index 2a311e38..8e4b4bb2 100644 --- a/examples/smoothies/app/Route/Profile/Edit.elm +++ b/examples/smoothies/app/Route/Profile/Edit.elm @@ -279,8 +279,7 @@ view maybeUrl sharedModel model app = _ -> Html.text "No errors" , formParser - |> Form.toDynamicTransition "edit-form" - |> Form.renderHtml + |> Form.renderHtml "edit-form" [ Attr.style "display" "flex" , Attr.style "flex-direction" "column" , Attr.style "gap" "20px" diff --git a/examples/smoothies/app/Route/SmoothieId_/Edit.elm b/examples/smoothies/app/Route/SmoothieId_/Edit.elm index 1bb506a8..853022fa 100644 --- a/examples/smoothies/app/Route/SmoothieId_/Edit.elm +++ b/examples/smoothies/app/Route/SmoothieId_/Edit.elm @@ -340,8 +340,7 @@ view maybeUrl sharedModel model app = , body = [ Html.h2 [] [ Html.text "Update item" ] , form - |> Form.toDynamicTransition "form" - |> Form.renderHtml + |> Form.renderHtml "form" [ Attr.style "display" "flex" , Attr.style "flex-direction" "column" , Attr.style "gap" "20px" @@ -354,8 +353,8 @@ view maybeUrl sharedModel model app = |> Maybe.map pendingView |> Maybe.withDefault (Html.div [] []) , deleteForm - |> Form.toDynamicTransition "delete-form" - |> Form.renderHtml [] + |> Form.toDynamicTransition + |> Form.renderHtml "delete-form" [] -- TODO Nothing app diff --git a/examples/todos/app/Route/Login.elm b/examples/todos/app/Route/Login.elm index 024950d3..b9bbe33c 100644 --- a/examples/todos/app/Route/Login.elm +++ b/examples/todos/app/Route/Login.elm @@ -395,8 +395,9 @@ view app shared = Html.div [] [ Html.text <| "Hello! You are already logged in as " ++ username , logoutForm - |> Form.toDynamicTransition "logout" - |> Form.renderHtml [] + |> Form.toDynamicTransition + |> Form.renderHtml "logout" + [] (\_ -> Nothing) app () @@ -406,8 +407,7 @@ view app shared = Html.text "You aren't logged in yet." ] , form - |> Form.toDynamicTransition "login" - |> Form.renderHtml [] .maybeError app () + |> Form.renderHtml "login" [] .maybeError app () ] ] } diff --git a/examples/todos/app/Route/Visibility__.elm b/examples/todos/app/Route/Visibility__.elm index 4cd680b2..70b80ab8 100644 --- a/examples/todos/app/Route/Visibility__.elm +++ b/examples/todos/app/Route/Visibility__.elm @@ -493,11 +493,11 @@ view app shared model = [ class "todoapp" ] [ addItemForm |> Form.toDynamicFetcher + |> Form.withOnSubmit (\_ -> NewItemSubmitted) + |> Form.renderHtml ("new-item-" ++ (model.nextId |> Time.posixToMillis |> String.fromInt) ) - |> Form.withOnSubmit (\_ -> NewItemSubmitted) - |> Form.renderHtml [ class "create-form" , hidden (not (List.isEmpty failedAddItemActions)) ] @@ -509,9 +509,10 @@ view app shared model = |> List.indexedMap (\index ( key, createFetcherErrors ) -> addItemForm - |> Form.toDynamicFetcher key + |> Form.toDynamicFetcher |> Form.withOnSubmit (\_ -> NewItemSubmitted) - |> Form.renderHtml [ class "create-form", hidden (index /= 0) ] + |> Form.renderHtml key + [ class "create-form", hidden (index /= 0) ] (\_ -> Nothing) app (Just createFetcherErrors) @@ -735,8 +736,8 @@ viewEntries app visibility entries = , style "visibility" cssVisibility ] [ toggleAllForm - |> Form.toDynamicFetcher "toggle-all" - |> Form.renderHtml [] (\_ -> Nothing) app { allCompleted = allCompleted } + |> Form.toDynamicFetcher + |> Form.renderHtml "toggle-all" [] (\_ -> Nothing) app { allCompleted = allCompleted } , Keyed.ul [ class "todo-list" ] <| List.map (viewKeyedEntry app) (List.filter isVisible entries) ] @@ -761,18 +762,18 @@ viewEntry app todo = [ div [ class "view" ] [ checkItemForm - |> Form.toDynamicFetcher ("toggle-" ++ todo.id) - |> Form.renderHtml [] (\_ -> Nothing) app todo + |> Form.toDynamicFetcher + |> Form.renderHtml ("toggle-" ++ todo.id) [] (\_ -> Nothing) app todo , editItemForm - |> Form.toDynamicFetcher ("edit-" ++ todo.id) - |> Form.renderHtml [] (\_ -> Nothing) app todo + |> Form.toDynamicFetcher + |> Form.renderHtml ("edit-" ++ todo.id) [] (\_ -> Nothing) app todo , if todo.isSaving then LoadingSpinner.view else deleteItemForm - |> Form.toDynamicFetcher ("delete-" ++ todo.id) - |> Form.renderHtml [] (\_ -> Nothing) app todo + |> Form.toDynamicFetcher + |> Form.renderHtml ("delete-" ++ todo.id) [] (\_ -> Nothing) app todo ] ] @@ -862,8 +863,8 @@ visibilitySwap visibilityParam visibility actualVisibility = viewControlsClear : App Data ActionData RouteParams -> Int -> Html (PagesMsg Msg) viewControlsClear app entriesCompleted = clearCompletedForm - |> Form.toDynamicFetcher "clear-completed" - |> Form.renderHtml [] (\_ -> Nothing) app { entriesCompleted = entriesCompleted } + |> Form.toDynamicFetcher + |> Form.renderHtml "clear-completed" [] (\_ -> Nothing) app { entriesCompleted = entriesCompleted } infoFooter : Html msg diff --git a/src/PagesMsg.elm b/src/PagesMsg.elm index 392fa7be..23fc252b 100644 --- a/src/PagesMsg.elm +++ b/src/PagesMsg.elm @@ -52,9 +52,8 @@ type alias PagesMsg userMsg = -- `Form.renderHtml` gives us `Html (PagesMsg msg)`, so we don't need to wrap its Msg type , logoutForm - |> Form.toDynamicTransition "logout" |> Form.withOnSubmit (\_ -> NewItemSubmitted) - |> Form.renderHtml [] (\_ -> Nothing) app Nothing + |> Form.renderHtml "logout" [] (\_ -> Nothing) app Nothing ] } diff --git a/src/Scaffold/Route.elm b/src/Scaffold/Route.elm index 3a30603a..e841a70f 100644 --- a/src/Scaffold/Route.elm +++ b/src/Scaffold/Route.elm @@ -170,7 +170,7 @@ buildNoState definitions builder_ = ServerRender declarations builder -> userFunction builder.moduleName { view = - \shared _ app -> + \app shared _ -> definitions.view { shared = shared , app = app @@ -191,7 +191,7 @@ buildNoState definitions builder_ = PreRender declarations builder -> userFunction builder.moduleName { view = - \shared _ app -> + \app shared _ -> definitions.view { shared = shared , app = app @@ -257,7 +257,7 @@ buildWithLocalState definitions builder_ = ServerRender declarations builder -> userFunction builder.moduleName { view = - \shared model app -> + \app shared model -> definitions.view { shared = shared , model = model @@ -266,7 +266,7 @@ buildWithLocalState definitions builder_ = , localState = Just { update = - \shared app msg model -> + \app shared msg model -> definitions.update { shared = shared , app = app @@ -274,7 +274,7 @@ buildWithLocalState definitions builder_ = , model = model } , init = - \shared app -> + \app shared -> definitions.init { shared = shared , app = app @@ -304,7 +304,7 @@ buildWithLocalState definitions builder_ = PreRender declarations builder -> userFunction builder.moduleName { view = - \shared model app -> + \app shared model -> definitions.view { shared = shared , model = model @@ -313,7 +313,7 @@ buildWithLocalState definitions builder_ = , localState = Just { update = - \shared app msg model -> + \app shared msg model -> definitions.update { shared = shared , app = app @@ -321,7 +321,7 @@ buildWithLocalState definitions builder_ = , model = model } , init = - \shared app -> + \app shared -> definitions.init { shared = shared , app = app @@ -385,7 +385,7 @@ buildWithSharedState definitions builder_ = ServerRender declarations builder -> userFunction builder.moduleName { view = - \shared model app -> + \app shared model -> definitions.view { shared = shared , model = model @@ -394,7 +394,7 @@ buildWithSharedState definitions builder_ = , localState = Just { update = - \shared app msg model -> + \app shared msg model -> definitions.update { shared = shared , app = app @@ -402,7 +402,7 @@ buildWithSharedState definitions builder_ = , model = model } , init = - \shared app -> + \app shared -> definitions.init { shared = shared , app = app @@ -432,7 +432,7 @@ buildWithSharedState definitions builder_ = PreRender declarations builder -> userFunction builder.moduleName { view = - \shared model app -> + \app shared model -> definitions.view { shared = shared , model = model @@ -441,7 +441,7 @@ buildWithSharedState definitions builder_ = , localState = Just { update = - \shared app msg model -> + \app shared msg model -> definitions.update { shared = shared , app = app @@ -449,7 +449,7 @@ buildWithSharedState definitions builder_ = , model = model } , init = - \shared app -> + \app shared -> definitions.init { shared = shared , app = app @@ -520,13 +520,13 @@ userFunction moduleName definitions = case definitions.localState of Just _ -> Elm.Declare.fn3 "view" + ( "app", Just appType ) ( "shared" , Just (Elm.Annotation.named [ "Shared" ] "Model") ) ( "model", Just (Elm.Annotation.named [] "Model") ) - ( "app", Just appType ) - (\shared model app -> - definitions.view shared model app + (\app shared model -> + definitions.view app shared model |> Elm.withType (Elm.Annotation.namedWith [ "View" ] "View" @@ -547,14 +547,14 @@ userFunction moduleName definitions = } viewDeclaration = Elm.Declare.fn2 "view" + ( "app", Just appType ) ( "shared" , Just (Elm.Annotation.named [ "Shared" ] "Model") ) - ( "app", Just appType ) (definitions.view Elm.unit) in { declaration = viewDeclaration.declaration - , call = \_ -> viewDeclaration.call + , call = \app shared _ -> viewDeclaration.call app shared , callFrom = \a _ c d -> viewDeclaration.callFrom a c d } @@ -575,17 +575,17 @@ userFunction moduleName definitions = (\localState -> { updateFn = Elm.Declare.fn4 "update" - ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) ( "app", Just appType ) + ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) ( "msg", Just (Elm.Annotation.named [] "Msg") ) ( "model", Just (Elm.Annotation.named [] "Model") ) localState.update , initFn = Elm.Declare.fn2 "init" - ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) ( "app", Just appType ) + ( "shared", Just (Elm.Annotation.named [ "Shared" ] "Model") ) (\shared app -> - localState.init shared app + localState.init app shared |> Elm.withType (Elm.Annotation.tuple (localType "Model")