euv_ui/component/native_select/view/struct.rs
1use super::*;
2
3/// Props for the [`euv_native_select`] component.
4///
5/// The select carries the size of the control and the state a form needs
6/// to read back. The options themselves are passed as children.
7#[derive(Clone, CustomDebug, Default)]
8pub struct EuvNativeSelectProps {
9 /// The size of the control.
10 pub size: EuvNativeSelectSize,
11 /// The identifier used to connect an external label to the control.
12 ///
13 /// An empty identifier is generated by the component.
14 pub id: &'static str,
15 /// The form name the control submits under.
16 pub name: &'static str,
17 /// Accessible name for the native select.
18 pub aria_label: String,
19 /// Whether the control refuses input.
20 pub disabled: bool,
21 /// Whether the native control is required by its form.
22 pub required: bool,
23 /// Whether the control is invalid and should expose its error state.
24 pub invalid: bool,
25 /// The value the control currently shows.
26 ///
27 /// An empty value leaves the control to the choice of the browser, and
28 /// the first option is the one it shows. A value the options do not
29 /// carry leaves the control as it is.
30 pub value: Signal<String>,
31 /// The callback that receives the value the reader chose.
32 ///
33 /// The control is the native one, so the change arrives as an event on
34 /// the control itself and the value is read from it.
35 #[debug(skip)]
36 pub onchange: Option<Rc<dyn Fn(Event)>>,
37}
38
39/// Props for the [`euv_native_select_option`] component.
40///
41/// The option carries the value the form submits and the label the
42/// reader sees.
43#[derive(Clone, CustomDebug, Default)]
44pub struct EuvNativeSelectOptionProps {
45 /// The value the option submits under.
46 pub value: &'static str,
47 /// The label the reader sees.
48 pub label: &'static str,
49 /// Whether the option is excluded from selection.
50 pub disabled: bool,
51}
52
53/// Props for the [`euv_native_select_opt_group`] component.
54///
55/// The group carries the label that names the options it wraps. The
56/// options themselves are passed as children.
57#[derive(Clone, CustomDebug, Default)]
58pub struct EuvNativeSelectOptGroupProps {
59 /// The label that names the group.
60 pub label: &'static str,
61 /// Whether every option in the group is excluded from selection.
62 pub disabled: bool,
63}