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. Includes a Touch Mode toggle for testing mobile-friendly sizing.

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 — accepts eSheet FormDefinition, FHIR R4 Questionnaire, SurveyJS schema, or MCP elicitation envelope. Auto-detected and converted internally.
onChange(def: FormDefinition) => void--Called when the form definition changes (any edit, reorder, add, remove)
dragEnabledbooleantrueWhether drag-and-drop reordering is enabled. When false, field reordering is disabled entirely — there is no fallback UI (e.g. arrow buttons).
classNamestring''Additional CSS class for the root container
touchModeboolean | 'auto'--Touch mode for preview: true, false, 'auto', or omit for CSS-only
onTouchModeChange(enabled: boolean) => void--Callback when touch mode changes
childrenReactNode--Content rendered between the header and the editor layout

See Touch Mode for details on mobile-friendly form preview.

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