|
1 |
| -import { createContext } from "react"; |
| 1 | +import { createContext, FC } from "react"; |
2 | 2 | import { ISchemaFieldCore } from "../types";
|
3 | 3 |
|
4 |
| -export type IComponentContainer<T = any> = ( |
5 |
| - _propsContainer: { |
6 |
| - data: T extends ISchemaFieldCore ? |
7 |
| - NonNullable<T["initialValue"]>[0] extends object ? |
8 |
| - NonNullable<T["initialValue"]>[0] : any |
9 |
| - : any; children: any; schema: T |
10 |
| - }) => any |
| 4 | +export type IComponentContainerProps<T = any> = { |
| 5 | + data: T extends ISchemaFieldCore ? |
| 6 | + NonNullable<T["initialValue"]>[0] extends object ? |
| 7 | + NonNullable<T["initialValue"]>[0] : any |
| 8 | + : any; children: any; schema: T |
| 9 | +} |
11 | 10 |
|
12 |
| -export type IComponent<T> = (_props: { |
| 11 | +export type IComponentProps<T> = { |
13 | 12 | schema: T;
|
14 | 13 | wrapper?: any;
|
15 | 14 | schemas?: any[];
|
16 |
| -}) => any |
17 |
| -export type IComponentGroup<T> = (_props: { |
| 15 | +}; |
| 16 | +export type IComponentGroupProps<T> = { |
18 | 17 | schema: T;
|
19 | 18 | wrapper?: any;
|
20 | 19 | children: any;
|
21 | 20 | schemas?: any[];
|
22 |
| -}) => any |
23 |
| -export type IComponentArray<T> = (_props: { |
| 21 | +}; |
| 22 | +export type IComponentArrayProps<T> = { |
24 | 23 | schema: T;
|
25 | 24 | wrapper?: any;
|
26 | 25 | schemas?: any[];
|
27 |
| - children: (_propsChildren: { |
| 26 | + children: FC<{ |
28 | 27 | value: any[],
|
29 |
| - container: IComponentContainer<T> |
30 |
| - }) => any; |
31 |
| -}) => any |
32 |
| -export type IComponentObject<T> = (_props: { |
| 28 | + container: FC<IComponentContainerProps<T>> |
| 29 | + }> |
| 30 | +}; |
| 31 | +export type IComponentObjectProps<T> = { |
33 | 32 | schema: T;
|
34 | 33 | wrapper?: any;
|
35 | 34 | schemas?: any[];
|
36 |
| - children: (_propsChildren: { |
| 35 | + children: FC<{ |
37 | 36 | value: Record<string, any>,
|
38 |
| - container: IComponentContainer<T> |
39 |
| - }) => any; |
40 |
| -}) => any |
| 37 | + container: FC<IComponentContainerProps<T>> |
| 38 | + }> |
| 39 | +}; |
41 | 40 | // Record<IVariant, Record<string, Component<any>>>;
|
42 | 41 | // ;
|
43 | 42 | export type IComponents = {
|
44 |
| - FIELD: Record<string, IComponent<any>>; |
45 |
| - VIEW: Record<string, IComponent<any>>; |
46 |
| - GROUP: Record<string, IComponentGroup<any>>; |
47 |
| - "FIELD-ARRAY": Record<string, IComponentArray<any>>; |
48 |
| - "FIELD-OBJECT": Record<string, IComponentObject<any>>; |
| 43 | + FIELD: Record<string, FC<IComponentProps<any>>>; |
| 44 | + VIEW: Record<string, FC<IComponentProps<any>>>; |
| 45 | + GROUP: Record<string, FC<IComponentGroupProps<any>>>; |
| 46 | + "FIELD-ARRAY": Record<string, FC<IComponentArrayProps<any>>>; |
| 47 | + "FIELD-OBJECT": Record<string, FC<IComponentObjectProps<any>>>; |
49 | 48 | };
|
50 | 49 |
|
51 | 50 | export const ComponentContext = createContext<{ components: IComponents }>({
|
|
0 commit comments