Skip to main content

euv_ui/component/checkbox_group/view/
struct.rs

1use super::*;
2
3/// One entry of the [`euv_checkbox_group`] option list.
4///
5/// Carries the machine value stored in the checked-values signal, the label
6/// the user reads, and whether the option can be toggled at all.
7#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
8pub struct EuvCheckboxGroupOption {
9    /// The machine value stored in the checked-values signal while ticked.
10    #[get(type(copy))]
11    pub value: &'static str,
12    /// The display label shown next to the checkbox marker.
13    #[get(type(copy))]
14    pub label: &'static str,
15    /// Whether the option is disabled.
16    ///
17    /// A disabled option cannot be toggled, so it never writes into the
18    /// checked-values signal.
19    #[get(type(copy))]
20    pub disabled: bool,
21}
22
23/// Props for the [`euv_checkbox_group`] component.
24///
25/// The checked values live in a caller-owned `Signal<Vec<String>>` so the
26/// group takes part in two-way binding with the rest of the page; the
27/// group reads that vector once per render to decide which markers are
28/// ticked.
29#[derive(Clone, CustomDebug, Default)]
30pub struct EuvCheckboxGroupProps {
31    /// The options rendered in the group, in display order.
32    pub options: Vec<EuvCheckboxGroupOption>,
33    /// The signal holding the currently checked option values.
34    pub values: Signal<Vec<String>>,
35    /// The group label above the options; an empty label renders no label.
36    pub label: &'static str,
37    /// Optional callback receiving the new set of checked values.
38    #[debug(skip)]
39    pub on_change: Option<Rc<dyn Fn(Vec<String>)>>,
40}