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, Copy, 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: &'static str,
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<&'static str>,
28 /// The stable row identity, used as the diffing key only.
29 pub key: &'static str,
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}