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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
use super::{AttributesOnly, HtmlElementUpdater, StaticAttributes, StaticAttributesOnly};
use crate::component::Component;

#[cfg(test)]
use crate::render::html::TestHtmlMethods;

make_trait_for_attributes_with_predefined_values! {
TestStructs: (TestHtmlMethods)
TraitName: HamsWithPredefinedValues
{
    AutoCapitalizeAttributeValue
    AutoCapitalize {
        Off => "off",
        On => "on",
        Sentences => "sentences",
        Words => "words",
        Characters => "characters",
    }
    {}
}
{
    AutoCompleteAttributeValue
    AutoComplete {
        On => "on",
        Off => "off",
    }
    { auto_complete "autocomplete" }
}
{
    ButtonTypeAttributeValue
    ButtonType {
        Button => "button",
        Submit => "submit",
        Reset => "reset",
    }
    {}
}
{
    CrossOriginAttributeValue
    CrossOrigin {
        Anonymous => "anonymous",
        UseCredentials => "use-credentials",
    }
    { cross_origin "crossorigin" }
}
{
    DecodingAttributeValue
    Decoding {
        Sync => "sync",
        Async => "async",
        Auto => "auto",
    }
    { decoding }
}
{
    DirAttributeValue
    Dir {
        LeftToRight => "ltr",
        RightToLeft => "rtl",
        Auto => "auto",
    }
    {}
}
{
    EncTypeAttributeValue
    EncType {
        ComponentXWwwFormUrlEncoded => "Component/x-www-form-urlencoded",
        MultiPartFormData => "multipart/form-data",
        TextPlain => "text/plain",
    }
    {
        enc_type "enctype"
        form_enc_type "formenctype"
    }
}
{
    FormMethodAttributeValue
    FormMethod {
        Post => "post",
        Get => "get",
    }
    {
        form_method "formmethod"
        method
    }
}
{
    InputModeAttributeValue
    InputMode {
        None => "none",
        Text => "text",
        Decimal => "decimal",
        Numeric => "numeric",
        Tel => "tel",
        Search => "search",
        Email => "email",
        Url => "url",
    }
    {}
}
{
    InputTypeAttributeValue
    InputType {
        Button => "button",
        CheckBox => "checkbox",
        Color => "color",
        Date => "date",
        DateTimeLocal => "datetime-local",
        Email => "email",
        FileUpload => "file",
        Hidden => "hidden",
        ImageButton => "image",
        Month => "month",
        Number => "number",
        Password => "password",
        RadioButton => "radio",
        Range => "range",
        ResetButton => "reset",
        Search => "search",
        SubmitButton => "submit",
        Telephone => "tel",
        Text => "text",
        Time => "time",
        Url => "url",
        Week => "week",
    }
    { r#type "type" }
}
{
    OlTypeAttributeValue
    OlType {
        Number => "1",
        LowerCase => "a",
        UpperCase => "C",
        LowerCaseRoman => "i",
        UpperCaseRoman => "I",
    }
    {}
}
{
    PreLoadAttributeValue
    PreLoad {
        None => "none",
        MetaData => "metadata",
        Auto => "auto",
    }
    { pre_load "preload" }
}
{
    ReferrerPolicyAttributeValue
    ReferrerPolicy {
        NoReferrer => "no-referrer",
        NoReferrerWhenDowngrade => "no-referrer-when-downgrade",
        Origin => "origin",
        OriginWhenCrossOrigin => "origin-when-cross-origin",
        SameOrigin => "same-origin",
        StrictOrigin => "strict-origin",
        StrictOriginWhenCrossOrigin => "strict-origin-when-cross-origin",
        UnsafeUrl => "unsafe-url",
    }
    { referrer_policy "referrerpolicy" }
}
{
    SandboxAttributeValue
    Sandbox {
        AllowForms => "allow-forms",
        AllowModals => "allow-modals",
        AllowOrientationLock => "allow-orientation-lock",
        AllowPointerLock => "allow-pointer-lock",
        AllowPopups => "allow-popups",
        AllowPopupsToEscapeSandbox => "allow-popups-to-escape-sandbox",
        AllowPresentation => "allow-presentation",
        AllowSameOrigin => "allow-same-origin",
        AllowScripts => "allow-scripts",
        // Should we have feature = "experimental" for things like this?
        // allow-storage-access-by-user-activation
        AllowTopNavigation => "allow-top-navigation",
        AllowTopNavigationByUserActivation => "allow-top-navigation-by-user-activation",
        //AllowDownloadsWithoutUserActivation => "allow-downloads-without-user-activation",
    }
    {}
}
{
    SpellCheckAttributeValue
    SpellCheck {
        True => "true",
        False => "false",
        Default => "default",
    }
    {}
}
{
    ThScopeAttributeValue
    ThScope {
        Row => "row",
        Col => "col",
        RowGroup => "rowgroup",
        ColGroup => "colgroup",
        Auto => "auto",
    }
    { scope }
}
{
    TargetAttributeValue
    Target {
        _Self => "_self",
        _Blank => "_blank",
        _Parent => "_parent",
        _Top => "_top",
    }
    {
        form_target "formtarget"
        target
    }
}
{
    TrackKindAttributeValue
    TrackKind {
        Subtitles => "subtitles",
        Captions => "captions",
        Descriptions => "descriptions",
        Chapters => "chapters",
        Metadata => "metadata",
    }
    { kind }
}
{
    WrapAttributeValue
    Wrap {
        Hard => "hard",
        Soft => "soft",
    }
    { wrap }
}
}

impl<'er, C: Component> HamsWithPredefinedValues<C> for HtmlElementUpdater<'er, C> {}
impl<'er, C: Component> HamsWithPredefinedValues<C> for StaticAttributes<'er, C> {}
impl<'er, C: Component> HamsWithPredefinedValues<C> for AttributesOnly<'er, C> {}
impl<'er, C: Component> HamsWithPredefinedValues<C> for StaticAttributesOnly<'er, C> {}