euv_ui/component/calendar/view/struct.rs
1use super::*;
2
3/// One cell of the [`euv_calendar`] day grid.
4///
5/// The calendar is pure presentation: the caller computes the month, the
6/// leading/trailing spill-over cells and the today flag, then hands the
7/// finished grid in. This keeps the component free of date arithmetic.
8#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
9pub struct EuvCalendarDay {
10 /// The day-of-month number rendered inside the cell.
11 #[get(type(copy))]
12 pub day: u32,
13 /// Whether the cell belongs to the previous or next month.
14 ///
15 /// Drives the `_muted` modifier so spill-over cells read as secondary
16 /// without changing the grid's shape.
17 #[get(type(copy))]
18 pub muted: bool,
19 /// Whether the cell is today's date.
20 #[get(type(copy))]
21 pub today: bool,
22}
23
24/// Props of the [`euv_calendar_day_button`] component.
25///
26/// The day button is the clickable cell of the grid. It reports whether
27/// the day is the chosen one and whether it can be picked at all.
28#[derive(Clone, CustomDebug, Default)]
29pub struct EuvCalendarDayButtonProps {
30 /// The day-of-month number shown inside the cell.
31 pub day: u32,
32 /// Whether the day is the chosen one.
33 pub selected: bool,
34 /// Whether the day refuses to be picked.
35 pub disabled: bool,
36 /// Optional callback fired when the cell is clicked.
37 #[debug(skip)]
38 pub on_select: Option<Rc<dyn Fn(u32)>>,
39}
40
41/// Props for the [`euv_calendar`] component.
42///
43/// The component renders only what it is given: `weekdays` drives the header
44/// row and `days` the grid. No date is computed here.
45#[derive(Clone, CustomDebug, Default)]
46pub struct EuvCalendarProps {
47 /// The month caption rendered in the header row.
48 pub title: &'static str,
49 /// The column headings, in display order.
50 pub weekdays: Vec<EuvCalendarWeekday>,
51 /// The day cells, in display order.
52 pub days: Vec<EuvCalendarDay>,
53 /// The currently selected day number.
54 pub selected: Signal<u32>,
55 /// The callback a click on a day cell runs.
56 ///
57 /// The calendar resolves no date of its own, so the cell hands the day
58 /// number and whether the cell belongs to a neighbouring month to this
59 /// callback and leaves the date arithmetic to the caller. When it is
60 /// absent the cell writes its day number into `selected` instead.
61 #[debug(skip)]
62 pub on_day_click: Option<Rc<dyn Fn(u32, bool)>>,
63}