import { AddFieldOptions } from '@esheet/core'; import { BuilderMode } from '@esheet/core'; import { createUIStore } from '@esheet/core'; import { default as default_2 } from 'react'; import { EditTab } from '@esheet/core'; import { FieldComponentProps } from '@esheet/core'; import { FieldDefinition } from '@esheet/core'; import { FieldNode } from '@esheet/core'; import { FieldResponse } from '@esheet/core'; import { FieldType } from '@esheet/core'; import { FieldTypeMeta } from '@esheet/core'; import { FormDefinition } from '@esheet/core'; import { FormStore } from '@esheet/core'; import { FormStoreContext } from '@esheet/fields'; import { getFieldComponent } from '@esheet/fields'; import { getRegisteredComponentKeys } from '@esheet/fields'; import { NormalizedDefinition } from '@esheet/core'; import { registerCustomFieldTypes } from '@esheet/fields'; import { UIContext } from '@esheet/fields'; import { UIState } from '@esheet/core'; import { UIStore } from '@esheet/core'; import { useFormStore } from '@esheet/fields'; import { useUI } from '@esheet/fields'; export declare const BUILDER_SYSTEM_PROMPT: string; export declare const BUILDER_TOOL_DEFINITIONS: readonly ToolDefinition[]; /** * BuilderHeader — top bar with Build/Code/Preview mode toggle and Import/Export actions. */ export declare function BuilderHeader({ allowDangerousJS, }: BuilderHeaderProps): default_2.JSX.Element; export declare interface BuilderHeaderProps { /** When false (default), hides the JS toggle and prevents enabling dangerous JS. */ allowDangerousJS?: boolean; } export { BuilderMode } /** * Narrow interface exposed to MCP / AI tools via `onBuilderToolsReady`. * Only the operations an external AI agent needs — no raw store internals. */ export declare interface BuilderTools { /** Add a new field. Returns the generated ID, or null for unknown type. */ addField: (fieldType: FieldType, opts?: AddFieldOptions) => string | null; /** Patch a field's properties. Returns false if the field was not found. */ updateField: (fieldId: string, patch: Record) => boolean; /** Remove a field. Returns false if not found. */ removeField: (fieldId: string) => boolean; /** Find a field ID by exact ID or partial question match. */ resolveFieldId: (fieldId?: string, fieldQuestion?: string) => string | undefined; /** Replace the entire form with a new definition. */ resetForm: (definition: { id?: string; fields: Record[]; }) => void; /** Generate a form from a list of plain question descriptors. */ generateForm: (questions: { question: string; fieldType?: string; required?: boolean; inputType?: string; options?: string[]; }[]) => string; /** Snapshot of the current form suitable for AI context. */ getFormSummary: () => { formId: string; fieldCount: number; fields: FieldSummary[]; }; /** Set a response value for a field (for testing in preview mode). Returns true on success, false if field not found, or an error string if the value format is invalid. */ fillField: (fieldId: string, value: unknown) => boolean | string; /** Clear all responses. */ clearResponses: () => void; /** Get current responses keyed by field ID. */ getResponses: () => Record; /** Granular option mutations (radio, check, dropdown, etc.). */ option: { add: (fieldId: string, value?: string) => string | null; update: (fieldId: string, optionId: string, value: string) => boolean; setScore: (fieldId: string, optionId: string, score: number | undefined) => boolean; remove: (fieldId: string, optionId: string) => boolean; }; /** Granular row mutations (matrix fields). */ row: { add: (fieldId: string, value?: string) => string | null; update: (fieldId: string, rowId: string, value: string) => boolean; remove: (fieldId: string, rowId: string) => boolean; }; /** Granular column mutations (matrix fields). */ column: { add: (fieldId: string, value?: string) => string | null; update: (fieldId: string, columnId: string, value: string) => boolean; setScore: (fieldId: string, columnId: string, score: number | undefined) => boolean; remove: (fieldId: string, columnId: string) => boolean; }; /** Move a field to a new index. */ moveField: (fieldId: string, toIndex: number, toParentId?: string | null) => boolean; /** Get a single field node by ID. */ getField: (fieldId: string) => FieldNode | undefined; /** List all registered field type keys and their labels. */ getFieldTypes: () => { key: string; label: string; category: string; hasOptions: boolean; hasMatrix: boolean; }[]; /** Get full spec for a single field type (properties, capabilities, defaults). */ getFieldSpec: (fieldType: string) => FieldTypeMeta | undefined; /** Export the full form definition tree (inverse of loadDefinition). */ getDefinition: () => FormDefinition; /** Update the form's top-level ID without replacing fields. */ setFormId: (id: string) => void; } /** * CodeView — Monaco-based JSON/YAML editor for the form definition. * * Serialize on mount, live-validate on edit, auto-save on unmount. */ export declare function CodeView({ form, ui }: CodeViewProps): default_2.JSX.Element; export declare interface CodeViewProps { form: FormStore; ui: UIStore; } export { createUIStore } export { EditTab } export declare const EsheetBuilder: default_2.ForwardRefExoticComponent>; declare interface EsheetBuilderHandle { /** Returns true if touch mode is currently enabled */ isTouchModeEnabled: () => boolean; /** Toggle touch mode on/off. Only works when touchMode prop is 'auto' or undefined. */ setTouchMode: (enabled: boolean) => void; /** Reset to auto-detection mode (clears manual override). Only works when touchMode='auto'. */ resetTouchMode: () => void; } export declare interface EsheetBuilderProps { /** Initial form definition to load. Also accepts SurveyJS, MCP elicitation, or FHIR Questionnaire schemas, which are auto-converted. */ definition?: FormDefinition | Record; /** Callback fired when the form definition changes. */ onChange?: (definition: FormDefinition) => void; /** * Opt-in to allow dangerously embedded JavaScript in this builder instance. * When `false` (default), the JS toggle is hidden and any `dangerouslyAllowJS: true` * flag in the loaded schema is suppressed — JS never executes regardless of schema content. * Only set to `true` when you fully control and trust the form schemas being authored. */ allowDangerousJS?: boolean; /** * Called once after the builder mounts, providing a narrow `BuilderTools` * facade for MCP / AI tool integrations. Not intended for general developer use — * everything a developer needs is available through the builder's own UI and props. */ onBuilderToolsReady?: (tools: BuilderTools) => void; /** Whether drag-and-drop reordering is enabled (default: true). When false, field reordering is disabled entirely — no fallback UI (e.g. arrow buttons) is shown. */ dragEnabled?: boolean; /** Additional CSS class name. */ className?: string; /** Optional content rendered below the header (e.g. custom status/debug panels). */ children?: default_2.ReactNode; /** * Enable touch-optimized mode with larger touch targets in preview mode. * - `true`: Always enable touch mode * - `false`: Never enable touch mode (CSS media query still applies) * - `'auto'`: Enable based on viewport width (<980px) via JavaScript * - `undefined`: Rely on CSS media query only (default) */ touchMode?: boolean | 'auto'; /** Called when touch mode changes (via auto-detection or programmatic toggle). */ onTouchModeChange?: (enabled: boolean) => void; } export declare function executeToolCall(toolName: string, args: ToolArgs, tools: BuilderTools): string | Record; export { FieldComponentProps } export { FieldDefinition } export declare type FieldResponseMap = Record; /** Summary of a single field, suitable for AI context. */ export declare interface FieldSummary { id: string; fieldType: string; question: string | undefined; required: boolean; options: { id: string; value: string; }[]; rows: { id: string; value: string; }[]; columns: { id: string; value: string; }[]; /** Which tool family to use: 'add_option' for option-based fields, 'add_row / add_column' for matrix fields. */ editWith: string; /** True if this field has conditional logic rules attached. Use get_field to inspect them. */ hasRules: boolean; /** Required value format for structured input types (date, datetime-local, month, time). Use this exact format when calling fill_field. */ valueFormat?: string; /** True if this field already has a response value. False means it is still empty and needs to be filled. */ hasValue: boolean; /** Section child fields (only present when fieldType === 'section'). */ children?: FieldSummary[]; } /** * FieldWrapper - Extensibility API for custom field components. * * Wraps a field with collapsible header, selection highlighting, edit/delete buttons, and drag handles. * Exposes field data and tools to the render function, allowing users to create * custom field types while getting all the built-in editor functionality. * * @example * ```tsx * * {({ field, onUpdate, onRemove }) => ( *
* onUpdate({ question: e.target.value })} * /> *
* )} *
* ``` */ export declare function FieldWrapper({ fieldId, form, ui, dragHandleRef, isSelectedOverride, onSelectOverride, selectedVariant, forceExpandVersion, forceCollapseVersion, computedValue, children, }: FieldWrapperProps): default_2.JSX.Element | null; export declare interface FieldWrapperProps { /** The field ID */ fieldId: string; /** The form store */ form: FormStore; /** The UI store */ ui: UIStore; /** Ref attached to the drag-handle element. */ dragHandleRef?: default_2.RefObject; /** Optional override for selection state (used by nested section child interaction). */ isSelectedOverride?: boolean; /** Optional override for click selection behavior. */ onSelectOverride?: (e: default_2.MouseEvent) => void; /** Optional selected styling variant. */ selectedVariant?: 'default' | 'nested'; /** Optional signal used to force expand a field wrapper (used for section drop UX). */ forceExpandVersion?: number; /** Optional signal used to force collapse a field wrapper. */ forceCollapseVersion?: number; /** Computed value from setValue effects (if applicable). */ computedValue?: string | number | null; /** Render function that receives field data and tools */ children: (props: FieldWrapperRenderProps) => default_2.ReactNode; } /** * Props exposed to the render function for custom field components. * Identical to `FieldComponentProps` from core — kept as a named alias for * backward-compatibility with existing builder consumers. */ export declare type FieldWrapperRenderProps = FieldComponentProps; export declare interface FormApi { field: FieldNode | undefined; response: FieldResponse | undefined; isVisible: boolean; isEnabled: boolean; isRequired: boolean; isReadOnly: boolean; isSoftRequired: boolean; normalized: NormalizedDefinition; responses: FieldResponseMap; instanceId: string; form: { addField: (type: FieldType, opts?: AddFieldOptions) => string | null; loadDefinition: FormStore['getState'] extends () => infer S ? S extends { loadDefinition: infer F; } ? F : never : never; setFormId: (id: string) => void; hydrateDefinition: () => ReturnType['hydrateDefinition']>; hydrateResponse: () => ReturnType['hydrateResponse']>; resetResponses: () => void; }; field_: { update: (patch: Partial>) => boolean; remove: () => boolean; move: (toIndex: number, toParentId?: string | null) => boolean; setResponse: (resp: FieldResponse) => void; clearResponse: () => void; }; option: { add: (value?: string) => string | null; update: (optId: string, value: string) => boolean; setScore: (optId: string, score: number | undefined) => boolean; remove: (optId: string) => boolean; }; row: { add: (value?: string) => string | null; update: (rowId: string, value: string) => boolean; remove: (rowId: string) => boolean; }; column: { add: (value?: string) => string | null; update: (colId: string, value: string) => boolean; setScore: (colId: string, score: number | undefined) => boolean; remove: (colId: string) => boolean; }; _form: FormStore; } export { FormDefinition } export { FormStoreContext } export { getFieldComponent } export { getRegisteredComponentKeys } export declare const InstanceIdContext: default_2.Context; export { registerCustomFieldTypes } declare type ToolArgs = Record; export declare interface ToolDefinition { type: string; function: { name: string; description: string; parameters: Record; }; } export declare interface UiApi { mode: BuilderMode; selectedFieldId: string | null; selectedFieldChildId: string | null; editTab: EditTab; codeEditorHasError: boolean; selectField: (id: string | null) => void; selectFieldChild: (parentId: string, childId: string | null) => void; setMode: (m: BuilderMode) => void; setEditTab: (tab: EditTab) => void; setEditModalOpen: (open: boolean) => void; clearDragState: () => void; _ui: UIStore; } export { UIContext } export { UIState } export { UIStore } /** * Listens for AI tool-call events on a target element and dispatches them to * the builder's MCP tool executor. Returns the `onBuilderToolsReady` callback * to pass to ``. * * @example – default (listens on document) * const onBuilderToolsReady = useBuilderMcpToolHandler(); * * * @example – scoped to a container element * const ref = React.useRef(null); * const onBuilderToolsReady = useBuilderMcpToolHandler({ target: ref.current ?? undefined }); *
* * @example – custom event name * const onBuilderToolsReady = useBuilderMcpToolHandler({ eventName: 'my-ai-tool-call' }); */ export declare function useBuilderMcpToolHandler(options: UseBuilderMcpToolHandlerOptions): (tools: BuilderTools) => void; export declare interface UseBuilderMcpToolHandlerOptions { /** * The DOM element to listen on for tool-call events. * Pass `document` to listen globally, or a specific element to scope it. */ target?: EventTarget; /** * The event name to listen for, e.g. `'ozwell-tool-call'`. */ eventName: string; } /** * useFormApi — reactive field state + form store actions. * * Touches only the FormStore. For UI state (mode, selection, tabs) use * useUiApi(). For the computed visible root IDs use useVisibleRootIds(). * * @param fieldId - The field to bind to. Pass undefined for form-level ops only. */ export declare function useFormApi(fieldId?: string): FormApi; export { useFormStore } /** Hook to access the per-instance ID for unique DOM element IDs. */ export declare function useInstanceId(): string; export { useUI } /** * useUiApi — lightweight hook for components that only need UI state/actions. * * Useful when you don't need field-scoped state. Requires UIContext provider. */ export declare function useUiApi(): UiApi; /** * useVisibleRootIds — returns the page-root field IDs to render for the active page. * * In build/code mode: all field IDs from the active page (via UIStore.activePagesId). * In preview mode: only IDs whose visibility rules evaluate to true. * * Requires both FormStoreContext and UIContext providers. * Uses a stable-ref cache so the array reference only changes when content does. */ export declare function useVisibleRootIds(): readonly string[]; export { }