dioxus_tw_components/components/molecules/table/
props.rs

1use crate::attributes::*;
2use dioxus::prelude::*;
3use dioxus_tw_components_macro::UiComp;
4
5#[derive(Clone, PartialEq, Props, UiComp)]
6pub struct TableProps {
7    #[props(extends = table, extends = GlobalAttributes)]
8    attributes: Vec<Attribute>,
9
10    children: Element,
11}
12
13impl std::default::Default for TableProps {
14    fn default() -> Self {
15        Self {
16            attributes: Vec::<Attribute>::default(),
17            children: rsx! {},
18        }
19    }
20}
21
22#[component]
23pub fn Table(mut props: TableProps) -> Element {
24    props.update_class_attribute();
25
26    rsx! {
27        table { ..props.attributes,{props.children} }
28    }
29}
30
31#[derive(Clone, PartialEq, Props, UiComp)]
32pub struct TableHeaderProps {
33    #[props(extends = thead, extends = GlobalAttributes)]
34    attributes: Vec<Attribute>,
35
36    children: Element,
37}
38
39impl std::default::Default for TableHeaderProps {
40    fn default() -> Self {
41        Self {
42            attributes: Vec::<Attribute>::default(),
43            children: rsx! {},
44        }
45    }
46}
47
48#[component]
49pub fn TableHeader(mut props: TableHeaderProps) -> Element {
50    props.update_class_attribute();
51
52    rsx! {
53        thead { ..props.attributes,{props.children} }
54    }
55}
56
57#[derive(Clone, PartialEq, Props, UiComp)]
58pub struct TableBodyProps {
59    #[props(extends = tbody, extends = GlobalAttributes)]
60    attributes: Vec<Attribute>,
61
62    children: Element,
63}
64
65impl std::default::Default for TableBodyProps {
66    fn default() -> Self {
67        Self {
68            attributes: Vec::<Attribute>::default(),
69            children: rsx! {},
70        }
71    }
72}
73
74#[component]
75pub fn TableBody(mut props: TableBodyProps) -> Element {
76    props.update_class_attribute();
77
78    rsx! {
79        tbody { ..props.attributes,{props.children} }
80    }
81}
82
83#[derive(Clone, PartialEq, Props, UiComp)]
84pub struct TableFooterProps {
85    #[props(extends = tfoot, extends = GlobalAttributes)]
86    attributes: Vec<Attribute>,
87
88    children: Element,
89}
90
91impl std::default::Default for TableFooterProps {
92    fn default() -> Self {
93        Self {
94            attributes: Vec::<Attribute>::default(),
95            children: rsx! {},
96        }
97    }
98}
99
100#[component]
101pub fn TableFooter(mut props: TableFooterProps) -> Element {
102    props.update_class_attribute();
103
104    rsx! {
105        tfoot { ..props.attributes,{props.children} }
106    }
107}
108
109#[derive(Clone, PartialEq, Props, UiComp)]
110pub struct TableHeadProps {
111    #[props(extends = th, extends = GlobalAttributes)]
112    attributes: Vec<Attribute>,
113
114    #[props(optional)]
115    onclick: EventHandler<MouseEvent>,
116
117    children: Element,
118}
119
120impl std::default::Default for TableHeadProps {
121    fn default() -> Self {
122        Self {
123            attributes: Vec::<Attribute>::default(),
124            onclick: EventHandler::<MouseEvent>::default(),
125            children: rsx! {},
126        }
127    }
128}
129
130#[component]
131pub fn TableHead(mut props: TableHeadProps) -> Element {
132    props.update_class_attribute();
133
134    let onclick = move |event| props.onclick.call(event);
135
136    rsx! {
137        th { onclick, ..props.attributes, {props.children} }
138    }
139}
140
141#[derive(Clone, PartialEq, Props, UiComp)]
142pub struct TableRowProps {
143    #[props(extends = tr, extends = GlobalAttributes)]
144    attributes: Vec<Attribute>,
145
146    children: Element,
147}
148
149impl std::default::Default for TableRowProps {
150    fn default() -> Self {
151        Self {
152            attributes: Vec::<Attribute>::default(),
153            children: rsx! {},
154        }
155    }
156}
157
158#[component]
159pub fn TableRow(mut props: TableRowProps) -> Element {
160    props.update_class_attribute();
161
162    rsx! {
163        tr { ..props.attributes,{props.children} }
164    }
165}
166
167#[derive(Clone, PartialEq, Props, UiComp)]
168pub struct TableCellProps {
169    #[props(extends = td, extends = GlobalAttributes)]
170    attributes: Vec<Attribute>,
171
172    children: Element,
173}
174
175impl std::default::Default for TableCellProps {
176    fn default() -> Self {
177        Self {
178            attributes: Vec::<Attribute>::default(),
179            children: rsx! {},
180        }
181    }
182}
183
184#[component]
185pub fn TableCell(mut props: TableCellProps) -> Element {
186    props.update_class_attribute();
187
188    rsx! {
189        td { ..props.attributes,{props.children} }
190    }
191}
192
193#[derive(Clone, PartialEq, Props, UiComp)]
194pub struct TableCaptionProps {
195    #[props(extends = caption, extends = GlobalAttributes)]
196    attributes: Vec<Attribute>,
197
198    children: Element,
199}
200
201impl std::default::Default for TableCaptionProps {
202    fn default() -> Self {
203        Self {
204            attributes: Vec::<Attribute>::default(),
205            children: rsx! {},
206        }
207    }
208}
209
210#[component]
211pub fn TableCaption(mut props: TableCaptionProps) -> Element {
212    props.update_class_attribute();
213
214    rsx! {
215        caption { ..props.attributes,{props.children} }
216    }
217}