Skip to main content

euv_ui/component/transfer/view/
struct.rs

1use super::*;
2
3/// One row of a transfer list.
4///
5/// Carries the machine value the row is keyed by, the label the reader
6/// sees, and whether the row can be marked at all.
7///
8/// The row is comparable so that a caller can keep a whole list of them in
9/// a signal — the transfer does not own its rows, the page does.
10#[derive(Clone, Copy, CustomDebug, Data, Default, New, PartialEq)]
11pub struct EuvTransferItem {
12    /// The machine value of the row.
13    #[get(type(copy))]
14    pub value: &'static str,
15    /// The label the reader sees.
16    #[get(type(copy))]
17    pub label: &'static str,
18    /// Whether the row is disabled.
19    ///
20    /// A disabled row cannot be marked, so clicking it never writes into
21    /// the selection signal.
22    #[get(type(copy))]
23    pub disabled: bool,
24}
25
26/// Props for the [`euv_transfer`] component.
27///
28/// The component is presentational: it owns neither of the two lists and
29/// only reports the moves the reader asks for. The marked rows live in a
30/// caller-owned `Signal<Vec<String>>`, so the transfer takes part in
31/// two-way binding with the rest of the page.
32#[derive(Clone, CustomDebug, Default)]
33pub struct EuvTransferProps {
34    /// The rows of the source list.
35    pub source: Vec<EuvTransferItem>,
36    /// The rows of the target list.
37    pub target: Vec<EuvTransferItem>,
38    /// The rows currently marked in either list.
39    pub selected: Signal<Vec<String>>,
40    /// The label of the source list's header.
41    pub source_title: &'static str,
42    /// The label of the target list's header.
43    pub target_title: &'static str,
44    /// The callback fired when a row moves from the source to the target.
45    #[debug(skip)]
46    pub on_move_to_target: Option<Rc<dyn Fn(&'static str)>>,
47    /// The callback fired when a row moves from the target to the source.
48    #[debug(skip)]
49    pub on_move_to_source: Option<Rc<dyn Fn(&'static str)>>,
50}