Skip to main content

API Reference

Quick reference of all public exports from each eSheet package.

@esheet/core

Types

ExportKindDescription
FormDefinitionInterfaceTop-level form structure
FieldDefinitionInterfaceSingle field structure
FieldResponseInterfaceResponse values for a field
FormResponseType aliasRecord<string, FieldResponse>
SelectedOptionInterface{ id, value } for selected options
FieldTypeTypeUnion of 19 field type strings
TextInputTypeTypeUnion of 9 text input variants
FieldOptionInterfaceOption in a choice field
MatrixRow / MatrixColumnInterfaceMatrix dimensions
ConditionalRuleInterfaceConditional rule structure
ConditionInterfaceSingle condition
ConditionTypeType'field' | 'expression' | 'js'
ConditionOperatorTypeUnion of 10 operators
ConditionalEffectType'visible' | 'enable' | 'required'
LogicModeType'AND' | 'OR'
FieldCategoryTypeField grouping category
AnswerTypeTypeHow a field stores its answer
RankedAnswerInterfaceRanked answer item
AttachmentAnswerInterfaceAttachment answer item
AnswerValueTypeUnion of all possible answer value types
FormResponseEnvelopeInterfaceEnvelope wrapping FormResponse with metadata
FieldTypeMetaInterfaceField type metadata
FieldTypeRegistryTypeRegistry map
FieldComponentPropsInterfaceProps contract for field components
ResponseItemInterface{ id, text, answer } — one per answerable field, returned by hydrateResponse
FieldNodeInterfaceNode in normalized definition tree
OptionBearingFieldDefinitionTypeUnion of field definitions that have options
NormalizedDefinitionInterfaceFlat normalized representation of a form
AddFieldOptionsInterfaceOptions for FormStore.addField()
TextFieldDefinitionInterfaceDefinition for text fields
LongtextFieldDefinitionInterfaceDefinition for longtext fields
MultitextFieldDefinitionInterfaceDefinition for multitext fields
RadioFieldDefinitionInterfaceDefinition for radio fields
CheckFieldDefinitionInterfaceDefinition for check fields
BooleanFieldDefinitionInterfaceDefinition for boolean fields
DropdownFieldDefinitionInterfaceDefinition for dropdown fields
MultiselectDropdownFieldDefinitionInterfaceDefinition for multiselect dropdown fields
RatingFieldDefinitionInterfaceDefinition for rating fields
RankingFieldDefinitionInterfaceDefinition for ranking fields
SliderFieldDefinitionInterfaceDefinition for slider fields
SingleMatrixFieldDefinitionInterfaceDefinition for single-select matrix fields
MultiMatrixFieldDefinitionInterfaceDefinition for multi-select matrix fields
ImageFieldDefinitionInterfaceDefinition for image fields
HtmlFieldDefinitionInterfaceDefinition for HTML fields
SignatureFieldDefinitionInterfaceDefinition for signature fields
DiagramFieldDefinitionInterfaceDefinition for diagram fields
DisplayFieldDefinitionInterfaceDefinition for display fields
SectionFieldDefinitionInterfaceDefinition for section fields

Type Predicates

ExportDescription
hasOptionsType predicate for fields with options property

Constants

ExportDescription
FIELD_TYPESArray of 19 field type strings
TEXT_INPUT_TYPESArray of 9 text input type strings
CONDITION_OPERATORSArray of 10 operator strings
CONDITIONAL_EFFECTSArray of 3 effect strings
CONDITION_TYPES['field', 'expression', 'js'] as const

Zod Schemas

ExportValidates
formDefinitionSchemaFormDefinition
fieldDefinitionSchemaFieldDefinition
fieldTypeSchemaFieldType
conditionSchemaCondition
conditionalRuleSchemaConditionalRule
conditionOperatorSchemaConditionOperator
conditionTypeSchemaConditionType
fieldOptionSchemaFieldOption
matrixRowSchemaMatrixRow
matrixColumnSchemaMatrixColumn
formDefinitionJSONSchemaJSON Schema (Draft-07) for Monaco

Store Factories

ExportReturnsDescription
createFormStore(def?)FormStoreCreate a new form state store
createUIStore()UIStoreCreate a new UI state store

