UNPKG

@canard/schema-form

Version:

React-based component library that renders forms based on JSON Schema with plugin system support for validators and UI components

24 lines (23 loc) 1.14 kB
import type { Fn } from '../@aileron/declare'; import type { AllowedValue, JsonSchema, ValidatorFactory } from '../types'; import { contextNodeFactory } from './nodes'; import type { ContextNode } from './nodes'; import type { InferSchemaNode, ValidationMode } from './nodes/type'; /** Properties interface for creating Node from JSON Schema */ interface NodeFromSchemaProps<Schema extends JsonSchema, Value extends AllowedValue> { jsonSchema: Schema; defaultValue?: Value; onChange: Fn<[value: Value]>; validationMode?: ValidationMode; validatorFactory?: ValidatorFactory; context?: ContextNode; } /** * Creates SchemaNode from JSON Schema. * @typeParam Schema - JSON Schema type * @typeParam Value - Value type, defaults to type inferred from Schema * @param props - Properties for Node creation * @returns Created SchemaNode */ export declare const nodeFromJsonSchema: <Schema extends JsonSchema, Value extends AllowedValue>({ jsonSchema, defaultValue, onChange, validationMode, validatorFactory, context, }: NodeFromSchemaProps<Schema, Value>) => InferSchemaNode<Schema>; export { contextNodeFactory };