euv_ui/component/field/view/struct.rs
1use super::*;
2
3/// Props for the `euv_field` component.
4///
5/// Defines the strongly-typed interface for a form field with label, input, and error display.
6#[derive(Clone, CustomDebug, Data, Default)]
7pub struct EuvFieldProps {
8 /// The unique identifier for the input element.
9 #[get(type(copy))]
10 pub id: &'static str,
11 /// The HTML name attribute for the input element.
12 #[get(type(copy))]
13 pub name: &'static str,
14 /// The label text displayed above the input.
15 #[get(type(copy))]
16 pub label: &'static str,
17 /// The HTML input type (e.g. "text", "email", "password", "number").
18 #[get(type(copy))]
19 pub input_type: &'static str,
20 /// The placeholder text shown when the input is empty.
21 #[get(type(copy))]
22 pub placeholder: &'static str,
23 /// The autocomplete hint for the browser.
24 #[get(type(copy))]
25 pub autocomplete: &'static str,
26 /// The current input value.
27 #[get(type(copy))]
28 pub value: Signal<String>,
29 /// The error message signal; when non-empty, the input shows error styling. When None, no error display.
30 pub error: Option<Signal<String>>,
31 /// Optional input event handler; defaults to `on_input_value(value)` if None.
32 #[debug(skip)]
33 pub oninput: Option<Rc<dyn Fn(Event)>>,
34}
35
36/// Props for the [`euv_field_set`] component.
37///
38/// The set takes no settings of its own.
39#[derive(Clone, CustomDebug, Default)]
40pub struct EuvFieldSetProps {}
41
42/// Props for the [`euv_field_legend`] component.
43///
44/// The legend says which size it is written at: the size of the legend
45/// of a set of fields, or the size of the caption of one control.
46#[derive(Clone, CustomDebug, Default)]
47pub struct EuvFieldLegendProps {
48 /// The size the legend is written at.
49 pub variant: EuvFieldLegendVariant,
50}
51
52/// Props for the [`euv_field_group`] component.
53///
54/// The group says how its rows are laid out and whether the fields it
55/// holds are in the invalid state.
56#[derive(Clone, CustomDebug, Default)]
57pub struct EuvFieldGroupProps {
58 /// The direction the rows of the group are laid out in.
59 pub orientation: EuvFieldOrientation,
60 /// Whether the fields of the group are in the invalid state.
61 pub invalid: bool,
62}
63
64/// Props for the [`euv_field_content`] component.
65///
66/// The content takes no settings of its own.
67#[derive(Clone, CustomDebug, Default)]
68pub struct EuvFieldContentProps {}
69
70/// Props for the [`euv_field_label`] component.
71///
72/// The label names the control it belongs to.
73#[derive(Clone, CustomDebug, Default)]
74pub struct EuvFieldLabelProps {
75 /// The id of the control the label names.
76 pub html_for: &'static str,
77}
78
79/// Props for the [`euv_field_title`] component.
80///
81/// The title takes no settings of its own.
82#[derive(Clone, CustomDebug, Default)]
83pub struct EuvFieldTitleProps {}
84
85/// Props for the [`euv_field_description`] component.
86///
87/// The description carries the id a control can reference with `aria-describedby`.
88#[derive(Clone, CustomDebug, Default)]
89pub struct EuvFieldDescriptionProps {
90 /// The id that names this description.
91 pub id: &'static str,
92}
93
94/// Props for the [`euv_field_error`] component.
95///
96/// The error carries the message that tells the reader what is wrong.
97#[derive(Clone, CustomDebug, Default)]
98pub struct EuvFieldErrorProps {
99 /// The message that tells the reader what is wrong.
100 pub message: &'static str,
101 /// The id a control can reference with `aria-describedby`.
102 pub id: &'static str,
103}
104
105/// Props for the [`euv_field_separator`] component.
106///
107/// The separator takes no settings of its own.
108#[derive(Clone, CustomDebug, Default)]
109pub struct EuvFieldSeparatorProps {}