dioxus_style_macro 0.5.1

Procedural macros for dioxus_style with SCSS/SASS compilation support - internal use only
Documentation
//! Shared CSS constants for parsing and validation
//!
//! This module contains all the CSS-related constants used across the macro implementation.
//! Centralizing these constants makes them easier to maintain and extend.

/// List of valid HTML5 elements that can be used as CSS selectors.
/// MUST BE SORTED ALPHABETICALLY for binary_search.
pub const VALID_HTML_ELEMENTS: &[&str] = &[
    "a", "abbr", "address", "area", "article", "aside", "audio", 
    "b", "base", "bdi", "bdo", "blockquote", "body", "br", "button", 
    "canvas", "caption", "cite", "code", "col", "colgroup", 
    "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", 
    "em", "embed", 
    "fieldset", "figcaption", "figure", "footer", "form", 
    "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", 
    "i", "iframe", "img", "input", "ins", 
    "kbd", 
    "label", "legend", "li", "link", 
    "main", "map", "mark", "math", "menu", "meta", "meter", 
    "nav", "noscript", 
    "object", "ol", "optgroup", "option", "output", 
    "p", "param", "picture", "portal", "pre", "progress", 
    "q", 
    "rp", "rt", "ruby", 
    "s", "samp", "script", "section", "select", "slot", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "svg", 
    "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", 
    "u", "ul", 
    "var", "video", 
    "wbr"
];

/// List of valid CSS pseudo-classes.
/// MUST BE SORTED ALPHABETICALLY for binary_search.
pub const VALID_PSEUDO_CLASSES: &[&str] = &[
    "active", "any-link", 
    "checked", 
    "default", "disabled", 
    "empty", "enabled", 
    "first-child", "first-of-type", "focus", "focus-visible", "focus-within", 
    "has", "hover", 
    "in-range", "indeterminate", "invalid", "is", 
    "last-child", "last-of-type", "link", 
    "not", "nth-child", "nth-last-child", "nth-last-of-type", "nth-of-type", 
    "only-child", "only-of-type", "optional", "out-of-range", 
    "placeholder-shown", 
    "read-only", "read-write", "required", "root", 
    "scope", 
    "target", 
    "valid", "visited", 
    "where"
];

/// SCSS-specific keywords that indicate SCSS syntax
pub const SCSS_KEYWORDS: &[&str] = &[
    "@mixin", "@include", "@import", "@use", "@forward", "@extend",
    "@function", "@return", "@if", "@else", "@each", "@for", "@while",
    "@at-root", "@error", "@warn", "@debug",
];

/// SCSS variable prefix
pub const SCSS_VARIABLE_PREFIX: char = '$';

/// SCSS parent reference
pub const SCSS_PARENT_REF: char = '&';

/// Checks if a string is a valid HTML element
#[inline]
pub fn is_valid_html_element(name: &str) -> bool {
    VALID_HTML_ELEMENTS.binary_search(&name).is_ok()
}

/// Checks if a string is a valid pseudo-class
#[inline]
pub fn is_valid_pseudo_class(name: &str) -> bool {
    VALID_PSEUDO_CLASSES.binary_search(&name).is_ok()
}

/// Checks if content looks like SCSS based on common patterns
#[inline]
pub fn looks_like_scss(content: &str) -> bool {
    // Check for SCSS variable
    if content.contains(SCSS_VARIABLE_PREFIX) {
        return true;
    }
    
    // Check for SCSS parent reference
    if content.contains(SCSS_PARENT_REF) {
        return true;
    }
    
    // Check for SCSS keywords
    for keyword in SCSS_KEYWORDS {
        if content.contains(keyword) {
            return true;
        }
    }
    
    false
}