Skip to main content

euv_ui/component/form/view/
struct.rs

1use super::*;
2
3/// Props for the [`euv_form`] component.
4///
5/// The component only owns the form shell: the fields themselves are passed
6/// in as children, so the caller decides which controls the form holds.
7#[derive(Clone, CustomDebug, Default)]
8pub struct EuvFormProps {
9    /// The label of the submit button.
10    ///
11    /// An empty string renders the form without a submit button, which is
12    /// the right choice for a form that submits itself.
13    pub submit_label: &'static str,
14    /// The callback invoked when the form is submitted.
15    #[debug(skip)]
16    pub on_submit: Option<Rc<dyn Fn()>>,
17}
18
19/// Props for the [`euv_form_field`] component.
20///
21/// The field wraps one control and tells the parts inside it which name the
22/// control carries, so a label, a description and a message can point at the
23/// same control without the caller repeating the name in three places.
24#[derive(Clone, CustomDebug, Default)]
25pub struct EuvFormFieldProps {
26    /// The name the control inside the field carries.
27    pub name: &'static str,
28    /// The id the control inside the field carries.
29    pub id: &'static str,
30    /// Whether the control inside the field is in the invalid state.
31    pub invalid: bool,
32}
33
34/// Props for the [`euv_form_item`] component.
35///
36/// The item is the box around one field. It owns the id that the label, the
37/// description and the message of the field point at.
38#[derive(Clone, CustomDebug, Default)]
39pub struct EuvFormItemProps {
40    /// The id the parts of the field point at.
41    pub id: &'static str,
42}