Skip to main content

euv_ui/component/select/view/
impl.rs

1use super::*;
2
3/// Internal behavior shared by Select option keyboard navigation.
4impl EuvSelectOption {
5    /// Checks whether the option label begins with a keyboard typeahead prefix.
6    ///
7    /// # Arguments
8    ///
9    /// - `&str` - The case-insensitive prefix to match.
10    ///
11    /// # Returns
12    ///
13    /// - `bool` - Whether this enabled option matches the prefix.
14    pub(crate) fn matches_typeahead(&self, query: &str) -> bool {
15        !self.get_disabled()
16            && self
17                .get_label()
18                .to_lowercase()
19                .starts_with(&query.to_lowercase())
20    }
21}
22
23/// Implementation of default props for Select.
24impl Default for EuvSelectProps {
25    /// Constructs a default [`EuvSelectProps`] value.
26    fn default() -> Self {
27        Self {
28            value: Signal::create(String::new()),
29            multiple: false,
30            values: Signal::create(Vec::new()),
31            size: EuvSelectSize::Default,
32            options: Vec::new(),
33            placeholder: "",
34            label: "",
35            aria_label: String::new(),
36            aria_describedby: "",
37            id: "",
38            name: "",
39            form: "",
40            auto_complete: "",
41            required: false,
42            invalid: false,
43            disabled: false,
44            read_only: false,
45            open: None,
46            default_open: false,
47            align_item_with_trigger: class_property(
48                c_euv_select_panel(),
49                "--euv-select-align-item",
50            )
51            .as_deref()
52                == Some("1"),
53            on_change: None,
54            on_change_values: None,
55            on_open_change: None,
56        }
57    }
58}