elm-pages 3.0.0-beta.33 → 3.0.0-beta.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/codegen/elm-pages-codegen.cjs +10 -78
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/dead-code-review/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +1 -1
- package/generator/review/elm.json +1 -1
- package/generator/src/RouteBuilder.elm +2 -2
- package/generator/src/compatibility-key.js +2 -2
- package/generator/static-code/elm-pages.js +10 -0
- package/package.json +3 -3
- package/src/Internal/Field.elm +19 -0
- package/src/Internal/Input.elm +81 -0
- package/src/Pages/Form.elm +229 -0
- package/src/Pages/Internal/Msg.elm +70 -61
- package/src/Pages/Internal/Platform/Cli.elm +423 -425
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +1 -1
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +1 -5
- package/src/Pages/Internal/Platform.elm +119 -100
- package/src/Pages/ProgramConfig.elm +12 -5
- package/src/Pages/StaticHttpRequest.elm +0 -1
- package/src/Pages/Transition.elm +9 -1
- package/src/PagesMsg.elm +0 -10
- package/src/Scaffold/Form.elm +9 -9
- package/src/Server/Request.elm +57 -61
- package/src/Form/Field.elm +0 -729
- package/src/Form/FieldStatus.elm +0 -36
- package/src/Form/FieldView.elm +0 -497
- package/src/Form/FormData.elm +0 -22
- package/src/Form/Validation.elm +0 -391
- package/src/Form/Value.elm +0 -118
- package/src/Form.elm +0 -1558
- package/src/FormDecoder.elm +0 -102
- package/src/Pages/FormState.elm +0 -257
- package/src/Pages/Internal/Form.elm +0 -37
package/src/Server/Request.elm
CHANGED
|
@@ -91,13 +91,14 @@ import CookieParser
|
|
|
91
91
|
import Dict exposing (Dict)
|
|
92
92
|
import FatalError exposing (FatalError)
|
|
93
93
|
import Form
|
|
94
|
+
import Form.Handler
|
|
94
95
|
import Form.Validation as Validation
|
|
95
96
|
import FormData
|
|
96
97
|
import Internal.Request
|
|
97
98
|
import Json.Decode
|
|
98
99
|
import Json.Encode
|
|
99
100
|
import List.NonEmpty
|
|
100
|
-
import Pages.
|
|
101
|
+
import Pages.Form
|
|
101
102
|
import QueryParams
|
|
102
103
|
import Time
|
|
103
104
|
import Url
|
|
@@ -877,60 +878,63 @@ fileField_ name =
|
|
|
877
878
|
|> Internal.Request.Parser
|
|
878
879
|
|
|
879
880
|
|
|
881
|
+
runForm : Validation.Validation error parsed kind constraints -> Form.Validated error parsed
|
|
882
|
+
runForm validation =
|
|
883
|
+
Form.Handler.run []
|
|
884
|
+
(Form.Handler.init identity
|
|
885
|
+
(Form.form
|
|
886
|
+
{ combine = validation
|
|
887
|
+
, view = []
|
|
888
|
+
}
|
|
889
|
+
)
|
|
890
|
+
)
|
|
891
|
+
|
|
892
|
+
|
|
880
893
|
{-| -}
|
|
881
894
|
formDataWithServerValidation :
|
|
882
|
-
Form.
|
|
883
|
-
-> Parser (BackendTask FatalError (Result (Form.
|
|
895
|
+
Form.Handler.Handler error (BackendTask FatalError (Validation.Validation error combined kind constraints))
|
|
896
|
+
-> Parser (BackendTask FatalError (Result (Form.ServerResponse error) ( Form.ServerResponse error, combined )))
|
|
884
897
|
formDataWithServerValidation formParsers =
|
|
885
898
|
rawFormData
|
|
886
899
|
|> andThen
|
|
887
900
|
(\rawFormData_ ->
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
Form.runOneOfServerSide
|
|
891
|
-
rawFormData_
|
|
892
|
-
formParsers
|
|
893
|
-
in
|
|
894
|
-
case ( maybeDecoded, errors |> Dict.toList |> List.filter (\( _, value ) -> value |> List.isEmpty |> not) |> List.NonEmpty.fromList ) of
|
|
895
|
-
( Just decoded, Nothing ) ->
|
|
901
|
+
case Form.Handler.run rawFormData_ formParsers of
|
|
902
|
+
Form.Valid decoded ->
|
|
896
903
|
succeed
|
|
897
904
|
(decoded
|
|
898
905
|
|> BackendTask.map
|
|
899
|
-
(\
|
|
900
|
-
case
|
|
901
|
-
|
|
906
|
+
(\clientValidated ->
|
|
907
|
+
case runForm clientValidated of
|
|
908
|
+
Form.Valid decodedFinal ->
|
|
902
909
|
Ok
|
|
903
|
-
(
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
910
|
+
( { persisted =
|
|
911
|
+
{ fields = Just rawFormData_
|
|
912
|
+
, clientSideErrors = Nothing
|
|
913
|
+
}
|
|
914
|
+
, serverSideErrors = Dict.empty
|
|
915
|
+
}
|
|
908
916
|
, decodedFinal
|
|
909
917
|
)
|
|
910
918
|
|
|
911
|
-
_ ->
|
|
919
|
+
Form.Invalid _ errors2 ->
|
|
912
920
|
Err
|
|
913
|
-
|
|
914
|
-
{ fields = rawFormData_
|
|
915
|
-
,
|
|
916
|
-
, clientErrors = errors
|
|
921
|
+
{ persisted =
|
|
922
|
+
{ fields = Just rawFormData_
|
|
923
|
+
, clientSideErrors = Just errors2
|
|
917
924
|
}
|
|
918
|
-
|
|
925
|
+
, serverSideErrors = Dict.empty
|
|
926
|
+
}
|
|
919
927
|
)
|
|
920
928
|
)
|
|
921
929
|
|
|
922
|
-
|
|
930
|
+
Form.Invalid _ errors ->
|
|
923
931
|
Err
|
|
924
|
-
|
|
925
|
-
{ fields = rawFormData_
|
|
926
|
-
,
|
|
927
|
-
maybeErrors
|
|
928
|
-
|> Maybe.map List.NonEmpty.toList
|
|
929
|
-
|> Maybe.withDefault []
|
|
930
|
-
|> Dict.fromList
|
|
931
|
-
, clientErrors = Dict.empty
|
|
932
|
+
{ persisted =
|
|
933
|
+
{ fields = Just rawFormData_
|
|
934
|
+
, clientSideErrors = Just errors
|
|
932
935
|
}
|
|
933
|
-
|
|
936
|
+
, serverSideErrors = Dict.empty
|
|
937
|
+
}
|
|
934
938
|
|> BackendTask.succeed
|
|
935
939
|
|> succeed
|
|
936
940
|
)
|
|
@@ -938,40 +942,32 @@ formDataWithServerValidation formParsers =
|
|
|
938
942
|
|
|
939
943
|
{-| -}
|
|
940
944
|
formData :
|
|
941
|
-
Form.
|
|
942
|
-
-> Parser ( Form.
|
|
945
|
+
Form.Handler.Handler error combined
|
|
946
|
+
-> Parser ( Form.ServerResponse error, Form.Validated error combined )
|
|
943
947
|
formData formParsers =
|
|
944
948
|
rawFormData
|
|
945
949
|
|> andThen
|
|
946
950
|
(\rawFormData_ ->
|
|
947
|
-
|
|
948
|
-
(
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
, Ok decoded
|
|
951
|
+
case Form.Handler.run rawFormData_ formParsers of
|
|
952
|
+
(Form.Valid decoded) as validated ->
|
|
953
|
+
( { persisted =
|
|
954
|
+
{ fields = Just rawFormData_
|
|
955
|
+
, clientSideErrors = Just Dict.empty
|
|
956
|
+
}
|
|
957
|
+
, serverSideErrors = Dict.empty
|
|
958
|
+
}
|
|
959
|
+
, validated
|
|
957
960
|
)
|
|
958
961
|
|> succeed
|
|
959
962
|
|
|
960
|
-
(
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
{ fields = rawFormData_
|
|
965
|
-
, errors = Dict.empty
|
|
966
|
-
, clientErrors =
|
|
967
|
-
maybeErrors
|
|
968
|
-
|> Maybe.map List.NonEmpty.toList
|
|
969
|
-
|> Maybe.withDefault []
|
|
970
|
-
|> Dict.fromList
|
|
963
|
+
(Form.Invalid maybeDecoded maybeErrors) as validated ->
|
|
964
|
+
( { persisted =
|
|
965
|
+
{ fields = Just rawFormData_
|
|
966
|
+
, clientSideErrors = Just maybeErrors
|
|
971
967
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
,
|
|
968
|
+
, serverSideErrors = Dict.empty
|
|
969
|
+
}
|
|
970
|
+
, validated
|
|
975
971
|
)
|
|
976
972
|
|> succeed
|
|
977
973
|
)
|