euv_ui/component/table/view/struct.rs
1use super::*;
2
3/// One column of the [`euv_table`] component.
4///
5/// `key` is the stable identity used for the column's own diffing key; it
6/// is not rendered, so a caller can pass a short slug (`"qty"`) while
7/// `label` carries the visible uppercase heading.
8#[derive(Clone, Debug, Default)]
9pub struct EuvTableColumn {
10 /// The stable column identity, used as the diffing key only.
11 pub key: &'static str,
12 /// The visible column heading text.
13 pub label: ::euv::CowText,
14 /// The horizontal alignment applied to this column's cells.
15 pub align: EuvTableAlign,
16}
17
18/// One body row of the [`euv_table`] component.
19///
20/// `cells` is positional: cell `i` is rendered under `columns[i]`, and a
21/// row shorter than the column list simply renders fewer cells. Extra
22/// cells beyond the column list are dropped, so a ragged row can never
23/// escape the header.
24#[derive(Clone, Debug, Default)]
25pub struct EuvTableRow {
26 /// The cell texts, positionally matched to [`EuvTableProps::columns`].
27 pub cells: Vec<::euv::CowText>,
28 /// The stable row identity, used as the diffing key only.
29 pub key: ::euv::CowText,
30}
31
32/// Props for the [`euv_table`] component.
33///
34/// Defines the strongly-typed interface for a bordered data table with a
35/// header, a zebra mode, and an optional caption.
36#[derive(Clone, CustomDebug, Default)]
37pub struct EuvTableProps {
38 /// The column definitions driving the header and each cell's alignment.
39 pub columns: Vec<EuvTableColumn>,
40 /// The body rows; an empty list renders an empty `<tbody>`.
41 pub rows: Vec<EuvTableRow>,
42 /// The caption rendered under the table (skipped when empty).
43 pub caption: &'static str,
44 /// Whether every other row gets the `c_euv_table_row_zebra` fill.
45 pub zebra: bool,
46 /// An optional application class composed with the design-system table classes.
47 pub class: Css,
48}
49
50/// Props for the [`euv_table_header`] component.
51///
52/// The header takes no settings of its own.
53#[derive(Clone, CustomDebug, Default)]
54pub struct EuvTableHeaderProps {}
55
56/// Props for the [`euv_table_body`] component.
57///
58/// The body takes no settings of its own.
59#[derive(Clone, CustomDebug, Default)]
60pub struct EuvTableBodyProps {}
61
62/// Props for the [`euv_table_footer`] component.
63///
64/// The footer takes no settings of its own.
65#[derive(Clone, CustomDebug, Default)]
66pub struct EuvTableFooterProps {}
67
68/// Props for the [`euv_table_caption`] component.
69///
70/// The caption carries the text that names what the table shows.
71#[derive(Clone, CustomDebug, Default)]
72pub struct EuvTableCaptionProps {
73 /// The text of the caption.
74 pub text: &'static str,
75}
76
77/// Props for the [`euv_table_row`] component.
78///
79/// The row takes no settings of its own.
80#[derive(Clone, CustomDebug, Default)]
81pub struct EuvTableRowProps {}
82
83/// Props for the [`euv_table_head`] component.
84///
85/// The heading takes no settings of its own.
86#[derive(Clone, CustomDebug, Default)]
87pub struct EuvTableHeadProps {}
88
89/// Props for the [`euv_table_cell`] component.
90///
91/// The cell takes no settings of its own.
92#[derive(Clone, CustomDebug, Default)]
93pub struct EuvTableCellProps {}