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