euv-macros 0.52.1

Zero-overhead procedural macros for the cross-platform euv UI framework, providing view!, style!, var!, watch!, computed!, state!, #[store], #[component], #[event], emit!, on!, and #[euv].
Documentation
/// Tag keyword for a generic container view.
pub(crate) const TAG_VIEW: &str = "view";

/// Tag keyword for a horizontal flex row.
pub(crate) const TAG_ROW: &str = "row";

/// Tag keyword for a vertical flex column.
pub(crate) const TAG_COLUMN: &str = "column";

/// Removed legacy short alias tag for a vertical flex column (`column`).
pub(crate) const TAG_COL_REMOVED: &str = "col";

/// Tag keyword for a grid container.
pub(crate) const TAG_GRID: &str = "grid";

/// Tag keyword for a scrollable container.
pub(crate) const TAG_SCROLL: &str = "scroll";

/// Tag keyword for a top-layer portal container.
pub(crate) const TAG_PORTAL: &str = "portal";

/// Tag keyword for a transparent sibling fragment grouping container.
pub(crate) const TAG_FRAGMENT: &str = "fragment";

/// Tag keyword for a text run node.
pub(crate) const TAG_TEXT: &str = "text";

/// Tag keyword for an editable text input node.
pub(crate) const TAG_INPUT: &str = "input";

/// Tag keyword for a bitmap image node.
pub(crate) const TAG_IMAGE: &str = "image";

/// Tag keyword for a custom 2D canvas node.
pub(crate) const TAG_CANVAS: &str = "canvas";

/// Tag keyword for a surgically updatable component-level dynamic slot.
pub(crate) const TAG_SLOT: &str = "slot";

/// Tag keyword for a surgically updatable page-level dynamic slot.
pub(crate) const TAG_PAGE_SLOT: &str = "page_slot";

/// Property keyword for element `Style` reference (`style: card_style(tokens)`).
pub(crate) const PROP_STYLE: &str = "style";

/// Property keyword for reactive style binding closure `move || -> Style`.
pub(crate) const PROP_BIND_STYLE: &str = "bind_style";

/// Property keyword for reactive children builder closure `move || -> Vec<NodeId>`.
pub(crate) const PROP_BIND_CHILDREN: &str = "bind_children";

/// Property keyword for capturing the created `NodeId` into a mutable local binding.
pub(crate) const PROP_NODE_REF: &str = "node_ref";

/// Property keyword for keyboard focus participation boolean.
pub(crate) const PROP_FOCUSABLE: &str = "focusable";

/// Property keyword for click callback.
pub(crate) const PROP_ON_CLICK: &str = "on_click";

/// Property keyword for input change callback.
pub(crate) const PROP_ON_CHANGE: &str = "on_change";

/// Property keyword for scroll callback.
pub(crate) const PROP_ON_SCROLL: &str = "on_scroll";

/// Property keyword for pointer-down callback.
pub(crate) const PROP_ON_POINTER_DOWN: &str = "on_pointer_down";

/// Property keyword for pointer-move callback.
pub(crate) const PROP_ON_POINTER_MOVE: &str = "on_pointer_move";

/// Property keyword for pointer-up callback.
pub(crate) const PROP_ON_POINTER_UP: &str = "on_pointer_up";

/// Property keyword for pointer-enter callback.
pub(crate) const PROP_ON_POINTER_ENTER: &str = "on_pointer_enter";

/// Property keyword for pointer-leave callback.
pub(crate) const PROP_ON_POINTER_LEAVE: &str = "on_pointer_leave";

/// Property keyword for pointer hover enter/leave callback.
pub(crate) const PROP_ON_HOVER: &str = "on_hover";

/// Property keyword for keyboard key-down callback.
pub(crate) const PROP_ON_KEY: &str = "on_key";

/// Property keyword for focus-gained callback.
pub(crate) const PROP_ON_FOCUS: &str = "on_focus";

/// Property keyword for focus-lost callback.
pub(crate) const PROP_ON_BLUR: &str = "on_blur";

/// Property keyword for input initial value.
pub(crate) const PROP_VALUE: &str = "value";

/// Property keyword for input placeholder text.
pub(crate) const PROP_PLACEHOLDER: &str = "placeholder";

/// Property keyword for input password masking boolean.
pub(crate) const PROP_PASSWORD: &str = "password";

/// Property keyword for input multiline boolean.
pub(crate) const PROP_MULTILINE: &str = "multiline";

/// Property keyword for input disabled boolean.
pub(crate) const PROP_DISABLED: &str = "disabled";

/// Property keyword for input initial caret offset.
pub(crate) const PROP_CARET: &str = "caret";

/// Property keyword for image buffer expression.
pub(crate) const PROP_SOURCE: &str = "source";

