import type { SchemaBuilder } from '@cleverbrush/schema'; import type { ReactNode } from 'react'; /** * A renderer function that receives field state and returns a React node. */ export type FieldRenderer = (props: FieldRenderProps) => ReactNode; /** * Props passed to a field renderer. */ export type FieldRenderProps = { value: any; initialValue: any; dirty: boolean; touched: boolean; error: string | undefined; validating: boolean; onChange: (value: any) => void; onBlur: () => void; setValue: (value: any) => void; schema: SchemaBuilder; /** * Rendering variant hint passed from the `Field` component. * Used by renderers to select a sub-variant of the base schema type * (e.g. `"password"` for a string field rendered as a password input). * * Also participates in renderer resolution: when set, the renderer * registry is first checked for `"type:variant"` (e.g. `"string:password"`) * before falling back to the base `"type"` key. * * @example * ```tsx * t.secret} form={form} variant="password" /> * ``` */ variant?: string; /** * Visible label text forwarded from the `Field` component. * Renderers can use this to render a `