@canard/schema-form
Version:
React-based component library that renders forms based on JSON Schema with plugin system support for validators and UI components
21 lines (20 loc) • 999 B
TypeScript
import type { SetStateFn } from '../@aileron/declare';
import type { AllowedValue, JsonSchema, ValidatorFactory } from '../types';
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?: SetStateFn<Value>;
validationMode?: ValidationMode;
validatorFactory?: ValidatorFactory;
}
/**
* 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, }: NodeFromSchemaProps<Schema, Value>) => InferSchemaNode<Schema>;
export {};