elm-pages 3.0.0-beta.33 → 3.0.0-beta.35
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 +165 -134
- 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/cli.js +5 -9
- package/generator/src/compatibility-key.js +2 -2
- package/generator/static-code/elm-pages.js +10 -0
- package/package.json +3 -3
- package/src/BackendTask/File.elm +43 -13
- package/src/BackendTask/Internal/Request.elm +48 -3
- package/src/FatalError.elm +4 -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 +14 -8
- package/src/Pages/Internal/Platform/StaticResponses.elm +1 -7
- 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/Form/FieldStatus.elm
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
module Form.FieldStatus exposing (FieldStatus(..), fieldStatusToString)
|
|
2
|
-
|
|
3
|
-
{-| elm-pages manages the client-side state of fields, including Status which you can use to determine when
|
|
4
|
-
in the user's workflow to show validation errors.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Field Status
|
|
8
|
-
|
|
9
|
-
@docs FieldStatus, fieldStatusToString
|
|
10
|
-
|
|
11
|
-
-}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
{-| -}
|
|
15
|
-
type FieldStatus
|
|
16
|
-
= NotVisited
|
|
17
|
-
| Focused
|
|
18
|
-
| Changed
|
|
19
|
-
| Blurred
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{-| -}
|
|
23
|
-
fieldStatusToString : FieldStatus -> String
|
|
24
|
-
fieldStatusToString fieldStatus =
|
|
25
|
-
case fieldStatus of
|
|
26
|
-
NotVisited ->
|
|
27
|
-
"NotVisited"
|
|
28
|
-
|
|
29
|
-
Focused ->
|
|
30
|
-
"Focused"
|
|
31
|
-
|
|
32
|
-
Changed ->
|
|
33
|
-
"Changed"
|
|
34
|
-
|
|
35
|
-
Blurred ->
|
|
36
|
-
"Blurred"
|
package/src/Form/FieldView.elm
DELETED
|
@@ -1,497 +0,0 @@
|
|
|
1
|
-
module Form.FieldView exposing
|
|
2
|
-
( Input(..), InputType(..), Options(..), input, inputTypeToString, radio, toHtmlProperties, Hidden(..), select, valueButton
|
|
3
|
-
, radioStyled, inputStyled, valueButtonStyled
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
{-|
|
|
7
|
-
|
|
8
|
-
@docs Input, InputType, Options, input, inputTypeToString, radio, toHtmlProperties, Hidden, select, valueButton
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Html.Styled Helpers
|
|
12
|
-
|
|
13
|
-
@docs radioStyled, inputStyled, valueButtonStyled
|
|
14
|
-
|
|
15
|
-
-}
|
|
16
|
-
|
|
17
|
-
import Form.Validation
|
|
18
|
-
import Html exposing (Html)
|
|
19
|
-
import Html.Attributes as Attr
|
|
20
|
-
import Html.Styled
|
|
21
|
-
import Html.Styled.Attributes as StyledAttr
|
|
22
|
-
import Json.Encode as Encode
|
|
23
|
-
import Pages.Internal.Form exposing (Validation(..), ViewField)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
{-| -}
|
|
27
|
-
type InputType
|
|
28
|
-
= Text
|
|
29
|
-
| Number
|
|
30
|
-
-- TODO should range have arguments for initial, min, and max?
|
|
31
|
-
| Range
|
|
32
|
-
| Radio
|
|
33
|
-
-- TODO should submit be a special type, or an Input type?
|
|
34
|
-
-- TODO have an option for a submit with a name/value?
|
|
35
|
-
| Date
|
|
36
|
-
| Time
|
|
37
|
-
| Checkbox
|
|
38
|
-
| Tel
|
|
39
|
-
| Search
|
|
40
|
-
| Password
|
|
41
|
-
| Email
|
|
42
|
-
| Url
|
|
43
|
-
| Textarea { rows : Maybe Int, cols : Maybe Int }
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{-| -}
|
|
47
|
-
inputTypeToString : InputType -> String
|
|
48
|
-
inputTypeToString inputType =
|
|
49
|
-
case inputType of
|
|
50
|
-
Text ->
|
|
51
|
-
"text"
|
|
52
|
-
|
|
53
|
-
Textarea _ ->
|
|
54
|
-
"text"
|
|
55
|
-
|
|
56
|
-
Number ->
|
|
57
|
-
"number"
|
|
58
|
-
|
|
59
|
-
Range ->
|
|
60
|
-
"range"
|
|
61
|
-
|
|
62
|
-
Radio ->
|
|
63
|
-
"radio"
|
|
64
|
-
|
|
65
|
-
Date ->
|
|
66
|
-
"date"
|
|
67
|
-
|
|
68
|
-
Time ->
|
|
69
|
-
"time"
|
|
70
|
-
|
|
71
|
-
Checkbox ->
|
|
72
|
-
"checkbox"
|
|
73
|
-
|
|
74
|
-
Tel ->
|
|
75
|
-
"tel"
|
|
76
|
-
|
|
77
|
-
Search ->
|
|
78
|
-
"search"
|
|
79
|
-
|
|
80
|
-
Password ->
|
|
81
|
-
"password"
|
|
82
|
-
|
|
83
|
-
Email ->
|
|
84
|
-
"email"
|
|
85
|
-
|
|
86
|
-
Url ->
|
|
87
|
-
"url"
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
{-| -}
|
|
91
|
-
type Input
|
|
92
|
-
= Input InputType
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
{-| There are no render helpers for hidden fields because the `Form.renderHtml` helper functions automatically render hidden fields for you.
|
|
96
|
-
-}
|
|
97
|
-
type Hidden
|
|
98
|
-
= Hidden
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
{-| -}
|
|
102
|
-
type Options a
|
|
103
|
-
= Options (String -> Maybe a) (List String)
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{-| Gives you a submit button that will submit the form with a specific value for the given Field.
|
|
107
|
-
-}
|
|
108
|
-
valueButton :
|
|
109
|
-
String
|
|
110
|
-
-> List (Html.Attribute msg)
|
|
111
|
-
-> List (Html msg)
|
|
112
|
-
-> Form.Validation.Field error parsed kind
|
|
113
|
-
-> Html msg
|
|
114
|
-
valueButton exactValue attrs children (Validation viewField fieldName _) =
|
|
115
|
-
let
|
|
116
|
-
justViewField : ViewField kind
|
|
117
|
-
justViewField =
|
|
118
|
-
expectViewField viewField
|
|
119
|
-
|
|
120
|
-
rawField : { name : String, value : Maybe String, kind : ( kind, List ( String, Encode.Value ) ) }
|
|
121
|
-
rawField =
|
|
122
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
123
|
-
, value = Just exactValue --justViewField.value
|
|
124
|
-
, kind = justViewField.kind
|
|
125
|
-
}
|
|
126
|
-
in
|
|
127
|
-
case rawField.kind of
|
|
128
|
-
( _, properties ) ->
|
|
129
|
-
Html.button
|
|
130
|
-
(attrs
|
|
131
|
-
++ toHtmlProperties properties
|
|
132
|
-
++ [ Attr.value (rawField.value |> Maybe.withDefault "")
|
|
133
|
-
, Attr.name rawField.name
|
|
134
|
-
]
|
|
135
|
-
)
|
|
136
|
-
children
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
{-| Gives you a submit button that will submit the form with a specific value for the given Field.
|
|
140
|
-
-}
|
|
141
|
-
valueButtonStyled :
|
|
142
|
-
String
|
|
143
|
-
-> List (Html.Styled.Attribute msg)
|
|
144
|
-
-> List (Html.Styled.Html msg)
|
|
145
|
-
-> Form.Validation.Field error parsed kind
|
|
146
|
-
-> Html.Styled.Html msg
|
|
147
|
-
valueButtonStyled exactValue attrs children (Validation viewField fieldName _) =
|
|
148
|
-
let
|
|
149
|
-
justViewField : ViewField kind
|
|
150
|
-
justViewField =
|
|
151
|
-
expectViewField viewField
|
|
152
|
-
|
|
153
|
-
rawField : { name : String, value : Maybe String, kind : ( kind, List ( String, Encode.Value ) ) }
|
|
154
|
-
rawField =
|
|
155
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
156
|
-
, value = Just exactValue
|
|
157
|
-
, kind = justViewField.kind
|
|
158
|
-
}
|
|
159
|
-
in
|
|
160
|
-
case rawField.kind of
|
|
161
|
-
( _, properties ) ->
|
|
162
|
-
Html.Styled.button
|
|
163
|
-
(attrs
|
|
164
|
-
++ (toHtmlProperties properties |> List.map StyledAttr.fromUnstyled)
|
|
165
|
-
++ ([ Attr.value (rawField.value |> Maybe.withDefault "")
|
|
166
|
-
, Attr.name rawField.name
|
|
167
|
-
]
|
|
168
|
-
|> List.map StyledAttr.fromUnstyled
|
|
169
|
-
)
|
|
170
|
-
)
|
|
171
|
-
children
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
{-| -}
|
|
175
|
-
input :
|
|
176
|
-
List (Html.Attribute msg)
|
|
177
|
-
-> Form.Validation.Field error parsed Input
|
|
178
|
-
-> Html msg
|
|
179
|
-
input attrs (Validation viewField fieldName _) =
|
|
180
|
-
let
|
|
181
|
-
justViewField : ViewField Input
|
|
182
|
-
justViewField =
|
|
183
|
-
expectViewField viewField
|
|
184
|
-
|
|
185
|
-
rawField : { name : String, value : Maybe String, kind : ( Input, List ( String, Encode.Value ) ) }
|
|
186
|
-
rawField =
|
|
187
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
188
|
-
, value = justViewField.value
|
|
189
|
-
, kind = justViewField.kind
|
|
190
|
-
}
|
|
191
|
-
in
|
|
192
|
-
case rawField.kind of
|
|
193
|
-
( Input (Textarea { rows, cols }), properties ) ->
|
|
194
|
-
Html.textarea
|
|
195
|
-
(attrs
|
|
196
|
-
++ toHtmlProperties properties
|
|
197
|
-
++ ([ rows |> Maybe.map Attr.rows
|
|
198
|
-
, cols |> Maybe.map Attr.cols
|
|
199
|
-
]
|
|
200
|
-
|> List.filterMap identity
|
|
201
|
-
)
|
|
202
|
-
++ [ Attr.name rawField.name
|
|
203
|
-
]
|
|
204
|
-
)
|
|
205
|
-
[ -- textarea does not support the `value` attribute, but instead uses inner text for its form value
|
|
206
|
-
Html.text (rawField.value |> Maybe.withDefault "")
|
|
207
|
-
]
|
|
208
|
-
|
|
209
|
-
( Input inputType, properties ) ->
|
|
210
|
-
Html.input
|
|
211
|
-
(attrs
|
|
212
|
-
++ toHtmlProperties properties
|
|
213
|
-
++ [ (case inputType of
|
|
214
|
-
Checkbox ->
|
|
215
|
-
Attr.checked ((rawField.value |> Maybe.withDefault "") == "on")
|
|
216
|
-
|
|
217
|
-
_ ->
|
|
218
|
-
Attr.value (rawField.value |> Maybe.withDefault "")
|
|
219
|
-
-- TODO is this an okay default?
|
|
220
|
-
)
|
|
221
|
-
, Attr.name rawField.name
|
|
222
|
-
, inputType |> inputTypeToString |> Attr.type_
|
|
223
|
-
]
|
|
224
|
-
)
|
|
225
|
-
[]
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
{-| -}
|
|
229
|
-
inputStyled :
|
|
230
|
-
List (Html.Styled.Attribute msg)
|
|
231
|
-
-> Form.Validation.Field error parsed Input
|
|
232
|
-
-> Html.Styled.Html msg
|
|
233
|
-
inputStyled attrs (Validation viewField fieldName _) =
|
|
234
|
-
let
|
|
235
|
-
justViewField : ViewField Input
|
|
236
|
-
justViewField =
|
|
237
|
-
expectViewField viewField
|
|
238
|
-
|
|
239
|
-
rawField : { name : String, value : Maybe String, kind : ( Input, List ( String, Encode.Value ) ) }
|
|
240
|
-
rawField =
|
|
241
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
242
|
-
, value = justViewField.value
|
|
243
|
-
, kind = justViewField.kind
|
|
244
|
-
}
|
|
245
|
-
in
|
|
246
|
-
case rawField.kind of
|
|
247
|
-
( Input (Textarea { rows, cols }), properties ) ->
|
|
248
|
-
Html.Styled.textarea
|
|
249
|
-
(attrs
|
|
250
|
-
++ (toHtmlProperties properties |> List.map StyledAttr.fromUnstyled)
|
|
251
|
-
++ ([ rows |> Maybe.map StyledAttr.rows
|
|
252
|
-
, cols |> Maybe.map StyledAttr.cols
|
|
253
|
-
]
|
|
254
|
-
|> List.filterMap identity
|
|
255
|
-
)
|
|
256
|
-
++ ([ Attr.name rawField.name
|
|
257
|
-
]
|
|
258
|
-
|> List.map StyledAttr.fromUnstyled
|
|
259
|
-
)
|
|
260
|
-
)
|
|
261
|
-
[ -- textarea does not support the `value` attribute, but instead uses inner text for its form value
|
|
262
|
-
Html.Styled.text (rawField.value |> Maybe.withDefault "")
|
|
263
|
-
]
|
|
264
|
-
|
|
265
|
-
( Input inputType, properties ) ->
|
|
266
|
-
Html.Styled.input
|
|
267
|
-
(attrs
|
|
268
|
-
++ (toHtmlProperties properties |> List.map StyledAttr.fromUnstyled)
|
|
269
|
-
++ ([ (case inputType of
|
|
270
|
-
Checkbox ->
|
|
271
|
-
Attr.checked ((rawField.value |> Maybe.withDefault "") == "on")
|
|
272
|
-
|
|
273
|
-
_ ->
|
|
274
|
-
Attr.value (rawField.value |> Maybe.withDefault "")
|
|
275
|
-
-- TODO is this an okay default?
|
|
276
|
-
)
|
|
277
|
-
, Attr.name rawField.name
|
|
278
|
-
, inputType |> inputTypeToString |> Attr.type_
|
|
279
|
-
]
|
|
280
|
-
|> List.map StyledAttr.fromUnstyled
|
|
281
|
-
)
|
|
282
|
-
)
|
|
283
|
-
[]
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
{-| -}
|
|
287
|
-
select :
|
|
288
|
-
List (Html.Attribute msg)
|
|
289
|
-
->
|
|
290
|
-
(parsed
|
|
291
|
-
->
|
|
292
|
-
( List (Html.Attribute msg)
|
|
293
|
-
, String
|
|
294
|
-
)
|
|
295
|
-
)
|
|
296
|
-
-> Form.Validation.Field error parsed2 (Options parsed)
|
|
297
|
-
-> Html msg
|
|
298
|
-
select selectAttrs enumToOption (Validation viewField fieldName _) =
|
|
299
|
-
let
|
|
300
|
-
justViewField : ViewField (Options parsed)
|
|
301
|
-
justViewField =
|
|
302
|
-
viewField |> expectViewField
|
|
303
|
-
|
|
304
|
-
rawField : { name : String, value : Maybe String, kind : ( Options parsed, List ( String, Encode.Value ) ) }
|
|
305
|
-
rawField =
|
|
306
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
307
|
-
, value = justViewField.value
|
|
308
|
-
, kind = justViewField.kind
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
(Options parseValue possibleValues) =
|
|
312
|
-
rawField.kind |> Tuple.first
|
|
313
|
-
in
|
|
314
|
-
Html.select
|
|
315
|
-
(selectAttrs
|
|
316
|
-
++ [ Attr.value (rawField.value |> Maybe.withDefault "")
|
|
317
|
-
, Attr.name rawField.name
|
|
318
|
-
]
|
|
319
|
-
)
|
|
320
|
-
(possibleValues
|
|
321
|
-
|> List.filterMap
|
|
322
|
-
(\possibleValue ->
|
|
323
|
-
let
|
|
324
|
-
parsed : Maybe parsed
|
|
325
|
-
parsed =
|
|
326
|
-
possibleValue
|
|
327
|
-
|> parseValue
|
|
328
|
-
in
|
|
329
|
-
case parsed of
|
|
330
|
-
Just justParsed ->
|
|
331
|
-
let
|
|
332
|
-
( optionAttrs, content ) =
|
|
333
|
-
enumToOption justParsed
|
|
334
|
-
in
|
|
335
|
-
Html.option (Attr.value possibleValue :: optionAttrs) [ Html.text content ]
|
|
336
|
-
|> Just
|
|
337
|
-
|
|
338
|
-
Nothing ->
|
|
339
|
-
Nothing
|
|
340
|
-
)
|
|
341
|
-
)
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
{-| -}
|
|
345
|
-
radio :
|
|
346
|
-
List (Html.Attribute msg)
|
|
347
|
-
->
|
|
348
|
-
(parsed
|
|
349
|
-
-> (List (Html.Attribute msg) -> Html msg)
|
|
350
|
-
-> Html msg
|
|
351
|
-
)
|
|
352
|
-
-> Form.Validation.Field error parsed2 (Options parsed)
|
|
353
|
-
-> Html msg
|
|
354
|
-
radio selectAttrs enumToOption (Validation viewField fieldName _) =
|
|
355
|
-
let
|
|
356
|
-
justViewField : ViewField (Options parsed)
|
|
357
|
-
justViewField =
|
|
358
|
-
viewField |> expectViewField
|
|
359
|
-
|
|
360
|
-
rawField : { name : String, value : Maybe String, kind : ( Options parsed, List ( String, Encode.Value ) ) }
|
|
361
|
-
rawField =
|
|
362
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
363
|
-
, value = justViewField.value
|
|
364
|
-
, kind = justViewField.kind
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
(Options parseValue possibleValues) =
|
|
368
|
-
rawField.kind |> Tuple.first
|
|
369
|
-
in
|
|
370
|
-
Html.fieldset
|
|
371
|
-
(selectAttrs
|
|
372
|
-
++ [ Attr.value (rawField.value |> Maybe.withDefault "")
|
|
373
|
-
, Attr.name rawField.name
|
|
374
|
-
]
|
|
375
|
-
)
|
|
376
|
-
(possibleValues
|
|
377
|
-
|> List.filterMap
|
|
378
|
-
(\possibleValue ->
|
|
379
|
-
let
|
|
380
|
-
parsed : Maybe parsed
|
|
381
|
-
parsed =
|
|
382
|
-
possibleValue
|
|
383
|
-
|> parseValue
|
|
384
|
-
in
|
|
385
|
-
case parsed of
|
|
386
|
-
Just justParsed ->
|
|
387
|
-
let
|
|
388
|
-
renderedElement : Html msg
|
|
389
|
-
renderedElement =
|
|
390
|
-
enumToOption justParsed
|
|
391
|
-
(\userHtmlAttrs ->
|
|
392
|
-
Html.input
|
|
393
|
-
([ Attr.type_ "radio"
|
|
394
|
-
, Attr.value possibleValue
|
|
395
|
-
, Attr.name rawField.name
|
|
396
|
-
, Attr.checked (rawField.value == Just possibleValue)
|
|
397
|
-
]
|
|
398
|
-
++ userHtmlAttrs
|
|
399
|
-
)
|
|
400
|
-
[]
|
|
401
|
-
)
|
|
402
|
-
in
|
|
403
|
-
Just renderedElement
|
|
404
|
-
|
|
405
|
-
Nothing ->
|
|
406
|
-
Nothing
|
|
407
|
-
)
|
|
408
|
-
)
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
expectViewField : Maybe (ViewField kind) -> ViewField kind
|
|
412
|
-
expectViewField viewField =
|
|
413
|
-
case viewField of
|
|
414
|
-
Just justViewField ->
|
|
415
|
-
justViewField
|
|
416
|
-
|
|
417
|
-
Nothing ->
|
|
418
|
-
expectViewField viewField
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
{-| -}
|
|
422
|
-
radioStyled :
|
|
423
|
-
List (Html.Styled.Attribute msg)
|
|
424
|
-
->
|
|
425
|
-
(parsed
|
|
426
|
-
-> (List (Html.Styled.Attribute msg) -> Html.Styled.Html msg)
|
|
427
|
-
-> Html.Styled.Html msg
|
|
428
|
-
)
|
|
429
|
-
-> Form.Validation.Field error parsed2 (Options parsed)
|
|
430
|
-
-> Html.Styled.Html msg
|
|
431
|
-
radioStyled selectAttrs enumToOption (Validation viewField fieldName _) =
|
|
432
|
-
let
|
|
433
|
-
justViewField : ViewField (Options parsed)
|
|
434
|
-
justViewField =
|
|
435
|
-
viewField |> expectViewField
|
|
436
|
-
|
|
437
|
-
rawField : { name : String, value : Maybe String, kind : ( Options parsed, List ( String, Encode.Value ) ) }
|
|
438
|
-
rawField =
|
|
439
|
-
{ name = fieldName |> Maybe.withDefault ""
|
|
440
|
-
, value = justViewField.value
|
|
441
|
-
, kind = justViewField.kind
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
(Options parseValue possibleValues) =
|
|
445
|
-
rawField.kind |> Tuple.first
|
|
446
|
-
in
|
|
447
|
-
Html.Styled.fieldset
|
|
448
|
-
(selectAttrs
|
|
449
|
-
++ [ StyledAttr.value (rawField.value |> Maybe.withDefault "")
|
|
450
|
-
, StyledAttr.name rawField.name
|
|
451
|
-
]
|
|
452
|
-
)
|
|
453
|
-
(possibleValues
|
|
454
|
-
|> List.filterMap
|
|
455
|
-
(\possibleValue ->
|
|
456
|
-
let
|
|
457
|
-
parsed : Maybe parsed
|
|
458
|
-
parsed =
|
|
459
|
-
possibleValue
|
|
460
|
-
|> parseValue
|
|
461
|
-
in
|
|
462
|
-
case parsed of
|
|
463
|
-
Just justParsed ->
|
|
464
|
-
let
|
|
465
|
-
renderedElement : Html.Styled.Html msg
|
|
466
|
-
renderedElement =
|
|
467
|
-
enumToOption justParsed
|
|
468
|
-
(\userHtmlAttrs ->
|
|
469
|
-
Html.Styled.input
|
|
470
|
-
(([ Attr.type_ "radio"
|
|
471
|
-
, Attr.value possibleValue
|
|
472
|
-
, Attr.name rawField.name
|
|
473
|
-
, Attr.checked (rawField.value == Just possibleValue)
|
|
474
|
-
]
|
|
475
|
-
|> List.map StyledAttr.fromUnstyled
|
|
476
|
-
)
|
|
477
|
-
++ userHtmlAttrs
|
|
478
|
-
)
|
|
479
|
-
[]
|
|
480
|
-
)
|
|
481
|
-
in
|
|
482
|
-
Just renderedElement
|
|
483
|
-
|
|
484
|
-
Nothing ->
|
|
485
|
-
Nothing
|
|
486
|
-
)
|
|
487
|
-
)
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
{-| -}
|
|
491
|
-
toHtmlProperties : List ( String, Encode.Value ) -> List (Html.Attribute msg)
|
|
492
|
-
toHtmlProperties properties =
|
|
493
|
-
properties
|
|
494
|
-
|> List.map
|
|
495
|
-
(\( key, value ) ->
|
|
496
|
-
Attr.property key value
|
|
497
|
-
)
|
package/src/Form/FormData.elm
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module Form.FormData exposing (FormData, Method(..))
|
|
2
|
-
|
|
3
|
-
{-|
|
|
4
|
-
|
|
5
|
-
@docs FormData, Method
|
|
6
|
-
|
|
7
|
-
-}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{-| -}
|
|
11
|
-
type alias FormData =
|
|
12
|
-
{ fields : List ( String, String )
|
|
13
|
-
, method : Method
|
|
14
|
-
, action : String
|
|
15
|
-
, id : Maybe String
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{-| -}
|
|
20
|
-
type Method
|
|
21
|
-
= Get
|
|
22
|
-
| Post
|