import { E as StringConstraints, f as FileConstraints, j as WalkedField, t as ArrayConstraints, w as SchemaMeta, x as ObjectConstraints, y as NumberConstraints } from "./types-BBQaEPfE.mjs"; //#region src/core/renderer.d.ts /** * Flat intersection of all constraint types. * Used in renderer props where the render function receives the union * but knows (by resolver key) which subset applies. * * The walker's discriminated WalkedField enforces type-correct constraints * at construction time; the renderer consumes them as this flat type. */ type AllConstraints = StringConstraints & NumberConstraints & ArrayConstraints & ObjectConstraints & FileConstraints; /** * Properties available on every schema field, regardless of rendering target. * Both React and HTML renderers receive these. * * Per-type schema data — enum values, object fields, array element schema, * union options, record key/value types, tuple `prefixItems`, conditional * if/then/else clauses, negation `negated`, recursive `refTarget`, literal * values — lives on the discriminated `tree`. Renderers narrow on * `tree.type` and read from the matching variant; there are no duplicate * sibling fields on these props. */ interface BaseFieldProps { /** Current field value. */ value: unknown; /** Whether to render as read-only display. */ readOnly: boolean; /** Whether to render as an empty input. */ writeOnly: boolean; /** Schema metadata for this field. */ meta: SchemaMeta; /** Constraints from schema checks. */ constraints: AllConstraints; /** Dot-separated path from root (e.g. "address.city"). */ path: string; /** Example values from the schema's `examples` keyword. */ examples?: unknown[]; /** Walked field tree for recursive rendering. */ tree: WalkedField; } /** * Framework-agnostic base for the props passed to every render * function. Extends {@link BaseFieldProps} with a `renderChild` * callable whose return type is parameterised over `Output` — the type * the framework adapter emits per field (typically `unknown` / * `ReactNode` for React, `string` for HTML, framework-specific for * future Vue / Solid / Svelte / Lit adapters). * * The base `renderChild` is declared with a `...args: never[]` rest * parameter so derived adapter interfaces can override it with a * richer signature carrying extra required arguments (React's * `onChange`, HTML's `pathSuffix`, etc.). The `never[]` rest makes the * base callable signature the bottom of the function-subtype lattice: * every adapter's concrete `renderChild` is assignable to it because * `never` accepts any parameter type contravariantly. The base * therefore documents the shared shape — "given a `WalkedField` and a * value, produce an `Output`" — without preventing adapters from * adding required parameters. * * @typeParam Output - The type the framework adapter emits per field * (e.g. `ReactNode` / `unknown` for React, `string` for HTML). */ interface BaseRenderProps extends BaseFieldProps { /** * Render a child field. Theme adapters call this to recursively * render nested structures (object fields, array elements, union * options). Each adapter narrows the signature in its specialised * variant ({@link RenderProps}, {@link HtmlRenderProps}, …) to * match its native rendering primitives. */ renderChild: (...args: never[]) => Output; } /** * Props for React render functions. Extends {@link BaseRenderProps} with: * - `onChange` — callback to propagate value changes back to state * - `renderChild` — recursively renders a child field, threading * `onChange` through the four-argument React signature */ interface RenderProps extends BaseRenderProps { /** Callback to update the field value. */ onChange: (value: unknown) => void; /** * Render a child field. Theme adapters call this to recursively render * nested structures (object fields, array elements, union options). * The resolver and rendering context are already wired in. * * @param tree - The walked field tree for the child * @param value - The child's current value * @param onChange - Callback receiving the child's next value * @param pathSuffix - Path segment from the parent (e.g. "city", * "[0]"). Joined to the parent's path with a dot, or substituted * when the parent acts as a transparent wrapper (union options). * Required for every container — without it children inherit no * path and `inputId()` will throw. */ renderChild: (tree: WalkedField, value: unknown, onChange: (v: unknown) => void, pathSuffix?: string) => unknown; } /** * Props for HTML render functions. Extends {@link BaseRenderProps} with * a narrower three-argument `renderChild` and no `onChange` — HTML * rendering is pure output with no event handling. */ interface HtmlRenderProps extends BaseRenderProps { /** * Render a child field to an HTML string. Theme adapters call this * to recursively render nested structures. * * @param tree - The walked field tree for the child * @param value - The child's current value * @param pathSuffix - Path segment from the parent (e.g. "city", * "[0]"). When omitted, the child's description is used as fallback. */ renderChild: (tree: WalkedField, value: unknown, pathSuffix?: string) => string; } /** * Build the `RenderProps` object handed to a resolver render function or a * widget. Used by both the server-side `` (which has no * `onChange`) and the client-side `` (which threads an * `onChange` callback). * * When `onChange` is `undefined` the caller is rendering in read-only mode: * a noop `onChange` is wired up, `readOnly` is forced to `true`, and * `writeOnly` is forced to `false`. Otherwise the editability is taken * from `tree.editability`. */ declare function buildRenderProps(tree: WalkedField, value: unknown, onChange: ((next: unknown) => void) | undefined, renderChild: RenderProps["renderChild"], path: string): RenderProps; /** * Generic render-function signature parameterised over the output type * (`Output`) and the per-framework props shape (`Props`). * * The React adapter uses {@link RenderProps} with `unknown` output — see * the default specialisation below — and the HTML adapter uses * {@link HtmlRenderFunction} (an alias for * `RenderFunction\`). Future framework * adapters (Vue, Solid, Svelte, Lit) pick their own pairing. * * The default `Output = unknown, Props = RenderProps` keeps the historic * React-flavoured signature compatible — any caller writing * `RenderFunction` without type arguments gets exactly the previous * `(props: RenderProps) =\> unknown` shape. */ type RenderFunction = (props: Props) => Output; /** * Widget map — maps component hints (from `.meta({ component })`) to render * functions. A per-render bag consumed by every renderer surface that * dispatches widget overrides; conceptually parallel to * {@link ComponentResolver} but keyed by user-supplied hint names rather * than schema types. * * Scoped at three levels in the React renderer: * * 1. **Per-instance** — `widgets` prop on `` * 2. **Context-scoped** — `widgets` prop on `` * 3. **Global** — `registerWidget()` (app-wide defaults) * * Resolution order: instance → context → global → resolver → headless. */ type WidgetMap = ReadonlyMap; /** * Theme adapter — maps every schema field type to its React renderer. * Unset keys fall back to the headless resolver. Pass to * `SchemaProvider` (or `SchemaView.resolver`) to drive every * schema-driven render with a specific theme. */ interface ComponentResolver { string?: RenderFunction; number?: RenderFunction; boolean?: RenderFunction; null?: RenderFunction; enum?: RenderFunction; object?: RenderFunction; array?: RenderFunction; tuple?: RenderFunction; record?: RenderFunction; union?: RenderFunction; discriminatedUnion?: RenderFunction; conditional?: RenderFunction; negation?: RenderFunction; literal?: RenderFunction; file?: RenderFunction; never?: RenderFunction; unknown?: RenderFunction; } /** * An HTML render function returns a string. Specialisation of the * generic {@link RenderFunction} signature with `Output = string` and * `Props = HtmlRenderProps`. */ type HtmlRenderFunction = RenderFunction; /** * HTML resolver — maps schema types to HTML string renderers. * Structurally mirrors ComponentResolver but produces strings. */ interface HtmlResolver { string?: HtmlRenderFunction; number?: HtmlRenderFunction; boolean?: HtmlRenderFunction; null?: HtmlRenderFunction; enum?: HtmlRenderFunction; object?: HtmlRenderFunction; array?: HtmlRenderFunction; tuple?: HtmlRenderFunction; record?: HtmlRenderFunction; union?: HtmlRenderFunction; discriminatedUnion?: HtmlRenderFunction; conditional?: HtmlRenderFunction; negation?: HtmlRenderFunction; literal?: HtmlRenderFunction; file?: HtmlRenderFunction; never?: HtmlRenderFunction; unknown?: HtmlRenderFunction; } /** * Canonical list of resolver keys, one per {@link WalkedField} variant. * Iterated by the resolver merge helpers so adding a new key here is the * single point of change when a new field variant is introduced. */ declare const RESOLVER_KEYS: readonly ["string", "number", "boolean", "null", "enum", "object", "array", "tuple", "record", "union", "discriminatedUnion", "conditional", "negation", "literal", "file", "never", "unknown"]; type ResolverKey = (typeof RESOLVER_KEYS)[number]; /** * Map a schema type to the resolver key that handles it. * Every WalkedField variant has a direct resolver key — exhaustive switch * ensures new variants surface as a type error rather than silently * falling through to "unknown". */ declare function typeToKey(type: WalkedField["type"]): ResolverKey; /** * Look up the render function for a schema type in a ComponentResolver. */ declare function getRenderFunction(type: WalkedField["type"], resolver: ComponentResolver): RenderFunction | undefined; /** * Look up the render function for a schema type in an HtmlResolver. */ declare function getHtmlRenderFn(type: WalkedField["type"], resolver: HtmlResolver): HtmlRenderFunction | undefined; /** * Merge two ComponentResolvers — user values take priority, fallback fills gaps. */ declare function mergeResolvers(user: ComponentResolver, fallback: ComponentResolver): ComponentResolver; /** * Merge two HtmlResolvers — user values take priority, fallback fills gaps. */ declare function mergeHtmlResolvers(user: HtmlResolver, fallback: HtmlResolver): HtmlResolver; //#endregion export { typeToKey as _, HtmlRenderFunction as a, RESOLVER_KEYS as c, WidgetMap as d, buildRenderProps as f, mergeResolvers as g, mergeHtmlResolvers as h, ComponentResolver as i, RenderFunction as l, getRenderFunction as m, BaseFieldProps as n, HtmlRenderProps as o, getHtmlRenderFn as p, BaseRenderProps as r, HtmlResolver as s, AllConstraints as t, RenderProps as u };