/**
 * Widget Props Types
 *
 * Runtime props for field widgets - combines field config with runtime context
 */
import type { ComponentType, ReactNode } from 'react';
import type { FormBackend } from '../backend/types';
import type { FieldConfig } from './types';
/**
 * Function for rendering child fields (used by container widgets like GroupField/RepeaterField)
 */
export type RenderChildField = (childConfig: FieldConfig, childPath: string) => ReactNode;
/**
 * Props for field widget components
 *
 * @template TValue - The type of value this field manages
 * @template TConfig - The specific field config type (e.g., TextFieldConfig, GroupFieldConfig)
 */
export interface FieldWidgetProps<TValue = unknown, TConfig extends FieldConfig = FieldConfig> {
    /** Runtime path to this field (e.g., 'title', 'items.0.name') */
    path: string;
    /** Form backend for reading/writing values */
    backend: FormBackend;
    /** Field configuration (pure definition) */
    config: TConfig;
    /** Function to render child fields (required for container widgets like group/repeater) */
    renderChild?: RenderChildField;
}
/**
 * Type for field widget components
 *
 * Widgets are strongly typed with specific config types (TextFieldConfig, etc.) for
 * type safety within their implementation. At the registry boundary, type assertions
 * are used to store them in a homogeneous collection (see registry/widgets.ts).
 *
 * This is safe because:
 * 1. The field.type discriminant ensures the correct widget is selected
 * 2. Each widget receives its expected config subtype at runtime
 * 3. The type system prevents accessing properties that don't exist on BaseFieldConfig
 */
export type FieldWidgetComponent<TValue = unknown, TConfig extends FieldConfig = FieldConfig> = ComponentType<FieldWidgetProps<TValue, TConfig>>;
/**
 * Widget registry - maps field type strings to their components
 *
 * This is a heterogeneous collection where each widget has different type parameters,
 * stored with a common base type for lookup. See registry/widgets.ts for implementation.
 */
export type WidgetRegistry = Record<string, FieldWidgetComponent>;