/// Property keyword for canvas painter closure.
pub(crate) const PROP_PAINTER: &str = "painter";

/// Property keyword for canvas caching policy (`CanvasCaching::DynamicPerFrame` or `CanvasCaching::RetainedStatic`).
pub(crate) const PROP_CACHING: &str = "caching";

/// Property keyword for complete `A11yProps` expression.
pub(crate) const PROP_A11Y: &str = "a11y";

/// Property keyword for semantic accessibility role (`A11yRole`).
pub(crate) const PROP_ROLE: &str = "role";

/// Property keyword for accessible screen-reader label string.
pub(crate) const PROP_A11Y_LABEL: &str = "a11y_label";

/// Property keyword for accessible screen-reader usage hint string.
pub(crate) const PROP_A11Y_HINT: &str = "a11y_hint";

/// Property keyword for accessible current value string.
pub(crate) const PROP_A11Y_VALUE: &str = "a11y_value";

/// Property keyword for accessible disabled boolean.
pub(crate) const PROP_A11Y_DISABLED: &str = "a11y_disabled";

/// Property keyword for accessible checked state `Option<bool>`.
pub(crate) const PROP_A11Y_CHECKED: &str = "a11y_checked";

/// Property keyword for a component-level dynamic slot identifier (`slot { id: "..." }`).
pub(crate) const PROP_ID: &str = "id";

/// Property keyword for a page-level dynamic slot route (`page_slot { route: "/..." }`).
pub(crate) const PROP_ROUTE: &str = "route";

/// Property keyword for an optional explicit `DynamicUpdateHub` override on `slot` / `page_slot`.
pub(crate) const PROP_HUB: &str = "hub";

/// Property keyword for an explicit fallback builder closure `move || -> NodeId` on `slot` / `page_slot`.
pub(crate) const PROP_FALLBACK: &str = "fallback";

/// Component type name whose nested children map to `.section(...)`.
pub(crate) const COMP_EUV_PAGE: &str = "EuvPage";

/// Component type name whose nested children map to `.field(...)`.
pub(crate) const COMP_EUV_FORM: &str = "EuvForm";

/// Component type name whose nested children map to `.action(...)`.
pub(crate) const COMP_EUV_NAVBAR: &str = "EuvNavbar";

/// Component type name whose nested children map to `.card(...)`.
pub(crate) const COMP_EUV_STAT_GRID: &str = "EuvStatGrid";

/// Component fluent method name for page section children.
pub(crate) const METHOD_SECTION: &str = "section";

/// Component fluent method name for form field children.
pub(crate) const METHOD_FIELD: &str = "field";

/// Component fluent method name for navbar action children.
pub(crate) const METHOD_ACTION: &str = "action";

/// Component fluent method name for stat grid card children.
pub(crate) const METHOD_CARD: &str = "card";

/// Default component fluent method name for generic nested children.
pub(crate) const METHOD_CHILD: &str = "child";

/// Complete list of supported non-style properties inside `view!` elements for typo diagnostics.
pub(crate) const KNOWN_VIEW_PROPS: &[&str] = &[
    PROP_STYLE,
    PROP_BIND_STYLE,
    PROP_BIND_CHILDREN,
    PROP_NODE_REF,
    PROP_FOCUSABLE,
    PROP_ON_CLICK,
    PROP_ON_CHANGE,
    PROP_ON_SCROLL,
    PROP_ON_POINTER_DOWN,
    PROP_ON_POINTER_MOVE,
    PROP_ON_POINTER_UP,
    PROP_ON_POINTER_ENTER,
    PROP_ON_POINTER_LEAVE,
    PROP_ON_HOVER,
    PROP_ON_KEY,
    PROP_ON_FOCUS,
    PROP_ON_BLUR,
    PROP_VALUE,
    PROP_PLACEHOLDER,
    PROP_PASSWORD,
    PROP_MULTILINE,
    PROP_DISABLED,
    PROP_CARET,
    PROP_SOURCE,
    PROP_PAINTER,
    PROP_CACHING,
    PROP_A11Y,
    PROP_ROLE,
    PROP_A11Y_LABEL,
    PROP_A11Y_HINT,
    PROP_A11Y_VALUE,
    PROP_A11Y_DISABLED,
    PROP_A11Y_CHECKED,
    PROP_ID,
    PROP_ROUTE,
    PROP_HUB,
    PROP_FALLBACK,
];

/// Error message when a caller passes a legacy explicit context argument to `view!(ctx, ...)` or `view!(in ctx, ...)`.
pub(crate) const ERR_LEGACY_VIEW_CONTEXT: &str = "view! manages Context automatically; remove explicit `ctx` / `in ctx,` and wrap external scenes in `with_context(ctx, || view! { ... })`";

