Skip to main content

ferro_json_ui/
lib.rs

1//! # Ferro JSON-UI
2//!
3//! **Experimental:** The component schema and plugin interface may evolve.
4//!
5//! JSON-based server-driven UI schema types for the Ferro framework.
6//!
7//! This crate defines the typed foundation for JSON-UI: a declarative
8//! component system where the server sends JSON descriptions that are
9//! rendered to HTML. Components, actions, and visibility rules are all
10//! defined as Rust types with serde serialization.
11//!
12//! ## Schema Structure
13//!
14//! A JSON-UI view consists of:
15//! - **Components** - UI elements (Card, Table, Form, Button, etc.)
16//! - **Actions** - Handler references with confirmations and outcomes
17//! - **Visibility** - Conditional rendering based on data conditions
18//! - **View** - Top-level container with layout and title
19//!
20//! ## Example
21//!
22//! ```rust
23//! use ferro_json_ui::{JsonUiView, ComponentNode, Component, CardProps};
24//!
25//! let view = JsonUiView::new()
26//!     .title("Users")
27//!     .component(ComponentNode {
28//!         key: "header".to_string(),
29//!         component: Component::Card(CardProps {
30//!             title: "User Management".to_string(),
31//!             description: None,
32//!             children: vec![],
33//!             footer: vec![],
34//!         }),
35//!         action: None,
36//!         visibility: None,
37//!     });
38//!
39//! let json = view.to_json().unwrap();
40//! assert!(json.contains("\"$schema\":\"ferro-json-ui/v1\""));
41//! ```
42
43pub mod action;
44pub mod component;
45pub mod config;
46pub mod data;
47pub mod layout;
48pub mod plugin;
49pub mod plugins;
50pub mod render;
51pub mod resolve;
52pub mod view;
53pub mod visibility;
54
55pub use action::{Action, ActionOutcome, ConfirmDialog, DialogVariant, HttpMethod, NotifyVariant};
56pub use component::{
57    AlertProps, AlertVariant, AvatarProps, BadgeProps, BadgeVariant, BreadcrumbItem,
58    BreadcrumbProps, ButtonProps, ButtonVariant, CardProps, CheckboxProps, Column, ColumnFormat,
59    Component, ComponentNode, DescriptionItem, DescriptionListProps, FormProps, IconPosition,
60    InputProps, InputType, ModalProps, Orientation, PaginationProps, PluginProps, ProgressProps,
61    SelectOption, SelectProps, SeparatorProps, Size, SkeletonProps, SortDirection, SwitchProps,
62    Tab, TableProps, TabsProps, TextElement, TextProps,
63};
64pub use config::JsonUiConfig;
65pub use data::{resolve_path, resolve_path_string};
66pub use layout::{
67    footer, global_registry, navigation, register_layout, render_layout, sidebar, AppLayout,
68    AuthLayout, DefaultLayout, Layout, LayoutContext, LayoutRegistry, NavItem, SidebarSection,
69};
70pub use plugin::{
71    collect_plugin_assets, global_plugin_registry, register_plugin, registered_plugin_types,
72    with_plugin, Asset, CollectedAssets, JsonUiPlugin, PluginRegistry,
73};
74pub use plugins::{register_built_in_plugins, MapPlugin};
75pub use render::{collect_plugin_types, render_to_html, render_to_html_with_plugins, RenderResult};
76pub use resolve::{resolve_actions, resolve_actions_strict, resolve_errors, resolve_errors_all};
77pub use view::{JsonUiView, SCHEMA_VERSION};
78pub use visibility::{Visibility, VisibilityCondition, VisibilityOperator};
79
80// Re-export serde_json for convenience
81pub use serde_json;