Widget Builder Enhancement - Super Powerful Widget Creator
Transform widget-builder into the ultimate visual widget creation system aligned with modular universe vision
🎨 Widget Builder Enhancement Plan
Date: November 14, 2025
Goal: Transform widget-builder into a Ferrari/Lamborghini-level widget creator
Status: 📋 READY FOR IMPLEMENTATION
🎯 Vision Alignment
Based on the MASTER-INDEX documentation, the widget-builder must support:
From Widget → Module Evolution
Basic Widget → Widget + Properties → Widget + Logic (Singularity) → Full Module
Current State: Widget + Properties ✅
Next Level: Widget + Logic (Singularity) ← THIS IS OUR FOCUS
Integration Points
- Modular Universe - Widgets live in universes
- Singularity System - Logic blocks and flows
- Cutting Mechanic - Canvas division for layouts
- Widget Taxonomy - Classification and promotion rules
- AI Generation - Intelligent widget creation
🏗️ Current Architecture Analysis
What Exists
widget-builder/
├── components/
│ ├── widget-builder/ # Main editor
│ ├── widget-builder-workspace/ # Canvas area
│ ├── widget-visual-designer/ # Visual design tools
│ ├── widget-templates-gallery/ # Pre-built templates
│ └── ai-widget-generator/ # AI-powered creation
├── services/
│ ├── widget-storage.service # Universe-scoped storage
│ ├── widget-generator.service # Widget creation
│ └── basic-widget-registry # Widget registry
└── models/
├── widget.types # Type definitions
└── basic-widget.types # Basic widget types
What's Missing (Critical Gaps)
- ❌ Integration with @widgets library (8 new basic widgets)
- ❌ Singularity integration (logic blocks and flows)
- ❌ Widget promotion workflow (widget → module)
- ❌ Cutting mechanic support (layout containers)
- ❌ Module manifest generation (embeddableComponent export)
- ❌ Property group editor (visual property configuration)
- ❌ Responsive system (widthUnits/heightUnits support)
- ❌ Widget composition (nesting and containers)
🚀 Enhancement Roadmap
Phase 1: Foundation Integration (Week 1-2)
Goal: Connect widget-builder with the new @widgets architecture
1.1 Widget Registry Sync
// NEW: services/widget-registry-sync.service.ts
export class WidgetRegistrySyncService {
// Sync with @widgets WidgetMetadataRegistry
syncWithMainRegistry(): void {
// Pull all 20 widget types
// Map to widget-builder templates
// Enable instant widget creation
}
// Get widget component reference
getWidgetComponent(type: WidgetType): Type<any> {
// Return actual component class
// Enable live preview in builder
}
}
Benefits:
- Instant access to all 20 widget types
- Live preview using actual components
- Automatic property group discovery
1.2 Property Group Visual Editor
// NEW: components/property-group-editor/
export class PropertyGroupEditorComponent {
// Visual interface for editing PropertyGroup[]
// Drag-drop property reordering
// Add/remove/edit properties
// Real-time validation
// Integration with @widgets property system
propertyGroups = input<PropertyGroup[]>();
propertyGroupsChange = output<PropertyGroup[]>();
}
Features:
- Visual property group management
- Type dropdown (string/number/boolean/color/select/textarea)
- Responsive toggle per property
- getValue/setValue code generation
- Live preview of property panel
1.3 Responsive Units Support
// ENHANCE: models/widget.types.ts
export interface WidgetBuilderConfig {
// NEW: Per-dimension units
widthUnits?: 'px' | '%' | 'rem' | 'em' | 'vw';
heightUnits?: 'px' | '%' | 'rem' | 'em' | 'vh';
// Support for responsive breakpoints
breakpoints?: {
base: SizeConfig;
sm?: SizeConfig;
md?: SizeConfig;
lg?: SizeConfig;
xl?: SizeConfig;
'2xl'?: SizeConfig;
};
}
Phase 2: Singularity Integration (Week 3-4)
Goal: Add logic blocks and flows to widgets (Widget → Widget + Logic)
2.1 Logic Block Connector
// NEW: services/widget-singularity.service.ts
export class WidgetSingularityService {
// Attach logic blocks to widget events
attachLogicBlock(widgetId: string, event: string, blockId: string): void {
// onClick → trigger flow
// onChange → data transformation
// onLoad → initialization
}
// Widget becomes trigger point for flows
registerWidgetTriggers(widget: Widget): void {
// Register as action source
// Enable flow connections
}
}
2.2 Flow Designer Integration
// NEW: components/widget-flow-designer/
export class WidgetFlowDesignerComponent {
// Visual flow editor for widget logic
// Drag-drop logic blocks
// Connect widget events to flows
// Test flows in real-time
// Example flows:
// - Button click → API call → Update UI
// - Form submit → Validation → Save to DB
// - Input change → Filter list → Render results
}
Capabilities:
- Widget events as flow triggers
- Logic blocks attached to widget lifecycle
- Data transformations on widget properties
- Inter-widget communication flows
Phase 3: Widget Composition & Containers (Week 5-6)
Goal: Support nested widgets and cutting mechanic integration
3.1 Container Widget Builder
// NEW: components/container-widget-builder/
export class ContainerWidgetBuilderComponent {
// Visual editor for container layouts
// Cutting mechanic integration
// Nested widget placement
// Layout presets (flex, grid, free)
// Cutting mechanic support
enableCuttingMode(): void {
// Allow dividing container
// Create sections dynamically
// Assign widgets to sections
}
}
3.2 Widget Nesting System
// ENHANCE: models/widget.types.ts
export interface CompositeWidgetConfig {
// Container can hold child widgets
childWidgets: Widget[];
// Layout configuration
layout: 'free' | 'flex' | 'grid';
layoutConfig: ContainerLayoutConfig;
// Cutting mechanic data
dividers?: DividerConfig[];
}
Features:
- Drag widgets into containers
- Visual layout configuration
- Cutting mechanic for dynamic sections
- Responsive nesting rules
Phase 4: Widget Promotion System (Week 7-8)
Goal: Automatic Widget → Module promotion workflow
4.1 Promotion Analyzer
// NEW: services/widget-promotion-analyzer.service.ts
export class WidgetPromotionAnalyzerService {
// Analyze widget to determine if it should become a module
analyzeForPromotion(widget: Widget): PromotionAnalysis {
return {
shouldPromote: boolean;
reasons: PromotionTrigger[];
confidence: number;
recommendations: string[];
};
}
// 6 Automatic Promotion Triggers (from WIDGET-MODULE-TAXONOMY)
checkTriggers(widget: Widget): PromotionTrigger[] {
// 1. Has logic blocks attached
// 2. Has inter-widget communication
// 3. Manages state beyond properties
// 4. Has lifecycle hooks
// 5. Reused across multiple pages
// 6. Exports public actions
}
}
4.2 Module Manifest Generator
// NEW: services/module-manifest-generator.service.ts
export class ModuleManifestGeneratorService {
// Generate ModuleManifest from widget
generateManifest(widget: Widget): ModuleManifest {
return {
id: widget.id,
name: widget.name,
version: '1.0.0',
description: widget.description,
category: 'widget-generated',
// Widget becomes embeddableComponent
embeddableComponents: [{
id: widget.id,
componentType: widget.componentClass,
displayName: widget.name,
description: widget.description,
category: 'widget',
inputs: this.generateInputs(widget),
outputs: this.generateOutputs(widget),
metadata: widget.metadata
}],
// Logic blocks become publicActions
publicActions: this.generateActions(widget),
// Widget events become events
events: this.generateEvents(widget)
};
}
}
5-Step Promotion Workflow:
- Analyze: Check if widget meets promotion criteria
- Review: Show promotion analysis to user
- Confirm: User confirms promotion
- Generate: Create module manifest automatically
- Register: Add to ModuleRegistryService
Phase 5: AI-Powered Generation (Week 9-10)
Goal: Intelligent widget creation and enhancement
5.1 AI Widget Generator Enhancement
// ENHANCE: components/ai-widget-generator/
export class AIWidgetGeneratorComponent {
// NEW: Template-aware generation
generateFromDescription(description: string): Observable<Widget> {
// Analyze description
// Select appropriate base widget
// Generate property groups
// Add default logic blocks
// Create responsive configuration
}
// NEW: Widget enhancement suggestions
suggestEnhancements(widget: Widget): Enhancement[] {
// Suggest missing properties
// Recommend logic blocks
// Propose responsive improvements
// Identify promotion opportunities
}
}
5.2 Intelligent Property Generation
// NEW: services/ai-property-generator.service.ts
export class AIPropertyGeneratorService {
// Generate PropertyGroup from natural language
generatePropertyGroups(description: string): PropertyGroup[] {
// Parse requirements
// Determine property types
// Generate getValue/setValue
// Add validation rules
}
// Example:
// "Email input with validation and placeholder"
// → Generates properties: placeholder, value, required, validationPattern
}
📋 Detailed Feature Specifications
Feature 1: Live Widget Preview
// NEW: components/widget-live-preview/
export class WidgetLivePreviewComponent {
// Real-time preview using actual component
widget = input.required<Widget>();
// Render actual component from @widgets
private renderComponent(): void {
const componentType = this.widgetRegistry.getComponent(this.widget().type);
const componentRef = this.viewContainerRef.createComponent(componentType);
// Bind widget properties
componentRef.setInput('widget', this.widget());
componentRef.setInput('isPreview', true);
}
// Hot reload on property changes
// Test responsive breakpoints
// Simulate interactions
}
Feature 2: Code Generator
// NEW: services/widget-code-generator.service.ts (ENHANCE EXISTING)
export class WidgetCodeGeneratorService {
// Generate complete Angular component code
generateComponent(widget: Widget): GeneratedCode {
return {
component: this.generateComponentTS(widget),
template: this.generateTemplateHTML(widget),
styles: this.generateStylesSCSS(widget),
propertyGroups: this.generatePropertyGroupsTS(widget),
manifest: this.generateModuleManifest(widget)
};
}
// Generate with all Session 1.3 patterns
private generateComponentTS(widget: Widget): string {
return `
import { Component, input, computed, output } from '@angular/core';
import { Widget, BreakpointKey } from '@libs-foundational/core-models';
import { ResponsiveWidgetPropsDirective } from '@widgets';
export interface ${widget.name}Config {
${this.generateConfigInterface(widget)}
}
@Component({
selector: 'lib-${widget.id}',
standalone: true,
imports: [CommonModule, ResponsiveWidgetPropsDirective],
templateUrl: './${widget.id}.component.html',
styleUrl: './${widget.id}.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ${widget.name}Component {
readonly widget = input.required<Widget>();
readonly activeBreakpoint = input<BreakpointKey>('base');
// ... full component code
}
`;
}
}
Feature 3: Widget Variants Manager
// NEW: components/widget-variants-manager/
export class WidgetVariantsManagerComponent {
// Manage widget variations
widget = input.required<Widget>();
variants = computed(() => this.widget().variants || []);
// Create variant
createVariant(name: string): void {
// Clone base widget
// Allow property overrides
// Save as new variant
}
// Switch between variants
// Compare variants side-by-side
// Merge variant changes back to base
}
Feature 4: Property Binding System
// NEW: components/property-binding-editor/
export class PropertyBindingEditorComponent {
// Visual binding editor
// Connect properties to data sources
// Support expressions and transformations
createBinding(property: string, source: string): PropertyBinding {
return {
property: property,
source: source, // 'static' | 'computed' | 'store' | 'api'
expression: '', // Transformation expression
updateOn: 'change' // When to update
};
}
}
🎨 UI/UX Enhancements
Workspace Layout
┌────────────────────────────────────────────────────────────────┐
│ Widget Builder [Save] [Test] │
├────────────────────────────────────────────────────────────────┤
│ ┌─────────────┐ ┌──────────────────────────┐ ┌────────────┐ │
│ │ │ │ │ │ │ │
│ │ Widget │ │ Live Preview │ │ Properties │ │
│ │ Templates │ │ │ │ Panel │ │
│ │ │ │ [Actual Component] │ │ │ │
│ │ - Input │ │ │ │ • Name │ │
│ │ - Select │ │ Breakpoint: [base ▼] │ │ • Type │ │
│ │ - Button │ │ Zoom: [100% ▼] │ │ • Config │ │
│ │ - Checkbox │ │ │ │ │ │
│ │ - Radio │ │ ┌────────────────────┐ │ │ + Property │ │
│ │ - Icon │ │ │ │ │ │ Groups │ │
│ │ - Link │ │ │ Widget Render │ │ │ │ │
│ │ - Container │ │ │ │ │ │ • Variants │ │
│ │ │ │ └────────────────────┘ │ │ • Logic │ │
│ │ │ │ │ │ • Flows │ │
│ └─────────────┘ └──────────────────────────┘ └────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ Code Generator Output (TypeScript/HTML/SCSS) │ │
│ │ [Component] [Template] [Styles] [Property Groups] [Manifest]│
│ └──────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────┘
Toolbar Features
- Quick Actions: New, Save, Test, Export, Promote to Module
- View Modes: Design, Code, Split, Preview
- Breakpoint Selector: Base, SM, MD, LG, XL, 2XL
- Zoom Control: 50%, 75%, 100%, 125%, 150%
- AI Assistant: Generate, Enhance, Analyze
🔌 Integration Architecture
With @widgets Library
// widget-builder connects to @widgets registry
@Injectable()
export class WidgetBuilderIntegrationService {
private widgetRegistry = inject(WidgetMetadataRegistry);
private propertyRegistry = inject(PropertyRegistryService);
// Get all available widget types
getAvailableWidgets(): WidgetRegistration[] {
return this.widgetRegistry.getAllRegistrations();
}
// Get property groups for widget type
getPropertyGroups(type: WidgetType): PropertyGroup[] {
return this.propertyRegistry.getPropertyGroups(type);
}
// Create widget instance
createWidgetInstance(type: WidgetType): Widget {
return this.widgetFactory.createWidget(type);
}
}
With Singularity System
// widget-builder connects to singularity-lib
@Injectable()
export class WidgetSingularityBridgeService {
private logicBlockService = inject(LogicBlockService);
private flowService = inject(FlowService);
// Attach logic to widget event
attachLogic(widgetId: string, event: string, logicBlockId: string): void {
// Widget event → Logic block trigger
}
// Create flow for widget
createWidgetFlow(widgetId: string, flowConfig: FlowConfig): void {
// Widget action → Flow execution
}
}
With Modular Universe
// widget-builder saves to universe storage
@Injectable()
export class WidgetUniverseStorageService {
// Save widget to universe
async saveToUniverse(widget: Widget, universeId: string): Promise<void> {
// Universe-scoped storage
// Flash persistence
// Automatic sync
}
// Promote widget to module
async promoteToModule(widget: Widget, universeId: string): Promise<Module> {
// Generate manifest
// Register in ModuleRegistryService
// Make available for composition
}
}
📊 Success Metrics
Phase 1 Completion
- ✅ All 20 widget types accessible in builder
- ✅ Live preview using actual components
- ✅ Property group visual editor working
- ✅ Per-dimension units support
Phase 2 Completion
- ✅ Logic blocks attachable to widgets
- ✅ Flow designer integrated
- ✅ Widget events trigger flows
- ✅ Data transformations functional
Phase 3 Completion
- ✅ Container widgets with nesting
- ✅ Cutting mechanic integration
- ✅ Layout presets functional
- ✅ Responsive nesting rules
Phase 4 Completion
- ✅ Promotion analyzer working
- ✅ Module manifest auto-generation
- ✅ 5-step workflow complete
- ✅ ModuleRegistryService integration
Phase 5 Completion
- ✅ AI generation enhanced
- ✅ Property generation from NLP
- ✅ Enhancement suggestions working
- ✅ Promotion opportunities detected
🚀 Implementation Priority
HIGH PRIORITY (Weeks 1-4)
- Widget Registry Sync (Phase 1.1)
- Property Group Editor (Phase 1.2)
- Responsive Units (Phase 1.3)
- Singularity Integration (Phase 2)
MEDIUM PRIORITY (Weeks 5-8)
- Widget Composition (Phase 3)
- Promotion System (Phase 4)
FUTURE (Weeks 9+)
- AI Enhancements (Phase 5)
- Advanced Features
🎯 Immediate Next Steps
- Fix Remaining Build Errors ✅ DONE
- Create WidgetRegistrySyncService ← START HERE
- Build Property Group Editor
- Enhance Live Preview Component
- Add Singularity Connector
Status: 📋 READY TO IMPLEMENT
Estimated Effort: 10 weeks (5 phases × 2 weeks)
Dependencies: @widgets library ✅, singularity-lib, modular-universe
Next Session: Begin Phase 1.1 implementation
The widget-builder will become the ultimate widget creation tool, supporting the journey from simple widgets to intelligent modules! 🎨🚀