Skip to main content

ferro_json_ui/
lib.rs

1//! # Ferro JSON-UI
2//!
3//! JSON-based server-driven UI schema types for the Ferro framework.
4//!
5//! This crate defines the v2 `Spec` foundation: a flat, ID-keyed element map
6//! with parse-time structural validation. Typed `*Props` structs describe
7//! per-component prop shape and feed the Phase 117 catalog via `JsonSchema`.
8//!
9//! ## Schema Structure
10//!
11//! A JSON-UI Spec consists of:
12//! - **Spec** - Top-level container: `$schema`, `root`, `elements`, `title?`, `layout?`, `data?`
13//! - **Element** - Single UI node: `type` (string), `props` (Value), `children` (`Vec<String>` of IDs), `action?`, `visible?`
14//! - **Actions** - Handler references with confirmations and outcomes
15//! - **Visibility** - Conditional rendering based on data conditions
16//!
17//! ## Example
18//!
19//! ```rust
20//! use ferro_json_ui::{Spec, Element};
21//!
22//! let spec = Spec::builder()
23//!     .title("Demo")
24//!     .element("root", Element::new("Text").prop("content", "Hi"))
25//!     .build()
26//!     .unwrap();
27//! ```
28
29pub mod action;
30pub mod assets;
31pub mod catalog;
32pub mod component;
33pub mod config;
34pub mod data;
35pub mod expression;
36pub mod layout;
37pub mod loader;
38pub mod plugin;
39pub mod plugins;
40pub mod render;
41pub mod resolve;
42pub mod spec;
43pub mod visibility;
44
45pub mod runtime;
46
47pub use action::{Action, ActionOutcome, ConfirmDialog, DialogVariant, HttpMethod, NotifyVariant};
48pub use assets::FERRO_BASE_CSS;
49pub use component::{
50    ActionCardProps, ActionCardVariant, ActionGroupProps, ActionItem, AlertProps, AlertVariant,
51    AvatarProps, BadgeProps, BadgeVariant, BreadcrumbItem, BreadcrumbProps, ButtonGroupProps,
52    ButtonProps, ButtonType, ButtonVariant, CardProps, CardVariant, CheckboxListProps,
53    CheckboxProps, ChecklistItem, ChecklistProps, CollapsibleProps, Column, ColumnFormat,
54    DataTableProps, DescriptionItem, DescriptionListProps, DropdownMenuAction, EmptyStateProps,
55    FormMaxWidth, FormProps, FormSectionProps, GapSize, GridProps, HeaderProps, IconPosition,
56    ImageProps, InputProps, InputType, KanbanBoardProps, KanbanColumnProps, ModalProps,
57    NotificationDropdownProps, NotificationItem, Orientation, PageHeaderProps, PaginationProps,
58    ProductTileProps, ProgressProps, RawHtmlProps, RichTextEditorProps, SegmentedControlProps,
59    SegmentedItem, SelectOption, SelectProps, SeparatorProps, SidebarGroup, SidebarLayoutItem,
60    SidebarLayoutProps, SidebarNavItem, SidebarProps, Size, SkeletonProps, SortDirection,
61    StatCardProps, SwitchProps, Tab, TableProps, TabsProps, TextElement, TextProps, ToastProps,
62    ToastVariant,
63};
64pub use config::JsonUiConfig;
65pub use runtime::FERRO_RUNTIME_JS;
66// resolve_path and resolve_path_string are pub(crate) — internal render pipeline helpers
67pub use layout::{
68    register_layout, render_layout, DashboardLayout, DashboardLayoutConfig, Layout, LayoutContext,
69    LayoutRegistry, NavItem, SidebarSection,
70};
71// AppLayout, AuthLayout, DefaultLayout are pub in layout.rs but not user-facing — users select
72// layouts by name string ("dashboard", "app", "auth"), not by struct.
73// navigation, sidebar, footer, global_registry are framework-internal.
74pub use catalog::{global_catalog, Catalog, CatalogError, ComponentSpec};
75pub use expression::resolve_expressions;
76pub use loader::{load_cached, LoadError};
77pub use plugin::{
78    collect_plugin_assets, global_plugin_registry, register_plugin, registered_plugin_types,
79    with_plugin, Asset, CollectedAssets, JsonUiPlugin, PluginRegistry,
80};
81pub use plugins::{register_built_in_plugins, MapPlugin, RichTextEditorPlugin};
82pub use render::{render_spec_to_html, render_spec_to_html_with_plugins, RenderResult};
83pub use resolve::{
84    expand_directives, resolve_actions, resolve_actions_strict, resolve_errors, resolve_errors_all,
85};
86pub use spec::{
87    DataRef, Element, ElementBuilder, Spec, SpecBuilder, SpecError, TitleBinding,
88    MAX_NESTING_DEPTH, SCHEMA_VERSION,
89};
90pub use visibility::{Visibility, VisibilityCondition, VisibilityOperator};
91
92#[cfg(feature = "projections")]
93pub mod projection;
94
95#[cfg(feature = "projections")]
96pub use projection::{JsonUiRenderer, ProjectionError, RenderMode, VisualContext};