euv_ui/component/radio/view/struct.rs
1use super::*;
2
3/// One selectable entry of the `euv_radio_group`.
4///
5/// Carries the machine value submitted with the form and the label the
6/// user reads; the group compares the machine value against its own
7/// `value` signal to decide which item renders as checked.
8#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
9pub struct EuvRadioOption {
10 /// The machine value submitted when this option is selected.
11 #[get(type(copy))]
12 pub value: &'static str,
13 /// The display label shown next to the radio control.
14 #[get(type(copy))]
15 pub label: &'static str,
16}
17
18/// Props for the `euv_radio` component.
19///
20/// Defines the strongly-typed interface for a radio group. The selection
21/// is owned by the caller through a `Signal<String>` so the group can
22/// take part in two-way binding with the rest of the page.
23#[derive(Clone, CustomDebug, Data, Default, New)]
24pub struct EuvRadioGroupProps {
25 /// The HTML name attribute shared by every radio in the group.
26 #[get(type(copy))]
27 pub name: &'static str,
28 /// The selectable options rendered in declaration order.
29 pub options: Vec<EuvRadioOption>,
30 /// The signal holding the currently selected option value.
31 #[get(type(copy))]
32 pub value: Signal<String>,
33 /// The group label text displayed above the options.
34 #[get(type(copy))]
35 pub label: &'static str,
36}
37
38/// Props of the [`euv_radio_group`] component.
39///
40/// The group is the container of a set of radio rows. It owns no state:
41/// the selection lives in the caller's signal, and each row reports the
42/// value it stands for.
43#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
44pub struct EuvRadioGroupRootProps {
45 /// The accessible name of the group.
46 #[get(type(copy))]
47 pub label: &'static str,
48}
49
50/// Props of the [`euv_radio_group_item`] component.
51#[derive(Clone, CustomDebug, Data, Default, New)]
52pub struct EuvRadioGroupItemProps {
53 /// The label shown inside the row.
54 #[get(type(copy))]
55 pub label: &'static str,
56 /// The value the row stands for.
57 #[get(type(copy))]
58 pub value: &'static str,
59 /// The signal holding the checked state of the row.
60 #[get(type(copy))]
61 pub checked: Signal<bool>,
62 /// Optional callback receiving the chosen value.
63 #[debug(skip)]
64 pub on_select: Option<Rc<dyn Fn(&'static str)>>,
65}