Logic & Validation

ExportDescription
evaluateRule(rule, normalized, responses)Evaluate a conditional rule
evaluateCondition(condition, definition, response)Evaluate a single condition
evaluateExpression(expression, normalized, responses)Evaluate a safe expression string
evaluateJsExpression(expression, normalized, responses)Evaluate an arbitrary JS expression (dangerous — host opt-in)
isExpressionValid(expr)Validate safe expression syntax
resolveEffect(effect, field, normalized, responses)Resolve a conditional effect for a field
validateField(fieldId, normalized, responses)Validate a single field
validateForm(normalized, responses)Validate all fields

Utilities

ExportDescription
normalizeDefinition(def)Convert tree → flat normalized state
hydrateDefinition(normalized)Convert flat → nested tree
hydrateResponse(normalized, responses)Walk normalized definition and return ResponseItem[] for export/submission
normalizeResponses(responses)Normalize raw form responses to resolved values
extractResponseValue(fieldDef, response)Extract the primary answer value from a field response
generateFieldId(fieldType)Generate a unique field ID
generateOptionId()Generate a unique option ID
generateRowId()Generate a unique matrix row ID
generateColumnId()Generate a unique matrix column ID
formatZodValidationError(error)Format Zod validation errors into readable strings

Registry

ExportDescription
registerFieldType(key, meta)Register a field type
registerFieldElements(elements)Batch-register UI element classes for field types
getFieldTypeMeta(key)Get field type metadata
getRegisteredFieldTypes()List all registered types

@esheet/fields

Components

All 19 field components: TextField, LongTextField, MultiTextField, RadioField, CheckField, BooleanField, DropdownField, MultiSelectDropdownField, RatingField, RankingField, SliderField, SingleMatrixField, MultiMatrixField, SectionField, DisplayField, HtmlField, ImageField, SignatureField, DiagramField

Custom Controls

ExportDescription
CustomRadioStyled radio with onSelect/onUnselect
CustomCheckboxStyled checkbox
CustomDropdownStyled dropdown
DrawingPadCanvas drawing component

Drawing Types

ExportDescription
DrawingDataDrawing canvas data structure
DrawingPadConfigConfiguration options for DrawingPad
DrawingPadPayloadPayload emitted by DrawingPad on change
NormalizedPoint{ x, y } coordinate normalized to canvas size
StrokeSingle stroke in a drawing (array of NormalizedPoint)

Icons

ExportDescription
TrashIconTrash / delete icon
PlusIconPlus / add icon
ArrowUpIconArrow up icon
ArrowDownIconArrow down icon
UpDownArrowIconUp-down (reorder) arrow icon

Registry

ExportDescription
registerCustomFieldTypes(types)Register custom field types with components
registerFieldComponents(map)Register a map of field type -> React component
getFieldComponent(fieldType)Get the React component for a field type
getRegisteredComponentKeys()List all registered field component keys

Validation UI

ExportDescription
ZodIssuesPanelPanel component for displaying Zod error lists

Touch Mode

ExportDescription
useTouchMode()Hook for auto/manual touch mode detection

Context

ExportDescription
FormStoreContextReact context for FormStore
UIContextReact context for UIStore
useFormStore()Hook to access FormStore
useUI()Hook to access UIStore

@esheet/builder

Components

ExportDescription
EsheetBuilderMain builder component
BuilderHeaderMode switcher header (advanced)
CodeViewJSON/YAML editor (advanced)
FieldWrapperSelection chrome wrapper (advanced)

Hooks & Context

ExportDescription
useFormStore()Access FormStore from context
useUI()Access UIStore from context
useInstanceId()Get unique instance ID
FormStoreContextFormStore React context
UIContextUIStore React context
InstanceIdContextInstance ID React context
useFormApi()Hook returning imperative form API
useUiApi()Hook returning imperative UI API
useVisibleRootIds()Hook returning visible root field IDs

MCP Integration

ExportDescription
executeToolCallExecute a builder tool call
BUILDER_TOOL_DEFINITIONSArray of MCP tool definitions for builder
BUILDER_SYSTEM_PROMPTSystem prompt describing builder tools
useBuilderMcpToolHandlerHook for handling MCP tool calls in React

