-
Notifications
You must be signed in to change notification settings - Fork 19
/
Program.fs
83 lines (65 loc) · 3.5 KB
/
Program.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module Program
open System.IO
open Feliz.Generator
let flip f x y = f y x
let addChildrenComponentOverload (comp: Component) =
comp
|> Component.addOverload (
ComponentOverload.create "children: #seq<ReactElement>" (sprintf "Feliz.%s.children (children :> ReactElement seq)" comp.MethodName)
)
let addChildrenProp =
Component.addProp (
Prop.create "children" "children"
|> Prop.setDocs ["Defines the text content of the element."]
|> Prop.addRegularOverload (RegularPropOverload.create "(elements: Fable.React.ReactElement seq)" "(Interop.reactApi.Children.toArray elements)")
|> Prop.addRegularOverload (RegularPropOverload.create "(element: Fable.React.ReactElement seq)" "element")
// TODO: more children prop overloads
)
let standardStringPropOverload = RegularPropOverload.create "(value: string)" "value"
let components = [
// Meta component without overloads, only used for global props (will not appear in Html.fs)
Component.createTag "prop" "NOT_USED"
|> Component.removeDefaultOverload
|> Component.addProp (
Prop.create "accesskey" "accesskey"
|> Prop.setDocs ["Defines a keyboard shortcut to activate or add focus to the element."]
|> Prop.addRegularOverload standardStringPropOverload
)
|> Component.addProp (
Prop.create "autocapitalize" "autocapitalize"
|> Prop.setDocs ["Controls whether and how text input is automatically capitalized as it is entered/edited by the user."]
|> Prop.addEnumOverload (EnumPropOverload.create "none" "none" |> EnumPropOverload.setDocs ["No autocapitalization is applied (all letters default to lowercase)"])
|> Prop.addEnumOverload (EnumPropOverload.create "off" "off" |> EnumPropOverload.setDocs ["Alias for `none`."])
|> Prop.addEnumOverload (EnumPropOverload.create "sentences" "sentences" |> EnumPropOverload.setDocs ["The first letter of each sentence defaults to a capital letter; all other letters default to lowercase"])
|> Prop.addEnumOverload (EnumPropOverload.create "on" "on" |> EnumPropOverload.setDocs ["Alias for `sentences`."])
|> Prop.addEnumOverload (EnumPropOverload.create "words" "words" |> EnumPropOverload.setDocs ["The first letter of each word defaults to a capital letter; all other letters default to lowercase"])
|> Prop.addEnumOverload (EnumPropOverload.create "characters" "characters" |> EnumPropOverload.setDocs ["All letters should default to uppercase"])
)
// TODO: Add other other global attributes similarly
// Form
Component.createTag "form" "form"
|> Component.setDocs ["Represents a document section that contains interactive controls for submitting information to a web server."]
|> Component.inheritsPropsFrom "prop"
|> addChildrenProp
|> addChildrenComponentOverload
|> Component.addProp (
Prop.create "accept" "accept"
|> Prop.setDocs ["List of types the server accepts, typically a file type."]
|> Prop.addRegularOverload standardStringPropOverload
)
|> Component.addProp (
Prop.create "action" "action"
|> Prop.setDocs ["The URI of a program that processes the information submitted via the form."]
|> Prop.addRegularOverload standardStringPropOverload
)
// TODO: Other form props
// TODO: other components
]
let api =
(ComponentApi.create "Feliz" "Html", components)
||> List.fold (flip ComponentApi.addComponent)
[<EntryPoint>]
let main argv =
File.WriteAllText(@"..\..\..\OUTPUT_COMPONENTS.fs", Render.componentDocument api)
File.WriteAllText(@"..\..\..\OUTPUT_PROPS.fs", Render.propsDocument api)
0