Skip to main content

Crate ferro_json_ui

Crate ferro_json_ui 

Source
Expand description

§Ferro JSON-UI

Experimental: The component schema and plugin interface may evolve.

JSON-based server-driven UI schema types for the Ferro framework.

This crate defines the typed foundation for JSON-UI: a declarative component system where the server sends JSON descriptions that are rendered to HTML. Components, actions, and visibility rules are all defined as Rust types with serde serialization.

§Schema Structure

A JSON-UI view consists of:

  • Components - UI elements (Card, Table, Form, Button, etc.)
  • Actions - Handler references with confirmations and outcomes
  • Visibility - Conditional rendering based on data conditions
  • View - Top-level container with layout and title

§Example

use ferro_json_ui::{JsonUiView, ComponentNode, Component, CardProps};

let view = JsonUiView::new()
    .title("Users")
    .component(ComponentNode {
        key: "header".to_string(),
        component: Component::Card(CardProps {
            title: "User Management".to_string(),
            description: None,
            children: vec![],
            footer: vec![],
        }),
        action: None,
        visibility: None,
    });

let json = view.to_json().unwrap();
assert!(json.contains("\"$schema\":\"ferro-json-ui/v1\""));

Re-exports§

pub use action::Action;
pub use action::ActionOutcome;
pub use action::ConfirmDialog;
pub use action::DialogVariant;
pub use action::HttpMethod;
pub use action::NotifyVariant;
pub use component::AlertProps;
pub use component::AlertVariant;
pub use component::AvatarProps;
pub use component::BadgeProps;
pub use component::BadgeVariant;
pub use component::BreadcrumbItem;
pub use component::BreadcrumbProps;
pub use component::ButtonProps;
pub use component::ButtonVariant;
pub use component::CardProps;
pub use component::CheckboxProps;
pub use component::Column;
pub use component::ColumnFormat;
pub use component::Component;
pub use component::ComponentNode;
pub use component::DescriptionItem;
pub use component::DescriptionListProps;
pub use component::FormProps;
pub use component::IconPosition;
pub use component::InputProps;
pub use component::InputType;
pub use component::ModalProps;
pub use component::Orientation;
pub use component::PaginationProps;
pub use component::PluginProps;
pub use component::ProgressProps;
pub use component::SelectOption;
pub use component::SelectProps;
pub use component::SeparatorProps;
pub use component::Size;
pub use component::SkeletonProps;
pub use component::SortDirection;
pub use component::SwitchProps;
pub use component::Tab;
pub use component::TableProps;
pub use component::TabsProps;
pub use component::TextElement;
pub use component::TextProps;
pub use config::JsonUiConfig;
pub use data::resolve_path;
pub use data::resolve_path_string;
pub use layout::footer;
pub use layout::global_registry;
pub use layout::navigation;
pub use layout::register_layout;
pub use layout::render_layout;
pub use layout::sidebar;
pub use layout::AppLayout;
pub use layout::AuthLayout;
pub use layout::DefaultLayout;
pub use layout::Layout;
pub use layout::LayoutContext;
pub use layout::LayoutRegistry;
pub use layout::NavItem;
pub use layout::SidebarSection;
pub use plugin::collect_plugin_assets;
pub use plugin::global_plugin_registry;
pub use plugin::register_plugin;
pub use plugin::registered_plugin_types;
pub use plugin::with_plugin;
pub use plugin::Asset;
pub use plugin::CollectedAssets;
pub use plugin::JsonUiPlugin;
pub use plugin::PluginRegistry;
pub use plugins::register_built_in_plugins;
pub use plugins::MapPlugin;
pub use render::collect_plugin_types;
pub use render::render_to_html;
pub use render::render_to_html_with_plugins;
pub use render::RenderResult;
pub use resolve::resolve_actions;
pub use resolve::resolve_actions_strict;
pub use resolve::resolve_errors;
pub use resolve::resolve_errors_all;
pub use view::JsonUiView;
pub use view::SCHEMA_VERSION;
pub use visibility::Visibility;
pub use visibility::VisibilityCondition;
pub use visibility::VisibilityOperator;
pub use serde_json;

Modules§

action
Action declarations for JSON-UI components.
component
Component catalog for JSON-UI.
config
Configuration for JSON-UI rendering.
data
Data path resolution for JSON-UI.
layout
Layout system for JSON-UI page rendering.
plugin
Plugin system for JSON-UI custom interactive components.
plugins
Built-in plugin components for JSON-UI.
render
HTML render engine for JSON-UI views.
resolve
Resolvers for JSON-UI component trees.
view
Top-level view container for JSON-UI.
visibility
Conditional visibility rules for JSON-UI components.