/// Error message when a semicolon appears inside `view!` where newline-separated entries are expected.
pub(crate) const ERR_VIEW_UNEXPECTED_SEMI: &str = "unexpected `;` in `view!` — separate properties and child nodes with newlines without semicolons";

/// Error message when the removed `col` alias tag is used in `view!`.
pub(crate) const ERR_TAG_COL_REMOVED: &str =
    "tag `col` is removed in `view!` — use `column { ... }` instead";

/// Error message when inline style blocks or inline `Style::default()` builders are written inside `view!`.
pub(crate) const ERR_INLINE_STYLE_FORBIDDEN: &str =
    "inline style definitions (`style: { ... }`, `style: style! {
        ...
    }`, or `style: Style::...`) are forbidden inside `view!` — extract a keyless `style!` function or variable and pass `style: my_style`";

/// Error message prefix when a style property is written loosely on a `view!` element instead of inside a `style!` definition.
pub(crate) const ERR_LOOSE_STYLE_PROP_PREFIX: &str = "style property";

/// Common non-canonical CSS/style alias keys rejected when written directly on a `view!` element.
pub(crate) const LOOSE_STYLE_ALIAS_PROPS: &[(&str, &str)] = &[
    ("bg", "Background(...)"),
    ("text_color", "TextColor(...)"),
    ("border_radius", "Radius(...)"),
    ("border_width", "Border::new(...)"),
    ("border_color", "Border::new(...)"),
    ("align_items", "AlignItems::..."),
    ("justify_content", "JustifyContent::..."),
    ("flex", "FlexGrow(...)"),
    ("top", "Inset(...)"),
    ("right", "Inset(...)"),
    ("bottom", "Inset(...)"),
    ("left", "Inset(...)"),
    ("box_shadow", "Shadow::new(...)"),
    ("height_px", "Height(...)"),
    ("backdrop_blur", "Shadow::new(...)"),
];

/// Error message when an unsupported property is placed on a transparent `fragment` element.
pub(crate) const ERR_FRAGMENT_PROP_FORBIDDEN: &str = "`fragment` is a transparent grouping container and only supports `node_ref:` and `bind_children:`";

/// Error message when `bind_children:` is placed on a non-container element.
pub(crate) const ERR_BIND_CHILDREN_CONTAINER_ONLY: &str = "`bind_children:` is only valid on container elements (`view`, `row`, `column`, `grid`, `scroll`, `portal`, `fragment`)";

/// Error message when `slot` or `page_slot` specifies both `fallback:` and inline children.
pub(crate) const ERR_SLOT_FALLBACK_CONFLICT: &str =
    "`fallback:` cannot be combined with inline fallback children on `slot` / `page_slot`";

/// Error message when `image` lacks a `source` property.
pub(crate) const ERR_IMAGE_MISSING_SOURCE: &str =
    "image element requires a `source:` ImageBuffer expression";

/// Error message when `canvas` lacks a `painter` property.
pub(crate) const ERR_CANVAS_MISSING_PAINTER: &str =
    "canvas element requires a `painter:` closure `|bounds: Rect, dl: &mut DisplayList| { ... }`";

/// Error message when `slot` lacks an `id` property.
pub(crate) const ERR_SLOT_MISSING_ID: &str =
    "`slot` element requires an `id:` string identifying the dynamic component slot";

/// Error message when `page_slot` lacks a `route` property.
pub(crate) const ERR_PAGE_SLOT_MISSING_ROUTE: &str =
    "`page_slot` element requires a `route:` string identifying the dynamic page route";

/// Error message when `id:` is placed on a non-`slot` element.
pub(crate) const ERR_ID_ONLY_ON_SLOT: &str =
    "`id:` is only valid on `slot { id: \"...\" }` dynamic component slots";

/// Error message when `route:` is placed on a non-`page_slot` element.
pub(crate) const ERR_ROUTE_ONLY_ON_PAGE_SLOT: &str =
    "`route:` is only valid on `page_slot { route: \"/...\" }` dynamic page slots";

/// Error message when `hub:` or `fallback:` is placed on an element other than `slot` or `page_slot`.
pub(crate) const ERR_HUB_ONLY_ON_DYNAMIC_SLOT: &str =
    "`hub:` and `fallback:` are only valid on `slot` or `page_slot` dynamic elements";

/// Error message when `source:` is placed on a non-`image` element.
pub(crate) const ERR_SOURCE_ONLY_ON_IMAGE: &str =
    "`source:` is only valid on `image { source: ... }` elements";

/// Error message when `painter:` is placed on a non-`canvas` element.
pub(crate) const ERR_PAINTER_ONLY_ON_CANVAS: &str =
    "`painter:` is only valid on `canvas { painter: ... }` elements";

/// Error message when `caching:` is placed on a non-`canvas` element.
pub(crate) const ERR_CACHING_ONLY_ON_CANVAS: &str =
    "`caching:` is only valid on `canvas { caching: ... painter: ... }` elements";

/// Error message when input-only properties are placed on a non-`input` element.
pub(crate) const ERR_INPUT_PROP_ONLY_ON_INPUT: &str = "`value:`, `placeholder:`, `password:`, `multiline:`, `disabled:`, and `caret:` are only valid on `input { ... }` elements";

/// Error message when child nodes are declared inside a leaf element (`input`, `image`, or `canvas`).
pub(crate) const ERR_LEAF_CHILDREN_FORBIDDEN: &str =
    "leaf elements (`input`, `image`, `canvas`) cannot contain child nodes";

/// Error message when `bind_children:` is combined with static children on the same element.
pub(crate) const ERR_BIND_CHILDREN_CONFLICT: &str = "`bind_children:` cannot be combined with inline static children because reactive updates replace all children";

/// Error message when `a11y:` is combined with individual `role:`/`a11y_*` properties.
pub(crate) const ERR_A11Y_CONFLICT: &str =
    "`a11y:` cannot be combined with individual `role:` or `a11y_*` properties on the same element";

/// Error message when `text` receives unsupported control-flow or multiple children.
pub(crate) const ERR_TEXT_CHILD_INVALID: &str =
    "`text` element accepts at most one string literal or `{ expr }` text expression";

/// Error message when `if` / `for` / `match` / `..spread` is used where a single root node is required without a container.
pub(crate) const ERR_SPREAD_IN_EXPR_CONTEXT: &str =
    "`..spread` can only appear inside a container, `fragment`, or component children block";

/// Error message prefix for duplicate property declarations on the same element.
pub(crate) const ERR_DUPLICATE_PROP_PREFIX: &str = "duplicate property";

/// Generated internal identifier for multi-root fragment container.
pub(crate) const IDENT_ROOT: &str = "__euv_root";

/// Generated internal identifier for control-flow fragment container.
pub(crate) const IDENT_FRAG: &str = "__euv_frag";

/// Generated internal identifier for mutable component builder local.
pub(crate) const IDENT_COMP: &str = "__euv_comp";

/// Generated internal identifier for newly constructed primitive node.
pub(crate) const IDENT_NODE: &str = "__euv_node";

/// Generated internal identifier for slot fallback root container.
pub(crate) const IDENT_FB_ROOT: &str = "__euv_fb_root";

/// Generated internal identifier for batched dynamic child node vector.
pub(crate) const IDENT_BATCH: &str = "__euv_batch";

/// Error message when an element tag has neither `{ ... }` body nor `(args...)`.
pub(crate) const ERR_EXPECTED_BODY_OR_ARGS: &str =
    "expected `{ ... }` body after element or component tag";

/// Error message when a PascalCase component passes positional `(...)` arguments instead of named attributes inside `{ ... }`.
pub(crate) const ERR_COMPONENT_POSITIONAL_ARGS: &str = "component parameters must be passed as named attributes inside `Component { prop: value }` instead of positional `(...)` arguments";

/// Legacy Web/HTML container tags rejected with native migration guidance.
pub(crate) const HTML_CONTAINER_TAGS: &[&str] = &[
    "div", "section", "main", "header", "footer", "nav", "article", "aside", "ul", "ol", "li",
    "form",
];

/// Legacy Web/HTML text tags rejected with native migration guidance.
pub(crate) const HTML_TEXT_TAGS: &[&str] = &[
    "span", "p", "h1", "h2", "h3", "h4", "h5", "h6", "label", "strong", "code",
];

/// Legacy Web/HTML interactive button/link tags rejected with native migration guidance.
pub(crate) const HTML_BUTTON_TAGS: &[&str] = &["button", "a"];

/// Legacy Web/HTML image tag rejected with native migration guidance.
pub(crate) const HTML_IMAGE_TAGS: &[&str] = &["img"];

/// Error message suffix for legacy HTML container tags.
pub(crate) const HTML_REPLACE_CONTAINER: &str = "`column`, `row`, `view`, or `grid`";

/// Error message suffix for legacy HTML text tags.
pub(crate) const HTML_REPLACE_TEXT: &str = "`text`";

/// Error message suffix for legacy HTML button/link tags.
pub(crate) const HTML_REPLACE_BUTTON: &str =
    "`EuvButton { label: \"...\" tokens: tokens }` or `view { on_click: ... }`";

/// Error message suffix for legacy HTML image tag.
pub(crate) const HTML_REPLACE_IMAGE: &str = "`image { source: ... }`";