leptos_struct_table/components/
row.rs1use crate::table_row::TableRow;
2use crate::EventHandler;
3use leptos::prelude::*;
4
5#[allow(unused_variables)]
8pub fn DefaultTableRowRenderer<Row>(
9 class: Signal<String>,
11 row: RwSignal<Row>,
13 index: usize,
15 selected: Signal<bool>,
17 on_select: EventHandler<web_sys::MouseEvent>,
19) -> impl IntoView
20where
21 Row: TableRow + 'static,
22{
23 view! {
24 <tr class=class on:click=move |mouse_event| on_select.run(mouse_event)>
25 {TableRow::render_row(row, index)}
26 </tr>
27 }
28}
29
30pub fn DefaultRowPlaceholderRenderer(height: Signal<f64>) -> impl IntoView {
34 view! { <tr style:height=move || format!("{}px", height.get()) style="display: block"></tr> }
35}
36
37#[allow(unused_variables)]
40pub fn DefaultErrorRowRenderer(err: String, index: usize, col_count: usize) -> impl IntoView {
41 view! { <tr><td colspan=col_count>{err}</td></tr> }
42}
43
44#[allow(unused_variables, unstable_name_collisions)]
46pub fn DefaultLoadingRowRenderer(
47 class: Signal<String>,
48 get_cell_class: Callback<(usize,), String>,
49 get_inner_cell_class: Callback<(usize,), String>,
50 index: usize,
51 col_count: usize,
52) -> impl IntoView {
53 view! {
54 <tr class=class>
55 {
56 (0..col_count).map(|col_index| view! {
57 <td class=get_cell_class.run((col_index,))>
58 <div class=get_inner_cell_class.run((col_index,))></div>
59 " "
60 </td>
61 }).collect_view()
62 }
63 </tr>
64 }
65}