forked from rjsf-team/react-jsonschema-form
/
index.ts
33 lines (26 loc) · 927 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { ComponentType } from "react";
import { FormContextType, RJSFSchema, StrictRJSFSchema } from "@rjsf/utils";
import { FormProps, ThemeProps, withTheme } from "@rjsf/core";
import Templates, { generateTemplates } from "./templates";
import Widgets, { generateWidgets } from "./widgets";
export function generateTheme<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any
>(): ThemeProps<T, S, F> {
return {
templates: generateTemplates<T, S, F>(),
widgets: generateWidgets<T, S, F>(),
};
}
const Theme = generateTheme();
export function generateForm<
T = any,
S extends StrictRJSFSchema = RJSFSchema,
F extends FormContextType = any
>(): ComponentType<FormProps<T, S, F>> {
return withTheme<T, S, F>(generateTheme<T, S, F>());
}
const Form = generateForm();
export { Form, Templates, Theme, Widgets, generateTemplates, generateWidgets };
export default Form;