Skip to main content

View Builder Package

The @repo/view-builder package provides a visual interface for creating and editing view schemas used by the @repo/view package. It offers a drag-and-drop canvas, component toolbox, JSON editor, and AI-assisted schema generation.

Features

  • Visual Builder: Drag-and-drop interface for creating view schemas
  • Live Preview: Real-time preview of the view being created
  • JSON Editor: Direct editing of the underlying JSON schema
  • AI Assistance: AI-powered suggestions for view creation
  • Schema Validation: Automatic validation of view schemas
  • Persistence: Save and load view schemas
  • Internationalization: Support for multiple languages

Installation

This package is part of the zopio monorepo and is available to all applications in the workspace.

Package Structure

The View Builder package is organized into several subpackages:
  • Canvas: Drag-and-drop interface for visual editing
  • Toolbox: Component palette for adding fields and elements
  • JSON Editor: Direct editing of the schema JSON
  • AI: AI-assisted schema generation
  • Hooks: React hooks for state management

Dependencies

The View Builder package depends on the following packages:
  • @repo/view: For rendering and validating view schemas
  • @repo/design-system: For UI components
  • @repo/crud: For schema definitions and field types

Basic Usage

Using the View Builder Component

Integrating with Custom Components

Using the Schema State Hook

Core Components

DragDropCanvas

The canvas component provides a visual interface for building views:

Toolbox

The toolbox component provides a palette of available components and fields:

JSONEditor

The JSON editor component allows direct editing of the schema JSON:

AIPromptPanel

The AI prompt panel provides AI-assisted schema generation:

Internationalization

The View Builder package supports internationalization using the same locales as the View package:
  • English (en)
  • Turkish (tr)
  • Spanish (es)
  • German (de)

Integration with View Package

The View Builder package is designed to work seamlessly with the View package:

Error Handling

The View Builder includes validation to prevent invalid schemas:

Advanced Usage

Custom Field Types

You can extend the View Builder with custom field types:

Schema Templates

You can provide predefined templates for common view types:

Conclusion

The View Builder package provides a powerful visual interface for creating and editing view schemas. It integrates seamlessly with the View package and supports a wide range of view types and field configurations.