Skip to main content

Builder Overview

The EsheetBuilder component provides a full visual form editor with drag-and-drop, property editing, conditional logic rules, and code editing.

Layout

Desktop (lg and above)

Three-column layout:

+----------+---------------------+--------------+
| ToolPanel| Canvas | EditPanel |
| | | |
| (field | (drag-and-drop | (edit tab |
| types | field list) | + logic |
| to add) | | tab) |
| | | |
+----------+---------------------+--------------+

Mobile / Tablet

Single-column with bottom-sheet drawers:

  • Canvas fills the screen
  • "Add Field" button opens the ToolPanel in a bottom drawer
  • Tapping a field opens the EditPanel in a bottom drawer

Three Modes

The builder header provides mode switching:

ModeDescription
BuildVisual editor -- drag-and-drop canvas with ToolPanel and EditPanel
CodeJSON/YAML editor (Monaco) -- edit the form definition as text
PreviewRead-only preview -- same rendering as the Renderer component

Component API

import { EsheetBuilder } from '@esheet/builder';

<EsheetBuilder
definition={myFormDef} // Initial FormDefinition
onChange={(def) => save(def)} // Called on every change
dragEnabled={true} // Drag-and-drop (default: true)
className="my-builder" // Additional CSS class
>
{/* Optional children below the header */}
</EsheetBuilder>;

Props Reference

PropTypeDefaultDescription
definitionFormDefinitionundefinedInitial form definition to load
onChange(def: FormDefinition) => void--Called when the form definition changes (any edit, reorder, add, remove)
dragEnabledbooleantrueWhether drag-and-drop is enabled. Disable for better performance on slow devices
classNamestring''Additional CSS class for the root container
childrenReactNode--Content rendered between the header and the editor layout

Exported Hooks & Contexts

The builder re-exports these from @esheet/fields for advanced use:

ExportTypeDescription
useFormStore()HookAccess the FormStore from React context
useUI()HookAccess the UIStore from React context
useInstanceId()HookGet the unique per-instance ID for DOM elements
FormStoreContextContextReact context providing the FormStore
UIContextContextReact context providing the UIStore
InstanceIdContextContextReact context providing the instance ID string