Skip to main content

euv_ui/component/collapse/view/
struct.rs

1use super::*;
2
3/// One entry of the [`euv_collapse`] accordion.
4///
5/// The `key` is the stable identity written into the caller-owned
6/// `open_keys` signal; the `title` is the header text. The panel body is
7/// supplied by the caller through the `bodies` prop.
8#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
9pub struct EuvCollapseItem {
10    /// The stable identity of this section (written to the `open_keys`
11    /// signal).
12    #[get(type(copy))]
13    pub key: &'static str,
14    /// The header text of this section.
15    #[get(type(copy))]
16    pub title: &'static str,
17}
18
19/// Props for the [`euv_collapse`] component.
20///
21/// `open_keys` holds the currently-open section keys; a `Vec<String>`
22/// (rather than a single key) is used so `allow_multiple` can widen or
23/// narrow the set without a different prop type. An empty list means every
24/// section is closed.
25#[derive(Clone, CustomDebug, Default)]
26pub struct EuvCollapseProps {
27    /// The accordion sections, in display order.
28    pub items: Vec<EuvCollapseItem>,
29    /// The keys of the currently-open sections (empty means all closed).
30    pub open_keys: Signal<Vec<String>>,
31    /// Whether more than one section may stay open at the same time.
32    pub allow_multiple: bool,
33}