@schema-render/core-react
Version:
Through a set of simple JSON Schema, efficiently build a set of forms.
30 lines (29 loc) • 1.01 kB
TypeScript
import type { IObjectAny } from '../typings/common';
interface ITraverseParams<S extends IObjectAny = IObjectAny> {
schema: S;
parentSchema?: S;
path: string[];
state: IObjectAny;
store: IObjectAny;
}
interface IVisitorMethodParams<S extends IObjectAny = IObjectAny> extends ITraverseParams<S> {
field: string;
}
interface IVisitor<S extends IObjectAny = IObjectAny> {
[type: string]: {
enter?: (p: IVisitorMethodParams<S> & {
traverse: (p?: Partial<ITraverseParams<S>>) => void;
}) => void;
exit?: (p: IVisitorMethodParams<S>) => void;
};
}
interface IOptions {
mapKey?: string;
ignoreCase?: boolean;
clone?: boolean;
initialState?: IObjectAny;
initialStore?: IObjectAny;
}
export declare function isInvalidTraverseSchema({ properties }: ITraverseParams['schema']): boolean;
export default function traverseSchema<S extends IObjectAny = IObjectAny>(schema: S, visitor: IVisitor<S>, options?: IOptions): S;
export {};