Lines
100 %
Functions
50 %
Branches
//! Data attribute definitions for autocomplete components.
//!
//! This module provides a single source of truth for HTML data attribute names
//! used by autocomplete components. Both the WASM frontend (reader) and the web
//! server templates (writer) use these definitions to ensure consistency.
/// Attribute names for autocomplete components.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AutocompleteAttr {
/// The type of autocomplete (e.g., "account", "tag-name", "tag-value")
Type,
/// URL to fetch suggestions from
FetchUrl,
/// ID of the visible display input field
DisplayInput,
/// ID of the hidden value input field
HiddenInput,
/// ID of the dependency input (for dependent autocompletes like tag-value)
DependsOn,
/// Marker attribute indicating the component is initialized
Initialized,
/// Index for suggestion items in the dropdown
Index,
}
impl AutocompleteAttr {
/// Returns the HTML attribute name as a string slice.
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Type => "data-autocomplete",
Self::FetchUrl => "data-fetch-url",
Self::DisplayInput => "data-display-input",
Self::HiddenInput => "data-hidden-input",
Self::DependsOn => "data-depends-on",
Self::Initialized => "data-initialized",
Self::Index => "data-index",
/// CSS selectors used by autocomplete components.
pub mod selectors {
/// Selector for the autocomplete results container
pub const RESULTS_CONTAINER: &str = ".autocomplete-results";
/// Values for the autocomplete type attribute.
pub mod autocomplete_type {
/// Account autocomplete type
pub const ACCOUNT: &str = "account";
/// Tag name autocomplete type
pub const TAG_NAME: &str = "tag-name";
/// Tag value autocomplete type (depends on tag-name)
pub const TAG_VALUE: &str = "tag-value";
#[cfg(test)]
#[path = "data_attrs_tests.rs"]
mod tests;