Skip to main content

euv_ui/component/cascader/view/
struct.rs

1use super::*;
2
3/// One choice of a [`euv_cascader`] column.
4///
5/// A choice carries the machine value written into the selection signal,
6/// the label the reader sees, and the choices one level below it. The
7/// struct is recursive, so it cannot be `Copy`; it derives `Clone` so a
8/// caller can build several pickers from one shared template.
9#[derive(Clone, CustomDebug, Data, Default, New)]
10pub struct EuvCascaderOption {
11    /// The machine value of the choice.
12    #[get(type(copy))]
13    pub value: &'static str,
14    /// The label the reader sees.
15    #[get(type(copy))]
16    pub label: &'static str,
17    /// The choices one level below this one.
18    pub children: Vec<EuvCascaderOption>,
19}
20
21/// Props for the [`euv_cascader`] component.
22///
23/// The chosen path lives in a caller-owned `Signal<Vec<String>>` so the
24/// picker takes part in two-way binding; the open state of the panel and
25/// the path the reader is browsing are owned by the component itself.
26#[derive(Clone, CustomDebug, Default)]
27pub struct EuvCascaderProps {
28    /// The top-level choices.
29    pub options: Vec<EuvCascaderOption>,
30    /// The values of the chosen path, outermost first.
31    pub value: Signal<Vec<String>>,
32    /// The text shown when nothing is chosen.
33    pub placeholder: &'static str,
34    /// The group label above the control.
35    pub label: &'static str,
36    /// The callback fired when a choice is made.
37    #[debug(skip)]
38    pub on_select: Option<Rc<dyn Fn(&'static str)>>,
39}