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 design;
36pub mod expression;
37pub mod layout;
38pub mod loader;
39pub mod plugin;
40pub mod plugins;
41pub mod render;
42pub mod resolve;
43pub mod spec;
44pub mod visibility;
45
46pub mod runtime;
47
48pub use action::{Action, ActionOutcome, ConfirmDialog, HttpMethod};
49pub use assets::leaflet::{leaflet_image, LEAFLET_CSS, LEAFLET_JS};
50pub use assets::FERRO_BASE_CSS;
51pub use component::{
52    ActionCardProps, ActionGroupProps, ActionItem, AlertProps, AvatarProps, BadgeProps,
53    BreadcrumbItem, BreadcrumbProps, ButtonGroupProps, ButtonProps, ButtonType, CardAppearance,
54    CardProps, CheckboxListProps, CheckboxProps, ChecklistItem, ChecklistProps, CollapsibleProps,
55    Column, ColumnFormat, DataTableProps, DescriptionItem, DescriptionListProps,
56    DropdownMenuAction, EmptyStateProps, FormMaxWidth, FormProps, FormSectionProps, GapSize,
57    GridProps, HeaderProps, IconPosition, ImageProps, InputProps, InputType, KanbanBoardProps,
58    KanbanColumnProps, ModalProps, NotificationDropdownProps, NotificationItem, Orientation,
59    PageHeaderProps, PaginationProps, ProgressProps, RawHtmlProps, RichTextEditorProps,
60    SegmentedControlProps, SegmentedItem, SelectOption, SelectProps, SeparatorProps, SidebarGroup,
61    SidebarLayoutItem, SidebarLayoutProps, SidebarNavItem, SidebarProps, Size, SkeletonProps,
62    SortDirection, StatCardProps, SwitchProps, Tab, TableProps, TabsProps, TextElement, TextProps,
63    TileProps, ToastProps, Tone, Variant,
64};
65pub use config::JsonUiConfig;
66pub use design::{lint, rules, DesignMeta, DesignRule, Finding, Severity, KNOWN_INTENTS};
67pub use runtime::FERRO_RUNTIME_JS;
68// resolve_path and resolve_path_string are pub(crate) — internal render pipeline helpers
69pub use layout::{
70    register_layout, render_layout, DashboardLayout, DashboardLayoutConfig, Layout, LayoutContext,
71    LayoutRegistry, NavItem, SidebarSection,
72};
73// AppLayout, AuthLayout, DefaultLayout are pub in layout.rs but not user-facing — users select
74// layouts by name string ("dashboard", "app", "auth"), not by struct.
75// navigation, sidebar, footer, global_registry are framework-internal.
76pub use catalog::{global_catalog, Catalog, CatalogError, ComponentSpec};
77pub use expression::resolve_expressions;
78pub use loader::{load_cached, LoadError};
79pub use plugin::{
80    collect_plugin_assets, global_plugin_registry, register_plugin, registered_plugin_types,
81    with_plugin, Asset, CollectedAssets, JsonUiPlugin, PluginRegistry,
82};
83pub use plugins::{register_built_in_plugins, MapPlugin, RichTextEditorPlugin};
84pub use render::{render_spec_to_html, render_spec_to_html_with_plugins, RenderResult};
85pub use resolve::{
86    expand_directives, resolve_actions, resolve_actions_strict, resolve_errors, resolve_errors_all,
87};
88pub use spec::{
89    DataRef, Element, ElementBuilder, Spec, SpecBuilder, SpecError, TitleBinding,
90    MAX_NESTING_DEPTH, SCHEMA_VERSION,
91};
92pub use visibility::{Visibility, VisibilityCondition, VisibilityOperator};
93
94#[cfg(feature = "projections")]
95pub mod projection;
96
97#[cfg(feature = "projections")]
98pub use projection::{JsonUiRenderer, ProjectionError, RenderMode, VisualContext};
99
100#[cfg(feature = "projections")]
101pub use projection::intent_layout::{default_template, register_template};