euv_ui/component/upload/view/struct.rs
1use super::*;
2
3/// One row of the [`euv_upload`] file list.
4///
5/// The view never touches the DOM `File` object: the caller turns each picked
6/// file into a name / size / status triple, so the list is driven by plain
7/// data and the row is reproducible from these fields alone.
8#[derive(Clone, Copy, CustomDebug, Data, Default, New, PartialEq)]
9pub struct EuvUploadFile {
10 /// The display name of the file.
11 #[get(type(copy))]
12 pub name: &'static str,
13 /// The pre-formatted size label (e.g. `"1.2 MB"`).
14 #[get(type(copy))]
15 pub size: &'static str,
16 /// The transfer state driving the status badge.
17 #[get(type(copy))]
18 pub status: EuvUploadStatus,
19}
20
21/// Props for the [`euv_upload`] component.
22///
23/// The file list and the drag state are caller-owned signals so the caller can
24/// feed real upload progress back in; the component only presents them.
25#[derive(Clone, CustomDebug, Default)]
26pub struct EuvUploadProps {
27 /// The `accept` filter applied to the underlying file input.
28 pub accept: &'static str,
29 /// Whether the file input allows selecting more than one file.
30 pub multiple: Signal<bool>,
31 /// The rows rendered in the file list.
32 pub files: Signal<Vec<EuvUploadFile>>,
33 /// Whether a drag is currently over the drop zone.
34 pub drag_active: Signal<bool>,
35 /// Optional callback receiving a display string for the picked files.
36 #[debug(skip)]
37 pub on_files: Option<Rc<dyn Fn(&'static str)>>,
38}