Types

ExportDescription
EsheetBuilderPropsBuilder component props
EsheetBuilderHandleRef handle (isTouchModeEnabled, setTouchMode, resetTouchMode)
BuilderToolsMCP tool facade returned by onBuilderToolsReady
FieldSummarySummary of a field in the builder
CodeViewPropsProps for CodeView
FieldWrapperPropsProps for FieldWrapper
FieldWrapperRenderPropsRender props passed to FieldWrapper children
FormApiImperative form API interface
FieldResponseMapMap of field IDs to responses
UiApiImperative UI API interface
ToolDefinitionMCP tool definition type
UseBuilderMcpToolHandlerOptionsOptions for useBuilderMcpToolHandler

@esheet/renderer

Components

ExportDescription
EsheetRendererMain renderer component (forwardRef)
RendererBodyInner renderer body (advanced)
FieldNodeRenders a single field node inside the renderer (advanced)

Hooks

ExportDescription
useRendererInit()Initialize renderer with form data (advanced)

MCP Integration

ExportDescription
executeToolCallExecute a renderer tool call
RENDERER_TOOL_DEFINITIONSArray of MCP tool definitions for renderer
RENDERER_SYSTEM_PROMPTSystem prompt describing renderer tools
useRendererMcpToolHandlerHook for handling MCP tool calls in React

Types

ExportDescription
EsheetRendererPropsRenderer component props
EsheetRendererHandleRef handle (getRawResponse, getResponse, getValidResponse, getFormStore, getUIStore, touch)
ResponseFormat'native' | 'fhir'
GetResponseOptionsOptions for getResponse() (format, FHIR metadata)
GetResponseResultGeneric return type for getResponse() — narrows to format
RendererToolsType for renderer MCP tool names
ToolDefinitionMCP tool definition type
UseRendererMcpToolHandlerOptionsOptions for useRendererMcpToolHandler

EsheetRendererProps

PropTypeDefaultDescription
formDataInputunknownrequiredForm definition (object, JSON string, YAML string, FHIR, MCP, SurveyJS)
classNamestring''Additional CSS class for the root container
initialResponsesFormResponse--Pre-fill response data
allowDangerousJSbooleanfalseOpt-in to allow JS calculations and conditionType: 'js'
strictbooleanfalseDisable auto-detection, require a valid FormDefinition
onReady() => void--Called when the renderer is initialized
onRendererToolsReady(tools: RendererTools) => void--Called with MCP tool handler when ready
touchModeboolean | 'auto'--Touch mode: true, false, 'auto', or omit for CSS-only
onTouchModeChange(enabled: boolean) => void--Callback when touch mode changes

@esheet/renderer-standalone

Functions

ExportDescription
mountStandaloneRenderer(container, props)Mount EsheetRenderer into a DOM node and return a control handle

Types

ExportDescription
EsheetRendererStandaloneHandleHandle with unmount(), getResponse(), and getValidResponse()

@esheet/renderer-blaze

Functions

ExportDescription
registerBlazeTemplate(templateName?)Register a Blaze template wrapper for the renderer. Returns false when required Blaze globals are not available, otherwise true.

registerBlazeTemplate uses esheetRenderer as the default template name when no argument is provided.


@esheet/adapters

Bidirectional converters for external schema formats.

See the Adapters section in the sidebar for detailed documentation including:

  • Adapters Overview — Installation, auto-detection, and all exports
  • SurveyJS Adapter — Import/export, type mapping, conditional logic
  • MCP Adapter — Import/export, constraints, type mapping
  • FHIR Adapter — Import/export FHIR R4 Questionnaire resources and QuestionnaireResponse

@esheet/field-kerebron

Optional rich text editor field. Install separately; not included in @esheet/fields by default.

Functions

ExportDescription
configureRichTextField(options)Initialize the Kerebron editor. Call once at app startup before rendering any richtext fields. Accepts { assetLoad }.

Components

ExportDescription
RichTextEditorFieldField component for the richtext field type

Types

ExportDescription
RichTextFieldDefinitionField definition type for richtext

See kerebron for full setup instructions.