use std::sync::atomic::{AtomicU32, Ordering};
use dioxus_nox_collection::ListItem;
pub(crate) static INSTANCE_COUNTER: AtomicU32 = AtomicU32::new(0);
pub(crate) fn next_instance_id() -> u32 {
INSTANCE_COUNTER.fetch_add(1, Ordering::Relaxed)
}
#[derive(Clone, Copy, Default, PartialEq, Debug)]
pub enum AutoComplete {
#[default]
None,
List,
Both,
}
impl AutoComplete {
pub fn as_aria_attr(&self) -> &'static str {
match self {
Self::None => "none",
Self::List => "list",
Self::Both => "both",
}
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct ItemEntry {
pub value: String,
pub label: String,
pub keywords: String,
pub disabled: bool,
pub group_id: Option<String>,
}
impl ListItem for ItemEntry {
fn value(&self) -> &str {
&self.value
}
fn label(&self) -> &str {
&self.label
}
fn keywords(&self) -> &str {
&self.keywords
}
fn disabled(&self) -> bool {
self.disabled
}
fn group_id(&self) -> Option<&str> {
self.group_id.as_deref()
}
}
#[derive(Clone, PartialEq, Debug)]
pub struct GroupEntry {
pub id: String,
pub label: Option<String>,
}
pub use dioxus_nox_collection::{CustomFilter, ScoredItem};