leptos_struct_table/components/
cell.rs

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
#![allow(unused_variables)]

use crate::CellValue;
use std::marker::PhantomData;

use leptos::prelude::*;

/// The default cell renderer. Uses the `<td>` element.
#[component]
pub fn DefaultTableCellRenderer<Row, T, M>(
    /// The class attribute for the cell element. Generated by the classes provider.
    class: String,
    /// The value to display.
    value: Signal<T>,
    /// Event handler called when the cell is changed. In this default renderer this will never happen.
    row: RwSignal<Row>,
    /// The index of the column. Starts at 0.
    index: usize,
    options: T::RenderOptions,
    #[prop(optional)] _marker: PhantomData<M>,
) -> impl IntoView
where
    Row: Send + Sync + 'static,
    T: CellValue<M> + Send + Sync + Clone + 'static,
    M: 'static,
{
    view! {
        <td class=class>{move || value.get().render_value(options.clone())}</td>
    }
}