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
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
use crate::elem::{HtmlProp, HtmlProps};
use std::borrow::Cow;
use web_sys::HtmlInputElement;

#[allow(non_camel_case_types)]
#[derive(Clone, PartialEq)]
pub enum InputProp {
    accept(Cow<'static, str>),
    alt(Cow<'static, str>),
    autocomplete(Cow<'static, str>),
    autofocus(bool),
    default_checked(bool),
    checked(bool),
    disabled(bool),
    files(web_sys::FileList),
    form_action(Cow<'static, str>),
    form_enctype(Cow<'static, str>),
    form_method(Cow<'static, str>),
    form_no_validate(bool),
    form_target(Cow<'static, str>),
    height(u32),
    indeterminate(bool),
    input_mode(Cow<'static, str>),
    max(Cow<'static, str>),
    max_length(i32),
    min(Cow<'static, str>),
    min_length(i32),
    multiple(bool),
    name(Cow<'static, str>),
    pattern(Cow<'static, str>),
    placeholder(Cow<'static, str>),
    read_only(bool),
    required(bool),
    size(u32),
    src(Cow<'static, str>),
    step(Cow<'static, str>),
    r#type(Cow<'static, str>),
    default_value(Cow<'static, str>),
    value(Cow<'static, str>),
    value_as_number(f64),
    width(u32),
    align(Cow<'static, str>),
    use_map(Cow<'static, str>),
    webkitdirectory(bool),
}

#[sealed::sealed]
impl crate::elem::HtmlComponent for HtmlInputElement {
    type PropEnum = InputProp;
}
#[sealed::sealed]
impl crate::elem::PropEnum<HtmlInputElement> for InputProp {
    fn unset_on(&self, elem: &HtmlInputElement) {
        match self {
            InputProp::accept(_) => elem.remove_attribute("accept").unwrap(),
            InputProp::alt(_) => elem.remove_attribute("alt").unwrap(),
            InputProp::autocomplete(_) => elem.remove_attribute("autocomplete").unwrap(),
            InputProp::autofocus(_) => elem.remove_attribute("autofocus").unwrap(),
            InputProp::default_checked(_) => elem.remove_attribute("default_checked").unwrap(),
            InputProp::checked(_) => elem.remove_attribute("checked").unwrap(),
            InputProp::disabled(_) => elem.remove_attribute("disabled").unwrap(),
            InputProp::files(_) => elem.set_files(None),
            InputProp::form_action(_) => elem.remove_attribute("form_action").unwrap(),
            InputProp::form_enctype(_) => elem.remove_attribute("form_enctype").unwrap(),
            InputProp::form_method(_) => elem.remove_attribute("form_method").unwrap(),
            InputProp::form_no_validate(_) => elem.remove_attribute("form_no_validate").unwrap(),
            InputProp::form_target(_) => elem.remove_attribute("form_target").unwrap(),
            InputProp::height(_) => elem.remove_attribute("height").unwrap(),
            InputProp::indeterminate(_) => elem.remove_attribute("indeterminate").unwrap(),
            InputProp::input_mode(_) => elem.remove_attribute("input_mode").unwrap(),
            InputProp::max(_) => elem.remove_attribute("max").unwrap(),
            InputProp::max_length(_) => elem.remove_attribute("max_length").unwrap(),
            InputProp::min(_) => elem.remove_attribute("min").unwrap(),
            InputProp::min_length(_) => elem.remove_attribute("min_length").unwrap(),
            InputProp::multiple(_) => elem.remove_attribute("multiple").unwrap(),
            InputProp::name(_) => elem.remove_attribute("name").unwrap(),
            InputProp::pattern(_) => elem.remove_attribute("pattern").unwrap(),
            InputProp::placeholder(_) => elem.remove_attribute("placeholder").unwrap(),
            InputProp::read_only(_) => elem.remove_attribute("read_only").unwrap(),
            InputProp::required(_) => elem.remove_attribute("required").unwrap(),
            InputProp::size(_) => elem.remove_attribute("size").unwrap(),
            InputProp::src(_) => elem.remove_attribute("src").unwrap(),
            InputProp::step(_) => elem.remove_attribute("step").unwrap(),
            InputProp::r#type(_) => elem.remove_attribute("type").unwrap(),
            InputProp::default_value(_) => elem.remove_attribute("default_value").unwrap(),
            InputProp::value(_) => elem.remove_attribute("value").unwrap(),
            InputProp::value_as_number(_) => elem.remove_attribute("value_as_number").unwrap(),
            InputProp::width(_) => elem.remove_attribute("width").unwrap(),
            InputProp::align(_) => elem.remove_attribute("align").unwrap(),
            InputProp::use_map(_) => elem.remove_attribute("use_map").unwrap(),
            InputProp::webkitdirectory(_) => elem.remove_attribute("webkitdirectory").unwrap(),
        }
    }

    fn set_on(&self, elem: &HtmlInputElement) {
        match self {
            InputProp::accept(v) => elem.set_accept(v),
            InputProp::alt(v) => elem.set_alt(v),
            InputProp::autocomplete(v) => elem.set_autocomplete(v),
            InputProp::autofocus(v) => elem.set_autofocus(*v),
            InputProp::default_checked(v) => elem.set_default_checked(*v),
            InputProp::checked(v) => elem.set_checked(*v),
            InputProp::disabled(v) => elem.set_disabled(*v),
            InputProp::files(v) => elem.set_files(Some(v)),
            InputProp::form_action(v) => elem.set_form_action(v),
            InputProp::form_enctype(v) => elem.set_form_enctype(v),
            InputProp::form_method(v) => elem.set_form_method(v),
            InputProp::form_no_validate(v) => elem.set_form_no_validate(*v),
            InputProp::form_target(v) => elem.set_form_target(v),
            InputProp::height(v) => elem.set_height(*v),
            InputProp::indeterminate(v) => elem.set_indeterminate(*v),
            InputProp::input_mode(v) => elem.set_input_mode(v),
            InputProp::max(v) => elem.set_max(v),
            InputProp::max_length(v) => elem.set_max_length(*v),
            InputProp::min(v) => elem.set_min(v),
            InputProp::min_length(v) => elem.set_min_length(*v),
            InputProp::multiple(v) => elem.set_multiple(*v),
            InputProp::name(v) => elem.set_name(v),
            InputProp::pattern(v) => elem.set_pattern(v),
            InputProp::placeholder(v) => elem.set_placeholder(v),
            InputProp::read_only(v) => elem.set_read_only(*v),
            InputProp::required(v) => elem.set_required(*v),
            InputProp::size(v) => elem.set_size(*v),
            InputProp::src(v) => elem.set_src(v),
            InputProp::step(v) => elem.set_step(v),
            InputProp::r#type(v) => elem.set_type(v),
            InputProp::default_value(v) => elem.set_default_value(v),
            InputProp::value(v) => elem.set_value(v),
            InputProp::value_as_number(v) => elem.set_value_as_number(*v),
            InputProp::width(v) => elem.set_width(*v),
            InputProp::align(v) => elem.set_align(v),
            InputProp::use_map(v) => elem.set_use_map(v),
            InputProp::webkitdirectory(v) => elem.set_webkitdirectory(*v),
        }
    }
}

impl HtmlProps<HtmlInputElement> {
    pub fn accept(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::accept(val)));
        self
    }

    pub fn alt(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::alt(val)));
        self
    }

    pub fn autocomplete(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0
            .push_back(HtmlProp::Own(InputProp::autocomplete(val)));
        self
    }

    pub fn autofocus(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::autofocus(val)));
        self
    }

    pub fn default_checked(mut self, val: bool) -> Self {
        self.0
            .push_back(HtmlProp::Own(InputProp::default_checked(val)));
        self
    }

    pub fn checked(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::checked(val)));
        self
    }

    pub fn disabled(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::disabled(val)));
        self
    }

    pub fn files(mut self, val: web_sys::FileList) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::files(val)));
        self
    }

    pub fn form_action(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::form_action(val)));
        self
    }

    pub fn form_enctype(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0
            .push_back(HtmlProp::Own(InputProp::form_enctype(val)));
        self
    }

    pub fn form_method(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::form_method(val)));
        self
    }

    pub fn form_no_validate(mut self, val: bool) -> Self {
        self.0
            .push_back(HtmlProp::Own(InputProp::form_no_validate(val)));
        self
    }

    pub fn form_target(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::form_target(val)));
        self
    }

