singlestage/components/dropdown/
item.rs1use crate::DropdownMenuContext;
2use leptos::prelude::*;
3
4#[component]
6pub fn DropdownMenuItem(
7 children: Children,
8
9 #[prop(optional, into)]
14 accesskey: MaybeProp<String>,
15 #[prop(optional, into)]
20 autocapitalize: MaybeProp<String>,
21 #[prop(optional, into)]
24 autofocus: MaybeProp<bool>,
25 #[prop(optional, into)]
27 class: MaybeProp<String>,
28 #[prop(optional, into)]
32 contenteditable: MaybeProp<String>,
33 #[prop(optional, into)]
37 dir: MaybeProp<String>,
38 #[prop(optional, into)]
40 draggable: MaybeProp<bool>,
41 #[prop(optional, into)]
43 enterkeyhint: MaybeProp<String>,
44 #[prop(optional, into)]
46 exportparts: MaybeProp<String>,
47 #[prop(optional, into)]
49 hidden: MaybeProp<String>,
50 #[prop(optional, into)]
52 id: MaybeProp<String>,
53 #[prop(optional, into)]
55 inert: MaybeProp<bool>,
56 #[prop(optional, into)]
59 inputmode: MaybeProp<String>,
60 #[prop(optional, into)]
62 is: MaybeProp<String>,
63 #[prop(optional, into)]
65 itemid: MaybeProp<String>,
66 #[prop(optional, into)]
68 itemprop: MaybeProp<String>,
69 #[prop(optional, into)]
71 itemref: MaybeProp<String>,
72 #[prop(optional, into)]
74 itemscope: MaybeProp<String>,
75 #[prop(optional, into)]
77 itemtype: MaybeProp<String>,
78 #[prop(optional, into)]
80 lang: MaybeProp<String>,
81 #[prop(optional, into)]
83 nonce: MaybeProp<String>,
84 #[prop(optional, into)]
86 part: MaybeProp<String>,
87 #[prop(optional, into)]
89 popover: MaybeProp<String>,
90 #[prop(optional, into)]
92 slot: MaybeProp<String>,
93 #[prop(optional, into)]
97 spellcheck: MaybeProp<String>,
98 #[prop(optional, into)]
100 style: MaybeProp<String>,
101 #[prop(optional, into)]
103 tabindex: MaybeProp<usize>,
104 #[prop(optional, into)]
106 title: MaybeProp<String>,
107 #[prop(optional, into)]
109 translate: MaybeProp<String>,
110
111 #[prop(optional, into)]
115 value: MaybeProp<String>,
116
117 #[prop(optional, into)]
119 disabled: MaybeProp<bool>,
120 #[prop(optional, into)]
124 variant: MaybeProp<String>,
125) -> impl IntoView {
126 let menu = expect_context::<DropdownMenuContext>();
127
128 let global_attrs_1 = view! {
129 <{..}
130 accesskey=move || accesskey.get()
131 autocapitalize=move || autocapitalize.get()
132 autofocus=move || autofocus.get()
133 contenteditable=move || contenteditable.get()
134 dir=move || dir.get()
135 draggable=move || draggable.get()
136 enterkeyhint=move || enterkeyhint.get()
137 exportparts=move || exportparts.get()
138 hidden=move || hidden.get()
139 id=move || id.get()
140 inert=move || inert.get()
141 inputmode=move || inputmode.get()
142 is=move || is.get()
143 itemid=move || itemid.get()
144 />
145 };
146
147 let global_attrs_2 = view! {
148 <{..}
149 itemprop=move || itemprop.get()
150 itemref=move || itemref.get()
151 itemscope=move || itemscope.get()
152 itemtype=move || itemtype.get()
153 lang=move || lang.get()
154 nonce=move || nonce.get()
155 part=move || part.get()
156 popover=move || popover.get()
157 slot=move || slot.get()
158 spellcheck=move || spellcheck.get()
159 style=move || style.get()
160 tabindex=move || tabindex.get()
161 title=move || title.get()
162 translate=move || translate.get()
163 />
164 };
165
166 view! {
167 <li
168 class=move || {
169 format!("singlestage-dropdown-menu-item {}", class.get().unwrap_or_default())
170 }
171 role="menuitem"
172 value=move || value.get()
173
174 {..global_attrs_1}
175 {..global_attrs_2}
176 >
177 <button
178 aria-controls=move || menu.menu_id.get()
179 aria-haspopup="menu"
180 data-disabled=move || disabled.get().unwrap_or_default()
181 data-variant=move || variant.get().unwrap_or_default()
182 popovertarget=move || menu.menu_id.get()
183 popovertargetaction="toggle"
184 type="button"
185 >
186 {children()}
187 </button>
188 </li>
189 }
190}