rumtk_web/components/form/
props.rs1use rumtk_core::strings::{rumtk_format, RUMString};
24
25#[derive(Debug, Clone, Default)]
26pub struct InputProps {
27 pub name: Option<RUMString>,
28 pub typ: Option<RUMString>,
29 pub value: Option<RUMString>,
30 pub placeholder: Option<RUMString>,
31 pub max_length: Option<usize>,
32 pub min_length: Option<usize>,
33 pub autocapitalize: bool,
34 pub autocomplete: bool,
35 pub autocorrect: bool,
36 pub autofocus: bool,
37 pub disabled: bool,
38 pub required: bool,
39}
40
41impl InputProps {
42 pub fn to_rumstring(&self) -> RUMString {
43 let default_text = RUMString::default();
44 rumtk_format!(
45 "{} {} {} {} {} {} {} {} {} {} {} {} {} ",
46 match &self.name {
47 Some(name) => rumtk_format!("id='{}'", name),
48 None => default_text.clone(),
49 },
50 match &self.name {
51 Some(name) => rumtk_format!("name='{}'", name),
52 None => default_text.clone(),
53 },
54 match &self.typ {
55 Some(typ) => rumtk_format!("type='{}'", typ),
56 None => default_text.clone(),
57 },
58 match &self.value {
59 Some(val) => rumtk_format!("value='{}'", val),
60 None => default_text.clone(),
61 },
62 match &self.placeholder {
63 Some(placeholder) => rumtk_format!("placeholder='{}'", placeholder),
64 None => default_text.clone(),
65 },
66 match self.max_length {
67 Some(max_length) => rumtk_format!("maxlength='{}'", max_length),
68 None => default_text.clone(),
69 },
70 match self.min_length {
71 Some(min_length) => rumtk_format!("minlength='{}'", min_length),
72 None => default_text.clone(),
73 },
74 match self.autocapitalize {
75 true => rumtk_format!("autocapitalize"),
76 false => default_text.clone(),
77 },
78 match self.autocomplete {
79 true => rumtk_format!("autocomplete"),
80 false => default_text.clone(),
81 },
82 match self.autocorrect {
83 true => rumtk_format!("autocorrect"),
84 false => default_text.clone(),
85 },
86 match self.autofocus {
87 true => rumtk_format!("autofocus"),
88 false => default_text.clone(),
89 },
90 match self.disabled {
91 true => rumtk_format!("disabled"),
92 false => default_text.clone(),
93 },
94 match self.required {
95 true => rumtk_format!("required"),
96 false => default_text.clone(),
97 },
98 )
99 }
100
101 pub fn to_string(&self) -> String {
102 self.to_rumstring().to_string()
103 }
104}