elm-pages 3.0.0-beta.32 → 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/src/render.js +1 -0
- package/generator/src/request-cache.js +20 -6
- package/generator/static-code/elm-pages.js +10 -0
- package/package.json +3 -3
- package/src/BackendTask/Http.elm +8 -2
- 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/RequestsAndPending.elm +31 -3
- 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/README.md
CHANGED
|
@@ -81,7 +81,7 @@ https://github.com/dillonkearns/elm-pages/projects
|
|
|
81
81
|
You will see an error if the NPM and Elm package do not have a matching Compatibility Key. Usually it's best to upgrade to the latest version of both the Elm and NPM
|
|
82
82
|
packages when you upgrade. However, in case you want to install versions that are behind the latest, the Compatibility Key is included here for reference.
|
|
83
83
|
|
|
84
|
-
Current Compatibility Key:
|
|
84
|
+
Current Compatibility Key: 14.
|
|
85
85
|
|
|
86
86
|
## Contributors ✨
|
|
87
87
|
|
|
@@ -25769,79 +25769,6 @@ var $author$project$Gen$Json$Encode$annotation_ = {
|
|
|
25769
25769
|
'Value',
|
|
25770
25770
|
_List_Nil)
|
|
25771
25771
|
};
|
|
25772
|
-
var $author$project$Gen$Pages$FormState$moduleName_ = _List_fromArray(
|
|
25773
|
-
['Pages', 'FormState']);
|
|
25774
|
-
var $author$project$Gen$Pages$FormState$annotation_ = {
|
|
25775
|
-
event: A3(
|
|
25776
|
-
$author$project$Elm$Annotation$namedWith,
|
|
25777
|
-
_List_fromArray(
|
|
25778
|
-
['Pages', 'FormState']),
|
|
25779
|
-
'Event',
|
|
25780
|
-
_List_Nil),
|
|
25781
|
-
fieldEvent: A4(
|
|
25782
|
-
$author$project$Elm$Annotation$alias,
|
|
25783
|
-
$author$project$Gen$Pages$FormState$moduleName_,
|
|
25784
|
-
'FieldEvent',
|
|
25785
|
-
_List_Nil,
|
|
25786
|
-
$author$project$Elm$Annotation$record(
|
|
25787
|
-
_List_fromArray(
|
|
25788
|
-
[
|
|
25789
|
-
_Utils_Tuple2('value', $author$project$Elm$Annotation$string),
|
|
25790
|
-
_Utils_Tuple2('formId', $author$project$Elm$Annotation$string),
|
|
25791
|
-
_Utils_Tuple2('name', $author$project$Elm$Annotation$string),
|
|
25792
|
-
_Utils_Tuple2(
|
|
25793
|
-
'event',
|
|
25794
|
-
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'Event', _List_Nil))
|
|
25795
|
-
]))),
|
|
25796
|
-
fieldState: A4(
|
|
25797
|
-
$author$project$Elm$Annotation$alias,
|
|
25798
|
-
$author$project$Gen$Pages$FormState$moduleName_,
|
|
25799
|
-
'FieldState',
|
|
25800
|
-
_List_Nil,
|
|
25801
|
-
$author$project$Elm$Annotation$record(
|
|
25802
|
-
_List_fromArray(
|
|
25803
|
-
[
|
|
25804
|
-
_Utils_Tuple2('value', $author$project$Elm$Annotation$string),
|
|
25805
|
-
_Utils_Tuple2(
|
|
25806
|
-
'status',
|
|
25807
|
-
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'FieldStatus', _List_Nil))
|
|
25808
|
-
]))),
|
|
25809
|
-
formState: A4(
|
|
25810
|
-
$author$project$Elm$Annotation$alias,
|
|
25811
|
-
$author$project$Gen$Pages$FormState$moduleName_,
|
|
25812
|
-
'FormState',
|
|
25813
|
-
_List_Nil,
|
|
25814
|
-
$author$project$Elm$Annotation$record(
|
|
25815
|
-
_List_fromArray(
|
|
25816
|
-
[
|
|
25817
|
-
_Utils_Tuple2(
|
|
25818
|
-
'fields',
|
|
25819
|
-
A3(
|
|
25820
|
-
$author$project$Elm$Annotation$namedWith,
|
|
25821
|
-
_List_Nil,
|
|
25822
|
-
'Dict',
|
|
25823
|
-
_List_fromArray(
|
|
25824
|
-
[
|
|
25825
|
-
$author$project$Elm$Annotation$string,
|
|
25826
|
-
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'FieldState', _List_Nil)
|
|
25827
|
-
]))),
|
|
25828
|
-
_Utils_Tuple2('submitAttempted', $author$project$Elm$Annotation$bool)
|
|
25829
|
-
]))),
|
|
25830
|
-
pageFormState: A4(
|
|
25831
|
-
$author$project$Elm$Annotation$alias,
|
|
25832
|
-
$author$project$Gen$Pages$FormState$moduleName_,
|
|
25833
|
-
'PageFormState',
|
|
25834
|
-
_List_Nil,
|
|
25835
|
-
A3(
|
|
25836
|
-
$author$project$Elm$Annotation$namedWith,
|
|
25837
|
-
_List_Nil,
|
|
25838
|
-
'Dict',
|
|
25839
|
-
_List_fromArray(
|
|
25840
|
-
[
|
|
25841
|
-
$author$project$Elm$Annotation$string,
|
|
25842
|
-
A3($author$project$Elm$Annotation$namedWith, _List_Nil, 'FormState', _List_Nil)
|
|
25843
|
-
])))
|
|
25844
|
-
};
|
|
25845
25772
|
var $author$project$Gen$Pages$Internal$NotFoundReason$moduleName_ = _List_fromArray(
|
|
25846
25773
|
['Pages', 'Internal', 'NotFoundReason']);
|
|
25847
25774
|
var $author$project$Gen$Pages$Internal$NotFoundReason$annotation_ = {
|
|
@@ -26079,8 +26006,8 @@ var $author$project$Gen$Pages$Internal$Platform$annotation_ = {
|
|
|
26079
26006
|
A3(
|
|
26080
26007
|
$author$project$Elm$Annotation$namedWith,
|
|
26081
26008
|
_List_fromArray(
|
|
26082
|
-
['
|
|
26083
|
-
'
|
|
26009
|
+
['Form']),
|
|
26010
|
+
'Model',
|
|
26084
26011
|
_List_Nil)),
|
|
26085
26012
|
_Utils_Tuple2('pendingRedirect', $author$project$Elm$Annotation$bool),
|
|
26086
26013
|
_Utils_Tuple2(
|
|
@@ -35396,7 +35323,12 @@ var $author$project$GenerateMain$otherFile = F2(
|
|
|
35396
35323
|
[
|
|
35397
35324
|
_Utils_Tuple2(
|
|
35398
35325
|
'pageFormState',
|
|
35399
|
-
$elm$core$Maybe$Just(
|
|
35326
|
+
$elm$core$Maybe$Just(
|
|
35327
|
+
A2(
|
|
35328
|
+
$author$project$Elm$Annotation$named,
|
|
35329
|
+
_List_fromArray(
|
|
35330
|
+
['Form']),
|
|
35331
|
+
'Model'))),
|
|
35400
35332
|
_Utils_Tuple2(
|
|
35401
35333
|
'fetchers',
|
|
35402
35334
|
$elm$core$Maybe$Just(
|
|
@@ -36636,8 +36568,8 @@ var $author$project$GenerateMain$otherFile = F2(
|
|
|
36636
36568
|
A2(
|
|
36637
36569
|
$author$project$Elm$Annotation$named,
|
|
36638
36570
|
_List_fromArray(
|
|
36639
|
-
['
|
|
36640
|
-
'
|
|
36571
|
+
['Form']),
|
|
36572
|
+
'Model'))),
|
|
36641
36573
|
_Utils_Tuple2(
|
|
36642
36574
|
'fetchers',
|
|
36643
36575
|
$elm$core$Maybe$Just(
|
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 3680802640, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
Binary file
|
|
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
|
|
|
75
75
|
const { Elm } = require("./Runner.elm.js");
|
|
76
76
|
|
|
77
77
|
// Start the Elm app
|
|
78
|
-
const flags = { initialSeed:
|
|
78
|
+
const flags = { initialSeed: 1263909344, fuzzRuns: 100, filter: null };
|
|
79
79
|
const app = Elm.Runner.init({ flags: flags });
|
|
80
80
|
|
|
81
81
|
// Record the timing at which we received the last "runTest" message
|
|
@@ -90,11 +90,11 @@ import Dict exposing (Dict)
|
|
|
90
90
|
import Effect exposing (Effect)
|
|
91
91
|
import ErrorPage exposing (ErrorPage)
|
|
92
92
|
import FatalError exposing (FatalError)
|
|
93
|
+
import Form
|
|
93
94
|
import Head
|
|
94
95
|
import Http
|
|
95
96
|
import Json.Decode
|
|
96
97
|
import Pages.Fetcher
|
|
97
|
-
import Pages.FormState
|
|
98
98
|
import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
|
99
99
|
import Pages.Internal.RoutePattern exposing (RoutePattern)
|
|
100
100
|
import Pages.PageUrl exposing (PageUrl)
|
|
@@ -147,7 +147,7 @@ type alias App data action routeParams =
|
|
|
147
147
|
-> Pages.Fetcher.Fetcher (Result Http.Error action)
|
|
148
148
|
, transition : Maybe Pages.Transition.Transition
|
|
149
149
|
, fetchers : Dict String (Pages.Transition.FetcherState (Maybe action))
|
|
150
|
-
, pageFormState :
|
|
150
|
+
, pageFormState : Form.Model
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const compatibilityKey =
|
|
1
|
+
export const compatibilityKey = 14;
|
|
2
2
|
|
|
3
|
-
export const packageVersion = "3.0.0-beta.
|
|
3
|
+
export const packageVersion = "3.0.0-beta.34";
|
package/generator/src/render.js
CHANGED
|
@@ -202,12 +202,26 @@ export function lookupOrPerform(
|
|
|
202
202
|
},
|
|
203
203
|
});
|
|
204
204
|
} catch (error) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
}
|
|
205
|
+
if (error.code === "ECONNREFUSED") {
|
|
206
|
+
resolve({
|
|
207
|
+
kind: "response-json",
|
|
208
|
+
value: { "elm-pages-internal-error": "NetworkError" },
|
|
209
|
+
});
|
|
210
|
+
} else if (
|
|
211
|
+
error.code === "ETIMEDOUT" ||
|
|
212
|
+
error.code === "ERR_SOCKET_TIMEOUT"
|
|
213
|
+
) {
|
|
214
|
+
resolve({
|
|
215
|
+
kind: "response-json",
|
|
216
|
+
value: { "elm-pages-internal-error": "Timeout" },
|
|
217
|
+
});
|
|
218
|
+
} else {
|
|
219
|
+
console.trace("elm-pages unhandled HTTP error", error);
|
|
220
|
+
resolve({
|
|
221
|
+
kind: "response-json",
|
|
222
|
+
value: { "elm-pages-internal-error": "NetworkError" },
|
|
223
|
+
});
|
|
224
|
+
}
|
|
211
225
|
}
|
|
212
226
|
}
|
|
213
227
|
});
|
|
@@ -103,4 +103,14 @@ function find_anchor(node) {
|
|
|
103
103
|
return /** @type {HTMLAnchorElement} */ (node);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
+
Object.defineProperty(SubmitEvent.prototype, "fields", {
|
|
107
|
+
get: function fields() {
|
|
108
|
+
let formData = new FormData(this.currentTarget);
|
|
109
|
+
if (this.submitter?.name) {
|
|
110
|
+
formData.append(this.submitter.name, this.submitter.value);
|
|
111
|
+
}
|
|
112
|
+
return [...formData.entries()];
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
106
116
|
setup();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.34",
|
|
5
5
|
"homepage": "https://elm-pages.com",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"memfs": "^3.4.13",
|
|
45
45
|
"micromatch": "^4.0.5",
|
|
46
46
|
"serve-static": "^1.15.0",
|
|
47
|
-
"vite": "^4.2.1",
|
|
48
47
|
"terser": "^5.16.8",
|
|
48
|
+
"vite": "^4.2.1",
|
|
49
49
|
"which": "^3.0.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"cypress": "^12.8.1",
|
|
59
59
|
"elm-codegen": "^0.3.0",
|
|
60
60
|
"elm-optimize-level-2": "^0.3.5",
|
|
61
|
-
"elm-review": "^2.
|
|
61
|
+
"elm-review": "^2.10.1",
|
|
62
62
|
"elm-test": "^0.19.1-revision11",
|
|
63
63
|
"elm-tooling": "^1.13.1",
|
|
64
64
|
"elm-verify-examples": "^5.2.0",
|
package/src/BackendTask/Http.elm
CHANGED
|
@@ -494,19 +494,25 @@ requestRaw request__ expect =
|
|
|
494
494
|
(\maybeMockResolver rawResponseDict ->
|
|
495
495
|
(case maybeMockResolver of
|
|
496
496
|
Just mockResolver ->
|
|
497
|
-
mockResolver request_
|
|
497
|
+
mockResolver request_ |> Maybe.map Ok
|
|
498
498
|
|
|
499
499
|
Nothing ->
|
|
500
500
|
rawResponseDict |> RequestsAndPending.get (request_ |> HashRequest.hash)
|
|
501
501
|
)
|
|
502
502
|
|> (\maybeResponse ->
|
|
503
503
|
case maybeResponse of
|
|
504
|
-
Just rawResponse ->
|
|
504
|
+
Just (Ok rawResponse) ->
|
|
505
505
|
Ok rawResponse
|
|
506
506
|
|
|
507
507
|
Nothing ->
|
|
508
508
|
--Err (Pages.StaticHttpRequest.UserCalledStaticHttpFail ("INTERNAL ERROR - expected request" ++ request_.url))
|
|
509
509
|
Err (BadBody Nothing ("INTERNAL ERROR - expected request" ++ request_.url))
|
|
510
|
+
|
|
511
|
+
Just (Err RequestsAndPending.NetworkError) ->
|
|
512
|
+
Err NetworkError
|
|
513
|
+
|
|
514
|
+
Just (Err RequestsAndPending.Timeout) ->
|
|
515
|
+
Err Timeout
|
|
510
516
|
)
|
|
511
517
|
|> Result.andThen
|
|
512
518
|
(\(RequestsAndPending.Response maybeResponse body) ->
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Internal.Field exposing (Field(..), FieldInfo)
|
|
2
|
+
|
|
3
|
+
{-| -}
|
|
4
|
+
|
|
5
|
+
import Json.Encode as Encode
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
type Field error parsed input initial kind constraints
|
|
9
|
+
= Field (FieldInfo error parsed input initial) kind
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
{-| -}
|
|
13
|
+
type alias FieldInfo error parsed input initial =
|
|
14
|
+
{ initialValue : input -> Maybe String
|
|
15
|
+
, decode : Maybe String -> ( Maybe parsed, List error )
|
|
16
|
+
, properties : List ( String, Encode.Value )
|
|
17
|
+
, initialToString : initial -> String
|
|
18
|
+
, compare : String -> initial -> Order
|
|
19
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module Internal.Input exposing
|
|
2
|
+
( Hidden(..)
|
|
3
|
+
, Input(..)
|
|
4
|
+
, InputType(..)
|
|
5
|
+
, Options(..)
|
|
6
|
+
, inputTypeToString
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
type InputType
|
|
11
|
+
= Text
|
|
12
|
+
| Number
|
|
13
|
+
-- TODO should range have arguments for initial, min, and max?
|
|
14
|
+
| Range
|
|
15
|
+
| Radio
|
|
16
|
+
-- TODO should submit be a special type, or an Input type?
|
|
17
|
+
-- TODO have an option for a submit with a name/value?
|
|
18
|
+
| Date
|
|
19
|
+
| Time
|
|
20
|
+
| Checkbox
|
|
21
|
+
| Tel
|
|
22
|
+
| Search
|
|
23
|
+
| Password
|
|
24
|
+
| Email
|
|
25
|
+
| Url
|
|
26
|
+
| Textarea { rows : Maybe Int, cols : Maybe Int }
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
inputTypeToString : InputType -> String
|
|
30
|
+
inputTypeToString inputType =
|
|
31
|
+
case inputType of
|
|
32
|
+
Text ->
|
|
33
|
+
"text"
|
|
34
|
+
|
|
35
|
+
Textarea _ ->
|
|
36
|
+
"text"
|
|
37
|
+
|
|
38
|
+
Number ->
|
|
39
|
+
"number"
|
|
40
|
+
|
|
41
|
+
Range ->
|
|
42
|
+
"range"
|
|
43
|
+
|
|
44
|
+
Radio ->
|
|
45
|
+
"radio"
|
|
46
|
+
|
|
47
|
+
Date ->
|
|
48
|
+
"date"
|
|
49
|
+
|
|
50
|
+
Time ->
|
|
51
|
+
"time"
|
|
52
|
+
|
|
53
|
+
Checkbox ->
|
|
54
|
+
"checkbox"
|
|
55
|
+
|
|
56
|
+
Tel ->
|
|
57
|
+
"tel"
|
|
58
|
+
|
|
59
|
+
Search ->
|
|
60
|
+
"search"
|
|
61
|
+
|
|
62
|
+
Password ->
|
|
63
|
+
"password"
|
|
64
|
+
|
|
65
|
+
Email ->
|
|
66
|
+
"email"
|
|
67
|
+
|
|
68
|
+
Url ->
|
|
69
|
+
"url"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
type Input
|
|
73
|
+
= Input InputType
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
type Hidden
|
|
77
|
+
= Hidden
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
type Options a
|
|
81
|
+
= Options (String -> Maybe a) (List String)
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
module Pages.Form exposing
|
|
2
|
+
( Strategy(..), renderHtml, renderStyledHtml
|
|
3
|
+
, FormWithServerValidations, Handler
|
|
4
|
+
)
|
|
5
|
+
|
|
6
|
+
{-|
|
|
7
|
+
|
|
8
|
+
@docs Strategy, renderHtml, renderStyledHtml
|
|
9
|
+
|
|
10
|
+
@docs FormWithServerValidations, Handler
|
|
11
|
+
|
|
12
|
+
-}
|
|
13
|
+
|
|
14
|
+
import BackendTask exposing (BackendTask)
|
|
15
|
+
import Dict exposing (Dict)
|
|
16
|
+
import FatalError exposing (FatalError)
|
|
17
|
+
import Form
|
|
18
|
+
import Form.Handler
|
|
19
|
+
import Form.Validation as Validation exposing (Validation)
|
|
20
|
+
import Html
|
|
21
|
+
import Html.Styled
|
|
22
|
+
import Pages.Internal.Msg
|
|
23
|
+
import Pages.Transition
|
|
24
|
+
import PagesMsg exposing (PagesMsg)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
{-| -}
|
|
28
|
+
type alias FormWithServerValidations error combined input view =
|
|
29
|
+
Form.Form
|
|
30
|
+
error
|
|
31
|
+
{ combine :
|
|
32
|
+
Validation
|
|
33
|
+
error
|
|
34
|
+
(BackendTask FatalError (Validation error combined Never Never))
|
|
35
|
+
Never
|
|
36
|
+
Never
|
|
37
|
+
, view : Form.Context error input -> view
|
|
38
|
+
}
|
|
39
|
+
(BackendTask FatalError (Validation error combined Never Never))
|
|
40
|
+
input
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
{-| -}
|
|
44
|
+
type alias Handler error combined =
|
|
45
|
+
Form.Handler.Handler error (BackendTask FatalError (Validation.Validation error combined Never Never))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
{-| -}
|
|
49
|
+
type Strategy
|
|
50
|
+
= Parallel
|
|
51
|
+
| Serial
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
{-| -}
|
|
55
|
+
renderHtml :
|
|
56
|
+
List (Html.Attribute (PagesMsg userMsg))
|
|
57
|
+
-> Strategy
|
|
58
|
+
-> Form.Options error parsed input userMsg
|
|
59
|
+
->
|
|
60
|
+
{ --path : Path
|
|
61
|
+
--, url : Maybe PageUrl
|
|
62
|
+
--, action : Maybe action
|
|
63
|
+
app
|
|
64
|
+
| pageFormState : Form.Model
|
|
65
|
+
, transition : Maybe Pages.Transition.Transition
|
|
66
|
+
, fetchers : Dict String (Pages.Transition.FetcherState (Maybe action))
|
|
67
|
+
}
|
|
68
|
+
-> Form.Form error { combine : Validation error parsed named constraints, view : Form.Context error input -> List (Html.Html (PagesMsg userMsg)) } parsed input
|
|
69
|
+
-> Html.Html (PagesMsg userMsg)
|
|
70
|
+
renderHtml attrs strategy options_ app form_ =
|
|
71
|
+
form_
|
|
72
|
+
|> Form.renderHtml
|
|
73
|
+
{ state = app.pageFormState
|
|
74
|
+
, submitting =
|
|
75
|
+
(case app.fetchers |> Dict.get options_.id of
|
|
76
|
+
Just { status } ->
|
|
77
|
+
case status of
|
|
78
|
+
Pages.Transition.FetcherComplete _ ->
|
|
79
|
+
False
|
|
80
|
+
|
|
81
|
+
Pages.Transition.FetcherSubmitting ->
|
|
82
|
+
True
|
|
83
|
+
|
|
84
|
+
Pages.Transition.FetcherReloading _ ->
|
|
85
|
+
True
|
|
86
|
+
|
|
87
|
+
Nothing ->
|
|
88
|
+
False
|
|
89
|
+
)
|
|
90
|
+
|| (case app.transition of
|
|
91
|
+
Just (Pages.Transition.Submitting formData) ->
|
|
92
|
+
formData.id == Just options_.id
|
|
93
|
+
|
|
94
|
+
Just (Pages.Transition.LoadAfterSubmit submitData _ _) ->
|
|
95
|
+
submitData.id == Just options_.id
|
|
96
|
+
|
|
97
|
+
Just (Pages.Transition.Loading _ _) ->
|
|
98
|
+
False
|
|
99
|
+
|
|
100
|
+
Nothing ->
|
|
101
|
+
False
|
|
102
|
+
)
|
|
103
|
+
, toMsg = Pages.Internal.Msg.FormMsg
|
|
104
|
+
}
|
|
105
|
+
{ id = options_.id
|
|
106
|
+
, method = options_.method
|
|
107
|
+
, input = options_.input
|
|
108
|
+
, serverResponse = options_.serverResponse
|
|
109
|
+
, action = options_.action
|
|
110
|
+
, onSubmit =
|
|
111
|
+
Just
|
|
112
|
+
(\submission ->
|
|
113
|
+
case submission.parsed of
|
|
114
|
+
Form.Valid _ ->
|
|
115
|
+
Pages.Internal.Msg.Submit
|
|
116
|
+
{ useFetcher = strategy == Parallel
|
|
117
|
+
, action = submission.action
|
|
118
|
+
, fields = submission.fields
|
|
119
|
+
, method = submission.method
|
|
120
|
+
, msg =
|
|
121
|
+
options_.onSubmit
|
|
122
|
+
|> Maybe.map
|
|
123
|
+
(\onSubmit -> onSubmit submission)
|
|
124
|
+
, id = options_.id
|
|
125
|
+
, valid = True
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
Form.Invalid _ _ ->
|
|
129
|
+
Pages.Internal.Msg.Submit
|
|
130
|
+
{ useFetcher = strategy == Parallel
|
|
131
|
+
, action = submission.action
|
|
132
|
+
, method = submission.method
|
|
133
|
+
, fields = submission.fields
|
|
134
|
+
, msg = options_.onSubmit |> Maybe.map (\onSubmit -> onSubmit submission)
|
|
135
|
+
, id = options_.id
|
|
136
|
+
, valid = False
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
attrs
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
{-| -}
|
|
144
|
+
renderStyledHtml :
|
|
145
|
+
List (Html.Styled.Attribute (PagesMsg userMsg))
|
|
146
|
+
-> Strategy
|
|
147
|
+
-> Form.Options error parsed input userMsg
|
|
148
|
+
->
|
|
149
|
+
{ --path : Path
|
|
150
|
+
--, url : Maybe PageUrl
|
|
151
|
+
--, action : Maybe action
|
|
152
|
+
app
|
|
153
|
+
| pageFormState : Form.Model
|
|
154
|
+
, transition : Maybe Pages.Transition.Transition
|
|
155
|
+
, fetchers : Dict String (Pages.Transition.FetcherState (Maybe action))
|
|
156
|
+
}
|
|
157
|
+
-> Form.Form error { combine : Validation error parsed named constraints, view : Form.Context error input -> List (Html.Styled.Html (PagesMsg userMsg)) } parsed input
|
|
158
|
+
-> Html.Styled.Html (PagesMsg userMsg)
|
|
159
|
+
renderStyledHtml attrs strategy options_ app form_ =
|
|
160
|
+
form_
|
|
161
|
+
|> Form.renderStyledHtml
|
|
162
|
+
{ state = app.pageFormState
|
|
163
|
+
, toMsg = Pages.Internal.Msg.FormMsg
|
|
164
|
+
, submitting =
|
|
165
|
+
(case app.fetchers |> Dict.get options_.id of
|
|
166
|
+
Just { status } ->
|
|
167
|
+
case status of
|
|
168
|
+
Pages.Transition.FetcherComplete _ ->
|
|
169
|
+
False
|
|
170
|
+
|
|
171
|
+
Pages.Transition.FetcherSubmitting ->
|
|
172
|
+
True
|
|
173
|
+
|
|
174
|
+
Pages.Transition.FetcherReloading _ ->
|
|
175
|
+
True
|
|
176
|
+
|
|
177
|
+
Nothing ->
|
|
178
|
+
False
|
|
179
|
+
)
|
|
180
|
+
|| (case app.transition of
|
|
181
|
+
Just (Pages.Transition.Submitting formData) ->
|
|
182
|
+
formData.id == Just options_.id
|
|
183
|
+
|
|
184
|
+
Just (Pages.Transition.LoadAfterSubmit submitData _ _) ->
|
|
185
|
+
submitData.id == Just options_.id
|
|
186
|
+
|
|
187
|
+
Just (Pages.Transition.Loading _ _) ->
|
|
188
|
+
False
|
|
189
|
+
|
|
190
|
+
Nothing ->
|
|
191
|
+
False
|
|
192
|
+
)
|
|
193
|
+
}
|
|
194
|
+
{ id = options_.id
|
|
195
|
+
, method = options_.method
|
|
196
|
+
, input = options_.input
|
|
197
|
+
, serverResponse = options_.serverResponse
|
|
198
|
+
, action = options_.action
|
|
199
|
+
, onSubmit =
|
|
200
|
+
Just
|
|
201
|
+
(\submission ->
|
|
202
|
+
case submission.parsed of
|
|
203
|
+
Form.Valid _ ->
|
|
204
|
+
Pages.Internal.Msg.Submit
|
|
205
|
+
{ useFetcher = strategy == Parallel
|
|
206
|
+
, action = submission.action
|
|
207
|
+
, fields = submission.fields
|
|
208
|
+
, method = submission.method
|
|
209
|
+
, msg =
|
|
210
|
+
options_.onSubmit
|
|
211
|
+
|> Maybe.map
|
|
212
|
+
(\onSubmit -> onSubmit submission)
|
|
213
|
+
, id = options_.id
|
|
214
|
+
, valid = True
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
Form.Invalid _ _ ->
|
|
218
|
+
Pages.Internal.Msg.Submit
|
|
219
|
+
{ useFetcher = strategy == Parallel
|
|
220
|
+
, action = submission.action
|
|
221
|
+
, fields = submission.fields
|
|
222
|
+
, method = submission.method
|
|
223
|
+
, msg = options_.onSubmit |> Maybe.map (\onSubmit -> onSubmit submission)
|
|
224
|
+
, id = options_.id
|
|
225
|
+
, valid = False
|
|
226
|
+
}
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
attrs
|