/** * UI Schema Type Definitions * * Core type definitions for the llm2ui system. * These types define the structure of UI components that can be * generated by LLMs and rendered dynamically. */ /** * Style properties that can be applied to any component */ export interface StyleProps { /** CSS class names */ className?: string; /** Inline styles */ style?: Record; /** Width (CSS value) */ width?: string | number; /** Height (CSS value) */ height?: string | number; /** Margin (CSS value) */ margin?: string | number; /** Padding (CSS value) */ padding?: string | number; /** Display property */ display?: 'block' | 'inline' | 'flex' | 'grid' | 'none'; /** Flex direction */ flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse'; /** Justify content */ justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly'; /** Align items */ alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline'; /** Gap between flex/grid items */ gap?: string | number; /** Background color */ backgroundColor?: string; /** Text color */ color?: string; /** Font size */ fontSize?: string | number; /** Font weight */ fontWeight?: string | number; /** Border radius */ borderRadius?: string | number; /** Border */ border?: string; } /** * Event binding configuration for component interactions */ export interface EventBinding { /** Event type (e.g., 'click', 'change', 'submit') */ event: string; /** Action to perform */ action: EventAction; } /** * Possible actions that can be triggered by events */ export type EventAction = { type: 'navigate'; url: string; } | { type: 'submit'; endpoint?: string; } | { type: 'update'; path: string; value: unknown; } | { type: 'toggle'; path: string; } | { type: 'custom'; handler: string; params?: Record; }; /** * Data context for data binding * Contains the data that can be bound to UI components */ export interface DataContext { /** Arbitrary data that can be bound to components */ [key: string]: unknown; } /** * UI Component definition * Represents a single UI component in the schema */ export interface UIComponent { /** Unique identifier for the component */ id: string; /** Component type (e.g., 'Button', 'Input', 'Card') */ type: string; /** Component properties */ props?: Record; /** Style properties */ style?: StyleProps; /** Child components */ children?: UIComponent[]; /** Text content (for leaf components) */ text?: string; /** Data binding expression (e.g., '{{user.name}}') */ binding?: string; /** Event bindings */ events?: EventBinding[]; /** Conditional rendering expression */ condition?: string; /** Loop rendering configuration */ loop?: { /** Data source path */ source: string; /** Item variable name */ itemName?: string; /** Index variable name */ indexName?: string; }; } /** * UI Schema - the root structure for defining a UI * This is the main type that LLMs generate and the renderer consumes */ export interface UISchema { /** Schema version for compatibility */ version: string; /** Root component of the UI tree */ root: UIComponent; /** Data context for data binding */ data?: DataContext; /** Schema metadata */ meta?: { /** Schema title/name */ title?: string; /** Schema description */ description?: string; /** Creation timestamp */ createdAt?: string; /** Last update timestamp */ updatedAt?: string; /** Author information */ author?: string; }; } /** * Validation result for schema validation */ export interface ValidationResult { /** Whether the schema is valid */ valid: boolean; /** Validation errors if any */ errors: ValidationError[]; } /** * Validation error details */ export interface ValidationError { /** Error path in the schema */ path: string; /** Error message */ message: string; /** Error code for programmatic handling */ code: string; } //# sourceMappingURL=ui-schema.d.ts.map