    pub fn height(mut self, val: u32) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::height(val)));
        self
    }

    pub fn indeterminate(mut self, val: bool) -> Self {
        self.0
            .push_back(HtmlProp::Own(InputProp::indeterminate(val)));
        self
    }

    pub fn input_mode(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::input_mode(val)));
        self
    }

    pub fn max(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::max(val)));
        self
    }

    pub fn max_length(mut self, val: i32) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::max_length(val)));
        self
    }

    pub fn min(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::min(val)));
        self
    }

    pub fn min_length(mut self, val: i32) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::min_length(val)));
        self
    }

    pub fn multiple(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::multiple(val)));
        self
    }

    pub fn name(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::name(val)));
        self
    }

    pub fn pattern(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::pattern(val)));
        self
    }

    pub fn placeholder(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::placeholder(val)));
        self
    }

    pub fn read_only(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::read_only(val)));
        self
    }

    pub fn required(mut self, val: bool) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::required(val)));
        self
    }

    pub fn size(mut self, val: u32) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::size(val)));
        self
    }

    pub fn src(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::src(val)));
        self
    }

    pub fn step(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::step(val)));
        self
    }

    pub fn r#type(mut self, val: Cow<'static, str>) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::r#type(val)));
        self
    }

    pub fn default_value(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0
            .push_back(HtmlProp::Own(InputProp::default_value(val)));
        self
    }

    pub fn value(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::value(val)));
        self
    }

    pub fn value_as_number(mut self, val: f64) -> Self {
        self.0
            .push_back(HtmlProp::Own(InputProp::value_as_number(val)));
        self
    }

    pub fn width(mut self, val: u32) -> Self {
        self.0.push_back(HtmlProp::Own(InputProp::width(val)));
        self
    }

    pub fn align(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::align(val)));
        self
    }

    pub fn use_map(mut self, val: impl Into<Cow<'static, str>>) -> Self {
        let val = val.into();
        self.0.push_back(HtmlProp::Own(InputProp::use_map(val)));
        self
    }

    pub fn webkitdirectory(mut self, val: bool) -> Self {
        self.0
            .push_back(HtmlProp::Own(InputProp::webkitdirectory(val)));
        self
    }
}