Skip to main content

euv_ui/component/combobox/view/
struct.rs

1use super::*;
2
3/// Props of the [`euv_combobox`] component.
4#[derive(Clone, CustomDebug, Default)]
5pub struct EuvComboboxProps {
6    /// Whether the list of options is open.
7    pub open: Signal<bool>,
8    /// The value the field is showing.
9    pub value: Signal<String>,
10    /// The accessible name of the combobox.
11    pub label: &'static str,
12}
13
14/// Props of the [`euv_combobox_trigger`] component.
15#[derive(Clone, CustomDebug, Default)]
16pub struct EuvComboboxTriggerProps {
17    /// Whether the list of options is open.
18    pub open: Signal<bool>,
19    /// The label shown inside the trigger.
20    pub label: &'static str,
21    /// Whether the trigger is disabled.
22    pub disabled: bool,
23}
24
25/// Props of the [`euv_combobox_input`] component.
26#[derive(Clone, CustomDebug, Default)]
27pub struct EuvComboboxInputProps {
28    /// Whether the list of options is open.
29    pub open: Signal<bool>,
30    /// The value the field is showing.
31    pub value: Signal<String>,
32    /// The text shown while the field is empty.
33    pub placeholder: &'static str,
34    /// Whether the field is disabled.
35    pub disabled: bool,
36    /// The accessible name of the input.
37    pub aria_label: &'static str,
38    /// The id of the listbox controlled by the input.
39    pub aria_controls: &'static str,
40}
41
42/// Props of the [`euv_combobox_content`] component.
43#[derive(Clone, CustomDebug, Default)]
44pub struct EuvComboboxContentProps {
45    /// Whether the list of options is open.
46    pub open: Signal<bool>,
47}
48
49/// Props of the [`euv_combobox_list`] component.
50#[derive(Clone, Copy, CustomDebug, Default)]
51pub struct EuvComboboxListProps {
52    /// The listbox id referenced by the combobox input.
53    pub id: &'static str,
54    /// The accessible name of the list.
55    pub label: &'static str,
56}
57
58/// Props of the [`euv_combobox_item`] component.
59#[derive(Clone, CustomDebug, Default)]
60pub struct EuvComboboxItemProps {
61    /// The open-state signal for the list of options.
62    pub open: Signal<bool>,
63    /// The value the row stands for.
64    pub value: &'static str,
65    /// The label shown inside the row.
66    pub label: &'static str,
67    /// Whether the row is the selected one.
68    pub selected: bool,
69    /// Whether the row is disabled.
70    pub disabled: bool,
71    /// Optional callback receiving the chosen value.
72    #[debug(skip)]
73    pub on_select: Option<Rc<dyn Fn(&'static str)>>,
74}
75
76/// Props of the [`euv_combobox_group`] component.
77#[derive(Clone, Copy, CustomDebug, Default)]
78pub struct EuvComboboxGroupProps {
79    /// The accessible name of the group.
80    pub label: &'static str,
81}
82
83/// Props of the [`euv_combobox_label`] component.
84#[derive(Clone, Copy, CustomDebug, Default)]
85pub struct EuvComboboxLabelProps {
86    /// The text of the label.
87    pub text: &'static str,
88}
89
90/// Props of the [`euv_combobox_empty`] component.
91#[derive(Clone, Copy, CustomDebug, Default)]
92pub struct EuvComboboxEmptyProps {
93    /// The text shown when nothing matched the query.
94    pub text: &'static str,
95}
96
97/// Props of the [`euv_combobox_separator`] component.
98#[derive(Clone, Copy, CustomDebug, Default)]
99pub struct EuvComboboxSeparatorProps {
100    /// The label reported to assistive technology, if any.
101    pub label: &'static str,
102}
103
104/// Props of the [`euv_combobox_clear`] component.
105#[derive(Clone, Copy, CustomDebug, Default)]
106pub struct EuvComboboxClearProps {
107    /// The accessible name of the button.
108    pub label: &'static str,
109}
110
111/// Props of the [`euv_combobox_chips`] component.
112///
113/// The chip row is the group that holds the chosen values and the text
114/// input the reader types into.
115#[derive(Clone, Copy, CustomDebug, Default)]
116pub struct EuvComboboxChipsProps {
117    /// The accessible name of the chip row.
118    pub label: &'static str,
119}
120
121/// Props of the [`euv_combobox_chip_list`] component.
122///
123/// The chip list holds the chip rows themselves; it is a wrapper that
124/// groups them for assistive technology.
125#[derive(Clone, Copy, CustomDebug, Default)]
126pub struct EuvComboboxChipListProps {
127    /// The accessible name of the chip list.
128    pub label: &'static str,
129}
130
131/// Props of the [`euv_combobox_chip`] component.
132///
133/// A chip is one chosen value. The chip carries its own remove button,
134/// so the caller decides what removing a value means.
135#[derive(Clone, CustomDebug, Default)]
136pub struct EuvComboboxChipProps {
137    /// The text shown inside the chip.
138    pub label: &'static str,
139    /// The value the chip stands for.
140    pub value: &'static str,
141    /// Whether the chip is disabled.
142    pub disabled: bool,
143    /// Optional callback fired when the chip is removed.
144    #[debug(skip)]
145    pub on_remove: Option<Rc<dyn Fn(&'static str)>>,
146}
147
148/// Props of the [`euv_combobox_chips_input`] component.
149///
150/// The input lives inside the chip row: the reader types the query there
151/// while the chosen values sit next to it as chips.
152#[derive(Clone, CustomDebug, Default)]
153pub struct EuvComboboxChipsInputProps {
154    /// The value the field is showing.
155    pub value: Signal<String>,
156    /// The text shown while the field is empty.
157    pub placeholder: &'static str,
158    /// Whether the field is disabled.
159    pub disabled: bool,
160}
161
162/// Props of the [`euv_combobox_value`] component.
163///
164/// The value shows one chosen entry of the list.
165#[derive(Clone, Copy, CustomDebug, Default)]
166pub struct EuvComboboxValueProps {
167    /// The text of the chosen value.
168    pub label: &'static str,
169}