euv 0.1.1

A declarative, cross-platform UI framework for Rust with virtual DOM, reactive signals, and RSX macros for WebAssembly.
Documentation
use crate::*;

/// Represents the type of an HTML tag or a component.
///
/// Distinguishes between standard HTML elements and user-defined components.
#[derive(Clone)]
pub enum Tag {
    /// A standard HTML element identified by its tag name.
    Element(String),
    /// A custom component type.
    Component(String),
}

/// Represents the name of an HTML attribute or DOM property.
///
/// Covers common HTML attributes, accessibility attributes, and custom data attributes.
#[derive(Clone)]
pub enum Attribute {
    /// The accesskey attribute.
    AccessKey,
    /// The action attribute for forms.
    Action,
    /// The alt attribute for images.
    Alt,
    /// The aria-label accessibility attribute.
    AriaLabel,
    /// The autocomplete attribute.
    AutoComplete,
    /// The autofocus attribute.
    AutoFocus,
    /// The checked attribute for checkboxes/radios.
    Checked,
    /// The class attribute.
    Class,
    /// The cols attribute for textareas.
    Cols,
    /// The contenteditable attribute.
    ContentEditable,
    /// The data-* custom attribute.
    Data(String),
    /// The dir attribute.
    Dir,
    /// The disabled attribute.
    Disabled,
    /// The draggable attribute.
    Draggable,
    /// The enctype attribute for forms.
    EncType,
    /// The for attribute for labels.
    For,
    /// The form attribute.
    Form,
    /// The height attribute.
    Height,
    /// The hidden attribute.
    Hidden,
    /// The href attribute for links.
    Href,
    /// The id attribute.
    Id,
    /// The lang attribute.
    Lang,
    /// The max attribute.
    Max,
    /// The maxlength attribute.
    MaxLength,
    /// The method attribute for forms.
    Method,
    /// The min attribute.
    Min,
    /// The minlength attribute.
    MinLength,
    /// The multiple attribute for selects.
    Multiple,
    /// The name attribute.
    Name,
    /// The pattern attribute for inputs.
    Pattern,
    /// The placeholder attribute.
    Placeholder,
    /// The readonly attribute.
    ReadOnly,
    /// The required attribute.
    Required,
    /// The rows attribute for textareas.
    Rows,
    /// The selected attribute for options.
    Selected,
    /// The size attribute.
    Size,
    /// The spellcheck attribute.
    SpellCheck,
    /// The src attribute for media/images.
    Src,
    /// The step attribute.
    Step,
    /// The style attribute.
    Style,
    /// The tabindex attribute.
    TabIndex,
    /// The target attribute for links/forms.
    Target,
    /// The title attribute.
    Title,
    /// The type attribute for inputs.
    Type,
    /// The value attribute.
    Value,
    /// The width attribute.
    Width,
    /// A custom attribute with an arbitrary name.
    Other(String),
}

/// Represents the value of an HTML attribute.
///
/// Attributes can be static text, reactive signals, event handlers, dynamic expressions,
/// or CSS class references.
#[derive(Clone)]
pub enum AttributeValue {
    /// A static string value.
    Text(String),
    /// A dynamic signal-backed value.
    Signal(Signal<String>),
    /// An event handler callback.
    Event(crate::event::NativeEventHandler),
    /// A dynamic expression value of any type (for component props).
    Dynamic(String),
    /// A CSS class reference created by the `class!` macro.
    Css(CssClass),
}

/// Represents a node in the virtual DOM tree.
///
/// The core enum representing elements, text, fragments, and empty nodes.
#[derive(Clone, Default)]
pub enum VirtualNode {
    /// An element node with a tag, attributes, and children.
    Element {
        /// The tag type of this element.
        tag: Tag,
        /// The attributes attached to this element.
        attributes: Vec<AttributeEntry>,
        /// The child nodes.
        children: Vec<VirtualNode>,
        /// An optional key for diffing.
        key: Option<String>,
    },
    /// A text node.
    Text(TextNode),
    /// A fragment of multiple nodes without a wrapper element.
    Fragment(Vec<VirtualNode>),
    /// A dynamic node that re-renders based on signal changes.
    Dynamic(DynamicNode),
    /// An empty placeholder node.
    #[default]
    Empty,
}