/**
 * JSON Structure Form Component
 *
 * Main form component for JSON Structure schema-based forms.
 * Provides validation, error handling, and form state management.
 */
import { Value, Renderable } from '@tempots/dom';
import { Controller, ControllerValidation } from '../form';
import { FormattedValidationError } from './validation/error-transform';
import type { JSONStructureSchema } from './structure-types';
import type { WidgetRegistry } from './widgets/widget-registry';
/**
 * Validation mode for the form
 * - 'onSubmit': Validate only when form is submitted
 * - 'onTouched': Validate fields after they are touched
 * - 'eager': Validate fields as they change
 */
export type ValidationMode = 'onSubmit' | 'onTouched' | 'eager';
/**
 * Props for JSONStructureForm component
 */
export interface JSONStructureFormProps<T> {
    /** The JSON Structure schema to render as a form */
    schema: JSONStructureSchema;
    /**
     * Initial value for the form data.
     *
     * When omitted, the form will be auto-populated from schema defaults:
     * - `default` property values (highest priority)
     * - First item from `examples` array (fallback)
     * - Empty object for object schemas (last resort)
     *
     * When provided, schema defaults are merged with the provided value
     * (provided values take precedence) unless `applySchemaDefaults` is false.
     */
    initialValue?: Value<T>;
    /** Validation behavior - when to validate the form */
    validationMode?: ValidationMode;
    /** Debounce delay in milliseconds for validation */
    validateDebounceMs?: number;
    /** Optional widget registry for custom widgets */
    widgetRegistry?: WidgetRegistry;
    /** Make all fields read-only */
    readOnly?: boolean;
    /** Locale for internationalization */
    locale?: string;
    /** Called when form value changes */
    onChange?: (value: T) => void;
    /** Called when validation runs */
    onValidate?: (errors: FormattedValidationError[]) => void;
    /**
     * Whether to automatically populate form values from schema defaults.
     * When true, extracts `default` values (with `examples[0]` as fallback)
     * from the schema and merges them with the provided initialValue.
     * Provided values take precedence over schema defaults.
     *
     * @default true
     */
    applySchemaDefaults?: boolean;
}
/**
 * JSON Structure Form Component
 *
 * Renders a complete form based on a JSON Structure schema with validation.
 *
 * @example
 * ```typescript
 * JSONStructureForm(
 *   {
 *     schema: mySchema,
 *     initialValue: prop(initialData),
 *     validationMode: 'onTouched',
 *   },
 *   ({ Form, controller, setStatus }) => {
 *     return html.form(
 *       on.submit(async (e) => {
 *         e.preventDefault()
 *         // Validate and submit
 *         const value = controller.signal.value
 *         // ... handle submission
 *       }),
 *       Form,
 *       html.button(
 *         attr.type('submit'),
 *         'Submit'
 *       )
 *     )
 *   }
 * )
 * ```
 */
export declare function JSONStructureForm<T>({ schema, initialValue, validationMode, validateDebounceMs, widgetRegistry, readOnly, locale, onChange, onValidate, applySchemaDefaults, }: JSONStructureFormProps<T>, fn: ({ Form, controller, setStatus, }: {
    Form: Renderable;
    controller: Controller<T>;
    setStatus: (result: ControllerValidation) => void;
}) => Renderable): Renderable;
