UNPKG

@rjsf/utils

Version:
19 lines (18 loc) 1.28 kB
import type { FormContextType, Registry, RJSFSchema, StrictRJSFSchema, UiSchema } from './types.js'; /** Resolves the uiSchema for a given schema, considering `ui:definitions` stored in the registry. * * Called at runtime for each field. When the schema contains a `$ref`, looks up the corresponding * uiSchema definition from `registry.uiSchemaDefinitions` and merges it with local overrides. * For schemas with `oneOf`/`anyOf` branches, also populates `uiSchema[keyword][i]` for branches * whose `$ref` matches a definition, so `MultiSchemaField` can read dropdown option titles. * * Resolution order (later sources override earlier): * 1. `ui:definitions[$ref]` - base definition from registry * 2. `localUiSchema` - local overrides at current path * * @param schema - The JSON schema (may contain `$ref` or `RJSF_REF_KEY`) * @param localUiSchema - The uiSchema at the current path (local overrides) * @param registry - The registry containing `uiSchemaDefinitions` * @returns - The resolved uiSchema with definitions merged in */ export default function resolveUiSchema<T = any, S extends StrictRJSFSchema = RJSFSchema, F extends FormContextType = any>(schema: S, localUiSchema: UiSchema<T, S, F> | undefined, registry: Registry<T, S, F>): UiSchema<T, S, F>;