(
checked: ReadSignal<CheckboxState>,
default_checked: CheckboxState,
#[props(extends = input)] attributes: Vec<Attribute>,
)
| 240 | |
| 241 | #[component] |
| 242 | fn BubbleInput( |
| 243 | checked: ReadSignal<CheckboxState>, |
| 244 | default_checked: CheckboxState, |
| 245 | #[props(extends = input)] attributes: Vec<Attribute>, |
| 246 | ) -> Element { |
| 247 | let id = use_unique_id(); |
| 248 | |
| 249 | // Update the actual input state to match our virtual state. |
| 250 | use_effect(move || { |
| 251 | let checked = checked(); |
| 252 | let js = eval( |
| 253 | r#" |
| 254 | let id = await dioxus.recv(); |
| 255 | let action = await dioxus.recv(); |
| 256 | let input = document.getElementById(id); |
| 257 | |
| 258 | switch(action) { |
| 259 | case "checked": |
| 260 | input.checked = true; |
| 261 | input.indeterminate = false; |
| 262 | break; |
| 263 | case "indeterminate": |
| 264 | input.indeterminate = true; |
| 265 | input.checked = true; |
| 266 | break; |
| 267 | case "unchecked": |
| 268 | input.checked = false; |
| 269 | input.indeterminate = false; |
| 270 | break; |
| 271 | } |
| 272 | "#, |
| 273 | ); |
| 274 | |
| 275 | let _ = js.send(id()); |
| 276 | let _ = js.send(checked.to_data_state()); |
| 277 | }); |
| 278 | |
| 279 | rsx! { |
| 280 | input { |
| 281 | id, |
| 282 | type: "checkbox", |
| 283 | aria_hidden: "true", |
| 284 | tabindex: "-1", |
| 285 | position: "absolute", |
| 286 | pointer_events: "none", |
| 287 | opacity: "0", |
| 288 | margin: "0", |
| 289 | transform: "translateX(-100%)", |
| 290 | |
| 291 | // Default checked |
| 292 | checked: default_checked != CheckboxState::Unchecked, |
| 293 | |
| 294 | ..attributes, |
| 295 | } |
| 296 | } |
| 297 | } |
nothing calls this directly
no test coverage detected