use crate::{PageProps, View, COUNTRIES}; use yew::prelude::*; use yew_autocomplete::{ view::{Bulma, Plain}, Autocomplete, ItemResolver, ItemResolverResult, }; #[function_component(Multi)] pub fn multi(props: &PageProps) -> Html { let resolve_items: ItemResolver = Callback::from(|input: String| -> ItemResolverResult { let items = COUNTRIES .into_iter() .filter(|s| s.to_lowercase().starts_with(input.to_lowercase().as_str())) .map(String::from) .collect(); Box::pin(futures::future::ok::<_, ()>(items)) }); let view = match props.view { View::Plain => html! { /> }, View::Bulma => html! { /> }, }; html! { <>

{"yew-components: Autocomplete Demo"}

{"multi_select: true, show_selected: true"}

onchange = { Callback::from(|_| ()) } multi_select = {true} show_selected = true {resolve_items} > {view} >
} }