/** * Structure Context * * Immutable context object threaded through the form rendering tree. * Provides access to schema, definition, path, and computed properties. */ import type { JSONStructureSchema, TypeDefinition, TypeKeyword, Altnames } from './structure-types'; import { RefResolver } from './ref-utils'; import type { WidgetRegistry } from './widgets/widget-registry'; /** * Options for creating a StructureContext */ export interface StructureContextOptions { /** Root schema document */ schema: JSONStructureSchema; /** Current type definition being rendered */ definition: TypeDefinition; /** Path from root to current position */ path: ReadonlyArray; /** Form-level read-only mode */ readOnly?: boolean; /** Locale for altnames resolution */ locale?: string; /** Custom widget registry */ widgetRegistry?: WidgetRegistry; /** Whether this property is required by parent */ isPropertyRequired?: boolean; /** Whether to suppress label rendering */ suppressLabel?: boolean; /** Shared ref resolver for the schema */ refResolver?: RefResolver; } /** * Updates that can be passed to context.with() */ export interface StructureContextUpdates { definition?: TypeDefinition; path?: ReadonlyArray; readOnly?: boolean; locale?: string; widgetRegistry?: WidgetRegistry; isPropertyRequired?: boolean; suppressLabel?: boolean; } /** * Immutable context for JSON Structure form rendering */ export declare class StructureContext { readonly schema: JSONStructureSchema; readonly definition: TypeDefinition; readonly path: ReadonlyArray; readonly readOnly: boolean; readonly locale: string | undefined; readonly widgetRegistry: WidgetRegistry | undefined; readonly isPropertyRequired: boolean; readonly suppressLabel: boolean; private readonly refResolver; constructor(options: StructureContextOptions); /** * Create a new context with updated fields */ with(updates: StructureContextUpdates): StructureContext; /** * Create a child context by appending to the path */ append(segment: PropertyKey): StructureContext; /** * Check if this is the root context */ get isRoot(): boolean; /** * Get the property name (last segment of path) */ get name(): string | undefined; /** * Get the widget name (dot-separated path) */ get widgetName(): string; /** * Get the resolved type(s) from the definition */ get resolvedType(): TypeKeyword | TypeKeyword[] | null; /** * Get the primary type (first non-null type) */ get primaryType(): TypeKeyword | null; /** * Check if this type is nullable */ get isNullable(): boolean; /** * Check if this is a required field */ get isRequired(): boolean; /** * Check if this is an optional field (can be absent) */ get isOptional(): boolean; /** * Check if this field is deprecated */ get isDeprecated(): boolean; /** * Check if this type is abstract */ get isAbstract(): boolean; /** * Check if this is a primitive type */ get isPrimitive(): boolean; /** * Get the description from the definition */ get description(): string | undefined; /** * Get examples from the definition */ get examples(): unknown[] | undefined; /** * Get the default value from the definition */ get defaultValue(): unknown; /** * Get the unit for numeric values */ get unit(): string | undefined; /** * Get the currency for monetary values */ get currency(): string | undefined; /** * Get the label for this field * * Resolution order: * 1. Locale-specific altname (if locale is set) * 2. Definition name * 3. Humanized path name */ get label(): string; /** * Get altnames from the definition */ get altnames(): Altnames | undefined; /** * Get the JSON path string (for validation error matching) */ get jsonPath(): string; /** * Resolve a $ref using the shared resolver */ resolveRef(ref: string): TypeDefinition | undefined; /** * Check if this definition has an enum constraint */ get hasEnum(): boolean; /** * Get enum values if present */ get enumValues(): unknown[] | undefined; /** * Check if this definition has a const constraint */ get hasConst(): boolean; /** * Get const value if present */ get constValue(): unknown; /** * Get string format if defined (for string types) */ get format(): string | undefined; } /** * Create a root context from a schema */ export declare function createStructureContext(schema: JSONStructureSchema, options?: Partial>): StructureContext;